@davidorex/pi-workflows 0.2.0 → 0.3.1

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.
Files changed (216) hide show
  1. package/CHANGELOG.md +7 -4
  2. package/README.md +12 -2
  3. package/agents/architecture-designer.agent.yaml +58 -0
  4. package/agents/architecture-inferrer.agent.yaml +60 -0
  5. package/agents/gap-identifier.agent.yaml +66 -0
  6. package/agents/handoff-writer.agent.yaml +64 -0
  7. package/agents/plan-creator.agent.yaml +63 -0
  8. package/agents/project-definer.agent.yaml +53 -0
  9. package/agents/project-inferrer.agent.yaml +63 -0
  10. package/agents/requirements-gatherer.agent.yaml +58 -0
  11. package/dist/agent-spec.d.ts +27 -0
  12. package/dist/agent-spec.d.ts.map +1 -0
  13. package/dist/agent-spec.js +112 -0
  14. package/dist/agent-spec.js.map +1 -0
  15. package/dist/checkpoint.d.ts +50 -0
  16. package/dist/checkpoint.d.ts.map +1 -0
  17. package/dist/checkpoint.js +109 -0
  18. package/dist/checkpoint.js.map +1 -0
  19. package/dist/completion.d.ts +18 -0
  20. package/dist/completion.d.ts.map +1 -0
  21. package/dist/completion.js +58 -0
  22. package/dist/completion.js.map +1 -0
  23. package/dist/dag.d.ts +56 -0
  24. package/dist/dag.d.ts.map +1 -0
  25. package/dist/dag.js +178 -0
  26. package/dist/dag.js.map +1 -0
  27. package/dist/dispatch.d.ts +35 -0
  28. package/dist/dispatch.d.ts.map +1 -0
  29. package/dist/dispatch.js +311 -0
  30. package/dist/dispatch.js.map +1 -0
  31. package/dist/expression.d.ts +64 -0
  32. package/dist/expression.d.ts.map +1 -0
  33. package/dist/expression.js +294 -0
  34. package/dist/expression.js.map +1 -0
  35. package/dist/format.d.ts +19 -0
  36. package/dist/format.d.ts.map +1 -0
  37. package/dist/format.js +42 -0
  38. package/dist/format.js.map +1 -0
  39. package/dist/index.d.ts +8 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +724 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/output.d.ts +12 -0
  44. package/dist/output.d.ts.map +1 -0
  45. package/dist/output.js +59 -0
  46. package/dist/output.js.map +1 -0
  47. package/dist/state.d.ts +66 -0
  48. package/dist/state.d.ts.map +1 -0
  49. package/dist/state.js +227 -0
  50. package/dist/state.js.map +1 -0
  51. package/dist/step-agent.d.ts +35 -0
  52. package/dist/step-agent.d.ts.map +1 -0
  53. package/dist/step-agent.js +171 -0
  54. package/dist/step-agent.js.map +1 -0
  55. package/dist/step-command.d.ts +21 -0
  56. package/dist/step-command.d.ts.map +1 -0
  57. package/dist/step-command.js +150 -0
  58. package/dist/step-command.js.map +1 -0
  59. package/dist/step-foreach.d.ts +33 -0
  60. package/dist/step-foreach.d.ts.map +1 -0
  61. package/dist/step-foreach.js +112 -0
  62. package/dist/step-foreach.js.map +1 -0
  63. package/dist/step-gate.d.ts +18 -0
  64. package/dist/step-gate.d.ts.map +1 -0
  65. package/dist/step-gate.js +137 -0
  66. package/dist/step-gate.js.map +1 -0
  67. package/dist/step-loop.d.ts +32 -0
  68. package/dist/step-loop.d.ts.map +1 -0
  69. package/dist/step-loop.js +278 -0
  70. package/dist/step-loop.js.map +1 -0
  71. package/dist/step-monitor.d.ts +56 -0
  72. package/dist/step-monitor.d.ts.map +1 -0
  73. package/dist/step-monitor.js +317 -0
  74. package/dist/step-monitor.js.map +1 -0
  75. package/dist/step-parallel.d.ts +43 -0
  76. package/dist/step-parallel.d.ts.map +1 -0
  77. package/dist/step-parallel.js +122 -0
  78. package/dist/step-parallel.js.map +1 -0
  79. package/{src/step-pause.ts → dist/step-pause.d.ts} +3 -13
  80. package/dist/step-pause.d.ts.map +1 -0
  81. package/dist/step-pause.js +22 -0
  82. package/dist/step-pause.js.map +1 -0
  83. package/dist/step-shared.d.ts +63 -0
  84. package/dist/step-shared.d.ts.map +1 -0
  85. package/dist/step-shared.js +136 -0
  86. package/dist/step-shared.js.map +1 -0
  87. package/dist/step-transform.d.ts +11 -0
  88. package/dist/step-transform.d.ts.map +1 -0
  89. package/dist/step-transform.js +41 -0
  90. package/dist/step-transform.js.map +1 -0
  91. package/dist/template.d.ts +51 -0
  92. package/dist/template.d.ts.map +1 -0
  93. package/{src/template.ts → dist/template.js} +32 -38
  94. package/dist/template.js.map +1 -0
  95. package/dist/test-helpers.d.ts +17 -0
  96. package/dist/test-helpers.d.ts.map +1 -0
  97. package/dist/test-helpers.js +46 -0
  98. package/dist/test-helpers.js.map +1 -0
  99. package/dist/tui.d.ts +47 -0
  100. package/dist/tui.d.ts.map +1 -0
  101. package/dist/tui.js +143 -0
  102. package/dist/tui.js.map +1 -0
  103. package/dist/types.d.ts +165 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +3 -0
  106. package/dist/types.js.map +1 -0
  107. package/dist/workflow-discovery.d.ts +23 -0
  108. package/dist/workflow-discovery.d.ts.map +1 -0
  109. package/dist/workflow-discovery.js +103 -0
  110. package/dist/workflow-discovery.js.map +1 -0
  111. package/dist/workflow-executor.d.ts +50 -0
  112. package/dist/workflow-executor.d.ts.map +1 -0
  113. package/dist/workflow-executor.js +738 -0
  114. package/dist/workflow-executor.js.map +1 -0
  115. package/dist/workflow-sdk.d.ts +44 -0
  116. package/dist/workflow-sdk.d.ts.map +1 -0
  117. package/dist/workflow-sdk.js +457 -0
  118. package/dist/workflow-sdk.js.map +1 -0
  119. package/dist/workflow-spec.d.ts +33 -0
  120. package/dist/workflow-spec.d.ts.map +1 -0
  121. package/dist/workflow-spec.js +476 -0
  122. package/dist/workflow-spec.js.map +1 -0
  123. package/dist/workflows-dir.d.ts +3 -0
  124. package/dist/workflows-dir.d.ts.map +1 -0
  125. package/{src/workflows-dir.ts → dist/workflows-dir.js} +1 -0
  126. package/dist/workflows-dir.js.map +1 -0
  127. package/package.json +53 -38
  128. package/schemas/decomposition-specs.schema.json +48 -48
  129. package/schemas/execution-results.schema.json +48 -48
  130. package/schemas/investigation-findings.schema.json +43 -43
  131. package/schemas/pattern-analysis.schema.json +41 -41
  132. package/schemas/phase.schema.json +48 -0
  133. package/schemas/plan-breakdown.schema.json +20 -20
  134. package/schemas/quality-analysis.schema.json +33 -33
  135. package/schemas/research-findings.schema.json +42 -42
  136. package/schemas/structure-analysis.schema.json +40 -40
  137. package/schemas/synthesis.schema.json +31 -31
  138. package/schemas/verifier-output.schema.json +94 -94
  139. package/skill-narrative.md +107 -0
  140. package/skills/pi-workflows/SKILL.md +185 -0
  141. package/skills/pi-workflows/references/bundled-resources.md +87 -0
  142. package/templates/architecture-designer/task.md +117 -0
  143. package/templates/architecture-inferrer/task.md +61 -0
  144. package/templates/gap-identifier/task.md +103 -0
  145. package/templates/handoff-writer/task.md +91 -0
  146. package/templates/plan-creator/task.md +143 -0
  147. package/templates/project-definer/task.md +67 -0
  148. package/templates/project-inferrer/task.md +56 -0
  149. package/templates/requirements-gatherer/task.md +90 -0
  150. package/workflows/analyze-existing-project.workflow.yaml +94 -0
  151. package/workflows/create-handoff.workflow.yaml +66 -0
  152. package/workflows/create-phase.workflow.yaml +1 -1
  153. package/workflows/do-gap.workflow.yaml +4 -4
  154. package/workflows/fix-audit.workflow.yaml +1 -1
  155. package/workflows/gap-to-phase.workflow.yaml +1 -1
  156. package/workflows/init-new-project.workflow.yaml +81 -0
  157. package/workflows/plan-from-requirements.workflow.yaml +59 -0
  158. package/workflows/self-implement.workflow.yaml +3 -3
  159. package/workflows/typed-analysis.workflow.yaml +4 -4
  160. package/src/agent-spec.test.ts +0 -289
  161. package/src/agent-spec.ts +0 -122
  162. package/src/block-validation.test.ts +0 -350
  163. package/src/checkpoint.test.ts +0 -237
  164. package/src/checkpoint.ts +0 -140
  165. package/src/completion.test.ts +0 -143
  166. package/src/completion.ts +0 -68
  167. package/src/dag.test.ts +0 -350
  168. package/src/dag.ts +0 -219
  169. package/src/dispatch.test.ts +0 -475
  170. package/src/dispatch.ts +0 -353
  171. package/src/expression.test.ts +0 -353
  172. package/src/expression.ts +0 -332
  173. package/src/format.test.ts +0 -80
  174. package/src/format.ts +0 -41
  175. package/src/graduated-failure.test.ts +0 -556
  176. package/src/index.test.ts +0 -114
  177. package/src/index.ts +0 -516
  178. package/src/loop.test.ts +0 -551
  179. package/src/output.test.ts +0 -213
  180. package/src/output.ts +0 -70
  181. package/src/parallel-integration.test.ts +0 -175
  182. package/src/resume.test.ts +0 -192
  183. package/src/state.test.ts +0 -192
  184. package/src/state.ts +0 -254
  185. package/src/step-agent.test.ts +0 -327
  186. package/src/step-agent.ts +0 -178
  187. package/src/step-command.test.ts +0 -330
  188. package/src/step-command.ts +0 -132
  189. package/src/step-foreach.test.ts +0 -647
  190. package/src/step-foreach.ts +0 -148
  191. package/src/step-gate.test.ts +0 -185
  192. package/src/step-gate.ts +0 -116
  193. package/src/step-loop.test.ts +0 -626
  194. package/src/step-loop.ts +0 -323
  195. package/src/step-parallel.test.ts +0 -475
  196. package/src/step-parallel.ts +0 -168
  197. package/src/step-pause.test.ts +0 -30
  198. package/src/step-shared.test.ts +0 -355
  199. package/src/step-shared.ts +0 -157
  200. package/src/step-transform.test.ts +0 -155
  201. package/src/step-transform.ts +0 -47
  202. package/src/template-integration.test.ts +0 -72
  203. package/src/template.test.ts +0 -162
  204. package/src/test-helpers.ts +0 -51
  205. package/src/tui.test.ts +0 -355
  206. package/src/tui.ts +0 -182
  207. package/src/types.ts +0 -195
  208. package/src/verifier-schema.test.ts +0 -226
  209. package/src/workflow-discovery.test.ts +0 -105
  210. package/src/workflow-discovery.ts +0 -114
  211. package/src/workflow-executor.test.ts +0 -1532
  212. package/src/workflow-executor.ts +0 -810
  213. package/src/workflow-sdk.test.ts +0 -238
  214. package/src/workflow-sdk.ts +0 -262
  215. package/src/workflow-spec.test.ts +0 -576
  216. package/src/workflow-spec.ts +0 -471
