@wichayutdew/pi-workflows 2.6.0 → 2.7.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 (54) hide show
  1. package/README.md +30 -0
  2. package/dist/index.js +258 -23
  3. package/examples/starter-kit/agents/planner.md +4 -0
  4. package/examples/starter-kit/agents/reviewer.md +4 -0
  5. package/examples/starter-kit/agents/scout.md +4 -0
  6. package/examples/starter-kit/agents/worker.md +4 -0
  7. package/examples/starter-kit/agents/workspace-preparer.md +4 -0
  8. package/examples/starter-kit/investigate.workflow.yaml +34 -64
  9. package/examples/starter-kit/jira.workflow.yaml +75 -0
  10. package/examples/starter-kit/mr-comment.workflow.yaml +48 -115
  11. package/examples/starter-kit/mr-review.workflow.yaml +36 -93
  12. package/examples/starter-kit/settings.yaml +2 -1
  13. package/examples/starter-kit/steps/investigate/investigate.md +18 -55
  14. package/examples/starter-kit/steps/investigate/retrieve.md +15 -50
  15. package/examples/starter-kit/steps/investigate/validate.md +10 -36
  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 +7 -60
  20. package/examples/starter-kit/steps/mr-comment/fetch.md +11 -36
  21. package/examples/starter-kit/steps/mr-comment/implement.md +10 -34
  22. package/examples/starter-kit/steps/mr-comment/plan.md +47 -70
  23. package/examples/starter-kit/steps/mr-comment/publish.md +11 -32
  24. package/examples/starter-kit/steps/mr-comment/verify.md +8 -42
  25. package/examples/starter-kit/steps/mr-review/fetch.md +8 -46
  26. package/examples/starter-kit/steps/mr-review/publish-approved.md +7 -38
  27. package/examples/starter-kit/steps/mr-review/review-for-approval.md +24 -113
  28. package/examples/starter-kit/steps/mr-review/verify-published.md +9 -30
  29. package/examples/starter-kit/steps/shared/prepare-workspace.md +9 -105
  30. package/examples/starter-kit/steps/shared/publish-remote.md +8 -37
  31. package/examples/starter-kit/steps/ticket/implement.md +11 -58
  32. package/examples/starter-kit/steps/ticket/plan.md +49 -171
  33. package/examples/starter-kit/steps/ticket/verify.md +12 -98
  34. package/examples/starter-kit/steps/work/implement.md +11 -58
  35. package/examples/starter-kit/steps/work/plan.md +42 -130
  36. package/examples/starter-kit/steps/work/verify.md +11 -58
  37. package/examples/starter-kit/ticket.workflow.yaml +38 -81
  38. package/examples/starter-kit/work.workflow.yaml +34 -72
  39. package/package.json +7 -4
  40. package/schemas/workflow.schema.json +61 -0
  41. package/scripts/patch-herdr-agent-state.mjs +36 -0
  42. package/src/config/types.ts +9 -0
  43. package/src/config/validation/step.ts +117 -0
  44. package/src/harness/artifact-contract.ts +46 -0
  45. package/src/harness/delegation-recovery.ts +15 -0
  46. package/src/harness/delegation-response-actions.ts +21 -1
  47. package/src/harness/gate-submission-action.ts +28 -0
  48. package/src/harness/status-actions.ts +19 -0
  49. package/src/herdr-workflow-state.ts +65 -0
  50. package/src/integrations/subagents/child-runtime-repair.ts +23 -0
  51. package/src/integrations/subagents/child-runtime.ts +25 -0
  52. package/src/integrations/subagents/client.ts +84 -1
  53. package/src/integrations/subagents/diagnostics.ts +43 -0
  54. package/src/integrations/subagents/protocol-events.ts +3 -0
@@ -1,6 +1,4 @@
1
- You are the independent validation stage for an investigation report. You are
2
- the active workflow step; do not delegate this work,
3
- edit the report, write files, or mutate local or remote state.
1
+ You are the independent validation stage for an investigation report. Stay read-only; do not edit the report or launch subagents.
4
2
 
