@bonesofspring/ai-rules 0.2.33 → 0.2.34

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 (396) hide show
  1. package/docs/PRESET-CONTRIBUTION.md +2 -2
  2. package/package.json +4 -1
  3. package/presets/_shared/README.md +1 -1
  4. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +22 -0
  5. package/presets/_shared/core/agent-team/agent-task-metrics.md +12 -1
  6. package/presets/_shared/core/agent-team/agent-team-intake.md +1 -1
  7. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +18 -4
  8. package/presets/_shared/core/agent-team/plan-graph.md +28 -0
  9. package/presets/_shared/core/agent-team/task-classification.md +2 -0
  10. package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
  11. package/presets/claude/android-kotlin/agents/task-router.md +10 -0
  12. package/presets/claude/android-kotlin/commands/task-continue.md +1 -1
  13. package/presets/claude/android-kotlin/commands/task.md +1 -1
  14. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +369 -16
  15. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +1 -1
  16. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  17. package/presets/claude/android-kotlin/team/README.md +4 -1
  18. package/presets/claude/go/agents/task-analyst.md +1 -1
  19. package/presets/claude/go/agents/task-router.md +10 -0
  20. package/presets/claude/go/commands/task-continue.md +1 -1
  21. package/presets/claude/go/commands/task.md +1 -1
  22. package/presets/claude/go/hooks/chain-team-phases.sh +367 -16
  23. package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +1 -1
  24. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  25. package/presets/claude/go/team/README.md +4 -1
  26. package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
  27. package/presets/claude/ios-swift/agents/task-router.md +10 -0
  28. package/presets/claude/ios-swift/commands/task-continue.md +1 -1
  29. package/presets/claude/ios-swift/commands/task.md +1 -1
  30. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +369 -16
  31. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +1 -1
  32. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  33. package/presets/claude/ios-swift/team/README.md +4 -1
  34. package/presets/claude/java/agents/task-analyst.md +1 -1
  35. package/presets/claude/java/agents/task-router.md +10 -0
  36. package/presets/claude/java/commands/task-continue.md +1 -1
  37. package/presets/claude/java/commands/task.md +1 -1
  38. package/presets/claude/java/hooks/chain-team-phases.sh +367 -16
  39. package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +1 -1
  40. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  41. package/presets/claude/java/team/README.md +4 -1
  42. package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
  43. package/presets/claude/mcp-ts/agents/task-router.md +10 -0
  44. package/presets/claude/mcp-ts/commands/task-continue.md +1 -1
  45. package/presets/claude/mcp-ts/commands/task.md +1 -1
  46. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +367 -16
  47. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +1 -1
  48. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  49. package/presets/claude/mcp-ts/team/README.md +4 -1
  50. package/presets/claude/next/agents/task-analyst.md +1 -1
  51. package/presets/claude/next/agents/task-router.md +10 -0
  52. package/presets/claude/next/commands/task-continue.md +1 -1
  53. package/presets/claude/next/commands/task.md +1 -1
  54. package/presets/claude/next/hooks/chain-team-phases.sh +369 -16
  55. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +1 -1
  56. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  57. package/presets/claude/next/team/README.md +4 -1
  58. package/presets/claude/next/team/fixtures/artifact-manifest.example.json +1 -1
  59. package/presets/claude/next/team/fixtures/feature-parallel.json +84 -0
  60. package/presets/claude/nuxt/agents/task-analyst.md +1 -1
  61. package/presets/claude/nuxt/agents/task-router.md +10 -0
  62. package/presets/claude/nuxt/commands/task-continue.md +1 -1
  63. package/presets/claude/nuxt/commands/task.md +1 -1
  64. package/presets/claude/nuxt/hooks/chain-team-phases.sh +369 -16
  65. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +1 -1
  66. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  67. package/presets/claude/nuxt/team/README.md +4 -1
  68. package/presets/claude/nuxt/team/fixtures/artifact-manifest.example.json +1 -1
  69. package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
  70. package/presets/claude/php-hexagonal/agents/task-router.md +10 -0
  71. package/presets/claude/php-hexagonal/commands/task-continue.md +1 -1
  72. package/presets/claude/php-hexagonal/commands/task.md +1 -1
  73. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +367 -16
  74. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +1 -1
  75. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  76. package/presets/claude/php-hexagonal/team/README.md +4 -1
  77. package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
  78. package/presets/claude/php-laravel/agents/task-router.md +10 -0
  79. package/presets/claude/php-laravel/commands/task-continue.md +1 -1
  80. package/presets/claude/php-laravel/commands/task.md +1 -1
  81. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +367 -16
  82. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +1 -1
  83. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  84. package/presets/claude/php-laravel/team/README.md +4 -1
  85. package/presets/claude/svelte/agents/task-analyst.md +1 -1
  86. package/presets/claude/svelte/agents/task-router.md +10 -0
  87. package/presets/claude/svelte/commands/task-continue.md +1 -1
  88. package/presets/claude/svelte/commands/task.md +1 -1
  89. package/presets/claude/svelte/hooks/chain-team-phases.sh +369 -16
  90. package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +1 -1
  91. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +12 -1
  92. package/presets/claude/svelte/team/README.md +4 -1
  93. package/presets/claude/svelte/team/fixtures/artifact-manifest.example.json +1 -1
  94. package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
  95. package/presets/cursor/android-kotlin/agents/task-router.md +10 -0
  96. package/presets/cursor/android-kotlin/commands/task-continue.md +1 -1
  97. package/presets/cursor/android-kotlin/commands/task.md +1 -1
  98. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +369 -16
  99. package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +1 -1
  100. package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +12 -1
  101. package/presets/cursor/android-kotlin/team/README.md +4 -1
  102. package/presets/cursor/go/agents/task-analyst.md +1 -1
  103. package/presets/cursor/go/agents/task-router.md +10 -0
  104. package/presets/cursor/go/commands/task-continue.md +1 -1
  105. package/presets/cursor/go/commands/task.md +1 -1
  106. package/presets/cursor/go/hooks/chain-team-phases.sh +367 -16
  107. package/presets/cursor/go/rules/agent-team-intake.mdc +1 -1
  108. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +12 -1
  109. package/presets/cursor/go/team/README.md +4 -1
  110. package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
  111. package/presets/cursor/ios-swift/agents/task-router.md +10 -0
  112. package/presets/cursor/ios-swift/commands/task-continue.md +1 -1
  113. package/presets/cursor/ios-swift/commands/task.md +1 -1
  114. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +369 -16
  115. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +1 -1
  116. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +12 -1
  117. package/presets/cursor/ios-swift/team/README.md +4 -1
  118. package/presets/cursor/java/agents/task-analyst.md +1 -1
  119. package/presets/cursor/java/agents/task-router.md +10 -0
  120. package/presets/cursor/java/commands/task-continue.md +1 -1
  121. package/presets/cursor/java/commands/task.md +1 -1
  122. package/presets/cursor/java/hooks/chain-team-phases.sh +367 -16
  123. package/presets/cursor/java/rules/agent-team-intake.mdc +1 -1
  124. package/presets/cursor/java/rules/agent-team-orchestrator.mdc +12 -1
  125. package/presets/cursor/java/team/README.md +4 -1
  126. package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
  127. package/presets/cursor/mcp-ts/agents/task-router.md +10 -0
  128. package/presets/cursor/mcp-ts/commands/task-continue.md +1 -1
  129. package/presets/cursor/mcp-ts/commands/task.md +1 -1
  130. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +367 -16
  131. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +1 -1
  132. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +12 -1
  133. package/presets/cursor/mcp-ts/team/README.md +4 -1
  134. package/presets/cursor/next/agents/task-analyst.md +1 -1
  135. package/presets/cursor/next/agents/task-router.md +10 -0
  136. package/presets/cursor/next/commands/task-continue.md +1 -1
  137. package/presets/cursor/next/commands/task.md +1 -1
  138. package/presets/cursor/next/hooks/chain-team-phases.sh +369 -16
  139. package/presets/cursor/next/rules/agent-team-intake.mdc +1 -1
  140. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +12 -1
  141. package/presets/cursor/next/team/README.md +4 -1
  142. package/presets/cursor/next/team/fixtures/artifact-manifest.example.json +1 -1
  143. package/presets/cursor/next/team/fixtures/feature-parallel.json +84 -0
  144. package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
  145. package/presets/cursor/nuxt/agents/task-router.md +10 -0
  146. package/presets/cursor/nuxt/commands/task-continue.md +1 -1
  147. package/presets/cursor/nuxt/commands/task.md +1 -1
  148. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +369 -16
  149. package/presets/cursor/nuxt/rules/agent-team-intake.mdc +1 -1
  150. package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +12 -1
  151. package/presets/cursor/nuxt/team/README.md +4 -1
  152. package/presets/cursor/nuxt/team/fixtures/artifact-manifest.example.json +1 -1
  153. package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
  154. package/presets/cursor/php-hexagonal/agents/task-router.md +10 -0
  155. package/presets/cursor/php-hexagonal/commands/task-continue.md +1 -1
  156. package/presets/cursor/php-hexagonal/commands/task.md +1 -1
  157. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +367 -16
  158. package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +1 -1
  159. package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +12 -1
  160. package/presets/cursor/php-hexagonal/team/README.md +4 -1
  161. package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
  162. package/presets/cursor/php-laravel/agents/task-router.md +10 -0
  163. package/presets/cursor/php-laravel/commands/task-continue.md +1 -1
  164. package/presets/cursor/php-laravel/commands/task.md +1 -1
  165. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +367 -16
  166. package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +1 -1
  167. package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +12 -1
  168. package/presets/cursor/php-laravel/team/README.md +4 -1
  169. package/presets/cursor/svelte/agents/task-analyst.md +1 -1
  170. package/presets/cursor/svelte/agents/task-router.md +10 -0
  171. package/presets/cursor/svelte/commands/task-continue.md +1 -1
  172. package/presets/cursor/svelte/commands/task.md +1 -1
  173. package/presets/cursor/svelte/hooks/chain-team-phases.sh +369 -16
  174. package/presets/cursor/svelte/rules/agent-team-intake.mdc +1 -1
  175. package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +12 -1
  176. package/presets/cursor/svelte/team/README.md +4 -1
  177. package/presets/cursor/svelte/team/fixtures/artifact-manifest.example.json +1 -1
  178. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  179. package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
  180. package/presets/mavis/android-kotlin/agents/task-router.md +10 -0
  181. package/presets/mavis/android-kotlin/commands/task-continue.md +1 -1
  182. package/presets/mavis/android-kotlin/commands/task.md +1 -1
  183. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +369 -16
  184. package/presets/mavis/android-kotlin/rules/agent-team-intake.md +1 -1
  185. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +18 -4
  186. package/presets/mavis/android-kotlin/team/README.md +4 -1
  187. package/presets/mavis/go/adapter-map.json +1 -1
  188. package/presets/mavis/go/agents/task-analyst.md +1 -1
  189. package/presets/mavis/go/agents/task-router.md +10 -0
  190. package/presets/mavis/go/commands/task-continue.md +1 -1
  191. package/presets/mavis/go/commands/task.md +1 -1
  192. package/presets/mavis/go/hooks/chain-team-phases.sh +367 -16
  193. package/presets/mavis/go/rules/agent-team-intake.md +1 -1
  194. package/presets/mavis/go/rules/agent-team-orchestrator.md +18 -4
  195. package/presets/mavis/go/team/README.md +4 -1
  196. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  197. package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
  198. package/presets/mavis/ios-swift/agents/task-router.md +10 -0
  199. package/presets/mavis/ios-swift/commands/task-continue.md +1 -1
  200. package/presets/mavis/ios-swift/commands/task.md +1 -1
  201. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +369 -16
  202. package/presets/mavis/ios-swift/rules/agent-team-intake.md +1 -1
  203. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +18 -4
  204. package/presets/mavis/ios-swift/team/README.md +4 -1
  205. package/presets/mavis/java/adapter-map.json +1 -1
  206. package/presets/mavis/java/agents/task-analyst.md +1 -1
  207. package/presets/mavis/java/agents/task-router.md +10 -0
  208. package/presets/mavis/java/commands/task-continue.md +1 -1
  209. package/presets/mavis/java/commands/task.md +1 -1
  210. package/presets/mavis/java/hooks/chain-team-phases.sh +367 -16
  211. package/presets/mavis/java/rules/agent-team-intake.md +1 -1
  212. package/presets/mavis/java/rules/agent-team-orchestrator.md +18 -4
  213. package/presets/mavis/java/team/README.md +4 -1
  214. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  215. package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
  216. package/presets/mavis/mcp-ts/agents/task-router.md +10 -0
  217. package/presets/mavis/mcp-ts/commands/task-continue.md +1 -1
  218. package/presets/mavis/mcp-ts/commands/task.md +1 -1
  219. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +367 -16
  220. package/presets/mavis/mcp-ts/rules/agent-team-intake.md +1 -1
  221. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +18 -4
  222. package/presets/mavis/mcp-ts/team/README.md +4 -1
  223. package/presets/mavis/next/adapter-map.json +9 -1
  224. package/presets/mavis/next/agents/task-analyst.md +1 -1
  225. package/presets/mavis/next/agents/task-router.md +10 -0
  226. package/presets/mavis/next/commands/task-continue.md +1 -1
  227. package/presets/mavis/next/commands/task.md +1 -1
  228. package/presets/mavis/next/hooks/chain-team-phases.sh +369 -16
  229. package/presets/mavis/next/rules/agent-team-intake.md +1 -1
  230. package/presets/mavis/next/rules/agent-team-orchestrator.md +18 -4
  231. package/presets/mavis/next/team/README.md +4 -1
  232. package/presets/mavis/next/team/fixtures/artifact-manifest.example.json +1 -1
  233. package/presets/mavis/next/team/fixtures/feature-parallel.json +84 -0
  234. package/presets/mavis/nuxt/adapter-map.json +1 -1
  235. package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
  236. package/presets/mavis/nuxt/agents/task-router.md +10 -0
  237. package/presets/mavis/nuxt/commands/task-continue.md +1 -1
  238. package/presets/mavis/nuxt/commands/task.md +1 -1
  239. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +369 -16
  240. package/presets/mavis/nuxt/rules/agent-team-intake.md +1 -1
  241. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +18 -4
  242. package/presets/mavis/nuxt/team/README.md +4 -1
  243. package/presets/mavis/nuxt/team/fixtures/artifact-manifest.example.json +1 -1
  244. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  245. package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
  246. package/presets/mavis/php-hexagonal/agents/task-router.md +10 -0
  247. package/presets/mavis/php-hexagonal/commands/task-continue.md +1 -1
  248. package/presets/mavis/php-hexagonal/commands/task.md +1 -1
  249. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +367 -16
  250. package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +1 -1
  251. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +18 -4
  252. package/presets/mavis/php-hexagonal/team/README.md +4 -1
  253. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  254. package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
  255. package/presets/mavis/php-laravel/agents/task-router.md +10 -0
  256. package/presets/mavis/php-laravel/commands/task-continue.md +1 -1
  257. package/presets/mavis/php-laravel/commands/task.md +1 -1
  258. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +367 -16
  259. package/presets/mavis/php-laravel/rules/agent-team-intake.md +1 -1
  260. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +18 -4
  261. package/presets/mavis/php-laravel/team/README.md +4 -1
  262. package/presets/mavis/svelte/adapter-map.json +1 -1
  263. package/presets/mavis/svelte/agents/task-analyst.md +1 -1
  264. package/presets/mavis/svelte/agents/task-router.md +10 -0
  265. package/presets/mavis/svelte/commands/task-continue.md +1 -1
  266. package/presets/mavis/svelte/commands/task.md +1 -1
  267. package/presets/mavis/svelte/hooks/chain-team-phases.sh +369 -16
  268. package/presets/mavis/svelte/rules/agent-team-intake.md +1 -1
  269. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +18 -4
  270. package/presets/mavis/svelte/team/README.md +4 -1
  271. package/presets/mavis/svelte/team/fixtures/artifact-manifest.example.json +1 -1
  272. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  273. package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
  274. package/presets/opencode/android-kotlin/agents/task-router.md +10 -0
  275. package/presets/opencode/android-kotlin/commands/task-continue.md +1 -1
  276. package/presets/opencode/android-kotlin/commands/task.md +1 -1
  277. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +369 -16
  278. package/presets/opencode/android-kotlin/rules/agent-team-intake.md +1 -1
  279. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +18 -4
  280. package/presets/opencode/android-kotlin/team/README.md +4 -1
  281. package/presets/opencode/go/adapter-map.json +1 -1
  282. package/presets/opencode/go/agents/task-analyst.md +1 -1
  283. package/presets/opencode/go/agents/task-router.md +10 -0
  284. package/presets/opencode/go/commands/task-continue.md +1 -1
  285. package/presets/opencode/go/commands/task.md +1 -1
  286. package/presets/opencode/go/hooks/chain-team-phases.sh +367 -16
  287. package/presets/opencode/go/rules/agent-team-intake.md +1 -1
  288. package/presets/opencode/go/rules/agent-team-orchestrator.md +18 -4
  289. package/presets/opencode/go/team/README.md +4 -1
  290. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  291. package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
  292. package/presets/opencode/ios-swift/agents/task-router.md +10 -0
  293. package/presets/opencode/ios-swift/commands/task-continue.md +1 -1
  294. package/presets/opencode/ios-swift/commands/task.md +1 -1
  295. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +369 -16
  296. package/presets/opencode/ios-swift/rules/agent-team-intake.md +1 -1
  297. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +18 -4
  298. package/presets/opencode/ios-swift/team/README.md +4 -1
  299. package/presets/opencode/java/adapter-map.json +1 -1
  300. package/presets/opencode/java/agents/task-analyst.md +1 -1
  301. package/presets/opencode/java/agents/task-router.md +10 -0
  302. package/presets/opencode/java/commands/task-continue.md +1 -1
  303. package/presets/opencode/java/commands/task.md +1 -1
  304. package/presets/opencode/java/hooks/chain-team-phases.sh +367 -16
  305. package/presets/opencode/java/rules/agent-team-intake.md +1 -1
  306. package/presets/opencode/java/rules/agent-team-orchestrator.md +18 -4
  307. package/presets/opencode/java/team/README.md +4 -1
  308. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  309. package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
  310. package/presets/opencode/mcp-ts/agents/task-router.md +10 -0
  311. package/presets/opencode/mcp-ts/commands/task-continue.md +1 -1
  312. package/presets/opencode/mcp-ts/commands/task.md +1 -1
  313. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +367 -16
  314. package/presets/opencode/mcp-ts/rules/agent-team-intake.md +1 -1
  315. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +18 -4
  316. package/presets/opencode/mcp-ts/team/README.md +4 -1
  317. package/presets/opencode/next/adapter-map.json +9 -1
  318. package/presets/opencode/next/agents/task-analyst.md +1 -1
  319. package/presets/opencode/next/agents/task-router.md +10 -0
  320. package/presets/opencode/next/commands/task-continue.md +1 -1
  321. package/presets/opencode/next/commands/task.md +1 -1
  322. package/presets/opencode/next/hooks/chain-team-phases.sh +369 -16
  323. package/presets/opencode/next/rules/agent-team-intake.md +1 -1
  324. package/presets/opencode/next/rules/agent-team-orchestrator.md +18 -4
  325. package/presets/opencode/next/team/README.md +4 -1
  326. package/presets/opencode/next/team/fixtures/artifact-manifest.example.json +1 -1
  327. package/presets/opencode/next/team/fixtures/feature-parallel.json +84 -0
  328. package/presets/opencode/nuxt/adapter-map.json +1 -1
  329. package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
  330. package/presets/opencode/nuxt/agents/task-router.md +10 -0
  331. package/presets/opencode/nuxt/commands/task-continue.md +1 -1
  332. package/presets/opencode/nuxt/commands/task.md +1 -1
  333. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +369 -16
  334. package/presets/opencode/nuxt/rules/agent-team-intake.md +1 -1
  335. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +18 -4
  336. package/presets/opencode/nuxt/team/README.md +4 -1
  337. package/presets/opencode/nuxt/team/fixtures/artifact-manifest.example.json +1 -1
  338. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  339. package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
  340. package/presets/opencode/php-hexagonal/agents/task-router.md +10 -0
  341. package/presets/opencode/php-hexagonal/commands/task-continue.md +1 -1
  342. package/presets/opencode/php-hexagonal/commands/task.md +1 -1
  343. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +367 -16
  344. package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +1 -1
  345. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +18 -4
  346. package/presets/opencode/php-hexagonal/team/README.md +4 -1
  347. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  348. package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
  349. package/presets/opencode/php-laravel/agents/task-router.md +10 -0
  350. package/presets/opencode/php-laravel/commands/task-continue.md +1 -1
  351. package/presets/opencode/php-laravel/commands/task.md +1 -1
  352. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +367 -16
  353. package/presets/opencode/php-laravel/rules/agent-team-intake.md +1 -1
  354. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +18 -4
  355. package/presets/opencode/php-laravel/team/README.md +4 -1
  356. package/presets/opencode/svelte/adapter-map.json +1 -1
  357. package/presets/opencode/svelte/agents/task-analyst.md +1 -1
  358. package/presets/opencode/svelte/agents/task-router.md +10 -0
  359. package/presets/opencode/svelte/commands/task-continue.md +1 -1
  360. package/presets/opencode/svelte/commands/task.md +1 -1
  361. package/presets/opencode/svelte/hooks/chain-team-phases.sh +369 -16
  362. package/presets/opencode/svelte/rules/agent-team-intake.md +1 -1
  363. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +18 -4
  364. package/presets/opencode/svelte/team/README.md +4 -1
  365. package/presets/opencode/svelte/team/fixtures/artifact-manifest.example.json +1 -1
  366. package/scripts/_lib/agent-write-scopes.json +27 -0
  367. package/scripts/check-parallel-plan.sh +353 -0
  368. package/scripts/check-preset-prompt-persistence.sh +51 -24
  369. package/scripts/check-preset-structure.sh +2 -0
  370. package/scripts/check-step-graph-contract.sh +123 -0
  371. package/scripts/fixtures/cli-golden/claude/next.json +10 -9
  372. package/scripts/fixtures/cli-golden/cursor/next.json +10 -9
  373. package/scripts/fixtures/cli-golden/mavis/android-kotlin.json +8 -8
  374. package/scripts/fixtures/cli-golden/mavis/go.json +8 -8
  375. package/scripts/fixtures/cli-golden/mavis/ios-swift.json +8 -8
  376. package/scripts/fixtures/cli-golden/mavis/java.json +8 -8
  377. package/scripts/fixtures/cli-golden/mavis/mcp-ts.json +8 -8
  378. package/scripts/fixtures/cli-golden/mavis/next.json +10 -9
  379. package/scripts/fixtures/cli-golden/mavis/nuxt.json +9 -9
  380. package/scripts/fixtures/cli-golden/mavis/php-hexagonal.json +8 -8
  381. package/scripts/fixtures/cli-golden/mavis/php-laravel.json +8 -8
  382. package/scripts/fixtures/cli-golden/mavis/svelte.json +9 -9
  383. package/scripts/fixtures/cli-golden/opencode/android-kotlin.json +8 -8
  384. package/scripts/fixtures/cli-golden/opencode/go.json +8 -8
  385. package/scripts/fixtures/cli-golden/opencode/ios-swift.json +8 -8
  386. package/scripts/fixtures/cli-golden/opencode/java.json +8 -8
  387. package/scripts/fixtures/cli-golden/opencode/mcp-ts.json +8 -8
  388. package/scripts/fixtures/cli-golden/opencode/next.json +10 -9
  389. package/scripts/fixtures/cli-golden/opencode/nuxt.json +9 -9
  390. package/scripts/fixtures/cli-golden/opencode/php-hexagonal.json +8 -8
  391. package/scripts/fixtures/cli-golden/opencode/php-laravel.json +8 -8
  392. package/scripts/fixtures/cli-golden/opencode/svelte.json +9 -9
  393. package/scripts/test-agent-task-metrics-hooks.mjs +167 -0
  394. package/scripts/test-chain-team-phases-coverage.mjs +129 -0
  395. package/scripts/test-parallel-plan-fixtures.mjs +173 -0
  396. package/scripts/test-preset-prompt-persistence-fixtures.mjs +58 -1
