@sanqianx/project-knowledge 5.0.24 → 5.0.25
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 +66 -63
- 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,131 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { StorageLayout } = require('../../lib/storage-layout');
|
|
5
|
+
const { SettingsStore } = require('../../lib/settings-store');
|
|
6
|
+
const { ProjectRegistryStore } = require('../../lib/project-registry-store');
|
|
7
|
+
const { ProjectStore } = require('../../lib/project-store');
|
|
8
|
+
const { Logger } = require('../../lib/structured-logger');
|
|
9
|
+
const { makeRepo } = require('../fixtures/make-git-repos');
|
|
10
|
+
|
|
11
|
+
async function createLoggingUiFixture(options = {}) {
|
|
12
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "pk-logging-ui-" + process.pid + "-"));
|
|
13
|
+
if (options.freshProduct) require('../../lib/product-data').initializeProductData(dataDir);
|
|
14
|
+
const knowledgeRoot = path.join(dataDir, "knowledge-root");
|
|
15
|
+
fs.mkdirSync(knowledgeRoot, { recursive: true });
|
|
16
|
+
const repo = makeRepo({ kind: "one-commit" });
|
|
17
|
+
const layout = new StorageLayout({ dataDir });
|
|
18
|
+
const settingsStore = new SettingsStore({ layout });
|
|
19
|
+
const registryStore = new ProjectRegistryStore({ layout });
|
|
20
|
+
const projectStore = new ProjectStore({ layout });
|
|
21
|
+
const projectId = "visual-project";
|
|
22
|
+
const knowledgePath = path.join(knowledgeRoot, projectId);
|
|
23
|
+
fs.mkdirSync(knowledgePath, { recursive: true });
|
|
24
|
+
|
|
25
|
+
await settingsStore.initialize({
|
|
26
|
+
knowledge: { rootPath: knowledgeRoot },
|
|
27
|
+
logging: {
|
|
28
|
+
levels: ["trace", "debug", "info", "warn", "error", "fatal"],
|
|
29
|
+
retentionDays: 365,
|
|
30
|
+
maxTotalSizeMB: 2048,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
await registryStore.initialize();
|
|
34
|
+
await projectStore.create(projectId, {
|
|
35
|
+
displayName: "视觉检测知识库",
|
|
36
|
+
storageName: projectId,
|
|
37
|
+
repoPath: repo.path,
|
|
38
|
+
knowledgePath,
|
|
39
|
+
}, {
|
|
40
|
+
trackingStartCommit: repo.headCommit,
|
|
41
|
+
lastAnalyzedCommit: repo.headCommit,
|
|
42
|
+
hook: { managedVersion: 2, migrationVersion: 2, lastVerifiedAt: new Date().toISOString() },
|
|
43
|
+
index: { dirty: false, generation: 7 },
|
|
44
|
+
});
|
|
45
|
+
await registryStore.add(projectId, { displayName: "视觉检测知识库" });
|
|
46
|
+
|
|
47
|
+
const logger = new Logger({
|
|
48
|
+
layout,
|
|
49
|
+
settingsProvider: () => settingsStore.read().logging,
|
|
50
|
+
});
|
|
51
|
+
const total = Number(options.totalLogs || 64);
|
|
52
|
+
const levels = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
53
|
+
for (let index = 0; index < total; index += 1) {
|
|
54
|
+
const level = levels[index % levels.length];
|
|
55
|
+
const operationId = index < 4 ? "op-flow-visual" : "op-" + String(index).padStart(3, "0");
|
|
56
|
+
const input = {
|
|
57
|
+
component: index % 2 ? "commit-reconciler" : "knowledge-promotion",
|
|
58
|
+
projectId: index === 7 ? "deleted-project" : projectId,
|
|
59
|
+
projectDisplayName: index === 7 ? "已删除的旧项目" : "视觉检测知识库",
|
|
60
|
+
projectDeleted: index === 7,
|
|
61
|
+
operationId,
|
|
62
|
+
runId: "run-" + Math.floor(index / 4),
|
|
63
|
+
commitSha: repo.headCommit,
|
|
64
|
+
phase: ["scanning", "claim.created", "markdown.promoted", "index.applied"][index % 4],
|
|
65
|
+
attempt: index % 3,
|
|
66
|
+
durationMs: 17 + index * 13,
|
|
67
|
+
context: {
|
|
68
|
+
repoPath: index === 6 ? "C:\\Users\\Example User\\Documents\\very-long-workspace\\机器视觉项目\\source" : repo.path,
|
|
69
|
+
fixture: index === 5 ? "<img src=x onerror=window.__xss=1>" : "safe",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
if (index === 3) {
|
|
73
|
+
const validationError = Object.assign(new Error("模型输出校验失败 <script>window.__xss=1</script>"), { code: "VALIDATION_FAILED" });
|
|
74
|
+
validationError.stack += "\n" + Array.from({ length: 24 }, (_, line) => " at promotionStep" + line + " (C:\\Users\\Example User\\Documents\\very-long-workspace\\机器视觉项目\\promotion.js:" + (line + 10) + ":7)").join("\n");
|
|
75
|
+
input.error = validationError;
|
|
76
|
+
}
|
|
77
|
+
await logger.log(level, "fixture.phase." + index, index === 5 ? "<img src=x onerror=window.__xss=1>" : "诊断事件 " + index, input);
|
|
78
|
+
}
|
|
79
|
+
await logger.close();
|
|
80
|
+
|
|
81
|
+
if (Number(options.conversationTurns || 0) > 0) {
|
|
82
|
+
const { ConversationStore } = require('../../lib/conversation-store');
|
|
83
|
+
const conversationStore = new ConversationStore({ layout, projectStore });
|
|
84
|
+
const turnCount = Number(options.conversationTurns);
|
|
85
|
+
const repoIdentity = { repoId: 'visual-project-repo' };
|
|
86
|
+
const baseTime = new Date();
|
|
87
|
+
baseTime.setHours(9, 0, 0, 0);
|
|
88
|
+
const captured = [];
|
|
89
|
+
for (let index = 0; index < turnCount; index += 1) {
|
|
90
|
+
const turnId = `visual-turn-${index + 1}`;
|
|
91
|
+
const promptAt = new Date(baseTime.getTime() + index * 120000).toISOString();
|
|
92
|
+
const replyAt = new Date(baseTime.getTime() + index * 120000 + 30000).toISOString();
|
|
93
|
+
const longToken = index === 1 ? ` ${'D:\\deep-project\\'.repeat(40)}README.md` : '';
|
|
94
|
+
const prompt = `请检查第 ${index + 1} 个视觉工作流。${longToken}`;
|
|
95
|
+
const reply = `已完成第 ${index + 1} 个工作流的检查。${longToken}`;
|
|
96
|
+
const user = (await conversationStore.appendEvent(projectId, {
|
|
97
|
+
eventId: `visual-user-${index + 1}`, sequence: index * 2 + 1, source: 'codex', eventType: 'user_prompt', role: 'user', content: prompt,
|
|
98
|
+
sessionId: 'visual-session', turnId, repoIdentity, projectPath: repo.path, branch: 'main', headAtCapture: repo.headCommit,
|
|
99
|
+
capturedAt: promptAt, identityConfidence: 'high', captureStatus: 'captured',
|
|
100
|
+
})).event;
|
|
101
|
+
const assistant = (await conversationStore.appendEvent(projectId, {
|
|
102
|
+
eventId: `visual-assistant-${index + 1}`, sequence: index * 2 + 2, source: 'codex', eventType: 'assistant_response', role: 'assistant', content: reply,
|
|
103
|
+
sessionId: 'visual-session', turnId, repoIdentity, projectPath: repo.path, branch: 'main', headAtCapture: repo.headCommit,
|
|
104
|
+
capturedAt: replyAt, identityConfidence: 'high', captureStatus: 'captured',
|
|
105
|
+
})).event;
|
|
106
|
+
captured.push({ turnId, user, assistant });
|
|
107
|
+
}
|
|
108
|
+
const projectEvent = event => ({ eventId: event.eventId, sequence: event.sequence, content: event.content, contentHash: event.contentHash, capturedAt: event.capturedAt });
|
|
109
|
+
if (captured[0]) conversationStore.writeSnapshot(projectId, {
|
|
110
|
+
commitSha: '1'.repeat(40), repoIdentity, parentSha: null, boundaryStartCursor: 0, boundaryEndCursor: 2, status: 'available',
|
|
111
|
+
turns: [{ turnId: captured[0].turnId, source: 'codex', sessionId: 'visual-session', bindingKind: 'direct', userEvents: [projectEvent(captured[0].user)], assistantEvents: [projectEvent(captured[0].assistant)] }],
|
|
112
|
+
});
|
|
113
|
+
if (captured[1]) conversationStore.writeSnapshot(projectId, {
|
|
114
|
+
commitSha: '2'.repeat(40), repoIdentity, parentSha: '1'.repeat(40), boundaryStartCursor: 2, boundaryEndCursor: 4, status: 'available',
|
|
115
|
+
turns: [{ turnId: captured[1].turnId, source: 'codex', sessionId: 'visual-session', bindingKind: 'shared-spanning', userEvents: [projectEvent(captured[1].user)], assistantEvents: [projectEvent(captured[1].assistant)] }],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
dataDir,
|
|
121
|
+
layout,
|
|
122
|
+
projectId,
|
|
123
|
+
repo,
|
|
124
|
+
cleanup() {
|
|
125
|
+
try { repo.cleanup(); } catch {}
|
|
126
|
+
try { fs.rmSync(dataDir, { recursive: true, force: true }); } catch {}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { createLoggingUiFixture };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// _site/_test/helpers/module-fixture.js
|
|
2
|
+
//
|
|
3
|
+
// Test-only services for the product's module boundary.
|
|
4
|
+
//
|
|
5
|
+
// Three kinds of helper live here, and each one is a real HTTP service the
|
|
6
|
+
// product talks to over the network:
|
|
7
|
+
//
|
|
8
|
+
// createModuleFixture a standalone module service (terminal / vector-hub
|
|
9
|
+
// / event-bridge) that keeps the registration state
|
|
10
|
+
// the product writes into it, can be switched offline
|
|
11
|
+
// (503) and records every request it receives.
|
|
12
|
+
//
|
|
13
|
+
// createUpstreamProxy a pass-through proxy in front of a real upstream
|
|
14
|
+
// (the vendored knowledge-engine module). It can hold
|
|
15
|
+
// the upstream offline with 503, and it can rewrite
|
|
16
|
+
// the runtime Authorization header so the product's
|
|
17
|
+
// own per-instance token reaches an engine that was
|
|
18
|
+
// started outside the product supervisor. Bodies and
|
|
19
|
+
// responses are forwarded verbatim.
|
|
20
|
+
//
|
|
21
|
+
// createProductProxy a pass-through proxy in front of the product
|
|
22
|
+
// server. It injects transport faults: a held
|
|
23
|
+
// response (late read) or a failed response.
|
|
24
|
+
//
|
|
25
|
+
// The proxies never fabricate a module answer: everything they return comes
|
|
26
|
+
// from the upstream service they front.
|
|
27
|
+
|
|
28
|
+
'use strict';
|
|
29
|
+
|
|
30
|
+
const http = require('node:http');
|
|
31
|
+
|
|
32
|
+
function readBody(req) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const chunks = [];
|
|
35
|
+
req.on('data', chunk => chunks.push(chunk));
|
|
36
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
37
|
+
req.on('error', reject);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function sendJson(res, status, payload) {
|
|
42
|
+
const body = JSON.stringify(payload);
|
|
43
|
+
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': Buffer.byteLength(body) });
|
|
44
|
+
res.end(body);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function listen(server) {
|
|
48
|
+
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
|
49
|
+
return `http://127.0.0.1:${server.address().port}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A standalone module service. `kind` selects the contract subset the
|
|
54
|
+
* product's module bridge uses for that module.
|
|
55
|
+
*/
|
|
56
|
+
function createModuleFixture({ kind, tag = kind }) {
|
|
57
|
+
const state = { online: true, projects: [], requests: [] };
|
|
58
|
+
let nextId = 1;
|
|
59
|
+
|
|
60
|
+
const server = http.createServer(async (req, res) => {
|
|
61
|
+
const url = new URL(req.url, 'http://127.0.0.1');
|
|
62
|
+
const raw = await readBody(req);
|
|
63
|
+
let body = null;
|
|
64
|
+
if (raw.length) { try { body = JSON.parse(raw.toString('utf8')); } catch { body = null; } }
|
|
65
|
+
state.requests.push({ method: req.method, path: url.pathname + url.search, body, at: Date.now() });
|
|
66
|
+
if (!state.online) {
|
|
67
|
+
sendJson(res, 503, { ok: false, error: { code: 'MODULE_OFFLINE', message: `验收中的离线 ${kind} 模块` } });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (kind === 'terminal') {
|
|
71
|
+
if (req.method === 'GET' && url.pathname === '/api/claude-workbench/v1/projects') {
|
|
72
|
+
sendJson(res, 200, { projects: state.projects });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (req.method === 'POST' && url.pathname === '/api/claude-workbench/v1/projects') {
|
|
76
|
+
const id = `terminal-${nextId++}`;
|
|
77
|
+
state.projects.push({ id, name: body?.name || id, rootPath: body?.rootPath || '' });
|
|
78
|
+
sendJson(res, 201, { id, name: body?.name || id, rootPath: body?.rootPath || '' });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (req.method === 'DELETE' && url.pathname.startsWith('/api/claude-workbench/v1/projects/')) {
|
|
82
|
+
const id = decodeURIComponent(url.pathname.split('/').pop());
|
|
83
|
+
state.projects = state.projects.filter(project => project.id !== id);
|
|
84
|
+
res.writeHead(204); res.end();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (kind === 'vectorHub') {
|
|
89
|
+
if (req.method === 'GET' && url.pathname === '/api/projects') { sendJson(res, 200, { projects: state.projects }); return; }
|
|
90
|
+
if (req.method === 'POST' && url.pathname === '/api/import') {
|
|
91
|
+
state.projects.push({ name: body?.projectName || '', sourceDir: body?.sourceDir || '', hasIndex: true });
|
|
92
|
+
sendJson(res, 200, { ok: true, project: body?.projectName || '' });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (req.method === 'DELETE' && url.pathname === '/api/project') {
|
|
96
|
+
const name = url.searchParams.get('name');
|
|
97
|
+
state.projects = state.projects.filter(project => project.name !== name);
|
|
98
|
+
sendJson(res, 200, { ok: true });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (kind === 'eventBridge') {
|
|
103
|
+
if (req.method === 'GET' && url.pathname === '/api/projects') { sendJson(res, 200, { projects: state.projects }); return; }
|
|
104
|
+
if (req.method === 'POST' && url.pathname === '/api/projects') {
|
|
105
|
+
const id = `bridge-${nextId++}`;
|
|
106
|
+
state.projects.push({ id, path: body?.path || '', auto: false, store: body?.store || '' });
|
|
107
|
+
sendJson(res, 201, { project: { id, path: body?.path || '' } });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (req.method === 'DELETE' && url.pathname === '/api/projects') {
|
|
111
|
+
const id = url.searchParams.get('id');
|
|
112
|
+
state.projects = state.projects.filter(project => project.id !== id);
|
|
113
|
+
sendJson(res, 200, { ok: true });
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sendJson(res, 404, { ok: false, error: { code: 'NOT_FOUND', message: '未实现的模块接口' } });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
kind,
|
|
122
|
+
tag,
|
|
123
|
+
state,
|
|
124
|
+
url: null,
|
|
125
|
+
requests: state.requests,
|
|
126
|
+
async start() { this.url = await listen(server); return this.url; },
|
|
127
|
+
setOnline(online) { state.online = online; },
|
|
128
|
+
countRequests(method, pathPrefix) {
|
|
129
|
+
return state.requests.filter(entry => entry.method === method && (!pathPrefix || entry.path.startsWith(pathPrefix))).length;
|
|
130
|
+
},
|
|
131
|
+
async close() { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Pass-through proxy in front of a real upstream service.
|
|
137
|
+
*
|
|
138
|
+
* - `offline` short-circuits every request with 503 (the upstream is never
|
|
139
|
+
* contacted), which is how the product observes an offline module.
|
|
140
|
+
* - `token` rewrites the Authorization header so the product's per-instance
|
|
141
|
+
* runtime token is replaced by the token the upstream was started with.
|
|
142
|
+
*
|
|
143
|
+
* The proxy streams both directions, so a server-sent event stream that the
|
|
144
|
+
* browser opens against the product stays a real event stream.
|
|
145
|
+
*/
|
|
146
|
+
function createUpstreamProxy({ target, token, offline = false, tag = 'upstream' }) {
|
|
147
|
+
const state = { online: !offline, requests: [] };
|
|
148
|
+
const upstream = new URL(target);
|
|
149
|
+
|
|
150
|
+
const server = http.createServer(async (req, res) => {
|
|
151
|
+
const url = new URL(req.url, 'http://127.0.0.1');
|
|
152
|
+
const raw = await readBody(req);
|
|
153
|
+
let body = null;
|
|
154
|
+
if (raw.length) { try { body = JSON.parse(raw.toString('utf8')); } catch { body = null; } }
|
|
155
|
+
const entry = { method: req.method, path: url.pathname + url.search, body, at: Date.now(), status: null };
|
|
156
|
+
state.requests.push(entry);
|
|
157
|
+
if (!state.online) {
|
|
158
|
+
entry.status = 503;
|
|
159
|
+
sendJson(res, 503, { ok: false, error: { code: 'MODULE_OFFLINE', message: `验收中的离线 ${tag} 模块` } });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const headers = { 'Content-Type': req.headers['content-type'] || 'application/json', 'Content-Length': String(raw.length) };
|
|
163
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
164
|
+
else if (req.headers.authorization) headers.Authorization = req.headers.authorization;
|
|
165
|
+
const upstreamRequest = http.request({
|
|
166
|
+
hostname: upstream.hostname,
|
|
167
|
+
port: upstream.port,
|
|
168
|
+
path: url.pathname + url.search,
|
|
169
|
+
method: req.method,
|
|
170
|
+
headers,
|
|
171
|
+
}, upstreamResponse => {
|
|
172
|
+
entry.status = upstreamResponse.statusCode;
|
|
173
|
+
res.writeHead(upstreamResponse.statusCode, upstreamResponse.headers);
|
|
174
|
+
upstreamResponse.pipe(res);
|
|
175
|
+
});
|
|
176
|
+
upstreamRequest.on('error', error => {
|
|
177
|
+
entry.status = 502;
|
|
178
|
+
if (!res.headersSent) sendJson(res, 502, { ok: false, error: { code: 'UPSTREAM_UNREACHABLE', message: String(error.message || error) } });
|
|
179
|
+
else res.destroy();
|
|
180
|
+
});
|
|
181
|
+
if (raw.length) upstreamRequest.write(raw);
|
|
182
|
+
upstreamRequest.end();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
tag,
|
|
187
|
+
state,
|
|
188
|
+
requests: state.requests,
|
|
189
|
+
url: null,
|
|
190
|
+
setOnline(online) { state.online = online; },
|
|
191
|
+
countRequests(method, pathPrefix) {
|
|
192
|
+
return state.requests.filter(entry => entry.method === method && (!pathPrefix || entry.path.startsWith(pathPrefix))).length;
|
|
193
|
+
},
|
|
194
|
+
async start() { this.url = await listen(server); return this.url; },
|
|
195
|
+
async close() { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); },
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Pass-through proxy in front of the product server that injects transport
|
|
201
|
+
* faults. `hold` keeps a matching response pending (a late read); `fail`
|
|
202
|
+
* answers a matching request with a transport error (a failed refresh).
|
|
203
|
+
*/
|
|
204
|
+
function createProductProxy({ target, tag = 'product' }) {
|
|
205
|
+
const state = { requests: [], held: [], faults: [] };
|
|
206
|
+
const upstream = new URL(target);
|
|
207
|
+
|
|
208
|
+
const server = http.createServer(async (req, res) => {
|
|
209
|
+
const url = new URL(req.url, 'http://127.0.0.1');
|
|
210
|
+
const raw = await readBody(req);
|
|
211
|
+
let body = null;
|
|
212
|
+
if (raw.length) { try { body = JSON.parse(raw.toString('utf8')); } catch { body = null; } }
|
|
213
|
+
const entry = { method: req.method, path: url.pathname + url.search, body, at: Date.now(), status: null };
|
|
214
|
+
state.requests.push(entry);
|
|
215
|
+
|
|
216
|
+
const fault = state.faults.find(item => !item.used && item.match(entry));
|
|
217
|
+
if (fault && fault.once) fault.used = true;
|
|
218
|
+
if (fault && fault.kind === 'fail') {
|
|
219
|
+
entry.status = fault.status;
|
|
220
|
+
sendJson(res, fault.status, { ok: false, error: { code: 'TRANSPORT_FAULT', message: fault.message || '注入的传输故障' } });
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const headers = { 'Content-Type': req.headers['content-type'] || 'application/json', 'Content-Length': String(raw.length) };
|
|
225
|
+
if (req.headers.authorization) headers.Authorization = req.headers.authorization;
|
|
226
|
+
const upstreamRequest = http.request({
|
|
227
|
+
hostname: upstream.hostname,
|
|
228
|
+
port: upstream.port,
|
|
229
|
+
path: url.pathname + url.search,
|
|
230
|
+
method: req.method,
|
|
231
|
+
headers,
|
|
232
|
+
}, upstreamResponse => {
|
|
233
|
+
entry.status = upstreamResponse.statusCode;
|
|
234
|
+
entry.respondedAt = Date.now();
|
|
235
|
+
if (fault && fault.kind === 'hold') {
|
|
236
|
+
const chunks = [];
|
|
237
|
+
upstreamResponse.on('data', chunk => chunks.push(chunk));
|
|
238
|
+
upstreamResponse.on('end', () => {
|
|
239
|
+
state.held.push({ response: res, entry, status: upstreamResponse.statusCode, headers: upstreamResponse.headers, payload: Buffer.concat(chunks) });
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
res.writeHead(upstreamResponse.statusCode, upstreamResponse.headers);
|
|
244
|
+
upstreamResponse.pipe(res);
|
|
245
|
+
});
|
|
246
|
+
upstreamRequest.on('error', error => {
|
|
247
|
+
entry.status = 502;
|
|
248
|
+
if (!res.headersSent) sendJson(res, 502, { ok: false, error: { code: 'UPSTREAM_UNREACHABLE', message: String(error.message || error) } });
|
|
249
|
+
else res.destroy();
|
|
250
|
+
});
|
|
251
|
+
if (raw.length) upstreamRequest.write(raw);
|
|
252
|
+
upstreamRequest.end();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
tag,
|
|
257
|
+
state,
|
|
258
|
+
requests: state.requests,
|
|
259
|
+
url: null,
|
|
260
|
+
/** Hold the response of every request that matches the predicate. */
|
|
261
|
+
hold(match, { once = false } = {}) { state.faults.push({ kind: 'hold', match, once }); },
|
|
262
|
+
/** Fail every matching request at the transport level. */
|
|
263
|
+
fail(match, status = 503, message = '注入的传输故障', { once = false } = {}) { state.faults.push({ kind: 'fail', match, status, message, once }); },
|
|
264
|
+
clearFaults() { state.faults = []; },
|
|
265
|
+
heldCount() { return state.held.length; },
|
|
266
|
+
/** Deliver every held response to the browser that is still waiting. */
|
|
267
|
+
releaseHeld() {
|
|
268
|
+
const held = state.held.splice(0);
|
|
269
|
+
for (const item of held) {
|
|
270
|
+
try {
|
|
271
|
+
item.response.writeHead(item.status, item.headers);
|
|
272
|
+
item.response.end(item.payload);
|
|
273
|
+
} catch {}
|
|
274
|
+
}
|
|
275
|
+
return held.length;
|
|
276
|
+
},
|
|
277
|
+
async start() { this.url = await listen(server); return this.url; },
|
|
278
|
+
async close() { state.held.length = 0; server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
module.exports = { createModuleFixture, createUpstreamProxy, createProductProxy };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// P-ENG-ADVANCED engine child wrapper. Runs in its own process with a scrubbed,
|
|
4
|
+
// isolated environment and starts the VENDORED knowledge-engine server module
|
|
5
|
+
// (byte-identical to source e5573bb) in debug mode so the documented debug
|
|
6
|
+
// fault-injection surface (POST /api/runs with simulateFailure) is available.
|
|
7
|
+
// The analyzer is the lane's declarative stand-in - real staged bytes, no real
|
|
8
|
+
// model output. Vendored engine code is never modified.
|
|
9
|
+
|
|
10
|
+
const { createEngineServer } = require('../../../_modules/knowledge-engine/src/server.js');
|
|
11
|
+
const { createStandinAnalyzer } = require('./parallel-engine-advanced-standin-analyzer.js');
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
const dataDir = process.env.ENGADV_DATA_DIR;
|
|
15
|
+
const vectorUrl = process.env.ENGADV_VECTOR_URL || 'http://127.0.0.1:9';
|
|
16
|
+
const planFile = process.env.ENGADV_PLAN_FILE;
|
|
17
|
+
const eventsFile = process.env.ENGADV_EVENTS_FILE;
|
|
18
|
+
const concurrency = process.env.ENGADV_CONCURRENCY ? Number(process.env.ENGADV_CONCURRENCY) : undefined;
|
|
19
|
+
const analyzer = createStandinAnalyzer({ planFile, eventsFile });
|
|
20
|
+
const runtime = createEngineServer({
|
|
21
|
+
dataDir,
|
|
22
|
+
debug: true,
|
|
23
|
+
analyzer,
|
|
24
|
+
vectorUrl,
|
|
25
|
+
consume: false,
|
|
26
|
+
managed: false,
|
|
27
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
28
|
+
});
|
|
29
|
+
await runtime.ready;
|
|
30
|
+
const { server } = runtime;
|
|
31
|
+
const stop = async () => {
|
|
32
|
+
try { await runtime.close(); process.exitCode = 0; } catch { process.exitCode = 1; }
|
|
33
|
+
if (process.connected) process.disconnect();
|
|
34
|
+
};
|
|
35
|
+
for (const signal of ['SIGINT', 'SIGTERM']) process.once(signal, stop);
|
|
36
|
+
process.on('message', message => { if (message?.type === 'kb:shutdown') stop(); });
|
|
37
|
+
server.listen(0, '127.0.0.1', () => {
|
|
38
|
+
process.stdout.write(`ENGADV-READY ${JSON.stringify({ base: `http://127.0.0.1:${server.address().port}`, pid: process.pid })}\n`);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main().catch(error => {
|
|
43
|
+
console.error(`[engadv-child] ${error.code || 'START_FAILED'}: ${error.message}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// P-ENG-ADVANCED ENG-009 fault-point writer/child.
|
|
4
|
+
//
|
|
5
|
+
// Exercises the VENDORED KnowledgePromotionService (byte-identical to source
|
|
6
|
+
// e5573bb) using its production `fault` constructor hook - the class's own
|
|
7
|
+
// sanctioned interruption point - to hard-exit the process at exact promotion
|
|
8
|
+
// phases. A separate process then runs the same vendored service's
|
|
9
|
+
// recoverAll(), which is exactly what EngineCoordinator.initialize() calls on
|
|
10
|
+
// every startup. The analyzer here is the same declarative stand-in (no real
|
|
11
|
+
// model output). The project state container is a real atomic JSON file with
|
|
12
|
+
// the runtime shape the promotion service reads/writes.
|
|
13
|
+
//
|
|
14
|
+
// Usage: node parallel-engine-advanced-fault-writer.js <mode> <workDir>
|
|
15
|
+
// mode crash-prepared - exit hard at fault point journal-prepared
|
|
16
|
+
// mode crash-mid-apply - exit hard at fault point operation-applied:0
|
|
17
|
+
// mode crash-after-apply - exit hard at fault point promotion-verified
|
|
18
|
+
// (journal already persisted as awaiting-state-advance)
|
|
19
|
+
// mode recover - run recoverAll() and report recovery + final state
|
|
20
|
+
// mode complete - control: full processClaim without injected crash
|
|
21
|
+
|
|
22
|
+
const fs = require('node:fs');
|
|
23
|
+
const path = require('node:path');
|
|
24
|
+
const crypto = require('node:crypto');
|
|
25
|
+
const { RuntimeLayout } = require('../../../_modules/knowledge-engine/src/runtime/layout.js');
|
|
26
|
+
const { KnowledgePromotionService } = require('../../../_modules/knowledge-engine/src/runtime/knowledge-promotion.js');
|
|
27
|
+
const AtomicFile = require('../../../_modules/knowledge-engine/src/runtime/atomic-file.js');
|
|
28
|
+
|
|
29
|
+
const PROJECT_ID = 'project-eng009-fault';
|
|
30
|
+
const COMMIT_SHA = 'a'.repeat(40); // fixture identity; not a real repo commit - promotion only needs claim identity + hashes
|
|
31
|
+
const RUN_ID = 'run-11111111-2222-3333-4444-555555555555';
|
|
32
|
+
const FINGERPRINT = `sha256:${'f'.repeat(64)}`;
|
|
33
|
+
|
|
34
|
+
function hashBuffer(value) {
|
|
35
|
+
return `sha256:${crypto.createHash('sha256').update(value).digest('hex')}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function workPaths(workDir) {
|
|
39
|
+
return {
|
|
40
|
+
dataDir: path.join(workDir, 'engine-data'),
|
|
41
|
+
knowledgePath: path.join(workDir, 'knowledge'),
|
|
42
|
+
stateFile: path.join(workDir, 'project-state.json'),
|
|
43
|
+
output: path.join(workDir, 'fault-result.json'),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function initialState() {
|
|
48
|
+
return {
|
|
49
|
+
lastAnalyzedCommit: null,
|
|
50
|
+
analysis: { status: 'idle', activeClaim: {
|
|
51
|
+
schema: 'commit-claim/v1', projectId: PROJECT_ID, commitSha: COMMIT_SHA, runId: RUN_ID,
|
|
52
|
+
fingerprint: FINGERPRINT, patchHash: `sha256:${'p'.repeat(64)}`, promptHash: `sha256:${'q'.repeat(64)}`,
|
|
53
|
+
evidenceHash: `sha256:${'e'.repeat(64)}`, evidenceManifestHash: `sha256:${'m'.repeat(64)}`,
|
|
54
|
+
retrievalManifestHash: `sha256:${'r'.repeat(64)}`, knowledgePath: null, phase: 'evidence.prepared', attempt: 1,
|
|
55
|
+
}, lastError: null },
|
|
56
|
+
index: { generation: 0, dirty: false, status: 'pending', sinceCommit: null, lastError: null },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function makeProjectStore(stateFile, knowledgePath) {
|
|
61
|
+
const read = () => AtomicFile.readJsonStrict(stateFile, { category: 'engadv-project-state', allowMissing: true, defaultValue: initialState() });
|
|
62
|
+
return {
|
|
63
|
+
readConfig: () => ({ projectId: PROJECT_ID, knowledgePath, repoPath: null, displayName: 'eng009-fault' }),
|
|
64
|
+
readState: () => read(),
|
|
65
|
+
updateState: async (id, fn) => {
|
|
66
|
+
const draft = read();
|
|
67
|
+
fn(draft);
|
|
68
|
+
AtomicFile.writeJsonAtomic(stateFile, draft);
|
|
69
|
+
return draft;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function standinAnalyzer({ knowledgePath }) {
|
|
75
|
+
return {
|
|
76
|
+
sourceReadMode: 'isolated-frozen-evidence',
|
|
77
|
+
async runClaim(input) {
|
|
78
|
+
const newReadme = `# eng009 fixture knowledge (replaced)\n\nPromoted for run ${input.claim.runId}.\n`;
|
|
79
|
+
const changeRel = `changes/${input.claim.runId.slice(4, 16)}.md`;
|
|
80
|
+
const changeContent = `# Change record eng009\n\nCommit ${input.claim.commitSha} via stand-in analyzer (no real model output).\n`;
|
|
81
|
+
AtomicFile.writeFileAtomic(path.join(input.stagingPath, 'files', 'README.md'), newReadme);
|
|
82
|
+
AtomicFile.writeFileAtomic(path.join(input.stagingPath, 'files', ...changeRel.split('/')), changeContent);
|
|
83
|
+
const refs = [
|
|
84
|
+
`commit:${input.claim.commitSha}`,
|
|
85
|
+
`patch:${input.claim.patchHash}`,
|
|
86
|
+
`conversation:${input.claim.conversationSnapshotHash}`,
|
|
87
|
+
`retrieval:${input.claim.retrievalManifestHash}`,
|
|
88
|
+
];
|
|
89
|
+
AtomicFile.writeJsonAtomic(input.manifestPath, {
|
|
90
|
+
schema: 'knowledge-staging-manifest/v1',
|
|
91
|
+
projectId: input.projectId,
|
|
92
|
+
runId: input.claim.runId,
|
|
93
|
+
commitSha: input.claim.commitSha,
|
|
94
|
+
operations: [
|
|
95
|
+
{ path: 'README.md', operation: 'replace', sha256: hashBuffer(newReadme), reason: 'Fixture replace for crash injection', evidenceReferences: refs },
|
|
96
|
+
{ path: changeRel, operation: 'create', sha256: hashBuffer(changeContent), reason: 'Fixture create for crash injection', evidenceReferences: refs },
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
return { ok: true };
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function main() {
|
|
105
|
+
const mode = process.argv[2];
|
|
106
|
+
const workDir = process.argv[3];
|
|
107
|
+
if (!mode || !workDir) throw new Error('usage: fault-writer <mode> <workDir>');
|
|
108
|
+
const { dataDir, knowledgePath, stateFile, output } = workPaths(workDir);
|
|
109
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
110
|
+
fs.mkdirSync(knowledgePath, { recursive: true });
|
|
111
|
+
if (!fs.existsSync(stateFile)) AtomicFile.writeJsonAtomic(stateFile, initialState());
|
|
112
|
+
if (!fs.existsSync(path.join(knowledgePath, 'README.md'))) {
|
|
113
|
+
AtomicFile.writeFileAtomic(path.join(knowledgePath, 'README.md'), '# eng009 fixture knowledge (original)\n\nPre-crash content.\n');
|
|
114
|
+
}
|
|
115
|
+
const layout = new RuntimeLayout(dataDir);
|
|
116
|
+
const projectStore = makeProjectStore(stateFile, knowledgePath);
|
|
117
|
+
const claim = {
|
|
118
|
+
schema: 'commit-claim/v1', projectId: PROJECT_ID, commitSha: COMMIT_SHA, runId: RUN_ID, fingerprint: FINGERPRINT,
|
|
119
|
+
patchHash: `sha256:${'p'.repeat(64)}`, promptHash: `sha256:${'q'.repeat(64)}`,
|
|
120
|
+
conversationSnapshotHash: `sha256:${'c'.repeat(64)}`, retrievalManifestHash: `sha256:${'r'.repeat(64)}`,
|
|
121
|
+
};
|
|
122
|
+
const fault = phase => {
|
|
123
|
+
if (mode === 'crash-prepared' && phase === 'journal-prepared') {
|
|
124
|
+
process.exit(137);
|
|
125
|
+
}
|
|
126
|
+
if (mode === 'crash-mid-apply' && phase === 'operation-applied:0') {
|
|
127
|
+
process.exit(137);
|
|
128
|
+
}
|
|
129
|
+
if (mode === 'crash-after-apply' && phase === 'promotion-verified') {
|
|
130
|
+
process.exit(137);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const service = new KnowledgePromotionService({ layout, projectStore, analyzer: standinAnalyzer({ knowledgePath }), fault });
|
|
134
|
+
const config = projectStore.readConfig();
|
|
135
|
+
|
|
136
|
+
if (mode === 'recover') {
|
|
137
|
+
const results = await service.recoverAll();
|
|
138
|
+
const state = projectStore.readState();
|
|
139
|
+
const readmeHash = hashBuffer(fs.readFileSync(path.join(knowledgePath, 'README.md')));
|
|
140
|
+
const changesDir = path.join(knowledgePath, 'changes');
|
|
141
|
+
AtomicFile.writeJsonAtomic(output, {
|
|
142
|
+
mode,
|
|
143
|
+
recoverAll: results,
|
|
144
|
+
lastAnalyzedCommit: state.lastAnalyzedCommit,
|
|
145
|
+
activeClaimRunId: state.analysis.activeClaim?.runId || null,
|
|
146
|
+
indexDirty: state.index.dirty,
|
|
147
|
+
indexGeneration: state.index.generation,
|
|
148
|
+
readmeHash,
|
|
149
|
+
changesFiles: fs.existsSync(changesDir) ? fs.readdirSync(changesDir) : [],
|
|
150
|
+
});
|
|
151
|
+
process.stdout.write(`ENGADV-FAULT-RECOVER ${JSON.stringify(results)}\n`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const result = await service.processClaim({ projectId: PROJECT_ID, config, claim, operationId: 'engadv-fault-op' });
|
|
156
|
+
const state = projectStore.readState();
|
|
157
|
+
AtomicFile.writeJsonAtomic(output, {
|
|
158
|
+
mode,
|
|
159
|
+
processClaim: { ok: result.ok, stateAdvanced: result.stateAdvanced === true, operations: result.operations },
|
|
160
|
+
lastAnalyzedCommit: state.lastAnalyzedCommit,
|
|
161
|
+
activeClaimRunId: state.analysis.activeClaim?.runId || null,
|
|
162
|
+
indexDirty: state.index.dirty,
|
|
163
|
+
});
|
|
164
|
+
process.stdout.write(`ENGADV-FAULT-COMPLETE ok=${result.ok}\n`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
main().catch(error => {
|
|
168
|
+
// A rejection still means the process is alive; crash modes exit via the fault hook.
|
|
169
|
+
process.stderr.write(`[engadv-fault] ${error.code || 'FAULT_FAILED'}: ${error.message}\n`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
});
|