@wichayutdew/pi-workflows 2.5.1 → 2.7.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 (103) hide show
  1. package/README.md +34 -1
  2. package/dist/index.js +1315 -2467
  3. package/examples/starter-kit/agents/planner.md +11 -0
  4. package/examples/starter-kit/agents/reviewer.md +10 -0
  5. package/examples/starter-kit/agents/scout.md +10 -0
  6. package/examples/starter-kit/agents/worker.md +11 -0
  7. package/examples/starter-kit/agents/workspace-preparer.md +10 -0
  8. package/examples/starter-kit/investigate.workflow.yaml +84 -0
  9. package/examples/starter-kit/jira.workflow.yaml +75 -0
  10. package/examples/starter-kit/mr-comment.workflow.yaml +86 -93
  11. package/examples/starter-kit/mr-review.workflow.yaml +52 -88
  12. package/examples/starter-kit/settings.yaml +4 -0
  13. package/examples/starter-kit/steps/investigate/investigate.md +40 -0
  14. package/examples/starter-kit/steps/investigate/retrieve.md +28 -0
  15. package/examples/starter-kit/steps/investigate/validate.md +20 -0
  16. package/examples/starter-kit/steps/jira/create.md +25 -0
  17. package/examples/starter-kit/steps/jira/draft.md +18 -0
  18. package/examples/starter-kit/steps/jira/plan.md +30 -0
  19. package/examples/starter-kit/steps/mr-comment/checkout-source.md +14 -0
  20. package/examples/starter-kit/steps/mr-comment/fetch.md +11 -28
  21. package/examples/starter-kit/steps/mr-comment/implement.md +9 -26
  22. package/examples/starter-kit/steps/mr-comment/plan.md +46 -55
  23. package/examples/starter-kit/steps/mr-comment/publish.md +11 -31
  24. package/examples/starter-kit/steps/mr-comment/verify.md +7 -34
  25. package/examples/starter-kit/steps/mr-review/fetch.md +13 -21
  26. package/examples/starter-kit/steps/mr-review/publish-approved.md +18 -0
  27. package/examples/starter-kit/steps/mr-review/review-for-approval.md +53 -0
  28. package/examples/starter-kit/steps/mr-review/verify-published.md +16 -0
  29. package/examples/starter-kit/steps/shared/prepare-workspace.md +11 -89
  30. package/examples/starter-kit/steps/shared/publish-remote.md +16 -0
  31. package/examples/starter-kit/steps/ticket/implement.md +10 -23
  32. package/examples/starter-kit/steps/ticket/plan.md +49 -98
  33. package/examples/starter-kit/steps/ticket/verify.md +14 -65
  34. package/examples/starter-kit/steps/work/implement.md +11 -22
  35. package/examples/starter-kit/steps/work/plan.md +43 -59
  36. package/examples/starter-kit/steps/work/verify.md +14 -25
  37. package/examples/starter-kit/ticket.workflow.yaml +57 -61
  38. package/examples/starter-kit/work.workflow.yaml +49 -57
  39. package/package.json +9 -19
  40. package/schemas/workflow.schema.json +63 -15
  41. package/scripts/patch-herdr-agent-state.mjs +36 -0
  42. package/src/agents/profile.ts +98 -0
  43. package/src/config/ceiling.ts +0 -82
  44. package/src/config/types.ts +15 -53
  45. package/src/config/validation/settings.ts +2 -14
  46. package/src/config/validation/step.ts +129 -8
  47. package/src/config/validation/workflow.ts +1 -10
  48. package/src/engine/run-workflow-validation.ts +0 -3
  49. package/src/engine/state-types.ts +1 -1
  50. package/src/harness/action-context.ts +1 -13
  51. package/src/harness/artifact-contract.ts +46 -0
  52. package/src/harness/delegation-control-actions.ts +4 -63
  53. package/src/harness/delegation-plan.ts +26 -80
  54. package/src/harness/delegation-response-actions.ts +22 -135
  55. package/src/harness/dependencies.ts +1 -12
  56. package/src/harness/gate-submission-action.ts +28 -0
  57. package/src/harness/status-actions.ts +20 -0
  58. package/src/harness/step-execution-actions.ts +2 -9
  59. package/src/harness/types.ts +2 -40
  60. package/src/harness.ts +2 -17
  61. package/src/herdr-workflow-state.ts +65 -0
  62. package/src/index.ts +4 -9
  63. package/src/integrations/subagents/child-policy-validation.ts +6 -7
  64. package/src/integrations/subagents/child-runtime-dependencies.ts +1 -1
  65. package/src/integrations/subagents/child-runtime-policy.ts +1 -7
  66. package/src/integrations/subagents/child-runtime.ts +18 -9
  67. package/src/integrations/subagents/client.ts +240 -98
  68. package/src/integrations/subagents/protocol-events.ts +32 -15
  69. package/src/integrations/subagents/protocol.ts +1 -1
  70. package/src/preflight.ts +0 -8
  71. package/src/prompt/main-workflow-notice.ts +8 -15
  72. package/src/prompt/step-task.ts +7 -6
  73. package/src/workflow-status/format-status.ts +5 -1
  74. package/src/workflow-status/render-step-detail.ts +94 -0
  75. package/src/workflow-status/types.ts +1 -0
  76. package/src/workflow-status/view.ts +49 -14
  77. package/agents/step.md +0 -32
  78. package/examples/mr-comments.workflow.yaml +0 -125
  79. package/examples/prompts/mr-comments/implement.md +0 -17
  80. package/examples/prompts/mr-comments/inspect.md +0 -5
  81. package/examples/prompts/mr-comments/plan.md +0 -54
  82. package/examples/prompts/mr-comments/verify.md +0 -9
  83. package/examples/settings.yaml +0 -27
  84. package/examples/starter-kit/steps/mr-review/publish.md +0 -48
  85. package/examples/starter-kit/steps/mr-review/review.md +0 -76
  86. package/examples/starter-kit/steps/mr-review/verify.md +0 -35
  87. package/src/config/validation/subagent.ts +0 -288
  88. package/src/harness/delegation-failure.ts +0 -248
  89. package/src/harness/delegation-recovery-validation.ts +0 -161
  90. package/src/harness/delegation-retry-policy.ts +0 -120
  91. package/src/integrations/subagents/client-delegation.ts +0 -181
  92. package/src/integrations/subagents/client-messages.ts +0 -66
  93. package/src/integrations/subagents/client-types.ts +0 -36
  94. package/src/integrations/subagents/diagnostic-format.ts +0 -45
  95. package/src/integrations/subagents/diagnostic-text.ts +0 -114
  96. package/src/integrations/subagents/diagnostic-types.ts +0 -83
  97. package/src/integrations/subagents/diagnostics.ts +0 -26
  98. package/src/integrations/subagents/failure-correlation.ts +0 -285
  99. package/src/integrations/subagents/failure-transcript.ts +0 -252
  100. package/src/integrations/subagents/hidden-bash-failure.ts +0 -98
  101. package/src/integrations/subagents/replay-audit.ts +0 -146
  102. package/src/integrations/subagents/replay-safety.ts +0 -67
  103. package/src/integrations/subagents/session-diagnostics.ts +0 -357
