@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6

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 (552) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +441 -2525
  3. package/README.md +19 -12
  4. package/dist/adapters/loop-agent.js +34 -0
  5. package/dist/application/dag/args.js +8 -0
  6. package/dist/application/dag/run-dag.js +5 -0
  7. package/dist/application/evaluation/budget.js +40 -1
  8. package/dist/application/evaluation/corpus-hash.js +10 -15
  9. package/dist/application/evaluation/corpus.js +2 -1
  10. package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
  11. package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
  12. package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
  13. package/dist/application/evaluation/frontend-pair-registration.js +143 -0
  14. package/dist/application/evaluation/frontend-paired-summary.js +150 -0
  15. package/dist/application/evaluation/frontend-run-observation.js +144 -0
  16. package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
  17. package/dist/application/evaluation/types.js +45 -12
  18. package/dist/application/task-lifecycle/advance.js +64 -15
  19. package/dist/application/task-lifecycle/observe.js +69 -30
  20. package/dist/application/task-lifecycle/plan-transitions.js +5 -4
  21. package/dist/build-stamp.json +3 -3
  22. package/dist/cli/command-definitions.js +18 -5
  23. package/dist/cli/program.js +8 -5
  24. package/dist/cli/update/init-surface-notifier.js +2 -0
  25. package/dist/cli/update/policy.js +2 -0
  26. package/dist/commands/client-recovery.js +20 -55
  27. package/dist/commands/cursor-prompt.js +2 -0
  28. package/dist/commands/dag-approve.js +2 -0
  29. package/dist/commands/dag-final-verification.js +2 -0
  30. package/dist/commands/dag-init-hybrid.js +2 -0
  31. package/dist/commands/dag-reconcile-tasks.js +2 -0
  32. package/dist/commands/dag-reject.js +2 -0
  33. package/dist/commands/dag-report.js +2 -0
  34. package/dist/commands/dag-rerun.js +2 -0
  35. package/dist/commands/dag-resume.js +2 -0
  36. package/dist/commands/dag-workflow-compile.js +2 -0
  37. package/dist/commands/dag-workflow-plan.js +2 -0
  38. package/dist/commands/dag-workflow-validate.js +2 -0
  39. package/dist/commands/delegate.js +2 -0
  40. package/dist/commands/examples.js +2 -0
  41. package/dist/commands/import-prd.js +2 -0
  42. package/dist/commands/init-legacy-audit.js +330 -0
  43. package/dist/commands/init-model-catalog.js +2 -0
  44. package/dist/commands/init-upgrade.js +644 -104
  45. package/dist/commands/init.js +700 -338
  46. package/dist/commands/instructions.js +2 -0
  47. package/dist/commands/knowledge.js +2 -0
  48. package/dist/commands/loop-benchmark.js +2 -0
  49. package/dist/commands/operator-guide.js +99 -0
  50. package/dist/commands/operator.js +16 -3
  51. package/dist/commands/pi-prompt.js +2 -0
  52. package/dist/commands/pi-reuse-benchmark.js +2 -0
  53. package/dist/commands/promote-run.js +2 -0
  54. package/dist/commands/stats.js +1 -1
  55. package/dist/commands/study-init.js +2 -0
  56. package/dist/commands/task-advance.js +32 -0
  57. package/dist/commands/task-source-prepare.js +18 -2
  58. package/dist/commands/worktree-create.js +2 -0
  59. package/dist/commands/worktree-remove.js +2 -0
  60. package/dist/executors/dag-pi/guards.js +4 -0
  61. package/dist/executors/dag-pi/model-config.js +30 -0
  62. package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
  63. package/dist/executors/dag-pi/plan/facts.js +180 -0
  64. package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
  65. package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
  66. package/dist/executors/dag-pi/plan/record-tools.js +861 -0
  67. package/dist/executors/dag-pi/plan/schema.js +129 -0
  68. package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
  69. package/dist/executors/dag-pi/sessions/index.js +6 -0
  70. package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
  71. package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
  72. package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
  73. package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
  74. package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
  75. package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
  76. package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
  77. package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
  78. package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
  79. package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
  80. package/dist/executors/dag-pi-executor.js +1516 -3181
  81. package/dist/executors/pi-executor.js +112 -4
  82. package/dist/executors/pi-sdk-executor.js +258 -44
  83. package/dist/executors/pi-writer-tool-policy.js +60 -4
  84. package/dist/executors/playwright-cli-launcher.js +31 -45
  85. package/dist/executors/shell-executor.js +313 -48
  86. package/dist/executors/shell-presets.js +1 -1
  87. package/dist/executors/shell-verification.js +3 -0
  88. package/dist/executors/shell-write-guard.js +77 -102
  89. package/dist/governance/exec-plans.js +16 -4
  90. package/dist/governance/harness.js +2 -7
  91. package/dist/governance/manifest-types.js +28 -9
  92. package/dist/governance/project-capability-scanner.js +263 -0
  93. package/dist/governance/project-config.js +96 -0
  94. package/dist/governance/resource-catalog.js +151 -0
  95. package/dist/infrastructure/console/app-data.js +12 -2
  96. package/dist/infrastructure/console/operation-store.js +48 -14
  97. package/dist/infrastructure/evaluation/corpus-store.js +37 -12
  98. package/dist/shared/artifacts-core.js +2 -0
  99. package/dist/shared/backend-dogfood-preflight.js +47 -0
  100. package/dist/shared/dag-failure-category.js +9 -0
  101. package/dist/shared/file-identity.js +23 -0
  102. package/dist/shared/frontend-execution-policy.js +23 -0
  103. package/dist/shared/git-progress.js +2 -0
  104. package/dist/shared/git-workspace-status.js +482 -0
  105. package/dist/shared/one-shot-prompt-args.js +2 -0
  106. package/dist/shared/operator/capabilities.js +185 -0
  107. package/dist/shared/package-metadata.js +29 -11
  108. package/dist/shared/path-safety.js +2 -2
  109. package/dist/shared/pi-context-pressure/extension.js +49 -16
  110. package/dist/shared/pi-context-pressure/index.js +1 -0
  111. package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
  112. package/dist/shared/pi-context-pressure/telemetry.js +4 -0
  113. package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
  114. package/dist/shared/pi-provider-recovery.js +182 -0
  115. package/dist/shared/pi-retry-settings.js +40 -0
  116. package/dist/shared/reference-context.js +2 -0
  117. package/dist/shared/update/npm-client.js +49 -1
  118. package/dist/shared/wizard-local-telemetry.js +51 -0
  119. package/dist/task/config-types.js +51 -2
  120. package/dist/task/contract/apply.js +36 -2
  121. package/dist/task/contract/project.js +22 -0
  122. package/dist/task/contract/recover.js +6 -0
  123. package/dist/task/contract/schema.js +12 -0
  124. package/dist/task/frontend-preflight.js +1 -1
  125. package/dist/task/source-prepare/artifact-meta.js +9 -2
  126. package/dist/task/source-prepare/build-draft.js +61 -0
  127. package/dist/task/source-prepare/fragment-inventory.js +4 -1
  128. package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
  129. package/dist/task/source-prepare/ledger-review.js +6 -9
  130. package/dist/task/source-prepare/parse-intent.js +165 -14
  131. package/dist/task/source-prepare/path-policy.js +17 -7
  132. package/dist/task/source-prepare/prepare.js +6 -1
  133. package/dist/task/source-prepare/semantic-intake.js +33 -28
  134. package/dist/task/source-prepare/source-execution.js +65 -0
  135. package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
  136. package/dist/task/source-prepare/source-provider-budget.js +290 -0
  137. package/dist/task/source-references.js +48 -23
  138. package/dist/task/task-demand-routing.js +5 -2
  139. package/dist/worker/cli.js +3 -5
  140. package/dist/worker/console/chat/assistant-content.js +5 -13
  141. package/dist/worker/console/chat/browser-automation.js +937 -0
  142. package/dist/worker/console/chat/browser-content.js +74 -0
  143. package/dist/worker/console/chat/browser-diagnostics.js +250 -0
  144. package/dist/worker/console/chat/browser-evaluation.js +58 -0
  145. package/dist/worker/console/chat/browser-operation-queue.js +19 -0
  146. package/dist/worker/console/chat/browser-pick.js +113 -0
  147. package/dist/worker/console/chat/browser-policy.js +113 -0
  148. package/dist/worker/console/chat/browser-routes.js +329 -0
  149. package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
  150. package/dist/worker/console/chat/browser-storage.js +89 -0
  151. package/dist/worker/console/chat/chat-event-store.js +73 -18
  152. package/dist/worker/console/chat/context-insights.js +788 -0
  153. package/dist/worker/console/chat/conversation-nodes.js +383 -0
  154. package/dist/worker/console/chat/db-connections.js +854 -0
  155. package/dist/worker/console/chat/explore-tools.js +18 -2
  156. package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
  157. package/dist/worker/console/chat/pet/pet-persist.js +109 -0
  158. package/dist/worker/console/chat/pet/pet-registry.js +142 -0
  159. package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
  160. package/dist/worker/console/chat/pet/pet-routes.js +125 -0
  161. package/dist/worker/console/chat/pet/pet-service.js +262 -0
  162. package/dist/worker/console/chat/pet/pet-state.js +99 -0
  163. package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
  164. package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
  165. package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
  166. package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
  167. package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
  168. package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
  169. package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
  170. package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
  171. package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
  172. package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
  173. package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
  174. package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
  175. package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
  176. package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
  177. package/dist/worker/console/chat/pi-runtime.js +793 -1230
  178. package/dist/worker/console/chat/provider-error.js +0 -12
  179. package/dist/worker/console/chat/repo-browser.js +132 -6
  180. package/dist/worker/console/chat/repo-preview-kind.js +155 -0
  181. package/dist/worker/console/chat/resource-loader.js +4 -1
  182. package/dist/worker/console/chat/routes.js +861 -148
  183. package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
  184. package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
  185. package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
  186. package/dist/worker/console/chat/scm-routes.js +217 -0
  187. package/dist/worker/console/chat/scm-service.js +283 -0
  188. package/dist/worker/console/chat/scm-tools.js +111 -0
  189. package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
  190. package/dist/worker/console/chat/session-catalog.js +32 -0
  191. package/dist/worker/console/chat/session-mode-view.js +49 -0
  192. package/dist/worker/console/chat/session-mode.js +224 -0
  193. package/dist/worker/console/chat/session-store.js +232 -32
  194. package/dist/worker/console/chat/shortcuts.js +13 -0
  195. package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
  196. package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
  197. package/dist/worker/console/chat/subagents/index.js +5 -0
  198. package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
  199. package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
  200. package/dist/worker/console/chat/subagents/types.js +13 -0
  201. package/dist/worker/console/chat/terminal-routes.js +216 -0
  202. package/dist/worker/console/chat/terminal-sessions.js +348 -0
  203. package/dist/worker/console/chat/terminal-tools.js +211 -0
  204. package/dist/worker/console/chat/timeline-message-order.js +22 -0
  205. package/dist/worker/console/chat/tool-preview.js +136 -0
  206. package/dist/worker/console/chat/tools.js +69 -1
  207. package/dist/worker/console/chat/turn-order.js +13 -0
  208. package/dist/worker/console/chat/turn-process.js +210 -36
  209. package/dist/worker/console/chat/user-turn-outline.js +19 -0
  210. package/dist/worker/console/console-shutdown.js +34 -0
  211. package/dist/worker/console/console-update-and-init.js +1 -19
  212. package/dist/worker/console/console-update-runtime.js +7 -22
  213. package/dist/worker/console/dag-confirmation.js +3 -0
  214. package/dist/worker/console/dag-execution-receipt.js +3 -0
  215. package/dist/worker/console/interview/tools.js +1 -0
  216. package/dist/worker/console/operator-actions.js +95 -4
  217. package/dist/worker/console/operator-user-error.js +28 -1
  218. package/dist/worker/console/pi-readiness.js +4 -4
  219. package/dist/worker/console/prd-intake-bridge.js +47 -1
  220. package/dist/worker/console/recovery-cta.js +14 -14
  221. package/dist/worker/console/routes.js +13 -0
  222. package/dist/worker/console/scheduled-goal-host.js +98 -0
  223. package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
  224. package/dist/worker/console/server.js +33 -31
  225. package/dist/worker/console/static/app-icon.svg +39 -0
  226. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
  227. package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
  228. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
  229. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
  230. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
  231. package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
  232. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
  233. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
  234. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
  235. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
  236. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
  237. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
  238. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
  239. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
  240. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
  241. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
  242. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
  243. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
  244. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
  245. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
  246. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
  247. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
  248. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
  249. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
  250. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
  251. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
  252. package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
  253. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
  254. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
  255. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
  256. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
  257. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
  258. package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
  259. package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
  260. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
  261. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
  262. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
  263. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
  264. package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
  265. package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
  266. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
  267. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
  268. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
  269. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
  270. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
  271. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
  272. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
  273. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
  274. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
  275. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
  276. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
  277. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
  278. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
  279. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
  280. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
  281. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
  282. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
  283. package/dist/worker/console/static/index.html +5 -2
  284. package/dist/worker/console/static/manifest.webmanifest +19 -0
  285. package/dist/worker/console/static/pets/ember/pet.json +167 -0
  286. package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
  287. package/dist/worker/console/static-src/app/console-types.js +9 -1
  288. package/dist/worker/console/static-src/chat-view-types.js +1 -1
  289. package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
  290. package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
  291. package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
  292. package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
  293. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
  294. package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
  295. package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
  296. package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
  297. package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
  298. package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
  299. package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
  300. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
  301. package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
  302. package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
  303. package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
  304. package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
  305. package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
  306. package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
  307. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
  308. package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
  309. package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
  310. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
  311. package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
  312. package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
  313. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
  314. package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
  315. package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
  316. package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
  317. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
  318. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
  319. package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
  320. package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
  321. package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
  322. package/dist/worker/console/static-src/prd-file-import.js +3 -1
  323. package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
  324. package/dist/worker/console/workspace-context.js +54 -1
  325. package/dist/worker/console/workspace-initialization.js +218 -0
  326. package/dist/worker/delivery/git-transaction.js +2 -0
  327. package/dist/worker/delivery/package.js +4 -1
  328. package/dist/worker/feature/fullstack-validate.js +2 -0
  329. package/dist/worker/loop-agent/loop-agent-client.js +8 -2
  330. package/dist/worker/materialize/harness-task-lineage.js +4 -2
  331. package/dist/worker/materialize/harness-task-materializer.js +4 -1
  332. package/dist/worker/metrics/projector.js +1 -1
  333. package/dist/worker/observability/event-store.js +4 -1
  334. package/dist/worker/observability/read-model.js +27 -3
  335. package/dist/worker/observe/node-context-insights.js +479 -0
  336. package/dist/worker/observe/node-transparency.js +103 -72
  337. package/dist/worker/observe/routes.js +24 -1
  338. package/dist/worker/observe/static/console-theme.css +178 -0
  339. package/dist/worker/observe/static/console-theme.js +74 -0
  340. package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
  341. package/dist/worker/observe/static/dom.js +20 -1
  342. package/dist/worker/observe/static/format-pool.d.ts +2 -0
  343. package/dist/worker/observe/static/format-pool.js +6 -0
  344. package/dist/worker/observe/static/format.js +7 -0
  345. package/dist/worker/observe/static/inspect-workspace.js +34 -7
  346. package/dist/worker/observe/static/inspector-submission.js +32 -0
  347. package/dist/worker/observe/static/kpi.js +1 -0
  348. package/dist/worker/observe/static/operator-chrome.css +85 -0
  349. package/dist/worker/observe/static/operator-chrome.js +13 -1
  350. package/dist/worker/observe/static/relations.js +2 -0
  351. package/dist/worker/observe/static/router.js +13 -0
  352. package/dist/worker/observe/static/run-processing.js +2 -0
  353. package/dist/worker/observe/static/shell-chrome.js +36 -3
  354. package/dist/worker/observe/static/state.js +35 -2
  355. package/dist/worker/observe/static/styles.css +263 -39
  356. package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
  357. package/dist/worker/observe/static/task-failure-labels.js +67 -0
  358. package/dist/worker/observe/static/task-history.js +12 -0
  359. package/dist/worker/observe/static/views/batch.js +6 -13
  360. package/dist/worker/observe/static/views/dag-graph.js +50 -3
  361. package/dist/worker/observe/static/views/dag-inspector.js +742 -268
  362. package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
  363. package/dist/worker/observe/static/views/dag.d.ts +6 -0
  364. package/dist/worker/observe/static/views/dag.js +49 -11
  365. package/dist/worker/observe/static/views/dags.js +2 -0
  366. package/dist/worker/observe/static/views/dashboard.js +21 -12
  367. package/dist/worker/observe/static/views/failures.js +21 -11
  368. package/dist/worker/observe/static/views/feature.js +11 -29
  369. package/dist/worker/observe/static/views/pool.js +37 -28
  370. package/dist/worker/observe/static/views/run.js +48 -5
  371. package/dist/worker/observe/static/views/session-timeline.js +189 -240
  372. package/dist/worker/observe/static/views/task.js +81 -62
  373. package/dist/worker/outcomes/declared-artifacts.js +2 -0
  374. package/dist/worker/preflight.js +3 -0
  375. package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
  376. package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
  377. package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
  378. package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
  379. package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
  380. package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
  381. package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
  382. package/dist/worker/task-spec/validate.js +4 -1
  383. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
  384. package/dist/workflows/dag/backend-test-layout.js +27 -7
  385. package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
  386. package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
  387. package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
  388. package/dist/workflows/dag/budget-enforcement.js +82 -3
  389. package/dist/workflows/dag/checkpoint.js +686 -0
  390. package/dist/workflows/dag/dag-retry-schema.js +14 -0
  391. package/dist/workflows/dag/decision-envelope.js +2 -0
  392. package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
  393. package/dist/workflows/dag/final-verification.js +45 -10
  394. package/dist/workflows/dag/frontend-capacity.js +9 -0
  395. package/dist/workflows/dag/frontend-closeout.js +5 -1
  396. package/dist/workflows/dag/frontend-committed-facts.js +461 -0
  397. package/dist/workflows/dag/frontend-contract-facts.js +133 -0
  398. package/dist/workflows/dag/frontend-design-policy.js +107 -21
  399. package/dist/workflows/dag/frontend-durable-tools.js +225 -0
  400. package/dist/workflows/dag/frontend-execution-groups.js +24 -0
  401. package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
  402. package/dist/workflows/dag/frontend-input-projection.js +76 -0
  403. package/dist/workflows/dag/frontend-plan-canary.js +103 -0
  404. package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
  405. package/dist/workflows/dag/frontend-plan-progress.js +92 -0
  406. package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
  407. package/dist/workflows/dag/frontend-plan-render.js +21 -5
  408. package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
  409. package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
  410. package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
  411. package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
  412. package/dist/workflows/dag/frontend-recovery-run.js +148 -47
  413. package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
  414. package/dist/workflows/dag/frontend-repair.js +79 -76
  415. package/dist/workflows/dag/frontend-review-context.js +71 -69
  416. package/dist/workflows/dag/frontend-review-scopes.js +237 -0
  417. package/dist/workflows/dag/frontend-risk.js +101 -12
  418. package/dist/workflows/dag/frontend-root-observation.js +261 -0
  419. package/dist/workflows/dag/frontend-session-budget.js +376 -0
  420. package/dist/workflows/dag/frontend-session-context.js +10 -0
  421. package/dist/workflows/dag/frontend-shape-facts.js +12 -2
  422. package/dist/workflows/dag/frontend-shape.js +27 -32
  423. package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
  424. package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
  425. package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
  426. package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
  427. package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
  428. package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
  429. package/dist/workflows/dag/frontend-test-layout.js +41 -12
  430. package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
  431. package/dist/workflows/dag/frontend-verification-trace.js +65 -48
  432. package/dist/workflows/dag/frontend-writer-admission.js +6 -48
  433. package/dist/workflows/dag/frontend-writer-status.js +0 -23
  434. package/dist/workflows/dag/hybrid/sources.js +1831 -0
  435. package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
  436. package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
  437. package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
  438. package/dist/workflows/dag/hybrid/templates/index.js +8 -0
  439. package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
  440. package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
  441. package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
  442. package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
  443. package/dist/workflows/dag/hybrid/types.js +32 -0
  444. package/dist/workflows/dag/init-hybrid.js +57 -7167
  445. package/dist/workflows/dag/interrupt-request.js +2 -0
  446. package/dist/workflows/dag/lifecycle.js +11 -2
  447. package/dist/workflows/dag/node-execution.js +257 -247
  448. package/dist/workflows/dag/output-protocol.js +1 -0
  449. package/dist/workflows/dag/prompt.js +4 -0
  450. package/dist/workflows/dag/reconcile-run.js +2 -0
  451. package/dist/workflows/dag/repair-artifact.js +3 -1
  452. package/dist/workflows/dag/report.js +2 -0
  453. package/dist/workflows/dag/rerun-feedback.js +36 -4
  454. package/dist/workflows/dag/rerun-plan.js +106 -4
  455. package/dist/workflows/dag/rerun-run.js +7 -0
  456. package/dist/workflows/dag/rerun-task.js +75 -1
  457. package/dist/workflows/dag/retry-policy.js +34 -10
  458. package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
  459. package/dist/workflows/dag/runner.js +38 -1074
  460. package/dist/workflows/dag/scheduler.js +2 -4
  461. package/dist/workflows/dag/skill-instructions.js +102 -32
  462. package/dist/workflows/dag/skill-snapshot.js +3 -0
  463. package/dist/workflows/dag/skills.js +7 -7
  464. package/dist/workflows/dag/structured-output-repair.js +4 -1
  465. package/dist/workflows/dag/terminal-status.js +502 -0
  466. package/dist/workflows/dag/test-artifact-namespace.js +73 -0
  467. package/dist/workflows/dag/types.js +58 -7
  468. package/dist/workflows/dag/validate.js +38 -13
  469. package/dist/workflows/dag/workspace-checkpoint.js +79 -1
  470. package/dist/workflows/loop/benchmark.js +11 -8
  471. package/docs/README.md +2 -1
  472. package/docs/architecture/dag-execution.md +4 -4
  473. package/docs/architecture/runtime-boundaries.md +29 -23
  474. package/docs/governance/README.md +1 -0
  475. package/docs/governance/harness-methodology-verification.md +11 -0
  476. package/docs/init-surface.manifest.json +44 -295
  477. package/docs/operations/README.md +4 -0
  478. package/docs/templates/README.md +5 -5
  479. package/docs/templates/agent-dag.base.json +9 -9
  480. package/docs/templates/agent-dag.final-verification.json +6 -6
  481. package/docs/templates/agent-dag.schema.json +2 -2
  482. package/docs/templates/agent-dag.supervised-implementation.json +12 -12
  483. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
  484. package/docs/templates/backend-test-dag.json +708 -703
  485. package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
  486. package/docs/templates/frontend-design-contract.md +4 -4
  487. package/docs/templates/frontend-implementation-contract.schema.json +99 -22
  488. package/docs/templates/frontend-implementation-dag.json +7 -7
  489. package/docs/templates/frontend-test-case-checklist.md +2 -2
  490. package/docs/templates/frontend-test-case.example.md +2 -0
  491. package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
  492. package/docs/templates/frontend-test-dag.json +46 -37
  493. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
  494. package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
  495. package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
  496. package/docs/templates/hybrid-dag.json +9 -9
  497. package/docs/templates/knowledge-sync-dag.json +8 -8
  498. package/harness.json +1 -1
  499. package/package.json +27 -8
  500. package/resource-catalog.v1.json +1981 -0
  501. package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
  502. package/resources/init-history/legacy-surface.v1.json +33 -0
  503. package/skills/fe-test-ui-scout/SKILL.md +4 -4
  504. package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
  505. package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
  506. package/skills/frontend-contract/SKILL.md +2 -1
  507. package/skills/frontend-contract/references/contract-protocol.md +22 -4
  508. package/skills/frontend-design-review/SKILL.md +16 -18
  509. package/skills/frontend-design-review/references/review-checklist.md +3 -4
  510. package/skills/frontend-plan/SKILL.md +25 -3
  511. package/skills/frontend-plan/references/decision-contract.md +117 -8
  512. package/skills/frontend-plan/references/design-decisions.md +32 -0
  513. package/skills/frontend-review/SKILL.md +29 -36
  514. package/skills/frontend-review/references/review-findings.md +8 -3
  515. package/skills/frontend-scout/references/scout-evidence.md +4 -0
  516. package/skills/init-update/SKILL.md +34 -0
  517. package/skills/init-update/agents/openai.yaml +6 -0
  518. package/skills/loop-agent/references/command-reference.md +8 -0
  519. package/skills/loop-agent/references/hybrid-dag.md +1 -1
  520. package/skills/playwright-cli/SKILL.md +1 -1
  521. package/skills/playwright-cli-case-generator/SKILL.md +7 -5
  522. package/dist/commands/new-task.js +0 -5
  523. package/dist/commands/status.js +0 -57
  524. package/dist/commands/task-contract.js +0 -269
  525. package/dist/shared/prompts.js +0 -26
  526. package/dist/task/config.js +0 -2
  527. package/dist/task/contract/validate-draft.js +0 -106
  528. package/dist/task/goal.js +0 -3
  529. package/dist/task/index.js +0 -12
  530. package/dist/task/lifecycle.js +0 -1
  531. package/dist/task/operator/capabilities.js +0 -6
  532. package/dist/task/operator/envelope.js +0 -2
  533. package/dist/task/operator/index.js +0 -5
  534. package/dist/task/operator/registry.js +0 -2
  535. package/dist/task/paths.js +0 -1
  536. package/dist/task/source-state.js +0 -1
  537. package/dist/task/subagent-guidance.js +0 -1
  538. package/dist/worker/console/chat/sift-bridge.js +0 -1
  539. package/dist/worker/console/index.js +0 -20
  540. package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
  541. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
  542. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
  543. package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
  544. package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
  545. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
  546. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
  547. package/dist/worker/scheduler/index.js +0 -25
  548. package/dist/workflows/dag/facts.js +0 -4
  549. package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
  550. package/dist/workflows/dag/index.js +0 -6
  551. package/dist/workflows/dynamic/index.js +0 -7
  552. /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
