@jaybeeuu/agent-cortex 1.20.0 → 1.38.1

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 (103) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +102 -0
  2. package/.changeset/README.md +8 -0
  3. package/.changeset/config.json +11 -0
  4. package/.github/workflows/ci.yml +227 -6
  5. package/AGENTS.md +29 -24
  6. package/CHANGELOG.md +119 -5
  7. package/README.md +132 -33
  8. package/agents/README.md +47 -13
  9. package/agents/plan/agent.md +51 -0
  10. package/agents/plan/claude/frontmatter.json +6 -0
  11. package/agents/plan/copilot/frontmatter.json +6 -0
  12. package/agents/plan/pi/frontmatter.json +6 -0
  13. package/agents/plan.agent.md +3 -0
  14. package/agents/ralph/agent.md +262 -0
  15. package/agents/ralph/claude/frontmatter.json +6 -0
  16. package/agents/ralph/claude/polling.md +31 -0
  17. package/agents/ralph/copilot/frontmatter.json +6 -0
  18. package/agents/ralph/copilot/polling.md +62 -0
  19. package/agents/ralph/pi/frontmatter.json +6 -0
  20. package/agents/ralph/pi/polling.md +74 -0
  21. package/agents/ralph-plan/agent.md +114 -0
  22. package/agents/ralph-plan/claude/frontmatter.json +6 -0
  23. package/agents/ralph-plan/copilot/frontmatter.json +6 -0
  24. package/agents/ralph-plan/pi/frontmatter.json +6 -0
  25. package/agents/ralph-plan.agent.md +5 -2
  26. package/agents/ralph.agent.md +83 -57
  27. package/agents/strategy/agent.md +104 -0
  28. package/agents/strategy/claude/frontmatter.json +6 -0
  29. package/agents/strategy/copilot/frontmatter.json +6 -0
  30. package/agents/strategy/pi/frontmatter.json +6 -0
  31. package/agents/strategy.agent.md +3 -0
  32. package/bin/agent-cortex.mjs +68 -1
  33. package/bin/installers/claude.mjs +262 -0
  34. package/bin/installers/copilot.mjs +129 -0
  35. package/bin/installers/pi.mjs +197 -0
  36. package/claude/.claude-plugin/plugin.json +1 -1
  37. package/claude/agents/plan.md +3 -1
  38. package/claude/agents/ralph-plan.md +5 -3
  39. package/claude/agents/strategy.md +3 -1
  40. package/claude/hooks/scripts/notify.mjs +54 -0
  41. package/claude/hooks.json +15 -0
  42. package/docs/claude-hooks.md +115 -0
  43. package/docs/ideas/unified-ci-pipeline.md +28 -0
  44. package/docs/skills/skill-anatomy.md +9 -0
  45. package/extensions/agent-modes/README.md +54 -0
  46. package/extensions/agent-modes/discover.test.ts +241 -0
  47. package/extensions/agent-modes/discover.ts +458 -0
  48. package/extensions/agent-modes/index.ts +13 -224
  49. package/extensions/agent-modes/node_modules/.bin/pi +21 -0
  50. package/extensions/agent-modes/node_modules/.bin/tsc +21 -0
  51. package/extensions/agent-modes/node_modules/.bin/tsserver +21 -0
  52. package/extensions/agent-modes/node_modules/.bin/tsx +21 -0
  53. package/extensions/agent-modes/package.json +20 -0
  54. package/extensions/agent-modes/tsconfig.json +12 -0
  55. package/extensions/session-start.ts +1 -1
  56. package/extensions/skill-stats/context-loader.test.ts +1 -1
  57. package/extensions/skill-stats/node_modules/.bin/pi +21 -0
  58. package/extensions/skill-stats/node_modules/.bin/tsc +21 -0
  59. package/extensions/skill-stats/node_modules/.bin/tsserver +21 -0
  60. package/extensions/skill-stats/node_modules/.bin/tsx +21 -0
  61. package/extensions/subagent/README.md +19 -0
  62. package/extensions/subagent/index.ts +131 -45
  63. package/extensions/subagent/node_modules/.bin/pi +21 -0
  64. package/extensions/subagent/node_modules/.bin/pi-ai +21 -0
  65. package/extensions/subagent/node_modules/.bin/tsc +21 -0
  66. package/extensions/subagent/node_modules/.bin/tsserver +21 -0
  67. package/extensions/subagent/node_modules/.bin/tsx +21 -0
  68. package/extensions/subagent/package.json +23 -0
  69. package/extensions/subagent/tsconfig.json +12 -0
  70. package/extensions/subagent/wait.test.ts +202 -0
  71. package/extensions/subagent/wait.ts +118 -0
  72. package/hooks/claude/hooks.json +38 -0
  73. package/hooks/claude/scripts/notify.mjs +54 -0
  74. package/lib/cli.mjs +62 -3
  75. package/package.json +10 -7
  76. package/plugin.json +1 -1
  77. package/pnpm-workspace.yaml +1 -0
  78. package/scripts/build-copilot-agents.mjs +30 -0
  79. package/scripts/lib/compose-agent.mjs +241 -0
  80. package/scripts/sync-plugin-version.sh +17 -0
  81. package/skills/engineering/design-an-interface/SKILL.md +1 -1
  82. package/skills/engineering/improve-codebase-architecture/SKILL.md +1 -1
  83. package/skills/workflow/ralph/REFERENCE.md +2 -2
  84. package/skills/workflow/ralph/SKILL.md +6 -6
  85. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +4 -2
  86. package/skills/workflow/using-agent-skills/SKILL.md +15 -2
  87. package/test/cli.test.mjs +115 -2
  88. package/test/copilot-installer.test.mjs +298 -0
  89. package/test/installer.test.mjs +179 -0
  90. package/test/notify-hook.test.mjs +63 -0
  91. package/test/pi-installer.test.mjs +371 -0
  92. package/token-map.README.md +128 -0
  93. package/token-map.json +106 -0
  94. package/.beads/README.md +0 -81
  95. package/.beads/config.yaml +0 -1
  96. package/.beads/issues.jsonl +0 -236
  97. package/.beads/metadata.json +0 -7
  98. package/.github/workflows/ci.test.ts +0 -217
  99. package/.github/workflows/publish.yml +0 -36
  100. package/scripts/build-claude-agents.mjs +0 -179
  101. package/skills/workflow/using-agent-skills/scripts/validate-skill-structure.test.ts +0 -73
  102. /package/extensions/{context-loader.md → lib/context-loader.md} +0 -0
  103. /package/extensions/{context-loader.ts → lib/context-loader.ts} +0 -0
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,92 @@ 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 — agent-cortex install claude (pnpm build:claude aliases it)
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`) — `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
68
+ it is never stale:
47
69
 