@@ -140,6 +140,16 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
140
140
  | `scope` | e.g. `unit-in-dev`, `e2e-only`, `preset-artifacts-only` — passed to developer/qa |
141
141
  | `model` | `cheap` \| `standard` \| `strong` — optional tier override |
142
142
 
143
+ ## Parallel scheduling (graph mode)
144
+
145
+ `pipeline.json` may carry an optional step graph: `steps[].id`, `steps[].taskIds[]`, `steps[].dependsOn[]`, `steps[].writeScopes[]`. While no step declares `dependsOn`, the hook keeps the legacy linear advance; any occurrence switches it to graph mode.
146
+
147
+ - The hook recomputes the **ready queue** on every stop: steps whose `dependsOn` are satisfied, not yet satisfied, not in flight, not skipped, not blocked.
148
+ - The **wave** is the join unit; a single `parallel: true` step is a one-step wave. `status.joinedSlots` is the persistent satisfaction ledger; `status.waveSteps`/`waveId` name the in-flight wave; `status.blockedSteps` excludes a blocked step.
149
+ - Set `parallel: true` only for a set proven conflict-free (disjoint `writeScopes`, distinct agents and `artifactOutputIds`); never place `mockup-reviewer` in a parallel group.
150
+ - **No advance before reconciliation.** Invoke exactly the handoff's agent list (a wave in one turn, multiple Task calls) and do not start a next step from your own reasoning until the hook records the join.
151
+ - A retry re-dispatches only unsatisfied slots: a satisfied sibling keeps its entry and terminal metric and is never re-invoked.
152
+
143
153
  ## Rules (strict)
