@bugb-technologies/bravos 1.17.1 → 1.18.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.
package/README.md CHANGED
@@ -21,7 +21,7 @@ bravos setup
21
21
 
22
22
  `bravos setup` is the one command for setting Bravos up. Run it in a repository, in a terminal:
23
23
 
24
- - **The first time on a machine** it signs you in, installs the tools, then asks about the repository: which agents, PR checks, scheduled upkeep and testing. It shows the changes before you choose Apply.
24
+ - **The first time on a machine** it offers to sign you in (optional: skip it to stay on Free, which needs no account), installs the tools, then asks about the repository: which agents, PR checks, scheduled upkeep and testing. It shows the changes before you choose Apply.
25
25
  - **In another repository** it skips what the machine already has and asks only that repository's questions.
26
26
  - **In a repository that already has Bravos** it brings this machine and the repository up to date; `bravos setup --change` asks the repository's questions again.
27
27
 
@@ -67,7 +67,7 @@ Invoke skills in your agent: `/bravos` in Claude Code or `$bravos` in Codex.
67
67
 
68
68
  ## Plans & licence
69
69
 
70
- **Free:** one person researching one repository, including the threat-model and authorized testing loop. **Team** (Solo is one seat) adds PR gates, autopilot, CI, scheduled upkeep, workspaces, campaigns, SAST and the code graph. `bravos account activate` starts a 30-day Team trial with no card when your account has no plan; `bravos licence` shows your plan.
70
+ **Free:** one person researching their repositories, each on its own and with no limit on how many, including the threat-model and authorized testing loop. **Team** (Solo is one seat) adds PR gates, autopilot, CI, scheduled upkeep, workspaces, campaigns, SAST and the code graph. `bravos account activate` starts a 30-day Team trial with no card when your account has no plan; `bravos licence` shows your plan.
71
71
 
72
72
  Bravos is proprietary software of BugB Technologies, free on the Free plan and licensed per developer for Team features. See [LICENSE](LICENSE) for terms; third-party components keep their own licences.
73
73
 
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ 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 { CURSOR_RULE_PATH, writeCursorPointer } from './cursor.js';
10
+ import { CURSOR_RULE_PATH, cursorHookRegistered, writeCursorHooks, writeCursorPointer } from './cursor.js';
11
11
  import { OMP_EXTENSION_PATH, writeOmpExtension } from './omp.js';
12
12
  import { homeOf, installGlobal } from './global.js';
13
13
  import { uninstall } from './uninstall.js';
@@ -39,7 +39,7 @@ import { LOCK_PATH, readLock, sha256, writeLock } from './lock.js';
39
39
  import { mergeCodexConfig, mergeMcpJson, selectServers } from './mcp.js';
40
40
  import { hooksDir, skillsDir as bundledSkillsDir, version } from './paths.js';
41
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."
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, and the Cursor session hook. 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
43
  export function installedAgents(root) {
44
44
  const has = (rel) => existsSync(join(root, rel));
45
45
  const out = [];
@@ -60,6 +60,8 @@ export function installedAgents(root) {
60
60
  out.push('opencode');
61
61
  if (has(OMP_EXTENSION_PATH))
62
62
  out.push('omp');
63
+ if (cursorHookRegistered(root))
64
+ out.push('cursor');
63
65
  return out;
64
66
  }
65
67
  // @comment -- "Parses --workflows pr-gate,nightly-claude,nightly-codex,nightly-copilot; anything else is a usage error"
@@ -75,16 +77,16 @@ function parseWorkflows(value) {
75
77
  }
76
78
  const GUARDLINK_HINT = 'guardlink: not found on PATH — run bravos setup --tools -y';
77
79
  // Antigravity reads the shared .agents/ root; opencode and omp get their own files on top of a skills root.
78
- const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agy', opencode: 'opencode', omp: 'omp' };
80
+ const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agy', opencode: 'opencode', omp: 'omp', cursor: 'cursor' };
79
81
  // @comment -- "Parses --agent <claude,codex>; codex maps to the .agents harness and anything else is a usage error."
80
82
  function parseAgents(value) {
81
83
  const out = [];
82
84
  // 'all' is every harness bravos knows: both skill roots plus the opencode and omp files.
83
- const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'agy', 'opencode', 'omp'] : [r]));
85
+ const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'agy', 'opencode', 'omp', 'cursor'] : [r]));
84
86
  for (const raw of raws) {
85
87
  const h = AGENT_MAP[raw];
86
88
  if (!h)
87
- throw new InvalidArgumentError(`unknown agent '${raw}' (expected claude, codex, agy, opencode, omp or all)`);
89
+ throw new InvalidArgumentError(`unknown agent '${raw}' (expected claude, codex, agy, opencode, omp, cursor or all)`);
88
90
  if (!out.includes(h))
89
91
  out.push(h);
90
92
  }
@@ -161,6 +163,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
161
163
  const hookHarnesses = harnesses.filter((h) => h === 'claude' || codex);
162
164
  const forceOpencode = !!opts.agent?.includes('opencode');
163
165
  const forceOmp = !!opts.agent?.includes('omp');
166
+ const forceCursor = !!opts.agent?.includes('cursor');
164
167
  lines.push(`Harnesses: ${harnesses.join(', ')}${defaulted ? ' (default: no evidence found)' : ''}`);
165
168
  let guardlinkPending = false;
166
169
  if (withGuardlink) {
@@ -238,8 +241,14 @@ function pipeline(root, io, opts, withGuardlink, lines) {
238
241
  for (const s of mirror.skipped)
239
242
  lines.push(` skipped ${s.path} — ${s.reason}`);
240
243
  }
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 });
244
+ // @comment -- "Cursor's session hook: the briefing and the first-reply card reach Cursor's agent through sessionStart (Cursor shows hook output to nobody but the model). Written with a .cursor/ folder, or with --agent cursor; with another --agent it is left alone. Written before the pointer, so --agent cursor in a repo with no .cursor/ yet gets both."
245
+ const cursorHooks = explicit && !forceCursor ? { status: 'absent' } : writeCursorHooks(root, { dryRun, always: forceCursor });
246
+ if (cursorHooks.status === 'skipped')
247
+ lines.push(`Cursor: skipped ${cursorHooks.path} — ${cursorHooks.reason}`);
248
+ else if (cursorHooks.status !== 'absent')
249
+ lines.push(`Cursor: ${cursorHooks.path} ${cursorHooks.status} (briefing and the Bravos card at session start)`);
250
+ // With another --agent the Cursor pointer is left alone; upkeep still refreshes one that is already there.
251
+ const cursor = explicit && !forceCursor && !(opts.refreshOnly && existsSync(join(root, CURSOR_RULE_PATH))) ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
243
252
  if (cursor.status === 'skipped')
244
253
  lines.push(`Cursor: skipped ${cursor.path} — ${cursor.reason}`);
245
254
  else if (cursor.status === 'no-skills')
@@ -342,7 +351,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
342
351
  if (stale.length)
