@bugb-technologies/bravos 1.6.0 → 1.8.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.
Files changed (42) hide show
  1. package/dist/cli.js +82 -17
  2. package/dist/codegraph.js +21 -0
  3. package/dist/context.js +36 -0
  4. package/dist/graphbin.js +2 -0
  5. package/dist/guide.js +7 -5
  6. package/dist/help.js +24 -5
  7. package/dist/install.js +2 -1
  8. package/dist/lock.js +1 -0
  9. package/dist/mcp.js +18 -3
  10. package/dist/palette.js +4 -4
  11. package/dist/prefs.js +47 -0
  12. package/dist/review-server.js +4 -4
  13. package/dist/review-wait.js +76 -0
  14. package/dist/review.js +103 -18
  15. package/dist/start/answers.js +33 -4
  16. package/dist/start/index.js +138 -57
  17. package/dist/upkeep.js +89 -0
  18. package/dist/watch-frame.js +67 -42
  19. package/dist/watch.js +21 -7
  20. package/docs/GUIDE.md +17 -5
  21. package/docs/UPGRADING.md +27 -0
  22. package/hooks/lib/autopilot.mjs +3 -18
  23. package/hooks/lib/briefing.mjs +250 -173
  24. package/hooks/lib/graph-autobuild.mjs +131 -0
  25. package/hooks/lib/palette.mjs +4 -4
  26. package/hooks/lib/prefs.mjs +108 -0
  27. package/hooks/lib/refresh.mjs +45 -1
  28. package/hooks/lib/setup.mjs +1 -1
  29. package/hooks/lib/snapshot.mjs +19 -1
  30. package/hooks/session-start.mjs +29 -2
  31. package/package.json +1 -1
  32. package/skills/bravos/SKILL.md +4 -3
  33. package/skills/bravos-annotate/SKILL.md +2 -2
  34. package/skills/bravos-context/SKILL.md +7 -6
  35. package/skills/bravos-env/SKILL.md +2 -2
  36. package/skills/bravos-env/scope.example.yaml +2 -1
  37. package/skills/bravos-prove/SKILL.md +2 -2
  38. package/skills/bravos-recheck/SKILL.md +1 -1
  39. package/skills/bravos-resync/SKILL.md +1 -1
  40. package/skills/bravos-ship/SKILL.md +1 -1
  41. package/skills/bravos-templatize/SKILL.md +1 -1
  42. package/templates/review/review.html +369 -124