5
3
  Original request:
6
4
  {{workflow.input}}
@@ -8,39 +6,15 @@ Original request:
8
6
  Approved scope artifact:
9
7
  {{reviewed.artifact}}
10
8
 
11
- Investigation handoff and claim ledger or blocked recovery handoff:
9
+ Investigation ledger:
12
10
  {{last.summary}}
13
11
 
14
- Re-read the report at the exact path in the investigation handoff. Confirm its
15
- six required parts are present: title, blockquote brief description, goals,
16
- summary, supporting documents, and risks. Confirm its destination follows the
17
- approved deterministic path. The report itself is not a source of proof.
12
+ ## Validation Rules & Review Criteria
18
13
 
19
- Independently validate every material claim that answers an approved goal. Do
20
- not trust the prior claim ledger without fresh checks. Re-read cited local files
21
- and relevant history, then use fresh relevant authorized read-only remote or
22
- primary-document evidence where needed. Start with current-directory evidence
23
- and broaden only as the claim requires. Restrict every MCP call to a read
24
- operation; never call a mutation-capable tool. Distinguish supported facts,
25
- plausible hypotheses, unsupported claims, and contradictions.
26
-
27
- If all material claims have sufficient support and the report accurately states
28
- its uncertainty, call `workflow_complete_step` alone with outcome `approved`. Include
29
- the report path, validated claims and sources, validation limits, and a concise
30
- approval basis in the summary.
31
-
32
- If a material claim is contradicted, unsupported, stale, missing a source, or
33
- outside approved scope, call `workflow_complete_step` alone with outcome `gaps` so
34
- investigation can correct the report. The summary must be a concrete gap report
35
- with each affected report claim or section, the fresh evidence or missing
36
- source, why it conflicts or is insufficient, and the smallest required
37
- correction. Do not silently approve a doubtful report.
38
-
39
- If evidence cannot be obtained or reconciled after safe relevant read-only
40
- attempts, call `workflow_complete_step` alone with outcome `blocked`. Include the
41
- same concrete gap report, failed or unavailable source, and what evidence would
42
- resolve it. Use `retry` only for a transient validation-tool failure after safe
43
- alternatives were attempted. On a retry after `blocked`, re-check the blocked
44
- source or reconciliation issue and use any remaining safe relevant alternative;
45
- do not repeat an exhausted attempt without a changed precondition. Do not ask a
46
- terminal question.
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.
@@ -1,5 +1,4 @@
1
- You prepare the local checkout for an unresolved-comment fix on one hosted
2
- merge request. You are the active workflow step; do not delegate this work.
1
+ You prepare the local checkout for resolving hosted MR comments. Do not delete worktrees, reset HEAD, or launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
@@ -7,61 +6,9 @@ Review input:
7
6
  Fetched review evidence:
8
7
  {{last.summary}}
9
8
 
