@davidorex/pi-workflows 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.
Files changed (215) 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 +172 -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 +675 -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 +156 -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 +57 -0
  84. package/dist/step-shared.d.ts.map +1 -0
  85. package/dist/step-shared.js +125 -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 +164 -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 +726 -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 +438 -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 +464 -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 +84 -0
  140. package/skills/pi-workflows/SKILL.md +247 -0
  141. package/templates/architecture-designer/task.md +117 -0
  142. package/templates/architecture-inferrer/task.md +61 -0
  143. package/templates/gap-identifier/task.md +103 -0
  144. package/templates/handoff-writer/task.md +91 -0
  145. package/templates/plan-creator/task.md +143 -0
  146. package/templates/project-definer/task.md +67 -0
  147. package/templates/project-inferrer/task.md +56 -0
  148. package/templates/requirements-gatherer/task.md +90 -0
  149. package/workflows/analyze-existing-project.workflow.yaml +74 -0
  150. package/workflows/create-handoff.workflow.yaml +58 -0
  151. package/workflows/create-phase.workflow.yaml +1 -1
  152. package/workflows/do-gap.workflow.yaml +4 -4
  153. package/workflows/fix-audit.workflow.yaml +1 -1
  154. package/workflows/gap-to-phase.workflow.yaml +1 -1
  155. package/workflows/init-new-project.workflow.yaml +55 -0
  156. package/workflows/plan-from-requirements.workflow.yaml +51 -0
  157. package/workflows/self-implement.workflow.yaml +3 -3
  158. package/workflows/typed-analysis.workflow.yaml +4 -4
  159. package/src/agent-spec.test.ts +0 -289
  160. package/src/agent-spec.ts +0 -122
  161. package/src/block-validation.test.ts +0 -350
  162. package/src/checkpoint.test.ts +0 -237
  163. package/src/checkpoint.ts +0 -140
  164. package/src/completion.test.ts +0 -143
  165. package/src/completion.ts +0 -68
  166. package/src/dag.test.ts +0 -350
  167. package/src/dag.ts +0 -219
  168. package/src/dispatch.test.ts +0 -475
  169. package/src/dispatch.ts +0 -353
  170. package/src/expression.test.ts +0 -353
  171. package/src/expression.ts +0 -332
  172. package/src/format.test.ts +0 -80
  173. package/src/format.ts +0 -41
  174. package/src/graduated-failure.test.ts +0 -556
  175. package/src/index.test.ts +0 -114
  176. package/src/index.ts +0 -516
  177. package/src/loop.test.ts +0 -551
  178. package/src/output.test.ts +0 -213
  179. package/src/output.ts +0 -70
  180. package/src/parallel-integration.test.ts +0 -175
  181. package/src/resume.test.ts +0 -192
  182. package/src/state.test.ts +0 -192
  183. package/src/state.ts +0 -254
  184. package/src/step-agent.test.ts +0 -327
  185. package/src/step-agent.ts +0 -178
  186. package/src/step-command.test.ts +0 -330
  187. package/src/step-command.ts +0 -132
  188. package/src/step-foreach.test.ts +0 -647
  189. package/src/step-foreach.ts +0 -148
  190. package/src/step-gate.test.ts +0 -185
  191. package/src/step-gate.ts +0 -116
  192. package/src/step-loop.test.ts +0 -626
  193. package/src/step-loop.ts +0 -323
  194. package/src/step-parallel.test.ts +0 -475
  195. package/src/step-parallel.ts +0 -168
  196. package/src/step-pause.test.ts +0 -30
  197. package/src/step-shared.test.ts +0 -355
  198. package/src/step-shared.ts +0 -157
  199. package/src/step-transform.test.ts +0 -155
  200. package/src/step-transform.ts +0 -47
  201. package/src/template-integration.test.ts +0 -72
  202. package/src/template.test.ts +0 -162
  203. package/src/test-helpers.ts +0 -51
  204. package/src/tui.test.ts +0 -355
  205. package/src/tui.ts +0 -182
  206. package/src/types.ts +0 -195
  207. package/src/verifier-schema.test.ts +0 -226
  208. package/src/workflow-discovery.test.ts +0 -105
  209. package/src/workflow-discovery.ts +0 -114
  210. package/src/workflow-executor.test.ts +0 -1532
  211. package/src/workflow-executor.ts +0 -810
  212. package/src/workflow-sdk.test.ts +0 -238
  213. package/src/workflow-sdk.ts +0 -262
  214. package/src/workflow-spec.test.ts +0 -576
  215. 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,84 @@
