@llblab/pi-actors 0.14.2 → 0.15.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 (67) hide show
  1. package/AGENTS.md +5 -1
  2. package/BACKLOG.md +18 -32
  3. package/CHANGELOG.md +25 -0
  4. package/README.md +24 -20
  5. package/docs/actor-messages.md +1 -1
  6. package/docs/async-runs.md +4 -4
  7. package/docs/command-templates.md +11 -11
  8. package/docs/recipe-library.md +7 -3
  9. package/docs/task-first-recipes.md +44 -43
  10. package/docs/template-recipes.md +7 -2
  11. package/docs/tool-registry.md +7 -5
  12. package/lib/actor-messages.ts +20 -7
  13. package/lib/async-runs.ts +25 -12
  14. package/lib/command-templates.ts +6 -1
  15. package/lib/config.ts +2 -2
  16. package/lib/execution.ts +9 -5
  17. package/lib/observability.ts +20 -10
  18. package/lib/prompts.ts +13 -20
  19. package/lib/tools.ts +196 -64
  20. package/package.json +17 -9
  21. package/recipes/coordinator-locker.json +46 -0
  22. package/recipes/music-player.json +16 -2
  23. package/recipes/pipeline-architect-coordinator.json +11 -3
  24. package/recipes/pipeline-artifact-bundle.json +12 -3
  25. package/recipes/pipeline-artifact-report.json +9 -3
  26. package/recipes/pipeline-artifact-write.json +9 -3
  27. package/recipes/pipeline-async-run-ops.json +18 -9
  28. package/recipes/pipeline-checkpoint-continuation.json +14 -3
  29. package/recipes/pipeline-development-tasking.json +12 -3
  30. package/recipes/pipeline-docs-maintenance.json +12 -3
  31. package/recipes/pipeline-media-library.json +12 -3
  32. package/recipes/pipeline-quorum-review.json +12 -9
  33. package/recipes/pipeline-release-readiness.json +27 -9
  34. package/recipes/pipeline-release-summary.json +89 -0
  35. package/recipes/pipeline-repo-health.json +12 -3
  36. package/recipes/pipeline-research-synthesis.json +11 -3
  37. package/recipes/pipeline-review-readiness.json +12 -6
  38. package/recipes/subagent-artifact.json +9 -3
  39. package/recipes/subagent-checkpoint.json +10 -3
  40. package/recipes/subagent-conflict-report.json +11 -3
  41. package/recipes/subagent-contradiction-map.json +11 -3
  42. package/recipes/subagent-critic.json +11 -3
  43. package/recipes/subagent-evidence-map.json +11 -3
  44. package/recipes/subagent-followup.json +10 -3
  45. package/recipes/subagent-judge.json +11 -3
  46. package/recipes/subagent-merge.json +11 -3
  47. package/recipes/subagent-message.json +8 -3
  48. package/recipes/subagent-normalize.json +11 -3
  49. package/recipes/subagent-plan.json +11 -3
  50. package/recipes/subagent-prompt.json +10 -3
  51. package/recipes/subagent-quorum.json +10 -7
  52. package/recipes/subagent-review-coordinator.json +14 -6
  53. package/recipes/subagent-review.json +11 -3
  54. package/recipes/subagent-task-card.json +11 -3
  55. package/recipes/subagent-tools.json +10 -3
  56. package/recipes/subagent-verify.json +11 -3
  57. package/recipes/subagents-prompts.json +10 -3
  58. package/recipes/utility-coordinator-lock-snapshot.json +14 -0
  59. package/recipes/utility-run-ops-snapshot.json +3 -3
  60. package/recipes/utility-skill-summary.json +14 -0
  61. package/scripts/coordinator-locker.mjs +272 -0
  62. package/scripts/music-player.mjs +2 -1
  63. package/scripts/recipe-utils.mjs +239 -81
  64. package/scripts/validate-recipe.mjs +28 -10
  65. package/skills/actors/SKILL.md +283 -0
  66. package/skills/swarm/SKILL.md +451 -0
  67. package/skills/swarm/references/development-swarm.md +596 -0
