@bugb-technologies/bravos 1.16.1 → 1.17.2

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/dist/setup.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // @comment -- "bravos setup: puts the binaries bravos drives onto this machine. The analyzer and the code graph are licensed bundles fetched through the account portal (artifacts.ts); guardlink and cxg are free CLIs installed with their own package managers. --check reports without changing anything, --dry-run says what would run, and nothing is fetched or installed without a licence for it. Also the SAST runner: `bravos sast run` invokes the staged analyzer with the argv the Python CLI used and writes the run folder the briefing and `bravos sast` read."
2
2
  import { checkProofTool, formatProofTool } from './proof-tools.js';
3
3
  import { spawnSync } from 'node:child_process';
4
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
5
5
  import { isAbsolute, join } from 'node:path';
6
6
  import { bundleEnvironment, hostTarget, install, missingPaths, olderThan, staged, stagedVersion, VERSIONS } from './artifacts.js';
7
- import { graphBin, graphEnv } from './codegraph.js';
7
+ import { graphBin, graphEnv, graphStore } from './codegraph.js';
8
8
  import { whichBin } from './guardlink.js';
9
9
  import { findAnalyzer } from './graphbin.js';
10
10
  import { licenceLib, requireFeature } from './licence.js';
@@ -135,7 +135,43 @@ export function selfTest(kind, dir, env) {
135
135
  }
136
136
  return out;
137
137
  }