package/dist/upkeep.js ADDED
@@ -0,0 +1,89 @@
1
+ // @comment -- "bravos upkeep: what in this repository or on this machine has fallen behind the installed bravos, read-only and without the network, fast enough for the session hook to ask at every start. Two things: the repository's own copies of the skills and hook scripts (compared file by file with what this bravos would write, so a lock that still names an old version cannot hide or invent a difference), and a staged bundle older than the version this bravos pins. It also says which side is newer, because bravos sync from an older bravos would roll a repository back."
2
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
3
+ import { join, relative } from 'node:path';
4
+ import { olderThan, VERSIONS } from './artifacts.js';
5
+ import { installSkills } from './install.js';
6
+ import { licenceLib } from './licence.js';
7
+ import { LOCK_PATH, readLock } from './lock.js';
8
+ import { hooksDir as packageHooksDir, version } from './paths.js';
9
+ import { behindPin } from './setup.js';
10
+ import { skillsRoot } from './skills.js';
11
+ export const UPKEEP_SCHEMA = 'bravos.upkeep/v1';
12
+ const listFiles = (dir) => {
13
+ const out = [];
14
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
15
+ const abs = join(dir, e.name);
16
+ if (e.isDirectory())
17
+ out.push(...listFiles(abs));
18
+ else if (e.isFile())
19
+ out.push(abs);
20
+ }
21
+ return out;
22
+ };
23
+ // @comment -- "The hook scripts the repository carries, against the ones this bravos ships: missing or different files, by path. Only where the repository has its own copies at all."
24
+ function staleHooks(root) {
25
+ if (!existsSync(join(root, '.bravos', 'hooks', 'session-start.mjs')))
26
+ return [];
27
+ const src = packageHooksDir();
28
+ const stale = [];
29
+ for (const abs of listFiles(src)) {
30
+ const rel = relative(src, abs).split('\\').join('/');
31
+ const dest = join(root, '.bravos', 'hooks', rel);
32
+ try {
33
+ if (!readFileSync(dest).equals(readFileSync(abs)))
34
+ stale.push(`.bravos/hooks/${rel}`);
35
+ }
36
+ catch {
37
+ stale.push(`.bravos/hooks/${rel}`);
38
+ }
39
+ }
40
+ return stale;
41
+ }
42
+ export async function gatherUpkeep(root, env) {
43
+ const cli = version();
44
+ const out = { schema: UPKEEP_SCHEMA, cli, repo: null, sync: { files: 0, sample: [], direction: 'same' }, bundles: [] };
45
+ if (existsSync(join(root, LOCK_PATH))) {
46
+ try {
47
+ const lock = readLock(root);
48
+ // The lock's own version stays behind when a sync skipped an edited file; synced_with is the bravos that last ran one.
49
+ const seen = [lock.bravos_version, lock.synced_with].filter((v) => typeof v === 'string' && !!v);
50
+ const repo = seen.reduce((a, b) => (olderThan(a, b) ? b : a), seen[0] ?? cli);
51
+ out.repo = repo;
52
+ out.sync.direction = olderThan(cli, repo) ? 'repo-newer' : olderThan(repo, cli) ? 'cli-newer' : 'same';
53
+ const harnesses = ['claude', 'agents'].filter((h) => existsSync(join(root, skillsRoot(h), 'bravos', 'SKILL.md')));
54
+ const dry = harnesses.length ? installSkills(root, harnesses, { dryRun: true }) : { written: [], updated: [] };
55
+ const stale = [...dry.updated, ...dry.written, ...staleHooks(root)];
56
+ out.sync.files = stale.length;
57
+ out.sync.sample = stale.slice(0, 5);
58
+ }
59
+ catch {
60
+ /* a lock that does not read: bravos sync says why; nothing to report here */
61
+ }
62
+ }
63
+ const L = await licenceLib();
64
+ const lic = L.status(env);
65
+ for (const [id, feature] of [['analyzer', 'sast'], ['codegraph', 'codegraph']]) {
66
+ if (!L.entitled(lic, feature))
67
+ continue;
68
+ const staged = behindPin(env, id);
69
+ if (staged)
70
+ out.bundles.push({ id, staged, pinned: VERSIONS[id] });
71
+ }
72
+ return out;
73
+ }
74
+ export function formatUpkeep(u) {
75
+ const lines = [];
76
+ if (u.repo === null)
77
+ lines.push('repository: bravos is not installed here (bravos start, or bravos init)');
78
+ else if (u.sync.files === 0)
79
+ lines.push(`repository: up to date with bravos ${u.cli}`);
80
+ else if (u.sync.direction === 'repo-newer')
81
+ lines.push(`repository: its Bravos files are from ${u.repo}, newer than this bravos (${u.cli}) — update bravos: npm install -g @bugb-technologies/bravos@latest (do not run bravos sync from this older one)`);
82
+ else
83
+ lines.push(`repository: ${u.sync.files} file${u.sync.files === 1 ? '' : 's'} behind bravos ${u.cli} — bravos sync (${u.sync.sample.join(', ')}${u.sync.files > u.sync.sample.length ? ', …' : ''})`);
84
+ for (const b of u.bundles)
85
+ lines.push(`${b.id}: staged ${b.staged}, this bravos pins ${b.pinned} — bravos setup`);
86
+ if (!u.bundles.length)
87
+ lines.push('bundles: none behind');
88
+ return lines;
89
+ }
@@ -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
- /** A bar split into named parts, each with its glyph and colour. */
101
- function partsBar(parts, width) {
102
- const total = parts.reduce((n, p) => n + p.n, 0);
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('░'.repeat(width), C.line)];
105
- const out = [];
106
- let used = 0;
107
- parts.forEach((p, k) => {
108
- const w = k === parts.length - 1 ? width - used : Math.round((p.n / total) * width);
109
- if (w > 0)
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, inner) {
169
+ function setupPanel(sn) {
167
170
  const pct = sn.setup.total ? Math.round((sn.setup.done / sn.setup.total) * 100) : 0;
168
- const body = [[...bar(pct, inner - 6, C.green), s(` ${String(pct).padStart(3)}%`, C.green, true)]];
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}`, rightColor: C.green, body };
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), s(` · ${L.confirmed} confirmed · ${L.refuted} refuted · ${L.retest} retest`, C.steel)]);
197
- body.push(partsBar([
198
- { n: L.confirmed, glyph: '█', c: C.red },
199
- { n: L.retest, glyph: '▓', c: C.amber },
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 left = [s(' ◆ bravos watch ', C.green, true, C.deep), s(' ', undefined, false, C.deep), s(sn.repo, C.white, true, C.deep), s(` ${sn.branch ?? '(detached)'} @ ${sn.sha}`, C.steel, false, C.deep), s(` ${sn.plan.label}`, sn.plan.licensed ? C.green : C.amber, false, C.deep)];
505
- const st = opts.stats;
506
- const right = [
507
- s(opts.status ?? '● live', opts.status?.startsWith('updating') ? C.amber : C.green, true, C.deep),
508
- ...(st ? [s(` · #${st.refreshes}${st.lastMs !== null ? ` ${(st.lastMs / 1000).toFixed(1)}s` : ''}`, C.steel, false, C.deep)] : []),
509
- s(' · 0 tokens ', C.steel, false, C.deep),
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 gap = width - len(left) - len(right);
512
- if (gap >= 1)
513
- return [...left, s(' '.repeat(gap), undefined, false, C.deep), ...right];
514
- return fitLine([...left, s(' ', undefined, false, C.deep), right[0]], width, true, C.deep);
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 = [header(sn, width, opts)];
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, w - 4), graphPanel(sn, w - 4), teamPanel(sn, w - 4), sastPanel(sn)], w);
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, inner), graphPanel(sn, inner), teamPanel(sn, inner), topPanel(sn, inner), sastPanel(sn), sizePanel(sn, inner)], w);
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, w2 - 4), graphPanel(sn, w2 - 4), teamPanel(sn, w2 - 4), sastPanel(sn), reportPanel(sn, w2 - 4), sizePanel(sn, w2 - 4)], w2),
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, w - 4), graphPanel(sn, w - 4), sastPanel(sn), reportPanel(sn, w - 4)], w),
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 seenAutopilot = 0;
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
- if (auto.length > seenAutopilot)
759
- events.push(...auto.slice(seenAutopilot));
760
- seenAutopilot = auto.length;
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
@@ -30,7 +30,7 @@ Every skill reads one dial: low, medium (default), high or max. Say it ("annotat
30
30
 
31
31
  ### Installing
32
32
 
33
- npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos start: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. It ends with the one thing to type in your agent.
33
+ npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos start: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).
34
34
 
