@tea-agent/loop-agent 0.1.0-fe-test.3 → 0.1.0-fe-test.4

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 (484) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +605 -93
  3. package/README.md +11 -5
  4. package/bin/loop-agent.js +7 -3
  5. package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
  6. package/dist/adapters/context-transfer/pi-session.js +61 -0
  7. package/dist/application/dag/generate-task-dag.js +90 -21
  8. package/dist/application/dag/run-dag.js +41 -0
  9. package/dist/application/task-lifecycle/advance.js +40 -5
  10. package/dist/application/task-lifecycle/observe.js +171 -17
  11. package/dist/application/task-lifecycle/plan-transitions.js +42 -7
  12. package/dist/application/task-lifecycle/recommendations.js +13 -2
  13. package/dist/build-stamp.json +3 -3
  14. package/dist/cli/command-definitions.js +44 -10
  15. package/dist/cli/program.js +82 -6
  16. package/dist/cli/update/notifier.js +2 -2
  17. package/dist/cli/update/runtime-activity.js +1 -29
  18. package/dist/cli.js +2 -1
  19. package/dist/commands/client-recovery.js +11 -36
  20. package/dist/commands/dag-artifact.js +284 -0
  21. package/dist/commands/dag-context.js +184 -0
  22. package/dist/commands/dag-follow-up.js +138 -0
  23. package/dist/commands/dag-rerun-task.js +2 -0
  24. package/dist/commands/dag-rerun.js +261 -2
  25. package/dist/commands/init-model-catalog.js +486 -0
  26. package/dist/commands/init-upgrade.js +265 -97
  27. package/dist/commands/init.js +455 -28
  28. package/dist/commands/inspect-next.js +8 -0
  29. package/dist/commands/task-advance.js +73 -1
  30. package/dist/commands/task-source-prepare.js +5 -0
  31. package/dist/commands/task-status.js +1 -0
  32. package/dist/executors/dag-pi-executor.js +4321 -231
  33. package/dist/executors/pi-event-serializer.js +42 -1
  34. package/dist/executors/pi-executor.js +70 -6
  35. package/dist/executors/pi-extension-resolver.js +245 -0
  36. package/dist/executors/pi-playwright-cli-tool.js +74 -28
  37. package/dist/executors/pi-read-budget-policy.js +239 -0
  38. package/dist/executors/pi-sdk-executor.js +263 -59
  39. package/dist/executors/pi-writer-tool-policy.js +57 -1
  40. package/dist/executors/shell-executor.js +1411 -240
  41. package/dist/executors/shell-write-guard.js +14 -0
  42. package/dist/executors/workspace-write-snapshot.js +68 -0
  43. package/dist/governance/checks.js +1 -0
  44. package/dist/{worker → infrastructure}/console/app-data.js +4 -0
  45. package/dist/infrastructure/console/artifact-revision-store.js +430 -0
  46. package/dist/infrastructure/console/context-export-store.js +160 -0
  47. package/dist/infrastructure/console/dir-lock.js +132 -0
  48. package/dist/infrastructure/console/operation-store.js +417 -0
  49. package/dist/infrastructure/harness/artifact-store.js +10 -1
  50. package/dist/infrastructure/harness/atomic-write.js +35 -2
  51. package/dist/shared/context-transfer/artifact-revision.js +172 -0
  52. package/dist/shared/context-transfer.js +418 -0
  53. package/dist/shared/dag-failure-category.js +150 -0
  54. package/dist/shared/dag-prompt-override.js +27 -0
  55. package/dist/shared/openspec-spec.js +70 -4
  56. package/dist/shared/operator/capabilities.js +65 -4
  57. package/dist/shared/operator/safe-run-summary.js +1 -0
  58. package/dist/shared/path-safety.js +93 -0
  59. package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
  60. package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
  61. package/dist/shared/pi-context-pressure/env.js +58 -0
  62. package/dist/shared/pi-context-pressure/extension.js +100 -0
  63. package/dist/shared/pi-context-pressure/index.js +7 -0
  64. package/dist/shared/pi-context-pressure/overflow.js +252 -0
  65. package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
  66. package/dist/shared/pi-context-pressure/telemetry.js +51 -0
  67. package/dist/shared/playwright-cli-command-policy.js +15 -0
  68. package/dist/shared/preview.js +28 -4
  69. package/dist/shared/update/console-notifier.js +100 -0
  70. package/dist/{cli → shared}/update/npm-client.js +70 -15
  71. package/dist/{cli → shared}/update/state.js +41 -13
  72. package/dist/task/config-types.js +125 -6
  73. package/dist/task/contract/adopt.js +4 -0
  74. package/dist/task/contract/apply.js +11 -1
  75. package/dist/task/contract/constants.js +3 -0
  76. package/dist/task/contract/diff.js +26 -0
  77. package/dist/task/contract/hash.js +3 -0
  78. package/dist/task/contract/import-revision.js +4 -0
  79. package/dist/task/contract/observe.js +25 -4
  80. package/dist/task/contract/paths.js +2 -1
  81. package/dist/task/contract/project.js +23 -1
  82. package/dist/task/contract/schema.js +9 -1
  83. package/dist/task/contract/transaction.js +12 -0
  84. package/dist/task/frontend-project-capability.js +203 -20
  85. package/dist/task/runtime.js +5 -2
  86. package/dist/task/source-prepare/build-draft.js +18 -3
  87. package/dist/task/source-prepare/completeness.js +188 -0
  88. package/dist/task/source-prepare/fragment-inventory.js +513 -0
  89. package/dist/task/source-prepare/index.js +3 -0
  90. package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
  91. package/dist/task/source-prepare/ledger-review.js +214 -0
  92. package/dist/task/source-prepare/ledger.js +545 -0
  93. package/dist/task/source-prepare/parse-intent.js +24 -4
  94. package/dist/task/source-prepare/prepare.js +368 -2
  95. package/dist/task/source-prepare/semantic-intake.js +25 -5
  96. package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
  97. package/dist/task/source-prepare/types.js +22 -0
  98. package/dist/task/source-references.js +22 -1
  99. package/dist/task/task-demand-routing.js +3 -0
  100. package/dist/worker/cli.js +18 -2
  101. package/dist/worker/console/chat/assistant-content.js +7 -0
  102. package/dist/worker/console/chat/chat-event-store.js +159 -18
  103. package/dist/worker/console/chat/chat-ui-policy.js +4 -2
  104. package/dist/worker/console/chat/context-panel.js +7 -0
  105. package/dist/worker/console/chat/deferred-turn.js +103 -0
  106. package/dist/worker/console/chat/goal-round-driver.js +72 -0
  107. package/dist/worker/console/chat/goals.js +300 -0
  108. package/dist/worker/console/chat/model-resolver.js +7 -4
  109. package/dist/worker/console/chat/operation-card.js +8 -1
  110. package/dist/worker/console/chat/pi-console-config.js +81 -10
  111. package/dist/worker/console/chat/pi-runtime.js +868 -30
  112. package/dist/worker/console/chat/provider-error.js +99 -0
  113. package/dist/worker/console/chat/repo-browser.js +101 -12
  114. package/dist/worker/console/chat/resource-preferences-store.js +1 -1
  115. package/dist/worker/console/chat/routes.js +1451 -145
  116. package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
  117. package/dist/worker/console/chat/semantic-activity.js +25 -24
  118. package/dist/worker/console/chat/session-catalog.js +50 -0
  119. package/dist/worker/console/chat/session-stats.js +275 -0
  120. package/dist/worker/console/chat/session-store.js +348 -76
  121. package/dist/worker/console/chat/shortcuts.js +26 -3
  122. package/dist/worker/console/chat/sift-bridge.js +1 -0
  123. package/dist/worker/console/chat/todos.js +115 -0
  124. package/dist/worker/console/chat/tool-preview.js +42 -0
  125. package/dist/worker/console/chat/turn-process.js +185 -112
  126. package/dist/worker/console/chat/user-questions.js +266 -0
  127. package/dist/worker/console/chat/workspace-landing.js +79 -0
  128. package/dist/worker/console/console-handoff.js +82 -0
  129. package/dist/worker/console/console-update-and-init.js +115 -0
  130. package/dist/worker/console/console-update-runtime.js +84 -0
  131. package/dist/worker/console/context-transfer-diagnostics.js +198 -0
  132. package/dist/worker/console/dag-confirmation.js +1 -1
  133. package/dist/worker/console/dag-execution-receipt.js +54 -3
  134. package/dist/worker/console/doctor.js +1 -1
  135. package/dist/worker/console/draft-store.js +50 -1
  136. package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
  137. package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
  138. package/dist/worker/console/human-gate-token.js +1 -1
  139. package/dist/worker/console/index.js +6 -3
  140. package/dist/worker/console/inspect-split.js +18 -0
  141. package/dist/worker/console/interview/assessment.js +1 -1
  142. package/dist/worker/console/interview/session.js +1 -1
  143. package/dist/worker/console/native-directory-picker.js +13 -0
  144. package/dist/worker/console/operation-run-facts.js +19 -3
  145. package/dist/worker/console/operation-runner.js +45 -4
  146. package/dist/worker/console/operation-sse.js +1 -1
  147. package/dist/worker/console/operation-wait.js +1 -1
  148. package/dist/worker/console/operator-actions.js +534 -15
  149. package/dist/worker/console/operator-selection.js +6 -2
  150. package/dist/worker/console/operator-surface-health.js +2 -1
  151. package/dist/worker/console/operator-user-error.js +171 -2
  152. package/dist/worker/console/pi-plugins.catalog.json +73658 -0
  153. package/dist/worker/console/pi-plugins.js +238 -0
  154. package/dist/worker/console/pi-readiness.js +7 -6
  155. package/dist/worker/console/prd-intake-bridge.js +13 -0
  156. package/dist/worker/console/recovery-cta.js +4 -4
  157. package/dist/worker/console/recovery-error-copy.js +4 -4
  158. package/dist/worker/console/routes.js +1231 -10
  159. package/dist/worker/console/security.js +102 -13
  160. package/dist/worker/console/server.js +762 -159
  161. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
  162. package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
  163. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
  164. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
  165. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
  166. package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
  167. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
  168. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
  169. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
  170. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
  171. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
  172. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
  173. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
  174. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
  175. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
  176. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
  177. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
  178. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
  179. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
  180. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
  181. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
  182. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
  183. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
  184. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
  185. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
  186. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
  187. package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
  188. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
  189. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
  190. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
  191. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
  192. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
  193. package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
  194. package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
  195. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
  196. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
  197. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
  198. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
  199. package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
  200. package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
  201. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
  202. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
  203. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
  204. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
  205. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
  206. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
  207. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
  208. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
  209. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
  210. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
  211. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
  212. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
  213. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
  214. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
  215. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
  216. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
  217. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
  218. package/dist/worker/console/static/index.html +7 -2
  219. package/dist/worker/console/static-src/active-run-badge.js +17 -0
  220. package/dist/worker/console/static-src/app/console-types.js +68 -4
  221. package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
  222. package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
  223. package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
  224. package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
  225. package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
  226. package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
  227. package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
  228. package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
  229. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
  230. package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
  231. package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
  232. package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
  233. package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
  234. package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
  235. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
  236. package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
  237. package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
  238. package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
  239. package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
  240. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
  241. package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
  242. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
  243. package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
  244. package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
  245. package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
  246. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
  247. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
  248. package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
  249. package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
  250. package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
  251. package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
  252. package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
  253. package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
  254. package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
  255. package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
  256. package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
  257. package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
  258. package/dist/worker/console/workspace-context.js +399 -0
  259. package/dist/worker/console/workspace-registry.js +487 -0
  260. package/dist/worker/continuation/worker-continuation.js +278 -0
  261. package/dist/worker/loop-agent/loop-agent-client.js +7 -3
  262. package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
  263. package/dist/worker/materialize/harness-task-lineage.js +5 -2
  264. package/dist/worker/observability/init-runtime-activity.js +26 -0
  265. package/dist/worker/observability/read-model.js +26 -0
  266. package/dist/worker/observe/health.js +1 -1
  267. package/dist/worker/observe/node-input.js +160 -3
  268. package/dist/worker/observe/node-process.js +377 -0
  269. package/dist/worker/observe/node-transparency.js +572 -0
  270. package/dist/worker/observe/routes.js +278 -3
  271. package/dist/worker/observe/server.js +4 -0
  272. package/dist/worker/observe/shell-handler-keys.js +34 -0
  273. package/dist/worker/observe/static/api.js +154 -4
  274. package/dist/worker/observe/static/app.js +18 -70
  275. package/dist/worker/observe/static/constants.js +26 -19
  276. package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
  277. package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
  278. package/dist/worker/observe/static/dag-helpers.js +4 -2
  279. package/dist/worker/observe/static/dag-history-labels.js +5 -0
  280. package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
  281. package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
  282. package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
  283. package/dist/worker/observe/static/dag-node-purpose.js +208 -0
  284. package/dist/worker/observe/static/format.js +60 -0
  285. package/dist/worker/observe/static/index.html +10 -5
  286. package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
  287. package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
  288. package/dist/worker/observe/static/inspect-workspace.js +374 -0
  289. package/dist/worker/observe/static/kpi.js +2 -2
  290. package/dist/worker/observe/static/markdown-render.js +20 -1
  291. package/dist/worker/observe/static/operator-chrome.css +168 -24
  292. package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
  293. package/dist/worker/observe/static/operator-chrome.js +354 -101
  294. package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
  295. package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
  296. package/dist/worker/observe/static/relations.js +7 -7
  297. package/dist/worker/observe/static/router.d.ts +57 -0
  298. package/dist/worker/observe/static/router.js +67 -1
  299. package/dist/worker/observe/static/run-processing.js +4 -2
  300. package/dist/worker/observe/static/shell-chrome.js +2 -2
  301. package/dist/worker/observe/static/state.d.ts +50 -0
  302. package/dist/worker/observe/static/state.js +191 -1
  303. package/dist/worker/observe/static/styles.css +1720 -86
  304. package/dist/worker/observe/static/views/dag-graph.js +5 -3
  305. package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
  306. package/dist/worker/observe/static/views/dag.d.ts +13 -0
  307. package/dist/worker/observe/static/views/dag.js +39 -18
  308. package/dist/worker/observe/static/views/dags.js +10 -6
  309. package/dist/worker/observe/static/views/dashboard.js +18 -8
  310. package/dist/worker/observe/static/views/failures.js +5 -2
  311. package/dist/worker/observe/static/views/night.js +2 -2
  312. package/dist/worker/observe/static/views/pool.js +8 -2
  313. package/dist/worker/observe/static/views/run.js +15 -4
  314. package/dist/worker/observe/static/views/session-timeline.js +386 -25
  315. package/dist/worker/observe/static/views/task.js +63 -3
  316. package/dist/worker/outcomes/adapters.js +19 -0
  317. package/dist/worker/outcomes/types.js +1 -0
  318. package/dist/worker/pool/attempt-lease.js +97 -66
  319. package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
  320. package/dist/worker/pool/reconcile.js +46 -1
  321. package/dist/worker/pool/run-store.js +2 -0
  322. package/dist/worker/pool/state-projection.js +2 -0
  323. package/dist/worker/task-spec/workflow-routing.js +8 -3
  324. package/dist/workflows/dag/artifact-bindings.js +149 -0
  325. package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
  326. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
  327. package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
  328. package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
  329. package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
  330. package/dist/workflows/dag/backend-test-result-contract.js +5 -1
  331. package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
  332. package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
  333. package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
  334. package/dist/workflows/dag/budget-enforcement.js +10 -0
  335. package/dist/workflows/dag/context-receipt.js +305 -0
  336. package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
  337. package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
  338. package/dist/workflows/dag/context-transfer/renderers.js +93 -0
  339. package/dist/workflows/dag/contract-output-registry.js +15 -0
  340. package/dist/workflows/dag/contract-validator-registrations.js +1 -2
  341. package/dist/workflows/dag/convergence/controller.js +141 -0
  342. package/dist/workflows/dag/dag-retry-schema.js +138 -0
  343. package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
  344. package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
  345. package/dist/workflows/dag/failure-category.js +7 -116
  346. package/dist/workflows/dag/frontend-closeout.js +221 -0
  347. package/dist/workflows/dag/frontend-design-policy.js +400 -0
  348. package/dist/workflows/dag/frontend-human-decision.js +182 -0
  349. package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
  350. package/dist/workflows/dag/frontend-plan-render.js +26 -1
  351. package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
  352. package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
  353. package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
  354. package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
  355. package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
  356. package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
  357. package/dist/workflows/dag/frontend-recovery-run.js +166 -34
  358. package/dist/workflows/dag/frontend-repair.js +7 -424
  359. package/dist/workflows/dag/frontend-review-context.js +348 -20
  360. package/dist/workflows/dag/frontend-review-findings.js +270 -0
  361. package/dist/workflows/dag/frontend-risk.js +15 -2
  362. package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
  363. package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
  364. package/dist/workflows/dag/frontend-shape-facts.js +419 -0
  365. package/dist/workflows/dag/frontend-shape.js +435 -0
  366. package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
  367. package/dist/workflows/dag/frontend-split-application-service.js +203 -0
  368. package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
  369. package/dist/workflows/dag/frontend-test-case-checklist.js +30 -4
  370. package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
  371. package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
  372. package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
  373. package/dist/workflows/dag/frontend-test-html-report.js +3 -1
  374. package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
  375. package/dist/workflows/dag/frontend-test-layout.js +159 -0
  376. package/dist/workflows/dag/frontend-test-markdown.js +61 -0
  377. package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
  378. package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
  379. package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
  380. package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
  381. package/dist/workflows/dag/frontend-verification-trace.js +281 -29
  382. package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
  383. package/dist/workflows/dag/frontend-writer-admission.js +319 -0
  384. package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
  385. package/dist/workflows/dag/frontend-writer-status.js +256 -0
  386. package/dist/workflows/dag/init-hybrid.js +1670 -706
  387. package/dist/workflows/dag/interrupt-request.js +10 -3
  388. package/dist/workflows/dag/lifecycle.js +3 -3
  389. package/dist/workflows/dag/node-execution.js +1141 -32
  390. package/dist/workflows/dag/path-safety.js +1 -0
  391. package/dist/workflows/dag/prompt.js +158 -7
  392. package/dist/workflows/dag/recovery-lease.js +170 -0
  393. package/dist/workflows/dag/report.js +37 -1
  394. package/dist/workflows/dag/rerun-feedback.js +526 -0
  395. package/dist/workflows/dag/rerun-plan.js +790 -28
  396. package/dist/workflows/dag/rerun-run.js +700 -21
  397. package/dist/workflows/dag/rerun-task.js +311 -14
  398. package/dist/workflows/dag/retry-policy.js +336 -101
  399. package/dist/workflows/dag/runner.js +596 -121
  400. package/dist/workflows/dag/scheduler.js +133 -20
  401. package/dist/workflows/dag/skill-snapshot.js +17 -0
  402. package/dist/workflows/dag/structured-output-repair.js +712 -0
  403. package/dist/workflows/dag/types.js +579 -31
  404. package/dist/workflows/dag/validate.js +92 -32
  405. package/docs/README.md +2 -0
  406. package/docs/architecture/evolution.md +45 -0
  407. package/docs/architecture/runtime-boundaries.md +8 -7
  408. package/docs/architecture/worker-and-feature.md +1 -1
  409. package/docs/examples/README.md +5 -0
  410. package/docs/init-surface.manifest.json +36 -12
  411. package/docs/operations/README.md +1 -1
  412. package/docs/operations/local-development-environment.md +22 -5
  413. package/docs/skills/vetted-skill-registry.md +16 -0
  414. package/docs/templates/README.md +4 -2
  415. package/docs/templates/agent-dag-report.schema.json +8 -2
  416. package/docs/templates/agent-dag.schema.json +95 -1
  417. package/docs/templates/backend-test-dag.json +278 -244
  418. package/docs/templates/frontend-implementation-contract.schema.json +684 -24
  419. package/docs/templates/frontend-implementation-dag.json +89 -0
  420. package/docs/templates/frontend-test-case-checklist.md +2 -2
  421. package/docs/templates/frontend-test-dag.json +8 -10
  422. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
  423. package/docs/templates/init-managed-agents.md +13 -3
  424. package/docs/templates/product-line/task.yaml +1 -1
  425. package/docs/templates/spec-registry.schema.json +45 -0
  426. package/harness.json +2 -2
  427. package/package.json +19 -5
  428. package/scripts/next-info.mjs +356 -0
  429. package/scripts/next-publish-gate.mjs +238 -0
  430. package/scripts/release-source-binding.mjs +251 -0
  431. package/skills/analyze-product-requirements/SKILL.md +8 -5
  432. package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
  433. package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
  434. package/skills/analyze-product-requirements/references/example.md +50 -0
  435. package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
  436. package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
  437. package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
  438. package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
  439. package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
  440. package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
  441. package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
  442. package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
  443. package/skills/codebase-scout/SKILL.md +1 -1
  444. package/skills/fe-test-ui-scout/SKILL.md +65 -0
  445. package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
  446. package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
  447. package/skills/frontend-bounded-implement/SKILL.md +15 -14
  448. package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
  449. package/skills/frontend-contract/SKILL.md +23 -0
  450. package/skills/frontend-contract/references/contract-protocol.md +34 -0
  451. package/skills/frontend-design-review/SKILL.md +22 -41
  452. package/skills/frontend-plan/SKILL.md +26 -0
  453. package/skills/frontend-plan/references/decision-contract.md +37 -0
  454. package/skills/frontend-plan/references/design-decisions.md +17 -0
  455. package/skills/frontend-review/SKILL.md +20 -15
  456. package/skills/frontend-review/references/review-findings.md +6 -7
  457. package/skills/frontend-scout/SKILL.md +25 -0
  458. package/skills/frontend-scout/references/design-evidence.md +16 -0
  459. package/skills/frontend-scout/references/scout-evidence.md +23 -0
  460. package/skills/frontend-verification/SKILL.md +1 -1
  461. package/skills/improve-codebase-architecture/SKILL.md +81 -0
  462. package/skills/improve-codebase-architecture/deepening.md +37 -0
  463. package/skills/improve-codebase-architecture/html-report.md +123 -0
  464. package/skills/improve-codebase-architecture/interface-design.md +44 -0
  465. package/skills/improve-codebase-architecture/language.md +53 -0
  466. package/skills/loop-agent/references/command-reference.md +32 -4
  467. package/skills/loop-agent/references/hybrid-dag.md +9 -2
  468. package/skills/playwright-cli/SKILL.md +23 -1
  469. package/skills/playwright-cli-case-generator/SKILL.md +50 -13
  470. package/dist/worker/console/operation-store.js +0 -169
  471. package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
  472. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
  473. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
  474. package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
  475. package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
  476. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
  477. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
  478. package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
  479. package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
  480. package/skills/frontend-implementation/SKILL.md +0 -52
  481. package/skills/frontend-implementation/references/code-standards.md +0 -33
  482. package/skills/frontend-implementation/references/design-spec.md +0 -56
  483. package/skills/frontend-implementation/references/node-contracts.md +0 -31
  484. /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
