@dreki-gg/pi-subagent 0.8.1 → 0.8.2
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/CHANGELOG.md +14 -0
- package/extensions/subagent/spawn-utils.ts +2 -1
- package/package.json +1 -1
- package/docs/plans/01_structured-handoffs-and-synthesis.plan.md +0 -376
- package/docs/plans/02_clean-context-review-loop.plan.md +0 -240
- package/docs/plans/03_parallel-recon-single-writer-docs.plan.md +0 -199
- package/docs/plans/04_manager-workflow.plan.md +0 -248
- package/docs/plans/05_advisor-routing.plan.md +0 -244
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @dreki-gg/pi-subagent
|
|
2
2
|
|
|
3
|
+
## 0.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`32797ff`](https://github.com/dreki-gg/pi-extensions/commit/32797ff18d968e22c6c44e95c46e3393d8928cef) Thanks [@jalbarrang](https://github.com/jalbarrang)! - feat(plan-mode): add Windows compatibility — replace Unix shell commands with cross-platform Bun/Node APIs
|
|
8
|
+
|
|
9
|
+
Plan-mode no longer shells out to `cat`, `bash`, or `mkdir` via `pi.exec()`. File I/O now uses `Bun.file()` / `Bun.write()` and `node:fs/promises` `mkdir`, making the extension fully cross-platform. Destructive and safe command pattern lists now include Windows equivalents (`del`, `rd`, `copy`, `move`, `powershell`, `dir`, `where`, `tasklist`, etc.).
|
|
10
|
+
|
|
11
|
+
Also fixes Windows compatibility in three other packages:
|
|
12
|
+
|
|
13
|
+
- **browser-tools**: `spawn` now uses `shell: true` on Windows so `.cmd` wrappers resolve correctly; `shellEscape` uses double-quote style on Windows; install guidance is platform-aware (Homebrew shown only on macOS).
|
|
14
|
+
- **subagent**: `spawn` uses `shell: true` on Windows when the command is bare `pi`, allowing `pi.cmd` resolution.
|
|
15
|
+
- **lsp**: `globalConfigPath()` now uses `os.homedir()` on Windows instead of the unreliable `process.env.HOME`.
|
|
16
|
+
|
|
3
17
|
## 0.8.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -114,9 +114,10 @@ export async function spawnPiAgent(options: SpawnPiAgentOptions): Promise<SpawnP
|
|
|
114
114
|
|
|
115
115
|
const exitCode = await new Promise<number>((resolve) => {
|
|
116
116
|
const invocation = getPiInvocation(args);
|
|
117
|
+
const needsShell = process.platform === 'win32' && invocation.command === 'pi';
|
|
117
118
|
const proc = spawn(invocation.command, invocation.args, {
|
|
118
119
|
cwd: options.cwd,
|
|
119
|
-
shell:
|
|
120
|
+
shell: needsShell,
|
|
120
121
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
121
122
|
});
|
|
122
123
|
let buffer = '';
|
package/package.json
CHANGED
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "Structured handoffs + synthesis for chain workflows"
|
|
3
|
-
overview: "Introduce a first-class handoff format for `@dreki-gg/pi-subagent` so chained agents pass compact, decision-rich context instead of raw `{previous}` markdown blobs. This slice should improve coherence across isolated agents without changing the core single/parallel/chain execution model."
|
|
4
|
-
todo:
|
|
5
|
-
- id: "structured-handoffs-1"
|
|
6
|
-
task: "Add a handoff module that normalizes agent output into a compact envelope with goal, decisions, constraints, files, symbols, and raw output"
|
|
7
|
-
status: pending
|
|
8
|
-
- id: "structured-handoffs-2"
|
|
9
|
-
task: "Thread the structured handoff through chain execution in `extensions/subagent/index.ts` while preserving `{previous}` compatibility"
|
|
10
|
-
status: pending
|
|
11
|
-
- id: "structured-handoffs-3"
|
|
12
|
-
task: "Tighten bundled prompts so scout/planner/worker/docs-scout emit sections the handoff module can reliably summarize"
|
|
13
|
-
status: pending
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Goal
|
|
17
|
-
|
|
18
|
-
Make chained subagent workflows in `packages/subagent` pass structured, compact handoffs instead of blindly injecting the previous agent’s final markdown blob into the next task.
|
|
19
|
-
|
|
20
|
-
# Context
|
|
21
|
-
|
|
22
|
-
- Parent rationale: apply the “single writer, many thinkers” / “context engineering over prompt gimmicks” learnings we discussed for `@dreki-gg/pi-subagent`.
|
|
23
|
-
- Module root: `packages/subagent`
|
|
24
|
-
- This slice is infrastructure. Later slices like clean-context review, manager orchestration, and advisor routing should be able to reuse the same handoff format, but this plan must **not** assume those slices already exist.
|
|
25
|
-
- Existing repo convention for package-local planning docs lives under `packages/<pkg>/docs/plans/` (see `packages/browser-tools/docs/plans/`).
|
|
26
|
-
|
|
27
|
-
## What exists
|
|
28
|
-
|
|
29
|
-
Current relevant file tree on disk:
|
|
30
|
-
|
|
31
|
-
- `packages/subagent/package.json`
|
|
32
|
-
- `packages/subagent/tsconfig.json`
|
|
33
|
-
- `packages/subagent/README.md`
|
|
34
|
-
- `packages/subagent/CHANGELOG.md`
|
|
35
|
-
- `packages/subagent/extensions/subagent/index.ts`
|
|
36
|
-
- `packages/subagent/extensions/subagent/agents.ts`
|
|
37
|
-
- `packages/subagent/extensions/subagent/agent-runner.ts`
|
|
38
|
-
- `packages/subagent/extensions/subagent/agent-runner-types.ts`
|
|
39
|
-
- `packages/subagent/extensions/subagent/agent-result-utils.ts`
|
|
40
|
-
- `packages/subagent/extensions/subagent/run-agent-args.ts`
|
|
41
|
-
- `packages/subagent/extensions/subagent/synthesis.ts`
|
|
42
|
-
- `packages/subagent/prompts/docs-scout.md`
|
|
43
|
-
- `packages/subagent/prompts/planner.md`
|
|
44
|
-
- `packages/subagent/prompts/reviewer.md`
|
|
45
|
-
- `packages/subagent/prompts/scout.md`
|
|
46
|
-
- `packages/subagent/prompts/ux-designer.md`
|
|
47
|
-
- `packages/subagent/prompts/worker.md`
|
|
48
|
-
- `packages/subagent/prompts/implement.md`
|
|
49
|
-
- `packages/subagent/prompts/implement-and-review.md`
|
|
50
|
-
- `packages/subagent/prompts/scout-and-plan.md`
|
|
51
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
52
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md`
|
|
53
|
-
|
|
54
|
-
Actual current behavior on disk:
|
|
55
|
-
|
|
56
|
-
- Chain mode is still raw text plumbing. In `packages/subagent/extensions/subagent/index.ts:658-716`, each step computes `taskWithContext = step.task.replace(/\{previous\}/g, previousOutput)` and then updates `previousOutput = getFinalOutput(result.messages)`. There is no typed handoff object, parser, or summarizer.
|
|
57
|
-
- `getFinalOutput()` in `packages/subagent/extensions/subagent/index.ts:204-214` returns only the last assistant text block, so any rich structure from tool calls or earlier assistant messages is discarded before handoff.
|
|
58
|
-
- `run-agent` synthesizes main-conversation context via `extractRecentConversation()` and `buildRunAgentTask()` (`index.ts:1215-1229`, `index.ts:1557-1559`), but that synthesis is only used for direct `/run-agent` entry and not for agent-to-agent handoff.
|
|
59
|
-
- `packages/subagent/extensions/subagent/synthesis.ts:5-38` already defines a strong section-oriented synthesis instruction (`Goal`, `Decisions`, `Constraints`, `Architecture`, `Open Questions`, `Intent`), but those sections are not reused anywhere in chain orchestration.
|
|
60
|
-
- Bundled prompt templates still explicitly rely on `{previous}` text substitution:
|
|
61
|
-
- `packages/subagent/prompts/implement.md:6-10`
|
|
62
|
-
- `packages/subagent/prompts/scout-and-plan.md:6-9`
|
|
63
|
-
- `packages/subagent/prompts/implement-and-review.md:6-10`
|
|
64
|
-
- The `spawn-subagents` skill already hints at the desired future shape: it says to “return a compact synthesis to the main thread” and to pass previous outputs “verbatim or as a tight structured summary” (`packages/subagent/skills/spawn-subagents/SKILL.md:31-35`, `:49-54`). That guidance is not enforced in code.
|
|
65
|
-
- Bundled agents already emit semi-structured markdown, but the section names are inconsistent across roles:
|
|
66
|
-
- `scout` => `Files Retrieved`, `Key Code`, `Architecture`, `Start Here`
|
|
67
|
-
- `docs-scout` => `Libraries`, `Key Documentation`, `Integration Notes`, `Recommended Next Step`
|
|
68
|
-
- `planner` => `Goal`, `Plan`, `Files to Modify`, `New Files`, `Risks`
|
|
69
|
-
- `worker` => `Completed`, `Files Changed`, `Notes`
|
|
70
|
-
- There is no test directory in `packages/subagent`; current validation is package typechecking (`packages/subagent/package.json`, `packages/subagent/tsconfig.json`).
|
|
71
|
-
|
|
72
|
-
# API inventory
|
|
73
|
-
|
|
74
|
-
## Existing public types and helpers the implementation will touch
|
|
75
|
-
|
|
76
|
-
From `packages/subagent/extensions/subagent/agents.ts`:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
export type AgentScope = 'user' | 'project' | 'both';
|
|
80
|
-
export type AgentSource = 'bundled' | 'user' | 'project' | 'package';
|
|
81
|
-
export type AgentSessionStrategy = 'inline' | 'fork-at';
|
|
82
|
-
|
|
83
|
-
export interface AgentConfig {
|
|
84
|
-
name: string;
|
|
85
|
-
description: string;
|
|
86
|
-
tools?: string[];
|
|
87
|
-
model?: string;
|
|
88
|
-
thinking?: string;
|
|
89
|
-
sessionStrategy?: AgentSessionStrategy;
|
|
90
|
-
systemPrompt: string;
|
|
91
|
-
source: AgentSource;
|
|
92
|
-
filePath: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface AgentDiscoveryResult {
|
|
96
|
-
agents: AgentConfig[];
|
|
97
|
-
projectAgentsDir: string | null;
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
From `packages/subagent/extensions/subagent/agent-runner-types.ts`:
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
export interface UsageStats {
|
|
105
|
-
input: number;
|
|
106
|
-
output: number;
|
|
107
|
-
cacheRead: number;
|
|
108
|
-
cacheWrite: number;
|
|
109
|
-
cost: number;
|
|
110
|
-
contextTokens: number;
|
|
111
|
-
turns: number;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface AgentResult {
|
|
115
|
-
agent: string;
|
|
116
|
-
task: string;
|
|
117
|
-
exitCode: number;
|
|
118
|
-
messages: Message[];
|
|
119
|
-
stderr: string;
|
|
120
|
-
usage: UsageStats;
|
|
121
|
-
model?: string;
|
|
122
|
-
stopReason?: string;
|
|
123
|
-
errorMessage?: string;
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
From `packages/subagent/extensions/subagent/agent-runner.ts`:
|
|
128
|
-
|
|
129
|
-
```ts
|
|
130
|
-
export type OnPhaseUpdate = (
|
|
131
|
-
phaseName: string,
|
|
132
|
-
agentName: string,
|
|
133
|
-
result: AgentResult,
|
|
134
|
-
) => void;
|
|
135
|
-
|
|
136
|
-
export interface RunAgentOptions {
|
|
137
|
-
agentScope?: AgentScope;
|
|
138
|
-
cwd?: string;
|
|
139
|
-
onUpdate?: OnPhaseUpdate;
|
|
140
|
-
phaseName?: string;
|
|
141
|
-
signal?: AbortSignal;
|
|
142
|
-
resolvedPaths?: ResolvedPaths;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export async function runAgent(
|
|
146
|
-
cwd: string,
|
|
147
|
-
agentName: string,
|
|
148
|
-
task: string,
|
|
149
|
-
options: RunAgentOptions = {},
|
|
150
|
-
): Promise<AgentResult>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
From `packages/subagent/extensions/subagent/synthesis.ts`:
|
|
154
|
-
|
|
155
|
-
```ts
|
|
156
|
-
export function extractRecentConversation(
|
|
157
|
-
ctx: ExtensionCommandContext,
|
|
158
|
-
): string
|
|
159
|
-
|
|
160
|
-
export function buildSynthesisPrompt(
|
|
161
|
-
conversation: string,
|
|
162
|
-
explicitTask?: string,
|
|
163
|
-
): string
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## Existing internal chain data shape in `index.ts`
|
|
167
|
-
|
|
168
|
-
```ts
|
|
169
|
-
interface SingleResult {
|
|
170
|
-
agent: string;
|
|
171
|
-
agentSource: AgentSource | 'unknown';
|
|
172
|
-
task: string;
|
|
173
|
-
exitCode: number;
|
|
174
|
-
messages: Message[];
|
|
175
|
-
stderr: string;
|
|
176
|
-
usage: UsageStats;
|
|
177
|
-
model?: string;
|
|
178
|
-
stopReason?: string;
|
|
179
|
-
errorMessage?: string;
|
|
180
|
-
step?: number;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
interface SubagentDetails {
|
|
184
|
-
mode: 'single' | 'parallel' | 'chain';
|
|
185
|
-
agentScope: AgentScope;
|
|
186
|
-
projectAgentsDir: string | null;
|
|
187
|
-
results: SingleResult[];
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
These are currently private to `index.ts`, but the new handoff helper can either:
|
|
192
|
-
- accept a narrow `Pick<SingleResult, ...>` shape, or
|
|
193
|
-
- define its own exported `HandoffSource` input type to avoid importing internal UI state.
|
|
194
|
-
|
|
195
|
-
## Proposed new handoff shape for this slice
|
|
196
|
-
|
|
197
|
-
Create a dedicated module for this instead of baking ad hoc string munging into `index.ts`:
|
|
198
|
-
|
|
199
|
-
```ts
|
|
200
|
-
export interface HandoffFileRef {
|
|
201
|
-
path: string;
|
|
202
|
-
notes?: string;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export interface HandoffEnvelope {
|
|
206
|
-
version: 'subagent-handoff/v1';
|
|
207
|
-
sourceAgent: string;
|
|
208
|
-
sourceStep?: number;
|
|
209
|
-
task: string;
|
|
210
|
-
summary: string;
|
|
211
|
-
goal?: string;
|
|
212
|
-
decisions: string[];
|
|
213
|
-
constraints: string[];
|
|
214
|
-
files: HandoffFileRef[];
|
|
215
|
-
symbols: string[];
|
|
216
|
-
openQuestions: string[];
|
|
217
|
-
rawOutput: string;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface RenderHandoffOptions {
|
|
221
|
-
includeRawOutput?: boolean;
|
|
222
|
-
maxRawChars?: number;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export function buildHandoffFromResult(input: {
|
|
226
|
-
agent: string;
|
|
227
|
-
step?: number;
|
|
228
|
-
task: string;
|
|
229
|
-
output: string;
|
|
230
|
-
}): HandoffEnvelope
|
|
231
|
-
|
|
232
|
-
export function renderHandoffForPrompt(
|
|
233
|
-
handoff: HandoffEnvelope,
|
|
234
|
-
options?: RenderHandoffOptions,
|
|
235
|
-
): string
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
The parser can be heuristic and markdown-based. It does **not** need to become a full AST parser. The goal is reliable compaction, not perfect semantic extraction.
|
|
239
|
-
|
|
240
|
-
# Tasks
|
|
241
|
-
|
|
242
|
-
## 1. Add a handoff module that normalizes agent output into a compact envelope
|
|
243
|
-
|
|
244
|
-
### Files
|
|
245
|
-
- Create `packages/subagent/extensions/subagent/handoffs.ts`
|
|
246
|
-
|
|
247
|
-
### What to add
|
|
248
|
-
- Export a small, typed handoff model (see `Proposed new handoff shape` above).
|
|
249
|
-
- Implement markdown-section extraction that recognizes the current bundled agent contracts:
|
|
250
|
-
- `## Goal`
|
|
251
|
-
- `## Decisions`
|
|
252
|
-
- `## Constraints`
|
|
253
|
-
- `## Architecture`
|
|
254
|
-
- `## Open Questions`
|
|
255
|
-
- `## Plan`
|
|
256
|
-
- `## Files Retrieved`
|
|
257
|
-
- `## Files to Modify`
|
|
258
|
-
- `## New Files`
|
|
259
|
-
- `## Files Changed`
|
|
260
|
-
- `## Notes`
|
|
261
|
-
- `## Risks`
|
|
262
|
-
- `## Recommended Next Step`
|
|
263
|
-
- Build a compact summary by prioritizing the most useful sections instead of returning the entire raw output.
|
|
264
|
-
- Extract file paths by scanning markdown bullets/code spans for repo-looking paths (e.g. `` `packages/subagent/...` ``).
|
|
265
|
-
- Extract symbols conservatively from code fences or bullets when they are clearly named functions/types; do not overfit.
|
|
266
|
-
- Always keep `rawOutput` so callers can still include the source text when needed.
|
|
267
|
-
|
|
268
|
-
### Code sketch
|
|
269
|
-
|
|
270
|
-
```ts
|
|
271
|
-
const SECTION_RE = /^##\s+(.+)$/gm;
|
|
272
|
-
|
|
273
|
-
function splitMarkdownSections(markdown: string): Map<string, string> {
|
|
274
|
-
// return section title -> body
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export function buildHandoffFromResult(input: {
|
|
278
|
-
agent: string;
|
|
279
|
-
step?: number;
|
|
280
|
-
task: string;
|
|
281
|
-
output: string;
|
|
282
|
-
}): HandoffEnvelope {
|
|
283
|
-
const sections = splitMarkdownSections(input.output);
|
|
284
|
-
return {
|
|
285
|
-
version: 'subagent-handoff/v1',
|
|
286
|
-
sourceAgent: input.agent,
|
|
287
|
-
sourceStep: input.step,
|
|
288
|
-
task: input.task,
|
|
289
|
-
summary: ...,
|
|
290
|
-
goal: ...,
|
|
291
|
-
decisions: ...,
|
|
292
|
-
constraints: ...,
|
|
293
|
-
files: ...,
|
|
294
|
-
symbols: ...,
|
|
295
|
-
openQuestions: ...,
|
|
296
|
-
rawOutput: input.output,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### Notes
|
|
302
|
-
- Keep this module dependency-free.
|
|
303
|
-
- Do not move UI rendering logic into this file.
|
|
304
|
-
- The formatter should emit readable markdown because existing prompt templates still use string substitution.
|
|
305
|
-
|
|
306
|
-
## 2. Thread the structured handoff through chain execution in `extensions/subagent/index.ts`
|
|
307
|
-
|
|
308
|
-
### Files
|
|
309
|
-
- Modify `packages/subagent/extensions/subagent/index.ts`
|
|
310
|
-
|
|
311
|
-
### What to change
|
|
312
|
-
- Import the new handoff helper.
|
|
313
|
-
- In the chain path (`index.ts:658-716`), replace the raw `previousOutput` update with a rendered handoff string built from the prior step’s final output.
|
|
314
|
-
- Preserve the existing `{previous}` placeholder contract so current prompt templates still work, but change what gets injected:
|
|
315
|
-
- before: raw final assistant text
|
|
316
|
-
- after: a compact structured markdown summary plus optional truncated raw output
|
|
317
|
-
- Keep error handling behavior unchanged.
|
|
318
|
-
- Keep streaming UI behavior unchanged.
|
|
319
|
-
|
|
320
|
-
### Implementation rules
|
|
321
|
-
- Do **not** change single-mode or parallel-mode semantics in this slice.
|
|
322
|
-
- Do **not** add a new tool mode; keep `single`, `parallel`, and `chain` only.
|
|
323
|
-
- Avoid coupling the handoff module to `Message[]`; extract final text in `index.ts` and pass plain strings into the helper.
|
|
324
|
-
- If the previous step returned no final text, fall back to `'(no output)'` exactly as current code does.
|
|
325
|
-
|
|
326
|
-
## 3. Tighten bundled prompts so handoffs have stable sections to summarize
|
|
327
|
-
|
|
328
|
-
### Files
|
|
329
|
-
- Modify `packages/subagent/prompts/scout.md`
|
|
330
|
-
- Modify `packages/subagent/prompts/docs-scout.md`
|
|
331
|
-
- Modify `packages/subagent/prompts/planner.md`
|
|
332
|
-
- Modify `packages/subagent/prompts/worker.md`
|
|
333
|
-
- Modify `packages/subagent/prompts/implement.md`
|
|
334
|
-
- Modify `packages/subagent/prompts/scout-and-plan.md`
|
|
335
|
-
|
|
336
|
-
### What to change
|
|
337
|
-
- Keep the roles the same, but make their output contracts easier to summarize reliably.
|
|
338
|
-
- Prefer stable section names over freeform prose.
|
|
339
|
-
- Add a small “Handoff” / “Next step” section where helpful instead of forcing the summarizer to infer everything from generic notes.
|
|
340
|
-
|
|
341
|
-
### Recommended section adjustments
|
|
342
|
-
- `scout.md`: keep `Files Retrieved` / `Key Code` / `Architecture`, and add `## Constraints or Unknowns`
|
|
343
|
-
- `docs-scout.md`: keep `Libraries` / `Key Documentation` / `Integration Notes`, and make `Recommended Next Step` mandatory
|
|
344
|
-
- `planner.md`: keep `Goal` / `Plan` / `Files to Modify` / `New Files` / `Risks`; optionally add `## Constraints`
|
|
345
|
-
- `worker.md`: keep `Completed` / `Files Changed` / `Notes`, but require a short bullet list of decisions made and unresolved concerns
|
|
346
|
-
- Prompt templates should mention that `{previous}` now contains a structured handoff, not an unbounded transcript dump
|
|
347
|
-
|
|
348
|
-
# Files to create
|
|
349
|
-
|
|
350
|
-
- `packages/subagent/extensions/subagent/handoffs.ts`
|
|
351
|
-
|
|
352
|
-
# Files to modify
|
|
353
|
-
|
|
354
|
-
- `packages/subagent/extensions/subagent/index.ts` — switch chain substitution from raw final text to rendered structured handoff
|
|
355
|
-
- `packages/subagent/prompts/scout.md` — make scout output easier to summarize deterministically
|
|
356
|
-
- `packages/subagent/prompts/docs-scout.md` — make docs handoff more consistent
|
|
357
|
-
- `packages/subagent/prompts/planner.md` — preserve plan structure but expose constraints explicitly
|
|
358
|
-
- `packages/subagent/prompts/worker.md` — add explicit decision / unresolved sections for downstream agents
|
|
359
|
-
- `packages/subagent/prompts/implement.md` — document structured `{previous}` expectations
|
|
360
|
-
- `packages/subagent/prompts/scout-and-plan.md` — document structured `{previous}` expectations
|
|
361
|
-
|
|
362
|
-
# Testing notes
|
|
363
|
-
|
|
364
|
-
- Run `bun run --filter '@dreki-gg/pi-subagent' typecheck` after adding `handoffs.ts` and updating imports.
|
|
365
|
-
- Manually inspect the rendered handoff string by running a small local chain (for example, a trivial `scout -> planner` task) and confirm that the second step receives a compact summary instead of a huge raw blob.
|
|
366
|
-
- Verify that existing prompt templates still work without changing the user-facing `{previous}` placeholder name.
|
|
367
|
-
- Do not add runtime-only assumptions about sibling plans. This slice must provide value on its own.
|
|
368
|
-
|
|
369
|
-
# Patterns to follow
|
|
370
|
-
|
|
371
|
-
- `packages/subagent/extensions/subagent/synthesis.ts:5-38` — section-oriented synthesis prompt structure worth mirroring in handoffs
|
|
372
|
-
- `packages/subagent/extensions/subagent/index.ts:658-716` — existing chain control flow to preserve
|
|
373
|
-
- `packages/subagent/extensions/subagent/index.ts:204-214` — current final-output extraction behavior to wrap, not duplicate all over the package
|
|
374
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:31-35` — “compact synthesis” guidance already present in the skill
|
|
375
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:49-54` — existing advice about structured summaries
|
|
376
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md:15-20` and `:62-67` — output contracts should stay sharp and structured
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "Clean-context review loop"
|
|
3
|
-
overview: "Refactor the existing implement→review→fix workflow so the reviewer starts from the diff and a minimal handoff instead of inheriting the worker’s full narrative. This slice should preserve the current single-writer loop while making review less correlated with generation."
|
|
4
|
-
todo:
|
|
5
|
-
- id: "clean-review-1"
|
|
6
|
-
task: "Tighten the reviewer prompt so review starts from `git diff` and re-discovered code context, not from the worker’s rationale"
|
|
7
|
-
status: pending
|
|
8
|
-
- id: "clean-review-2"
|
|
9
|
-
task: "Change the worker output contract so implementation handoff exposes exact files, symbols, validation, and unresolved risks in a compact review packet"
|
|
10
|
-
status: pending
|
|
11
|
-
- id: "clean-review-3"
|
|
12
|
-
task: "Rewrite `/implement-and-review` to pass only the minimal review packet and findings needed for the next step"
|
|
13
|
-
status: pending
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Goal
|
|
17
|
-
|
|
18
|
-
Improve the bundled review loop so the reviewer reasons from a fresh, diff-first context and the worker only receives actionable findings back.
|
|
19
|
-
|
|
20
|
-
# Context
|
|
21
|
-
|
|
22
|
-
- Parent rationale: we want the reviewer to act as a clean-context verifier rather than a second pass over the worker’s self-explanation.
|
|
23
|
-
- Module root: `packages/subagent`
|
|
24
|
-
- This slice must work against the current package even if the structured-handoff plan has not landed yet.
|
|
25
|
-
- Keep the package philosophy intact: one writer (`worker`) plus verifier intelligence (`reviewer`), not competing writers.
|
|
26
|
-
|
|
27
|
-
## What exists
|
|
28
|
-
|
|
29
|
-
Current relevant file tree on disk:
|
|
30
|
-
|
|
31
|
-
- `packages/subagent/prompts/reviewer.md`
|
|
32
|
-
- `packages/subagent/prompts/worker.md`
|
|
33
|
-
- `packages/subagent/prompts/implement-and-review.md`
|
|
34
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
35
|
-
- `packages/subagent/extensions/subagent/index.ts`
|
|
36
|
-
- `packages/subagent/README.md`
|
|
37
|
-
|
|
38
|
-
Actual current behavior on disk:
|
|
39
|
-
|
|
40
|
-
- The bundled review workflow is a plain chain prompt. `packages/subagent/prompts/implement-and-review.md:4-10` tells the main agent to:
|
|
41
|
-
1. run `worker` to implement `$@`
|
|
42
|
-
2. run `reviewer` “to review the implementation from the previous step (use {previous} placeholder)”
|
|
43
|
-
3. run `worker` again to apply review feedback from `{previous}`
|
|
44
|
-
- Chain execution in `packages/subagent/extensions/subagent/index.ts:658-716` performs raw `{previous}` replacement with the previous step’s final assistant text. There is no review-specific minimization layer in code today.
|
|
45
|
-
- The current reviewer prompt already points in the right direction:
|
|
46
|
-
- `packages/subagent/prompts/reviewer.md:12-18` restricts bash to read-only commands and tells the agent to start with `git diff`, then read modified files.
|
|
47
|
-
- But the prompt does **not** explicitly tell the reviewer to distrust or deprioritize the worker’s implementation narrative when that narrative is also passed through `{previous}`.
|
|
48
|
-
- The current worker prompt includes a helpful but minimal handoff hint:
|
|
49
|
-
- `packages/subagent/prompts/worker.md:13-26` asks for `Completed`, `Files Changed`, and `Notes`, and says that if handing off to another agent it should include exact file paths changed and key functions/types touched.
|
|
50
|
-
- There is no required section for validation run, constraints, or unresolved risk, so the review handoff is underspecified.
|
|
51
|
-
- The `spawn-subagents` skill currently recommends a `reviewer` loop after implementation and says the main agent may apply fixes directly or send a focused follow-up to `worker` (`packages/subagent/skills/spawn-subagents/SKILL.md:44-58`). It does not yet describe “clean context” review explicitly.
|
|
52
|
-
- There is no additional workflow prompt for “clean review”; the current `/implement-and-review` prompt is the only bundled implementation review loop.
|
|
53
|
-
|
|
54
|
-
# API inventory
|
|
55
|
-
|
|
56
|
-
## Existing reviewer and worker contracts
|
|
57
|
-
|
|
58
|
-
From `packages/subagent/prompts/reviewer.md`:
|
|
59
|
-
|
|
60
|
-
```md
|
|
61
|
-
Strategy:
|
|
62
|
-
1. Run `git diff` to see recent changes (if applicable)
|
|
63
|
-
2. Read the modified files
|
|
64
|
-
3. Check for bugs, security issues, code smells
|
|
65
|
-
|
|
66
|
-
Output format:
|
|
67
|
-
## Files Reviewed
|
|
68
|
-
- `path/to/file.ts` (lines X-Y)
|
|
69
|
-
|
|
70
|
-
## Critical (must fix)
|
|
71
|
-
- `file.ts:42` - Issue description
|
|
72
|
-
|
|
73
|
-
## Warnings (should fix)
|
|
74
|
-
- `file.ts:100` - Issue description
|
|
75
|
-
|
|
76
|
-
## Suggestions (consider)
|
|
77
|
-
- `file.ts:150` - Improvement idea
|
|
78
|
-
|
|
79
|
-
## Summary
|
|
80
|
-
Overall assessment in 2-3 sentences.
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
From `packages/subagent/prompts/worker.md`:
|
|
84
|
-
|
|
85
|
-
```md
|
|
86
|
-
Output format when finished:
|
|
87
|
-
|
|
88
|
-
## Completed
|
|
89
|
-
What was done.
|
|
90
|
-
|
|
91
|
-
## Files Changed
|
|
92
|
-
- `path/to/file.ts` - what changed
|
|
93
|
-
|
|
94
|
-
## Notes (if any)
|
|
95
|
-
Anything the main agent should know.
|
|
96
|
-
|
|
97
|
-
If handing off to another agent (e.g. reviewer), include:
|
|
98
|
-
- Exact file paths changed
|
|
99
|
-
- Key functions/types touched (short list)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Existing workflow prompt shape
|
|
103
|
-
|
|
104
|
-
From `packages/subagent/prompts/implement-and-review.md`:
|
|
105
|
-
|
|
106
|
-
```md
|
|
107
|
-
1. First, use the "worker" agent to implement: $@
|
|
108
|
-
2. Then, use the "reviewer" agent to review the implementation from the previous step (use {previous} placeholder)
|
|
109
|
-
3. Finally, use the "worker" agent to apply the feedback from the review (use {previous} placeholder)
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Existing chain plumbing in code
|
|
113
|
-
|
|
114
|
-
From `packages/subagent/extensions/subagent/index.ts`:
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
const taskWithContext = step.task.replace(/\{previous\}/g, previousOutput);
|
|
118
|
-
...
|
|
119
|
-
previousOutput = getFinalOutput(result.messages);
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
This means the review workflow can be improved significantly even with prompt-only changes, because the thing being substituted is whatever the worker chose to emit as final text.
|
|
123
|
-
|
|
124
|
-
# Tasks
|
|
125
|
-
|
|
126
|
-
## 1. Tighten the reviewer prompt so review starts from `git diff` and re-discovered code context
|
|
127
|
-
|
|
128
|
-
### Files
|
|
129
|
-
- Modify `packages/subagent/prompts/reviewer.md`
|
|
130
|
-
|
|
131
|
-
### What to change
|
|
132
|
-
- Keep the reviewer read-only.
|
|
133
|
-
- Make “diff first, repo second, worker narrative last” an explicit rule.
|
|
134
|
-
- Tell the reviewer to use the incoming handoff only for:
|
|
135
|
-
- the original goal
|
|
136
|
-
- exact file paths / symbols to inspect first
|
|
137
|
-
- any explicit constraints that must not be violated
|
|
138
|
-
- Tell the reviewer to challenge assumptions openly when the diff suggests a bug, insecure pattern, or scope creep.
|
|
139
|
-
- Add a rule that the reviewer should request more investigation rather than hallucinate missing repo context.
|
|
140
|
-
|
|
141
|
-
### Recommended prompt additions
|
|
142
|
-
- Add a short “Rules” section such as:
|
|
143
|
-
1. Start with `git diff` / `git show`; do not trust the generator’s explanation over the code.
|
|
144
|
-
2. Use the incoming handoff only as a pointer to files, constraints, and touched symbols.
|
|
145
|
-
3. Re-discover missing context from the repo yourself.
|
|
146
|
-
4. If a claim cannot be verified from diff or code, say so explicitly.
|
|
147
|
-
- Keep the current output sections, but add a mandatory “No findings” bullet format when the diff looks good.
|
|
148
|
-
|
|
149
|
-
## 2. Change the worker output contract so implementation handoff becomes a compact review packet
|
|
150
|
-
|
|
151
|
-
### Files
|
|
152
|
-
- Modify `packages/subagent/prompts/worker.md`
|
|
153
|
-
|
|
154
|
-
### What to change
|
|
155
|
-
- Keep the worker autonomous and implementation-focused.
|
|
156
|
-
- Expand the finish contract so a downstream reviewer gets a compact, machine-readable packet.
|
|
157
|
-
|
|
158
|
-
### Required output structure
|
|
159
|
-
|
|
160
|
-
```md
|
|
161
|
-
## Completed
|
|
162
|
-
- concise implementation summary
|
|
163
|
-
|
|
164
|
-
## Files Changed
|
|
165
|
-
- `path/to/file.ts` - what changed
|
|
166
|
-
|
|
167
|
-
## Key Symbols Touched
|
|
168
|
-
- `functionName`
|
|
169
|
-
- `TypeName`
|
|
170
|
-
|
|
171
|
-
## Validation
|
|
172
|
-
- command run / not run
|
|
173
|
-
- result
|
|
174
|
-
|
|
175
|
-
## Constraints Followed
|
|
176
|
-
- user constraints that shaped the implementation
|
|
177
|
-
|
|
178
|
-
## Open Risks or Unknowns
|
|
179
|
-
- anything the reviewer should pressure-test
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Notes
|
|
183
|
-
- Do not ask the worker to justify every design choice in prose; that would reintroduce context bloat.
|
|
184
|
-
- The goal is a review packet, not a diary.
|
|
185
|
-
|
|
186
|
-
## 3. Rewrite `/implement-and-review` to pass only the minimal review packet and findings needed for the next step
|
|
187
|
-
|
|
188
|
-
### Files
|
|
189
|
-
- Modify `packages/subagent/prompts/implement-and-review.md`
|
|
190
|
-
|
|
191
|
-
### What to change
|
|
192
|
-
- Replace the vague “review the implementation from the previous step” language with explicit review behavior.
|
|
193
|
-
- The prompt should instruct the main agent to pass a **minimal** handoff to `reviewer`:
|
|
194
|
-
- goal
|
|
195
|
-
- exact files changed
|
|
196
|
-
- touched symbols
|
|
197
|
-
- constraints followed
|
|
198
|
-
- open risks / unknowns
|
|
199
|
-
- The prompt should instruct the reviewer to start from `git diff`, not from the packet itself.
|
|
200
|
-
- The prompt should instruct the final `worker` step to apply only concrete review findings, not to rewrite code based on generic commentary.
|
|
201
|
-
|
|
202
|
-
### Suggested prompt shape
|
|
203
|
-
|
|
204
|
-
```md
|
|
205
|
-
1. Use `worker` to implement: $@
|
|
206
|
-
2. Use `reviewer` to perform a diff-first review. Treat the previous step only as a compact review packet (goal, files changed, key symbols, constraints, open risks). Re-discover repo context from the diff and files as needed.
|
|
207
|
-
3. Use `worker` to address concrete Critical and Warning findings from the review. Ignore Suggestions unless they clearly fit scope.
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Optional follow-up
|
|
211
|
-
- If, during implementation, you find the package benefits from a second prompt template instead of changing the default one, create `packages/subagent/prompts/implement-and-clean-review.md` and keep `/implement-and-review` as a thin wrapper or conservative alias.
|
|
212
|
-
- If you choose that route, document the reason in the plan output and README follow-up notes.
|
|
213
|
-
|
|
214
|
-
# Files to create
|
|
215
|
-
|
|
216
|
-
- None required for the first iteration
|
|
217
|
-
|
|
218
|
-
# Files to modify
|
|
219
|
-
|
|
220
|
-
- `packages/subagent/prompts/reviewer.md` — make clean-context review an explicit prompt rule
|
|
221
|
-
- `packages/subagent/prompts/worker.md` — emit a compact review packet instead of only freeform notes
|
|
222
|
-
- `packages/subagent/prompts/implement-and-review.md` — encode diff-first review semantics in the bundled workflow
|
|
223
|
-
|
|
224
|
-
# Testing notes
|
|
225
|
-
|
|
226
|
-
- No TypeScript changes are required unless you choose to add a helper module, so package validation is primarily manual.
|
|
227
|
-
- Run a small local `/implement-and-review` workflow and verify:
|
|
228
|
-
- the reviewer starts from `git diff`
|
|
229
|
-
- the reviewer output references concrete files/lines
|
|
230
|
-
- the worker’s second pass applies Critical/Warning items rather than rewriting everything
|
|
231
|
-
- If you add any TS helper to support review packet rendering, run `bun run --filter '@dreki-gg/pi-subagent' typecheck`.
|
|
232
|
-
- Do not assume the structured-handoff slice already exists. This prompt-level refactor should still improve behavior on its own.
|
|
233
|
-
|
|
234
|
-
# Patterns to follow
|
|
235
|
-
|
|
236
|
-
- `packages/subagent/prompts/reviewer.md:12-18` — existing diff-first reviewer stance to strengthen, not replace
|
|
237
|
-
- `packages/subagent/prompts/worker.md:24-26` — current handoff hints to make mandatory and more compact
|
|
238
|
-
- `packages/subagent/prompts/implement-and-review.md:4-10` — current workflow entry point to refine
|
|
239
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:44-58` — current review-loop guidance
|
|
240
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md:15-20` and `:62-67` — keep prompt files sharp, minimal, and output-contract-driven
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "Parallel recon, single-writer docs refresh"
|
|
3
|
-
overview: "Document `@dreki-gg/pi-subagent` as an opinionated orchestration tool for parallel reconnaissance, planning, and review around a single writer. This slice updates the package docs and skill guidance without introducing new runtime behavior."
|
|
4
|
-
todo:
|
|
5
|
-
- id: "docs-refresh-1"
|
|
6
|
-
task: "Add a package-local orchestration principles doc that explains when to use single, parallel, and chain modes—and when not to"
|
|
7
|
-
status: done
|
|
8
|
-
- id: "docs-refresh-2"
|
|
9
|
-
task: "Update the package README so one-writer guidance appears near the top instead of being implied"
|
|
10
|
-
status: done
|
|
11
|
-
- id: "docs-refresh-3"
|
|
12
|
-
task: "Tighten the spawn-subagents skill and bundled prompt descriptions so they consistently recommend parallel recon, not parallel conflicting edits"
|
|
13
|
-
status: done
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Goal
|
|
17
|
-
|
|
18
|
-
Make the package documentation explicitly teach the operating model we want users and orchestrating agents to follow: parallelize discovery and verification, keep writes coherent, and use fresh-context reviewers instead of swarms of editors.
|
|
19
|
-
|
|
20
|
-
# Context
|
|
21
|
-
|
|
22
|
-
- Parent rationale: the current package direction is already mostly right; the docs should make that philosophy unmistakable.
|
|
23
|
-
- Module root: `packages/subagent`
|
|
24
|
-
- This is a docs-and-guidance slice. It should not depend on runtime changes landing first.
|
|
25
|
-
- Prefer package-local docs because the repo already stores package-specific plans under package-local `docs/` trees (for example `packages/browser-tools/docs/plans/`).
|
|
26
|
-
|
|
27
|
-
## What exists
|
|
28
|
-
|
|
29
|
-
Current relevant file tree on disk:
|
|
30
|
-
|
|
31
|
-
- `packages/subagent/README.md`
|
|
32
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
33
|
-
- `packages/subagent/prompts/implement.md`
|
|
34
|
-
- `packages/subagent/prompts/scout-and-plan.md`
|
|
35
|
-
- `packages/subagent/prompts/implement-and-review.md`
|
|
36
|
-
- `packages/subagent/prompts/scout.md`
|
|
37
|
-
- `packages/subagent/prompts/planner.md`
|
|
38
|
-
- `packages/subagent/prompts/reviewer.md`
|
|
39
|
-
- `packages/subagent/prompts/worker.md`
|
|
40
|
-
- `packages/subagent/package.json`
|
|
41
|
-
- `packages/subagent/CHANGELOG.md`
|
|
42
|
-
|
|
43
|
-
Actual current state on disk:
|
|
44
|
-
|
|
45
|
-
- `packages/subagent/README.md` explains the three tool modes and the bundled agents, but it does not prominently state a philosophy like “parallel readers, single writer” or “use review loops over swarms.” The first sections are mode descriptions and examples (`README.md:11-45`).
|
|
46
|
-
- The README does list examples that already imply sensible usage—scout, planner, worker, reviewer—but it stops short of explicitly warning against conflicting parallel edits (`README.md:21-45`).
|
|
47
|
-
- The `spawn-subagents` skill is already the clearest articulation of current best practice:
|
|
48
|
-
- `Single specialist` (`SKILL.md:23-29`)
|
|
49
|
-
- `Parallel recon` (`SKILL.md:31-35`)
|
|
50
|
-
- `Plan then implement` (`SKILL.md:37-42`)
|
|
51
|
-
- `Review loop` (`SKILL.md:44-47`)
|
|
52
|
-
- execution rules that say “Parallelize reconnaissance, not conflicting edits” and “Prefer one worker unless file ownership is clearly partitioned” (`SKILL.md:49-53`)
|
|
53
|
-
- The prompt templates are short and functional, but their descriptions do not advertise the package’s opinionated orchestration stance:
|
|
54
|
-
- `/implement` is “Full implementation workflow” (`packages/subagent/prompts/implement.md:1-10`)
|
|
55
|
-
- `/scout-and-plan` is “Scout gathers context, planner creates implementation plan” (`packages/subagent/prompts/scout-and-plan.md:1-9`)
|
|
56
|
-
- `/implement-and-review` is “Worker implements, reviewer reviews, worker applies feedback” (`packages/subagent/prompts/implement-and-review.md:1-10`)
|
|
57
|
-
- There is currently no `packages/subagent/docs/` directory other than the plans we are now adding.
|
|
58
|
-
|
|
59
|
-
# API inventory
|
|
60
|
-
|
|
61
|
-
## User-facing package surface documented today
|
|
62
|
-
|
|
63
|
-
From `packages/subagent/README.md`:
|
|
64
|
-
|
|
65
|
-
```md
|
|
66
|
-
## Subagent Tool
|
|
67
|
-
|
|
68
|
-
The `subagent` tool supports three modes:
|
|
69
|
-
|
|
70
|
-
| Mode | Description |
|
|
71
|
-
| Single | `{ agent, task }` — one agent, one task |
|
|
72
|
-
| Parallel | `{ tasks: [...] }` — multiple agents concurrently |
|
|
73
|
-
| Chain | `{ chain: [...] }` — sequential with `{previous}` placeholder |
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
```md
|
|
77
|
-
### Bundled Agents
|
|
78
|
-
- `scout` — fast codebase recon
|
|
79
|
-
- `docs-scout` — Context7-first documentation lookup
|
|
80
|
-
- `planner` — implementation planning
|
|
81
|
-
- `worker` — general-purpose implementation (`sessionStrategy: fork-at` by default)
|
|
82
|
-
- `reviewer` — code review (`sessionStrategy: fork-at` by default)
|
|
83
|
-
- `ux-designer` — frontend UI design
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Current skill guidance to preserve and elevate
|
|
87
|
-
|
|
88
|
-
From `packages/subagent/skills/spawn-subagents/SKILL.md`:
|
|
89
|
-
|
|
90
|
-
```md
|
|
91
|
-
## 2. Parallel recon
|
|
92
|
-
- Run `scout` + `docs-scout` in parallel when both code and docs matter.
|
|
93
|
-
- Keep parallel tasks non-overlapping.
|
|
94
|
-
- Return a compact synthesis to the main thread.
|
|
95
|
-
|
|
96
|
-
Execution rules:
|
|
97
|
-
- Parallelize reconnaissance, not conflicting edits.
|
|
98
|
-
- Prefer one `worker` unless file ownership is clearly partitioned.
|
|
99
|
-
- Use `docs-scout` when external library/framework details matter.
|
|
100
|
-
- Pass previous outputs verbatim or as a tight structured summary.
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
These lines are the core behavioral contract the docs refresh should reinforce.
|
|
104
|
-
|
|
105
|
-
# Tasks
|
|
106
|
-
|
|
107
|
-
## 1. Add a package-local orchestration principles doc
|
|
108
|
-
|
|
109
|
-
### Files
|
|
110
|
-
- Create `packages/subagent/docs/orchestration-principles.md`
|
|
111
|
-
|
|
112
|
-
### What to add
|
|
113
|
-
Create a short, high-signal doc that explains the intended operating model of `@dreki-gg/pi-subagent`.
|
|
114
|
-
|
|
115
|
-
### Required sections
|
|
116
|
-
- `## Default philosophy`
|
|
117
|
-
- single writer, many thinkers
|
|
118
|
-
- parallel recon yes / conflicting edits no
|
|
119
|
-
- `## When to use each mode`
|
|
120
|
-
- `single`
|
|
121
|
-
- `parallel`
|
|
122
|
-
- `chain`
|
|
123
|
-
- `## Recommended workflows`
|
|
124
|
-
- scout → planner → worker
|
|
125
|
-
- worker → reviewer → worker
|
|
126
|
-
- scout + docs-scout in parallel
|
|
127
|
-
- `## Non-goals`
|
|
128
|
-
- arbitrary swarms
|
|
129
|
-
- multi-writer editing without clear ownership
|
|
130
|
-
- using subagents as a substitute for coherent architecture decisions
|
|
131
|
-
- `## Examples`
|
|
132
|
-
- concise examples mirroring current prompt templates and skill guidance
|
|
133
|
-
|
|
134
|
-
### Notes
|
|
135
|
-
- Keep it grounded in features that exist today.
|
|
136
|
-
- Do not document manager/advisor agents here unless they actually ship before this slice lands.
|
|
137
|
-
|
|
138
|
-
## 2. Update the package README so one-writer guidance appears near the top
|
|
139
|
-
|
|
140
|
-
### Files
|
|
141
|
-
- Modify `packages/subagent/README.md`
|
|
142
|
-
|
|
143
|
-
### What to change
|
|
144
|
-
- Add an “Opinionated defaults” or “How to think about this package” section immediately after the mode table.
|
|
145
|
-
- Make these points explicit:
|
|
146
|
-
- `parallel` is best for scouts and other read-only discovery agents
|
|
147
|
-
- `chain` is best when a single writer needs planned, sequential help
|
|
148
|
-
- `reviewer` is a verifier, not a second writer
|
|
149
|
-
- default safe pattern is one writer unless file ownership is clearly partitioned
|
|
150
|
-
- Keep existing install/use examples, but rewrite at least one example block to show the philosophy in practice.
|
|
151
|
-
|
|
152
|
-
### Suggested wording targets
|
|
153
|
-
- “Use parallel mode for discovery, not competing edits.”
|
|
154
|
-
- “Prefer one worker and surround it with scouts, planners, and reviewers.”
|
|
155
|
-
- “Use review loops to inject fresh context before a human or main agent reads the result.”
|
|
156
|
-
|
|
157
|
-
## 3. Tighten the `spawn-subagents` skill and prompt descriptions
|
|
158
|
-
|
|
159
|
-
### Files
|
|
160
|
-
- Modify `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
161
|
-
- Modify `packages/subagent/prompts/implement.md`
|
|
162
|
-
- Modify `packages/subagent/prompts/scout-and-plan.md`
|
|
163
|
-
- Modify `packages/subagent/prompts/implement-and-review.md`
|
|
164
|
-
|
|
165
|
-
### What to change
|
|
166
|
-
- Keep the skill concise, but move the “parallel recon, not conflicting edits” principle earlier or phrase it more strongly.
|
|
167
|
-
- Make the prompt descriptions more self-explanatory:
|
|
168
|
-
- `/implement` should read as a safe sequential workflow around one implementing agent.
|
|
169
|
-
- `/scout-and-plan` should read as a recon + planning workflow, not a half-implemented swarm.
|
|
170
|
-
- `/implement-and-review` should read as a generator-verifier loop.
|
|
171
|
-
- If any prompt template still implies that `{previous}` is just an unbounded transcript, rewrite the wording to say “handoff” / “summary” instead.
|
|
172
|
-
|
|
173
|
-
# Files to create
|
|
174
|
-
|
|
175
|
-
- `packages/subagent/docs/orchestration-principles.md`
|
|
176
|
-
|
|
177
|
-
# Files to modify
|
|
178
|
-
|
|
179
|
-
- `packages/subagent/README.md` — make package philosophy explicit near the top
|
|
180
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md` — strengthen the opinionated orchestration guidance
|
|
181
|
-
- `packages/subagent/prompts/implement.md` — clarify this is a sequential one-writer workflow
|
|
182
|
-
- `packages/subagent/prompts/scout-and-plan.md` — clarify this is recon + planning, not implementation
|
|
183
|
-
- `packages/subagent/prompts/implement-and-review.md` — describe the workflow as a generator-verifier loop
|
|
184
|
-
|
|
185
|
-
# Testing notes
|
|
186
|
-
|
|
187
|
-
- This slice is markdown-only unless you also tweak package metadata, so there is no TypeScript typecheck requirement.
|
|
188
|
-
- Manually read the final README and skill files in one pass to make sure they do not contradict each other.
|
|
189
|
-
- Keep examples aligned with currently shipped agents and prompts.
|
|
190
|
-
- If a later feature slice adds manager/advisor agents before this one lands, update the new principles doc in the same branch rather than documenting speculative agents now.
|
|
191
|
-
|
|
192
|
-
# Patterns to follow
|
|
193
|
-
|
|
194
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:21-58` — current best articulation of package operating rules
|
|
195
|
-
- `packages/subagent/README.md:11-45` — current package intro to improve, not replace wholesale
|
|
196
|
-
- `packages/subagent/prompts/implement.md:1-10` — terse prompt-template style to preserve
|
|
197
|
-
- `packages/subagent/prompts/scout-and-plan.md:1-9` — terse prompt-template style to preserve
|
|
198
|
-
- `packages/subagent/prompts/implement-and-review.md:1-10` — terse prompt-template style to preserve
|
|
199
|
-
- `packages/browser-tools/docs/plans/*.plan.md` — package-local docs/plans organization pattern already used elsewhere in the repo
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "Manager workflow for multi-slice delegation"
|
|
3
|
-
overview: "Add a bundled `manager` role and a reusable manager workflow so `@dreki-gg/pi-subagent` can coordinate larger, multi-slice tasks without turning into an unstructured swarm. The manager should split work, delegate bounded child tasks, synthesize discoveries, and keep writes coherent."
|
|
4
|
-
todo:
|
|
5
|
-
- id: "manager-workflow-1"
|
|
6
|
-
task: "Add a bundled `manager` agent with a narrow orchestration role, explicit child-report contract, and no multi-writer default"
|
|
7
|
-
status: pending
|
|
8
|
-
- id: "manager-workflow-2"
|
|
9
|
-
task: "Add a bundled prompt template that invokes the manager for larger features or migrations"
|
|
10
|
-
status: pending
|
|
11
|
-
- id: "manager-workflow-3"
|
|
12
|
-
task: "Expose the new manager role in package docs and examples without overpromising unstructured swarm behavior"
|
|
13
|
-
status: pending
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Goal
|
|
17
|
-
|
|
18
|
-
Introduce a first-class manager workflow that can decompose larger tasks into bounded child-agent workstreams, synthesize the results, and keep decision-making coherent.
|
|
19
|
-
|
|
20
|
-
# Context
|
|
21
|
-
|
|
22
|
-
- Parent rationale: the package already has strong primitives (`single`, `parallel`, `chain`), but not a clear higher-level delegation pattern for “a feature spanning several slices” or “a migration with multiple child tasks.”
|
|
23
|
-
- Module root: `packages/subagent`
|
|
24
|
-
- This slice should stay opinionated: map / reduce / manage, not arbitrary peer-to-peer swarms.
|
|
25
|
-
- The manager should be useful even if no new runtime code is added. Prefer prompt + workflow packaging first.
|
|
26
|
-
|
|
27
|
-
## What exists
|
|
28
|
-
|
|
29
|
-
Current relevant file tree on disk:
|
|
30
|
-
|
|
31
|
-
- `packages/subagent/prompts/scout.md`
|
|
32
|
-
- `packages/subagent/prompts/docs-scout.md`
|
|
33
|
-
- `packages/subagent/prompts/planner.md`
|
|
34
|
-
- `packages/subagent/prompts/worker.md`
|
|
35
|
-
- `packages/subagent/prompts/reviewer.md`
|
|
36
|
-
- `packages/subagent/prompts/implement.md`
|
|
37
|
-
- `packages/subagent/prompts/scout-and-plan.md`
|
|
38
|
-
- `packages/subagent/prompts/implement-and-review.md`
|
|
39
|
-
- `packages/subagent/README.md`
|
|
40
|
-
- `packages/subagent/extensions/subagent/index.ts`
|
|
41
|
-
- `packages/subagent/extensions/subagent/agent-runner.ts`
|
|
42
|
-
- `packages/subagent/extensions/subagent/agents.ts`
|
|
43
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
44
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md`
|
|
45
|
-
|
|
46
|
-
Actual current state on disk:
|
|
47
|
-
|
|
48
|
-
- The package ships six bundled agents today: `scout`, `docs-scout`, `planner`, `worker`, `reviewer`, and `ux-designer` (`packages/subagent/README.md:88-105`). There is no `manager` agent.
|
|
49
|
-
- The package ships three prompt templates today: `/implement`, `/scout-and-plan`, and `/implement-and-review` (`README.md:121-124`). There is no manager-oriented workflow prompt.
|
|
50
|
-
- The `subagent` tool supports only three orchestration modes:
|
|
51
|
-
- single
|
|
52
|
-
- parallel
|
|
53
|
-
- chain
|
|
54
|
-
(`packages/subagent/extensions/subagent/index.ts:584-595` and `README.md:13-20`)
|
|
55
|
-
- Parallel mode is already bounded and intentionally limited:
|
|
56
|
-
- max 8 tasks (`index.ts:50`, `:728-738`)
|
|
57
|
-
- max concurrency 4 (`index.ts:51`, `:780-805`)
|
|
58
|
-
- The `spawn-subagents` skill already encodes the package’s desired shape:
|
|
59
|
-
- parallel recon
|
|
60
|
-
- plan then implement
|
|
61
|
-
- review loop
|
|
62
|
-
- “Parallelize reconnaissance, not conflicting edits” (`SKILL.md:31-58`)
|
|
63
|
-
But there is no equivalent section for higher-level “manager delegates to children, then synthesizes.”
|
|
64
|
-
- The current agent runner logic is already compatible with a manager-style agent:
|
|
65
|
-
- `runSingleAgent()` in `index.ts:325-328` only passes `--tools` when the agent frontmatter declares a tool list.
|
|
66
|
-
- `runAgent()` in `agent-runner.ts:73-76` behaves the same way.
|
|
67
|
-
- This means a new `manager` agent can omit `tools:` in frontmatter if it needs access to the full tool set, including the `subagent` tool itself.
|
|
68
|
-
- There is no project-local `.pi/prompts/*.md` manager override in this repo right now; `.pi/prompts/` exists but is empty.
|
|
69
|
-
|
|
70
|
-
# API inventory
|
|
71
|
-
|
|
72
|
-
## Existing agent frontmatter model
|
|
73
|
-
|
|
74
|
-
From `packages/subagent/extensions/subagent/agents.ts`:
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
export interface AgentConfig {
|
|
78
|
-
name: string;
|
|
79
|
-
description: string;
|
|
80
|
-
tools?: string[];
|
|
81
|
-
model?: string;
|
|
82
|
-
thinking?: string;
|
|
83
|
-
sessionStrategy?: 'inline' | 'fork-at';
|
|
84
|
-
systemPrompt: string;
|
|
85
|
-
source: 'bundled' | 'user' | 'project' | 'package';
|
|
86
|
-
filePath: string;
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
From `packages/subagent/README.md`:
|
|
91
|
-
|
|
92
|
-
```md
|
|
93
|
-
---
|
|
94
|
-
name: my-agent
|
|
95
|
-
description: What this agent does
|
|
96
|
-
tools: read, grep, find, ls
|
|
97
|
-
model: anthropic/claude-haiku-4-5
|
|
98
|
-
sessionStrategy: fork-at
|
|
99
|
-
---
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Existing subagent tool modes the manager will likely use
|
|
103
|
-
|
|
104
|
-
From `packages/subagent/README.md` and `packages/subagent/extensions/subagent/index.ts`:
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
// Single
|
|
108
|
-
{ agent, task }
|
|
109
|
-
|
|
110
|
-
// Parallel
|
|
111
|
-
{ tasks: [{ agent, task }, ...] }
|
|
112
|
-
|
|
113
|
-
// Chain
|
|
114
|
-
{ chain: [{ agent, task }, ...] }
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Existing agent roles the manager should compose, not replace
|
|
118
|
-
|
|
119
|
-
- `scout` — repo reconnaissance
|
|
120
|
-
- `docs-scout` — docs lookup
|
|
121
|
-
- `planner` — implementation planning
|
|
122
|
-
- `worker` — implementation
|
|
123
|
-
- `reviewer` — verification
|
|
124
|
-
|
|
125
|
-
The manager should orchestrate these roles, not absorb them.
|
|
126
|
-
|
|
127
|
-
## Proposed manager output contract
|
|
128
|
-
|
|
129
|
-
Create a prompt contract that is directly usable by the main agent or a human:
|
|
130
|
-
|
|
131
|
-
```md
|
|
132
|
-
## Goal
|
|
133
|
-
- one-sentence statement of the parent task
|
|
134
|
-
|
|
135
|
-
## Workstreams
|
|
136
|
-
1. Workstream name — owner agent, scope, expected output
|
|
137
|
-
2. ...
|
|
138
|
-
|
|
139
|
-
## Shared Decisions
|
|
140
|
-
- constraints all children must follow
|
|
141
|
-
|
|
142
|
-
## Child Reports
|
|
143
|
-
### <workstream>
|
|
144
|
-
- what was learned / produced
|
|
145
|
-
- files implicated
|
|
146
|
-
- blockers or open questions
|
|
147
|
-
|
|
148
|
-
## Recommended Next Action
|
|
149
|
-
- whether to run worker, reviewer, or ask the human
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
# Tasks
|
|
153
|
-
|
|
154
|
-
## 1. Add a bundled `manager` agent with a narrow orchestration role
|
|
155
|
-
|
|
156
|
-
### Files
|
|
157
|
-
- Create `packages/subagent/prompts/manager.md`
|
|
158
|
-
|
|
159
|
-
### What to add
|
|
160
|
-
Author a concise bundled agent prompt that:
|
|
161
|
-
- decomposes a larger task into bounded child workstreams
|
|
162
|
-
- delegates to child agents via the `subagent` tool when beneficial
|
|
163
|
-
- prefers read-only discovery or planning in parallel
|
|
164
|
-
- keeps implementation coherent by limiting writing to one `worker` at a time unless file ownership is truly partitioned
|
|
165
|
-
- synthesizes child output into a structured manager report
|
|
166
|
-
|
|
167
|
-
### Frontmatter guidance
|
|
168
|
-
- Omit `tools:` in the first implementation unless you confirm that explicitly listing `subagent` is supported end-to-end in spawned agent tool selection.
|
|
169
|
-
- Use an existing strong model already present in the package (for example `openai/gpt-5.4`) rather than introducing a new provider requirement in this slice.
|
|
170
|
-
- Keep the file under ~100 lines, following `packages/subagent/skills/write-an-agent/SKILL.md`.
|
|
171
|
-
|
|
172
|
-
### Required prompt rules
|
|
173
|
-
1. Split work by scope, not by arbitrary agent count.
|
|
174
|
-
2. Prefer `scout` / `docs-scout` / `planner` in parallel for discovery.
|
|
175
|
-
3. Prefer a single `worker` for edits unless file ownership is obviously isolated.
|
|
176
|
-
4. Synthesize child findings before asking for more work.
|
|
177
|
-
5. Escalate open product or architecture decisions back to the main agent / user instead of hallucinating consensus.
|
|
178
|
-
|
|
179
|
-
## 2. Add a bundled prompt template that invokes the manager for larger tasks
|
|
180
|
-
|
|
181
|
-
### Files
|
|
182
|
-
- Create `packages/subagent/prompts/manage.md`
|
|
183
|
-
|
|
184
|
-
### What to add
|
|
185
|
-
Add a prompt template for larger tasks such as migrations, multi-package refactors, or features that need several child investigations.
|
|
186
|
-
|
|
187
|
-
### Suggested prompt shape
|
|
188
|
-
|
|
189
|
-
```md
|
|
190
|
-
Use the subagent tool to run the `manager` agent on: $@
|
|
191
|
-
|
|
192
|
-
The manager should:
|
|
193
|
-
1. break the work into bounded child workstreams
|
|
194
|
-
2. use parallel scouts/planners where helpful
|
|
195
|
-
3. keep implementation single-writer by default
|
|
196
|
-
4. return a synthesized report with recommended next steps
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Notes
|
|
200
|
-
- Do not build an unbounded recursive swarm prompt.
|
|
201
|
-
- The manager prompt should feel like a higher-level entry point, not a new runtime mode.
|
|
202
|
-
|
|
203
|
-
## 3. Expose the new manager role in docs and examples
|
|
204
|
-
|
|
205
|
-
### Files
|
|
206
|
-
- Modify `packages/subagent/README.md`
|
|
207
|
-
- Modify `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
208
|
-
|
|
209
|
-
### What to change
|
|
210
|
-
- Add `manager` to the bundled agent list in the README.
|
|
211
|
-
- Add one example showing when to use it, such as a multi-package migration or a feature spanning several child tasks.
|
|
212
|
-
- Extend the `spawn-subagents` skill with a new “Manager pattern” section that explains:
|
|
213
|
-
- when to use a manager
|
|
214
|
-
- how it should delegate
|
|
215
|
-
- why this is different from a generic swarm
|
|
216
|
-
|
|
217
|
-
### Suggested skill wording targets
|
|
218
|
-
- “Use `manager` when the task is too large for one prompt but still needs coherent decisions.”
|
|
219
|
-
- “Managers split work, children investigate or implement bounded slices, the manager synthesizes.”
|
|
220
|
-
- “Do not create arbitrary peer-to-peer negotiation loops.”
|
|
221
|
-
|
|
222
|
-
# Files to create
|
|
223
|
-
|
|
224
|
-
- `packages/subagent/prompts/manager.md`
|
|
225
|
-
- `packages/subagent/prompts/manage.md`
|
|
226
|
-
|
|
227
|
-
# Files to modify
|
|
228
|
-
|
|
229
|
-
- `packages/subagent/README.md` — add manager to bundled agents and prompt templates, plus one usage example
|
|
230
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md` — add manager orchestration guidance
|
|
231
|
-
|
|
232
|
-
# Testing notes
|
|
233
|
-
|
|
234
|
-
- If the manager prompt remains markdown-only, there is no package typecheck requirement.
|
|
235
|
-
- Manually run a small `/run-agent manager ...` or equivalent `subagent` call and confirm the manager:
|
|
236
|
-
- breaks work into bounded tasks
|
|
237
|
-
- uses parallel recon rather than parallel conflicting edits
|
|
238
|
-
- returns a synthesized report instead of dumping raw child logs
|
|
239
|
-
- If you decide to add any helper TS module to support manager summaries, run `bun run --filter '@dreki-gg/pi-subagent' typecheck`.
|
|
240
|
-
- Keep the manager role useful without assuming any future advisor/handoff feature exists.
|
|
241
|
-
|
|
242
|
-
# Patterns to follow
|
|
243
|
-
|
|
244
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:31-58` — existing orchestration philosophy to extend upward
|
|
245
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md:15-20` and `:46-67` — agent-authoring constraints for concise, high-signal prompts
|
|
246
|
-
- `packages/subagent/prompts/planner.md:9-38` — good example of a narrow role with a clear output contract
|
|
247
|
-
- `packages/subagent/prompts/worker.md:9-26` — example of a task-focused executor the manager should call, not replace
|
|
248
|
-
- `packages/subagent/README.md:88-124` — bundled-agent and bundled-prompt sections to update
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "Advisor / smart-friend routing"
|
|
3
|
-
overview: "Add a bundled `advisor` role and lightweight escalation guidance so strong primary agents in `@dreki-gg/pi-subagent` can ask for focused second opinions on tricky cases without turning every task into a swarm. This slice is about capability routing, not replacing the main worker."
|
|
4
|
-
todo:
|
|
5
|
-
- id: "advisor-routing-1"
|
|
6
|
-
task: "Add a bundled `advisor` agent with a focused consultative contract: diagnose, suggest next investigation, and surface risks without taking ownership of implementation"
|
|
7
|
-
status: done
|
|
8
|
-
- id: "advisor-routing-2"
|
|
9
|
-
task: "Teach bundled worker/planner/reviewer prompts when to call the advisor and what context to send"
|
|
10
|
-
status: done
|
|
11
|
-
- id: "advisor-routing-3"
|
|
12
|
-
task: "Add a reusable prompt entry point and docs examples for advisor-assisted workflows"
|
|
13
|
-
status: done
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Goal
|
|
17
|
-
|
|
18
|
-
Introduce a lightweight advisor pattern so primary agents can consult a strong second opinion for hard cases while keeping a single primary owner of the work.
|
|
19
|
-
|
|
20
|
-
# Context
|
|
21
|
-
|
|
22
|
-
- Parent rationale: we want capability routing and targeted escalation, not a default “everyone talks to everyone” swarm.
|
|
23
|
-
- Module root: `packages/subagent`
|
|
24
|
-
- This slice should work with the current package architecture and should not depend on a new runtime mode.
|
|
25
|
-
- Keep the advisor narrowly scoped: diagnose, redirect, highlight risk, or suggest the next question. The advisor should not silently become another worker.
|
|
26
|
-
|
|
27
|
-
## What exists
|
|
28
|
-
|
|
29
|
-
Current relevant file tree on disk:
|
|
30
|
-
|
|
31
|
-
- `packages/subagent/prompts/planner.md`
|
|
32
|
-
- `packages/subagent/prompts/reviewer.md`
|
|
33
|
-
- `packages/subagent/prompts/worker.md`
|
|
34
|
-
- `packages/subagent/prompts/docs-scout.md`
|
|
35
|
-
- `packages/subagent/prompts/implement.md`
|
|
36
|
-
- `packages/subagent/prompts/implement-and-review.md`
|
|
37
|
-
- `packages/subagent/README.md`
|
|
38
|
-
- `packages/subagent/extensions/subagent/index.ts`
|
|
39
|
-
- `packages/subagent/extensions/subagent/agent-runner.ts`
|
|
40
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
41
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md`
|
|
42
|
-
|
|
43
|
-
Actual current state on disk:
|
|
44
|
-
|
|
45
|
-
- There is no bundled `advisor` agent in `packages/subagent/prompts/`.
|
|
46
|
-
- There is no advisor-oriented prompt template in `packages/subagent/prompts/`.
|
|
47
|
-
- The current bundled roles are:
|
|
48
|
-
- `planner` for planning (`packages/subagent/prompts/planner.md`)
|
|
49
|
-
- `worker` for implementation (`packages/subagent/prompts/worker.md`)
|
|
50
|
-
- `reviewer` for verification (`packages/subagent/prompts/reviewer.md`)
|
|
51
|
-
- plus `scout`, `docs-scout`, and `ux-designer`
|
|
52
|
-
- The package runner already supports spawned agents consulting tools as needed:
|
|
53
|
-
- in `packages/subagent/extensions/subagent/index.ts:325-328`, `runSingleAgent()` passes `--tools` only when frontmatter declares them
|
|
54
|
-
- in `packages/subagent/extensions/subagent/agent-runner.ts:73-76`, `runAgent()` behaves the same way
|
|
55
|
-
- therefore bundled agents with omitted `tools:` can keep access to the broader tool surface, including `subagent`
|
|
56
|
-
- The current prompt contracts do **not** teach any role when to escalate:
|
|
57
|
-
- `planner.md` only says to produce a concrete plan
|
|
58
|
-
- `worker.md` only says to complete the task autonomously
|
|
59
|
-
- `reviewer.md` only says to review the diff / files
|
|
60
|
-
- The `spawn-subagents` skill recommends specialists and review loops, but does not mention an advisor or “consult when tricky” routing rule.
|
|
61
|
-
|
|
62
|
-
# API inventory
|
|
63
|
-
|
|
64
|
-
## Existing agent prompt contracts that may invoke advisor
|
|
65
|
-
|
|
66
|
-
From `packages/subagent/prompts/planner.md`:
|
|
67
|
-
|
|
68
|
-
```md
|
|
69
|
-
You are a planning specialist.
|
|
70
|
-
You must NOT make any changes. Only read, analyze, and plan.
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
From `packages/subagent/prompts/worker.md`:
|
|
74
|
-
|
|
75
|
-
```md
|
|
76
|
-
You are a worker agent with full capabilities.
|
|
77
|
-
Work autonomously to complete the assigned task. Use all available tools as needed.
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
From `packages/subagent/prompts/reviewer.md`:
|
|
81
|
-
|
|
82
|
-
```md
|
|
83
|
-
You are a senior code reviewer.
|
|
84
|
-
Analyze code for quality, security, and maintainability.
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Existing subagent entry shapes available to an advisor pattern
|
|
88
|
-
|
|
89
|
-
From the `subagent` tool surface:
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
// single consult
|
|
93
|
-
{ agent: 'advisor', task: '...' }
|
|
94
|
-
|
|
95
|
-
// consult inside a chain
|
|
96
|
-
{ chain: [{ agent: 'worker', task: '...' }, { agent: 'advisor', task: '... {previous} ...' }] }
|
|
97
|
-
|
|
98
|
-
// focused parallel consults
|
|
99
|
-
{ tasks: [{ agent: 'advisor', task: '...' }, { agent: 'docs-scout', task: '...' }] }
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Proposed advisor contract
|
|
103
|
-
|
|
104
|
-
The advisor should return guidance the caller can act on immediately:
|
|
105
|
-
|
|
106
|
-
```md
|
|
107
|
-
## Assessment
|
|
108
|
-
- what looks tricky / risky / ambiguous
|
|
109
|
-
|
|
110
|
-
## What to inspect next
|
|
111
|
-
- concrete files, commands, or questions
|
|
112
|
-
|
|
113
|
-
## Recommendation
|
|
114
|
-
- best next action for the caller
|
|
115
|
-
|
|
116
|
-
## Risks
|
|
117
|
-
- what could still go wrong
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
The advisor should not claim to have implemented or verified anything it did not actually inspect.
|
|
121
|
-
|
|
122
|
-
# Tasks
|
|
123
|
-
|
|
124
|
-
## 1. Add a bundled `advisor` agent with a focused consultative contract
|
|
125
|
-
|
|
126
|
-
### Files
|
|
127
|
-
- Create `packages/subagent/prompts/advisor.md`
|
|
128
|
-
|
|
129
|
-
### What to add
|
|
130
|
-
Create a concise bundled agent whose sole job is to provide focused second-opinion guidance.
|
|
131
|
-
|
|
132
|
-
### Required behavior
|
|
133
|
-
- Work from the caller’s question plus any provided handoff.
|
|
134
|
-
- Ask the caller to investigate specific files / commands when the answer depends on context the advisor has not yet inspected.
|
|
135
|
-
- Surface hidden risks or better approaches.
|
|
136
|
-
- Avoid taking over implementation.
|
|
137
|
-
- Prefer decisive recommendations over brainstorming lists.
|
|
138
|
-
|
|
139
|
-
### Frontmatter guidance
|
|
140
|
-
- Use an existing strong model already in package conventions (default to `openai/gpt-5.4` unless there is a strong reason to diversify).
|
|
141
|
-
- Keep the prompt under ~100 lines per `packages/subagent/skills/write-an-agent/SKILL.md`.
|
|
142
|
-
- Omit `tools:` only if you want the advisor to have broad access; otherwise keep the tool list minimal and read-oriented.
|
|
143
|
-
|
|
144
|
-
### Suggested prompt rules
|
|
145
|
-
1. Diagnose the hard part, not the whole task from scratch.
|
|
146
|
-
2. If more repo context is needed, say exactly what to inspect next.
|
|
147
|
-
3. Return a recommendation the caller can act on immediately.
|
|
148
|
-
4. Do not implement code or rewrite plans unless explicitly asked.
|
|
149
|
-
|
|
150
|
-
## 2. Teach bundled prompts when to call the advisor and what context to send
|
|
151
|
-
|
|
152
|
-
### Files
|
|
153
|
-
- Modify `packages/subagent/prompts/worker.md`
|
|
154
|
-
- Modify `packages/subagent/prompts/planner.md`
|
|
155
|
-
- Modify `packages/subagent/prompts/reviewer.md`
|
|
156
|
-
|
|
157
|
-
### What to change
|
|
158
|
-
Add small, explicit escalation rules to the existing bundled roles.
|
|
159
|
-
|
|
160
|
-
### Recommended escalation triggers
|
|
161
|
-
- `worker`
|
|
162
|
-
- ambiguous architecture tradeoff
|
|
163
|
-
- persistent failing tests or unexplained errors
|
|
164
|
-
- merge conflicts / tangled diffs
|
|
165
|
-
- security-sensitive or migration-heavy changes
|
|
166
|
-
- `planner`
|
|
167
|
-
- multiple viable designs with materially different blast radius
|
|
168
|
-
- unclear ownership boundaries across packages
|
|
169
|
-
- need for sharper decomposition before implementation
|
|
170
|
-
- `reviewer`
|
|
171
|
-
- uncertainty whether an issue is real vs. intended
|
|
172
|
-
- suspected deeper architectural problem beyond the current diff
|
|
173
|
-
- need for a second opinion on severity
|
|
174
|
-
|
|
175
|
-
### Required context to send when consulting advisor
|
|
176
|
-
Keep the consult lightweight:
|
|
177
|
-
- current role (`worker` / `planner` / `reviewer`)
|
|
178
|
-
- the exact question
|
|
179
|
-
- touched files / symbols if known
|
|
180
|
-
- the smallest relevant task summary
|
|
181
|
-
- what has already been tried or observed
|
|
182
|
-
|
|
183
|
-
### Notes
|
|
184
|
-
- Do not tell every role to always call the advisor. This is an escalation path, not a mandatory step.
|
|
185
|
-
- Keep the primary role in charge; the advisor should inform decisions, not replace ownership.
|
|
186
|
-
|
|
187
|
-
## 3. Add a reusable prompt entry point and docs examples for advisor-assisted workflows
|
|
188
|
-
|
|
189
|
-
### Files
|
|
190
|
-
- Create `packages/subagent/prompts/consult-advisor.md`
|
|
191
|
-
- Modify `packages/subagent/README.md`
|
|
192
|
-
- Modify `packages/subagent/skills/spawn-subagents/SKILL.md`
|
|
193
|
-
|
|
194
|
-
### What to add
|
|
195
|
-
Create a simple prompt template that encourages focused advisor consultation without changing core workflow semantics.
|
|
196
|
-
|
|
197
|
-
### Suggested prompt shape
|
|
198
|
-
|
|
199
|
-
```md
|
|
200
|
-
Use the subagent tool to consult the `advisor` agent about: $@
|
|
201
|
-
|
|
202
|
-
The advisor should:
|
|
203
|
-
1. identify the hard part
|
|
204
|
-
2. suggest the next investigation or decision
|
|
205
|
-
3. surface concrete risks
|
|
206
|
-
4. return a recommendation, not a full implementation
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### README / skill updates
|
|
210
|
-
- Add `advisor` to the bundled agent list once shipped.
|
|
211
|
-
- Add one example such as:
|
|
212
|
-
- “ask advisor whether this migration should be split before sending it to worker”
|
|
213
|
-
- “have worker consult advisor on the failing test loop”
|
|
214
|
-
- In `spawn-subagents`, add guidance that advisor use is optional and should be reserved for tricky or high-risk cases.
|
|
215
|
-
|
|
216
|
-
# Files to create
|
|
217
|
-
|
|
218
|
-
- `packages/subagent/prompts/advisor.md`
|
|
219
|
-
- `packages/subagent/prompts/consult-advisor.md`
|
|
220
|
-
|
|
221
|
-
# Files to modify
|
|
222
|
-
|
|
223
|
-
- `packages/subagent/prompts/worker.md` — add narrow escalation guidance
|
|
224
|
-
- `packages/subagent/prompts/planner.md` — add narrow escalation guidance
|
|
225
|
-
- `packages/subagent/prompts/reviewer.md` — add narrow escalation guidance
|
|
226
|
-
- `packages/subagent/README.md` — document the new advisor role and one or two examples
|
|
227
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md` — explain when to use advisor vs. planner/reviewer
|
|
228
|
-
|
|
229
|
-
# Testing notes
|
|
230
|
-
|
|
231
|
-
- If this remains markdown-only, there is no TypeScript validation requirement.
|
|
232
|
-
- Manually test one focused consult, such as a planner or worker asking advisor a hard question, and verify:
|
|
233
|
-
- the advisor returns a recommendation rather than trying to own the full task
|
|
234
|
-
- the caller stays in charge of implementation or review
|
|
235
|
-
- the exchange is shorter and more targeted than a full additional workflow
|
|
236
|
-
- If you introduce any helper TS module later to render consult packets, run `bun run --filter '@dreki-gg/pi-subagent' typecheck`.
|
|
237
|
-
|
|
238
|
-
# Patterns to follow
|
|
239
|
-
|
|
240
|
-
- `packages/subagent/skills/write-an-agent/SKILL.md:15-20` and `:46-67` — keep the new agent narrow, concise, and output-contract-driven
|
|
241
|
-
- `packages/subagent/prompts/planner.md:9-38` — example of a specialist planner role that the advisor should complement, not replace
|
|
242
|
-
- `packages/subagent/prompts/reviewer.md:10-37` — example of a verifier role that may occasionally need escalation
|
|
243
|
-
- `packages/subagent/prompts/worker.md:9-26` — example of a primary owner role that should remain in charge after consulting advisor
|
|
244
|
-
- `packages/subagent/skills/spawn-subagents/SKILL.md:23-58` — existing specialist-selection guidance to extend with optional escalation
|