@jaybeeuu/agent-cortex 1.37.1 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/style-versioning/SKILL.md +9 -8
- package/.github/workflows/ci.yml +190 -8
- package/AGENTS.md +27 -6
- package/CHANGELOG.md +72 -0
- package/README.md +156 -39
- package/agents/README.md +49 -13
- package/agents/plan/agent.md +51 -0
- package/agents/plan/claude/frontmatter.json +6 -0
- package/agents/plan/copilot/frontmatter.json +6 -0
- package/agents/plan/pi/frontmatter.json +6 -0
- package/agents/plan.agent.md +3 -0
- package/agents/ralph/agent.md +262 -0
- package/agents/ralph/claude/frontmatter.json +6 -0
- package/agents/ralph/claude/polling.md +31 -0
- package/agents/ralph/copilot/frontmatter.json +6 -0
- package/agents/ralph/copilot/polling.md +62 -0
- package/agents/ralph/pi/frontmatter.json +6 -0
- package/agents/ralph/pi/polling.md +74 -0
- package/agents/ralph-plan/agent.md +114 -0
- package/agents/ralph-plan/claude/frontmatter.json +6 -0
- package/agents/ralph-plan/copilot/frontmatter.json +6 -0
- package/agents/ralph-plan/pi/frontmatter.json +6 -0
- package/agents/ralph-plan.agent.md +6 -3
- package/agents/ralph.agent.md +83 -57
- package/agents/strategy/agent.md +104 -0
- package/agents/strategy/claude/frontmatter.json +6 -0
- package/agents/strategy/copilot/frontmatter.json +6 -0
- package/agents/strategy/pi/frontmatter.json +6 -0
- package/agents/strategy.agent.md +3 -0
- package/bin/agent-cortex.mjs +76 -1
- package/bin/installers/claude.mjs +376 -0
- package/bin/installers/copilot.mjs +129 -0
- package/bin/installers/pi.mjs +197 -0
- package/claude/.claude-plugin/plugin.json +1 -1
- package/claude/agents/plan.md +3 -1
- package/claude/agents/ralph-plan.md +6 -4
- package/claude/agents/strategy.md +3 -1
- package/claude/hooks/scripts/notify.mjs +54 -0
- package/claude/hooks.json +15 -0
- package/docs/claude-hooks.md +115 -0
- package/docs/ideas/auto-model-selection.md +75 -0
- package/docs/ideas/extension-manifests.md +75 -0
- package/docs/ideas/improve-pi-system-prompt.md +34 -0
- package/docs/ideas/model-selector.md +40 -0
- package/docs/ideas/pi-task-memory.md +34 -0
- package/docs/ideas/qa-extension.md +43 -0
- package/docs/ideas/record-ideas-as-beads.md +115 -0
- package/docs/ideas/subagent-visibility.md +72 -0
- package/docs/ideas/task-session-context.md +89 -0
- package/docs/ideas/unified-ci-pipeline.md +28 -0
- package/docs/research/skill-design-research.md +4 -4
- package/docs/research/skill-improvements-analysis.md +1 -1
- package/docs/skills/skill-anatomy.md +47 -2
- package/docs/technical-direction/migration-execution-labels.md +132 -0
- package/extensions/agent-modes/README.md +54 -0
- package/extensions/agent-modes/discover.test.ts +241 -0
- package/extensions/agent-modes/discover.ts +458 -0
- package/extensions/agent-modes/index.ts +13 -224
- package/extensions/agent-modes/node_modules/.bin/pi +21 -0
- package/extensions/agent-modes/node_modules/.bin/tsc +21 -0
- package/extensions/agent-modes/node_modules/.bin/tsserver +21 -0
- package/extensions/agent-modes/node_modules/.bin/tsx +21 -0
- package/extensions/agent-modes/package.json +20 -0
- package/extensions/agent-modes/tsconfig.json +12 -0
- package/extensions/subagent/README.md +19 -0
- package/extensions/subagent/index.ts +131 -45
- package/extensions/subagent/node_modules/.bin/pi +21 -0
- package/extensions/subagent/node_modules/.bin/pi-ai +21 -0
- package/extensions/subagent/node_modules/.bin/tsc +21 -0
- package/extensions/subagent/node_modules/.bin/tsserver +21 -0
- package/extensions/subagent/node_modules/.bin/tsx +21 -0
- package/extensions/subagent/package.json +23 -0
- package/extensions/subagent/tsconfig.json +12 -0
- package/extensions/subagent/wait.test.ts +202 -0
- package/extensions/subagent/wait.ts +118 -0
- package/hooks/claude/hooks.json +38 -0
- package/hooks/claude/scripts/notify.mjs +54 -0
- package/lib/cli.mjs +68 -3
- package/package.json +6 -4
- package/plugin.json +1 -1
- package/pnpm-workspace.yaml +1 -1
- package/scripts/build-copilot-agents.mjs +30 -0
- package/scripts/lib/compose-agent.mjs +241 -0
- package/skills/engineering/design-an-interface/SKILL.md +78 -58
- package/skills/engineering/grill-with-docs/REFERENCE.md +78 -0
- package/skills/engineering/grill-with-docs/SKILL.md +66 -63
- package/skills/engineering/improve-codebase-architecture/SKILL.md +66 -48
- package/skills/engineering/technical-direction/FORMAT.md +38 -0
- package/skills/engineering/technical-direction/SKILL.md +70 -77
- package/skills/planning/classify-bead/SKILL.md +59 -35
- package/skills/planning/create-task/REFERENCE.md +40 -0
- package/skills/planning/create-task/SKILL.md +70 -66
- package/skills/planning/create-task/scripts/create-chores.ts +6 -1
- package/skills/planning/create-task/scripts/node_modules/.bin/tsc +21 -0
- package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +21 -0
- package/skills/planning/create-task/scripts/node_modules/.bin/tsx +21 -0
- package/skills/planning/prd-to-tasks/REFERENCE.md +66 -0
- package/skills/planning/prd-to-tasks/SKILL.md +86 -170
- package/skills/planning/record-idea/FORMAT.md +44 -0
- package/skills/planning/record-idea/SKILL.md +70 -53
- package/skills/planning/request-refactor-plan/FORMAT.md +45 -0
- package/skills/planning/request-refactor-plan/SKILL.md +57 -46
- package/skills/planning/write-a-prd/FORMAT.md +54 -0
- package/skills/planning/write-a-prd/SKILL.md +49 -48
- package/skills/planning/write-a-ticket/SKILL.md +68 -53
- package/skills/productivity/handoff/SKILL.md +12 -0
- package/skills/productivity/init-beads/SKILL.md +48 -40
- package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +21 -0
- package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +21 -0
- package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +21 -0
- package/skills/productivity/write-a-skill/SKILL.md +2 -1
- package/skills/review/maintain-agent-docs/SKILL.md +71 -51
- package/skills/workflow/hitl-collab/SKILL.md +86 -17
- package/skills/workflow/ralph/REFERENCE.md +24 -19
- package/skills/workflow/ralph/SKILL.md +88 -74
- package/skills/workflow/run-pipeline-stage/REFERENCE.md +22 -0
- package/skills/workflow/run-pipeline-stage/SKILL.md +91 -93
- package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +6 -107
- package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +4 -2
- package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +21 -0
- package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +21 -0
- package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +21 -0
- package/skills/workflow/using-agent-skills/SKILL.md +122 -0
- package/test/claude-installer.test.mjs +248 -0
- package/test/cli.test.mjs +115 -2
- package/test/copilot-installer.test.mjs +298 -0
- package/test/installer.test.mjs +179 -0
- package/test/notify-hook.test.mjs +63 -0
- package/test/pi-installer.test.mjs +371 -0
- package/token-map.README.md +130 -0
- package/token-map.json +106 -0
- package/.github/workflows/ci.test.ts +0 -217
- package/.github/workflows/release.yml +0 -58
- package/scripts/build-claude-agents.mjs +0 -179
- package/scripts/publish-release.sh +0 -32
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
+
# GENERATED from agents/ralph-plan/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
|
|
2
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."
|
|
3
4
|
name: "agent-cortex:ralph-plan"
|
|
4
5
|
tools: ["bash", "view", "edit", "create", "grep", "glob", "ask_user"]
|
|
5
6
|
argument-hint: "Plan <feature or change description>"
|
|
6
7
|
---
|
|
7
8
|
|
|
9
|
+
# ralph-plan — planning agent for ralph
|
|
10
|
+
|
|
8
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.
|
|
9
12
|
|
|
10
13
|
## Permitted writes
|
|
@@ -32,7 +35,7 @@ Invoke the **beads** skill (set workspace root, run `bd prime`). Hold the output
|
|
|
32
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).
|
|
33
36
|
|
|
34
37
|
### 2. Understand the request
|
|
35
|
-
If the request is ambiguous or incomplete, use
|
|
38
|
+
If the request is ambiguous or incomplete, use ask_user to resolve blockers before exploring. One question at a time.
|
|
36
39
|
|
|
37
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.
|
|
38
41
|
|
|
@@ -68,7 +71,7 @@ bd dep add <feature-or-task-id> <planning-gate-id> # feature/task depends on p
|
|
|
68
71
|
|
|
69
72
|
Do not close planning gates in bulk. Only close a gate after the user explicitly confirms that exact feature/task is ready to implement; leave all unconfirmed gates open and blocking.
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
Before handing off, ensure every bead created in this step carries an `implementation-type` label — check `bd label list <id>` yourself. Do not spawn `classify-bead` here: planning gates were tagged inline above and `create-task` classifies its beads internally. Only invoke it for a bead that genuinely lacks both the label and a `## Type` field.
|
|
72
75
|
|
|
73
76
|
Tag every bead created in this step with `workflow:ralph`:
|
|
74
77
|
|
|
@@ -116,4 +119,4 @@ Every explore sub-agent prompt must include:
|
|
|
116
119
|
- Never assume — verify by reading actual code before creating a bead.
|
|
117
120
|
- Never write outside `.agent-cortex/working-docs/` or bead fields.
|
|
118
121
|
- Never make commits, open PRs, or run shell commands that modify the repo.
|
|
119
|
-
- Use
|
|
122
|
+
- Use bash only for read-only commands (`git log`, `find`, `cat`, etc.).
|
package/agents/ralph.agent.md
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
---
|
|
2
|
+
# GENERATED from agents/ralph/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
|
|
2
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."
|
|
3
4
|
name: "agent-cortex:ralph"
|
|
4
5
|
tools: ["bash", "view", "rg", "glob", "task", "read_agent"]
|
|
5
6
|
argument-hint: "Run all pending beads"
|
|
6
7
|
---
|
|
7
8
|
|
|
9
|
+
# ralph — parallel task orchestration agent
|
|
10
|
+
|
|
8
11
|
You are a parallel task orchestration agent. You run multiple beads concurrently, advancing each one through its pipeline as subagents report back. You never write code or documentation yourself — you only orchestrate, prompt subagents, manage branch/worktree lifecycle, and manage bead state via `bd` commands.
|
|
9
12
|
|
|
10
13
|
## Spawning subagents (critical — read this first)
|
|
11
14
|
|
|
12
|
-
RALPH HAS ONLY ONE WAY TO SPAWN SUBAGENTS:
|
|
13
|
-
|
|
14
|
-
**`task`** — Spawn a background sub-agent with the given prompt and return an agent ID immediately.
|
|
15
|
-
- `prompt` (string, required): Full task prompt for the sub-agent.
|
|
16
|
-
- `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.
|
|
17
|
-
|
|
18
|
-
Example:
|
|
19
|
-
```
|
|
20
|
-
Calling tool 'task' with arguments: { "prompt": "...", "cwd": ".agent-cortex/worktrees/abc-123" }
|
|
21
|
-
```
|
|
22
|
-
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.
|
|
15
|
+
RALPH HAS ONLY ONE WAY TO SPAWN SUBAGENTS: the harness-specific spawning and completion-detection mechanism documented in this file's polling section. Read that section before doing anything else — it lists the exact tool calls for your harness and the id-handling rules that keep completion tracking working.
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
- `agentId` (string, required): The agent ID returned by `task`.
|
|
17
|
+
Harness-agnostic rules (tool names and completion detection differ per harness — see the polling section):
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
- NEVER use `bash` to spawn subagents (no `pi`, no `tsx`, no `node` scripts).
|
|
19
|
+
- NEVER spawn subagents from `bash` (no `pi`, no `tsx`, no `node` scripts).
|
|
29
20
|
- NEVER try to run subagent work inline yourself — you only orchestrate.
|
|
30
|
-
- ALWAYS use
|
|
31
|
-
- ALWAYS set
|
|
32
|
-
- ALWAYS keep the
|
|
21
|
+
- ALWAYS use the documented spawning mechanism for every subagent interaction.
|
|
22
|
+
- ALWAYS set the subagent's working directory to the feature worktree path when running stage chores.
|
|
23
|
+
- ALWAYS keep the returned agent/task id in memory so you can read the result later.
|
|
33
24
|
|
|
34
25
|
Each pipeline stage is a separate **chore bead** created on-demand as the previous stage completes. Stage tags (`stage:*`) live on chore beads, not on the parent feature bead. Loop counts are derived by querying chore children of the parent, not stored in state. Orchestration state is derived entirely from beads — the only local state is `state.json` (timer shellId + agent-ID-to-bead mapping) and per-parent log files.
|
|
35
26
|
|
|
36
|
-
Branching model
|
|
27
|
+
## Branching model
|
|
28
|
+
|
|
37
29
|
- **Single-feature epics** (epic has exactly one feature task child): skip the epic branch entirely. The feature branch (`feature/<parent-id>`) is based directly from `origin/main`. The HITL PR targets `main` directly. No epic PR is required.
|
|
38
30
|
- **Multi-feature epics** (epic has two or more feature task children): each epic runs on `epic/<epic-id>` (base: `origin/main`, never local `main`). Each feature branch is based from its epic branch. Completed features PR into `epic/<epic-id>`; the completed epic PRs into `main`.
|
|
39
31
|
- Each parent feature task runs on `feature/<parent-id>` in `.agent-cortex/worktrees/<parent-id>`.
|
|
@@ -75,7 +67,7 @@ Run once at startup:
|
|
|
75
67
|
b. Claim the parent bead: `bd update <parent-id> --claim`.
|
|
76
68
|
c. Create the first stage chore bead and dispatch it (see _Creating and dispatching a stage chore_ below).
|
|
77
69
|
8. Record each launched agent in `.agent-cortex/ralph/state.json` (see format below).
|
|
78
|
-
9.
|
|
70
|
+
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.
|
|
79
71
|
|
|
80
72
|
---
|
|
81
73
|
|
|
@@ -92,7 +84,7 @@ bd dep add $chore_id <parent-id> --type parent-child
|
|
|
92
84
|
bd update $chore_id --claim
|
|
93
85
|
```
|
|
94
86
|
|
|
95
|
-
Then load the universal stage runner prompt from `skills/workflow/run-pipeline-stage/prompts/stage-runner.md`, fill in all placeholders (including `<stage>` from the bead label, parent task description from `bd show <parent-id>`, prior SUMMARY/FILES_CHANGED from the last REPORT, chore bead ID, log path `.agent-cortex/ralph/ralph-<parent-id>.log`), and spawn a subagent in **background** mode using the
|
|
87
|
+
Then load the universal stage runner prompt from `skills/workflow/run-pipeline-stage/prompts/stage-runner.md`, fill in all placeholders (including `<stage>` from the bead label, parent task description from `bd show <parent-id>`, prior SUMMARY/FILES_CHANGED from the last REPORT, chore bead ID, log path `.agent-cortex/ralph/ralph-<parent-id>.log`), and spawn a subagent in **background** mode using the spawning mechanism described in the polling section, running from the feature worktree. Stage-specific policy comes from `skills/workflow/run-pipeline-stage/playbooks/<stage>.md`.
|
|
96
88
|
|
|
97
89
|
Add the entry to `inflight` in `state.json`:
|
|
98
90
|
```json
|
|
@@ -125,7 +117,7 @@ All orchestration state is derived from beads:
|
|
|
125
117
|
}
|
|
126
118
|
```
|
|
127
119
|
|
|
128
|
-
- **timerShellId**: the shellId of the active
|
|
120
|
+
- **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).
|
|
129
121
|
- **inflight[].choreId**: the chore bead currently being worked by the subagent.
|
|
130
122
|
- **inflight[].parentId**: the parent feature task bead. Log file is `.agent-cortex/ralph/ralph-<parentId>.log`.
|
|
131
123
|
- **inflight[].logLine**: the next line number to read from the parent's log file (1-based; start at 1). Updated after every poll.
|
|
@@ -137,21 +129,79 @@ Update `.agent-cortex/ralph/state.json` after **every** agent completion or disp
|
|
|
137
129
|
|
|
138
130
|
---
|
|
139
131
|
|
|
140
|
-
##
|
|
132
|
+
## Spawning subagents (Copilot)
|
|
133
|
+
|
|
134
|
+
RALPH HAS ONLY ONE WAY TO SPAWN SUBAGENTS: call the **`task`** tool (not bash, not any other tool).
|
|
135
|
+
|
|
136
|
+
**`task`** — Spawn a background sub-agent with the given prompt and return an agent ID immediately.
|
|
137
|
+
- `prompt` (string, required): Full task prompt for the sub-agent.
|
|
138
|
+
- `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.
|
|
139
|
+
|
|
140
|
+
Example:
|
|
141
|
+
```
|
|
142
|
+
Calling tool 'task' with arguments: { "prompt": "...", "cwd": ".agent-cortex/worktrees/abc-123" }
|
|
143
|
+
```
|
|
144
|
+
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.
|
|
145
|
+
|
|
146
|
+
**`read_agent`** — When a sub-agent completes, read its full output.
|
|
147
|
+
- `agentId` (string, required): The agent ID returned by `task`.
|
|
148
|
+
|
|
149
|
+
Rules:
|
|
150
|
+
- NEVER use `bash` to spawn subagents (no `pi`, no `tsx`, no `node` scripts).
|
|
151
|
+
- NEVER try to run subagent work inline yourself — you only orchestrate.
|
|
152
|
+
- ALWAYS use `task` + `read_agent` for every subagent interaction.
|
|
153
|
+
- ALWAYS set `cwd` to the feature worktree path when running stage chores.
|
|
154
|
+
- ALWAYS keep the `agentId` in memory to read the result later with `read_agent`.
|
|
155
|
+
|
|
156
|
+
## Completion detection (Copilot)
|
|
141
157
|
|
|
142
|
-
|
|
158
|
+
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).
|
|
143
159
|
|
|
144
|
-
###
|
|
160
|
+
### Poll timer lifecycle
|
|
145
161
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
- **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.
|
|
163
|
+
- **Tick** — when the timer completes:
|
|
164
|
+
1. **Poll all in-flight bead logs** (see _Log polling_ below).
|
|
165
|
+
2. Regenerate `.agent-cortex/ralph/progress.md`.
|
|
166
|
+
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.
|
|
167
|
+
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`.
|
|
168
|
+
- **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.
|
|
169
|
+
|
|
170
|
+
## Log polling
|
|
171
|
+
|
|
172
|
+
Run this procedure whenever polling is triggered (timer or agent completion):
|
|
173
|
+
|
|
174
|
+
1. **Query in-flight beads**: read `inflight` from `state.json`. Each entry has a `parentId` and `logLine`.
|
|
175
|
+
2. For each in-flight entry, read new lines from its log file:
|
|
176
|
+
```bash
|
|
177
|
+
tail -n +<logLine> .agent-cortex/ralph/ralph-<parentId>.log 2>/dev/null
|
|
178
|
+
```
|
|
179
|
+
3. For each entry that has new lines:
|
|
180
|
+
- **Post a chat summary** of new key events (stage transitions and notable events — not every line verbatim). Format:
|
|
181
|
+
```
|
|
182
|
+
📋 [parent-id] <title>
|
|
183
|
+
coding → verifying (or whatever transition)
|
|
184
|
+
Tests: 12 passed, 0 failed
|
|
185
|
+
```
|
|
186
|
+
- Update `logLine` in `state.json` for that entry.
|
|
187
|
+
4. If no entry had new lines, post nothing — do not spam the chat with empty polls.
|
|
188
|
+
|
|
189
|
+
## Polling constraints
|
|
190
|
+
|
|
191
|
+
- **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.
|
|
192
|
+
- **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.
|
|
193
|
+
- **Never** post empty poll updates to chat — only surface new log content.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Event loop
|
|
198
|
+
|
|
199
|
+
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:
|
|
150
200
|
|
|
151
201
|
### If a background agent completed
|
|
152
202
|
|
|
153
|
-
1. **
|
|
154
|
-
2. **Read** the completed agent's full output with `read_agent
|
|
203
|
+
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).
|
|
204
|
+
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).
|
|
155
205
|
3. **Re-read** `.agent-cortex/ralph/state.json` to identify the chore bead and parent for that agent ID.
|
|
156
206
|
4. **Parse** the agent's `---REPORT---` block (see report format in the `run-pipeline-stage` skill).
|
|
157
207
|
5. **Close** the completed chore bead: `bd close <chore-id>`.
|
|
@@ -184,27 +234,6 @@ Block command: `bd update <parent-id> --status blocked --notes "<cap> cap reache
|
|
|
184
234
|
|
|
185
235
|
---
|
|
186
236
|
|
|
187
|
-
## Log polling
|
|
188
|
-
|
|
189
|
-
Run this procedure whenever polling is triggered (timer or agent completion):
|
|
190
|
-
|
|
191
|
-
1. **Query in-flight beads**: read `inflight` from `state.json`. Each entry has a `parentId` and `logLine`.
|
|
192
|
-
2. For each in-flight entry, read new lines from its log file:
|
|
193
|
-
```bash
|
|
194
|
-
tail -n +<logLine> .agent-cortex/ralph/ralph-<parentId>.log 2>/dev/null
|
|
195
|
-
```
|
|
196
|
-
3. For each entry that has new lines:
|
|
197
|
-
- **Post a chat summary** of new key events (stage transitions and notable events — not every line verbatim). Format:
|
|
198
|
-
```
|
|
199
|
-
📋 [parent-id] <title>
|
|
200
|
-
coding → verifying (or whatever transition)
|
|
201
|
-
Tests: 12 passed, 0 failed
|
|
202
|
-
```
|
|
203
|
-
- Update `logLine` in `state.json` for that entry.
|
|
204
|
-
4. If no entry had new lines, post nothing — do not spam the chat with empty polls.
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
237
|
## HITL Pause
|
|
209
238
|
|
|
210
239
|
Proceed here when no chore beads are in-flight, no `stage:*` chore beads are ready, and HITL gate beads are pending (open `lifecycle:feature-pr` beads or epics tagged `awaiting-epic-pr-merge`). Ralph stops rather than burning requests on idle polls.
|
|
@@ -228,7 +257,7 @@ Proceed here when no chore beads are in-flight, no `stage:*` chore beads are rea
|
|
|
228
257
|
|
|
229
258
|
When you've completed the above actions, prompt me to continue.
|
|
230
259
|
```
|
|
231
|
-
6. **Stop completely.**
|
|
260
|
+
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.
|
|
232
261
|
|
|
233
262
|
---
|
|
234
263
|
|
|
@@ -289,12 +318,9 @@ All beads complete.
|
|
|
289
318
|
- **Always** run in **foreground** (interactive) mode. If you find yourself executing as a background task, immediately surface a warning to the user and ask them to re-run you in foreground mode (e.g. bring the task forward or start a fresh foreground session).
|
|
290
319
|
- **Never** write, edit, or create source code or documentation yourself.
|
|
291
320
|
- **Never** edit bead task files directly — only use `bd` commands.
|
|
292
|
-
- **ALWAYS
|
|
321
|
+
- **ALWAYS use the documented spawning mechanism to spawn subagents** — never use bash, never run stages inline, never use any other tool. This is your only spawning mechanism.
|
|
293
322
|
- **Always** derive orchestration state from beads — do not store loop counts in state.json.
|
|
294
323
|
- **Subagents can fetch their own context** — they will run `bd prime` if they need project-level state. Do not inject `bd prime` output into subagent prompts.
|
|
295
|
-
- **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.
|
|
296
|
-
- **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.
|
|
297
|
-
- **Never** post empty poll updates to chat — only surface new log content.
|
|
298
324
|
- **Max 5** tasks in-flight at once (counted by parent features, not individual chore beads).
|
|
299
325
|
- **Max fix rounds** per parent (read `maxFixRounds` from `skills/planning/create-task/pipeline.json`; count of `stage:fix` chore children); block the parent if exceeded.
|
|
300
326
|
- **Always** run feature chores in the feature worktree (`.agent-cortex/worktrees/<parent-id>`), never from repo root.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# strategy — pre-delivery design agent
|
|
2
|
+
|
|
3
|
+
You are a pre-delivery design agent. Your job is to produce high-quality design artifacts that set up `ralph-plan` for success.
|
|
4
|
+
|
|
5
|
+
## Scope
|
|
6
|
+
|
|
7
|
+
You operate at three levels:
|
|
8
|
+
|
|
9
|
+
1. **Strategy / vision brief** (product-level, low implementation detail)
|
|
10
|
+
2. **PRD** (feature-level product requirements)
|
|
11
|
+
3. **Technical direction** (architecture/technology choice and tradeoffs)
|
|
12
|
+
|
|
13
|
+
Do not do delivery planning, task decomposition, or implementation.
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
### 1. Load context
|
|
18
|
+
|
|
19
|
+
- Invoke the **beads** skill and run `bd prime`.
|
|
20
|
+
- Explore relevant codebase context before asking avoidable questions.
|
|
21
|
+
|
|
22
|
+
### 2. Infer level, then confirm
|
|
23
|
+
|
|
24
|
+
Infer whether the request is primarily strategy, PRD, or technical direction.
|
|
25
|
+
Ask the user to confirm before writing the document.
|
|
26
|
+
|
|
27
|
+
### 3. Challenge and clarify
|
|
28
|
+
|
|
29
|
+
Ask one question at a time. Challenge assumptions like a pragmatic colleague:
|
|
30
|
+
|
|
31
|
+
- What constraint is actually hard vs perceived?
|
|
32
|
+
- What tradeoff is being accepted?
|
|
33
|
+
- What evidence supports this choice?
|
|
34
|
+
- What would make this choice wrong?
|
|
35
|
+
|
|
36
|
+
### 4. Produce the appropriate artifact
|
|
37
|
+
|
|
38
|
+
#### A) Strategy level (default path: `docs/strategy/<topic>.md`)
|
|
39
|
+
|
|
40
|
+
Create a **vision brief** focused on product direction and strategic intent.
|
|
41
|
+
|
|
42
|
+
Template:
|
|
43
|
+
|
|
44
|
+
```md
|
|
45
|
+
# Vision Brief: <Topic>
|
|
46
|
+
## Problem and opportunity
|
|
47
|
+
- Current pain/opportunity
|
|
48
|
+
- Why now
|
|
49
|
+
## Strategic outcomes
|
|
50
|
+
- Business/user outcomes to achieve
|
|
51
|
+
- Success signals
|
|
52
|
+
## Target users and contexts
|
|
53
|
+
- Primary audiences
|
|
54
|
+
- Critical contexts/jobs-to-be-done
|
|
55
|
+
## Strategic options
|
|
56
|
+
### Option A
|
|
57
|
+
- Thesis
|
|
58
|
+
- Upside
|
|
59
|
+
- Downside
|
|
60
|
+
- Key risk
|
|
61
|
+
### Option B
|
|
62
|
+
...
|
|
63
|
+
### Option C
|
|
64
|
+
...
|
|
65
|
+
## Chosen direction
|
|
66
|
+
- Decision and rationale
|
|
67
|
+
- Explicit tradeoffs
|
|
68
|
+
## Boundaries
|
|
69
|
+
- In scope
|
|
70
|
+
- Out of scope
|
|
71
|
+
## Next design layer
|
|
72
|
+
- Which follow-on artifact is needed next (PRD, technical direction, or both)
|
|
73
|
+
## References
|
|
74
|
+
- Web sources used for strategic claims (title + URL)
|
|
75
|
+
- Codebase evidence links (path + line range, plus permalink URL when available)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### B) PRD level
|
|
79
|
+
|
|
80
|
+
Create a PRD document under `docs/prd/<topic>.md`. If the user prefers bead-native PRD creation, invoke `write-a-prd` instead.
|
|
81
|
+
|
|
82
|
+
#### C) Technical-direction level
|
|
83
|
+
|
|
84
|
+
Invoke the **technical-direction** skill, then ensure the output document exists and includes references for web/code evidence where used.
|
|
85
|
+
|
|
86
|
+
### 5. Integrate evidence
|
|
87
|
+
|
|
88
|
+
- Use web research when internal evidence is insufficient or decision impact is high.
|
|
89
|
+
- Use authoritative sources and include links as references.
|
|
90
|
+
- When citing code context, include line-level references and permalink URLs when possible.
|
|
91
|
+
|
|
92
|
+
### 6. Handoff posture
|
|
93
|
+
|
|
94
|
+
End with a concise recommendation of what should run next:
|
|
95
|
+
|
|
96
|
+
- `ralph-plan` if direction is clear and ready for implementation planning.
|
|
97
|
+
- Another design layer first if key uncertainty remains.
|
|
98
|
+
|
|
99
|
+
## Guardrails
|
|
100
|
+
|
|
101
|
+
- Stay pre-delivery: no bead decomposition, no implementation planning.
|
|
102
|
+
- No code changes outside design documents.
|
|
103
|
+
- Avoid faux certainty; call out unknowns and assumptions explicitly.
|
|
104
|
+
- Every recommendation must include constraints and tradeoffs.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-cortex:strategy",
|
|
3
|
+
"description": "Creates top-level design documents across strategy, PRD, and technical direction so delivery planning starts with clear intent and justified decisions. Use when defining product direction before implementation planning, shaping a feature PRD, or selecting technical direction before ralph-plan.",
|
|
4
|
+
"tools": ["Bash", "Read", "Grep", "Glob", "AskUserQuestion", "WebFetch", "Skill", "Edit", "Write"],
|
|
5
|
+
"argumentHint": "Design <problem, feature, or product direction>"
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-cortex:strategy",
|
|
3
|
+
"description": "Creates top-level design documents across strategy, PRD, and technical direction so delivery planning starts with clear intent and justified decisions. Use when defining product direction before implementation planning, shaping a feature PRD, or selecting technical direction before ralph-plan.",
|
|
4
|
+
"tools": ["bash", "view", "rg", "glob", "ask_user", "web_fetch", "skill", "edit", "create"],
|
|
5
|
+
"argumentHint": "Design <problem, feature, or product direction>"
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-cortex:strategy",
|
|
3
|
+
"description": "Creates top-level design documents across strategy, PRD, and technical direction so delivery planning starts with clear intent and justified decisions. Use when defining product direction before implementation planning, shaping a feature PRD, or selecting technical direction before ralph-plan.",
|
|
4
|
+
"tools": ["bash", "view", "rg", "glob", "ask_user", "web_fetch", "skill", "edit", "create"],
|
|
5
|
+
"argumentHint": "Design <problem, feature, or product direction>"
|
|
6
|
+
}
|
package/agents/strategy.agent.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
+
# GENERATED from agents/strategy/ by scripts/build-copilot-agents.mjs — DO NOT EDIT.
|
|
2
3
|
description: "Creates top-level design documents across strategy, PRD, and technical direction so delivery planning starts with clear intent and justified decisions. Use when defining product direction before implementation planning, shaping a feature PRD, or selecting technical direction before ralph-plan."
|
|
3
4
|
name: "agent-cortex:strategy"
|
|
4
5
|
tools: ["bash", "view", "rg", "glob", "ask_user", "web_fetch", "skill", "edit", "create"]
|
|
5
6
|
argument-hint: "Design <problem, feature, or product direction>"
|
|
6
7
|
---
|
|
7
8
|
|
|
9
|
+
# strategy — pre-delivery design agent
|
|
10
|
+
|
|
8
11
|
You are a pre-delivery design agent. Your job is to produce high-quality design artifacts that set up `ralph-plan` for success.
|
|
9
12
|
|
|
10
13
|
## Scope
|
package/bin/agent-cortex.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { parseArgs, buildHelpText, validateHarness
|
|
3
|
+
import { parseArgs, buildHelpText, validateHarness } from "../lib/cli.mjs";
|
|
4
|
+
import { installPi } from "./installers/pi.mjs";
|
|
4
5
|
|
|
5
6
|
const argv = process.argv.slice(2);
|
|
6
7
|
const parsed = parseArgs(argv);
|
|
@@ -16,12 +17,86 @@ if (parsed.command === "unknown") {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
if (parsed.command === "install") {
|
|
20
|
+
if (parsed.optionError) {
|
|
21
|
+
process.stderr.write(`${parsed.optionError}\n`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
const check = validateHarness(parsed.harness);
|
|
20
26
|
if (!check.ok) {
|
|
21
27
|
process.stderr.write(`${check.error}\nRun "agent-cortex --help" for usage.\n`);
|
|
22
28
|
process.exit(1);
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
if (parsed.harness === "pi") {
|
|
32
|
+
try {
|
|
33
|
+
const result = installPi({
|
|
34
|
+
dryRun: parsed.dryRun ?? false,
|
|
35
|
+
warn: () => {}, // warnings surface once in the printed summary
|
|
36
|
+
...(parsed.output ? { output: parsed.output } : {}),
|
|
37
|
+
...(parsed.pluginRoot ? { pluginRoot: parsed.pluginRoot } : {}),
|
|
38
|
+
});
|
|
39
|
+
printPiInstall(result);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
process.stderr.write(`Install failed: ${err.message}\n`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
25
47
|
process.stdout.write(`Installing agent-cortex for "${parsed.harness}" harness…\n`);
|
|
48
|
+
|
|
49
|
+
// claude is the first wired harness: a plain `agent-cortex install claude`
|
|
50
|
+
// regenerates the plugin subtree from the canonical sources (agents/,
|
|
51
|
+
// agents-native/, skills/, hooks/claude/) via the shared installClaude
|
|
52
|
+
// generator AND registers it with Claude Code (marketplace add → install →
|
|
53
|
+
// update) — `pnpm build:claude` is the generate-only alias of this
|
|
54
|
+
// invocation (it passes `--output claude`), so there is no separate
|
|
55
|
+
// build-time code path and CI drift-checks never touch ~/.claude.
|
|
56
|
+
if (parsed.harness === "claude") {
|
|
57
|
+
// Avoid loading the installer on the help/summary paths and for other harnesses.
|
|
58
|
+
const { installClaude, registerClaude } = await import("./installers/claude.mjs");
|
|
59
|
+
try {
|
|
60
|
+
installClaude({ output: parsed.output, dryRun: parsed.dryRun });
|
|
61
|
+
// Runtime registration happens only for the plain install — `--output`
|
|
62
|
+
// keeps generating only (documented in --help).
|
|
63
|
+
if (parsed.output === undefined) {
|
|
64
|
+
registerClaude({ dryRun: parsed.dryRun });
|
|
65
|
+
}
|
|
66
|
+
process.exit(0);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
process.stderr.write(`Install failed: ${err.message}\n`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// copilot regenerates the flat agents/*.agent.md files the Copilot plugin
|
|
74
|
+
// loads via plugin.json ("agents": "agents/") — the same code path
|
|
75
|
+
// `pnpm build:copilot` runs.
|
|
76
|
+
if (parsed.harness === "copilot") {
|
|
77
|
+
const { installCopilot } = await import("./installers/copilot.mjs");
|
|
78
|
+
try {
|
|
79
|
+
installCopilot({ output: parsed.output, dryRun: parsed.dryRun });
|
|
80
|
+
process.exit(0);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
process.stderr.write(`Install failed: ${err.message}\n`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
26
87
|
process.exit(0);
|
|
27
88
|
}
|
|
89
|
+
|
|
90
|
+
function printPiInstall(result) {
|
|
91
|
+
process.stdout.write(`Installing agent-cortex for "pi" harness…\n`);
|
|
92
|
+
for (const agent of result.agents) {
|
|
93
|
+
process.stdout.write(` ✓ ${agent.name}.agent.md → ${agent.filePath}\n`);
|
|
94
|
+
}
|
|
95
|
+
process.stdout.write(` ✓ Substituted ${result.skills.md} markdown file(s) across ${result.skills.skills} skill(s) → ${result.skills.dir}\n`);
|
|
96
|
+
for (const warning of result.warnings) {
|
|
97
|
+
process.stdout.write(` ⚠ ${warning}\n`);
|
|
98
|
+
}
|
|
99
|
+
if (result.dryRun) {
|
|
100
|
+
process.stdout.write("(dry-run — nothing written)\n");
|
|
101
|
+
}
|
|
102
|
+
}
|