@tea-agent/loop-agent 0.41.1-beta.0 → 0.41.2

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 (209) hide show
  1. package/CHANGELOG.md +61 -267
  2. package/dist/application/dag/generate-task-dag.js +19 -75
  3. package/dist/application/task-lifecycle/advance.js +5 -24
  4. package/dist/application/task-lifecycle/observe.js +17 -171
  5. package/dist/application/task-lifecycle/plan-transitions.js +7 -42
  6. package/dist/application/task-lifecycle/recommendations.js +2 -13
  7. package/dist/build-stamp.json +3 -3
  8. package/dist/cli/command-definitions.js +0 -7
  9. package/dist/cli/program.js +0 -5
  10. package/dist/commands/client-recovery.js +0 -3
  11. package/dist/commands/init.js +1 -27
  12. package/dist/commands/task-advance.js +0 -19
  13. package/dist/executors/dag-pi-executor.js +231 -3784
  14. package/dist/executors/pi-executor.js +4 -15
  15. package/dist/executors/pi-extension-resolver.js +14 -2
  16. package/dist/executors/shell-executor.js +217 -945
  17. package/dist/executors/shell-write-guard.js +0 -7
  18. package/dist/shared/dag-failure-category.js +0 -12
  19. package/dist/shared/openspec-spec.js +4 -70
  20. package/dist/shared/operator/capabilities.js +0 -7
  21. package/dist/task/config-types.js +7 -34
  22. package/dist/task/contract/adopt.js +0 -4
  23. package/dist/task/contract/import-revision.js +0 -4
  24. package/dist/task/contract/project.js +0 -3
  25. package/dist/task/contract/schema.js +1 -2
  26. package/dist/task/frontend-project-capability.js +20 -203
  27. package/dist/task/runtime.js +2 -5
  28. package/dist/task/source-prepare/build-draft.js +3 -3
  29. package/dist/task/source-prepare/fragment-inventory.js +9 -15
  30. package/dist/task/source-prepare/prepare.js +1 -89
  31. package/dist/task/source-prepare/semantic-intake.js +2 -6
  32. package/dist/task/source-references.js +1 -22
  33. package/dist/worker/console/chat/chat-ui-policy.js +4 -2
  34. package/dist/worker/console/chat/pi-runtime.js +235 -13
  35. package/dist/worker/console/chat/repo-browser.js +10 -3
  36. package/dist/worker/console/chat/routes.js +86 -44
  37. package/dist/worker/console/chat/semantic-activity.js +12 -11
  38. package/dist/worker/console/chat/session-stats.js +96 -0
  39. package/dist/worker/console/chat/session-store.js +133 -70
  40. package/dist/worker/console/chat/shortcuts.js +1 -1
  41. package/dist/worker/console/chat/turn-process.js +139 -60
  42. package/dist/worker/console/index.js +0 -3
  43. package/dist/worker/console/operation-store.js +6 -226
  44. package/dist/worker/console/operator-actions.js +7 -169
  45. package/dist/worker/console/pi-plugins.js +3 -1
  46. package/dist/worker/console/server.js +19 -4
  47. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-Bho4we4c.js → abnfDiagram-N423BO3Z-DQ5jlYVU.js} +1 -1
  48. package/dist/worker/console/static/assets/{arc-TBDkTeK0.js → arc-BeTVCzH9.js} +1 -1
  49. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-BF_fZrn2.js → architectureDiagram-T3A2C74G-DassREBi.js} +1 -1
  50. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CCnPgUe2.js → blockDiagram-VBNYF7ZC-DyeNX8Ek.js} +1 -1
  51. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BCYZJLAT.js → c4Diagram-5PPSVZJV-BXb_zxGx.js} +1 -1
  52. package/dist/worker/console/static/assets/channel-B_lofstT.js +1 -0
  53. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D8K6adhU.js → chunk-2GRJ4B5K-B9F9gxGC.js} +1 -1
  54. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-DkT1Q78b.js → chunk-2Q5K7J3B-Byd5zHEQ.js} +1 -1
  55. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DuhvpIr7.js → chunk-5RXB4S5H-BqoxMJk9.js} +1 -1
  56. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BnK6dC49.js → chunk-5VM5RSS4-CT7d6YZw.js} +1 -1
  57. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-DPz__z7r.js → chunk-6Q2QTUOP-CdiNyN0N.js} +1 -1
  58. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-0kkppM2j.js → chunk-GF5L2VYU-BGw9bpVc.js} +1 -1
  59. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-BB41iK5t.js → chunk-JWPE2WC7-DiDVlVB1.js} +1 -1
  60. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CiVrxKHU.js → chunk-KBJHAD2P-BhHf-4yK.js} +1 -1
  61. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-C2h9Xje1.js → chunk-RYQCIY6F-B79pEgwv.js} +1 -1
  62. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-3iOSHdbM.js → chunk-XXDRQBXY-Cb70EcUV.js} +1 -1
  63. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-ieUI0-eY.js +1 -0
  64. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-ieUI0-eY.js +1 -0
  65. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BN3A7tkk.js → cose-bilkent-JH36ORCC-DBHLnAf1.js} +1 -1
  66. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CTuBy0Or.js → cynefin-VYW2F7L2-BT_JRsOH.js} +1 -1
  67. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-wb6tUlMN.js → cynefinDiagram-MW4NZA55-Bss-msa3.js} +1 -1
  68. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-GP1Ivx8B.js → dagre-VZM6K2ZE-B8Gr24pt.js} +1 -1
  69. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-ejrcK6L0.js → diagram-7IWD3JNH-BrjU70Jw.js} +1 -1
  70. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-YFkCCvUU.js → diagram-B4RE2ZJO-Cp_JpPGd.js} +1 -1
  71. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B4rrvIaL.js → diagram-LBJQPF4R-BWKICEP-.js} +1 -1
  72. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-C-YIZcUf.js → diagram-Q27KOJAE-D3z_UNR_.js} +1 -1
  73. package/dist/worker/console/static/assets/{diagram-UB23O5K3-BPF5wcL1.js → diagram-UB23O5K3-_Ywm390x.js} +1 -1
  74. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-CU5SzXjO.js → ebnfDiagram-BXEA7PRR-D9QYQQMB.js} +1 -1
  75. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CpL414DE.js → erDiagram-JOGREHBK-BNgXNKAr.js} +1 -1
  76. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-MrhLzNau.js → flowDiagram-UKHOOZJN-QRLnkPCg.js} +1 -1
  77. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Bg4qFuUo.js → ganttDiagram-PKOTCBZU-B9fOduNi.js} +1 -1
  78. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-ColxSXLR.js → gitGraphDiagram-DS77QQ5N-FSEdtPN2.js} +1 -1
  79. package/dist/worker/console/static/assets/index-Cs9JUSPs.css +1 -0
  80. package/dist/worker/console/static/assets/index-DtPrwu7M.js +451 -0
  81. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Czvtm6gc.js → infoDiagram-6WML65LV-D5Bjg9dm.js} +1 -1
  82. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-B7Xp8HyJ.js → ishikawaDiagram-WSZJBQD7-BlNRkWvf.js} +1 -1
  83. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DWYZcvph.js → journeyDiagram-NVQOT4AX-BdJiw3SL.js} +1 -1
  84. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-KTLZRUjx.js → kanban-definition-27J2QSJJ-CsDNlYht.js} +1 -1
  85. package/dist/worker/console/static/assets/{linear-_Exn7bfl.js → linear-8g9dbEmX.js} +1 -1
  86. package/dist/worker/console/static/assets/{mermaid.core-Cxg8kX8V.js → mermaid.core-ChyQH_ut.js} +5 -5
  87. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-oKrlo2Bt.js → mindmap-definition-FAOFIHXS-DwYoCTYt.js} +1 -1
  88. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-XAeteiNd.js → pegDiagram-VL7TDLO6-T_b2rS17.js} +1 -1
  89. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BTf1K-lp.js → pieDiagram-7S7Q4E2Y-1Cr7WMhH.js} +1 -1
  90. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-C0IlY0Jf.js → quadrantDiagram-CIZ2JOQS-Bq4qM59o.js} +1 -1
  91. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BVbKtZhW.js → railroadDiagram-AXF67PYL-ytFgR1RL.js} +1 -1
  92. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-C5e4JFcr.js → requirementDiagram-LRYGKXZP-CnUdUVYX.js} +1 -1
  93. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-Cz30hc29.js → sankeyDiagram-W5VNT64P-_5rJqG6R.js} +1 -1
  94. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DS33n6d0.js → sequenceDiagram-SI44F4Z6-D5imyGbt.js} +1 -1
  95. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-46w7v-9T.js → sizeCapture-X5ZJPWSS-DvgDn3wL.js} +1 -1
  96. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-pbcD5SsZ.js → stateDiagram-OKZ733FA-BViu7duc.js} +1 -1
  97. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-kNxnG4_w.js +1 -0
  98. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DuivYBSj.js → swimlanes-SLNWSIFB-BcULKg2P.js} +2 -2
  99. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DyTzlcWH.js +8 -0
  100. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-Cb9VZVIl.js → timeline-definition-Z64GVDOM-DmPveIjt.js} +1 -1
  101. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-D2-mfOgR.js → vennDiagram-T6HMQDX7-9r-iFy0R.js} +1 -1
  102. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DeS2aC76.js → wardleyDiagram-T6FBY63Y-D3fIXdvM.js} +1 -1
  103. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-WGsrFjxH.js → xychartDiagram-ELKLHX3M-BCSS9SBg.js} +1 -1
  104. package/dist/worker/console/static/index.html +2 -2
  105. package/dist/worker/console/static-src/app/useRunProgress.js +9 -2
  106. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +19 -8
  107. package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
  108. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +15 -7
  109. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +2 -0
  110. package/dist/worker/console/static-src/operator-chat/useChatThread.js +6 -0
  111. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +28 -3
  112. package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +106 -0
  113. package/dist/worker/console/static-src/shell/workspace-route.js +4 -0
  114. package/dist/worker/console/workspace-context.js +1 -111
  115. package/dist/worker/observability/read-model.js +4 -0
  116. package/dist/worker/observe/routes.js +4 -0
  117. package/dist/worker/observe/static/dag-node-purpose.js +0 -5
  118. package/dist/worker/observe/static/views/dag-inspector.js +2 -7
  119. package/dist/worker/observe/static/views/session-timeline.js +46 -15
  120. package/dist/workflows/dag/backend-test-result-contract.js +1 -1
  121. package/dist/workflows/dag/contract-validator-registrations.js +2 -1
  122. package/dist/workflows/dag/frontend-implementation-contract.js +162 -932
  123. package/dist/workflows/dag/frontend-plan-render.js +1 -2
  124. package/dist/workflows/dag/frontend-prewrite-gate.js +349 -255
  125. package/dist/workflows/dag/frontend-recovery-plan.js +10 -17
  126. package/dist/workflows/dag/frontend-recovery-run.js +20 -33
  127. package/dist/workflows/dag/frontend-repair.js +432 -1
  128. package/dist/workflows/dag/frontend-review-context.js +15 -261
  129. package/dist/workflows/dag/frontend-verification-trace.js +24 -249
  130. package/dist/workflows/dag/frontend-worktree-diff.js +17 -250
  131. package/dist/workflows/dag/init-hybrid.js +494 -685
  132. package/dist/workflows/dag/interrupt-request.js +0 -7
  133. package/dist/workflows/dag/node-execution.js +4 -732
  134. package/dist/workflows/dag/prompt.js +1 -34
  135. package/dist/workflows/dag/report.js +1 -37
  136. package/dist/workflows/dag/rerun-feedback.js +1 -256
  137. package/dist/workflows/dag/rerun-plan.js +2 -10
  138. package/dist/workflows/dag/rerun-run.js +0 -23
  139. package/dist/workflows/dag/rerun-task.js +0 -29
  140. package/dist/workflows/dag/retry-policy.js +104 -214
  141. package/dist/workflows/dag/runner.js +122 -429
  142. package/dist/workflows/dag/scheduler.js +16 -114
  143. package/dist/workflows/dag/types.js +12 -239
  144. package/dist/workflows/dag/validate.js +12 -28
  145. package/docs/init-surface.manifest.json +12 -30
  146. package/docs/skills/vetted-skill-registry.md +2 -4
  147. package/docs/templates/README.md +0 -2
  148. package/docs/templates/agent-dag-report.schema.json +2 -8
  149. package/docs/templates/agent-dag.schema.json +1 -1
  150. package/docs/templates/frontend-implementation-contract.schema.json +1 -4
  151. package/harness.json +3 -3
  152. package/package.json +1 -1
  153. package/skills/frontend-bounded-implement/SKILL.md +14 -15
  154. package/skills/frontend-design-review/SKILL.md +41 -22
  155. package/skills/frontend-implementation/SKILL.md +52 -0
  156. package/skills/frontend-implementation/references/code-standards.md +33 -0
  157. package/skills/frontend-implementation/references/design-spec.md +56 -0
  158. package/skills/frontend-implementation/references/node-contracts.md +31 -0
  159. package/skills/frontend-review/SKILL.md +15 -20
  160. package/skills/frontend-review/references/review-findings.md +7 -6
  161. package/skills/frontend-verification/SKILL.md +1 -1
  162. package/skills/loop-agent/references/command-reference.md +0 -1
  163. package/skills/loop-agent/references/hybrid-dag.md +2 -2
  164. package/dist/commands/dag-follow-up.js +0 -138
  165. package/dist/executors/pi-read-budget-policy.js +0 -239
  166. package/dist/worker/console/frontend-human-decision-adapter.js +0 -19
  167. package/dist/worker/console/frontend-split-operation-adapter.js +0 -20
  168. package/dist/worker/console/static/assets/channel-bnXW0U3C.js +0 -1
  169. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-rZpq_twR.js +0 -1
  170. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-rZpq_twR.js +0 -1
  171. package/dist/worker/console/static/assets/index-D3CC4eUz.css +0 -1
  172. package/dist/worker/console/static/assets/index-DLt4ZFvD.js +0 -437
  173. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-zBMYiUyi.js +0 -1
  174. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-d_rms-5i.js +0 -8
  175. package/dist/worker/console/static-src/active-run-badge.js +0 -17
  176. package/dist/worker/materialize/frontend-split-task-materializer.js +0 -72
  177. package/dist/workflows/dag/dag-retry-schema.js +0 -138
  178. package/dist/workflows/dag/frontend-closeout.js +0 -221
  179. package/dist/workflows/dag/frontend-design-policy.js +0 -400
  180. package/dist/workflows/dag/frontend-human-decision.js +0 -182
  181. package/dist/workflows/dag/frontend-provider-capability-matrix.js +0 -159
  182. package/dist/workflows/dag/frontend-read-budgets.js +0 -12
  183. package/dist/workflows/dag/frontend-recovery-capsule.js +0 -455
  184. package/dist/workflows/dag/frontend-recovery-controller.js +0 -202
  185. package/dist/workflows/dag/frontend-recovery-lineage.js +0 -178
  186. package/dist/workflows/dag/frontend-review-findings.js +0 -270
  187. package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -914
  188. package/dist/workflows/dag/frontend-shape-capsule-store.js +0 -191
  189. package/dist/workflows/dag/frontend-shape-facts.js +0 -409
  190. package/dist/workflows/dag/frontend-shape.js +0 -427
  191. package/dist/workflows/dag/frontend-source-fidelity-ledger.js +0 -108
  192. package/dist/workflows/dag/frontend-split-application-service.js +0 -203
  193. package/dist/workflows/dag/frontend-split-orchestrator.js +0 -899
  194. package/dist/workflows/dag/frontend-typed-event-store.js +0 -452
  195. package/dist/workflows/dag/frontend-typed-event-transaction.js +0 -180
  196. package/dist/workflows/dag/frontend-writer-admission.js +0 -285
  197. package/dist/workflows/dag/frontend-writer-status.js +0 -256
  198. package/dist/workflows/dag/recovery-lease.js +0 -80
  199. package/docs/templates/frontend-implementation-dag.json +0 -89
  200. package/docs/templates/spec-registry.schema.json +0 -45
  201. package/skills/frontend-bounded-implement/references/code-standards.md +0 -19
  202. package/skills/frontend-contract/SKILL.md +0 -23
  203. package/skills/frontend-contract/references/contract-protocol.md +0 -34
  204. package/skills/frontend-plan/SKILL.md +0 -26
  205. package/skills/frontend-plan/references/decision-contract.md +0 -37
  206. package/skills/frontend-plan/references/design-decisions.md +0 -17
  207. package/skills/frontend-scout/SKILL.md +0 -25
  208. package/skills/frontend-scout/references/design-evidence.md +0 -16
  209. package/skills/frontend-scout/references/scout-evidence.md +0 -23
