@bugb-technologies/bravos 1.8.0 → 1.9.1

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/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 { AUTOPILOT_COMMAND, HOOK_COMMANDS, LEGACY_HOOK_COMMAND, PRE_PR_COMMAND, hookRegistered } from './hooks.js';
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', [AUTOPILOT_COMMAND]),
62
- codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'Stop', [AUTOPILOT_COMMAND]),
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', [PRE_PR_COMMAND]),
66
- codex: hookRegistered(join(root, '.codex', 'hooks.json'), 'PreToolUse', [PRE_PR_COMMAND]),
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 init',
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 init --pre-pr-hook)'}`,
87
- `autopilot claude: ${yn(r.autopilot.claude)} codex: ${yn(r.autopilot.codex)}${r.autopilot.claude || r.autopilot.codex ? '' : ' (opt-in: bravos init --autopilot)'}`,
88
- ...(r.theme ? [`colours ${r.theme.theme} (${r.theme.source})${r.theme.source.startsWith('default') ? ' — pick yours: BRAVOS_THEME=light or dark, or bravos start' : ''}`] : []),
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 init --global / sync --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."
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 init --global / bravos sync --global in your own terminal (BRAVOS_ALLOW_SESSION_GLOBAL=1 overrides)');
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('Repos with bravos init keep their own skills and hooks; bravos init there is still how a team shares bravos through git.');
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/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 init skip guardlink init); never overwrites a scope the team may have reviewed, and records the hash in the lock."
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 start: 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 init in a repository writes the skills, hooks and MCP wiring, and bravos setup puts the analyzer and the code graph on the machine (Team plan). 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.',
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 init --autopilot (or sync --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.',
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 init --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).',
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 init --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.',
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
  ],
@@ -130,8 +130,8 @@ export const GUIDE_TOPICS = [
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 sync for the repository\'s skills and hooks, or bravos setup for Bravos\'s own bundles, 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 start 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
+ { 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.'] },
135
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".'] },
136
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).'] },
137
137
  ],
@@ -145,7 +145,7 @@ export const GUIDE_TOPICS = [
145
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.'] },
146
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.'] },
147
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.'] },
148
- { name: 'bravos-ship', body: ['The pre-PR gate. Optional PreToolUse hook (bravos init --pre-pr-hook) runs it on every gh pr create / gh pr ready.'] },
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.'] },
149
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.'] },
150
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.'] },
151
151
  { name: 'bravos-prove', body: ['Runs the authorized test, reads cxg\'s report and exit code, writes outcomes only through guardlink\'s hypothesis ledger.'] },
@@ -194,8 +194,8 @@ export const GUIDE_TOPICS = [
194
194
  { name: 'Antigravity (agy)', body: ['Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group that injects the briefing.'] },
195
195
  { name: 'Cursor', body: ['.cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.'] },
196
196
  { name: 'VS Code (Copilot agent)', body: ['Reads hooks from .claude/settings.json (preview), so the briefing can load there too.'] },
197
- { name: 'Every repo, or one copy of each skill', body: ['bravos init --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 sync --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 start, then neutral. bravos doctor shows which, and the c key in bravos watch switches.'] },
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.'] },
199
199
  ],
200
200
  },
201
201
  ];
package/dist/help.js CHANGED
@@ -138,14 +138,14 @@ Design rules
138
138
 
139
139
  Commits
140
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 start asks it too).
141
+ bravos prefs set commits commit|leave|ask --by "<your name>" (bravos setup asks it too).
142
142
  The answer is kept under this clone's git directory, never committed; your own code is
143
143
  never part of such a commit. bravos prefs get shows it.
144
144
 
145
145
  Upkeep
146
146
  After you update bravos, each repository's copies of the skills and hooks are behind it,
147
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 sync or bravos setup itself.
148
+ agent's session briefing reads it and the agent runs bravos setup itself.
149
149
  When the repository is the newer side, it tells you to update bravos and syncs nothing.
150
150
  BRAVOS_UPKEEP_PROBE=off stops the check.
151
151
 
@@ -171,7 +171,7 @@ Session start
171
171
  the briefing still reaches the model. The banner uses bravos's brand colours (truecolor);
