@sanqianx/project-knowledge 5.0.31 → 5.0.32

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.
Files changed (89) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +5 -2
  4. package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +1 -1
  5. package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +1 -1
  6. package/_site/_test/helpers/parallel-engine-advanced-engine-child.js +1 -1
  7. package/_site/_test/helpers/parallel-engine-advanced-fault-writer.js +3 -3
  8. package/_site/_test/helpers/parallel-engine-advanced-harness.js +1 -1
  9. package/_site/_test/helpers/parallel-engine-advanced-standin-analyzer.js +1 -1
  10. package/_site/_test/helpers/parallel-engine-final-harness.js +2 -2
  11. package/_site/_test/helpers/parallel-engine-final-standin-analyzer.js +1 -1
  12. package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +1 -1
  13. package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +1 -1
  14. package/_site/_test/helpers/parallel-memory-analyzer.js +1 -1
  15. package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +1 -1
  16. package/_site/_test/helpers/parallel-memory-injection-shell.js +1 -1
  17. package/_site/_test/helpers/parallel-nav-shell.js +1 -1
  18. package/_site/_test/helpers/parallel-qa-engine-endpoint-guard.js +1 -1
  19. package/_site/_test/helpers/parallel-retrieval-followup-r2-shell.js +1 -1
  20. package/_site/_test/helpers/qa-r91-harness.cjs +4 -1
  21. package/_site/_test/package-boundary-test.js +5 -0
  22. package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +1 -1
  23. package/_site/_test/parallel-engine-advanced-eng011-ui-probe.js +1 -1
  24. package/_site/_test/parallel-knowledge-engine-test.js +3 -3
  25. package/_site/_test/parallel-knowledge-retrieval-test.js +2 -2
  26. package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +1 -1
  27. package/_site/_test/parallel-memory-injection-origin-probe.js +1 -1
  28. package/_site/_test/parallel-nav-isolation-test.js +1 -1
  29. package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +1 -1
  30. package/_site/_test/parallel-retrieval-followup-citation-test.js +2 -2
  31. package/_site/_test/parallel-retrieval-followup-corpus-test.js +1 -1
  32. package/_site/_test/qa-r45-offline-backfill-test.js +2 -2
  33. package/_site/_test/t07d-git-rel-coverage-test.js +5 -3
  34. package/_site/_test/t07f-mem-008-coverage-test.js +1 -1
  35. package/_site/lib/module-bridge.js +2 -11
  36. package/_site/scripts/install-module-candidates.js +1 -1
  37. package/_site/scripts/pack-module-candidates.js +2 -1
  38. package/_site/scripts/verify-module-runtime.js +17 -32
  39. package/_site/scripts/verify-product-runtime.js +7 -3
  40. package/docs/README.zh-CN.md +3 -1
  41. package/module-runtime-manifest.json +53 -3
  42. package/package.json +2 -4
  43. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  44. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  45. package/plugins/project-knowledge/.mcp.json +1 -1
  46. package/_modules/knowledge-engine/README.md +0 -133
  47. package/_modules/knowledge-engine/package.json +0 -38
  48. package/_modules/knowledge-engine/src/analysis-contract.js +0 -35
  49. package/_modules/knowledge-engine/src/analysis-failures.js +0 -39
  50. package/_modules/knowledge-engine/src/analysis-output.js +0 -52
  51. package/_modules/knowledge-engine/src/analysis-worker.js +0 -58
  52. package/_modules/knowledge-engine/src/bin.js +0 -52
  53. package/_modules/knowledge-engine/src/bridge-client.js +0 -24
  54. package/_modules/knowledge-engine/src/context.js +0 -140
  55. package/_modules/knowledge-engine/src/coordinator.js +0 -376
  56. package/_modules/knowledge-engine/src/diagnostics.js +0 -37
  57. package/_modules/knowledge-engine/src/headless-analyzer.js +0 -66
  58. package/_modules/knowledge-engine/src/index-request.js +0 -49
  59. package/_modules/knowledge-engine/src/knowledge-targets.js +0 -46
  60. package/_modules/knowledge-engine/src/memories.js +0 -281
  61. package/_modules/knowledge-engine/src/memory-eligibility.js +0 -74
  62. package/_modules/knowledge-engine/src/retrieval-policy.json +0 -14
  63. package/_modules/knowledge-engine/src/retrieval-ranking.js +0 -153
  64. package/_modules/knowledge-engine/src/retrieval.js +0 -367
  65. package/_modules/knowledge-engine/src/runtime/README.md +0 -7
  66. package/_modules/knowledge-engine/src/runtime/atomic-file.js +0 -204
  67. package/_modules/knowledge-engine/src/runtime/automation-config.js +0 -140
  68. package/_modules/knowledge-engine/src/runtime/commit-conversation-binder.js +0 -250
  69. package/_modules/knowledge-engine/src/runtime/commit-processing-ledger.js +0 -26
  70. package/_modules/knowledge-engine/src/runtime/commit-prompt.js +0 -205
  71. package/_modules/knowledge-engine/src/runtime/commit-reconciler.js +0 -432
  72. package/_modules/knowledge-engine/src/runtime/content-hash.js +0 -4
  73. package/_modules/knowledge-engine/src/runtime/contracts.js +0 -282
  74. package/_modules/knowledge-engine/src/runtime/conversation-exclusions.js +0 -204
  75. package/_modules/knowledge-engine/src/runtime/conversation-store.js +0 -389
  76. package/_modules/knowledge-engine/src/runtime/evidence-bundle.js +0 -228
  77. package/_modules/knowledge-engine/src/runtime/git-runner.js +0 -62
  78. package/_modules/knowledge-engine/src/runtime/knowledge-promotion.js +0 -559
  79. package/_modules/knowledge-engine/src/runtime/knowledge-retrieval-service.js +0 -408
  80. package/_modules/knowledge-engine/src/runtime/layout.js +0 -46
  81. package/_modules/knowledge-engine/src/runtime/markdown-knowledge-indexer.js +0 -276
  82. package/_modules/knowledge-engine/src/runtime/scanner.js +0 -298
  83. package/_modules/knowledge-engine/src/server.js +0 -166
  84. package/_modules/knowledge-engine/src/store.js +0 -267
  85. package/_modules/knowledge-engine/ui/app.css +0 -172
  86. package/_modules/knowledge-engine/ui/app.js +0 -318
  87. package/_modules/knowledge-engine/ui/index.html +0 -95
  88. package/_site/scripts/vendor-modules.js +0 -49
  89. package/vendor-manifest.json +0 -55
