@bugb-technologies/bravos 1.18.0 → 1.22.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 (45) hide show
  1. package/dist/account.js +19 -2
  2. package/dist/cli.js +133 -15
  3. package/dist/context.js +126 -3
  4. package/dist/cursor.js +4 -2
  5. package/dist/dashboard.js +9 -0
  6. package/dist/device.js +3 -1
  7. package/dist/doctor.js +4 -0
  8. package/dist/guide.js +7 -3
  9. package/dist/help.js +15 -8
  10. package/dist/instruction-blocks.js +257 -0
  11. package/dist/principles.js +279 -0
  12. package/dist/review-server.js +19 -4
  13. package/dist/review-wait.js +11 -0
  14. package/dist/review.js +342 -41
  15. package/dist/rules.js +82 -6
  16. package/dist/uninstall.js +9 -2
  17. package/docs/GUIDE.md +18 -2
  18. package/docs/UPGRADING.md +63 -0
  19. package/hooks/autopilot.mjs +2 -1
  20. package/hooks/cards.mjs +23 -5
  21. package/hooks/coach.mjs +3 -0
  22. package/hooks/invite.mjs +10 -0
  23. package/hooks/lib/audience.mjs +83 -0
  24. package/hooks/lib/briefing.mjs +83 -2
  25. package/hooks/lib/context.mjs +57 -1
  26. package/hooks/lib/display.mjs +11 -0
  27. package/hooks/lib/licence.mjs +2 -1
  28. package/hooks/lib/machine.mjs +77 -0
  29. package/hooks/lib/pre-pr.mjs +82 -1
  30. package/hooks/lib/principles.mjs +513 -0
  31. package/hooks/lib/refresh.mjs +11 -1
  32. package/hooks/lib/replay.mjs +218 -100
  33. package/hooks/pre-pr.mjs +3 -0
  34. package/hooks/session-start.mjs +35 -7
  35. package/package.json +1 -1
  36. package/skills/bravos/SKILL.md +1 -0
  37. package/skills/bravos-context/SKILL.md +4 -4
  38. package/skills/bravos-principles/SKILL.md +52 -0
  39. package/templates/dashboard/dashboard.html +75 -1
  40. package/templates/omp/bravos.js +10 -1
  41. package/templates/opencode/bravos.js +11 -2
  42. package/templates/review/review.html +140 -11
  43. package/templates/workflows/bravos-nightly-claude.yml +1 -1
  44. package/templates/workflows/bravos-nightly-codex.yml +1 -1
  45. package/templates/workflows/bravos-pr-gate.yml +1 -1
package/dist/account.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { hostname } from 'node:os';
4
4
  import { join } from 'node:path';
5
- import { refreshLib, userAgent } from './device.js';
5
+ import { machineLib, refreshLib, userAgent } from './device.js';
6
6
  import { openInBrowser } from './open.js';
7
7
  import { licenceLib, licenceLines } from './licence.js';
8
8
  import { BravosError } from './types.js';
