@wichayutdew/pi-workflows 1.0.0 → 2.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/README.md +312 -221
- package/agents/step.md +4 -11
- package/dist/index.js +2556 -961
- package/examples/mr-comments.workflow.yaml +18 -8
- package/examples/prompts/mr-comments/implement.md +13 -9
- package/examples/prompts/mr-comments/plan.md +44 -15
- package/examples/prompts/mr-comments/verify.md +8 -7
- package/examples/settings.yaml +7 -1
- package/examples/starter-kit/mr-comment.workflow.yaml +149 -0
- package/examples/starter-kit/mr-review.workflow.yaml +130 -0
- package/examples/starter-kit/steps/mr-comment/fetch.md +33 -0
- package/examples/starter-kit/steps/mr-comment/implement.md +38 -0
- package/examples/starter-kit/steps/mr-comment/plan.md +62 -0
- package/examples/starter-kit/steps/mr-comment/publish.md +36 -0
- package/examples/starter-kit/steps/mr-comment/verify.md +35 -0
- package/examples/starter-kit/steps/mr-review/fetch.md +25 -0
- package/examples/starter-kit/steps/mr-review/publish.md +30 -0
- package/examples/starter-kit/steps/mr-review/review.md +69 -0
- package/examples/starter-kit/steps/mr-review/verify.md +24 -0
- package/examples/starter-kit/steps/shared/prepare-workspace.md +57 -0
- package/examples/starter-kit/steps/ticket/implement.md +35 -0
- package/examples/starter-kit/steps/ticket/plan.md +40 -0
- package/examples/starter-kit/steps/ticket/verify.md +29 -0
- package/examples/starter-kit/steps/work/implement.md +34 -0
- package/examples/starter-kit/steps/work/plan.md +38 -0
- package/examples/starter-kit/steps/work/verify.md +30 -0
- package/examples/starter-kit/ticket.workflow.yaml +100 -0
- package/examples/starter-kit/work.workflow.yaml +97 -0
- package/package.json +3 -3
- package/schemas/workflow.schema.json +78 -35
- package/src/command-names.ts +1 -0
- package/src/commands.ts +33 -4
- package/src/config/ceiling.ts +6 -8
- package/src/config/load-workflows.ts +12 -1
- package/src/config/step-digests.ts +19 -0
- package/src/config/types.ts +17 -11
- package/src/config/validation/permissions.ts +5 -45
- package/src/config/validation/prompt.ts +3 -0
- package/src/config/validation/shared.ts +0 -2
- package/src/config/validation/step.ts +106 -2
- package/src/config/validation/workflow.ts +76 -0
- package/src/engine/create-run.ts +4 -0
- package/src/engine/gate-transitions.ts +58 -6
- package/src/engine/reconciliation-history.ts +61 -24
- package/src/engine/run-advance.ts +37 -4
- package/src/engine/run-lifecycle.ts +11 -0
- package/src/engine/run-reconciliation.ts +51 -21
- package/src/engine/run-validation.ts +236 -0
- package/src/engine/run-workflow-validation.ts +191 -0
- package/src/engine/state-types.ts +109 -4
- package/src/engine/state.ts +15 -1
- package/src/engine/step-trace.ts +495 -0
- package/src/engine/transitions.ts +1 -0
- package/src/harness/action-context.ts +31 -6
- package/src/harness/core-actions.ts +30 -1
- package/src/harness/delegation-control-actions.ts +27 -2
- package/src/harness/delegation-failure.ts +42 -9
- package/src/harness/delegation-plan.ts +96 -40
- package/src/harness/delegation-recovery-validation.ts +3 -1
- package/src/harness/delegation-response-actions.ts +73 -3
- package/src/harness/delegation-retry-policy.ts +5 -3
- package/src/harness/dependencies.ts +11 -2
- package/src/harness/gate-submission-action.ts +5 -31
- package/src/harness/lifecycle-actions.ts +4 -5
- package/src/harness/pause-actions.ts +10 -1
- package/src/harness/plannotator-result-actions.ts +20 -11
- package/src/harness/prompt-gate-actions.ts +40 -2
- package/src/harness/resume-action.ts +75 -1
- package/src/harness/start-actions.ts +77 -3
- package/src/harness/status-actions.ts +7 -17
- package/src/harness/step-effects.ts +61 -0
- package/src/harness/step-execution-actions.ts +181 -25
- package/src/harness/step-reporting.ts +168 -0
- package/src/harness/types.ts +1 -0
- package/src/harness/workspace-directory.ts +67 -0
- package/src/harness.ts +37 -9
- package/src/integrations/plannotator-requests.ts +40 -5
- package/src/integrations/subagents/child-policy-sections.ts +71 -72
- package/src/integrations/subagents/child-policy-types.ts +7 -7
- package/src/integrations/subagents/child-policy-validation.ts +10 -4
- package/src/integrations/subagents/child-runtime-completion.ts +1 -0
- package/src/integrations/subagents/child-runtime-files.ts +29 -86
- package/src/integrations/subagents/child-runtime-policy.ts +8 -33
- package/src/integrations/subagents/child-runtime.ts +3 -15
- package/src/integrations/subagents/delegated-result.ts +1 -0
- package/src/integrations/subagents/diagnostic-format.ts +5 -0
- package/src/integrations/subagents/diagnostic-types.ts +7 -1
- package/src/integrations/subagents/diagnostics.ts +2 -0
- package/src/integrations/subagents/failure-correlation.ts +52 -2
- package/src/integrations/subagents/failure-transcript.ts +60 -1
- package/src/integrations/subagents/replay-audit.ts +0 -1
- package/src/integrations/subagents/replay-safety.ts +12 -27
- package/src/integrations/subagents/session-diagnostics.ts +102 -3
- package/src/policy/bash-authorization.ts +2 -21
- package/src/policy/bash-types.ts +0 -5
- package/src/policy/bash.ts +1 -2
- package/src/policy/tool-call-authorization.ts +1 -7
- package/src/preflight.ts +0 -5
- package/src/prompt/retry-task.ts +11 -3
- package/src/prompt/step-contract.ts +10 -56
- package/src/prompt/step-sections.ts +8 -10
- package/src/prompt/step-task.ts +41 -10
- package/src/prompt/template.ts +5 -2
- package/src/runtime/completion-tool.ts +14 -0
- package/src/runtime/main-step-completion.ts +3 -0
- package/src/runtime/main-step-policy.ts +2 -1
- package/src/runtime/main-step-runtime-types.ts +9 -1
- package/src/runtime/main-step-runtime.ts +2 -0
- package/src/runtime/main-step-state.ts +6 -0
- package/src/runtime/main-step-trace.ts +45 -0
- package/src/runtime/step-result.ts +57 -0
- package/src/step-log.ts +178 -0
- package/src/workflow-doctor.ts +254 -0
- package/src/workflow-status/format-status.ts +32 -3
- package/src/workflow-status/render-board.ts +7 -4
- package/src/workflow-status/render-path.ts +51 -24
- package/src/workflow-status/render-step-detail.ts +379 -0
- package/src/workflow-status/render-summary.ts +22 -0
- package/src/workflow-status/transcript-reader.ts +231 -0
- package/src/workflow-status/types.ts +8 -0
- package/src/workflow-status/view.ts +161 -14
- package/src/workflow-status.ts +6 -0
- package/src/policy/approved-command-extraction.ts +0 -71
- package/src/policy/approved-commands.ts +0 -15
- package/src/policy/bash-read-only.ts +0 -161
- package/src/policy/restricted-git.ts +0 -30
- package/src/policy/reviewed-artifact.ts +0 -97
- package/src/policy/reviewed-command-safety.ts +0 -150
- package/src/policy/reviewed-command-shape.ts +0 -49
- package/src/policy/reviewed-repository-contract.ts +0 -138
- package/src/policy/reviewed-repository-cwd.ts +0 -102
package/README.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
# Pi Workflows
|
|
2
|
+
|
|
3
|
+
**Turn repeatable agent work into declarative, pauseable workflows that cannot
|
|
4
|
+
silently loop forever.** Put the steps, tools, prompts, approvals, and outcomes
|
|
5
|
+
in YAML; Pi Workflows supplies durable checkpoints, finite automatic execution,
|
|
6
|
+
and a live status view without learning your language, framework, or process.
|
|
7
|
+
|
|
1
8
|
[](https://codecov.io/gh/wichayutdew/pi-workflows)
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
```bash
|
|
11
|
+
pi install npm:@wichayutdew/pi-workflows
|
|
12
|
+
```
|
|
4
13
|
|
|
5
|
-
|
|
14
|
+
- Compose main-agent and isolated subagent steps from one strict YAML contract.
|
|
15
|
+
- Pause for built-in or Plannotator review, then resume the same checkpoint.
|
|
16
|
+
- Reject dead-end graphs up front and pause bounded cycles at `maxStepVisits`.
|
|
17
|
+
- Keep every domain decision in your workflow files—not in the harness.
|
|
6
18
|
|
|
7
19
|
## Overview
|
|
8
20
|
|
|
@@ -47,43 +59,107 @@ delegated step cannot start.
|
|
|
47
59
|
|
|
48
60
|
Pi loads `src/index.ts` through the package manifest. Restart Pi or run `/reload` after changing extension source.
|
|
49
61
|
|
|
50
|
-
##
|
|
62
|
+
## Quick start: bootstrap four practical workflows
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
The checked-in [`examples/starter-kit`](./examples/starter-kit) is a portable,
|
|
65
|
+
user-owned starting point for:
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
| Command | Included flow |
|
|
68
|
+
| ------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `/work` | Prepare or reuse one dedicated Git worktree, plan, approve, implement, and verify local work. |
|
|
70
|
+
| `/ticket` | Prepare or reuse one dedicated Git worktree, read a ticket, plan, approve, implement, and verify. |
|
|
71
|
+
| `/mr-review` | Fetch a hosted review, produce a child review, approve it, publish it, and verify the remote effect. |
|
|
72
|
+
| `/mr-comment` | Fetch review comments, plan and approve fixes, edit only the current branch/worktree, verify, push, reply. |
|
|
73
|
+
|
|
74
|
+
Install the integrations required by these four examples:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pi install npm:pi-subagents
|
|
78
|
+
pi install npm:@plannotator/pi-extension
|
|
57
79
|
```
|
|
58
80
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
Configure a Pi MCP proxy for the `atlassian`, `gitlab`, and/or `github` server
|
|
82
|
+
IDs when you want that access route. The MR examples try a matching MCP server
|
|
83
|
+
first but can fall back to the repository/host CLIs or cURL named in their
|
|
84
|
+
YAML; ensure at least one route is authenticated and available. The ticket
|
|
85
|
+
example requires Atlassian MCP by default. MCP server names, authentication,
|
|
86
|
+
tool availability, Git hosting, and repository commands are environment
|
|
87
|
+
choices, so adapt the selectors, `requires`, and Bash rules instead of
|
|
88
|
+
expecting the extension to infer them.
|
|
63
89
|
|
|
64
|
-
|
|
90
|
+
Copy the starter files into the user workflow directory:
|
|
65
91
|
|
|
66
92
|
```bash
|
|
67
|
-
mkdir -p ~/.pi/agent/workflows
|
|
68
|
-
cp examples/
|
|
69
|
-
cp -R examples/
|
|
93
|
+
mkdir -p ~/.pi/agent/workflows
|
|
94
|
+
cp examples/starter-kit/*.workflow.yaml ~/.pi/agent/workflows/
|
|
95
|
+
cp -R examples/starter-kit/steps ~/.pi/agent/workflows/
|
|
70
96
|
```
|
|
71
97
|
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
If files with those names already exist, review and merge them instead of
|
|
99
|
+
overwriting your working configuration. Then customize:
|
|
100
|
+
|
|
101
|
+
1. In `work.workflow.yaml` and `ticket.workflow.yaml`, set each
|
|
102
|
+
`workspace.allowedRoots` to relative directories where the preparation
|
|
103
|
+
prompt may create or reuse a worktree.
|
|
104
|
+
2. Replace or narrow the `atlassian`, `gitlab`, and `github` MCP selectors to
|
|
105
|
+
match your configured adapter. Remove an unused host consistently from the
|
|
106
|
+
relevant `permissions.mcp` blocks and prompts.
|
|
107
|
+
3. Review every Bash mode and executable. The starter implementation and
|
|
108
|
+
verification steps are deliberately language-neutral and therefore
|
|
109
|
+
unrestricted; replace them with repository-specific allow lists when
|
|
110
|
+
possible. Command syntax—including package-manager argument order—belongs
|
|
111
|
+
in your prompt and repository context.
|
|
112
|
+
4. Edit the prompt files under `steps/` to define your artifact format,
|
|
113
|
+
acceptance criteria, publication policy, and organization-specific rules.
|
|
114
|
+
Pi Workflows treats all of that content as opaque domain configuration.
|
|
115
|
+
|
|
116
|
+
Reload and diagnose every graph before the first run:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
/reload
|
|
120
|
+
/workflow-reload
|
|
121
|
+
/workflow-doctor work
|
|
122
|
+
/workflow-doctor ticket
|
|
123
|
+
/workflow-doctor mr-review
|
|
124
|
+
/workflow-doctor mr-comment
|
|
125
|
+
```
|
|
74
126
|
|
|
75
|
-
|
|
127
|
+
Start them from the repository checkout that should supply the initial
|
|
128
|
+
workspace:
|
|
76
129
|
|
|
77
130
|
```text
|
|
78
|
-
/
|
|
131
|
+
/work update the navigation
|
|
132
|
+
/ticket PROJ-123 retry failed requests
|
|
133
|
+
/mr-review https://gitlab.example.com/group/project/-/merge_requests/42
|
|
134
|
+
/mr-comment https://github.com/example/project/pull/42
|
|
79
135
|
```
|
|
80
136
|
|
|
81
|
-
|
|
137
|
+
`/work` and `/ticket` bind the exact worktree returned by their user-authored
|
|
138
|
+
preparation prompt. `/mr-comment` intentionally has no workspace-binding step:
|
|
139
|
+
every child stays on the branch and worktree from which the run started.
|
|
140
|
+
Approval rejection pauses either review workflow; it never launches an
|
|
141
|
+
automatic replacement plan. Remote publication prompts first check whether an
|
|
142
|
+
approved effect already exists because the harness cannot guarantee
|
|
143
|
+
exactly-once external side effects.
|
|
144
|
+
|
|
145
|
+
## Add a workflow
|
|
146
|
+
|
|
147
|
+
User workflows live in one of these formats:
|
|
82
148
|
|
|
83
149
|
```text
|
|
84
|
-
/workflow
|
|
150
|
+
~/.pi/agent/workflows/*.workflow.yaml
|
|
151
|
+
~/.pi/agent/workflows/*.workflow.yml
|
|
85
152
|
```
|
|
86
153
|
|
|
154
|
+
YAML keeps nested steps and permission lists compact. The loader uses the
|
|
155
|
+
strict YAML 1.2 core schema: duplicate keys, merge keys, invalid tags,
|
|
156
|
+
multiple documents, non-1.2 directives, and excessive alias expansion fail
|
|
157
|
+
closed.
|
|
158
|
+
|
|
159
|
+
Set `PI_WORKFLOWS_DIR` to use another directory. For a complete portable
|
|
160
|
+
starting point, copy the four-workflow starter kit above. Every configured
|
|
161
|
+
command is also available as `/workflow-start <workflow-id> [input]`.
|
|
162
|
+
|
|
87
163
|
## Minimal workflow
|
|
88
164
|
|
|
89
165
|
```yaml
|
|
@@ -99,7 +175,11 @@ steps:
|
|
|
99
175
|
permissions:
|
|
100
176
|
tools: [read, grep, bash]
|
|
101
177
|
bash:
|
|
102
|
-
mode:
|
|
178
|
+
mode: allow-list
|
|
179
|
+
allow:
|
|
180
|
+
- executable: git
|
|
181
|
+
argsPrefixes: [[status], [diff]]
|
|
182
|
+
- executable: rg
|
|
103
183
|
requires:
|
|
104
184
|
tools: [read, bash]
|
|
105
185
|
transitions:
|
|
@@ -114,7 +194,7 @@ steps:
|
|
|
114
194
|
bash:
|
|
115
195
|
mode: allow-list
|
|
116
196
|
allow:
|
|
117
|
-
- executable:
|
|
197
|
+
- executable: project-check
|
|
118
198
|
argsPrefix: [test]
|
|
119
199
|
transitions:
|
|
120
200
|
done: $done
|
|
@@ -143,15 +223,16 @@ Top-level fields:
|
|
|
143
223
|
|
|
144
224
|
Each step supports:
|
|
145
225
|
|
|
146
|
-
| Field | Required | Description
|
|
147
|
-
| ------------- | -------- |
|
|
148
|
-
| `title` | No | Human-readable name. Defaults to the step identifier.
|
|
149
|
-
| `prompt` | Yes | Inline text or `{ "file": "relative/path.md" }`.
|
|
150
|
-
| `subagent` | No | Opt into isolated delegation and select the Pi Subagents profile and execution budgets.
|
|
151
|
-
| `permissions` | No | Resources callable during this step. Everything defaults to denied.
|
|
152
|
-
| `requires` | No | Dependencies that must be detectable before the step starts.
|
|
153
|
-
| `transitions` | Yes | Exact outcome to next step, `$pause`, or `$done`.
|
|
154
|
-
| `gate` | No | Built-in prompt or Plannotator human-review gate.
|
|
226
|
+
| Field | Required | Description |
|
|
227
|
+
| ------------- | -------- | ----------------------------------------------------------------------------------------------------- |
|
|
228
|
+
| `title` | No | Human-readable name. Defaults to the step identifier. |
|
|
229
|
+
| `prompt` | Yes | Inline text or `{ "file": "relative/path.md" }`. |
|
|
230
|
+
| `subagent` | No | Opt into isolated delegation and select the Pi Subagents profile and execution budgets. |
|
|
231
|
+
| `permissions` | No | Resources callable during this step. Everything defaults to denied. |
|
|
232
|
+
| `requires` | No | Dependencies that must be detectable before the step starts. |
|
|
233
|
+
| `transitions` | Yes | Exact outcome to next step, `$pause`, or `$done`. |
|
|
234
|
+
| `gate` | No | Built-in prompt or Plannotator human-review gate. |
|
|
235
|
+
| `workspace` | No | Bind one delegated step result as the working directory for all reachable downstream delegated steps. |
|
|
155
236
|
|
|
156
237
|
Supported prompt variables:
|
|
157
238
|
|
|
@@ -162,14 +243,26 @@ Supported prompt variables:
|
|
|
162
243
|
{{step.id}}
|
|
163
244
|
{{step.title}}
|
|
164
245
|
{{last.summary}}
|
|
246
|
+
{{reviewed.artifact}}
|
|
247
|
+
{{reviewed.feedback}}
|
|
165
248
|
{{gate.feedback}}
|
|
249
|
+
{{resume.input}}
|
|
166
250
|
```
|
|
167
251
|
|
|
168
252
|
Unknown variables fail configuration loading.
|
|
169
253
|
|
|
170
254
|
`{{last.summary}}` normally contains the previous completed step's handoff.
|
|
171
255
|
After a step-requested `$pause`, it contains both the preserved incoming
|
|
172
|
-
|
|
256
|
+
previous-step handoff and the latest paused-attempt summary. Gate artifacts and
|
|
257
|
+
summaries stay separate: prompts opt into the opaque approved artifact through
|
|
258
|
+
`{{reviewed.artifact}}`.
|
|
259
|
+
`{{resume.input}}` contains guidance supplied to the current attempt through
|
|
260
|
+
`/workflow-resume [guidance]`. If a prompt omits that variable, the harness
|
|
261
|
+
adds the guidance in a clearly delimited standard section, so every workflow
|
|
262
|
+
can still use it. Standard-section guidance is an authoritative task-level
|
|
263
|
+
amendment for that retry, but it cannot change the workflow graph or bypass
|
|
264
|
+
YAML-enforced resource and workspace boundaries. The value is replaced on each
|
|
265
|
+
explicit resume and cleared after the step returns an outcome.
|
|
173
266
|
|
|
174
267
|
### Per-step subagents
|
|
175
268
|
|
|
@@ -205,6 +298,34 @@ The expanded defaults are `agent: pi-workflows.step`, `context: fresh`,
|
|
|
205
298
|
original workflow input and the previous step's compact handoff, never the
|
|
206
299
|
parent or a sibling transcript.
|
|
207
300
|
|
|
301
|
+
The run captures Pi's current working directory when it starts. Without a
|
|
302
|
+
`workspace` binding, every delegated visit—including cycles, retries, and
|
|
303
|
+
resumed steps—uses that directory.
|
|
304
|
+
|
|
305
|
+
One delegated, non-gated step may bind a different directory through structured
|
|
306
|
+
result data:
|
|
307
|
+
|
|
308
|
+
```yaml
|
|
309
|
+
workspace:
|
|
310
|
+
bindOn: [ready]
|
|
311
|
+
allowedRoots: ['..']
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
On a binding outcome, the result must include
|
|
315
|
+
`workspace: { cwd: "/absolute/directory" }`. The harness resolves its real path,
|
|
316
|
+
requires an existing directory under one configured root relative to the
|
|
317
|
+
run-start directory, persists it once, and passes that exact directory to every
|
|
318
|
+
reachable downstream child, revisit, recovery attempt, and resume. Other
|
|
319
|
+
outcomes must omit `workspace`; later results cannot replace the binding. All
|
|
320
|
+
reachable nonterminal steps after a binding must be delegated because the main
|
|
321
|
+
Pi process cannot change its working directory.
|
|
322
|
+
|
|
323
|
+
The workflow prompt owns how the directory is prepared and what it represents.
|
|
324
|
+
The harness does not know Git, worktrees, languages, frameworks, or command
|
|
325
|
+
syntax, and it never derives a directory from summaries or gate artifacts. A
|
|
326
|
+
legacy checkpoint without a captured directory fails closed before delegation;
|
|
327
|
+
abort it and start a new run.
|
|
328
|
+
|
|
208
329
|
Use a profile name directly when only the child profile changes:
|
|
209
330
|
|
|
210
331
|
```yaml
|
|
@@ -339,14 +460,14 @@ process; the tool policy does not unload extension code.
|
|
|
339
460
|
|
|
340
461
|
### Bash modes
|
|
341
462
|
|
|
342
|
-
| Mode | Behavior
|
|
343
|
-
| -------------- |
|
|
344
|
-
| `deny` | Blocks Bash. This is the default.
|
|
345
|
-
| `
|
|
346
|
-
| `
|
|
347
|
-
| `unrestricted` | Allows any Bash command. Use only in user-owned workflows. |
|
|
463
|
+
| Mode | Behavior |
|
|
464
|
+
| -------------- | ------------------------------------------------------------------- |
|
|
465
|
+
| `deny` | Blocks Bash. This is the default. |
|
|
466
|
+
| `allow-list` | Allows one executable plus user-configured argument prefixes. |
|
|
467
|
+
| `unrestricted` | Allows any Bash command. Use only in trusted, user-owned workflows. |
|
|
348
468
|
|
|
349
|
-
|
|
469
|
+
Allow-list mode rejects shell operators, substitutions, expansions, wrapper
|
|
470
|
+
shells, and environment assignments before matching the declarative rule.
|
|
350
471
|
|
|
351
472
|
Allow-list entries are OR alternatives. `argsPrefix` is one ordered token
|
|
352
473
|
sequence:
|
|
@@ -356,11 +477,11 @@ mode: allow-list
|
|
|
356
477
|
allow:
|
|
357
478
|
- executable: git
|
|
358
479
|
argsPrefix: [status]
|
|
359
|
-
- executable:
|
|
480
|
+
- executable: project-check
|
|
360
481
|
argsPrefix: [test]
|
|
361
482
|
```
|
|
362
483
|
|
|
363
|
-
This permits `
|
|
484
|
+
This permits `project-check test --focused` but not `project-check build`.
|
|
364
485
|
|
|
365
486
|
Use `argsPrefixes` to merge several alternatives for one executable without
|
|
366
487
|
widening permission:
|
|
@@ -380,94 +501,13 @@ sequence `git status diff`; it does not mean “status or diff.” `argsPrefix`
|
|
|
380
501
|
`argsPrefixes` are mutually exclusive in one rule. Omitting both allows that
|
|
381
502
|
executable with any safely tokenized arguments.
|
|
382
503
|
|
|
383
|
-
|
|
384
|
-
|
|
504
|
+
The engine deliberately has no package-manager, language, framework, Git, or
|
|
505
|
+
hosted-API command knowledge. It does not rewrite command argument order and
|
|
506
|
+
does not derive Bash authority from prompts, summaries, or gate artifacts.
|
|
507
|
+
Command meaning and syntax belong to the step prompt and the agent's own
|
|
508
|
+
context; executable scope belongs entirely to the YAML `allow` rules.
|
|
385
509
|
|
|
386
|
-
|
|
387
|
-
mode: allow-list
|
|
388
|
-
allow:
|
|
389
|
-
- executable: git
|
|
390
|
-
argsPrefix: [status]
|
|
391
|
-
approvedSources: [verification-worker]
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
Supported sources are:
|
|
395
|
-
|
|
396
|
-
| Source | Reviewed JSON path |
|
|
397
|
-
| ----------------------- | --------------------------------------------------------------------- |
|
|
398
|
-
| `verification-worker` | `repositories[].worker[].command` |
|
|
399
|
-
| `verification-reviewer` | `repositories[].reviewer[].command` |
|
|
400
|
-
| `remote-actions` | `actions[]` where `toolName` is `bash` and `input.command` is present |
|
|
401
|
-
|
|
402
|
-
The JSON must be the whole reviewed artifact or appear in a fenced `json`
|
|
403
|
-
block. The harness copies only exact strings into the correlated step policy.
|
|
404
|
-
Verification sources reject shell wrappers, remote-transfer programs,
|
|
405
|
-
`gh`/`glab`, publishing commands, and non-local Git operations. Remote actions
|
|
406
|
-
accept only `gh api`, `glab api`, or non-force `git push`. A model cannot widen
|
|
407
|
-
an approved command by adding arguments or shell composition.
|
|
408
|
-
|
|
409
|
-
Approved sources fail closed until a gate has actually been approved. Ordinary
|
|
410
|
-
step summaries never become command provenance. Legacy v1 checkpoints remain
|
|
411
|
-
readable, but they receive no reviewed-command capabilities until a new gate
|
|
412
|
-
produces an approved artifact.
|
|
413
|
-
|
|
414
|
-
Static allow-list rules for `gh api` and `glab api` are GET-only: mutation
|
|
415
|
-
flags such as fields, input, forms, or an explicit method are blocked. A
|
|
416
|
-
mutating API call therefore needs an exact `remote-actions` command from a
|
|
417
|
-
reviewed artifact.
|
|
418
|
-
|
|
419
|
-
#### How `approvedSources` works
|
|
420
|
-
|
|
421
|
-
`approvedSources` does not allow an executable, run a command, or read from the
|
|
422
|
-
current step summary. It tells the harness which fixed field in the most recent
|
|
423
|
-
human-approved artifact may contribute exact command strings. Approval may
|
|
424
|
-
come from the built-in Pi prompt gate or Plannotator.
|
|
425
|
-
|
|
426
|
-
For example, suppose the approved artifact contains:
|
|
427
|
-
|
|
428
|
-
```json
|
|
429
|
-
{
|
|
430
|
-
"repositories": [
|
|
431
|
-
{
|
|
432
|
-
"cwd": "/absolute/path/to/repository",
|
|
433
|
-
"sourceCwd": "/absolute/path/to/source",
|
|
434
|
-
"worker": [
|
|
435
|
-
{
|
|
436
|
-
"command": "bun --cwd /absolute/path/to/repository test"
|
|
437
|
-
}
|
|
438
|
-
]
|
|
439
|
-
}
|
|
440
|
-
]
|
|
441
|
-
}
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
A later step with `approvedSources: [verification-worker]` may run only the
|
|
445
|
-
exact reviewed command. Cwd-dependent commands must encode that entry's
|
|
446
|
-
absolute `repositories[].cwd`, such as `bun --cwd /reviewed/root test`; they
|
|
447
|
-
may not substitute another directory or add `--watch`.
|
|
448
|
-
`verification-reviewer` reads the sibling `reviewer` list with the same rule.
|
|
449
|
-
`remote-actions` reads only Bash actions from
|
|
450
|
-
`actions[]` and additionally filters them to supported hosted-API mutations or
|
|
451
|
-
non-force pushes.
|
|
452
|
-
|
|
453
|
-
A delegated step accepts one distinct reviewed repository directory; repeated
|
|
454
|
-
entries may name that same absolute `cwd`. Missing, relative, or ambiguous
|
|
455
|
-
multiple directories fail closed before the child starts. A not-yet-created
|
|
456
|
-
worktree may bootstrap only from the same contract's one existing absolute
|
|
457
|
-
`sourceCwd`; file mutations remain confined to the reviewed target `cwd`, and
|
|
458
|
-
all setup and later Bash commands must still match the approved strings.
|
|
459
|
-
|
|
460
|
-
The complete path is:
|
|
461
|
-
|
|
462
|
-
```text
|
|
463
|
-
step artifact -> human approval -> persisted reviewed artifact
|
|
464
|
-
-> source-specific extraction -> correlated step policy -> exact string check
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
If no gate has been approved, the selected field is absent, the command is
|
|
468
|
-
unsafe for that source, or the string differs at all, no permission is added.
|
|
469
|
-
|
|
470
|
-
Hard turn and tool-call budgets are best for read-only inspection and
|
|
510
|
+
Hard turn and tool-call budgets are best for non-mutating inspection and
|
|
471
511
|
verification steps. For a step that edits files, use a generous timeout and no
|
|
472
512
|
hard count budget unless partial edits are acceptable; inspect the working tree
|
|
473
513
|
after any interruption before resuming.
|
|
@@ -484,14 +524,16 @@ gate:
|
|
|
484
524
|
rejectedOutcome: changes-requested
|
|
485
525
|
transitions:
|
|
486
526
|
approved: implement
|
|
487
|
-
changes-requested:
|
|
527
|
+
changes-requested: $pause
|
|
488
528
|
blocked: $pause
|
|
489
529
|
```
|
|
490
530
|
|
|
491
531
|
When the step completes with outcome `submit`, it must include the full content
|
|
492
532
|
in `artifact`. Pi shows Approve, Request changes, and Pause workflow. Requested
|
|
493
533
|
changes are returned through `{{gate.feedback}}`; approval persists the
|
|
494
|
-
artifact as
|
|
534
|
+
artifact as `{{reviewed.artifact}}` while the step's `summary` remains the
|
|
535
|
+
compact handoff. A requested change pauses at the same step with feedback, so
|
|
536
|
+
revision starts only after explicit `/workflow-resume`. Dismissing the panel
|
|
495
537
|
keeps the pending artifact, so `/workflow-resume` reopens the same review.
|
|
496
538
|
|
|
497
539
|
Dialog-capable UI is available in Pi TUI and RPC modes. In print or JSON mode,
|
|
@@ -513,7 +555,8 @@ Pi Workflows uses Plannotator's shared extension API as a human approval gate:
|
|
|
513
555
|
- A workflow submits its plan or other Markdown artifact.
|
|
514
556
|
- Plannotator opens the visual review in your browser.
|
|
515
557
|
- Approval advances through the configured transition.
|
|
516
|
-
- Requested changes
|
|
558
|
+
- Requested changes follow the workflow's configured transition with structured
|
|
559
|
+
feedback.
|
|
517
560
|
- Pausing never discards a decision; resume queries the same review identifier.
|
|
518
561
|
|
|
519
562
|
This keeps workflow order and permissions declarative while Plannotator handles
|
|
@@ -529,36 +572,37 @@ gate:
|
|
|
529
572
|
submitOutcome: submit
|
|
530
573
|
approvedOutcome: approved
|
|
531
574
|
rejectedOutcome: changes-requested
|
|
532
|
-
timeoutMs:
|
|
575
|
+
timeoutMs: 30000
|
|
533
576
|
transitions:
|
|
534
577
|
approved: implement
|
|
535
|
-
changes-requested:
|
|
578
|
+
changes-requested: $pause
|
|
536
579
|
blocked: $pause
|
|
537
580
|
```
|
|
538
581
|
|
|
539
|
-
Setting `provider: plannotator` is the entire opt-in;
|
|
540
|
-
|
|
582
|
+
Setting `provider: plannotator` is the entire opt-in; do not also grant the
|
|
583
|
+
planning child Plannotator extension tools. The harness preflights the installed
|
|
584
|
+
extension automatically. A main-agent planning step calls
|
|
541
585
|
`workflow_complete_step`; a delegated planning child calls
|
|
542
|
-
`structured_output`. In either case it uses
|
|
543
|
-
content in `artifact`. The harness correlates the Plannotator
|
|
544
|
-
and accepts only the matching decision. On approval,
|
|
545
|
-
|
|
586
|
+
`structured_output`. In either case it uses the configured submit outcome and
|
|
587
|
+
places the review content in `artifact`. The harness correlates the Plannotator
|
|
588
|
+
review identifier and accepts only the matching decision. On approval, the
|
|
589
|
+
artifact is preserved as an opaque template value; the separate `summary`
|
|
590
|
+
remains the next step's compact handoff.
|
|
591
|
+
|
|
592
|
+
The artifact is never substituted for a missing summary. If an older pending
|
|
593
|
+
gate has no separately stored summary, its transition uses an empty compact
|
|
594
|
+
handoff.
|
|
546
595
|
|
|
547
596
|
If review finishes while the workflow is paused, the result is checkpointed and applied only after `/workflow-resume`. Resume also queries Plannotator’s durable review status, so a decision made while Pi was closed is not lost.
|
|
548
597
|
|
|
549
|
-
###
|
|
550
|
-
|
|
551
|
-
For a delegated plan workflow, put every unresolved choice in the plan artifact
|
|
552
|
-
with evidence, options, a recommendation, and an adopted default. The built-in
|
|
553
|
-
review panel or Plannotator is where the user resolves those choices. Approval
|
|
554
|
-
makes that reviewed artifact the final implementation contract and compact
|
|
555
|
-
handoff.
|
|
598
|
+
### Artifact format belongs to the workflow
|
|
556
599
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
600
|
+
Pi Workflows imposes no plan headings, acceptance-criteria layout,
|
|
601
|
+
machine-readable appendix, command schema, or other Plannotator prompt format.
|
|
602
|
+
The step's YAML prompt defines what the artifact means and how downstream steps
|
|
603
|
+
use `{{reviewed.artifact}}`. Outcome names are equally opaque: names such as
|
|
604
|
+
`approved`, `retry`, or `replan` have only the transitions and meanings the
|
|
605
|
+
workflow author gives them.
|
|
562
606
|
|
|
563
607
|
In print or JSON mode, a pending built-in plan review remains safely paused.
|
|
564
608
|
Reopen the same session in TUI or RPC mode and run `/workflow-resume` to show
|
|
@@ -579,10 +623,18 @@ the Pi session. A late completion cannot advance a paused, aborted,
|
|
|
579
623
|
reconfigured, or replaced run.
|
|
580
624
|
|
|
581
625
|
When a step itself transitions to `$pause`, the checkpoint keeps both the
|
|
582
|
-
incoming
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
626
|
+
incoming previous-step handoff and the latest failed-attempt summary. The
|
|
627
|
+
resumed execution sees both. The run-start directory, any accepted workspace
|
|
628
|
+
binding, and any separately persisted reviewed artifact are preserved without
|
|
629
|
+
being interpreted.
|
|
630
|
+
|
|
631
|
+
Every settled step also posts one visible chat summary without starting another
|
|
632
|
+
agent turn. Successful and `$pause` outcomes show only the step's validated
|
|
633
|
+
`summary`; the final one also states that the workflow completed. Manual,
|
|
634
|
+
restored-session, and review pauses show their concise pause reason. Runtime
|
|
635
|
+
failures show only a short, redacted failure summary—not the task, artifact,
|
|
636
|
+
tool transcript, or full diagnostic. Complete evidence remains available in
|
|
637
|
+
the status explorer.
|
|
586
638
|
|
|
587
639
|
For a delegated step, if child termination is not confirmed within five
|
|
588
640
|
seconds, the pause is recorded but main tools remain isolated and resume is
|
|
@@ -597,10 +649,11 @@ automatic recovery child. The audit accepts only regular, non-symlink session
|
|
|
597
649
|
files contained by the current parent session's child-run root, requires the
|
|
598
650
|
persisted policy-stripped task and its per-request binding to match the active
|
|
599
651
|
delegation, reads a bounded complete tail, and proves that every recorded call
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
652
|
+
used a known-safe non-Bash tool or was rejected by policy before execution.
|
|
653
|
+
A zero-tool attempt is also replay-safe when the complete bound transcript
|
|
654
|
+
proves it. Executed Bash is treated as an unknown effect; automatic recovery
|
|
655
|
+
requires explicit authorization and still cannot claim that a domain-specific
|
|
656
|
+
command was non-mutating.
|
|
604
657
|
|
|
605
658
|
When the terminal error identifies a failed tool, the harness also records the
|
|
606
659
|
exact correlated call, tool error, subagent exit code, terminal error, and
|
|
@@ -633,26 +686,26 @@ can consume at most three times its per-child timeout, turn budget, and tool
|
|
|
633
686
|
budget.
|
|
634
687
|
|
|
635
688
|
Inside a live child, recovery is not tied to a list of known error strings. The
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
the failed call, error, attempted alternatives, and remaining blocker in its
|
|
640
|
-
handoff. A fresh retry is explicitly a continuation: it inspects state first
|
|
641
|
-
and must not repeat a side effect that is already present.
|
|
689
|
+
agent receives the exact error and current state, then follows the user-authored
|
|
690
|
+
step prompt and configured outcomes. The engine does not assign a recovery,
|
|
691
|
+
pause, or replanning meaning to any outcome name.
|
|
642
692
|
|
|
643
693
|
While paused, fix repository code, workflow YAML, prompts, MCP configuration,
|
|
644
694
|
an extension, or any other environmental problem. Then run:
|
|
645
695
|
|
|
646
696
|
```text
|
|
647
|
-
/workflow-resume
|
|
697
|
+
/workflow-resume inspect the existing partial output before retrying
|
|
648
698
|
```
|
|
649
699
|
|
|
650
700
|
Resume reloads configuration before continuing:
|
|
651
701
|
|
|
702
|
+
- Optional text after `/workflow-resume` is passed as a user-authored
|
|
703
|
+
task-level amendment for this attempt. It may supersede conflicting prompt or
|
|
704
|
+
handoff instructions, but never YAML-enforced resource or workspace policy.
|
|
652
705
|
- The paused step restarts in its configured main-agent or delegated mode.
|
|
653
706
|
- A changed current step restarts that step.
|
|
654
707
|
- A changed ordinary completed step restarts the earliest changed completed step.
|
|
655
|
-
- A completed human-approved gate keeps its
|
|
708
|
+
- A completed human-approved gate keeps its opaque reviewed artifact; later prompt or configuration digest changes do not reopen that gate while its configuration and approved outcome still match.
|
|
656
709
|
- Future-only changes preserve the current checkpoint.
|
|
657
710
|
- Removing the current or a completed step fails closed and requires restoring configuration or aborting.
|
|
658
711
|
- Restoring a Pi session automatically pauses an in-progress workflow for inspection.
|
|
@@ -661,29 +714,56 @@ Resume reloads configuration before continuing:
|
|
|
661
714
|
|
|
662
715
|
## Commands
|
|
663
716
|
|
|
664
|
-
The full status overlay
|
|
665
|
-
`Ctrl+Alt+W` by default (`q` or `Esc`
|
|
666
|
-
`settings.yaml` to another Pi key identifier, then run Pi's
|
|
667
|
-
re-register it; `/workflow-reload` cannot change extension
|
|
668
|
-
overlay shows run timing, execution or review, pause reasons,
|
|
669
|
-
drift, and the completed attempt path without a task-viewer pane
|
|
670
|
-
editor. The main surface shows only one small animated
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
717
|
+
The full status overlay is an on-demand verification and history page. Toggle
|
|
718
|
+
it with `Ctrl+Alt+W` by default (`q` or `Esc` hides the board). Set
|
|
719
|
+
`statusShortcut` in `settings.yaml` to another Pi key identifier, then run Pi's
|
|
720
|
+
`/reload` to re-register it; `/workflow-reload` cannot change extension
|
|
721
|
+
shortcuts. The overlay shows run timing, execution or review, pause reasons,
|
|
722
|
+
configuration drift, and the completed attempt path without a task-viewer pane
|
|
723
|
+
below the editor. The main surface shows only one small animated
|
|
724
|
+
`◐`/`◓`/`◑`/`◒` working
|
|
725
|
+
indicator followed by the workflow id and current step title/id while a
|
|
726
|
+
workflow runs, then clears it when execution stops. This makes live progress
|
|
727
|
+
visible without opening the status page. All attempt logs, history, failure,
|
|
728
|
+
and review detail stays in the overlay. There, `✓` marks a completed step, `✕`
|
|
729
|
+
a failed or aborted run, and `◆` a paused step or pending review.
|
|
730
|
+
|
|
731
|
+
Use `↑`/`↓` or `j`/`k` to select a step, then `Enter`, `→`, or `l` to inspect
|
|
732
|
+
the bounded task supplied to each attempt, its result and gate decision, and a
|
|
733
|
+
chronological execution log when available. In the detail view,
|
|
734
|
+
`↑`/`↓` or `j`/`k` scrolls; `←`, `h`, or `Esc` returns to the board; `q` or the
|
|
735
|
+
configured shortcut closes it. PgUp/PgDn and Home/End retain page navigation.
|
|
736
|
+
Trace references and bounded task/result evidence live in the checkpoint, so
|
|
737
|
+
completed, paused, resumed, and restored runs remain inspectable. Child logs
|
|
738
|
+
are path-confined, size-bounded, control-sanitized, and redact common
|
|
739
|
+
credential forms.
|
|
740
|
+
For new main-agent attempts, the extension arms only on the exact workflow
|
|
741
|
+
task and checkpoints a redacted, size-bounded prefix of finalized assistant
|
|
742
|
+
and tool events in source order. This log remains part of the parent session,
|
|
743
|
+
but the explorer never reads unrelated parent-session traffic. Legacy
|
|
744
|
+
checkpoints without a main-agent log still show their bounded task and result.
|
|
745
|
+
Long reasons are clamped to the display width while the durable checkpoint
|
|
746
|
+
retains the full reason.
|
|
747
|
+
|
|
748
|
+
| Command | Purpose |
|
|
749
|
+
| ------------------------------- | --------------------------------------------------------- |
|
|
750
|
+
| `/workflow-list` | List loaded workflows and their configured commands. |
|
|
751
|
+
| `/workflow-doctor [id]` | Diagnose completion paths, unreachable steps, and cycles. |
|
|
752
|
+
| `/workflow-start <id> [input]` | Start by workflow identifier. |
|
|
753
|
+
| `/<configured-command> [input]` | Start through a workflow alias. |
|
|
754
|
+
| `/workflow-pause [reason]` | Halt without losing the checkpoint. |
|
|
755
|
+
| `/workflow-resume [guidance]` | Reload, reconcile, and continue with an optional hint. |
|
|
756
|
+
| `/workflow-abort [reason]` | End the active run and restore baseline tools. |
|
|
757
|
+
| `/workflow-reload` | Reload definitions while no workflow is running. |
|
|
758
|
+
|
|
759
|
+
Before a workflow starts or resumes, the doctor rejects graphs whose start
|
|
760
|
+
cannot reach `$done` or whose reachable branches contain a step that cannot
|
|
761
|
+
reach `$done`.
|
|
762
|
+
Unreachable steps and cycles are reported as warnings; a cycle with an exit may
|
|
763
|
+
run, but `maxStepVisits` pauses the uninterrupted run before a step can execute
|
|
764
|
+
more than its configured limit. An explicit resume can continue from that
|
|
765
|
+
checkpoint, so the guard bounds automatic graph advancement rather than
|
|
766
|
+
guaranteeing completion or wall-clock duration.
|
|
687
767
|
|
|
688
768
|
Configured aliases also accept multiline input. For example, if `work` is a
|
|
689
769
|
loaded workflow command, Pi Workflows normalizes:
|
|
@@ -718,7 +798,12 @@ permissionCeiling:
|
|
|
718
798
|
mcp: []
|
|
719
799
|
extensions: []
|
|
720
800
|
skills: []
|
|
721
|
-
bash:
|
|
801
|
+
bash:
|
|
802
|
+
mode: allow-list
|
|
803
|
+
allow:
|
|
804
|
+
- executable: git
|
|
805
|
+
argsPrefixes: [[status], [diff]]
|
|
806
|
+
- executable: rg
|
|
722
807
|
subagent:
|
|
723
808
|
agents: [scout, planner, worker, reviewer]
|
|
724
809
|
contexts: [fresh]
|
|
@@ -739,34 +824,36 @@ path.
|
|
|
739
824
|
Project workflows load only when Pi trusts the project and every step stays
|
|
740
825
|
within this ceiling. The `subagent` ceiling is optional for main-only project
|
|
741
826
|
workflows; if omitted, any project step that declares `subagent` is rejected.
|
|
827
|
+
Project workflows cannot declare `workspace` binding at all, even when their
|
|
828
|
+
other permissions fit the ceiling. Keep workflows that create, choose, or bind
|
|
829
|
+
a different execution directory in the user-owned workflow directory.
|
|
742
830
|
Each delegated project step must declare `turnBudget` and `toolBudget` with
|
|
743
831
|
`"block": "*"`, so it cannot silently inherit unbounded child defaults or keep
|
|
744
832
|
mutation tools after reaching the hard limit. The ceiling also controls
|
|
745
833
|
agent profile names, fresh-context use, model overrides, timeouts, artifact
|
|
746
|
-
retention, and the Bash rules
|
|
747
|
-
|
|
748
|
-
commands.
|
|
834
|
+
retention, and the Bash rules that a project workflow may request. Project
|
|
835
|
+
workflows cannot override user workflow identifiers or commands.
|
|
749
836
|
|
|
750
837
|
## Architecture
|
|
751
838
|
|
|
752
839
|
The package keeps the Pi entry point intentionally small:
|
|
753
840
|
|
|
754
|
-
| Module | Responsibility
|
|
755
|
-
| --------------------------------- |
|
|
756
|
-
| `src/index.ts` | Pi entry point only.
|
|
757
|
-
| `src/harness.ts` | Runtime orchestration and session lifecycle.
|
|
758
|
-
| `src/commands.ts` | User command surface.
|
|
759
|
-
| `src/config/` | Types, strict validation, prompt loading, precedence, ceilings.
|
|
760
|
-
| `src/engine/` | Serializable run state and deterministic transitions.
|
|
761
|
-
| `src/policy/` | Tool, MCP, and Bash enforcement.
|
|
762
|
-
| `src/
|
|
763
|
-
| `src/integrations/subagents/` | Delegation client, child protocol, and child policy runtime.
|
|
764
|
-
| `src/integrations/plannotator.ts` | Versioned Plannotator gate adapter.
|
|
765
|
-
| `src/integrations/prompt-gate.ts` | Built-in Pi prompt review adapter.
|
|
766
|
-
| `src/runtime/` | Shared completion parsing and main-agent step runtime.
|
|
767
|
-
| `src/preflight.ts` | Required tool, extension, and skill checks.
|
|
768
|
-
| `src/prompt.ts` | Template rendering and step contract.
|
|
769
|
-
| `agents/step.md` | Default general-purpose profile plus workflow child guidance.
|
|
841
|
+
| Module | Responsibility |
|
|
842
|
+
| --------------------------------- | --------------------------------------------------------------- |
|
|
843
|
+
| `src/index.ts` | Pi entry point only. |
|
|
844
|
+
| `src/harness.ts` | Runtime orchestration and session lifecycle. |
|
|
845
|
+
| `src/commands.ts` | User command surface. |
|
|
846
|
+
| `src/config/` | Types, strict validation, prompt loading, precedence, ceilings. |
|
|
847
|
+
| `src/engine/` | Serializable run state and deterministic transitions. |
|
|
848
|
+
| `src/policy/` | Tool, MCP, and Bash enforcement. |
|
|
849
|
+
| `src/workflow-doctor.ts` | Deterministic transition-graph liveness diagnostics. |
|
|
850
|
+
| `src/integrations/subagents/` | Delegation client, child protocol, and child policy runtime. |
|
|
851
|
+
| `src/integrations/plannotator.ts` | Versioned Plannotator gate adapter. |
|
|
852
|
+
| `src/integrations/prompt-gate.ts` | Built-in Pi prompt review adapter. |
|
|
853
|
+
| `src/runtime/` | Shared completion parsing and main-agent step runtime. |
|
|
854
|
+
| `src/preflight.ts` | Required tool, extension, and skill checks. |
|
|
855
|
+
| `src/prompt.ts` | Template rendering and step contract. |
|
|
856
|
+
| `agents/step.md` | Default general-purpose profile plus workflow child guidance. |
|
|
770
857
|
|
|
771
858
|
The engine and policy modules do not depend on Pi runtime types, so they are fast to test.
|
|
772
859
|
|
|
@@ -785,7 +872,7 @@ process separation when a step opts into pi-subagents:
|
|
|
785
872
|
- a single-use, parent-created child capability tied to the delegated step;
|
|
786
873
|
- explicit MCP server and tool checks;
|
|
787
874
|
- restricted Bash parsing;
|
|
788
|
-
- exact Bash
|
|
875
|
+
- exact user-declared Bash executable and argument-prefix rules;
|
|
789
876
|
- project trust and a user-owned permission ceiling;
|
|
790
877
|
- fail-closed durable state, correlated child results, and correlated gate results.
|
|
791
878
|
|
|
@@ -798,14 +885,15 @@ source before installing or enabling it.
|
|
|
798
885
|
Step completion is structurally validated—policy digest, declared outcome,
|
|
799
886
|
non-empty bounded summary, required gate artifact, and sole completion call—but
|
|
800
887
|
the harness cannot prove that a model's semantic claims or test evidence are
|
|
801
|
-
true. Put exact checks in
|
|
802
|
-
verification step, and keep consequential actions behind a human
|
|
888
|
+
true. Put exact checks and acceptance criteria in the workflow prompt, use an
|
|
889
|
+
independent verification step, and keep consequential actions behind a human
|
|
890
|
+
gate.
|
|
803
891
|
|
|
804
892
|
The harness does not provide exactly-once external effects. If a publish step
|
|
805
893
|
is interrupted after a remote action succeeds but before it checkpoints, a
|
|
806
|
-
resumed execution receives the same
|
|
807
|
-
query the remote effect first, skip only proven-complete actions,
|
|
808
|
-
ambiguous state.
|
|
894
|
+
resumed execution receives the same declarative step permissions. Publish
|
|
895
|
+
prompts should query the remote effect first, skip only proven-complete actions,
|
|
896
|
+
and pause on ambiguous state.
|
|
809
897
|
|
|
810
898
|
## Development
|
|
811
899
|
|
|
@@ -821,10 +909,14 @@ main-agent completion, built-in feedback/approval, subagent request correlation
|
|
|
821
909
|
and cancellation, child policy enforcement, and dependency preflight,
|
|
822
910
|
including bounded automatic recovery after replay-safe terminal errors,
|
|
823
911
|
timeouts, budget exhaustion, and nonzero exits; duplicate-failure stopping;
|
|
824
|
-
|
|
912
|
+
opaque gate artifacts; workspace binding and cwd reuse; workflow liveness
|
|
913
|
+
diagnostics; and fail-closed legacy checkpoints.
|
|
825
914
|
`bun run check` also launches real Pi RPC subprocesses, invokes
|
|
826
915
|
`/work`, and verifies fresh `scout`, `worker`, and `reviewer` children receive
|
|
827
|
-
only the explicit compact handoff from the immediately preceding step.
|
|
916
|
+
only the explicit compact handoff from the immediately preceding step. The
|
|
917
|
+
real-Pi scenario binds a sibling workspace, revisits its worker once, and
|
|
918
|
+
verifies that every downstream visit keeps the bound cwd and receives no
|
|
919
|
+
undeclared `replan` outcome.
|
|
828
920
|
|
|
829
921
|
## Publishing checklist
|
|
830
922
|
|
|
@@ -845,7 +937,6 @@ extensions, without hard-coding them into the orchestrator, are:
|
|
|
845
937
|
| --------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
846
938
|
| Configurable recovery and backoff | Replace the fixed two-attempt recovery cap with a ceiling-aware per-step transient-failure policy. |
|
|
847
939
|
| Acceptance criteria | Give each step machine-checkable completion evidence and verification commands. |
|
|
848
|
-
| Working directory or worktree | Isolate mutating steps, monorepo packages, and concurrent branches. |
|
|
849
940
|
| Parallel groups and join policy | Run independent steps together and declare fail-fast, quorum, or all-success behavior. |
|
|
850
941
|
| Generic gates | Add ticket, CI, chat, or custom approval providers behind the same versioned gate contract. |
|
|
851
942
|
| Output schema and named artifacts | Pass structured data between steps instead of relying only on a summary. |
|
|
@@ -859,7 +950,7 @@ extensions, without hard-coding them into the orchestrator, are:
|
|
|
859
950
|
- Gate providers are built-in prompt and Plannotator; custom providers are not yet configurable.
|
|
860
951
|
- Delegated steps require pi-subagents 0.36.0 or newer and launch the actual profile selected by `subagent.agent`.
|
|
861
952
|
- Extension tools are enforced; autonomous extension event-handler side effects cannot be disabled per step.
|
|
862
|
-
- Completion evidence is model-reported; use
|
|
953
|
+
- Completion evidence is model-reported; use declarative executable checks and a fresh verification step when correctness matters.
|
|
863
954
|
- Workflow configuration uses YAML. Prompt bodies may live in separate Markdown files.
|
|
864
955
|
|
|
865
956
|
## License
|