@bugb-technologies/bravos 1.2.0 → 1.2.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/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.
@@ -188,6 +188,7 @@ With `--pre-pr-hook`, every `gh pr create` and `gh pr ready` an agent runs first
188
188
 
189
189
  - `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
190
  - `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.
191
+ - `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
192
 
192
193
  ## Install as a plugin (after 1.0)
193
194
 
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
@@ -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)) {
package/dist/help.js CHANGED
@@ -285,9 +285,18 @@ Flags in depth
285
285
  scope's host_allowlist; optional vars.BRAVOS_SCAN_AUTH +
286
286
  secrets.BRAVOS_AUTH_STATE import a login. Otherwise it
287
287
  skips with a notice.
288
- Needs repository secret ANTHROPIC_API_KEY or OPENAI_API_KEY, and Settings > Actions >
288
+ Needs repository secret CLAUDE_CODE_OAUTH_TOKEN (Claude Code on your Claude plan; run
289
+ 'claude setup-token' once) or OPENAI_API_KEY (Codex), and Settings > Actions >
289
290
  "Allow GitHub Actions to create and approve pull requests". Workflows you wrote or
290
291
  edited are skipped unless --force.
292
+ Only when named (--workflows nightly-copilot), for teams on GitHub Copilot:
293
+ bravos-nightly-copilot.yml On the schedule, opens one issue asking Copilot's cloud
294
+ agent to annotate the next slice and assigns it to
295
+ Copilot, which opens the PR on your Copilot plan. Needs
296
+ repository secret COPILOT_ASSIGN_TOKEN (a Copilot user's
297
+ personal access token) and BRAVOS_LICENCE as an Agents
298
+ secret. Skips while an earlier one is open.
299
+ copilot-setup-steps.yml Node and guardlink in Copilot's session.
291
300
  --pre-pr-hook
292
301
  Registers the pre-PR gate as a PreToolUse hook on Bash for 'gh pr create' and
293
302
  'gh pr ready' in .claude/settings.json and .codex/hooks.json, and lists
@@ -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(', ')}`] : []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
5
5
  "keywords": [
6
6
  "security",
@@ -20,7 +20,7 @@ description: "Audit and write the repo's security CI: the bravos PR gate (valida
20
20
  4. Fix what the audit found in workflows bravos did not write: replace a broken guardlink call with the form above, and pass event text through `env:` and quote it in the shell. Show each change to the user before committing it.
21
21
  5. SAST in CI, only when the team has a bravos licence: add a step running `bravos-cli analyze . --ci --fail-on error -f sarif,json -o sast` with the licence from a repo secret, and upload `sast.sarif` under its own code-scanning category.
22
22
  6. Validate the workflows: run `actionlint` on them if it is installed; otherwise parse each as YAML. Fix every error.
23
- 7. Name the secrets and settings the user must add (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY` for the nightly job, the bravos licence for SAST, permission for Actions to create pull requests) without writing any value.
23
+ 7. Name the secrets and settings the user must add (`CLAUDE_CODE_OAUTH_TOKEN` for the Claude nightly, which runs on the user's Claude plan and comes from `claude setup-token`, or `OPENAI_API_KEY` for the Codex one, or for the Copilot nightly `COPILOT_ASSIGN_TOKEN` plus `BRAVOS_LICENCE` as an Agents secret; the bravos licence for SAST, permission for Actions to create pull requests) without writing any value.
24
24
  8. Ship the workflow changes as a pull request through bravos-ship.
25
25
 
26
26
  ## Never
@@ -16,7 +16,7 @@ description: "Set up recurring security upkeep with each harness's own mechanism
16
16
 
17
17
  1. If the user wants a goal reached in rounds with rests ("100% coverage", "every exposure", subagents per round), that is bravos-campaign; hand it over. Otherwise map the intent to one mechanism and say which: while this session is open → an in-session loop; while the laptop is closed, any harness → the nightly GitHub Actions workflow; while the laptop is closed, Claude Code with a cloud account → a cloud scheduled task the user creates.
18
18
  2. In-session loop (Claude Code only): copy `{{SKILL_DIR}}/loop.md` to `.claude/loop.md`, adjust the steps to the user's request, and commit it. Tell the user to start it with a bare `/loop`, which reads that file; it runs only while the session is open, stops when it exits, and expires after seven days. Codex has no equivalent; offer the nightly workflow instead.
19
- 3. Nightly workflow: run `bravos init --ci` (or `bravos sync --ci` in a repo bravos already set up), keep the variant for the team's harness (`bravos-nightly-claude.yml` or `bravos-nightly-codex.yml`) and delete the other. Tell the user the secret it needs (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) and to allow GitHub Actions to create pull requests in the repo settings.
19
+ 3. Nightly workflow: run `bravos init --ci` (or `bravos sync --ci` in a repo bravos already set up), keep the variant for the team's harness (`bravos-nightly-claude.yml` or `bravos-nightly-codex.yml`) and delete the other. A team on GitHub Copilot uses `bravos init --workflows nightly-copilot` instead: it opens an issue each night and assigns it to Copilot's cloud agent, which needs the secret `COPILOT_ASSIGN_TOKEN` (a Copilot user's personal access token) and `BRAVOS_LICENCE` as an Agents secret. Tell the user the secret it needs (`CLAUDE_CODE_OAUTH_TOKEN` for Claude Code, made once with `claude setup-token` so the run uses their Claude plan, or `OPENAI_API_KEY` for Codex) and to allow GitHub Actions to create pull requests in the repo settings.
20
20
  4. Cloud scheduled task: a skill cannot create one. Give the user the prompt to paste into `/schedule`: follow bravos-annotate in slice mode on the next unannotated files, run its lint gate, and open one pull request whose body carries bravos-ship's Security gate section. Tell them the task clones the default branch and runs at most hourly.
21
21
  5. State the spend before the user starts any of them: files per run (the default slice is five) times runs per day, and that each run spends model tokens.
22
22
  6. Nightly scan, opt-in: it replays the kits in `.guardlink/cxg-replay/` and records outcomes through `guardlink hypothesis confirm --from-scan`, and it runs only when `.guardlink/scope.yaml` is committed with an `authorization_attestation` a human typed and reviewed in a PR, and the repo variable `BRAVOS_SCAN_TARGET` is a loopback URL the job starts (repo variable `BRAVOS_APP_START`) or a host in that scope's `host_allowlist`. Otherwise the step prints why it skipped. Tell the user which variables to set and that the scope file is their standing authorization.
@@ -6,9 +6,12 @@
6
6
  # file's human-written attestation the scan step skips and the job annotates only.
7
7
  # The nightly is on the Team plan: add the repo secret BRAVOS_LICENCE (the token from
8
8
  # account.bugb.io/dashboard/license) so the agent's paid skills run; without it they say so and stop.
9
- # Needs the repo secret ANTHROPIC_API_KEY, and Settings > Actions > General > "Allow GitHub
10
- # Actions to create and approve pull requests". Pin the actions to commit SHAs if your
11
- # organisation requires it.
9
+ # Claude Code here signs in with your Claude plan, so the run uses that plan like a session would:
10
+ # run `claude setup-token` once on your machine and store what it prints as the repo secret
11
+ # CLAUDE_CODE_OAUTH_TOKEN. A repo that already set ANTHROPIC_API_KEY keeps working on that key;
12
+ # delete that secret to run on your plan instead. Also enable Settings > Actions > General >
13
+ # "Allow GitHub Actions to create and approve pull requests". Pin the actions to commit SHAs if
14
+ # your organisation requires it.
12
15
  name: bravos nightly (Claude Code)
13
16
 
14
17
  on:
@@ -57,6 +60,7 @@ jobs:
57
60
  - name: Annotate the next slice
58
61
  uses: anthropics/claude-code-action@v1
59
62
  with:
63
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
60
64
  anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
61
65
  prompt: |
62
66
  Follow .claude/skills/bravos-annotate/SKILL.md in slice mode (the default) to cover the
@@ -0,0 +1,73 @@
1
+ # bravos:generated — written by `bravos init --workflows nightly-copilot`; `bravos sync` refreshes it while this line stays.
2
+ # The nightly for teams on GitHub Copilot: on the schedule this job opens one issue asking Copilot's
3
+ # cloud agent to cover the next slice of unannotated files with the bravos-annotate skill, and
4
+ # assigns the issue to Copilot. Copilot works in its own session on GitHub Actions (prepared by
5
+ # copilot-setup-steps.yml, written alongside this file) and opens the pull request itself; the
6
+ # bravos PR gate then checks it like any other. It annotates only, and uses your Copilot plan:
7
+ # no AI API key. While an earlier nightly issue is still open it skips, so issues never pile up.
8
+ # Needs:
9
+ # - Copilot cloud agent enabled for this repository and for the person below (a Copilot Pro,
10
+ # Pro+, Business or Enterprise plan);
11
+ # - the repo secret COPILOT_ASSIGN_TOKEN: that person's personal access token. GitHub assigns
12
+ # Copilot only with a user's token, so the workflow's own token cannot. Fine-grained: read
13
+ # access to metadata, read and write access to actions, contents, issues and pull requests.
14
+ # Classic: the repo scope;
15
+ # - BRAVOS_LICENCE as an Agents secret (Settings > Secrets and variables > Agents), so the paid
16
+ # skills run in Copilot's session. Copilot does not see ordinary Actions secrets.
17
+ # Assigning Copilot through the API is in public preview at GitHub and may change.
18
+ name: bravos nightly (GitHub Copilot)
19
+
20
+ on:
21
+ schedule:
22
+ - cron: '17 3 * * 1-5'
23
+ workflow_dispatch:
24
+
25
+ permissions:
26
+ contents: read
27
+ issues: read
28
+
29
+ concurrency:
30
+ group: bravos-nightly
31
+ cancel-in-progress: false
32
+
33
+ jobs:
34
+ assign:
35
+ runs-on: ubuntu-latest
36
+ timeout-minutes: 10
37
+ defaults:
38
+ run:
39
+ shell: bash
40
+ steps:
41
+ - name: Ask Copilot for the next slice
42
+ env:
43
+ GH_TOKEN: ${{ secrets.COPILOT_ASSIGN_TOKEN }}
44
+ REPO: ${{ github.repository }}
45
+ BASE: ${{ github.event.repository.default_branch }}
46
+ START: ${{ github.sha }}
47
+ run: |
48
+ if [ -z "$GH_TOKEN" ]; then
49
+ echo "::error::Add the repo secret COPILOT_ASSIGN_TOKEN (a personal access token of someone with Copilot); see the comment at the top of this workflow"
50
+ exit 1
51
+ fi
52
+ open=$(gh issue list -R "$REPO" --label bravos-nightly --state open --json number --jq length)
53
+ if [ "$open" != "0" ]; then
54
+ echo "::notice::An earlier bravos nightly issue is still open; skipping until Copilot's pull request is merged or the issue is closed"
55
+ exit 0
56
+ fi
57
+ gh label create bravos-nightly -R "$REPO" --color 1E9A6C --description "Opened by the bravos nightly for Copilot" 2>/dev/null || true
58
+ body=$(cat <<EOF
59
+ Cover the next slice of unannotated files in this repository with GuardLink annotations.
60
+
61
+ - Follow the bravos-annotate skill (\`.claude/skills/bravos-annotate/SKILL.md\` or \`.agents/skills/bravos-annotate/SKILL.md\`) in slice mode, its default, on the files \`guardlink unannotated --json\` lists first.
62
+ - Do the work yourself in this session. Never run guardlink annotate with an agent flag.
63
+ - Stop when \`guardlink lint . --since $START --json\` reports 0 errors and \`guardlink validate .\` passes.
64
+ - Change annotations only, not code, and open one pull request with them.
65
+
66
+ Opened by the bravos nightly. While this issue is open the nightly opens no other; the next one comes after it closes.
67
+ EOF
68
+ )
69
+ jq -n --arg title "bravos nightly: annotate the next slice" --arg body "$body" --arg repo "$REPO" --arg base "$BASE" \
70
+ '{title: $title, body: $body, labels: ["bravos-nightly"], assignees: ["copilot-swe-agent[bot]"],
71
+ agent_assignment: {target_repo: $repo, base_branch: $base, custom_instructions: "", custom_agent: "", model: ""}}' \
72
+ | gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "repos/$REPO/issues" --input - \
73
+ | jq -r '"Assigned to Copilot: " + .html_url'
@@ -0,0 +1,35 @@
1
+ # bravos:generated — written with bravos-nightly-copilot.yml; `bravos sync` refreshes it while this line stays.
2
+ # Prepares GitHub Copilot cloud agent's session on GitHub Actions: Node and guardlink, so the
3
+ # bravos skills can run guardlink there. Copilot reads this file only from the default branch, and
4
+ # only a single job named copilot-setup-steps; it honours steps, permissions, runs-on, services,
5
+ # snapshot and timeout-minutes (at most 59). The push and pull_request triggers just check the
6
+ # steps still work when this file changes.
7
+ name: Copilot setup steps
8
+
9
+ on:
10
+ workflow_dispatch:
11
+ push:
12
+ paths:
13
+ - .github/workflows/copilot-setup-steps.yml
14
+ pull_request:
15
+ paths:
16
+ - .github/workflows/copilot-setup-steps.yml
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ copilot-setup-steps:
23
+ runs-on: ubuntu-latest
24
+ timeout-minutes: 15
25
+ permissions:
26
+ contents: read
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - uses: actions/setup-node@v4
31
+ with:
32
+ node-version: 22
33
+
34
+ - name: Install guardlink
35
+ run: npm install -g guardlink