@@ -5,152 +5,25 @@ import { runResilientGitCommand } from "../../shared/resilient-git.js";
5
5
  import { writeDagRunJsonArtifact } from "../../infrastructure/harness/artifact-store.js";
6
6
  import { pathMatchesPattern } from "../../shared/git-progress.js";
7
7
  export const FRONTEND_WORKTREE_DIFF_SCHEMA_ID = "frontend-worktree-diff-v1";
8
- export const FRONTEND_REVIEW_DIFF_INDEX_SCHEMA_ID = "frontend-review-diff-index-v1";
9
- const MAX_REVIEW_DIFF_SUMMARY_ENTRIES = 48;
10
- /** Maximum diff payload per review artifact; metadata adds a small fixed header. */
11
- const MAX_REVIEW_DIFF_FRAGMENT_BYTES = 20 * 1024;
12
8
  export const FRONTEND_WORKTREE_BASELINE_SCHEMA_ID = "frontend-worktree-baseline-v1";
13
9
  async function runGit(cwd, args) {
14
10
  const result = await runResilientGitCommand({ cwd, args, readOnly: true });
15
11
  return { code: result.code, stdout: result.stdout, stderr: result.stderr };
16
12
  }
17
- /**
18
- * Ephemeral interpreter/tool caches that writers may create while drafting
19
- * tests (kept in sync with `isEphemeralToolCachePath` in
20
- * src/executors/shell-write-guard.ts). They are not product evidence: tool
21
- * cache writes must neither fail the write guard nor appear in the review
22
- * diff as pre-existing changes.
23
- */
24
- export function isEphemeralToolCachePath(filePath) {
25
- const normalized = filePath.replace(/\\/g, "/");
26
- if (!normalized)
27
- return false;
28
- if (normalized === ".pytest_cache" ||
29
- normalized.startsWith(".pytest_cache/")) {
30
- return true;
31
- }
32
- if (normalized === ".mypy_cache" || normalized.startsWith(".mypy_cache/")) {
33
- return true;
34
- }
35
- if (normalized === ".ruff_cache" || normalized.startsWith(".ruff_cache/")) {
36
- return true;
37
- }
38
- if (normalized === ".playwright-cli" ||
39
- normalized.startsWith(".playwright-cli/")) {
40
- return true;
41
- }
42
- if (normalized === ".coverage" || normalized.startsWith(".coverage.")) {
43
- return true;
44
- }
45
- // vite/vitest runtime caches live under node_modules/.vite (e.g.
46
- // node_modules/.vite/vitest/results.json). node_modules is the gitignored
47
- // dependency tree — tool cache writes there are never a product change.
48
- if (normalized.startsWith("node_modules/.vite/")) {
49
- return true;
50
- }
51
- if (/(?:^|\/)__pycache__(?:\/|$)/.test(normalized))
52
- return true;
53
- if (/\.(?:pyc|pyo)$/.test(normalized))
54
- return true;
55
- return false;
56
- }
57
13
  function splitLines(text) {
58
14
  return text
59
15
  .split(/\r?\n/)
60
16
  .map((line) => line.trim())
61
17
  .filter(Boolean);
62
18
  }
