@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.
- package/AGENTS.md +6 -3
- package/CHANGELOG.md +605 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1411 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +30 -4
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1670 -706
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +579 -31
- package/dist/workflows/dag/validate.js +92 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* next-info: read-only report of the current npm `next` binding.
|
|
4
|
+
*
|
|
5
|
+
* Resolves the moving git ref `npm-next` (local, then origin) and the
|
|
6
|
+
* published tarball build stamp. Does not write the repo, move dist-tags,
|
|
7
|
+
* or call GitHub APIs.
|
|
8
|
+
*/
|
|
9
|
+
import { execFileSync } from "node:child_process";
|
|
10
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import process from "node:process";
|
|
14
|
+
import {
|
|
15
|
+
commandLaunch,
|
|
16
|
+
defaultRun,
|
|
17
|
+
isAncestor,
|
|
18
|
+
normalizeCommandArgs,
|
|
19
|
+
npmViewDistTags,
|
|
20
|
+
} from "./next-publish-gate.mjs";
|
|
21
|
+
import {
|
|
22
|
+
downloadNpmTarball,
|
|
23
|
+
readTarballBuildStamp,
|
|
24
|
+
} from "./release-source-binding.mjs";
|
|
25
|
+
|
|
26
|
+
export const UNPUBLISHED_COMMIT_LIMIT_DEFAULT = 50;
|
|
27
|
+
const GIT_REF_CANDIDATES = ["refs/heads/npm-next", "origin/npm-next"];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} cmd
|
|
31
|
+
* @param {string[]} args
|
|
32
|
+
* @param {string} [cwd]
|
|
33
|
+
*/
|
|
34
|
+
function runWithCwd(cmd, args, cwd) {
|
|
35
|
+
const launch = commandLaunch(cmd, normalizeCommandArgs(cmd, args));
|
|
36
|
+
return execFileSync(launch.cmd, launch.args, {
|
|
37
|
+
encoding: "utf8",
|
|
38
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
39
|
+
cwd,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function scriptEntryHref(argv1) {
|
|
44
|
+
try {
|
|
45
|
+
return argv1 ? new URL(`file://${argv1}`).href : "";
|
|
46
|
+
} catch {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function trimSha(value) {
|
|
52
|
+
if (typeof value !== "string") return null;
|
|
53
|
+
const sha = value.trim();
|
|
54
|
+
return sha ? sha : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function equalSha(left, right) {
|
|
58
|
+
if (!left || !right) return false;
|
|
59
|
+
return left.toLowerCase() === right.toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function tryRevParse(run, ref) {
|
|
63
|
+
try {
|
|
64
|
+
return trimSha(run("git", ["rev-parse", ref]));
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resolveGitRefSha(run) {
|
|
71
|
+
for (const ref of GIT_REF_CANDIDATES) {
|
|
72
|
+
const sha = tryRevParse(run, ref);
|
|
73
|
+
if (sha) return { ref, sha };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function readStampBuiltAt(tarballPath, run) {
|
|
79
|
+
try {
|
|
80
|
+
const listing = run("tar", ["-tzf", tarballPath]);
|
|
81
|
+
const stampEntry = String(listing)
|
|
82
|
+
.split("\n")
|
|
83
|
+
.map((line) => line.trim())
|
|
84
|
+
.find((line) => /\/dist\/build-stamp\.json$/.test(line));
|
|
85
|
+
if (!stampEntry) return null;
|
|
86
|
+
const stampJson = run("tar", ["-xzf", tarballPath, "-O", stampEntry]);
|
|
87
|
+
const parsed = JSON.parse(String(stampJson));
|
|
88
|
+
return typeof parsed.builtAt === "string" ? parsed.builtAt : null;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Download the published next tarball and read gitSha + builtAt. */
|
|
95
|
+
export function defaultNextStampProbe(version, run = defaultRun) {
|
|
96
|
+
const dir = mkdtempSync(join(tmpdir(), "loop-agent-next-info-"));
|
|
97
|
+
try {
|
|
98
|
+
const tarball = downloadNpmTarball(version, dir, run);
|
|
99
|
+
const stamp = readTarballBuildStamp(tarball, run);
|
|
100
|
+
return {
|
|
101
|
+
gitSha: stamp.gitSha,
|
|
102
|
+
version: stamp.version ?? null,
|
|
103
|
+
builtAt: readStampBuiltAt(tarball, run),
|
|
104
|
+
};
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
} finally {
|
|
108
|
+
rmSync(dir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function emptyResult(overrides) {
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
npmNextVersion: null,
|
|
117
|
+
gitSha: null,
|
|
118
|
+
gitRef: null,
|
|
119
|
+
gitRefSha: null,
|
|
120
|
+
stampSha: null,
|
|
121
|
+
builtAt: null,
|
|
122
|
+
source: null,
|
|
123
|
+
aheadBy: null,
|
|
124
|
+
aheadByReason: null,
|
|
125
|
+
unpublishedCommits: [],
|
|
126
|
+
unpublishedTruncated: false,
|
|
127
|
+
unpublishedLimit: UNPUBLISHED_COMMIT_LIMIT_DEFAULT,
|
|
128
|
+
drift: false,
|
|
129
|
+
error: null,
|
|
130
|
+
...overrides,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function collectAheadState(gitSha, run) {
|
|
135
|
+
if (!gitSha) {
|
|
136
|
+
return {
|
|
137
|
+
aheadBy: null,
|
|
138
|
+
aheadByReason: "no gitSha to compare against HEAD",
|
|
139
|
+
unpublishedCommits: [],
|
|
140
|
+
unpublishedTruncated: false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const headSha = tryRevParse(run, "HEAD");
|
|
144
|
+
if (!headSha) {
|
|
145
|
+
return {
|
|
146
|
+
aheadBy: null,
|
|
147
|
+
aheadByReason: "HEAD is unavailable",
|
|
148
|
+
unpublishedCommits: [],
|
|
149
|
+
unpublishedTruncated: false,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
let unpublishedCommits = [];
|
|
153
|
+
let unpublishedTruncated = false;
|
|
154
|
+
try {
|
|
155
|
+
const log = run("git", ["log", "--oneline", `${gitSha}..HEAD`]);
|
|
156
|
+
const lines = String(log ?? "")
|
|
157
|
+
.split("\n")
|
|
158
|
+
.map((line) => line.trim())
|
|
159
|
+
.filter(Boolean);
|
|
160
|
+
unpublishedTruncated = lines.length > UNPUBLISHED_COMMIT_LIMIT_DEFAULT;
|
|
161
|
+
unpublishedCommits = lines.slice(0, UNPUBLISHED_COMMIT_LIMIT_DEFAULT);
|
|
162
|
+
} catch {
|
|
163
|
+
unpublishedCommits = [];
|
|
164
|
+
}
|
|
165
|
+
if (!isAncestor(gitSha, headSha, run)) {
|
|
166
|
+
return {
|
|
167
|
+
aheadBy: null,
|
|
168
|
+
aheadByReason: "gitSha is not an ancestor of HEAD",
|
|
169
|
+
unpublishedCommits,
|
|
170
|
+
unpublishedTruncated,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const count = Number(
|
|
175
|
+
String(run("git", ["rev-list", "--count", `${gitSha}..HEAD`])).trim(),
|
|
176
|
+
);
|
|
177
|
+
if (!Number.isFinite(count)) {
|
|
178
|
+
return {
|
|
179
|
+
aheadBy: null,
|
|
180
|
+
aheadByReason: "rev-list count is not a number",
|
|
181
|
+
unpublishedCommits,
|
|
182
|
+
unpublishedTruncated,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
aheadBy: count,
|
|
187
|
+
aheadByReason: null,
|
|
188
|
+
unpublishedCommits,
|
|
189
|
+
unpublishedTruncated,
|
|
190
|
+
};
|
|
191
|
+
} catch {
|
|
192
|
+
return {
|
|
193
|
+
aheadBy: null,
|
|
194
|
+
aheadByReason: "rev-list failed",
|
|
195
|
+
unpublishedCommits,
|
|
196
|
+
unpublishedTruncated,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Pure-ish collector. Tests inject `run` / `viewDistTags` / `stampProbe`
|
|
203
|
+
* so this never hits the real npm registry.
|
|
204
|
+
*
|
|
205
|
+
* @param {{
|
|
206
|
+
* cwd?: string,
|
|
207
|
+
* run?: (cmd: string, args: string[]) => string,
|
|
208
|
+
* viewDistTags?: () => Record<string, string>,
|
|
209
|
+
* stampProbe?: (version: string) =>
|
|
210
|
+
* | { gitSha?: string, builtAt?: string | null }
|
|
211
|
+
* | null,
|
|
212
|
+
* }} [deps]
|
|
213
|
+
*/
|
|
214
|
+
export function collectNextInfo(deps = {}) {
|
|
215
|
+
const run =
|
|
216
|
+
deps.run ??
|
|
217
|
+
((cmd, args) =>
|
|
218
|
+
deps.cwd ? runWithCwd(cmd, args, deps.cwd) : defaultRun(cmd, args));
|
|
219
|
+
const viewDistTags = deps.viewDistTags ?? (() => npmViewDistTags(run));
|
|
220
|
+
const stampProbe =
|
|
221
|
+
deps.stampProbe ?? ((version) => defaultNextStampProbe(version, run));
|
|
222
|
+
|
|
223
|
+
let distTags = {};
|
|
224
|
+
try {
|
|
225
|
+
distTags = viewDistTags() ?? {};
|
|
226
|
+
} catch {
|
|
227
|
+
distTags = {};
|
|
228
|
+
}
|
|
229
|
+
const npmNextVersion = distTags.next ? String(distTags.next) : null;
|
|
230
|
+
const gitRef = resolveGitRefSha(run);
|
|
231
|
+
const gitRefSha = gitRef?.sha ?? null;
|
|
232
|
+
let stamp = null;
|
|
233
|
+
if (npmNextVersion) {
|
|
234
|
+
try {
|
|
235
|
+
stamp = stampProbe(npmNextVersion);
|
|
236
|
+
} catch {
|
|
237
|
+
stamp = null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const stampSha = trimSha(stamp?.gitSha);
|
|
241
|
+
const builtAt = typeof stamp?.builtAt === "string" ? stamp.builtAt : null;
|
|
242
|
+
|
|
243
|
+
if (!gitRefSha && !stampSha) {
|
|
244
|
+
const error = npmNextVersion
|
|
245
|
+
? `no npm-next git ref and tarball stamp unreadable for next=${npmNextVersion}`
|
|
246
|
+
: "no npm-next git ref and no dist-tags.next";
|
|
247
|
+
return emptyResult({ error, npmNextVersion });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let source;
|
|
251
|
+
let gitSha;
|
|
252
|
+
let drift = false;
|
|
253
|
+
let error = null;
|
|
254
|
+
let ok = true;
|
|
255
|
+
let exitCode = 0;
|
|
256
|
+
|
|
257
|
+
if (gitRefSha && stampSha) {
|
|
258
|
+
source = "both";
|
|
259
|
+
if (!equalSha(gitRefSha, stampSha)) {
|
|
260
|
+
drift = true;
|
|
261
|
+
ok = false;
|
|
262
|
+
exitCode = 1;
|
|
263
|
+
error =
|
|
264
|
+
`npm-next git ref (${gitRefSha}) does not match tarball stamp gitSha (${stampSha})`;
|
|
265
|
+
}
|
|
266
|
+
gitSha = gitRefSha;
|
|
267
|
+
} else if (gitRefSha) {
|
|
268
|
+
source = "git-ref";
|
|
269
|
+
gitSha = gitRefSha;
|
|
270
|
+
} else {
|
|
271
|
+
source = "tarball-stamp";
|
|
272
|
+
gitSha = stampSha;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ahead = collectAheadState(gitSha, run);
|
|
276
|
+
return {
|
|
277
|
+
ok,
|
|
278
|
+
exitCode,
|
|
279
|
+
npmNextVersion,
|
|
280
|
+
gitSha,
|
|
281
|
+
gitRef: gitRef?.ref ?? null,
|
|
282
|
+
gitRefSha,
|
|
283
|
+
stampSha,
|
|
284
|
+
builtAt,
|
|
285
|
+
source,
|
|
286
|
+
aheadBy: ahead.aheadBy,
|
|
287
|
+
aheadByReason: ahead.aheadByReason,
|
|
288
|
+
unpublishedCommits: ahead.unpublishedCommits,
|
|
289
|
+
unpublishedTruncated: ahead.unpublishedTruncated,
|
|
290
|
+
unpublishedLimit: UNPUBLISHED_COMMIT_LIMIT_DEFAULT,
|
|
291
|
+
drift,
|
|
292
|
+
error,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function formatNextInfo(result, { json = false } = {}) {
|
|
297
|
+
if (json) {
|
|
298
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
299
|
+
}
|
|
300
|
+
const lines = [];
|
|
301
|
+
if (result.npmNextVersion) {
|
|
302
|
+
lines.push(`npm next: ${result.npmNextVersion}`);
|
|
303
|
+
} else {
|
|
304
|
+
lines.push("npm next: (no dist-tags.next)");
|
|
305
|
+
}
|
|
306
|
+
if (result.gitSha) {
|
|
307
|
+
lines.push(`gitSha: ${result.gitSha} (source: ${result.source})`);
|
|
308
|
+
} else {
|
|
309
|
+
lines.push("gitSha: (unavailable)");
|
|
310
|
+
}
|
|
311
|
+
if (result.gitRefSha && result.stampSha && result.drift) {
|
|
312
|
+
lines.push(`git-ref SHA: ${result.gitRefSha}`);
|
|
313
|
+
lines.push(`tarball stamp SHA: ${result.stampSha}`);
|
|
314
|
+
}
|
|
315
|
+
if (result.builtAt) {
|
|
316
|
+
lines.push(`builtAt: ${result.builtAt}`);
|
|
317
|
+
}
|
|
318
|
+
if (result.aheadBy === null) {
|
|
319
|
+
lines.push(
|
|
320
|
+
`aheadBy: null${result.aheadByReason ? ` (${result.aheadByReason})` : ""}`,
|
|
321
|
+
);
|
|
322
|
+
} else {
|
|
323
|
+
lines.push(`aheadBy: ${result.aheadBy}`);
|
|
324
|
+
}
|
|
325
|
+
const commits = result.unpublishedCommits ?? [];
|
|
326
|
+
if (commits.length === 0) {
|
|
327
|
+
lines.push("unpublishedCommits: (none)");
|
|
328
|
+
} else {
|
|
329
|
+
lines.push("unpublishedCommits:");
|
|
330
|
+
for (const commit of commits) lines.push(` ${commit}`);
|
|
331
|
+
if (result.unpublishedTruncated) {
|
|
332
|
+
lines.push(
|
|
333
|
+
` … truncated to ${result.unpublishedLimit} commits`,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (result.error) {
|
|
338
|
+
lines.push(`error: ${result.error}`);
|
|
339
|
+
}
|
|
340
|
+
return `${lines.join("\n")}\n`;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function main(argv = process.argv.slice(2)) {
|
|
344
|
+
const json = argv.includes("--json");
|
|
345
|
+
const result = collectNextInfo();
|
|
346
|
+
process.stdout.write(formatNextInfo(result, { json }));
|
|
347
|
+
process.exit(result.ok ? 0 : result.exitCode || 1);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const invokedAsScript =
|
|
351
|
+
Boolean(process.argv[1]) &&
|
|
352
|
+
import.meta.url === scriptEntryHref(process.argv[1]);
|
|
353
|
+
|
|
354
|
+
if (invokedAsScript) {
|
|
355
|
+
main();
|
|
356
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* next-publish-gate: throttle main -> npm `next` publishing.
|
|
4
|
+
*
|
|
5
|
+
* Every main push used to publish a new next build. With this gate a
|
|
6
|
+
* push-triggered run only publishes when HEAD is at least COMMIT_THRESHOLD
|
|
7
|
+
* commits ahead of the commit that produced the current dist-tags.next
|
|
8
|
+
* build (read from the published tarball's dist/build-stamp.json).
|
|
9
|
+
*
|
|
10
|
+
* Bypasses (publish regardless of the count):
|
|
11
|
+
* - workflow_dispatch runs (manual trigger, e.g. right before cutting a
|
|
12
|
+
* release line); the workflow passes --force for those.
|
|
13
|
+
* - recovery: HEAD already IS the source of the current next build, so
|
|
14
|
+
* re-publishing would be the same version anyway.
|
|
15
|
+
* - unknown last-published SHA (no npm history / unreadable stamp /
|
|
16
|
+
* SHA not an ancestor of HEAD): fail open — a missed next build is
|
|
17
|
+
* cheap, permanently stuck publishing is not.
|
|
18
|
+
*
|
|
19
|
+
* Exit codes: 0 = publish, 2 = skip (gate), 1 = hard error. The workflow
|
|
20
|
+
* maps skip to a successful early exit so non-publishing runs are green.
|
|
21
|
+
*/
|
|
22
|
+
import { execFileSync } from "node:child_process";
|
|
23
|
+
import { mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import process from "node:process";
|
|
27
|
+
import { readTarballBuildStamp } from "./release-source-binding.mjs";
|
|
28
|
+
|
|
29
|
+
export const COMMIT_THRESHOLD_DEFAULT = 5;
|
|
30
|
+
const SKIP_EXIT_CODE = 2;
|
|
31
|
+
|
|
32
|
+
/** Run a command and return trimmed stdout; injected for tests. */
|
|
33
|
+
function normalizeWindowsTarArg(value) {
|
|
34
|
+
const match = /^([A-Za-z]):[\\/](.*)$/.exec(String(value));
|
|
35
|
+
if (!match) return value;
|
|
36
|
+
return `/${match[1].toLowerCase()}/${match[2].replaceAll("\\", "/")}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function normalizeCommandArgs(cmd, args, platform = process.platform) {
|
|
40
|
+
if (platform !== "win32" || cmd !== "tar") return args;
|
|
41
|
+
return args.map(normalizeWindowsTarArg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function commandLaunch(cmd, args, platform = process.platform) {
|
|
45
|
+
if (platform === "win32" && cmd === "npm") {
|
|
46
|
+
return {
|
|
47
|
+
cmd: process.env.ComSpec || "cmd.exe",
|
|
48
|
+
args: ["/d", "/s", "/c", "npm", ...args],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { cmd, args };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function defaultRun(cmd, args) {
|
|
55
|
+
const launch = commandLaunch(cmd, normalizeCommandArgs(cmd, args));
|
|
56
|
+
return execFileSync(launch.cmd, launch.args, {
|
|
57
|
+
encoding: "utf8",
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function npmViewDistTags(run = defaultRun) {
|
|
63
|
+
const out = run("npm", [
|
|
64
|
+
"view",
|
|
65
|
+
"@tea-agent/loop-agent",
|
|
66
|
+
"dist-tags",
|
|
67
|
+
"--json",
|
|
68
|
+
]);
|
|
69
|
+
const trimmed = String(out ?? "").trim();
|
|
70
|
+
if (!trimmed) return {};
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(trimmed);
|
|
74
|
+
} catch {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Download the exact published next version and read its build stamp. */
|
|
81
|
+
export function defaultStampProbe(version) {
|
|
82
|
+
const dir = mkdtempSync(join(tmpdir(), "loop-agent-next-gate-"));
|
|
83
|
+
try {
|
|
84
|
+
defaultRun("npm", [
|
|
85
|
+
"pack",
|
|
86
|
+
`@tea-agent/loop-agent@${version}`,
|
|
87
|
+
"--pack-destination",
|
|
88
|
+
dir,
|
|
89
|
+
]);
|
|
90
|
+
const file = readdirSync(dir).find((entry) => entry.endsWith(".tgz"));
|
|
91
|
+
if (!file) return null;
|
|
92
|
+
try {
|
|
93
|
+
return readTarballBuildStamp(join(dir, file), defaultRun);
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
} finally {
|
|
100
|
+
rmSync(dir, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function isAncestor(sha, head, run = defaultRun) {
|
|
105
|
+
try {
|
|
106
|
+
run("git", ["merge-base", "--is-ancestor", sha, head]);
|
|
107
|
+
return true;
|
|
108
|
+
} catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Pure decision. Inputs:
|
|
115
|
+
* - threshold: minimum commits ahead of lastPublishedSha to publish
|
|
116
|
+
* - aheadBy: commits between lastPublishedSha and headSha (null = unknown)
|
|
117
|
+
* - lastPublishedSha / headSha: for the recovery equality check
|
|
118
|
+
* Returns { publish, reason, aheadBy }.
|
|
119
|
+
*/
|
|
120
|
+
export function shouldPublishNext({
|
|
121
|
+
threshold = COMMIT_THRESHOLD_DEFAULT,
|
|
122
|
+
lastPublishedSha,
|
|
123
|
+
headSha,
|
|
124
|
+
aheadBy,
|
|
125
|
+
force = false,
|
|
126
|
+
}) {
|
|
127
|
+
if (force) {
|
|
128
|
+
return { publish: true, reason: "force-bypass", aheadBy };
|
|
129
|
+
}
|
|
130
|
+
if (!headSha) {
|
|
131
|
+
return { publish: true, reason: "head-unknown-fail-open", aheadBy };
|
|
132
|
+
}
|
|
133
|
+
if (!lastPublishedSha) {
|
|
134
|
+
return {
|
|
135
|
+
publish: true,
|
|
136
|
+
reason: "last-published-sha-unknown-fail-open",
|
|
137
|
+
aheadBy,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const last = String(lastPublishedSha).toLowerCase();
|
|
141
|
+
const head = String(headSha).toLowerCase();
|
|
142
|
+
if (last === head) {
|
|
143
|
+
return { publish: true, reason: "same-commit-recovery", aheadBy: 0 };
|
|
144
|
+
}
|
|
145
|
+
if (aheadBy === null || aheadBy === undefined || !Number.isFinite(aheadBy)) {
|
|
146
|
+
return { publish: true, reason: "ahead-unknown-fail-open", aheadBy: null };
|
|
147
|
+
}
|
|
148
|
+
const normalizedThreshold = Number(threshold);
|
|
149
|
+
if (!Number.isFinite(normalizedThreshold) || normalizedThreshold <= 0) {
|
|
150
|
+
return { publish: true, reason: "threshold-invalid-fail-open", aheadBy };
|
|
151
|
+
}
|
|
152
|
+
if (aheadBy >= normalizedThreshold) {
|
|
153
|
+
return { publish: true, reason: "ahead-threshold-met", aheadBy };
|
|
154
|
+
}
|
|
155
|
+
return { publish: false, reason: "below-threshold-skip", aheadBy };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseArgs(argv) {
|
|
159
|
+
return Object.fromEntries(
|
|
160
|
+
argv
|
|
161
|
+
.filter((arg) => arg.startsWith("--"))
|
|
162
|
+
.map((arg) => {
|
|
163
|
+
const [key, ...value] = arg.replace(/^--/, "").split("=");
|
|
164
|
+
return [key, value.join("=") || "true"];
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function main() {
|
|
170
|
+
const args = parseArgs(process.argv.slice(2));
|
|
171
|
+
const threshold = Number(args.threshold || COMMIT_THRESHOLD_DEFAULT);
|
|
172
|
+
const distTags = npmViewDistTags();
|
|
173
|
+
const currentNext = distTags.next ? String(distTags.next) : null;
|
|
174
|
+
let lastPublishedSha = null;
|
|
175
|
+
let currentNextNote = "no dist-tags.next";
|
|
176
|
+
if (currentNext) {
|
|
177
|
+
const stamp = defaultStampProbe(currentNext);
|
|
178
|
+
if (stamp && stamp.gitSha) {
|
|
179
|
+
lastPublishedSha = stamp.gitSha;
|
|
180
|
+
currentNextNote = `next=${currentNext} from ${stamp.gitSha.slice(0, 10)}`;
|
|
181
|
+
} else {
|
|
182
|
+
currentNextNote = `next=${currentNext} (stamp unreadable)`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
let headSha = null;
|
|
186
|
+
let aheadBy = null;
|
|
187
|
+
try {
|
|
188
|
+
headSha = defaultRun("git", ["rev-parse", "HEAD"]).trim();
|
|
189
|
+
} catch {
|
|
190
|
+
headSha = null;
|
|
191
|
+
}
|
|
192
|
+
if (headSha && lastPublishedSha) {
|
|
193
|
+
if (!isAncestor(lastPublishedSha, headSha)) {
|
|
194
|
+
aheadBy = null;
|
|
195
|
+
} else {
|
|
196
|
+
aheadBy = Number(
|
|
197
|
+
defaultRun("git", [
|
|
198
|
+
"rev-list",
|
|
199
|
+
"--count",
|
|
200
|
+
`${lastPublishedSha}..${headSha}`,
|
|
201
|
+
]).trim(),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const decision = shouldPublishNext({
|
|
206
|
+
threshold,
|
|
207
|
+
lastPublishedSha,
|
|
208
|
+
headSha,
|
|
209
|
+
aheadBy,
|
|
210
|
+
force: args.force === "true",
|
|
211
|
+
});
|
|
212
|
+
process.stdout.write(
|
|
213
|
+
`next-publish-gate: ${currentNextNote}\n` +
|
|
214
|
+
`next-publish-gate: head=${headSha ? headSha.slice(0, 10) : "unknown"} ` +
|
|
215
|
+
`aheadBy=${aheadBy === null ? "unknown" : aheadBy} ` +
|
|
216
|
+
`threshold=${threshold}\n` +
|
|
217
|
+
`next-publish-gate: ${decision.publish ? "PUBLISH" : "SKIP"} ` +
|
|
218
|
+
`(${decision.reason})\n`,
|
|
219
|
+
);
|
|
220
|
+
process.exit(decision.publish ? 0 : SKIP_EXIT_CODE);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// CLI 入口安全判断(argv[1] 非合法 file: URL 时 new URL 会抛异常)
|
|
224
|
+
function scriptEntryHref(argv1) {
|
|
225
|
+
try {
|
|
226
|
+
return argv1 ? new URL(`file://${argv1}`).href : "";
|
|
227
|
+
} catch {
|
|
228
|
+
return "";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const invokedAsScript =
|
|
233
|
+
Boolean(process.argv[1]) &&
|
|
234
|
+
import.meta.url === scriptEntryHref(process.argv[1]);
|
|
235
|
+
|
|
236
|
+
if (invokedAsScript) {
|
|
237
|
+
main();
|
|
238
|
+
}
|