@bugb-technologies/bravos 1.17.2 → 1.19.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,8 @@ import { checkProofTool, formatProofTool } from './proof-tools.js';
7
7
  import { DOCTOR_HELP, INIT_HELP, PROGRAM_HELP, SYNC_HELP } from './help.js';
8
8
  import { Command, CommanderError, InvalidArgumentError, Option } from 'commander';
9
9
  import { CADENCES, CRON, WORKFLOW_NAMES, writeWorkflows } from './ci.js';
10
- import { CURSOR_RULE_PATH, writeCursorPointer } from './cursor.js';
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';
@@ -39,7 +40,7 @@ import { LOCK_PATH, readLock, sha256, writeLock } from './lock.js';
39
40
  import { mergeCodexConfig, mergeMcpJson, selectServers } from './mcp.js';
40
41
  import { hooksDir, skillsDir as bundledSkillsDir, version } from './paths.js';
41
42
  import { BravosError } from './types.js';
42
- // @comment -- "Which agents a repository already has Bravos installed for, read from the files Bravos wrote there: the two skills roots, the Codex and Antigravity hook registrations, and the opencode and omp plugins. Upkeep re-applies to exactly these, so a tool that happens to be on this machine, or an AGENTS.md someone added, never widens a team's setup."
43
+ // @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
44
  export function installedAgents(root) {
44
45
  const has = (rel) => existsSync(join(root, rel));
45
46
  const out = [];
@@ -60,6 +61,8 @@ export function installedAgents(root) {
60
61
  out.push('opencode');
61
62
  if (has(OMP_EXTENSION_PATH))
62
63
  out.push('omp');
64
+ if (cursorHookRegistered(root))
65
+ out.push('cursor');
63
66
  return out;
64
67
  }
65
68
  // @comment -- "Parses --workflows pr-gate,nightly-claude,nightly-codex,nightly-copilot; anything else is a usage error"
@@ -75,16 +78,16 @@ function parseWorkflows(value) {
75
78
  }
76
79
  const GUARDLINK_HINT = 'guardlink: not found on PATH — run bravos setup --tools -y';
77
80
  // 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' };
81
+ const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agy', opencode: 'opencode', omp: 'omp', cursor: 'cursor' };
79
82
  // @comment -- "Parses --agent <claude,codex>; codex maps to the .agents harness and anything else is a usage error."
80
83
  function parseAgents(value) {
81
84
  const out = [];
82
85
  // '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]));
86
+ const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'agy', 'opencode', 'omp', 'cursor'] : [r]));
84
87
  for (const raw of raws) {
85
88
  const h = AGENT_MAP[raw];
86
89
  if (!h)
87
- throw new InvalidArgumentError(`unknown agent '${raw}' (expected claude, codex, agy, opencode, omp or all)`);
90
+ throw new InvalidArgumentError(`unknown agent '${raw}' (expected claude, codex, agy, opencode, omp, cursor or all)`);
88
91
  if (!out.includes(h))
89
92
  out.push(h);
90
93
  }
@@ -161,6 +164,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
161
164
  const hookHarnesses = harnesses.filter((h) => h === 'claude' || codex);
162
165
  const forceOpencode = !!opts.agent?.includes('opencode');
163
166
  const forceOmp = !!opts.agent?.includes('omp');
167
+ const forceCursor = !!opts.agent?.includes('cursor');
164
168
  lines.push(`Harnesses: ${harnesses.join(', ')}${defaulted ? ' (default: no evidence found)' : ''}`);
165
169
  let guardlinkPending = false;
166
170
  if (withGuardlink) {
@@ -238,14 +242,24 @@ function pipeline(root, io, opts, withGuardlink, lines) {
238
242
  for (const s of mirror.skipped)
239
243
  lines.push(` skipped ${s.path} — ${s.reason}`);
240
244
  }
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 });
245
+ // @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."
246
+ const cursorHooks = explicit && !forceCursor ? { status: 'absent' } : writeCursorHooks(root, { dryRun, always: forceCursor });
247
+ if (cursorHooks.status === 'skipped')
248
+ lines.push(`Cursor: skipped ${cursorHooks.path} — ${cursorHooks.reason}`);
249
+ else if (cursorHooks.status !== 'absent')
250
+ lines.push(`Cursor: ${cursorHooks.path} ${cursorHooks.status} (briefing and the Bravos card at session start)`);
251
+ // With another --agent the Cursor pointer is left alone; upkeep still refreshes one that is already there.
252
+ const cursor = explicit && !forceCursor && !(opts.refreshOnly && existsSync(join(root, CURSOR_RULE_PATH))) ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
243
253
  if (cursor.status === 'skipped')
