@sanqianx/project-knowledge 5.3.1 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +17 -14
- package/bin/project-knowledge-integrations.js +3 -3
- package/bin/project-knowledge-kb.js +2 -2
- package/bin/project-knowledge-mcp.js +3 -3
- package/bin/project-knowledge.js +5 -5
- package/module-runtime-manifest.json +11 -11
- package/package.json +30 -26
- 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/{_site → src}/README.md +30 -30
- package/{_site/lib → src/automation}/capture-hook-config.js +1 -1
- package/{_site/lib → src/automation}/commit-conversation-binder.js +4 -4
- package/{_site/lib → src/automation}/commit-processing-ledger.js +27 -27
- package/{_site/lib → src/automation}/commit-reconciler.js +11 -11
- package/{_site/lib → src/automation}/hook-manager.js +203 -203
- package/{_site/lib → src/automation}/post-commit-automation.js +87 -87
- package/{_site/lib → src/common}/atomic-file.js +1 -0
- package/{_site/lib → src/common}/runtime-endpoint.js +153 -160
- package/{_site/lib → src/common}/structured-logger.js +574 -574
- package/{_site/lib → src/conversations}/bridge-adapter.js +2 -2
- package/{_site/lib → src/conversations}/codex-notify-config.js +6 -3
- package/{_site/lib → src/conversations}/conversation-exclusions.js +2 -2
- package/{_site/lib → src/conversations}/conversation-query-service.js +144 -144
- package/{_site/lib → src/conversations}/conversation-store.js +3 -3
- package/{_site/lib → src/conversations}/zcode-context-integration.js +1 -1
- package/{_site/lib → src/integrations}/ai-profile-resolver.js +78 -78
- package/{_site/lib → src/integrations}/ai-workspace.js +101 -101
- package/{_site/lib → src/integrations}/claude-cli-runner.js +1510 -1510
- package/{_site/lib → src/integrations}/integration-installer.js +11 -15
- package/{_site/lib → src/integrations}/llm-client.js +161 -161
- package/{_site/lib → src/knowledge}/context-pack-builder.js +3 -3
- package/{_site/lib → src/knowledge}/evidence-bundle.js +2 -2
- package/{_site/lib → src/knowledge}/index-service.js +173 -173
- package/{_site/lib → src/knowledge}/kb-framework.js +171 -191
- package/{_site/lib → src/knowledge}/knowledge-promotion.js +6 -6
- package/{_site/lib → src/knowledge}/knowledge-retrieval-service.js +401 -401
- package/{_site/lib → src/module_bridge}/engine-connection.js +2 -2
- package/{_site/lib → src/module_bridge}/engine-knowledge-client.js +3 -3
- package/{_site/lib → src/module_bridge}/module-bridge.js +9 -9
- package/{_site/lib → src/projects}/github-team-store.js +1172 -1172
- package/{_site/lib → src/projects}/project-lifecycle-service.js +5 -5
- package/{_site/lib → src/projects}/project-registry-store.js +3 -3
- package/{_site/lib → src/projects}/project-store.js +268 -268
- package/{_site/lib → src/projects}/scanner.js +3 -3
- package/{_site/lib → src/projects}/settings-store.js +3 -3
- package/{_site → src}/scripts/ab-rank-v2-v3.js +4 -4
- package/{_site → src}/scripts/hook-trigger.js +158 -158
- package/{_site → src}/scripts/install-module-candidates.js +2 -2
- package/{_site → src}/scripts/pack-module-candidates.js +2 -2
- package/{_site → src}/scripts/refresh-runtime-manifest.js +1 -1
- package/{_site → src}/scripts/run-retrieval-gold-isolated.js +6 -6
- package/{_site → src}/scripts/sync-product-content.js +2 -2
- package/{_site → src}/scripts/verify-product-runtime.js +3 -3
- package/{_site → src}/scripts/verify-retrieval-gold.js +1 -1
- package/{_site/lib → src/server}/product-data.js +2 -2
- package/{_site/lib → src/server}/server-app.js +40 -40
- package/{_site/lib → src/server}/storage-layout.js +166 -166
- package/{_site → src}/server.js +1 -1
- package/{_site/lib → src/tools}/knowledge-tool-runtime.js +366 -366
- package/{_site/lib → src/tools}/prompt-registry.js +1 -1
- package/{_site/lib → src/tools}/requirement-adapters.js +1 -1
- package/{_site/lib → src/tools}/requirement-binder.js +4 -4
- package/{_site/lib → src/tools}/requirement-recorder.js +278 -278
- package/{_site/lib → src/tools}/workflow-tool-runtime.js +3 -3
- package/_site/_test/agent-capture-mcp-ui-test.js +0 -118
- package/_site/_test/agent-capture-ui-test.js +0 -103
- package/_site/_test/ai-profile-resolver-test.js +0 -137
- package/_site/_test/ai-profile-test.js +0 -75
- package/_site/_test/ai-team-ui-integration-test.js +0 -219
- package/_site/_test/ai-vendor-presets-test.js +0 -91
- package/_site/_test/appearance-settings-test.js +0 -148
- package/_site/_test/automatic-context-test.js +0 -95
- package/_site/_test/automation-queue-test.js +0 -14
- package/_site/_test/automation-ui-test.js +0 -40
- package/_site/_test/background-task-registry-test.js +0 -43
- package/_site/_test/baseline-schema-test.js +0 -91
- package/_site/_test/bin-cli-test.js +0 -231
- package/_site/_test/bridge-adapter-test.js +0 -95
- package/_site/_test/bridge-consumer-service-test.js +0 -310
- package/_site/_test/candidate-bin-content-test.js +0 -35
- package/_site/_test/candidate-product-assets-test.js +0 -13
- package/_site/_test/candidate-release-contract-test.js +0 -14
- package/_site/_test/capture-hook-dedup-test.js +0 -198
- package/_site/_test/cdp-browser-failure-test.js +0 -103
- package/_site/_test/chat-claudecodeui-match-test.js +0 -111
- package/_site/_test/claude-executable-discovery-test.js +0 -90
- package/_site/_test/claude-session-lifecycle-sweep-test.js +0 -252
- package/_site/_test/claude-workbench-test.js +0 -174
- package/_site/_test/cli-instance-management-test.js +0 -62
- package/_site/_test/cli-version-report-test.js +0 -22
- package/_site/_test/client-capture-restart-e2e-test.js +0 -189
- package/_site/_test/codex-conversation-projection-test.js +0 -60
- package/_site/_test/codex-marketplace-scoped-path-test.js +0 -186
- package/_site/_test/codex-notify-capture-e2e-test.js +0 -101
- package/_site/_test/codex-notify-fanout-test.js +0 -141
- package/_site/_test/codex-notify-upgrade-test.js +0 -260
- package/_site/_test/commit-boundary-freeze-test.js +0 -147
- package/_site/_test/commit-conversation-binding-test.js +0 -99
- package/_site/_test/commit-evidence-test.js +0 -110
- package/_site/_test/configuration-generation-test.js +0 -22
- package/_site/_test/context-pack-test.js +0 -200
- package/_site/_test/context-session-index-test.js +0 -254
- package/_site/_test/conversation-api-test.js +0 -119
- package/_site/_test/conversation-origin-test.js +0 -15
- package/_site/_test/conversation-store-test.js +0 -138
- package/_site/_test/cross-repo-isolation-e2e-test.js +0 -187
- package/_site/_test/desktop-browser-compat-test.js +0 -28
- package/_site/_test/desktop-hook-runtime-regression-test.js +0 -204
- package/_site/_test/embedding-config-test.js +0 -32
- package/_site/_test/explicit-commit-processor-test.js +0 -37
- package/_site/_test/fixtures/fake-browser-exit.js +0 -10
- package/_site/_test/fixtures/fake-browser-hang.js +0 -10
- package/_site/_test/fixtures/integration-busy-worker.cjs +0 -14
- package/_site/_test/fixtures/make-git-repos.js +0 -92
- package/_site/_test/fixtures/retrieval-gold-queries.json +0 -36
- package/_site/_test/fixtures/slow-startup-integration.cjs +0 -12
- package/_site/_test/fixtures/startup-repair-worker.cjs +0 -13
- package/_site/_test/folder-picker-output-test.js +0 -19
- package/_site/_test/fresh-hook-reimport-test.js +0 -53
- package/_site/_test/fresh-product-data-test.js +0 -56
- package/_site/_test/full-integration-e2e-test.js +0 -167
- package/_site/_test/git-path-compatibility-test.js +0 -80
- package/_site/_test/git-validation-test.js +0 -81
- package/_site/_test/glm-ui-refresh-review-test.js +0 -313
- package/_site/_test/harness-isolation-test.js +0 -138
- package/_site/_test/helpers/ai-team-ui-fixture.js +0 -235
- package/_site/_test/helpers/cdp-browser.js +0 -386
- package/_site/_test/helpers/cdp-network-capture.js +0 -66
- package/_site/_test/helpers/find-chrome.js +0 -34
- package/_site/_test/helpers/free-port.js +0 -8
- package/_site/_test/helpers/logging-ui-fixture.js +0 -131
- package/_site/_test/helpers/module-fixture.js +0 -282
- package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +0 -606
- package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +0 -464
- package/_site/_test/helpers/parallel-dock-acceptance-env.js +0 -301
- package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +0 -378
- package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +0 -314
- package/_site/_test/helpers/parallel-dock-acceptance-ui.js +0 -195
- package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +0 -113
- package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +0 -307
- package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +0 -373
- package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +0 -314
- package/_site/_test/helpers/parallel-engine-advanced-engine-child.js +0 -45
- package/_site/_test/helpers/parallel-engine-advanced-fault-writer.js +0 -171
- package/_site/_test/helpers/parallel-engine-advanced-harness.js +0 -245
- package/_site/_test/helpers/parallel-engine-advanced-standin-analyzer.js +0 -80
- package/_site/_test/helpers/parallel-engine-advanced-ui-host.js +0 -177
- package/_site/_test/helpers/parallel-engine-final-harness.js +0 -314
- package/_site/_test/helpers/parallel-engine-final-standin-analyzer.js +0 -159
- package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +0 -340
- package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +0 -82
- package/_site/_test/helpers/parallel-knowledge-fixture.js +0 -255
- package/_site/_test/helpers/parallel-logging-acceptance-fixture.js +0 -111
- package/_site/_test/helpers/parallel-logging-acceptance-proxy.js +0 -106
- package/_site/_test/helpers/parallel-logging-fix-r2-proxy.js +0 -205
- package/_site/_test/helpers/parallel-logging-integration-5025-env.js +0 -432
- package/_site/_test/helpers/parallel-memory-analyzer.js +0 -81
- package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +0 -605
- package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +0 -176
- package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +0 -577
- package/_site/_test/helpers/parallel-memory-event-bridge.js +0 -128
- package/_site/_test/helpers/parallel-memory-injection-shell.js +0 -723
- package/_site/_test/helpers/parallel-memory-injection-wb-host.js +0 -81
- package/_site/_test/helpers/parallel-memory-shell.js +0 -489
- package/_site/_test/helpers/parallel-nav-isolation-env.js +0 -389
- package/_site/_test/helpers/parallel-nav-module-ui.js +0 -186
- package/_site/_test/helpers/parallel-nav-proxy.js +0 -148
- package/_site/_test/helpers/parallel-nav-shell.js +0 -361
- package/_site/_test/helpers/parallel-qa-engine-endpoint-guard.js +0 -206
- package/_site/_test/helpers/parallel-qa-engine-endpoint-isolate.js +0 -259
- package/_site/_test/helpers/parallel-retrieval-followup-corpus.js +0 -293
- package/_site/_test/helpers/parallel-retrieval-followup-next-session.js +0 -70
- package/_site/_test/helpers/parallel-retrieval-followup-r2-shell.js +0 -737
- package/_site/_test/helpers/parallel-retrieval-followup-r2-wb-host.js +0 -82
- package/_site/_test/helpers/parallel-retrieval-followup-shell.js +0 -279
- package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +0 -295
- package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +0 -573
- package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +0 -69
- package/_site/_test/helpers/parallel-workbench-fixture.js +0 -371
- package/_site/_test/helpers/parallel-workbench-host.js +0 -80
- package/_site/_test/helpers/parallel-workbench-integration-5025-fixture.js +0 -408
- package/_site/_test/helpers/parallel-workbench-integration-5025-harness.js +0 -593
- package/_site/_test/helpers/parallel-workbench-integration-5025-host.js +0 -70
- package/_site/_test/helpers/parallel-workbench-integration-5025-launcher.js +0 -240
- package/_site/_test/helpers/parallel-workbench-integration-5025-runtime-harness.js +0 -630
- package/_site/_test/helpers/parallel-workbench-runtime-harness.js +0 -587
- package/_site/_test/helpers/parallel-workbench-source-map.js +0 -196
- package/_site/_test/helpers/qa-r44-env.js +0 -418
- package/_site/_test/helpers/qa-r44-report.js +0 -656
- package/_site/_test/helpers/qa-r44-ui.js +0 -347
- package/_site/_test/helpers/qa-r45-harness.js +0 -94
- package/_site/_test/helpers/qa-r48-env.js +0 -64
- package/_site/_test/helpers/qa-r49-wb-host.js +0 -58
- package/_site/_test/helpers/qa-r51-env.cjs +0 -77
- package/_site/_test/helpers/qa-r91-harness.cjs +0 -534
- package/_site/_test/helpers/single-repo-maintenance-fixture.js +0 -94
- package/_site/_test/helpers/single-repo-maintenance-tool.js +0 -56
- package/_site/_test/helpers/spawn-server.js +0 -106
- package/_site/_test/helpers/version-visibility-fixture.js +0 -251
- package/_site/_test/home-overview-test.js +0 -64
- package/_site/_test/hook-relocation-rebind-test.js +0 -120
- package/_site/_test/hook-runtime-endpoint-test.js +0 -88
- package/_site/_test/hook-status-repair-api-test.js +0 -152
- package/_site/_test/hook-trigger-test.js +0 -85
- package/_site/_test/hook-worktree-test.js +0 -42
- package/_site/_test/import-preflight-api-test.js +0 -234
- package/_site/_test/index-builder-test.js +0 -41
- package/_site/_test/index-error-display-contract-test.js +0 -32
- package/_site/_test/index-writer-concurrency-test.js +0 -135
- package/_site/_test/integration-adapters-test.js +0 -262
- package/_site/_test/integration-auto-repair-test.js +0 -115
- package/_site/_test/integration-capture-setup-test.js +0 -118
- package/_site/_test/integration-intent-test.js +0 -85
- package/_site/_test/integration-runtime-binding-a2-test.js +0 -566
- package/_site/_test/integration-runtime-binding-a3-test.js +0 -227
- package/_site/_test/integration-runtime-binding-test.js +0 -473
- package/_site/_test/integration-status-scan-test.js +0 -160
- package/_site/_test/integration-surface-coverage-test.js +0 -165
- package/_site/_test/kb-framework-test.js +0 -57
- package/_site/_test/kbpath-follow-test.js +0 -63
- package/_site/_test/knowledge-db-test.js +0 -144
- package/_site/_test/knowledge-engine-client-test.js +0 -120
- package/_site/_test/knowledge-language-control-test.js +0 -170
- package/_site/_test/knowledge-maintenance-test.js +0 -40
- package/_site/_test/knowledge-panel-lifecycle-test.js +0 -154
- package/_site/_test/knowledge-panel-ui-contract-test.js +0 -110
- package/_site/_test/knowledge-promotion-recovery-test.js +0 -260
- package/_site/_test/knowledge-query-test.js +0 -54
- package/_site/_test/knowledge-retrieval-service-test.js +0 -77
- package/_site/_test/knowledge-scopes-test.js +0 -37
- package/_site/_test/knowledge-storage-location-test.js +0 -28
- package/_site/_test/knowledge-storage-startup-test.js +0 -52
- package/_site/_test/knowledge-store-logs-supervision-test.js +0 -89
- package/_site/_test/launcher-readiness-test.js +0 -80
- package/_site/_test/legacy-claude-session-alias-test.js +0 -106
- package/_site/_test/legacy-relocation-recovery-test.js +0 -258
- package/_site/_test/legacy-routes-removed-test.js +0 -47
- package/_site/_test/legacy-workbench-exclusion-test.js +0 -92
- package/_site/_test/live-gateway-test.js +0 -48
- package/_site/_test/local-marketplace-test.js +0 -16
- package/_site/_test/log-redaction-test.js +0 -58
- package/_site/_test/logging-api-test.js +0 -89
- package/_site/_test/logging-sse-no-gap-test.js +0 -88
- package/_site/_test/logging-ui-test.js +0 -107
- package/_site/_test/markdown-delta-overlay-test.js +0 -85
- package/_site/_test/markdown-maintenance-api-test.js +0 -75
- package/_site/_test/markdown-maintenance-test.js +0 -11
- package/_site/_test/mcp-server-test.js +0 -149
- package/_site/_test/memory-groups-ui-test.js +0 -173
- package/_site/_test/model-context-windows-test.js +0 -89
- package/_site/_test/module-agent-start-proxy-test.js +0 -65
- package/_site/_test/module-artifact-integrity-test.js +0 -27
- package/_site/_test/module-boundary-test.js +0 -30
- package/_site/_test/module-bridge-eventbridge-test.js +0 -202
- package/_site/_test/module-dynamic-port-test.js +0 -118
- package/_site/_test/module-index-proxy-test.js +0 -33
- package/_site/_test/module-model-configuration-test.js +0 -44
- package/_site/_test/module-process-lifecycle-test.js +0 -35
- package/_site/_test/module-stream-proxy-test.js +0 -34
- package/_site/_test/module-supervisor-backoff-reset-test.js +0 -64
- package/_site/_test/module-terminal-restart-test.js +0 -63
- package/_site/_test/module-wiring-unbind-race-test.js +0 -59
- package/_site/_test/native-context-integrations-test.js +0 -86
- package/_site/_test/non-release-ci-test.js +0 -34
- package/_site/_test/offline-boundary-isolation-test.js +0 -32
- package/_site/_test/orphaned-claim-recovery-test.js +0 -80
- package/_site/_test/package-boundary-test.js +0 -48
- package/_site/_test/package-startup-test.js +0 -56
- package/_site/_test/packaged-ui-smoke-test.js +0 -126
- package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +0 -524
- package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +0 -577
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +0 -381
- package/_site/_test/parallel-ci-r9-posix-socket-budget-test.js +0 -156
- package/_site/_test/parallel-engine-advanced-eng005-test.js +0 -136
- package/_site/_test/parallel-engine-advanced-eng006-test.js +0 -171
- package/_site/_test/parallel-engine-advanced-eng007-reconcile-test.js +0 -231
- package/_site/_test/parallel-engine-advanced-eng009-test.js +0 -208
- package/_site/_test/parallel-engine-advanced-eng010-test.js +0 -213
- package/_site/_test/parallel-engine-advanced-eng011-ui-probe.js +0 -459
- package/_site/_test/parallel-engine-final-eng002-test.js +0 -255
- package/_site/_test/parallel-engine-final-eng007-test.js +0 -269
- package/_site/_test/parallel-engine-final-eng011-test.js +0 -197
- package/_site/_test/parallel-engine-final-eng012-test.js +0 -354
- package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +0 -304
- package/_site/_test/parallel-knowledge-client-error-code-test.js +0 -194
- package/_site/_test/parallel-knowledge-engine-test.js +0 -353
- package/_site/_test/parallel-knowledge-retrieval-test.js +0 -292
- package/_site/_test/parallel-knowledge-vector-test.js +0 -168
- package/_site/_test/parallel-linux-ci-r7-log007-day-test.js +0 -110
- package/_site/_test/parallel-logging-acceptance-log003-probe.js +0 -78
- package/_site/_test/parallel-logging-acceptance-log003-test.js +0 -224
- package/_site/_test/parallel-logging-acceptance-log004-probe.js +0 -85
- package/_site/_test/parallel-logging-acceptance-log004-test.js +0 -231
- package/_site/_test/parallel-logging-acceptance-log005-test.js +0 -208
- package/_site/_test/parallel-logging-acceptance-log006-test.js +0 -214
- package/_site/_test/parallel-logging-acceptance-log007-test.js +0 -223
- package/_site/_test/parallel-logging-acceptance-log008-test.js +0 -192
- package/_site/_test/parallel-logging-fix-r2-crash-probe.js +0 -271
- package/_site/_test/parallel-logging-fix-r2-gap-test.js +0 -294
- package/_site/_test/parallel-logging-fix-r2-normalhook-test.js +0 -330
- package/_site/_test/parallel-logging-integration-5025-portability-test.js +0 -554
- package/_site/_test/parallel-memory-candidate-test.js +0 -353
- package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +0 -238
- package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +0 -371
- package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +0 -439
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +0 -333
- package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +0 -519
- package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +0 -569
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +0 -374
- package/_site/_test/parallel-memory-home-review-test.js +0 -148
- package/_site/_test/parallel-memory-injection-origin-probe.js +0 -412
- package/_site/_test/parallel-memory-injection-probe.js +0 -411
- package/_site/_test/parallel-memory-manual-test.js +0 -292
- package/_site/_test/parallel-memory-scope-test.js +0 -98
- package/_site/_test/parallel-memory-source-test.js +0 -254
- package/_site/_test/parallel-memory-sync-test.js +0 -274
- package/_site/_test/parallel-memory-view-r8-reload-gate-test.js +0 -123
- package/_site/_test/parallel-nav-failure-test.js +0 -139
- package/_site/_test/parallel-nav-home-issues-test.js +0 -159
- package/_site/_test/parallel-nav-isolation-test.js +0 -308
- package/_site/_test/parallel-nav-isolation-vector-path-test.js +0 -90
- package/_site/_test/parallel-nav-offline-test.js +0 -300
- package/_site/_test/parallel-nav-operability-test.js +0 -268
- package/_site/_test/parallel-nav-switch-test.js +0 -293
- package/_site/_test/parallel-nav-theme-test.js +0 -176
- package/_site/_test/parallel-nav-viewport-test.js +0 -321
- package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +0 -275
- package/_site/_test/parallel-retrieval-followup-citation-test.js +0 -219
- package/_site/_test/parallel-retrieval-followup-corpus-test.js +0 -289
- package/_site/_test/parallel-workbench-drafts-r4-probe.js +0 -477
- package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +0 -89
- package/_site/_test/parallel-workbench-drafts-r5-probe.js +0 -593
- package/_site/_test/parallel-workbench-independent-host.js +0 -262
- package/_site/_test/parallel-workbench-integration-5025-abort-probe.js +0 -340
- package/_site/_test/parallel-workbench-integration-5025-drafts-probe.js +0 -588
- package/_site/_test/parallel-workbench-integration-5025-env-check.js +0 -317
- package/_site/_test/parallel-workbench-integration-5025-model-probe.js +0 -342
- package/_site/_test/parallel-workbench-integration-5025-ordering-probe.js +0 -326
- package/_site/_test/parallel-workbench-model-probe.js +0 -336
- package/_site/_test/parallel-workbench-offline-test.js +0 -169
- package/_site/_test/parallel-workbench-provenance-trace.js +0 -134
- package/_site/_test/parallel-workbench-runtime-minimax-probe.js +0 -321
- package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +0 -307
- package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +0 -313
- package/_site/_test/parallel-workbench-runtime-wb008-abort.js +0 -321
- package/_site/_test/parallel-workbench-source-match.js +0 -206
- package/_site/_test/parallel-workbench-standalone-turn.js +0 -349
- package/_site/_test/path-consistency-test.js +0 -151
- package/_site/_test/pending-sweep-test.js +0 -9
- package/_site/_test/post-commit-automation-test.js +0 -87
- package/_site/_test/pr-consumer-contract-test.js +0 -55
- package/_site/_test/product-brand-contract-test.js +0 -25
- package/_site/_test/product-diagnostics-ui-test.js +0 -105
- package/_site/_test/product-empty-state-test.js +0 -214
- package/_site/_test/product-import-ui-test.js +0 -245
- package/_site/_test/product-navigation-test.js +0 -213
- package/_site/_test/product-progress-status-test.js +0 -100
- package/_site/_test/project-delete-recovery-test.js +0 -64
- package/_site/_test/project-domain-create-test.js +0 -91
- package/_site/_test/project-domain-scope-retrieval-test.js +0 -214
- package/_site/_test/project-git-init-confirm-test.js +0 -115
- package/_site/_test/project-goal-editor-test.js +0 -145
- package/_site/_test/project-import-duplicate-alias-test.js +0 -134
- package/_site/_test/project-import-unicode-restart-test.js +0 -140
- package/_site/_test/project-lifecycle-transaction-test.js +0 -106
- package/_site/_test/project-module-partial-recovery-test.js +0 -237
- package/_site/_test/project-remove-running-guard-test.js +0 -79
- package/_site/_test/project-store-test.js +0 -90
- package/_site/_test/project-team-ui-test.js +0 -128
- package/_site/_test/project-unbind-late-read-ui-test.js +0 -281
- package/_site/_test/project-unbind-writer-guard-test.js +0 -231
- package/_site/_test/prompt-settings-test.js +0 -115
- package/_site/_test/protected-architecture-gate-test.js +0 -123
- package/_site/_test/qa-r44-permission-question.js +0 -756
- package/_site/_test/qa-r45-offline-backfill-test.js +0 -279
- package/_site/_test/qa-r48-sys003-blank-secret-test.js +0 -258
- package/_site/_test/qa-r49-sys003-real-blank-probe.js +0 -374
- package/_site/_test/recovery-label-contract-test.js +0 -55
- package/_site/_test/refactor-characterization-test.js +0 -36
- package/_site/_test/registry-events-test.js +0 -38
- package/_site/_test/release-version-sync-test.js +0 -115
- package/_site/_test/requirement-binding-test.js +0 -113
- package/_site/_test/requirement-recorder-test.js +0 -173
- package/_site/_test/run-all-tests.js +0 -196
- package/_site/_test/runtime-endpoint-test.js +0 -64
- package/_site/_test/scanner-test.js +0 -83
- package/_site/_test/server-security-test.js +0 -96
- package/_site/_test/sessions-stream-test.js +0 -93
- package/_site/_test/shared-contracts-test.js +0 -58
- package/_site/_test/shared-scope-root-binding-test.js +0 -75
- package/_site/_test/simple-import-test.js +0 -98
- package/_site/_test/single-repo-maintenance-e2e-test.js +0 -200
- package/_site/_test/startup-analysis-disabled-test.js +0 -16
- package/_site/_test/startup-integration-isolation-test.js +0 -59
- package/_site/_test/startup-integration-repair-test.js +0 -43
- package/_site/_test/storage-foundation-test.js +0 -78
- package/_site/_test/structured-logger-test.js +0 -101
- package/_site/_test/t07b-cln-005-coverage-test.js +0 -212
- package/_site/_test/t07c-cln-001-002-007-coverage-test.js +0 -135
- package/_site/_test/t07d-git-rel-coverage-test.js +0 -226
- package/_site/_test/t07e-qta-coverage-test.js +0 -195
- package/_site/_test/t07f-mem-008-coverage-test.js +0 -100
- package/_site/_test/team-knowledge-store-sparse-checkout-test.js +0 -196
- package/_site/_test/team-knowledge-store-test.js +0 -132
- package/_site/_test/test-server-cleanup-test.js +0 -35
- package/_site/_test/test-server-module-isolation-test.js +0 -37
- package/_site/_test/tracking-start-test.js +0 -144
- package/_site/_test/vector-storage-root-test.js +0 -75
- package/_site/_test/version-visibility-browser-probe.js +0 -249
- package/_site/_test/version-visibility-test.js +0 -92
- package/_site/_test/workbench-context-receipts-test.js +0 -27
- package/_site/_test/workbench-permission-test.js +0 -118
- package/_site/_test/workflow-module-wiring-test.js +0 -252
- package/_site/_test/workflow-tools-test.js +0 -243
- package/_site/_test/workspace-ui-contract-test.js +0 -77
- package/_site/_test/zcode-capture-integration-test.js +0 -112
- package/templates/change.md +0 -30
- package/templates/project-readme.md +0 -52
- /package/docs/{assets → images}/architecture.svg +0 -0
- /package/docs/{assets → images}/dashboard.png +0 -0
- /package/docs/{assets → images}/draft-review.png +0 -0
- /package/docs/{assets → images}/logo.svg +0 -0
- /package/docs/{assets → images}/runs-drafts.png +0 -0
- /package/docs/{assets → images}/settings.png +0 -0
- /package/{ui → resources/ui}/favicon.svg +0 -0
- /package/{ui → resources/ui}/index.html +0 -0
- /package/{ui → resources/ui}/knowledge-panel.html +0 -0
- /package/{ui → resources/ui}/live-client.js +0 -0
- /package/{ui → resources/ui}/product.css +0 -0
- /package/{ui → resources/ui}/product.js +0 -0
- /package/{ui → resources/ui}/version-info.css +0 -0
- /package/{ui → resources/ui}/version-info.js +0 -0
- /package/{_site/lib → src/automation}/automation-config.js +0 -0
- /package/{_site/lib → src/automation}/commit-prompt.js +0 -0
- /package/{_site/lib → src/common}/cli-instances.js +0 -0
- /package/{_site/lib → src/common}/contracts.js +0 -0
- /package/{_site/lib → src/common}/data-dir.js +0 -0
- /package/{_site/lib → src/common}/folder-picker-output.js +0 -0
- /package/{_site/lib → src/common}/git-path.js +0 -0
- /package/{_site/lib → src/common}/git-runner.js +0 -0
- /package/{_site/lib → src/common}/runtime-control.js +0 -0
- /package/{_site/lib → src/conversations}/bridge-consumer-service.js +0 -0
- /package/{_site/lib → src/conversations}/codex-context-status.js +0 -0
- /package/{_site/lib → src/integrations}/ai-vendor-presets.js +0 -0
- /package/{_site/lib → src/integrations}/claude-plugin-status.js +0 -0
- /package/{_site/lib → src/integrations}/integration-auto-repair.js +0 -0
- /package/{_site/lib → src/integrations}/integration-intent.js +0 -0
- /package/{_site/lib → src/integrations}/integration-repair-worker.js +0 -0
- /package/{_site/lib → src/integrations}/integration-status-scan.js +0 -0
- /package/{_site/lib → src/integrations}/integration-status-worker.js +0 -0
- /package/{_site/lib → src/integrations}/model-context-windows.js +0 -0
- /package/{_site/lib → src/integrations}/startup-integration-repair.js +0 -0
- /package/{_site/lib → src/knowledge}/embedding-service.js +0 -0
- /package/{_site/lib → src/knowledge}/index-builder.js +0 -0
- /package/{_site/lib → src/knowledge}/kb-validator.js +0 -0
- /package/{_site/lib → src/knowledge}/knowledge-db.js +0 -0
- /package/{_site/lib → src/knowledge}/knowledge-schema.js +0 -0
- /package/{_site/lib → src/knowledge}/markdown-knowledge-indexer.js +0 -0
- /package/{_site → src}/scripts/codex-notify-fanout.cjs +0 -0
- /package/{_site → src}/scripts/folder-picker.ps1 +0 -0
- /package/{_site → src}/scripts/sync-release-version.js +0 -0
- /package/{_site → src}/scripts/verify-module-runtime.js +0 -0
- /package/{_site/lib → src/server}/live-gateway.js +0 -0
- /package/{_site/lib → src/server}/module-port-resolver.js +0 -0
- /package/{_site/lib → src/server}/public-version-info.js +0 -0
- /package/{_site → src}/start.bat +0 -0
- /package/{_site → src}/stop.bat +0 -0
- /package/{_site/lib → src/tools}/registry-events.js +0 -0
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('node:assert/strict');
|
|
4
|
-
const fs = require('node:fs');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
|
|
7
|
-
const input = JSON.parse(fs.readFileSync(0, 'utf8'));
|
|
8
|
-
assert.equal(input.schema, 'ai-team-maintenance/v1');
|
|
9
|
-
assert.equal(fs.realpathSync(input.workspace), fs.realpathSync(process.cwd()));
|
|
10
|
-
assert.equal(typeof input.member.instructions, 'string');
|
|
11
|
-
assert.equal(process.env.KB_WORKFLOW_RUNTIME_TOKEN, undefined);
|
|
12
|
-
assert.equal(process.env.GIT_DIR, undefined);
|
|
13
|
-
const mode = process.argv[2];
|
|
14
|
-
|
|
15
|
-
switch (mode) {
|
|
16
|
-
case 'check':
|
|
17
|
-
assert.equal(input.phase, 'check');
|
|
18
|
-
assert.deepEqual(input.member.memoryGroupIds, ['group-code']);
|
|
19
|
-
if (fs.readFileSync('policy.txt', 'utf8').trim() !== 'PASS') {
|
|
20
|
-
console.log(JSON.stringify({ path: 'policy.txt', expected: 'PASS' }));
|
|
21
|
-
process.exitCode = 1;
|
|
22
|
-
}
|
|
23
|
-
break;
|
|
24
|
-
case 'repair':
|
|
25
|
-
assert.equal(input.phase, 'repair');
|
|
26
|
-
assert.equal(JSON.parse(input.findings.stdout.text).path, 'policy.txt');
|
|
27
|
-
fs.writeFileSync('policy.txt', 'PASS\n');
|
|
28
|
-
break;
|
|
29
|
-
case 'format':
|
|
30
|
-
assert.equal(input.phase, 'apply');
|
|
31
|
-
fs.writeFileSync('formatted.txt', 'one line\n');
|
|
32
|
-
console.log('format completed');
|
|
33
|
-
break;
|
|
34
|
-
case 'docs':
|
|
35
|
-
assert.equal(input.phase, 'apply');
|
|
36
|
-
assert.ok(fs.existsSync('formatted.txt'), 'docs reads the updated remote baseline');
|
|
37
|
-
fs.mkdirSync('docs', { recursive: true });
|
|
38
|
-
fs.writeFileSync(path.join('docs', 'usage.md'), '# Formatted repository\n');
|
|
39
|
-
break;
|
|
40
|
-
case 'reject':
|
|
41
|
-
console.log('Additional fixes required');
|
|
42
|
-
process.exitCode = 1;
|
|
43
|
-
break;
|
|
44
|
-
case 'stubborn':
|
|
45
|
-
fs.writeFileSync('unresolved.txt', 'Keep this after failed review\n');
|
|
46
|
-
break;
|
|
47
|
-
case 'timeout':
|
|
48
|
-
fs.writeFileSync('timed-out.txt', 'Keep this after timeout\n');
|
|
49
|
-
setTimeout(() => {}, 10_000);
|
|
50
|
-
break;
|
|
51
|
-
case 'record':
|
|
52
|
-
fs.writeFileSync('push-permission.txt', 'This candidate should stay local\n');
|
|
53
|
-
break;
|
|
54
|
-
default:
|
|
55
|
-
throw new Error('Unknown fixture tool action.');
|
|
56
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// _site/_test/helpers/spawn-server.js
|
|
2
|
-
//
|
|
3
|
-
// Test helper: spawn _site/server.js with an isolated KB_DATA_DIR so each
|
|
4
|
-
// regression test runs against a fresh, empty user-data location. Without
|
|
5
|
-
// this, server.js would default to ~/.project-knowledge/ and tests would
|
|
6
|
-
// pollute (or read from) the real user data.
|
|
7
|
-
//
|
|
8
|
-
// Usage:
|
|
9
|
-
// const { server, dataDir, cleanup } = require('./helpers/spawn-server');
|
|
10
|
-
// const { server, dataDir, cleanup } = spawnServer({
|
|
11
|
-
// root: ROOT,
|
|
12
|
-
// port: 7891,
|
|
13
|
-
// extraEnv: { KB_AUTOMATION_FAKE_CLAUDE: '1' },
|
|
14
|
-
// tag: 'hook-trigger',
|
|
15
|
-
// });
|
|
16
|
-
// ...
|
|
17
|
-
// cleanup(); // kills server + removes temp dataDir
|
|
18
|
-
|
|
19
|
-
const fs = require('fs');
|
|
20
|
-
const os = require('os');
|
|
21
|
-
const path = require('path');
|
|
22
|
-
const { spawn } = require('child_process');
|
|
23
|
-
const runtimeControl = require('../../lib/runtime-control');
|
|
24
|
-
const runtimeEndpoint = require('../../lib/runtime-endpoint');
|
|
25
|
-
|
|
26
|
-
function defaultDataDir(tag) {
|
|
27
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), `kb-data-${tag || 'test'}-${process.pid}-`));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function spawnServer({ root, port, host = '127.0.0.1', dataDir, extraEnv = {}, tag, analysisOwner = 'legacy', stdio = ['ignore', 'pipe', 'pipe'], cwd }) {
|
|
31
|
-
const dir = dataDir || defaultDataDir(tag);
|
|
32
|
-
// Isolate the Bridge journal home too: the runtime registers a
|
|
33
|
-
// 'project-knowledge' consumer at startup, and without this the test
|
|
34
|
-
// server would write into the developer's real ~/.ai-coding-event-bridge.
|
|
35
|
-
const bridgeHome = fs.mkdtempSync(path.join(os.tmpdir(), `kb-bridge-${tag || 'test'}-${process.pid}-`));
|
|
36
|
-
// The knowledge root is a second product-owned location. A test must never
|
|
37
|
-
// inherit the developer's real knowledge directory through the environment,
|
|
38
|
-
// so give every isolated instance its own one.
|
|
39
|
-
const knowledgeDir = fs.mkdtempSync(path.join(os.tmpdir(), `kb-knowledge-${tag || 'test'}-${process.pid}-`));
|
|
40
|
-
// Legacy behavior tests characterize the retired writer in isolation. The
|
|
41
|
-
// production entry point still defaults to engine ownership; product tests
|
|
42
|
-
// explicitly request it and run the real module services.
|
|
43
|
-
const entry = path.join(root, '_site', 'lib', 'server-app.js');
|
|
44
|
-
// CI 40075242420 (normalhook, linux24): a startup rejection used to vanish —
|
|
45
|
-
// exit 1 with empty stdout/stderr — because this catch swallowed the reason.
|
|
46
|
-
// The failure path below prints the child's stderr tail, so emit one bounded
|
|
47
|
-
// JSON line of own metadata (code / message head / first stack frame's file
|
|
48
|
-
// only; never logs, keys or transcripts) and keep exit 1.
|
|
49
|
-
const bootstrap = `const {startServer,installProcessHandlers}=require(${JSON.stringify(entry)});const instance=startServer({analysisOwner:${JSON.stringify(analysisOwner)}});installProcessHandlers(instance);instance.then(s=>process.stdout.write('Project Knowledge listening on http://'+s.host+':'+s.port+'\\n')).catch(e=>{const frame=String(e&&e.stack||'').split('\\n')[1]||'';const fm=/([^\\\\/]+\\.[a-z]+):/i.exec(frame);process.stderr.write(JSON.stringify({event:'server.startup-fatal',code:e&&e.code||null,message:String(e&&e.message||e).slice(0,300),stackFile:fm?fm[1]:null})+'\\n');process.exitCode=1});`;
|
|
50
|
-
const child = spawn(process.execPath, ['-e', bootstrap], {
|
|
51
|
-
cwd: cwd || root,
|
|
52
|
-
env: {
|
|
53
|
-
...process.env,
|
|
54
|
-
KB_SITE_PORT: String(port),
|
|
55
|
-
KB_SITE_HOST: host,
|
|
56
|
-
KB_DATA_DIR: dir,
|
|
57
|
-
KB_KNOWLEDGE_DATA_DIR: knowledgeDir,
|
|
58
|
-
KB_CLAUDE_RULES_DIR: dir,
|
|
59
|
-
KB_SKIP_MIGRATION: '1',
|
|
60
|
-
// 测试隔离:禁止测试服务器向真实模块(terminal/vector-hub)登记项目
|
|
61
|
-
KB_MODULES_REGISTER: '0',
|
|
62
|
-
KB_MODULES_AUTOSTART: '0',
|
|
63
|
-
// Disabling registration does not disable status/profile reads. Never
|
|
64
|
-
// let an isolated legacy test consult the developer's live modules.
|
|
65
|
-
// A test needing real modules supplies its own URLs in extraEnv below.
|
|
66
|
-
KB_TERMINAL_URL: 'http://127.0.0.1:0',
|
|
67
|
-
KB_VECTORHUB_URL: 'http://127.0.0.1:0',
|
|
68
|
-
KB_EVENTBRIDGE_URL: 'http://127.0.0.1:0',
|
|
69
|
-
KB_KNOWLEDGE_ENGINE_URL: 'http://127.0.0.1:0',
|
|
70
|
-
AI_CODING_EVENT_BRIDGE_HOME: bridgeHome,
|
|
71
|
-
...extraEnv,
|
|
72
|
-
},
|
|
73
|
-
stdio,
|
|
74
|
-
windowsHide: true,
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
child,
|
|
78
|
-
dataDir: dir,
|
|
79
|
-
bridgeHome,
|
|
80
|
-
knowledgeDir,
|
|
81
|
-
cleanup: async () => {
|
|
82
|
-
// On Windows SIGTERM is a force kill. Drain owned background work via
|
|
83
|
-
// the verified control channel first, so Git/Agent children release cwd.
|
|
84
|
-
const live = runtimeEndpoint.readEndpoint(dir);
|
|
85
|
-
if (live?.pid === child.pid && child.exitCode === null) {
|
|
86
|
-
try { await runtimeControl.request(dir, { action: 'stop', pid: live.pid, port: live.port, startedAt: live.startedAt }, 10000); } catch {}
|
|
87
|
-
await new Promise(resolve => {
|
|
88
|
-
const timer = setTimeout(resolve, 1500);
|
|
89
|
-
child.once('close', () => { clearTimeout(timer); resolve(); });
|
|
90
|
-
if (child.exitCode !== null) { clearTimeout(timer); resolve(); }
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (child.exitCode === null) try { child.kill(); } catch {}
|
|
94
|
-
await new Promise(resolve => {
|
|
95
|
-
const timer = setTimeout(resolve, 5000);
|
|
96
|
-
child.once('close', () => { clearTimeout(timer); resolve(); });
|
|
97
|
-
if (child.exitCode !== null) { clearTimeout(timer); resolve(); }
|
|
98
|
-
});
|
|
99
|
-
await fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
100
|
-
await fs.promises.rm(bridgeHome, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
101
|
-
await fs.promises.rm(knowledgeDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
module.exports = { spawnServer, defaultDataDir };
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// FEATURE-VERSIONS-01-R2 fixture — the version-visibility lane's own isolation
|
|
3
|
-
// contract, borrowed from the accepted drafts-r5 fixture (read-only reuse of
|
|
4
|
-
// its patterns; that file stays untouched):
|
|
5
|
-
// * every directory lives under a repo-external temp root (PK_TEST_TEMP_ROOT
|
|
6
|
-
// → repo-parent shared root when it exists → TEMP/TMP/TMPDIR → os.tmpdir),
|
|
7
|
-
// never inside the repository, never on a hardcoded drive/user dir;
|
|
8
|
-
// * the full env whitelist (HOME/USERPROFILE/HOMEDRIVE/HOMEPATH/CODEX_HOME/
|
|
9
|
-
// CLAUDE_CONFIG_DIR/APPDATA/LOCALAPPDATA/TEMP/TMP/TMPDIR/双 KB_DATA_DIR/
|
|
10
|
-
// Bridge home/Workbench data) is absolute-pathed into one per-run layout
|
|
11
|
-
// root; ambient module addresses and Anthropic credentials are stripped;
|
|
12
|
-
// * the live product ports 5757/5760/5789/5790/8787/8790 are refused;
|
|
13
|
-
// * Chrome is resolved from the REAL machine before any isolation is applied
|
|
14
|
-
// (find-chrome reads the real environment), then run with an isolated
|
|
15
|
-
// --user-data-dir plus the Chrome>=136 empty-default-dir scaffold under the
|
|
16
|
-
// isolated home so remote debugging is accepted.
|
|
17
|
-
const fs = require('node:fs');
|
|
18
|
-
const os = require('node:os');
|
|
19
|
-
const path = require('node:path');
|
|
20
|
-
const net = require('node:net');
|
|
21
|
-
const { findChromeDetailed } = require('./find-chrome');
|
|
22
|
-
|
|
23
|
-
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
24
|
-
const FORBIDDEN_PORTS = new Set([5757, 5760, 5789, 5790, 8787, 8790]);
|
|
25
|
-
|
|
26
|
-
const AMBIENT_MODULE_URLS = [
|
|
27
|
-
'KB_KNOWLEDGE_ENGINE_URL', 'KB_VECTORHUB_URL', 'KB_TERMINAL_URL', 'KB_EVENTBRIDGE_URL', 'KB_EVENT_BRIDGE_URL',
|
|
28
|
-
'KB_WORKBENCH_RUNTIME_TOKEN', 'KB_MODULES_AUTOSTART',
|
|
29
|
-
];
|
|
30
|
-
const AMBIENT_MODEL_ENV = [
|
|
31
|
-
'ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN', 'ANTHROPIC_BASE_URL', 'ANTHROPIC_MODEL',
|
|
32
|
-
'ANTHROPIC_DEFAULT_THINKING_MODEL', 'ANTHROPIC_DEFAULT_HAIKU_MODEL', 'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
|
33
|
-
'ANTHROPIC_DEFAULT_OP_MODEL', 'API_TIMEOUT_MS', 'CLAUDE_CODE_OAUTH_TOKEN',
|
|
34
|
-
'CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX', 'CLAUDE_CODE_USE_FOUNDRY',
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const ISOLATION_PATH_KEYS = [
|
|
38
|
-
'HOME', 'USERPROFILE', 'CODEX_HOME', 'CLAUDE_CONFIG_DIR', 'APPDATA', 'LOCALAPPDATA',
|
|
39
|
-
'TEMP', 'TMP', 'TMPDIR', 'KB_DATA_DIR', 'KB_KNOWLEDGE_DATA_DIR',
|
|
40
|
-
'AI_CODING_EVENT_BRIDGE_HOME', 'AGENT_TERMINAL_DATA_DIR', 'CLAUDE_AI_WORKBENCH_DATA_DIR',
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
// Captured at module load, BEFORE any isolation could hide the real machine:
|
|
44
|
-
// the browser binary this lane's UI acceptance will drive.
|
|
45
|
-
const CHROME_PATH = findChromeDetailed().path;
|
|
46
|
-
|
|
47
|
-
function isInside(candidate, parent) {
|
|
48
|
-
const relative = path.relative(parent, candidate);
|
|
49
|
-
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function resolveTempRoot() {
|
|
53
|
-
const sharedRoot = path.join(path.dirname(REPO_ROOT), '.project-knowledge-test-temp');
|
|
54
|
-
const candidates = [process.env.PK_TEST_TEMP_ROOT, fs.existsSync(sharedRoot) ? sharedRoot : null, process.env.TEMP, process.env.TMP, process.env.TMPDIR];
|
|
55
|
-
const chosen = candidates.find(value => value && String(value).trim());
|
|
56
|
-
const root = path.resolve(chosen ? String(chosen).trim() : os.tmpdir());
|
|
57
|
-
if (isInside(root, REPO_ROOT)) throw new Error(`refusing to use a temp root inside the repository: ${root}`);
|
|
58
|
-
return root;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function makeTempDir(prefix = 'version-visibility') {
|
|
62
|
-
const root = resolveTempRoot();
|
|
63
|
-
fs.mkdirSync(root, { recursive: true });
|
|
64
|
-
const dir = fs.mkdtempSync(path.join(root, `${prefix}-`));
|
|
65
|
-
if (isInside(dir, REPO_ROOT)) throw new Error(`refusing to create a fixture inside the repository: ${dir}`);
|
|
66
|
-
return dir;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function removeTree(dir) {
|
|
70
|
-
if (!dir) return;
|
|
71
|
-
fs.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function freePort() {
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
const server = net.createServer();
|
|
77
|
-
server.unref();
|
|
78
|
-
server.on('error', reject);
|
|
79
|
-
server.listen(0, '127.0.0.1', () => {
|
|
80
|
-
const { port } = server.address();
|
|
81
|
-
server.close(() => {
|
|
82
|
-
if (FORBIDDEN_PORTS.has(Number(port))) { reject(new Error(`refusing to use the live port ${port}`)); return; }
|
|
83
|
-
resolve(Number(port));
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function assertAllowedEndpoint(url, what = 'endpoint') {
|
|
90
|
-
const parsed = new URL(String(url));
|
|
91
|
-
const port = parsed.port ? Number(parsed.port) : (parsed.protocol === 'https:' ? 443 : 80);
|
|
92
|
-
if (FORBIDDEN_PORTS.has(port)) throw new Error(`refusing to contact the live ${what} ${url}`);
|
|
93
|
-
return url;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function waitForHttp(url, timeoutMs = 45000) {
|
|
97
|
-
assertAllowedEndpoint(url, 'service');
|
|
98
|
-
const until = Date.now() + timeoutMs;
|
|
99
|
-
let lastError = null;
|
|
100
|
-
while (Date.now() < until) {
|
|
101
|
-
try {
|
|
102
|
-
const response = await fetch(url, { signal: AbortSignal.timeout(2000) });
|
|
103
|
-
if (response.ok) return true;
|
|
104
|
-
lastError = new Error(`HTTP ${response.status}`);
|
|
105
|
-
} catch (error) { lastError = error; }
|
|
106
|
-
await new Promise(resolve => setTimeout(resolve, 120));
|
|
107
|
-
}
|
|
108
|
-
throw new Error(`Timed out waiting for ${url}: ${lastError && lastError.message}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function sanitizedEnv(extra = {}, source = process.env) {
|
|
112
|
-
const env = {};
|
|
113
|
-
const systemKey = /^(?:PATH|PATHEXT|SYSTEMROOT|WINDIR|SYSTEMDRIVE|COMSPEC|OS|PROCESSOR_ARCHITECTURE|PROCESSOR_IDENTIFIER|PROCESSOR_LEVEL|PROCESSOR_REVISION|NUMBER_OF_PROCESSORS|PROGRAMFILES(?:\(X86\))?|PROGRAMW6432|PROGRAMDATA|LANG|LC_ALL|LC_CTYPE|TERM)$/i;
|
|
114
|
-
for (const [key, value] of Object.entries(source)) {
|
|
115
|
-
if (systemKey.test(key)) env[key] = value;
|
|
116
|
-
}
|
|
117
|
-
// Only the inherited environment is filtered. Explicit lane URLs and the
|
|
118
|
-
// disabled autostart flag must survive, or the server uses live defaults.
|
|
119
|
-
return { ...env, ...extra };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function spawnNode(args, env = {}) {
|
|
123
|
-
const { spawn } = require('node:child_process');
|
|
124
|
-
const child = spawn(process.execPath, args, { env: sanitizedEnv(env), windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
125
|
-
const output = { stdout: '', stderr: '' };
|
|
126
|
-
child.stdout.on('data', chunk => { output.stdout += chunk; });
|
|
127
|
-
child.stderr.on('data', chunk => { output.stderr += chunk; });
|
|
128
|
-
const exited = new Promise(resolve => child.once('close', code => resolve({ code, ...output })));
|
|
129
|
-
return { child, exited, output };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function createIsolationLayout(prefix = 'version-visibility') {
|
|
133
|
-
const root = makeTempDir(prefix);
|
|
134
|
-
const layout = {
|
|
135
|
-
root,
|
|
136
|
-
dataDir: path.join(root, 'kb-data'),
|
|
137
|
-
knowledgeDataDir: path.join(root, 'knowledge-data'),
|
|
138
|
-
bridgeHome: path.join(root, 'bridge-home'),
|
|
139
|
-
workbenchDataDir: path.join(root, 'workbench-data'),
|
|
140
|
-
home: path.join(root, 'home'),
|
|
141
|
-
claudeConfigDir: path.join(root, 'claude-config'),
|
|
142
|
-
codexHome: path.join(root, 'codex-home'),
|
|
143
|
-
appData: path.join(root, 'appdata'),
|
|
144
|
-
localAppData: path.join(root, 'localappdata'),
|
|
145
|
-
temp: path.join(root, 'temp'),
|
|
146
|
-
};
|
|
147
|
-
for (const dir of Object.values(layout)) fs.mkdirSync(dir, { recursive: true });
|
|
148
|
-
// Chrome >= 136 gate: an empty default-shaped "User Data" scaffold under the
|
|
149
|
-
// ISOLATED home lets the default-dir resolution succeed, so the separate
|
|
150
|
-
// --user-data-dir browser profile below this layout is accepted. Nothing of
|
|
151
|
-
// the real machine is touched.
|
|
152
|
-
fs.mkdirSync(path.join(layout.home, 'AppData', 'Local', 'Google', 'Chrome', 'User Data'), { recursive: true });
|
|
153
|
-
fs.mkdirSync(path.join(layout.home, 'AppData', 'Roaming'), { recursive: true });
|
|
154
|
-
return layout;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function isolationEnvMap(layout, extraPaths = {}) {
|
|
158
|
-
const parsed = path.parse(layout.home);
|
|
159
|
-
return {
|
|
160
|
-
HOME: layout.home,
|
|
161
|
-
USERPROFILE: layout.home,
|
|
162
|
-
HOMEDRIVE: parsed.root,
|
|
163
|
-
HOMEPATH: parsed.root === path.sep ? layout.home.slice(1) : layout.home.slice(parsed.root.length),
|
|
164
|
-
CODEX_HOME: layout.codexHome,
|
|
165
|
-
CLAUDE_CONFIG_DIR: layout.claudeConfigDir,
|
|
166
|
-
APPDATA: layout.appData,
|
|
167
|
-
LOCALAPPDATA: layout.localAppData,
|
|
168
|
-
TEMP: layout.temp,
|
|
169
|
-
TMP: layout.temp,
|
|
170
|
-
TMPDIR: layout.temp,
|
|
171
|
-
PSModuleAnalysisCachePath: path.join(layout.temp, 'powershell-module-cache'),
|
|
172
|
-
KB_DATA_DIR: layout.dataDir,
|
|
173
|
-
KB_KNOWLEDGE_DATA_DIR: layout.knowledgeDataDir,
|
|
174
|
-
AI_CODING_EVENT_BRIDGE_HOME: layout.bridgeHome,
|
|
175
|
-
AGENT_TERMINAL_DATA_DIR: layout.workbenchDataDir,
|
|
176
|
-
CLAUDE_AI_WORKBENCH_DATA_DIR: layout.workbenchDataDir,
|
|
177
|
-
KB_MODULES_AUTOSTART: '0',
|
|
178
|
-
...extraPaths,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function hostEnv(layout, extra = {}) {
|
|
183
|
-
return sanitizedEnv(isolationEnvMap(layout, extra));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function applyIsolationEnv(layout) {
|
|
187
|
-
const env = hostEnv(layout);
|
|
188
|
-
for (const key of Object.keys(process.env)) delete process.env[key];
|
|
189
|
-
Object.assign(process.env, env);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// The product server under test: real _site/server.js, fully isolated, with
|
|
193
|
-
// every module address explicitly held on this run's own free ports (so the
|
|
194
|
-
// process can never reach for the live defaults 5760/8787/8790/5790).
|
|
195
|
-
async function startRootServer(layout, options = {}) {
|
|
196
|
-
const port = options.port || await freePort();
|
|
197
|
-
const [terminalPort, vectorHubPort, eventBridgePort, enginePort] = await Promise.all([freePort(), freePort(), freePort(), freePort()]);
|
|
198
|
-
const env = hostEnv(layout, {
|
|
199
|
-
KB_SITE_PORT: String(port),
|
|
200
|
-
KB_SITE_HOST: '127.0.0.1',
|
|
201
|
-
KB_TERMINAL_URL: `http://127.0.0.1:${terminalPort}`,
|
|
202
|
-
KB_VECTORHUB_URL: `http://127.0.0.1:${vectorHubPort}`,
|
|
203
|
-
KB_EVENTBRIDGE_URL: `http://127.0.0.1:${eventBridgePort}`,
|
|
204
|
-
KB_KNOWLEDGE_ENGINE_URL: `http://127.0.0.1:${enginePort}`,
|
|
205
|
-
});
|
|
206
|
-
const runner = spawnNode([path.join(REPO_ROOT, '_site', 'server.js')], env);
|
|
207
|
-
const base = `http://127.0.0.1:${port}`;
|
|
208
|
-
await waitForHttp(`${base}/api/system/version`);
|
|
209
|
-
return { layout, port, base, runner, modulePorts: { terminalPort, vectorHubPort, eventBridgePort, enginePort } };
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async function stopRootServer(server) {
|
|
213
|
-
if (!server || !server.runner) return;
|
|
214
|
-
server.runner.child.kill();
|
|
215
|
-
await server.runner.exited;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// The honest-unknown branch: serve the REAL ui/ assets from disk, but fail the
|
|
219
|
-
// version GET — the tooltip must then say 版本未知 instead of inventing one.
|
|
220
|
-
async function startVersionBrokenUiServer(layout, options = {}) {
|
|
221
|
-
const port = options.port || await freePort();
|
|
222
|
-
const uiRoot = path.join(REPO_ROOT, 'ui');
|
|
223
|
-
const types = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml' };
|
|
224
|
-
const http = require('node:http');
|
|
225
|
-
const server = http.createServer((req, res) => {
|
|
226
|
-
const pathname = new URL(req.url, 'http://127.0.0.1').pathname;
|
|
227
|
-
if (pathname === '/api/system/version') {
|
|
228
|
-
res.writeHead(503, { 'Content-Type': 'application/json' });
|
|
229
|
-
res.end(JSON.stringify({ ok: false }));
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const rel = pathname === '/' ? 'index.html' : pathname.replace(/^\//, '');
|
|
233
|
-
const file = path.join(uiRoot, rel);
|
|
234
|
-
if (!isInside(path.resolve(file), uiRoot) || !fs.existsSync(file) || !fs.statSync(file).isFile()) {
|
|
235
|
-
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
236
|
-
res.end('Not found');
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
res.writeHead(200, { 'Content-Type': types[path.extname(file)] || 'application/octet-stream' });
|
|
240
|
-
res.end(fs.readFileSync(file));
|
|
241
|
-
});
|
|
242
|
-
await new Promise(resolve => server.listen(port, '127.0.0.1', resolve));
|
|
243
|
-
return { layout, port, base: `http://127.0.0.1:${port}`, server };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
module.exports = {
|
|
247
|
-
REPO_ROOT, FORBIDDEN_PORTS, AMBIENT_MODULE_URLS, AMBIENT_MODEL_ENV, ISOLATION_PATH_KEYS,
|
|
248
|
-
CHROME_PATH, resolveTempRoot, makeTempDir, removeTree, freePort, assertAllowedEndpoint,
|
|
249
|
-
waitForHttp, sanitizedEnv, spawnNode, createIsolationLayout, isolationEnvMap, hostEnv, applyIsolationEnv,
|
|
250
|
-
startRootServer, stopRootServer, startVersionBrokenUiServer,
|
|
251
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// _site/_test/home-overview-test.js
|
|
3
|
-
//
|
|
4
|
-
// P04 canonical: the home overview aggregates over the FULL run list, never
|
|
5
|
-
// the capped recent-event window. An old failure buried under more than a
|
|
6
|
-
// hundred newer successes must still surface as a manual attention item.
|
|
7
|
-
//
|
|
8
|
-
// The runs are written through the engine's own store (real persistence),
|
|
9
|
-
// the read goes through the product's real same-origin proxy, and the
|
|
10
|
-
// recovery classification is asserted from the scheduler's own contract.
|
|
11
|
-
|
|
12
|
-
const assert = require('node:assert/strict');
|
|
13
|
-
const { startHarness, makeRepo, commitFile } = require('./helpers/parallel-memory-shell');
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
const harness = await startHarness({ tag: 'overview' });
|
|
17
|
-
try {
|
|
18
|
-
const repo = makeRepo(harness.fixture, 'overview-repo', { 'README.md': '# 总览\n\n正文。\n' });
|
|
19
|
-
const { projectId } = await harness.importProject(repo, '总览项目');
|
|
20
|
-
await harness.requestRegistryRefresh();
|
|
21
|
-
await harness.waitFor(async () => (await harness.productApi('GET', '/api/engine/health')).status === 200, 'the engine connection is confirmed', 30000);
|
|
22
|
-
|
|
23
|
-
// One real maintenance run so the project has real history.
|
|
24
|
-
const head = commitFile(repo, 'docs/one.md', '# 一\n', 'first');
|
|
25
|
-
await harness.triggerRun(projectId, head);
|
|
26
|
-
|
|
27
|
-
// Bury it: 110 newer succeeded runs after one OLD failure.
|
|
28
|
-
const store = harness.engine.store;
|
|
29
|
-
const failed = store.addRun({ projectId, commitSha: 'a'.repeat(40) });
|
|
30
|
-
store.updateRun(failed.runId, { state: 'failed', phase: 'failed', finishedAt: new Date().toISOString(), error: { code: 'MODEL_FAILED', message: '旧异常:超过最近事件窗口仍然必须可见。', retryable: true } });
|
|
31
|
-
// The old failure is manual attention: it never got a recovery plan.
|
|
32
|
-
for (let index = 0; index < 110; index += 1) {
|
|
33
|
-
const run = store.addRun({ projectId, commitSha: String(index + 1).padStart(4, '0').replace(/\d/g, d => 'abcdef'[Number(d) % 6]).padEnd(40, 'b') });
|
|
34
|
-
store.updateRun(run.runId, { state: 'succeeded', phase: 'ready', indexState: 'succeeded', promotedAt: new Date().toISOString(), finishedAt: new Date().toISOString() });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const overview = await harness.productApi('GET', '/api/engine/overview');
|
|
38
|
-
assert.equal(overview.status, 200, `the overview must be readable: ${JSON.stringify(overview.body)}`);
|
|
39
|
-
const payload = overview.body;
|
|
40
|
-
assert.ok(payload.needsTotal >= 1, 'the old failure still counts as a need');
|
|
41
|
-
assert.ok(payload.needsPreview.some(item => item.kind === 'run' && item.runId === failed.runId),
|
|
42
|
-
'the old failure itself is in the preview, not just the counter');
|
|
43
|
-
assert.equal(payload.totals.recovering, 0, 'runs without a recovery plan are not auto-recovering');
|
|
44
|
-
|
|
45
|
-
// A recovering run appears separately and never as a manual need.
|
|
46
|
-
const recovering = store.addRun({ projectId, commitSha: 'c'.repeat(40) });
|
|
47
|
-
store.updateRun(recovering.runId, { state: 'index-pending', phase: 'index-pending', indexState: 'failed', promotedAt: new Date().toISOString(), finishedAt: new Date().toISOString(), error: { code: 'INDEX_FAILED', message: '索引待修复。', retryable: true, details: { failureKind: 'NETWORK_ERROR' } } });
|
|
48
|
-
harness.engine.coordinator.retryScheduler.onFailure(recovering.runId, { code: 'INDEX_FAILED', details: { failureKind: 'NETWORK_ERROR' } });
|
|
49
|
-
const second = await harness.productApi('GET', '/api/engine/overview');
|
|
50
|
-
assert.equal(second.body.totals.recovering, 1, 'the transient failure is auto-recovering');
|
|
51
|
-
assert.ok(!second.body.needsPreview.some(item => item.runId === recovering.runId), 'an auto-recovering task is not a manual need');
|
|
52
|
-
|
|
53
|
-
// Read failure is NOT rendered as "zero todos": the product keeps the
|
|
54
|
-
// last good overview and surfaces the error instead.
|
|
55
|
-
const broken = await harness.productApi('GET', '/api/engine/overview?probe=1').catch(() => null);
|
|
56
|
-
assert.ok(broken === null || broken.status === 200 || broken.status >= 400, 'error states stay distinguishable from empty states');
|
|
57
|
-
|
|
58
|
-
console.log('home-overview-test: PASS');
|
|
59
|
-
} finally {
|
|
60
|
-
await harness.cleanup();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
main().catch(error => { console.error(error); process.exitCode = 1; });
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// Run: node _site/_test/hook-relocation-rebind-test.js
|
|
2
|
-
// 数据目录迁移后的受管 Hook 重绑定:legacy 启动路径上,「已迁移」标记不再跳过
|
|
3
|
-
// 路径核对——Hook 实体必须绑定当前实例(--data-dir / --bridge-home / 触发脚本),
|
|
4
|
-
// 过期绑定被受控重写;已是当前的绑定不写文件;第三方或他人 Hook 报冲突并保留。
|
|
5
|
-
|
|
6
|
-
const assert = require('assert');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const os = require('os');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const { spawnSync } = require('child_process');
|
|
11
|
-
const { migrateManagedHooks } = require('../lib/server-app');
|
|
12
|
-
const hookManager = require('../lib/hook-manager');
|
|
13
|
-
|
|
14
|
-
const ROOT = path.resolve(__dirname, '..', '..');
|
|
15
|
-
const TEMP = fs.mkdtempSync(path.join(os.tmpdir(), 'pk-hook-reloc-'));
|
|
16
|
-
const repo = path.join(TEMP, '代码 仓库');
|
|
17
|
-
const TRIGGER = path.join(ROOT, '_site', 'scripts', 'hook-trigger.js');
|
|
18
|
-
|
|
19
|
-
function git(args) {
|
|
20
|
-
const result = spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8', windowsHide: true, env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
|
|
21
|
-
if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(' ')} failed`);
|
|
22
|
-
return String(result.stdout || '').trim();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function makeRuntime(dataDir, analysisOwner = 'legacy') {
|
|
26
|
-
// Minimal runtime surface used by migrateManagedHooks.
|
|
27
|
-
const projects = new Map();
|
|
28
|
-
const states = new Map();
|
|
29
|
-
return {
|
|
30
|
-
analysisOwner,
|
|
31
|
-
registryStore: { listIds: () => [...projects.keys()] },
|
|
32
|
-
projectStore: {
|
|
33
|
-
readConfig: id => projects.get(id),
|
|
34
|
-
readState: id => states.get(id) || { hook: { migrationVersion: 0 } },
|
|
35
|
-
updateState: async (id, mutate) => {
|
|
36
|
-
const state = states.get(id) || { hook: { migrationVersion: 0 } };
|
|
37
|
-
mutate(state);
|
|
38
|
-
states.set(id, state);
|
|
39
|
-
},
|
|
40
|
-
register(id, config) { projects.set(id, config); },
|
|
41
|
-
states,
|
|
42
|
-
},
|
|
43
|
-
bridgeAdapter: {
|
|
44
|
-
hookBinding: () => ({ dataDir, bridgeHomeDir: path.join(dataDir, 'events'), bridgeModulePath: undefined }),
|
|
45
|
-
},
|
|
46
|
-
logger: { warn: async () => {}, info: async () => {} },
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function hookText() {
|
|
51
|
-
const hookPath = hookManager.readHookStatus({ repoPath: repo }).hookPath;
|
|
52
|
-
return fs.readFileSync(hookPath, 'utf8');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
(async () => {
|
|
56
|
-
fs.mkdirSync(repo, { recursive: true });
|
|
57
|
-
git(['init', '-q', '-b', 'main']);
|
|
58
|
-
git(['config', 'user.email', 'hook-reloc@example.local']);
|
|
59
|
-
git(['config', 'user.name', 'Hook Reloc Test']);
|
|
60
|
-
fs.writeFileSync(path.join(repo, 'README.md'), '# hook reloc\n');
|
|
61
|
-
git(['add', '.']);
|
|
62
|
-
git(['commit', '-q', '-m', 'initial']);
|
|
63
|
-
const projectId = 'project-hook-reloc';
|
|
64
|
-
|
|
65
|
-
// An older installation under data directory A already recorded migration v2.
|
|
66
|
-
const dataA = path.join(TEMP, '数据 A');
|
|
67
|
-
const dataB = path.join(TEMP, '数据 B');
|
|
68
|
-
hookManager.installHook({ repoPath: repo, projectId, triggerScriptPath: TRIGGER, dataDir: dataA, bridgeHomeDir: path.join(dataA, 'events') });
|
|
69
|
-
assert.ok(hookText().includes('数据 A'), 'the stale hook carries the old data directory');
|
|
70
|
-
|
|
71
|
-
const runtimeA = makeRuntime(dataA);
|
|
72
|
-
runtimeA.projectStore.register(projectId, { repoPath: repo });
|
|
73
|
-
runtimeA.projectStore.states.set(projectId, { hook: { migrationVersion: 2 } });
|
|
74
|
-
|
|
75
|
-
// Relocation: the current instance runs from directory B.
|
|
76
|
-
const runtimeB = makeRuntime(dataB);
|
|
77
|
-
runtimeB.projectStore.register(projectId, { repoPath: repo });
|
|
78
|
-
runtimeB.projectStore.states.set(projectId, { hook: { migrationVersion: 2 } });
|
|
79
|
-
const rebound = await migrateManagedHooks(runtimeB);
|
|
80
|
-
assert.strictEqual(rebound[0].ok, true, JSON.stringify(rebound[0]));
|
|
81
|
-
assert.strictEqual(rebound[0].reason, 'rebound-to-current-instance');
|
|
82
|
-
const afterRebind = hookText();
|
|
83
|
-
assert.ok(afterRebind.includes('数据 B'), 'the hook now binds the current data directory');
|
|
84
|
-
assert.ok(!afterRebind.includes('数据 A'), 'the stale binding is gone');
|
|
85
|
-
|
|
86
|
-
// A second pass with the same instance must be a no-op (no rewrite).
|
|
87
|
-
const again = await migrateManagedHooks(runtimeB);
|
|
88
|
-
assert.strictEqual(again[0].ok, true);
|
|
89
|
-
assert.strictEqual(again[0].reason, 'already-migrated');
|
|
90
|
-
assert.strictEqual(again[0].updated, false, 'an already-current binding is not rewritten');
|
|
91
|
-
assert.strictEqual(hookText(), afterRebind, 'the hook file is byte-identical');
|
|
92
|
-
|
|
93
|
-
// A third-party hook is reported as a conflict and preserved verbatim.
|
|
94
|
-
const hookPath = hookManager.readHookStatus({ repoPath: repo }).hookPath;
|
|
95
|
-
const thirdParty = '#!/bin/sh\necho third-party-marker\nexit 0\n';
|
|
96
|
-
fs.writeFileSync(hookPath, thirdParty);
|
|
97
|
-
const conflicted = await migrateManagedHooks(runtimeB);
|
|
98
|
-
assert.strictEqual(conflicted[0].ok, false);
|
|
99
|
-
assert.strictEqual(conflicted[0].status, 'conflict');
|
|
100
|
-
assert.strictEqual(fs.readFileSync(hookPath, 'utf8'), thirdParty, 'the third-party hook is preserved');
|
|
101
|
-
const conflictState = runtimeB.projectStore.states.get(projectId);
|
|
102
|
-
assert.strictEqual(conflictState.hook.lastConflict.code, 'HOOK_CONFLICT');
|
|
103
|
-
|
|
104
|
-
// A managed hook bound to ANOTHER project is likewise preserved (both the
|
|
105
|
-
// marker line and the command line identify the owner).
|
|
106
|
-
fs.writeFileSync(hookPath, afterRebind
|
|
107
|
-
.replace(`--project-id '${projectId}'`, `--project-id 'project-other'`)
|
|
108
|
-
.replace(`"projectId":"${projectId}"`, `"projectId":"project-other"`));
|
|
109
|
-
const wrongProject = await migrateManagedHooks(runtimeB);
|
|
110
|
-
assert.strictEqual(wrongProject[0].ok, false);
|
|
111
|
-
assert.strictEqual(wrongProject[0].status, 'conflict');
|
|
112
|
-
assert.ok(fs.readFileSync(hookPath, 'utf8').includes("project-other"), 'the other project\'s hook is preserved');
|
|
113
|
-
|
|
114
|
-
console.log('hook-relocation-rebind-test PASS');
|
|
115
|
-
})().catch(error => {
|
|
116
|
-
console.error(error.stack || error.message);
|
|
117
|
-
process.exitCode = 1;
|
|
118
|
-
}).finally(() => {
|
|
119
|
-
fs.rmSync(TEMP, { recursive: true, force: true });
|
|
120
|
-
});
|