@@ -0,0 +1,28 @@
1
+ You are the scope-retrieval stage for `/investigate`. Stay read-only in this delegated child; do not launch subagents.
2
+
3
+ Workflow input:
4
+ {{workflow.input}}
5
+
6
+ Previously rejected scope:
7
+ {{gate.artifact}}
8
+
9
+ Plannotator feedback:
10
+ {{gate.feedback}}
11
+
12
+ ## Scope Artifact Structure
13
+
14
+ 1. `# <Investigation title>`
15
+ 2. `## Brief description`
16
+ 3. `## Goals` (numbered list)
17
+ 4. `## Boundaries` (in-scope systems & explicit exclusions)
18
+ 5. `## Evidence & sources` (Jira, local files, documents, search tools)
19
+ 6. `## Report destination` (`./investigation-findings/<slug>.md`)
20
+ 7. `## Open evidence gaps`
21
+
22
+ ## Artifact limit
23
+ Keep the submitted artifact concise and at most 6,000 characters. Do not replace required content with a filesystem path or external reference.
24
+
25
+ ## Outcomes
26
+ - `submit`: Scope ready for Plannotator gate review.
27
+ - `retry`: Transient read-only API failure.
28
+ - `blocked`: Empty input or inaccessible required Jira data.
@@ -0,0 +1,20 @@
1
+ You are the independent validation stage for an investigation report. Stay read-only; do not edit the report or launch subagents.
2
+
3
+ Original request:
4
+ {{workflow.input}}
5
+
6
+ Approved scope artifact:
7
+ {{reviewed.artifact}}
8
+
9
+ Investigation ledger:
10
+ {{last.summary}}
11
+
12
+ ## Validation Rules & Review Criteria
13
+
14
+ 1. **Independent Verification**: Do not trust the prior claim ledger; verify citations, line numbers, and sources directly with read-only tools.
15
+ 2. **Reader-Clarity Review**: Ensure prose is concise, scannable, and free of filler. Recommend Mermaid diagrams only where complex flows or relationships warrant visual representation.
16
+ 3. **Outcomes**:
17
+ - `approved`: All material claims verified and clear.
18
+ - `gaps`: Actionable evidence gaps, contradictions, or clarity issues (returns to `investigate`).
19
+ - `retry`: Recoverable read-only tool failure.
20
+ - `blocked`: Irreconcilable evidence or missing sources after exhaustive attempts.
@@ -0,0 +1,25 @@
1
+ You are the Jira creation stage for an approved `/jira` plan. Do not launch subagents, write local files, or mutate unapproved Jira records.
2
+
3
+ Original input:
4
+ {{workflow.input}}
5
+
6
+ Approved Jira plan:
7
+ {{reviewed.artifact}}
8
+
9
+ Approval feedback:
10
+ {{reviewed.feedback}}
11
+
12
+ Previous creation ledger:
13
+ {{last.summary}}
14
+
15
+ ## Guardrails & Output Contract
16
+
17
+ 1. **Idempotence**: Check the creation ledger before every write; skip any issue or link already created and confirmed.
18
+ 2. **Immediate Readback**: Always read back created issues to capture exact numeric IDs, keys, and URLs.
19
+ 3. **Safety**: Never delete issues, guess custom fields, or retry ambiguous mutations. On any partial failure or timeout, return `blocked` with the confirmed ledger.
20
+ 4. **Required Output Format**:
21
+ - `# Epic ID: <numeric ID>`
22
+ - `# Epic key: <key>`
23
+ - `# Epic URL: <URL>`
24
+ - `## Stories` (numbered list with IDs, keys, URLs, Epic membership, and link proofs)
25
+ - `## Creation ledger` (full preflight mapping and execution trace)
@@ -0,0 +1,18 @@
1
+ You are the input-normalization stage for `/jira`. Stay read-only; do not call Atlassian tools or write files.
2
+
3
+ Workflow input:
4
+ {{workflow.input}}
5
+
6
+ ## Draft Artifact Structure
7
+
8
+ 1. `# Jira draft`
9
+ 2. `## Source` (`Markdown path: <path>` or `Quick summary`)
10
+ 3. `## Project key` (explicit key or `Missing`)
11
+ 4. `## Epic draft` (Name, goal, expected value, touched services)
12
+ 5. `## Ordered Story draft` (numbered list with stable draft IDs, service, frontend/backend scope, implementation bullets, risks, dependencies)
13
+ 6. `## Unknowns` (missing details needed before creation)
14
+
15
+ ## Outcomes
16
+ - `ready`: Draft parsed and ready for planning.
17
+ - `retry`: Transient file read failure.
18
+ - `blocked`: Unreadable file path or empty input.
@@ -0,0 +1,30 @@
1
+ You are the Jira planning and approval stage for `/jira`. Stay read-only; do not create issues or launch subagents.
2
+
3
+ Original input:
4
+ {{workflow.input}}
5
+
6
+ Normalized draft:
7
+ {{last.summary}}
8
+
9
+ Previously rejected plan:
10
+ {{gate.artifact}}
11
+
12
+ Plannotator feedback:
13
+ {{gate.feedback}}
14
+
15
+ ## Plan Artifact Structure
16
+
17
+ 1. `# Create Jira Epic and Stories`
18
+ 2. `## Jira field contract` — verified field IDs, link types, payload shapes, and representative keys.
19
+ 3. `## Epic` — Name, quick summary, goal, **Feature diagram (Mermaid)**, expected value, timeline, touched services, references.
20
+ 4. `## Ordered Stories` — Numbered stories with `<service> — <Frontend|Backend> — <outcome>`, background, implementation bullets, risks, acceptance criteria, Epic membership, dependencies.
21
+ 5. `## Creation sequence` — Epic first, followed by stories in dependency order.
22
+ 6. `## Safety limits` — Exact mapped fields only; no guessed IDs or unapproved objects.
23
+
24
+ ## Artifact limit
25
+ Keep the submitted artifact concise and at most 16,000 characters. Do not replace required content with a filesystem path or external reference.
26
+
27
+ ## Outcomes
28
+ - `submit`: Plan ready for Plannotator review.
29
+ - `retry`: Transient read-only Atlassian API failure.
30
+ - `blocked`: Inaccessible project, unverified field mappings, or missing project key.
@@ -0,0 +1,14 @@
1
+ You prepare the local checkout for resolving hosted MR comments. Do not delete worktrees, reset HEAD, or launch subagents.
2
+
3
+ Review input:
4
+ {{workflow.input}}
5
+
6
+ Fetched review evidence:
7
+ {{last.summary}}
8
+
9
+ ## Guardrails
10
+ - **Preservation**: Never stash, reset, clean, or delete files.
11
+ - **Outcomes**:
12
+ - `ready`: Source branch checked out/bound safely. Include `workspace: {cwd: "<path>"}`.
13
+ - `retry`: Transient fetch error.
14
+ - `blocked`: Dirty unrelated checkout, divergent branch history, or missing remote.
@@ -1,33 +1,16 @@
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.
1
+ You are the read-only evidence-fetch stage for `/mr-comment`. Do not modify local/remote state or launch subagents.
4
2
 