172
172
  NO_COLOR or BRAVOS_BANNER_COLOR=off prints it plain. Colours follow the terminal's
173
173
  background: BRAVOS_THEME=light|dark|neutral, else COLORFGBG, else the choice saved by
174
- bravos start, else neutral (readable on light and dark); bravos doctor says which.
174
+ bravos setup, else neutral (readable on light and dark); bravos doctor says which.
175
175
  Codex lists a hook message as a
176
176
  warning, so there it is a two-line summary instead of the art. Since 0.5.0 the hook is registered with
177
177
  --harness claude or --harness codex so the banner prints /skill or $skill; sync migrates
@@ -184,7 +184,7 @@ Session start
184
184
  Antigravity (agy) reads .agents/hooks.json: bravos adds a 'bravos' SessionStart group
185
185
  there that hands the briefing to the model (it documents no way to show a banner).
186
186
 
187
- Autopilot (hands-off): bravos init --autopilot
187
+ Autopilot (hands-off): bravos setup --autopilot
188
188
  For teams who would rather not ask. At the end of every turn a check (a Stop hook in
189
189
  Claude Code and Codex, a few seconds) sends the agent back once when the turn's changes
190
190
  add or change source behavior or affect a claim due for testing. The check names
@@ -199,8 +199,8 @@ Autopilot (hands-off): bravos init --autopilot
199
199
 
200
200
  Harnesses
201
201
  Claude Code, Codex, Antigravity (agy), opencode and omp; --agent all installs for every
202
- one. bravos init --global installs for your user (skills in ~/.claude/skills, a user hook
203
- that briefs repos with a threat model but no bravos). bravos sync --link-skills keeps one
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
204
204
  copy of each skill when a tool reads both .claude/skills and .agents/skills (Warp).
205
205
  bravos uninstall [--global] removes it again.
206
206
 
@@ -235,15 +235,22 @@ Rules every skill follows
235
235
  disposable loopback target. Never invents credentials. Never calls anything clean unless
236
236
  a gate exited 0.
237
237
 
238
- Typical first run
239
- bravos start # guided: licence, tools, repo, agents, PR checks,
240
- # schedule, testing permission; nothing changes until Apply
241
- Or by hand
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
242
246
  bravos doctor # what is installed, what is missing
243
- bravos init --dry-run # preview every write
244
- bravos init # install; then open a Claude Code or Codex session
245
- bravos sync --ci --pre-pr-hook # later: add CI and the pre-PR gate
246
- bravos sync --workflows nightly-claude --schedule weekly # a weekly nightly only
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.
247
254
  In Codex, run /hooks once to trust .codex/hooks.json.
248
255
 
249
256
  Exit codes
@@ -311,9 +318,9 @@ Flags in depth
311
318
  registered in ~/.claude/settings.json and ~/.codex/hooks.json, guardlink MCP in
312
319
  ~/.codex/config.toml. The user hook stays silent in a repo that has its own bravos
313
320
  hook or no .guardlink/, so it briefs only repos with a threat model and no bravos.
314
- Personal skills are not in git: bravos init in a repo is still how a team shares it.
321
+ Personal skills are not in git: bravos setup in a repo is still how a team shares it.
315
322
  Claude Code prefers personal skills over a repo's, so once a user-level install
