@bugb-technologies/bravos 1.18.0 → 1.22.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.
Files changed (45) hide show
  1. package/dist/account.js +19 -2
  2. package/dist/cli.js +133 -15
  3. package/dist/context.js +126 -3
  4. package/dist/cursor.js +4 -2
  5. package/dist/dashboard.js +9 -0
  6. package/dist/device.js +3 -1
  7. package/dist/doctor.js +4 -0
  8. package/dist/guide.js +7 -3
  9. package/dist/help.js +15 -8
  10. package/dist/instruction-blocks.js +257 -0
  11. package/dist/principles.js +279 -0
  12. package/dist/review-server.js +19 -4
  13. package/dist/review-wait.js +11 -0
  14. package/dist/review.js +342 -41
  15. package/dist/rules.js +82 -6
  16. package/dist/uninstall.js +9 -2
  17. package/docs/GUIDE.md +18 -2
  18. package/docs/UPGRADING.md +63 -0
  19. package/hooks/autopilot.mjs +2 -1
  20. package/hooks/cards.mjs +23 -5
  21. package/hooks/coach.mjs +3 -0
  22. package/hooks/invite.mjs +10 -0
  23. package/hooks/lib/audience.mjs +83 -0
  24. package/hooks/lib/briefing.mjs +83 -2
  25. package/hooks/lib/context.mjs +57 -1
  26. package/hooks/lib/display.mjs +11 -0
  27. package/hooks/lib/licence.mjs +2 -1
  28. package/hooks/lib/machine.mjs +77 -0
  29. package/hooks/lib/pre-pr.mjs +82 -1
  30. package/hooks/lib/principles.mjs +513 -0
  31. package/hooks/lib/refresh.mjs +11 -1
  32. package/hooks/lib/replay.mjs +218 -100
  33. package/hooks/pre-pr.mjs +3 -0
  34. package/hooks/session-start.mjs +35 -7
  35. package/package.json +1 -1
  36. package/skills/bravos/SKILL.md +1 -0
  37. package/skills/bravos-context/SKILL.md +4 -4
  38. package/skills/bravos-principles/SKILL.md +52 -0
  39. package/templates/dashboard/dashboard.html +75 -1
  40. package/templates/omp/bravos.js +10 -1
  41. package/templates/opencode/bravos.js +11 -2
  42. package/templates/review/review.html +140 -11
  43. package/templates/workflows/bravos-nightly-claude.yml +1 -1
  44. package/templates/workflows/bravos-nightly-codex.yml +1 -1
  45. package/templates/workflows/bravos-pr-gate.yml +1 -1
