@jaybeeuu/agent-cortex 1.43.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 (42) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +5 -6
  2. package/.github/workflows/ci.yml +4 -11
  3. package/AGENTS.md +10 -16
  4. package/CHANGELOG.md +16 -0
  5. package/README.md +44 -55
  6. package/agents/README.md +9 -23
  7. package/agents/ralph/agent.md +7 -10
  8. package/agents/ralph/claude/polling.md +1 -1
  9. package/bin/agent-cortex.mjs +0 -16
  10. package/bin/installers/claude.mjs +2 -2
  11. package/docs/research/disable-model-invocation.md +5 -26
  12. package/docs/skills/skill-anatomy.md +2 -3
  13. package/docs/technical-direction/harness-config.md +6 -14
  14. package/docs/user-preferences.md +2 -2
  15. package/extensions/agent-modes/README.md +3 -3
  16. package/extensions/agent-modes/discover.ts +6 -6
  17. package/extensions/subagent/README.md +2 -2
  18. package/extensions/subagent/agents.ts +1 -2
  19. package/lib/cli.mjs +5 -7
  20. package/package.json +3 -5
  21. package/scripts/lib/compose-agent.mjs +10 -10
  22. package/skills/workflow/ralph/REFERENCE.md +3 -3
  23. package/skills/workflow/ralph/SKILL.md +5 -5
  24. package/test/cli.test.mjs +11 -10
  25. package/token-map.README.md +9 -12
  26. package/token-map.json +26 -31
  27. package/agents/plan/copilot/frontmatter.json +0 -6
  28. package/agents/plan.agent.md +0 -59
  29. package/agents/ralph/copilot/frontmatter.json +0 -6
  30. package/agents/ralph/copilot/polling.md +0 -62
  31. package/agents/ralph-plan/copilot/frontmatter.json +0 -6
  32. package/agents/ralph-plan.agent.md +0 -126
  33. package/agents/ralph.agent.md +0 -331
  34. package/agents/strategy/copilot/frontmatter.json +0 -6
  35. package/agents/strategy.agent.md +0 -112
  36. package/bin/installers/copilot.mjs +0 -124
  37. package/hooks.json +0 -10
  38. package/plugin.json +0 -35
  39. package/scripts/build-copilot-agents.mjs +0 -30
  40. package/scripts/install-instructions.sh +0 -82
  41. package/scripts/sync-plugin-version.sh +0 -17
  42. package/test/copilot-installer.test.mjs +0 -308
package/token-map.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "agent-cortex token map",
3
- "description": "Central mapping of tool names, paths, and agent naming conventions across the copilot, claude, and pi harnesses. Single source of truth for install-time token substitution. See token-map.README.md for the design rationale.",
3
+ "description": "Central mapping of tool names, paths, and agent naming conventions across the claude and pi harnesses. Single source of truth for install-time token substitution. See token-map.README.md for the design rationale.",
4
4
  "version": 1,
5
- "harnesses": ["copilot", "claude", "pi"],
5
+ "harnesses": ["claude", "pi"],
6
6
  "token_format": {
7
7
  "convention": "{{TYPE:NAME}}",
8
8
  "decision": "Adopt the {{TOOL:name}} / {{PATH:name}} / {{SECTION:name}} grammar already standardised by ADR #63 (agents/README.md) rather than a dotted {{tool.name}} form. The uppercase type prefix disambiguates token kinds at a glance, keeps tool/path/section names in one namespace collision-free, and matches the token grammar skills are already written against.",
@@ -13,40 +13,36 @@
13
13
  }
14
14
  },
