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
Merge main into fork-features
emanuele-emc8cd51135067
diff --cc README.mdindex 327e1a4,4535f89..45de60a--- a/README.md+++ b/README.md@@@ -225,10 -211,9 +225,10 @@@ Everything lives in `~/kanzo`: the boarport = 4242listen = "127.0.0.1" # sharing opens the board to your network; "0.0.0.0" keeps it openmcp_http = true # MCP at /mcp+editor = "/usr/local/bin/cursor" # opens file:/// links; on macOS, your text editor without it```- 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.-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 fastdiff --cc src/app.jsindex f7f5378,62731c0..13f4850--- a/src/app.js+++ b/src/app.js@@@ -351,13 -362,13 +370,13 @@@ function renderNav()el("span", { class: "count" }, String(count)));const item = (p) => renaming && renaming.slug === p.slug? el("div", { class: "item renaming" }, icon("folder", projectColor(p.slug)), renaming.input)- : el("div", { class: "item" + (state.menu === p.slug ? " menu-open" : "") },+ : el("div", { class: "item" + (state.menu === p.slug ? " menu-open" : ""), draggable: "true", "data-slug": p.slug },link(p.slug, p.name, p.open, icon("folder", projectColor(p.slug))),- el("button", { class: "more", title: "More", "aria-label": `More for ${p.name}`, "aria-haspopup": "menu",+ el("button", { class: "more", title: tr("More"), "aria-label": tr("More for {0}", p.name), "aria-haspopup": "menu",onclick: (e) => toggleProjectMenu(p, e.currentTarget) }, icon("more")));$("#nav").replaceChildren(- link("all", "All projects", open, icon("board")),- ...(projects.length ? [el("div", { class: "label" }, "Projects")] : []),+ link("all", tr("All projects"), open, icon("board")),+ ...(projects.length ? [el("div", { class: "label" }, tr("Projects"))] : []),...projects.map(item),);}@@@ -518,11 -499,9 +537,11 @@@ function renderHeader()$("#new-task").hidden = !projects.length;$("#human-only").hidden = !projects.length || isPropertyHidden("human");$("#filter-box").hidden = !projects.length;+ $("#view").hidden = !projects.length;+ $("#view").setAttribute("aria-pressed", String(isList()));$("#filters").replaceChildren(...(projects.length ? savedFilters() : []).map((f, i) =>el("span", { class: "chip" }, el("span", {}, queryNodes(f)),- el("button", { type: "button", title: `Remove "${f}"`, "aria-label": `Remove the filter ${f}`,+ el("button", { type: "button", title: tr(`Remove "{0}"`, f), "aria-label": tr("Remove the filter {0}", f),onclick: () => setFilters(savedFilters().filter((_, j) => j !== i)) }, icon("close")))));$("#human-only").setAttribute("aria-pressed", String(isHumanOnly()));if (!projects.length) { header.replaceChildren(); return; }@@@ -595,157 -570,24 +614,157 @@@ function renderColumns()const humanOnly = isHumanOnly();const query = filterQuery();$("#filter").classList.toggle("on", query.length > 0);- for (const status of statuses) {- const col = columns.querySelector(`[data-status="${CSS.escape(status)}"]`);- const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human));- const last = status === statuses[statuses.length - 1];- const hidden = last && !state.allDone ? state.board.done_hidden || 0 : 0;- // Filtered, the server's count of older done tasks says nothing about human ones.- const filtered = humanOnly || query.length > 0;- const count = mine.length + (filtered ? 0 : hidden);- col.querySelector("h2 .count").textContent = count ? String(count) : "";- const more = hidden- ? el("button", { class: "ghost more", onclick: () => { state.allDone = true; loadBoard(); } },- filtered ? tr("Show older") : tr("Show {0} older", hidden))- : null;- col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.map((t) => card(t, all)));+ // Filtered, the server's count of older done tasks says nothing about human ones.+ const filtered = humanOnly || query.length > 0;+ const hiddenDone = state.allDone ? 0 : state.board.done_hidden || 0;+ const more = hiddenDone+ ? el("button", { class: "ghost more", onclick: () => { state.allDone = true; loadBoard(); } },- filtered ? "Show older" : `Show ${hiddenDone} older`)++ filtered ? tr("Show older") : tr("Show {0} older", hiddenDone))+ : null;+ if (inList) {+ renderList(tasks.filter((t) => !humanOnly || t.human), all, more);+ } else {+ for (const status of statuses) {+ const col = columns.querySelector(`[data-status="${CSS.escape(status)}"]`);+ const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human));+ const last = status === statuses[statuses.length - 1];+ const count = mine.length + (!last || filtered ? 0 : hiddenDone);+ col.querySelector("h2 .count").textContent = count ? String(count) : "";+ col.querySelector(".cards").replaceChildren(...(last && more ? [more] : []), ...mine.map((t) => card(t, all)));+ }+ }+ highlight("filter", inList ? $("#list") : columns, wordsOf(query));+ for (const id of [...state.selected]) {+ if (!document.querySelector(`.card[data-id="${id}"]`)) state.selected.delete(id);+ }+ showSelection();+}++function isList() {+ return localStorageGet("kanzo.view") === "list";+}++// Only the view on screen is rendered: every refresh would otherwise build both.+$("#view").addEventListener("click", () => {+ localStorageSet("kanzo.view", isList() ? "" : "list");+ state.layout = "";+ render();+});+for (const [select, name] of [[$("#list-sort"), "kanzo.sort"], [$("#list-group"), "kanzo.group"]]) {+ select.value = localStorageGet(name) || "";+ select.addEventListener("change", () => { localStorageSet(name, select.value); renderColumns(); });+}++function renderList(tasks, all, more) {+ const { statuses, projects } = state.board;+ const by = $("#list-sort").value, group = $("#list-group").value;+ const sorted = !by ? tasks : [...tasks].sort((a, b) =>+ by === "id" ? a.id - b.id : by === "title" ? a.title.localeCompare(b.title) : b[by].localeCompare(a[by]));+ const groups = new Map((group === "status" ? statuses : group === "project" ? projects.map((p) => p.slug) : []).map((g) => [g, []]));+ for (const t of sorted) {+ for (const g of group === "tags" ? (t.tags.length ? t.tags : [""]) : [group ? t[group] : ""]) {+ if (!groups.has(g)) groups.set(g, []);+ groups.get(g).push(t);+ }}- highlight("filter", columns, wordsOf(query));+ const names = group === "tags" ? [...groups.keys()].sort((a, b) => !a - !b || a.localeCompare(b)) : [...groups.keys()];+ $("#list").replaceChildren(...names.flatMap((g) => !groups.get(g).length ? [] : [+ group ? el("h2", { style: group === "status" ? "text-transform:capitalize" : null }, g || "No tag", el("span", { class: "count" }, String(groups.get(g).length))) : null,+ ...groups.get(g).map((t) => card(t, all, true)),+ ]).filter(Boolean), ...(more ? [more] : []));+}++function showSelection() {+ $("#bulk").hidden = !state.selected.size;+ $("#bulk-count").textContent = `${state.selected.size} selected`;+}++function setSelected(id, on) {+ if (on) state.selected.add(id); else state.selected.delete(id);+ // Grouped by tag, a task can have several rows.+ document.querySelectorAll(`.card[data-id="${id}"]`).forEach((n) => n.classList.toggle("selected", on));+}++function clearSelection() {+ state.selected.forEach((id) => setSelected(id, false));+ showSelection();+}++// Closes the panel: one or the other, so the bar can't cover it.+function toggleSelected(id) {+ if (state.task) closeTask();+ setSelected(id, !state.selected.has(id));+ showSelection();+}++// Drag on empty board space to select, with ⌘ to add to what's selected. Cards are measured once, when+// the drag starts, so moving the mouse never forces a layout.+function sweep(down) {+ const marquee = el("div", { class: "marquee" });+ const kept = new Set(down.metaKey || down.ctrlKey ? state.selected : []);+ let cards, x, y, frame = 0;+ const paint = () => {+ frame = 0;+ const x1 = Math.min(down.clientX, x), x2 = Math.max(down.clientX, x), y1 = Math.min(down.clientY, y), y2 = Math.max(down.clientY, y);+ marquee.style.cssText = `left:${x1}px;top:${y1}px;width:${x2 - x1}px;height:${y2 - y1}px`;+ for (const { id, r, list } of cards) {+ // A card scrolled out of its column can't be under the box.+ const hit = r.right > x1 && r.left < x2 && r.bottom > Math.max(y1, list.top) && r.top < Math.min(y2, list.bottom);+ if ((hit || kept.has(id)) !== state.selected.has(id)) setSelected(id, !state.selected.has(id));+ }+ showSelection();+ };+ const move = (e) => {+ x = e.clientX; y = e.clientY;+ if (!cards) {+ if (Math.hypot(x - down.clientX, y - down.clientY) < 4) return;+ state.sweeping = true;+ document.body.append(marquee);+ cards = [...$("#columns").querySelectorAll(".column:not(.collapsed) .card")].map((n) =>+ ({ id: +n.dataset.id, r: n.getBoundingClientRect(), list: n.parentNode.getBoundingClientRect() }));+ }+ if (!frame) frame = requestAnimationFrame(paint);+ };+ const up = () => {+ cancelAnimationFrame(frame);+ document.removeEventListener("mousemove", move);+ document.removeEventListener("mouseup", up);+ marquee.remove();+ state.sweeping = false;+ if (cards) renderColumns();+ else if (!kept.size) clearSelection();+ };+ document.addEventListener("mousemove", move);+ document.addEventListener("mouseup", up);}+$("#columns").addEventListener("mousedown", (e) => {+ const onScrollbar = e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight;+ if (e.button || onScrollbar || e.target.closest(".card, button, a, .collapsed")) return;+ e.preventDefault();+ sweep(e);+});++async function changeSelected(change) {+ const ids = state.board.tasks.filter((t) => state.selected.has(t.id)).map((t) => t.id);+ try { await api("POST", "/tasks/bulk", { ids, ...change }); } catch (err) { toast(err.message); }+ loadBoard();+}++$("#bulk").addEventListener("keydown", (e) => {+ const { name, value } = e.target;+ if (e.key === "Escape") { e.stopPropagation(); e.target.blur(); clearSelection(); }+ else if (e.key === "Enter" && name && value.trim()) { changeSelected({ [name]: value }); e.target.value = ""; }+});+$("#bulk-status").addEventListener("change", (e) => {+ changeSelected({ status: e.target.value });+ e.target.value = "";+});+$("#bulk-delete").addEventListener("click", () => {+ if (confirm(`Delete ${plural(state.selected.size, "task")}, with comments and images? This cannot be undone.`)) changeSelected({ delete: true });+});+$("#bulk-clear").addEventListener("click", clearSelection);+function savedFilters() {try { return JSON.parse(localStorageGet("kanzo.filters")) || []; } catch { return []; }}@@@ -906,91 -743,15 +925,91 @@@ function plainText(md).trim();}-function card(t, showProject) {- const node = el("div", { class: "card" + (state.task === t.id ? " open" : ""), draggable: "true", "data-id": t.id,- onclick: () => openTask(t.id) },+// Dragging a selected card takes the others along: they fly behind it, and spread out where it lands.+const MOTION = { duration: 180, easing: "ease-out" };+const MOST_FLYING = 30;+const STACK_TOP = 8;++function calm() {+ return matchMedia("(prefers-reduced-motion: reduce)").matches;+}++function inView(card) {+ const r = card.getBoundingClientRect(), list = card.parentNode.getBoundingClientRect();+ return r.width > 0 && r.bottom > list.top && r.top < list.bottom;+}++// The browser draws the dragged image, and only from what's on the page when the drag starts.+function stackImage(card, count) {+ const stack = el("div", { class: "stack", style: `width:${card.offsetWidth}px` },+ card.cloneNode(true), el("span", { class: "stack-count" }, String(count)));+ document.body.append(stack);+ requestAnimationFrame(() => stack.remove());+ return stack;+}++// A copy above the board, so that its column can't clip it.+function fly(card, from, to, fade) {+ const { width, height } = card.getBoundingClientRect();+ const ghost = card.cloneNode(true);+ ghost.classList.add("flying");+ ghost.style.cssText = `left:${from.left}px;top:${from.top}px;width:${width}px;height:${height}px`;+ document.body.append(ghost);+ const end = `translate(${to.left - from.left}px,${to.top - from.top}px)`;+ const flight = ghost.animate([{ transform: "none", opacity: 1 }, { transform: end, opacity: fade ? 0 : 1 }], MOTION);+ return new Promise((done) => { flight.onfinish = () => { ghost.remove(); done(); }; });+}++// Makes a change to the board, then glides the cards it moved from where they were.+function shift(change) {+ const tops = new Map(calm() ? [] : [...$("#columns").querySelectorAll(".card:not(.gathered)")].filter(inView)+ .map((c) => [c, c.getBoundingClientRect().top]));+ change();+ tops.forEach((top, c) => {+ const r = c.getBoundingClientRect();+ if (r.width && r.top !== top) c.animate([{ transform: `translateY(${top - r.top}px)` }, { transform: "none" }], MOTION);+ });+}++function gather(group, grabbed) {+ const to = grabbed.getBoundingClientRect();+ const others = group.filter((c) => c !== grabbed);+ if (!calm()) others.filter(inView).slice(0, MOST_FLYING).forEach((c) => fly(c, c.getBoundingClientRect(), to, true));+ shift(() => {+ grabbed.classList.add("dragging");+ others.forEach((c) => c.classList.add("dragging", "gathered"));+ });+}++// `place` puts the cards where they land. A refresh waits, as it would replace what's flying.+async function spread(group, grabbed, from, place) {+ state.settling = true;+ shift(() => {+ place();+ group.forEach((c) => c.classList.remove("dragging", "gathered"));+ });+ const others = calm() ? [] : group.filter((c) => c !== grabbed && inView(c)).slice(0, MOST_FLYING);+ const flying = calm() || !inView(grabbed) ? others : [...others, grabbed];+ await Promise.all(flying.map((c) => {+ const landed = fly(c, from, c.getBoundingClientRect(), false);+ c.classList.add("landing");+ return landed.then(() => c.classList.remove("landing"));+ }));+ state.settling = false;+}++// In the list, a row: no drag to reorder, since a sorted list has no one position to drop into.+function card(t, showProject, row) {+ const node = el("div", { class: "card" + (row ? " row" : "") + (state.task === t.id ? " open" : "") + (t.waiting_on ? " waiting" : "") + (state.selected.has(t.id) ? " selected" : ""),+ draggable: row ? null : "true", "data-id": t.id,+ onclick: (e) => { if (e.metaKey || e.ctrlKey) toggleSelected(t.id); else openTask(t.id); } },+ row ? statusIcon(t.status) : null,el("div", { class: "head" },el("div", { class: "title" }, t.title),- t.human ? el("span", { class: "human-mark", title: "Human task: agents skip it" }, icon("human")) : null,- el("span", { class: "num", title: `Copy ${key(t)}`, onclick: (e) => { e.stopPropagation(); copyKey(key(t)); } },+ t.human ? el("span", { class: "human-mark", title: tr("Human task: agents skip it") }, icon("human")) : null,+ el("span", { class: "num", title: tr("Copy {0}", key(t)), onclick: (e) => { e.stopPropagation(); copyKey(key(t)); } },showProject ? el("span", { class: "dot", style: `background:${projectColor(t.project)}` }) : null, `#${t.id}`)),- ...summary(t, urlChip(t)));+ ...summary(t, waitChip(t), urlChip(t)).slice(row ? 1 : 0));node.addEventListener("dragstart", (e) => {state.dragging = t.id;e.dataTransfer.effectAllowed = "move";@@@ -1199,15 -914,13 +1218,15 @@@ async function refreshTask()}// Another task may have taken the panel meanwhile.if (state.task !== id) return;- const { task, comments, images } = data;+ // A board on an older version sends neither list.+ const { task, comments, images, waits_on = [], blocks = [] } = data;panelTask = task;+ panelWaits = waits_on.map(key).join(", ");$("#p-key").textContent = key(task);- $("#p-key").title = `Copy ${key(task)}`;+ $("#p-key").title = tr("Copy {0}", key(task));// Never overwrite what is being typed or picked.if (!$("#p-project").contains(document.activeElement)) renderProjectPick(task);- for (const [field, value] of [[$("#p-title"), task.title], [$("#p-desc"), task.description], [$("#p-tags"), task.tags.join(", ")], [$("#p-url"), task.url || ""]]) {+ for (const [field, value] of [[$("#p-title"), task.title], [$("#p-desc"), task.description], [$("#p-tags"), task.tags.join(", ")], [$("#p-url"), task.url || ""], [$("#p-waits"), panelWaits]]) {if (document.activeElement !== field) { field.value = value; fit(field); }}showDesc();@@@ -1876,11 -1466,10 +1895,11 @@@ function toggleSettingsMenu()const button = $("#settings");button.classList.add("open");const menu = el("div", { class: "menu", role: "menu", tabindex: "-1" },- el("button", { onclick: () => openSettings() }, icon("settings"), "Settings"),- el("button", { onclick: () => { closeMenu(); checkForUpdates(); } }, icon("update"), "Check for updates",+ el("button", { onclick: () => openSettings() }, icon("settings"), tr("Settings")),+ el("button", { onclick: () => { closeMenu(); checkForUpdates(); } }, icon("update"), tr("Check for updates"),el("span", { class: "value" }, `v${state.board.version}`)),- el("button", { onclick: () => openSettings("about") }, icon("news"), "What's new?"),- el("button", { onclick: sync }, icon("sync"), "Sync"));++ el("button", { onclick: () => openSettings("about") }, icon("news"), tr("What's new?")),+ el("button", { onclick: sync }, icon("sync"), tr("Sync")));document.body.append(menu);const r = button.getBoundingClientRect();menu.style.width = `${r.width}px`;@@@ -1942,11 -1520,11 +1961,11 @@@ async function saveSetting(box, fields} catch (err) { box.checked = !box.checked; toast(err.message); }}$("#settings-backlog").addEventListener("change", (e) => saveSetting(e.target, { backlog: e.target.checked }));-$('.settings-pane[data-section="board"]').append(...["Description", "Tags", "URL", "Human", "Created", "Updated", "Comments", "Images"].map((name) => {+$('.settings-pane[data-section="board"]').append(...["Description", "Tags", "URL", "Human", "Waiting", "Created", "Updated", "Comments", "Images"].map((name) => {const property = name.toLowerCase();- return el("label", { class: "setting" }, el("span", { class: "text" }, name),+ return el("label", { class: "setting" }, el("span", { class: "text" }, tr(name)),el("span", { class: "switch" },- el("input", { type: "checkbox", "data-property": property, "aria-label": name,+ el("input", { type: "checkbox", "data-property": property, "aria-label": tr(name),onchange: (e) => saveSetting(e.target, { property, visible: e.target.checked }) }),el("span")));}));@@@ -2013,30 -1603,6 +2044,25 @@@ async function installUpdate(availablelocation.reload();}+function setRail(on) {+ document.documentElement.classList.toggle("rail", on);+ $("#rail").setAttribute("aria-expanded", String(!on));+ localStorageSet("kanzo.rail", on ? "1" : "");+}+setRail(localStorageGet("kanzo.rail") === "1");+document.documentElement.classList.add("ready");+$("#rail").addEventListener("click", () => setRail($("#rail").getAttribute("aria-expanded") === "true"));++// Chromium's browsers ask this only while the board isn't installed; the others never do.+let installPrompt;+window.addEventListener("beforeinstallprompt", (e) => {+ e.preventDefault();+ installPrompt = e;+ $("#install").hidden = false;+});+window.addEventListener("appinstalled", () => { $("#install").hidden = true; });+$("#install").addEventListener("click", () => installPrompt.prompt());+- checkUpdate();- setInterval(checkUpdate, 24 * 60 * 60 * 1000);- loadSyncRemote();- loadNetwork();-setInterval(() => {document.querySelectorAll("time[datetime]").forEach((t) => { t.textContent = ago(t.getAttribute("datetime")); });}, 60000);diff --cc src/web.rsindex b5697bc,2ff1cb5..c6213df--- a/src/web.rs+++ b/src/web.rs@@@ -24,10 -24,8 +24,11 @@@ use crate::{sync, update}const INDEX: &str = include_str!("index.html");const IMAGE_LIMIT: usize = 25 * 1024 * 1024;const APP_JS: &str = include_str!("app.js");+ const ZH_CN_JS: &str = include_str!("zh-cn.js");const LOGO: &[u8] = include_bytes!("logo.png");+const ICON: &[u8] = include_bytes!("icon.png");+const CHANGELOG: &str = include_str!("../CHANGELOG.md");+const MANIFEST: &str = r##"{"id":"/","name":"Kanzo","start_url":"/","display":"standalone","background_color":"#ffffff","icons":[{"src":"/icon.png","sizes":"192x192 512x512","type":"image/png"}]}"##;/// Scripts only from this server, so even a bug in the Markdown renderer cannot run injected script.const CSP: &str = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; \@@@ -177,13 -170,11 +178,17 @@@ fn router(home: Home, guard: Arc<Guard>Router::new().route("/", get(|| async { Html(INDEX) })).route("/app.js", get(|| async { ([(header::CONTENT_TYPE, "text/javascript; charset=utf-8")], APP_JS) }))+ .route(+ "/i18n/zh-cn.js",+ get(|| async { ([(header::CONTENT_TYPE, "text/javascript; charset=utf-8")], ZH_CN_JS) }),+ ).route("/logo.png", get(|| async { ([(header::CONTENT_TYPE, "image/png")], LOGO) }))+ .route("/icon.png", get(|| async { ([(header::CONTENT_TYPE, "image/png")], ICON) }))+ .route("/changelog.md", get(|| async { ([(header::CONTENT_TYPE, "text/markdown; charset=utf-8")], CHANGELOG) }))+ .route(+ "/manifest.webmanifest",+ get(|| async { ([(header::CONTENT_TYPE, "application/manifest+json")], MANIFEST) }),+ ).route("/api/ping", get(|| async { "kanzo" })).route("/api/update", get(update_status).post(update_now)).route("/api/network", get(network).post(change_network).route_layer(middleware::from_fn(this_computer)))