@bugb-technologies/bravos 1.0.3 → 1.2.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 +7 -4
- package/dist/account.js +41 -5
- package/dist/artifacts.js +23 -10
- package/dist/ci.js +14 -1
- package/dist/cli.js +123 -13
- package/dist/device.js +124 -0
- package/dist/doctor.js +3 -0
- package/dist/guide.js +3 -3
- package/dist/help.js +17 -6
- package/dist/licence.js +6 -3
- package/dist/palette.js +100 -0
- package/dist/plugin-release.js +63 -13
- package/dist/setup.js +1 -1
- package/dist/start/answers.js +82 -0
- package/dist/start/index.js +442 -0
- package/dist/start/repos.js +78 -0
- package/dist/start/ui.js +219 -0
- package/dist/watch-frame.js +28 -16
- package/dist/watch.js +40 -1
- package/docs/GUIDE.md +6 -2
- package/hooks/lib/autopilot.mjs +3 -22
- package/hooks/lib/briefing.mjs +18 -15
- package/hooks/lib/palette.mjs +115 -0
- package/hooks/lib/pre-pr.mjs +1 -1
- package/hooks/lib/proving.mjs +25 -0
- package/hooks/lib/refresh.mjs +203 -0
- package/hooks/session-start.mjs +4 -1
- package/package.json +3 -1
- package/templates/omp/bravos.js +5 -0
package/dist/guide.js
CHANGED
|
@@ -25,7 +25,7 @@ export const GUIDE_TOPICS = [
|
|
|
25
25
|
{
|
|
26
26
|
name: 'Plans',
|
|
27
27
|
body: [
|
|
28
|
-
'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in one repository. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
|
|
28
|
+
'Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in one repository. Team, licensed per developer (Solo is one seat), adds the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph. The briefing opens every session with a Plan: line; bravos licence shows the same in a shell. bravos account activate signs you in once in the browser and writes the licence (a 30-day Team trial, no card, when the account has no plan); bravos account import <file> installs a downloaded one. On a team plan the licence is yours and this machine\'s: an owner or admin assigns you a licence, each machine you activate gets its own short-lived token that bravos renews automatically (at the session start and before a paid command), bravos account devices lists your machines, bravos account revoke <id> signs one out (a lost laptop), and bravos account logout signs this one out. Removing you from the team, or taking your licence back, stops every one of your machines at its next renewal. In CI, BRAVOS_LICENCE holds a CI licence an owner or admin creates for that repository, and the CLI never renews it. Without a licence a paid command explains what it would do and how to start the trial, a paid hook stands down with one line and never blocks, and a paid skill stops at its first step and says so.',
|
|
29
29
|
],
|
|
30
30
|
},
|
|
31
31
|
{
|
|
@@ -37,7 +37,7 @@ export const GUIDE_TOPICS = [
|
|
|
37
37
|
{
|
|
38
38
|
name: 'Installing',
|
|
39
39
|
body: [
|
|
40
|
-
'npm install -g @bugb-technologies/bravos (Node 20 or newer).
|
|
40
|
+
'npm install -g @bugb-technologies/bravos (Node 20 or newer), then bravos start: a guided setup that asks one question at a time (colours, licence, tools, repository, AI tools, PR checks, a scheduled run, how testing is allowed), shows every change, and writes nothing until you choose Apply. It ends with the one thing to type in your agent.', 'By hand instead: bravos account activate signs you in once in the browser and writes the licence — a 30-day Team trial when the account has no plan; skip it to stay on Free — bravos init in a repository writes the skills, hooks and MCP wiring, and bravos setup puts the analyzer and the code graph on the machine (Team plan). guardlink and cxg come from bravos setup --tools -y, or npm and cargo by hand. If you used the Python bravos, rename its command so bravos means this one: mv ~/.local/bin/bravos ~/.local/bin/bravos-py (this CLI still finds its code graph and analyzer), or remove it with pipx or uv.',
|
|
41
41
|
],
|
|
42
42
|
},
|
|
43
43
|
{
|
|
@@ -187,7 +187,7 @@ export const GUIDE_TOPICS = [
|
|
|
187
187
|
{ name: 'Cursor', body: ['.cursor/rules/bravos.mdc points at the skills when the repo has a .cursor/ folder.'] },
|
|
188
188
|
{ name: 'VS Code (Copilot agent)', body: ['Reads hooks from .claude/settings.json (preview), so the briefing can load there too.'] },
|
|
189
189
|
{ name: 'Every repo, or one copy of each skill', body: ['bravos init --global installs for your user: skills in ~/.claude/skills (linked from ~/.agents/skills) and a user hook that briefs repos with a threat model but no bravos install. bravos sync --link-skills makes a repo\'s .agents/skills a link to .claude/skills, so tools that read both (Warp) list each skill once.'] },
|
|
190
|
-
{ name: 'Banner switches', body: ['BRAVOS_BANNER=off hides it; BRAVOS_BANNER_COLOR=off or NO_COLOR prints it plain. The briefing for the model is unchanged either way.'] },
|
|
190
|
+
{ name: 'Banner switches', body: ['BRAVOS_BANNER=off hides it; BRAVOS_BANNER_COLOR=off or NO_COLOR prints it plain. The briefing for the model is unchanged either way.', 'Light terminal? BRAVOS_THEME=light (or dark, or neutral) picks the colours for the banner and bravos watch; otherwise COLORFGBG, the choice saved by bravos start, then neutral. bravos doctor shows which, and the c key in bravos watch switches.'] },
|
|
191
191
|
],
|
|
192
192
|
},
|
|
193
193
|
];
|
package/dist/help.js
CHANGED
|
@@ -53,10 +53,13 @@ Commands
|
|
|
53
53
|
graph --json lists every question this machine's binary answers.
|
|
54
54
|
licence Which plan this machine is on, where the licence is, what it unlocks
|
|
55
55
|
(--json: bravos.licence/v1). 'license' works too.
|
|
56
|
-
account <activate|import FILE|status>
|
|
56
|
+
account <activate|import FILE|status|refresh|devices|revoke ID|logout>
|
|
57
57
|
activate: sign in once in the browser and get this machine its licence — a
|
|
58
|
-
30-day Team trial when the account has no plan, no card
|
|
59
|
-
licence
|
|
58
|
+
30-day Team trial when the account has no plan, no card; on a team plan the
|
|
59
|
+
licence is yours, for this machine, and renews itself. import: install a
|
|
60
|
+
licence downloaded from account.bugb.io/dashboard/license. refresh: renew
|
|
61
|
+
now. devices: your signed-in machines. revoke ID: sign one out. logout: sign
|
|
62
|
+
this machine out and remove its licence.
|
|
60
63
|
guide [topic] How to use bravos: by role, by task, every skill, the safety rules.
|
|
61
64
|
Topics: start, roles, tasks, skills, states, safety, harnesses, all.
|
|
62
65
|
Run 'bravos <command> --help' for every flag and what it writes.
|
|
@@ -68,8 +71,9 @@ Plans
|
|
|
68
71
|
workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph.
|
|
69
72
|
A paid command or flag without a licence says what it would do and how to start the trial;
|
|
70
73
|
a paid hook stands down with one line and never blocks. The licence is an offline-verified
|
|
71
|
-
token: BRAVOS_LICENCE,
|
|
72
|
-
|
|
74
|
+
token: BRAVOS_LICENCE (in CI, a CI licence from the account portal), or licence.jwt in
|
|
75
|
+
$BRAVOS_HOME (default ~/.bravos), renewed automatically for a signed-in machine. Grace after
|
|
76
|
+
expiry is min(14 days, a quarter of the term). Seats are licences an owner or admin assigns.
|
|
73
77
|
|
|
74
78
|
The skills it installs (one folder each in .claude/skills/ and .agents/skills/)
|
|
75
79
|
bravos Start here: reads the briefing, explains the loop, routes to the rest.
|
|
@@ -112,7 +116,10 @@ Session start
|
|
|
112
116
|
state, and a short introduction while .guardlink/intent.md is missing. Claude Code shows
|
|
113
117
|
it above the first prompt; Codex shows it as a hook message. BRAVOS_BANNER=off hides it;
|
|
114
118
|
the briefing still reaches the model. The banner uses bravos's brand colours (truecolor);
|
|
115
|
-
NO_COLOR or BRAVOS_BANNER_COLOR=off prints it plain.
|
|
119
|
+
NO_COLOR or BRAVOS_BANNER_COLOR=off prints it plain. Colours follow the terminal's
|
|
120
|
+
background: BRAVOS_THEME=light|dark|neutral, else COLORFGBG, else the choice saved by
|
|
121
|
+
bravos start, else neutral (readable on light and dark); bravos doctor says which.
|
|
122
|
+
Codex lists a hook message as a
|
|
116
123
|
warning, so there it is a two-line summary instead of the art. Since 0.5.0 the hook is registered with
|
|
117
124
|
--harness claude or --harness codex so the banner prints /skill or $skill; sync migrates
|
|
118
125
|
the older entry, and Codex asks you to trust the changed hook once (/hooks).
|
|
@@ -176,10 +183,14 @@ Rules every skill follows
|
|
|
176
183
|
a gate exited 0.
|
|
177
184
|
|
|
178
185
|
Typical first run
|
|
186
|
+
bravos start # guided: licence, tools, repo, agents, PR checks,
|
|
187
|
+
# schedule, testing permission; nothing changes until Apply
|
|
188
|
+
Or by hand
|
|
179
189
|
bravos doctor # what is installed, what is missing
|
|
180
190
|
bravos init --dry-run # preview every write
|
|
181
191
|
bravos init # install; then open a Claude Code or Codex session
|
|
182
192
|
bravos sync --ci --pre-pr-hook # later: add CI and the pre-PR gate
|
|
193
|
+
bravos sync --workflows nightly-claude --schedule weekly # a weekly nightly only
|
|
183
194
|
In Codex, run /hooks once to trust .codex/hooks.json.
|
|
184
195
|
|
|
185
196
|
Exit codes
|
package/dist/licence.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @comment -- "The CLI's view of the licence: a typed wrapper over hooks/lib/licence.mjs (the one implementation, shared with the session hooks), plus the gate every paid command calls. Nothing here verifies on its own; it asks the library and turns a refusal into a BravosError the person can act on."
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { refresh } from './device.js';
|
|
4
5
|
import { hooksDir } from './paths.js';
|
|
5
6
|
import { BravosError } from './types.js';
|
|
6
7
|
let cached = null;
|
|
@@ -8,13 +9,15 @@ export const licenceLib = () => (cached ??= import(pathToFileURL(join(hooksDir()
|
|
|
8
9
|
export async function licenceStatus(env) {
|
|
9
10
|
return (await licenceLib()).status(env);
|
|
10
11
|
}
|
|
11
|
-
// @comment -- "The gate: returns the status when `feature` is unlocked, else throws a BravosError whose message says what `what` does, that it is on the Team plan, and how to start the trial or renew. Every paid command and flag goes through here, so a refusal always reads the same."
|
|
12
|
-
export async function requireFeature(env, feature, what) {
|
|
12
|
+
// @comment -- "The gate: first renews this machine's device licence when it is due (hooks/lib/refresh.mjs; fail-open, never for a token from the environment), then returns the status when `feature` is unlocked, else throws a BravosError whose message says what `what` does, that it is on the Team plan, and how to start the trial or renew — prefixed with why, when the renewal found this machine is no longer licensed. Every paid command and flag goes through here, so a refusal always reads the same."
|
|
13
|
+
export async function requireFeature(env, feature, what, io = {}) {
|
|
13
14
|
const L = await licenceLib();
|
|
15
|
+
const renewed = await refresh({ env, fetch: io.fetch });
|
|
14
16
|
const v = L.status(env);
|
|
15
17
|
if (L.entitled(v, feature))
|
|
16
18
|
return v;
|
|
17
|
-
|
|
19
|
+
const why = renewed.outcome === 'revoked' || renewed.outcome === 'lapsed' ? `${renewed.note} ` : '';
|
|
20
|
+
throw new BravosError(why + L.refusal(v, feature, what));
|
|
18
21
|
}
|
|
19
22
|
/** The JSON document `bravos licence --json` prints: the status without the tenant id (an account id is not for logs). */
|
|
20
23
|
export function licenceDocument(v) {
|
package/dist/palette.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @comment -- "bravos watch's copy of hooks/lib/palette.mjs: the same three themes and fixed pairs, typed and synchronous for the frame renderer. tests/palette.test.ts fails if the two ever differ, so there is still one palette."
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
export const THEMES = {
|
|
6
|
+
dark: {
|
|
7
|
+
green: '#33d49d', blue: '#0360a2', light: '#f0f0f0', steel: '#55899e', red: '#ea1d1d',
|
|
8
|
+
slate: '#3b6779', amber: '#f0b429', line: '#2b4f5c',
|
|
9
|
+
},
|
|
10
|
+
light: {
|
|
11
|
+
green: '#0f7a55', blue: '#0360a2', light: null, steel: '#3f6576', red: '#c41616',
|
|
12
|
+
slate: '#4d6b78', amber: '#9a6400', line: '#7d98a3',
|
|
13
|
+
},
|
|
14
|
+
neutral: {
|
|
15
|
+
green: '#1e9a6c', blue: '#2f7fc1', light: null, steel: '#4f8296', red: '#e02424',
|
|
16
|
+
slate: '#5a7d8b', amber: '#b07a00', line: '#5a7d8b',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const FIXED = {
|
|
20
|
+
green: '#33d49d', blue: '#0360a2', light: '#f0f0f0', steel: '#55899e', red: '#dc1f1f',
|
|
21
|
+
slate: '#3b6779', amber: '#f0b429', line: '#2b4f5c', ink: '#0e1b21', deep: '#1f3943', white: '#ffffff',
|
|
22
|
+
};
|
|
23
|
+
export const THEME_NAMES = ['dark', 'light', 'neutral'];
|
|
24
|
+
export const isTheme = (t) => THEME_NAMES.includes(t);
|
|
25
|
+
/** The next theme in the cycle the watch `t` key steps through. */
|
|
26
|
+
export const nextTheme = (t) => THEME_NAMES[(THEME_NAMES.indexOf(t) + 1) % THEME_NAMES.length];
|
|
27
|
+
/**
|
|
28
|
+
* A segment's foreground: from the theme when it sits on the terminal's own background,
|
|
29
|
+
* from FIXED when it sits on a background of its own (a badge, a key chip, the header bar),
|
|
30
|
+
* because that pair is the same in every theme. Null: the terminal's default foreground.
|
|
31
|
+
*/
|
|
32
|
+
export function fgFor(theme, role, onOwnBackground) {
|
|
33
|
+
if (onOwnBackground)
|
|
34
|
+
return FIXED[role] ?? null;
|
|
35
|
+
const t = THEMES[theme];
|
|
36
|
+
return role in t ? t[role] : FIXED[role] ?? null;
|
|
37
|
+
}
|
|
38
|
+
export const bgFor = (role) => FIXED[role] ?? null;
|
|
39
|
+
/* ------------------------------------------------------------------ choosing a theme */
|
|
40
|
+
/** Where Bravos keeps its own settings: $BRAVOS_HOME, else ~/.bravos. */
|
|
41
|
+
export const bravosHome = (env = process.env) => env.BRAVOS_HOME || join(env.HOME || homedir(), '.bravos');
|
|
42
|
+
/** The theme saved by `bravos start` ($BRAVOS_HOME/config.json), or null. Never throws. */
|
|
43
|
+
export function savedTheme(env = process.env) {
|
|
44
|
+
try {
|
|
45
|
+
const file = join(bravosHome(env), 'config.json');
|
|
46
|
+
if (!existsSync(file))
|
|
47
|
+
return null;
|
|
48
|
+
const t = JSON.parse(readFileSync(file, 'utf8'))?.theme;
|
|
49
|
+
return isTheme(t) ? t : null;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** COLORFGBG "fg;bg": a background of 7 or 15 is light, 0–6 or 8 dark. */
|
|
56
|
+
export function themeFromColorFgBg(value) {
|
|
57
|
+
if (!value)
|
|
58
|
+
return null;
|
|
59
|
+
const bg = Number(String(value).split(';').pop());
|
|
60
|
+
if (!Number.isInteger(bg))
|
|
61
|
+
return null;
|
|
62
|
+
if (bg === 7 || bg === 15)
|
|
63
|
+
return 'light';
|
|
64
|
+
if ((bg >= 0 && bg <= 6) || bg === 8)
|
|
65
|
+
return 'dark';
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/** An OSC 11 answer ("rgb:ffff/ffff/ffff" or "#rrggbb") as a theme, or null. */
|
|
69
|
+
export function themeFromBackground(answer) {
|
|
70
|
+
if (!answer)
|
|
71
|
+
return null;
|
|
72
|
+
let rgbv;
|
|
73
|
+
const m = /rgb:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i.exec(answer);
|
|
74
|
+
if (m)
|
|
75
|
+
rgbv = [m[1], m[2], m[3]].map((h) => parseInt(h, 16) / (16 ** h.length - 1));
|
|
76
|
+
else {
|
|
77
|
+
const h = /#([0-9a-f]{6})/i.exec(answer);
|
|
78
|
+
if (!h)
|
|
79
|
+
return null;
|
|
80
|
+
rgbv = [0, 2, 4].map((i) => parseInt(h[1].slice(i, i + 2), 16) / 255);
|
|
81
|
+
}
|
|
82
|
+
const lum = 0.2126 * rgbv[0] + 0.7152 * rgbv[1] + 0.0722 * rgbv[2];
|
|
83
|
+
return lum > 0.5 ? 'light' : 'dark';
|
|
84
|
+
}
|
|
85
|
+
/** Same order as hooks/lib/palette.mjs resolveTheme: BRAVOS_THEME, the terminal's answer, COLORFGBG, the saved choice, neutral. */
|
|
86
|
+
// @comment -- "Theme choice for bravos watch and doctor, in the same order as the hook's: BRAVOS_THEME, the terminal's own answer, COLORFGBG, the saved choice, neutral"
|
|
87
|
+
export function resolveTheme(env = process.env, detected = null) {
|
|
88
|
+
const asked = String(env.BRAVOS_THEME ?? '').toLowerCase();
|
|
89
|
+
if (isTheme(asked))
|
|
90
|
+
return { theme: asked, source: 'BRAVOS_THEME' };
|
|
91
|
+
if (detected && isTheme(detected))
|
|
92
|
+
return { theme: detected, source: 'terminal' };
|
|
93
|
+
const fgbg = themeFromColorFgBg(env.COLORFGBG);
|
|
94
|
+
if (fgbg)
|
|
95
|
+
return { theme: fgbg, source: 'COLORFGBG' };
|
|
96
|
+
const saved = savedTheme(env);
|
|
97
|
+
if (saved)
|
|
98
|
+
return { theme: saved, source: 'saved by bravos start' };
|
|
99
|
+
return { theme: 'neutral', source: 'default (background unknown)' };
|
|
100
|
+
}
|
package/dist/plugin-release.js
CHANGED
|
@@ -16,16 +16,19 @@ const KEYWORDS = ['security', 'threat-modeling', 'guardlink', 'pentest', 'cxg',
|
|
|
16
16
|
const SESSION_MATCHER = 'startup|resume|clear|compact';
|
|
17
17
|
const json = (v) => Buffer.from(JSON.stringify(v, null, 2) + '\n');
|
|
18
18
|
const text = (s) => Buffer.from(s.endsWith('\n') ? s : s + '\n');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
// @comment -- "The hook files a plugin ships: the session-start script and every file it imports, followed through relative imports. Plugins register only SessionStart; the pre-PR gate and autopilot run through the installed CLI (bravos hook), so their scripts are not shipped where a reviewer would have to read them."
|
|
20
|
+
export function hookClosure(hooks, entry = 'session-start.mjs') {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const visit = (abs) => {
|
|
23
|
+
if (seen.has(abs))
|
|
24
|
+
return;
|
|
25
|
+
seen.add(abs);
|
|
26
|
+
const src = readFileSync(abs, 'utf8');
|
|
27
|
+
for (const m of src.matchAll(/(?:from\s+|import\s*\(\s*)['"](\.{1,2}\/[^'"]+)['"]/g))
|
|
28
|
+
visit(join(dirname(abs), m[1]));
|
|
29
|
+
};
|
|
30
|
+
visit(join(hooks, entry));
|
|
31
|
+
return [...seen].sort();
|
|
29
32
|
}
|
|
30
33
|
const guardlinkServer = () => ({ type: 'stdio', command: SERVERS.guardlink.command, args: [...SERVERS.guardlink.args] });
|
|
31
34
|
// @comment -- "Every file of the public plugin repository, computed and not written. Skills: Claude Code's copy uses ${CLAUDE_SKILL_DIR} and ${CLAUDE_PLUGIN_ROOT}, which it substitutes; every other copy uses the portable SKILL_DIR wording. In every copy a skill's `node .bravos/hooks/<hook>.mjs` is `bravos hook <hook>`, because a plugin install has no .bravos/hooks/. Session hooks are registered where the harness's plugin format and SessionStart output are known: Claude Code, Codex, Gemini CLI and Antigravity. Copilot, VS Code and Cursor get the skills and MCP, and the bravos skill loads the briefing itself."
|
|
@@ -35,7 +38,7 @@ export function releaseFiles(opts = {}) {
|
|
|
35
38
|
const add = (path, content) => files.push({ path, content });
|
|
36
39
|
const skills = listBundledSkills(opts.skillsDir);
|
|
37
40
|
const hooks = opts.hooksDir ?? hooksDir();
|
|
38
|
-
const hookFiles =
|
|
41
|
+
const hookFiles = hookClosure(hooks);
|
|
39
42
|
const licence = opts.licence ?? readFileSync(join(packageRoot(), 'LICENSE'));
|
|
40
43
|
const addSkills = (prefix, render) => {
|
|
41
44
|
for (const skill of skills) {
|
|
@@ -50,14 +53,27 @@ export function releaseFiles(opts = {}) {
|
|
|
50
53
|
add(`${prefix}hooks/${relative(hooks, abs).split('\\').join('/')}`, readFileSync(abs));
|
|
51
54
|
};
|
|
52
55
|
const sessionGroup = (command) => ({ matcher: SESSION_MATCHER, hooks: [{ type: 'command', command, timeout: 30 }] });
|
|
56
|
+
// Claude's directory wants the interpreter in command and the file first in args, which also starts on Windows without a shell.
|
|
57
|
+
const sessionArgs = (file, harness) => ({ matcher: SESSION_MATCHER, hooks: [{ type: 'command', command: 'node', args: [file, '--harness', harness], timeout: 30 }] });
|
|
58
|
+
const icon = opts.icon ?? readFileSync(join(packageRoot(), 'assets', 'plugin-icon.png'));
|
|
53
59
|
const base = { name: NAME, version: v, description: DESCRIPTION, author: AUTHOR, homepage: HOMEPAGE, repository: REPOSITORY, license: LICENSE_ID, keywords: KEYWORDS };
|
|
54
60
|
// Claude Code: claude/, listed by .claude-plugin/marketplace.json.
|
|
55
61
|
addSkills('claude/', (c, rel) => viaCliHooks(renderPluginSkillFile(c, rel)));
|
|
56
62
|
addHookScripts('claude/');
|
|
57
|
-
add('claude/hooks/hooks.json', json({ hooks: { SessionStart: [
|
|
63
|
+
add('claude/hooks/hooks.json', json({ hooks: { SessionStart: [sessionArgs('${CLAUDE_PLUGIN_ROOT}/hooks/session-start.mjs', 'claude')] } }));
|
|
64
|
+
add('claude/.claude-plugin/icon.png', icon);
|
|
58
65
|
add('claude/.mcp.json', json({ mcpServers: { guardlink: SERVERS.guardlink } }));
|
|
59
|
-
|
|
66
|
+
// Claude's directory shows these links on the listing; the pages are the company site's own.
|
|
67
|
+
add('claude/.claude-plugin/plugin.json', json({
|
|
68
|
+
...base,
|
|
69
|
+
displayName: 'Bravos',
|
|
70
|
+
documentationUrl: HOMEPAGE,
|
|
71
|
+
supportUrl: 'https://www.bugb.io/contact',
|
|
72
|
+
privacyPolicyUrl: 'https://www.bugb.io/privacy',
|
|
73
|
+
termsOfServiceUrl: 'https://www.bugb.io/terms',
|
|
74
|
+
}));
|
|
60
75
|
add('claude/LICENSE', licence);
|
|
76
|
+
add('claude/README.md', text(readme(v)));
|
|
61
77
|
add('.claude-plugin/marketplace.json', json({
|
|
62
78
|
name: NAME,
|
|
63
79
|
owner: AUTHOR,
|
|
@@ -82,8 +98,11 @@ export function releaseFiles(opts = {}) {
|
|
|
82
98
|
capabilities: ['Read', 'Write'],
|
|
83
99
|
websiteURL: HOMEPAGE,
|
|
84
100
|
defaultPrompt: ['Where do I start on security here?', 'Threat-model this repository', 'Is this PR safe to open?'],
|
|
101
|
+
composerIcon: './assets/icon.png',
|
|
102
|
+
logo: './assets/icon.png',
|
|
85
103
|
},
|
|
86
104
|
}));
|
|
105
|
+
add('codex/assets/icon.png', icon);
|
|
87
106
|
add('codex/LICENSE', licence);
|
|
88
107
|
add('.agents/plugins/marketplace.json', json({
|
|
89
108
|
name: NAME,
|
|
@@ -128,12 +147,14 @@ export function releaseFiles(opts = {}) {
|
|
|
128
147
|
add('.antigravity-plugin/plugin.json', json({
|
|
129
148
|
...base,
|
|
130
149
|
displayName: 'Bravos',
|
|
150
|
+
logo: 'assets/icon.png',
|
|
131
151
|
suggestedPrompts: ['Where do I start on security here?', 'Threat-model this repository', 'Is this PR safe to open?'],
|
|
132
152
|
}));
|
|
133
153
|
add('hooks.json', json({ bravos: { SessionStart: [{ type: 'command', command: 'node hooks/session-start.mjs --harness agy', timeout: 30 }] } }));
|
|
134
154
|
// Antigravity loads a plugin's context only from rules/; GEMINI.md is Gemini CLI's.
|
|
135
155
|
add('rules/bravos.md', text(GEMINI_CONTEXT));
|
|
136
156
|
add('mcp_config.json', json({ mcpServers: { guardlink: { command: SERVERS.guardlink.command, args: [...SERVERS.guardlink.args] } } }));
|
|
157
|
+
add('assets/icon.png', icon);
|
|
137
158
|
add('LICENSE', licence);
|
|
138
159
|
add('README.md', text(readme(v)));
|
|
139
160
|
return files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
@@ -177,6 +198,35 @@ Then install the plugin for your agent:
|
|
|
177
198
|
You do not need a plugin: \`bravos init\` in a repository installs the same skills,
|
|
178
199
|
hooks and MCP wiring for every agent it finds, and commits them with the code.
|
|
179
200
|
|
|
201
|
+
## Where data goes
|
|
202
|
+
|
|
203
|
+
Bravos runs on your machine. Its skills, its session hook and the CLI they call
|
|
204
|
+
reach only these places:
|
|
205
|
+
|
|
206
|
+
- **account.bugb.io:**
|
|
207
|
+
- \`bravos account activate\` signs this machine in once, in the browser. The
|
|
208
|
+
portal records the machine under its name (its hostname), so you and your
|
|
209
|
+
team's owners and admins can see it and sign it out.
|
|
210
|
+
- While the machine is signed in, Bravos renews its licence there automatically,
|
|
211
|
+
every few days: the session hook or the CLI sends the machine's secret, and the
|
|
212
|
+
portal records the time, your CLI version and a one-way digest of your IP
|
|
213
|
+
address. Licences for CI and licences imported from a file are never renewed.
|
|
214
|
+
- \`bravos setup\` downloads the SAST analyzer and the code graph with your licence.
|
|
215
|
+
|
|
216
|
+
Your licence and machine details go there; your code does not.
|
|
217
|
+
- **GitHub:** the session briefing uses \`gh\`, if it is installed and signed in, to
|
|
218
|
+
list open pull requests in your repository. The CI workflows \`bravos sync --ci\`
|
|
219
|
+
writes run on GitHub Actions in your own repository.
|
|
220
|
+
- **A test target you own:** \`bravos-prove\` and \`bravos-recheck\` send test
|
|
221
|
+
requests through cxg. Loopback by default; any other host only with a reviewed
|
|
222
|
+
\`.guardlink/scope.yaml\` and your own typed authorization naming it.
|
|
223
|
+
- **A model API, only if you agree:** cxg can generate probes through a model API
|
|
224
|
+
you configure. The skill asks before it spends.
|
|
225
|
+
- **npm and crates.io:** \`bravos setup --tools\` installs guardlink and cxg.
|
|
226
|
+
|
|
227
|
+
The threat model, test results and reports stay in your repository. Bugb keeps
|
|
228
|
+
nothing from your sessions.
|
|
229
|
+
|
|
180
230
|
## Plans
|
|
181
231
|
|
|
182
232
|
The research loop is free for one researcher in one repository. The pre-PR gate
|
package/dist/setup.js
CHANGED
|
@@ -37,7 +37,7 @@ export async function runSetup(env, opts, io) {
|
|
|
37
37
|
const bundles = [...(pick.codegraph ? ['codegraph'] : []), ...(pick.analyzer ? ['analyzer'] : [])];
|
|
38
38
|
for (const kind of bundles) {
|
|
39
39
|
const what = `bravos setup --${kind}`;
|
|
40
|
-
await requireFeature(env, kind === 'analyzer' ? 'sast' : 'codegraph', what);
|
|
40
|
+
await requireFeature(env, kind === 'analyzer' ? 'sast' : 'codegraph', what, { fetch: io.fetch });
|
|
41
41
|
const have = staged(env, kind);
|
|
42
42
|
if (have && !opts.yes) {
|
|
43
43
|
lines.push(`${kind}: already staged at ${have} (add -y to fetch ${VERSIONS[kind]} again)`);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @comment -- "What bravos start asks and records: the answers, the three starting presets, the bravos init command they amount to, and the two files only start writes itself — the person's proving choice (.guardlink/proving.md, their words and name) and the saved answers (.bravos/setup.json, for --again)."
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
export const PRESETS = {
|
|
5
|
+
annotate: { label: 'Map my threats only', hint: 'annotations; nothing runs on its own', pr: 'none', autopilot: false, schedule: 'none', proving: 'none' },
|
|
6
|
+
pr: { label: 'Map threats and check every pull request', hint: 'no AI key needed', pr: 'hook+github', autopilot: false, schedule: 'none', proving: 'ask' },
|
|
7
|
+
everything: { label: 'Everything: annotations, PR checks and scheduled testing', hint: 'weekly nightly run, autopilot on', pr: 'hook+github', autopilot: true, schedule: 'weekly', proving: 'ask' },
|
|
8
|
+
};
|
|
9
|
+
/** Where the cost of one pentest is published; the continuous-pentest question links to it. */
|
|
10
|
+
export const PENTEST_COST_URL = 'https://bugb.io/pricing#pentest-cost';
|
|
11
|
+
/** The bravos init arguments these answers amount to (the review step prints them). */
|
|
12
|
+
// @comment -- "The init flags for the chosen answers: agents, the pre-PR hook, autopilot, which workflows and the nightly cadence, and the loopback scope starter when testing is on"
|
|
13
|
+
export function initArgs(a) {
|
|
14
|
+
const args = ['init', a.repo, '--agent', a.agents.join(',')];
|
|
15
|
+
if (a.pr !== 'none')
|
|
16
|
+
args.push('--pre-pr-hook');
|
|
17
|
+
if (a.autopilot)
|
|
18
|
+
args.push('--autopilot');
|
|
19
|
+
const workflows = [...(a.pr === 'hook+github' ? ['pr-gate'] : []), ...(a.schedule !== 'none' ? [`nightly-${a.nightlyAgent}`] : [])];
|
|
20
|
+
if (workflows.length)
|
|
21
|
+
args.push('--workflows', workflows.join(','));
|
|
22
|
+
if (a.schedule !== 'none')
|
|
23
|
+
args.push('--schedule', a.schedule);
|
|
24
|
+
if (a.proving !== 'none')
|
|
25
|
+
args.push('--scope');
|
|
26
|
+
return args;
|
|
27
|
+
}
|
|
28
|
+
/** The secrets and variables the nightly needs, by name. */
|
|
29
|
+
export function nightlySecrets(a) {
|
|
30
|
+
if (a.schedule === 'none')
|
|
31
|
+
return [];
|
|
32
|
+
return ['BRAVOS_LICENCE', a.nightlyAgent === 'codex' ? 'OPENAI_API_KEY' : 'ANTHROPIC_API_KEY'];
|
|
33
|
+
}
|
|
34
|
+
// @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
|
+
export function provingText(a, date) {
|
|
36
|
+
const quoted = a.words.trim().replace(/\s+/g, ' ').replace(/"/g, "'");
|
|
37
|
+
return [
|
|
38
|
+
'# How findings are proven',
|
|
39
|
+
'',
|
|
40
|
+
'Recorded by `bravos start` from the answers below. Edit it, or run `bravos start --again`, to change it.',
|
|
41
|
+
'',
|
|
42
|
+
`choice: ${a.proving}`,
|
|
43
|
+
`generation: ${a.generation ? 'yes' : 'no'}`,
|
|
44
|
+
'',
|
|
45
|
+
`"${quoted}"`,
|
|
46
|
+
'',
|
|
47
|
+
`— confirmed by ${a.name.trim()}, ${date}`,
|
|
48
|
+
'',
|
|
49
|
+
].join('\n');
|
|
50
|
+
}
|
|
51
|
+
export const SETUP_FILE = join('.bravos', 'setup.json');
|
|
52
|
+
export function readAnswers(root) {
|
|
53
|
+
try {
|
|
54
|
+
const p = join(root, SETUP_FILE);
|
|
55
|
+
return existsSync(p) ? (JSON.parse(readFileSync(p, 'utf8'))?.answers ?? null) : null;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Saved for --again; the person's words and name stay in proving.md, not here. */
|
|
62
|
+
export function writeAnswers(root, a, version, at) {
|
|
63
|
+
const p = join(root, SETUP_FILE);
|
|
64
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
65
|
+
const { words: _w, name: _n, ...kept } = a;
|
|
66
|
+
writeFileSync(p, JSON.stringify({ schema: 'bravos.start/v1', bravos_version: version, at, answers: kept }, null, 2) + '\n');
|
|
67
|
+
}
|
|
68
|
+
/** Saves the colour theme in $BRAVOS_HOME/config.json, keeping anything else in it. */
|
|
69
|
+
export function writeTheme(home, theme) {
|
|
70
|
+
const p = join(home, 'config.json');
|
|
71
|
+
let cfg = {};
|
|
72
|
+
try {
|
|
73
|
+
if (existsSync(p))
|
|
74
|
+
cfg = JSON.parse(readFileSync(p, 'utf8')) ?? {};
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
cfg = {};
|
|
78
|
+
}
|
|
79
|
+
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
80
|
+
writeFileSync(p, JSON.stringify({ ...cfg, theme }, null, 2) + '\n');
|
|
81
|
+
return p;
|
|
82
|
+
}
|