@dreki-gg/pi-subagent 0.8.1 → 0.8.3
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 +22 -0
- package/extensions/subagent/index.ts +52 -30
- 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
|
@@ -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
|