@bugb-technologies/bravos 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +11 -7
  2. package/dist/ci.js +1 -1
  3. package/dist/cli.js +271 -111
  4. package/dist/codegraph.js +21 -0
  5. package/dist/context.js +1 -1
  6. package/dist/doctor.js +20 -11
  7. package/dist/global.js +3 -3
  8. package/dist/graphbin.js +2 -0
  9. package/dist/guardlink.js +1 -1
  10. package/dist/guide.js +12 -10
  11. package/dist/help.js +45 -19
  12. package/dist/hooks.js +44 -21
  13. package/dist/install.js +2 -1
  14. package/dist/lock.js +1 -0
  15. package/dist/mcp.js +21 -5
  16. package/dist/palette.js +2 -2
  17. package/dist/plugin-release.js +2 -2
  18. package/dist/plugin.js +3 -3
  19. package/dist/prefs.js +66 -0
  20. package/dist/review-wait.js +76 -0
  21. package/dist/setup-route.js +37 -0
  22. package/dist/setup.js +3 -2
  23. package/dist/skills.js +1 -1
  24. package/dist/start/answers.js +36 -7
  25. package/dist/start/index.js +190 -69
  26. package/dist/start/repos.js +1 -1
  27. package/dist/start/ui.js +2 -2
  28. package/dist/upkeep.js +89 -0
  29. package/dist/watch-frame.js +1 -1
  30. package/dist/watch.js +1 -1
  31. package/docs/GUIDE.md +23 -11
  32. package/docs/UPGRADING.md +43 -1
  33. package/hooks/lib/autopilot.mjs +3 -18
  34. package/hooks/lib/briefing.mjs +93 -14
  35. package/hooks/lib/graph-autobuild.mjs +131 -0
  36. package/hooks/lib/legacy-skills.mjs +68 -0
  37. package/hooks/lib/palette.mjs +4 -4
  38. package/hooks/lib/prefs.mjs +108 -0
  39. package/hooks/lib/refresh.mjs +45 -1
  40. package/hooks/lib/setup.mjs +8 -8
  41. package/hooks/lib/snapshot.mjs +19 -1
  42. package/hooks/session-start.mjs +7 -2
  43. package/package.json +1 -1
  44. package/skills/bravos/SKILL.md +5 -4
  45. package/skills/bravos-annotate/SKILL.md +4 -4
  46. package/skills/bravos-cicd/SKILL.md +1 -1
  47. package/skills/bravos-codegraph/SKILL.md +1 -1
  48. package/skills/bravos-context/SKILL.md +6 -6
  49. package/skills/bravos-env/SKILL.md +2 -2
  50. package/skills/bravos-env/scope.example.yaml +2 -1
  51. package/skills/bravos-prove/SKILL.md +2 -2
  52. package/skills/bravos-recheck/SKILL.md +1 -1
  53. package/skills/bravos-resync/SKILL.md +1 -1
  54. package/skills/bravos-schedule/SKILL.md +1 -1
  55. package/skills/bravos-ship/SKILL.md +3 -3
  56. package/skills/bravos-templatize/SKILL.md +1 -1
  57. package/templates/review/review.html +1 -1
package/dist/cli.js CHANGED
@@ -7,8 +7,8 @@ import { checkProofTool, formatProofTool } from './proof-tools.js';
7
7
  import { DOCTOR_HELP, INIT_HELP, PROGRAM_HELP, SYNC_HELP } from './help.js';
8
8
  import { Command, CommanderError, InvalidArgumentError, Option } from 'commander';
9
9
  import { CADENCES, CRON, WORKFLOW_NAMES, writeWorkflows } from './ci.js';
10
- import { writeCursorPointer } from './cursor.js';
11
- import { writeOmpExtension } from './omp.js';
10
+ import { CURSOR_RULE_PATH, writeCursorPointer } from './cursor.js';
11
+ import { OMP_EXTENSION_PATH, writeOmpExtension } from './omp.js';
12
12
  import { homeOf, installGlobal } from './global.js';
13
13
  import { uninstall } from './uninstall.js';
14
14
  import { checkKind, newToken, prepareReview, readAllAnswers, readDraft, renderReview, summarize, writePage } from './review.js';
@@ -17,26 +17,51 @@ import { formatRules, gatherRules } from './rules.js';
17
17
  import { spawn as spawnChild, spawnSync } from 'node:child_process';
18
18
  import { createServer as netServer } from 'node:net';
19
19
  import { dirname as pathDirname, join as pathJoin } from 'node:path';
20
- import { OPENCODE_CONFIG, writeOpencode } from './opencode.js';
20
+ import { OPENCODE_CONFIG, OPENCODE_PLUGIN_PATH, writeOpencode } from './opencode.js';
21
21
  import { GUIDE_TOPIC_IDS, renderGuide, renderGuideMarkdown } from './guide.js';
22
22
  import { detectHarnesses } from './detect.js';
23
- import { formatDoctor, runDoctor, withLicence } from './doctor.js';
23
+ import { formatDoctor, runDoctor, withLegacySkills, withLicence } from './doctor.js';
24
24
  import { ensureGuardlink, registerPrePr, whichBin, writeScope } from './guardlink.js';
25
- import { installHook, installedOptIns } from './hooks.js';
25
+ import { AGY_HOOKS_FILE, ALL_SESSION_COMMANDS, hookRegistered, installHook, installedOptIns } from './hooks.js';
26
26
  import { activate, importLicence } from './account.js';
27
27
  import { listDevices, logout, refresh as refreshDevice, revokeDevice } from './device.js';
28
28
  import * as graph from './codegraph.js';
29
29
  import { askGraph } from './watch.js';
30
30
  import { plan as setupPlan, runSast, runSetup } from './setup.js';
31
+ import { isTerminal, setupRoute } from './setup-route.js';
32
+ import { leaveHandoff } from './prefs.js';
31
33
  import { openInBrowser } from './open.js';
32
34
  import { licenceDocument, licenceLib, licenceLines, requireFeature } from './licence.js';
33
35
  import { migrateFromOldName, OLD_DIR, reportMigration } from './migrate.js';
34
36
  import { listBundledSkills } from './skills.js';
35
37
  import { installSkills, linkSkillRoots, mirrorGuardlinkSkills, skillRootsLinked } from './install.js';
36
- import { readLock, sha256, writeLock } from './lock.js';
38
+ import { LOCK_PATH, readLock, sha256, writeLock } from './lock.js';
37
39
  import { mergeCodexConfig, mergeMcpJson, selectServers } from './mcp.js';
38
40
  import { hooksDir, skillsDir as bundledSkillsDir, version } from './paths.js';
