@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
package/dist/account.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { hostname } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import { refreshLib, userAgent } from './device.js';
|
|
5
|
+
import { machineLib, refreshLib, userAgent } from './device.js';
|
|
6
6
|
import { openInBrowser } from './open.js';
|
|
7
7
|
import { licenceLib, licenceLines } from './licence.js';
|
|
8
8
|
import { BravosError } from './types.js';
|
|
@@ -66,7 +66,15 @@ export async function activate(io) {
|
|
|
66
66
|
const ua = { 'User-Agent': userAgent(), Accept: 'application/json' };
|
|
67
67
|
let start;
|
|
68
68
|
try {
|
|
69
|
-
|
|
69
|
+
// The machine's one-way fingerprint (hooks/lib/machine.mjs): the portal's
|
|
70
|
+
// one-free-trial rule tells machines apart by it. Null in a container or CI,
|
|
71
|
+
// which the portal allows and flags; the raw machine id never leaves here.
|
|
72
|
+
const machine = (io.machine ?? (await machineLib()).machineFingerprint)(io.env);
|
|
73
|
+
const r = await f(`${origin}${ACTIVATION_PATH}`, {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
headers: { ...ua, 'Content-Type': 'application/json' },
|
|
76
|
+
body: JSON.stringify({ device_name: deviceName(), refresh: true, machine: machine.key, ...(machine.key ? {} : { machine_reason: machine.reason }) }),
|
|
77
|
+
});
|
|
70
78
|
if (r.status === 404 || r.status === 405)
|
|
71
79
|
throw new BravosError(`${origin} does not offer CLI sign-in yet; download the licence from ${L.ACCOUNT_LICENCES} and run bravos account import <file>`);
|
|
72
80
|
if (!r.ok)
|
|
@@ -114,14 +122,19 @@ export async function activate(io) {
|
|
|
114
122
|
// The portal answers 402 when the account has no plan and its one trial is used up: nothing is written, Free keeps working.
|
|
115
123
|
if (r.status === 402) {
|
|
116
124
|
let upgrade = L.ACCOUNT_UPGRADE;
|
|
125
|
+
let error = null;
|
|
117
126
|
try {
|
|
118
127
|
const b = (await r.json());
|
|
128
|
+
error = b?.error;
|
|
119
129
|
if (typeof b?.upgrade === 'string' && b.upgrade.startsWith(origin + '/'))
|
|
120
130
|
upgrade = b.upgrade;
|
|
121
131
|
}
|
|
122
132
|
catch {
|
|
123
133
|
/* the default page */
|
|
124
134
|
}
|
|
135
|
+
// The portal's one-free-trial rule: this person, or this machine, had a trial under another account.
|
|
136
|
+
if (error === 'trial_used')
|
|
137
|
+
throw new BravosError(`a free trial has already been used by you or on this machine, so a new one was not started and no licence was written; this machine stays on Free (the research loop keeps working). Choose a plan at ${upgrade}, or write to support@bugb.report if you think this is a mistake`);
|
|
125
138
|
throw new BravosError(`this account's Team trial has ended and it has no plan, so no licence was written; this machine stays on Free (the research loop keeps working). Choose a plan at ${upgrade}, then run bravos account activate again`);
|
|
126
139
|
}
|
|
127
140
|
// 403: the person was signed in but the portal will not license this machine for them. Nothing is written.
|
|
@@ -139,6 +152,10 @@ export async function activate(io) {
|
|
|
139
152
|
}
|
|
140
153
|
if (error === 'device_limit')
|
|
141
154
|
throw new BravosError(`you already have the most machines your account allows, so no licence was written; remove one at ${manage} (or run bravos account devices / bravos account revoke <id> on a machine that is signed in), then run bravos account activate again`);
|
|
155
|
+
if (error === 'update_cli')
|
|
156
|
+
throw new BravosError(`this version of bravos cannot start a trial; update it (npm install -g @bugb-technologies/bravos), then run bravos account activate again`);
|
|
157
|
+
if (error === 'use_terminal')
|
|
158
|
+
throw new BravosError(`a trial starts from the terminal: run bravos account activate on the machine you want to use and enter the code it shows`);
|
|
142
159
|
if (error === 'licence_not_assigned')
|
|
143
160
|
throw new BravosError(`you do not hold a licence on your team's account yet, so no licence was written; this machine stays on Free. Ask an owner or admin to assign you one, or request it at ${manage}, then run bravos account activate again`);
|
|
144
161
|
throw new BravosError(`${origin} refused to license this machine (HTTP 403${typeof error === 'string' ? `: ${error}` : ''}); see ${manage}`);
|
package/dist/cli.js
CHANGED
|
@@ -12,8 +12,8 @@ import { writeInstructionBlocks } from './instruction-blocks.js';
|
|
|
12
12
|
import { OMP_EXTENSION_PATH, writeOmpExtension } from './omp.js';
|
|
13
13
|
import { homeOf, installGlobal } from './global.js';
|
|
14
14
|
import { uninstall } from './uninstall.js';
|
|
15
|
-
import { checkKind, newToken, prepareReview, readAllAnswers, readDraft, renderReview, summarize, writePage } from './review.js';
|
|
16
|
-
import { addSource, checkSources, declineContext, gateFor, installPrePush, listSources, updateSource } from './context.js';
|
|
15
|
+
import { checkKind, confirmedOnly, draftPath, lostAnswers, newToken, prepareReview, readAllAnswers, readDraft, renderReview, summarize, writePage } from './review.js';
|
|
16
|
+
import { addSource, checkSources, contextIgnoreFix, contextIgnoreWarning, declineContext, gateFor, installPrePush, listSources, shareContext, storeRoot as storeRootOf, updateSource } from './context.js';
|
|
17
17
|
import { formatRules, gatherRules } from './rules.js';
|
|
18
18
|
import { spawn as spawnChild, spawnSync } from 'node:child_process';
|
|
19
19
|
import { createServer as netServer } from 'node:net';
|
|
@@ -288,7 +288,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
288
288
|
lines.push(`Hooks: ${r.file} ${r.changed ? 'registered' : 'already registered'}`);
|
|
289
289
|
// A repository that keeps design documents gets the pre-push check in every clone that runs init or sync, not only
|
|
290
290
|
// in the clone of whoever added the first one. Upkeep leaves the clone's git hooks to a person.
|
|
291
|
-
if (!dryRun && !opts.global && !opts.refreshOnly && existsSync(join(root, '.bravos', 'context', 'sources.json')))
|
|
291
|
+
if (!dryRun && !opts.global && !opts.refreshOnly && (existsSync(join(root, '.bravos', 'context', 'sources.json')) || existsSync(join(root, '.guardlink', 'principles.md'))))
|
|
292
292
|
lines.push(...installPrePush(root, io.env));
|
|
293
293
|
// An agent left out of --agent keeps its own settings, which may still run the old-name hook the migration moved.
|
|
294
294
|
for (const w of oldHookReferences(root))
|
|
@@ -362,6 +362,10 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
362
362
|
const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
|
|
363
363
|
const written = [...skills.written, ...skills.updated, ...mirror.written, ...mirror.updated, ...cursorWritten, ...blocksWritten, ...ompWritten, ...ocWritten, ...workflowWritten, ...hook.copied, ...hook.registered.map((r) => r.file), ...guardlinkWritten];
|
|
364
364
|
lines.push(...gitignoreWarnings(root, written, io.env));
|
|
365
|
+
// The intake and design documents are meant for the team: say so when a .gitignore rule keeps them here.
|
|
366
|
+
const hidden = contextIgnoreWarning(contextIgnoreFix(root, io.env));
|
|
367
|
+
if (hidden)
|
|
368
|
+
lines.push(hidden);
|
|
365
369
|
if (autopilotKept)
|
|
366
370
|
lines.push('autopilot: kept (already installed); BRAVOS_AUTOPILOT=off pauses the check.');
|
|
367
371
|
else if (prePrKept)
|
|
@@ -627,14 +631,14 @@ export function buildProgram(io, result) {
|
|
|
627
631
|
// @comment -- "bravos hook <name> runs one of the scripts this install ships (session-start, pre-pr, autopilot, replay) with the given arguments and stdin passed through; plugin skills use it where the repository has no .bravos/hooks/ copy. Only allowlisted entry points run; the script's own exit code is returned."
|
|
628
632
|
program
|
|
629
633
|
.command('hook <name> [args...]')
|
|
630
|
-
.description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot, replay), e.g. `bravos hook session-start --briefing` or `bravos hook
|
|
634
|
+
.description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot, replay), e.g. `bravos hook session-start --briefing` or `bravos hook replay preflight run <kit.js>` (versioned JSON, no kit execution): what plugin installs use where the repository has no .bravos/hooks/.')
|
|
631
635
|
.allowUnknownOption()
|
|
632
636
|
.helpOption(false)
|
|
633
637
|
.action((name, args) => guarded((lines) => {
|
|
634
|
-
const known = ['session-start', 'pre-pr', 'autopilot', 'replay', 'context'];
|
|
638
|
+
const known = ['session-start', 'pre-pr', 'autopilot', 'replay', 'context', 'principles'];
|
|
635
639
|
if (!known.includes(name))
|
|
636
640
|
throw new BravosError(`unknown hook '${name}'; use ${known.join(', ')}`);
|
|
637
|
-
const script = name === 'replay' || name === 'context' ? `lib/${name}.mjs` : `${name}.mjs`;
|
|
641
|
+
const script = name === 'replay' || name === 'context' || name === 'principles' ? `lib/${name}.mjs` : `${name}.mjs`;
|
|
638
642
|
const r = spawnSync(process.execPath, [pathJoin(hooksDir(), script), ...args], { env: io.env, encoding: 'utf8', stdio: ['inherit', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024 });
|
|
639
643
|
if (r.stdout)
|
|
640
644
|
lines.push(r.stdout.replace(/\n$/, ''));
|
|
@@ -853,7 +857,7 @@ export function buildProgram(io, result) {
|
|
|
853
857
|
// @comment -- "bravos context: the design documents behind the threat model. add and update take text (a file, or - for standard input) and refuse a secret, a local path or embedded content before anything is written; list and check read. Free on every plan and runs no model: converting a PDF or fetching a link is the coding agent's job, in the session, with the person's own access."
|
|
854
858
|
program
|
|
855
859
|
.command('context <action> [args...]')
|
|
856
|
-
.description('Keep the design documents behind the threat model in the repository (.bravos/context/, committed): `context add <file.md|-> --title "<what it is>" --kind prd` stores a document after checking it for secrets and local paths; `context update SRC-n [file]` replaces it or records a hand edit; `context list`; `context check`; `context gate` says whether threat-modelling may start (context confirmed, or declined); `context decline --by "<name>"` records that a named person chose to go without. Text only: your coding agent converts PDFs and fetches links. Free; runs no model.')
|
|
860
|
+
.description('Keep the design documents behind the threat model in the repository (.bravos/context/, committed): `context add <file.md|-> --title "<what it is>" --kind prd` stores a document after checking it for secrets and local paths; `context update SRC-n [file]` replaces it or records a hand edit; `context list`; `context check`; `context gate` says whether threat-modelling may start (context confirmed, or declined); `context decline --by "<name>"` records that a named person chose to go without; `context share [--yes]` says which .gitignore rule keeps the context out of git and, with --yes, narrows a blanket .bravos/ rule. Text only: your coding agent converts PDFs and fetches links. Free; runs no model.')
|
|
857
861
|
.option('-C, --dir <dir>', 'the repository (default: the current directory)')
|
|
858
862
|
.option('--title <title>', 'add/update: what the document is, in a few words')
|
|
859
863
|
.option('--kind <kind>', 'add/update: prd, design, threat-model, policy, api, upstream or other')
|
|
@@ -863,6 +867,7 @@ export function buildProgram(io, result) {
|
|
|
863
867
|
.option('--keep-query', 'add/update: keep a link whose query looks like an access token')
|
|
864
868
|
.option('--reason <why>', 'decline: why the team goes without design context')
|
|
865
869
|
.option('--json', 'list/check/gate: print JSON')
|
|
870
|
+
.option('--yes', 'share: make the change to .gitignore (without it, share only says what it would change)')
|
|
866
871
|
.action((action, args, opts) => guardedAsync(async (lines) => {
|
|
867
872
|
const dir = dirArg(opts.dir);
|
|
868
873
|
const source = (from) => (from === '-' ? { from, stdin: readStdin() } : { from });
|
|
@@ -895,8 +900,12 @@ export function buildProgram(io, result) {
|
|
|
895
900
|
else if (action === 'decline') {
|
|
896
901
|
lines.push(...(await declineContext(dir, opts, io.env)));
|
|
897
902
|
}
|
|
903
|
+
else if (action === 'share') {
|
|
904
|
+
// Which rule keeps the context off the team's machines; --yes narrows a blanket .bravos/ line.
|
|
905
|
+
lines.push(...shareContext(storeRootOf(dir, io.env), !!opts.yes, io.env));
|
|
906
|
+
}
|
|
898
907
|
else
|
|
899
|
-
throw new BravosError(`unknown context action '${action}'; use add, update, list, check, gate or
|
|
908
|
+
throw new BravosError(`unknown context action '${action}'; use add, update, list, check, gate, decline or share`);
|
|
900
909
|
}));
|
|
901
910
|
// @comment -- "bravos upkeep: what has fallen behind the installed bravos, here and on this machine: the repository's copies of the skills and hooks, and staged bundles older than this version pins; bravos setup brings both up to date. Read-only, no network, free; the session hook asks it at every start so the agent can run those two commands itself."
|
|
902
911
|
program
|
|
@@ -934,6 +943,79 @@ export function buildProgram(io, result) {
|
|
|
934
943
|
const doc = await gatherRules(dirArg(dir), io.env);
|
|
935
944
|
lines.push(...(opts.json ? [JSON.stringify(doc, null, 2)] : formatRules(doc)));
|
|
936
945
|
}));
|
|
946
|
+
// @comment -- "bravos principles: the company's security design principles in this repository. check verifies principles.md against the confirmed adoptions and the exceptions (free; the pre-push hook and CI run the same); list prints them; write regenerates the file; except records an exception a person approves at an interactive terminal; copy takes another repository's set. Adoption itself happens only on the review page, by a named person."
|
|
947
|
+
program
|
|
948
|
+
.command('principles <action> [args...]')
|
|
949
|
+
.description('Your company\'s security design principles, kept in the repository (.guardlink/principles.md, written by bravos from what named people adopted on bravos review principles): `principles check` verifies the file still says only what people adopted and that no exception has ended (free; the pre-push hook and CI run it); `principles list`; `principles write` rewrites the file from the adoptions; `principles except SDP-n --where "<glob>" --reason "<why>" --until YYYY-MM-DD` records an exception, approved by the person typing their name at a terminal (never by an agent); `principles except --clear-expired`; `principles copy --from <other repository>` takes the same principles. Runs no model.')
|
|
950
|
+
.option('-C, --dir <dir>', 'the repository (default: the current directory)')
|
|
951
|
+
.option('--json', 'check/list: print JSON')
|
|
952
|
+
.option('--where <glob>', 'except: the code the exception covers, as a repository glob (src/legacy/**)')
|
|
953
|
+
.option('--reason <why>', 'except: why this code may break the principle for now')
|
|
954
|
+
.option('--until <day>', 'except: the last day it holds (YYYY-MM-DD, within a year)')
|
|
955
|
+
.option('--clear-expired', 'except: remove exceptions whose last day has passed')
|
|
956
|
+
.option('--from <repository>', 'copy: the repository to take the principles from (a path)')
|
|
957
|
+
.option('--replace', 'copy: replace adoptions made in this repository')
|
|
958
|
+
.action((action, args, opts) => guardedAsync(async (lines) => {
|
|
959
|
+
const P = await import('./principles.js');
|
|
960
|
+
const root = dirArg(opts.dir);
|
|
961
|
+
if (action === 'check') {
|
|
962
|
+
const { result: checked, lines: said } = await P.checkPrinciplesAt(root);
|
|
963
|
+
lines.push(...(opts.json ? [JSON.stringify(checked, null, 2)] : said));
|
|
964
|
+
if (!checked.ok)
|
|
965
|
+
result.code = 1;
|
|
966
|
+
}
|
|
967
|
+
else if (action === 'list') {
|
|
968
|
+
const { result: checked } = await P.checkPrinciplesAt(root);
|
|
969
|
+
if (opts.json)
|
|
970
|
+
lines.push(JSON.stringify({ schema: 'bravos.principles/v1', ok: checked.ok, adopted: checked.adopted, exceptions: checked.exceptions }, null, 2));
|
|
971
|
+
else if (!checked.adopted.length)
|
|
972
|
+
lines.push('principles: none adopted here (bravos review principles proposes them).');
|
|
973
|
+
else {
|
|
974
|
+
for (const p of checked.adopted)
|
|
975
|
+
lines.push(`${p.id} ${p.kind.padEnd(8)} ${p.statement} (applies to: ${p.scope}; adopted by ${p.adopters.map((a) => a.by).join(', ')})`);
|
|
976
|
+
for (const e of checked.exceptions)
|
|
977
|
+
lines.push(` exception: ${e.principle} in ${e.where} until ${e.until}, approved by ${e.by}`);
|
|
978
|
+
if (!checked.ok)
|
|
979
|
+
lines.push('principles check fails: run bravos principles check');
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
else if (action === 'write') {
|
|
983
|
+
await requireFeature(io.env, 'principles', 'Writing security design principles');
|
|
984
|
+
lines.push(...(await P.writePrinciples(root)));
|
|
985
|
+
}
|
|
986
|
+
else if (action === 'except') {
|
|
987
|
+
await requireFeature(io.env, 'principles', 'Exceptions to security design principles');
|
|
988
|
+
if (opts.clearExpired) {
|
|
989
|
+
lines.push(...(await P.clearExpired(root)));
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (args.length !== 1 || !opts.where || !opts.reason || !opts.until)
|
|
993
|
+
throw new BravosError('usage: bravos principles except SDP-n --where "<glob>" --reason "<why>" --until YYYY-MM-DD');
|
|
994
|
+
// @mitigates #principles against #forged-principle using #person-only-exception -- "An exception needs an interactive terminal where the approver types their own name and the principle id; a coding agent's shell has no terminal, so it cannot approve one"
|
|
995
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
996
|
+
throw new BravosError('an exception is a person\'s decision: run this yourself in a terminal, where you type your name to approve it. A coding agent cannot approve one.');
|
|
997
|
+
const rl = (await import('node:readline/promises')).createInterface({ input: process.stdin, output: process.stdout });
|
|
998
|
+
try {
|
|
999
|
+
io.stdout(`Exception to ${args[0]} for ${opts.where} until ${opts.until}: ${opts.reason}`);
|
|
1000
|
+
const by = (await rl.question('Your name, approving this exception: ')).trim();
|
|
1001
|
+
const typed = (await rl.question(`Type ${args[0]} to confirm: `)).trim();
|
|
1002
|
+
if (typed !== args[0])
|
|
1003
|
+
throw new BravosError('not confirmed: the principle id did not match, nothing was recorded');
|
|
1004
|
+
lines.push(...(await P.addException(root, { principle: args[0], where: opts.where, reason: opts.reason, until: opts.until, by })));
|
|
1005
|
+
}
|
|
1006
|
+
finally {
|
|
1007
|
+
rl.close();
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
else if (action === 'copy') {
|
|
1011
|
+
await requireFeature(io.env, 'principles', 'Copying security design principles');
|
|
1012
|
+
if (!opts.from)
|
|
1013
|
+
throw new BravosError('usage: bravos principles copy --from <path to the other repository> [--replace]');
|
|
1014
|
+
lines.push(...(await P.copyPrinciples(root, opts.from, { replace: opts.replace }, io.env)));
|
|
1015
|
+
}
|
|
1016
|
+
else
|
|
1017
|
+
throw new BravosError(`unknown principles action '${action}'; use check, list, write, except or copy`);
|
|
1018
|
+
}));
|
|
937
1019
|
program
|
|
938
1020
|
.command('review <kind> [dir]')
|
|
939
1021
|
.description("Open bravos's questions (.guardlink/<kind>-draft.json, e.g. kind 'intent') as a branded page people answer in; answers are saved to .guardlink/<kind>-answers/<name>.json. Runs no model.")
|
|
@@ -945,7 +1027,22 @@ export function buildProgram(io, result) {
|
|
|
945
1027
|
.action((kind, dir, opts) => guardedAsync(async (lines) => {
|
|
946
1028
|
const root = dirArg(dir);
|
|
947
1029
|
checkKind(kind);
|
|
1030
|
+
// Adopting principles is a Team feature, and it happens on the served page only: that is where the server
|
|
1031
|
+
// records each adoption with its fingerprint (src/principles.ts withAdoptions).
|
|
1032
|
+
if (kind === 'principles' && !opts.summary) {
|
|
1033
|
+
await requireFeature(io.env, 'principles', 'Adopting security design principles');
|
|
1034
|
+
if (opts.share || opts.serve === false)
|
|
1035
|
+
throw new BravosError('principles are adopted on the served page only (bravos review principles), so each adoption is recorded with its exact wording; --share and --no-serve are for other reviews');
|
|
1036
|
+
}
|
|
948
1037
|
const draft = readDraft(root, kind);
|
|
1038
|
+
// A rewritten draft must not lose an answer somebody confirmed (review.ts lostAnswers).
|
|
1039
|
+
if (!opts.summary) {
|
|
1040
|
+
const lost = lostAnswers(draft, readAllAnswers(root, draft).files);
|
|
1041
|
+
if (lost.length) {
|
|
1042
|
+
throw new BravosError(`${draftPath(kind)} no longer asks ${lost.map((l) => `${l.id} (answered by ${l.by.join(', ')})`).join('; ')}. ` +
|
|
1043
|
+
`Put "replaces": ["<old id>"] on the question that took its place, or list the id under "retired" in the draft if it is no longer asked on purpose; the answers are kept either way.`);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
949
1046
|
if (opts.summary) {
|
|
950
1047
|
const { files, skipped } = readAllAnswers(root, draft);
|
|
951
1048
|
lines.push(summarize(draft, files, skipped));
|
|
@@ -980,9 +1077,17 @@ export function buildProgram(io, result) {
|
|
|
980
1077
|
}
|
|
981
1078
|
const commonDir = (await (await import('./prefs.js')).prefsLib()).gitCommonDir(root, io.env);
|
|
982
1079
|
const say = (l) => (waitFor === null ? lines.push(l) : io.stdout(l));
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1080
|
+
// ONE PAGE PER REVIEW: a page already being served is reused (it re-reads the draft on each load), so a
|
|
1081
|
+
// person's open tab keeps working and nothing they typed is lost to a second page.
|
|
1082
|
+
let live = RW.readLive(commonDir, kind);
|
|
1083
|
+
const started = new Date().toISOString();
|
|
1084
|
+
if (live) {
|
|
1085
|
+
say(`Review page: ${live.url} (already open${waitFor === null ? '' : '; waiting for Confirm'})`);
|
|
1086
|
+
if (waitFor === null)
|
|
1087
|
+
lines.push(`When everyone is done: bravos review ${kind} --summary`);
|
|
1088
|
+
if (waitFor === null && opts.open !== false)
|
|
1089
|
+
openInBrowser(live.url, io.env);
|
|
1090
|
+
}
|
|
986
1091
|
else {
|
|
987
1092
|
const port = await freePort();
|
|
988
1093
|
const token = newToken();
|
|
@@ -996,7 +1101,7 @@ export function buildProgram(io, result) {
|
|
|
996
1101
|
RW.writeLive(commonDir, kind, live);
|
|
997
1102
|
}
|
|
998
1103
|
say(`Review page: ${url}`);
|
|
999
|
-
say(`Answers save
|
|
1104
|
+
say(`Answers save as you go and count once you press Confirm (.guardlink/${kind}-answers/<name>.json). Teammates run bravos review ${kind} after pulling. The page stays open after Confirm and stops after 30 minutes idle.`);
|
|
1000
1105
|
if (waitFor === null)
|
|
1001
1106
|
lines.push(`When everyone is done: bravos review ${kind} --summary`);
|
|
1002
1107
|
if (opts.open !== false)
|
|
@@ -1004,11 +1109,16 @@ export function buildProgram(io, result) {
|
|
|
1004
1109
|
}
|
|
1005
1110
|
if (waitFor === null || !live)
|
|
1006
1111
|
return;
|
|
1007
|
-
|
|
1112
|
+
// Done when somebody confirms after this wait began, or when the page stops (Done, idle).
|
|
1113
|
+
const confirmedSince = () => confirmedOnly(readAllAnswers(root, draft).files).some((f) => (f.confirmedAt ?? '') >= started);
|
|
1114
|
+
const pid = live.pid;
|
|
1115
|
+
const outcome = await RW.waitUntil(() => confirmedSince() || !RW.alive(pid), waitFor * 1000);
|
|
1116
|
+
if (!outcome) {
|
|
1008
1117
|
lines.push(`review: waiting — the page is still open. Run bravos review ${kind} --wait again to keep waiting; it will not open a second page.`);
|
|
1009
1118
|
return;
|
|
1010
1119
|
}
|
|
1011
|
-
RW.
|
|
1120
|
+
if (!RW.alive(pid))
|
|
1121
|
+
RW.clearLive(commonDir, kind);
|
|
1012
1122
|
const { files, skipped } = readAllAnswers(root, draft);
|
|
1013
1123
|
lines.push(files.length ? 'review: done' : 'review: closed with no answers saved', summarize(draft, files, skipped));
|
|
1014
1124
|
}));
|
package/dist/context.js
CHANGED
|
@@ -37,7 +37,7 @@ function readInput(input, L, cwd) {
|
|
|
37
37
|
if (input.from === '-') {
|
|
38
38
|
if (!input.stdin || input.stdin.length === 0)
|
|
39
39
|
throw new BravosError('nothing arrived on standard input: pipe the document in, e.g. cat prd.md | bravos context add - --title "Billing PRD"');
|
|
40
|
-
return { bytes: input.stdin, name: null };
|
|
40
|
+
return { bytes: input.stdin, name: input.name ? basename(input.name.replace(/\\/g, '/')) || null : null };
|
|
41
41
|
}
|
|
42
42
|
const abs = isAbsolute(input.from) ? input.from : resolve(cwd, input.from);
|
|
43
43
|
let st;
|
|
@@ -205,6 +205,51 @@ export async function addSource(dir, input, opts, env, cwd = process.cwd()) {
|
|
|
205
205
|
lines.push(`Commit it with the team's other context: git add ${L.CONTEXT_DIR}`);
|
|
206
206
|
return lines;
|
|
207
207
|
}
|
|
208
|
+
/** Files the intake page may hand the agent to convert: documents people write designs in. */
|
|
209
|
+
const INBOX_TYPES = /\.(pdf|docx?|pptx?|key|odt|odp|rtf|html?|pages)$/i;
|
|
210
|
+
const MAX_INBOX_BYTES = 10 * 1024 * 1024;
|
|
211
|
+
// @comment -- "A design document added on the intake page (src/review.ts POST /documents). Text (Markdown or plain) is stored at once by addSource, with every check bravos context add makes. A file the CLI does not convert (PDF, Word, slides, a web page export) or a link goes to .bravos/context/inbox/, a folder git ignores: the original file and a record of its title, kind and who added it, for the agent to convert and store (the briefing counts them). The browser gives a file name, never a path; nothing is fetched or converted here."
|
|
212
|
+
// @mitigates #context-sources against #committed-secret using #refuse-before-store -- "Text added on the intake page goes through addSource, so the same secret, local-path and embedded-content refusals apply before anything is written; a file the CLI does not convert is kept only in the git-ignored inbox, never committed, until the agent stores its converted text through the same checks"
|
|
213
|
+
// @mitigates #context-sources against #local-path-disclosure using #refuse-before-store -- "A browser-reported file name is reduced to its last segment before it is recorded, so no local path from the person's machine reaches the index"
|
|
214
|
+
export async function addPageDocument(root, doc, env, now = new Date()) {
|
|
215
|
+
const L = await contextLib();
|
|
216
|
+
const store = storeRoot(root, env);
|
|
217
|
+
refuseIfIgnored(store, L, env);
|
|
218
|
+
if (!L.KINDS.includes(doc.kind))
|
|
219
|
+
throw new BravosError(`the kind must be one of ${L.KINDS.join(', ')}`);
|
|
220
|
+
const by = L.cleanLine(doc.by, 80);
|
|
221
|
+
const title = L.cleanLine(doc.title, 120);
|
|
222
|
+
if (!by || !title)
|
|
223
|
+
throw new BravosError('a document needs a title and your name');
|
|
224
|
+
if (doc.text !== undefined) {
|
|
225
|
+
return addSource(store, { from: '-', stdin: Buffer.from(doc.text, 'utf8'), name: doc.name }, { title, kind: doc.kind, by, now }, env);
|
|
226
|
+
}
|
|
227
|
+
const inbox = join(store, L.CONTEXT_DIR, 'inbox');
|
|
228
|
+
mkdirSync(inbox, { recursive: true, mode: 0o700 });
|
|
229
|
+
if (!existsSync(join(inbox, '.gitignore')))
|
|
230
|
+
writeAtomic(join(inbox, '.gitignore'), '*\n');
|
|
231
|
+
const stamp = now.toISOString().replace(/[:.]/g, '-');
|
|
232
|
+
const base = `${stamp}-${L.sourceName('SRC-1', title).replace(/^SRC-1-/, '').replace(/\.md$/, '')}`;
|
|
233
|
+
if (doc.url !== undefined) {
|
|
234
|
+
const u = L.checkUrl(doc.url, {});
|
|
235
|
+
if (!u.url)
|
|
236
|
+
throw new BravosError(`the link was not kept: ${u.problems.join('; ')}`);
|
|
237
|
+
writeAtomic(join(inbox, `${base}.json`), JSON.stringify({ title, kind: doc.kind, by, url: u.url, added: today(now) }, null, 2) + '\n');
|
|
238
|
+
return [`Kept the link for your agent to read and store: ${title}`, 'It appears in the next briefing; the agent stores it with bravos context add --url.'];
|
|
239
|
+
}
|
|
240
|
+
if (!doc.file)
|
|
241
|
+
throw new BravosError('paste the text, choose a file, or give a link');
|
|
242
|
+
const name = L.cleanLine(basename(doc.file.name.replace(/\\/g, '/')), 200).replace(/[\/]/g, '-');
|
|
243
|
+
if (!INBOX_TYPES.test(name))
|
|
244
|
+
throw new BravosError(`${name || 'that file'} is not a document the agent converts here (PDF, Word, slides, Pages or a saved web page); paste Markdown or text instead`);
|
|
245
|
+
const bytes = Buffer.from(doc.file.base64, 'base64');
|
|
246
|
+
if (bytes.length === 0 || bytes.length > MAX_INBOX_BYTES)
|
|
247
|
+
throw new BravosError(`a file must be between 1 byte and ${MAX_INBOX_BYTES / 1048576} MB`);
|
|
248
|
+
const ext = /\.[A-Za-z0-9]{1,8}$/.exec(name)?.[0] ?? '';
|
|
249
|
+
writeAtomic(join(inbox, `${base}${ext}`), bytes);
|
|
250
|
+
writeAtomic(join(inbox, `${base}.json`), JSON.stringify({ title, kind: doc.kind, by, file: `${base}${ext}`, original: name, sha256: L.sha256(bytes), added: today(now) }, null, 2) + '\n');
|
|
251
|
+
return [`Received ${name} (${size(bytes.length)}): your agent converts it to Markdown and stores it with bravos context add --original.`, 'It appears in the next briefing; the original stays in .bravos/context/inbox/, which git ignores.'];
|
|
252
|
+
}
|
|
208
253
|
// @comment -- "bravos context update SRC-n [file]: with a file (or '-'), replaces the stored text after the same vetting; with none, records the file as it now stands, which is how a hand edit is accepted. Either way the stored text must pass the checks, the hash and size are refreshed, and who updated it and when is recorded."
|
|
209
254
|
export async function updateSource(dir, id, input, opts, env, cwd = process.cwd()) {
|
|
210
255
|
const L = await contextLib();
|
|
@@ -331,8 +376,26 @@ export async function declineContext(dir, opts, env) {
|
|
|
331
376
|
// The pre-push check
|
|
332
377
|
// ---------------------------------------------------------------------------------------------
|
|
333
378
|
export const PRE_PUSH_MARKER = 'bravos-context-pre-push';
|
|
334
|
-
// @comment -- "The git pre-push hook bravos writes: a few lines of sh that hand git's list of pushed refs to the context check, from the repository's own copy of the hook scripts or, failing that, the bravos on PATH. With neither it does nothing, so a clone without bravos is never blocked."
|
|
379
|
+
// @comment -- "The git pre-push hook bravos writes: a few lines of sh that hand git's list of pushed refs to the context check and then to the principles check, from the repository's own copy of the hook scripts or, failing that, the bravos on PATH. With neither it does nothing, so a clone without bravos is never blocked."
|
|
335
380
|
export const PRE_PUSH_SCRIPT = `#!/bin/sh
|
|
381
|
+
# ${PRE_PUSH_MARKER} v2: checks the design documents under .bravos/context/ and the security design principles in .guardlink/ before they reach the remote.
|
|
382
|
+
# Written by bravos. Delete this file to stop it; git push --no-verify skips it once.
|
|
383
|
+
refs=$(cat)
|
|
384
|
+
if [ -f .bravos/hooks/lib/context.mjs ] && command -v node >/dev/null 2>&1; then
|
|
385
|
+
printf '%s\\n' "$refs" | node .bravos/hooks/lib/context.mjs pre-push || exit 1
|
|
386
|
+
if [ -f .bravos/hooks/lib/principles.mjs ]; then
|
|
387
|
+
printf '%s\\n' "$refs" | node .bravos/hooks/lib/principles.mjs pre-push || exit 1
|
|
388
|
+
fi
|
|
389
|
+
exit 0
|
|
390
|
+
fi
|
|
391
|
+
if command -v bravos >/dev/null 2>&1; then
|
|
392
|
+
printf '%s\\n' "$refs" | bravos hook context pre-push || exit 1
|
|
393
|
+
printf '%s\\n' "$refs" | bravos hook principles pre-push || exit 1
|
|
394
|
+
fi
|
|
395
|
+
exit 0
|
|
396
|
+
`;
|
|
397
|
+
/** The first version of the hook, so uninstall still recognises one written before principles were checked. */
|
|
398
|
+
const PRE_PUSH_SCRIPT_V1 = `#!/bin/sh
|
|
336
399
|
# ${PRE_PUSH_MARKER} v1: checks the design documents under .bravos/context/ before they reach the remote.
|
|
337
400
|
# Written by bravos. Delete this file to stop it; git push --no-verify skips it once.
|
|
338
401
|
if [ -f .bravos/hooks/lib/context.mjs ] && command -v node >/dev/null 2>&1; then
|
|
@@ -375,7 +438,8 @@ export function removePrePush(root, env, dryRun = false) {
|
|
|
375
438
|
return false;
|
|
376
439
|
const file = join(isAbsolute(rel) ? rel : join(root, rel), 'pre-push');
|
|
377
440
|
try {
|
|
378
|
-
|
|
441
|
+
const have = readFileSync(file, 'utf8');
|
|
442
|
+
if (have !== PRE_PUSH_SCRIPT && have !== PRE_PUSH_SCRIPT_V1)
|
|
379
443
|
return false;
|
|
380
444
|
if (!dryRun)
|
|
381
445
|
rmSync(file);
|
|
@@ -385,3 +449,62 @@ export function removePrePush(root, env, dryRun = false) {
|
|
|
385
449
|
return false;
|
|
386
450
|
}
|
|
387
451
|
}
|
|
452
|
+
// ============================ making the intake travel ============================
|
|
453
|
+
/** The paths the team's context lives at, which must reach the team through git. */
|
|
454
|
+
const MUST_TRAVEL = ['.bravos/context/sources.json', '.guardlink/intent.md', '.guardlink/intent-draft.json', '.guardlink/intent-answers/x.json'];
|
|
455
|
+
// @comment -- "Which of the files the team's context lives in (.bravos/context/, .guardlink/intent*) git would never commit, and the rule that hides each (git check-ignore -v, argv array). When the cause is the common blanket `.bravos/` line in the repository's own .gitignore, the narrowest repair is offered: ignore Bravos's folder except its context. Read-only; silent without git."
|
|
456
|
+
export function contextIgnoreFix(root, env = process.env) {
|
|
457
|
+
let out = '';
|
|
458
|
+
try {
|
|
459
|
+
out = execFileSync('git', ['check-ignore', '-v', '--non-matching', '--stdin'], { cwd: root, env, input: MUST_TRAVEL.join('\n') + '\n', encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 });
|
|
460
|
+
}
|
|
461
|
+
catch (e) {
|
|
462
|
+
out = String(e.stdout ?? '');
|
|
463
|
+
}
|
|
464
|
+
const problems = [];
|
|
465
|
+
for (const row of out.split('\n')) {
|
|
466
|
+
const m = /^([^:]+):(\d+):(.*)\t(.+)$/.exec(row);
|
|
467
|
+
if (!m || !m[1] || m[3].startsWith('!'))
|
|
468
|
+
continue;
|
|
469
|
+
problems.push({ file: m[1], line: Number(m[2]), pattern: m[3], path: m[4] });
|
|
470
|
+
}
|
|
471
|
+
const blanket = problems.find((p) => p.file === '.gitignore' && /^\/?\.bravos\/?\**$/.test(p.pattern.trim()) && p.path.startsWith('.bravos/'));
|
|
472
|
+
return {
|
|
473
|
+
problems,
|
|
474
|
+
fixable: blanket ? { line: blanket.line, was: blanket.pattern, becomes: ['.bravos/*', '!.bravos/context/'] } : null,
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/** The one-line warning setup and doctor print when the context would stay on one machine. */
|
|
478
|
+
export function contextIgnoreWarning(fix) {
|
|
479
|
+
if (!fix.problems.length)
|
|
480
|
+
return null;
|
|
481
|
+
const first = fix.problems[0];
|
|
482
|
+
const how = fix.fixable
|
|
483
|
+
? `run bravos context share --yes to change line ${fix.fixable.line} of .gitignore from "${fix.fixable.was}" to "${fix.fixable.becomes.join('" and "')}"`
|
|
484
|
+
: `remove or narrow the rule at ${first.file}:${first.line} ("${first.pattern}")`;
|
|
485
|
+
return `warning: ${first.file}:${first.line} ("${first.pattern}") hides ${[...new Set(fix.problems.map((p) => p.path.replace(/\/x\.json$/, '/')))].join(', ')} from git, so the intake and design documents will not reach your team; ${how}`;
|
|
486
|
+
}
|
|
487
|
+
// @comment -- "bravos context share: says which rule keeps the team's context out of git and, with --yes, makes the narrowest repair to a blanket `.bravos/` line in the repository's own .gitignore (that one line becomes `.bravos/*` and `!.bravos/context/`; every other rule is left as the team wrote it). Without --yes it changes nothing and prints the exact edit, so a person decides."
|
|
488
|
+
export function shareContext(root, yes, env = process.env) {
|
|
489
|
+
const fix = contextIgnoreFix(root, env);
|
|
490
|
+
if (!fix.problems.length)
|
|
491
|
+
return ['context: nothing hides .bravos/context/ or .guardlink/intent* from git here; commit them and your team gets them on their next pull'];
|
|
492
|
+
const lines = fix.problems.map((p) => `${p.path.replace(/\/x\.json$/, '/')} is ignored by ${p.file}:${p.line} ("${p.pattern}")`);
|
|
493
|
+
if (!fix.fixable)
|
|
494
|
+
return [...lines, 'bravos repairs only a blanket .bravos/ line in .gitignore; change the rule above by hand so these paths are committed'];
|
|
495
|
+
const abs = join(root, '.gitignore');
|
|
496
|
+
const text = readFileSync(abs, 'utf8');
|
|
497
|
+
const rows = text.split('\n');
|
|
498
|
+
const at = fix.fixable.line - 1;
|
|
499
|
+
if (rows[at] === undefined || rows[at].trim() !== fix.fixable.was.trim())
|
|
500
|
+
return [...lines, `.gitignore changed while bravos was reading it; run bravos context share again`];
|
|
501
|
+
if (!yes)
|
|
502
|
+
return [...lines, `With --yes, bravos changes line ${fix.fixable.line} of .gitignore from "${fix.fixable.was}" to:`, ...fix.fixable.becomes.map((b) => ` ${b}`), 'Everything else in .bravos/ stays ignored, as now; only .bravos/context/ (the design documents) is committed.'];
|
|
503
|
+
rows.splice(at, 1, ...fix.fixable.becomes);
|
|
504
|
+
writeAtomic(abs, rows.join('\n'));
|
|
505
|
+
const after = contextIgnoreFix(root, env);
|
|
506
|
+
return [
|
|
507
|
+
`.gitignore line ${fix.fixable.line}: "${fix.fixable.was}" → ${fix.fixable.becomes.map((b) => `"${b}"`).join(', ')}`,
|
|
508
|
+
after.problems.length ? `still ignored: ${after.problems.map((p) => `${p.path} (${p.file}:${p.line})`).join(', ')}` : 'The intake and design documents now reach your team: commit .gitignore, .bravos/context/ and .guardlink/intent* together',
|
|
509
|
+
];
|
|
510
|
+
}
|
package/dist/dashboard.js
CHANGED
|
@@ -7,6 +7,7 @@ import { featureState, licenceLib } from './licence.js';
|
|
|
7
7
|
import { templatesDir, version } from './paths.js';
|
|
8
8
|
import { BravosError } from './types.js';
|
|
9
9
|
import { gatherRules } from './rules.js';
|
|
10
|
+
import { intakeSummary } from './review.js';
|
|
10
11
|
export const DASHBOARD_DIR = '.bravos/dashboard';
|
|
11
12
|
export const DASHBOARD_PATH = `${DASHBOARD_DIR}/index.html`;
|
|
12
13
|
/** What the saved page was built from, for the session briefing to tell a current page from an old one. */
|
|
@@ -262,6 +263,13 @@ export async function buildDashboard(root, env, opts = {}) {
|
|
|
262
263
|
try {
|
|
263
264
|
rules = await gatherRules(root, env, { names: opts.blame !== false, details: true });
|
|
264
265
|
rulesPart = { state: rules.state === 'none' ? 'missing' : 'present', note: rules.note };
|
|
266
|
+
// The Security design view is on the Team plan; on Free the principles stay followed (the instruction block) and
|
|
267
|
+
// the view says what would show them.
|
|
268
|
+
if (rules.principles.length) {
|
|
269
|
+
const f = await featureState(env, 'principles', 'The Security design view');
|
|
270
|
+
if (!f.entitled)
|
|
271
|
+
rules = { ...rules, principles: [], principlesNote: `${rules.principles.length} security design principle${rules.principles.length === 1 ? ' is' : 's are'} adopted here, and coding agents follow ${rules.principles.length === 1 ? 'it' : 'them'} on every plan. ${f.refusal}.` };
|
|
272
|
+
}
|
|
265
273
|
}
|
|
266
274
|
catch (e) {
|
|
267
275
|
rulesPart = { state: 'failed', note: `The design rules could not be read (${e.message.split('\n')[0].slice(0, 200)}).` };
|
|
@@ -285,6 +293,7 @@ export async function buildDashboard(root, env, opts = {}) {
|
|
|
285
293
|
threatModel: { state: tm.state, note: tm.note, blame: tm.blame, since: tm.since },
|
|
286
294
|
codeGraph: { state: cg.state, note: cg.note },
|
|
287
295
|
rules: rulesPart,
|
|
296
|
+
intake: intakeSummary(root),
|
|
288
297
|
};
|
|
289
298
|
const page = renderDashboard(data, tm.html, cg.store, rules);
|
|
290
299
|
let path;
|
package/dist/device.js
CHANGED
|
@@ -6,10 +6,12 @@ import { BravosError } from './types.js';
|
|
|
6
6
|
let cached = null;
|
|
7
7
|
export const refreshLib = () => (cached ??= import(pathToFileURL(join(hooksDir(), 'lib', 'refresh.mjs')).href));
|
|
8
8
|
export const userAgent = () => `bravos-cli/${version()}`;
|
|
9
|
+
let machineCached = null;
|
|
10
|
+
export const machineLib = () => (machineCached ??= import(pathToFileURL(join(hooksDir(), 'lib', 'machine.mjs')).href));
|
|
9
11
|
// @comment -- "Refreshes this machine's device licence when it is due (or always, with force). Never throws; the outcome says what happened, and a revocation or a lapsed plan carries the sentence to show."
|
|
10
12
|
export async function refresh(io, force = false) {
|
|
11
13
|
const R = await refreshLib();
|
|
12
|
-
return R.refreshIfDue(io.env, { fetch: io.fetch, now: io.now, force, userAgent: userAgent() });
|
|
14
|
+
return R.refreshIfDue(io.env, { fetch: io.fetch, now: io.now, force, userAgent: userAgent(), ...(io.machine ? { machine: io.machine } : {}) });
|
|
13
15
|
}
|
|
14
16
|
const requireDevice = async (env) => {
|
|
15
17
|
const R = await refreshLib();
|
package/dist/doctor.js
CHANGED
|
@@ -7,6 +7,7 @@ import { findAnalyzer, findLicence } from './graphbin.js';
|
|
|
7
7
|
import { ALL_AUTOPILOT_COMMANDS, ALL_CARDS_COMMANDS, ALL_COACH_COMMANDS, ALL_PRE_PR_COMMANDS, HOOK_COMMANDS, LEGACY_HOOK_COMMAND, RELATIVE_HOOK_COMMANDS, hookRegistered } from './hooks.js';
|
|
8
8
|
import { skillsRoot } from './skills.js';
|
|
9
9
|
import { cursorHookRegistered } from './cursor.js';
|
|
10
|
+
import { contextIgnoreFix, contextIgnoreWarning } from './context.js';
|
|
10
11
|
import { resolveTheme } from './palette.js';
|
|
11
12
|
import { pathToFileURL } from 'node:url';
|
|
12
13
|
import { hooksDir, version as packageVersion } from './paths.js';
|
|
@@ -62,6 +63,8 @@ export function runDoctor(root, env = process.env) {
|
|
|
62
63
|
tools,
|
|
63
64
|
licence,
|
|
64
65
|
guardlink_initialised: existsSync(join(root, '.guardlink')),
|
|
66
|
+
// Only asked where Bravos is set up: a repository without .guardlink/ has no context to share yet.
|
|
67
|
+
...(existsSync(join(root, '.guardlink')) ? { context_shared: contextIgnoreWarning(contextIgnoreFix(root, env)) } : {}),
|
|
65
68
|
skills: { claude: bravosSkills(root, 'claude'), agents: bravosSkills(root, 'agents') },
|
|
66
69
|
guardlink_skills: { claude: guardlinkSkills(root, 'claude'), agents: guardlinkSkills(root, 'agents') },
|
|
67
70
|
hooks: {
|
|
@@ -154,6 +157,7 @@ export function formatDoctor(r) {
|
|
|
154
157
|
`coach claude: ${yn(r.coach.claude)} codex: ${yn(r.coach.codex)}${r.coach.claude || r.coach.codex ? (process.env.BRAVOS_COACH === 'off' ? ' (off for this run: BRAVOS_COACH=off)' : '') : ' (bravos setup adds it)'}`,
|
|
155
158
|
...(r.dead_hooks?.length ? [`✘ dead user-level hooks ${r.dead_hooks.map((d) => `${d.file} ${d.event}: ${d.script} is gone`).join('; ')} — every session shows "hook error". Remove them (a backup is kept): bravos doctor --fix-hooks`] : r.dead_hooks ? ['✔ no dead user-level hooks'] : []),
|
|
156
159
|
...(r.legacy_skills?.length ? [`✘ old Python bravos skills ${r.legacy_skills.map((f) => `${f.root}: ${f.names.join(', ')}`).join('; ')} — your agent may load them instead of this repository's. Move them aside (reversible): ${r.legacy_command}`] : r.legacy_skills ? ['✔ no old Python bravos skills at user level'] : []),
|
|
160
|
+
...(r.context_shared === undefined ? [] : r.context_shared ? [`✘ ${r.context_shared.replace(/^warning: /, '')}`] : ['✔ intake and design documents reach the team through git']),
|
|
157
161
|
...(r.updates ? [updatesLine(r.updates)] : []),
|
|
158
162
|
...(r.theme ? [`colours ${r.theme.theme} (${r.theme.source})${r.theme.source.startsWith('default') ? ' — pick yours: BRAVOS_THEME=light or dark, or bravos setup' : ''}`] : []),
|
|
159
163
|
].join('\n');
|
package/dist/guide.js
CHANGED
|
@@ -26,7 +26,7 @@ export const GUIDE_TOPICS = [
|
|
|
26
26
|
{
|
|
27
27
|
name: 'Plans',
|
|
28
28
|
body: [
|
|
29
|
-
'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine\'s: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
|
|
29
|
+
'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine\'s: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. At activation and at each renewal bravos sends the account portal a one-way fingerprint of the machine (a hash of the operating system machine id, never the id itself, and none in a container or CI), which the portal uses to allow one free trial per person and machine. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
|
|
30
30
|
],
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -116,8 +116,9 @@ export const GUIDE_TOPICS = [
|
|
|
116
116
|
{ name: 'Where do I start? What is open?', skills: ['bravos'], body: ['Reads the briefing and names the one next step, with the reason.'] },
|
|
117
117
|
{ name: 'Teach bravos what the app is for', skills: ['bravos-context'], body: ['Writes .guardlink/intent.md: invariants (INV-n) that become threats, and intended-by-design items (INT-n) that get an "intended?" audit instead of a high rating.'] },
|
|
118
118
|
{ name: 'Start from your design documents', skills: ['bravos-context'], body: ['Give bravos-context your PRDs, design documents or an earlier threat model, as files or links. Each is kept in the repository as Markdown under .bravos/context/ (bravos context add; committed, so the team can keep it current) after a check for secrets and local paths; a link is kept beside its snapshot. Every rule then names the document it came from (INV-4, source: SRC-2), including who may do what: "sales may see every report except the revenue report" becomes a rule that can be tested, where a scan would see nothing wrong. bravos context list shows the documents, bravos context check re-checks them, and a pre-push check stops a push that would send a secret in one. Free; the CLI runs no model and fetches nothing: your agent converts and fetches with your own access.'] },
|
|
119
|
+
{ name: 'Write down your company\'s security design principles', skills: ['bravos-principles'], body: ['Ask for "our security design principles". bravos-principles proposes candidates only from your stored documents (cited by section, checked against the text), INV rules a person already confirmed in this or another repository, or an optional starter list mapped to OWASP ASVS 4.0.3, which is never pre-selected; bravos review principles refuses anything else. On the page each principle is its own decision (Agree, Change the wording, or No); there is no adopt-all. Confirm records your adoption with the exact wording and a fingerprint, and bravos writes .guardlink/principles.md from the adoptions: committed, so every developer who pulls gets it, and the Bravos block in AGENTS.md and CLAUDE.md tells every coding agent to read and follow it and never edit it. A principle is enforced (it becomes a threat with principle:SDP-n, is tested, and the pre-PR gate stops a change that breaks it, whatever the PR body says) or guidance (followed, not tested). bravos principles check (free; the pre-push hook and the gate run it) fails a hand-edited line, an adoption nobody made, or an exception past its date. An exception is approved by a person at their own terminal: bravos principles except SDP-n --where "<glob>" --reason "<why>" --until <date>, at most a year, never extended; a coding agent cannot run it. bravos principles copy --from <repository> takes the same set into another repository, and check says when the source changes. The dashboard\'s Security design view shows each principle, where it is enforced, its exceptions, and what it caught or stopped in the last 30 and 90 days. Team plan for authoring, the gate and the view; adopted principles are followed on every plan.'] },
|
|
119
120
|
{ name: 'See which design rules hold', skills: ['bravos', 'bravos-recheck'], body: ['bravos rules lists every rule your design states (INV-n in the intent) with its status: broken (a test got through), retest due (the code under it changed since it was tested), unguarded (it can break somewhere and nothing stops it), guarded but untested, not placed (no code is tied to it yet), or holds (a test tried and was refused everywhere it is enforced). Each line names the document the rule came from and the places it is enforced. bravos dashboard shows the same under Threat model, as Design rules in GuardLink\'s sidebar beside Exposures, worst first. Free, read-only, no model; --json prints bravos.rules/v1. On the Team plan the pre-PR check and the PR workflow hold a pull request that changes a file a holding rule is enforced in (the check, or the role table that grants the permission) after that rule was last tested, until its test is replayed or the PR body names the rule; the after-edit note says the same while you work.'] },
|
|
120
|
-
{ name: 'The intake asks, it never blocks', skills: ['bravos-context', 'bravos-annotate'], body: ['Annotation starts in the first session. With no confirmed intent, the agent drafts what the product is for from the README, docs and code (.guardlink/intent.md, every item marked draft), annotates against that draft, and opens the intake page without waiting. Each session asks once for a person to confirm it (bravos review intent, a few minutes) until someone confirms or declines; the agent never confirms for you. Rules drafted from the design are tested and can block a pull request right away; bravos rules and the block message label them draft until a person confirms them. When the answers arrive, the agent re-judges what they changed: an item you mark intended by design is annotated as intended, not as a finding. A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent and ends the asking; a coding agent is told never to decline for you. bravos context gate says which state a repository is in.'] },
|
|
121
|
+
{ name: 'The intake asks, it never blocks', skills: ['bravos-context', 'bravos-annotate'], body: ['Annotation starts in the first session. With no confirmed intent, the agent drafts what the product is for from the README, docs and code (.guardlink/intent.md, every item marked draft), annotates against that draft, and opens the intake page without waiting. Each session asks once for a person to confirm it (bravos review intent, a few minutes) until someone confirms or declines; the agent never confirms for you. Rules drafted from the design are tested and can block a pull request right away; bravos rules and the block message label them draft until a person confirms them. When the answers arrive, the agent re-judges what they changed: an item you mark intended by design is annotated as intended, not as a finding. The intake page brings back the answers each person gave when they reopen it, and saves them as they go; only Confirm makes them count, and it records who and when. Design documents (a PRD, a design document, an earlier threat model) can be added on the page itself: Markdown and text are stored with the usual checks, and a PDF, Word file, slides or link waits for the agent to convert. Every rule cites the section of the document it came from, the page shows that passage under the question, and bravos context check refuses a section the document does not have. The intake and the documents are committed so the team gets them on their next pull; bravos doctor warns when a .gitignore rule keeps them on one machine, and bravos context share --yes narrows a blanket .bravos/ rule. A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent and ends the asking; a coding agent is told never to decline for you. bravos context gate says which state a repository is in.'] },
|
|
121
122
|
{ name: 'Updates', skills: ['bravos'], body: ['Bravos tells you when it is updated. At most once a day a session start asks the npm registry, in a background process the session never waits on, for the latest published version: the same request npm install makes, with only the package name. A newer version shows in the banner and the briefing, and the coach tells a session that is already running, once. Installing it is yours to do (npm install -g @bugb-technologies/bravos); once it is installed the coach has the agent run bravos setup in the repository, which brings its Bravos files up to date. bravos doctor shows the last check. BRAVOS_UPDATE_CHECK=off stops the check, and it never runs in CI.'] },
|
|
122
123
|
{ name: 'Threat cards', skills: ['bravos-prove', 'bravos-env'], body: ['When an edit adds a critical or high threat to the threat model (an @exposes claim) that no test has confirmed or refuted, a hook that runs after the edit shows you a card in the terminal straight away: the severity, what the threat is, the claim and where it is, its state, and one next step (bravos-env to set up a test target, where you type the authorization, then bravos-prove). The agent is told to raise it in the same reply and recommend confirming it; it never confirms, refutes or accepts a threat itself. Only lines that are not in the last commit count, so existing claims never raise a card, and each threat raises one card per clone. The hook reads the edited files, their committed copy and the local ledger; it runs no guardlink, no test and no network. bravos watch lists every card. BRAVOS_THREAT_CARDS=off turns cards off for a run and bravos prefs set cards off --by "<your name>" for the clone; bravos prefs set notify on --by "<your name>" adds a desktop notification (macOS and Linux).'] },
|
|
123
124
|
{ name: 'The coach', skills: ['bravos'], body: ['Bravos does not wait to be asked. Before each prompt a fast hook (it runs no guardlink and no network) may add one line for the agent. A question about issues, threats, vulnerabilities, findings or risks builds the dashboard while the agent answers, and opens it in your browser the first time in a session; later questions rebuild it and give the path. From the second prompt on it reminds, each topic once a session and at most one per prompt: claims waiting to be confirmed, with the next step (bravos-env to set up a target, where you type the authorization, then bravos-prove); how much of the code the threat model covers, with the next round; and a dashboard that is older than the model. Skills end every round the same way. bravos watch lists each reminder. BRAVOS_COACH=off turns it off for one run, and bravos prefs set coach off --by "<your name>" for this clone.'] },
|
|
@@ -145,7 +146,7 @@ export const GUIDE_TOPICS = [
|
|
|
145
146
|
{
|
|
146
147
|
id: 'skills',
|
|
147
148
|
title: 'Every skill',
|
|
148
|
-
summary: 'all
|
|
149
|
+
summary: 'all seventeen skills, what each does and leaves for the next',
|
|
149
150
|
items: [
|
|
150
151
|
{ name: 'bravos', body: ['Front door: reads the security picture, explains the evidence loop, routes to the right skill.'] },
|
|
151
152
|
{ name: 'bravos-context', body: ['Learns what the product intends from the repo and a short interview; records invariants, intended behaviour, actors, assets and boundaries.'] },
|
|
@@ -159,6 +160,7 @@ export const GUIDE_TOPICS = [
|
|
|
159
160
|
{ name: 'bravos-resync', body: ['A stale checkout or a left-behind branch: carries its annotation work onto the base with bravos resync, maps duplicate ids, re-reads every carried claim on changed code.'] },
|
|
160
161
|
{ name: 'bravos-sast', body: ['Licensed static analysis joined to guardlink claims and reachability; gates on findings new since the base.'] },
|
|
161
162
|
{ name: 'bravos-threat-hunt', body: ['"Identify all the threats": maps the attack surface with the code graph, runs SAST, records every finding in the threat model with bravos-annotate, rebuilds the dashboard and reports from what was recorded, then recommends confirming the top three.'] },
|
|
163
|
+
{ name: 'bravos-principles', body: ['Your company\'s security design principles, from your own documents and confirmed rules (or an optional starter list mapped to OWASP ASVS): proposed on the review page, adopted one by one by named people, written by bravos to .guardlink/principles.md, followed by every coding agent, and enforced ones tested and held to by the pre-PR gate.'] },
|
|
162
164
|
{ name: 'bravos-campaign', body: ['A goal over many rounds: disjoint batches, one subagent each, a gate per batch, rests, a final before-and-after.'] },
|
|
163
165
|
{ name: 'bravos-schedule', body: ['Recurring upkeep with each harness\'s own mechanism; never live tests from a loop.'] },
|
|
164
166
|
{ name: 'bravos-cicd', body: ['Audits and writes the security workflows.'] },
|