@bugb-technologies/bravos 1.5.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +81 -9
- package/dist/context.js +387 -0
- package/dist/dashboard.js +19 -5
- package/dist/guide.js +5 -2
- package/dist/help.js +19 -0
- package/dist/palette.js +4 -4
- package/dist/review-server.js +4 -4
- package/dist/review.js +103 -18
- package/dist/rules.js +218 -0
- package/dist/uninstall.js +6 -0
- package/dist/watch-frame.js +67 -42
- package/dist/watch.js +21 -7
- package/docs/GUIDE.md +20 -2
- package/docs/UPGRADING.md +28 -0
- package/hooks/lib/autopilot.mjs +29 -7
- package/hooks/lib/briefing.mjs +214 -171
- package/hooks/lib/context.mjs +522 -0
- package/hooks/lib/palette.mjs +4 -4
- package/hooks/lib/pre-pr.mjs +70 -0
- package/hooks/lib/setup.mjs +5 -2
- package/hooks/session-start.mjs +24 -2
- package/package.json +1 -1
- package/skills/bravos/SKILL.md +1 -1
- package/skills/bravos-annotate/SKILL.md +5 -3
- package/skills/bravos-annotate/scripts/lib/gate.mjs +45 -0
- package/skills/bravos-annotate/scripts/slice.mjs +10 -0
- package/skills/bravos-campaign/SKILL.md +1 -1
- package/skills/bravos-context/SKILL.md +17 -10
- package/skills/bravos-context/intent.example.md +14 -1
- package/skills/bravos-recheck/SKILL.md +1 -1
- package/skills/bravos-ship/SKILL.md +2 -1
- package/skills/bravos-templatize/SKILL.md +1 -1
- package/templates/dashboard/dashboard.html +97 -0
- package/templates/review/review.html +368 -123
- package/templates/workflows/bravos-nightly-claude.yml +36 -2
- package/templates/workflows/bravos-nightly-codex.yml +36 -2
- package/templates/workflows/bravos-nightly-copilot.yml +23 -0
- package/templates/workflows/bravos-pr-gate.yml +76 -0
package/dist/watch-frame.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
1
2
|
import { bgFor, fgFor } from './palette.js';
|
|
2
3
|
// @comment -- "Draws bravos watch's frames: a header bar, a row of number tiles, bordered panels (setup, threat model, test next, top threats and assets, code graph, SAST, branch and team, the model's size, activity) arranged in three, two or one columns by terminal width, a scrollable body and a key bar. Pure: text in, text out. Colour is added per segment after layout, so the plain and coloured frames have the same characters, and every glyph that carries meaning (severity, bars) differs in plain text too."
|
|
3
4
|
/* ------------------------------------------------------------------ segments */
|
|
@@ -15,6 +16,8 @@ const C = {
|
|
|
15
16
|
amber: 'amber',
|
|
16
17
|
white: 'white',
|
|
17
18
|
line: 'line',
|
|
19
|
+
warm: 'warm',
|
|
20
|
+
cool: 'cool',
|
|
18
21
|
};
|
|
19
22
|
const s = (t, c, b, bg) => ({ t, c, b, bg });
|
|
20
23
|
const len = (l) => l.reduce((n, x) => n + [...x.t].length, 0);
|
|
@@ -97,20 +100,20 @@ function sevBar(by, width) {
|
|
|
97
100
|
big.w = Math.max(0, big.w + width - used);
|
|
98
101
|
return parts.filter((p) => p.w > 0).map((p) => s(sevGlyph[p.k].repeat(p.w), sevColor(p.k)));
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
// A solid warm chip signals attention (pending setup or a confirmed hypothesis).
|
|
104
|
+
// A shaded cool chip marks a completed step or a refuted hypothesis.
|
|
105
|
+
const chip = (attention) => attention ? s('██ ', C.warm) : s('░░ ', C.cool);
|
|
106
|
+
/** One chip per tested hypothesis while they fit. Beyond that, show the same
|
|
107
|
+
* distribution proportionally and retain both outcomes when both are present. */
|
|
108
|
+
function outcomeChips(confirmed, refuted, inner) {
|
|
109
|
+
const total = confirmed + refuted;
|
|
103
110
|
if (!total)
|
|
104
|
-
return [s('
|
|
105
|
-
const
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
out.push(s(p.glyph.repeat(w), p.c));
|
|
111
|
-
used += Math.max(0, w);
|
|
112
|
-
});
|
|
113
|
-
return out;
|
|
111
|
+
return [s('No tested outcomes yet', C.steel)];
|
|
112
|
+
const slots = Math.min(total, Math.floor(inner / 3));
|
|
113
|
+
let warm = Math.round(confirmed / total * slots);
|
|
114
|
+
if (confirmed && refuted)
|
|
115
|
+
warm = Math.max(1, Math.min(slots - 1, warm));
|
|
116
|
+
return Array.from({ length: slots }, (_, i) => chip(i < warm));
|
|
114
117
|
}
|
|
115
118
|
const SPARK = '▁▂▃▄▅▆▇█';
|
|
116
119
|
/** A sparkline of values, scaled between their min and max; flat when they do not move. */
|
|
@@ -163,9 +166,9 @@ function tiles(items, width) {
|
|
|
163
166
|
});
|
|
164
167
|
return rows;
|
|
165
168
|
}
|
|
166
|
-
function setupPanel(sn
|
|
169
|
+
function setupPanel(sn) {
|
|
167
170
|
const pct = sn.setup.total ? Math.round((sn.setup.done / sn.setup.total) * 100) : 0;
|
|
168
|
-
const body = [
|
|
171
|
+
const body = [sn.setup.items.map((item) => chip(!item.on)), [s(`${sn.setup.total - sn.setup.done} pending · ${sn.setup.done} complete`, C.steel)]];
|
|
169
172
|
for (const x of sn.setup.items) {
|
|
170
173
|
const isNext = sn.setup.next && x.label === sn.setup.next.label;
|
|
171
174
|
body.push(x.on ? [s('✔ ', C.green), s(x.label)] : isNext ? [s('▸ ', C.green, true), s(x.label, C.green, true)] : [s('· ', C.slate), s(x.label, C.steel)]);
|
|
@@ -177,7 +180,7 @@ function setupPanel(sn, inner) {
|
|
|
177
180
|
}
|
|
178
181
|
else
|
|
179
182
|
body.push([], [s('everything bravos can use here is on', C.green)]);
|
|
180
|
-
return { title: 'SETUP', right: `${sn.setup.done}/${sn.setup.total}
|
|
183
|
+
return { title: 'SETUP', right: `${sn.setup.done}/${sn.setup.total} · ${pct}%`, rightColor: C.green, body };
|
|
181
184
|
}
|
|
182
185
|
function modelPanel(sn, inner, history) {
|
|
183
186
|
if (!sn.counts) {
|
|
@@ -193,13 +196,10 @@ function modelPanel(sn, inner, history) {
|
|
|
193
196
|
const L = sn.ledger;
|
|
194
197
|
const total = L.untested + L.confirmed + L.refuted + L.retest;
|
|
195
198
|
body.push([]);
|
|
196
|
-
body.push([s('tested ', C.steel), s(`${L.confirmed + L.refuted}/${total}`, C.light, true)
|
|
197
|
-
body.push(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
{ n: L.refuted, glyph: '▒', c: C.green },
|
|
201
|
-
{ n: L.untested, glyph: '░', c: C.line },
|
|
202
|
-
], inner));
|
|
199
|
+
body.push([s('tested ', C.steel), s(`${L.confirmed + L.refuted}/${total}`, C.light, true)]);
|
|
200
|
+
body.push(outcomeChips(L.confirmed, L.refuted, inner));
|
|
201
|
+
body.push([s(`${L.confirmed} confirmed`, C.warm), s(' · ', C.steel), s(`${L.refuted} refuted`, C.cool)]);
|
|
202
|
+
body.push([s(`${L.untested} untested · ${L.retest} awaiting retest`, C.steel)]);
|
|
203
203
|
}
|
|
204
204
|
if (sn.boundaries) {
|
|
205
205
|
const B = sn.boundaries;
|
|
@@ -458,17 +458,30 @@ const kindIcon = {
|
|
|
458
458
|
report: ['❏', C.green],
|
|
459
459
|
workspace: ['⇄', C.blue],
|
|
460
460
|
};
|
|
461
|
+
// @comment -- "Event text can include repository-controlled filenames and local log contents. Display it as plain text in the activity panel and detail view, without terminal control sequences or injected rows."
|
|
462
|
+
const eventText = (value) => stripVTControlCharacters(value).replace(/[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, ' ').trim();
|
|
463
|
+
export function activityOverlay(events) {
|
|
464
|
+
const rows = [`ACTIVITY · ${events.length} retained event${events.length === 1 ? '' : 's'}`];
|
|
465
|
+
if (!events.length)
|
|
466
|
+
return [...rows, '', 'No changes recorded yet.'];
|
|
467
|
+
for (const event of [...events].reverse()) {
|
|
468
|
+
rows.push('', `${eventText(event.at)} ${eventText(event.kind)}`, eventText(event.text));
|
|
469
|
+
if (event.hint)
|
|
470
|
+
rows.push('→ ' + eventText(event.hint));
|
|
471
|
+
}
|
|
472
|
+
return rows;
|
|
473
|
+
}
|
|
461
474
|
function activityPanel(events, max, title = 'ACTIVITY') {
|
|
462
475
|
const body = [];
|
|
463
476
|
if (!events.length)
|
|
464
477
|
body.push([s('nothing yet — changes appear here as you and the agent work', C.steel)]);
|
|
465
478
|
for (const e of events.slice(-max).reverse()) {
|
|
466
479
|
const [icon, c] = kindIcon[e.kind] ?? ['·', C.steel];
|
|
467
|
-
body.push([s(time(e.at) + ' ', C.steel), s(icon + ' ', c), s(e.kind === 'autopilot' ? 'autopilot ' : '', C.green, true), s(e.text, e.kind === 'confirmed' ? C.red : undefined)]);
|
|
480
|
+
body.push([s(time(e.at) + ' ', C.steel), s(icon + ' ', c), s(e.kind === 'autopilot' ? 'autopilot ' : '', C.green, true), s(eventText(e.text), e.kind === 'confirmed' ? C.red : undefined)]);
|
|
468
481
|
if (e.hint)
|
|
469
|
-
body.push([s(' → ' + e.hint, C.slate)]);
|
|
482
|
+
body.push([s(' → ' + eventText(e.hint), C.slate)]);
|
|
470
483
|
}
|
|
471
|
-
return { title, right: `${events.length} event${events.length === 1 ? '' : 's'}`, body };
|
|
484
|
+
return { title, right: `${events.length} event${events.length === 1 ? '' : 's'} · a full log`, body };
|
|
472
485
|
}
|
|
473
486
|
/** Three columns from 150, two from 110, one bordered column from 80, compact below. */
|
|
474
487
|
export const layoutFor = (width, compact = false) => (compact || width < 80 ? 'compact' : width >= 150 ? 'wide' : width >= 110 ? 'two' : 'pane');
|
|
@@ -478,6 +491,7 @@ const KEYS = [
|
|
|
478
491
|
['d', 'dashboard'],
|
|
479
492
|
['g', 'graph'],
|
|
480
493
|
['t', 'test-next'],
|
|
494
|
+
['a', 'activity'],
|
|
481
495
|
['i', 'intent'],
|
|
482
496
|
['p', 'report'],
|
|
483
497
|
['s', 'services'],
|
|
@@ -489,7 +503,7 @@ const KEYS = [
|
|
|
489
503
|
['q', 'quit'],
|
|
490
504
|
];
|
|
491
505
|
// Keys dropped first when the bar does not fit; quit always stays.
|
|
492
|
-
const DROP_ORDER = ['c', 'u', 'o', 's', 'd', '?', 'i', 'p', 't', 'r', 'g', 'j/k', 'n'];
|
|
506
|
+
const DROP_ORDER = ['c', 'u', 'o', 's', 'd', '?', 'i', 'p', 't', 'r', 'g', 'a', 'j/k', 'n'];
|
|
493
507
|
function keyBar(width) {
|
|
494
508
|
let keys = KEYS;
|
|
495
509
|
const chips = (ks) => ks.flatMap(([k, label]) => [s(` ${k} `, C.ink, true, C.green), s(` ${label} `, C.steel)]);
|
|
@@ -500,18 +514,29 @@ function keyBar(width) {
|
|
|
500
514
|
}
|
|
501
515
|
return chips(keys);
|
|
502
516
|
}
|
|
517
|
+
// The supplied Bravos SVG sampled at 12 × 8 pixels, two vertical pixels per cell.
|
|
518
|
+
const WATCH_MARK = [' ▄████▄ ', '▄▄ ██████ ▄▄', '██▄█▄██▄█▄██', ' ▄▄██▀▀██▄▄ '];
|
|
503
519
|
function header(sn, width, opts) {
|
|
504
|
-
const
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
520
|
+
const status = s(opts.status ?? '● live', opts.status?.startsWith('updating') ? C.amber : C.green, true);
|
|
521
|
+
const plan = s(sn.plan.label, sn.plan.licensed ? C.green : C.amber);
|
|
522
|
+
const branch = `${sn.branch ?? '(detached)'} @ ${sn.sha}`;
|
|
523
|
+
const stats = opts.stats;
|
|
524
|
+
const refresh = stats ? `refresh #${stats.refreshes}${stats.lastMs !== null ? ` · ${(stats.lastMs / 1000).toFixed(1)}s` : ''} · ` : '';
|
|
525
|
+
const cost = s(refresh + '0 tokens', C.steel);
|
|
526
|
+
if (opts.compact || width < 80 || (opts.height !== undefined && opts.height < 16)) {
|
|
527
|
+
const brand = [s('bravos watch', C.green, true), s(' · by bugb', C.steel)];
|
|
528
|
+
const context = [s(` ${sn.repo} ${branch} `, C.steel), plan, s(' '), cost];
|
|
529
|
+
return [[...fitLine([...brand, ...context], Math.max(0, width - len([status]) - 2)), s(' '), status]];
|
|
530
|
+
}
|
|
531
|
+
const info = [
|
|
532
|
+
[s('bravos watch', C.light, true)], [s('by bugb', C.steel)],
|
|
533
|
+
[s(sn.repo, C.light, true), s(` ${branch}`, C.steel)], [plan],
|
|
510
534
|
];
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
535
|
+
const right = [[status], [cost], [], []];
|
|
536
|
+
return WATCH_MARK.map((mark, i) => {
|
|
537
|
+
const left = [s(mark, C.green), s(' '), ...info[i]];
|
|
538
|
+
return [...fitLine(left, width - len(right[i]), true), ...right[i]];
|
|
539
|
+
});
|
|
515
540
|
}
|
|
516
541
|
function tileItems(sn) {
|
|
517
542
|
const c = sn.counts;
|
|
@@ -554,20 +579,20 @@ export function renderFrame(sn, events, opts) {
|
|
|
554
579
|
const color = opts.color ?? false;
|
|
555
580
|
const layout = layoutFor(width, opts.compact);
|
|
556
581
|
const history = opts.history ?? [];
|
|
557
|
-
const top =
|
|
582
|
+
const top = header(sn, width, opts);
|
|
558
583
|
let body;
|
|
559
584
|
if (layout === 'compact') {
|
|
560
585
|
const c = sn.counts;
|
|
561
586
|
top.push([s(`setup ${sn.setup.done}/${sn.setup.total}`, C.green, true), s(sn.setup.next ? ` · next ${sn.setup.next.cta}` : '', C.steel)], c ? [s(`open ${c.open}`, C.amber, true), s(` · high ${(c.bySeverity.critical ?? 0) + (c.bySeverity.high ?? 0)}`, C.red), s(` · confirmed ${c.confirmed} · coverage ${sn.coverage?.percent ?? '?'}%`)] : [s('counts unknown', C.amber)]);
|
|
562
587
|
const w = width;
|
|
563
|
-
body = stack([activityPanel(events, 4, 'CHANGED JUST NOW'), ...opt(servicesPanel(sn, w - 4)), nextPanel(sn, 3, w - 4), modelPanel(sn, w - 4, history), reportPanel(sn, w - 4), setupPanel(sn
|
|
588
|
+
body = stack([activityPanel(events, 4, 'CHANGED JUST NOW'), ...opt(servicesPanel(sn, w - 4)), nextPanel(sn, 3, w - 4), modelPanel(sn, w - 4, history), reportPanel(sn, w - 4), setupPanel(sn), graphPanel(sn, w - 4), teamPanel(sn, w - 4), sastPanel(sn)], w);
|
|
564
589
|
}
|
|
565
590
|
else {
|
|
566
591
|
top.push(...tiles(tileItems(sn), width));
|
|
567
592
|
if (layout === 'pane') {
|
|
568
593
|
const w = width;
|
|
569
594
|
const inner = w - 4;
|
|
570
|
-
body = stack([activityPanel(events, 5, 'CHANGED JUST NOW'), ...opt(servicesPanel(sn, inner)), nextPanel(sn, 4, inner), modelPanel(sn, inner, history), reportPanel(sn, inner), setupPanel(sn
|
|
595
|
+
body = stack([activityPanel(events, 5, 'CHANGED JUST NOW'), ...opt(servicesPanel(sn, inner)), nextPanel(sn, 4, inner), modelPanel(sn, inner, history), reportPanel(sn, inner), setupPanel(sn), graphPanel(sn, inner), teamPanel(sn, inner), topPanel(sn, inner), sastPanel(sn), sizePanel(sn, inner)], w);
|
|
571
596
|
}
|
|
572
597
|
else if (layout === 'two') {
|
|
573
598
|
const gap = 1;
|
|
@@ -575,7 +600,7 @@ export function renderFrame(sn, events, opts) {
|
|
|
575
600
|
const w2 = width - gap - w;
|
|
576
601
|
body = joinColumns([
|
|
577
602
|
stack([activityPanel(events, 6), ...opt(servicesPanel(sn, w - 4)), nextPanel(sn, 5, w - 4), modelPanel(sn, w - 4, history), topPanel(sn, w - 4)], w),
|
|
578
|
-
stack([setupPanel(sn
|
|
603
|
+
stack([setupPanel(sn), graphPanel(sn, w2 - 4), teamPanel(sn, w2 - 4), sastPanel(sn), reportPanel(sn, w2 - 4), sizePanel(sn, w2 - 4)], w2),
|
|
579
604
|
], [w, w2], gap);
|
|
580
605
|
}
|
|
581
606
|
else {
|
|
@@ -583,7 +608,7 @@ export function renderFrame(sn, events, opts) {
|
|
|
583
608
|
const w = Math.floor((width - gap * 2) / 3);
|
|
584
609
|
const w3 = width - gap * 2 - w * 2;
|
|
585
610
|
body = joinColumns([
|
|
586
|
-
stack([setupPanel(sn
|
|
611
|
+
stack([setupPanel(sn), graphPanel(sn, w - 4), sastPanel(sn), reportPanel(sn, w - 4)], w),
|
|
587
612
|
stack([modelPanel(sn, w - 4, history), nextPanel(sn, 5, w - 4), sizePanel(sn, w - 4)], w),
|
|
588
613
|
stack([activityPanel(events, 8), ...opt(servicesPanel(sn, w3 - 4)), teamPanel(sn, w3 - 4), topPanel(sn, w3 - 4)], w3),
|
|
589
614
|
], [w, w, w3], gap);
|
package/dist/watch.js
CHANGED
|
@@ -9,9 +9,9 @@ import { openInBrowser } from './open.js';
|
|
|
9
9
|
import { hooksDir, version } from './paths.js';
|
|
10
10
|
import { readAllAnswers, readDraft } from './review.js';
|
|
11
11
|
import { listReports, readMeta, reportDir } from './report/meta.js';
|
|
12
|
-
import { renderFrame } from './watch-frame.js';
|
|
12
|
+
import { activityOverlay, renderFrame } from './watch-frame.js';
|
|
13
13
|
import { nextTheme, themeFromBackground } from './palette.js';
|
|
14
|
-
export { buildFrame, layoutFor, renderFrame, tailPath } from './watch-frame.js';
|
|
14
|
+
export { activityOverlay, buildFrame, layoutFor, renderFrame, tailPath } from './watch-frame.js';
|
|
15
15
|
// @comment -- "bravos watch: a live, read-only, zero-token terminal view of a repository's security work, beside any harness. snapshot() gathers what the briefing gathers (guardlink ci, hypothesis next, tickets, git, gh, intent, proving, SAST, setup) plus the hypothesis and boundary ledgers, the model's size, review answers, branch state and the code graph's own answers; diffSnapshots() turns two snapshots into activity events in memory; watch-frame.ts draws them; handleKey() maps keys to read-only actions. Nothing here writes to the repository."
|
|
16
16
|
export const WATCH_SCHEMA = 'bravos.watch/v1';
|
|
17
17
|
// @comment -- "The newest report's summary for watch, from meta.json only (title, kind, check verdict and counts, exported formats) plus how many commits HEAD has moved since its evidence was gathered; null with no report. Read-only."
|
|
@@ -468,6 +468,16 @@ export function readAutopilotEvents(root) {
|
|
|
468
468
|
}
|
|
469
469
|
return out;
|
|
470
470
|
}
|
|
471
|
+
/** Resume by event identity because the rolling log stays at 500 rows while it gains new events. */
|
|
472
|
+
export function newAutopilotEvents(log, last) {
|
|
473
|
+
if (last) {
|
|
474
|
+
for (let i = log.length - 1; i >= 0; i--) {
|
|
475
|
+
if (log[i].at === last.at && log[i].text === last.text)
|
|
476
|
+
return log.slice(i + 1);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return log;
|
|
480
|
+
}
|
|
471
481
|
/* ------------------------------------------------------------------ keys */
|
|
472
482
|
// @comment -- "The recorded intent for the i overlay: .guardlink/intent.md as written, under a line naming who answered the review; when there is none, how to create it. Read-only."
|
|
473
483
|
export function intentOverlay(root) {
|
|
@@ -580,7 +590,7 @@ export function graphAnswer(status, stdout, failure = '') {
|
|
|
580
590
|
}
|
|
581
591
|
return [`no answer${failure ? `: ${failure}` : status !== null ? ` (exit ${status})` : ''}`];
|
|
582
592
|
}
|
|
583
|
-
// @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."
|
|
593
|
+
// @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 full retained activity, test-next, the recorded intent or the guide, scroll, refresh everything now, or quit; anything else does nothing."
|
|
584
594
|
export function handleKey(key, sn, root = '.') {
|
|
585
595
|
switch (key) {
|
|
586
596
|
case 'n':
|
|
@@ -594,6 +604,8 @@ export function handleKey(key, sn, root = '.') {
|
|
|
594
604
|
}
|
|
595
605
|
case 'g':
|
|
596
606
|
return { kind: 'overlay', what: 'graph' };
|
|
607
|
+
case 'a':
|
|
608
|
+
return { kind: 'overlay', what: 'activity' };
|
|
597
609
|
case 't':
|
|
598
610
|
return { kind: 'overlay', what: 'next' };
|
|
599
611
|
case 'p':
|
|
@@ -705,7 +717,7 @@ export async function runWatch(root, env, opts) {
|
|
|
705
717
|
let note = '';
|
|
706
718
|
let overlay = null;
|
|
707
719
|
let overlayScroll = 0;
|
|
708
|
-
let
|
|
720
|
+
let lastAutopilot;
|
|
709
721
|
let graphPrompt = null;
|
|
710
722
|
let scroll = 0;
|
|
711
723
|
let maxScroll = 0;
|
|
@@ -755,9 +767,9 @@ export async function runWatch(root, env, opts) {
|
|
|
755
767
|
lastGraph = Date.now();
|
|
756
768
|
events.push(...diffSnapshots(sn, next));
|
|
757
769
|
const auto = readAutopilotEvents(root);
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
770
|
+
events.push(...newAutopilotEvents(auto, lastAutopilot));
|
|
771
|
+
if (auto.length)
|
|
772
|
+
lastAutopilot = auto.at(-1);
|
|
761
773
|
if (events.length > 50)
|
|
762
774
|
events.splice(0, events.length - 50);
|
|
763
775
|
history.push({ at: next.at, open: next.counts?.open ?? null, coverage: next.coverage?.percent ?? null });
|
|
@@ -897,6 +909,8 @@ export async function runWatch(root, env, opts) {
|
|
|
897
909
|
overlayScroll = 0;
|
|
898
910
|
if (a.what === 'graph')
|
|
899
911
|
graphPrompt = '';
|
|
912
|
+
else if (a.what === 'activity')
|
|
913
|
+
overlay = activityOverlay(events);
|
|
900
914
|
else if (a.what === 'intent')
|
|
901
915
|
overlay = intentOverlay(root);
|
|
902
916
|
else if (a.what === 'report')
|
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 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.
|
|
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, a opens the full text of retained activity, 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
|
|
|
@@ -100,6 +100,24 @@ Skills: `/bravos-context`
|
|
|
100
100
|
|
|
101
101
|
Writes .guardlink/intent.md: invariants (INV-n) that become threats, and intended-by-design items (INT-n) that get an "intended?" audit instead of a high rating.
|
|
102
102
|
|
|
103
|
+
### Start from your design documents
|
|
104
|
+
|
|
105
|
+
Skills: `/bravos-context`
|
|
106
|
+
|
|
107
|
+
Give bravos-context your PRDs, design documents or an earlier threat model, as files or links. Each is kept in the repository as Markdown under .bravos/context/ (bravos context add; committed, so the team can keep it current) after a check for secrets and local paths; a link is kept beside its snapshot. Every rule then names the document it came from (INV-4, source: SRC-2), including who may do what: "sales may see every report except the revenue report" becomes a rule that can be tested, where a scan would see nothing wrong. bravos context list shows the documents, bravos context check re-checks them, and a pre-push check stops a push that would send a secret in one. Free; the CLI runs no model and fetches nothing: your agent converts and fetches with your own access.
|
|
108
|
+
|
|
109
|
+
### See which design rules hold
|
|
110
|
+
|
|
111
|
+
Skills: `/bravos` · `/bravos-recheck`
|
|
112
|
+
|
|
113
|
+
bravos rules lists every rule your design states (INV-n in the intent) with its status: broken (a test got through), retest due (the code under it changed since it was tested), unguarded (it can break somewhere and nothing stops it), guarded but untested, not placed (no code is tied to it yet), or holds (a test tried and was refused everywhere it is enforced). Each line names the document the rule came from and the places it is enforced. bravos dashboard shows the same as its Design rules tab, worst first, beside GuardLink's threat model. Free, read-only, no model; --json prints bravos.rules/v1. On the Team plan the pre-PR check and the PR workflow hold a pull request that changes a file a holding rule is enforced in (the check, or the role table that grants the permission) after that rule was last tested, until its test is replayed or the PR body names the rule; the after-edit note says the same while you work.
|
|
114
|
+
|
|
115
|
+
### Context comes first
|
|
116
|
+
|
|
117
|
+
Skills: `/bravos-context` · `/bravos-annotate`
|
|
118
|
+
|
|
119
|
+
Threat-modelling starts only when a named person has confirmed what the product intends: bravos-annotate, campaigns and the nightly workflows wait until at least one item in .guardlink/intent.md is confirmed (run bravos-context; it asks for your design documents and a few decisions). A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent; a coding agent is told never to decline for you. bravos context gate says which state a repository is in. Rechecks, retests and the ship check are not held back: they maintain a model that already exists.
|
|
120
|
+
|
|
103
121
|
### Threat-model someone else's project
|
|
104
122
|
|
|
105
123
|
Skills: `/bravos-context` · `/bravos-annotate`
|
|
@@ -110,7 +128,7 @@ bravos-context assumes you are researching software you do not own (an open-sour
|
|
|
110
128
|
|
|
111
129
|
Skills: `/bravos-context`
|
|
112
130
|
|
|
113
|
-
bravos-context opens its questions as a bravos page (bravos review intent): pre-filled with bravos's suggestions and their sources; change what is wrong, make the calls marked 'needs your call' (Confirm stays off until you do), and the facts bravos drafted stay folded unless you open one to object. Each person's answers save to .guardlink/intent-answers/<name>.json; teammates run bravos review intent after pulling and commit theirs. bravos review intent --summary shows where people agree and disagree; only what a named person agreed to is marked confirmed. On Claude Code, --share
|
|
131
|
+
bravos-context opens its questions as a bravos page (bravos review intent): pre-filled with bravos's suggestions and their sources; change what is wrong, make the calls marked 'needs your call' (Confirm stays off until you do), and the facts bravos drafted stay folded unless you open one to object. The role-by-action matrix links each documented permission to its question. In local reviews, open a cited SRC document to read its verified text. The saved HTML can contain these documents. Each person's answers save to .guardlink/intent-answers/<name>.json; teammates run bravos review intent after pulling and commit theirs. bravos review intent --summary shows where people agree and disagree; only what a named person agreed to is marked confirmed. On Claude Code, --share prepares an artifact with the draft and its citations. Publish that artifact to share it.
|
|
114
132
|
|
|
115
133
|
### I wrote security-relevant code
|
|
116
134
|
|
package/docs/UPGRADING.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
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.7.0
|
|
6
|
+
|
|
7
|
+
- **SessionStart** shows the Bravos mark, repository and branch, findings and next action in a terminal layout that adapts to the available width. Existing theme, plain-text and banner switches still apply.
|
|
8
|
+
- **`bravos watch`** gives setup and test outcomes segmented trackers alongside the existing metrics, panels and keyboard commands. Press `a` to read long activity entries and older events in the current session.
|
|
9
|
+
- **`bravos review intent`** opens a redesigned owner or researcher intake. Its perspective, sections and questions come from the draft. New drafts can describe a role and action on each documented permission. Select a matrix cell to review the full rule, its exceptions and sources. Existing drafts and named answer files still work. To add a matrix to an older draft, refresh its permission items with the context skill and keep their question IDs.
|
|
10
|
+
- Local reviews can show verified copies of cited design documents. A `--no-serve` HTML file can contain their full text. Use `--share` to prepare an artifact containing the draft and its citations, including anything quoted in the draft itself.
|
|
11
|
+
- Run `bravos sync` in each installed repository to refresh the startup hook and context skill.
|
|
12
|
+
|
|
13
|
+
## 1.6.0
|
|
14
|
+
|
|
15
|
+
1.6 makes threat modelling start from your design. Bravos now asks for your design documents, keeps them in the repository, turns what they state into rules it can test, and shows which rules hold.
|
|
16
|
+
|
|
17
|
+
- **Context now comes first. This changes what happens after `bravos sync`.** The annotate skill, campaigns, the after-edit notes that ask for annotation and the nightly annotate job all wait until a named person has confirmed at least one item of `.guardlink/intent.md`. A repository with no intent, or with a draft nobody confirmed, stops annotating until one of two things happens:
|
|
18
|
+
- you run the context step (ask your agent to "learn what this app intends"), or
|
|
19
|
+
- a named person records that the team goes without: `bravos context decline --by "<name>"`, then commit `.bravos/context/status.json`.
|
|
20
|
+
|
|
21
|
+
`bravos context gate` says which state a repository is in. Rechecks, retests and the ship check are not held back.
|
|
22
|
+
- **Design documents live in the repository.** Give the context step your PRDs, design documents or an earlier threat model, as files or links. Each is stored as Markdown under `.bravos/context/` and committed, so the team can keep it current; a link is kept beside its snapshot. `bravos context add | update | list | check`.
|
|
23
|
+
- A document carrying a secret, a local path or an embedded image is refused, by line number.
|
|
24
|
+
- A git pre-push check stops a push that would send one. It is installed in a clone only when that clone has no pre-push hook; otherwise Bravos prints the one line to add.
|
|
25
|
+
- Everyone with access to the repository can read these documents.
|
|
26
|
+
- **Rules name where they came from.** `intent.md` gains a Sources section and a "Who may do what" table, and each rule cites its document (`INV-4 … (source: SRC-2 "Report access")`).
|
|
27
|
+
- **A rule that holds can be tested.** The annotate skill now writes where a rule could break beside the check that stops it. Checks recorded before 1.6 show as "guarded, untested" until the next annotation pass rewrites them.
|
|
28
|
+
- **`bravos rules` and a Design rules tab in `bravos dashboard`** list every rule with its status: broken, retest due, unguarded, guarded but untested, not placed, or holds.
|
|
29
|
+
- **A change under a rule is noticed (Team plan).** The pre-PR check and the PR workflow hold a pull request that changes a file a holding rule is enforced or granted in, after that rule was last tested, until its test is replayed or the PR body names the rule (its INV id). This is conservative: an unrelated edit to such a file asks for the same.
|
|
30
|
+
- **For scripts:** the annotate skill's `slice.mjs` exits 3 with only `gate` and `notes` in its JSON while the gate is closed; `bravos dashboard --json` and the page's data gain a `rules` field.
|
|
31
|
+
- Run `bravos sync` in each repository to get the updated skills, hooks and workflows.
|
|
32
|
+
|
|
5
33
|
## 1.5.3
|
|
6
34
|
|
|
7
35
|
1.5.3 ships with code graph 0.1.1 (Team plan), which fixes the fault 1.5.2 worked around.
|
package/hooks/lib/autopilot.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { appendFileSync, existsSync, mkdirSync, openSync, readFileSync, readSync, closeSync, fstatSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
+
import { contextGate } from './context.mjs';
|
|
5
6
|
import { gitStaleness, staleness } from './resync.mjs';
|
|
6
7
|
import { asyncRunner, changedHunks, fingerprint, readSnapshot, workingChanges } from './snapshot.mjs';
|
|
7
8
|
|
|
@@ -180,12 +181,20 @@ export async function runAutopilot({ root, env = process.env, payload = {}, run
|
|
|
180
181
|
}
|
|
181
182
|
const paths = rows => arr(rows).map(w => typeof w === 'string' ? w : w?.file ?? w?.path)
|
|
182
183
|
.filter(path => changedSource(path) && !isGenerated(path) && !configFiles.has(path));
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
add(`
|
|
184
|
+
// Context first. While nobody has confirmed what the product intends (or declined), changed files are not put
|
|
185
|
+
// forward for annotation: one note says why and what to do, in place of a note per file. Notes about claims that
|
|
186
|
+
// already exist (stale, to retest, removed) still follow: they maintain the model, they do not start one.
|
|
187
|
+
const gate = contextGate(root);
|
|
188
|
+
if (!gate.open) {
|
|
189
|
+
if (paths(wl?.worklist).length || paths(wl?.annotated).length) add(`context:${gate.state}`, `${gate.message} The files changed this turn are not being put forward for annotation until then.`);
|
|
190
|
+
} else {
|
|
191
|
+
for (const path of paths(wl?.worklist)) {
|
|
192
|
+
add(`unannotated:${path}`, `${path} has no GuardLink annotation: review the change with bravos-annotate; record any security-relevant behavior.`);
|
|
193
|
+
}
|
|
194
|
+
for (const path of paths(wl?.annotated)) {
|
|
195
|
+
const ranges = hunks.get(path)?.map(h => h.start === h.end ? h.start : `${h.start}-${h.end}`).join(', ');
|
|
196
|
+
add(`review:${path}`, `review changed code in ${path}${ranges ? ` (lines ${ranges})` : ''} with bravos-annotate. Check new behavior and guards even when another symbol in this file already has an annotation.`);
|
|
197
|
+
}
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
const excluded = new Set(arr(wl?.excluded).map(e => e?.path ?? e?.file));
|
|
@@ -228,6 +237,18 @@ export async function runAutopilot({ root, env = process.env, payload = {}, run
|
|
|
228
237
|
if (!controls.has(pair)) controls.set(pair, []);
|
|
229
238
|
controls.get(pair).push(m.location);
|
|
230
239
|
}
|
|
240
|
+
// A claim against a design rule (a threat the team's intent states, #inv-…) is named as one, with its INV id when
|
|
241
|
+
// the threat carries it, so the agent knows a rule from the design is what the edit sits under.
|
|
242
|
+
const ruleIds = new Map();
|
|
243
|
+
for (const t of arr(model?.threats)) {
|
|
244
|
+
const id = String(t?.id ?? '').replace(/^#/, '');
|
|
245
|
+
if (/^inv-/i.test(id)) ruleIds.set(id, arr(t.external_refs).map(r => /^intent:(INV-\d+)$/i.exec(String(r))?.[1]).find(Boolean) ?? null);
|
|
246
|
+
}
|
|
247
|
+
const ruleOf = (threat) => {
|
|
248
|
+
const id = String(threat ?? '').replace(/^#/, '');
|
|
249
|
+
if (!/^inv-/i.test(id)) return '';
|
|
250
|
+
return `design rule ${ruleIds.get(id) ? `${ruleIds.get(id)} ` : ''}`;
|
|
251
|
+
};
|
|
231
252
|
const pref = readProving(root);
|
|
232
253
|
if (ledger?.ledger === 'corrupt') {
|
|
233
254
|
add('ledger:corrupt', 'GuardLink could not read the hypothesis ledger. Restore its evidence before treating any claim as untested or running a retest.');
|
|
@@ -247,7 +268,8 @@ export async function runAutopilot({ root, env = process.env, payload = {}, run
|
|
|
247
268
|
// A current refutation holds until its anchor or a separate control changes.
|
|
248
269
|
if (record.state === 'refuted' && !affectedControls.length) continue;
|
|
249
270
|
const retest = record.state === 'retest' || record.state === 'confirmed' || record.expired || record.state === 'refuted';
|
|
250
|
-
|
|
271
|
+
const rule = ruleOf(record.threat);
|
|
272
|
+
add(`proof:${record.key}:${record.state}`, `${retest ? 'Retest' : 'Untested'} ${rule}${record.threat} on ${record.asset} at ${loc.file}:${loc.line} (claim ${record.key}): ${proofInstruction(pref, retest)}.${rule && retest ? ' If a PR is opened before it is retested, name the rule in the PR body.' : ''}`);
|
|
251
273
|
}
|
|
252
274
|
} else {
|
|
253
275
|
// A legacy/unavailable ledger cannot report coverage of mitigated claims.
|