pi-herdr-agents 0.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 (49) hide show
  1. package/AGENTS.md +116 -0
  2. package/CONTEXT.md +159 -0
  3. package/LICENSE +21 -0
  4. package/README.md +874 -0
  5. package/RELEASING.md +139 -0
  6. package/agents/adversarial-reviewer.md +80 -0
  7. package/agents/claude-reviewer.md +23 -0
  8. package/agents/planner.md +539 -0
  9. package/agents/poteto.md +32 -0
  10. package/agents/reviewer.md +164 -0
  11. package/agents/scout.md +106 -0
  12. package/agents/visual-tester.md +224 -0
  13. package/agents/worker.md +132 -0
  14. package/config.json.example +8 -0
  15. package/docs/README.md +42 -0
  16. package/docs/adr/0001-btw-ephemeral-side-questions.md +142 -0
  17. package/docs/adr/0002-agent-workflow-skill-runtime-taxonomy.md +265 -0
  18. package/docs/adr/0003-installable-role-packs.md +135 -0
  19. package/docs/adr/0004-require-active-user-approval-for-workflow-execution.md +17 -0
  20. package/docs/adr/0005-parent-owns-workflow-script-authority.md +17 -0
  21. package/docs/adr/0006-limit-v1-execution-effects-to-isolated-worktrees.md +18 -0
  22. package/docs/adr/0007-require-fresh-review-for-workflow-scripts.md +19 -0
  23. package/docs/orchestrated-review-workflow-plan.md +479 -0
  24. package/docs/research/pdw-architecture-assessment.md +525 -0
  25. package/docs/research/pi-workflows-sol-advisor.md +255 -0
  26. package/docs/research/worktree-subagent-orchestration.md +317 -0
  27. package/docs/worktree-subagents.md +196 -0
  28. package/examples/role-pack/extension.ts +18 -0
  29. package/examples/role-pack/package.json +16 -0
  30. package/examples/role-pack/roles/example-reviewer.md +12 -0
  31. package/package.json +58 -0
  32. package/pi-extension/subagents/activity.ts +511 -0
  33. package/pi-extension/subagents/completion.ts +177 -0
  34. package/pi-extension/subagents/herdr.ts +541 -0
  35. package/pi-extension/subagents/index.ts +4730 -0
  36. package/pi-extension/subagents/lifecycle.ts +477 -0
  37. package/pi-extension/subagents/model-config.ts +95 -0
  38. package/pi-extension/subagents/plan-skill.md +262 -0
  39. package/pi-extension/subagents/plugin/.claude-plugin/plugin.json +5 -0
  40. package/pi-extension/subagents/plugin/hooks/hooks.json +15 -0
  41. package/pi-extension/subagents/plugin/hooks/on-stop.sh +68 -0
  42. package/pi-extension/subagents/runtime-routing.ts +313 -0
  43. package/pi-extension/subagents/session.ts +216 -0
  44. package/pi-extension/subagents/status.ts +513 -0
  45. package/pi-extension/subagents/subagent-done.ts +326 -0
  46. package/pi-extension/subagents/terminal.ts +163 -0
  47. package/pi-extension/subagents/workflow-worker.js +56 -0
  48. package/pi-extension/subagents/workflow.ts +1210 -0
  49. package/skills/orchestrate/SKILL.md +184 -0
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: orchestrate
3
+ description: Run an approved, review-only orchestration workflow from local files, URLs, tickets, or combinations of accessible sources. Use when a parent needs bounded fresh parallel review and synthesis with one final result.
4
+ ---
5
+
6
+ # Orchestrate a review
7
+
8
+ This is a parent-only authoring procedure. Read this file before doing any
9
+ orchestration. The extension is the runner; this skill is the only bundled
10
+ workflow author. Do not use `subagent()` for workflow nodes.
11
+
12
+ ## 1. Resolve and materialize the source
13
+
14
+ Accept one or more user sources: local paths, URLs, tickets, or any
15
+ combination. Use only capabilities already available to the parent (for
16
+ example, `read` for repository files and an already-installed browser or
17
+ research capability for remote material). There is no tracker client in this
18
+ package.
19
+
20
+ - Stop and report the inaccessible source. Do not guess, silently omit it, or
21
+ continue with a partial source.
22
+ - Read remote and tracker content now, before preparation. Materialize the
23
+ exact text, URL or ticket identifier, and retrieval note into the workflow
24
+ prompts/script. Children must never refetch a URL or ticket.
25
+ - Resolve local paths inside the approved repository at the selected committed
26
+ base. Reviewers may read those paths only through the runner-owned read-only
27
+ checkout. Do not use parent uncommitted or untracked files as evidence.
28
+ - Keep source strings in metadata as provenance. If exact evidence cannot fit
29
+ within the runner limits, stop and ask the user to narrow the source.
30
+
31
+ ## 2. Parent-only preflight
32
+
33
+ Perform discovery in the parent session only. Inspect the source and candidate
34
+ revision, identify the review questions, and resolve distinct available Pi
35
+ review roles and their exact authenticated `provider/model` and `thinking`
36
+ values. Use the normal role discovery and model catalog already available to
37
+ the parent; do not add a tracker client, a second discovery mechanism, or ask a
38
+ child to discover roles.
39
+
40
+ Choose at least two independent reviewer roles and one different synthesizer
41
+ role. Every declared role must be distinct, Pi-backed, and have a non-empty
42
+ read-only tool set after runner derivation. Use bounded caps no higher than
43
+ `maxAgents: 8` and `maxConcurrency: 4`; leave enough agent calls for one
44
+ synthesizer and any permitted replacement. Exact model and thinking are
45
+ mandatory for every role. Never inherit, guess, or fall back to a parent or
46
+ role default.
47
+
48
+ The first flow is review-only. Do not plan writers, commits, worktrees for
49
+ writing, ticket changes, pull requests, merges, deployments, publishing,
50
+ messages to external systems, cleanup, replay, nested workflows, or runtime or
51
+ model/tool fallback.
52
+
53
+ ## 3. Author one exact workflow script
54
+
55
+ The parent alone writes `.pi/plans/<run>/workflow.js` in a new unique run
56
+ directory. Use the committed `baseSha` selected during preflight, not a moving
57
+ ref. Do not
58
+ overwrite a prior run or create a journal yourself. The first bytes must be the
59
+ runner metadata comment, with only the fields accepted by the runner:
60
+
61
+ ```js
62
+ /* herdr-workflow
63
+ {
64
+ "version": 1,
65
+ "name": "review: <short request>",
66
+ "sources": ["<provenance>", "<provenance>"],
67
+ "baseSha": "<40 lowercase hex characters>",
68
+ "maxAgents": 8,
69
+ "maxConcurrency": 4,
70
+ "roles": [
71
+ {"role": "<review-role-a>", "kind": "review", "model": "<provider/model>", "thinking": "<level>"},
72
+ {"role": "<review-role-b>", "kind": "review", "model": "<provider/model>", "thinking": "<level>"},
73
+ {"role": "<synthesizer-role>", "kind": "review", "model": "<provider/model>", "thinking": "<level>"}
74
+ ]
75
+ }
76
+ */
77
+ ```
78
+
79
+ After the metadata, embed exact remote and tracker evidence as ordinary
80
+ JSON-compatible constants. For local repository sources, include the exact path
81
+ and committed base and direct reviewers to inspect that path in the runner-owned
82
+ read-only checkout. Children must not refetch URLs or tickets or use shell,
83
+ network, or MCP access. The parent-authored task prompt and review questions
84
+ must be explicit. Keep the script below the runner's size limit.
85
+
86
+ Launch independent fresh reviewers with ordinary JavaScript and `Promise.all`.
87
+ Each reviewer must get the exact evidence and the same review request, while
88
+ retaining its distinct declared role. Pass only
89
+ `{ kind: "review", role: "<declared-role>" }` to `agent()`; the script cannot
90
+ select tools, model, thinking, cwd, skills, or context.
91
+
92
+ A required reviewer may have at most one fresh same-role replacement, and only
93
+ when its returned failure envelope explicitly has `retryable === true`:
94
+
95
+ ```js
96
+ const finalReviews = await Promise.all(reviewRequests.map(async ({ role, prompt }) => {
97
+ const first = await agent(prompt, { kind: "review", role });
98
+ if (first && first.ok === false && first.retryable === true) {
99
+ return await agent(prompt + "\nThis is the one approved replacement attempt.", {
100
+ kind: "review",
101
+ role,
102
+ });
103
+ }
104
+ return first;
105
+ }));
106
+ ```
107
+
108
+ Do not infer retryability from prose, error text, stop reasons, null values, or
109
+ negative review findings. Do not retry a successful review or a failure without
110
+ explicit `retryable: true`. The replacement keeps the exact same role and
111
+ approved runtime. Current runtime failures are non-retryable, so this branch is
112
+ normally dormant; do not invent a retryable integration fixture.
113
+
114
+ Start one fresh synthesizer only after all reviewers and any bounded
115
+ replacement have settled. It must receive the exact source evidence and every
116
+ final reviewer success/failure envelope, including failures; never filter,
117
+ collapse, or synthesize in the parent. The synthesizer is a distinct declared
118
+ role and uses only:
119
+
120
+ ```js
121
+ const synthesis = await agent(synthesisPrompt, {
122
+ kind: "review",
123
+ role: "<synthesizer-role>",
124
+ });
125
+ ```
126
+
127
+ Return one JSON-compatible, task-specific result chosen for this request. Do
128
+ not impose a package-wide verdict enum, review receipt, fixed task schema, or
129
+ mechanical worst-result rule. Keep operational failure envelopes explicit in
130
+ whatever evidence shape the task needs.
131
+
132
+ ## 4. Prepare, show, and approve
133
+
134
+ Call only the parent-facing `herdr_workflow` tool for workflow execution:
135
+
136
+ ```ts
137
+ herdr_workflow({ action: "prepare", path: ".pi/plans/<run>/workflow.js" })
138
+ ```
139
+
140
+ Preparation has no child, journal, checkout, or other execution effect. Present
141
+ the returned approval packet **unmodified**. Do not summarize it in place of
142
+ the packet or alter its hash, role fingerprints, repository, base, sources, or
143
+ tools. Ask the user to reply with the exact line shown by the packet:
144
+
145
+ ```text
146
+ APPROVE <8 lowercase hex characters>
147
+ ```
148
+
149
+ Do not call `start` until that exact user reply is received in the same active
150
+ parent session. Do not put approval text in a tool argument. After the reply,
151
+ call:
152
+
153
+ ```ts
154
+ herdr_workflow({ action: "start", runId: "<run from packet>" })
155
+ ```
156
+
157
+ If preparation fails, source access fails, or the candidate changes, stop and
158
+ explain the failure. A revised script requires a new prepare and approval.
159
+
160
+ ## 5. Wait for one delivery
161
+
162
+ After `start` returns, wait for the single final workflow delivery. Do not poll,
163
+ sleep, tail a journal, call a status/history/resume action, or ask children for
164
+ updates. The runner delivers one bounded result and retains the journal and
165
+ child sessions as evidence.
166
+
167
+ The parent may cancel with:
168
+
169
+ ```ts
170
+ herdr_workflow({ action: "cancel", runId: "<run>" })
171
+ ```
172
+
173
+ Cancellation is fail-closed: active child process identities are captured,
174
+ panes are closed, process exit is confirmed before checkout disposal, and an
175
+ unconfirmed process retains the checkout and produces a failed terminal result.
176
+ A same-process `/reload` preserves the active owner and one final delivery. A
177
+ full process restart does not replay work; stale running evidence is marked
178
+ `interrupted`, retained artifacts remain for inspection, and a new approved
179
+ run is required.
180
+
181
+ The Worker and Node `vm` isolate workflow availability from Pi's main event
182
+ loop, but neither is a security boundary. Treat the approved script as trusted
183
+ code and inspect it before approval. Worktrees isolate Git state only; Pi,
184
+ Herdr, children, and installed packages retain the user's system permissions.