138
- // @comment -- "Runs the analyzer the way the Python adapter did: bravos-cli analyze ROOT --ci --fail-on never --allow-incomplete-analysis --codegraph <reuse when a graph store exists> --scip off -f json,sarif -o .bravos/sast/<run>/report, under the bundle's environment, then writes meta.json (sha, exit, at) so the briefing's SAST line and bravos sast candidates read it. The exit code is a health signal; findings are read from the report."
138
+ // @comment -- "Whether this process can create entries in dir: makes and removes one empty probe folder. False for a missing folder or one a sandbox (Codex's workspace-write, Seatbelt) refuses, which a mode-bit check would not see."
139
+ function canWriteIn(dir) {
140
+ if (!dir)
141
+ return false;
142
+ try {
143
+ rmSync(mkdtempSync(join(dir, '.bravos-write-probe-')), { recursive: true, force: true });
144
+ return true;
145
+ }
146
+ catch {
147
+ return false;
148
+ }
149
+ }
150
+ // @comment -- "Where a SAST run keeps its caches, all inside the repository under .bravos/sast/cache/ (owner-only, gitignored), so the run works in a sandbox that allows writes only in the workspace: the analyzer's scan workspace (--workspace), Semgrep's settings, log and version cache (SEMGREP_SETTINGS_FILE, SEMGREP_LOG_FILE, SEMGREP_VERSION_CACHE_PATH, unless set), and, when the shared code-graph store cannot be written, the analyzer's own graph store (BRAVOS_CODEGRAPH_DIR), which holds the extraction cache the analyzer writes even when it only reads a graph. The shared store stays in use while it is writable, so the analyzer keeps reading the graph bravos graph build wrote; a BRAVOS_CODEGRAPH_DIR the caller set is always used as given."
151
+ export function sastCache(root, env) {
152
+ const dir = join(root, '.bravos', 'sast', 'cache');
153
+ const workspace = join(dir, 'workspace');
154
+ const semgrep = join(dir, 'semgrep');
155
+ for (const d of [dir, workspace, semgrep])
156
+ mkdirSync(d, { recursive: true, mode: 0o700 });
157
+ const out = {};
158
+ const set = (k, v) => {
159
+ if (!env[k])
160
+ out[k] = v;
161
+ };
162
+ set('SEMGREP_SETTINGS_FILE', join(semgrep, 'settings.yml'));
163
+ set('SEMGREP_LOG_FILE', join(semgrep, 'semgrep.log'));
164
+ set('SEMGREP_VERSION_CACHE_PATH', join(semgrep, 'semgrep_version'));
165
+ const sharedStore = env.BRAVOS_CODEGRAPH_DIR ? null : graphStore(env);
166
+ const ownGraph = !env.BRAVOS_CODEGRAPH_DIR && !canWriteIn(sharedStore);
167
+ if (ownGraph) {
168
+ const store = join(dir, 'codegraph');
169
+ mkdirSync(store, { recursive: true, mode: 0o700 });
170
+ out.BRAVOS_CODEGRAPH_DIR = store;
171
+ }
172
+ return { dir, workspace, env: out, ownGraph, sharedStore };
173
+ }
174
+ // @comment -- "Runs the analyzer the way the Python adapter did: bravos-cli analyze ROOT --ci --fail-on never --allow-incomplete-analysis --codegraph <reuse when a graph store exists, auto when it keeps its own> --scip off --workspace .bravos/sast/cache/workspace -f json,sarif -o .bravos/sast/<run>/report, under the bundle's environment with its caches in the repository (sastCache), then writes meta.json (sha, exit, at, cache, graphStore) so the briefing's SAST line and bravos sast candidates read it. The exit code is a health signal; findings are read from the report."
139
175
  export async function runSast(root, env, opts = {}) {
140
176
  const licence = await requireFeature(env, 'sast', 'bravos sast run');
141
177
  const dir = staged(env, 'analyzer');
@@ -155,9 +191,11 @@ export async function runSast(root, env, opts = {}) {
155
191
  const runDir = join(base, run);
156
192
  mkdirSync(runDir, { recursive: true });
157
193
  const sha = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', timeout: 5000 }).stdout?.trim() || null;
158
- let codegraph = opts.codegraph ?? (graphBin('codegraph-mcp', env) ? 'reuse' : 'off');
194
+ const cache = sastCache(root, env);
195
+ // @comment -- "A graph store of the analyzer's own starts empty, so reuse would refuse every first run: let the analyzer build the graph there (auto) unless the caller chose a mode."
196
+ let codegraph = opts.codegraph ?? (cache.ownGraph ? 'auto' : graphBin('codegraph-mcp', env) ? 'reuse' : 'off');
159
197
  const argvFor = (graph) => {
160
- const a = ['analyze', root, '--ci', '--fail-on', 'never', '--allow-incomplete-analysis', '--codegraph', graph, '--scip', opts.scip ?? 'off', '-f', 'json,sarif', '-o', join(runDir, 'report')];
198
+ const a = ['analyze', root, '--ci', '--fail-on', 'never', '--allow-incomplete-analysis', '--codegraph', graph, '--scip', opts.scip ?? 'off', '--workspace', cache.workspace, '-f', 'json,sarif', '-o', join(runDir, 'report')];
161
199
  if (opts.scope?.length)
162
200
  a.push('--scope', opts.scope.join(','));
163
201
  // @comment -- ".bravos/ is always excluded: it holds the hooks bravos setup copied into the repository and the SAST runs themselves, which are bravos's code, not the customer's, and would otherwise surface as findings 'not in the threat model'."
@@ -168,22 +206,24 @@ export async function runSast(root, env, opts = {}) {
168
206
  a.push('--timeout', String(Math.max(1, opts.timeoutS - 1)));
169
207
  return a;
170
208
  };
171
- // @comment -- "The analyzer reads the code graph from the same store bravos graph build writes to, so it runs with BRAVOS_CODEGRAPH_DIR set (graphEnv): without it, --codegraph reuse looks in the analyzer's own default store and finds no graph even when one was just built."
172
- const baseEnv = graphEnv(env);
209
+ // @comment -- "The analyzer reads the code graph from the same store bravos graph build writes to, so it runs with BRAVOS_CODEGRAPH_DIR set (graphEnv): without it, --codegraph reuse looks in the analyzer's own default store and finds no graph even when one was just built. sastCache's variables go on top: the in-repository caches, and an in-repository store only when the shared one cannot be written."
210
+ const baseEnv = { ...graphEnv(env), ...cache.env };
173
211
  // @comment -- "The analyzer looks for its licence only in $BRAVOS_HOME or $BRAVOS_LICENCE, while bravos also falls back to ~/.bravos and ~/.bugb. Hand it the licence file bravos found (the path, never the token), so a SAST run never refuses a licence bravos accepted."
174
212
  if (!env.BRAVOS_LICENCE && !env.BRAVOS_LICENSE && isAbsolute(licence.source) && existsSync(licence.source))
175
213
  baseEnv.BRAVOS_LICENCE = licence.source;
176
214
  const runEnv = dir ? bundleEnvironment(dir, baseEnv) : baseEnv;
177
215
  const spawn = (graph) => spawnSync(bin, argvFor(graph), { cwd: root, env: runEnv, encoding: 'utf8', timeout: (opts.timeoutS ?? 1800) * 1000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
178
- let r = spawn(codegraph);
179
216
  const notes = [];
217
+ if (cache.ownGraph)
218
+ notes.push(` ${cache.sharedStore ? `the shared code-graph store ${cache.sharedStore} is not writable here (a sandbox that allows writes only in the workspace?)` : 'there is no shared code-graph store'}, so the analyzer kept its graph in ${cache.env.BRAVOS_CODEGRAPH_DIR}`);
219
+ let r = spawn(codegraph);
180
220
  // No graph built for this commit yet: reuse refuses outright. Scan without reachability rather than fail, and say how to get it.
181
221
  if (codegraph === 'reuse' && r.status === 3 && /CodeGraph unavailable|No CodeGraph/i.test(`${r.stdout}\n${r.stderr}`)) {
182
222
  notes.push(' no code graph for this commit yet, so the scan ran without reachability; bravos graph build . --scip no-exec first, then bravos sast run again, to see which findings are reached');
183
223
  codegraph = 'off';
184
224
  r = spawn(codegraph);
185
225
  }
186
- writeFileSync(join(runDir, 'meta.json'), JSON.stringify({ sha, base: null, scope: opts.scope?.length ? opts.scope.join(',') : 'all', exit: r.status, at: new Date().toISOString(), analyzer: bin, codegraph }, null, 2) + '\n');
226
+ writeFileSync(join(runDir, 'meta.json'), JSON.stringify({ sha, base: null, scope: opts.scope?.length ? opts.scope.join(',') : 'all', exit: r.status, at: new Date().toISOString(), analyzer: bin, codegraph, cache: cache.dir, graphStore: runEnv.BRAVOS_CODEGRAPH_DIR ?? null }, null, 2) + '\n');
187
227
  const lines = [`SAST run ${run}: bravos-cli exited ${r.status ?? 'by signal'} (0 clean at the level, 1 findings, 3 licence refused or analysis failed, 4 a stage failed)`, ` report: ${join(runDir, 'report.json')}`, ...notes];
188
228
  // @comment -- "Keep analyzer diagnostics in the gitignored run folder with owner-only permissions, including warnings on exit 0/1. Failure summaries show both ends so trailing progress cannot hide the cause; spawn errors have no stderr."
189
229
  if (r.stderr) {
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,37 @@
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.17.2
6
+
7
+ - **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:
8
+ - the findings and how many claims are untested;
9
+ - the top threats;
10
+ - each setup step's state, and the next step.
11
+
12
+ It still appears once per new Codex session, not on resume or compact, and not with `BRAVOS_BANNER=off`.
13
+ - **`bravos sast run` works inside Codex's sandbox.** Before, it failed with "extraction cache I/O failed: Operation not permitted" until you granted Full Access, because the analyzer wrote its caches outside the repository. It now keeps them in `.bravos/sast/cache/`, which is ignored by git.
14
+ - **The shared code graph is still used when it can be written to.** Inside a sandbox, the scan builds its own copy in that folder and says so in one line.
15
+ - **Any `BRAVOS_CODEGRAPH_DIR` or Semgrep path you set yourself is respected.**
16
+ - **To get both:** run `bravos setup` in each repository.
17
+
18
+ ## 1.17.1
19
+
20
+ - **Codex now shows you the Bravos status.** Codex folds a hook's message into its warnings ("⚠ warnings · f2 to view"), and a hook cannot print to the Codex transcript, so the startup summary was easy to miss.
21
+ - **The agent opens its first reply in a new Codex session with one status line:** open findings by severity, confirmed and untested claims, coverage, the setup score and the next step.
22
+ - **It appears once,** not on resume or compact, and not when `BRAVOS_BANNER=off` is set.
23
+ - **The three-line summary is still behind F2,** and other harnesses are unchanged.
24
+ - **To get it:** run `bravos setup` in each repository, then start a new Codex session.
25
+
26
+ ## 1.17.0
27
+
28
+ - **The session banner shows more of what Bravos knows.**
29
+ - **Untested claims are counted.** Beside the confirmed count it says how many recorded claims are still untested (and how many were refuted or are due a retest), so "0 confirmed" no longer reads as "checked and clean". The count covers every claim, open or with a control, so it can be larger than the open count. While anything is untested it offers "Prove the top 3".
30
+ - **Every setup step shows its state:** intent, code graph, pre-PR, autopilot, CI, SAST, proving and test target.
31
+ - **A drafted intent says how much is waiting for you** ("Intent draft (24 to review)"), and its next step is now `bravos review intent`, the page where you confirm or correct the draft, instead of drafting it again.
32
+ - **On a wide terminal it also shows the step after next.** A step too long for its column breaks before the arrow, so a command is never split.
33
+ - **One more quick guardlink call at session start** (`guardlink hypothesis list`), run alongside the others. If it fails, the count is left out and nothing else changes.
34
+ - **To see it:** run `bravos setup` in each repository, then start a new session.
35
+
5
36
  ## 1.16.1
6
37
 
7
38
  - **The workflows Bravos installs are hardened.** This covers the PR gate, the Claude, Codex and Copilot nightlies, and Copilot's setup steps. These are the same issues a SAST scan reports against them:
@@ -537,6 +537,9 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
537
537
  run('ci', ['ci', '-f', 'json']),
538
538
  run('hypothesis next', ['hypothesis', 'next', '--json', '-n', String(nextCount)]),
539
539
  run('lookup tickets', ['lookup', 'tickets']),
540
+ // Every claim's tested state (untested, confirmed, refuted, retest), for the banner's counts. Optional: a guardlink
541
+ // without it, or a failed run, leaves the counts out and records no error.
542
+ run('hypothesis list', ['hypothesis', 'list', '--json']),
540
543
  ];
541
544
  const prRun = runJsonAsync('gh', ['pr', 'list', '--state', 'open', '--json', 'number,files', '--limit', '50'], {
542
545
  cwd: root,
@@ -561,7 +564,8 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
561
564
  errors.push(r.error.replace(/^guardlink/, `guardlink ${label}`));
562
565
  return null;
563
566
  };
564
- guardlink = { ci: val(gl[0]), next: val(gl[1]), tickets: val(gl[2]), unannotated: null };
567
+ const states = gl[3]?.r?.ok ? gl[3].r.json?.summary : null;
568
+ guardlink = { ci: val(gl[0]), next: val(gl[1]), tickets: val(gl[2]), unannotated: null, states: states && typeof states === 'object' ? states : null };
565
569
  }
566
570
 
567
571
  let inFlight = null;
@@ -838,6 +842,22 @@ function bannerMetrics(g) {
838
842
  };
839
843
  }
840
844
 
845
+ // @comment -- "How many recorded claims (open or mitigated, so it can exceed the open count) have been tested, from guardlink's hypothesis ledger: 'N claims untested', plus refuted and retest counts when there are any. Without the ledger's summary it falls back to hypothesis next's total ('N to test'); with neither it says nothing rather than guess."
846
+ function testedStates(g) {
847
+ const s = g?.states;
848
+ if (s && typeof s === 'object') {
849
+ const parts = [`${num(s.untested)} claims untested`];
850
+ if (num(s.refuted) > 0) parts.push(`${num(s.refuted)} refuted`);
851
+ if (num(s.retest) > 0) parts.push(`${num(s.retest)} to retest`);
852
+ return parts.join(' · ');
853
+ }
854
+ return typeof g?.next?.total === 'number' ? `${g.next.total} to test` : null;
855
+ }
856
+ function untestedCount(g) {
857
+ if (g?.states && typeof g.states === 'object') return num(g.states.untested) + num(g.states.retest);
858
+ return typeof g?.next?.total === 'number' ? g.next.total : 0;
859
+ }
860
+
841
861
  function countsLine(g) {
842
862
  const m = bannerMetrics(g);
843
863
  if (!m) return 'threat counts unknown (guardlink ci unavailable)';
@@ -904,7 +924,7 @@ function wrap(text, width) {
904
924
  return rows;
905
925
  }
906
926
 
907
- // @comment -- "Renders the human's session briefing from collected facts. The supplied symbol and repo facts share the header; on wide terminals the real setup checklist sits beside confirmed findings. Known-free plans get free commands; missing CI counts and stale checkouts are identified before showing findings. Commands follow the harness syntax and untrusted repo text is cleaned before applying terminal colours."
927
+ // @comment -- "Renders the human's session briefing from collected facts. The supplied symbol and repo facts share the header; on wide terminals the real setup checklist sits beside confirmed findings. The findings side says how many claims are untested, refuted or due a retest (from the hypothesis ledger) and offers to prove the top 3; the setup side shows each capability's state (intent with how many drafted items await review, graph, hooks, CI, SAST, proving, target), the next step and, when wide, the one after it, breaking a long step before its arrow so a command is never split. Known-free plans get free commands; missing CI counts and stale checkouts are identified before showing findings. Commands follow the harness syntax and untrusted repo text is cleaned before applying terminal colours."
908
928
  export function buildBanner(inputs, opts = {}) {
909
929
  const i = inputs ?? {};
910
930
  const harness = opts.harness ?? i.harness ?? 'other';
@@ -949,13 +969,17 @@ export function buildBanner(inputs, opts = {}) {
949
969
  findings.push(threat + ' ' + clipped(file, leftWidth - cells(threat) - cells(locator) - 2) + locator);
950
970
  }
951
971
  } else if (g.ci) {
952
- findings.push('0 CONFIRMED FINDINGS · Top threats');
972
+ const states = testedStates(g);
973
+ if (states) findings.push(`0 CONFIRMED FINDINGS · ${states}`, 'Top threats');
974
+ else findings.push('0 CONFIRMED FINDINGS · Top threats');
953
975
  const top = topThreats(g.ci.exposures);
954
976
  for (const t of top) {
955
977
  const tail = ' ×' + t.count;
956
978
  findings.push(t.severity.padEnd(9) + clipped(t.threat, leftWidth - 9 - cells(tail)) + tail);
957
979
  }
958
980
  if (!top.length) findings.push('none open');
981
+ // Untested claims and nothing confirmed yet: the step that turns them into evidence.
982
+ if (top.length && untestedCount(g) > 0 && !hooksLocked(i)) findings.push('Prove the top 3 ' + sk('bravos-prove'));
959
983
  } else findings.push('Findings unavailable', 'threat counts unknown (guardlink ci unavailable)');
960
984
  const allFindings = 'All findings bravos dashboard';
961
985
  if (confirmed.length && !wide && width >= 72) {
@@ -970,12 +994,25 @@ export function buildBanner(inputs, opts = {}) {
970
994
  const hook = (on) => !on ? 'off' : hooksLocked(i) ? 'locked' : 'on';
971
995
  const sast = i.sast?.summary ? `SAST ${i.sast.summary.reachable} reachable` : i.sast?.available?.ok ? 'SAST has not run' : 'SAST off';
972
996
  const score = setup ? `SETUP ${setup.done}/${setup.total}` : 'SETUP';
973
- const intentGraph = `Intent ${i.intent?.status ?? 'unknown'} · Code graph ${graph}`;
974
- const hooks = `Pre-PR ${hook(i.prePr)} · Autopilot ${hook(i.autopilot)}`;
975
- const checks = wide ? [score, intentGraph, hooks, sast] : [score + ' · ' + intentGraph, hooks + ' · ' + sast];
997
+ // A draft says how much of it is waiting on a person, so "confirm" never reads as "do it again".
998
+ const intentState = i.intent?.status === 'draft' && num(i.intent.drafts) > 0 ? `draft (${num(i.intent.drafts)} to review)` : i.intent?.status ?? 'unknown';
999
+ const intentGraph = `Intent ${intentState} · Code graph ${graph}`;
1000
+ const on = (id) => setup?.items.find((x) => x.id === id)?.on;
1001
+ const hooks = `Pre-PR ${hook(i.prePr)} · Autopilot ${hook(i.autopilot)}` + (setup ? ` · CI ${on('ci') ? 'on' : 'off'}` : '');
1002
+ const proving = i.proving?.status === 'set' ? `Proving ${clean(i.proving.choice)}` : 'Proving not set';
1003
+ const testing = setup ? `${sast} · ${proving} · Target ${on('target') ? 'set' : 'none'}` : sast;
1004
+ const checks = wide ? [score, intentGraph, hooks, testing] : [score + ' · ' + intentGraph, hooks, testing];
1005
+ // A step that does not fit on one row breaks before its arrow, so the command is never split across rows.
1006
+ const stepRows = (head, cta) => {
1007
+ const one = `${head} → ${cta}`;
1008
+ return cells(clean(one)) <= rightWidth ? [one] : [...wrap(head, rightWidth), ...wrap(` → ${cta}`, rightWidth)];
1009
+ };
976
1010
  if (setup?.next) {
977
1011
  const step = setup.next;
978
- checks.push(...wrap(step.paid ? 'Next: activate Team → bravos account activate' : `Next: ${step.label} → ${step.cta}`, rightWidth));
1012
+ checks.push(...(step.paid ? stepRows('Next: activate Team', 'bravos account activate') : stepRows(`Next: ${step.label}`, step.cta)));
1013
+ // On a wide terminal the step after it too, so the two that are left are both in view.
1014
+ const then = wide ? setup.items.find((x) => !x.on && !x.paid && x !== step) : null;
1015
+ if (then) checks.push(...stepRows(`Then: ${then.label}`, then.cta));
979
1016
  } else if (!setup) checks.push(...wrap('Tip: ' + TIPS[(opts.day ?? dayNumber()) % TIPS.length], rightWidth));
980
1017
  else checks.push('All setup steps complete');
981
1018
  const further = 'Further setup bravos next';
@@ -1020,6 +1057,28 @@ export function buildSummary(inputs, opts = {}) {
1020
1057
  return `${head} · ${countsLine(i.guardlink ?? {})}\n${plan ? `plan ${plan.label} · ` : ''}intent ${i.intent?.status ?? 'unknown'} · skills: ${next}\n${third}${update}`;
1021
1058
  }
1022
1059
 
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."
1061
+ export function statusCard(inputs, opts = {}) {
1062
+ // 68 columns leaves 64 for the layout: under the logo's 68, so the card is text only.
1063
+ const lines = buildBanner(inputs, { harness: opts.harness, version: opts.version, columns: 68 }).replace(/`/g, "'").split('\n');
1064
+ // The narrow header gives each fact its own row; in a reply, pack them into as few rows of 64 as fit.
1065
+ const end = lines.findIndex((l, n) => n > 1 && /^[!~─]/.test(l));
1066
+ if (lines[0] !== 'BRAVOS' || lines[1] !== 'by bugb' || end < 2) return lines.join('\n');
1067
+ const rows = ['BRAVOS by bugb'];
1068
+ for (const fact of lines.slice(2, end)) {
1069
+ const joined = rows.at(-1) + (rows.length === 1 ? ' · ' : ' · ') + fact;
1070
+ if (cells(joined) <= 64) rows[rows.length - 1] = joined;
1071
+ else rows.push(fact);
1072
+ }
1073
+ return [...rows, ...lines.slice(end)].join('\n');
1074
+ }
1075
+
1076
+ export function firstReplyStatus(inputs, opts = {}) {
1077
+ const source = inputs?.source;
1078
+ 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\`\`\``;
1080
+ }
1081
+
1023
1082
  // Brand palette by theme (hooks/lib/palette.mjs). Colour is truecolor ANSI, added after
1024
1083
  // layout so widths are measured on plain text. A null colour is the terminal's own
1025
1084
  // foreground, so it is readable on whatever background the terminal has.
@@ -1032,7 +1091,7 @@ export const paint = (text, hex, bold = false) => (hex || bold ? `${bold ? '\x1b
1032
1091
  export function colorize(lines, _inputs = {}, theme = 'dark') {
1033
1092
  const p = THEMES[theme] ?? THEMES.neutral;
1034
1093
  // One pass over plain text; never run another replacement over terminal escapes.
1035
- const token = /[█▄▀]+(?: +[█▄▀]+)*|[╗╔╝╚═║]+(?: +[╗╔╝╚═║]+)*|[─│]+|\b\d+ CONFIRMED FINDINGS?\b|#[-\w]+|\b(?:\d+ )?(?:critical|high)\b|\b\d+% annotation coverage|\bSETUP\b|\bBRAVOS\b|by bugb|(?:\/skill:|\/|\$)?bravos-[\w-]+|\bbravos (?:dashboard|next|guide|doctor|sync|account activate|licence)\b/g;
1094
+ const token = /[█▄▀]+(?: +[█▄▀]+)*|[╗╔╝╚═║]+(?: +[╗╔╝╚═║]+)*|[─│]+|\b\d+ CONFIRMED FINDINGS?\b|#[-\w]+|\b(?:\d+ )?(?:critical|high)\b|\b\d+% annotation coverage|\bSETUP\b|\bBRAVOS\b|by bugb|(?:\/skill:|\/|\$)?bravos-[\w-]+|\bbravos (?:dashboard|next|guide|doctor|sync|account activate|licence|review intent)\b/g;
1036
1095
  return lines.map((line) => {
1037
1096
  if (/^! /.test(line)) return paint(line, p.red, true);
1038
1097
  if (/^~ /.test(line)) return paint(line, p.steel);
@@ -16,9 +16,10 @@ export function hooksLocked(i) {
16
16
  return i?.licence?.licensed === false;
17
17
  }
18
18
 
19
- // @comment -- "Builds the nine setup items in dependency order: the code graph first (a machine step every later skill reads), then intent (people), coverage (annotate reads intent and the graph), SAST (reads the annotations), how findings are proven and a test target (needed to test), then the gates (autopilot, pre-PR, CI). Each has its done-state, what it unlocks and how, with skills in the harness syntax. bravos assumes a licensed bravos-cli, so a missing one is a to-do, not 'not available'."
19
+ // @comment -- "Builds the nine setup items in dependency order: the code graph first (a machine step every later skill reads), then intent (people), coverage (annotate reads intent and the graph), SAST (reads the annotations), how findings are proven and a test target (needed to test), then the gates (autopilot, pre-PR, CI). Each has its done-state, what it unlocks and how, with skills in the harness syntax. A drafted intent whose questions are on disk is sent to the intake page (bravos review intent), since only a person can confirm it. bravos assumes a licensed bravos-cli, so a missing one is a to-do, not 'not available'."
20
20
  export function readSetup(root, i = {}, harness = 'other') {
21
21
  const coverage = Number(i.guardlink?.ci?.summary?.coverage?.percent);
22
+ const reviewable = i.intent?.status === 'draft' && existsSync(join(root, '.guardlink', 'intent-draft.json'));
22
23
  const items = [
23
24
  {
24
25
  id: 'graph',
@@ -35,9 +36,13 @@ export function readSetup(root, i = {}, harness = 'other') {
35
36
  // pass the gate (older ones) keep the earlier reading: any intent at all.
36
37
  on: i.gate && typeof i.gate.open === 'boolean' ? i.gate.open : !!(i.intent?.status && i.intent.status !== 'none'),
37
38
  label: i.intent?.status === 'draft' ? 'confirm what the app intends' : 'record what the app intends',
38
- cta: skill('bravos-context', harness),
39
+ // A draft with its questions on disk is the person's to review on the intake page; drafting again would not
40
+ // confirm anything. With no draft questions (an older draft), the context skill writes them first.
41
+ cta: reviewable ? 'bravos review intent' : skill('bravos-context', harness),
39
42
  unlocks: 'severities judged against what the software is meant to do and which attackers are in scope',
40
- how: `ask "learn what this app intends" (${skill('bravos-context', harness)})`,
43
+ how: reviewable
44
+ ? `the agent drafted it; confirm or correct the drafted answers on the intake page: bravos review intent (a few minutes; the agent never confirms for you)`
45
+ : `ask "learn what this app intends" (${skill('bravos-context', harness)})`,
41
46
  },
42
47
  {
43
48
  id: 'coverage',
@@ -1,9 +1,9 @@
1
- // @comment -- "SessionStart hook entry (--global: the user-level copy, silent where the repo has its own bravos hook or no .guardlink/; --briefing prints only the briefing text, for a skill that runs it by hand): reads the hook payload from stdin (bounded wait, bad input ignored; source, and Antigravity's workspacePaths), awaits collect() (read-only guardlink, git and gh facts under a shared 20 s deadline) and, where autopilot is registered, the session-start snapshot of the working tree (.bravos/watch/turn-base), and prints one JSON envelope: the briefing as additionalContext for the model, plus on a fresh start a banner as systemMessage for the human (brand-coloured; a three-line summary for Codex). With --harness agy it prints Antigravity's injectSteps instead. Always exits 0 so a session never fails to start."
1
+ // @comment -- "SessionStart hook entry (--global: the user-level copy, silent where the repo has its own bravos hook or no .guardlink/; --briefing prints only the briefing text, for a skill that runs it by hand): reads the hook payload from stdin (bounded wait, bad input ignored; source, and Antigravity's workspacePaths), awaits collect() (read-only guardlink, git and gh facts under a shared 20 s deadline) and, where autopilot is registered, the session-start snapshot of the working tree (.bravos/watch/turn-base), and prints one JSON envelope: the briefing as additionalContext for the model, plus on a fresh start a banner as systemMessage for the human (brand-coloured; a three-line summary for Codex, whose briefing also asks the agent to open its first reply with the banner as a text card, since Codex folds a hook's message away as a warning). With --harness agy it prints Antigravity's injectSteps instead. Always exits 0 so a session never fails to start."
2
2
  import { closeSync, existsSync, openSync, realpathSync } from 'node:fs';
3
3
  import { WriteStream } from 'node:tty';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { autopilotRegistered, buildBanner, buildBriefing, buildSummary, collect, readVersion, sessionHookRegistered } from './lib/briefing.mjs';
6
+ import { autopilotRegistered, buildBanner, buildBriefing, buildSummary, collect, firstReplyStatus, readVersion, sessionHookRegistered } from './lib/briefing.mjs';
7
7
  import { resolveTheme } from './lib/palette.mjs';
8
8
  import { startGraphBuild } from './lib/graph-autobuild.mjs';
9
9
  import { takeSnapshot } from './lib/snapshot.mjs';
@@ -112,6 +112,11 @@ async function main() {
112
112
  // @comment -- "Starts the daily check for a newer Bravos in a detached process (hooks/lib/update-check.mjs); this session never waits on it, and the next prompt's coach or the next session reads its answer."
113
113
  checkUpdates({ env });
114
114
  text = buildBriefing(inputs);
115
+ // @comment -- "Codex shows the summary below only as a folded warning (F2) and no hook field prints to its transcript, so on a fresh start the briefing asks the agent to open its first reply with the banner as a text card."
116
+ if (harness === 'codex') {
117
+ const status = firstReplyStatus(inputs, { harness, env, version: readVersion(dirname(fileURLToPath(import.meta.url))) });
118
+ if (status) text += '\n' + status;
119
+ }
115
120
  if (env.BRAVOS_BANNER !== 'off' && (source === null || source === 'startup') && harness !== 'agy') {
116
121
  const version = readVersion(dirname(fileURLToPath(import.meta.url)));
117
122
  const color = !env.NO_COLOR && env.BRAVOS_BANNER_COLOR !== 'off';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.16.1",
3
+ "version": "1.17.2",
4
4
  "description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
5
5
  "keywords": [
6
6
  "security",