144
154
 
145
155
  1. **`/task` always starts with task-router** (except user says "skip router" with documented pipeline).
@@ -151,7 +161,7 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
151
161
  7. On `validation_failed` from `build-verifier`: hook sets `retryAfterFix: build-verifier` → developer → build-verifier.
152
162
  8. When all steps complete, suggest `/technical-retro <slug>`.
153
163
  9. If `autoChain: false` in pipeline, do not rely on hook — manual step only.
154
- 10. **Persist the verbatim original prompt.** Every `/task` and every routed work request writes the user's raw prompt to `.ai.local/team/tasks/<slug>/prompt.md` during slug bootstrap (write-if-absent; never overwrite on resume). Not a manifest `artifacts[]` body — register the path on the `routing` entry. See **agent-artifact-contracts** § Prompt artifact.
164
+ 10. **Persist the verbatim original prompt.** Every `/task` and every routed work request writes the user's raw prompt to `.ai.local/team/tasks/<slug>/prompt.md` during slug bootstrap (write-if-absent; never overwrite on resume). Not a manifest `artifacts[]` body — register the path on the `routing` entry. See **agent-artifact-contracts** § Prompt artifact. Also append every **subsequent user-authored** prompt for the same slug — a new user message while the slug is active, `/task-continue` arguments, human-gate feedback, a clarification answer — to the append-only `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; never rewrite or duplicate an entry; never log machine-generated hook `followup_message` or empty/argument-less invocations). Register its path on the `routing` entry. See **agent-artifact-contracts** § Prompt log.
155
165
  11. **Answer the user in the resolved dialogue language for the whole task.** Resolve once at task start