@@ -9,17 +9,25 @@ references:
9
9
 
10
10
  # Frontend Review
11
11
 
12
- Use for `frontend-review-pi`; read the findings guide first. Required inputs are
13
- original task/reference material, effective plan/design branch, implementation summary,
14
- and `contracts/frontend-review-context.json`. That canonical context binds the validated
15
- implementation contract, effective verification trace, repair assessment, optional
16
- `frontend-lint-assessment-v1`, and run-owned diff. The diff is authoritative.
12
+ Use for `frontend-review-pi`; read the findings guide and capacity diagnostic first.
13
+ Inputs are `contracts/frontend-review-context.json`, its hash-bound contract
14
+ reference/index and diff fragments, and only source files named by that diff. Use
15
+ indexed contract sections when recommended. Do not reopen task sources, plans,
16
+ design-review prose, OpenSpec, or `ai_workspace/`; the bound context is authoritative.
17
17
 
18
- ## Verdict Contract
18
+ ## Authoritative Terminal
19
19
 
20
- The first non-empty line must be exactly `VERDICT: pass` or
21
- `VERDICT: request-revision`. Any Critical/Important finding, failed or missing
22
- required check, forbidden write, or unmet acceptance criterion forces revision.
20
+ Complete the review with exactly one committed typed tool call:
21
+
22
+ - `approve_review` when no Critical/Important finding remains;
23
+ - `request_review_changes` for a defect, missing required evidence, forbidden
24
+ write, or unmet acceptance criterion. It must include a typed `issueCategory`,
25
+ at least one `evidenceRef`, and non-empty findings.
26
+
27
+ The typed terminal is the only authoritative outcome. Do not require or emit a
28
+ `VERDICT:` line or response-text JSON verdict. A request for review changes ends
29
+ this run and is handled by the recovery controller rather than a same-run repair
30
+ branch.
23
31
 
