@sanqianx/project-knowledge 5.0.24 → 5.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -20
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +1361 -1353
- package/LICENSE +201 -201
- package/NOTICE +5 -5
- package/README.md +349 -349
- package/_modules/knowledge-engine/package.json +1 -1
- package/_modules/knowledge-engine/src/coordinator.js +48 -3
- package/_modules/knowledge-engine/src/runtime/automation-config.js +140 -140
- package/_modules/knowledge-engine/src/runtime/commit-conversation-binder.js +238 -238
- package/_modules/knowledge-engine/src/runtime/commit-processing-ledger.js +26 -26
- package/_modules/knowledge-engine/src/runtime/commit-prompt.js +193 -193
- package/_modules/knowledge-engine/src/runtime/commit-reconciler.js +394 -394
- package/_modules/knowledge-engine/src/runtime/contracts.js +282 -282
- package/_modules/knowledge-engine/src/runtime/conversation-store.js +389 -389
- package/_modules/knowledge-engine/src/runtime/evidence-bundle.js +228 -228
- package/_modules/knowledge-engine/src/runtime/git-runner.js +62 -62
- package/_modules/knowledge-engine/src/runtime/knowledge-promotion.js +505 -505
- package/_modules/knowledge-engine/src/runtime/knowledge-retrieval-service.js +400 -400
- package/_modules/knowledge-engine/src/runtime/markdown-knowledge-indexer.js +171 -171
- package/_modules/knowledge-engine/src/runtime/scanner.js +298 -298
- package/_modules/knowledge-engine/ui/app.js +23 -2
- package/_site/README.md +30 -30
- package/_site/_test/agent-capture-mcp-ui-test.js +68 -68
- package/_site/_test/agent-capture-ui-test.js +101 -101
- package/_site/_test/ai-profile-resolver-test.js +137 -137
- package/_site/_test/ai-profile-test.js +75 -75
- package/_site/_test/ai-vendor-presets-test.js +91 -91
- package/_site/_test/automatic-context-test.js +70 -70
- package/_site/_test/automation-queue-test.js +14 -14
- package/_site/_test/automation-ui-test.js +40 -40
- package/_site/_test/background-task-registry-test.js +43 -43
- package/_site/_test/baseline-schema-test.js +91 -91
- package/_site/_test/bin-cli-test.js +230 -230
- package/_site/_test/bridge-adapter-test.js +95 -95
- package/_site/_test/bridge-consumer-service-test.js +310 -310
- package/_site/_test/candidate-bin-content-test.js +35 -35
- package/_site/_test/candidate-product-assets-test.js +13 -13
- package/_site/_test/candidate-release-contract-test.js +14 -14
- package/_site/_test/capture-hook-dedup-test.js +158 -158
- package/_site/_test/cdp-browser-failure-test.js +103 -103
- package/_site/_test/chat-claudecodeui-match-test.js +92 -92
- package/_site/_test/claude-executable-discovery-test.js +90 -90
- package/_site/_test/claude-session-lifecycle-sweep-test.js +252 -252
- package/_site/_test/claude-workbench-test.js +174 -174
- package/_site/_test/cli-instance-management-test.js +62 -62
- package/_site/_test/client-capture-restart-e2e-test.js +189 -189
- package/_site/_test/codex-conversation-projection-test.js +60 -60
- package/_site/_test/codex-marketplace-scoped-path-test.js +186 -186
- package/_site/_test/codex-notify-capture-e2e-test.js +101 -101
- package/_site/_test/codex-notify-fanout-test.js +141 -134
- package/_site/_test/codex-notify-upgrade-test.js +253 -253
- package/_site/_test/commit-boundary-freeze-test.js +147 -147
- package/_site/_test/commit-conversation-binding-test.js +99 -99
- package/_site/_test/commit-evidence-test.js +110 -110
- package/_site/_test/configuration-generation-test.js +22 -22
- package/_site/_test/context-pack-test.js +200 -200
- package/_site/_test/conversation-api-test.js +119 -119
- package/_site/_test/conversation-origin-test.js +15 -15
- package/_site/_test/conversation-store-test.js +138 -138
- package/_site/_test/cross-repo-isolation-e2e-test.js +187 -187
- package/_site/_test/desktop-browser-compat-test.js +28 -28
- package/_site/_test/desktop-hook-runtime-regression-test.js +204 -204
- package/_site/_test/embedding-config-test.js +32 -32
- package/_site/_test/explicit-commit-processor-test.js +37 -37
- package/_site/_test/fixtures/fake-browser-exit.js +10 -10
- package/_site/_test/fixtures/fake-browser-hang.js +10 -10
- package/_site/_test/fixtures/integration-busy-worker.cjs +6 -6
- package/_site/_test/fixtures/make-git-repos.js +92 -92
- package/_site/_test/fixtures/retrieval-gold-queries.json +32 -32
- package/_site/_test/folder-picker-output-test.js +19 -19
- package/_site/_test/fresh-hook-reimport-test.js +53 -53
- package/_site/_test/fresh-product-data-test.js +56 -56
- package/_site/_test/full-integration-e2e-test.js +167 -167
- package/_site/_test/git-path-compatibility-test.js +80 -80
- package/_site/_test/git-validation-test.js +81 -81
- package/_site/_test/glm-ui-refresh-review-test.js +313 -404
- package/_site/_test/harness-isolation-test.js +138 -0
- package/_site/_test/helpers/cdp-browser.js +383 -0
- package/_site/_test/helpers/cdp-network-capture.js +66 -0
- package/_site/_test/helpers/find-chrome.js +34 -0
- package/_site/_test/helpers/free-port.js +8 -0
- package/_site/_test/helpers/logging-ui-fixture.js +131 -0
- package/_site/_test/helpers/module-fixture.js +282 -0
- package/_site/_test/helpers/parallel-engine-advanced-engine-child.js +45 -0
- package/_site/_test/helpers/parallel-engine-advanced-fault-writer.js +171 -0
- package/_site/_test/helpers/parallel-engine-advanced-harness.js +245 -0
- package/_site/_test/helpers/parallel-engine-advanced-standin-analyzer.js +80 -0
- package/_site/_test/helpers/parallel-engine-advanced-ui-host.js +177 -0
- package/_site/_test/helpers/parallel-engine-final-harness.js +314 -0
- package/_site/_test/helpers/parallel-engine-final-standin-analyzer.js +159 -0
- package/_site/_test/helpers/parallel-knowledge-fixture.js +255 -0
- package/_site/_test/helpers/parallel-logging-acceptance-fixture.js +111 -0
- package/_site/_test/helpers/parallel-logging-acceptance-proxy.js +106 -0
- package/_site/_test/helpers/parallel-logging-fix-r2-proxy.js +205 -0
- package/_site/_test/helpers/parallel-logging-integration-5025-env.js +432 -0
- package/_site/_test/helpers/parallel-memory-analyzer.js +81 -0
- package/_site/_test/helpers/parallel-memory-event-bridge.js +128 -0
- package/_site/_test/helpers/parallel-memory-shell.js +470 -0
- package/_site/_test/helpers/parallel-nav-isolation-env.js +389 -0
- package/_site/_test/helpers/parallel-nav-module-ui.js +186 -0
- package/_site/_test/helpers/parallel-nav-proxy.js +148 -0
- package/_site/_test/helpers/parallel-nav-shell.js +361 -0
- package/_site/_test/helpers/parallel-qa-engine-endpoint-guard.js +206 -0
- package/_site/_test/helpers/parallel-qa-engine-endpoint-isolate.js +257 -0
- package/_site/_test/helpers/parallel-retrieval-followup-corpus.js +293 -0
- package/_site/_test/helpers/parallel-retrieval-followup-next-session.js +70 -0
- package/_site/_test/helpers/parallel-retrieval-followup-r2-shell.js +737 -0
- package/_site/_test/helpers/parallel-retrieval-followup-r2-wb-host.js +82 -0
- package/_site/_test/helpers/parallel-retrieval-followup-shell.js +279 -0
- package/_site/_test/helpers/parallel-workbench-fixture.js +371 -0
- package/_site/_test/helpers/parallel-workbench-host.js +80 -0
- package/_site/_test/helpers/parallel-workbench-integration-5025-fixture.js +408 -0
- package/_site/_test/helpers/parallel-workbench-integration-5025-harness.js +593 -0
- package/_site/_test/helpers/parallel-workbench-integration-5025-host.js +70 -0
- package/_site/_test/helpers/parallel-workbench-integration-5025-launcher.js +240 -0
- package/_site/_test/helpers/parallel-workbench-integration-5025-runtime-harness.js +630 -0
- package/_site/_test/helpers/parallel-workbench-source-map.js +196 -0
- package/_site/_test/helpers/spawn-server.js +106 -0
- package/_site/_test/helpers/version-visibility-fixture.js +251 -0
- package/_site/_test/hook-runtime-endpoint-test.js +88 -88
- package/_site/_test/hook-status-repair-api-test.js +152 -152
- package/_site/_test/hook-trigger-test.js +85 -85
- package/_site/_test/hook-worktree-test.js +42 -42
- package/_site/_test/import-preflight-api-test.js +234 -234
- package/_site/_test/index-builder-test.js +41 -41
- package/_site/_test/index-error-display-contract-test.js +10 -10
- package/_site/_test/index-writer-concurrency-test.js +135 -135
- package/_site/_test/integration-adapters-test.js +262 -262
- package/_site/_test/integration-auto-repair-test.js +113 -113
- package/_site/_test/integration-capture-setup-test.js +118 -118
- package/_site/_test/integration-intent-test.js +81 -81
- package/_site/_test/integration-runtime-binding-a2-test.js +566 -566
- package/_site/_test/integration-runtime-binding-a3-test.js +227 -227
- package/_site/_test/integration-runtime-binding-test.js +473 -473
- package/_site/_test/integration-status-scan-test.js +29 -29
- package/_site/_test/integration-surface-coverage-test.js +164 -164
- package/_site/_test/kb-framework-test.js +57 -57
- package/_site/_test/kbpath-follow-test.js +63 -63
- package/_site/_test/knowledge-db-test.js +144 -144
- package/_site/_test/knowledge-engine-client-test.js +120 -109
- package/_site/_test/knowledge-language-control-test.js +170 -170
- package/_site/_test/knowledge-maintenance-test.js +40 -40
- package/_site/_test/knowledge-promotion-recovery-test.js +260 -260
- package/_site/_test/knowledge-query-test.js +54 -54
- package/_site/_test/knowledge-retrieval-service-test.js +77 -77
- package/_site/_test/knowledge-scopes-test.js +37 -37
- package/_site/_test/knowledge-storage-location-test.js +28 -28
- package/_site/_test/knowledge-storage-startup-test.js +52 -52
- package/_site/_test/knowledge-store-logs-supervision-test.js +89 -89
- package/_site/_test/launcher-readiness-test.js +80 -80
- package/_site/_test/legacy-claude-session-alias-test.js +106 -106
- package/_site/_test/legacy-routes-removed-test.js +47 -47
- package/_site/_test/legacy-workbench-exclusion-test.js +92 -92
- package/_site/_test/live-gateway-test.js +48 -48
- package/_site/_test/local-marketplace-test.js +16 -16
- package/_site/_test/log-redaction-test.js +58 -58
- package/_site/_test/logging-api-test.js +89 -89
- package/_site/_test/logging-sse-no-gap-test.js +88 -88
- package/_site/_test/logging-ui-test.js +107 -107
- package/_site/_test/markdown-delta-overlay-test.js +85 -85
- package/_site/_test/markdown-maintenance-api-test.js +75 -75
- package/_site/_test/markdown-maintenance-test.js +11 -11
- package/_site/_test/mcp-server-test.js +149 -149
- package/_site/_test/model-context-windows-test.js +89 -89
- package/_site/_test/module-agent-start-proxy-test.js +65 -65
- package/_site/_test/module-artifact-integrity-test.js +27 -27
- package/_site/_test/module-boundary-test.js +30 -30
- package/_site/_test/module-bridge-eventbridge-test.js +202 -202
- package/_site/_test/module-dynamic-port-test.js +118 -118
- package/_site/_test/module-index-proxy-test.js +33 -33
- package/_site/_test/module-model-configuration-test.js +44 -44
- package/_site/_test/module-process-lifecycle-test.js +35 -35
- package/_site/_test/module-stream-proxy-test.js +34 -34
- package/_site/_test/module-terminal-restart-test.js +63 -63
- package/_site/_test/module-wiring-unbind-race-test.js +59 -59
- package/_site/_test/native-context-integrations-test.js +86 -86
- package/_site/_test/non-release-ci-test.js +34 -34
- package/_site/_test/offline-boundary-isolation-test.js +32 -32
- package/_site/_test/orphaned-claim-recovery-test.js +80 -80
- package/_site/_test/package-boundary-test.js +43 -43
- package/_site/_test/package-startup-test.js +56 -56
- package/_site/_test/packaged-ui-smoke-test.js +88 -88
- package/_site/_test/parallel-ci-r9-posix-socket-budget-test.js +156 -0
- package/_site/_test/parallel-engine-advanced-eng005-test.js +136 -0
- package/_site/_test/parallel-engine-advanced-eng006-test.js +171 -0
- package/_site/_test/parallel-engine-advanced-eng007-reconcile-test.js +231 -0
- package/_site/_test/parallel-engine-advanced-eng009-test.js +208 -0
- package/_site/_test/parallel-engine-advanced-eng010-test.js +213 -0
- package/_site/_test/parallel-engine-advanced-eng011-ui-probe.js +459 -0
- package/_site/_test/parallel-engine-final-eng002-test.js +255 -0
- package/_site/_test/parallel-engine-final-eng007-test.js +269 -0
- package/_site/_test/parallel-engine-final-eng011-test.js +197 -0
- package/_site/_test/parallel-engine-final-eng012-test.js +354 -0
- package/_site/_test/parallel-knowledge-client-error-code-test.js +184 -0
- package/_site/_test/parallel-knowledge-engine-test.js +353 -0
- package/_site/_test/parallel-knowledge-retrieval-test.js +292 -0
- package/_site/_test/parallel-knowledge-vector-test.js +168 -0
- package/_site/_test/parallel-linux-ci-r7-log007-day-test.js +110 -0
- package/_site/_test/parallel-logging-acceptance-log003-test.js +224 -0
- package/_site/_test/parallel-logging-acceptance-log004-test.js +231 -0
- package/_site/_test/parallel-logging-acceptance-log005-test.js +208 -0
- package/_site/_test/parallel-logging-acceptance-log006-test.js +214 -0
- package/_site/_test/parallel-logging-acceptance-log007-test.js +223 -0
- package/_site/_test/parallel-logging-acceptance-log008-test.js +180 -0
- package/_site/_test/parallel-logging-fix-r2-crash-probe.js +271 -0
- package/_site/_test/parallel-logging-fix-r2-gap-test.js +294 -0
- package/_site/_test/parallel-logging-fix-r2-normalhook-test.js +330 -0
- package/_site/_test/parallel-logging-integration-5025-portability-test.js +554 -0
- package/_site/_test/parallel-memory-candidate-test.js +301 -0
- package/_site/_test/parallel-memory-manual-test.js +197 -0
- package/_site/_test/parallel-memory-scope-test.js +228 -0
- package/_site/_test/parallel-memory-source-test.js +227 -0
- package/_site/_test/parallel-memory-sync-test.js +238 -0
- package/_site/_test/parallel-memory-view-r8-reload-gate-test.js +123 -0
- package/_site/_test/parallel-nav-failure-test.js +119 -0
- package/_site/_test/parallel-nav-isolation-test.js +308 -0
- package/_site/_test/parallel-nav-isolation-vector-path-test.js +90 -0
- package/_site/_test/parallel-nav-offline-test.js +272 -0
- package/_site/_test/parallel-nav-operability-test.js +257 -0
- package/_site/_test/parallel-nav-switch-test.js +247 -0
- package/_site/_test/parallel-nav-theme-test.js +130 -0
- package/_site/_test/parallel-nav-viewport-test.js +310 -0
- package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +273 -0
- package/_site/_test/parallel-retrieval-followup-citation-test.js +219 -0
- package/_site/_test/parallel-retrieval-followup-corpus-test.js +287 -0
- package/_site/_test/parallel-workbench-independent-host.js +262 -0
- package/_site/_test/parallel-workbench-integration-5025-abort-probe.js +340 -0
- package/_site/_test/parallel-workbench-integration-5025-drafts-probe.js +588 -0
- package/_site/_test/parallel-workbench-integration-5025-env-check.js +317 -0
- package/_site/_test/parallel-workbench-integration-5025-model-probe.js +342 -0
- package/_site/_test/parallel-workbench-integration-5025-ordering-probe.js +326 -0
- package/_site/_test/parallel-workbench-model-probe.js +336 -0
- package/_site/_test/parallel-workbench-offline-test.js +169 -0
- package/_site/_test/parallel-workbench-provenance-trace.js +134 -0
- package/_site/_test/parallel-workbench-source-match.js +206 -0
- package/_site/_test/parallel-workbench-standalone-turn.js +349 -0
- package/_site/_test/path-consistency-test.js +151 -151
- package/_site/_test/pending-sweep-test.js +9 -9
- package/_site/_test/post-commit-automation-test.js +87 -87
- package/_site/_test/pr-consumer-contract-test.js +55 -55
- package/_site/_test/product-brand-contract-test.js +25 -25
- package/_site/_test/product-diagnostics-ui-test.js +93 -93
- package/_site/_test/product-empty-state-test.js +148 -0
- package/_site/_test/product-import-ui-test.js +219 -104
- package/_site/_test/product-navigation-test.js +152 -0
- package/_site/_test/product-progress-status-test.js +84 -84
- package/_site/_test/project-delete-recovery-test.js +64 -64
- package/_site/_test/project-domain-create-test.js +91 -0
- package/_site/_test/project-domain-scope-retrieval-test.js +214 -0
- package/_site/_test/project-git-init-confirm-test.js +115 -0
- package/_site/_test/project-goal-editor-test.js +144 -144
- package/_site/_test/project-import-duplicate-alias-test.js +134 -0
- package/_site/_test/project-import-unicode-restart-test.js +140 -0
- package/_site/_test/project-lifecycle-transaction-test.js +106 -106
- package/_site/_test/project-module-partial-recovery-test.js +222 -0
- package/_site/_test/project-remove-running-guard-test.js +79 -79
- package/_site/_test/project-store-test.js +90 -90
- package/_site/_test/project-unbind-late-read-ui-test.js +250 -0
- package/_site/_test/project-unbind-writer-guard-test.js +231 -0
- package/_site/_test/prompt-settings-test.js +115 -115
- package/_site/_test/protected-architecture-gate-test.js +122 -122
- package/_site/_test/refactor-characterization-test.js +36 -36
- package/_site/_test/registry-events-test.js +38 -38
- package/_site/_test/release-version-sync-test.js +115 -115
- package/_site/_test/requirement-binding-test.js +113 -113
- package/_site/_test/requirement-recorder-test.js +173 -173
- package/_site/_test/run-all-tests.js +173 -161
- package/_site/_test/runtime-endpoint-test.js +64 -64
- package/_site/_test/scanner-test.js +83 -83
- package/_site/_test/server-security-test.js +96 -96
- package/_site/_test/sessions-stream-test.js +93 -93
- package/_site/_test/shared-contracts-test.js +58 -58
- package/_site/_test/shared-scope-root-binding-test.js +74 -67
- package/_site/_test/simple-import-test.js +98 -98
- package/_site/_test/startup-analysis-disabled-test.js +16 -16
- package/_site/_test/storage-foundation-test.js +78 -78
- package/_site/_test/structured-logger-test.js +101 -101
- package/_site/_test/t07b-cln-005-coverage-test.js +212 -0
- package/_site/_test/team-knowledge-store-sparse-checkout-test.js +196 -196
- package/_site/_test/team-knowledge-store-test.js +132 -132
- package/_site/_test/test-server-cleanup-test.js +35 -35
- package/_site/_test/test-server-module-isolation-test.js +37 -37
- package/_site/_test/tracking-start-test.js +144 -144
- package/_site/_test/vector-storage-root-test.js +75 -75
- package/_site/_test/version-visibility-browser-probe.js +249 -0
- package/_site/_test/version-visibility-test.js +92 -0
- package/_site/_test/workbench-context-receipts-test.js +22 -22
- package/_site/_test/workbench-permission-test.js +117 -117
- package/_site/_test/zcode-capture-integration-test.js +112 -112
- package/_site/lib/ai-profile-resolver.js +78 -78
- package/_site/lib/ai-vendor-presets.js +83 -83
- package/_site/lib/ai-workspace.js +104 -104
- package/_site/lib/atomic-file.js +204 -204
- package/_site/lib/automation-config.js +140 -140
- package/_site/lib/bridge-adapter.js +260 -260
- package/_site/lib/bridge-consumer-service.js +402 -402
- package/_site/lib/capture-hook-config.js +108 -108
- package/_site/lib/claude-cli-runner.js +1599 -1599
- package/_site/lib/cli-instances.js +43 -43
- package/_site/lib/codex-context-status.js +17 -17
- package/_site/lib/codex-notify-config.js +193 -193
- package/_site/lib/commit-conversation-binder.js +247 -247
- package/_site/lib/commit-processing-ledger.js +27 -27
- package/_site/lib/commit-prompt.js +202 -202
- package/_site/lib/commit-reconciler.js +444 -444
- package/_site/lib/context-pack-builder.js +299 -299
- package/_site/lib/contracts.js +291 -291
- package/_site/lib/conversation-exclusions.js +204 -204
- package/_site/lib/conversation-query-service.js +161 -161
- package/_site/lib/conversation-store.js +387 -387
- package/_site/lib/data-dir.js +13 -13
- package/_site/lib/embedding-service.js +85 -85
- package/_site/lib/engine-connection.js +93 -93
- package/_site/lib/engine-knowledge-client.js +76 -72
- package/_site/lib/evidence-bundle.js +228 -228
- package/_site/lib/folder-picker-output.js +24 -24
- package/_site/lib/git-path.js +14 -14
- package/_site/lib/git-runner.js +62 -62
- package/_site/lib/github-team-store.js +1175 -1175
- package/_site/lib/hook-manager.js +203 -203
- package/_site/lib/index-builder.js +157 -157
- package/_site/lib/index-service.js +173 -173
- package/_site/lib/integration-auto-repair.js +77 -77
- package/_site/lib/integration-installer.js +1240 -1240
- package/_site/lib/integration-intent.js +88 -88
- package/_site/lib/integration-status-scan.js +99 -99
- package/_site/lib/integration-status-worker.js +14 -14
- package/_site/lib/kb-framework.js +191 -191
- package/_site/lib/kb-validator.js +124 -124
- package/_site/lib/knowledge-db.js +363 -363
- package/_site/lib/knowledge-promotion.js +435 -435
- package/_site/lib/knowledge-retrieval-service.js +401 -401
- package/_site/lib/knowledge-schema.js +121 -121
- package/_site/lib/knowledge-tool-runtime.js +366 -366
- package/_site/lib/live-gateway.js +78 -78
- package/_site/lib/llm-client.js +173 -173
- package/_site/lib/markdown-knowledge-indexer.js +230 -230
- package/_site/lib/model-context-windows.js +82 -82
- package/_site/lib/module-bridge.js +874 -874
- package/_site/lib/module-port-resolver.js +57 -57
- package/_site/lib/post-commit-automation.js +141 -141
- package/_site/lib/product-data.js +35 -35
- package/_site/lib/project-lifecycle-service.js +554 -554
- package/_site/lib/project-registry-store.js +129 -129
- package/_site/lib/project-store.js +268 -268
- package/_site/lib/prompt-registry.js +148 -148
- package/_site/lib/public-version-info.js +37 -0
- package/_site/lib/registry-events.js +16 -16
- package/_site/lib/requirement-adapters.js +10 -10
- package/_site/lib/requirement-binder.js +112 -112
- package/_site/lib/requirement-recorder.js +278 -278
- package/_site/lib/runtime-control.js +89 -89
- package/_site/lib/runtime-endpoint.js +160 -160
- package/_site/lib/scanner.js +298 -298
- package/_site/lib/server-app.js +1672 -1664
- package/_site/lib/settings-store.js +153 -153
- package/_site/lib/storage-layout.js +166 -166
- package/_site/lib/structured-logger.js +574 -574
- package/_site/lib/zcode-context-integration.js +60 -60
- package/_site/scripts/codex-notify-fanout.cjs +95 -95
- package/_site/scripts/folder-picker.ps1 +156 -156
- package/_site/scripts/hook-trigger.js +158 -158
- package/_site/scripts/install-module-candidates.js +69 -69
- package/_site/scripts/pack-module-candidates.js +89 -89
- package/_site/scripts/sync-product-content.js +28 -28
- package/_site/scripts/sync-release-version.js +164 -164
- package/_site/scripts/vendor-modules.js +49 -49
- package/_site/scripts/verify-module-runtime.js +50 -50
- package/_site/scripts/verify-product-runtime.js +36 -36
- package/_site/scripts/verify-retrieval-gold.js +83 -83
- package/_site/server.js +15 -15
- package/_site/start.bat +26 -26
- package/_site/stop.bat +11 -11
- package/bin/project-knowledge-integrations.js +254 -254
- package/bin/project-knowledge-kb.js +67 -67
- package/bin/project-knowledge-mcp.js +201 -201
- package/bin/project-knowledge.js +269 -170
- package/claude-prompts.json +21 -21
- package/docs/README.zh-CN.md +207 -205
- package/docs/assets/architecture.svg +181 -181
- package/docs/assets/logo.svg +49 -49
- package/docs/fresh-v5-start.md +44 -44
- package/docs/leader-glm-workbench-playbook.md +122 -122
- package/docs/project-registry-schema.md +33 -33
- package/docs/release-5.0.16-acceptance.md +176 -176
- package/docs/release-5.0.17-acceptance.md +117 -117
- package/docs/release-5.0.19-acceptance.md +39 -39
- package/docs/team-knowledge-mode-a-plan.md +73 -73
- package/docs/testing-strategy.md +33 -33
- package/module-runtime-manifest.json +68 -65
- package/package.json +113 -110
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/templates/change.md +30 -30
- package/templates/project-readme.md +52 -52
- package/ui/index.html +3 -2
- package/ui/version-info.css +44 -0
- package/ui/version-info.js +24 -0
- package/vendor-manifest.json +55 -55
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// P-WB-QA-INTEGRATION-5025 runtime harness — the canonical harness for the
|
|
3
|
+
// REAL-MODEL Workbench tools (WB-003 / WB-004 / WB-008 canonical copies),
|
|
4
|
+
// carried forward from the accepted lane harness
|
|
5
|
+
// (helpers/parallel-workbench-runtime-harness.js, frozen untracked) with
|
|
6
|
+
// exactly the integration changes:
|
|
7
|
+
// * layouts and child environments come from the canonical
|
|
8
|
+
// integration-5025 fixture: portable temp roots (PK_TEST_TEMP_ROOT → the
|
|
9
|
+
// shared root next to the repo when it exists → TEMP/TMP/TMPDIR → the OS
|
|
10
|
+
// temp dir, never inside the repo), the FULL R5 env whitelist
|
|
11
|
+
// (APPDATA/LOCALAPPDATA/CODEX_HOME included) and the Chrome >= 136
|
|
12
|
+
// default-dir scaffold, all under a per-run owner root;
|
|
13
|
+
// * the host child is still the FROZEN TRACKED host
|
|
14
|
+
// (helpers/parallel-workbench-host.js): the real subscription profile is
|
|
15
|
+
// served through its read-only facade, with the real profile directory
|
|
16
|
+
// passed explicitly (PK_WB_REAL_PROFILE_DIR, resolved from the real
|
|
17
|
+
// environment or the explicit override) because the isolated HOME hides
|
|
18
|
+
// the original location; the credential stays in the host's memory;
|
|
19
|
+
// * openBrowser accepts an explicit chrome path ONLY — resolved with the
|
|
20
|
+
// real environment (or the safe runner's capture) BEFORE any isolation;
|
|
21
|
+
// a post-isolation browser discovery is refused. P-WB-CANONICAL-R2:
|
|
22
|
+
// every probe entry now goes through the canonical launcher boot (gates →
|
|
23
|
+
// read-only discovery → full driver isolation → carried-through captures),
|
|
24
|
+
// so the DRIVER process itself and every child below it run on the full
|
|
25
|
+
// R5 whitelist; the installed-product identity label resolves from the
|
|
26
|
+
// pre-isolation capture and can no longer degrade to a repository pin.
|
|
27
|
+
//
|
|
28
|
+
// Everything else is the accepted harness verbatim: it drives the REAL
|
|
29
|
+
// agent-terminal UI in a REAL browser against the REAL module; the recorder
|
|
30
|
+
// logs every event the product receives, verbatim — it never filters,
|
|
31
|
+
// reorders or repairs anything; whether a stale event is honoured or dropped
|
|
32
|
+
// is decided by the product, not by the driver.
|
|
33
|
+
const fs = require('node:fs');
|
|
34
|
+
const path = require('node:path');
|
|
35
|
+
const crypto = require('node:crypto');
|
|
36
|
+
const { spawnSync } = require('node:child_process');
|
|
37
|
+
const fixture = require('./parallel-workbench-integration-5025-fixture');
|
|
38
|
+
const sourceMap = require('./parallel-workbench-source-map');
|
|
39
|
+
const { launchCdpBrowser } = require('./cdp-browser');
|
|
40
|
+
|
|
41
|
+
const API_BASE = '/api/claude-workbench/v1';
|
|
42
|
+
|
|
43
|
+
function sha256File(file) {
|
|
44
|
+
try { return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); } catch { return null; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The real profile directory for the read-only facade, resolved with the REAL
|
|
48
|
+
// environment (before any isolation). An explicit override keeps the tool
|
|
49
|
+
// portable across machines; the default is the product's own convention.
|
|
50
|
+
function realProfileDir(options = {}) {
|
|
51
|
+
const override = String(options.realProfileDir || process.env.PK_WB_REAL_PROFILE_DIR || '').trim();
|
|
52
|
+
return override ? path.resolve(override) : fixture.realWorkbenchProfileDir();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Installed in the page before any product script runs. It wraps EventSource
|
|
56
|
+
// so that every delivered event is recorded, and it exposes a replay that
|
|
57
|
+
// re-delivers a recorded event to the same stream.
|
|
58
|
+
const RECORDER_SOURCE = `
|
|
59
|
+
(function () {
|
|
60
|
+
if (window.__wbRecorder) return;
|
|
61
|
+
var Native = window.EventSource;
|
|
62
|
+
var recorder = { log: [], streams: [] };
|
|
63
|
+
window.__wbRecorder = recorder;
|
|
64
|
+
function RecordingEventSource(url, init) {
|
|
65
|
+
var stream = new Native(url, init);
|
|
66
|
+
recorder.streams.push({ stream: stream, url: String(url) });
|
|
67
|
+
var nativeAdd = stream.addEventListener.bind(stream);
|
|
68
|
+
stream.addEventListener = function (type, fn, options) {
|
|
69
|
+
if (typeof fn === 'function' && type !== 'message') {
|
|
70
|
+
var wrapped = function (event) {
|
|
71
|
+
try { recorder.log.push({ type: event.type, data: String(event.data), at: Date.now() }); } catch (error) {}
|
|
72
|
+
return fn.call(stream, event);
|
|
73
|
+
};
|
|
74
|
+
return nativeAdd(type, wrapped, options);
|
|
75
|
+
}
|
|
76
|
+
return nativeAdd(type, fn, options);
|
|
77
|
+
};
|
|
78
|
+
return stream;
|
|
79
|
+
}
|
|
80
|
+
RecordingEventSource.prototype = Native.prototype;
|
|
81
|
+
window.EventSource = RecordingEventSource;
|
|
82
|
+
window.__wbReplay = function (index, urlPattern) {
|
|
83
|
+
var entry = recorder.log[index];
|
|
84
|
+
if (!entry) return { replayed: false, reason: 'no recorded event at that index' };
|
|
85
|
+
var delivered = 0;
|
|
86
|
+
for (var i = 0; i < recorder.streams.length; i++) {
|
|
87
|
+
var target = recorder.streams[i];
|
|
88
|
+
if (urlPattern && target.url.indexOf(urlPattern) < 0) continue;
|
|
89
|
+
try {
|
|
90
|
+
target.stream.dispatchEvent(new MessageEvent(entry.type, { data: entry.data, lastEventId: '' }));
|
|
91
|
+
delivered += 1;
|
|
92
|
+
} catch (error) {}
|
|
93
|
+
}
|
|
94
|
+
return { replayed: true, type: entry.type, delivered: delivered, urlPattern: urlPattern || null };
|
|
95
|
+
};
|
|
96
|
+
})();
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
function wait(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
|
100
|
+
|
|
101
|
+
async function waitUntil(fn, label, timeoutMs = 30000, intervalMs = 100) {
|
|
102
|
+
const deadline = Date.now() + timeoutMs;
|
|
103
|
+
let last;
|
|
104
|
+
while (Date.now() < deadline) {
|
|
105
|
+
try {
|
|
106
|
+
const value = await fn();
|
|
107
|
+
if (value) return value;
|
|
108
|
+
last = value;
|
|
109
|
+
} catch (error) { last = error && error.message; }
|
|
110
|
+
await wait(intervalMs);
|
|
111
|
+
}
|
|
112
|
+
const detail = last === undefined ? '' : ` (last: ${typeof last === 'string' ? last : JSON.stringify(last)})`;
|
|
113
|
+
throw new Error(`timed out after ${timeoutMs}ms waiting for ${label}${detail}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function getJson(url, options) {
|
|
117
|
+
const response = await fetch(url, { ...options, signal: AbortSignal.timeout(30000) });
|
|
118
|
+
const body = await response.json().catch(() => null);
|
|
119
|
+
return { status: response.status, ok: response.ok, body };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// --- the isolated host ----------------------------------------------------
|
|
123
|
+
|
|
124
|
+
async function startHost(options = {}) {
|
|
125
|
+
const moduleRoot = options.moduleRoot || fixture.resolveHostModuleRoot();
|
|
126
|
+
if (!moduleRoot) throw new Error('no claude-ai-workbench module copy was found to host');
|
|
127
|
+
// A restart of the SAME host keeps the layout (data dir, browser profile)
|
|
128
|
+
// and may keep the port, so the page origin — and with it the browser
|
|
129
|
+
// storage the product uses for drafts — stays the same.
|
|
130
|
+
const layout = options.layout || fixture.createIsolationLayout(options.prefix || 'parallel-wb-integration-5025-rt');
|
|
131
|
+
const port = options.port || await fixture.freePort();
|
|
132
|
+
const base = `http://127.0.0.1:${port}`;
|
|
133
|
+
const profileSource = options.profileSource || 'real-readonly';
|
|
134
|
+
const child = fixture.spawnNode([path.join(__dirname, 'parallel-workbench-host.js')], fixture.hostEnv(layout, {
|
|
135
|
+
PK_WB_MODULE_ROOT: moduleRoot,
|
|
136
|
+
PK_WB_HOST_PORT: String(port),
|
|
137
|
+
PK_WB_HOST_DATA_DIR: layout.dataDir,
|
|
138
|
+
PK_WB_HOST_WORKSPACE: layout.workspace,
|
|
139
|
+
PK_WB_HOST_MODE: options.mode || 'standalone',
|
|
140
|
+
PK_WB_PROFILE_SOURCE: profileSource,
|
|
141
|
+
...(profileSource === 'real-readonly' ? { PK_WB_REAL_PROFILE_DIR: realProfileDir(options) } : {}),
|
|
142
|
+
...(options.engineUrl ? { PK_WB_ENGINE_URL: options.engineUrl } : {}),
|
|
143
|
+
}));
|
|
144
|
+
await fixture.waitForHttp(`${base}${API_BASE}/health`, 30000);
|
|
145
|
+
return { layout, moduleRoot, port, base, child };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function stopHost(host) {
|
|
149
|
+
if (!host || !host.child) return;
|
|
150
|
+
host.child.child.kill();
|
|
151
|
+
await host.child.exited;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// --- the real browser -----------------------------------------------------
|
|
155
|
+
|
|
156
|
+
async function openBrowser(base, layout, options = {}) {
|
|
157
|
+
// Chrome must have been resolved with the REAL environment before the
|
|
158
|
+
// launcher boot isolated this process (the boot carries it through as the
|
|
159
|
+
// explicit PK_WB_CHROME). Discovering a browser from the isolated
|
|
160
|
+
// environment would violate the discovery-before-isolation contract.
|
|
161
|
+
const chrome = options.chrome
|
|
162
|
+
|| (String(process.env.PK_WB_CHROME || '').trim() ? path.resolve(process.env.PK_WB_CHROME) : null);
|
|
163
|
+
if (!chrome) {
|
|
164
|
+
throw new Error('openBrowser requires a Chrome path captured before isolation — pass options.chrome from the launcher boot discovery');
|
|
165
|
+
}
|
|
166
|
+
const profileDir = path.join(layout.root, 'browser-profile');
|
|
167
|
+
const browser = await launchCdpBrowser({
|
|
168
|
+
chrome,
|
|
169
|
+
profileDir,
|
|
170
|
+
url: 'about:blank',
|
|
171
|
+
width: 1360,
|
|
172
|
+
height: 900,
|
|
173
|
+
launchAttempts: 2,
|
|
174
|
+
});
|
|
175
|
+
await browser.send('Page.addScriptToEvaluateOnNewDocument', { source: RECORDER_SOURCE });
|
|
176
|
+
const target = `${base}/agent-terminal/?apiBase=${encodeURIComponent(API_BASE)}`;
|
|
177
|
+
await browser.send('Page.navigate', { url: target });
|
|
178
|
+
await waitUntil(
|
|
179
|
+
async () => browser.evaluate("document.readyState === 'complete' && !!window.__wbRecorder && !!document.getElementById('chat-input')"),
|
|
180
|
+
'the agent terminal page',
|
|
181
|
+
30000,
|
|
182
|
+
);
|
|
183
|
+
return { browser, chrome, profileDir, target };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function reloadPage(browser) {
|
|
187
|
+
await browser.send('Page.reload', { ignoreCache: false });
|
|
188
|
+
await waitUntil(
|
|
189
|
+
async () => browser.evaluate("document.readyState === 'complete' && !!window.__wbRecorder && !!document.getElementById('chat-input')"),
|
|
190
|
+
'the reloaded agent terminal page',
|
|
191
|
+
30000,
|
|
192
|
+
);
|
|
193
|
+
// The product script defines its own `state`; the page is only usable once
|
|
194
|
+
// that global exists, not merely when the document finished loading.
|
|
195
|
+
await waitUntil(
|
|
196
|
+
async () => browser.evaluate("typeof state !== 'undefined' && !!state"),
|
|
197
|
+
'the product state of the reloaded page',
|
|
198
|
+
30000,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// --- the product's own state, read from the page --------------------------
|
|
203
|
+
|
|
204
|
+
const READ_STATE = `(() => {
|
|
205
|
+
const send = document.getElementById('btn-send');
|
|
206
|
+
const status = document.getElementById('session-status');
|
|
207
|
+
const statusText = document.getElementById('session-status-text');
|
|
208
|
+
const col = document.getElementById('stream-col');
|
|
209
|
+
const input = document.getElementById('chat-input');
|
|
210
|
+
const tray = document.querySelector('.composer .attach-tray');
|
|
211
|
+
const modelLabel = document.getElementById('model-label');
|
|
212
|
+
const activeProj = document.querySelector('#project-list .proj.active');
|
|
213
|
+
return {
|
|
214
|
+
sendTitle: send ? send.title : null,
|
|
215
|
+
busy: send ? send.title === '停止' : null,
|
|
216
|
+
statusHidden: status ? status.hidden : null,
|
|
217
|
+
statusText: statusText ? statusText.textContent : null,
|
|
218
|
+
inputValue: input ? input.value : null,
|
|
219
|
+
inputDisabled: input ? input.disabled : null,
|
|
220
|
+
streamText: col ? col.textContent : '',
|
|
221
|
+
assistantMessages: col ? Array.from(col.querySelectorAll('.msg.ai')).map(node => node.textContent) : [],
|
|
222
|
+
userMessages: col ? Array.from(col.querySelectorAll('.msg.user')).map(node => node.textContent) : [],
|
|
223
|
+
attachments: tray ? Array.from(tray.querySelectorAll('.attachment-item')).map(node => node.textContent.trim()) : [],
|
|
224
|
+
modelLabel: modelLabel ? modelLabel.textContent : null,
|
|
225
|
+
activeProjectId: activeProj ? activeProj.dataset.project : null,
|
|
226
|
+
product: typeof state === 'undefined' ? null : {
|
|
227
|
+
activeProjectId: state.activeProjectId,
|
|
228
|
+
activeSessionId: state.activeSessionId,
|
|
229
|
+
busy: state.busy,
|
|
230
|
+
sessionState: state.sessionState || null,
|
|
231
|
+
liveRevision: state.liveRevision || 0,
|
|
232
|
+
attachmentCount: (state.attachments || []).length,
|
|
233
|
+
currentProfileId: state.currentProfileId === undefined ? 'undefined' : state.currentProfileId,
|
|
234
|
+
currentModel: state.currentModel,
|
|
235
|
+
projects: (state.projects || []).map(project => ({ id: project.id, name: project.name })),
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
})()`;
|
|
239
|
+
|
|
240
|
+
async function readState(browser) {
|
|
241
|
+
return browser.evaluate(READ_STATE);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function waitForState(browser, predicate, label, timeoutMs = 30000, intervalMs = 100) {
|
|
245
|
+
return waitUntil(async () => {
|
|
246
|
+
const state = await readState(browser);
|
|
247
|
+
return predicate(state) ? state : null;
|
|
248
|
+
}, label, timeoutMs, intervalMs);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// --- UI actions (the product's own controls) ------------------------------
|
|
252
|
+
|
|
253
|
+
async function selectModel(browser, profileName, modelId, options = {}) {
|
|
254
|
+
await browser.evaluate("document.getElementById('btn-model').click()");
|
|
255
|
+
const scan = `(() => {
|
|
256
|
+
const pop = document.getElementById('pop-model');
|
|
257
|
+
const groups = pop && pop.querySelector('.pop-groups');
|
|
258
|
+
if (!groups) return null;
|
|
259
|
+
const items = [];
|
|
260
|
+
let profile = null;
|
|
261
|
+
for (const child of Array.from(groups.children)) {
|
|
262
|
+
if (child.tagName === 'BUTTON') {
|
|
263
|
+
const label = ((child.querySelector('.grow') || child).textContent || '').trim();
|
|
264
|
+
items.push({ profile, label, disabled: child.disabled === true });
|
|
265
|
+
} else if (child.classList.contains('pop-group')) {
|
|
266
|
+
profile = (child.textContent || '').trim();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return { items };
|
|
270
|
+
})()`;
|
|
271
|
+
const menu = await waitUntil(async () => {
|
|
272
|
+
const found = await browser.evaluate(scan);
|
|
273
|
+
return found && found.items.length ? found : null;
|
|
274
|
+
}, 'the model menu', options.timeoutMs || 30000);
|
|
275
|
+
const match = menu.items.find(item => item.profile && item.profile.includes(profileName) && item.label.includes(modelId));
|
|
276
|
+
if (!match) throw new Error(`the model menu has no ${profileName} / ${modelId} entry: ${JSON.stringify(menu.items)}`);
|
|
277
|
+
if (match.disabled) throw new Error(`the ${profileName} / ${modelId} entry is disabled`);
|
|
278
|
+
const clicked = await browser.evaluate(`(() => {
|
|
279
|
+
const profileName = ${JSON.stringify(profileName)};
|
|
280
|
+
const modelId = ${JSON.stringify(modelId)};
|
|
281
|
+
const groups = document.querySelector('#pop-model .pop-groups');
|
|
282
|
+
let profile = null;
|
|
283
|
+
for (const child of Array.from(groups.children)) {
|
|
284
|
+
if (child.tagName === 'BUTTON') {
|
|
285
|
+
const label = ((child.querySelector('.grow') || child).textContent || '').trim();
|
|
286
|
+
if (profile && profile.includes(profileName) && label.includes(modelId)) { child.click(); return { clicked: true, label }; }
|
|
287
|
+
} else if (child.classList.contains('pop-group')) {
|
|
288
|
+
profile = (child.textContent || '').trim();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { clicked: false };
|
|
292
|
+
})()`);
|
|
293
|
+
if (!clicked.clicked) throw new Error(`the ${profileName} / ${modelId} entry could not be clicked`);
|
|
294
|
+
await waitForState(browser, state => state.product && state.product.currentModel === modelId, `the ${modelId} selection`, 15000);
|
|
295
|
+
return clicked;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function selectProject(browser, projectId) {
|
|
299
|
+
const clicked = await clickProjectHead(browser, projectId);
|
|
300
|
+
await waitForState(browser, state => state.activeProjectId === projectId, `the ${projectId} project to become active`, 15000);
|
|
301
|
+
return clicked;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// The native folder picker opens a blocking OS dialog, which a headless
|
|
305
|
+
// browser cannot answer. The product ships a manual fallback form for
|
|
306
|
+
// exactly that case; this drives that form, so the project is still created
|
|
307
|
+
// by the product's own handler and the product's own client call.
|
|
308
|
+
async function createProjectThroughForm(browser, rootPath, options = {}) {
|
|
309
|
+
const prepared = await browser.evaluate(`(() => {
|
|
310
|
+
const modal = document.getElementById('modal-add-proj');
|
|
311
|
+
const path = document.getElementById('np-path');
|
|
312
|
+
const confirm = document.getElementById('np-confirm');
|
|
313
|
+
modal.classList.add('open');
|
|
314
|
+
path.value = ${JSON.stringify(rootPath)};
|
|
315
|
+
path.dispatchEvent(new Event('input', { bubbles: true }));
|
|
316
|
+
return { confirmDisabled: confirm.disabled === true, derivedName: document.getElementById('np-name').value };
|
|
317
|
+
})()`);
|
|
318
|
+
if (prepared.confirmDisabled) throw new Error(`the add-project form refused the path ${rootPath}`);
|
|
319
|
+
const before = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => node.dataset.project)");
|
|
320
|
+
await browser.evaluate("document.getElementById('np-confirm').click()");
|
|
321
|
+
const after = await waitUntil(async () => {
|
|
322
|
+
const ids = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => node.dataset.project)");
|
|
323
|
+
const added = ids.filter(id => !before.includes(id));
|
|
324
|
+
return added.length ? added : null;
|
|
325
|
+
}, 'the new project to appear in the sidebar', 15000);
|
|
326
|
+
return { projectId: after[0], derivedName: prepared.derivedName };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// The isolated host ships a context workspace but no project entry, so the
|
|
330
|
+
// sidebar starts empty. The project is created through the product's own
|
|
331
|
+
// add-project form, on an isolated directory of this run.
|
|
332
|
+
async function ensureProject(browser, rootPath, options = {}) {
|
|
333
|
+
const projects = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => ({ id: node.dataset.project, name: ((node.querySelector('.p-name') || {}).textContent || '').trim() }))");
|
|
334
|
+
const wanted = options.name ? projects.find(project => project.name === options.name) : null;
|
|
335
|
+
if (wanted) return { projectId: wanted.id, created: false, name: wanted.name };
|
|
336
|
+
fs.mkdirSync(rootPath, { recursive: true });
|
|
337
|
+
const created = await createProjectThroughForm(browser, rootPath, options);
|
|
338
|
+
return { ...created, created: true };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async function typeText(browser, text) {
|
|
342
|
+
const typed = await browser.evaluate(`(() => {
|
|
343
|
+
const input = document.getElementById('chat-input');
|
|
344
|
+
input.value = ${JSON.stringify(text)};
|
|
345
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
346
|
+
return input.value;
|
|
347
|
+
})()`);
|
|
348
|
+
if (typed !== text) throw new Error('the composer did not accept the typed text');
|
|
349
|
+
return typed;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async function clickSend(browser) {
|
|
353
|
+
await browser.evaluate("document.getElementById('btn-send').click()");
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async function clickNewSession(browser) {
|
|
357
|
+
await browser.evaluate("document.getElementById('btn-new-session').click()");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// The product's own sidebar: a session is opened by clicking its row, and a
|
|
361
|
+
// project is switched by clicking its head. Both are real UI actions.
|
|
362
|
+
async function clickProjectHead(browser, projectId) {
|
|
363
|
+
const selector = `#project-list .proj[data-project="${String(projectId).replace(/"/g, '\\"')}"] .proj-item`;
|
|
364
|
+
await waitUntil(async () => browser.evaluate(`!!document.querySelector(${JSON.stringify(selector)})`), `the project ${projectId} in the sidebar`, 20000);
|
|
365
|
+
const clicked = await browser.evaluate(`(() => {
|
|
366
|
+
const node = document.querySelector(${JSON.stringify(selector)});
|
|
367
|
+
if (!node) return { clicked: false };
|
|
368
|
+
node.click();
|
|
369
|
+
return { clicked: true };
|
|
370
|
+
})()`);
|
|
371
|
+
if (!clicked.clicked) throw new Error(`the project ${projectId} has no head in the sidebar`);
|
|
372
|
+
return clicked;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// The product's project-head click ALWAYS toggles state.expanded (app.js
|
|
376
|
+
// renderProjectList head handler), in both directions, and renders
|
|
377
|
+
// asynchronously against SSE-driven refreshes. A fixed two-click dance can
|
|
378
|
+
// race a re-render; this state-based settle loop only re-clicks while the
|
|
379
|
+
// list is verifiably collapsed or absent, bounded.
|
|
380
|
+
async function waitForSessionListExpanded(browser, projectId, attempts = 5) {
|
|
381
|
+
const probe = `(() => {
|
|
382
|
+
const id = ${JSON.stringify(projectId)};
|
|
383
|
+
const proj = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"]');
|
|
384
|
+
const list = proj && proj.querySelector('.sess-list');
|
|
385
|
+
return { projPresent: !!proj, listPresent: !!list, visible: list ? !list.hidden : null, projCount: document.querySelectorAll('#project-list .proj').length };
|
|
386
|
+
})()`;
|
|
387
|
+
let last = null;
|
|
388
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
389
|
+
last = await browser.evaluate(probe);
|
|
390
|
+
if (last && last.visible === true) return last;
|
|
391
|
+
await clickProjectHead(browser, projectId);
|
|
392
|
+
await wait(500);
|
|
393
|
+
}
|
|
394
|
+
throw new Error(`the session list of ${projectId} stayed collapsed or absent after ${attempts} head clicks: ${JSON.stringify(last)}`);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async function openSessionRow(browser, projectId, sessionId) {
|
|
398
|
+
const current = await readState(browser);
|
|
399
|
+
if (current.activeProjectId !== projectId) {
|
|
400
|
+
await clickProjectHead(browser, projectId);
|
|
401
|
+
await waitForState(browser, state => state.activeProjectId === projectId, `the ${projectId} project to become active`, 15000);
|
|
402
|
+
}
|
|
403
|
+
await waitForSessionListExpanded(browser, projectId);
|
|
404
|
+
const ready = await waitUntil(async () => {
|
|
405
|
+
const found = await browser.evaluate(`(() => {
|
|
406
|
+
const id = ${JSON.stringify(projectId)};
|
|
407
|
+
const session = ${JSON.stringify(sessionId)};
|
|
408
|
+
const row = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list .session[data-session="' + session.replace(/"/g, '\\\\"') + '"]');
|
|
409
|
+
return row ? { found: true, title: (row.querySelector('.s-title') || {}).textContent || '' } : null;
|
|
410
|
+
})()`);
|
|
411
|
+
return found;
|
|
412
|
+
}, `the session ${sessionId} to be listed under ${projectId}`, 20000);
|
|
413
|
+
await browser.evaluate(`(() => {
|
|
414
|
+
const id = ${JSON.stringify(projectId)};
|
|
415
|
+
const session = ${JSON.stringify(sessionId)};
|
|
416
|
+
const row = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list .session[data-session="' + session.replace(/"/g, '\\\\"') + '"]');
|
|
417
|
+
row.click();
|
|
418
|
+
return true;
|
|
419
|
+
})()`);
|
|
420
|
+
await waitForState(browser, state => state.product && state.product.activeSessionId === sessionId, `the session ${sessionId} to open`, 20000);
|
|
421
|
+
return ready;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// The product's own browser storage for drafts, read raw. Nothing is written
|
|
425
|
+
// through it here: the product writes it, this only looks.
|
|
426
|
+
async function readDraftStorage(browser) {
|
|
427
|
+
return browser.evaluate(`(() => {
|
|
428
|
+
const key = ${JSON.stringify(`kb.workbench.session-drafts:${API_BASE}`)};
|
|
429
|
+
const raw = localStorage.getItem(key) || '';
|
|
430
|
+
let parsed = null;
|
|
431
|
+
try { parsed = JSON.parse(raw || '{}'); } catch { parsed = null; }
|
|
432
|
+
const keys = Object.keys(parsed || {});
|
|
433
|
+
return { key, raw, parsed, keys, entryCount: keys.length };
|
|
434
|
+
})()`);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// A real file goes into the real <input type="file">; the product's own
|
|
438
|
+
// change handler reads it.
|
|
439
|
+
async function attachFile(browser, fileName, content, mediaType = 'text/plain') {
|
|
440
|
+
const result = await browser.evaluate(`(() => {
|
|
441
|
+
const input = document.getElementById('file-input');
|
|
442
|
+
const file = new File([${JSON.stringify(content)}], ${JSON.stringify(fileName)}, { type: ${JSON.stringify(mediaType)} });
|
|
443
|
+
const transfer = new DataTransfer();
|
|
444
|
+
transfer.items.add(file);
|
|
445
|
+
input.files = transfer.files;
|
|
446
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
447
|
+
return { files: input.files.length };
|
|
448
|
+
})()`);
|
|
449
|
+
await waitForState(browser, state => state.attachments.length > 0, `the attachment ${fileName} to reach the tray`, 15000);
|
|
450
|
+
return result;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async function recordedEvents(browser) {
|
|
454
|
+
return browser.evaluate("Array.from((window.__wbRecorder && window.__wbRecorder.log) || []).map((entry, index) => ({ index, type: entry.type, data: entry.data, at: entry.at }))");
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async function replayRecordedEvent(browser, index, urlPattern) {
|
|
458
|
+
return browser.evaluate(`window.__wbReplay(${Number(index)}, ${urlPattern === undefined || urlPattern === null ? 'null' : JSON.stringify(urlPattern)})`);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// --- the module's own session contract ------------------------------------
|
|
462
|
+
|
|
463
|
+
function sessionEventsUrl(base, sessionId, after = 0) {
|
|
464
|
+
const suffix = after > 0 ? `?after=${encodeURIComponent(after)}` : '';
|
|
465
|
+
return `${base}${API_BASE}/sessions/${encodeURIComponent(sessionId)}/events${suffix}`;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Consume a session's SSE stream and count the events by type. This is the
|
|
469
|
+
// product's own event contract, read from outside the browser.
|
|
470
|
+
function consumeSessionEvents(url, onEvent, until, timeoutMs) {
|
|
471
|
+
const controller = new AbortController();
|
|
472
|
+
const timer = setTimeout(() => controller.abort(new Error(`event stream timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
473
|
+
let done = null;
|
|
474
|
+
const finished = new Promise(resolve => { done = resolve; });
|
|
475
|
+
(async () => {
|
|
476
|
+
try {
|
|
477
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
478
|
+
if (!response.ok) throw new Error(`event stream HTTP ${response.status}`);
|
|
479
|
+
const reader = response.body.getReader();
|
|
480
|
+
const decoder = new TextDecoder();
|
|
481
|
+
let buffer = '';
|
|
482
|
+
for (;;) {
|
|
483
|
+
const { value, done: streamDone } = await reader.read();
|
|
484
|
+
if (streamDone) break;
|
|
485
|
+
buffer += decoder.decode(value, { stream: true });
|
|
486
|
+
let index;
|
|
487
|
+
while ((index = buffer.indexOf('\n')) >= 0) {
|
|
488
|
+
const line = buffer.slice(0, index).replace(/\r$/, '');
|
|
489
|
+
buffer = buffer.slice(index + 1);
|
|
490
|
+
if (!line.startsWith('data:')) continue;
|
|
491
|
+
const payload = line.slice(5).trim();
|
|
492
|
+
if (!payload) continue;
|
|
493
|
+
let event;
|
|
494
|
+
try { event = JSON.parse(payload); } catch { continue; }
|
|
495
|
+
try { onEvent(event); } catch { /* listener errors never kill the stream */ }
|
|
496
|
+
if (until && until(event)) { controller.abort(); return; }
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
} catch { /* aborted or ended */ }
|
|
500
|
+
finally { done && done(); }
|
|
501
|
+
})();
|
|
502
|
+
return { finished, stop: () => controller.abort() };
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// --- the process census ----------------------------------------------------
|
|
506
|
+
//
|
|
507
|
+
// Only the subtree of THIS test's host child is inspected. Nothing outside it
|
|
508
|
+
// is ever enumerated by name, signalled or stopped.
|
|
509
|
+
function listProcesses() {
|
|
510
|
+
const script = "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine | ConvertTo-Json -Compress -Depth 2";
|
|
511
|
+
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], {
|
|
512
|
+
encoding: 'utf8', timeout: 60000, windowsHide: true, maxBuffer: 32 * 1024 * 1024,
|
|
513
|
+
});
|
|
514
|
+
if (result.status !== 0 || !result.stdout) return [];
|
|
515
|
+
let parsed;
|
|
516
|
+
try { parsed = JSON.parse(result.stdout); } catch { return []; }
|
|
517
|
+
if (!Array.isArray(parsed)) parsed = [parsed];
|
|
518
|
+
return parsed.map(entry => ({
|
|
519
|
+
pid: Number(entry.ProcessId),
|
|
520
|
+
ppid: Number(entry.ParentProcessId),
|
|
521
|
+
name: String(entry.Name || ''),
|
|
522
|
+
commandLine: String(entry.CommandLine || ''),
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function descendantProcesses(rootPid) {
|
|
527
|
+
const all = listProcesses();
|
|
528
|
+
const byParent = new Map();
|
|
529
|
+
for (const entry of all) {
|
|
530
|
+
if (!byParent.has(entry.ppid)) byParent.set(entry.ppid, []);
|
|
531
|
+
byParent.get(entry.ppid).push(entry);
|
|
532
|
+
}
|
|
533
|
+
const found = [];
|
|
534
|
+
const stack = [Number(rootPid)];
|
|
535
|
+
const seen = new Set();
|
|
536
|
+
while (stack.length) {
|
|
537
|
+
const pid = stack.pop();
|
|
538
|
+
for (const child of byParent.get(pid) || []) {
|
|
539
|
+
if (seen.has(child.pid)) continue;
|
|
540
|
+
seen.add(child.pid);
|
|
541
|
+
found.push(child);
|
|
542
|
+
stack.push(child.pid);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return found;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// The runtime the module spawns for a session is a node process running the
|
|
549
|
+
// Claude CLI. Only names and pids leave this function.
|
|
550
|
+
function runtimeProcesses(rootPid) {
|
|
551
|
+
return descendantProcesses(rootPid)
|
|
552
|
+
.filter(entry => /^(node|claude|bun|deno)/i.test(entry.name))
|
|
553
|
+
.map(entry => ({
|
|
554
|
+
pid: entry.pid,
|
|
555
|
+
ppid: entry.ppid,
|
|
556
|
+
name: entry.name,
|
|
557
|
+
// The command line carries the session identity of the runtime; it is
|
|
558
|
+
// truncated and holds no credential (the credential lives in the env).
|
|
559
|
+
commandLine: String(entry.commandLine || '').slice(0, 300),
|
|
560
|
+
}));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// --- evidence helpers -----------------------------------------------------
|
|
564
|
+
|
|
565
|
+
function moduleIdentity(moduleRoot) {
|
|
566
|
+
const identity = sourceMap.packageIdentity(moduleRoot) || {};
|
|
567
|
+
return {
|
|
568
|
+
// The installed-product root comes from the fixture's load-time capture or
|
|
569
|
+
// the launcher's carried-through override — never from a live read of the
|
|
570
|
+
// (already isolated) APPDATA, so an AppData-hosted module can no longer be
|
|
571
|
+
// mislabelled as a repository pin after the driver isolated itself.
|
|
572
|
+
label: moduleRoot === fixture.installedProductPackage()
|
|
573
|
+
? 'currently-installed-package:installed-product'
|
|
574
|
+
: 'currently-installed-package:repository-pin',
|
|
575
|
+
root: moduleRoot,
|
|
576
|
+
name: identity.name || null,
|
|
577
|
+
version: identity.version || null,
|
|
578
|
+
// The independent constraint the identity chain compares against.
|
|
579
|
+
independentConstraint: fixture.rootWorkbenchDependency(),
|
|
580
|
+
uiFiles: {
|
|
581
|
+
'apps/agent-terminal/app.js': sha256File(path.join(moduleRoot, 'apps', 'agent-terminal', 'app.js')),
|
|
582
|
+
'apps/agent-terminal/index.html': sha256File(path.join(moduleRoot, 'apps', 'agent-terminal', 'index.html')),
|
|
583
|
+
'packages/client/index.js': sha256File(path.join(moduleRoot, 'packages', 'client', 'index.js')),
|
|
584
|
+
'src/backend/lib/claude-cli-runner.js': sha256File(path.join(moduleRoot, 'src', 'backend', 'lib', 'claude-cli-runner.js')),
|
|
585
|
+
},
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function writeEvidence(target, payload) {
|
|
590
|
+
if (!target) return null;
|
|
591
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
592
|
+
fs.writeFileSync(target, JSON.stringify(payload, null, 2), 'utf8');
|
|
593
|
+
return target;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
module.exports = {
|
|
597
|
+
API_BASE,
|
|
598
|
+
RECORDER_SOURCE,
|
|
599
|
+
wait,
|
|
600
|
+
waitUntil,
|
|
601
|
+
getJson,
|
|
602
|
+
startHost,
|
|
603
|
+
stopHost,
|
|
604
|
+
openBrowser,
|
|
605
|
+
reloadPage,
|
|
606
|
+
readState,
|
|
607
|
+
waitForState,
|
|
608
|
+
selectModel,
|
|
609
|
+
selectProject,
|
|
610
|
+
createProjectThroughForm,
|
|
611
|
+
ensureProject,
|
|
612
|
+
typeText,
|
|
613
|
+
clickSend,
|
|
614
|
+
clickNewSession,
|
|
615
|
+
clickProjectHead,
|
|
616
|
+
openSessionRow,
|
|
617
|
+
readDraftStorage,
|
|
618
|
+
attachFile,
|
|
619
|
+
recordedEvents,
|
|
620
|
+
replayRecordedEvent,
|
|
621
|
+
sessionEventsUrl,
|
|
622
|
+
consumeSessionEvents,
|
|
623
|
+
listProcesses,
|
|
624
|
+
descendantProcesses,
|
|
625
|
+
runtimeProcesses,
|
|
626
|
+
realProfileDir,
|
|
627
|
+
moduleIdentity,
|
|
628
|
+
writeEvidence,
|
|
629
|
+
sha256File,
|
|
630
|
+
};
|