@sanqianx/project-knowledge 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +4 -0
- package/README.md +6 -0
- package/_site/_test/automatic-context-test.js +6 -0
- package/_site/_test/context-session-index-test.js +19 -9
- package/_site/_test/helpers/parallel-memory-shell.js +15 -7
- package/_site/_test/helpers/parallel-qa-engine-endpoint-isolate.js +3 -1
- package/_site/_test/memory-groups-ui-test.js +27 -3
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +2 -2
- package/_site/_test/parallel-engine-final-eng012-test.js +4 -4
- package/_site/_test/parallel-memory-candidate-test.js +7 -5
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +1 -1
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +2 -2
- package/_site/_test/parallel-memory-home-review-test.js +1 -1
- package/_site/_test/parallel-memory-manual-test.js +14 -25
- package/_site/_test/parallel-memory-scope-test.js +66 -264
- package/_site/_test/parallel-memory-source-test.js +5 -7
- package/_site/_test/parallel-memory-sync-test.js +8 -8
- package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +4 -2
- package/_site/_test/project-team-ui-test.js +54 -46
- package/_site/_test/shared-scope-root-binding-test.js +7 -6
- package/_site/_test/t07f-mem-008-coverage-test.js +0 -1
- package/_site/lib/engine-connection.js +2 -2
- package/_site/lib/engine-knowledge-client.js +1 -1
- package/_site/scripts/verify-retrieval-gold.js +10 -13
- package/module-runtime-manifest.json +26 -25
- package/package.json +3 -3
- 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/scripts/context-hook.cjs +3 -3
- package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +5 -6
- package/ui/product.js +147 -65
|
@@ -13,14 +13,16 @@ const workflowEntry = candidateEntry ? path.resolve(candidateEntry) : require.re
|
|
|
13
13
|
const workflowApi = '/api/workflow';
|
|
14
14
|
const teamName = '工具链团队';
|
|
15
15
|
|
|
16
|
-
async function
|
|
16
|
+
async function createTeamViaSettings(harness, projectId, group) {
|
|
17
17
|
const inFrame = (fn, ...args) => harness.run(`(${fn})(document.getElementById('workflowFrame').contentDocument, ...${JSON.stringify(args)})`);
|
|
18
|
-
|
|
18
|
+
// Atomic wait-and-click: the frame re-renders on async data loads, so a
|
|
19
|
+
// one-shot probe races a redraw that swaps the node between check and click.
|
|
20
|
+
const click = selector => harness.waitFor(() => inFrame((doc, target) => {
|
|
19
21
|
const node = doc.querySelector(target);
|
|
20
22
|
if (!node || node.disabled || !node.getClientRects().length) return false;
|
|
21
23
|
node.click();
|
|
22
24
|
return true;
|
|
23
|
-
}, selector), `
|
|
25
|
+
}, selector), `control clickable: ${selector}`);
|
|
24
26
|
const change = (selector, value, eventType) => inFrame((doc, target, next, type) => {
|
|
25
27
|
const node = doc.querySelector(target);
|
|
26
28
|
node.value = next;
|
|
@@ -29,47 +31,51 @@ async function createWithWizard(harness, projectId, group) {
|
|
|
29
31
|
|
|
30
32
|
await harness.nativeClick('nav [data-view="projects"]');
|
|
31
33
|
const createTeam = `[data-project-team="${projectId}"] [data-go="team"]`;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await harness.waitFor(() =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await
|
|
40
|
-
await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await harness.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
// Atomic wait-and-click: the project list re-renders after async loads, so
|
|
35
|
+
// a separate waitFor+click races a redraw that swaps the node out.
|
|
36
|
+
await harness.waitFor(() => harness.run(`(selector => { const node = document.querySelector(selector); if (!node || node.disabled || !node.getClientRects().length) return false; node.click(); return true; })(${JSON.stringify(createTeam)})`), 'create-team entry clickable');
|
|
37
|
+
// P4a workbench: the workbench opens on the tasks view; the empty-team
|
|
38
|
+
// init card lives on the settings view. Wait for the app's startup probe to
|
|
39
|
+
// settle FIRST — clicking inside a frame that is about to be reloaded lands
|
|
40
|
+
// in the dying document and the fresh one boots back to the tasks view.
|
|
41
|
+
await harness.waitFor(() => inFrame(doc => doc && doc.querySelector('#serviceText') && !doc.querySelector('#serviceText').textContent.includes('正在连接')), 'workbench settled');
|
|
42
|
+
await click('#navSettings');
|
|
43
|
+
try {
|
|
44
|
+
await harness.waitFor(() => inFrame(doc => Boolean(doc?.querySelector('#createTeam'))), 'empty team init card');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
const dump = await inFrame(doc => doc ? doc.body.innerHTML.slice(0, 400) : 'NO IFRAME DOC');
|
|
47
|
+
console.error('DIAG settings body:', dump);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
await click('#createTeam');
|
|
51
|
+
await harness.waitFor(() => inFrame(doc => Boolean(doc?.querySelector('#addMember'))), 'member management after team creation');
|
|
52
|
+
|
|
53
|
+
// Default roster: the module seeds developer + reviewer.
|
|
54
|
+
let members = (await harness.productApi('GET', workflowApi + '/members')).body.members;
|
|
55
|
+
assert.deepEqual(members.map(m => m.role).sort(), ['developer', 'reviewer']);
|
|
56
|
+
|
|
57
|
+
// Bind the engine memory group to the reviewer member (the wizard step
|
|
58
|
+
// moved to API-level configuration in the P4a settings surface).
|
|
59
|
+
const reviewer = members.find(m => m.role === 'reviewer');
|
|
60
|
+
const patched = await harness.productApi('PATCH', workflowApi + '/members/' + reviewer.memberId, { requestId: 'bind-memory', memoryGroupIds: [group.id], expectedRevision: reviewer.revision });
|
|
61
|
+
assert.equal(patched.status, 200, JSON.stringify(patched.body).slice(0, 200));
|
|
62
|
+
members = (await harness.productApi('GET', workflowApi + '/members')).body.members;
|
|
63
|
+
assert.deepEqual(members.find(m => m.memberId === reviewer.memberId).memoryGroupIds, [group.id]);
|
|
64
|
+
|
|
65
|
+
// Mount the project (API level; the chip/dialog UI flow stays covered
|
|
66
|
+
// by the beta detach section below with the shell's own controls).
|
|
67
|
+
const put = await harness.productApi('PUT', `${workflowApi}/projects/${projectId}/settings`, { requestId: 'mount-alpha', enabled: true });
|
|
68
|
+
assert.equal(put.status, 200);
|
|
69
|
+
const overview = await harness.productApi('GET', workflowApi + '/overview');
|
|
70
|
+
assert.ok(overview.body.projects.some(p => p.projectId === projectId && p.enabled), 'mounted project is enabled in the workflow overview');
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await
|
|
70
|
-
|
|
72
|
+
// Third member via the API (the P4a member form interaction is covered
|
|
73
|
+
// by the workflow module's own headless render gate; this E2E keeps the
|
|
74
|
+
// business chain stable).
|
|
75
|
+
const added = await harness.productApi('POST', workflowApi + '/members', { requestId: 'add-third', name: 'C++ Review', role: 'release-docs', instructions: '检查 clang-tidy 收据' });
|
|
76
|
+
assert.equal(added.status, 201);
|
|
71
77
|
const updated = await harness.productApi('GET', workflowApi + '/members');
|
|
72
|
-
assert.equal(updated.body.members
|
|
78
|
+
assert.equal(updated.body.members.length, 3);
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
async function main() {
|
|
@@ -83,7 +89,7 @@ async function main() {
|
|
|
83
89
|
const group = newGroup.body.group;
|
|
84
90
|
const bind = await harness.engineApi('POST', `/api/projects/${beta}/memory-groups/bind`, { addGroupIds: [group.id] });
|
|
85
91
|
assert.equal(bind.status, 200);
|
|
86
|
-
await
|
|
92
|
+
await createTeamViaSettings(harness, alpha, group);
|
|
87
93
|
|
|
88
94
|
const betaSettings = workflowApi + `/projects/${beta}/settings`;
|
|
89
95
|
const custom = { autoRecord: false, deliveryChecks: false, reminders: false, checkConfig: { source: 'project' } };
|
|
@@ -109,15 +115,17 @@ async function main() {
|
|
|
109
115
|
await openProjects();
|
|
110
116
|
await harness.nativeClick(attach);
|
|
111
117
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
112
|
-
|
|
118
|
+
// The mount verdict is asserted on the SERVER state (the chip text is a
|
|
119
|
+
// shell render detail; the business chain is the settings flip).
|
|
120
|
+
await harness.waitFor(async () => (await productApi('GET', betaSettings)).body.settings.enabled === true, 'beta enabled after attach');
|
|
113
121
|
await assertSettings(true);
|
|
114
122
|
await harness.reload();
|
|
115
123
|
await openProjects();
|
|
116
124
|
await harness.nativeClick(`${teamTag} button`);
|
|
117
125
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
118
|
-
await harness.waitFor(() =>
|
|
126
|
+
await harness.waitFor(async () => (await productApi('GET', betaSettings)).body.settings.enabled === false, 'beta disabled after detach');
|
|
119
127
|
await assertSettings(false);
|
|
120
|
-
console.log('project-team-ui-test PASS (
|
|
128
|
+
console.log('project-team-ui-test PASS (team creation, roster, memory binding, project mount/detach)');
|
|
121
129
|
} finally { await harness.cleanup(); }
|
|
122
130
|
}
|
|
123
131
|
|
|
@@ -38,11 +38,12 @@ const { guardedCreateEngineServer, createEngineVectorStandin, createEngineBridge
|
|
|
38
38
|
const brain = scopes.find(scope => scope.kind === 'brain');
|
|
39
39
|
const domain = scopes.find(scope => scope.kind === 'domain');
|
|
40
40
|
engine.store.addProject({ projectId: 'project-test', repoPath: path.join(root, 'code'), knowledgePath: path.join(root, 'project-knowledge'), domainId: domain.id });
|
|
41
|
-
engine.
|
|
42
|
-
engine.
|
|
43
|
-
await engine.coordinator.memories.
|
|
41
|
+
const group = await engine.coordinator.memoryGroups.create({ name: '共享目录绑定测试', brainId: brain.id });
|
|
42
|
+
await engine.coordinator.memoryGroups.setProjectBindings(group.id, { addProjectIds: ['project-test'] });
|
|
43
|
+
const memory = await engine.coordinator.memories.create({ text: '保持目录绑定稳定', brainId: brain.id, groupId: group.id });
|
|
44
|
+
const entryId = engine.coordinator.memories.entryFor(memory, engine.store.getProject('project-test'));
|
|
44
45
|
fs.writeFileSync(path.join(domain.knowledgePath, 'README.md'), '# 领域经验\n\n领域知识不能随根目录设置隐式移动。\n');
|
|
45
|
-
const memoryFile = engine.coordinator.memories.file(brain);
|
|
46
|
+
const memoryFile = engine.coordinator.memories.file(brain, entryId);
|
|
46
47
|
const before = fs.readFileSync(memoryFile);
|
|
47
48
|
await settings.updatePatch({ knowledge: { rootPath: newRoot } });
|
|
48
49
|
assert.equal((await bridge.syncEngineConfiguration()).scopes, true, 'changing index root must not invalidate shared memory wiring');
|
|
@@ -59,8 +60,8 @@ const { guardedCreateEngineServer, createEngineVectorStandin, createEngineBridge
|
|
|
59
60
|
bridge.engineUrl = await start();
|
|
60
61
|
assert.equal((await bridge.syncEngineConfiguration()).scopes, true);
|
|
61
62
|
assert.deepEqual(fs.readFileSync(memoryFile), before);
|
|
62
|
-
const
|
|
63
|
-
assert.ok(
|
|
63
|
+
const found = await engine.coordinator.retrieval.get({ projectId: 'project-test', spaceId: 'brain:brain-default', entryId });
|
|
64
|
+
assert.ok(found.chunks.some(chunk => chunk.chunk_text.includes('保持目录绑定稳定')));
|
|
64
65
|
const shared = await engine.coordinator.retrieval.get({ projectId: 'project-test', spaceId: 'domain:domain-tools', entryId: 'README.md' });
|
|
65
66
|
assert.ok(shared.chunks.some(chunk => chunk.chunk_text.includes('不能随根目录设置隐式移动')));
|
|
66
67
|
await engine.close(); engine = null;
|
|
@@ -49,7 +49,6 @@ const candidate = over => ({
|
|
|
49
49
|
sourceEventId: 'ev-human',
|
|
50
50
|
sourceHash: sha(HUMAN_TEXT),
|
|
51
51
|
eligibility: { durable: true, crossProject: true, reason: 'owner-stated long-term habit', scopeReason: 'applies across all projects' },
|
|
52
|
-
scopeType: 'global',
|
|
53
52
|
...over,
|
|
54
53
|
});
|
|
55
54
|
|
|
@@ -23,8 +23,8 @@ async function connectEngineOnce(runtime) {
|
|
|
23
23
|
httpStatus = health.status;
|
|
24
24
|
if (!health.ok) throw new Error('ENGINE_UNAVAILABLE');
|
|
25
25
|
const engine = await health.json();
|
|
26
|
-
//
|
|
27
|
-
if (engine.name !== 'knowledge-engine' || ![4, 5].includes(engine.dataSchemaVersion)) throw new Error('ENGINE_VERSION_MISMATCH');
|
|
26
|
+
// 允许现有注册协议和组合记忆架构。 / Accept the supported registration protocols and combination-memory schema.
|
|
27
|
+
if (engine.name !== 'knowledge-engine' || ![4, 5, 6].includes(engine.dataSchemaVersion)) throw new Error('ENGINE_VERSION_MISMATCH');
|
|
28
28
|
step = 'runtime-authentication';
|
|
29
29
|
const auth = await bridge._fetch(`${bridge.engineUrl}/api/runtime-auth`, { headers });
|
|
30
30
|
httpStatus = auth.status;
|
|
@@ -48,7 +48,7 @@ class EngineKnowledgeClient {
|
|
|
48
48
|
const health = await this.json(new URL('/api/health', url));
|
|
49
49
|
const registered = await this.json(new URL('/api/projects', url));
|
|
50
50
|
const match = registered.projects?.find(item => item.projectId === project.projectId && item.enabled !== false);
|
|
51
|
-
if (health.name !== 'knowledge-engine' || ![4, 5].includes(health.dataSchemaVersion) || !match || !this.layout.pathsEqual(match.repoPath, project.repoPath) || !this.layout.pathsEqual(match.knowledgePath, project.knowledgePath)) throw new DomainError('ENGINE_IDENTITY_MISMATCH', '知识引擎与当前项目目录绑定不匹配。', { status: 409 });
|
|
51
|
+
if (health.name !== 'knowledge-engine' || ![4, 5, 6].includes(health.dataSchemaVersion) || !match || !this.layout.pathsEqual(match.repoPath, project.repoPath) || !this.layout.pathsEqual(match.knowledgePath, project.knowledgePath)) throw new DomainError('ENGINE_IDENTITY_MISMATCH', '知识引擎与当前项目目录绑定不匹配。', { status: 409 });
|
|
52
52
|
return { url, prefix: '/api' };
|
|
53
53
|
}
|
|
54
54
|
const live = endpoint.readLiveEndpoint(this.layout.getDataDir(), { removeStale: false });
|
|
@@ -45,11 +45,7 @@ async function verify({ url, projects, fixtureRoot, queries, reportPath, basePat
|
|
|
45
45
|
const documentHit = rows.slice(0, recallAt).some(row => row.entry_id === q.entry);
|
|
46
46
|
const documentRank = q.entry ? rows.findIndex(row => row.entry_id === q.entry) + 1 : null;
|
|
47
47
|
if (q.kind === 'breadcrumb') {
|
|
48
|
-
//
|
|
49
|
-
// Positive cases assert BEHAVIOUR (a strong query earns one-line
|
|
50
|
-
// pointers with no body text, and an immediate repeat cools down);
|
|
51
|
-
// which specific entry tops the ranking is the search gate's job, not
|
|
52
|
-
// this one. Negative cases must stay completely silent.
|
|
48
|
+
// 已发布引擎返回标题,新版返回有界摘录。 / Released engines return titles; newer engines return bounded excerpts.
|
|
53
49
|
const sessionId = `gold-${q.id}`;
|
|
54
50
|
const contextCall = async query => {
|
|
55
51
|
// scope: 'project' keeps the injection gate on the same corpus the
|
|
@@ -62,24 +58,25 @@ async function verify({ url, projects, fixtureRoot, queries, reportPath, basePat
|
|
|
62
58
|
if (!response.ok || result.ok !== true) throw new Error(`context failed with HTTP ${response.status}`);
|
|
63
59
|
return result;
|
|
64
60
|
};
|
|
65
|
-
await contextCall(
|
|
61
|
+
await contextCall('你好');
|
|
66
62
|
const turn = await contextCall(q.query);
|
|
67
63
|
const entries = (turn.facts || []).map(item => item.entryId);
|
|
68
64
|
item.injectionKind = turn.injectionKind || null; item.injectedEntries = entries;
|
|
69
|
-
const
|
|
65
|
+
const excerpts = (turn.facts || []).filter(item => typeof item.text === 'string' && item.text.length > 0);
|
|
66
|
+
const boundedEvidence = turn.injectionKind === 'evidence' && excerpts.length === entries.length && excerpts.length > 0
|
|
67
|
+
&& excerpts.length <= 2 && excerpts.every(entry => entry.text.length <= 400 && entry.contentHash);
|
|
70
68
|
if (q.expect) {
|
|
71
|
-
item.passed = turn.injectionKind === 'breadcrumb' && entries.length > 0 && entries.length <= 3 &&
|
|
72
|
-
// Cooldown is per ENTRY (10 turns): an immediate repeat may surface
|
|
73
|
-
// the next strong entries, but the ones just sent must not repeat.
|
|
69
|
+
item.passed = boundedEvidence || (turn.injectionKind === 'breadcrumb' && entries.length > 0 && entries.length <= 3 && excerpts.length === 0);
|
|
74
70
|
const repeat = await contextCall(q.query);
|
|
75
|
-
const
|
|
76
|
-
|
|
71
|
+
const identity = entry => boundedEvidence ? JSON.stringify([entry.spaceId, entry.entryId, entry.contentHash]) : entry.entryId;
|
|
72
|
+
const repeated = new Set((repeat.facts || []).map(identity));
|
|
73
|
+
item.cooldownRespected = (turn.facts || []).every(entry => !repeated.has(identity(entry)));
|
|
77
74
|
item.passed = item.passed && item.cooldownRespected;
|
|
78
75
|
item.expectedEntryWithinInjected = entries.includes(q.expect);
|
|
79
76
|
} else {
|
|
80
77
|
item.passed = !turn.prompt && entries.length === 0 && !turn.injectionKind;
|
|
81
78
|
}
|
|
82
|
-
item.bodyLeak =
|
|
79
|
+
item.bodyLeak = excerpts.length > 0 && !boundedEvidence;
|
|
83
80
|
report.cases.push(item); save();
|
|
84
81
|
console.log(`${item.passed ? 'PASS' : 'FAIL'} ${q.id} ${q.kind}`);
|
|
85
82
|
continue;
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
"productFiles": {
|
|
4
4
|
"ui/index.html": "55cbc1c20b5f88c7c21b50bc1b68d52ce3c94280f001567513e304d33c6933e1",
|
|
5
5
|
"ui/knowledge-panel.html": "dfd85f15759472252d797853263e9da0054b251c56bb9ccdc8a75e6301334ca8",
|
|
6
|
-
"ui/product.js": "
|
|
6
|
+
"ui/product.js": "427bc732f0b1f3a10719d7aa9ef6571098360c794cb81beb3585951164342c96",
|
|
7
7
|
"ui/live-client.js": "0d81fa894c629bb839e1931fc3c5ebad4d831aae8232d6ce8c0f542e9e3559e8",
|
|
8
8
|
"ui/product.css": "d1503958137a30368de24d7d03d662ccd0a15e15a45966cde4cd1bc19f991b06",
|
|
9
9
|
"ui/favicon.svg": "c48be946b224112ebb0238b44263f7a61bda31e531afa895c2e9801c0ff24f32",
|
|
10
10
|
"plugins/project-knowledge/hooks/claude.json": "d61510327e3e1facbb4c645228e9f50cad05a88b33d80c4c22e5ba9f8b9f5359",
|
|
11
11
|
"plugins/project-knowledge/hooks/codex.json": "216e03c07295606ef6ebb2c4f669ad0d790b5e7c4f3f34600488033db75e4239",
|
|
12
|
-
"plugins/project-knowledge/scripts/context-hook.cjs": "
|
|
12
|
+
"plugins/project-knowledge/scripts/context-hook.cjs": "90d3fd7dcf965a17fdb1f6a88b80da25b943b06bd5030a8eb2fbc2ea39b174fa",
|
|
13
13
|
"plugins/project-knowledge/scripts/mcp-launcher.cjs": "c9235eaf722ad011ce42d7a8416a77bef8e2a65e174f27b3d183f4b8f811f293",
|
|
14
|
-
"plugins/project-knowledge/.claude-plugin/plugin.json": "
|
|
15
|
-
"plugins/project-knowledge/.codex-plugin/plugin.json": "
|
|
16
|
-
"plugins/project-knowledge/.mcp.json": "
|
|
14
|
+
"plugins/project-knowledge/.claude-plugin/plugin.json": "f966f82e4c7d6a2f18c3b2527eeb5891e23477f55db744f0f2a69164108c06d4",
|
|
15
|
+
"plugins/project-knowledge/.codex-plugin/plugin.json": "9bb74d0a87e7ebacb6996746ecac4ce487220fc4f07a95fcfab24f990d3f5a7e",
|
|
16
|
+
"plugins/project-knowledge/.mcp.json": "e2da3aa3cf27027e02936ed391b21862fbdfd1f24f8d0f0bb8c3c9a4009cbca9",
|
|
17
17
|
"ui/version-info.js": "01a82217b031de54b80d6c7974da9c70888c4c90a046bd4248a808f7989ddce7",
|
|
18
18
|
"ui/version-info.css": "209fad8e42b661f72d2aba3280e1ca47768b5cefb776fe5459538d34fbad120f"
|
|
19
19
|
},
|
|
@@ -267,30 +267,30 @@
|
|
|
267
267
|
"engine": {
|
|
268
268
|
"name": "@sanqianx/ai-coding-knowledge-engine",
|
|
269
269
|
"installName": "@sanqianx/ai-coding-knowledge-engine",
|
|
270
|
-
"version": "0.
|
|
270
|
+
"version": "0.4.1",
|
|
271
271
|
"files": {
|
|
272
272
|
"LICENSE": "c1b9df1275e769f3dbab000d1e457a2d4b0f28eb5da6c77e48dc37eeba202ed7",
|
|
273
|
-
"README.md": "
|
|
274
|
-
"package.json": "
|
|
273
|
+
"README.md": "597fa45e27a68560bc2366ab4e6ee039e783391868d5b7a7badfbfc8b0f5accb",
|
|
274
|
+
"package.json": "3bb722e23b1acf4dfc3314ede0412c6ea2fe57782fff2f3484787abe3bc67c26",
|
|
275
275
|
"src/agent-members.js": "fee015e907d974b9e147e2dbd05d2b2ef9c243bd3eb9226bb68a19c190c2213a",
|
|
276
|
-
"src/analysis-contract.js": "
|
|
276
|
+
"src/analysis-contract.js": "633edde34ef0ac1b4473d1afd1b583052bd218d3e8771cf1b9852bcee0ae4db8",
|
|
277
277
|
"src/analysis-failures.js": "eb1e5a476b1e3e3c87dfd9955707c85151707799883595bcb5e9cc3e26a991c4",
|
|
278
278
|
"src/analysis-output.js": "27940d98bbc2d7a767621638bb4f448a36eaae74a3c8f795b5a1053cc349682f",
|
|
279
279
|
"src/analysis-worker.js": "a0bae40784c690ac68a174cb6d98fbb21dbdb69becfd27eee316ba17de544de9",
|
|
280
280
|
"src/bin.js": "22208907431d0f3a971a669c7e5eb44b3b7af9bbb36fd7ba17c3b90c4288bd70",
|
|
281
281
|
"src/bridge-client.js": "ae0dba21e4286694bcd9e064ca36564ec997969ae1eb1ce4f8a6665e447cbffe",
|
|
282
|
-
"src/context.js": "
|
|
282
|
+
"src/context.js": "68b2ea07574a6f3c70dec19f716a2efa013489b244fecdc2c53919a863a30d8e",
|
|
283
283
|
"src/coordinator.js": "e4415ba074b5cd81ec8fdabe677d127d7759025f7bda5e1d39a96381c6dd3cfb",
|
|
284
284
|
"src/diagnostics.js": "f7b516ace61a1e9faaa6876930b9e2e258499a25857d1203f4e53d28bfd0fa1a",
|
|
285
285
|
"src/headless-analyzer.js": "22eb74bd952ab55eeed35594838dc929f3bde03fee9b103e975c0cdb2357fb6f",
|
|
286
286
|
"src/index-request.js": "78f26b872299005499fff4f2d1f9e8f986784f2ff36a5cf2be2b1e7b7c7d9378",
|
|
287
287
|
"src/knowledge-targets.js": "aa44ec285d16d7b1c0b63bf084058a1d6f867fa9929c753b6b0cbb24f7b20ee2",
|
|
288
|
-
"src/memories.js": "
|
|
289
|
-
"src/memory-eligibility.js": "
|
|
290
|
-
"src/memory-groups.js": "
|
|
291
|
-
"src/retrieval-policy.json": "
|
|
288
|
+
"src/memories.js": "4c170b0079ab7bba24e15c7aa50f77788b324f75a591ff3930c35dfa639ca9e7",
|
|
289
|
+
"src/memory-eligibility.js": "0cc68807e0d113d52c2a2455f8f629c1e04e922b24813d02eaff9e7509208f2f",
|
|
290
|
+
"src/memory-groups.js": "6dda17be0469b731c4d45c4aade7fc0c37fb6065cd924e7c7b03bd8e7e230c61",
|
|
291
|
+
"src/retrieval-policy.json": "4c2ce26e6c99330eb58c375da8f480ca9bc5f603b13e02712d66a267cd546e61",
|
|
292
292
|
"src/retrieval-ranking.js": "43f61504bca5e5fd9fdaf7234e775b25dd97d2777ef4615394e8069c7371e75e",
|
|
293
|
-
"src/retrieval.js": "
|
|
293
|
+
"src/retrieval.js": "6b6b057f58cd3d91088f3f402806c68c77cbc6079290d51307e8301f79069255",
|
|
294
294
|
"src/retry-scheduler.js": "81285c30fdc04e78139f89a956ff12f7cc95df46124632e7586cdbe9f8834a88",
|
|
295
295
|
"src/runtime/atomic-file.js": "9846b4b69db5ded811acf19a1181ef93615d93efaa542b858e552a7f3124ad23",
|
|
296
296
|
"src/runtime/automation-config.js": "2794aea67e3604db9b69dcaef6d303d0b5163b7e998a9730b93797f306c679cc",
|
|
@@ -311,35 +311,36 @@
|
|
|
311
311
|
"src/runtime/README.md": "9be676eca76a7857b34d7357194e6f0ee733c22e61d962d53984715dbec7f673",
|
|
312
312
|
"src/runtime/scanner.js": "fdcf87aedb8df037a595fa5271185427d80c66d5a82a218409e8d8bd149d591a",
|
|
313
313
|
"src/server.js": "626cb8741fa3f2c725a2fe364f5c9fd80d93db9a7090cf3368e24ed1681a7354",
|
|
314
|
-
"src/store.js": "
|
|
314
|
+
"src/store.js": "da3c36fea9a03d723836f2994adbdd64aaf840f519ee253e9900e253c805789b",
|
|
315
315
|
"ui/app.css": "7ad370c269e60a7b5ec907d81a607b2d16bd07b2d7c22a81f102dab51eeb2889",
|
|
316
316
|
"ui/app.js": "e9ecb0125d5f2a8bb30a58c4d278fe0737ee2540ecfb065f97f453495cfc792d",
|
|
317
|
-
"ui/index.html": "ce3565cfefd4838b11d37a91a906ef26ca5a1834844fe3f7c897b56851a3c418"
|
|
317
|
+
"ui/index.html": "ce3565cfefd4838b11d37a91a906ef26ca5a1834844fe3f7c897b56851a3c418",
|
|
318
|
+
"src/memory-migration.js": "89ca4e9ec0ecfe4839ff5e37b7e9a0fd6df51238b8b555051fed4b88db9bc4b8"
|
|
318
319
|
}
|
|
319
320
|
},
|
|
320
321
|
"workflow": {
|
|
321
322
|
"name": "@sanqianx/ai-coding-workflow",
|
|
322
323
|
"installName": "@sanqianx/ai-coding-workflow",
|
|
323
|
-
"version": "0.2.
|
|
324
|
+
"version": "0.2.2",
|
|
324
325
|
"files": {
|
|
325
326
|
"LICENSE": "c1b9df1275e769f3dbab000d1e457a2d4b0f28eb5da6c77e48dc37eeba202ed7",
|
|
326
327
|
"README.md": "0ee483525831969a3855d942cbb2388d0c6a72e160bfa3c4fd33ee1bc729d1c7",
|
|
327
|
-
"docs/contract.md": "
|
|
328
|
-
"package.json": "
|
|
328
|
+
"docs/contract.md": "ee869693eea33a3c3e763fc2008951bc5c888f2bcdb5a36c28c611064ca3f320",
|
|
329
|
+
"package.json": "e767e75f8a8f091d25e0bd12f68c70085afa62cbe866068e243cc0c23b1146e2",
|
|
329
330
|
"src/bin.js": "1feb264c5f2df3302846d604a3a58c51d991d3736ee46c31d658e50978946618",
|
|
330
|
-
"src/checks.js": "
|
|
331
|
+
"src/checks.js": "adffca98f9717a23bc6a611ecc387b15626b187a2e37a65cb658ac917cf3b1bb",
|
|
331
332
|
"src/consumer.js": "2033895f7b536de8505bac00a3f88f717768adfdc9ae25b53c5e4bf75243f250",
|
|
332
333
|
"src/digests.js": "dd90e639d21c3b59a604e3280f214d0b4ed178e3c659c18b90d31b5479913332",
|
|
333
334
|
"src/domain.js": "2edd3170002a592fc17f09456074b3c3c7d48dcd608efb64e9e76b314cd9a361",
|
|
334
335
|
"src/errors.js": "1868330aa021b3dba5e92061dbb41e15a94f4cb0746f870c49aac4bf6119d708",
|
|
335
|
-
"src/identity.js": "
|
|
336
|
+
"src/identity.js": "01d119c5f04c80860444224e2b74f732ca0ea4ccdaac9e8aa40cdc7f0ad6e84e",
|
|
336
337
|
"src/server.js": "0cc18b28fd449d22aeed159cc7fae0e63d4acb31bba79ab5ef987eb8f8c05e4d",
|
|
337
338
|
"src/snapshots.js": "e4d3dca2d9193a536f9c24fb9f572aff58eb1031f2caac71ba8531d4b47db7b0",
|
|
338
339
|
"src/store.js": "5c7d5e1415c326fec192bc2e6824b93abda1236e23b1304afe11f52754d96500",
|
|
339
340
|
"src/tasks.js": "95a043d7c9a25cb266a9ec7f21b8502dc96e13b441b0e4c884c4f91996f558ed",
|
|
340
|
-
"ui/app.css": "
|
|
341
|
-
"ui/app.js": "
|
|
342
|
-
"ui/index.html": "
|
|
341
|
+
"ui/app.css": "4d0fe1ce87abc26763ad312104312d2cd4a0363872ac7ba19a1f3c7adebbbb1f",
|
|
342
|
+
"ui/app.js": "09494b513c66770e29d2c27287cd5cd1be3d539578708e6c38dfb1fd694df2e5",
|
|
343
|
+
"ui/index.html": "3226838b7415beaeb559413195dcd3d53ec779b1cd987dcfc33e89c0405e6a17"
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanqianx/project-knowledge",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Knowledge base manager with Git integration, AI-driven analysis, and bilingual (zh-CN/en-US) knowledge output",
|
|
5
5
|
"main": "_site/server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"@lancedb/lancedb": "0.31.0",
|
|
88
88
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
89
89
|
"@sanqianx/ai-coding-event-bridge-console": "0.7.5-rc.1",
|
|
90
|
-
"@sanqianx/ai-coding-knowledge-engine": "0.
|
|
91
|
-
"@sanqianx/ai-coding-workflow": "0.2.
|
|
90
|
+
"@sanqianx/ai-coding-knowledge-engine": "0.4.1",
|
|
91
|
+
"@sanqianx/ai-coding-workflow": "0.2.2",
|
|
92
92
|
"@sanqianx/vector-hub": "1.0.8-rc.9",
|
|
93
93
|
"buffer": "^6.0.3",
|
|
94
94
|
"cheerio": "^1.2.0",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
3
|
"name": "project-knowledge",
|
|
4
4
|
"hooks": "./hooks/claude.json",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.3.0",
|
|
6
6
|
"description": "Read durable project decisions and implementation history from Project Knowledge.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "SanQianX",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"const fs=require('fs'),path=require('path'),os=require('os');const PKG='@sanqianx/project-knowledge',SC='project-knowledge/integration-runtime/v1';let f='';const root=process.env.CLAUDE_PLUGIN_ROOT||process.env.PLUGIN_ROOT;if(root){f=path.join(root,'scripts','mcp-launcher.cjs');if(!fs.existsSync(f))f=''}if(!f){const dd=process.env.KB_DATA_DIR||path.join(os.homedir(),'.project-knowledge');try{const bp=path.join(dd,'integration-runtime.json');const st=fs.statSync(bp);if(st.isFile()&&st.size<=32768){const b=JSON.parse(fs.readFileSync(bp,'utf8'));if(b&&b.schema===SC&&b.packageName===PKG&&typeof b.packageRoot==='string'&&path.isAbsolute(b.packageRoot)){const c=path.join(b.packageRoot,'plugins','project-knowledge','scripts','mcp-launcher.cjs');const rr=fs.realpathSync(b.packageRoot),cr=fs.realpathSync(c);const rel=path.relative(rr,cr);if(rel&&rel!=='..'&&!rel.startsWith('..'+path.sep)&&!path.isAbsolute(rel)&&fs.statSync(cr).isFile())f=cr}}}catch(e){}}if(!f){console.error('[project-knowledge-mcp] 未能通过受信任插件根或已验证的安装绑定定位启动器,已停止;不访问网络,也不加载工作目录源码。');process.exit(127)}require(f);"
|
|
9
9
|
],
|
|
10
10
|
"env": {
|
|
11
|
-
"KB_PLUGIN_VERSION": "5.
|
|
11
|
+
"KB_PLUGIN_VERSION": "5.3.0"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -22,7 +22,7 @@ async function boundedJson(response) {
|
|
|
22
22
|
function log(dataDir, event, input) {
|
|
23
23
|
// Only metadata: never log the prompt, context body, headers or CLI environment.
|
|
24
24
|
const projectId = /^project-[A-Za-z0-9._-]+$/.test(input.projectId || '') ? input.projectId : '';
|
|
25
|
-
const record = { schema: 'log/v2', id: `log-${crypto.randomUUID()}`, ts: new Date().toISOString(), level: input.code ? 'warn' : 'info', component: 'agent-context', event, message: input.code ? '开发前知识读取未完成,已提示后继续。' : '知识上下文已输出给客户端;模型实际送达需原生运行证据。', projectId, operationId: input.requestId, phase: 'context', context: { client: input.client, code: input.code || null, status: input.status, injectionKind: input.injectionKind || null, sessionIndexedCount: input.sessionIndexedCount ?? null, factCount: input.factCount, memoryCount: input.memoryCount, durationMs: input.durationMs } };
|
|
25
|
+
const record = { schema: 'log/v2', id: `log-${crypto.randomUUID()}`, ts: new Date().toISOString(), level: input.code ? 'warn' : 'info', component: 'agent-context', event, message: input.code ? '开发前知识读取未完成,已提示后继续。' : '知识上下文已输出给客户端;模型实际送达需原生运行证据。', projectId, operationId: input.requestId, phase: 'context', context: { client: input.client, code: input.code || null, status: input.status, injectionKind: input.injectionKind || null, sessionIndexedCount: input.sessionIndexedCount ?? null, factCount: input.factCount, evidenceCount: input.evidenceCount, memoryCount: input.memoryCount, durationMs: input.durationMs } };
|
|
26
26
|
try { const directory = path.join(dataDir, 'logs', projectId ? 'projects' : 'system', ...(projectId ? [projectId] : [])); fs.mkdirSync(directory, { recursive: true }); const now = new Date(), date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`; fs.appendFileSync(path.join(directory, `${date}.jsonl`), JSON.stringify(record) + '\n', { encoding: 'utf8', mode: 0o600 }); } catch { /* Diagnostic disk failures must not block the IDE. */ }
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -57,8 +57,8 @@ async function run(payload, { env = process.env, argv = process.argv.slice(2), f
|
|
|
57
57
|
// messages and never enter the model context.
|
|
58
58
|
const notice = [result.status === 'file-fallback' ? '知识向量检索暂不可用,本次使用当前文件事实。' : '', result.memoryStatus === 'pending' ? '部分已确认记忆文件待同步,本次未注入失效内容。' : ''].filter(Boolean).join(' ');
|
|
59
59
|
const output = { ...(notice ? { systemMessage: notice } : {}), ...(result.prompt ? { hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: result.prompt } } : {}) };
|
|
60
|
-
const injectionKind = /^(index|memory-delta|breadcrumb|refresh)$/.test(result.injectionKind || '') ? result.injectionKind : null;
|
|
61
|
-
Object.defineProperty(output, 'receipt', { value: { dataDir, requestId, client, projectId: result.projectId, status: result.status, injectionKind, sessionIndexedCount: Number.isInteger(result.sessionIndexedCount) ? result.sessionIndexedCount : null, factCount: result.facts.length, memoryCount: result.memories.length, durationMs: Date.now() - started } });
|
|
60
|
+
const injectionKind = /^(index|memory-delta|breadcrumb|evidence|refresh)$/.test(result.injectionKind || '') ? result.injectionKind : null;
|
|
61
|
+
Object.defineProperty(output, 'receipt', { value: { dataDir, requestId, client, projectId: result.projectId, status: result.status, injectionKind, sessionIndexedCount: Number.isInteger(result.sessionIndexedCount) ? result.sessionIndexedCount : null, factCount: result.facts.length, evidenceCount: result.facts.filter(fact => typeof fact?.text === 'string' && fact.text).length, memoryCount: result.memories.length, durationMs: Date.now() - started } });
|
|
62
62
|
return output;
|
|
63
63
|
} catch (error) {
|
|
64
64
|
const code = controller.signal.aborted ? 'CONTEXT_TIMEOUT' : /^[A-Z][A-Z0-9_]{0,79}$/.test(error.message || '') ? error.message : 'CONTEXT_UNAVAILABLE';
|
|
@@ -9,14 +9,13 @@ Use Project Knowledge as a read-only source of durable project context. Automati
|
|
|
9
9
|
|
|
10
10
|
## Automatic session injection (read this first)
|
|
11
11
|
|
|
12
|
-
Clients with the UserPromptSubmit hook receive
|
|
12
|
+
Clients with the UserPromptSubmit hook can receive confirmed memories and project knowledge automatically.
|
|
13
13
|
|
|
14
|
-
- The first message
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- Everything else is silent by design - silence means "nothing new", not "no knowledge".
|
|
14
|
+
- The first message supplies applicable confirmed combination memories and a bounded catalog of knowledge titles and entry IDs.
|
|
15
|
+
- Concrete questions on any turn can supply up to two strongly matched excerpts with their sources. Clearly referential short follow-ups can use the preceding topic. A repeated excerpt from the same revision is suppressed even if another excerpt from that entry can still be shown.
|
|
16
|
+
- Changed or newly applicable confirmed memories are sent again. Removed memories get a one-line notice. Published engines with the earlier session-index policy may supply title-only hints.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Use `project_knowledge_search` when a task needs evidence that the hook did not supply. Read the full entry with `project_knowledge_get` when its title or excerpt leaves a detail unresolved. Check the current source before relying on historical knowledge.
|
|
20
19
|
|
|
21
20
|
## Workflow
|
|
22
21
|
|