@@ -0,0 +1,283 @@
1
+ ---
2
+ name: actors
3
+ description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
4
+ metadata:
5
+ version: 0.15.0
6
+ ---
7
+
8
+ # Actors (pi-actors)
9
+
10
+ `pi-actors` turns trusted local capabilities into addressable actors. This skill is the compact operator/reference layer for the extension itself: tools, nouns, lifecycle, message protocol, recipes, and common edge cases. It is not a multi-agent strategy guide; use a swarm skill for decomposition, quorum design, reviewer lenses, and consensus methodology.
11
+
12
+ ## Knowledge Surfaces
13
+
14
+ Context arrives in layers:
15
+
16
+ - **Injected prompt**: always present at extension load. It is a bootstrap/reminder of current verbs, paths, and runtime rules; it should not try to be documentation.
17
+ - **Skill header**: automatically matched by agents from `name`/`description`. Its job is to signal: if pi-actors use is unclear, read this skill body.
18
+ - **This skill body**: highest-density practical reference. It should explain extension operation from multiple angles and link to deeper docs without becoming a changelog or swarm-methodology guide.
19
+ - **README**: human entrypoint. It explains what pi-actors is, why it matters, benefits, rhythm, and representative scenarios; it is not automatically in agent context.
20
+ - **Docs**: transportable standards by domain: command templates, recipes, async runs, actor messages, registry, recipe library; read on demand.
21
+ - **AGENTS.md**: project context for agents changing pi-actors: architecture constraints, durable conventions, do/don't rules, validation; read for repo work.
22
+
23
+ ## Core Nouns
24
+
25
+ ```text
26
+ Trusted local capability
27
+ -> Command template execution graph
28
+ -> Recipe saved actor definition
29
+ -> spawn starts one run instance
30
+ -> run:<id> addressable actor
31
+
32
+ Trusted local capability
33
+ -> Command template or recipe
34
+ -> register_tool persists an agent-callable wrapper
35
+ -> tool:<name> addressable tool actor
36
+ ```
37
+
38
+ - **Command template**: portable execution graph. String leaf, sequence array, or object node with controls.
39
+ - **Recipe**: saved JSON definition wrapping a template with args, defaults, imports, mailbox, artifacts, metadata, and optional `async: true`.
40
+ - **Run actor**: one detached execution instance addressable as `run:<id>` with status, logs, messages, mailbox metadata, files, and artifacts.
41
+ - **Tool actor**: registered persistent capability addressable as `tool:<name>` and callable through the generated tool or `message`.
42
+ - **Coordinator/session**: the current pi session endpoint that receives bounded actor follow-ups.
43
+ - **Mailbox**: public interaction contract: message types the actor accepts/emits.
44
+ - **Artifact**: named durable output path declared by a recipe/run.
45
+
46
+ ## Three Verbs
47
+
48
+ ### `spawn` — create a run actor
49
+
50
+ Use for long work, background services, subagents, fanout, pipelines, and reusable recipes.
51
+
52
+ ```json
53
+ {
54
+ "as": "run:repo-health",
55
+ "file": "pipeline-repo-health",
56
+ "values": { "path": "/repo" },
57
+ "artifacts": { "report": "/tmp/repo-health.md" }
58
+ }
59
+ ```
60
+
61
+ Rules:
62
+
63
+ - Use `file`/`recipe` for saved recipes; bare names resolve under `~/.pi/agent/recipes`.
64
+ - Use inline `template` for one-off experiments; promote useful repeats to recipes.
65
+ - Use stable `as` names when you will inspect or message the actor later.
66
+ - `async: true` on the recipe is the detached run switch.
67
+
68
+ ### `message` — send a typed envelope
69
+
70
+ ```json
71
+ {
72
+ "to": "run:repo-health",
73
+ "type": "control.cancel",
74
+ "summary": "Cancel stale repo-health run",
75
+ "body": {}
76
+ }
77
+ ```
78
+
79
+ Envelope fields:
80
+
81
+ - Required: `to`, `type`.
82
+ - Useful: `summary`, `body`, `from`, `reply_to`, `correlation_id`, `metadata`.
83
+ - Addresses: `run:<id>`, `branch:<run>/<branch>`, `tool:<name>`, `coordinator`, `session:<id>`.
84
+ - Standard termination messages: `control.stop`, `control.cancel`, `control.kill`.
85
+
86
+ Check `inspect view=mailbox` before domain-specific messages.
87
+
88
+ ### `inspect` — observe intentionally
89
+
90
+ ```json
91
+ { "target": "run:repo-health", "view": "status" }
92
+ { "target": "run:repo-health", "view": "tail", "lines": "80" }
93
+ { "target": "run:repo-health", "view": "messages" }
94
+ { "target": "run:repo-health", "view": "artifacts" }
95
+ { "target": "tool:music_player", "view": "status" }
96
+ { "target": "coordinator", "view": "status" }
97
+ ```
98
+
99
+ Views:
100
+
101
+ - `status`: lifecycle, pid, values, progress, result, compact summary.
102
+ - `tail`: recent stdout/stderr/log tail.
103
+ - `messages`: actor messages emitted by the run.
104
+ - `mailbox`: declared accepts/emits contract.
105
+ - `files`: run state directory file list.
106
+ - `artifacts`: declared artifact paths/status.
107
+
108
+ Let terminal notifications arrive; avoid sleep-poll loops except during diagnosis.
109
+
110
+ ## Command Template Standard
111
+
112
+ Forms:
113
+
114
+ ```json
115
+ "npm test -- {file}"
116
+ ["npm run typecheck", "npm test"]
117
+ { "parallel": true, "template": ["job-a", "job-b"] }
118
+ ```
119
+
120
+ Controls:
121
+
122
+ - `args`, `defaults`: public placeholder declarations and defaults.
123
+ - `parallel: true`: fanout child nodes.
124
+ - `when`: conditional execution.
125
+ - `timeout`, `delay`, `retry`: timing and retry controls; string placeholders are allowed where supported.
126
+ - `failure`: `continue`, `branch`, or `root` propagation.
127
+ - `recover`: cleanup between retry attempts.
128
+ - `repeat`: repeated node expansion.
129
+ - `output`: output behavior selection.
130
+
131
+ Placeholders:
132
+
133
+ - `{name}` required value.
134
+ - `{name=default}` inline default.
135
+ - `{name:type=default}` typed inline arg.
136
+ - `{value??fallback}` nullish fallback.
137
+ - `{flag?yes:no}` ternary fallback.
138
+
139
+ Templates are synchronous and portable. Recipes give them identity and lifecycle.
140
+
141
+ ## Recipe Standard
142
+
143
+ Minimal actor recipe:
144
+
145
+ ```json
146
+ {
147
+ "name": "my-task",
148
+ "async": true,
149
+ "args": ["path:path", "model:string"],
150
+ "defaults": {},
151
+ "mailbox": {
152
+ "accepts": ["control.stop", "control.cancel", "control.kill"],
153
+ "emits": ["command.done", "run.done", "run.failed"]
154
+ },
155
+ "artifacts": { "report": "{path}/report.md" },
156
+ "template": "some-command {path} --model {model}"
157
+ }
158
+ ```
159
+
160
+ Rules:
161
+
162
+ 1. Every recipe owns `template` directly.
163
+ 2. `async: true` makes spawned work a detached actor run.
164
+ 3. Public knobs belong in `args`/`defaults`; hidden launch mechanics stay inside `template`.
165
+ 4. Use `imports` to compose recipes; imported recipes are definitions, not nested async runs.
166
+ 5. Declare `mailbox` for actors that accept or emit meaningful messages.
167
+ 6. Declare `artifacts` for durable outputs the coordinator should inspect.
168
+ 7. Keep packaged recipes generic: no machine-local paths, no private companion identities, no project-specific defaults unless the recipe is explicitly project-specific.
169
+ 8. Do not ship concrete model-version defaults in packaged recipes; expose `model`, `models`, and stage-specific model args so the caller must choose current policy at launch.
170
+
171
+ ## Registered Tools
172
+
173
+ `register_tool` persists trusted local capabilities in `~/.pi/agent/actors-tools.json`.
174
+
175
+ Use it when a command/template/recipe should become durable agent muscle memory. Prefer typed args or placeholder-derived args; use `update=true` for replacement and `template=null` or `template=""` for deletion.
176
+
177
+ Tool templates may be:
178
+
179
+ - A foreground command template.
180
+ - A file-backed recipe name/path.
181
+ - A co-located recipe, optionally `async: true`.
182
+
183
+ Registered tools are convenient buttons; recipes are the reusable semantic definitions behind them.
184
+
185
+ ## Recipe Navigator
186
+
187
+ Use packaged recipes by name with `spawn file=<name>` for async actors, or register/call them as tools when repeated use deserves a stable shortcut. The links below point to recipe files shipped with this extension; read the JSON for args, defaults, mailbox, artifacts, and imports.
188
+
189
+ ### Coordination and Services
190
+
191
+ - [`coordinator-locker`](../../recipes/coordinator-locker.json): queue + acquire/renew/release lease locks + journaled coordinator messages.
192
+ - [`utility-coordinator-lock-snapshot`](../../recipes/utility-coordinator-lock-snapshot.json): one-shot JSON snapshot of a coordinator-locker state directory.
193
+ - [`music-player`](../../recipes/music-player.json): background local/URL/directory/playlist playback actor controlled by messages.
194
+
195
+ ### Subagent Atoms
196
+
197
+ - Launchers: [`subagent-prompt`](../../recipes/subagent-prompt.json), [`subagent-tools`](../../recipes/subagent-tools.json), [`subagents-prompts`](../../recipes/subagents-prompts.json).
198
+ - Review chain: [`subagent-review`](../../recipes/subagent-review.json), [`subagent-verify`](../../recipes/subagent-verify.json), [`subagent-merge`](../../recipes/subagent-merge.json), [`subagent-judge`](../../recipes/subagent-judge.json), [`subagent-normalize`](../../recipes/subagent-normalize.json).
199
+ - Planning/evidence: [`subagent-plan`](../../recipes/subagent-plan.json), [`subagent-task-card`](../../recipes/subagent-task-card.json), [`subagent-evidence-map`](../../recipes/subagent-evidence-map.json), [`subagent-contradiction-map`](../../recipes/subagent-contradiction-map.json), [`subagent-critic`](../../recipes/subagent-critic.json).
200
+ - Handoffs: [`subagent-checkpoint`](../../recipes/subagent-checkpoint.json), [`subagent-followup`](../../recipes/subagent-followup.json), [`subagent-message`](../../recipes/subagent-message.json), [`subagent-artifact`](../../recipes/subagent-artifact.json), [`subagent-conflict-report`](../../recipes/subagent-conflict-report.json).
201
+ - Composition: [`subagent-quorum`](../../recipes/subagent-quorum.json), [`subagent-review-coordinator`](../../recipes/subagent-review-coordinator.json).
202
+
203
+ ### Pipelines
204
+
205
+ - [`pipeline-release-readiness`](../../recipes/pipeline-release-readiness.json): changelog/package/skill/validation evidence → release review → artifact report.
206
+ - [`pipeline-release-summary`](../../recipes/pipeline-release-summary.json): evidence-only release summary, risk checklist, and PR body draft artifact without release side effects.
207
+ - [`pipeline-repo-health`](../../recipes/pipeline-repo-health.json): git/doc/validation evidence → normalized repository health report.
208
+ - [`pipeline-async-run-ops`](../../recipes/pipeline-async-run-ops.json): run summary + selected run messages → operations report.
209
+ - [`pipeline-docs-maintenance`](../../recipes/pipeline-docs-maintenance.json): docs index/review/planning → maintenance artifact.
210
+ - Artifacts: [`pipeline-artifact-report`](../../recipes/pipeline-artifact-report.json), [`pipeline-artifact-write`](../../recipes/pipeline-artifact-write.json), [`pipeline-artifact-bundle`](../../recipes/pipeline-artifact-bundle.json).
211
+ - Review gates: [`pipeline-quorum-review`](../../recipes/pipeline-quorum-review.json), [`pipeline-review-readiness`](../../recipes/pipeline-review-readiness.json).
212
+ - Task-first workflows: [`pipeline-architect-coordinator`](../../recipes/pipeline-architect-coordinator.json), [`pipeline-research-synthesis`](../../recipes/pipeline-research-synthesis.json), [`pipeline-development-tasking`](../../recipes/pipeline-development-tasking.json), [`pipeline-checkpoint-continuation`](../../recipes/pipeline-checkpoint-continuation.json), [`pipeline-media-library`](../../recipes/pipeline-media-library.json).
213
+
214
+ ### Utilities
215
+
216
+ - Repo/release evidence: [`utility-git-status`](../../recipes/utility-git-status.json), [`utility-git-log`](../../recipes/utility-git-log.json), [`utility-changelog-head`](../../recipes/utility-changelog-head.json), [`utility-changelog-section`](../../recipes/utility-changelog-section.json), [`utility-package-summary`](../../recipes/utility-package-summary.json), [`utility-skill-summary`](../../recipes/utility-skill-summary.json).
217
+ - Validation/state: [`utility-validation-wrapper`](../../recipes/utility-validation-wrapper.json), [`utility-validate-recipe`](../../recipes/utility-validate-recipe.json), [`utility-run-summary`](../../recipes/utility-run-summary.json), [`utility-run-ops-snapshot`](../../recipes/utility-run-ops-snapshot.json), [`utility-run-state-files`](../../recipes/utility-run-state-files.json), [`utility-jsonl-tail`](../../recipes/utility-jsonl-tail.json).
218
+ - Artifacts/media/messages: [`utility-artifact-manifest`](../../recipes/utility-artifact-manifest.json), [`utility-artifact-write`](../../recipes/utility-artifact-write.json), [`utility-actor-message`](../../recipes/utility-actor-message.json), [`utility-markdown-index`](../../recipes/utility-markdown-index.json), [`utility-playlist-scan`](../../recipes/utility-playlist-scan.json), [`utility-playlist-build`](../../recipes/utility-playlist-build.json).
219
+
220
+ Deep inventory: [`docs/recipe-library.md`](../../docs/recipe-library.md).
221
+
222
+ ## Operating Patterns
223
+
224
+ - **Short deterministic command**: call foreground registered tool or command template.
225
+ - **Long job/service/fanout**: `spawn` async recipe, then inspect/messages/artifacts.
226
+ - **One-off experiment**: inline `template`; promote after repeat use.
227
+ - **Reusable workflow**: recipe with public knobs, mailbox, artifacts, docs.
228
+ - **Subagent/swarm execution**: actor mechanics here; methodology belongs to swarm guidance.
229
+ - **Coordinated workers**: spawn `coordinator-locker` when several actors need a shared queue, acquire/renew/release resource leases, or a journaled coordination point.
230
+ - **Release/review pipeline**: pi-actors can prepare evidence, summaries, and artifacts; external actions such as commit, PR, merge, tag, and publish require the appropriate gated release workflow.
231
+
232
+ ## Complementary Methodology Engines
233
+
234
+ pi-actors is the local execution engine for methodology skills. A methodology skill can define abstract patterns such as lens swarm, quorum, task cards, lock discipline, or clean-context merge; pi-actors turns those patterns into concrete local actors, recipes, queues, leases, artifacts, and messages.
235
+
236
+ Example mapping:
237
+
238
+ ```text
239
+ methodology says: protect shared files
240
+ pi-actors does: spawn coordinator-locker, enqueue tasks, lease resources
241
+
242
+ methodology says: run reviewers then merge
243
+ pi-actors does: spawn review pipeline, inspect messages/artifacts
244
+ ```
245
+
246
+ Keep the split clean: methodology chooses coordination shape; pi-actors supplies addressable local machinery.
247
+
248
+ ## Lifecycle Discipline
249
+
250
+ 1. Choose existing recipe/tool when available.
251
+ 2. Spawn with a stable actor id for observable work.
252
+ 3. Inspect `status` after launch.
253
+ 4. Use notifications and `inspect`; do not busy-poll.
254
+ 5. Read `messages` and `artifacts`, not only stdout.
255
+ 6. Use `message` for explicit control or domain commands.
256
+ 7. Promote repeated inline forms to recipes.
257
+ 8. Update docs/context when changing public behavior.
258
+
259
+ ## Common Pitfalls
260
+
261
+ - Treating actor mechanics as multi-agent methodology.
262
+ - Repeating inline templates instead of promoting recipes.
263
+ - Omitting stable run ids for work that needs follow-up.
264
+ - Sending domain messages without checking `mailbox`.
265
+ - Reading only stdout and missing actor messages/artifacts.
266
+ - Baking local absolute paths into published docs or reusable recipes.
267
+ - Creating recipes that perform external side effects without explicit operator gates.
268
+ - Preserving old runtime/event/FIFO vocabulary instead of `spawn`/`message`/`inspect` and actor messages.
269
+
270
+ ## Deep References
271
+
272
+ - `docs/command-templates.md` — execution graph semantics.
273
+ - `docs/template-recipes.md` — recipe storage, imports, defaults, references.
274
+ - `docs/async-runs.md` — detached lifecycle, state, cancellation, observability.
275
+ - `docs/actor-messages.md` — addressed envelope protocol and mailbox model.
276
+ - `docs/tool-registry.md` — persistent tool registry and generated tools.
277
+ - `docs/recipe-library.md` — packaged recipes.
278
+ - `docs/task-first-recipes.md` — deriving reusable pipelines from operator tasks.
279
+ - `docs/component-recipes.md` — reusable coordinator/subagent building blocks.
280
+
281
+ ## One-Sentence Contract
282
+
283
+ Use pi-actors to wrap local capabilities as addressable actors: define launch with templates, preserve semantics in recipes/tools, start with `spawn`, communicate with `message`, observe with `inspect`, and hand off durable results through messages and artifacts.