24
32
  ## Review Scope
25
33
 
@@ -27,7 +35,7 @@ required check, forbidden write, or unmet acceptance criterion forces revision.
27
35
  - Inspect every changed file against allowed, forbidden, and approved write scope.
28
36
  - Map criteria to behavior, applicable UI states, tests, and shell evidence.
29
37
  - Review state/data flow, validation, async/error behavior, design, responsive/a11y,
30
- dependencies, maintenance, and regression risk when applicable.
38
+ dependencies, and regression risk when applicable.
31
39
  - Inspect static, behavior, and available Mock-specific artifacts directly. For Mock
32
40
  strategies, compare the endpoint matrix, handler/fixture/adapter and consumer diff;
33
41
  require the real request as default, contract-aligned fixtures, production isolation,
@@ -38,11 +46,8 @@ required check, forbidden write, or unmet acceptance criterion forces revision.
38
46
  baseline-matched diagnostics on unchanged files, and none on writer-changed files.
39
47
  Report debt, never `lint passed`; `failed`/`unavailable` blocks. Typecheck, build,
40
48
  and test still require successful final exits.
41
- - Component/design claims need both knowledge-base and local openspec evidence. Query
42
- the connector when available and always read task-relevant files under
43
- `<repoRoot>/openspec/schemas/`, `<repoRoot>/openspec/project-specs/`, and `<repoRoot>/ai_workspace/`.
44
- Connector format is TODO; never invent evidence. Only successful `read` calls are
45
- observable as "已读取规范文件".
49
+ - Evaluate component/design claims against bound evidence; do not replace it with a
50
+ repository-wide search or connector query.
46
51
  - Treat shell exit status as authoritative. Do not edit files.
