@bugb-technologies/bravos 1.7.0 → 1.9.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/README.md +11 -7
- package/dist/ci.js +1 -1
- package/dist/cli.js +271 -111
- package/dist/codegraph.js +21 -0
- package/dist/context.js +1 -1
- package/dist/doctor.js +20 -11
- package/dist/global.js +3 -3
- package/dist/graphbin.js +2 -0
- package/dist/guardlink.js +1 -1
- package/dist/guide.js +12 -10
- package/dist/help.js +45 -19
- package/dist/hooks.js +44 -21
- package/dist/install.js +2 -1
- package/dist/lock.js +1 -0
- package/dist/mcp.js +21 -5
- package/dist/palette.js +2 -2
- package/dist/plugin-release.js +2 -2
- package/dist/plugin.js +3 -3
- package/dist/prefs.js +66 -0
- package/dist/review-wait.js +76 -0
- package/dist/setup-route.js +37 -0
- package/dist/setup.js +3 -2
- package/dist/skills.js +1 -1
- package/dist/start/answers.js +36 -7
- package/dist/start/index.js +190 -69
- package/dist/start/repos.js +1 -1
- package/dist/start/ui.js +2 -2
- package/dist/upkeep.js +89 -0
- package/dist/watch-frame.js +1 -1
- package/dist/watch.js +1 -1
- package/docs/GUIDE.md +23 -11
- package/docs/UPGRADING.md +43 -1
- package/hooks/lib/autopilot.mjs +3 -18
- package/hooks/lib/briefing.mjs +93 -14
- package/hooks/lib/graph-autobuild.mjs +131 -0
- package/hooks/lib/legacy-skills.mjs +68 -0
- package/hooks/lib/palette.mjs +4 -4
- package/hooks/lib/prefs.mjs +108 -0
- package/hooks/lib/refresh.mjs +45 -1
- package/hooks/lib/setup.mjs +8 -8
- package/hooks/lib/snapshot.mjs +19 -1
- package/hooks/session-start.mjs +7 -2
- package/package.json +1 -1
- package/skills/bravos/SKILL.md +5 -4
- package/skills/bravos-annotate/SKILL.md +4 -4
- package/skills/bravos-cicd/SKILL.md +1 -1
- package/skills/bravos-codegraph/SKILL.md +1 -1
- package/skills/bravos-context/SKILL.md +6 -6
- package/skills/bravos-env/SKILL.md +2 -2
- package/skills/bravos-env/scope.example.yaml +2 -1
- package/skills/bravos-prove/SKILL.md +2 -2
- package/skills/bravos-recheck/SKILL.md +1 -1
- package/skills/bravos-resync/SKILL.md +1 -1
- package/skills/bravos-schedule/SKILL.md +1 -1
- package/skills/bravos-ship/SKILL.md +3 -3
- package/skills/bravos-templatize/SKILL.md +1 -1
- package/templates/review/review.html +1 -1
package/dist/codegraph.js
CHANGED
|
@@ -52,6 +52,27 @@ export function build(root, env, opts = {}) {
|
|
|
52
52
|
const r = spawnSync(bin, args, { cwd: root, env: graphEnv(env), encoding: 'utf8', timeout: opts.timeoutMs ?? 3 * 600 * 1000, maxBuffer: 64 * 1024 * 1024 });
|
|
53
53
|
return { status: r.status, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };
|
|
54
54
|
}
|
|
55
|
+
// @comment -- "bravos graph mcp: runs codegraph-mcp for this repository with the terminal's own stdin, stdout and stderr and the graph store in its environment, and resolves with its exit code. This is what .mcp.json registers, so an agent's MCP client talks to the server through this CLI and the entry holds no path. Nothing is printed here: stdout belongs to the protocol. A signal to this process is passed on, and the server also stops when its stdin closes."
|
|
56
|
+
export function serveMcp(root, env) {
|
|
57
|
+
const bin = graphBin('codegraph-mcp', env);
|
|
58
|
+
if (!bin)
|
|
59
|
+
throw new BravosError('codegraph-mcp is not installed: bravos setup --codegraph fetches it (on the Team plan)');
|
|
60
|
+
return new Promise((done) => {
|
|
61
|
+
const child = spawn(bin, ['--project-path', root], { cwd: root, env: graphEnv(env), stdio: 'inherit' });
|
|
62
|
+
const pass = (sig) => () => child.kill(sig);
|
|
63
|
+
const onInt = pass('SIGINT');
|
|
64
|
+
const onTerm = pass('SIGTERM');
|
|
65
|
+
process.on('SIGINT', onInt);
|
|
66
|
+
process.on('SIGTERM', onTerm);
|
|
67
|
+
const finish = (code) => {
|
|
68
|
+
process.off('SIGINT', onInt);
|
|
69
|
+
process.off('SIGTERM', onTerm);
|
|
70
|
+
done(code);
|
|
71
|
+
};
|
|
72
|
+
child.on('error', () => finish(1));
|
|
73
|
+
child.on('exit', (code, sig) => finish(code ?? (sig ? 1 : 0)));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
55
76
|
export class GraphUnavailable extends BravosError {
|
|
56
77
|
constructor(message) {
|
|
57
78
|
super(message);
|
package/dist/context.js
CHANGED
|
@@ -362,7 +362,7 @@ export function installPrePush(root, env) {
|
|
|
362
362
|
mkdirSync(dir, { recursive: true });
|
|
363
363
|
writeFileSync(file, PRE_PUSH_SCRIPT, { mode: 0o755 });
|
|
364
364
|
chmodSync(file, 0o755);
|
|
365
|
-
return ['A pre-push check now runs in this clone: a push that changes the design documents is stopped if one carries a secret or a local path (teammates get it from bravos
|
|
365
|
+
return ['A pre-push check now runs in this clone: a push that changes the design documents is stopped if one carries a secret or a local path (teammates get it from bravos setup).'];
|
|
366
366
|
}
|
|
367
367
|
catch (e) {
|
|
368
368
|
return [`The pre-push check could not be installed (${e.message.split('\n')[0]}); bravos context check does the same by hand.`];
|
package/dist/doctor.js
CHANGED
|
@@ -4,9 +4,11 @@ import { join } from 'node:path';
|
|
|
4
4
|
import { installedGuardlinkSkills, whichBin } from './guardlink.js';
|
|
5
5
|
import { graphBin } from './codegraph.js';
|
|
6
6
|
import { findAnalyzer, findLicence } from './graphbin.js';
|
|
7
|
-
import {
|
|
7
|
+
import { ALL_AUTOPILOT_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 { resolveTheme } from './palette.js';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
11
|
+
import { hooksDir } from './paths.js';
|
|
10
12
|
const TOOLS = [
|
|
11
13
|
{ name: 'guardlink', hint: 'bravos setup --tools -y installs a compatible GuardLink' },
|
|
12
14
|
{ name: 'cxg', hint: 'bravos setup --tools -y installs a compatible CXG' },
|
|
@@ -54,16 +56,16 @@ export function runDoctor(root, env = process.env) {
|
|
|
54
56
|
skills: { claude: bravosSkills(root, 'claude'), agents: bravosSkills(root, 'agents') },
|
|
55
57
|
guardlink_skills: { claude: guardlinkSkills(root, 'claude'), agents: guardlinkSkills(root, 'agents') },
|
|
56
58
|
hooks: {
|
|
57
|
-
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'SessionStart', [HOOK_COMMANDS.claude, LEGACY_HOOK_COMMAND]),
|
|
58
|
-
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'SessionStart', [HOOK_COMMANDS.agents, LEGACY_HOOK_COMMAND]),
|
|
59
|
+
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'SessionStart', [HOOK_COMMANDS.claude, RELATIVE_HOOK_COMMANDS.claude, LEGACY_HOOK_COMMAND]),
|
|
60
|
+
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'SessionStart', [HOOK_COMMANDS.agents, RELATIVE_HOOK_COMMANDS.agents, LEGACY_HOOK_COMMAND]),
|
|
59
61
|
},
|
|
60
62
|
autopilot: {
|
|
61
|
-
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'Stop',
|
|
62
|
-
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'Stop',
|
|
63
|
+
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'Stop', ALL_AUTOPILOT_COMMANDS),
|
|
64
|
+
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'Stop', ALL_AUTOPILOT_COMMANDS),
|
|
63
65
|
},
|
|
64
66
|
pre_pr: {
|
|
65
|
-
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'PreToolUse',
|
|
66
|
-
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'PreToolUse',
|
|
67
|
+
claude: hookRegistered(join(root, '.claude', 'settings.json'), 'PreToolUse', ALL_PRE_PR_COMMANDS),
|
|
68
|
+
codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'PreToolUse', ALL_PRE_PR_COMMANDS),
|
|
67
69
|
},
|
|
68
70
|
theme: resolveTheme(env),
|
|
69
71
|
};
|
|
@@ -73,18 +75,25 @@ export function runDoctor(root, env = process.env) {
|
|
|
73
75
|
export function withLicence(r, plan, licensed) {
|
|
74
76
|
return { ...r, licence: { ...r.licence, plan, licensed } };
|
|
75
77
|
}
|
|
78
|
+
// @comment -- "Adds the user-level skills the retired Python bravos left behind, and the command that moves them aside, to a report built synchronously; the finder is the hook library's, loaded asynchronously like the licence."
|
|
79
|
+
export async function withLegacySkills(r, env) {
|
|
80
|
+
const L = (await import(pathToFileURL(join(hooksDir(), 'lib', 'legacy-skills.mjs')).href));
|
|
81
|
+
const found = L.legacySkills({ ...env, HOME: env.HOME ?? homedir() });
|
|
82
|
+
return { ...r, legacy_skills: found, ...(found.length ? { legacy_command: L.retireCommand(found) } : {}) };
|
|
83
|
+
}
|
|
76
84
|
export function formatDoctor(r) {
|
|
77
85
|
const yn = (b) => (b ? 'yes' : 'no');
|
|
78
86
|
const names = (l) => (l.length ? l.join(', ') : 'none');
|
|
79
87
|
return [
|
|
80
88
|
...r.tools.map((t) => (t.found ? `✔ ${t.name} ${t.path}` : `✘ ${t.name} ${t.hint}`)),
|
|
81
89
|
r.licence.plan ? `${r.licence.licensed ? '✔' : '✘'} licence ${r.licence.plan}` : r.licence.present ? `✔ licence ${r.licence.source}` : '✘ licence not found — Free (researcher) plan; bravos account activate starts a 30-day Team trial',
|
|
82
|
-
r.guardlink_initialised ? '✔ guardlink initialised (.guardlink/)' : '✘ guardlink not initialised — run bravos
|
|
90
|
+
r.guardlink_initialised ? '✔ guardlink initialised (.guardlink/)' : '✘ guardlink not initialised — run bravos setup',
|
|
83
91
|
`skills claude: ${r.skills.claude.length} agents: ${r.skills.agents.length}`,
|
|
84
92
|
`guardlink skills claude: ${names(r.guardlink_skills.claude)} agents: ${names(r.guardlink_skills.agents)}`,
|
|
85
93
|
`hooks claude: ${yn(r.hooks.claude)} codex: ${yn(r.hooks.codex)}`,
|
|
86
|
-
`pre-pr claude: ${yn(r.pre_pr.claude)} codex: ${yn(r.pre_pr.codex)}${r.pre_pr.claude || r.pre_pr.codex ? '' : ' (opt-in: bravos
|
|
87
|
-
`autopilot claude: ${yn(r.autopilot.claude)} codex: ${yn(r.autopilot.codex)}${r.autopilot.claude || r.autopilot.codex ? '' : ' (opt-in: bravos
|
|
88
|
-
...(r.
|
|
94
|
+
`pre-pr claude: ${yn(r.pre_pr.claude)} codex: ${yn(r.pre_pr.codex)}${r.pre_pr.claude || r.pre_pr.codex ? '' : ' (opt-in: bravos setup --pre-pr-hook)'}`,
|
|
95
|
+
`autopilot claude: ${yn(r.autopilot.claude)} codex: ${yn(r.autopilot.codex)}${r.autopilot.claude || r.autopilot.codex ? '' : ' (opt-in: bravos setup --autopilot)'}`,
|
|
96
|
+
...(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'] : []),
|
|
97
|
+
...(r.theme ? [`colours ${r.theme.theme} (${r.theme.source})${r.theme.source.startsWith('default') ? ' — pick yours: BRAVOS_THEME=light or dark, or bravos setup' : ''}`] : []),
|
|
89
98
|
].join('\n');
|
|
90
99
|
}
|
package/dist/global.js
CHANGED
|
@@ -41,14 +41,14 @@ function linkUserSkill(home, name, dryRun) {
|
|
|
41
41
|
}
|
|
42
42
|
return 'linked';
|
|
43
43
|
}
|
|
44
|
-
// @comment -- "User-level install (bravos
|
|
44
|
+
// @comment -- "User-level install (bravos setup --global): skills once in ~/.claude/skills with absolute paths, a link per skill from ~/.agents/skills, the hook scripts in ~/.bravos/hooks registered as user SessionStart hooks for Claude Code (~/.claude/settings.json) and Codex (~/.codex/hooks.json) in --global mode, and guardlink in ~/.codex/config.toml. Touches nothing in any repo; the lock is ~/.bravos/skills.lock."
|
|
45
45
|
export function installGlobal(env, lines, opts = {}) {
|
|
46
46
|
const home = homeOf(env);
|
|
47
47
|
const dryRun = !!opts.dryRun;
|
|
48
48
|
// Claude Code's sandbox can hold back writes under ~/.claude while ~/.bravos/skills.lock still lands,
|
|
49
49
|
// leaving a stale copy marked current; the user-level install runs only outside a Claude Code session.
|
|
50
50
|
if (env.CLAUDECODE && !dryRun && env.BRAVOS_ALLOW_SESSION_GLOBAL !== '1') {
|
|
51
|
-
throw new BravosError('the user-level install writes ~/.claude, which a Claude Code session may not reach; run bravos
|
|
51
|
+
throw new BravosError('the user-level install writes ~/.claude, which a Claude Code session may not reach; run bravos setup --global in your own terminal (BRAVOS_ALLOW_SESSION_GLOBAL=1 overrides)');
|
|
52
52
|
}
|
|
53
53
|
if (dryRun)
|
|
54
54
|
lines.push('dry-run: nothing written');
|
|
@@ -91,5 +91,5 @@ export function installGlobal(env, lines, opts = {}) {
|
|
|
91
91
|
lines.push(`MCP: ~/${m.path} added ${m.added.length ? m.added.join(', ') : 'none'}`);
|
|
92
92
|
lines.push(`MCP for Claude Code at user level: claude mcp add --scope user guardlink -- guardlink mcp`);
|
|
93
93
|
lines.push('In Codex run /hooks once to trust ~/.codex/hooks.json');
|
|
94
|
-
lines.push('
|
|
94
|
+
lines.push('Repositories set up with bravos setup keep their own skills and hooks; that is still how a team shares bravos through git.');
|
|
95
95
|
}
|
package/dist/graphbin.js
CHANGED
|
@@ -132,5 +132,7 @@ export function graphStoreDir(env = process.env) {
|
|
|
132
132
|
return null;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
// @comment -- "True for a codegraph-mcp entry written by full path into this CLI's staged bundle ($BRAVOS_HOME/codegraph/<version>/<target>/codegraph-mcp). Such a path exists only on the machine that wrote it and changes with every bundle upgrade, so in a committed file it is both a local path and a broken entry for everyone else."
|
|
136
|
+
export const isStagedGraphCommand = (command) => typeof command === 'string' && /^(?:\/|[A-Za-z]:[\\/]).*[\\/]codegraph[\\/][^\\/]+[\\/][^\\/]+[\\/]codegraph-mcp$/.test(command);
|
|
135
137
|
/** True for a codegraph-mcp entry bravos registers by full path into a bravos install, which goes stale when that install is replaced. */
|
|
136
138
|
export const isInstallGraphCommand = (command) => typeof command === 'string' && /[\\/]bravos[\\/]_graph[\\/]bin[\\/]codegraph-mcp$/.test(command);
|
package/dist/guardlink.js
CHANGED
|
@@ -66,7 +66,7 @@ export function installedGuardlinkSkills(root, skillsRoot) {
|
|
|
66
66
|
export const SCOPE_PATH = '.guardlink/scope.yaml';
|
|
67
67
|
export const SCOPE_SOURCE = 'bravos-env/scope.example.yaml';
|
|
68
68
|
/** Copies the bundled loopback-only scope starter to `.guardlink/scope.yaml` when that file is absent; never overwrites. */
|
|
69
|
-
// @comment -- "Writes the cxg scope starter only when .guardlink/scope.yaml is absent and .guardlink/ exists (creating .guardlink/ here would make a later bravos
|
|
69
|
+
// @comment -- "Writes the cxg scope starter only when .guardlink/scope.yaml is absent and .guardlink/ exists (creating .guardlink/ here would make a later bravos setup skip guardlink init); never overwrites a scope the team may have reviewed, and records the hash in the lock."
|
|
70
70
|
export function writeScope(root, skillsDir, opts = {}) {
|
|
71
71
|
const abs = join(root, SCOPE_PATH);
|
|
72
72
|
if (existsSync(abs))
|
package/dist/guide.js
CHANGED
|
@@ -37,7 +37,7 @@ export const GUIDE_TOPICS = [
|
|
|
37
37
|
{
|
|
38
38
|
name: 'Installing',
|
|
39
39
|
body: [
|
|
40
|
-
'npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos
|
|
40
|
+
'npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos setup: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. Then open your agent and say anything: Bravos begins with what the app is for and goes on to your code once you confirm (where the agent runs no hooks, it tells you the one thing to type).', 'By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos setup --agent claude in a repository writes the skills, hooks and MCP wiring, bravos setup --analyzer --codegraph puts the analyzer and the code graph on the machine (Team plan), and guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.',
|
|
41
41
|
],
|
|
42
42
|
},
|
|
43
43
|
{
|
|
@@ -51,7 +51,7 @@ export const GUIDE_TOPICS = [
|
|
|
51
51
|
{
|
|
52
52
|
name: 'Hands-off: autopilot',
|
|
53
53
|
body: [
|
|
54
|
-
'bravos
|
|
54
|
+
'bravos setup --autopilot makes upkeep happen without anyone asking. At turn end the agent reviews changed code, including edits inside annotated files. It follows the recorded proving preference for affected claims. The pre-PR gate runs on every gh pr create.',
|
|
55
55
|
'Proving follows your choice, not a fixed rule: the first time it comes up the agent asks you once — prove automatically on your loopback target, ask each time, on a schedule, or not now — and records your words in .guardlink/proving.md. Say "ask me first" or "stop auto-proving" at any time to change it. Non-loopback targets still need a reviewed scope and your typed authorization every time.',
|
|
56
56
|
],
|
|
57
57
|
},
|
|
@@ -86,7 +86,7 @@ export const GUIDE_TOPICS = [
|
|
|
86
86
|
name: 'Team lead or reviewer',
|
|
87
87
|
skills: ['bravos-campaign', 'bravos-schedule', 'bravos-cicd'],
|
|
88
88
|
body: [
|
|
89
|
-
'Turn on bravos
|
|
89
|
+
'Turn on bravos setup --autopilot so the threat model keeps up as people work, with no commands to remember, and settle once with the team how findings should be proven (it is recorded in .guardlink/proving.md and shows in every briefing).',
|
|
90
90
|
'Coverage and findings are visible to everyone from the repo itself. To raise coverage or clear the backlog, run bravos-campaign with a goal ("coverage 100%", "test every open exposure"): it plans disjoint batches, runs one subagent per batch, gates each, rests, and reports before-and-after numbers. Use bravos-schedule for recurring upkeep (an in-session loop or the nightly workflow) and bravos-cicd for the PR gate and code-scanning upload. Acceptances (@accepts) and entitlements are yours to write; agents never write them.',
|
|
91
91
|
],
|
|
92
92
|
},
|
|
@@ -101,7 +101,7 @@ export const GUIDE_TOPICS = [
|
|
|
101
101
|
name: 'CI owner',
|
|
102
102
|
skills: ['bravos-cicd', 'bravos-schedule'],
|
|
103
103
|
body: [
|
|
104
|
-
'bravos
|
|
104
|
+
'bravos setup --ci writes the PR gate and nightly workflows. bravos-cicd audits existing workflows: broken guardlink calls, script injection from pull-request text, missing SARIF upload. The Claude and Codex nightlies can replay committed, bound kits when scheduled testing is authorized. The Copilot job assigns an annotation task.',
|
|
105
105
|
],
|
|
106
106
|
},
|
|
107
107
|
],
|
|
@@ -117,19 +117,21 @@ export const GUIDE_TOPICS = [
|
|
|
117
117
|
{ 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 as its Design rules tab, worst first, beside GuardLink\'s threat model. 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.'] },
|
|
118
118
|
{ name: 'Context comes first', skills: ['bravos-context', 'bravos-annotate'], body: ['Threat-modelling starts only when a named person has confirmed what the product intends: bravos-annotate, campaigns and the nightly workflows wait until at least one item in .guardlink/intent.md is confirmed (run bravos-context; it asks for your design documents and a few decisions). A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent; a coding agent is told never to decline for you. bravos context gate says which state a repository is in. Rechecks, retests and the ship check are not held back: they maintain a model that already exists.'] },
|
|
119
119
|
{ name: 'Threat-model someone else\'s project', skills: ['bravos-context', 'bravos-annotate'], body: ['bravos-context assumes you are researching software you do not own (an open-source project, a vendor\'s code): it drafts the intent from upstream\'s own docs with links and asks only the scope decisions — which configuration to rate against (shipped defaults or the hardened setup upstream recommends), single organisation or multi-tenant, which attackers are in scope, and the intended-looking behaviours upstream does not document. intent.md records them as Assumptions, and severities are rated against them. Say "this is our product" for the owner interview instead.'] },
|
|
120
|
-
{ name: 'Answer bravos\'s questions as a team', skills: ['bravos-context'], body: ['bravos-context opens its questions as a bravos page (bravos review intent): pre-filled with bravos\'s suggestions and their sources; change what is wrong, make the calls marked \'needs your call\' (Confirm stays off until you do), and the facts bravos drafted stay folded unless you open one to object. The role-by-action matrix links each documented permission to its question. In local reviews, open a cited SRC document to read its verified text. The saved HTML can contain these documents. Each person\'s answers save to .guardlink/intent-answers/<name>.json; teammates run bravos review intent after pulling and commit theirs. bravos review intent --summary shows where people agree and disagree; only what a named person agreed to is marked confirmed. On Claude Code, --share prepares an artifact with the draft and its citations. Publish that artifact to share it.'] },
|
|
120
|
+
{ name: 'Answer bravos\'s questions as a team', skills: ['bravos-context'], body: ['bravos-context opens its questions as a bravos page (bravos review intent): pre-filled with bravos\'s suggestions and their sources; change what is wrong, make the calls marked \'needs your call\' (Confirm stays off until you do), and the facts bravos drafted stay folded unless you open one to object. The role-by-action matrix links each documented permission to its question. In local reviews, open a cited SRC document to read its verified text. The saved HTML can contain these documents. Each person\'s answers save to .guardlink/intent-answers/<name>.json; teammates run bravos review intent after pulling and commit theirs. Press Done when you are finished: the agent runs bravos review intent --wait and carries on by itself. bravos review intent --summary shows where people agree and disagree; only what a named person agreed to is marked confirmed. On Claude Code, --share prepares an artifact with the draft and its citations. Publish that artifact to share it.'] },
|
|
121
121
|
{ name: 'I wrote security-relevant code', skills: ['bravos-annotate'], body: ['Annotates what you changed to guardlink\'s evidence bar and runs the lint gate until clean.'] },
|
|
122
122
|
{ name: 'Cover the whole repo', skills: ['bravos-campaign'], body: ['Rounds of batches with subagents and rests, until the coverage goal or until you stop it.'] },
|
|
123
123
|
{ name: 'Is this exposure real?', skills: ['bravos-templatize', 'bravos-env', 'bravos-prove'], body: ['Template → authorized target → run. Only a reproduced run confirms; reading code never does.'] },
|
|
124
124
|
{ name: 'My branch moved, or I found old annotation work', skills: ['bravos-resync'], body: ['When the briefing says this checkout is far behind its base, or lists idle branches with annotation work the base lacks: saves uncommitted work in a commit, starts a branch from the base, carries the sidecars and definitions with bravos resync, maps ids that duplicate the base\'s, and re-reads every carried claim on code that changed since. Old annotations are leads until re-read.'] },
|
|
125
125
|
{ name: 'I fixed a finding', skills: ['bravos-recheck'], body: ['Re-verifies stale claims, replays the retest kit, and checks the fix added no new exposure.'] },
|
|
126
126
|
{ name: 'I am about to open a PR', skills: ['bravos-ship'], body: ['The no-mistakes gate: validate, lint since the merge base, disclose new exposure, block confirmed exploits on changed paths.'] },
|
|
127
|
-
{ name: 'Find the routes, callers or blast radius', skills: ['bravos-codegraph'], body: ['One bounded question to the code graph instead of grepping. Team plan: bravos setup --codegraph stages codegraph-mcp, then bravos graph build . indexes the repository. With it, other skills get sharper on their own: bravos-templatize targets the route and auth that actually reach each sink, bravos-recheck follows a fix\'s callers and blast radius into other files, bravos-context drafts the real public surface, and bravos-prove tests the most reachable exposures first. Without it they read the code and say so.'] },
|
|
127
|
+
{ name: 'Find the routes, callers or blast radius', skills: ['bravos-codegraph'], body: ['One bounded question to the code graph instead of grepping. Team plan: bravos setup --codegraph stages codegraph-mcp, then bravos graph build . indexes the repository. With it, other skills get sharper on their own: bravos-templatize targets the route and auth that actually reach each sink, bravos-recheck follows a fix\'s callers and blast radius into other files, bravos-context drafts the real public surface, and bravos-prove tests the most reachable exposures first. After each commit the graph is rebuilt for you: when a session starts and the commit has none, the session hook starts one quiet background build (no tokens; one at a time; never in CI; BRAVOS_GRAPH_AUTOBUILD=off turns it off). Without it they read the code and say so.'] },
|
|
128
128
|
{ name: 'Scan for dependency CVEs, secrets, IaC', skills: ['bravos-sast'], body: ['Licensed bravos-cli: Semgrep rules, request-to-sink taint over the code graph, dependency CVEs with whether the vulnerable function is reached, secrets (git history too) and IaC. It reads the GuardLink threat model as input, so annotate first. Says plainly when it is unavailable.'] },
|
|
129
129
|
{ name: 'What did SAST find, and what happens to it', skills: ['bravos-sast', 'bravos-annotate', 'bravos-templatize', 'bravos-prove', 'bravos-recheck'], body: ['bravos sast candidates (free, no model) reads the newest run in .bravos/sast/: reachable findings joined to a claim feed bravos-templatize and bravos-prove (the route and taint path to target, tested first); reachable findings not in the threat model are leads for bravos-annotate; bravos-recheck rescans the changed files after a fix. A static finding is a lead, never a confirmation; only a run confirms. The briefing\'s SAST line shows the latest run, or that SAST is unavailable.'] },
|
|
130
130
|
{ name: 'Keep it fresh while I work, or nightly', skills: ['bravos-schedule'], body: ['An in-session /loop from .claude/loop.md, the nightly workflow, or a cloud task you create. Loops never send test traffic.'] },
|
|
131
131
|
{ name: 'Add or fix security CI', skills: ['bravos-cicd'], body: ['PR gate, nightly annotation, SARIF to code scanning, script-injection fixes.'] },
|
|
132
132
|
{ name: 'An app made of several repositories (microservices)', skills: ['bravos-annotate', 'bravos-codegraph', 'bravos-prove'], body: ['Clone the services side by side in one folder, then run bravos workspace create NAME --member ./gateway=gateway@http://127.0.0.1:8080 --member ./orders=orders@http://127.0.0.1:8081 (bravos workspace plus guardlink link-project plus bravos in each repo and in the shared folder). Work on a service from its own repo; ask questions that cross services from the shared folder, where the briefing and bravos watch show every service. Declare each call to another service as @flows #<this>-<x> -> #<other>-<y> via http (plain ids, not #repo.tag). Build the code graph over the shared folder so it links one service\'s client calls to another\'s handlers. bravos report data --workspace writes one report across the services.'] },
|
|
133
|
+
{ name: 'After updating bravos', skills: ['bravos'], body: ['Nothing to run by hand in a repository you work in with an agent: at the start of a session bravos upkeep (read-only, no network) tells the agent what is behind the installed version, and the agent runs bravos setup, which brings the repository\'s skills and hooks and Bravos\'s own bundles up to date, without asking. If a teammate synced the repository with a newer bravos than yours, the agent syncs nothing and tells you to update. Installing guardlink and cxg (bravos setup --tools) still waits for your go-ahead.'] },
|
|
134
|
+
{ name: 'Stop being asked about commits', skills: ['bravos'], body: ['Say once whether your agent commits the files Bravos writes (annotations, intent, definitions, tests): bravos prefs set commits commit|leave|ask --by "<your name>". bravos setup asks it too. The answer is kept in this clone\'s git directory, never committed, and your own code is never part of such a commit. bravos prefs get shows it.'] },
|
|
133
135
|
{ name: 'See the findings on one page', skills: ['bravos'], body: ['Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink\'s threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. Run it again whenever you want the picture: it rebuilds from the code as it stands, rebuilding a code graph that is missing or behind first, and a saved page says when it is more than half a day old. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".'] },
|
|
134
136
|
{ name: 'Write up the assessment, a finding or a retest', skills: ['bravos-report'], body: ['Ask "write the assessment report" (or a finding, a retest, an executive brief). bravos report data gathers the evidence; the agent writes report.md in the eight-section reading order, with every proof claim citing its evidence; bravos report check refuses a finding labelled reproduced without a run or ledger record; bravos report export writes md, txt, html and pdf. bravos watch shows the newest report (p to read it, o to open the pdf or html).'] },
|
|
135
137
|
],
|
|
@@ -143,7 +145,7 @@ export const GUIDE_TOPICS = [
|
|
|
143
145
|
{ name: 'bravos-context', body: ['Learns what the product intends from the repo and a short interview; records invariants, intended behaviour, actors, assets and boundaries.'] },
|
|
144
146
|
{ name: 'bravos-annotate', body: ['Picks a budgeted slice (entry points and trust code first), follows guardlink\'s own playbook, writes annotations to the evidence bar, lints until clean, reports the coverage delta.'] },
|
|
145
147
|
{ name: 'bravos-codegraph', body: ['Bounded questions to codegraph-mcp: routes, attack surface, sinks a symbol reaches, liveness, blast radius, annotation gaps in a change.'] },
|
|
146
|
-
{ name: 'bravos-ship', body: ['The pre-PR gate. Optional PreToolUse hook (bravos
|
|
148
|
+
{ name: 'bravos-ship', body: ['The pre-PR gate. Optional PreToolUse hook (bravos setup --pre-pr-hook) runs it on every gh pr create / gh pr ready.'] },
|
|
147
149
|
{ name: 'bravos-templatize', body: ['Turns open exposures into validated cxg templates following guardlink\'s translate method; keeps replay kits apart from scan templates; records classes with no oracle as gaps.'] },
|
|
148
150
|
{ name: 'bravos-env', body: ['Brings up a target you own: loopback by default, a committed reviewed scope.yaml, your typed authorization, a real session captured or imported.'] },
|
|
149
151
|
{ name: 'bravos-prove', body: ['Runs the authorized test, reads cxg\'s report and exit code, writes outcomes only through guardlink\'s hypothesis ledger.'] },
|
|
@@ -176,7 +178,7 @@ export const GUIDE_TOPICS = [
|
|
|
176
178
|
{ name: 'Authorization', body: ['No request goes to a host other than loopback without a committed, reviewed scope.yaml and your own typed authorization naming the target.'] },
|
|
177
179
|
{ name: 'Destructive tests', body: ['DoS and other destructive classes run only against a disposable loopback target.'] },
|
|
178
180
|
{ name: 'Credentials', body: ['Never invented. Test users and sessions are seeded or captured for real, or the run waits for you.'] },
|
|
179
|
-
{ name: 'No hidden agents', body: ['The agent in your session does the work; bravos never spawns another agent CLI
|
|
181
|
+
{ name: 'No hidden agents', body: ['The agent in your session does the work; bravos never spawns another agent CLI, and never uses cxg\'s model-API probe generation: the tests it runs are the ones written and reviewed in your session.'] },
|
|
180
182
|
{ name: 'Governance', body: ['Agents never write @accepts or @entitles (a human\'s decision) and never write @confirmed without reproduction evidence in hand.'] },
|
|
181
183
|
],
|
|
182
184
|
},
|
|
@@ -192,8 +194,8 @@ export const GUIDE_TOPICS = [
|
|
|
192
194
|
{ name: 'Antigravity (agy)', body: ['Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group that injects the briefing.'] },
|
|
193
195
|
{ name: 'Cursor', body: ['.cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.'] },
|
|
194
196
|
{ name: 'VS Code (Copilot agent)', body: ['Reads hooks from .claude/settings.json (preview), so the briefing can load there too.'] },
|
|
195
|
-
{ name: 'Every repo, or one copy of each skill', body: ['bravos
|
|
196
|
-
{ name: 'Banner switches', body: ['BRAVOS_BANNER=off hides it; BRAVOS_BANNER_COLOR=off or NO_COLOR prints it plain. The briefing for the model is unchanged either way.', 'Light terminal? BRAVOS_THEME=light (or dark, or neutral) picks the colours for the banner and bravos watch; otherwise COLORFGBG, the choice saved by bravos
|
|
197
|
+
{ name: 'Every repo, or one copy of each skill', body: ['bravos setup --global installs for your user: skills in ~/.claude/skills (linked from ~/.agents/skills) and a user hook that briefs repos with a threat model but no bravos install. bravos setup --link-skills makes a repo\'s .agents/skills a link to .claude/skills, so tools that read both (Warp) list each skill once.'] },
|
|
198
|
+
{ name: 'Banner switches', body: ['BRAVOS_BANNER=off hides it; BRAVOS_BANNER_COLOR=off or NO_COLOR prints it plain. The briefing for the model is unchanged either way.', 'Light terminal? BRAVOS_THEME=light (or dark, or neutral) picks the colours for the banner and bravos watch; otherwise COLORFGBG, the choice saved by bravos setup, then neutral. bravos doctor shows which, and the c key in bravos watch switches.'] },
|
|
197
199
|
],
|
|
198
200
|
},
|
|
199
201
|
];
|
package/dist/help.js
CHANGED
|
@@ -136,6 +136,25 @@ Design rules
|
|
|
136
136
|
unguarded, guarded but untested, not placed, holds), the document it came from and where the
|
|
137
137
|
code enforces it. bravos dashboard shows them as its Design rules tab. Read-only; no model.
|
|
138
138
|
|
|
139
|
+
Commits
|
|
140
|
+
Your agent asks before it commits the files Bravos writes. Say it once and it stops asking:
|
|
141
|
+
bravos prefs set commits commit|leave|ask --by "<your name>" (bravos setup asks it too).
|
|
142
|
+
The answer is kept under this clone's git directory, never committed; your own code is
|
|
143
|
+
never part of such a commit. bravos prefs get shows it.
|
|
144
|
+
|
|
145
|
+
Upkeep
|
|
146
|
+
After you update bravos, each repository's copies of the skills and hooks are behind it,
|
|
147
|
+
and a staged bundle may be older than the new version pins. bravos upkeep says so; your
|
|
148
|
+
agent's session briefing reads it and the agent runs bravos setup itself.
|
|
149
|
+
When the repository is the newer side, it tells you to update bravos and syncs nothing.
|
|
150
|
+
BRAVOS_UPKEEP_PROBE=off stops the check.
|
|
151
|
+
|
|
152
|
+
The code graph is rebuilt for you too (Team plan): a graph belongs to the commit it was
|
|
153
|
+
built at, so when a session starts and the commit has none, the session hook starts one
|
|
154
|
+
quiet background build (bravos graph build . --scip no-exec: no tokens, no network, and the
|
|
155
|
+
repository's own build scripts are not run). One build per repository at a time; never in
|
|
156
|
+
CI; BRAVOS_GRAPH_AUTOBUILD=off turns it off.
|
|
157
|
+
|
|
139
158
|
Context comes first
|
|
140
159
|
bravos-annotate, campaigns and the nightly workflows start only when a named person has
|
|
141
160
|
confirmed at least one item of .guardlink/intent.md, or has recorded that the team goes
|
|
@@ -152,7 +171,7 @@ Session start
|
|
|
152
171
|
the briefing still reaches the model. The banner uses bravos's brand colours (truecolor);
|
|
153
172
|
NO_COLOR or BRAVOS_BANNER_COLOR=off prints it plain. Colours follow the terminal's
|
|
154
173
|
background: BRAVOS_THEME=light|dark|neutral, else COLORFGBG, else the choice saved by
|
|
155
|
-
bravos
|
|
174
|
+
bravos setup, else neutral (readable on light and dark); bravos doctor says which.
|
|
156
175
|
Codex lists a hook message as a
|
|
157
176
|
warning, so there it is a two-line summary instead of the art. Since 0.5.0 the hook is registered with
|
|
158
177
|
--harness claude or --harness codex so the banner prints /skill or $skill; sync migrates
|
|
@@ -165,7 +184,7 @@ Session start
|
|
|
165
184
|
Antigravity (agy) reads .agents/hooks.json: bravos adds a 'bravos' SessionStart group
|
|
166
185
|
there that hands the briefing to the model (it documents no way to show a banner).
|
|
167
186
|
|
|
168
|
-
Autopilot (hands-off): bravos
|
|
187
|
+
Autopilot (hands-off): bravos setup --autopilot
|
|
169
188
|
For teams who would rather not ask. At the end of every turn a check (a Stop hook in
|
|
170
189
|
Claude Code and Codex, a few seconds) sends the agent back once when the turn's changes
|
|
171
190
|
add or change source behavior or affect a claim due for testing. The check names
|
|
@@ -180,8 +199,8 @@ Autopilot (hands-off): bravos init --autopilot
|
|
|
180
199
|
|
|
181
200
|
Harnesses
|
|
182
201
|
Claude Code, Codex, Antigravity (agy), opencode and omp; --agent all installs for every
|
|
183
|
-
one. bravos
|
|
184
|
-
that briefs repos with a threat model but no bravos). bravos
|
|
202
|
+
one. bravos setup --global installs for your user (skills in ~/.claude/skills, a user hook
|
|
203
|
+
that briefs repos with a threat model but no bravos). bravos setup --link-skills keeps one
|
|
185
204
|
copy of each skill when a tool reads both .claude/skills and .agents/skills (Warp).
|
|
186
205
|
bravos uninstall [--global] removes it again.
|
|
187
206
|
|
|
@@ -216,15 +235,22 @@ Rules every skill follows
|
|
|
216
235
|
disposable loopback target. Never invents credentials. Never calls anything clean unless
|
|
217
236
|
a gate exited 0.
|
|
218
237
|
|
|
219
|
-
|
|
220
|
-
bravos
|
|
221
|
-
#
|
|
222
|
-
|
|
238
|
+
One command sets Bravos up: bravos setup
|
|
239
|
+
bravos setup # in a terminal, guided: this machine (sign in, tools), then
|
|
240
|
+
# this repository (agents, PR checks, testing); nothing
|
|
241
|
+
# changes until Apply. In a repository that already has
|
|
242
|
+
# Bravos it brings the machine and the repository up to date.
|
|
243
|
+
bravos setup --change # ask this repository's questions again
|
|
244
|
+
bravos setup --check # what is installed and what setup would do; changes nothing
|
|
245
|
+
Or one part at a time, without questions
|
|
223
246
|
bravos doctor # what is installed, what is missing
|
|
224
|
-
bravos
|
|
225
|
-
bravos
|
|
226
|
-
bravos
|
|
227
|
-
bravos
|
|
247
|
+
bravos setup --tools -y # this machine: guardlink and cxg
|
|
248
|
+
bravos setup --agent claude --dry-run # this repository: preview every write
|
|
249
|
+
bravos setup --agent claude # install; then open a Claude Code or Codex session
|
|
250
|
+
bravos setup --ci --pre-pr-hook # later: add CI and the pre-PR gate
|
|
251
|
+
bravos setup --workflows nightly-claude --schedule weekly # a weekly nightly only
|
|
252
|
+
bravos setup --yes # a first setup with the defaults, nothing asked
|
|
253
|
+
With no terminal (an agent, a script), a plain bravos setup only brings what is installed up to date.
|
|
228
254
|
In Codex, run /hooks once to trust .codex/hooks.json.
|
|
229
255
|
|
|
230
256
|
Exit codes
|
|
@@ -243,10 +269,10 @@ What it writes (repository-relative)
|
|
|
243
269
|
.claude/settings.json SessionStart hook, --harness claude (+ PreToolUse gate
|
|
244
270
|
with --pre-pr-hook)
|
|
245
271
|
.codex/hooks.json the same for Codex, --harness codex
|
|
246
|
-
.mcp.json, .codex/config.toml MCP servers: guardlink always; cxg when on PATH;
|
|
247
|
-
|
|
248
|
-
the
|
|
249
|
-
|
|
272
|
+
.mcp.json, .codex/config.toml MCP servers: guardlink always; cxg when on PATH; the code graph
|
|
273
|
+
as "bravos graph mcp" when its bundle is staged (no path, so
|
|
274
|
+
the entry works for every teammate; sync rewrites an older
|
|
275
|
+
entry that held a full path), else codegraph-mcp from PATH
|
|
250
276
|
.cursor/rules/bravos.mdc pointer to the skills, only if .cursor/ exists
|
|
251
277
|
.omp/extensions/bravos.js omp session start, only if .omp/ exists or omp is on PATH
|
|
252
278
|
Every merge keeps entries bravos did not write. A file it cannot parse is refused with
|
|
@@ -277,7 +303,7 @@ Flags in depth
|
|
|
277
303
|
for testing. Also registers the pre-PR gate (implies --pre-pr-hook), which also lints. New
|
|
278
304
|
exposures are handled as you choose: the first time proving comes up the agent asks
|
|
279
305
|
you once (prove automatically on your loopback target, ask each time, on a schedule,
|
|
280
|
-
or not now
|
|
306
|
+
or not now) and records your
|
|
281
307
|
words in .guardlink/proving.md, which a PR that changes it must mention. It uses only
|
|
282
308
|
guardlink's fast calls (a few seconds); a missing tool or timeout lets the turn finish.
|
|
283
309
|
BRAVOS_AUTOPILOT=off pauses the check.
|
|
@@ -292,9 +318,9 @@ Flags in depth
|
|
|
292
318
|
registered in ~/.claude/settings.json and ~/.codex/hooks.json, guardlink MCP in
|
|
293
319
|
~/.codex/config.toml. The user hook stays silent in a repo that has its own bravos
|
|
294
320
|
hook or no .guardlink/, so it briefs only repos with a threat model and no bravos.
|
|
295
|
-
Personal skills are not in git: bravos
|
|
321
|
+
Personal skills are not in git: bravos setup in a repo is still how a team shares it.
|
|
296
322
|
Claude Code prefers personal skills over a repo's, so once a user-level install
|
|
297
|
-
exists, bravos
|
|
323
|
+
exists, bravos setup in any repo also brings it to the same version (it never creates
|
|
298
324
|
one). BRAVOS_SYNC_GLOBAL=off keeps them separate and only warns.
|
|
299
325
|
--force
|
|
300
326
|
Overwrite bravos files you edited, and same-named files bravos did not write.
|
package/dist/hooks.js
CHANGED
|
@@ -5,24 +5,40 @@ import { OLD_HOOK_COMMANDS, OLD_NAME, oldGlobalHookCommand } from './migrate.js'
|
|
|
5
5
|
import { BravosError } from './types.js';
|
|
6
6
|
// @comment -- "The SessionStart command before 0.5.0; init and sync replace it with the per-harness form, and doctor still accepts it."
|
|
7
7
|
export const LEGACY_HOOK_COMMAND = 'node .bravos/hooks/session-start.mjs';
|
|
8
|
+
// @comment -- "Where a hook command finds the repository's .bravos/hooks. Until 1.8 the commands were relative (node .bravos/hooks/x.mjs), and a harness runs a hook in the session's current folder: once the agent changed folder (cd ios/Runner), every hook failed with 'Cannot find module', autopilot stopped running and the pre-PR gate let gh pr create through unchecked. Claude Code gives the project root as ${CLAUDE_PROJECT_DIR}; Codex documents resolving from the git top level. Both are quoted, so a path with a space works. Antigravity runs its hook in the workspace and keeps the relative form."
|
|
9
|
+
const HOOK_ROOT = {
|
|
10
|
+
claude: '${CLAUDE_PROJECT_DIR}',
|
|
11
|
+
agents: '$(git rev-parse --show-toplevel)',
|
|
12
|
+
};
|
|
13
|
+
/** The command a harness runs for one of the repository's hook scripts, found from the project root. */
|
|
14
|
+
export const hookCommand = (harness, script, args = '') => `node "${HOOK_ROOT[harness]}/.bravos/hooks/${script}"${args ? ` ${args}` : ''}`;
|
|
15
|
+
/** The relative form 1.8 and earlier registered for each script; sync replaces it, doctor and uninstall still recognise it. */
|
|
16
|
+
const relative1 = (script, args = '') => `node .bravos/hooks/${script}${args ? ` ${args}` : ''}`;
|
|
17
|
+
const HARNESS_ARG = { claude: '--harness claude', agents: '--harness codex' };
|
|
8
18
|
// @comment -- "The SessionStart command bravos registers per harness; --harness tells the banner which skill syntax to print. doctor matches on the same constants."
|
|
9
19
|
export const HOOK_COMMANDS = {
|
|
10
|
-
claude:
|
|
11
|
-
agents:
|
|
20
|
+
claude: hookCommand('claude', 'session-start.mjs', HARNESS_ARG.claude),
|
|
21
|
+
agents: hookCommand('agents', 'session-start.mjs', HARNESS_ARG.agents),
|
|
22
|
+
};
|
|
23
|
+
/** The relative SessionStart commands 1.8 and earlier registered. */
|
|
24
|
+
export const RELATIVE_HOOK_COMMANDS = {
|
|
25
|
+
claude: relative1('session-start.mjs', HARNESS_ARG.claude),
|
|
26
|
+
agents: relative1('session-start.mjs', HARNESS_ARG.agents),
|
|
12
27
|
};
|
|
13
|
-
// @comment -- "The
|
|
14
|
-
export const PRE_PR_COMMAND = '
|
|
28
|
+
// @comment -- "The relative pre-PR and autopilot commands 1.8 and earlier registered. The per-harness forms below replace them; every check that asks whether a hook is installed accepts both."
|
|
29
|
+
export const PRE_PR_COMMAND = relative1('pre-pr.mjs');
|
|
15
30
|
// @comment -- "The SessionStart registration bravos writes into .claude/settings.json and .codex/hooks.json, per harness; the Codex plugin build reuses its shape."
|
|
16
|
-
// @comment -- "The user-level SessionStart command (bravos
|
|
31
|
+
// @comment -- "The user-level SessionStart command (bravos setup --global): an absolute path into ~/.bravos/hooks, and --global so the hook stays silent in repos that have their own bravos hook or no threat model."
|
|
17
32
|
export const globalHookCommand = (home, harness) => `node "${home}/.bravos/hooks/session-start.mjs" --harness ${harness === 'claude' ? 'claude' : 'codex'} --global`;
|
|
18
33
|
export function sessionStart(harness, home) {
|
|
19
34
|
const command = home ? globalHookCommand(home, harness) : HOOK_COMMANDS[harness];
|
|
20
35
|
return {
|
|
21
36
|
event: 'SessionStart',
|
|
22
37
|
command,
|
|
23
|
-
// The pre-0.5.0 form, and every form the old name (joseph) registered, repo-level and user-level.
|
|
38
|
+
// The pre-0.5.0 form, the relative per-harness forms up to 1.8, and every form the old name (joseph) registered, repo-level and user-level.
|
|
24
39
|
replaces: [
|
|
25
40
|
LEGACY_HOOK_COMMAND,
|
|
41
|
+
...(home ? [] : Object.values(RELATIVE_HOOK_COMMANDS)),
|
|
26
42
|
OLD_HOOK_COMMANDS.sessionStart,
|
|
27
43
|
...['claude', 'codex', 'agy'].map((h) => `${OLD_HOOK_COMMANDS.sessionStart} --harness ${h}`),
|
|
28
44
|
...(home ? ['claude', 'codex'].map((h) => oldGlobalHookCommand(home, h)) : []),
|
|
@@ -31,20 +47,27 @@ export function sessionStart(harness, home) {
|
|
|
31
47
|
};
|
|
32
48
|
}
|
|
33
49
|
// @comment -- "The command bravos registers as its opt-in autopilot Stop hook (Claude Code and Codex); doctor and uninstall match on it."
|
|
34
|
-
export const AUTOPILOT_COMMAND = '
|
|
35
|
-
|
|
50
|
+
export const AUTOPILOT_COMMAND = relative1('autopilot.mjs');
|
|
51
|
+
/** The commands each harness now registers for the opt-in hooks. */
|
|
52
|
+
export const AUTOPILOT_COMMANDS = { claude: hookCommand('claude', 'autopilot.mjs'), agents: hookCommand('agents', 'autopilot.mjs') };
|
|
53
|
+
export const PRE_PR_COMMANDS = { claude: hookCommand('claude', 'pre-pr.mjs'), agents: hookCommand('agents', 'pre-pr.mjs') };
|
|
54
|
+
/** Every form of each opt-in hook bravos has registered, for the checks that ask whether one is installed. */
|
|
55
|
+
export const ALL_AUTOPILOT_COMMANDS = [AUTOPILOT_COMMAND, ...Object.values(AUTOPILOT_COMMANDS)];
|
|
56
|
+
export const ALL_PRE_PR_COMMANDS = [PRE_PR_COMMAND, ...Object.values(PRE_PR_COMMANDS)];
|
|
57
|
+
export const ALL_SESSION_COMMANDS = [LEGACY_HOOK_COMMAND, ...Object.values(RELATIVE_HOOK_COMMANDS), ...Object.values(HOOK_COMMANDS)];
|
|
58
|
+
const autopilot = (h) => ({
|
|
36
59
|
event: 'Stop',
|
|
37
|
-
command:
|
|
38
|
-
replaces: [OLD_HOOK_COMMANDS.autopilot],
|
|
39
|
-
group: { hooks: [{ type: 'command', command:
|
|
40
|
-
};
|
|
60
|
+
command: AUTOPILOT_COMMANDS[h],
|
|
61
|
+
replaces: [OLD_HOOK_COMMANDS.autopilot, AUTOPILOT_COMMAND],
|
|
62
|
+
group: { hooks: [{ type: 'command', command: AUTOPILOT_COMMANDS[h], timeout: 30 }] },
|
|
63
|
+
});
|
|
41
64
|
// The hook script itself only acts on commands that run gh pr create or gh pr ready.
|
|
42
|
-
const
|
|
65
|
+
const prePr = (h) => ({
|
|
43
66
|
event: 'PreToolUse',
|
|
44
|
-
command:
|
|
45
|
-
replaces: [OLD_HOOK_COMMANDS.prePr],
|
|
46
|
-
group: { matcher: 'Bash', hooks: [{ type: 'command', command:
|
|
47
|
-
};
|
|
67
|
+
command: PRE_PR_COMMANDS[h],
|
|
68
|
+
replaces: [OLD_HOOK_COMMANDS.prePr, PRE_PR_COMMAND],
|
|
69
|
+
group: { matcher: 'Bash', hooks: [{ type: 'command', command: PRE_PR_COMMANDS[h], timeout: 180 }] },
|
|
70
|
+
});
|
|
48
71
|
const SETTINGS_FILE = {
|
|
49
72
|
claude: '.claude/settings.json',
|
|
50
73
|
agents: '.codex/hooks.json',
|
|
@@ -145,8 +168,8 @@ export function hookRegistered(file, event, commands) {
|
|
|
145
168
|
export function installedOptIns(root) {
|
|
146
169
|
const files = [join(root, '.claude', 'settings.json'), join(root, '.codex', 'hooks.json')];
|
|
147
170
|
return {
|
|
148
|
-
autopilot: files.some((f) => hookRegistered(f, 'Stop',
|
|
149
|
-
prePr: files.some((f) => hookRegistered(f, 'PreToolUse',
|
|
171
|
+
autopilot: files.some((f) => hookRegistered(f, 'Stop', ALL_AUTOPILOT_COMMANDS)),
|
|
172
|
+
prePr: files.some((f) => hookRegistered(f, 'PreToolUse', ALL_PRE_PR_COMMANDS)),
|
|
150
173
|
};
|
|
151
174
|
}
|
|
152
175
|
export const AGY_HOOK_COMMAND = `${LEGACY_HOOK_COMMAND} --harness agy`;
|
|
@@ -183,8 +206,8 @@ export function installHook(root, harnesses, opts = {}) {
|
|
|
183
206
|
const withAutopilot = opts.autopilot && !opts.globalHome;
|
|
184
207
|
const plans = [...new Set(harnesses)].map((h) => planRegistration(root, SETTINGS_FILE[h], [
|
|
185
208
|
sessionStart(h, opts.globalHome),
|
|
186
|
-
...(withPrePr ? [
|
|
187
|
-
...(withAutopilot ? [
|
|
209
|
+
...(withPrePr ? [prePr(h)] : []),
|
|
210
|
+
...(withAutopilot ? [autopilot(h)] : []),
|
|
188
211
|
], [
|
|
189
212
|
...(withPrePr ? [] : [{ event: 'PreToolUse', commands: [OLD_HOOK_COMMANDS.prePr] }]),
|
|
190
213
|
...(withAutopilot ? [] : [{ event: 'Stop', commands: [OLD_HOOK_COMMANDS.autopilot] }]),
|
package/dist/install.js
CHANGED
|
@@ -68,7 +68,8 @@ export function installSkills(root, harnesses, opts = {}) {
|
|
|
68
68
|
// The lock claims this version only when every file was written; a skipped or failed file keeps
|
|
69
69
|
// the old version, so a stale copy stays visible to the shadow check and the next sync retries it.
|
|
70
70
|
const complete = report.skipped.length === 0;
|
|
71
|
-
|
|
71
|
+
// synced_with records which bravos ran this sync whatever was skipped, so bravos upkeep can tell an older bravos from a newer one.
|
|
72
|
+
writeLock(root, { schema: lock.schema, bravos_version: complete ? version() : lock.bravos_version, synced_with: version(), files: { ...lock.files, ...record } });
|
|
72
73
|
}
|
|
73
74
|
return report;
|
|
74
75
|
}
|
package/dist/lock.js
CHANGED
|
@@ -39,6 +39,7 @@ export function readLock(root) {
|
|
|
39
39
|
return {
|
|
40
40
|
schema: LOCK_SCHEMA,
|
|
41
41
|
bravos_version: typeof p.bravos_version === 'string' ? p.bravos_version : version(),
|
|
42
|
+
...(typeof p.synced_with === 'string' && p.synced_with ? { synced_with: p.synced_with } : {}),
|
|
42
43
|
files,
|
|
43
44
|
};
|
|
44
45
|
}
|
package/dist/mcp.js
CHANGED
|
@@ -3,7 +3,8 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { parse as parseToml } from 'smol-toml';
|
|
4
4
|
import { whichBin } from './guardlink.js';
|
|
5
5
|
import { graphBin, graphStore } from './codegraph.js';
|
|
6
|
-
import {
|
|
6
|
+
import { staged } from './artifacts.js';
|
|
7
|
+
import { isInstallGraphCommand, isStagedGraphCommand, pythonBravos } from './graphbin.js';
|
|
7
8
|
import { BravosError } from './types.js';
|
|
8
9
|
// @comment -- "The launch argv (command and args) for each of the three MCP servers bravos knows: guardlink, cxg and codegraph; frozen so no caller can mutate a shared entry."
|
|
9
10
|
export const SERVERS = Object.freeze({
|
|
@@ -12,6 +13,13 @@ export const SERVERS = Object.freeze({
|
|
|
12
13
|
codegraph: Object.freeze({ command: 'codegraph-mcp', args: ['--project-path', '.'] }),
|
|
13
14
|
});
|
|
14
15
|
const BIN = { cxg: 'cxg', codegraph: 'codegraph-mcp' };
|
|
16
|
+
// @comment -- "The code graph server reached through this CLI (bravos graph mcp), not by the path of the binary. The entry is the same on every machine and after every bundle upgrade, so a committed .mcp.json carries no local path and works for each teammate who has Bravos installed."
|
|
17
|
+
export const GRAPH_LAUNCHER = Object.freeze({ command: 'bravos', args: ['graph', 'mcp'] });
|
|
18
|
+
/** Whether `bravos` on PATH is this CLI (and not the older Python one, which has no `graph mcp`). */
|
|
19
|
+
const thisBravosOnPath = (env) => {
|
|
20
|
+
const onPath = whichBin('bravos', env);
|
|
21
|
+
return !!onPath && pythonBravos(env) !== onPath;
|
|
22
|
+
};
|
|
15
23
|
// @comment -- "Picks the servers to register: guardlink always, cxg when on PATH, codegraph when codegraph-mcp is on PATH or inside the bravos install (registered by full path, with the graph store the bravos launcher uses as BRAVOS_CODEGRAPH_DIR so the MCP route reads the graphs bravos graph build writes); the rest are reported as deferred."
|
|
16
24
|
export function selectServers(env = process.env) {
|
|
17
25
|
const selected = { guardlink: SERVERS.guardlink };
|
|
@@ -24,6 +32,9 @@ export function selectServers(env = process.env) {
|
|
|
24
32
|
const mcpBin = graphBin('codegraph-mcp', env);
|
|
25
33
|
if (mcpBin && mcpBin === whichBin('codegraph-mcp', env))
|
|
26
34
|
selected.codegraph = SERVERS.codegraph;
|
|
35
|
+
// The staged bundle is registered through the launcher wherever this CLI is on PATH; the full path is the fallback (bravos run by path, or the older Python install).
|
|
36
|
+
else if (mcpBin && staged(env, 'codegraph') && thisBravosOnPath(env))
|
|
37
|
+
selected.codegraph = { command: GRAPH_LAUNCHER.command, args: [...GRAPH_LAUNCHER.args] };
|
|
27
38
|
else if (mcpBin) {
|
|
28
39
|
const store = graphStore(env);
|
|
29
40
|
selected.codegraph = { command: mcpBin, args: [...SERVERS.codegraph.args], ...(store ? { env: { BRAVOS_CODEGRAPH_DIR: store } } : {}) };
|
|
@@ -33,9 +44,13 @@ export function selectServers(env = process.env) {
|
|
|
33
44
|
return { selected, deferred };
|
|
34
45
|
}
|
|
35
46
|
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
36
|
-
// @comment -- "Whether an existing entry is bravos's own codegraph registration
|
|
47
|
+
// @comment -- "Whether an existing entry is bravos's own codegraph registration that no longer matches what bravos would write now: one into a replaced Python install (or a graph store it lacks), or one by full path into a staged bundle on some machine when the portable launcher entry is available. Such an entry is refreshed; every other existing entry, a hand-written one included, is kept as it is."
|
|
37
48
|
export function staleGraphEntry(name, existing, next) {
|
|
38
|
-
if (name !== 'codegraph' || !next || !isObject(existing)
|
|
49
|
+
if (name !== 'codegraph' || !next || !isObject(existing))
|
|
50
|
+
return false;
|
|
51
|
+
// A full path into a staged bundle is replaced only by the launcher entry, which is the same everywhere: two machines never rewrite the file back and forth.
|
|
52
|
+
const stagedPath = isStagedGraphCommand(existing.command) && next.command === GRAPH_LAUNCHER.command;
|
|
53
|
+
if (!isInstallGraphCommand(existing.command) && !stagedPath)
|
|
39
54
|
return false;
|
|
40
55
|
return JSON.stringify({ c: existing.command, a: existing.args, e: existing.env ?? null }) !== JSON.stringify({ c: next.command, a: next.args, e: next.env ?? null });
|
|
41
56
|
}
|
|
@@ -64,7 +79,8 @@ export function mergeMcpJson(root, servers, opts = {}) {
|
|
|
64
79
|
const existing = (doc.mcpServers ?? {});
|
|
65
80
|
const updated = names.filter((n) => Object.hasOwn(existing, n) && staleGraphEntry(n, existing[n], servers[n]));
|
|
66
81
|
const kept = names.filter((n) => Object.hasOwn(existing, n) && !updated.includes(n));
|
|
67
|
-
|
|
82
|
+
// onlyExisting: an upkeep run refreshes bravos's own stale entry and adds none, so a tool that happens to be on this machine never changes a committed file.
|
|
83
|
+
const added = opts.onlyExisting ? [] : names.filter((n) => !Object.hasOwn(existing, n));
|
|
68
84
|
if (added.length === 0 && updated.length === 0)
|
|
69
85
|
return { path: rel, changed: false, added, kept };
|
|
70
86
|
for (const n of [...added, ...updated])
|
|
@@ -112,7 +128,7 @@ export function mergeCodexConfig(root, servers, opts = {}) {
|
|
|
112
128
|
}
|
|
113
129
|
const updated = names.filter((n) => Object.hasOwn(tables, n) && staleGraphEntry(n, tables[n], servers[n]) && tomlTable(text, n));
|
|
114
130
|
const kept = names.filter((n) => Object.hasOwn(tables, n) && !updated.includes(n));
|
|
115
|
-
const added = names.filter((n) => !Object.hasOwn(tables, n));
|
|
131
|
+
const added = opts.onlyExisting ? [] : names.filter((n) => !Object.hasOwn(tables, n));
|
|
116
132
|
if (added.length === 0 && updated.length === 0)
|
|
117
133
|
return { path: rel, changed: false, added, kept };
|
|
118
134
|
let base = text;
|