@wichayutdew/pi-workflows 1.0.1 → 2.0.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 (131) hide show
  1. package/README.md +320 -223
  2. package/agents/step.md +4 -11
  3. package/dist/index.js +2554 -976
  4. package/examples/mr-comments.workflow.yaml +16 -8
  5. package/examples/prompts/mr-comments/implement.md +13 -9
  6. package/examples/prompts/mr-comments/plan.md +44 -15
  7. package/examples/prompts/mr-comments/verify.md +8 -7
  8. package/examples/settings.yaml +7 -1
  9. package/examples/starter-kit/mr-comment.workflow.yaml +149 -0
  10. package/examples/starter-kit/mr-review.workflow.yaml +130 -0
  11. package/examples/starter-kit/steps/mr-comment/fetch.md +33 -0
  12. package/examples/starter-kit/steps/mr-comment/implement.md +38 -0
  13. package/examples/starter-kit/steps/mr-comment/plan.md +62 -0
  14. package/examples/starter-kit/steps/mr-comment/publish.md +36 -0
  15. package/examples/starter-kit/steps/mr-comment/verify.md +35 -0
  16. package/examples/starter-kit/steps/mr-review/fetch.md +25 -0
  17. package/examples/starter-kit/steps/mr-review/publish.md +30 -0
  18. package/examples/starter-kit/steps/mr-review/review.md +69 -0
  19. package/examples/starter-kit/steps/mr-review/verify.md +24 -0
  20. package/examples/starter-kit/steps/shared/prepare-workspace.md +57 -0
  21. package/examples/starter-kit/steps/ticket/implement.md +35 -0
  22. package/examples/starter-kit/steps/ticket/plan.md +40 -0
  23. package/examples/starter-kit/steps/ticket/verify.md +29 -0
  24. package/examples/starter-kit/steps/work/implement.md +34 -0
  25. package/examples/starter-kit/steps/work/plan.md +38 -0
  26. package/examples/starter-kit/steps/work/verify.md +30 -0
  27. package/examples/starter-kit/ticket.workflow.yaml +100 -0
  28. package/examples/starter-kit/work.workflow.yaml +97 -0
  29. package/package.json +3 -3
  30. package/schemas/workflow.schema.json +78 -44
  31. package/src/command-names.ts +1 -0
  32. package/src/commands.ts +33 -4
  33. package/src/config/ceiling.ts +6 -12
  34. package/src/config/load-workflows.ts +12 -1
  35. package/src/config/step-digests.ts +19 -0
  36. package/src/config/types.ts +17 -22
  37. package/src/config/validation/permissions.ts +5 -66
  38. package/src/config/validation/prompt.ts +1 -0
  39. package/src/config/validation/shared.ts +0 -2
  40. package/src/config/validation/step.ts +106 -2
  41. package/src/config/validation/workflow.ts +76 -0
  42. package/src/engine/create-run.ts +3 -0
  43. package/src/engine/gate-transitions.ts +58 -9
  44. package/src/engine/reconciliation-history.ts +61 -24
  45. package/src/engine/run-advance.ts +37 -4
  46. package/src/engine/run-lifecycle.ts +11 -0
  47. package/src/engine/run-reconciliation.ts +51 -21
  48. package/src/engine/run-validation.ts +235 -0
  49. package/src/engine/run-workflow-validation.ts +191 -0
  50. package/src/engine/state-types.ts +108 -5
  51. package/src/engine/state.ts +15 -1
  52. package/src/engine/step-trace.ts +495 -0
  53. package/src/engine/transitions.ts +1 -0
  54. package/src/harness/action-context.ts +31 -6
  55. package/src/harness/core-actions.ts +30 -1
  56. package/src/harness/delegation-control-actions.ts +27 -2
  57. package/src/harness/delegation-failure.ts +42 -9
  58. package/src/harness/delegation-plan.ts +96 -40
  59. package/src/harness/delegation-recovery-validation.ts +3 -1
  60. package/src/harness/delegation-response-actions.ts +73 -3
  61. package/src/harness/delegation-retry-policy.ts +5 -3
  62. package/src/harness/dependencies.ts +11 -2
  63. package/src/harness/gate-submission-action.ts +5 -31
  64. package/src/harness/lifecycle-actions.ts +4 -5
  65. package/src/harness/pause-actions.ts +10 -1
  66. package/src/harness/plannotator-result-actions.ts +20 -11
  67. package/src/harness/prompt-gate-actions.ts +40 -2
  68. package/src/harness/resume-action.ts +75 -1
  69. package/src/harness/start-actions.ts +77 -3
  70. package/src/harness/status-actions.ts +7 -17
  71. package/src/harness/step-effects.ts +61 -0
  72. package/src/harness/step-execution-actions.ts +181 -25
  73. package/src/harness/step-reporting.ts +168 -0
  74. package/src/harness/types.ts +1 -0
  75. package/src/harness/workspace-directory.ts +67 -0
  76. package/src/harness.ts +37 -9
  77. package/src/integrations/plannotator-requests.ts +40 -5
  78. package/src/integrations/subagents/child-policy-sections.ts +71 -84
  79. package/src/integrations/subagents/child-policy-types.ts +7 -7
  80. package/src/integrations/subagents/child-policy-validation.ts +10 -4
  81. package/src/integrations/subagents/child-runtime-completion.ts +1 -0
  82. package/src/integrations/subagents/child-runtime-files.ts +29 -86
  83. package/src/integrations/subagents/child-runtime-policy.ts +8 -33
  84. package/src/integrations/subagents/child-runtime.ts +3 -15
  85. package/src/integrations/subagents/delegated-result.ts +1 -0
  86. package/src/integrations/subagents/diagnostic-format.ts +5 -0
  87. package/src/integrations/subagents/diagnostic-types.ts +7 -1
  88. package/src/integrations/subagents/diagnostics.ts +2 -0
  89. package/src/integrations/subagents/failure-correlation.ts +52 -2
  90. package/src/integrations/subagents/failure-transcript.ts +60 -1
  91. package/src/integrations/subagents/replay-audit.ts +0 -1
  92. package/src/integrations/subagents/replay-safety.ts +12 -27
  93. package/src/integrations/subagents/session-diagnostics.ts +102 -3
  94. package/src/policy/bash-authorization.ts +2 -21
  95. package/src/policy/bash-types.ts +0 -5
  96. package/src/policy/bash.ts +1 -2
  97. package/src/policy/tool-call-authorization.ts +1 -7
  98. package/src/preflight.ts +0 -5
  99. package/src/prompt/retry-task.ts +11 -3
  100. package/src/prompt/step-contract.ts +10 -56
  101. package/src/prompt/step-sections.ts +8 -10
  102. package/src/prompt/step-task.ts +41 -10
  103. package/src/prompt/template.ts +3 -2
  104. package/src/runtime/completion-tool.ts +14 -0
  105. package/src/runtime/main-step-completion.ts +3 -0
  106. package/src/runtime/main-step-policy.ts +2 -1
  107. package/src/runtime/main-step-runtime-types.ts +9 -1
  108. package/src/runtime/main-step-runtime.ts +2 -0
  109. package/src/runtime/main-step-state.ts +6 -0
  110. package/src/runtime/main-step-trace.ts +45 -0
  111. package/src/runtime/step-result.ts +57 -0
  112. package/src/step-log.ts +178 -0
  113. package/src/workflow-doctor.ts +254 -0
  114. package/src/workflow-status/format-status.ts +32 -3
  115. package/src/workflow-status/render-board.ts +7 -4
  116. package/src/workflow-status/render-path.ts +51 -24
  117. package/src/workflow-status/render-step-detail.ts +379 -0
  118. package/src/workflow-status/render-summary.ts +22 -0
  119. package/src/workflow-status/transcript-reader.ts +231 -0
  120. package/src/workflow-status/types.ts +8 -0
  121. package/src/workflow-status/view.ts +161 -14
  122. package/src/workflow-status.ts +6 -0
  123. package/src/policy/approved-command-extraction.ts +0 -71
  124. package/src/policy/approved-commands.ts +0 -15
  125. package/src/policy/bash-read-only.ts +0 -161
  126. package/src/policy/restricted-git.ts +0 -30
  127. package/src/policy/reviewed-artifact.ts +0 -97
  128. package/src/policy/reviewed-command-safety.ts +0 -150
  129. package/src/policy/reviewed-command-shape.ts +0 -49
  130. package/src/policy/reviewed-repository-contract.ts +0 -138
  131. package/src/policy/reviewed-repository-cwd.ts +0 -102
