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.

docs(api): list local view v1 routes [N26,A2]

Corey Olsond5a312de2c89
diff --git a/docs/api.md b/docs/api.md
index 96d06ff5..323061ca 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -342,11 +342,19 @@ The server checks any Origin against its own address and grants no CORS permissi
| `GET /api/v1/boards/:board/items/:id` | One item's full detail: the fields its summary leaves out |
| `GET /api/v1/boards/:board/items?q=text` | The ids of the items whose id, title, lane, spec ids or criterion contain the text, ignoring case |
| `GET /api/v1/boards/:board/shouts/:id` | One shout from any point in the board's history, including its decision and answer fields |
+| `GET /api/v1/boards/:board/tokens` | This linked board's agent-token metadata |
+| `POST /api/v1/boards/:board/tokens` | Revoke one token named by its opaque id |
| `GET /api/v1/boards/:board/code?ref=path:lines@commit&before=...` | A bounded preview of committed file lines from that registered board |
| `GET /api/v1/boards/:board/events?after=N` | Events after sequence N, in order, and their event-log format version |
| `GET /api/v1/events?boards=<id>,<id>` | One live stream of every named board's events and changed signals, each tagged with its board |
| `POST /api/v1/boards/:board/moves` | One CLI move and its emitted event |
| `POST /api/v1/boards/:board/requests` | A person's request for the coordinator (view only) |
+| `GET /api/v1/view-link` | Whether the full-machine view can start device sign-in |
+| `POST /api/v1/view-link` | Start, inspect, cancel or continue device sign-in in that view |
+
+The local API exposes token management for a board already linked to the relay. `GET` returns `{version: 1, tokens: [...]}`; each row contains only `id`, `board`, `agent`, `created`, `expires` and `revoked`, never a bearer credential. `POST` accepts only `{id}` from that board's token list and returns `{version: 1, linked, board, url, link, sequence, behind, recovery, id, revoked}` with `revoked: true`. Revocation is a person action: the local view has the required person channel, while an ordinary `pullboard serve` API caller is refused with `B26_PERSON_CHANNEL`. An unlinked board cannot list or revoke its relay tokens.
+
+The full-machine local view calls `/api/v1/view-link` with its `X-Pullboard-Key` header only. This route rejects query strings and `Authorization`, and a project-scoped view reports `available: false` and refuses sign-in. `GET` returns `{version: 1, available}`. `POST` takes a JSON action: `{action: "start"}` returns `{version, intentId, verificationURL, userCode, expiresAt}`; `{action: "status", intentId}` returns the public state and board outcomes; `{action: "cancel", intentId}` returns the state after cancellation; and `{action: "pairing", intentId}` returns a short HTML page with a link to continue the pending phone-pairing step. The intent id must have been started in this view. Status and cancellation results include `{version, state, boards}` and may include a public `error` or `pairingCleanup`; private machine paths, relay tickets and credentials are not returned. Sign-in and pairing use the existing person flow, so completed board links are not described as rolled back if pairing is cancelled.
The boards response keeps `boards` and may include `warnings` for registered entries that could not be opened. State `seen` must be a nonnegative safe integer; omitting it retains the `unseen: null` result. State continues to include only the newest 40 shouts. Use `GET /api/v1/boards/:board/shouts/:id` to resolve an older address; its `{ shout }` result contains the complete stored shout row, including sender, recipient, text, timestamp, decision flag and reply relationship. Decision shouts also include `decision_state` (`open` or `answered`) and `decision_answer` (the reply row or `null`); other shouts use `null` for both fields. A missing id returns `NO_SHOUT` with HTTP 404; malformed ids are refused with HTTP 400. Code previews read only a registered repo's committed tree, use a plain commit SHA and at most 60 lines, and never read the working tree. The shared router lets adapters omit the optional code capability; such adapters return the versioned `CODE_NOT_AVAILABLE` refusal.
diff --git a/docs/api.test.js b/docs/api.test.js
index f5f360fd..12d741e8 100644
--- a/docs/api.test.js
+++ b/docs/api.test.js
@@ -1,3 +1,5 @@
+/** @pullboard-test-input source-tree */
+/** @pullboard-test-input docs-tree */
/** Keep the public API guide aligned with the CLI's versioned shape catalog [A1]. */
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
@@ -58,3 +60,41 @@ test('[A2] API guide documents the local HTTP response catalog', () => {
assert.match(guide, /`GET \/api\/v1\/events\?boards=<id>,<id>`/);
assert.match(guide, /`<id>:<sequence>` pairs joined by commas/);
});
+
+/** Expand the simple alternation groups used by the HTTP router's path matchers. */
+function expandRouteAlternatives(path) {
+ const group = /\(([^()]*\|[^()]*)\)/u.exec(path);
+ if (!group) return [path];
+ return group[1].split('|').flatMap(value => expandRouteAlternatives(path.replace(group[0], value)));
+}
+
+/** Collect exact and patterned v1 paths dispatched by the local view and its API router. */
+function routedV1Paths() {
+ const sources = [
+ readFileSync(new URL('../src/serve.js', import.meta.url), 'utf8'),
+ readFileSync(new URL('../src/api-http.js', import.meta.url), 'utf8'),
+ ];
+ const paths = new Set();
+ for (const source of sources) {
+ for (const match of source.matchAll(/url\.pathname\s*===\s*'([^']+)'/gu)) {
+ if (match[1].startsWith('/api/v1/')) paths.add(match[1]);
+ }
+ }
+ for (const match of sources[1].matchAll(/const\s+\w+\s*=\s*(\/[^\r\n]*\/[a-z]*)\.exec\(url\.pathname\)/gu)) {
+ let pattern = match[1].slice(1, match[1].lastIndexOf('/'));
+ pattern = pattern.replace(/^\^/u, '').replace(/\$$/u, '').replaceAll('\\/', '/');
+ pattern = pattern.replace('/boards/([^/]+)', '/boards/:board').replaceAll('([^/]+)', ':id');
+ for (const path of expandRouteAlternatives(pattern)) {
+ const normalized = path;
+ if (normalized.startsWith('/api/v1/')) paths.add(normalized);
+ }
+ }
+ return [...paths].sort();
+}
+
+test('[N26] every routed v1 path is documented', () => {
+ const paths = routedV1Paths();
+ assert.ok(paths.length > 0, 'the local view and API router expose versioned paths');
+ const missing = paths.filter(path => !guide.includes(path));
+ assert.deepEqual(missing, [], 'API guide documents every local view v1 path');
+});