beehaven 0.8.34 → 0.8.35

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.
@@ -1,64 +1,80 @@
1
1
  /**
2
2
  * agents-md-text — the Clearly block for a PROJECT's AGENTS.md, as `beehaven agents-md` writes it
3
- * (CAN2-66).
3
+ * (CAN2-66, AWO-401).
4
4
  *
5
5
  * ⚠⚠ A COPY, PINNED. The source of truth is the monorepo's `lib/connections/agentsMd.ts`, which the
6
- * Integrations page, each agent's details and the MCP `clearly-agents-md` prompt render. This
7
- * package cannot import it (it ships on its own), so the text is repeated here and the monorepo's
8
- * `lib/__tests__/agentsMdCliParity.test.mjs` compares the two OUTPUTS, name argument included.
9
- * Change both or the test fails — a stale copy does not render wrong, it instructs wrong.
6
+ * Integrations page, each agent's details, the /cli and /mcp guides and the MCP `clearly-agents-md`
7
+ * prompt render. This package cannot import it (it ships on its own), so the text is repeated here
8
+ * and the monorepo's `lib/__tests__/agentsMdCliParity.test.mjs` compares the two OUTPUTS, name
9
+ * argument included. Change both or the test fails — a stale copy does not render wrong, it
10
+ * instructs wrong.
11
+ *
12
+ * ⚠ ONE TRACKED BLOCK FOR MCP AND THE CLI (founder 2026-10-28): every task is tracked in Clearly,
13
+ * and each step names the MCP tool and the CLI command. The per-route blocks before it are removed
14
+ * when this one is written (`LEGACY_BLOCK_MARKERS`).
10
15
  *
11
16
  * ⚠ NO IMPORTS, so that test can load this file directly.
12
17
  */
13
- export const CLI_BLOCK_START = '<!-- clearly:cli:start -->';
14
- export const CLI_BLOCK_END = '<!-- clearly:cli:end -->';
15
- export const MCP_BLOCK_START = '<!-- clearly:mcp:start -->';
16
- export const MCP_BLOCK_END = '<!-- clearly:mcp:end -->';
18
+ export const AGENTS_MD_START = '<!-- clearly:start -->';
19
+ export const AGENTS_MD_END = '<!-- clearly:end -->';
20
+ /** The per-route markers used before AWO-401. Writers remove these blocks; nothing writes them. */
21
+ export const LEGACY_BLOCK_MARKERS = [
22
+ ['<!-- clearly:cli:start -->', '<!-- clearly:cli:end -->'],
23
+ ['<!-- clearly:mcp:start -->', '<!-- clearly:mcp:end -->'],
24
+ ];
25
+ /** How Claude Code runs the MCP server's `clearly-agents-md` prompt, which writes the block. */
26
+ export const MCP_AGENTS_MD_SLASH = '/mcp__clearly__clearly-agents-md';
17
27
  /** What goes in CLAUDE.md so Claude Code reads the AGENTS.md block too. */
18
28
  export const CLAUDE_MD_IMPORT = '@AGENTS.md';