47
52
 
48
53
  ## Evidence And Output
@@ -14,24 +14,23 @@
14
14
  `baseline-debt` only with a valid `frontend-lint-assessment-v1`; this is not a
15
15
  passed lint result. A changed-file lint diagnostic, new unmatched diagnostic,
16
16
  command drift, missing baseline, timeout, or unparseable output is Important.
17
- - Treat knowledge base, `openspec/schemas/`, `openspec/project-specs/`, and `ai_workspace/` as
18
- parallel sources. Record connector/query/source/time plus openspec search terms and
19
- matched paths/headings; label fallback or unavailable accurately.
17
+ - Treat the design evidence already bound in the canonical review context as the
18
+ source of truth. Do not launch a connector query or repository-wide OpenSpec/
19
+ `ai_workspace` search to replace frozen evidence; label a missing bound evidence
20
+ reference accurately instead.
20
21
 
21
22
  ## Review Sequence
22
23
 
23
24
  1. Establish changed-file inventory and write boundaries.
24
- 2. Compare original requirement with derived contract/constraints.
25
+ 2. Compare the bound contract with the approved constraints and cumulative diff.
25
26
  3. Map each criterion to code, states, tests, and evidence.
26
27
  4. Inspect interactions, state/data/API behavior, failure paths, and regressions.
