@bf-meishijian/aip 0.0.41 → 0.0.43
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/dist/apps/local-coding-host/src/bash-discovery.d.ts +8 -0
- package/dist/apps/local-coding-host/src/bash-discovery.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/bash-discovery.js +66 -0
- package/dist/apps/local-coding-host/src/bash-discovery.js.map +1 -0
- package/dist/apps/local-coding-host/src/cli.d.ts +4 -0
- package/dist/apps/local-coding-host/src/cli.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/cli.js +388 -0
- package/dist/apps/local-coding-host/src/cli.js.map +1 -0
- package/dist/apps/local-coding-host/src/coding-run-manager.d.ts +174 -0
- package/dist/apps/local-coding-host/src/coding-run-manager.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/coding-run-manager.js +1587 -0
- package/dist/apps/local-coding-host/src/coding-run-manager.js.map +1 -0
- package/dist/apps/local-coding-host/src/coding-subagent-child.d.ts +22 -0
- package/dist/apps/local-coding-host/src/coding-subagent-child.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/coding-subagent-child.js +96 -0
- package/dist/apps/local-coding-host/src/coding-subagent-child.js.map +1 -0
- package/dist/apps/local-coding-host/src/coding-subagents.d.ts +65 -0
- package/dist/apps/local-coding-host/src/coding-subagents.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/coding-subagents.js +521 -0
- package/dist/apps/local-coding-host/src/coding-subagents.js.map +1 -0
- package/dist/apps/local-coding-host/src/command-executor.d.ts +9 -0
- package/dist/apps/local-coding-host/src/command-executor.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/command-executor.js +222 -0
- package/dist/apps/local-coding-host/src/command-executor.js.map +1 -0
- package/dist/apps/local-coding-host/src/command-wakeup.d.ts +19 -0
- package/dist/apps/local-coding-host/src/command-wakeup.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/command-wakeup.js +109 -0
- package/dist/apps/local-coding-host/src/command-wakeup.js.map +1 -0
- package/dist/apps/local-coding-host/src/daemon.d.ts +8 -0
- package/dist/apps/local-coding-host/src/daemon.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/daemon.js +314 -0
- package/dist/apps/local-coding-host/src/daemon.js.map +1 -0
- package/dist/apps/local-coding-host/src/delivery-files.d.ts +39 -0
- package/dist/apps/local-coding-host/src/delivery-files.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/delivery-files.js +237 -0
- package/dist/apps/local-coding-host/src/delivery-files.js.map +1 -0
- package/dist/apps/local-coding-host/src/delivery-tools.d.ts +30 -0
- package/dist/apps/local-coding-host/src/delivery-tools.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/delivery-tools.js +196 -0
- package/dist/apps/local-coding-host/src/delivery-tools.js.map +1 -0
- package/dist/apps/local-coding-host/src/diagnostic-log.d.ts +20 -0
- package/dist/apps/local-coding-host/src/diagnostic-log.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/diagnostic-log.js +61 -0
- package/dist/apps/local-coding-host/src/diagnostic-log.js.map +1 -0
- package/dist/apps/local-coding-host/src/diagnostics.d.ts +38 -0
- package/dist/apps/local-coding-host/src/diagnostics.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/diagnostics.js +217 -0
- package/dist/apps/local-coding-host/src/diagnostics.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process-observer.d.ts +19 -0
- package/dist/apps/local-coding-host/src/execution-process-observer.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process-observer.js +35 -0
- package/dist/apps/local-coding-host/src/execution-process-observer.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process-tree.d.ts +32 -0
- package/dist/apps/local-coding-host/src/execution-process-tree.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process-tree.js +288 -0
- package/dist/apps/local-coding-host/src/execution-process-tree.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process.d.ts +59 -0
- package/dist/apps/local-coding-host/src/execution-process.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-process.js +112 -0
- package/dist/apps/local-coding-host/src/execution-process.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-receipts.d.ts +12 -0
- package/dist/apps/local-coding-host/src/execution-receipts.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-receipts.js +89 -0
- package/dist/apps/local-coding-host/src/execution-receipts.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-supervisor.d.ts +25 -0
- package/dist/apps/local-coding-host/src/execution-supervisor.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-supervisor.js +482 -0
- package/dist/apps/local-coding-host/src/execution-supervisor.js.map +1 -0
- package/dist/apps/local-coding-host/src/execution-worker.d.ts +42 -0
- package/dist/apps/local-coding-host/src/execution-worker.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/execution-worker.js +165 -0
- package/dist/apps/local-coding-host/src/execution-worker.js.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-client.d.ts +111 -0
- package/dist/apps/local-coding-host/src/general-run-client.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-client.js +41 -0
- package/dist/apps/local-coding-host/src/general-run-client.js.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-manager.d.ts +33 -0
- package/dist/apps/local-coding-host/src/general-run-manager.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-manager.js +363 -0
- package/dist/apps/local-coding-host/src/general-run-manager.js.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-supervisor.d.ts +12 -0
- package/dist/apps/local-coding-host/src/general-run-supervisor.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-supervisor.js +160 -0
- package/dist/apps/local-coding-host/src/general-run-supervisor.js.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-tools.d.ts +25 -0
- package/dist/apps/local-coding-host/src/general-run-tools.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/general-run-tools.js +123 -0
- package/dist/apps/local-coding-host/src/general-run-tools.js.map +1 -0
- package/dist/apps/local-coding-host/src/git-credential-environment.d.ts +3 -0
- package/dist/apps/local-coding-host/src/git-credential-environment.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/git-credential-environment.js +46 -0
- package/dist/apps/local-coding-host/src/git-credential-environment.js.map +1 -0
- package/dist/apps/local-coding-host/src/git-credential-helper.d.ts +2 -0
- package/dist/apps/local-coding-host/src/git-credential-helper.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/git-credential-helper.js +38 -0
- package/dist/apps/local-coding-host/src/git-credential-helper.js.map +1 -0
- package/dist/apps/local-coding-host/src/git-http-migration.d.ts +24 -0
- package/dist/apps/local-coding-host/src/git-http-migration.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/git-http-migration.js +197 -0
- package/dist/apps/local-coding-host/src/git-http-migration.js.map +1 -0
- package/dist/apps/local-coding-host/src/git-process.d.ts +25 -0
- package/dist/apps/local-coding-host/src/git-process.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/git-process.js +85 -0
- package/dist/apps/local-coding-host/src/git-process.js.map +1 -0
- package/dist/apps/local-coding-host/src/git-transport.d.ts +6 -0
- package/dist/apps/local-coding-host/src/git-transport.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/git-transport.js +57 -0
- package/dist/apps/local-coding-host/src/git-transport.js.map +1 -0
- package/dist/apps/local-coding-host/src/gitlab-cli.d.ts +2 -0
- package/dist/apps/local-coding-host/src/gitlab-cli.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/gitlab-cli.js +39 -0
- package/dist/apps/local-coding-host/src/gitlab-cli.js.map +1 -0
- package/dist/apps/local-coding-host/src/gitlab-credentials.d.ts +18 -0
- package/dist/apps/local-coding-host/src/gitlab-credentials.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/gitlab-credentials.js +137 -0
- package/dist/apps/local-coding-host/src/gitlab-credentials.js.map +1 -0
- package/dist/apps/local-coding-host/src/handoff-cli.d.ts +2 -0
- package/dist/apps/local-coding-host/src/handoff-cli.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/handoff-cli.js +86 -0
- package/dist/apps/local-coding-host/src/handoff-cli.js.map +1 -0
- package/dist/apps/local-coding-host/src/harness.d.ts +2 -0
- package/dist/apps/local-coding-host/src/harness.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/harness.js +2 -0
- package/dist/apps/local-coding-host/src/harness.js.map +1 -0
- package/dist/apps/local-coding-host/src/host-log.d.ts +13 -0
- package/dist/apps/local-coding-host/src/host-log.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/host-log.js +43 -0
- package/dist/apps/local-coding-host/src/host-log.js.map +1 -0
- package/dist/apps/local-coding-host/src/host-shell.d.ts +2 -0
- package/dist/apps/local-coding-host/src/host-shell.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/host-shell.js +2 -0
- package/dist/apps/local-coding-host/src/host-shell.js.map +1 -0
- package/dist/apps/local-coding-host/src/host-status.d.ts +57 -0
- package/dist/apps/local-coding-host/src/host-status.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/host-status.js +144 -0
- package/dist/apps/local-coding-host/src/host-status.js.map +1 -0
- package/dist/apps/local-coding-host/src/host-tools.d.ts +15 -0
- package/dist/apps/local-coding-host/src/host-tools.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/host-tools.js +178 -0
- package/dist/apps/local-coding-host/src/host-tools.js.map +1 -0
- package/dist/apps/local-coding-host/src/host-update.d.ts +3 -0
- package/dist/apps/local-coding-host/src/host-update.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/host-update.js +95 -0
- package/dist/apps/local-coding-host/src/host-update.js.map +1 -0
- package/dist/apps/local-coding-host/src/installer.d.ts +28 -0
- package/dist/apps/local-coding-host/src/installer.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/installer.js +346 -0
- package/dist/apps/local-coding-host/src/installer.js.map +1 -0
- package/dist/apps/local-coding-host/src/linux-service.d.ts +14 -0
- package/dist/apps/local-coding-host/src/linux-service.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/linux-service.js +63 -0
- package/dist/apps/local-coding-host/src/linux-service.js.map +1 -0
- package/dist/apps/local-coding-host/src/live-employee.d.ts +17 -0
- package/dist/apps/local-coding-host/src/live-employee.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/live-employee.js +74 -0
- package/dist/apps/local-coding-host/src/live-employee.js.map +1 -0
- package/dist/apps/local-coding-host/src/local-employee-runtime.d.ts +30 -0
- package/dist/apps/local-coding-host/src/local-employee-runtime.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/local-employee-runtime.js +521 -0
- package/dist/apps/local-coding-host/src/local-employee-runtime.js.map +1 -0
- package/dist/apps/local-coding-host/src/local-handoff-workspace.d.ts +27 -0
- package/dist/apps/local-coding-host/src/local-handoff-workspace.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/local-handoff-workspace.js +71 -0
- package/dist/apps/local-coding-host/src/local-handoff-workspace.js.map +1 -0
- package/dist/apps/local-coding-host/src/local-mcp.d.ts +246 -0
- package/dist/apps/local-coding-host/src/local-mcp.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/local-mcp.js +173 -0
- package/dist/apps/local-coding-host/src/local-mcp.js.map +1 -0
- package/dist/apps/local-coding-host/src/local-model-usage.d.ts +6 -0
- package/dist/apps/local-coding-host/src/local-model-usage.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/local-model-usage.js +40 -0
- package/dist/apps/local-coding-host/src/local-model-usage.js.map +1 -0
- package/dist/apps/local-coding-host/src/login-url.d.ts +3 -0
- package/dist/apps/local-coding-host/src/login-url.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/login-url.js +30 -0
- package/dist/apps/local-coding-host/src/login-url.js.map +1 -0
- package/dist/apps/local-coding-host/src/managed-process.d.ts +21 -0
- package/dist/apps/local-coding-host/src/managed-process.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/managed-process.js +119 -0
- package/dist/apps/local-coding-host/src/managed-process.js.map +1 -0
- package/dist/apps/local-coding-host/src/merge-requests.d.ts +54 -0
- package/dist/apps/local-coding-host/src/merge-requests.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/merge-requests.js +230 -0
- package/dist/apps/local-coding-host/src/merge-requests.js.map +1 -0
- package/dist/apps/local-coding-host/src/model-stores.d.ts +20 -0
- package/dist/apps/local-coding-host/src/model-stores.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/model-stores.js +77 -0
- package/dist/apps/local-coding-host/src/model-stores.js.map +1 -0
- package/dist/apps/local-coding-host/src/open-browser.d.ts +2 -0
- package/dist/apps/local-coding-host/src/open-browser.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/open-browser.js +20 -0
- package/dist/apps/local-coding-host/src/open-browser.js.map +1 -0
- package/dist/apps/local-coding-host/src/operation-context.d.ts +31 -0
- package/dist/apps/local-coding-host/src/operation-context.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/operation-context.js +166 -0
- package/dist/apps/local-coding-host/src/operation-context.js.map +1 -0
- package/dist/apps/local-coding-host/src/outcome-cli.d.ts +3 -0
- package/dist/apps/local-coding-host/src/outcome-cli.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/outcome-cli.js +91 -0
- package/dist/apps/local-coding-host/src/outcome-cli.js.map +1 -0
- package/dist/apps/local-coding-host/src/paths.d.ts +30 -0
- package/dist/apps/local-coding-host/src/paths.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/paths.js +52 -0
- package/dist/apps/local-coding-host/src/paths.js.map +1 -0
- package/dist/apps/local-coding-host/src/pi-message-queue.d.ts +20 -0
- package/dist/apps/local-coding-host/src/pi-message-queue.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/pi-message-queue.js +78 -0
- package/dist/apps/local-coding-host/src/pi-message-queue.js.map +1 -0
- package/dist/apps/local-coding-host/src/pi-model-service.d.ts +91 -0
- package/dist/apps/local-coding-host/src/pi-model-service.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/pi-model-service.js +372 -0
- package/dist/apps/local-coding-host/src/pi-model-service.js.map +1 -0
- package/dist/apps/local-coding-host/src/platform-client.d.ts +398 -0
- package/dist/apps/local-coding-host/src/platform-client.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/platform-client.js +255 -0
- package/dist/apps/local-coding-host/src/platform-client.js.map +1 -0
- package/dist/apps/local-coding-host/src/platform-gitlab-credential.d.ts +8 -0
- package/dist/apps/local-coding-host/src/platform-gitlab-credential.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/platform-gitlab-credential.js +31 -0
- package/dist/apps/local-coding-host/src/platform-gitlab-credential.js.map +1 -0
- package/dist/apps/local-coding-host/src/platform.d.ts +2 -0
- package/dist/apps/local-coding-host/src/platform.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/platform.js +15 -0
- package/dist/apps/local-coding-host/src/platform.js.map +1 -0
- package/dist/apps/local-coding-host/src/profile.d.ts +9 -0
- package/dist/apps/local-coding-host/src/profile.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/profile.js +43 -0
- package/dist/apps/local-coding-host/src/profile.js.map +1 -0
- package/dist/apps/local-coding-host/src/project-facts.d.ts +20 -0
- package/dist/apps/local-coding-host/src/project-facts.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/project-facts.js +94 -0
- package/dist/apps/local-coding-host/src/project-facts.js.map +1 -0
- package/dist/apps/local-coding-host/src/provider-auth-error.d.ts +3 -0
- package/dist/apps/local-coding-host/src/provider-auth-error.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/provider-auth-error.js +12 -0
- package/dist/apps/local-coding-host/src/provider-auth-error.js.map +1 -0
- package/dist/apps/local-coding-host/src/qa-contract.d.ts +2 -0
- package/dist/apps/local-coding-host/src/qa-contract.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/qa-contract.js +3 -0
- package/dist/apps/local-coding-host/src/qa-contract.js.map +1 -0
- package/dist/apps/local-coding-host/src/qa-project-checkout.d.ts +16 -0
- package/dist/apps/local-coding-host/src/qa-project-checkout.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/qa-project-checkout.js +92 -0
- package/dist/apps/local-coding-host/src/qa-project-checkout.js.map +1 -0
- package/dist/apps/local-coding-host/src/qa-session-manager.d.ts +83 -0
- package/dist/apps/local-coding-host/src/qa-session-manager.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/qa-session-manager.js +782 -0
- package/dist/apps/local-coding-host/src/qa-session-manager.js.map +1 -0
- package/dist/apps/local-coding-host/src/run-resources.d.ts +17 -0
- package/dist/apps/local-coding-host/src/run-resources.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/run-resources.js +115 -0
- package/dist/apps/local-coding-host/src/run-resources.js.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-cleanup.d.ts +5 -0
- package/dist/apps/local-coding-host/src/runtime-cleanup.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-cleanup.js +187 -0
- package/dist/apps/local-coding-host/src/runtime-cleanup.js.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-environment.d.ts +2 -0
- package/dist/apps/local-coding-host/src/runtime-environment.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-environment.js +7 -0
- package/dist/apps/local-coding-host/src/runtime-environment.js.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-search-tools.d.ts +3 -0
- package/dist/apps/local-coding-host/src/runtime-search-tools.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/runtime-search-tools.js +30 -0
- package/dist/apps/local-coding-host/src/runtime-search-tools.js.map +1 -0
- package/dist/apps/local-coding-host/src/secure-json.d.ts +12 -0
- package/dist/apps/local-coding-host/src/secure-json.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/secure-json.js +129 -0
- package/dist/apps/local-coding-host/src/secure-json.js.map +1 -0
- package/dist/apps/local-coding-host/src/self-check.d.ts +3 -0
- package/dist/apps/local-coding-host/src/self-check.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/self-check.js +9 -0
- package/dist/apps/local-coding-host/src/self-check.js.map +1 -0
- package/dist/apps/local-coding-host/src/skill-bundle-cache.d.ts +11 -0
- package/dist/apps/local-coding-host/src/skill-bundle-cache.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/skill-bundle-cache.js +76 -0
- package/dist/apps/local-coding-host/src/skill-bundle-cache.js.map +1 -0
- package/dist/apps/local-coding-host/src/skill-storage.d.ts +18 -0
- package/dist/apps/local-coding-host/src/skill-storage.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/skill-storage.js +287 -0
- package/dist/apps/local-coding-host/src/skill-storage.js.map +1 -0
- package/dist/apps/local-coding-host/src/stage-delivery.d.ts +2 -0
- package/dist/apps/local-coding-host/src/stage-delivery.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/stage-delivery.js +3 -0
- package/dist/apps/local-coding-host/src/stage-delivery.js.map +1 -0
- package/dist/apps/local-coding-host/src/state.d.ts +55 -0
- package/dist/apps/local-coding-host/src/state.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/state.js +151 -0
- package/dist/apps/local-coding-host/src/state.js.map +1 -0
- package/dist/apps/local-coding-host/src/storage-maintenance.d.ts +13 -0
- package/dist/apps/local-coding-host/src/storage-maintenance.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/storage-maintenance.js +62 -0
- package/dist/apps/local-coding-host/src/storage-maintenance.js.map +1 -0
- package/dist/apps/local-coding-host/src/test-cli.d.ts +2 -0
- package/dist/apps/local-coding-host/src/test-cli.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/test-cli.js +48 -0
- package/dist/apps/local-coding-host/src/test-cli.js.map +1 -0
- package/dist/apps/local-coding-host/src/test-executor.d.ts +41 -0
- package/dist/apps/local-coding-host/src/test-executor.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/test-executor.js +483 -0
- package/dist/apps/local-coding-host/src/test-executor.js.map +1 -0
- package/dist/apps/local-coding-host/src/test-reports.d.ts +25 -0
- package/dist/apps/local-coding-host/src/test-reports.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/test-reports.js +129 -0
- package/dist/apps/local-coding-host/src/test-reports.js.map +1 -0
- package/dist/apps/local-coding-host/src/test-run-manager.d.ts +34 -0
- package/dist/apps/local-coding-host/src/test-run-manager.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/test-run-manager.js +180 -0
- package/dist/apps/local-coding-host/src/test-run-manager.js.map +1 -0
- package/dist/apps/local-coding-host/src/tool-dispatch.d.ts +14 -0
- package/dist/apps/local-coding-host/src/tool-dispatch.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/tool-dispatch.js +59 -0
- package/dist/apps/local-coding-host/src/tool-dispatch.js.map +1 -0
- package/dist/apps/local-coding-host/src/tool-probe.d.ts +31 -0
- package/dist/apps/local-coding-host/src/tool-probe.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/tool-probe.js +95 -0
- package/dist/apps/local-coding-host/src/tool-probe.js.map +1 -0
- package/dist/apps/local-coding-host/src/windows-runtime.d.ts +9 -0
- package/dist/apps/local-coding-host/src/windows-runtime.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/windows-runtime.js +64 -0
- package/dist/apps/local-coding-host/src/windows-runtime.js.map +1 -0
- package/dist/apps/local-coding-host/src/windows-service.d.ts +22 -0
- package/dist/apps/local-coding-host/src/windows-service.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/windows-service.js +126 -0
- package/dist/apps/local-coding-host/src/windows-service.js.map +1 -0
- package/dist/apps/local-coding-host/src/workflow-guidance.d.ts +2 -0
- package/dist/apps/local-coding-host/src/workflow-guidance.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/workflow-guidance.js +3 -0
- package/dist/apps/local-coding-host/src/workflow-guidance.js.map +1 -0
- package/dist/apps/local-coding-host/src/workspace-diff.d.ts +6 -0
- package/dist/apps/local-coding-host/src/workspace-diff.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/workspace-diff.js +280 -0
- package/dist/apps/local-coding-host/src/workspace-diff.js.map +1 -0
- package/dist/apps/local-coding-host/src/workspace-gc.d.ts +25 -0
- package/dist/apps/local-coding-host/src/workspace-gc.d.ts.map +1 -0
- package/dist/apps/local-coding-host/src/workspace-gc.js +417 -0
- package/dist/apps/local-coding-host/src/workspace-gc.js.map +1 -0
- package/dist/apps/local-coding-host/tests/bash-discovery.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/bash-discovery.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/bash-discovery.test.js +36 -0
- package/dist/apps/local-coding-host/tests/bash-discovery.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/cli-startup.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/cli-startup.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/cli-startup.test.js +176 -0
- package/dist/apps/local-coding-host/tests/cli-startup.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-run-manager.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/coding-run-manager.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-run-manager.test.js +3211 -0
- package/dist/apps/local-coding-host/tests/coding-run-manager.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-subagent-child.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/coding-subagent-child.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-subagent-child.test.js +223 -0
- package/dist/apps/local-coding-host/tests/coding-subagent-child.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.js +390 -0
- package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/command-wakeup.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/command-wakeup.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/command-wakeup.test.js +148 -0
- package/dist/apps/local-coding-host/tests/command-wakeup.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/daemon-wakeup.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/daemon-wakeup.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/daemon-wakeup.test.js +636 -0
- package/dist/apps/local-coding-host/tests/daemon-wakeup.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/database-tool-transport.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/database-tool-transport.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/database-tool-transport.test.js +37 -0
- package/dist/apps/local-coding-host/tests/database-tool-transport.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/delivery-files.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/delivery-files.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/delivery-files.test.js +655 -0
- package/dist/apps/local-coding-host/tests/delivery-files.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.js +116 -0
- package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/diagnostic-logging.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/diagnostic-logging.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/diagnostic-logging.test.js +143 -0
- package/dist/apps/local-coding-host/tests/diagnostic-logging.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-process.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/execution-process.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-process.test.js +127 -0
- package/dist/apps/local-coding-host/tests/execution-process.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-receipts.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/execution-receipts.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-receipts.test.js +72 -0
- package/dist/apps/local-coding-host/tests/execution-receipts.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-supervisor.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/execution-supervisor.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/execution-supervisor.test.js +488 -0
- package/dist/apps/local-coding-host/tests/execution-supervisor.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/general-employee-fixture.d.ts +3 -0
- package/dist/apps/local-coding-host/tests/general-employee-fixture.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/general-employee-fixture.js +43 -0
- package/dist/apps/local-coding-host/tests/general-employee-fixture.js.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-manager.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/general-run-manager.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-manager.test.js +506 -0
- package/dist/apps/local-coding-host/tests/general-run-manager.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-supervisor.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/general-run-supervisor.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-supervisor.test.js +252 -0
- package/dist/apps/local-coding-host/tests/general-run-supervisor.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-tools.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/general-run-tools.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run-tools.test.js +202 -0
- package/dist/apps/local-coding-host/tests/general-run-tools.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run.integration.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/general-run.integration.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/general-run.integration.test.js +150 -0
- package/dist/apps/local-coding-host/tests/general-run.integration.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/git-http-migration.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/git-http-migration.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/git-http-migration.test.js +140 -0
- package/dist/apps/local-coding-host/tests/git-http-migration.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/git-process.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/git-process.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/git-process.test.js +106 -0
- package/dist/apps/local-coding-host/tests/git-process.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/git-transport.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/git-transport.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/git-transport.test.js +56 -0
- package/dist/apps/local-coding-host/tests/git-transport.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/gitlab-credentials.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/gitlab-credentials.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/gitlab-credentials.test.js +130 -0
- package/dist/apps/local-coding-host/tests/gitlab-credentials.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.js +273 -0
- package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-log.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-log.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-log.test.js +51 -0
- package/dist/apps/local-coding-host/tests/host-log.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-status-workspace.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-status-workspace.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-status-workspace.test.js +256 -0
- package/dist/apps/local-coding-host/tests/host-status-workspace.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tool-stages.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-tool-stages.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tool-stages.test.js +82 -0
- package/dist/apps/local-coding-host/tests/host-tool-stages.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tools-logging.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-tools-logging.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tools-logging.test.js +110 -0
- package/dist/apps/local-coding-host/tests/host-tools-logging.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tools.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-tools.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-tools.test.js +96 -0
- package/dist/apps/local-coding-host/tests/host-tools.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/host-update.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/host-update.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/host-update.test.js +102 -0
- package/dist/apps/local-coding-host/tests/host-update.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/install-scripts.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/install-scripts.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/install-scripts.test.js +80 -0
- package/dist/apps/local-coding-host/tests/install-scripts.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/linux-service.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/linux-service.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/linux-service.test.js +32 -0
- package/dist/apps/local-coding-host/tests/linux-service.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/live-employee.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/live-employee.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/live-employee.test.js +739 -0
- package/dist/apps/local-coding-host/tests/live-employee.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.js +33 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.js +67 -0
- package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-host.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-host.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-host.test.js +1009 -0
- package/dist/apps/local-coding-host/tests/local-host.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-intake-recovery.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-intake-recovery.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-intake-recovery.test.js +71 -0
- package/dist/apps/local-coding-host/tests/local-intake-recovery.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-mcp.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-mcp.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-mcp.test.js +193 -0
- package/dist/apps/local-coding-host/tests/local-mcp.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-model-usage.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-model-usage.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-model-usage.test.js +55 -0
- package/dist/apps/local-coding-host/tests/local-model-usage.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.js +87 -0
- package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/login-url.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/login-url.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/login-url.test.js +82 -0
- package/dist/apps/local-coding-host/tests/login-url.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/material-fixture.d.ts +13 -0
- package/dist/apps/local-coding-host/tests/material-fixture.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/material-fixture.js +32 -0
- package/dist/apps/local-coding-host/tests/material-fixture.js.map +1 -0
- package/dist/apps/local-coding-host/tests/merge-requests.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/merge-requests.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/merge-requests.test.js +318 -0
- package/dist/apps/local-coding-host/tests/merge-requests.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/model-stores.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/model-stores.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/model-stores.test.js +152 -0
- package/dist/apps/local-coding-host/tests/model-stores.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/operation-context.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/operation-context.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/operation-context.test.js +171 -0
- package/dist/apps/local-coding-host/tests/operation-context.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/outcome-cli.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/outcome-cli.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/outcome-cli.test.js +208 -0
- package/dist/apps/local-coding-host/tests/outcome-cli.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-message-queue.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/pi-message-queue.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-message-queue.test.js +91 -0
- package/dist/apps/local-coding-host/tests/pi-message-queue.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-model-switch.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/pi-model-switch.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-model-switch.test.js +244 -0
- package/dist/apps/local-coding-host/tests/pi-model-switch.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.js +75 -0
- package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.js +183 -0
- package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-session-restore.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/pi-session-restore.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/pi-session-restore.test.js +84 -0
- package/dist/apps/local-coding-host/tests/pi-session-restore.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/platform-client-status.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/platform-client-status.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/platform-client-status.test.js +29 -0
- package/dist/apps/local-coding-host/tests/platform-client-status.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/platform-models.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/platform-models.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/platform-models.test.js +395 -0
- package/dist/apps/local-coding-host/tests/platform-models.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/powershell-resolution.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/powershell-resolution.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/powershell-resolution.test.js +138 -0
- package/dist/apps/local-coding-host/tests/powershell-resolution.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/profile-installer.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/profile-installer.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/profile-installer.test.js +88 -0
- package/dist/apps/local-coding-host/tests/profile-installer.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/profile.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/profile.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/profile.test.js +88 -0
- package/dist/apps/local-coding-host/tests/profile.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/provider-auth-status.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/provider-auth-status.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/provider-auth-status.test.js +82 -0
- package/dist/apps/local-coding-host/tests/provider-auth-status.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-project-checkout.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/qa-project-checkout.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-project-checkout.test.js +101 -0
- package/dist/apps/local-coding-host/tests/qa-project-checkout.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-session-manager.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/qa-session-manager.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-session-manager.test.js +1493 -0
- package/dist/apps/local-coding-host/tests/qa-session-manager.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-verification-contract.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/qa-verification-contract.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/qa-verification-contract.test.js +208 -0
- package/dist/apps/local-coding-host/tests/qa-verification-contract.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/recovery-workspace.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/recovery-workspace.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/recovery-workspace.test.js +69 -0
- package/dist/apps/local-coding-host/tests/recovery-workspace.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/review-query.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/review-query.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/review-query.test.js +66 -0
- package/dist/apps/local-coding-host/tests/review-query.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/run-resources.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/run-resources.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/run-resources.test.js +207 -0
- package/dist/apps/local-coding-host/tests/run-resources.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-cleanup.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/runtime-cleanup.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-cleanup.test.js +161 -0
- package/dist/apps/local-coding-host/tests/runtime-cleanup.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-package-install.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/runtime-package-install.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-package-install.test.js +63 -0
- package/dist/apps/local-coding-host/tests/runtime-package-install.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-version.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/runtime-version.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/runtime-version.test.js +15 -0
- package/dist/apps/local-coding-host/tests/runtime-version.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/secure-json.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/secure-json.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/secure-json.test.js +64 -0
- package/dist/apps/local-coding-host/tests/secure-json.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/skill-storage-gc.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/skill-storage-gc.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/skill-storage-gc.test.js +312 -0
- package/dist/apps/local-coding-host/tests/skill-storage-gc.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/storage-maintenance.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/storage-maintenance.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/storage-maintenance.test.js +135 -0
- package/dist/apps/local-coding-host/tests/storage-maintenance.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/test-executor.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/test-executor.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/test-executor.test.js +365 -0
- package/dist/apps/local-coding-host/tests/test-executor.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/test-reports.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/test-reports.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/test-reports.test.js +68 -0
- package/dist/apps/local-coding-host/tests/test-reports.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/test-run-manager.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/test-run-manager.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/test-run-manager.test.js +287 -0
- package/dist/apps/local-coding-host/tests/test-run-manager.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.js +224 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.test.js +47 -0
- package/dist/apps/local-coding-host/tests/tool-dispatch.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-probe.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/tool-probe.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/tool-probe.test.js +55 -0
- package/dist/apps/local-coding-host/tests/tool-probe.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-background-check.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/windows-background-check.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-background-check.test.js +60 -0
- package/dist/apps/local-coding-host/tests/windows-background-check.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-install-script.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/windows-install-script.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-install-script.test.js +170 -0
- package/dist/apps/local-coding-host/tests/windows-install-script.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-installer.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/windows-installer.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-installer.test.js +244 -0
- package/dist/apps/local-coding-host/tests/windows-installer.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-task-configuration.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/windows-task-configuration.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/windows-task-configuration.test.js +34 -0
- package/dist/apps/local-coding-host/tests/windows-task-configuration.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.js +370 -0
- package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/workspace-diff.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/workspace-diff.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/workspace-diff.test.js +166 -0
- package/dist/apps/local-coding-host/tests/workspace-diff.test.js.map +1 -0
- package/dist/apps/local-coding-host/tests/workspace-gc.test.d.ts +2 -0
- package/dist/apps/local-coding-host/tests/workspace-gc.test.d.ts.map +1 -0
- package/dist/apps/local-coding-host/tests/workspace-gc.test.js +391 -0
- package/dist/apps/local-coding-host/tests/workspace-gc.test.js.map +1 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +23 -0
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-tools.d.ts +4 -2
- package/dist/delivery-tools.d.ts.map +1 -1
- package/dist/delivery-tools.js +45 -32
- package/dist/delivery-tools.js.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/general-run-client.d.ts.map +1 -1
- package/dist/git-process.d.ts +1 -0
- package/dist/git-process.d.ts.map +1 -1
- package/dist/git-process.js +5 -1
- package/dist/git-process.js.map +1 -1
- package/dist/host-status.d.ts.map +1 -1
- package/dist/merge-requests.d.ts +4 -1
- package/dist/merge-requests.d.ts.map +1 -1
- package/dist/merge-requests.js +34 -8
- package/dist/merge-requests.js.map +1 -1
- package/dist/pi-model-service.d.ts.map +1 -1
- package/dist/platform-client.d.ts +4 -0
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/platform-client.js +3 -0
- package/dist/platform-client.js.map +1 -1
- package/dist/project-facts.d.ts +1 -0
- package/dist/project-facts.d.ts.map +1 -1
- package/dist/project-facts.js +1 -1
- package/dist/project-facts.js.map +1 -1
- package/dist/services/platform-api/src/coding-run/coding-tool-definitions.d.ts +83 -0
- package/dist/services/platform-api/src/coding-run/coding-tool-definitions.d.ts.map +1 -0
- package/dist/services/platform-api/src/coding-run/coding-tool-definitions.js +282 -0
- package/dist/services/platform-api/src/coding-run/coding-tool-definitions.js.map +1 -0
- package/dist/services/platform-api/src/coding-run/delivery-requirements.d.ts +15 -0
- package/dist/services/platform-api/src/coding-run/delivery-requirements.d.ts.map +1 -0
- package/dist/services/platform-api/src/coding-run/delivery-requirements.js +60 -0
- package/dist/services/platform-api/src/coding-run/delivery-requirements.js.map +1 -0
- package/dist/services/platform-api/src/coding-run/development-test-report.d.ts +10 -0
- package/dist/services/platform-api/src/coding-run/development-test-report.d.ts.map +1 -0
- package/dist/services/platform-api/src/coding-run/development-test-report.js +32 -0
- package/dist/services/platform-api/src/coding-run/development-test-report.js.map +1 -0
- package/dist/services/platform-api/src/coding-run/host-tool-dispatch.d.ts +21 -0
- package/dist/services/platform-api/src/coding-run/host-tool-dispatch.d.ts.map +1 -0
- package/dist/services/platform-api/src/coding-run/host-tool-dispatch.js +86 -0
- package/dist/services/platform-api/src/coding-run/host-tool-dispatch.js.map +1 -0
- package/dist/services/platform-api/src/coding-run/workspace-materials.d.ts +37 -0
- package/dist/services/platform-api/src/coding-run/workspace-materials.d.ts.map +1 -0
- package/dist/services/platform-api/src/coding-run/workspace-materials.js +99 -0
- package/dist/services/platform-api/src/coding-run/workspace-materials.js.map +1 -0
- package/dist/services/platform-api/src/common/app-exception.d.ts +17 -0
- package/dist/services/platform-api/src/common/app-exception.d.ts.map +1 -0
- package/dist/services/platform-api/src/common/app-exception.js +46 -0
- package/dist/services/platform-api/src/common/app-exception.js.map +1 -0
- package/dist/services/platform-api/src/config/environment.d.ts +30 -0
- package/dist/services/platform-api/src/config/environment.d.ts.map +1 -0
- package/dist/services/platform-api/src/config/environment.js +123 -0
- package/dist/services/platform-api/src/config/environment.js.map +1 -0
- package/dist/services/platform-api/src/database/database.service.d.ts +38 -0
- package/dist/services/platform-api/src/database/database.service.d.ts.map +1 -0
- package/dist/services/platform-api/src/database/database.service.js +520 -0
- package/dist/services/platform-api/src/database/database.service.js.map +1 -0
- package/dist/services/platform-api/src/database/migration-ledger.d.ts +5 -0
- package/dist/services/platform-api/src/database/migration-ledger.d.ts.map +1 -0
- package/dist/services/platform-api/src/database/migration-ledger.js +33 -0
- package/dist/services/platform-api/src/database/migration-ledger.js.map +1 -0
- package/dist/services/platform-api/src/digital-employee/local-skill-bundles.d.ts +13 -0
- package/dist/services/platform-api/src/digital-employee/local-skill-bundles.d.ts.map +1 -0
- package/dist/services/platform-api/src/digital-employee/local-skill-bundles.js +25 -0
- package/dist/services/platform-api/src/digital-employee/local-skill-bundles.js.map +1 -0
- package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.d.ts +6 -0
- package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.d.ts.map +1 -0
- package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.js +20 -0
- package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.js.map +1 -0
- package/dist/services/platform-api/src/qa/qa-tool-definitions.d.ts +100 -0
- package/dist/services/platform-api/src/qa/qa-tool-definitions.d.ts.map +1 -0
- package/dist/services/platform-api/src/qa/qa-tool-definitions.js +498 -0
- package/dist/services/platform-api/src/qa/qa-tool-definitions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/workspace-diff.d.ts +6 -0
- package/dist/workspace-diff.d.ts.map +1 -0
- package/dist/workspace-diff.js +278 -0
- package/dist/workspace-diff.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,3211 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
+
import { codingDeliveryRequirements } from "../../../services/platform-api/src/coding-run/delivery-requirements.js";
|
|
10
|
+
import { hostToolDispatch } from "../../../services/platform-api/src/coding-run/host-tool-dispatch.js";
|
|
11
|
+
import { workspaceMaterialPreparation } from "../../../services/platform-api/src/coding-run/workspace-materials.js";
|
|
12
|
+
import { CodingRunManager, inspectPriorTransferWorkspaces, inspectWorkspaceInitialization, prepareDeploymentProjects, prepareProjects, redactHostText, worktreeTreeHash, } from "../src/coding-run-manager.js";
|
|
13
|
+
import { commandMaterialReader, initializeDeliveryFiles } from "../src/delivery-files.js";
|
|
14
|
+
import { PlatformClientError } from "../src/platform-client.js";
|
|
15
|
+
import { acquireOperationLock, OperationContext } from "../src/operation-context.js";
|
|
16
|
+
import { paths } from "../src/paths.js";
|
|
17
|
+
import { materialInput, materialSource, readMaterialFixture } from "./material-fixture.js";
|
|
18
|
+
const execFileAsync = promisify(execFile);
|
|
19
|
+
const mrMocks = vi.hoisted(() => ({ api: vi.fn() }));
|
|
20
|
+
vi.mock("../src/merge-requests.js", async (importOriginal) => {
|
|
21
|
+
const actual = await importOriginal();
|
|
22
|
+
return {
|
|
23
|
+
...actual,
|
|
24
|
+
prepareMergeRequest: (options) => actual.prepareMergeRequest({ ...options, api: mrMocks.api }),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
const subagentMocks = vi.hoisted(() => ({ options: undefined }));
|
|
28
|
+
vi.mock("../src/coding-subagents.js", () => ({
|
|
29
|
+
createCodingSubagents: async (options) => {
|
|
30
|
+
subagentMocks.options = options;
|
|
31
|
+
const pending = new Map();
|
|
32
|
+
const started = options.started, completed = options.completed;
|
|
33
|
+
options.started = (key, agent) => {
|
|
34
|
+
pending.set(key, agent);
|
|
35
|
+
started(key, agent);
|
|
36
|
+
};
|
|
37
|
+
options.completed = async (key, agent) => {
|
|
38
|
+
pending.delete(key);
|
|
39
|
+
await completed(key, agent);
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
extension: (api) => api.registerTool({ name: "subagent" }),
|
|
43
|
+
stop: vi.fn(async () => {
|
|
44
|
+
for (const [key, agent] of pending) {
|
|
45
|
+
await options.emit("SUBAGENT_STOPPED", { activityKey: key, agentId: agent });
|
|
46
|
+
await options.completed(key, agent);
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
flush: vi.fn(async () => { }),
|
|
50
|
+
dispose: vi.fn(async () => { }),
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
const piMocks = vi.hoisted(() => ({
|
|
55
|
+
createAgentSession: vi.fn(),
|
|
56
|
+
loaderOptions: undefined,
|
|
57
|
+
openSession: vi.fn(),
|
|
58
|
+
createSession: vi.fn(),
|
|
59
|
+
listSessions: vi.fn(),
|
|
60
|
+
}));
|
|
61
|
+
vi.mock("@earendil-works/pi-coding-agent", async (importOriginal) => ({
|
|
62
|
+
...(await importOriginal()),
|
|
63
|
+
createAgentSession: async (options) => {
|
|
64
|
+
const { sessionManager, model } = options;
|
|
65
|
+
sessionManager.buildSessionContext ??= () => ({
|
|
66
|
+
model: { provider: model.provider, modelId: model.id },
|
|
67
|
+
});
|
|
68
|
+
const result = await piMocks.createAgentSession(options);
|
|
69
|
+
result.session.getContextUsage ??= () => undefined;
|
|
70
|
+
result.session.agent ??= { state: { tools: [] }, abort: vi.fn() };
|
|
71
|
+
result.session.agent.steer ??= vi.fn();
|
|
72
|
+
result.session.agent.followUp ??= vi.fn();
|
|
73
|
+
result.session.agent.getQueuedMessages ??= () => ({ steering: [], followUp: [] });
|
|
74
|
+
const steer = result.session.steer;
|
|
75
|
+
if (steer?.mockImplementation)
|
|
76
|
+
steer.mockImplementation(async (text, images) => {
|
|
77
|
+
result.session.queuedInput = {
|
|
78
|
+
role: "user",
|
|
79
|
+
content: [{ type: "text", text }, ...(images ?? [])],
|
|
80
|
+
timestamp: Date.now(),
|
|
81
|
+
};
|
|
82
|
+
result.session.agent.steer(result.session.queuedInput);
|
|
83
|
+
});
|
|
84
|
+
result.session.followUp ??= vi.fn(async (text) => {
|
|
85
|
+
result.session.agent.followUp({
|
|
86
|
+
role: "user",
|
|
87
|
+
content: [{ type: "text", text }],
|
|
88
|
+
timestamp: Date.now(),
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
result.session.setSteeringMode ??= vi.fn();
|
|
92
|
+
result.session.setFollowUpMode ??= vi.fn();
|
|
93
|
+
result.session.setActiveToolsByName ??= vi.fn();
|
|
94
|
+
result.session.setAutoCompactionEnabled ??= vi.fn();
|
|
95
|
+
result.session.waitForIdle ??= vi.fn().mockResolvedValue(undefined);
|
|
96
|
+
result.session.dispose ??= vi.fn();
|
|
97
|
+
result.session.bindExtensions ??= vi.fn().mockResolvedValue(undefined);
|
|
98
|
+
return result;
|
|
99
|
+
},
|
|
100
|
+
DefaultResourceLoader: class {
|
|
101
|
+
constructor(options) {
|
|
102
|
+
piMocks.loaderOptions = options;
|
|
103
|
+
}
|
|
104
|
+
async reload() { }
|
|
105
|
+
},
|
|
106
|
+
SessionManager: {
|
|
107
|
+
open: piMocks.openSession,
|
|
108
|
+
create: piMocks.createSession,
|
|
109
|
+
listAll: piMocks.listSessions,
|
|
110
|
+
},
|
|
111
|
+
}));
|
|
112
|
+
// Session projection tests without repositories isolate the filesystem boundary;
|
|
113
|
+
// real file behavior and Git validation are covered below and in delivery-files.test.ts.
|
|
114
|
+
vi.mock("../src/delivery-files.js", async (importOriginal) => {
|
|
115
|
+
const actual = await importOriginal();
|
|
116
|
+
return {
|
|
117
|
+
...actual,
|
|
118
|
+
commandMaterialReader: vi.fn(() => readMaterialFixture),
|
|
119
|
+
deliveryDirectory: (root, input) => input.projects.length ? actual.deliveryDirectory(root, input) : join(root, "docs/aip/AIP-1"),
|
|
120
|
+
initializeDeliveryFiles: (root, input, resume = false, reader = readMaterialFixture) => input.projects.length
|
|
121
|
+
? actual.initializeDeliveryFiles(root, input, resume, reader)
|
|
122
|
+
: Promise.resolve(join(root, "docs/aip/AIP-1")),
|
|
123
|
+
collectDeliveryFiles: (root, input, requirements) => input.projects.length
|
|
124
|
+
? actual.collectDeliveryFiles(root, input, requirements)
|
|
125
|
+
: Promise.resolve([
|
|
126
|
+
{
|
|
127
|
+
slot: "SUMMARY",
|
|
128
|
+
path: "docs/aip/AIP-1/summary.md",
|
|
129
|
+
content: "完成",
|
|
130
|
+
contentHash: "a".repeat(64),
|
|
131
|
+
},
|
|
132
|
+
]),
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
let testRoot;
|
|
136
|
+
if (process.platform === "win32")
|
|
137
|
+
vi.setConfig({ testTimeout: 60_000, hookTimeout: 15_000 });
|
|
138
|
+
// 本文件隔离 Pi/平台,只测会话生命周期。Windows ACL 在 secure-json 测试与
|
|
139
|
+
// 正式 Runtime/真实 E2E 中验证,避免每条模拟事件启动 PowerShell 超过单测预算。
|
|
140
|
+
// 文件写入仍采用真正的原子替换,不模拟状态持久化或吞掉写入错误。
|
|
141
|
+
vi.mock("../src/secure-json.js", async (importOriginal) => {
|
|
142
|
+
const actual = await importOriginal();
|
|
143
|
+
const fs = await import("node:fs/promises");
|
|
144
|
+
const { dirname } = await import("node:path");
|
|
145
|
+
return {
|
|
146
|
+
...actual,
|
|
147
|
+
writeSecureJson: process.platform !== "win32"
|
|
148
|
+
? actual.writeSecureJson
|
|
149
|
+
: async (path, value) => {
|
|
150
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
|
151
|
+
const temporary = `${path}.${randomUUID()}.test-tmp`;
|
|
152
|
+
await fs.writeFile(temporary, JSON.stringify(value), { flag: "wx" });
|
|
153
|
+
await actual.replaceSecureFile(temporary, path);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
const runInput = {
|
|
158
|
+
phase: "DEPLOYMENT",
|
|
159
|
+
teamEmployees: {
|
|
160
|
+
frontend: { name: "前端工程师", description: "页面实现" },
|
|
161
|
+
backend: { name: "后端工程师", description: "接口实现" },
|
|
162
|
+
tester: { name: "测试工程师", description: "验证" },
|
|
163
|
+
},
|
|
164
|
+
team: {
|
|
165
|
+
id: "team",
|
|
166
|
+
members: {
|
|
167
|
+
supervisorId: "supervisor",
|
|
168
|
+
employeeIds: ["frontend", "backend", "tester", "excluded"],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
primaryProjectId: "",
|
|
172
|
+
workItem: { id: "work-item", key: "AIP-1", title: "微型需求" },
|
|
173
|
+
requirement: { title: "PRD", body_markdown: "实现相加" },
|
|
174
|
+
technicalDesign: null,
|
|
175
|
+
projects: [],
|
|
176
|
+
agent: {
|
|
177
|
+
systemPrompt: "自主开发",
|
|
178
|
+
skills: [{ name: "typescript", path: "../SKILL.md", content: "# TypeScript" }],
|
|
179
|
+
},
|
|
180
|
+
reviewer: { id: "backend", description: "审查", systemPrompt: "只读审查" },
|
|
181
|
+
providerId: "openai-codex",
|
|
182
|
+
modelId: "gpt-test",
|
|
183
|
+
thinkingLevel: "high",
|
|
184
|
+
};
|
|
185
|
+
const dispatchedInputs = new Map();
|
|
186
|
+
const employeeConfig = vi.fn(async (_runId, binding) => {
|
|
187
|
+
const input = dispatchedInputs.get(binding.turnId ?? turnId) ?? runInput;
|
|
188
|
+
const enabledTools = ["read", "ls", "grep", "find", "edit", "write", "bash"];
|
|
189
|
+
return {
|
|
190
|
+
agent: {
|
|
191
|
+
id: crypto.randomUUID(),
|
|
192
|
+
name: binding.member,
|
|
193
|
+
revision: 1,
|
|
194
|
+
systemPrompt: "按职责执行",
|
|
195
|
+
enabledTools,
|
|
196
|
+
skills: [],
|
|
197
|
+
},
|
|
198
|
+
member: binding.member,
|
|
199
|
+
nodeRules: {
|
|
200
|
+
node: "DEVELOPMENT",
|
|
201
|
+
source: "WORKSPACE",
|
|
202
|
+
sourceId: "workspace",
|
|
203
|
+
revision: 1,
|
|
204
|
+
prompt: "节点方法",
|
|
205
|
+
},
|
|
206
|
+
collaborationSource: null,
|
|
207
|
+
executionFacts: {},
|
|
208
|
+
collaborationInstructions: "协作",
|
|
209
|
+
configHash: "test",
|
|
210
|
+
...hostToolDispatch(enabledTools, {
|
|
211
|
+
phase: input.phase,
|
|
212
|
+
projects: input.projects,
|
|
213
|
+
...(input.executionPurpose ? { executionPurpose: input.executionPurpose } : {}),
|
|
214
|
+
...(input.deploymentConfiguration
|
|
215
|
+
? { deploymentConfiguration: input.deploymentConfiguration }
|
|
216
|
+
: {}),
|
|
217
|
+
...(binding.child ? { child: true } : {}),
|
|
218
|
+
...(input.team
|
|
219
|
+
? {
|
|
220
|
+
agents: Object.entries(input.teamEmployees ?? {}).map(([id, value]) => ({
|
|
221
|
+
id,
|
|
222
|
+
name: value.name,
|
|
223
|
+
})),
|
|
224
|
+
}
|
|
225
|
+
: {}),
|
|
226
|
+
}),
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
async function writeArtifacts(manager) {
|
|
230
|
+
const run = manager.active.get(runId);
|
|
231
|
+
if (!run)
|
|
232
|
+
throw Error("missing active test run");
|
|
233
|
+
const revisions = [];
|
|
234
|
+
for (const project of run.input.projects) {
|
|
235
|
+
const cwd = join(testRoot, "profiles", "default", "workspaces", "runs", runId, project.name);
|
|
236
|
+
const commitSha = (await execFileAsync("git", ["rev-parse", "HEAD"], { cwd })).stdout.trim();
|
|
237
|
+
const directory = join(cwd, "docs/aip/AIP-1");
|
|
238
|
+
if (project.id === run.input.primaryProjectId) {
|
|
239
|
+
await mkdir(directory, { recursive: true });
|
|
240
|
+
for (const name of ["plan.md", "code_review.md", "report.md", "release_checklist.md"])
|
|
241
|
+
await writeFile(join(directory, name), "完成");
|
|
242
|
+
}
|
|
243
|
+
const treeHash = await worktreeTreeHash(cwd, project.id === run.input.primaryProjectId ? "AIP-1" : undefined, true);
|
|
244
|
+
revisions.push({ projectId: project.id, commitSha, treeHash });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const host = { hostId: "22222222-2222-4222-8222-222222222222", generation: 3 };
|
|
248
|
+
const runId = "11111111-1111-4111-8111-111111111111";
|
|
249
|
+
const turnId = "55555555-5555-4555-8555-555555555555";
|
|
250
|
+
function command(action, overrides = {}) {
|
|
251
|
+
const explicitlyMissing = Object.hasOwn(overrides, "runInput") && overrides.runInput === undefined;
|
|
252
|
+
const selected = overrides.runInput ?? runInput;
|
|
253
|
+
overrides = {
|
|
254
|
+
...overrides,
|
|
255
|
+
runInput: explicitlyMissing
|
|
256
|
+
? undefined
|
|
257
|
+
: {
|
|
258
|
+
...materialInput(selected),
|
|
259
|
+
primaryProjectId: selected.primaryProjectId || selected.projects[0]?.id,
|
|
260
|
+
deliveryRequirements: codingDeliveryRequirements(selected),
|
|
261
|
+
materialPreparation: workspaceMaterialPreparation({
|
|
262
|
+
...materialInput(selected),
|
|
263
|
+
primaryProjectId: selected.primaryProjectId || selected.projects[0]?.id,
|
|
264
|
+
}),
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
const selectedTurn = overrides.turnId ?? turnId;
|
|
268
|
+
if (!explicitlyMissing && action !== "STOP")
|
|
269
|
+
dispatchedInputs.set(selectedTurn, selected);
|
|
270
|
+
return {
|
|
271
|
+
id: "33333333-3333-4333-8333-333333333333",
|
|
272
|
+
kind: "CODING_RUN_START",
|
|
273
|
+
expiresAt: new Date(Date.now() + 60_000).toISOString(),
|
|
274
|
+
run: {
|
|
275
|
+
runId,
|
|
276
|
+
turnId,
|
|
277
|
+
action,
|
|
278
|
+
runInput,
|
|
279
|
+
...(action === "STEER" ? { messageId: "44444444-4444-4444-8444-444444444444" } : {}),
|
|
280
|
+
...overrides,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function mockSessionManager(fileName, sessionId = "11111111-1111-7111-8111-111111111111") {
|
|
285
|
+
const sessionFile = join(testRoot, "profiles", "default", "pi", "sessions", fileName);
|
|
286
|
+
return {
|
|
287
|
+
setSessionFile: vi.fn(),
|
|
288
|
+
appendCustomEntry: vi.fn(() => writeFileSync(sessionFile, "{}\n")),
|
|
289
|
+
getSessionFile: () => sessionFile,
|
|
290
|
+
getSessionId: () => sessionId,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function rememberSession(manager) {
|
|
294
|
+
piMocks.listSessions.mockResolvedValue([
|
|
295
|
+
{ id: manager.getSessionId(), path: manager.getSessionFile() },
|
|
296
|
+
]);
|
|
297
|
+
return manager;
|
|
298
|
+
}
|
|
299
|
+
describe("CodingRunManager", () => {
|
|
300
|
+
beforeEach(async () => {
|
|
301
|
+
// Keep fixture bytes deterministic regardless of the developer's Git defaults.
|
|
302
|
+
vi.stubEnv("GIT_CONFIG_COUNT", "1");
|
|
303
|
+
vi.stubEnv("GIT_CONFIG_KEY_0", "core.autocrlf");
|
|
304
|
+
vi.stubEnv("GIT_CONFIG_VALUE_0", "false");
|
|
305
|
+
dispatchedInputs.clear();
|
|
306
|
+
testRoot = await mkdtemp(join(tmpdir(), "coding-run-manager-test-"));
|
|
307
|
+
process.env.AIP_HOME = testRoot;
|
|
308
|
+
piMocks.loaderOptions = undefined;
|
|
309
|
+
piMocks.createAgentSession.mockReset();
|
|
310
|
+
piMocks.openSession.mockReset();
|
|
311
|
+
piMocks.createSession.mockReset();
|
|
312
|
+
piMocks.listSessions.mockReset();
|
|
313
|
+
piMocks.listSessions.mockResolvedValue([]);
|
|
314
|
+
});
|
|
315
|
+
afterEach(async () => {
|
|
316
|
+
vi.unstubAllEnvs();
|
|
317
|
+
delete process.env.AIP_TEST_PI;
|
|
318
|
+
delete process.env.AIP_HOME;
|
|
319
|
+
if (testRoot)
|
|
320
|
+
await rm(testRoot, { recursive: true, force: true });
|
|
321
|
+
testRoot = undefined;
|
|
322
|
+
for (const [options] of piMocks.createAgentSession.mock.calls) {
|
|
323
|
+
// Pi 的 tools 是永久 allowlist,不能仅传内置工具而过滤平台扩展。
|
|
324
|
+
expect(options).not.toHaveProperty("tools");
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
it("准备等待共享仓库时已登记为忙碌,取消后不会在锁释放时启动", async () => {
|
|
328
|
+
const ac = new AbortController();
|
|
329
|
+
const manager = new CodingRunManager({}, ac.signal);
|
|
330
|
+
const client = { appendCodingEvents: vi.fn(), reportCodingTerminal: vi.fn() };
|
|
331
|
+
await mkdir(paths().repositoryCache, { recursive: true });
|
|
332
|
+
const mirror = join(paths().repositoryCache, "pending-project.git");
|
|
333
|
+
const release = await new OperationContext().run(() => acquireOperationLock(mirror));
|
|
334
|
+
try {
|
|
335
|
+
const task = manager.execute(client, host, command("START", {
|
|
336
|
+
runInput: {
|
|
337
|
+
...runInput,
|
|
338
|
+
phase: "PREPARATION",
|
|
339
|
+
projects: [
|
|
340
|
+
{
|
|
341
|
+
id: "pending-project",
|
|
342
|
+
name: "pending",
|
|
343
|
+
repositoryUrl: testRoot,
|
|
344
|
+
baselineCommit: "a".repeat(40),
|
|
345
|
+
baselineBranch: "main",
|
|
346
|
+
devBranch: "aip/AIP-1",
|
|
347
|
+
testBranch: "test",
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
},
|
|
351
|
+
}));
|
|
352
|
+
const rejection = expect(task).rejects.toThrow();
|
|
353
|
+
expect(manager.isBusy()).toBe(true);
|
|
354
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
355
|
+
ac.abort();
|
|
356
|
+
await rejection;
|
|
357
|
+
await manager.settled();
|
|
358
|
+
expect(manager.isBusy()).toBe(false);
|
|
359
|
+
expect(manager.cleanupConfirmed).toBe(true);
|
|
360
|
+
expect(client.appendCodingEvents).not.toHaveBeenCalled();
|
|
361
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
362
|
+
}
|
|
363
|
+
finally {
|
|
364
|
+
await release();
|
|
365
|
+
}
|
|
366
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
367
|
+
await expect(readFile(join(mirror, "HEAD"))).rejects.toThrow();
|
|
368
|
+
});
|
|
369
|
+
it("材料请求只发送Host绑定字段,不泄漏完整运行Host状态", async () => {
|
|
370
|
+
let fetchMaterial;
|
|
371
|
+
vi.mocked(commandMaterialReader).mockImplementationOnce((fetch) => {
|
|
372
|
+
fetchMaterial = fetch;
|
|
373
|
+
return readMaterialFixture;
|
|
374
|
+
});
|
|
375
|
+
const source = materialSource("材料正文");
|
|
376
|
+
const commandMaterial = vi.fn(async () => ({
|
|
377
|
+
content: "材料正文",
|
|
378
|
+
encoding: "utf8",
|
|
379
|
+
contentHash: source.contentHash,
|
|
380
|
+
}));
|
|
381
|
+
const manager = new CodingRunManager({});
|
|
382
|
+
const execution = command("STOP", { action: "RECALL_QUEUE" });
|
|
383
|
+
const fullHost = {
|
|
384
|
+
...host,
|
|
385
|
+
name: "本机 Host",
|
|
386
|
+
platformUrl: "https://platform.invalid",
|
|
387
|
+
deviceId: "device",
|
|
388
|
+
};
|
|
389
|
+
await manager.execute({ commandMaterial }, fullHost, execution);
|
|
390
|
+
await fetchMaterial(source);
|
|
391
|
+
expect(commandMaterial).toHaveBeenCalledWith("33333333-3333-4333-8333-333333333333", {
|
|
392
|
+
hostId: host.hostId,
|
|
393
|
+
generation: host.generation,
|
|
394
|
+
contentHash: source.contentHash,
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
it.each([true, false])("机械准备有需求=%s,只回报事实,不提前创建 Agent Session", async (hasRequirement) => {
|
|
398
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
399
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
400
|
+
const manager = new CodingRunManager({});
|
|
401
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal }, host, command("START", {
|
|
402
|
+
runInput: {
|
|
403
|
+
...runInput,
|
|
404
|
+
phase: "PREPARATION",
|
|
405
|
+
requirement: hasRequirement ? runInput.requirement : null,
|
|
406
|
+
},
|
|
407
|
+
}));
|
|
408
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
409
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
410
|
+
expect(appendCodingEvents.mock.calls.flatMap((c) => c[1].events.map((e) => e.kind))).toEqual(["PREPARATION_COMPLETED"]);
|
|
411
|
+
});
|
|
412
|
+
it.each([
|
|
413
|
+
[409, "CODING_EVENT_TURN_STALE", 1],
|
|
414
|
+
[409, "CODING_MATERIAL_WORKSPACE_MISSING", 8],
|
|
415
|
+
[500, "UNEXPECTED_ERROR", 8],
|
|
416
|
+
])("准备完成事件被拒绝 %s/%s 时执行失败,显式重试才继续", async (status, code, attempts) => {
|
|
417
|
+
const failure = new PlatformClientError(status, code, "准备完成事件被拒绝");
|
|
418
|
+
const appendCodingEvents = vi.fn().mockRejectedValue(failure);
|
|
419
|
+
const client = { employeeConfig, appendCodingEvents };
|
|
420
|
+
const manager = new CodingRunManager({});
|
|
421
|
+
const prepare = (action) => command(action, {
|
|
422
|
+
runInput: { ...runInput, phase: "PREPARATION", requirement: null },
|
|
423
|
+
});
|
|
424
|
+
await expect(manager.execute(client, host, prepare("START"))).rejects.toBe(failure);
|
|
425
|
+
expect(appendCodingEvents).toHaveBeenCalledTimes(attempts);
|
|
426
|
+
const events = appendCodingEvents.mock.calls.flatMap((call) => call[1].events);
|
|
427
|
+
expect(new Set(events.map((event) => event.eventId)).size).toBe(1);
|
|
428
|
+
expect(events.every((event) => event.sequence === 1)).toBe(true);
|
|
429
|
+
const stateFile = join(testRoot, "profiles/default/state/runs", `${runId}.json`);
|
|
430
|
+
expect(JSON.parse(await readFile(stateFile, "utf8"))).toMatchObject({
|
|
431
|
+
prepared: true,
|
|
432
|
+
lastEventSequence: 0,
|
|
433
|
+
});
|
|
434
|
+
appendCodingEvents.mockResolvedValue({ accepted: true });
|
|
435
|
+
await manager.execute(client, host, prepare("RESUME"));
|
|
436
|
+
expect(appendCodingEvents.mock.lastCall[1].events[0]).toMatchObject({
|
|
437
|
+
kind: "PREPARATION_COMPLETED",
|
|
438
|
+
sequence: 1,
|
|
439
|
+
});
|
|
440
|
+
expect(JSON.parse(await readFile(stateFile, "utf8")).lastEventSequence).toBe(1);
|
|
441
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
442
|
+
});
|
|
443
|
+
it("仅准备无Session,外部修改后远端离线仍复用目录和分支创建首个开发会话", async () => {
|
|
444
|
+
const source = join(testRoot, "prepare-source");
|
|
445
|
+
await mkdir(source);
|
|
446
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
447
|
+
await git(source, "init", "-b", "main");
|
|
448
|
+
await writeFile(join(source, "source.txt"), "baseline\n");
|
|
449
|
+
await git(source, "add", ".");
|
|
450
|
+
await git(source, "-c", "user.name=AIP", "-c", "user.email=aip@test.local", "commit", "-m", "baseline");
|
|
451
|
+
const project = {
|
|
452
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
453
|
+
name: "fixture",
|
|
454
|
+
repositoryUrl: source,
|
|
455
|
+
baselineCommit: await git(source, "rev-parse", "HEAD"),
|
|
456
|
+
baselineBranch: "main",
|
|
457
|
+
devBranch: `aip/${runId}/44444444`,
|
|
458
|
+
testBranch: "test",
|
|
459
|
+
};
|
|
460
|
+
const input = {
|
|
461
|
+
...runInput,
|
|
462
|
+
phase: "PREPARATION",
|
|
463
|
+
projects: [project],
|
|
464
|
+
primaryProjectId: project.id,
|
|
465
|
+
};
|
|
466
|
+
const events = vi.fn().mockResolvedValue({ accepted: true });
|
|
467
|
+
const client = {
|
|
468
|
+
employeeConfig,
|
|
469
|
+
appendCodingEvents: events,
|
|
470
|
+
reportCodingTerminal: vi.fn(),
|
|
471
|
+
};
|
|
472
|
+
const manager = new CodingRunManager({
|
|
473
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
474
|
+
});
|
|
475
|
+
const rejectPush = join(source, ".git/hooks/pre-receive");
|
|
476
|
+
await writeFile(rejectPush, "#!/bin/sh\necho materials-push-rejected >&2\nexit 1\n", {
|
|
477
|
+
mode: 0o700,
|
|
478
|
+
});
|
|
479
|
+
await expect(manager.execute(client, host, command("START", { runInput: input }))).rejects.toMatchObject({
|
|
480
|
+
code: 1,
|
|
481
|
+
message: "GIT_PROCESS_EXIT (1)",
|
|
482
|
+
stderr: expect.stringContaining("materials-push-rejected"),
|
|
483
|
+
});
|
|
484
|
+
expect(events).not.toHaveBeenCalled();
|
|
485
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
486
|
+
await rm(rejectPush);
|
|
487
|
+
await manager.execute(client, host, command("START", { runInput: input }));
|
|
488
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
489
|
+
const fact = events.mock.calls.find((c) => c[1].events[0].kind === "PREPARATION_COMPLETED")[1].events[0].payload.projects[0];
|
|
490
|
+
expect(fact.directory).toBe(join(testRoot, "profiles", "default", "workspaces", "runs", runId, "fixture"));
|
|
491
|
+
expect(fact.baselineCommit).toBe(project.baselineCommit);
|
|
492
|
+
expect(await git(source, "show", `${project.devBranch}:docs/aip/AIP-1/prd.md`)).toBe(input.requirement.body_markdown.trim());
|
|
493
|
+
expect(await git(fact.directory, "rev-parse", "HEAD")).not.toBe(project.baselineCommit);
|
|
494
|
+
await writeFile(join(fact.directory, "source.txt"), "external commit\n");
|
|
495
|
+
await git(fact.directory, "add", "source.txt");
|
|
496
|
+
await git(fact.directory, "-c", "user.name=AIP", "-c", "user.email=aip@test.local", "commit", "-m", "external implementation");
|
|
497
|
+
const externalHead = await git(fact.directory, "rev-parse", "HEAD");
|
|
498
|
+
await writeFile(join(fact.directory, "source.txt"), "external uncommitted edit\n");
|
|
499
|
+
await writeFile(join(fact.directory, "docs/aip/AIP-1/prd.md"), "external PRD notes");
|
|
500
|
+
await rename(source, `${source}-offline`);
|
|
501
|
+
const session = {
|
|
502
|
+
prompt: vi.fn(() => new Promise(() => { })),
|
|
503
|
+
waitForIdle: vi.fn(),
|
|
504
|
+
subscribe: vi.fn(),
|
|
505
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
506
|
+
};
|
|
507
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("prepared-first-session.jsonl"));
|
|
508
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
509
|
+
const next = crypto.randomUUID();
|
|
510
|
+
await manager.execute(client, host, command("START", { turnId: next, runInput: { ...input, phase: "DEVELOPMENT" } }));
|
|
511
|
+
expect(piMocks.createAgentSession).toHaveBeenCalledTimes(1);
|
|
512
|
+
expect(await git(fact.directory, "branch", "--show-current")).toBe(fact.branch);
|
|
513
|
+
expect(await git(fact.directory, "rev-parse", "HEAD")).toBe(externalHead);
|
|
514
|
+
expect(await readFile(join(fact.directory, "source.txt"), "utf8")).toBe("external uncommitted edit\n");
|
|
515
|
+
expect(await readFile(join(fact.directory, "docs/aip/AIP-1/prd.md"), "utf8")).toBe("external PRD notes");
|
|
516
|
+
await manager.execute(client, host, command("STOP", { turnId: next }));
|
|
517
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
518
|
+
it("测试模式仍通过 Host 事件与终态接口投影 reviewer 和交付", async () => {
|
|
519
|
+
process.env.AIP_TEST_PI = "1";
|
|
520
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
521
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
522
|
+
const manager = new CodingRunManager({});
|
|
523
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal }, host, {
|
|
524
|
+
id: "33333333-3333-4333-8333-333333333333",
|
|
525
|
+
kind: "CODING_RUN_START",
|
|
526
|
+
expiresAt: new Date(Date.now() + 60_000).toISOString(),
|
|
527
|
+
run: {
|
|
528
|
+
runId,
|
|
529
|
+
turnId,
|
|
530
|
+
action: "START",
|
|
531
|
+
runInput: {
|
|
532
|
+
workItem: { id: "work-item", key: "AIP-1", title: "微型需求" },
|
|
533
|
+
requirement: { title: "PRD", body_markdown: "实现相加" },
|
|
534
|
+
technicalDesign: null,
|
|
535
|
+
projects: [
|
|
536
|
+
{
|
|
537
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
538
|
+
name: "fixture",
|
|
539
|
+
repositoryUrl: "/tmp/fixture",
|
|
540
|
+
baselineCommit: "a".repeat(40),
|
|
541
|
+
baselineBranch: "main",
|
|
542
|
+
devBranch: `aip/${runId}/44444444`,
|
|
543
|
+
testBranch: "test",
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
agent: { systemPrompt: "自主开发", skills: [] },
|
|
547
|
+
phase: "DEPLOYMENT",
|
|
548
|
+
team: { id: "team", members: { supervisorId: "supervisor", employeeIds: ["backend"] } },
|
|
549
|
+
providerId: "openai-codex",
|
|
550
|
+
modelId: "gpt-test",
|
|
551
|
+
thinkingLevel: "high",
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
});
|
|
555
|
+
expect(appendCodingEvents.mock.calls.map((call) => call[1].events[0].kind)).toEqual([
|
|
556
|
+
"RUN_STARTED",
|
|
557
|
+
"MESSAGE_COMPLETED",
|
|
558
|
+
]);
|
|
559
|
+
expect(appendCodingEvents.mock.calls.every((call) => call[1].events[0].turnId === turnId)).toBe(true);
|
|
560
|
+
expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({ kind: "DELIVERY" }));
|
|
561
|
+
});
|
|
562
|
+
it("校验命令并投影停止、继续和 steer 协议", async () => {
|
|
563
|
+
process.env.AIP_TEST_PI = "1";
|
|
564
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
565
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
566
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal };
|
|
567
|
+
const manager = new CodingRunManager({});
|
|
568
|
+
await expect(manager.execute(client, host, {})).rejects.toThrow("CODING_RUN_COMMAND_INVALID");
|
|
569
|
+
await expect(manager.execute(client, host, command("STEER", { contentMarkdown: "" }))).rejects.toThrow("CODING_RUN_MESSAGE_MISSING");
|
|
570
|
+
await expect(manager.execute(client, host, command("STEER", { runInput: undefined, contentMarkdown: "继续" }))).rejects.toThrow("CODING_RUN_INPUT_MISSING");
|
|
571
|
+
await manager.execute(client, host, command("STEER", { contentMarkdown: "继续" }));
|
|
572
|
+
await manager.execute(client, host, command("RESUME"));
|
|
573
|
+
await manager.execute(client, host, command("STOP"));
|
|
574
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
575
|
+
expect(appendCodingEvents.mock.calls.some((call) => call[1].events[0].kind === "RUN_STOPPED")).toBe(true);
|
|
576
|
+
expect(reportCodingTerminal).toHaveBeenCalledTimes(2);
|
|
577
|
+
});
|
|
578
|
+
it.each([
|
|
579
|
+
{ projectNames: [] },
|
|
580
|
+
{ projectNames: ["fixture project"] },
|
|
581
|
+
{ projectNames: ["frontend", "backend"] },
|
|
582
|
+
])("部署进行时研发讨论按原工作目录恢复会话,停止讨论不停止部署(项目 $projectNames)", async ({ projectNames }) => {
|
|
583
|
+
const makeSession = () => {
|
|
584
|
+
let finish;
|
|
585
|
+
return {
|
|
586
|
+
prompt: vi.fn(() => new Promise((resolve) => {
|
|
587
|
+
finish = resolve;
|
|
588
|
+
})),
|
|
589
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
590
|
+
abort: vi.fn(async () => finish?.()),
|
|
591
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
592
|
+
subscribe: vi.fn(),
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
const deployment = makeSession();
|
|
596
|
+
const discussion = makeSession();
|
|
597
|
+
const developmentSession = mockSessionManager("development.jsonl", "development-session");
|
|
598
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("deployment.jsonl"));
|
|
599
|
+
piMocks.openSession.mockReturnValue(developmentSession);
|
|
600
|
+
const { SessionManager } = await vi.importActual("@earendil-works/pi-coding-agent");
|
|
601
|
+
piMocks.listSessions.mockImplementation(SessionManager.listAll);
|
|
602
|
+
piMocks.createAgentSession
|
|
603
|
+
.mockResolvedValueOnce({ session: deployment })
|
|
604
|
+
.mockResolvedValueOnce({ session: discussion });
|
|
605
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
606
|
+
const reportCodingTerminal = vi.fn();
|
|
607
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal };
|
|
608
|
+
const manager = new CodingRunManager({
|
|
609
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
610
|
+
});
|
|
611
|
+
await manager.execute(client, host, command("START"));
|
|
612
|
+
// Use the actual persisted state location; its phase must remain deployment throughout discussion.
|
|
613
|
+
const { paths } = await import("../src/paths.js");
|
|
614
|
+
const actualStateFile = join(paths().runState, `${runId}.json`);
|
|
615
|
+
const state = JSON.parse(await readFile(actualStateFile, "utf8"));
|
|
616
|
+
await writeFile(actualStateFile, JSON.stringify({
|
|
617
|
+
...state,
|
|
618
|
+
phaseSessions: { ...state.phaseSessions, DEVELOPMENT: "development-session" },
|
|
619
|
+
}));
|
|
620
|
+
for (const name of projectNames) {
|
|
621
|
+
const cwd = join(paths().runWorktrees, runId, name.replaceAll(" ", "-"));
|
|
622
|
+
await mkdir(cwd, { recursive: true });
|
|
623
|
+
await execFileAsync("git", ["init", "-b", "main"], { cwd });
|
|
624
|
+
await execFileAsync("git", [
|
|
625
|
+
"-c",
|
|
626
|
+
"user.name=AIP",
|
|
627
|
+
"-c",
|
|
628
|
+
"user.email=aip@test.local",
|
|
629
|
+
"commit",
|
|
630
|
+
"--allow-empty",
|
|
631
|
+
"-m",
|
|
632
|
+
"fixture",
|
|
633
|
+
], { cwd });
|
|
634
|
+
}
|
|
635
|
+
const developmentCwd = join(paths().runWorktrees, runId, ...(projectNames.length === 1 ? ["fixture-project"] : []));
|
|
636
|
+
await writeFile(developmentSession.getSessionFile(), `${JSON.stringify({ type: "session", version: 3, id: "development-session", timestamp: new Date().toISOString(), cwd: developmentCwd })}\n`);
|
|
637
|
+
const discussionInput = {
|
|
638
|
+
...runInput,
|
|
639
|
+
phase: "DEVELOPMENT",
|
|
640
|
+
discussionTurn: true,
|
|
641
|
+
projects: projectNames.map((name, index) => ({
|
|
642
|
+
id: `project-${index}`,
|
|
643
|
+
name,
|
|
644
|
+
repositoryUrl: "unused",
|
|
645
|
+
baselineBranch: "main",
|
|
646
|
+
})),
|
|
647
|
+
conversationContext: { discussionOnly: true },
|
|
648
|
+
autoContinueEnabled: false,
|
|
649
|
+
};
|
|
650
|
+
const discussionId = "66666666-6666-4666-8666-666666666666";
|
|
651
|
+
await manager.execute(client, host, command("STEER", {
|
|
652
|
+
turnId: discussionId,
|
|
653
|
+
runInput: discussionInput,
|
|
654
|
+
contentMarkdown: "解释目前实现",
|
|
655
|
+
}));
|
|
656
|
+
expect(piMocks.openSession).toHaveBeenCalledWith(developmentSession.getSessionFile(), paths().piSessions, developmentCwd);
|
|
657
|
+
expect(discussion.prompt).toHaveBeenCalledWith(expect.stringContaining("解释目前实现"), undefined);
|
|
658
|
+
await manager.execute(client, host, command("STOP", { turnId: discussionId, runInput: discussionInput }));
|
|
659
|
+
expect(discussion.abort).toHaveBeenCalledOnce();
|
|
660
|
+
expect(deployment.abort).not.toHaveBeenCalled();
|
|
661
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
662
|
+
const persisted = JSON.parse(await readFile(actualStateFile, "utf8"));
|
|
663
|
+
expect(persisted.phase).toBe("DEPLOYMENT");
|
|
664
|
+
const events = appendCodingEvents.mock.calls.map((call) => call[1].events[0]);
|
|
665
|
+
expect(events.map((event) => event.sequence)).toEqual(events.map((_, index) => index + 1));
|
|
666
|
+
expect(events.some((event) => event.turnId === discussionId && event.kind === "RUN_STOPPED")).toBe(true);
|
|
667
|
+
await manager.execute(client, host, command("STOP"));
|
|
668
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
669
|
+
});
|
|
670
|
+
it("停止时后续事件上报失败不产生未处理拒绝,Host 仍中止会话", async () => {
|
|
671
|
+
let finishPrompt;
|
|
672
|
+
const unhandled = [];
|
|
673
|
+
const onUnhandled = (reason) => unhandled.push(reason);
|
|
674
|
+
process.on("unhandledRejection", onUnhandled);
|
|
675
|
+
const session = {
|
|
676
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
677
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
678
|
+
steer: vi.fn(),
|
|
679
|
+
abort: vi.fn(async () => finishPrompt?.()),
|
|
680
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
681
|
+
subscribe: vi.fn(),
|
|
682
|
+
};
|
|
683
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("stop-session.jsonl"));
|
|
684
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
685
|
+
const appendCodingEvents = vi
|
|
686
|
+
.fn()
|
|
687
|
+
.mockResolvedValueOnce({ accepted: true })
|
|
688
|
+
.mockRejectedValueOnce(new PlatformClientError(500, "UNEXPECTED_ERROR", "服务暂时无法完成请求"))
|
|
689
|
+
.mockResolvedValue({ accepted: true });
|
|
690
|
+
const manager = new CodingRunManager({
|
|
691
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
692
|
+
});
|
|
693
|
+
try {
|
|
694
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() }, host, command("START"));
|
|
695
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() }, host, command("STOP"));
|
|
696
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
697
|
+
expect(session.abort).toHaveBeenCalledOnce();
|
|
698
|
+
expect(unhandled).toEqual([]);
|
|
699
|
+
}
|
|
700
|
+
finally {
|
|
701
|
+
process.off("unhandledRejection", onUnhandled);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
it("事件上报失败时重送同一 eventId 和序号,确认后再递增", async () => {
|
|
705
|
+
let finishPrompt;
|
|
706
|
+
const session = {
|
|
707
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
708
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
709
|
+
steer: vi.fn(),
|
|
710
|
+
abort: vi.fn(async () => finishPrompt?.()),
|
|
711
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
712
|
+
subscribe: vi.fn(),
|
|
713
|
+
};
|
|
714
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("seq-session.jsonl"));
|
|
715
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
716
|
+
let rejectedQueue = false;
|
|
717
|
+
const appendCodingEvents = vi.fn(async (_runId, batch) => {
|
|
718
|
+
if (batch.events[0].kind === "MESSAGE_QUEUE_UPDATED" && !rejectedQueue) {
|
|
719
|
+
rejectedQueue = true;
|
|
720
|
+
throw new PlatformClientError(500, "UNEXPECTED_ERROR", "服务暂时无法完成请求");
|
|
721
|
+
}
|
|
722
|
+
return { accepted: true };
|
|
723
|
+
});
|
|
724
|
+
const manager = new CodingRunManager({
|
|
725
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
726
|
+
});
|
|
727
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
728
|
+
await manager.execute(client, host, command("START"));
|
|
729
|
+
await manager.execute(client, host, command("STEER", { contentMarkdown: "继续" }));
|
|
730
|
+
const events = appendCodingEvents.mock.calls.map((call) => call[1].events[0]);
|
|
731
|
+
const queuedAttempts = events.filter((event) => event.kind === "MESSAGE_QUEUE_UPDATED");
|
|
732
|
+
expect(queuedAttempts.length).toBeGreaterThanOrEqual(2);
|
|
733
|
+
expect(queuedAttempts[0]).toMatchObject({
|
|
734
|
+
eventId: queuedAttempts[1].eventId,
|
|
735
|
+
sequence: queuedAttempts[1].sequence,
|
|
736
|
+
payload: { deliveryStatus: "QUEUED" },
|
|
737
|
+
});
|
|
738
|
+
const previous = events[events.indexOf(queuedAttempts[0]) - 1];
|
|
739
|
+
expect(queuedAttempts[0].sequence).toBe(previous.sequence + 1);
|
|
740
|
+
await manager.execute(client, host, command("STOP"));
|
|
741
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
742
|
+
});
|
|
743
|
+
it("事件持续失败时有界重试后仍能停止并开始下一轮", async () => {
|
|
744
|
+
let finishPrompt;
|
|
745
|
+
const session = {
|
|
746
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
747
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
748
|
+
steer: vi.fn(),
|
|
749
|
+
abort: vi.fn(async () => finishPrompt?.()),
|
|
750
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
751
|
+
subscribe: vi.fn(),
|
|
752
|
+
};
|
|
753
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("bounded-retry-session.jsonl"));
|
|
754
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
755
|
+
const appendCodingEvents = vi
|
|
756
|
+
.fn()
|
|
757
|
+
.mockRejectedValue(new PlatformClientError(500, "UNEXPECTED_ERROR", "服务暂时无法完成请求"));
|
|
758
|
+
const manager = new CodingRunManager({
|
|
759
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
760
|
+
});
|
|
761
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
762
|
+
await Promise.race([
|
|
763
|
+
(async () => {
|
|
764
|
+
await manager.execute(client, host, command("START"));
|
|
765
|
+
await manager.execute(client, host, command("STOP"));
|
|
766
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
767
|
+
})(),
|
|
768
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("事件上报挂起,阻塞了下一阶段 START")), 1500)),
|
|
769
|
+
]);
|
|
770
|
+
const attemptsByEventId = new Map();
|
|
771
|
+
for (const [, body] of appendCodingEvents.mock.calls) {
|
|
772
|
+
const eventId = body.events[0].eventId;
|
|
773
|
+
attemptsByEventId.set(eventId, (attemptsByEventId.get(eventId) ?? 0) + 1);
|
|
774
|
+
}
|
|
775
|
+
expect(attemptsByEventId.size).toBeGreaterThan(0);
|
|
776
|
+
expect(Math.max(...attemptsByEventId.values())).toBeLessThanOrEqual(8);
|
|
777
|
+
});
|
|
778
|
+
it("助手无正文时仍上报真实用量与本地订阅美元费用", async () => {
|
|
779
|
+
let subscriber;
|
|
780
|
+
let finishPrompt;
|
|
781
|
+
const session = {
|
|
782
|
+
model: {
|
|
783
|
+
provider: "anthropic",
|
|
784
|
+
id: "native-model",
|
|
785
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
786
|
+
},
|
|
787
|
+
getContextUsage: vi.fn(() => ({
|
|
788
|
+
tokens: 1300,
|
|
789
|
+
contextWindow: 128000,
|
|
790
|
+
percent: 1,
|
|
791
|
+
})),
|
|
792
|
+
settingsManager: { getCompactionSettings: () => ({ enabled: true, reserveTokens: 16000 }) },
|
|
793
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
794
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
795
|
+
steer: vi.fn(),
|
|
796
|
+
abort: vi.fn(async () => finishPrompt?.()),
|
|
797
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
798
|
+
subscribe: vi.fn((listener) => {
|
|
799
|
+
subscriber = listener;
|
|
800
|
+
}),
|
|
801
|
+
};
|
|
802
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("empty-assistant-session.jsonl"));
|
|
803
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
804
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
805
|
+
const manager = new CodingRunManager({
|
|
806
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
807
|
+
});
|
|
808
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
809
|
+
try {
|
|
810
|
+
await manager.execute(client, host, command("START"));
|
|
811
|
+
subscriber?.({
|
|
812
|
+
type: "message_end",
|
|
813
|
+
message: {
|
|
814
|
+
role: "assistant",
|
|
815
|
+
content: [{ type: "text", text: " " }],
|
|
816
|
+
usage: {
|
|
817
|
+
input: 3,
|
|
818
|
+
output: 0,
|
|
819
|
+
cacheRead: 0,
|
|
820
|
+
cacheWrite: 0,
|
|
821
|
+
totalTokens: 3,
|
|
822
|
+
cost: { total: 0.000009 },
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
});
|
|
826
|
+
subscriber?.({
|
|
827
|
+
type: "message_end",
|
|
828
|
+
message: {
|
|
829
|
+
role: "assistant",
|
|
830
|
+
content: [],
|
|
831
|
+
usage: {
|
|
832
|
+
input: 4,
|
|
833
|
+
output: 0,
|
|
834
|
+
cacheRead: 0,
|
|
835
|
+
cacheWrite: 0,
|
|
836
|
+
totalTokens: 4,
|
|
837
|
+
cost: { total: 0.000012 },
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
});
|
|
841
|
+
subscriber?.({ type: "compaction_start", reason: "threshold" });
|
|
842
|
+
session.getContextUsage.mockReturnValue({ tokens: null, contextWindow: 128000, percent: 0 });
|
|
843
|
+
subscriber?.({
|
|
844
|
+
type: "compaction_end",
|
|
845
|
+
reason: "threshold",
|
|
846
|
+
result: { summary: "压缩完成" },
|
|
847
|
+
});
|
|
848
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls
|
|
849
|
+
.flatMap((call) => call[1].events)
|
|
850
|
+
.filter((event) => event.kind === "CONTEXT_UPDATED")
|
|
851
|
+
.at(-1)?.payload.contextUsage).toMatchObject({ status: "UNKNOWN", tokens: null }));
|
|
852
|
+
const contexts = appendCodingEvents.mock.calls
|
|
853
|
+
.flatMap((call) => call[1].events)
|
|
854
|
+
.filter((event) => event.kind === "CONTEXT_UPDATED")
|
|
855
|
+
.map((event) => event.payload.contextUsage);
|
|
856
|
+
expect(contexts[0]).toMatchObject({
|
|
857
|
+
tokens: 1300,
|
|
858
|
+
contextWindow: 128000,
|
|
859
|
+
modelId: "anthropic/native-model",
|
|
860
|
+
compressionThreshold: 112000,
|
|
861
|
+
});
|
|
862
|
+
expect(contexts.at(-2)).toMatchObject({ status: "COMPACTING", tokens: null });
|
|
863
|
+
expect(contexts.at(-1)).toMatchObject({ status: "UNKNOWN", tokens: null });
|
|
864
|
+
const messages = appendCodingEvents.mock.calls
|
|
865
|
+
.flatMap((call) => call[1].events)
|
|
866
|
+
.filter((event) => event.kind === "MESSAGE_COMPLETED");
|
|
867
|
+
expect(messages).toHaveLength(2);
|
|
868
|
+
expect(messages[0].payload).toMatchObject({
|
|
869
|
+
usage: { input: 3 },
|
|
870
|
+
modelCost: {
|
|
871
|
+
currency: "USD",
|
|
872
|
+
source: "PI",
|
|
873
|
+
amount: 0.000009,
|
|
874
|
+
providerId: "anthropic",
|
|
875
|
+
prices: { input: 3, output: 15 },
|
|
876
|
+
},
|
|
877
|
+
});
|
|
878
|
+
expect(messages[1].payload.modelCost.amount).toBe(0.000012);
|
|
879
|
+
}
|
|
880
|
+
finally {
|
|
881
|
+
await manager.execute(client, host, command("STOP"));
|
|
882
|
+
await manager.settled();
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
it("上线准备恢复开发历史并带入新指令;代码修改工具自动绑定执行身份", async () => {
|
|
886
|
+
await mkdir(join(testRoot, "profiles", "default", "state/runs"), { recursive: true });
|
|
887
|
+
await mkdir(join(testRoot, "profiles", "default", "pi/sessions"), { recursive: true });
|
|
888
|
+
await writeFile(join(testRoot, "profiles", "default", "pi/sessions/development.jsonl"), "{}\n");
|
|
889
|
+
await writeFile(join(testRoot, "profiles", "default", "state/runs", `${runId}.json`), JSON.stringify({
|
|
890
|
+
prepared: true,
|
|
891
|
+
phase: "DEPLOYMENT",
|
|
892
|
+
harness: "pi",
|
|
893
|
+
phaseSessions: {
|
|
894
|
+
DEVELOPMENT: "11111111-1111-7111-8111-111111111111",
|
|
895
|
+
DEPLOYMENT: "22222222-2222-7222-8222-222222222222",
|
|
896
|
+
},
|
|
897
|
+
}));
|
|
898
|
+
const session = {
|
|
899
|
+
prompt: vi.fn(() => new Promise(() => { })),
|
|
900
|
+
waitForIdle: vi.fn(),
|
|
901
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
902
|
+
subscribe: vi.fn(),
|
|
903
|
+
dispose: vi.fn(),
|
|
904
|
+
};
|
|
905
|
+
const managerSession = rememberSession(mockSessionManager("development.jsonl", "11111111-1111-7111-8111-111111111111"));
|
|
906
|
+
piMocks.openSession.mockReturnValue(managerSession);
|
|
907
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
908
|
+
const client = {
|
|
909
|
+
employeeConfig,
|
|
910
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
911
|
+
request: vi.fn().mockResolvedValue({ accepted: true }),
|
|
912
|
+
};
|
|
913
|
+
const manager = new CodingRunManager({
|
|
914
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
915
|
+
});
|
|
916
|
+
await manager.execute(client, host, command("START", {
|
|
917
|
+
runInput: {
|
|
918
|
+
...runInput,
|
|
919
|
+
executionPurpose: "RELEASE",
|
|
920
|
+
testHandoff: { summary: "已验收:目标环境部署完成且服务就绪" },
|
|
921
|
+
},
|
|
922
|
+
contentMarkdown: "按审查意见处理配置问题",
|
|
923
|
+
}));
|
|
924
|
+
expect(piMocks.openSession).toHaveBeenCalledWith(join(testRoot, "profiles", "default", "pi/sessions/development.jsonl"), expect.any(String), expect.any(String));
|
|
925
|
+
expect(session.prompt).toHaveBeenCalledWith(expect.stringContaining("按审查意见处理配置问题"));
|
|
926
|
+
expect(session.prompt).toHaveBeenCalledWith(expect.stringContaining("已验收:目标环境部署完成且服务就绪"));
|
|
927
|
+
const tools = new Map();
|
|
928
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
929
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
930
|
+
expect(Object.keys(tools.get("submit_pull_requests").parameters.properties)).toEqual([
|
|
931
|
+
"checklistSummary",
|
|
932
|
+
"projects",
|
|
933
|
+
]);
|
|
934
|
+
expect(Object.keys(tools.get("request_code_changes").parameters.properties)).toEqual([
|
|
935
|
+
"reason",
|
|
936
|
+
]);
|
|
937
|
+
// 平台接受退回会立即切换轮次;本轮已产生的工具开始等事件必须先送达。
|
|
938
|
+
let releaseEvents = () => { };
|
|
939
|
+
client.appendCodingEvents.mockImplementation(() => new Promise((resolve) => {
|
|
940
|
+
releaseEvents = () => resolve({ accepted: true });
|
|
941
|
+
}));
|
|
942
|
+
for (const [listener] of vi.mocked(session.subscribe).mock.calls)
|
|
943
|
+
listener({
|
|
944
|
+
type: "tool_execution_start",
|
|
945
|
+
toolCallId: "call",
|
|
946
|
+
toolName: "request_code_changes",
|
|
947
|
+
args: {},
|
|
948
|
+
});
|
|
949
|
+
const returned = tools
|
|
950
|
+
.get("request_code_changes")
|
|
951
|
+
.execute("call", { reason: "用户要求调整配置读取逻辑" });
|
|
952
|
+
await vi.waitFor(() => expect(client.appendCodingEvents).toHaveBeenCalledWith(runId, expect.objectContaining({
|
|
953
|
+
events: [
|
|
954
|
+
expect.objectContaining({
|
|
955
|
+
kind: "TOOL_STARTED",
|
|
956
|
+
payload: expect.objectContaining({ activityKey: "call" }),
|
|
957
|
+
}),
|
|
958
|
+
],
|
|
959
|
+
})));
|
|
960
|
+
expect(client.request).not.toHaveBeenCalled();
|
|
961
|
+
releaseEvents();
|
|
962
|
+
await returned;
|
|
963
|
+
expect(client.request).toHaveBeenCalledWith(`/api/v1/coding-runs/${runId}/return-to-development`, {
|
|
964
|
+
method: "POST",
|
|
965
|
+
body: JSON.stringify({ ...host, turnId, reason: "用户要求调整配置读取逻辑" }),
|
|
966
|
+
});
|
|
967
|
+
client.appendCodingEvents.mockResolvedValue({ accepted: true });
|
|
968
|
+
await manager.execute(client, host, command("STOP"));
|
|
969
|
+
});
|
|
970
|
+
it("开发阶段只提供开发完成工具,不需要伪造系统测试通过", async () => {
|
|
971
|
+
const session = {
|
|
972
|
+
prompt: vi.fn(() => new Promise(() => { })),
|
|
973
|
+
waitForIdle: vi.fn(),
|
|
974
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
975
|
+
subscribe: vi.fn(),
|
|
976
|
+
};
|
|
977
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("development.jsonl"));
|
|
978
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
979
|
+
const manager = new CodingRunManager({
|
|
980
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
981
|
+
});
|
|
982
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
983
|
+
const client = {
|
|
984
|
+
employeeConfig,
|
|
985
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
986
|
+
reportCodingTerminal,
|
|
987
|
+
};
|
|
988
|
+
await manager.execute(client, host, command("START", { runInput: { ...runInput, phase: "DEVELOPMENT" } }));
|
|
989
|
+
const tools = new Map();
|
|
990
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
991
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
992
|
+
expect(tools.has("complete_development")).toBe(true);
|
|
993
|
+
expect(Object.keys(tools.get("complete_development").parameters.properties)).toEqual([
|
|
994
|
+
"summary",
|
|
995
|
+
]);
|
|
996
|
+
expect(tools.has("submit_delivery")).toBe(false);
|
|
997
|
+
expect(tools.has("record_deployment_observation")).toBe(false);
|
|
998
|
+
expect(tools.has("update_question")).toBe(false);
|
|
999
|
+
await tools
|
|
1000
|
+
.get("complete_development")
|
|
1001
|
+
.execute("complete", { summary: "开发已完成并自测通过" });
|
|
1002
|
+
expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({ kind: "DEVELOPMENT_COMPLETED", summary: "开发已完成并自测通过" }));
|
|
1003
|
+
await manager.execute(client, host, command("STOP"));
|
|
1004
|
+
});
|
|
1005
|
+
it.each([
|
|
1006
|
+
{ reviewEnabled: true, remoteState: "missing", error: "AIP_REVIEW_REMOTE_BRANCH_MISSING" },
|
|
1007
|
+
{ reviewEnabled: true, remoteState: "unavailable", error: "AIP_REVIEW_REMOTE_CHECK_FAILED" },
|
|
1008
|
+
{ reviewEnabled: true, remoteState: "different", error: "AIP_REVIEW_REMOTE_HEAD_MISMATCH" },
|
|
1009
|
+
{ reviewEnabled: true, remoteState: "exact", error: undefined },
|
|
1010
|
+
{ reviewEnabled: false, remoteState: "missing", error: undefined },
|
|
1011
|
+
])("开发完成远端审查门禁 review=$reviewEnabled remote=$remoteState", async ({ reviewEnabled, remoteState, error }) => {
|
|
1012
|
+
const source = join(testRoot, `review-source-${remoteState}-${reviewEnabled}`);
|
|
1013
|
+
await mkdir(source);
|
|
1014
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
1015
|
+
await git(source, "init", "-b", "main");
|
|
1016
|
+
await writeFile(join(source, "source.txt"), "baseline\n");
|
|
1017
|
+
await git(source, "add", ".");
|
|
1018
|
+
await git(source, "-c", "user.name=AIP", "-c", "user.email=aip@test.local", "commit", "-m", "baseline");
|
|
1019
|
+
const baselineCommit = await git(source, "rev-parse", "HEAD");
|
|
1020
|
+
const project = {
|
|
1021
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
1022
|
+
name: "review-fixture",
|
|
1023
|
+
repositoryUrl: source,
|
|
1024
|
+
baselineCommit,
|
|
1025
|
+
baselineBranch: "main",
|
|
1026
|
+
devBranch: `aip/${runId}/44444444`,
|
|
1027
|
+
testBranch: "test",
|
|
1028
|
+
};
|
|
1029
|
+
const input = {
|
|
1030
|
+
...runInput,
|
|
1031
|
+
phase: "DEVELOPMENT",
|
|
1032
|
+
qualityReview: { enabled: reviewEnabled },
|
|
1033
|
+
projects: [project],
|
|
1034
|
+
primaryProjectId: project.id,
|
|
1035
|
+
};
|
|
1036
|
+
const session = {
|
|
1037
|
+
prompt: vi.fn(() => new Promise(() => { })),
|
|
1038
|
+
waitForIdle: vi.fn(),
|
|
1039
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1040
|
+
subscribe: vi.fn(),
|
|
1041
|
+
};
|
|
1042
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("review-development.jsonl"));
|
|
1043
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1044
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
1045
|
+
const client = {
|
|
1046
|
+
employeeConfig,
|
|
1047
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
1048
|
+
reportCodingTerminal,
|
|
1049
|
+
};
|
|
1050
|
+
const manager = new CodingRunManager({
|
|
1051
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1052
|
+
});
|
|
1053
|
+
await manager.execute(client, host, command("START", { runInput: input }));
|
|
1054
|
+
const cwd = join(testRoot, "profiles", "default", "workspaces", "runs", runId, project.name);
|
|
1055
|
+
const delivery = join(cwd, "docs/aip/AIP-1");
|
|
1056
|
+
for (const name of ["plan.md", "code_review.md", "report.md", "release_checklist.md"])
|
|
1057
|
+
await writeFile(join(delivery, name), "完成");
|
|
1058
|
+
await git(cwd, "add", ".");
|
|
1059
|
+
await git(cwd, "-c", "user.name=AIP", "-c", "user.email=aip@test.local", "commit", "-m", "implementation");
|
|
1060
|
+
const head = await git(cwd, "rev-parse", "HEAD");
|
|
1061
|
+
if (remoteState !== "missing") {
|
|
1062
|
+
if (remoteState === "unavailable")
|
|
1063
|
+
await rename(source, `${source}-offline`);
|
|
1064
|
+
else {
|
|
1065
|
+
if (remoteState === "exact")
|
|
1066
|
+
await git(source, "fetch", cwd, head);
|
|
1067
|
+
await git(source, "update-ref", `refs/heads/${project.devBranch}`, remoteState === "exact" ? head : baselineCommit);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
const tools = new Map();
|
|
1071
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
1072
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
1073
|
+
expect(session.prompt).not.toHaveBeenCalledWith(expect.stringContaining("不得 force push"));
|
|
1074
|
+
expect(session.prompt).toHaveBeenCalledWith(expect.stringContaining(project.devBranch));
|
|
1075
|
+
expect(session.prompt).not.toHaveBeenCalledWith(expect.stringContaining("必须提交每个项目的全部本轮改动"));
|
|
1076
|
+
expect(session.prompt).not.toHaveBeenCalledWith(expect.stringContaining("只读核对远端精确分支 SHA"));
|
|
1077
|
+
const completion = tools
|
|
1078
|
+
.get("complete_development")
|
|
1079
|
+
.execute("complete", { summary: "开发已完成并自测通过" });
|
|
1080
|
+
if (error) {
|
|
1081
|
+
await expect(completion).rejects.toThrow(error);
|
|
1082
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
1083
|
+
}
|
|
1084
|
+
else {
|
|
1085
|
+
await expect(completion).resolves.toBeDefined();
|
|
1086
|
+
expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({
|
|
1087
|
+
kind: "DEVELOPMENT_COMPLETED",
|
|
1088
|
+
projectFacts: [expect.objectContaining({ commitSha: head })],
|
|
1089
|
+
}));
|
|
1090
|
+
}
|
|
1091
|
+
await manager.execute(client, host, command("STOP"));
|
|
1092
|
+
});
|
|
1093
|
+
it.each([
|
|
1094
|
+
{ action: "START", requestId: "new-request", purpose: undefined, newRequest: true },
|
|
1095
|
+
{ action: "START", requestId: "prior-request", purpose: undefined, newRequest: false },
|
|
1096
|
+
{ action: "RESUME", requestId: "prior-request", purpose: undefined, newRequest: false },
|
|
1097
|
+
{ action: "START", requestId: "new-request", purpose: "RELEASE", newRequest: false },
|
|
1098
|
+
])("部署请求 $requestId / $action / $purpose 保留会话经验并隔离提交批次", async ({ action, requestId, purpose, newRequest }) => {
|
|
1099
|
+
await mkdir(join(testRoot, "profiles", "default", "state/runs"), { recursive: true });
|
|
1100
|
+
await mkdir(join(testRoot, "profiles", "default", "pi/sessions"), { recursive: true });
|
|
1101
|
+
const oldFile = join(testRoot, "profiles", "default", "pi/sessions/deployment.jsonl");
|
|
1102
|
+
await writeFile(oldFile, "{}\n");
|
|
1103
|
+
const stateFile = join(testRoot, "profiles", "default", "state/runs", `${runId}.json`);
|
|
1104
|
+
const oldSessionId = "11111111-1111-7111-8111-111111111111";
|
|
1105
|
+
const newSessionId = "22222222-2222-7222-8222-222222222222";
|
|
1106
|
+
await writeFile(stateFile, JSON.stringify({
|
|
1107
|
+
phase: "DEPLOYMENT",
|
|
1108
|
+
harness: "pi",
|
|
1109
|
+
deploymentRequestId: "prior-request",
|
|
1110
|
+
phaseSessions: { DEPLOYMENT: oldSessionId, DEVELOPMENT: oldSessionId },
|
|
1111
|
+
pendingDelivery: { turnId: "old-turn", submissionId: "old-batch" },
|
|
1112
|
+
}));
|
|
1113
|
+
const session = {
|
|
1114
|
+
prompt: vi.fn(() => new Promise(() => { })),
|
|
1115
|
+
waitForIdle: vi.fn(),
|
|
1116
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1117
|
+
subscribe: vi.fn(),
|
|
1118
|
+
};
|
|
1119
|
+
piMocks.openSession.mockReturnValue(rememberSession(mockSessionManager("deployment.jsonl", oldSessionId)));
|
|
1120
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("new-deployment.jsonl", newSessionId));
|
|
1121
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1122
|
+
// A new manager models Host restart: the session identity comes only from persisted state.
|
|
1123
|
+
const manager = new CodingRunManager({
|
|
1124
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1125
|
+
});
|
|
1126
|
+
await manager.execute({
|
|
1127
|
+
employeeConfig,
|
|
1128
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
1129
|
+
}, host, command(action, {
|
|
1130
|
+
runInput: { ...runInput, deploymentRequestId: requestId, executionPurpose: purpose },
|
|
1131
|
+
}));
|
|
1132
|
+
const state = JSON.parse(await readFile(stateFile, "utf8"));
|
|
1133
|
+
expect(piMocks.openSession).toHaveBeenCalled();
|
|
1134
|
+
expect(piMocks.createSession).not.toHaveBeenCalled();
|
|
1135
|
+
expect(state.phaseSessions.DEPLOYMENT).toBe(oldSessionId);
|
|
1136
|
+
if (newRequest) {
|
|
1137
|
+
expect(state.deploymentRequestId).toBe(requestId);
|
|
1138
|
+
expect(state.pendingDelivery).toBeUndefined();
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
expect(state.deploymentRequestId).toBe("prior-request");
|
|
1142
|
+
expect(state.pendingDelivery.submissionId).toBe("old-batch");
|
|
1143
|
+
}
|
|
1144
|
+
expect(state.phaseSessions.DEVELOPMENT).toBe(oldSessionId);
|
|
1145
|
+
expect(await readFile(oldFile, "utf8")).toBe("{}\n");
|
|
1146
|
+
expect(session.prompt).not.toHaveBeenCalledWith(expect.stringContaining("旧的部署成功不代表本轮完成"));
|
|
1147
|
+
});
|
|
1148
|
+
it.each(["START", "RESUME"])("%s 和纯图片追加直接传入 Pi 图片块", async (action) => {
|
|
1149
|
+
let finishPrompt;
|
|
1150
|
+
const session = {
|
|
1151
|
+
model: { input: ["text", "image"] },
|
|
1152
|
+
prompt: vi.fn(() => new Promise((resolve) => {
|
|
1153
|
+
finishPrompt = resolve;
|
|
1154
|
+
})),
|
|
1155
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1156
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1157
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1158
|
+
subscribe: vi.fn(),
|
|
1159
|
+
};
|
|
1160
|
+
const storedImageMessage = {
|
|
1161
|
+
role: "user",
|
|
1162
|
+
content: [{ type: "image", data: "prior-image", mimeType: "image/png" }],
|
|
1163
|
+
};
|
|
1164
|
+
if (action === "RESUME") {
|
|
1165
|
+
await mkdir(join(testRoot, "profiles", "default", "state", "runs"), { recursive: true });
|
|
1166
|
+
await mkdir(join(testRoot, "profiles", "default", "pi", "sessions"), { recursive: true });
|
|
1167
|
+
await writeFile(join(testRoot, "profiles", "default", "state", "runs", `${runId}.json`), JSON.stringify({
|
|
1168
|
+
phase: "DEPLOYMENT",
|
|
1169
|
+
harness: "pi",
|
|
1170
|
+
phaseSessions: { DEPLOYMENT: "11111111-1111-7111-8111-111111111111" },
|
|
1171
|
+
}));
|
|
1172
|
+
await writeFile(join(testRoot, "profiles", "default", "pi", "sessions", "image-session.jsonl"), JSON.stringify(storedImageMessage));
|
|
1173
|
+
rememberSession(mockSessionManager("image-session.jsonl"));
|
|
1174
|
+
piMocks.openSession.mockReturnValue(mockSessionManager("image-session.jsonl"));
|
|
1175
|
+
Object.assign(session, { messages: [storedImageMessage] });
|
|
1176
|
+
}
|
|
1177
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("image-session.jsonl"));
|
|
1178
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1179
|
+
const manager = new CodingRunManager({
|
|
1180
|
+
resolveRuntimeModel: vi
|
|
1181
|
+
.fn()
|
|
1182
|
+
.mockResolvedValue({ runtime: {}, model: { input: ["text", "image"] } }),
|
|
1183
|
+
});
|
|
1184
|
+
const image = { type: "image", data: "cGljdHVyZQ==", mimeType: "image/png" };
|
|
1185
|
+
const attachmentContent = vi.fn().mockResolvedValue(image);
|
|
1186
|
+
const client = {
|
|
1187
|
+
employeeConfig,
|
|
1188
|
+
attachmentContent,
|
|
1189
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
1190
|
+
};
|
|
1191
|
+
const attachments = [
|
|
1192
|
+
{
|
|
1193
|
+
id: "image-1",
|
|
1194
|
+
filename: "image.png",
|
|
1195
|
+
mediaType: "image/png",
|
|
1196
|
+
sizeBytes: 7,
|
|
1197
|
+
width: 2,
|
|
1198
|
+
height: 2,
|
|
1199
|
+
},
|
|
1200
|
+
];
|
|
1201
|
+
await manager.execute(client, {
|
|
1202
|
+
...host,
|
|
1203
|
+
hostName: "fixture-host",
|
|
1204
|
+
os: "darwin",
|
|
1205
|
+
arch: "arm64",
|
|
1206
|
+
catalogRevision: 4,
|
|
1207
|
+
}, command(action, { contentMarkdown: "", attachments }));
|
|
1208
|
+
expect(session.prompt).toHaveBeenCalledWith(expect.any(String), { images: [image] });
|
|
1209
|
+
if (action === "RESUME") {
|
|
1210
|
+
expect(piMocks.openSession).toHaveBeenCalled();
|
|
1211
|
+
expect(piMocks.createSession).not.toHaveBeenCalled();
|
|
1212
|
+
}
|
|
1213
|
+
await manager.execute(client, { ...host, hostName: "fixture-host", catalogRevision: 4 }, command("STEER", { contentMarkdown: "", attachments }));
|
|
1214
|
+
expect(session.steer).toHaveBeenCalledWith("", [image]);
|
|
1215
|
+
expect(attachmentContent).toHaveBeenCalledWith(runId, "image-1", { ...host, turnId });
|
|
1216
|
+
session.abort.mockImplementation(async () => {
|
|
1217
|
+
finishPrompt?.();
|
|
1218
|
+
});
|
|
1219
|
+
attachmentContent.mockRejectedValueOnce(new PlatformClientError(503, "IMAGE_ATTACHMENT_READ_FAILED", "图片读取失败"));
|
|
1220
|
+
await expect(manager.execute(client, host, command("STEER", { contentMarkdown: "", attachments }))).rejects.toMatchObject({ code: "IMAGE_ATTACHMENT_READ_FAILED" });
|
|
1221
|
+
expect(session.abort).toHaveBeenCalled();
|
|
1222
|
+
expect(manager.isBusy()).toBe(false);
|
|
1223
|
+
const resumedTurn = crypto.randomUUID();
|
|
1224
|
+
rememberSession(mockSessionManager("image-session.jsonl"));
|
|
1225
|
+
piMocks.openSession.mockReturnValue(mockSessionManager("image-session.jsonl"));
|
|
1226
|
+
await manager.execute(client, host, command("RESUME", { turnId: resumedTurn, contentMarkdown: "", attachments }));
|
|
1227
|
+
expect(session.prompt).toHaveBeenLastCalledWith(expect.any(String), { images: [image] });
|
|
1228
|
+
await manager.execute(client, host, command("STOP", { turnId: resumedTurn }));
|
|
1229
|
+
finishPrompt?.();
|
|
1230
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1231
|
+
});
|
|
1232
|
+
it("恢复已有图片会话时,历史图片交给 Pi 转换,不阻止非视觉模型续接", async () => {
|
|
1233
|
+
await mkdir(join(testRoot, "profiles", "default", "state", "runs"), { recursive: true });
|
|
1234
|
+
await mkdir(join(testRoot, "profiles", "default", "pi", "sessions"), { recursive: true });
|
|
1235
|
+
await writeFile(join(testRoot, "profiles", "default", "state", "runs", `${runId}.json`), JSON.stringify({
|
|
1236
|
+
phase: "DEPLOYMENT",
|
|
1237
|
+
harness: "pi",
|
|
1238
|
+
phaseSessions: { DEPLOYMENT: "11111111-1111-7111-8111-111111111111" },
|
|
1239
|
+
}));
|
|
1240
|
+
const storedImageMessage = {
|
|
1241
|
+
role: "user",
|
|
1242
|
+
content: [{ type: "image", data: "prior-image", mimeType: "image/png" }],
|
|
1243
|
+
};
|
|
1244
|
+
await writeFile(join(testRoot, "profiles", "default", "pi", "sessions", "image-session.jsonl"), JSON.stringify(storedImageMessage));
|
|
1245
|
+
const session = {
|
|
1246
|
+
model: { input: ["text"] },
|
|
1247
|
+
messages: [storedImageMessage],
|
|
1248
|
+
prompt: vi.fn().mockResolvedValue(undefined),
|
|
1249
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1250
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1251
|
+
subscribe: vi.fn(),
|
|
1252
|
+
};
|
|
1253
|
+
rememberSession(mockSessionManager("image-session.jsonl"));
|
|
1254
|
+
piMocks.openSession.mockReturnValue(mockSessionManager("image-session.jsonl"));
|
|
1255
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1256
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1257
|
+
const manager = new CodingRunManager({
|
|
1258
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: { input: ["text"] } }),
|
|
1259
|
+
});
|
|
1260
|
+
await manager.execute({
|
|
1261
|
+
employeeConfig,
|
|
1262
|
+
appendCodingEvents,
|
|
1263
|
+
reportCodingTerminal: vi.fn().mockResolvedValue({ accepted: true }),
|
|
1264
|
+
}, host, command("RESUME"));
|
|
1265
|
+
await vi.waitFor(() => expect(session.prompt).toHaveBeenCalledWith(expect.any(String)));
|
|
1266
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1267
|
+
expect(session.messages).toEqual([storedImageMessage]);
|
|
1268
|
+
expect(appendCodingEvents.mock.calls.some((call) => call[1].events[0].payload.code === "MODEL_IMAGES_UNSUPPORTED")).toBe(false);
|
|
1269
|
+
});
|
|
1270
|
+
it("非 Error 失败码与历史 Pi 一致为 PI_RUN_FAILED", async () => {
|
|
1271
|
+
const session = {
|
|
1272
|
+
prompt: vi.fn().mockResolvedValue(undefined),
|
|
1273
|
+
waitForIdle: vi.fn().mockRejectedValue("native-idle-failed"),
|
|
1274
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1275
|
+
subscribe: vi.fn(),
|
|
1276
|
+
};
|
|
1277
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("session.jsonl"));
|
|
1278
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1279
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1280
|
+
const manager = new CodingRunManager({
|
|
1281
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1282
|
+
});
|
|
1283
|
+
await manager.execute({ employeeConfig, appendCodingEvents }, host, command("START"));
|
|
1284
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls.find((call) => call[1].events[0].kind === "RUN_FAILED")?.[1]
|
|
1285
|
+
.events[0].payload.code).toBe("PI_RUN_FAILED"));
|
|
1286
|
+
});
|
|
1287
|
+
it("在真实 Pi 路径注册 reviewer 与终态工具,并实时投影会话事件", async () => {
|
|
1288
|
+
let subscriber;
|
|
1289
|
+
let finishPrompt;
|
|
1290
|
+
const prompt = vi.fn(() => new Promise((resolve) => (finishPrompt = resolve)));
|
|
1291
|
+
const session = {
|
|
1292
|
+
prompt,
|
|
1293
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1294
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1295
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1296
|
+
setAutoCompactionEnabled: vi.fn(),
|
|
1297
|
+
subscribe: vi.fn((listener) => {
|
|
1298
|
+
subscriber = listener;
|
|
1299
|
+
}),
|
|
1300
|
+
};
|
|
1301
|
+
const sessionManager = mockSessionManager("session.jsonl");
|
|
1302
|
+
piMocks.createSession.mockReturnValue(sessionManager);
|
|
1303
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1304
|
+
const resolveRuntimeModel = vi.fn().mockResolvedValue({ runtime: {}, model: {} });
|
|
1305
|
+
const manager = new CodingRunManager({ resolveRuntimeModel });
|
|
1306
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1307
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
1308
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal };
|
|
1309
|
+
await manager.execute(client, host, command("START"));
|
|
1310
|
+
await manager.execute(client, host, command("START"));
|
|
1311
|
+
await expect(manager.execute(client, host, command("STEER", { turnId: crypto.randomUUID(), contentMarkdown: "错误轮次" }))).rejects.toThrow("CODING_RUN_TURN_MISMATCH");
|
|
1312
|
+
expect(resolveRuntimeModel).toHaveBeenCalledWith("openai-codex", "gpt-test", {
|
|
1313
|
+
runId,
|
|
1314
|
+
turnId,
|
|
1315
|
+
hostId: host.hostId,
|
|
1316
|
+
generation: host.generation,
|
|
1317
|
+
});
|
|
1318
|
+
expect(prompt).not.toHaveBeenCalledWith(expect.stringContaining("需要业务判断时在聊天正文自然提问"));
|
|
1319
|
+
expect(prompt).toHaveBeenCalledWith(expect.stringContaining("当前阶段:DEPLOYMENT"));
|
|
1320
|
+
expect(prompt).toHaveBeenCalledWith(expect.stringContaining("当前阶段:DEPLOYMENT"));
|
|
1321
|
+
expect(prompt).not.toHaveBeenCalledWith(expect.stringContaining("首次复核未通过可排障一次"));
|
|
1322
|
+
const registeredTools = new Map();
|
|
1323
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
1324
|
+
expect(factories).toHaveLength(3);
|
|
1325
|
+
factories[0]({ registerTool: vi.fn() });
|
|
1326
|
+
factories.at(-2)({
|
|
1327
|
+
registerTool: (tool) => registeredTools.set(tool.name, tool),
|
|
1328
|
+
});
|
|
1329
|
+
expect(registeredTools.has("report_blocker")).toBe(false);
|
|
1330
|
+
expect(registeredTools.has("request_code_changes")).toBe(true);
|
|
1331
|
+
expect(Object.keys(registeredTools.get("request_code_changes").parameters.properties)).toEqual([
|
|
1332
|
+
"reason",
|
|
1333
|
+
]);
|
|
1334
|
+
expect(registeredTools.get("request_code_changes").description).not.toContain("测试分支合并冲突");
|
|
1335
|
+
expect(registeredTools.has("complete_development")).toBe(false);
|
|
1336
|
+
expect(registeredTools.has("submit_delivery")).toBe(true);
|
|
1337
|
+
expect(subagentMocks.options.agents).toEqual([]);
|
|
1338
|
+
subscriber?.({ type: "message_start", message: { role: "assistant" } });
|
|
1339
|
+
subscriber?.({
|
|
1340
|
+
type: "message_update",
|
|
1341
|
+
assistantMessageEvent: { type: "text_delta", delta: "正在实现" },
|
|
1342
|
+
});
|
|
1343
|
+
subscriber?.({
|
|
1344
|
+
type: "message_update",
|
|
1345
|
+
assistantMessageEvent: { type: "text_delta", delta: ",准备审查" },
|
|
1346
|
+
});
|
|
1347
|
+
subagentMocks.options.started("review-1", "backend");
|
|
1348
|
+
await subagentMocks.options.emit("SUBAGENT_STARTED", {
|
|
1349
|
+
activityKey: "review-1",
|
|
1350
|
+
agentId: "backend",
|
|
1351
|
+
});
|
|
1352
|
+
await subagentMocks.options.emit("SUBAGENT_UPDATED", {
|
|
1353
|
+
activityKey: "review-1",
|
|
1354
|
+
agentId: "backend",
|
|
1355
|
+
currentAction: `检查 ${testRoot}/secret.ts`,
|
|
1356
|
+
});
|
|
1357
|
+
await subagentMocks.options.completed("review-1", "backend");
|
|
1358
|
+
await subagentMocks.options.emit("SUBAGENT_COMPLETED", {
|
|
1359
|
+
activityKey: "review-1",
|
|
1360
|
+
agentId: "backend",
|
|
1361
|
+
summary: `审查 ${testRoot}/secret.ts 通过`,
|
|
1362
|
+
});
|
|
1363
|
+
subscriber?.({
|
|
1364
|
+
type: "tool_execution_start",
|
|
1365
|
+
toolName: "subagent",
|
|
1366
|
+
toolCallId: "review-1",
|
|
1367
|
+
args: { agent: "backend" },
|
|
1368
|
+
});
|
|
1369
|
+
subscriber?.({
|
|
1370
|
+
type: "tool_execution_update",
|
|
1371
|
+
toolName: "subagent",
|
|
1372
|
+
toolCallId: "review-1",
|
|
1373
|
+
args: { agent: "backend" },
|
|
1374
|
+
partialResult: { content: [{ type: "text", text: `检查 ${testRoot}/secret.ts` }] },
|
|
1375
|
+
});
|
|
1376
|
+
subscriber?.({
|
|
1377
|
+
type: "tool_execution_end",
|
|
1378
|
+
toolName: "subagent",
|
|
1379
|
+
toolCallId: "review-1",
|
|
1380
|
+
isError: false,
|
|
1381
|
+
result: { content: [{ type: "text", text: `审查 ${testRoot}/secret.ts 通过` }], details: {} },
|
|
1382
|
+
});
|
|
1383
|
+
subscriber?.({
|
|
1384
|
+
type: "bash_execution_update",
|
|
1385
|
+
id: "bash-1",
|
|
1386
|
+
delta: "progress-1\n",
|
|
1387
|
+
});
|
|
1388
|
+
subscriber?.({ type: "compaction_start", reason: "threshold" });
|
|
1389
|
+
subscriber?.({
|
|
1390
|
+
type: "compaction_end",
|
|
1391
|
+
reason: "threshold",
|
|
1392
|
+
aborted: false,
|
|
1393
|
+
willRetry: false,
|
|
1394
|
+
result: { summary: "已压缩早期工具结果", firstKeptEntryId: "keep", tokensBefore: 80_000 },
|
|
1395
|
+
});
|
|
1396
|
+
subscriber?.({
|
|
1397
|
+
type: "message_end",
|
|
1398
|
+
message: {
|
|
1399
|
+
role: "assistant",
|
|
1400
|
+
content: [{ type: "text", text: `开发完成:${testRoot}/secret.ts TOKEN=top-secret` }],
|
|
1401
|
+
usage: { input: 12, output: 4, cacheRead: 0, cacheWrite: 0, totalTokens: 16 },
|
|
1402
|
+
},
|
|
1403
|
+
});
|
|
1404
|
+
await writeArtifacts(manager);
|
|
1405
|
+
await registeredTools.get("submit_delivery").execute("tool-3", { summary: "完成" });
|
|
1406
|
+
await manager.execute(client, host, command("STEER", { contentMarkdown: "补充边界测试" }));
|
|
1407
|
+
expect(session.steer).toHaveBeenCalledWith("补充边界测试");
|
|
1408
|
+
expect(appendCodingEvents.mock.calls
|
|
1409
|
+
.map((call) => call[1].events[0])
|
|
1410
|
+
.filter((event) => event.kind === "MESSAGE_QUEUE_UPDATED")).toMatchObject([{ turnId, payload: { deliveryStatus: "QUEUED" } }]);
|
|
1411
|
+
// Native Pi preserves the queued message object when it emits message_start.
|
|
1412
|
+
subscriber?.({
|
|
1413
|
+
type: "message_start",
|
|
1414
|
+
message: session.queuedInput,
|
|
1415
|
+
});
|
|
1416
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls
|
|
1417
|
+
.map((call) => call[1].events[0])
|
|
1418
|
+
.filter((event) => event.kind === "MESSAGE_QUEUE_UPDATED")).toMatchObject([
|
|
1419
|
+
{ turnId, payload: { deliveryStatus: "QUEUED" } },
|
|
1420
|
+
{ turnId, payload: { deliveryStatus: "READ" } },
|
|
1421
|
+
]));
|
|
1422
|
+
subagentMocks.options.started("review-2", "backend");
|
|
1423
|
+
await subagentMocks.options.emit("SUBAGENT_STARTED", {
|
|
1424
|
+
activityKey: "review-2",
|
|
1425
|
+
agentId: "backend",
|
|
1426
|
+
});
|
|
1427
|
+
subscriber?.({
|
|
1428
|
+
type: "tool_execution_start",
|
|
1429
|
+
toolName: "subagent",
|
|
1430
|
+
toolCallId: "review-2",
|
|
1431
|
+
args: { agent: "backend" },
|
|
1432
|
+
});
|
|
1433
|
+
await manager.execute(client, host, command("STOP"));
|
|
1434
|
+
expect(session.abort).toHaveBeenCalledOnce();
|
|
1435
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls.map((call) => call[1].events[0].kind)).toEqual(expect.arrayContaining([
|
|
1436
|
+
"RUN_STARTED",
|
|
1437
|
+
"MESSAGE_STARTED",
|
|
1438
|
+
"TEXT_DELTA",
|
|
1439
|
+
"SUBAGENT_STARTED",
|
|
1440
|
+
"SUBAGENT_UPDATED",
|
|
1441
|
+
"SUBAGENT_COMPLETED",
|
|
1442
|
+
"SUBAGENT_STOPPED",
|
|
1443
|
+
"TOOL_UPDATED",
|
|
1444
|
+
"TOOL_STARTED",
|
|
1445
|
+
"TOOL_COMPLETED",
|
|
1446
|
+
"MESSAGE_COMPLETED",
|
|
1447
|
+
"MESSAGE_QUEUE_UPDATED",
|
|
1448
|
+
"RUN_STOPPED",
|
|
1449
|
+
])));
|
|
1450
|
+
expect(reportCodingTerminal.mock.calls.map((call) => call[1].kind)).toEqual(["DELIVERY"]);
|
|
1451
|
+
expect(appendCodingEvents.mock.calls.every((call) => call[1].events[0].turnId === turnId)).toBe(true);
|
|
1452
|
+
expect(reportCodingTerminal.mock.calls.every((call) => call[1].turnId === turnId)).toBe(true);
|
|
1453
|
+
expect(appendCodingEvents.mock.calls.filter((call) => call[1].events[0].kind === "TEXT_DELTA")).toHaveLength(1);
|
|
1454
|
+
expect(appendCodingEvents.mock.calls.find((call) => call[1].events[0].kind === "TEXT_DELTA")?.[1]
|
|
1455
|
+
.events[0].payload.text).toBe("正在实现,准备审查");
|
|
1456
|
+
expect(JSON.stringify([appendCodingEvents.mock.calls, reportCodingTerminal.mock.calls])).not.toContain(testRoot);
|
|
1457
|
+
expect(JSON.stringify([appendCodingEvents.mock.calls, reportCodingTerminal.mock.calls])).not.toContain("top-secret");
|
|
1458
|
+
expect(session.setAutoCompactionEnabled).toHaveBeenCalledWith(true);
|
|
1459
|
+
expect(appendCodingEvents.mock.calls.find((call) => call[1].events[0].kind === "TOOL_UPDATED" &&
|
|
1460
|
+
call[1].events[0].payload.toolName === "bash")?.[1].events[0].payload.currentAction).toBe("progress-1\n");
|
|
1461
|
+
expect(appendCodingEvents.mock.calls.find((call) => call[1].events[0].kind === "TOOL_STARTED" &&
|
|
1462
|
+
call[1].events[0].payload.toolName === "compaction")).toBeTruthy();
|
|
1463
|
+
expect(appendCodingEvents.mock.calls.find((call) => call[1].events[0].kind === "MESSAGE_COMPLETED")?.[1].events[0].payload.usage).toEqual({ input: 12, output: 4, cacheRead: 0, cacheWrite: 0, totalTokens: 16 });
|
|
1464
|
+
expect(sessionManager.appendCustomEntry).toHaveBeenCalledWith("aip-run-binding", { runId });
|
|
1465
|
+
finishPrompt?.();
|
|
1466
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1467
|
+
});
|
|
1468
|
+
it("把 overflow 压缩开始/结束和有界失败投影为 compaction 工具事件", async () => {
|
|
1469
|
+
let subscriber;
|
|
1470
|
+
let finishPrompt;
|
|
1471
|
+
const session = {
|
|
1472
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
1473
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1474
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1475
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1476
|
+
subscribe: vi.fn((listener) => {
|
|
1477
|
+
subscriber = listener;
|
|
1478
|
+
}),
|
|
1479
|
+
};
|
|
1480
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("overflow-session.jsonl"));
|
|
1481
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1482
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1483
|
+
const manager = new CodingRunManager({
|
|
1484
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1485
|
+
});
|
|
1486
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
1487
|
+
await manager.execute(client, host, command("START"));
|
|
1488
|
+
subscriber?.({ type: "compaction_start", reason: "overflow" });
|
|
1489
|
+
subscriber?.({
|
|
1490
|
+
type: "compaction_end",
|
|
1491
|
+
reason: "overflow",
|
|
1492
|
+
aborted: false,
|
|
1493
|
+
willRetry: true,
|
|
1494
|
+
result: { summary: "已压缩超限上下文", tokensBefore: 40_000 },
|
|
1495
|
+
});
|
|
1496
|
+
subscriber?.({
|
|
1497
|
+
type: "compaction_end",
|
|
1498
|
+
reason: "overflow",
|
|
1499
|
+
aborted: false,
|
|
1500
|
+
willRetry: false,
|
|
1501
|
+
errorMessage: "Context overflow recovery failed after one compact-and-retry attempt.",
|
|
1502
|
+
});
|
|
1503
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls.filter((call) => call[1].events[0].payload?.toolName === "compaction")).toHaveLength(3));
|
|
1504
|
+
const compaction = appendCodingEvents.mock.calls
|
|
1505
|
+
.map((call) => call[1].events[0])
|
|
1506
|
+
.filter((event) => event.payload?.toolName === "compaction");
|
|
1507
|
+
expect(compaction).toMatchObject([
|
|
1508
|
+
{ kind: "TOOL_STARTED", payload: { summary: "上下文压缩(overflow)" } },
|
|
1509
|
+
{ kind: "TOOL_COMPLETED", payload: { isError: false, summary: "已压缩超限上下文" } },
|
|
1510
|
+
{
|
|
1511
|
+
kind: "TOOL_COMPLETED",
|
|
1512
|
+
payload: {
|
|
1513
|
+
isError: true,
|
|
1514
|
+
summary: "Context overflow recovery failed after one compact-and-retry attempt.",
|
|
1515
|
+
},
|
|
1516
|
+
},
|
|
1517
|
+
]);
|
|
1518
|
+
await manager.execute(client, host, command("STOP"));
|
|
1519
|
+
finishPrompt?.();
|
|
1520
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1521
|
+
});
|
|
1522
|
+
it("交付后的新 turn 隔离上一轮尾部事件并继续原 Pi Session", async () => {
|
|
1523
|
+
const nextTurnId = "66666666-6666-4666-8666-666666666666";
|
|
1524
|
+
let firstSubscriber;
|
|
1525
|
+
let secondSubscriber;
|
|
1526
|
+
let finishFirst;
|
|
1527
|
+
let finishSecond;
|
|
1528
|
+
const firstSession = {
|
|
1529
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishFirst = resolve))),
|
|
1530
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1531
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1532
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1533
|
+
subscribe: vi.fn((listener) => {
|
|
1534
|
+
firstSubscriber = listener;
|
|
1535
|
+
return vi.fn();
|
|
1536
|
+
}),
|
|
1537
|
+
};
|
|
1538
|
+
const secondSession = {
|
|
1539
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishSecond = resolve))),
|
|
1540
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1541
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1542
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1543
|
+
subscribe: vi.fn((listener) => {
|
|
1544
|
+
secondSubscriber = listener;
|
|
1545
|
+
return vi.fn();
|
|
1546
|
+
}),
|
|
1547
|
+
};
|
|
1548
|
+
const sessionManager = mockSessionManager("turn-rollover.jsonl");
|
|
1549
|
+
piMocks.createSession.mockReturnValue(sessionManager);
|
|
1550
|
+
rememberSession(sessionManager);
|
|
1551
|
+
piMocks.openSession.mockReturnValue(sessionManager);
|
|
1552
|
+
piMocks.createAgentSession
|
|
1553
|
+
.mockResolvedValueOnce({ session: firstSession })
|
|
1554
|
+
.mockResolvedValueOnce({ session: secondSession });
|
|
1555
|
+
let platformTurnId = turnId;
|
|
1556
|
+
const appendCodingEvents = vi.fn(async (_runId, input) => {
|
|
1557
|
+
if (input.events[0]?.turnId !== platformTurnId)
|
|
1558
|
+
throw new PlatformClientError(409, "CODING_EVENT_TURN_STALE", "Coding Run 事件不属于当前执行轮次");
|
|
1559
|
+
return { accepted: true };
|
|
1560
|
+
});
|
|
1561
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
1562
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal };
|
|
1563
|
+
const manager = new CodingRunManager({
|
|
1564
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1565
|
+
});
|
|
1566
|
+
await manager.execute(client, host, command("START"));
|
|
1567
|
+
await subagentMocks.options.emit("SUBAGENT_COMPLETED", {
|
|
1568
|
+
activityKey: "review-old-turn",
|
|
1569
|
+
agentId: "backend",
|
|
1570
|
+
});
|
|
1571
|
+
firstSubscriber?.({
|
|
1572
|
+
type: "tool_execution_end",
|
|
1573
|
+
toolName: "subagent",
|
|
1574
|
+
toolCallId: "review-old-turn",
|
|
1575
|
+
isError: false,
|
|
1576
|
+
result: { details: { agent: "backend" } },
|
|
1577
|
+
});
|
|
1578
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls.some((call) => call[1].events[0]?.kind === "SUBAGENT_COMPLETED")).toBe(true));
|
|
1579
|
+
const tools = new Map();
|
|
1580
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
1581
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
1582
|
+
await writeArtifacts(manager);
|
|
1583
|
+
await tools.get("submit_delivery").execute("deliver-old-turn", { summary: "首轮完成" });
|
|
1584
|
+
platformTurnId = nextTurnId;
|
|
1585
|
+
const hostLog = vi.spyOn(process.stderr, "write");
|
|
1586
|
+
await manager.execute(client, host, command("STEER", { turnId: nextTurnId, contentMarkdown: "你好" }));
|
|
1587
|
+
firstSubscriber?.({
|
|
1588
|
+
type: "message_update",
|
|
1589
|
+
assistantMessageEvent: { type: "text_delta", delta: "上一轮迟到" },
|
|
1590
|
+
});
|
|
1591
|
+
firstSubscriber?.({
|
|
1592
|
+
type: "message_end",
|
|
1593
|
+
message: { role: "assistant", content: [{ type: "text", text: "上一轮迟到消息" }] },
|
|
1594
|
+
});
|
|
1595
|
+
secondSubscriber?.({ type: "message_start", message: { role: "assistant" } });
|
|
1596
|
+
secondSubscriber?.({
|
|
1597
|
+
type: "message_end",
|
|
1598
|
+
message: { role: "assistant", content: [{ type: "text", text: "你好,已收到。" }] },
|
|
1599
|
+
});
|
|
1600
|
+
await vi.waitFor(() => expect(appendCodingEvents.mock.calls.some((call) => call[1].events[0]?.turnId === nextTurnId &&
|
|
1601
|
+
call[1].events[0]?.kind === "MESSAGE_COMPLETED" &&
|
|
1602
|
+
call[1].events[0]?.payload.contentMarkdown === "你好,已收到。")).toBe(true));
|
|
1603
|
+
// 被拒的旧轮事件留下可核对的标识(不含正文),并且没有被平台接受。
|
|
1604
|
+
const stale = hostLog.mock.calls
|
|
1605
|
+
.map(([line]) => String(line))
|
|
1606
|
+
.filter((line) => line.includes('"event":"coding_event_turn_stale"'))
|
|
1607
|
+
.map((line) => JSON.parse(line));
|
|
1608
|
+
hostLog.mockRestore();
|
|
1609
|
+
expect(stale).toContainEqual(expect.objectContaining({
|
|
1610
|
+
runId,
|
|
1611
|
+
turnId,
|
|
1612
|
+
kind: "MESSAGE_COMPLETED",
|
|
1613
|
+
sequence: expect.any(Number),
|
|
1614
|
+
}));
|
|
1615
|
+
expect(JSON.stringify(stale)).not.toContain("上一轮迟到消息");
|
|
1616
|
+
const staleEvents = appendCodingEvents.mock.calls
|
|
1617
|
+
.map((call) => call[1].events[0])
|
|
1618
|
+
.filter((event) => event?.turnId === turnId)
|
|
1619
|
+
.map((event) => event?.kind);
|
|
1620
|
+
expect(staleEvents).toEqual(expect.arrayContaining(["TEXT_DELTA", "MESSAGE_COMPLETED"]));
|
|
1621
|
+
expect(firstSession.abort).toHaveBeenCalledOnce();
|
|
1622
|
+
expect(secondSession.prompt).toHaveBeenCalledWith(expect.stringContaining("你好"));
|
|
1623
|
+
expect(secondSession.prompt).toHaveBeenCalledWith(expect.stringMatching(/[\\/]prd\.md/u));
|
|
1624
|
+
expect(secondSession.prompt).not.toHaveBeenCalledWith(expect.stringContaining("首次复核未通过可排障一次"));
|
|
1625
|
+
await subagentMocks.options.emit("SUBAGENT_COMPLETED", {
|
|
1626
|
+
activityKey: "review-new-turn",
|
|
1627
|
+
agentId: "backend",
|
|
1628
|
+
});
|
|
1629
|
+
secondSubscriber?.({
|
|
1630
|
+
type: "tool_execution_end",
|
|
1631
|
+
toolName: "subagent",
|
|
1632
|
+
toolCallId: "review-new-turn",
|
|
1633
|
+
isError: false,
|
|
1634
|
+
result: { details: { agent: "backend" } },
|
|
1635
|
+
});
|
|
1636
|
+
const nextTools = new Map();
|
|
1637
|
+
const nextFactories = piMocks.loaderOptions?.extensionFactories;
|
|
1638
|
+
nextFactories.at(-2)({
|
|
1639
|
+
registerTool: (tool) => nextTools.set(tool.name, tool),
|
|
1640
|
+
});
|
|
1641
|
+
const newReviewerEvent = await vi.waitFor(() => {
|
|
1642
|
+
const event = appendCodingEvents.mock.calls
|
|
1643
|
+
.map((call) => call[1].events[0])
|
|
1644
|
+
.find((event) => event?.turnId === nextTurnId && event.kind === "SUBAGENT_COMPLETED");
|
|
1645
|
+
expect(event).toBeDefined();
|
|
1646
|
+
return event;
|
|
1647
|
+
});
|
|
1648
|
+
await writeArtifacts(manager);
|
|
1649
|
+
await nextTools.get("submit_delivery").execute("deliver-new-turn", { summary: "补充交付完成" });
|
|
1650
|
+
expect(reportCodingTerminal).toHaveBeenLastCalledWith(runId, expect.objectContaining({ turnId: nextTurnId, kind: "DELIVERY" }));
|
|
1651
|
+
expect(manager.isBusy()).toBe(true);
|
|
1652
|
+
finishFirst?.();
|
|
1653
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(true));
|
|
1654
|
+
await vi.waitFor(async () => {
|
|
1655
|
+
const state = JSON.parse(await readFile(join(testRoot, "profiles", "default", "state", "runs", `${runId}.json`), "utf8"));
|
|
1656
|
+
expect(state.lastEventSequence).toBe(newReviewerEvent?.sequence);
|
|
1657
|
+
});
|
|
1658
|
+
finishSecond?.();
|
|
1659
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1660
|
+
});
|
|
1661
|
+
it("只有 Pi Session 文件真实落盘后才发布 RUN_STARTED", async () => {
|
|
1662
|
+
const sessionFile = join(testRoot, "not-persisted.jsonl");
|
|
1663
|
+
piMocks.createSession.mockReturnValue({
|
|
1664
|
+
setSessionFile: vi.fn(() => rmSync(sessionFile, { force: true })),
|
|
1665
|
+
appendCustomEntry: vi.fn(),
|
|
1666
|
+
getSessionFile: () => sessionFile,
|
|
1667
|
+
getSessionId: () => "11111111-1111-7111-8111-111111111111",
|
|
1668
|
+
});
|
|
1669
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1670
|
+
const manager = new CodingRunManager({
|
|
1671
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1672
|
+
});
|
|
1673
|
+
await expect(manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() }, host, command("START"))).rejects.toThrow("PI_SESSION_FILE_NOT_PERSISTED");
|
|
1674
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
1675
|
+
expect(appendCodingEvents).not.toHaveBeenCalled();
|
|
1676
|
+
});
|
|
1677
|
+
it("新 Host 进程从已落盘绑定恢复同一个 Pi Session", async () => {
|
|
1678
|
+
let finishFirst;
|
|
1679
|
+
let finishSecond;
|
|
1680
|
+
const firstSession = {
|
|
1681
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishFirst = resolve))),
|
|
1682
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1683
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1684
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1685
|
+
subscribe: vi.fn(),
|
|
1686
|
+
};
|
|
1687
|
+
const secondSession = {
|
|
1688
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishSecond = resolve))),
|
|
1689
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
1690
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
1691
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1692
|
+
subscribe: vi.fn(),
|
|
1693
|
+
};
|
|
1694
|
+
const sessionManager = mockSessionManager("stable-session.jsonl");
|
|
1695
|
+
piMocks.createSession.mockReturnValue(sessionManager);
|
|
1696
|
+
rememberSession(sessionManager);
|
|
1697
|
+
piMocks.openSession.mockReturnValue({
|
|
1698
|
+
getSessionFile: sessionManager.getSessionFile,
|
|
1699
|
+
getSessionId: sessionManager.getSessionId,
|
|
1700
|
+
});
|
|
1701
|
+
piMocks.createAgentSession
|
|
1702
|
+
.mockResolvedValueOnce({ session: firstSession })
|
|
1703
|
+
.mockResolvedValueOnce({ session: secondSession });
|
|
1704
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1705
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
1706
|
+
const runtime = {
|
|
1707
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1708
|
+
};
|
|
1709
|
+
const firstManager = new CodingRunManager(runtime);
|
|
1710
|
+
const secondManager = new CodingRunManager(runtime);
|
|
1711
|
+
await firstManager.execute(client, host, command("START"));
|
|
1712
|
+
await secondManager.execute(client, host, command("RESUME"));
|
|
1713
|
+
expect(piMocks.openSession).toHaveBeenCalledWith(sessionManager.getSessionFile(), join(testRoot, "profiles", "default", "pi", "sessions"), expect.any(String));
|
|
1714
|
+
expect(appendCodingEvents.mock.calls
|
|
1715
|
+
.filter((call) => call[1].events[0].kind === "RUN_STARTED")
|
|
1716
|
+
.map((call) => call[1].events[0].payload.sessionRef)).toEqual(["11111111-1111-7111-8111-111111111111", "11111111-1111-7111-8111-111111111111"]);
|
|
1717
|
+
await firstManager.execute(client, host, command("STOP"));
|
|
1718
|
+
finishFirst?.();
|
|
1719
|
+
await vi.waitFor(() => expect(firstManager.isBusy()).toBe(false));
|
|
1720
|
+
await secondManager.execute(client, host, command("STOP"));
|
|
1721
|
+
finishSecond?.();
|
|
1722
|
+
await vi.waitFor(() => expect(secondManager.isBusy()).toBe(false));
|
|
1723
|
+
});
|
|
1724
|
+
it.each(["WAIT", "SKIP"])("平台判断 %s 后自然结束,不合成 blocker 或发续跑", async (decision) => {
|
|
1725
|
+
let listener;
|
|
1726
|
+
const session = {
|
|
1727
|
+
prompt: vi.fn(async () => {
|
|
1728
|
+
const tools = new Map();
|
|
1729
|
+
piMocks.loaderOptions.extensionFactories[1]({
|
|
1730
|
+
registerTool: (tool) => tools.set(tool.name, tool),
|
|
1731
|
+
});
|
|
1732
|
+
expect(tools.has("update_question")).toBe(false);
|
|
1733
|
+
expect(tools.has("report_blocker")).toBe(false);
|
|
1734
|
+
expect(tools.has("begin_execution")).toBe(false);
|
|
1735
|
+
listener?.({
|
|
1736
|
+
type: "message_end",
|
|
1737
|
+
message: {
|
|
1738
|
+
role: "assistant",
|
|
1739
|
+
stopReason: "stop",
|
|
1740
|
+
content: [{ type: "text", text: "采用哪条计费规则?" }],
|
|
1741
|
+
},
|
|
1742
|
+
});
|
|
1743
|
+
}),
|
|
1744
|
+
subscribe: vi.fn((value) => {
|
|
1745
|
+
listener = value;
|
|
1746
|
+
}),
|
|
1747
|
+
};
|
|
1748
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("wait.jsonl"));
|
|
1749
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1750
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1751
|
+
const reportCodingTerminal = vi.fn();
|
|
1752
|
+
const evaluateContinuation = vi.fn(async () => {
|
|
1753
|
+
expect(appendCodingEvents.mock.calls.flatMap((call) => call[1].events)).toContainEqual(expect.objectContaining({ kind: "MESSAGE_COMPLETED" }));
|
|
1754
|
+
return {
|
|
1755
|
+
decision,
|
|
1756
|
+
reason: decision === "WAIT" ? "NEEDS_USER_INPUT" : "USER_MESSAGE",
|
|
1757
|
+
explanation: "等待规则确认",
|
|
1758
|
+
model: decision === "WAIT" ? "Mandao/DeepSeek-V4-Flash" : null,
|
|
1759
|
+
auditId: "audit-1",
|
|
1760
|
+
attempt: 0,
|
|
1761
|
+
maxAttempts: 2,
|
|
1762
|
+
prompt: null,
|
|
1763
|
+
commandId: null,
|
|
1764
|
+
autoContinueEnabled: decision === "WAIT",
|
|
1765
|
+
};
|
|
1766
|
+
});
|
|
1767
|
+
const manager = new CodingRunManager({
|
|
1768
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1769
|
+
});
|
|
1770
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal, evaluateContinuation }, { ...host, fingerprint: "device-fingerprint", hostName: "test-host" }, command("START"));
|
|
1771
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1772
|
+
expect(session.prompt).toHaveBeenCalledOnce();
|
|
1773
|
+
expect(evaluateContinuation).toHaveBeenCalledOnce();
|
|
1774
|
+
expect(evaluateContinuation).toHaveBeenCalledWith(expect.any(String), {
|
|
1775
|
+
hostId: host.hostId,
|
|
1776
|
+
generation: host.generation,
|
|
1777
|
+
turnId: expect.any(String),
|
|
1778
|
+
stopReason: "stop",
|
|
1779
|
+
});
|
|
1780
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
1781
|
+
const events = appendCodingEvents.mock.calls.flatMap((call) => call[1].events);
|
|
1782
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1783
|
+
kind: "EXECUTION_DECIDED",
|
|
1784
|
+
payload: expect.objectContaining({ decision, auditId: "audit-1" }),
|
|
1785
|
+
}));
|
|
1786
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1787
|
+
kind: "CONVERSATION_COMPLETED",
|
|
1788
|
+
payload: { workspaceChanged: false },
|
|
1789
|
+
}));
|
|
1790
|
+
expect(events.some((event) => event.kind === "EXECUTION_CONTINUED")).toBe(false);
|
|
1791
|
+
});
|
|
1792
|
+
it.each(["WAIT", "CONTINUE", "ERROR"])("子任务唤醒主管后,迟到的 %s 判断不能关闭新执行", async (decision) => {
|
|
1793
|
+
let listener = () => { };
|
|
1794
|
+
let finishJudge;
|
|
1795
|
+
let failJudge;
|
|
1796
|
+
let finishNative;
|
|
1797
|
+
const native = new Promise((resolve) => {
|
|
1798
|
+
finishNative = resolve;
|
|
1799
|
+
});
|
|
1800
|
+
const session = {
|
|
1801
|
+
prompt: vi.fn().mockResolvedValue(undefined),
|
|
1802
|
+
subscribe: vi.fn((value) => {
|
|
1803
|
+
listener = value;
|
|
1804
|
+
}),
|
|
1805
|
+
waitForIdle: vi
|
|
1806
|
+
.fn()
|
|
1807
|
+
.mockResolvedValueOnce(undefined)
|
|
1808
|
+
.mockImplementation(() => native),
|
|
1809
|
+
dispose: vi.fn(),
|
|
1810
|
+
};
|
|
1811
|
+
const dispose = session.dispose;
|
|
1812
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("notify-during-judge.jsonl"));
|
|
1813
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1814
|
+
const evaluateContinuation = vi
|
|
1815
|
+
.fn()
|
|
1816
|
+
.mockImplementationOnce(() => new Promise((resolve, reject) => {
|
|
1817
|
+
finishJudge = resolve;
|
|
1818
|
+
failJudge = reject;
|
|
1819
|
+
}))
|
|
1820
|
+
.mockResolvedValue({ decision: "WAIT", reason: "USER_DECISION" });
|
|
1821
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1822
|
+
const manager = new CodingRunManager({
|
|
1823
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1824
|
+
});
|
|
1825
|
+
const client = { employeeConfig, appendCodingEvents, evaluateContinuation };
|
|
1826
|
+
await manager.execute(client, host, command("START"));
|
|
1827
|
+
await vi.waitFor(() => expect(evaluateContinuation).toHaveBeenCalledOnce());
|
|
1828
|
+
listener({ type: "agent_start" });
|
|
1829
|
+
if (decision === "ERROR")
|
|
1830
|
+
failJudge(new Error("connection lost"));
|
|
1831
|
+
else
|
|
1832
|
+
finishJudge({ decision, auditId: "obsolete", reason: "NO_SAFE_ACTION" });
|
|
1833
|
+
await vi.waitFor(() => expect(session.waitForIdle).toHaveBeenCalledTimes(2));
|
|
1834
|
+
expect(manager.isBusy()).toBe(true);
|
|
1835
|
+
expect(dispose).not.toHaveBeenCalled();
|
|
1836
|
+
expect(appendCodingEvents.mock.calls
|
|
1837
|
+
.flatMap((call) => call[1].events)
|
|
1838
|
+
.some((event) => event.kind === "CONVERSATION_COMPLETED")).toBe(false);
|
|
1839
|
+
const staleCommand = decision === "CONTINUE"
|
|
1840
|
+
? manager.execute(client, host, command("CONTINUE", {
|
|
1841
|
+
contentMarkdown: "旧判断要求继续",
|
|
1842
|
+
continuation: { auditId: "obsolete", attempt: 1, maxAttempts: 2 },
|
|
1843
|
+
}))
|
|
1844
|
+
: Promise.resolve();
|
|
1845
|
+
finishNative();
|
|
1846
|
+
await staleCommand;
|
|
1847
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1848
|
+
expect(evaluateContinuation).toHaveBeenCalledTimes(2);
|
|
1849
|
+
expect(session.prompt).toHaveBeenCalledOnce();
|
|
1850
|
+
expect(dispose).toHaveBeenCalledOnce();
|
|
1851
|
+
});
|
|
1852
|
+
it("CONTINUE 判断只排队,领取平台命令后才续跑并提交", async () => {
|
|
1853
|
+
const session = {
|
|
1854
|
+
prompt: vi.fn(async () => {
|
|
1855
|
+
if (session.prompt.mock.calls.length === 1)
|
|
1856
|
+
return;
|
|
1857
|
+
const tools = new Map();
|
|
1858
|
+
piMocks.loaderOptions.extensionFactories[1]({
|
|
1859
|
+
registerTool: (tool) => tools.set(tool.name, tool),
|
|
1860
|
+
});
|
|
1861
|
+
await tools
|
|
1862
|
+
.get("submit_delivery")
|
|
1863
|
+
.execute("finish", { summary: "本轮部署完成,服务已就绪" });
|
|
1864
|
+
}),
|
|
1865
|
+
subscribe: vi.fn(),
|
|
1866
|
+
};
|
|
1867
|
+
const stored = rememberSession(mockSessionManager("continue.jsonl"));
|
|
1868
|
+
piMocks.createSession.mockReturnValue(stored);
|
|
1869
|
+
piMocks.openSession.mockReturnValue(stored);
|
|
1870
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1871
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1872
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
1873
|
+
const evaluateContinuation = vi.fn().mockResolvedValue({
|
|
1874
|
+
decision: "CONTINUE",
|
|
1875
|
+
reason: "GOAL_NOT_MET_YET",
|
|
1876
|
+
explanation: "还需完成测试",
|
|
1877
|
+
model: "Mandao/DeepSeek-V4-Flash",
|
|
1878
|
+
auditId: "audit-2",
|
|
1879
|
+
attempt: 1,
|
|
1880
|
+
maxAttempts: 2,
|
|
1881
|
+
prompt: "完成剩余测试后提交",
|
|
1882
|
+
commandId: "queued-command",
|
|
1883
|
+
autoContinueEnabled: true,
|
|
1884
|
+
});
|
|
1885
|
+
const client = {
|
|
1886
|
+
employeeConfig,
|
|
1887
|
+
appendCodingEvents,
|
|
1888
|
+
reportCodingTerminal,
|
|
1889
|
+
evaluateContinuation,
|
|
1890
|
+
};
|
|
1891
|
+
const manager = new CodingRunManager({
|
|
1892
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1893
|
+
});
|
|
1894
|
+
await manager.execute(client, host, command("START"));
|
|
1895
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1896
|
+
expect(session.prompt).toHaveBeenCalledTimes(1);
|
|
1897
|
+
expect(appendCodingEvents.mock.calls
|
|
1898
|
+
.flatMap((call) => call[1].events)
|
|
1899
|
+
.some((event) => event.kind === "CONVERSATION_COMPLETED")).toBe(false);
|
|
1900
|
+
await manager.execute(client, host, command("CONTINUE", {
|
|
1901
|
+
contentMarkdown: "完成剩余测试后提交",
|
|
1902
|
+
continuation: { auditId: "audit-2", attempt: 1, maxAttempts: 2 },
|
|
1903
|
+
}));
|
|
1904
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1905
|
+
expect(session.prompt).toHaveBeenLastCalledWith("完成剩余测试后提交");
|
|
1906
|
+
expect(evaluateContinuation).toHaveBeenCalledOnce();
|
|
1907
|
+
expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({ kind: "DELIVERY" }));
|
|
1908
|
+
const events = appendCodingEvents.mock.calls.flatMap((call) => call[1].events);
|
|
1909
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1910
|
+
kind: "EXECUTION_CONTINUED",
|
|
1911
|
+
payload: expect.objectContaining({
|
|
1912
|
+
auditId: "audit-2",
|
|
1913
|
+
attempt: 1,
|
|
1914
|
+
prompt: "完成剩余测试后提交",
|
|
1915
|
+
deliveryStatus: "SUBMITTED",
|
|
1916
|
+
}),
|
|
1917
|
+
}));
|
|
1918
|
+
expect(events.some((event) => event.kind === "MESSAGE_QUEUE_UPDATED")).toBe(false);
|
|
1919
|
+
});
|
|
1920
|
+
it("判断等待期间用户停止,不因迟到CONTINUE结果自动执行", async () => {
|
|
1921
|
+
let finishJudge;
|
|
1922
|
+
const session = {
|
|
1923
|
+
prompt: vi.fn().mockResolvedValue(undefined),
|
|
1924
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
1925
|
+
subscribe: vi.fn(),
|
|
1926
|
+
};
|
|
1927
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("stop-judge.jsonl"));
|
|
1928
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1929
|
+
const evaluateContinuation = vi.fn(() => new Promise((resolve) => {
|
|
1930
|
+
finishJudge = resolve;
|
|
1931
|
+
}));
|
|
1932
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1933
|
+
const client = { employeeConfig, appendCodingEvents, evaluateContinuation };
|
|
1934
|
+
const manager = new CodingRunManager({
|
|
1935
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1936
|
+
});
|
|
1937
|
+
await manager.execute(client, host, command("START"));
|
|
1938
|
+
await vi.waitFor(() => expect(evaluateContinuation).toHaveBeenCalledOnce());
|
|
1939
|
+
await manager.execute(client, host, command("STOP"));
|
|
1940
|
+
finishJudge({ decision: "CONTINUE", auditId: "stale", prompt: "继续" });
|
|
1941
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1942
|
+
expect(session.abort).toHaveBeenCalledOnce();
|
|
1943
|
+
expect(session.prompt).toHaveBeenCalledOnce();
|
|
1944
|
+
const events = appendCodingEvents.mock.calls.flatMap((call) => call[1].events);
|
|
1945
|
+
expect(events.some((event) => event.kind === "EXECUTION_CONTINUED")).toBe(false);
|
|
1946
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1947
|
+
kind: "EXECUTION_DECIDED",
|
|
1948
|
+
payload: expect.objectContaining({ reason: "STOP_REQUESTED" }),
|
|
1949
|
+
}));
|
|
1950
|
+
});
|
|
1951
|
+
it("判断期间到达用户消息,在旧判断结束后启动真实用户回复,不丢给空闲steer队列", async () => {
|
|
1952
|
+
let finishJudge;
|
|
1953
|
+
const session = {
|
|
1954
|
+
prompt: vi.fn().mockResolvedValue(undefined),
|
|
1955
|
+
steer: vi.fn(),
|
|
1956
|
+
subscribe: vi.fn(),
|
|
1957
|
+
};
|
|
1958
|
+
const stored = rememberSession(mockSessionManager("judge-steer.jsonl"));
|
|
1959
|
+
piMocks.createSession.mockReturnValue(stored);
|
|
1960
|
+
piMocks.openSession.mockReturnValue(stored);
|
|
1961
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
1962
|
+
const evaluateContinuation = vi
|
|
1963
|
+
.fn()
|
|
1964
|
+
.mockImplementationOnce(() => new Promise((resolve) => {
|
|
1965
|
+
finishJudge = resolve;
|
|
1966
|
+
}))
|
|
1967
|
+
.mockResolvedValue({
|
|
1968
|
+
decision: "SKIP",
|
|
1969
|
+
reason: "USER_MESSAGE",
|
|
1970
|
+
model: null,
|
|
1971
|
+
autoContinueEnabled: false,
|
|
1972
|
+
});
|
|
1973
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
1974
|
+
const client = { employeeConfig, appendCodingEvents, evaluateContinuation };
|
|
1975
|
+
const manager = new CodingRunManager({
|
|
1976
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
1977
|
+
});
|
|
1978
|
+
await manager.execute(client, host, command("START"));
|
|
1979
|
+
await vi.waitFor(() => expect(evaluateContinuation).toHaveBeenCalledOnce());
|
|
1980
|
+
const replying = manager.execute(client, host, command("STEER", {
|
|
1981
|
+
contentMarkdown: "先解释当前结果",
|
|
1982
|
+
runInput: { ...runInput, autoContinueEnabled: false },
|
|
1983
|
+
}));
|
|
1984
|
+
await vi.waitFor(() => expect(manager.active.get(runId).observed.handingOffInput).toBe(true));
|
|
1985
|
+
finishJudge({
|
|
1986
|
+
decision: "SKIP",
|
|
1987
|
+
reason: "USER_MESSAGE",
|
|
1988
|
+
model: null,
|
|
1989
|
+
autoContinueEnabled: false,
|
|
1990
|
+
});
|
|
1991
|
+
await replying;
|
|
1992
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
1993
|
+
expect(session.steer).not.toHaveBeenCalled();
|
|
1994
|
+
expect(session.prompt).toHaveBeenCalledTimes(2);
|
|
1995
|
+
expect(session.prompt).toHaveBeenLastCalledWith(expect.stringContaining("用户本次消息:先解释当前结果"));
|
|
1996
|
+
const events = appendCodingEvents.mock.calls.flatMap((call) => call[1].events);
|
|
1997
|
+
expect(events.filter((event) => event.kind === "CONVERSATION_COMPLETED")).toHaveLength(1);
|
|
1998
|
+
expect(events.some((event) => event.kind === "EXECUTION_CONTINUED")).toBe(false);
|
|
1999
|
+
});
|
|
2000
|
+
it("部署快照注入提示词,完整流水线结果透传,首次未就绪可处理一轮,第二次停止自动工具", async () => {
|
|
2001
|
+
let finishPrompt;
|
|
2002
|
+
const session = {
|
|
2003
|
+
prompt: vi.fn((_text) => new Promise((resolve) => {
|
|
2004
|
+
finishPrompt = resolve;
|
|
2005
|
+
})),
|
|
2006
|
+
subscribe: vi.fn(),
|
|
2007
|
+
};
|
|
2008
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("deployment-gate.jsonl"));
|
|
2009
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2010
|
+
const snapshot = {
|
|
2011
|
+
projects: [
|
|
2012
|
+
{
|
|
2013
|
+
projectId: "44444444-4444-4444-8444-444444444444",
|
|
2014
|
+
projectName: "scf-member",
|
|
2015
|
+
testBranch: "test",
|
|
2016
|
+
instructions: "先发布会员服务,再发布 Worker",
|
|
2017
|
+
pipelines: [
|
|
2018
|
+
{
|
|
2019
|
+
name: "会员",
|
|
2020
|
+
pipelineId: "6998",
|
|
2021
|
+
consoleUrl: "https://cloud.example/pipeline/6998",
|
|
2022
|
+
triggerMode: "AUTO",
|
|
2023
|
+
targets: [{ cluster: "test", namespace: "baojie-test", deployment: "scf-member" }],
|
|
2024
|
+
},
|
|
2025
|
+
],
|
|
2026
|
+
},
|
|
2027
|
+
],
|
|
2028
|
+
};
|
|
2029
|
+
const reportCodingTerminal = vi
|
|
2030
|
+
.fn()
|
|
2031
|
+
.mockResolvedValueOnce({
|
|
2032
|
+
accepted: false,
|
|
2033
|
+
deploymentCheck: {
|
|
2034
|
+
status: "NOT_READY",
|
|
2035
|
+
summary: "scf-member 副本尚未就绪",
|
|
2036
|
+
canContinue: true,
|
|
2037
|
+
},
|
|
2038
|
+
})
|
|
2039
|
+
.mockResolvedValueOnce({
|
|
2040
|
+
accepted: false,
|
|
2041
|
+
deploymentCheck: {
|
|
2042
|
+
status: "NOT_READY",
|
|
2043
|
+
summary: "scf-member 仍未就绪",
|
|
2044
|
+
canContinue: false,
|
|
2045
|
+
},
|
|
2046
|
+
});
|
|
2047
|
+
const manager = new CodingRunManager({
|
|
2048
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2049
|
+
});
|
|
2050
|
+
await manager.execute({
|
|
2051
|
+
employeeConfig,
|
|
2052
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2053
|
+
reportCodingTerminal,
|
|
2054
|
+
}, host, command("START", { runInput: { ...runInput, deploymentConfiguration: snapshot } }));
|
|
2055
|
+
const prompt = String(session.prompt.mock.calls[0]?.[0]);
|
|
2056
|
+
expect(JSON.parse(prompt.split("本轮执行上下文:\n")[1])).toMatchObject({
|
|
2057
|
+
deploymentConfiguration: snapshot,
|
|
2058
|
+
});
|
|
2059
|
+
expect(prompt).not.toContain("测试侧合并、冲突适配");
|
|
2060
|
+
expect(prompt).not.toContain("不修改开发分支业务代码");
|
|
2061
|
+
expect(prompt).not.toContain("不修改仓库代码");
|
|
2062
|
+
const factories = piMocks.loaderOptions.extensionFactories;
|
|
2063
|
+
const tools = new Map();
|
|
2064
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
2065
|
+
const hooks = new Map();
|
|
2066
|
+
factories.at(-1)({
|
|
2067
|
+
registerTool: vi.fn(),
|
|
2068
|
+
on: (name, handler) => hooks.set(name, handler),
|
|
2069
|
+
});
|
|
2070
|
+
const submit = tools.get("submit_delivery");
|
|
2071
|
+
expect(Object.keys(submit.parameters.properties).sort()).toEqual([
|
|
2072
|
+
"pipelineExecutions",
|
|
2073
|
+
"summary",
|
|
2074
|
+
]);
|
|
2075
|
+
expect(Object.keys(submit.parameters.properties.pipelineExecutions.items.properties).sort()).toEqual(["executionUrl", "pipeline", "project", "status", "summary"]);
|
|
2076
|
+
const pipelineExecutions = [
|
|
2077
|
+
{
|
|
2078
|
+
project: "scf-member",
|
|
2079
|
+
pipeline: "6998",
|
|
2080
|
+
executionUrl: "https://cloud.example/execution/42",
|
|
2081
|
+
status: "SUCCESS",
|
|
2082
|
+
summary: "本次执行成功,共享环境稍后被更新",
|
|
2083
|
+
},
|
|
2084
|
+
];
|
|
2085
|
+
const first = await submit.execute("first", { summary: "流水线已成功", pipelineExecutions });
|
|
2086
|
+
expect(first.content[0].text).toContain("scf-member 副本尚未就绪");
|
|
2087
|
+
expect(first.content[0].text).not.toContain("等待人工验收");
|
|
2088
|
+
expect(reportCodingTerminal.mock.calls[0][1].pipelineExecutions).toEqual(pipelineExecutions);
|
|
2089
|
+
expect(manager.active.get(runId).observed.terminalReached).toBe(false);
|
|
2090
|
+
expect(JSON.parse(await readFile(join(testRoot, "profiles", "default", "state", "runs", `${runId}.json`), "utf8")).pendingDelivery).toBeUndefined();
|
|
2091
|
+
expect(await hooks.get("tool_call")({ toolName: "bash" })).toBeUndefined();
|
|
2092
|
+
const second = await submit.execute("second", {
|
|
2093
|
+
summary: "排查后重新检查",
|
|
2094
|
+
pipelineExecutions,
|
|
2095
|
+
});
|
|
2096
|
+
expect(second.content[0].text).toContain("自动处理已停止");
|
|
2097
|
+
expect(second.content[0].text).not.toContain("等待人工验收");
|
|
2098
|
+
expect(manager.active.get(runId).observed.terminalReached).toBe(true);
|
|
2099
|
+
expect(await hooks.get("tool_call")({ toolName: "bash" })).toEqual(expect.objectContaining({ block: true }));
|
|
2100
|
+
expect(reportCodingTerminal.mock.calls[1][1].submissionId).not.toBe(reportCodingTerminal.mock.calls[0][1].submissionId);
|
|
2101
|
+
finishPrompt();
|
|
2102
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2103
|
+
});
|
|
2104
|
+
it("网络恢复重传相同部署批次,重复结果未通过时清理批次且不误报交付完成", async () => {
|
|
2105
|
+
let finishPrompt;
|
|
2106
|
+
const session = {
|
|
2107
|
+
prompt: vi.fn((_text) => new Promise((resolve) => {
|
|
2108
|
+
finishPrompt = resolve;
|
|
2109
|
+
})),
|
|
2110
|
+
subscribe: vi.fn(),
|
|
2111
|
+
};
|
|
2112
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("deployment-replay.jsonl"));
|
|
2113
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2114
|
+
const reportCodingTerminal = vi.fn().mockRejectedValue(new Error("network disconnected"));
|
|
2115
|
+
const manager = new CodingRunManager({
|
|
2116
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2117
|
+
});
|
|
2118
|
+
await manager.execute({
|
|
2119
|
+
employeeConfig,
|
|
2120
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2121
|
+
reportCodingTerminal,
|
|
2122
|
+
}, host, command("START"));
|
|
2123
|
+
const tools = new Map();
|
|
2124
|
+
piMocks.loaderOptions.extensionFactories.at(-2)({
|
|
2125
|
+
registerTool: (tool) => tools.set(tool.name, tool),
|
|
2126
|
+
});
|
|
2127
|
+
const pipelineExecutions = [
|
|
2128
|
+
{
|
|
2129
|
+
project: "scf-member",
|
|
2130
|
+
pipeline: "6998",
|
|
2131
|
+
executionUrl: "https://cloud.example/execution/42",
|
|
2132
|
+
status: "SUCCESS",
|
|
2133
|
+
summary: "执行完成",
|
|
2134
|
+
},
|
|
2135
|
+
];
|
|
2136
|
+
await expect(tools.get("submit_delivery").execute("offline", { summary: "原始结果", pipelineExecutions })).rejects.toThrow("AIP_DELIVERY_UPLOAD_FAILED");
|
|
2137
|
+
const statePath = join(testRoot, "profiles", "default", "state", "runs", `${runId}.json`);
|
|
2138
|
+
const pending = JSON.parse(await readFile(statePath, "utf8")).pendingDelivery;
|
|
2139
|
+
expect(pending.submissionId).toBeTruthy();
|
|
2140
|
+
reportCodingTerminal.mockResolvedValue({
|
|
2141
|
+
accepted: false,
|
|
2142
|
+
duplicate: true,
|
|
2143
|
+
deploymentCheck: { status: "UNCONFIRMED", summary: "OpenAPI 暂不可用", canContinue: true },
|
|
2144
|
+
});
|
|
2145
|
+
const result = await tools
|
|
2146
|
+
.get("submit_delivery")
|
|
2147
|
+
.execute("retry", { summary: "不应覆盖已上传批次", pipelineExecutions: [] });
|
|
2148
|
+
expect(reportCodingTerminal).toHaveBeenLastCalledWith(runId, pending);
|
|
2149
|
+
expect(result.content[0].text).toContain("OpenAPI 暂不可用");
|
|
2150
|
+
expect(result.content[0].text).not.toContain("等待人工验收");
|
|
2151
|
+
expect(manager.active.get(runId).observed.terminalReached).toBe(false);
|
|
2152
|
+
expect(JSON.parse(await readFile(statePath, "utf8")).pendingDelivery).toBeUndefined();
|
|
2153
|
+
finishPrompt();
|
|
2154
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2155
|
+
});
|
|
2156
|
+
it("提交被拒绝仍交平台判断,不以工具调用或文字伪造交付", async () => {
|
|
2157
|
+
const reportCodingTerminal = vi
|
|
2158
|
+
.fn()
|
|
2159
|
+
.mockRejectedValue(new PlatformClientError(422, "DELIVERY_MISSING", "缺少测试报告"));
|
|
2160
|
+
const session = {
|
|
2161
|
+
prompt: vi.fn(async () => {
|
|
2162
|
+
const tools = new Map();
|
|
2163
|
+
piMocks.loaderOptions.extensionFactories[1]({
|
|
2164
|
+
registerTool: (tool) => tools.set(tool.name, tool),
|
|
2165
|
+
});
|
|
2166
|
+
await expect(tools.get("submit_delivery").execute("submit", { summary: "本轮部署完成,服务已就绪" })).rejects.toThrow("缺少测试报告");
|
|
2167
|
+
}),
|
|
2168
|
+
subscribe: vi.fn(),
|
|
2169
|
+
};
|
|
2170
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("rejected.jsonl"));
|
|
2171
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2172
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
2173
|
+
const evaluateContinuation = vi.fn().mockResolvedValue({
|
|
2174
|
+
decision: "CONTINUE",
|
|
2175
|
+
reason: "GOAL_NOT_MET_YET",
|
|
2176
|
+
auditId: "retry",
|
|
2177
|
+
model: "Mandao/DeepSeek-V4-Flash",
|
|
2178
|
+
});
|
|
2179
|
+
const manager = new CodingRunManager({
|
|
2180
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2181
|
+
});
|
|
2182
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal, evaluateContinuation }, host, command("START"));
|
|
2183
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2184
|
+
expect(evaluateContinuation).toHaveBeenCalledOnce();
|
|
2185
|
+
expect(reportCodingTerminal).toHaveBeenCalledOnce();
|
|
2186
|
+
expect(appendCodingEvents.mock.calls
|
|
2187
|
+
.flatMap((call) => call[1].events)
|
|
2188
|
+
.some((event) => event.payload?.reason === "TERMINAL_ACCEPTED")).toBe(false);
|
|
2189
|
+
});
|
|
2190
|
+
it("判断请求失败仅记录失败并结束回复,不伪造交付或启动下一轮", async () => {
|
|
2191
|
+
const session = { prompt: vi.fn().mockResolvedValue(undefined), subscribe: vi.fn() };
|
|
2192
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("judge-error.jsonl"));
|
|
2193
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2194
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
2195
|
+
const reportCodingTerminal = vi.fn();
|
|
2196
|
+
const evaluateContinuation = vi.fn().mockRejectedValue(new Error("connection lost"));
|
|
2197
|
+
const manager = new CodingRunManager({
|
|
2198
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2199
|
+
});
|
|
2200
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal, evaluateContinuation }, host, command("START"));
|
|
2201
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2202
|
+
expect(session.prompt).toHaveBeenCalledOnce();
|
|
2203
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
2204
|
+
expect(appendCodingEvents.mock.calls.flatMap((call) => call[1].events)).toContainEqual(expect.objectContaining({
|
|
2205
|
+
kind: "EXECUTION_DECIDED",
|
|
2206
|
+
payload: expect.objectContaining({ reason: "JUDGE_REQUEST_FAILED" }),
|
|
2207
|
+
}));
|
|
2208
|
+
});
|
|
2209
|
+
it.each(["source.txt", "docs/aip/AIP-1/summary.md"])("有限操作修改 %s 时如实报告工作区已变化", async (file) => {
|
|
2210
|
+
const source = join(testRoot, "conversation-source");
|
|
2211
|
+
await mkdir(source);
|
|
2212
|
+
const git = async (...args) => (await execFileAsync("git", args, { cwd: source })).stdout.trim();
|
|
2213
|
+
await git("init", "-b", "main");
|
|
2214
|
+
await writeFile(join(source, "source.txt"), "baseline\n");
|
|
2215
|
+
await git("add", ".");
|
|
2216
|
+
await git("-c", "user.name=AIP", "-c", "user.email=aip@test.local", "commit", "-m", "baseline");
|
|
2217
|
+
await git("branch", "test");
|
|
2218
|
+
const project = {
|
|
2219
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
2220
|
+
name: "fixture",
|
|
2221
|
+
repositoryUrl: source,
|
|
2222
|
+
baselineCommit: await git("rev-parse", "HEAD"),
|
|
2223
|
+
baselineBranch: "main",
|
|
2224
|
+
devBranch: `aip/${runId}/44444444`,
|
|
2225
|
+
testBranch: "test",
|
|
2226
|
+
};
|
|
2227
|
+
const session = {
|
|
2228
|
+
prompt: vi.fn(async () => {
|
|
2229
|
+
const target = join(testRoot, "profiles", "default", "workspaces/deployments", runId, "fixture", file);
|
|
2230
|
+
await mkdir(join(target, ".."), { recursive: true });
|
|
2231
|
+
await writeFile(target, "changed\n");
|
|
2232
|
+
}),
|
|
2233
|
+
subscribe: vi.fn(),
|
|
2234
|
+
};
|
|
2235
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("changed.jsonl"));
|
|
2236
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2237
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
2238
|
+
const manager = new CodingRunManager({
|
|
2239
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2240
|
+
});
|
|
2241
|
+
await manager.execute({ employeeConfig, appendCodingEvents }, host, command("RESUME", {
|
|
2242
|
+
runInput: {
|
|
2243
|
+
...runInput,
|
|
2244
|
+
projects: [project],
|
|
2245
|
+
primaryProjectId: project.id,
|
|
2246
|
+
autoContinueEnabled: false,
|
|
2247
|
+
},
|
|
2248
|
+
}));
|
|
2249
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2250
|
+
expect(session.prompt).toHaveBeenCalledTimes(1);
|
|
2251
|
+
expect(appendCodingEvents.mock.calls.flatMap((call) => call[1].events)).toContainEqual(expect.objectContaining({
|
|
2252
|
+
kind: "CONVERSATION_COMPLETED",
|
|
2253
|
+
payload: { workspaceChanged: true },
|
|
2254
|
+
}));
|
|
2255
|
+
});
|
|
2256
|
+
it("Pi 内部恢复尚未空闲时不催跑,恢复中完成交付后直接结束", async () => {
|
|
2257
|
+
let subscriber;
|
|
2258
|
+
let finishIdle;
|
|
2259
|
+
const idle = new Promise((resolve) => {
|
|
2260
|
+
finishIdle = resolve;
|
|
2261
|
+
});
|
|
2262
|
+
const tools = new Map();
|
|
2263
|
+
const session = {
|
|
2264
|
+
prompt: vi.fn(async () => {
|
|
2265
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
2266
|
+
factories.at(-2)({ registerTool: (entry) => tools.set(entry.name, entry) });
|
|
2267
|
+
subscriber?.({ type: "agent_end", willRetry: true });
|
|
2268
|
+
}),
|
|
2269
|
+
waitForIdle: vi.fn(() => idle),
|
|
2270
|
+
subscribe: vi.fn((listener) => {
|
|
2271
|
+
subscriber = listener;
|
|
2272
|
+
}),
|
|
2273
|
+
};
|
|
2274
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("terminal-idle.jsonl"));
|
|
2275
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2276
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
2277
|
+
const manager = new CodingRunManager({
|
|
2278
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2279
|
+
});
|
|
2280
|
+
await manager.execute({
|
|
2281
|
+
employeeConfig,
|
|
2282
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2283
|
+
reportCodingTerminal,
|
|
2284
|
+
}, host, command("START"));
|
|
2285
|
+
try {
|
|
2286
|
+
await vi.waitFor(() => expect(session.waitForIdle).toHaveBeenCalledTimes(1));
|
|
2287
|
+
expect(session.prompt).toHaveBeenCalledTimes(1);
|
|
2288
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
2289
|
+
await tools
|
|
2290
|
+
.get("submit_delivery")
|
|
2291
|
+
.execute("accepted", { summary: "本轮部署完成,服务已就绪" });
|
|
2292
|
+
}
|
|
2293
|
+
finally {
|
|
2294
|
+
finishIdle();
|
|
2295
|
+
}
|
|
2296
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2297
|
+
expect(session.prompt).toHaveBeenCalledTimes(1);
|
|
2298
|
+
expect(reportCodingTerminal).toHaveBeenCalledTimes(1);
|
|
2299
|
+
expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({ kind: "DELIVERY" }));
|
|
2300
|
+
});
|
|
2301
|
+
it.each(["任务已完成", '{"status":"completed"}', "遇到问题,等待用户处理"])("文本自报 %s 不等于交付,交给平台判断", async (text) => {
|
|
2302
|
+
let subscriber;
|
|
2303
|
+
const session = {
|
|
2304
|
+
prompt: vi.fn(async () => {
|
|
2305
|
+
subscriber?.({
|
|
2306
|
+
type: "message_end",
|
|
2307
|
+
message: {
|
|
2308
|
+
role: "assistant",
|
|
2309
|
+
stopReason: "stop",
|
|
2310
|
+
content: [{ type: "text", text }],
|
|
2311
|
+
},
|
|
2312
|
+
});
|
|
2313
|
+
}),
|
|
2314
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
2315
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
2316
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
2317
|
+
subscribe: vi.fn((listener) => {
|
|
2318
|
+
subscriber = listener;
|
|
2319
|
+
}),
|
|
2320
|
+
};
|
|
2321
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("session.jsonl"));
|
|
2322
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2323
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
2324
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
2325
|
+
const manager = new CodingRunManager({
|
|
2326
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2327
|
+
});
|
|
2328
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal }, host, command("START"));
|
|
2329
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2330
|
+
expect(session.prompt).toHaveBeenCalledOnce();
|
|
2331
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
2332
|
+
});
|
|
2333
|
+
it.each([
|
|
2334
|
+
{
|
|
2335
|
+
stopReason: "error",
|
|
2336
|
+
errorMessage: "authentication failed: invalid api key",
|
|
2337
|
+
code: "authentication failed: invalid api key",
|
|
2338
|
+
},
|
|
2339
|
+
{
|
|
2340
|
+
stopReason: "error",
|
|
2341
|
+
errorMessage: "OAuth refresh failed: refresh_token_reused",
|
|
2342
|
+
code: "PROVIDER_LOGIN_REQUIRED",
|
|
2343
|
+
},
|
|
2344
|
+
{ stopReason: "aborted", errorMessage: undefined, code: "PI_MODEL_ABORTED" },
|
|
2345
|
+
])("模型 stopReason=$stopReason 时保留失败原因,不再催交付", async ({ stopReason, errorMessage, code }) => {
|
|
2346
|
+
let subscriber;
|
|
2347
|
+
let finishPrompt;
|
|
2348
|
+
const session = {
|
|
2349
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
2350
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
2351
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
2352
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
2353
|
+
subscribe: vi.fn((listener) => {
|
|
2354
|
+
subscriber = listener;
|
|
2355
|
+
}),
|
|
2356
|
+
};
|
|
2357
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("auth-error-session.jsonl"));
|
|
2358
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2359
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
2360
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
2361
|
+
const manager = new CodingRunManager({
|
|
2362
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2363
|
+
});
|
|
2364
|
+
await manager.execute({ employeeConfig, appendCodingEvents, reportCodingTerminal }, { ...host, fingerprint: "host-fingerprint", runtimeVersion: "0.0.6" }, command("START"));
|
|
2365
|
+
subscriber?.({
|
|
2366
|
+
type: "message_end",
|
|
2367
|
+
message: {
|
|
2368
|
+
role: "assistant",
|
|
2369
|
+
stopReason,
|
|
2370
|
+
errorMessage,
|
|
2371
|
+
content: [],
|
|
2372
|
+
},
|
|
2373
|
+
});
|
|
2374
|
+
finishPrompt?.();
|
|
2375
|
+
await vi.waitFor(() => expect(session.prompt).toHaveBeenCalledTimes(1));
|
|
2376
|
+
await vi.waitFor(() => expect(reportCodingTerminal).toHaveBeenCalledWith(runId, expect.objectContaining({
|
|
2377
|
+
kind: "FAILED",
|
|
2378
|
+
failureCode: code,
|
|
2379
|
+
})));
|
|
2380
|
+
expect(reportCodingTerminal.mock.calls[0][1]).not.toHaveProperty("fingerprint");
|
|
2381
|
+
expect(reportCodingTerminal.mock.calls[0][1]).not.toHaveProperty("runtimeVersion");
|
|
2382
|
+
if (code === "PROVIDER_LOGIN_REQUIRED")
|
|
2383
|
+
expect(reportCodingTerminal.mock.calls[0][1].summary).toContain("重新登录");
|
|
2384
|
+
expect(session.prompt).toHaveBeenCalledTimes(1);
|
|
2385
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2386
|
+
});
|
|
2387
|
+
it("PR 工具不按验收 SHA/tree 门禁,推送指定分支且保留镜像配置", async () => {
|
|
2388
|
+
const source = join(testRoot, "push-source");
|
|
2389
|
+
const remote = join(testRoot, "push-remote.git");
|
|
2390
|
+
await mkdir(source);
|
|
2391
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
2392
|
+
await git(source, "init", "-b", "main");
|
|
2393
|
+
await writeFile(join(source, "rule.txt"), "baseline\n");
|
|
2394
|
+
await git(source, "add", ".");
|
|
2395
|
+
await git(source, "-c", "user.name=AIP Test", "-c", "user.email=aip@example.test", "commit", "-m", "baseline");
|
|
2396
|
+
const baselineCommit = await git(source, "rev-parse", "HEAD");
|
|
2397
|
+
await git(testRoot, "clone", "--bare", source, remote);
|
|
2398
|
+
const projectId = "44444444-4444-4444-8444-444444444444";
|
|
2399
|
+
const input = {
|
|
2400
|
+
...runInput,
|
|
2401
|
+
executionPurpose: "RELEASE",
|
|
2402
|
+
primaryProjectId: projectId,
|
|
2403
|
+
projects: [
|
|
2404
|
+
{
|
|
2405
|
+
id: projectId,
|
|
2406
|
+
name: "fixture",
|
|
2407
|
+
repositoryUrl: remote,
|
|
2408
|
+
baselineCommit,
|
|
2409
|
+
baselineBranch: "main",
|
|
2410
|
+
devBranch: `aip/${runId}/44444444`,
|
|
2411
|
+
testBranch: "test",
|
|
2412
|
+
},
|
|
2413
|
+
],
|
|
2414
|
+
};
|
|
2415
|
+
let finishPrompt;
|
|
2416
|
+
const session = {
|
|
2417
|
+
prompt: vi.fn(() => new Promise((resolve) => {
|
|
2418
|
+
finishPrompt = resolve;
|
|
2419
|
+
})),
|
|
2420
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
2421
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
2422
|
+
subscribe: vi.fn(),
|
|
2423
|
+
};
|
|
2424
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("release-session.jsonl"));
|
|
2425
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2426
|
+
const manager = new CodingRunManager({
|
|
2427
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2428
|
+
});
|
|
2429
|
+
const submitPullRequests = vi.fn().mockResolvedValue({ accepted: true });
|
|
2430
|
+
const hostState = { ...host, hostName: "development-machine", catalogRevision: 7 };
|
|
2431
|
+
await manager.execute({
|
|
2432
|
+
employeeConfig,
|
|
2433
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2434
|
+
reportCodingTerminal: vi.fn(),
|
|
2435
|
+
submitPullRequests,
|
|
2436
|
+
}, hostState, command("START", { runInput: input }));
|
|
2437
|
+
const worktree = join(testRoot, "profiles", "default", "workspaces", "runs", runId, "fixture");
|
|
2438
|
+
await writeFile(join(worktree, "rule.txt"), "accepted candidate\n");
|
|
2439
|
+
await git(worktree, "add", "rule.txt");
|
|
2440
|
+
await git(worktree, "-c", "user.name=AIP Test", "-c", "user.email=aip@example.test", "commit", "-m", "candidate");
|
|
2441
|
+
const commitSha = await git(worktree, "rev-parse", "HEAD");
|
|
2442
|
+
const branch = await git(worktree, "branch", "--show-current");
|
|
2443
|
+
const active = manager.active.get(runId);
|
|
2444
|
+
active.input.acceptedProjectFacts = [
|
|
2445
|
+
{ projectId, commitSha, branch, treeHash: await worktreeTreeHash(worktree, "AIP-1", true) },
|
|
2446
|
+
];
|
|
2447
|
+
// Existing mirror caches remain supported; the tool overrides only this push.
|
|
2448
|
+
await git(worktree, "config", "remote.origin.mirror", "true");
|
|
2449
|
+
expect(await git(worktree, "config", "--get", "remote.origin.mirror")).toBe("true");
|
|
2450
|
+
await expect(git(worktree, "push", "origin", `${commitSha}:refs/heads/${branch}`)).rejects.toThrow("--mirror can't be combined with refspecs");
|
|
2451
|
+
const tools = new Map();
|
|
2452
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
2453
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
2454
|
+
await writeArtifacts(manager);
|
|
2455
|
+
active.input.acceptedProjectFacts[0].commitSha = "old-accepted-commit";
|
|
2456
|
+
active.input.acceptedProjectFacts[0].treeHash = "old-accepted-tree";
|
|
2457
|
+
mrMocks.api.mockImplementation(async (endpoint) => {
|
|
2458
|
+
if (endpoint.startsWith("merge_requests?"))
|
|
2459
|
+
return [];
|
|
2460
|
+
if (endpoint.startsWith("repository/compare?"))
|
|
2461
|
+
return { diffs: [{}] };
|
|
2462
|
+
return {
|
|
2463
|
+
iid: 12,
|
|
2464
|
+
source_project_id: 1,
|
|
2465
|
+
target_project_id: 1,
|
|
2466
|
+
web_url: "https://gitlab.example/team/fixture/-/merge_requests/12",
|
|
2467
|
+
source_branch: branch,
|
|
2468
|
+
target_branch: "main",
|
|
2469
|
+
state: "opened",
|
|
2470
|
+
};
|
|
2471
|
+
});
|
|
2472
|
+
await tools.get("submit_pull_requests").execute("tool-call", {
|
|
2473
|
+
checklistSummary: "已读取测试交接与最新代码,清单无需修改",
|
|
2474
|
+
projects: [
|
|
2475
|
+
{
|
|
2476
|
+
project: "fixture",
|
|
2477
|
+
createMr: true,
|
|
2478
|
+
title: "[AIP-1] fixture",
|
|
2479
|
+
description: "测试通过,详见上线清单",
|
|
2480
|
+
},
|
|
2481
|
+
],
|
|
2482
|
+
});
|
|
2483
|
+
expect(submitPullRequests).toHaveBeenCalledWith(runId, expect.objectContaining({
|
|
2484
|
+
projects: [
|
|
2485
|
+
expect.objectContaining({ mrIid: 12, sourceBranch: branch, targetBranch: "main" }),
|
|
2486
|
+
],
|
|
2487
|
+
}));
|
|
2488
|
+
expect(submitPullRequests).toHaveBeenLastCalledWith(runId, expect.objectContaining({ completeRelease: true }));
|
|
2489
|
+
for (const [, body] of submitPullRequests.mock.calls) {
|
|
2490
|
+
expect(body).not.toHaveProperty("hostName");
|
|
2491
|
+
expect(body).not.toHaveProperty("catalogRevision");
|
|
2492
|
+
}
|
|
2493
|
+
expect(mrMocks.api).toHaveBeenCalledExactlyOnceWith("merge_requests", "POST", expect.objectContaining({ source_branch: branch, target_branch: "main" }));
|
|
2494
|
+
expect(await git(remote, "rev-parse", `refs/heads/${branch}`)).toBe(commitSha);
|
|
2495
|
+
expect(await git(remote, "rev-parse", "refs/heads/main")).toBe(baselineCommit);
|
|
2496
|
+
expect(await git(worktree, "config", "--get", "remote.origin.mirror")).toBe("true");
|
|
2497
|
+
finishPrompt?.();
|
|
2498
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2499
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
2500
|
+
it.each([false, true])("独立员工=%s,部署不要求研发团队或测试成员证据,采集真实分支事实并保持上传重试幂等", async (solo) => {
|
|
2501
|
+
const source = join(testRoot, "delivery-source");
|
|
2502
|
+
await mkdir(source, { recursive: true });
|
|
2503
|
+
await execFileAsync("git", ["init", "-b", "main"], { cwd: source });
|
|
2504
|
+
await execFileAsync("git", ["config", "user.name", "AIP Test"], { cwd: source });
|
|
2505
|
+
await execFileAsync("git", ["config", "user.email", "aip@example.test"], { cwd: source });
|
|
2506
|
+
await writeFile(join(source, "shipping.ts"), "export const shipping = 12;\n");
|
|
2507
|
+
await execFileAsync("git", ["add", "."], { cwd: source });
|
|
2508
|
+
await execFileAsync("git", ["commit", "-m", "fixture"], { cwd: source });
|
|
2509
|
+
const baselineCommit = (await execFileAsync("git", ["rev-parse", "HEAD"], { cwd: source })).stdout.trim();
|
|
2510
|
+
await execFileAsync("git", ["branch", "test"], { cwd: source });
|
|
2511
|
+
const projectInput = {
|
|
2512
|
+
...runInput,
|
|
2513
|
+
team: solo ? null : runInput.team,
|
|
2514
|
+
projects: [
|
|
2515
|
+
{
|
|
2516
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
2517
|
+
name: "fixture",
|
|
2518
|
+
repositoryUrl: source,
|
|
2519
|
+
baselineCommit,
|
|
2520
|
+
baselineBranch: "main",
|
|
2521
|
+
devBranch: `aip/${runId}/44444444`,
|
|
2522
|
+
testBranch: "test",
|
|
2523
|
+
},
|
|
2524
|
+
],
|
|
2525
|
+
};
|
|
2526
|
+
const developmentRoot = join(testRoot, "profiles", "default", "workspaces", "runs", runId);
|
|
2527
|
+
await prepareProjects(join(testRoot, "profiles", "default", "workspaces/repos"), developmentRoot, "AIP-1", projectInput.projects, false);
|
|
2528
|
+
await initializeDeliveryFiles(developmentRoot, {
|
|
2529
|
+
...materialInput(projectInput),
|
|
2530
|
+
materialPreparation: workspaceMaterialPreparation({
|
|
2531
|
+
...materialInput(projectInput),
|
|
2532
|
+
phase: "DEVELOPMENT",
|
|
2533
|
+
primaryProjectId: projectInput.projects[0].id,
|
|
2534
|
+
}),
|
|
2535
|
+
primaryProjectId: projectInput.projects[0].id,
|
|
2536
|
+
}, false, readMaterialFixture);
|
|
2537
|
+
let finishPrompt;
|
|
2538
|
+
const session = {
|
|
2539
|
+
prompt: vi.fn(() => new Promise((resolve) => (finishPrompt = resolve))),
|
|
2540
|
+
waitForIdle: vi.fn().mockResolvedValue(undefined),
|
|
2541
|
+
steer: vi.fn().mockResolvedValue(undefined),
|
|
2542
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
2543
|
+
subscribe: vi.fn(),
|
|
2544
|
+
};
|
|
2545
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("delivery-session.jsonl"));
|
|
2546
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2547
|
+
const manager = new CodingRunManager({
|
|
2548
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2549
|
+
});
|
|
2550
|
+
const reportCodingTerminal = vi
|
|
2551
|
+
.fn()
|
|
2552
|
+
.mockRejectedValueOnce(new Error("temporary network failure"))
|
|
2553
|
+
.mockResolvedValue({ accepted: true });
|
|
2554
|
+
await manager.execute({
|
|
2555
|
+
employeeConfig,
|
|
2556
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2557
|
+
reportCodingTerminal,
|
|
2558
|
+
}, host, command("START", { runInput: projectInput }));
|
|
2559
|
+
const tools = new Map();
|
|
2560
|
+
const factories = piMocks.loaderOptions?.extensionFactories;
|
|
2561
|
+
factories[0]({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
2562
|
+
factories.at(-2)({
|
|
2563
|
+
registerTool: (tool) => tools.set(tool.name, tool),
|
|
2564
|
+
});
|
|
2565
|
+
expect(tools.has("subagent")).toBe(true);
|
|
2566
|
+
const deployment = join(testRoot, "profiles", "default", "workspaces", "deployments", runId, "fixture");
|
|
2567
|
+
expect(piMocks.createAgentSession.mock.calls[0][0].cwd).toBe(deployment);
|
|
2568
|
+
await writeFile(join(deployment, "shipping.ts"), "test-side-only\n");
|
|
2569
|
+
const worktree = join(testRoot, "profiles", "default", "workspaces", "runs", runId, "fixture");
|
|
2570
|
+
await writeFile(join(worktree, "shipping.ts"), "export const shipping = 0;\n");
|
|
2571
|
+
expect(tools.has("record_integration_test")).toBe(false);
|
|
2572
|
+
expect(tools.has("record_deployment_observation")).toBe(false);
|
|
2573
|
+
await rm(join(worktree, "docs/aip/AIP-1/plan.md"));
|
|
2574
|
+
await expect(tools.get("submit_delivery").execute("missing", { summary: "本轮部署完成,服务已就绪" })).rejects.toThrow();
|
|
2575
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
2576
|
+
await writeArtifacts(manager);
|
|
2577
|
+
await tools.get("submit_delivery").execute("delivery", { summary: "完成" });
|
|
2578
|
+
expect(Object.keys(tools.get("submit_delivery").parameters.properties)).toEqual([
|
|
2579
|
+
"pipelineExecutions",
|
|
2580
|
+
"summary",
|
|
2581
|
+
]);
|
|
2582
|
+
const batches = reportCodingTerminal.mock.calls.filter((call) => call[1].kind === "DELIVERY");
|
|
2583
|
+
expect(batches).toHaveLength(2);
|
|
2584
|
+
expect(batches[0][1]).toEqual(batches[1][1]);
|
|
2585
|
+
expect(batches[0][1].submissionId).toBeTruthy();
|
|
2586
|
+
const delivery = reportCodingTerminal.mock.calls.find((call) => call[1].kind === "DELIVERY")?.[1];
|
|
2587
|
+
expect(delivery.summary).toBe("完成");
|
|
2588
|
+
expect(delivery.files.map((file) => file.slot)).not.toContain("SUMMARY");
|
|
2589
|
+
expect(delivery.files.map((file) => file.slot)).not.toContain("DEPLOYMENT_REPORT");
|
|
2590
|
+
expect(delivery.testFacts).toEqual([]);
|
|
2591
|
+
expect(delivery.projectFacts[0].branch).toBe(projectInput.projects[0].devBranch);
|
|
2592
|
+
expect(delivery.projectFacts[0].commitSha).toBe(baselineCommit);
|
|
2593
|
+
expect(delivery.projectFacts[0].treeHash).toBe(await worktreeTreeHash(worktree, "AIP-1"));
|
|
2594
|
+
expect((await execFileAsync("git", ["status", "--porcelain"], { cwd: worktree })).stdout).toContain("shipping.ts");
|
|
2595
|
+
finishPrompt?.();
|
|
2596
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2597
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
2598
|
+
it.each([
|
|
2599
|
+
"latest",
|
|
2600
|
+
"resume",
|
|
2601
|
+
"dirty",
|
|
2602
|
+
"diverged",
|
|
2603
|
+
"ahead",
|
|
2604
|
+
"wrong-branch",
|
|
2605
|
+
"wrong-origin",
|
|
2606
|
+
"missing-branch",
|
|
2607
|
+
])("新部署同步真实研发来源,现有现场与同请求续接受保护:%s", async (scenario) => {
|
|
2608
|
+
const source = join(testRoot, "deployment-handoff-source");
|
|
2609
|
+
await mkdir(join(source, "docs/aip/AIP-1"), { recursive: true });
|
|
2610
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
2611
|
+
await git(source, "init", "-b", "main");
|
|
2612
|
+
await git(source, "config", "user.name", "AIP Test");
|
|
2613
|
+
await git(source, "config", "user.email", "aip@example.test");
|
|
2614
|
+
await writeFile(join(source, "business.txt"), "A\n");
|
|
2615
|
+
for (const file of [
|
|
2616
|
+
"prd.md",
|
|
2617
|
+
"plan.md",
|
|
2618
|
+
"report.md",
|
|
2619
|
+
"code_review.md",
|
|
2620
|
+
"release_checklist.md",
|
|
2621
|
+
])
|
|
2622
|
+
await writeFile(join(source, "docs/aip/AIP-1", file), "A 材料\n");
|
|
2623
|
+
await git(source, "add", ".");
|
|
2624
|
+
await git(source, "commit", "-m", "development A");
|
|
2625
|
+
const first = await git(source, "rev-parse", "HEAD");
|
|
2626
|
+
await git(source, "branch", "test");
|
|
2627
|
+
await git(source, "checkout", "-b", "aip/AIP-1");
|
|
2628
|
+
const project = {
|
|
2629
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
2630
|
+
name: "fixture",
|
|
2631
|
+
repositoryUrl: source,
|
|
2632
|
+
baselineCommit: first,
|
|
2633
|
+
baselineBranch: "main",
|
|
2634
|
+
devBranch: "aip/AIP-1",
|
|
2635
|
+
testBranch: "test",
|
|
2636
|
+
};
|
|
2637
|
+
const local = join(testRoot, "profiles/default");
|
|
2638
|
+
const developmentRoot = join(local, "workspaces/runs", runId);
|
|
2639
|
+
const worktree = await prepareProjects(join(local, "workspaces/repos"), developmentRoot, "AIP-1", [project], false);
|
|
2640
|
+
await git(worktree, "config", "user.name", "AIP Test");
|
|
2641
|
+
await git(worktree, "config", "user.email", "aip@example.test");
|
|
2642
|
+
let localHead = first;
|
|
2643
|
+
if (["ahead", "diverged"].includes(scenario)) {
|
|
2644
|
+
await writeFile(join(worktree, "unpublished.txt"), "用户未推送成果\n");
|
|
2645
|
+
await git(worktree, "add", ".");
|
|
2646
|
+
await git(worktree, "commit", "-m", "unpublished work");
|
|
2647
|
+
localHead = await git(worktree, "rev-parse", "HEAD");
|
|
2648
|
+
}
|
|
2649
|
+
if (scenario !== "ahead") {
|
|
2650
|
+
await writeFile(join(source, "business.txt"), "B\n");
|
|
2651
|
+
await writeFile(join(source, "docs/aip/AIP-1/report.md"), "B 材料\n");
|
|
2652
|
+
await git(source, "commit", "-am", "branch advanced to B");
|
|
2653
|
+
}
|
|
2654
|
+
const latest = await git(source, "rev-parse", "HEAD");
|
|
2655
|
+
if (["dirty", "resume"].includes(scenario))
|
|
2656
|
+
await writeFile(join(worktree, "business.txt"), "用户未提交修改\n");
|
|
2657
|
+
if (scenario === "wrong-branch")
|
|
2658
|
+
await git(worktree, "checkout", "-b", "wrong-branch");
|
|
2659
|
+
if (scenario === "wrong-origin")
|
|
2660
|
+
await git(worktree, "remote", "set-url", "origin", join(testRoot, "other-project"));
|
|
2661
|
+
if (scenario === "missing-branch") {
|
|
2662
|
+
await git(source, "checkout", "main");
|
|
2663
|
+
await git(source, "branch", "-D", project.devBranch);
|
|
2664
|
+
}
|
|
2665
|
+
const beforeStatus = await git(worktree, "status", "--porcelain");
|
|
2666
|
+
const stateFile = join(local, "state/runs", `${runId}.json`);
|
|
2667
|
+
await mkdir(join(local, "state/runs"), { recursive: true });
|
|
2668
|
+
const remembered = mockSessionManager("branch-handoff.jsonl");
|
|
2669
|
+
await mkdir(join(local, "pi/sessions"), { recursive: true });
|
|
2670
|
+
await writeFile(remembered.getSessionFile(), "{}\n");
|
|
2671
|
+
await writeFile(stateFile, JSON.stringify({
|
|
2672
|
+
prepared: true,
|
|
2673
|
+
harness: "pi",
|
|
2674
|
+
phase: scenario === "resume" ? "DEPLOYMENT" : "DEVELOPMENT",
|
|
2675
|
+
deploymentRequestId: scenario === "resume" ? "new-request" : "old-request",
|
|
2676
|
+
phaseSessions: { DEPLOYMENT: remembered.getSessionId() },
|
|
2677
|
+
}));
|
|
2678
|
+
let finishPrompt;
|
|
2679
|
+
const session = {
|
|
2680
|
+
prompt: vi.fn(() => new Promise((resolve) => {
|
|
2681
|
+
finishPrompt = resolve;
|
|
2682
|
+
})),
|
|
2683
|
+
subscribe: vi.fn(),
|
|
2684
|
+
waitForIdle: vi.fn(),
|
|
2685
|
+
abort: vi.fn().mockResolvedValue(undefined),
|
|
2686
|
+
};
|
|
2687
|
+
piMocks.openSession.mockReturnValue(rememberSession(remembered));
|
|
2688
|
+
piMocks.createAgentSession.mockResolvedValue({ session });
|
|
2689
|
+
const reportCodingTerminal = vi.fn().mockResolvedValue({ accepted: true });
|
|
2690
|
+
const manager = new CodingRunManager({
|
|
2691
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
2692
|
+
});
|
|
2693
|
+
const execution = manager.execute({
|
|
2694
|
+
employeeConfig,
|
|
2695
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
2696
|
+
reportCodingTerminal,
|
|
2697
|
+
}, host, command(scenario === "resume" ? "RESUME" : "START", {
|
|
2698
|
+
runInput: { ...runInput, projects: [project], deploymentRequestId: "new-request" },
|
|
2699
|
+
}));
|
|
2700
|
+
const errors = {
|
|
2701
|
+
dirty: "CODING_WORKTREE_REMOTE_AHEAD_DIRTY",
|
|
2702
|
+
diverged: "CODING_WORKTREE_DIVERGED",
|
|
2703
|
+
"wrong-branch": "CODING_WORKTREE_BRANCH_MISMATCH",
|
|
2704
|
+
"wrong-origin": "CODING_REPOSITORY_ORIGIN_MISMATCH",
|
|
2705
|
+
// 单分支 clone 的 fetch 在远端分支已删除时直接失败,不能创建替代成果。
|
|
2706
|
+
"missing-branch": "CODING_REPOSITORY_ACCESS_FAILED",
|
|
2707
|
+
};
|
|
2708
|
+
if (errors[scenario]) {
|
|
2709
|
+
await expect(execution).rejects.toThrow(errors[scenario]);
|
|
2710
|
+
expect(await git(worktree, "rev-parse", "HEAD")).toBe(localHead);
|
|
2711
|
+
expect(await git(worktree, "status", "--porcelain")).toBe(beforeStatus);
|
|
2712
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
2713
|
+
expect(reportCodingTerminal).not.toHaveBeenCalled();
|
|
2714
|
+
expect(JSON.parse(await readFile(stateFile, "utf8")).deploymentRequestId).toBe("old-request");
|
|
2715
|
+
return;
|
|
2716
|
+
}
|
|
2717
|
+
await execution;
|
|
2718
|
+
expect(await git(worktree, "rev-parse", "HEAD")).toBe(scenario === "latest" ? latest : localHead);
|
|
2719
|
+
expect(await git(worktree, "status", "--porcelain")).toBe(beforeStatus);
|
|
2720
|
+
expect(piMocks.openSession).toHaveBeenCalled();
|
|
2721
|
+
if (scenario === "resume") {
|
|
2722
|
+
expect(await readFile(join(worktree, "business.txt"), "utf8")).toBe("用户未提交修改\n");
|
|
2723
|
+
}
|
|
2724
|
+
else {
|
|
2725
|
+
const tools = new Map();
|
|
2726
|
+
const factories = piMocks.loaderOptions.extensionFactories;
|
|
2727
|
+
factories.at(-2)({ registerTool: (tool) => tools.set(tool.name, tool) });
|
|
2728
|
+
await tools.get("submit_delivery").execute("delivery", { summary: "本次真实交付" });
|
|
2729
|
+
const batch = reportCodingTerminal.mock.calls[0][1];
|
|
2730
|
+
expect(batch.projectFacts[0]).toMatchObject({
|
|
2731
|
+
projectId: project.id,
|
|
2732
|
+
branch: project.devBranch,
|
|
2733
|
+
commitSha: scenario === "latest" ? latest : localHead,
|
|
2734
|
+
});
|
|
2735
|
+
expect(batch.projectFacts[0].treeHash).toBe(await worktreeTreeHash(worktree, "AIP-1"));
|
|
2736
|
+
if (scenario === "latest")
|
|
2737
|
+
expect(batch.files.find((file) => file.slot === "TEST_REPORT").content).toBe("B 材料\n");
|
|
2738
|
+
}
|
|
2739
|
+
finishPrompt();
|
|
2740
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
2741
|
+
}, 15_000);
|
|
2742
|
+
it("部署独立 clone 使用配置测试分支,保留冲突现场且研发可继续", async () => {
|
|
2743
|
+
const source = join(testRoot, "deployment-source");
|
|
2744
|
+
await mkdir(source);
|
|
2745
|
+
const git = (args, cwd = source) => execFileAsync("git", args, { cwd });
|
|
2746
|
+
await git(["init", "-b", "main"]);
|
|
2747
|
+
await git(["config", "user.name", "AIP Test"]);
|
|
2748
|
+
await git(["config", "user.email", "aip@example.test"]);
|
|
2749
|
+
await writeFile(join(source, "file.txt"), "base\n");
|
|
2750
|
+
await git(["add", "."]);
|
|
2751
|
+
await git(["commit", "-m", "base"]);
|
|
2752
|
+
const baselineCommit = (await git(["rev-parse", "HEAD"])).stdout.trim();
|
|
2753
|
+
await git(["checkout", "-b", "qa-shared"]);
|
|
2754
|
+
await writeFile(join(source, "file.txt"), "test changes\n");
|
|
2755
|
+
await git(["commit", "-am", "test changes"]);
|
|
2756
|
+
await git(["checkout", "main"]);
|
|
2757
|
+
const projects = [
|
|
2758
|
+
{
|
|
2759
|
+
id: "project",
|
|
2760
|
+
name: "app",
|
|
2761
|
+
repositoryUrl: source,
|
|
2762
|
+
baselineBranch: "main",
|
|
2763
|
+
baselineCommit,
|
|
2764
|
+
devBranch: "aip/ISOLATION",
|
|
2765
|
+
testBranch: "unused",
|
|
2766
|
+
},
|
|
2767
|
+
];
|
|
2768
|
+
const devRoot = join(testRoot, "development");
|
|
2769
|
+
const deployRoot = join(testRoot, "deployment");
|
|
2770
|
+
const dev = await prepareProjects(join(testRoot, "cache"), devRoot, "ISOLATION", projects, false);
|
|
2771
|
+
await git(["config", "user.name", "AIP Test"], dev);
|
|
2772
|
+
await git(["config", "user.email", "aip@example.test"], dev);
|
|
2773
|
+
await writeFile(join(dev, "file.txt"), "development changes\n");
|
|
2774
|
+
await git(["commit", "-am", "development changes"], dev);
|
|
2775
|
+
await git(["push", "origin", "aip/ISOLATION"], dev);
|
|
2776
|
+
const configuration = {
|
|
2777
|
+
projects: [
|
|
2778
|
+
{
|
|
2779
|
+
projectId: "project",
|
|
2780
|
+
projectName: "app",
|
|
2781
|
+
testBranch: "qa-shared",
|
|
2782
|
+
pipelines: [],
|
|
2783
|
+
instructions: "",
|
|
2784
|
+
},
|
|
2785
|
+
],
|
|
2786
|
+
};
|
|
2787
|
+
const deployment = await prepareDeploymentProjects(deployRoot, projects, configuration);
|
|
2788
|
+
expect((await git(["branch", "--show-current"], deployment)).stdout.trim()).toBe("qa-shared");
|
|
2789
|
+
await git(["config", "user.name", "AIP Test"], deployment);
|
|
2790
|
+
await git(["config", "user.email", "aip@example.test"], deployment);
|
|
2791
|
+
await expect(git(["merge", "origin/aip/ISOLATION"], deployment)).rejects.toThrow();
|
|
2792
|
+
const conflict = await readFile(join(deployment, "file.txt"), "utf8");
|
|
2793
|
+
const mergeHead = (await git(["rev-parse", "MERGE_HEAD"], deployment)).stdout;
|
|
2794
|
+
expect(await prepareDeploymentProjects(deployRoot, projects, configuration)).toBe(deployment);
|
|
2795
|
+
expect(await readFile(join(deployment, "file.txt"), "utf8")).toBe(conflict);
|
|
2796
|
+
expect((await git(["rev-parse", "MERGE_HEAD"], deployment)).stdout).toBe(mergeHead);
|
|
2797
|
+
expect(await prepareProjects(join(testRoot, "cache"), devRoot, "ISOLATION", projects, true)).toBe(dev);
|
|
2798
|
+
expect((await git(["branch", "--show-current"], dev)).stdout.trim()).toBe("aip/ISOLATION");
|
|
2799
|
+
expect((await git(["status", "--porcelain"], dev)).stdout.trim()).toBe("");
|
|
2800
|
+
const https = "https://git.example.test/group/app.git";
|
|
2801
|
+
const migrated = projects.map((project) => ({
|
|
2802
|
+
...project,
|
|
2803
|
+
repositoryUrl: https,
|
|
2804
|
+
}));
|
|
2805
|
+
await git(["remote", "set-url", "origin", https], dev);
|
|
2806
|
+
await git(["remote", "set-url", "origin", https], deployment);
|
|
2807
|
+
await git(["config", "remote.origin.pushurl", https], deployment);
|
|
2808
|
+
await writeFile(join(dev, "pending.txt"), "uncommitted");
|
|
2809
|
+
const head = (await git(["rev-parse", "HEAD"], dev)).stdout;
|
|
2810
|
+
await prepareProjects(join(testRoot, "cache"), devRoot, "ISOLATION", migrated, true);
|
|
2811
|
+
await prepareDeploymentProjects(deployRoot, migrated, configuration);
|
|
2812
|
+
for (const cwd of [dev, deployment]) {
|
|
2813
|
+
expect((await git(["config", "--get", "remote.origin.url"], cwd)).stdout.trim()).toBe(https);
|
|
2814
|
+
}
|
|
2815
|
+
expect((await git(["config", "--get", "remote.origin.pushurl"], deployment)).stdout.trim()).toBe(https);
|
|
2816
|
+
expect((await git(["rev-parse", "HEAD"], dev)).stdout).toBe(head);
|
|
2817
|
+
expect(await readFile(join(dev, "pending.txt"), "utf8")).toBe("uncommitted");
|
|
2818
|
+
expect(await readFile(join(deployment, "file.txt"), "utf8")).toBe(conflict);
|
|
2819
|
+
expect((await git(["rev-parse", "MERGE_HEAD"], deployment)).stdout).toBe(mergeHead);
|
|
2820
|
+
});
|
|
2821
|
+
it("SSH 仓库地址被拒绝,不尝试 SSH 认证或改用其他地址", async () => {
|
|
2822
|
+
const source = join(testRoot, "ssh-source");
|
|
2823
|
+
await mkdir(source);
|
|
2824
|
+
await execFileAsync("git", ["init", "--bare", source]);
|
|
2825
|
+
vi.stubEnv("GIT_SSH_COMMAND", "exit 1");
|
|
2826
|
+
await expect(prepareProjects(join(testRoot, "ssh-cache"), join(testRoot, "ssh-run"), "SSH", [
|
|
2827
|
+
{
|
|
2828
|
+
id: "ssh-project",
|
|
2829
|
+
name: "app",
|
|
2830
|
+
repositoryUrl: "ssh://git@ssh.example.test:2222/group/app.git",
|
|
2831
|
+
baselineBranch: "main",
|
|
2832
|
+
baselineCommit: "",
|
|
2833
|
+
devBranch: "aip/SSH",
|
|
2834
|
+
testBranch: "test",
|
|
2835
|
+
},
|
|
2836
|
+
], false)).rejects.toThrow("GIT_HTTP_URL_REQUIRED");
|
|
2837
|
+
});
|
|
2838
|
+
it.each([false, true])("复用仓库验证远端、归属与干净边界(Git insteadOf=%s)", async (alias) => {
|
|
2839
|
+
const source = join(testRoot, "source");
|
|
2840
|
+
const cache = join(testRoot, "cache");
|
|
2841
|
+
const runRoot = join(testRoot, "run");
|
|
2842
|
+
await mkdir(source, { recursive: true });
|
|
2843
|
+
await mkdir(runRoot, { recursive: true });
|
|
2844
|
+
await execFileAsync("git", ["init", "-b", "main"], { cwd: source });
|
|
2845
|
+
await execFileAsync("git", ["config", "user.name", "AIP Test"], { cwd: source });
|
|
2846
|
+
await execFileAsync("git", ["config", "user.email", "aip@example.test"], { cwd: source });
|
|
2847
|
+
await writeFile(join(source, "README.md"), "fixture\n");
|
|
2848
|
+
await execFileAsync("git", ["add", "."], { cwd: source });
|
|
2849
|
+
await execFileAsync("git", ["commit", "-m", "fixture"], { cwd: source });
|
|
2850
|
+
const baselineCommit = (await execFileAsync("git", ["rev-parse", "HEAD"], { cwd: source })).stdout.trim();
|
|
2851
|
+
const projects = [
|
|
2852
|
+
{
|
|
2853
|
+
id: "44444444-4444-4444-8444-444444444444",
|
|
2854
|
+
name: "fixture",
|
|
2855
|
+
repositoryUrl: source,
|
|
2856
|
+
baselineCommit,
|
|
2857
|
+
baselineBranch: "main",
|
|
2858
|
+
devBranch: "",
|
|
2859
|
+
testBranch: "test",
|
|
2860
|
+
},
|
|
2861
|
+
];
|
|
2862
|
+
if (alias) {
|
|
2863
|
+
const declaredUrl = "https://git.example.test/team/fixture.git";
|
|
2864
|
+
vi.stubEnv("GIT_CONFIG_COUNT", "1");
|
|
2865
|
+
vi.stubEnv("GIT_CONFIG_KEY_0", `url.${source}.insteadOf`);
|
|
2866
|
+
vi.stubEnv("GIT_CONFIG_VALUE_0", declaredUrl);
|
|
2867
|
+
projects[0].repositoryUrl = declaredUrl;
|
|
2868
|
+
await expect(prepareProjects(cache, runRoot, "BAOFU-245", projects, false)).rejects.toThrow("GIT_HTTP_REWRITE_CONFLICT");
|
|
2869
|
+
return;
|
|
2870
|
+
}
|
|
2871
|
+
const [cwd, otherCwd] = await Promise.all([
|
|
2872
|
+
prepareProjects(cache, runRoot, "BAOFU-245", projects, false),
|
|
2873
|
+
prepareProjects(cache, `${runRoot}-other`, "BAOFU-246", projects, false),
|
|
2874
|
+
]);
|
|
2875
|
+
expect((await execFileAsync("git", ["branch", "--show-current"], { cwd: otherCwd })).stdout.trim()).toBe("aip/BAOFU-246");
|
|
2876
|
+
expect(cwd).toBe(join(runRoot, "fixture"));
|
|
2877
|
+
expect((await execFileAsync("git", ["branch", "--show-current"], { cwd })).stdout.trim()).toBe("aip/BAOFU-245");
|
|
2878
|
+
await expect(prepareProjects(cache, runRoot, "BAOFU-245", projects, false)).resolves.toBe(cwd);
|
|
2879
|
+
await writeFile(join(cwd, "README.md"), "本 Run 修改\n");
|
|
2880
|
+
// 重复机械准备保持本 Run 的工作现场,不清除已有修改。
|
|
2881
|
+
await expect(prepareProjects(cache, runRoot, "BAOFU-245", projects, false)).resolves.toBe(cwd);
|
|
2882
|
+
await expect(prepareProjects(cache, runRoot, "BAOFU-245", projects, true)).resolves.toBe(cwd);
|
|
2883
|
+
await execFileAsync("git", [
|
|
2884
|
+
"--git-dir",
|
|
2885
|
+
join(cache, `${projects[0].id}.git`),
|
|
2886
|
+
"remote",
|
|
2887
|
+
"set-url",
|
|
2888
|
+
"origin",
|
|
2889
|
+
testRoot,
|
|
2890
|
+
]);
|
|
2891
|
+
await expect(prepareProjects(cache, runRoot, "BAOFU-245", projects, true)).rejects.toThrow("CODING_REPOSITORY_ORIGIN_MISMATCH");
|
|
2892
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
2893
|
+
it.each([false, true])("共享缓存 legacyMirror=%s:准备第二工单不改第一工单分支和现场", async (legacyMirror) => {
|
|
2894
|
+
const source = join(testRoot, "shared-source");
|
|
2895
|
+
const cache = join(testRoot, "shared-cache");
|
|
2896
|
+
await mkdir(source);
|
|
2897
|
+
await mkdir(cache);
|
|
2898
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
2899
|
+
await git(source, "init", "-b", "main");
|
|
2900
|
+
await writeFile(join(source, "rule.txt"), "baseline\n");
|
|
2901
|
+
await git(source, "add", ".");
|
|
2902
|
+
await git(source, "-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", "baseline");
|
|
2903
|
+
const baselineCommit = await git(source, "rev-parse", "HEAD");
|
|
2904
|
+
const project = {
|
|
2905
|
+
id: "shared-project",
|
|
2906
|
+
name: "fixture",
|
|
2907
|
+
repositoryUrl: source,
|
|
2908
|
+
baselineCommit,
|
|
2909
|
+
baselineBranch: "main",
|
|
2910
|
+
devBranch: "",
|
|
2911
|
+
testBranch: "test",
|
|
2912
|
+
};
|
|
2913
|
+
const mirror = join(cache, `${project.id}.git`);
|
|
2914
|
+
if (legacyMirror)
|
|
2915
|
+
await git(source, "clone", "--mirror", source, mirror);
|
|
2916
|
+
const first = await prepareProjects(cache, join(testRoot, "run-a"), "run-a", [project], false);
|
|
2917
|
+
const branch = await git(first, "branch", "--show-current");
|
|
2918
|
+
await git(first, "-c", "remote.origin.mirror=false", "push", "origin", `${baselineCommit}:refs/heads/${branch}`);
|
|
2919
|
+
await writeFile(join(first, "rule.txt"), "local commit\n");
|
|
2920
|
+
await git(first, "add", ".");
|
|
2921
|
+
await git(first, "-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", "local work");
|
|
2922
|
+
const head = await git(first, "rev-parse", "HEAD");
|
|
2923
|
+
await writeFile(join(first, "rule.txt"), "uncommitted work\n");
|
|
2924
|
+
const beforeStatus = await git(first, "status", "--porcelain");
|
|
2925
|
+
const second = await prepareProjects(cache, join(testRoot, "run-b"), "run-b", [{ ...project, devBranch: "aip/run-b/shared" }], false);
|
|
2926
|
+
expect(await git(second, "rev-parse", "HEAD")).toBe(baselineCommit);
|
|
2927
|
+
expect(await git(first, "rev-parse", "HEAD")).toBe(head);
|
|
2928
|
+
expect(await git(first, "branch", "--show-current")).toBe(branch);
|
|
2929
|
+
expect(await readFile(join(first, "rule.txt"), "utf8")).toBe("uncommitted work\n");
|
|
2930
|
+
expect(await git(first, "status", "--porcelain")).toBe(beforeStatus);
|
|
2931
|
+
expect(await git(mirror, "rev-parse", `refs/remotes/origin/${branch}`)).toBe(baselineCommit);
|
|
2932
|
+
await expect(prepareProjects(cache, join(testRoot, "run-a"), "run-a", [project], true)).resolves.toBe(first);
|
|
2933
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
2934
|
+
it("失败后检查初始化事实,缺失目录与损坏缓存不会混为一谈", async () => {
|
|
2935
|
+
const input = {
|
|
2936
|
+
workItem: { key: "INIT" },
|
|
2937
|
+
projects: [{ id: "project", name: "fixture", devBranch: "aip/INIT" }],
|
|
2938
|
+
};
|
|
2939
|
+
expect(await inspectWorkspaceInitialization("old", input)).toEqual([
|
|
2940
|
+
{ projectId: "project", status: "NOT_INITIALIZED" },
|
|
2941
|
+
]);
|
|
2942
|
+
// Check the actual configured cache path rather than inventing a replacement workspace.
|
|
2943
|
+
const { paths } = await import("../src/paths.js");
|
|
2944
|
+
const mirror = join(paths().repositoryCache, "project.git");
|
|
2945
|
+
await mkdir(mirror, { recursive: true });
|
|
2946
|
+
expect(await inspectWorkspaceInitialization("old", input)).toEqual([
|
|
2947
|
+
{ projectId: "project", status: "UNKNOWN" },
|
|
2948
|
+
]);
|
|
2949
|
+
const target = join(paths().runWorktrees, "old", "fixture");
|
|
2950
|
+
await mkdir(target, { recursive: true });
|
|
2951
|
+
expect(await inspectWorkspaceInitialization("old", input)).toEqual([
|
|
2952
|
+
{ projectId: "project", status: "UNKNOWN" },
|
|
2953
|
+
]);
|
|
2954
|
+
await execFileAsync("git", ["init", "-b", "aip/INIT", target]);
|
|
2955
|
+
await execFileAsync("git", [
|
|
2956
|
+
"-c",
|
|
2957
|
+
"user.name=Test",
|
|
2958
|
+
"-c",
|
|
2959
|
+
"user.email=test@example.test",
|
|
2960
|
+
"commit",
|
|
2961
|
+
"--allow-empty",
|
|
2962
|
+
"-m",
|
|
2963
|
+
"initial",
|
|
2964
|
+
], { cwd: target });
|
|
2965
|
+
expect(await inspectWorkspaceInitialization("old", input)).toEqual([
|
|
2966
|
+
{ projectId: "project", status: "INITIALIZED" },
|
|
2967
|
+
]);
|
|
2968
|
+
});
|
|
2969
|
+
it("转交使用已推送分支并隔离同机旧现场,往返时检查最新远端", async () => {
|
|
2970
|
+
const source = join(testRoot, "transfer-source");
|
|
2971
|
+
const cache = join(testRoot, "transfer-cache");
|
|
2972
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
2973
|
+
const commit = async (cwd, message) => {
|
|
2974
|
+
await git(cwd, "add", ".");
|
|
2975
|
+
await git(cwd, "-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", message);
|
|
2976
|
+
return git(cwd, "rev-parse", "HEAD");
|
|
2977
|
+
};
|
|
2978
|
+
await mkdir(source);
|
|
2979
|
+
await git(source, "init", "-b", "main");
|
|
2980
|
+
await writeFile(join(source, "file.txt"), "baseline");
|
|
2981
|
+
const baselineCommit = await commit(source, "baseline");
|
|
2982
|
+
const project = {
|
|
2983
|
+
id: "transfer-project",
|
|
2984
|
+
name: "fixture",
|
|
2985
|
+
repositoryUrl: source,
|
|
2986
|
+
baselineCommit,
|
|
2987
|
+
baselineBranch: "main",
|
|
2988
|
+
devBranch: "aip/TRANSFER",
|
|
2989
|
+
testBranch: "test",
|
|
2990
|
+
};
|
|
2991
|
+
const aId = "11111111-1111-1111-1111-111111111111";
|
|
2992
|
+
const aRoot = join(testRoot, aId);
|
|
2993
|
+
const uninitialized = { ...project, id: "uninitialized", devBranch: "aip/NEW" };
|
|
2994
|
+
const firstPreparation = await prepareProjects(cache, join(testRoot, "first-after-transfer"), "NEW", [uninitialized], false, true, ["uninitialized"]);
|
|
2995
|
+
expect(await git(firstPreparation, "rev-parse", "HEAD")).toBe(baselineCommit);
|
|
2996
|
+
const a = await prepareProjects(cache, aRoot, "TRANSFER", [project], false);
|
|
2997
|
+
await writeFile(join(a, "file.txt"), "A delivery");
|
|
2998
|
+
const aCommit = await commit(a, "A delivery");
|
|
2999
|
+
await expect(prepareProjects(cache, join(testRoot, "transfer-unpublished"), "TRANSFER", [project], false)).rejects.toThrow("CODING_BRANCH_NOT_PUBLISHED");
|
|
3000
|
+
expect(await git(a, "rev-parse", "HEAD")).toBe(aCommit);
|
|
3001
|
+
await expect(prepareProjects(join(testRoot, "unpublished-other-cache"), join(testRoot, "unpublished-other-run"), "TRANSFER", [project], false, true)).rejects.toThrow("CODING_BRANCH_INITIALIZATION_UNCONFIRMED");
|
|
3002
|
+
await git(a, "push", "origin", "HEAD:refs/heads/aip/TRANSFER");
|
|
3003
|
+
await writeFile(join(a, "draft.txt"), "A unpublished draft");
|
|
3004
|
+
// 换到另一台 Host 时逐项目判断:已发布的从远端准备,只有确认从未初始化的项目可从基准创建。
|
|
3005
|
+
const switchedRoot = join(testRoot, "switched-host-run");
|
|
3006
|
+
const fresh = { ...uninitialized, name: "fresh" };
|
|
3007
|
+
const unknown = { ...project, id: "unknown", name: "unknown", devBranch: "aip/UNKNOWN" };
|
|
3008
|
+
await expect(prepareProjects(join(testRoot, "switched-host-cache"), switchedRoot, "TRANSFER", [project, fresh, unknown], false, true, [fresh.id])).rejects.toThrow("CODING_BRANCH_INITIALIZATION_UNCONFIRMED");
|
|
3009
|
+
expect(await git(join(switchedRoot, project.name), "rev-parse", "HEAD")).toBe(aCommit);
|
|
3010
|
+
expect(await git(join(switchedRoot, fresh.name), "rev-parse", "HEAD")).toBe(baselineCommit);
|
|
3011
|
+
await expect(readFile(join(switchedRoot, unknown.name, ".git"))).rejects.toMatchObject({
|
|
3012
|
+
code: "ENOENT",
|
|
3013
|
+
});
|
|
3014
|
+
await expect(readFile(join(switchedRoot, project.name, "draft.txt"))).rejects.toMatchObject({
|
|
3015
|
+
code: "ENOENT",
|
|
3016
|
+
});
|
|
3017
|
+
const b = await prepareProjects(cache, join(testRoot, "transfer-b"), "TRANSFER", [project], false);
|
|
3018
|
+
expect(await git(b, "rev-parse", "HEAD")).toBe(aCommit);
|
|
3019
|
+
expect(await git(b, "branch", "--show-current")).toBe("aip/TRANSFER");
|
|
3020
|
+
expect(await readFile(join(a, "draft.txt"), "utf8")).toBe("A unpublished draft");
|
|
3021
|
+
expect(await git(b, "status", "--porcelain")).toBe("");
|
|
3022
|
+
await writeFile(join(b, "file.txt"), "B delivery");
|
|
3023
|
+
const bCommit = await commit(b, "B delivery");
|
|
3024
|
+
await git(b, "push", "origin", "HEAD");
|
|
3025
|
+
await expect(prepareProjects(cache, aRoot, "TRANSFER", [project], true, true)).rejects.toThrow("CODING_WORKTREE_REMOTE_AHEAD_DIRTY");
|
|
3026
|
+
expect(await git(a, "rev-parse", "HEAD")).toBe(aCommit);
|
|
3027
|
+
expect(await readFile(join(a, "draft.txt"), "utf8")).toBe("A unpublished draft");
|
|
3028
|
+
const notes = await inspectPriorTransferWorkspaces(testRoot, [aId], [project]);
|
|
3029
|
+
expect(notes.join()).toContain("有未提交修改");
|
|
3030
|
+
expect(notes.join()).toContain("远端领先 1");
|
|
3031
|
+
const returned = await prepareProjects(cache, join(testRoot, "new-a-run"), "TRANSFER", [project], false, true);
|
|
3032
|
+
expect(await git(returned, "rev-parse", "HEAD")).toBe(bCommit);
|
|
3033
|
+
expect(await readFile(join(a, "draft.txt"), "utf8")).toBe("A unpublished draft");
|
|
3034
|
+
// User resolves the local draft; A can now fast-forward to B's delivery.
|
|
3035
|
+
await rm(join(a, "draft.txt"));
|
|
3036
|
+
await prepareProjects(cache, aRoot, "TRANSFER", [project], true, true);
|
|
3037
|
+
expect(await git(a, "rev-parse", "HEAD")).toBe(bCommit);
|
|
3038
|
+
await writeFile(join(a, "file.txt"), "A local commit");
|
|
3039
|
+
const unpublished = await commit(a, "A local commit");
|
|
3040
|
+
await writeFile(join(b, "file.txt"), "B newer delivery");
|
|
3041
|
+
await commit(b, "B newer delivery");
|
|
3042
|
+
await git(b, "push", "origin", "HEAD");
|
|
3043
|
+
await expect(prepareProjects(cache, aRoot, "TRANSFER", [project], true, true)).rejects.toThrow("CODING_WORKTREE_DIVERGED");
|
|
3044
|
+
expect(await git(a, "rev-parse", "HEAD")).toBe(unpublished);
|
|
3045
|
+
expect((await inspectPriorTransferWorkspaces(testRoot, [aId], [project])).join()).toContain("已分叉");
|
|
3046
|
+
// A different Host also starts from the published branch, never from baseline.
|
|
3047
|
+
const c = await prepareProjects(join(testRoot, "other-host-cache"), join(testRoot, "transfer-c"), "TRANSFER", [project], false);
|
|
3048
|
+
expect(await git(c, "rev-parse", "HEAD")).toBe(await git(b, "rev-parse", "HEAD"));
|
|
3049
|
+
}, process.platform === "win32" ? 60_000 : 20_000);
|
|
3050
|
+
it.each([true, false])("新建会话接续旧工作树:换回该 Host 时读取最新工单分支,原 Host 保留修改(hostChanged=%s)", async (hostChanged) => {
|
|
3051
|
+
const { paths } = await import("../src/paths.js");
|
|
3052
|
+
const source = join(testRoot, "recovery-source");
|
|
3053
|
+
const git = async (cwd, ...args) => (await execFileAsync("git", args, { cwd })).stdout.trim();
|
|
3054
|
+
await mkdir(source);
|
|
3055
|
+
await git(source, "init", "-b", "main");
|
|
3056
|
+
await git(source, "config", "user.name", "AIP Test");
|
|
3057
|
+
await git(source, "config", "user.email", "aip@example.test");
|
|
3058
|
+
await writeFile(join(source, "work.txt"), "原版本");
|
|
3059
|
+
await git(source, "add", "work.txt");
|
|
3060
|
+
await git(source, "commit", "-m", "baseline");
|
|
3061
|
+
const original = await git(source, "rev-parse", "HEAD");
|
|
3062
|
+
const project = {
|
|
3063
|
+
id: "recovery-project",
|
|
3064
|
+
name: "fixture",
|
|
3065
|
+
repositoryUrl: source,
|
|
3066
|
+
devBranch: "aip/AIP-1",
|
|
3067
|
+
baselineBranch: "main",
|
|
3068
|
+
baselineCommit: original,
|
|
3069
|
+
testBranch: "test",
|
|
3070
|
+
};
|
|
3071
|
+
await git(source, "switch", "-c", project.devBranch);
|
|
3072
|
+
const worktree = await prepareProjects(paths().repositoryCache, join(paths().runWorktrees, runId), "AIP-1", [project], false);
|
|
3073
|
+
await writeFile(join(source, "work.txt"), "远端最新版本");
|
|
3074
|
+
await git(source, "commit", "-am", "advance work-item branch");
|
|
3075
|
+
const published = await git(source, "rev-parse", project.devBranch);
|
|
3076
|
+
expect(await git(worktree, "rev-parse", "HEAD")).toBe(original);
|
|
3077
|
+
expect(await git(worktree, "status", "--porcelain")).toBe("");
|
|
3078
|
+
if (!hostChanged)
|
|
3079
|
+
await writeFile(join(worktree, "work.txt"), "本机未提交修改");
|
|
3080
|
+
piMocks.createSession.mockReturnValue(mockSessionManager("recovery.jsonl"));
|
|
3081
|
+
piMocks.createAgentSession.mockResolvedValue({
|
|
3082
|
+
session: { subscribe: vi.fn(), prompt: vi.fn().mockResolvedValue(undefined) },
|
|
3083
|
+
});
|
|
3084
|
+
const manager = new CodingRunManager({
|
|
3085
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
3086
|
+
});
|
|
3087
|
+
const client = {
|
|
3088
|
+
employeeConfig,
|
|
3089
|
+
appendCodingEvents: vi.fn().mockResolvedValue({ accepted: true }),
|
|
3090
|
+
evaluateContinuation: vi
|
|
3091
|
+
.fn()
|
|
3092
|
+
.mockResolvedValue({ decision: "SKIP", reason: "USER_MESSAGE" }),
|
|
3093
|
+
};
|
|
3094
|
+
await manager.execute(client, host, command("RESUME", {
|
|
3095
|
+
runInput: {
|
|
3096
|
+
...runInput,
|
|
3097
|
+
phase: "DEVELOPMENT",
|
|
3098
|
+
projects: [project],
|
|
3099
|
+
sessionRecovery: {
|
|
3100
|
+
mode: "NEW_SESSION",
|
|
3101
|
+
hostChanged,
|
|
3102
|
+
expectedSessionId: null,
|
|
3103
|
+
lastEventSequence: 0,
|
|
3104
|
+
context: "",
|
|
3105
|
+
},
|
|
3106
|
+
},
|
|
3107
|
+
}));
|
|
3108
|
+
await vi.waitFor(() => expect(manager.isBusy()).toBe(false));
|
|
3109
|
+
expect(piMocks.createAgentSession).toHaveBeenCalledWith(expect.objectContaining({ cwd: worktree }));
|
|
3110
|
+
expect(await git(worktree, "rev-parse", "HEAD")).toBe(hostChanged ? published : original);
|
|
3111
|
+
expect(await readFile(join(worktree, "work.txt"), "utf8")).toBe(hostChanged ? "远端最新版本" : "本机未提交修改");
|
|
3112
|
+
}, process.platform === "win32" ? 60_000 : 15_000);
|
|
3113
|
+
it("准备访问失败后RESUME可创建尚不存在的worktree且不提前创建Session", async () => {
|
|
3114
|
+
const source = join(testRoot, "resume-source");
|
|
3115
|
+
const hidden = join(testRoot, "unavailable-source");
|
|
3116
|
+
await mkdir(source);
|
|
3117
|
+
const git = async (...args) => (await execFileAsync("git", args, { cwd: source })).stdout.trim();
|
|
3118
|
+
await git("init", "-b", "main");
|
|
3119
|
+
await writeFile(join(source, "rule.txt"), "baseline\n");
|
|
3120
|
+
await git("add", ".");
|
|
3121
|
+
await git("-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", "baseline");
|
|
3122
|
+
const baselineCommit = await git("rev-parse", "HEAD");
|
|
3123
|
+
const input = {
|
|
3124
|
+
...runInput,
|
|
3125
|
+
requirement: null,
|
|
3126
|
+
phase: "PREPARATION",
|
|
3127
|
+
primaryProjectId: "resume-project",
|
|
3128
|
+
projects: [
|
|
3129
|
+
{
|
|
3130
|
+
id: "resume-project",
|
|
3131
|
+
name: "fixture",
|
|
3132
|
+
repositoryUrl: source,
|
|
3133
|
+
baselineCommit,
|
|
3134
|
+
baselineBranch: "main",
|
|
3135
|
+
devBranch: `aip/${runId}/44444444`,
|
|
3136
|
+
testBranch: "test",
|
|
3137
|
+
},
|
|
3138
|
+
],
|
|
3139
|
+
};
|
|
3140
|
+
const appendCodingEvents = vi.fn().mockResolvedValue({ accepted: true });
|
|
3141
|
+
const client = { employeeConfig, appendCodingEvents, reportCodingTerminal: vi.fn() };
|
|
3142
|
+
const manager = new CodingRunManager({});
|
|
3143
|
+
await rename(source, hidden);
|
|
3144
|
+
await expect(manager.execute(client, host, command("START", { runInput: input }))).rejects.toThrow("CODING_REPOSITORY_ACCESS_FAILED");
|
|
3145
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
3146
|
+
await rename(hidden, source);
|
|
3147
|
+
await manager.execute(client, host, command("RESUME", { runInput: input }));
|
|
3148
|
+
expect(await readFile(join(testRoot, "profiles", "default", "workspaces", "runs", runId, "fixture", "rule.txt"), "utf8")).toBe("baseline\n");
|
|
3149
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
3150
|
+
expect(appendCodingEvents.mock.calls.flatMap((call) => call[1].events.map((event) => event.kind))).toEqual(["PREPARATION_COMPLETED"]);
|
|
3151
|
+
await expect(readFile(join(testRoot, "profiles", "default", "workspaces", "runs", runId, "fixture", "docs/aip/AIP-1/prd.md"))).rejects.toMatchObject({ code: "ENOENT" });
|
|
3152
|
+
});
|
|
3153
|
+
it("上传前脱敏凭证、环境变量与完整本地路径", () => {
|
|
3154
|
+
expect(redactHostText('Bearer abc.def TOKEN=top-secret {"access_token":"oauth-secret"} /Users/xiachen/private/file.ts C:\\Users\\name\\secret.txt')).toBe('Bearer [已脱敏] TOKEN=[已脱敏] {"access_token":"[已脱敏]"} [本地路径] [本地路径]');
|
|
3155
|
+
});
|
|
3156
|
+
it("旧 Deep Agents 会话明确拒绝续接且不删历史", async () => {
|
|
3157
|
+
await mkdir(join(testRoot, "profiles", "default", "state/runs"), { recursive: true });
|
|
3158
|
+
const stateFile = join(testRoot, "profiles", "default", "state/runs", `${runId}.json`);
|
|
3159
|
+
await writeFile(stateFile, JSON.stringify({
|
|
3160
|
+
prepared: true,
|
|
3161
|
+
phase: "DEPLOYMENT",
|
|
3162
|
+
harness: "deepagents",
|
|
3163
|
+
phaseSessions: { DEPLOYMENT: "aaaaaaaa-aaaa-7aaa-8aaa-aaaaaaaaaaaa" },
|
|
3164
|
+
sessionRef: "aaaaaaaa-aaaa-7aaa-8aaa-aaaaaaaaaaaa",
|
|
3165
|
+
}));
|
|
3166
|
+
const manager = new CodingRunManager({
|
|
3167
|
+
resolveRuntimeModel: vi.fn().mockResolvedValue({ runtime: {}, model: {} }),
|
|
3168
|
+
});
|
|
3169
|
+
await expect(manager.execute({ employeeConfig, appendCodingEvents: vi.fn(), reportCodingTerminal: vi.fn() }, host, command("RESUME"))).rejects.toThrow(/PRIOR_HARNESS_SESSION_UNSUPPORTED/);
|
|
3170
|
+
expect(piMocks.createAgentSession).not.toHaveBeenCalled();
|
|
3171
|
+
expect(JSON.parse(await readFile(stateFile, "utf8")).harness).toBe("deepagents");
|
|
3172
|
+
});
|
|
3173
|
+
it("工作区摘要忽略平台审查报告但保留源码及其他工单变化", async () => {
|
|
3174
|
+
const source = join(testRoot, "review-tree");
|
|
3175
|
+
await mkdir(source);
|
|
3176
|
+
const git = async (...args) => (await execFileAsync("git", args, { cwd: source })).stdout.trim();
|
|
3177
|
+
await git("init", "-b", "main");
|
|
3178
|
+
await writeFile(join(source, "app.ts"), "export const value = 1;\n");
|
|
3179
|
+
await git("add", ".");
|
|
3180
|
+
await git("-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", "baseline");
|
|
3181
|
+
const baseline = await worktreeTreeHash(source, "AIP-1");
|
|
3182
|
+
const reportRoot = join(source, "docs/aip/AIP-1");
|
|
3183
|
+
await mkdir(join(reportRoot, "reviews"), { recursive: true });
|
|
3184
|
+
await writeFile(join(reportRoot, "system_review.md"), "审查通过");
|
|
3185
|
+
await writeFile(join(reportRoot, "reviews/round-01.md"), "第一轮报告");
|
|
3186
|
+
await writeFile(join(reportRoot, "deployment.md"), "实际部署记录");
|
|
3187
|
+
await mkdir(join(reportRoot, "handoff"));
|
|
3188
|
+
await writeFile(join(reportRoot, "handoff/base-1.md"), "原始交接材料");
|
|
3189
|
+
await writeFile(join(reportRoot, "handoff/confirmed-6.md"), "确认交接材料");
|
|
3190
|
+
expect(await worktreeTreeHash(source, "AIP-1")).toBe(baseline);
|
|
3191
|
+
await git("add", ".");
|
|
3192
|
+
const indexBefore = await git("write-tree");
|
|
3193
|
+
await git("-c", "user.name=Test", "-c", "user.email=test@example.test", "commit", "-m", "reports");
|
|
3194
|
+
expect(await worktreeTreeHash(source, "AIP-1", true)).toBe(baseline);
|
|
3195
|
+
expect(await git("write-tree")).toBe(indexBefore);
|
|
3196
|
+
await writeFile(join(source, "app.ts"), "export const value = 2;\n");
|
|
3197
|
+
expect(await worktreeTreeHash(source, "AIP-1")).not.toBe(baseline);
|
|
3198
|
+
await git("restore", "app.ts");
|
|
3199
|
+
await writeFile(join(reportRoot, "handoff/business.md"), "真实业务文档");
|
|
3200
|
+
expect(await worktreeTreeHash(source, "AIP-1")).not.toBe(baseline);
|
|
3201
|
+
await rm(join(reportRoot, "handoff/business.md"));
|
|
3202
|
+
await mkdir(join(source, "docs/aip/AIP-2"), { recursive: true });
|
|
3203
|
+
await writeFile(join(source, "docs/aip/AIP-2/system_review.md"), "其他工单材料");
|
|
3204
|
+
expect(await worktreeTreeHash(source, "AIP-1")).not.toBe(baseline);
|
|
3205
|
+
});
|
|
3206
|
+
it("真实 Pi 不可用时明确失败", async () => {
|
|
3207
|
+
const manager = new CodingRunManager({});
|
|
3208
|
+
await expect(manager.execute({ employeeConfig, appendCodingEvents: vi.fn(), reportCodingTerminal: vi.fn() }, host, command("START"))).rejects.toThrow("MODEL_RUNTIME_UNAVAILABLE");
|
|
3209
|
+
});
|
|
3210
|
+
});
|
|
3211
|
+
//# sourceMappingURL=coding-run-manager.test.js.map
|