19
- /** The block for agents that use the `beehaven` CLI. */
20
- export function agentsMdCliBlock(agentName) {
29
+ /** Where the block goes, said once for every surface. */
30
+ export const AGENTS_MD_HOW = 'Every agent that opens the repository reads AGENTS.md, so the block makes each session track its work in Clearly. Claude Code reads CLAUDE.md — give it one line.';
31
+ /** The MCP tools the block names. Each must be on the server's `tools/list` (a Worker test pins it). */
32
+ export const MCP_BLOCK_TOOLS = ['clearly_catalog', 'clearly_read', 'clearly_grep', 'clearly_create', 'clearly_edit', 'clearly_comment'];
33
+ /**
34
+ * The block. `agentName` personalises the CLI sign-in line for one agent (its details view);
35
+ * without it the agent is told to use its own name.
36
+ */
37
+ export function agentsMdBlock(agentName) {
21
38
  const name = (agentName ?? '').trim();
22
39
  const login = name
23
- ? `\`beehaven agent login ${name} --label "<what you are doing>"\` — you are ${name} in this workspace.`
24
- : '`beehaven agent login <name> --label "<what you are doing>"`, using your own name (claude, codex, gemini).';
40
+ ? `\`beehaven agent login ${name} --label "<the task>"\` — you are ${name} in this workspace —`
41
+ : '`beehaven agent login <your-name> --label "<the task>"` (claude, codex, gemini…)';
25
42
  return [
26
- CLI_BLOCK_START,
27
- '<!-- managed-by: clearly. Run `beehaven agents-md` to update; edit outside this block. -->',
43
+ AGENTS_MD_START,
44
+ '<!-- managed-by: clearly. Run `beehaven agents-md` or the `clearly-agents-md` MCP prompt to update; edit outside this block. -->',
28
45
  '',
29
- '## Clearly workspace',
46
+ '## Clearly workspace: track every task',
30
47
  '',
31
- 'This project keeps its documents, plans, boards and tickets in Clearly. Use the `beehaven` CLI',
32
- 'for anything the team should see, not files in this repo.',
48
+ "This project's plans, tickets, documents and designs live in Clearly. Track every task there,",
49
+ 'even when the person does not ask. Use whichever route this session has: the `clearly_*` MCP tools,',
50
+ "or the `beehaven` CLI (`beehaven actions` lists actions; `beehaven call <action> '<json>'` runs one).",
33
51
  '',
34
- `- Sign in once per session: ${login}`,
52
+ '### Start of every session',
53
+ '',
54
+ `- CLI: sign in first with ${login} and read the brief it prints.`,
35
55
  ' If it says the daemon is not running: `beehaven start --headless`.',
36
- '- Read the `clearly-agent` skill before anything else, and `clearly-canvas` before design work',
37
- ' (`beehaven skills install` puts them in place).',
38
- '- `beehaven actions` lists what you can call; `beehaven call <action> \'<json>\'` calls it.',
39
- '- Search before you create, file work in the project it belongs to, and end the session with',
40
- ' `beehaven agent handoff "what you did · what is next"` so the next one starts there.',
41
- CLI_BLOCK_END,
42
- ].join('\n');
43
- }
44
- /** The block for agents connected over MCP (the `clearly` server). */
45
- export function agentsMdMcpBlock() {
46
- return [
47
- MCP_BLOCK_START,
48
- '<!-- managed-by: clearly-mcp. Re-run the `clearly-agents-md` prompt to update; edit outside this block. -->',
56
+ ' MCP: you are already signed in as the agent chosen when Clearly was connected.',
57
+ "- Read this project's open tickets and its latest handoff before starting (`clearly_grep` /",
58
+ ' `clearly_read`, or the brief).',
59
+ '',
60
+ '### Every task has a ticket',
61
+ '',
62
+ '1. Search first (`clearly_grep`, `clearly_catalog`, or `beehaven call ticket-list`). Reuse the project,',
63
+ ' board and ticket that already own the work; create a board only if the project has none.',
64
+ '2. Create the ticket before changing code or files (`clearly_create` with `type: "ticket"` and',
65
+ ' `fields.boardId`, or `beehaven call ticket-create`). Say in its body what done means.',
66
+ '3. Move it to in-progress when work begins (`clearly_edit`, or `beehaven call ticket-update`).',
67
+ '4. File what you make (documents, designs, notes) into the project and link it from the ticket.',
68
+ ' Record decisions, open questions and progress as comments (`clearly_comment`).',
69
+ '5. Mark it done only after verifying the result, with the resolution and any remaining risk.',
49
70
  '',
50
- '## Clearly workspace (connected over MCP as `clearly`)',
71
+ '### End of every session',
51
72
  '',
52
- 'This project keeps its documents, plans, boards and tickets in Clearly. Use the `clearly_*`',
53
- 'tools, not files in this repo, for anything the team should see.',
73
+ '- Leave a handoff: what you did and what is next. CLI: `beehaven agent handoff "<done · next>"`.',
74
+ ' MCP: a comment on the work ticket.',
54
75
  '',
55
- '- Start with `clearly_catalog` to see what exists; search with `clearly_grep` / `clearly_glob`.',
56
- '- Read with `clearly_read`, make new work with `clearly_create`, change it with `clearly_edit`,',
57
- ' and discuss it with `clearly_comment`. They take a `target`: a path (`~/Q1/Plan.md`), a key',
58
- ' (`CLR-42`), an id or an exact title. The extension names the type (`.md` document, `.csv`',
59
- ' sheet, `.board.json` board); a trailing slash means a project.',
60
- '- Search before you write, and write decisions back so the next session inherits them.',
61
- '- If a job is not covered by a listed tool, say so rather than guessing an action name.',
62
- MCP_BLOCK_END,
76
+ 'If this session has neither the `clearly_*` tools nor `beehaven`, stop and ask the person to connect',
77
+ 'Clearly (clearly.sh/docs/mcp or clearly.sh/docs/cli). Do not skip the tracking.',
78
+ AGENTS_MD_END,
63
79
  ].join('\n');
64
80
  }
@@ -53,9 +53,9 @@ export const PUBLIC_BUILD = true;
53
53
  * ⚠ REWRITTEN IN `dist/` AT BUILD TIME, like `PUBLIC_BUILD`. `unstamped` is what a source checkout
54
54
  * carries and what `tsx`/`vitest` see, and it is honest: nothing has stamped them.
55
55
  */
56
- export const BUILD_SHA = '0fc3f190acdb';
56
+ export const BUILD_SHA = 'f866489dd2f1';
57
57
  /** ISO-8601 minute precision, UTC. Rewritten in `dist/` by `scripts/stamp-build-channel.mjs`. */
58
- export const BUILD_TIME = '2026-10-27T20:29Z';
58
+ export const BUILD_TIME = '2026-10-28T16:02Z';
59
59
  /**
60
60
  * The build identity as one short string, for `--version`.
61
61
  *
package/dist/cli.js CHANGED
@@ -1340,7 +1340,7 @@ async function run() {
1340
1340
  state: { type: 'string' },
1341
1341
  goal: { type: 'string' },
1342
1342
  remove: { type: 'boolean', default: false },
1343
- // `agents-md`: the MCP block instead of the CLI one; print it instead of writing it (CAN2-66).
1343
+ // `agents-md`: `--mcp` is accepted for older instructions (one block since AWO-401); `--print` prints it.
1344
1344
  mcp: { type: 'boolean', default: false },
1345
1345
  print: { type: 'boolean', default: false },
1346
1346
  /**
@@ -8,17 +8,81 @@
8
8
  * is its own command the person (or their agent, asked first) runs, not a side effect of install.
9
9
  *
10
10
  * ⚠ THE MARKERS ARE THE UPDATE MECHANISM, as on every other surface (lib/connections/agentsMd.ts):
11
- * re-running replaces only what lies between our markers and leaves the rest byte for byte. The
12
- * CLI and MCP blocks have their own markers, so a repo used both ways keeps both.
11
+ * re-running replaces only what lies between our markers and leaves the rest byte for byte.
12
+ *
13
+ * ⚠ ONE TRACKED BLOCK FOR BOTH ROUTES (AWO-401). The block names the MCP tool and the CLI command
14
+ * for each step, so `--mcp` is kept only so older instructions still work; it writes the same block.
15
+ * Writing it removes the per-route blocks earlier versions wrote (`LEGACY_BLOCK_MARKERS`), so a repo
16
+ * that had both converges on one.
13
17
  *
14
18
  * ⚠ AGENTS.md IS THE FILE; CLAUDE.md POINTS AT IT with one `@AGENTS.md` line — one copy to keep
15
19
  * current. An existing CLAUDE.md gains the line only if it lacks it; nothing else in it is touched.
20
+ * The project's `.claude/settings.json` gains `CLAUDE_BASH_RULE` the same way (AWO-401).
16
21
  */
17
- import { existsSync, readFileSync, writeFileSync } from 'fs';
22
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
18
23
  import { join, resolve } from 'path';
19
24
  import { execFileSync } from 'child_process';
20
25
  import { color } from '../spinner.js';
21
- import { CLI_BLOCK_START, CLI_BLOCK_END, MCP_BLOCK_START, MCP_BLOCK_END, CLAUDE_MD_IMPORT, agentsMdCliBlock, agentsMdMcpBlock, } from '../agents-md-text.js';
26
+ import { AGENTS_MD_START, AGENTS_MD_END, LEGACY_BLOCK_MARKERS, CLAUDE_MD_IMPORT, agentsMdBlock } from '../agents-md-text.js';
27
+ /**
28
+ * The Claude Code permission that lets an agent run `beehaven` without a prompt per call (AWO-401).
29
+ * The tracked block makes several calls a task; a prompt on each one pushes people to turn tracking
30
+ * off. Written to the PROJECT's `.claude/settings.json` (committed with AGENTS.md, so it is the
31
+ * team's rule, not a change to anyone's user-wide settings). Claude Code matches each part of a
32
+ * chained command separately, so the rule never approves `beehaven … && something-else`.
33
+ */
34
+ export const CLAUDE_BASH_RULE = 'Bash(beehaven:*)';
35
+ /**
36
+ * Settings text with the rule added (or removed). `null` text means no file. A file that is not a
37
+ * JSON object is left alone (`skipped`) — never rewritten from a guess.
38
+ */
39
+ export function editClaudeSettings(text, remove = false) {
40
+ if (text === null) {
41
+ if (remove)
42
+ return { next: null, change: 'absent' };
43
+ return { next: JSON.stringify({ permissions: { allow: [CLAUDE_BASH_RULE] } }, null, 2) + '\n', change: 'created' };
44
+ }
45
+ let data;
46
+ try {
47
+ data = JSON.parse(text);
48
+ }
49
+ catch {
50
+ return { next: text, change: 'skipped' };
51
+ }
52
+ if (!data || typeof data !== 'object' || Array.isArray(data))
53
+ return { next: text, change: 'skipped' };
54
+ const perms = data.permissions && typeof data.permissions === 'object' && !Array.isArray(data.permissions) ? data.permissions : null;
55
+ const allow = perms && Array.isArray(perms.allow) ? perms.allow : [];
56
+ if (remove) {
57
+ if (!allow.includes(CLAUDE_BASH_RULE))
58
+ return { next: text, change: 'absent' };
59
+ perms.allow = allow.filter((r) => r !== CLAUDE_BASH_RULE);
60
+ if (!perms.allow.length)
61
+ delete perms.allow;
62
+ if (!Object.keys(perms).length)
63
+ delete data.permissions;
64
+ return { next: Object.keys(data).length ? JSON.stringify(data, null, 2) + '\n' : null, change: 'removed' };
65
+ }
66
+ if (allow.includes(CLAUDE_BASH_RULE))
67
+ return { next: text, change: 'current' };
68
+ if (perms && perms.allow !== undefined && !Array.isArray(perms.allow))
69
+ return { next: text, change: 'skipped' };
70
+ data.permissions = { ...(perms ?? {}), allow: [...allow, CLAUDE_BASH_RULE] };
71
+ return { next: JSON.stringify(data, null, 2) + '\n', change: 'updated' };
72
+ }
73
+ /** Apply `editClaudeSettings` to `<root>/.claude/settings.json`. */
74
+ function writeClaudeSettings(root, remove) {
75
+ const path = join(root, '.claude', 'settings.json');
76
+ const before = existsSync(path) ? readFileSync(path, 'utf8') : null;
77
+ const { next, change } = editClaudeSettings(before, remove);
78
+ if (next === null && before !== null)
79
+ rmSync(path);
80
+ else if (next !== null && next !== before) {
81
+ mkdirSync(join(root, '.claude'), { recursive: true });
82
+ writeFileSync(path, next);
83
+ }
84
+ return { path, change };
85
+ }
22
86
  /** Our block replaced between its markers, or appended after one blank line. Keeps CRLF files CRLF. */
23
87
  export function spliceBlock(text, block, start, end) {
24
88
  const eol = text.includes('\r\n') ? '\r\n' : '\n';
@@ -57,22 +121,42 @@ export function projectRoot(dir) {
57
121
  }
58
122
  }
59
123
  /** Write (or remove) the block in `<root>/AGENTS.md` and make CLAUDE.md import it. */
124
+ /** The text with every per-route block from before AWO-401 taken out. */
125
+ export function removeLegacyBlocks(text) {
126
+ return LEGACY_BLOCK_MARKERS.reduce((t, [start, end]) => removeBlock(t, start, end), text);
127
+ }
128
+ /**
129
+ * The block written into `text`: in place of our current block, else in place of the first legacy
130
+ * block (so a migrated repo keeps its layout), else appended. Any other legacy block is removed.
131
+ */
132
+ export function upsertAgentsMdBlock(text, block) {
133
+ if (text.includes(AGENTS_MD_START))
134
+ return spliceBlock(removeLegacyBlocks(text), block, AGENTS_MD_START, AGENTS_MD_END);
135
+ const legacy = LEGACY_BLOCK_MARKERS.find(([start, end]) => {
136
+ const i = text.indexOf(start);
137
+ return i >= 0 && text.indexOf(end, i) >= 0;
138
+ });
139
+ if (legacy)
140
+ return removeLegacyBlocks(spliceBlock(text, block, legacy[0], legacy[1]));
141
+ return spliceBlock(text, block, AGENTS_MD_START, AGENTS_MD_END);
142
+ }
143
+ /** `mcp` is accepted for older instructions and changes nothing: there is one block (AWO-401). */
60
144
  export function writeProjectAgentsMd(opts) {
61
145
  const root = projectRoot(resolve(opts.dir));
62
- const [start, end] = opts.mcp ? [MCP_BLOCK_START, MCP_BLOCK_END] : [CLI_BLOCK_START, CLI_BLOCK_END];
63
146
  const agentsPath = join(root, 'AGENTS.md');
64
147
  const claudePath = join(root, 'CLAUDE.md');
65
148
  const files = [];
66
149
  const had = existsSync(agentsPath);
67
150
  const before = had ? readFileSync(agentsPath, 'utf8') : '';
68
151
  if (opts.remove) {
69
- const next = removeBlock(before, start, end);
152
+ const next = removeLegacyBlocks(removeBlock(before, AGENTS_MD_START, AGENTS_MD_END));
70
153
  if (next !== before)
71
154
  writeFileSync(agentsPath, next);
72
155
  files.push({ path: agentsPath, change: next !== before ? 'removed' : 'absent' });
156
+ files.push(writeClaudeSettings(root, true));
73
157
  return { root, files };
74
158
  }
75
- const next = spliceBlock(before, opts.mcp ? agentsMdMcpBlock() : agentsMdCliBlock(), start, end);
159
+ const next = upsertAgentsMdBlock(before, agentsMdBlock());
76
160
  if (next !== before)
77
161
  writeFileSync(agentsPath, next);
78
162
  files.push({ path: agentsPath, change: !had ? 'created' : next !== before ? 'updated' : 'current' });
@@ -89,11 +173,12 @@ export function writeProjectAgentsMd(opts) {
89
173
  else {
90
174
  files.push({ path: claudePath, change: 'current' });
91
175
  }
176
+ files.push(writeClaudeSettings(root, false));
92
177
  return { root, files };
93
178
  }
94
179
  export function cmdAgentsMd(dir, opts) {
95
180
  if (opts.print) {
96
- process.stdout.write((opts.mcp ? agentsMdMcpBlock() : agentsMdCliBlock()) + '\n');
181
+ process.stdout.write(agentsMdBlock() + '\n');
97
182
  return 0;
98
183
  }
99
184
  let r;
@@ -106,10 +191,11 @@ export function cmdAgentsMd(dir, opts) {
106
191
  }
107
192
  console.log('');
108
193
  for (const f of r.files) {
109
- const mark = f.change === 'current' || f.change === 'absent' ? color.dim('·') : color.green('✓');
110
- console.log(` ${mark} ${f.path} ${color.dim(f.change)}`);
194
+ const mark = f.change === 'current' || f.change === 'absent' ? color.dim('·') : f.change === 'skipped' ? color.yellow('!') : color.green('✓');
195
+ const note = f.change === 'skipped' ? ` — not valid JSON, so left unchanged; add "${CLAUDE_BASH_RULE}" to permissions.allow yourself` : '';
196
+ console.log(` ${mark} ${f.path} ${color.dim(f.change)}${note}`);
111
197
  }
112
- const changed = r.files.some((f) => f.change !== 'current' && f.change !== 'absent');
198
+ const changed = r.files.some((f) => f.change !== 'current' && f.change !== 'absent' && f.change !== 'skipped');
113
199
  if (changed && !opts.remove) {
114
200
  console.log(color.dim(`\n Commit ${r.files.map((f) => f.path.slice(r.root.length + 1)).join(' and ')} so every agent that opens this project knows the workspace.`));
115
201
  }
@@ -414,23 +414,26 @@ const PAGES = {
414
414
  related: ['login', 'guide'],
415
415
  },
416
416
  'agents-md': {
417
- synopsis: 'beehaven agents-md [dir] [--mcp] [--print] [--remove]',
417
+ synopsis: 'beehaven agents-md [dir] [--print] [--remove]',
418
418
  description: `Add the Clearly block to this project's AGENTS.md, so every agent that opens the
419
- repository — a teammate's Codex or Claude Code, a cloud agent, CI — knows the workspace and how
420
- to reach it. Writes at the git root (or the directory given), and makes CLAUDE.md import it with
421
- one \`@AGENTS.md\` line. Needs no login.
422
-
423
- The block sits between Clearly's markers: run it again to update the block, and everything
424
- else in the file stays as it was. \`beehaven login\` already teaches the agents on THIS machine
425
- (their global instruction files); this is the shared, committed copy for everyone else.`,
419
+ repository — a teammate's Codex or Claude Code, a cloud agent, CI — tracks its work in the
420
+ workspace: sign in, a ticket for every task, a handoff at the end. One block serves agents on
421
+ the CLI and over MCP. Writes at the git root (or the directory given), and makes CLAUDE.md
422
+ import it with one \`@AGENTS.md\` line, and lets Claude Code run \`beehaven\` without a prompt per
423
+ call (\`Bash(beehaven:*)\` in the project's .claude/settings.json). Needs no login.
424
+
425
+ The block sits between Clearly's markers: run it again to update it, and everything else in
426
+ the file stays as it was. Older per-route Clearly blocks are replaced. \`beehaven login\`
427
+ already points the agents on THIS machine at Clearly (their global instruction files); this is
428
+ the shared, committed copy for everyone who opens the repository.`,
426
429
  flags: [
427
- { name: '--mcp', desc: 'Write the block for agents connected over MCP instead of the CLI' },
428
430
  { name: '--print', desc: 'Print the block and write nothing' },
429
431
  { name: '--remove', desc: 'Take the block out again' },
432
+ { name: '--mcp', desc: 'Accepted for older instructions; the block is the same for MCP and the CLI' },
430
433
  ],
431
434
  examples: [
432
- { cmd: 'beehaven agents-md', note: 'AGENTS.md + CLAUDE.md at the repository root' },
433
- { cmd: 'beehaven agents-md --mcp', note: 'for a team that connects over MCP' },
435
+ { cmd: 'beehaven agents-md', note: 'AGENTS.md, CLAUDE.md and .claude/settings.json at the repository root' },
436
+ { cmd: 'beehaven agents-md --print', note: 'see the block without writing it' },
434
437
  ],
435
438
  related: ['skills', 'login'],
436
439
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beehaven",
3
- "version": "0.8.34",
3
+ "version": "0.8.35",
4
4
  "description": "Beehaven CLI — command your Clearly workspace, agents, and canvas from the terminal",
5
5
  "private": false,
6
6
  "type": "module",