@@ -22,7 +22,13 @@ steps:
22
22
  tools: [read, grep, bash]
23
23
  mcp: [gitlab/get_merge_request, gitlab/list_merge_request_discussions]
24
24
  bash:
25
- mode: read-only
25
+ mode: allow-list
26
+ allow:
27
+ - executable: git
28
+ argsPrefixes:
29
+ [[status], [diff], [log], [show], [grep], [ls-files], [rev-parse]]
30
+ - executable: rg
31
+ argsPrefix: []
26
32
  requires:
27
33
  tools: [read, bash, mcp]
28
34
  transitions:
@@ -42,23 +48,27 @@ steps:
42
48
  permissions:
43
49
  tools: [read, grep, bash]
44
50
  mcp: [gitlab/get_merge_request, gitlab/list_merge_request_discussions]
45
- extensions: [plannotator]
46
51
  skills: [superpowers:brainstorming]
47
52
  bash:
48
- mode: read-only
53
+ mode: allow-list
54
+ allow:
55
+ - executable: git
56
+ argsPrefixes:
57
+ [[status], [diff], [log], [show], [grep], [ls-files], [rev-parse]]
58
+ - executable: rg
59
+ argsPrefix: []
49
60
  requires:
50
61
  tools: [read, mcp]
51
- extensions: [plannotator]
52
62
  skills: [superpowers:brainstorming]
