@bugb-technologies/bravos 1.2.0 → 1.3.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 CHANGED
@@ -25,7 +25,7 @@ Or remove it (`pipx uninstall bravos` or `uv tool uninstall bravos`). `which -a
25
25
  ## Commands
26
26
 
27
27
  - `bravos start [dir]`: the guided first run described above. `--again`, `--yes`, `--preset annotate|pr|everything`.
28
- - `bravos init`: write skills, MCP wiring and the session-start hook into the current repo. `--agent claude,codex` picks the harnesses instead of detecting them. `--pre-pr-hook` also registers the PreToolUse gate on `gh pr create` / `gh pr ready` and lists it under `pre_pr` in `.guardlink/config.json`, so guardlink's agent block names it after `guardlink sync`; `--ci` also writes the GitHub Actions workflows (`--workflows pr-gate,nightly-claude,nightly-codex` picks which, `--schedule weekday|daily|weekly` sets how often the nightly runs; either implies `--ci`); `--scope` writes the loopback-only cxg scope starter to `.guardlink/scope.yaml` when no scope file exists (never overwritten). A repo with a `.cursor/` folder also gets `.cursor/rules/bravos.mdc`, a pointer to the skills.
28
+ - `bravos init`: write skills, MCP wiring and the session-start hook into the current repo. `--agent claude,codex` picks the harnesses instead of detecting them. `--pre-pr-hook` also registers the PreToolUse gate on `gh pr create` / `gh pr ready` and lists it under `pre_pr` in `.guardlink/config.json`, so guardlink's agent block names it after `guardlink sync`; `--ci` also writes the GitHub Actions workflows (`--workflows pr-gate,nightly-claude,nightly-codex` picks which, and `nightly-copilot` adds the GitHub Copilot nightly, which is never written unless named; `--schedule weekday|daily|weekly` sets how often the nightly runs; either implies `--ci`); `--scope` writes the loopback-only cxg scope starter to `.guardlink/scope.yaml` when no scope file exists (never overwritten). A repo with a `.cursor/` folder also gets `.cursor/rules/bravos.mdc`, a pointer to the skills.
29
29
  - `bravos sync`: refresh the installed skills and wiring to match this version of bravos; it also adds the cxg and codegraph MCP servers once they are installed (bravos's own committed MCP config carries guardlink only). The codegraph server is registered by its full path with the graph store as `BRAVOS_CODEGRAPH_DIR`, so the MCP tools read the graphs `bravos graph build` writes; after a `bravos setup` that stages a new bundle, `sync` refreshes that one entry, and keeps every other existing entry as it is.
30
30
  - `bravos setup`: puts the binaries bravos drives on this machine. The analyzer (`bravos-cli`, SAST) and the code graph (`codegraph-build`, `codegraph-mcp`) are signed bundles fetched through the account portal on the Team plan — the portal verifies the licence, the CLI verifies each file's Ed25519 signature before it unpacks, and nothing under `$BRAVOS_HOME` changes until every check has passed; `--tools -y` also installs guardlink (npm) and cxg (cargo). `--check` reports, `--dry-run` says what would happen.
31
31
  - `bravos graph`: `graph build [DIR]` indexes a repository (`--scip no-exec` by default, so no repository code runs); `graph <question> [args] --json` asks it — the same answers as the `codegraph_` MCP tools, through a one-call MCP session on stdio; `graph --json` lists every question this machine's binary answers.
@@ -45,6 +45,7 @@ Or remove it (`pipx uninstall bravos` or `uv tool uninstall bravos`). `which -a
45
45
  | `bravos-env` | Brings up a target the user owns: loopback by default, a reviewed `scope.yaml`, the human's typed authorization, a real session. |
46
46
  | `bravos-prove` | Runs the authorized test and writes outcomes back only through guardlink's hypothesis ledger. |
47
47
  | `bravos-recheck` | After a fix: re-verifies stale claims, replays retest kits, checks the fix added no exposure. |
48
+ | `bravos-resync` | When a checkout is far behind its base or a branch with annotations was left behind: carries the sidecars and definitions onto the base with `bravos resync`, maps duplicate ids, and re-reads every carried claim on code that changed since. |
48
49
  | `bravos-sast` | Licensed static analysis (bravos-cli: Semgrep, request-to-sink taint, dependency CVEs, secrets, IaC) joined to the threat model and the code graph; says plainly when it is unavailable. Its runs land in `.bravos/sast/` (not committed), and `bravos sast candidates` hands them on: reachable findings joined to a claim give bravos-templatize and bravos-prove the route to target, findings not in the threat model are leads for bravos-annotate, and bravos-recheck rescans after a fix. A static finding is a lead; only a run confirms. |
49
50
  | `bravos-schedule` | Recurring upkeep: an in-session `/loop`, the nightly workflow, or a cloud task you create. Never live tests. |
50
51
  | `bravos-cicd` | Audits and writes the security workflows; fixes broken guardlink calls and script-injection risks. |
@@ -188,6 +189,7 @@ With `--pre-pr-hook`, every `gh pr create` and `gh pr ready` an agent runs first
188
189
 
189
190
  - `bravos-pr-gate.yml`: the bravos-ship gate on every pull request, with the same rulings as the pre-PR hook (lint errors, undisclosed new exposure by id, a confirmed claim on a changed file without a `@ticket`; a gate input that fails is "unknown" and fails the job). guardlink and jq only, no model, no secret. Uploads guardlink's SARIF to code scanning (skipped for fork PRs).
190
191
  - `bravos-nightly-claude.yml` / `bravos-nightly-codex.yml`: a coding agent covers the next slice of unannotated files, the lint gate checks it, and the job opens one small PR. Keep the one for your harness. They annotate only: live testing needs a human's authorization typed in a session, which a scheduled job cannot give.
192
+ - `bravos-nightly-copilot.yml` + `copilot-setup-steps.yml` (only with `--workflows nightly-copilot`): for teams on GitHub Copilot. The scheduled job opens one issue and assigns it to Copilot's cloud agent, which annotates the next slice on the team's Copilot plan and opens the pull request; the PR gate checks it. Needs the repo secret `COPILOT_ASSIGN_TOKEN` (a Copilot user's personal access token: GitHub assigns Copilot only with a user's token) and `BRAVOS_LICENCE` as an Agents secret.
191
193
 