35
35
  By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos init in a repository writes the skills, hooks and MCP wiring, and bravos setup puts the analyzer and the code graph on the machine (Team plan). guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.
36
36
 
@@ -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
 
@@ -128,7 +128,7 @@ bravos-context assumes you are researching software you do not own (an open-sour
128
128
 
129
129
  Skills: `/bravos-context`
130
130
 
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. 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 puts the same page on a private claude.ai link instead.
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. Press Done when you are finished: the agent runs bravos review intent --wait and carries on by itself. 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.
132
132
 
133
133
  ### I wrote security-relevant code
134
134
 
@@ -170,7 +170,7 @@ The no-mistakes gate: validate, lint since the merge base, disclose new exposure
170
170
 
171
171
  Skills: `/bravos-codegraph`
172
172
 
173
- One bounded question to the code graph instead of grepping. Team plan: bravos setup --codegraph stages codegraph-mcp, then bravos graph build . indexes the repository. With it, other skills get sharper on their own: bravos-templatize targets the route and auth that actually reach each sink, bravos-recheck follows a fix's callers and blast radius into other files, bravos-context drafts the real public surface, and bravos-prove tests the most reachable exposures first. Without it they read the code and say so.
173
+ One bounded question to the code graph instead of grepping. Team plan: bravos setup --codegraph stages codegraph-mcp, then bravos graph build . indexes the repository. With it, other skills get sharper on their own: bravos-templatize targets the route and auth that actually reach each sink, bravos-recheck follows a fix's callers and blast radius into other files, bravos-context drafts the real public surface, and bravos-prove tests the most reachable exposures first. After each commit the graph is rebuilt for you: when a session starts and the commit has none, the session hook starts one quiet background build (no tokens; one at a time; never in CI; BRAVOS_GRAPH_AUTOBUILD=off turns it off). Without it they read the code and say so.
174
174
 
175
175
  ### Scan for dependency CVEs, secrets, IaC
176
176
 
@@ -202,6 +202,18 @@ Skills: `/bravos-annotate` · `/bravos-codegraph` · `/bravos-prove`
202
202
 
203
203
  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.
204
204
 
205
+ ### After updating bravos
206
+
207
+ Skills: `/bravos`
208
+
209
+ Nothing to run by hand in a repository you work in with an agent: at the start of a session bravos upkeep (read-only, no network) tells the agent what is behind the installed version, and the agent runs bravos sync for the repository's skills and hooks, or bravos setup for Bravos's own bundles, without asking. If a teammate synced the repository with a newer bravos than yours, the agent syncs nothing and tells you to update. Installing guardlink and cxg (bravos setup --tools) still waits for your go-ahead.
210
+
211
+ ### Stop being asked about commits
212
+
213
+ Skills: `/bravos`
214
+
215
+ Say once whether your agent commits the files Bravos writes (annotations, intent, definitions, tests): bravos prefs set commits commit|leave|ask --by "<your name>". bravos start asks it too. The answer is kept in this clone's git directory, never committed, and your own code is never part of such a commit. bravos prefs get shows it.
216
+
205
217
  ### See the findings on one page
206
218
 
207
219
  Skills: `/bravos`
@@ -314,7 +326,7 @@ Never invented. Test users and sessions are seeded or captured for real, or the
314
326
 
315
327
  ### No hidden agents
316
328
 
317
- The agent in your session does the work; bravos never spawns another agent CLI. Model-API probe generation in cxg runs only after you agree to the spend.
329
+ The agent in your session does the work; bravos never spawns another agent CLI, and never uses cxg's model-API probe generation: the tests it runs are the ones written and reviewed in your session.
318
330
 
319
331
  ### Governance
320
332
 
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.8.0
6
+
7
+ 1.8 removes the stops Bravos put between a developer and their code. After `bravos start`, you open your agent and say anything; Bravos asks once for what only you can decide, then keeps itself current.
8
+
9
+ - **Run `bravos sync` once in each repository, by hand.** It is the last time: from now on the agent's session briefing says when a repository is behind and the agent runs `bravos sync` (and `bravos setup` for Bravos's own bundles) itself. `bravos upkeep` shows what is behind. A bravos older than the one that last synced a repository never syncs it; it tells you to update instead. `BRAVOS_UPKEEP_PROBE=off` stops the check.
10
+ - **After `bravos start`, the agent begins by itself.** For three days, in that clone, the first session starts the context step without being asked and goes on to annotation once a named person confirms. The context gate is unchanged: nothing is annotated before that confirmation.
11
+ - **Done on the review page is enough.** `bravos review intent --wait` returns with everyone's answers when the person presses Done, so nobody types "done" in chat. Run again, it joins the same page.
12
+ - **The commit question is asked once.** `bravos start` asks whether your agent commits the files Bravos writes (annotations, intent, definitions, tests); `bravos prefs set commits commit|leave|ask --by "<your name>"` changes it. The answer is kept under the clone's git directory, never committed, and never covers your own code.
13
+ - **The code graph rebuilds itself (Team plan).** When a session starts and the commit has no graph, the session hook starts one background build (`--scip no-exec`, no tokens). One per repository at a time; never in CI; `BRAVOS_GRAPH_AUTOBUILD=off` turns it off.
14
+ - **`bravos start`:**
15
+ - `--yes` keeps autopilot on for the pull-request preset, as the interactive default does.
16
+ - In a repository that already has Bravos, it sets up only this machine and leaves the team's `proving.md` and setup alone; `bravos start --again` changes the repository's setup.
17
+ - With automatic testing it can take your local app's address and write the target, so the policy needs one merge.
18
+ - It no longer asks about cxg model generation, which Bravos never uses.
19
+ - **`.mcp.json` no longer holds a path from one machine.** The code graph server is registered as `bravos graph mcp`; the next `bravos sync` rewrites an older entry. Reconnect MCP in your agent once (`/mcp` in Claude Code). `bravos` must be on PATH where the agent runs.
20
+ - **`.bravos/setup.json` no longer records your repository path**, theme or tool install.
21
+ - **Licence:** if the portal revokes a machine or a plan ends, the briefing now says so; before, that was lost.
22
+ - **Skills:** no skill tells the agent to stash; the dashboard is built and its path given instead of offered; `bravos-resync` asks before committing your work in progress.
23
+
24
+ ## 1.7.0
25
+
26
+ - **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.
27
+ - **`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.
28
+ - **`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.
29
+ - 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.
30
+ - Run `bravos sync` in each installed repository to refresh the startup hook and context skill.
31
+
5
32
  ## 1.6.0