343
352
  lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos setup --ci to refresh them.`);
344
353
  }
345
- const cursorWritten = cursor.status === 'written' || cursor.status === 'updated' ? [cursor.path] : [];
354
+ const cursorWritten = [cursor, cursorHooks].flatMap((c) => (c.status === 'written' || c.status === 'updated' ? [c.path] : []));
346
355
  const ompWritten = omp.status === 'written' || omp.status === 'updated' ? [omp.path] : [];
347
356
  const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
348
357
  const written = [...skills.written, ...skills.updated, ...mirror.written, ...mirror.updated, ...cursorWritten, ...ompWritten, ...ocWritten, ...workflowWritten, ...hook.copied, ...hook.registered.map((r) => r.file), ...guardlinkWritten];
package/dist/cursor.js CHANGED
@@ -68,3 +68,51 @@ export function writeCursorPointer(root, harnesses, opts = {}) {
68
68
  }
69
69
  return { status, path };
70
70
  }
71
+ // @comment -- "Where Cursor reads project hooks (the IDE and the Cursor Agent CLI): a { version, hooks: { <event>: [{ command }] } } file, entries listed directly under each event."
72
+ export const CURSOR_HOOKS_PATH = '.cursor/hooks.json';
73
+ // @comment -- "The session-start command Cursor runs: the repo's own hook script, found from any folder in the checkout, told it is Cursor so it prints Cursor's output shape."
74
+ export const CURSOR_SESSION_COMMAND = 'node "$(git rev-parse --show-toplevel)/.bravos/hooks/session-start.mjs" --harness cursor';
75
+ // @comment -- "Registers bravos's sessionStart hook in .cursor/hooks.json, so Cursor gives the agent the briefing (and the first-reply card) at session start. Written when the repo has a .cursor/ folder or the person chose --agent cursor. Merges with the file's other hooks and keeps them; an unreadable or non-object file is left alone and reported. Not lock-recorded: it is shared with the team's own hooks, so uninstall removes only bravos's entry."
76
+ export function writeCursorHooks(root, opts = {}) {
77
+ if (!opts.always && !existsSync(join(root, '.cursor')))
78
+ return { status: 'absent' };
79
+ const path = CURSOR_HOOKS_PATH;
80
+ const abs = join(root, path);
81
+ let doc = { version: 1, hooks: {} };
82
+ const had = existsSync(abs);
83
+ if (had) {
84
+ try {
85
+ const parsed = JSON.parse(readFileSync(abs, 'utf8'));
86
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
87
+ return { status: 'skipped', path, reason: 'not a JSON object; fix it and run bravos setup again' };
88
+ doc = parsed;
89
+ }
90
+ catch {
91
+ return { status: 'skipped', path, reason: 'not valid JSON; fix it and run bravos setup again' };
92
+ }
93
+ }
94
+ const hooks = typeof doc.hooks === 'object' && doc.hooks !== null && !Array.isArray(doc.hooks) ? { ...doc.hooks } : {};
95
+ const ours = (e) => typeof e === 'object' && e !== null && /\.bravos\/hooks\/session-start\.mjs/.test(String(e.command ?? ''));
96
+ const current = Array.isArray(hooks.sessionStart) ? hooks.sessionStart : [];
97
+ const others = current.filter((e) => !ours(e));
98
+ hooks.sessionStart = [...others, { command: CURSOR_SESSION_COMMAND }];
99
+ const next = { version: typeof doc.version === 'number' ? doc.version : 1, ...doc, hooks };
100
+ const text = JSON.stringify(next, null, 2) + '\n';
101
+ if (had && readFileSync(abs, 'utf8') === text)
102
+ return { status: 'unchanged', path };
103
+ if (!opts.dryRun) {
104
+ mkdirSync(dirname(abs), { recursive: true });
105
+ writeFileSync(abs, text);
106
+ }
107
+ return { status: had ? 'updated' : 'written', path };
108
+ }
109
+ // @comment -- "True when .cursor/hooks.json registers bravos's session-start hook; an absent or unreadable file reads as false."
110
+ export function cursorHookRegistered(root) {
111
+ try {
112
+ const start = JSON.parse(readFileSync(join(root, CURSOR_HOOKS_PATH), 'utf8')).hooks?.sessionStart;
113
+ return Array.isArray(start) && start.some((e) => /\.bravos\/hooks\/session-start\.mjs/.test(String(e?.command ?? '')));
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
package/dist/doctor.js CHANGED
@@ -6,6 +6,7 @@ import { graphBin } from './codegraph.js';
6
6
  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
+ import { cursorHookRegistered } from './cursor.js';
9
10
  import { resolveTheme } from './palette.js';
10
11
  import { pathToFileURL } from 'node:url';
11
12
  import { hooksDir, version as packageVersion } from './paths.js';
@@ -66,6 +67,7 @@ export function runDoctor(root, env = process.env) {
66
67
  hooks: {
67
68
  claude: hookRegistered(join(root, '.claude', 'settings.json'), 'SessionStart', [HOOK_COMMANDS.claude, RELATIVE_HOOK_COMMANDS.claude, LEGACY_HOOK_COMMAND]),
68
69
  codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'SessionStart', [HOOK_COMMANDS.agents, RELATIVE_HOOK_COMMANDS.agents, LEGACY_HOOK_COMMAND]),
70
+ cursor: cursorHookRegistered(root),
69
71
  },
70
72
  autopilot: {
71
73
  claude: hookRegistered(join(root, '.claude', 'settings.json'), 'Stop', ALL_AUTOPILOT_COMMANDS),
@@ -145,7 +147,7 @@ export function formatDoctor(r) {
145
147
  r.guardlink_initialised ? '✔ guardlink initialised (.guardlink/)' : '✘ guardlink not initialised — run bravos setup',
146
148
  `skills claude: ${r.skills.claude.length} agents: ${r.skills.agents.length}`,
147
149
  `guardlink skills claude: ${names(r.guardlink_skills.claude)} agents: ${names(r.guardlink_skills.agents)}`,
148
- `hooks claude: ${yn(r.hooks.claude)} codex: ${yn(r.hooks.codex)}`,
150
+ `hooks claude: ${yn(r.hooks.claude)} codex: ${yn(r.hooks.codex)} cursor: ${yn(r.hooks.cursor)}`,
149
151
  `pre-pr claude: ${yn(r.pre_pr.claude)} codex: ${yn(r.pre_pr.codex)}${r.pre_pr.claude || r.pre_pr.codex ? '' : ' (opt-in: bravos setup --pre-pr-hook)'}`,
150
152
  `autopilot claude: ${yn(r.autopilot.claude)} codex: ${yn(r.autopilot.codex)}${r.autopilot.claude || r.autopilot.codex ? '' : ' (opt-in: bravos setup --autopilot)'}`,
151
153
  `cards claude: ${yn(r.cards.claude)} codex: ${yn(r.cards.codex)}${r.cards.claude || r.cards.codex ? (process.env.BRAVOS_THREAT_CARDS === 'off' ? ' (off for this run: BRAVOS_THREAT_CARDS=off)' : '') : ' (bravos setup adds it)'}`,
package/dist/guide.js CHANGED
@@ -13,7 +13,7 @@ export const GUIDE_TOPICS = [
13
13
  name: 'At session start',
14
14
  body: [
15
15
  'A hook gathers the repo\'s security picture (open exposures, confirmed exploits, what to test next, stale claims, tickets, teammates\' open PRs, intent) and hands it to the model, so you never need a command to load it. On a fresh start you also see the banner; the model does not.',
16
- 'Claude Code shows the banner above the first prompt. Codex lists a two-line summary as a hook warning (F2 to view). omp shows the banner above the editor until your first prompt. opencode gets the briefing for the model only. Antigravity (agy) gets the briefing for the model only. Anywhere else, the bravos skill loads the briefing when you run it.',
16
+ 'Every agent shows the same Bravos picture, through the best channel it has. Claude Code shows the banner above the first prompt, and Gemini shows it at session start. omp shows it above the editor until your first prompt. Codex shows the Bravos card (the banner without the logo) with your first message. Cursor and opencode cannot draw anything at launch, so the agent opens its first reply with the card. Antigravity gets the briefing for the model only. Anywhere else, the bravos skill loads the briefing when you run it.',
17
17
  ],
18
18
  },
19
19
  {
@@ -25,7 +25,7 @@ export const GUIDE_TOPICS = [
25
25
  {
26
26
  name: 'Plans',
27
27
  body: [
28
- 'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in one repository. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine\'s: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
28
+ 'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine\'s: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
29
29
  ],
30
30
  },
31
31
  {
@@ -37,7 +37,7 @@ export const GUIDE_TOPICS = [
37
37
  {
38
38
  name: 'Installing',
39
39
  body: [
40
- 'npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos setup: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).', 'By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos setup --agent claude in a repository writes the skills, hooks and MCP wiring, bravos setup --analyzer --codegraph puts the analyzer and the code graph on the machine (Team plan), and guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.',
40
+ 'npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos setup: a guided setup that asks one question at a time (colours, an optional sign-in that you can skip to stay on Free, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).', 'By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos setup --agent claude in a repository writes the skills, hooks and MCP wiring, bravos setup --analyzer --codegraph puts the analyzer and the code graph on the machine (Team plan), and guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.',
41
41
  ],
42
42
  },
43
43
  {
@@ -198,7 +198,7 @@ export const GUIDE_TOPICS = [
198
198
  { name: 'omp', body: ['Reads the Claude Code skills and MCP; .omp/extensions/bravos.js shows the banner and hands over the briefing.'] },
199
199
  { name: 'opencode', body: ['Finds the skills in .claude/skills and .agents/skills through its skill tool; bravos adds /bravos… commands in .opencode/commands that load them, a plugin in .opencode/plugins (opencode 2.x) that adds the briefing to the system prompt, and guardlink MCP in opencode.json.'] },
200
200
  { name: 'Antigravity (agy)', body: ['Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group that injects the briefing.'] },
201
- { name: 'Cursor', body: ['.cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.'] },
201
+ { name: 'Cursor', body: ['When the repo has a .cursor/ folder (or with --agent cursor): .cursor/rules/bravos.mdc points at the skills, and a sessionStart hook in .cursor/hooks.json gives the agent the briefing and the Bravos card for its first reply.'] },
202
202
  { name: 'VS Code (Copilot agent)', body: ['Reads hooks from .claude/settings.json (preview), so the briefing can load there too.'] },
203
203
  { name: 'Every repo, or one copy of each skill', body: ['bravos setup --global installs for your user: skills in ~/.claude/skills (linked from ~/.agents/skills) and a user hook that briefs repos with a threat model but no bravos install. bravos setup --link-skills makes a repo\'s .agents/skills a link to .claude/skills, so tools that read both (Warp) list each skill once.'] },
204
204
  { name: 'Banner switches', body: ['BRAVOS_BANNER=off hides it; BRAVOS_BANNER_COLOR=off or NO_COLOR prints it plain. The briefing for the model is unchanged either way.', 'Light terminal? BRAVOS_THEME=light (or dark, or neutral) picks the colours for the banner and bravos watch; otherwise COLORFGBG, the choice saved by bravos setup, then neutral. bravos doctor shows which, and the c key in bravos watch switches.'] },
package/dist/help.js CHANGED
@@ -78,8 +78,8 @@ Commands
78
78
  Run 'bravos <command> --help' for every flag and what it writes.
79
79
 
80
80
  Plans
81
- Free (researcher): the research loop in one repository — context, annotate, templatize,
82
- env, prove, recheck, report, watch — with no licence at all.
81
+ Free (researcher): the research loop in each repository on its own, any number of them —
82
+ context, annotate, templatize, env, prove, recheck, report, watch — with no licence at all.
83
83
  Team (per developer; Solo is one seat): the pre-PR gate and autopilot, the CI and nightly
84
84
  workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph.
85
85
  A paid command or flag without a licence says what it would do and how to start the trial;
@@ -105,7 +105,7 @@ export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
105
105
  }
106
106
  // Check the user's PATH again after installation, before invoking any post-install command on the selected binary.
107
107
  const found = whichBin(name, installEnv);
108
- const status = checkProofTool(name, installEnv);
108
+ const status = checkProofTool(name, installEnv, undefined, pins);
109
109
  if (!found && name === 'cxg' && !cargoBinOnPath(env)) {
110
110
  throw new BravosError(`cxg was built and installed in ${cargoBinDir(env)}, but that folder is not on your PATH, so nothing can run it. Add it once: ${cargoPathFix(env)}; then run bravos setup --check.`);
111
111
  }
package/dist/licence.js CHANGED
@@ -40,7 +40,7 @@ export function licenceLines(L, v) {
40
40
  }
41
41
  else if (v.state === 'invalid' || v.state === 'unreadable')
42
42
  lines.push(` ${v.message}`);
43
- lines.push(`Unlocked: ${v.unlocked.length ? v.unlocked.map((f) => L.PAID_FEATURE_LABELS[f]).join(', ') : 'the research loop (context, annotate, templatize, env, prove, recheck, report, watch), in one repository'}`);
43
+ lines.push(`Unlocked: ${v.unlocked.length ? v.unlocked.map((f) => L.PAID_FEATURE_LABELS[f]).join(', ') : 'the research loop (context, annotate, templatize, env, prove, recheck, report, watch), in each repository on its own'}`);
44
44
  if (v.locked.length)
45
45
  lines.push(`On Team: ${v.locked.map((f) => L.PAID_FEATURE_LABELS[f]).join(', ')}`);
46
46
  if (!v.licensed)
@@ -229,7 +229,7 @@ nothing from your sessions.
229
229
 
230
230
  ## Plans
231
231
 
232
- The research loop is free for one researcher in one repository. The pre-PR gate
232
+ The research loop is free for one researcher, in any number of repositories. The pre-PR gate
233
233
  and autopilot, CI and nightly workflows, scheduled upkeep, workspaces, campaigns,
234
234
  SAST and the code graph are on the Team plan: \`bravos account activate\` starts a
235
235
  30-day trial with no card. See [how licensing works](https://docs.bugb.io/bravos/concepts/how-licensing-works/).
@@ -1,8 +1,30 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { resolve } from 'node:path';
3
3
  import { findTool, withToolDir } from './tool-path.js';
4
+ import { PROOF_TOOL_PINS } from './versions.js';
5
+ // @comment -- "Reads the first X.Y.Z (with an optional -prerelease) from a tool's --version output: cxg prints 'cxg 1.9.1', guardlink prints '2.7.0'. Anything else is unparseable, and the caller says so instead of guessing."
6
+ export function parseToolVersion(output) {
7
+ const m = /(?:^|[\s v])(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?=$|[\s+,;)])/m.exec(output.trim());
8
+ return m ? `${m[1]}.${m[2]}.${m[3]}${m[4] ?? ''}` : null;
9
+ }
10
+ /** Negative when a < b, 0 when equal, positive when a > b; a prerelease sorts before its release. */
11
+ export function compareToolVersions(a, b) {
12
+ const split = (v) => { const [core, pre] = v.split(/-(.*)/s); return { core: core.split('.').map(Number), pre: pre ?? '' }; };
13
+ const x = split(a), y = split(b);
14
+ for (let i = 0; i < 3; i++)
15
+ if ((x.core[i] ?? 0) !== (y.core[i] ?? 0))
16
+ return (x.core[i] ?? 0) - (y.core[i] ?? 0);
17
+ if (x.pre === y.pre)
18
+ return 0;
19
+ if (!x.pre)
20
+ return 1;
21
+ if (!y.pre)
22
+ return -1;
23
+ return x.pre < y.pre ? -1 : 1;
24
+ }
4
25
  // @comment -- "Checks the CLI interface in the executable that will run. Release and development binaries can have identical version strings. Only fixed help arguments are passed, with no shell, bounded output and a deadline (10 s: a cold start on a busy machine can take several); no URL, credentials or template is supplied."
5
- export function checkProofTool(name, env, timeoutMs = 10000) {
26
+ // @comment -- "Then compares the version the executable reports with the release this bravos pins: an older one needs the same upgrade a fresh install gets, a newer or equal one is kept (setup never downgrades), and one whose version cannot be read is reported for a person to look at rather than replaced. A source pin (a revision) names a commit, not a release, so only the interface is checked for it."
27
+ export function checkProofTool(name, env, timeoutMs = 10000, pins = PROOF_TOOL_PINS) {
6
28
  const guardlink = name === 'guardlink';
7
29
  const capability = guardlink ? 'in-session probe translation' : 'plain scan of supplied JS probes with zero model calls';
8
30
  // Found on PATH or, for cxg, in cargo's folder off PATH: it is checked, and later run, by its full path.
@@ -17,12 +39,25 @@ export function checkProofTool(name, env, timeoutMs = 10000) {
17
39
  const flags = guardlink ? ['--stdout', '--contract', '--threat'] : ['--no-author', '--templates', '--scope-file', '--auth-dir', '--session-dir'];
18
40
  const supported = flags.every((flag) => new RegExp('(?:^|\\s)' + flag + '(?=\\s|,|$)', 'm').test(help.stdout))
19
41
  && (guardlink || /supplied JS probe/i.test(help.stdout));
20
- return { name, capability, status: supported ? 'ready' : 'incompatible' };
42
+ if (!supported)
43
+ return { name, capability, status: 'incompatible' };
44
+ const pin = pins[name];
45
+ if (pin.revision)
46
+ return { name, capability, status: 'ready' };
47
+ const ver = spawnSync(resolve(binary), guardlink ? ['--version'] : ['--disable-update-check', '--version'], { env: withToolDir(env, found), encoding: 'utf8', timeout: timeoutMs, maxBuffer: 64 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
48
+ const version = !ver.error && ver.status === 0 ? parseToolVersion(ver.stdout ?? '') : null;
49
+ if (!version)
50
+ return { name, capability, status: 'unknown-version', pinned: pin.version };
51
+ return { name, capability, status: compareToolVersions(version, pin.version) < 0 ? 'outdated' : 'ready', version, pinned: pin.version };
21
52
  }
22
53
  export function formatProofTool(check) {
23
54
  const what = check.name + ' · ' + check.capability;
24
55
  if (check.status === 'ready')
25
- return '✔ ' + what;
56
+ return '✔ ' + what + (check.version ? ' (' + check.version + ')' : '');
57
+ if (check.status === 'outdated')
58
+ return '✘ ' + what + ' — ' + check.version + ' is older than the pinned ' + check.pinned + ': bravos setup --tools -y upgrades it';
59
+ if (check.status === 'unknown-version')
60
+ return '✘ ' + what + ' — could not read its version (' + check.name + ' --version); this bravos pins ' + check.pinned + ': check which ' + check.name + ' is first on PATH, or install the pinned release';
26
61
  if (check.status === 'missing')
27
62
  return '✘ ' + what + ' — tool missing';
28
63
  if (check.status === 'unavailable')
package/dist/setup.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // @comment -- "bravos setup: puts the binaries bravos drives onto this machine. The analyzer and the code graph are licensed bundles fetched through the account portal (artifacts.ts); guardlink and cxg are free CLIs installed with their own package managers. --check reports without changing anything, --dry-run says what would run, and nothing is fetched or installed without a licence for it. Also the SAST runner: `bravos sast run` invokes the staged analyzer with the argv the Python CLI used and writes the run folder the briefing and `bravos sast` read."
2
2
  import { checkProofTool, formatProofTool } from './proof-tools.js';
3
3
  import { spawnSync } from 'node:child_process';
4
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
5
5
  import { isAbsolute, join } from 'node:path';
6
6
  import { bundleEnvironment, hostTarget, install, missingPaths, olderThan, staged, stagedVersion, VERSIONS } from './artifacts.js';
7
- import { graphBin, graphEnv } from './codegraph.js';
7
+ import { graphBin, graphEnv, graphStore } from './codegraph.js';
8
8
  import { whichBin } from './guardlink.js';
9
9
  import { findAnalyzer } from './graphbin.js';
10
10
  import { licenceLib, requireFeature } from './licence.js';
@@ -100,7 +100,12 @@ export async function runSetup(env, opts, io) {
100
100
  if (!check)
101
101
  throw new BravosError(i.id + ': capability check is unavailable');
102
102
  if (i.present && check.status === 'ready') {
103
- lines.push(formatProofTool(check), i.id + ': already compatible at ' + i.present);
103
+ lines.push(formatProofTool(check), i.id + ': already compatible at ' + i.present + (check.version ? ' (' + check.version + ')' : ''));
104
+ continue;
105
+ }
106
+ // A version that cannot be read may be newer than the pin; installing over it could downgrade it, so a person decides.
107
+ if (i.present && check.status === 'unknown-version') {
108
+ lines.push(formatProofTool(check), i.id + ': left as it is at ' + i.present + '; to install the pinned release instead: ' + i.action);
104
109
  continue;
105
110
  }
106
111
  // A cxg already built into cargo's folder, which is not on PATH: building it again ends the same way, so say how to put it on PATH instead.
@@ -110,7 +115,7 @@ export async function runSetup(env, opts, io) {
110
115
  continue;
111
116
  }
112
117
  if (opts.dryRun || !opts.yes) {
113
- const state = i.present ? check.status + ' at ' + i.present : 'absent';
118
+ const state = i.present ? (check.status === 'outdated' ? 'outdated (' + check.version + ', pinned ' + check.pinned + ')' : check.status) + ' at ' + i.present : 'absent';
114
119
  lines.push(i.id + ': ' + state + ' — ' + i.action + (opts.yes ? '' : ' (add -y to run it here)'));
115
120
  continue;
116
121
  }
@@ -135,7 +140,43 @@ export function selfTest(kind, dir, env) {
135
140
  }
136
141
  return out;
137
142
  }
138
- // @comment -- "Runs the analyzer the way the Python adapter did: bravos-cli analyze ROOT --ci --fail-on never --allow-incomplete-analysis --codegraph <reuse when a graph store exists> --scip off -f json,sarif -o .bravos/sast/<run>/report, under the bundle's environment, then writes meta.json (sha, exit, at) so the briefing's SAST line and bravos sast candidates read it. The exit code is a health signal; findings are read from the report."
143
+ // @comment -- "Whether this process can create entries in dir: makes and removes one empty probe folder. False for a missing folder or one a sandbox (Codex's workspace-write, Seatbelt) refuses, which a mode-bit check would not see."
144
+ function canWriteIn(dir) {
145
+ if (!dir)
146
+ return false;
147
+ try {
148
+ rmSync(mkdtempSync(join(dir, '.bravos-write-probe-')), { recursive: true, force: true });
149
+ return true;
150
+ }
151
+ catch {
152
+ return false;
153
+ }
154
+ }
155
+ // @comment -- "Where a SAST run keeps its caches, all inside the repository under .bravos/sast/cache/ (owner-only, gitignored), so the run works in a sandbox that allows writes only in the workspace: the analyzer's scan workspace (--workspace), Semgrep's settings, log and version cache (SEMGREP_SETTINGS_FILE, SEMGREP_LOG_FILE, SEMGREP_VERSION_CACHE_PATH, unless set), and, when the shared code-graph store cannot be written, the analyzer's own graph store (BRAVOS_CODEGRAPH_DIR), which holds the extraction cache the analyzer writes even when it only reads a graph. The shared store stays in use while it is writable, so the analyzer keeps reading the graph bravos graph build wrote; a BRAVOS_CODEGRAPH_DIR the caller set is always used as given."
156
+ export function sastCache(root, env) {
157
+ const dir = join(root, '.bravos', 'sast', 'cache');
158
+ const workspace = join(dir, 'workspace');
159
+ const semgrep = join(dir, 'semgrep');
160
+ for (const d of [dir, workspace, semgrep])
161
+ mkdirSync(d, { recursive: true, mode: 0o700 });
162
+ const out = {};
163
+ const set = (k, v) => {
164
+ if (!env[k])
165
+ out[k] = v;
166
+ };
167
+ set('SEMGREP_SETTINGS_FILE', join(semgrep, 'settings.yml'));
168
+ set('SEMGREP_LOG_FILE', join(semgrep, 'semgrep.log'));
169
+ set('SEMGREP_VERSION_CACHE_PATH', join(semgrep, 'semgrep_version'));
170
+ const sharedStore = env.BRAVOS_CODEGRAPH_DIR ? null : graphStore(env);
171
+ const ownGraph = !env.BRAVOS_CODEGRAPH_DIR && !canWriteIn(sharedStore);
172
+ if (ownGraph) {
173
+ const store = join(dir, 'codegraph');
174
+ mkdirSync(store, { recursive: true, mode: 0o700 });
175
+ out.BRAVOS_CODEGRAPH_DIR = store;
176
+ }
177
+ return { dir, workspace, env: out, ownGraph, sharedStore };
178
+ }
179
+ // @comment -- "Runs the analyzer the way the Python adapter did: bravos-cli analyze ROOT --ci --fail-on never --allow-incomplete-analysis --codegraph <reuse when a graph store exists, auto when it keeps its own> --scip off --workspace .bravos/sast/cache/workspace -f json,sarif -o .bravos/sast/<run>/report, under the bundle's environment with its caches in the repository (sastCache), then writes meta.json (sha, exit, at, cache, graphStore) so the briefing's SAST line and bravos sast candidates read it. The exit code is a health signal; findings are read from the report."
139
180
  export async function runSast(root, env, opts = {}) {
140
181
  const licence = await requireFeature(env, 'sast', 'bravos sast run');
141
182
  const dir = staged(env, 'analyzer');
@@ -155,9 +196,11 @@ export async function runSast(root, env, opts = {}) {
155
196
  const runDir = join(base, run);
156
197
  mkdirSync(runDir, { recursive: true });
157
198
  const sha = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', timeout: 5000 }).stdout?.trim() || null;
158
- let codegraph = opts.codegraph ?? (graphBin('codegraph-mcp', env) ? 'reuse' : 'off');
199
+ const cache = sastCache(root, env);
200
+ // @comment -- "A graph store of the analyzer's own starts empty, so reuse would refuse every first run: let the analyzer build the graph there (auto) unless the caller chose a mode."
201
+ let codegraph = opts.codegraph ?? (cache.ownGraph ? 'auto' : graphBin('codegraph-mcp', env) ? 'reuse' : 'off');
159
202
  const argvFor = (graph) => {
160
- const a = ['analyze', root, '--ci', '--fail-on', 'never', '--allow-incomplete-analysis', '--codegraph', graph, '--scip', opts.scip ?? 'off', '-f', 'json,sarif', '-o', join(runDir, 'report')];
203
+ const a = ['analyze', root, '--ci', '--fail-on', 'never', '--allow-incomplete-analysis', '--codegraph', graph, '--scip', opts.scip ?? 'off', '--workspace', cache.workspace, '-f', 'json,sarif', '-o', join(runDir, 'report')];
161
204
  if (opts.scope?.length)
162
205
  a.push('--scope', opts.scope.join(','));
163
206
  // @comment -- ".bravos/ is always excluded: it holds the hooks bravos setup copied into the repository and the SAST runs themselves, which are bravos's code, not the customer's, and would otherwise surface as findings 'not in the threat model'."
@@ -168,22 +211,24 @@ export async function runSast(root, env, opts = {}) {
168
211
  a.push('--timeout', String(Math.max(1, opts.timeoutS - 1)));
169
212
  return a;
170
213
  };
171
- // @comment -- "The analyzer reads the code graph from the same store bravos graph build writes to, so it runs with BRAVOS_CODEGRAPH_DIR set (graphEnv): without it, --codegraph reuse looks in the analyzer's own default store and finds no graph even when one was just built."
172
- const baseEnv = graphEnv(env);
214
+ // @comment -- "The analyzer reads the code graph from the same store bravos graph build writes to, so it runs with BRAVOS_CODEGRAPH_DIR set (graphEnv): without it, --codegraph reuse looks in the analyzer's own default store and finds no graph even when one was just built. sastCache's variables go on top: the in-repository caches, and an in-repository store only when the shared one cannot be written."
215
+ const baseEnv = { ...graphEnv(env), ...cache.env };
173
216
  // @comment -- "The analyzer looks for its licence only in $BRAVOS_HOME or $BRAVOS_LICENCE, while bravos also falls back to ~/.bravos and ~/.bugb. Hand it the licence file bravos found (the path, never the token), so a SAST run never refuses a licence bravos accepted."
174
217
  if (!env.BRAVOS_LICENCE && !env.BRAVOS_LICENSE && isAbsolute(licence.source) && existsSync(licence.source))
175
218
  baseEnv.BRAVOS_LICENCE = licence.source;
176
219
  const runEnv = dir ? bundleEnvironment(dir, baseEnv) : baseEnv;
177
220
  const spawn = (graph) => spawnSync(bin, argvFor(graph), { cwd: root, env: runEnv, encoding: 'utf8', timeout: (opts.timeoutS ?? 1800) * 1000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
178
- let r = spawn(codegraph);
179
221
  const notes = [];
222
+ if (cache.ownGraph)
223
+ notes.push(` ${cache.sharedStore ? `the shared code-graph store ${cache.sharedStore} is not writable here (a sandbox that allows writes only in the workspace?)` : 'there is no shared code-graph store'}, so the analyzer kept its graph in ${cache.env.BRAVOS_CODEGRAPH_DIR}`);
224
+ let r = spawn(codegraph);
180
225
  // No graph built for this commit yet: reuse refuses outright. Scan without reachability rather than fail, and say how to get it.
181
226
  if (codegraph === 'reuse' && r.status === 3 && /CodeGraph unavailable|No CodeGraph/i.test(`${r.stdout}\n${r.stderr}`)) {
182
227
  notes.push(' no code graph for this commit yet, so the scan ran without reachability; bravos graph build . --scip no-exec first, then bravos sast run again, to see which findings are reached');
183
228
  codegraph = 'off';
184
229
  r = spawn(codegraph);
185
230
  }
186
- writeFileSync(join(runDir, 'meta.json'), JSON.stringify({ sha, base: null, scope: opts.scope?.length ? opts.scope.join(',') : 'all', exit: r.status, at: new Date().toISOString(), analyzer: bin, codegraph }, null, 2) + '\n');
231
+ writeFileSync(join(runDir, 'meta.json'), JSON.stringify({ sha, base: null, scope: opts.scope?.length ? opts.scope.join(',') : 'all', exit: r.status, at: new Date().toISOString(), analyzer: bin, codegraph, cache: cache.dir, graphStore: runEnv.BRAVOS_CODEGRAPH_DIR ?? null }, null, 2) + '\n');
187
232
  const lines = [`SAST run ${run}: bravos-cli exited ${r.status ?? 'by signal'} (0 clean at the level, 1 findings, 3 licence refused or analysis failed, 4 a stage failed)`, ` report: ${join(runDir, 'report.json')}`, ...notes];
188
233
  // @comment -- "Keep analyzer diagnostics in the gitignored run folder with owner-only permissions, including warnings on exit 0/1. Failure summaries show both ends so trailing progress cannot hide the cause; spawn errors have no stderr."
189
234
  if (r.stderr) {
@@ -76,14 +76,14 @@ async function flow(opts, d) {
76
76
  }
77
77
  // What to type to ask the repository's questions again, in the words of the command the person used.
78
78
  const change = opts.command === 'setup' ? 'bravos setup --change' : 'bravos start --again';
79
- // @comment -- "The setup has two parts, and each says so once: this machine (colours, sign-in, tools: set once, used by every repository) and this repository (agents, checks, testing: recorded in the repository for the team). A second repository on a machine that is ready skips the first part with one line saying so."
79
+ // @comment -- "The setup has two parts, and each says so once: this machine (colours, an optional sign-in, tools: set once, used by every repository) and this repository (agents, checks, testing: recorded in the repository for the team). A second repository on a machine that is ready skips the first part with one line saying so."
80
80
  const said = { machine: false, repository: false };
81
81
  const heading = (part) => {
82
82
  if (said[part])
83
83
  return;
84
84
  said[part] = true;
85
85
  p.info(part === 'machine'
86
- ? 'This machine — colours, sign-in and tools. Set once; every repository on this machine uses them.'
86
+ ? 'This machine — colours, an optional sign-in and tools. Set once; every repository on this machine uses them.'
87
87
  : 'This repository — which agents, pull-request checks and testing. Recorded in the repository, so your team gets the same.');
88
88
  };
89
89
  let themeKept = false;
@@ -123,9 +123,10 @@ async function flow(opts, d) {
123
123
  if (!s.lic.licensed && !opts.yes)
124
124
  heading('machine');
125
125
  if (!s.lic.licensed && !opts.yes) {
126
- const how = await p.select('licence', 'No Bravos licence on this machine yet.', [
126
+ // @comment -- "Signing in is offered first (it starts the Team trial) but is optional: the Free plan needs no account, and the skip option says what Free includes, matching README 'Plans & licence' and LICENSE."
127
+ const how = await p.select('licence', 'No Bravos licence on this machine yet. Signing in is optional: the Free plan needs no account.', [
127
128
  { value: 'activate', label: 'Sign in now', hint: 'activate your licence, or start the free 30-day Team trial', recommended: true },
128
- { value: 'skip', label: 'Continue on the free plan', hint: 'annotations only; PR checks and schedules need Team' },
129
+ { value: 'skip', label: 'Continue on the Free plan, no account needed', hint: 'annotate and the authorized test loop (env, prove, recheck) in each repository, no limit on how many; PR checks, CI, SAST, the code graph, schedules and multi-repository workspaces need Team' },
129
130
  ], 'activate');
130
131
  if (how === 'activate') {
131
132
  try {
@@ -146,6 +147,10 @@ async function flow(opts, d) {
146
147
  async (s) => {
147
148
  s.items = (await d.setupPlan()).items;
148
149
  p.note(s.items.map((i) => {
150
+ if (i.present && i.proofTool?.status === 'outdated')
151
+ return `✗ ${i.id.padEnd(10)} ${i.present} is ${i.proofTool.version}, older than the pinned ${i.proofTool.pinned}`;
152
+ if (i.present && i.proofTool?.status === 'unknown-version')
153
+ return `✗ ${i.id.padEnd(10)} ${i.present} did not report a version; this bravos pins ${i.proofTool.pinned}`;
149
154
  if (i.present && i.proofTool && i.proofTool.status !== 'ready')
150
155
  return `✗ ${i.id.padEnd(10)} ${i.present} needs a compatible build for ${i.proofTool.capability}`;
151
156
  if (i.present && i.behind && i.licensed)
package/dist/uninstall.js CHANGED
@@ -21,7 +21,7 @@ function readJson(root, rel) {
21
21
  throw new BravosError(`${rel} is not a JSON object; fix it or remove it, nothing was removed`);
22
22
  return parsed;
23
23
  }
24
- /** Removes bravos's commands from a Claude Code / Codex hooks file; returns the new document, or null when nothing changed. */
24
+ /** Removes bravos's commands from a Claude Code / Codex hooks file (groups holding hooks) or a Cursor one (entries listed directly); returns the new document, or null when nothing changed. */
25
25
  function stripHooks(doc) {
26
26
  if (!isObject(doc.hooks))
27
27
  return null;
@@ -33,6 +33,14 @@ function stripHooks(doc) {
33
33
  continue;
34
34
  }
35
35
  const kept = groups
36
+ .filter((g) => {
37
+ // Cursor lists { command } entries directly under the event.
38
+ if (isObject(g) && !Array.isArray(g.hooks) && isBravosCommand(g.command)) {
39
+ changed = true;
40
+ return false;
41
+ }
42
+ return true;
43
+ })
36
44
  .map((g) => {
37
45
  if (!isObject(g) || !Array.isArray(g.hooks))
38
46
  return g;
@@ -50,6 +58,9 @@ function stripHooks(doc) {
50
58
  const out = { ...doc, hooks };
51
59
  if (Object.keys(hooks).length === 0)
52
60
  delete out.hooks;
61
+ // A Cursor file left with nothing but its version number held only bravos's hook.
62
+ if (Object.keys(out).length === 1 && 'version' in out)
63
+ delete out.version;
53
64
  return out;
54
65
  }
55
66
  function writeOrDelete(root, rel, doc, dryRun) {
@@ -77,7 +88,7 @@ function pruneEmpty(root, rel) {
77
88
  dir = dirname(dir);
78
89
  }
79
90
  }
80
- // @comment -- "Removes what bravos installed under root: every file its lock records that is unchanged (edited ones are kept and listed unless --force), bravos's hook entries in .claude/settings.json and .codex/hooks.json, its group in .agents/hooks.json, its pre_pr entry in .guardlink/config.json, and .bravos/ itself; with home set, also the ~/.agents/skills/bravos* links. Never removes guardlink's own files, a reviewed scope.yaml, or MCP entries (which may predate bravos); those are listed. Hooks files are validated before anything is removed."
91
+ // @comment -- "Removes what bravos installed under root: every file its lock records that is unchanged (edited ones are kept and listed unless --force), bravos's hook entries in .claude/settings.json, .codex/hooks.json and .cursor/hooks.json, its group in .agents/hooks.json, its pre_pr entry in .guardlink/config.json, and .bravos/ itself; with home set, also the ~/.agents/skills/bravos* links. Never removes guardlink's own files, a reviewed scope.yaml, or MCP entries (which may predate bravos); those are listed. Hooks files are validated before anything is removed."
81
92
  export function uninstall(root, opts = {}) {
82
93
  const dryRun = !!opts.dryRun;
83
94
  const report = { removed: [], kept: [], unregistered: [], notes: [] };
@@ -85,7 +96,7 @@ export function uninstall(root, opts = {}) {
85
96
  throw new BravosError(`bravos is not installed in ${root} (no .bravos/ folder); nothing was removed`);
86
97
  }
87
98
  // Validate every structured file first, so a malformed one stops the run before any removal.
88
- const hookFiles = ['.claude/settings.json', '.codex/hooks.json'];
99
+ const hookFiles = opts.home ? ['.claude/settings.json', '.codex/hooks.json'] : ['.claude/settings.json', '.codex/hooks.json', '.cursor/hooks.json'];
89
100
  const docs = new Map(hookFiles.map((f) => [f, readJson(root, f)]));
90
101
  const agy = opts.home ? null : readJson(root, '.agents/hooks.json');
91
102
  const glConfig = opts.home ? null : readJson(root, '.guardlink/config.json');
package/docs/GUIDE.md CHANGED
@@ -14,7 +14,7 @@ Every claim moves through one loop: an annotation says code is exposed (or mitig
14
14
 
15
15
  A hook gathers the repo's security picture (open exposures, confirmed exploits, what to test next, stale claims, tickets, teammates' open PRs, intent) and hands it to the model, so you never need a command to load it. On a fresh start you also see the banner; the model does not.
16
16
 
17
- Claude Code shows the banner above the first prompt. Codex lists a two-line summary as a hook warning (F2 to view). omp shows the banner above the editor until your first prompt. opencode gets the briefing for the model only. Antigravity (agy) gets the briefing for the model only. Anywhere else, the bravos skill loads the briefing when you run it.
17
+ Every agent shows the same Bravos picture, through the best channel it has. Claude Code shows the banner above the first prompt, and Gemini shows it at session start. omp shows it above the editor until your first prompt. Codex shows the Bravos card (the banner without the logo) with your first message. Cursor and opencode cannot draw anything at launch, so the agent opens its first reply with the card. Antigravity gets the briefing for the model only. Anywhere else, the bravos skill loads the briefing when you run it.
18
18
 
19
19
  ### Running a skill
20
20
 
@@ -22,7 +22,7 @@ Claude Code and opencode: /bravos-ship. Codex: $bravos-ship. omp: /skill:bravos-
22
22
 
23
23
  ### Plans
24
24
 
25
- Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in one repository. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine's: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.
25
+ Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine's: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.
26
26
 
27
27
  ### Effort
28
28
 
@@ -30,7 +30,7 @@ Every skill reads one dial: low, medium (default), high or max. Say it ("annotat
30
30
 
31
31
  ### Installing
32
32
 
33
- npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos setup: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).
33
+ npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos setup: a guided setup that asks one question at a time (colours, an optional sign-in that you can skip to stay on Free, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).
34
34
 
35
35
  By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos setup --agent claude in a repository writes the skills, hooks and MCP wiring, bravos setup --analyzer --codegraph puts the analyzer and the code graph on the machine (Team plan), and guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.
36
36
 
@@ -386,7 +386,7 @@ Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group tha
386
386
 
387
387
  ### Cursor
388
388
 
389
- .cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.
389
+ When the repo has a .cursor/ folder (or with --agent cursor): .cursor/rules/bravos.mdc points at the skills, and a sessionStart hook in .cursor/hooks.json gives the agent the briefing and the Bravos card for its first reply.
390
390
 
391
391
  ### VS Code (Copilot agent)
392
392
 
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  After `npm install -g @bugb-technologies/bravos`, run **`bravos setup`** in a repository you work in: it brings this machine and that repository up to date. In repositories you work in with an agent you can skip even that: the agent runs it at the start of a session. From 1.12 on you do not have to watch for releases: Bravos tells you when a newer version is out, and after you install it the agent brings each repository up to date. The notes below say what else changes, newest first. (Before 1.9 the same was `bravos setup --tools -y` per machine and `bravos sync` per repository; both still work.)
4
4
 
5
+ ## 1.18.0
6
+
7
+ - **Every agent now shows the same Bravos card,** through the best channel that agent has:
8
+
9
+ | Agent | Where you see it |
10
+ |---|---|
11
+ | Claude Code | the banner, at launch |
12
+ | omp | the banner, above the editor until your first prompt |
13
+ | Gemini | the banner, at session start |
14
+ | Codex | the card itself, shown as "↳ Hook ·" with your first message |
15
+ | Cursor | the agent's first reply opens with the card |
16
+ | OpenCode | the agent's first reply opens with the card |
17
+
18
+ Cursor and OpenCode give a hook or plugin no way to draw text for you, so the agent shows the card instead, once per session.
19
+ - **Codex no longer shows Bravos twice.** The hook's own message is now the card, so the agent stops repeating it, which saves about 700 tokens per session.
20
+ - **Cursor gets a session hook.** In a repository with a `.cursor/` folder, `bravos setup` adds a `sessionStart` entry to `.cursor/hooks.json`:
21
+ - It gives the agent the Bravos briefing.
22
+ - It keeps any hooks your team already has in that file.
23
+ - `--agent cursor` adds it to a repository without a `.cursor/` folder.
24
+ - `bravos doctor` lists it.
25
+ - `bravos uninstall` removes only Bravos's entry.
26
+ - **Bravos now installs GuardLink 2.7.1 and cert-x-gen 1.9.2.**
27
+ - **`bravos setup --tools -y` now upgrades a GuardLink or cert-x-gen older than these pins** (it used to keep any build with the right commands). A newer build is kept, and a build whose version cannot be read is reported and left for you; `bravos doctor` and `bravos setup --check` show which applies.
28
+ - **Signing in is optional.** The guided setup still offers sign-in first, but says the Free plan needs no account, and the Free option says what it includes. Free works in each repository on its own, with no limit on how many.
29
+ - **To get it:** run `bravos setup` in each repository, then start a new session in each agent.
30
+
31
+ ## 1.17.2
32
+
33
+ - **Codex's first reply opens with the full Bravos card.** It is the same content as the Claude Code banner, without the logo art, in a text block:
34
+ - the findings and how many claims are untested;
35
+ - the top threats;
36
+ - each setup step's state, and the next step.
37
+
38
+ It still appears once per new Codex session, not on resume or compact, and not with `BRAVOS_BANNER=off`.
39
+ - **`bravos sast run` works inside Codex's sandbox.** Before, it failed with "extraction cache I/O failed: Operation not permitted" until you granted Full Access, because the analyzer wrote its caches outside the repository. It now keeps them in `.bravos/sast/cache/`, which is ignored by git.
40
+ - **The shared code graph is still used when it can be written to.** Inside a sandbox, the scan builds its own copy in that folder and says so in one line.
41
+ - **Any `BRAVOS_CODEGRAPH_DIR` or Semgrep path you set yourself is respected.**
42
+ - **To get both:** run `bravos setup` in each repository.
43
+
5
44
  ## 1.17.1
6
45
 
7
46
  - **Codex now shows you the Bravos status.** Codex folds a hook's message into its warnings ("⚠ warnings · f2 to view"), and a hook cannot print to the Codex transcript, so the startup summary was easy to miss.
@@ -1057,32 +1057,26 @@ export function buildSummary(inputs, opts = {}) {
1057
1057
  return `${head} · ${countsLine(i.guardlink ?? {})}\n${plan ? `plan ${plan.label} · ` : ''}intent ${i.intent?.status ?? 'unknown'} · skills: ${next}\n${third}${update}`;
1058
1058
  }
1059
1059
 
1060
- // @comment -- "The one-line security status for a harness that shows the startup summary only as a folded warning (Codex puts a hook's systemMessage behind F2 and has no field that prints to the transcript): counts, tested state, coverage and the next setup step, plain text with nothing from the repo but its name. firstReplyStatus wraps it as the briefing's instruction to open the agent's first reply with that line, once; null on a resume or compact, or with BRAVOS_BANNER=off."
1061
- export function statusLine(inputs, opts = {}) {
1062
- const i = inputs ?? {};
1063
- const head = `Bravos${opts.version ? ` ${opts.version}` : ''}`;
1064
- if (i.guardlink === 'missing') return `${head} · guardlink not found on PATH — run bravos doctor`;
1065
- const g = i.guardlink ?? {};
1066
- const m = bannerMetrics(g);
1067
- const parts = [head];
1068
- if (m) {
1069
- parts.push(`${m.total} open${m.severities.length ? ` (${m.severities.join(', ')})` : ''}`, `${m.confirmed} confirmed`);
1070
- const states = testedStates(g);
1071
- if (states) parts.push(states);
1072
- if (m.coverage) parts.push(`coverage ${num(m.coverage.percent)}%`);
1073
- } else parts.push('threat counts unknown');
1074
- const setup = i.root ? readSetup(i.root, i, opts.harness) : null;
1075
- if (setup) {
1076
- parts.push(`setup ${setup.done}/${setup.total}`);
1077
- if (setup.next) parts.push(`next: ${setup.next.paid ? 'activate Team → bravos account activate' : `${setup.next.label} → ${setup.next.cta}`}`);
1060
+ // @comment -- "The startup picture for an agent that cannot draw the banner at launch: Codex draws the card itself as its hook message when the first prompt is sent; Cursor (whose sessionStart output reaches only the model) and opencode (whose plugin adds only to the system prompt) get it as the opening of the agent's first reply. statusCard is the Claude Code banner without the logo art: the banner's narrow layout in the harness's skill syntax, uncoloured, its header facts packed into rows of 64, with backticks swapped for quotes so it cannot close the code block it is shown in. firstReplyStatus wraps the card as the briefing's instruction to open the agent's first reply with it, once (skipped when the conversation already shows it, since opencode adds it to every request); null on a resume or compact, or with BRAVOS_BANNER=off."
1061
+ export function statusCard(inputs, opts = {}) {
1062
+ // 68 columns leaves 64 for the layout: under the logo's 68, so the card is text only.
1063
+ const lines = buildBanner(inputs, { harness: opts.harness, version: opts.version, columns: 68 }).replace(/`/g, "'").split('\n');
1064
+ // The narrow header gives each fact its own row; in a reply, pack them into as few rows of 64 as fit.
1065
+ const end = lines.findIndex((l, n) => n > 1 && /^[!~─]/.test(l));
1066
+ if (lines[0] !== 'BRAVOS' || lines[1] !== 'by bugb' || end < 2) return lines.join('\n');
1067
+ const rows = ['BRAVOS by bugb'];
1068
+ for (const fact of lines.slice(2, end)) {
1069
+ const joined = rows.at(-1) + (rows.length === 1 ? ' · ' : ' · ') + fact;
1070
+ if (cells(joined) <= 64) rows[rows.length - 1] = joined;
1071
+ else rows.push(fact);
1078
1072
  }
