@jaybeeuu/agent-cortex 1.37.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 (135) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +9 -8
  2. package/.github/workflows/ci.yml +190 -8
  3. package/AGENTS.md +27 -6
  4. package/CHANGELOG.md +72 -0
  5. package/README.md +156 -39
  6. package/agents/README.md +49 -13
  7. package/agents/plan/agent.md +51 -0
  8. package/agents/plan/claude/frontmatter.json +6 -0
  9. package/agents/plan/copilot/frontmatter.json +6 -0
  10. package/agents/plan/pi/frontmatter.json +6 -0
  11. package/agents/plan.agent.md +3 -0
  12. package/agents/ralph/agent.md +262 -0
  13. package/agents/ralph/claude/frontmatter.json +6 -0
  14. package/agents/ralph/claude/polling.md +31 -0
  15. package/agents/ralph/copilot/frontmatter.json +6 -0
  16. package/agents/ralph/copilot/polling.md +62 -0
  17. package/agents/ralph/pi/frontmatter.json +6 -0
  18. package/agents/ralph/pi/polling.md +74 -0
  19. package/agents/ralph-plan/agent.md +114 -0
  20. package/agents/ralph-plan/claude/frontmatter.json +6 -0
  21. package/agents/ralph-plan/copilot/frontmatter.json +6 -0
  22. package/agents/ralph-plan/pi/frontmatter.json +6 -0
  23. package/agents/ralph-plan.agent.md +6 -3
  24. package/agents/ralph.agent.md +83 -57
  25. package/agents/strategy/agent.md +104 -0
  26. package/agents/strategy/claude/frontmatter.json +6 -0
  27. package/agents/strategy/copilot/frontmatter.json +6 -0
  28. package/agents/strategy/pi/frontmatter.json +6 -0
  29. package/agents/strategy.agent.md +3 -0
  30. package/bin/agent-cortex.mjs +76 -1
  31. package/bin/installers/claude.mjs +376 -0
  32. package/bin/installers/copilot.mjs +129 -0
  33. package/bin/installers/pi.mjs +197 -0
  34. package/claude/.claude-plugin/plugin.json +1 -1
  35. package/claude/agents/plan.md +3 -1
  36. package/claude/agents/ralph-plan.md +6 -4
  37. package/claude/agents/strategy.md +3 -1
  38. package/claude/hooks/scripts/notify.mjs +54 -0
  39. package/claude/hooks.json +15 -0
  40. package/docs/claude-hooks.md +115 -0
  41. package/docs/ideas/auto-model-selection.md +75 -0
  42. package/docs/ideas/extension-manifests.md +75 -0
  43. package/docs/ideas/improve-pi-system-prompt.md +34 -0
  44. package/docs/ideas/model-selector.md +40 -0
  45. package/docs/ideas/pi-task-memory.md +34 -0
  46. package/docs/ideas/qa-extension.md +43 -0
  47. package/docs/ideas/record-ideas-as-beads.md +115 -0
  48. package/docs/ideas/subagent-visibility.md +72 -0
  49. package/docs/ideas/task-session-context.md +89 -0
  50. package/docs/ideas/unified-ci-pipeline.md +28 -0
  51. package/docs/research/skill-design-research.md +4 -4
  52. package/docs/research/skill-improvements-analysis.md +1 -1
  53. package/docs/skills/skill-anatomy.md +47 -2
  54. package/docs/technical-direction/migration-execution-labels.md +132 -0
  55. package/extensions/agent-modes/README.md +54 -0
  56. package/extensions/agent-modes/discover.test.ts +241 -0
  57. package/extensions/agent-modes/discover.ts +458 -0
  58. package/extensions/agent-modes/index.ts +13 -224
  59. package/extensions/agent-modes/node_modules/.bin/pi +21 -0
  60. package/extensions/agent-modes/node_modules/.bin/tsc +21 -0
  61. package/extensions/agent-modes/node_modules/.bin/tsserver +21 -0
  62. package/extensions/agent-modes/node_modules/.bin/tsx +21 -0
  63. package/extensions/agent-modes/package.json +20 -0
  64. package/extensions/agent-modes/tsconfig.json +12 -0
  65. package/extensions/subagent/README.md +19 -0
  66. package/extensions/subagent/index.ts +131 -45
  67. package/extensions/subagent/node_modules/.bin/pi +21 -0
  68. package/extensions/subagent/node_modules/.bin/pi-ai +21 -0
  69. package/extensions/subagent/node_modules/.bin/tsc +21 -0
  70. package/extensions/subagent/node_modules/.bin/tsserver +21 -0
  71. package/extensions/subagent/node_modules/.bin/tsx +21 -0
  72. package/extensions/subagent/package.json +23 -0
  73. package/extensions/subagent/tsconfig.json +12 -0
  74. package/extensions/subagent/wait.test.ts +202 -0
  75. package/extensions/subagent/wait.ts +118 -0
  76. package/hooks/claude/hooks.json +38 -0
  77. package/hooks/claude/scripts/notify.mjs +54 -0
  78. package/lib/cli.mjs +68 -3
  79. package/package.json +6 -4
  80. package/plugin.json +1 -1
  81. package/pnpm-workspace.yaml +1 -1
  82. package/scripts/build-copilot-agents.mjs +30 -0
  83. package/scripts/lib/compose-agent.mjs +241 -0
  84. package/skills/engineering/design-an-interface/SKILL.md +78 -58
  85. package/skills/engineering/grill-with-docs/REFERENCE.md +78 -0
  86. package/skills/engineering/grill-with-docs/SKILL.md +66 -63
  87. package/skills/engineering/improve-codebase-architecture/SKILL.md +66 -48
  88. package/skills/engineering/technical-direction/FORMAT.md +38 -0
  89. package/skills/engineering/technical-direction/SKILL.md +70 -77
  90. package/skills/planning/classify-bead/SKILL.md +59 -35
  91. package/skills/planning/create-task/REFERENCE.md +40 -0
  92. package/skills/planning/create-task/SKILL.md +70 -66
  93. package/skills/planning/create-task/scripts/create-chores.ts +6 -1
  94. package/skills/planning/create-task/scripts/node_modules/.bin/tsc +21 -0
  95. package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +21 -0
  96. package/skills/planning/create-task/scripts/node_modules/.bin/tsx +21 -0
  97. package/skills/planning/prd-to-tasks/REFERENCE.md +66 -0
  98. package/skills/planning/prd-to-tasks/SKILL.md +86 -170
  99. package/skills/planning/record-idea/FORMAT.md +44 -0
  100. package/skills/planning/record-idea/SKILL.md +70 -53
  101. package/skills/planning/request-refactor-plan/FORMAT.md +45 -0
  102. package/skills/planning/request-refactor-plan/SKILL.md +57 -46
  103. package/skills/planning/write-a-prd/FORMAT.md +54 -0
  104. package/skills/planning/write-a-prd/SKILL.md +49 -48
  105. package/skills/planning/write-a-ticket/SKILL.md +68 -53
  106. package/skills/productivity/handoff/SKILL.md +12 -0
  107. package/skills/productivity/init-beads/SKILL.md +48 -40
  108. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +21 -0
  109. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +21 -0
  110. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +21 -0
  111. package/skills/productivity/write-a-skill/SKILL.md +2 -1
  112. package/skills/review/maintain-agent-docs/SKILL.md +71 -51
  113. package/skills/workflow/hitl-collab/SKILL.md +86 -17
  114. package/skills/workflow/ralph/REFERENCE.md +24 -19
  115. package/skills/workflow/ralph/SKILL.md +88 -74
  116. package/skills/workflow/run-pipeline-stage/REFERENCE.md +22 -0
  117. package/skills/workflow/run-pipeline-stage/SKILL.md +91 -93
  118. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +6 -107
  119. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +4 -2
  120. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +21 -0
  121. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +21 -0
  122. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +21 -0
  123. package/skills/workflow/using-agent-skills/SKILL.md +122 -0
  124. package/test/claude-installer.test.mjs +248 -0
  125. package/test/cli.test.mjs +115 -2
  126. package/test/copilot-installer.test.mjs +298 -0
  127. package/test/installer.test.mjs +179 -0
  128. package/test/notify-hook.test.mjs +63 -0
  129. package/test/pi-installer.test.mjs +371 -0
  130. package/token-map.README.md +130 -0
  131. package/token-map.json +106 -0
  132. package/.github/workflows/ci.test.ts +0 -217
  133. package/.github/workflows/release.yml +0 -58
  134. package/scripts/build-claude-agents.mjs +0 -179
  135. package/scripts/publish-release.sh +0 -32