@@ -0,0 +1,482 @@
1
+ import { access, lstat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { runResilientGitCommand } from "./resilient-git.js";
4
+ const MAX_SUBMODULE_DEPTH = 4;
5
+ export const DEFAULT_WORKSPACE_STATUS_DEPENDENCIES = {
6
+ runGit: (cwd, args) => runResilientGitCommand({ cwd, args, readOnly: true }).then((result) => ({
7
+ code: result.code,
8
+ stdout: result.stdout,
9
+ stderr: result.stderr,
10
+ })),
11
+ readSubmoduleStatus: async (cwd) => {
12
+ const result = await runResilientGitCommand({
13
+ cwd,
14
+ args: ["status", "--porcelain=v1", "--untracked-files=all"],
15
+ readOnly: true,
16
+ });
17
+ if (result.code !== 0) {
18
+ throw new Error(result.stderr.trim() ||
19
+ result.stdout.trim() ||
20
+ `git status exited ${result.code}`);
21
+ }
22
+ return result.stdout;
23
+ },
24
+ };
25
+ /** Parse porcelain v1 output into normalized path -> "XY" entries. */
26
+ export function parsePorcelainEntries(porcelain) {
27
+ const entries = new Map();
28
+ for (const line of porcelain.split("\n")) {
29
+ const trimmed = line.trimEnd();
30
+ if (!trimmed)
31
+ continue;
32
+ const x = trimmed[0] ?? " ";
33
+ const y = trimmed[1] ?? " ";
34
+ const rawPath = trimmed.slice(3);
35
+ if (!rawPath)
36
+ continue;
37
+ const normalized = normalizeWorkspacePath(unquoteGitPath(renameTargetPath(rawPath)));
38
+ if (!normalized)
39
+ continue;
40
+ entries.set(normalized, `${x}${y}`);
41
+ }
42
+ return entries;
43
+ }
44
+ /**
45
+ * Return the destination path of a porcelain path field. Rename entries
46
+ * render as `ORIG -> DEST` where either side may independently be C-quoted;
47
+ * splitting on a quoted ` -> ` (or unquoting before splitting) corrupts the
48
+ * key with residual quotes or half-decoded octal. Scan for the last
49
+ * outside-quote separator instead, then return the still-quoted DEST for
50
+ * the caller to unquote.
51
+ */
52
+ function renameTargetPath(rawPath) {
53
+ let inQuotes = false;
54
+ let separatorIndex = -1;
55
+ for (let i = 0; i < rawPath.length - 3; i += 1) {
56
+ const char = rawPath[i];
57
+ if (char === "\\") {
58
+ i += 1; // skip the escaped character; it cannot open/close quotes
59
+ continue;
60
+ }
61
+ if (char === '"')
62
+ inQuotes = !inQuotes;
63
+ if (!inQuotes && rawPath.startsWith(" -> ", i))
64
+ separatorIndex = i;
65
+ }
66
+ if (separatorIndex === -1)
67
+ return rawPath;
68
+ return rawPath.slice(separatorIndex + 4);
69
+ }
70
+ function normalizeWorkspacePath(value) {
71
+ const target = value.includes(" -> ")
72
+ ? (value.split(" -> ").at(-1) ?? value)
73
+ : value;
74
+ // Embedded-repo untracked entries render as `dir/`; strip the trailing
75
+ // slash so the key matches the registered submodule path form.
76
+ return target.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
77
+ }
78
+ /**
79
+ * Unquote a git C-quoted path (`"..."` with C-style escapes; non-ASCII bytes
80
+ * arrive as octal like \346\225\260). Returns the input unchanged when not
81
+ * quoted. This keeps Chinese/space paths (e.g. `source/需求.md`) comparable
82
+ * against writeSet patterns.
83
+ */
84
+ export function unquoteGitPath(value) {
85
+ if (value.length < 2 || !value.startsWith('"') || !value.endsWith('"')) {
86
+ return value;
87
+ }
88
+ const inner = value.slice(1, -1);
89
+ let out = "";
90
+ for (let i = 0; i < inner.length; i += 1) {
91
+ const char = inner[i];
92
+ if (char !== "\\") {
93
+ out += char;
94
+ continue;
95
+ }
96
+ const next = inner[i + 1];
97
+ if (next === undefined)
98
+ break;
99
+ if (next === "n")
100
+ out += "\n";
101
+ else if (next === "t")
102
+ out += "\t";
103
+ else if (next === "r")
104
+ out += "\r";
105
+ else if (next === "\\")
106
+ out += "\\";
107
+ else if (next === '"')
108
+ out += '"';
109
+ else if (/[0-7]{3}/.test(inner.slice(i + 1, i + 4))) {
110
+ // Octal byte escape: collect consecutive escapes into one string
111
+ // and decode as UTF-8. `continue` skips the shared `i += 1` below
112
+ // (i already points past the consumed run).
113
+ const bytes = [];
114
+ let j = i;
115
+ while (j < inner.length && inner[j] === "\\" && /[0-7]{3}/.test(inner.slice(j + 1, j + 4))) {
116
+ bytes.push(Number.parseInt(inner.slice(j + 1, j + 4), 8));
117
+ j += 4;
118
+ }
119
+ out += Buffer.from(bytes).toString("utf8");
120
+ i = j - 1;
121
+ continue;
122
+ }
123
+ else {
124
+ out += next;
125
+ }
126
+ i += 1;
127
+ }
128
+ return out;
129
+ }
130
+ /**
131
+ * Read registered submodule directories from `.gitmodules` via
132
+ * `git config -f .gitmodules --get-regexp` (structured output; no
133
+ * shell-quoting hazards). Returns [] when the file is absent or empty.
134
+ */
135
+ export async function readSubmoduleRegistrations(rootCwd, dependencies = DEFAULT_WORKSPACE_STATUS_DEPENDENCIES) {
136
+ if (!(await hasGitmodulesFile(rootCwd)))
137
+ return [];
138
+ const result = await dependencies.runGit(rootCwd, [
139
+ "config",
140
+ "-f",
141
+ ".gitmodules",
142
+ "--get-regexp",
143
+ "^submodule\\..*\\.path$",
144
+ ]);
145
+ // Exit 1 with no stderr = the file exists but has no matching keys.
146
+ // Any other non-zero exit (unreadable file, parse error) must fail closed:
147
+ // returning [] would silently drop every submodule from observation.
148
+ if (result.code === 1 && !result.stderr.trim())
149
+ return [];
150
+ if (result.code !== 0) {
151
+ throw new Error(`git config -f .gitmodules failed (exit ${result.code}): ${result.stderr.trim() || result.stdout.trim() || "no output"}`);
152
+ }
153
+ if (!result.stdout.trim())
154
+ return [];
155
+ const paths = [];
156
+ for (const line of result.stdout.split("\n")) {
157
+ const trimmed = line.trim();
158
+ if (!trimmed)
159
+ continue;
160
+ // Line format: `submodule.<name>.path <value>`. The value may contain
161
+ // spaces; split on the first space after the key only.
162
+ const separator = trimmed.indexOf(" ");
163
+ if (separator <= 0)
164
+ continue;
165
+ const submodulePath = trimmed.slice(separator + 1).trim();
166
+ if (!submodulePath)
167
+ continue;
168
+ paths.push(normalizeWorkspacePath(submodulePath));
169
+ }
170
+ return paths;
171
+ }
172
+ /**
173
+ * Probe the gitlink state of one submodule against its parent repository.
174
+ * Porcelain codes cannot distinguish "dirty content inside the submodule"
175
+ * (covered by the child's file-level entries) from "the child HEAD actually
176
+ * moved" (a git mutation the child's own clean status cannot express), so
177
+ * the relevant SHAs are compared directly.
178
+ *
179
+ * Three facts are captured so staged gitlinks and repeated moves cannot
180
+ * hide a mutation:
181
+ * - `indexSha`: what the parent index records for the gitlink now.
182
+ * - `headTreeSha`: what the parent HEAD tree records (detects `git add sub`
183
+ * staged after a commit — the working gitlink moved but index == HEAD is
184
+ * not the full story; see gitlinkMutated).
185
+ * - `headSha`: the child's checked-out HEAD.
186
+ *
187
+ * `readFailed` maps to the caller's fail-closed incomplete path.
188
+ */
189
+ async function readGitlinkState(parentRoot, submodulePath, dependencies) {
190
+ const ls = await dependencies.runGit(parentRoot, [
191
+ "ls-files",
192
+ "-s",
193
+ "--",
194
+ submodulePath,
195
+ ]);
196
+ const line = ls.code !== 0
197
+ ? undefined
198
+ : ls.stdout.split("\n").find((entry) => entry.trim());
199
+ // `160000 <sha> 0\t<path>` for a gitlink entry.
200
+ const indexSha = line?.split(/\s+/)[1];
201
+ const headTree = await dependencies.runGit(parentRoot, [
202
+ "rev-parse",
203
+ `HEAD:${submodulePath}`,
204
+ ]);
205
+ const headTreeSha = headTree.code === 0 ? headTree.stdout.trim() : undefined;
206
+ const rev = await dependencies.runGit(joinFsPath(parentRoot, submodulePath), ["rev-parse", "HEAD"]);
207
+ const headSha = rev.code === 0 ? rev.stdout.trim() : undefined;
208
+ if (ls.code !== 0 || rev.code !== 0) {
209
+ return {
210
+ indexSha,
211
+ headTreeSha,
212
+ headSha,
213
+ readFailed: true,
214
+ errorDetail: `ls-files exit ${ls.code}; rev-parse exit ${rev.code}: ${rev.stderr.trim() || ls.stderr.trim() || "no output"}`,
215
+ };
216
+ }
217
+ return { indexSha, headTreeSha, headSha, readFailed: false };
218
+ }
219
+ /**
220
+ * A gitlink mutation is any state where the working gitlink (child HEAD)
221
+ * disagrees with what the parent's committed or staged history expects, or
222
+ * where the parent index gitlink is itself dirty relative to HEAD:
223
+ * - child HEAD != index: writer moved the submodule HEAD (committed inside
224
+ * the submodule, or checked out another commit).
225
+ * - index != HEAD tree: the gitlink change was staged (`git add sub`) but
226
+ * not committed — still an unauthorized git mutation during a run.
227
+ * - child HEAD != HEAD tree (index clean): a moved HEAD not yet staged;
228
+ * the classic in-submodule commit.
229
+ * When the parent has never committed the submodule (fresh `submodule add`,
230
+ * no `HEAD:<path>`), only the index-vs-child comparison applies.
231
+ */
232
+ function gitlinkMutated(state) {
233
+ const { indexSha, headTreeSha, headSha } = state;
234
+ if (indexSha !== undefined && headSha !== undefined && indexSha !== headSha) {
235
+ return true;
236
+ }
237
+ if (headTreeSha !== undefined &&
238
+ indexSha !== undefined &&
239
+ headTreeSha !== indexSha) {
240
+ return true;
241
+ }
242
+ if (headTreeSha !== undefined &&
243
+ headSha !== undefined &&
244
+ headTreeSha !== headSha) {
245
+ return true;
246
+ }
247
+ return false;
248
+ }
249
+ /**
250
+ * Sentinel key for a mutated gitlink. Embeds the observed SHA triple so the
251
+ * key changes when the gitlink moves again (a constant key would make a
252
+ * second move on a dirty baseline indistinguishable from no move).
253
+ */
254
+ function gitlinkSentinelKey(workspacePath, state) {
255
+ const fingerprint = [state.indexSha, state.headTreeSha, state.headSha]
256
+ .map((sha) => sha ?? "-")
257
+ .join("+");
258
+ return `${GITLINK_SENTINEL_PREFIX}${workspacePath}@${fingerprint}`;
259
+ }
260
+ async function submoduleWorkingTreeInitialized(rootCwd, submodulePath) {
261
+ try {
262
+ const info = await lstat(path.resolve(rootCwd, ...submodulePath.split("/"), ".git"));
263
+ return info.isFile() || info.isDirectory();
264
+ }
265
+ catch {
266
+ return false;
267
+ }
268
+ }
269
+ async function collectSubmoduleEntries(input) {
270
+ // undefined = collection failed for this submodule (recorded, fail-closed).
271
+ const repoRoot = joinFsPath(input.rootCwd, input.workspacePath);
272
+ try {
273
+ const porcelain = await input.dependencies.readSubmoduleStatus(repoRoot);
274
+ input.repos.push({
275
+ repoRelativePath: input.repoWorkspacePath,
276
+ repoId: input.repoWorkspacePath,
277
+ state: "clean-status-read",
278
+ porcelain,
279
+ });
280
+ const childEntries = parsePorcelainEntries(porcelain);
281
+ const expanded = new Map();
282
+ for (const [childPath, code] of childEntries) {
283
+ expanded.set(`${input.repoWorkspacePath}/${childPath}`, code);
284
+ }
285
+ if (input.depth < MAX_SUBMODULE_DEPTH) {
286
+ const nestedPaths = await readSubmoduleRegistrations(repoRoot, input.dependencies);
287
+ for (const nestedPath of nestedPaths) {
288
+ const nestedWorkspacePath = `${input.repoWorkspacePath}/${nestedPath}`;
289
+ const initialized = await submoduleWorkingTreeInitialized(repoRoot, nestedPath);
290
+ if (!initialized) {
291
+ input.repos.push({
292
+ repoRelativePath: nestedWorkspacePath,
293
+ repoId: nestedWorkspacePath,
294
+ state: "uninitialized",
295
+ porcelain: "",
296
+ });
297
+ continue;
298
+ }
299
+ // Gitlink probe at this nesting level: the parent of `nested` is the
300
+ // current repository (repoRoot). Same three-SHA semantics as the
301
+ // top level; a moved nested HEAD surfaces as a SHA-tagged sentinel.
302
+ const nestedGitlink = await readGitlinkState(repoRoot, nestedPath, input.dependencies);
303
+ if (nestedGitlink.readFailed) {
304
+ input.repos.push({
305
+ repoRelativePath: nestedWorkspacePath,
306
+ repoId: nestedWorkspacePath,
307
+ state: "status-read-failed",
308
+ porcelain: "",
309
+ errorDetail: `gitlink probe failed: ${nestedGitlink.errorDetail ?? "unknown"}`,
310
+ });
311
+ continue;
312
+ }
313
+ const nestedEntries = await collectSubmoduleEntries({
314
+ rootCwd: repoRoot,
315
+ workspacePath: nestedPath,
316
+ repoWorkspacePath: nestedWorkspacePath,
317
+ depth: input.depth + 1,
318
+ repos: input.repos,
319
+ dependencies: input.dependencies,
320
+ });
321
+ if (nestedEntries === undefined) {
322
+ // Nested collection failures are recorded in the shared
323
+ // repos array with state status-read-failed; completeness
324
+ // is derived from those states after the top-level loop.
325
+ continue;
326
+ }
327
+ for (const [nestedFile, code] of nestedEntries) {
328
+ // nestedEntries keys are already full workspace paths
329
+ // (prefixed with nestedWorkspacePath).
330
+ expanded.set(nestedFile, code);
331
+ }
332
+ if (gitlinkMutated(nestedGitlink)) {
333
+ expanded.set(gitlinkSentinelKey(nestedWorkspacePath, nestedGitlink), "M ");
334
+ }
335
+ // Drop the child's own directory-level entry for the nested
336
+ // submodule (gitlink ` M nested` or embedded `?? nested/`);
337
+ // its file facts now come from the nested repository.
338
+ expanded.delete(`${input.repoWorkspacePath}/${nestedPath}`);
339
+ }
340
+ }
341
+ return expanded;
342
+ }
343
+ catch (error) {
344
+ input.repos.push({
345
+ repoRelativePath: input.repoWorkspacePath,
346
+ repoId: input.repoWorkspacePath,
347
+ state: "status-read-failed",
348
+ porcelain: "",
349
+ errorDetail: error instanceof Error ? error.message : String(error),
350
+ });
351
+ return undefined;
352
+ }
353
+ }
354
+ function joinFsPath(root, workspacePath) {
355
+ return path.resolve(root, ...workspacePath.split("/"));
356
+ }
357
+ /**
358
+ * Expand a parent porcelain snapshot into workspace file-level facts.
359
+ * Callers pass the already-captured parent porcelain so the parent bytes are
360
+ * captured once and reused.
361
+ */
362
+ export async function expandWorkspaceStatus(input) {
363
+ const dependencies = input.dependencies ?? DEFAULT_WORKSPACE_STATUS_DEPENDENCIES;
364
+ const parentEntries = parsePorcelainEntries(input.parentPorcelain);
365
+ const repos = [
366
+ {
367
+ repoRelativePath: "",
368
+ repoId: "parent",
369
+ state: "clean-status-read",
370
+ porcelain: input.parentPorcelain,
371
+ },
372
+ ];
373
+ const entries = new Map();
374
+ let complete = true;
375
+ const registrations = input.hasGitmodulesFile
376
+ ? await readSubmoduleRegistrations(input.rootCwd, dependencies)
377
+ : [];
378
+ for (const registration of registrations) {
379
+ const initialized = await submoduleWorkingTreeInitialized(input.rootCwd, registration);
380
+ if (!initialized) {
381
+ repos.push({
382
+ repoRelativePath: registration,
383
+ repoId: registration,
384
+ state: "uninitialized",
385
+ porcelain: "",
386
+ });
387
+ continue;
388
+ }
389
+ // Gitlink probe: SHA-compare the parent index gitlink against the
390
+ // child's checked-out HEAD. Only a real HEAD move (e.g. the writer
391
+ // committed inside the submodule) becomes a sentinel; dirty child
392
+ // content stays covered by the child's file-level entries.
393
+ const gitlink = await readGitlinkState(input.rootCwd, registration, dependencies);
394
+ if (gitlink.readFailed) {
395
+ repos.push({
396
+ repoRelativePath: registration,
397
+ repoId: registration,
398
+ state: "status-read-failed",
399
+ porcelain: "",
400
+ errorDetail: `gitlink probe failed: ${gitlink.errorDetail ?? "unknown"}`,
401
+ });
402
+ complete = false;
403
+ continue;
404
+ }
405
+ const submoduleEntries = await collectSubmoduleEntries({
406
+ rootCwd: input.rootCwd,
407
+ workspacePath: registration,
408
+ repoWorkspacePath: registration,
409
+ depth: 1,
410
+ repos,
411
+ dependencies,
412
+ });
413
+ if (submoduleEntries === undefined) {
414
+ complete = false;
415
+ continue;
416
+ }
417
+ for (const [workspacePath, code] of submoduleEntries) {
418
+ entries.set(workspacePath, code);
419
+ }
420
+ if (gitlinkMutated(gitlink)) {
421
+ entries.set(gitlinkSentinelKey(registration, gitlink), "M ");
422
+ }
423
+ }
424
+ // Completeness is derived from the recorded repo states: any
425
+ // status-read-failed repository at any depth (top-level or nested)
426
+ // makes the observation incomplete, so nested failures bubble up.
427
+ // (.gitmodules read failures throw and fail the whole observation.)
428
+ const completeNow = complete &&
429
+ !repos.some((repo) => repo.state === "status-read-failed");
430
+ // Parent entries: keep everything except directory-level gitlink entries
431
+ // of submodules whose own status was read successfully AND whose gitlink
432
+ // is unchanged. When the parent still reports the submodule as modified
433
+ // (gitlink differs from the index — the writer committed inside the
434
+ // submodule, or checked out another commit), keep a sentinel entry so the
435
+ // change stays visible in the expanded delta instead of silently
436
+ // vanishing behind the child's clean status. The child's clean file-level
437
+ // status cannot distinguish "gitlink untouched" from "gitlink moved";
438
+ // only the parent entry can, so it is preserved whenever non-clean.
439
+ const expandedRegistrations = new Set(repos
440
+ .filter((repo) => repo.repoRelativePath !== "" &&
441
+ repo.state === "clean-status-read")
442
+ .map((repo) => repo.repoRelativePath));
443
+ for (const [parentPath, code] of parentEntries) {
444
+ if (expandedRegistrations.has(parentPath)) {
445
+ // Directory-level submodule entries are dropped: file-level facts
446
+ // come from the child repos, and a moved gitlink is surfaced by the
447
+ // SHA probe as a sentinel during the registration loop. Porcelain
448
+ // codes cannot distinguish dirty content from a moved HEAD, so no
449
+ // code-based sentinel may be derived here.
450
+ continue;
451
+ }
452
+ if (entries.has(parentPath))
453
+ continue; // child facts take precedence
454
+ entries.set(parentPath, code);
455
+ }
456
+ return {
457
+ parentPorcelain: input.parentPorcelain,
458
+ entries,
459
+ repos,
460
+ complete: completeNow,
461
+ };
462
+ }
463
+ /** Prefix marking a preserved parent gitlink fact (mutated submodule HEAD). */
464
+ export const GITLINK_SENTINEL_PREFIX = "\u0000gitlink\u0000/";
465
+ /** Serialize expanded entries back into sorted porcelain-v1-shaped lines. */
466
+ export function synthesizeExpandedPorcelain(entries) {
467
+ const lines = [];
468
+ for (const [filePath, code] of [...entries.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
469
+ lines.push(`${code} ${filePath}`);
470
+ }
471
+ return lines.join("\n") + (lines.length > 0 ? "\n" : "");
472
+ }
473
+ /** Check for a `.gitmodules` file at the repository root. */
474
+ export async function hasGitmodulesFile(rootCwd) {
475
+ try {
476
+ await access(path.resolve(rootCwd, ".gitmodules"));
477
+ return true;
478
+ }
479
+ catch {
480
+ return false;
481
+ }
482
+ }
@@ -8,6 +8,8 @@ export function createOneShotPromptParseAccum() {
8
8
  }
9
9
  export function parseOneShotCommonFlag(args, index, accum) {
10
10
  const arg = args[index];
11
+ if (arg === undefined)
12
+ return { kind: "not-common" };
11
13
  if (arg === "--stdin") {
12
14
  accum.fromStdin = true;
13
15
  return { kind: "consumed", nextIndex: index };