@@ -1,42 +1,42 @@
1
1
  {
2
- "type": "object",
3
- "required": ["architecture", "modules", "dependencies"],
4
- "properties": {
5
- "architecture": {
6
- "type": "object",
7
- "required": ["patterns", "organization"],
8
- "properties": {
9
- "patterns": { "type": "array", "items": { "type": "string" } },
10
- "organization": { "type": "string" }
11
- }
12
- },
13
- "modules": {
14
- "type": "array",
15
- "items": {
16
- "type": "object",
17
- "required": ["name", "responsibility", "files"],
18
- "properties": {
19
- "name": { "type": "string" },
20
- "responsibility": { "type": "string" },
21
- "files": { "type": "array", "items": { "type": "string" } }
22
- }
23
- }
24
- },
25
- "dependencies": {
26
- "type": "array",
27
- "items": {
28
- "type": "object",
29
- "required": ["from", "to", "type"],
30
- "properties": {
31
- "from": { "type": "string" },
32
- "to": { "type": "string" },
33
- "type": { "type": "string", "enum": ["import", "runtime", "config"] }
34
- }
35
- }
36
- },
37
- "entryPoints": {
38
- "type": "array",
39
- "items": { "type": "string" }
40
- }
41
- }
2
+ "type": "object",
3
+ "required": ["architecture", "modules", "dependencies"],
4
+ "properties": {
5
+ "architecture": {
6
+ "type": "object",
7
+ "required": ["patterns", "organization"],
8
+ "properties": {
9
+ "patterns": { "type": "array", "items": { "type": "string" } },
10
+ "organization": { "type": "string" }
11
+ }
12
+ },
13
+ "modules": {
14
+ "type": "array",
15
+ "items": {
16
+ "type": "object",
17
+ "required": ["name", "responsibility", "files"],
18
+ "properties": {
19
+ "name": { "type": "string" },
20
+ "responsibility": { "type": "string" },
21
+ "files": { "type": "array", "items": { "type": "string" } }
22
+ }
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "object",
29
+ "required": ["from", "to", "type"],
30
+ "properties": {
31
+ "from": { "type": "string" },
32
+ "to": { "type": "string" },
33
+ "type": { "type": "string", "enum": ["import", "runtime", "config"] }
34
+ }
35
+ }
36
+ },
37
+ "entryPoints": {
38
+ "type": "array",
39
+ "items": { "type": "string" }
40
+ }
41
+ }
42
42
  }
