@bugb-technologies/bravos 1.19.0 → 1.22.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/account.js +19 -2
- package/dist/cli.js +124 -14
- package/dist/context.js +126 -3
- package/dist/dashboard.js +9 -0
- package/dist/device.js +3 -1
- package/dist/doctor.js +4 -0
- package/dist/guide.js +5 -3
- package/dist/help.js +15 -8
- package/dist/instruction-blocks.js +2 -1
- package/dist/principles.js +279 -0
- package/dist/review-server.js +19 -4
- package/dist/review-wait.js +11 -0
- package/dist/review.js +342 -41
- package/dist/rules.js +82 -6
- package/docs/GUIDE.md +12 -2
- package/docs/UPGRADING.md +39 -0
- package/hooks/cards.mjs +20 -5
- package/hooks/lib/briefing.mjs +26 -2
- package/hooks/lib/context.mjs +57 -1
- package/hooks/lib/licence.mjs +2 -1
- package/hooks/lib/machine.mjs +77 -0
- package/hooks/lib/pre-pr.mjs +82 -1
- package/hooks/lib/principles.mjs +513 -0
- package/hooks/lib/refresh.mjs +11 -1
- package/hooks/lib/replay.mjs +218 -100
- package/package.json +1 -1
- package/skills/bravos/SKILL.md +1 -0
- package/skills/bravos-context/SKILL.md +4 -4
- package/skills/bravos-principles/SKILL.md +52 -0
- package/templates/dashboard/dashboard.html +75 -1
- package/templates/review/review.html +140 -11
- package/templates/workflows/bravos-nightly-claude.yml +1 -1
- package/templates/workflows/bravos-nightly-codex.yml +1 -1
- package/templates/workflows/bravos-pr-gate.yml +1 -1
|
@@ -221,6 +221,8 @@ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid va
|
|
|
221
221
|
var head = mk('div', 'page-head');
|
|
222
222
|
var ht = mk('div', 'ph-text');
|
|
223
223
|
ht.append(mk('h2', 'ph-title', 'Design rules'), mk('p', 'lead', doc.note || ''), mk('p', 'lead', 'The business-logic rules your design states (INV-n in .guardlink/intent.md), where the code enforces each one, and what testing has shown. Broken and lapsed rules come first.'));
|
|
224
|
+
// The intake behind the rules: who confirmed it, what is still open, the documents. Text only.
|
|
225
|
+
if (doc.intake) ht.append(mk('p', 'lead', doc.intake));
|
|
224
226
|
head.append(ht);
|
|
225
227
|
sec.append(head);
|
|
226
228
|
var chips = mk('div', 'rchips');
|
|
@@ -428,7 +430,7 @@ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid va
|
|
|
428
430
|
].join('');
|
|
429
431
|
const rulesForFrame = () => {
|
|
430
432
|
// With no rules yet, the sidebar item still appears, saying how to get them.
|
|
431
|
-
const doc = hasRules ? RULES : { rules: [], note: (DATA.rules || {}).note || 'No design rules yet: /bravos-context asks for your design documents and writes the rules they state into .guardlink/intent.md.' };
|
|
433
|
+
const doc = Object.assign({}, hasRules ? RULES : { rules: [], note: (DATA.rules || {}).note || 'No design rules yet: /bravos-context asks for your design documents and writes the rules they state into .guardlink/intent.md.' }, DATA.intake ? { intake: DATA.intake } : {});
|
|
432
434
|
const inert = JSON.stringify(doc).replace(/</g, '\\u003c');
|
|
433
435
|
return '<style>' + RULES_CSS + '</style><script type="application/json" id="bravos-rules-data">' + inert + '</scr' + 'ipt><scr' + 'ipt>(' + frameRules.toString() + ')();</scr' + 'ipt>';
|
|
434
436
|
};
|
|
@@ -532,6 +534,78 @@ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid va
|
|
|
532
534
|
},
|
|
533
535
|
});
|
|
534
536
|
|
|
537
|
+
// Security design: the company's principles adopted in this repository (.guardlink/principles.md), each with where
|
|
538
|
+
// the code enforces it, its exceptions and when they end, and what it has done lately. Bravos computes this
|
|
539
|
+
// (src/rules.ts) and it is drawn here as text. Shown only when the repository has principles or something to say.
|
|
540
|
+
// @comment -- "The Security design view: one card per adopted principle with its status, kind, statement, where it applies, who adopted it, the threats and INV rules that stand for it, each place it is enforced (a place under a live exception marked with the approver and end date), its exceptions, and its value: tests that tried it, breaks caught, and pre-PR gate stops recorded on this machine in the last 30 and 90 days. Every value is set as text."
|
|
541
|
+
if (RULES && ((Array.isArray(RULES.principles) && RULES.principles.length) || RULES.principlesNote)) views.push({
|
|
542
|
+
id: 'security-design',
|
|
543
|
+
label: 'Security design',
|
|
544
|
+
build(section) {
|
|
545
|
+
const LABEL = { broken: 'broken', 'retest-due': 'retest due', holds: 'holds', unguarded: 'unguarded', 'guarded-untested': 'guarded, untested', 'not-placed': 'not placed', guidance: 'guidance' };
|
|
546
|
+
const SITE = { check: 'enforced at', gap: 'no control at', grant: 'granted in' };
|
|
547
|
+
const STATE = { broken: 'a test got through', retest: 'the code changed since it was tested', held: 'a test was refused', untested: 'not tested' };
|
|
548
|
+
const wrap = el('div', { class: 'rules' });
|
|
549
|
+
const inner = el('div', { class: 'rules-inner' });
|
|
550
|
+
const lead = prose(RULES.principlesNote || '');
|
|
551
|
+
lead.className = 'rules-lead';
|
|
552
|
+
inner.append(lead, prose('Your company\'s security design principles, adopted by named people on bravos review principles and kept in .guardlink/principles.md. Every coding agent here follows them; an enforced principle is tested, and the pre-PR gate stops a change that breaks it unless a person approved an exception for that code.'));
|
|
553
|
+
for (const p of RULES.principles || []) {
|
|
554
|
+
const status = LABEL[p.status] ? p.status : 'not-placed';
|
|
555
|
+
const card = el('article', { class: 'rule ' + status });
|
|
556
|
+
const head = el('div', { class: 'rule-head' });
|
|
557
|
+
head.append(el('span', { class: 'pill ' + status }, LABEL[status]), el('span', { class: 'rule-id' }, p.id));
|
|
558
|
+
if (status !== 'guidance') head.append(el('span', { class: 'pill' }, p.kind));
|
|
559
|
+
card.append(head, el('p', { class: 'rule-text' }, p.statement || ''), el('p', { class: 'rule-why' }, p.why || ''));
|
|
560
|
+
const meta = el('ul', { class: 'rule-meta' });
|
|
561
|
+
const fact = (label, value) => {
|
|
562
|
+
if (!value) return;
|
|
563
|
+
const li = el('li');
|
|
564
|
+
li.append(el('b', {}, label + ' '), value);
|
|
565
|
+
meta.append(li);
|
|
566
|
+
};
|
|
567
|
+
fact('applies to', p.scope);
|
|
568
|
+
fact('adopted by', (p.adoptedBy || []).map((a) => a.by + ' (' + a.date + ')').join(', '));
|
|
569
|
+
fact('threats', (p.threats || []).join(', '));
|
|
570
|
+
fact('design rules', (p.rules || []).join(', '));
|
|
571
|
+
const v = p.value || {};
|
|
572
|
+
const pair = (x) => (Array.isArray(x) ? x[0] + ' in 30 days, ' + x[1] + ' in 90' : '');
|
|
573
|
+
if (p.kind === 'enforced') {
|
|
574
|
+
fact('tested', pair(v.tested));
|
|
575
|
+
fact('breaks caught by a test', pair(v.caught));
|
|
576
|
+
fact('changes stopped by the pre-PR gate on this machine', pair(v.gateStops));
|
|
577
|
+
fact('code it covers', v.files ? v.files + ' file' + (v.files === 1 ? '' : 's') : '');
|
|
578
|
+
}
|
|
579
|
+
card.append(meta);
|
|
580
|
+
if (Array.isArray(p.sites) && p.sites.length) {
|
|
581
|
+
const sites = el('ul', { class: 'sites' });
|
|
582
|
+
for (const st of p.sites) {
|
|
583
|
+
const li = el('li');
|
|
584
|
+
li.append(el('span', {}, SITE[st.kind] || 'at'), el('span', { class: 'where' }, String(st.file) + (st.line ? ':' + st.line : '')));
|
|
585
|
+
if (st.exception) li.append(el('span', { class: 'state retest' }, 'under an exception until ' + st.exception.until + (st.exception.by ? ', approved by ' + st.exception.by : '')));
|
|
586
|
+
else if (st.state) li.append(el('span', { class: 'state ' + st.state }, STATE[st.state] || st.state));
|
|
587
|
+
if (st.control) li.append(el('span', {}, 'by #' + st.control));
|
|
588
|
+
sites.append(li);
|
|
589
|
+
}
|
|
590
|
+
card.append(sites);
|
|
591
|
+
}
|
|
592
|
+
if (Array.isArray(p.exceptions) && p.exceptions.length) {
|
|
593
|
+
const ex = el('ul', { class: 'sites' });
|
|
594
|
+
for (const e of p.exceptions) {
|
|
595
|
+
const li = el('li');
|
|
596
|
+
li.append(el('span', {}, e.live ? 'exception' : 'ended exception'), el('span', { class: 'where' }, e.where), el('span', {}, 'until ' + e.until), el('span', {}, e.reason));
|
|
597
|
+
if (e.by) li.append(el('span', {}, 'approved by ' + e.by + ' on ' + e.approved));
|
|
598
|
+
ex.append(li);
|
|
599
|
+
}
|
|
600
|
+
card.append(ex);
|
|
601
|
+
}
|
|
602
|
+
inner.append(card);
|
|
603
|
+
}
|
|
604
|
+
wrap.append(inner);
|
|
605
|
+
section.append(wrap);
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
|
|
535
609
|
// Code graph: the seven pages the Bravos VS Code extension draws (Map, Owners & History, Coupling, Trust,
|
|
536
610
|
// Attack surface, Entry points, Links), vendored unchanged and run in their own sandboxed frame. In the editor
|
|
537
611
|
// a page asks its host for data; here the host is the small script below, which answers from the graph's
|
|
@@ -92,6 +92,16 @@ th,td { text-align: left; padding: 4px 7px; border-bottom: 1px solid var(--line)
|
|
|
92
92
|
textarea { width: 100%; min-height: 64px; margin: 5px 0; resize: vertical; }
|
|
93
93
|
textarea.comment { min-height: 37px; }
|
|
94
94
|
.note { padding: 10px; background: var(--chip); margin: 12px 0; }
|
|
95
|
+
.badge.changed { color: var(--warn); border-color: #865d40; }
|
|
96
|
+
.excerpt { margin: 8px 0; padding: 8px 10px; border-left: 2px solid var(--accent); background: #13201b; font-size: 13px; }
|
|
97
|
+
.excerpt b { display: block; font: 11px/1.5 var(--mono); color: var(--muted); }
|
|
98
|
+
.excerpt pre { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 system-ui, sans-serif; color: var(--ink); max-height: 14em; overflow: auto; }
|
|
99
|
+
.confirmed { padding: 10px 12px; margin: 12px 0; border: 1px solid #3c6854; background: #1b3027; border-radius: 4px; }
|
|
100
|
+
.docs { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 4px; }
|
|
101
|
+
.docs summary { font-weight: 600; }
|
|
102
|
+
.docs .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
|
|
103
|
+
.docs input[type=text], .docs input[type=url], .docs select { background: #111b17; border: 1px solid #64796c; border-radius: 4px; padding: 6px 8px; color: var(--ink); }
|
|
104
|
+
.stale li { font-size: 13px; color: var(--muted); }
|
|
95
105
|
.skip { position: absolute; left: -10000px; }
|
|
96
106
|
.skip:focus { left: 12px; top: 6px; z-index: 2; background: var(--bg); }
|
|
97
107
|
@media(max-width:780px) {
|
|
@@ -127,10 +137,21 @@ textarea.comment { min-height: 37px; }
|
|
|
127
137
|
<div id="lens" class="lens" hidden><span class="metakey">Draft perspective</span><b id="perspective"></b></div></header>
|
|
128
138
|
<h1 id="heading" tabindex="-1">Review</h1><p id="sub"></p>
|
|
129
139
|
<section class="scope" id="matrix" hidden><h2>Who may do what</h2><p>Each cell opens a proposed permission for review.</p></section>
|
|
140
|
+
<details id="docs" class="docs" hidden><summary>Your design documents</summary>
|
|
141
|
+
<p class="note">Add a PRD, a design document or an earlier threat model. Markdown and text are stored now, with the same checks as <code>bravos context add</code> (no secrets, no local paths, no embedded images), and committed for the team. A PDF, Word file, slides or a link waits for your agent to convert and store it.</p>
|
|
142
|
+
<div class="row"><input id="doctitle" type="text" placeholder="What it is, e.g. Billing PRD" maxlength="120" aria-label="Document title">
|
|
143
|
+
<select id="dockind" aria-label="Kind of document"><option value="prd">PRD</option><option value="design">Design</option><option value="threat-model">Threat model</option><option value="policy">Policy</option><option value="api">API</option><option value="other">Other</option></select></div>
|
|
144
|
+
<div class="row"><input id="docfile" type="file" accept=".md,.markdown,.txt,.pdf,.doc,.docx,.ppt,.pptx,.key,.odt,.odp,.rtf,.html,.htm,.pages" aria-label="Choose a file"><span class="metakey">or</span><input id="docurl" type="url" placeholder="https://… a link" aria-label="A link"></div>
|
|
145
|
+
<textarea id="doctext" placeholder="…or paste the text here" aria-label="Paste the document text"></textarea>
|
|
146
|
+
<div class="row"><button id="docadd" type="button">Add document</button></div>
|
|
147
|
+
<div id="docstatus" class="note hidden" role="status"></div>
|
|
148
|
+
</details>
|
|
130
149
|
<details id="sources" class="srcs" hidden><summary id="sourcecount"></summary><div id="sourcelist"></div></details>
|
|
150
|
+
<div id="confirmed" class="confirmed hidden" role="status"></div>
|
|
131
151
|
<div class="bar" id="review-actions"><label for="who">Reviewer</label><input id="who" placeholder="Your name" autocomplete="name" maxlength="80">
|
|
132
152
|
<button id="save" class="primary">Confirm</button><button id="draftfile">Download review inputs</button></div>
|
|
133
153
|
<div id="status" class="note hidden" role="status"></div><div id="questions"></div>
|
|
154
|
+
<details id="stale" class="stale" hidden><summary>No longer asked</summary><p class="note">You answered these before; the draft no longer asks them. Your answers are kept in your file.</p><ul id="stalelist"></ul></details>
|
|
134
155
|
<a href="#review-actions">Return to review actions ↑</a>
|
|
135
156
|
</article>
|
|
136
157
|
</main>
|
|
@@ -152,6 +173,7 @@ textarea.comment { min-height: 37px; }
|
|
|
152
173
|
$('sub').textContent = isIntent
|
|
153
174
|
? owner ? 'Confirm what the product is for, who may act, and which outcomes must never occur.'
|
|
154
175
|
: 'Review the proposed scope, assumptions and boundaries. Make each decision marked as needing your call.'
|
|
176
|
+
: draft.kind === 'principles' ? 'Each principle below came from your documents, a rule your team confirmed, or bravos\'s optional starter list. Adopt each one yourself: Agree keeps the wording, Change rewords it, No leaves it out. There is no adopt-all; what you adopt becomes .guardlink/principles.md, which every coding agent here follows.'
|
|
155
177
|
: 'Review the questions below and confirm your answers.';
|
|
156
178
|
if (draft.repo) {
|
|
157
179
|
const label = DATA.repoUrl ? el('a') : el('span');
|
|
@@ -219,7 +241,10 @@ textarea.comment { min-height: 37px; }
|
|
|
219
241
|
$('who').addEventListener('change', () => store.set('bravos-review-name', $('who').value.trim()));
|
|
220
242
|
|
|
221
243
|
const qs = draft.questions;
|
|
222
|
-
const state = Object.create(null); // id -> { verdict, value, touched, comment }
|
|
244
|
+
const state = Object.create(null); // id -> { verdict, value, touched, comment, changed? }
|
|
245
|
+
// Filled in by load(): answers to questions no longer asked, and when this person last confirmed.
|
|
246
|
+
let staleAnswers = null;
|
|
247
|
+
let confirmedAt = null;
|
|
223
248
|
const cards = Object.create(null);
|
|
224
249
|
const sameValue = (a, b) => JSON.stringify(Array.isArray(a) ? [...a].sort() : a) === JSON.stringify(Array.isArray(b) ? [...b].sort() : b);
|
|
225
250
|
const status = (msg) => { const s = $('status'); s.textContent = msg; s.classList.remove('hidden'); };
|
|
@@ -314,7 +339,7 @@ textarea.comment { min-height: 37px; }
|
|
|
314
339
|
for (const [kind, count] of Object.entries(counts)) counters.get(kind).textContent = count;
|
|
315
340
|
$('remaining').textContent = counts.pending;
|
|
316
341
|
$('save').disabled = counts.pending > 0;
|
|
317
|
-
$('save').textContent = mode.kind === 'file' ? 'Download answers' : 'Confirm';
|
|
342
|
+
$('save').textContent = mode.kind === 'file' ? 'Download answers' : confirmedAt ? 'Confirm again' : 'Confirm';
|
|
318
343
|
};
|
|
319
344
|
|
|
320
345
|
// Optional, explicit role/action proposals. Missing cells have no rule. Clicking only navigates to the source question.
|
|
@@ -406,6 +431,7 @@ textarea.comment { min-height: 37px; }
|
|
|
406
431
|
else if (s.verdict === 'chosen') top.appendChild(el('span', 'badge chosen', 'your call'));
|
|
407
432
|
else if (s.verdict === 'accepted') top.appendChild(el('span', 'badge sugg', 'suggested'));
|
|
408
433
|
if (q.confidence === 'low') top.appendChild(el('span', 'badge low', 'bravos is unsure'));
|
|
434
|
+
if (s.changed) top.appendChild(el('span', 'badge changed', 'changed since you answered — check'));
|
|
409
435
|
return top;
|
|
410
436
|
};
|
|
411
437
|
|
|
@@ -417,8 +443,15 @@ textarea.comment { min-height: 37px; }
|
|
|
417
443
|
if (q.title) card.appendChild(el('div', 'title', q.title));
|
|
418
444
|
if (q.why) card.appendChild(el('div', 'why', q.why));
|
|
419
445
|
if (q.type === 'item' && q.text) card.appendChild(el('div', 'text', q.text));
|
|
446
|
+
// A principle's kind, where it applies and why, as text from the draft.
|
|
447
|
+
if (q.principle) card.appendChild(el('div', 'reason', (q.principle.kind === 'enforced' ? 'Enforced: tested, and the pre-PR gate stops a change that breaks it' : 'Guidance: coding agents follow it; nothing is tested') + ' · applies to ' + q.principle.scope + (Array.isArray(q.principle.paths) && q.principle.paths.length ? ' (' + q.principle.paths.join(', ') + ')' : '') + (q.principle.why ? ' · why: ' + q.principle.why : '')));
|
|
420
448
|
if (q.reason) card.appendChild(el('div', 'reason', `bravos: ${q.reason}`));
|
|
421
449
|
if (q.sources && q.sources.length) card.appendChild(el('div', 'sources', `from ${q.sources.join(' · ')}`));
|
|
450
|
+
for (const x of q.excerpts || []) {
|
|
451
|
+
const box = el('div', 'excerpt');
|
|
452
|
+
box.append(el('b', '', `${x.id} · “${x.section}” — the passage itself`), el('pre', '', x.text));
|
|
453
|
+
card.appendChild(box);
|
|
454
|
+
}
|
|
422
455
|
|
|
423
456
|
const row = el('div', 'choices');
|
|
424
457
|
const btn = (label, on, fn) => {
|
|
@@ -550,13 +583,13 @@ textarea.comment { min-height: 37px; }
|
|
|
550
583
|
const s = state[q.id];
|
|
551
584
|
if (!s.verdict && !s.comment) continue;
|
|
552
585
|
const ownText = s.own !== undefined && s.own.trim() ? { text: s.own.trim() } : {};
|
|
553
|
-
answers[q.id] = { verdict: s.verdict || 'comment', ...(s.verdict && s.verdict !== 'accepted' && s.value !== null ? { value: s.value } : {}), ...ownText, ...(s.comment ? { comment: s.comment } : {}) };
|
|
586
|
+
answers[q.id] = { verdict: s.verdict || 'comment', ...(s.verdict && s.verdict !== 'accepted' && s.value !== null ? { value: s.value } : {}), ...ownText, ...(s.comment ? { comment: s.comment } : {}), ...(q.suggested !== undefined ? { suggested: q.suggested } : {}) };
|
|
554
587
|
}
|
|
555
|
-
return { schema: 'bravos.review-answers/v1', kind: draft.kind, by, date: new Date().toISOString().slice(0, 10), answers };
|
|
588
|
+
return { schema: 'bravos.review-answers/v1', kind: draft.kind, by, date: new Date().toISOString().slice(0, 10), answers, ...(staleAnswers ? { stale: staleAnswers } : {}) };
|
|
556
589
|
};
|
|
557
590
|
const slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
|
|
558
591
|
|
|
559
|
-
const api = (path, body) => fetch(`${path}?t=${encodeURIComponent(mode.token)}`, body === undefined ? {} : { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
592
|
+
const api = (path, body, query) => fetch(`${path}?t=${encodeURIComponent(mode.token)}${query ? Object.entries(query).map(([k, v]) => `&${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('') : ''}`, body === undefined ? {} : { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
560
593
|
|
|
561
594
|
// Artifact mode (opt-in sharing): the page saves through the artifact's shared database (claude.use('db')),
|
|
562
595
|
// which resolves null outside claude.ai; the page then falls back to downloading the answers file.
|
|
@@ -567,30 +600,126 @@ textarea.comment { min-height: 37px; }
|
|
|
567
600
|
return dbPromise;
|
|
568
601
|
};
|
|
569
602
|
|
|
603
|
+
// @comment -- "Picking up where a person left off: their unconfirmed answers (saved as they went) if any, else their confirmed file, filled into the form. An answer given before bravos changed its suggestion, or to a question that was replaced, is filled in but flagged, and a must-touch one needs the person's call again. Everyone else's answers stay as read-only chips."
|
|
604
|
+
const sameAs = (a, b) => JSON.stringify(Array.isArray(a) ? [...a].sort() : a) === JSON.stringify(Array.isArray(b) ? [...b].sort() : b);
|
|
605
|
+
const applyAnswers = (file) => {
|
|
606
|
+
if (!file || !file.answers) return;
|
|
607
|
+
for (const q of qs) {
|
|
608
|
+
const a = Object.hasOwn(file.answers, q.id) ? file.answers[q.id] : null;
|
|
609
|
+
if (!a) continue;
|
|
610
|
+
const s = state[q.id];
|
|
611
|
+
const v = a.verdict;
|
|
612
|
+
if (v === 'accepted') { s.verdict = 'accepted'; s.value = Array.isArray(q.suggested) ? [...q.suggested] : (q.suggested ?? s.value); }
|
|
613
|
+
else if (v === 'chosen' || v === 'agree') { s.value = a.value ?? (Array.isArray(q.suggested) ? [...q.suggested] : q.suggested ?? 'agree'); s.verdict = v === 'agree' ? 'accepted' : 'chosen'; s.touched = true; }
|
|
614
|
+
else if (v === 'no') { s.value = 'no'; s.verdict = 'no'; s.touched = true; }
|
|
615
|
+
else if (v === 'edited' || v === 'change' || v === 'choice') {
|
|
616
|
+
if (a.value !== undefined) s.value = a.value;
|
|
617
|
+
else if (v === 'choice' && a.choice) s.value = a.choice;
|
|
618
|
+
else if (a.text) { if (q.type === 'choice' || q.type === 'multi') { s.own = a.text; s.value = null; } else s.value = a.text; }
|
|
619
|
+
s.verdict = 'edited';
|
|
620
|
+
s.touched = true;
|
|
621
|
+
}
|
|
622
|
+
if (a.comment) s.comment = a.comment;
|
|
623
|
+
const moved = !!a.from || (a.suggested !== undefined && q.suggested !== undefined && !sameAs(a.suggested, q.suggested));
|
|
624
|
+
if (moved) { s.changed = true; if (q.mustTouch) s.touched = false; }
|
|
625
|
+
}
|
|
626
|
+
if (file.stale && Object.keys(file.stale).length) {
|
|
627
|
+
staleAnswers = file.stale;
|
|
628
|
+
const list = $('stalelist');
|
|
629
|
+
list.replaceChildren();
|
|
630
|
+
for (const [id, a] of Object.entries(file.stale)) list.append(el('li', '', `${id}: ${a.verdict}${a.comment ? ' · ' + a.comment : ''}`));
|
|
631
|
+
$('stale').hidden = false;
|
|
632
|
+
}
|
|
633
|
+
for (const q of qs) render(q);
|
|
634
|
+
refresh();
|
|
635
|
+
};
|
|
636
|
+
const showConfirmed = (who, at) => {
|
|
637
|
+
const box = $('confirmed');
|
|
638
|
+
box.replaceChildren(el('b', '', `Confirmed by ${who}${at ? ' on ' + at.slice(0, 10) : ''}.`), document.createTextNode(' Your answers are filled in below. Change any of them and press Confirm again; until then your confirmed answers stand.'));
|
|
639
|
+
box.classList.remove('hidden');
|
|
640
|
+
};
|
|
570
641
|
const load = async () => {
|
|
571
642
|
try {
|
|
572
|
-
if (mode.kind === 'serve') {
|
|
573
|
-
|
|
643
|
+
if (mode.kind === 'serve') {
|
|
644
|
+
const r = await api('/answers');
|
|
645
|
+
const all = r.ok ? await r.json() : [];
|
|
646
|
+
const me = slug($('who').value.trim());
|
|
647
|
+
const mine = me ? all.find((f) => slug(f.by) === me) : null;
|
|
648
|
+
const others = all.filter((f) => f !== mine);
|
|
649
|
+
let progress = null;
|
|
650
|
+
if (me) { const pr = await api('/progress', undefined, { by: $('who').value.trim() }); if (pr.ok) progress = await pr.json(); }
|
|
651
|
+
applyAnswers(progress || mine);
|
|
652
|
+
if (mine) { confirmedAt = mine.confirmedAt || mine.date; showConfirmed(mine.by, confirmedAt); refresh(); }
|
|
653
|
+
if (progress && mine) status('You have changes since you confirmed; they are filled in. Press Confirm to make them count.');
|
|
654
|
+
showOthers(others);
|
|
655
|
+
} else if (mode.kind === 'artifact') {
|
|
574
656
|
const db = await artifactDb();
|
|
575
657
|
if (db) { const snap = await db.collection('answers').get(); showOthers(snap.docs.map((d) => d.data()).filter(Boolean)); }
|
|
576
658
|
}
|
|
577
659
|
} catch { /* offline: nothing to show */ }
|
|
578
660
|
};
|
|
579
661
|
load();
|
|
662
|
+
$('who').addEventListener('change', () => { if (mode.kind === 'serve') load(); });
|
|
663
|
+
|
|
664
|
+
// @comment -- "Saves as the person goes: two seconds after the last change, to the server's scratch file for them (never the committed answers, never counted). Only on a served page, and only once they have given a name."
|
|
665
|
+
let saveTimer = null;
|
|
666
|
+
const autosave = () => {
|
|
667
|
+
if (mode.kind !== 'serve') return;
|
|
668
|
+
clearTimeout(saveTimer);
|
|
669
|
+
saveTimer = setTimeout(async () => {
|
|
670
|
+
const p = payload();
|
|
671
|
+
if (!slug(p.by)) return;
|
|
672
|
+
try { await api('/progress', p); } catch { /* the next change tries again */ }
|
|
673
|
+
}, 2000);
|
|
674
|
+
};
|
|
675
|
+
$('questions').addEventListener('click', autosave);
|
|
676
|
+
$('questions').addEventListener('input', autosave);
|
|
677
|
+
|
|
678
|
+
// @comment -- "The documents panel: paste or upload Markdown and text (stored now, with the usual checks), or a PDF, Word file, slides or a link (kept for the agent to convert). The browser reports a file name, never its path. Served pages only."
|
|
679
|
+
if (mode.kind === 'serve') {
|
|
680
|
+
$('docs').hidden = false;
|
|
681
|
+
const docStatus = (msg, bad) => { const d = $('docstatus'); d.textContent = msg; d.classList.remove('hidden'); d.style.color = bad ? 'var(--warn)' : ''; };
|
|
682
|
+
const asBase64 = (file) => new Promise((resolve, reject) => { const r = new FileReader(); r.onload = () => resolve(String(r.result).split(',')[1] || ''); r.onerror = reject; r.readAsDataURL(file); });
|
|
683
|
+
const asText = (file) => new Promise((resolve, reject) => { const r = new FileReader(); r.onload = () => resolve(String(r.result)); r.onerror = reject; r.readAsText(file); });
|
|
684
|
+
$('docadd').addEventListener('click', async () => {
|
|
685
|
+
const by = $('who').value.trim();
|
|
686
|
+
const title = $('doctitle').value.trim();
|
|
687
|
+
if (!slug(by)) { docStatus('Enter your name in Reviewer first: the document is recorded as added by you.', true); $('who').focus(); return; }
|
|
688
|
+
if (!title) { docStatus('Give the document a title.', true); $('doctitle').focus(); return; }
|
|
689
|
+
const body = { title, kind: $('dockind').value, by };
|
|
690
|
+
const file = $('docfile').files[0];
|
|
691
|
+
try {
|
|
692
|
+
if (file) {
|
|
693
|
+
if (/\.(md|markdown|txt)$/i.test(file.name)) { body.text = await asText(file); body.name = file.name; }
|
|
694
|
+
else body.file = { name: file.name, base64: await asBase64(file) };
|
|
695
|
+
} else if ($('docurl').value.trim()) body.url = $('docurl').value.trim();
|
|
696
|
+
else if ($('doctext').value.trim()) body.text = $('doctext').value;
|
|
697
|
+
else { docStatus('Choose a file, give a link, or paste the text.', true); return; }
|
|
698
|
+
const r = await api('/documents', body);
|
|
699
|
+
const t = await r.text();
|
|
700
|
+
if (!r.ok) { docStatus(t, true); return; }
|
|
701
|
+
docStatus(JSON.parse(t).lines.join(' '));
|
|
702
|
+
$('doctitle').value = ''; $('docurl').value = ''; $('doctext').value = ''; $('docfile').value = '';
|
|
703
|
+
} catch (e) { docStatus(`Could not add it (${e.message || e}).`, true); }
|
|
704
|
+
});
|
|
705
|
+
}
|
|
580
706
|
|
|
581
|
-
// @comment -- "One button finishes the review. Confirm saves this person's answers
|
|
707
|
+
// @comment -- "One button finishes the review. Confirm saves this person's answers (the server records when), which is what the agent's bravos review --wait is waiting for: there is no separate Done to forget. The page stays open and shows the confirmed state, so the person can change an answer and confirm again. Teammates add theirs later with their own bravos review run. A shared (claude.ai) page saves to its shared store; a file page downloads the answers."
|
|
582
708
|
$('save').addEventListener('click', async () => {
|
|
583
709
|
const p = payload();
|
|
584
710
|
if (!slug(p.by)) { status('Enter a name containing a letter a–z or a digit to identify your answers file.'); $('who').focus(); return; }
|
|
585
711
|
store.set('bravos-review-name', p.by);
|
|
586
712
|
try {
|
|
587
713
|
if (mode.kind === 'serve') {
|
|
714
|
+
clearTimeout(saveTimer);
|
|
588
715
|
const r = await api('/answers', p);
|
|
589
716
|
if (r.status === 400) { status(await r.text()); return; }
|
|
590
717
|
if (!r.ok) throw new Error(await r.text());
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
718
|
+
const done = await r.json();
|
|
719
|
+
confirmedAt = done.confirmedAt;
|
|
720
|
+
showConfirmed(p.by, confirmedAt);
|
|
721
|
+
refresh();
|
|
722
|
+
status(`Saved to .guardlink/${draft.kind}-answers/${slug(p.by)}.json. The agent carries on from here; you can close this tab, or change an answer and confirm again. Teammates add theirs with bravos review ${draft.kind}.`);
|
|
594
723
|
return;
|
|
595
724
|
}
|
|
596
725
|
const db = await artifactDb();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# bravos:generated — written by `bravos
|
|
1
|
+
# bravos:generated — written by `bravos setup --ci`; a later `bravos setup` refreshes it while this line stays.
|
|
2
2
|
# The nightly "bulk bee": Claude Code covers the next slice of unannotated files with the
|
|
3
3
|
# bravos-annotate skill, the lint gate checks what it wrote, and the job opens one small PR.
|
|
4
4
|
# A separate clean runner first replays reviewed kits under a current scheduled grant.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# bravos:generated — written by `bravos
|
|
1
|
+
# bravos:generated — written by `bravos setup --ci`; a later `bravos setup` refreshes it while this line stays.
|
|
2
2
|
# The nightly "bulk bee": Codex covers the next slice of unannotated files with the
|
|
3
3
|
# bravos-annotate skill, the lint gate checks what it wrote, and the job opens one small PR.
|
|
4
4
|
# A separate clean runner first replays reviewed kits under a current scheduled grant.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# bravos:generated — written by `bravos
|
|
1
|
+
# bravos:generated — written by `bravos setup --ci`; a later `bravos setup` refreshes it while this line stays.
|
|
2
2
|
# The bravos-ship gate as a pull-request check, the same rulings as the opt-in pre-PR hook.
|
|
3
3
|
# Deterministic: it runs guardlink only, spends no model, and needs no secret. A gate input that
|
|
4
4
|
# fails or does not parse fails the job as "unknown", never passes. Every action is pinned to a
|