1079
- return clean(parts.join(' · '));
1073
+ return [...rows, ...lines.slice(end)].join('\n');
1080
1074
  }
1081
1075
 
1082
1076
  export function firstReplyStatus(inputs, opts = {}) {
1083
1077
  const source = inputs?.source;
1084
1078
  if (source === 'resume' || source === 'compact' || opts.env?.BRAVOS_BANNER === 'off') return null;
1085
- return `Status for the person: this harness shows Bravos's startup summary only as a folded warning, so open your first reply with this line, as written and on its own line, then answer their message; never repeat it later in the session: ${statusLine(inputs, opts)}`;
1079
+ return `Status for the person: this agent cannot show Bravos's startup banner to the person, so open your first reply with the card below, copied exactly, inside a text code block, then answer their message. Show it once: skip it when this conversation already shows it.\n\`\`\`text\n${statusCard(inputs, opts)}\n\`\`\``;
1086
1080
  }
1087
1081
 
1088
1082
  // Brand palette by theme (hooks/lib/palette.mjs). Colour is truecolor ANSI, added after
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "guardlink": {
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "repository": "https://github.com/Bugb-Technologies/guardlink.git",
5
5
  "revision": null
6
6
  },
7
7
  "cxg": {
8
- "version": "1.8.0",
8
+ "version": "1.9.2",
9
9
  "repository": "https://github.com/Bugb-Technologies/cert-x-gen.git",
10
10
  "revision": null
11
11
  }
