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.

fix(relay): relay help and pair say what each output is for [H17]

Corey Olson76a38c72263e
diff --git a/src/help.js b/src/help.js
index ce71173b..8953cd37 100644
--- a/src/help.js
+++ b/src/help.js
@@ -213,6 +213,7 @@ const HELP_EXAMPLES = {
verify: 'pullboard verify 12 accept --note "removed the fix; the test failed"',
answer: 'pullboard answer 12 "done"', pass: 'pullboard pass 12 "please decide"',
status: 'pullboard status', view: 'pullboard view', mcp: 'pullboard mcp', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',
+ relay: 'pullboard relay on --all', 'relay recover': 'pullboard relay recover --skip 12',
'lane add': 'pullboard lane add web --owns apps/web/', lane: 'pullboard lane add web --owns apps/web/',
roadmap: 'pullboard roadmap', milestone: 'pullboard milestone add "0.7.0" --items 12,13',
runner: 'pullboard runner add studio --slots 2 --browser 1', 'runner add': 'pullboard runner add studio --slots 2 --browser 1',
@@ -237,6 +238,7 @@ const HELP_ALIASES = {
status: { usage: 'pullboard status', source: 'whoami' },
done: { usage: 'pullboard done <id>', source: 'submit <id>' },
inbox: { usage: 'pullboard inbox', source: null },
+ relay: { source: 'relay', every: true },
lifecycle: { usage: 'pullboard lifecycle', source: null },
escalate: { usage: 'pullboard escalate <id> --note "..." [--note-file <file>]', source: 'escalate <id> --note "what was tried and how it failed"', extraFlags: ['--note-file <file>'] },
'view export': { usage: 'pullboard view --export <dir>', source: 'view' },
@@ -290,8 +292,8 @@ function commandHelpRows(fullHelp) {
const next = tokens[parts.length];
return !next || next.startsWith('--') || next.startsWith('<') || next.startsWith('[') || next === '|';
});
- const usages = alias ? [alias.usage] : matches.length ? [...new Set(matches.map((row) => `pullboard ${row.usage}`))] : [`pullboard ${name}`];
- const foundFlags = [...matches.flatMap((row) => row.details.flatMap((line) => line.match(/--[a-z][a-z-]*(?:\s+(?:<[^>]+>|"[^"]*"|\[[^\]]+\]|[A-Za-z][A-Za-z0-9|_-]*))?/gu) ?? [])), ...(alias?.extraFlags ?? []), '--json', '--help', ...(name === 'help' ? ['--all'] : [])];
+ const usages = alias && !alias.every ? [alias.usage] : matches.length ? [...new Set(matches.map((row) => `pullboard ${row.usage}`))] : [`pullboard ${name}`];
+ const foundFlags = [...matches.flatMap((row) => row.details.flatMap((line) => line.match(/--[a-z][a-z-]*(?:\s+(?:<[^>]+>|"[^"]*"|\[(?!-)[^\]]+\]|[A-Za-z][A-Za-z0-9|_-]*))?/gu) ?? [])), ...(alias?.extraFlags ?? []), '--json', '--help', ...(name === 'help' ? ['--all'] : [])];
const flagMap = new Map();
for (const flag of foundFlags) {
const key = flag.split(/\s/u, 1)[0];
diff --git a/src/relay-pairing-client.js b/src/relay-pairing-client.js
index 6d2b885d..3fbe4444 100644
--- a/src/relay-pairing-client.js
+++ b/src/relay-pairing-client.js
@@ -9,7 +9,7 @@ import { forgetBoardKey, readBoardKey, storeBoardKey } from './relay-key.js';
import { encodeBoardKey } from './seal.js';
import { createPairingCode, openPairingBundle, parsePairingCode, sealPairingBundle } from './pairing.js';
import { terminalQr } from './qr.js';
-import { DEFAULT_RELAY, originRepository, relayStatus, syncRelay } from './relay.js';
+import { DEFAULT_RELAY, originRepository, syncRelay } from './relay.js';
import { ENGINE_VERSION } from './machine.js';
import { Refused } from './refused.js';
import { requirePersonChannel } from './person.js';
@@ -139,10 +139,12 @@ export async function relayPair(root, io) {
const sealed = await sealPairingBundle(code.code, bundle);
const response = await relayRequest(state.url, state.token,
`/api/v1/pairings/${code.board}/${code.locator}`, { sealed });
- const viewLink = relayStatus(root).link;
+ // The board page lives on the relay this board is linked to, which may differ from the hosted default.
+ const viewLink = state.url + '/#board=' + state.board;
io.result?.({ code: code.code, link: viewLink, expiresIn: response.expiresIn });
- io.say(`One-time code (10 minutes, one use): ${code.code}`);
- io.say(`Phone link: ${viewLink}`);
+ const address = state.url === DEFAULT_RELAY ? '' : ' --url ' + state.url;
+ io.say(`For another computer: in its clone of this repository, run pullboard init, then pullboard relay join ${code.code}${address}. The code works once, for 10 minutes.`);
+ io.say(`For a phone: scan this QR code, or open ${viewLink}. Pair a new phone first with pullboard relay on --all.`);
io.say(terminalQr(viewLink));
return 0;
}
diff --git a/src/relay-setup.js b/src/relay-setup.js
index ef931dbf..b2ed471c 100644
--- a/src/relay-setup.js
+++ b/src/relay-setup.js
@@ -12,6 +12,13 @@ import { deliverDeviceWraps, relayDeviceRequest, relayMachineSignIn, relayMachin
import { terminalQr } from './qr.js';
import { Refused } from './refused.js';
+/** Say which paired phone must approve a new board's link, and when the request ends in this computer's time. */
+function approvalWait(name, pending, devices) {
+ const phone = devices.find(entry => entry.deviceId === pending.context.device)?.label ?? 'your paired phone';
+ const expires = new Date(pending.context.expires).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit', timeZoneName: 'short' });
+ return 'waiting for phone approval: approve linking ' + name + ' on ' + phone + ' by ' + expires;
+}
+
/** Return local opt-in gaps without contacting the relay or renewing a person session. */
export function unlinkedRelayProjects() {
const machine = readRelayMachine();
@@ -19,7 +26,7 @@ export function unlinkedRelayProjects() {
return listApiProjects().filter(project => !machine.excluded.includes(project.root)).flatMap(project => {
try { if (relayStatus(project.root).linked) return []; } catch { /* Preserve the registered project as a named finding. */ }
const pending = machine.approvals.find(entry => entry.root === project.root);
- return [{ code: pending ? 'PHONE_APPROVAL_PENDING' : 'RELAY_NOT_LINKED', message: pending ? 'waiting for phone approval: ' + project.name + '; expires ' + new Date(pending.context.expires).toISOString() : 'not linked: ' + project.name + '; run pullboard relay on --all', next: pending && Date.now() < pending.context.expires ? 'Approve the named link on your paired phone.' : 'pullboard relay on --all' }];
+ return [{ code: pending ? 'PHONE_APPROVAL_PENDING' : 'RELAY_NOT_LINKED', message: pending ? approvalWait(project.name, pending, machine.devices) : 'not linked: ' + project.name + '; run pullboard relay on --all', next: pending && Date.now() < pending.context.expires ? 'Approve the named link on your paired phone.' : 'pullboard relay on --all' }];
});
}
@@ -37,6 +44,8 @@ export async function autoLinkProject(root, io) {
if (machine.excluded.includes(project) || relayStatus(project).linked) return;
const name = listApiProjects().find(entry => entry.root === project)?.name ?? project;
let pending = machine.approvals.find(entry => entry.root === project);
+ // Only the command that publishes the request prints the wait; later commands poll quietly.
+ let announce = false;
try {
if (pending && Date.now() >= pending.context.expires) throw new Refused('PHONE_APPROVAL_EXPIRED', 'Link approval expired; run pullboard relay on --all explicitly to link this project.');
let source;
@@ -59,11 +68,13 @@ export async function autoLinkProject(root, io) {
if (!source?.token?.startsWith('pm_')) throw new Refused('RELAY_SESSION', 'Restore the publishing board link or run pullboard relay on --all.');
if (!pending.published) {
await publishPhoneApproval(source, pending, io, relayDeviceRequest);
+ announce = true;
updateRelayMachine(state => { const entry = state.approvals.find(value => value.context.id === pending.context.id); if (entry) entry.published = true; });
}
const document = await relayDeviceRequest(source, '/api/v1/devices/approvals/' + pending.context.id, {}, io);
if (document.approval.state !== 'approved') {
- io.err('waiting for phone approval: ' + name + '; expires ' + new Date(pending.context.expires).toISOString() + '; local work continues.'); return;
+ if (announce) io.err(approvalWait(name, pending, machine.devices) + '; local work continues.');
+ return;
}
const privateKey = await restoreLinkReply(pending.replyKey);
const result = await openApproval(privateKey, JSON.parse(Buffer.from(document.approval.response, 'base64url').toString('utf8')), pending.context, 'reply');
diff --git a/test/pairing.test.js b/test/pairing.test.js
index 9e033a19..5465b080 100644
--- a/test/pairing.test.js
+++ b/test/pairing.test.js
@@ -302,7 +302,7 @@ test('[H15,H17] production CLI pairs a real second clone and reads the same boar
assert.equal(printed.code, 0, 'the linked CLI publishes a one-use pairing envelope');
assert.match(printed.document.code, /^[0-9a-f]{32}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}$/);
assert.equal(printed.document.expiresIn, 600);
- assert.match(printed.document.link, /^https:\/\/app\.pullboard\.dev\/#board=/);
+ assert.ok(printed.document.link.startsWith(box.origin + '/#board='), 'the phone link uses the relay this board is linked to');
const state = JSON.parse(readFileSync(box.linkFile, 'utf8'));
const { locator } = parsePairingCode(printed.document.code);
const staleClient = await fetch(box.origin + '/api/v1/pairings/' + state.board + '/' + locator + '/consume', {
diff --git a/test/relay-setup-once.test.js b/test/relay-setup-once.test.js
index 9f725e6d..967dd5cc 100644
--- a/test/relay-setup-once.test.js
+++ b/test/relay-setup-once.test.js
@@ -229,7 +229,8 @@ test('set up once links three registered boards, later registration and a persis
assert.equal(linkProposal.published, true);
const approvalPosts = () => box.calls.filter(call => call.method === 'POST' && call.path === '/api/v1/devices/approvals').length;
assert.equal(approvalPosts(), 1, 'registration publishes one proposal');
- const pendingMessage = 'waiting for phone approval: fourth-project; expires ' + new Date(linkProposal.context.expires).toISOString();
+ const pendingMessage = 'waiting for phone approval: approve linking fourth-project on Phone browser by '
+ + new Date(linkProposal.context.expires).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit', timeZoneName: 'short' });
const statusPending = await command(fourth, box.env, ['status']).done;
assert.equal(statusPending.code, 0, 'status remains available while a new board awaits phone approval');
const doctor = await command(fourth, box.env, ['doctor']).done;
diff --git a/test/relay-setup.test.js b/test/relay-setup.test.js
index f03c5893..ea04a158 100644
--- a/test/relay-setup.test.js
+++ b/test/relay-setup.test.js
@@ -1,5 +1,8 @@
/** The view uses the actual device authorization and all-board linking path without a terminal [H5,N26]. */
import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import { readFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { test } from 'node:test';
@@ -231,3 +234,101 @@ test("the view's sign-in links every board without a terminal or a stored sessio
});
}
});
+
+const CLI = resolve(import.meta.dirname, '../bin/pullboard.js');
+
+test('relay help lists every relay command, with a whole example [H17]', () => {
+ const printed = spawnSync(process.execPath, [CLI, 'relay', '--help'], { cwd: tmpdir(), encoding: 'utf8' });
+ assert.equal(printed.status, 0, printed.stderr);
+ const [usage, rest] = printed.stdout.split('\nFlags:\n');
+ for (const command of ['relay [on|off|pair|join <code>]', 'relay on --all', 'relay devices', 'relay revoke <device>',
+ 'relay tokens', 'relay revoke <token-id>', 'relay recover --skip <sequence>']) {
+ assert.ok(usage.includes('pullboard ' + command), 'relay help lists pullboard ' + command);
+ }
+ const example = rest.split('\nExample:\n')[1].trim();
+ assert.equal(example, 'pullboard relay on --all', 'the example is one whole command a person can paste');
+ assert.ok(!/--all \[/u.test(rest), 'flags name --all alone');
+});
+
+test('relay pair labels the code for a computer and the QR for a phone [H17]', async (t) => {
+ const box = await relayClientFixture(t);
+ await box.link();
+ const cliModule = pathToFileURL(resolve(import.meta.dirname, '../src/cli.js')).href;
+ const result = await box.script(`
+import { main } from ${JSON.stringify(cliModule)};
+let output = '';
+const streams = { cwd: ${JSON.stringify(box.root)}, stdout: { write: part => { output += part; } }, stderr: { write() {} } };
+const code = await main(['relay', 'pair'], streams);
+process.stdout.write(JSON.stringify({ code, lines: output.split('\\n') }));
+`);
+ assert.equal(result.code, 0, 'the private pair script completes');
+ const { code, lines } = result.document;
+ assert.equal(code, 0, 'relay pair publishes a code');
+ const board = JSON.parse(readFileSync(box.linkFile, 'utf8')).board;
+ const computer = lines.findIndex(line => line.startsWith('For another computer: '));
+ assert.ok(computer >= 0, 'the one-time code is labelled for another computer');
+ assert.match(lines[computer], new RegExp('run pullboard init, then pullboard relay join ' + board + '\\.[A-Za-z0-9_.-]+ --url '
+ + box.origin.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&') + '\\. The code works once, for 10 minutes\\.$', 'u'),
+ 'the computer line is the relay join command for this relay');
+ const phone = lines.findIndex(line => line.startsWith('For a phone: scan this QR code'));
+ assert.ok(phone > computer, 'the QR is labelled for a phone');
+ assert.ok(lines[phone].includes(box.origin + '/#board=' + board), 'the phone link uses the relay this board is linked to');
+ assert.ok((lines[phone + 1] ?? '').startsWith('\u001b[30;47m'), 'the QR follows its phone label');
+ assert.ok(!lines.join('\n').includes('app.pullboard.dev'), 'a board on another relay never points at the hosted default');
+});
+
+test('the approval wait names the phone in local time once [H17]', async (t) => {
+ const box = await relayClientFixture(t);
+ await box.link();
+ const module = name => JSON.stringify(pathToFileURL(resolve(import.meta.dirname, '../src/' + name)).href);
+ const fixtureModule = JSON.stringify(pathToFileURL(resolve(import.meta.dirname, 'fixture-child.js')).href);
+ const result = await box.script(`
+import { readFileSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { mkdirSync } from 'node:fs';
+import { main } from ${module('cli.js')};
+import { readRelayMachine, updateRelayMachine } from ${module('relay-machine.js')};
+import { runFixtureGit } from ${fixtureModule};
+process.env.TZ = 'America/Chicago';
+const root = ${JSON.stringify(box.root)};
+const link = JSON.parse(readFileSync(${JSON.stringify(box.linkFile)}, 'utf8'));
+const pair = await crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, ['deriveBits']);
+const { kty, crv, x, y } = await crypto.subtle.exportKey('jwk', pair.publicKey);
+updateRelayMachine(state => {
+ state.autoLink = true;
+ state.owner = { account: link.account, url: link.url };
+ state.devices.push({ deviceId: 'device-' + 'a'.repeat(32), account: link.account, url: link.url, fingerprint: 'b'.repeat(64),
+ label: 'Kitchen phone', createdAt: new Date().toISOString(), publicKey: { kty, crv, x, y } });
+});
+const originalFetch = globalThis.fetch;
+globalThis.fetch = async (input, options) => {
+ const address = new URL(input instanceof Request ? input.url : input);
+ // The stand-in phone never answers, so the link request stays pending.
+ if (address.pathname.startsWith('/api/v1/devices/')) {
+ const body = address.pathname === '/api/v1/devices/approvals' ? { version: 1 } : { version: 1, approval: { state: 'pending' } };
+ return new Response(JSON.stringify(body), { status: 200, headers: { 'content-type': 'application/json' } });
+ }
+ return originalFetch(input, options);
+};
+const other = join(dirname(root), 'waiting-board');
+mkdirSync(other);
+for (const args of [['init','-q','-b','main'], ['-c','commit.gpgsign=false','commit','--allow-empty','-q','-m','chore: waiting board'],
+ ['remote','add','origin','[email protected]:fixture/repository.git']]) runFixtureGit(args, { cwd: other, env: process.env });
+let errors = '';
+const streams = { cwd: other, stdin: process.stdin, stdout: { isTTY: false, write() {} }, stderr: { write: part => { errors += part; } } };
+const codes = [];
+for (const argv of [['init'], ['status'], ['list']]) codes.push(await main(argv, streams));
+globalThis.fetch = originalFetch;
+const approval = readRelayMachine().approvals.find(entry => entry.root.endsWith('waiting-board'));
+const expected = new Date(approval.context.expires).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit', timeZoneName: 'short', timeZone: 'America/Chicago' });
+process.stdout.write(JSON.stringify({ codes, lines: errors.split('\\n').filter(line => line.includes('waiting for phone approval')),
+ expected, iso: new Date(approval.context.expires).toISOString() }));
+`);
+ assert.equal(result.code, 0, 'the private approval-wait script completes');
+ const { codes, lines, expected, iso } = result.document;
+ assert.deepEqual(codes, [0, 0, 0], 'init, status and list complete while the link waits');
+ assert.equal(lines.length, 1, 'three commands in a row print the wait once');
+ assert.equal(lines[0], 'waiting for phone approval: approve linking waiting-board on Kitchen phone by ' + expected + '; local work continues.',
+ 'the wait names the phone and the expiry in local time');
+ assert.ok(!lines[0].includes(iso), 'the expiry is never printed in UTC');
+});