@@ -1,33 +1,33 @@
1
1
  {
2
- "type": "object",
3
- "required": ["summary", "findings", "recommendations"],
4
- "properties": {
5
- "summary": { "type": "string" },
6
- "findings": {
7
- "type": "array",
8
- "items": {
9
- "type": "object",
10
- "required": ["category", "description", "severity"],
11
- "properties": {
12
- "category": { "type": "string", "enum": ["structure", "quality", "patterns"] },
13
- "description": { "type": "string" },
14
- "severity": { "type": "string", "enum": ["info", "warning", "critical"] },
15
- "files": { "type": "array", "items": { "type": "string" } }
16
- }
17
- }
18
- },
19
- "recommendations": {
20
- "type": "array",
21
- "items": {
22
- "type": "object",
23
- "required": ["action", "rationale", "priority"],
24
- "properties": {
25
- "action": { "type": "string" },
26
- "rationale": { "type": "string" },
27
- "priority": { "type": "string", "enum": ["high", "medium", "low"] },
28
- "affectedFiles": { "type": "array", "items": { "type": "string" } }
29
- }
30
- }
31
- }
32
- }
2
+ "type": "object",
3
+ "required": ["summary", "findings", "recommendations"],
4
+ "properties": {
5
+ "summary": { "type": "string" },
6
+ "findings": {
7
+ "type": "array",
8
+ "items": {
9
+ "type": "object",
10
+ "required": ["category", "description", "severity"],
11
+ "properties": {
12
+ "category": { "type": "string", "enum": ["structure", "quality", "patterns"] },
13
+ "description": { "type": "string" },
14
+ "severity": { "type": "string", "enum": ["info", "warning", "critical"] },
15
+ "files": { "type": "array", "items": { "type": "string" } }
16
+ }
17
+ }
18
+ },
19
+ "recommendations": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "object",
23
+ "required": ["action", "rationale", "priority"],
24
+ "properties": {
25
+ "action": { "type": "string" },
26
+ "rationale": { "type": "string" },
27
+ "priority": { "type": "string", "enum": ["high", "medium", "low"] },
28
+ "affectedFiles": { "type": "array", "items": { "type": "string" } }
29
+ }
30
+ }
31
+ }
32
+ }
33
33
  }
