@tea-agent/loop-agent 0.1.0-fe-test.3 → 0.1.0-fe-test.5
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 +607 -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 +4323 -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 +1456 -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 +17 -3
- 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 +32 -4
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +69 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +17 -5
- 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 +202 -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 +1771 -717
- 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 +600 -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 +10 -12
- 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
|
@@ -20,7 +20,8 @@ const factsSchema = z
|
|
|
20
20
|
tpId: z.string(),
|
|
21
21
|
field: z.string().optional(),
|
|
22
22
|
intent: z.string(),
|
|
23
|
-
observed: z.string(),
|
|
23
|
+
observed: z.string().max(200),
|
|
24
|
+
observedLength: z.number().int().min(0).optional(),
|
|
24
25
|
status: z.enum(["MATCH", "MISMATCH", "UNDETERMINED"]),
|
|
25
26
|
repairability: z.enum([
|
|
26
27
|
"repairable",
|
|
@@ -28,6 +29,12 @@ const factsSchema = z
|
|
|
28
29
|
"none",
|
|
29
30
|
"undetermined-no-repair",
|
|
30
31
|
]),
|
|
32
|
+
reasonCode: z.enum(["SCENARIO_PARAM_MATCH", "SCENARIO_PARAM_MISMATCH", "SCENARIO_PARAM_UNDETERMINED"]),
|
|
33
|
+
expectedRaw: z.string().max(512).optional(),
|
|
34
|
+
observedRaw: z.string().max(512),
|
|
35
|
+
expectedNormalized: z.string().max(512).optional(),
|
|
36
|
+
observedNormalized: z.string().max(512).optional(),
|
|
37
|
+
sourceLocation: z.string().max(512).optional(),
|
|
31
38
|
suggestedFix: z.string().optional(),
|
|
32
39
|
scriptPath: z.string().optional(),
|
|
33
40
|
bound: z.number().optional(),
|
|
@@ -52,6 +59,7 @@ const CLOSED_SET = new Set([
|
|
|
52
59
|
"null",
|
|
53
60
|
"min-1",
|
|
54
61
|
"min",
|
|
62
|
+
"max-1",
|
|
55
63
|
"max",
|
|
56
64
|
"max+1",
|
|
57
65
|
"pattern-invalid",
|
|
@@ -148,14 +156,19 @@ function parseScenarioBoundToken(raw) {
|
|
|
148
156
|
function parseScenarioIntentLine(line) {
|
|
149
157
|
// Target may contain commas (body.title,body.status). Intent may contain `|` / spaces.
|
|
150
158
|
// Stop field values only at known trailing keys or end-of-line.
|
|
151
|
-
const
|
|
159
|
+
const unfenced = line
|
|
160
|
+
.trim()
|
|
161
|
+
.replace(/^[-*+]\s+/, "")
|
|
162
|
+
.replace(/^`(.+)`$/, "$1")
|
|
163
|
+
.trim();
|
|
164
|
+
const precise = /场景意图\s*[::]\s*(TP-[A-Z0-9-]+)\s*[|;]\s*operation\s*=\s*([^;\n]+?)\s*[|;]\s*target\s*=\s*([^;\n]+?)\s*[|;]\s*intent\s*=\s*([^;\n]+?)(?:\s*[|;]\s*bound\s*=\s*([^\s;`|\n]+))?(?:\s*[|;]\s*example\s*=\s*([^;\n]*))?(?:\s*[|;]\s*expectedCode\s*=\s*[^;\n]+)?\s*$/i.exec(unfenced);
|
|
152
165
|
if (precise) {
|
|
153
166
|
return {
|
|
154
167
|
tpId: precise[1],
|
|
155
168
|
rawIntent: (precise[4] ?? "unknown").trim(),
|
|
156
169
|
target: precise[3]?.trim(),
|
|
157
170
|
bound: parseScenarioBoundToken(precise[5]),
|
|
158
|
-
example: precise[6]
|
|
171
|
+
example: precise[6] === undefined ? undefined : precise[6].trim(),
|
|
159
172
|
legacy: false,
|
|
160
173
|
};
|
|
161
174
|
}
|
|
@@ -185,6 +198,53 @@ function resolveScenarioIntentField(target, field) {
|
|
|
185
198
|
target.split(/\s*,\s*/)[0];
|
|
186
199
|
return preferred?.split(".").at(-1);
|
|
187
200
|
}
|
|
201
|
+
function normalizeLengthIntentAlias(rawIntent) {
|
|
202
|
+
const lower = rawIntent.trim().toLowerCase();
|
|
203
|
+
if (lower === "max-1" || lower === "maxminus1" || lower === "max_minus_1") {
|
|
204
|
+
return "max-1";
|
|
205
|
+
}
|
|
206
|
+
if (lower === "min-1" || lower === "minminus1" || lower === "min_minus_1") {
|
|
207
|
+
return "min-1";
|
|
208
|
+
}
|
|
209
|
+
return lower;
|
|
210
|
+
}
|
|
211
|
+
function proseLengthBound(haystack, field) {
|
|
212
|
+
const fieldAlt = field ? field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : undefined;
|
|
213
|
+
const scoped = fieldAlt ? new RegExp(`${fieldAlt}[^\\n]{0,160}`, "ig") : undefined;
|
|
214
|
+
const windows = [];
|
|
215
|
+
if (scoped) {
|
|
216
|
+
for (const match of haystack.matchAll(scoped)) {
|
|
217
|
+
windows.push(match[0] ?? "");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
windows.push(haystack);
|
|
221
|
+
let max;
|
|
222
|
+
let min;
|
|
223
|
+
const proseMaxRe = /(\d{1,4})\s*个字符的最大/i;
|
|
224
|
+
for (const window of windows) {
|
|
225
|
+
const proseMax = proseMaxRe.exec(window);
|
|
226
|
+
if (proseMax && max === undefined)
|
|
227
|
+
max = Number(proseMax[1]);
|
|
228
|
+
const nums = [...window.matchAll(/(?<![+\-])\d{1,4}/g)]
|
|
229
|
+
.map((item) => Number(item[0]))
|
|
230
|
+
.filter((item) => Number.isFinite(item));
|
|
231
|
+
for (let i = 0; i + 2 < nums.length; i += 1) {
|
|
232
|
+
const a = nums[i];
|
|
233
|
+
const b = nums[i + 1];
|
|
234
|
+
const c = nums[i + 2];
|
|
235
|
+
// Prefer n-1,n,n+1 around a documented max (100/2000), not 0,1,99 or 99,100,101's first two plus leftover.
|
|
236
|
+
if (b === a + 1 && c === b + 1 && b >= 10) {
|
|
237
|
+
max ??= b;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (nums.includes(0) && nums.includes(1))
|
|
242
|
+
min ??= 1;
|
|
243
|
+
if (max !== undefined && min !== undefined)
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return { max, min };
|
|
247
|
+
}
|
|
188
248
|
function resolveCustomLiteralIntent(rawIntent, field) {
|
|
189
249
|
const lower = rawIntent.toLowerCase();
|
|
190
250
|
if (!lower.startsWith("custom-literal:")) {
|
|
@@ -243,7 +303,7 @@ export function inferScenarioParamIntent(input) {
|
|
|
243
303
|
const field = resolveScenarioIntentField(machine.target, machine.field);
|
|
244
304
|
const rawIntent = machine.rawIntent.trim();
|
|
245
305
|
const example = machine.example;
|
|
246
|
-
const lower = rawIntent
|
|
306
|
+
const lower = normalizeLengthIntentAlias(rawIntent);
|
|
247
307
|
let normalizedIntent = lower === "nominal-operation" ? "nominal" : lower;
|
|
248
308
|
// Writers sometimes mark a short "typical" length sample as min/max with bound=LEN<nominal>.
|
|
249
309
|
// Treat that as nominal so a short helper/string is not forced to equal maxLength.
|
|
@@ -266,16 +326,16 @@ export function inferScenarioParamIntent(input) {
|
|
|
266
326
|
new RegExp(`(?:minLength|min(?:imum)?|下限|最小长度)\\s*[=::]?\\s*(\\d{1,4})[^\\n]{0,80}?${fieldEsc}`, "i").exec(haystack) ??
|
|
267
327
|
/(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack)
|
|
268
328
|
: /(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack);
|
|
329
|
+
const proseBound = proseLengthBound(haystack, field);
|
|
269
330
|
const prefersMinBound = normalizedIntent === "min" ||
|
|
270
331
|
normalizedIntent === "min-1" ||
|
|
271
332
|
/(?:MIN|LEN1|LENGTH-?1|最短|最小)/i.test(tpId);
|
|
272
|
-
const boundFromBody = prefersMinBound
|
|
273
|
-
? minBoundFromBody ?? maxBoundFromBody
|
|
274
|
-
: maxBoundFromBody ?? minBoundFromBody;
|
|
333
|
+
const boundFromBody = prefersMinBound ? minBoundFromBody : maxBoundFromBody ?? minBoundFromBody;
|
|
275
334
|
const boundFromTp = /(?:LEN(?:GTH)?|长度)[_-]?(\d{1,5})(?:[_-]|$)/i.exec(tpId) ??
|
|
276
|
-
/(?:MIN|MAX)[_-]
|
|
335
|
+
/(?:MIN|MAX)[_-](\d{2,5})(?:[_-]|$)/i.exec(tpId);
|
|
277
336
|
const lengthIntent = normalizedIntent === "min" ||
|
|
278
337
|
normalizedIntent === "min-1" ||
|
|
338
|
+
normalizedIntent === "max-1" ||
|
|
279
339
|
normalizedIntent === "max" ||
|
|
280
340
|
normalizedIntent === "max+1";
|
|
281
341
|
// Length intents: explicit machine bound >0, then TP-encoded LEN1/LEN100,
|
|
@@ -287,13 +347,35 @@ export function inferScenarioParamIntent(input) {
|
|
|
287
347
|
: normalizedIntent === "max+1"
|
|
288
348
|
? Math.max(0, boundFromTpNumber - 1)
|
|
289
349
|
: boundFromTpNumber;
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
350
|
+
const boundFromProse = prefersMinBound ? proseBound.min : proseBound.max;
|
|
351
|
+
const offsetIntent = normalizedIntent === "max-1" ||
|
|
352
|
+
normalizedIntent === "max+1" ||
|
|
353
|
+
normalizedIntent === "min-1";
|
|
354
|
+
const contractBound = boundFromBody
|
|
355
|
+
? Number(boundFromBody[1])
|
|
356
|
+
: boundFromProse !== undefined && boundFromProse >= 0
|
|
357
|
+
? boundFromProse
|
|
358
|
+
: undefined;
|
|
359
|
+
const machineBoundPositive = typeof machine.bound === "number" && Number.isFinite(machine.bound) && machine.bound > 0;
|
|
360
|
+
const minLengthFromBody = prefersMinBound && minBoundFromBody ? Number(minBoundFromBody[1]) : undefined;
|
|
361
|
+
const machineBoundZeroMin = prefersMinBound &&
|
|
362
|
+
machine.bound === 0 &&
|
|
363
|
+
minLengthFromBody === undefined &&
|
|
364
|
+
boundFromTpNormalized === undefined;
|
|
365
|
+
const bound = offsetIntent && contractBound !== undefined && contractBound > 0
|
|
366
|
+
? contractBound
|
|
367
|
+
: machineBoundPositive && !offsetIntent
|
|
368
|
+
? machine.bound
|
|
369
|
+
: lengthIntent && boundFromTpNormalized !== undefined
|
|
370
|
+
? boundFromTpNormalized
|
|
371
|
+
: minLengthFromBody !== undefined && minLengthFromBody >= 0
|
|
372
|
+
? minLengthFromBody
|
|
373
|
+
: machineBoundZeroMin
|
|
374
|
+
? 0
|
|
375
|
+
: contractBound !== undefined &&
|
|
376
|
+
(prefersMinBound ? contractBound >= 0 : contractBound > 0)
|
|
377
|
+
? contractBound
|
|
378
|
+
: undefined;
|
|
297
379
|
if (rawIntent.toLowerCase().startsWith("custom-literal:")) {
|
|
298
380
|
const resolved = resolveCustomLiteralIntent(rawIntent, field);
|
|
299
381
|
const rawLiteral = rawIntent.slice(rawIntent.indexOf(":") + 1).trim();
|
|
@@ -380,13 +462,15 @@ export function inferScenarioParamIntent(input) {
|
|
|
380
462
|
const boundMatch = fieldScopedBound ??
|
|
381
463
|
/(?:maxLength|max(?:imum)?|上限|最大长度)\s*[=::]?\s*(\d{1,4})/i.exec(`${caseBody}\n${dataSection}`) ??
|
|
382
464
|
/(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(`${caseBody}\n${dataSection}`);
|
|
383
|
-
const
|
|
465
|
+
const proseBound = proseLengthBound(`${caseBody}
|
|
466
|
+
${dataSection}`, field);
|
|
467
|
+
const bound = boundMatch ? Number(boundMatch[1]) : proseBound.max ?? proseBound.min;
|
|
384
468
|
const exampleMatch = /(?:反例|invalid example|example)\s*[=::]\s*[`"]?([^`"\n]+)[`"]?/i.exec(caseBody);
|
|
385
469
|
const example = exampleMatch?.[1]?.trim();
|
|
386
470
|
if (/EMPTY|空白|空串|空字符串/.test(upper) || /空字符串|空串|empty string/i.test(caseBody)) {
|
|
387
471
|
return { intent: "empty", field, bound, example, intentSource: "tp-fallback" };
|
|
388
472
|
}
|
|
389
|
-
if (/MISSING|缺省|缺失|省略/.test(upper) || /缺少字段|缺失字段|missing field/i.test(caseBody)) {
|
|
473
|
+
if (/MISSING|OMITTED|\bOMIT\b|缺省|缺失|省略/.test(upper) || /缺少字段|缺失字段|missing field/i.test(caseBody)) {
|
|
390
474
|
return { intent: "missing", field, bound, example, intentSource: "tp-fallback" };
|
|
391
475
|
}
|
|
392
476
|
if (/\bNULL\b|空值/.test(upper) || /\bnull\b/i.test(caseBody)) {
|
|
@@ -395,6 +479,9 @@ export function inferScenarioParamIntent(input) {
|
|
|
395
479
|
if (/MAX[-_]?PLUS[-_]?1|MAX\+1|超长|越界|LENGTH[-_]?OVER|OVER[-_]?LENGTH|OVER/.test(upper)) {
|
|
396
480
|
return { intent: "max+1", field, bound, example, intentSource: "tp-fallback" };
|
|
397
481
|
}
|
|
482
|
+
if (/MAX[-_]1(?:$|[-_])|max-1/i.test(upper)) {
|
|
483
|
+
return { intent: "max-1", field, bound, example, intentSource: "tp-fallback" };
|
|
484
|
+
}
|
|
398
485
|
if (/\bMAX\b|最大/.test(upper)) {
|
|
399
486
|
return { intent: "max", field, bound, example, intentSource: "tp-fallback" };
|
|
400
487
|
}
|
|
@@ -418,7 +505,7 @@ export function inferScenarioParamIntent(input) {
|
|
|
418
505
|
}
|
|
419
506
|
return { intent: "unknown", field, bound, example, intentSource: "tp-fallback" };
|
|
420
507
|
}
|
|
421
|
-
const OMIT_SENTINEL_RE = /^(?:_OMIT|OMIT|MISSING|Ellipsis|\.\.\.)\b/;
|
|
508
|
+
const OMIT_SENTINEL_RE = /^(?:_OMIT|_MISSING|OMIT|MISSING|Ellipsis|\.\.\.)\b/;
|
|
422
509
|
const HTTP_EXPECTED_CODE_RE = /^(?:2xx|3xx|4xx|5xx|[1-5]\d{2}|HTTP_[1-5]\d{2})$/i;
|
|
423
510
|
/** Semantic custom-literal tokens that describe a value class, not a raw string. */
|
|
424
511
|
function isWhitespaceSemanticLiteral(token) {
|
|
@@ -435,8 +522,16 @@ function isWhitespacePaddedString(value) {
|
|
|
435
522
|
}
|
|
436
523
|
function normalizeScenarioLiteralText(value) {
|
|
437
524
|
// Writers sometimes emit visible-space placeholders (U+2420), NBSP variants,
|
|
438
|
-
//
|
|
525
|
+
// URL-encoded spaces, or explicit Python/JSON whitespace escapes in
|
|
526
|
+
// machine-readable Markdown. Decode only escapes that resolve to whitespace;
|
|
527
|
+
// ordinary business characters such as `\\u0041` remain literal and fail closed.
|
|
528
|
+
const decodeWhitespaceEscape = (token, hex) => {
|
|
529
|
+
const decoded = String.fromCodePoint(Number.parseInt(hex, 16));
|
|
530
|
+
return /^\s$/u.test(decoded) || /[ ]/u.test(decoded) ? decoded : token;
|
|
531
|
+
};
|
|
439
532
|
const normalized = value
|
|
533
|
+
.replace(/\\u([0-9a-f]{4})/gi, decodeWhitespaceEscape)
|
|
534
|
+
.replace(/\\x([0-9a-f]{2})/gi, decodeWhitespaceEscape)
|
|
440
535
|
.replace(/␠/g, " ")
|
|
441
536
|
.replace(/ /g, " ")
|
|
442
537
|
.replace(/ /g, " ")
|
|
@@ -677,6 +772,50 @@ export function extractPytestParamBlock(source, tpId) {
|
|
|
677
772
|
}
|
|
678
773
|
return undefined;
|
|
679
774
|
}
|
|
775
|
+
function extractPytestParamTopLevelArgs(block) {
|
|
776
|
+
if (!block)
|
|
777
|
+
return [];
|
|
778
|
+
const open = block.indexOf("(");
|
|
779
|
+
const close = block.lastIndexOf(")");
|
|
780
|
+
if (open < 0 || close <= open)
|
|
781
|
+
return [];
|
|
782
|
+
const input = block.slice(open + 1, close);
|
|
783
|
+
const args = [];
|
|
784
|
+
let start = 0;
|
|
785
|
+
let depth = 0;
|
|
786
|
+
let quote = "";
|
|
787
|
+
let escaped = false;
|
|
788
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
789
|
+
const ch = input[index];
|
|
790
|
+
if (escaped) {
|
|
791
|
+
escaped = false;
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if (ch === "\\") {
|
|
795
|
+
escaped = true;
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
if (quote) {
|
|
799
|
+
if (ch === quote)
|
|
800
|
+
quote = "";
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
if (ch === '"' || ch === "'") {
|
|
804
|
+
quote = ch;
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
if (ch === "[" || ch === "{" || ch === "(")
|
|
808
|
+
depth += 1;
|
|
809
|
+
else if (ch === "]" || ch === "}" || ch === ")")
|
|
810
|
+
depth -= 1;
|
|
811
|
+
else if (ch === "," && depth === 0) {
|
|
812
|
+
args.push(input.slice(start, index).trim());
|
|
813
|
+
start = index + 1;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
args.push(input.slice(start).trim());
|
|
817
|
+
return args.filter((arg) => arg && !/^(?:id|marks)\s*=/.test(arg));
|
|
818
|
+
}
|
|
680
819
|
function extractPytestParamParameterNames(source, tpId) {
|
|
681
820
|
const block = extractPytestParamBlock(source, tpId);
|
|
682
821
|
if (!block)
|
|
@@ -688,8 +827,11 @@ function extractPytestParamParameterNames(source, tpId) {
|
|
|
688
827
|
if (decoratorIndex < 0)
|
|
689
828
|
return [];
|
|
690
829
|
const prefix = source.slice(decoratorIndex, blockIndex);
|
|
691
|
-
const
|
|
692
|
-
|
|
830
|
+
const scalar = /@pytest\.mark\.parametrize\s*\(\s*["']([^"']+)["']/s.exec(prefix)?.[1];
|
|
831
|
+
if (scalar)
|
|
832
|
+
return scalar.split(",").map((name) => name.trim()).filter(Boolean);
|
|
833
|
+
const tuple = /@pytest\.mark\.parametrize\s*\(\s*\(\s*((?:["'][^"']+["']\s*,?\s*)+)\)/s.exec(prefix)?.[1];
|
|
834
|
+
return tuple ? [...tuple.matchAll(/["']([^"']+)["']/g)].map((match) => match[1]).filter(Boolean) : [];
|
|
693
835
|
}
|
|
694
836
|
export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
695
837
|
if (!block)
|
|
@@ -712,6 +854,10 @@ export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
|
712
854
|
(/["'][A-Za-z_][A-Za-z0-9_]*["']\s*:/.test(dictText) ||
|
|
713
855
|
/(?:payload|body|data|json)\s*=/.test(block));
|
|
714
856
|
if (dictLooksLikePayload && !field) {
|
|
857
|
+
const emptyField = /["']([A-Za-z_][A-Za-z0-9_.]*)["']\s*:\s*(?:""|'')/.exec(dictText);
|
|
858
|
+
if (emptyField?.[1]) {
|
|
859
|
+
return { kind: "empty-string", text: '""', length: 0, literal: "" };
|
|
860
|
+
}
|
|
715
861
|
return { kind: "dict", text: dictText.replace(/\s+/g, " ").slice(0, 160) };
|
|
716
862
|
}
|
|
717
863
|
if (dictLooksLikePayload && field) {
|
|
@@ -741,7 +887,7 @@ export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
|
741
887
|
};
|
|
742
888
|
}
|
|
743
889
|
// Bare omit sentinel before id=...
|
|
744
|
-
if (/pytest\.param\s*\(\s*(?:_OMIT|OMIT|MISSING|\.\.\.|Ellipsis)\s*(?:,|\)|$)/.test(block)) {
|
|
890
|
+
if (/pytest\.param\s*\(\s*(?:_OMIT|_MISSING|OMIT|MISSING|\.\.\.|Ellipsis)\s*(?:,|\)|$)/.test(block)) {
|
|
745
891
|
return {
|
|
746
892
|
kind: "missing-key",
|
|
747
893
|
text: field ? `missing:${field}` : "missing-key",
|
|
@@ -749,48 +895,7 @@ export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
|
749
895
|
}
|
|
750
896
|
// Parse top-level positional args before the legacy token scanner so list
|
|
751
897
|
// cardinality and field/value rows remain statically visible.
|
|
752
|
-
const topLevelArgs = (
|
|
753
|
-
const open = block.indexOf("(");
|
|
754
|
-
const close = block.lastIndexOf(")");
|
|
755
|
-
if (open < 0 || close <= open)
|
|
756
|
-
return [];
|
|
757
|
-
const input = block.slice(open + 1, close);
|
|
758
|
-
const args = [];
|
|
759
|
-
let start = 0;
|
|
760
|
-
let depth = 0;
|
|
761
|
-
let quote = "";
|
|
762
|
-
let escaped = false;
|
|
763
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
764
|
-
const ch = input[i];
|
|
765
|
-
if (escaped) {
|
|
766
|
-
escaped = false;
|
|
767
|
-
continue;
|
|
768
|
-
}
|
|
769
|
-
if (ch === "\\") {
|
|
770
|
-
escaped = true;
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
|
-
if (quote) {
|
|
774
|
-
if (ch === quote)
|
|
775
|
-
quote = "";
|
|
776
|
-
continue;
|
|
777
|
-
}
|
|
778
|
-
if (ch === '"' || ch === "'") {
|
|
779
|
-
quote = ch;
|
|
780
|
-
continue;
|
|
781
|
-
}
|
|
782
|
-
if (ch === "[" || ch === "{" || ch === "(")
|
|
783
|
-
depth += 1;
|
|
784
|
-
else if (ch === "]" || ch === "}" || ch === ")")
|
|
785
|
-
depth -= 1;
|
|
786
|
-
else if (ch === "," && depth === 0) {
|
|
787
|
-
args.push(input.slice(start, i).trim());
|
|
788
|
-
start = i + 1;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
args.push(input.slice(start).trim());
|
|
792
|
-
return args.filter((arg) => arg && !/^(?:id|marks)\s*=/.test(arg));
|
|
793
|
-
})();
|
|
898
|
+
const topLevelArgs = extractPytestParamTopLevelArgs(block);
|
|
794
899
|
if (topLevelArgs.length > 0) {
|
|
795
900
|
const idTp = /\bid\s*=\s*["'](TP-[A-Z0-9-]+)["']/i.exec(block)?.[1]?.toUpperCase();
|
|
796
901
|
const meaningfulArgs = topLevelArgs.filter((arg) => {
|
|
@@ -844,7 +949,7 @@ export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
|
844
949
|
if (paramOpen) {
|
|
845
950
|
const afterOpen = block.slice((paramOpen.index ?? 0) + paramOpen[0].length);
|
|
846
951
|
const positionalTokens = [];
|
|
847
|
-
const tokenRe = /\s*(_OMIT|OMIT|MISSING|Ellipsis|\.\.\.|None|True|False|-?\d+(?:\.\d+)?|"""[\s\S]*?"""|\'\'\'[\s\S]*?\'\'\'|(?:["'][^"'\\]["']\s*\*\s*(?:\d{1,5}|[A-Za-z_][A-Za-z0-9_]*))|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_][A-Za-z0-9_]*)\s*(?:,|\)|$)/g;
|
|
952
|
+
const tokenRe = /\s*(_OMIT|_MISSING|OMIT|MISSING|Ellipsis|\.\.\.|None|True|False|-?\d+(?:\.\d+)?|"""[\s\S]*?"""|\'\'\'[\s\S]*?\'\'\'|(?:["'][^"'\\]["']\s*\*\s*(?:\d{1,5}|[A-Za-z_][A-Za-z0-9_]*))|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_][A-Za-z0-9_]*)\s*(?:,|\)|$)/g;
|
|
848
953
|
let match;
|
|
849
954
|
while ((match = tokenRe.exec(afterOpen)) !== null) {
|
|
850
955
|
const between = afterOpen.slice(0, match.index);
|
|
@@ -987,12 +1092,25 @@ function compareIntent(intent, observed, bound, example, field) {
|
|
|
987
1092
|
return "MATCH";
|
|
988
1093
|
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
989
1094
|
}
|
|
1095
|
+
case "max-1":
|
|
1096
|
+
if (bound === undefined)
|
|
1097
|
+
return "UNDETERMINED";
|
|
1098
|
+
{
|
|
1099
|
+
const expectedMax1 = Math.max(0, bound - 1);
|
|
1100
|
+
const len = observedLengthValue(observed);
|
|
1101
|
+
if (len === expectedMax1)
|
|
1102
|
+
return "MATCH";
|
|
1103
|
+
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
1104
|
+
}
|
|
990
1105
|
case "min":
|
|
991
1106
|
if (bound === undefined)
|
|
992
1107
|
return "UNDETERMINED";
|
|
993
1108
|
{
|
|
994
1109
|
if (isMinLengthHelper(observed))
|
|
995
1110
|
return "MATCH";
|
|
1111
|
+
// Optional min=0 may omit the key instead of sending "".
|
|
1112
|
+
if (bound === 0 && observed.kind === "missing-key")
|
|
1113
|
+
return "MATCH";
|
|
996
1114
|
const len = observedLengthValue(observed);
|
|
997
1115
|
if (len === bound)
|
|
998
1116
|
return "MATCH";
|
|
@@ -1095,7 +1213,11 @@ function compareIntent(intent, observed, bound, example, field) {
|
|
|
1095
1213
|
? "UNDETERMINED"
|
|
1096
1214
|
: "MISMATCH";
|
|
1097
1215
|
}
|
|
1098
|
-
|
|
1216
|
+
const comparableObserved = observed.kind === "boolean"
|
|
1217
|
+
? (observed.literal === "True" ? "true" : observed.literal === "False" ? "false" : literal)
|
|
1218
|
+
: literal;
|
|
1219
|
+
const comparableExpected = expected === "True" ? "true" : expected === "False" ? "false" : expected;
|
|
1220
|
+
return comparableObserved === comparableExpected
|
|
1099
1221
|
? "MATCH"
|
|
1100
1222
|
: observed.kind === "unknown"
|
|
1101
1223
|
? "UNDETERMINED"
|
|
@@ -1142,6 +1264,10 @@ function suggestedFixFor(intent, field, bound, example) {
|
|
|
1142
1264
|
return field && bound !== undefined
|
|
1143
1265
|
? `set ${field}="x"*${bound + 1}`
|
|
1144
1266
|
: undefined;
|
|
1267
|
+
case "max-1":
|
|
1268
|
+
return field && bound !== undefined
|
|
1269
|
+
? `set ${field}="x"*${Math.max(0, bound - 1)}`
|
|
1270
|
+
: undefined;
|
|
1145
1271
|
case "min":
|
|
1146
1272
|
return field && bound !== undefined
|
|
1147
1273
|
? `set ${field}="x"*${bound}`
|
|
@@ -1161,11 +1287,13 @@ function suggestedFixFor(intent, field, bound, example) {
|
|
|
1161
1287
|
: undefined;
|
|
1162
1288
|
default:
|
|
1163
1289
|
if (intent.startsWith("custom-literal:")) {
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1290
|
+
const expectedRaw = intent.slice("custom-literal:".length);
|
|
1291
|
+
const expected = normalizeCustomLiteralExpected(expectedRaw);
|
|
1292
|
+
if (isWhitespaceSemanticLiteral(expectedRaw) || isWhitespaceOnlyString(expected)) {
|
|
1293
|
+
const length = isWhitespaceOnlyString(expected) ? expected.length : 3;
|
|
1294
|
+
return field ? `set ${field} to ${length} literal spaces` : `set value to ${length} literal spaces`;
|
|
1167
1295
|
}
|
|
1168
|
-
if (isWhitespacePaddedSemanticLiteral(
|
|
1296
|
+
if (isWhitespacePaddedSemanticLiteral(expectedRaw)) {
|
|
1169
1297
|
return field
|
|
1170
1298
|
? `set ${field}=" ${field}-value "`
|
|
1171
1299
|
: 'set value=" value "';
|
|
@@ -1177,6 +1305,232 @@ function suggestedFixFor(intent, field, bound, example) {
|
|
|
1177
1305
|
return undefined;
|
|
1178
1306
|
}
|
|
1179
1307
|
}
|
|
1308
|
+
const MAX_PERSISTED_SCENARIO_TEXT = 192;
|
|
1309
|
+
function boundedScenarioText(value, logicalLength) {
|
|
1310
|
+
if (value.length <= MAX_PERSISTED_SCENARIO_TEXT)
|
|
1311
|
+
return value;
|
|
1312
|
+
const suffix = `<truncated length=${logicalLength ?? value.length}>`;
|
|
1313
|
+
return `${value.slice(0, Math.max(0, MAX_PERSISTED_SCENARIO_TEXT - suffix.length - 3))}...${suffix}`;
|
|
1314
|
+
}
|
|
1315
|
+
/** Facts schema forbids negative lengths. Internal helper sentinels stay in-memory only. */
|
|
1316
|
+
function persistedObservedLength(length) {
|
|
1317
|
+
return typeof length === "number" && Number.isFinite(length) && length >= 0
|
|
1318
|
+
? Math.trunc(length)
|
|
1319
|
+
: undefined;
|
|
1320
|
+
}
|
|
1321
|
+
function localPythonFunctionRegion(source, functionName) {
|
|
1322
|
+
const escaped = functionName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1323
|
+
const startMatch = new RegExp(`^def\\s+${escaped}\\s*\\(`, "m").exec(source);
|
|
1324
|
+
if (!startMatch || startMatch.index === undefined)
|
|
1325
|
+
return undefined;
|
|
1326
|
+
const start = startMatch.index;
|
|
1327
|
+
const remainder = source.slice(start + startMatch[0].length);
|
|
1328
|
+
const nextTopLevel = /^(?:def|class|@pytest\b|@(?:[A-Za-z_][A-Za-z0-9_.]*))\s*/m.exec(remainder);
|
|
1329
|
+
return source.slice(start, nextTopLevel?.index === undefined ? source.length : start + startMatch[0].length + nextTopLevel.index);
|
|
1330
|
+
}
|
|
1331
|
+
function splitPythonTopLevelArguments(input) {
|
|
1332
|
+
const args = [];
|
|
1333
|
+
let start = 0;
|
|
1334
|
+
let depth = 0;
|
|
1335
|
+
let quote = "";
|
|
1336
|
+
let escaped = false;
|
|
1337
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
1338
|
+
const ch = input[index];
|
|
1339
|
+
if (escaped) {
|
|
1340
|
+
escaped = false;
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
if (ch === "\\") {
|
|
1344
|
+
escaped = true;
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
if (quote) {
|
|
1348
|
+
if (ch === quote)
|
|
1349
|
+
quote = "";
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
if (ch === '"' || ch === "'") {
|
|
1353
|
+
quote = ch;
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
if (ch === "[" || ch === "{" || ch === "(")
|
|
1357
|
+
depth += 1;
|
|
1358
|
+
else if (ch === "]" || ch === "}" || ch === ")")
|
|
1359
|
+
depth -= 1;
|
|
1360
|
+
else if (ch === "," && depth === 0) {
|
|
1361
|
+
args.push(input.slice(start, index).trim());
|
|
1362
|
+
start = index + 1;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
args.push(input.slice(start).trim());
|
|
1366
|
+
return args.filter(Boolean);
|
|
1367
|
+
}
|
|
1368
|
+
function parseSimplePythonCall(expression) {
|
|
1369
|
+
const call = /^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/.exec(expression.trim());
|
|
1370
|
+
if (!call)
|
|
1371
|
+
return undefined;
|
|
1372
|
+
const positional = [];
|
|
1373
|
+
const keywords = new Map();
|
|
1374
|
+
for (const argument of splitPythonTopLevelArguments(call[2] ?? "")) {
|
|
1375
|
+
const keyword = /^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([\s\S]+)$/.exec(argument);
|
|
1376
|
+
if (keyword) {
|
|
1377
|
+
if (keywords.has(keyword[1]))
|
|
1378
|
+
return undefined;
|
|
1379
|
+
keywords.set(keyword[1], keyword[2].trim());
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
if (keywords.size > 0 || /^\*{1,2}/.test(argument))
|
|
1383
|
+
return undefined;
|
|
1384
|
+
positional.push(argument);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return { name: call[1], positional, keywords };
|
|
1388
|
+
}
|
|
1389
|
+
function safeSameModuleDictHelper(source, helperName) {
|
|
1390
|
+
if (!helperName.startsWith("_"))
|
|
1391
|
+
return undefined;
|
|
1392
|
+
const region = localPythonFunctionRegion(source, helperName);
|
|
1393
|
+
if (!region)
|
|
1394
|
+
return undefined;
|
|
1395
|
+
const functionBody = region.slice(region.indexOf(":") + 1);
|
|
1396
|
+
const escapedName = helperName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1397
|
+
if (new RegExp(`\\b${escapedName}\\s*\\(`).test(functionBody))
|
|
1398
|
+
return undefined;
|
|
1399
|
+
if (/\b(?:Faker|fake|random|randint|uuid4|environ|getenv|requests|httpx|urlopen|subprocess|Popen|socket|open)\b/i.test(region))
|
|
1400
|
+
return undefined;
|
|
1401
|
+
const signature = new RegExp(`^def\\s+${escapedName}\\s*\\(([\\s\\S]*?)\\)\\s*(?:->[^:]+)?\\s*:`, "m").exec(region);
|
|
1402
|
+
if (!signature)
|
|
1403
|
+
return undefined;
|
|
1404
|
+
const parameters = [];
|
|
1405
|
+
for (const rawParameter of splitPythonTopLevelArguments(signature[1] ?? "")) {
|
|
1406
|
+
if (rawParameter === "*" || rawParameter === "/")
|
|
1407
|
+
continue;
|
|
1408
|
+
if (/^\*{1,2}/.test(rawParameter))
|
|
1409
|
+
return undefined;
|
|
1410
|
+
const parameter = /^([A-Za-z_][A-Za-z0-9_]*)(?:\s*:[^=]+)?(?:\s*=\s*([\s\S]+))?$/.exec(rawParameter);
|
|
1411
|
+
if (!parameter)
|
|
1412
|
+
return undefined;
|
|
1413
|
+
parameters.push({ name: parameter[1], defaultExpression: parameter[2]?.trim() });
|
|
1414
|
+
}
|
|
1415
|
+
const directReturn = /\breturn\s*(\{[\s\S]*?\})/.exec(functionBody)?.[1];
|
|
1416
|
+
const assignment = /\b([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=\n]+)?=\s*(\{[\s\S]*?\})/.exec(functionBody);
|
|
1417
|
+
const assignedReturn = assignment && new RegExp(`\\breturn\\s+${assignment[1].replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`).test(functionBody)
|
|
1418
|
+
? assignment[2]
|
|
1419
|
+
: undefined;
|
|
1420
|
+
const dictExpression = directReturn ?? assignedReturn;
|
|
1421
|
+
if (!dictExpression)
|
|
1422
|
+
return undefined;
|
|
1423
|
+
const fieldBindings = new Map();
|
|
1424
|
+
for (const item of splitPythonTopLevelArguments(dictExpression.slice(1, -1))) {
|
|
1425
|
+
const binding = /^(?:["']([^"']+)["'])\s*:\s*([A-Za-z_][A-Za-z0-9_]*)$/.exec(item);
|
|
1426
|
+
if (!binding || !parameters.some((parameter) => parameter.name === binding[2]))
|
|
1427
|
+
return undefined;
|
|
1428
|
+
fieldBindings.set(binding[1], binding[2]);
|
|
1429
|
+
}
|
|
1430
|
+
return { parameters, fieldBindings };
|
|
1431
|
+
}
|
|
1432
|
+
function observeSameModulePayloadHelperField(input) {
|
|
1433
|
+
const payloadIndex = input.parameterNames.findIndex((name) => /^(?:payload|body|data|json)$/i.test(name));
|
|
1434
|
+
if (payloadIndex < 0)
|
|
1435
|
+
return undefined;
|
|
1436
|
+
let expression = extractPytestParamTopLevelArgs(input.block)[payloadIndex]?.trim() ?? "";
|
|
1437
|
+
const wrapper = parseSimplePythonCall(expression);
|
|
1438
|
+
if (wrapper?.name === "_without") {
|
|
1439
|
+
if (wrapper.positional.length !== 2 || wrapper.keywords.size > 0)
|
|
1440
|
+
return undefined;
|
|
1441
|
+
const removed = observeLiteralToken(wrapper.positional[1], input.field, input.constants);
|
|
1442
|
+
if (removed?.kind !== "string" || removed.literal !== input.field)
|
|
1443
|
+
return undefined;
|
|
1444
|
+
expression = wrapper.positional[0];
|
|
1445
|
+
const inner = parseSimplePythonCall(expression);
|
|
1446
|
+
if (!inner || !safeSameModuleDictHelper(input.source, inner.name))
|
|
1447
|
+
return undefined;
|
|
1448
|
+
return { kind: "missing-key", text: `missing:${input.field}` };
|
|
1449
|
+
}
|
|
1450
|
+
const call = parseSimplePythonCall(expression);
|
|
1451
|
+
if (!call)
|
|
1452
|
+
return undefined;
|
|
1453
|
+
const helper = safeSameModuleDictHelper(input.source, call.name);
|
|
1454
|
+
if (!helper)
|
|
1455
|
+
return undefined;
|
|
1456
|
+
const parameterName = helper.fieldBindings.get(input.field);
|
|
1457
|
+
if (!parameterName)
|
|
1458
|
+
return { kind: "missing-key", text: `missing:${input.field}` };
|
|
1459
|
+
const parameterIndex = helper.parameters.findIndex((parameter) => parameter.name === parameterName);
|
|
1460
|
+
if (parameterIndex < 0 || call.positional.length > helper.parameters.length)
|
|
1461
|
+
return undefined;
|
|
1462
|
+
const expressionForField = call.keywords.get(parameterName) ?? call.positional[parameterIndex] ?? helper.parameters[parameterIndex]?.defaultExpression;
|
|
1463
|
+
return expressionForField
|
|
1464
|
+
? observeLiteralToken(expressionForField, input.field, input.constants)
|
|
1465
|
+
: undefined;
|
|
1466
|
+
}
|
|
1467
|
+
function hasSafeSameModulePayloadHelper(source, block, parameterNames) {
|
|
1468
|
+
const payloadIndex = parameterNames.findIndex((name) => /^(?:payload|body|data|json)$/i.test(name));
|
|
1469
|
+
if (payloadIndex < 0)
|
|
1470
|
+
return false;
|
|
1471
|
+
const expression = extractPytestParamTopLevelArgs(block)[payloadIndex]?.trim() ?? "";
|
|
1472
|
+
const call = parseSimplePythonCall(expression);
|
|
1473
|
+
if (!call)
|
|
1474
|
+
return false;
|
|
1475
|
+
if (/\b(?:Faker|fake|random|randint|uuid4|environ|getenv|requests|httpx|urlopen|subprocess|Popen|socket|open)\b/i.test(expression))
|
|
1476
|
+
return false;
|
|
1477
|
+
return Boolean(safeSameModuleDictHelper(source, call.name));
|
|
1478
|
+
}
|
|
1479
|
+
function observeBranchPayloadField(input) {
|
|
1480
|
+
const region = scenarioFunctionRegion(input.source, input.tpId);
|
|
1481
|
+
if (!region || !input.block)
|
|
1482
|
+
return undefined;
|
|
1483
|
+
const args = extractPytestParamTopLevelArgs(input.block);
|
|
1484
|
+
const escapedField = input.field.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&");
|
|
1485
|
+
for (let index = 0; index < input.parameterNames.length; index += 1) {
|
|
1486
|
+
const parameter = input.parameterNames[index];
|
|
1487
|
+
const raw = args[index]?.trim();
|
|
1488
|
+
if (!raw || !/^['\"](?:[^'\"\\\\]|\\\\.)*['\"]$/.test(raw))
|
|
1489
|
+
continue;
|
|
1490
|
+
const branchValue = raw.slice(1, -1).replace(/\\\\([\\\"'])/g, "$1");
|
|
1491
|
+
const escapedParameter = parameter.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&");
|
|
1492
|
+
const escapedBranchValue = branchValue.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&");
|
|
1493
|
+
const branch = new RegExp(`(?:^|\\n)([ \\t]*)if\\s+${escapedParameter}\\s*==\\s*['\"]${escapedBranchValue}['\"]\\s*:\\s*([\\s\\S]*?)(?=\\n\\1(?:elif\\b|else\\s*:)|\\n\\1(?:if\\b|def\\b)|$)`, "m").exec(region)?.[2];
|
|
1494
|
+
if (!branch)
|
|
1495
|
+
continue;
|
|
1496
|
+
const value = new RegExp(`['\"]${escapedField}['\"]\\s*:\\s*([^,}\\n]+)`).exec(branch)?.[1];
|
|
1497
|
+
if (!value)
|
|
1498
|
+
continue;
|
|
1499
|
+
const observed = observeLiteralToken(value.trim(), input.field, input.constants);
|
|
1500
|
+
if (observed)
|
|
1501
|
+
return observed;
|
|
1502
|
+
}
|
|
1503
|
+
return undefined;
|
|
1504
|
+
}
|
|
1505
|
+
function observeDeterministicFunctionFieldOverride(input) {
|
|
1506
|
+
const region = scenarioFunctionRegion(input.source, input.tpId);
|
|
1507
|
+
if (!region)
|
|
1508
|
+
return undefined;
|
|
1509
|
+
const escapedField = input.field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1510
|
+
const assignment = new RegExp(`^([ \\t]*)([A-Za-z_][A-Za-z0-9_]*)\\s*\\[\\s*["']${escapedField}["']\\s*\\]\\s*=\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*$`, "m").exec(region);
|
|
1511
|
+
if (!assignment)
|
|
1512
|
+
return undefined;
|
|
1513
|
+
const indentation = assignment[1]?.length ?? 0;
|
|
1514
|
+
const valueParameter = assignment[3];
|
|
1515
|
+
const valueIndex = input.parameterNames.indexOf(valueParameter);
|
|
1516
|
+
if (valueIndex < 0)
|
|
1517
|
+
return undefined;
|
|
1518
|
+
const beforeAssignment = region.slice(0, assignment.index);
|
|
1519
|
+
const guardMatches = [...beforeAssignment.matchAll(/^([ \\t]*)if\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*$/gm)];
|
|
1520
|
+
const nearestGuard = guardMatches.at(-1);
|
|
1521
|
+
if (nearestGuard && (nearestGuard[1]?.length ?? 0) < indentation) {
|
|
1522
|
+
const guardIndex = input.parameterNames.indexOf(nearestGuard[2]);
|
|
1523
|
+
if (guardIndex < 0)
|
|
1524
|
+
return undefined;
|
|
1525
|
+
const guardExpression = extractPytestParamTopLevelArgs(input.block)[guardIndex]?.trim();
|
|
1526
|
+
if (guardExpression !== "True")
|
|
1527
|
+
return undefined;
|
|
1528
|
+
}
|
|
1529
|
+
const valueExpression = extractPytestParamTopLevelArgs(input.block)[valueIndex]?.trim();
|
|
1530
|
+
return valueExpression
|
|
1531
|
+
? observeLiteralToken(valueExpression, input.field, input.constants)
|
|
1532
|
+
: undefined;
|
|
1533
|
+
}
|
|
1180
1534
|
function scenarioFunctionRegion(source, tpId) {
|
|
1181
1535
|
const idIndex = source.indexOf(`id="${tpId}"`) >= 0
|
|
1182
1536
|
? source.indexOf(`id="${tpId}"`)
|
|
@@ -1202,6 +1556,44 @@ function hasCreateDeleteDerivedJourney(source, tpId) {
|
|
|
1202
1556
|
(/\b_create[A-Za-z0-9_]*\s*\(/.test(region) &&
|
|
1203
1557
|
(/\b_delete[A-Za-z0-9_]*\s*\(/.test(region) || /\.delete\s*\(/.test(region) || /\.request\s*\(\s*["']DELETE["']/i.test(region)));
|
|
1204
1558
|
}
|
|
1559
|
+
function hasConditionalFieldOmission(source, tpId, field, parameterNames) {
|
|
1560
|
+
if (!field)
|
|
1561
|
+
return false;
|
|
1562
|
+
const region = scenarioFunctionRegion(source, tpId);
|
|
1563
|
+
const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1564
|
+
const candidateNames = parameterNames.filter((name) => {
|
|
1565
|
+
const normalized = name.toLowerCase();
|
|
1566
|
+
const normalizedField = field.toLowerCase();
|
|
1567
|
+
return normalized === normalizedField || normalized.startsWith(`${normalizedField}_`) || normalized.endsWith(`_${normalizedField}`);
|
|
1568
|
+
});
|
|
1569
|
+
return candidateNames.some((name) => {
|
|
1570
|
+
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1571
|
+
return new RegExp(`\\{\\s*\\}\\s*if\\s+${escapedName}\\s+is\\s+None\\s+else\\s+\\{[\\s\\S]{0,200}?["']${escapedField}["']\\s*:\\s*${escapedName}\\b`).test(region) ||
|
|
1572
|
+
new RegExp(`\\{[\\s\\S]{0,200}?["']${escapedField}["']\\s*:\\s*${escapedName}\\b[\\s\\S]{0,200}?\\}\\s*if\\s+${escapedName}\\s+is\\s+not\\s+None\\s+else\\s+\\{\\s*\\}`).test(region) ||
|
|
1573
|
+
new RegExp(`if\\s+${escapedName}\\s+is\\s+not\\s+None\\s*:[\\s\\S]{0,200}?["']${escapedField}["']\\s*\\]\\s*=\\s*${escapedName}\\b`).test(region);
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
function scenarioParamSourceLocation(scriptPath, source, tpId) {
|
|
1577
|
+
const block = extractPytestParamBlock(source, tpId);
|
|
1578
|
+
if (!block)
|
|
1579
|
+
return undefined;
|
|
1580
|
+
const index = source.indexOf(block);
|
|
1581
|
+
if (index < 0)
|
|
1582
|
+
return undefined;
|
|
1583
|
+
return `${scriptPath}:${source.slice(0, index).split("\n").length}`;
|
|
1584
|
+
}
|
|
1585
|
+
function scenarioParamDiagnosticValues(intent, observed) {
|
|
1586
|
+
const expectedRaw = intent.startsWith("custom-literal:")
|
|
1587
|
+
? intent.slice("custom-literal:".length)
|
|
1588
|
+
: intent === "unknown" ? undefined : intent;
|
|
1589
|
+
const persistedLength = persistedObservedLength(observed.length);
|
|
1590
|
+
return {
|
|
1591
|
+
expectedRaw,
|
|
1592
|
+
observedRaw: boundedScenarioText(observed.text, persistedLength),
|
|
1593
|
+
expectedNormalized: expectedRaw === undefined ? undefined : normalizeCustomLiteralExpected(expectedRaw).slice(0, 512),
|
|
1594
|
+
observedNormalized: observed.literal === undefined ? undefined : boundedScenarioText(normalizeScenarioLiteralText(observed.literal), persistedLength),
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1205
1597
|
export async function assessBackendScenarioParamConsistency(input) {
|
|
1206
1598
|
const cases = await listMarkdownCases(input.workspaceRoot, input.layout);
|
|
1207
1599
|
const entries = [];
|
|
@@ -1223,7 +1615,29 @@ export async function assessBackendScenarioParamConsistency(input) {
|
|
|
1223
1615
|
const constants = source ? collectPythonStringConstants(source) : undefined;
|
|
1224
1616
|
const block = source ? extractPytestParamBlock(source, tpId) : undefined;
|
|
1225
1617
|
const parameterNames = source ? extractPytestParamParameterNames(source, tpId) : [];
|
|
1226
|
-
const
|
|
1618
|
+
const functionFieldOverride = source && inferred.field
|
|
1619
|
+
? observeDeterministicFunctionFieldOverride({
|
|
1620
|
+
source,
|
|
1621
|
+
tpId,
|
|
1622
|
+
block,
|
|
1623
|
+
parameterNames,
|
|
1624
|
+
field: inferred.field,
|
|
1625
|
+
constants,
|
|
1626
|
+
})
|
|
1627
|
+
: undefined;
|
|
1628
|
+
const helperFieldObserved = source && inferred.field
|
|
1629
|
+
? observeSameModulePayloadHelperField({
|
|
1630
|
+
source,
|
|
1631
|
+
block,
|
|
1632
|
+
parameterNames,
|
|
1633
|
+
field: inferred.field,
|
|
1634
|
+
constants,
|
|
1635
|
+
})
|
|
1636
|
+
: undefined;
|
|
1637
|
+
const branchFieldObserved = source && inferred.field
|
|
1638
|
+
? observeBranchPayloadField({ source, tpId, block, parameterNames, field: inferred.field, constants })
|
|
1639
|
+
: undefined;
|
|
1640
|
+
const observed = functionFieldOverride ?? helperFieldObserved ?? branchFieldObserved ?? observeParamFeatures(block, inferred.field, constants, parameterNames);
|
|
1227
1641
|
// Request-level / health checks often have no pytest.param payload row,
|
|
1228
1642
|
// or only a TP-id label positional (no field value).
|
|
1229
1643
|
const requestLevelNoParam = Boolean(source) &&
|
|
@@ -1242,9 +1656,17 @@ export async function assessBackendScenarioParamConsistency(input) {
|
|
|
1242
1656
|
hasCreateDeleteDerivedJourney(source, tpId)) ||
|
|
1243
1657
|
(/^custom-literal:(?:create-derived(?:-active-id|-id)?|active-existing-derived)$/i.test(inferred.intent) &&
|
|
1244
1658
|
hasCreateDerivedJourney(source, tpId)));
|
|
1659
|
+
const conditionalOmissionMatch = Boolean(source) &&
|
|
1660
|
+
inferred.intent === "missing" &&
|
|
1661
|
+
observed.kind === "none" &&
|
|
1662
|
+
hasConditionalFieldOmission(source, tpId, inferred.field, parameterNames);
|
|
1663
|
+
const localPayloadHelperMatch = Boolean(source) &&
|
|
1664
|
+
inferred.intent === "nominal" &&
|
|
1665
|
+
!inferred.field &&
|
|
1666
|
+
hasSafeSameModulePayloadHelper(source, block, parameterNames);
|
|
1245
1667
|
const status = !source
|
|
1246
1668
|
? "UNDETERMINED"
|
|
1247
|
-
: derivedJourneyMatch
|
|
1669
|
+
: derivedJourneyMatch || conditionalOmissionMatch || localPayloadHelperMatch
|
|
1248
1670
|
? "MATCH"
|
|
1249
1671
|
: requestLevelNoParam
|
|
1250
1672
|
? "MATCH"
|
|
@@ -1252,14 +1674,19 @@ export async function assessBackendScenarioParamConsistency(input) {
|
|
|
1252
1674
|
? "UNDETERMINED"
|
|
1253
1675
|
: compareIntent(inferred.intent, observed, inferred.bound, inferred.example, inferred.field);
|
|
1254
1676
|
const repairability = repairabilityFor(status, inferred.intent, observed, inferred.example);
|
|
1677
|
+
const diagnostics = scenarioParamDiagnosticValues(inferred.intent, observed);
|
|
1255
1678
|
entries.push({
|
|
1256
1679
|
caseId: testCase.caseId,
|
|
1257
1680
|
tpId,
|
|
1258
1681
|
field: inferred.field,
|
|
1259
1682
|
intent: inferred.intent,
|
|
1260
|
-
observed: observed.text,
|
|
1683
|
+
observed: boundedScenarioText(observed.text, persistedObservedLength(observed.length)),
|
|
1684
|
+
observedLength: persistedObservedLength(observed.length),
|
|
1261
1685
|
status,
|
|
1262
1686
|
repairability,
|
|
1687
|
+
reasonCode: status === "MATCH" ? "SCENARIO_PARAM_MATCH" : status === "MISMATCH" ? "SCENARIO_PARAM_MISMATCH" : "SCENARIO_PARAM_UNDETERMINED",
|
|
1688
|
+
...diagnostics,
|
|
1689
|
+
sourceLocation: source ? scenarioParamSourceLocation(testCase.scriptPath, source, tpId) : undefined,
|
|
1263
1690
|
suggestedFix: fallbackSourced
|
|
1264
1691
|
? undefined
|
|
1265
1692
|
: suggestedFixFor(inferred.intent, inferred.field, inferred.bound, inferred.example),
|
|
@@ -1423,6 +1850,12 @@ export function deterministicRewriteScenarioParam(input) {
|
|
|
1423
1850
|
}
|
|
1424
1851
|
valueLiteral = `"x" * ${bound + 1}`;
|
|
1425
1852
|
break;
|
|
1853
|
+
case "max-1":
|
|
1854
|
+
if (bound === undefined) {
|
|
1855
|
+
return { ok: false, source: input.source, detail: "missing bound for max-1" };
|
|
1856
|
+
}
|
|
1857
|
+
valueLiteral = `"x" * ${Math.max(0, bound - 1)}`;
|
|
1858
|
+
break;
|
|
1426
1859
|
case "min-1":
|
|
1427
1860
|
if (bound === undefined) {
|
|
1428
1861
|
return { ok: false, source: input.source, detail: "missing bound for min-1" };
|