@jaybeeuu/agent-cortex 1.38.1 → 1.39.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 (62) hide show
  1. package/AGENTS.md +3 -1
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +34 -16
  4. package/agents/README.md +7 -5
  5. package/agents/ralph-plan/agent.md +1 -1
  6. package/agents/ralph-plan.agent.md +1 -1
  7. package/bin/agent-cortex.mjs +13 -5
  8. package/bin/installers/claude.mjs +129 -15
  9. package/claude/.claude-plugin/plugin.json +1 -1
  10. package/claude/agents/ralph-plan.md +1 -1
  11. package/docs/ideas/extension-manifests.md +75 -0
  12. package/docs/ideas/record-ideas-as-beads.md +115 -0
  13. package/docs/ideas/subagent-visibility.md +72 -0
  14. package/docs/ideas/task-session-context.md +89 -0
  15. package/docs/research/skill-design-research.md +4 -4
  16. package/docs/research/skill-improvements-analysis.md +1 -1
  17. package/docs/skills/skill-anatomy.md +38 -2
  18. package/docs/technical-direction/migration-execution-labels.md +132 -0
  19. package/lib/cli.mjs +9 -3
  20. package/package.json +2 -2
  21. package/plugin.json +1 -1
  22. package/pnpm-workspace.yaml +1 -1
  23. package/skills/engineering/design-an-interface/SKILL.md +78 -58
  24. package/skills/engineering/grill-with-docs/REFERENCE.md +78 -0
  25. package/skills/engineering/grill-with-docs/SKILL.md +66 -63
  26. package/skills/engineering/improve-codebase-architecture/SKILL.md +66 -48
  27. package/skills/engineering/technical-direction/FORMAT.md +38 -0
  28. package/skills/engineering/technical-direction/SKILL.md +70 -77
  29. package/skills/planning/classify-bead/SKILL.md +59 -35
  30. package/skills/planning/create-task/REFERENCE.md +40 -0
  31. package/skills/planning/create-task/SKILL.md +70 -66
  32. package/skills/planning/create-task/scripts/create-chores.ts +6 -1
  33. package/skills/planning/create-task/scripts/node_modules/.bin/tsc +21 -0
  34. package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +21 -0
  35. package/skills/planning/create-task/scripts/node_modules/.bin/tsx +21 -0
  36. package/skills/planning/prd-to-tasks/REFERENCE.md +66 -0
  37. package/skills/planning/prd-to-tasks/SKILL.md +86 -170
  38. package/skills/planning/record-idea/FORMAT.md +44 -0
  39. package/skills/planning/record-idea/SKILL.md +70 -53
  40. package/skills/planning/request-refactor-plan/FORMAT.md +45 -0
  41. package/skills/planning/request-refactor-plan/SKILL.md +57 -46
  42. package/skills/planning/write-a-prd/FORMAT.md +54 -0
  43. package/skills/planning/write-a-prd/SKILL.md +49 -48
  44. package/skills/planning/write-a-ticket/SKILL.md +68 -53
  45. package/skills/productivity/handoff/SKILL.md +12 -0
  46. package/skills/productivity/init-beads/SKILL.md +48 -40
  47. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +21 -0
  48. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +21 -0
  49. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +21 -0
  50. package/skills/productivity/write-a-skill/SKILL.md +2 -1
  51. package/skills/review/maintain-agent-docs/SKILL.md +71 -51
  52. package/skills/workflow/hitl-collab/SKILL.md +86 -17
  53. package/skills/workflow/ralph/REFERENCE.md +22 -17
  54. package/skills/workflow/ralph/SKILL.md +88 -74
  55. package/skills/workflow/run-pipeline-stage/REFERENCE.md +22 -0
  56. package/skills/workflow/run-pipeline-stage/SKILL.md +91 -93
  57. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +6 -107
  58. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +21 -0
  59. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +21 -0
  60. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +21 -0
  61. package/test/claude-installer.test.mjs +248 -0
  62. package/token-map.README.md +5 -3
package/AGENTS.md CHANGED
@@ -67,7 +67,9 @@ Generated automatically by changesets. Do not edit `CHANGELOG.md` manually.
67
67
  `agent-cortex install copilot` and `scripts/build-copilot-agents.mjs` (thin wrapper), and
68
68
  committed for Copilot CLI (plugin.json `agents: "agents/"` scans for `*.agent.md`); never edit
69
69
  them by hand. The `claude/` subtree is generated by the install-time generator
