@jaybeeuu/agent-cortex 1.42.0 → 2.0.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 (83) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +78 -8
  2. package/.github/workflows/ci.yml +51 -38
  3. package/AGENTS.md +32 -17
  4. package/CHANGELOG.md +182 -0
  5. package/README.md +167 -126
  6. package/agents/README.md +26 -27
  7. package/agents/ralph/agent.md +7 -10
  8. package/agents/ralph/claude/polling.md +1 -1
  9. package/bin/agent-cortex.mjs +46 -44
  10. package/bin/installers/claude.mjs +2 -2
  11. package/bin/installers/pi.mjs +885 -237
  12. package/docs/claude-hooks.md +5 -4
  13. package/docs/commit-signing.md +231 -0
  14. package/docs/ideas/enable-signed-commit-enforcement-changesets-bot-commits-must-be-signed.md +10 -1
  15. package/docs/ideas/extension-manifests.md +5 -0
  16. package/docs/research/disable-model-invocation.md +82 -0
  17. package/docs/research/skill-design-research.md +2 -2
  18. package/docs/skills/skill-anatomy.md +5 -2
  19. package/docs/technical-direction/harness-config.md +30 -14
  20. package/docs/technical-direction/migration-execution-labels.md +17 -9
  21. package/docs/user-preferences.md +2 -2
  22. package/extensions/agent-modes/README.md +3 -3
  23. package/extensions/agent-modes/discover.test.ts +19 -0
  24. package/extensions/agent-modes/discover.ts +31 -9
  25. package/extensions/session-start/README.md +38 -0
  26. package/extensions/session-start/index.test.ts +122 -0
  27. package/extensions/session-start/index.ts +27 -0
  28. package/extensions/session-start/package.json +19 -0
  29. package/extensions/session-start/tsconfig.json +12 -0
  30. package/extensions/skill-stats/pnpm-lock.yaml +329 -0
  31. package/extensions/subagent/README.md +3 -3
  32. package/extensions/subagent/agents.test.ts +176 -0
  33. package/extensions/subagent/agents.ts +101 -11
  34. package/extensions/subagent/index.ts +2 -1
  35. package/extensions/subagent/package.json +1 -1
  36. package/lib/cli.mjs +40 -16
  37. package/package.json +8 -9
  38. package/pi/settings.json +1 -7
  39. package/pnpm-workspace.yaml +6 -0
  40. package/scripts/check-changeset.mjs +42 -0
  41. package/scripts/lib/compose-agent.mjs +10 -10
  42. package/scripts/lib/release-gates.mjs +61 -0
  43. package/scripts/lib/verify-worker-tree.mjs +107 -0
  44. package/scripts/resolve-publish-command.mjs +17 -0
  45. package/skills/planning/create-task/scripts/pnpm-lock.yaml +342 -0
  46. package/skills/productivity/validate-agent-dir/scripts/pnpm-lock.yaml +329 -0
  47. package/skills/workflow/git-workflow/SKILL.md +35 -1
  48. package/skills/workflow/ralph/REFERENCE.md +20 -4
  49. package/skills/workflow/ralph/SKILL.md +9 -6
  50. package/skills/workflow/run-pipeline-stage/SKILL.md +11 -4
  51. package/skills/workflow/run-pipeline-stage/playbooks/code.md +2 -0
  52. package/skills/workflow/run-pipeline-stage/playbooks/document.md +3 -0
  53. package/skills/workflow/run-pipeline-stage/playbooks/fix.md +2 -0
  54. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +11 -0
  55. package/skills/workflow/run-pipeline-stage/scripts/pnpm-lock.yaml +342 -0
  56. package/test/cli.test.mjs +37 -39
  57. package/test/helpers/fake-pi.mjs +132 -0
  58. package/test/pi-installer.test.mjs +345 -286
  59. package/test/pi-register.test.mjs +342 -0
  60. package/test/pi-sweep.test.mjs +619 -0
  61. package/test/release-gates.test.mjs +190 -0
  62. package/test/verify-worker-tree.test.mjs +120 -0
  63. package/token-map.README.md +16 -18
  64. package/token-map.json +29 -33
  65. package/agents/plan/copilot/frontmatter.json +0 -6
  66. package/agents/plan.agent.md +0 -59
  67. package/agents/ralph/copilot/frontmatter.json +0 -6
  68. package/agents/ralph/copilot/polling.md +0 -62
  69. package/agents/ralph-plan/copilot/frontmatter.json +0 -6
  70. package/agents/ralph-plan.agent.md +0 -126
  71. package/agents/ralph.agent.md +0 -331
  72. package/agents/strategy/copilot/frontmatter.json +0 -6
  73. package/agents/strategy.agent.md +0 -112
  74. package/bin/installers/copilot.mjs +0 -124
  75. package/extensions/session-start.ts +0 -44
  76. package/hooks.json +0 -10
  77. package/lib/pi-packages.mjs +0 -169
  78. package/plugin.json +0 -35
  79. package/scripts/build-copilot-agents.mjs +0 -30
  80. package/scripts/install-instructions.sh +0 -82
  81. package/scripts/sync-plugin-version.sh +0 -17
  82. package/test/copilot-installer.test.mjs +0 -308
  83. package/test/pi-packages.test.mjs +0 -295
package/README.md CHANGED
@@ -1,21 +1,18 @@
1
1
  # agent-cortex
2
2
 
