@bugb-technologies/bravos 1.4.1 → 1.5.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 (41) hide show
  1. package/README.md +53 -219
  2. package/dist/account.js +2 -11
  3. package/dist/cli.js +77 -29
  4. package/dist/codegraph.js +25 -0
  5. package/dist/dashboard.js +242 -0
  6. package/dist/guardlink.js +4 -3
  7. package/dist/guide.js +2 -1
  8. package/dist/help.js +8 -0
  9. package/dist/hooks.js +27 -5
  10. package/dist/install-proof-tool.js +5 -7
  11. package/dist/install.js +2 -2
  12. package/dist/licence.js +11 -4
  13. package/dist/omp.js +2 -1
  14. package/dist/open.js +22 -0
  15. package/dist/opencode.js +2 -1
  16. package/dist/setup.js +11 -2
  17. package/dist/skills.js +8 -0
  18. package/dist/start/index.js +10 -2
  19. package/dist/watch.js +8 -24
  20. package/docs/GUIDE.md +7 -1
  21. package/docs/UPGRADING.md +50 -0
  22. package/hooks/lib/briefing.mjs +82 -27
  23. package/hooks/lib/licence.mjs +13 -0
  24. package/hooks/lib/nightly-tools.sh +8 -2
  25. package/hooks/lib/replay.mjs +18 -7
  26. package/hooks/lib/setup.mjs +1 -1
  27. package/package.json +3 -2
  28. package/skills/bravos/SKILL.md +3 -2
  29. package/skills/bravos-annotate/SKILL.md +1 -1
  30. package/skills/bravos-annotate/scripts/lib/pick.mjs +1 -1
  31. package/skills/bravos-annotate/scripts/slice.mjs +1 -1
  32. package/skills/bravos-context/SKILL.md +5 -4
  33. package/skills/bravos-env/SKILL.md +2 -2
  34. package/skills/bravos-env/scope.example.yaml +2 -2
  35. package/skills/bravos-prove/SKILL.md +5 -5
  36. package/skills/bravos-templatize/SKILL.md +3 -3
  37. package/skills/bravos-templatize/operator-guidance.md +4 -4
  38. package/templates/dashboard/codegraph-pages.css +279 -0
  39. package/templates/dashboard/codegraph-pages.js +6230 -0
  40. package/templates/dashboard/codegraph-pages.json +11 -0
  41. package/templates/dashboard/dashboard.html +252 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "schema": "bravos.vendor-codegraph-pages/v1",