15
15
  "tools": {
16
- "bash": { "copilot": "bash", "claude": "Bash", "pi": "bash" },
17
- "view": { "copilot": "view", "claude": "Read", "pi": "read" },
18
- "edit": { "copilot": "edit", "claude": "Edit", "pi": "edit" },
19
- "create": { "copilot": "create", "claude": "Write", "pi": "write" },
20
- "grep": { "copilot": "grep", "claude": "Grep", "pi": "grep" },
21
- "rg": { "copilot": "rg", "claude": "Grep", "pi": "grep" },
22
- "glob": { "copilot": "glob", "claude": "Glob", "pi": "find" },
23
- "ask_user": { "copilot": "ask_user", "claude": "AskUserQuestion", "pi": "ask_questions" },
24
- "web_fetch": { "copilot": "web_fetch", "claude": "WebFetch", "pi": "fetch_content" },
25
- "skill": { "copilot": "skill", "claude": "Skill", "pi": "read" },
26
- "task": { "copilot": "task", "claude": "Task", "pi": "task" },
27
- "read_agent": { "copilot": "read_agent", "claude": null, "pi": "read_agent" },
28
- "wait_for_agents": { "copilot": null, "claude": null, "pi": "wait_for_agents" }
16
+ "bash": { "claude": "Bash", "pi": "bash" },
17
+ "view": { "claude": "Read", "pi": "read" },
18
+ "edit": { "claude": "Edit", "pi": "edit" },
19
+ "create": { "claude": "Write", "pi": "write" },
20
+ "grep": { "claude": "Grep", "pi": "grep" },
21
+ "rg": { "claude": "Grep", "pi": "grep" },
22
+ "glob": { "claude": "Glob", "pi": "find" },
23
+ "ask_user": { "claude": "AskUserQuestion", "pi": "ask_questions" },
24
+ "web_fetch": { "claude": "WebFetch", "pi": "fetch_content" },
25
+ "skill": { "claude": "Skill", "pi": "read" },
26
+ "task": { "claude": "Task", "pi": "task" },
27
+ "read_agent": { "claude": null, "pi": "read_agent" },
28
+ "wait_for_agents": { "claude": null, "pi": "wait_for_agents" }
29
29
  },
30
30
  "paths": {
31
31
  "plugin_root": {
32
- "copilot": "~/.copilot/installed-plugins/_direct/agent-cortex",
33
32
  "claude": "${CLAUDE_PLUGIN_ROOT}",
34
33
  "pi": "~/.agent-cortex/pi"
35
34
  },
36
35
  "agents_dir": {
37
- "copilot": { "base": "plugin_root", "relative": "agents" },
38
36
  "claude": { "base": "plugin_root", "relative": "agents" },
39
37
  "pi": { "base": "plugin_root", "relative": "agents" }
40
38
  },
41
39
  "skills_dir": {
42
- "copilot": { "base": "plugin_root", "relative": "skills" },
43
40
  "claude": { "base": "plugin_root", "relative": "skills" },
44
41
  "pi": { "base": "plugin_root", "relative": "skills" }
45
42
  }
46
43
  },
47
44
  "agents": {
48
45
  "prefix": {
49
- "copilot": "agent-cortex:",
50
46
  "claude": "",
51
47
  "pi": "agent-cortex:"
52
48
  },
@@ -54,41 +50,40 @@
54
50
  "ralph": ["claude"]
55
51
  },
56
52
  "sources": {
57
- "copilot": "agents/<name>/ composable dirs (canonical) — composed to agents/*.agent.md by scripts/build-copilot-agents.mjs",
58
53
  "pi": "agents/<name>/ composable dirs (canonical) — composed at runtime by the agent-modes extension",
59
54
  "claude": "agents/<name>/ composable dirs (canonical) — composed by bin/installers/claude.mjs (install-time generator, the only generator — the generated claude/ plugin subtree is not committed), plus agents-native/*.md for deferred agents"
60
55
  }
61
56
  },