@@ -1,9 +1,9 @@
1
- // @comment -- "SessionStart hook entry (--global: the user-level copy, silent where the repo has its own bravos hook or no .guardlink/; --briefing prints only the briefing text, for a skill that runs it by hand): reads the hook payload from stdin (bounded wait, bad input ignored; source, and Antigravity's workspacePaths), awaits collect() (read-only guardlink, git and gh facts under a shared 20 s deadline) and, where autopilot is registered, the session-start snapshot of the working tree (.bravos/watch/turn-base), and prints one JSON envelope: the briefing as additionalContext for the model, plus on a fresh start a banner as systemMessage for the human (brand-coloured; a three-line summary for Codex, whose briefing also asks the agent to open its first reply with a one-line status, since Codex folds a hook's message away as a warning). With --harness agy it prints Antigravity's injectSteps instead. Always exits 0 so a session never fails to start."
1
+ // @comment -- "SessionStart hook entry (--global: the user-level copy, silent where the repo has its own bravos hook or no .guardlink/; --briefing prints only the briefing text, for a skill that runs it by hand): reads the hook payload from stdin (bounded wait, bad input ignored; source, and Antigravity's workspacePaths), awaits collect() (read-only guardlink, git and gh facts under a shared 20 s deadline) and, where autopilot is registered, the session-start snapshot of the working tree (.bravos/watch/turn-base), and prints one JSON envelope: the briefing as additionalContext for the model, plus on a fresh start a banner as systemMessage for the human (brand-coloured; for Codex, which draws it inline with the first prompt, the Bravos card uncoloured; for Gemini, uncoloured). With --harness agy it prints Antigravity's injectSteps instead; with --harness cursor, Cursor's { additional_context }, whose briefing asks the agent to open its first reply with the Bravos card, since Cursor shows a hook's output to nobody but the model. Always exits 0 so a session never fails to start."
2
2
  import { closeSync, existsSync, openSync, realpathSync } from 'node:fs';
