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.
Rust ai-agentsclaude-codeclicodexcoding-agentskanbanlocal-firstmcpmcp-servermodel-context-protocolproductivityproject-managementraspberry-pirustself-hostedsqlitetask-manager
Make the columns' roles configurable
Edward Niewold36fe072a3bb3
diff --git a/README.md b/README.mdindex 6748fba..bb0140c 100644--- a/README.md+++ b/README.md@@ -84,7 +84,10 @@ Everything lives in `~/kanzo`: the board in `kanzo.db`, settings in `config.toml```tomlport = 4242listen = "127.0.0.1" # "0.0.0.0" opens the board to your network: no logins, so only on one you trust-statuses = ["todo", "doing", "review", "done"] # new tasks go first, the last counts as done+statuses = ["backlog", "todo", "doing", "review", "done"] # the last counts as done+collapsed = ["backlog", "done"] # start as thin strips on the board+inbox = "todo" # new tasks go here, and agents take their next task from here+working = "doing" # ... and move it heremcp_http = true # MCP at /mcp```diff --git a/src/app.js b/src/app.jsindex 32ea89c..11168e6 100644--- a/src/app.js+++ b/src/app.js@@ -129,18 +129,28 @@ function projectColor(slug) {return PROJECT_COLORS[projectColorName(slug)];}+// How many columns a status is past the inbox, where new tasks go: negative for the+// columns before it, like backlog, and 0 for a status the board doesn't know.+function statusStep(status) {+ const { statuses, inbox } = state.board;+ const i = statuses.indexOf(status);+ return i < 0 ? 0 : i - Math.max(statuses.indexOf(inbox), 0);+}+function statusColor(status) {- const i = state.board ? state.board.statuses.indexOf(status) : 0;+ const i = state.board ? statusStep(status) : 0;return STATUS_COLORS[Math.max(i, 0) % STATUS_COLORS.length];}-// A column's status as a small progress circle, as in Linear: empty for the first column,-// filling up across the board, a check for the last. A shape, so it can't be taken for a-// project's colour dot.+// A column's status as a small progress circle, as in Linear: dashed before the inbox,+// empty for the inbox, filling up across the board, a check for the last. A shape, so it+// can't be taken for a project's colour dot.function statusIcon(status) {- const { statuses } = state.board;- const f = statuses.length > 1 ? Math.max(statuses.indexOf(status), 0) / (statuses.length - 1) : 0;+ const { statuses, inbox } = state.board;+ const step = statusStep(status), steps = statuses.length - 1 - Math.max(statuses.indexOf(inbox), 0);+ const f = steps > 0 ? Math.max(step, 0) / steps : 0;const color = statusColor(status);+ const dash = step < 0 ? ' stroke-dasharray="2.36 2.36"' : "";let inside = "";if (f >= 1) {inside = `<circle cx="7" cy="7" r="6" fill="${color}"/>` +@@ -151,7 +161,7 @@ function statusIcon(status) {inside = `<path d="M7 7L7 ${7 - r}A${r} ${r} 0 ${f > 0.5 ? 1 : 0} 1 ${x} ${y}Z" fill="${color}"/>`;}const span = el("span", { class: "status-icon" });- span.innerHTML = `<svg viewBox="0 0 14 14" aria-hidden="true"><circle cx="7" cy="7" r="6" fill="none" stroke="${color}" stroke-width="1.5"/>${inside}</svg>`;+ span.innerHTML = `<svg viewBox="0 0 14 14" aria-hidden="true"><circle cx="7" cy="7" r="6" fill="none" stroke="${color}" stroke-width="1.5"${dash}/>${inside}</svg>`;return span;}@@ -503,25 +513,26 @@ function renderColumns() {columns.style.display = "";// Build the columns once per layout so a refresh never wipes a half-typed task.- const layout = statuses.join(",") + "|" + state.project;+ const { collapsed, inbox } = state.board;+ const layout = [statuses.join(","), collapsed.join(","), inbox, state.project].join("|");if (state.layout !== layout) {state.layout = layout;- columns.replaceChildren(...statuses.map((status, i) => {- const last = i === statuses.length - 1;+ columns.replaceChildren(...statuses.map((status) => {+ const collapsible = collapsed.includes(status);const col = el("section", { class: "column", "data-status": status },el("h2", {},statusIcon(status), status,el("span", { class: "count" }),// At the top, so a long column never hides it.- i === 0 ? el("button", { class: "add", title: "Add task (n)", "aria-label": "Add task", onclick: newTask }, icon("plus")) : null,- last ? el("button", { class: "collapse", onclick: (e) => { e.stopPropagation(); setDoneCollapsed(!doneCollapsed()); } }) : null),+ status === inbox ? el("button", { class: "add", title: "Add task (n)", "aria-label": "Add task", onclick: newTask }, icon("plus")) : null,+ collapsible ? el("button", { class: "collapse", onclick: (e) => { e.stopPropagation(); setCollapsed(status, !isCollapsed(status)); } }) : null),el("div", { class: "cards" }),);wireDrop(col, col.querySelector(".cards"), status);- if (last) col.addEventListener("click", () => { if (doneCollapsed()) setDoneCollapsed(false); });+ if (collapsible) col.addEventListener("click", () => { if (isCollapsed(status)) setCollapsed(status, false); });return col;}));- showDoneCollapsed();+ showCollapsed();}// During a drag the DOM is being moved by hand; refresh once it ends.@@ -542,29 +553,37 @@ function renderColumns() {}}-// The done column only grows; it starts collapsed to a thin strip, as in Trello or Linear,-// and each browser remembers the choice. Cards can still be dropped on the strip.-function doneCollapsed() {- return localStorageGet("kanzo.doneCollapsed") !== "0";+// Columns listed under `collapsed` in config.toml, like done, which only grows, start+// collapsed to a thin strip, as in Trello or Linear, and each browser remembers the+// choice. Cards can still be dropped on a strip.+function isCollapsed(status) {+ const saved = localStorageGet("kanzo.collapsed." + status);+ return saved === null ? state.board.collapsed.includes(status) : saved === "1";}-function setDoneCollapsed(collapsed) {- try { localStorage.setItem("kanzo.doneCollapsed", collapsed ? "1" : "0"); } catch {}- showDoneCollapsed();+function setCollapsed(status, collapsed) {+ try { localStorage.setItem("kanzo.collapsed." + status, collapsed ? "1" : "0"); } catch {}+ showCollapsed();}-function showDoneCollapsed() {+function showCollapsed() {const columns = $("#columns");const cols = [...columns.querySelectorAll(".column")];if (!cols.length) return;- const collapsed = doneCollapsed();- const done = cols[cols.length - 1];- done.classList.toggle("collapsed", collapsed);- const button = done.querySelector(".collapse");- button.replaceChildren(icon(collapsed ? "expand" : "collapse"));- button.title = collapsed ? `Show ${done.dataset.status}` : `Collapse ${done.dataset.status}`;- button.setAttribute("aria-label", button.title);- columns.style.gridTemplateColumns = cols.map((c) => (c === done && collapsed ? "48px" : "minmax(260px, 1fr)")).join(" ");+ for (const col of cols) {+ const button = col.querySelector(".collapse");+ if (!button) continue;+ const { status } = col.dataset;+ const collapsed = isCollapsed(status);+ col.classList.toggle("collapsed", collapsed);+ // The arrows point the way the column folds: to the right edge, or for the+ // columns before the inbox, to the left one.+ const left = statusStep(status) < 0;+ button.replaceChildren(icon(collapsed !== left ? "expand" : "collapse"));+ button.title = collapsed ? `Show ${status}` : `Collapse ${status}`;+ button.setAttribute("aria-label", button.title);+ }+ columns.style.gridTemplateColumns = cols.map((c) => (c.classList.contains("collapsed") ? "48px" : "minmax(260px, 1fr)")).join(" ");}// A description as one line of plain text for a card: Markdown markers dropped, lines joined.diff --git a/src/export.rs b/src/export.rsindex b8ba5bb..02b1259 100644--- a/src/export.rs+++ b/src/export.rs@@ -189,7 +189,7 @@ mod tests {assert!(md.contains("## Web `web`"), "{md}");let json: serde_json::Value = serde_json::to_value(&board).unwrap();- assert_eq!(json["statuses"][0], "todo");+ assert_eq!(json["statuses"][0], "backlog");assert_eq!(json["projects"][0]["slug"], "api");assert_eq!(json["projects"][0]["tasks"][0]["key"], "api#1");assert_eq!(json["projects"][0]["tasks"][0]["comments"][0]["author"], "claude-code");diff --git a/src/home.rs b/src/home.rsindex f4804bc..5efcbc8 100644--- a/src/home.rs+++ b/src/home.rs@@ -8,7 +8,7 @@ use std::time::{Duration, Instant};use anyhow::{Context, Result, bail};use serde::Deserialize;-use crate::store::{self, ImagesOf, Store};+use crate::store::{self, Columns, ImagesOf, Store};const DEFAULT_PORT: u16 = 4242;@@ -23,9 +23,17 @@ port = 4242# port can read and change the board, and use its MCP endpoint.listen = "127.0.0.1"-# Board columns, left to right. New tasks go in the first one;-# tasks in the last one count as done.-statuses = ["todo", "doing", "review", "done"]+# Board columns, left to right. Tasks in the last one count as done.+statuses = ["backlog", "todo", "doing", "review", "done"]++# Columns the board starts collapsed to a thin strip. Each browser remembers+# when you open or close one.+collapsed = ["backlog", "done"]++# New tasks go in `inbox`, and agents take their next task from there and+# move it to `working`. Without these, the first and second column.+inbox = "todo"+working = "doing"# Also serve MCP over HTTP at http://localhost:<port>/mcp, for agents# that cannot start `kanzo mcp` themselves.@@ -54,6 +62,9 @@ pub struct Config {pub port: u16,pub listen: IpAddr,pub statuses: Vec<String>,+ pub collapsed: Option<Vec<String>>,+ pub inbox: Option<String>,+ pub working: Option<String>,pub mcp_http: bool,}@@ -62,14 +73,19 @@ impl Default for Config {Self {port: DEFAULT_PORT,listen: IpAddr::V4(Ipv4Addr::LOCALHOST),+ // A config.toml from before `collapsed`, `inbox` and `working` keeps its board.statuses: ["todo", "doing", "review", "done"].map(String::from).to_vec(),+ collapsed: None,+ inbox: None,+ working: None,mcp_http: true,}}}impl Config {- fn validate(&self) -> Result<()> {+ /// Checks the column settings and fills in the ones left out.+ fn columns(&self) -> Result<Columns> {if self.statuses.len() < 2 {bail!("config.toml: `statuses` needs at least two columns");}@@ -82,7 +98,32 @@ impl Config {bail!("config.toml: status {s:?} is listed twice");}}- Ok(())+ let listed = |key: &str, s: &String| {+ if self.statuses.contains(s) {+ Ok(s.clone())+ } else {+ bail!("config.toml: {key} {s:?} is not one of the statuses: {}", self.statuses.join(", "))+ }+ };+ let mut columns = Columns::new(self.statuses.clone());+ if let Some(s) = &self.inbox {+ columns.inbox = listed("inbox", s)?;+ }+ let at = self.statuses.iter().position(|s| *s == columns.inbox).unwrap_or(0);+ if at == self.statuses.len() - 1 {+ bail!("config.toml: inbox {:?} is the done column; pick another", columns.inbox);+ }+ columns.working = match &self.working {+ Some(s) => listed("working", s)?,+ None => self.statuses[at + 1].clone(),+ };+ if columns.working == columns.inbox {+ bail!("config.toml: inbox and working are both {:?}", columns.inbox);+ }+ if let Some(collapsed) = &self.collapsed {+ columns.collapsed = collapsed.iter().map(|s| listed("collapsed", s)).collect::<Result<_>>()?;+ }+ Ok(columns)}}@@ -91,6 +132,7 @@ impl Config {pub struct Home {pub dir: PathBuf,pub config: Config,+ pub columns: Columns,}impl Home {@@ -116,9 +158,9 @@ impl Home {let path = dir.join("config.toml");let text = fs::read_to_string(&path).with_context(|| format!("cannot read {}", path.display()))?;let config: Config = toml::from_str(&text).with_context(|| format!("{} is not valid", path.display()))?;- config.validate()?;+ let columns = config.columns()?;- let home = Self { dir, config };+ let home = Self { dir, config, columns };home.store()?.migrate()?;Ok(home)}@@ -162,7 +204,7 @@ impl Home {Err(TryLockError::Error(_)) => break None,}};- Store::open(&self.db_path(), self.config.statuses.clone(), lock)+ Store::open(&self.db_path(), self.columns.clone(), lock)}/// Runs `delete`, then deletes the image files of `of` that nothing uses any more:@@ -218,7 +260,9 @@ mod tests {assert!(dir.join(".gitignore").exists());assert!(dir.join("kanzo.db").exists());assert_eq!(home.config.port, DEFAULT_PORT);- assert_eq!(home.config.statuses, ["todo", "doing", "review", "done"]);+ assert_eq!(home.columns.statuses, ["backlog", "todo", "doing", "review", "done"]);+ assert_eq!(home.columns.collapsed, ["backlog", "done"]);+ assert_eq!((home.columns.inbox.as_str(), home.columns.working.as_str()), ("todo", "doing"));assert!(home.config.mcp_http);assert!(home.config.listen.is_loopback());}@@ -230,4 +274,40 @@ mod tests {let err = Home::open(tmp.path().to_path_buf()).unwrap_err();assert!(err.to_string().contains("listed twice"), "{err}");}++ #[test]+ fn statuses_alone_keep_the_old_board() {+ let tmp = tempfile::tempdir().unwrap();+ let text = "statuses = [\"todo\", \"doing\", \"review\", \"done\"]\n";+ fs::write(tmp.path().join("config.toml"), text).unwrap();+ let home = Home::open(tmp.path().to_path_buf()).unwrap();+ assert_eq!(home.columns, Columns::new(["todo", "doing", "review", "done"].map(String::from).to_vec()));+ assert_eq!(home.columns.collapsed, ["done"]);+ }++ #[test]+ fn working_follows_inbox() {+ let tmp = tempfile::tempdir().unwrap();+ let text = "statuses = [\"later\", \"next\", \"now\", \"done\"]\ninbox = \"next\"\n";+ fs::write(tmp.path().join("config.toml"), text).unwrap();+ let home = Home::open(tmp.path().to_path_buf()).unwrap();+ assert_eq!((home.columns.inbox.as_str(), home.columns.working.as_str()), ("next", "now"));+ }++ #[test]+ fn rejects_bad_columns() {+ for (extra, says) in [+ ("inbox = \"nope\"", "not one of the statuses"),+ ("working = \"nope\"", "not one of the statuses"),+ ("collapsed = [\"nope\"]", "not one of the statuses"),+ ("inbox = \"done\"", "done column"),+ ("inbox = \"doing\"\nworking = \"doing\"", "both"),+ ] {+ let tmp = tempfile::tempdir().unwrap();+ let text = format!("statuses = [\"todo\", \"doing\", \"done\"]\n{extra}\n");+ fs::write(tmp.path().join("config.toml"), text).unwrap();+ let err = Home::open(tmp.path().to_path_buf()).unwrap_err();+ assert!(err.to_string().contains(says), "{extra}: {err}");+ }+ }}diff --git a/src/index.html b/src/index.htmlindex c19ddd7..bd75302 100644--- a/src/index.html+++ b/src/index.html@@ -167,7 +167,7 @@ header .repo-link .icon svg { width: 14px; height: 14px; }background: none; color: var(--faint);}.column h2 .collapse:hover, .column h2 .collapse:focus-visible { background: var(--hover); color: var(--text); }-/* A collapsed done column: a thin strip, name written downwards, that expands on a click. */+/* A collapsed column: a thin strip, name written downwards, that expands on a click. */.column.collapsed { cursor: pointer; }.column.collapsed:hover { background: var(--hover); }.column.collapsed h2 { writing-mode: vertical-rl; padding: 12px 0; align-items: center; gap: 10px; }diff --git a/src/mcp.rs b/src/mcp.rsindex 1cb762d..379f767 100644--- a/src/mcp.rs+++ b/src/mcp.rs@@ -449,7 +449,7 @@ impl Kanzo {Some(task) => Ok(format!("Moved to {}:\n{}", task.status, task_detail(ctx, store, &task)?)),None => {let scope = project.map_or("any project".into(), |p| p.slug);- Ok(format!("Nothing in {} for {scope}.", store.statuses()[0]))+ Ok(format!("Nothing in {} for {scope}.", store.columns().inbox))}}})diff --git a/src/store.rs b/src/store.rsindex 1157a21..476975b 100644--- a/src/store.rs+++ b/src/store.rs@@ -162,16 +162,41 @@ pub struct TaskPatch {pub human: Option<bool>,}+/// The board's columns, from `config.toml`.+#[derive(Debug, Clone, PartialEq)]+pub struct Columns {+ /// Left to right; tasks in the last one count as done.+ pub statuses: Vec<String>,+ /// Columns the board starts collapsed.+ pub collapsed: Vec<String>,+ /// Where new tasks go, and where agents take the next task from.+ pub inbox: String,+ /// Where an agent's next task moves to.+ pub working: String,+}++impl Columns {+ /// New tasks in the first column, agents move them to the second, done starts collapsed.+ pub fn new(statuses: Vec<String>) -> Self {+ Self {+ collapsed: statuses.last().cloned().into_iter().collect(),+ inbox: statuses[0].clone(),+ working: statuses[1].clone(),+ statuses,+ }+ }+}+pub struct Store {conn: Connection,- statuses: Vec<String>,+ columns: Columns,/// Held while the connection is open; declared after `conn` so it is released after it closes._lock: Option<std::fs::File>,}impl Store {/// Opens the database. `lock` is kept until the store is dropped (see `Home::store`).- pub fn open(path: &Path, statuses: Vec<String>, lock: Option<std::fs::File>) -> Result<Self> {+ pub fn open(path: &Path, columns: Columns, lock: Option<std::fs::File>) -> Result<Self> {let conn = Connection::open(path)?;// The board and any number of agents share this file; wait instead of failing.conn.busy_timeout(Duration::from_secs(5))?;@@ -181,19 +206,19 @@ impl Store {// when a board loses power.conn.pragma_update_and_check(None, "journal_mode", "TRUNCATE", |_| Ok(()))?;conn.pragma_update(None, "foreign_keys", "ON")?;- Ok(Self { conn, statuses, _lock: lock })+ Ok(Self { conn, columns, _lock: lock })}pub fn statuses(&self) -> &[String] {- &self.statuses+ &self.columns.statuses}- fn first_status(&self) -> &str {- &self.statuses[0]+ pub fn columns(&self) -> &Columns {+ &self.columns}fn done_status(&self) -> &str {- self.statuses.last().expect("config has at least two statuses")+ self.columns.statuses.last().expect("config has at least two statuses")}/// Runs `f` in an immediate transaction, so concurrent writers queue up@@ -492,7 +517,7 @@ impl Store {let mut tasks: Vec<Task> = stmt.query_map(params![project_id, status, done, limit], Self::task_row)?.collect::<rusqlite::Result<_>>()?;- let column = |t: &Task| self.statuses.iter().position(|s| *s == t.status).unwrap_or(usize::MAX);+ let column = |t: &Task| self.statuses().iter().position(|s| *s == t.status).unwrap_or(usize::MAX);tasks.sort_by_key(column);let hidden = match keep_done {Some(keep) if status.is_none_or(|s| s == done) => {@@ -554,10 +579,10 @@ impl Store {}fn check_status(&self, status: &str) -> Result<()> {- if self.statuses.iter().any(|s| s == status) {+ if self.statuses().iter().any(|s| s == status) {Ok(())} else {- Err(Error::Invalid(format!("unknown status {status:?}; use one of: {}", self.statuses.join(", "))))+ Err(Error::Invalid(format!("unknown status {status:?}; use one of: {}", self.statuses().join(", "))))}}@@ -572,7 +597,7 @@ impl Store {pub fn create_task(&self, project_id: i64, title: &str, description: &str) -> Result<Task> {let title = clean_title(title)?;- let status = self.first_status();+ let status = &self.columns.inbox;let id = self.write(|c| {let position = Self::end_of_column(c, status, 0)?;c.execute(@@ -696,11 +721,11 @@ impl Store {Ok(())}- /// Takes the top task of the first column that isn't for a person, and moves it to- /// the bottom of the second.+ /// Takes the top task of the inbox column that isn't for a person, and moves it to+ /// the bottom of the working one.pub fn next_task(&self, project_id: Option<i64>) -> Result<Option<Task>> {- let from = self.first_status();- let to = &self.statuses[1];+ let from = &self.columns.inbox;+ let to = &self.columns.working;let id = self.write(|c| {let id: Option<i64> = c.query_row(@@ -970,9 +995,12 @@ mod tests {use super::*;fn store() -> (tempfile::TempDir, Store) {+ store_with(Columns::new(["todo", "doing", "review", "done"].map(String::from).to_vec()))+ }++ fn store_with(columns: Columns) -> (tempfile::TempDir, Store) {let dir = tempfile::tempdir().unwrap();- let statuses = ["todo", "doing", "review", "done"].map(String::from).to_vec();- let store = Store::open(&dir.path().join("kanzo.db"), statuses, None).unwrap();+ let store = Store::open(&dir.path().join("kanzo.db"), columns, None).unwrap();store.migrate().unwrap();(dir, store)}@@ -1139,7 +1167,7 @@ mod tests {.unwrap();}let statuses = ["todo", "doing", "review", "done"].map(String::from).to_vec();- let s = Store::open(&path, statuses, None).unwrap();+ let s = Store::open(&path, Columns::new(statuses), None).unwrap();s.migrate().unwrap();assert_eq!(s.find_project("api").unwrap().repos, ["me/api"]);assert!(s.find_project("web").unwrap().repos.is_empty());@@ -1265,6 +1293,23 @@ mod tests {assert_eq!(s.get_task(human.id).unwrap().status, "todo");}+ #[test]+ fn inbox_and_working_need_not_be_the_first_columns() {+ let statuses = ["backlog", "todo", "doing", "done"].map(String::from).to_vec();+ let columns = Columns { inbox: "todo".into(), working: "doing".into(), ..Columns::new(statuses) };+ let (_dir, s) = store_with(columns);+ let api = s.create_project("api", "", None).unwrap();+ let backlog = s.create_task(api.id, "later", "").unwrap();+ assert_eq!(backlog.status, "todo");+ s.move_task(backlog.id, "backlog", None).unwrap();+ s.create_task(api.id, "now", "").unwrap();++ let t = s.next_task(None).unwrap().unwrap();+ assert_eq!((t.title.as_str(), t.status.as_str()), ("now", "doing"));+ assert!(s.next_task(None).unwrap().is_none());+ assert_eq!(s.get_task(backlog.id).unwrap().status, "backlog");+ }+#[test]fn change_counter_moves_on_every_write() {let (_dir, s) = store();diff --git a/src/sync.rs b/src/sync.rsindex 429464d..93ee322 100644--- a/src/sync.rs+++ b/src/sync.rs@@ -149,7 +149,7 @@ pub fn sync(home: &Home, keep: Option<Keep>, prompt: bool) -> Result<String> {// kanzo.db, never across a commit (hooks, signing prompts) or the network.{let _lock = home.lock_exclusive()?;- crate::store::Store::open(&home.db_path(), home.config.statuses.clone(), None)?.settle()?;+ crate::store::Store::open(&home.db_path(), home.columns.clone(), None)?.settle()?;git(&["add", "--all"])?;}if !git_ok(&["diff", "--cached", "--quiet"]) {diff --git a/src/web.rs b/src/web.rsindex 3d05a33..0a05778 100644--- a/src/web.rs+++ b/src/web.rs@@ -283,7 +283,9 @@ struct BoardQuery {#[derive(Serialize)]struct Board {changes: String,+ collapsed: Vec<String>,done_hidden: usize,+ inbox: String,projects: Vec<store::Project>,statuses: Vec<String>,tasks: Vec<store::Task>,@@ -300,7 +302,9 @@ async fn board(State(home): Shared, Query(q): Query<BoardQuery>) -> Response {let (tasks, done_hidden) = s.list_tasks_keeping_done(project.map(|p| p.id), None, keep_done)?;Ok(Board {changes: change_token(h, s)?,+ collapsed: s.columns().collapsed.clone(),done_hidden,+ inbox: s.columns().inbox.clone(),projects: s.list_projects()?,statuses: s.statuses().to_vec(),tasks,