@chankov/agent-fleet 0.0.9 → 0.0.10

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 (354) hide show
  1. package/.claude/commands/doctor-agent-fleet.md +12 -7
  2. package/.claude/commands/setup-agent-fleet.md +7 -15
  3. package/.opencode/commands/af-doctor-agent-fleet.md +12 -7
  4. package/.opencode/commands/af-setup-agent-fleet.md +8 -6
  5. package/.pi/extensions/agent-fleet-update-check/README.md +2 -3
  6. package/.pi/extensions/btw/README.md +2 -2
  7. package/.pi/extensions/chrome-devtools-mcp/README.md +3 -6
  8. package/.pi/extensions/compact-and-continue/README.md +3 -3
  9. package/.pi/extensions/mcp-bridge/README.md +1 -1
  10. package/.pi/harnesses/agent-hub/README.md +139 -10
  11. package/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  12. package/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  13. package/.pi/harnesses/agent-hub/index.ts +448 -39
  14. package/.pi/harnesses/agent-hub/package.json +1 -1
  15. package/.pi/harnesses/agent-hub/review-findings.js +102 -0
  16. package/.pi/harnesses/agent-hub/run-budget.js +302 -4
  17. package/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  18. package/.pi/harnesses/coms/package.json +1 -1
  19. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  20. package/.pi/prompts/af-doctor-agent-fleet.md +13 -6
  21. package/.pi/prompts/af-setup-agent-fleet.md +7 -15
  22. package/.versions/0.0.10/.claude/commands/build.md +44 -0
  23. package/.versions/0.0.10/.claude/commands/code-simplify.md +22 -0
  24. package/.versions/0.0.10/.claude/commands/design-agent.md +14 -0
  25. package/.versions/0.0.10/.claude/commands/doctor-agent-fleet.md +22 -0
  26. package/.versions/0.0.10/.claude/commands/orchestrate.md +112 -0
  27. package/.versions/0.0.10/.claude/commands/plan.md +16 -0
  28. package/.versions/0.0.10/.claude/commands/prime.md +22 -0
  29. package/.versions/0.0.10/.claude/commands/review.md +16 -0
  30. package/.versions/0.0.10/.claude/commands/set-hermes-telegram.md +15 -0
  31. package/.versions/0.0.10/.claude/commands/set-hermes-watchdog.md +6 -0
  32. package/.versions/0.0.10/.claude/commands/setup-agent-fleet.md +17 -0
  33. package/.versions/0.0.10/.claude/commands/ship.md +72 -0
  34. package/.versions/0.0.10/.claude/commands/spec.md +15 -0
  35. package/.versions/0.0.10/.claude/commands/test.md +19 -0
  36. package/.versions/0.0.10/.claude/commands/webperf.md +32 -0
  37. package/.versions/0.0.10/.claude/orchestrate-teams.yaml +24 -0
  38. package/.versions/0.0.10/.opencode/commands/af-build.md +17 -0
  39. package/.versions/0.0.10/.opencode/commands/af-code-simplify.md +16 -0
  40. package/.versions/0.0.10/.opencode/commands/af-compound.md +16 -0
  41. package/.versions/0.0.10/.opencode/commands/af-design-agent.md +15 -0
  42. package/.versions/0.0.10/.opencode/commands/af-doctor-agent-fleet.md +22 -0
  43. package/.versions/0.0.10/.opencode/commands/af-orchestrate.md +112 -0
  44. package/.versions/0.0.10/.opencode/commands/af-plan.md +16 -0
  45. package/.versions/0.0.10/.opencode/commands/af-prime.md +22 -0
  46. package/.versions/0.0.10/.opencode/commands/af-review.md +15 -0
  47. package/.versions/0.0.10/.opencode/commands/af-set-hermes-telegram.md +15 -0
  48. package/.versions/0.0.10/.opencode/commands/af-set-hermes-watchdog.md +6 -0
  49. package/.versions/0.0.10/.opencode/commands/af-setup-agent-fleet.md +17 -0
  50. package/.versions/0.0.10/.opencode/commands/af-ship.md +16 -0
  51. package/.versions/0.0.10/.opencode/commands/af-spec.md +16 -0
  52. package/.versions/0.0.10/.opencode/commands/af-test.md +21 -0
  53. package/.versions/0.0.10/.opencode/commands/af-webperf.md +32 -0
  54. package/.versions/0.0.10/.opencode/orchestrate-teams.yaml +24 -0
  55. package/.versions/0.0.10/.pi/agents/dispatch-policy.yaml +32 -0
  56. package/.versions/0.0.10/.pi/agents/model-profiles.yaml +27 -0
  57. package/.versions/0.0.10/.pi/agents/peers.yaml +142 -0
  58. package/.versions/0.0.10/.pi/agents/teams.yaml +41 -0
  59. package/.versions/0.0.10/.pi/damage-control-rules.yaml +297 -0
  60. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  61. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  62. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  63. package/.versions/0.0.10/.pi/extensions/btw/README.md +118 -0
  64. package/.versions/0.0.10/.pi/extensions/btw/index.ts +917 -0
  65. package/.versions/0.0.10/.pi/extensions/btw/package.json +6 -0
  66. package/.versions/0.0.10/.pi/extensions/btw/state.js +179 -0
  67. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  68. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  69. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  70. package/.versions/0.0.10/.pi/extensions/compact-and-continue/README.md +42 -0
  71. package/.versions/0.0.10/.pi/extensions/compact-and-continue/index.ts +120 -0
  72. package/.versions/0.0.10/.pi/extensions/compact-and-continue/package.json +6 -0
  73. package/.versions/0.0.10/.pi/extensions/mcp-bridge/README.md +46 -0
  74. package/.versions/0.0.10/.pi/extensions/mcp-bridge/index.ts +206 -0
  75. package/.versions/0.0.10/.pi/extensions/mcp-bridge/package.json +6 -0
  76. package/.versions/0.0.10/.pi/extensions/package-lock.json +1143 -0
  77. package/.versions/0.0.10/.pi/extensions/package.json +9 -0
  78. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/README.md +201 -0
  79. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/config.ts +198 -0
  80. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  81. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/index.ts +248 -0
  82. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/package.json +6 -0
  83. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  84. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  85. package/.versions/0.0.10/.pi/harnesses/agent-hub/README.md +1001 -0
  86. package/.versions/0.0.10/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  87. package/.versions/0.0.10/.pi/harnesses/agent-hub/artifacts.js +146 -0
  88. package/.versions/0.0.10/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  89. package/.versions/0.0.10/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  90. package/.versions/0.0.10/.pi/harnesses/agent-hub/context-window.js +106 -0
  91. package/.versions/0.0.10/.pi/harnesses/agent-hub/delegate.ts +435 -0
  92. package/.versions/0.0.10/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  93. package/.versions/0.0.10/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  94. package/.versions/0.0.10/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  95. package/.versions/0.0.10/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  96. package/.versions/0.0.10/.pi/harnesses/agent-hub/footer.ts +31 -0
  97. package/.versions/0.0.10/.pi/harnesses/agent-hub/helpers.ts +248 -0
  98. package/.versions/0.0.10/.pi/harnesses/agent-hub/index.ts +9111 -0
  99. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  100. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  101. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  102. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  103. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  104. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  105. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  106. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-session-bridge.ts +257 -0
  107. package/.versions/0.0.10/.pi/harnesses/agent-hub/package.json +7 -0
  108. package/.versions/0.0.10/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  109. package/.versions/0.0.10/.pi/harnesses/agent-hub/research-retention.js +34 -0
  110. package/.versions/0.0.10/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  111. package/.versions/0.0.10/.pi/harnesses/agent-hub/return-contract.js +293 -0
  112. package/.versions/0.0.10/.pi/harnesses/agent-hub/return-extract.js +75 -0
  113. package/.versions/0.0.10/.pi/harnesses/agent-hub/review-findings.js +102 -0
  114. package/.versions/0.0.10/.pi/harnesses/agent-hub/run-budget.js +479 -0
  115. package/.versions/0.0.10/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  116. package/.versions/0.0.10/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  117. package/.versions/0.0.10/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  118. package/.versions/0.0.10/.pi/harnesses/agent-hub/session-health.js +110 -0
  119. package/.versions/0.0.10/.pi/harnesses/agent-hub/spawn.ts +354 -0
  120. package/.versions/0.0.10/.pi/harnesses/agent-hub/version.ts +42 -0
  121. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/README.md +19 -0
  122. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/index.ts +321 -0
  123. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  124. package/.versions/0.0.10/.pi/harnesses/coms/README.md +100 -0
  125. package/.versions/0.0.10/.pi/harnesses/coms/index.ts +1767 -0
  126. package/.versions/0.0.10/.pi/harnesses/coms/package.json +7 -0
  127. package/.versions/0.0.10/.pi/harnesses/coms/version.ts +42 -0
  128. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/README.md +124 -0
  129. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/index.ts +536 -0
  130. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/package.json +7 -0
  131. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/version.ts +42 -0
  132. package/.versions/0.0.10/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  133. package/.versions/0.0.10/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  134. package/.versions/0.0.10/.pi/harnesses/lib/herdr-client.ts +472 -0
  135. package/.versions/0.0.10/.pi/harnesses/lib/herdr-presence.ts +399 -0
  136. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  137. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  138. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  139. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  140. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  141. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  142. package/.versions/0.0.10/.pi/harnesses/lib/spawned-peers.js +190 -0
  143. package/.versions/0.0.10/.pi/harnesses/package-lock.json +35 -0
  144. package/.versions/0.0.10/.pi/harnesses/package.json +9 -0
  145. package/.versions/0.0.10/.pi/prompts/af-build.md +24 -0
  146. package/.versions/0.0.10/.pi/prompts/af-code-simplify.md +22 -0
  147. package/.versions/0.0.10/.pi/prompts/af-doctor-agent-fleet.md +22 -0
  148. package/.versions/0.0.10/.pi/prompts/af-plan.md +16 -0
  149. package/.versions/0.0.10/.pi/prompts/af-review.md +16 -0
  150. package/.versions/0.0.10/.pi/prompts/af-set-hermes-telegram.md +15 -0
  151. package/.versions/0.0.10/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  152. package/.versions/0.0.10/.pi/prompts/af-setup-agent-fleet.md +19 -0
  153. package/.versions/0.0.10/.pi/prompts/af-ship.md +17 -0
  154. package/.versions/0.0.10/.pi/prompts/af-spec.md +15 -0
  155. package/.versions/0.0.10/.pi/prompts/af-test.md +19 -0
  156. package/.versions/0.0.10/.pi/skills/bowser/SKILL.md +145 -0
  157. package/.versions/0.0.10/.version +1 -0
  158. package/.versions/0.0.10/agents/architect.md +24 -0
  159. package/.versions/0.0.10/agents/bowser.md +27 -0
  160. package/.versions/0.0.10/agents/builder.md +54 -0
  161. package/.versions/0.0.10/agents/code-reviewer.md +208 -0
  162. package/.versions/0.0.10/agents/deep-researcher.md +32 -0
  163. package/.versions/0.0.10/agents/documenter.md +18 -0
  164. package/.versions/0.0.10/agents/orchestrator.md +72 -0
  165. package/.versions/0.0.10/agents/plan-reviewer.md +83 -0
  166. package/.versions/0.0.10/agents/planner.md +70 -0
  167. package/.versions/0.0.10/agents/releaser.md +24 -0
  168. package/.versions/0.0.10/agents/researcher.md +28 -0
  169. package/.versions/0.0.10/agents/security-auditor.md +167 -0
  170. package/.versions/0.0.10/agents/test-engineer.md +153 -0
  171. package/.versions/0.0.10/agents/web-debugger.md +43 -0
  172. package/.versions/0.0.10/agents/web-performance-auditor.md +193 -0
  173. package/.versions/0.0.10/codex/CONDUCTOR.md +148 -0
  174. package/.versions/0.0.10/docs/ARCHITECTURE.md +303 -0
  175. package/.versions/0.0.10/docs/agent-fleet-setup.md +377 -0
  176. package/.versions/0.0.10/docs/claude-code-coms-bridge.md +109 -0
  177. package/.versions/0.0.10/docs/codex-remote-conductor.md +170 -0
  178. package/.versions/0.0.10/docs/coms-hermes-bridge.md +189 -0
  179. package/.versions/0.0.10/docs/getting-started.md +254 -0
  180. package/.versions/0.0.10/docs/npm-install.md +514 -0
  181. package/.versions/0.0.10/docs/opencode-setup.md +281 -0
  182. package/.versions/0.0.10/docs/pi-extensions.md +363 -0
  183. package/.versions/0.0.10/docs/pi-setup.md +571 -0
  184. package/.versions/0.0.10/docs/skill-anatomy.md +150 -0
  185. package/.versions/0.0.10/hermes/README.md +347 -0
  186. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  187. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  188. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  189. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  190. package/.versions/0.0.10/hermes/gates/gate-o-capability.md +8 -0
  191. package/.versions/0.0.10/hermes/gates/gate-o-validator-fixtures.json +1 -0
  192. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  193. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  194. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  195. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  196. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  197. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  198. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  199. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  200. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  201. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  202. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  203. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  204. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  205. package/.versions/0.0.10/hermes/skills/hub-conductor/SKILL.md +84 -0
  206. package/.versions/0.0.10/hermes/skills/hub-liaison/SKILL.md +84 -0
  207. package/.versions/0.0.10/hermes/skills/hub-watchdog/SKILL.md +76 -0
  208. package/.versions/0.0.10/hermes/skills/hub-watchdog/manifest.json +1 -0
  209. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  210. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  211. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  212. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  213. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  214. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  215. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  216. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  217. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  218. package/.versions/0.0.10/hermes/watchdog-tests/__init__.py +0 -0
  219. package/.versions/0.0.10/hooks/SIMPLIFY-IGNORE.md +90 -0
  220. package/.versions/0.0.10/hooks/coms-stop-hook.mjs +84 -0
  221. package/.versions/0.0.10/hooks/hooks.json +14 -0
  222. package/.versions/0.0.10/hooks/session-start.sh +74 -0
  223. package/.versions/0.0.10/hooks/simplify-ignore.sh +302 -0
  224. package/.versions/0.0.10/install-manifest.json +3615 -0
  225. package/.versions/0.0.10/justfile +254 -0
  226. package/.versions/0.0.10/manifest-meta.json +472 -0
  227. package/.versions/0.0.10/references/accessibility-checklist.md +160 -0
  228. package/.versions/0.0.10/references/definition-of-done.md +67 -0
  229. package/.versions/0.0.10/references/fleet-coordination-patterns.md +151 -0
  230. package/.versions/0.0.10/references/observability-checklist.md +91 -0
  231. package/.versions/0.0.10/references/orchestration-patterns.md +370 -0
  232. package/.versions/0.0.10/references/performance-checklist.md +153 -0
  233. package/.versions/0.0.10/references/prompting-patterns.md +380 -0
  234. package/.versions/0.0.10/references/security-checklist.md +179 -0
  235. package/.versions/0.0.10/references/testing-patterns.md +236 -0
  236. package/.versions/0.0.10/scripts/codex-conductor.ts +41 -0
  237. package/.versions/0.0.10/scripts/codex-remote-control.ts +167 -0
  238. package/.versions/0.0.10/scripts/coms-claude-bridge.ts +401 -0
  239. package/.versions/0.0.10/scripts/coms-cli.ts +484 -0
  240. package/.versions/0.0.10/scripts/coms-hermes-bridge.ts +413 -0
  241. package/.versions/0.0.10/scripts/fleet.ts +168 -0
  242. package/.versions/0.0.10/scripts/hermes-monitor-capability-runner.ts +25 -0
  243. package/.versions/0.0.10/scripts/hermes-monitor-scenario.ts +474 -0
  244. package/.versions/0.0.10/scripts/hermes-watchdog-capability-probe.ts +45 -0
  245. package/.versions/0.0.10/scripts/install-hermes-plugin.sh +180 -0
  246. package/.versions/0.0.10/scripts/lib/claude-bridge-core.ts +165 -0
  247. package/.versions/0.0.10/scripts/lib/codex-conductor.ts +88 -0
  248. package/.versions/0.0.10/scripts/lib/codex-remote-control.ts +480 -0
  249. package/.versions/0.0.10/scripts/lib/coms-envelope.ts +582 -0
  250. package/.versions/0.0.10/scripts/lib/fake-herdr-server.ts +88 -0
  251. package/.versions/0.0.10/scripts/lib/fleet-command.ts +111 -0
  252. package/.versions/0.0.10/scripts/lib/herdr-layout.ts +281 -0
  253. package/.versions/0.0.10/scripts/lib/hermes-bridge-core.ts +241 -0
  254. package/.versions/0.0.10/scripts/lib/hermes-monitor-events.ts +1 -0
  255. package/.versions/0.0.10/scripts/lib/hermes-monitor-herdr.ts +2 -0
  256. package/.versions/0.0.10/scripts/lib/hermes-monitor-model.ts +3 -0
  257. package/.versions/0.0.10/scripts/lib/hermes-monitor-registry.ts +2 -0
  258. package/.versions/0.0.10/scripts/lib/hermes-monitor-socket.ts +2 -0
  259. package/.versions/0.0.10/scripts/lib/hermes-monitor-store.ts +2 -0
  260. package/.versions/0.0.10/scripts/lib/monitor-env.ts +120 -0
  261. package/.versions/0.0.10/scripts/lib/peer-launch.ts +314 -0
  262. package/.versions/0.0.10/scripts/lib/persona-banner.ts +62 -0
  263. package/.versions/0.0.10/scripts/lib/spawn-stagger.ts +101 -0
  264. package/.versions/0.0.10/scripts/lib/team-project.ts +193 -0
  265. package/.versions/0.0.10/scripts/lib/team-snapshot.ts +147 -0
  266. package/.versions/0.0.10/scripts/peer-banner.ts +40 -0
  267. package/.versions/0.0.10/scripts/peer-launch.ts +259 -0
  268. package/.versions/0.0.10/scripts/team-snapshot.ts +237 -0
  269. package/.versions/0.0.10/scripts/team-up.ts +360 -0
  270. package/.versions/0.0.10/skills/_internal/grilling.md +11 -0
  271. package/.versions/0.0.10/skills/browser-testing-with-devtools/SKILL.md +351 -0
  272. package/.versions/0.0.10/skills/code-review-and-quality/SKILL.md +381 -0
  273. package/.versions/0.0.10/skills/compound-learning/SKILL.md +137 -0
  274. package/.versions/0.0.10/skills/context-engineering/SKILL.md +291 -0
  275. package/.versions/0.0.10/skills/deprecation-and-migration/SKILL.md +206 -0
  276. package/.versions/0.0.10/skills/designing-agents/SKILL.md +394 -0
  277. package/.versions/0.0.10/skills/designing-agents/pi-harness-authoring.md +222 -0
  278. package/.versions/0.0.10/skills/frontend-ui-engineering/SKILL.md +328 -0
  279. package/.versions/0.0.10/skills/git-workflow-and-versioning/SKILL.md +316 -0
  280. package/.versions/0.0.10/skills/guided-workspace-setup/SKILL.md +226 -0
  281. package/.versions/0.0.10/skills/guided-workspace-setup/companion-manifest.json +38 -0
  282. package/.versions/0.0.10/skills/idea-refine/SKILL.md +182 -0
  283. package/.versions/0.0.10/skills/idea-refine/examples.md +238 -0
  284. package/.versions/0.0.10/skills/idea-refine/frameworks.md +99 -0
  285. package/.versions/0.0.10/skills/idea-refine/refinement-criteria.md +113 -0
  286. package/.versions/0.0.10/skills/idea-refine/scripts/idea-refine.sh +15 -0
  287. package/.versions/0.0.10/skills/incremental-implementation/SKILL.md +287 -0
  288. package/.versions/0.0.10/skills/interview-me/SKILL.md +226 -0
  289. package/.versions/0.0.10/skills/orchestration-verification/SKILL.md +181 -0
  290. package/.versions/0.0.10/skills/peer-coms/SKILL.md +90 -0
  291. package/.versions/0.0.10/skills/performance-optimization/SKILL.md +350 -0
  292. package/.versions/0.0.10/skills/planning-and-task-breakdown/SKILL.md +254 -0
  293. package/.versions/0.0.10/skills/security-and-hardening/SKILL.md +461 -0
  294. package/.versions/0.0.10/skills/spec-driven-development/SKILL.md +257 -0
  295. package/.versions/0.0.10/skills/using-agent-skills/SKILL.md +199 -0
  296. package/.versions/0.0.10/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  297. package/.versions/0.0.10/vendor/agent-skills-upstream/LICENSE +21 -0
  298. package/.versions/0.0.10/vendor/agent-skills-upstream/README.md +11 -0
  299. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  300. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  301. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  302. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  303. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  304. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  305. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  306. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  307. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  308. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  309. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  310. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  311. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  312. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  313. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  314. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  315. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  316. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  317. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  318. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  319. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  320. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  321. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  322. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  323. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  324. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  325. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  326. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  327. package/CHANGELOG.md +103 -0
  328. package/README.md +22 -5
  329. package/agents/code-reviewer.md +4 -0
  330. package/agents/orchestrator.md +7 -1
  331. package/agents/plan-reviewer.md +22 -1
  332. package/bin/build-manifest.js +68 -0
  333. package/bin/cli.js +679 -49
  334. package/bin/lib/apply.js +641 -0
  335. package/bin/lib/manifest.js +731 -0
  336. package/bin/lib/merge-forms.js +106 -0
  337. package/bin/lib/plan.js +569 -0
  338. package/bin/lib/state.js +213 -0
  339. package/bin/lib/verify.js +576 -0
  340. package/bin/snapshot-version.js +5 -0
  341. package/docs/ARCHITECTURE.md +52 -11
  342. package/docs/agent-fleet-setup.md +59 -48
  343. package/docs/getting-started.md +29 -6
  344. package/docs/npm-install.md +208 -31
  345. package/docs/opencode-setup.md +32 -0
  346. package/docs/pi-extensions.md +17 -10
  347. package/docs/pi-setup.md +164 -69
  348. package/install-manifest.json +3615 -0
  349. package/manifest-meta.json +472 -0
  350. package/package.json +8 -3
  351. package/skills/browser-testing-with-devtools/SKILL.md +3 -4
  352. package/skills/guided-workspace-setup/SKILL.md +172 -490
  353. package/skills/planning-and-task-breakdown/SKILL.md +18 -0
  354. package/skills/spec-driven-development/SKILL.md +12 -0