@@ -9,7 +9,7 @@
9
9
  "plugins": [
10
10
  {
11
11
  "name": "project-knowledge",
12
- "version": "5.0.31",
12
+ "version": "5.0.32",
13
13
  "source": "./plugins/project-knowledge",
14
14
  "description": "Search durable project decisions and implementation history through MCP."
15
15
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.0.32] - 2026-11-10
4
+
5
+ - 将 knowledge-engine 改为固定版本的公开 npm 依赖 `@sanqianx/ai-coding-knowledge-engine@0.2.7-rc.12`,从主仓库移除内置引擎源码和旧 vendoring 脚本;保留历史提交及现有 npm 版本。
6
+ - 四个模块统一进行安装版本与运行文件哈希验证,更新包边界、候选安装和回归工具;安装和运行无需访问模块的私有 GitHub 仓库。
7
+
3
8
  ## [5.0.31] - 2026-11-09
4
9
 
5
10
  - 新增外观与皮肤:预设主题与浅色/深色两套自定义颜色(`#RRGGBB` 白名单校验),改动即时预览、保存后对本机所有入口生效;支持 `kb-skin/v1` 皮肤文件的导出与导入,服务未就绪时保持默认皮肤不阻塞启动。
package/README.md CHANGED
@@ -20,7 +20,10 @@ project-knowledge
20
20
  ```
21
21
 
22
22
  1. `npm install -g @sanqianx/project-knowledge@latest` installs the shell,
23
- three pinned module dependencies and the bundled knowledge-engine.
23
+ four pinned npm module dependencies, including knowledge-engine.
24
+ Module source repositories may be private; installation uses public npm
25
+ packages and needs no GitHub credentials. Engine source is maintained in its
26
+ own repository rather than copied into this shell.
24
27
  2. `project-knowledge-integrations install` is the one-time Integration Setup.
25
28
  For every detected client (Claude Code / Codex / OpenCode) it installs two
26
29
  independent capabilities, reported separately:
@@ -316,7 +319,7 @@ _site/lib/knowledge-tool-runtime.js
316
319
  _site/scripts/hook-trigger.js
317
320
  ui/index.html # unified production web UI
318
321
  ui/product.js, ui/product.css # shell navigation and state projection
319
- _modules/knowledge-engine/ # verified dependency-free engine
322
+ node_modules/@sanqianx/ai-coding-knowledge-engine/ # pinned npm runtime (not tracked)
320
323
  bin/project-knowledge*.js # CLI and MCP entry points
321
324
  desktop/ # Windows Electron package
322
325
  ```
@@ -64,7 +64,7 @@ const freePort = require('../helpers/free-port');
64
64
  const { createMemoryStandinAnalyzer } = require('./parallel-memory-analyzer');
65
65
 
66
66
  const ROOT = r3cap.ROOT;
67
- const ENGINE_ENTRY = path.join(ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
67
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(ROOT)] })), 'src', 'server.js');
68
68
  const CONSOLE_ENTRY = path.join(ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'bin.js');
69
69
  const { resolveTempRoot, withSanitizedEnv } = r3cap;
70
70
 
@@ -48,7 +48,7 @@ const { createEventBridgeStandin } = require('./parallel-memory-event-bridge');
48
48
  const { startLaneVectorHub } = require('./parallel-capture-safety-r5-cap-shell');
49
49
 
50
50
  const ROOT = path.resolve(__dirname, '../../..');
51
- const ENGINE_ENTRY = path.join(ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
51
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(ROOT)] })), 'src', 'server.js');
52
52
  const LIVE_PORTS = new Set([5757, 5790, 8787, 8790]);
53
53
 
54
54
  function isInside(candidate, parent) {
@@ -7,7 +7,7 @@
7
7
  // The analyzer is the lane's declarative stand-in - real staged bytes, no real
8
8
  // model output. Vendored engine code is never modified.
9
9
 
10
- const { createEngineServer } = require('../../../_modules/knowledge-engine/src/server.js');
10
+ const { createEngineServer } = require('@sanqianx/ai-coding-knowledge-engine/src/server.js');
11
11
  const { createStandinAnalyzer } = require('./parallel-engine-advanced-standin-analyzer.js');
12
12
 
13
13
  async function main() {
@@ -22,9 +22,9 @@
22
22
  const fs = require('node:fs');
23
23
  const path = require('node:path');
24
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');
25
+ const { RuntimeLayout } = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/layout.js');
26
+ const { KnowledgePromotionService } = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/knowledge-promotion.js');
27
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file.js');
28
28
 
29
29
  const PROJECT_ID = 'project-eng009-fault';
30
30
  const COMMIT_SHA = 'a'.repeat(40); // fixture identity; not a real repo commit - promotion only needs claim identity + hashes
@@ -19,7 +19,7 @@ const os = require('node:os');
19
19
  const path = require('node:path');
20
20
 
21
21
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
22
- const VENDORED_ENGINE_SERVER = path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
22
+ const VENDORED_ENGINE_SERVER = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'src', 'server.js');
23
23
  const ENGINE_CHILD = path.join(__dirname, 'parallel-engine-advanced-engine-child.js');
24
24
 
25
25
  // Temp root: PK_TEST_TEMP_ROOT or the OS temp dir; never inside the repository.
@@ -23,7 +23,7 @@
23
23
  const fs = require('node:fs');
24
24
  const path = require('node:path');
25
25
  const crypto = require('node:crypto');
26
- const AtomicFile = require('../../../_modules/knowledge-engine/src/runtime/atomic-file.js');
26
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file.js');
27
27
 
28
28
  function hashBuffer(value) {
29
29
  return `sha256:${crypto.createHash('sha256').update(value).digest('hex')}`;
@@ -31,8 +31,8 @@ const os = require('node:os');
31
31
  const path = require('node:path');
32
32
 
33
33
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
34
- const VENDORED_ENGINE_SERVER = path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
35
- const VENDORED_ATOMIC_FILE = path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'runtime', 'atomic-file.js');
34
+ const VENDORED_ENGINE_SERVER = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'src', 'server.js');
35
+ const VENDORED_ATOMIC_FILE = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'src', 'runtime', 'atomic-file.js');
36
36
 