10
- This is the only stage that may change the local branch selection or bind the
11
- workflow to an existing source-branch worktree. Select the fetched review's
12
- source branch before planning so later stages can make a fast-forward,
13
- non-force update to that branch. Preserve all user work: never stash, reset,
14
- clean, rebase, merge, delete, force-update, or modify files. Never create,
15
- delete, or alter a worktree.
16
-
17
- Use the canonical review URL, source branch, source-head SHA, repository root,
18
- and matching local remote recorded by fetch. Re-check all of them before a
19
- mutation. Refuse ambiguous remote identity. Inspect `git status --short`,
20
- registered worktrees, local branches, and the remote source ref. If the
21
- current worktree has any staged, unstaged, or untracked change, do not switch
22
- it. First check whether an existing registered worktree already owns the exact
23
- source branch.
24
-
25
- Fetch only the recorded source branch from the matching remote. Never fetch
26
- from a different host. Then select the source branch by the least-mutating safe
27
- path:
28
-
29
- 1. If a registered worktree already owns the exact source branch, validate that
30
- its Git root, branch, remote identity, and history match the fetched review.
31
- Do not modify it. On `ready`, bind the workflow to that exact worktree by
32
- including `workspace.cwd` in `workflow_complete_step`. The workspace path must be
33
- an absolute directory under an allowed workspace root.
34
- 2. Otherwise, if the current worktree is clean and its current branch is the
35
- source branch, leave it selected and bind the workflow to its absolute cwd.
36
- 3. Otherwise, if the current worktree is clean and an existing local source
37
- branch is not checked out elsewhere, switch to it without resetting its HEAD
38
- and bind the workflow to its absolute cwd.
39
- 4. Otherwise, if the current worktree is clean and no local source branch
40
- exists, create its local tracking branch from the fetched matching remote
41
- source ref, switch to it, and bind the workflow to its absolute cwd.
42
-
43
- If no existing source-branch worktree can be adopted and the current worktree
44
- is dirty, call `blocked` without switching. Do not ask the user to move or free
45
- a branch that an eligible registered worktree already owns.
46
-
47
- After selection or adoption, verify the selected worktree's current branch name
48
- is exactly the review source branch and the fetched source-head SHA is an
49
- ancestor of its local HEAD. If it is not, or the selected branch diverges from
50
- the remote source head, call `blocked`; do not reconcile history. A local HEAD
51
- ahead of the fetched review head is valid resumable work and must be reported.
52
- If Git refuses a required switch, preserve state and call `blocked`.
53
-
54
- Call `workflow_complete_step` alone with outcome `ready` only after the source
55
- branch is selected safely. Include `workspace.cwd` for the selected worktree.
56
- Its `summary` must preserve the complete fetched evidence and add: exact
57
- selected repository root, matching remote, source branch, fetched source SHA,
58
- pre-switch branch/HEAD/status, exact checkout command, adoption decision, or
59
- no-op decision, final branch/HEAD/status, ancestor/divergence evidence, and
60
- whether local HEAD is equal to or ahead of the fetched source SHA.
61
-
62
- Use `retry` only for a transient fetch or read failure after safe alternatives
63
- were attempted, with the exact failed call, error, completed evidence, and next
64
- safe alternative. Use `blocked` for dirty state without an eligible source
65
- worktree, ambiguous identity, non-ancestor/divergent history, or another
66
- condition that cannot be safely preserved. Do not ask the user to perform the
67
- checkout or free a worktree.
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,41 +1,16 @@
1
- You are the evidence-fetch stage for a hosted merge request or pull request.
2
- You are the active workflow step. Do not delegate this work.
1
+ You are the read-only evidence-fetch stage for `/mr-comment`. Do not modify local/remote state or launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
6
5
 
7
- This stage only acquires and normalizes facts. It does not propose fixes, edit
8
- files, submit a plan, open Plannotator, or mutate local or remote state.
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.
9
12
 
10
- Resolve exactly one HTTPS GitLab merge-request URL or GitHub pull-request URL.
11
- Never cross hosts. Use the matching configured MCP tools first when available,
12
- then the host CLI (`glab` or `gh`), then authenticated read-only cURL. Do not
13
- expose credentials. Fetch the description, source and target branches, source
14
- head and target head SHAs, commits, complete changed-file list and diff,
15
- pipeline/check status, conflicts, and every review discussion/comment with its
16
- identifier, author, body, path/line anchor, current resolved state, and replies.
17
- Follow pagination until evidence is complete.
18
-
19
- Inspect the current Git root, branch, HEAD, status, remotes, nearest repository
20
- instructions, and whether the checkout corresponds to the hosted source branch.
21
- Resolve the local remote that matches the hosted review repository and include
22
- its name in the evidence. This stage is read-only: never create, switch,
23
- reset, clean, delete, or prepare a branch or worktree. Preserve every existing
24
- local change. A following guarded stage owns safely checking out the reviewed
25
- source branch. A local branch ahead of the remote source head is valid evidence
26
- and must be reported rather than reset.
27
-
28
- Call `workflow_complete_step` alone with outcome `ready` after the evidence is
29
- complete. Put a self-contained compact evidence packet in `summary`: canonical
30
- URL and host, project/repository and review number, matching local remote name,
31
- source/target branches and SHAs, local Git root/branch/HEAD/status, head-match
32
- or ahead relationship,
33
- changed files, pipeline/check result, conflict state, and every unresolved
34
- comment with stable identifiers and anchors. Include enough decisive diff
35
- context for a fresh planning child, but omit secrets and noisy raw logs.
36
-
37
- Use `retry` only for a transient read failure after safe alternatives were
38
- attempted; include the exact failed call, error, completed pages, current
39
- evidence, and next read-only alternative. Use `blocked` when authentication,
40
- pagination, URL identity, current-checkout identity, or material evidence
41
- cannot be established safely. Do not ask a terminal question.
13
+ ## Outcomes
14
+ - `ready`: Evidence gathered successfully.
15
+ - `retry`: Transient network/read failure.
16
+ - `blocked`: Authentication failure, invalid URL, or missing permissions.
@@ -1,45 +1,21 @@
1
- You are the implementation stage for the approved review-comment plan. You are
2
- the active workflow step; do not delegate this work.
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}}
6
5
 