6
33
 
7
34
  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.
@@ -4,7 +4,7 @@ import { appendFileSync, existsSync, mkdirSync, openSync, readFileSync, readSync
4
4
  import { join } from 'node:path';
5
5
  import { contextGate } from './context.mjs';
6
6
  import { gitStaleness, staleness } from './resync.mjs';
7
- import { asyncRunner, changedHunks, fingerprint, readSnapshot, workingChanges } from './snapshot.mjs';
7
+ import { asyncRunner, changedHunks, fingerprint, logWatchEvent, readSnapshot, workingChanges } from './snapshot.mjs';
8
8
 
9
9
  export { asyncRunner, readSnapshot, safeSessionId, takeSnapshot } from './snapshot.mjs';
10
10
 
@@ -314,20 +314,5 @@ function finish(findings, payload) {
314
314
  return { decision: 'block', reason, summary, keys: fresh2.map((f) => f.key) };
315
315
  }
316
316
 
317
- export const WATCH_LOG_CAP = 500;
318
-
319
- // @comment -- "Appends one autopilot nudge to .bravos/watch/events.jsonl for bravos watch to show: a local log, not a state store. The folder carries its own .gitignore of *, the file keeps its newest WATCH_LOG_CAP lines, and any failure is swallowed because the nudge itself already went out."
320
- export function logWatchEvent(root, { summary, keys = [] }, now = new Date()) {
321
- try {
322
- const dir = join(root, '.bravos', 'watch');
323
- mkdirSync(dir, { recursive: true });
324
- const ignore = join(dir, '.gitignore');
325
- if (!existsSync(ignore)) writeFileSync(ignore, '*\n');
326
- const file = join(dir, 'events.jsonl');
327
- appendFileSync(file, JSON.stringify({ at: now.toISOString(), text: String(summary ?? '').slice(0, 400), keys }) + '\n');
328
- const lines = readFileSync(file, 'utf8').split('\n').filter(Boolean);
329
- if (lines.length > WATCH_LOG_CAP) writeFileSync(file, lines.slice(-WATCH_LOG_CAP).join('\n') + '\n');
330
- } catch {
331
- /* the log is a convenience for bravos watch */
332
- }
333
- }
317
+ // The watch log lives in snapshot.mjs so the session hook's background graph build can write to it too.
318
+ export { logWatchEvent, WATCH_LOG_CAP } from './snapshot.mjs';