37
37
  // Pinned runtime by default: the root repo's installed
38
38
  // versions declared by the root package (identity-checked below), so the drivers are portable to any checkout of this
@@ -82,7 +82,7 @@ function createStandinAnalyzer(options = {}) {
82
82
  if (delegatedQuote) lines.push(`维护指令:${delegatedQuote}`, '');
83
83
  const markdown = lines.join('\n');
84
84
 
85
- const AtomicFile = require('../../../_modules/knowledge-engine/src/runtime/atomic-file.js');
85
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file.js');
86
86
  AtomicFile.writeFileAtomic(path.join(input.stagingPath, 'files', ...filename.split('/')), markdown);
87
87
 
88
88
  const references = [
@@ -36,7 +36,7 @@ const path = require('node:path');
36
36
  const crypto = require('node:crypto');
37
37
 
38
38
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
39
- const VENDORED_ENGINE_ROOT = path.join(REPO_ROOT, '_modules', 'knowledge-engine');
39
+ const VENDORED_ENGINE_ROOT = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })));
40
40
  const VENDORED_ENGINE_VERSION = '0.2.7-rc.10';
41
41
 
42
42
  function resolveRuntimeRoot(envVar, pinnedDir, pinnedVersion) {
@@ -47,7 +47,7 @@ function createStandinAnalyzer(options = {}) {
47
47
 
48
48
  const atomicFilePath = engineRoot
49
49
  ? path.join(engineRoot, 'src', 'runtime', 'atomic-file.js')
50
- : path.join(__dirname, '..', '..', '..', '_modules', 'knowledge-engine', 'src', 'runtime', 'atomic-file.js');
50
+ : path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(__dirname, '..', '..', '..')] })), 'src', 'runtime', 'atomic-file.js');
51
51
  const AtomicFile = require(atomicFilePath);
52
52
  AtomicFile.writeFileAtomic(path.join(input.stagingPath, 'files', ...filename.split('/')), markdown);
53
53
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  const path = require('node:path');
22
22
  const crypto = require('node:crypto');
23
- const AtomicFile = require('../../../_modules/knowledge-engine/src/runtime/atomic-file.js');
23
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file.js');
24
24
 