156
166
  (`.ai.local` `## Language` → prompt language → English) and pass it to every step; `/task-continue` keeps
157
167
  it. Never ask the user to pick a language. Development, reasoning, and artifacts stay English. See
@@ -160,6 +170,7 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
160
170
  ## Team artifact I/O (Cursor Shell sandbox)
161
171
 
162
172
  - **Persist the original prompt.** For **every** task — `/task` or a routed work request — write the user's **verbatim** prompt to `.ai.local/team/tasks/<slug>/prompt.md` during slug bootstrap (write-if-absent; never overwrite on resume). The header is additive provenance only; the fenced text block holds the user's words unchanged. Not a manifest `artifacts[]` body — the path lives on the `routing` entry. See **agent-artifact-contracts** § Prompt artifact.
173
+ - **Append follow-up prompts.** When a user-authored prompt arrives for an active slug (new message, `/task-continue` args, gate feedback, clarification), append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` — `seq` = current max + 1, create on first append, never rewrite or duplicate an entry, never touch `prompt.md`. Exclude hook `followup_message` and empty/argument-less invocations. Not a manifest `artifacts[]` body — the path lives on the `routing` entry. See **agent-artifact-contracts** § Prompt log.
163
174
  - **Answer in the resolved dialogue language.** Resolve once at task start (`.ai.local` `## Language` →
164
175
  prompt language → English; mixed → dominant; nearest `.ai.local` wins) and reuse it for every user-facing
165
176
  message and `/task-continue`. Record the tag in the `prompt.md` header (`language: <BCP-47>`) + a
@@ -17,6 +17,7 @@ Shared `/task` runtime for Cursor, Claude, Mavis, and OpenCode. Seeded at **`.ai
17
17
  metrics.json # hook-owned append-only ledger
18
18
  artifact-manifest.json # producer receipts
19
19
  prompt.md # verbatim original ask + resolved `language: <BCP-47>` header (write-if-absent; write point = /task Slug bootstrap; path on the routing entry)
20
+ prompt-log.md # append-only ledger of subsequent user-authored prompts (orchestrator-written; created on first follow-up; path on the routing entry)
20
21
  brief.md, decomposition.md, implementation.md, review.md, …
21
22
  .memlog.md # optional agent notes (hook does not parse)
22
23
  ```
@@ -53,7 +54,7 @@ Bootstrap a slug by **writing** `pipeline.json` (editor Write tool). Do not `mkd
53
54
 
54
55
  ## status.json
55
56
 
56
- Prefer `phase: executing`. States: `in_progress`, `completed`, `awaiting_approval` (`/task-continue`), `changes_requested`, `validation_failed`.
57
+ Prefer `phase: executing`. States: `in_progress`, `completed`, `awaiting_approval` (`/task-continue`), `changes_requested`, `validation_failed`, `blocked` (graph mode still dispatches independent ready steps), `awaiting_artifact_receipt`.
57
58
 
58
59
  ## Commands
59
60
 
@@ -77,6 +78,8 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
77
78
 
78
79
  `pipeline.json` MAY carry these additive, **hook-ignored** fields (schema v1 ignores unknown fields; the hook never parses them): `epics[]` (staging + exit criteria), `planRevision` (current plan rev), `contextBudget` (budget / checkpoint note).
79
80
 
81
+ `pipeline.json` `steps[]` MAY also carry the optional **step graph**: `id`, `taskIds[]`, `dependsOn[]`, `writeScopes[]`. While no step declares `dependsOn`, the hook keeps the linear pass; any occurrence switches it to graph mode, where the hook computes the ready queue and dispatches each conflict-free wave (one turn, multiple Task calls). `writeScopes` is the declared write surface that proves conflict-freedom (see shared-core `agent-team/plan-graph.md` § Pipeline step graph / § Conflict model). The hook records satisfaction in `status.joinedSlots` and names the in-flight wave in `status.waveSteps` / `status.waveId`.
82
+
80
83
  **Checkpoint / resume:** progress is checkpointed to `tasks/<slug>/.memlog.md` (`## <date>` + `event:` entries) and the `artifact-manifest.json` `implementation` entry (`authoritativePaths`). A resumed run reads both and continues at the first stage whose exit criteria are unmet.
81
84
 
82
85
  **Self-review / re-anchor:** each producing agent records a `## Self-review` block in the artifact it owns (`brief.md` / `implementation.md` / `debug-report.md` / `validation-report.md` / `review.md`) and, on detected context loss / excess, a re-anchor line in `.memlog.md` — `event:` (no plan change) or `decision: replan rev N → N+1` (plan change). No hook/lifecycle field is added.
@@ -29,7 +29,7 @@ Before decomposing: state the **goal frame** (goal, user value, success criteria
29
29
 
30
30
  <!-- shared-core: agent-team/plan-graph.md -->
31
31
 
32
- Decompose as a **dependency graph**: each task carries `dependsOn[]`, the edges form a **DAG** with a critical path and parallelizable groups. Large flows are staged into **Epics / stages** with **exit criteria** (ratchet: bounded tasks stay flat). Plan revision is a named, auditable operation (`decision: replan rev N → N+1` in `.memlog.md`, then re-gate).
32
+ Decompose as a **dependency graph**: each task carries `dependsOn[]`, the edges form a **DAG** with a critical path and parallelizable groups. Large flows are staged into **Epics / stages** with **exit criteria** (ratchet: bounded tasks stay flat). Plan revision is a named, auditable operation (`decision: replan rev N → N+1` in `.memlog.md`, then re-gate). Parallelizable groups are **proven conflict-free** before the router may mark them `parallel: true` — disjoint declared `writeScopes`, distinct agents and `artifactOutputIds`, and no producer→consumer edge. Keep task IDs stable so `steps[].taskIds` / `steps[].dependsOn[]` reuse this vocabulary (see **plan-graph** § Conflict model).
33
33
 
34
34
  ## Context budget & iterative refinement
35
35
 
@@ -118,6 +118,16 @@ Keep top-level `profile` and emit this top-level object in every new `pipeline.j
118
118
  - **Always build-verifier** after developer (or after ci-investigator/debugger if they changed code) for `feature`, `bugfix`, `refactor`, `migration`, `a11y`.
119
119
  - **skipIf:** `debugger.fixed` on developer (bugfix); `ci-investigator.resolved` (ci-fix).
120
120
 
121
+ ## Parallel step graph (emission rule)
122
+
123
+ A pipeline may carry a step graph. Emit it only for the **architectural** class with more than one independent work package; bounded/spike pipelines stay linear.
124
+
125
+ - Give steps `id` (the decomposition task ID when 1:1), `taskIds` (the analyst's decomposition task IDs), `dependsOn` (step IDs or `taskIds` that must finish first), and `writeScopes` (repo-relative paths the step may write, `<slug>` the only placeholder).
126
+ - Set `parallel: true` (with an `agent` array) **only** for a set proven conflict-free: disjoint declared `writeScopes`, distinct agents, distinct `artifactOutputIds`, none of `status.json` / `metrics.json` / `artifact-manifest.json` / `.metrics-receipts.json` in any scope.
127
+ - A producer → consumer artifact pair is a `dependsOn` edge, never a parallel group.
128
+ - **Never** put `mockup-reviewer` in a parallel group — its FAIL gate is serial.
129
+ - Reference fixture: `team/fixtures/feature-parallel.json` (graph + one `parallel: true` step).
130
+
121
131
  ## Model tiers (`steps[].model`)
122
132
 
123
133
  Optional per-step field: `"model": "cheap" | "standard" | "strong"`. Omit → agent frontmatter default (see **Model matrix** in `agents/README.md`).
@@ -39,7 +39,7 @@ printf '%s\n' '{"status":"completed","action":"end_human_gate","activateNext":tr
39
39
 
40
40
  ## Checkpoint & resume
41
41
 
42
- Resume from the on-disk checkpoint, not from chat: read `.ai.local/team/tasks/<slug>/artifact-manifest.json` (authoritative paths per producer) and `.memlog.md` (`## <date>` + `event:` entries), skip completed waves, and continue at the first stage whose exit criteria are unmet. Record produced paths on the `implementation` manifest entry as you go. Do **not** overwrite or duplicate `.ai.local/team/tasks/<slug>/prompt.md` — it records the original ask (write-if-absent).
42
+ Resume from the on-disk checkpoint, not from chat: read `.ai.local/team/tasks/<slug>/artifact-manifest.json` (authoritative paths per producer) and `.memlog.md` (`## <date>` + `event:` entries), skip completed waves, and continue at the first stage whose exit criteria are unmet. Record produced paths on the `implementation` manifest entry as you go. Do **not** overwrite or duplicate `.ai.local/team/tasks/<slug>/prompt.md` — it records the original ask (write-if-absent). Append the `/task-continue` arguments (when present) and any gate feedback verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; skip when the invocation carries no new user words).
43
43
 