63
- function buildReviewDiffSummary(input) {
64
- const files = [...input.hunks.reduce((grouped, hunk) => {
65
- const existing = grouped.get(hunk.path);
66
- if (existing) {
67
- existing.bytes += hunk.bytes;
68
- existing.lastPatchPath = hunk.patchPath;
69
- return grouped;
70
- }
71
- grouped.set(hunk.path, {
72
- path: hunk.path,
73
- bytes: hunk.bytes,
74
- parts: hunk.parts,
75
- firstPatchPath: hunk.patchPath,
76
- lastPatchPath: hunk.patchPath,
77
- });
78
- return grouped;
79
- }, new Map()).values()];
80
- const listedFiles = files.slice(0, MAX_REVIEW_DIFF_SUMMARY_ENTRIES);
81
- const remainingFiles = files.length - listedFiles.length;
82
- const listedUntracked = input.untrackedFiles.slice(0, MAX_REVIEW_DIFF_SUMMARY_ENTRIES);
83
- const remainingUntracked = input.untrackedFiles.length - listedUntracked.length;
84
- return [
85
- "# Frontend review diff summary",
86
- "",
87
- "Read this bounded summary first. Do not read artifacts/diff_patch.patch in full; it is retained only as the canonical audit artifact.",
88
- "For a semantic finding, read only the matching per-file diff fragment below and then the current source file when necessary. Read fragments in part order when a file has more than one.",
89
- "",
90
- `Canonical patch SHA-256: ${input.patchSha256}`,
91
- `Canonical patch bytes: ${input.patchBytes}`,
92
- `Tracked changed files: ${files.length}`,
93
- `Review diff fragments: ${input.hunks.length}`,
94
- `Untracked files (inventory only): ${input.untrackedFiles.length}`,
95
- "",
96
- "## Tracked file diff fragment references",
97
- ...(listedFiles.length > 0
98
- ? listedFiles.map((file) => file.parts === 1
99
- ? `- ${file.path} — ${file.bytes} bytes — read ${file.firstPatchPath} only if this file needs review`
100
- : `- ${file.path} — ${file.bytes} bytes across ${file.parts} ordered fragments — read ${file.firstPatchPath} through ${file.lastPatchPath} only if this file needs review`)
101
- : ["- (none)"]),
102
- ...(remainingFiles > 0
103
- ? [`- … ${remainingFiles} additional tracked files are recorded in contracts/frontend-review-diff-index.json; do not bulk-read them.`]
104
- : []),
105
- "",
106
- "## Untracked inventory",
107
- ...(listedUntracked.length > 0
108
- ? listedUntracked.map((file) => `- ${file}`)
109
- : ["- (none)"]),
110
- ...(remainingUntracked > 0
111
- ? [`- … ${remainingUntracked} additional untracked files are recorded in contracts/frontend-review-diff-index.json.`]
112
- : []),
113
- "",
114
- ].join("\n");
115
- }
116
- function splitReviewDiffFragments(text) {
117
- const fragments = [];
118
- let current = "";
119
- for (const line of text.match(/[^\n]*\n|[^\n]+/g) ?? []) {
120
- const lineBytes = Buffer.byteLength(line);
121
- if (current.length > 0 &&
122
- Buffer.byteLength(current) + lineBytes >
123
- MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
124
- fragments.push(current);
125
- current = "";
126
- }
127
- if (lineBytes <= MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
128
- current += line;
129
- continue;
130
- }
131
- // Generated/minified files can produce a single diff line larger than the
132
- // review budget. Split by Unicode code point so no fragment exceeds the
133
- // byte limit while preserving the original patch bytes when concatenated.
134
- let oversizedLineFragment = "";
135
- let oversizedLineFragmentBytes = 0;
136
- for (const codePoint of line) {
137
- const codePointBytes = Buffer.byteLength(codePoint);
138
- if (oversizedLineFragmentBytes > 0 &&
139
- oversizedLineFragmentBytes + codePointBytes >
140
- MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
141
- fragments.push(oversizedLineFragment);
142
- oversizedLineFragment = "";
143
- oversizedLineFragmentBytes = 0;
144
- }
145
- oversizedLineFragment += codePoint;
146
- oversizedLineFragmentBytes += codePointBytes;
147
- }
148
- if (oversizedLineFragment)
149
- fragments.push(oversizedLineFragment);
150
- }
151
- if (current.length > 0)
152
- fragments.push(current);
153
- return fragments.length > 0 ? fragments : [""];
19
+ function statusPaths(status) {
20
+ return status
21
+ .split(/\r?\n/)
22
+ .map((line) => line.trimEnd())
23
+ .filter((line) => line.length >= 4)
24
+ .map((line) => line.slice(3).split(" -> ").at(-1) ?? "")
25
+ .filter(Boolean)
26
+ .sort();
154
27
  }
155
28
  async function sha256File(filePath) {
156
29
  try {
@@ -164,26 +37,15 @@ async function sha256File(filePath) {
164
37
  export async function captureFrontendWorktreeBaseline(input) {
165
38
  const run = input.dependencies?.runGit ?? runGit;
166
39
  const root = path.resolve(input.workspaceRoot);
167
- // Baseline = the full concrete workspace inventory the writer may touch
168
- // (tracked + untracked, gitignored excluded), NOT just currently-changed
169
- // files. Using `git status` here made a clean repository baseline-empty
170
- // (status has no entries when nothing changed), which wrongly blocked
171
- // writer admission with baseline-empty.
172
- const ls = await run(root, [
173
- "ls-files",
174
- "-co",
175
- "--exclude-standard",
176
- "-z",
40
+ const status = await run(root, [
41
+ "status",
42
+ "--porcelain=v1",
43
+ "--untracked-files=all",
177
44
  ]);
178
- if (ls.code !== 0) {
179
- throw new Error(`frontend worktree baseline failed: ${ls.stderr.trim() || ls.stdout.trim()}`);
45
+ if (status.code !== 0) {
46
+ throw new Error(`frontend worktree baseline failed: ${status.stderr.trim() || status.stdout.trim()}`);
180
47
  }
181
- const files = ls.stdout
182
- .split("\0")
183
- .map((line) => line.trim())
184
- .filter(Boolean)
185
- .filter((file) => !isEphemeralToolCachePath(file))
186
- .sort();
48
+ const files = statusPaths(status.stdout);
187
49
  const hashes = {};
188
50
  for (const file of files)
189
51
  hashes[file] = await sha256File(path.join(root, file));
@@ -250,12 +112,8 @@ export async function runFrontendWorktreeDiffGate(input) {
250
112
  if (untracked.code !== 0) {
251
113
  throw new Error(`frontend worktree diff gate ls-files failed: ${untracked.stderr.trim() || untracked.stdout.trim()}`);
252
114
  }
253
- const changedFilesAll = splitLines(nameOnly.stdout)
254
- .filter((file) => !isEphemeralToolCachePath(file))
255
- .sort();
256
- const untrackedFilesAll = splitLines(untracked.stdout)
257
- .filter((file) => !isEphemeralToolCachePath(file))
258
- .sort();
115
+ const changedFilesAll = splitLines(nameOnly.stdout).sort();
116
+ const untrackedFilesAll = splitLines(untracked.stdout).sort();
259
117
  const authorizedChangedPaths = input.authorizedChangedPaths ?? [];
260
118
  if (baseline) {
261
119
  for (const file of baseline.files) {
@@ -302,65 +160,11 @@ export async function runFrontendWorktreeDiffGate(input) {
302
160
  const absolutePatch = path.join(input.runDir, ...relativePatch.split("/"));
303
161
  await mkdir(path.dirname(absolutePatch), { recursive: true });
304
162
  await writeFile(absolutePatch, patchText, "utf8");
305
- // Keep the complete patch as immutable audit evidence, but create a bounded
306
- // reviewer entrypoint plus one file-scoped artifact per tracked change. This
307
- // prevents final review from loading a multi-thousand-line patch into a
308
- // single Pi session merely to inspect one or two relevant files.
309
- const reviewHunks = [];
310
- const reviewHunksDir = path.join(input.runDir, "artifacts", "diff-hunks");
311
- await mkdir(reviewHunksDir, { recursive: true });
312
- for (const [index, file] of changedFiles.entries()) {
313
- const filePatch = await run(root, ["diff", "--binary", "HEAD", "--", file]);
314
- if (filePatch.code !== 0) {
315
- throw new Error(`frontend worktree diff hunk failed for ${file}: ${filePatch.stderr.trim() || filePatch.stdout.trim()}`);
316
- }
317
- const text = filePatch.stdout.endsWith("\n") || filePatch.stdout.length === 0
318
- ? filePatch.stdout
319
- : `${filePatch.stdout}\n`;
320
- const fragments = splitReviewDiffFragments(text);
321
- for (const [partIndex, fragment] of fragments.entries()) {
322
- const part = partIndex + 1;
323
- const patchPath = `artifacts/diff-hunks/${String(index + 1).padStart(3, "0")}-${String(part).padStart(3, "0")}.patch`;
324
- const artifact = [
325
- "# Frontend review diff fragment",
326
- `# path: ${file}`,
327
- `# part: ${part}/${fragments.length}`,
328
- "",
329
- fragment,
330
- ].join("\n");
331
- await writeFile(path.join(input.runDir, ...patchPath.split("/")), artifact, "utf8");
332
- reviewHunks.push({
333
- path: file,
334
- patchPath,
335
- sha256: createHash("sha256").update(artifact).digest("hex"),
336
- bytes: Buffer.byteLength(artifact),
337
- part,
338
- parts: fragments.length,
339
- });
340
- }
341
- }
342
- const reviewIndexPath = "contracts/frontend-review-diff-index.json";
343
- await writeDagRunJsonArtifact(input.runDir, reviewIndexPath, {
344
- schemaVersion: 1,
345
- schemaId: FRONTEND_REVIEW_DIFF_INDEX_SCHEMA_ID,
346
- patchSha256,
347
- hunks: reviewHunks,
348
- untrackedFiles,
349
- });
350
- const reviewSummaryPath = "artifacts/diff_summary.md";
351
- await writeFile(path.join(input.runDir, ...reviewSummaryPath.split("/")), buildReviewDiffSummary({
352
- patchSha256,
353
- patchBytes: Buffer.byteLength(patchText),
354
- hunks: reviewHunks,
355
- untrackedFiles,
356
- }), "utf8");
357
163
  const payload = {
358
164
  schemaVersion: 1,
359
165
  schemaId: FRONTEND_WORKTREE_DIFF_SCHEMA_ID,
360
166
  patchPath: relativePatch,
361
167
  patchSha256,
362
- reviewSummaryPath,
363
- reviewIndexPath,
364
168
  changedFiles,
365
169
  untrackedFiles,
366
170
  empty: changedFiles.length === 0 && untrackedFiles.length === 0,
@@ -373,8 +177,6 @@ export async function runFrontendWorktreeDiffGate(input) {
373
177
  patchPath: relativePatch,
374
178
  patchAbsolutePath: absolutePatch,
375
179
  patchSha256,
376
- reviewSummaryPath,
377
- reviewIndexPath,
378
180
  changedFiles,
379
181
  untrackedFiles,
380
182
  empty: payload.empty,
@@ -387,8 +189,6 @@ export function formatFrontendWorktreeDiffStdout(result) {
387
189
  `schemaId=${result.schemaId}`,
388
190
  `patchPath=${result.patchPath}`,
389
191
  `patchSha256=${result.patchSha256}`,
390
- `reviewSummaryPath=${result.reviewSummaryPath}`,
391
- `reviewIndexPath=${result.reviewIndexPath}`,
392
192
  `changedFiles=${result.changedFiles.length}`,
393
193
  `untrackedFiles=${result.untrackedFiles.length}`,
394
194
  `empty=${result.empty ? "true" : "false"}`,
@@ -399,36 +199,3 @@ export function formatFrontendWorktreeDiffStdout(result) {
399
199
  .filter(Boolean)
400
200
  .join("\n");
401
201
  }
402
- /**
403
- * Expand glob-shaped contract paths into concrete workspace file paths.
404
- *
405
- * The frontend contract schema allows `targets.files` entries such as
406
- * `src/**` (skeleton inherits the task allowedPaths), but writer admission
407
- * derives the concrete writeSet and requires real file paths. This helper
408
- * matches every candidate against the enumerated workspace files and returns
409
- * the concrete paths. Candidates that are already concrete are kept as-is;
410
- * globs that match nothing are dropped (the derived writeSet only contains
411
- * paths the writer can actually touch).
412
- */
413
- export function expandFrontendGlobPaths(input) {
414
- const concrete = new Set();
415
- const patterns = [];
416
- for (const candidate of input.candidates) {
417
- const normalized = candidate.replace(/\\/g, "/");
418
- if (normalized.includes("*")) {
419
- patterns.push(normalized);
420
- }
421
- else {
422
- concrete.add(normalized);
423
- }
424
- }
425
- if (patterns.length === 0)
426
- return [...concrete].sort();
427
- const workspace = [...new Set(input.workspaceFiles.map((f) => f.replace(/\\/g, "/")))];
428
- for (const file of workspace) {
429
- if (patterns.some((pattern) => pathMatchesPattern(file, pattern))) {
430
- concrete.add(file);
431
- }
432
- }
433
- return [...concrete].sort();
434
- }