@dreki-gg/pi-subagent 0.2.0 → 0.3.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/CHANGELOG.md +29 -0
- package/README.md +66 -4
- package/agents/docs-scout.md +36 -0
- package/agents/planner.md +38 -0
- package/agents/reviewer.md +36 -0
- package/agents/scout.md +51 -0
- package/agents/ux-designer.md +101 -0
- package/agents/worker.md +25 -0
- package/extensions/subagent/agents.ts +11 -0
- package/extensions/subagent/delegate-executor.ts +200 -0
- package/extensions/subagent/delegate-types.ts +62 -0
- package/extensions/subagent/delegate-ui.ts +132 -0
- package/extensions/subagent/index.ts +294 -1
- package/extensions/subagent/synthesis.ts +78 -0
- package/extensions/subagent/workflows.ts +150 -0
- package/package.json +8 -2
- package/prompts/implement-and-review.md +10 -0
- package/prompts/implement.md +10 -0
- package/prompts/scout-and-plan.md +9 -0
- package/skills/subagent-workflows/SKILL.md +52 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { WorkflowDefinition, WorkflowId } from './delegate-types';
|
|
2
|
+
|
|
3
|
+
export const WORKFLOWS: WorkflowDefinition[] = [
|
|
4
|
+
{
|
|
5
|
+
id: 'scout-only',
|
|
6
|
+
label: 'Scout only',
|
|
7
|
+
description: 'Parallel scouts for exploration — no plan, no implementation',
|
|
8
|
+
phases: [
|
|
9
|
+
{
|
|
10
|
+
kind: 'parallel',
|
|
11
|
+
name: 'Scouts',
|
|
12
|
+
agents: ['scout', 'docs-scout'],
|
|
13
|
+
taskTemplate: '{synthesis}',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'scout-and-plan',
|
|
19
|
+
label: 'Scout and plan',
|
|
20
|
+
description: 'Parallel scouts → planner — produces a plan without implementing',
|
|
21
|
+
phases: [
|
|
22
|
+
{
|
|
23
|
+
kind: 'parallel',
|
|
24
|
+
name: 'Scouts',
|
|
25
|
+
agents: ['scout', 'docs-scout'],
|
|
26
|
+
taskTemplate: '{synthesis}',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
kind: 'single',
|
|
30
|
+
name: 'Planner',
|
|
31
|
+
agents: ['planner'],
|
|
32
|
+
taskTemplate:
|
|
33
|
+
'Create an implementation plan based on the following context.\n\n## Task\n{synthesis}\n\n## Scout findings\n{previous}',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'implement',
|
|
39
|
+
label: 'Implement',
|
|
40
|
+
description: 'Parallel scouts → planner → worker — full implementation',
|
|
41
|
+
phases: [
|
|
42
|
+
{
|
|
43
|
+
kind: 'parallel',
|
|
44
|
+
name: 'Scouts',
|
|
45
|
+
agents: ['scout', 'docs-scout'],
|
|
46
|
+
taskTemplate: '{synthesis}',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
kind: 'single',
|
|
50
|
+
name: 'Planner',
|
|
51
|
+
agents: ['planner'],
|
|
52
|
+
requiresConfirmation: true,
|
|
53
|
+
taskTemplate:
|
|
54
|
+
'Create an implementation plan based on the following context.\n\n## Task\n{synthesis}\n\n## Scout findings\n{previous}',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
kind: 'single',
|
|
58
|
+
name: 'Worker',
|
|
59
|
+
agents: ['worker'],
|
|
60
|
+
taskTemplate:
|
|
61
|
+
'Implement the following plan.\n\n## Task\n{synthesis}\n\n## Plan\n{previous}',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'implement-and-review',
|
|
67
|
+
label: 'Implement and review',
|
|
68
|
+
description:
|
|
69
|
+
'Parallel scouts → planner → worker → reviewer — full implementation with code review',
|
|
70
|
+
phases: [
|
|
71
|
+
{
|
|
72
|
+
kind: 'parallel',
|
|
73
|
+
name: 'Scouts',
|
|
74
|
+
agents: ['scout', 'docs-scout'],
|
|
75
|
+
taskTemplate: '{synthesis}',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
kind: 'single',
|
|
79
|
+
name: 'Planner',
|
|
80
|
+
agents: ['planner'],
|
|
81
|
+
requiresConfirmation: true,
|
|
82
|
+
taskTemplate:
|
|
83
|
+
'Create an implementation plan based on the following context.\n\n## Task\n{synthesis}\n\n## Scout findings\n{previous}',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
kind: 'single',
|
|
87
|
+
name: 'Worker',
|
|
88
|
+
agents: ['worker'],
|
|
89
|
+
taskTemplate:
|
|
90
|
+
'Implement the following plan.\n\n## Task\n{synthesis}\n\n## Plan\n{previous}',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
kind: 'single',
|
|
94
|
+
name: 'Reviewer',
|
|
95
|
+
agents: ['reviewer'],
|
|
96
|
+
taskTemplate:
|
|
97
|
+
'Review the implementation described below.\n\n## Task\n{synthesis}\n\n## Implementation output\n{previous}',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'quick-fix',
|
|
103
|
+
label: 'Quick fix',
|
|
104
|
+
description: 'Worker only — fast, no scouts or planning',
|
|
105
|
+
phases: [
|
|
106
|
+
{
|
|
107
|
+
kind: 'single',
|
|
108
|
+
name: 'Worker',
|
|
109
|
+
agents: ['worker'],
|
|
110
|
+
taskTemplate: '{synthesis}',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 'review',
|
|
116
|
+
label: 'Review',
|
|
117
|
+
description: 'Reviewer only — code review of recent changes',
|
|
118
|
+
phases: [
|
|
119
|
+
{
|
|
120
|
+
kind: 'single',
|
|
121
|
+
name: 'Reviewer',
|
|
122
|
+
agents: ['reviewer'],
|
|
123
|
+
taskTemplate: '{synthesis}',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
export function getWorkflow(id: WorkflowId): WorkflowDefinition {
|
|
130
|
+
const wf = WORKFLOWS.find((w) => w.id === id);
|
|
131
|
+
if (!wf) throw new Error(`Unknown workflow: ${id}`);
|
|
132
|
+
return wf;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function suggestWorkflow(synthesis: string): WorkflowId {
|
|
136
|
+
const lower = synthesis.toLowerCase();
|
|
137
|
+
|
|
138
|
+
const hasReview = /review|audit|check quality|security/.test(lower);
|
|
139
|
+
const hasFix = /fix|bug|patch|hotfix|quick/.test(lower);
|
|
140
|
+
const hasImplement = /implement|build|create|add|refactor|migrate/.test(lower);
|
|
141
|
+
const hasDesign = /design|plan|architect|explore|investigate|scout/.test(lower);
|
|
142
|
+
|
|
143
|
+
if (hasFix && !hasImplement && !hasDesign) return 'quick-fix';
|
|
144
|
+
if (hasReview && !hasImplement && !hasDesign) return 'review';
|
|
145
|
+
if (hasDesign && !hasImplement) return 'scout-and-plan';
|
|
146
|
+
if (hasImplement && hasReview) return 'implement-and-review';
|
|
147
|
+
if (hasImplement) return 'implement';
|
|
148
|
+
|
|
149
|
+
return 'implement';
|
|
150
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreki-gg/pi-subagent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Subagent tool for pi —
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Subagent tool and delegate orchestration for pi — isolated agents, parallel scouts, planning gates, and workflow presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"pi": {
|
|
23
23
|
"extensions": [
|
|
24
24
|
"./extensions/subagent"
|
|
25
|
+
],
|
|
26
|
+
"skills": [
|
|
27
|
+
"./skills"
|
|
28
|
+
],
|
|
29
|
+
"prompts": [
|
|
30
|
+
"./prompts"
|
|
25
31
|
]
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Worker implements, reviewer reviews, worker applies feedback
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "worker" agent to implement: $@
|
|
7
|
+
2. Then, use the "reviewer" agent to review the implementation from the previous step (use {previous} placeholder)
|
|
8
|
+
3. Finally, use the "worker" agent to apply the feedback from the review (use {previous} placeholder)
|
|
9
|
+
|
|
10
|
+
Execute this as a chain, passing output between steps via {previous}.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Full implementation workflow - scout gathers context, planner creates plan, worker implements
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "scout" agent to find all code relevant to: $@
|
|
7
|
+
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
|
8
|
+
3. Finally, use the "worker" agent to implement the plan from the previous step (use {previous} placeholder)
|
|
9
|
+
|
|
10
|
+
Execute this as a chain, passing output between steps via {previous}.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Scout gathers context, planner creates implementation plan (no implementation)
|
|
3
|
+
---
|
|
4
|
+
Use the subagent tool with the chain parameter to execute this workflow:
|
|
5
|
+
|
|
6
|
+
1. First, use the "scout" agent to find all code relevant to: $@
|
|
7
|
+
2. Then, use the "planner" agent to create an implementation plan for "$@" using the context from the previous step (use {previous} placeholder)
|
|
8
|
+
|
|
9
|
+
Execute this as a chain, passing output between steps via {previous}. Do NOT implement - just return the plan.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-workflows
|
|
3
|
+
description: Use explicit subagent workflows for planning or implementation after a grill/design session. Runs parallel scouts, then planner, then optional worker/reviewer.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Use this skill when the user wants to execute a plan with subagents, parallelize discovery intelligently, or asks to hand work off after a design/grill session.
|
|
7
|
+
|
|
8
|
+
Principles:
|
|
9
|
+
- Use the `subagent` tool explicitly; do not improvise ad hoc parallelism.
|
|
10
|
+
- Parallelize reconnaissance, not conflicting edits.
|
|
11
|
+
- Prefer one planner synthesis step after parallel scouts.
|
|
12
|
+
- Prefer one worker unless file ownership can be partitioned safely.
|
|
13
|
+
- Use `docs-scout` whenever library/framework docs matter.
|
|
14
|
+
|
|
15
|
+
Recommended workflows:
|
|
16
|
+
|
|
17
|
+
## 1. Scout and plan
|
|
18
|
+
Use when the user wants a concrete implementation plan before coding.
|
|
19
|
+
|
|
20
|
+
Run `subagent` in parallel mode with two tasks:
|
|
21
|
+
- `scout` for codebase reconnaissance
|
|
22
|
+
- `docs-scout` for library/framework docs if docs are relevant
|
|
23
|
+
|
|
24
|
+
Then run `subagent` in chain or single mode with `planner`, feeding it the scout outputs.
|
|
25
|
+
|
|
26
|
+
## 2. Implement from a grilled plan
|
|
27
|
+
Use when the design is already clarified and the user wants execution.
|
|
28
|
+
|
|
29
|
+
Recommended sequence:
|
|
30
|
+
1. Parallel scouts (`scout` + optionally `docs-scout`)
|
|
31
|
+
2. `planner` synthesis
|
|
32
|
+
3. `worker` implementation
|
|
33
|
+
4. Optional `reviewer`
|
|
34
|
+
|
|
35
|
+
## 3. Review-oriented loop
|
|
36
|
+
Use when the user wants implementation with a final quality pass.
|
|
37
|
+
|
|
38
|
+
Recommended sequence:
|
|
39
|
+
1. `worker`
|
|
40
|
+
2. `reviewer`
|
|
41
|
+
3. Main agent decides whether to apply fixes directly or run another `worker`
|
|
42
|
+
|
|
43
|
+
Execution guidance:
|
|
44
|
+
- Keep parallel scouts focused on different concerns.
|
|
45
|
+
- Do not run multiple workers against the same file set unless boundaries are explicit.
|
|
46
|
+
- If docs are required, use `docs-scout` instead of relying on memory.
|
|
47
|
+
- When handing off between subagents, pass the previous output verbatim or clearly summarized.
|
|
48
|
+
|
|
49
|
+
When reporting back to the user:
|
|
50
|
+
- Say which subagents ran
|
|
51
|
+
- Summarize what each contributed
|
|
52
|
+
- Present the synthesized plan or implementation result clearly
|