@bugb-technologies/bravos 1.9.1 → 1.9.3
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/install-proof-tool.js +24 -0
- package/dist/review.js +3 -1
- package/dist/setup.js +7 -1
- package/dist/start/answers.js +53 -0
- package/dist/start/index.js +41 -10
- package/docs/UPGRADING.md +11 -0
- package/package.json +1 -1
- package/templates/review/review.html +60 -4
|
@@ -23,6 +23,27 @@ const prerequisites = {
|
|
|
23
23
|
tar: 'install tar for the pinned GuardLink grammar build',
|
|
24
24
|
cargo: 'install the Rust toolchain (cargo and rustc) and a native linker',
|
|
25
25
|
};
|
|
26
|
+
// @comment -- "Where cargo puts what it installs (CARGO_INSTALL_ROOT, else CARGO_HOME, else ~/.cargo, then /bin), and whether that folder is on PATH. A cargo from Homebrew or a package manager runs fine while that folder is missing from PATH, so cxg builds for minutes and then nothing can find it; setup checks first and says the one line to add."
|
|
27
|
+
export function cargoBinDir(env) {
|
|
28
|
+
const root = env.CARGO_INSTALL_ROOT || env.CARGO_HOME || (env.HOME ? join(env.HOME, '.cargo') : null);
|
|
29
|
+
return root ? join(isAbsolute(root) ? root : resolve(root), 'bin') : null;
|
|
30
|
+
}
|
|
31
|
+
export function cargoBinOnPath(env) {
|
|
32
|
+
const dir = cargoBinDir(env);
|
|
33
|
+
if (!dir)
|
|
34
|
+
return true;
|
|
35
|
+
return (env.PATH ?? '').split(delimiter).some((p) => p && resolve(p) === dir);
|
|
36
|
+
}
|
|
37
|
+
/** The line that puts cargo's folder on PATH, for the person's own shell profile. */
|
|
38
|
+
export function cargoPathFix(env) {
|
|
39
|
+
const dir = cargoBinDir(env) ?? '~/.cargo/bin';
|
|
40
|
+
const shown = env.HOME && dir.startsWith(env.HOME + '/') ? `$HOME${dir.slice(env.HOME.length)}` : dir;
|
|
41
|
+
const shell = (env.SHELL ?? '').split('/').pop();
|
|
42
|
+
const profile = shell === 'zsh' ? '~/.zshrc' : shell === 'bash' ? '~/.bash_profile' : shell === 'fish' ? null : '~/.profile';
|
|
43
|
+
return profile
|
|
44
|
+
? `echo 'export PATH="${shown}:$PATH"' >> ${profile}, then open a new terminal`
|
|
45
|
+
: `fish_add_path ${shown}, then open a new terminal`;
|
|
46
|
+
}
|
|
26
47
|
// @comment -- "Use fixed package-manager argv in a private scratch directory, outside the customer repository. Ignore inherited Git working-tree overrides and relative PATH entries, so the checkout cannot supply a .cargo/config.toml, .npmrc, Git config or executable for the install."
|
|
27
48
|
export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
|
|
28
49
|
const pin = pins[name];
|
|
@@ -103,6 +124,9 @@ export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
|
|
|
103
124
|
// Check the user's PATH again after installation, before invoking any post-install command on the selected binary.
|
|
104
125
|
const found = whichBin(name, installEnv);
|
|
105
126
|
const status = checkProofTool(name, installEnv);
|
|
127
|
+
if (!found && name === 'cxg' && !cargoBinOnPath(env)) {
|
|
128
|
+
throw new BravosError(`cxg was built and installed in ${cargoBinDir(env)}, but that folder is not on your PATH, so nothing can run it. Add it once: ${cargoPathFix(env)}; then run bravos setup --check.`);
|
|
129
|
+
}
|
|
106
130
|
if (!found || status.status !== 'ready') {
|
|
107
131
|
const destination = name === 'guardlink' ? 'the bin directory under npm prefix --global' : 'the bin directory under your Cargo install root (normally ~/.cargo/bin)';
|
|
108
132
|
throw new BravosError(`${name} was installed but ${found ?? 'no executable'} is selected on PATH (${status.status}). Put ${destination} first, check which -a ${name}, then run bravos setup --check.`);
|
package/dist/review.js
CHANGED
|
@@ -243,7 +243,9 @@ function effective(q, a) {
|
|
|
243
243
|
return 'no';
|
|
244
244
|
const legacy = a.verdict === 'choice' ? a.choice : a.verdict === 'change' ? a.text : undefined;
|
|
245
245
|
const asIs = a.verdict === 'accepted' || a.verdict === 'agree' ? (q.suggested ?? 'agree') : undefined;
|
|
246
|
-
|
|
246
|
+
// An answer in the reviewer's own words (a choice or multi question none of whose options fit) is carried as text.
|
|
247
|
+
const own = a.verdict === 'edited' && a.value === undefined && a.text ? `own answer: "${a.text}"` : undefined;
|
|
248
|
+
const v = a.value ?? legacy ?? asIs ?? own ?? a.verdict;
|
|
247
249
|
return Array.isArray(v) ? [...v].sort().join(', ') : String(v);
|
|
248
250
|
}
|
|
249
251
|
// @comment -- "Plain-text summary for the agent, most important first: disagreements, edits and rejections, the must-touch decisions with who made them, unanswered questions, then one line per group of suggestions accepted as is, with names; no model involved."
|
package/dist/setup.js
CHANGED
|
@@ -10,7 +10,7 @@ import { findAnalyzer } from './graphbin.js';
|
|
|
10
10
|
import { licenceLib, requireFeature } from './licence.js';
|
|
11
11
|
import { BravosError } from './types.js';
|
|
12
12
|
import { PROOF_TOOL_PINS } from './versions.js';
|
|
13
|
-
import { installProofTool, proofToolAction } from './install-proof-tool.js';
|
|
13
|
+
import { cargoBinDir, cargoBinOnPath, cargoPathFix, installProofTool, proofToolAction } from './install-proof-tool.js';
|
|
14
14
|
// @comment -- "The version of a staged bundle when it is older than the one this bravos pins, else null. An existing install keeps working on the old bundle until setup runs; this is how setup, and its --check, know there is a newer one to fetch. Read-only."
|
|
15
15
|
export function behindPin(env, kind) {
|
|
16
16
|
const dir = staged(env, kind);
|
|
@@ -103,6 +103,12 @@ export async function runSetup(env, opts, io) {
|
|
|
103
103
|
lines.push(formatProofTool(check), i.id + ': already compatible at ' + i.present);
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
+
// A cxg already built into cargo's folder, which is not on PATH: building it again ends the same way, so say how to put it on PATH instead.
|
|
107
|
+
const built = cargoBinDir(env);
|
|
108
|
+
if (i.id === 'cxg' && !i.present && built && !cargoBinOnPath(env) && existsSync(join(built, 'cxg'))) {
|
|
109
|
+
lines.push(`cxg: already built at ${join(built, 'cxg')}, but that folder is not on your PATH, so nothing can run it. Add it once: ${cargoPathFix(env)}; no need to build it again.`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
106
112
|
if (opts.dryRun || !opts.yes) {
|
|
107
113
|
const state = i.present ? check.status + ' at ' + i.present : 'absent';
|
|
108
114
|
lines.push(i.id + ': ' + state + ' — ' + i.action + (opts.yes ? '' : ' (add -y to run it here)'));
|
package/dist/start/answers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @comment -- "What bravos setup asks and records: the answers, the three starting presets, the bravos setup command they amount to, and the two files only start writes itself — the person's proving choice (.guardlink/proving.md, their words and name) and the saved answers (.bravos/setup.json, for --again)."
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
import { CRON } from '../ci.js';
|
|
4
5
|
export const PRESETS = {
|
|
5
6
|
annotate: { label: 'Map my threats only', hint: 'annotations; nothing runs on its own', pr: 'none', autopilot: false, schedule: 'none', proving: 'none' },
|
|
6
7
|
// @comment -- "Autopilot is on for the pr preset in the preset itself, so bravos setup --yes and the interactive default agree."
|
|
@@ -114,3 +115,55 @@ export function targetProblem(value) {
|
|
|
114
115
|
}
|
|
115
116
|
/** The target as replay compares it (URL.href), or undefined when none was given. */
|
|
116
117
|
export const normalTarget = (value) => (value?.trim() ? new URL(value.trim()).href : undefined);
|
|
118
|
+
// @comment -- "What a repository that already has Bravos is set up with, read from the files it carries: the agents whose skills are installed, the pull-request checks (the pre-PR hook, the PR workflow), autopilot, the scheduled run and its cadence, and the recorded testing choice. The guided setup shows it when someone joins, and preselects it when they choose to change it; a repository installed by flags has no setup.json, so this is the only record of its choices."
|
|
119
|
+
export function currentSetup(repo, opts) {
|
|
120
|
+
const has = (rel) => existsSync(join(repo, rel));
|
|
121
|
+
const agents = [];
|
|
122
|
+
if (has('.claude/skills/bravos/SKILL.md'))
|
|
123
|
+
agents.push('claude');
|
|
124
|
+
if (has('.codex/hooks.json') && has('.agents/skills/bravos/SKILL.md'))
|
|
125
|
+
agents.push('codex');
|
|
126
|
+
if (has('.agents/hooks.json') && has('.agents/skills/bravos/SKILL.md'))
|
|
127
|
+
agents.push('agy');
|
|
128
|
+
if (has('.opencode/plugins/bravos.js'))
|
|
129
|
+
agents.push('opencode');
|
|
130
|
+
if (has('.omp/extensions/bravos.js'))
|
|
131
|
+
agents.push('omp');
|
|
132
|
+
const gate = has('.github/workflows/bravos-pr-gate.yml');
|
|
133
|
+
const nightly = ['claude', 'codex', 'copilot'].find((a) => has(`.github/workflows/bravos-nightly-${a}.yml`));
|
|
134
|
+
let schedule = 'none';
|
|
135
|
+
if (nightly) {
|
|
136
|
+
const text = readFileSync(join(repo, `.github/workflows/bravos-nightly-${nightly}.yml`), 'utf8');
|
|
137
|
+
schedule = Object.keys(CRON).find((c) => text.includes(CRON[c])) ?? 'weekly';
|
|
138
|
+
}
|
|
139
|
+
let proving;
|
|
140
|
+
try {
|
|
141
|
+
const m = /^choice:\s*(auto|ask|schedule|none)\b/m.exec(readFileSync(join(repo, '.guardlink', 'proving.md'), 'utf8'));
|
|
142
|
+
if (m)
|
|
143
|
+
proving = m[1];
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
/* no testing choice recorded */
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
...(agents.length ? { agents } : {}),
|
|
150
|
+
pr: gate ? 'hook+github' : opts.prePr || opts.autopilot ? 'hook' : 'none',
|
|
151
|
+
autopilot: opts.autopilot,
|
|
152
|
+
schedule,
|
|
153
|
+
...(nightly ? { nightlyAgent: nightly } : {}),
|
|
154
|
+
...(proving ? { proving } : {}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** The repository's setup in a few plain lines, for the guided setup to show before asking whether to keep it. */
|
|
158
|
+
export function describeSetup(a) {
|
|
159
|
+
const label = { claude: 'Claude Code', codex: 'Codex', agy: 'Antigravity', opencode: 'opencode', omp: 'oh-my-pi' };
|
|
160
|
+
const pr = { none: 'none', hook: 'checked before your agent opens a PR', 'hook+github': 'checked before your agent opens a PR, and every PR in GitHub' };
|
|
161
|
+
const proving = { ask: 'ask every time', auto: 'test the local app as you build', schedule: 'only in the scheduled run', none: 'never test, just annotate' };
|
|
162
|
+
return [
|
|
163
|
+
`Agents: ${(a.agents ?? []).map((x) => label[x] ?? x).join(', ') || 'none found'}`,
|
|
164
|
+
`Pull requests: ${pr[a.pr ?? 'none']}`,
|
|
165
|
+
`Autopilot: ${a.autopilot ? 'on: changed code is reviewed at the end of each agent turn' : 'off'}`,
|
|
166
|
+
`Schedule: ${a.schedule && a.schedule !== 'none' ? `${a.schedule}, run by ${a.nightlyAgent ?? 'claude'} in GitHub Actions` : 'none'}`,
|
|
167
|
+
`Testing: ${a.proving ? proving[a.proving] : 'not recorded yet (your agent asks when testing comes up)'}`,
|
|
168
|
+
];
|
|
169
|
+
}
|
package/dist/start/index.js
CHANGED
|
@@ -4,11 +4,13 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { resolveTheme, THEMES } from '../palette.js';
|
|
5
5
|
import { detectHarnesses } from '../detect.js';
|
|
6
6
|
import { CRON } from '../ci.js';
|
|
7
|
-
import { initArgs, nightlySecrets, normalTarget, PRESETS, provingText, readAnswers, targetProblem, writeAnswers, writeTheme, } from './answers.js';
|
|
7
|
+
import { initArgs, nightlySecrets, normalTarget, PRESETS, provingText, readAnswers, currentSetup, describeSetup, targetProblem, writeAnswers, writeTheme, } from './answers.js';
|
|
8
8
|
import { findRepos, isGitRepo, repoHint, repoProblem, tildify } from './repos.js';
|
|
9
9
|
import { Back, Cancelled } from './ui.js';
|
|
10
10
|
import { BravosError } from '../types.js';
|
|
11
11
|
import { prefsLib } from '../prefs.js';
|
|
12
|
+
import { installedOptIns } from '../hooks.js';
|
|
13
|
+
import { cargoBinDir, cargoBinOnPath, cargoPathFix } from '../install-proof-tool.js';
|
|
12
14
|
const AGENTS = [
|
|
13
15
|
{ value: 'claude', label: 'Claude Code' },
|
|
14
16
|
{ value: 'codex', label: 'Codex' },
|
|
@@ -61,7 +63,8 @@ export async function runStart(opts, d) {
|
|
|
61
63
|
}
|
|
62
64
|
async function flow(opts, d) {
|
|
63
65
|
const p = d.prompter;
|
|
64
|
-
|
|
66
|
+
// The repository's recorded answers, preselected when its questions are asked again (--change, or choosing Change when joining).
|
|
67
|
+
let saved = opts.again ? readAnswers(opts.dir ? resolve(opts.dir) : d.cwd) : null;
|
|
65
68
|
p.intro(`Bravos ${d.version} setup`);
|
|
66
69
|
p.info('About five minutes. Esc goes back a step, Ctrl-C quits. Signing in happens when you choose it; everything else waits for your OK at the end.');
|
|
67
70
|
const major = Number(process.versions.node.split('.')[0]);
|
|
@@ -85,7 +88,9 @@ async function flow(opts, d) {
|
|
|
85
88
|
};
|
|
86
89
|
let themeKept = false;
|
|
87
90
|
const has = (s, f) => !!s.lic?.unlocked.includes(f);
|
|
88
|
-
|
|
91
|
+
// cxg already built into cargo's folder, which is not on PATH: building it again would take minutes and end the same way, so it is not offered for install; the tools step says how to put it on PATH instead.
|
|
92
|
+
const strandedCxg = (s) => (s.items ?? []).some((i) => i.id === 'cxg' && !i.present) && !cargoBinOnPath(d.env) && !!cargoBinDir(d.env) && existsSync(join(cargoBinDir(d.env), 'cxg'));
|
|
93
|
+
const missingTools = (s) => (s.items ?? []).filter((i) => (i.id === 'guardlink' || i.id === 'cxg') && (!i.present || (i.proofTool && i.proofTool.status !== 'ready')) && !(i.id === 'cxg' && strandedCxg(s)));
|
|
89
94
|
// A bundle older than this version pins counts as missing: setting up again after an upgrade must bring it up to date.
|
|
90
95
|
const missingBundles = (s) => (s.items ?? []).filter((i) => (i.id === 'analyzer' || i.id === 'codegraph') && (!i.present || !!i.behind) && i.licensed);
|
|
91
96
|
// @comment -- "A repository-level question is skipped when joining: those answers are the team's, already committed."
|
|
@@ -145,9 +150,13 @@ async function flow(opts, d) {
|
|
|
145
150
|
return `✗ ${i.id.padEnd(10)} ${i.present} needs a compatible build for ${i.proofTool.capability}`;
|
|
146
151
|
if (i.present && i.behind && i.licensed)
|
|
147
152
|
return `↑ ${i.id.padEnd(10)} ${i.behind} installed, this version uses ${i.wanted}`;
|
|
153
|
+
if (i.id === 'cxg' && strandedCxg(s))
|
|
154
|
+
return `! cxg built, but not on your PATH`;
|
|
148
155
|
return `${i.present ? '✔' : '✗'} ${i.id.padEnd(10)} ${i.present ? 'installed' : i.licensed === false ? 'Team plan' : `missing — ${i.action}`}`;
|
|
149
156
|
}).join('\n'), 'Tools');
|
|
150
157
|
const missing = [...missingTools(s), ...missingBundles(s)];
|
|
158
|
+
if (strandedCxg(s))
|
|
159
|
+
p.warn(`cxg is already built at ${join(cargoBinDir(d.env), 'cxg')}, but that folder is not on your PATH, so nothing can run it. No need to build it again: ${cargoPathFix(d.env)}.`);
|
|
151
160
|
// @comment -- "The answer given before (Esc returns here) is kept as the default; the first time the default is yes. It used to be reset to no before the question, so Enter skipped the install. An unattended run is never asked: it fetches Bravos's own bundles at Apply and leaves guardlink and cxg, whose installers are other people's, to a person."
|
|
152
161
|
const before = s.installTools;
|
|
153
162
|
s.installTools = false;
|
|
@@ -159,6 +168,10 @@ async function flow(opts, d) {
|
|
|
159
168
|
if (missingTools(s).some((i) => i.id === 'cxg') && !d.which('cargo')) {
|
|
160
169
|
p.warn('cxg (the test engine) installs with Rust\'s cargo, which is not here. Install Rust first: curl --proto \'=https\' --tlsv1.2 -sSf https://sh.rustup.rs | sh — or skip cxg for now; annotations work without it.');
|
|
161
170
|
}
|
|
171
|
+
// cargo is here, but where it installs is not on PATH: cxg would build for minutes and then not be found. Said before the question, with the fix.
|
|
172
|
+
if (missingTools(s).some((i) => i.id === 'cxg') && d.which('cargo') && !cargoBinOnPath(d.env)) {
|
|
173
|
+
p.warn(`cxg installs into ${cargoBinDir(d.env)}, which is not on your PATH, so after it builds nothing will find it. Add it first: ${cargoPathFix(d.env)}, and run bravos setup there. Or install now and add it afterwards.`);
|
|
174
|
+
}
|
|
162
175
|
s.installTools = await p.confirm('tools', `Install ${missing.map((i) => i.id).join(', ')} when you apply?`, before ?? true);
|
|
163
176
|
},
|
|
164
177
|
// repository
|
|
@@ -203,8 +216,18 @@ async function flow(opts, d) {
|
|
|
203
216
|
// The lock alone means Bravos is here, whichever way it was installed (the guided setup, or flags, which leave no setup.json): bravos setup in such a repository brings it up to date, and only --change asks its questions.
|
|
204
217
|
s.join = !opts.again && existsSync(join(repo, '.bravos', 'skills.lock'));
|
|
205
218
|
if (s.join) {
|
|
206
|
-
|
|
207
|
-
|
|
219
|
+
// @comment -- "Joining a repository that has Bravos: say what it is set up with (agents, pull-request checks, autopilot, schedule, testing) and ask once whether to keep that or change it, so the repository's choices are one Enter away instead of behind a flag. Keep is the default and changes nothing the team decided; Change asks the repository's questions with what is there now selected. An unattended run keeps."
|
|
220
|
+
const now = { ...currentSetup(repo, installedOptIns(repo)), ...(readAnswers(repo) ?? {}) };
|
|
221
|
+
s.agents = now.agents ?? s.agents;
|
|
222
|
+
p.note(describeSetup(now).join('\n'), 'This repository is already set up');
|
|
223
|
+
const keep = opts.yes ? 'keep' : await p.select('repo-setup', 'Keep this repository\'s setup, or change it?', [
|
|
224
|
+
{ value: 'keep', label: 'Keep it', hint: 'set up this machine only; the team\'s choices stay as they are', recommended: true },
|
|
225
|
+
{ value: 'change', label: 'Change it', hint: 'agents, pull-request checks, autopilot, schedule, testing' },
|
|
226
|
+
], s.join ? 'keep' : 'change');
|
|
227
|
+
if (keep === 'change') {
|
|
228
|
+
s.join = false;
|
|
229
|
+
saved = { ...now, ...(saved ?? {}) };
|
|
230
|
+
}
|
|
208
231
|
}
|
|
209
232
|
},
|
|
210
233
|
// agents
|
|
@@ -458,7 +481,7 @@ async function flow(opts, d) {
|
|
|
458
481
|
...(has(s, 'codegraph') ? [`bravos graph build ${JSON.stringify(answers.repo)} --scip no-exec`] : []),
|
|
459
482
|
].join('\n'), 'Commands');
|
|
460
483
|
}
|
|
461
|
-
return apply(toAnswers(s), s, d, opts, { missingTools: missingTools(s).length > 0, missingBundles: missingBundles(s).length > 0, codegraph: has(s, 'codegraph'), join: !!s.join, commits: s.commits, cxgMissing: missingTools(s).some((i) => i.id === 'cxg') });
|
|
484
|
+
return apply(toAnswers(s), s, d, opts, { missingTools: missingTools(s).length > 0, missingBundles: missingBundles(s).length > 0, codegraph: has(s, 'codegraph'), join: !!s.join, commits: s.commits, cxgMissing: missingTools(s).some((i) => i.id === 'cxg'), toolNames: missingTools(s).map((i) => i.id) });
|
|
462
485
|
}
|
|
463
486
|
function toAnswers(s) {
|
|
464
487
|
return {
|
|
@@ -493,16 +516,18 @@ async function apply(answers, s, d, opts, has) {
|
|
|
493
516
|
let at = 0;
|
|
494
517
|
const step = (label) => `[${++at}/${steps}] ${label}`;
|
|
495
518
|
const slowCxg = answers.installTools && has.missingTools && !opts.yes && has.cxgMissing;
|
|
496
|
-
|
|
519
|
+
// Named for what is actually missing: a step that installs only cxg says so.
|
|
520
|
+
const what = has.toolNames?.length ? has.toolNames.join(' and ') : 'guardlink and cxg';
|
|
521
|
+
const tools = slowCxg ? `Installing ${what} (cxg is compiled from source: often 5 to 10 minutes)` : `Installing ${what}`;
|
|
497
522
|
p.info(`Applying: ${steps} step${steps === 1 ? '' : 's'}${slowCxg ? '. The first takes longest, because cargo compiles cxg; the clock and the line beside it show where it is' : ''}. Leave this window open until "Bravos is set up".`);
|
|
498
523
|
if (answers.installTools && has.missingTools && !opts.yes) {
|
|
499
|
-
const r = await p.spin(step(tools), (progress) => d.bravos(['setup', '--tools', '-y'], progress), (r) => (r.code ? { fail: `${tools} — failed` } :
|
|
524
|
+
const r = await p.spin(step(tools), (progress) => d.bravos(['setup', '--tools', '-y'], progress), (r) => (r.code ? { fail: `${tools} — failed` } : `Installed ${what}`));
|
|
500
525
|
for (const l of [...r.out, ...r.err])
|
|
501
526
|
(r.code ? p.warn : p.info)(l);
|
|
502
527
|
// A tool that would not install (no cargo, offline, an incompatible build) limits proving, not the
|
|
503
528
|
// rest of setup: carry on, and say what still needs doing instead of leaving the repo unset.
|
|
504
529
|
if (r.code)
|
|
505
|
-
p.warn(
|
|
530
|
+
p.warn(`Carrying on without ${what}: annotation and the briefing work now; proving needs guardlink and cxg. Fix the line above, then run bravos setup --tools -y.`);
|
|
506
531
|
}
|
|
507
532
|
// The bundles are named: a bare `bravos setup` is the whole setup now, and would start this wizard again. An unattended run fetches them too; they are Bravos's own, signed.
|
|
508
533
|
if ((answers.installTools || opts.yes) && has.missingBundles) {
|
|
@@ -514,7 +539,8 @@ async function apply(answers, s, d, opts, has) {
|
|
|
514
539
|
const init = has.join
|
|
515
540
|
? await p.spin(step('Bringing this machine up to date with the repository'), (progress) => d.bravos(['sync', repo], progress), (r) => (r.code ? { fail: 'Syncing the repository — failed' } : 'Repository in sync'))
|
|
516
541
|
: await p.spin(step('Setting up the repository'), (progress) => d.bravos(initArgs(answers), progress), (r) => (r.code ? { fail: 'Setting up the repository — failed' } : 'Repository set up'));
|
|
517
|
-
|
|
542
|
+
// @comment -- "What the repository step printed is shown only where it matters: a change, a warning or something to do. A re-apply that changed nothing is the one line on the spinner; the install log's own closing 'Next: open a session' is left out, because the guided setup ends with its own."
|
|
543
|
+
for (const l of init.code === 0 ? worthShowing(init.out) : init.out)
|
|
518
544
|
p.info(l);
|
|
519
545
|
if (init.code !== 0) {
|
|
520
546
|
for (const l of init.err)
|
|
@@ -604,6 +630,11 @@ async function apply(answers, s, d, opts, has) {
|
|
|
604
630
|
p.outro('Bravos is set up.');
|
|
605
631
|
return 0;
|
|
606
632
|
}
|
|
633
|
+
// @comment -- "Lines from the install that tell a person something: a file written or updated, a warning, something skipped or left to do. 'Unchanged', 'already registered' and the install's own closing line are left out."
|
|
634
|
+
export function worthShowing(lines) {
|
|
635
|
+
const quiet = [/^Next: open a session/, /already registered$/, /already lists/, /^Harnesses: /, /\b0 written, 0 updated, \d+ unchanged, 0 skipped\b/, /\bunchanged \(/, /added none; kept/, /^autopilot: kept/, /^guardlink: present$/];
|
|
636
|
+
return lines.filter((l) => l.trim() && !quiet.some((q) => q.test(l)));
|
|
637
|
+
}
|
|
607
638
|
function provingLabel(p) {
|
|
608
639
|
return { ask: 'Ask me every time before testing', auto: 'Test my local app automatically', schedule: 'Only in the scheduled run', none: 'Never test, just annotate' }[p];
|
|
609
640
|
}
|
package/docs/UPGRADING.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
After `npm install -g @bugb-technologies/bravos`, run **`bravos setup`** in a repository you work in: it brings this machine and that repository up to date. In repositories you work in with an agent you can skip even that: the agent runs it at the start of a session. The notes below say what else changes, newest first. (Before 1.9 the same was `bravos setup --tools -y` per machine and `bravos sync` per repository; both still work.)
|
|
4
4
|
|
|
5
|
+
## 1.9.3
|
|
6
|
+
|
|
7
|
+
- **Answer in your own words on the context page.** A question with set options (for example "What should bravos rate this against?") now has **✎ My own answer**. Your text is the decision, and the agent receives it as written. Before, typing into the comment box was the only option, and it did not count, so Confirm stayed off.
|
|
8
|
+
- **Done is honest.** Pressing Done before Confirm says what is still open instead of closing as if your answers had been saved.
|
|
9
|
+
|
|
10
|
+
## 1.9.2
|
|
11
|
+
|
|
12
|
+
- **Joining a repository shows its setup.** In a repository that already has Bravos, `bravos setup` lists what it is set up with (agents, pull-request checks, autopilot, schedule, testing) and asks whether to keep it or change it. Keep is the default and changes nothing; Change asks the repository's questions with what is there selected.
|
|
13
|
+
- **cxg and cargo's folder.** cargo installs into `~/.cargo/bin`, which a cargo from Homebrew does not put on PATH, so cxg could build for minutes and then not be found. Setup now warns before the build, with the line to add for your shell, and does not build a cxg that is already there again.
|
|
14
|
+
- The re-apply step prints only what changed or needs doing.
|
|
15
|
+
|
|
5
16
|
## 1.9.1
|
|
6
17
|
|
|
7
18
|
- **Apply shows what it is doing.** After you choose Apply in `bravos setup`, the screen used to stay still while the tools installed, which can take several minutes because cargo compiles cxg. It now says how many steps there are, numbers each one, and shows a running clock and the step it is on.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugb-technologies/bravos",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -231,10 +231,13 @@ textarea.comment { min-height: 37px; }
|
|
|
231
231
|
state[q.id] = { verdict: has ? 'accepted' : null, value: Array.isArray(initial) ? [...initial] : initial, touched: false, comment: '' };
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
// A decision is made by picking an option, or by writing an answer of one's own (s.own, choice and multi questions); an own answer left empty is not one yet.
|
|
235
|
+
const needsCall = (q) => q.mustTouch && (!state[q.id].touched || (state[q.id].own !== undefined && !state[q.id].own.trim()));
|
|
235
236
|
const decide = (q, value, explicit, editInPlace = false) => {
|
|
236
237
|
const s = state[q.id];
|
|
237
238
|
s.value = value;
|
|
239
|
+
// Picking an option replaces an answer written in one's own words.
|
|
240
|
+
if (value !== null) delete s.own;
|
|
238
241
|
s.touched = s.touched || explicit;
|
|
239
242
|
if (q.type === 'item' && value === 'no') s.verdict = 'no';
|
|
240
243
|
else if (q.suggested !== undefined && sameValue(value, q.suggested)) s.verdict = q.mustTouch ? (s.touched ? 'chosen' : 'accepted') : 'accepted';
|
|
@@ -254,6 +257,22 @@ textarea.comment { min-height: 37px; }
|
|
|
254
257
|
refresh();
|
|
255
258
|
};
|
|
256
259
|
|
|
260
|
+
// @comment -- "An answer in the reviewer's own words, for a choice or multi question whose options all miss: it is the decision (verdict edited, the text sent as `text`), so a must-touch question no longer stays red when none of bravos's options fits."
|
|
261
|
+
const decideOwn = (q, text, editInPlace = false) => {
|
|
262
|
+
const s = state[q.id];
|
|
263
|
+
s.own = text;
|
|
264
|
+
s.value = null;
|
|
265
|
+
s.touched = true;
|
|
266
|
+
s.verdict = text.trim() ? 'edited' : null;
|
|
267
|
+
if (editInPlace) {
|
|
268
|
+
const card = cards[q.id];
|
|
269
|
+
card.replaceChild(badges(q), card.firstElementChild);
|
|
270
|
+
const keep = card.querySelector('.keep');
|
|
271
|
+
if (keep && !needsCall(q)) keep.remove();
|
|
272
|
+
} else render(q);
|
|
273
|
+
refresh();
|
|
274
|
+
};
|
|
275
|
+
|
|
257
276
|
const stateLabels = {
|
|
258
277
|
pending: 'Needs your call', reviewed: 'Reviewed', suggested: 'Suggested', optional: 'Optional',
|
|
259
278
|
};
|
|
@@ -410,8 +429,28 @@ textarea.comment { min-height: 37px; }
|
|
|
410
429
|
button.addEventListener('click', fn);
|
|
411
430
|
row.append(button);
|
|
412
431
|
};
|
|
432
|
+
const own = () => {
|
|
433
|
+
btn('✎ My own answer', s.own !== undefined, () => {
|
|
434
|
+
decideOwn(q, s.own ?? '');
|
|
435
|
+
const box = cards[q.id].querySelector('textarea.own');
|
|
436
|
+
if (box) box.focus();
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
const ownBox = () => {
|
|
440
|
+
if (s.own === undefined) return;
|
|
441
|
+
const t = el('textarea', 'own');
|
|
442
|
+
t.setAttribute('aria-label', 'Your own answer to ' + (q.title || q.id));
|
|
443
|
+
t.placeholder = 'Your answer, in your own words';
|
|
444
|
+
t.value = s.own;
|
|
445
|
+
t.maxLength = 4000;
|
|
446
|
+
t.addEventListener('input', () => decideOwn(q, t.value, true));
|
|
447
|
+
card.appendChild(row);
|
|
448
|
+
card.appendChild(t);
|
|
449
|
+
};
|
|
413
450
|
if (q.type === 'choice') {
|
|
414
451
|
for (const o of q.options) btn(`${o.id === q.suggested ? '★ ' : ''}${o.label}`, s.value === o.id, () => decide(q, o.id, true));
|
|
452
|
+
own();
|
|
453
|
+
ownBox();
|
|
415
454
|
} else if (q.type === 'multi') {
|
|
416
455
|
for (const o of q.options) {
|
|
417
456
|
const on = Array.isArray(s.value) && s.value.includes(o.id);
|
|
@@ -421,6 +460,8 @@ textarea.comment { min-height: 37px; }
|
|
|
421
460
|
decide(q, q.options.map((x) => x.id).filter((id) => next.has(id)), true);
|
|
422
461
|
});
|
|
423
462
|
}
|
|
463
|
+
own();
|
|
464
|
+
ownBox();
|
|
424
465
|
} else if (q.type === 'item') {
|
|
425
466
|
const isText = typeof s.value === 'string' && s.value !== 'agree' && s.value !== 'no';
|
|
426
467
|
btn('Agree', s.value === 'agree', () => decide(q, 'agree', true));
|
|
@@ -453,7 +494,7 @@ textarea.comment { min-height: 37px; }
|
|
|
453
494
|
}
|
|
454
495
|
const c = el('textarea', 'comment');
|
|
455
496
|
c.setAttribute('aria-label', 'Comment on ' + (q.title || q.id));
|
|
456
|
-
c.placeholder = 'Comment (optional)';
|
|
497
|
+
c.placeholder = q.type === 'choice' || q.type === 'multi' ? 'Comment (optional; to answer differently, choose ✎ My own answer)' : 'Comment (optional)';
|
|
457
498
|
c.maxLength = 4000;
|
|
458
499
|
c.value = s.comment;
|
|
459
500
|
c.addEventListener('input', () => { s.comment = c.value; });
|
|
@@ -509,7 +550,8 @@ textarea.comment { min-height: 37px; }
|
|
|
509
550
|
for (const q of qs) {
|
|
510
551
|
const s = state[q.id];
|
|
511
552
|
if (!s.verdict && !s.comment) continue;
|
|
512
|
-
|
|
553
|
+
const ownText = s.own !== undefined && s.own.trim() ? { text: s.own.trim() } : {};
|
|
554
|
+
answers[q.id] = { verdict: s.verdict || 'comment', ...(s.verdict && s.verdict !== 'accepted' && s.value !== null ? { value: s.value } : {}), ...ownText, ...(s.comment ? { comment: s.comment } : {}) };
|
|
513
555
|
}
|
|
514
556
|
return { schema: 'bravos.review-answers/v1', kind: draft.kind, by, date: new Date().toISOString().slice(0, 10), answers };
|
|
515
557
|
};
|
|
@@ -537,6 +579,9 @@ textarea.comment { min-height: 37px; }
|
|
|
537
579
|
};
|
|
538
580
|
load();
|
|
539
581
|
|
|
582
|
+
// Whether this page saved anyone's answers; Done says so plainly when it did not.
|
|
583
|
+
let saved = false;
|
|
584
|
+
let doneArmed = false;
|
|
540
585
|
$('save').addEventListener('click', async () => {
|
|
541
586
|
const p = payload();
|
|
542
587
|
if (!slug(p.by)) { status('Enter a name containing a letter a–z or a digit to identify your answers file.'); $('who').focus(); return; }
|
|
@@ -546,6 +591,7 @@ textarea.comment { min-height: 37px; }
|
|
|
546
591
|
const r = await api('/answers', p);
|
|
547
592
|
if (r.status === 400) { status(await r.text()); return; }
|
|
548
593
|
if (!r.ok) throw new Error(await r.text());
|
|
594
|
+
saved = true;
|
|
549
595
|
status(`Confirmed and saved to .guardlink/${draft.kind}-answers/${slug(p.by)}.json. Teammates can run bravos review ${draft.kind} and add theirs; click Done when you are finished.`);
|
|
550
596
|
load();
|
|
551
597
|
return;
|
|
@@ -553,6 +599,7 @@ textarea.comment { min-height: 37px; }
|
|
|
553
599
|
const db = await artifactDb();
|
|
554
600
|
if (db) {
|
|
555
601
|
await db.doc(`answers/${slug(p.by)}`).set(p);
|
|
602
|
+
saved = true;
|
|
556
603
|
status('Saved. Everyone with this link sees it; the agent will read it back into the repo.');
|
|
557
604
|
load();
|
|
558
605
|
return;
|
|
@@ -562,9 +609,18 @@ textarea.comment { min-height: 37px; }
|
|
|
562
609
|
status(`Downloaded ${slug(p.by)}.json. Put it in .guardlink/${draft.kind}-answers/ and commit it.`);
|
|
563
610
|
});
|
|
564
611
|
|
|
612
|
+
// @comment -- "Done closes the review. When nothing was confirmed on this page it says so and waits for a second click, because closing then means the agent finds no answers and cannot record any decision. It never claims answers were read when none were saved."
|
|
565
613
|
$('done').addEventListener('click', async () => {
|
|
614
|
+
if (!saved && !doneArmed) {
|
|
615
|
+
const left = qs.filter(needsCall).length;
|
|
616
|
+
doneArmed = true;
|
|
617
|
+
status(`Nothing is saved yet${left ? `: ${left} decision${left === 1 ? '' : 's'} marked "needs your call" ${left === 1 ? 'is' : 'are'} still open` : ''}. ${left ? 'Make ' + (left === 1 ? 'it' : 'them') + ', then ' : ''}press Confirm, then Done. To close without saving anything, press Done again.`);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
566
620
|
if (mode.kind === 'serve') { try { await api('/done', {}); } catch { /* already gone */ } }
|
|
567
|
-
status(
|
|
621
|
+
status(saved
|
|
622
|
+
? 'Thanks. The agent reads everyone\'s answers now; if it does not carry on, tell it "done". You can close this tab.'
|
|
623
|
+
: 'Closed without saving. The agent will find no answers from you; run bravos review ' + draft.kind + ' to answer later.');
|
|
568
624
|
});
|
|
569
625
|
})();
|
|
570
626
|
</script>
|