@harms-haus/pi-workflows 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/docs/architecture.md +318 -0
- package/docs/configuration-reference.md +427 -0
- package/docs/contributing.md +132 -0
- package/docs/examples.md +1242 -0
- package/docs/hook-lifecycle.md +380 -0
- package/docs/state-management.md +534 -0
- package/docs/subworkflows.md +428 -0
- package/docs/template-variables.md +383 -0
- package/docs/testing.md +479 -0
- package/package.json +69 -0
- package/skills/workflow-generation/SKILL.md +272 -0
- package/src/TimerManager.ts +67 -0
- package/src/command.ts +199 -0
- package/src/config/index.ts +11 -0
- package/src/config/loading-parse.ts +205 -0
- package/src/config/loading-phases.ts +78 -0
- package/src/config/loading-resolve.ts +82 -0
- package/src/config/loading.ts +202 -0
- package/src/config/templates.ts +25 -0
- package/src/config/validation.ts +258 -0
- package/src/hooks.ts +265 -0
- package/src/index.ts +98 -0
- package/src/prompts.ts +141 -0
- package/src/renderers.ts +46 -0
- package/src/state.ts +426 -0
- package/src/tool.ts +364 -0
- package/src/types.ts +211 -0
package/docs/examples.md
ADDED
|
@@ -0,0 +1,1242 @@
|
|
|
1
|
+
# Workflow Examples
|
|
2
|
+
|
|
3
|
+
Complete, runnable workflow definitions demonstrating every major feature of pi-workflows. Each example includes the full directory structure, `workflow.yaml`, and all phase `.md` files.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [1. Minimal Linear Workflow](#1-minimal-linear-workflow)
|
|
10
|
+
- [2. RPIR Development Workflow](#2-rpir-development-workflow)
|
|
11
|
+
- [3. Subworkflow Reuse Example](#3-subworkflow-reuse-example)
|
|
12
|
+
- [4. Looping Pattern](#4-looping-pattern)
|
|
13
|
+
- [5. Whitelist Pattern](#5-whitelist-pattern)
|
|
14
|
+
- [6. Custom Templates Example](#6-custom-templates-example)
|
|
15
|
+
- [7. Multi-Project Setup](#7-multi-project-setup)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 1. Minimal Linear Workflow
|
|
20
|
+
|
|
21
|
+
The simplest possible workflow: two phases, no tool restrictions, no subworkflows. The orchestrator handles everything directly.
|
|
22
|
+
|
|
23
|
+
### Directory Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
~/.pi/agent/workflows/
|
|
27
|
+
└── hello-task/
|
|
28
|
+
├── workflow.yaml
|
|
29
|
+
├── analyze.md
|
|
30
|
+
└── execute.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `hello-task/workflow.yaml`
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
name: "Hello Task"
|
|
37
|
+
commandName: "hello"
|
|
38
|
+
initialMessage: |
|
|
39
|
+
Starting {workflowName} for: "{description}"
|
|
40
|
+
Begin with {firstPhaseEmoji} {firstPhaseName}.
|
|
41
|
+
phases:
|
|
42
|
+
- analyze.md
|
|
43
|
+
- execute.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `hello-task/analyze.md`
|
|
47
|
+
|
|
48
|
+
```markdown
|
|
49
|
+
---
|
|
50
|
+
id: analyze
|
|
51
|
+
name: Analyze
|
|
52
|
+
emoji: "🔍"
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
Analyze the user's request: {description}
|
|
56
|
+
|
|
57
|
+
1. Read the relevant files in the codebase
|
|
58
|
+
2. Identify what needs to change
|
|
59
|
+
3. Summarize your findings
|
|
60
|
+
|
|
61
|
+
When finished, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `hello-task/execute.md`
|
|
65
|
+
|
|
66
|
+
```markdown
|
|
67
|
+
---
|
|
68
|
+
id: execute
|
|
69
|
+
name: Execute
|
|
70
|
+
emoji: "⚙️"
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
Implement the changes identified during analysis for: {description}
|
|
74
|
+
|
|
75
|
+
Apply the edits directly. No tool restrictions — you have full access.
|
|
76
|
+
|
|
77
|
+
When finished, call workflow_step with action='next' to complete the workflow.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### How to Run
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
/workflow hello Add a hello world endpoint to the API
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The workflow advances linearly: Analyze → Execute → DONE.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 2. RPIR Development Workflow
|
|
91
|
+
|
|
92
|
+
A realistic 4-phase workflow following the **R**esearch, **P**lan, **I**mplement, **R**eview pattern. Each phase restricts tools and specifies which subagent profiles the orchestrator may delegate to.
|
|
93
|
+
|
|
94
|
+
### Directory Structure
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
~/.pi/agent/workflows/
|
|
98
|
+
└── rpir/
|
|
99
|
+
├── workflow.yaml
|
|
100
|
+
├── research.md
|
|
101
|
+
├── planning.md
|
|
102
|
+
├── implementing.md
|
|
103
|
+
└── reviewing.md
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `rpir/workflow.yaml`
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
name: "RPIR Development"
|
|
110
|
+
commandName: "rpir"
|
|
111
|
+
sessionNamePrefix: "RPIR: "
|
|
112
|
+
sessionNameMaxLength: 60
|
|
113
|
+
initialMessage: |
|
|
114
|
+
Starting {workflowName} for: "{description}"
|
|
115
|
+
|
|
116
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
117
|
+
Available profiles: {firstPhaseProfiles}
|
|
118
|
+
phases:
|
|
119
|
+
- research.md
|
|
120
|
+
- planning.md
|
|
121
|
+
- implementing.md
|
|
122
|
+
- reviewing.md
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `rpir/research.md`
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
---
|
|
129
|
+
id: research
|
|
130
|
+
name: Research
|
|
131
|
+
emoji: "🔍"
|
|
132
|
+
tools:
|
|
133
|
+
blacklist:
|
|
134
|
+
- edit
|
|
135
|
+
- write
|
|
136
|
+
availableProfiles:
|
|
137
|
+
- vertical-scout
|
|
138
|
+
- horizontal-scout
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Research Phase
|
|
142
|
+
|
|
143
|
+
You are in **{phaseName}** of **{workflowName}** (step {globalStepCount}).
|
|
144
|
+
|
|
145
|
+
Task: {description} (ID: {taskId})
|
|
146
|
+
|
|
147
|
+
You must NOT edit or write files directly. Your job is to gather information.
|
|
148
|
+
|
|
149
|
+
### Instructions
|
|
150
|
+
|
|
151
|
+
1. Spawn 1-4 parallel scout subagents to investigate the codebase:
|
|
152
|
+
|
|
153
|
+
delegate_to_subagents: [
|
|
154
|
+
{ name: "scout-vertical", prompt: "Trace the vertical slice for: {description}. Find all files, functions, and types involved.", profile: "vertical-scout" },
|
|
155
|
+
{ name: "scout-horizontal", prompt: "Search for patterns, utilities, and conventions related to: {description}", profile: "horizontal-scout" }
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
2. Collect results using get_subagent_output for each sessionId.
|
|
159
|
+
|
|
160
|
+
3. Synthesize findings into a concise research summary:
|
|
161
|
+
- Relevant files and their roles
|
|
162
|
+
- Existing patterns to follow
|
|
163
|
+
- Potential risks or edge cases
|
|
164
|
+
|
|
165
|
+
Blocked tools: {blockedToolsList}
|
|
166
|
+
|
|
167
|
+
When your research is complete, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `rpir/planning.md`
|
|
171
|
+
|
|
172
|
+
```markdown
|
|
173
|
+
---
|
|
174
|
+
id: planning
|
|
175
|
+
name: Planning
|
|
176
|
+
emoji: "📋"
|
|
177
|
+
tools:
|
|
178
|
+
blacklist:
|
|
179
|
+
- edit
|
|
180
|
+
- write
|
|
181
|
+
availableProfiles:
|
|
182
|
+
- planner
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Planning Phase
|
|
186
|
+
|
|
187
|
+
You are in **{phaseName}** of **{workflowName}** (step {globalStepCount}).
|
|
188
|
+
|
|
189
|
+
Task: {description}
|
|
190
|
+
|
|
191
|
+
The previous phase (**{previousPhaseName}**) produced research findings. Now create an implementation plan.
|
|
192
|
+
|
|
193
|
+
### Instructions
|
|
194
|
+
|
|
195
|
+
1. Based on the research, delegate plan creation to the planner profile:
|
|
196
|
+
|
|
197
|
+
delegate_to_subagents: [
|
|
198
|
+
{ name: "planner", prompt: "Create a step-by-step implementation plan for: {description}\n\nResearch context: [insert research summary here]\n\nProduce a numbered list of specific, atomic changes.", profile: "planner" }
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
2. Collect and review the plan.
|
|
202
|
+
|
|
203
|
+
3. Ensure the plan covers:
|
|
204
|
+
- Files to create or modify
|
|
205
|
+
- Specific functions/types to add or change
|
|
206
|
+
- Test coverage requirements
|
|
207
|
+
- Migration or deployment steps (if any)
|
|
208
|
+
|
|
209
|
+
Blocked tools: {blockedToolsList}
|
|
210
|
+
|
|
211
|
+
When the plan is finalized, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `rpir/implementing.md`
|
|
215
|
+
|
|
216
|
+
```markdown
|
|
217
|
+
---
|
|
218
|
+
id: implementing
|
|
219
|
+
name: Implementation
|
|
220
|
+
emoji: "⚙️"
|
|
221
|
+
tools:
|
|
222
|
+
blacklist:
|
|
223
|
+
- edit
|
|
224
|
+
- write
|
|
225
|
+
availableProfiles:
|
|
226
|
+
- task-worker
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Implementation Phase
|
|
230
|
+
|
|
231
|
+
You are in **{phaseName}** of **{workflowName}** (step {globalStepCount}).
|
|
232
|
+
|
|
233
|
+
Task: {description}
|
|
234
|
+
|
|
235
|
+
The plan from **{previousPhaseName}** is ready. Execute it by delegating to task workers.
|
|
236
|
+
|
|
237
|
+
### Instructions
|
|
238
|
+
|
|
239
|
+
1. Break the plan into discrete, parallelizable tasks.
|
|
240
|
+
|
|
241
|
+
2. Spawn 1-4 task-worker subagents:
|
|
242
|
+
|
|
243
|
+
delegate_to_subagents: [
|
|
244
|
+
{ name: "worker-1", prompt: "Implement step X of the plan for: {description}\n\nSpecific changes: [describe]", profile: "task-worker" },
|
|
245
|
+
{ name: "worker-2", prompt: "Implement step Y of the plan for: {description}\n\nSpecific changes: [describe]", profile: "task-worker" }
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
3. Collect results and verify each worker completed its task.
|
|
249
|
+
|
|
250
|
+
4. If any task failed or is incomplete, spawn additional workers to address the gaps.
|
|
251
|
+
|
|
252
|
+
Blocked tools: {blockedToolsList}
|
|
253
|
+
|
|
254
|
+
When all implementation tasks are complete, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### `rpir/reviewing.md`
|
|
258
|
+
|
|
259
|
+
```markdown
|
|
260
|
+
---
|
|
261
|
+
id: reviewing
|
|
262
|
+
name: Review
|
|
263
|
+
emoji: "🔎"
|
|
264
|
+
tools:
|
|
265
|
+
blacklist:
|
|
266
|
+
- edit
|
|
267
|
+
- write
|
|
268
|
+
availableProfiles:
|
|
269
|
+
- reviewer
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Review Phase
|
|
273
|
+
|
|
274
|
+
You are in **{phaseName}** of **{workflowName}** (step {globalStepCount}).
|
|
275
|
+
|
|
276
|
+
Task: {description}
|
|
277
|
+
|
|
278
|
+
The implementation is complete. Perform a final quality review.
|
|
279
|
+
|
|
280
|
+
### Instructions
|
|
281
|
+
|
|
282
|
+
1. Delegate a review to the reviewer profile:
|
|
283
|
+
|
|
284
|
+
delegate_to_subagents: [
|
|
285
|
+
{ name: "reviewer", prompt: "Review the implementation for: {description}\n\nCheck for:\n- Correctness and edge cases\n- Code style and conventions\n- Missing tests\n- Potential regressions\n- Performance concerns", profile: "reviewer" }
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
2. Collect the review output.
|
|
289
|
+
|
|
290
|
+
3. If issues are found:
|
|
291
|
+
- Delegate fixes to additional task-worker subagents
|
|
292
|
+
- Re-review after fixes
|
|
293
|
+
|
|
294
|
+
4. If the review passes cleanly, finalize.
|
|
295
|
+
|
|
296
|
+
Blocked tools: {blockedToolsList}
|
|
297
|
+
|
|
298
|
+
When the review is complete and all issues are resolved, call workflow_step with action='next' to complete the workflow.
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### How to Run
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
/workflow rpir Add user authentication with JWT tokens
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The orchestrator delegates all implementation work to subagent profiles. It never edits files directly — the `blacklist` on every phase enforces this.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 3. Subworkflow Reuse Example
|
|
312
|
+
|
|
313
|
+
Two top-level workflows (`rpir-dev` and `rpir-improve`) share a common `rpir-implement` subworkflow containing the implementation and review loop. This avoids duplicating those phase definitions.
|
|
314
|
+
|
|
315
|
+
### Directory Structure
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
~/.pi/agent/workflows/
|
|
319
|
+
├── rpir-dev/
|
|
320
|
+
│ ├── workflow.yaml
|
|
321
|
+
│ ├── research.md
|
|
322
|
+
│ └── planning.md
|
|
323
|
+
├── rpir-improve/
|
|
324
|
+
│ ├── workflow.yaml
|
|
325
|
+
│ ├── assess.md
|
|
326
|
+
│ └── scope.md
|
|
327
|
+
└── rpir-implement/
|
|
328
|
+
├── workflow.yaml
|
|
329
|
+
├── implementing.md
|
|
330
|
+
└── reviewing.md
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### `rpir-dev/workflow.yaml`
|
|
334
|
+
|
|
335
|
+
A development workflow: research, plan, then hand off to the shared implement+review subworkflow.
|
|
336
|
+
|
|
337
|
+
```yaml
|
|
338
|
+
name: "RPIR Development"
|
|
339
|
+
commandName: "rpir-dev"
|
|
340
|
+
sessionNamePrefix: "RPIR-Dev: "
|
|
341
|
+
initialMessage: |
|
|
342
|
+
Starting {workflowName} for: "{description}"
|
|
343
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
344
|
+
phases:
|
|
345
|
+
- research.md
|
|
346
|
+
- planning.md
|
|
347
|
+
- { subworkflow: rpir-implement }
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### `rpir-dev/research.md`
|
|
351
|
+
|
|
352
|
+
```markdown
|
|
353
|
+
---
|
|
354
|
+
id: rpir-dev-research
|
|
355
|
+
name: Research
|
|
356
|
+
emoji: "🔍"
|
|
357
|
+
tools:
|
|
358
|
+
blacklist:
|
|
359
|
+
- edit
|
|
360
|
+
- write
|
|
361
|
+
availableProfiles:
|
|
362
|
+
- vertical-scout
|
|
363
|
+
- horizontal-scout
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Research Phase
|
|
367
|
+
|
|
368
|
+
Task: {description}
|
|
369
|
+
|
|
370
|
+
Investigate the codebase using scout subagents. Identify all relevant files, patterns, and conventions.
|
|
371
|
+
|
|
372
|
+
Summarize findings. When done, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### `rpir-dev/planning.md`
|
|
376
|
+
|
|
377
|
+
```markdown
|
|
378
|
+
---
|
|
379
|
+
id: rpir-dev-planning
|
|
380
|
+
name: Planning
|
|
381
|
+
emoji: "📋"
|
|
382
|
+
tools:
|
|
383
|
+
blacklist:
|
|
384
|
+
- edit
|
|
385
|
+
- write
|
|
386
|
+
availableProfiles:
|
|
387
|
+
- planner
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Planning Phase
|
|
391
|
+
|
|
392
|
+
Task: {description}
|
|
393
|
+
|
|
394
|
+
Create an implementation plan based on research findings. Delegate to the planner profile.
|
|
395
|
+
|
|
396
|
+
When the plan is finalized, call workflow_step with action='next' to advance to {nextPhaseName} (the implementation subworkflow).
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### `rpir-improve/workflow.yaml`
|
|
400
|
+
|
|
401
|
+
An improvement workflow: assess existing code, scope changes, then reuse the same implement+review subworkflow.
|
|
402
|
+
|
|
403
|
+
```yaml
|
|
404
|
+
name: "RPIR Improvement"
|
|
405
|
+
commandName: "rpir-improve"
|
|
406
|
+
sessionNamePrefix: "RPIR-Improve: "
|
|
407
|
+
initialMessage: |
|
|
408
|
+
Starting {workflowName} for: "{description}"
|
|
409
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
410
|
+
phases:
|
|
411
|
+
- assess.md
|
|
412
|
+
- scope.md
|
|
413
|
+
- { subworkflow: rpir-implement }
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### `rpir-improve/assess.md`
|
|
417
|
+
|
|
418
|
+
```markdown
|
|
419
|
+
---
|
|
420
|
+
id: rpir-improve-assess
|
|
421
|
+
name: Assess
|
|
422
|
+
emoji: "📊"
|
|
423
|
+
tools:
|
|
424
|
+
blacklist:
|
|
425
|
+
- edit
|
|
426
|
+
- write
|
|
427
|
+
availableProfiles:
|
|
428
|
+
- vertical-scout
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Assessment Phase
|
|
432
|
+
|
|
433
|
+
Task: {description}
|
|
434
|
+
|
|
435
|
+
Examine the existing code that needs improvement. Identify current behavior, pain points, and technical debt.
|
|
436
|
+
|
|
437
|
+
When done, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### `rpir-improve/scope.md`
|
|
441
|
+
|
|
442
|
+
```markdown
|
|
443
|
+
---
|
|
444
|
+
id: rpir-improve-scope
|
|
445
|
+
name: Scope Changes
|
|
446
|
+
emoji: "📐"
|
|
447
|
+
tools:
|
|
448
|
+
blacklist:
|
|
449
|
+
- edit
|
|
450
|
+
- write
|
|
451
|
+
availableProfiles:
|
|
452
|
+
- planner
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
## Scoping Phase
|
|
456
|
+
|
|
457
|
+
Task: {description}
|
|
458
|
+
|
|
459
|
+
Based on the assessment, create a scoped improvement plan. Define exactly what will change and what will stay the same.
|
|
460
|
+
|
|
461
|
+
When done, call workflow_step with action='next' to enter the implementation subworkflow.
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### `rpir-implement/workflow.yaml`
|
|
465
|
+
|
|
466
|
+
The shared subworkflow — hidden from `/workflow` via `show: "workflows"`, and loopable so the implement-review cycle can repeat.
|
|
467
|
+
|
|
468
|
+
```yaml
|
|
469
|
+
name: "Implement & Review"
|
|
470
|
+
show: "workflows"
|
|
471
|
+
loopable: true
|
|
472
|
+
phases:
|
|
473
|
+
- implementing.md
|
|
474
|
+
- reviewing.md
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### `rpir-implement/implementing.md`
|
|
478
|
+
|
|
479
|
+
```markdown
|
|
480
|
+
---
|
|
481
|
+
id: shared-implement
|
|
482
|
+
name: Implementation
|
|
483
|
+
emoji: "⚙️"
|
|
484
|
+
tools:
|
|
485
|
+
blacklist:
|
|
486
|
+
- edit
|
|
487
|
+
- write
|
|
488
|
+
availableProfiles:
|
|
489
|
+
- task-worker
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Implementation Phase
|
|
493
|
+
|
|
494
|
+
Task: {description}
|
|
495
|
+
|
|
496
|
+
Execute the plan by delegating implementation tasks to task-worker subagents. Break work into parallel units where possible.
|
|
497
|
+
|
|
498
|
+
Blocked tools: {blockedToolsList}
|
|
499
|
+
|
|
500
|
+
When all implementation tasks are complete, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### `rpir-implement/reviewing.md`
|
|
504
|
+
|
|
505
|
+
```markdown
|
|
506
|
+
---
|
|
507
|
+
id: shared-review
|
|
508
|
+
name: Review
|
|
509
|
+
emoji: "🔎"
|
|
510
|
+
tools:
|
|
511
|
+
blacklist:
|
|
512
|
+
- edit
|
|
513
|
+
- write
|
|
514
|
+
availableProfiles:
|
|
515
|
+
- reviewer
|
|
516
|
+
- task-worker
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## Review Phase
|
|
520
|
+
|
|
521
|
+
Task: {description}
|
|
522
|
+
|
|
523
|
+
Delegate a quality review to the reviewer profile. Check for correctness, style, test coverage, and regressions.
|
|
524
|
+
|
|
525
|
+
### Outcomes
|
|
526
|
+
|
|
527
|
+
- **Issues found:** Delegate fixes to task-worker subagents, then call workflow_step with action='loop' to restart the implement-review cycle.
|
|
528
|
+
- **Clean review:** Call workflow_step with action='next' to exit the subworkflow and return to the parent.
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Key Points
|
|
532
|
+
|
|
533
|
+
- `rpir-implement` has `show: "workflows"` — it never appears in `/workflow` listings and cannot be started directly.
|
|
534
|
+
- Both `rpir-dev` and `rpir-improve` reference `{ subworkflow: rpir-implement }` by directory name.
|
|
535
|
+
- The `loopable: true` on `rpir-implement` allows the review phase to restart from implementation if issues are found. See [Looping Pattern](#4-looping-pattern) for details.
|
|
536
|
+
- Phase `id` values are unique within their own workflow — `shared-implement` and `shared-review` exist in `rpir-implement`'s scope, while `rpir-dev-research` and `rpir-dev-planning` exist in `rpir-dev`'s scope. Cross-workflow ID collisions are allowed.
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## 4. Looping Pattern
|
|
541
|
+
|
|
542
|
+
The implement-review loop is the most common looping pattern. When review finds issues, the agent calls `workflow_step loop` to restart the current scope from phase 0. When clean, it calls `workflow_step next` to advance.
|
|
543
|
+
|
|
544
|
+
This example shows two variations: a loop within a subworkflow scope, and a loop in a flat workflow.
|
|
545
|
+
|
|
546
|
+
### Variation A: Subworkflow Loop (Recommended)
|
|
547
|
+
|
|
548
|
+
Using the `rpir-implement` subworkflow from [Example 3](#3-subworkflow-reuse-example), the loop scope is limited to the subworkflow's phases only:
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
rpir-dev phases: [research, planning, {subworkflow: rpir-implement}]
|
|
552
|
+
│
|
|
553
|
+
rpir-implement phases: [implementing, reviewing] ◄──────┘
|
|
554
|
+
↑ │
|
|
555
|
+
└── loop ───────┘ (only this scope restarts)
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
The `reviewing.md` phase instructions control the loop:
|
|
559
|
+
|
|
560
|
+
```markdown
|
|
561
|
+
---
|
|
562
|
+
id: shared-review
|
|
563
|
+
name: Review
|
|
564
|
+
emoji: "🔎"
|
|
565
|
+
tools:
|
|
566
|
+
blacklist:
|
|
567
|
+
- edit
|
|
568
|
+
- write
|
|
569
|
+
availableProfiles:
|
|
570
|
+
- reviewer
|
|
571
|
+
- task-worker
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## Review Phase
|
|
575
|
+
|
|
576
|
+
Task: {description}
|
|
577
|
+
|
|
578
|
+
### Instructions
|
|
579
|
+
|
|
580
|
+
1. Delegate a review to the reviewer profile:
|
|
581
|
+
|
|
582
|
+
delegate_to_subagents: [
|
|
583
|
+
{ name: "reviewer", prompt: "Review the implementation for: {description}. Check correctness, style, tests, regressions.", profile: "reviewer" }
|
|
584
|
+
]
|
|
585
|
+
|
|
586
|
+
2. Collect the review output.
|
|
587
|
+
|
|
588
|
+
### Decision
|
|
589
|
+
|
|
590
|
+
- **If issues were found:**
|
|
591
|
+
1. Delegate fixes to task-worker subagents
|
|
592
|
+
2. After fixes are applied, call workflow_step with action='loop'
|
|
593
|
+
3. This restarts the implement-review subworkflow from implementing.md
|
|
594
|
+
|
|
595
|
+
- **If the review passes:**
|
|
596
|
+
1. Call workflow_step with action='next'
|
|
597
|
+
2. The subworkflow completes and control returns to the parent workflow
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
**What happens on `loop`:**
|
|
601
|
+
|
|
602
|
+
```
|
|
603
|
+
currentPath = [{ rpir-dev, 2 }, { rpir-implement, 1 }]
|
|
604
|
+
^^^^^ reviewing (last phase in subworkflow)
|
|
605
|
+
|
|
606
|
+
→ workflow_step loop
|
|
607
|
+
|
|
608
|
+
currentPath = [{ rpir-dev, 2 }, { rpir-implement, 0 }]
|
|
609
|
+
^^^^^^^ implementing (restarted)
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
The parent scope (`rpir-dev` at phaseIndex 2) is unaffected. Only the innermost scope loops.
|
|
613
|
+
|
|
614
|
+
### Variation B: Flat Workflow Loop
|
|
615
|
+
|
|
616
|
+
A single workflow where `loop` restarts the entire workflow:
|
|
617
|
+
|
|
618
|
+
```
|
|
619
|
+
flat-iterate phases: [implementing, reviewing]
|
|
620
|
+
↑ │
|
|
621
|
+
└── loop ───────┘ (entire workflow restarts)
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### `flat-iterate/workflow.yaml`
|
|
625
|
+
|
|
626
|
+
```yaml
|
|
627
|
+
name: "Iterate Until Clean"
|
|
628
|
+
commandName: "iterate"
|
|
629
|
+
loopable: true
|
|
630
|
+
initialMessage: |
|
|
631
|
+
Starting {workflowName} for: "{description}"
|
|
632
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
633
|
+
phases:
|
|
634
|
+
- implementing.md
|
|
635
|
+
- reviewing.md
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### `flat-iterate/implementing.md`
|
|
639
|
+
|
|
640
|
+
```markdown
|
|
641
|
+
---
|
|
642
|
+
id: flat-implement
|
|
643
|
+
name: Implement
|
|
644
|
+
emoji: "⚙️"
|
|
645
|
+
availableProfiles:
|
|
646
|
+
- task-worker
|
|
647
|
+
---
|
|
648
|
+
|
|
649
|
+
## Implement Phase
|
|
650
|
+
|
|
651
|
+
Task: {description}
|
|
652
|
+
|
|
653
|
+
Implement the required changes by delegating to task-worker subagents.
|
|
654
|
+
|
|
655
|
+
When done, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### `flat-iterate/reviewing.md`
|
|
659
|
+
|
|
660
|
+
```markdown
|
|
661
|
+
---
|
|
662
|
+
id: flat-review
|
|
663
|
+
name: Review
|
|
664
|
+
emoji: "🔎"
|
|
665
|
+
availableProfiles:
|
|
666
|
+
- reviewer
|
|
667
|
+
- task-worker
|
|
668
|
+
---
|
|
669
|
+
|
|
670
|
+
## Review Phase
|
|
671
|
+
|
|
672
|
+
Task: {description}
|
|
673
|
+
|
|
674
|
+
Delegate a review to the reviewer profile.
|
|
675
|
+
|
|
676
|
+
### Decision
|
|
677
|
+
|
|
678
|
+
- **Issues found:** Delegate fixes, then call workflow_step with action='loop' to restart from the workflow's first phase (Implement).
|
|
679
|
+
- **Clean:** Call workflow_step with action='next' to complete the workflow.
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### Preventing Loops
|
|
683
|
+
|
|
684
|
+
Set `loopable: false` to prevent the agent from looping back. This is useful for planning or research phases that should run exactly once:
|
|
685
|
+
|
|
686
|
+
```yaml
|
|
687
|
+
name: "One-Shot Plan"
|
|
688
|
+
commandName: "plan-once"
|
|
689
|
+
loopable: false # ← agent cannot call workflow_step loop
|
|
690
|
+
initialMessage: "Starting {workflowName} for: {description}"
|
|
691
|
+
phases:
|
|
692
|
+
- gather.md
|
|
693
|
+
- plan.md
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
If the agent calls `workflow_step loop` on a non-loopable workflow, it receives:
|
|
697
|
+
|
|
698
|
+
```
|
|
699
|
+
⚠️ Looping is disabled for this workflow.
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
---
|
|
703
|
+
|
|
704
|
+
## 5. Whitelist Pattern
|
|
705
|
+
|
|
706
|
+
While `blacklist` blocks specific tools and allows everything else, `whitelist` takes the opposite approach: **only** the listed tools are allowed. This is useful for phases that need tightly scoped, minimal tool access.
|
|
707
|
+
|
|
708
|
+
> **Remember:** `workflow_step` is always allowed regardless of whitelist or blacklist configuration. You cannot block it.
|
|
709
|
+
|
|
710
|
+
### Directory Structure
|
|
711
|
+
|
|
712
|
+
```
|
|
713
|
+
~/.pi/agent/workflows/
|
|
714
|
+
└── audit/
|
|
715
|
+
├── workflow.yaml
|
|
716
|
+
├── scan.md
|
|
717
|
+
└── report.md
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### `audit/workflow.yaml`
|
|
721
|
+
|
|
722
|
+
```yaml
|
|
723
|
+
name: "Security Audit"
|
|
724
|
+
commandName: "audit"
|
|
725
|
+
sessionNamePrefix: "Audit: "
|
|
726
|
+
initialMessage: |
|
|
727
|
+
Starting {workflowName} for: "{description}"
|
|
728
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
729
|
+
phases:
|
|
730
|
+
- scan.md
|
|
731
|
+
- report.md
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
### `audit/scan.md`
|
|
735
|
+
|
|
736
|
+
```markdown
|
|
737
|
+
---
|
|
738
|
+
id: scan
|
|
739
|
+
name: Scan
|
|
740
|
+
emoji: "🛡️"
|
|
741
|
+
tools:
|
|
742
|
+
whitelist:
|
|
743
|
+
- read
|
|
744
|
+
- search
|
|
745
|
+
- delegate_to_subagents
|
|
746
|
+
availableProfiles:
|
|
747
|
+
- vertical-scout
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
## Security Scan Phase
|
|
751
|
+
|
|
752
|
+
Task: {description}
|
|
753
|
+
|
|
754
|
+
### Allowed Tools
|
|
755
|
+
|
|
756
|
+
You may ONLY use: read, search, delegate_to_subagents, and workflow_step.
|
|
757
|
+
All other tools are blocked.
|
|
758
|
+
|
|
759
|
+
### Instructions
|
|
760
|
+
|
|
761
|
+
1. Scan the codebase for security concerns using read and search tools.
|
|
762
|
+
|
|
763
|
+
2. For broader coverage, spawn scout subagents:
|
|
764
|
+
|
|
765
|
+
delegate_to_subagents: [
|
|
766
|
+
{ name: "sec-scout", prompt: "Scan for security vulnerabilities in: {description}. Check input validation, auth patterns, injection risks.", profile: "vertical-scout" }
|
|
767
|
+
]
|
|
768
|
+
|
|
769
|
+
3. Compile a list of findings with severity ratings (Critical / High / Medium / Low).
|
|
770
|
+
|
|
771
|
+
When the scan is complete, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### `audit/report.md`
|
|
775
|
+
|
|
776
|
+
```markdown
|
|
777
|
+
---
|
|
778
|
+
id: report
|
|
779
|
+
name: Report
|
|
780
|
+
emoji: "📄"
|
|
781
|
+
tools:
|
|
782
|
+
whitelist:
|
|
783
|
+
- read
|
|
784
|
+
- delegate_to_subagents
|
|
785
|
+
availableProfiles:
|
|
786
|
+
- planner
|
|
787
|
+
---
|
|
788
|
+
|
|
789
|
+
## Report Phase
|
|
790
|
+
|
|
791
|
+
Task: {description}
|
|
792
|
+
|
|
793
|
+
### Allowed Tools
|
|
794
|
+
|
|
795
|
+
You may ONLY use: read, delegate_to_subagents, and workflow_step.
|
|
796
|
+
|
|
797
|
+
### Instructions
|
|
798
|
+
|
|
799
|
+
1. Using the scan findings from the previous phase, compile a security report.
|
|
800
|
+
|
|
801
|
+
2. Delegate report writing to the planner profile:
|
|
802
|
+
|
|
803
|
+
delegate_to_subagents: [
|
|
804
|
+
{ name: "reporter", prompt: "Create a structured security audit report for: {description}\n\nFindings: [insert findings]\n\nInclude: executive summary, detailed findings with severity, remediation steps.", profile: "planner" }
|
|
805
|
+
]
|
|
806
|
+
|
|
807
|
+
3. Present the final report.
|
|
808
|
+
|
|
809
|
+
When done, call workflow_step with action='next' to complete the workflow.
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
### Blacklist vs Whitelist Decision Guide
|
|
813
|
+
|
|
814
|
+
| Scenario | Use | Why |
|
|
815
|
+
| ------------------------------------ | ------------------------------ | ---------------------------------------- |
|
|
816
|
+
| Phase should be read-only | `blacklist: [edit, write]` | Broad access minus the dangerous tools |
|
|
817
|
+
| Phase needs minimal, specific tools | `whitelist: [read, search]` | Maximum restriction — nothing unexpected |
|
|
818
|
+
| Phase has full access | Omit `tools` entirely | No restrictions applied |
|
|
819
|
+
| Both `blacklist` and `whitelist` set | **Invalid** — validation error | Mutually exclusive |
|
|
820
|
+
|
|
821
|
+
See [Configuration Reference → Tool Configuration](configuration-reference.md#tool-configuration-details) for full details.
|
|
822
|
+
|
|
823
|
+
---
|
|
824
|
+
|
|
825
|
+
## 6. Custom Templates Example
|
|
826
|
+
|
|
827
|
+
Override the default `roleInstruction`, `advanceReminder`, `blockReasonTemplate`, `completionMessage`, and `notDoneReminder` to customize the orchestrator's behavior and messaging for a specific workflow.
|
|
828
|
+
|
|
829
|
+
> All template variables documented in [Template Variables Reference](template-variables.md) are available.
|
|
830
|
+
|
|
831
|
+
### Directory Structure
|
|
832
|
+
|
|
833
|
+
```
|
|
834
|
+
~/.pi/agent/workflows/
|
|
835
|
+
└── guided-fix/
|
|
836
|
+
├── workflow.yaml
|
|
837
|
+
├── diagnose.md
|
|
838
|
+
└── repair.md
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
### `guided-fix/workflow.yaml`
|
|
842
|
+
|
|
843
|
+
```yaml
|
|
844
|
+
name: "Guided Fix"
|
|
845
|
+
commandName: "fix"
|
|
846
|
+
sessionNamePrefix: "Fix: "
|
|
847
|
+
sessionNameMaxLength: 40
|
|
848
|
+
loopable: false
|
|
849
|
+
|
|
850
|
+
roleInstruction: |
|
|
851
|
+
You are a senior debug assistant running {workflowName}.
|
|
852
|
+
Blocked tools: {blockedToolsList}.
|
|
853
|
+
Approach every problem methodically: observe, hypothesize, test, fix.
|
|
854
|
+
Delegate implementation to subagents when edits are needed.
|
|
855
|
+
|
|
856
|
+
advanceReminder: |
|
|
857
|
+
👉 Phase "{phaseName}" is done. Use {toolName} with action='next' to move to {nextPhaseName}.
|
|
858
|
+
|
|
859
|
+
blockReasonTemplate: |
|
|
860
|
+
🚫 Tool "{toolName}" is not available during {phaseName}.
|
|
861
|
+
Allowed tools: {allowedTools}.
|
|
862
|
+
Follow the phase instructions or delegate to a subagent profile.
|
|
863
|
+
|
|
864
|
+
completionMessage: |
|
|
865
|
+
🎉 {workflowName} complete!
|
|
866
|
+
|
|
867
|
+
**What was fixed:** {taskDescription}
|
|
868
|
+
**Task ID:** {taskId}
|
|
869
|
+
**Total phases:** {phaseCount}
|
|
870
|
+
|
|
871
|
+
notDoneReminder: |
|
|
872
|
+
⚡ Hold on — {workflowName} is still in progress.
|
|
873
|
+
Current phase: {phaseEmoji} {phaseName}
|
|
874
|
+
|
|
875
|
+
You cannot stop here. Complete the phase instructions:
|
|
876
|
+
{phaseInstructions}
|
|
877
|
+
|
|
878
|
+
Then call workflow_step to advance.
|
|
879
|
+
|
|
880
|
+
initialMessage: |
|
|
881
|
+
🔧 Starting {workflowName}
|
|
882
|
+
|
|
883
|
+
**Problem:** {description}
|
|
884
|
+
**Phase 1:** {firstPhaseEmoji} {firstPhaseName}
|
|
885
|
+
|
|
886
|
+
phases:
|
|
887
|
+
- diagnose.md
|
|
888
|
+
- repair.md
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
### `guided-fix/diagnose.md`
|
|
892
|
+
|
|
893
|
+
```markdown
|
|
894
|
+
---
|
|
895
|
+
id: diagnose
|
|
896
|
+
name: Diagnose
|
|
897
|
+
emoji: "🔬"
|
|
898
|
+
tools:
|
|
899
|
+
blacklist:
|
|
900
|
+
- edit
|
|
901
|
+
- write
|
|
902
|
+
availableProfiles:
|
|
903
|
+
- vertical-scout
|
|
904
|
+
---
|
|
905
|
+
|
|
906
|
+
## Diagnose Phase
|
|
907
|
+
|
|
908
|
+
**Problem:** {description}
|
|
909
|
+
|
|
910
|
+
### Instructions
|
|
911
|
+
|
|
912
|
+
1. Reproduce the issue. Use read and search to trace the code path.
|
|
913
|
+
|
|
914
|
+
2. Identify the root cause. Document:
|
|
915
|
+
- Which file(s) and function(s) are involved
|
|
916
|
+
- What the expected behavior should be
|
|
917
|
+
- What's going wrong and why
|
|
918
|
+
|
|
919
|
+
3. If the codebase is large, delegate targeted investigation:
|
|
920
|
+
|
|
921
|
+
delegate_to_subagents: [
|
|
922
|
+
{ name: "investigator", prompt: "Trace the bug: {description}. Find the exact line where the behavior diverges from expected.", profile: "vertical-scout" }
|
|
923
|
+
]
|
|
924
|
+
|
|
925
|
+
Blocked tools: {blockedToolsList}
|
|
926
|
+
|
|
927
|
+
When the root cause is identified, call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
### `guided-fix/repair.md`
|
|
931
|
+
|
|
932
|
+
```markdown
|
|
933
|
+
---
|
|
934
|
+
id: repair
|
|
935
|
+
name: Repair
|
|
936
|
+
emoji: "🔧"
|
|
937
|
+
availableProfiles:
|
|
938
|
+
- task-worker
|
|
939
|
+
- reviewer
|
|
940
|
+
---
|
|
941
|
+
|
|
942
|
+
## Repair Phase
|
|
943
|
+
|
|
944
|
+
**Problem:** {description}
|
|
945
|
+
|
|
946
|
+
The diagnosis from **{previousPhaseName}** identified the root cause. Now fix it.
|
|
947
|
+
|
|
948
|
+
### Instructions
|
|
949
|
+
|
|
950
|
+
1. Delegate the fix to a task-worker:
|
|
951
|
+
|
|
952
|
+
delegate_to_subagents: [
|
|
953
|
+
{ name: "fixer", prompt: "Apply the fix for: {description}\n\nRoot cause: [insert diagnosis]\n\nFix approach: [describe the change]", profile: "task-worker" }
|
|
954
|
+
]
|
|
955
|
+
|
|
956
|
+
2. After the fix is applied, delegate a quick review:
|
|
957
|
+
|
|
958
|
+
delegate_to_subagents: [
|
|
959
|
+
{ name: "verifier", prompt: "Verify the fix for: {description}. Check that the original issue is resolved and no regressions introduced.", profile: "reviewer" }
|
|
960
|
+
]
|
|
961
|
+
|
|
962
|
+
When the fix is verified, call workflow_step with action='next' to complete the workflow.
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
### Template Variable Resolution Example
|
|
966
|
+
|
|
967
|
+
When the agent is in the **Diagnose** phase and tries to call a blocked tool:
|
|
968
|
+
|
|
969
|
+
`blockReasonTemplate` resolves to:
|
|
970
|
+
|
|
971
|
+
```
|
|
972
|
+
🚫 Tool "edit" is not available during Diagnose.
|
|
973
|
+
Allowed tools: all tools except edit, write.
|
|
974
|
+
Follow the phase instructions or delegate to a subagent profile.
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
When the workflow completes:
|
|
978
|
+
|
|
979
|
+
`completionMessage` resolves to:
|
|
980
|
+
|
|
981
|
+
```
|
|
982
|
+
🎉 Guided Fix complete!
|
|
983
|
+
|
|
984
|
+
**What was fixed:** Fix null pointer exception in user service
|
|
985
|
+
**Task ID:** wf-1747234567890-a3f2k1
|
|
986
|
+
**Total phases:** 2
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
---
|
|
990
|
+
|
|
991
|
+
## 7. Multi-Project Setup
|
|
992
|
+
|
|
993
|
+
pi-workflows loads definitions from two tiers: **global** (shared across all projects) and **project-local** (specific to one project). Project definitions override global definitions with the same key.
|
|
994
|
+
|
|
995
|
+
### Loading Order
|
|
996
|
+
|
|
997
|
+
| Priority | Location | Loaded From |
|
|
998
|
+
| ----------- | ------------------------ | ----------------------------------------------------------- |
|
|
999
|
+
| 1 (highest) | `.pi/workflows/` | Relative to the project root (`cwd`) |
|
|
1000
|
+
| 2 | `~/.pi/agent/workflows/` | Global home directory, or `$PI_CODING_AGENT_DIR/workflows/` |
|
|
1001
|
+
|
|
1002
|
+
When both tiers define a workflow with the same directory name, the **project** version wins. The merge uses a simple object spread: `{ ...globalDefs, ...projectDefs }`.
|
|
1003
|
+
|
|
1004
|
+
### Example Layout
|
|
1005
|
+
|
|
1006
|
+
```
|
|
1007
|
+
~/.pi/agent/workflows/ # GLOBAL — available to every project
|
|
1008
|
+
├── rpir/
|
|
1009
|
+
│ ├── workflow.yaml # Standard RPIR workflow
|
|
1010
|
+
│ ├── research.md
|
|
1011
|
+
│ ├── planning.md
|
|
1012
|
+
│ ├── implementing.md
|
|
1013
|
+
│ └── reviewing.md
|
|
1014
|
+
├── code-review/
|
|
1015
|
+
│ ├── workflow.yaml
|
|
1016
|
+
│ ├── gather-context.md
|
|
1017
|
+
│ └── report-findings.md
|
|
1018
|
+
└── _shared/
|
|
1019
|
+
├── implement-review/
|
|
1020
|
+
│ ├── workflow.yaml # show: "workflows" — shared subworkflow
|
|
1021
|
+
│ ├── implementing.md
|
|
1022
|
+
│ └── reviewing.md
|
|
1023
|
+
└── scouting.md # Shared phase file (not a workflow)
|
|
1024
|
+
|
|
1025
|
+
~/projects/webapp/.pi/workflows/ # PROJECT — specific to webapp
|
|
1026
|
+
├── rpir/
|
|
1027
|
+
│ ├── workflow.yaml # OVERRIDES global rpir/
|
|
1028
|
+
│ ├── research.md # Custom research phase for this project
|
|
1029
|
+
│ ├── planning.md # Custom planning phase
|
|
1030
|
+
│ ├── implementing.md # References project-specific profiles
|
|
1031
|
+
│ ├── reviewing.md
|
|
1032
|
+
│ └── deploy.md # Extra phase — 5 phases instead of 4
|
|
1033
|
+
└── hotfix/
|
|
1034
|
+
├── workflow.yaml # PROJECT-ONLY workflow
|
|
1035
|
+
├── reproduce.md
|
|
1036
|
+
├── patch.md
|
|
1037
|
+
└── verify.md
|
|
1038
|
+
|
|
1039
|
+
~/projects/api/.pi/workflows/ # PROJECT — specific to api
|
|
1040
|
+
└── hotfix/
|
|
1041
|
+
├── workflow.yaml # Different hotfix workflow for API project
|
|
1042
|
+
├── assess.md
|
|
1043
|
+
├── fix.md
|
|
1044
|
+
└── test.md
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
### Scenario: Override Global Workflow
|
|
1048
|
+
|
|
1049
|
+
The global `rpir` workflow has 4 phases. The `webapp` project needs a 5th deployment phase.
|
|
1050
|
+
|
|
1051
|
+
**Global `~/.pi/agent/workflows/rpir/workflow.yaml`:**
|
|
1052
|
+
|
|
1053
|
+
```yaml
|
|
1054
|
+
name: "RPIR Development"
|
|
1055
|
+
commandName: "rpir"
|
|
1056
|
+
initialMessage: |
|
|
1057
|
+
Starting {workflowName} for: "{description}"
|
|
1058
|
+
phases:
|
|
1059
|
+
- research.md
|
|
1060
|
+
- planning.md
|
|
1061
|
+
- implementing.md
|
|
1062
|
+
- reviewing.md
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
**Project `webapp/.pi/workflows/rpir/workflow.yaml`** (overrides global):
|
|
1066
|
+
|
|
1067
|
+
```yaml
|
|
1068
|
+
name: "RPIR Development (Webapp)"
|
|
1069
|
+
commandName: "rpir"
|
|
1070
|
+
sessionNamePrefix: "Webapp-RPIR: "
|
|
1071
|
+
initialMessage: |
|
|
1072
|
+
Starting {workflowName} for: "{description}"
|
|
1073
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
1074
|
+
phases:
|
|
1075
|
+
- research.md
|
|
1076
|
+
- planning.md
|
|
1077
|
+
- implementing.md
|
|
1078
|
+
- reviewing.md
|
|
1079
|
+
- deploy.md
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
**Project `webapp/.pi/workflows/rpir/deploy.md`** (project-only phase):
|
|
1083
|
+
|
|
1084
|
+
```markdown
|
|
1085
|
+
---
|
|
1086
|
+
id: deploy
|
|
1087
|
+
name: Deploy
|
|
1088
|
+
emoji: "🚀"
|
|
1089
|
+
availableProfiles:
|
|
1090
|
+
- task-worker
|
|
1091
|
+
---
|
|
1092
|
+
|
|
1093
|
+
## Deploy Phase
|
|
1094
|
+
|
|
1095
|
+
Task: {description}
|
|
1096
|
+
|
|
1097
|
+
The review from **{previousPhaseName}** passed. Deploy the changes.
|
|
1098
|
+
|
|
1099
|
+
### Instructions
|
|
1100
|
+
|
|
1101
|
+
1. Run the deployment commands via task-worker subagents.
|
|
1102
|
+
2. Verify the deployment succeeded.
|
|
1103
|
+
3. Check health endpoints.
|
|
1104
|
+
|
|
1105
|
+
When deployment is verified, call workflow_step with action='next' to complete the workflow.
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
### Scenario: Project-Only Workflow
|
|
1109
|
+
|
|
1110
|
+
The `webapp` project defines a `hotfix` workflow that doesn't exist globally:
|
|
1111
|
+
|
|
1112
|
+
**Project `webapp/.pi/workflows/hotfix/workflow.yaml`:**
|
|
1113
|
+
|
|
1114
|
+
```yaml
|
|
1115
|
+
name: "Hotfix Pipeline"
|
|
1116
|
+
commandName: "hotfix"
|
|
1117
|
+
sessionNamePrefix: "Hotfix: "
|
|
1118
|
+
loopable: false
|
|
1119
|
+
initialMessage: |
|
|
1120
|
+
🚨 Starting {workflowName} for: "{description}"
|
|
1121
|
+
Phase 1: {firstPhaseEmoji} {firstPhaseName}
|
|
1122
|
+
phases:
|
|
1123
|
+
- reproduce.md
|
|
1124
|
+
- patch.md
|
|
1125
|
+
- verify.md
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
**Project `webapp/.pi/workflows/hotfix/reproduce.md`:**
|
|
1129
|
+
|
|
1130
|
+
```markdown
|
|
1131
|
+
---
|
|
1132
|
+
id: hotfix-reproduce
|
|
1133
|
+
name: Reproduce
|
|
1134
|
+
emoji: "🐛"
|
|
1135
|
+
tools:
|
|
1136
|
+
blacklist:
|
|
1137
|
+
- edit
|
|
1138
|
+
- write
|
|
1139
|
+
---
|
|
1140
|
+
|
|
1141
|
+
## Reproduce the Bug
|
|
1142
|
+
|
|
1143
|
+
Bug report: {description}
|
|
1144
|
+
|
|
1145
|
+
1. Search for the relevant code paths
|
|
1146
|
+
2. Identify and confirm the reproduction steps
|
|
1147
|
+
3. Document the root cause
|
|
1148
|
+
|
|
1149
|
+
Call workflow_step with action='next' to advance to {nextPhaseName}.
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
**Project `webapp/.pi/workflows/hotfix/patch.md`:**
|
|
1153
|
+
|
|
1154
|
+
```markdown
|
|
1155
|
+
---
|
|
1156
|
+
id: hotfix-patch
|
|
1157
|
+
name: Patch
|
|
1158
|
+
emoji: "🩹"
|
|
1159
|
+
availableProfiles:
|
|
1160
|
+
- task-worker
|
|
1161
|
+
---
|
|
1162
|
+
|
|
1163
|
+
## Apply the Patch
|
|
1164
|
+
|
|
1165
|
+
Bug: {description}
|
|
1166
|
+
|
|
1167
|
+
Based on the reproduction from **{previousPhaseName}**, delegate the fix to a task-worker subagent.
|
|
1168
|
+
|
|
1169
|
+
Call workflow_step with action='next' when the patch is applied.
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
**Project `webapp/.pi/workflows/hotfix/verify.md`:**
|
|
1173
|
+
|
|
1174
|
+
```markdown
|
|
1175
|
+
---
|
|
1176
|
+
id: hotfix-verify
|
|
1177
|
+
name: Verify
|
|
1178
|
+
emoji: "✅"
|
|
1179
|
+
---
|
|
1180
|
+
|
|
1181
|
+
## Verify the Fix
|
|
1182
|
+
|
|
1183
|
+
Bug: {description}
|
|
1184
|
+
|
|
1185
|
+
Confirm the patch resolves the bug. Run tests and check for regressions.
|
|
1186
|
+
|
|
1187
|
+
Call workflow_step with action='next' to complete the hotfix.
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
### Result: What Each Project Sees
|
|
1191
|
+
|
|
1192
|
+
| Workflow | `~/projects/webapp` | `~/projects/api` | Any other project |
|
|
1193
|
+
| ------------- | :--------------------: | :--------------------: | :--------------------: |
|
|
1194
|
+
| `rpir` | Webapp-RPIR (5 phases) | Global RPIR (4 phases) | Global RPIR (4 phases) |
|
|
1195
|
+
| `code-review` | Global code-review | Global code-review | Global code-review |
|
|
1196
|
+
| `hotfix` | Webapp Hotfix Pipeline | API Hotfix Pipeline | _(not available)_ |
|
|
1197
|
+
|
|
1198
|
+
### Environment Variable Override
|
|
1199
|
+
|
|
1200
|
+
The global workflows root defaults to `~/.pi/agent/workflows/`. Set the `PI_CODING_AGENT_DIR` environment variable to change the base directory:
|
|
1201
|
+
|
|
1202
|
+
```bash
|
|
1203
|
+
export PI_CODING_AGENT_DIR="/opt/pi-agent"
|
|
1204
|
+
# Global workflows loaded from: /opt/pi-agent/workflows/
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
---
|
|
1208
|
+
|
|
1209
|
+
## Quick Reference
|
|
1210
|
+
|
|
1211
|
+
### `workflow_step` Actions
|
|
1212
|
+
|
|
1213
|
+
| Action | Description | When to Use |
|
|
1214
|
+
| -------- | --------------------------------------------------------- | ------------------------------------ |
|
|
1215
|
+
| `next` | Advance to the next phase (or DONE if last) | Phase work is complete |
|
|
1216
|
+
| `loop` | Restart the current scope from phase 0 | Review found issues; retry the cycle |
|
|
1217
|
+
| `status` | Show current workflow state, phase instructions, profiles | Need to check where you are |
|
|
1218
|
+
| `cancel` | Cancel the workflow (requires confirmation) | Workflow is wrong; abort it |
|
|
1219
|
+
|
|
1220
|
+
### Phase Frontmatter Fields
|
|
1221
|
+
|
|
1222
|
+
| Field | Required | Description |
|
|
1223
|
+
| ------------------- | -------- | ------------------------------------- |
|
|
1224
|
+
| `id` | **Yes** | Unique identifier within the workflow |
|
|
1225
|
+
| `name` | **Yes** | Display name |
|
|
1226
|
+
| `emoji` | **Yes** | Single emoji for UI |
|
|
1227
|
+
| `tools.blacklist` | No | Tools to block |
|
|
1228
|
+
| `tools.whitelist` | No | Only these tools allowed |
|
|
1229
|
+
| `availableProfiles` | No | Subagent profiles for this phase |
|
|
1230
|
+
|
|
1231
|
+
### workflow.yaml Key Fields
|
|
1232
|
+
|
|
1233
|
+
| Field | Required | Description |
|
|
1234
|
+
| ---------------- | ----------------------- | ------------------------------------------------------ |
|
|
1235
|
+
| `name` | **Yes** | Display name |
|
|
1236
|
+
| `commandName` | Yes (if `show: "user"`) | Slash command name |
|
|
1237
|
+
| `initialMessage` | Yes (if `show: "user"`) | Message sent on start |
|
|
1238
|
+
| `phases` | **Yes** | Array of `.md` filenames or `{ subworkflow: key }` |
|
|
1239
|
+
| `show` | No | `"user"` (default) or `"workflows"` (subworkflow-only) |
|
|
1240
|
+
| `loopable` | No | `true` (default) or `false` |
|
|
1241
|
+
|
|
1242
|
+
For complete field documentation, see [Configuration Reference](configuration-reference.md). For all available template variables, see [Template Variables](template-variables.md).
|