5
3
  Review input:
6
4
  {{workflow.input}}
7
5
 
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.
6
+ ## Evidence Packet Structure
7
+ - Canonical URL, host, project/repo, review number.
8
+ - Source/target branches and remote SHAs.
9
+ - Matching local remote name and local Git status.
10
+ - Changed file list and diff context.
11
+ - Unresolved discussion comments with IDs, authors, anchors (path/line), and text.
12
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.
13
+ ## Outcomes
14
+ - `ready`: Evidence gathered successfully.
15
+ - `retry`: Transient network/read failure.
16
+ - `blocked`: Authentication failure, invalid URL, or missing permissions.
@@ -1,5 +1,4 @@
1
- You implement the approved hosted-review comment fixes on top of the current
2
- checkout.
1
+ You are the implementation stage for the approved review-comment plan. Stay in this delegated child; do not launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
@@ -10,29 +9,13 @@ Approved plan:
10
9
  Approval feedback:
11
10
  {{reviewed.feedback}}
12
11
 
13
- Previous attempt handoff:
12
+ Previous ledger:
14
13
  {{last.summary}}
15
14
 
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.
15
+ ## Rules & Invariants
16
+ - Execute only approved `workerCommands`.
17
+ - For reply-only plans (no code changes needed), verify code without creating commits.
18
+ - Outcomes:
19
+ - `ready`: Implementation complete and committed. Pass full JSON contract to reviewer.
20
+ - `retry`: Transient tool failure.
21
+ - `blocked`: Unapproved command required or unrecoverable error.
@@ -1,4 +1,4 @@
1
- You are the planning child for unresolved hosted-review comments.
1
+ You are the planning stage for resolving hosted MR comments. Stay read-only on the bound checkout; do not launch subagents.
2
2
 
