@bugb-technologies/bravos 1.4.1 → 1.5.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 +53 -219
- package/dist/account.js +2 -11
- package/dist/cli.js +77 -29
- package/dist/codegraph.js +25 -0
- package/dist/dashboard.js +242 -0
- package/dist/guardlink.js +4 -3
- package/dist/guide.js +2 -1
- package/dist/help.js +8 -0
- package/dist/hooks.js +27 -5
- package/dist/install-proof-tool.js +5 -7
- package/dist/install.js +2 -2
- package/dist/licence.js +11 -4
- package/dist/omp.js +2 -1
- package/dist/open.js +22 -0
- package/dist/opencode.js +2 -1
- package/dist/setup.js +11 -2
- package/dist/skills.js +8 -0
- package/dist/start/index.js +10 -2
- package/dist/watch.js +8 -24
- package/docs/GUIDE.md +7 -1
- package/docs/UPGRADING.md +50 -0
- package/hooks/lib/briefing.mjs +82 -27
- package/hooks/lib/licence.mjs +13 -0
- package/hooks/lib/nightly-tools.sh +8 -2
- package/hooks/lib/replay.mjs +18 -7
- package/hooks/lib/setup.mjs +1 -1
- package/package.json +3 -2
- package/skills/bravos/SKILL.md +3 -2
- package/skills/bravos-annotate/SKILL.md +1 -1
- package/skills/bravos-annotate/scripts/lib/pick.mjs +1 -1
- package/skills/bravos-annotate/scripts/slice.mjs +1 -1
- package/skills/bravos-context/SKILL.md +5 -4
- package/skills/bravos-env/SKILL.md +2 -2
- package/skills/bravos-env/scope.example.yaml +2 -2
- package/skills/bravos-prove/SKILL.md +5 -5
- package/skills/bravos-templatize/SKILL.md +3 -3
- package/skills/bravos-templatize/operator-guidance.md +4 -4
- package/templates/dashboard/codegraph-pages.css +279 -0
- package/templates/dashboard/codegraph-pages.js +6230 -0
- package/templates/dashboard/codegraph-pages.json +11 -0
- package/templates/dashboard/dashboard.html +252 -0
package/README.md
CHANGED
|
@@ -1,238 +1,72 @@
|
|
|
1
1
|
# Bravos
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Shift-left security that runs with every commit and pull request.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Bravos makes the coding agent you already use work your threat model, code graph, SAST and authorized pentests, then gates every pull request and keeps a test that guards each fix.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install -g @bugb-technologies/bravos
|
|
9
|
-
```
|
|
7
|
+
## The loop
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Keep the threat model in the code with GuardLink → trace reachability with the code graph → investigate SAST findings → prove exposures with authorized pentests through cert-x-gen (`cxg`) → gate pull requests locally and in CI → replay a test after each fix.
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
Skills, hooks and MCP integration bring this loop into your coding agent, including Claude Code and Codex. A static finding is a lead; a test run supplies evidence. Pentests require a target you own and authorization; local targets use loopback by default.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## Install
|
|
16
14
|
|
|
17
|
-
**
|
|
15
|
+
Requires **Node.js 20 or newer**.
|
|
18
16
|
|
|
19
17
|
```bash
|
|
20
|
-
|
|
18
|
+
npm install -g @bugb-technologies/bravos
|
|
19
|
+
bravos start
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Upgrading to 1.4
|
|
26
|
-
|
|
27
|
-
1.4 adds continuous proof: autopilot reviews changed code in already-annotated files, the active agent writes a test bound to the claim it affects, and Bravos replays it through cxg and records the result in GuardLink. After `npm install -g @bugb-technologies/bravos`:
|
|
28
|
-
|
|
29
|
-
1. **`bravos setup --tools -y`** installs GuardLink 2.6.0 and cxg 1.8.0, the first releases with the interfaces 1.4 uses, and refreshes cxg's pentest pipeline; `bravos doctor` shows both as ready. Browser replay also needs cxg's Python requirements and Playwright Chromium, which setup names.
|
|
30
|
-
2. **`bravos sync`** in each repository refreshes the skills and hooks and keeps the hooks you already turned on. It tells you when the workflows are older than this version; **`bravos sync --ci`** refreshes the ones you have, keeping their schedule, and adds none.
|
|
31
|
-
3. **Scheduled proving** in the nightly needs `choice: schedule` in `.guardlink/proving.md`, with a `— confirmed by <name>, <date>` line, merged to the default branch (bravos-prove records it). Until then the job summary says why scheduled proof is off.
|
|
32
|
-
4. **Test kits written before 1.4** are reported as needing review and `bind` and are not run until bound (bravos-templatize does it).
|
|
33
|
-
5. **Automatic local testing** starts once a `target: http://localhost:<port>/` line for your app is merged to the default branch, and needs an `origin` remote; without one, tests run only once each, with your typed authorization.
|
|
34
|
-
6. Teammates **without a licence** now see that autopilot and the pre-PR gate are installed but locked for them, with the trial command, instead of "on".
|
|
35
|
-
7. **1.4.1:** `bravos setup` fetches analyzer 0.6.2 (Team plan), whose reachability matches the code graph and whose own GuardLink pin is 2.6.0. `bravos sast run` now starts only with the GuardLink step 1 installs on PATH, so SAST and the rest of Bravos read the threat model with the same GuardLink.
|
|
22
|
+
`bravos start` guides you through licence, tools, repository and agent setup, PR checks and scheduled upkeep. It shows the changes before you choose Apply, then tells you what to type in your agent. Bravos never starts an agent itself.
|
|
36
23
|
|
|
37
|
-
|
|
24
|
+
For manual setup, run `bravos init` in your repository to write skills, hooks and MCP wiring. `bravos setup` installs the analyzer and code graph (Team); `bravos setup --tools -y` also installs missing or incompatible GuardLink and cxg tools.
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
- `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.
|
|
41
|
-
- `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.
|
|
42
|
-
- `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` keeps compatible tools and installs missing or incompatible ones. Until the corresponding public releases are available, it builds GuardLink and CXG from the pinned upstream revisions in `hooks/lib/proof-tool-pins.json`. `--check` reports, `--dry-run` says what would happen.
|
|
43
|
-
- `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.
|
|
44
|
-
- `bravos sast run`: analyzes the repository with the staged analyzer into `.bravos/sast/<run>/` (not committed), which `bravos sast status` and `candidates` read. Takes the same `--agent`, `--pre-pr-hook`, `--ci` and `--scope` options as `init`, and never runs `guardlink init`.
|
|
45
|
-
- `bravos doctor`: check that the installed pieces and the underlying CLIs are present and healthy.
|
|
46
|
-
- `bravos watch`: a live, read-only view of the repo's security work for a second terminal pane beside any agent (below).
|
|
26
|
+
## Core commands
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| Skill | What it does |
|
|
28
|
+
| Command | Purpose |
|
|
51
29
|
|---|---|
|
|
52
|
-
| `bravos` |
|
|
53
|
-
| `bravos
|
|
54
|
-
| `bravos
|
|
55
|
-
| `bravos
|
|
56
|
-
| `bravos
|
|
57
|
-
| `bravos
|
|
58
|
-
| `bravos
|
|
59
|
-
| `bravos
|
|
60
|
-
| `bravos
|
|
61
|
-
| `bravos
|
|
62
|
-
| `bravos
|
|
63
|
-
| `bravos-cicd` | Audits and writes the security workflows; fixes broken guardlink calls and script-injection risks. |
|
|
64
|
-
| `bravos-report` | Writes the assessment, one finding, a retest or an executive brief from the evidence `bravos report data` gathers, checks it with `bravos report check`, and exports it to md, txt, html and pdf. |
|
|
65
|
-
|
|
66
|
-
## Plans and the licence
|
|
67
|
-
|
|
68
|
-
Bravos is free for one person researching one repository, and licensed per developer for a team.
|
|
69
|
-
|
|
70
|
-
| Plan | What it gives |
|
|
71
|
-
|---|---|
|
|
72
|
-
| **Free (researcher)** — no licence | bravos-context, bravos-annotate, bravos-templatize, bravos-env, bravos-prove, bravos-recheck, bravos-report and `bravos watch`, in one repository |
|
|
73
|
-
| **Team** (Solo is one seat) | everything above plus the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph |
|
|
74
|
-
|
|
75
|
-
`bravos licence` says which plan this machine is on, where the licence is and what it unlocks; the same line opens every session's briefing (`Plan: …`), `bravos doctor`, `bravos next` and the `bravos watch` header. `bravos account activate` signs you in once in the browser and writes the licence — a 30-day Team trial with no card when the account has no plan — and `bravos account import <file>` installs one downloaded from [account.bugb.io/dashboard/license](https://account.bugb.io/dashboard/license). A paid command or flag used without a licence explains what it would do and how to start the trial, and writes nothing; a paid hook (the pre-PR gate, autopilot) stands down with one line and never blocks a pull request; a paid skill stops at its first step and says so. The licence is a signed token verified offline (`BRAVOS_LICENCE`, or `licence.jwt` under `$BRAVOS_HOME`, default `~/.bravos`); after expiry it keeps working for min(14 days, a quarter of the term) and says so. Seats are counted in the account portal, not on the machine.
|
|
76
|
-
|
|
77
|
-
## Several repositories, one app: `bravos workspace`
|
|
78
|
-
|
|
79
|
-
For microservices, clone the services side by side in one folder and link them:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
bravos workspace create platform \
|
|
83
|
-
--member ./gateway=gateway@http://127.0.0.1:8080 \
|
|
84
|
-
--member ./orders=orders@http://127.0.0.1:8081 \
|
|
85
|
-
--member ./billing=billing@http://127.0.0.1:8082
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
That one command:
|
|
89
|
-
- creates a bravos workspace, the source of truth for members, services and URLs;
|
|
90
|
-
- runs `guardlink link-project`, so each repo's `.guardlink/workspace.yaml` names its siblings;
|
|
91
|
-
- runs `bravos init` (or `sync`) in each service, and installs bravos in the shared folder, the **app folder**;
|
|
92
|
-
- writes a snapshot to `.bravos/workspace/` in each of them (gitignored, since its paths are machine-local).
|
|
93
|
-
|
|
94
|
-
`add`, `remove`, `target NAME SERVICE=URL`, `show [NAME] [--json]` and `sync` keep all three in step. Members can live anywhere, but only the app folder lets the code graph link services: `bravos graph build <app folder> --scip no-exec` connects one service's HTTP, gRPC, GraphQL or OpenAPI client call to another's handler.
|
|
95
|
-
|
|
96
|
-
**In a service repo:**
|
|
97
|
-
- the briefing names the app, the other services, and the calls into and out of this one;
|
|
98
|
-
- `bravos watch` gets a SERVICES panel, and `s` shows every service and cross-service edge.
|
|
99
|
-
|
|
100
|
-
**At the app folder:**
|
|
101
|
-
- the briefing lists each service's open, high and confirmed exposures and coverage;
|
|
102
|
-
- `bravos report data --workspace` gathers one report across services, with ids prefixed by service (`orders:EXP-3`) and cross-service calls as `EDGE-n`.
|
|
103
|
-
|
|
104
|
-
Declare each call to another service as `@flows #<this>-<x> -> #<other>-<y> via http|grpc|queue`, with plain ids prefixed by service. guardlink merge, bravos export and cxg chaining all read this form. guardlink's dotted `#repo.tag` form is not chained by cxg.
|
|
105
|
-
|
|
106
|
-
## Reports: `bravos report` and the bravos-report skill
|
|
107
|
-
|
|
108
|
-
Ask the agent to "write the assessment report" (or a single finding, a retest, an executive brief) and the bravos-report skill does it in three steps:
|
|
109
|
-
|
|
110
|
-
1. `bravos report data` (free, no model) gathers every fact a report may cite into `.bravos/reports/<id>/evidence.json`:
|
|
111
|
-
- the threat model, and the hypothesis and boundary ledgers;
|
|
112
|
-
- each cxg run under `.guardlink/pentest-findings/`;
|
|
113
|
-
- SAST, the code graph, intent, scope and proving;
|
|
114
|
-
- tool versions.
|
|
115
|
-
|
|
116
|
-
Each fact gets an id (`EXP-n`, `LED-…`, `RUN-n/F-n`, `SAST-n`). Each exposure gets an evidence level computed from that evidence: reproduced at runtime, control held at runtime, established by code or configuration review, or suspected, awaiting validation. Token-shaped strings are redacted as they are read.
|
|
117
|
-
2. **The agent writes `report.md`** from the skill's templates. The full assessment follows the eight-section reading order (executive assessment, scope and limitations, system and threat context, coverage and approach, principal attack narratives, findings, remediation roadmap, retest and appendices). Every finding is self-contained, with:
|
|
118
|
-
- prerequisites;
|
|
119
|
-
- expected and observed behaviour;
|
|
120
|
-
- reproduction;
|
|
121
|
-
- root cause;
|
|
122
|
-
- impact (demonstrated, supported, uncertain);
|
|
123
|
-
- a severity rationale and a priority;
|
|
124
|
-
- remediation and verification.
|
|
125
|
-
|
|
126
|
-
Every proof claim cites its evidence ids.
|
|
127
|
-
3. **`bravos report check` fails the report** when any of these is wrong:
|
|
128
|
-
- a section is missing or out of order, or a finding lacks a field;
|
|
129
|
-
- a label is stronger than its cited evidence supports, or a cited id is unknown;
|
|
130
|
-
- a percentage has no denominator, or a CVSS score has no vector;
|
|
131
|
-
- something looks like a secret.
|
|
132
|
-
|
|
133
|
-
`bravos report export <id> --format md,txt,html,pdf` renders the checked report beside `report.md`:
|
|
134
|
-
- **html:** a branded page with no script and no external request, and a print stylesheet;
|
|
135
|
-
- **txt:** 80 columns;
|
|
136
|
-
- **pdf:** printed by an installed Chrome, Edge, Brave or Chromium (or Playwright's Chromium) in headless mode, with a throwaway profile. Set `BRAVOS_PDF_BROWSER` to choose one.
|
|
137
|
-
|
|
138
|
-
`bravos report list` shows the reports. Reports quote evidence, so `.bravos/reports/` carries its own `.gitignore`; sharing an export is a deliberate act. `bravos watch` shows the newest report in a REPORT panel: findings by evidence level and severity, check verdict, exports, and commits since. `p` shows its findings and executive section; `o` opens the pdf or html.
|
|
139
|
-
|
|
140
|
-
## Answering bravos's questions: `bravos review`
|
|
141
|
-
|
|
142
|
-
bravos-context no longer pastes thirty questions into chat. By default it assumes you are researching software you do not own: it drafts the intent from upstream's own docs (with links) and asks only the scope decisions — configuration baseline, single organisation or multi-tenant, attackers in scope, and intended-looking behaviours upstream leaves undocumented — which `intent.md` records as Assumptions that severities are rated against; say it is your product for the owner interview. It writes its suggestions to `.guardlink/intent-draft.json` and runs `bravos review intent`, which opens a bravos-branded page served from your machine only (loopback, a random token, answers capped and validated). Every card comes pre-filled with bravos's suggestion, its reason and its source; facts are folded away; decisions are marked "needs your call" and Confirm stays off until each one is clicked, so nobody rubber-stamps them. `intent.md` records each item as accepted as suggested, edited, chosen or draft, with names. Each person's answers are saved to `.guardlink/intent-answers/<name>.json`. Teammates run `bravos review intent` after pulling, or open the page with `--no-serve` and send the downloaded file, and the answers travel through git like any other change. `bravos review intent --summary` prints who agreed and who disagreed, for the agent to settle; `intent.md` marks each item confirmed only by the people who agreed to it. On Claude Code, `--share` renders the page for a private claude.ai artifact with a shared database instead; the agent says first that this puts your security intent on claude.ai.
|
|
143
|
-
|
|
144
|
-
## Autopilot
|
|
145
|
-
|
|
146
|
-
`bravos init --autopilot` (or `sync --autopilot`) is for teams who would rather not ask. It registers an end-of-turn check, a Stop hook in Claude Code and Codex, plus the pre-PR gate. The agent reviews changes inside existing files as well as newly added code. It checks affected exposures and declared controls against GuardLink’s hypothesis ledger. A changed claim with prior evidence can need a retest even while its control remains documented.
|
|
30
|
+
| `bravos start` | Guided setup. |
|
|
31
|
+
| `bravos init` | Install skills, hooks and MCP wiring in a repository. |
|
|
32
|
+
| `bravos sync` | Refresh installed skills and wiring after an upgrade. |
|
|
33
|
+
| `bravos setup` | Install the tools Bravos drives. |
|
|
34
|
+
| `bravos graph build .` | Index the repository for code graph questions. |
|
|
35
|
+
| `bravos sast run` | Run static analysis against the repository. |
|
|
36
|
+
| `bravos doctor` | Check installed tools and configuration. |
|
|
37
|
+
| `bravos next` | Show setup progress and the next step. |
|
|
38
|
+
| `bravos watch` | Watch security work live in a second terminal pane. |
|
|
39
|
+
| `bravos dashboard` | Open the findings as one page in your browser: the threat model and, on Team, the code graph. |
|
|
40
|
+
| `bravos guide` | Read the guide by role, task or skill. |
|
|
147
41
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
For a web claim, the coding agent authors one JavaScript probe with GuardLink’s translate method. It runs `bravos hook replay bind <kit.js>` to bind the test to the current exposure. At a verified fresh launch from the local worktree, `bravos hook replay build <loopback-url>` prints a build witness. Pass that JSON in `BRAVOS_REPLAY_BUILD` to the replay for that same launch. The normal automatic path is `bravos hook replay run <kit.js>`; a one-off run under an ask policy uses `run-once` with the exact target and current authorization. The helper executes the selected test through plain `cxg scan` with authoring disabled. A qualified result on the bound local build is recorded in GuardLink; remote or unidentified builds produce observations only. Raw run evidence stays outside Git. `bravos doctor` and `bravos setup --check` check the GuardLink and CXG command interfaces needed for this path.
|
|
151
|
-
|
|
152
|
-
## User-level install and one copy of each skill
|
|
153
|
-
|
|
154
|
-
`bravos init --global` (and `bravos sync --global` after an upgrade) installs bravos for your user rather than a repo: the skills once in `~/.claude/skills`, linked from `~/.agents/skills` for Codex and other shared-root agents, the session-start hook in `~/.bravos/hooks` registered in `~/.claude/settings.json` and `~/.codex/hooks.json`, and guardlink MCP in `~/.codex/config.toml`. The user hook is quiet in any repo that has its own bravos hook or no `.guardlink/`, so it briefs only repos with a threat model that bravos is not installed in. It is personal: teammates get bravos through `bravos init` in the repo. Because Claude Code prefers personal skills over a repo's, `bravos sync` in any repo also brings an existing user-level install to the same version, so an older personal copy never stands in for the repo's; it never creates one, and `BRAVOS_SYNC_GLOBAL=off` keeps the two separate.
|
|
155
|
-
|
|
156
|
-
`bravos sync --link-skills` replaces a repo's `.agents/skills` with a link to `.claude/skills`, so each skill exists once; tools that read both folders, such as Warp, otherwise show every skill twice. It removes only bravos's own unchanged copies and refuses, removing nothing, when anything else is there.
|
|
157
|
-
|
|
158
|
-
## Uninstall
|
|
159
|
-
|
|
160
|
-
`bravos uninstall` removes bravos from the current repository: every file its lock records that is unchanged, its hook entries in `.claude/settings.json`, `.codex/hooks.json` and `.agents/hooks.json`, its `pre_pr` entry in `.guardlink/config.json`, and `.bravos/`. `bravos uninstall --global` does the same for the user-level install, including the `~/.agents/skills/bravos*` links. Edited files are kept and listed unless `--force`; `--dry-run` lists everything first. It never removes guardlink's own files, a reviewed `scope.yaml`, or MCP entries, which may predate bravos; it lists them.
|
|
161
|
-
|
|
162
|
-
## A live view: `bravos watch`
|
|
163
|
-
|
|
164
|
-
`bravos watch` runs in a second terminal pane beside any agent (Claude Code, Codex, omp, opencode, Antigravity) and shows the repo's security work as it changes. A row of tiles (open, high, confirmed, tested, coverage, stale, setup, graph resolution, SAST) sits under a header bar, and bordered panels below it show:
|
|
165
|
-
|
|
166
|
-
- **Setup**: the nine steps with a progress bar, and the next one with its command.
|
|
167
|
-
- **Threat model**: a severity bar (one glyph per severity, so it reads without colour), the hypothesis ledger (confirmed, refuted, retest, untested), boundary claims held or broken, coverage, annotations, stale claims, drift, orphans, accepted risks and tickets, with sparklines of open exposures and coverage over the session.
|
|
168
|
-
- **Test next**: `guardlink hypothesis next` with severity badges, asset, state and file.
|
|
169
|
-
- **Top threats and assets**, ranked with bars.
|
|
170
|
-
- **Code graph**: currency, files, callables and calls, call resolution per language (with a warning below 50%, where "not reached" is weak evidence), entry points by kind, route access levels, how many declared exposures a test reaches, hot files that change open exposures, accepted risks. A commit leaves the checkout without a graph until it is rebuilt, because bravos keys the graph to the commit; the panel says so and gives the command.
|
|
171
|
-
- **SAST**, **branch and team** (ahead and behind the base, uncommitted files and how many lack annotations, recent commits, PRs, autopilot, pre-PR and CI hooks, intent, proving, review answers, a skills-version mismatch), the **model's size** (`guardlink status`), and **activity**.
|
|
172
|
-
|
|
173
|
-
It redraws within a couple of seconds of a file change (`fs.watch`, debounced; one snapshot at a time), re-reads boundaries, the model's size and PRs every `--interval` seconds (default 60), and asks the code graph again every `--graph-interval` seconds (default 300). Read-only and free: no model, nothing written to the repo. Autopilot logs each nudge to `.bravos/watch/events.jsonl`, a local log with its own `.gitignore`, capped at 500 lines.
|
|
174
|
-
|
|
175
|
-
Three columns from 150 wide, two from 110, one column from 80 (a split pane), a compact list below that (`--compact` forces it); the panels scroll when the terminal is shorter than they are. Keys: `n` copies the next command, `r` opens the intent review page, `d` writes guardlink's dashboard to a temp file and opens it, `g` asks the code graph a question (`bravos graph <q>`), `t` shows test-next and stale claims in full, `i` shows the recorded intent (`.guardlink/intent.md`, with who answered the review), `u` refreshes everything now, `j`/`k` (or the arrows, space, `G`) scroll, `?` the guide, `q` quits. Overlays (`t`, `i`, `?`, a graph answer) wrap to the terminal and scroll with the same keys; any other key closes them. `--once` prints one frame (and is what happens when stdout is not a terminal), `--json` one snapshot (`bravos.watch/v1`). `c` switches the colours between dark, light and neutral. `NO_COLOR` or `BRAVOS_WATCH_COLOR=off` prints it plain; on a live terminal bravos asks it for its background colour and picks the light or dark palette (see `BRAVOS_THEME` below).
|
|
176
|
-
|
|
177
|
-
## Getting started: `bravos next`
|
|
178
|
-
|
|
179
|
-
`bravos next` (free, in a shell) is the setup score for a repo, in the order the steps build on each other: the code graph first (a machine step every later skill reads), then what the app intends, annotation coverage, SAST (which reads the annotations), how findings are proven and a test target, then the gates (autopilot, the pre-PR gate, CI — cheap, fine to switch on early). It shows what each unlocks and the exact command for the next one; bravos assumes a licensed bravos-cli. The same line is in the banner (`Next: … → …`, and `setup n/9` on the status line) and in the briefing every harness hands the agent, together with a few coaching rules: offer a few starts once in the first reply, suggest the next bravos step at natural moments (annotate after security edits, the ship check before a PR, a recheck after a fix), plain words first, never nag. Ask "help me get started" for a guided tour. `BRAVOS_COACH=off` keeps only the Setup line.
|
|
180
|
-
|
|
181
|
-
## The guide
|
|
182
|
-
|
|
183
|
-
`bravos guide` prints how to use bravos by role (developer, security engineer, team lead, new to the repo, CI owner), by task, skill by skill, how to read a finding, the hard safety rules and what each harness gets. It runs no model. `bravos guide <topic>` prints one topic (`start`, `roles`, `tasks`, `skills`, `states`, `safety`, `harnesses`, `all`); `--harness codex|omp` shows skills in that harness's syntax. The same text is in [docs/GUIDE.md](docs/GUIDE.md).
|
|
184
|
-
|
|
185
|
-
## Session start: a briefing for the model, a banner for you
|
|
186
|
-
|
|
187
|
-
The session-start hook prints one JSON object. Its `additionalContext` is the briefing: open exposures by severity, coverage, confirmed findings, what to test next, stale claims, tickets, work in flight and the intent state, sent to the model on every start, resume, clear and compact. On a fresh start only (`source: startup`, or a manual run), its `systemMessage` carries a banner for the human, which the model does not see: the bravos logo, repo and branch, the counts, the top three threats (or the confirmed findings to fix now) beside a three-step quick start chosen from the repo's state, and a short introduction to bravos while `.guardlink/intent.md` is missing. It is plain text within 80 columns. The registered command carries `--harness claude` or `--harness codex` so the quick start prints `/bravos-…` or `$bravos-…`; `bravos sync` replaces the older entry without the flag, and Codex asks you to trust the changed hook once in `/hooks`. Set `BRAVOS_BANNER=off` to hide the banner; the briefing is unchanged. The banner is drawn in bravos's brand colours; `NO_COLOR` or `BRAVOS_BANNER_COLOR=off` prints it plain. Colours follow the terminal's background: `BRAVOS_THEME=light|dark|neutral` picks them, otherwise `COLORFGBG`, the choice saved by `bravos start`, then `neutral`, whose colours read on light and dark backgrounds alike (`bravos doctor` says which and why). Codex lists a hook's message as a warning (behind F2), so Codex gets a two-line summary instead of the art. opencode finds the skills through its skill tool but lists only its own `/commands` and runs no hooks, so when opencode is in use (`.opencode/`, `opencode.json`, or `opencode` on PATH) bravos also writes one `.opencode/commands/<skill>.md` per skill (so `/bravos`, `/bravos-ship` and the rest appear), `.opencode/plugins/bravos.js` (an opencode 2.x plugin that adds the briefing to the system prompt of each request), and guardlink under `mcp` in `opencode.json`. Antigravity (`agy`) reads `.agents/hooks.json`; bravos adds a `bravos` SessionStart group there that hands the briefing to the model, since Antigravity documents no way for a hook to show text to you.
|
|
188
|
-
|
|
189
|
-
omp runs neither Claude Code's nor Codex's hooks, so when omp is in use (a `.omp/` folder, or `omp` on PATH) `bravos init` and `sync` also write `.omp/extensions/bravos.js`, which omp loads by itself: it shows the same banner above the editor at session start and hands the briefing to the model, hidden, with the first prompt. In none of these harnesses do you need to type a command for the briefing; `/bravos` is for deciding the next step. Anywhere else, the bravos skill runs `node .bravos/hooks/session-start.mjs --briefing`, which prints the briefing as plain text.
|
|
190
|
-
|
|
191
|
-
## The pre-PR gate
|
|
192
|
-
|
|
193
|
-
With `--pre-pr-hook`, every `gh pr create` and `gh pr ready` an agent runs first passes the bravos-ship gate: `guardlink validate`, `guardlink lint --since <merge-base>` with no errors, every new unmitigated exposure from `guardlink diff <merge-base> --json` disclosed in the PR body by both its threat and asset id (on `gh pr ready` the body is read with `gh pr view`), and no `@confirmed` claim from `guardlink ci -f json` on a changed file unless that file carries a `@ticket` for it. An exposure paired with `@audit` stays listed by design and is reported, not blocked forever. A gate input that fails or does not parse blocks as "unknown", including `gh pr view` on `gh pr ready`; the gate allows, and says why, in exactly two cases: guardlink is not on PATH, or no merge base with the default branch is found. It runs from the repository's top level whatever directory the agent is in. Before a PR exists, run `node .bravos/hooks/pre-pr.mjs --check` (the line `--pre-pr-hook` lists under `pre_pr` for guardlink's agent block): it blocks on lint errors and confirmed claims on changed files, and prints the new exposures the PR body must disclose. The whole gate shares a 150 s deadline inside the hook's 180 s timeout. Set `BRAVOS_PRE_PR=off` in your own environment to disable it.
|
|
194
|
-
|
|
195
|
-
## Workflows (`bravos init --ci`)
|
|
196
|
-
|
|
197
|
-
- `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).
|
|
198
|
-
- `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. When the team has enabled scheduled proving, the job also replays eligible, bound JS kits on its reviewed target. Set BRAVOS_SCAN_TARGET and configure any test identity secrets that the kits require.
|
|
199
|
-
- `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.
|
|
200
|
-
|
|
201
|
-
## Install as a plugin (after 1.0)
|
|
202
|
-
|
|
203
|
-
The repo also renders a plugin for each harness from the same `skills/` and `hooks/`: `plugin/` for Claude Code (served by `.claude-plugin/marketplace.json`) and `plugin-codex/` for Codex (`.agents/plugins/marketplace.json`). Regenerate both with `npm run build:plugin`; a test fails when either drifts from the source. A plugin marketplace is served from a repository customers can read, and this one is private, so the marketplace route (a small public repo holding only the built plugins, then `claude plugin marketplace add …` / `claude plugin install bravos@bravos`) comes after 1.0; until then `bravos init` is the way in for every harness.
|
|
204
|
-
|
|
205
|
-
Each plugin carries the skills, the session-start briefing (from the plugin's own copy of the hook) and the guardlink MCP entry. cxg and the code-graph server are left out because they fail to start on machines without them; `bravos init` adds them per repo when they are installed. The Codex build renders skill paths repo-relative (`.agents/skills/<name>`), so the scripts a skill runs (for example bravos-annotate's slice picker) resolve once `bravos init --agent codex` has written `.agents/skills/` into the repo. The pre-PR gate and the workflows come from `bravos init` for both harnesses. Use the plugin or `bravos init`'s session-start hook, not both, or the briefing prints twice.
|
|
206
|
-
|
|
207
|
-
## How bravos works with the model
|
|
208
|
-
|
|
209
|
-
Claude Code and Codex are already strong; bravos is an add-on, never a cap. Every budget in a skill
|
|
210
|
-
(files per slice, templates per run, rounds per campaign) is a default the agent may exceed when the
|
|
211
|
-
work needs it, saying why in one line. Only the safety rules are hard: no request to a non-loopback
|
|
212
|
-
host without a committed, reviewed `scope.yaml` and your typed authorization; destructive probe
|
|
213
|
-
classes only on a disposable loopback target; never `@accepts`, `@entitles` or a hand-written
|
|
214
|
-
`@confirmed`; never launch an external agent CLI; never invent credentials; never call anything clean
|
|
215
|
-
unless a gate exited 0.
|
|
216
|
-
|
|
217
|
-
**Effort** (`low | medium | high | max`) is one dial every skill reads: from your request ("annotate at
|
|
218
|
-
high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. Run
|
|
219
|
-
`bravos --help` for what each level means per skill.
|
|
220
|
-
|
|
221
|
-
**bravos-campaign** reaches a goal over many rounds — `/bravos-campaign coverage 100% at max, rest 10m`
|
|
222
|
-
in Claude Code, `$bravos-campaign test every open exposure` in Codex — with disjoint batches, one
|
|
223
|
-
subagent per batch, a gate per batch, a rest between rounds, and a stop when the goal is met.
|
|
224
|
-
|
|
225
|
-
## Intent-aware annotation
|
|
226
|
-
|
|
227
|
-
Code patterns alone over-rate features and miss business-logic flaws. `bravos-context` reads the
|
|
228
|
-
repo, drafts answers, and asks you a short interview: what the product is for, who the roles are,
|
|
229
|
-
what data and actions matter most, what must never happen, and what looks dangerous but is
|
|
230
|
-
intended. Answers go into `.guardlink/intent.md` (each item `— confirmed by <name>` or `— draft`)
|
|
231
|
-
and into the threat model as actors, assets, boundaries and one `#inv-…` threat per invariant.
|
|
232
|
-
bravos-annotate then adds a logic pass over user journeys, rates each exposure by impact × reach
|
|
233
|
-
× ease with the reason in the description, and writes an "intended?" `@audit` for you to answer
|
|
234
|
-
rather than claiming a by-design feature as a critical flaw.
|
|
42
|
+
## Skills
|
|
235
43
|
|
|
236
|
-
|
|
44
|
+
Invoke skills in your agent: `/bravos` in Claude Code or `$bravos` in Codex.
|
|
237
45
|
|
|
238
|
-
|
|
46
|
+
| Skill | Purpose |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `bravos` | Start here: read the security picture and route to the next step. |
|
|
49
|
+
| `bravos-context` | Record software intent, actors, assets and boundaries before judging code. |
|
|
50
|
+
| `bravos-annotate` | Keep the GuardLink threat model accurate and growing, with evidence and lint gates. |
|
|
51
|
+
| `bravos-codegraph` | Ask one bounded question about routes, sinks, reachability or blast radius. |
|
|
52
|
+
| `bravos-sast` | Run licensed static analysis, join findings to claims and reachability, and gate new findings. |
|
|
53
|
+
| `bravos-templatize` | Turn open exposures into correct, testable cxg templates. |
|
|
54
|
+
| `bravos-env` | Prepare a target you own with reviewed scope and your authorization; loopback by default. |
|
|
55
|
+
| `bravos-prove` | Prove a claim or replay it after a fix against an authorized target. |
|
|
56
|
+
| `bravos-recheck` | Recheck stale findings, replay retest kits and confirm a fix held. |
|
|
57
|
+
| `bravos-ship` | Gate a PR on valid claims and new exposures; block confirmed exploitable claims on changed paths without a ticket. |
|
|
58
|
+
| `bravos-cicd` | Audit and write security CI: PR gate, nightly annotation and optional SAST. |
|
|
59
|
+
| `bravos-report` | Write and export an evidence-bound white-box VAPT report. |
|
|
60
|
+
| `bravos-campaign` | Work toward a security goal over multiple rounds, then stop. |
|
|
61
|
+
| `bravos-schedule` | Set up recurring upkeep through a session loop, nightly workflow or cloud task. |
|
|
62
|
+
| `bravos-resync` | Carry annotation work from an unmerged branch onto the base and reverify it. |
|
|
63
|
+
|
|
64
|
+
## Plans & licence
|
|
65
|
+
|
|
66
|
+
**Free:** one person researching one repository, including the threat-model and authorized testing loop. **Team** (Solo is one seat) adds PR gates, autopilot, CI, scheduled upkeep, workspaces, campaigns, SAST and the code graph. `bravos account activate` starts a 30-day Team trial with no card when your account has no plan; `bravos licence` shows your plan.
|
|
67
|
+
|
|
68
|
+
Bravos is proprietary software of BugB Technologies, free on the Free plan and licensed per developer for Team features. See [LICENSE](LICENSE) for terms; third-party components keep their own licences.
|
|
69
|
+
|
|
70
|
+
## Learn more
|
|
71
|
+
|
|
72
|
+
Visit [Bravos](https://bugb.io/bravos) for the product and plans. Run `bravos guide` for detailed setup, workflows, safety rules and harness guidance, or `bravos --help` for command options. The guide is also shipped with the npm package at `docs/GUIDE.md`, and what changes between versions is in [docs/UPGRADING.md](docs/UPGRADING.md).
|
package/dist/account.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @comment -- "bravos account: how a licence gets onto this machine. `activate` is the device-code pairing with the account portal (one POST to start, the browser to approve, polling until the portal hands back a signed token); `import` takes a downloaded file. Either way the token is verified by the same offline verifier before it is written, so a token the portal signed with a key this build does not trust is refused here, not at the first gated command. The origin is fixed (BRAVOS_ACCOUNT_ORIGIN overrides it for a local portal), no proxy is read from the environment, and the token is written 0600."
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
2
|
import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
3
|
import { hostname } from 'node:os';
|
|
5
4
|
import { join } from 'node:path';
|
|
6
5
|
import { refreshLib, userAgent } from './device.js';
|
|
6
|
+
import { openInBrowser } from './open.js';
|
|
7
7
|
import { licenceLib, licenceLines } from './licence.js';
|
|
8
8
|
import { BravosError } from './types.js';
|
|
9
9
|
export const ACTIVATION_PATH = '/api/v1/cli/activation';
|
|
@@ -18,15 +18,6 @@ export const accountOrigin = (env, L) => {
|
|
|
18
18
|
throw new BravosError(`BRAVOS_ACCOUNT_ORIGIN must be an origin like https://account.bugb.io, got ${JSON.stringify(raw)}`);
|
|
19
19
|
return raw;
|
|
20
20
|
};
|
|
21
|
-
const defaultOpen = (url) => {
|
|
22
|
-
const [cmd, args] = process.platform === 'darwin' ? ['open', [url]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', url]] : ['xdg-open', [url]];
|
|
23
|
-
try {
|
|
24
|
-
spawn(cmd, args, { stdio: 'ignore', detached: true }).unref();
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
/* the URL is printed anyway */
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
21
|
const licenceFile = (env, L) => {
|
|
31
22
|
const home = L.bravosHome(env);
|
|
32
23
|
if (!home)
|
|
@@ -71,7 +62,7 @@ export async function activate(io) {
|
|
|
71
62
|
const f = io.fetch ?? fetch;
|
|
72
63
|
const sleep = io.sleep ?? ((s) => new Promise((r) => setTimeout(r, s * 1000)));
|
|
73
64
|
const now = io.now ?? (() => Date.now() / 1000);
|
|
74
|
-
const open = io.open ??
|
|
65
|
+
const open = io.open ?? ((url) => void openInBrowser(url, io.env));
|
|
75
66
|
const ua = { 'User-Agent': userAgent(), Accept: 'application/json' };
|
|
76
67
|
let start;
|
|
77
68
|
try {
|
package/dist/cli.js
CHANGED
|
@@ -26,8 +26,9 @@ import { listDevices, logout, refresh as refreshDevice, revokeDevice } from './d
|
|
|
26
26
|
import * as graph from './codegraph.js';
|
|
27
27
|
import { askGraph } from './watch.js';
|
|
28
28
|
import { plan as setupPlan, runSast, runSetup } from './setup.js';
|
|
29
|
+
import { openInBrowser } from './open.js';
|
|
29
30
|
import { licenceDocument, licenceLib, licenceLines, requireFeature } from './licence.js';
|
|
30
|
-
import { migrateFromOldName, reportMigration } from './migrate.js';
|
|
31
|
+
import { migrateFromOldName, OLD_DIR, reportMigration } from './migrate.js';
|
|
31
32
|
import { listBundledSkills } from './skills.js';
|
|
32
33
|
import { installSkills, linkSkillRoots, mirrorGuardlinkSkills, skillRootsLinked } from './install.js';
|
|
33
34
|
import { readLock, sha256, writeLock } from './lock.js';
|
|
@@ -47,12 +48,12 @@ function parseWorkflows(value) {
|
|
|
47
48
|
}
|
|
48
49
|
const GUARDLINK_HINT = 'guardlink: not found on PATH — run bravos setup --tools -y';
|
|
49
50
|
// Antigravity reads the shared .agents/ root; opencode and omp get their own files on top of a skills root.
|
|
50
|
-
const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: '
|
|
51
|
+
const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agy', opencode: 'opencode', omp: 'omp' };
|
|
51
52
|
// @comment -- "Parses --agent <claude,codex>; codex maps to the .agents harness and anything else is a usage error."
|
|
52
53
|
function parseAgents(value) {
|
|
53
54
|
const out = [];
|
|
54
55
|
// 'all' is every harness bravos knows: both skill roots plus the opencode and omp files.
|
|
55
|
-
const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'opencode', 'omp'] : [r]));
|
|
56
|
+
const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'agy', 'opencode', 'omp'] : [r]));
|
|
56
57
|
for (const raw of raws) {
|
|
57
58
|
const h = AGENT_MAP[raw];
|
|
58
59
|
if (!h)
|
|
@@ -86,21 +87,43 @@ function gitignoreWarnings(root, paths, env) {
|
|
|
86
87
|
return dirs.map((d) => `warning: ${d}/ is gitignored in this repo; files under it will not reach teammates via git`);
|
|
87
88
|
}
|
|
88
89
|
// @comment -- "Runs the install pipeline (detect, guardlink init unless sync, skills, hook, lock, MCP) and pushes summary lines as it goes, so a mid-way BravosError still leaves the summary so far in `lines`."
|
|
90
|
+
// @comment -- "Names any agent settings file that still runs a hook script from the old name's folder (.joseph/hooks), which the migration removes: an agent not selected with --agent keeps its own settings, so its sessions would start a script that is gone. Read-only; an unreadable file is skipped."
|
|
91
|
+
function oldHookReferences(root) {
|
|
92
|
+
const files = [['.claude/settings.json', 'claude'], ['.codex/hooks.json', 'codex'], ['.agents/hooks.json', 'agy']];
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const [rel, agent] of files) {
|
|
95
|
+
try {
|
|
96
|
+
if (readFileSync(join(root, rel), 'utf8').includes(`${OLD_DIR}/hooks/`)) {
|
|
97
|
+
out.push(`Hooks: ${rel} still runs the old ${OLD_DIR}/hooks scripts, which are gone; run bravos sync --agent ${agent} to replace them, or remove those entries.`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
/* not there */
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
89
106
|
function pipeline(root, io, opts, withGuardlink, lines) {
|
|
90
107
|
const dryRun = !!opts.dryRun;
|
|
91
108
|
if (dryRun)
|
|
92
109
|
lines.push('dry-run: nothing written');
|
|
110
|
+
// @comment -- "The move from the old name runs whatever --agent selects: it removes only old-name files the old lock vouches for and moves the data folders, and creates nothing for an agent that was not chosen. bravos start always passes --agent, so skipping it there would leave every old install unmigrated."
|
|
93
111
|
reportMigration(migrateFromOldName(root, { dryRun, ownSkills: listBundledSkills(io.skillsDir).map((s) => s.name) }), lines);
|
|
94
112
|
const detected = detectHarnesses(root);
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const
|
|
113
|
+
// @comment -- "Explicit --agent limits agent-specific writes, independent of detection and shared skill roots. Antigravity and Codex share .agents/skills but have separate hook registrations; omp/opencode alone use that skills root without installing Codex."
|
|
114
|
+
const explicit = opts.agent !== undefined;
|
|
115
|
+
const chosen = opts.agent?.flatMap((a) => a === 'claude' ? ['claude'] : a === 'agents' || a === 'agy' ? ['agents'] : []);
|
|
116
|
+
const harnesses = explicit ? [...new Set(chosen?.length ? chosen : ['agents'])] : detected.harnesses;
|
|
117
|
+
const defaulted = !explicit && detected.defaulted;
|
|
118
|
+
const codex = explicit ? opts.agent.includes('agents') : harnesses.includes('agents');
|
|
119
|
+
const agy = explicit ? opts.agent.includes('agy') : harnesses.includes('agents');
|
|
120
|
+
const hookHarnesses = harnesses.filter((h) => h === 'claude' || codex);
|
|
98
121
|
const forceOpencode = !!opts.agent?.includes('opencode');
|
|
99
122
|
const forceOmp = !!opts.agent?.includes('omp');
|
|
100
123
|
lines.push(`Harnesses: ${harnesses.join(', ')}${defaulted ? ' (default: no evidence found)' : ''}`);
|
|
101
124
|
let guardlinkPending = false;
|
|
102
125
|
if (withGuardlink) {
|
|
103
|
-
const g = ensureGuardlink(root,
|
|
126
|
+
const g = ensureGuardlink(root, hookHarnesses, {
|
|
104
127
|
mode: opts.guardlinkMode,
|
|
105
128
|
skip: opts.guardlinkInit === false,
|
|
106
129
|
dryRun,
|
|
@@ -174,14 +197,14 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
174
197
|
for (const s of mirror.skipped)
|
|
175
198
|
lines.push(` skipped ${s.path} — ${s.reason}`);
|
|
176
199
|
}
|
|
177
|
-
const cursor = writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
|
|
200
|
+
const cursor = explicit ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
|
|
178
201
|
if (cursor.status === 'skipped')
|
|
179
202
|
lines.push(`Cursor: skipped ${cursor.path} — ${cursor.reason}`);
|
|
180
203
|
else if (cursor.status === 'no-skills')
|
|
181
204
|
lines.push(`Cursor: ${cursor.path} not written — no skills root was installed for it to point at`);
|
|
182
205
|
else if (cursor.status !== 'absent')
|
|
183
206
|
lines.push(`Cursor: ${cursor.path} ${cursor.status}`);
|
|
184
|
-
const omp = writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
|
|
207
|
+
const omp = explicit && !forceOmp ? { status: 'absent' } : writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
|
|
185
208
|
if (omp.status === 'skipped')
|
|
186
209
|
lines.push(`omp: skipped ${omp.path} — ${omp.reason}`);
|
|
187
210
|
else if (omp.status !== 'absent')
|
|
@@ -198,7 +221,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
198
221
|
// Autopilot is the pre-PR gate plus the end-of-turn check.
|
|
199
222
|
if (opts.autopilot)
|
|
200
223
|
opts.prePrHook = true;
|
|
201
|
-
const hook = installHook(root,
|
|
224
|
+
const hook = installHook(root, hookHarnesses, { hooksDir: io.hooksDir, dryRun, antigravity: agy, prePr: !!opts.prePrHook, autopilot: !!opts.autopilot });
|
|
202
225
|
if (!dryRun) {
|
|
203
226
|
const lock = readLock(root);
|
|
204
227
|
for (const rel of hook.copied)
|
|
@@ -207,6 +230,9 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
207
230
|
}
|
|
208
231
|
for (const r of hook.registered)
|
|
209
232
|
lines.push(`Hooks: ${r.file} ${r.changed ? 'registered' : 'already registered'}`);
|
|
233
|
+
// An agent left out of --agent keeps its own settings, which may still run the old-name hook the migration moved.
|
|
234
|
+
for (const w of oldHookReferences(root))
|
|
235
|
+
lines.push(w);
|
|
210
236
|
const guardlinkWritten = [];
|
|
211
237
|
if (opts.prePrHook) {
|
|
212
238
|
const p = registerPrePr(root, { dryRun });
|
|
@@ -234,15 +260,16 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
234
260
|
}
|
|
235
261
|
const { selected, deferred } = selectServers(io.env);
|
|
236
262
|
// opencode lists skills only through its skill tool and runs no hooks: commands, a plugin and MCP.
|
|
237
|
-
const oc = writeOpencode(root, io.env, selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
|
|
263
|
+
const oc = explicit && !forceOpencode ? { status: 'absent' } : writeOpencode(root, io.env, selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
|
|
238
264
|
if (oc.status === 'done') {
|
|
239
265
|
lines.push(`opencode: ${oc.written.length} written, ${oc.unchanged.length} unchanged, ${oc.skipped.length} skipped (plugin, /bravos commands)${oc.mcpAdded.length ? `; ${OPENCODE_CONFIG} mcp added ${oc.mcpAdded.join(', ')}` : ''}${oc.mcpUpdated?.length ? `; ${OPENCODE_CONFIG} mcp refreshed ${oc.mcpUpdated.join(', ')}` : ''}`);
|
|
240
266
|
for (const s of oc.skipped)
|
|
241
267
|
lines.push(` skipped ${s.path} — ${s.reason}`);
|
|
242
268
|
}
|
|
243
269
|
const mcpLine = (m) => lines.push(`MCP: ${m.path} added ${names(m.added)}; kept ${names(m.kept)}${m.updated?.length ? `; refreshed ${names(m.updated)} (it pointed at another bravos install or graph store)` : ''}`);
|
|
244
|
-
|
|
245
|
-
|
|
270
|
+
if (!explicit || harnesses.includes('claude'))
|
|
271
|
+
mcpLine(mergeMcpJson(root, selected, { dryRun }));
|
|
272
|
+
if (codex)
|
|
246
273
|
mcpLine(mergeCodexConfig(root, selected, { dryRun }));
|
|
247
274
|
if (deferred.length) {
|
|
248
275
|
const tools = runDoctor(root, io.env).tools;
|
|
@@ -279,7 +306,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
279
306
|
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.');
|
|
280
307
|
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.');
|
|
281
308
|
}
|
|
282
|
-
if (
|
|
309
|
+
if (codex)
|
|
283
310
|
lines.push('In Codex run /hooks once to trust .codex/hooks.json');
|
|
284
311
|
// A user-level install of another version silently replaces these skills in Claude Code, so a
|
|
285
312
|
// repo sync brings an existing one up to date too (never creates one; a dry run only reports;
|
|
@@ -381,7 +408,7 @@ export function buildProgram(io, result) {
|
|
|
381
408
|
.description('First install: detect agents, run guardlink init if needed, install skills, hooks and MCP wiring.')
|
|
382
409
|
.addHelpText('after', INIT_HELP)
|
|
383
410
|
.option('--agent <list>', 'comma-separated agents: claude,codex,agy,opencode,omp, or all', parseAgents)
|
|
384
|
-
.addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode').choices(['inline', 'external'])
|
|
411
|
+
.addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode (default: GuardLink chooses)').choices(['inline', 'external']))
|
|
385
412
|
.option('--no-guardlink-init', 'do not run guardlink init')
|
|
386
413
|
.option('--force', 'overwrite edited or authored skill files')
|
|
387
414
|
.option('--pre-pr-hook', 'also register the PreToolUse gate that checks gh pr create / gh pr ready')
|
|
@@ -689,7 +716,7 @@ export function buildProgram(io, result) {
|
|
|
689
716
|
const rel = writePage(root, kind, await renderReview(draft, { kind: 'file' }));
|
|
690
717
|
lines.push(`Review page: ${rel} (Save downloads your answers; put them in .guardlink/${kind}-answers/ and commit)`);
|
|
691
718
|
if (opts.open !== false)
|
|
692
|
-
openInBrowser(pathJoin(root, rel));
|
|
719
|
+
openInBrowser(pathJoin(root, rel), io.env);
|
|
693
720
|
return;
|
|
694
721
|
}
|
|
695
722
|
const port = await freePort();
|
|
@@ -703,7 +730,7 @@ export function buildProgram(io, result) {
|
|
|
703
730
|
lines.push(`Answers save to .guardlink/${kind}-answers/<name>.json. Teammates run bravos review ${kind} after pulling. The page stops on Done or after 30 minutes idle.`);
|
|
704
731
|
lines.push(`When everyone is done: bravos review ${kind} --summary`);
|
|
705
732
|
if (opts.open !== false)
|
|
706
|
-
openInBrowser(url);
|
|
733
|
+
openInBrowser(url, io.env);
|
|
707
734
|
}));
|
|
708
735
|
program
|
|
709
736
|
.command('next [dir]')
|
|
@@ -720,7 +747,16 @@ export function buildProgram(io, result) {
|
|
|
720
747
|
lines.push(JSON.stringify(s, null, 2));
|
|
721
748
|
return;
|
|
722
749
|
}
|
|
723
|
-
lines.push(`bravos setup ${s.done}/${s.total} for ${inputs.repo}
|
|
750
|
+
lines.push(`bravos setup ${s.done}/${s.total} for ${inputs.repo}`);
|
|
751
|
+
// Which plan this machine is on, so the Team-plan steps below read as a choice and not a fault.
|
|
752
|
+
try {
|
|
753
|
+
if (inputs.licence?.state)
|
|
754
|
+
lines.push((await licenceLib()).planLine(inputs.licence));
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
/* no plan line */
|
|
758
|
+
}
|
|
759
|
+
lines.push('');
|
|
724
760
|
for (const item of s.items) {
|
|
725
761
|
const mark = item.on ? '✔' : item.unavailable ? '·' : item === s.next ? '→' : '✘';
|
|
726
762
|
lines.push(`${mark} ${item.label}${item.on ? '' : item.unavailable ? ' (not available here)' : ''}`);
|
|
@@ -748,6 +784,28 @@ export function buildProgram(io, result) {
|
|
|
748
784
|
const report = r.resync(root, opts.from, { apply: !!opts.apply, env: io.env });
|
|
749
785
|
lines.push(...(opts.json ? [JSON.stringify(report, null, 2)] : r.formatReport(report)));
|
|
750
786
|
}));
|
|
787
|
+
program
|
|
788
|
+
.command('dashboard [dir]')
|
|
789
|
+
.description("One page for the repository's security picture, opened in the browser: GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch, and on the Team plan the code graph (map, owners, coupling, attack surface, entry points). Written to .bravos/dashboard/index.html (git-ignored); one self-contained file, no server, no network, no model.")
|
|
790
|
+
.option('--out <file>', 'write the page here instead; nothing is then written inside the repository')
|
|
791
|
+
.option('--since <ref>', "compare against this branch, tag or commit instead of the repository's default branch")
|
|
792
|
+
.option('--no-blame', 'leave git names out (who introduced and fixed each exposure, and the code graph\'s owners), for a page you will share')
|
|
793
|
+
.option('--no-open', 'write the page and print its path without opening a browser')
|
|
794
|
+
.option('--json', 'print the result as JSON (bravos.dashboard-run/v1)')
|
|
795
|
+
.action((dir, opts) => guardedAsync(async (lines) => {
|
|
796
|
+
const root = dirArg(dir);
|
|
797
|
+
const { buildDashboard } = await import('./dashboard.js');
|
|
798
|
+
const r = await buildDashboard(root, io.env, { out: opts.out, since: opts.since, blame: opts.blame });
|
|
799
|
+
// Opening is a convenience: the path is always printed, and a session with no display just reads it.
|
|
800
|
+
const opened = opts.open !== false && !opts.json && openInBrowser(r.path, io.env);
|
|
801
|
+
if (opts.json) {
|
|
802
|
+
lines.push(JSON.stringify({ schema: 'bravos.dashboard-run/v1', path: r.path, opened, threatModel: r.threatModel, codeGraph: r.codeGraph }, null, 2));
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
lines.push(`Dashboard: ${r.path}${opened ? ' (opened in your browser)' : ''}`, ` threat model: ${r.threatModel.note}`, ` code graph: ${r.codeGraph.note}`);
|
|
806
|
+
if (!opened && opts.open !== false)
|
|
807
|
+
lines.push(' No browser could be opened here; open the file above.');
|
|
808
|
+
}));
|
|
751
809
|
program
|
|
752
810
|
.command('watch [dir]')
|
|
753
811
|
.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.')
|
|
@@ -982,7 +1040,7 @@ export function buildProgram(io, result) {
|
|
|
982
1040
|
if (opts.open) {
|
|
983
1041
|
const target = r.written.find((w) => w.format === 'pdf') ?? r.written.find((w) => w.format === 'html');
|
|
984
1042
|
if (target)
|
|
985
|
-
openInBrowser(target.path);
|
|
1043
|
+
openInBrowser(target.path, io.env);
|
|
986
1044
|
}
|
|
987
1045
|
lines.push('These files quote assessment evidence and are not committed; share them deliberately.');
|
|
988
1046
|
return;
|
|
@@ -1083,16 +1141,6 @@ function seconds(min) {
|
|
|
1083
1141
|
return n;
|
|
1084
1142
|
};
|
|
1085
1143
|
}
|
|
1086
|
-
// @comment -- "Opens a URL or file in the person's browser with the OS opener (argv, no shell); failure is silent because the URL is printed anyway."
|
|
1087
|
-
function openInBrowser(target) {
|
|
1088
|
-
const [cmd, args] = process.platform === 'darwin' ? ['open', [target]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', target]] : ['xdg-open', [target]];
|
|
1089
|
-
try {
|
|
1090
|
-
spawnChild(cmd, args, { detached: true, stdio: 'ignore' }).on('error', () => { }).unref();
|
|
1091
|
-
}
|
|
1092
|
-
catch {
|
|
1093
|
-
/* printed URL is enough */
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
1144
|
// @comment -- "Runs the CLI in-process and returns the exit code: 0 ok, 1 BravosError, 2 commander usage error."
|
|
1097
1145
|
export async function run(argv, io = {}) {
|
|
1098
1146
|
const full = {
|