27
28
  5. Check mock selection, contract-to-fixture mapping, activation/default path,
28
29
  handler/fixture/adapter and consumer diff, verification, production imports, and
29
30
  the real-integration gap.
30
- 6. Check design evidence, responsive/a11y behavior, dependencies, and maintenance.
31
+ 6. Check bound design evidence, responsive/a11y behavior, dependencies, and maintenance.
31
32
  7. Classify findings and derive the verdict mechanically.
32
33
 
33
- Skipping either directory is Important when design compliance affects acceptance.
34
-
35
34
  ```text
36
35
  - [Critical|Important|Minor] path:line — Problem; impact; required correction; evidence.
37
36
  ```
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: frontend-scout
3
+ description: Use only for read-only frontend target-surface and design-evidence scouting.
4
+ references:
5
+ - path: references/scout-evidence.md
6
+ required: true
7
+ maxChars: 4200
8
+ - path: references/design-evidence.md
9
+ required: true
10
+ maxChars: 3600
11
+ ---
12
+
13
+ # Frontend Scout
14
+
15
+ Inspect only enough repository evidence to prove the target surface and applicable
16
+ design rules. Separate facts, inferences, and unresolved gaps. Reuse the frozen
17
+ capability context and contract selections before running bounded task-term searches.
18
+
19
+ Submit findings incrementally through `record_target_surface` and
20
+ `record_design_evidence`. A complete surface names proven entrypoints, routes or
21
+ mounts, implementation paths, test paths, data sources, and any allowed-path
22
+ conflicts. If ownership remains unresolved, commit `completeness=blocked` with the
23
+ specific gaps rather than guessing.
24
+
25
+ This node is read-only and does not make plan decisions.
@@ -0,0 +1,16 @@
1
+ # Frontend Design Evidence
2
+
3
+ Use the generation-frozen component/design capability context and cited candidate
4
+ set. When a connector is available, query the configured knowledge base; regardless
5
+ of its result, inspect relevant frozen OpenSpec or `ai_workspace` candidates. Search
6
+ local specification roots only for unresolved task terms and never recursively read
7
+ all supported files.
8
+
9
+ Record evidence as `knowledge-base`, `openspec fallback`, `repository fallback`, or
10
+ `unavailable`. Include query/search terms, paths, headings or tight line ranges,
11
+ applied rules, and conflicts. Filename-only and unread search matches are not rules.
12
+
13
+ Look for components, variants, composition, tokens, layout, responsive behavior,
14
+ accessibility, state patterns, data/Mock conventions, deprecations, exceptions, and
15
+ forbidden patterns. Explicit task requirements remain authoritative; report source
16
+ conflicts instead of merging them silently.
@@ -0,0 +1,23 @@
1
+ # Frontend Scout Evidence
2
+
3
+ ## Target surface
4
+
5
+ Prove the current frontend stack and the files that own the requested behavior:
6
+
7
+ - entrypoint, route or mount;
8
+ - page/component/style implementation paths;
9
+ - state and data/API/Mock flow;
10
+ - supported scripts and test entrypoints;
11
+ - reusable components, tokens, helpers, fixtures, and assets;
12
+ - paths discovered outside task `allowedPaths`;
13
+ - unresolved ownership or missing evidence.
14
+
15
+ Use repository-relative POSIX paths. A search hit, lockfile, fixture, or filename is
16
+ not proof by itself. Read the relevant surrounding code or configuration and report
17
+ the exact evidence. Do not recursively inspect unrelated directories.
18
+
19
+ ## Completeness
20
+
21
+ Commit `complete` only when the target surface is sufficiently proven for Plan to
22
+ reuse without repository discovery. Otherwise commit `blocked` and list every
23
+ unresolved path or ownership question. Do not shift discovery work into Plan.
@@ -30,7 +30,7 @@ verdict/findings, and required browser, visual, manual, or knowledge evidence.
30
30
  `frontend-lint-assessment-v1` proving only pre-writer diagnostics on unchanged
31
31
  files. Report debt count, changed files, and raw evidence. Typecheck/build/test do
32
32
  not support debt.
33
- - Use design and requirement evidence already bound inside
33
+ - Use design and requirement evidence referenced and hash-bound by
34
34
  `contracts/frontend-review-context.json`. Closeout must not query connectors,
35
35
  re-open task sources, OpenSpec, AI workspace, upstream model prose, or start new