3
3
  Review input:
4
4
  {{workflow.input}}
@@ -9,62 +9,53 @@ Fetched evidence:
9
9
  Previously rejected artifact:
10
10
  {{gate.artifact}}
11
11
 
12
- Feedback from a previously rejected review:
12
+ Plannotator feedback:
13
13
  {{gate.feedback}}
14
14
 
15
- When feedback is non-empty, revise the rejected artifact against current
16
- evidence and submit the complete proposal for another review. Each rejection
17
- returns to this same planning step on the existing checkout.
15
+ ## Plan Artifact Structure
18
16
 
19
- Re-verify the same review and the current Git root, registered worktree,
20
- branch, HEAD, and status. Work on top of this checkout exactly as it exists.
21
- Never create, switch, reset, clean, delete, or prepare another branch or
22
- worktree. Use matching read-only MCP/CLI/cURL calls and repository inspection
23
- to close evidence gaps.
24
-
25
- Classify every unresolved comment as valid, partly valid, invalid, or already
26
- addressed, with causal evidence. Define scoped code changes, exact
27
- repository-native checks, an optional commit, and the public reply for each
28
- comment. Include the matching non-force push whenever a committed code fix must
29
- reach the host, and one same-host reply action for every comment that requires
30
- a response. Never include approval, merge, resolution, closure, deletion,
31
- force-push, cross-host mutation, or unrelated work.
32
-
33
- This user-owned prompt defines the Plannotator artifact:
34
-
35
- 1. `# <outcome-oriented title>`
17
+ 1. `# <Outcome-oriented title>`
36
18
  2. `## Review summary`
