@sanqianx/project-knowledge 5.0.19 → 5.0.20
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 +3 -3
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +5 -0
- package/LICENSE +201 -201
- package/NOTICE +5 -5
- package/README.md +349 -349
- package/_modules/knowledge-engine/README.md +4 -0
- package/_modules/knowledge-engine/src/analysis-failures.js +39 -0
- package/_modules/knowledge-engine/src/analysis-worker.js +6 -2
- package/_modules/knowledge-engine/src/coordinator.js +7 -0
- package/_modules/knowledge-engine/src/headless-analyzer.js +2 -1
- package/_modules/knowledge-engine/src/server.js +1 -1
- package/_site/_test/agent-capture-mcp-ui-test.js +67 -67
- 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/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/claude-executable-discovery-test.js +28 -28
- package/_site/_test/claude-session-lifecycle-sweep-test.js +252 -252
- 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 +134 -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 +4 -4
- 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 +10 -10
- package/_site/_test/conversation-origin-test.js +15 -15
- package/_site/_test/cross-repo-isolation-e2e-test.js +187 -187
- package/_site/_test/embedding-config-test.js +32 -32
- 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/fresh-hook-reimport-test.js +53 -53
- package/_site/_test/fresh-product-data-test.js +56 -56
- package/_site/_test/git-path-compatibility-test.js +80 -80
- package/_site/_test/git-validation-test.js +81 -81
- package/_site/_test/hook-worktree-test.js +42 -42
- package/_site/_test/index-builder-test.js +41 -41
- package/_site/_test/index-error-display-contract-test.js +10 -10
- package/_site/_test/integration-adapters-test.js +67 -67
- package/_site/_test/integration-capture-setup-test.js +118 -118
- 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/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 +109 -109
- package/_site/_test/knowledge-maintenance-test.js +40 -40
- package/_site/_test/knowledge-panel-ui-contract-test.js +112 -0
- package/_site/_test/knowledge-scopes-test.js +37 -37
- package/_site/_test/knowledge-storage-location-test.js +28 -28
- 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/markdown-maintenance-test.js +11 -11
- 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/orphaned-claim-recovery-test.js +80 -80
- package/_site/_test/package-boundary-test.js +43 -42
- package/_site/_test/package-startup-test.js +56 -56
- package/_site/_test/packaged-ui-smoke-test.js +88 -88
- 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-import-ui-test.js +104 -104
- package/_site/_test/product-progress-status-test.js +12 -1
- package/_site/_test/project-remove-running-guard-test.js +79 -79
- package/_site/_test/project-store-test.js +90 -90
- 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/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-scope-root-binding-test.js +67 -67
- package/_site/_test/simple-import-test.js +98 -98
- package/_site/_test/startup-analysis-disabled-test.js +6 -6
- 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 +35 -35
- package/_site/_test/workbench-context-receipts-test.js +22 -22
- package/_site/_test/workspace-ui-contract-test.js +31 -31
- package/_site/_test/zcode-capture-integration-test.js +108 -108
- package/_site/lib/ai-vendor-presets.js +83 -83
- package/_site/lib/ai-workspace.js +3 -3
- package/_site/lib/atomic-file.js +204 -204
- package/_site/lib/bridge-adapter.js +260 -260
- package/_site/lib/capture-hook-config.js +108 -108
- package/_site/lib/claude-cli-runner.js +89 -89
- 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 +12 -12
- package/_site/lib/commit-reconciler.js +38 -38
- package/_site/lib/context-pack-builder.js +299 -299
- package/_site/lib/conversation-exclusions.js +204 -204
- package/_site/lib/conversation-query-service.js +17 -17
- 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 +72 -72
- package/_site/lib/folder-picker-output.js +3 -3
- package/_site/lib/git-path.js +14 -14
- package/_site/lib/github-team-store.js +3 -3
- package/_site/lib/index-builder.js +157 -157
- package/_site/lib/integration-status-scan.js +99 -99
- package/_site/lib/integration-status-worker.js +14 -14
- package/_site/lib/kb-framework.js +15 -15
- package/_site/lib/knowledge-db.js +363 -363
- package/_site/lib/knowledge-schema.js +121 -121
- package/_site/lib/live-gateway.js +78 -78
- package/_site/lib/llm-client.js +12 -12
- 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 +54 -54
- package/_site/lib/product-data.js +35 -35
- package/_site/lib/project-lifecycle-service.js +14 -14
- package/_site/lib/project-registry-store.js +129 -129
- package/_site/lib/prompt-registry.js +148 -148
- 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/runtime-control.js +89 -89
- package/_site/lib/runtime-endpoint.js +5 -5
- package/_site/lib/zcode-context-integration.js +60 -60
- package/_site/scripts/codex-notify-fanout.cjs +95 -95
- 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 +8 -8
- package/bin/project-knowledge.js +170 -170
- package/claude-prompts.json +21 -21
- package/docs/README.zh-CN.md +205 -205
- package/docs/assets/architecture.svg +181 -181
- package/docs/assets/logo.svg +49 -49
- package/docs/fresh-v5-start.md +42 -42
- package/docs/leader-glm-workbench-playbook.md +122 -122
- package/docs/project-registry-schema.md +11 -11
- 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 -25
- package/docs/team-knowledge-mode-a-plan.md +73 -73
- package/module-runtime-manifest.json +53 -33
- package/package.json +3 -2
- 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/plugins/project-knowledge/opencode/project-knowledge.md +3 -3
- package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +28 -28
- package/templates/change.md +30 -30
- package/templates/project-readme.md +18 -18
- package/ui/index.html +1 -1
- package/ui/knowledge-panel.html +118 -0
- package/ui/product.css +8 -0
- package/ui/product.js +146 -4
- package/vendor-manifest.json +55 -54
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const fs = require('node:fs');
|
|
3
|
-
const path = require('node:path');
|
|
4
|
-
const crypto = require('node:crypto');
|
|
5
|
-
|
|
6
|
-
async function verify({ url, projects, fixtureRoot, queries, reportPath }) {
|
|
7
|
-
const root = path.resolve(fixtureRoot);
|
|
8
|
-
const inside = file => { const relative = path.relative(root, path.resolve(file)); return relative && !relative.startsWith('..') && !path.isAbsolute(relative); };
|
|
9
|
-
const report = { passed: false, source: 'real engine and configured remote embeddings', startedAt: new Date().toISOString(), cases: [], metrics: {} };
|
|
10
|
-
const save = () => fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
|
|
11
|
-
let semanticHits = 0, vectorCases = 0, checkedCitations = 0, badCitations = 0, scopeLeaks = 0, deepReads = 0, snippetFactHits = 0;
|
|
12
|
-
for (const q of queries) {
|
|
13
|
-
const project = projects[q.project];
|
|
14
|
-
if (!project || !inside(project.knowledgePath)) throw new Error('gold corpus must be bound to an explicit isolated fixture root');
|
|
15
|
-
const item = { id: q.id, kind: q.kind, query: q.query, passed: false };
|
|
16
|
-
let hidden, target;
|
|
17
|
-
try {
|
|
18
|
-
if (q.kind === 'stale') {
|
|
19
|
-
target = path.resolve(project.knowledgePath, q.entry);
|
|
20
|
-
if (!inside(target) || fs.lstatSync(target).isSymbolicLink()) throw new Error('unsafe stale-test path');
|
|
21
|
-
hidden = path.join(root, `gold-hidden-${q.id}.md`);
|
|
22
|
-
if (fs.existsSync(hidden)) throw new Error('prior interrupted stale test needs recovery');
|
|
23
|
-
fs.renameSync(target, hidden);
|
|
24
|
-
}
|
|
25
|
-
const response = await fetch(new URL('/api/engine/search', url), { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
26
|
-
body: JSON.stringify({ projectId: project.projectId, scope: 'project', query: q.query, limit: 5 }), signal: AbortSignal.timeout(20000) });
|
|
27
|
-
const result = await response.json();
|
|
28
|
-
if (!response.ok) throw new Error(`search failed with HTTP ${response.status}`);
|
|
29
|
-
const rows = result.results || [];
|
|
30
|
-
item.health = result.health;
|
|
31
|
-
item.matchStatus = result.matchStatus;
|
|
32
|
-
item.results = rows;
|
|
33
|
-
let citationErrors = 0, leaks = 0;
|
|
34
|
-
for (const row of rows) {
|
|
35
|
-
checkedCitations++;
|
|
36
|
-
if (row.scope_project_id !== project.projectId) { leaks++; continue; }
|
|
37
|
-
const file = path.resolve(project.knowledgePath, row.entry_id);
|
|
38
|
-
if (!inside(file) || !fs.existsSync(file)) { citationErrors++; continue; }
|
|
39
|
-
const body = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
|
|
40
|
-
const snippet = String(row.chunk_text || '').replace(/\r\n/g, '\n');
|
|
41
|
-
const hash = crypto.createHash('sha256').update(snippet).digest('hex');
|
|
42
|
-
if (!snippet.trim() || !body.includes(snippet) || hash !== row.content_hash) citationErrors++;
|
|
43
|
-
}
|
|
44
|
-
badCitations += citationErrors; scopeLeaks += leaks;
|
|
45
|
-
const documentHit = rows.some(row => row.entry_id === q.entry);
|
|
46
|
-
const snippetFactHit = rows.some(row => row.entry_id === q.entry && (!q.fact || String(row.chunk_text).toLowerCase().includes(q.fact.toLowerCase())));
|
|
47
|
-
let factRetrieved = snippetFactHit;
|
|
48
|
-
if (q.fact && documentHit && !snippetFactHit) {
|
|
49
|
-
// Search locates documents; an agent may then get the selected entry.
|
|
50
|
-
// Record this separately rather than claiming a snippet contained it.
|
|
51
|
-
const detail = await fetch(new URL('/api/engine/get', url), { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
52
|
-
body: JSON.stringify({ projectId: project.projectId, entryId: q.entry, scope: 'project' }), signal: AbortSignal.timeout(10000) });
|
|
53
|
-
const full = await detail.json();
|
|
54
|
-
const text = full.chunks?.map(chunk => chunk.chunk_text).join('\n') || '';
|
|
55
|
-
const source = fs.readFileSync(path.resolve(project.knowledgePath, q.entry), 'utf8');
|
|
56
|
-
factRetrieved = detail.ok && text === source && text.toLowerCase().includes(q.fact.toLowerCase());
|
|
57
|
-
item.followupRead = { entry: q.entry, passed: factRetrieved, sha256: crypto.createHash('sha256').update(text).digest('hex') };
|
|
58
|
-
deepReads++;
|
|
59
|
-
}
|
|
60
|
-
item.documentHit = documentHit; item.snippetFactHit = snippetFactHit;
|
|
61
|
-
const vector = rows.some(row => row.match_channels?.includes('index:vector-hub')) && result.health?.vectorMode === 'verified-chunks';
|
|
62
|
-
if (q.kind === 'semantic') { if (documentHit) semanticHits++; if (vector) vectorCases++; if (snippetFactHit) snippetFactHits++; }
|
|
63
|
-
item.passed = !citationErrors && !leaks && (q.empty ? rows.length === 0
|
|
64
|
-
: q.kind === 'stale' ? rows.every(row => row.entry_id !== q.entry)
|
|
65
|
-
: q.kind === 'isolation' ? true : documentHit && factRetrieved && (q.kind !== 'semantic' || vector));
|
|
66
|
-
item.citationErrors = citationErrors; item.scopeLeaks = leaks;
|
|
67
|
-
} catch (error) { item.error = error.message; }
|
|
68
|
-
finally { if (hidden && fs.existsSync(hidden)) { if (fs.existsSync(target)) throw new Error('stale-test source changed concurrently; backup retained'); fs.renameSync(hidden, target); } }
|
|
69
|
-
report.cases.push(item); save();
|
|
70
|
-
console.log(`${item.passed ? 'PASS' : 'FAIL'} ${q.id} ${q.kind}`);
|
|
71
|
-
}
|
|
72
|
-
report.metrics = { semanticRecallAt5: semanticHits / queries.filter(q => q.kind === 'semantic').length, semanticSnippetFactCoverage: snippetFactHits / 10, followupEntryReads: deepReads, semanticVectorCases: vectorCases, checkedCitations, badCitations, scopeLeaks };
|
|
73
|
-
report.passed = report.cases.every(c => c.passed) && report.metrics.semanticRecallAt5 >= 0.9 && vectorCases === 10 && !badCitations && !scopeLeaks;
|
|
74
|
-
report.finishedAt = new Date().toISOString(); save();
|
|
75
|
-
return report;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (require.main === module) {
|
|
79
|
-
const env = JSON.parse(fs.readFileSync(path.resolve(process.argv[2]), 'utf8'));
|
|
80
|
-
const queries = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../_test/fixtures/retrieval-gold-queries.json'), 'utf8'));
|
|
81
|
-
verify({ ...env, queries, reportPath: path.resolve(process.argv[3]) }).then(report => { console.log(JSON.stringify(report.metrics)); process.exitCode = report.passed ? 0 : 1; }).catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
82
|
-
}
|
|
83
|
-
module.exports = { verify };
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const crypto = require('node:crypto');
|
|
5
|
+
|
|
6
|
+
async function verify({ url, projects, fixtureRoot, queries, reportPath }) {
|
|
7
|
+
const root = path.resolve(fixtureRoot);
|
|
8
|
+
const inside = file => { const relative = path.relative(root, path.resolve(file)); return relative && !relative.startsWith('..') && !path.isAbsolute(relative); };
|
|
9
|
+
const report = { passed: false, source: 'real engine and configured remote embeddings', startedAt: new Date().toISOString(), cases: [], metrics: {} };
|
|
10
|
+
const save = () => fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
|
|
11
|
+
let semanticHits = 0, vectorCases = 0, checkedCitations = 0, badCitations = 0, scopeLeaks = 0, deepReads = 0, snippetFactHits = 0;
|
|
12
|
+
for (const q of queries) {
|
|
13
|
+
const project = projects[q.project];
|
|
14
|
+
if (!project || !inside(project.knowledgePath)) throw new Error('gold corpus must be bound to an explicit isolated fixture root');
|
|
15
|
+
const item = { id: q.id, kind: q.kind, query: q.query, passed: false };
|
|
16
|
+
let hidden, target;
|
|
17
|
+
try {
|
|
18
|
+
if (q.kind === 'stale') {
|
|
19
|
+
target = path.resolve(project.knowledgePath, q.entry);
|
|
20
|
+
if (!inside(target) || fs.lstatSync(target).isSymbolicLink()) throw new Error('unsafe stale-test path');
|
|
21
|
+
hidden = path.join(root, `gold-hidden-${q.id}.md`);
|
|
22
|
+
if (fs.existsSync(hidden)) throw new Error('prior interrupted stale test needs recovery');
|
|
23
|
+
fs.renameSync(target, hidden);
|
|
24
|
+
}
|
|
25
|
+
const response = await fetch(new URL('/api/engine/search', url), { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
26
|
+
body: JSON.stringify({ projectId: project.projectId, scope: 'project', query: q.query, limit: 5 }), signal: AbortSignal.timeout(20000) });
|
|
27
|
+
const result = await response.json();
|
|
28
|
+
if (!response.ok) throw new Error(`search failed with HTTP ${response.status}`);
|
|
29
|
+
const rows = result.results || [];
|
|
30
|
+
item.health = result.health;
|
|
31
|
+
item.matchStatus = result.matchStatus;
|
|
32
|
+
item.results = rows;
|
|
33
|
+
let citationErrors = 0, leaks = 0;
|
|
34
|
+
for (const row of rows) {
|
|
35
|
+
checkedCitations++;
|
|
36
|
+
if (row.scope_project_id !== project.projectId) { leaks++; continue; }
|
|
37
|
+
const file = path.resolve(project.knowledgePath, row.entry_id);
|
|
38
|
+
if (!inside(file) || !fs.existsSync(file)) { citationErrors++; continue; }
|
|
39
|
+
const body = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
|
|
40
|
+
const snippet = String(row.chunk_text || '').replace(/\r\n/g, '\n');
|
|
41
|
+
const hash = crypto.createHash('sha256').update(snippet).digest('hex');
|
|
42
|
+
if (!snippet.trim() || !body.includes(snippet) || hash !== row.content_hash) citationErrors++;
|
|
43
|
+
}
|
|
44
|
+
badCitations += citationErrors; scopeLeaks += leaks;
|
|
45
|
+
const documentHit = rows.some(row => row.entry_id === q.entry);
|
|
46
|
+
const snippetFactHit = rows.some(row => row.entry_id === q.entry && (!q.fact || String(row.chunk_text).toLowerCase().includes(q.fact.toLowerCase())));
|
|
47
|
+
let factRetrieved = snippetFactHit;
|
|
48
|
+
if (q.fact && documentHit && !snippetFactHit) {
|
|
49
|
+
// Search locates documents; an agent may then get the selected entry.
|
|
50
|
+
// Record this separately rather than claiming a snippet contained it.
|
|
51
|
+
const detail = await fetch(new URL('/api/engine/get', url), { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
52
|
+
body: JSON.stringify({ projectId: project.projectId, entryId: q.entry, scope: 'project' }), signal: AbortSignal.timeout(10000) });
|
|
53
|
+
const full = await detail.json();
|
|
54
|
+
const text = full.chunks?.map(chunk => chunk.chunk_text).join('\n') || '';
|
|
55
|
+
const source = fs.readFileSync(path.resolve(project.knowledgePath, q.entry), 'utf8');
|
|
56
|
+
factRetrieved = detail.ok && text === source && text.toLowerCase().includes(q.fact.toLowerCase());
|
|
57
|
+
item.followupRead = { entry: q.entry, passed: factRetrieved, sha256: crypto.createHash('sha256').update(text).digest('hex') };
|
|
58
|
+
deepReads++;
|
|
59
|
+
}
|
|
60
|
+
item.documentHit = documentHit; item.snippetFactHit = snippetFactHit;
|
|
61
|
+
const vector = rows.some(row => row.match_channels?.includes('index:vector-hub')) && result.health?.vectorMode === 'verified-chunks';
|
|
62
|
+
if (q.kind === 'semantic') { if (documentHit) semanticHits++; if (vector) vectorCases++; if (snippetFactHit) snippetFactHits++; }
|
|
63
|
+
item.passed = !citationErrors && !leaks && (q.empty ? rows.length === 0
|
|
64
|
+
: q.kind === 'stale' ? rows.every(row => row.entry_id !== q.entry)
|
|
65
|
+
: q.kind === 'isolation' ? true : documentHit && factRetrieved && (q.kind !== 'semantic' || vector));
|
|
66
|
+
item.citationErrors = citationErrors; item.scopeLeaks = leaks;
|
|
67
|
+
} catch (error) { item.error = error.message; }
|
|
68
|
+
finally { if (hidden && fs.existsSync(hidden)) { if (fs.existsSync(target)) throw new Error('stale-test source changed concurrently; backup retained'); fs.renameSync(hidden, target); } }
|
|
69
|
+
report.cases.push(item); save();
|
|
70
|
+
console.log(`${item.passed ? 'PASS' : 'FAIL'} ${q.id} ${q.kind}`);
|
|
71
|
+
}
|
|
72
|
+
report.metrics = { semanticRecallAt5: semanticHits / queries.filter(q => q.kind === 'semantic').length, semanticSnippetFactCoverage: snippetFactHits / 10, followupEntryReads: deepReads, semanticVectorCases: vectorCases, checkedCitations, badCitations, scopeLeaks };
|
|
73
|
+
report.passed = report.cases.every(c => c.passed) && report.metrics.semanticRecallAt5 >= 0.9 && vectorCases === 10 && !badCitations && !scopeLeaks;
|
|
74
|
+
report.finishedAt = new Date().toISOString(); save();
|
|
75
|
+
return report;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (require.main === module) {
|
|
79
|
+
const env = JSON.parse(fs.readFileSync(path.resolve(process.argv[2]), 'utf8'));
|
|
80
|
+
const queries = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../_test/fixtures/retrieval-gold-queries.json'), 'utf8'));
|
|
81
|
+
verify({ ...env, queries, reportPath: path.resolve(process.argv[3]) }).then(report => { console.log(JSON.stringify(report.metrics)); process.exitCode = report.passed ? 0 : 1; }).catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
82
|
+
}
|
|
83
|
+
module.exports = { verify };
|
package/_site/server.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Project Knowledge v2 HTTP entry point.
|
|
2
|
-
const { startServer, installProcessHandlers } = require('./lib/server-app');
|
|
3
|
-
|
|
4
|
-
const instancePromise = startServer();
|
|
5
|
-
installProcessHandlers(instancePromise);
|
|
6
|
-
module.exports = instancePromise;
|
|
7
|
-
|
|
8
|
-
instancePromise.then(instance => {
|
|
9
|
-
process.stdout.write(`Project Knowledge listening on http://${instance.host}:${instance.port}\n`);
|
|
10
|
-
}).catch(error => {
|
|
11
|
-
if (require.main === module) {
|
|
12
|
-
process.stderr.write(`[project-knowledge] startup failed: ${String(error && error.message || error)}\n`);
|
|
13
|
-
process.exitCode = 1;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
1
|
+
// Project Knowledge v2 HTTP entry point.
|
|
2
|
+
const { startServer, installProcessHandlers } = require('./lib/server-app');
|
|
3
|
+
|
|
4
|
+
const instancePromise = startServer();
|
|
5
|
+
installProcessHandlers(instancePromise);
|
|
6
|
+
module.exports = instancePromise;
|
|
7
|
+
|
|
8
|
+
instancePromise.then(instance => {
|
|
9
|
+
process.stdout.write(`Project Knowledge listening on http://${instance.host}:${instance.port}\n`);
|
|
10
|
+
}).catch(error => {
|
|
11
|
+
if (require.main === module) {
|
|
12
|
+
process.stderr.write(`[project-knowledge] startup failed: ${String(error && error.message || error)}\n`);
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
}
|
|
15
|
+
});
|
package/_site/start.bat
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal
|
|
3
|
-
|
|
4
|
-
REM KB Management Site launcher — double-click to start
|
|
5
|
-
set KB_SITE=%~dp0
|
|
6
|
-
set PORT=5757
|
|
7
|
-
|
|
8
|
-
REM Check if already running
|
|
9
|
-
netstat -ano | findstr ":%PORT% " | findstr "LISTENING" >nul 2>&1
|
|
10
|
-
if %ERRORLEVEL%==0 (
|
|
11
|
-
echo [kb-site] Already running on port %PORT%. Opening browser...
|
|
12
|
-
start "" "http://localhost:%PORT%/"
|
|
13
|
-
goto :eof
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
echo [kb-site] Starting server on port %PORT%...
|
|
17
|
-
start "KB-Site" /min cmd /c "cd /d "%KB_SITE%" && node server.js"
|
|
18
|
-
timeout /t 2 /nobreak >nul
|
|
19
|
-
|
|
20
|
-
REM Open browser
|
|
21
|
-
start "" "http://localhost:%PORT%/"
|
|
22
|
-
|
|
23
|
-
echo.
|
|
24
|
-
echo [kb-site] Server started. To stop: close the "KB-Site" window, or run stop.bat
|
|
25
|
-
echo.
|
|
26
|
-
pause
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
|
|
4
|
+
REM KB Management Site launcher — double-click to start
|
|
5
|
+
set KB_SITE=%~dp0
|
|
6
|
+
set PORT=5757
|
|
7
|
+
|
|
8
|
+
REM Check if already running
|
|
9
|
+
netstat -ano | findstr ":%PORT% " | findstr "LISTENING" >nul 2>&1
|
|
10
|
+
if %ERRORLEVEL%==0 (
|
|
11
|
+
echo [kb-site] Already running on port %PORT%. Opening browser...
|
|
12
|
+
start "" "http://localhost:%PORT%/"
|
|
13
|
+
goto :eof
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
echo [kb-site] Starting server on port %PORT%...
|
|
17
|
+
start "KB-Site" /min cmd /c "cd /d "%KB_SITE%" && node server.js"
|
|
18
|
+
timeout /t 2 /nobreak >nul
|
|
19
|
+
|
|
20
|
+
REM Open browser
|
|
21
|
+
start "" "http://localhost:%PORT%/"
|
|
22
|
+
|
|
23
|
+
echo.
|
|
24
|
+
echo [kb-site] Server started. To stop: close the "KB-Site" window, or run stop.bat
|
|
25
|
+
echo.
|
|
26
|
+
pause
|
package/_site/stop.bat
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal
|
|
3
|
-
set PORT=5757
|
|
4
|
-
|
|
5
|
-
echo [kb-site] Stopping server on port %PORT%...
|
|
6
|
-
for /f "tokens=5" %%P in ('netstat -ano ^| findstr ":%PORT% " ^| findstr "LISTENING"') do (
|
|
7
|
-
taskkill /F /PID %%P >nul 2>&1
|
|
8
|
-
echo [kb-site] Killed PID %%P
|
|
9
|
-
)
|
|
10
|
-
echo Done.
|
|
11
|
-
pause
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
set PORT=5757
|
|
4
|
+
|
|
5
|
+
echo [kb-site] Stopping server on port %PORT%...
|
|
6
|
+
for /f "tokens=5" %%P in ('netstat -ano ^| findstr ":%PORT% " ^| findstr "LISTENING"') do (
|
|
7
|
+
taskkill /F /PID %%P >nul 2>&1
|
|
8
|
+
echo [kb-site] Killed PID %%P
|
|
9
|
+
)
|
|
10
|
+
echo Done.
|
|
11
|
+
pause
|