@@ -1,96 +1,96 @@
1
1
  {
2
- "type": "object",
3
- "required": ["status", "score", "truths", "criteria_results"],
4
- "properties": {
5
- "status": {
6
- "type": "string",
7
- "enum": ["passed", "gaps_found", "human_needed"]
8
- },
9
- "score": {
10
- "type": "string",
11
- "description": "Score in N/M format (e.g. '5/7')"
12
- },
13
- "truths": {
14
- "type": "array",
15
- "items": {
16
- "type": "object",
17
- "required": ["truth", "status", "evidence"],
18
- "properties": {
19
- "truth": { "type": "string" },
20
- "status": { "type": "string", "enum": ["verified", "failed", "uncertain"] },
21
- "evidence": { "type": "string" }
22
- }
23
- }
24
- },
25
- "artifacts": {
26
- "type": "array",
27
- "items": {
28
- "type": "object",
29
- "required": ["path", "status"],
30
- "properties": {
31
- "path": { "type": "string" },
32
- "status": { "type": "string", "enum": ["verified", "stub", "missing"] },
33
- "exists": { "type": "boolean" },
34
- "substantive": { "type": "boolean" },
35
- "wired": { "type": "boolean" },
36
- "details": { "type": "string" }
37
- }
38
- }
39
- },
40
- "requirements_coverage": {
41
- "type": "array",
42
- "items": {
43
- "type": "object",
44
- "required": ["requirement_id", "status"],
45
- "properties": {
46
- "requirement_id": { "type": "string" },
47
- "status": { "type": "string", "enum": ["satisfied", "blocked", "needs_human"] },
48
- "supporting_truths": {
49
- "type": "array",
50
- "items": { "type": "string" }
51
- }
52
- }
53
- }
54
- },
55
- "criteria_results": {
56
- "type": "array",
57
- "items": {
58
- "type": "object",
59
- "required": ["criterion", "verify_method", "status"],
60
- "properties": {
61
- "criterion": { "type": "string" },
62
- "verify_method": { "type": "string", "enum": ["command", "grep", "inspect"] },
63
- "status": { "type": "string", "enum": ["passed", "failed", "uncertain", "skipped"] },
64
- "expected_outcome": { "type": "string" },
65
- "actual_outcome": { "type": "string" },
66
- "evidence": { "type": "string" }
67
- }
68
- }
69
- },
70
- "human_verification": {
71
- "type": "array",
72
- "items": {
73
- "type": "object",
74
- "required": ["name", "test", "expected", "why_human"],
75
- "properties": {
76
- "name": { "type": "string" },
77
- "test": { "type": "string" },
78
- "expected": { "type": "string" },
79
- "why_human": { "type": "string" }
80
- }
81
- }
82
- },
83
- "gaps": {
84
- "type": "array",
85
- "items": {
86
- "type": "object",
87
- "required": ["truth", "status", "reason"],
88
- "properties": {
89
- "truth": { "type": "string" },
90
- "status": { "type": "string" },
91
- "reason": { "type": "string" }
92
- }
93
- }
94
- }
95
- }
2
+ "type": "object",
3
+ "required": ["status", "score", "truths", "criteria_results"],
4
+ "properties": {
5
+ "status": {
6
+ "type": "string",
7
+ "enum": ["passed", "gaps_found", "human_needed"]
8
+ },
9
+ "score": {
10
+ "type": "string",
11
+ "description": "Score in N/M format (e.g. '5/7')"
12
+ },
13
+ "truths": {
14
+ "type": "array",
15
+ "items": {
16
+ "type": "object",
17
+ "required": ["truth", "status", "evidence"],
18
+ "properties": {
19
+ "truth": { "type": "string" },
20
+ "status": { "type": "string", "enum": ["verified", "failed", "uncertain"] },
21
+ "evidence": { "type": "string" }
22
+ }
23
+ }
24
+ },
25
+ "artifacts": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "object",
29
+ "required": ["path", "status"],
30
+ "properties": {
31
+ "path": { "type": "string" },
32
+ "status": { "type": "string", "enum": ["verified", "stub", "missing"] },
33
+ "exists": { "type": "boolean" },
34
+ "substantive": { "type": "boolean" },
35
+ "wired": { "type": "boolean" },
36
+ "details": { "type": "string" }
37
+ }
38
+ }
39
+ },
40
+ "requirements_coverage": {
41
+ "type": "array",
42
+ "items": {
43
+ "type": "object",
44
+ "required": ["requirement_id", "status"],
45
+ "properties": {
46
+ "requirement_id": { "type": "string" },
47
+ "status": { "type": "string", "enum": ["satisfied", "blocked", "needs_human"] },
48
+ "supporting_truths": {
49
+ "type": "array",
50
+ "items": { "type": "string" }
51
+ }
52
+ }
53
+ }
54
+ },
55
+ "criteria_results": {
56
+ "type": "array",
57
+ "items": {
58
+ "type": "object",
59
+ "required": ["criterion", "verify_method", "status"],
60
+ "properties": {
61
+ "criterion": { "type": "string" },
62
+ "verify_method": { "type": "string", "enum": ["command", "grep", "inspect"] },
63
+ "status": { "type": "string", "enum": ["passed", "failed", "uncertain", "skipped"] },
64
+ "expected_outcome": { "type": "string" },
65
+ "actual_outcome": { "type": "string" },
66
+ "evidence": { "type": "string" }
67
+ }
68
+ }
69
+ },
70
+ "human_verification": {
71
+ "type": "array",
72
+ "items": {
73
+ "type": "object",
74
+ "required": ["name", "test", "expected", "why_human"],
75
+ "properties": {
76
+ "name": { "type": "string" },
77
+ "test": { "type": "string" },
78
+ "expected": { "type": "string" },
79
+ "why_human": { "type": "string" }
80
+ }
81
+ }
82
+ },
83
+ "gaps": {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "object",
87
+ "required": ["truth", "status", "reason"],
88
+ "properties": {
89
+ "truth": { "type": "string" },
90
+ "status": { "type": "string" },
91
+ "reason": { "type": "string" }
92
+ }
93
+ }
94
+ }
95
+ }
96
96
  }
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: pi-workflows
3
+ description: >
4
+ Orchestrates multi-step agent workflows defined in YAML with DAG-based execution,
5
+ typed data flow, checkpoint/resume, and output validation. Use when running workflows,
6
+ authoring workflow specs, debugging step failures, or inspecting agent configurations.
7
+ ---
8
+
9
+ <objective>
10
+ pi-workflows orchestrates multi-step agent workflows defined in YAML. Workflows are DAGs of typed steps with data flow via `${{ }}` expressions.
11
+ </objective>
12
+
13
+ <workflow_discovery>
14
+ Workflows are discovered from three locations (first match wins):
15
+ 1. `.workflows/*.workflow.yaml` — project-level
16
+ 2. `~/.pi/agent/workflows/*.workflow.yaml` — user-level
17
+ 3. Package bundled `workflows/` — built-in
18
+ </workflow_discovery>
19
+
20
+ <step_types>
21
+ | Type | Field | Description |
22
+ |------|-------|-------------|
23
+ | agent | `agent: name` | Dispatch an LLM subprocess via `pi --mode json` |
24
+ | command | `command: "..."` | Run a shell command, capture stdout as output |
25
+ | monitor | `monitor: name` | Run a monitor classification as a verification gate |
26
+ | transform | `transform: { mapping: {...} }` | Pure data transformation via expressions, no LLM |
27
+ | gate | `gate: { check: "..." }` | Shell command exit code as pass/fail boolean |
28
+ | loop | `loop: { maxAttempts, steps }` | Repeat sub-steps until gate breaks or max reached |
29
+ | parallel | `parallel: { a: ..., b: ... }` | Run named sub-steps concurrently |
30
+ | pause | `pause: true` or `pause: "message"` | Pause execution, resumable later |
31
+ | forEach | `forEach: "${{ expr }}"` | Iterate over an array, executing the step per element |
32
+ </step_types>
33
+
34
+ <expression_syntax>
35
+ `${{ expression }}` resolves against scope: `input`, `steps`, `loop`, `forEach`.
36
+
37
+ Access step outputs: `${{ steps.investigate.output.findings }}`
38
+ Filters: `${{ steps.analyze.output | json }}`, `${{ items | length }}`, `${{ name | upper }}`
39
+
40
+ Available filters: length, keys, filter, json, upper, lower, trim, default, first, last, join, split, replace, includes, map, sum, min, max, sort, unique, flatten, zip, group_by, count_by, chunk, pick, omit, entries, from_entries, merge, values, not, and, or.
41
+ </expression_syntax>
42
+
43
+ <agent_resolution>
44
+ Agent specs (`.agent.yaml`) are resolved from three locations (first match wins):
45
+ 1. `.pi/agents/<name>.agent.yaml` — project-level
46
+ 2. `~/.pi/agent/agents/<name>.agent.yaml` — user-level
47
+ 3. Package bundled `agents/<name>.agent.yaml` — built-in
48
+
49
+ Agent specs define: model, thinking level, tools, system prompt (or template), task template, output format/schema.
50
+ </agent_resolution>
51
+
52
+ <execution_model>
53
+ 1. Steps are ordered by YAML declaration order
54
+ 2. DAG planner infers parallelism from `${{ steps.X }}` references
55
+ 3. Steps without explicit dependencies run after their predecessor (conservative sequential)
56
+ 4. Each step's result is persisted atomically to `<runDir>/state.json`
57
+ 5. TUI progress widget shows real-time step status, cost, and timing
58
+ </execution_model>
59
+
60
+ <checkpoint_resume>
61
+ Incomplete runs (failed or paused) are detected on next invocation. If the workflow spec hasn't changed incompatibly, execution resumes from the last completed step. Failed steps are re-executed. Use `fresh: "true"` to force a new run.
62
+ </checkpoint_resume>
63
+
64
+ <output_validation>
65
+ Steps with `output.schema` validate the agent's JSON output against a JSON Schema file. Validation failure marks the step as failed.
66
+
67
+ Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `.project/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
68
+ </output_validation>
69
+
70
+ <retry>
71
+ Steps with `retry: { maxAttempts: N }` are re-executed on failure. Between retries:
72
+ - Project block files are rolled back to pre-attempt state
73
+ - Prior error messages are injected into the prompt
74
+ - Optional `steeringMessage` provides custom retry guidance
75
+ </retry>
76
+
77
+ <completion_messages>
78
+ After execution, the workflow result is injected into the main LLM conversation. The `completion` field controls this: either a `template` (full `${{ }}` template) or `message` + `include` (message text plus resolved data paths).
79
+ </completion_messages>
80
+
81
+ <artifacts>
82
+ Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `.project/*.json` are routed through `writeBlock()` for schema validation.
83
+
84
+ Block artifact write failures are fatal — if the data doesn't conform to the block's schema, the workflow fails. Non-block artifact failures remain non-fatal (warning). On resume, all steps are preserved; only artifact processing re-runs, so fixing the schema issue or agent output and resuming avoids re-running expensive LLM steps.
85
+ </artifacts>
86
+
87
+ <validation>
88
+ `validateWorkflow(spec, cwd)` runs authoring-time checks without executing the workflow:
89
+
90
+ 1. **Agent resolution** — all referenced agents exist in the three-tier search
91
+ 2. **Monitor resolution** — all referenced monitors exist in .pi/monitors/ or built-in examples
92
+ 3. **Schema resolution** — all output schema file paths resolve to existing files
93
+ 4. **Step reference validity** — `${{ steps.X }}` expressions reference declared steps
94
+ 5. **Step ordering** — referenced steps are declared before the referencing step
95
+ 6. **Filter name validity** — `${{ value | filter }}` uses known filter names
96
+
97
+ Returns `{ valid: boolean, issues: ValidationIssue[] }` where each issue has severity, message, and field path. Use `/workflow validate` or `/workflow validate <name>` to run from the command line.
98
+ </validation>
99
+
100
+ <success_criteria>
101
+ - Workflow completes all steps without unhandled failures
102
+ - Step outputs match declared output schemas
103
+ - State is persisted atomically after each step
104
+ - Completion message is delivered to main conversation
105
+ - `/workflow validate` returns no errors for authored specs
106
+ - Checkpoint/resume recovers from the last completed step
107
+ </success_criteria>
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: pi-workflows
3
+ description: >
4
+ Orchestrates multi-step agent workflows defined in YAML with DAG-based
5
+ execution, typed data flow, checkpoint/resume, and output validation. Use when
6
+ running workflows, authoring workflow specs, debugging step failures, or
7
+ inspecting agent configurations.
8
+ ---
9
+
10
+ <tools_reference>
11
+ <tool name="workflow">
12
+ Run a named workflow with typed input. Discovers workflows from .workflows/ and ~/.pi/agent/workflows/.
13
+
14
+ *Run a multi-step workflow with typed data flow between agents*
15
+
16
+ | Parameter | Type | Required | Description |
17
+ |-----------|------|----------|-------------|
18
+ | `workflow` | string | yes | Name of the workflow to run |
19
+ | `input` | unknown | no | Input data for the workflow (validated against workflow's input schema) |
20
+ | `fresh` | string | no | Set to 'true' to start a fresh run, ignoring any incomplete prior runs |
21
+ </tool>
22
+
23
+ <tool name="workflow-list">
24
+ List available workflows with names, descriptions, and sources.
25
+
26
+ *List available workflows with names, descriptions, and sources*
27
+
28
+ </tool>
29
+
30
+ <tool name="workflow-agents">
31
+ List available agents with full specs, or inspect a single agent by name. Returns role, description, model, tools, output format/schema, prompt template paths.
32
+
33
+ *List available agents with specs, or inspect a single agent by name*
34
+
35
+ | Parameter | Type | Required | Description |
36
+ |-----------|------|----------|-------------|
37
+ | `name` | string | no | Agent name to inspect (omit to list all) |
38
+ </tool>
39
+
40
+ <tool name="workflow-validate">
41
+ Validate workflow specs — check agents, schemas, step references, and filters.
42
+
43
+ *Validate workflow specs — check agents, schemas, step references, filters*
44
+
45
+ | Parameter | Type | Required | Description |
46
+ |-----------|------|----------|-------------|
47
+ | `name` | string | no | Workflow name to validate (omit to validate all) |
48
+ </tool>
49
+
50
+ <tool name="workflow-status">
51
+ Get workflow vocabulary — step types, filters, available agents, workflows, schemas, templates.
52
+
53
+ *Get workflow vocabulary — step types, filters, available agents, workflows, schemas*
54
+
55
+ </tool>
56
+
57
+ <tool name="workflow-init">
58
+ Initialize .workflows/ directory for workflow run state.
59
+
60
+ *Initialize .workflows/ directory for workflow run state*
61
+
62
+ </tool>
63
+
64
+ </tools_reference>
65
+
66
+ <commands_reference>
67
+ <command name="/workflow">
68
+ List and run workflows
69
+
70
+ Subcommands: `init`, `run`, `list`, `resume`, `validate`, `status`
71
+ </command>
72
+
73
+ </commands_reference>
74
+
75
+ <keyboard_shortcuts>
76
+ - **ctrl+h** — Pause running workflow
77
+ - **ctrl+j** — Resume paused workflow
78
+ </keyboard_shortcuts>
79
+
80
+ <bundled_resources>
81
+ 21 agents, 11 schemas, 14 workflows, 28 templates bundled.
82
+ See references/bundled-resources.md for full inventory.
83
+ </bundled_resources>
84
+
85
+ <objective>
86
+ pi-workflows orchestrates multi-step agent workflows defined in YAML. Workflows are DAGs of typed steps with data flow via `${{ }}` expressions.
87
+ </objective>
88
+
89
+ <workflow_discovery>
90
+ Workflows are discovered from three locations (first match wins):
91
+ 1. `.workflows/*.workflow.yaml` — project-level
92
+ 2. `~/.pi/agent/workflows/*.workflow.yaml` — user-level
93
+ 3. Package bundled `workflows/` — built-in
94
+ </workflow_discovery>
95
+
96
+ <step_types>
97
+ | Type | Field | Description |
98
+ |------|-------|-------------|
99
+ | agent | `agent: name` | Dispatch an LLM subprocess via `pi --mode json` |
100
+ | command | `command: "..."` | Run a shell command, capture stdout as output |
101
+ | monitor | `monitor: name` | Run a monitor classification as a verification gate |
102
+ | transform | `transform: { mapping: {...} }` | Pure data transformation via expressions, no LLM |
103
+ | gate | `gate: { check: "..." }` | Shell command exit code as pass/fail boolean |
104
+ | loop | `loop: { maxAttempts, steps }` | Repeat sub-steps until gate breaks or max reached |
105
+ | parallel | `parallel: { a: ..., b: ... }` | Run named sub-steps concurrently |
106
+ | pause | `pause: true` or `pause: "message"` | Pause execution, resumable later |
107
+ | forEach | `forEach: "${{ expr }}"` | Iterate over an array, executing the step per element |
108
+ </step_types>
109
+
110
+ <expression_syntax>
111
+ `${{ expression }}` resolves against scope: `input`, `steps`, `loop`, `forEach`.
112
+
113
+ Access step outputs: `${{ steps.investigate.output.findings }}`
114
+ Filters: `${{ steps.analyze.output | json }}`, `${{ items | length }}`, `${{ name | upper }}`
115
+
116
+ Available filters: length, keys, filter, json, upper, lower, trim, default, first, last, join, split, replace, includes, map, sum, min, max, sort, unique, flatten, zip, group_by, count_by, chunk, pick, omit, entries, from_entries, merge, values, not, and, or.
117
+ </expression_syntax>
118
+
119
+ <agent_resolution>
120
+ Agent specs (`.agent.yaml`) are resolved from three locations (first match wins):
121
+ 1. `.pi/agents/<name>.agent.yaml` — project-level
122
+ 2. `~/.pi/agent/agents/<name>.agent.yaml` — user-level
123
+ 3. Package bundled `agents/<name>.agent.yaml` — built-in
124
+
125
+ Agent specs define: model, thinking level, tools, system prompt (or template), task template, output format/schema.
126
+ </agent_resolution>
127
+
128
+ <execution_model>
129
+ 1. Steps are ordered by YAML declaration order
130
+ 2. DAG planner infers parallelism from `${{ steps.X }}` references
131
+ 3. Steps without explicit dependencies run after their predecessor (conservative sequential)
132
+ 4. Each step's result is persisted atomically to `<runDir>/state.json`
133
+ 5. TUI progress widget shows real-time step status, cost, and timing
134
+ </execution_model>
135
+
136
+ <checkpoint_resume>
137
+ Incomplete runs (failed or paused) are detected on next invocation. If the workflow spec hasn't changed incompatibly, execution resumes from the last completed step. Failed steps are re-executed. Use `fresh: "true"` to force a new run.
138
+ </checkpoint_resume>
139
+
140
+ <output_validation>
141
+ Steps with `output.schema` validate the agent's JSON output against a JSON Schema file. Validation failure marks the step as failed.
142
+
143
+ Use `block:<name>` to reference project block schemas portably: `output.schema: block:project` resolves to `.project/schemas/project.schema.json` from cwd. Works across monorepo, npm install, and user-customized schemas. Combined with `retry: { maxAttempts: 2 }`, the agent gets the schema validation error injected into its retry prompt and can self-correct.
144
+ </output_validation>
145
+
146
+ <retry>
147
+ Steps with `retry: { maxAttempts: N }` are re-executed on failure. Between retries:
148
+ - Project block files are rolled back to pre-attempt state
149
+ - Prior error messages are injected into the prompt
150
+ - Optional `steeringMessage` provides custom retry guidance
151
+ </retry>
152
+
153
+ <completion_messages>
154
+ After execution, the workflow result is injected into the main LLM conversation. The `completion` field controls this: either a `template` (full `${{ }}` template) or `message` + `include` (message text plus resolved data paths).
155
+ </completion_messages>
156
+
157
+ <artifacts>
158
+ Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `.project/*.json` are routed through `writeBlock()` for schema validation.
159
+
160
+ Block artifact write failures are fatal — if the data doesn't conform to the block's schema, the workflow fails. Non-block artifact failures remain non-fatal (warning). On resume, all steps are preserved; only artifact processing re-runs, so fixing the schema issue or agent output and resuming avoids re-running expensive LLM steps.
161
+ </artifacts>
162
+
163
+ <validation>
164
+ `validateWorkflow(spec, cwd)` runs authoring-time checks without executing the workflow:
165
+
166
+ 1. **Agent resolution** — all referenced agents exist in the three-tier search
167
+ 2. **Monitor resolution** — all referenced monitors exist in .pi/monitors/ or built-in examples
168
+ 3. **Schema resolution** — all output schema file paths resolve to existing files
169
+ 4. **Step reference validity** — `${{ steps.X }}` expressions reference declared steps
170
+ 5. **Step ordering** — referenced steps are declared before the referencing step
171
+ 6. **Filter name validity** — `${{ value | filter }}` uses known filter names
172
+
173
+ Returns `{ valid: boolean, issues: ValidationIssue[] }` where each issue has severity, message, and field path. Use `/workflow validate` or `/workflow validate <name>` to run from the command line.
174
+ </validation>
175
+
176
+ <success_criteria>
177
+ - Workflow completes all steps without unhandled failures
178
+ - Step outputs match declared output schemas
179
+ - State is persisted atomically after each step
180
+ - Completion message is delivered to main conversation
181
+ - `/workflow validate` returns no errors for authored specs
182
+ - Checkpoint/resume recovers from the last completed step
183
+ </success_criteria>
184
+
185
+ *Generated from source by `scripts/generate-skills.js` — do not edit by hand.*