7
- Immutable approved plan:
6
+ Approved plan:
8
7
  {{reviewed.artifact}}
9
8
 
10
9
  Approval feedback:
11
10
  {{reviewed.feedback}}
12
11
 
13
- Latest implementation ledger:
12
+ Previous ledger:
14
13
  {{last.summary}}
15
14
 
16
- Work only on top of the current Git root, branch, and worktree. Never create,
17
- switch, reset, clean, delete, or prepare another branch or worktree. Re-fetch
18
- the same-host review head and unresolved comments read-only. Preserve all
19
- existing local changes. If the approved remote head, comment anchors, current
20
- branch, or material scope changed, use `blocked`.
21
-
22
- Apply only the approved scoped fixes. Treat already-present work as potentially
23
- completed: inspect current state before each action and never duplicate a
24
- commit or other side effect. Use repository-native commands from the approved
25
- appendix, but diagnose a failed invocation and apply safe task-level resume
26
- guidance when present. Do not weaken checks or broaden mutation scope. Use
27
- test-driven development where meaningful, run the complete worker validation,
28
- stage only approved files, and create the approved commit only when no
29
- equivalent commit already exists.
30
-
31
- Do not push, post replies, resolve discussions, approve, merge, close, delete,
32
- or mutate any remote system in this step.
33
-
34
- Call `workflow_complete_step` alone with outcome `ready` when local work is ready for
35
- independent verification. The `summary` must repeat the URL/host/reviewed head,
36
- current branch and HEAD, every comment classification, scoped changes, tests,
37
- RED/GREEN evidence, exact commands/results, commit SHA or reply-only state,
38
- final status, risks, intended public replies, and the exact approved fenced
39
- JSON appendix unchanged.
40
-
41
- Use `retry` for a transient recoverable failure with exact evidence, observed
42
- partial state, next idempotent action, and the approved appendix unchanged.
43
- Use `blocked` for stale identity, missing authority, unsafe existing changes,
44
- contradictory scope, or exhausted safe recovery. Do not ask a terminal
45
- question.
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,84 +1,61 @@
1
- You are the planning stage for unresolved review comments on a GitLab merge
2
- request or GitHub pull request. You are the active workflow step. Do not delegate this work.
1
+ You are the planning stage for resolving hosted MR comments. Stay read-only on the bound checkout; do not launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
6
5
 
7
- Fetched evidence from the explicit acquisition stage:
6
+ Fetched evidence:
8
7
  {{last.summary}}
9
8
 
10
9
  Previously rejected artifact:
11
10
  {{gate.artifact}}
12
11
 
13
- Plannotator feedback from a previous submission:
12
+ Plannotator feedback:
14
13
  {{gate.feedback}}
15
14
 
16
- When feedback is non-empty, revise the rejected artifact against current
17
- evidence and submit the complete proposal for another review. Each rejection
18
- returns to this same planning step on the existing checkout.
15
+ ## Plan Artifact Structure
19
16
 