package/README.md CHANGED
@@ -11,11 +11,12 @@ agent-cortex/
11
11
  ├── plugin.json # Copilot plugin manifest
12
12
  ├── .claude-plugin/
13
13
  │ └── marketplace.json # Claude marketplace (exposes ./claude as the "jaybeeuu" market)
14
- ├── agents/ # Canonical agents (Copilot/pi format: *.agent.md)
15
- │ ├── ralph.agent.md
16
- │ ├── ralph-plan.agent.md
17
- │ ├── plan.agent.md
18
- │ └── strategy.agent.md
14
+ ├── agents/ # Canonical agents — composable <name>/ dirs (see agents/README.md)
15
+ │ ├── *.agent.md # ralph, ralph-plan, plan, strategy — GENERATED from <name>/ by scripts/build-copilot-agents.mjs
16
+ │ ├── ralph/ # composable form (shared agent.md + per-harness pi/, copilot/, claude/)
17
+ │ ├── plan/ # "
18
+ │ ├── ralph-plan/ # "
19
+ │ └── strategy/ # "
19
20
  ├── agents-native/ # Claude-only agents with no Copilot equivalent
20
21
  │ └── ralph.md # the lean Claude Ralph
21
22
  ├── skills/ # Skills (grouped by domain) — shared by all harnesses