package/dist/rules.js CHANGED
@@ -16,7 +16,7 @@ export const STATUS_LABEL = {
16
16
  const arr = (v) => (Array.isArray(v) ? v : []);
17
17
  const bare = (id) => String(id ?? '').replace(/^#/, '');
18
18
  const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : null);
19
- // @comment -- "Reads the rules out of intent.md: every bullet that starts INV-n. What follows the last ' — ' is how it was decided (draft, or who agreed), a '(source: SRC-2 \"Report access\")' names the documents it came from, and the rest is the rule's text. Table rows and prose that mention a rule are not rules."
19
+ // @comment -- "Reads the rules out of intent.md: every bullet that starts INV-n. What follows the last ' — ' is how it was decided (draft, or who agreed), a '(source: SRC-2 \"Report access\")' names the documents it came from, a '(principle: SDP-1)' the company principle it carries out, and the rest is the rule's text. Table rows and prose that mention a rule are not rules."
20
20
  export function parseIntentRules(text) {
21
21
  const out = [];
22
22
  const seen = new Set();
@@ -33,7 +33,13 @@ export function parseIntentRules(text) {
33
33
  rest = rest.slice(0, dash).trim();
34
34
  }
35
35
  const sources = [];
36
+ const principles = [];
36
37
  rest = rest
38
+ .replace(/\(principles?:\s*([^)]*)\)/gi, (_all, inner) => {
39
+ for (const s of inner.matchAll(/\b(SDP-[1-9][0-9]{0,3})\b/g))
40
+ principles.push(s[1]);
41
+ return '';
42
+ })
37
43
  .replace(/\(source:\s*([^)]*)\)/gi, (_all, inner) => {
38
44
  for (const s of inner.matchAll(/\b(SRC-[1-9][0-9]{0,4})\b(?:\s*"([^"]{0,120})")?/g))
39
45
  sources.push({ id: s[1], section: s[2]?.trim() || null });
@@ -43,7 +49,7 @@ export function parseIntentRules(text) {
43
49
  .trim();
44
50
  const draft = /^draft\b/i.test(attribution) || attribution === '';
45
51
  const by = /\b(?:accepted|edited|chosen|set|confirmed) by\s+(.+)$/i.exec(attribution)?.[1]?.trim() ?? null;
46
- out.push({ id: m[1], text: rest.slice(0, 600), decided: draft ? 'draft' : 'confirmed', decidedBy: draft ? null : by, sources });
52
+ out.push({ id: m[1], text: rest.slice(0, 600), decided: draft ? 'draft' : 'confirmed', decidedBy: draft ? null : by, sources, principles });
47
53
  }
48
54
  return out;
49
55
  }
@@ -272,18 +278,81 @@ export async function gatherRules(root, env, opts = {}) {
272
278
  rules.push({ id: null, text: t.description || t.name || `#${t.id}`, decided: null, decidedBy: null, sources: t.refs.filter((r) => /^design:SRC-/i.test(r)).map((r) => source({ id: r.slice(7), section: null })), threat: `#${t.id}`, severity: t.severity, refs: t.refs, status: verdict.status, why: `${verdict.why} No item in intent.md stands behind this threat: confirm it there, or remove it.`, sites });
273
279
  }
274
280
  rules.sort((a, b) => STATUS_ORDER.indexOf(a.status) - STATUS_ORDER.indexOf(b.status) || String(a.id ?? '~').localeCompare(String(b.id ?? '~'), undefined, { numeric: true }));
281
+ // THE COMPANY'S PRINCIPLES: each adopted one joined to the threats that stand for it (principle:SDP-n, or an INV
282
+ // rule that names it), with the places under a live exception set aside, and what it has done lately.
283
+ const P = await (await import('./principles.js')).principlesLib();
284
+ const checked = P.checkPrinciples(P.treeReader(root));
285
+ const now = Date.now();
286
+ const within = (at, days) => {
287
+ const t = Date.parse(String(at ?? ''));
288
+ return Number.isFinite(t) && now - t <= days * 86400000;
289
+ };
290
+ const stops = gateStops(root, env);
291
+ const principles = [];
292
+ for (const p of checked.adopted) {
293
+ const fromRules = intentRules.filter((r) => r.principles.includes(p.id));
294
+ const ids = [...new Set([...threats.filter((t) => t.refs.some((r) => r.toLowerCase() === `principle:${p.id.toLowerCase()}`)).map((t) => t.id), ...fromRules.map((r) => threatFor(r.id)?.id).filter((x) => !!x)])].sort();
295
+ const exceptions = checked.exceptions.filter((e) => e.principle === p.id);
296
+ const sites = ids.flatMap((id) => sitesFor(id)).map((site) => {
297
+ const e = P.exceptionFor(exceptions, p.id, site.file);
298
+ return e ? { ...site, exception: { where: e.where, by: names ? e.by : '', until: e.until } } : site;
299
+ });
300
+ const active = sites.filter((x) => !('exception' in x && x.exception));
301
+ const verdict = p.kind === 'guidance'
302
+ ? { status: 'guidance', why: 'Guidance: coding agents follow it here; nothing is tested.' }
303
+ : !model
304
+ ? { status: 'not-placed', why: 'GuardLink is not installed here, so where this principle is enforced is not known.' }
305
+ : !ids.length
306
+ ? { status: 'not-placed', why: `No threat in the model stands for it yet: the next annotation pass adds one with the reference principle:${p.id} (or an INV rule names it).` }
307
+ : afterChanges(ruleStatus(active), active);
308
+ const mine = records.filter((r) => ids.includes(bare(r.threat)) && r.outcome?.at);
309
+ const count = (f) => [mine.filter((r) => f(r) && within(r.outcome.at, 30)).length, mine.filter((r) => f(r) && within(r.outcome.at, 90)).length];
310
+ const stopped = stops.filter((x) => x.principle === p.id);
311
+ principles.push({
312
+ id: p.id, kind: p.kind, statement: p.statement, scope: p.scope, adoptedBy: names ? p.adopters : null, threats: ids.map((id) => `#${id}`), rules: fromRules.map((r) => r.id),
313
+ status: verdict.status, why: `${verdict.why}${sites.length > active.length ? ` ${sites.length - active.length} place${sites.length - active.length === 1 ? ' is' : 's are'} under an approved exception.` : ''}`,
314
+ sites,
315
+ exceptions: exceptions.map((e) => ({ where: e.where, reason: e.reason, by: names ? e.by : '', approved: e.approved, until: e.until, live: P.live(e) })),
316
+ value: { tested: count(() => true), held: count((r) => r.outcome?.outcome === 'refuted'), caught: count((r) => r.outcome?.outcome === 'confirmed'), gateStops: [stopped.filter((x) => within(x.at, 30)).length, stopped.filter((x) => within(x.at, 90)).length], files: new Set(sites.map((x) => x.file)).size },
317
+ });
318
+ }
319
+ const order = (s) => (s === 'guidance' ? STATUS_ORDER.length : STATUS_ORDER.indexOf(s));
320
+ principles.sort((a, b) => order(a.status) - order(b.status) || Number(a.id.slice(4)) - Number(b.id.slice(4)));
321
+ const enforcedCount = principles.filter((p) => p.kind === 'enforced').length;
322
+ const principlesNote = !principles.length
323
+ ? checked.ok ? '' : `principles.md does not match what people adopted (${checked.problems.length} problem${checked.problems.length === 1 ? '' : 's'}): bravos principles check.`
324
+ : `${principles.length} security design principle${principles.length === 1 ? '' : 's'} adopted (${enforcedCount} enforced)${principles.filter((p) => p.status === 'broken').length ? `, ${principles.filter((p) => p.status === 'broken').length} broken` : ''}${checked.ok ? '' : `; principles.md does not match the adoptions: bravos principles check`}.`;
275
325
  const summary = { total: rules.length, draft: rules.filter((r) => r.decided === 'draft').length, broken: 0, 'retest-due': 0, holds: 0, unguarded: 0, 'guarded-untested': 0, 'not-placed': 0 };
276
326
  for (const r of rules)
277
327
  summary[r.status] += 1;
278
328
  if (!rules.length) {
279
- return { schema: 'bravos.rules/v1', state: 'none', note: 'No design rules are recorded yet. Run /bravos-context: it asks for your design documents and writes the rules they state (who may do what, what must never happen) into .guardlink/intent.md.', summary, rules };
329
+ return { schema: 'bravos.rules/v1', state: 'none', note: 'No design rules are recorded yet. Run /bravos-context: it asks for your design documents and writes the rules they state (who may do what, what must never happen) into .guardlink/intent.md.', summary, rules, principles, principlesNote };
280
330
  }
281
331
  if (!model)
282
- return { schema: 'bravos.rules/v1', state: 'no-guardlink', note: 'GuardLink is not installed on this machine, so the rules are listed without where the code enforces them: run bravos setup --tools -y, then bravos dashboard again.', summary, rules };
332
+ return { schema: 'bravos.rules/v1', state: 'no-guardlink', note: 'GuardLink is not installed on this machine, so the rules are listed without where the code enforces them: run bravos setup --tools -y, then bravos dashboard again.', summary, rules, principles, principlesNote };
283
333
  const said = STATUS_ORDER.filter((s) => summary[s]).map((s) => `${summary[s]} ${STATUS_LABEL[s]}`);
284
- return { schema: 'bravos.rules/v1', state: 'present', note: `${rules.length} design rule${rules.length === 1 ? '' : 's'} from the intent: ${said.join(', ')}${summary.draft ? `; ${summary.draft} still a draft nobody has confirmed` : ''}.`, summary, rules };
334
+ return { schema: 'bravos.rules/v1', state: 'present', note: `${rules.length} design rule${rules.length === 1 ? '' : 's'} from the intent: ${said.join(', ')}${summary.draft ? `; ${summary.draft} still a draft nobody has confirmed` : ''}.`, summary, rules, principles, principlesNote };
335
+ }
336
+ // @comment -- "The pre-PR gate's record of the times it stopped a change for breaking a principle, kept on this machine under the git directory (<git-common-dir>/bravos/principles-gate.jsonl, never committed): what the dashboard counts as the changes a principle stopped. Read-only, bounded; a missing or damaged file counts nothing."
337
+ export function gateStops(root, env) {
338
+ try {
339
+ const common = execFileSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], { cwd: root, env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 }).trim();
340
+ const text = readFileSync(join(common, 'bravos', 'principles-gate.jsonl'), 'utf8').slice(-256 * 1024);
341
+ return text.split('\n').flatMap((l) => {
342
+ try {
343
+ const j = JSON.parse(l);
344
+ return typeof j.at === 'string' && typeof j.principle === 'string' && /^SDP-\d+$/.test(j.principle) ? [{ at: j.at, principle: j.principle }] : [];
345
+ }
346
+ catch {
347
+ return [];
348
+ }
349
+ });
350
+ }
351
+ catch {
352
+ return [];
353
+ }
285
354
  }