3
+ "repository": "siete",
4
+ "commit": "4eab40738b980c837938d0f553c6d331ef8c73fd",
5
+ "entry": "clients/vscode/src/webview/pages/pages.entry.ts",
6
+ "note": "Built by scripts/vendor-codegraph-pages.mjs from that commit. Do not edit the two files: change the pages in siete and run the script again.",
7
+ "files": {
8
+ "codegraph-pages.js": "88bc9634bd5d0584ea117829373ac0fbcbd710928dc113a9145d089d39a81204",
9
+ "codegraph-pages.css": "eaf010c79cbd8b03465af8ea3f0204f5f42e279b612230cdc8617291389a95d1"
10
+ }
11
+ }
@@ -0,0 +1,252 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="color-scheme" content="dark light">
7
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'">
8
+ <link rel="icon" href="data:,">
9
+ <title>Bravos dashboard</title>
10
+ <!-- bravos (written by bravos dashboard; run it again to refresh). One file, no network: the page's facts,
11
+ GuardLink's own dashboard and, on the Team plan, the code graph's answers with the pages that draw them
12
+ are embedded below as JSON, and nothing is fetched. -->
13
+ <style>
14
+ /* The palette is the one GuardLink's dashboard and the Bravos web interface use (Instrument v2), so the
15
+ frame and what it frames read as one page in both colour schemes. */
16
+ :root {
17
+ color-scheme: light dark;
18
+ --canvas: #ffffff; --canvas-inset: #eff2f5; --panel: #ffffff; --raised: #f4f6f8;
19
+ --border: #d9dde3; --border-strong: #b4bcc6;
20
+ --fg: #14181d; --fg-muted: #59636e; --fg-subtle: #656f7b;
21
+ --accent: #2f6f9e; --review: #93650a; --resolved: #1b7a59;
22
+ --sev-low: #c69b78; --sev-medium: #c36c36; --sev-high: #b4410d; --sev-critical: #9e1618;
23
+ --bar-bg: #14181d; --bar-fg: #ffffff; --bar-fg-muted: #9aa4b0;
24
+ --bar-hover: rgba(255,255,255,.08); --bar-selected: rgba(255,255,255,.12);
25
+ --radius: 8px;
26
+ --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
27
+ --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, "Helvetica Neue", sans-serif;
28
+ }
29
+ @media (prefers-color-scheme: dark) {
30
+ :root {
31
+ --canvas: #0d1114; --canvas-inset: #0b0e12; --panel: #14191f; --raised: #1a212a;
32
+ --border: #222a33; --border-strong: #3d4c5c;
33
+ --fg: #e8eef4; --fg-muted: #b9c4cf; --fg-subtle: #97a2ae;
34
+ --accent: #8fc4ee; --review: #e0a24e; --resolved: #3fae86;
35
+ --sev-low: #7c5c3f; --sev-medium: #af6533; --sev-high: #db693a; --sev-critical: #ff7064;
36
+ --bar-bg: #0a0d10; --bar-fg: #e8eef4; --bar-fg-muted: #707b88;
37
+ }
38
+ }
39
+ * { box-sizing: border-box; }
40
+ html, body { height: 100%; }
41
+ body { margin: 0; display: flex; flex-direction: column; background: var(--canvas); color: var(--fg); font: 14px/1.5 var(--sans); }
42
+ .bar { background: var(--bar-bg); color: var(--bar-fg); display: flex; align-items: center; gap: 16px; padding: 0 16px; min-height: 52px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
43
+ .brand { font: 600 15px/1 var(--mono); letter-spacing: .32em; }
44
+ .facts { color: var(--bar-fg-muted); font: 12px/1.4 var(--mono); display: flex; gap: 6px 14px; flex-wrap: wrap; }
45
+ .facts b { color: var(--bar-fg); font-weight: 500; }
46
+ .tabs { margin-left: auto; display: flex; gap: 4px; }
47
+ .tabs[hidden] { display: none; }
48
+ .tabs button { font: inherit; color: var(--bar-fg-muted); background: none; border: 0; border-radius: var(--radius); padding: 7px 12px; cursor: pointer; }
49
+ .tabs button:hover { background: var(--bar-hover); color: var(--bar-fg); }
50
+ .tabs button[aria-selected="true"] { background: var(--bar-selected); color: var(--bar-fg); }
51
+ .tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
52
+ main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
53
+ section { flex: 1; min-height: 0; display: none; flex-direction: column; }
54
+ section.on { display: flex; }
55
+ iframe { flex: 1; width: 100%; border: 0; background: var(--canvas); }
56
+ .strip { padding: 6px 16px; font-size: 12px; color: var(--fg-subtle); background: var(--canvas-inset); border-bottom: 1px solid var(--border); }
57
+ .note { max-width: 640px; margin: 48px auto; padding: 20px 24px; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--review); border-radius: var(--radius); }
58
+ .note h2 { margin: 0 0 6px; font-size: 15px; }
59
+ .note p { margin: 0; color: var(--fg-muted); }
60
+ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
61
+ </style>
62
+ </head>
63
+ <body>
64
+ <div class="bar">
65
+ <span class="brand">BRAVOS</span>
66
+ <span class="facts" id="facts"></span>
67
+ <nav class="tabs" id="tabs" role="tablist" aria-label="Dashboard views"></nav>
68
+ </div>
69
+ <main id="main"></main>
70
+ <script type="application/json" id="bravos-data">__BRAVOS_DATA__</script>
71
+ <script type="application/json" id="bravos-threat-model">__BRAVOS_THREAT_MODEL__</script>
72
+ <script type="application/json" id="bravos-codegraph">__BRAVOS_CODEGRAPH__</script>
73
+ <script type="application/json" id="bravos-pages-css">__BRAVOS_PAGES_CSS__</script>
74
+ <script type="application/json" id="bravos-pages-js">__BRAVOS_PAGES_JS__</script>
75
+ <script>
76
+ (() => {
77
+ const DATA = JSON.parse(document.getElementById('bravos-data').textContent);
78
+ const el = (tag, attrs = {}, text) => {
79
+ const n = document.createElement(tag);
80
+ for (const [k, v] of Object.entries(attrs)) n.setAttribute(k, v);
81
+ if (text !== undefined) n.textContent = text;
82
+ return n;
83
+ };
84
+ // Commands inside a note are shown as code; everything is set as text, never as markup.
85
+ const COMMAND = /(bravos setup --tools -y|bravos setup --codegraph|bravos graph build \.|bravos account activate|bravos dashboard|guardlink validate \.|\/bravos-[a-z]+)/g;
86
+ const prose = (text) => {
87
+ const p = el('p');
88
+ String(text).split(COMMAND).forEach((part, k) => p.append(k % 2 ? el('code', {}, part) : part));
89
+ return p;
90
+ };
91
+ const note = (title, text) => {
92
+ const box = el('div', { class: 'note' });
93
+ box.append(el('h2', {}, title), prose(text));
94
+ return box;
95
+ };
96
+
97
+ const facts = document.getElementById('facts');
98
+ const fact = (label, value) => {
99
+ if (!value) return;
100
+ const s = el('span', {}, `${label} `);
101
+ s.append(el('b', {}, value));
102
+ facts.append(s);
103
+ };
104
+ fact('repo', DATA.repo);
105
+ fact('at', [DATA.branch, DATA.sha].filter(Boolean).join(' @ '));
106
+ fact('plan', DATA.plan);
107
+ fact('built', String(DATA.generatedAt || '').slice(0, 16).replace('T', ' ') + ' UTC');
108
+ document.title = `Bravos — ${DATA.repo}`;
109
+
110
+ const views = [];
111
+ // Threat model: GuardLink's own page, shown whole in a sandboxed frame (srcdoc), so it has no access to this
112
+ // page, and this page's policy keeps it off the network. GuardLink routes on location.hash, and a "#page"
113
+ // link in a srcdoc frame would resolve against this file and load it inside the frame; the small script
114
+ // appended to its page turns those clicks into hash changes instead. (A blob: URL was tried first: opened
115
+ // from a file, Chrome does not follow "#page" links inside a sandboxed blob frame at all.)
116
+ const STAY = '<scr' + 'ipt>document.addEventListener("click", function (e) { var a = e.target && e.target.closest ? e.target.closest("a[href^=\\"#\\"]") : null; if (a && !a.target) { e.preventDefault(); location.hash = a.getAttribute("href"); } }, true);</scr' + 'ipt>';
117
+ views.push({
118
+ id: 'threat-model',
119
+ label: 'Threat model',
120
+ build(section) {
121
+ const tm = DATA.threatModel || {};
122
+ const html = JSON.parse(document.getElementById('bravos-threat-model').textContent);
123
+ if (tm.state !== 'present' || !html) {
124
+ section.append(note(tm.state === 'missing' ? 'GuardLink is not installed' : 'No threat model to show yet', tm.note || 'Run bravos dashboard again after annotating.'));
125
+ return;
126
+ }
127
+ section.append(el('div', { class: 'strip' }, tm.note));
128
+ const frame = el('iframe', { title: 'GuardLink threat model', sandbox: 'allow-scripts allow-popups allow-popups-to-escape-sandbox', referrerpolicy: 'no-referrer' });
129
+ frame.srcdoc = html + STAY;
130
+ section.append(frame);
131
+ },
132
+ });
133
+
134
+ // Code graph: the seven pages the Bravos VS Code extension draws (Map, Owners & History, Coupling, Trust,
135
+ // Attack surface, Entry points, Links), vendored unchanged and run in their own sandboxed frame. In the editor
136
+ // a page asks its host for data; here the host is the small script below, which answers from the graph's
137
+ // answers stored in this file. On the Free plan, or with no graph built, the tab says what would fill it.
138
+ const FRAME_THEME = [
139
+ // The pages read the editor's colour names; these point them at this dashboard's palette, light and dark.
140
+ ':root{--vscode-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,"Helvetica Neue",sans-serif;--vscode-editor-font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;--vscode-font-size:13px;',
141
+ '--vscode-foreground:#14181d;--vscode-editor-foreground:#14181d;--vscode-editor-background:#ffffff;--vscode-descriptionForeground:#59636e;--vscode-disabledForeground:#656f7b;',
142
+ '--vscode-panel-border:#d9dde3;--vscode-editorGroup-border:#e6e9ee;--vscode-widget-border:#d9dde3;--vscode-input-border:#b4bcc6;--vscode-contrastBorder:#b4bcc6;',
143
+ '--vscode-sideBar-background:#f4f6f8;--vscode-editorWidget-background:#ffffff;--vscode-input-background:#f4f6f8;--vscode-input-foreground:#14181d;--vscode-editorGroupHeader-tabsBackground:#f4f6f8;',
144
+ '--vscode-editorHoverWidget-background:#ffffff;--vscode-editorHoverWidget-foreground:#14181d;--vscode-editorHoverWidget-border:#b4bcc6;--vscode-list-hoverBackground:#eaedf1;--vscode-toolbar-hoverBackground:#eaedf1;--vscode-list-inactiveSelectionBackground:#f4f6f8;',
145
+ '--vscode-focusBorder:#2f6f9e;--vscode-textLink-foreground:#2f6f9e;--vscode-button-background:#2f6f9e;--vscode-button-foreground:#ffffff;--vscode-button-hoverBackground:#28608a;--vscode-button-secondaryBackground:#f4f6f8;--vscode-button-secondaryForeground:#14181d;',
146
+ '--vscode-charts-green:#1b7a59;--vscode-charts-yellow:#93650a;--vscode-widget-shadow:rgba(20,24,29,.16)}',
147
+ '@media (prefers-color-scheme: dark){:root{--vscode-foreground:#e8eef4;--vscode-editor-foreground:#e8eef4;--vscode-editor-background:#0d1114;--vscode-descriptionForeground:#b9c4cf;--vscode-disabledForeground:#97a2ae;',
148
+ '--vscode-panel-border:#222a33;--vscode-editorGroup-border:#1a212a;--vscode-widget-border:#222a33;--vscode-input-border:#3d4c5c;--vscode-contrastBorder:#3d4c5c;',
149
+ '--vscode-sideBar-background:#0a0d10;--vscode-editorWidget-background:#14191f;--vscode-input-background:#1a212a;--vscode-input-foreground:#e8eef4;--vscode-editorGroupHeader-tabsBackground:#0a0d10;',
150
+ '--vscode-editorHoverWidget-background:#1a212a;--vscode-editorHoverWidget-foreground:#e8eef4;--vscode-editorHoverWidget-border:#3d4c5c;--vscode-list-hoverBackground:#212a34;--vscode-toolbar-hoverBackground:#212a34;--vscode-list-inactiveSelectionBackground:#1a212a;',
151
+ '--vscode-focusBorder:#8fc4ee;--vscode-textLink-foreground:#8fc4ee;--vscode-button-background:#8fc4ee;--vscode-button-foreground:#08131b;--vscode-button-hoverBackground:#a9d3f3;--vscode-button-secondaryBackground:#1a212a;--vscode-button-secondaryForeground:#e8eef4;',
152
+ '--vscode-charts-green:#3fae86;--vscode-charts-yellow:#e0a24e;--vscode-widget-shadow:rgba(0,0,0,.35)}}',
153
+ 'html,body{min-height:100%}#said{position:sticky;bottom:0;margin:0;padding:7px 14px;min-height:30px;font:12px/1.4 var(--vscode-editor-font-family);color:var(--vscode-descriptionForeground);background:var(--vscode-sideBar-background);border-top:1px solid var(--vscode-panel-border);overflow-wrap:anywhere}',
154
+ ].join('');
155
+ // The stand-in for the editor, run inside the frame before the pages' script. It speaks the pages' own
156
+ // protocol (siete: clients/vscode/src/webview/pages/protocol.ts): "ready" and "page" are answered with the
157
+ // stored message for that page; what a saved file cannot do (open a file, ask the graph again) is said in
158
+ // the line at the foot of the frame, with the command that would do it.
159
+ const frameHost = () => {
160
+ var saved = JSON.parse(document.getElementById('store').textContent);
161
+ var STORE = saved.pages;
162
+ // The code map is stored once; each message that carries it holds a reference, resolved here.
163
+ Object.keys(STORE).forEach(function (page) {
164
+ var m = STORE[page];
165
+ Object.keys(m).forEach(function (k) {
166
+ var v = m[k];
167
+ if (v && v.$ref === 'codemap') m[k] = saved.codemap;
168
+ else if (v && v.value && v.value.$ref === 'codemap') v.value = saved.codemap;
169
+ });
170
+ });
171
+ var current = 'map';
172
+ var said = document.getElementById('said');
173
+ var mq = window.matchMedia('(prefers-color-scheme: dark)');
174
+ var mark = function () {
175
+ document.body.classList.toggle('vscode-dark', mq.matches);
176
+ document.body.classList.toggle('vscode-light', !mq.matches);
177
+ };
178
+ mark();
179
+ if (mq.addEventListener) mq.addEventListener('change', mark);
180
+ var send = function (m) { setTimeout(function () { window.postMessage(m, '*'); }, 0); };
181
+ window.acquireVsCodeApi = function () {
182
+ return { postMessage: function (m) {
183
+ if (m.type === 'ready') send(STORE[current]);
184
+ else if (m.type === 'page' && STORE[m.page]) { current = m.page; send(STORE[current]); }
185
+ else if (m.type === 'reload') { said.textContent = 'This page is a saved snapshot: run bravos dashboard again to refresh it.'; send(STORE[current]); }
186
+ else if (m.type === 'open') said.textContent = String(m.file) + (m.line ? ':' + m.line : '') + ' (open it in your editor)';
187
+ else if (m.type === 'ownership') send({ type: 'ownership', file: m.file, answer: { ok: false, message: 'not asked when this page was saved', remedy: 'bravos graph ownership ' + m.file + ' --json' } });
188
+ else if (m.type === 'blast') said.textContent = 'Blast radius: bravos graph impact ' + m.file + ' --json';
189
+ else if (m.type === 'whoOwns') said.textContent = 'Who owns it: bravos graph ownership ' + m.file + ' --json';
190
+ } };
191
+ };
192
+ // A "#…" link in a srcdoc frame would load this file inside the frame; none is followed.
193
+ document.addEventListener('click', function (e) { var a = e.target && e.target.closest ? e.target.closest('a[href^="#"]') : null; if (a) e.preventDefault(); }, true);
194
+ };
195
+ views.push({
196
+ id: 'code-graph',
197
+ label: 'Code graph',
198
+ build(section) {
199
+ const cg = DATA.codeGraph || {};
200
+ const read = (id) => JSON.parse(document.getElementById(id).textContent);
201
+ const store = read('bravos-codegraph');
202
+ if (cg.state !== 'present' || !store) {
203
+ const titles = { locked: 'On the Team plan', missing: 'The code graph is not installed', 'not-built': 'No code graph for this commit yet' };
204
+ section.append(note(titles[cg.state] || 'No code graph to show', cg.note || 'Run bravos dashboard again after building the code graph.'));
205
+ return;
206
+ }
207
+ section.append(el('div', { class: 'strip' }, cg.note));
208
+ const inert = JSON.stringify(store).replace(/</g, '\\u003c');
209
+ const open = '<scr' + 'ipt>';
210
+ const close = '</scr' + 'ipt>';
211
+ const frame = el('iframe', { title: 'Code graph', sandbox: 'allow-scripts', referrerpolicy: 'no-referrer' });
212
+ frame.srcdoc = '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Code graph</title><style>' + read('bravos-pages-css') + '</style><style>' + FRAME_THEME + '</style></head><body>'
213
+ + '<div id="app"></div><p id="said" aria-live="polite"></p>'
214
+ + '<script type="application/json" id="store">' + inert + close
215
+ + open + '(' + frameHost.toString() + ')();' + close
216
+ + open + read('bravos-pages-js') + close
217
+ + '</body></html>';
218
+ section.append(frame);
219
+ },
220
+ });
221
+
222
+ const tabs = document.getElementById('tabs');
223
+ const main = document.getElementById('main');
224
+ const show = (id) => {
225
+ for (const v of views) {
226
+ const on = v.id === id;
227
+ v.tab.setAttribute('aria-selected', String(on));
228
+ v.section.classList.toggle('on', on);
229
+ if (on && !v.built) {
230
+ v.built = true;
231
+ v.build(v.section);
232
+ }
233
+ }
234
+ };
235
+ for (const v of views) {
236
+ v.tab = el('button', { type: 'button', role: 'tab', 'aria-controls': `view-${v.id}` }, v.label);
237
+ v.section = el('section', { id: `view-${v.id}`, role: 'tabpanel' });
238
+ v.tab.addEventListener('click', () => {
239
+ history.replaceState(null, '', `#${v.id}`);
240
+ show(v.id);
241
+ });
242
+ tabs.append(v.tab);
243
+ main.append(v.section);
244
+ }
245
+ // One view needs no tab bar.
246
+ if (views.length < 2) tabs.hidden = true;
247
+ const wanted = location.hash.slice(1);
248
+ show(views.some((v) => v.id === wanted) ? wanted : views[0].id);
249
+ })();
250
+ </script>
251
+ </body>
252
+ </html>