1
+ ## How It Works
2
+
3
+ pi-workflows orchestrates multi-step agent workflows defined in YAML. Workflows are DAGs of typed steps with data flow via `${{ }}` expressions.
4
+
5
+ ### Workflow Discovery
6
+
7
+ Workflows are discovered from three locations (first match wins):
8
+ 1. `.workflows/*.workflow.yaml` — project-level
9
+ 2. `~/.pi/agent/workflows/*.workflow.yaml` — user-level
10
+ 3. Package bundled `workflows/` — built-in
11
+
12
+ ### Step Types
13
+
14
+ | Type | Field | Description |
15
+ |------|-------|-------------|
16
+ | agent | `agent: name` | Dispatch an LLM subprocess via `pi --mode json` |
17
+ | command | `command: "..."` | Run a shell command, capture stdout as output |
18
+ | transform | `transform: { mapping: {...} }` | Pure data transformation via expressions, no LLM |
19
+ | gate | `gate: { check: "..." }` | Shell command exit code as pass/fail boolean |
20
+ | loop | `loop: { maxAttempts, steps }` | Repeat sub-steps until gate breaks or max reached |
21
+ | parallel | `parallel: { a: ..., b: ... }` | Run named sub-steps concurrently |
22
+ | pause | `pause: true` or `pause: "message"` | Pause execution, resumable later |
23
+ | forEach | `forEach: "${{ expr }}"` | Iterate over an array, executing the step per element |
24
+
25
+ ### Expression Syntax
26
+
27
+ `${{ expression }}` resolves against scope: `input`, `steps`, `loop`, `forEach`.
28
+
29
+ Access step outputs: `${{ steps.investigate.output.findings }}`
30
+ Filters: `${{ steps.analyze.output | json }}`, `${{ items | length }}`, `${{ name | upper }}`
31
+
32
+ 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.
33
+
34
+ ### Agent Resolution
35
+
36
+ Agent specs (`.agent.yaml`) are resolved from three locations (first match wins):
37
+ 1. `.pi/agents/<name>.agent.yaml` — project-level
38
+ 2. `~/.pi/agent/agents/<name>.agent.yaml` — user-level
39
+ 3. Package bundled `agents/<name>.agent.yaml` — built-in
40
+
41
+ Agent specs define: model, thinking level, tools, system prompt (or template), task template, output format/schema.
42
+
43
+ ### Execution Model
44
+
45
+ 1. Steps are ordered by YAML declaration order
46
+ 2. DAG planner infers parallelism from `${{ steps.X }}` references
47
+ 3. Steps without explicit dependencies run after their predecessor (conservative sequential)
48
+ 4. Each step's result is persisted atomically to `<runDir>/state.json`
49
+ 5. TUI progress widget shows real-time step status, cost, and timing
50
+
51
+ ### Checkpoint and Resume
52
+
53
+ 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.
54
+
55
+ ### Output Validation
56
+
57
+ Steps with `output.schema` validate the agent's JSON output against a JSON Schema file. Validation failure marks the step as failed.
58
+
59
+ ### Per-Step Retry
60
+
61
+ Steps with `retry: { maxAttempts: N }` are re-executed on failure. Between retries:
62
+ - Project block files are rolled back to pre-attempt state
63
+ - Prior error messages are injected into the prompt
64
+ - Optional `steeringMessage` provides custom retry guidance
65
+
66
+ ### Completion Messages
67
+
68
+ 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).
69
+
70
+ ### Artifacts
71
+
72
+ Workflows can write post-completion files via the `artifacts` field. Paths may contain `${{ }}` expressions. Artifacts targeting `.project/*.json` are validated against block schemas.
73
+
74
+ ### Validation
75
+
76
+ `validateWorkflow(spec, cwd)` runs authoring-time checks without executing the workflow:
77
+
78
+ 1. **Agent resolution** — all referenced agents exist in the three-tier search
79
+ 2. **Schema resolution** — all output schema file paths resolve to existing files
80
+ 3. **Step reference validity** — `${{ steps.X }}` expressions reference declared steps
81
+ 4. **Step ordering** — referenced steps are declared before the referencing step
82
+ 5. **Filter name validity** — `${{ value | filter }}` uses known filter names
83
+
84
+ 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.