@bugb-technologies/bravos 1.16.0 → 1.17.1
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/docs/UPGRADING.md +29 -0
- package/hooks/lib/briefing.mjs +73 -8
- package/hooks/lib/setup.mjs +8 -3
- package/hooks/session-start.mjs +7 -2
- package/package.json +1 -1
- package/templates/workflows/bravos-nightly-claude.yml +24 -13
- package/templates/workflows/bravos-nightly-codex.yml +24 -13
- package/templates/workflows/bravos-nightly-copilot.yml +6 -4
- package/templates/workflows/bravos-pr-gate.yml +9 -6
- package/templates/workflows/copilot-setup-steps.yml +4 -3
package/docs/UPGRADING.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
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.1
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **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.
|
|
9
|
+
- **It appears once,** not on resume or compact, and not when `BRAVOS_BANNER=off` is set.
|
|
10
|
+
- **The three-line summary is still behind F2,** and other harnesses are unchanged.
|
|
11
|
+
- **To get it:** run `bravos setup` in each repository, then start a new Codex session.
|
|
12
|
+
|
|
13
|
+
## 1.17.0
|
|
14
|
+
|
|
15
|
+
- **The session banner shows more of what Bravos knows.**
|
|
16
|
+
- **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".
|
|
17
|
+
- **Every setup step shows its state:** intent, code graph, pre-PR, autopilot, CI, SAST, proving and test target.
|
|
18
|
+
- **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.
|
|
19
|
+
- **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.
|
|
20
|
+
- **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.
|
|
21
|
+
- **To see it:** run `bravos setup` in each repository, then start a new session.
|
|
22
|
+
|
|
23
|
+
## 1.16.1
|
|
24
|
+
|
|
25
|
+
- **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:
|
|
26
|
+
- **Every action is pinned to a commit,** with its version in a comment beside it. A moved tag can no longer change what runs.
|
|
27
|
+
- **No token is left in the checkout:** checkouts use `persist-credentials: false`. Copilot's setup is the exception, because Copilot pushes from it.
|
|
28
|
+
- **The nightly push stays authenticated another way.** The token is masked in the log and sent only to the two git commands that need it. It is never written to git config.
|
|
29
|
+
- **guardlink is pinned:** the PR gate and Copilot's setup install the pinned version (2.6.0) instead of whatever npm has that day.
|
|
30
|
+
- **Run `bravos setup`** in each repository that has these workflows, then commit the changed `.github/workflows` files.
|
|
31
|
+
- **It updates only the Bravos workflows you already have.** It never adds one you didn't choose.
|
|
32
|
+
- **A workflow you edited yourself is left as it is.** `bravos sync --ci --force` replaces it.
|
|
33
|
+
|
|
5
34
|
## 1.16.0
|
|
6
35
|
|
|
7
36
|
- **"Identify all the threats" uses everything Bravos has.** A new skill, `bravos-threat-hunt`, runs when you ask to identify, find or list threats or vulnerabilities, for a security review or audit, or to threat-model the codebase:
|
package/hooks/lib/briefing.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
974
|
-
const
|
|
975
|
-
const
|
|
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(...
|
|
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,34 @@ 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 one-line security status for a harness that shows the startup summary only as a folded warning (Codex puts a hook's systemMessage behind F2 and has no field that prints to the transcript): counts, tested state, coverage and the next setup step, plain text with nothing from the repo but its name. firstReplyStatus wraps it as the briefing's instruction to open the agent's first reply with that line, once; null on a resume or compact, or with BRAVOS_BANNER=off."
|
|
1061
|
+
export function statusLine(inputs, opts = {}) {
|
|
1062
|
+
const i = inputs ?? {};
|
|
1063
|
+
const head = `Bravos${opts.version ? ` ${opts.version}` : ''}`;
|
|
1064
|
+
if (i.guardlink === 'missing') return `${head} · guardlink not found on PATH — run bravos doctor`;
|
|
1065
|
+
const g = i.guardlink ?? {};
|
|
1066
|
+
const m = bannerMetrics(g);
|
|
1067
|
+
const parts = [head];
|
|
1068
|
+
if (m) {
|
|
1069
|
+
parts.push(`${m.total} open${m.severities.length ? ` (${m.severities.join(', ')})` : ''}`, `${m.confirmed} confirmed`);
|
|
1070
|
+
const states = testedStates(g);
|
|
1071
|
+
if (states) parts.push(states);
|
|
1072
|
+
if (m.coverage) parts.push(`coverage ${num(m.coverage.percent)}%`);
|
|
1073
|
+
} else parts.push('threat counts unknown');
|
|
1074
|
+
const setup = i.root ? readSetup(i.root, i, opts.harness) : null;
|
|
1075
|
+
if (setup) {
|
|
1076
|
+
parts.push(`setup ${setup.done}/${setup.total}`);
|
|
1077
|
+
if (setup.next) parts.push(`next: ${setup.next.paid ? 'activate Team → bravos account activate' : `${setup.next.label} → ${setup.next.cta}`}`);
|
|
1078
|
+
}
|
|
1079
|
+
return clean(parts.join(' · '));
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
export function firstReplyStatus(inputs, opts = {}) {
|
|
1083
|
+
const source = inputs?.source;
|
|
1084
|
+
if (source === 'resume' || source === 'compact' || opts.env?.BRAVOS_BANNER === 'off') return null;
|
|
1085
|
+
return `Status for the person: this harness shows Bravos's startup summary only as a folded warning, so open your first reply with this line, as written and on its own line, then answer their message; never repeat it later in the session: ${statusLine(inputs, opts)}`;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1023
1088
|
// Brand palette by theme (hooks/lib/palette.mjs). Colour is truecolor ANSI, added after
|
|
1024
1089
|
// layout so widths are measured on plain text. A null colour is the terminal's own
|
|
1025
1090
|
// foreground, so it is readable on whatever background the terminal has.
|
|
@@ -1032,7 +1097,7 @@ export const paint = (text, hex, bold = false) => (hex || bold ? `${bold ? '\x1b
|
|
|
1032
1097
|
export function colorize(lines, _inputs = {}, theme = 'dark') {
|
|
1033
1098
|
const p = THEMES[theme] ?? THEMES.neutral;
|
|
1034
1099
|
// 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;
|
|
1100
|
+
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
1101
|
return lines.map((line) => {
|
|
1037
1102
|
if (/^! /.test(line)) return paint(line, p.red, true);
|
|
1038
1103
|
if (/^~ /.test(line)) return paint(line, p.steel);
|
package/hooks/lib/setup.mjs
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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',
|
package/hooks/session-start.mjs
CHANGED
|
@@ -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 a one-line status, since Codex folds a hook's message away as a warning). With --harness agy it prints Antigravity's injectSteps instead. Always exits 0 so a session never fails to start."
|
|
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 same status in one line."
|
|
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.
|
|
3
|
+
"version": "1.17.1",
|
|
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",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
# run `claude setup-token` once on your machine and store what it prints as the repo secret
|
|
10
10
|
# CLAUDE_CODE_OAUTH_TOKEN. A repo that already set ANTHROPIC_API_KEY keeps working on that key;
|
|
11
11
|
# delete that secret to run on your plan instead. Also enable Settings > Actions > General >
|
|
12
|
-
# "Allow GitHub Actions to create and approve pull requests".
|
|
13
|
-
#
|
|
12
|
+
# "Allow GitHub Actions to create and approve pull requests". Every action is pinned to a commit (its release in the comment beside it), and no checkout leaves the job's token on disk:
|
|
13
|
+
# the one step that pushes passes it to that push alone.
|
|
14
14
|
# Team view, off by default: set the repository variable BRAVOS_THREAT_ISSUES to on (Settings > Secrets and
|
|
15
15
|
# variables > Actions > Variables) and the threat-issues job opens one issue per critical or high threat still
|
|
16
16
|
# untested BRAVOS_THREAT_ISSUES_DAYS days (default 2) after it was committed. A confirmed threat keeps its issue,
|
|
@@ -49,8 +49,10 @@ jobs:
|
|
|
49
49
|
BRAVOS_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
50
50
|
BRAVOS_SCAN_TARGET: ${{ vars.BRAVOS_SCAN_TARGET }}
|
|
51
51
|
steps:
|
|
52
|
-
- uses: actions/checkout@v4
|
|
53
|
-
|
|
52
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
53
|
+
with:
|
|
54
|
+
persist-credentials: false
|
|
55
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
54
56
|
with:
|
|
55
57
|
node-version: 22
|
|
56
58
|
- name: Check current scheduled consent
|
|
@@ -136,9 +138,11 @@ jobs:
|
|
|
136
138
|
outputs:
|
|
137
139
|
open: ${{ steps.gate.outputs.open }}
|
|
138
140
|
steps:
|
|
139
|
-
- uses: actions/checkout@v4
|
|
141
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
142
|
+
with:
|
|
143
|
+
persist-credentials: false
|
|
140
144
|
|
|
141
|
-
- uses: actions/setup-node@v4
|
|
145
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
142
146
|
with:
|
|
143
147
|
node-version: 22
|
|
144
148
|
|
|
@@ -166,11 +170,12 @@ jobs:
|
|
|
166
170
|
run:
|
|
167
171
|
shell: bash
|
|
168
172
|
steps:
|
|
169
|
-
- uses: actions/checkout@v4
|
|
173
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
170
174
|
with:
|
|
175
|
+
persist-credentials: false
|
|
171
176
|
fetch-depth: 0
|
|
172
177
|
|
|
173
|
-
- uses: actions/setup-node@v4
|
|
178
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
174
179
|
with:
|
|
175
180
|
node-version: 22
|
|
176
181
|
|
|
@@ -195,7 +200,7 @@ jobs:
|
|
|
195
200
|
echo "coverage=$(jq -r '.summary.coverage.percent // "unknown"' "$RUNNER_TEMP/ci-before.json")" >> "$GITHUB_OUTPUT"
|
|
196
201
|
|
|
197
202
|
- name: Annotate the next slice
|
|
198
|
-
uses: anthropics/claude-code-action@v1
|
|
203
|
+
uses: anthropics/claude-code-action@d1f58ad5e6f4d2b79547e63e37c2116064135896 # v1.0.277
|
|
199
204
|
with:
|
|
200
205
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
201
206
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
@@ -241,9 +246,15 @@ jobs:
|
|
|
241
246
|
LEDGER: ${{ needs.replay.outputs.ledger }}
|
|
242
247
|
PROOF_SUMMARY: ${{ needs.replay.outputs.summary || 'No completed replay summary. Check the replay job.' }}
|
|
243
248
|
GH_TOKEN: ${{ github.token }}
|
|
249
|
+
SERVER: ${{ github.server_url }}
|
|
244
250
|
START: ${{ steps.start.outputs.sha }}
|
|
245
251
|
BEFORE: ${{ steps.start.outputs.coverage }}
|
|
246
252
|
run: |
|
|
253
|
+
# The checkout kept no token on disk, so the agent above never saw one. The two git calls that reach the
|
|
254
|
+
# remote get it here as a header, for that call alone.
|
|
255
|
+
basic=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')
|
|
256
|
+
echo "::add-mask::$basic"
|
|
257
|
+
remote_auth="http.$SERVER/.extraheader=AUTHORIZATION: basic $basic"
|
|
247
258
|
# Load the staging helper and verified ledger from trusted inputs after the agent exits.
|
|
248
259
|
git show "$START:.bravos/hooks/lib/nightly-stage.mjs" > "$RUNNER_TEMP/nightly-stage.mjs"
|
|
249
260
|
node "$RUNNER_TEMP/nightly-stage.mjs"
|
|
@@ -258,10 +269,10 @@ jobs:
|
|
|
258
269
|
git config user.name "bravos-nightly[bot]"
|
|
259
270
|
git config user.email "bravos-nightly@users.noreply.github.com"
|
|
260
271
|
test "$(git rev-parse HEAD)" = "$START"
|
|
261
|
-
test "$(git ls-remote --exit-code origin "refs/heads/$base" | cut -f1)" = "$START"
|
|
272
|
+
test "$(git -c "$remote_auth" ls-remote --exit-code origin "refs/heads/$base" | cut -f1)" = "$START"
|
|
262
273
|
tree=$(git write-tree)
|
|
263
274
|
commit=$(git commit-tree "$tree" -p "$START" -m "annotate: nightly coverage slice (${BEFORE}% -> ${after}%)")
|
|
264
|
-
git -c core.hooksPath=/dev/null push origin "$commit:refs/heads/$branch"
|
|
275
|
+
git -c core.hooksPath=/dev/null -c "$remote_auth" push origin "$commit:refs/heads/$branch"
|
|
265
276
|
{
|
|
266
277
|
echo "Nightly coverage slice by bravos-annotate: ${BEFORE}% -> ${after}%."
|
|
267
278
|
echo
|
|
@@ -290,13 +301,13 @@ jobs:
|
|
|
290
301
|
run:
|
|
291
302
|
shell: bash
|
|
292
303
|
steps:
|
|
293
|
-
- uses: actions/checkout@v4
|
|
304
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
294
305
|
with:
|
|
295
306
|
# guardlink blame reads when each claim was committed from the full history.
|
|
296
307
|
fetch-depth: 0
|
|
297
308
|
persist-credentials: false
|
|
298
309
|
|
|
299
|
-
- uses: actions/setup-node@v4
|
|
310
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
300
311
|
with:
|
|
301
312
|
node-version: 22
|
|
302
313
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
# The nightly is on the Team plan: add the repo secret BRAVOS_LICENCE (the token from
|
|
7
7
|
# account.bugb.io/dashboard/license) so the agent's paid skills run; without it they say so and stop.
|
|
8
8
|
# Needs the repo secret OPENAI_API_KEY, and Settings > Actions > General > "Allow GitHub
|
|
9
|
-
# Actions to create and approve pull requests".
|
|
10
|
-
#
|
|
9
|
+
# Actions to create and approve pull requests". Every action is pinned to a commit (its release in the comment beside it), and no checkout leaves the job's token on disk:
|
|
10
|
+
# the one step that pushes passes it to that push alone.
|
|
11
11
|
# Team view, off by default: set the repository variable BRAVOS_THREAT_ISSUES to on (Settings > Secrets and
|
|
12
12
|
# variables > Actions > Variables) and the threat-issues job opens one issue per critical or high threat still
|
|
13
13
|
# untested BRAVOS_THREAT_ISSUES_DAYS days (default 2) after it was committed. A confirmed threat keeps its issue,
|
|
@@ -44,8 +44,10 @@ jobs:
|
|
|
44
44
|
BRAVOS_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
45
45
|
BRAVOS_SCAN_TARGET: ${{ vars.BRAVOS_SCAN_TARGET }}
|
|
46
46
|
steps:
|
|
47
|
-
- uses: actions/checkout@v4
|
|
48
|
-
|
|
47
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
48
|
+
with:
|
|
49
|
+
persist-credentials: false
|
|
50
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
49
51
|
with:
|
|
50
52
|
node-version: 22
|
|
51
53
|
- name: Check current scheduled consent
|
|
@@ -131,9 +133,11 @@ jobs:
|
|
|
131
133
|
outputs:
|
|
132
134
|
open: ${{ steps.gate.outputs.open }}
|
|
133
135
|
steps:
|
|
134
|
-
- uses: actions/checkout@v4
|
|
136
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
137
|
+
with:
|
|
138
|
+
persist-credentials: false
|
|
135
139
|
|
|
136
|
-
- uses: actions/setup-node@v4
|
|
140
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
137
141
|
with:
|
|
138
142
|
node-version: 22
|
|
139
143
|
|
|
@@ -161,11 +165,12 @@ jobs:
|
|
|
161
165
|
run:
|
|
162
166
|
shell: bash
|
|
163
167
|
steps:
|
|
164
|
-
- uses: actions/checkout@v4
|
|
168
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
165
169
|
with:
|
|
170
|
+
persist-credentials: false
|
|
166
171
|
fetch-depth: 0
|
|
167
172
|
|
|
168
|
-
- uses: actions/setup-node@v4
|
|
173
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
169
174
|
with:
|
|
170
175
|
node-version: 22
|
|
171
176
|
|
|
@@ -190,7 +195,7 @@ jobs:
|
|
|
190
195
|
echo "coverage=$(jq -r '.summary.coverage.percent // "unknown"' "$RUNNER_TEMP/ci-before.json")" >> "$GITHUB_OUTPUT"
|
|
191
196
|
|
|
192
197
|
- name: Annotate the next slice
|
|
193
|
-
uses: openai/codex-action@v1
|
|
198
|
+
uses: openai/codex-action@306c6a196a99dcc6582530c396a19d2672d5e9ec # v1.14
|
|
194
199
|
with:
|
|
195
200
|
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
|
|
196
201
|
permission-profile: ":workspace"
|
|
@@ -236,9 +241,15 @@ jobs:
|
|
|
236
241
|
LEDGER: ${{ needs.replay.outputs.ledger }}
|
|
237
242
|
PROOF_SUMMARY: ${{ needs.replay.outputs.summary || 'No completed replay summary. Check the replay job.' }}
|
|
238
243
|
GH_TOKEN: ${{ github.token }}
|
|
244
|
+
SERVER: ${{ github.server_url }}
|
|
239
245
|
START: ${{ steps.start.outputs.sha }}
|
|
240
246
|
BEFORE: ${{ steps.start.outputs.coverage }}
|
|
241
247
|
run: |
|
|
248
|
+
# The checkout kept no token on disk, so the agent above never saw one. The two git calls that reach the
|
|
249
|
+
# remote get it here as a header, for that call alone.
|
|
250
|
+
basic=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')
|
|
251
|
+
echo "::add-mask::$basic"
|
|
252
|
+
remote_auth="http.$SERVER/.extraheader=AUTHORIZATION: basic $basic"
|
|
242
253
|
# Load the staging helper and verified ledger from trusted inputs after the agent exits.
|
|
243
254
|
git show "$START:.bravos/hooks/lib/nightly-stage.mjs" > "$RUNNER_TEMP/nightly-stage.mjs"
|
|
244
255
|
node "$RUNNER_TEMP/nightly-stage.mjs"
|
|
@@ -253,10 +264,10 @@ jobs:
|
|
|
253
264
|
git config user.name "bravos-nightly[bot]"
|
|
254
265
|
git config user.email "bravos-nightly@users.noreply.github.com"
|
|
255
266
|
test "$(git rev-parse HEAD)" = "$START"
|
|
256
|
-
test "$(git ls-remote --exit-code origin "refs/heads/$base" | cut -f1)" = "$START"
|
|
267
|
+
test "$(git -c "$remote_auth" ls-remote --exit-code origin "refs/heads/$base" | cut -f1)" = "$START"
|
|
257
268
|
tree=$(git write-tree)
|
|
258
269
|
commit=$(git commit-tree "$tree" -p "$START" -m "annotate: nightly coverage slice (${BEFORE}% -> ${after}%)")
|
|
259
|
-
git -c core.hooksPath=/dev/null push origin "$commit:refs/heads/$branch"
|
|
270
|
+
git -c core.hooksPath=/dev/null -c "$remote_auth" push origin "$commit:refs/heads/$branch"
|
|
260
271
|
{
|
|
261
272
|
echo "Nightly coverage slice by bravos-annotate: ${BEFORE}% -> ${after}%."
|
|
262
273
|
echo
|
|
@@ -285,13 +296,13 @@ jobs:
|
|
|
285
296
|
run:
|
|
286
297
|
shell: bash
|
|
287
298
|
steps:
|
|
288
|
-
- uses: actions/checkout@v4
|
|
299
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
289
300
|
with:
|
|
290
301
|
# guardlink blame reads when each claim was committed from the full history.
|
|
291
302
|
fetch-depth: 0
|
|
292
303
|
persist-credentials: false
|
|
293
304
|
|
|
294
|
-
- uses: actions/setup-node@v4
|
|
305
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
295
306
|
with:
|
|
296
307
|
node-version: 22
|
|
297
308
|
|
|
@@ -43,9 +43,11 @@ jobs:
|
|
|
43
43
|
run:
|
|
44
44
|
shell: bash
|
|
45
45
|
steps:
|
|
46
|
-
- uses: actions/checkout@v4
|
|
46
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
47
|
+
with:
|
|
48
|
+
persist-credentials: false
|
|
47
49
|
|
|
48
|
-
- uses: actions/setup-node@v4
|
|
50
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
49
51
|
with:
|
|
50
52
|
node-version: 22
|
|
51
53
|
|
|
@@ -116,13 +118,13 @@ jobs:
|
|
|
116
118
|
run:
|
|
117
119
|
shell: bash
|
|
118
120
|
steps:
|
|
119
|
-
- uses: actions/checkout@v4
|
|
121
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
120
122
|
with:
|
|
121
123
|
# guardlink blame reads when each claim was committed from the full history.
|
|
122
124
|
fetch-depth: 0
|
|
123
125
|
persist-credentials: false
|
|
124
126
|
|
|
125
|
-
- uses: actions/setup-node@v4
|
|
127
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
126
128
|
with:
|
|
127
129
|
node-version: 22
|
|
128
130
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# bravos:generated — written by `bravos init --ci`; `bravos sync --ci` refreshes it while this line stays.
|
|
2
2
|
# The bravos-ship gate as a pull-request check, the same rulings as the opt-in pre-PR hook.
|
|
3
3
|
# Deterministic: it runs guardlink only, spends no model, and needs no secret. A gate input that
|
|
4
|
-
# fails or does not parse fails the job as "unknown", never passes.
|
|
5
|
-
# commit
|
|
4
|
+
# fails or does not parse fails the job as "unknown", never passes. Every action is pinned to a
|
|
5
|
+
# commit (its release in the comment beside it), the checkout keeps no token on disk, and guardlink
|
|
6
|
+
# is the version bravos pins (.bravos/hooks/lib/proof-tool-pins.json).
|
|
6
7
|
name: bravos security gate
|
|
7
8
|
|
|
8
9
|
on:
|
|
@@ -24,16 +25,18 @@ jobs:
|
|
|
24
25
|
run:
|
|
25
26
|
shell: bash
|
|
26
27
|
steps:
|
|
27
|
-
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
28
29
|
with:
|
|
30
|
+
persist-credentials: false
|
|
29
31
|
fetch-depth: 0
|
|
30
32
|
|
|
31
|
-
- uses: actions/setup-node@v4
|
|
33
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
32
34
|
with:
|
|
33
35
|
node-version: 22
|
|
34
36
|
|
|
37
|
+
# The guardlink version bravos pins, installed by the same script as the nightlies, never whatever npm calls latest.
|
|
35
38
|
- name: Install guardlink
|
|
36
|
-
run:
|
|
39
|
+
run: bash .bravos/hooks/lib/nightly-tools.sh annotate
|
|
37
40
|
|
|
38
41
|
- name: Merge base
|
|
39
42
|
id: base
|
|
@@ -292,7 +295,7 @@ jobs:
|
|
|
292
295
|
# A fork's pull_request token cannot write security events; skip the upload there.
|
|
293
296
|
- name: Upload SARIF
|
|
294
297
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
295
|
-
uses: github/codeql-action/upload-sarif@v3
|
|
298
|
+
uses: github/codeql-action/upload-sarif@9418214df1f2c4b8128c770156c409013b07d6b9 # v3.39.3
|
|
296
299
|
with:
|
|
297
300
|
sarif_file: guardlink.sarif
|
|
298
301
|
category: guardlink
|
|
@@ -25,11 +25,12 @@ jobs:
|
|
|
25
25
|
permissions:
|
|
26
26
|
contents: read
|
|
27
27
|
steps:
|
|
28
|
-
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
29
29
|
|
|
30
|
-
- uses: actions/setup-node@v4
|
|
30
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
31
31
|
with:
|
|
32
32
|
node-version: 22
|
|
33
33
|
|
|
34
|
+
# The guardlink version bravos pins, installed by the same script as the nightlies.
|
|
34
35
|
- name: Install guardlink
|
|
35
|
-
run:
|
|
36
|
+
run: bash .bravos/hooks/lib/nightly-tools.sh annotate
|