62
57
  "notes": {
63
58
  "tools": {
64
- "rg": "Copilot alias for grep. Claude and pi collapse it onto their single search tool (Grep / grep) — same collapse rule as the build script.",
59
+ "rg": "Canonical alias for grep. Claude and pi collapse it onto their single search tool (Grep / grep).",
65
60
  "glob": "Claude has a dedicated Glob tool. pi's built-in pattern-search tool is find (hypa_find when the pi-hypa extension is installed).",
66
- "ask_user": "Copilot (ask_user) and Claude (AskUserQuestion) prompt the user mid-run. pi's equivalent is ask_questions, provided by the pi-questions package (an ordinary runtime dependency of this package that `agent-cortex install pi` bundles into the staged package's node_modules) — the genuine interactive-questioning tool, restoring grilling in plan/ralph-plan/strategy modes. Like fetch_content (pi-web-access), it is only present when its package is installed, so the mapping depends on that package (see the extension-manifests idea). pi still intentionally ships no permission popups; ask_questions is the interactive mid-run question tool, not a popup.",
61
+ "ask_user": "Claude (AskUserQuestion) prompts the user mid-run. pi's equivalent is ask_questions, provided by the pi-questions package (an ordinary runtime dependency of this package that `agent-cortex install pi` bundles into the staged package's node_modules) — the genuine interactive-questioning tool, restoring grilling in plan/ralph-plan/strategy modes. Like fetch_content (pi-web-access), it is only present when its package is installed, so the mapping depends on that package (see the extension-manifests idea). pi still intentionally ships no permission popups; ask_questions is the interactive mid-run question tool, not a popup.",
67
62
  "web_fetch": "pi's fetch_content comes from the pi-web-access package (an ordinary runtime dependency of this package that `agent-cortex install pi` bundles into the staged package's node_modules).",
68
- "skill": "Copilot (skill) and Claude (Skill) expose skills as a tool. pi has no dedicated skill tool — skills are surfaced in the always-present 'Available skills' context block and loaded by reading the listed SKILL.md path ({{PATH:<skill>/SKILL.md}}). The pi mapping is read, the tool used to load a skill's file; a dedicated skill tool is a follow-on design candidate if prompting proves insufficient.",
69
- "read_agent": "Claude's Task returns results inline — there is no separate read step, so read_agent drops on claude (null). Copilot uses the task + read_agent poll loop; pi exposes read_agent as a fallback to wait_for_agents.",
70
- "task": "Copilot and Claude provide a subagent tool natively. On pi it is supplied by this repo's own extensions/subagent extension (which also registers read_agent and wait_for_agents), not by pi itself — a pi session started before that extension was installed has no dispatch tool at all. Skills must therefore stop and report a missing subagent tool rather than improvising a backgrounded CLI run, which has no completion signal.",
71
- "wait_for_agents": "PI-only blocking wait over background subagent runs (the task tool): returns the results of completed agents and STILL RUNNING for the rest. Copilot has no equivalent tool (its task + read_agent poll loop stays) and Claude's Task delivers results inline with no wait step — both null."
63
+ "skill": "Claude (Skill) exposes skills as a tool. pi has no dedicated skill tool — skills are surfaced in the always-present 'Available skills' context block and loaded by reading the listed SKILL.md path ({{PATH:<skill>/SKILL.md}}). The pi mapping is read, the tool used to load a skill's file; a dedicated skill tool is a follow-on design candidate if prompting proves insufficient.",
64
+ "read_agent": "Claude's Task returns results inline — there is no separate read step, so read_agent drops on claude (null). pi exposes read_agent as a fallback to wait_for_agents.",
65
+ "task": "Claude provides a subagent tool natively. On pi it is supplied by this repo's own extensions/subagent extension (which also registers read_agent and wait_for_agents), not by pi itself — a pi session started before that extension was installed has no dispatch tool at all. Skills must therefore stop and report a missing subagent tool rather than improvising a backgrounded CLI run, which has no completion signal.",
66
+ "wait_for_agents": "PI-only blocking wait over background subagent runs (the task tool): returns the results of completed agents and STILL RUNNING for the rest. Claude's Task delivers results inline with no wait step — null on claude."
72
67
  },
73
68
  "paths": {
74
69
  "pi": "plugin_root is the staged package `agent-cortex install pi` materialises at ~/.agent-cortex/pi; pi loads that directory by path and the shipped extensions resolve their own resources relative to it (agent-modes computes plugin_root from its actual install location). A checkout or symlinked install differs — installers compute plugin_root from the actual resolution and can override it (--plugin-root).",
75
70
  "claude": "plugin_root stays ${CLAUDE_PLUGIN_ROOT} (env var) for the materialised plugin — never a literal ~/.agent-cortex/claude. Claude Code copies marketplace-installed plugins (including local directory sources like ~/.agent-cortex/claude) into its own cache and expands the env var per context, so a literal home path in substituted files would break under cache-copy; the installer passes the env form through verbatim."
76
71
  },
77
72
  "agents": {
78
- "prefix": "Claude strips the agent-cortex: name prefix during conversion (NAME_PREFIX in bin/installers/claude.mjs): copilot/pi agents are agent-cortex:<slug>, claude agents are <slug>.",
79
- "deferred": "ralph has no generated claude counterpart — it is authored natively as agents-native/ralph.md (its event-driven orchestration cannot be produced by section composition from the polling copilot source)."
73
+ "prefix": "Claude strips the agent-cortex: name prefix during conversion (NAME_PREFIX in bin/installers/claude.mjs): pi agents are agent-cortex:<slug>, claude agents are <slug>.",
74
+ "deferred": "ralph has no generated claude counterpart — it is authored natively as agents-native/ralph.md (its event-driven orchestration cannot be produced by section composition from the polling pi source)."
80
75
  }
81
76
  },