@@ -26,39 +27,94 @@ agent-cortex/
26
27
  │ ├── style/ # style-code, style-tests, style-comms, style-documentation
27
28
  │ └── workflow/ # ralph, run-pipeline-stage, create-task, …
28
29
  ├── extensions/ # pi extensions (pi only)
30
+ │ ├── agent-modes/ # switchable agent modes (reads composable agents/)
29
31
  │ ├── skill-stats/
30
32
  │ └── notify/
31
33
  ├── pi/ # Global pi configuration (see below)
32
34
  │ └── settings.json
35
+ ├── token-map.json # canonical tool/path/agent names per harness (install-time token substitution)
36
+ ├── token-map.README.md # design decisions behind token-map.json
37
+ ├── bin/
38
+ │ ├── agent-cortex.mjs # CLI entrypoint
39
+ │ └── installers/
40
+ │ ├── copilot.mjs # shared generator: agent-cortex install copilot + scripts/build-copilot-agents.mjs
41
+ │ └── claude.mjs # install-time generator + Claude Code registrar (pnpm build:claude = generate-only --output form)
33
42
  ├── scripts/
34
- │ └── build-claude-agents.mjs # builds the claude/ subtree from the sources above
43
+ │ └── build-copilot-agents.mjs # thin wrapper over bin/installers/copilot.mjs (regenerates agents/*.agent.md)
35
44
  └── claude/ # Self-contained Claude Code plugin (GENERATED — do not hand-edit)
36
45
  ├── .claude-plugin/
37
46
  │ └── plugin.json