244
254
  lines.push(`Cursor: skipped ${cursor.path} — ${cursor.reason}`);
245
255
  else if (cursor.status === 'no-skills')
246
256
  lines.push(`Cursor: ${cursor.path} not written — no skills root was installed for it to point at`);
247
257
  else if (cursor.status !== 'absent')
248
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)`);
249
263
  const omp = explicit && !forceOmp ? { status: 'absent' } : writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
250
264
  if (omp.status === 'skipped')
251
265
  lines.push(`omp: skipped ${omp.path} — ${omp.reason}`);
@@ -342,10 +356,11 @@ function pipeline(root, io, opts, withGuardlink, lines) {
342
356
  if (stale.length)
343
357
  lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos setup --ci to refresh them.`);
344
358
  }
345
- const cursorWritten = cursor.status === 'written' || cursor.status === 'updated' ? [cursor.path] : [];
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] : []));
346
361
  const ompWritten = omp.status === 'written' || omp.status === 'updated' ? [omp.path] : [];
347
362
  const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
348
- 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];
349
364
  lines.push(...gitignoreWarnings(root, written, io.env));
350
365
  if (autopilotKept)
351
366
  lines.push('autopilot: kept (already installed); BRAVOS_AUTOPILOT=off pauses the check.');
@@ -826,6 +841,8 @@ export function buildProgram(io, result) {
826
841
  lines.push(` ${p}`);
827
842
  for (const u of r.unregistered)
828
843
  lines.push(`Unregistered bravos's hooks from ${u}`);
844
+ for (const u of r.unblocked)
845
+ lines.push(`Removed the Bravos block from ${u}; the rest of the file is kept`);
829
846
  for (const k of r.kept)
830
847
  lines.push(`Kept ${k.path} — ${k.reason}`);
831
848
  for (const n of r.notes)
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'))
@@ -68,3 +70,51 @@ export function writeCursorPointer(root, harnesses, opts = {}) {
68
70
  }
69
71
  return { status, path };
70
72
  }
73
+ // @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."
74
+ export const CURSOR_HOOKS_PATH = '.cursor/hooks.json';
75
+ // @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."
76
+ export const CURSOR_SESSION_COMMAND = 'node "$(git rev-parse --show-toplevel)/.bravos/hooks/session-start.mjs" --harness cursor';
77
+ // @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."
78
+ export function writeCursorHooks(root, opts = {}) {
79
+ if (!opts.always && !existsSync(join(root, '.cursor')))
80
+ return { status: 'absent' };
81
+ const path = CURSOR_HOOKS_PATH;
82
+ const abs = join(root, path);
83
+ let doc = { version: 1, hooks: {} };
84
+ const had = existsSync(abs);
85
+ if (had) {
86
+ try {
87
+ const parsed = JSON.parse(readFileSync(abs, 'utf8'));
88
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
89
+ return { status: 'skipped', path, reason: 'not a JSON object; fix it and run bravos setup again' };
90
+ doc = parsed;
91
+ }
92
+ catch {
93
+ return { status: 'skipped', path, reason: 'not valid JSON; fix it and run bravos setup again' };
94
+ }
95
+ }
96
+ const hooks = typeof doc.hooks === 'object' && doc.hooks !== null && !Array.isArray(doc.hooks) ? { ...doc.hooks } : {};
97
+ const ours = (e) => typeof e === 'object' && e !== null && /\.bravos\/hooks\/session-start\.mjs/.test(String(e.command ?? ''));
98
+ const current = Array.isArray(hooks.sessionStart) ? hooks.sessionStart : [];
99
+ const others = current.filter((e) => !ours(e));
100
+ hooks.sessionStart = [...others, { command: CURSOR_SESSION_COMMAND }];
101
+ const next = { version: typeof doc.version === 'number' ? doc.version : 1, ...doc, hooks };
102
+ const text = JSON.stringify(next, null, 2) + '\n';
103
+ if (had && readFileSync(abs, 'utf8') === text)
104
+ return { status: 'unchanged', path };
105
+ if (!opts.dryRun) {
106
+ mkdirSync(dirname(abs), { recursive: true });
107
+ writeFileSync(abs, text);
108
+ }
109
+ return { status: had ? 'updated' : 'written', path };
110
+ }
111
+ // @comment -- "True when .cursor/hooks.json registers bravos's session-start hook; an absent or unreadable file reads as false."
112
+ export function cursorHookRegistered(root) {
113
+ try {
114
+ const start = JSON.parse(readFileSync(join(root, CURSOR_HOOKS_PATH), 'utf8')).hooks?.sessionStart;
115
+ return Array.isArray(start) && start.some((e) => /\.bravos\/hooks\/session-start\.mjs/.test(String(e?.command ?? '')));
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ }
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,8 @@ 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
+ 'Teammates without Bravos: the hooks travel with the repository, but on a machine without Bravos (no bravos command, licence or plugin) they show only an invitation, once per session: the repository\'s own numbers from the committed threat model and the one command to join. Nothing else runs for them: no briefing, coach, threat cards, checks or background work, and nothing is sent anywhere. Their agent offers setup once and runs it only on a yes; "not now" hides it for 7 days in that clone (node .bravos/hooks/invite.mjs snooze). A team switches it off with {"invite": "off"} in .bravos/config.json.',
17
18
  ],