82
77
  "contract": {
83
78
  "version": 1,
84
79
  "summary": "Installers substitute {{TOOL:...}}, {{PATH:...}}, and {{SECTION:...}} tokens in generated harness files using this map. This contract is the single reference installers must implement; token-map.json is the data those rules operate on.",
85
- "harness_ids": ["copilot", "claude", "pi"],
80
+ "harness_ids": ["claude", "pi"],
86
81
  "binding": "The harness id is the same value the installer is invoked with (agent-cortex install <harness>). Each harness reads its own column from the tools, paths, and agents sections.",
87
82
  "substitution_order": ["SECTION", "TOOL", "PATH"],
88
83
  "rules": [
89
- "TOOL: replace {{TOOL:<key>}} with tools.<key>.<harness>. Canonical keys are exact, case-sensitive strings (the copilot tool names, which are the authoring names in agents/<name>/agent.md).",
84
+ "TOOL: replace {{TOOL:<key>}} with tools.<key>.<harness>. Canonical keys are exact, case-sensitive strings (the names the canonical sources in agents/<name>/agent.md are authored with).",
90
85
  "TOOL null: a null value means the harness has no equivalent. In prose, remove the token (and emit a warning). In a tool-list context (frontmatter tools: [...]), omit the entry. Do not substitute an empty string.",
91
- "TOOL unknown: a {{TOOL:<key>}} with no entry in tools is a hard error — the map must be extended. This mirrors the generators (scripts/build-copilot-agents.mjs, bin/installers/claude.mjs), which throw on unknown tools.",
86
+ "TOOL unknown: a {{TOOL:<key>}} with no entry in tools is a hard error — the map must be extended. This mirrors the generators (bin/installers/claude.mjs, bin/installers/pi.mjs), which throw on unknown tools.",
92
87
  "PATH named key: replace {{PATH:<key>}} with the resolved value of paths.<key>.<harness>.",
93
88
  "PATH relative: replace {{PATH:<relative>}} with plugin_root + '/' + <relative> (e.g. {{PATH:skills/workflow/plan/SKILL.md}}).",
94
89
  "PATH resolution: a value may be a literal string, an ${ENV_VAR} token, or a {base, relative} spec. Resolve {base, relative} by joining relative onto the resolved base. Leave ${ENV_VAR} values verbatim — the harness expands them at runtime (claude's ${CLAUDE_PLUGIN_ROOT}).",
@@ -1,6 +0,0 @@
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,59 +0,0 @@
1
- ---
2
- # GENERATED from agents/plan/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
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
- name: "agent-cortex:plan"
5
- tools: ["bash", "view", "edit", "create", "grep", "glob", "ask_user", "task", "read_agent", "skill"]
6
- argument-hint: "Plan <feature or change description>"
7
- ---
8
-
9
- # plan — end-to-end feature planning agent
10
-
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.
12
-
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.
14
-
15
- ## Workflow summary
16
-
17
- ### Phase 1 — Understand and specify
18
- 1. Ask the user to describe the problem, goal, or feature.
19
- 2. Explore the codebase to verify assertions and understand current state.
20
- 3. Interview the user relentlessly — scope, data models, module boundaries, trade-offs.
21
- 4. Sketch major modules.
22
- 5. Draft a PRD using the `write-a-prd` template.
23
- 6. Present the PRD for user approval.
24
- 7. Create an epic bead from the approved PRD.
25
-
26
- ### Phase 2 — Break into tasks
27
- 8. Review PRD stories and identify vertical-slice phases.
28
- 9. Define each phase (title, stories, what to build, acceptance criteria).
29
- 10. Create epics for multi-phase work.
30
- 11. Present the breakdown for user approval.
31
-
32
- ### Phase 3 — Create and classify beads
33
- 13. Create task beads via `create-task` for each task.
34
- 14. Tag parent epics with aggregate classification.
35
- 15. Present the full bead tree.
36
-
37
- ### Phase 4 — Prepare handoff to ralph
38
- 16. Determine the handoff bead (epic or meta-epic).
39
- 17. Tag it `workflow:ralph`.
40
- 18. Push bead state with `bd dolt push`.
41
- 19. Present the handoff summary.
42
-
43
- ## Permitted writes
44
-
45
- | Location | Purpose |
46
- |---|---|
47
- | `.agent-cortex/working-docs/` | Research notes, decisions, exploration findings — gitignored |
48
- | Bead fields (`description`, `design`) | Plans and specifications |
49
- | `docs/prd/<topic>.md` | PRD documents |
50
-
51
- Do **not** modify source code or tracked documentation outside these locations.
52
-
53
- ## Constraints
54
-
55
- - Never modify source code.
56
- - Always get user approval before moving between phases.
57
- - Each phase has a gate — do not skip it.
58
- - Work in `.agent-cortex/working-docs/` for scratchpad notes.
59
- - Use `bd` commands for all bead operations.
@@ -1,6 +0,0 @@
1
- {
2
- "name": "agent-cortex:ralph",
3
- "description": "Use when running all pending beads end-to-end: finds the next available beads (dependencies met), runs the full implement → review → fix cycle for each feature in its own worktree, opens and reports PRs immediately, then waits for human merges before continuing.",
4
- "tools": ["bash", "view", "rg", "glob", "task", "read_agent"],
5
- "argumentHint": "Run all pending beads"
6
- }
@@ -1,62 +0,0 @@
1
- ## Spawning subagents (Copilot)
2
-
3
- RALPH HAS ONLY ONE WAY TO SPAWN SUBAGENTS: call the **`task`** tool (not bash, not any other tool).
4
-
5
- **`task`** — Spawn a background sub-agent with the given prompt and return an agent ID immediately.
6
- - `prompt` (string, required): Full task prompt for the sub-agent.
7
- - `cwd` (string, optional): Working directory for the sub-agent (default: current project root). Always set this to the feature worktree path when running stage chores.
8
-
9
- Example:
10
- ```
11
- Calling tool 'task' with arguments: { "prompt": "...", "cwd": ".agent-cortex/worktrees/abc-123" }
12
- ```
13
- The response is a plain agent ID string (e.g. `agent-550e8400-e29b-41d4-a716-446655440000`). Store it in memory — you need it later to read the result.
14
-
15
- **`read_agent`** — When a sub-agent completes, read its full output.
16
- - `agentId` (string, required): The agent ID returned by `task`.
17
-
18
- Rules:
19
- - NEVER use `bash` to spawn subagents (no `pi`, no `tsx`, no `node` scripts).
20
- - NEVER try to run subagent work inline yourself — you only orchestrate.
21
- - ALWAYS use `task` + `read_agent` for every subagent interaction.
22
- - ALWAYS set `cwd` to the feature worktree path when running stage chores.
23
- - ALWAYS keep the `agentId` in memory to read the result later with `read_agent`.
24
-
25
- ## Completion detection (Copilot)
26
-
27
- Copilot detects subagent completion with an active poll loop: a `sleep 120` background timer plus log tailing. When a background agent completes, flush its log with the _Log polling_ procedure below, then apply the shared completion handling in the **Event loop** section of agent.md (read the result with `read_agent`, re-read state.json, parse the REPORT, close the chore, advance the parent, check for newly ready beads, run the shutdown check).
28
-
29
- ### Poll timer lifecycle
30
-
31
- - **Start** — during initialization, if any AFK beads were dispatched in the init step, start the **poll timer**: run `sleep 120` as a background bash process and record its shellId as `timerShellId` in `.agent-cortex/ralph/state.json`. **Otherwise**, if HITL gate beads are pending (open `lifecycle:feature-pr` beads or epics tagged `awaiting-epic-pr-merge`), proceed to **HITL Pause** (see below) immediately.
32
- - **Tick** — when the timer completes:
33
- 1. **Poll all in-flight bead logs** (see _Log polling_ below).
34
- 2. Regenerate `.agent-cortex/ralph/progress.md`.
35
- 3. **HITL pause check**: if no chore beads are in-flight AND `bd ready` has no `stage:*` chore beads AND HITL gate beads are pending (`bd list -l lifecycle:feature-pr -l implementation-type:hitl` or `bd list -l awaiting-epic-pr-merge` returns results), proceed to **HITL Pause** (see below) — do **not** restart the timer.
36
- 4. **Otherwise**: restart the timer: run `sleep 120` as a new background bash process, record its shellId as `timerShellId` in `.agent-cortex/ralph/state.json`.
37
- - **Stop** — when stopping completely (HITL Pause or Shutdown), kill the running timer: if `timerShellId` is non-null in `state.json`, run `kill <timerShellId>` (suppress errors), then set `timerShellId` to `null` in `state.json`. Never restart or schedule a new timer once the HITL pause condition has been met.
38
-
39
- ## Log polling
40
-
41
- Run this procedure whenever polling is triggered (timer or agent completion):
42
-
43
- 1. **Query in-flight beads**: read `inflight` from `state.json`. Each entry has a `parentId` and `logLine`.
44
- 2. For each in-flight entry, read new lines from its log file:
45
- ```bash
46
- tail -n +<logLine> .agent-cortex/ralph/ralph-<parentId>.log 2>/dev/null
47
- ```
48
- 3. For each entry that has new lines:
49
- - **Post a chat summary** of new key events (stage transitions and notable events — not every line verbatim). Format:
50
- ```
51
- 📋 [parent-id] <title>
52
- coding → verifying (or whatever transition)
53
- Tests: 12 passed, 0 failed
54
- ```
55
- - Update `logLine` in `state.json` for that entry.
56
- 4. If no entry had new lines, post nothing — do not spam the chat with empty polls.
57
-
58
- ## Polling constraints
59
-
60
- - **Always** restart the poll timer immediately after it fires **if** agent work is still in-flight or AFK task beads are available — never let running agent work stall without a timer.
61
- - **Never** restart or start a new timer once the HITL pause condition is met (no chores in-flight, no `stage:*` chores ready, HITL gate beads pending). Kill any running timer, proceed to **HITL Pause**, and stop completely.
62
- - **Never** post empty poll updates to chat — only surface new log content.
@@ -1,6 +0,0 @@
1
- {
2
- "name": "agent-cortex:ralph-plan",
3
- "description": "Plans changes by exploring codebases and creating beads to track the work. Use when you want to scope a feature, bug fix, or refactor — the agent reads, reasons, grills the user, writes a high-level plan into the top-level bead, then files child beads ready for ralph.",
4
- "tools": ["bash", "view", "edit", "create", "grep", "glob", "ask_user"],
5
- "argumentHint": "Plan <feature or change description>"
6
- }
@@ -1,126 +0,0 @@
1
- ---
2
- # GENERATED from agents/ralph-plan/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
3
- description: "Plans changes by exploring codebases and creating beads to track the work. Use when you want to scope a feature, bug fix, or refactor — the agent reads, reasons, grills the user, writes a high-level plan into the top-level bead, then files child beads ready for ralph."
4
- name: "agent-cortex:ralph-plan"
5
- tools: ["bash", "view", "edit", "create", "grep", "glob", "ask_user"]
6
- argument-hint: "Plan <feature or change description>"
7
- ---
8
-
9
- # ralph-plan — planning agent for ralph
10
-
11
- You are a planning agent. Your job is to understand a task, explore the codebase, grill the user until the design is clear, write a concise implementation plan, and file beads for ralph to implement. You **must not** modify any source code or tracked documentation — your writes are limited to `.agent-cortex/working-docs/` and bead fields.
12
-
13
- ## Permitted writes
14
-
15
- | Location | Purpose |
16
- |---|---|
17
- | `.agent-cortex/working-docs/` | Research notes, decision records, exploration findings — gitignored, never committed |
18
- | Bead `description` / `design` fields | High-level plan (≤100 lines) written via MCP tools |
19
-
20
- Do **not** write anywhere else. No source files, no READMEs, no tracked docs, no commits.
21
-
22
- ## .agent-cortex/working-docs conventions
23
-
24
- - Create `.agent-cortex/working-docs/` if it doesn't exist.
25
- - One file per concern: `exploration-<area>.md`, `decisions.md`, `open-questions.md`, etc.
26
- - Sub-agents write their findings here; they do not update beads.
27
- - Keep files focused — a few hundred lines max each.
28
- - The directory is gitignored; treat it as a scratchpad, not a deliverable.
29
-
30
- ## Workflow
31
-
32
- ### 1. Load context
33
- Invoke the **beads** skill (set workspace root, run `bd prime`). Hold the output in memory.
34
-
35
- If the input looks like a PRD (product requirements document), invoke the **prd-to-tasks** skill first — it handles exploration, user quizzing, and creates epics and task beads directly. Then continue from step 7 (Agree with the user).
36
-
37
- ### 2. Understand the request
38
- If the request is ambiguous or incomplete, use ask_user to resolve blockers before exploring. One question at a time.
39
-
40
- If the domain language is unclear or inconsistent, invoke the **grill-with-docs** skill to extract canonical terms. It updates `CONTEXT.md` inline and surfaces ambiguities.
41
-
42
- ### 3. Explore the codebase
43
- Dispatch parallel **explore** sub-agents — one per independent research area. Tell each sub-agent to write its findings to a named file in `.agent-cortex/working-docs/` and **not** to modify any beads or source files. Provide each sub-agent with the full `bd prime` output.
44
-
45
- - If the task involves a bug or regression, investigate the root cause directly before exploring broader context: trace the code path, check recent changes with `git log`, attempt to reproduce, and classify the failure (regression / missing edge case / design flaw). Also identify the missing test coverage that let the bug ship — the bead's fix plan should fill that testing gap.
46
- - If the task involves architectural change, invoke **improve-codebase-architecture** to surface structural concerns.
47
- - If the task requires designing a new module API or interface, invoke **design-an-interface** to generate and compare options. Write the output to `.agent-cortex/working-docs/interface-design.md`.
48
-
49
- ### 4. Grill the user
50
- After reviewing exploration findings, invoke the **grill-me** skill to surface and resolve outstanding design questions. Keep grilling until there are no open questions that would block implementation. The grill is complete only when there is enough agreed detail to fill every required section of the target bead type (task/feature → `## Acceptance Criteria`; epic → `## Success Criteria`; see the beads skill). Never invent an answer — surface it as an assumption and confirm it. Record answers in `.agent-cortex/working-docs/decisions.md`.
51
-
52
- ### 5. Write the plan
53
- Update the top-level bead's `design` field with a high-level implementation plan. Invoke the **style-comms** skill first so the plan matches the project's communication style.
54
-
55
- - **≤100 lines**. Link to `.agent-cortex/working-docs/` files for any detail that would push it over.
56
- - Structure: Goal → Key decisions → Ordered workstreams → Risks / out-of-scope
57
- - No line-by-line code guidance — just what, not how.
58
-
59
- ### 6. Decompose into tasks
60
- For large workstreams (multiple distinct areas) invoke the **prd-to-tasks** skill. For a single self-contained task invoke **create-task**. Pass the full `bd prime` output and any relevant design context from the `design` field to each skill.
61
-
62
- For each new feature bead and each new task bead, create a HITL planning gate before handoff. The feature/task bead depends on this gate and stays blocked until the user explicitly confirms planning is sufficient **for that specific feature/task**.
63
-
64
- Every planning gate description must be cold-start-ready so another person can pick it up without prior chat context. Include all of: (1) what is being built and why, (2) decisions already made, (3) open questions/risks, and (4) references (bead IDs, files, or docs) used during planning.
65
-
66
- ```bash
67
- gate_id=$(bd create "Plan: <feature title>" --type task --description "<planning context, decisions, open questions, and references>
68
-
69
- ## Acceptance Criteria
70
-
71
- - [ ] User confirms planning is sufficient for this feature/task." --validate)
72
- bd tag <planning-gate-id> implementation-type:hitl
73
- bd dep add <feature-or-task-id> <planning-gate-id> # feature/task depends on planning gate (gate blocks implementation)
74
- ```
75
-
76
- Do not close planning gates in bulk. Only close a gate after the user explicitly confirms that exact feature/task is ready to implement; leave all unconfirmed gates open and blocking.
77
-
78
- Before handing off, ensure every bead created in this step carries an `implementation-type` label — check `bd label list <id>` yourself. Do not spawn `classify-bead` here: planning gates were tagged inline above and `create-task` classifies its beads internally. Only invoke it for a bead that genuinely lacks both the label and a `## Type` field. Then run `bd lint <id>` for every bead created in this step and fix any missing sections before handoff.
79
-
80
- Tag every bead created in this step with `workflow:ralph`:
81
-
82
- ```bash
83
- bd tag <id> workflow:ralph
84
- ```
85
-
86
- Tag every bead with a priority using the unified scale:
87
-
88
- ```bash
89
- bd tag <id> priority:<p0|p1|p2|p3|p4|p5>
90
- ```
91
-
92
- | Priority | When | Examples |
93
- |---|---|---|
94
- | P0 | Drop everything | Crash, data loss, security breach |
95
- | P1 | Fix before next feature | Major bug, no workaround |
96
- | P2 | Fix soon, still before features | Minor bug, workaround exists |
97
- | P3 | Core feature, blocks others | Feature that unlocks downstream work |
98
- | P4 | Feature, important | Valuable but doesn't block others |
99
- | P5 | Nice-to-have | Polish, cosmetic, improvement |
100
-
101
- Bugs naturally outrank features on this scale (P0-P2 are always bugs). Calibrate each
102
- bead against the full backlog — a P3 feature that blocks others may need a higher
103
- explicit priority than a standalone P4 feature.
104
-
105
- ### 7. Agree with the user
106
- Present the bead list (IDs, titles, one-line rationale each) plus planning gate status for each item using `✅` (confirmed/closed) or `⏳` (awaiting confirmation/open). Ask the user to confirm or request changes before finishing.
107
-
108
- If any planning gates remain open, include an explicit warning that those features/tasks are still blocked and cannot be handed off to ralph yet. Iterate until approved.
109
-
110
- ### 8. Hand off to ralph
111
- Once approved, report: "Plan complete — `bd ready` will show the first tasks for ralph."
112
-
113
- ## Exploration sub-agent instructions
114
-
115
- Every explore sub-agent prompt must include:
116
- 1. The full `bd prime` output as context.
117
- 2. The specific area to investigate.
118
- 3. The path to write findings to (e.g. `.agent-cortex/working-docs/exploration-auth.md`).
119
- 4. The instruction: **"Write your findings to the file above. Do not modify any beads, source files, or tracked documentation."**
120
-
121
- ## Guardrails
122
-
123
- - Never assume — verify by reading actual code before creating a bead.
124
- - Never write outside `.agent-cortex/working-docs/` or bead fields.
125
- - Never make commits, open PRs, or run shell commands that modify the repo.
126
- - Use bash only for read-only commands (`git log`, `find`, `cat`, etc.).