37
- 3. `## Comment decisions`
38
- 4. `## Implementation plan`
39
- 5. `## Acceptance criteria and validation`
40
- 6. `## Replies and remote actions`
19
+ 3. `## Comment decisions` (per-comment classification and evidence)
20
+ 4. `## Implementation plan` (scoped files, observable changes)
21
+ 5. `## Validation` (tests, lint, format)
22
+ 6. `## Replies and remote actions` (exact reply text per comment)
41
23
  7. `## Risks`
42
- 8. `## Execution contract`
43
-
44
- The Execution contract is one fenced `json` object containing:
45
-
46
- - `repository`: exact current root, worktree, branch, starting HEAD, hosted
47
- head, scoped files, optional commit title, and acceptance criteria;
48
- - `workerCommands` and `reviewerCommands`: exact repository-native commands
49
- derived from current scripts and documentation;
50
- - `remoteActions`: ordered non-force push and same-host reply actions, each
51
- with an exact configured MCP tool/input or standalone `git`, `glab`, `gh`, or
52
- cURL command, stable review/comment identity, precondition, effect, and
53
- unique marker.
54
-
55
- Command shape is domain data owned by this prompt. Verify executable,
56
- subcommand, argument ordering, and cwd behavior from repository context or
57
- current tool help. Do not assume a language, framework, package manager, or
58
- flag order. All Git actions run from `repository.cwd`: emit `git <subcommand>`
59
- with the approved subcommand first and never add a dynamic `git -C` prefix,
60
- because the publisher's YAML allow-list authorizes concrete subcommands. For
61
- machine-readable GitLab state, prefer `glab api` and do not assume the installed
62
- `glab mr view` supports `--json`. Use no unresolved placeholders, credentials,
63
- shell composition, or wrapper shells.
64
-
65
- Call `structured_output` alone with outcome `submit` only when the complete
66
- plan can be implemented and published without another planning decision. Put
67
- the Markdown plan in `artifact` and a self-contained handoff, including the
68
- unchanged JSON contract, in `summary`. Use `blocked` when identity, scope,
69
- authority, anchors, or evidence cannot be made safe. A rejected proposal is
70
- revised here; never restart the workflow or create a new workspace.
24
+ 8. `## Execution appendix (machine-readable)` (fenced JSON with `repository`, `workerCommands`, `reviewerCommands`, `remoteActions`)
25
+
26
+ ```json
27
+ {
28
+ "repository": {
29
+ "cwd": "<bound-path>",
30
+ "branch": "<source-branch>",
31
+ "commitTitle": "fix(scope): address review comments",
32
+ "scopedFiles": ["src/a.ts"]
33
+ },
34
+ "workerCommands": [
35
+ {"id": "test-red", "command": "..."},
36
+ {"id": "test-green", "command": "..."}
37
+ ],
38
+ "reviewerCommands": [
39
+ {"id": "full-tests", "command": "..."},
40
+ {"id": "lint", "command": "..."}
41
+ ],
42
+ "remoteActions": [
43
+ {
44
+ "toolName": "bash",
45
+ "input": {"command": "git push origin HEAD:<source-branch>"}
46
+ },
47
+ {
48
+ "toolName": "bash",
49
+ "input": {"command": "glab api projects/<id>/merge_requests/<iid>/discussions/<disc_id>/notes -f body='...'"}
50
+ }
51
+ ]
52
+ }
53
+ ```
54
+
55
+ ## Artifact limit
56
+ Keep the submitted artifact concise and at most 10,000 characters. Do not replace required content with a filesystem path or external reference.
57
+
58
+ ## Outcomes
59
+ - `submit`: Complete plan ready for Plannotator gate.
60
+ - `retry`: Transient API failure.
61
+ - `blocked`: Unsafe anchors, ambiguous comment context, or missing permissions.
@@ -1,37 +1,17 @@
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.
1
+ You are the publication stage for an approved review-comment plan. Do not broaden scope or launch subagents.
4
2
 
5
3
  Review input:
6
4
  {{workflow.input}}