44
44
  Plan revision during execution is a named, auditable operation: an evaluation oracle failing twice, a scope/requirement change, or a newly discovered dependency triggers `decision: replan rev N → N+1` in `.memlog.md`, an edit to `decomposition.md` (+ optional `planRevision`), and a **re-run of the affected gate**.
45
45
 
@@ -27,7 +27,7 @@ Examples:
27
27
 
28
28
  ## Procedure
29
29
 
30
- 1. **Slug** — kebab-case from the description (≤48 characters). Create `.ai.local/team/tasks/<slug>/` via **Write** (e.g. placeholder `pipeline.json` or empty marker) — runtime/hook owns `status.json` — **not** via Shell `mkdir` (sandbox → `Operation not permitted`). Also write the user's **verbatim** prompt to `.ai.local/team/tasks/<slug>/prompt.md` (write-if-absent; never overwrite on resume; not a manifest `artifacts[]` body).
30
+ 1. **Slug** — kebab-case from the description (≤48 characters). Create `.ai.local/team/tasks/<slug>/` via **Write** (e.g. placeholder `pipeline.json` or empty marker) — runtime/hook owns `status.json` — **not** via Shell `mkdir` (sandbox → `Operation not permitted`). Also write the user's **verbatim** prompt to `.ai.local/team/tasks/<slug>/prompt.md` (write-if-absent; never overwrite on resume; not a manifest `artifacts[]` body). Do **not** create the follow-up ledger `prompt-log.md` here; it is created on the first subsequent user-authored prompt (see **agent-artifact-contracts** § Prompt log).
31
31
  2. **Router** — invoke subagent **task-router** with the task description and slug path.
32
32
  3. **Plan** — show the user the table from `pipeline.json`: intent, steps, skipped, humanGates.
33
33
  4. **Intent retro** — if `intent === "retro"`, run `/technical-retro` and **stop**.
@@ -55,6 +55,9 @@ const statusPath = path.join(taskDir, 'status.json');
55
55
  const pipelinePath = path.join(taskDir, 'pipeline.json');
56
56
  const METRICS_PATH = path.join(taskDir, 'metrics.json');
57
57
  const METRICS_LOCK = `${METRICS_PATH}.lock`;
58
+ // Pipeline step graph is assigned once pipeline.json is parsed; declared early so the
59
+ // gate-resume branch can schedule from the graph before the main parse point.
60
+ let steps = [];
58
61
 
59
62
  if (!fs.existsSync(statusPath)) {
60
63
  process.stdout.write('{}');
@@ -189,15 +192,16 @@ function artifactOutputIdFor(step, agent) {
189
192
  if (step?.artifactOutputIds && typeof step.artifactOutputIds[agent] === 'string') return step.artifactOutputIds[agent];
190
193
  return DEFAULT_ARTIFACT_OUTPUT_IDS[agent] || agent;
191
194
  }
192
- function activateAttempts(step, stepIndex) {
193
- const active = { ...(status.activeAttempts || {}) }; const agents = getStepAgents(step);
194
- const parallelGroupId = step.parallel && agents.length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
195
+ function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null) {
196
+ const active = { ...(status.activeAttempts || {}) };
197
+ const agents = Array.isArray(agentsOverride) && agentsOverride.length > 0 ? agentsOverride : getStepAgents(step);
198
+ const parallelGroupId = step.parallel && getStepAgents(step).length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
195
199
  for (const agent of agents) {
196
200
  const attempt = nextAttemptOrdinal(stepIndex, agent); const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
197
201
  status.metricsRunId = runId; const attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
198
202
  if (active[attemptId]) continue;
199
- active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId };
200
- appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, source: 'hook', attributionConfidence: 'high' });
203
+ active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId, waveId: waveId || null };
204
+ appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, waveId: waveId || null, source: 'hook', attributionConfidence: 'high' });
201
205
  }
202
206
  status.activeAttempts = active;
203
207
  }
@@ -293,8 +297,8 @@ function reconcileStatusFromManifest(agent, step, resolved) {
293
297
  return status.state;
294
298
  }
295
299
 
296
- function finishActiveAttempt() {
297
- const resolved = resolvedAttempt(); if (!resolved) return null;
300
+ function finishActiveAttempt(forced) {
301
+ const resolved = forced || resolvedAttempt(); if (!resolved) return null;
298
302
  const durationMs = Date.parse(now) - Date.parse(resolved.entry.startedAt);
299
303
  const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
300
304
  appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence });
@@ -374,6 +378,208 @@ function findNextExecutableStep(steps, startIdx, dir) {
374
378
  return null;
375
379
  }
376
380
 