38
- ├── .mcp.json # MCP servers (context7, github)
39
- ├── hooks.json # SessionStart hooks (beads context + style policy)
40
- ├── agents/ # generated from agents/*.agent.md + copied from agents-native/
41
- └── skills/ # symlinks to the grouped skills/ dirs (28 skills)
47
+ ├── .mcp.json # MCP servers (context7, github) — hand-authored
48
+ ├── hooks.json # SessionStart + Notification hooks — generated from hooks/claude/
49
+ ├── hooks/ # hook scripts (e.g. scripts/notify.mjs) — generated from hooks/claude/
50
+ ├── agents/ # composed from agents/<name>/claude/ + copied from agents-native/
51
+ └── skills/ # symlinks to the grouped skills/ dirs (29 skills)
42
52
  ```
43
53
 
44
54
  The same `agents/` and `skills/` power three harnesses (Copilot, pi, Claude Code).
45
- The `claude/` subtree is **generated** by `scripts/build-claude-agents.mjs`
46
- (`pnpm build:claude`) and committed; CI checks it is never stale:
55
+ The composable `agents/<name>/` directories are the single source of truth; the flat
56
+ `agents/*.agent.md` files are **generated** by the shared copilot installer
57
+ (`agent-cortex install copilot`, or `scripts/build-copilot-agents.mjs` via
58
+ `pnpm build:copilot` — both run the same `bin/installers/copilot.mjs` code path, so
59
+ install-time and build-time output can never diverge) and committed so Copilot CLI
60
+ (plugin.json `agents: "agents/"`) and pi keep loading the agents — don't hand-edit them.
61
+ The `{{TOOL:...}}` / `{{PATH:...}}` tokens written in agent and skill files are resolved
62
+ per harness at install time from `token-map.json`, the single source of truth for
63
+ canonical tool/path/agent names (see `token-map.README.md` and the `contract` section).
64
+ The `claude/` subtree is **generated** by the install-time generator
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
70
+ it is never stale:
47
71
 
48
72
  - **Skills** stay single-source — `claude/skills/<name>` are symlinks into the grouped
49
73
  `skills/<group>/<name>` dirs (Claude discovers skills only one level deep, so the
50
74
  grouping is flattened via links, not copies).
51
75
  - **Agents** can't be shared files (the frontmatter formats differ), so `claude/agents/*.md`
52
- are converted from the canonical `agents/*.agent.md`. Claude only loads agents from a
53
- plugin's default `agents/` dir, so the plugin root is `claude/` — isolating it from the
54
- Copilot `.agent.md` files.
76
+ are composed from the canonical `agents/<name>/` directories' `claude/` harness dirs
77
+ (frontmatter.json + section files), exactly like the Copilot flats are composed from their
78
+ `copilot/` dirs. Claude only loads agents from a plugin's default `agents/` dir, so the plugin
79
+ root is `claude/` — isolating it from the Copilot `.agent.md` files.
55
80
  - **Claude-native agents** that have no Copilot equivalent live in `agents-native/*.md` and are
56
81
  copied verbatim into `claude/agents/`. `ralph` is one: it is reimplemented for Claude around
57
82
  background workers + an independent review gate (the Copilot Ralph's `task`/`read_agent`
58
83
  poll loop has no Claude equivalent), so it can't be mechanically converted.
59
-
60
- Edit the sources (`agents/*.agent.md`, `agents-native/*.md`, `skills/**`), never anything
61
- under `claude/`.
84
+ - **Manifests** are generated too: `claude/.claude-plugin/plugin.json` (its `version` tracks
85
+ `package.json`, so it never goes stale) and `claude/hooks.json` (copied from the canonical
86
+ `hooks/claude/hooks.json` source), plus any support files under `hooks/claude/` bundled into
87
+ `claude/hooks/` so hook commands can reach them via `$CLAUDE_PLUGIN_ROOT`. `claude/.mcp.json`
88
+ and `claude/scripts/` stay hand-authored. See `docs/claude-hooks.md` for the extension→hook
89
+ mapping and the rejections (auto-name, skill-stats, subagent, agent-modes).
90
+
91
+ Edit the sources (`agents/<name>/` composable dirs, `agents-native/*.md`, `skills/**`,
92
+ `hooks/claude/`, `package.json`), never anything under `claude/` or the generated
93
+ `agents/*.agent.md` files.
94
+
95
+ ## CI
96
+
97
+ The CI pipeline runs lint, test, and claude-plugin-check as three parallel jobs
98
+ (`lint`, `test`, `claude-plugin-check`), each gated on `needs: setup`. Each job
99
+ does its own checkout and `pnpm install` rather than sharing build artifacts from
100
+ the `setup` job — pnpm workspace symlinks don't survive artifact upload/download,
101
+ so artifact sharing would break the workspace resolution that the build depends on.
102
+
103
+ A separate `changeset-check` job runs only on pull requests and fails any PR that
104
+ touches a versioned path (`extensions/`, `skills/`, `agents/`, `package.json`, or
105
+ `plugin.json`) without a changeset in `.changeset/`. Add one with `pnpm changeset` —
106
+ the `style-versioning` skill documents the format.
107
+
108
+ On pushes to `main`, a `release` job (gated on `lint`, `test`, and
109
+ `claude-plugin-check`) runs changesets to open a `chore: version packages` PR when
110
+ changesets are pending, then publishes to npm once it lands. The version step runs
111
+ `pnpm version-packages` — bumping `package.json`, syncing `plugin.json`, and
112
+ regenerating the committed generated output so the drift gates stay green; the
113
+ publish step runs `pnpm publish-package` (pack + provenance publish). Publish
114
+ authenticates via npm Trusted Publishing (OIDC) — no npm token or GitHub
115
+ secret is needed, only the one-time npm-side setup on npmjs.com (package →
116
+ Access → Trusted Publishing for the `jaybeeuu/agent-cortex` repo). Releases
117
+ are sourced entirely from `main`.
62
118
 
63
119
  ## Installation
64
120
 
@@ -92,6 +148,29 @@ Desktop notifications are handled by the local `extensions/notify/` extension
92
148
  notification on multi-turn tasks, labelled with the tmux session:window.pane
93
149
  if available, or the project directory name otherwise.
94
150
 
151
+ ### Pi harness agents & skills (`agent-cortex install pi`)
152
+
153
+ The agents are already available to pi through the package (`pi.skills` + the
154
+ `agent-modes` extension compose them at runtime), but the raw package files carry
155
+ literal `{{TOOL:...}}` / `{{PATH:...}}` tokens. Run the pi installer to materialise
156
+ composed agents and token-substituted skills into pi's user scope:
157
+
158
+ ```sh
159
+ agent-cortex install pi
160
+ # → ~/.pi/agent/agents/<name>.agent.md (ralph, plan, ralph-plan, strategy)
161
+ # → ~/.pi/agent/skills/ (token-substituted skill tree)
162
+ ```
163
+
164
+ Flags:
165
+
166
+ | Flag | Meaning |
167
+ | --- | --- |
168
+ | `--dry-run` | Show what would be installed without writing anything |
169
+ | `--output <dir>` | Install into `<dir>/agents` and `<dir>/skills` (default `~/.pi/agent`) |
170
+ | `--plugin-root <dir>` | Override the plugin root used for `{{PATH:...}}` tokens (default: token-map.json's pi value — use it for checkout or symlinked installs) |
171
+
172
+ Re-run whenever you pull changes (`git pull` + reinstall, or after `pnpm build:copilot`).
173
+
95
174
  ### Copilot plugin (separate)
96
175
 
97
176
  ```sh
@@ -108,13 +187,22 @@ copilot plugin install ./agent-cortex
108
187
 
109
188
  The Claude plugin is the self-contained `claude/` subtree (manifest at
110
189
  `claude/.claude-plugin/plugin.json`), containing **4 agents** (`strategy`, `plan`,
111
- `ralph-plan`, `ralph`), **28 skills**, a `SessionStart` hook, and 2 MCP servers.
190
+ `ralph-plan`, `ralph`), **29 skills**, `SessionStart` + `Notification` hooks, and 2 MCP servers.
112
191
 
113
- `claude/` is committed, so a fresh clone is installable as-is. If you change the sources,
114
- rebuild it (the generator is a zero-dependency Node script):
192
+ `claude/` is committed (the marketplace install flow reads it straight from the working
193
+ tree, so a fresh clone installs as-is), and rebuilt via the install-time generator if you
194
+ change the sources:
115
195
 
116
196
  ```sh
117
- pnpm build:claude # or: node scripts/build-claude-agents.mjs
197
+ pnpm build:copilot # or: node scripts/build-copilot-agents.mjs (regenerates agents/*.agent.md)
198
+ pnpm build:claude # or: node bin/agent-cortex.mjs install claude --output claude (generate-only)
199
+ # or the install-time entry (same generator, less typing):
200
+ node bin/agent-cortex.mjs install copilot # regenerates agents/*.agent.md in place
201
+ node bin/agent-cortex.mjs install copilot --dry-run # plan only, no writes
202
+ node bin/agent-cortex.mjs install copilot --output /tmp/x # preview the flat files 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
118
206
  ```
119
207
 
120
208
  #### Try it for one session
@@ -131,8 +219,20 @@ claude --plugin-dir /path/to/agent-cortex/claude plugin details agent-cortex
131
219
  #### Install persistently (recommended)
132
220
 
133
221
  The repo ships a marketplace manifest (`.claude-plugin/marketplace.json`) that exposes the
134
- `claude/` subtree. Register it by **absolute path** (a bare `.` is rejected — use an absolute
135
- 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):
136
236
 
137
237
  ```sh
138
238
  claude plugin marketplace add /path/to/agent-cortex
@@ -146,16 +246,18 @@ flag, and Ralph is just `claude --agent agent-cortex:ralph`.
146
246
 
147
247
  #### Update
148
248
 
149
- The marketplace source is your local checkout, so after pulling changes you must rebuild the
150
- `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:
151
252
 
152
253
  ```sh
153
254
  git pull
154
- pnpm build:claude # regenerate claude/ from the sources
155
- claude plugin marketplace update jaybeeuu
156
- claude plugin update agent-cortex # restart Claude Code to apply
255
+ agent-cortex install claude # rebuild + refresh (restart Claude Code to apply)
157
256
  ```
158
257
 
258
+ `pnpm build:claude` only regenerates the subtree (no registration), so on its own it won't
259
+ refresh an installed plugin.
260
+
159
261
  #### Uninstall
160
262
 
161
263
  ```sh
@@ -186,15 +288,22 @@ It finds ready beads, spawns parallel background workers (implement → independ
186
288
  fix), opens a PR per feature, and pauses at each human merge gate. After you merge, re-invoke
187
289
  it and it resumes from `bd ready`.
188
290
 
189
- #### Style-skill enforcement
291
+ #### Hooks
190
292
 
191
- The plugin's `SessionStart` hook injects a "style policy" each session, nudging Claude to
192
- invoke `style-code` / `style-tests` / `style-documentation` / `style-comms` before the
193
- corresponding work; the style skills' descriptions are also written to auto-trigger proactively.
293
+ `SessionStart` injects a per-session policy nudging Claude to prefer the shipped skills over
294
+ ad-hoc choices: the "style policy" (invoke `style-code` / `style-tests` /
295
+ `style-documentation` / `style-comms` before the corresponding work — their descriptions also
296
+ auto-trigger proactively) and the "skill policy" (`using-agent-skills` for routing, `bd-tool`
297
+ for beads context, `git-workflow` for branch/PR discipline). A `Notification` hook matched on
298
+ `agent_completed|agent_needs_input|permission_prompt` raises a desktop notification when a
299
+ task finishes, waits on input, or needs approval. See `docs/claude-hooks.md` for the full
300
+ extension→hook audit.
194
301
 
195
302
  #### Not ported / follow-ups
196
303
 
197
- - The pi `extensions/` have no Claude runtime-extension equivalent (use hooks/MCP instead).
304
+ - Only `session-start` and `notify` had Claude equivalents (both ported to hooks); the other
305
+ pi `extensions/` (auto-name, skill-stats, subagent, agent-modes) have none — the audit and
306
+ rejection rationale live in `docs/claude-hooks.md`.
198
307
  - Ralph follow-ups: multi-feature epic branches, and a GitHub-trigger routine to auto-resume
199
308
  after a PR merge (instead of manual re-invocation).
200
309
  - The Copilot/pi Ralph (the 4-stage `run-pipeline-stage` pipeline) is unchanged; those two
@@ -202,8 +311,16 @@ corresponding work; the style skills' descriptions are also written to auto-trig
202
311
 
203
312
  #### Contributing to the Claude plugin
204
313
 
205
- Edit the **sources** — `agents/*.agent.md` (Copilot format, auto-converted),
206
- `agents-native/*.md` (Claude-only agents like `ralph`), and `skills/**` — then run
207
- `pnpm build:claude`. Never hand-edit anything under `claude/` (except the hand-authored
208
- `claude/hooks.json`, `claude/.mcp.json`, and `claude/.claude-plugin/plugin.json`). CI runs
209
- `git diff --exit-code claude/agents/ claude/skills/` so the generated tree can never drift.
314
+ Edit the **sources** — the composable `agents/<name>/` directories (shared `agent.md` +
315
+ per-harness frontmatter/sections, auto-composed by `scripts/build-copilot-agents.mjs` and
316
+ the install-time generator `bin/installers/claude.mjs`), `agents-native/*.md` (Claude-only
317
+ agents like `ralph` — the canonical bodies the installer copies verbatim), `skills/**`,
318
+ `hooks/claude/hooks.json` (hook config), and `package.json` (plugin
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
322
+ anything under `claude/` except the hand-authored `claude/.mcp.json` and `claude/scripts/`
323
+ files, or the generated `agents/*.agent.md` files, `claude/agents/`, `claude/skills/`,
324
+ `claude/.claude-plugin/plugin.json`, and `claude/hooks.json`. CI runs
325
+ `git diff --exit-code claude/agents/ claude/skills/ claude/.claude-plugin/plugin.json claude/hooks.json`
326
+ and `git diff --exit-code -- 'agents/*.agent.md'` so the generated outputs can never drift.
package/agents/README.md CHANGED
@@ -4,9 +4,9 @@ This document defines the canonical format for composable agent directories in a
4
4
 
5
5
  ## Motivation
6
6
 
7
- The current format uses a single `*.agent.md` file per agent, combining harness-agnostic logic with harness-specific configuration. This creates duplication when the same agent needs to run on multiple harnesses (PI, Copilot, Claude) with different tool names and polling mechanisms.
7
+ The original format used a single `*.agent.md` file per agent, combining harness-agnostic logic with harness-specific configuration. This created duplication when the same agent needed to run on multiple harnesses (PI, Copilot, Claude) with different tool names and polling mechanisms.
8
8
 
9
- The new format separates concerns:
9
+ The composable directory format separates concerns:
10
10
 
11
11
  - **Shared body**: Harness-agnostic instructions (workflow, branching model, constraints)
12
12
  - **Harness-specific frontmatter**: Tool names, model preferences, metadata per harness
@@ -35,11 +35,11 @@ agents/
35
35
  agents/ralph/
36
36
  ├── agent.md # Shared body (branching model, dispatch logic, constraints)
37
37
  ├── pi/
38
- │ ├── frontmatter.json # PI tools: ["bash", "task", "read_agent"]
39
- │ └── polling.md # PI polling loop using read_agent
38
+ │ ├── frontmatter.json # PI tools: ["bash", "task", "read_agent", "wait_for_agents"]
39
+ │ └── polling.md # PI completion: blocking wait_for_agents (no poll timer)
40
40
  ├── copilot/
41
- │ ├── frontmatter.json # Copilot tools (same as PI for now)
42
- │ └── polling.md # Copilot polling (same as PI)
41
+ │ ├── frontmatter.json # Copilot tools: ["bash", "task", "read_agent"]
42
+ │ └── polling.md # Copilot completion: sleep-120 poll timer + read_agent
43
43
  └── claude/
44
44
  ├── frontmatter.json # Claude tools: ["bash", "task"]
45
45
  └── polling.md # Claude event-driven (no polling)
@@ -123,9 +123,9 @@ Tokens in agent.md reference tools, paths, and sections:
123
123
 
124
124
  | Token | Syntax | Description |
125
125
  |-------|--------|-------------|
126
- | Tool reference | `{{TOOL:name}}` | Reference a tool by name (for documentation/highlighting) |
127
- | Path reference | `{{PATH:path}}` | Reference a file path (e.g., skills, extensions) |
128
- | Section include | `{{SECTION:name}}` | Include content from a section file in the harness directory |
126
+ | Tool reference | `{{TOOL:name}}` | Canonical tool name; resolved per harness from `token-map.json` |
127
+ | Path reference | `{{PATH:path}}` | Canonical path name; resolved per harness from `token-map.json` |
128
+ | Section include | `{{SECTION:name}}` | Include content from a section file in the harness directory (substituted by the composer) |
129
129
 
130
130
  ### Examples
131
131
 
@@ -141,7 +141,17 @@ When composing the final agent file for a specific harness:
141
141
 
142
142
  1. Start with agent.md content
143
143
  2. Replace `{{SECTION:name}}` with content from `<harness>/<name>.md`
144
- 3. `{{TOOL:name}}` and `{{PATH:name}}` remain as-is (documentation tokens)
144
+ 3. `{{TOOL:name}}` and `{{PATH:name}}` are resolved against `token-map.json` — the
145
+ canonical tool/path/agent names per harness. `scripts/lib/compose-agent.mjs` (used by
146
+ `build:copilot` / `build:claude` and by `bin/installers/pi.mjs`) resolves them when
147
+ generating the flat files / installing for pi; pi's `agent-modes` extension does the
148
+ same at runtime. See the `contract` section of `token-map.json` and
149
+ `token-map.README.md` for the rules.
150
+
151
+ The pi harness's `agent-modes` extension is a runtime consumer of this format: it
152
+ composes agent prompts on the fly from `agent.md` + `pi/frontmatter.json`, substituting
153
+ tokens against `token-map.json`'s pi column with no install step. See
154
+ `extensions/agent-modes/README.md`.
145
155
 
146
156
  ## Composition Rules
147
157
 
@@ -188,10 +198,36 @@ agents/plan/
188
198
  ## Migration Path
189
199
 
190
200
  1. Define the format (this document)
191
- 2. Migrate ralph agent first (proves the pattern)
192
- 3. Migrate plan, ralph-plan, strategy agents
201
+ 2. Migrate ralph agent first (proves the pattern) — DONE
202
+ 3. Migrate plan, ralph-plan, strategy agents — DONE
193
203
  4. Update the installer/composer to handle the new format
194
- 5. Remove old `*.agent.md` files
204
+ 5. Remove old `*.agent.md` files — DONE (the flat files are now **generated output**, see below)
205
+
206
+ All four agents (`ralph`, `plan`, `ralph-plan`, `strategy`) use the composable layout and the
207
+ flat `agents/*.agent.md` files are built from them:
208
+
209
+ - `scripts/build-copilot-agents.mjs` (`pnpm build:copilot`) composes `agents/*.agent.md` from
210
+ each agent's `copilot/` harness dir — committed for Copilot CLI, which loads `*.agent.md`
211
+ from `plugin.json`'s `agents: "agents/"` path.
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
215
+ `ralph`, which ships natively from `agents-native/ralph.md`, copied verbatim).
216
+ - The pi harness delivers two ways: the `agent-modes` extension composes `agent.md` +
217
+ `pi/frontmatter.json` at runtime against `token-map.json`, and `agent-cortex install pi`
218
+ materialises composed agents + token-substituted skills into `~/.pi/agent` at install
219
+ time (see README "Pi harness agents & skills").
220
+
221
+ Never edit the generated flat/claude files by hand — edit the composable directory. CI
222
+ regenerates both outputs and fails on drift. Generation is install-time: `claude` ships
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
227
+ `bin/installers/copilot.mjs`, the shared code path behind both `agent-cortex install
228
+ copilot` and `scripts/build-copilot-agents.mjs`; `pi` ships via
229
+ `bin/installers/pi.mjs`, which materialises composed agents + token-substituted skills
230
+ into `~/.pi/agent`.
195
231
 
196
232
  ## Validation
197
233
 
@@ -0,0 +1,51 @@
1
+ # plan — end-to-end feature planning agent
2
+
3
+ You are a planning agent. Your job is to guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution.
4
+
5
+ You follow the **plan** skill workflow. The skill is defined in `{{PATH:skills/workflow/plan/SKILL.md}}`. Read it now to load the full instructions.
6
+
7
+ ## Workflow summary
8
+
9
+ ### Phase 1 — Understand and specify
10
+ 1. Ask the user to describe the problem, goal, or feature.
11
+ 2. Explore the codebase to verify assertions and understand current state.
12
+ 3. Interview the user relentlessly — scope, data models, module boundaries, trade-offs.
13
+ 4. Sketch major modules.
14
+ 5. Draft a PRD using the `write-a-prd` template.
15
+ 6. Present the PRD for user approval.
16
+ 7. Create an epic bead from the approved PRD.
17
+
18
+ ### Phase 2 — Break into tasks
19
+ 8. Review PRD stories and identify vertical-slice phases.
20
+ 9. Define each phase (title, stories, what to build, acceptance criteria).
21
+ 10. Create epics for multi-phase work.
22
+ 11. Present the breakdown for user approval.
23
+
24
+ ### Phase 3 — Create and classify beads
25
+ 13. Create task beads via `create-task` for each task.
26
+ 14. Tag parent epics with aggregate classification.
27
+ 15. Present the full bead tree.
28
+
29
+ ### Phase 4 — Prepare handoff to ralph
30
+ 16. Determine the handoff bead (epic or meta-epic).
31
+ 17. Tag it `workflow:ralph`.
32
+ 18. Push bead state with `bd dolt push`.
33
+ 19. Present the handoff summary.
34
+
35
+ ## Permitted writes
36
+
37
+ | Location | Purpose |
38
+ |---|---|
39
+ | `.agent-cortex/working-docs/` | Research notes, decisions, exploration findings — gitignored |
40
+ | Bead fields (`description`, `design`) | Plans and specifications |
41
+ | `docs/prd/<topic>.md` | PRD documents |
42
+
43
+ Do **not** modify source code or tracked documentation outside these locations.
44
+
45
+ ## Constraints
46
+
47
+ - Never modify source code.
48
+ - Always get user approval before moving between phases.
49
+ - Each phase has a gate — do not skip it.
50
+ - Work in `.agent-cortex/working-docs/` for scratchpad notes.
51
+ - Use `bd` commands for all bead operations.
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "agent-cortex:plan",
3
+ "description": "Guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution. Full end-to-end planning workflow using the plan skill. Use when starting a new feature, scoping work to hand off to ralph, or saying 'plan this'.",
4
+ "tools": ["Bash", "Read", "Edit", "Write", "Grep", "Glob", "AskUserQuestion", "Task", "Skill"],
5
+ "argumentHint": "Plan <feature or change description>"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "agent-cortex:plan",
3
+ "description": "Guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution. Full end-to-end planning workflow using the plan skill. Use when starting a new feature, scoping work to hand off to ralph, or saying 'plan this'.",
4
+ "tools": ["bash", "view", "edit", "create", "grep", "glob", "ask_user", "task", "read_agent", "skill"],
5
+ "argumentHint": "Plan <feature or change description>"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "agent-cortex:plan",
3
+ "description": "Guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution. Full end-to-end planning workflow using the plan skill. Use when starting a new feature, scoping work to hand off to ralph, or saying 'plan this'.",
4
+ "tools": ["bash", "view", "edit", "create", "grep", "glob", "ask_user", "task", "read_agent", "skill"],
5
+ "argumentHint": "Plan <feature or change description>"
6
+ }
@@ -1,10 +1,13 @@
1
1
  ---
2
+ # GENERATED from agents/plan/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
2
3
  description: "Guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution. Full end-to-end planning workflow using the plan skill. Use when starting a new feature, scoping work to hand off to ralph, or saying 'plan this'."
3
4
  name: "agent-cortex:plan"
4
5
  tools: ["bash", "view", "edit", "create", "grep", "glob", "ask_user", "task", "read_agent", "skill"]
5
6
  argument-hint: "Plan <feature or change description>"
6
7
  ---
7
8
 
9
+ # plan — end-to-end feature planning agent
10
+
8
11
  You are a planning agent. Your job is to guide a feature from first discussion through PRD and task breakdown to classified beads ready for ralph execution.
9
12
 
10
13
  You follow the **plan** skill workflow. The skill is defined in `skills/workflow/plan/SKILL.md`. Read it now to load the full instructions.