36
36
  repository research.
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: improve-codebase-architecture
3
+ description: Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
4
+ ---
5
+
6
+ # Improve Codebase Architecture
7
+
8
+ Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
9
+
10
+ ## Glossary
11
+
12
+ Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in [language.md](language.md).
13
+
14
+ - **Module** — anything with an interface and an implementation (function, class, package, slice).
15
+ - **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
16
+ - **Implementation** — the code inside.
17
+ - **Depth** — leverage at the interface: a lot of behaviour behind a small interface. **Deep** = high leverage. **Shallow** = interface nearly as complex as the implementation.
18
+ - **Seam** — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
19
+ - **Adapter** — a concrete thing satisfying an interface at a seam.
20
+ - **Leverage** — what callers get from depth.
21
+ - **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
22
+
23
+ Key principles (see [language.md](language.md) for the full list):
24
+
25
+ - **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
26
+ - **The interface is the test surface.**
27
+ - **One adapter = hypothetical seam. Two adapters = real seam.**
28
+
29
+ This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
30
+
31
+ ## Process
32
+
33
+ ### 1. Explore
34
+
35
+ Read the project's domain glossary and any ADRs in the area you're touching first.
36
+
37
+ Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
38
+
39
+ - Where does understanding one concept require bouncing between many small modules?
40
+ - Where are modules **shallow** — interface nearly as complex as the implementation?
41
+ - Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
42
+ - Where do tightly-coupled modules leak across their seams?
43
+ - Which parts of the codebase are untested, or hard to test through their current interface?
44
+
45
+ Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
46
+
47
+ ### 2. Present candidates as an HTML report
48
+
49
+ Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user — `xdg-open <path>` on Linux, `open <path>` on macOS, `start <path>` on Windows — and tell them the absolute path.
50
+
51
+ The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
52
+
53
+ For each candidate, the same template as before, but rendered as a card:
54
+
55
+ - **Files** — which files/modules are involved
56
+ - **Problem** — why the current architecture is causing friction
57
+ - **Solution** — plain English description of what would change
58
+ - **Benefits** — explained in terms of locality and leverage, and how tests would improve
59
+ - **Before / After diagram** — side-by-side, custom-drawn, illustrating the shallowness and the deepening
60
+ - **Recommendation strength** — one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
61
+
62
+ End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
63
+
64
+ **Use CONTEXT.md vocabulary for the domain, and [language.md](language.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
65
+
66
+ **ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
67
+
68
+ See [html-report.md](html-report.md) for the full HTML scaffold, diagram patterns, and styling guidance.
69
+
70
+ Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
71
+
72
+ ### 3. Grilling loop
73
+
74
+ Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
75
+
76
+ Side effects happen inline as decisions crystallize:
77
+
78
+ - **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `/grill-with-docs` (see [context-format.md](../grill-with-docs/context-format.md)). Create the file lazily if it doesn't exist.
79
+ - **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
80
+ - **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See [adr-format.md](../grill-with-docs/adr-format.md).
81
+ - **Want to explore alternative interfaces for the deepened module?** See [interface-design.md](interface-design.md).
@@ -0,0 +1,37 @@
1
+ # Deepening
2
+
3
+ How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [language.md](language.md) — **module**, **interface**, **seam**, **adapter**.
4
+
5
+ ## Dependency categories
6
+
7
+ When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
8
+
9
+ ### 1. In-process
10
+
11
+ Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
12
+
13
+ ### 2. Local-substitutable
14
+
15
+ Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
16
+
17
+ ### 3. Remote but owned (Ports & Adapters)
18
+
19
+ Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
20
+
21
+ Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
22
+
23
+ ### 4. True external (Mock)
24
+
25
+ Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
26
+
27
+ ## Seam discipline
28
+
29
+ - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
30
+ - **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
31
+
32
+ ## Testing strategy: replace, don't layer
33
+
34
+ - Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
35
+ - Write new tests at the deepened module's interface. The **interface is the test surface**.
36
+ - Tests assert on observable outcomes through the interface, not internal state.
37
+ - Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
@@ -0,0 +1,123 @@
1
+ # HTML Report Format
2
+
3
+ The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two — don't lean on Mermaid for everything, it'll start to look generic.
4
+
5
+ ## Scaffold
6
+
7
+ ```html
8
+ <!doctype html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <title>Architecture review — {{repo name}}</title>
13
+ <script src="https://cdn.tailwindcss.com"></script>
14
+ <script type="module">
15
+ import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
16
+ mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
17
+ </script>
18
+ <style>
19
+ /* small custom layer for things Tailwind doesn't cover cleanly:
20
+ dashed seam lines, hand-drawn-feeling arrow heads, etc. */
21
+ .seam { stroke-dasharray: 4 4; }
22
+ .leak { stroke: #dc2626; }
23
+ .deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
24
+ </style>
25
+ </head>
26
+ <body class="bg-stone-50 text-slate-900 font-sans">
27
+ <main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
28
+ <header>...</header>
29
+ <section id="candidates" class="space-y-10">...</section>
30
+ <section id="top-recommendation">...</section>
31
+ </main>
32
+ </body>
33
+ </html>
34
+ ```
35
+
36
+ ## Header
37
+
38
+ Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph — straight into the candidates.
39
+
40
+ ## Candidate card
41
+
42
+ The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms ([language.md](language.md)) without ceremony.
43
+
44
+ Each candidate is one `<article>`:
45
+
46
+ - **Title** — short, names the deepening (e.g. "Collapse the Order intake pipeline").
47
+ - **Badge row** — recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
48
+ - **Files** — monospaced list, `font-mono text-sm`.
49
+ - **Before / After diagram** — the centrepiece. Two columns, side by side. See patterns below.
50
+ - **Problem** — one sentence. What hurts.
51
+ - **Solution** — one sentence. What changes.
52
+ - **Wins** — bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
53
+ - **ADR callout** (if applicable) — one line in an amber-tinted box.
54
+
55
+ No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
56
+
57
+ ## Diagram patterns
58
+
59
+ Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same — variety is part of the point.
60
+
61
+ ### Mermaid graph (the workhorse for dependencies / call flow)
62
+
63
+ Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
64
+
65
+ ```html
66
+ <div class="rounded-lg border border-slate-200 bg-white p-4">
67
+ <pre class="mermaid">
68
+ flowchart LR
69
+ A[OrderHandler] --> B[OrderValidator]
70
+ B --> C[OrderRepo]
71
+ C -.leak.-> D[PricingClient]
72
+ classDef leak stroke:#dc2626,stroke-width:2px;
73
+ class C,D leak
74
+ </pre>
75
+ </div>
76
+ ```
77
+
78
+ ### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
79
+
80
+ Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals — Mermaid won't render that with the right weight.
81
+
82
+ ### Cross-section (good for layered shallowness)
83
+
84
+ Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
85
+
86
+ ### Mass diagram (good for "interface as wide as implementation")
87
+
88
+ Two rectangles per module — one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
89
+
90
+ ### Call-graph collapse
91
+
92
+ Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
93
+
94
+ ## Style guidance
95
+
96
+ - Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
97
+ - Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
98
+ - Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
99
+ - Use `text-xs uppercase tracking-wider` for module labels inside diagrams — they should read as schematic, not as UI.
100
+ - The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static — no app code, no interactivity beyond Mermaid's own rendering.
101
+
102
+ ## Top recommendation section
103
+
104
+ One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
105
+
106
+ ## Tone
107
+
108
+ Plain English, concise — but the architectural nouns and verbs come straight from [language.md](language.md). Concision is not an excuse to drift.
109
+
110
+ **Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
111
+
112
+ **Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
113
+
114
+ **Phrasings that fit the style:**
115
+
116
+ - "Order intake module is shallow — interface nearly matches the implementation."
117
+ - "Pricing leaks across the seam."
118
+ - "Deepen: one interface, one place to test."
119
+ - "Two adapters justify the seam: HTTP in prod, in-memory in tests."
120
+
121
+ **Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
122
+
123
+ No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in [language.md](language.md), reach for one that is before inventing a new one.
@@ -0,0 +1,44 @@
1
+ # Interface Design
2
+
3
+ When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
4
+
5
+ Uses the vocabulary in [language.md](language.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
6
+
7
+ ## Process
8
+
9
+ ### 1. Frame the problem space
10
+
11
+ Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
12
+
13
+ - The constraints any new interface would need to satisfy
14
+ - The dependencies it would rely on, and which category they fall into (see [deepening.md](deepening.md))
15
+ - A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
16
+
17
+ Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
18
+
19
+ ### 2. Spawn sub-agents
20
+
21
+ Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
22
+
23
+ Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [deepening.md](deepening.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
24
+
25
+ - Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
26
+ - Agent 2: "Maximise flexibility — support many use cases and extension."
27
+ - Agent 3: "Optimise for the most common caller — make the default case trivial."
28
+ - Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
29
+
30
+ Include both [language.md](language.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
31
+
32
+ Each sub-agent outputs:
33
+
34
+ 1. Interface (types, methods, params — plus invariants, ordering, error modes)
35
+ 2. Usage example showing how callers use it
36
+ 3. What the implementation hides behind the seam
37
+ 4. Dependency strategy and adapters (see [deepening.md](deepening.md))
38
+ 5. Trade-offs — where leverage is high, where it's thin
39
+
40
+ ### 3. Present and compare
41
+
42
+ Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
43
+
44
+ After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
@@ -0,0 +1,53 @@
1
+ # Language
2
+
3
+ Shared vocabulary for every suggestion this skill makes. Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
4
+
5
+ ## Terms
6
+
7
+ **Module**
8
+ Anything with an interface and an implementation. Deliberately scale-agnostic — applies equally to a function, class, package, or tier-spanning slice.
9
+ _Avoid_: unit, component, service.
10
+
11
+ **Interface**
12
+ Everything a caller must know to use the module correctly. Includes the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics.
13
+ _Avoid_: API, signature (too narrow — those refer only to the type-level surface).
14
+
15
+ **Implementation**
16
+ What's inside a module — its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
17
+
18
+ **Depth**
19
+ Leverage at the interface — the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface. A module is **shallow** when the interface is nearly as complex as the implementation.
20
+
21
+ **Seam** _(from Michael Feathers)_
22
+ A place where you can alter behaviour without editing in that place. The *location* at which a module's interface lives. Choosing where to put the seam is its own design decision, distinct from what goes behind it.
23
+ _Avoid_: boundary (overloaded with DDD's bounded context).
24
+
25
+ **Adapter**
26
+ A concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
27
+
28
+ **Leverage**
29
+ What callers get from depth. More capability per unit of interface they have to learn. One implementation pays back across N call sites and M tests.
30
+
31
+ **Locality**
32
+ What maintainers get from depth. Change, bugs, knowledge, and verification concentrate at one place rather than spreading across callers. Fix once, fixed everywhere.
33
+
34
+ ## Principles
35
+
36
+ - **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts — they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
37
+ - **The deletion test.** Imagine deleting the module. If complexity vanishes, the module wasn't hiding anything (it was a pass-through). If complexity reappears across N callers, the module was earning its keep.
38
+ - **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
39
+ - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
40
+
41
+ ## Relationships
42
+
43
+ - A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
44
+ - **Depth** is a property of a **Module**, measured against its **Interface**.
45
+ - A **Seam** is where a **Module**'s **Interface** lives.
46
+ - An **Adapter** sits at a **Seam** and satisfies the **Interface**.
47
+ - **Depth** produces **Leverage** for callers and **Locality** for maintainers.
48
+
49
+ ## Rejected framings
50
+
51
+ - **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
52
+ - **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
53
+ - **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
@@ -100,6 +100,8 @@ loop-agent --help
100
100
  ```bash
101
101
  loop-agent inspect # 当前 repo(自动检测)
102
102
  loop-agent --repo-root /path/to/target-repo inspect # 指定 repo
103
+ loop-agent inspect next # 当前 npm next 绑定(version / SHA / unpublished commits)
104
+ loop-agent inspect next --json
103
105
  ```
104
106
 
105
107
  ### 健康检查
@@ -132,13 +134,18 @@ SDK 回归或 SDK 可选依赖不可用时用 `cli-only` 诊断。CLI fallback
132
134
 
133
135
  ```bash
134
136
  loop-agent init instructions --repo-root <target-repo>
137
+ loop-agent init model-catalog --repo-root <target-repo> --json
135
138
  loop-agent init --repo-root <target-repo> --profile full --merge \
136
- --provider deepseek --model deepseek/deepseek-v4-flash
139
+ --low-model deepseek/deepseek-chat \
140
+ --med-model deepseek/deepseek-v4-flash \
141
+ --high-model deepseek/deepseek-v4-pro
137
142
  loop-agent init doctor --repo-root <target-repo>
138
143
  loop-agent init check-update --repo-root <target-repo> --json
139
144
  loop-agent init check-update --repo-root <target-repo> --markdown
140
145
  loop-agent init update --repo-root <target-repo> --bootstrap-surface
141
146
  loop-agent init update --repo-root <target-repo> --apply-safe
147
+ loop-agent init update --repo-root <target-repo> --apply-safe \
148
+ --low-model <current-or-selected> --med-model <current-or-selected> --high-model <current-or-selected>
142
149
  loop-agent init reconcile --repo-root <target-repo> [--json|--markdown] # compatibility low-level diagnostic
143
150
  loop-agent init upgrade --repo-root <target-repo> --json
144
151
  loop-agent init upgrade --repo-root <target-repo> --run-id <run-id> --status --json
@@ -146,13 +153,13 @@ loop-agent init upgrade --repo-root <target-repo> --run-id <run-id> --continue -
146
153
  loop-agent init upgrade --repo-root <target-repo> --run-id <run-id> --report --markdown
147
154
  ```
148
155
 
149
- fresh init 将精确引用写到 `executors.pi.LOW/MED/HIGH`。fresh `loop-agent init` 会将合格且完整的 `provider/model` 引用投影到 `executors.pi.LOW/MED/HIGH`,即 `executors.pi.LOW`、`executors.pi.MED` 和 `executors.pi.HIGH`。三个 tier 齐全时不会写入 `defaultModel`,也不会恢复或建议旧顶层 routing 字段。
156
+ fresh init 将精确引用写到 `executors.pi.LOW/MED/HIGH`。模型先运行只读 `init model-catalog`:Pi SDK runtime 与 OpenCode 非 verbose 列表由代码确定性发现,只向模型暴露 provider/model、能力/成本/窗口元数据、Pi setup、兼容性与 credential-ready 布尔值,不暴露原始配置和凭据。已有档位仍存在于 Pi 时原样保留,只重选失效/缺失档位;代码在 update 时拒绝替换仍有效档位。对于 `wizard-local`,四个精确模型 ID 的家族内能力顺序是 `aicoder-default < aicoder-plus < aicoder-pro < aicoder-max`;catalog 以 `relativeCapability` 暴露此顺序,模型仍结合成本、窗口和目标项目选择三档,不机械一一绑定。Pi 无定义时先向用户补齐必要模型元数据并帮助字段级配置 `models.json`;只有认证缺失时保留 harness 并修复认证。三个 tier 齐全时不会写入 `defaultModel`,也不会恢复旧顶层 routing 字段。
150
157
 
151
158
  `init check-update` 是只读升级报告,用于发现目标项目是否落后于当前包内初始化 surface。输出会区分 deterministic actions、model merge tasks、human decisions 和 recommended next。`--markdown` 会渲染可直接交给模型执行的合并指引,包含 `allowedPaths`、`forbiddenPaths`、`mergeRules` 和 `verification`。
152
159
 
153
- `init update --bootstrap-surface` 为旧项目写入 `.harness/init-surface.json` 的 `inferred-baseline`,不伪装成历史 recorded baseline。`init update --apply-safe` 只执行确定性安全动作:补缺失文件、创建目录、刷新 managed block;已有但无法确认与当前包一致的文件会进入 model merge tasks,不会被覆盖。模型 merge 只会自动展开不含 tier 或其他旧字段的唯一、完整且可证明等价的旧 `defaultModel: "provider/model"`;顶层 `model`、`models`、`modelProfiles`、`modelRouting`、`verify`、`sequentialWorkflowRole`、部分/对象 tier、bare model、冲突 provider 或未知语义均 fail closed,并保留原始 `harness.json`。
160
+ `init update --bootstrap-surface` 为旧项目写入 `.harness/init-surface.json` 的 `inferred-baseline`,不伪装成历史 recorded baseline。`init update --apply-safe` 只执行确定性安全动作:补缺失文件、创建目录、刷新 managed block;`harness.json` 永不走整文件 `refresh-owned-file`,即使它仍与旧 recorded hash 一致,也只允许字段级确定性迁移或 bounded merge。带完整三档参数的 update 只替换 catalog 已判定失效的档位,仍有效档位的对象形态与 thinking 配置保持不变。模型 merge 只会自动展开不含 tier 或其他旧字段的唯一、完整且可证明等价的旧 `defaultModel: "provider/model"`;其他歧义均 fail closed 并保留原文件。
154
161
 
155
- `init upgrade` 是写入型升级入口:首次运行冻结 controller identity、检查 npm latest、扫描 surface、自动执行安全动作,并把 run facts 持久化到 `.harness/init-upgrades/<run-id>/`。`--status` 与 `--report` 严格只读;`--continue` 会重新核验 identity、当前 hash 与不变量。版本选择、无法判定冲突、凭据、破坏性删除或 active writer 才进入 human decision。普通语义冲突返回具体单文件 `allowedPaths` merge task,主会话必须合并后继续,不能把 `needs-model-merge` 作为完成。默认管理项目级 OpenCode/Pi recovery 与 `.pi/settings.json` nested merge,保留显式 disabled,Pi trust 后才加载;默认不读写 `~/.pi/agent/settings.json`。旧 `init reconcile` 保留为兼容低层诊断。
162
+ `init upgrade` 是写入型升级入口:首次运行冻结 controller identity 与脱敏模型目录,检查 npm latest,并用一次 surface scan 形成完整计划。固定投影按 recorded bytes 确定性增删改;recorded `harness.json` 按属性树增删字段并保留项目值、同步 schema;项目自适应内容由模型决定。多个语义合并在同一计划中串行排队,每次仍只开放一个文件的 `allowedPaths`;接受后直接激活下一项,不重复版本发现/规划,队列清空后只跑一次最终验证。确定性收敛最多两轮。完成态的 verification/report 均有 controller hash anchor,`--status`、`--report` 和已完成 run 的幂等 `--continue` 只读持久化证据,不重新跑项目校验。默认管理项目级 OpenCode/Pi recovery 与 `.pi/settings.json` nested merge,默认不读写 `~/.pi/agent/settings.json`。旧 `init reconcile` 保留为兼容低层诊断。
156
163
 
157
164
  升级在 managed block 收敛后生成只读 gitignore 迁移评估(`.harness/init-upgrades/<run-id>/gitignore-migration.json`):inventory 已跟踪的 `.harness/**` 与 `.agents/**`,建议 index-only 命令 `git rm -r --cached --ignore-unmatch .harness` / `.agents`(只改 index、保留工作区文件;`scripts/**` 与 `ai_workspace/loop-agent/**` 永不出现)。`.agents` 已跟踪内容会触发 human-decision 暂停等待审查;非 Git 仓库、git 查询失败或存在 staged 条目时 `status: blocked` 且无命令建议。controller 不自动修改 Git index。
158
165
 
@@ -182,6 +189,20 @@ loop-agent task status <task-id> --json
182
189
 
183
190
  PRD 原文 **不改写**;冲突时以 `source/references/*` 为准。`referenceDocs` 是 `{ path, name? }[]` 对象数组。
184
191
 
192
+ ### 确定性任务源投影(task source prepare)
193
+
194
+ ```bash
195
+ loop-agent task source prepare <task-id> \
196
+ --from-text "需求文本" \
197
+ --objective "<目标>" --scope "<范围>" \
198
+ --ac "AC-1: <验收>" \
199
+ --allowed-path "src/**" \
200
+ --dry-run | --apply
201
+ loop-agent task source prepare <task-id> --from-draft <TaskContractDraftV1.json> --apply
202
+ ```
203
+
204
+ `task source prepare` 将 PRD/draft/文本投影为确定性的 `source/需求.md` / `执行约束.md`(managed contract),不改写已导入的 PRD 原文;`--apply` 落盘,`--dry-run` 只投影不写。完整 flag 面见 `task source prepare --help`;任务推进仍走 `task advance`。
205
+
185
206
  ### Task Contract / operator machine surface
186
207
 
187
208
  ```bash
@@ -326,7 +347,14 @@ loop-agent dag reconcile-run --run-id <run-id> --action abandon --reason "..."
326
347
  loop-agent dag request-interrupt --run-id <run-id> --request-id <id> --target-operation-id <id> --reason-code <code> --reason <detail> [--json] # 协作中止:写入 interrupt.json(identity CAS);需配 --expected-runner-pid/--expected-runner-hostname 校验 runner 身份
327
348
  loop-agent dag rerun --run-id <run-id> --from-node <node-id> --plan [--json] # 从节点重跑资格预检(不执行)
328
349
  loop-agent dag rerun --run-id <run-id> --from-node <node-id> --plan-hash <sha256> --request-id <key> --reason "..." [--json] # 安全子图 continuation
350
+ loop-agent dag context show --run-id <run-id> --node-id <node-id> --attempt <n> --json # 有界 effective-context 摘要
351
+ loop-agent dag context export --run-id <run-id> --node-id <node-id> --attempt <n> --target <generic|pi-session|pi-handoff|readable> --output <bundle.zip> # 默认 redacted;raw 另需显式确认
352
+ loop-agent dag artifact consumers --run-id <run-id> --node-id <producer> --artifact <relative-path> --json # 只读 frozen binding consumer
353
+ loop-agent dag artifact revision stage --run-id <run-id> --node-id <producer> --artifact <relative-path> --file <replacement> --request-id <key> --json # 暂存 revision,不修改 parent
354
+ loop-agent dag artifact revision discard --revision-id <revision-id> --request-id <key> --json
355
+ loop-agent dag rerun --run-id <run-id> --artifact-revision <revision-id> --plan [--json] # 单产物影响闭包预检
329
356
  loop-agent dag rerun-task --run-id <run-id> --reason "..." --request-id <key> [--profile auto] [--task-id <id>] [--json] # standalone 完整任务重跑
357
+ loop-agent dag follow-up <parent-run-id> [--task-id <id>] [--execute] [--profile auto|minimal|standard|reviewed|supervised] # 将 frontend review 的 request_review_changes findings 物化为下游 frontend task;默认只创建并返回 task advance 命令
330
358
  loop-agent dag request-interrupt --run-id <run-id> --request-id <key> --target-operation-id <op-id> --reason-code <code> --reason "..." --expected-runner-pid <pid> --expected-runner-hostname <host> --expected-runner-started-at <ts> --expected-controller-fingerprint <fingerprint> # 协作式中止:经 Human Gate 登记 interrupt.json,runner 等当前节点安全收敛后再停调度,不直接 SIGKILL
331
359
  loop-agent dag reconcile-tasks --glob '<pattern>' # 仅报告的 task/run/artifact/verify drift audit
332
360
  loop-agent dag final-verification <task-id> # 生成 closeout DAG,closeout artifact 后再 final verify