18
19
  },
19
20
  {
@@ -25,7 +26,7 @@ export const GUIDE_TOPICS = [
25
26
  {
26
27
  name: 'Plans',
27
28
  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.',
29
+ '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
30
  ],
30
31
  },
31
32
  {
@@ -37,7 +38,7 @@ export const GUIDE_TOPICS = [
37
38
  {
38
39
  name: 'Installing',
39
40
  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.',
41
+ '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
42
  ],
42
43
  },
43
44
  {
@@ -198,7 +199,8 @@ export const GUIDE_TOPICS = [
198
199
  { name: 'omp', body: ['Reads the Claude Code skills and MCP; .omp/extensions/bravos.js shows the banner and hands over the briefing.'] },
199
200
  { 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
201
  { 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.'] },
202
+ { 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.'] },
203
+ { name: 'Agents without hooks', body: ['A short Bravos block, between <!-- bravos:begin --> and <!-- bravos:end -->, in AGENTS.md and CLAUDE.md (when they exist or their skills are installed), GEMINI.md and .github/copilot-instructions.md (when they exist), and .windsurf/rules/bravos.md (with a .windsurf/ folder): an agent that got no briefing from a hook runs node .bravos/hooks/session-start.mjs --briefing. Setup replaces only that block; uninstall removes it.'] },
202
204
  { name: 'VS Code (Copilot agent)', body: ['Reads hooks from .claude/settings.json (preview), so the briefing can load there too.'] },
203
205
  { 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
206
  { 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
  }
@@ -0,0 +1,256 @@
1
+ import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join, relative, isAbsolute } from 'node:path';
3
+ import { readLock, sha256, writeLock } from './lock.js';
4
+ import { MARKER, skillsRoot } from './skills.js';
5
+ // @comment -- "The markers around Bravos's block in an instruction file other people also edit. Distinct from GuardLink's <!-- guardlink:begin --> / <!-- guardlink:end -->, so neither tool's sync can mistake the other's block for its own."
6
+ export const BLOCK_BEGIN = '<!-- bravos:begin -->';
7
+ export const BLOCK_END = '<!-- bravos:end -->';
8
+ const GUARDLINK_BEGIN = '<!-- guardlink:begin -->';
9
+ const GUARDLINK_END = '<!-- guardlink:end -->';
10
+ // @comment -- "The block's text, written for an agent: what Bravos is, the one command that brings the briefing (or, on a machine without Bravos, the invitation) when no hook delivered it, what to say when node is missing, and that nothing is installed without the person's go-ahead. Fixed text: no repository or user content is ever spliced in."
11
+ export const BLOCK_BODY = [
12
+ '## Bravos',
13
+ '',
14
+ 'This repository uses Bravos, a security workflow for coding agents.',
15
+ '- If no Bravos briefing reached you through a hook at session start, run `node .bravos/hooks/session-start.mjs --briefing` from the repository root once, at the start of the session, and follow what it prints: the security briefing, or an invitation to show the person when Bravos is not installed on this machine.',
16
+ '- If `node` is not available, tell the person once that this repository uses Bravos (`npm install -g @bugb-technologies/bravos && bravos setup`), then continue.',
17
+ '- Never install anything without the person\'s go-ahead.',
18
+ ];
19
+ // @comment -- "The whole delimited block, ending with one line break, in the file's own line ending."
20
+ export function bravosBlock(eol = '\n') {
21
+ return [BLOCK_BEGIN, ...BLOCK_BODY, BLOCK_END].join(eol) + eol;
22
+ }
23
+ // @comment -- "Where Bravos's Windsurf rule lives: Windsurf reads workspace rules from .windsurf/rules/*.md, and trigger: always_on puts it in every Cascade session. The whole file is Bravos's, so it is lock-recorded and uninstall deletes it when unchanged."
24
+ export const WINDSURF_RULE_PATH = '.windsurf/rules/bravos.md';
25
+ export const windsurfRule = () => `---\ntrigger: always_on\n---\n${MARKER}\n${bravosBlock()}`;
26
+ // @comment -- "The shared instruction files that carry the block, the agents that read each, and when each is created: AGENTS.md and CLAUDE.md also when their agent's skills root is installed, GEMINI.md and Copilot's file only when they already exist."
27
+ export const SHARED_FILES = [
28
+ { path: 'AGENTS.md', agents: ['agents', 'agy', 'opencode', 'omp', 'cursor'], skills: 'agents' },
29
+ { path: 'CLAUDE.md', agents: ['claude'], skills: 'claude' },
30
+ { path: 'GEMINI.md', agents: ['agy'] },
31
+ { path: '.github/copilot-instructions.md', agents: [] },
32
+ ];
33
+ /** [start, end) ranges of GuardLink's own blocks, where a Bravos marker is never looked for. */
34
+ function guardlinkRanges(text) {
35
+ const out = [];
36
+ let from = 0;
37
+ for (;;) {
38
+ const b = text.indexOf(GUARDLINK_BEGIN, from);
39
+ if (b === -1)
40
+ return out;
41
+ const e = text.indexOf(GUARDLINK_END, b);
42
+ if (e === -1) {
43
+ out.push([b, text.length]);
44
+ return out;
45
+ }
46
+ out.push([b, e + GUARDLINK_END.length]);
47
+ from = e + GUARDLINK_END.length;
48
+ }
49
+ }
50
+ /** The first index of `needle` at or after `from` that is not inside a GuardLink block, or -1. */
51
+ function indexOutside(text, needle, from, ranges) {
52
+ for (let i = text.indexOf(needle, from); i !== -1; i = text.indexOf(needle, i + 1)) {
53
+ if (!ranges.some(([s, e]) => i >= s && i < e))
54
+ return i;
55
+ }
56
+ return -1;
57
+ }
58
+ /** Where Bravos's block sits in `text`: its begin and end-marker offsets, null when absent, or an error for a begin with no end. */
59
+ function findBlock(text) {
60
+ const ranges = guardlinkRanges(text);
61
+ const begin = indexOutside(text, BLOCK_BEGIN, 0, ranges);
62
+ if (begin === -1)
63
+ return null;
64
+ const end = indexOutside(text, BLOCK_END, begin, ranges);
65
+ if (end === -1)
66
+ return { error: `has ${BLOCK_BEGIN} with no ${BLOCK_END} after it; fix it and run bravos setup again` };
67
+ return { begin, end };
68
+ }
69
+ // @comment -- "Puts the block into an instruction file's text: replaces the existing Bravos block in place, or appends it after everything else with one blank line before it. Text outside the markers, GuardLink's block included, is kept byte for byte."
70
+ export function upsertBlock(text) {
71
+ const eol = text.includes('\r\n') ? '\r\n' : '\n';
72
+ const block = bravosBlock(eol);
73
+ const at = findBlock(text);
74
+ if (at && 'error' in at)
75
+ return at;
76
+ if (at) {
77
+ // The block ends with one line break the previous write put there; drop exactly that one so a re-run is unchanged.
78
+ const tail = text.slice(at.end + BLOCK_END.length).replace(/^\r?\n/, '');
79
+ return { text: text.slice(0, at.begin) + block + tail };
80
+ }
81
+ if (text === '')
82
+ return { text: block };
83
+ const sep = text.endsWith('\n') ? eol : eol + eol;
84
+ return { text: text + sep + block };
85
+ }
86
+ // @comment -- "Takes the block out of an instruction file's text, with the line break that ends it and the blank line upsertBlock put before it; returns null when the file holds no Bravos block. Nothing else is changed."
87
+ export function removeBlock(text) {
88
+ const at = findBlock(text);
89
+ if (!at || 'error' in at)
90
+ return null;
91
+ let head = text.slice(0, at.begin);
92
+ const tail = text.slice(at.end + BLOCK_END.length).replace(/^\r?\n/, '');
93
+ if (/(\r?\n){2}$/.test(head))
94
+ head = head.replace(/\r?\n$/, '');
95
+ return head + tail;
96
+ }
97
+ // @comment -- "Resolves an instruction file for writing: absent, a regular file whose real path stays inside the repository, or a reason to leave it alone (a folder, a link that leaves the repository)."
98
+ // @exposes #instruction-blocks to #out-of-repo-write [medium] cwe:CWE-59 -- "AGENTS.md, CLAUDE.md and the rest come from the cloned repository, and any of them can be a link."
99
+ // @mitigates #instruction-blocks against #out-of-repo-write using #in-repo-target -- "A link such as CLAUDE.md -> AGENTS.md is followed only when it ends at a regular file inside the repository; anything else is reported and never written."
100
+ function target(root, rel) {
101
+ const abs = join(root, rel);
102
+ let st;
103
+ try {
104
+ st = lstatSync(abs);
105
+ }
106
+ catch {
107
+ // Absent: the parent must also stay inside the repository (a linked .github/ or .windsurf/ is not followed out).
108
+ try {
109
+ const parent = realpathSync(dirname(abs));
110
+ const rp = relative(realpathSync(root), parent);
111
+ if (rp.startsWith('..') || isAbsolute(rp))
112
+ return { reason: 'its folder is a link that leaves the repository' };
113
+ }
114
+ catch {
115
+ /* the folder does not exist yet; mkdir creates it inside root */
116
+ }
117
+ return { exists: false };
118
+ }
119
+ if (st.isSymbolicLink()) {
120
+ let real;
121
+ try {
122
+ real = realpathSync(abs);
123
+ }
124
+ catch {
125
+ return { reason: 'a link to a file that does not exist' };
126
+ }
127
+ const rp = relative(realpathSync(root), real);
128
+ if (rp.startsWith('..') || isAbsolute(rp))
129
+ return { reason: 'a link that leaves the repository' };
130
+ if (!lstatSync(real).isFile())
131
+ return { reason: 'not a regular file' };
132
+ return { exists: true };
133
+ }
134
+ if (!st.isFile())
135
+ return { reason: 'not a regular file' };
136
+ return { exists: true };
137
+ }
138
+ const lexists = (abs) => {
139
+ try {
140
+ lstatSync(abs);
141
+ return true;
142
+ }
143
+ catch {
144
+ return false;
145
+ }
146
+ };
147
+ // @comment -- "Writes or refreshes the Bravos block in each shared instruction file under its condition: the file exists, or (AGENTS.md, CLAUDE.md) that agent's skills root is installed. With an explicit --agent a file is written only when one of its agents was chosen, or when no --agent can name it (Copilot's file); upkeep also refreshes a block already present. Shared files are never lock-recorded, since people edit them."
148
+ export function writeInstructionBlocks(root, opts) {
149
+ const out = [];
150
+ const seen = new Set();
151
+ for (const f of SHARED_FILES) {
152
+ const t = target(root, f.path);
153
+ const has = 'exists' in t && t.exists;
154
+ const chosen = opts.agents === undefined || f.agents.length === 0 || f.agents.some((a) => opts.agents.includes(a));
155
+ const text = has ? readFileSync(join(root, f.path), 'utf8') : '';
156
+ const present = has && findBlock(text) !== null;
157
+ if (!chosen && !(opts.refreshOnly && present))
158
+ continue;
159
+ const installed = f.skills !== undefined && (opts.harnesses.includes(f.skills) || existsSync(join(root, skillsRoot(f.skills), 'bravos', 'SKILL.md')));
160
+ if ('reason' in t) {
161
+ if (installed || lexists(join(root, f.path)))
162
+ out.push({ path: f.path, status: 'skipped', reason: t.reason });
163
+ continue;
164
+ }
165
+ if (!has && !installed)
166
+ continue;
167
+ // CLAUDE.md linked to AGENTS.md is one file: it gets one block.
168
+ const real = has ? realpathSync(join(root, f.path)) : join(root, f.path);
169
+ if (seen.has(real)) {
170
+ out.push({ path: f.path, status: 'unchanged' });
171
+ continue;
172
+ }
173
+ seen.add(real);
174
+ const next = upsertBlock(text);
175
+ if ('error' in next) {
176
+ out.push({ path: f.path, status: 'skipped', reason: next.error });
177
+ continue;
178
+ }
179
+ if (has && next.text === text) {
180
+ out.push({ path: f.path, status: 'unchanged' });
181
+ continue;
182
+ }
183
+ if (!opts.dryRun) {
184
+ mkdirSync(dirname(join(root, f.path)), { recursive: true });
185
+ writeFileSync(join(root, f.path), next.text);
186
+ }
187
+ out.push({ path: f.path, status: has ? 'updated' : 'written' });
188
+ }
189
+ const w = writeWindsurfRule(root, opts);
190
+ if (w)
191
+ out.push(w);
192
+ return out;
193
+ }
194
+ // @comment -- "Writes .windsurf/rules/bravos.md when the repo has a .windsurf/ folder. Windsurf has no --agent value, so it follows the folder alone. The file is Bravos's whole: replaced only when the lock vouches for it or it carries the generated marker, unless --force, and the lock records what was written."
195
+ export function writeWindsurfRule(root, opts = {}) {
196
+ if (!existsSync(join(root, '.windsurf')))
197
+ return null;
198
+ const path = WINDSURF_RULE_PATH;
199
+ const t = target(root, path);
200
+ if ('reason' in t)
201
+ return { path, status: 'skipped', reason: t.reason };
202
+ const abs = join(root, path);
203
+ const content = Buffer.from(windsurfRule());
204
+ const hash = sha256(content);
205
+ const lock = readLock(root);
206
+ let status = 'written';
207
+ if (t.exists) {
208
+ const disk = readFileSync(abs);
209
+ const diskHash = sha256(disk);
210
+ if (diskHash === hash)
211
+ return { path, status: 'unchanged' };
212
+ const locked = lock.files[path];
213
+ if (locked !== undefined && diskHash !== locked && !opts.force)
214
+ return { path, status: 'skipped', reason: 'edited since last install (use --force to overwrite)' };
215
+ if (locked === undefined && !disk.toString('utf8').includes(MARKER) && !opts.force)
216
+ return { path, status: 'skipped', reason: 'authored file, not managed by bravos (use --force to overwrite)' };
217
+ status = 'updated';
218
+ }
219
+ if (!opts.dryRun) {
220
+ mkdirSync(dirname(abs), { recursive: true });
221
+ writeFileSync(abs, content);
222
+ writeLock(root, { ...lock, files: { ...lock.files, [path]: hash } });
223
+ }
224
+ return { path, status };
225
+ }
226
+ // @comment -- "Uninstall's part: takes the Bravos block out of each shared instruction file and keeps every other line; a file left holding nothing but blank space (Bravos created it) is deleted. The Windsurf rule is lock-recorded, so the lock pass removes it when unchanged. Links that leave the repository are not followed."
227
+ export function removeInstructionBlocks(root, opts = {}) {
228
+ const cleaned = [];
229
+ const deleted = [];
230
+ const seen = new Set();
231
+ for (const f of SHARED_FILES) {
232
+ const t = target(root, f.path);
233
+ if (!('exists' in t) || !t.exists)
234
+ continue;
235
+ const abs = join(root, f.path);
236
+ const real = realpathSync(abs);
237
+ if (seen.has(real))
238
+ continue;
239
+ seen.add(real);
240
+ const text = readFileSync(abs, 'utf8');
241
+ const next = removeBlock(text);
242
+ if (next === null)
243
+ continue;
244
+ if (next.trim() === '' && !lstatSync(abs).isSymbolicLink()) {
245
+ deleted.push(f.path);
246
+ if (!opts.dryRun)
247
+ unlinkSync(abs);
248
+ }
249
+ else {
250
+ cleaned.push(f.path);
251
+ if (!opts.dryRun)
252
+ writeFileSync(abs, next);
253
+ }
254
+ }
255
+ return { cleaned, deleted };
256
+ }
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/).