@@ -66,7 +66,15 @@ export async function activate(io) {
66
66
  const ua = { 'User-Agent': userAgent(), Accept: 'application/json' };
67
67
  let start;
68
68
  try {
69
- const r = await f(`${origin}${ACTIVATION_PATH}`, { method: 'POST', headers: { ...ua, 'Content-Type': 'application/json' }, body: JSON.stringify({ device_name: deviceName(), refresh: true }) });
69
+ // The machine's one-way fingerprint (hooks/lib/machine.mjs): the portal's
70
+ // one-free-trial rule tells machines apart by it. Null in a container or CI,
71
+ // which the portal allows and flags; the raw machine id never leaves here.
72
+ const machine = (io.machine ?? (await machineLib()).machineFingerprint)(io.env);
73
+ const r = await f(`${origin}${ACTIVATION_PATH}`, {
74
+ method: 'POST',
75
+ headers: { ...ua, 'Content-Type': 'application/json' },
76
+ body: JSON.stringify({ device_name: deviceName(), refresh: true, machine: machine.key, ...(machine.key ? {} : { machine_reason: machine.reason }) }),
77
+ });
70
78
  if (r.status === 404 || r.status === 405)
71
79
  throw new BravosError(`${origin} does not offer CLI sign-in yet; download the licence from ${L.ACCOUNT_LICENCES} and run bravos account import <file>`);
72
80
  if (!r.ok)
@@ -114,14 +122,19 @@ export async function activate(io) {
114
122
  // The portal answers 402 when the account has no plan and its one trial is used up: nothing is written, Free keeps working.
115
123
  if (r.status === 402) {
116
124
  let upgrade = L.ACCOUNT_UPGRADE;
125
+ let error = null;
117
126
  try {
118
127
  const b = (await r.json());
128
+ error = b?.error;
119
129
  if (typeof b?.upgrade === 'string' && b.upgrade.startsWith(origin + '/'))
120
130
  upgrade = b.upgrade;
121
131
  }
122
132
  catch {
123
133
  /* the default page */
124
134
  }
135
+ // The portal's one-free-trial rule: this person, or this machine, had a trial under another account.
136
+ if (error === 'trial_used')
137
+ throw new BravosError(`a free trial has already been used by you or on this machine, so a new one was not started and no licence was written; this machine stays on Free (the research loop keeps working). Choose a plan at ${upgrade}, or write to support@bugb.report if you think this is a mistake`);
125
138
  throw new BravosError(`this account's Team trial has ended and it has no plan, so no licence was written; this machine stays on Free (the research loop keeps working). Choose a plan at ${upgrade}, then run bravos account activate again`);
126
139
  }
127
140
  // 403: the person was signed in but the portal will not license this machine for them. Nothing is written.
@@ -139,6 +152,10 @@ export async function activate(io) {
139
152
  }
140
153
  if (error === 'device_limit')
141
154
  throw new BravosError(`you already have the most machines your account allows, so no licence was written; remove one at ${manage} (or run bravos account devices / bravos account revoke <id> on a machine that is signed in), then run bravos account activate again`);
155
+ if (error === 'update_cli')
156
+ throw new BravosError(`this version of bravos cannot start a trial; update it (npm install -g @bugb-technologies/bravos), then run bravos account activate again`);
157
+ if (error === 'use_terminal')
158
+ throw new BravosError(`a trial starts from the terminal: run bravos account activate on the machine you want to use and enter the code it shows`);
142
159
  if (error === 'licence_not_assigned')
143
160
  throw new BravosError(`you do not hold a licence on your team's account yet, so no licence was written; this machine stays on Free. Ask an owner or admin to assign you one, or request it at ${manage}, then run bravos account activate again`);
144
161
  throw new BravosError(`${origin} refused to license this machine (HTTP 403${typeof error === 'string' ? `: ${error}` : ''}); see ${manage}`);
package/dist/cli.js CHANGED
@@ -8,11 +8,12 @@ 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
10
  import { CURSOR_RULE_PATH, cursorHookRegistered, writeCursorHooks, writeCursorPointer } from './cursor.js';
11
+ import { writeInstructionBlocks } from './instruction-blocks.js';
11
12
  import { OMP_EXTENSION_PATH, writeOmpExtension } from './omp.js';
12
13
  import { homeOf, installGlobal } from './global.js';
13
14
  import { uninstall } from './uninstall.js';
14
- import { checkKind, newToken, prepareReview, readAllAnswers, readDraft, renderReview, summarize, writePage } from './review.js';
15
- import { addSource, checkSources, declineContext, gateFor, installPrePush, listSources, updateSource } from './context.js';
15
+ import { checkKind, confirmedOnly, draftPath, lostAnswers, newToken, prepareReview, readAllAnswers, readDraft, renderReview, summarize, writePage } from './review.js';
16
+ import { addSource, checkSources, contextIgnoreFix, contextIgnoreWarning, declineContext, gateFor, installPrePush, listSources, shareContext, storeRoot as storeRootOf, updateSource } from './context.js';
16
17
  import { formatRules, gatherRules } from './rules.js';
17
18
  import { spawn as spawnChild, spawnSync } from 'node:child_process';
18
19
  import { createServer as netServer } from 'node:net';
@@ -255,6 +256,10 @@ function pipeline(root, io, opts, withGuardlink, lines) {
255
256
  lines.push(`Cursor: ${cursor.path} not written — no skills root was installed for it to point at`);
256
257
  else if (cursor.status !== 'absent')
257
258
  lines.push(`Cursor: ${cursor.path} ${cursor.status}`);
259
+ // @comment -- "The Bravos block in the instruction files every agent reads (AGENTS.md, CLAUDE.md, GEMINI.md, Copilot's, Windsurf's rule), for agents and surfaces with no hook or whose hook output may not show. Each file is written under its own condition; with an explicit --agent only the files its agents read (and those no --agent can name), and upkeep refreshes a block already there."
260
+ const blocks = writeInstructionBlocks(root, { harnesses, agents: explicit ? opts.agent : undefined, refreshOnly: opts.refreshOnly, dryRun, force: opts.force });
261
+ for (const b of blocks)
262
+ lines.push(b.status === 'skipped' ? `Instructions: skipped ${b.path} — ${b.reason}` : `Instructions: ${b.path} ${b.status} (Bravos block)`);
258
263
  const omp = explicit && !forceOmp ? { status: 'absent' } : writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
259
264
  if (omp.status === 'skipped')
260
265
  lines.push(`omp: skipped ${omp.path} — ${omp.reason}`);
@@ -283,7 +288,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
283
288
  lines.push(`Hooks: ${r.file} ${r.changed ? 'registered' : 'already registered'}`);
284
289
  // A repository that keeps design documents gets the pre-push check in every clone that runs init or sync, not only
285
290
  // in the clone of whoever added the first one. Upkeep leaves the clone's git hooks to a person.
286
- if (!dryRun && !opts.global && !opts.refreshOnly && existsSync(join(root, '.bravos', 'context', 'sources.json')))
291
+ if (!dryRun && !opts.global && !opts.refreshOnly && (existsSync(join(root, '.bravos', 'context', 'sources.json')) || existsSync(join(root, '.guardlink', 'principles.md'))))
287
292
  lines.push(...installPrePush(root, io.env));
288
293
  // An agent left out of --agent keeps its own settings, which may still run the old-name hook the migration moved.
289
294
  for (const w of oldHookReferences(root))
@@ -352,10 +357,15 @@ function pipeline(root, io, opts, withGuardlink, lines) {
352
357
  lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos setup --ci to refresh them.`);
353
358
  }
354
359
  const cursorWritten = [cursor, cursorHooks].flatMap((c) => (c.status === 'written' || c.status === 'updated' ? [c.path] : []));
360
+ const blocksWritten = blocks.flatMap((b) => (b.status === 'written' || b.status === 'updated' ? [b.path] : []));
355
361
  const ompWritten = omp.status === 'written' || omp.status === 'updated' ? [omp.path] : [];
356
362
  const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
357
- const written = [...skills.written, ...skills.updated, ...mirror.written, ...mirror.updated, ...cursorWritten, ...ompWritten, ...ocWritten, ...workflowWritten, ...hook.copied, ...hook.registered.map((r) => r.file), ...guardlinkWritten];
363
+ const written = [...skills.written, ...skills.updated, ...mirror.written, ...mirror.updated, ...cursorWritten, ...blocksWritten, ...ompWritten, ...ocWritten, ...workflowWritten, ...hook.copied, ...hook.registered.map((r) => r.file), ...guardlinkWritten];
358
364
  lines.push(...gitignoreWarnings(root, written, io.env));
365
+ // The intake and design documents are meant for the team: say so when a .gitignore rule keeps them here.
366
+ const hidden = contextIgnoreWarning(contextIgnoreFix(root, io.env));
367
+ if (hidden)
368
+ lines.push(hidden);
359
369
  if (autopilotKept)
360
370
  lines.push('autopilot: kept (already installed); BRAVOS_AUTOPILOT=off pauses the check.');
361
371
  else if (prePrKept)
@@ -621,14 +631,14 @@ export function buildProgram(io, result) {
621
631
  // @comment -- "bravos hook <name> runs one of the scripts this install ships (session-start, pre-pr, autopilot, replay) with the given arguments and stdin passed through; plugin skills use it where the repository has no .bravos/hooks/ copy. Only allowlisted entry points run; the script's own exit code is returned."
622
632
  program
623
633
  .command('hook <name> [args...]')
624
- .description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot, replay), e.g. `bravos hook session-start --briefing` or `bravos hook pre-pr --check`: what plugin installs use where the repository has no .bravos/hooks/.')
634
+ .description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot, replay), e.g. `bravos hook session-start --briefing` or `bravos hook replay preflight run <kit.js>` (versioned JSON, no kit execution): what plugin installs use where the repository has no .bravos/hooks/.')
625
635
  .allowUnknownOption()
626
636
  .helpOption(false)
627
637
  .action((name, args) => guarded((lines) => {
628
- const known = ['session-start', 'pre-pr', 'autopilot', 'replay', 'context'];
638
+ const known = ['session-start', 'pre-pr', 'autopilot', 'replay', 'context', 'principles'];
629
639
  if (!known.includes(name))
630
640
  throw new BravosError(`unknown hook '${name}'; use ${known.join(', ')}`);
631
- const script = name === 'replay' || name === 'context' ? `lib/${name}.mjs` : `${name}.mjs`;
641
+ const script = name === 'replay' || name === 'context' || name === 'principles' ? `lib/${name}.mjs` : `${name}.mjs`;
632
642
  const r = spawnSync(process.execPath, [pathJoin(hooksDir(), script), ...args], { env: io.env, encoding: 'utf8', stdio: ['inherit', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024 });
633
643
  if (r.stdout)
634
644
  lines.push(r.stdout.replace(/\n$/, ''));
@@ -835,6 +845,8 @@ export function buildProgram(io, result) {
835
845
  lines.push(` ${p}`);
836
846
  for (const u of r.unregistered)
837
847
  lines.push(`Unregistered bravos's hooks from ${u}`);
848
+ for (const u of r.unblocked)
849
+ lines.push(`Removed the Bravos block from ${u}; the rest of the file is kept`);
838
850
  for (const k of r.kept)
839
851
  lines.push(`Kept ${k.path} — ${k.reason}`);
840
852
  for (const n of r.notes)
@@ -845,7 +857,7 @@ export function buildProgram(io, result) {
845
857
  // @comment -- "bravos context: the design documents behind the threat model. add and update take text (a file, or - for standard input) and refuse a secret, a local path or embedded content before anything is written; list and check read. Free on every plan and runs no model: converting a PDF or fetching a link is the coding agent's job, in the session, with the person's own access."
846
858
  program
847
859
  .command('context <action> [args...]')
848
- .description('Keep the design documents behind the threat model in the repository (.bravos/context/, committed): `context add <file.md|-> --title "<what it is>" --kind prd` stores a document after checking it for secrets and local paths; `context update SRC-n [file]` replaces it or records a hand edit; `context list`; `context check`; `context gate` says whether threat-modelling may start (context confirmed, or declined); `context decline --by "<name>"` records that a named person chose to go without. Text only: your coding agent converts PDFs and fetches links. Free; runs no model.')
860
+ .description('Keep the design documents behind the threat model in the repository (.bravos/context/, committed): `context add <file.md|-> --title "<what it is>" --kind prd` stores a document after checking it for secrets and local paths; `context update SRC-n [file]` replaces it or records a hand edit; `context list`; `context check`; `context gate` says whether threat-modelling may start (context confirmed, or declined); `context decline --by "<name>"` records that a named person chose to go without; `context share [--yes]` says which .gitignore rule keeps the context out of git and, with --yes, narrows a blanket .bravos/ rule. Text only: your coding agent converts PDFs and fetches links. Free; runs no model.')
849
861
  .option('-C, --dir <dir>', 'the repository (default: the current directory)')
850
862
  .option('--title <title>', 'add/update: what the document is, in a few words')
851
863
  .option('--kind <kind>', 'add/update: prd, design, threat-model, policy, api, upstream or other')
@@ -855,6 +867,7 @@ export function buildProgram(io, result) {
855
867
  .option('--keep-query', 'add/update: keep a link whose query looks like an access token')
856
868
  .option('--reason <why>', 'decline: why the team goes without design context')
857
869
  .option('--json', 'list/check/gate: print JSON')
870
+ .option('--yes', 'share: make the change to .gitignore (without it, share only says what it would change)')
858
871
  .action((action, args, opts) => guardedAsync(async (lines) => {
859
872
  const dir = dirArg(opts.dir);
860
873
  const source = (from) => (from === '-' ? { from, stdin: readStdin() } : { from });
@@ -887,8 +900,12 @@ export function buildProgram(io, result) {
887
900
  else if (action === 'decline') {
888
901
  lines.push(...(await declineContext(dir, opts, io.env)));
889
902
  }
903
+ else if (action === 'share') {
904
+ // Which rule keeps the context off the team's machines; --yes narrows a blanket .bravos/ line.
905
+ lines.push(...shareContext(storeRootOf(dir, io.env), !!opts.yes, io.env));
906
+ }
890
907
  else
891
- throw new BravosError(`unknown context action '${action}'; use add, update, list, check, gate or decline`);
908
+ throw new BravosError(`unknown context action '${action}'; use add, update, list, check, gate, decline or share`);
892
909
  }));
893
910
  // @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."
894
911
  program
@@ -926,6 +943,79 @@ export function buildProgram(io, result) {
926
943
  const doc = await gatherRules(dirArg(dir), io.env);
927
944
  lines.push(...(opts.json ? [JSON.stringify(doc, null, 2)] : formatRules(doc)));
928
945
  }));
946
+ // @comment -- "bravos principles: the company's security design principles in this repository. check verifies principles.md against the confirmed adoptions and the exceptions (free; the pre-push hook and CI run the same); list prints them; write regenerates the file; except records an exception a person approves at an interactive terminal; copy takes another repository's set. Adoption itself happens only on the review page, by a named person."
947
+ program
948
+ .command('principles <action> [args...]')
949
+ .description('Your company\'s security design principles, kept in the repository (.guardlink/principles.md, written by bravos from what named people adopted on bravos review principles): `principles check` verifies the file still says only what people adopted and that no exception has ended (free; the pre-push hook and CI run it); `principles list`; `principles write` rewrites the file from the adoptions; `principles except SDP-n --where "<glob>" --reason "<why>" --until YYYY-MM-DD` records an exception, approved by the person typing their name at a terminal (never by an agent); `principles except --clear-expired`; `principles copy --from <other repository>` takes the same principles. Runs no model.')
950
+ .option('-C, --dir <dir>', 'the repository (default: the current directory)')
951
+ .option('--json', 'check/list: print JSON')
952
+ .option('--where <glob>', 'except: the code the exception covers, as a repository glob (src/legacy/**)')
953
+ .option('--reason <why>', 'except: why this code may break the principle for now')
954
+ .option('--until <day>', 'except: the last day it holds (YYYY-MM-DD, within a year)')
955
+ .option('--clear-expired', 'except: remove exceptions whose last day has passed')
956
+ .option('--from <repository>', 'copy: the repository to take the principles from (a path)')
957
+ .option('--replace', 'copy: replace adoptions made in this repository')
958
+ .action((action, args, opts) => guardedAsync(async (lines) => {
959
+ const P = await import('./principles.js');
960
+ const root = dirArg(opts.dir);
961
+ if (action === 'check') {
962
+ const { result: checked, lines: said } = await P.checkPrinciplesAt(root);
963
+ lines.push(...(opts.json ? [JSON.stringify(checked, null, 2)] : said));
964
+ if (!checked.ok)
965
+ result.code = 1;
966
+ }
967
+ else if (action === 'list') {
968
+ const { result: checked } = await P.checkPrinciplesAt(root);
969
+ if (opts.json)
970
+ lines.push(JSON.stringify({ schema: 'bravos.principles/v1', ok: checked.ok, adopted: checked.adopted, exceptions: checked.exceptions }, null, 2));
971
+ else if (!checked.adopted.length)
972
+ lines.push('principles: none adopted here (bravos review principles proposes them).');
973
+ else {
974
+ for (const p of checked.adopted)
975
+ lines.push(`${p.id} ${p.kind.padEnd(8)} ${p.statement} (applies to: ${p.scope}; adopted by ${p.adopters.map((a) => a.by).join(', ')})`);
976
+ for (const e of checked.exceptions)
977
+ lines.push(` exception: ${e.principle} in ${e.where} until ${e.until}, approved by ${e.by}`);
978
+ if (!checked.ok)
979
+ lines.push('principles check fails: run bravos principles check');
980
+ }
981
+ }
982
+ else if (action === 'write') {
983
+ await requireFeature(io.env, 'principles', 'Writing security design principles');
984
+ lines.push(...(await P.writePrinciples(root)));
985
+ }
986
+ else if (action === 'except') {
987
+ await requireFeature(io.env, 'principles', 'Exceptions to security design principles');
988
+ if (opts.clearExpired) {
989
+ lines.push(...(await P.clearExpired(root)));
990
+ return;
991
+ }
992
+ if (args.length !== 1 || !opts.where || !opts.reason || !opts.until)
993
+ throw new BravosError('usage: bravos principles except SDP-n --where "<glob>" --reason "<why>" --until YYYY-MM-DD');
994
+ // @mitigates #principles against #forged-principle using #person-only-exception -- "An exception needs an interactive terminal where the approver types their own name and the principle id; a coding agent's shell has no terminal, so it cannot approve one"
995
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
996
+ throw new BravosError('an exception is a person\'s decision: run this yourself in a terminal, where you type your name to approve it. A coding agent cannot approve one.');
997
+ const rl = (await import('node:readline/promises')).createInterface({ input: process.stdin, output: process.stdout });
998
+ try {
999
+ io.stdout(`Exception to ${args[0]} for ${opts.where} until ${opts.until}: ${opts.reason}`);
1000
+ const by = (await rl.question('Your name, approving this exception: ')).trim();
1001
+ const typed = (await rl.question(`Type ${args[0]} to confirm: `)).trim();
1002
+ if (typed !== args[0])
1003
+ throw new BravosError('not confirmed: the principle id did not match, nothing was recorded');
1004
+ lines.push(...(await P.addException(root, { principle: args[0], where: opts.where, reason: opts.reason, until: opts.until, by })));
1005
+ }
1006
+ finally {
1007
+ rl.close();
1008
+ }
1009
+ }
1010
+ else if (action === 'copy') {
1011
+ await requireFeature(io.env, 'principles', 'Copying security design principles');
1012
+ if (!opts.from)
1013
+ throw new BravosError('usage: bravos principles copy --from <path to the other repository> [--replace]');
1014
+ lines.push(...(await P.copyPrinciples(root, opts.from, { replace: opts.replace }, io.env)));
1015
+ }
1016
+ else
1017
+ throw new BravosError(`unknown principles action '${action}'; use check, list, write, except or copy`);
1018
+ }));
929
1019
  program
930
1020
  .command('review <kind> [dir]')
931
1021
  .description("Open bravos's questions (.guardlink/<kind>-draft.json, e.g. kind 'intent') as a branded page people answer in; answers are saved to .guardlink/<kind>-answers/<name>.json. Runs no model.")
@@ -937,7 +1027,22 @@ export function buildProgram(io, result) {
937
1027
  .action((kind, dir, opts) => guardedAsync(async (lines) => {
938
1028
  const root = dirArg(dir);
939
1029
  checkKind(kind);
1030
+ // Adopting principles is a Team feature, and it happens on the served page only: that is where the server
1031
+ // records each adoption with its fingerprint (src/principles.ts withAdoptions).
1032
+ if (kind === 'principles' && !opts.summary) {
1033
+ await requireFeature(io.env, 'principles', 'Adopting security design principles');
1034
+ if (opts.share || opts.serve === false)
1035
+ throw new BravosError('principles are adopted on the served page only (bravos review principles), so each adoption is recorded with its exact wording; --share and --no-serve are for other reviews');
1036
+ }
940
1037
  const draft = readDraft(root, kind);
1038
+ // A rewritten draft must not lose an answer somebody confirmed (review.ts lostAnswers).
1039
+ if (!opts.summary) {
1040
+ const lost = lostAnswers(draft, readAllAnswers(root, draft).files);
1041
+ if (lost.length) {
1042
+ throw new BravosError(`${draftPath(kind)} no longer asks ${lost.map((l) => `${l.id} (answered by ${l.by.join(', ')})`).join('; ')}. ` +
1043
+ `Put "replaces": ["<old id>"] on the question that took its place, or list the id under "retired" in the draft if it is no longer asked on purpose; the answers are kept either way.`);
1044
+ }
1045
+ }
941
1046
  if (opts.summary) {
942
1047
  const { files, skipped } = readAllAnswers(root, draft);
943
1048
  lines.push(summarize(draft, files, skipped));
@@ -972,9 +1077,17 @@ export function buildProgram(io, result) {
972
1077
  }
973
1078
  const commonDir = (await (await import('./prefs.js')).prefsLib()).gitCommonDir(root, io.env);
974
1079
  const say = (l) => (waitFor === null ? lines.push(l) : io.stdout(l));
975
- let live = waitFor === null ? null : RW.readLive(commonDir, kind);
976
- if (live)
977
- say(`Review page: ${live.url} (already open; waiting for Confirm)`);
1080
+ // ONE PAGE PER REVIEW: a page already being served is reused (it re-reads the draft on each load), so a
1081
+ // person's open tab keeps working and nothing they typed is lost to a second page.
1082
+ let live = RW.readLive(commonDir, kind);
1083
+ const started = new Date().toISOString();
1084
+ if (live) {
1085
+ say(`Review page: ${live.url} (already open${waitFor === null ? '' : '; waiting for Confirm'})`);
1086
+ if (waitFor === null)
1087
+ lines.push(`When everyone is done: bravos review ${kind} --summary`);
1088
+ if (waitFor === null && opts.open !== false)
1089
+ openInBrowser(live.url, io.env);
1090
+ }
978
1091
  else {
979
1092
  const port = await freePort();
980
1093
  const token = newToken();
@@ -988,7 +1101,7 @@ export function buildProgram(io, result) {
988
1101
  RW.writeLive(commonDir, kind, live);
989
1102
  }
990
1103
  say(`Review page: ${url}`);
991
- say(`Answers save to .guardlink/${kind}-answers/<name>.json. Teammates run bravos review ${kind} after pulling. The page stops on Confirm or after 30 minutes idle.`);
1104
+ say(`Answers save as you go and count once you press Confirm (.guardlink/${kind}-answers/<name>.json). Teammates run bravos review ${kind} after pulling. The page stays open after Confirm and stops after 30 minutes idle.`);
992
1105
  if (waitFor === null)
993
1106
  lines.push(`When everyone is done: bravos review ${kind} --summary`);
994
1107
  if (opts.open !== false)
@@ -996,11 +1109,16 @@ export function buildProgram(io, result) {
996
1109
  }
997
1110
  if (waitFor === null || !live)
998
1111
  return;
999
- if (!(await RW.waitGone(live.pid, waitFor * 1000))) {
1112
+ // Done when somebody confirms after this wait began, or when the page stops (Done, idle).
1113
+ const confirmedSince = () => confirmedOnly(readAllAnswers(root, draft).files).some((f) => (f.confirmedAt ?? '') >= started);
1114
+ const pid = live.pid;
1115
+ const outcome = await RW.waitUntil(() => confirmedSince() || !RW.alive(pid), waitFor * 1000);
1116
+ if (!outcome) {
1000
1117
  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.`);
1001
1118
  return;
1002
1119
  }
1003
- RW.clearLive(commonDir, kind);
1120
+ if (!RW.alive(pid))
1121
+ RW.clearLive(commonDir, kind);
1004
1122
  const { files, skipped } = readAllAnswers(root, draft);
1005
1123
  lines.push(files.length ? 'review: done' : 'review: closed with no answers saved', summarize(draft, files, skipped));
1006
1124
  }));
package/dist/context.js CHANGED
@@ -37,7 +37,7 @@ function readInput(input, L, cwd) {
37
37
  if (input.from === '-') {
38
38
  if (!input.stdin || input.stdin.length === 0)
39
39
  throw new BravosError('nothing arrived on standard input: pipe the document in, e.g. cat prd.md | bravos context add - --title "Billing PRD"');
40
- return { bytes: input.stdin, name: null };
40
+ return { bytes: input.stdin, name: input.name ? basename(input.name.replace(/\\/g, '/')) || null : null };
41
41
  }
42
42
  const abs = isAbsolute(input.from) ? input.from : resolve(cwd, input.from);
43
43
  let st;
@@ -205,6 +205,51 @@ export async function addSource(dir, input, opts, env, cwd = process.cwd()) {
205
205
  lines.push(`Commit it with the team's other context: git add ${L.CONTEXT_DIR}`);
206
206
  return lines;
207
207
  }
208
+ /** Files the intake page may hand the agent to convert: documents people write designs in. */
209
+ const INBOX_TYPES = /\.(pdf|docx?|pptx?|key|odt|odp|rtf|html?|pages)$/i;
210
+ const MAX_INBOX_BYTES = 10 * 1024 * 1024;
211
+ // @comment -- "A design document added on the intake page (src/review.ts POST /documents). Text (Markdown or plain) is stored at once by addSource, with every check bravos context add makes. A file the CLI does not convert (PDF, Word, slides, a web page export) or a link goes to .bravos/context/inbox/, a folder git ignores: the original file and a record of its title, kind and who added it, for the agent to convert and store (the briefing counts them). The browser gives a file name, never a path; nothing is fetched or converted here."
212
+ // @mitigates #context-sources against #committed-secret using #refuse-before-store -- "Text added on the intake page goes through addSource, so the same secret, local-path and embedded-content refusals apply before anything is written; a file the CLI does not convert is kept only in the git-ignored inbox, never committed, until the agent stores its converted text through the same checks"
213
+ // @mitigates #context-sources against #local-path-disclosure using #refuse-before-store -- "A browser-reported file name is reduced to its last segment before it is recorded, so no local path from the person's machine reaches the index"
214
+ export async function addPageDocument(root, doc, env, now = new Date()) {
215
+ const L = await contextLib();
216
+ const store = storeRoot(root, env);
217
+ refuseIfIgnored(store, L, env);
218
+ if (!L.KINDS.includes(doc.kind))
219
+ throw new BravosError(`the kind must be one of ${L.KINDS.join(', ')}`);
220
+ const by = L.cleanLine(doc.by, 80);
221
+ const title = L.cleanLine(doc.title, 120);
222
+ if (!by || !title)
223
+ throw new BravosError('a document needs a title and your name');
224
+ if (doc.text !== undefined) {
225
+ return addSource(store, { from: '-', stdin: Buffer.from(doc.text, 'utf8'), name: doc.name }, { title, kind: doc.kind, by, now }, env);
226
+ }
227
+ const inbox = join(store, L.CONTEXT_DIR, 'inbox');
228
+ mkdirSync(inbox, { recursive: true, mode: 0o700 });
229
+ if (!existsSync(join(inbox, '.gitignore')))
230
+ writeAtomic(join(inbox, '.gitignore'), '*\n');
231
+ const stamp = now.toISOString().replace(/[:.]/g, '-');
232
+ const base = `${stamp}-${L.sourceName('SRC-1', title).replace(/^SRC-1-/, '').replace(/\.md$/, '')}`;
233
+ if (doc.url !== undefined) {
234
+ const u = L.checkUrl(doc.url, {});
235
+ if (!u.url)
236
+ throw new BravosError(`the link was not kept: ${u.problems.join('; ')}`);
237
+ writeAtomic(join(inbox, `${base}.json`), JSON.stringify({ title, kind: doc.kind, by, url: u.url, added: today(now) }, null, 2) + '\n');
238
+ return [`Kept the link for your agent to read and store: ${title}`, 'It appears in the next briefing; the agent stores it with bravos context add --url.'];
239
+ }
240
+ if (!doc.file)
241
+ throw new BravosError('paste the text, choose a file, or give a link');
242
+ const name = L.cleanLine(basename(doc.file.name.replace(/\\/g, '/')), 200).replace(/[\/]/g, '-');
243
+ if (!INBOX_TYPES.test(name))
244
+ throw new BravosError(`${name || 'that file'} is not a document the agent converts here (PDF, Word, slides, Pages or a saved web page); paste Markdown or text instead`);
245
+ const bytes = Buffer.from(doc.file.base64, 'base64');
246
+ if (bytes.length === 0 || bytes.length > MAX_INBOX_BYTES)
247
+ throw new BravosError(`a file must be between 1 byte and ${MAX_INBOX_BYTES / 1048576} MB`);
248
+ const ext = /\.[A-Za-z0-9]{1,8}$/.exec(name)?.[0] ?? '';
249
+ writeAtomic(join(inbox, `${base}${ext}`), bytes);
250
+ writeAtomic(join(inbox, `${base}.json`), JSON.stringify({ title, kind: doc.kind, by, file: `${base}${ext}`, original: name, sha256: L.sha256(bytes), added: today(now) }, null, 2) + '\n');
251
+ return [`Received ${name} (${size(bytes.length)}): your agent converts it to Markdown and stores it with bravos context add --original.`, 'It appears in the next briefing; the original stays in .bravos/context/inbox/, which git ignores.'];
252
+ }
208
253
  // @comment -- "bravos context update SRC-n [file]: with a file (or '-'), replaces the stored text after the same vetting; with none, records the file as it now stands, which is how a hand edit is accepted. Either way the stored text must pass the checks, the hash and size are refreshed, and who updated it and when is recorded."
209
254
  export async function updateSource(dir, id, input, opts, env, cwd = process.cwd()) {
210
255
  const L = await contextLib();
@@ -331,8 +376,26 @@ export async function declineContext(dir, opts, env) {
331
376
  // The pre-push check
332
377
  // ---------------------------------------------------------------------------------------------
333
378
  export const PRE_PUSH_MARKER = 'bravos-context-pre-push';
334
- // @comment -- "The git pre-push hook bravos writes: a few lines of sh that hand git's list of pushed refs to the context check, from the repository's own copy of the hook scripts or, failing that, the bravos on PATH. With neither it does nothing, so a clone without bravos is never blocked."
379
+ // @comment -- "The git pre-push hook bravos writes: a few lines of sh that hand git's list of pushed refs to the context check and then to the principles check, from the repository's own copy of the hook scripts or, failing that, the bravos on PATH. With neither it does nothing, so a clone without bravos is never blocked."
335
380
  export const PRE_PUSH_SCRIPT = `#!/bin/sh
381
+ # ${PRE_PUSH_MARKER} v2: checks the design documents under .bravos/context/ and the security design principles in .guardlink/ before they reach the remote.
382
+ # Written by bravos. Delete this file to stop it; git push --no-verify skips it once.
383
+ refs=$(cat)
384
+ if [ -f .bravos/hooks/lib/context.mjs ] && command -v node >/dev/null 2>&1; then
385
+ printf '%s\\n' "$refs" | node .bravos/hooks/lib/context.mjs pre-push || exit 1
386
+ if [ -f .bravos/hooks/lib/principles.mjs ]; then
387
+ printf '%s\\n' "$refs" | node .bravos/hooks/lib/principles.mjs pre-push || exit 1
388
+ fi
389
+ exit 0
390
+ fi
391
+ if command -v bravos >/dev/null 2>&1; then
392
+ printf '%s\\n' "$refs" | bravos hook context pre-push || exit 1
393
+ printf '%s\\n' "$refs" | bravos hook principles pre-push || exit 1
394
+ fi
395
+ exit 0
396
+ `;
397
+ /** The first version of the hook, so uninstall still recognises one written before principles were checked. */
398
+ const PRE_PUSH_SCRIPT_V1 = `#!/bin/sh
336
399
  # ${PRE_PUSH_MARKER} v1: checks the design documents under .bravos/context/ before they reach the remote.
337
400
  # Written by bravos. Delete this file to stop it; git push --no-verify skips it once.
338
401
  if [ -f .bravos/hooks/lib/context.mjs ] && command -v node >/dev/null 2>&1; then
@@ -375,7 +438,8 @@ export function removePrePush(root, env, dryRun = false) {
375
438
  return false;
376
439
  const file = join(isAbsolute(rel) ? rel : join(root, rel), 'pre-push');
377
440
  try {
378
- if (readFileSync(file, 'utf8') !== PRE_PUSH_SCRIPT)
441
+ const have = readFileSync(file, 'utf8');
442
+ if (have !== PRE_PUSH_SCRIPT && have !== PRE_PUSH_SCRIPT_V1)
379
443
  return false;
380
444
  if (!dryRun)
381
445
  rmSync(file);
@@ -385,3 +449,62 @@ export function removePrePush(root, env, dryRun = false) {
385
449
  return false;
386
450
  }
387
451
  }
452
+ // ============================ making the intake travel ============================
453
+ /** The paths the team's context lives at, which must reach the team through git. */
454
+ const MUST_TRAVEL = ['.bravos/context/sources.json', '.guardlink/intent.md', '.guardlink/intent-draft.json', '.guardlink/intent-answers/x.json'];
455
+ // @comment -- "Which of the files the team's context lives in (.bravos/context/, .guardlink/intent*) git would never commit, and the rule that hides each (git check-ignore -v, argv array). When the cause is the common blanket `.bravos/` line in the repository's own .gitignore, the narrowest repair is offered: ignore Bravos's folder except its context. Read-only; silent without git."
456
+ export function contextIgnoreFix(root, env = process.env) {
457
+ let out = '';
458
+ try {
459
+ out = execFileSync('git', ['check-ignore', '-v', '--non-matching', '--stdin'], { cwd: root, env, input: MUST_TRAVEL.join('\n') + '\n', encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 });
460
+ }
461
+ catch (e) {
462
+ out = String(e.stdout ?? '');
463
+ }
464
+ const problems = [];
465
+ for (const row of out.split('\n')) {
466
+ const m = /^([^:]+):(\d+):(.*)\t(.+)$/.exec(row);
467
+ if (!m || !m[1] || m[3].startsWith('!'))
468
+ continue;
469
+ problems.push({ file: m[1], line: Number(m[2]), pattern: m[3], path: m[4] });
470
+ }
471
+ const blanket = problems.find((p) => p.file === '.gitignore' && /^\/?\.bravos\/?\**$/.test(p.pattern.trim()) && p.path.startsWith('.bravos/'));
472
+ return {
473
+ problems,
474
+ fixable: blanket ? { line: blanket.line, was: blanket.pattern, becomes: ['.bravos/*', '!.bravos/context/'] } : null,
475
+ };
476
+ }
477
+ /** The one-line warning setup and doctor print when the context would stay on one machine. */
478
+ export function contextIgnoreWarning(fix) {
479
+ if (!fix.problems.length)
480
+ return null;
481
+ const first = fix.problems[0];
482
+ const how = fix.fixable
483
+ ? `run bravos context share --yes to change line ${fix.fixable.line} of .gitignore from "${fix.fixable.was}" to "${fix.fixable.becomes.join('" and "')}"`
484
+ : `remove or narrow the rule at ${first.file}:${first.line} ("${first.pattern}")`;
485
+ return `warning: ${first.file}:${first.line} ("${first.pattern}") hides ${[...new Set(fix.problems.map((p) => p.path.replace(/\/x\.json$/, '/')))].join(', ')} from git, so the intake and design documents will not reach your team; ${how}`;
486
+ }
487
+ // @comment -- "bravos context share: says which rule keeps the team's context out of git and, with --yes, makes the narrowest repair to a blanket `.bravos/` line in the repository's own .gitignore (that one line becomes `.bravos/*` and `!.bravos/context/`; every other rule is left as the team wrote it). Without --yes it changes nothing and prints the exact edit, so a person decides."
488
+ export function shareContext(root, yes, env = process.env) {
489
+ const fix = contextIgnoreFix(root, env);
490
+ if (!fix.problems.length)
491
+ return ['context: nothing hides .bravos/context/ or .guardlink/intent* from git here; commit them and your team gets them on their next pull'];
492
+ const lines = fix.problems.map((p) => `${p.path.replace(/\/x\.json$/, '/')} is ignored by ${p.file}:${p.line} ("${p.pattern}")`);
493
+ if (!fix.fixable)
494
+ return [...lines, 'bravos repairs only a blanket .bravos/ line in .gitignore; change the rule above by hand so these paths are committed'];
495
+ const abs = join(root, '.gitignore');
496
+ const text = readFileSync(abs, 'utf8');
497
+ const rows = text.split('\n');
498
+ const at = fix.fixable.line - 1;
499
+ if (rows[at] === undefined || rows[at].trim() !== fix.fixable.was.trim())
500
+ return [...lines, `.gitignore changed while bravos was reading it; run bravos context share again`];
501
+ if (!yes)
502
+ return [...lines, `With --yes, bravos changes line ${fix.fixable.line} of .gitignore from "${fix.fixable.was}" to:`, ...fix.fixable.becomes.map((b) => ` ${b}`), 'Everything else in .bravos/ stays ignored, as now; only .bravos/context/ (the design documents) is committed.'];
503
+ rows.splice(at, 1, ...fix.fixable.becomes);
504
+ writeAtomic(abs, rows.join('\n'));
505
+ const after = contextIgnoreFix(root, env);
506
+ return [
507
+ `.gitignore line ${fix.fixable.line}: "${fix.fixable.was}" → ${fix.fixable.becomes.map((b) => `"${b}"`).join(', ')}`,
508
+ after.problems.length ? `still ignored: ${after.problems.map((p) => `${p.path} (${p.file}:${p.line})`).join(', ')}` : 'The intake and design documents now reach your team: commit .gitignore, .bravos/context/ and .guardlink/intent* together',
509
+ ];
510
+ }
package/dist/cursor.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { readLock, sha256, writeLock } from './lock.js';
4
+ import { bravosBlock } from './instruction-blocks.js';
4
5
  import { MARKER, skillsRoot } from './skills.js';
5
6
  // @comment -- "Where bravos's Cursor rule lives; Cursor reads project rules from .cursor/rules/*.mdc."
6
7
  export const CURSOR_RULE_PATH = '.cursor/rules/bravos.mdc';
7
- // @comment -- "The rule body for one skills root: a pointer to the bravos skills there plus the two rules that hold everywhere; no method is copied here, so it cannot drift from the skills."
8
+ // @comment -- "The rule body for one skills root: a pointer to the bravos skills there, the two rules that hold everywhere, and the same Bravos block the other instruction files carry (so a session whose hook output did not arrive still runs the briefing); no method is copied here, so it cannot drift from the skills."
8
9
  export const cursorRule = (root) => `---
9
10
  description: bravos security workflow skills for this repo (guardlink, cxg, code graph)
10
11
  globs:
@@ -25,7 +26,8 @@ Two rules hold everywhere:
25
26
  follow the method in this session.
26
27
  - Never write \`@accepts\`, \`@entitles\` or \`@confirmed\`. Acceptance and entitlement are a human's
27
28
  decision, and only a reproduced run confirms an exposure.
28
- `;
29
+
30
+ ${bravosBlock()}`;
29
31
  // @comment -- "The skills root the pointer names: .claude/skills when Claude Code's root was installed, else .agents/skills, else none."
30
32
  export function cursorSkillsRoot(harnesses) {
31
33
  if (harnesses.includes('claude'))
package/dist/dashboard.js CHANGED
@@ -7,6 +7,7 @@ import { featureState, licenceLib } from './licence.js';
7
7
  import { templatesDir, version } from './paths.js';
8
8
  import { BravosError } from './types.js';
9
9
  import { gatherRules } from './rules.js';
10
+ import { intakeSummary } from './review.js';
10
11
  export const DASHBOARD_DIR = '.bravos/dashboard';
11
12
  export const DASHBOARD_PATH = `${DASHBOARD_DIR}/index.html`;
12
13
  /** What the saved page was built from, for the session briefing to tell a current page from an old one. */
@@ -262,6 +263,13 @@ export async function buildDashboard(root, env, opts = {}) {
262
263
  try {
263
264
  rules = await gatherRules(root, env, { names: opts.blame !== false, details: true });
264
265
  rulesPart = { state: rules.state === 'none' ? 'missing' : 'present', note: rules.note };
266
+ // The Security design view is on the Team plan; on Free the principles stay followed (the instruction block) and
267
+ // the view says what would show them.
268
+ if (rules.principles.length) {
269
+ const f = await featureState(env, 'principles', 'The Security design view');
270
+ if (!f.entitled)
271
+ rules = { ...rules, principles: [], principlesNote: `${rules.principles.length} security design principle${rules.principles.length === 1 ? ' is' : 's are'} adopted here, and coding agents follow ${rules.principles.length === 1 ? 'it' : 'them'} on every plan. ${f.refusal}.` };
272
+ }
265
273
  }
266
274
  catch (e) {
267
275
  rulesPart = { state: 'failed', note: `The design rules could not be read (${e.message.split('\n')[0].slice(0, 200)}).` };
@@ -285,6 +293,7 @@ export async function buildDashboard(root, env, opts = {}) {
285
293
  threatModel: { state: tm.state, note: tm.note, blame: tm.blame, since: tm.since },
286
294
  codeGraph: { state: cg.state, note: cg.note },
287
295
  rules: rulesPart,
296
+ intake: intakeSummary(root),
288
297
  };
289
298
  const page = renderDashboard(data, tm.html, cg.store, rules);
290
299
  let path;
package/dist/device.js CHANGED
@@ -6,10 +6,12 @@ import { BravosError } from './types.js';
6
6
  let cached = null;
7
7
  export const refreshLib = () => (cached ??= import(pathToFileURL(join(hooksDir(), 'lib', 'refresh.mjs')).href));
8
8
  export const userAgent = () => `bravos-cli/${version()}`;
9
+ let machineCached = null;
10
+ export const machineLib = () => (machineCached ??= import(pathToFileURL(join(hooksDir(), 'lib', 'machine.mjs')).href));
9
11
  // @comment -- "Refreshes this machine's device licence when it is due (or always, with force). Never throws; the outcome says what happened, and a revocation or a lapsed plan carries the sentence to show."
10
12
  export async function refresh(io, force = false) {
11
13
  const R = await refreshLib();
12
- return R.refreshIfDue(io.env, { fetch: io.fetch, now: io.now, force, userAgent: userAgent() });
14
+ return R.refreshIfDue(io.env, { fetch: io.fetch, now: io.now, force, userAgent: userAgent(), ...(io.machine ? { machine: io.machine } : {}) });
13
15
  }
14
16
  const requireDevice = async (env) => {
15
17
  const R = await refreshLib();
package/dist/doctor.js CHANGED
@@ -7,6 +7,7 @@ import { findAnalyzer, findLicence } from './graphbin.js';
7
7
  import { ALL_AUTOPILOT_COMMANDS, ALL_CARDS_COMMANDS, ALL_COACH_COMMANDS, ALL_PRE_PR_COMMANDS, HOOK_COMMANDS, LEGACY_HOOK_COMMAND, RELATIVE_HOOK_COMMANDS, hookRegistered } from './hooks.js';
8
8
  import { skillsRoot } from './skills.js';
9
9
  import { cursorHookRegistered } from './cursor.js';
10
+ import { contextIgnoreFix, contextIgnoreWarning } from './context.js';
10
11
  import { resolveTheme } from './palette.js';
11
12
  import { pathToFileURL } from 'node:url';
12
13
  import { hooksDir, version as packageVersion } from './paths.js';
@@ -62,6 +63,8 @@ export function runDoctor(root, env = process.env) {
62
63
  tools,
63
64
  licence,
64
65
  guardlink_initialised: existsSync(join(root, '.guardlink')),
66
+ // Only asked where Bravos is set up: a repository without .guardlink/ has no context to share yet.
67
+ ...(existsSync(join(root, '.guardlink')) ? { context_shared: contextIgnoreWarning(contextIgnoreFix(root, env)) } : {}),
65
68
  skills: { claude: bravosSkills(root, 'claude'), agents: bravosSkills(root, 'agents') },
66
69
  guardlink_skills: { claude: guardlinkSkills(root, 'claude'), agents: guardlinkSkills(root, 'agents') },
67
70
  hooks: {
@@ -154,6 +157,7 @@ export function formatDoctor(r) {
154
157
  `coach claude: ${yn(r.coach.claude)} codex: ${yn(r.coach.codex)}${r.coach.claude || r.coach.codex ? (process.env.BRAVOS_COACH === 'off' ? ' (off for this run: BRAVOS_COACH=off)' : '') : ' (bravos setup adds it)'}`,
155
158
  ...(r.dead_hooks?.length ? [`✘ dead user-level hooks ${r.dead_hooks.map((d) => `${d.file} ${d.event}: ${d.script} is gone`).join('; ')} — every session shows "hook error". Remove them (a backup is kept): bravos doctor --fix-hooks`] : r.dead_hooks ? ['✔ no dead user-level hooks'] : []),
156
159
  ...(r.legacy_skills?.length ? [`✘ old Python bravos skills ${r.legacy_skills.map((f) => `${f.root}: ${f.names.join(', ')}`).join('; ')} — your agent may load them instead of this repository's. Move them aside (reversible): ${r.legacy_command}`] : r.legacy_skills ? ['✔ no old Python bravos skills at user level'] : []),
160
+ ...(r.context_shared === undefined ? [] : r.context_shared ? [`✘ ${r.context_shared.replace(/^warning: /, '')}`] : ['✔ intake and design documents reach the team through git']),
157
161
  ...(r.updates ? [updatesLine(r.updates)] : []),
158
162
  ...(r.theme ? [`colours ${r.theme.theme} (${r.theme.source})${r.theme.source.startsWith('default') ? ' — pick yours: BRAVOS_THEME=light or dark, or bravos setup' : ''}`] : []),
159
163
  ].join('\n');