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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(relay): relay on says who signed in and what it linked [H5,I1]
Corey Olson550a840a0186
diff --git a/src/cli.js b/src/cli.jsindex 8e575399..f188781c 100644--- a/src/cli.js+++ b/src/cli.js@@ -3816,7 +3816,8 @@ async function runCommand(argv, io) {const result = first === 'on' ? await relayOn(ctx.info.root, values.url, io): first === 'off' ? await relayOff(ctx.info.root, io) : relayStatus(ctx.info.root);io.result?.(result);- io.say(result.linked ? `${result.link}\nrelay: sequence ${result.sequence}; ${result.behind} pending uploads${result.recovery?.pending ? `; recovery pending for sequence ${result.recovery.skip}; retry ${result.recovery.next}` : ''}` : (result.notice || 'relay off; the local board is complete'));+ const boardName = listApiProjects().find((project) => project.root === ctx.info.root)?.name ?? basename(ctx.info.root);+ io.say(result.linked ? `${result.link}\nrelay: ${boardName} (board ${result.board}) is linked for GitHub ${result.login || `account ${result.account}`}; sequence ${result.sequence}; ${result.behind} pending uploads${result.recovery?.pending ? `; recovery pending for sequence ${result.recovery.skip}; retry ${result.recovery.next}` : ''}` : (result.notice || 'relay off; the local board is complete'));return 0;}if (command === 'blueprint' && first === 'save') {diff --git a/src/relay-setup.js b/src/relay-setup.jsindex ef931dbf..b37b9b21 100644--- a/src/relay-setup.js+++ b/src/relay-setup.js@@ -107,23 +107,26 @@ async function linkProjects(session, io, { onBoardOutcome } = {}) {const machine = readRelayMachine();const linked = [];const failed = [];- for (const project of listApiProjects()) {+ const projects = listApiProjects();+ for (const project of projects) {if (machine.excluded.includes(project.root)) {onBoardOutcome?.({ root: project.root, name: project.name, outcome: 'skipped', reason: 'Excluded from automatic linking on this machine.' });+ io.say(`Did not link ${project.name}: it is excluded from automatic linking on this machine.`);continue;}try {const result = await relayOn(project.root, session.url, io, { session, quiet: true, strict: true });linked.push({ project: project.name, root: project.root, board: result.board });onBoardOutcome?.({ root: project.root, name: project.name, outcome: 'linked', reason: '' });- io.say(`linked: ${project.name}`);+ io.say(`Linked ${project.name}.`);} catch (error) {const reason = error instanceof Refused ? error.message : 'Restore this registered project and retry.';failed.push({ project: project.name, root: project.root, reason });onBoardOutcome?.({ root: project.root, name: project.name, outcome: 'failed', reason });- io.err(`not linked: ${project.name}; ${reason}`);+ io.err(`Did not link ${project.name}: ${reason}`);}}+ io.say(`Linked ${linked.length} of ${projects.length} registered ${projects.length === 1 ? 'board' : 'boards'}.`);return { linked, failed };}@@ -169,9 +172,12 @@ async function pairFirstDevice(session, board, linked, io, { signal, onPairingURif (signal?.aborted || interrupted) pairingOutcome = 'cancelled';else if (onPairingURL) onPairingURL({ url: link, expires: pending.expires });else {+ io.say('Now waiting for a phone to pair. On your phone, scan the code below or open this link.');io.say('Pair your phone once: ' + link);try { io.say(terminalQr(link)); }catch (error) { if (error.code !== 'PAIR_LINK_LONG') throw error; io.say('Open the pairing link above.'); }+ // Ctrl-C reaches the stop handler above, which keeps every linked board and exits cleanly.+ io.say(`To skip pairing, press Ctrl-C. The linked boards stay linked, and pullboard relay on --all gives a fresh code later. This code works until ${new Date(pending.expires).toISOString()}.`);}while (!signal?.aborted && !interrupted && Date.now() < pending.expires) {let result;@@ -230,6 +236,7 @@ export async function relayOnAll(address, io, { signal, onPairingURL, onSignIn,await revokeRelayPersonSession(session, io);return { outcome: 'cancelled' };}+ io.say(`Signed in to GitHub as ${session.login || `account ${session.account}`}.`);try { await flushRevocations(session, io); }catch (error) {if (!signal?.aborted) throw error;@@ -246,6 +253,7 @@ export async function relayOnAll(address, io, { signal, onPairingURL, onSignIn,updateRelayMachine(state => { state.autoLink = true; state.owner = { account: session.account, url: session.url }; state.approvals = []; });const result = await linkProjects(session, io, { onBoardOutcome });const devices = readRelayMachine().devices.filter(device => device.account === session.account && device.url === session.url);+ if (devices.length) io.say('Your phone is already paired; the linked boards appear there.');const pairing = devices.length || !result.linked.length ? { paired: devices.length > 0 }: await pairFirstDevice(session, result.linked[0].board, result.linked, io, { signal, onPairingURL });return { ...result, ...pairing, autoLink: true };diff --git a/src/relay.js b/src/relay.jsindex 6767a6df..fad5d923 100644--- a/src/relay.js+++ b/src/relay.js@@ -249,7 +249,7 @@ function summary(root, state, { pairing = false } = {}) {if (state.unlinking) return { linked: false, board: state.board, url: state.url, link: '', sequence: state.sequence, behind: 0, cleanup: true, recovery: recoverySummary(state) };const fragment = pairing ? '&key=' + encodeBoardKey(readBoardKey(state.board)) : '';const oversizedSnapshot = snapshotSize(state);- return { linked: true, board: state.board, url: state.url,+ return { linked: true, board: state.board, url: state.url, account: state.account ?? '', login: state.login ?? '',link: 'https://app.pullboard.dev/#board=' + state.board + fragment,sequence: state.sequence, behind: (state.baselinePause ? behind(root, state) : state.mode === 'ordered' ? Number(Boolean(state.pending)) : behind(root, state)) + Number(Boolean(state.snapshot || state.checkpoint)),recovery: recoverySummary(state),@@ -1354,8 +1354,11 @@ export async function relayOn(root, address, io, { session, credential, quiet =const issued = reusableCredential ?? await request({ ...state, token: signed.token }, '/auth/machines', { method: 'POST', body: { board: state.board, machine } }, io);if (!/^pm_[A-Za-z0-9_-]{43}$/u.test(issued.token ?? '') || issued.board !== state.board || issued.machine !== machine) throw new Refused('RELAY_RESPONSE', 'the relay did not issue this board’s machine credential; sign in again');// Cached agent credentials belong to the account that minted them.- if (state.account !== account) delete state.agentTokens;+ if (state.account !== account) { delete state.agentTokens; delete state.login; }state.account = account;+ // Kept so relay status can name who linked the board; a phone-approved credential carries none.+ const login = signed.login ?? signed.user?.login;+ if (typeof login === 'string' && login) state.login = login;state.token = issued.token;state.tokenId = issued.id;state.machine = machine;@@ -1447,7 +1450,8 @@ export async function relayMachineSignIn(address, io, { signal, onSignIn } = {})return { outcome: 'cancelled' };}if (typeof signed.user?.id !== 'string') throw new Refused('RELAY_RESPONSE', 'Sign in again to receive an authenticated account identity.');- return { token: signed.token, id: signed.id, account: signed.user.id, url };+ // The login is display text only: the account id stays the identity every check compares.+ return { token: signed.token, id: signed.id, account: signed.user.id, login: typeof signed.user.login === 'string' ? signed.user.login : '', url };}/** Share the existing bounded transport only with fixed account/device endpoints. */diff --git a/test/relay-setup.test.js b/test/relay-setup.test.jsindex f03c5893..69ac0674 100644--- a/test/relay-setup.test.js+++ b/test/relay-setup.test.js@@ -1,10 +1,12 @@/** The view uses the actual device authorization and all-board linking path without a terminal [H5,N26]. */import assert from 'node:assert/strict';-import { resolve } from 'node:path';+import { mkdirSync, readFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';import { pathToFileURL } from 'node:url';import { test } from 'node:test';import * as setup from '../src/relay-setup.js';import { relayClientFixture } from './relay-client-fixture.js';+import { runFixtureChild, startFixtureChild } from './fixture-child.js';/** Run the public view adapter in a process whose complete home, registry and boards are private. */async function viewScenario(box, mode) {@@ -231,3 +233,63 @@ test("the view's sign-in links every board without a terminal or a stored sessio});}});++/** Run the production CLI in plain words, with a finite hang ceiling and stdout kept as text. */+function plainCommand(root, env, args) {+ const child = startFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });+ const output = { stdout: '', stderr: '' };+ child.stdout.setEncoding('utf8').on('data', value => { output.stdout += value; });+ child.stderr.setEncoding('utf8').on('data', value => { output.stderr += value; });+ const done = new Promise((resolveResult, reject) => {+ child.once('error', reject);+ child.once('close', code => resolveResult({ code, ...output }));+ });+ return { child, output, done };+}++test('relay on --all says who signed in, what it linked and what it waits for [H5,I1]', async (t) => {+ const box = await relayClientFixture(t);+ const second = join(dirname(box.root), 'second-board');+ mkdirSync(second);+ for (const args of [['init', '-q', '-b', 'main'], ['-c', 'commit.gpgsign=false', 'commit', '--allow-empty', '-q', '-m', 'fixture base'],+ ['remote', 'add', 'origin', '[email protected]:fixture/repository.git']]) {+ assert.equal(runFixtureChild('git', args, { cwd: second, env: box.env }).status, 0);+ }+ assert.equal(runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), 'init', '--json'], { cwd: second, env: box.env }).status, 0,+ 'the second board registers through the actual init command');+ const setup = plainCommand(box.root, box.env, ['relay', 'on', '--all', '--url', box.origin]);+ t.after(async () => { if (setup.child.exitCode === null) setup.child.kill('SIGTERM'); await setup.done; });+ const deadline = Date.now() + 20_000; // budget: hang ceiling for the loopback sign-in, two links and the first pairing poll.+ // Every pairing line is written before the first enrollment poll, so that poll marks the wait.+ while (!box.calls.some(call => call.method === 'GET' && call.path.startsWith('/api/v1/devices/enrollments/'))) {+ assert.ok(Date.now() < deadline && setup.child.exitCode === null, 'relay on --all reaches its pairing wait');+ await new Promise(done => setTimeout(done, 25));+ }+ setup.child.kill('SIGINT');+ const finished = await setup.done;+ assert.equal(finished.code, 0, 'Ctrl-C during the pairing wait keeps the links and exits cleanly');+ const waiting = finished.stdout.split('Boards linked; phone pairing stopped.')[0];+ const lines = waiting.split('\n');+ assert.ok(lines.includes('Signed in to GitHub as fixture-user.'), 'it names the GitHub account it signed in as');+ assert.ok(lines.includes('Linked repo.') && lines.includes('Linked second-board.'), 'it names each board it linked');+ assert.ok(lines.includes('Linked 2 of 2 registered boards.'), 'it says how many registered boards it linked');+ assert.ok(lines.includes('Now waiting for a phone to pair. On your phone, scan the code below or open this link.'), 'it says what it waits for');+ const pairLink = lines.find(line => line.startsWith('Pair your phone once: '));+ assert.match(pairLink ?? '', /^Pair your phone once: http:\/\/127\.0\.0\.1:\d+\/#device=/u, 'it gives the pairing link beside the code');+ assert.match(waiting, /^To skip pairing, press Ctrl-C\. The linked boards stay linked, and pullboard relay on --all gives a fresh code later\./mu,+ 'it says how to skip the wait');+ assert.ok(lines.indexOf('Signed in to GitHub as fixture-user.') < lines.indexOf('Linked repo.')+ && lines.indexOf('Linked 2 of 2 registered boards.') < lines.indexOf('Now waiting for a phone to pair. On your phone, scan the code below or open this link.'),+ 'it says each step in the order it happens');+ assert.doesNotMatch(finished.stdout + finished.stderr, /\b(?:ps|pm|pa|pd|pg)_[A-Za-z0-9_-]{20,}/u, 'no token or session is printed');+ assert.equal((finished.stdout.match(/#device=/gu) ?? []).length, 1, 'the pairing secret appears only in the one existing link');++ const board = JSON.parse(readFileSync(join(box.root, '.git/pullboard/relay.json'), 'utf8')).board;+ const status = plainCommand(box.root, box.env, ['relay']);+ const shown = await status.done;+ assert.equal(shown.code, 0, shown.stderr);+ const statusLine = shown.stdout.split('\n').find(line => line.startsWith('relay: ')) ?? '';+ assert.ok(statusLine.startsWith(`relay: repo (board ${board}) `), `relay status names the linked board: ${statusLine}`);+ assert.ok(statusLine.includes(' is linked for GitHub fixture-user; '), `relay status names the linked account: ${statusLine}`);+ assert.match(statusLine, /; sequence \d+; \d+ pending uploads$/u, 'relay status still gives the sequence and pending uploads');+});