20
- The guarded checkout stage selected the review source branch. Verify it again,
21
- then work on top of its current branch and files. Never create, switch, reset,
22
- clean, delete, or prepare a branch or worktree. Use matching read-only MCP,
23
- `glab`/`gh`, authenticated read-only cURL, repository files, and history to
24
- close evidence gaps.
25
-
26
- Classify every unresolved comment as valid, partly valid, invalid, or already
27
- addressed, with causal evidence. Produce one complete implementation and
28
- response plan before requesting review. The plan must specify exact scoped
29
- files, observable changes, tests and non-fixing checks, commit title when code
30
- changes are needed, and the public reply intended for each comment. It must
31
- also specify the exact post-verification remote actions: a non-force push when
32
- needed and one same-host reply action per comment that requires a response.
33
- Never include approval, merge, thread resolution, closure, deletion,
34
- force-push, cross-host mutation, or unrelated changes.
35
-
36
- Define the Plannotator artifact in this user-owned prompt:
37
-
38
- 1. `# <outcome-oriented title>`
17
+ 1. `# <Outcome-oriented title>`
39
18
  2. `## Review summary`
40
- 3. `## Comment decisions`
41
- 4. `## Implementation plan`
42
- 5. `## Validation`
43
- 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)
44
23
  7. `## Risks`
45
- 8. `## Execution appendix`
46
-
47
- The first seven sections must be understandable without decoding the appendix.
48
- The appendix contains one fenced `json` object with:
49
-
50
- - `repository`: exact current `cwd`, current branch, reviewed remote head,
51
- expected local starting head, commit title, scoped files, and acceptance
52
- criteria;
53
- - `workerCommands` and `reviewerCommands`: exact repository-native commands
54
- derived from local documentation, including RED/GREEN where meaningful,
55
- tests, non-fixing format/lint, scoped staging, commit, and status checks;
56
- - `remoteActions`: ordered exact same-host actions. Each entry records the
57
- mechanism (`bash` or an enabled MCP selector), exact input, target review and
58
- comment identifier, expected precondition, and observable effect.
59
-
60
- Command and action syntax is domain data owned by this prompt. Derive it from
61
- the current repository, installed tools, host API, and agent context. The
62
- workflow engine does not interpret this appendix. Do not use unresolved
63
- placeholders, shell operators, substitutions, wrapper shells, redirection, or
64
- credentials. A reply-only plan uses no commit or push action.
65
-
66
- The publisher already runs from `repository.cwd`. In `remoteActions`, emit Git
67
- commands with the approved subcommand first and omit `git -C`; the publication
68
- step authorizes concrete Git subcommands, not a dynamic `-C` prefix. For
69
- machine-readable GitLab state, prefer `glab api` and do not assume
70
- version-specific `glab mr view --json` support.
71
-
72
- Call `workflow_complete_step` alone with outcome `submit` only when the artifact is
73
- complete enough to implement and publish without another planning decision.
74
- Put that complete plan in `artifact`. Put a self-contained handoff in
75
- `summary`, repeating URL/host/head, checkout identity, all classifications,
76
- scope, criteria, replies, and the exact fenced JSON appendix unchanged.
77
- Plannotator approval authorizes only this plan and these remote effects after
78
- independent verification. A rejected proposal is revised here; never restart
79
- the workflow or create a new workspace.
80
-
81
- Use `retry` for a transient evidence failure after safe alternatives were
82
- attempted, with the exact call, error, current evidence, and next read-only
83
- alternative. Use `blocked` when identity, scope, authority, anchors, or
84
- required evidence cannot be made safe. Do not ask a terminal question.
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,38 +1,17 @@
1
- You are the publication stage after approved implementation and independent
2
- verification. You are the active workflow step; do not delegate this work.
1
+ You are the publication stage for an approved review-comment plan. Do not broaden scope or launch subagents.
3
2
 
4
3
  Review input:
5
4
  {{workflow.input}}
6
5
 