3
3
  import { WriteStream } from 'node:tty';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { autopilotRegistered, buildBanner, buildBriefing, buildSummary, collect, firstReplyStatus, readVersion, sessionHookRegistered } from './lib/briefing.mjs';
6
+ import { autopilotRegistered, buildBanner, buildBriefing, collect, firstReplyStatus, readVersion, sessionHookRegistered, statusCard } from './lib/briefing.mjs';
7
7
  import { resolveTheme } from './lib/palette.mjs';
8
8
  import { startGraphBuild } from './lib/graph-autobuild.mjs';
9
9
  import { takeSnapshot } from './lib/snapshot.mjs';
@@ -33,7 +33,7 @@ async function readPayload() {
33
33
  function harnessArg(argv, env) {
34
34
  const i = argv.indexOf('--harness');
35
35
  const v = i === -1 ? null : argv[i + 1];
36
- if (v === 'claude' || v === 'codex' || v === 'omp' || v === 'agy') return v;
36
+ if (v === 'claude' || v === 'codex' || v === 'omp' || v === 'agy' || v === 'cursor' || v === 'gemini') return v;
37
37
  return env.CLAUDE_PROJECT_DIR ? 'claude' : 'other';
38
38
  }
39
39
 
@@ -112,23 +112,29 @@ async function main() {
112
112
  // @comment -- "Starts the daily check for a newer Bravos in a detached process (hooks/lib/update-check.mjs); this session never waits on it, and the next prompt's coach or the next session reads its answer."
113
113
  checkUpdates({ env });
114
114
  text = buildBriefing(inputs);
115
- // @comment -- "Codex shows the summary below only as a folded warning (F2) and no hook field prints to its transcript, so on a fresh start the briefing asks the agent to open its first reply with the same status in one line."
116
- if (harness === 'codex') {
115
+ // @comment -- "Cursor's sessionStart hook has no field the person sees, only context for the model, so on a fresh start the briefing asks the agent to open its first reply with the Bravos card."
116
+ if (harness === 'cursor') {
117
117
  const status = firstReplyStatus(inputs, { harness, env, version: readVersion(dirname(fileURLToPath(import.meta.url))) });
118
118
  if (status) text += '\n' + status;
119
119
  }
120
- if (env.BRAVOS_BANNER !== 'off' && (source === null || source === 'startup') && harness !== 'agy') {
120
+ if (env.BRAVOS_BANNER !== 'off' && (source === null || source === 'startup') && harness !== 'agy' && harness !== 'cursor') {
121
121
  const version = readVersion(dirname(fileURLToPath(import.meta.url)));
122
- const color = !env.NO_COLOR && env.BRAVOS_BANNER_COLOR !== 'off';
122
+ // Gemini and Codex draw a hook's message as plain text, so they get no colour codes.
123
+ const color = !env.NO_COLOR && env.BRAVOS_BANNER_COLOR !== 'off' && harness !== 'gemini' && harness !== 'codex';
123
124
  // Which palette: BRAVOS_THEME, COLORFGBG, the choice saved by bravos setup, else neutral (hooks/lib/palette.mjs).
124
125
  const { theme } = resolveTheme(env);
125
- // Codex lists a hook's message as a warning, so it gets a three-line summary, not the art.
126
+ // @comment -- "Codex draws a hook's message inline as '↳ Hook ·' when the first prompt is sent, so it gets the Bravos card (the banner without the logo art), exact and uncoloured, and the agent is not asked to repeat it."
126
127
  // The leading newline puts the logo on its own lines: Claude Code prefixes the first line with "SessionStart:startup says:".
127
- out.systemMessage = harness === 'codex' ? buildSummary(inputs, { harness, version }) : '\n' + buildBanner(inputs, { harness, version, color, theme, columns: terminalColumns(env) });
128
+ out.systemMessage = harness === 'codex' ? statusCard(inputs, { harness, version }) : '\n' + buildBanner(inputs, { harness, version, color, theme, columns: terminalColumns(env) });
128
129
  }
129
130
  } catch (e) {
130
131
  text = `bravos briefing failed: ${e instanceof Error ? e.message : String(e)}`;
131
132
  }
133
+ if (harness === 'cursor') {
134
+ // Cursor's sessionStart output: additional_context reaches the model; nothing is shown to the person.
135
+ process.stdout.write(JSON.stringify({ additional_context: text }) + '\n');
136
+ process.exit(0);
137
+ }
132
138
  if (harness === 'agy') {
133
139
  // Antigravity's SessionStart output: steps injected before the first model call.
134
140
  process.stdout.write(JSON.stringify({ injectSteps: [{ systemMessage: text, metadata: { source: 'bravos' } }] }) + '\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
5
5
  "keywords": [
6
6
  "security",
@@ -1,5 +1,5 @@
1
1
  // bravos (managed by bravos init/sync; edits are kept, bravos sync --force replaces them)
2
- // @comment -- "opencode 2.x plugin (default export { id, setup }): opencode runs no Claude Code or Codex hooks, so this does bravos's session start itself. setup() runs the repo's .bravos/hooks briefing code in-process (read-only guardlink, git and gh facts) and registers session hooks that append the briefing to the system prompt of each model request and of compaction. Never throws into opencode."
2
+ // @comment -- "opencode 2.x plugin (default export { id, setup }): opencode runs no Claude Code or Codex hooks, so this does bravos's session start itself. setup() runs the repo's .bravos/hooks briefing code in-process (read-only guardlink, git and gh facts) and registers session hooks that append the briefing to the system prompt of each model request and of compaction. Each model request also carries the Bravos card with the instruction to open the agent's first reply with it, once (opencode's plugin can draw nothing in the transcript itself); compaction gets the briefing only. Never throws into opencode."
3
3
  import { join } from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
5
 
@@ -8,22 +8,26 @@ export default {
8
8
  setup: async (api) => {
9
9
  const root = api?.location?.directory ?? process.cwd();
10
10
  let briefing = null;
11
+ let card = null;
11
12
  const ready = (async () => {
12
13
  try {
13
14
  const lib = await import(pathToFileURL(join(root, '.bravos', 'hooks', 'lib', 'briefing.mjs')).href);
14
- briefing = lib.buildBriefing(await lib.collect(root, process.env));
15
+ const inputs = await lib.collect(root, process.env);
16
+ briefing = lib.buildBriefing(inputs);
17
+ // An older .bravos/hooks copy has no card yet; the briefing still goes in.
18
+ card = typeof lib.firstReplyStatus === 'function' ? lib.firstReplyStatus(inputs, { harness: 'opencode', env: process.env }) : null;
15
19
  } catch (e) {
16
20
  briefing = `bravos briefing failed: ${e instanceof Error ? e.message : String(e)}`;
17
21
  }
18
22
  })();
19
- const add = async (request) => {
23
+ const add = (withCard) => async (request) => {
20
24
  await ready;
21
- if (briefing && Array.isArray(request?.system)) request.system.push({ type: 'text', text: briefing });
25
+ if (briefing && Array.isArray(request?.system)) request.system.push({ type: 'text', text: withCard && card ? `${briefing}\n${card}` : briefing });
22
26
  };
23
27
  const handles = [];
24
- for (const name of ['context', 'compaction']) {
28
+ for (const [name, withCard] of [['context', true], ['compaction', false]]) {
25
29
  try {
26
- handles.push(await api.session.hook(name, add));
30
+ handles.push(await api.session.hook(name, add(withCard)));
27
31
  } catch {
28
32
  /* this opencode has no such hook */
29
33
  }