@@ -0,0 +1,731 @@
1
+ // manifest.js — build, load, and validate the install manifest.
2
+ //
3
+ // The manifest is the deterministic installer's catalogue: what can be
4
+ // installed, for which agent, from where, to where, with which strategy.
5
+ // See plans/deterministic-installer-manifest-spec.md for the normative schema.
6
+ //
7
+ // It is GENERATED from the repository tree, never hand-written. Everything
8
+ // mechanical (which skills exist, which agent has a source for a command) is
9
+ // derived by walking the source root; only curated judgement (grouping,
10
+ // recommendations, consent class, companions) lives in `manifest-meta.json`.
11
+ // A hand-maintained parallel list is exactly how a catalogue rots — the
12
+ // generator plus `build-manifest.js --check` makes drift a CI failure.
13
+ //
14
+ // Determinism is a hard requirement: same tree + same meta → byte-identical
15
+ // JSON. That is why there is no `generatedAt` timestamp in the output.
16
+
17
+ import { readdirSync, existsSync, readFileSync } from "node:fs";
18
+ import { join } from "node:path";
19
+
20
+ import { listPersonas, targetRelPath } from "./transform-persona.js";
21
+
22
+ export const MANIFEST_SCHEMA_VERSION = 1;
23
+
24
+ // Fixed order everywhere the manifest emits per-agent data, so output is stable.
25
+ export const MANIFEST_AGENTS = ["claude-code", "opencode", "pi"];
26
+
27
+ export const MANIFEST_FILE = "install-manifest.json";
28
+ export const MANIFEST_META_FILE = "manifest-meta.json";
29
+
30
+ const STRATEGIES = [
31
+ "copy-file",
32
+ "copy-tree",
33
+ "transform-persona",
34
+ "managed-region",
35
+ "json-merge",
36
+ "exec",
37
+ "external",
38
+ "operator",
39
+ ];
40
+ const CONSENT = ["file", "exec", "external", "operator"];
41
+ const PLATFORMS = ["any", "linux", "darwin"];
42
+ const ID_RE = /^[a-z][a-z-]*:[a-z0-9][a-z0-9._-]*$/;
43
+
44
+ // Skill catalogue roots, in resolution order. The fleet-native tree shadows the
45
+ // vendored upstream import (docs/UPSTREAM-SKILLS.md) — same rule the doctor's
46
+ // findReplacement() already applies.
47
+ const SKILL_ROOTS = ["skills", join("vendor", "agent-skills-upstream", "skills")];
48
+
49
+ const SKILL_TARGET_DIR = {
50
+ "claude-code": ".claude/skills",
51
+ "opencode": ".opencode/skills",
52
+ "pi": ".pi/skills",
53
+ };
54
+
55
+ const COMMAND_SOURCE = {
56
+ "claude-code": { dir: ".claude/commands", prefix: "" },
57
+ "opencode": { dir: ".opencode/commands", prefix: "af-" },
58
+ "pi": { dir: ".pi/prompts", prefix: "af-" },
59
+ };
60
+
61
+ // ── build ───────────────────────────────────────────────────────────────────
62
+
63
+ /**
64
+ * Build the manifest from a source tree.
65
+ *
66
+ * @param {object} opts
67
+ * @param {string} opts.sourceRoot agent-fleet package root (absolute)
68
+ * @param {string} opts.packageVersion version stamped into the manifest
69
+ * @param {object} [opts.meta] parsed manifest-meta.json (default: read from sourceRoot)
70
+ * @returns {object} manifest
71
+ */
72
+ export function buildManifest({ sourceRoot, packageVersion, meta = null }) {
73
+ const m = meta ?? loadMeta(sourceRoot);
74
+ const items = [
75
+ ...deriveSkills(sourceRoot, m),
76
+ ...derivePersonas(sourceRoot, m),
77
+ ...deriveCommands(sourceRoot, m),
78
+ ...deriveReferences(sourceRoot, m),
79
+ ...deriveHooks(sourceRoot, m),
80
+ ...derivePiTrees(sourceRoot, m),
81
+ ...deriveOperatorItems(sourceRoot, m),
82
+ ...deriveCompanions(sourceRoot, m),
83
+ ...deriveExternals(m),
84
+ ];
85
+
86
+ // Companion back-references: an item lists its companions, and each companion
87
+ // records its parents so removal can tell whether anyone still needs it.
88
+ const byId = new Map(items.map((i) => [i.id, i]));
89
+ for (const item of items) {
90
+ for (const cid of item.companions ?? []) {
91
+ const c = byId.get(cid);
92
+ if (c) (c.parents ??= []).push(item.id);
93
+ }
94
+ }
95
+ for (const item of items) if (item.parents) item.parents = uniqSorted(item.parents);
96
+
97
+ return orderedManifest({
98
+ schemaVersion: MANIFEST_SCHEMA_VERSION,
99
+ packageVersion,
100
+ groups: m.groups,
101
+ profiles: m.profiles,
102
+ items: items.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)),
103
+ });
104
+ }
105
+
106
+ /** Deterministic serialization — the byte form `--check` compares against. */
107
+ export function serializeManifest(manifest) {
108
+ return JSON.stringify(manifest, null, 2) + "\n";
109
+ }
110
+
111
+ export function loadMeta(sourceRoot) {
112
+ return JSON.parse(readFileSync(join(sourceRoot, MANIFEST_META_FILE), "utf8"));
113
+ }
114
+
115
+ export function loadManifest(sourceRoot) {
116
+ const path = join(sourceRoot, MANIFEST_FILE);
117
+ if (!existsSync(path)) {
118
+ throw new Error(
119
+ `${MANIFEST_FILE} is missing from ${sourceRoot} — run \`node bin/build-manifest.js\``,
120
+ );
121
+ }
122
+ return JSON.parse(readFileSync(path, "utf8"));
123
+ }
124
+
125
+ // ── derivation ──────────────────────────────────────────────────────────────
126
+
127
+ function deriveSkills(sourceRoot, meta) {
128
+ const excluded = new Set(meta.exclude?.skills ?? []);
129
+ const names = new Set();
130
+ for (const root of SKILL_ROOTS) {
131
+ for (const name of dirsIn(join(sourceRoot, root))) {
132
+ if (excluded.has(name)) continue;
133
+ if (!existsSync(join(sourceRoot, root, name, "SKILL.md"))) continue;
134
+ names.add(name);
135
+ }
136
+ }
137
+
138
+ return [...names].sort().map((name) => {
139
+ const sources = SKILL_ROOTS
140
+ .map((root) => `${root}/${name}`)
141
+ .filter((rel) => existsSync(join(sourceRoot, rel)));
142
+ const agents = {};
143
+ for (const agent of MANIFEST_AGENTS) {
144
+ agents[agent] = {
145
+ source: sources,
146
+ target: `${SKILL_TARGET_DIR[agent]}/${name}`,
147
+ strategy: "copy-tree",
148
+ };
149
+ }
150
+ return makeItem(meta, {
151
+ id: `skill:${name}`,
152
+ kind: "skill",
153
+ group: "skills",
154
+ title: name,
155
+ summary: frontmatterDescription(join(sourceRoot, sources[0], "SKILL.md")),
156
+ agents,
157
+ });
158
+ });
159
+ }
160
+
161
+ function derivePersonas(sourceRoot, meta) {
162
+ const excluded = new Set(meta.exclude?.personas ?? []);
163
+ const perAgent = new Map(
164
+ MANIFEST_AGENTS.map((agent) => [
165
+ agent,
166
+ new Map(listPersonas(sourceRoot, { agent }).map((p) => [p.name, p])),
167
+ ]),
168
+ );
169
+
170
+ const names = uniqSorted(
171
+ [...perAgent.get("pi").keys()].filter((n) => !excluded.has(n)),
172
+ );
173
+
174
+ return names.map((name) => {
175
+ const agents = {};
176
+ for (const agent of MANIFEST_AGENTS) {
177
+ if (!perAgent.get(agent).has(name)) continue; // pi-only persona
178
+ agents[agent] = {
179
+ source: [`agents/${name}.md`],
180
+ target: targetRelPath(agent, name).split("\\").join("/"),
181
+ strategy: agent === "pi" ? "copy-file" : "transform-persona",
182
+ };
183
+ }
184
+ return makeItem(meta, {
185
+ id: `persona:${name}`,
186
+ kind: "persona",
187
+ group: "personas",
188
+ title: name,
189
+ summary: frontmatterDescription(join(sourceRoot, "agents", `${name}.md`)),
190
+ agents,
191
+ });
192
+ });
193
+ }
194
+
195
+ function deriveCommands(sourceRoot, meta) {
196
+ const excluded = new Set(meta.exclude?.commands ?? []);
197
+ const names = new Set();
198
+ for (const { dir, prefix } of Object.values(COMMAND_SOURCE)) {
199
+ for (const file of filesIn(join(sourceRoot, dir))) {
200
+ if (!file.endsWith(".md")) continue;
201
+ const base = file.slice(0, -3);
202
+ if (prefix && !base.startsWith(prefix)) continue;
203
+ const name = prefix ? base.slice(prefix.length) : base;
204
+ if (!excluded.has(name)) names.add(name);
205
+ }
206
+ }
207
+
208
+ return [...names].sort().map((name) => {
209
+ const agents = {};
210
+ for (const agent of MANIFEST_AGENTS) {
211
+ const { dir, prefix } = COMMAND_SOURCE[agent];
212
+ const rel = `${dir}/${prefix}${name}.md`;
213
+ // Source-availability filter: an agent without its own file does not get
214
+ // the row. Never substitute another runtime's file (see SKILL.md step 6).
215
+ if (!existsSync(join(sourceRoot, rel))) continue;
216
+ agents[agent] = {
217
+ source: [rel],
218
+ target: rel,
219
+ strategy: "copy-file",
220
+ // pi and opencode commands used to install unprefixed. A workspace set
221
+ // up before the `af-` namespace still has the old file, and pi will
222
+ // happily keep offering `/spec` from it. Declaring the old path lets
223
+ // apply() retire it under the same ownership rule as anything else.
224
+ ...(prefix ? { legacyTargets: [`${dir}/${name}.md`] } : {}),
225
+ };
226
+ }
227
+ const first = MANIFEST_AGENTS.find((a) => agents[a]);
228
+ return makeItem(meta, {
229
+ id: `command:${name}`,
230
+ kind: "command",
231
+ group: "commands",
232
+ title: name,
233
+ summary: first
234
+ ? frontmatterDescription(join(sourceRoot, agents[first].source[0]))
235
+ : "",
236
+ agents,
237
+ });
238
+ });
239
+ }
240
+
241
+ function deriveReferences(sourceRoot, meta) {
242
+ const excluded = new Set(meta.exclude?.references ?? []);
243
+ return filesIn(join(sourceRoot, "references"))
244
+ .filter((f) => f.endsWith(".md") && !excluded.has(f))
245
+ .sort()
246
+ .map((file) => {
247
+ const name = file.slice(0, -3);
248
+ // claude-code only: neither docs/pi-setup.md nor docs/opencode-setup.md
249
+ // defines a reference install path, and inventing one is worse than not
250
+ // offering the row (SKILL.md step 3: ask rather than guess).
251
+ return makeItem(meta, {
252
+ id: `reference:${name}`,
253
+ kind: "reference",
254
+ group: "references-hooks",
255
+ title: name,
256
+ summary: "",
257
+ agents: {
258
+ "claude-code": {
259
+ source: [`references/${file}`],
260
+ target: `.claude/references/${file}`,
261
+ strategy: "copy-file",
262
+ },
263
+ },
264
+ });
265
+ });
266
+ }
267
+
268
+ function deriveHooks(sourceRoot, meta) {
269
+ const excluded = new Set(meta.exclude?.hooks ?? []);
270
+ return filesIn(join(sourceRoot, "hooks"))
271
+ .filter((f) => (f.endsWith(".sh") || f.endsWith(".mjs")) && !excluded.has(f))
272
+ .sort()
273
+ .map((file) => {
274
+ const name = file.replace(/\.(sh|mjs)$/, "");
275
+ // Hooks register into .claude/settings.json; no hook install path is
276
+ // defined for opencode or pi.
277
+ return makeItem(meta, {
278
+ id: `hook:${name}`,
279
+ kind: "hook",
280
+ group: "references-hooks",
281
+ title: name,
282
+ summary: "",
283
+ agents: {
284
+ "claude-code": {
285
+ source: [`hooks/${file}`],
286
+ target: `.claude/hooks/${file}`,
287
+ strategy: "copy-file",
288
+ },
289
+ },
290
+ });
291
+ });
292
+ }
293
+
294
+ // pi extensions, harnesses, and runtime skills — same shape, pi only.
295
+ function derivePiTrees(sourceRoot, meta) {
296
+ const specs = [
297
+ { dir: ".pi/extensions", kind: "pi-extension", group: "pi-extensions", exclude: meta.exclude?.piExtensions },
298
+ { dir: ".pi/harnesses", kind: "pi-harness", group: "pi-harnesses", exclude: meta.exclude?.piHarnesses },
299
+ { dir: ".pi/skills", kind: "pi-runtime-skill", group: "pi-extensions", exclude: meta.exclude?.piRuntimeSkills },
300
+ ];
301
+ const out = [];
302
+ for (const spec of specs) {
303
+ const excluded = new Set(["node_modules", ...(spec.exclude ?? [])]);
304
+ for (const name of dirsIn(join(sourceRoot, spec.dir))) {
305
+ if (excluded.has(name)) continue;
306
+ out.push(makeItem(meta, {
307
+ id: `${spec.kind}:${name}`,
308
+ kind: spec.kind,
309
+ group: spec.group,
310
+ title: name,
311
+ summary: "",
312
+ agents: {
313
+ pi: {
314
+ source: [`${spec.dir}/${name}`],
315
+ target: `${spec.dir}/${name}`,
316
+ strategy: "copy-tree",
317
+ },
318
+ },
319
+ }));
320
+ }
321
+ }
322
+ return out;
323
+ }
324
+
325
+ // Hermes plugins/skills and the Codex bridge install outside the workspace (a
326
+ // Hermes profile, a user systemd unit). They are catalogued so a plan can name
327
+ // them, but carry `consent: "operator"` and no workspace target — the engine
328
+ // prints next steps and performs nothing. Phase 6 gives them real handling.
329
+ function deriveOperatorItems(sourceRoot, meta) {
330
+ const out = [];
331
+
332
+ const pluginIds = new Set([
333
+ ...dirsIn(join(sourceRoot, "hermes", "plugins")),
334
+ ...dirsIn(join(sourceRoot, "hermes", "desktop-plugins")),
335
+ ]);
336
+ for (const id of [...pluginIds].sort()) {
337
+ const source = ["hermes/plugins", "hermes/desktop-plugins"]
338
+ .map((root) => `${root}/${id}`)
339
+ .filter((rel) => existsSync(join(sourceRoot, rel)));
340
+ out.push(makeItem(meta, {
341
+ id: `hermes-plugin:${id}`,
342
+ kind: "hermes-plugin",
343
+ group: "hermes",
344
+ title: id,
345
+ summary: "",
346
+ consent: "operator",
347
+ agents: { pi: { source, target: null, targetScope: "hermes-profile", strategy: "operator" } },
348
+ }));
349
+ }
350
+
351
+ for (const name of dirsIn(join(sourceRoot, "hermes", "skills")).sort()) {
352
+ out.push(makeItem(meta, {
353
+ id: `hermes-skill:${name}`,
354
+ kind: "hermes-skill",
355
+ group: "hermes",
356
+ title: name,
357
+ summary: frontmatterDescription(join(sourceRoot, "hermes", "skills", name, "SKILL.md")),
358
+ consent: "operator",
359
+ agents: {
360
+ pi: {
361
+ source: [`hermes/skills/${name}`],
362
+ target: null,
363
+ targetScope: "hermes-profile",
364
+ strategy: "operator",
365
+ },
366
+ },
367
+ }));
368
+ }
369
+
370
+ for (const file of filesIn(join(sourceRoot, "systemd", "user")).sort()) {
371
+ const name = file.replace(/\.(service|timer)?(\.in)?$/, "");
372
+ out.push(makeItem(meta, {
373
+ id: `codex:${name}`,
374
+ kind: "codex",
375
+ group: "codex-bridge",
376
+ title: name,
377
+ summary: "",
378
+ consent: "operator",
379
+ platform: "linux",
380
+ agents: {
381
+ pi: {
382
+ source: [`systemd/user/${file}`],
383
+ target: null,
384
+ targetScope: "user-systemd",
385
+ strategy: "operator",
386
+ },
387
+ },
388
+ }));
389
+ }
390
+
391
+ return out;
392
+ }
393
+
394
+ // Companions are applied with their parents and are never selectable rows.
395
+ // Most are hand-declared in meta; the pi-harness runtime closure is derived
396
+ // from the existing companion-manifest.json so the two cannot diverge.
397
+ function deriveCompanions(sourceRoot, meta) {
398
+ const out = [];
399
+
400
+ for (const [id, decl] of Object.entries(meta.companions ?? {})) {
401
+ out.push(makeItem(meta, {
402
+ id,
403
+ kind: "companion",
404
+ group: decl.group ?? "companions",
405
+ title: decl.title ?? id.split(":")[1],
406
+ summary: decl.summary ?? "",
407
+ consent: decl.consent ?? "file",
408
+ agents: decl.agents ?? {},
409
+ exec: decl.exec,
410
+ operatorSteps: decl.operatorSteps,
411
+ }));
412
+ }
413
+
414
+ const closurePath = join(
415
+ sourceRoot, "skills", "guided-workspace-setup", "companion-manifest.json",
416
+ );
417
+ if (existsSync(closurePath)) {
418
+ const closure = JSON.parse(readFileSync(closurePath, "utf8"));
419
+ // `justfile` is in the closure list but needs the managed-region strategy,
420
+ // not a whole-file copy — meta declares it as its own companion.
421
+ const files = (closure.files ?? []).filter((f) => f !== "justfile").sort();
422
+ const dirs = (closure.directories ?? []).slice().sort();
423
+ out.push(makeItem(meta, {
424
+ id: "companion:harness-runtime-closure",
425
+ kind: "companion",
426
+ group: "companions",
427
+ title: "harness-runtime-closure",
428
+ summary: "Runtime files the pi harness recipes shell out to",
429
+ agents: {
430
+ pi: {
431
+ source: [...dirs, ...files],
432
+ sourceMode: "all",
433
+ // Every entry keeps its repo-relative path in the workspace, so
434
+ // `scripts/lib/team-project.ts` lands where the recipes expect it.
435
+ target: null,
436
+ preserveLayout: true,
437
+ strategy: "copy-tree",
438
+ },
439
+ },
440
+ }));
441
+ }
442
+
443
+ return out;
444
+ }
445
+
446
+ function deriveExternals(meta) {
447
+ return Object.entries(meta.externalPackages ?? {}).map(([id, decl]) =>
448
+ makeItem(meta, {
449
+ id,
450
+ kind: "external-package",
451
+ group: decl.group ?? "external-packages",
452
+ title: decl.title ?? id.split(":")[1],
453
+ summary: decl.summary ?? "",
454
+ consent: "external",
455
+ agents: Object.fromEntries(
456
+ (decl.agents ?? ["pi"]).map((a) => [
457
+ a, { source: [], target: null, strategy: "external" },
458
+ ]),
459
+ ),
460
+ package: decl.package,
461
+ }),
462
+ );
463
+ }
464
+
465
+ // ── item assembly ───────────────────────────────────────────────────────────
466
+
467
+ function makeItem(meta, base) {
468
+ const overrides = meta.items?.[base.id] ?? {};
469
+ const item = {
470
+ id: base.id,
471
+ kind: base.kind,
472
+ group: overrides.group ?? base.group,
473
+ subcategory: overrides.subcategory ?? meta.subcategory?.[base.id] ?? null,
474
+ title: base.title,
475
+ summary: overrides.summary ?? base.summary ?? "",
476
+ recommended: (meta.recommended ?? []).includes(base.id),
477
+ consent: overrides.consent ?? base.consent ?? "file",
478
+ platform: overrides.platform ?? base.platform ?? "any",
479
+ agents: orderAgents(base.agents),
480
+ };
481
+ if (base.exec ?? overrides.exec) item.exec = base.exec ?? overrides.exec;
482
+ if (base.package) item.package = base.package;
483
+ // Operator items are the ones the engine refuses to perform. A row that only
484
+ // says "do this yourself" without saying what to do is worse than no row, so
485
+ // the steps are declared data and validateManifest insists on them.
486
+ const steps = overrides.operatorSteps ?? base.operatorSteps;
487
+ if (steps?.length) item.operatorSteps = [...steps];
488
+ if (overrides.retired) item.retired = overrides.retired;
489
+
490
+ for (const key of ["companions", "requires", "recommendsWith", "pinnedBy"]) {
491
+ const value = overrides[key];
492
+ if (value?.length) item[key] = uniqSorted(value);
493
+ }
494
+ return item;
495
+ }
496
+
497
+ function orderAgents(agents) {
498
+ const out = {};
499
+ for (const agent of MANIFEST_AGENTS) {
500
+ if (!agents?.[agent]) continue;
501
+ const a = agents[agent];
502
+ out[agent] = {
503
+ source: a.source ?? [],
504
+ // "first" (default): `source` is an ordered candidate list — the first
505
+ // existing path wins (this is how native skills shadow the vendored
506
+ // copy). "all": every source is installed, and `target` names the
507
+ // directory they land in (or, with preserveLayout, they keep their own
508
+ // repo-relative path).
509
+ sourceMode: a.sourceMode === "all" ? "all" : "first",
510
+ target: a.target ?? null,
511
+ strategy: a.strategy,
512
+ ...(a.targetScope ? { targetScope: a.targetScope } : {}),
513
+ ...(a.preserveLayout ? { preserveLayout: true } : {}),
514
+ ...(a.legacyTargets?.length ? { legacyTargets: [...a.legacyTargets].sort() } : {}),
515
+ };
516
+ }
517
+ return out;
518
+ }
519
+
520
+ function orderedManifest({ schemaVersion, packageVersion, groups, profiles, items }) {
521
+ return { schemaVersion, packageVersion, groups, profiles, items };
522
+ }
523
+
524
+ // ── validation ──────────────────────────────────────────────────────────────
525
+
526
+ /**
527
+ * Validate a manifest. Returns an array of human-readable problems; empty
528
+ * means valid. `sourceRoot` enables the source-existence checks.
529
+ *
530
+ * @param {object} manifest
531
+ * @param {object} [opts]
532
+ * @param {string} [opts.sourceRoot]
533
+ * @returns {string[]}
534
+ */
535
+ export function validateManifest(manifest, { sourceRoot = null } = {}) {
536
+ const problems = [];
537
+
538
+ if (manifest.schemaVersion !== MANIFEST_SCHEMA_VERSION) {
539
+ problems.push(
540
+ `schemaVersion is ${manifest.schemaVersion}, expected ${MANIFEST_SCHEMA_VERSION}`,
541
+ );
542
+ }
543
+ if (!manifest.packageVersion) problems.push("packageVersion is missing");
544
+
545
+ const groupIds = new Set((manifest.groups ?? []).map((g) => g.id));
546
+ const seen = new Set();
547
+ const targets = new Map(); // `${agent}\0${target}` → item id
548
+
549
+ for (const item of manifest.items ?? []) {
550
+ const at = `item ${item.id}`;
551
+ if (!ID_RE.test(item.id ?? "")) problems.push(`${at}: id does not match ${ID_RE}`);
552
+ if (seen.has(item.id)) problems.push(`${at}: duplicate id`);
553
+ seen.add(item.id);
554
+
555
+ if (!groupIds.has(item.group)) problems.push(`${at}: unknown group "${item.group}"`);
556
+ if (!CONSENT.includes(item.consent)) problems.push(`${at}: unknown consent "${item.consent}"`);
557
+ if (!PLATFORMS.includes(item.platform)) problems.push(`${at}: unknown platform "${item.platform}"`);
558
+
559
+ const agents = Object.keys(item.agents ?? {});
560
+ if (agents.length === 0) problems.push(`${at}: has no agent bindings`);
561
+ for (const agent of agents) {
562
+ if (!MANIFEST_AGENTS.includes(agent)) {
563
+ problems.push(`${at}: unknown agent "${agent}"`);
564
+ continue;
565
+ }
566
+ const binding = item.agents[agent];
567
+ if (!STRATEGIES.includes(binding.strategy)) {
568
+ problems.push(`${at} (${agent}): unknown strategy "${binding.strategy}"`);
569
+ }
570
+ if (!["first", "all"].includes(binding.sourceMode)) {
571
+ problems.push(`${at} (${agent}): unknown sourceMode "${binding.sourceMode}"`);
572
+ }
573
+ if (binding.sourceMode === "all" && !binding.target && !binding.preserveLayout) {
574
+ problems.push(`${at} (${agent}): sourceMode "all" needs either a target directory or preserveLayout`);
575
+ }
576
+ if (binding.sourceMode === "first" && (binding.source ?? []).length > 0 && !binding.target
577
+ && !["exec", "operator", "external"].includes(binding.strategy)) {
578
+ problems.push(`${at} (${agent}): has sources but no target`);
579
+ }
580
+ if (sourceRoot) {
581
+ for (const rel of binding.source ?? []) {
582
+ if (!existsSync(join(sourceRoot, rel))) {
583
+ problems.push(`${at} (${agent}): source does not exist — ${rel}`);
584
+ }
585
+ }
586
+ }
587
+ // Two items writing the same path for the same agent is a silent
588
+ // clobber waiting to happen; catch it at build time instead.
589
+ if (binding.target && binding.target !== ".") {
590
+ const key = `${agent}\0${binding.target}`;
591
+ if (targets.has(key)) {
592
+ problems.push(`${at} (${agent}): target collides with ${targets.get(key)} — ${binding.target}`);
593
+ } else {
594
+ targets.set(key, item.id);
595
+ }
596
+ }
597
+ if (item.consent === "operator" && binding.target) {
598
+ problems.push(`${at} (${agent}): operator-consent items must not declare a workspace target`);
599
+ }
600
+ }
601
+
602
+ if (item.consent === "exec" && !item.exec) problems.push(`${at}: consent "exec" without an exec block`);
603
+ if (item.exec && item.consent !== "exec") problems.push(`${at}: exec block requires consent "exec"`);
604
+ if (item.consent === "operator" && !(item.operatorSteps ?? []).length) {
605
+ problems.push(`${at}: consent "operator" without operatorSteps — an unactionable row`);
606
+ }
607
+ if (item.operatorSteps && item.consent !== "operator") {
608
+ problems.push(`${at}: operatorSteps requires consent "operator"`);
609
+ }
610
+
611
+ for (const key of ["companions", "requires", "pinnedBy", "parents"]) {
612
+ for (const ref of item[key] ?? []) {
613
+ if (!(manifest.items ?? []).some((i) => i.id === ref)) {
614
+ problems.push(`${at}: ${key} references unknown item "${ref}"`);
615
+ }
616
+ }
617
+ }
618
+ }
619
+
620
+ for (const [name, profile] of Object.entries(manifest.profiles ?? {})) {
621
+ if (profile.rule && profile.items) {
622
+ problems.push(`profile ${name}: declares both "rule" and "items"`);
623
+ }
624
+ if (!profile.rule && !profile.items) {
625
+ problems.push(`profile ${name}: declares neither "rule" nor "items"`);
626
+ }
627
+ if (profile.rule && !["recommended", "all"].includes(profile.rule)) {
628
+ problems.push(`profile ${name}: unknown rule "${profile.rule}"`);
629
+ }
630
+ for (const id of profile.items ?? []) {
631
+ if (!seen.has(id)) problems.push(`profile ${name}: unknown item "${id}"`);
632
+ }
633
+ }
634
+
635
+ return problems;
636
+ }
637
+
638
+ // ── queries ─────────────────────────────────────────────────────────────────
639
+
640
+ /** Items installable for one agent, with that agent's binding resolved. */
641
+ export function itemsForAgent(manifest, agent) {
642
+ return (manifest.items ?? [])
643
+ .filter((i) => i.agents?.[agent])
644
+ .map((i) => ({ ...i, binding: i.agents[agent] }));
645
+ }
646
+
647
+ /**
648
+ * Turn profiles and/or explicit item ids into the selected id set, applying
649
+ * the `requires` and `companions` closures. Selection never implies removal.
650
+ *
651
+ * @returns {{ selected: string[], unknown: string[] }}
652
+ */
653
+ export function resolveSelection(manifest, agent, { profiles = [], items = [] } = {}) {
654
+ const available = new Map(itemsForAgent(manifest, agent).map((i) => [i.id, i]));
655
+ const selected = new Set();
656
+ const unknown = [];
657
+
658
+ for (const name of profiles) {
659
+ const profile = manifest.profiles?.[name];
660
+ if (!profile) { unknown.push(`profile:${name}`); continue; }
661
+ if (profile.rule === "all") {
662
+ for (const [id, item] of available) if (item.kind !== "companion") selected.add(id);
663
+ } else if (profile.rule === "recommended") {
664
+ for (const [id, item] of available) if (item.recommended) selected.add(id);
665
+ }
666
+ for (const id of profile.items ?? []) {
667
+ if (available.has(id)) selected.add(id);
668
+ else unknown.push(id);
669
+ }
670
+ }
671
+ for (const id of items) {
672
+ if (available.has(id)) selected.add(id);
673
+ else unknown.push(id);
674
+ }
675
+
676
+ // Closure: requires are hard, companions travel with their parent.
677
+ let changed = true;
678
+ while (changed) {
679
+ changed = false;
680
+ for (const id of [...selected]) {
681
+ for (const ref of [...(available.get(id)?.requires ?? []), ...(available.get(id)?.companions ?? [])]) {
682
+ if (available.has(ref) && !selected.has(ref)) { selected.add(ref); changed = true; }
683
+ }
684
+ }
685
+ }
686
+
687
+ return { selected: [...selected].sort(), unknown: uniqSorted(unknown) };
688
+ }
689
+
690
+ // ── helpers ─────────────────────────────────────────────────────────────────
691
+
692
+ function dirsIn(dir) {
693
+ if (!existsSync(dir)) return [];
694
+ try {
695
+ return readdirSync(dir, { withFileTypes: true })
696
+ .filter((e) => e.isDirectory() || e.isSymbolicLink())
697
+ .map((e) => e.name)
698
+ .sort();
699
+ } catch { return []; }
700
+ }
701
+
702
+ function filesIn(dir) {
703
+ if (!existsSync(dir)) return [];
704
+ try {
705
+ return readdirSync(dir, { withFileTypes: true })
706
+ .filter((e) => e.isFile())
707
+ .map((e) => e.name)
708
+ .sort();
709
+ } catch { return []; }
710
+ }
711
+
712
+ // Reads `description:` from YAML frontmatter. Single-line scalars only — the
713
+ // artifacts we read all use them, and a full YAML parse here would pull the
714
+ // whole `yaml` dependency into a path that must stay cheap.
715
+ function frontmatterDescription(path) {
716
+ if (!existsSync(path)) return "";
717
+ let text;
718
+ try { text = readFileSync(path, "utf8"); } catch { return ""; }
719
+ const fm = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
720
+ if (!fm) return "";
721
+ const line = fm[1].split(/\r?\n/).find((l) => /^description:\s*\S/.test(l));
722
+ if (!line) return "";
723
+ const value = line.replace(/^description:\s*/, "").trim().replace(/^["']|["']$/g, "");
724
+ // First sentence, capped — summaries are one-line labels in every front-end.
725
+ const first = value.split(/(?<=\.)\s+(?=[A-Z])/)[0] ?? value;
726
+ return first.length > 120 ? first.slice(0, 117).trimEnd() + "…" : first;
727
+ }
728
+
729
+ function uniqSorted(list) {
730
+ return [...new Set(list)].sort();
731
+ }