286
- // @comment -- "bravos rules as lines: the note, then one line per rule with its status, id, text, sources and the places it is enforced."
355
+ // @comment -- "bravos rules as lines: the note, then one line per rule with its status, id, text, sources and the places it is enforced; then the adopted security design principles the same way."
287
356
  export function formatRules(doc) {
288
357
  const lines = [doc.note];
289
358
  for (const r of doc.rules) {
@@ -292,5 +361,12 @@ export function formatRules(doc) {
292
361
  for (const s of r.sites)
293
362
  lines.push(`${' '.repeat(19)}${s.kind === 'grant' ? 'granted in' : s.kind === 'gap' ? 'no control at' : 'enforced at'} ${s.file}${s.line ? `:${s.line}` : ''}${s.state ? ` — ${SITE_WORD[s.state]}` : ''}`);
294
363
  }
364
+ if (doc.principlesNote)
365
+ lines.push('', doc.principlesNote);
366
+ for (const p of doc.principles ?? []) {
367
+ lines.push(`${(p.status === 'guidance' ? 'guidance' : STATUS_LABEL[p.status]).padEnd(18)} ${p.id.padEnd(7)} ${p.statement}`);
368
+ for (const s of p.sites)
369
+ lines.push(`${' '.repeat(19)}${s.kind === 'grant' ? 'granted in' : s.kind === 'gap' ? 'no control at' : 'enforced at'} ${s.file}${s.line ? `:${s.line}` : ''}${s.exception ? ` — under an exception until ${s.exception.until}` : s.state ? ` — ${SITE_WORD[s.state]}` : ''}`);
370
+ }
295
371
  return lines;
296
372
  }
package/dist/uninstall.js CHANGED
@@ -2,6 +2,7 @@ import { existsSync, lstatSync, readFileSync, readdirSync, readlinkSync, rmdirSy
2
2
  import { dirname, join } from 'node:path';
3
3
  import { LOCK_PATH, readLock, sha256 } from './lock.js';
4
4
  import { removePrePush } from './context.js';
5
+ import { removeInstructionBlocks } from './instruction-blocks.js';
5
6
  import { BravosError } from './types.js';
6
7
  const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
7
8
  // Any command bravos registers: the per-repo relative forms and the user-level absolute one.
@@ -88,10 +89,10 @@ function pruneEmpty(root, rel) {
88
89
  dir = dirname(dir);
89
90
  }
90
91
  }
91
- // @comment -- "Removes what bravos installed under root: every file its lock records that is unchanged (edited ones are kept and listed unless --force), bravos's hook entries in .claude/settings.json, .codex/hooks.json and .cursor/hooks.json, its group in .agents/hooks.json, its pre_pr entry in .guardlink/config.json, and .bravos/ itself; with home set, also the ~/.agents/skills/bravos* links. Never removes guardlink's own files, a reviewed scope.yaml, or MCP entries (which may predate bravos); those are listed. Hooks files are validated before anything is removed."
92
+ // @comment -- "Removes what bravos installed under root: every file its lock records that is unchanged (edited ones are kept and listed unless --force), the Bravos block in the shared instruction files, bravos's hook entries in .claude/settings.json, .codex/hooks.json and .cursor/hooks.json, its group in .agents/hooks.json, its pre_pr entry in .guardlink/config.json, and .bravos/ itself; with home set, also the ~/.agents/skills/bravos* links. Never removes guardlink's own files, a reviewed scope.yaml, or MCP entries (which may predate bravos); those are listed. Hooks files are validated before anything is removed."
92
93
  export function uninstall(root, opts = {}) {
93
94
  const dryRun = !!opts.dryRun;
94
- const report = { removed: [], kept: [], unregistered: [], notes: [] };
95
+ const report = { removed: [], kept: [], unregistered: [], unblocked: [], notes: [] };
95
96
  if (!existsSync(join(root, '.bravos'))) {
96
97
  throw new BravosError(`bravos is not installed in ${root} (no .bravos/ folder); nothing was removed`);
97
98
  }
@@ -150,6 +151,12 @@ export function uninstall(root, opts = {}) {
150
151
  report.notes.push('run guardlink sync to drop the gate from the agent instruction files');
151
152
  }
152
153
  }
154
+ // @comment -- "The Bravos block comes out of the shared instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, Copilot's) and every other line stays; a file that held only the block is deleted. Windsurf's rule went with the lock pass above."
155
+ if (!opts.home) {
156
+ const b = removeInstructionBlocks(root, { dryRun });
157
+ report.unblocked.push(...b.cleaned);
158
+ report.removed.push(...b.deleted);
159
+ }
153
160
  if (opts.home) {
154
161
  const dir = join(root, '.agents', 'skills');
155
162
  let entries = [];
package/docs/GUIDE.md CHANGED
@@ -16,13 +16,15 @@ A hook gathers the repo's security picture (open exposures, confirmed exploits,
16
16
 
17
17
  Every agent shows the same Bravos picture, through the best channel it has. Claude Code shows the banner above the first prompt, and Gemini shows it at session start. omp shows it above the editor until your first prompt. Codex shows the Bravos card (the banner without the logo) with your first message. Cursor and opencode cannot draw anything at launch, so the agent opens its first reply with the card. Antigravity gets the briefing for the model only. Anywhere else, the bravos skill loads the briefing when you run it.
18
18
 
19
+ Teammates without Bravos: the hooks travel with the repository, but on a machine without Bravos (no bravos command, licence or plugin) they show only an invitation, once per session: the repository's own numbers from the committed threat model and the one command to join. Nothing else runs for them: no briefing, coach, threat cards, checks or background work, and nothing is sent anywhere. Their agent offers setup once and runs it only on a yes; "not now" hides it for 7 days in that clone (node .bravos/hooks/invite.mjs snooze). A team switches it off with {"invite": "off"} in .bravos/config.json.
20
+
19
21
  ### Running a skill
20
22
 
21
23
  Claude Code and opencode: /bravos-ship. Codex: $bravos-ship. omp: /skill:bravos-ship. Elsewhere, ask for it by name ("use the bravos-ship skill"). You can also just say what you want ("is this PR safe to open?") and the agent picks the skill.
22
24
 
23
25
  ### Plans
24
26
 
25
- Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. 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.
27
+ Free (researcher) needs no licence: context, annotate, templatize, env, prove, recheck, report and watch, in each repository on its own, with no limit on how many. 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. At activation and at each renewal bravos sends the account portal a one-way fingerprint of the machine (a hash of the operating system machine id, never the id itself, and none in a container or CI), which the portal uses to allow one free trial per person and machine. 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.
26
28
 
27
29
  ### Effort
28
30
 
@@ -108,6 +110,12 @@ Skills: `/bravos-context`
108
110
 
109
111
  Give bravos-context your PRDs, design documents or an earlier threat model, as files or links. Each is kept in the repository as Markdown under .bravos/context/ (bravos context add; committed, so the team can keep it current) after a check for secrets and local paths; a link is kept beside its snapshot. Every rule then names the document it came from (INV-4, source: SRC-2), including who may do what: "sales may see every report except the revenue report" becomes a rule that can be tested, where a scan would see nothing wrong. bravos context list shows the documents, bravos context check re-checks them, and a pre-push check stops a push that would send a secret in one. Free; the CLI runs no model and fetches nothing: your agent converts and fetches with your own access.
110
112
 
113
+ ### Write down your company's security design principles
114
+
115
+ Skills: `/bravos-principles`
116
+
117
+ Ask for "our security design principles". bravos-principles proposes candidates only from your stored documents (cited by section, checked against the text), INV rules a person already confirmed in this or another repository, or an optional starter list mapped to OWASP ASVS 4.0.3, which is never pre-selected; bravos review principles refuses anything else. On the page each principle is its own decision (Agree, Change the wording, or No); there is no adopt-all. Confirm records your adoption with the exact wording and a fingerprint, and bravos writes .guardlink/principles.md from the adoptions: committed, so every developer who pulls gets it, and the Bravos block in AGENTS.md and CLAUDE.md tells every coding agent to read and follow it and never edit it. A principle is enforced (it becomes a threat with principle:SDP-n, is tested, and the pre-PR gate stops a change that breaks it, whatever the PR body says) or guidance (followed, not tested). bravos principles check (free; the pre-push hook and the gate run it) fails a hand-edited line, an adoption nobody made, or an exception past its date. An exception is approved by a person at their own terminal: bravos principles except SDP-n --where "<glob>" --reason "<why>" --until <date>, at most a year, never extended; a coding agent cannot run it. bravos principles copy --from <repository> takes the same set into another repository, and check says when the source changes. The dashboard's Security design view shows each principle, where it is enforced, its exceptions, and what it caught or stopped in the last 30 and 90 days. Team plan for authoring, the gate and the view; adopted principles are followed on every plan.
118
+
111
119
  ### See which design rules hold
112
120
 
113
121
  Skills: `/bravos` · `/bravos-recheck`
@@ -118,7 +126,7 @@ bravos rules lists every rule your design states (INV-n in the intent) with its
118
126
 
119
127
  Skills: `/bravos-context` · `/bravos-annotate`
120
128
 
121
- Annotation starts in the first session. With no confirmed intent, the agent drafts what the product is for from the README, docs and code (.guardlink/intent.md, every item marked draft), annotates against that draft, and opens the intake page without waiting. Each session asks once for a person to confirm it (bravos review intent, a few minutes) until someone confirms or declines; the agent never confirms for you. Rules drafted from the design are tested and can block a pull request right away; bravos rules and the block message label them draft until a person confirms them. When the answers arrive, the agent re-judges what they changed: an item you mark intended by design is annotated as intended, not as a finding. A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent and ends the asking; a coding agent is told never to decline for you. bravos context gate says which state a repository is in.
129
+ Annotation starts in the first session. With no confirmed intent, the agent drafts what the product is for from the README, docs and code (.guardlink/intent.md, every item marked draft), annotates against that draft, and opens the intake page without waiting. Each session asks once for a person to confirm it (bravos review intent, a few minutes) until someone confirms or declines; the agent never confirms for you. Rules drafted from the design are tested and can block a pull request right away; bravos rules and the block message label them draft until a person confirms them. When the answers arrive, the agent re-judges what they changed: an item you mark intended by design is annotated as intended, not as a finding. The intake page brings back the answers each person gave when they reopen it, and saves them as they go; only Confirm makes them count, and it records who and when. Design documents (a PRD, a design document, an earlier threat model) can be added on the page itself: Markdown and text are stored with the usual checks, and a PDF, Word file, slides or link waits for the agent to convert. Every rule cites the section of the document it came from, the page shows that passage under the question, and bravos context check refuses a section the document does not have. The intake and the documents are committed so the team gets them on their next pull; bravos doctor warns when a .gitignore rule keeps them on one machine, and bravos context share --yes narrows a blanket .bravos/ rule. A team that chooses to go without records that under a name, bravos context decline --by "<name>", which is committed like the intent and ends the asking; a coding agent is told never to decline for you. bravos context gate says which state a repository is in.
122
130
 
123
131
  ### Updates
124
132
 
@@ -302,6 +310,10 @@ Licensed static analysis joined to guardlink claims and reachability; gates on f
302
310
 
303
311
  "Identify all the threats": maps the attack surface with the code graph, runs SAST, records every finding in the threat model with bravos-annotate, rebuilds the dashboard and reports from what was recorded, then recommends confirming the top three.
304
312
 
313
+ ### bravos-principles
314
+
315
+ Your company's security design principles, from your own documents and confirmed rules (or an optional starter list mapped to OWASP ASVS): proposed on the review page, adopted one by one by named people, written by bravos to .guardlink/principles.md, followed by every coding agent, and enforced ones tested and held to by the pre-PR gate.
316
+
305
317
  ### bravos-campaign
306
318
 
307
319
  A goal over many rounds: disjoint batches, one subagent each, a gate per batch, rests, a final before-and-after.
@@ -388,6 +400,10 @@ Reads .agents/skills; .agents/hooks.json carries a bravos SessionStart group tha
388
400
 
389
401
  When the repo has a .cursor/ folder (or with --agent cursor): .cursor/rules/bravos.mdc points at the skills, and a sessionStart hook in .cursor/hooks.json gives the agent the briefing and the Bravos card for its first reply.
390
402
 
403
+ ### Agents without hooks
404
+
405
+ A short Bravos block, between <!-- bravos:begin --> and <!-- bravos:end -->, in AGENTS.md and CLAUDE.md (when they exist or their skills are installed), GEMINI.md and .github/copilot-instructions.md (when they exist), and .windsurf/rules/bravos.md (with a .windsurf/ folder): an agent that got no briefing from a hook runs node .bravos/hooks/session-start.mjs --briefing. Setup replaces only that block; uninstall removes it.
406
+
391
407
  ### VS Code (Copilot agent)
392
408
 
393
409
  Reads hooks from .claude/settings.json (preview), so the briefing can load there too.
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,69 @@
2
2
 
3
3
  After `npm install -g @bugb-technologies/bravos`, run **`bravos setup`** in a repository you work in: it brings this machine and that repository up to date. In repositories you work in with an agent you can skip even that: the agent runs it at the start of a session. From 1.12 on you do not have to watch for releases: Bravos tells you when a newer version is out, and after you install it the agent brings each repository up to date. The notes below say what else changes, newest first. (Before 1.9 the same was `bravos setup --tools -y` per machine and `bravos sync` per repository; both still work.)
4
4
 
5
+ ## 1.22.0
6
+
7
+ - **The intake picks up where you left off.** `bravos review intent` brings back the answers you gave when you reopen it, saves them as you go (only Confirm makes them count), and reuses the page already open instead of opening a second one. After Confirm the page stays open and says who confirmed and when.
8
+ - **A rewritten draft no longer loses answers.** A draft that stops asking a question someone confirmed is refused unless the new question names the old id in `replaces`, or the id is listed under `retired`. An answer given before its question changed is flagged for the person to check.
9
+ - **Design documents on the page.** The intake page has a "Your design documents" panel: Markdown and text are stored at once with the same checks as `bravos context add`; a PDF, Word file, slides or link waits in `.bravos/context/inbox/` (not committed) for your agent to convert.
10
+ - **Citations are checked against the text.** `bravos context check` refuses a `SRC-n "<section>"` the document does not have, and the page shows the cited passage under each question.
11
+ - **The intake travels with the repository.** `bravos doctor` and `bravos setup` warn when a `.gitignore` rule keeps `.bravos/context/` or `.guardlink/intent*` on one machine; `bravos context share --yes` narrows a blanket `.bravos/` rule.
12
+ - **Security design principles (Team plan).** Your company's principles, kept in each repository:
13
+ - **Proposed only from your side.** The new `bravos-principles` skill proposes candidates from your stored documents, rules a person already confirmed, or an optional starter list mapped to OWASP ASVS 4.0.3. `bravos review principles` refuses anything else.
14
+ - **Adopted by people.** Each principle is its own decision on the page (Agree, Change, No); there is no adopt-all. Bravos writes `.guardlink/principles.md` from the confirmed adoptions. Commit it with `.guardlink/principles-answers/`.
15
+ - **Followed everywhere.** The Bravos block in `AGENTS.md`, `CLAUDE.md` and the other instruction files gains one paragraph telling every agent to read and follow the file and never edit it. This applies on every plan.
16
+ - **Enforced.** An enforced principle becomes a threat with `principle:SDP-n`; `bravos rules`, the dashboard's new Security design view and the pre-PR gate treat it like a design rule, and a change that breaks it is blocked whatever the PR body says, unless a person approved an exception (`bravos principles except`, at their own terminal, at most a year).
17
+ - **Checked.** `bravos principles check` (free) fails a hand-edited line, an adoption nobody made or an ended exception. `bravos principles copy --from <repository>` takes the same set into another repository.
18
+ - **The pre-push hook checks principles too.** `bravos setup` rewrites the hook Bravos installed (v2); one you wrote yourself is left alone.
19
+ - Run `bravos setup` in each repository: it refreshes the hook copy, the instruction-file block and the pre-push hook.
20
+
21
+ ## 1.21.0
22
+
23
+ - **`bravos account activate` sends a one-way fingerprint of this machine.** The account portal allows one free trial per person and per machine, and this is how it tells machines apart.
24
+ - **What is sent:** a SHA-256 hash of a fixed label and the operating system's machine id (macOS `IOPlatformUUID`, Linux `/etc/machine-id`, Windows `MachineGuid`). The id itself never leaves the machine.
25
+ - **When:** at activation, and with each licence renewal (as the `X-Bravos-Machine` header).
26
+ - **When not:** inside a container or on a CI runner, where many machines share one id, and when the id cannot be read. The portal treats "no fingerprint" as allowed.
27
+ - **Clearer answers when a trial cannot start.** `bravos account activate` now says so when a free trial was already used by you or on this machine (with the plans link and support address), when this version is too old to start a trial, and when a trial has to be started from the terminal.
28
+ - Nothing else changes. Run `bravos setup` in each repository to refresh its installed hook copy.
29
+
30
+ ## 1.20.0
31
+
32
+ - **Replay can report permission and prerequisites without executing a kit.**
33
+ `bravos hook replay preflight run <kit.js>` (also `run-once` and `scheduled`)
34
+ emits `bravos.replay-preflight/v1` JSON. It shares policy, scope, target,
35
+ owner-word and profile checks with replay. Blocked checks refuse the run;
36
+ pending build/identity/launch provenance remains explicit.
37
+ - **Supplied replay identities must pass CXG auth verify before execution.**
38
+ Capture or re-import a missing or expired profile before retrying. Preflight
39
+ performs this same liveness check after authorization; no proof executes.
40
+ - See [continuous proof](continuous-proof.md#non-executing-replay-preflight-1200)
41
+ for the receipt contract and launch provenance limitations. Run `bravos setup`
42
+ in each repository to refresh its installed hook copy.
43
+
44
+ ## 1.19.0
45
+
46
+ - **Teammates without Bravos get an invitation instead of your setup.** The hooks travel with the repository. On a machine without Bravos (no `bravos` command, licence or plugin), they now show only an invitation, once per session:
47
+ - **What it shows:** the repository's own numbers from its committed threat model, what Bravos would do for that person, and the one command to join (Free, no account needed).
48
+ - **What runs for them:** nothing else. No briefing, coach, threat cards, pre-PR gate, autopilot or background work, and nothing is sent anywhere.
49
+ - **Their agent** offers setup once and runs it only if they say yes. "Not now" hides the invitation in that clone for 7 days (`node .bravos/hooks/invite.mjs snooze`, kept under `.git`).
50
+ - **To switch it off for the team:** add `{"invite": "off"}` to `.bravos/config.json`. CI always counts as having Bravos, so the nightly and PR workflows are unchanged.
51
+ - **Agents without hooks get Bravos too.** `bravos setup` keeps a short Bravos block in the instruction files agents read: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`, `.windsurf/rules/bravos.md` and the Cursor rule.
52
+ - The block tells an agent that got no Bravos briefing from a hook to run `node .bravos/hooks/session-start.mjs --briefing`. That prints the briefing, or the invitation on a machine without Bravos.
53
+ - Your own text in those files is kept, GuardLink's block is left alone, and `bravos uninstall` removes only Bravos's block.
54
+ - **Where the card shows now depends on the surface, not just the agent:**
55
+
56
+ | Agent | Where you see it |
57
+ |---|---|
58
+ | Claude Code in a terminal | the banner, at launch |
59
+ | Claude Code desktop app and IDE extensions | the agent's first reply opens with the card (before, a banner these surfaces don't draw) |
60
+ | omp | the banner, above the editor until your first prompt |
61
+ | Gemini | the banner, at session start |
62
+ | Codex | the card itself, shown as "↳ Hook ·" with your first message |
63
+ | Cursor, OpenCode, Antigravity | the agent's first reply opens with the card |
64
+ | Windsurf, Copilot and other agents without hooks | the agent runs the briefing from the repository's instruction files, then opens its reply with the card |
65
+ - **A Team trial warns in its last 5 days.** The banner says how many days are left and to ask your admin to keep Team.
66
+ - **To get it:** run `bravos setup` in each repository (it writes the instruction-file blocks), commit what it changes, then start a new session in each agent.
67
+
5
68
  ## 1.18.0
6
69
 
7
70
  - **Every agent now shows the same Bravos card,** through the best channel that agent has:
@@ -1,5 +1,6 @@
1
1
  // @comment -- "bravos autopilot Stop hook entry (Claude Code and Codex): reads the Stop payload from stdin with a bounded wait, resolves the repo as git's top level for the payload cwd, runs the end-of-turn check, and prints {} to allow or {decision:'block', reason} to send the agent back once, logging the nudge for bravos watch. Always exits 0; a failure allows."
2
2
  import { entitled, status as licenceStatus } from './lib/licence.mjs';
3
+ import { audience } from './lib/audience.mjs';
3
4
  import { resolveRoot } from './lib/pre-pr.mjs';
4
5
  import { logWatchEvent, runAutopilot } from './lib/autopilot.mjs';
5
6
 
@@ -22,7 +23,7 @@ async function readPayload() {
22
23
  async function main() {
23
24
  let out = {};
24
25
  // Autopilot is part of the pre-PR gate feature; without the licence the Stop hook answers nothing and the turn ends normally.
25
- if (!entitled(licenceStatus(process.env), 'pre-pr')) {
26
+ if (audience(process.env).kind === 'none' || !entitled(licenceStatus(process.env), 'pre-pr')) {
26
27
  process.stdout.write('{}\n');
27
28
  process.exit(0);
28
29
  }
package/hooks/cards.mjs CHANGED
@@ -1,11 +1,24 @@
1
1
  // @comment -- "bravos threat cards PostToolUse hook entry (Claude Code and Codex): after an edit, shows the developer a card for each new critical or high exposure no test has confirmed or refuted (hooks/lib/cards.mjs), gives the agent one line to raise it, logs it for bravos watch and, when the person turned it on, sends a desktop notification. Silent when BRAVOS_THREAT_CARDS=off, when the person switched cards off (bravos prefs set cards off), or when it is the plugin's copy in a repository that registers its own. Always exits 0; a failure shows nothing."
2
2
  import { readFileSync, realpathSync } from 'node:fs';
3
- import { basename, join } from 'node:path';
3
+ import { basename, isAbsolute, join, relative } from 'node:path';
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { agentLine, decideCards, notify, readSeen, renderCard, targetRecorded, writeSeen } from './lib/cards.mjs';
7
7
  import { gitCommonDir, readPrefs } from './lib/prefs.mjs';
8
+ import { audience } from './lib/audience.mjs';
8
9
  import { logWatchEvent } from './lib/snapshot.mjs';
10
+ import { adoptedPrinciples, principlesForFile } from './lib/principles.mjs';
11
+
12
+ // @comment -- "The after-edit note about the company's security design principles: when the edited file matches the paths an adopted principle names, one line for the agent naming that principle and its statement, so it keeps to it while it works. Statements come from principles.md, fingerprint-checked, cleaned to one line and cut short."
13
+ function principleNote(root, toolInput) {
14
+ const file = typeof toolInput?.file_path === 'string' ? toolInput.file_path : typeof toolInput?.path === 'string' ? toolInput.path : '';
15
+ if (!file) return '';
16
+ const rel = (isAbsolute(file) ? relative(root, file) : file).split('\\').join('/');
17
+ if (!rel || rel.startsWith('..')) return '';
18
+ const hits = principlesForFile(adoptedPrinciples(root), rel).slice(0, 3);
19
+ if (!hits.length) return '';
20
+ return `${rel} is under the team's security design principles: ${hits.map((p) => `${p.id} (${p.kind}) "${p.statement.slice(0, 200)}"`).join('; ')}. Keep to ${hits.length === 1 ? 'it' : 'them'}; if this change cannot, say so and ask the person (.guardlink/principles.md).`;
21
+ }
9
22
 
10
23
  async function readPayload() {
11
24
  if (process.stdin.isTTY) return {};
@@ -43,15 +56,19 @@ async function main() {
43
56
  let out = {};
44
57
  try {
45
58
  if (process.env.BRAVOS_THREAT_CARDS === 'off') throw new Error('off');
59
+ // A machine without Bravos gets only the session-start invitation: no threat cards.
60
+ if (audience(process.env).kind === 'none') throw new Error('off');
46
61
  const payload = await readPayload();
47
62
  const cwd = typeof payload.cwd === 'string' ? payload.cwd : process.env.CLAUDE_PROJECT_DIR || process.cwd();
48
63
  const top = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'] });
49
64
  if (top.status !== 0) throw new Error('not a repository');
50
65
  const root = top.stdout.trim();
51
66
  if (deferToRepo(root)) throw new Error('repo copy');
67
+ const note = principleNote(root, payload.tool_input);
68
+ if (note) out = { hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext: note } };
52
69
  const commonDir = gitCommonDir(root);
53
70
  const prefs = readPrefs(commonDir);
54
- if (prefs.cards?.value === 'off') throw new Error('off');
71
+ if (prefs.cards?.value === 'off') throw new Error('cards off');
55
72
  const harness = process.argv.includes('--harness') ? process.argv[process.argv.indexOf('--harness') + 1] : 'claude';
56
73
  const { cards, seen } = decideCards({ root, toolName: payload.tool_name, toolInput: payload.tool_input, seen: readSeen(commonDir) });
57
74
  if (cards.length) {
@@ -60,12 +77,13 @@ async function main() {
60
77
  const shown = cards.slice(0, 3);
61
78
  const more = cards.length - shown.length;
62
79
  const text = ['bravos · threat card', ...shown.map((c) => renderCard(c, { target, harness })), ...(more > 0 ? [`… and ${more} more: bravos watch lists them`] : []), 'Shown once per threat. bravos watch and the dashboard keep the list.'].join('\n');
63
- out = { systemMessage: text, hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext: agentLine(cards, { target, harness }) } };
80
+ out = { systemMessage: text, hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext: [agentLine(cards, { target, harness }), note].filter(Boolean).join('\n') } };
64
81
  for (const c of cards) logWatchEvent(root, { summary: `card: ${c.severity.toUpperCase()} ${c.threat} on ${c.asset} · ${c.file}${c.line ? `:${c.line}` : ''} · untested`, keys: [`bravos-card:${c.threat}`] });
65
82
  if (prefs.notify?.value === 'on' || process.env.BRAVOS_NOTIFY === 'on') notify(cards[0], basename(root));
66
83
  }
67
- } catch {
68
- out = {};
84
+ } catch (e) {
85
+ // Cards switched off still leave the principles note; anything else that failed shows nothing.
86
+ if (!(e instanceof Error && e.message === 'cards off')) out = {};
69
87
  }
70
88
  process.stdout.write(JSON.stringify(out) + '\n');
71
89
  process.exit(0);
package/hooks/coach.mjs CHANGED
@@ -6,6 +6,7 @@ import { spawnSync } from 'node:child_process';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { coachTurn, newestModelChange, readCoach, writeCoach } from './lib/coach.mjs';
8
8
  import { gitCommonDir, readPrefs } from './lib/prefs.mjs';
9
+ import { audience } from './lib/audience.mjs';
9
10
  import { logWatchEvent } from './lib/snapshot.mjs';
10
11
  import { cliVersion, readUpdate, repoVersion } from './lib/update-check.mjs';
11
12
 
@@ -61,6 +62,8 @@ async function main() {
61
62
  let out = {};
62
63
  try {
63
64
  if (process.env.BRAVOS_COACH === 'off') throw new Error('off');
65
+ // A machine without Bravos gets only the session-start invitation: no coaching.
66
+ if (audience(process.env).kind === 'none') throw new Error('off');
64
67
  const payload = await readPayload();
65
68
  const cwd = typeof payload.cwd === 'string' ? payload.cwd : process.env.CLAUDE_PROJECT_DIR || process.cwd();
66
69
  const root = git(cwd, ['rev-parse', '--show-toplevel']) || cwd;
@@ -0,0 +1,10 @@
1
+ // @comment -- "The one thing a person without Bravos can ask of it: node .bravos/hooks/invite.mjs snooze hides the invitation in this clone for seven days. Their agent runs it when they say 'not now'. Writes only <git-common-dir>/bravos/invite.json; prints one line; always exits 0."
2
+ import { gitCommonDir } from './lib/prefs.mjs';
3
+ import { snoozeInvite } from './lib/audience.mjs';
4
+
5
+ const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
6
+ if (process.argv[2] === 'snooze') {
7
+ const file = snoozeInvite(gitCommonDir(root));
8
+ process.stdout.write(file ? 'Bravos invitation hidden in this clone for 7 days.\n' : 'Not a git repository: nothing recorded.\n');
9
+ } else process.stdout.write('usage: node .bravos/hooks/invite.mjs snooze\n');
10
+ process.exit(0);
@@ -0,0 +1,83 @@
1
+ // @comment -- "Who is in this session, for what the hooks show and do: a machine without Bravos (none: a teammate who cloned a repository that uses it), Free, a Team trial, a Team seat, or an expired licence. Installed means the Bravos CLI is on PATH, a licence is on this machine, or the Claude Code or Codex plugin is installed; a Bravos folder alone does not count, since older hooks wrote one for anyone. CI always counts as installed: Bravos's own workflows run the agents there. Read-only, dependency-free."
2
+ import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { cliVersion } from './update-check.mjs';
5
+ import { status as licenceStatus } from './licence.mjs';
6
+
7
+ const SNOOZE_DAYS = 7;
8
+
9
+ // @comment -- "True when the Claude Code or Codex plugin cache holds a Bravos plugin: someone installed it from a marketplace without the npm CLI."
10
+ function pluginInstalled(home) {
11
+ if (!home) return false;
12
+ for (const cache of [join(home, '.claude', 'plugins', 'cache'), join(home, '.codex', 'plugins', 'cache')]) {
13
+ let entries = [];
14
+ try {
15
+ entries = readdirSync(cache, { withFileTypes: true });
16
+ } catch {
17
+ continue;
18
+ }
19
+ for (const e of entries) {
20
+ if (!e.isDirectory()) continue;
21
+ if (/^bravos/i.test(e.name)) return true;
22
+ try {
23
+ if (readdirSync(join(cache, e.name)).some((n) => /^bravos/i.test(n))) return true;
24
+ } catch {
25
+ /* unreadable marketplace folder */
26
+ }
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+
32
+ // @comment -- "Whether this machine has Bravos: CI, the CLI on PATH, a licence, or a plugin install. BRAVOS_AUDIENCE=installed or none states it outright (tests, mirrors)."
33
+ export function bravosInstalled(env = process.env, licence = licenceStatus(env)) {
34
+ if (env.BRAVOS_AUDIENCE === 'installed') return true;
35
+ if (env.BRAVOS_AUDIENCE === 'none') return false;
36
+ if (env.CI || env.GITHUB_ACTIONS) return true;
37
+ if (cliVersion(env)) return true;
38
+ if (licence && licence.state && licence.state !== 'absent') return true;
39
+ return pluginInstalled(env.HOME);
40
+ }
41
+
42
+ // @comment -- "The audience: { kind: none | free | trial | team | expired, licence, daysLeft }. daysLeft is set for a trial."
43
+ export function audience(env = process.env, now = Math.floor(Date.now() / 1000)) {
44
+ const licence = licenceStatus(env);
45
+ if (!bravosInstalled(env, licence)) return { kind: 'none', licence };
46
+ if (licence.licensed) {
47
+ if (licence.trial) return { kind: 'trial', licence, daysLeft: Math.max(0, Math.ceil((Number(licence.trial.endsAt) - now) / 86400)) };
48
+ return { kind: 'team', licence };
49
+ }
50
+ if (licence.state === 'expired') return { kind: 'expired', licence };
51
+ return { kind: 'free', licence };
52
+ }
53
+
54
+ // @comment -- "Whether the invitation may show in this clone: the team can switch it off in the committed .bravos/config.json (\"invite\": \"off\"), and a person can snooze it for seven days (<git-common-dir>/bravos/invite.json, which no commit can write). BRAVOS_BANNER=off hides it as it hides the banner."
55
+ export function inviteAllowed(root, commonDir, env = process.env, now = Date.now()) {
56
+ if (env.BRAVOS_BANNER === 'off') return false;
57
+ try {
58
+ const cfg = JSON.parse(readFileSync(join(root, '.bravos', 'config.json'), 'utf8'));
59
+ if (cfg && cfg.invite === 'off') return false;
60
+ } catch {
61
+ /* no team setting: on */
62
+ }
63
+ if (!commonDir) return true;
64
+ try {
65
+ const j = JSON.parse(readFileSync(inviteFile(commonDir), 'utf8'));
66
+ const at = Date.parse(j?.snoozedAt);
67
+ if (j?.schema === 'bravos.invite/v1' && Number.isFinite(at) && at <= now + 60000 && now - at < SNOOZE_DAYS * 86400000) return false;
68
+ } catch {
69
+ /* never snoozed */
70
+ }
71
+ return true;
72
+ }
73
+
74
+ export const inviteFile = (commonDir) => join(commonDir, 'bravos', 'invite.json');
75
+
76
+ // @comment -- "Records that the person said 'not now' to the invitation, for seven days, in this clone's git directory. The agent runs it through hooks/invite.mjs, since a person without Bravos has no bravos command."
77
+ export function snoozeInvite(commonDir, now = new Date()) {
78
+ if (!commonDir) return null;
79
+ const file = inviteFile(commonDir);
80
+ mkdirSync(join(file, '..'), { recursive: true, mode: 0o700 });
81
+ writeFileSync(file, JSON.stringify({ schema: 'bravos.invite/v1', snoozedAt: now.toISOString() }) + '\n', { mode: 0o600 });
82
+ return file;
83
+ }