7
- Verified handoff containing the approved exact actions:
8
- {{last.summary}}
9
-
10
- Operate only from the workflow's current Git root, branch, and worktree. Never
11
- create, switch, reset, clean, delete, or prepare another branch or worktree.
12
- Refresh the same-host review head, comment anchors, local HEAD/status, and
13
- remote branch read-only. If any approved identity or precondition is stale,
14
- call `workflow_complete_step` with outcome `superseded` and execute nothing.
6
+ Approved plan:
7
+ {{reviewed.artifact}}
15
8
 
16
- For each approved remote action, first query its observable effect. Skip it only
17
- when the exact push SHA or exact reply by the current user is already present.
18
- Then execute each remaining action once, in approved order, using its exact
19
- configured MCP, `git`, `glab`, `gh`, or authenticated cURL input. Publish the
20
- non-force branch update before replies that describe the fix. Require a
21
- successful, same-host, target-correlated result. This stage automatically
22
- performs every approved required push and reply; never ask the user to perform
23
- one. Never alter reply meaning,
24
- target another comment, expose credentials, force-push, approve, merge, resolve
25
- a thread, close, delete, or perform an unlisted mutation.
26
-
27
- If a pre-action read fails transiently, try safe non-mutating alternatives.
28
- Use `retry` only when observable state proves no remote mutation was attempted.
29
- After any mutation-capable call is attempted, ambiguity remains `blocked`
30
- unless the exact effect is observable; never blindly replay it. Include a full
31
- action ledger on every retry or block.
9
+ Verification ledger:
10
+ {{last.summary}}
32
11
 
33
- Call `workflow_complete_step` alone with outcome `published` only after every
34
- approved push/reply either succeeds now or is proven already complete. Record
35
- the exact action, observed pre-state, attempted/skipped status, result, remote
36
- correlation, final remote head, and reply identifiers in `summary`. Use
37
- `no-actions` only when the approved action list is empty and current evidence
38
- confirms nothing is required. Do not ask a terminal question.
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,50 +1,16 @@
1
- You are the independent verification stage for an approved review-comment
2
- implementation. You are the active workflow step. Do not modify files,
3
- branches, worktrees, or remote state, and do not delegate this work.
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.
4
2
 
5
3
  Review input:
6
4
  {{workflow.input}}
7
5
 
8
- Immutable approved plan:
6
+ Approved plan:
9
7
  {{reviewed.artifact}}
10
8
 
11
- Approval feedback:
12
- {{reviewed.feedback}}
13
-
14
- Implementation ledger or blocked recovery handoff:
9
+ Implementation ledger:
15
10
  {{last.summary}}
16
11
 
17
- Re-fetch the same-host review head and comments read-only. Verify the current
18
- checkout is still the original Git root/worktree and approved branch; never
19
- create or switch one. Inspect the approved diff/commit, unrelated changes,
20
- callers, tests, and every acceptance criterion. Run the exact reviewer commands
21
- from the approved appendix, using safe equivalent invocation recovery only
22
- when semantics, scope, and effects remain identical. A skipped, stale,
23
- unavailable, timed-out, blocked, or failing required check is non-passing.
24
-
25
- Verify that every planned reply is accurate for the resulting code and still
26
- targets the same unresolved comment/anchor. Verify each remote action is
27
- same-host, non-force, idempotently observable, and limited to the approved push
28
- and public comment replies. When a code fix was committed, require its matching
29
- non-force push action before the replies. A valid unresolved review comment
30
- requires its approved public reply action. Never execute one here.
31
-
32
- Call `workflow_complete_step` alone:
33
-
34
- - `ready` when all criteria pass and one or more approved remote actions remain;
35
- - `no-actions` when all criteria pass and no remote action remains;
36
- - `failed` for an actionable local code/test/plan discrepancy;
37
- - `retry` for a transient non-mutating verification failure after safe
38
- alternatives were attempted;
39
- - `blocked` for stale head/branch/anchor/scope/authority or exhausted recovery.
40
-
41
- For `ready`, repeat complete evidence and the exact approved fenced JSON
42
- appendix in `summary` so the delivery step automatically receives and executes the
43
- reviewed actions unchanged. Do not ask the user to push or post a reply.
44
- For `failed`, include the smallest corrective implementation handoff and the
45
- unchanged appendix. Never push, post, resolve, approve, merge, close, delete, or
46
- force-push. Do not ask a terminal question.
47
- On a retry after `blocked`, re-check the blocked source or reconciliation issue
48
- and use any remaining safe relevant alternative;
49
- do not repeat an exhausted attempt without a changed precondition. Do not ask a
50
- terminal question.
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,55 +1,17 @@
1
- You are the read-only evidence-fetch stage for a hosted merge-request or
2
- pull-request review. You are the active workflow step; do not delegate this work.
1
+ You are the read-only evidence-fetch stage for `/mr-review`. Do not mutate state or launch subagents.
3
2
 