7
5
 
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.
6
+ Approved plan:
7
+ {{reviewed.artifact}}
17
8
 
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. Automatically perform every required approved push and reply; never
24
- ask the user to perform one.
25
-
26
- Require a successful same-host, target-correlated response. Never change reply
27
- meaning, target another comment, expose credentials, force-push, approve,
28
- merge, resolve, close, delete, or perform an unlisted mutation. After any
29
- mutation-capable call is attempted, ambiguity is `blocked`; never blindly
30
- replay it.
9
+ Verification ledger:
10
+ {{last.summary}}
31
11
 
32
- Call `structured_output` alone with outcome `published` only after every
33
- approved push/reply succeeds now or is proven already complete. Record each
34
- pre-state, attempted/skipped action, exact result, remote identifier/URL, final
35
- remote head, and remaining work in `summary`. Use `no-actions` only when the
36
- approved list is empty and current evidence confirms nothing is required. Use
37
- `blocked` with the full ledger on stale or ambiguous state.
12
+ ## Guardrails
13
+ - Run only approved `remoteActions` (`git push`, `glab api`, `gh api`).
14
+ - Never force-push, resolve threads, approve, or merge MRs.
15
+ - Outcomes:
16
+ - `published`: All remote actions executed and confirmed.
17
+ - `blocked`: Remote failure or ambiguous state.
@@ -1,5 +1,4 @@
1
- You independently verify the approved review-comment implementation. Do not
2
- edit files, change branches or worktrees, or mutate remote state.
1
+ You are the independent verification stage for the approved review-comment fixes. Stay read-only for code; do not modify files or launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
@@ -7,37 +6,11 @@ Review input:
7
6
  Approved plan:
8
7
  {{reviewed.artifact}}
9
8
 
10
- Implementation handoff:
9
+ Implementation ledger:
11
10
  {{last.summary}}
12
11
 
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
- Any regression, lint failure, formatting failure, or other actionable local
26
- finding is `failed`; the workflow sends that outcome directly back to
27
- implementation. Do not use `blocked` for a fixable local finding. When a code
28
- fix was committed, require the matching approved non-force push action before
29
- the replies. A valid unresolved review comment requires its approved public
30
- reply action.
31
-
32
- Call `structured_output` alone with:
33
-
34
- - `ready` when all criteria pass and approved remote actions remain;
35
- - `no-actions` when all criteria pass and no remote action is needed;
36
- - `failed` for an actionable local defect, with exact evidence and the smallest
37
- corrective handoff;
38
- - `blocked` for stale head, checkout, anchor, scope, authority, or verification
39
- that cannot proceed safely.
40
-
41
- For `ready` and `failed`, include complete fresh evidence and the unchanged
42
- Execution contract in `summary`. A `ready` handoff automatically proceeds to
43
- the publisher; do not ask the user to push or post a reply.
12
+ ## Outcomes
13
+ - `passed`: All acceptance criteria, tests, and linters pass. Hands off approved `remoteActions` to publication stage.
14
+ - `failed`: Local test failure or regression (returns to `implement`).
15
+ - `retry`: Recoverable read-only environment failure.
16
+ - `blocked`: Corrupted workspace or missing authority.
@@ -1,25 +1,17 @@
1
- You are the initial evidence-acquisition child for one GitLab merge request or
2
- GitHub pull request. Do not review the code yet and do not mutate local or
3
- remote state.
1
+ You are the read-only evidence-fetch stage for `/mr-review`. Do not mutate state or launch subagents.
4
2
 
5
- Review input:
3
+ Hosted review URL & context:
6
4
  {{workflow.input}}
7
5
 
8
- Resolve exactly one canonical HTTPS review URL and keep all calls on that host.
9
- Fetch through the matching configured MCP server first. If a required read is
10
- unavailable there, use the matching host CLI (`glab` or `gh`), then
11
- authenticated read-only cURL. Never print or store credentials.
6
+ ## Evidence Bundle Structure
7
+ 1. `# Hosted review evidence`
8
+ 2. `## Identity and immutable coordinates` (URL, host, project, MR/PR number, source/target branch, head SHA)
9
+ 3. `## Description and commits`
10
+ 4. `## Change manifest and diff evidence`
11
+ 5. `## Pipelines or checks`
12
+ 6. `## Existing review state`
13
+ 7. `## Repository context`
12
14
 