53
63
  gate:
54
64
  provider: plannotator
55
65
  submitOutcome: submit
56
66
  approvedOutcome: approved
57
67
  rejectedOutcome: changes-requested
58
- timeoutMs: 5000
68
+ timeoutMs: 30000
59
69
  transitions:
60
70
  approved: implement
61
- changes-requested: plan
71
+ changes-requested: $pause
62
72
  blocked: $pause
63
73
  implement:
64
74
  title: Implement the approved plan
@@ -79,7 +89,6 @@ steps:
79
89
  argsPrefixes: [[status], [diff]]
80
90
  - executable: npm
81
91
  argsPrefix: [test]
82
- approvedSources: [verification-worker]
83
92
  requires:
84
93
  tools: [read, edit, bash]
85
94
  skills: [superpowers:test-driven-development]
@@ -107,7 +116,6 @@ steps:
107
116
  argsPrefixes: [[status], [diff]]
108
117
  - executable: npm
109
118
  argsPrefix: [test]
110
- approvedSources: [verification-reviewer]
111
119
  requires:
112
120
  tools: [read, bash]
113
121
  transitions:
@@ -1,13 +1,17 @@
1
1
  Implement the approved plan with a small, coherent diff.
2
2
 
3
+ Approved review artifact:
4
+
5
+ {{reviewed.artifact}}
6
+
3
7
  Use repository conventions and the allowed skill. Add or update focused tests
4
- where practical. Treat the approved plan as the final contract: do not ask a
5
- terminal question or block solely because a profile or skill prefers an
6
- unapproved ceremony or command. Apply TDD with the authorized commands when the
7
- reviewed contract supports it; otherwise implement and record that constraint.
8
- Run each exact reviewed worker command with its enclosing
9
- `repositories[].cwd`, plus the static allow-list. Do not perform remote actions.
8
+ where practical. Treat the approved plan as the final contract. Apply TDD with
9
+ commands permitted by this step's declarative Bash allow-list. Do not perform
10
+ remote actions.
10
11
  Complete with `ready` when implementation and focused checks are complete;
11
- include the exact fenced JSON contract in the summary for verification.
12
- Complete with `blocked` only if the harness, configuration, repository, or
13
- approved contract must be repaired first.
12
+ include a compact verification handoff in the summary.
13
+ Complete with `retry` when the approved contract remains valid and another
14
+ bounded attempt can safely continue unfinished work. The `replan` outcome is
15
+ unavailable. When the approved contract is missing, stale, contradictory, or
16
+ requires a material change to its targets or authority,
17
+ complete with `blocked` and preserve the existing worktree for follow-up.
@@ -1,18 +1,47 @@
1
- Create a concrete implementation plan from the inspected feedback.
2
-
3
- Include scope, exact files or symbols, risks, and verification. Account for prior review feedback:
1
+ Create a concrete, decision-ready implementation plan from the inspected
2
+ feedback. Account for previous Plannotator feedback:
4
3
 
5
4
  {{gate.feedback}}
6
5
 