39
41
  import { BravosError } from './types.js';
42
+ // @comment -- "Which agents a repository already has Bravos installed for, read from the files Bravos wrote there: the two skills roots, the Codex and Antigravity hook registrations, and the opencode and omp plugins. Upkeep re-applies to exactly these, so a tool that happens to be on this machine, or an AGENTS.md someone added, never widens a team's setup."
43
+ export function installedAgents(root) {
44
+ const has = (rel) => existsSync(join(root, rel));
45
+ const out = [];
46
+ if (has('.claude/skills/bravos/SKILL.md'))
47
+ out.push('claude');
48
+ if (has('.agents/skills/bravos/SKILL.md')) {
49
+ if (hookRegistered(join(root, '.codex', 'hooks.json'), 'SessionStart', ALL_SESSION_COMMANDS))
50
+ out.push('agents');
51
+ try {
52
+ if ('bravos' in JSON.parse(readFileSync(join(root, AGY_HOOKS_FILE), 'utf8')))
53
+ out.push('agy');
54
+ }
55
+ catch {
56
+ /* no Antigravity registration */
57
+ }
58
+ }
59
+ if (has(OPENCODE_PLUGIN_PATH))
60
+ out.push('opencode');
61
+ if (has(OMP_EXTENSION_PATH))
62
+ out.push('omp');
63
+ return out;
64
+ }
40
65
  // @comment -- "Parses --workflows pr-gate,nightly-claude,nightly-codex,nightly-copilot; anything else is a usage error"