316
- exists, bravos sync in any repo also brings it to the same version (it never creates
323
+ exists, bravos setup in any repo also brings it to the same version (it never creates
317
324
  one). BRAVOS_SYNC_GLOBAL=off keeps them separate and only warns.
318
325
  --force
319
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: `${LEGACY_HOOK_COMMAND} --harness claude`,
11
- agents: `${LEGACY_HOOK_COMMAND} --harness codex`,
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 command bravos registers as its opt-in PreToolUse pre-PR gate; doctor matches on the same constant."
14
- export const PRE_PR_COMMAND = 'node .bravos/hooks/pre-pr.mjs';
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 init --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."
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 = 'node .bravos/hooks/autopilot.mjs';
35
- const AUTOPILOT = {
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: AUTOPILOT_COMMAND,
38
- replaces: [OLD_HOOK_COMMANDS.autopilot],
39
- group: { hooks: [{ type: 'command', command: AUTOPILOT_COMMAND, timeout: 30 }] },
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 PRE_PR = {
65
+ const prePr = (h) => ({
43
66
  event: 'PreToolUse',
44
- command: PRE_PR_COMMAND,
45
- replaces: [OLD_HOOK_COMMANDS.prePr],
46
- group: { matcher: 'Bash', hooks: [{ type: 'command', command: PRE_PR_COMMAND, timeout: 180 }] },
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', [AUTOPILOT_COMMAND])),
149
- prePr: files.some((f) => hookRegistered(f, 'PreToolUse', [PRE_PR_COMMAND])),
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 ? [PRE_PR] : []),
187
- ...(withAutopilot ? [AUTOPILOT] : []),
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] }]),
@@ -47,6 +47,8 @@ export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
47
47
  }
48
48
  const work = mkdtempSync(join(tmpdir(), 'bravos-tools-'));
49
49
  function invoke(command, args, cwd, step) {
50
+ // Each step is said before it runs, so whoever is watching (the guided setup's spinner) knows what the wait is for.
51
+ echo(`${name}: ${step}${command === 'cargo' ? ' (cargo compiles it from source; this is the long step)' : ''}…`);
50
52
  const result = spawnSync(executables.get(command) ?? command, args, {
51
53
  cwd, env: installEnv, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 32 * 1024 * 1024, timeout: 30 * 60 * 1000,
52
54
  });
package/dist/mcp.js CHANGED
@@ -79,7 +79,8 @@ export function mergeMcpJson(root, servers, opts = {}) {
79
79
  const existing = (doc.mcpServers ?? {});
80
80
  const updated = names.filter((n) => Object.hasOwn(existing, n) && staleGraphEntry(n, existing[n], servers[n]));
81
81
  const kept = names.filter((n) => Object.hasOwn(existing, n) && !updated.includes(n));
82
- const added = names.filter((n) => !Object.hasOwn(existing, n));
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));
83
84
  if (added.length === 0 && updated.length === 0)
84
85
  return { path: rel, changed: false, added, kept };
85
86
  for (const n of [...added, ...updated])
@@ -127,7 +128,7 @@ export function mergeCodexConfig(root, servers, opts = {}) {
127
128
  }
128
129
  const updated = names.filter((n) => Object.hasOwn(tables, n) && staleGraphEntry(n, tables[n], servers[n]) && tomlTable(text, n));
129
130
  const kept = names.filter((n) => Object.hasOwn(tables, n) && !updated.includes(n));
130
- const added = names.filter((n) => !Object.hasOwn(tables, n));
131
+ const added = opts.onlyExisting ? [] : names.filter((n) => !Object.hasOwn(tables, n));
131
132
  if (added.length === 0 && updated.length === 0)
132
133
  return { path: rel, changed: false, added, kept };
133
134
  let base = text;
package/dist/palette.js CHANGED
@@ -39,7 +39,7 @@ export const bgFor = (role) => FIXED[role] ?? null;
39
39
  /* ------------------------------------------------------------------ choosing a theme */
40
40
  /** Where Bravos keeps its own settings: $BRAVOS_HOME, else ~/.bravos. */
41
41
  export const bravosHome = (env = process.env) => env.BRAVOS_HOME || join(env.HOME || homedir(), '.bravos');