3
- A personal collection of custom agents and skills, shipped to three harnesses from one
4
- source: the [GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/plugins-creating),
5
- pi, and [Claude Code](https://code.claude.com/docs) (as a plugin).
3
+ A personal collection of custom agents and skills, shipped to two harnesses from one
4
+ source: pi and [Claude Code](https://code.claude.com/docs) (as a plugin).
6
5
 
7
6
  ## Structure
8
7
 
9
8
  ```
10
9
  agent-cortex/
11
- ├── plugin.json # Copilot plugin manifest
12
10
  ├── agents/ # Canonical agents — composable <name>/ dirs (see agents/README.md)
13
- │ ├── *.agent.md # ralph, ralph-plan, plan, strategy — GENERATED from <name>/ by scripts/build-copilot-agents.mjs
14
- │ ├── ralph/ # composable form (shared agent.md + per-harness pi/, copilot/, claude/)
11
+ │ ├── ralph/ # composable form (shared agent.md + per-harness pi/, claude/)
15
12
  │ ├── plan/ # "
16
13
  │ ├── ralph-plan/ # "
17
14
  │ └── strategy/ # "
18
- ├── agents-native/ # Claude-only agents with no Copilot equivalent
15
+ ├── agents-native/ # Claude-only agents
19
16
  │ └── ralph.md # the lean Claude Ralph
20
17
  ├── skills/ # Skills (grouped by domain) — shared by all harnesses
21
18
  │ ├── engineering/ # tdd, improve-codebase-architecture, …
@@ -37,23 +34,18 @@ agent-cortex/
37
34
  ├── bin/
38
35
  │ ├── agent-cortex.mjs # CLI entrypoint
39
36
  │ └── installers/
40
- │ ├── copilot.mjs # shared generator: agent-cortex install copilot + scripts/build-copilot-agents.mjs
41
- │ └── claude.mjs # materialises ~/.agent-cortex/claude + ~/.claude/settings.json, registers with Claude Code (--output <dir> = generate-only)
42
- ├── scripts/
43
- │ └── build-copilot-agents.mjs # thin wrapper over bin/installers/copilot.mjs (regenerates agents/*.agent.md)
37
+ │ ├── claude.mjs # materialises ~/.agent-cortex/claude + ~/.claude/settings.json, registers with Claude Code (--output <dir> = generate-only)
38
+ │ └── pi.mjs # stages ~/.agent-cortex/pi + registers it with pi (--output <dir> = stage-only)
44
39
  ├── claude/ # Committed Claude user-settings template (settings.json) — merged into ~/.claude/settings.json
45
40
  └── claude-extras/ # Hand-authored Claude plugin extras
46
41
  ├── .mcp.json # MCP servers (context7, github) — copied into installs
47
42
  └── scripts/ # statusline-command.sh — copied into installs (executable)
48
43
  ```
49
44
 
50
- The same `agents/` and `skills/` power three harnesses (Copilot, pi, Claude Code).
51
- The composable `agents/<name>/` directories are the single source of truth; the flat
52
- `agents/*.agent.md` files are **generated** by the shared copilot installer
53
- (`agent-cortex install copilot`, or `scripts/build-copilot-agents.mjs` via
54
- `pnpm build:copilot` — both run the same `bin/installers/copilot.mjs` code path, so
55
- install-time and build-time output can never diverge) and committed so Copilot CLI
56
- (plugin.json `agents: "agents/"`) and pi keep loading the agents — don't hand-edit them.
45
+ The same `agents/` and `skills/` power two harnesses (pi and Claude Code). The composable
46
+ `agents/<name>/` directories are the single source of truth, and no flat agent file is
47
+ committed: `agent-cortex install claude` and `agent-cortex install pi` each render their own
48
+ from the canonical directories, so install-time output can never drift from the sources.
57
49
  The `{{TOOL:...}}` / `{{PATH:...}}` tokens written in agent and skill files are resolved
58
50
  per harness at install time from `token-map.json`, the single source of truth for
59
51
  canonical tool/path/agent names (see `token-map.README.md` and the `contract` section).
@@ -76,15 +68,13 @@ temp-dir install plus structural checks:
76
68
  - **Agents** can't be shared files (the frontmatter formats differ), so the materialised
77
69
  plugin's `agents/*.md` are composed from the canonical `agents/<name>/` directories' `claude/`
78
70
  harness dirs
79
- (frontmatter.json + section files), exactly like the Copilot flats are composed from their
80
- `copilot/` dirs. Claude only loads agents from a plugin's default `agents/` dir, so the plugin
81
- ships them at its own root (default `~/.agent-cortex/claude/agents/`) — isolating them from the
82
- Copilot `.agent.md` files.
83
- - **Claude-native agents** that have no Copilot equivalent live in `agents-native/*.md` and are
84
- copied verbatim into the materialised plugin's `agents/`. `ralph` is one: it is reimplemented
85
- for Claude around
86
- background workers + an independent review gate (the Copilot Ralph's `task`/`read_agent`
87
- poll loop has no Claude equivalent), so it can't be mechanically converted.
71
+ (frontmatter.json + section files). Claude only loads agents from a plugin's default `agents/`
72
+ dir, so the plugin ships them at its own root (default `~/.agent-cortex/claude/agents/`).
73
+ - **Claude-native agents** that cannot be composed from a shared body live in
74
+ `agents-native/*.md` and are copied verbatim into the materialised plugin's `agents/`. `ralph`
75
+ is one: it is reimplemented for Claude around background workers + an independent review gate
76
+ (Claude's event-driven completion delivery has no `task`/`read_agent` poll loop to reuse), so
77
+ it can't be mechanically converted.
88
78
  - **Manifests** are generated too: the plugin's `.claude-plugin/plugin.json` (its `version`
89
79
  tracks `package.json`, so it never goes stale) and `hooks.json` (copied from the canonical
90
80
  `hooks/claude/hooks.json` source), plus any support files under `hooks/claude/` bundled into
@@ -94,8 +84,8 @@ temp-dir install plus structural checks:
94
84
  extension→hook mapping and the rejections (auto-name, agent-guardrails, skill-stats, subagent, agent-modes).
95
85
 
96
86
  Edit the sources (`agents/<name>/` composable dirs, `agents-native/*.md`, `skills/**`,
97
- `hooks/claude/`, `claude-extras/`, `package.json`), never the generated
98
- `agents/*.agent.md` files or anything under the materialised `~/.agent-cortex/claude`.
87
+ `hooks/claude/`, `claude-extras/`, `package.json`), never anything under the materialised
88
+ `~/.agent-cortex/claude`.
99
89
 
100
90
  ## CI
101
91
 
@@ -105,123 +95,180 @@ does its own checkout and `pnpm install` rather than sharing build artifacts fro
105
95
  the `setup` job — pnpm workspace symlinks don't survive artifact upload/download,
106
96
  so artifact sharing would break the workspace resolution that the build depends on.
107
97
 
98
+ The root `pnpm-workspace.yaml` carries a strict `allowBuilds` map: on pnpm 12 (what CI
99
+ pins) any dependency with install or build scripts that is not named there aborts
100
+ `pnpm install` with `ERR_PNPM_IGNORED_BUILDS`. pnpm 10 only warns, so a newly pulled-in
101
+ native dependency surfaces as a red `Setup` job before it surfaces locally. Adding one
102
+ therefore means deciding its build policy in that map — `false` unless it genuinely
103
+ needs to compile, with a comment saying why.
104
+
108
105
  The repo commits no generated `claude/` plugin output, so the `claude-plugin-check` job
109
106
  validates the Claude plugin **materialiser** instead of diffing a committed mirror:
110
107
  it runs `node bin/agent-cortex.mjs install claude --output <tmp dir>` and checks the
111
108
  result structurally — `plugin.json` version tracks `package.json`, every generated and
112
109
  hand-authored piece is present, no literal `{{TOOL:...}}`/`{{PATH:...}}` tokens survive,
113
- and no symlinks leak into the copied tree. The Copilot drift check
114
- (`pnpm build:copilot` + `git diff --exit-code -- 'agents/*.agent.md'`) still guards the
115
- committed flat agent files.
116
-
117
- A separate `changeset-check` job runs only on pull requests and fails any PR that
118
- touches a versioned path (`extensions/`, `skills/`, `agents/`, `package.json`, or
119
- `plugin.json`) without a changeset in `.changeset/`. Add one with `pnpm changeset` —
120
- the `style-versioning` skill documents the format.
110
+ and no symlinks leak into the copied tree. There is no committed agent file to drift-check:
111
+ the `agents/` tree holds the composable sources only, and both installers render from them.
112
+
113
+ A separate `changeset-check` job runs on every pull request and fails it unless the
114
+ PR adds a `.changeset/*.md` file. **Publishing is the default and `no-publish` is the
115
+ only opt-out**, so shipping nothing has to be a deliberate, reviewable act rather
116
+ than an accident. Two exemptions: the changesets bot's Version Packages PR (it
117
+ consumes changesets and adds none) and PRs labelled `no-publish`. The `no-publish`
118
+ label must exist in the repository's label settings — a one-off repo-settings step
119
+ that no PR can ship. The `style-versioning` skill documents the format of a
120
+ changeset.
121
121
 