7
- Include one fenced `json` verification contract with a top-level
8
- `repositories` array. Every repository entry must contain its exact absolute
9
- `cwd`; this workflow requires one distinct repository directory. Put exact
10
- standalone implementation commands under `worker[].command` and independent
11
- commands under `reviewer[].command`. Resolve any TDD setup, test selection, or
12
- command limitation in this reviewed contract; later steps must not invent
13
- another prerequisite or ask for clarification.
14
-
15
- When the plan is ready, call `structured_output` with a `value` whose outcome
16
- is `submit` and whose `artifact` is the full Markdown plan. The Plannotator gate
17
- decides the next transition; its reviewed artifact becomes the next step's
18
- handoff.
6
+ Write the artifact for a human reviewer first. Use this order:
7
+
8
+ # <Short outcome-oriented title>
9
+
10
+ ## Review summary
11
+
12
+ In three to five plain-language bullets, explain the desired result, why it
13
+ matters, what is in scope, and what is deliberately out of scope.
14
+
15
+ ## Review focus
16
+
17
+ List only choices that materially affect behavior, scope, risk, or an
18
+ irreversible action. For each choice, give the recommendation, useful
19
+ alternatives, and consequence. Say `No decisions needed` when there are none.
20
+
21
+ ## Proposed changes
22
+
23
+ Use a short numbered list. Name the exact file or symbol, state its observable
24
+ change and reason, and give the corresponding acceptance criterion. Use
25
+ checkboxes only for acceptance criteria, not for scope, evidence, risks, or
26
+ every sentence.
27
+
28
+ ## Validation
29
+
30
+ Explain the focused and independent checks in reviewer language. State what
31
+ each check proves; keep exact shell metadata out of this narrative.
32
+
33
+ ## Risks
34
+
35
+ List only material risks, with a concrete safeguard or rollback signal for
36
+ each. Cite decisive evidence inline instead of dumping raw exploration logs or
37
+ labeling every bullet `FACT`, `HYPOTHESIS`, or `UNKNOWN`.
38
+
39
+ Do not leave `UNKNOWN`, `TBD`, or implementation-time research in the plan. If
40
+ the allowed resources cannot resolve required access, provenance, repository
41
+ state, resource identity, or targets, complete with `blocked` instead of
42
+ submitting an incomplete plan. A user choice may remain only in Review focus
43
+ with evidence and an adopted recommendation.
44
+
45
+ When ready, call `structured_output` with a `value` whose outcome is `submit`
46
+ and whose `artifact` is the full Markdown plan. This format is defined by this
47
+ workflow prompt; Pi Workflows treats the artifact as opaque.
@@ -1,8 +1,9 @@
1
- Review the implementation against the requested merge-request feedback and approved plan.
1
+ Review the implementation against the requested merge-request feedback and
2
+ approved plan:
2
3
 
3
- Inspect the diff and run each exact reviewed reviewer command with its enclosing
4
- `repositories[].cwd`, plus the static allow-list. Do not ask a terminal
5
- question. Complete with `passed` only when evidence supports completion.
6
- Complete with `failed` to return to implementation and preserve the exact
7
- fenced JSON contract in the summary, or `blocked` when the workflow or
8
- environment must be repaired.
4
+ {{reviewed.artifact}}
5
+
6
+ Inspect the diff and run checks permitted by this step's declarative Bash
7
+ allow-list. Complete with `passed` only when evidence supports completion.
8
+ Complete with `failed` to return to implementation with a compact actionable
9
+ summary, or `blocked` when the workflow or environment must be repaired.
@@ -8,7 +8,13 @@ permissionCeiling:
8
8
  extensions: []
9
9
  skills: []
10
10
  bash:
11
- mode: read-only
11
+ mode: allow-list
12
+ allow:
13
+ - executable: git
14
+ argsPrefixes:
15
+ [[status], [diff], [log], [show], [grep], [ls-files], [rev-parse]]
16
+ - executable: rg
17
+ argsPrefix: []
12
18
  subagent:
13
19
  agents: [scout, planner, worker, reviewer]
14
20
  contexts: [fresh]