381
+ // --- Parallel scheduling & conflict model (mirrors _shared/core/agent-team/plan-graph.md) ---
382
+ function isGraphMode() { return steps.some((step) => step && Array.isArray(step.dependsOn)); }
383
+ function graphSlotKey(stepIndex, agent) { return `${stepIndex}:${agent}`; }
384
+ function readJoinedSlots() { return { ...(status.joinedSlots || {}) }; }
385
+ function isSlotSatisfied(stepIndex, agent) { return Boolean((status.joinedSlots || {})[graphSlotKey(stepIndex, agent)]); }
386
+ function resolveStepIndex(dep) {
387
+ for (let i = 0; i < steps.length; i += 1) if (steps[i] && steps[i].id === dep) return i;
388
+ for (let i = 0; i < steps.length; i += 1) {
389
+ const ids = Array.isArray(steps[i]?.taskIds) ? steps[i].taskIds : [];
390
+ if (ids.includes(dep)) return i;
391
+ }
392
+ return -1;
393
+ }
394
+ function isStepSkipped(stepIndex) {
395
+ if (Array.isArray(status.skippedSteps) && status.skippedSteps.includes(stepIndex)) return true;
396
+ return skipIfMatches(steps[stepIndex]?.skipIf, taskDir);
397
+ }
398
+ function isStepSatisfied(stepIndex) {
399
+ const step = steps[stepIndex];
400
+ if (!step) return false;
401
+ if (isStepSkipped(stepIndex)) return true;
402
+ return getStepAgents(step).every((agent) => isSlotSatisfied(stepIndex, agent));
403
+ }
404
+ function pendingStepIndexes() { return steps.map((_, index) => index).filter((index) => !isStepSatisfied(index)); }
405
+ function unsatisfiedAgents(stepIndex) {
406
+ const step = steps[stepIndex];
407
+ if (!step) return [];
408
+ return getStepAgents(step).filter((agent) => !isSlotSatisfied(stepIndex, agent));
409
+ }
410
+ function declaredScopes(step) {
411
+ return Array.isArray(step?.writeScopes) ? step.writeScopes.filter((scope) => typeof scope === 'string' && scope.length > 0) : [];
412
+ }
413
+ function normalizeScope(scope) { return String(scope).replace(/\/+$/, ''); }
414
+ function scopesOverlap(left, right) {
415
+ const a = normalizeScope(left); const b = normalizeScope(right);
416
+ return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
417
+ }
418
+ function stepsConflict(leftIndex, rightIndex) {
419
+ if (leftIndex === rightIndex) return true;
420
+ const leftStep = steps[leftIndex]; const rightStep = steps[rightIndex];
421
+ const leftAgents = getStepAgents(leftStep); const rightAgents = getStepAgents(rightStep);
422
+ if (leftAgents.some((agent) => rightAgents.includes(agent))) return true;
423
+ const leftOutputs = new Set(leftAgents.map((agent) => artifactOutputIdFor(leftStep, agent)));
424
+ if (rightAgents.some((agent) => leftOutputs.has(artifactOutputIdFor(rightStep, agent)))) return true;
425
+ // An undeclared scope is unknown, and an unknown unit conflicts with everything (safe default).
426
+ const leftScopes = declaredScopes(leftStep); const rightScopes = declaredScopes(rightStep);
427
+ if (leftScopes.length === 0 || rightScopes.length === 0) return true;
428
+ for (const a of leftScopes) for (const b of rightScopes) if (scopesOverlap(a, b)) return true;
429
+ return false;
430
+ }
431
+ function selectWave(candidates) {
432
+ const wave = []; const deferred = [];
433
+ for (const index of candidates) {
434
+ if (wave.every((chosen) => !stepsConflict(chosen, index))) wave.push(index);
435
+ else deferred.push(index);
436
+ }
437
+ return { wave, deferred };
438
+ }
439
+ function invalidateFrom(stepIndex, preserveStepIndex) {
440
+ const remove = new Set([stepIndex]);
441
+ let changed = true;
442
+ while (changed) {
443
+ changed = false;
444
+ for (let i = 0; i < steps.length; i += 1) {
445
+ if (remove.has(i)) continue;
446
+ const deps = Array.isArray(steps[i]?.dependsOn) ? steps[i].dependsOn : [];
447
+ if (deps.some((dep) => { const j = resolveStepIndex(dep); return j >= 0 && remove.has(j); })) { remove.add(i); changed = true; }
448
+ }
449
+ }
450
+ // Preserve the requesting step's satisfied slots so a sibling is never re-invoked.
451
+ if (Number.isInteger(preserveStepIndex)) remove.delete(preserveStepIndex);
452
+ const slots = readJoinedSlots();
453
+ const removedAgents = new Set();
454
+ for (const key of Object.keys(slots)) {
455
+ const index = Number(key.split(':')[0]);
456
+ if (remove.has(index)) { removedAgents.add(slots[key].agent); delete slots[key]; }
457
+ }
458
+ status.joinedSlots = slots;
459
+ status.parallelCompleted = (status.parallelCompleted || []).filter((agent) => !removedAgents.has(agent));
460
+ return remove;
461
+ }
462
+ function computeReadySteps() {
463
+ if (!isGraphMode()) return [];
464
+ const inFlight = new Set(Object.values(status.activeAttempts || {}).map((entry) => entry.stepIndex));
465
+ const blocked = new Set(Array.isArray(status.blockedSteps) ? status.blockedSteps : []);
466
+ const skipped = new Set(Array.isArray(status.skippedSteps) ? status.skippedSteps : []);
467
+ const ready = [];
468
+ for (let i = 0; i < steps.length; i += 1) {
469
+ if (blocked.has(i) || inFlight.has(i)) continue;
470
+ if (skipIfMatches(steps[i].skipIf, taskDir)) {
471
+ if (!skipped.has(i)) { recordSkippedStep(steps[i], i); skipped.add(i); }
472
+ continue;
473
+ }
474
+ if (isStepSatisfied(i)) continue;
475
+ const deps = Array.isArray(steps[i].dependsOn) ? steps[i].dependsOn : [];
476
+ if (deps.every((dep) => { const j = resolveStepIndex(dep); return j >= 0 && isStepSatisfied(j); })) ready.push(i);
477
+ }
478
+ status.skippedSteps = [...skipped];
479
+ return ready;
480
+ }
481
+ function handoffForWave(units, waveId) {
482
+ const labels = units.map((unit) => `${steps[unit.stepIndex].id || `step-${unit.stepIndex}`}=${unit.agent}`);
483
+ const attemptIds = Object.entries(status.activeAttempts || {})
484
+ .filter(([, entry]) => units.some((unit) => unit.stepIndex === entry.stepIndex && unit.agent === entry.agent))
485
+ .map(([attemptId, entry]) => `${entry.agent}=${attemptId}`);
486
+ const outputIds = units.map((unit) => `${unit.agent}=${artifactOutputIdFor(steps[unit.stepIndex], unit.agent)}`);
487
+ const inputIds = [...new Set(units.flatMap((unit) => (Array.isArray(steps[unit.stepIndex].artifactInputIds) ? steps[unit.stepIndex].artifactInputIds : [])))];
488
+ return (
489
+ `Invoke IN PARALLEL (one message, multiple Task calls): ${labels.join(' AND ')} for slug "${slug}"${waveId ? ` (waveId=${waveId})` : ''}. ` +
490
+ `Each agent writes its artifact and owned receipt; the hook records slot joins from stops. Do not mutate status.json lifecycle fields. ` +
491
+ `Artifact inputs: ${inputIds.length > 0 ? inputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${outputIds.join('; ')}. ` +
492
+ `Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration.`
493
+ );
494
+ }
495
+ function blockedNotice(blockedIndex, agent) {
496
+ const gated = [];
497
+ for (let i = 0; i < steps.length; i += 1) {
498
+ if (i === blockedIndex || isStepSatisfied(i)) continue;
499
+ const deps = Array.isArray(steps[i].dependsOn) ? steps[i].dependsOn : [];
500
+ if (deps.some((dep) => resolveStepIndex(dep) === blockedIndex)) gated.push(steps[i].id || `step-${i}`);
501
+ }
502
+ return `Step ${blockedIndex} (${agent}) is blocked for slug "${slug}"${gated.length > 0 ? ` and gates: ${gated.join(', ')}` : ''}. No independent ready step remains. Resume only via /task-continue ${slug}.`;
503
+ }
504
+ function noProgressNotice() {
505
+ const pending = pendingStepIndexes().map((index) => steps[index].id || `step-${index}`);
506
+ return `No schedulable step remains for slug "${slug}" (unsatisfied: ${pending.join(', ')}). Resume only via /task-continue ${slug}.`;
507
+ }
508
+ function dispatchReadyWave(prefixMessage) {
509
+ const ready = computeReadySteps();
510
+ if (ready.length === 0) return false;
511
+ const { wave, deferred } = selectWave(ready);
512
+ if (deferred.length > 0) {
513
+ appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: 'ready set not conflict-free or writeScopes undeclared', source: 'hook', attributionConfidence: 'fallback' });
514
+ }
515
+ // Slot-filtered dispatch: only unsatisfied (stepIndex, agent) slots are invoked.
516
+ const units = wave.flatMap((stepIndex) => unsatisfiedAgents(stepIndex).map((agent) => ({ stepIndex, agent })));
517
+ if (units.length === 0) return false;
518
+ const first = units[0].stepIndex;
519
+ const waveId = `${status.metricsRunId || slug}:wave-${first}`;
520
+ for (const unit of units) activateAttempts(steps[unit.stepIndex], unit.stepIndex, units.length > 1 ? waveId : null, [unit.agent]);
521
+ writeStatus({
522
+ pipelineIndex: first,
523
+ currentAgent: units[0].agent,
524
+ phase: 'executing',
525
+ state: 'in_progress',
526
+ awaitingHumanGate: false,
527
+ parallelCompleted: [],
528
+ parallelOutcomes: {},
529
+ waveSteps: wave,
530
+ waveId,
531
+ });
532
+ const stepIndexes = [...new Set(units.map((unit) => unit.stepIndex))];
533
+ appendMetric({ type: 'parallel_wave_started', at: now, waveId, stepIndexes, agents: units.map((unit) => unit.agent), source: 'hook', attributionConfidence: 'high' });
534
+ let message;
535
+ if (units.length === 1) message = handoffForAgent(units[0].agent, steps[first]?.scope, steps[first]);
536
+ else if (stepIndexes.length === 1 && steps[first].parallel && units.length === getStepAgents(steps[first]).length) message = handoffForParallelStep(steps[first]);
537
+ else message = handoffForWave(units, waveId);
538
+ out(prefixMessage ? `${prefixMessage} ${message}` : message);
539
+ return true;
540
+ }
541
+ function resolveProducerStepIndex(agent, fromIndex) {
542
+ const seen = new Set([fromIndex]);
543
+ const stack = [fromIndex];
544
+ let best = -1;
545
+ while (stack.length > 0) {
546
+ const node = stack.pop();
547
+ const deps = Array.isArray(steps[node]?.dependsOn) ? steps[node].dependsOn : [];
548
+ for (const dep of deps) {
549
+ const j = resolveStepIndex(dep);
550
+ if (j < 0 || seen.has(j)) continue;
551
+ seen.add(j);
552
+ if (getStepAgents(steps[j]).includes(agent)) best = Math.max(best, j);
553
+ stack.push(j);
554
+ }
555
+ }
556
+ return best >= 0 ? best : -1;
557
+ }
558
+ function repairUnattributableStop() {
559
+ const entries = Object.entries(status.activeAttempts || {});
560
+ if (entries.length === 0) return null;
561
+ const bindByAgent = (agent) => {
562
+ if (!agent) return null;
563
+ const matches = entries.filter(([, entry]) => entry.agent === agent);
564
+ return matches.length === 1 ? { attemptId: matches[0][0], entry: matches[0][1], confidence: 'fallback', repaired: true } : null;
565
+ };
566
+ const payloadAgent = typeof hookInput.agentType === 'string' ? hookInput.agentType : (typeof hookInput.agent_type === 'string' ? hookInput.agent_type : null);
567
+ const byPayload = bindByAgent(payloadAgent);
568
+ if (byPayload) return byPayload;
569
+ if (Array.isArray(status.waveSteps) && status.waveSteps.length > 0) {
570
+ const outcomes = status.parallelOutcomes || {};
571
+ const unrecorded = status.waveSteps.flatMap((index) => getStepAgents(steps[index])).filter((agent) => !outcomes[agent]);
572
+ if (unrecorded.length === 1) { const bySole = bindByAgent(unrecorded[0]); if (bySole) return bySole; }
573
+ }
574
+ const byCurrent = bindByAgent(status.currentAgent);
575
+ if (byCurrent) return byCurrent;
576
+ return null;
577
+ }
578
+ function repairHandoffMessage() {
579
+ const listing = Object.entries(status.activeAttempts || {}).map(([attemptId, entry]) => `${entry.agent}=${attemptId}`).join('; ');
580
+ return `Parallel stop could not be attributed for slug "${slug}": in-flight attempts ${listing}; no payload attemptId and no bound receipt for the finished agent. Resume deterministically: append a minimal { attemptId, outcome } receipt for the agent that just finished to .ai.local/team/tasks/${slug}/.metrics-receipts.json, then re-run the installed hooks/chain-team-phases.sh with that attemptId. Do not edit status.json manually.`;
581
+ }
582
+
377
583
  const AGENT_HANDOFF = {
378
584
  'task-analyst': (s) =>
379
585
  `Invoke task-analyst for slug "${s}". Write brief.md and decomposition.md under .ai.local/team/tasks/${s}/. ` +
@@ -588,6 +794,24 @@ if (hookInput.action === 'end_human_gate') {
588
794
  try { resumePipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8')); } catch {}
589
795
  if (resumePipeline) {
590
796
  const resumeSteps = resumePipeline.steps || [];
797
+ if (resumeSteps.some((step) => step && Array.isArray(step.dependsOn))) {
798
+ steps = resumeSteps;
799
+ status.blockedSteps = [];
800
+ status.parallelCompleted = [];
801
+ status.parallelOutcomes = {};
802
+ status.waveSteps = [];
803
+ status.waveId = null;
804
+ if (dispatchReadyWave()) process.exit(0);
805
+ if (pendingStepIndexes().length === 0) {
806
+ status.state = 'completed';
807
+ completeTaskMetrics();
808
+ writeStatus({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
809
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
810
+ process.exit(0);
811
+ }
812
+ out(noProgressNotice());
813
+ process.exit(0);
814
+ }
591
815
  const resumeStart = (typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0) + 1;
592
816
  const resumeNext = findNextExecutableStep(resumeSteps, resumeStart, taskDir);
593
817
  if (resumeNext) {
@@ -686,7 +910,7 @@ if (pipelineParseError) {
686
910
  legacyFlow();
687
911
  }
688
912
 
689
- const steps = pipeline.steps || [];
913
+ steps = pipeline.steps || [];
690
914
  const initialIdx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
691
915
  const initialStep = steps[initialIdx];
692
916
  const activeAttemptCountBeforeFinish = Object.keys(status.activeAttempts || {}).length;
@@ -703,10 +927,23 @@ if (status.state === 'awaiting_artifact_receipt') {
703
927
  process.stdout.write('{}');
704
928
  process.exit(0);
705
929
  }
706
- const finishedAttempt = finishActiveAttempt();
707
- if (!finishedAttempt && (hookInput.attemptId || activeAttemptCountBeforeFinish > 0)) {
708
- process.stdout.write('{}');
709
- process.exit(0);
930
+ let finishedAttempt = finishActiveAttempt();
931
+ if (!finishedAttempt && activeAttemptCountBeforeFinish > 0) {
932
+ if (!hookInput.attemptId) {
933
+ const repaired = repairUnattributableStop();
934
+ if (repaired) {
935
+ appendMetric({ type: 'parallel_attribution_repair', at: now, attemptIds: [repaired.attemptId], source: 'hook', attributionConfidence: 'fallback' });
936
+ reconcileStatusFromManifest(repaired.entry.agent, steps[repaired.entry.stepIndex], repaired);
937
+ finishedAttempt = finishActiveAttempt(repaired);
938
+ } else {
939
+ writeStatus({});
940
+ out(repairHandoffMessage());
941
+ process.exit(0);
942
+ }
943
+ } else {
944
+ process.stdout.write('{}');
945
+ process.exit(0);
946
+ }
710
947
  }
711
948
  endHumanGateIfResumed();
712
949
  if (steps.length === 0 || pipeline.autoChain === false) {
@@ -742,10 +979,28 @@ function scheduleRetry(agent, retryAfterFix, predecessor, explicitStepIndex = nu
742
979
  const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
743
980
  const currentStep = steps[idx];
744
981
  const completedAgent = finishedAttempt?.entry?.agent || status.currentAgent || getStepAgents(currentStep)[0];
982
+ const completedStepIndex = Number.isInteger(finishedAttempt?.entry?.stepIndex) ? finishedAttempt.entry.stepIndex : idx;
745
983
  const stepAgents = getStepAgents(currentStep);
984
+ const activeWave = isGraphMode() && Array.isArray(status.waveSteps) && status.waveSteps.filter((i) => Number.isInteger(i) && steps[i]).length > 0
985
+ ? status.waveSteps.filter((i) => Number.isInteger(i) && steps[i])
986
+ : null;
987
+ const waveIndexes = activeWave
988
+ ? activeWave
989
+ : (currentStep?.parallel && stepAgents.length > 1
990
+ ? [idx]
991
+ : (isGraphMode() && finishedAttempt ? [completedStepIndex] : null));
746
992
 
747
- if (currentStep?.parallel && stepAgents.length > 1) {
993
+
994
+ if (waveIndexes) {
995
+ const waveAgents = waveIndexes.flatMap((i) => getStepAgents(steps[i]));
748
996
  const done = [...(status.parallelCompleted || [])];
997
+ if (isGraphMode()) {
998
+ for (const waveStep of waveIndexes) {
999
+ for (const waveAgent of getStepAgents(steps[waveStep])) {
1000
+ if (isSlotSatisfied(waveStep, waveAgent) && !done.includes(waveAgent)) done.push(waveAgent);
1001
+ }
1002
+ }
1003
+ }
749
1004
  const outcomes = { ...(status.parallelOutcomes || {}) };
750
1005
  if (finishedAttempt && completedAgent) {
751
1006
  if (!done.includes(completedAgent)) done.push(completedAgent);
@@ -755,21 +1010,39 @@ if (currentStep?.parallel && stepAgents.length > 1) {
755
1010
  confidence: finishedAttempt.confidence,
756
1011
  };
757
1012
  }
1013
+ if (finishedAttempt && completedAgent && isGraphMode() && (finishedAttempt.outcome || status.state) === 'completed') {
1014
+ const completedSlots = readJoinedSlots();
1015
+ completedSlots[graphSlotKey(completedStepIndex, completedAgent)] = {
1016
+ agent: completedAgent,
1017
+ stepIndex: completedStepIndex,
1018
+ attemptId: finishedAttempt.attemptId,
1019
+ outcome: 'completed',
1020
+ };
1021
+ status.joinedSlots = completedSlots;
1022
+ appendMetric({ type: 'step_joined', at: now, stepIndex: completedStepIndex, slotKeys: [graphSlotKey(completedStepIndex, completedAgent)], attemptIds: [finishedAttempt.attemptId], source: 'hook', attributionConfidence: 'high' });
1023
+ }
758
1024
  writeStatus({ parallelCompleted: done, parallelOutcomes: outcomes });
759
- const remaining = stepAgents.filter((agent) => !done.includes(agent));
1025
+ const remaining = waveAgents.filter((agent) => !done.includes(agent));
760
1026
  if (remaining.length > 0) {
761
1027
  process.stdout.write('{}');
762
1028
  process.exit(0);
763
1029
  }
764
1030
 
765
- const blockedProducer = stepAgents.find((agent) => outcomes[agent]?.outcome === 'blocked');
1031
+ const blockedProducer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'blocked');
766
1032
  if (blockedProducer) {
1033
+ if (isGraphMode()) {
1034
+ const blockedStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(blockedProducer));
1035
+ status.blockedSteps = [...new Set([...(status.blockedSteps || []), blockedStepIndex])];
1036
+ writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: blockedProducer, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
1037
+ if (!dispatchReadyWave(`Step ${blockedStepIndex} (${blockedProducer}) is blocked; proceeding with independent ready steps.`)) out(blockedNotice(blockedStepIndex, blockedProducer));
1038
+ process.exit(0);
1039
+ }
767
1040
  writeStatus({ parallelCompleted: [], parallelOutcomes: {}, state: 'blocked', phase: 'blocked', currentAgent: blockedProducer });
768
1041
  process.stdout.write('{}');
769
1042
  process.exit(0);
770
1043
  }
771
1044
 
772
- const retryReviewer = stepAgents.find((agent) => outcomes[agent]?.outcome === 'changes_requested');
1045
+ const retryReviewer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'changes_requested');
773
1046
  if (retryReviewer === 'mockup-reviewer') {
774
1047
  beginHumanGate();
775
1048
  writeStatus({
@@ -778,11 +1051,34 @@ if (currentStep?.parallel && stepAgents.length > 1) {
778
1051
  currentAgent: 'mockup-reviewer',
779
1052
  parallelCompleted: [],
780
1053
  parallelOutcomes: {},
1054
+ waveSteps: [],
1055
+ waveId: null,
781
1056
  });
782
1057
  out(`Mockup review FAIL for slug "${slug}". Read mockup-review.md. Resume only via /task-continue. Do not retry feature-developer.`);
783
1058
  process.exit(0);
784
1059
  }
785
1060
  if (retryReviewer) {
1061
+ if (isGraphMode()) {
1062
+ const reviewerStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(retryReviewer));
1063
+ const producerIndex = resolveProducerStepIndex('feature-developer', reviewerStepIndex);
1064
+ if (producerIndex < 0) {
1065
+ beginHumanGate();
1066
+ writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: retryReviewer, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
1067
+ out(`${retryReviewer} requested changes for slug "${slug}" but no graph ancestor authors fixes. Read the review artifact. Resume only via /task-continue.`);
1068
+ process.exit(0);
1069
+ }
1070
+ const graphPredecessor = outcomes[retryReviewer]
1071
+ ? { attemptId: outcomes[retryReviewer].attemptId, confidence: outcomes[retryReviewer].confidence }
1072
+ : finishedAttempt;
1073
+ appendMetric({ type: 'retry_scheduled', at: now, attemptId: graphPredecessor?.attemptId || status.lastCompletedAttempt?.attemptId || null, nextAgent: 'feature-developer', retryAfterFix: retryReviewer, source: 'hook', attributionConfidence: graphPredecessor ? graphPredecessor.confidence : 'unknown' });
1074
+ invalidateFrom(producerIndex, reviewerStepIndex);
1075
+ const siblingOutcomes = { ...(status.parallelOutcomes || {}) };
1076
+ delete siblingOutcomes[retryReviewer];
1077
+ status.parallelOutcomes = siblingOutcomes;
1078
+ writeStatus({ state: 'in_progress', phase: 'executing', waveSteps: [], waveId: null, retryAfterFix: null, retryAfterFixStepIndex: null });
1079
+ if (!dispatchReadyWave(`Step ${reviewerStepIndex} (${retryReviewer}) requested changes; re-dispatching unsatisfied steps.`)) out(noProgressNotice());
1080
+ process.exit(0);
1081
+ }
786
1082
  const retryAfterFixStepIndex = idx;
787
1083
  const predecessor = outcomes[retryReviewer]
788
1084
  ? {
@@ -817,10 +1113,51 @@ if (currentStep?.parallel && stepAgents.length > 1) {
817
1113
  process.exit(0);
818
1114
  }
819
1115
 
1116
+ if (isGraphMode()) {
1117
+ const validationProducer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'validation_failed');
1118
+ if (validationProducer) {
1119
+ const verifierStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(validationProducer));
1120
+ const producerIndex = resolveProducerStepIndex('feature-developer', verifierStepIndex);
1121
+ if (producerIndex >= 0) {
1122
+ appendMetric({ type: 'retry_scheduled', at: now, attemptId: outcomes[validationProducer]?.attemptId || null, nextAgent: 'feature-developer', retryAfterFix: validationProducer, source: 'hook', attributionConfidence: 'fallback' });
1123
+ invalidateFrom(producerIndex, verifierStepIndex);
1124
+ writeStatus({ state: 'in_progress', phase: 'executing', parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
1125
+ if (dispatchReadyWave(`Step ${verifierStepIndex} (${validationProducer}) failed validation; re-dispatching unsatisfied steps.`)) process.exit(0);
1126
+ }
1127
+ }
1128
+ const gatedStep = waveIndexes.find((i) => hasGateAfterStep(steps[i], pipeline.humanGates));
1129
+ if (gatedStep !== undefined) {
1130
+ beginHumanGate();
1131
+ writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: completedAgent, pipelineIndex: gatedStep, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
1132
+ process.stdout.write('{}');
1133
+ process.exit(0);
1134
+ }
1135
+ writeStatus({ parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null, state: 'completed' });
1136
+ if (dispatchReadyWave()) process.exit(0);
1137
+ if (Object.keys(status.activeAttempts || {}).length > 0) {
1138
+ process.stdout.write('{}');
1139
+ process.exit(0);
1140
+ }
1141
+ if (pendingStepIndexes().length === 0) {
1142
+ completeTaskMetrics();
1143
+ writeStatus({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1144
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
1145
+ process.exit(0);
1146
+ }
1147
+ out(noProgressNotice());
1148
+ process.exit(0);
1149
+ }
1150
+
820
1151
  writeStatus({ parallelCompleted: [], parallelOutcomes: {}, state: 'completed' });
821
1152
  }
822
1153
 
823
1154
  if (status.state === 'blocked') {
1155
+ if (isGraphMode()) {
1156
+ status.blockedSteps = [...new Set([...(status.blockedSteps || []), idx])];
1157
+ writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: completedAgent, waveSteps: [], waveId: null, parallelCompleted: [], parallelOutcomes: {} });
1158
+ if (!dispatchReadyWave(`Step ${idx} (${completedAgent}) is blocked; proceeding with independent ready steps.`)) out(blockedNotice(idx, completedAgent));
1159
+ process.exit(0);
1160
+ }
824
1161
  writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: completedAgent });
825
1162
  process.stdout.write('{}');
826
1163
  process.exit(0);
@@ -913,6 +1250,22 @@ if (hasGateAfterStep(currentStep, pipeline.humanGates)) {
913
1250
  process.exit(0);
914
1251
  }
915
1252
 
1253
+ if (isGraphMode()) {
1254
+ if (Object.keys(status.activeAttempts || {}).length > 0) {
1255
+ process.stdout.write('{}');
1256
+ process.exit(0);
1257
+ }
1258
+ if (dispatchReadyWave()) process.exit(0);
1259
+ if (pendingStepIndexes().length === 0) {
1260
+ completeTaskMetrics();
1261
+ writeStatus({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
1262
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
1263
+ process.exit(0);
1264
+ }
1265
+ out(noProgressNotice());
1266
+ process.exit(0);
1267
+ }
1268
+
916
1269
  const next = findNextExecutableStep(steps, idx + 1, taskDir);
917
1270
  if (!next) {
918
1271
  completeTaskMetrics();
@@ -13,7 +13,7 @@ When the user message looks like a **work request** (implement, add, fix, refact
13
13
  2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
14
14
  3. Pure questions (“how does X work”, “explain”) — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
15
15
  4. A work request now runs the planning workflow — **goal frame → requirements → information-sufficiency → decompose** (dependency graph / epics); see **task-framing** and **plan-graph**.
16
- 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file.
16
+ 5. Every **work request** — with or without `/task`, and even when the user says “no pipeline” / “just do it” — persists the **verbatim** original prompt at `.ai.local/team/tasks/<slug>/prompt.md`. Prefer `/task` (its **Slug** step writes it). If handling inline without `/task`, first create the slug dir and write `prompt.md` (write-if-absent), then proceed. Pure questions and trivial one-liners are not work requests → no file. On an inline follow-up for an existing slug (no `/task`) where the user authors new text, append it verbatim to `.ai.local/team/tasks/<slug>/prompt-log.md` (`seq` = max + 1; create on first append; exclude machine-generated and empty/argument-less invocations).
17
17
  6. **Resolve the dialogue language before you speak to the user.** Read the `## Language` section of `.ai.local/conventions.md` (nearest `.ai.local` first); else infer from the prompt language; else English (mixed → dominant). Persist it once in the `prompt.md` header (`language: <BCP-47>`) + a `.memlog.md` `event:` line, and reuse it for the whole task. Development, reasoning, and artifacts stay English. The setting wins over a mid-task prompt switch (surface it once, never ask). See **language-policy**.
18
18
 
19
19
  Exceptions: user explicitly says “no pipeline”, “just do it”, or continues an active slug.