192
194
  ## Install as a plugin (after 1.0)
193
195
 
package/dist/ci.js CHANGED
@@ -8,7 +8,16 @@ export const CADENCES = ['weekday', 'daily', 'weekly'];
8
8
  // 03:17 UTC, off the hour so it does not land with everyone else's cron.
9
9
  export const CRON = { weekday: '17 3 * * 1-5', daily: '17 3 * * *', weekly: '17 3 * * 0' };
10
10
  /** The workflow files, by the name bravos init --workflows takes. */
11
- export const WORKFLOW_NAMES = ['pr-gate', 'nightly-claude', 'nightly-codex'];
11
+ export const WORKFLOW_NAMES = ['pr-gate', 'nightly-claude', 'nightly-codex', 'nightly-copilot'];
12
+ // @comment -- "The files each workflow name writes. The Copilot nightly also writes copilot-setup-steps.yml, the fixed file GitHub reads to prepare Copilot's session."
13
+ export const WORKFLOW_FILES = {
14
+ 'pr-gate': ['bravos-pr-gate.yml'],
15
+ 'nightly-claude': ['bravos-nightly-claude.yml'],
16
+ 'nightly-codex': ['bravos-nightly-codex.yml'],
17
+ 'nightly-copilot': ['bravos-nightly-copilot.yml', 'copilot-setup-steps.yml'],
18
+ };
19
+ // @comment -- "Workflows written only when named: a Copilot nightly fails every night without its token, so a plain --ci leaves it out, while sync keeps refreshing one that bravos already installed."
20
+ export const OPT_IN_WORKFLOWS = ['nightly-copilot'];
12
21
  /** The template with its schedule line set to the cadence; any other file is unchanged. */
