@bugb-technologies/bravos 1.4.2 → 1.5.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/README.md +1 -0
- package/dist/account.js +2 -11
- package/dist/cli.js +38 -14
- package/dist/codegraph.js +25 -0
- package/dist/dashboard.js +283 -0
- package/dist/guide.js +2 -1
- package/dist/help.js +11 -0
- package/dist/install.js +2 -2
- package/dist/licence.js +11 -4
- package/dist/omp.js +2 -1
- package/dist/open.js +22 -0
- package/dist/opencode.js +2 -1
- package/dist/skills.js +8 -0
- package/dist/watch.js +8 -24
- package/docs/GUIDE.md +7 -1
- package/docs/UPGRADING.md +27 -0
- package/hooks/lib/briefing.mjs +109 -27
- package/hooks/lib/licence.mjs +13 -0
- package/hooks/lib/setup.mjs +1 -1
- package/package.json +1 -1
- package/skills/bravos/SKILL.md +3 -2
- package/skills/bravos-annotate/SKILL.md +2 -1
- package/skills/bravos-annotate/scripts/lib/pick.mjs +1 -1
- package/skills/bravos-annotate/scripts/slice.mjs +1 -1
- package/skills/bravos-codegraph/SKILL.md +1 -1
- package/skills/bravos-context/SKILL.md +5 -4
- package/skills/bravos-recheck/SKILL.md +1 -0
- package/skills/bravos-report/SKILL.md +1 -0
- package/skills/bravos-ship/SKILL.md +1 -0
- package/skills/bravos-templatize/SKILL.md +1 -1
- package/templates/dashboard/codegraph-pages.css +279 -0
- package/templates/dashboard/codegraph-pages.js +6230 -0
- package/templates/dashboard/codegraph-pages.json +11 -0
- package/templates/dashboard/dashboard.html +273 -0
package/dist/skills.js
CHANGED
|
@@ -47,6 +47,14 @@ function withMarker(content, rel) {
|
|
|
47
47
|
lines.splice(at, 0, MARKER);
|
|
48
48
|
return lines.join('\n');
|
|
49
49
|
}
|
|
50
|
+
// @comment -- "Bravos's own GuardLink annotations must not travel into a customer's repository with the scripts it installs there: GuardLink counts any annotated file towards coverage, so a fresh project used to report 50% before anyone had annotated anything, and the model listed Bravos's files as the customer's. Each one-line annotation comment (// @verb … -- \"text\") becomes a plain comment carrying the same text; every other byte is kept."
|
|
51
|
+
export function withoutOwnAnnotations(content, rel) {
|
|
52
|
+
if (!/\.(mjs|cjs|js|ts)$/.test(rel))
|
|
53
|
+
return content;
|
|
54
|
+
const text = content.toString('utf8');
|
|
55
|
+
const out = text.replace(/^([ \t]*\/\/)[ \t]*@[a-z]+\b[^\n]*?-- "((?:[^"\\\n]|\\.)*)"[ \t]*$/gm, (_m, lead, desc) => `${lead} ${desc.replace(/\\(.)/g, '$1')}`);
|
|
56
|
+
return out === text ? content : Buffer.from(out);
|
|
57
|
+
}
|
|
50
58
|
/** Insert the generated marker into SKILL.md after the frontmatter (or at line 1) and substitute placeholders. */
|
|
51
59
|
// @comment -- "Renders a bundled skill file for one harness: inserts the generated marker into SKILL.md (rel is the file's path inside the skill folder) and substitutes {{SKILL_DIR}} and {{SKILLS_ROOT}} in every .md file."
|
|
52
60
|
export function renderSkillFile(content, harness, name, rel = 'SKILL.md') {
|
package/dist/watch.js
CHANGED
|
@@ -5,6 +5,7 @@ import { basename, join } from 'node:path';
|
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
6
6
|
import * as graph from './codegraph.js';
|
|
7
7
|
import { LOCK_PATH } from './lock.js';
|
|
8
|
+
import { openInBrowser } from './open.js';
|
|
8
9
|
import { hooksDir, version } from './paths.js';
|
|
9
10
|
import { readAllAnswers, readDraft } from './review.js';
|
|
10
11
|
import { listReports, readMeta, reportDir } from './report/meta.js';
|
|
@@ -40,20 +41,6 @@ export function readReportSummary(root, env) {
|
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
const libs = {};
|
|
43
|
-
// @comment -- "The header's plan label from the briefing's licence status: short enough for one bar, honest about trial days and expiry."
|
|
44
|
-
export function planLabel(v) {
|
|
45
|
-
if (!v || typeof v !== 'object')
|
|
46
|
-
return { label: 'Free', licensed: false };
|
|
47
|
-
const tier = typeof v.tier === 'string' ? v.tier.charAt(0).toUpperCase() + v.tier.slice(1) : 'Free';
|
|
48
|
-
if (v.licensed) {
|
|
49
|
-
if (v.trial)
|
|
50
|
-
return { label: `${tier} trial · ${Math.max(0, Math.ceil((v.trial.endsAt - Date.now() / 1000) / 86400))}d left`, licensed: true };
|
|
51
|
-
return { label: `${tier} · ${v.seats} seat${v.seats === 1 ? '' : 's'}${v.state === 'grace' ? ' · in grace' : ''}`, licensed: true };
|
|
52
|
-
}
|
|
53
|
-
if (v.state === 'expired')
|
|
54
|
-
return { label: `${tier} · expired`, licensed: false };
|
|
55
|
-
return { label: 'Free', licensed: false };
|
|
56
|
-
}
|
|
57
44
|
export const lib = (name) => (libs[name] ??= import(pathToFileURL(join(hooksDir(), 'lib', name)).href));
|
|
58
45
|
export const runner = async () => (await lib('autopilot.mjs')).asyncRunner;
|
|
59
46
|
export const parseJson = (r) => {
|
|
@@ -273,7 +260,8 @@ export async function snapshot(root, env, opts = {}) {
|
|
|
273
260
|
setup: { done: setup.done, total: setup.total, items: setup.items.map((x) => ({ id: x.id, label: x.label, on: x.on })), next: setup.next ? { label: setup.next.label, cta: setup.next.cta, how: setup.next.how } : null },
|
|
274
261
|
sast: i.sast?.summary ? { total: i.sast.summary.total, reachable: i.sast.summary.reachable, unjoinedReachable: i.sast.summary.unjoinedReachable, staleCommits: i.sast.summary.staleCommits } : null,
|
|
275
262
|
sastAvailable: !!i.sast?.available?.ok,
|
|
276
|
-
|
|
263
|
+
// One short label, shared with the banner (hooks/lib/licence.mjs).
|
|
264
|
+
plan: (await lib('licence.mjs')).planLabel(i.licence),
|
|
277
265
|
graph,
|
|
278
266
|
team: { prs: num(i.inFlight?.prs), files: num(i.inFlight?.files), numbers: arr(i.inFlight?.numbers) },
|
|
279
267
|
branchWork: {
|
|
@@ -568,7 +556,7 @@ export function graphAnswer(status, stdout, failure = '') {
|
|
|
568
556
|
}
|
|
569
557
|
return [`no answer${failure ? `: ${failure}` : status !== null ? ` (exit ${status})` : ''}`];
|
|
570
558
|
}
|
|
571
|
-
// @comment -- "Maps one key to a read-only action: copy the next command, open the intent review or
|
|
559
|
+
// @comment -- "Maps one key to a read-only action: copy the next command, open the intent review or the dashboard (bravos dashboard, written outside the repository), ask the graph, show test-next, the recorded intent or the guide, scroll, refresh everything now, or quit; anything else does nothing."
|
|
572
560
|
export function handleKey(key, sn, root = '.') {
|
|
573
561
|
switch (key) {
|
|
574
562
|
case 'n':
|
|
@@ -578,7 +566,7 @@ export function handleKey(key, sn, root = '.') {
|
|
|
578
566
|
case 'd': {
|
|
579
567
|
// Written outside the repository so the key never changes the working tree.
|
|
580
568
|
const file = join(tmpdir(), `bravos-dashboard-${basename(root) || 'repo'}.html`);
|
|
581
|
-
return { kind: 'spawn', cmd:
|
|
569
|
+
return { kind: 'spawn', cmd: process.execPath, args: [...selfArgs(), 'dashboard', root, '--out', file, '--no-open'], note: `writing the dashboard to ${file}`, open: file };
|
|
582
570
|
}
|
|
583
571
|
case 'g':
|
|
584
572
|
return { kind: 'overlay', what: 'graph' };
|
|
@@ -632,7 +620,7 @@ export function ignoredChange(name) {
|
|
|
632
620
|
return !(n === '.git/HEAD' || n.startsWith('.git/refs/'));
|
|
633
621
|
if (n.startsWith('node_modules/') || n.includes('/node_modules/'))
|
|
634
622
|
return true;
|
|
635
|
-
if (n.startsWith('.bravos/sast/'))
|
|
623
|
+
if (n.startsWith('.bravos/sast/') || n.startsWith('.bravos/dashboard/'))
|
|
636
624
|
return true;
|
|
637
625
|
if (n.startsWith('.bravos/watch/'))
|
|
638
626
|
return n !== '.bravos/watch/events.jsonl';
|
|
@@ -641,10 +629,6 @@ export function ignoredChange(name) {
|
|
|
641
629
|
return !n.endsWith('/meta.json');
|
|
642
630
|
return false;
|
|
643
631
|
}
|
|
644
|
-
function openTarget(target) {
|
|
645
|
-
const [cmd, args] = process.platform === 'darwin' ? ['open', [target]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', target]] : ['xdg-open', [target]];
|
|
646
|
-
spawn(cmd, args, { detached: true, stdio: 'ignore' }).on('error', () => { }).unref();
|
|
647
|
-
}
|
|
648
632
|
function copyToClipboard(text) {
|
|
649
633
|
const tries = process.platform === 'darwin' ? [['pbcopy', []]] : process.platform === 'win32' ? [['clip', []]] : [['wl-copy', []], ['xclip', ['-selection', 'clipboard']]];
|
|
650
634
|
for (const [cmd, args] of tries) {
|
|
@@ -854,7 +838,7 @@ export async function runWatch(root, env, opts) {
|
|
|
854
838
|
const file = r ? (['pdf', 'html'].map((f) => join(r.dir, `report.${f}`)).find((f) => existsSync(f)) ?? null) : null;
|
|
855
839
|
note = file ? `opening ${file}` : r ? `no html or pdf yet: bravos report export ${r.id} --format html,pdf` : 'no report yet: ask "write the assessment report" (/bravos-report)';
|
|
856
840
|
if (file)
|
|
857
|
-
|
|
841
|
+
openInBrowser(file, env);
|
|
858
842
|
}
|
|
859
843
|
if (a.kind === 'theme') {
|
|
860
844
|
theme = nextTheme(theme);
|
|
@@ -878,7 +862,7 @@ export async function runWatch(root, env, opts) {
|
|
|
878
862
|
child.on('exit', (code) => {
|
|
879
863
|
note = code === 0 ? `dashboard: ${file}` : `${a.cmd} exited ${code}`;
|
|
880
864
|
if (code === 0)
|
|
881
|
-
|
|
865
|
+
openInBrowser(file, env);
|
|
882
866
|
draw();
|
|
883
867
|
});
|
|
884
868
|
}
|
package/docs/GUIDE.md
CHANGED
|
@@ -40,7 +40,7 @@ Run bravos next in a shell (free): it shows which of the nine steps are done her
|
|
|
40
40
|
|
|
41
41
|
Or just ask the agent "help me get started" (or run /bravos, $bravos in Codex): it gives a short tour fitted to this repo. BRAVOS_COACH=off stops the coaching; the Setup line stays.
|
|
42
42
|
|
|
43
|
-
Keep bravos watch running in a second terminal pane beside your agent (free, read-only, no model): the setup score, open and confirmed exposures, what to test next, stale claims and autopilot nudges, redrawn within seconds of a change. It also shows the hypothesis ledger, boundaries, the model's size, the code graph's call resolution and entry points, and the branch's commits. Keys: n copies the next command, r opens the intent review, d
|
|
43
|
+
Keep bravos watch running in a second terminal pane beside your agent (free, read-only, no model): the setup score, open and confirmed exposures, what to test next, stale claims and autopilot nudges, redrawn within seconds of a change. It also shows the hypothesis ledger, boundaries, the model's size, the code graph's call resolution and entry points, and the branch's commits. Keys: n copies the next command, r opens the intent review, d the dashboard (bravos dashboard), g asks the code graph, t shows test-next, i shows the recorded intent, u refreshes now, j and k scroll, q quits. Three columns from 150 wide, two from 110, one in an 80-column split.
|
|
44
44
|
|
|
45
45
|
### Hands-off: autopilot
|
|
46
46
|
|
|
@@ -184,6 +184,12 @@ Skills: `/bravos-annotate` · `/bravos-codegraph` · `/bravos-prove`
|
|
|
184
184
|
|
|
185
185
|
Clone the services side by side in one folder, then run bravos workspace create NAME --member ./gateway=gateway@http://127.0.0.1:8080 --member ./orders=orders@http://127.0.0.1:8081 (bravos workspace plus guardlink link-project plus bravos in each repo and in the shared folder). Work on a service from its own repo; ask questions that cross services from the shared folder, where the briefing and bravos watch show every service. Declare each call to another service as @flows #<this>-<x> -> #<other>-<y> via http (plain ids, not #repo.tag). Build the code graph over the shared folder so it links one service's client calls to another's handlers. bravos report data --workspace writes one report across the services.
|
|
186
186
|
|
|
187
|
+
### See the findings on one page
|
|
188
|
+
|
|
189
|
+
Skills: `/bravos`
|
|
190
|
+
|
|
191
|
+
Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. Run it again whenever you want the picture: it rebuilds from the code as it stands, rebuilding a code graph that is missing or behind first, and a saved page says when it is more than half a day old. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".
|
|
192
|
+
|
|
187
193
|
### Write up the assessment, a finding or a retest
|
|
188
194
|
|
|
189
195
|
Skills: `/bravos-report`
|
package/docs/UPGRADING.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
After `npm install -g @bugb-technologies/bravos`, run **`bravos setup --tools -y`** once on each machine and **`bravos sync`** in each repository. The notes below say what else changes, newest first.
|
|
4
4
|
|
|
5
|
+
## 1.5.1
|
|
6
|
+
|
|
7
|
+
- **`bravos dashboard` makes the code graph current first** (Team plan). With no graph for this commit it builds one; when the code has moved since the graph was built, it rebuilds it. It says so as it starts and runs none of the repository's code. A first build on a large repository takes minutes; `--no-graph-build` draws from the graph as it is.
|
|
8
|
+
- **A saved dashboard says how old it is.** The bar shows when it was built, and a page opened more than half a day later says it may be behind the code and names the command.
|
|
9
|
+
- **Your agent keeps you off old pages.** The briefing has a `Dashboard:` line saying whether the saved page is current or how many commits behind it is, and the skills run `bravos dashboard` afresh instead of opening a saved copy. After annotating or rechecking, the agent says an earlier dashboard is now behind and offers to rebuild it.
|
|
10
|
+
- Run `bravos sync` in each repository to get the updated skills and briefing.
|
|
11
|
+
|
|
12
|
+
## 1.5.0
|
|
13
|
+
|
|
14
|
+
1.5 adds a dashboard and tells you which plan you are on. It includes everything listed under 1.4.3, which was not published on its own.
|
|
15
|
+
|
|
16
|
+
- **`bravos dashboard`** writes one self-contained page and opens it in your browser. It is saved as `.bravos/dashboard/index.html`, which git ignores; it needs no server, network or model.
|
|
17
|
+
- **Threat model tab:** GuardLink's own dashboard, with who introduced and fixed each exposure and what changed since the default branch.
|
|
18
|
+
- **Code graph tab (Team plan, with the graph built):** the map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. On the Free plan the tab says so.
|
|
19
|
+
- `--no-blame` leaves git names out of both tabs, for a page you will share. `--no-open` only prints the path; `--out <file>` writes elsewhere.
|
|
20
|
+
- A large repository makes a large page (tens of megabytes) and takes a couple of minutes.
|
|
21
|
+
- **Ask your agent "show me the findings"** and it offers this page. `d` in `bravos watch` builds it too.
|
|
22
|
+
- **The banner states your plan** beside the mascot (`Plan: Free`, `Plan: Team trial · 25d left`, `Plan: Team · 5 seats`), and `bravos next` prints it under its title. Without a licence it shows `graph locked` instead of `graph on`, lists free skills where the Team-only ones were, and says once what Team adds.
|
|
23
|
+
- **Opening a browser** is skipped in CI and on Linux without a display; the path or URL is still printed.
|
|
24
|
+
|
|
25
|
+
## 1.4.3
|
|
26
|
+
|
|
27
|
+
- **Coverage counts only your code.** Bravos's own annotations no longer travel into a repository with the skill scripts it installs, so a fresh project starts at 0% instead of 50%. After `bravos sync`, coverage in an existing repository drops by those files (two per agent); nothing of yours changed.
|
|
28
|
+
- **The briefing states the plan and where annotations go:** a `Plan:` line, and an `Annotations:` line saying external `.gal` sidecars or inline comments. bravos-context follows it instead of always writing beside the code.
|
|
29
|
+
- **On the Free plan the next step is a free one.** `bravos next` and the briefing list the code graph as a Team-plan step and start from "record what the app intends".
|
|
30
|
+
- **The agent asks before the first commit of a session,** in bravos-context, bravos-annotate and bravos-templatize. Campaigns and schedules, where you already asked for commits, are not interrupted.
|
|
31
|
+
|
|
5
32
|
## 1.4.2
|
|
6
33
|
|
|
7
34
|
- **Bravos tests only with `cxg scan`.** It never runs `cxg pentest run`, `cxg scan --pentest` or cxg's model generation; every probe is written and reviewed in your agent's session. Electron apps run through `cxg scan --target-type electron` with `--app-cmd` or `--app-binary`, and Tauri's in-process proof through `--tauri-prove`. Test logins still use `cxg pentest auth`.
|
package/hooks/lib/briefing.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { accessSync, constants, readFileSync } from 'node:fs';
|
|
|
4
4
|
import { basename, delimiter, dirname, join } from 'node:path';
|
|
5
5
|
import { THEMES } from './palette.mjs';
|
|
6
6
|
import { readProving } from './proving.mjs';
|
|
7
|
-
import { planLine, status as licenceStatus } from './licence.mjs';
|
|
7
|
+
import { planLabel, planLine, status as licenceStatus } from './licence.mjs';
|
|
8
8
|
import { refreshIfDue } from './refresh.mjs';
|
|
9
9
|
import { gitStaleness, staleLine, staleness, strandedBranches, strandedLine } from './resync.mjs';
|
|
10
10
|
import { readSast, sastAvailable, sastLine } from './sast.mjs';
|
|
@@ -67,6 +67,40 @@ function exposuresLine(g) {
|
|
|
67
67
|
return line;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// @comment -- "Reads annotation_mode from .guardlink/config.json: 'external' (sidecars), 'inline', or null when the file is missing, unreadable or names neither; read-only."
|
|
71
|
+
export function readAnnotationMode(root) {
|
|
72
|
+
try {
|
|
73
|
+
const mode = JSON.parse(readFileSync(join(root, '.guardlink', 'config.json'), 'utf8'))?.annotation_mode;
|
|
74
|
+
return mode === 'external' || mode === 'inline' ? mode : null;
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// @comment -- "Reads .bravos/dashboard/meta.json, which bravos dashboard writes beside the page it saves: when the page was built and from which commit. null when no page was saved here or the record is unreadable; the commit is returned only when it is a plain hex id, since it is handed to git. Read-only."
|
|
81
|
+
export function readDashboard(root) {
|
|
82
|
+
try {
|
|
83
|
+
const m = JSON.parse(readFileSync(join(root, '.bravos', 'dashboard', 'meta.json'), 'utf8'));
|
|
84
|
+
const at = Date.parse(m?.generatedAt);
|
|
85
|
+
if (!Number.isFinite(at)) return null;
|
|
86
|
+
return { generatedAt: at, commit: typeof m.commit === 'string' && /^[0-9a-f]{7,40}$/.test(m.commit) ? m.commit : null };
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// @comment -- "One briefing line about the saved dashboard, so the agent never sends the person to an old page: out of date when commits have landed since it was built or it is more than half a day old, with the one command that rebuilds it (and, on the Team plan, the code graph it draws from). Pure."
|
|
93
|
+
export function dashboardLine(d, now = Date.now()) {
|
|
94
|
+
if (!d || !Number.isFinite(d.generatedAt)) return null;
|
|
95
|
+
const minutes = Math.max(0, Math.round((now - d.generatedAt) / 60000));
|
|
96
|
+
const age = minutes < 2 ? 'just now' : minutes < 90 ? `${minutes} minutes ago` : minutes < 36 * 60 ? `${Math.round(minutes / 60)} hours ago` : `${Math.round(minutes / 1440)} days ago`;
|
|
97
|
+
const behind = num(d.behind);
|
|
98
|
+
if (behind > 0 || minutes > 12 * 60) {
|
|
99
|
+
return `Dashboard: the saved page is out of date (built ${age}${behind > 0 ? `, ${behind} commit${behind === 1 ? '' : 's'} behind` : ''}) — never send the person to it as it is; \`bravos dashboard\` rebuilds it from the code as it stands`;
|
|
100
|
+
}
|
|
101
|
+
return `Dashboard: built ${age} at this commit (.bravos/dashboard/index.html); after changes to code or annotations, \`bravos dashboard\` rebuilds it`;
|
|
102
|
+
}
|
|
103
|
+
|
|
70
104
|
// @comment -- "Reads .guardlink/intent.md (written by bravos-context) and reports whether the product's intent is recorded: none, draft (any item marked '— draft') or confirmed, with the invariant count; read-only."
|
|
71
105
|
export function readIntent(root) {
|
|
72
106
|
let text;
|
|
@@ -104,10 +138,11 @@ function coachLines(i) {
|
|
|
104
138
|
}
|
|
105
139
|
out.push(
|
|
106
140
|
'How to help this person (offer, never lecture; one offer per topic per session):',
|
|
107
|
-
`- In your first reply, if setup is under 5 or intent is none, offer once in plain words three starts that fit this repo, in setup order (build the code graph first if it is off, then learn what the app intends, annotate the uncovered files, run SAST, prove the top threats; or check this branch before a PR) and \`bravos guide\` for more; then follow their lead.`,
|
|
141
|
+
`- In your first reply, if setup is under 5 or intent is none, offer once in plain words three starts that fit this repo, in setup order (${i.licence?.licensed === false ? 'on the Free plan: learn what the app intends, annotate the uncovered files, prove the top threats; never lead with a Team-plan step' : 'build the code graph first if it is off, then learn what the app intends, annotate the uncovered files, run SAST, prove the top threats; or check this branch before a PR'}) and \`bravos guide\` for more; then follow their lead.`,
|
|
108
142
|
`- After you edit security-relevant code, offer to record what it exposes (${k('bravos-annotate')}); before a PR, run the ship check (${k('bravos-ship')}); after a fix, offer a recheck (${k('bravos-recheck')}).`,
|
|
143
|
+
'- Commits are the person\'s call: before the first commit of a session ask once (commit now, or leave the files for them to review), even where a skill says to commit; skip the question only when they already asked for commits (a campaign, a schedule).',
|
|
109
144
|
'- When a request would go better with the next unlock above, say what it would add, once. Plain words first, skill name second. Never send test traffic without the authorization bravos-env asks for.',
|
|
110
|
-
'- Once, when it helps them follow along, mention that `bravos watch` in a second terminal pane shows this live as you work (free, read-only).',
|
|
145
|
+
'- Once, when it helps them follow along, mention that `bravos watch` in a second terminal pane shows this live as you work (free, read-only), and that `bravos dashboard` opens the findings as one page in their browser (rebuilt from the code each time; never open a saved copy instead).',
|
|
111
146
|
);
|
|
112
147
|
return out;
|
|
113
148
|
}
|
|
@@ -117,7 +152,9 @@ export function buildBriefing(inputs) {
|
|
|
117
152
|
const i = inputs ?? {};
|
|
118
153
|
const lines = [`GuardLink security picture (bravos) — ${i.repo} @ ${i.sha}, base ${i.base}`];
|
|
119
154
|
for (const e of arr(i.errors).slice(0, MAX_DEGRADED)) lines.push(` (degraded: ${e})`);
|
|
120
|
-
|
|
155
|
+
// The pre-PR ship check is on the Team plan, so an unlicensed person's last pointer is the recheck instead.
|
|
156
|
+
const nextBase = i.harness === 'claude' ? NEXT_CLAUDE : NEXT_OTHER;
|
|
157
|
+
const nextLine = hooksLocked(i) ? nextBase.replace('bravos-ship before a PR', 'bravos-recheck after a fix') : nextBase;
|
|
121
158
|
|
|
122
159
|
if (i.guardlink === 'missing') {
|
|
123
160
|
lines.push('guardlink: not found on PATH — run bravos doctor', nextLine);
|
|
@@ -130,6 +167,18 @@ export function buildBriefing(inputs) {
|
|
|
130
167
|
const staleText = staleLine(i.stale, { branch: i.branch, base: i.base });
|
|
131
168
|
if (staleText) head.push(staleText);
|
|
132
169
|
head.push(exposuresLine(g));
|
|
170
|
+
// The plan the skills and the lines below refer to ("see Plan above"): which tier this machine is on.
|
|
171
|
+
// A licence record missing a field must never cost the person their briefing, so a line that cannot be built is left out.
|
|
172
|
+
if (i.licence && typeof i.licence === 'object' && i.licence.state) {
|
|
173
|
+
try {
|
|
174
|
+
head.push(planLine(i.licence));
|
|
175
|
+
} catch {
|
|
176
|
+
/* no plan line */
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Where annotations go here, so no skill writes them in the wrong place.
|
|
180
|
+
if (i.annotationMode === 'external') head.push('Annotations: external — written in `.gal` sidecars under `.guardlink/annotations/<source path>.gal`, never in the source files; where a skill says "beside the code", that means the file\'s sidecar here.');
|
|
181
|
+
else if (i.annotationMode === 'inline') head.push('Annotations: inline — written in comments beside the code they describe.');
|
|
133
182
|
const strandedText = strandedLine(i.stranded, i.base);
|
|
134
183
|
if (strandedText) head.push(strandedText);
|
|
135
184
|
|
|
@@ -189,6 +238,8 @@ export function buildBriefing(inputs) {
|
|
|
189
238
|
else if (i.codegraph === 'locked') tail.push('Code graph: on the Team plan (see Plan above) — skills trace routes by reading until then');
|
|
190
239
|
else if (i.codegraph === 'unavailable') tail.push('Code graph: unavailable — skills trace routes by reading; when the person asks, set it up yourself (bravos-codegraph step 1: bravos setup with their go-ahead, then bravos graph build .)');
|
|
191
240
|
if (i.sast && typeof i.sast === 'object') tail.push(sastLine(i.sast.summary, i.sast.available));
|
|
241
|
+
const dash = dashboardLine(i.dashboard, i.now);
|
|
242
|
+
if (dash) tail.push(dash);
|
|
192
243
|
if (i.workspace) tail.push(...workspaceLines(i.workspace, i.workspaceCounts));
|
|
193
244
|
|
|
194
245
|
const sections = [fix, next, staleSec, tickets].filter((s) => s.items.length > 0);
|
|
@@ -336,11 +387,14 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
|
|
|
336
387
|
const base = ref || 'origin/main';
|
|
337
388
|
const name = branch && branch !== 'HEAD' ? branch : null;
|
|
338
389
|
const later = (args) => git(args, budget());
|
|
339
|
-
const
|
|
390
|
+
const saved = readDashboard(root);
|
|
391
|
+
const [diff, behind, stranded, defaultHead, since] = await Promise.all([
|
|
340
392
|
later(['diff', '--name-only', `${base}...HEAD`]),
|
|
341
393
|
gitStaleness(later, base),
|
|
342
394
|
strandedBranches(later, base, { current: name }),
|
|
343
395
|
ref ? later(['rev-parse', '--verify', `${ref}^{commit}`]) : null,
|
|
396
|
+
// How many commits have landed since the saved dashboard was built; unknown (a rebased-away commit) reads as none.
|
|
397
|
+
saved?.commit ? later(['rev-list', '--count', `${saved.commit}..HEAD`]) : null,
|
|
344
398
|
]);
|
|
345
399
|
return {
|
|
346
400
|
sha: sha ?? 'unknown',
|
|
@@ -350,6 +404,7 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
|
|
|
350
404
|
changedFiles: diff ? diff.split('\n').filter(Boolean) : [],
|
|
351
405
|
stale: staleness({ ...behind, branch: name, base }),
|
|
352
406
|
stranded,
|
|
407
|
+
dashboard: saved ? { ...saved, behind: /^\d+$/.test(since ?? '') ? Number(since) : 0 } : null,
|
|
353
408
|
};
|
|
354
409
|
})();
|
|
355
410
|
|
|
@@ -404,8 +459,10 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
|
|
|
404
459
|
stranded: facts.stranded,
|
|
405
460
|
guardlink,
|
|
406
461
|
changedFiles: facts.changedFiles,
|
|
462
|
+
dashboard: facts.dashboard,
|
|
407
463
|
inFlight,
|
|
408
464
|
intent: readIntent(root),
|
|
465
|
+
annotationMode: readAnnotationMode(root),
|
|
409
466
|
// bravos on PATH: what its probe says (a graph for this commit or not); else codegraph-mcp on PATH means the MCP route.
|
|
410
467
|
codegraph: graphState ?? (whichOnPath('codegraph-mcp', env) ? 'unknown' : 'unavailable'),
|
|
411
468
|
sast: { summary: readSast(root, env), available: sastAvailable(env) },
|
|
@@ -453,11 +510,12 @@ export const MASCOT = [
|
|
|
453
510
|
];
|
|
454
511
|
const MASCOT_WIDTH = 26;
|
|
455
512
|
const LEFT_WIDTH = 36;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
513
|
+
// Two lines, so the plan nudge below the counts has room. The pre-PR gate is named only to people who have it.
|
|
514
|
+
const INTRO_HEAD = 'bravos makes this agent a guardlink power user: it keeps the threat model beside';
|
|
515
|
+
const INTRO_TEAM = 'the code, proves exposures on targets you own, and gates pull requests.';
|
|
516
|
+
const INTRO_FREE = 'the code, proves exposures on targets you own, and rechecks them after a fix.';
|
|
517
|
+
// What the Team plan adds, short enough for one banner line.
|
|
518
|
+
const TEAM_ADDS = 'autopilot, PR gate, SAST, code graph';
|
|
461
519
|
|
|
462
520
|
export const fit = (s, w) => (s.length <= w ? s : s.slice(0, Math.max(0, w - 1)) + '…');
|
|
463
521
|
|
|
@@ -555,6 +613,7 @@ const SKILL_HINT = {
|
|
|
555
613
|
'bravos-templatize': 'write templates',
|
|
556
614
|
bravos: 'where to start',
|
|
557
615
|
'bravos-ship': 'check before a PR',
|
|
616
|
+
'bravos-report': 'write it up',
|
|
558
617
|
};
|
|
559
618
|
|
|
560
619
|
/** Three skills chosen from state, bravos-ship always last; `harness` picks /x (Claude Code), $x (Codex), /skill:x (omp) or the bare name. */
|
|
@@ -570,7 +629,9 @@ export function quickStart(inputs, harness) {
|
|
|
570
629
|
if (arr(g.next?.queue).some((q) => q?.state === 'untested')) picks.push('bravos-templatize');
|
|
571
630
|
const chosen = picks.slice(0, 2);
|
|
572
631
|
if (chosen.length < 2) chosen.unshift('bravos');
|
|
573
|
-
|
|
632
|
+
// The ship check is on the Team plan; an unlicensed person gets a free last step instead.
|
|
633
|
+
if (inputs?.licence?.licensed === false) chosen.push(chosen.includes('bravos-recheck') ? 'bravos-report' : 'bravos-recheck');
|
|
634
|
+
else chosen.push('bravos-ship');
|
|
574
635
|
const sigil = SIGIL[harness] ?? '';
|
|
575
636
|
return chosen.slice(0, 3).map((name) => ({ name, command: sigil + name, hint: SKILL_HINT[name] }));
|
|
576
637
|
}
|
|
@@ -607,13 +668,20 @@ function countsLine(g) {
|
|
|
607
668
|
return line;
|
|
608
669
|
}
|
|
609
670
|
|
|
671
|
+
// @comment -- "The banner's one-line state: intent, code graph, the two hooks, SAST and the setup score. A locked code graph says locked, never on. The full wording is kept while it fits 80 columns; past that it shortens in steps (one word for both hooks when they agree, PR for pre-PR, reach. for reachable, then the bare count) so the line is never cut mid-word."
|
|
610
672
|
function statusLine(i) {
|
|
611
673
|
const intent = i.intent?.status ?? 'unknown';
|
|
612
|
-
const graph = i.codegraph === 'unavailable' ? 'graph off' : i.codegraph === 'not-built' ? 'graph none' : i.codegraph === 'diverged' ? 'graph stale' : 'graph on';
|
|
613
|
-
const sast = i.sast?.summary ? `sast ${i.sast.summary.reachable} reachable` : i.sast?.available?.ok ? 'sast not run' : 'sast off';
|
|
674
|
+
const graph = i.codegraph === 'unavailable' ? 'graph off' : i.codegraph === 'not-built' ? 'graph none' : i.codegraph === 'diverged' ? 'graph stale' : i.codegraph === 'locked' ? 'graph locked' : 'graph on';
|
|
614
675
|
const setup = i.root ? readSetup(i.root, i, i.harness) : null;
|
|
615
676
|
const hook = (on) => (!on ? 'off' : hooksLocked(i) ? 'locked' : 'on');
|
|
616
|
-
|
|
677
|
+
const [pr, auto] = [hook(i.prePr), hook(i.autopilot)];
|
|
678
|
+
const build = (level) => {
|
|
679
|
+
const hooks = level >= 1 && pr === auto ? `hooks ${pr}` : `${level >= 2 ? 'PR' : 'pre-PR'} ${pr} · auto ${auto}`;
|
|
680
|
+
const sast = i.sast?.summary ? `sast ${i.sast.summary.reachable}${level >= 4 ? '' : level >= 3 ? ' reach.' : ' reachable'}` : i.sast?.available?.ok ? 'sast not run' : 'sast off';
|
|
681
|
+
return `intent ${intent} · ${graph} · ${hooks} · ${sast}${setup ? ` · setup ${setup.done}/${setup.total}` : ''}`;
|
|
682
|
+
};
|
|
683
|
+
for (let level = 0; level < 4; level++) if (build(level).length <= BANNER_WIDTH) return build(level);
|
|
684
|
+
return build(4);
|
|
617
685
|
}
|
|
618
686
|
|
|
619
687
|
/**
|
|
@@ -631,7 +699,9 @@ export function buildBanner(inputs, opts = {}) {
|
|
|
631
699
|
[`bravos${opts.version ? ` ${opts.version}` : ''}`, i.repo].filter(Boolean).join(' · '),
|
|
632
700
|
[i.branch, i.sha ? `@ ${i.sha}` : ''].filter(Boolean).join(' '),
|
|
633
701
|
];
|
|
634
|
-
|
|
702
|
+
// The plan sits on the row between the wordmark and the repo facts, so it costs no line; nothing is shown while the licence is unknown.
|
|
703
|
+
const plan = i.licence && typeof i.licence === 'object' && i.licence.state ? planLabel(i.licence) : null;
|
|
704
|
+
const header = ['', '', ...LOGO, plan ? `Plan: ${plan.label}` : '', ...facts];
|
|
635
705
|
const lines = MASCOT.map((row, r) => `${row} ${fit(header[r] ?? '', room)}`);
|
|
636
706
|
|
|
637
707
|
if (i.guardlink === 'missing') {
|
|
@@ -641,7 +711,10 @@ export function buildBanner(inputs, opts = {}) {
|
|
|
641
711
|
}
|
|
642
712
|
const g = i.guardlink ?? {};
|
|
643
713
|
lines.push('', countsLine(g), statusLine(i));
|
|
714
|
+
// One plan nudge at most: hooks this repo registers but this person cannot run, a lapsed licence, or what Team would add.
|
|
644
715
|
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`);
|
|
716
|
+
else if (plan && !plan.licensed && i.licence.state === 'expired') lines.push(`~ licence expired: ${TEAM_ADDS} locked · bravos licence`);
|
|
717
|
+
else if (plan && !plan.licensed) lines.push(`~ Team adds ${TEAM_ADDS} · bravos account activate`);
|
|
645
718
|
if (i.stale) lines.push(`! ${i.branch ?? 'this checkout'} is ${i.stale.behind} behind ${i.base} · findings describe older code · bravos-resync`);
|
|
646
719
|
else if (arr(i.stranded).length > 0) lines.push(`~ annotation work on ${i.stranded[0].branch} is not on ${i.base} · bravos-resync`);
|
|
647
720
|
if (i.shadow) {
|
|
@@ -671,13 +744,15 @@ export function buildBanner(inputs, opts = {}) {
|
|
|
671
744
|
};
|
|
672
745
|
left = ['Top threats', ...(top.length ? top.map(row) : ['none open'])];
|
|
673
746
|
}
|
|
674
|
-
//
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
// By role and by task: the skill each starts with, in the harness's own syntax.
|
|
747
|
+
// By role and by task: the skill each starts with, in the harness's own syntax. Campaigns, the ship check and
|
|
748
|
+
// the code graph are on the Team plan, so an unlicensed person is shown free skills in their place.
|
|
678
749
|
const sk = (name) => (SIGIL[harness] ?? '') + name;
|
|
679
|
-
const
|
|
680
|
-
const
|
|
750
|
+
const free = hooksLocked(i);
|
|
751
|
+
const roles = [['developer', 'bravos-annotate'], ['security', 'bravos-prove'], ['team lead', free ? 'bravos-report' : 'bravos-campaign'], ['new here', 'bravos']];
|
|
752
|
+
const tasks = free
|
|
753
|
+
? [['what next?', 'bravos'], ['app intent', 'bravos-context'], ['after a fix', 'bravos-recheck'], ['write it up', 'bravos-report']]
|
|
754
|
+
: [['what next?', 'bravos'], ['before a PR', 'bravos-ship'], ['after a fix', 'bravos-recheck'], ['find routes', 'bravos-codegraph']];
|
|
755
|
+
const head = lines.splice(0);
|
|
681
756
|
lines.push('', 'If you are'.padEnd(LEFT_WIDTH) + 'To');
|
|
682
757
|
for (let r = 0; r < roles.length; r++) {
|
|
683
758
|
lines.push(fit(`${roles[r][0].padEnd(11)}${sk(roles[r][1])}`, LEFT_WIDTH - 2).padEnd(LEFT_WIDTH) + `${tasks[r][0].padEnd(13)}${sk(tasks[r][1])}`);
|
|
@@ -690,9 +765,13 @@ export function buildBanner(inputs, opts = {}) {
|
|
|
690
765
|
lines.push('Guide (free, no tokens): bravos guide · bravos guide roles · bravos guide tasks');
|
|
691
766
|
|
|
692
767
|
if (i.intent?.status === 'none') {
|
|
693
|
-
lines.push('',
|
|
768
|
+
lines.push('', INTRO_HEAD, free ? INTRO_FREE : INTRO_TEAM, `Start with the Next step above, or ask "help me get started" (${SIGIL[harness] ? `${SIGIL[harness]}bravos` : 'the bravos skill'}).`, 'Hide this banner with BRAVOS_BANNER=off.');
|
|
694
769
|
}
|
|
695
|
-
|
|
770
|
+
// When notes above the threats push the banner past its cap, threat rows give way (one always stays),
|
|
771
|
+
// so the Next and Guide lines are never the ones cut.
|
|
772
|
+
const cap = i.intent?.status === 'none' ? 35 : 29;
|
|
773
|
+
while (head.length + left.length + lines.length > cap && left.length > 2) left.pop();
|
|
774
|
+
const out = [...head, ...left.map((row) => fit(row, BANNER_WIDTH)), ...lines].map((l) => fit(l.trimEnd(), BANNER_WIDTH)).slice(0, cap);
|
|
696
775
|
return (opts.color ? colorize(out, i, opts.theme) : out).join('\n');
|
|
697
776
|
}
|
|
698
777
|
|
|
@@ -704,8 +783,10 @@ export function buildSummary(inputs, opts = {}) {
|
|
|
704
783
|
if (i.guardlink === 'missing') return `${head}\nguardlink not found on PATH — run bravos doctor\n${guide}`;
|
|
705
784
|
const next = quickStart(i, opts.harness).map((q) => q.command).join(' · ');
|
|
706
785
|
const setup = i.root ? readSetup(i.root, i, opts.harness) : null;
|
|
707
|
-
const
|
|
708
|
-
|
|
786
|
+
const plan = i.licence && typeof i.licence === 'object' && i.licence.state ? planLabel(i.licence) : null;
|
|
787
|
+
const trial = !plan || plan.licensed ? '' : i.licence.state === 'expired' ? ' · renew: bravos licence' : ' · Team trial: bravos account activate';
|
|
788
|
+
const third = (setup ? `setup ${setup.done}/${setup.total}${setup.next ? ` · next: ${setup.next.label} · bravos next` : ''} · bravos guide` : guide) + trial;
|
|
789
|
+
return `${head} · ${countsLine(i.guardlink ?? {})}\n${plan ? `plan ${plan.label} · ` : ''}intent ${i.intent?.status ?? 'unknown'} · skills: ${next}\n${third}`;
|
|
709
790
|
}
|
|
710
791
|
|
|
711
792
|
// Brand palette by theme (hooks/lib/palette.mjs). Colour is truecolor ANSI, added after
|
|
@@ -747,6 +828,7 @@ export function colorize(lines, inputs = {}, theme = 'dark') {
|
|
|
747
828
|
const left = runs(chars.slice(0, MASCOT_WIDTH), mascotColour);
|
|
748
829
|
const rest = chars.slice(MASCOT_WIDTH).join('');
|
|
749
830
|
if (n >= 2 && n < 2 + LOGO.length) return left + runs([...rest], wordColour);
|
|
831
|
+
if (n === MASCOT.length - 3) return left + rest.replace(/Plan: (.+)$/, (_m, label) => paint('Plan: ', P.steel) + paint(label, P.light, true));
|
|
750
832
|
if (n === MASCOT.length - 2) return left + rest.replace(/bravos( [\d.]+)?/, (m) => paint(m, P.green, true)).replace(/ · (.+)$/, (_m, r) => ` · ${paint(r, P.light, true)}`);
|
|
751
833
|
if (n === MASCOT.length - 1) return left + rest.replace(/\S.*$/, (m) => paint(m, P.steel));
|
|
752
834
|
return left + rest;
|
|
@@ -756,7 +838,7 @@ export function colorize(lines, inputs = {}, theme = 'dark') {
|
|
|
756
838
|
return line.split(/((?:\/skill:|\/|\$)?bravos(?:-[a-z]+)?(?= |$))/).map((part, k) => (k % 2 ? paint(part, P.green) : part)).join('');
|
|
757
839
|
}
|
|
758
840
|
if (/^! your user-level bravos/.test(line)) return paint(line, P.red, true);
|
|
759
|
-
if (/^~ repo bravos /.test(line)) return paint(line, P.steel);
|
|
841
|
+
if (/^~ (repo bravos |Team adds |licence expired)/.test(line)) return paint(line, P.steel);
|
|
760
842
|
if (/^Tip: /.test(line)) return paint('Tip: ', P.green, true) + paint(line.slice(5), P.light);
|
|
761
843
|
if (/^Next: /.test(line)) {
|
|
762
844
|
const [what, rest = ''] = line.slice(6).split(' → ');
|
|
@@ -780,7 +862,7 @@ export function colorize(lines, inputs = {}, theme = 'dark') {
|
|
|
780
862
|
.replace(/coverage \d+%( \(\d+\/\d+\))?/, (m) => paint(m, P.green))
|
|
781
863
|
.replace(/((?:\/skill:|\/|\$)bravos(?:-[a-z]+)?)(\s+)([^\x1b]+)$/, (_m, cmd, sp, hint) => `${paint(cmd, P.green)}${sp}${paint(hint, P.steel)}`)
|
|
782
864
|
.replace(/(?<![\w/$:-])((?:\/skill:|\/|\$)bravos(?:-[a-z]+)?)(?![\w-])(?![^\x1b]*\x1b\[0m)/g, (m) => paint(m, P.green));
|
|
783
|
-
if (/^(Start with|Hide this|bravos makes|
|
|
865
|
+
if (/^(Start with|Hide this|bravos makes|the code, proves)/.test(line)) {
|
|
784
866
|
l = line.split(/((?:\/skill:|\/|\$)bravos-[a-z]+)/).map((part, k) => (k % 2 ? paint(part, P.green) : part ? paint(part, P.steel) : '')).join('');
|
|
785
867
|
}
|
|
786
868
|
return l;
|
package/hooks/lib/licence.mjs
CHANGED
|
@@ -443,6 +443,19 @@ export function planLine(v, now = Math.floor(Date.now() / 1000)) {
|
|
|
443
443
|
return `Plan: ${tierName} · ${v.seats} seat${v.seats === 1 ? '' : 's'} · renews ${date(v.expiresAt)}`;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
+
// @comment -- "The short plan label for one-line places (the banner beside the mascot, Codex's summary, the watch header): Free, Team trial with days left, Team with seats (and grace), or expired. Never throws on a partial record; anything it cannot read is Free."
|
|
447
|
+
export function planLabel(v, now = Math.floor(Date.now() / 1000)) {
|
|
448
|
+
if (!v || typeof v !== 'object') return { label: 'Free', licensed: false };
|
|
449
|
+
const tier = typeof v.tier === 'string' && v.tier ? v.tier.charAt(0).toUpperCase() + v.tier.slice(1) : 'Free';
|
|
450
|
+
if (v.licensed) {
|
|
451
|
+
if (v.trial) return { label: `${tier} trial · ${days(Number(v.trial.endsAt) - now) || 0}d left`, licensed: true };
|
|
452
|
+
const seats = Number.isFinite(v.seats) ? ` · ${v.seats} seat${v.seats === 1 ? '' : 's'}` : '';
|
|
453
|
+
return { label: `${tier}${seats}${v.state === 'grace' ? ' · in grace' : ''}`, licensed: true };
|
|
454
|
+
}
|
|
455
|
+
if (v.state === 'expired') return { label: `${tier} · expired`, licensed: false };
|
|
456
|
+
return { label: 'Free', licensed: false };
|
|
457
|
+
}
|
|
458
|
+
|
|
446
459
|
// @comment -- "What a gate says when a paid feature is asked for without the licence for it: what the feature does, that it is on the Team plan, and the two ways to get it. Never silent, never a stack trace."
|
|
447
460
|
export function refusal(v, feature, what) {
|
|
448
461
|
const label = PAID_FEATURE_LABELS[feature] ?? feature;
|
package/hooks/lib/setup.mjs
CHANGED
|
@@ -97,7 +97,7 @@ export function readSetup(root, i = {}, harness = 'other') {
|
|
|
97
97
|
// Paid steps on an unlicensed machine say so in their `how` and are never the next step: the score
|
|
98
98
|
// counts what the person can do today, and the plan line (briefing, doctor, watch) says how to change it.
|
|
99
99
|
const licensed = !!i.licence?.licensed;
|
|
100
|
-
const paid = { sast: 'SAST', autopilot: 'autopilot', prepr: 'the pre-PR gate', ci: 'the CI gate and nightly' };
|
|
100
|
+
const paid = { graph: 'the code graph', sast: 'SAST', autopilot: 'autopilot', prepr: 'the pre-PR gate', ci: 'the CI gate and nightly' };
|
|
101
101
|
for (const x of items) {
|
|
102
102
|
if (!licensed && x.id in paid && !x.on) {
|
|
103
103
|
x.paid = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugb-technologies/bravos",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|
package/skills/bravos/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: "Start here in any repo bravos is installed in: reads the security
|
|
|
13
13
|
|
|
14
14
|
## Do
|
|
15
15
|
|
|
16
|
-
1. If the user is new or asks how to start, give the guided start and stop there: read the briefing's `Setup n/9` line (or run `bravos next --json`); say in three sentences what bravos does here; show what is on and the next step with its exact command and what it unlocks; offer three things to try now that fit the repo, in setup order
|
|
16
|
+
1. If the user is new or asks how to start, give the guided start and stop there: read the briefing's `Setup n/9` line (or run `bravos next --json`); say in three sentences what bravos does here; show what is on and the next step with its exact command and what it unlocks; offer three things to try now that fit the repo and the plan, in setup order. On the Free plan (the briefing's `Plan:` line) offer only free steps: intent none → learn what the app intends; low coverage → annotate the top files; untested exposures → prove the top 3; mention the Team plan once, in one sentence, only if they ask what else there is. On Team the code graph comes first because every later step reads it (graph off → build it with `bravos graph build . --scip no-exec`; intent none → learn what the app intends; low coverage → annotate the top files; then SAST, which reads the annotations; untested exposures → prove the top 3; a branch with changes → the ship check). Say each in plain words with the skill named second; point to `bravos guide roles`, and mention once that `bravos watch` in a second terminal pane shows all of this live while they work. Run a setup command that changes config or hooks only after the person agrees. Otherwise read the session-start briefing. It opens with `GuardLink security picture (bravos) — <repo> @ <sha>, base <base>`. If none is in context (a harness that ran no hook), run `node .bravos/hooks/session-start.mjs --briefing` once: it prints the briefing as plain text. Pull out: the `Open exposures:` line (severity counts, coverage, worklist), `FIX NOW — confirmed exploitable`, `Next to test or fix (guardlink hypothesis next)`, `Went stale in files you changed since <base>`, `Open tickets`, `In flight by teammates`, the `Code graph:` state, and the `Intent:` line (none or draft means severities are not yet calibrated to the product; offer bravos-context). `Open exposures: unknown (guardlink ci unavailable)` means the picture is unknown, not empty. bravos keeps no state of its own (`.bravos/` holds only the hook and the skills lock); when the briefing says a tool is unavailable, `bravos doctor` reports which tools are present. When the briefing has a `Workspace:` line, this repo is one service of a larger app: changes belong in the service's own repo, questions across services go to the app folder it names, and `bravos workspace show` lists the services, their URLs and the calls between them.
|
|
17
17
|
2. Explain the evidence loop in five lines when the user is new to it or asks what a finding means:
|
|
18
18
|
claim (an annotation says code is exposed or mitigated) → testable template → authorized run against a target the user owns → verified outcome → recheck when the code changes.
|
|
19
19
|
Three states are independent of each other: open / mitigated / accepted · untested / confirmed / refuted · verified / stale. A mitigated claim can still be untested; a confirmed one can go stale.
|
|
@@ -27,13 +27,14 @@ description: "Start here in any repo bravos is installed in: reads the security
|
|
|
27
27
|
proving a finding, testing whether an exposure is exploitable → bravos-prove (after bravos-env).
|
|
28
28
|
a fix landed, stale claims, closing a security ticket → bravos-recheck.
|
|
29
29
|
the briefing says the branch is far behind its base, annotation work sits on an idle branch, a branch was moved or abandoned → bravos-resync.
|
|
30
|
+
"what is open?", "show me the findings", "is there a dashboard?" → answer in two or three lines from the briefing, then offer the page: `bravos dashboard` writes one self-contained HTML page (GuardLink's threat model, who introduced and fixed each exposure, what changed since the default branch; on the Team plan with the code graph built, also a Code graph tab: a map of where the risk sits, owners and history, coupling, the attack surface and entry points) under `.bravos/dashboard/`, git-ignored, and opens it in their browser. Run it when they say yes or asked to see it; add `--no-open` and give the path when no browser can open here, and `--no-blame` when they will share the page. Always run the command: it rebuilds the page from the code as it stands, and on the Team plan rebuilds a code graph that is missing or behind first. Never open or point to a saved page instead, and when the briefing's `Dashboard:` line says the saved page is out of date, say so.
|
|
30
31
|
write up the assessment, a finding, a retest or a brief for leadership → bravos-report.
|
|
31
32
|
static analysis, dependency, secret or IaC findings → bravos-sast; "what did SAST find" → `bravos sast candidates` (the briefing's `SAST:` line says whether a run exists, or that SAST is unavailable).
|
|
32
33
|
keep annotating while I work, nightly or periodic runs → bravos-schedule.
|
|
33
34
|
security CI, a PR check, code-scanning upload → bravos-cicd.
|
|
34
35
|
reach a goal over many rounds ("100% coverage", "test every exposure", "until done", autopilot, a campaign) → bravos-campaign.
|
|
35
36
|
The briefing's `Plan:` line says which tier this machine is on. On Free, the research loop (context, annotate, templatize, env, prove, recheck, report, watch) is all there; the pre-PR gate, CI and nightly, schedule, workspaces, campaign, SAST and the code graph are on Team. When the request needs one of those, still name the right skill, say in one sentence that it is on the Team plan (`bravos account activate` starts a 30-day trial, no card), and offer the nearest free step instead; never pretend the feature ran.
|
|
36
|
-
4. bravos adds method and memory to what you can already do; it never caps it. Budgets in the skills are defaults: exceed them when the work calls for it and say why. Effort (low, medium, high, max) comes from the user's words, else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. Only the safety rules under each skill's Never are hard.
|
|
37
|
+
4. bravos adds method and memory to what you can already do; it never caps it. Budgets in the skills are defaults: exceed them when the work calls for it and say why. Effort (low, medium, high, max) comes from the user's words, else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. Only the safety rules under each skill's Never are hard. Two of them hold in every skill: before the first commit of a session ask the person once (commit now, or leave the files for them to review), even where a skill says to commit, unless they already asked for commits (a campaign, a schedule); and write annotations where the briefing's `Annotations:` line says, a `.gal` sidecar in external mode and a comment above the code in inline mode.
|
|
37
38
|
5. Name the next step in one line, taken from the briefing: a `FIX NOW` item first, then a stale claim in a file the user changed, then the top `guardlink hypothesis next` item, then coverage.
|
|
38
39
|
6. When the user takes an item to work on and it already has a ticket in their tracker, record the pick-up beside its claim so the hive can see it: write `@ticket #<threat> on #<asset> <ticket-ref> sla "<label>" by <assignee> until <YYYY-MM-DD>` directly beside the claim's `@exposes`, clauses in that order, dropping `sla "<label>"` and `until <YYYY-MM-DD>` unless the user gives them, then run `guardlink validate .`. The briefing's `Open tickets` line and `guardlink lookup tickets` show it to teammates; removing the line is how the ticket leaves the model.
|
|
39
40
|
|
|
@@ -26,7 +26,7 @@ description: "Keep the GuardLink threat model correct and growing, in this sessi
|
|
|
26
26
|
8. Gate: run `guardlink lint . --since <start> --json`. For each entry in `violations[]`, apply its `fix`. Repeat until `summary.errors` is 0. A violation on a line you did not write this session is not yours: leave the line as it is and report it to the user.
|
|
27
27
|
9. Run `guardlink validate .` and fix what it reports in the lines you wrote.
|
|
28
28
|
10. Run `guardlink ci -f json` again and report `+<files>, <p0>% → <p1>%, <errors> lint errors`. Deep only: repeat steps 4–10 once per round, and stop when `coverage` comes back empty or a round adds no claims.
|
|
29
|
-
11. On a normal coding turn keep annotations with the code change and preserve the user's staged and uncommitted edits. For a requested standalone coverage slice, commit the slice on its own: `git add` only the annotated files, message `annotate: <n> files, <playbook>`. Ship it as a small PR or on the feature branch, whichever the team does.
|
|
29
|
+
11. On a normal coding turn keep annotations with the code change and preserve the user's staged and uncommitted edits. For a requested standalone coverage slice, with the person's go-ahead (ask once per session unless they already asked for commits), commit the slice on its own: `git add` only the annotated files, message `annotate: <n> files, <playbook>`. Ship it as a small PR or on the feature branch, whichever the team does.
|
|
30
30
|
12. Read `guardlink hypothesis list --json`. Keep each changed exposure's stable key, source location, sidecar location when applicable, and tested state. Include untested claims with a declared mitigation. Hand new claims to bravos-templatize for a concrete kit; expired or previously tested claims go to bravos-recheck. Apply the recorded proving choice before execution: auto follows bravos-env and bravos-prove in its authorized scope; ask seeks a decision; schedule leaves the claim queued; none records that it was not tested. Evidence from a real run is required before marking a claim confirmed or refuted. Hand the change to bravos-ship before a PR.
|
|
31
31
|
|
|
32
32
|
## Never
|
|
@@ -45,6 +45,7 @@ description: "Keep the GuardLink threat model correct and growing, in this sessi
|
|
|
45
45
|
- You reported the delta line from step 10, the files left in `skipped`, and any lint violation on a line you did not write.
|
|
46
46
|
- Each new `@exposes` carries a severity with its reason, and every "intended?" `@audit` is listed for the user.
|
|
47
47
|
- Each new claim's state is clear: open or mitigated (none accepted by you), untested (an annotation alone confirms or refutes nothing), and verified or stale per `guardlink ci`. Say what was not tested. Do not call the code clean; the lint gate judges annotations, not code.
|
|
48
|
+
- If a dashboard was built earlier (the briefing's `Dashboard:` line, or one you opened this session), you said it is now behind these changes and offered to rebuild it with `bravos dashboard`.
|
|
48
49
|
|
|
49
50
|
## What it leaves for the next skill
|
|
50
51
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @comment -- "Pure slice picker for bravos-annotate: ranks the worklist (entry points first, tests/generated/CI last), decides which files this session or its subagents annotate, skips files teammates have in open PRs, and splits the pick into disjoint directory-coherent batches; dependency-free, copied
|
|
1
|
+
// @comment -- "Pure slice picker for bravos-annotate: ranks the worklist (entry points first, tests/generated/CI last), decides which files this session or its subagents annotate, skips files teammates have in open PRs, and splits the pick into disjoint directory-coherent batches; dependency-free, copied into target repos with this annotation turned into a plain comment."
|
|
2
2
|
|
|
3
3
|
const arr = (v) => (Array.isArray(v) ? v : []);
|
|
4
4
|
const dirOf = (p) => (p.includes('/') ? p.slice(0, p.lastIndexOf('/')) : '');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @comment -- "Entry for bravos-annotate: gathers git diff, guardlink worklist/coverage and open PRs via read-only spawnSync calls, runs pickSlice and prints bravos.slice/v2 JSON (coverage, coverage_detail, batches, tiers); dependency-free, copied
|
|
2
|
+
// @comment -- "Entry for bravos-annotate: gathers git diff, guardlink worklist/coverage and open PRs via read-only spawnSync calls, runs pickSlice and prints bravos.slice/v2 JSON (coverage, coverage_detail, batches, tiers); dependency-free, copied into target repos with its annotations turned into plain comments."
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { closeSync, openSync, readSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
@@ -16,7 +16,7 @@ description: "Ask the repo's code graph (codegraph-mcp) one bounded question —
|
|
|
16
16
|
**Plan check first.** The code graph is on the Team plan. Run `bravos licence --json` once per session (the briefing's `Plan:` line says the same); if `licensed` is false, tell the person in two sentences what this skill would do here and that it needs a Team licence — `bravos account activate` starts a 30-day trial with no card, or https://account.bugb.io/pricing — then stop, and do nothing else from this skill. A licence in grace still counts.
|
|
17
17
|
|
|
18
18
|
1. Ask the graph one bounded question per call; a graph answer replaces reading or grepping the tree. There are two ways in, with the same answers: the MCP tools (`codegraph_attack_surface` …) when the `codegraph` server is connected, or `bravos graph <question> --json` in the shell, where the question is the tool name without `codegraph_` and with hyphens (`codegraph_attack_surface` → `bravos graph attack-surface --json`, `codegraph_callers` → `bravos graph callers '<file>::<symbol>' --json`; `bravos graph --json` lists every question and its arguments). The shell route needs no MCP reconnect and works in every harness. The briefing's `Code graph:` line says which route is there. If neither is (no codegraph-mcp), set it up yourself: `bravos setup --check` reports what is missing without changing anything; show the person `bravos setup --dry-run --codegraph` and with their go-ahead run `bravos setup --codegraph` (it fetches the signed bundle through the account portal and verifies it before anything lands). If an install fails, quote its error and give the exact command for their own terminal; until then say "code graph unavailable; the other skills read the code instead" and answer by reading. Read the effort: the user's words ("at high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. It sets a starting budget, not a limit; go beyond it when the work needs it and say why in one line. Starting budget — low: the one question asked; medium: whatever questions the task needs; high: start from `codegraph_attack_surface`; max: the full attack surface plus `codegraph_impact` on every changed symbol.
|
|
19
|
-
2. Build or refresh the graph when an answer says there is none for this repository, or its `graph_currency` is `diverged`: `bravos graph build . --scip no-exec` indexes without running the repository's build scripts (`--scip auto` and `--isolate` run them; use those only on a repo the user trusts and only when they say so). A build that reports `semantic <language>: off` lacks that language's type checker; say that calls through interfaces may not connect and that `bravos setup --indexers` (with their go-ahead) adds it. For the MCP route, `bravos sync` registers the server from the bravos install; the person reconnects MCP (`/mcp` in Claude Code) to load it. In a bravos workspace, build one graph over the app folder (`bravos graph build <app folder> --scip no-exec`, the folder the briefing's `Workspace:` line names) and ask cross-service questions there: only a graph that holds both services links one service's HTTP, gRPC, GraphQL or OpenAPI client call to the other's handler (`callees` shows `via_framework`). A graph built inside one member stops at its own repository.
|
|
19
|
+
2. Build or refresh the graph when an answer says there is none for this repository, or its `graph_currency` is `diverged`: `bravos graph build . --scip no-exec` indexes without running the repository's build scripts (`--scip auto` and `--isolate` run them; use those only on a repo the user trusts and only when they say so). A build that reports `semantic <language>: off` lacks that language's type checker; say that calls through interfaces may not connect and that `bravos setup --indexers` (with their go-ahead) adds it. For the MCP route, `bravos sync` registers the server from the bravos install; the person reconnects MCP (`/mcp` in Claude Code) to load it. In a bravos workspace, build one graph over the app folder (`bravos graph build <app folder> --scip no-exec`, the folder the briefing's `Workspace:` line names) and ask cross-service questions there: only a graph that holds both services links one service's HTTP, gRPC, GraphQL or OpenAPI client call to the other's handler (`callees` shows `via_framework`). A graph built inside one member stops at its own repository. A graph belongs to the commit it was built at: after a commit it answers nothing until it is rebuilt, so rebuild before the next graph question and carry on with other work while it builds. `bravos dashboard` rebuilds a missing or behind graph itself and draws it as the Code graph tab (the map, owners and history, coupling, the attack surface, entry points), which is the view to offer a person who wants to see the graph.
|
|
20
20
|
3. Pick the one tool that answers the question:
|
|
21
21
|
find a symbol → `codegraph_search`
|
|
22
22
|
routes → `codegraph_routes`
|