48
70
  - **Skills** stay single-source — `claude/skills/<name>` are symlinks into the grouped
49
71
  `skills/<group>/<name>` dirs (Claude discovers skills only one level deep, so the
50
72
  grouping is flattened via links, not copies).
51
73
  - **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.
74
+ are composed from the canonical `agents/<name>/` directories' `claude/` harness dirs
75
+ (frontmatter.json + section files), exactly like the Copilot flats are composed from their
76
+ `copilot/` dirs. Claude only loads agents from a plugin's default `agents/` dir, so the plugin
77
+ root is `claude/` — isolating it from the Copilot `.agent.md` files.
55
78
  - **Claude-native agents** that have no Copilot equivalent live in `agents-native/*.md` and are
56
79
  copied verbatim into `claude/agents/`. `ralph` is one: it is reimplemented for Claude around
57
80
  background workers + an independent review gate (the Copilot Ralph's `task`/`read_agent`
58
81
  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/`.
82
+ - **Manifests** are generated too: `claude/.claude-plugin/plugin.json` (its `version` tracks
83
+ `package.json`, so it never goes stale) and `claude/hooks.json` (copied from the canonical
84
+ `hooks/claude/hooks.json` source), plus any support files under `hooks/claude/` bundled into
85
+ `claude/hooks/` so hook commands can reach them via `$CLAUDE_PLUGIN_ROOT`. `claude/.mcp.json`
86
+ and `claude/scripts/` stay hand-authored. See `docs/claude-hooks.md` for the extension→hook
87
+ mapping and the rejections (auto-name, skill-stats, subagent, agent-modes).
88
+
89
+ Edit the sources (`agents/<name>/` composable dirs, `agents-native/*.md`, `skills/**`,
90
+ `hooks/claude/`, `package.json`), never anything under `claude/` or the generated
91
+ `agents/*.agent.md` files.
92
+
93
+ ## CI
94
+
95
+ The CI pipeline runs lint, test, and claude-plugin-check as three parallel jobs
96
+ (`lint`, `test`, `claude-plugin-check`), each gated on `needs: setup`. Each job
97
+ does its own checkout and `pnpm install` rather than sharing build artifacts from
98
+ the `setup` job — pnpm workspace symlinks don't survive artifact upload/download,
99
+ so artifact sharing would break the workspace resolution that the build depends on.
100
+
101
+ A separate `changeset-check` job runs only on pull requests and fails any PR that
102
+ touches a versioned path (`extensions/`, `skills/`, `agents/`, `package.json`, or
103
+ `plugin.json`) without a changeset in `.changeset/`. Add one with `pnpm changeset` —
104
+ the `style-versioning` skill documents the format.
105
+
106
+ On pushes to `main`, a `release` job (gated on `lint`, `test`, and
107
+ `claude-plugin-check`) runs changesets to open a `chore: version packages` PR when
108
+ changesets are pending, then publishes to npm once it lands. The version step runs
109
+ `pnpm version-packages` — bumping `package.json`, syncing `plugin.json`, and
110
+ regenerating the committed generated output so the drift gates stay green; the
111
+ publish step runs `pnpm publish-package` (pack + provenance publish). Publish
112
+ authenticates via npm Trusted Publishing (OIDC) — no npm token or GitHub
113
+ secret is needed, only the one-time npm-side setup on npmjs.com (package →
114
+ Access → Trusted Publishing for the `jaybeeuu/agent-cortex` repo). Releases
115
+ are sourced entirely from `main`.
62
116
 
63
117
  ## Installation
64
118
 
@@ -92,6 +146,29 @@ Desktop notifications are handled by the local `extensions/notify/` extension
92
146
  notification on multi-turn tasks, labelled with the tmux session:window.pane
93
147
  if available, or the project directory name otherwise.
94
148
 
149
+ ### Pi harness agents & skills (`agent-cortex install pi`)
150
+
151
+ The agents are already available to pi through the package (`pi.skills` + the
152
+ `agent-modes` extension compose them at runtime), but the raw package files carry
153
+ literal `{{TOOL:...}}` / `{{PATH:...}}` tokens. Run the pi installer to materialise
154
+ composed agents and token-substituted skills into pi's user scope:
155
+
156
+ ```sh
157
+ agent-cortex install pi
158
+ # → ~/.pi/agent/agents/<name>.agent.md (ralph, plan, ralph-plan, strategy)
159
+ # → ~/.pi/agent/skills/ (token-substituted skill tree)
160
+ ```
161
+
162
+ Flags:
163
+
164
+ | Flag | Meaning |
165
+ | --- | --- |
166
+ | `--dry-run` | Show what would be installed without writing anything |
167
+ | `--output <dir>` | Install into `<dir>/agents` and `<dir>/skills` (default `~/.pi/agent`) |
168
+ | `--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) |
169
+
170
+ Re-run whenever you pull changes (`git pull` + reinstall, or after `pnpm build:copilot`).
171
+
95
172
  ### Copilot plugin (separate)
96
173
 
97
174
  ```sh
@@ -108,13 +185,22 @@ copilot plugin install ./agent-cortex
108
185
 
109
186
  The Claude plugin is the self-contained `claude/` subtree (manifest at
110
187
  `claude/.claude-plugin/plugin.json`), containing **4 agents** (`strategy`, `plan`,
111
- `ralph-plan`, `ralph`), **28 skills**, a `SessionStart` hook, and 2 MCP servers.
188
+ `ralph-plan`, `ralph`), **29 skills**, `SessionStart` + `Notification` hooks, and 2 MCP servers.
112
189
 
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):
190
+ `claude/` is committed (the marketplace install flow reads it straight from the working
191
+ tree, so a fresh clone installs as-is), and rebuilt via the install-time generator if you
192
+ change the sources:
115
193
 
116
194
  ```sh
117
- pnpm build:claude # or: node scripts/build-claude-agents.mjs
195
+ 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)
197
+ # or the install-time entry (same generator, less typing):
198
+ node bin/agent-cortex.mjs install copilot # regenerates agents/*.agent.md in place
199
+ node bin/agent-cortex.mjs install copilot --dry-run # plan only, no writes
200
+ 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
118
204
  ```
119
205
 
120
206
  #### Try it for one session
@@ -151,7 +237,7 @@ The marketplace source is your local checkout, so after pulling changes you must
151
237
 
152
238
  ```sh
153
239
  git pull
154
- pnpm build:claude # regenerate claude/ from the sources
240
+ pnpm build:claude # alias of agent-cortex install claude
155
241
  claude plugin marketplace update jaybeeuu
156
242
  claude plugin update agent-cortex # restart Claude Code to apply
157
243
  ```
@@ -186,15 +272,22 @@ It finds ready beads, spawns parallel background workers (implement → independ
186
272
  fix), opens a PR per feature, and pauses at each human merge gate. After you merge, re-invoke
187
273
  it and it resumes from `bd ready`.
188
274
 
189
- #### Style-skill enforcement
275
+ #### Hooks
190
276
 
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.
277
+ `SessionStart` injects a per-session policy nudging Claude to prefer the shipped skills over
278
+ ad-hoc choices: the "style policy" (invoke `style-code` / `style-tests` /
279
+ `style-documentation` / `style-comms` before the corresponding work — their descriptions also
280
+ auto-trigger proactively) and the "skill policy" (`using-agent-skills` for routing, `bd-tool`
281
+ for beads context, `git-workflow` for branch/PR discipline). A `Notification` hook matched on
282
+ `agent_completed|agent_needs_input|permission_prompt` raises a desktop notification when a
283
+ task finishes, waits on input, or needs approval. See `docs/claude-hooks.md` for the full
284
+ extension→hook audit.
194
285
 
195
286
  #### Not ported / follow-ups
196
287
 
197
- - The pi `extensions/` have no Claude runtime-extension equivalent (use hooks/MCP instead).
288
+ - Only `session-start` and `notify` had Claude equivalents (both ported to hooks); the other
289
+ pi `extensions/` (auto-name, skill-stats, subagent, agent-modes) have none — the audit and
290
+ rejection rationale live in `docs/claude-hooks.md`.
198
291
  - Ralph follow-ups: multi-feature epic branches, and a GitHub-trigger routine to auto-resume
199
292
  after a PR merge (instead of manual re-invocation).
200
293
  - The Copilot/pi Ralph (the 4-stage `run-pipeline-stage` pipeline) is unchanged; those two
@@ -202,8 +295,14 @@ corresponding work; the style skills' descriptions are also written to auto-trig
202
295
 
203
296
  #### Contributing to the Claude plugin
204
297
 
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.
298
+ Edit the **sources** — the composable `agents/<name>/` directories (shared `agent.md` +
299
+ per-harness frontmatter/sections, auto-composed by `scripts/build-copilot-agents.mjs` and
300
+ the install-time generator `bin/installers/claude.mjs`), `agents-native/*.md` (Claude-only
301
+ agents like `ralph` — the canonical bodies the installer copies verbatim), `skills/**`,
302
+ `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
304
+ anything under `claude/` except the hand-authored `claude/.mcp.json` and `claude/scripts/`
305
+ files, or the generated `agents/*.agent.md` files, `claude/agents/`, `claude/skills/`,
306
+ `claude/.claude-plugin/plugin.json`, and `claude/hooks.json`. CI runs
307
+ `git diff --exit-code claude/agents/ claude/skills/ claude/.claude-plugin/plugin.json claude/hooks.json`
308
+ 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,34 @@ 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` (`agent-cortex install claude`; `pnpm build:claude` is a pure
213
+ alias) composes `claude/agents/*.md` from each agent's `claude/` harness dir (except
214
+ `ralph`, which ships natively from `agents-native/ralph.md`, copied verbatim).
215
+ - The pi harness delivers two ways: the `agent-modes` extension composes `agent.md` +
216
+ `pi/frontmatter.json` at runtime against `token-map.json`, and `agent-cortex install pi`
217
+ materialises composed agents + token-substituted skills into `~/.pi/agent` at install
218
+ time (see README "Pi harness agents & skills").
219
+
220
+ Never edit the generated flat/claude files by hand — edit the composable directory. CI
221
+ 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
225
+ `bin/installers/copilot.mjs`, the shared code path behind both `agent-cortex install
226
+ copilot` and `scripts/build-copilot-agents.mjs`; `pi` ships via
227
+ `bin/installers/pi.mjs`, which materialises composed agents + token-substituted skills
228
+ into `~/.pi/agent`.
195
229
 
196
230
  ## Validation
197
231
 
@@ -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.