Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat(cli): pullboard view, every project on localhost [N26,N27,I8]

Corey Olson405b7d7ecc5b
diff --git a/src/board.js b/src/board.js
index 6d152c9a..bb320d88 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1162,6 +1162,17 @@ export function peekShouts(board, agentId, limit = 2) {
.reverse();
}
+/**
+ * The newest shouts on the board, newest first, read without marking anything read (N26).
+ *
+ * @param {any} board
+ * @param {number} [limit]
+ * @returns {any[]}
+ */
+export function recentShouts(board, limit = 40) {
+ return board.db.prepare('SELECT * FROM shout ORDER BY shout_id DESC LIMIT ?').all(limit);
+}
+
/**
* Counts for the status line and the ledger's summary: items by status, verdicts by decision.
*
diff --git a/src/cli.js b/src/cli.js
index cfb25173..1f93ee67 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -2,13 +2,13 @@
* The pullboard command line: every command, bound to who is asking (B3). The main checkout is the
* coordinator; every other worktree is the agent that joined from it.
*/
-import { spawnSync } from 'node:child_process';
+import { spawn, spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { basename, dirname, join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
import * as store from './board.js';
-import { COORDINATOR, loadConfig } from './config.js';
+import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';
import { digestOf, gateReport, runGate, runShell } from './gate.js';
import { contains, git, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';
import {
@@ -40,6 +40,8 @@ import { runItems } from './run.js';
import { parseProblems, sweepItems } from './sweep.js';
import { renderSpecView } from './view.js';
import { tour } from './tour.js';
+import { registerProject } from './projects.js';
+import { serveView } from './serve.js';
const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
export const VERSION = PACKAGE.version;
@@ -54,6 +56,8 @@ Set up
pullboard join <lane> [--route light] register the worktree you are in as an agent in a lane
--route light: a lighter model that takes only items routed light
pullboard whoami | lanes | status who you are, the lanes, the board at a glance
+ pullboard view [--port N] [--no-open] every project on this machine in your browser: items, shouts, doctrine,
+ agents and activity, live; add items, shout and hold lanes from it
pullboard resume where you are: your claim, branch, uncommitted work, what came back,
unread shouts, what to do next; run it to start any session
pullboard hooks reinstall the git hooks (e.g. after a fresh clone)
@@ -119,6 +123,8 @@ const OPTIONS = {
parent: { type: 'string' },
reason: { type: 'string' },
off: { type: 'boolean' },
+ port: { type: 'string' },
+ 'no-open': { type: 'boolean' },
note: { type: 'string' },
'note-file': { type: 'string' },
by: { type: 'string' },
@@ -493,6 +499,38 @@ function resumeHere(io) {
return 0;
}
+/**
+ * \`pullboard view\` (N26): serve the micro site for every project on this machine until stopped,
+ * registering the repo it starts in, and open it in the browser unless asked not to.
+ *
+ * @param {any} io
+ * @param {any} values
+ * @returns {Promise<number>}
+ */
+async function viewHere(io, values) {
+ try {
+ const info = repoInfo(io.cwd);
+ if (info.isMain && existsSync(join(info.root, CONFIG_FILE))) registerProject(info.root);
+ } catch (error) {
+ if (!(error instanceof Refused)) throw error;
+ }
+ const port = values.port === undefined ? 0 : Number(values.port);
+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Refused('USAGE', '--port is a number from 0 to 65535; 0 picks a free one');
+ const view = await serveView({ port });
+ io.say(`Pullboard view: ${view.url}`);
+ io.say('Only this machine can reach it, and only with that link. Ctrl-C stops it.');
+ if (!values['no-open']) {
+ const opener = process.platform === 'darwin' ? ['open', [view.url]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', view.url]] : ['xdg-open', [view.url]];
+ spawn(opener[0], opener[1], { detached: true, stdio: 'ignore' }).on('error', () => {}).unref();
+ }
+ await new Promise((stop) => {
+ process.once('SIGINT', stop);
+ process.once('SIGTERM', stop);
+ });
+ await view.close();
+ return 0;
+}
+
/**
* The commands that set a repo or a worktree up.
*
@@ -511,6 +549,7 @@ function setupCommands(io, { first, values }) {
closeBoard: store.closeBoard,
});
notes.forEach((note) => io.say(note));
+ if (registerProject(info.root)) io.say('registered this project on this machine, so pullboard view lists it');
io.say('next: write SPEC.md rows, declare lanes in pullboard.json, then: pullboard add <lane> <title>');
return 0;
},
@@ -1228,6 +1267,7 @@ export async function main(argv, streams) {
const args = { first, second, rest, values };
try {
if (command === 'tour') return tour(io);
+ if (command === 'view') return await viewHere(io, values);
if (command === 'spec') return specCommand(io, args);
if (command === 'prompt') {
let root = io.cwd;
diff --git a/src/cockpit.js b/src/cockpit.js
new file mode 100644
index 00000000..1dedeffb
--- /dev/null
+++ b/src/cockpit.js
@@ -0,0 +1,273 @@
+/**
+ * The page `pullboard view` serves (N26): one self-contained file, no assets from anywhere, that
+ * reads the board through the server's JSON and refreshes itself. Forms post actions that the server
+ * runs as CLI commands (N27), so the page never decides a rule itself.
+ *
+ * @returns {string}
+ */
+export function cockpitPage() {
+ return `<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Pullboard</title>
+<style>
+:root {
+ --ground: #e9eceb; --surface: #fdfefd; --surface-2: #f2f4f1; --line: #d3d9d5; --line-strong: #bcc5bf;
+ --ink: #121a17; --ink-muted: #4c5852; --ink-faint: #7a887f;
+ --accent: #08915f; --accent-strong: #067049; --accent-soft: #dcefe6; --on-accent: #f4fbf7;
+ --warn: #a2660f; --warn-soft: #f2e6cf; --reject: #bd4437; --reject-soft: #f4e0dc;
+ --blue: #3f6f9e; --blue-soft: #e1eaf3;
+ --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
+ --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
+ color-scheme: light;
+}
+@media (prefers-color-scheme: dark) { :root {
+ --ground: #0c110f; --surface: #121815; --surface-2: #171f1b; --line: #232e29; --line-strong: #34423b;
+ --ink: #e7ece9; --ink-muted: #9caba3; --ink-faint: #6a776f;
+ --accent: #34d89e; --accent-strong: #4ee3ac; --accent-soft: #10231c; --on-accent: #05201a;
+ --warn: #e4b25a; --warn-soft: #241d10; --reject: #f0776b; --reject-soft: #271613;
+ --blue: #6ba7d6; --blue-soft: #142231; color-scheme: dark; } }
+* { box-sizing: border-box; }
+body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.5 var(--sans); }
+button, input, select, textarea { font: inherit; color: inherit; }
+.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
+@media (max-width: 760px) { .app { grid-template-columns: minmax(0, 1fr); } }
+aside { background: var(--surface); border-right: 1px solid var(--line); padding: 16px; display: grid; gap: 14px; align-content: start; }
+.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
+.brand svg { width: 22px; height: 22px; }
+.label { font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
+.projects { display: grid; gap: 4px; }
+.project { text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; gap: 3px; }
+.project:hover { background: var(--surface-2); }
+.project.on { background: var(--accent-soft); border-color: var(--accent); }
+.project b { font-size: 14px; overflow-wrap: anywhere; }
+.project small { color: var(--ink-faint); font-size: 12px; }
+.project .bad { color: var(--reject); }
+main { padding: 18px clamp(14px, 3vw, 28px) 40px; min-width: 0; display: grid; gap: 16px; align-content: start; }
+header.head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
+header.head h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
+header.head code { color: var(--ink-faint); font: 12px var(--mono); overflow-wrap: anywhere; }
+header.head .live { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
+.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
+.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
+.tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
+.needs { display: flex; flex-wrap: wrap; gap: 8px; }
+.need { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
+.need b { margin-right: 4px; }
+.need.hot { border-color: var(--warn); background: var(--warn-soft); }
+.columns { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: start; }
+@media (max-width: 1100px) { .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
+@media (max-width: 560px) { .columns { grid-template-columns: minmax(0, 1fr); } }
+.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; gap: 8px; align-content: start; min-width: 0; }
+.col h3 { margin: 2px 4px; font: 600 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); display: flex; justify-content: space-between; }
+.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; display: grid; gap: 5px; cursor: pointer; min-width: 0; }
+.card:hover { border-color: var(--line-strong); }
+.card .t { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
+.card .t span { color: var(--ink-faint); font: 500 12px var(--mono); margin-right: 4px; }
+.meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; color: var(--ink-muted); font-size: 12px; }
+.chip { font: 600 10.5px/1 var(--mono); letter-spacing: .03em; padding: 3px 5px; border-radius: 4px; background: var(--surface-2); color: var(--ink-muted); white-space: nowrap; }
+.chip.ok { background: var(--accent-soft); color: var(--accent-strong); }
+.chip.warn { background: var(--warn-soft); color: var(--warn); }
+.chip.no { background: var(--reject-soft); color: var(--reject); }
+.chip.busy { background: var(--blue-soft); color: var(--blue); }
+.more { display: none; border-top: 1px dashed var(--line); padding-top: 6px; color: var(--ink-muted); font-size: 12.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
+.card.open .more { display: grid; gap: 6px; }
+.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
+.list { display: grid; gap: 0; }
+.list .row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
+.list .row:first-child { border-top: 0; }
+.list time { color: var(--ink-faint); font: 12px var(--mono); }
+.rows h4 { margin: 14px 0 6px; font-size: 13px; color: var(--ink-muted); }
+.rows .r { display: grid; grid-template-columns: 4.5em 5.5em minmax(0, 1fr); gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); align-items: baseline; }
+.rows .r code { font: 600 12px var(--mono); }
+.rows .r small { display: block; color: var(--ink-faint); font: 11.5px var(--mono); }
+.filters { display: flex; gap: 6px; flex-wrap: wrap; }
+.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
+.filters button.on { border-color: var(--accent); background: var(--accent-soft); }
+form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
+form label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-muted); flex: 1 1 140px; min-width: 0; }
+input, select { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 7px; padding: 7px 9px; min-width: 0; width: 100%; }
+.go { border: 0; background: var(--ink); color: var(--surface); border-radius: 7px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
+.go:hover { background: var(--accent-strong); color: var(--on-accent); }
+.small { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 7px; padding: 4px 9px; cursor: pointer; }
+table { border-collapse: collapse; width: 100%; font-size: 13px; }
+td, th { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
+th { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); border-top: 0; }
+.scroll { overflow-x: auto; }
+.console { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow: auto; }
+.console.ok { border-color: var(--accent); }
+.console.no { border-color: var(--reject); }
+.empty { color: var(--ink-faint); padding: 8px 4px; }
+:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+</style>
+</head>
+<body>
+<div class="app">
+ <aside>
+ <div class="brand"><svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect width="56" height="14" x="3" y="25" fill="var(--accent)" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg>Pullboard</div>
+ <div class="label">Projects on this machine</div>
+ <div class="projects" id="projects"><div class="empty">Loading…</div></div>
+ <div class="label">Start a board</div>
+ <form id="init-form"><label>Folder of a git repo<input id="init-path" placeholder="/path/to/repo" required></label><button class="go" type="submit">Init</button></form>
+ </aside>
+ <main>
+ <header class="head"><h1 id="name">Pullboard</h1><code id="root"></code><span class="live" id="live"></span></header>
+ <div class="needs" id="needs"></div>
+ <nav class="tabs" id="tabs">
+ <button class="tab" data-tab="board">Board</button><button class="tab" data-tab="doctrine">Doctrine</button><button class="tab" data-tab="shouts">Shouts</button><button class="tab" data-tab="fleet">Agents</button><button class="tab" data-tab="activity">Activity</button>
+ </nav>
+ <section data-pane="board">
+ <div class="panel"><form id="add-form"><label>Lane<select id="add-lane"></select></label><label style="flex:3 1 220px">Title<input id="add-title" required placeholder="What to build"></label><label style="flex:3 1 220px">Criterion<input id="add-criterion" placeholder="How a verifier knows it's done"></label><label>Spec rows<input id="add-specs" placeholder="G1,G2"></label><button class="go" type="submit">Add item</button></form></div>
+ <div class="columns" id="columns" style="margin-top:12px"></div>
+ </section>
+ <section data-pane="doctrine" class="panel"><div class="filters" id="row-filters"><button data-f="all">All rows</button><button data-f="decide">Needs your decision</button><button data-f="approved">Approved</button></div><div class="rows" id="rows"></div></section>
+ <section data-pane="shouts" class="panel"><form id="shout-form"><label>To<input id="shout-to" list="shout-targets" required placeholder="all, a lane or an agent"></label><datalist id="shout-targets"></datalist><label style="flex:4 1 280px">Message<input id="shout-text" required></label><button class="go" type="submit">Shout</button></form><div class="list" id="shouts" style="margin-top:10px"></div></section>
+ <section data-pane="fleet" class="panel"><div class="scroll"><table><thead><tr><th>Lane</th><th>State</th><th></th></tr></thead><tbody id="lanes"></tbody></table></div><div class="scroll" style="margin-top:14px"><table><thead><tr><th>Agent</th><th>Lane</th><th>Route</th><th>Worktree</th></tr></thead><tbody id="agents"></tbody></table></div></section>
+ <section data-pane="activity" class="panel"><div class="list" id="events"></div></section>
+ <div class="console" id="console" hidden></div>
+ </main>
+</div>
+<script>
+const key = new URLSearchParams(location.search).get('k') || '';
+const keep = (name, value) => { try { if (value === undefined) return localStorage.getItem(name); localStorage.setItem(name, value); } catch { return null; } return value; };
+let selected = keep('pb.project');
+let tab = keep('pb.tab') || 'board';
+let rowFilter = 'decide';
+let state = null;
+const opened = new Set();
+const $ = (id) => document.getElementById(id);
+const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
+const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };
+const clock = (iso) => new Date(iso).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
+
+async function api(path, body) {
+ const res = await fetch(path, { method: body ? 'POST' : 'GET', headers: { 'x-pullboard-key': key, ...(body ? { 'content-type': 'application/json' } : {}) }, body: body ? JSON.stringify(body) : undefined });
+ const data = await res.json();
+ if (!res.ok) throw new Error(data.error || res.status);
+ return data;
+}
+
+async function refresh() {
+ const data = await api('/api/state' + (selected ? '?root=' + encodeURIComponent(selected) : ''));
+ if ((!selected || !data.project) && data.projects.some((p) => p.ok)) {
+ const first = data.projects.find((p) => p.ok && (!selected || p.root === selected)) || data.projects.find((p) => p.ok);
+ if (first.root !== selected || !data.project) { selected = first.root; keep('pb.project', selected); return refresh(); }
+ }
+ state = data;
+ render();
+ $('live').textContent = 'live · updated ' + new Date().toLocaleTimeString();
+}
+
+function render() {
+ $('projects').innerHTML = state.projects.length ? state.projects.map((p) => '<button class="project' + (p.root === selected ? ' on' : '') + '" data-root="' + esc(p.root) + '"><b>' + esc(p.name) + '</b>' + (p.ok
+ ? '<small>' + p.building + ' building · ' + p.awaiting + ' to verify · ' + p.verified + ' verified' + (p.pending ? ' · ' + p.pending + ' questions' : '') + '</small>'
+ : '<small class="bad">' + esc(p.error) + '</small>') + '</button>').join('') : '<div class="empty">No projects yet. Run pullboard init in a repo, or start one below.</div>';
+ const project = state.project;
+ if (!project) { $('name').textContent = 'Pullboard'; return; }
+ $('name').textContent = project.root.split('/').pop();
+ $('root').textContent = project.root;
+ const items = project.items;
+ const sentBack = items.filter((i) => i.status === 'open' && i.verdict && i.verdict.decision === 'REJECT');
+ const awaiting = items.filter((i) => i.status === 'submitted');
+ const questions = project.spec.filter((r) => r.status === 'pending');
+ const drafts = project.spec.filter((r) => r.status === 'draft');
+ $('needs').innerHTML = [
+ questions.length ? '<button class="need hot" data-go="doctrine"><b>' + questions.length + '</b>questions for you</button>' : '',
+ drafts.length ? '<button class="need" data-go="doctrine"><b>' + drafts.length + '</b>draft rows to approve</button>' : '',
+ awaiting.length ? '<button class="need" data-go="board"><b>' + awaiting.length + '</b>awaiting a verdict</button>' : '',
+ sentBack.length ? '<button class="need" data-go="board"><b>' + sentBack.length + '</b>sent back for rework</button>' : '',
+ project.holds.length ? '<button class="need hot" data-go="fleet"><b>' + project.holds.length + '</b>lanes held</button>' : '',
+ ].join('');
+ const lanes = project.lanes;
+ if ($('add-lane').dataset.lanes !== lanes.join()) {
+ $('add-lane').innerHTML = lanes.map((l) => '<option>' + esc(l) + '</option>').join('');
+ $('add-lane').dataset.lanes = lanes.join();
+ }
+ $('shout-targets').innerHTML = ['all', ...lanes, ...project.agents.map((a) => a.agent_id)].map((t) => '<option value="' + esc(t) + '">').join('');
+ const card = (i) => {
+ const v = i.verdict;
+ const chip = i.status === 'verified' ? '<span class="chip ok">verified</span>' : i.status === 'submitted' ? '<span class="chip warn">to verify</span>' : i.status === 'claimed' ? '<span class="chip busy">building</span>' : v && v.decision === 'REJECT' ? '<span class="chip no">sent back</span>' : i.blockedBy.length ? '<span class="chip">waits on #' + i.blockedBy.join(', #') + '</span>' : '<span class="chip">ready</span>';
+ const who = i.status === 'claimed' ? i.owner : [i.builtBy, i.verifiedBy].filter(Boolean).join(' → ');
+ return '<div class="card' + (opened.has(i.id) ? ' open' : '') + '" data-item="' + i.id + '"><div class="t"><span>#' + i.id + '</span>' + esc(i.title) + '</div><div class="meta">' + chip + '<span class="chip">' + esc(i.lane) + '</span>' + i.specs.map((s) => '<span class="chip">' + esc(s) + '</span>').join('') + (who ? '<span>' + esc(who) + '</span>' : '') + '<span>' + ago(i.updatedAt) + '</span></div><div class="more">' + (i.criterion ? '<div><b>Criterion.</b> ' + esc(i.criterion) + '</div>' : '') + (v ? '<div><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b> by ' + esc(v.by) + ', ' + clock(v.at) + ': ' + esc(v.note) + '</div>' : '') + (i.commit ? '<div>commit ' + esc(i.commit.slice(0, 12)) + (i.merged ? ' · merged ' + esc(i.merged.slice(0, 12)) : '') + '</div>' : '') + '</div></div>';
+ };
+ const col = (title, list) => '<div class="col"><h3><span>' + title + '</span><span>' + list.length + '</span></h3>' + (list.length ? list.map(card).join('') : '<div class="empty">Nothing here.</div>') + '</div>';
+ const open = items.filter((i) => i.status === 'open' && !(i.verdict && i.verdict.decision === 'REJECT'));
+ const verified = items.filter((i) => i.status === 'verified').sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)).slice(0, 15);
+ $('columns').innerHTML = col('Open', open) + col('Building', items.filter((i) => i.status === 'claimed')) + col('To verify', awaiting) + col('Sent back', sentBack) + col('Verified', verified);
+ const rowList = (title, rows) => {
+ const shown = rows.filter((r) => rowFilter === 'all' || (rowFilter === 'decide' ? ['pending', 'draft'].includes(r.status) : r.status === 'approved'));
+ if (!shown.length) return '<h4>' + title + '</h4><div class="empty">No rows match.</div>';
+ const tone = (s) => s === 'approved' ? 'ok' : s === 'pending' ? 'no' : s === 'draft' ? 'warn' : '';
+ return '<h4>' + title + '</h4>' + shown.map((r) => '<div class="r"><code>' + esc(r.id) + '</code><span><span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span></span><div>' + esc(r.text) + '<small>' + esc(r.section) + (r.gate ? ' · gate: ' + esc(r.gate) : '') + '</small></div></div>').join('');
+ };
+ $('rows').innerHTML = rowList('Spec: what to build', project.spec) + rowList('Practice: how it is built', project.practice);
+ $('shouts').innerHTML = project.shouts.length ? project.shouts.map((s) => '<div class="row"><time>' + clock(s.shout_at) + '</time><div><b>' + esc(s.shout_from) + ' → ' + esc(s.shout_to) + '</b> ' + esc(s.shout_text) + '</div></div>').join('') : '<div class="empty">No shouts yet.</div>';
+ const held = new Map(project.holds.map((h) => [h.hold_lane, h]));
+ $('lanes').innerHTML = lanes.filter((l) => l !== 'coordinator').map((l) => '<tr><td><b>' + esc(l) + '</b></td><td>' + (held.has(l) ? '<span class="chip no">held</span> ' + esc(held.get(l).hold_reason) : '<span class="chip ok">open</span>') + '</td><td>' + (held.has(l) ? '<button class="small" data-release="' + esc(l) + '">Release</button>' : '<button class="small" data-hold="' + esc(l) + '">Hold</button>') + '</td></tr>').join('');
+ $('agents').innerHTML = project.agents.map((a) => '<tr><td><b>' + esc(a.agent_id) + '</b></td><td>' + esc(a.agent_lane) + '</td><td>' + esc(a.agent_route) + '</td><td><code>' + esc(a.agent_path) + '</code></td></tr>').join('');
+ $('events').innerHTML = project.events.map((e) => '<div class="row"><time>' + clock(e.event_at) + '</time><div><b>' + esc(e.event_by) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' #' + e.item_id : '') + '</div></div>').join('') || '<div class="empty">No activity yet.</div>';
+ showTab();
+}
+
+function showTab() {
+ document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = pane.dataset.pane !== tab; });
+ document.querySelectorAll('.tab').forEach((button) => button.classList.toggle('on', button.dataset.tab === tab));
+ document.querySelectorAll('#row-filters button').forEach((button) => button.classList.toggle('on', button.dataset.f === rowFilter));
+}
+
+async function act(command, args, root = selected) {
+ const out = $('console');
+ out.hidden = false;
+ out.className = 'console';
+ out.textContent = 'running…';
+ try {
+ const result = await api('/api/act', { root, command, args });
+ out.className = 'console ' + (result.code === 0 ? 'ok' : 'no');
+ out.textContent = '$ ' + result.command + '\\n' + (result.out + result.err).trim();
+ await refresh();
+ return result.code === 0;
+ } catch (error) {
+ out.className = 'console no';
+ out.textContent = String(error.message || error);
+ return false;
+ }
+}
+
+document.addEventListener('click', (event) => {
+ const target = event.target.closest('[data-root],[data-tab],[data-go],[data-item],[data-f],[data-hold],[data-release]');
+ if (!target) return;
+ if (target.dataset.root) { selected = target.dataset.root; keep('pb.project', selected); refresh(); }
+ else if (target.dataset.tab || target.dataset.go) { tab = target.dataset.tab || target.dataset.go; keep('pb.tab', tab); showTab(); }
+ else if (target.dataset.item) { const id = Number(target.dataset.item); opened.has(id) ? opened.delete(id) : opened.add(id); target.classList.toggle('open'); }
+ else if (target.dataset.f) { rowFilter = target.dataset.f; render(); }
+ else if (target.dataset.hold) {
+ const lane = target.dataset.hold;
+ const box = document.createElement('form');
+ box.innerHTML = '<label>Why hold ' + esc(lane) + '?<input required></label><button class="go">Hold</button>';
+ box.onsubmit = (e) => { e.preventDefault(); act('hold', { lane, reason: box.querySelector('input').value }); };
+ target.replaceWith(box);
+ box.querySelector('input').focus();
+ }
+ else if (target.dataset.release) act('release', { lane: target.dataset.release });
+});
+$('add-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ if (await act('add', { lane: $('add-lane').value, title: $('add-title').value, criterion: $('add-criterion').value, specs: $('add-specs').value })) { $('add-title').value = ''; $('add-criterion').value = ''; }
+});
+$('shout-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ if (await act('shout', { to: $('shout-to').value, text: $('shout-text').value })) $('shout-text').value = '';
+});
+$('init-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ if (await act('init', { path: $('init-path').value }, null)) $('init-path').value = '';
+});
+showTab();
+refresh().catch((error) => { $('live').textContent = 'cannot reach the view: ' + error.message; });
+setInterval(() => { if (!document.hidden) refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }); }, 3000);
+</script>
+</body>
+</html>`;
+}
diff --git a/src/projects.js b/src/projects.js
new file mode 100644
index 00000000..3c4eb7ee
--- /dev/null
+++ b/src/projects.js
@@ -0,0 +1,50 @@
+/**
+ * The projects on this machine (I8): every repo `pullboard init` set up, so `pullboard view` can show
+ * them all on one page. A plain JSON file in the person's home, or wherever PULLBOARD_HOME points,
+ * which is how tests and the tour keep their throwaway repos out of it.
+ */
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { homedir } from 'node:os';
+import { basename, join } from 'node:path';
+
+/**
+ * The registry file.
+ *
+ * @returns {string}
+ */
+export function registryFile() {
+ return join(process.env.PULLBOARD_HOME || join(homedir(), '.pullboard'), 'projects.json');
+}
+
+/**
+ * Every registered project, oldest first. An unreadable registry reads as empty.
+ *
+ * @returns {{ root: string, name: string, added: string }[]}
+ */
+export function listProjects() {
+ const file = registryFile();
+ if (!existsSync(file)) return [];
+ try {
+ const projects = JSON.parse(readFileSync(file, 'utf8')).projects;
+ return Array.isArray(projects) ? projects.filter((project) => typeof project?.root === 'string') : [];
+ } catch {
+ return [];
+ }
+}
+
+/**
+ * Add a project's main checkout to the registry, once.
+ *
+ * @param {string} root
+ * @param {Date} [now]
+ * @returns {boolean} Whether it was new.
+ */
+export function registerProject(root, now = new Date()) {
+ const projects = listProjects();
+ if (projects.some((project) => project.root === root)) return false;
+ const file = registryFile();
+ mkdirSync(join(file, '..'), { recursive: true });
+ projects.push({ root, name: basename(root), added: now.toISOString() });
+ writeFileSync(file, `${JSON.stringify({ projects }, null, 2)}\n`);
+ return true;
+}
diff --git a/src/serve.js b/src/serve.js
new file mode 100644
index 00000000..0d897be6
--- /dev/null
+++ b/src/serve.js
@@ -0,0 +1,224 @@
+/**
+ * `pullboard view` (N26, N27): the person's micro site. One page on this machine shows every
+ * registered project: items by state, what needs the person, shouts, doctrine, agents and activity,
+ * refreshing itself. Its actions run the real CLI in the project, so every rule and refusal applies
+ * exactly as at a terminal.
+ *
+ * It listens on the loopback address only and answers nothing without the session's secret and its
+ * own Host, so another site in the browser cannot reach it. It opens no outbound connection (P5).
+ */
+import { spawn } from 'node:child_process';
+import { randomBytes, timingSafeEqual } from 'node:crypto';
+import { existsSync, statSync } from 'node:fs';
+import { createServer } from 'node:http';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import * as store from './board.js';
+import { cockpitPage } from './cockpit.js';
+import { COORDINATOR, loadConfig } from './config.js';
+import { repoInfo } from './git.js';
+import { listProjects } from './projects.js';
+import { loadSpec } from './spec.js';
+
+const BIN = fileURLToPath(new URL('../bin/pullboard.js', import.meta.url));
+export const LOOPBACK = '127.0.0.1';
+
+/**
+ * Open a project's board, read from it, and always close it.
+ *
+ * @template T
+ * @param {string} root
+ * @param {(board: any, info: any, config: any) => T} read
+ * @returns {T}
+ */
+function withProject(root, read) {
+ const info = repoInfo(root);
+ const config = loadConfig(info.root);
+ const board = store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'));
+ try {
+ return read(board, info, config);
+ } finally {
+ store.closeBoard(board);
+ }
+}
+
+/**
+ * One project in the sidebar: its counts, or why it cannot be read (moved, no config).
+ *
+ * @param {{ root: string, name: string }} project
+ * @returns {any}
+ */
+function summary(project) {
+ try {
+ return withProject(project.root, (board, info, config) => {
+ const items = store.listItems(board, { all: true });
+ const count = (test) => items.filter(test).length;
+ const pending = loadSpec(info.root, config).rows.filter((row) => row.status === 'pending').length;
+ return {
+ ...project,
+ ok: true,
+ building: count((item) => item.item_status === 'claimed'),
+ awaiting: count((item) => item.item_status === 'submitted'),
+ sentBack: count((item) => item.item_status === 'open' && item.item_verdict === 'REJECT'),
+ open: count((item) => item.item_status === 'open'),
+ verified: count((item) => item.item_status === 'verified'),
+ pending,
+ holds: store.laneHolds(board).length,
+ };
+ });
+ } catch (error) {
+ return { ...project, ok: false, error: error.message };
+ }
+}
+
+/**
+ * Everything the page shows for one project.
+ *
+ * @param {string} root
+ * @returns {any}
+ */
+export function projectState(root) {
+ return withProject(root, (board, info, config) => {
+ const all = store.listItems(board, { all: true });
+ const status = new Map(all.map((item) => [item.item_id, item.item_status]));
+ const rows = (file) => loadSpec(info.root, { ...config, spec: file }).rows.map(({ id, status: state, tier, text, gate, section }) => ({ id, status: state, tier, text, gate, section }));
+ return {
+ root: info.root,
+ lanes: [COORDINATOR, ...Object.keys(config.lanes)],
+ items: all.map((item) => {
+ const verdict = store.verdictsFor(board, item.item_id).at(-1);
+ const after = item.item_after ? item.item_after.split(',').map(Number) : [];
+ return {
+ id: item.item_id,
+ title: item.item_title,
+ lane: item.item_lane,
+ status: item.item_status,
+ route: item.item_route,
+ owner: item.item_owner,
+ builtBy: item.item_built_by,
+ verifiedBy: item.item_verified_by,
+ specs: item.item_spec_ids ? item.item_spec_ids.split(',') : [],
+ criterion: item.item_criterion,
+ commit: item.item_commit,
+ merged: item.item_merged_commit,
+ blockedBy: after.filter((id) => status.get(id) !== 'verified'),
+ updatedAt: item.item_updated_at,
+ verdict: verdict ? { decision: verdict.verdict_decision, reason: verdict.verdict_reason, note: verdict.verdict_note, by: verdict.verdict_by, at: verdict.verdict_at } : null,
+ };
+ }),
+ shouts: store.recentShouts(board, 40),
+ events: store.events(board).slice(-80).reverse(),
+ agents: store.listAgents(board),
+ holds: store.laneHolds(board),
+ spec: rows(config.spec),
+ practice: rows(config.practice),
+ };
+ });
+}
+
+/**
+ * The CLI command an action from the page stands for, or null for one it does not offer.
+ *
+ * @param {string} command
+ * @param {any} args
+ * @returns {string[] | null}
+ */
+export function actionArgs(command, args = {}) {
+ const text = (value) => String(value ?? '').trim();
+ if (command === 'add') {
+ return ['add', text(args.lane), text(args.title), ...(text(args.criterion) ? ['--criterion', text(args.criterion)] : []), ...(text(args.specs) ? ['--specs', text(args.specs)] : [])];
+ }
+ if (command === 'shout') return ['shout', text(args.to), text(args.text)];
+ if (command === 'hold') return ['hold', text(args.lane), '--reason', text(args.reason)];
+ if (command === 'release') return ['hold', text(args.lane), '--off'];
+ if (command === 'init') return ['init'];
+ return null;
+}
+
+/**
+ * Run the CLI in a folder, as the person would at a terminal there.
+ *
+ * @param {string} cwd
+ * @param {string[]} args
+ * @returns {Promise<{ code: number | null, out: string, err: string }>}
+ */
+function runCli(cwd, args) {
+ return new Promise((done) => {
+ const child = spawn(process.execPath, [BIN, ...args], { cwd, env: process.env, stdio: ['ignore', 'pipe', 'pipe'] });
+ let out = '';
+ let err = '';
+ child.stdout.on('data', (chunk) => { out += chunk; });
+ child.stderr.on('data', (chunk) => { err += chunk; });
+ const timer = setTimeout(() => child.kill(), 120_000);
+ child.on('close', (code) => {
+ clearTimeout(timer);
+ done({ code, out, err });
+ });
+ });
+}
+
+/**
+ * Serve the view until stopped.
+ *
+ * @param {{ port?: number, secret?: string }} [options]
+ * @returns {Promise<{ url: string, port: number, close: () => Promise<void> }>}
+ */
+export function serveView({ port = 0, secret = randomBytes(18).toString('base64url') } = {}) {
+ const key = Buffer.from(secret);
+ let bound = 0;
+ const reply = (res, code, type, body) => {
+ res.writeHead(code, {
+ 'content-type': type,
+ 'cache-control': 'no-store',
+ 'referrer-policy': 'no-referrer',
+ 'x-content-type-options': 'nosniff',
+ 'content-security-policy': "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
+ });
+ res.end(body);
+ };
+ const json = (res, code, value) => reply(res, code, 'application/json; charset=utf-8', JSON.stringify(value));
+ const server = createServer(async (req, res) => {
+ const url = new URL(req.url ?? '/', `http://${LOOPBACK}`);
+ const given = Buffer.from(String(req.headers['x-pullboard-key'] ?? url.searchParams.get('k') ?? ''));
+ const isOwnHost = req.headers.host === `${LOOPBACK}:${bound}` || req.headers.host === `localhost:${bound}`;
+ if (!isOwnHost || given.length !== key.length || !timingSafeEqual(given, key)) return json(res, 403, { error: 'this view needs its own address and secret: open the link pullboard view printed' });
+ try {
+ if (req.method === 'GET' && url.pathname === '/') return reply(res, 200, 'text/html; charset=utf-8', cockpitPage());
+ if (req.method === 'GET' && url.pathname === '/api/state') {
+ const projects = listProjects().map(summary);
+ const root = url.searchParams.get('root');
+ const known = projects.find((project) => project.root === root && project.ok);
+ return json(res, 200, { projects, project: known ? projectState(known.root) : null });
+ }
+ if (req.method === 'POST' && url.pathname === '/api/act' && String(req.headers['content-type']).startsWith('application/json')) {
+ let raw = '';
+ for await (const chunk of req) {
+ raw += chunk;
+ if (raw.length > 100_000) return json(res, 413, { error: 'too large' });
+ }
+ const { root, command, args } = JSON.parse(raw || '{}');
+ const argv = actionArgs(command, args);
+ if (!argv) return json(res, 400, { error: `no action "${command}"` });
+ const cwd = command === 'init' ? String(args?.path ?? '').trim() : root;
+ if (command === 'init' ? !(cwd && existsSync(cwd) && statSync(cwd).isDirectory()) : !listProjects().some((project) => project.root === root)) {
+ return json(res, 400, { error: command === 'init' ? `no folder ${cwd}` : 'not a project on this machine' });
+ }
+ return json(res, 200, { command: `pullboard ${argv.join(' ')}`, ...(await runCli(cwd, argv)) });
+ }
+ return json(res, 404, { error: 'no such page' });
+ } catch (error) {
+ return json(res, 500, { error: error.message });
+ }
+ });
+ return new Promise((ready, fail) => {
+ server.once('error', fail);
+ server.listen(port, LOOPBACK, () => {
+ bound = /** @type {any} */ (server.address()).port;
+ ready({
+ url: `http://${LOOPBACK}:${bound}/?k=${secret}`,
+ port: bound,
+ close: () => new Promise((closed) => server.close(() => closed())),
+ });
+ });
+ });
+}
diff --git a/src/tour.js b/src/tour.js
index b62dcf84..27b8a7b3 100644
--- a/src/tour.js
+++ b/src/tour.js
@@ -76,7 +76,7 @@ export function tour(io) {
// Nothing of the person's git setup reaches the tour: no config files, and no GIT_ variable, such
// as GIT_DIR from a hook or GIT_CONFIG_COUNT pairs, which git reads as config too.
const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_') && name !== 'NODE_TEST_CONTEXT'));
- Object.assign(env, { PATH: `${shims}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' });
+ Object.assign(env, { PATH: `${shims}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(dir, '.pullboard') });
const repo = join(dir, 'greeter');
const app = `${repo}-app-1`;
const review = `${repo}-review-1`;
diff --git a/test/boundary.test.js b/test/boundary.test.js
index 12370a71..f0e34a10 100644
--- a/test/boundary.test.js
+++ b/test/boundary.test.js
@@ -34,9 +34,16 @@ test('the core names no model, engine or vendor; secret patterns may name the ke
assert.deepEqual(found, []);
});
-test('the core opens no network connection [P5]', () => {
+test('the core opens no outbound connection; only the view listens, on loopback, and its page calls only it [P5, N26]', () => {
+ const allowed = (file, line) =>
+ (file === 'src/serve.js' && line.trim() === "import { createServer } from 'node:http';") ||
+ (file === 'src/cockpit.js' && /^\s*const res = await fetch\(path, /.test(line));
const found = sources().flatMap(({ file, lines }) =>
- lines.flatMap((line, index) => (NETWORK.test(line) ? [`${file}:${index + 1}: ${line.trim()}`] : [])),
+ lines.flatMap((line, index) => (NETWORK.test(line) && !allowed(file, line) ? [`${file}:${index + 1}: ${line.trim()}`] : [])),
);
assert.deepEqual(found, []);
+ const serve = readFileSync(join(ROOT, 'src', 'serve.js'), 'utf8');
+ assert.match(serve, /export const LOOPBACK = '127\.0\.0\.1';/);
+ assert.match(serve, /server\.listen\(port, LOOPBACK, /);
+ assert.match(serve, /connect-src 'self'/, "the page may call nothing but its own server");
});
diff --git a/test/e2e.test.js b/test/e2e.test.js
index b3643587..b3d14c0a 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -15,6 +15,7 @@ import {
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
+import { request } from 'node:http';
import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
@@ -45,6 +46,7 @@ function sandbox() {
GIT_AUTHOR_EMAIL: '[email protected]',
GIT_COMMITTER_NAME: 'Test Agent',
GIT_COMMITTER_EMAIL: '[email protected]',
+ PULLBOARD_HOME: join(dir, 'pullboard-home'),
};
const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();
const tryGit = (cwd, ...args) => spawnSync('git', args, { cwd, env, encoding: 'utf8' });
@@ -872,3 +874,83 @@ test('worktree prints the opening lines of a subagent\'s prompt, with its folder
const entered = spawnSync('sh', ['-c', `${cdLine} pwd`], { env: { ...box.env, PULLBOARD_PATH_PROBE: 'elsewhere' }, encoding: 'utf8' });
assert.equal(entered.stdout.trim(), folder);
});
+
+/**
+ * Start `pullboard view` in a folder and read the link it prints; stop() ends it.
+ */
+async function startView(box, cwd) {
+ const child = spawn(process.execPath, [BIN, 'view', '--no-open'], { cwd, env: box.env });
+ const link = await new Promise((found, fail) => {
+ let out = '';
+ child.stdout.on('data', (chunk) => {
+ out += chunk;
+ const match = /Pullboard view: (http:\/\/127\.0\.0\.1:\d+\/\?k=\S+)/.exec(out);
+ if (match) found(new URL(match[1]));
+ });
+ child.on('exit', (code) => fail(new Error(`view exited ${code}: ${out}`)));
+ });
+ const key = link.searchParams.get('k');
+ const base = `http://127.0.0.1:${link.port}`;
+ const state = (root) => fetch(`${base}/api/state${root ? `?root=${encodeURIComponent(root)}` : ''}`, { headers: { 'x-pullboard-key': key } }).then((res) => res.json());
+ const act = (body) => fetch(`${base}/api/act`, { method: 'POST', headers: { 'x-pullboard-key': key, 'content-type': 'application/json' }, body: JSON.stringify(body) }).then((res) => res.json());
+ const stop = () => new Promise((done) => { child.once('exit', done); child.kill('SIGTERM'); });
+ return { link, key, base, state, act, stop };
+}
+
+test('view serves every project on this machine, on loopback, behind its secret and its own Host [N26, I8]', async () => {
+ const box = project();
+ box.run(box.repo, 'add', 'web', 'Page', '--specs', 'G1', '--criterion', 'renders');
+ box.run(box.repo, 'shout', 'web-1', 'the heading is in G1');
+ const registry = JSON.parse(readFileSync(join(box.env.PULLBOARD_HOME, 'projects.json'), 'utf8'));
+ assert.deepEqual(registry.projects.map((entry) => entry.root), [box.repo]);
+ const view = await startView(box, box.repo);
+ try {
+ assert.equal((await fetch(`${view.base}/`)).status, 403, 'no secret');
+ assert.equal((await fetch(`${view.base}/api/state`, { headers: { 'x-pullboard-key': 'guess' } })).status, 403, 'a wrong secret');
+ const page = await fetch(view.link);
+ assert.equal(page.status, 200);
+ assert.match(await page.text(), /<title>Pullboard<\/title>/);
+ const { projects, project: shown } = await view.state(box.repo);
+ assert.deepEqual(projects.map((entry) => [entry.name, entry.ok, entry.open]), [['repo', true, 1]]);
+ assert.deepEqual(shown.items.map((item) => [item.id, item.title, item.status, item.specs]), [[1, 'Page', 'open', ['G1']]]);
+ assert.equal(shown.shouts[0].shout_text, 'the heading is in G1');
+ assert.deepEqual(shown.spec.map((row) => [row.id, row.status]), [['G1', 'approved'], ['G2', 'approved']]);
+ assert.ok(shown.agents.some((agent) => agent.agent_id === 'web-1'));
+ const rebound = await new Promise((done) => {
+ request({ host: '127.0.0.1', port: view.link.port, path: '/api/state', headers: { host: `evil.example:${view.link.port}`, 'x-pullboard-key': view.key } }, (res) => done(res.statusCode)).end();
+ });
+ assert.equal(rebound, 403, 'the right secret from another Host, as DNS rebinding would send it');
+ } finally {
+ await view.stop();
+ }
+});
+
+test('from the view the person adds items, shouts, holds lanes and starts a board, through the CLI and its refusals [N27]', async () => {
+ const box = project();
+ const view = await startView(box, box.repo);
+ try {
+ const act = (body) => view.act({ root: box.repo, ...body });
+ const added = await act({ command: 'add', args: { lane: 'web', title: 'From the view', specs: 'G1' } });
+ assert.equal(added.code, 0, added.err);
+ assert.equal(added.command, 'pullboard add web From the view --specs G1');
+ assert.equal(JSON.parse(box.run(box.repo, 'show', '1', '--json').out).item_title, 'From the view');
+ const refused = await act({ command: 'add', args: { lane: 'web', title: 'Ghost', specs: 'Z9' } });
+ assert.equal(refused.code, 1);
+ assert.match(refused.err, /UNKNOWN_SPEC/);
+ assert.equal((await act({ command: 'shout', args: { to: 'web', text: 'from the person' } })).code, 0);
+ assert.match(box.run(box.web, 'inbox').out, /coordinator -> web: from the person/);
+ assert.equal((await act({ command: 'hold', args: { lane: 'web', reason: 'G1 is changing' } })).code, 0);
+ assert.match(box.run(box.web, 'next').err, /coordinator holds the web lane: G1 is changing/);
+ assert.equal((await act({ command: 'release', args: { lane: 'web' } })).code, 0);
+ assert.match((await act({ root: box.dir, command: 'shout', args: { to: 'all', text: 'x' } })).error, /not a project on this machine/);
+ const stranger = await fetch(`${view.base}/api/act`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ root: box.repo, command: 'shout', args: { to: 'all', text: 'x' } }) });
+ assert.equal(stranger.status, 403);
+ const other = join(box.dir, 'other');
+ mkdirSync(other);
+ box.git(other, 'init', '-q', '-b', 'main');
+ assert.equal((await view.act({ command: 'init', args: { path: other } })).code, 0);
+ assert.deepEqual((await view.state()).projects.map((entry) => entry.name).sort(), ['other', 'repo']);
+ } finally {
+ await view.stop();
+ }
+});