70
- `bin/installers/claude.mjs` (`pnpm build:claude` aliases `agent-cortex install claude`; `ralph`
70
+ `bin/installers/claude.mjs` (a plain `agent-cortex install claude` also registers the plugin
71
+ with Claude Code via the `claude plugin` CLI; `pnpm build:claude` is the generate-only alias,
72
+ running `agent-cortex install claude --output claude`; `ralph`
71
73
  is authored natively in `agents-native/` and copied verbatim; the other agents compose from their
72
74
  `claude/` harness dirs).
73
75
  - Keep orchestration logic in the agent file; extract shared per-task workflow into a skill
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5d4159f: Handoff documents now end with a `## Starter prompt` section: a ready-to-paste first-message prompt pointing the next session at the handoff doc by absolute path and the artifacts it references, telling it to read those before acting, asking it to clean up any provisional artifacts unless the handoff says otherwise, and staying under ~150 words.
8
+ - 5351ae9: agent-cortex install claude now fully installs agent-cortex into Claude Code: it regenerates the claude/ subtree and registers it with the Claude Code runtime via the claude plugin CLI (--dry-run prints the plan without writing; --output <dir> generates only).
9
+
10
+ ### Patch Changes
11
+
12
+ - adb5f84: Add optional ASCII workflow diagram guidance (inclusion rules, style guide, template example) to the skill anatomy and reference it from write-a-skill
13
+ - 5d4159f: Fix create-chores to resolve `bd` via PATH by default instead of a machine-specific hardcoded path. The BD_PATH env override is retained for machines where bd is not on PATH.
14
+ - 3e8b6e7: Refactor the `hitl-collab` skill to the canonical anatomy template: added When to use / When NOT to use boundaries, Red Flags, Common Rationalizations, a worked handoff-doc example, and a verification checklist; switched bead updates to `--append-notes` so existing notes are preserved.
15
+ - b33d9ef: Refactor the improve-codebase-architecture skill to the anatomy template: add when-to-use / when-not-to-use boundaries, red flags, common rationalizations, philosophy, phase-gate checklists, cross-skill references, a worked example, and a verification checklist.
16
+ - da1e3dd: Add `bd dep add` line to the init-beads skill's embedded AGENTS.md quick-reference template so it matches the repo template and stops re-propagating the drift
17
+ - 358509f: Prune stale doc-contract prose assertions from the run-pipeline-stage progress test; re-enable the skills-script test suites in the pnpm workspace so they actually run in CI.
18
+ - 32b33ac: Refactor the record-idea skill to the anatomy template: add when-to-use boundaries, red flags, rationale, and a verification checklist; move the idea-record scaffold to FORMAT.md to match the generator script.
19
+ - 662cea5: Refactor the `classify-bead` skill to the anatomy template: adds when-not-to-use boundaries, red flags, common rationalizations, philosophy, and a verification checklist.
20
+ - bb01fd6: Refactor create-task skill to the anatomy template: adds When to use / When NOT to use, Red Flags, Common Rationalizations, verification checklist, and moves the bead-property contract detail to REFERENCE.md. No behavioural change — the create-chores script invocation contract is preserved exactly.
21
+ - 876e5cc: Refactor design-an-interface skill to the anatomy template: adds When to use, When NOT to use, verification checklist, phase gates, and rationalization sections while keeping the parallel sub-agent design workflow intact
22
+ - 00c4238: Refactor grill-with-docs to the anatomy template: add when-to-use boundaries, numbered workflow, red flags, common rationalizations, examples, and a verification checklist; consolidate the previously-dangling CONTEXT.md/ADR format links into REFERENCE.md.
23
+ - fd5f787: Refactor init-beads skill to the anatomy template: adds When to use / When NOT to use, Red Flags, Common Rationalizations, Cross-skill references, Examples, and a verification checklist. No behavioural change — the `bd init --quiet --stealth` invocation, install-method preference order, and AGENTS.md quick-reference block are preserved exactly.
24
+ - 608fb58: Refactor maintain-agent-docs skill to the canonical anatomy template: added When NOT to use, Philosophy, Red Flags, Common Rationalizations, Phase-gate checklist, Cross-skill references, Examples, and a concrete Verification checklist; tightened the description to the two-sentence format with quoted trigger phrases.
25
+ - 027431c: Refactor the `prd-to-tasks` skill to the canonical anatomy template: condensed the 5-phase workflow, moved the epic/task body templates into `REFERENCE.md`, added Examples and Phase-gate checklists, and aligned section ordering and voice with `docs/skills/skill-anatomy.md`.
26
+ - e80246a: Refactor the ralph skill to the canonical skill anatomy: add When to use / When NOT to use, Red Flags, Common Rationalizations, Philosophy, phase-gate checklists, cross-skill references, and a verification checklist; align the skill docs with the ralph agent definition (state.json for poll-timer and agent-ID→bead bookkeeping, parent-keyed stage log files, stage runners self-serving `bd prime`, and the single-feature-epic one-hop branching shortcut).
27
+ - d917afb: Refactor request-refactor-plan SKILL.md to the anatomy template; move the refactor plan template into FORMAT.md.
28
+ - d6d33ec: Refactor technical-direction skill to the canonical anatomy template, adding when-to-use/not-to-use boundaries, red flags, common rationalizations, cross-skill references, an examples section, and a verification checklist. The decision-memo template moves to FORMAT.md.
29
+ - 67a668f: Refactor the write-a-prd skill to the anatomy template: adds when-to-use/when-not-to-use boundaries, red flags, common rationalizations, phase gates, cross-skill references, an example, and a verification checklist; the PRD template moves to FORMAT.md.
30
+ - bedd373: Refactor the write-a-ticket skill to the canonical anatomy template: added when-to-use and when-not-to-use boundaries, red flags, common rationalizations, philosophy, cross-skill references, worked examples, and a verification checklist. The ticket template and per-section guidance are preserved.
31
+ - fd95ffe: Refactor run-pipeline-stage SKILL.md to the canonical anatomy template: add `When to use`, `When NOT to use`, `Workflow`, `Red Flags`, `Common Rationalizations`, `Cross-skill references`, `Examples`, `Philosophy / rationale`, and a `Verification checklist`; add quoted trigger phrases to the description; tokenize subagent dispatch as {{TOOL:task}}. No behavioural change to the stage pipeline — all playbooks, prompts, dispatch rules, and path references are preserved.
32
+
3
33
  ## 1.38.1
4
34
 
5
35
  ### Patch Changes
package/README.md CHANGED
@@ -38,7 +38,7 @@ agent-cortex/
38
38
  │ ├── agent-cortex.mjs # CLI entrypoint
39
39
  │ └── installers/
40
40
  │ ├── copilot.mjs # shared generator: agent-cortex install copilot + scripts/build-copilot-agents.mjs
41
- │ └── claude.mjs # install-time generator — agent-cortex install claude (pnpm build:claude aliases it)
41
+ │ └── claude.mjs # install-time generator + Claude Code registrar (pnpm build:claude = generate-only --output form)
42
42
  ├── scripts/
43
43
  │ └── build-copilot-agents.mjs # thin wrapper over bin/installers/copilot.mjs (regenerates agents/*.agent.md)
44
44
  └── claude/ # Self-contained Claude Code plugin (GENERATED — do not hand-edit)
@@ -62,9 +62,11 @@ The `{{TOOL:...}}` / `{{PATH:...}}` tokens written in agent and skill files are
62
62
  per harness at install time from `token-map.json`, the single source of truth for
63
63
  canonical tool/path/agent names (see `token-map.README.md` and the `contract` section).
64
64
  The `claude/` subtree is **generated** by the install-time generator
65
- (`bin/installers/claude.mjs`) — `pnpm build:claude` is a pure alias of
66
- `agent-cortex install claude`, so there is no separate build-time code path, and the
67
- committed subtree can never diverge from a real install. CI regenerates it and checks
65
+ (`bin/installers/claude.mjs`). A plain `agent-cortex install claude` regenerates the
66
+ subtree AND registers it with Claude Code by driving the `claude plugin` CLI (marketplace
67
+ add → install → marketplace update → plugin update). `pnpm build:claude` is the pure,
68
+ generate-only alias — it passes `--output claude`, so CI and release drift-checks never
69
+ spawn the claude CLI or touch `~/.claude`. CI regenerates it and checks
68
70
  it is never stale:
69
71
 
70
72
  - **Skills** stay single-source — `claude/skills/<name>` are symlinks into the grouped
@@ -193,14 +195,14 @@ change the sources:
193
195
 
194
196
  ```sh
195
197
  pnpm build:copilot # or: node scripts/build-copilot-agents.mjs (regenerates agents/*.agent.md)
196
- pnpm build:claude # or: node bin/agent-cortex.mjs install claude (same generator)
198
+ pnpm build:claude # or: node bin/agent-cortex.mjs install claude --output claude (generate-only)
197
199
  # or the install-time entry (same generator, less typing):
198
200
  node bin/agent-cortex.mjs install copilot # regenerates agents/*.agent.md in place
199
201
  node bin/agent-cortex.mjs install copilot --dry-run # plan only, no writes
200
202
  node bin/agent-cortex.mjs install copilot --output /tmp/x # preview the flat files elsewhere
201
- node bin/agent-cortex.mjs install claude # regenerates ./claude in place
202
- node bin/agent-cortex.mjs install claude --dry-run # plan only, no writes
203
- node bin/agent-cortex.mjs install claude --output /tmp/x # write the subtree elsewhere
203
+ node bin/agent-cortex.mjs install claude # regenerates ./claude AND registers it with Claude Code
204
+ node bin/agent-cortex.mjs install claude --dry-run # plan generation + registration, no writes/spawns
205
+ node bin/agent-cortex.mjs install claude --output /tmp/x # generate only — no registration
204
206
  ```
205
207
 
206
208
  #### Try it for one session
@@ -217,8 +219,20 @@ claude --plugin-dir /path/to/agent-cortex/claude plugin details agent-cortex
217
219
  #### Install persistently (recommended)
218
220
 
219
221
  The repo ships a marketplace manifest (`.claude-plugin/marketplace.json`) that exposes the
220
- `claude/` subtree. Register it by **absolute path** (a bare `.` is rejected — use an absolute
221
- path or a `./`-prefixed one), then install:
222
+ `claude/` subtree. A plain `agent-cortex install claude` does both halves in one step: it
223
+ regenerates `claude/` and registers the plugin with Claude Code by driving the `claude
224
+ plugin` CLI (marketplace add → install → marketplace update → plugin update), pointing it
225
+ at this checkout's manifest. This requires the `claude` plugin CLI (Claude Code v2+):
226
+
227
+ ```sh
228
+ git clone https://github.com/jaybeeuu/agent-cortex # first time (or git pull to update)
229
+ agent-cortex install claude # regenerate + register (user scope)
230
+ ```
231
+
232
+ `--dry-run` prints the full plan without spawning the claude CLI or writing anything;
233
+ `--output <dir>` regenerates only, with no registration. The equivalent manual registration
234
+ (e.g. on a Claude Code build without the plugin CLI) adds the checkout by **absolute path**
235
+ (a bare `.` is rejected):
222
236
 
223
237
  ```sh
224
238
  claude plugin marketplace add /path/to/agent-cortex
@@ -232,16 +246,18 @@ flag, and Ralph is just `claude --agent agent-cortex:ralph`.
232
246
 
233
247
  #### Update
234
248
 
235
- The marketplace source is your local checkout, so after pulling changes you must rebuild the
236
- `claude/` subtree and refresh the plugin:
249
+ The marketplace source is your local checkout, so after pulling changes re-run the installer —
250
+ it rebuilds the `claude/` subtree and refreshes the registered plugin (marketplace update →
251
+ plugin update) in one step:
237
252
 
238
253
  ```sh
239
254
  git pull
240
- pnpm build:claude # alias of agent-cortex install claude
241
- claude plugin marketplace update jaybeeuu
242
- claude plugin update agent-cortex # restart Claude Code to apply
255
+ agent-cortex install claude # rebuild + refresh (restart Claude Code to apply)
243
256
  ```
244
257
 
258
+ `pnpm build:claude` only regenerates the subtree (no registration), so on its own it won't
259
+ refresh an installed plugin.
260
+
245
261
  #### Uninstall
246
262
 
247
263
  ```sh
@@ -300,7 +316,9 @@ per-harness frontmatter/sections, auto-composed by `scripts/build-copilot-agents
300
316
  the install-time generator `bin/installers/claude.mjs`), `agents-native/*.md` (Claude-only
301
317
  agents like `ralph` — the canonical bodies the installer copies verbatim), `skills/**`,
302
318
  `hooks/claude/hooks.json` (hook config), and `package.json` (plugin
303
- version) — then run `pnpm build:claude` (an alias of `agent-cortex install claude`). Never hand-edit
319
+ version) — then run `pnpm build:claude` (the generate-only alias of `agent-cortex install
320
+ claude --output claude`; run the plain install instead if you also want the plugin
321
+ re-registered with Claude Code). Never hand-edit
304
322
  anything under `claude/` except the hand-authored `claude/.mcp.json` and `claude/scripts/`
305
323
  files, or the generated `agents/*.agent.md` files, `claude/agents/`, `claude/skills/`,
306
324
  `claude/.claude-plugin/plugin.json`, and `claude/hooks.json`. CI runs
package/agents/README.md CHANGED
@@ -209,8 +209,9 @@ flat `agents/*.agent.md` files are built from them:
209
209
  - `scripts/build-copilot-agents.mjs` (`pnpm build:copilot`) composes `agents/*.agent.md` from
210
210
  each agent's `copilot/` harness dir — committed for Copilot CLI, which loads `*.agent.md`
211
211
  from `plugin.json`'s `agents: "agents/"` path.
212
- - `bin/installers/claude.mjs` (`agent-cortex install claude`; `pnpm build:claude` is a pure
213
- alias) composes `claude/agents/*.md` from each agent's `claude/` harness dir (except
212
+ - `bin/installers/claude.mjs` (plain `agent-cortex install claude` also registers the plugin
213
+ with Claude Code; `pnpm build:claude` is its generate-only alias, running `install claude
214
+ --output claude`) composes `claude/agents/*.md` from each agent's `claude/` harness dir (except
214
215
  `ralph`, which ships natively from `agents-native/ralph.md`, copied verbatim).
215
216
  - The pi harness delivers two ways: the `agent-modes` extension composes `agent.md` +
216
217
  `pi/frontmatter.json` at runtime against `token-map.json`, and `agent-cortex install pi`
@@ -219,9 +220,10 @@ flat `agents/*.agent.md` files are built from them:
219
220
 
220
221
  Never edit the generated flat/claude files by hand — edit the composable directory. CI
221
222
  regenerates both outputs and fails on drift. Generation is install-time: `claude` ships
222
- via `bin/installers/claude.mjs`, the single generator behind both `agent-cortex install
223
- claude` and the `pnpm build:claude` alias (the committed `claude/` subtree is regenerated
224
- by it and drift-checked, so it can never be stale); `copilot` ships via
223
+ via `bin/installers/claude.mjs`, the generator behind plain `agent-cortex install claude`
224
+ (which also registers the plugin with Claude Code) and its generate-only `pnpm
225
+ build:claude` alias (`install claude --output claude`) — the committed `claude/` subtree
226
+ is regenerated by it and drift-checked, so it can never be stale; `copilot` ships via
225
227
  `bin/installers/copilot.mjs`, the shared code path behind both `agent-cortex install
226
228
  copilot` and `scripts/build-copilot-agents.mjs`; `pi` ships via
227
229
  `bin/installers/pi.mjs`, which materialises composed agents + token-substituted skills
@@ -63,7 +63,7 @@ bd dep add <feature-or-task-id> <planning-gate-id> # feature/task depends on p
63
63
 
64
64
  Do not close planning gates in bulk. Only close a gate after the user explicitly confirms that exact feature/task is ready to implement; leave all unconfirmed gates open and blocking.
65
65
 
66
- After creating each bead, invoke **classify-bead** to ensure it has an `implementation-type` label before handing off.
66
+ Before handing off, ensure every bead created in this step carries an `implementation-type` label — check `bd label list <id>` yourself. Do not spawn `classify-bead` here: planning gates were tagged inline above and `create-task` classifies its beads internally. Only invoke it for a bead that genuinely lacks both the label and a `## Type` field.
67
67
 
68
68
  Tag every bead created in this step with `workflow:ralph`:
69
69
 
@@ -71,7 +71,7 @@ bd dep add <feature-or-task-id> <planning-gate-id> # feature/task depends on p
71
71
 
72
72
  Do not close planning gates in bulk. Only close a gate after the user explicitly confirms that exact feature/task is ready to implement; leave all unconfirmed gates open and blocking.
73
73
 
74
- After creating each bead, invoke **classify-bead** to ensure it has an `implementation-type` label before handing off.
74
+ Before handing off, ensure every bead created in this step carries an `implementation-type` label — check `bd label list <id>` yourself. Do not spawn `classify-bead` here: planning gates were tagged inline above and `create-task` classifies its beads internally. Only invoke it for a bead that genuinely lacks both the label and a `## Type` field.
75
75
 
76
76
  Tag every bead created in this step with `workflow:ralph`:
77
77
 
@@ -46,15 +46,23 @@ if (parsed.command === "install") {
46
46
 
47
47
  process.stdout.write(`Installing agent-cortex for "${parsed.harness}" harness…\n`);
48
48
 
49
- // claude is the first wired harness: generates the plugin subtree from the
50
- // canonical sources (agents/, agents-native/, skills/, hooks/claude/) via the
51
- // shared installClaude generator — `pnpm build:claude` is an alias of this
52
- // invocation, so there is no separate build-time code path.
49
+ // claude is the first wired harness: a plain `agent-cortex install claude`
50
+ // regenerates the plugin subtree from the canonical sources (agents/,
51
+ // agents-native/, skills/, hooks/claude/) via the shared installClaude
52
+ // generator AND registers it with Claude Code (marketplace add → install →
53
+ // update) — `pnpm build:claude` is the generate-only alias of this
54
+ // invocation (it passes `--output claude`), so there is no separate
55
+ // build-time code path and CI drift-checks never touch ~/.claude.
53
56
  if (parsed.harness === "claude") {
54
57
  // Avoid loading the installer on the help/summary paths and for other harnesses.
55
- const { installClaude } = await import("./installers/claude.mjs");
58
+ const { installClaude, registerClaude } = await import("./installers/claude.mjs");
56
59
  try {
57
60
  installClaude({ output: parsed.output, dryRun: parsed.dryRun });
61
+ // Runtime registration happens only for the plain install — `--output`
62
+ // keeps generating only (documented in --help).
63
+ if (parsed.output === undefined) {
64
+ registerClaude({ dryRun: parsed.dryRun });
65
+ }
58
66
  process.exit(0);
59
67
  } catch (err) {
60
68
  process.stderr.write(`Install failed: ${err.message}\n`);
@@ -1,19 +1,24 @@
1
- // Install-time generator for the Claude Code plugin subtree — the ONLY code path
2
- // for producing claude/ from the canonical sources. There is no build-time
3
- // generator: the package script `pnpm build:claude` is a pure alias of the CLI
4
- // (`node bin/agent-cortex.mjs install claude`), so regenerating the committed
5
- // subtree and installing the plugin run exactly the same code:
1
+ // Install-time generator + registrar for the Claude Code plugin. Producing
2
+ // claude/ from the canonical sources is the ONLY code path — there is no
3
+ // separate build-time generator: the package script `pnpm build:claude` runs
4
+ // the same command as the CLI with `--output` (`node bin/agent-cortex.mjs
5
+ // install claude --output claude`), so the committed subtree and installer
6
+ // output can never diverge:
6
7
  //
7
- // node bin/agent-cortex.mjs install claude `pnpm build:claude` (regenerates
8
- // the committed claude/ subtree in place; `--output
9
- // <dir>` targets another dir, `--dry-run` plans
10
- // without writing)
8
+ // node bin/agent-cortex.mjs install claude regenerates claude/ in place
9
+ // AND registers the plugin with Claude Code via
10
+ // the `claude plugin` CLI (marketplace add →
11
+ // install → marketplace update → plugin update)
12
+ // node bin/agent-cortex.mjs install claude --output <dir>
13
+ // generates only — no runtime registration
14
+ // node bin/agent-cortex.mjs install claude --dry-run
15
+ // plans generation + registration without writing
11
16
  //
12
- // claude/ stays committed (not gitignored): the marketplace install flow
13
- // (`claude plugin marketplace add <repo>` → `claude plugin install
14
- // agent-cortex@jaybeeuu`) reads the subtree straight from the working tree, so a
15
- // fresh clone installs as-is with no generation step. CI regenerates it via the
16
- // same installer and runs `git diff --exit-code claude/...` — byte-for-byte
17
+ // claude/ stays committed (not gitignored): registration points Claude Code's
18
+ // marketplace at this checkout (`.claude-plugin/marketplace.json` exposes
19
+ // ./claude), so the plugin content is the working tree and a fresh clone
20
+ // installs as-is with no generation step. CI regenerates claude/ via
21
+ // `--output` and runs `git diff --exit-code claude/...` — byte-for-byte
17
22
  // validation that the committed output equals installer output, catching stale
18
23
  // output and hand-edits to generated files alike.
19
24
  //
@@ -39,7 +44,8 @@
39
44
  // Zero dependencies so it runs on the CI Node and local Node alike.
40
45
 
41
46
  import { readFileSync, writeFileSync, mkdirSync, rmSync, symlinkSync, statSync, existsSync, readdirSync } from "node:fs";
42
- import { join, dirname, relative } from "node:path";
47
+ import { spawnSync } from "node:child_process";
48
+ import { join, dirname, relative, resolve } from "node:path";
43
49
  import { fileURLToPath } from "node:url";
44
50
  import { composeAgent } from "../../scripts/lib/compose-agent.mjs";
45
51
 
@@ -258,5 +264,113 @@ export function installClaude({ root = DEFAULT_ROOT, output, dryRun = false } =
258
264
  console.log(`Skipped hooks.json — ${hooksSrc} not found (existing file left untouched)`);
259
265
  }
260
266
 
267
+ return summary;
268
+ }
269
+
270
+ // ─── Claude Code registration ────────────────────────────────────────────────
271
+
272
+ // The `claude` CLI on PATH. Overridable in tests via the claudeBin option.
273
+ const DEFAULT_CLAUDE_BIN = "claude";
274
+
275
+ /**
276
+ * Read the marketplace manifest that exposes this checkout's claude/ subtree
277
+ * (`.claude-plugin/marketplace.json`); returns the marketplace and plugin
278
+ * names that `claude plugin` commands address. Registration is only possible
279
+ * from a checkout carrying the manifest.
280
+ */
281
+ function readMarketplaceManifest(root) {
282
+ const manifestPath = join(root, ".claude-plugin", "marketplace.json");
283
+ let manifest;
284
+ try {
285
+ manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
286
+ } catch (err) {
287
+ throw new Error(
288
+ `no Claude marketplace manifest at ${manifestPath} (${err.message}) — ` +
289
+ `"agent-cortex install claude" registers the plugin by pointing Claude Code at this checkout`,
290
+ );
291
+ }
292
+ const marketplace = manifest.name;
293
+ const plugin = manifest.plugins?.[0]?.name;
294
+ if (typeof marketplace !== "string" || typeof plugin !== "string") {
295
+ throw new Error(
296
+ `unparsable marketplace manifest at ${manifestPath}: expected { name, plugins: [{ name }] }`,
297
+ );
298
+ }
299
+ return { marketplace, plugin };
300
+ }
301
+
302
+ /** Run one claude plugin command, inheriting its output; throws on failure. */
303
+ function runClaudeCommand(claudeBin, args) {
304
+ const label = `${claudeBin} ${args.join(" ")}`;
305
+ const result = spawnSync(claudeBin, args, { stdio: "inherit" });
306
+ if (result.error) {
307
+ throw new Error(`failed to run "${label}": ${result.error.message}`);
308
+ }
309
+ if (result.status !== 0) {
310
+ throw new Error(`"${label}" exited ${result.status}`);
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Register the freshly generated claude/ subtree with Claude Code by driving
316
+ * the `claude plugin` CLI against this checkout as the marketplace source:
317
+ *
318
+ * 1. `claude plugin marketplace add <root>` (idempotent: already on disk)
319
+ * 2. `claude plugin install <plugin>@<market> -y` (idempotent: already installed)
320
+ * 3. `claude plugin marketplace update <market>` (re-validate the directory source)
321
+ * 4. `claude plugin update <plugin> -y` (refresh the cache on version bumps)
322
+ *
323
+ * Requires a Claude Code binary whose `plugin` subcommand exists (v2+); older
324
+ * CLIs treat the args as a chat prompt, so support is probed first. In
325
+ * --dry-run mode nothing is spawned — the commands are reported as a plan.
326
+ *
327
+ * @param {object} options
328
+ * @param {string} [options.root] Checkout root carrying .claude-plugin/marketplace.json
329
+ * (defaults to the repo containing this module)
330
+ * @param {string} [options.claudeBin] The `claude` executable (default: `claude` from PATH)
331
+ * @param {boolean} [options.dryRun] Plan and report without running or writing
332
+ * @returns {{ marketplace: string, plugin: string, commands: string[][], dryRun: boolean }}
333
+ */
334
+ export function registerClaude({ root = DEFAULT_ROOT, claudeBin = DEFAULT_CLAUDE_BIN, dryRun = false } = {}) {
335
+ const { marketplace, plugin } = readMarketplaceManifest(root);
336
+ const pluginId = `${plugin}@${marketplace}`;
337
+ const commands = [
338
+ ["plugin", "marketplace", "add", resolve(root)],
339
+ ["plugin", "install", pluginId, "-y"],
340
+ ["plugin", "marketplace", "update", marketplace],
341
+ ["plugin", "update", plugin, "-y"],
342
+ ];
343
+
344
+ const summary = { marketplace, plugin, commands, dryRun };
345
+ console.log(`Registering plugin "${pluginId}" with Claude Code (via ${claudeBin})…`);
346
+
347
+ if (dryRun) {
348
+ for (const args of commands) console.log(` would run: ${claudeBin} ${args.join(" ")}`);
349
+ console.log("(dry-run — no Claude Code state written)");
350
+ return summary;
351
+ }
352
+
353
+ // Older Claude Code builds treat `claude plugin …` as a chat prompt; reject
354
+ // them up-front instead of letting the registration appear to succeed.
355
+ const probe = spawnSync(claudeBin, ["plugin", "--help"], { stdio: "ignore" });
356
+ if (probe.error) {
357
+ throw new Error(
358
+ `cannot run "${claudeBin}" (${probe.error.message}) — is Claude Code installed and on PATH?`,
359
+ );
360
+ }
361
+ if (probe.status !== 0) {
362
+ throw new Error(
363
+ `"${claudeBin}" lacks the "plugin" subcommand — its Claude Code build predates plugin support; ` +
364
+ `update to a build with the plugin CLI (v2+), e.g. "pnpm add -g @anthropic-ai/claude-code@latest", and re-run`,
365
+ );
366
+ }
367
+
368
+ for (const args of commands) {
369
+ console.log(` ${claudeBin} ${args.join(" ")}`);
370
+ runClaudeCommand(claudeBin, args);
371
+ }
372
+ console.log(
373
+ `Installed — verify with "claude plugin list" / "claude plugin details ${plugin}" (restart Claude Code to apply).`,
374
+ );
261
375
  return summary;
262
376
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-cortex",
3
- "version": "1.38.1",
3
+ "version": "1.39.0",
4
4
  "description": "Personal Claude Code plugin with custom agents and skills",
5
5
  "author": {
6
6
  "name": "jaybeeuu"
@@ -70,7 +70,7 @@ bd dep add <feature-or-task-id> <planning-gate-id> # feature/task depends on p
70
70
 
71
71
  Do not close planning gates in bulk. Only close a gate after the user explicitly confirms that exact feature/task is ready to implement; leave all unconfirmed gates open and blocking.
72
72
 
73
- After creating each bead, invoke **classify-bead** to ensure it has an `implementation-type` label before handing off.
73
+ Before handing off, ensure every bead created in this step carries an `implementation-type` label — check `bd label list <id>` yourself. Do not spawn `classify-bead` here: planning gates were tagged inline above and `create-task` classifies its beads internally. Only invoke it for a bead that genuinely lacks both the label and a `## Type` field.
74
74
 
75
75
  Tag every bead created in this step with `workflow:ralph`:
76
76
 
@@ -0,0 +1,75 @@
1
+ # Idea: extension-manifests
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Created
7
+ 2026-08-25
8
+
9
+ ## Problem
10
+ PI extensions and Claude/Copilot plugins are installed individually (`pi install <ext>`) and
11
+ live implicit in the machine's state (`~/.pi/agent/extensions/`) with no declared manifest of
12
+ what the author uses or where it came from. A fresh machine, clean `~/.pi`, or a failed update
13
+ leaves the environment without the expected extensions. The toolset isn't reproducible and
14
+ isn't documented anywhere in the author's repos. Experimenting with an extension (install, try,
15
+ remove) is also all manual, and there's no way to uninstall cleanly.
16
+
17
+ ## Who benefits
18
+ The author. Installing/updating agent-cortex becomes a reliable way to restore a known PI +
19
+ Claude environment (agent-cortex + declared extensions in one step). The manifests document and
20
+ reproduce the toolset across machines. A prune CLI makes extension experimentation fast and safe.
21
+
22
+ ## Proposed outcome
23
+ agent-cortex ships **committed extension manifests** (reviewed and stored on GitHub) declaring
24
+ which extensions to install — **per harness**: one manifest for PI extensions, one for
25
+ Claude/Copilot plugins. On install or update of agent-cortex, it reads the manifests and
26
+ installs the declared extensions. The manifests are the single source of truth.
27
+
28
+ Key decisions from the interview:
29
+
30
+ 1. **No monitoring** — nothing observes installs, and the CLI never writes the manifests.
31
+ Adding an extension = edit the manifest, commit it, ship it. This keeps the source of truth
32
+ in GitHub where it belongs (and gets the usual PR/review flow).
33
+ 2. **Per-harness manifests** — separate records for the pi harness vs the Claude harness, each
34
+ carrying the extension source (git URL / package name) for that harness's installer. The
35
+ install-on-update path handles each harness with its own mechanism.
36
+ 3. **Prune CLI with a TUI** — a CLI command (e.g. `agent-cortex ext prune`) opens an interactive
37
+ TUI listing locally-installed extensions; selecting one **uninstalls** it from the local
38
+ environment. Removing from the manifest is done manually on GitHub. This supports the
39
+ experimentation loop: install → try → prune locally, then curate the manifest separately.
40
+
41
+ agent-cortex's own bundled extensions (auto-discovered via `pi install`, e.g. `skill-stats`)
42
+ are deliberately excluded from the manifests — only third-party extensions are declared.
43
+
44
+ ## Validity check
45
+ - Evidence we already have: agent-cortex already has an install surface to hang this on
46
+ (`pi install` package discovery for the pi harness, plus the existing `bin/agent-cortex.mjs`
47
+ install command and `postinstall` script). The repo already carries a `plugin.json` (Claude
48
+ harness) alongside `package.json` (pi harness), showing the per-harness split is natural.
49
+ - Riskiest assumption: that an automated install-on-update of declared extensions is safe and
50
+ desirable (auto-installing on every update could surprise, or fail mid-flight on a new
51
+ machine lacking auth/network). Also, the TUI prune needs the local extension store's shape
52
+ (`~/.pi/agent/extensions/` for pi; whatever Claude uses) to be introspectable.
53
+ - What would invalidate this idea: if auto-install-on-update proves too disruptive (better as
54
+ an explicit `agent-cortex ext install` command), or if the pi/Claude installers don't expose
55
+ the store in a way that supports listing + uninstall for the TUI.
56
+
57
+ ## Constraints
58
+ - Manifests live in this repo, committed via the normal PR flow — the CLI never edits them.
59
+ - Install-on-update must be idempotent and safe to skip/fail gracefully (no hard breakage of
60
+ agent-cortex's own install on extension failure).
61
+ - Follow the repo's extension conventions where relevant (lightweight, no internal LLM calls).
62
+ - If any local data is persisted (e.g. prune history), write to `~/.pi/agent-cortex/`.
63
+
64
+ ## Next validation step
65
+ Confirm the install surface for each harness: how `pi install <source>` works for the pi side,
66
+ and how Claude/Copilot plugins get installed, plus whether each store can be listed and
67
+ uninstalled programmatically (needed for the prune TUI). Then prototype the manifest + one
68
+ harness's install-on-update path.
69
+
70
+ ## Notes
71
+ Recorded 2026-08-25. The idea was refined during the interview: initially framed as
72
+ "record the extensions I use" (observer-based), corrected to a **committed manifest** model —
73
+ recording happens by editing + committing, not by monitoring. Prune uninstalls locally only;
74
+ the manifest stays GitHub-managed. This idea is adjacent to `record-ideas-as-beads`: both make
75
+ agent-cortex the declared source of truth for the author's environment and workflow.
@@ -0,0 +1,115 @@
1
+ # Idea: record-ideas-as-beads
2
+
3
+ ## Status
4
+ Fleshed out 2026-08-25 — design decisions locked in an interview; not yet implemented.
5
+
6
+ ## Created
7
+ 2026-08-25
8
+
9
+ ## Problem
10
+ Ideas currently live as loose markdown files in `docs/ideas/`. This sits awkwardly alongside
11
+ the rest of the workflow, which is almost entirely bead-based (bd). Because ideas aren't beads,
12
+ they can't be searched with `bd label`, can't express relationships/dependencies to real tasks,
13
+ can't be given priority that surfaces alongside other work, and can't sync to remote via
14
+ `bd dolt push`. There's no clean promotion path from "idea" to "epic" to "executable task".
15
+
16
+ ## Who benefits
17
+ The author's daily planning loop. Ideas are the beginning of epics, so making them first-class
18
+ beads gives a single coherent backlog where an idea can grow relationships to the tasks it
19
+ spawns. The plan/agent-nexus agents benefit too: agent-nexus will eventually schedule work
20
+ through planning stages (not just execution), and a beads-native idea record gives it a clean
21
+ input to plan against.
22
+
23
+ ## Proposed outcome
24
+ Record ideas as beads labelled `kind:idea`, replacing `docs/ideas/*.md` entirely (bead-only —
25
+ files deleted after migration). `bd` already supports labels natively (`bd create -l`,
26
+ `bd label add/list`). An idea bead maps directly to an epic; promoting it means spawning task
27
+ beads as children and letting the idea bead become the epic node.
28
+
29
+ ## Fleshed-out design (decided 2026-08-25)
30
+
31
+ ### Label & identification
32
+ - **`kind:idea` label** marks idea beads. Ideas do NOT use `deferred` status — they stay
33
+ `open` so they're visible to idea tooling; hiding from actionable work is done by exclusion,
34
+ not status.
35
+ - **ralph excludes them**: ready queries use `bd ready --exclude-label kind:idea`
36
+ (verified: `bd ready` supports `--exclude-label`). Idea beads never appear as claimable work.
37
+ - Optional companion labels: `priority:<0-4>`, `epic:<id>` once promoted.
38
+
39
+ ### Flesh-out workflow (the skill that consumes them)
40
+ There should be a **flesh-out skill** (e.g. `flesh-out-idea`) that answers: *"which idea beads
41
+ are ready to be fleshed out?"* This is `bd ready -l kind:idea` — the blocker-aware ready query
42
+ scoped to ideas. Because `bd ready` already respects dependencies, an idea bead that
43
+ `depends-on` in-flight work (e.g. "needs unified-ci-pipeline landed first") naturally shows as
44
+ *not ready* until its deps close. That's exactly the semantics wanted:
45
+ - `bd ready -l kind:idea` → list & pick an idea ready for fleshing.
46
+ - The skill runs the record-idea-style interview (why / how / when / priority) at deeper depth,
47
+ updating the bead's description/design/notes as the idea ripens.
48
+ - Once fleshed out enough, the idea can be promoted (below).
49
+
50
+ ### Promotion path: idea → epic → tasks
51
+ Parent-child hierarchy (chosen over labels+deps only):
52
+ 1. Idea bead starts with `kind:idea`, type defaulted appropriately (still `task` type, or set
53
+ `epic` type on promotion).
54
+ 2. On promotion: `bd label add <idea> epic:<idea-id>` (or flip to an epic label), then spawn
55
+ task beads with `--parent <idea-id>` — children inherit the epic relationship natively.
56
+ 3. The idea bead becomes the epic node; its children are the executable tasks. Closing the
57
+ children resolves to the epic closing.
58
+
59
+ ### Content model (bead fields)
60
+ Map the current idea-template sections onto bd fields:
61
+ | md template field | bd field |
62
+ |---|---|
63
+ | Title | `--title` |
64
+ | Problem / Why | `--description` |
65
+ | How we might do it | `--design` |
66
+ | When / Priority / Validity / Constraints / Notes | `--notes` (structured, keep section markers) |
67
+ | anything referential | `--context` |
68
+
69
+ Multiple sections per field use explicit markers (`## Validity check`, etc.) inside the field
70
+ so the flesh-out interview can find/update them later.
71
+
72
+ ### Skill changes
73
+ - **`record-idea`**: replace scaffold-file flow (`new-idea.sh` → `docs/ideas/x.md`) with bead
74
+ creation: interview → `bd create "<title>" -l kind:idea -d "<why>" --design "<how>"
75
+ --notes "<when/priority/validity>"`. Keep the interview; drop the markdown scaffold script.
76
+ - New **`flesh-out-idea`** skill (see above) — validates readiness (`bd ready -l kind:idea`),
77
+ picks an idea, drives the deepening interview, updates the bead, optionally promotes.
78
+
79
+ ### Migration
80
+ - Bulk-migrate the existing `docs/ideas/*.md` records to beads: read each file, map sections to
81
+ bd fields, `bd create -l kind:idea`, preserve priority. Run as a one-off (manual or scripted).
82
+ - Then **delete `docs/ideas/`** — bead-only going forward.
83
+ - Update `AGENTS.md` + any stale references that point at `docs/ideas/`.
84
+ - The `record-idea` skill itself must unlearn the docs/ideas path.
85
+
86
+ ## Validity check
87
+ - Evidence we already have: `bd ready --exclude-label` and `bd ready -l` both exist and compose
88
+ (label filtering + blocker-aware ready semantics) — the two core mechanisms this idea needs
89
+ are native, no feature build. `--parent` exists for the hierarchy. 9-10 idea files exist to
90
+ migrate; the record-idea skill and its script are the only two consumers of the file flow.
91
+ - Riskiest assumption: that keeping ideas `open` (not `deferred`) + label exclusion is
92
+ discoverable enough — ralph, plan agents, and the author must remember the exclusion. The
93
+ `bd-tool` skill's labels table needs `kind:idea` documented with the exclusion convention.
94
+ - What would invalidate this idea: if label-based exclusion leaks idea beads into `bd ready`
95
+ via some path (e.g. `bd ready` without the exclude flag), or if losing the scannable
96
+ `docs/ideas/` directory hurts occasional review more than bead queries help it.
97
+
98
+ ## Constraints
99
+ - Ideas stay quick to scan: `bd list -l kind:idea` + `bd show <id>` should be a comfortable
100
+ replacement for opening the directory.
101
+ - Idea beads must never appear in ralph's actionable-ready view.
102
+ - `record-idea` and `bd-tool` skills stay consistent — no stale references to docs/ideas.
103
+ - Priority of ideas uses the same P0-P4 scale as tasks (P4 = backlog default for ideas).
104
+
105
+ ## Next validation step
106
+ Prototype one idea as a labelled bead: create it with `-l kind:idea`, confirm `bd ready`
107
+ excludes it by default and `bd ready -l kind:idea` surfaces it; then promote it (add epic label,
108
+ spawn a child task) to confirm the hierarchy reads correctly. If the prototype passes, do the
109
+ bulk migration + skill updates.
110
+
111
+ ## Notes
112
+ Interview on 2026-08-25 locked: labels over status (kind:idea + ralph exclusion), bead-only
113
+ content (files deleted), parent-child promotion, and record-idea skill rewritten to create
114
+ beads. Agent-nexus is the planned consumer. Once this lands, this very record becomes an
115
+ idea-bead (and then this file is deleted — the migration eats its own tail).