122
122
  On pushes to `main`, a `release` job (gated on `lint`, `test`, and
123
123
  `claude-plugin-check`) runs changesets to open a `chore: version packages` PR when
124
124
  changesets are pending, then publishes to npm once it lands. The version step runs
125
- `pnpm version-packages` — bumping `package.json`, syncing `plugin.json`, and
126
- regenerating the committed Copilot agent files (the Claude plugin is materialised at
127
- install time with the package version, so it has no committed output to regenerate)
128
- so the drift gates stay green; the
129
- publish step runs `pnpm publish-package` (pack + provenance publish). Publish
130
- authenticates via npm Trusted Publishing (OIDC) — no npm token or GitHub
131
- secret is needed, only the one-time npm-side setup on npmjs.com (package →
125
+ `pnpm version-packages` — `changeset version`, which bumps `package.json` and rewrites
126
+ `CHANGELOG.md` and touches nothing else (both plugins are materialised at install time
127
+ with the package version, so there is no committed output to regenerate); the publish
128
+ step runs `pnpm publish-package` (pack + provenance publish), or
129
+ `pnpm publish-noop` when the merged PR carried `no-publish`. Labels are invisible on
130
+ a push event, so the job resolves the PR merged for the pushed commit through the
131
+ GitHub API and reads its labels — no extra secret or scope, since the job already
132
+ holds `GITHUB_TOKEN` and `pull-requests: write`. A direct push with no merged PR
133
+ resolves to no labels and therefore publishes, so attempting to publish an
134
+ already-published version still fails loudly; there is deliberately no idempotency
135
+ guard. Publishing authenticates via npm Trusted Publishing (OIDC) — no npm token or
136
+ GitHub secret is needed, only the one-time npm-side setup on npmjs.com (package →
132
137
  Access → Trusted Publishing for the `jaybeeuu/agent-cortex` repo). Releases
133
138
  are sourced entirely from `main`.
134
139
 
135
- ## Installation
136
-
137
- ### Pi config files (`settings.json` + `keybindings.json`)
138
-
139
- `agent-cortex install pi` materialises `~/.pi/agent/settings.json` and
140
- `~/.pi/agent/keybindings.json` as real CLI-managed files — the legacy symlinks
141
- into this repo's `pi/` directory are gone. `pi/settings.json` and
142
- `pi/keybindings.json` are the committed **templates**; the live files exist only
143
- on the machine, so re-run the installer after pulling changes.
144
-
145
- `settings.json` is merged. The template supplies defaults for keys the live file
146
- lacks, every value already present in the live file wins, and keys the template
147
- does not know about are preserved — so personal config (and anything pi itself
148
- wrote) survives re-install. The one key the CLI owns outright is `packages`: it
149
- is rebuilt from the template with the repo path entry resolved against the live
150
- settings file.
151
-
152
- Two consequences follow from that precedence:
153
-
154
- - **Template changes to non-`packages` keys never reach an existing install.**
155
- Because the live value always wins, editing a default in `pi/settings.json`
156
- only affects a fresh install (or a manually deleted live file) — edit the live
157
- file to adopt a new default.
158
- - **`pi install npm:<pkg>` entries do not survive re-install.** `packages` is
159
- rebuilt from the template, so any `npm:` package pi added to the live file is
160
- dropped on the next `agent-cortex install pi`. Declare long-lived packages in
161
- the repo template instead.
162
-
163
- An unparseable live `settings.json` is warned about and overwritten.
164
- `keybindings.json` follows a checksum rule: written from the template, refreshed
165
- when the template changes, and left untouched once you edit it by hand (delete
166
- it to re-adopt the template).
167
-
168
- ### Pi package dependencies
169
-
170
- These packages are declared in the package manifest (`package.json` → `pi.packages`) and
171
- provisioned by `agent-cortex install pi`, so a clean `~/.pi` gets the tools they provide
172
- without a manual `pi install`. They are also declared in the template `pi/settings.json`,
173
- so the materialised `settings.json` registers them with pi.
174
-
175
- | Package | Version | Purpose |
176
- |---|---|---|
177
- | [`pi-web-access`](https://www.npmjs.com/package/pi-web-access) | 0.10.7 | Web search, URL fetching, GitHub repo access, PDF/YouTube/video analysis (`fetch_content`) |
178
- | [`pi-questions`](https://www.npmjs.com/package/pi-questions) | latest | Structured interactive questions (`ask_questions`) |
179
-
180
- Pass `--no-provision` to skip the package install step (e.g. offline machines); a
181
- missing `pi` CLI or failed install warns and leaves the rest of the install intact.
140
+ Merge the version PR whenever its plan and diff look right, but approve its CI
141
+ first: `changesets/action` pushes that branch with `GITHUB_TOKEN`, so GitHub parks
142
+ the CI run the push creates behind **“Approve workflows to run”** — a run with no
143
+ jobs, which reports nothing, so the merge box shows `BLOCKED` with an empty check
144
+ list even though no gate has run or failed. Approving it from the merge box (or
145
+ `gh api -X POST repos/{owner}/{repo}/actions/runs/<run-id>/approve`) starts the five
146
+ required checks. Do it after the last merge to `main`, not once at the start of a
147
+ release: every subsequent merge force-updates the version branch, and a new head
148
+ brings a new parked run. This stays manual by design — letting the bot's push
149
+ trigger CI on its own means a personal access token or GitHub App token, a
150
+ long-lived credential in repository secrets to save one click per release.
182
151
 
183
- Desktop notifications are handled by the local `extensions/notify/` extension
184
- (replaces the former `pi-notify` dependency). It sends an OSC desktop
185
- notification on multi-turn tasks, labelled with the tmux session:window.pane
186
- if available, or the project directory name otherwise.
152
+ ## Installation
187
153
 
188
- ### Pi harness agents & skills (`agent-cortex install pi`)
154
+ ### Pi package staging (`agent-cortex install pi`)
189
155
 
190
- The agents are already available to pi through the package (`pi.skills` + the
191
- `agent-modes` extension compose them at runtime), but the raw package files carry
192
- literal `{{TOOL:...}}` / `{{PATH:...}}` tokens. Run the pi installer to materialise
193
- composed agents and token-substituted skills into pi's user scope:
156
+ `agent-cortex install pi` materialises agent-cortex as a self-contained pi
157
+ package in `~/.agent-cortex/pi` — the pi analogue of `~/.agent-cortex/claude` —
158
+ and registers that directory with pi through pi's own `pi install`. Nothing is
159
+ generated into pi's own directories (`~/.pi/agent/…`): pi owns its settings
160
+ file, so the installer only reads it to decide the plan and lets the `pi` CLI
161
+ write it. Once the staged package is registered, the artifacts an older
162
+ installer rendered there are swept (see below).
194
163
 
195
164
  ```sh
196
- agent-cortex install pi
197
- # → ~/.pi/agent/agents/<name>.agent.md (ralph, plan, ralph-plan, strategy)
198
- # → ~/.pi/agent/skills/ (token-substituted skill tree)
199
- # → ~/.pi/agent/settings.json + keybindings.json (merged from the repo templates)
165
+ agent-cortex install pi # stage ~/.agent-cortex/pi + register it with pi
200
166
  ```
201
167
 
202
- Flags:
168
+ Registration is idempotent by state: the staged path is registered once (a
169
+ re-run is a true no-op — a local package source is read from disk on every pi
170
+ start, so nothing needs refreshing), and a source pointing at a raw agent-cortex
171
+ checkout is removed first, so exactly one agent-cortex source stays configured.
172
+ The installer decides that plan by reading pi's settings at
173
+ `~/.pi/agent/settings.json`, so a pi agent dir relocated with
174
+ `PI_CODING_AGENT_DIR` is not inspected — a superseded raw-repo source configured
175
+ there has to be removed by hand with `pi remove <path>`.
176
+
177
+ Under the old model the same installer rendered agents and skills into
178
+ `~/.pi/agent/{agents,skills}`. Those copies are a second source of the same
179
+ resource — the skill-collision diagnostics the staged model exists to remove —
180
+ so once registration succeeds the installer removes the ones it can attribute to
181
+ agent-cortex: `agents/<name>.agent.md` and `skills/<group>/<name>` for agents and
182
+ skills this package ships or once shipped, and a `.agent-cortex-install.json`
183
+ path record left there listing those copies. It is a one-time migration:
184
+ attribution is by name, which cannot tell a rendered copy from a file you wrote
185
+ under the same name, so once it has finished it records that in
186
+ `~/.agent-cortex/legacy-sweep.json` — keyed by the pi user directory, never
187
+ inside it — and never removes anything there again. A completed migration
188
+ leaves `~/.pi/agent` with no agent-cortex file in it. Only a migration that
189
+ removed every copy it attributed, from directories it could read, is recorded:
190
+ a copy that could not be deleted (permissions, `EBUSY`) or a directory that
191
+ could not be listed is warned about and retried on the next install, and a
192
+ record that cannot be written is a warning, not a failed install. Anything
193
+ whose name this package does not ship is left alone, and
194
+ `~/.pi/agent/extensions` is never touched at all — no
195
+ installer has written there, so its contents are yours. `--output <dir>` and
196
+ `--dry-run` sweep nothing.
197
+ The sweep follows the settings file the installer reads (`~/.pi/agent`): a pi
198
+ agent dir relocated with `PI_CODING_AGENT_DIR` keeps its copies.
199
+
200
+ The staged package contains:
201
+
202
+ | Path | Contents |
203
+ | --- | --- |
204
+ | `package.json` | pi manifest — `keywords: ["pi-package"]`, `pi.extensions` + `pi.skills`; the version tracks the package |
205
+ | `agents/` | composed flat agents (ralph, plan, ralph-plan, strategy) with `{{TOOL:...}}` / `{{PATH:...}}` substituted — the shipped `agent-modes` extension resolves them from the package root |
206
+ | `skills/` | token-substituted skill copies (real files, never symlinks) |
207
+ | `extensions/` | copy of the repo `extensions/` tree |
208
+ | `token-map.json` | the token map `agent-modes` reads from the package root |
209
+ | `node_modules/` | the required third-party pi packages and their transitive closure |
210
+
211
+ The third-party packages supply the tools the agents need — `pi-questions`
212
+ (`ask_questions`) and `pi-web-access` (`fetch_content`). They are ordinary
213
+ runtime dependencies of this package and travel inside the staged tree, so pi
214
+ loads them from a local directory without any npm resolution of its own. An
215
+ unresolvable dependency fails the install rather than staging a package that
216
+ cannot provide those tools. Re-staging clears the children the installer owns, so
217
+ a re-run never accumulates stale copies.
203
218
 
204
219
  | Flag | Meaning |
205
220
  | --- | --- |
206
- | `--dry-run` | Show what would be installed without writing anything |
207
- | `--output <dir>` | Install into `<dir>/agents`, `<dir>/skills` and the config files (default `~/.pi/agent`) |
221
+ | `--dry-run` | Show what would be staged and registered without writing or spawning anything |
222
+ | `--output <dir>` | Stage into `<dir>` only — no registration (tests/CI) |
208
223
  | `--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) |
209
- | `--no-provision` | Skip provisioning the third-party pi packages declared in `package.json` `pi.packages` (default: install them via the `pi` CLI) |
224
+ | `--require-register` | Fail the install when the `pi` CLI cannot drive registration; by default a missing CLI warns and prints the commands to run |
210
225
 
211
- Re-run whenever you pull changes (`git pull` + reinstall, or after `pnpm build:copilot`).
226
+ If the `pi` CLI is not on `PATH`, the staged package is correct but unregistered:
227
+ the installer warns and prints the exact commands (`pi install
228
+ ~/.agent-cortex/pi`, plus a `pi remove` for any superseded raw-repo source).
212
229
 
213
- ### Copilot plugin (separate)
230
+ A superseded raw-repo source that `pi remove` cannot drop fails the install
231
+ (non-zero, naming the source still configured): pi would load both sources, so
232
+ reporting success would leave the two-source state registration exists to
233
+ prevent. Nothing is installed on that path — remove the source by hand and re-run.
214
234
 
215
- ```sh
216
- copilot plugin install jaybeeuu/agent-cortex
217
- ```
235
+ Re-run `agent-cortex install pi` after every `git pull` to refresh the staged
236
+ package; registration is already in place, so that re-run changes nothing in
237
+ pi's settings. Verify with `pi list` and `pi config` (restart pi to apply).
238
+
239
+ ### Desktop notifications
240
+
241
+ Desktop notifications are handled by the local `extensions/notify/` extension
242
+ (replaces the former `pi-notify` dependency). It sends an OSC desktop
243
+ notification on multi-turn tasks, labelled with the tmux session:window.pane
244
+ if available, or the project directory name otherwise.
245
+
246
+ ### Pi config files
218
247
 
219
- Or install a local checkout:
248
+ `pi/settings.json` and `pi/keybindings.json` are committed **reference
249
+ templates** for your own pi configuration. They are not installer output: pi's
250
+ `settings.json` and `keybindings.json` are pi's own user config, so
251
+ `agent-cortex install pi` leaves them alone.
252
+
253
+ ### Removing a stale Copilot install
254
+
255
+ Copilot CLI is no longer a deploy target: `agent-cortex install copilot` and the
256
+ `plugin.json` manifest are gone, and nothing in this package reads or writes `~/.copilot`
257
+ any more. No installer sweeps an existing install, so a machine that used the old target
258
+ keeps a stale plugin, a cached marketplace, and an instruction block until you remove them
259
+ by hand:
220
260
 
221
261
  ```sh
222
- copilot plugin install ./agent-cortex
262
+ rm -rf ~/.copilot/installed-plugins/_direct/agent-cortex
263
+ rm -rf ~/.cache/copilot/marketplaces/https---github-com-jaybeeuu-agent-cortex
264
+ sed -i.bak '/<!-- agent-cortex:start -->/,/<!-- agent-cortex:end -->/d' \
265
+ ~/.copilot/copilot-instructions.md
223
266
  ```
224
267
 
268
+ The first two paths are the old install and its marketplace cache. The `sed` deletes only
269
+ the agent-cortex block the removed `postinstall` hook appended to Copilot's own
270
+ instructions file, leaving the rest of that file — and a `.bak` copy — intact.
271
+
225
272
  ### Claude Code plugin (separate)
226
273
 
227
274
  A plain `agent-cortex install claude` **materialises** the plugin into the home install
@@ -241,10 +288,6 @@ The generate-only `--output <dir>` form is for previewing and CI validation; the
241
288
  documented path is the plain install to `~/.agent-cortex/claude`:
242
289
 
243
290
  ```sh
244
- pnpm build:copilot # or: node scripts/build-copilot-agents.mjs (regenerates agents/*.agent.md)
245
- node bin/agent-cortex.mjs install copilot # regenerates agents/*.agent.md in place
246
- node bin/agent-cortex.mjs install copilot --dry-run # plan only, no writes
247
- node bin/agent-cortex.mjs install copilot --output /tmp/x # preview the flat files elsewhere
248
291
  node bin/agent-cortex.mjs install claude # materialises ~/.agent-cortex/claude + marketplace manifest AND registers it with Claude Code (user scope, idempotent)
249
292
  node bin/agent-cortex.mjs install claude --dry-run # plan generation + registration, no writes/spawns
250
293
  node bin/agent-cortex.mjs install claude --require-register # fail (non-zero exit) when the claude CLI can't drive registration
@@ -380,14 +423,14 @@ extension→hook audit.
380
423
  rejection rationale live in `docs/claude-hooks.md`.
381
424
  - Ralph follow-ups: multi-feature epic branches, and a GitHub-trigger routine to auto-resume
382
425
  after a PR merge (instead of manual re-invocation).
383
- - The Copilot/pi Ralph (the 4-stage `run-pipeline-stage` pipeline) is unchanged; those two
426
+ - The pi Ralph (the 4-stage `run-pipeline-stage` pipeline) is unchanged; those two
384
427
  ralph-coupled skills (`ralph`, `run-pipeline-stage`) are intentionally not shipped to Claude.
385
428
 
386
429
  #### Contributing to the Claude plugin
387
430
 
388
431
  Edit the **sources** — the composable `agents/<name>/` directories (shared `agent.md` +
389
- per-harness frontmatter/sections, auto-composed by `scripts/build-copilot-agents.mjs` and
390
- `bin/installers/claude.mjs`), `agents-native/*.md` (Claude-only
432
+ per-harness frontmatter/sections, composed by `bin/installers/claude.mjs`),
433
+ `agents-native/*.md` (Claude-only
391
434
  agents like `ralph` — the canonical bodies the installer copies verbatim), `skills/**`,
392
435
  `hooks/claude/hooks.json` (hook config), `claude/settings.json` (the user-settings template
393
436
  merged into `~/.claude/settings.json`), `claude-extras/` (hand-authored `.mcp.json` and
@@ -397,7 +440,5 @@ version — picked up at install time) — then run
397
440
  re-registers it; `--output <dir>` generates a preview only). The only committed file under
398
441
  `claude/` is the settings template; `~/.agent-cortex/claude` is generated in full
399
442
  (`.claude-plugin/plugin.json`, `agents/`, `skills/`, `hooks.json`, `.mcp.json`, `scripts/`)
400
- so never edit anything under it. The generated `agents/*.agent.md` files are still
401
- drift-checked by CI (`git diff --exit-code -- 'agents/*.agent.md'`), and CI validates the
402
- Claude materialiser (structural checks on a temp-dir install) so sources and installer can
403
- never silently diverge.
443
+ so never edit anything under it. CI validates the Claude materialiser (structural checks on
444
+ a temp-dir install) so sources and installer can never silently diverge.
package/agents/README.md CHANGED
@@ -4,7 +4,7 @@ This document defines the canonical format for composable agent directories in a
4
4
 
5
5
  ## Motivation
6
6
 
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.
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, Claude) with different tool names and polling mechanisms.
8
8
 
9
9
  The composable directory format separates concerns:
10
10
 
@@ -21,9 +21,6 @@ agents/
21
21
  │ ├── pi/
22
22
  │ │ ├── frontmatter.json # PI-specific metadata
23
23
  │ │ └── <section>.md # Optional: PI-specific sections
24
- │ ├── copilot/
25
- │ │ ├── frontmatter.json # Copilot-specific metadata
26
- │ │ └── <section>.md # Optional: Copilot-specific sections
27
24
  │ └── claude/
28
25
  │ ├── frontmatter.json # Claude-specific metadata
29
26
  │ └── <section>.md # Optional: Claude-specific sections
@@ -37,9 +34,6 @@ agents/ralph/
37
34
  ├── pi/
38
35
  │ ├── frontmatter.json # PI tools: ["bash", "task", "read_agent", "wait_for_agents"]
39
36
  │ └── polling.md # PI completion: blocking wait_for_agents (no poll timer)
40
- ├── copilot/
41
- │ ├── frontmatter.json # Copilot tools: ["bash", "task", "read_agent"]
42
- │ └── polling.md # Copilot completion: sleep-120 poll timer + read_agent
43
37
  └── claude/
44
38
  ├── frontmatter.json # Claude tools: ["bash", "task"]
45
39
  └── polling.md # Claude event-driven (no polling)
@@ -52,8 +46,6 @@ agents/plan/
52
46
  ├── agent.md # Shared body (planning workflow)
53
47
  ├── pi/
54
48
  │ └── frontmatter.json # PI tools
55
- ├── copilot/
56
- │ └── frontmatter.json # Copilot tools
57
49
  └── claude/
58
50
  └── frontmatter.json # Claude tools
59
51
  ```
@@ -143,9 +135,8 @@ When composing the final agent file for a specific harness:
143
135
  2. Replace `{{SECTION:name}}` with content from `<harness>/<name>.md`
144
136
  3. `{{TOOL:name}}` and `{{PATH:name}}` are resolved against `token-map.json` — the
145
137
  canonical tool/path/agent names per harness. `scripts/lib/compose-agent.mjs` (used by
146
- `build:copilot` and by `bin/installers/claude.mjs` / `bin/installers/pi.mjs`) resolves them when
147
- generating the flat files / installing for claude and pi; pi's `agent-modes` extension does the
148
- same at runtime. See the `contract` section of `token-map.json` and
138
+ `bin/installers/claude.mjs` / `bin/installers/pi.mjs`) resolves them when generating the flat
139
+ files / installing for claude and pi; pi's `agent-modes` extension does the same at runtime. See the `contract` section of `token-map.json` and
149
140
  `token-map.README.md` for the rules.
150
141
 
151
142
  The pi harness's `agent-modes` extension is a runtime consumer of this format: it
@@ -153,6 +144,16 @@ composes agent prompts on the fly from `agent.md` + `pi/frontmatter.json`, subst
153
144
  tokens against `token-map.json`'s pi column with no install step. See
154
145
  `extensions/agent-modes/README.md`.
155
146
 
147
+ ### Rendered tool lists are comma-separated
148
+
149
+ pi's `parseFrontmatter` returns the `tools` scalar as one string, and its consumers split
150
+ that string on commas — the subagent extension forwards it straight to `pi --tools`, whose
151
+ parser is comma-separated too. Generated pi agents therefore render
152
+ `tools: "bash, read, task"`; a space-separated list collapses to a single bogus name and
153
+ leaves the agent with an allowlist matching no tool. Both parsers
154
+ (`extensions/subagent/agents.ts`, `extensions/agent-modes/discover.ts`) accept whitespace
155
+ as well, so either form round-trips safely.
156
+
156
157
  ## Composition Rules
157
158
 
158
159
  ### For Harnesses with Sections
@@ -191,7 +192,6 @@ Agents like `plan`, `ralph-plan`, and `strategy` that have identical behavior ac
191
192
  agents/plan/
192
193
  ├── agent.md # Shared body (same for all harnesses)
193
194
  ├── pi/frontmatter.json # PI tools
194
- ├── copilot/frontmatter.json # Copilot tools
195
195
  └── claude/frontmatter.json # Claude tools
196
196
  ```
197
197
 
@@ -201,14 +201,12 @@ agents/plan/
201
201
  2. Migrate ralph agent first (proves the pattern) — DONE
202
202
  3. Migrate plan, ralph-plan, strategy agents — DONE
203
203
  4. Update the installer/composer to handle the new format
204
- 5. Remove old `*.agent.md` files — DONE (the flat files are now **generated output**, see below)
204
+ 5. Remove old `*.agent.md` files — DONE (the composable directories are the only committed
205
+ form; every harness composes or renders its own agent files at install time)
205
206
 
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:
207
+ All four agents (`ralph`, `plan`, `ralph-plan`, `strategy`) use the composable layout, and no
208
+ flat agent file is committed:
208
209
 
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
210
  - `bin/installers/claude.mjs` (plain `agent-cortex install claude` materialises the plugin
213
211
  into `~/.agent-cortex/claude` and registers it with Claude Code; `--output <dir>` is its
214
212
  generate-only form, used by tests/CI) composes the plugin's
@@ -216,8 +214,11 @@ flat `agents/*.agent.md` files are built from them:
216
214
  from `agents-native/ralph.md`, copied verbatim).
