@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.
@@ -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
@@ -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
  }
@@ -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
@@ -2,6 +2,7 @@ import { existsSync, lstatSync, readFileSync, readdirSync, readlinkSync, rmdirSy
2
2
  import { dirname, join } from 'node:path';
3
3
  import { LOCK_PATH, readLock, sha256 } from './lock.js';
4
4
  import { removePrePush } from './context.js';
5
+ import { removeInstructionBlocks } from './instruction-blocks.js';
5
6
  import { BravosError } from './types.js';
6
7
  const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
7
8
  // Any command bravos registers: the per-repo relative forms and the user-level absolute one.
@@ -21,7 +22,7 @@ function readJson(root, rel) {
21
22
  throw new BravosError(`${rel} is not a JSON object; fix it or remove it, nothing was removed`);
22
23
  return parsed;
23
24
  }
24
- /** Removes bravos's commands from a Claude Code / Codex hooks file; returns the new document, or null when nothing changed. */
25
+ /** 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
26
  function stripHooks(doc) {
26
27
  if (!isObject(doc.hooks))
27
28
  return null;
@@ -33,6 +34,14 @@ function stripHooks(doc) {
33
34
  continue;
34
35
  }
35
36
  const kept = groups
37
+ .filter((g) => {
38
+ // Cursor lists { command } entries directly under the event.
39
+ if (isObject(g) && !Array.isArray(g.hooks) && isBravosCommand(g.command)) {
40
+ changed = true;
41
+ return false;
42
+ }
43
+ return true;
44
+ })
36
45
  .map((g) => {
37
46
  if (!isObject(g) || !Array.isArray(g.hooks))
38
47
  return g;
@@ -50,6 +59,9 @@ function stripHooks(doc) {
50
59
  const out = { ...doc, hooks };
51
60
  if (Object.keys(hooks).length === 0)
52
61
  delete out.hooks;
62
+ // A Cursor file left with nothing but its version number held only bravos's hook.
63
+ if (Object.keys(out).length === 1 && 'version' in out)
64
+ delete out.version;
53
65
  return out;
54
66
  }
55
67
  function writeOrDelete(root, rel, doc, dryRun) {
@@ -77,15 +89,15 @@ function pruneEmpty(root, rel) {
77
89
  dir = dirname(dir);
78
90
  }
79
91
  }
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."
92
+ // @comment -- "Removes what bravos installed under root: every file its lock records that is unchanged (edited ones are kept and listed unless --force), the Bravos block in the shared instruction files, 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
93
  export function uninstall(root, opts = {}) {
82
94
  const dryRun = !!opts.dryRun;
83
- const report = { removed: [], kept: [], unregistered: [], notes: [] };
95
+ const report = { removed: [], kept: [], unregistered: [], unblocked: [], notes: [] };
84
96
  if (!existsSync(join(root, '.bravos'))) {
85
97
  throw new BravosError(`bravos is not installed in ${root} (no .bravos/ folder); nothing was removed`);
86
98
  }
87
99
  // Validate every structured file first, so a malformed one stops the run before any removal.
88
- const hookFiles = ['.claude/settings.json', '.codex/hooks.json'];
100
+ const hookFiles = opts.home ? ['.claude/settings.json', '.codex/hooks.json'] : ['.claude/settings.json', '.codex/hooks.json', '.cursor/hooks.json'];
89
101
  const docs = new Map(hookFiles.map((f) => [f, readJson(root, f)]));
90
102
  const agy = opts.home ? null : readJson(root, '.agents/hooks.json');
91
103
  const glConfig = opts.home ? null : readJson(root, '.guardlink/config.json');
@@ -139,6 +151,12 @@ export function uninstall(root, opts = {}) {
139
151
  report.notes.push('run guardlink sync to drop the gate from the agent instruction files');
140
152
  }
141
153
  }
154
+ // @comment -- "The Bravos block comes out of the shared instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, Copilot's) and every other line stays; a file that held only the block is deleted. Windsurf's rule went with the lock pass above."
155
+ if (!opts.home) {
156
+ const b = removeInstructionBlocks(root, { dryRun });
157
+ report.unblocked.push(...b.cleaned);
158
+ report.removed.push(...b.deleted);
159
+ }
142
160
  if (opts.home) {
143
161
  const dir = join(root, '.agents', 'skills');
144
162
  let entries = [];
package/docs/GUIDE.md CHANGED
@@ -14,7 +14,9 @@ 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
+
19
+ 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.
18
20
 
19
21
  ### Running a skill
20
22
 
@@ -22,7 +24,7 @@ Claude Code and opencode: /bravos-ship. Codex: $bravos-ship. omp: /skill:bravos-
22
24
 
23
25
  ### Plans
24
26
 
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.
27
+ 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
28
 
27
29
  ### Effort
28
30
 
@@ -30,7 +32,7 @@ Every skill reads one dial: low, medium (default), high or max. Say it ("annotat
30
32
 
31
33
  ### Installing
32
34
 
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).
35
+ 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
36
 
35
37
  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
38
 
@@ -386,7 +388,11 @@ Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group tha
386
388
 
387
389
  ### Cursor
388
390
 
389
- .cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.
391
+ 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.
392
+
393
+ ### Agents without hooks
394
+
395
+ 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.
390
396
 
391
397
  ### VS Code (Copilot agent)
392
398
 
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,56 @@
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.19.0
6
+
7
+ - **Teammates without Bravos get an invitation instead of your setup.** The hooks travel with the repository. On a machine without Bravos (no `bravos` command, licence or plugin), they now show only an invitation, once per session:
8
+ - **What it shows:** the repository's own numbers from its committed threat model, what Bravos would do for that person, and the one command to join (Free, no account needed).
9
+ - **What runs for them:** nothing else. No briefing, coach, threat cards, pre-PR gate, autopilot or background work, and nothing is sent anywhere.
10
+ - **Their agent** offers setup once and runs it only if they say yes. "Not now" hides the invitation in that clone for 7 days (`node .bravos/hooks/invite.mjs snooze`, kept under `.git`).
11
+ - **To switch it off for the team:** add `{"invite": "off"}` to `.bravos/config.json`. CI always counts as having Bravos, so the nightly and PR workflows are unchanged.
12
+ - **Agents without hooks get Bravos too.** `bravos setup` keeps a short Bravos block in the instruction files agents read: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`, `.windsurf/rules/bravos.md` and the Cursor rule.
13
+ - The block tells an agent that got no Bravos briefing from a hook to run `node .bravos/hooks/session-start.mjs --briefing`. That prints the briefing, or the invitation on a machine without Bravos.
14
+ - Your own text in those files is kept, GuardLink's block is left alone, and `bravos uninstall` removes only Bravos's block.
15
+ - **Where the card shows now depends on the surface, not just the agent:**
16
+
17
+ | Agent | Where you see it |
18
+ |---|---|
19
+ | Claude Code in a terminal | the banner, at launch |
20
+ | Claude Code desktop app and IDE extensions | the agent's first reply opens with the card (before, a banner these surfaces don't draw) |
21
+ | omp | the banner, above the editor until your first prompt |
22
+ | Gemini | the banner, at session start |
23
+ | Codex | the card itself, shown as "↳ Hook ·" with your first message |
24
+ | Cursor, OpenCode, Antigravity | the agent's first reply opens with the card |
25
+ | Windsurf, Copilot and other agents without hooks | the agent runs the briefing from the repository's instruction files, then opens its reply with the card |
26
+ - **A Team trial warns in its last 5 days.** The banner says how many days are left and to ask your admin to keep Team.
27
+ - **To get it:** run `bravos setup` in each repository (it writes the instruction-file blocks), commit what it changes, then start a new session in each agent.
28
+
29
+ ## 1.18.0
30
+
31
+ - **Every agent now shows the same Bravos card,** through the best channel that agent has:
32
+
33
+ | Agent | Where you see it |
34
+ |---|---|
35
+ | Claude Code | the banner, at launch |
36
+ | omp | the banner, above the editor until your first prompt |
37
+ | Gemini | the banner, at session start |
38
+ | Codex | the card itself, shown as "↳ Hook ·" with your first message |
39
+ | Cursor | the agent's first reply opens with the card |
40
+ | OpenCode | the agent's first reply opens with the card |
41
+
42
+ 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.
43
+ - **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.
44
+ - **Cursor gets a session hook.** In a repository with a `.cursor/` folder, `bravos setup` adds a `sessionStart` entry to `.cursor/hooks.json`:
45
+ - It gives the agent the Bravos briefing.
46
+ - It keeps any hooks your team already has in that file.
47
+ - `--agent cursor` adds it to a repository without a `.cursor/` folder.
48
+ - `bravos doctor` lists it.
49
+ - `bravos uninstall` removes only Bravos's entry.
50
+ - **Bravos now installs GuardLink 2.7.1 and cert-x-gen 1.9.2.**
51
+ - **`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.
52
+ - **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.
53
+ - **To get it:** run `bravos setup` in each repository, then start a new session in each agent.
54
+
5
55
  ## 1.17.2
6
56
 
7
57
  - **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:
@@ -1,5 +1,6 @@
1
1
  // @comment -- "bravos autopilot Stop hook entry (Claude Code and Codex): reads the Stop payload from stdin with a bounded wait, resolves the repo as git's top level for the payload cwd, runs the end-of-turn check, and prints {} to allow or {decision:'block', reason} to send the agent back once, logging the nudge for bravos watch. Always exits 0; a failure allows."
2
2
  import { entitled, status as licenceStatus } from './lib/licence.mjs';
3
+ import { audience } from './lib/audience.mjs';
3
4
  import { resolveRoot } from './lib/pre-pr.mjs';
4
5
  import { logWatchEvent, runAutopilot } from './lib/autopilot.mjs';
5
6
 
@@ -22,7 +23,7 @@ async function readPayload() {
22
23
  async function main() {
23
24
  let out = {};
24
25
  // Autopilot is part of the pre-PR gate feature; without the licence the Stop hook answers nothing and the turn ends normally.
25
- if (!entitled(licenceStatus(process.env), 'pre-pr')) {
26
+ if (audience(process.env).kind === 'none' || !entitled(licenceStatus(process.env), 'pre-pr')) {
26
27
  process.stdout.write('{}\n');
27
28
  process.exit(0);
28
29
  }
package/hooks/cards.mjs CHANGED
@@ -5,6 +5,7 @@ import { spawnSync } from 'node:child_process';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { agentLine, decideCards, notify, readSeen, renderCard, targetRecorded, writeSeen } from './lib/cards.mjs';
7
7
  import { gitCommonDir, readPrefs } from './lib/prefs.mjs';
8
+ import { audience } from './lib/audience.mjs';
8
9
  import { logWatchEvent } from './lib/snapshot.mjs';
9
10
 
10
11
  async function readPayload() {
@@ -43,6 +44,8 @@ async function main() {
43
44
  let out = {};
44
45
  try {
45
46
  if (process.env.BRAVOS_THREAT_CARDS === 'off') throw new Error('off');
47
+ // A machine without Bravos gets only the session-start invitation: no threat cards.
48
+ if (audience(process.env).kind === 'none') throw new Error('off');
46
49
  const payload = await readPayload();
47
50
  const cwd = typeof payload.cwd === 'string' ? payload.cwd : process.env.CLAUDE_PROJECT_DIR || process.cwd();
48
51
  const top = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'] });
package/hooks/coach.mjs CHANGED
@@ -6,6 +6,7 @@ import { spawnSync } from 'node:child_process';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { coachTurn, newestModelChange, readCoach, writeCoach } from './lib/coach.mjs';
8
8
  import { gitCommonDir, readPrefs } from './lib/prefs.mjs';
9
+ import { audience } from './lib/audience.mjs';
9
10
  import { logWatchEvent } from './lib/snapshot.mjs';
10
11
  import { cliVersion, readUpdate, repoVersion } from './lib/update-check.mjs';
11
12
 
@@ -61,6 +62,8 @@ async function main() {
61
62
  let out = {};
62
63
  try {
63
64
  if (process.env.BRAVOS_COACH === 'off') throw new Error('off');
65
+ // A machine without Bravos gets only the session-start invitation: no coaching.
66
+ if (audience(process.env).kind === 'none') throw new Error('off');
64
67
  const payload = await readPayload();
65
68
  const cwd = typeof payload.cwd === 'string' ? payload.cwd : process.env.CLAUDE_PROJECT_DIR || process.cwd();
66
69
  const root = git(cwd, ['rev-parse', '--show-toplevel']) || cwd;
@@ -0,0 +1,10 @@
1
+ // @comment -- "The one thing a person without Bravos can ask of it: node .bravos/hooks/invite.mjs snooze hides the invitation in this clone for seven days. Their agent runs it when they say 'not now'. Writes only <git-common-dir>/bravos/invite.json; prints one line; always exits 0."
2
+ import { gitCommonDir } from './lib/prefs.mjs';
3
+ import { snoozeInvite } from './lib/audience.mjs';
4
+
5
+ const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
6
+ if (process.argv[2] === 'snooze') {
7
+ const file = snoozeInvite(gitCommonDir(root));
8
+ process.stdout.write(file ? 'Bravos invitation hidden in this clone for 7 days.\n' : 'Not a git repository: nothing recorded.\n');
9
+ } else process.stdout.write('usage: node .bravos/hooks/invite.mjs snooze\n');
10
+ process.exit(0);
@@ -0,0 +1,83 @@
1
+ // @comment -- "Who is in this session, for what the hooks show and do: a machine without Bravos (none: a teammate who cloned a repository that uses it), Free, a Team trial, a Team seat, or an expired licence. Installed means the Bravos CLI is on PATH, a licence is on this machine, or the Claude Code or Codex plugin is installed; a Bravos folder alone does not count, since older hooks wrote one for anyone. CI always counts as installed: Bravos's own workflows run the agents there. Read-only, dependency-free."
2
+ import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { cliVersion } from './update-check.mjs';
5
+ import { status as licenceStatus } from './licence.mjs';
6
+
7
+ const SNOOZE_DAYS = 7;
8
+
9
+ // @comment -- "True when the Claude Code or Codex plugin cache holds a Bravos plugin: someone installed it from a marketplace without the npm CLI."
10
+ function pluginInstalled(home) {
11
+ if (!home) return false;
12
+ for (const cache of [join(home, '.claude', 'plugins', 'cache'), join(home, '.codex', 'plugins', 'cache')]) {
13
+ let entries = [];
14
+ try {
15
+ entries = readdirSync(cache, { withFileTypes: true });
16
+ } catch {
17
+ continue;
18
+ }
19
+ for (const e of entries) {
20
+ if (!e.isDirectory()) continue;
21
+ if (/^bravos/i.test(e.name)) return true;
22
+ try {
23
+ if (readdirSync(join(cache, e.name)).some((n) => /^bravos/i.test(n))) return true;
24
+ } catch {
25
+ /* unreadable marketplace folder */
26
+ }
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+
32
+ // @comment -- "Whether this machine has Bravos: CI, the CLI on PATH, a licence, or a plugin install. BRAVOS_AUDIENCE=installed or none states it outright (tests, mirrors)."
33
+ export function bravosInstalled(env = process.env, licence = licenceStatus(env)) {
34
+ if (env.BRAVOS_AUDIENCE === 'installed') return true;
35
+ if (env.BRAVOS_AUDIENCE === 'none') return false;
36
+ if (env.CI || env.GITHUB_ACTIONS) return true;
37
+ if (cliVersion(env)) return true;
38
+ if (licence && licence.state && licence.state !== 'absent') return true;
39
+ return pluginInstalled(env.HOME);
40
+ }
41
+
42
+ // @comment -- "The audience: { kind: none | free | trial | team | expired, licence, daysLeft }. daysLeft is set for a trial."
43
+ export function audience(env = process.env, now = Math.floor(Date.now() / 1000)) {
44
+ const licence = licenceStatus(env);
45
+ if (!bravosInstalled(env, licence)) return { kind: 'none', licence };
46
+ if (licence.licensed) {
47
+ if (licence.trial) return { kind: 'trial', licence, daysLeft: Math.max(0, Math.ceil((Number(licence.trial.endsAt) - now) / 86400)) };
48
+ return { kind: 'team', licence };
49
+ }
50
+ if (licence.state === 'expired') return { kind: 'expired', licence };
51
+ return { kind: 'free', licence };
52
+ }
53
+
54
+ // @comment -- "Whether the invitation may show in this clone: the team can switch it off in the committed .bravos/config.json (\"invite\": \"off\"), and a person can snooze it for seven days (<git-common-dir>/bravos/invite.json, which no commit can write). BRAVOS_BANNER=off hides it as it hides the banner."
55
+ export function inviteAllowed(root, commonDir, env = process.env, now = Date.now()) {
56
+ if (env.BRAVOS_BANNER === 'off') return false;
57
+ try {
58
+ const cfg = JSON.parse(readFileSync(join(root, '.bravos', 'config.json'), 'utf8'));
59
+ if (cfg && cfg.invite === 'off') return false;
60
+ } catch {
61
+ /* no team setting: on */
62
+ }
63
+ if (!commonDir) return true;
64
+ try {
65
+ const j = JSON.parse(readFileSync(inviteFile(commonDir), 'utf8'));
66
+ const at = Date.parse(j?.snoozedAt);
67
+ if (j?.schema === 'bravos.invite/v1' && Number.isFinite(at) && at <= now + 60000 && now - at < SNOOZE_DAYS * 86400000) return false;
68
+ } catch {
69
+ /* never snoozed */
70
+ }
71
+ return true;
72
+ }
73
+
74
+ export const inviteFile = (commonDir) => join(commonDir, 'bravos', 'invite.json');
75
+
76
+ // @comment -- "Records that the person said 'not now' to the invitation, for seven days, in this clone's git directory. The agent runs it through hooks/invite.mjs, since a person without Bravos has no bravos command."
77
+ export function snoozeInvite(commonDir, now = new Date()) {
78
+ if (!commonDir) return null;
79
+ const file = inviteFile(commonDir);
80
+ mkdirSync(join(file, '..'), { recursive: true, mode: 0o700 });
81
+ writeFileSync(file, JSON.stringify({ schema: 'bravos.invite/v1', snoozedAt: now.toISOString() }) + '\n', { mode: 0o600 });
82
+ return file;
83
+ }
@@ -895,6 +895,11 @@ function bannerWarnings(i, plan) {
895
895
  if ((i.autopilot || i.prePr) && hooksLocked(i)) lines.push(`~ ${i.autopilot ? 'autopilot' : 'the pre-PR gate'} is set up here, on the Team plan for you · bravos account activate`);
896
896
  else if (plan && !plan.licensed && i.licence.state === 'expired') lines.push(`~ licence expired: ${TEAM_ADDS} locked · bravos licence`);
897
897
  else if (plan && !plan.licensed) lines.push(`~ Team adds ${TEAM_ADDS} · bravos account activate`);
898
+ // A trial in its last days says so, so keeping Team is the person's (or their admin's) decision, not a surprise.
899
+ else if (plan && i.licence?.trial) {
900
+ const left = Math.ceil((Number(i.licence.trial.endsAt) - Math.floor(Date.now() / 1000)) / 86400);
901
+ if (Number.isFinite(left) && left <= 5) lines.push(`~ Team trial ends in ${Math.max(0, left)} day${left === 1 ? '' : 's'}: ask your admin to keep Team · bravos licence`);
902
+ }
898
903
  if (i.stale) lines.push(`! Findings describe older code · ${i.stale.behind} behind ${clean(i.base)} · bravos-resync`);
899
904
  else if (arr(i.stranded).length > 0) lines.push(`~ Work on ${clean(i.stranded[0].branch)} is not on ${clean(i.base)} · bravos-resync`);
900
905
  if (i.shadow) {
@@ -1057,7 +1062,7 @@ export function buildSummary(inputs, opts = {}) {
1057
1062
  return `${head} · ${countsLine(i.guardlink ?? {})}\n${plan ? `plan ${plan.label} · ` : ''}intent ${i.intent?.status ?? 'unknown'} · skills: ${next}\n${third}${update}`;
1058
1063
  }
1059
1064
 
1060
- // @comment -- "The startup picture for a harness that shows the hook's summary only as a folded warning (Codex puts a hook's systemMessage behind F2 and has no field that prints to the transcript). 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; null on a resume or compact, or with BRAVOS_BANNER=off."
1065
+ // @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
1066
  export function statusCard(inputs, opts = {}) {
1062
1067
  // 68 columns leaves 64 for the layout: under the logo's 68, so the card is text only.
1063
1068
  const lines = buildBanner(inputs, { harness: opts.harness, version: opts.version, columns: 68 }).replace(/`/g, "'").split('\n');
@@ -1076,7 +1081,59 @@ export function statusCard(inputs, opts = {}) {
1076
1081
  export function firstReplyStatus(inputs, opts = {}) {
1077
1082
  const source = inputs?.source;
1078
1083
  if (source === 'resume' || source === 'compact' || opts.env?.BRAVOS_BANNER === 'off') return null;
1079
- return `Status for the person: this harness shows Bravos's startup banner only as a folded warning, so open your first reply with the card below, copied exactly, inside a text code block, then answer their message; never repeat it later in the session.\n\`\`\`text\n${statusCard(inputs, opts)}\n\`\`\``;
1084
+ 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\`\`\``;
1085
+ }
1086
+
1087
+ const INSTALL = 'npm install -g @bugb-technologies/bravos';
1088
+ const KNOWN_SEVERITY = ['critical', 'high', 'medium', 'low'];
1089
+
1090
+ // @comment -- "The repository's own numbers for the invitation, read from the committed GuardLink report (.guardlink/report.json), so a machine with no Bravos and no GuardLink still shows them: recorded threats by severity, confirmed exploits and annotated files. Null when there is no report or it cannot be read. Only counts and a cleaned project name leave the file."
1091
+ export function readCommittedReport(root) {
1092
+ try {
1093
+ const j = JSON.parse(readFileSync(join(root, '.guardlink', 'report.json'), 'utf8'));
1094
+ const exposures = Array.isArray(j?.exposures) ? j.exposures : [];
1095
+ const by = Object.fromEntries(KNOWN_SEVERITY.map((k) => [k, exposures.filter((e) => e?.severity === k).length]));
1096
+ const files = (v) => (Array.isArray(v) ? v.length : Number.isFinite(v) ? v : null);
1097
+ return {
1098
+ project: typeof j?.project === 'string' ? clean(j.project).trim().slice(0, 40) : null,
1099
+ threats: exposures.length,
1100
+ by,
1101
+ confirmed: Array.isArray(j?.confirmed) ? j.confirmed.length : 0,
1102
+ annotated: files(j?.annotated_files),
1103
+ source: files(j?.source_files),
1104
+ };
1105
+ } catch {
1106
+ return null;
1107
+ }
1108
+ }
1109
+
1110
+ // @comment -- "The invitation a person without Bravos sees, in the card's plain 64-column style: that their team protects this repository with Bravos, the repository's real numbers when a report is committed, what Bravos would do for them, and the one command that sets it up (Free, no account). Nothing in it comes from the repository but counts and a cleaned name."
1111
+ export function inviteCard(root) {
1112
+ const r = readCommittedReport(root);
1113
+ const name = r?.project || clean(basename(root)).trim().slice(0, 40) || 'this repository';
1114
+ const rows = ['BRAVOS by bugb · your team protects this repository'];
1115
+ if (r && r.threats > 0) {
1116
+ const sev = KNOWN_SEVERITY.filter((k) => r.by[k] > 0).map((k) => `${r.by[k]} ${k}`).join(' · ');
1117
+ rows.push(clipped(`${name}: ${r.threats} threats recorded${sev ? ` · ${sev}` : ''}`, 64));
1118
+ const cover = r.annotated !== null && r.source ? `${r.annotated} / ${r.source} files annotated · ` : '';
1119
+ rows.push(`${cover}${r.confirmed} confirmed exploitable`);
1120
+ } else rows.push(clipped(`${name} keeps a security threat model with Bravos`, 64));
1121
+ const rule = '─'.repeat(64);
1122
+ rows.push(rule, 'With Bravos, your coding agent:', ' · knows these threats before it edits the code', ' · checks each pull request for new exposure', ' · proves which threats are real, on your own machine', rule);
1123
+ rows.push(`Join your team: ${INSTALL}`, ' then: bravos setup', 'Free, no account needed. Say "not now" to hide this for 7 days.');
1124
+ return rows.map((l) => l.replace(/`/g, "'")).join('\n');
1125
+ }
1126
+
1127
+ // @comment -- "What the agent of a person without Bravos is told: no security briefing, threat cards or checks run on this machine; show the invitation once (in the first reply, unless the person already saw it on screen); offer setup once and run it only on a yes; on 'not now', snooze it with node .bravos/hooks/invite.mjs snooze and say no more; never let it delay or block their request."
1128
+ export function inviteBriefing(card, { shownOnScreen = false } = {}) {
1129
+ const show = shownOnScreen
1130
+ ? 'The person has already seen the Bravos invitation on screen; do not repeat it.'
1131
+ : `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${card}\n\`\`\``;
1132
+ return [
1133
+ 'Bravos: this repository uses Bravos (security workflow for coding agents), but this machine does not have it installed, so no security briefing, threat cards or checks run here.',
1134
+ show,
1135
+ `After answering, offer once, in one sentence, to set Bravos up so this person gets what their team has: \`${INSTALL}\`, then \`bravos setup\` in this repository. Run them only if the person says yes. If they say no or not now, run \`node .bravos/hooks/invite.mjs snooze\` (it hides the invitation in this clone for 7 days) and do not mention Bravos again this session. Never let this delay or block what they asked for.`,
1136
+ ].join('\n');
1080
1137
  }
1081
1138
 
1082
1139
  // Brand palette by theme (hooks/lib/palette.mjs). Colour is truecolor ANSI, added after
@@ -0,0 +1,11 @@
1
+ // @comment -- "Where the person sees Bravos's startup picture, per agent and surface. The agent's own reply is the one channel every surface shows, so anything not known to draw a hook's message natively gets the card in the agent's first reply. banner: the hook's systemMessage holds the banner (the Claude Code CLI in a terminal, Gemini CLI); hook-card: the hook's systemMessage holds the card, drawn inline with the first prompt (Codex); reply: the agent opens its first reply with the card (Claude Code's desktop app, IDE extensions and SDK, Cursor, Antigravity). A run with no known harness (a manual run, an unknown host) keeps the banner, as before. Pure."
2
+ export function displayMode(harness, env = process.env) {
3
+ if (harness === 'claude') {
4
+ // Claude Code says where it runs; an older CLI that does not say is the terminal.
5
+ const entry = String(env.CLAUDE_CODE_ENTRYPOINT ?? '');
6
+ return entry === '' || entry === 'cli' ? 'banner' : 'reply';
7
+ }
8
+ if (harness === 'codex') return 'hook-card';
9
+ if (harness === 'gemini' || harness === 'other') return 'banner';
10
+ return 'reply';
11
+ }
@@ -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
  }
package/hooks/pre-pr.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // @comment -- "bravos's pre-PR gate entry, two ways. As the opt-in PreToolUse hook it reads the hook payload from stdin, gates only Bash commands that run gh pr create or gh pr ready, and exits 2 with the reason on stderr to block; every other command, unparseable input and BRAVOS_PRE_PR=off exit 0. Run by hand (--check, or no stdin / a TTY) it gates the current branch before any PR exists: exit 2 on lint errors, a confirmed claim on a changed file without a @ticket, or an input that fails; new exposures are printed to disclose, not blocked on. The repo root is git's top level for the working directory, never the payload cwd as given."
2
2
  import { entitled, refusal, status as licenceStatus } from './lib/licence.mjs';
3
+ import { audience } from './lib/audience.mjs';
3
4
  import { prAction, resolveRoot, runGate } from './lib/pre-pr.mjs';
4
5
 
5
6
  async function readStdin() {
@@ -21,6 +22,8 @@ function finish({ decision, reason }, check) {
21
22
  async function main() {
22
23
  const env = process.env;
23
24
  if (env.BRAVOS_PRE_PR === 'off') process.exit(0);
25
+ // A machine without Bravos: the gate is the team's Bravos feature, not this person's; say nothing and block nothing.
26
+ if (audience(env).kind === 'none') process.exit(0);
24
27
  // Without a Team licence the gate stands down: one line on stderr (never a block), so a teammate
25
28
  // without a seat still opens their PR and knows why nothing was checked.
26
29
  const lic = licenceStatus(env);