41
66
  function parseWorkflows(value) {
42
67
  const out = [];
@@ -105,7 +130,7 @@ function oldHookReferences(root) {
105
130
  for (const [rel, agent] of files) {
106
131
  try {
107
132
  if (readFileSync(join(root, rel), 'utf8').includes(`${OLD_DIR}/hooks/`)) {
108
- out.push(`Hooks: ${rel} still runs the old ${OLD_DIR}/hooks scripts, which are gone; run bravos sync --agent ${agent} to replace them, or remove those entries.`);
133
+ out.push(`Hooks: ${rel} still runs the old ${OLD_DIR}/hooks scripts, which are gone; run bravos setup --agent ${agent} to replace them, or remove those entries.`);
109
134
  }
110
135
  }
111
136
  catch {
@@ -116,10 +141,15 @@ function oldHookReferences(root) {
116
141
  }
117
142
  function pipeline(root, io, opts, withGuardlink, lines) {
118
143
  const dryRun = !!opts.dryRun;
144
+ // Whether Bravos was here before this run: only a first install leaves the hand-off below.
145
+ const hadLock = existsSync(join(root, LOCK_PATH));
119
146
  if (dryRun)
120
147
  lines.push('dry-run: nothing written');
121
- // @comment -- "The move from the old name runs whatever --agent selects: it removes only old-name files the old lock vouches for and moves the data folders, and creates nothing for an agent that was not chosen. bravos start always passes --agent, so skipping it there would leave every old install unmigrated."
148
+ // @comment -- "The move from the old name runs whatever --agent selects: it removes only old-name files the old lock vouches for and moves the data folders, and creates nothing for an agent that was not chosen. the guided setup always passes --agent, so skipping it there would leave every old install unmigrated."
122
149
  reportMigration(migrateFromOldName(root, { dryRun, ownSkills: listBundledSkills(io.skillsDir).map((s) => s.name) }), lines);
150
+ // Upkeep names the agents itself, from what is installed, so nothing below is decided by detection or by this machine's tools.
151
+ if (opts.refreshOnly)
152
+ opts = { ...opts, agent: installedAgents(root) };
123
153
  const detected = detectHarnesses(root);
124
154
  // @comment -- "Explicit --agent limits agent-specific writes, independent of detection and shared skill roots. Antigravity and Codex share .agents/skills but have separate hook registrations; omp/opencode alone use that skills root without installing Codex."
125
155
  const explicit = opts.agent !== undefined;
@@ -208,7 +238,8 @@ function pipeline(root, io, opts, withGuardlink, lines) {
208
238
  for (const s of mirror.skipped)
209
239
  lines.push(` skipped ${s.path} — ${s.reason}`);
210
240
  }
211
- const cursor = explicit ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
241
+ // With --agent the Cursor pointer is left alone; upkeep still refreshes one that is already there.
242
+ const cursor = explicit && !(opts.refreshOnly && existsSync(join(root, CURSOR_RULE_PATH))) ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
212
243
  if (cursor.status === 'skipped')
213
244
  lines.push(`Cursor: skipped ${cursor.path} — ${cursor.reason}`);
214
245
  else if (cursor.status === 'no-skills')
@@ -242,8 +273,8 @@ function pipeline(root, io, opts, withGuardlink, lines) {
242
273
  for (const r of hook.registered)
243
274
  lines.push(`Hooks: ${r.file} ${r.changed ? 'registered' : 'already registered'}`);
244
275
  // A repository that keeps design documents gets the pre-push check in every clone that runs init or sync, not only
245
- // in the clone of whoever added the first one.
246
- if (!dryRun && !opts.global && existsSync(join(root, '.bravos', 'context', 'sources.json')))
276
+ // in the clone of whoever added the first one. Upkeep leaves the clone's git hooks to a person.
277
+ if (!dryRun && !opts.global && !opts.refreshOnly && existsSync(join(root, '.bravos', 'context', 'sources.json')))
247
278
  lines.push(...installPrePush(root, io.env));
248
279
  // An agent left out of --agent keeps its own settings, which may still run the old-name hook the migration moved.
249
280
  for (const w of oldHookReferences(root))
@@ -252,7 +283,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
252
283
  if (opts.prePrHook) {
253
284
  const p = registerPrePr(root, { dryRun });
254
285
  if (p.status === 'no-config')
255
- lines.push(`pre_pr: ${p.path} absent, bravos's gate not listed in guardlink's agent block (run guardlink init, then bravos sync --pre-pr-hook)`);
286
+ lines.push(`pre_pr: ${p.path} absent, bravos's gate not listed in guardlink's agent block (run guardlink init, then bravos setup --pre-pr-hook)`);
256
287
  else if (p.status === 'already-registered')
257
288
  lines.push(`pre_pr: ${p.path} already lists bravos's gate`);
258
289
  else {
@@ -275,7 +306,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
275
306
  }
276
307
  const { selected, deferred } = selectServers(io.env);
277
308
  // opencode lists skills only through its skill tool and runs no hooks: commands, a plugin and MCP.
278
- const oc = explicit && !forceOpencode ? { status: 'absent' } : writeOpencode(root, io.env, selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
309
+ const oc = explicit && !forceOpencode ? { status: 'absent' } : writeOpencode(root, io.env, opts.refreshOnly ? {} : selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
279
310
  if (oc.status === 'done') {
280
311
  lines.push(`opencode: ${oc.written.length} written, ${oc.unchanged.length} unchanged, ${oc.skipped.length} skipped (plugin, /bravos commands)${oc.mcpAdded.length ? `; ${OPENCODE_CONFIG} mcp added ${oc.mcpAdded.join(', ')}` : ''}${oc.mcpUpdated?.length ? `; ${OPENCODE_CONFIG} mcp refreshed ${oc.mcpUpdated.join(', ')}` : ''}`);
281
312
  for (const s of oc.skipped)
@@ -283,9 +314,9 @@ function pipeline(root, io, opts, withGuardlink, lines) {
283
314
  }
284
315
  const mcpLine = (m) => lines.push(`MCP: ${m.path} added ${names(m.added)}; kept ${names(m.kept)}${m.updated?.length ? `; refreshed ${names(m.updated)} (it pointed at another bravos install or graph store)` : ''}`);
285
316
  if (!explicit || harnesses.includes('claude'))
286
- mcpLine(mergeMcpJson(root, selected, { dryRun }));
317
+ mcpLine(mergeMcpJson(root, selected, { dryRun, onlyExisting: opts.refreshOnly }));
287
318
  if (codex)
288
- mcpLine(mergeCodexConfig(root, selected, { dryRun }));
319
+ mcpLine(mergeCodexConfig(root, selected, { dryRun, onlyExisting: opts.refreshOnly }));
289
320
  if (deferred.length) {
290
321
  const tools = runDoctor(root, io.env).tools;
291
322
  const bin = { cxg: 'cxg', codegraph: 'codegraph-mcp' };
@@ -306,7 +337,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
306
337
  // A plain sync leaves workflows alone, but says when the installed ones are older than this bravos.
307
338
  const stale = writeWorkflows(root, { dryRun: true, installedOnly: true }).updated;
308
339
  if (stale.length)
309
- lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos sync --ci to refresh them.`);
340
+ lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos setup --ci to refresh them.`);
310
341
  }
311
342
  const cursorWritten = cursor.status === 'written' || cursor.status === 'updated' ? [cursor.path] : [];
312
343
  const ompWritten = omp.status === 'written' || omp.status === 'updated' ? [omp.path] : [];
@@ -326,7 +357,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
326
357
  // A user-level install of another version silently replaces these skills in Claude Code, so a
327
358
  // repo sync brings an existing one up to date too (never creates one; a dry run only reports;
328
359
  // BRAVOS_SYNC_GLOBAL=off keeps the two separate).
329
- // @comment -- "When the person already has a user-level install (bravos init --global) of another version, a repo sync re-applies it through installGlobal, so an older ~/.claude/skills copy never shadows the repo's; it never creates a user-level install, and BRAVOS_SYNC_GLOBAL=off opts out."
360
+ // @comment -- "When the person already has a user-level install (bravos setup --global) of another version, a repo sync re-applies it through installGlobal, so an older ~/.claude/skills copy never shadows the repo's; it never creates a user-level install, and BRAVOS_SYNC_GLOBAL=off opts out."
330
361
  let userVersion = null;
331
362
  try {
332
363
  userVersion = JSON.parse(readFileSync(pathJoin(homeOf(io.env), '.bravos', 'skills.lock'), 'utf8'))?.bravos_version ?? null;
@@ -337,13 +368,16 @@ function pipeline(root, io, opts, withGuardlink, lines) {
337
368
  if (userVersion && userVersion !== version() && resolve(homeOf(io.env)) !== resolve(root)) {
338
369
  if (dryRun)
339
370
  lines.push(`user-level bravos is ${userVersion}: a real sync would bring it to ${version()} too`);
371
+ // Upkeep writes inside the repository only: the person's own folders are theirs to update.
372
+ else if (opts.refreshOnly)
373
+ lines.push(`note: your user-level bravos (~/.claude/skills) is ${userVersion}, not ${version()}; upkeep left it alone. In your own terminal run: bravos setup --global`);
340
374
  else if (io.env.BRAVOS_SYNC_GLOBAL === 'off') {
341
- lines.push(`warning: your user-level bravos (~/.claude/skills) is ${userVersion}; Claude Code prefers it over this repo's ${version()}. Run: bravos sync --global`);
375
+ lines.push(`warning: your user-level bravos (~/.claude/skills) is ${userVersion}; Claude Code prefers it over this repo's ${version()}. Run: bravos setup --global`);
342
376
  }
343
377
  else if (io.env.CLAUDECODE) {
344
378
  // Inside a Claude Code session, writes under ~/.claude can be held back by its sandbox while the
345
379
  // lock in ~/.bravos still lands, which would mark a stale copy current. Leave the user install alone.
346
- lines.push(`warning: your user-level bravos is ${userVersion}, older than ${version()}; this runs inside a Claude Code session, which may not write ~/.claude, so it was left alone. In your own terminal run: bravos sync --global`);
380
+ lines.push(`warning: your user-level bravos is ${userVersion}, older than ${version()}; this runs inside a Claude Code session, which may not write ~/.claude, so it was left alone. In your own terminal run: bravos setup --global`);
347
381
  }
348
382
  else {
349
383
  try {
@@ -351,18 +385,22 @@ function pipeline(root, io, opts, withGuardlink, lines) {
351
385
  installGlobal(io.env, sub, { skillsDir: io.skillsDir, hooksDir: io.hooksDir });
352
386
  const skipped = sub.filter((l) => l.startsWith(' skipped'));
353
387
  if (skipped.length) {
354
- lines.push(`warning: user-level bravos only partly updated; ${skipped.length} file(s) were not written. Run: bravos sync --global`);
388
+ lines.push(`warning: user-level bravos only partly updated; ${skipped.length} file(s) were not written. Run: bravos setup --global`);
355
389
  lines.push(...skipped);
356
390
  }
357
391
  else
358
392
  lines.push(`user-level bravos updated ${userVersion} → ${version()} (~/.claude/skills, ~/.bravos/hooks), so Claude Code does not use an older copy. BRAVOS_SYNC_GLOBAL=off keeps them separate.`);
359
393
  }
360
394
  catch (e) {
361
- lines.push(`warning: could not update your user-level bravos (${e instanceof Error ? e.message : String(e)}). Run: bravos sync --global`);
395
+ lines.push(`warning: could not update your user-level bravos (${e instanceof Error ? e.message : String(e)}). Run: bravos setup --global`);
362
396
  }
363
397
  }
364
398
  }
365
- lines.push('Next: open a session. The banner and briefing load by themselves; /bravos is only for the next step.');
399
+ // @comment -- "A first install, by any route, leaves the hand-off: the next session of an agent that runs the session hook begins the context step by itself. Not for a re-apply, a dry run, a workspace member, or agents that run no hook."
400
+ const handed = withGuardlink && !hadLock && !dryRun && opts.handoff !== false && (hookHarnesses.length > 0 || agy) && leaveHandoff(root, io.env);
401
+ lines.push(handed
402
+ ? 'Next: open a session and say anything. Bravos begins by learning what the app is for, then maps the threats in your code.'
403
+ : 'Next: open a session. The banner and briefing load by themselves; /bravos is only for the next step.');
366
404
  }
367
405
  // @comment -- "Builds the commander program (init, sync, doctor); exit-code mapping lives in run()."
368
406
  export function buildProgram(io, result) {
@@ -418,52 +456,44 @@ export function buildProgram(io, result) {
418
456
  for (const l of lines)
419
457
  io.stdout(l);
420
458
  };
421
- program
422
- .command('init [dir]')
423
- .description('First install: detect agents, run guardlink init if needed, install skills, hooks and MCP wiring.')
424
- .addHelpText('after', INIT_HELP)
425
- .option('--agent <list>', 'comma-separated agents: claude,codex,agy,opencode,omp, or all', parseAgents)
426
- .addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode (default: GuardLink chooses)').choices(['inline', 'external']))
427
- .option('--no-guardlink-init', 'do not run guardlink init')
428
- .option('--force', 'overwrite edited or authored skill files')
429
- .option('--pre-pr-hook', 'also register the PreToolUse gate that checks gh pr create / gh pr ready')
430
- .option('--ci', 'also write the PR gate and nightly GitHub Actions workflows into .github/workflows/')
431
- .option('--workflows <list>', `which workflows --ci writes: ${WORKFLOW_NAMES.join(',')} (implies --ci)`, parseWorkflows)
432
- .addOption(new Option('--schedule <cadence>', 'how often the nightly workflow runs (implies --ci)').choices(CADENCES))
433
- .option('--scope', 'also write the loopback-only cxg scope starter to .guardlink/scope.yaml when absent')
434
- .option('--link-skills', 'make .agents/skills a link to .claude/skills so each skill exists once')
435
- .option('--global', 'install for your user (home folder) instead of a repository')
436
- .option('--autopilot', 'end-of-turn check plus the pre-PR gate, so upkeep happens without being asked')
437
- .option('--dry-run', 'report what would change without writing')
438
- .action((dir, opts) => guardedAsync(async (lines) => {
439
- await gateInstallFlags(opts, 'init');
459
+ // Registered first so it leads the command list in help; its options and action are attached below, once the parts it dispatches to exist.
460
+ const setupCommand = program.command('setup [dir]');
461
+ // @comment -- "The options that set Bravos up in a repository, defined once: bravos setup takes them, and so do the older init and sync, which stay registered but hidden from help so scripts, the website's setup skill and 1.8 briefings that name them keep working unchanged."
462
+ const repositoryOptions = (cmd, o) => {
463
+ cmd.option('--agent <list>', 'comma-separated agents: claude,codex,agy,opencode,omp, or all', parseAgents);
464
+ if (o.guardlink) {
465
+ cmd.addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode (default: GuardLink chooses)').choices(['inline', 'external']));
466
+ cmd.option('--no-guardlink-init', 'do not run guardlink init');
467
+ }
468
+ return cmd
469
+ .option('--force', 'overwrite edited or authored skill files')
470
+ .option('--pre-pr-hook', 'also register the PreToolUse gate that checks gh pr create / gh pr ready')
471
+ .option('--ci', 'also write the PR gate and nightly GitHub Actions workflows into .github/workflows/')
472
+ .option('--workflows <list>', `which workflows --ci writes: ${WORKFLOW_NAMES.join(',')} (implies --ci)`, parseWorkflows)
473
+ .addOption(new Option('--schedule <cadence>', 'how often the nightly workflow runs (implies --ci)').choices(CADENCES))
474
+ .option('--scope', 'also write the loopback-only cxg scope starter to .guardlink/scope.yaml when absent')
475
+ .option('--link-skills', 'make .agents/skills a link to .claude/skills so each skill exists once')
476
+ .option('--global', 'install for your user (home folder) instead of a repository')
477
+ .option('--autopilot', 'end-of-turn check plus the pre-PR gate, so upkeep happens without being asked')
478
+ .option('--dry-run', 'report what would change without writing')
479
+ .addOption(new Option('--no-handoff', 'do not leave the marker that makes the next agent session begin by itself').hideHelp());
480
+ };
481
+ // @comment -- "The repository part: the licence gate for the paid flags first, then the user-level install for --global, else the install pipeline. `first` is true for a first install (it runs guardlink init); the refusal names the command the person typed."
482
+ const repositoryAction = async (name, dir, opts, first, lines) => {
483
+ await gateInstallFlags(opts, name);
440
484
  if (opts.global)
441
485
  installGlobal(io.env, lines, { force: opts.force, dryRun: opts.dryRun, skillsDir: io.skillsDir, hooksDir: io.hooksDir });
442
486
  else
443
- pipeline(dirArg(dir), io, opts, true, lines);
444
- }));
445
- program
446
- .command('sync [dir]')
487
+ pipeline(dirArg(dir), io, opts, first, lines);
488
+ };
489
+ repositoryOptions(program
490
+ .command('init [dir]', { hidden: true })
491
+ .description('First install: detect agents, run guardlink init if needed, install skills, hooks and MCP wiring.')
492
+ .addHelpText('after', INIT_HELP), { guardlink: true }).action((dir, opts) => guardedAsync((lines) => repositoryAction('init', dir, opts, true, lines)));
493
+ repositoryOptions(program
494
+ .command('sync [dir]', { hidden: true })
447
495
  .description('Re-apply the installed bravos version to a repository (never runs guardlink init).')
448
- .addHelpText('after', SYNC_HELP)
449
- .option('--agent <list>', 'comma-separated agents: claude,codex,agy,opencode,omp, or all', parseAgents)
450
- .option('--force', 'overwrite edited or authored skill files')
451
- .option('--pre-pr-hook', 'also register the PreToolUse gate that checks gh pr create / gh pr ready')
452
- .option('--ci', 'also write the PR gate and nightly GitHub Actions workflows into .github/workflows/')
453
- .option('--workflows <list>', `which workflows --ci writes: ${WORKFLOW_NAMES.join(',')} (implies --ci)`, parseWorkflows)
454
- .addOption(new Option('--schedule <cadence>', 'how often the nightly workflow runs (implies --ci)').choices(CADENCES))
455
- .option('--scope', 'also write the loopback-only cxg scope starter to .guardlink/scope.yaml when absent')
456
- .option('--link-skills', 'make .agents/skills a link to .claude/skills so each skill exists once')
457
- .option('--global', 'install for your user (home folder) instead of a repository')
458
- .option('--autopilot', 'end-of-turn check plus the pre-PR gate, so upkeep happens without being asked')
459
- .option('--dry-run', 'report what would change without writing')
460
- .action((dir, opts) => guardedAsync(async (lines) => {
461
- await gateInstallFlags(opts, 'sync');
462
- if (opts.global)
463
- installGlobal(io.env, lines, { force: opts.force, dryRun: opts.dryRun, skillsDir: io.skillsDir, hooksDir: io.hooksDir });
464
- else
465
- pipeline(dirArg(dir), io, opts, false, lines);
466
- }));
496
+ .addHelpText('after', SYNC_HELP), { guardlink: false }).action((dir, opts) => guardedAsync((lines) => repositoryAction('sync', dir, opts, false, lines)));
467
497
  program
468
498
  .command('licence')
469
499
  .alias('license')
@@ -518,27 +548,9 @@ export function buildProgram(io, result) {
518
548
  else
519
549
  throw new BravosError(`unknown account action ${JSON.stringify(action)}: activate, import <file>, status, refresh, devices, revoke <id> or logout`);
520
550
  }));
521
- program
522
- .command('setup')
523
- .description('Put the binaries bravos drives on this machine: the analyzer (bravos-cli, SAST) and the code graph (codegraph-build, codegraph-mcp) are licensed bundles fetched through the account portal, verified and staged under $BRAVOS_HOME; --tools adds guardlink and cxg through npm and cargo.')
524
- .option('--analyzer', 'only the analyzer bundle')
525
- .option('--codegraph', 'only the code graph bundle')
526
- .option('--tools', 'also guardlink (npm) and cxg (cargo); needs -y')
527
- .option('--check', 'report what is here and what setup would do; changes nothing')
528
- .option('--dry-run', 'say what would be fetched or run; changes nothing')
529
- .option('-y, --yes', 'run the package-manager installs, and refetch a bundle that is already staged')
530
- .option('--json', 'with --check: print the plan as JSON (bravos.setup-plan/v1)')
531
- .action((opts) => guardedAsync(async (lines) => {
532
- if (opts.check && opts.json) {
533
- const p = await setupPlan(io.env);
534
- lines.push(JSON.stringify({ schema: 'bravos.setup-plan/v1', plan: p.licence.licensed ? 'licensed' : p.licence.state, items: p.items }, null, 2));
535
- return;
536
- }
537
- lines.push(...(await runSetup(io.env, opts, { echo: io.stdout })));
538
- }));
539
551
  program
540
552
  .command('graph [question] [args...]')
541
- .description('Ask the code graph (Team plan): `graph build [DIR] [--scip MODE]` indexes a repository; `graph <question> [args] --json` asks it (attack-surface, entry-points, callers <file::symbol>, reachable-sinks, call-chain, …; the same answers as the codegraph_ MCP tools); `graph --json` lists every question this machine\'s binary answers.')
553
+ .description('Ask the code graph (Team plan): `graph build [DIR] [--scip MODE]` indexes a repository; `graph <question> [args] --json` asks it (attack-surface, entry-points, callers <file::symbol>, reachable-sinks, call-chain, …; the same answers as the codegraph_ MCP tools); `graph mcp` serves those tools over MCP on stdio (what .mcp.json registers); `graph --json` lists every question this machine\'s binary answers.')
542
554
  .option('-C, --dir <dir>', 'the repository (default: the current directory)')
543
555
  .option('--json', 'print the answer as JSON')
544
556
  .option('--scip <mode>', 'build: how the type checkers run — no-exec (default), auto, trusted, isolate, off')
@@ -557,6 +569,11 @@ export function buildProgram(io, result) {
557
569
  throw new BravosError(L.refusal(lic, 'codegraph', `bravos graph ${question ?? ''}`.trim()));
558
570
  }
559
571
  const root = dirArg(opts.dir ?? (question === 'build' && args[0] && !args[0].startsWith('--') ? args.shift() : undefined));
572
+ // The server .mcp.json registers: stdio is the agent's, so nothing else is written to stdout.
573
+ if (question === 'mcp') {
574
+ result.code = await graph.serveMcp(root, io.env);
575
+ return;
576
+ }
560
577
  if (question === 'build') {
561
578
  const r = graph.build(root, io.env, { scip: opts.scip, mode: opts.mode, json: opts.json });
562
579
  lines.push((r.stdout || r.stderr).trim());
@@ -607,22 +624,17 @@ export function buildProgram(io, result) {
607
624
  io.stderr(r.stderr.replace(/\n$/, ''));
608
625
  result.code = r.status ?? 1;
609
626
  }));
610
- // @comment -- "bravos start: the guided first run (src/start). Interactive in a terminal; --yes takes every default and never invents what a person must answer. It installs through these same commands, run in-process."
611
- program
612
- .command('start [dir]')
613
- .description('Guided first-run setup: licence, tools, repository, agents, PR checks, schedule and testing permission, one question at a time. Nothing changes until you confirm.')
614
- .option('--again', 'ask again, with your previous answers selected')
615
- .option('-y, --yes', 'no questions: take every default (testing permission stays unrecorded)')
616
- .addOption(new Option('--preset <name>', 'starting point').choices(['annotate', 'pr', 'everything']))
617
- .action((dir, opts) => guardedAsync(async () => {
627
+ // @comment -- "bravos setup: the guided first run (src/start). Interactive in a terminal; --yes takes every default and never invents what a person must answer. It installs through these same commands, run in-process."
628
+ // @comment -- "The guided setup (and its unattended --yes form), shared by bravos setup and the older bravos start: builds what the wizard needs (a prompter for a terminal or a scripted one, this CLI run in-process and as a child, the licence, the clipboard) and runs it. Without a terminal and without --yes it refuses, naming the command that was typed."
629
+ const wizardAction = async (name, dir, opts) => {
618
630
  const { runStart } = await import('./start/index.js');
619
631
  const ui = await import('./start/ui.js');
620
632
  const { plan: startPlan } = await import('./setup.js');
621
633
  const { licenceStatus } = await import('./licence.js');
622
634
  const { bravosHome } = await import('./palette.js');
623
- const interactive = !opts.yes && !!process.stdout.isTTY && !!process.stdin.isTTY;
635
+ const interactive = !opts.yes && isTerminal(io);
624
636
  if (!opts.yes && !interactive)
625
- throw new BravosError('bravos start asks questions, so it needs a terminal. In a script use: bravos start --yes --preset pr <dir>');
637
+ throw new BravosError(`bravos ${name} asks questions, so it needs a terminal. In a script use: bravos ${name} --yes --preset pr <dir>`);
626
638
  const prompter = interactive ? ui.terminalPrompter() : ui.scriptedPrompter({}, io.stdout);
627
639
  const capture = async (argv) => {
628
640
  const out = [];
@@ -630,7 +642,7 @@ export function buildProgram(io, result) {
630
642
  const code = await run(argv, { ...io, stdout: (x) => out.push(x), stderr: (x) => err.push(x) });
631
643
  return { code, out, err };
632
644
  };
633
- result.code = await runStart({ dir, again: opts.again, yes: opts.yes, preset: opts.preset }, {
645
+ result.code = await runStart({ dir, again: opts.again, yes: opts.yes, preset: opts.preset, command: name }, {
634
646
  prompter,
635
647
  env: io.env,
636
648
  cwd: process.cwd(),
@@ -667,6 +679,93 @@ export function buildProgram(io, result) {
667
679
  },
668
680
  today: () => new Date().toISOString().slice(0, 10),
669
681
  });
682
+ };
683
+ program
684
+ .command('start [dir]', { hidden: true })
685
+ .description('Guided first-run setup: licence, tools, repository, agents, PR checks, schedule and testing permission, one question at a time. Nothing changes until you confirm.')
686
+ .option('--again', 'ask again, with your previous answers selected')
687
+ .option('-y, --yes', 'no questions: take every default (testing permission stays unrecorded)')
688
+ .addOption(new Option('--preset <name>', 'starting point').choices(['annotate', 'pr', 'everything']))
689
+ .action((dir, opts) => guardedAsync(() => wizardAction('start', dir, opts)));
690
+ // @comment -- "Upkeep: what a plain bravos setup does where nobody can be asked (an agent's shell, a script, a pipe). It brings what is already installed up to date and nothing more. The repository's Bravos files are re-applied only where Bravos is installed and this bravos is not the older side, and only for the agents the repository already has (refreshOnly). Bravos's own signed bundles are fetched only when they are behind the version this bravos pins. It never installs Bravos into a repository, never runs the guardlink and cxg installers, never writes to the person's own folders, and it exits 0 with a line for everything it left to a person, so a session briefing can tell an agent to run it without asking."
691
+ const upkeepAction = async (root, dryRun, lines) => {
692
+ const { gatherUpkeep } = await import('./upkeep.js');
693
+ const u = await gatherUpkeep(root, io.env);
694
+ lines.push('bravos setup: no terminal here, so this is upkeep only: nothing is asked and nothing new is installed. In a terminal, bravos setup is the guided setup.');
695
+ if (u.repo === null)
696
+ lines.push(`repository: Bravos is not set up in ${root}; nothing was changed. A person sets it up: bravos setup in a terminal, or bravos setup --yes ${JSON.stringify(root)}`);
697
+ else if (u.sync.files === 0)
698
+ lines.push(`repository: up to date with bravos ${u.cli}`);
699
+ else if (u.sync.direction === 'repo-newer')
700
+ lines.push(`repository: its Bravos files are from ${u.repo}, newer than this bravos (${u.cli}); nothing was changed, because an older bravos would roll them back. Update bravos: npm install -g @bugb-technologies/bravos@latest`);
701
+ else {
702
+ lines.push(`repository: ${u.sync.files} file${u.sync.files === 1 ? '' : 's'} behind bravos ${u.cli}${dryRun ? ' would be' : ''} brought up to date`);
703
+ const sub = [];
704
+ pipeline(root, io, { refreshOnly: true, dryRun }, false, sub);
705
+ // The pipeline's own closing line is for a person after a first install; everything else it said is the record of what changed.
706
+ lines.push(...sub.filter((l) => !l.startsWith('Next: open a session')).map((l) => ` ${l}`));
707
+ }
708
+ for (const b of u.bundles) {
709
+ lines.push(...(await runSetup(io.env, { [b.id]: true, dryRun }, { echo: io.stdout })));
710
+ }
711
+ // Absent pieces are named, never fetched here: a first install is a person's go-ahead.
712
+ const plan = await setupPlan(io.env);
713
+ for (const item of plan.items) {
714
+ if (item.present)
715
+ continue;
716
+ if (item.id === 'analyzer' || item.id === 'codegraph') {
717
+ if (item.licensed)
718
+ lines.push(`${item.id}: not installed; left for a person's go-ahead: bravos setup --${item.id}`);
719
+ }
720
+ else
721
+ lines.push(`${item.id}: not installed; left for a person's go-ahead: bravos setup --tools -y`);
722
+ }
723
+ };
724
+ // @comment -- "bravos setup: the one command. It looks at what was typed and whether there is a terminal (src/setup-route.ts) and does one job: the read-only check, the machine part, the user-level install, the repository part by flags, an unattended first setup, the guided wizard, or upkeep. It is declared after the wizard and repository actions it dispatches to."
725
+ const SETUP_FLAGS = 'bravos setup: --tools, --analyzer and --codegraph set up this machine; the other flags set up a repository. Run them as two commands, for example: bravos setup --tools -y, then bravos setup --agent claude';
726
+ repositoryOptions(setupCommand
727
+ .description('Set Bravos up, here and on this machine, doing only what is missing. In a terminal it is a guided setup: sign in, install the tools, then this repository\'s agents, PR checks and testing permission; in a repository that already has Bravos it only brings this machine and the repository up to date (--change re-asks the repository\'s choices). Without a terminal (an agent, a script) a plain bravos setup only brings what is already installed up to date. Flags do one part by hand: --tools, --analyzer, --codegraph for this machine; --agent, --autopilot, --ci and the rest for the repository; --yes for an unattended first setup; --check to look and change nothing.')
728
+ .option('--change', 'ask this repository\'s questions again, with the recorded answers selected')
729
+ .addOption(new Option('--again', 'the earlier name of --change').hideHelp())
730
+ .addOption(new Option('--preset <name>', 'starting point for the guided setup').choices(['annotate', 'pr', 'everything']))
731
+ .option('--analyzer', 'this machine: only the analyzer bundle')
732
+ .option('--codegraph', 'this machine: only the code graph bundle')
733
+ .option('--tools', 'this machine: guardlink (npm) and cxg (cargo); needs -y')
734
+ .option('--check', 'report what is here and what setup would do; changes nothing')
735
+ .option('-y, --yes', 'alone: no questions, set this repository up with the defaults (or join it). With --tools, --analyzer or --codegraph: run the installers, and fetch a staged bundle again')
736
+ .option('--json', 'with --check: print the plan as JSON (bravos.setup-plan/v1)'), { guardlink: true });
737
+ setupCommand.action((dir, opts) => guardedAsync(async (lines) => {
738
+ const given = new Set(Object.keys(opts).filter((k) => setupCommand.getOptionValueSource(k) === 'cli'));
739
+ if (given.has('again'))
740
+ given.add('change');
741
+ const route = setupRoute(given, isTerminal(io));
742
+ if (route === 'conflict')
743
+ throw new BravosError(SETUP_FLAGS);
744
+ if (route === 'needs-terminal')
745
+ throw new BravosError('bravos setup asks questions here, so it needs a terminal. Without one: bravos setup --yes [--preset pr] [dir]');
746
+ if (route === 'check' || route === 'machine') {
747
+ if (dir)
748
+ throw new BravosError(`bravos setup ${route === 'check' ? '--check' : '--tools, --analyzer and --codegraph'} is about this machine and takes no folder`);
749
+ if (route === 'check' && opts.json) {
750
+ const p = await setupPlan(io.env);
751
+ lines.push(JSON.stringify({ schema: 'bravos.setup-plan/v1', plan: p.licence.licensed ? 'licensed' : p.licence.state, items: p.items }, null, 2));
752
+ return;
753
+ }
754
+ lines.push(...(await runSetup(io.env, { analyzer: opts.analyzer, codegraph: opts.codegraph, tools: opts.tools, check: opts.check, dryRun: opts.dryRun, yes: opts.yes }, { echo: io.stdout })));
755
+ return;
756
+ }
757
+ if (route === 'upkeep') {
758
+ await upkeepAction(dirArg(dir), !!opts.dryRun, lines);
759
+ return;
760
+ }
761
+ if (route === 'global' || route === 'repository') {
762
+ // A repository that has Bravos is re-applied to (as sync did); one that does not gets a first install (as init did).
763
+ const first = !existsSync(join(dirArg(dir), LOCK_PATH));
764
+ await repositoryAction('setup', dir, opts, first, lines);
765
+ return;
766
+ }
767
+ // unattended or wizard
768
+ await wizardAction('setup', dir, { again: opts.change || opts.again, yes: route === 'unattended', preset: opts.preset });
670
769
  }));
671
770
  program
672
771
  .command('doctor [dir]')
@@ -675,7 +774,7 @@ export function buildProgram(io, result) {
675
774
  .action((dir) => guardedAsync(async (lines) => {
676
775
  const L = await licenceLib();
677
776
  const v = L.status(io.env);
678
- lines.push(formatDoctor(withLicence(runDoctor(dirArg(dir), io.env), L.planLine(v), v.licensed)));
777
+ lines.push(formatDoctor(await withLegacySkills(withLicence(runDoctor(dirArg(dir), io.env), L.planLine(v), v.licensed), io.env)));
679
778
  for (const name of ['guardlink', 'cxg'])
680
779
  lines.push(formatProofTool(checkProofTool(name, io.env)));
681
780
  }));
@@ -751,6 +850,33 @@ export function buildProgram(io, result) {
751
850
  else
752
851
  throw new BravosError(`unknown context action '${action}'; use add, update, list, check, gate or decline`);
753
852
  }));
853
+ // @comment -- "bravos upkeep: what has fallen behind the installed bravos, here and on this machine: the repository's copies of the skills and hooks, and staged bundles older than this version pins; bravos setup brings both up to date. Read-only, no network, free; the session hook asks it at every start so the agent can run those two commands itself."
854
+ program
855
+ .command('upkeep [dir]')
856
+ .description('Say what is behind the installed bravos: this repository\'s copies of the skills and hooks, and staged bundles older than this version pins. bravos setup brings both up to date. Read-only; no network; free; runs no model.')
857
+ .option('--json', 'print bravos.upkeep/v1')
858
+ .action((dir, opts) => guardedAsync(async (lines) => {
859
+ const { gatherUpkeep, formatUpkeep } = await import('./upkeep.js');
860
+ const u = await gatherUpkeep(dirArg(dir), io.env);
861
+ lines.push(...(opts.json ? [JSON.stringify(u)] : formatUpkeep(u)));
862
+ }));
863
+ // @comment -- "bravos prefs: what this person told Bravos once so no session asks again. `prefs get` shows it; `prefs set commits <commit|leave|ask> --by <name>` records the answer about committing Bravos's own files. Kept under the git directory of this clone, never committed."
864
+ program
865
+ .command('prefs <action> [args...]')
866
+ .description('Your standing answers for this clone, kept under its git directory and never committed: `prefs get` shows them; `prefs set commits <commit|leave|ask> --by "<your name>"` says whether your agent commits Bravos\'s own files (annotations, intent, definitions, tests) without asking, always leaves them for you, or asks each session. Free; runs no model.')
867
+ .option('-C, --dir <dir>', 'the repository (default: the current directory)')
868
+ .option('--by <name>', 'set: whose answer this is')
869
+ .option('--json', 'get: print JSON')
870
+ .action((action, args, opts) => guardedAsync(async (lines) => {
871
+ const { getPrefs, setCommits } = await import('./prefs.js');
872
+ const dir = dirArg(opts.dir);
873
+ if (action === 'get' && args.length === 0)
874
+ lines.push(...(await getPrefs(dir, io.env, !!opts.json)));
875
+ else if (action === 'set' && args[0] === 'commits' && args.length === 2)
876
+ lines.push(...(await setCommits(dir, args[1], opts.by, io.env)));
877
+ else
878
+ throw new BravosError('usage: bravos prefs get [--json] | bravos prefs set commits <commit|leave|ask> --by "<your name>"');
879
+ }));
754
880
  // @comment -- "bravos rules: the design rules (INV-n in the intent, each a #inv- threat) with where the code enforces each and what testing has shown. Read-only and free; runs guardlink parse and hypothesis list, no model."
755
881
  program
756
882
  .command('rules [dir]')
@@ -767,6 +893,7 @@ export function buildProgram(io, result) {
767
893
  .option('--no-serve', 'write the page as a file instead of serving it; Save then downloads the answers')
768
894
  .option('--no-open', 'do not open a browser, only print the URL')
769
895
  .option('--share', 'render the page for a shared claude.ai artifact (Claude Code only; the agent publishes it)')
896
+ .option('--wait [seconds]', 'serve the page, then wait until the person presses Done and print everyone\'s answers; after the wait (default 90 seconds) it says "review: waiting" and exits 0, and running it again keeps waiting on the same page')
770
897
  .action((kind, dir, opts) => guardedAsync(async (lines) => {
771
898
  const root = dirArg(dir);
772
899
  checkKind(kind);
@@ -792,18 +919,50 @@ export function buildProgram(io, result) {
792
919
  openInBrowser(pathJoin(root, rel), io.env);
793
920
  return;
794
921
  }
795
- const port = await freePort();
796
- const token = newToken();
797
- const child = spawnChild(process.execPath, [pathJoin(pathDirname(fileURLToPath(import.meta.url)), 'review-server.js'), root, kind, token, String(port)], { detached: true, stdio: 'ignore' });
798
- child.unref();
799
- const url = `http://127.0.0.1:${port}/?t=${token}`;
800
- if (!(await waitUp(url)))
801
- throw new BravosError('the review server did not start; try bravos review --no-serve');
802
- lines.push(`Review page: ${url}`);
803
- lines.push(`Answers save to .guardlink/${kind}-answers/<name>.json. Teammates run bravos review ${kind} after pulling. The page stops on Done or after 30 minutes idle.`);
804
- lines.push(`When everyone is done: bravos review ${kind} --summary`);
805
- if (opts.open !== false)
806
- openInBrowser(url, io.env);
922
+ // @comment -- "With --wait the command stays until the person presses Done (the page's server exits), then prints the answers, so an agent continues without anyone typing 'done'. What it prints before waiting goes out at once, because the agent's shell shows nothing until the command ends otherwise. A page already open for this review is waited on, never opened twice."
923
+ const RW = await import('./review-wait.js');
924
+ let waitFor = null;
925
+ if (opts.wait !== undefined) {
926
+ try {
927
+ waitFor = RW.waitSeconds(opts.wait);
928
+ }
929
+ catch (e) {
930
+ throw new BravosError(e instanceof Error ? e.message : String(e));
931
+ }
932
+ }
933
+ const commonDir = (await (await import('./prefs.js')).prefsLib()).gitCommonDir(root, io.env);
934
+ const say = (l) => (waitFor === null ? lines.push(l) : io.stdout(l));
935
+ let live = waitFor === null ? null : RW.readLive(commonDir, kind);
936
+ if (live)
937
+ say(`Review page: ${live.url} (already open; waiting for Done)`);
938
+ else {
939
+ const port = await freePort();
940
+ const token = newToken();
941
+ const child = spawnChild(process.execPath, [pathJoin(pathDirname(fileURLToPath(import.meta.url)), 'review-server.js'), root, kind, token, String(port)], { detached: true, stdio: 'ignore' });
942
+ child.unref();
943
+ const url = `http://127.0.0.1:${port}/?t=${token}`;
944
+ if (!(await waitUp(url)))
945
+ throw new BravosError('the review server did not start; try bravos review --no-serve');
946
+ if (child.pid) {
947
+ live = { pid: child.pid, port, url };
948
+ RW.writeLive(commonDir, kind, live);
949
+ }
950
+ say(`Review page: ${url}`);
951
+ say(`Answers save to .guardlink/${kind}-answers/<name>.json. Teammates run bravos review ${kind} after pulling. The page stops on Done or after 30 minutes idle.`);
952
+ if (waitFor === null)
953
+ lines.push(`When everyone is done: bravos review ${kind} --summary`);
954
+ if (opts.open !== false)
955
+ openInBrowser(url, io.env);
956
+ }
957
+ if (waitFor === null || !live)
958
+ return;
959
+ if (!(await RW.waitGone(live.pid, waitFor * 1000))) {
960
+ lines.push(`review: waiting — the page is still open. Run bravos review ${kind} --wait again to keep waiting; it will not open a second page.`);
961
+ return;
962
+ }
963
+ RW.clearLive(commonDir, kind);
964
+ const { files, skipped } = readAllAnswers(root, draft);
965
+ lines.push(files.length ? 'review: done' : 'review: closed with no answers saved', summarize(draft, files, skipped));
807
966
  }));
808
967
  program
809
968
  .command('next [dir]')
@@ -820,7 +979,8 @@ export function buildProgram(io, result) {
820
979
  lines.push(JSON.stringify(s, null, 2));
821
980
  return;
822
981
  }
823
- lines.push(`bravos setup ${s.done}/${s.total} for ${inputs.repo}`);
982
+ // "Setup", not "bravos setup": that is the name of a command now.
983
+ lines.push(`Setup ${s.done}/${s.total} for ${inputs.repo}`);
824
984
  // Which plan this machine is on, so the Team-plan steps below read as a choice and not a fault.
825
985
  try {
826
986
  if (inputs.licence?.state)
@@ -925,11 +1085,11 @@ export function buildProgram(io, result) {
925
1085
  const ws = await import('./workspace.js');
926
1086
  const env = io.env;
927
1087
  const cwd = process.cwd();
928
- // bravos init (no bravos yet) or sync in one folder, in-process, summarised to one line.
1088
+ // bravos setup (no bravos yet) or sync in one folder, in-process, summarised to one line.
929
1089
  const install = async (path, appFolder = false) => {
930
1090
  const out = [];
931
1091
  const fresh = !appFolder && !existsSync(pathJoin(path, '.bravos', 'skills.lock'));
932
- const code = await run([fresh ? 'init' : 'sync', path], { ...io, stdout: (s) => out.push(s), stderr: (s) => out.push(s) });
1092
+ const code = await run([fresh ? 'init' : 'sync', path, ...(fresh ? ['--no-handoff'] : [])], { ...io, stdout: (s) => out.push(s), stderr: (s) => out.push(s) });
933
1093
  return `${code === 0 ? '✔' : '✘'} bravos ${fresh ? 'init' : 'sync'} ${path}${code === 0 ? '' : `: ${out.filter(Boolean).slice(-1)[0] ?? `exit ${code}`}`}`;
934
1094
  };
935
1095
  const known = (name) => {
@@ -1227,7 +1387,7 @@ export async function run(argv, io = {}) {
1227
1387
  const result = { code: 0 };
1228
1388
  // @comment -- "Bare bravos in a repository bravos has not set up yet points at the guided setup first"
1229
1389
  if (argv.length === 0 && !existsSync(join(process.cwd(), '.bravos')))
1230
- full.stdout('New here? Run bravos start: a guided setup, one question at a time.\n');
1390
+ full.stdout('New here? Run bravos setup: a guided setup, one question at a time.\n');
1231
1391
  try {
1232
1392
  await buildProgram(full, result).parseAsync(argv, { from: 'user' });
1233
1393
  }