13
- Collect the title, description, author, source and target branches, base/start/
14
- head SHAs, commits, complete changed-file list and diff, pipelines/checks,
15
- conflicts, and existing discussions or comments. Follow pagination until the
16
- evidence is complete. Inspect the local repository only when it corresponds to
17
- the same review; record repository instructions and relevant current code
18
- without editing it.
19
-
20
- Call `structured_output` alone with outcome `fetched` and a self-contained
21
- evidence packet in `summary`: canonical URL and host, project/repository and
22
- review number, branches and SHAs, changed files, decisive diff context,
23
- pipeline/check result, conflict state, discussions, pagination evidence, local
24
- context used, and acquisition mechanisms. Use `blocked` when identity,
25
- authentication, pagination, or material evidence cannot be established safely.
15
+ ## Outcomes
16
+ - `fetched`: Evidence gathering complete.
17
+ - `blocked`: Inaccessible review, invalid URL, or missing permissions.
@@ -0,0 +1,18 @@
1
+ You are the publication stage for an approved hosted code review. Do not rewrite approved content or launch subagents.
2
+
3
+ Original input:
4
+ {{workflow.input}}
5
+
6
+ Approved review artifact:
7
+ {{reviewed.artifact}}
8
+
9
+ Approval feedback:
10
+ {{reviewed.feedback}}
11
+
12
+ Previous step handoff:
13
+ {{last.summary}}
14
+
15
+ ## Guardrails
16
+ - Execute only literal commands approved in `actions`.
17
+ - Never force-push, approve, merge, resolve, or close reviews.
18
+ - Outcome `published` requires all actions either executed or verified already existing. Outcome `blocked` on ambiguity or error.
@@ -0,0 +1,53 @@
1
+ You are the independent reviewer for a hosted MR/PR. This is the sole review artifact submitted to Plannotator. Do not mutate state or launch subagents.
2
+
3
+ Original input:
4
+ {{workflow.input}}
5
+
6
+ Fetched evidence bundle:
7
+ {{last.summary}}
8
+
9
+ Previously rejected artifact:
10
+ {{gate.artifact}}
11
+
12
+ Plannotator feedback:
13
+ {{gate.feedback}}
14
+
15
+ ## Review Artifact Structure
16
+
17
+ 1. `# Review: <Short verdict>`
18
+ 2. `## Verdict` — URL, host, current head SHA, concise outcome.
19
+ 3. `## Findings` — Ordered by severity: path, line, problem, impact, evidence, fix. (Or `No actionable findings.`).
20
+ 4. `## Validation` — Refreshed diff, checks, and false-positive checks.
21
+ 5. `## Publication contract` — Fenced JSON with `actions` array.
22
+ 6. `## Safety boundaries` — Prohibited actions (no force push, no unapproved merges).
23
+
24
+ ```json
25
+ {
26
+ "actions": [
27
+ {
28
+ "toolName": "bash",
29
+ "input": {
30
+ "command": "glab api projects/<id>/merge_requests/<iid>/discussions ..."
31
+ },
32
+ "effect": {
33
+ "kind": "inline-comment",
34
+ "host": "gitlab.com",
35
+ "reviewUrl": "https://...",
36
+ "headSha": "<current-sha>",
37
+ "path": "src/file.ts",
38
+ "line": 42,
39
+ "body": "Exact feedback...",
40
+ "marker": "<unique-marker>"
41
+ }
42
+ }
43
+ ]
44
+ }
45
+ ```
46
+
47
+ ## Artifact limit
48
+ Keep the submitted artifact concise and at most 8,000 characters. Do not replace required content with a filesystem path or external reference.
49
+
50
+ ## Outcomes
51
+ - `submit`: Review artifact ready for Plannotator gate.
52
+ - `retry`: Transient read-only API failure.
53
+ - `blocked`: Stale review head or inaccessible discussion API.
@@ -0,0 +1,16 @@
1
+ You are the read-only verification stage for an approved hosted review. Do not mutate state or execute publication commands.
2
+
3
+ Original input:
4
+ {{workflow.input}}
5
+
6
+ Approved review artifact:
7
+ {{reviewed.artifact}}
8
+
9
+ Publication ledger:
10
+ {{last.summary}}
11
+
12
+ ## Reviewer Invariants & Outcomes
13
+ - `verified`: Every approved inline comment or summary note is observable on the host with its exact marker.
14
+ - `failed`: An actionable missing comment or mismatch is detected; returns to `publish-approved` stage for correction.
15
+ - `retry`: Recoverable read-only API failure.
16
+ - `blocked`: Stale review or corrupted state.