25
25
  /**
26
26
  * A long enough sentence that the engine's own capture gate accepts it as a
@@ -49,7 +49,7 @@ const freePort = require('../helpers/free-port');
49
49
  const { createMemoryStandinAnalyzer } = require('./parallel-memory-analyzer');
50
50
 
51
51
  const ROOT = r3cap.ROOT;
52
- const ENGINE_ENTRY = path.join(ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
52
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(ROOT)] })), 'src', 'server.js');
53
53
  const CONSOLE_ENTRY = path.join(ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'bin.js');
54
54
  const { resolveTempRoot, withSanitizedEnv } = r3cap;
55
55
 
@@ -37,7 +37,7 @@ const crypto = require('node:crypto');
37
37
  const { spawn, execFileSync } = require('node:child_process');
38
38
 
39
39
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
40
- const ENGINE_ENTRY = path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
40
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'src', 'server.js');
41
41
  const BRIDGE_CONSOLE_ENTRY = path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'server.js');
42
42
  const BRIDGE_REPO_CONTEXT = path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'bridge', 'core', 'repo-context.js');
43
43
 
@@ -36,7 +36,7 @@ const { enterNavIsolation } = require('./parallel-nav-isolation-env');
36
36
  const freePort = require('../helpers/free-port');
37
37
 
38
38
  const ROOT = path.resolve(__dirname, '../../..');
39
- const ENGINE_ENTRY = path.join(ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
39
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(ROOT)] })), 'src', 'server.js');
40
40
 
41
41
  const THEMES = ['light', 'dark'];
42
42
 
@@ -43,7 +43,7 @@ const { PROTECTED_PORTS } = require('./parallel-qa-engine-endpoint-isolate');
43
43
 
44
44
  const REFUSAL_CODE = 'PK_ENGINE_ENDPOINT_REFUSED';
45
45
  const EGRESS_BLOCK_CODE = 'PK_PROTECTED_EGRESS_BLOCKED';
46
- const ENGINE_SERVER_MODULE = path.resolve(__dirname, '..', '..', '..', '_modules', 'knowledge-engine', 'src', 'server.js');
46
+ const ENGINE_SERVER_MODULE = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.resolve(__dirname, '..', '..', '..')] })), 'src', 'server.js');
47
47
 
48
48
  function refusal(message, extra = {}) {
49
49
  return Object.assign(new Error(message), { code: REFUSAL_CODE, ...extra });
@@ -44,7 +44,7 @@ const { spawn, execFileSync } = require('node:child_process');
44
44
  const chain = require('./parallel-retrieval-followup-shell');
45
45
 
46
46
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
47
- const ENGINE_ENTRY = path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
47
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'src', 'server.js');
48
48
  const BRIDGE_CONSOLE_ENTRY = path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'server.js');
49
49
  const BRIDGE_REPO_CONTEXT = path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console', 'src', 'bridge', 'core', 'repo-context.js');
50
50
 
@@ -120,7 +120,10 @@ function resolveProductRoot(candidate) {
120
120
  if (!packageJson || typeof packageJson.name !== 'string' || !packageJson.name || typeof packageJson.version !== 'string' || !packageJson.version) {
121
121
  throw invalidProductRoot('INVALID_PACKAGE', `package.json must carry name and version, got ${JSON.stringify({ name: packageJson && packageJson.name, version: packageJson && packageJson.version })}`);
122
122
  }
123
- return { root, packageJson, siteEntry, engineRoot: path.join(root, '_modules', 'knowledge-engine') };
123
+ let engineRoot;
124
+ try { engineRoot = path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [root] })); }
125
+ catch { throw invalidProductRoot('MISSING_ENGINE', 'the installed npm engine dependency is missing'); }
126
+ return { root, packageJson, siteEntry, engineRoot };
124
127
  }
125
128
 
126
129
  function r91CreateEngineServer(options = {}, engineSourceRoot = ENGINE_SOURCE_ROOT) {
@@ -4,6 +4,9 @@ const path = require('path');
4
4
  const { spawnSync } = require('child_process');
5
5
 
6
6
  const root = path.resolve(__dirname, '..', '..');
7
+ for (const retired of ['_modules/knowledge-engine', 'vendor-manifest.json', '_site/scripts/vendor-modules.js']) {
8
+ assert(!fs.existsSync(path.join(root, retired)), `engine must remain an npm dependency; remove the retired source copy: ${retired}`);
9
+ }
7
10
  const npmCli = process.env.npm_execpath
8
11
  || path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
9
12
  const result = spawnSync(process.execPath, [npmCli, 'pack', '--dry-run', '--json'], {
@@ -16,6 +19,8 @@ assert.strictEqual(result.status, 0, result.stderr || result.stdout);
16
19
  const report = JSON.parse(result.stdout);
17
20
  const files = report[0].files.map(entry => entry.path.replace(/\\/g, '/'));
18
21
  const forbidden = [
22
+ '_modules/knowledge-engine/',
23
+ 'vendor-manifest.json',
19
24
  'docs/project-knowledge-base-review-deliverables.zip',
20
25
  'docs/project-knowledge-base-review-deliverables/',
21
26
  'docs/project-knowledge-base-pro-review-prompt.md',
@@ -115,7 +115,7 @@ function identityChain(shimPath) {
115
115
  return {
116
116
  gitHead: gitHead(),
117
117
  core: coreFiles.map(file => ({ file, sha256: sha256File(path.join(r3cap.ROOT, file)) })),
118
- engine: engineFiles.map(file => ({ file, sha256: sha256File(path.join(r3cap.ROOT, '_modules', 'knowledge-engine', file)) })),
118
+ engine: engineFiles.map(file => ({ file, sha256: sha256File(path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(r3cap.ROOT)] })), file)) })),
119
119
  console: consoleIdentity(),
120
120
  shim: {
121
121
  installedPath: shimPath,
@@ -80,7 +80,7 @@ const { attachNetworkCapture } = require('./helpers/cdp-network-capture.js');
80
80
  const ARTIFACTS = process.env.KB_ENG011_EVIDENCE_DIR
81
81
  || path.resolve(__dirname, '../../qa-autopilot/artifacts/parallel-20261023/engine-review-r3/evidence/eng011ui');
82
82
  const UI_DIR = process.env.KB_ENG011_UI_DIR
83
- || path.join(REPO_ROOT, '_modules', 'knowledge-engine', 'ui');
83
+ || path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO_ROOT)] })), 'ui');
84
84
 
85
85
  function isRetryPost(entry) {
86
86
  return entry.method === 'POST' && /\/api\/runs\/[^/]+\/retry$/.test(new URL(entry.url).pathname);
@@ -19,9 +19,9 @@ const { StorageLayout } = require('../lib/storage-layout');
19
19
  const { ProjectStore } = require('../lib/project-store');
20
20
  const { ProjectRegistryStore } = require('../lib/project-registry-store');
21
21
  const { ProjectLifecycleService } = require('../lib/project-lifecycle-service');
22
- const { createEngineServer } = require('../../_modules/knowledge-engine/src/server');
23
- const { CommitScanner } = require('../../_modules/knowledge-engine/src/runtime/scanner');
24
- const AtomicFile = require('../../_modules/knowledge-engine/src/runtime/atomic-file');
22
+ const { createEngineServer } = require('@sanqianx/ai-coding-knowledge-engine/src/server');
23
+ const { CommitScanner } = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/scanner');
24
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file');
25
25
 
26
26
  const results = [];
27
27
  function record(caseId, status, detail) {
@@ -21,8 +21,8 @@ const { KnowledgeRetrievalService } = require('../lib/knowledge-retrieval-servic
21
21
  const { EngineKnowledgeClient } = require('../lib/engine-knowledge-client');
22
22
  const { CHUNKER_VERSION } = require('../lib/markdown-knowledge-indexer');
23
23
  const { sha256 } = require('../lib/knowledge-schema');
24
- const { createEngineServer } = require('../../_modules/knowledge-engine/src/server');
25
- const AtomicFile = require('../../_modules/knowledge-engine/src/runtime/atomic-file');
24
+ const { createEngineServer } = require('@sanqianx/ai-coding-knowledge-engine/src/server');
25
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file');
26
26
 
27
27
  const results = [];
28
28
  function record(caseId, status, detail) {
@@ -107,7 +107,7 @@ function identityChain(shimPath) {
107
107
  return {
108
108
  gitHead: gitHead(),
109
109
  core: coreFiles.map(file => ({ file, sha256: sha256File(path.join(r3cap.ROOT, file)) })),
110
- engine: engineFiles.map(file => ({ file, sha256: sha256File(path.join(r3cap.ROOT, '_modules', 'knowledge-engine', file)) })),
110
+ engine: engineFiles.map(file => ({ file, sha256: sha256File(path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(r3cap.ROOT)] })), file)) })),
111
111
  console: consoleIdentity(),
112
112
  shim: {
113
113
  installedPath: shimPath,
@@ -41,7 +41,7 @@ const REQUESTED_MODEL = String(process.env.PK_WB_MODEL_ID || 'MiniMax-M3.1-Flash
41
41
  const EFFORT = String(process.env.PK_WB_MODEL_EFFORT || 'max');
42
42
  const TURN_TIMEOUT_MS = Number(process.env.PK_WB_TURN_TIMEOUT_MS || 420000);
43
43
 
44
- const BINDER_ENTRY = path.join(shell.REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'runtime', 'commit-conversation-binder.js');
44
+ const BINDER_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(shell.REPO_ROOT)] })), 'src', 'runtime', 'commit-conversation-binder.js');
45
45
 
46
46
  const results = [];
47
47
  function record(caseId, status, detail) {
@@ -49,7 +49,7 @@ const {
49
49
  } = require('./helpers/parallel-nav-isolation-env');
50
50
 
51
51
  const ROOT = path.resolve(__dirname, '..', '..');
52
- const ENGINE_ENTRY = path.join(ROOT, '_modules', 'knowledge-engine', 'src', 'server.js');
52
+ const ENGINE_ENTRY = path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(ROOT)] })), 'src', 'server.js');
53
53
  const SHELL_FILE = path.join(ROOT, '_site', '_test', 'helpers', 'parallel-nav-shell.js');
54
54
  const EVIDENCE = process.env.PK_R7_EVIDENCE_DIR ? path.resolve(process.env.PK_R7_EVIDENCE_DIR) : null;
55
55
 
@@ -75,7 +75,7 @@ const {
75
75
 
76
76
  // ── Leg B: negative regression — the ORIGINAL defect, safely held ──
77
77
  // Raw product constructor without vectorUrl (exactly the S1/S2/S3 shape).
78
- const { createEngineServer } = require('../../_modules/knowledge-engine/src/server');
78
+ const { createEngineServer } = require('@sanqianx/ai-coding-knowledge-engine/src/server');
79
79
  const negRoot = mkdtemp('neg');
80
80
  const negBrainDir = path.join(negRoot, 'brain-shared');
81
81
  fs.mkdirSync(negBrainDir, { recursive: true });
@@ -26,8 +26,8 @@ const shell = require('./helpers/parallel-retrieval-followup-shell');
26
26
  // Isolate before any product module is loaded.
27
27
  shell.isolateProcess();
28
28
 
29
- const { createEngineServer } = require('../../_modules/knowledge-engine/src/server');
30
- const AtomicFile = require('../../_modules/knowledge-engine/src/runtime/atomic-file');
29
+ const { createEngineServer } = require('@sanqianx/ai-coding-knowledge-engine/src/server');
30
+ const AtomicFile = require('@sanqianx/ai-coding-knowledge-engine/src/runtime/atomic-file');
31
31
 
32
32
  const TOKEN = 'RET007OFFLINE';
33
33
  const results = [];
@@ -38,7 +38,7 @@ const shell = require('./helpers/parallel-retrieval-followup-shell');
38
38
  shell.isolateProcess();
39
39
 
40
40
  const corpusDefinitions = require('./helpers/parallel-retrieval-followup-corpus');
41
- const ranking = require('../../_modules/knowledge-engine/src/retrieval-ranking');
41
+ const ranking = require('@sanqianx/ai-coding-knowledge-engine/src/retrieval-ranking');
42
42
 
43
43
  const HUB_DIST = path.join(shell.REPO_ROOT, 'node_modules', '@sanqianx', 'vector-hub', 'dist', 'cjs');
44
44
  const DIMENSIONS = 512;
@@ -83,8 +83,8 @@ async function main() {
83
83
  caseId: 'ENG-007', lane: 'P-ENGINE-OFFLINE-AUDIT-R45', laneDir: lane, phases: {}, commands,
84
84
  isolation: { tempRoot: TEMP_ROOT, evidenceRoot: EVIDENCE_ROOT, envIsolation: ENV_ISOLATION_RESOLVED },
85
85
  identity: {
86
- vendoredEngineVersion: JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', '_modules', 'knowledge-engine', 'package.json'), 'utf8')).version,
87
- vendoredCoordinatorSha256: sha256(path.resolve(__dirname, '..', '..', '_modules', 'knowledge-engine', 'src', 'coordinator.js')),
86
+ vendoredEngineVersion: JSON.parse(fs.readFileSync(path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.resolve(__dirname, '..', '..')] })), 'package.json'), 'utf8')).version,
87
+ vendoredCoordinatorSha256: sha256(path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.resolve(__dirname, '..', '..')] })), 'src', 'coordinator.js')),
88
88
  bridge: RUNTIME_IDENTITY.bridge, vector: RUNTIME_IDENTITY.vector,
89
89
  },
90
90
  };
@@ -172,7 +172,7 @@ function main() {
172
172
  // ---------------- REL-003 制品泄漏 ------------------------------------
173
173
  {
174
174
  const { validatePack } = require(path.join(REPO, 'qa-autopilot', 'lib', 'registry.cjs'));
175
- const essentials = ['package.json', '_site/server.js', 'ui/index.html', 'ui/product.js', 'ui/live-client.js', 'module-runtime-manifest.json', 'vendor-manifest.json'];
175
+ const essentials = ['package.json', '_site/server.js', 'ui/index.html', 'ui/product.js', 'ui/live-client.js', 'module-runtime-manifest.json'];
176
176
  assert.throws(() => validatePack([...essentials, 'qa-autopilot/tools/x.cjs']), /Forbidden package file.*qa-autopilot/,
177
177
  'QA-SPEC-REL-003: qa/ paths are refused in the pack');
178
178
  assert.throws(() => validatePack([...essentials, 'state/runs/1.json']), /Forbidden package file.*state/,
@@ -185,8 +185,10 @@ function main() {
185
185
  assert.throws(() => validatePack(essentials.filter(f => f !== required)), /Required runtime missing/,
186
186
  `QA-SPEC-REL-003: removing the essential ${required} is refused — the engine/plugins runtime cannot be cleaned away`);
187
187
  }
188
- assert.doesNotThrow(() => validatePack([...essentials, '_modules/knowledge-engine/src/server.js', 'plugins/project-knowledge/plugin.json']),
189
- 'QA-SPEC-REL-003: the required engine and plugin payload passes the audit');
188
+ assert.doesNotThrow(() => validatePack([...essentials, 'plugins/project-knowledge/plugin.json']),
189
+ 'QA-SPEC-REL-003: shell and plugin payload passes the audit with npm runtime dependencies');
190
+ assert.throws(() => validatePack([...essentials, '_modules/knowledge-engine/src/server.js']), /Engine source must be installed/,
191
+ 'QA-SPEC-REL-003: engine source cannot leak back into the shell package');
190
192
  console.log('QA-SPEC-REL-003: leak paths refused; required runtime essentials protected');
191
193
  }
192
194
 
@@ -21,7 +21,7 @@ const path = require('node:path');
21
21
  const crypto = require('node:crypto');
22
22
 
23
23
  const REPO = path.resolve(__dirname, '..', '..');
24
- const { MemoryEligibility } = require(path.join(REPO, '_modules', 'knowledge-engine', 'src', 'memory-eligibility.js'));
24
+ const { MemoryEligibility } = require(path.join(path.dirname(require.resolve('@sanqianx/ai-coding-knowledge-engine/package.json', { paths: [path.join(REPO)] })), 'src', 'memory-eligibility.js'));
25
25
 
26
26
  const sha = text => crypto.createHash('sha256').update(text).digest('hex');
27
27
 
@@ -49,24 +49,15 @@ const INDEX_TIMEOUT_MS = 120000;
49
49
  // Native folder dialogs wait for the user without a bound.
50
50
  const PICKER_TIMEOUT_MS = 10 * 60 * 1000;
51
51
 
52
- // Vendored module runtimes shipped inside the npm package. Sibling-checkout
53
- // spawning is gone: the services are bundled, spawned from here, and resolved
54
- // through normal node_modules resolution
55
- // node_modules.
56
- // Module entry scripts resolve through normal node_modules dependencies
57
- // (claude-ai-workbench, @sanqianx/vector-hub, @sanqianx/ai-coding-event-bridge-
58
- // console) — the npm packages are the single source of these runtimes.
52
+ // All four services resolve through the host's pinned npm dependencies.
59
53
  const MODULE_ENTRIES = {
60
54
  terminal: 'claude-ai-workbench/packages/server/bin/agent-terminal-server.js',
61
55
  'vector-hub': '@sanqianx/vector-hub/bin.js',
62
56
  'event-bridge': '@sanqianx/ai-coding-event-bridge-console/src/bin.js',
57
+ 'knowledge-engine': '@sanqianx/ai-coding-knowledge-engine/src/bin.js',
63
58
  };
64
59
 
65
60
  function resolveModuleEntry(name) {
66
- if (name === 'knowledge-engine') {
67
- const runtime = path.resolve(__dirname, '..', '..', '_modules', 'knowledge-engine', 'src', 'bin.js');
68
- return fs.existsSync(runtime) ? runtime : null;
69
- }
70
61
  try { return require.resolve(MODULE_ENTRIES[name]); } catch { return null; }
71
62
  }
72
63
 
@@ -56,7 +56,7 @@ function main() {
56
56
  const verify = spawnSync(process.execPath, [path.join(core, '_site/scripts/verify-module-runtime.js'), '--working-tree'], { cwd: installedRoot, windowsHide: true, encoding: 'utf8' });
57
57
  if (verify.status !== 0) throw new Error('Packaged engine integrity failed');
58
58
  require('./verify-product-runtime').verifyProductRuntime(core);
59
- for (const relative of ['vendor-manifest.json', 'module-runtime-manifest.json']) {
59
+ for (const relative of ['module-runtime-manifest.json']) {
60
60
  if (!fs.readFileSync(path.join(core, relative)).equals(fs.readFileSync(path.join(root, relative)))) throw new Error(`Installed candidate is stale: ${relative}`);
61
61
  }
62
62
  const report = { schema: 'project-knowledge/installed-candidates/v1', mode: 'local npm candidate installation, not remote release', installedRoot, core, artifactManifest: manifestFile, shellVersion: candidate.version, shellSha256, shellArtifact, modules: Object.fromEntries(Object.entries(manifest.modules).map(([key, module]) => [key, { version: module.version, sha256: module.sha256 }])), integrityPassed: true, testedAt: new Date().toISOString() };
@@ -12,6 +12,7 @@ const definitions = {
12
12
  terminal: { option: '--terminal-source', name: '@sanqianx/claude-ai-workbench', installName: 'claude-ai-workbench', required: ['apps/agent-terminal/app.js', 'apps/agent-terminal/app.css', 'packages/server/lib/knowledge-context.js'] },
13
13
  vectorHub: { option: '--vector-source', name: '@sanqianx/vector-hub', installName: '@sanqianx/vector-hub', required: ['dist/cjs/bin.js', 'dist/cjs/server/manager.js', 'ui/index.html'] },
14
14
  eventBridge: { option: '--bridge-source', name: '@sanqianx/ai-coding-event-bridge-console', installName: '@sanqianx/ai-coding-event-bridge-console', required: ['src/server.js', 'src/bridge/core/consumer-registry.js', 'console/index.html'] },
15
+ engine: { option: '--engine-source', name: '@sanqianx/ai-coding-knowledge-engine', installName: '@sanqianx/ai-coding-knowledge-engine', required: ['src/bin.js', 'src/server.js', 'src/coordinator.js', 'src/analysis-worker.js', 'ui/index.html', 'ui/app.js', 'ui/app.css'] },
15
16
  };
16
17
  function run(command, args, cwd) {
17
18
  const result = spawnSync(command, args, { cwd, windowsHide: true, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
@@ -86,4 +87,4 @@ if (require.main === module) {
86
87
  }
87
88
  } catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; }
88
89
  }
89
- module.exports = { verifyInstalled, safeRelative, productFiles, installedFileBytes };
90
+ module.exports = { definitions, verifyInstalled, safeRelative, productFiles, installedFileBytes };
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const crypto = require('crypto');
5
4
  const { spawnSync } = require('child_process');
5
+ const { verifyProductRuntime } = require('./verify-product-runtime');
6
+ const { definitions } = require('./pack-module-candidates');
6
7
  const root = path.resolve(__dirname, '../..');
7
8
  const workingTree = process.argv.includes('--working-tree');
8
9
  function isPinnedModuleVersion(name, value) {
@@ -10,41 +11,25 @@ function isPinnedModuleVersion(name, value) {
10
11
  return /^\d+\.\d+\.\d+(?:-rc\.\d+)?$/.test(version || '');
11
12
  }
12
13
  function verify() {
13
- const manifest = JSON.parse(fs.readFileSync(path.join(root, 'vendor-manifest.json'), 'utf8'));
14
- if (manifest.schema !== 'project-knowledge/vendor-runtime/v1') throw new Error('Invalid runtime manifest');
15
- const engine = manifest.modules['knowledge-engine'];
16
- if (!engine || engine.root !== '_modules/knowledge-engine') throw new Error('Missing engine runtime');
17
- const packageInfo = JSON.parse(fs.readFileSync(path.join(root, 'package.json')));
18
- for (const dependency of ['claude-ai-workbench', '@sanqianx/vector-hub', '@sanqianx/ai-coding-event-bridge-console']) {
19
- if (!isPinnedModuleVersion(dependency, packageInfo.dependencies[dependency])) throw new Error(`Module dependency must be pinned: ${dependency}`);
14
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json')));
15
+ for (const { installName } of Object.values(definitions)) {
16
+ if (!isPinnedModuleVersion(installName, pkg.dependencies[installName])) throw new Error(`Module dependency must be pinned: ${installName}`);
20
17
  }
21
- const required = ['package.json', 'src/bin.js', 'src/server.js', 'src/coordinator.js', 'src/analysis-worker.js', 'ui/index.html', 'ui/app.js', 'ui/app.css'];
22
- if (required.some(file => !engine.files[file])) throw new Error('Incomplete runtime manifest');
23
- const hasGit = fs.existsSync(path.join(root, '.git'));
24
- function checkTree(directory, prefix = '') {
25
- for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
26
- const relative = prefix + entry.name;
27
- if (entry.isSymbolicLink()) throw new Error(`Unsafe runtime path: ${relative}`);
28
- if (entry.isDirectory()) checkTree(path.join(directory, entry.name), relative + '/');
29
- else if (!Object.hasOwn(engine.files, relative)) throw new Error(`Unreviewed runtime file: ${relative}`);
30
- }
18
+ const modules = verifyProductRuntime(root);
19
+ const engine = JSON.parse(fs.readFileSync(path.join(modules.engine.directory, 'package.json')));
20
+ if (Object.keys(engine.dependencies || {}).length || Object.keys(engine.devDependencies || {}).length) throw new Error('Engine must remain dependency-free');
21
+ const manifest = JSON.parse(fs.readFileSync(path.join(root, 'module-runtime-manifest.json')));
22
+ for (const file of Object.keys(manifest.modules.engine.files).filter(file => file.endsWith('.js'))) {
23
+ const syntax = spawnSync(process.execPath, ['--check', path.join(modules.engine.directory, file)], { windowsHide: true, encoding: 'utf8' });
24
+ if (syntax.status !== 0) throw new Error(`Engine runtime syntax error: ${file}`);
31
25
  }
32
- checkTree(path.join(root, engine.root));
33
- for (const [relative, expected] of Object.entries(engine.files)) {
34
- if (relative.includes('..') || path.isAbsolute(relative)) throw new Error('Unsafe manifest path');
35
- const file = path.join(root, engine.root, relative);
36
- if (fs.lstatSync(file).isSymbolicLink()) throw new Error('Unsafe vendored symlink');
37
- if (crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex') !== expected) throw new Error(`Runtime drift: ${relative}`);
38
- if (relative.endsWith('.js')) { const syntax = spawnSync(process.execPath, ['--check', file], { windowsHide: true, encoding: 'utf8' }); if (syntax.status !== 0) throw new Error(`Runtime syntax error: ${relative}`); }
39
- if (hasGit && !workingTree) {
40
- const indexed = spawnSync('git', ['show', `:${engine.root}/${relative}`], { cwd: root, windowsHide: true });
41
- if (indexed.status !== 0) throw new Error(`Release blocked: runtime file is not Git tracked: ${relative}`);
42
- if (crypto.createHash('sha256').update(indexed.stdout).digest('hex') !== expected) throw new Error(`Release blocked: Git runtime bytes differ from manifest: ${relative}`);
26
+ if (fs.existsSync(path.join(root, '.git')) && !workingTree) {
27
+ for (const file of ['package.json', 'module-runtime-manifest.json']) {
28
+ const indexed = spawnSync('git', ['show', `:${file}`], { cwd: root, windowsHide: true });
29
+ if (indexed.status !== 0 || indexed.stdout.toString().replace(/\r\n/g, '\n') !== fs.readFileSync(path.join(root, file), 'utf8').replace(/\r\n/g, '\n')) throw new Error(`Release blocked: Git bytes differ from runtime contract: ${file}`);
43
30
  }
44
31
  }
45
- const enginePackage = JSON.parse(fs.readFileSync(path.join(root, engine.root, 'package.json')));
46
- if (enginePackage.version !== engine.version || Object.keys(enginePackage.dependencies || {}).length || Object.keys(enginePackage.devDependencies || {}).length) throw new Error('Engine version/dependency contract failed');
47
- process.stdout.write(workingTree ? 'Runtime content verified; uncommitted working tree is not release approval.\n' : 'Vendored runtime release gate passed.\n');
32
+ process.stdout.write(workingTree ? 'Four npm module runtimes verified; working tree is not release approval.\n' : 'Pinned npm runtime release gate passed.\n');
48
33
  }
49
34
  if (require.main === module) { try { verify(); } catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; } }
50
35
  module.exports = { isPinnedModuleVersion };
@@ -3,10 +3,11 @@ const fs = require('node:fs');
3
3
  const path = require('node:path');
4
4
  const crypto = require('node:crypto');
5
5
  const { createRequire } = require('node:module');
6
- const { safeRelative } = require('./pack-module-candidates');
6
+ const { safeRelative, definitions } = require('./pack-module-candidates');
7
7
  function verifyProductRuntime(coreRoot, resolveFrom = path.join(coreRoot, 'package.json')) {
8
8
  const manifest = JSON.parse(fs.readFileSync(path.join(coreRoot, 'module-runtime-manifest.json')));
9
- if (manifest.schema !== 'project-knowledge/module-content/v1' || Object.keys(manifest.modules).length !== 3) throw new Error('Incomplete module content manifest');
9
+ if (manifest.schema !== 'project-knowledge/module-content/v1' || Object.keys(manifest.modules).length !== Object.keys(definitions).length || Object.keys(definitions).some(key => !manifest.modules[key])) throw new Error('Incomplete module content manifest');
10
+ const host = JSON.parse(fs.readFileSync(path.join(coreRoot, 'package.json')));
10
11
  for (const file of ['ui/index.html', 'ui/knowledge-panel.html', 'ui/product.js', 'ui/product.css', 'ui/favicon.svg', 'plugins/project-knowledge/hooks/claude.json', 'plugins/project-knowledge/hooks/codex.json', 'plugins/project-knowledge/scripts/context-hook.cjs', 'plugins/project-knowledge/scripts/mcp-launcher.cjs', 'plugins/project-knowledge/.claude-plugin/plugin.json', 'plugins/project-knowledge/.codex-plugin/plugin.json', 'plugins/project-knowledge/.mcp.json']) if (!manifest.productFiles?.[file]) throw new Error(`Product asset missing from content manifest: ${file}`);
11
12
  const resolve = createRequire(resolveFrom);
12
13
  if (!manifest.productFiles['ui/live-client.js']) throw new Error('Product live transport missing from content manifest');
@@ -15,6 +16,9 @@ function verifyProductRuntime(coreRoot, resolveFrom = path.join(coreRoot, 'packa
15
16
  }
16
17
  const modules = {};
17
18
  for (const [key, module] of Object.entries(manifest.modules)) {
19
+ const definition = definitions[key];
20
+ if (module.name !== definition.name || module.installName !== definition.installName || definition.required.some(file => !module.files[file])) throw new Error(`Incomplete module runtime: ${key}`);
21
+ if (![module.version, `npm:${module.name}@${module.version}`].includes(host.dependencies[module.installName])) throw new Error(`Module dependency is not pinned to manifest: ${key}`);
18
22
  const pkgFile = resolve.resolve(`${module.installName}/package.json`);
19
23
  const directory = path.dirname(pkgFile);
20
24
  const pkg = JSON.parse(fs.readFileSync(pkgFile));
@@ -26,7 +30,7 @@ function verifyProductRuntime(coreRoot, resolveFrom = path.join(coreRoot, 'packa
26
30
  }
27
31
  modules[key] = { directory, version: pkg.version };
28
32
  }
29
- for (const file of ['ui/index.html', 'ui/knowledge-panel.html', 'ui/product.js', 'ui/product.css', '_modules/knowledge-engine/src/bin.js', '_modules/knowledge-engine/src/coordinator.js']) if (!fs.existsSync(path.join(coreRoot, file))) throw new Error(`Product runtime missing: ${file}`);
33
+ for (const file of ['ui/index.html', 'ui/knowledge-panel.html', 'ui/product.js', 'ui/product.css']) if (!fs.existsSync(path.join(coreRoot, file))) throw new Error(`Product runtime missing: ${file}`);
30
34
  return modules;
31
35
  }
32
36
  if (require.main === module) {
@@ -18,7 +18,9 @@ project-knowledge
18
18
  ```
19
19
 
20
20
  1. `npm install -g @sanqianx/project-knowledge@latest` 安装外壳、固定版本的
21
- 工作台、vector-hub、event-bridge,以及包内 knowledge-engine。
21
+ 工作台、vector-hub、event-bridge,以及固定版本的 knowledge-engine npm 包。
22
+ 模块源码仓库可保持私有;安装使用公开 npm 包,不需要 GitHub 凭据。
23
+ 主仓库不再保存 knowledge-engine 的源码副本。
22
24
  2. `project-knowledge-integrations install` 是一次性的 Integration Setup,
23
25
  对检测到的每个客户端(Claude Code / Codex / OpenCode)同时安装两类
24
26
  相互独立、分别上报状态的能力: