@ag-eco/agentplate-cli 0.13.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 (455) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -0
  3. package/agents/ap-co-creation.md +90 -0
  4. package/agents/builder.md +144 -0
  5. package/agents/coordinator.md +377 -0
  6. package/agents/lead.md +435 -0
  7. package/agents/merger.md +164 -0
  8. package/agents/monitor.md +214 -0
  9. package/agents/orchestrator.md +239 -0
  10. package/agents/reviewer.md +140 -0
  11. package/agents/scout.md +125 -0
  12. package/agents/supervisor.md +427 -0
  13. package/package.json +66 -0
  14. package/src/agents/capabilities.test.ts +85 -0
  15. package/src/agents/capabilities.ts +125 -0
  16. package/src/agents/checkpoint.test.ts +88 -0
  17. package/src/agents/checkpoint.ts +101 -0
  18. package/src/agents/copilot-hooks-deployer.test.ts +162 -0
  19. package/src/agents/copilot-hooks-deployer.ts +93 -0
  20. package/src/agents/guard-rules.test.ts +372 -0
  21. package/src/agents/guard-rules.ts +97 -0
  22. package/src/agents/headless-mail-injector.test.ts +709 -0
  23. package/src/agents/headless-mail-injector.ts +377 -0
  24. package/src/agents/headless-prompt.test.ts +102 -0
  25. package/src/agents/headless-prompt.ts +68 -0
  26. package/src/agents/hooks-deployer.test.ts +3119 -0
  27. package/src/agents/hooks-deployer.ts +804 -0
  28. package/src/agents/identity.test.ts +604 -0
  29. package/src/agents/identity.ts +384 -0
  30. package/src/agents/lifecycle.test.ts +196 -0
  31. package/src/agents/lifecycle.ts +183 -0
  32. package/src/agents/mail-poll-detect.test.ts +153 -0
  33. package/src/agents/mail-poll-detect.ts +73 -0
  34. package/src/agents/manifest.test.ts +1026 -0
  35. package/src/agents/manifest.ts +376 -0
  36. package/src/agents/overlay.test.ts +1058 -0
  37. package/src/agents/overlay.ts +490 -0
  38. package/src/agents/scope-detect.test.ts +190 -0
  39. package/src/agents/scope-detect.ts +146 -0
  40. package/src/agents/turn-lock.test.ts +181 -0
  41. package/src/agents/turn-lock.ts +235 -0
  42. package/src/agents/turn-runner-dispatch.test.ts +182 -0
  43. package/src/agents/turn-runner-dispatch.ts +105 -0
  44. package/src/agents/turn-runner.test.ts +2312 -0
  45. package/src/agents/turn-runner.ts +1383 -0
  46. package/src/beads/client.test.ts +217 -0
  47. package/src/beads/client.ts +230 -0
  48. package/src/beads/molecules.test.ts +338 -0
  49. package/src/beads/molecules.ts +198 -0
  50. package/src/commands/agents.test.ts +328 -0
  51. package/src/commands/agents.ts +299 -0
  52. package/src/commands/clean.test.ts +797 -0
  53. package/src/commands/clean.ts +791 -0
  54. package/src/commands/completions.test.ts +348 -0
  55. package/src/commands/completions.ts +981 -0
  56. package/src/commands/coordinator.test.ts +2975 -0
  57. package/src/commands/coordinator.ts +1841 -0
  58. package/src/commands/costs.test.ts +1183 -0
  59. package/src/commands/costs.ts +599 -0
  60. package/src/commands/dashboard.test.ts +954 -0
  61. package/src/commands/dashboard.ts +1212 -0
  62. package/src/commands/discover.test.ts +288 -0
  63. package/src/commands/discover.ts +202 -0
  64. package/src/commands/doctor.test.ts +303 -0
  65. package/src/commands/doctor.ts +311 -0
  66. package/src/commands/ecosystem.test.ts +226 -0
  67. package/src/commands/ecosystem.ts +248 -0
  68. package/src/commands/errors.test.ts +654 -0
  69. package/src/commands/errors.ts +197 -0
  70. package/src/commands/feed.test.ts +709 -0
  71. package/src/commands/feed.ts +260 -0
  72. package/src/commands/group.test.ts +475 -0
  73. package/src/commands/group.ts +546 -0
  74. package/src/commands/hooks.test.ts +458 -0
  75. package/src/commands/hooks.ts +263 -0
  76. package/src/commands/init.test.ts +1011 -0
  77. package/src/commands/init.ts +967 -0
  78. package/src/commands/inspect.test.ts +1239 -0
  79. package/src/commands/inspect.ts +648 -0
  80. package/src/commands/log.test.ts +1913 -0
  81. package/src/commands/log.ts +958 -0
  82. package/src/commands/logs.test.ts +801 -0
  83. package/src/commands/logs.ts +483 -0
  84. package/src/commands/mail.test.ts +1501 -0
  85. package/src/commands/mail.ts +848 -0
  86. package/src/commands/merge.test.ts +864 -0
  87. package/src/commands/merge.ts +381 -0
  88. package/src/commands/metrics.test.ts +458 -0
  89. package/src/commands/metrics.ts +129 -0
  90. package/src/commands/monitor.test.ts +191 -0
  91. package/src/commands/monitor.ts +409 -0
  92. package/src/commands/nudge.test.ts +579 -0
  93. package/src/commands/nudge.ts +646 -0
  94. package/src/commands/orchestrator.ts +42 -0
  95. package/src/commands/prime.test.ts +612 -0
  96. package/src/commands/prime.ts +359 -0
  97. package/src/commands/replay.test.ts +757 -0
  98. package/src/commands/replay.ts +231 -0
  99. package/src/commands/run.test.ts +469 -0
  100. package/src/commands/run.ts +353 -0
  101. package/src/commands/serve/agent-actions.test.ts +210 -0
  102. package/src/commands/serve/agent-actions.ts +192 -0
  103. package/src/commands/serve/build.test.ts +202 -0
  104. package/src/commands/serve/build.ts +206 -0
  105. package/src/commands/serve/coordinator-actions.test.ts +339 -0
  106. package/src/commands/serve/coordinator-actions.ts +410 -0
  107. package/src/commands/serve/dev.test.ts +168 -0
  108. package/src/commands/serve/dev.ts +117 -0
  109. package/src/commands/serve/mail-actions.test.ts +312 -0
  110. package/src/commands/serve/mail-actions.ts +167 -0
  111. package/src/commands/serve/rest.test.ts +1680 -0
  112. package/src/commands/serve/rest.ts +1130 -0
  113. package/src/commands/serve/static.ts +51 -0
  114. package/src/commands/serve/ws.test.ts +361 -0
  115. package/src/commands/serve/ws.ts +332 -0
  116. package/src/commands/serve.test.ts +459 -0
  117. package/src/commands/serve.ts +654 -0
  118. package/src/commands/sling.test.ts +1583 -0
  119. package/src/commands/sling.ts +1351 -0
  120. package/src/commands/spec.test.ts +179 -0
  121. package/src/commands/spec.ts +105 -0
  122. package/src/commands/status.test.ts +614 -0
  123. package/src/commands/status.ts +403 -0
  124. package/src/commands/stop.test.ts +964 -0
  125. package/src/commands/stop.ts +319 -0
  126. package/src/commands/supervisor.test.ts +185 -0
  127. package/src/commands/supervisor.ts +537 -0
  128. package/src/commands/trace.test.ts +762 -0
  129. package/src/commands/trace.ts +205 -0
  130. package/src/commands/update.test.ts +466 -0
  131. package/src/commands/update.ts +263 -0
  132. package/src/commands/upgrade.test.ts +48 -0
  133. package/src/commands/upgrade.ts +240 -0
  134. package/src/commands/watch.test.ts +257 -0
  135. package/src/commands/watch.ts +308 -0
  136. package/src/commands/worktree.test.ts +1297 -0
  137. package/src/commands/worktree.ts +451 -0
  138. package/src/config.test.ts +1535 -0
  139. package/src/config.ts +1064 -0
  140. package/src/doctor/agents.test.ts +523 -0
  141. package/src/doctor/agents.ts +399 -0
  142. package/src/doctor/config-check.test.ts +191 -0
  143. package/src/doctor/config-check.ts +183 -0
  144. package/src/doctor/consistency.test.ts +807 -0
  145. package/src/doctor/consistency.ts +347 -0
  146. package/src/doctor/databases.test.ts +350 -0
  147. package/src/doctor/databases.ts +243 -0
  148. package/src/doctor/dependencies.test.ts +296 -0
  149. package/src/doctor/dependencies.ts +272 -0
  150. package/src/doctor/ecosystem.test.ts +308 -0
  151. package/src/doctor/ecosystem.ts +156 -0
  152. package/src/doctor/logs.test.ts +253 -0
  153. package/src/doctor/logs.ts +295 -0
  154. package/src/doctor/merge-queue.test.ts +315 -0
  155. package/src/doctor/merge-queue.ts +167 -0
  156. package/src/doctor/providers.test.ts +409 -0
  157. package/src/doctor/providers.ts +250 -0
  158. package/src/doctor/serve.test.ts +95 -0
  159. package/src/doctor/serve.ts +86 -0
  160. package/src/doctor/structure.test.ts +423 -0
  161. package/src/doctor/structure.ts +285 -0
  162. package/src/doctor/types.ts +43 -0
  163. package/src/doctor/version.test.ts +241 -0
  164. package/src/doctor/version.ts +132 -0
  165. package/src/doctor/watchdog.test.ts +167 -0
  166. package/src/doctor/watchdog.ts +214 -0
  167. package/src/e2e/init-sling-lifecycle.test.ts +283 -0
  168. package/src/errors.test.ts +350 -0
  169. package/src/errors.ts +217 -0
  170. package/src/events/store.test.ts +660 -0
  171. package/src/events/store.ts +369 -0
  172. package/src/events/tailer.test.ts +719 -0
  173. package/src/events/tailer.ts +332 -0
  174. package/src/events/tool-filter.test.ts +330 -0
  175. package/src/events/tool-filter.ts +126 -0
  176. package/src/index.ts +533 -0
  177. package/src/insights/analyzer.test.ts +466 -0
  178. package/src/insights/analyzer.ts +203 -0
  179. package/src/insights/quality-gates.test.ts +141 -0
  180. package/src/insights/quality-gates.ts +156 -0
  181. package/src/json.test.ts +72 -0
  182. package/src/json.ts +53 -0
  183. package/src/loam/client.test.ts +752 -0
  184. package/src/loam/client.ts +664 -0
  185. package/src/logging/color.test.ts +252 -0
  186. package/src/logging/color.ts +105 -0
  187. package/src/logging/format.test.ts +110 -0
  188. package/src/logging/format.ts +255 -0
  189. package/src/logging/logger.test.ts +814 -0
  190. package/src/logging/logger.ts +266 -0
  191. package/src/logging/reporter.test.ts +259 -0
  192. package/src/logging/reporter.ts +110 -0
  193. package/src/logging/sanitizer.test.ts +190 -0
  194. package/src/logging/sanitizer.ts +57 -0
  195. package/src/logging/theme.ts +140 -0
  196. package/src/mail/broadcast.test.ts +204 -0
  197. package/src/mail/broadcast.ts +92 -0
  198. package/src/mail/client.test.ts +774 -0
  199. package/src/mail/client.ts +236 -0
  200. package/src/mail/store.test.ts +898 -0
  201. package/src/mail/store.ts +425 -0
  202. package/src/merge/lock.test.ts +149 -0
  203. package/src/merge/lock.ts +140 -0
  204. package/src/merge/predict.test.ts +387 -0
  205. package/src/merge/predict.ts +249 -0
  206. package/src/merge/queue.test.ts +426 -0
  207. package/src/merge/queue.ts +246 -0
  208. package/src/merge/resolver.test.ts +1993 -0
  209. package/src/merge/resolver.ts +926 -0
  210. package/src/metrics/pricing.test.ts +258 -0
  211. package/src/metrics/pricing.ts +135 -0
  212. package/src/metrics/store.test.ts +978 -0
  213. package/src/metrics/store.ts +501 -0
  214. package/src/metrics/summary.test.ts +398 -0
  215. package/src/metrics/summary.ts +178 -0
  216. package/src/metrics/transcript.test.ts +483 -0
  217. package/src/metrics/transcript.ts +114 -0
  218. package/src/runtimes/__fixtures__/claude-stream-fixture.ts +22 -0
  219. package/src/runtimes/aider.test.ts +124 -0
  220. package/src/runtimes/aider.ts +147 -0
  221. package/src/runtimes/amp.test.ts +164 -0
  222. package/src/runtimes/amp.ts +154 -0
  223. package/src/runtimes/claude.test.ts +1474 -0
  224. package/src/runtimes/claude.ts +579 -0
  225. package/src/runtimes/codex.test.ts +805 -0
  226. package/src/runtimes/codex.ts +273 -0
  227. package/src/runtimes/connections.test.ts +214 -0
  228. package/src/runtimes/connections.ts +103 -0
  229. package/src/runtimes/copilot.test.ts +707 -0
  230. package/src/runtimes/copilot.ts +316 -0
  231. package/src/runtimes/cursor.test.ts +497 -0
  232. package/src/runtimes/cursor.ts +205 -0
  233. package/src/runtimes/gemini.test.ts +537 -0
  234. package/src/runtimes/gemini.ts +243 -0
  235. package/src/runtimes/goose.test.ts +133 -0
  236. package/src/runtimes/goose.ts +157 -0
  237. package/src/runtimes/headless-connection.test.ts +264 -0
  238. package/src/runtimes/headless-connection.ts +158 -0
  239. package/src/runtimes/opencode.test.ts +325 -0
  240. package/src/runtimes/opencode.ts +188 -0
  241. package/src/runtimes/pi-guards.test.ts +486 -0
  242. package/src/runtimes/pi-guards.ts +367 -0
  243. package/src/runtimes/pi.test.ts +789 -0
  244. package/src/runtimes/pi.ts +305 -0
  245. package/src/runtimes/registry.test.ts +196 -0
  246. package/src/runtimes/registry.ts +99 -0
  247. package/src/runtimes/sapling.test.ts +1267 -0
  248. package/src/runtimes/sapling.ts +710 -0
  249. package/src/runtimes/types.ts +266 -0
  250. package/src/schema-consistency.test.ts +246 -0
  251. package/src/sessions/compat.test.ts +281 -0
  252. package/src/sessions/compat.ts +105 -0
  253. package/src/sessions/store.test.ts +1748 -0
  254. package/src/sessions/store.ts +858 -0
  255. package/src/test-helpers.test.ts +124 -0
  256. package/src/test-helpers.ts +145 -0
  257. package/src/test-setup.test.ts +31 -0
  258. package/src/test-setup.ts +28 -0
  259. package/src/tools/loam/api.ts +368 -0
  260. package/src/tools/loam/cli.ts +278 -0
  261. package/src/tools/loam/commands/add.ts +52 -0
  262. package/src/tools/loam/commands/archive.ts +214 -0
  263. package/src/tools/loam/commands/audit.ts +276 -0
  264. package/src/tools/loam/commands/compact.ts +1062 -0
  265. package/src/tools/loam/commands/completions.ts +79 -0
  266. package/src/tools/loam/commands/config.ts +381 -0
  267. package/src/tools/loam/commands/delete-domain.ts +121 -0
  268. package/src/tools/loam/commands/delete.ts +316 -0
  269. package/src/tools/loam/commands/diff.ts +200 -0
  270. package/src/tools/loam/commands/doctor.ts +1113 -0
  271. package/src/tools/loam/commands/edit.ts +226 -0
  272. package/src/tools/loam/commands/init.ts +31 -0
  273. package/src/tools/loam/commands/learn.ts +179 -0
  274. package/src/tools/loam/commands/move.ts +323 -0
  275. package/src/tools/loam/commands/onboard.ts +374 -0
  276. package/src/tools/loam/commands/outcome.ts +185 -0
  277. package/src/tools/loam/commands/prime.ts +688 -0
  278. package/src/tools/loam/commands/prune.ts +614 -0
  279. package/src/tools/loam/commands/query.ts +218 -0
  280. package/src/tools/loam/commands/rank.ts +180 -0
  281. package/src/tools/loam/commands/ready.ts +189 -0
  282. package/src/tools/loam/commands/record.ts +1210 -0
  283. package/src/tools/loam/commands/restore.ts +166 -0
  284. package/src/tools/loam/commands/search.ts +327 -0
  285. package/src/tools/loam/commands/setup.ts +887 -0
  286. package/src/tools/loam/commands/status.ts +103 -0
  287. package/src/tools/loam/commands/sync.ts +298 -0
  288. package/src/tools/loam/commands/update.ts +19 -0
  289. package/src/tools/loam/commands/upgrade.ts +93 -0
  290. package/src/tools/loam/commands/validate.ts +190 -0
  291. package/src/tools/loam/index.ts +62 -0
  292. package/src/tools/loam/log.ts +127 -0
  293. package/src/tools/loam/registry/builtins.ts +409 -0
  294. package/src/tools/loam/registry/custom.ts +431 -0
  295. package/src/tools/loam/registry/init.ts +55 -0
  296. package/src/tools/loam/registry/template.ts +40 -0
  297. package/src/tools/loam/registry/type-registry.ts +113 -0
  298. package/src/tools/loam/schemas/config-schema.ts +489 -0
  299. package/src/tools/loam/schemas/config.ts +245 -0
  300. package/src/tools/loam/schemas/index.ts +18 -0
  301. package/src/tools/loam/schemas/record-schema.ts +191 -0
  302. package/src/tools/loam/schemas/record.ts +115 -0
  303. package/src/tools/loam/utils/active-work.ts +205 -0
  304. package/src/tools/loam/utils/anchor-validity.ts +80 -0
  305. package/src/tools/loam/utils/archive.ts +146 -0
  306. package/src/tools/loam/utils/audit.ts +667 -0
  307. package/src/tools/loam/utils/bm25.ts +238 -0
  308. package/src/tools/loam/utils/budget.ts +142 -0
  309. package/src/tools/loam/utils/config.ts +344 -0
  310. package/src/tools/loam/utils/dir-anchors.ts +62 -0
  311. package/src/tools/loam/utils/domain-rules.ts +114 -0
  312. package/src/tools/loam/utils/expertise.ts +393 -0
  313. package/src/tools/loam/utils/format-helpers.ts +96 -0
  314. package/src/tools/loam/utils/format.ts +1234 -0
  315. package/src/tools/loam/utils/git-context.ts +50 -0
  316. package/src/tools/loam/utils/git.ts +183 -0
  317. package/src/tools/loam/utils/hooks.ts +299 -0
  318. package/src/tools/loam/utils/index.ts +52 -0
  319. package/src/tools/loam/utils/json-output.ts +13 -0
  320. package/src/tools/loam/utils/lock.ts +76 -0
  321. package/src/tools/loam/utils/markers.ts +48 -0
  322. package/src/tools/loam/utils/numeric-flags.ts +20 -0
  323. package/src/tools/loam/utils/palette.ts +44 -0
  324. package/src/tools/loam/utils/prime-ranking.ts +135 -0
  325. package/src/tools/loam/utils/recipe-discovery.ts +195 -0
  326. package/src/tools/loam/utils/runtime-flags.ts +28 -0
  327. package/src/tools/loam/utils/scoring.ts +94 -0
  328. package/src/tools/loam/utils/version.ts +116 -0
  329. package/src/tools/sprout/commands/block.ts +64 -0
  330. package/src/tools/sprout/commands/blocked.ts +86 -0
  331. package/src/tools/sprout/commands/close.ts +129 -0
  332. package/src/tools/sprout/commands/completions.ts +198 -0
  333. package/src/tools/sprout/commands/config.ts +238 -0
  334. package/src/tools/sprout/commands/create.ts +164 -0
  335. package/src/tools/sprout/commands/dep.ts +148 -0
  336. package/src/tools/sprout/commands/doctor.ts +979 -0
  337. package/src/tools/sprout/commands/init.ts +83 -0
  338. package/src/tools/sprout/commands/label.ts +178 -0
  339. package/src/tools/sprout/commands/list.ts +210 -0
  340. package/src/tools/sprout/commands/migrate.ts +133 -0
  341. package/src/tools/sprout/commands/onboard.ts +207 -0
  342. package/src/tools/sprout/commands/plan-show.ts +278 -0
  343. package/src/tools/sprout/commands/plan.ts +2526 -0
  344. package/src/tools/sprout/commands/prime.ts +399 -0
  345. package/src/tools/sprout/commands/ready.ts +245 -0
  346. package/src/tools/sprout/commands/search.ts +221 -0
  347. package/src/tools/sprout/commands/show.ts +277 -0
  348. package/src/tools/sprout/commands/stats.ts +146 -0
  349. package/src/tools/sprout/commands/sync.ts +134 -0
  350. package/src/tools/sprout/commands/tpl.ts +364 -0
  351. package/src/tools/sprout/commands/unblock.ts +115 -0
  352. package/src/tools/sprout/commands/update.ts +257 -0
  353. package/src/tools/sprout/commands/upgrade.ts +91 -0
  354. package/src/tools/sprout/config-schema.ts +152 -0
  355. package/src/tools/sprout/config.ts +355 -0
  356. package/src/tools/sprout/filter.ts +107 -0
  357. package/src/tools/sprout/format.ts +43 -0
  358. package/src/tools/sprout/id.ts +22 -0
  359. package/src/tools/sprout/index.ts +204 -0
  360. package/src/tools/sprout/log.ts +76 -0
  361. package/src/tools/sprout/markers.ts +22 -0
  362. package/src/tools/sprout/output.ts +121 -0
  363. package/src/tools/sprout/plan-backref.ts +93 -0
  364. package/src/tools/sprout/plan-context.ts +81 -0
  365. package/src/tools/sprout/plan-domain.ts +139 -0
  366. package/src/tools/sprout/plan-lifecycle.ts +65 -0
  367. package/src/tools/sprout/plan-loam.ts +207 -0
  368. package/src/tools/sprout/plan-schema.ts +209 -0
  369. package/src/tools/sprout/sort.ts +31 -0
  370. package/src/tools/sprout/store.ts +172 -0
  371. package/src/tools/sprout/types.ts +118 -0
  372. package/src/tools/sprout/validation.ts +119 -0
  373. package/src/tools/sprout/version.ts +1 -0
  374. package/src/tools/sprout/yaml.ts +387 -0
  375. package/src/tools/trellis/commands/archive.ts +87 -0
  376. package/src/tools/trellis/commands/completions.ts +610 -0
  377. package/src/tools/trellis/commands/config.ts +382 -0
  378. package/src/tools/trellis/commands/create.ts +252 -0
  379. package/src/tools/trellis/commands/diff.ts +150 -0
  380. package/src/tools/trellis/commands/doctor.ts +771 -0
  381. package/src/tools/trellis/commands/emit.ts +365 -0
  382. package/src/tools/trellis/commands/history.ts +83 -0
  383. package/src/tools/trellis/commands/import.ts +198 -0
  384. package/src/tools/trellis/commands/init.ts +81 -0
  385. package/src/tools/trellis/commands/list.ts +103 -0
  386. package/src/tools/trellis/commands/onboard.ts +156 -0
  387. package/src/tools/trellis/commands/pin.ts +172 -0
  388. package/src/tools/trellis/commands/prime.ts +193 -0
  389. package/src/tools/trellis/commands/render.ts +122 -0
  390. package/src/tools/trellis/commands/schema.ts +353 -0
  391. package/src/tools/trellis/commands/show.ts +115 -0
  392. package/src/tools/trellis/commands/stats.ts +65 -0
  393. package/src/tools/trellis/commands/sync.ts +112 -0
  394. package/src/tools/trellis/commands/tree.ts +123 -0
  395. package/src/tools/trellis/commands/update.ts +330 -0
  396. package/src/tools/trellis/commands/upgrade.ts +95 -0
  397. package/src/tools/trellis/commands/validate.ts +166 -0
  398. package/src/tools/trellis/config-schema.ts +81 -0
  399. package/src/tools/trellis/config.ts +108 -0
  400. package/src/tools/trellis/frontmatter.ts +348 -0
  401. package/src/tools/trellis/id.ts +24 -0
  402. package/src/tools/trellis/index.ts +209 -0
  403. package/src/tools/trellis/markers.ts +28 -0
  404. package/src/tools/trellis/output.ts +84 -0
  405. package/src/tools/trellis/render.ts +212 -0
  406. package/src/tools/trellis/store.ts +144 -0
  407. package/src/tools/trellis/types.ts +82 -0
  408. package/src/tools/trellis/validate.ts +199 -0
  409. package/src/tools/trellis/yaml.ts +309 -0
  410. package/src/tracker/beads.test.ts +454 -0
  411. package/src/tracker/beads.ts +56 -0
  412. package/src/tracker/factory.test.ts +90 -0
  413. package/src/tracker/factory.ts +65 -0
  414. package/src/tracker/sprout.test.ts +461 -0
  415. package/src/tracker/sprout.ts +182 -0
  416. package/src/tracker/types.ts +52 -0
  417. package/src/trellis/client.test.ts +107 -0
  418. package/src/trellis/client.ts +179 -0
  419. package/src/types.ts +970 -0
  420. package/src/utils/bin.test.ts +10 -0
  421. package/src/utils/bin.ts +37 -0
  422. package/src/utils/browser.test.ts +49 -0
  423. package/src/utils/browser.ts +48 -0
  424. package/src/utils/fs.test.ts +119 -0
  425. package/src/utils/fs.ts +62 -0
  426. package/src/utils/pid.test.ts +152 -0
  427. package/src/utils/pid.ts +130 -0
  428. package/src/utils/process-scan.test.ts +53 -0
  429. package/src/utils/process-scan.ts +76 -0
  430. package/src/utils/time.test.ts +43 -0
  431. package/src/utils/time.ts +37 -0
  432. package/src/utils/version.test.ts +33 -0
  433. package/src/utils/version.ts +70 -0
  434. package/src/version.ts +5 -0
  435. package/src/watchdog/daemon.test.ts +3721 -0
  436. package/src/watchdog/daemon.ts +1257 -0
  437. package/src/watchdog/health.test.ts +830 -0
  438. package/src/watchdog/health.ts +434 -0
  439. package/src/watchdog/triage.test.ts +205 -0
  440. package/src/watchdog/triage.ts +205 -0
  441. package/src/worktree/manager.test.ts +720 -0
  442. package/src/worktree/manager.ts +405 -0
  443. package/src/worktree/process.test.ts +172 -0
  444. package/src/worktree/process.ts +131 -0
  445. package/src/worktree/tmux.test.ts +1616 -0
  446. package/src/worktree/tmux.ts +721 -0
  447. package/templates/CLAUDE.md.tmpl +100 -0
  448. package/templates/copilot-hooks.json.tmpl +13 -0
  449. package/templates/hooks.json.tmpl +109 -0
  450. package/templates/overlay.md.tmpl +88 -0
  451. package/ui/dist/apple-touch-icon-bdy6teep.png +0 -0
  452. package/ui/dist/chunk-8s31f05k.css +1 -0
  453. package/ui/dist/chunk-vm5rz679.js +300 -0
  454. package/ui/dist/favicon-nzb39vza.svg +4 -0
  455. package/ui/dist/index.html +17 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jaymin West
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,462 @@
1
+ # Agentplate
2
+
3
+ Multi-agent orchestration for AI coding agents.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@ag-eco/agentplate-cli)](https://www.npmjs.com/package/@ag-eco/agentplate-cli)
6
+ [![CI](https://github.com/hgoudat/agentplate/actions/workflows/ci.yml/badge.svg)](https://github.com/hgoudat/agentplate/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+
9
+ Agentplate turns a single coding session into a multi-agent team by spawning worker agents in isolated git worktrees, coordinating them through a custom SQLite mail system, and merging their work back with tiered conflict resolution. New projects spawn Claude agents headless and surface them through a web UI (`ap serve`); `tmux attach` is the opt-in escape hatch for live steering. A pluggable `AgentRuntime` interface lets you swap between 11 runtimes — Claude Code, [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent), [Gemini CLI](https://github.com/google-gemini/gemini-cli), [Aider](https://aider.chat), [Goose](https://github.com/block/goose), [Amp](https://amp.dev), or your own adapter.
10
+
11
+ > **Warning: Agent swarms are not a universal solution.** Do not deploy Agentplate without understanding the risks of multi-agent orchestration — compounding error rates, cost amplification, debugging complexity, and merge conflicts are the normal case, not edge cases. Read [STEELMAN.md](STEELMAN.md) for a full risk analysis and the [Agentic Engineering Book](https://github.com/hgoudat/agentic-engineering-book) ([web version](https://hgoudat.com/agentic-engineering-book)) before using this tool in production.
12
+
13
+ ## Install
14
+
15
+ Requires [Bun](https://bun.sh) v1.0+ and git. `tmux` is optional — only needed if you want to spawn workers with `--no-headless` or attach to a coordinator/worker pane directly. At least one supported agent runtime must be installed:
16
+
17
+ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`claude` CLI)
18
+ - [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) (`pi` CLI)
19
+ - [GitHub Copilot](https://github.com/features/copilot) (`copilot` CLI)
20
+ - [Codex](https://github.com/openai/codex) (`codex` CLI)
21
+ - [Gemini CLI](https://github.com/google-gemini/gemini-cli) (`gemini` CLI)
22
+ - [Cursor CLI](https://cursor.com/docs/cli/overview) (`agent` CLI)
23
+ - [Sapling](https://github.com/hgoudat/sapling) (`sp` CLI)
24
+ - [OpenCode](https://opencode.ai) (`opencode` CLI)
25
+ - [Aider](https://aider.chat) (`aider` CLI)
26
+ - [Goose](https://github.com/block/goose) (`goose` CLI)
27
+ - [Amp](https://amp.dev) (`amp` CLI)
28
+
29
+ ```bash
30
+ bun install -g @ag-eco/agentplate-cli
31
+ ```
32
+
33
+ Or try without installing:
34
+
35
+ ```bash
36
+ npx @ag-eco/agentplate-cli --help
37
+ ```
38
+
39
+ ### Development
40
+
41
+ ```bash
42
+ git clone https://github.com/hgoudat/agentplate.git
43
+ cd agentplate
44
+ bun install
45
+ bun link # Makes 'ap' available globally
46
+
47
+ bun test # Run all tests
48
+ bun run lint # Biome check
49
+ bun run typecheck # tsc --noEmit
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ # Initialize agentplate in your project
56
+ cd your-project
57
+ ap init
58
+
59
+ # Install hooks into .claude/settings.local.json
60
+ ap hooks install
61
+
62
+ # Start a coordinator (persistent orchestrator)
63
+ ap coordinator start
64
+
65
+ # Open the web UI — primary operator surface for the swarm
66
+ ap serve # then open http://localhost:7321
67
+ ```
68
+
69
+ `ap serve` is where you watch the fleet, read the mail bus, and inspect
70
+ per-agent timelines. New projects spawn Claude workers headless by default,
71
+ so the UI sees them with full structured-event fidelity.
72
+
73
+ Other common commands:
74
+
75
+ ```bash
76
+ # Spawn an individual worker agent (coordinator usually does this for you)
77
+ ap sling <task-id> --capability builder --name my-builder
78
+
79
+ # Force a worker into tmux when you want to attach mid-session
80
+ ap sling <task-id> --capability builder --name my-builder --no-headless
81
+ tmux attach -t ap-my-builder
82
+
83
+ # Inspect state from the CLI (also visible in the UI)
84
+ ap status
85
+ ap dashboard # live TUI alternative to the web UI
86
+ ap mail check --inject
87
+ ap nudge <agent-name> # send a follow-up to a stalled agent
88
+ ```
89
+
90
+ ## Commands
91
+
92
+ Every command supports `--json` where noted. Global flags: `-q`/`--quiet`, `--timing`, `--project <path>`. ANSI colors respect `NO_COLOR`.
93
+
94
+ ### Core Workflow
95
+
96
+ | Command | Description |
97
+ |---------|-------------|
98
+ | `ap init` | Initialize `.agentplate/` and bootstrap ag-eco tools (`--yes`, `--name`, `--tools`, `--skip-loam`, `--skip-sprout`, `--skip-trellis`, `--skip-onboard`, `--json`) |
99
+ | `ap sling <task-id>` | Spawn a worker agent (`--capability`, `--name`, `--spec`, `--files`, `--parent`, `--depth`, `--skip-scout`, `--skip-review`, `--max-agents`, `--dispatch-max-agents`, `--skip-task-check`, `--no-scout-check`, `--runtime`, `--base-branch`, `--profile`, `--headless`, `--no-headless`, `--recover`, `--json`) |
100
+ | `ap stop <agent-name>` | Terminate a running agent (`--clean-worktree`, `--json`) |
101
+ | `ap prime` | Load context for orchestrator/agent (`--agent`, `--compact`) |
102
+ | `ap spec write <task-id>` | Write a task specification (`--body`) |
103
+ | `ap discover` | Discover a brownfield codebase via coordinator-driven scout swarm (`--skip`, `--name`, `--attach`, `--watchdog`, `--json`) |
104
+ | `ap update` | Refresh `.agentplate/` managed files from installed package (`--agents`, `--manifest`, `--hooks`, `--dry-run`, `--json`) |
105
+
106
+ ### Coordination
107
+
108
+ | Command | Description |
109
+ |---------|-------------|
110
+ | `ap coordinator start` | Start persistent coordinator agent (`--attach`/`--no-attach`, `--watchdog`, `--monitor`, `--profile`) |
111
+ | `ap coordinator stop` | Stop coordinator |
112
+ | `ap coordinator status` | Show coordinator state |
113
+ | `ap coordinator send` | Fire-and-forget message to coordinator (`--subject`) |
114
+ | `ap coordinator ask` | Synchronous request/response to coordinator (`--subject`, `--timeout`) |
115
+ | `ap coordinator output` | Show recent coordinator output (`--lines`) |
116
+ | `ap coordinator check-complete` | Evaluate exit triggers, return completion status |
117
+ | `ap orchestrator start` | Start multi-repo orchestrator agent (`--attach`/`--no-attach`, `--watchdog`, `--profile`) |
118
+ | `ap orchestrator stop` | Stop orchestrator |
119
+ | `ap orchestrator status` | Show orchestrator state |
120
+ | `ap orchestrator send` | Fire-and-forget message to orchestrator (`--subject`) |
121
+ | `ap orchestrator ask` | Synchronous request/response to orchestrator (`--subject`, `--timeout`) |
122
+ | `ap orchestrator output` | Show recent orchestrator output (`--lines`) |
123
+ | `ap supervisor start` | **[DEPRECATED]** Start per-project supervisor agent |
124
+ | `ap supervisor stop` | **[DEPRECATED]** Stop supervisor |
125
+ | `ap supervisor status` | **[DEPRECATED]** Show supervisor state |
126
+
127
+ ### Messaging
128
+
129
+ | Command | Description |
130
+ |---------|-------------|
131
+ | `ap mail send` | Send a message (`--to`, `--subject`, `--body`, `--type`, `--priority`) |
132
+ | `ap mail check` | Check inbox — unread messages (`--agent`, `--inject`, `--debounce`, `--json`) |
133
+ | `ap mail list` | List messages with filters (`--from`, `--to`, `--unread`) |
134
+ | `ap mail read <id>` | Mark message as read |
135
+ | `ap mail reply <id>` | Reply in same thread (`--body`) |
136
+ | `ap nudge <agent> [message]` | Send a text nudge to an agent (`--from`, `--force`, `--json`) |
137
+
138
+ ### Task Groups
139
+
140
+ | Command | Description |
141
+ |---------|-------------|
142
+ | `ap group create <name>` | Create a task group for batch tracking |
143
+ | `ap group status <name>` | Show group progress |
144
+ | `ap group add <name> <issue-id>` | Add issue to group |
145
+ | `ap group list` | List all groups |
146
+
147
+ ### Merge
148
+
149
+ | Command | Description |
150
+ |---------|-------------|
151
+ | `ap merge` | Merge agent branches into canonical (`--branch`, `--all`, `--into`, `--dry-run`, `--json`) |
152
+
153
+ ### Observability
154
+
155
+ | Command | Description |
156
+ |---------|-------------|
157
+ | `ap status` | Show all active agents, worktrees, tracker state (`--json`, `--verbose`, `--all`) |
158
+ | `ap dashboard` | Live TUI dashboard for agent monitoring (`--interval`, `--all`) |
159
+ | `ap inspect <agent>` | Deep per-agent inspection (`--follow`, `--interval`, `--no-tmux`, `--limit`, `--json`) |
160
+ | `ap trace` | View agent/task timeline (`--agent`, `--run`, `--since`, `--until`, `--limit`, `--json`) |
161
+ | `ap errors` | Aggregated error view across agents (`--agent`, `--run`, `--since`, `--until`, `--limit`, `--json`) |
162
+ | `ap replay` | Interleaved chronological replay (`--run`, `--agent`, `--since`, `--until`, `--limit`, `--json`) |
163
+ | `ap feed` | Unified real-time event stream (`--follow`, `--interval`, `--agent`, `--run`, `--json`) |
164
+ | `ap logs` | Query NDJSON logs across agents (`--agent`, `--level`, `--since`, `--until`, `--follow`, `--json`) |
165
+ | `ap costs` | Token/cost analysis and breakdown (`--live`, `--self`, `--agent`, `--run`, `--bead`, `--by-capability`, `--last`, `--json`) |
166
+ | `ap metrics` | Show session metrics (`--last`, `--json`) |
167
+ | `ap run list` | List orchestration runs (`--last`, `--json`) |
168
+ | `ap run show <id>` | Show run details |
169
+ | `ap run complete` | Mark current run as completed |
170
+
171
+ ### Infrastructure
172
+
173
+ | Command | Description |
174
+ |---------|-------------|
175
+ | `ap hooks install` | Install orchestrator hooks to `.claude/settings.local.json` (`--force`) |
176
+ | `ap hooks uninstall` | Remove orchestrator hooks |
177
+ | `ap hooks status` | Check if hooks are installed |
178
+ | `ap worktree list` | List worktrees with status |
179
+ | `ap worktree clean` | Remove completed worktrees (`--completed`, `--all`, `--force`) |
180
+ | `ap watch` | Start watchdog daemon — Tier 0 (`--interval`, `--background`) |
181
+ | `ap monitor start` | Start Tier 2 monitor agent |
182
+ | `ap monitor stop` | Stop monitor agent |
183
+ | `ap monitor status` | Show monitor state |
184
+ | `ap log <event>` | Log a hook event (`--agent`) |
185
+ | `ap clean` | Clean up worktrees, sessions, artifacts (`--completed`, `--all`, `--run`) |
186
+ | `ap doctor` | Run health checks on agentplate setup — 13 categories (`--category`, `--fix`, `--json`) |
187
+ | `ap serve` | HTTP + WebSocket surface for the web UI (`--port`, `--host`, `--json`) |
188
+ | `ap ecosystem` | Show ag-eco tool versions and health (`--json`) |
189
+ | `ap upgrade` | Upgrade agentplate to latest npm version (`--check`, `--all`, `--json`) |
190
+ | `ap agents discover` | Discover agents by capability/state/parent (`--capability`, `--state`, `--parent`, `--json`) |
191
+ | `ap completions <shell>` | Generate shell completions (bash, zsh, fish) |
192
+
193
+ ## Architecture
194
+
195
+ Agentplate uses instruction overlays and tool-call guards to turn agent sessions into orchestrated workers. Each agent runs in an isolated git worktree; new projects spawn Claude workers as headless subprocesses (stream-json over stdout) and surface them through `ap serve`'s web UI, with tmux available as an opt-in for live attach. Inter-agent messaging is handled by a custom SQLite mail system (WAL mode, ~1-5ms per query) with typed protocol messages and broadcast support. A FIFO merge queue with 4-tier conflict resolution merges agent branches back to canonical. A tiered watchdog system (Tier 0 mechanical daemon, Tier 1 AI-assisted triage, Tier 2 monitor agent) ensures fleet health. See [CLAUDE.md](CLAUDE.md) for full technical details.
196
+
197
+ ### Runtime Adapters
198
+
199
+ Agentplate is runtime-agnostic. The `AgentRuntime` interface (`src/runtimes/types.ts`) defines the contract — each adapter handles spawning, config deployment, guard enforcement, readiness detection, and transcript parsing for its runtime. Set the default in `config.yaml` or override per-agent with `ap sling --runtime <name>`.
200
+
201
+ Claude Code agents can run in **headless mode** (the default for new projects — `-p --output-format stream-json` subprocess, NDJSON events parsed by `ClaudeRuntime.parseEvents`, surfaced through `ap serve`'s web UI) or **tmux mode** (escape hatch for live attach — operator can `tmux attach` to watch and steer mid-session). `ap init` writes `runtime.claudeHeadlessByDefault: true` for new projects; legacy projects upgrading from earlier agentplate versions keep tmux until they edit config. Override per-spawn with `ap sling --no-headless` (force tmux) or `--headless` (force headless). Sapling is statically headless; Pi, Codex, and Cursor have no `buildDirectSpawn` and reject `--headless`.
202
+
203
+ | Runtime | CLI | Guard Mechanism | Stability |
204
+ |---------|-----|-----------------|-----------|
205
+ | Claude Code | `claude` | `settings.local.json` hooks | Stable |
206
+ | Sapling | `sp` | `.sapling/guards.json` | Stable |
207
+ | Pi | `pi` | `.pi/extensions/` guard extension | Experimental |
208
+ | Copilot | `copilot` | (none — `--allow-all-tools`) | Experimental |
209
+ | Cursor | `agent` | (none — `--yolo`) | Experimental |
210
+ | Codex | `codex` | OS-level sandbox (Seatbelt/Landlock) | Experimental |
211
+ | Gemini | `gemini` | `--sandbox` flag | Experimental |
212
+ | Aider | `aider` | (none — `--yes-always`) | Experimental |
213
+ | Goose | `goose` | Profile-based permissions | Experimental |
214
+ | Amp | `amp` | Built-in approval system | Experimental |
215
+ | OpenCode | `opencode` | (none) | Experimental |
216
+
217
+ ## How It Works
218
+
219
+ Instruction overlays + tool-call guards + the `ap` CLI turn your coding session into a multi-agent orchestrator. A persistent coordinator agent manages task decomposition and dispatch, while a mechanical watchdog daemon monitors agent health in the background.
220
+
221
+ ```
222
+ Orchestrator (multi-repo coordinator of coordinators)
223
+ --> Coordinator (persistent orchestrator at project root)
224
+ --> Supervisor / Lead (team lead, depth 1)
225
+ --> Workers: Scout, Builder, Reviewer, Merger (depth 2)
226
+ ```
227
+
228
+ ### Agent Types
229
+
230
+ | Agent | Role | Access |
231
+ |-------|------|--------|
232
+ | **Orchestrator** | Multi-repo coordinator of coordinators — dispatches coordinators per sub-repo | Read-only |
233
+ | **Coordinator** | Persistent orchestrator — decomposes objectives, dispatches agents, tracks task groups | Read-only |
234
+ | **Supervisor** | Per-project team lead — manages worker lifecycle, handles nudge/escalation | Read-only |
235
+ | **Scout** | Read-only exploration and research | Read-only |
236
+ | **Builder** | Implementation and code changes | Read-write |
237
+ | **Reviewer** | Validation and code review | Read-only |
238
+ | **Lead** | Team coordination, can spawn sub-workers | Read-write |
239
+ | **Merger** | Branch merge specialist | Read-write |
240
+ | **Monitor** | Tier 2 continuous fleet patrol — ongoing health monitoring | Read-only |
241
+
242
+ ### Key Architecture
243
+
244
+ - **Agent Definitions**: Two-layer system — base `.md` files define the HOW (workflow), per-task overlays define the WHAT (task scope). Base definition content is injected into spawned agent overlays automatically.
245
+ - **Messaging**: Custom SQLite mail system with typed protocol — 8 message types (`worker_done`, `merge_ready`, `dispatch`, `escalation`, etc.) for structured agent coordination, plus broadcast messaging with group addresses (`@all`, `@builders`, etc.)
246
+ - **Worktrees**: Each agent gets an isolated git worktree — no file conflicts between agents
247
+ - **Merge**: FIFO merge queue (SQLite-backed) with 4-tier conflict resolution
248
+ - **Watchdog**: Tiered health monitoring — Tier 0 mechanical daemon (tmux/pid liveness), Tier 1 AI-assisted failure triage, Tier 2 monitor agent for continuous fleet patrol
249
+ - **Tool Enforcement**: Runtime-specific guards (hooks for Claude Code, extensions for Pi) mechanically block file modifications for non-implementation agents and dangerous git operations for all agents
250
+ - **Task Groups**: Batch coordination with auto-close when all member issues complete
251
+ - **Session Lifecycle**: Checkpoint save/restore for compaction survivability, handoff orchestration for crash recovery
252
+ - **Token Instrumentation**: Session metrics extracted from runtime transcript files (JSONL)
253
+
254
+ ## Project Structure
255
+
256
+ ```
257
+ agentplate/
258
+ src/
259
+ index.ts CLI entry point (Commander.js program)
260
+ types.ts Shared types and interfaces
261
+ config.ts Config loader + validation
262
+ errors.ts Custom error types
263
+ json.ts Standardized JSON envelope helpers
264
+ commands/ One file per CLI subcommand (38 commands)
265
+ agents.ts Agent discovery and querying
266
+ coordinator.ts Persistent orchestrator lifecycle
267
+ supervisor.ts Team lead management [DEPRECATED]
268
+ dashboard.ts Live TUI dashboard (ANSI via Chalk)
269
+ hooks.ts Orchestrator hooks management
270
+ sling.ts Agent spawning
271
+ group.ts Task group batch tracking
272
+ nudge.ts Agent nudging
273
+ mail.ts Inter-agent messaging
274
+ monitor.ts Tier 2 monitor management
275
+ merge.ts Branch merging
276
+ status.ts Fleet status overview
277
+ prime.ts Context priming
278
+ init.ts Project initialization
279
+ worktree.ts Worktree management
280
+ watch.ts Watchdog daemon
281
+ log.ts Hook event logging
282
+ logs.ts NDJSON log query
283
+ feed.ts Unified real-time event stream
284
+ run.ts Orchestration run lifecycle
285
+ trace.ts Agent/task timeline viewing
286
+ clean.ts Worktree/session cleanup
287
+ doctor.ts Health check runner (13 check modules)
288
+ inspect.ts Deep per-agent inspection
289
+ spec.ts Task spec management
290
+ errors.ts Aggregated error view
291
+ replay.ts Interleaved event replay
292
+ stop.ts Agent termination
293
+ costs.ts Token/cost analysis
294
+ metrics.ts Session metrics
295
+ ecosystem.ts ag-eco tool dashboard
296
+ update.ts Refresh managed files
297
+ upgrade.ts npm version upgrades
298
+ discover.ts Brownfield codebase discovery via coordinator-driven scout swarm
299
+ orchestrator.ts Multi-repo coordination (PersistentAgentSpec)
300
+ completions.ts Shell completion generation (bash/zsh/fish)
301
+ serve.ts HTTP + WebSocket surface for the web UI
302
+ serve/ REST handlers, WebSocket broadcaster, static SPA fallback
303
+ trellis/
304
+ client.ts Trellis client (prompt rendering, listing, emission)
305
+ agents/ Agent lifecycle management
306
+ manifest.ts Agent registry (load + query)
307
+ overlay.ts Dynamic CLAUDE.md overlay generator
308
+ identity.ts Persistent agent identity (CVs)
309
+ checkpoint.ts Session checkpoint save/restore
310
+ lifecycle.ts Handoff orchestration
311
+ hooks-deployer.ts Deploy hooks + tool enforcement
312
+ copilot-hooks-deployer.ts Deploy hooks config to Copilot worktrees
313
+ guard-rules.ts Shared guard constants (tool lists, bash patterns)
314
+ mail-poll-detect.ts Bash mail-poll pattern detector (runtime backstop)
315
+ scope-detect.ts Soft FILE_SCOPE violation detection (builder/merger)
316
+ worktree/ Git worktree + tmux management
317
+ mail/ SQLite mail system (typed protocol, broadcast)
318
+ merge/ FIFO queue + conflict resolution + sentinel-file lock + dry-run prediction
319
+ watchdog/ Tiered health monitoring (daemon, triage, health)
320
+ logging/ Multi-format logger + sanitizer + reporter + color control + shared theme/format
321
+ metrics/ SQLite metrics + pricing + transcript parsing
322
+ doctor/ Health check modules (13 checks)
323
+ utils/ Shared utilities (bin, fs, pid, time, version)
324
+ insights/ Session insight analyzer + quality-gate runner (success/partial/failure)
325
+ runtimes/ AgentRuntime abstraction (registry + adapters: Claude, Pi, Copilot, Codex, Gemini, Sapling, OpenCode, Cursor, Aider, Goose, Amp)
326
+ tracker/ Pluggable task tracker (beads + sprout backends)
327
+ loam/ loam client (programmatic API + CLI wrapper)
328
+ e2e/ End-to-end lifecycle tests
329
+ agents/ Base agent definitions (.md, 9 roles) + skill definitions
330
+ templates/ Templates for overlays and hooks
331
+ ```
332
+
333
+ ## Configuration
334
+
335
+ ### Gateway Providers
336
+
337
+ Route agent API calls through custom gateway endpoints (z.ai, OpenRouter, self-hosted proxies). Configure providers in `.agentplate/config.yaml`:
338
+
339
+ ```yaml
340
+ providers:
341
+ anthropic:
342
+ type: native
343
+ zai:
344
+ type: gateway
345
+ baseUrl: https://api.z.ai/v1
346
+ authTokenEnv: ZAI_API_KEY
347
+ openrouter:
348
+ type: gateway
349
+ baseUrl: https://openrouter.ai/api/v1
350
+ authTokenEnv: OPENROUTER_API_KEY
351
+ models:
352
+ builder: zai/claude-sonnet-4-6
353
+ scout: openrouter/openai/gpt-4o
354
+ ```
355
+
356
+ **How it works:** Model refs use `provider/model-id` format. Agentplate sets `ANTHROPIC_BASE_URL` to the gateway `baseUrl`, `ANTHROPIC_AUTH_TOKEN` from the env var named in `authTokenEnv`, and `ANTHROPIC_API_KEY=""` to prevent direct Anthropic calls. The agent receives `"sonnet"` as a model alias and Claude Code routes via env vars.
357
+
358
+ **Environment variable notes:**
359
+ - `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_API_KEY` are mutually exclusive per-agent
360
+ - Gateway agents get `ANTHROPIC_API_KEY=""` and `ANTHROPIC_AUTH_TOKEN` from provider config
361
+ - Direct Anthropic API calls (merge resolver, watchdog triage) still need `ANTHROPIC_API_KEY` in the orchestrator env
362
+
363
+ **Validation:** `ap doctor --category providers` checks reachability, auth tokens, model-provider refs, and tool-use compatibility.
364
+
365
+ **`ProviderConfig` fields:**
366
+
367
+ | Field | Type | Required | Description |
368
+ |-------|------|----------|-------------|
369
+ | `type` | `native` or `gateway` | Yes | Provider type |
370
+ | `baseUrl` | string | Gateway only | API endpoint URL |
371
+ | `authTokenEnv` | string | Gateway only | Env var name holding auth token |
372
+
373
+ ## Troubleshooting
374
+
375
+ ### Recovering a dead lead (or any agent that exited mid-task)
376
+
377
+ If a lead exits without sending `merge_ready` (process termination, watchdog kill, manual `ap stop`) and the task was already closed, both `ap nudge` and `ap sling` would normally refuse to re-engage:
378
+
379
+ - `ap nudge <name>` reports `No active session for agent "..." (state: completed)`. The agent's process is gone, so there's nothing to send keystrokes to.
380
+ - `ap sling <task-id> --capability lead` reports `Task "..." is not workable (status: closed)`.
381
+
382
+ To re-dispatch a fresh lead against the same task, pass `--recover`:
383
+
384
+ ```bash
385
+ ap sling <task-id> --capability lead --recover --name <fresh-name>
386
+ ```
387
+
388
+ `--recover` bypasses the workable-status check so the new lead can pick up where the dead one left off (the task remains closed; the new lead reads the spec and proceeds). The terminal-state nudge error itself includes a copy-paste hint to this exact form.
389
+
390
+ ### Coordinator died during startup
391
+
392
+ This error means the coordinator tmux session exited before the TUI became ready. The most common cause is slow shell initialization.
393
+
394
+ **Step 1: Measure shell startup time**
395
+
396
+ ```bash
397
+ time zsh -i -c exit # For zsh
398
+ time bash -i -c exit # For bash
399
+ ```
400
+
401
+ If startup takes more than 1 second, slow shell init is likely the cause.
402
+
403
+ **Step 2: Common slow-startup causes**
404
+
405
+ | Cause | Typical delay | Fix |
406
+ |-------|---------------|-----|
407
+ | oh-my-zsh with many plugins | 1-5s | Reduce plugins, switch to lighter framework (zinit with lazy loading) |
408
+ | nvm (Node Version Manager) | 1-3s | Use `--no-use` + lazy-load nvm, or switch to fnm/volta |
409
+ | pyenv init | 0.5-2s | Lazy-load pyenv |
410
+ | rbenv init | 0.5-1s | Lazy-load rbenv |
411
+ | starship prompt | 0.5-1s | Check starship timings |
412
+ | conda auto-activate | 1-3s | `auto_activate_base: false` in `.condarc` |
413
+ | Homebrew shellenv | 0.5-1s | Cache output instead of evaluating every shell start |
414
+
415
+ **Step 3: Configure `shellInitDelayMs`** in `.agentplate/config.yaml`:
416
+
417
+ ```yaml
418
+ runtime:
419
+ shellInitDelayMs: 3000
420
+ ```
421
+
422
+ - Default: `0` (no delay)
423
+ - Typical values: `1000`–`5000` depending on shell startup time
424
+ - Values above `30000` (30s) trigger a warning
425
+ - Inserts a delay between tmux session creation and TUI readiness polling
426
+
427
+ **Step 4: Optimization examples**
428
+
429
+ Lazy-load nvm (add to `~/.zshrc` or `~/.bashrc`):
430
+
431
+ ```bash
432
+ # Lazy-load nvm — only activates when you first call nvm/node/npm
433
+ export NVM_DIR="$HOME/.nvm"
434
+ nvm() { unset -f nvm node npm npx; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; nvm "$@"; }
435
+ node() { unset -f nvm node npm npx; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; node "$@"; }
436
+ npm() { unset -f nvm node npm npx; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; npm "$@"; }
437
+ npx() { unset -f nvm node npm npx; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; npx "$@"; }
438
+ ```
439
+
440
+ Reduce oh-my-zsh plugins (edit `~/.zshrc`):
441
+
442
+ ```bash
443
+ # Before: plugins=(git zsh-autosuggestions zsh-syntax-highlighting node npm python ruby rbenv pyenv ...)
444
+ # After: keep only what you use regularly
445
+ plugins=(git)
446
+ ```
447
+
448
+ ## Part of ag-eco
449
+
450
+ Agentplate is part of the [ag-eco](https://github.com/hgoudat/ag-eco) AI agent tooling ecosystem.
451
+
452
+ <p align="center">
453
+ <img src="https://raw.githubusercontent.com/hgoudat/ag-eco/main/branding/logo.png" alt="ag-eco" width="444" />
454
+ </p>
455
+
456
+ ## Contributing
457
+
458
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
459
+
460
+ ## License
461
+
462
+ MIT
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: ap-co-creation
3
+ description: Co-creation workflow profile — human-in-the-loop at explicit decision gates
4
+ ---
5
+
6
+ ## propulsion-principle
7
+
8
+ Read your assignment. For implementation work within an approved plan, execute immediately — no confirmation needed for routine decisions (naming, file organization, test strategy, implementation details within spec).
9
+
10
+ PAUSE at decision gates. When you encounter an architectural choice, design fork, scope boundary, or tool selection, stop and do not proceed. Instead:
11
+
12
+ 1. Write a structured decision document (context, options, tradeoffs, recommendation).
13
+ 2. Send it as a decision_gate mail to the coordinator.
14
+ 3. Wait for a response before proceeding past the gate.
15
+
16
+ Hesitation is the default at gates; action is the default within approved plans.
17
+
18
+ ## escalation-policy
19
+
20
+ At decision points, present options rather than choosing. When you encounter a meaningful decision:
21
+
22
+ 1. Write a structured decision document: context, 2+ options with tradeoffs, and your recommendation.
23
+ 2. Send it as a decision_gate mail to the coordinator and wait.
24
+ 3. Do not proceed until you receive a reply selecting an option.
25
+
26
+ Routine implementation decisions within an already-approved plan remain autonomous. Do not send decision gates for: variable names, file organization within spec, test strategy, or minor implementation choices that do not affect overall direction.
27
+
28
+ Escalate immediately (not as a decision gate) when you discover: risks that could cause data loss, security issues, or breaking changes beyond scope; blocked dependencies outside your control.
29
+
30
+ ## artifact-expectations
31
+
32
+ Decision artifacts come before code. Deliverables in order:
33
+
34
+ 1. **Option memos**: For any decision with multiple viable approaches, write a structured memo with options, tradeoffs, and a recommendation. Send as a decision_gate mail and await approval.
35
+ 2. **ADRs (Architecture Decision Records)**: For architectural choices, create a lightweight ADR capturing context, decision, and consequences.
36
+ 3. **Tradeoff matrices**: When comparing approaches across multiple dimensions, present a structured comparison.
37
+ 4. **Code and tests**: Implementation proceeds after decision artifacts are approved. Code must be clean, follow project conventions, and include automated tests.
38
+ 5. **Quality gates**: All lints, type checks, and tests must pass before reporting completion.
39
+
40
+ Do not write implementation code before decisions are resolved. The human reviews and approves decision documents; implementation follows approval.
41
+
42
+ ## completion-criteria
43
+
44
+ Work is complete when all of the following are true:
45
+
46
+ - All quality gates pass: tests green, linting clean, type checking passes.
47
+ - Changes are committed to the appropriate branch.
48
+ - Any issues tracked in the task system are updated or closed.
49
+ - A completion signal has been sent to the appropriate recipient (parent agent, coordinator, or human).
50
+
51
+ Do not declare completion prematurely. Run the quality gates yourself — do not assume they pass. If a gate fails, fix the issue before reporting done.
52
+
53
+ ## human-role
54
+
55
+ The human is an active co-creator at explicit decision gates — not a hands-off supervisor.
56
+
57
+ - **Active at gates.** The human reviews decision documents and selects options via mail reply. The agent waits for this input before proceeding.
58
+ - **Autonomous between gates.** Once a direction is approved, the agent executes without further check-ins. Implementation details within an approved plan are delegated.
59
+ - **Milestone reviews.** The human reviews work at defined checkpoints (planning, prototype, final). These are collaborative reviews with explicit proceed signals.
60
+ - **Minimal interruption between gates.** Do not ask questions that could be answered by reading the codebase or attempting something. Reserve interruptions for genuinely ambiguous requirements.
61
+
62
+ ## decision-gates
63
+
64
+ When you reach a decision point (architectural choice, scope boundary, design fork, tool selection), follow this protocol:
65
+
66
+ 1. **Write a structured decision document** containing:
67
+ - **Context**: What problem are you solving? What constraints apply?
68
+ - **Options**: At least 2 viable approaches, each with: description, tradeoffs (pros/cons), and implementation implications.
69
+ - **Recommendation**: Which option you recommend and why.
70
+
71
+ 2. **Send a decision_gate mail** to the coordinator with the decision document in the body. Include a payload with the options array and brief context. Use --type decision_gate.
72
+
73
+ 3. **BLOCK and wait** for a reply. Do not continue past the gate without a response. Poll your inbox periodically while waiting.
74
+
75
+ Decision gates are NOT for: variable names, file organization within spec, test strategy, or minor implementation choices within an approved design. They are for choices that meaningfully affect the direction of work.
76
+
77
+ ## milestone-reviews
78
+
79
+ Send checkpoint reviews at three milestones:
80
+
81
+ **After planning** (before any implementation begins):
82
+ Send a status mail with: scope summary (what will be built), approach (high-level design with all decisions resolved via gates), file list (which files will be affected), and any open questions requiring confirmation before starting.
83
+
84
+ **After prototyping** (when a working prototype exists):
85
+ Send a status mail with: what works and what is rough, remaining decisions (if any), revised scope if it changed during prototyping, and an explicit request to proceed before final implementation.
86
+
87
+ **Before final implementation** (after all gates resolved and prototype reviewed):
88
+ Send a status mail summarizing: complete plan with all decisions incorporated, any deviations from original scope, and a confirmation request before beginning the final commit sequence.
89
+
90
+ Each milestone review uses mail type status and clearly labels the milestone in the subject line.