42
- /** The theme saved by `bravos start` ($BRAVOS_HOME/config.json), or null. Never throws. */
42
+ /** The theme saved by `bravos setup` ($BRAVOS_HOME/config.json), or null. Never throws. */
43
43
  export function savedTheme(env = process.env) {
44
44
  try {
45
45
  const file = join(bravosHome(env), 'config.json');
@@ -95,6 +95,6 @@ export function resolveTheme(env = process.env, detected = null) {
95
95
  return { theme: fgbg, source: 'COLORFGBG' };
96
96
  const saved = savedTheme(env);
97
97
  if (saved)
98
- return { theme: saved, source: 'saved by bravos start' };
98
+ return { theme: saved, source: 'saved by bravos setup' };
99
99
  return { theme: 'neutral', source: 'default (background unknown)' };
100
100
  }
@@ -195,7 +195,7 @@ Then install the plugin for your agent:
195
195
  | Antigravity | \`agy plugin install ${REPOSITORY}\` |
196
196
  | Cursor (Teams and Enterprise) | Dashboard → Plugins → Import from Repo → \`${REPOSITORY}\` |
197
197
 
198
- You do not need a plugin: \`bravos init\` in a repository installs the same skills,
198
+ You do not need a plugin: \`bravos setup\` in a repository installs the same skills,
199
199
  hooks and MCP wiring for every agent it finds, and commits them with the code.
200
200
 
201
201
  ## Where data goes
@@ -215,7 +215,7 @@ reach only these places:
215
215
 
216
216
  Your licence and machine details go there; your code does not.
217
217
  - **GitHub:** the session briefing uses \`gh\`, if it is installed and signed in, to
218
- list open pull requests in your repository. The CI workflows \`bravos sync --ci\`
218
+ list open pull requests in your repository. The CI workflows \`bravos setup --ci\`
219
219
  writes run on GitHub Actions in your own repository.
220
220
  - **A test target you own:** \`bravos-prove\` and \`bravos-recheck\` send test
221
221
  requests through cxg. Loopback by default; any other host only with a reviewed
package/dist/plugin.js CHANGED
@@ -24,7 +24,7 @@ function walk(dir) {
24
24
  }
25
25
  return out;
26
26
  }
27
- // @comment -- "Every file of both plugin builds, computed and not written. plugin/ (Claude Code): skills rendered with ${CLAUDE_SKILL_DIR} and ${CLAUDE_PLUGIN_ROOT}, the hook scripts, a Claude hooks.json, .mcp.json and .claude-plugin/plugin.json. plugin-codex/ (Codex, Agent Plugins layout): skills rendered with repo-relative .agents/skills paths, the hook scripts, hooks/hooks.json in the shape .codex/hooks.json takes with the command under ${PLUGIN_ROOT}, mcp.json and a root plugin.json. Both register SessionStart only (the pre-PR gate stays opt-in through bravos init) and the guardlink MCP server only. Plus both marketplaces."
27
+ // @comment -- "Every file of both plugin builds, computed and not written. plugin/ (Claude Code): skills rendered with ${CLAUDE_SKILL_DIR} and ${CLAUDE_PLUGIN_ROOT}, the hook scripts, a Claude hooks.json, .mcp.json and .claude-plugin/plugin.json. plugin-codex/ (Codex, Agent Plugins layout): skills rendered with repo-relative .agents/skills paths, the hook scripts, hooks/hooks.json in the shape .codex/hooks.json takes with the command under ${PLUGIN_ROOT}, mcp.json and a root plugin.json. Both register SessionStart only (the pre-PR gate stays opt-in through bravos setup) and the guardlink MCP server only. Plus both marketplaces."
28
28
  export function pluginFiles(opts = {}) {
29
29
  const v = version();
30
30
  const files = [];
@@ -51,12 +51,12 @@ export function pluginFiles(opts = {}) {
51
51
  }],
52
52
  },
53
53
  }));
54
- // Codex substitutes ${PLUGIN_ROOT} in plugin hooks; the group is otherwise the one bravos init writes.
54
+ // Codex substitutes ${PLUGIN_ROOT} in plugin hooks; the group is otherwise the one bravos setup writes.
55
55
  const start = sessionStart('agents');
56
56
  const codexStart = { ...start.group, hooks: start.group.hooks.map((h) => ({ ...h, command: 'node "${PLUGIN_ROOT}/hooks/session-start.mjs" --harness codex' })) };
57
57
  add(`${CODEX_PLUGIN_DIR}/hooks/hooks.json`, json({ hooks: { [start.event]: [codexStart] } }));
58
58
  // guardlink only: cxg and codegraph-mcp are optional, and a server that fails to start on every
59
- // machine without its binary is noise. bravos init adds them per repo when they are installed.
59
+ // machine without its binary is noise. bravos setup adds them per repo when they are installed.
60
60
  const servers = { guardlink: SERVERS.guardlink };
61
61
  add(`${PLUGIN_DIR}/.mcp.json`, json({ mcpServers: servers }));
62
62
  add(`${CODEX_PLUGIN_DIR}/mcp.json`, json({
package/dist/prefs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // @comment -- "bravos prefs: a person's standing answers for one clone, read and written through hooks/lib/prefs.mjs so the CLI and the session hook agree on the file and its shape. `prefs get` prints what is recorded; `prefs set commits <commit|leave|ask> --by <name>` records what a named person said about committing Bravos's own files. The file is under the git directory, never in the working tree."
2
+ import { spawnSync } from 'node:child_process';
3
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
4
  import { pathToFileURL } from 'node:url';
3
- import { join } from 'node:path';
5
+ import { isAbsolute, join, resolve } from 'node:path';
4
6
  import { hooksDir } from './paths.js';
5
7
  import { BravosError } from './types.js';
6
8
  let cached;
@@ -45,3 +47,20 @@ export async function setCommits(root, value, by, env, now = new Date()) {
45
47
  }
46
48
  return [`commits: ${value} — from now on the agent will ${WHAT[value]}`, `recorded in ${file} (this clone only; never committed)`];
47
49
  }
50
+ // @comment -- "Leaves the hand-off marker after a first install, from the install pipeline itself (which is synchronous, so it cannot load the hook library): the same file and shape hooks/lib/prefs.mjs writeHandoff writes and readHandoff reads, under the clone's git directory. It is what makes the next agent session begin the context step by itself, whichever way Bravos was installed: the guided setup, flags from a script, or the website's setup skill. Returns whether it was written; a folder that is not a git repository, or git not answering, only means the person types the first command."
51
+ // @mitigates #person-prefs against #governance-forgery using #prefs-outside-tree -- "The marker is written under the git directory, where no commit, clone or pull can put one."
52
+ export function leaveHandoff(root, env, at = new Date().toISOString()) {
53
+ try {
54
+ const r = spawnSync('git', ['rev-parse', '--git-common-dir'], { cwd: root, env, encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
55
+ const printed = r.status === 0 ? String(r.stdout ?? '').trim() : '';
56
+ if (!printed)
57
+ return false;
58
+ const dir = join(isAbsolute(printed) ? printed : resolve(root, printed), 'bravos');
59
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
60
+ writeFileSync(join(dir, 'handoff.json'), JSON.stringify({ schema: 'bravos.handoff/v1', at }) + '\n', { mode: 0o600 });
61
+ return true;
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
@@ -0,0 +1,37 @@
1
+ // @comment -- "bravos setup is the one command for setting Bravos up: this decides, from the flags a person actually typed and whether there is a terminal, which of its jobs to do. It is a pure function so the whole table can be tested. First match wins: a read-only check; a refusal when machine and repository flags are mixed; the machine part (bundles, tools); the user-level install; the repository part by flags; an unattended first setup; the guided wizard; and otherwise safe upkeep, which is what an agent or a script with no terminal gets. The two meanings -y had on two commands are kept apart here: with a machine flag it means 'run the installers', alone it means 'no questions, take the defaults', and that second route never runs third-party installers."
2
+ /** Flags that say "set up this machine": Bravos's own bundles and the third-party tools. */
3
+ export const MACHINE_FLAGS = ['tools', 'analyzer', 'codegraph'];
4
+ /** Flags that only mean something for a repository, so giving one says "set up (or re-apply to) this repository". */
5
+ export const REPOSITORY_FLAGS = ['agent', 'autopilot', 'prePrHook', 'ci', 'workflows', 'schedule', 'scope', 'linkSkills', 'force', 'guardlinkMode', 'guardlinkInit'];
6
+ // @comment -- "`given` holds the option names typed on the command line (commander's value source 'cli'), never defaults: --no-guardlink-init defaults to true, so truthiness would read it as given every time."
7
+ export function setupRoute(given, tty) {
8
+ const has = (k) => given.has(k);
9
+ const machine = MACHINE_FLAGS.some(has);
10
+ const repository = REPOSITORY_FLAGS.some(has);
11
+ if (has('check'))
12
+ return 'check';
13
+ if (machine && (repository || has('global') || has('change') || has('preset')))
14
+ return 'conflict';
15
+ if (machine)
16
+ return 'machine';
17
+ if (has('global'))
18
+ return 'global';
19
+ if (repository)
20
+ return 'repository';
21
+ if (has('yes'))
22
+ return 'unattended';
23
+ if (has('change') || has('preset'))
24
+ return tty ? 'wizard' : 'needs-terminal';
25
+ // A dry run is a preview, never a wizard: it shows what upkeep would do.
26
+ if (tty && !has('dryRun'))
27
+ return 'wizard';
28
+ return 'upkeep';
29
+ }
30
+ // @comment -- "Whether a person is at a terminal. An agent's shell is not one even when it is given a pseudo-terminal: Claude Code sets CLAUDECODE, and CI sets CI. Tests pass `tty` directly, because a test runner has no terminal."
31
+ export function isTerminal(io, streams = process) {
32
+ if (typeof io.tty === 'boolean')
33
+ return io.tty;
34
+ if (io.env.CLAUDECODE || io.env.CI)
35
+ return false;
36
+ return !!streams.stdout?.isTTY && !!streams.stdin?.isTTY;
37
+ }
package/dist/setup.js CHANGED
@@ -67,7 +67,8 @@ export async function runSetup(env, opts, io) {
67
67
  // "already staged" would leave an existing install on the old one for good.
68
68
  const older = behindPin(env, kind);
69
69
  if (have && !opts.yes && !older) {
70
- lines.push(`${kind}: already staged at ${have} (add -y to fetch ${VERSIONS[kind]} again)`);
70
+ // The hint names the bundle: -y on its own is the unattended setup now, not a refetch.
71
+ lines.push(`${kind}: already staged at ${have} (bravos setup --${kind} -y fetches ${VERSIONS[kind]} again)`);
71
72
  continue;
72
73
  }
73
74
  if (opts.dryRun) {
@@ -153,7 +154,7 @@ export async function runSast(root, env, opts = {}) {
153
154
  const a = ['analyze', root, '--ci', '--fail-on', 'never', '--allow-incomplete-analysis', '--codegraph', graph, '--scip', opts.scip ?? 'off', '-f', 'json,sarif', '-o', join(runDir, 'report')];
154
155
  if (opts.scope?.length)
155
156
  a.push('--scope', opts.scope.join(','));
156
- // @comment -- ".bravos/ is always excluded: it holds the hooks bravos init copied into the repository and the SAST runs themselves, which are bravos's code, not the customer's, and would otherwise surface as findings 'not in the threat model'."
157
+ // @comment -- ".bravos/ is always excluded: it holds the hooks bravos setup copied into the repository and the SAST runs themselves, which are bravos's code, not the customer's, and would otherwise surface as findings 'not in the threat model'."
157
158
  a.push('--exclude', ['.bravos', ...(opts.exclude ?? []).filter((p) => p !== '.bravos')].join(','));
158
159
  if (opts.minSeverity)
159
160
  a.push('--min-severity', opts.minSeverity);
package/dist/skills.js CHANGED
@@ -100,7 +100,7 @@ export function renderPortableSkillFile(content, rel = 'SKILL.md') {
100
100
  }
101
101
  return out;
102
102
  }
103
- // @comment -- "User-level render (bravos init --global): bravos's own paths become absolute under the home folder (skills in ~/.claude/skills, hook scripts in ~/.bravos/hooks), while {{SKILLS_ROOT}} for guardlink's generated skills stays at the repo's .claude/skills."
103
+ // @comment -- "User-level render (bravos setup --global): bravos's own paths become absolute under the home folder (skills in ~/.claude/skills, hook scripts in ~/.bravos/hooks), while {{SKILLS_ROOT}} for guardlink's generated skills stays at the repo's .claude/skills."
104
104
  export function renderGlobalSkillFile(home) {
105
105
  return (content, _harness, name, rel = 'SKILL.md') => withMarker(content, rel)
106
106
  .split('{{SKILL_DIR}}')