13
22
  export function withCadence(content, cadence) {
14
23
  return content.replace(/^(\s*- cron: )'[^']*'/m, `$1'${CRON[cadence]}'`);
@@ -22,8 +31,11 @@ export function writeWorkflows(root, opts = {}) {
22
31
  return report;
23
32
  const lock = readLock(root);
24
33
  const record = {};
34
+ const installed = (w) => WORKFLOW_FILES[w].some((f) => lock.files[`.github/workflows/${f}`] !== undefined);
35
+ const wanted = opts.only ?? WORKFLOW_NAMES.filter((w) => !OPT_IN_WORKFLOWS.includes(w) || installed(w));
36
+ const files = new Set(wanted.flatMap((w) => WORKFLOW_FILES[w]));
25
37
  for (const name of readdirSync(src).filter((n) => n.endsWith('.yml')).sort()) {
26
- if (opts.only && !opts.only.some((w) => name === `bravos-${w}.yml`))
38
+ if (!files.has(name))
27
39
  continue;
28
40
  const path = `.github/workflows/${name}`;
29
41
  const abs = join(root, path);
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import { GUIDE_TOPIC_IDS, renderGuide, renderGuideMarkdown } from './guide.js';
19
19
  import { detectHarnesses } from './detect.js';
20
20
  import { formatDoctor, runDoctor, withLicence } from './doctor.js';
21
21
  import { ensureGuardlink, registerPrePr, whichBin, writeScope } from './guardlink.js';
22
- import { installHook } from './hooks.js';
22
+ import { installHook, installedOptIns } from './hooks.js';
23
23
  import { activate, importLicence } from './account.js';
24
24
  import { listDevices, logout, refresh as refreshDevice, revokeDevice } from './device.js';
25
25
  import * as graph from './codegraph.js';
@@ -33,7 +33,7 @@ import { readLock, sha256, writeLock } from './lock.js';
33
33
  import { mergeCodexConfig, mergeMcpJson, selectServers } from './mcp.js';
34
34
  import { hooksDir, skillsDir as bundledSkillsDir, version } from './paths.js';
35
35
  import { BravosError } from './types.js';
36
- // @comment -- "Parses --workflows pr-gate,nightly-claude,nightly-codex; anything else is a usage error"
36
+ // @comment -- "Parses --workflows pr-gate,nightly-claude,nightly-codex,nightly-copilot; anything else is a usage error"
37
37
  function parseWorkflows(value) {
38
38
  const out = [];
39
39
  for (const raw of value.split(',').map((x) => x.trim()).filter(Boolean)) {
@@ -185,6 +185,15 @@ function pipeline(root, io, opts, withGuardlink, lines) {
185
185
  lines.push(`omp: skipped ${omp.path} — ${omp.reason}`);
186
186
  else if (omp.status !== 'absent')
187
187
  lines.push(`omp: ${omp.path} ${omp.status} (banner and briefing at session start)`);
188
+ // A hook the repo already registers stays registered: sync re-applies what is installed, so an
189
+ // opt-in is given once, not on every sync (removing one is bravos uninstall, or editing the settings).
190
+ const installed = installedOptIns(root);
191
+ const autopilotKept = !opts.autopilot && installed.autopilot;
192
+ const prePrKept = !opts.prePrHook && !opts.autopilot && installed.prePr && !installed.autopilot;
193
+ if (autopilotKept)
194
+ opts.autopilot = true;
195
+ if (prePrKept)
196
+ opts.prePrHook = true;
188
197
  // Autopilot is the pre-PR gate plus the end-of-turn check.
189
198
  if (opts.autopilot)
190
199
  opts.prePrHook = true;
@@ -255,7 +264,11 @@ function pipeline(root, io, opts, withGuardlink, lines) {
255
264
  const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
256
265
  const written = [...skills.written, ...skills.updated, ...mirror.written, ...mirror.updated, ...cursorWritten, ...ompWritten, ...ocWritten, ...workflowWritten, ...hook.copied, ...hook.registered.map((r) => r.file), ...guardlinkWritten];
257
266
  lines.push(...gitignoreWarnings(root, written, io.env));
258
- if (opts.autopilot) {
267
+ if (autopilotKept)
268
+ lines.push('autopilot: kept (already installed); BRAVOS_AUTOPILOT=off pauses the check.');
269
+ else if (prePrKept)
270
+ lines.push('pre-PR gate: kept (already installed).');
271
+ if (opts.autopilot && !autopilotKept) {
259
272
  lines.push('autopilot on: an end-of-turn check (Stop hook) sends the agent back once when changed code lacks annotations, sits under a confirmed or stale claim, or adds exposures; the pre-PR gate checks every gh pr create / gh pr ready.');
260
273
  lines.push('autopilot: the first time proving comes up, the agent asks you once how you want it handled and records your answer in .guardlink/proving.md. BRAVOS_AUTOPILOT=off pauses the check.');
261
274
  }
@@ -706,6 +719,25 @@ export function buildProgram(io, result) {
706
719
  }
707
720
  lines.push('', s.next ? `Next: ${s.next.label} — ${s.next.how}` : 'Everything bravos can use here is on.', 'More: bravos guide · bravos guide roles · bravos guide tasks', 'Live view: bravos watch (in a second terminal pane)');
708
721
  }));
722
+ program
723
+ .command('resync [dir]')
724
+ .description('Carry GuardLink annotation work from another branch or commit onto this checkout (external mode sidecars and the definitions they need): a dry run unless --apply; then reanchors, validates and lists what to re-read. --list shows idle branches with annotation work the base lacks. Runs no model.')
725
+ .option('--from <ref>', 'the branch or commit whose annotation work to carry here')
726
+ .option('--apply', 'write the sidecars and definitions, then reanchor and validate')
727
+ .option('--list', 'show this checkout\'s staleness and the idle branches with annotation work not on the base')
728
+ .option('--json', 'print the report as JSON (bravos.resync/v1)')
729
+ .action((dir, opts) => guardedAsync(async (lines) => {
730
+ const root = dirArg(dir);
731
+ const r = await import('./resync.js');
732
+ if (opts.list) {
733
+ lines.push(...(await r.listStranded(root, io.env)));
734
+ return;
735
+ }
736
+ if (!opts.from)
737
+ throw new BravosError('bravos resync: name the work to carry with --from <branch or commit>, or use --list to find it');
738
+ const report = r.resync(root, opts.from, { apply: !!opts.apply, env: io.env });
739
+ lines.push(...(opts.json ? [JSON.stringify(report, null, 2)] : r.formatReport(report)));
740
+ }));
709
741
  program
710
742
  .command('watch [dir]')
711
743
  .description('A live, read-only view of the repository\'s security work for a second terminal pane beside any agent: setup, open and confirmed exposures, what to test next, stale claims, the code graph, SAST, teammates\' PRs and autopilot nudges. Redraws when files change. Runs no model.')
package/dist/doctor.js CHANGED
@@ -1,10 +1,10 @@
1
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readdirSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
3
  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 } from './hooks.js';
7
+ import { AUTOPILOT_COMMAND, HOOK_COMMANDS, LEGACY_HOOK_COMMAND, PRE_PR_COMMAND, hookRegistered } from './hooks.js';
8
8
  import { skillsRoot } from './skills.js';
9
9
  import { resolveTheme } from './palette.js';
10
10
  const TOOLS = [
@@ -37,18 +37,6 @@ function guardlinkSkills(root, harness) {
37
37
  }
38
38
  }
39
39
  // @comment -- "True when a harness settings file registers one of bravos's commands under the given hook event (the per-harness SessionStart command or its pre-0.5.0 form); unreadable or malformed files read as not registered."
40
- function hookRegistered(file, event, commands) {
41
- try {
42
- const json = JSON.parse(readFileSync(file, 'utf8'));
43
- const groups = json?.hooks?.[event];
44
- if (!Array.isArray(groups))
45
- return false;
46
- return groups.some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => typeof h?.command === 'string' && commands.includes(h.command)));
47
- }
48
- catch {
49
- return false;
50
- }
51
- }
52
40
  /** Read-only environment check: PATH lookups and file reads only. */
53
41
  // @comment -- "Read-only environment check: looks up guardlink, cxg, codegraph-mcp and bravos-cli on PATH, the optional licence, guardlink initialisation, installed bravos and guardlink playbook skills per root, and hook registration; runs nothing."
54
42
  export function runDoctor(root, env = process.env) {
package/dist/guide.js CHANGED
@@ -118,6 +118,7 @@ export const GUIDE_TOPICS = [
118
118
  { 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.'] },
119
119
  { 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.'] },
120
120
  { 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.'] },
121
+ { 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.'] },
121
122
  { 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.'] },
122
123
  { 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.'] },
123
124
  { 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.'] },
@@ -132,7 +133,7 @@ export const GUIDE_TOPICS = [
132
133
  {
133
134
  id: 'skills',
134
135
  title: 'Every skill',
135
- summary: 'all fourteen skills, what each does and leaves for the next',
136
+ summary: 'all fifteen skills, what each does and leaves for the next',
136
137
  items: [
137
138
  { name: 'bravos', body: ['Front door: reads the security picture, explains the evidence loop, routes to the right skill.'] },
138
139
  { name: 'bravos-context', body: ['Learns what the product intends from the repo and a short interview; records invariants, intended behaviour, actors, assets and boundaries.'] },
@@ -143,6 +144,7 @@ export const GUIDE_TOPICS = [
143
144
  { 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.'] },
144
145
  { name: 'bravos-prove', body: ['Runs the authorized test, reads cxg\'s report and exit code, writes outcomes only through guardlink\'s hypothesis ledger.'] },
145
146
  { name: 'bravos-recheck', body: ['After a fix: stale claims, retest-kit replay, no new exposure, what to test next.'] },
147
+ { name: 'bravos-resync', body: ['A stale checkout or a left-behind branch: carries its annotation work onto the base with bravos resync, maps duplicate ids, re-reads every carried claim on changed code.'] },
146
148
  { name: 'bravos-sast', body: ['Licensed static analysis joined to guardlink claims and reachability; gates on findings new since the base.'] },
147
149
  { name: 'bravos-campaign', body: ['A goal over many rounds: disjoint batches, one subagent each, a gate per batch, rests, a final before-and-after.'] },
148
150
  { name: 'bravos-schedule', body: ['Recurring upkeep with each harness\'s own mechanism; never live tests from a loop.'] },
package/dist/help.js CHANGED
@@ -11,9 +11,11 @@ What bravos is
11
11
  Commands
12
12
  init [dir] First install in a repository. Runs guardlink init if .guardlink/ is absent.
13
13
  sync [dir] Re-apply bravos to a repository that already has it (after upgrading bravos,
14
- or to add --ci / --pre-pr-hook / --scope / --autopilot later). Never runs
15
- guardlink init. init and sync take --global for a user-level install.
14
+ or to add --ci / --pre-pr-hook / --scope / --autopilot later; hooks already
15
+ installed stay installed). Never runs guardlink init. init and sync take --global for a user-level install.
16
16
  doctor [dir] Read-only check of tools, licence, installed skills and hooks.
17
+ resync [dir] Carry annotation work from another branch onto this checkout: --from <ref>
18
+ (a dry run; --apply writes, reanchors and validates), or --list to find it.
17
19
  uninstall [dir]
18
20
  Remove bravos from a repository (--global: from your user), keeping
19
21
  anything you edited unless --force; --dry-run lists it first.
@@ -87,6 +89,8 @@ The skills it installs (one folder each in .claude/skills/ and .agents/skills/)
87
89
  bravos-prove Runs the authorized test, reads cxg's verdicts, writes outcomes back
88
90
  only through guardlink's hypothesis ledger.
89
91
  bravos-recheck After a fix: re-verifies stale claims, replays retest kits.
92
+ bravos-resync Carries annotation work a stale or abandoned branch holds onto the base,
93
+ then re-reads every carried claim on code that changed since.
90
94
  bravos-sast Licensed static analysis; says plainly when it is unavailable.
91
95
  bravos-schedule /loop while you work, the nightly workflow, or a cloud task you create.
92
96
  bravos-cicd Writes and audits the security GitHub Actions workflows.
@@ -285,9 +289,18 @@ Flags in depth
285
289
  scope's host_allowlist; optional vars.BRAVOS_SCAN_AUTH +
286
290
  secrets.BRAVOS_AUTH_STATE import a login. Otherwise it
287
291
  skips with a notice.
288
- Needs repository secret ANTHROPIC_API_KEY or OPENAI_API_KEY, and Settings > Actions >
292
+ Needs repository secret CLAUDE_CODE_OAUTH_TOKEN (Claude Code on your Claude plan; run
293
+ 'claude setup-token' once) or OPENAI_API_KEY (Codex), and Settings > Actions >
289
294
  "Allow GitHub Actions to create and approve pull requests". Workflows you wrote or
290
295
  edited are skipped unless --force.
296
+ Only when named (--workflows nightly-copilot), for teams on GitHub Copilot:
297
+ bravos-nightly-copilot.yml On the schedule, opens one issue asking Copilot's cloud
298
+ agent to annotate the next slice and assigns it to
299
+ Copilot, which opens the PR on your Copilot plan. Needs
300
+ repository secret COPILOT_ASSIGN_TOKEN (a Copilot user's
301
+ personal access token) and BRAVOS_LICENCE as an Agents
302
+ secret. Skips while an earlier one is open.
303
+ copilot-setup-steps.yml Node and guardlink in Copilot's session.
291
304
  --pre-pr-hook
292
305
  Registers the pre-PR gate as a PreToolUse hook on Bash for 'gh pr create' and
293
306
  'gh pr ready' in .claude/settings.json and .codex/hooks.json, and lists
package/dist/hooks.js CHANGED
@@ -111,6 +111,27 @@ function planRegistration(root, rel, regs) {
111
111
  return { file: rel, changed, doc };
112
112
  }
113
113
  // @comment -- "The command Antigravity runs from .agents/hooks.json; --harness agy makes the hook print Antigravity's injectSteps."
114
+ // @comment -- "True when a harness settings file registers one of the given commands under the event; read-only, an unreadable or malformed file reads as not registered. Doctor and sync share it."
115
+ export function hookRegistered(file, event, commands) {
116
+ try {
117
+ const json = JSON.parse(readFileSync(file, 'utf8'));
118
+ const groups = json?.hooks?.[event];
119
+ if (!Array.isArray(groups))
120
+ return false;
121
+ return groups.some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => typeof h?.command === 'string' && commands.includes(h.command)));
122
+ }
123
+ catch {
124
+ return false;
125
+ }
126
+ }
127
+ // @comment -- "Which opt-in hooks a repository already registers for Claude Code or Codex, so sync re-applies them without the flag being given again."
128
+ export function installedOptIns(root) {
129
+ const files = [join(root, '.claude', 'settings.json'), join(root, '.codex', 'hooks.json')];
130
+ return {
131
+ autopilot: files.some((f) => hookRegistered(f, 'Stop', [AUTOPILOT_COMMAND])),
132
+ prePr: files.some((f) => hookRegistered(f, 'PreToolUse', [PRE_PR_COMMAND])),
133
+ };
134
+ }
114
135
  export const AGY_HOOK_COMMAND = `${LEGACY_HOOK_COMMAND} --harness agy`;
115
136
  export const AGY_HOOKS_FILE = '.agents/hooks.json';
116
137
  const AGY_GROUP = { SessionStart: [{ type: 'command', command: AGY_HOOK_COMMAND, timeout: 30 }] };
package/dist/resync.js ADDED
@@ -0,0 +1,272 @@
1
+ // @comment -- "bravos resync: carries GuardLink annotation work from another branch or commit (sidecars, external mode) onto this checkout, mechanically and with no model: copies the sidecars whose source file still exists and that this checkout lacks, appends the definitions they reference and this checkout does not define (flagging ones that look like an existing id under another name), then with --apply reanchors and validates, and reports what moved, what lost its symbol and which files changed since the claims were written. A dry run unless --apply; never merges two sidecars, never deletes, never touches the source branch. Inline mode copies nothing and points at merge or cherry-pick. --list prints local branches carrying annotation work their base lacks."
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { dirname, join } from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { hooksDir } from './paths.js';
7
+ import { BravosError } from './types.js';
8
+ export const SIDECAR_DIR = '.guardlink/annotations/';
9
+ export const RESYNC_RECORD = '.bravos/resync/last.json';
10
+ // @comment -- "Read-only git over argv (no shell): stdout, or null on any failure or non-zero exit. Output is capped generously because ls-tree and show of a large definitions file can be big."
11
+ function gitIn(root, env) {
12
+ return (args) => {
13
+ const r = spawnSync('git', args, { cwd: root, env, encoding: 'utf8', timeout: 30000, maxBuffer: 256 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] });
14
+ return r.error || r.status !== 0 ? null : r.stdout;
15
+ };
16
+ }
17
+ // @comment -- "Runs guardlink over argv with a long timeout and returns its exit status and combined output; a missing guardlink reads as status null, which the report states rather than failing."
18
+ function guardlink(root, env, args) {
19
+ const r = spawnSync('guardlink', args, { cwd: root, env, encoding: 'utf8', timeout: 300000, maxBuffer: 256 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
20
+ if (r.error)
21
+ return { status: null, out: '' };
22
+ return { status: r.status, out: `${r.stdout ?? ''}\n${r.stderr ?? ''}` };
23
+ }
24
+ // @comment -- "Option-injection guard: --from reaches git as an argument, so a value beginning with '-' (e.g. --output=…) is refused before any git call, and the ref must resolve to a commit."
25
+ export function assertRef(ref) {
26
+ if (typeof ref !== 'string' || ref.length === 0 || ref.startsWith('-') || /[\0\n]/.test(ref)) {
27
+ throw new BravosError(`bravos resync: --from needs a branch or commit name (got "${ref}")`);
28
+ }
29
+ }
30
+ /** Definitions declared on lines of a definitions file: `@asset Name (#id)`, `@threat …`, `@control …`, `@actor …`. */
31
+ // @comment -- "Pure parser for one-line GuardLink declarations (@asset, @threat, @control, @actor with a (#id)), keeping the raw line so it can be carried verbatim; the CWE is read from a cwe:CWE-n token when present."
32
+ export function parseDefinitions(text) {
33
+ const out = [];
34
+ for (const line of text.split('\n')) {
35
+ const m = /@(asset|threat|control|actor)\s+(\S+)\s*\(#([A-Za-z0-9][\w.-]*)\)/.exec(line);
36
+ if (!m)
37
+ continue;
38
+ const cwe = /cwe:(CWE-\d+)/i.exec(line);
39
+ out.push({ kind: m[1], name: m[2], id: m[3], cwe: cwe ? cwe[1].toUpperCase() : null, line: line.trimEnd() });
40
+ }
41
+ return out;
42
+ }
43
+ /** The #ids a sidecar's annotation lines reference, outside their quoted descriptions. */
44
+ // @comment -- "Pure extractor: for each @ line other than @source and @comment, the #ids before its ` -- \"` description, so a # inside prose is never mistaken for a reference; a parenthesised (#id), which names the annotation itself, is skipped."
45
+ export function referencedIds(sidecar) {
46
+ const ids = new Set();
47
+ for (const raw of sidecar.split('\n')) {
48
+ const line = raw.trim();
49
+ if (!line.startsWith('@') || line.startsWith('@source') || line.startsWith('@comment'))
50
+ continue;
51
+ // A parenthesised (#id) names the annotation itself (a @boundary's own id): a declaration, not a reference.
52
+ const head = line.split(' -- "')[0].replace(/\(#[A-Za-z0-9][\w.-]*\)/g, '');
53
+ for (const m of head.matchAll(/#([A-Za-z0-9][\w.-]*)/g))
54
+ ids.add(m[1]);
55
+ }
56
+ return ids;
57
+ }
58
+ const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, '');
59
+ /** Existing definitions that look like the same thing as `d`: same kind, and the same CWE or the same normalized name. */
60
+ // @comment -- "Pure duplicate heuristic for a carried definition: an existing one of the same kind with the same CWE, or whose name or id normalizes the same; only ever a suggestion for a person or agent to map."
61
+ export function duplicatesOf(d, existing) {
62
+ return existing
63
+ .filter((e) => e.kind === d.kind && e.id !== d.id && ((d.cwe && e.cwe === d.cwe) || norm(e.name) === norm(d.name) || norm(e.id) === norm(d.id)))
64
+ .map((e) => e.id);
65
+ }
66
+ function readConfig(root) {
67
+ try {
68
+ const c = JSON.parse(readFileSync(join(root, '.guardlink', 'config.json'), 'utf8'));
69
+ return { mode: c?.annotation_mode === 'external' ? 'external' : 'inline', definitions: typeof c?.definitions === 'string' ? c.definitions : 'definitions.ts' };
70
+ }
71
+ catch {
72
+ return { mode: 'inline', definitions: 'definitions.ts' };
73
+ }
74
+ }
75
+ function coverage(root, env) {
76
+ const r = guardlink(root, env, ['ci', '-f', 'json']);
77
+ try {
78
+ const c = JSON.parse(r.out.slice(r.out.indexOf('{'), r.out.lastIndexOf('}') + 1))?.summary?.coverage;
79
+ return c ? { annotated_files: c.annotated_files, source_files: c.source_files, annotations: c.annotations } : null;
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ }
85
+ /** Sidecars `guardlink reanchor` reports by kind: { moved: [...], symbol_gone: [...] }. */
86
+ // @comment -- "Pure parser for guardlink reanchor's text report: each [kind] `sidecar` line, grouped by kind."
87
+ export function parseReanchor(out) {
88
+ const by = {};
89
+ for (const m of out.matchAll(/\[(moved|symbol_gone|line_gone|file_gone)\] `([^`]+)`/g))
90
+ (by[m[1]] ??= []).push(m[2]);
91
+ return by;
92
+ }
93
+ /**
94
+ * Plans (and with apply, performs) carrying annotation work from `from` onto the checkout at `root`.
95
+ */
96
+ // @comment -- "The resync pipeline: resolve the ref, classify its sidecars against this checkout, gather missing definitions and duplicate suggestions, then with apply write sidecars and a marked definitions block, reanchor, validate and measure coverage; the report is also saved to .bravos/resync/last.json (ignored scratch) for the bravos-resync skill. Writes only under .guardlink/ and .bravos/resync/, and only with apply."
97
+ export function resync(root, from, opts = {}) {
98
+ const env = opts.env ?? process.env;
99
+ assertRef(from);
100
+ const git = gitIn(root, env);
101
+ const sha = git(['rev-parse', '--verify', '--quiet', `${from}^{commit}`])?.trim();
102
+ if (!sha)
103
+ throw new BravosError(`bravos resync: ${from} is not a branch or commit in this repository`);
104
+ const head = git(['rev-parse', 'HEAD'])?.trim();
105
+ if (head === sha)
106
+ throw new BravosError(`bravos resync: ${from} is this checkout's own commit; check out the branch you want to carry the work onto first`);
107
+ const { mode, definitions } = readConfig(root);
108
+ const commitsNotHere = Number(git(['rev-list', '--count', `HEAD..${sha}`])?.trim() ?? 0);
109
+ const report = {
110
+ schema: 'bravos.resync/v1', from, sha, mode, applied: false,
111
+ copied: [], both: [], same: 0, sourceGone: [],
112
+ definitionsCarried: [], definitionsMissing: [], possibleDuplicates: [], changedSince: [],
113
+ reanchored: null, symbolGone: [], validate: null, coverage: { before: null, after: null },
114
+ commitsNotHere, note: null,
115
+ };
116
+ if (mode === 'inline') {
117
+ report.note = `inline mode: annotations live in source comments, so they travel with code. Bring the ${commitsNotHere} commit(s) on ${from} over with git merge or git cherry-pick, then run guardlink validate and bravos-resync's re-read step.`;
118
+ return save(root, report, false);
119
+ }
120
+ const listed = (git(['ls-tree', '-r', '--name-only', sha, '--', SIDECAR_DIR]) ?? '').split('\n').filter((f) => f.endsWith('.gal'));
121
+ const carried = new Map();
122
+ for (const f of listed) {
123
+ const src = f.slice(SIDECAR_DIR.length, -'.gal'.length);
124
+ if (!existsSync(join(root, src))) {
125
+ report.sourceGone.push(src);
126
+ continue;
127
+ }
128
+ const theirs = git(['show', `${sha}:${f}`]);
129
+ if (theirs === null)
130
+ continue;
131
+ if (existsSync(join(root, f))) {
132
+ if (readFileSync(join(root, f), 'utf8') === theirs)
133
+ report.same++;
134
+ else
135
+ report.both.push(f);
136
+ continue;
137
+ }
138
+ carried.set(f, theirs);
139
+ report.copied.push(f);
140
+ // Changed since: the source file here differs from the one the claims were written against.
141
+ const diff = spawnSync('git', ['diff', '--quiet', sha, '--', src], { cwd: root, env, stdio: 'ignore', timeout: 30000 });
142
+ if (diff.status === 1)
143
+ report.changedSince.push(src);
144
+ }
145
+ const defsRel = join('.guardlink', definitions);
146
+ const ours = existsSync(join(root, defsRel)) ? parseDefinitions(readFileSync(join(root, defsRel), 'utf8')) : [];
147
+ const theirsDefs = parseDefinitions(git(['show', `${sha}:${defsRel}`]) ?? '');
148
+ const known = new Set(ours.map((d) => d.id));
149
+ const needed = new Set();
150
+ for (const text of carried.values())
151
+ for (const id of referencedIds(text))
152
+ if (!known.has(id))
153
+ needed.add(id);
154
+ const carriedDefs = [];
155
+ for (const id of [...needed].sort()) {
156
+ const d = theirsDefs.find((x) => x.id === id);
157
+ if (!d) {
158
+ report.definitionsMissing.push(id);
159
+ continue;
160
+ }
161
+ carriedDefs.push(d);
162
+ report.definitionsCarried.push(id);
163
+ const dup = duplicatesOf(d, ours);
164
+ if (dup.length)
165
+ report.possibleDuplicates.push({ id, kind: d.kind, candidates: dup });
166
+ }
167
+ if (!opts.apply)
168
+ return save(root, report, false);
169
+ report.coverage.before = coverage(root, env);
170
+ const before = parseReanchor(guardlink(root, env, ['reanchor', '.']).out);
171
+ for (const [f, text] of carried) {
172
+ mkdirSync(dirname(join(root, f)), { recursive: true });
173
+ writeFileSync(join(root, f), text);
174
+ }
175
+ if (carriedDefs.length) {
176
+ const block = ['', `// ─── carried from ${from}@${sha.slice(0, 12)} by bravos resync (map possible duplicates, then drop them here) ───`, ...carriedDefs.map((d) => d.line), ''].join('\n');
177
+ const path = join(root, defsRel);
178
+ const existing = existsSync(path) ? readFileSync(path, 'utf8') : '';
179
+ writeFileSync(path, existing.replace(/\n*$/, '\n') + block);
180
+ }
181
+ const moved = parseReanchor(guardlink(root, env, ['reanchor', '.']).out).moved ?? [];
182
+ const apply = guardlink(root, env, ['reanchor', '.', '--apply']);
183
+ if (apply.status !== null) {
184
+ const copiedSet = new Set(report.copied);
185
+ const existingMoved = new Set(before.moved ?? []);
186
+ report.reanchored = { carried: moved.filter((f) => copiedSet.has(f)).length, existing: moved.filter((f) => existingMoved.has(f)).length };
187
+ report.symbolGone = [...new Set(parseReanchor(guardlink(root, env, ['reanchor', '.']).out).symbol_gone ?? [])].filter((f) => copiedSet.has(f));
188
+ const v = guardlink(root, env, ['validate', '.']);
189
+ const counts = /(\d+) error\(s\), (\d+) warning\(s\)/.exec(v.out);
190
+ report.validate = counts ? { errors: Number(counts[1]), warnings: Number(counts[2]) } : null;
191
+ report.coverage.after = coverage(root, env);
192
+ }
193
+ else {
194
+ report.note = 'guardlink not found on PATH: sidecars and definitions were written, but nothing was reanchored or validated; install guardlink and run guardlink reanchor . --apply';
195
+ }
196
+ report.applied = true;
197
+ return save(root, report, true);
198
+ }
199
+ // @comment -- "Saves the report to .bravos/resync/last.json, with a .gitignore of * beside it so the scratch never reaches git; a failure to save never fails the resync."
200
+ function save(root, report, _applied) {
201
+ try {
202
+ const dir = join(root, dirname(RESYNC_RECORD));
203
+ mkdirSync(dir, { recursive: true });
204
+ if (!existsSync(join(dir, '.gitignore')))
205
+ writeFileSync(join(dir, '.gitignore'), '*\n');
206
+ writeFileSync(join(root, RESYNC_RECORD), JSON.stringify(report, null, 2) + '\n');
207
+ }
208
+ catch {
209
+ /* the record is a convenience for the skill */
210
+ }
211
+ return report;
212
+ }
213
+ /** Report lines for a person. */
214
+ // @comment -- "Formats a ResyncReport as plain lines: what would be (or was) carried, what needs a person, and the next step."
215
+ export function formatReport(r) {
216
+ const verb = r.applied ? 'carried' : 'would carry';
217
+ const lines = [`bravos resync from ${r.from} (${r.sha.slice(0, 12)}), ${r.mode} mode${r.applied ? '' : ' — dry run, nothing written'}`];
218
+ if (r.note)
219
+ lines.push(r.note);
220
+ if (r.mode === 'inline')
221
+ return lines;
222
+ lines.push(`Sidecars: ${verb} ${r.copied.length} · already here ${r.same} · both have differing sidecars ${r.both.length} · source file gone ${r.sourceGone.length}`);
223
+ lines.push(`Definitions: ${verb} ${r.definitionsCarried.length}${r.definitionsMissing.length ? ` · referenced but defined nowhere ${r.definitionsMissing.length} (${r.definitionsMissing.slice(0, 5).join(', ')})` : ''}`);
224
+ if (r.possibleDuplicates.length) {
225
+ lines.push(`Possible duplicates to map onto this checkout's ids (${r.possibleDuplicates.length}):`);
226
+ for (const d of r.possibleDuplicates.slice(0, 10))
227
+ lines.push(` #${d.id} (${d.kind}) ~ ${d.candidates.map((c) => `#${c}`).join(', ')}`);
228
+ if (r.possibleDuplicates.length > 10)
229
+ lines.push(` … and ${r.possibleDuplicates.length - 10} more (in ${RESYNC_RECORD})`);
230
+ }
231
+ lines.push(`Changed since the claims were written: ${r.changedSince.length} file(s); re-read their annotations against today's code`);
232
+ if (r.both.length)
233
+ lines.push(`Both sides annotate ${r.both.length} file(s); not merged: ${r.both.slice(0, 3).join(', ')}${r.both.length > 3 ? ' …' : ''}`);
234
+ if (r.applied) {
235
+ if (r.reanchored)
236
+ lines.push(`Reanchored: ${r.reanchored.carried} carried sidecar(s), plus ${r.reanchored.existing} that had already drifted here`);
237
+ if (r.symbolGone.length)
238
+ lines.push(`Symbol gone (rewrite or drop): ${r.symbolGone.length} — ${r.symbolGone.slice(0, 3).join(', ')}${r.symbolGone.length > 3 ? ' …' : ''}`);
239
+ if (r.validate)
240
+ lines.push(`guardlink validate: ${r.validate.errors} error(s), ${r.validate.warnings} warning(s)`);
241
+ const c = (x) => (x ? `${x.annotated_files}/${x.source_files} files, ${x.annotations} annotations` : 'unknown');
242
+ lines.push(`Coverage: ${c(r.coverage.before)} → ${c(r.coverage.after)}`);
243
+ lines.push('Next: bravos-resync maps the duplicates, re-reads the changed files and drops what lost its code; nothing here is verified.');
244
+ }
245
+ else {
246
+ lines.push(`Next: bravos resync --from ${r.from} --apply`);
247
+ }
248
+ lines.push(`Details: ${RESYNC_RECORD}`);
249
+ return lines;
250
+ }
251
+ /** Stranded annotation work and the checkout's own staleness, from the hooks' shared helper. */
252
+ // @comment -- "bravos resync --list: the checkout's staleness against its base and the idle local branches carrying .guardlink/ work the base lacks, using hooks/lib/resync.mjs (the same answer the session briefing gives)."
253
+ export async function listStranded(root, env = process.env) {
254
+ const lib = await import(pathToFileURL(join(hooksDir(), 'lib', 'resync.mjs')).href);
255
+ const g = gitIn(root, env);
256
+ const git = async (args) => g(args)?.trim() ?? null;
257
+ const base = (await git(['symbolic-ref', '-q', '--short', 'refs/remotes/origin/HEAD'])) || 'origin/main';
258
+ const branchRef = await git(['rev-parse', '--abbrev-ref', 'HEAD']);
259
+ const branch = branchRef && branchRef !== 'HEAD' ? branchRef : null;
260
+ const stale = lib.staleness({ ...(await lib.gitStaleness(git, base)), branch, base });
261
+ const stranded = await lib.strandedBranches(git, base, { current: branch });
262
+ const lines = [];
263
+ lines.push(stale ? lib.staleLine(stale, { branch, base }) : `This checkout${branch ? ` (${branch})` : ''} is current with ${base} (as of last fetch).`);
264
+ if (stranded.length === 0)
265
+ lines.push(`No idle local branch carries annotation work that ${base} lacks.`);
266
+ else {
267
+ lines.push(`Idle branches with annotation work not on ${base}:`);
268
+ for (const s of stranded)
269
+ lines.push(` ${s.branch}: ${s.files} .guardlink/ file(s) — bravos resync --from ${s.branch}`);
270
+ }
271
+ return lines;
272
+ }
@@ -26,10 +26,13 @@ export function initArgs(a) {
26
26
  return args;
27
27
  }
28
28
  /** The secrets and variables the nightly needs, by name. */
29
+ // @comment -- "The repository secrets a scheduled run needs: the Bravos licence, plus CLAUDE_CODE_OAUTH_TOKEN for Claude Code (from claude setup-token, so the run uses the person's Claude plan) or OPENAI_API_KEY for Codex, whose action takes no other sign-in. For Copilot only COPILOT_ASSIGN_TOKEN, a user's token that assigns the issue; the licence goes to the Agents secrets, which gh secret set does not reach"
29
30
  export function nightlySecrets(a) {
30
31
  if (a.schedule === 'none')
31
32
  return [];
32
- return ['BRAVOS_LICENCE', a.nightlyAgent === 'codex' ? 'OPENAI_API_KEY' : 'ANTHROPIC_API_KEY'];
33
+ if (a.nightlyAgent === 'copilot')
34
+ return ['COPILOT_ASSIGN_TOKEN'];
35
+ return ['BRAVOS_LICENCE', a.nightlyAgent === 'codex' ? 'OPENAI_API_KEY' : 'CLAUDE_CODE_OAUTH_TOKEN'];
33
36
  }
34
37
  // @comment -- "proving.md in the exact form the prove skill and the briefing read: choice, generation, the person's own words quoted, and confirmed by their name and the date. Setup records no target or start command: the agent finds how the app starts and where it listens (loopback only) when it tests, and writes them then."
35
38
  export function provingText(a, date) {
@@ -202,9 +202,9 @@ async function flow(opts, d) {
202
202
  s.schedule = 'none';
203
203
  return;
204
204
  }
205
- p.info('A scheduled run starts Claude Code or Codex inside GitHub Actions to annotate what changed, so it needs that tool\'s API key as a repository secret and spends its credits. The PR check needs no key.');
205
+ p.info('A scheduled run has an agent annotate what changed, on GitHub. Claude Code signs in there with your Claude plan and GitHub Copilot uses your Copilot plan, like a session would; Codex needs an OpenAI API key. The PR check uses no AI.');
206
206
  s.schedule = await p.select('schedule', 'Run Bravos on a schedule in GitHub Actions?', [
207
- { value: 'none', label: 'No schedule', hint: 'no API key needed' },
207
+ { value: 'none', label: 'No schedule', hint: 'no sign-in needed' },
208
208
  { value: 'weekly', label: 'Once a week', hint: 'Sunday night; the cheapest', recommended: true },
209
209
  { value: 'weekday', label: 'Every weekday night' },
210
210
  { value: 'daily', label: 'Every night' },
@@ -212,12 +212,14 @@ async function flow(opts, d) {
212
212
  },
213
213
  // which agent runs on the schedule
214
214
  async (s) => {
215
- if (s.schedule === 'none' || !(s.agents.includes('claude') && s.agents.includes('codex')))
215
+ if (s.schedule === 'none' || opts.yes)
216
216
  return;
217
+ const usual = s.nightlyAgent ?? 'claude';
217
218
  s.nightlyAgent = await p.select('nightly-agent', 'Which agent should the scheduled run use?', [
218
- { value: 'claude', label: 'Claude Code', hint: 'needs ANTHROPIC_API_KEY', recommended: true },
219
- { value: 'codex', label: 'Codex', hint: 'needs OPENAI_API_KEY' },
220
- ], s.nightlyAgent ?? saved?.nightlyAgent ?? 'claude');
219
+ { value: 'claude', label: 'Claude Code', hint: 'runs on your Claude plan', recommended: usual === 'claude' },
220
+ { value: 'copilot', label: 'GitHub Copilot', hint: 'runs on your Copilot plan; Copilot opens the pull request' },
221
+ { value: 'codex', label: 'Codex', hint: 'needs an OpenAI API key', recommended: usual === 'codex' },
222
+ ], saved?.nightlyAgent ?? usual);
221
223
  },
222
224
  // testing permission
223
225
  async (s) => {
@@ -268,8 +270,17 @@ async function flow(opts, d) {
268
270
  const gh = d.which('gh') && d.exec('gh', ['auth', 'status'], { cwd: s.repo }).code === 0;
269
271
  p.note([
270
272
  `The ${s.schedule} run needs these GitHub secrets: ${needed.join(', ')}.`,
271
- `${needed[1]} is what lets the agent run in GitHub Actions; each run spends credits on it (weekly costs about a fifth of weekday).`,
272
- 'Also: Settings → Actions → General → "Allow GitHub Actions to create and approve pull requests".',
273
+ ...(s.nightlyAgent === 'copilot'
274
+ ? [
275
+ 'COPILOT_ASSIGN_TOKEN is a personal access token of someone with Copilot: GitHub lets only a user assign Copilot. Fine-grained: read access to metadata, read and write access to actions, contents, issues and pull requests (classic: the repo scope). Each run uses that person\'s Copilot plan.',
276
+ 'Also: turn on Copilot cloud agent for this repository, and add BRAVOS_LICENCE under Settings → Secrets and variables → Agents. Copilot does not see ordinary Actions secrets.',
277
+ ]
278
+ : [
279
+ s.nightlyAgent === 'codex'
280
+ ? `${needed[1]} lets Codex run in GitHub Actions; each run spends credits on it (weekly uses about a fifth of weekday).`
281
+ : `${needed[1]} lets Claude Code run there on your Claude plan: run \`claude setup-token\` in a terminal and paste what it prints. Each run uses your plan like a session would (weekly uses about a fifth of weekday).`,
282
+ 'Also: Settings → Actions → General → "Allow GitHub Actions to create and approve pull requests".',
283
+ ]),
273
284
  ].join('\n'), 'Scheduled run');
274
285
  if (!gh) {
275
286
  p.info(`To add them later: gh secret set ${needed[0]} (or the repository's Settings → Secrets).`);
@@ -320,6 +331,7 @@ async function flow(opts, d) {
320
331
  ...(answers.pr === 'hook+github' ? [' + .github/workflows/bravos-pr-gate.yml'] : []),
321
332
  ...(answers.autopilot ? [' + autopilot'] : []),
322
333
  ...(answers.schedule !== 'none' ? [` + .github/workflows/bravos-nightly-${answers.nightlyAgent}.yml (${answers.schedule}, cron ${CRON[answers.schedule]} UTC)`] : []),
334
+ ...(answers.schedule !== 'none' && answers.nightlyAgent === 'copilot' ? [' + .github/workflows/copilot-setup-steps.yml (prepares Copilot\'s session: Node and guardlink)'] : []),
323
335
  ...(answers.proving !== 'none' ? [' + .guardlink/scope.yaml (localhost only; authorization left for you)'] : []),
324
336
  ...(answers.name ? [` + .guardlink/proving.md (${answers.proving}${answers.generation ? ', continuous pentest' : ''}, confirmed by ${answers.name})`] : []),
325
337
  ...(Object.keys(s.secrets).length ? [` + GitHub secrets: ${Object.keys(s.secrets).join(', ')}`] : []),