@@ -0,0 +1,149 @@
1
+ version: 1
2
+ id: mr-comment
3
+ command: mr-comment
4
+ description: Fetch review comments, approve fixes, edit the current checkout, verify, push, and reply
5
+ start: fetch
6
+ maxStepVisits: 4
7
+ summaryMaxChars: 50000
8
+ steps:
9
+ fetch:
10
+ title: Fetch merge-request or pull-request comments
11
+ prompt:
12
+ file: steps/mr-comment/fetch.md
13
+ subagent:
14
+ agent: scout
15
+ context: fresh
16
+ timeoutMs: 1800000
17
+ permissions:
18
+ tools: [read, ls, bash]
19
+ mcp: [gitlab, github]
20
+ bash:
21
+ mode: allow-list
22
+ allow:
23
+ - executable: git
24
+ argsPrefixes:
25
+ [
26
+ [status],
27
+ [diff],
28
+ [log],
29
+ [show],
30
+ [grep],
31
+ [ls-files],
32
+ [remote, -v],
33
+ [remote, get-url],
34
+ [rev-parse],
35
+ ]
36
+ - executable: glab
37
+ argsPrefixes: [[mr, view], [mr, diff], [api]]
38
+ - executable: gh
39
+ argsPrefixes: [[pr, view], [pr, diff], [pr, checks], [api]]
40
+ - executable: curl
41
+ requires:
42
+ tools: [read, ls, bash]
43
+ transitions:
44
+ ready: plan
45
+ blocked: $pause
46
+
47
+ plan:
48
+ title: Propose a complete comment-fix plan
49
+ prompt:
50
+ file: steps/mr-comment/plan.md
51
+ subagent:
52
+ agent: planner
53
+ context: fresh
54
+ timeoutMs: 1800000
55
+ permissions:
56
+ tools: [read, ls, bash]
57
+ mcp: [gitlab, github]
58
+ bash:
59
+ mode: allow-list
60
+ allow:
61
+ - executable: git
62
+ argsPrefixes:
63
+ [[status], [diff], [log], [show], [grep], [ls-files], [rev-parse]]
64
+ - executable: glab
65
+ argsPrefixes: [[mr, view], [mr, diff], [api]]
66
+ - executable: gh
67
+ argsPrefixes: [[pr, view], [pr, diff], [pr, checks], [api]]
68
+ - executable: curl
69
+ requires:
70
+ tools: [read, ls, bash]
71
+ gate:
72
+ provider: plannotator
73
+ submitOutcome: submit
74
+ approvedOutcome: approved
75
+ rejectedOutcome: changes-requested
76
+ timeoutMs: 30000
77
+ transitions:
78
+ approved: implement
79
+ changes-requested: $pause
80
+ blocked: $pause
81
+
82
+ implement:
83
+ title: Implement the approved comment fixes
84
+ prompt:
85
+ file: steps/mr-comment/implement.md
86
+ subagent:
87
+ agent: worker
88
+ context: fresh
89
+ timeoutMs: 7200000
90
+ artifacts: true
91
+ permissions:
92
+ tools: [read, ls, bash, edit, write]
93
+ mcp: [gitlab, github]
94
+ bash:
95
+ mode: unrestricted
96
+ requires:
97
+ tools: [read, ls, bash, edit, write]
98
+ transitions:
99
+ ready: verify
100
+ blocked: $pause
101
+
102
+ verify:
103
+ title: Independently verify comment handling
104
+ prompt:
105
+ file: steps/mr-comment/verify.md
106
+ subagent:
107
+ agent: reviewer
108
+ context: fresh
109
+ timeoutMs: 3600000
110
+ permissions:
111
+ tools: [read, ls, bash]
112
+ mcp: [gitlab, github]
113
+ bash:
114
+ mode: unrestricted
115
+ requires:
116
+ tools: [read, ls, bash]
117
+ transitions:
118
+ ready: publish
119
+ no-actions: $done
120
+ failed: implement
121
+ blocked: $pause
122
+
123
+ publish:
124
+ title: Push verified work and reply to comments
125
+ prompt:
126
+ file: steps/mr-comment/publish.md
127
+ subagent:
128
+ agent: worker
129
+ context: fresh
130
+ timeoutMs: 1800000
131
+ permissions:
132
+ tools: [read, ls, bash]
133
+ mcp: [gitlab, github]
134
+ bash:
135
+ mode: allow-list
136
+ allow:
137
+ - executable: git
138
+ argsPrefixes: [[status], [rev-parse], [show], [ls-remote], [push]]
139
+ - executable: glab
140
+ argsPrefixes: [[mr, view], [api]]
141
+ - executable: gh
142
+ argsPrefixes: [[pr, view], [api]]
143
+ - executable: curl
144
+ requires:
145
+ tools: [read, ls, bash]
146
+ transitions:
147
+ published: $done
148
+ no-actions: $done
149
+ blocked: $pause
@@ -0,0 +1,130 @@
1
+ version: 1
2
+ id: mr-review
3
+ command: mr-review
4
+ description: Fetch, approve, publish, and verify one hosted code review
5
+ start: fetch
6
+ maxStepVisits: 3
7
+ summaryMaxChars: 50000
8
+ steps:
9
+ fetch:
10
+ title: Fetch complete hosted-review evidence
11
+ prompt:
12
+ file: steps/mr-review/fetch.md
13
+ subagent:
14
+ agent: scout
15
+ context: fresh
16
+ timeoutMs: 1800000
17
+ permissions:
18
+ tools: [read, ls, bash]
19
+ mcp: [gitlab, github]
20
+ bash:
21
+ mode: allow-list
22
+ allow:
23
+ - executable: git
24
+ argsPrefixes:
25
+ [
26
+ [status],
27
+ [diff],
28
+ [log],
29
+ [show],
30
+ [grep],
31
+ [ls-files],
32
+ [remote, -v],
33
+ [remote, get-url],
34
+ [rev-parse],
35
+ ]
36
+ - executable: glab
37
+ argsPrefixes: [[mr, view], [mr, diff], [api]]
38
+ - executable: gh
39
+ argsPrefixes: [[pr, view], [pr, diff], [pr, checks], [api]]
40
+ - executable: curl
41
+ requires:
42
+ tools: [read, ls, bash]
43
+ transitions:
44
+ fetched: review
45
+ blocked: $pause
46
+
47
+ review:
48
+ title: Produce and approve a complete review
49
+ prompt:
50
+ file: steps/mr-review/review.md
51
+ subagent:
52
+ agent: reviewer
53
+ context: fresh
54
+ timeoutMs: 1800000
55
+ permissions:
56
+ tools: [read, ls, bash]
57
+ mcp: [gitlab, github]
58
+ bash:
59
+ mode: allow-list
60
+ allow:
61
+ - executable: git
62
+ argsPrefixes:
63
+ [[status], [diff], [log], [show], [grep], [ls-files], [rev-parse]]
64
+ - executable: glab
65
+ argsPrefixes: [[mr, view], [mr, diff], [api]]
66
+ - executable: gh
67
+ argsPrefixes: [[pr, view], [pr, diff], [pr, checks], [api]]
68
+ - executable: curl
69
+ requires:
70
+ tools: [read, ls, bash]
71
+ gate:
72
+ provider: plannotator
73
+ submitOutcome: submit
74
+ approvedOutcome: approved
75
+ rejectedOutcome: changes-requested
76
+ timeoutMs: 30000
77
+ transitions:
78
+ approved: publish
79
+ changes-requested: $pause
80
+ blocked: $pause
81
+
82
+ publish:
83
+ title: Publish the approved review
84
+ prompt:
85
+ file: steps/mr-review/publish.md
86
+ subagent:
87
+ agent: worker
88
+ context: fresh
89
+ timeoutMs: 900000
90
+ permissions:
91
+ tools: [bash]
92
+ mcp: [gitlab, github]
93
+ bash:
94
+ mode: allow-list
95
+ allow:
96
+ - executable: glab
97
+ argsPrefixes: [[mr, view], [api]]
98
+ - executable: gh
99
+ argsPrefixes: [[pr, view], [api]]
100
+ - executable: curl
101
+ requires:
102
+ tools: [bash]
103
+ transitions:
104
+ published: verify
105
+ blocked: $pause
106
+
107
+ verify:
108
+ title: Verify the review is observable remotely
109
+ prompt:
110
+ file: steps/mr-review/verify.md
111
+ subagent:
112
+ agent: reviewer
113
+ context: fresh
114
+ timeoutMs: 900000
115
+ permissions:
116
+ tools: [bash]
117
+ mcp: [gitlab, github]
118
+ bash:
119
+ mode: allow-list
120
+ allow:
121
+ - executable: glab
122
+ argsPrefixes: [[mr, view], [api]]
123
+ - executable: gh
124
+ argsPrefixes: [[pr, view], [api]]
125
+ - executable: curl
126
+ requires:
127
+ tools: [bash]
128
+ transitions:
129
+ verified: $done
130
+ blocked: $pause
@@ -0,0 +1,33 @@
1
+ You are the initial evidence-acquisition child for unresolved GitLab merge
2
+ request or GitHub pull request comments. Do not propose fixes, edit files, or
3
+ mutate remote state.
4
+
5
+ Review input:
6
+ {{workflow.input}}
7
+
8
+ Resolve exactly one canonical HTTPS review URL. Fetch through the matching
9
+ configured MCP server first, then the matching host CLI (`glab` or `gh`), then
10
+ authenticated read-only cURL when a required read is unavailable. Stay on the
11
+ same host and never expose credentials.
12
+
13
+ Collect title and description, source/target branches and SHAs, commits,
14
+ complete diff, checks/pipelines, conflicts, and every discussion/comment with
15
+ stable ID, author, body, replies, current resolution, and path/line anchor.
16
+ Follow pagination to completion.
17
+
18
+ Inspect the current Git root, registered worktree, branch, HEAD, status,
19
+ remotes, and repository instructions. This current checkout is the only
20
+ workspace the entire workflow may use. Never create, switch, reset, clean,
21
+ delete, or prepare another branch or worktree. Preserve all local changes. A
22
+ local branch ahead of the hosted head is evidence, not a reason to reset it.
23
+ Run Git inspection from the current child directory with the subcommand first
24
+ (`git status`, `git rev-parse`, and so on); the YAML allow-list does not permit
25
+ a dynamic `git -C` prefix. For machine-readable GitLab evidence, prefer
26
+ `glab api` and do not assume the installed `glab mr view` supports `--json`.
27
+
28
+ Call `structured_output` alone with outcome `ready` and a self-contained
29
+ evidence packet in `summary`: canonical URL/host, review identity, branches and
30
+ SHAs, current Git root/worktree/branch/HEAD/status, head relationship, changed
31
+ files, checks/conflicts, every unresolved comment and anchor, pagination, and
32
+ acquisition mechanisms. Use `blocked` when review identity, authentication,
33
+ pagination, checkout identity, or material evidence cannot be made safe.
@@ -0,0 +1,38 @@
1
+ You implement the approved hosted-review comment fixes on top of the current
2
+ checkout.
3
+
4
+ Review input:
5
+ {{workflow.input}}
6
+
7
+ Approved plan:
8
+ {{reviewed.artifact}}
9
+
10
+ Approval feedback:
11
+ {{reviewed.feedback}}
12
+
13
+ Previous attempt handoff:
14
+ {{last.summary}}
15
+
16
+ Refresh the same-host review head and comments read-only. Confirm the current
17
+ Git root, registered worktree, branch, HEAD, and existing files still match the
18
+ approved contract. This checkout is the only workspace. Never create, switch,
19
+ reset, clean, delete, or prepare another branch or worktree. Preserve unrelated
20
+ local work and inspect already-present changes before each action.
21
+
22
+ Apply only the approved scoped fixes. Derive command syntax from the repository
23
+ and current tool documentation; the harness does not know the language,
24
+ framework, package manager, argument order, or cwd syntax. Diagnose a failed
25
+ invocation and current state before trying a semantically identical repair.
26
+ Never weaken checks, broaden mutation scope, or duplicate an existing commit.
27
+
28
+ Run all approved worker validation and commit only when the contract requires
29
+ it. Do not push, reply, resolve, approve, merge, close, delete, or otherwise
30
+ mutate remote state.
31
+
32
+ Call `structured_output` alone with outcome `ready` when local work is ready for
33
+ independent verification. Repeat review/head/checkout identity, comment
34
+ classifications, changed files, exact commands/results, criteria evidence,
35
+ commit or reply-only state, current status, intended replies, risks, and the
36
+ unchanged Execution contract in `summary`. Use `blocked` for stale identity,
37
+ missing authority, unsafe scope, or exhausted recovery. Do not create a new
38
+ plan or workspace.
@@ -0,0 +1,62 @@
1
+ You are the planning child for unresolved hosted-review comments.
2
+
3
+ Review input:
4
+ {{workflow.input}}
5
+
6
+ Fetched evidence:
7
+ {{last.summary}}
8
+
9
+ Feedback from a previously rejected review:
10
+ {{gate.feedback}}
11
+
12
+ Re-verify the same review and the current Git root, registered worktree,
13
+ branch, HEAD, and status. Work on top of this checkout exactly as it exists.
14
+ Never create, switch, reset, clean, delete, or prepare another branch or
15
+ worktree. Use matching read-only MCP/CLI/cURL calls and repository inspection
16
+ to close evidence gaps.
17
+
18
+ Classify every unresolved comment as valid, partly valid, invalid, or already
19
+ addressed, with causal evidence. Define scoped code changes, exact
20
+ repository-native checks, an optional commit, and the public reply for each
21
+ comment. Include a non-force push only when verified local code must reach the
22
+ host. Never include approval, merge, resolution, closure, deletion,
23
+ force-push, cross-host mutation, or unrelated work.
24
+
25
+ This user-owned prompt defines the Plannotator artifact:
26
+
27
+ 1. `# <outcome-oriented title>`
28
+ 2. `## Review summary`
29
+ 3. `## Comment decisions`
30
+ 4. `## Implementation plan`
31
+ 5. `## Acceptance criteria and validation`
32
+ 6. `## Replies and remote actions`
33
+ 7. `## Risks`
34
+ 8. `## Execution contract`
35
+
36
+ The Execution contract is one fenced `json` object containing:
37
+
38
+ - `repository`: exact current root, worktree, branch, starting HEAD, hosted
39
+ head, scoped files, optional commit title, and acceptance criteria;
40
+ - `workerCommands` and `reviewerCommands`: exact repository-native commands
41
+ derived from current scripts and documentation;
42
+ - `remoteActions`: ordered non-force push and same-host reply actions, each
43
+ with an exact configured MCP tool/input or standalone `git`, `glab`, `gh`, or
44
+ cURL command, stable review/comment identity, precondition, effect, and
45
+ unique marker.
46
+
47
+ Command shape is domain data owned by this prompt. Verify executable,
48
+ subcommand, argument ordering, and cwd behavior from repository context or
49
+ current tool help. Do not assume a language, framework, package manager, or
50
+ flag order. All Git actions run from `repository.cwd`: emit `git <subcommand>`
51
+ with the approved subcommand first and never add a dynamic `git -C` prefix,
52
+ because the publisher's YAML allow-list authorizes concrete subcommands. For
53
+ machine-readable GitLab state, prefer `glab api` and do not assume the installed
54
+ `glab mr view` supports `--json`. Use no unresolved placeholders, credentials,
55
+ shell composition, or wrapper shells.
56
+
57
+ Call `structured_output` alone with outcome `submit` only when the complete
58
+ plan can be implemented and published without another planning decision. Put
59
+ the Markdown plan in `artifact` and a self-contained handoff, including the
60
+ unchanged JSON contract, in `summary`. Use `blocked` when identity, scope,
61
+ authority, anchors, or evidence cannot be made safe. Rejection pauses through
62
+ the YAML transition; never automatically replan or create a new workspace.
@@ -0,0 +1,36 @@
1
+ You publish the independently verified comment fixes and replies. Operate only
2
+ from the current Git root, branch, and worktree; never create, switch, reset,
3
+ clean, delete, or prepare another one.
4
+
5
+ Review input:
6
+ {{workflow.input}}
7
+
8
+ Verified handoff:
9
+ {{last.summary}}
10
+
11
+ Refresh the same-host review head, comment anchors, local HEAD/status, and
12
+ remote branch through read-only calls. Require every identity and precondition
13
+ in the approved Execution contract to remain current.
14
+ Run Git from the current child directory with the approved subcommand first;
15
+ do not add `git -C`. Use `glab api` for machine-readable GitLab reads instead of
16
+ assuming `glab mr view --json` support.
17
+
18
+ For each approved remote action, query its observable effect first. Skip only
19
+ an exact already-present non-force push SHA or an exact reply by the current
20
+ user with the approved marker. Execute each remaining action once, in approved
21
+ order, through its exact configured MCP tool/input or standalone `git`, `glab`,
22
+ `gh`, or authenticated cURL command. Push before replies that describe the
23
+ code fix.
24
+
25
+ Require a successful same-host, target-correlated response. Never change reply
26
+ meaning, target another comment, expose credentials, force-push, approve,
27
+ merge, resolve, close, delete, or perform an unlisted mutation. After any
28
+ mutation-capable call is attempted, ambiguity is `blocked`; never blindly
29
+ replay it.
30
+
31
+ Call `structured_output` alone with outcome `published` only after every
32
+ approved push/reply succeeds now or is proven already complete. Record each
33
+ pre-state, attempted/skipped action, exact result, remote identifier/URL, final
34
+ remote head, and remaining work in `summary`. Use `no-actions` only when the
35
+ approved list is empty and current evidence confirms nothing is required. Use
36
+ `blocked` with the full ledger on stale or ambiguous state.
@@ -0,0 +1,35 @@
1
+ You independently verify the approved review-comment implementation. Do not
2
+ edit files, change branches or worktrees, or mutate remote state.
3
+
4
+ Review input:
5
+ {{workflow.input}}
6
+
7
+ Approved plan:
8
+ {{reviewed.artifact}}
9
+
10
+ Implementation handoff:
11
+ {{last.summary}}
12
+
13
+ Refresh the same-host review and unresolved comments read-only. Confirm the
14
+ current Git root, registered worktree, branch, HEAD, and status still identify
15
+ the original checkout and approved scope. Never create or switch a workspace.
16
+
17
+ Inspect the diff/commit, affected callers, tests, unrelated changes, and every
18
+ acceptance criterion. Run all exact reviewer commands from the approved
19
+ contract. A skipped, stale, unavailable, or failing required check is not
20
+ passing. Verify every planned reply remains accurate and targets the same
21
+ comment/anchor. Verify every remote action is same-host, non-force,
22
+ idempotently observable, and limited to the approved push and replies. Do not
23
+ execute remote actions here.
24
+
25
+ Call `structured_output` alone with:
26
+
27
+ - `ready` when all criteria pass and approved remote actions remain;
28
+ - `no-actions` when all criteria pass and no remote action is needed;
29
+ - `failed` for an actionable local defect, with exact evidence and the smallest
30
+ corrective handoff;
31
+ - `blocked` for stale head, checkout, anchor, scope, authority, or verification
32
+ that cannot proceed safely.
33
+
34
+ For `ready` and `failed`, include complete fresh evidence and the unchanged
35
+ Execution contract in `summary`.