Skip to content

armgit / kanzo

Public Imported from GitHub
0

Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.

Merge main into fork-features

emanuele-emf7ab2a33f3fb
diff --cc README.md
index 45de60a,de6ca74..4ba9a7f
--- a/README.md
+++ b/README.md
@@@ -225,10 -211,11 +225,12 @@@ Everything lives in `~/kanzo`: the boar
port = 4242
listen = "127.0.0.1" # sharing opens the board to your network; "0.0.0.0" keeps it open
mcp_http = true # MCP at /mcp
+editor = "/usr/local/bin/cursor" # opens file:/// links; on macOS, your text editor without it
```
+ These settings stay on each machine: `kanzo sync` leaves them out.
+
-Settings on the board lists each task's properties, like tags or comments. Turn one off to hide it there and leave it out of what agents get; nothing is deleted. The board itself reads English or Chinese: pick the language under Settings → Board, and it remembers your choice.
+Settings on the board lists each task's properties, like tags or comments. Turn one off to hide it there and leave it out of what agents get; nothing is deleted. Its About section shows what's new in this version. The board itself reads English or Chinese: pick the language under Settings → Board, and it remembers your choice.
## Small and fast
diff --cc src/home.rs
index c512ce3,0fc7ec9..668a579
--- a/src/home.rs
+++ b/src/home.rs
@@@ -152,24 -158,9 +169,23 @@@ impl Home
return Err(store::Error::Invalid(format!("cannot lock kanzo.lock: {e}")));
}
}
- };
- Store::open(&self.db_path(), lock)
+ }
}
+ pub fn open_file(&self, file: &Path) -> Result<(), String> {
+ let mut cmd = editor_command(self.config.editor.as_deref(), file)?;
+ let program = cmd.get_program().to_string_lossy().into_owned();
+ let mut child = cmd
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .spawn()
+ .map_err(|e| format!("cannot run {program}: {e}; set `editor` in config.toml to its full path"))?;
+ // An editor's command can run for as long as the editor does: this isn't work for a database thread.
+ std::thread::spawn(move || child.wait());
+ Ok(())
+ }
+
pub fn images(&self) -> PathBuf {
self.dir.join("images")
}
@@@ -316,30 -287,38 +332,62 @@@ mod tests
assert_eq!(waiting.join().unwrap().unwrap(), 4);
}
+ #[test]
+ fn a_file_link_opens_in_an_editor_and_only_a_file() {
+ let tmp = tempfile::tempdir().unwrap();
+ let file = tmp.path().join("run.command");
+ fs::write(&file, "").unwrap();
+ let args = |cmd: &Command| cmd.get_args().map(|a| a.to_owned()).collect::<Vec<_>>();
+
+ let cmd = editor_command(Some(Path::new("/bin/cursor")), &file).unwrap();
+ assert_eq!(cmd.get_program(), "/bin/cursor");
+ assert_eq!(args(&cmd), [file.as_os_str()]);
+ if cfg!(target_os = "macos") {
+ let cmd = editor_command(None, &file).unwrap();
+ assert_eq!(cmd.get_program(), "open");
+ assert_eq!(args(&cmd), [std::ffi::OsStr::new("-t"), file.as_os_str()]);
+ } else {
+ assert!(editor_command(None, &file).is_err_and(|e| e.contains("editor")));
+ }
+
+ let editor = Some(Path::new("/bin/cursor"));
+ for bad in [Path::new("run.command"), tmp.path(), &tmp.path().join("missing")] {
+ assert!(editor_command(editor, bad).is_err(), "{}", bad.display());
+ }
+ }
+
+ #[test]
+ fn open_waits_for_a_pull_to_put_config_toml_back() {
+ let tmp = tempfile::tempdir().unwrap();
+ let home = Home::open(tmp.path().to_path_buf()).unwrap();
+ let config = home.dir.join("config.toml");
+ let lock = home.lock_exclusive().unwrap();
+ fs::write(&config, "listen = \"0.0.0.0\"\n").unwrap();
+
+ let opening = std::thread::spawn({
+ let dir = home.dir.clone();
+ move || Home::open(dir)
+ });
+ std::thread::sleep(Duration::from_millis(200));
+ assert!(!opening.is_finished());
+ fs::write(&config, "listen = \"127.0.0.1\"\n").unwrap();
+ drop(lock);
+ assert!(opening.join().unwrap().unwrap().config.listen.is_loopback());
+ }
+
+ #[test]
+ fn open_restores_a_config_toml_left_aside_by_a_crash() {
+ let tmp = tempfile::tempdir().unwrap();
+ fs::write(tmp.path().join("config.toml.bak"), "listen = \"0.0.0.0\"\n").unwrap();
+ // What git had pulled when the sync died.
+ fs::write(tmp.path().join("config.toml"), "port = 4300\n").unwrap();
+
+ let home = Home::open(tmp.path().to_path_buf()).unwrap();
+ assert!(!home.config.listen.is_loopback());
+ assert_eq!(home.config.port, DEFAULT_PORT);
+ assert!(!home.config_aside().exists());
+ }
+
#[test]
fn no_lock_only_when_unsupported() {
assert!(unsupported(&io::Error::from(io::ErrorKind::Unsupported)));