217
215
  - The pi harness delivers two ways: the `agent-modes` extension composes `agent.md` +
218
216
  `pi/frontmatter.json` at runtime against `token-map.json`, and `agent-cortex install pi`
219
- materialises composed agents + token-substituted skills into `~/.pi/agent` at install
220
- time (see README "Pi harness agents & skills").
217
+ renders flat pi agents + token-substituted skills into a self-contained package at
218
+ `~/.agent-cortex/pi`, which pi loads once registered (see README "Pi package staging
219
+ (`agent-cortex install pi`)"). `agent-modes` and the `subagent` extension both read agents
220
+ beside themselves,
221
+ so the staged package needs no `~/.pi/agent` writes.
221
222
 
222
223
  Never edit the generated flat materialised files by hand — edit the composable directory.
223
224
  Generation is install-time: `claude` ships
@@ -226,11 +227,9 @@ via `bin/installers/claude.mjs`, the generator behind plain `agent-cortex instal
226
227
  `claude/settings.json` into `~/.claude/settings.json`, and registers the plugin with Claude
227
228
  Code); the only committed `claude/` file is that settings template (hand-authored extras live
228
229
  in `claude-extras/`), and CI validates the materialiser with structural checks on a temp-dir
229
- install; `copilot` ships via
230
- `bin/installers/copilot.mjs`, the shared code path behind both `agent-cortex install
231
- copilot` and `scripts/build-copilot-agents.mjs`; `pi` ships via
232
- `bin/installers/pi.mjs`, which materialises composed agents + token-substituted skills
233
- into `~/.pi/agent`.
230
+ install; `pi` ships via
231
+ `bin/installers/pi.mjs`, which stages a self-contained pi package (manifest, rendered
232
+ agents, token-substituted skills, extensions) at `~/.agent-cortex/pi`.
234
233
 
235
234
  ## Validation
236
235
 
@@ -251,7 +250,7 @@ The validator checks:
251
250
 
252
251
  - JSON has strict syntax (no comments, no ambiguity)
253
252
  - Easier to validate with JSON Schema
254
- - Consistent with existing tooling (package.json, plugin.json)
253
+ - Consistent with existing tooling (package.json)
255
254
  - No need for YAML parser dependency
256
255
 
257
256
  ### Why separate section files instead of inline sections?
@@ -42,7 +42,7 @@ Run once at startup:
42
42
  5. Create Ralph's workspace directory: `mkdir -p .agent-cortex/ralph`
43
43
  6. Create `.agent-cortex/ralph/state.json` with initial content:
44
44
  ```json
45
- { "timerShellId": null, "inflight": [] }
45
+ { "inflight": [] }
46
46
  ```
47
47
  Then generate the progress file:
48
48
  ```bash
@@ -59,7 +59,7 @@ Run once at startup:
59
59
  b. Claim the parent bead: `bd update <parent-id> --claim`.
60
60
  c. Create the first stage chore bead and dispatch it (see _Creating and dispatching a stage chore_ below).
61
61
  8. Record each launched agent in `.agent-cortex/ralph/state.json` (see format below).
62
- 9. Hand over to the completion-detection mechanism in the polling section: it starts the Copilot poll loop, blocks with `wait_for_agents` (PI), or waits for event-driven wake-ups (Claude), and proceeds to **HITL Pause** directly when no agent work was dispatched and HITL gate beads are pending.
62
+ 9. Hand over to the completion-detection mechanism in the polling section: it blocks with `wait_for_agents` (PI) or waits for event-driven wake-ups (Claude), and proceeds to **HITL Pause** directly when no agent work was dispatched and HITL gate beads are pending.
63
63
 
64
64
  ---
65
65
 
@@ -101,7 +101,6 @@ All orchestration state is derived from beads:
101
101
 
102
102
  ```json
103
103
  {
104
- "timerShellId": "shell-abc",
105
104
  "inflight": [
106
105
  { "choreId": "xyz-456", "parentId": "abc-123", "title": "Add auth", "agentId": "agent-xyz-456", "logLine": 4 },
107
106
  { "choreId": "def-789", "parentId": "ghi-101", "title": "Fix cache", "agentId": "agent-def-789", "logLine": 7 }
@@ -109,7 +108,6 @@ All orchestration state is derived from beads:
109
108
  }
110
109
  ```
111
110
 
112
- - **timerShellId**: the shellId of the active poll-timer bash process used for completion polling (Copilot; stays `null` on PI, which blocks with `wait_for_agents` instead, and on event-driven harnesses such as Claude).
113
111
  - **inflight[].choreId**: the chore bead currently being worked by the subagent.
114
112
  - **inflight[].parentId**: the parent feature task bead. Log file is `.agent-cortex/ralph/ralph-<parentId>.log`.
115
113
  - **inflight[].logLine**: the next line number to read from the parent's log file (1-based; start at 1). Updated after every poll.
@@ -127,12 +125,12 @@ Update `.agent-cortex/ralph/state.json` after **every** agent completion or disp
127
125
 
128
126
  ## Event loop
129
127
 
130
- After initialization, Ralph waits for background agents to complete. Completion notifications are delivered by the mechanism documented in the polling section — PI blocks with `wait_for_agents` until a worker completes and its result is returned inline; Copilot uses an active poll timer plus log polling; Claude is event-driven (you are re-invoked automatically when a worker completes, with its result delivered inline). On each completion notification:
128
+ After initialization, Ralph waits for background agents to complete. Completion notifications are delivered by the mechanism documented in the polling section — PI blocks with `wait_for_agents` until a worker completes and its result is returned inline; Claude is event-driven (you are re-invoked automatically when a worker completes, with its result delivered inline). On each completion notification:
131
129
 
132
130
  ### If a background agent completed
133
131
 
134
- 1. **Flush** that bead's log using the log-polling procedure in the polling section to pick up any final lines for the chat summary (PI: flush new log lines as part of handling the `wait_for_agents` result; Copilot: flush to detect completion; Claude: nothing to flush — the result is delivered with the wake-up).
135
- 2. **Read** the completed agent's full output (PI: the result arrives in the `wait_for_agents` response, with `read_agent` as a fallback for a specific result; Copilot: `read_agent`; Claude: the result was delivered inline).
132
+ 1. **Flush** that bead's log using the log-polling procedure in the polling section to pick up any final lines for the chat summary (PI: flush new log lines as part of handling the `wait_for_agents` result; Claude: nothing to flush — the result is delivered with the wake-up).
133
+ 2. **Read** the completed agent's full output (PI: the result arrives in the `wait_for_agents` response, with `read_agent` as a fallback for a specific result; Claude: the result was delivered inline).
136
134
  3. **Re-read** `.agent-cortex/ralph/state.json` to identify the chore bead and parent for that agent ID.
137
135
  4. **Parse** the agent's `---REPORT---` block (see report format in the `run-pipeline-stage` skill).
138
136
  5. **Close** the completed chore bead: `bd close <chore-id>`.
@@ -188,7 +186,7 @@ Proceed here when no chore beads are in-flight, no `stage:*` chore beads are rea
188
186
 
189
187
  When you've completed the above actions, prompt me to continue.
190
188
  ```
191
- 6. **Stop completely.** Stop the polling mechanism documented in the polling section (Copilot: kill any running timer; PI and Claude: nothing to stop — there is no timer). Do **not** restart or schedule anything. Do **not** start any background processes. Do **not** check bead status again. Do **not** continue the event loop. Output **nothing further** after the summary above. Ralph is now fully idle — it must not act again until the user explicitly re-prompts.
189
+ 6. **Stop completely.** Stop the polling mechanism documented in the polling section (PI and Claude: nothing to stop — there is no timer). Do **not** restart or schedule anything. Do **not** start any background processes. Do **not** check bead status again. Do **not** continue the event loop. Output **nothing further** after the summary above. Ralph is now fully idle — it must not act again until the user explicitly re-prompts.
192
190
 
193
191
  ---
194
192
 
@@ -258,5 +256,4 @@ All beads complete.
258
256
  - **Never** auto-merge feature or epic PRs — merge decisions are human-controlled.
259
257
  - **Never** continue past feature completion until PR `feature/<parent-id> -> epic/<epic-id>` is merged and the child HITL PR gate bead is closed by a human.
260
258
  - **Never** continue past epic completion until PR `epic/<epic-id> -> main` is merged.
261
- - **When a feature hits the HITL PR gate, push and open the PR immediately and report the URL — do not wait for explicit approval to push or create the PR.**
262
- - **Always** bump the patch version in `plugin.json` as part of any commit that changes agent or skill files.
259
+ - **When a feature hits the HITL PR gate, push and open the PR immediately and report the URL — do not wait for explicit approval to push or create the PR.**
@@ -20,7 +20,7 @@ Rules:
20
20
 
21
21
  Claude Code **re-invokes you automatically when a background worker completes** — the worker's result is delivered to you inline on the wake-up. **Do not poll and do not `sleep`.** React to completions as they arrive.
22
22
 
23
- - There is **no poll timer on Claude**: skip the PI/Copilot timer start and restart steps in initialization, and there is nothing to kill in **HITL Pause** — when you stop, you simply stop. The harness wakes you again when the user re-invokes you.
23
+ - There is **no poll timer anywhere in this pipeline**: nothing in initialization starts one, and there is nothing to kill in **HITL Pause** — when you stop, you simply stop. The harness wakes you again when the user re-invokes you.
24
24
  - There is **no log tailing on Claude**: workers' progress lines (`.agent-cortex/ralph/ralph-<parentId>.log`) are written by the workers themselves and surfaced by the harness with the completion — nothing to flush, nothing to poll. Produce the shared chat summaries from the delivered result instead.
25
25
  - On each completion, apply the shared handling in the **Event loop** section of agent.md (steps 3–8: correlate the task ID to its bead via `state.json`, parse the REPORT, close the chore, advance the parent, check for newly ready beads, run the shutdown check). `state.json` `logLine` tracking is not used on Claude.
26
26