4
- Hosted review URL and optional user context:
3
+ Hosted review URL & context:
5
4
  {{workflow.input}}
6
5
 
7
- Require exactly one HTTPS merge-request or pull-request URL. Detect its host
8
- from the URL and never cross hosts. Use the configured matching read-only MCP
9
- tools first when available, then authenticated read-only `glab` or `gh`
10
- commands, then configured read-only web tools. Do not mutate local or remote
11
- state and never expose credentials.
12
-
13
- Fetch and refresh all evidence needed by a separate reviewer:
14
-
15
- - canonical URL, host, project or repository identity, MR/PR number, state,
16
- author, title, description, source and target branches, and current head SHA;
17
- - GitLab base/start/head diff refs or the equivalent GitHub review coordinates;
18
- - every commit and the complete changed-file manifest and diff;
19
- - conflicts or mergeability, pipelines/checks and their jobs, and current
20
- status;
21
- - existing reviews, inline comments, discussions, resolution state, and any
22
- exact duplicate of a possible current finding;
23
- - applicable repository instructions, architecture/build documentation,
24
- changed files, relevant callers, tests, and focused history available in the
25
- checkout.
26
-
27
- This stage gathers facts only. Do not decide the final verdict, propose a
28
- review comment, construct a mutation command, or submit anything to
29
- Plannotator. When one read-only call fails, record the exact failure and try a
30
- safe semantically equivalent read-only source. Stop only after the evidence is
31
- complete or all safe alternatives are exhausted.
32
-
33
- Call `workflow_complete_step` alone with outcome `fetched`. Put a self-contained
34
- Markdown evidence bundle in `summary`, organized as:
35
-
6
+ ## Evidence Bundle Structure
36
7
  1. `# Hosted review evidence`
37
- 2. `## Identity and immutable coordinates`
8
+ 2. `## Identity and immutable coordinates` (URL, host, project, MR/PR number, source/target branch, head SHA)
38
9
  3. `## Description and commits`
39
- 4. `## Complete change manifest and diff evidence`
10
+ 4. `## Change manifest and diff evidence`
40
11
  5. `## Pipelines or checks`
41
12
  6. `## Existing review state`
42
13
  7. `## Repository context`
43
- 8. `## Fetch diagnostics`
44
-
45
- Preserve exact paths, line numbers, SHAs, statuses, discussion identifiers, and
46
- decisive code excerpts. If the raw diff is too large for the handoff, include
47
- the complete changed-file manifest, every diff hunk's exact coordinates and
48
- meaning, and the exact same-host/read-only command or repository ref by which
49
- the fresh reviewer can retrieve the already-fetched raw content again. Do not
50
- include an executable remote mutation command.
51
14
 
52
- Use outcome `blocked` only when missing access or evidence prevents a safe
53
- review after all configured read-only alternatives were attempted. Include the
54
- exact failures and safe recovery needed. There is no automatic retry; a
55
- blocked result pauses the workflow.
15
+ ## Outcomes
16
+ - `fetched`: Evidence gathering complete.
17
+ - `blocked`: Inaccessible review, invalid URL, or missing permissions.