@sanqianx/project-knowledge 5.2.1 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +6 -0
- package/_site/_test/ai-team-ui-integration-test.js +219 -0
- package/_site/_test/automatic-context-test.js +6 -0
- package/_site/_test/context-session-index-test.js +19 -9
- package/_site/_test/helpers/ai-team-ui-fixture.js +235 -0
- 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/helpers/single-repo-maintenance-fixture.js +94 -0
- package/_site/_test/helpers/single-repo-maintenance-tool.js +56 -0
- 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 +18 -9
- package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +4 -2
- package/_site/_test/project-team-ui-test.js +11 -15
- package/_site/_test/shared-scope-root-binding-test.js +7 -6
- package/_site/_test/single-repo-maintenance-e2e-test.js +200 -0
- package/_site/_test/t07f-mem-008-coverage-test.js +0 -1
- package/_site/_test/workbench-context-receipts-test.js +9 -4
- 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 +31 -26
- 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.css +20 -0
- package/ui/product.js +161 -67
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { setTimeout: delay } = require('node:timers/promises');
|
|
7
|
+
const { createAiTeamUiFixture, cliOptions } = require('./helpers/ai-team-ui-fixture');
|
|
8
|
+
|
|
9
|
+
async function until(read, predicate, label) {
|
|
10
|
+
const deadline = Date.now() + 30_000;
|
|
11
|
+
let value;
|
|
12
|
+
while (Date.now() < deadline) {
|
|
13
|
+
value = await read();
|
|
14
|
+
if (predicate(value)) return value;
|
|
15
|
+
await delay(125);
|
|
16
|
+
}
|
|
17
|
+
throw new Error('Timed out waiting for ' + label + '\n' + JSON.stringify(value));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const options = cliOptions({ test: true });
|
|
22
|
+
let fakeTime;
|
|
23
|
+
const fixture = await createAiTeamUiFixture({
|
|
24
|
+
...options, maintenance: true, emptyTeam: false,
|
|
25
|
+
maintenanceTiming: { pollMs: 150, bridgePollMs: 250, clock: () => fakeTime || new Date() },
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const { repo, remote, baseline, configPath, projectId, journalId, bridge, git, gitAsync, appendBoundary } = fixture.maintenance;
|
|
29
|
+
const status = () => fixture.call('maintenance');
|
|
30
|
+
const post = (route, body) => fixture.call('maintenance/' + route, { method: 'POST', body });
|
|
31
|
+
const detail = runId => fixture.call('maintenance/runs/' + runId).then(value => value.run);
|
|
32
|
+
const upstream = () => git(remote, 'rev-parse', 'refs/heads/main');
|
|
33
|
+
const terminal = run => !['queued', 'running'].includes(run.status);
|
|
34
|
+
const waitRun = id => until(() => detail(id), terminal, 'run ' + id);
|
|
35
|
+
const getRuns = async (job, kind) => (await status()).runs.filter(run => run.jobId === job.jobId && run.trigger.kind === kind);
|
|
36
|
+
let requestIndex = 0;
|
|
37
|
+
const save = fields => post('jobs', {
|
|
38
|
+
requestId: 'job-' + (++requestIndex), memberId: fixture.members[0].memberId,
|
|
39
|
+
enabled: true, delivery: 'candidate', ...fields,
|
|
40
|
+
}).then(value => value.job);
|
|
41
|
+
const control = (busy, fields = {}) => post('control', { requestId: 'control-' + (++requestIndex), busy, ...fields });
|
|
42
|
+
const runNow = (job, id) => post('runs', { requestId: id || 'run-' + (++requestIndex), jobId: job.jobId }).then(value => value.run);
|
|
43
|
+
|
|
44
|
+
const available = await status();
|
|
45
|
+
assert.equal(available.projectId, projectId);
|
|
46
|
+
assert.equal(available.workspace, null);
|
|
47
|
+
assert.equal(available.timeZone, 'Asia/Shanghai');
|
|
48
|
+
assert.ok(available.tools.every(tool => !tool.phases && !tool.command));
|
|
49
|
+
const consumers = await bridge.listConsumers();
|
|
50
|
+
assert.deepEqual(consumers.find(item => item.name === 'workflow:default').meta.journals, ['global', journalId]);
|
|
51
|
+
const direct = fixture.workflowUrl + '/api/workflow/v1/maintenance';
|
|
52
|
+
assert.equal((await fetch(direct, { headers: { Origin: 'https://foreign.example' } })).status, 403);
|
|
53
|
+
assert.equal((await fetch(direct + '/runs', { method: 'POST', headers: { 'Content-Type': 'text/plain' }, body: '{}' })).status, 400);
|
|
54
|
+
assert.equal((await fetch(fixture.address + '/api/workflow/maintenance/control', {
|
|
55
|
+
method: 'POST', headers: { Origin: 'https://foreign.example', 'Content-Type': 'application/json' },
|
|
56
|
+
body: JSON.stringify({ requestId: 'cross-origin', busy: true }),
|
|
57
|
+
})).status, 403);
|
|
58
|
+
await assert.rejects(save({ title: 'Invalid member', toolId: 'review', memberId: 'other', trigger: { kind: 'commit' } }), /400/);
|
|
59
|
+
await assert.rejects(save({ title: 'Unknown executable', toolId: 'arbitrary', trigger: { kind: 'commit' } }), /400/);
|
|
60
|
+
|
|
61
|
+
const historical = await appendBoundary(); // Already captured before maintenance is enabled.
|
|
62
|
+
assert.ok(historical.sequence > 1, 'the project journal starts with a real compacted prefix');
|
|
63
|
+
let review = await save({ title: '处理提交检查', toolId: 'review', trigger: { kind: 'commit' } });
|
|
64
|
+
assert.deepEqual(await getRuns(review, 'commit'), []);
|
|
65
|
+
await control(true);
|
|
66
|
+
fs.writeFileSync(path.join(repo, 'policy.txt'), 'FAIL\n');
|
|
67
|
+
await gitAsync(repo, 'add', 'policy.txt');
|
|
68
|
+
await gitAsync(repo, 'commit', '-qm', 'source commit from development');
|
|
69
|
+
const source = git(repo, 'rev-parse', 'HEAD');
|
|
70
|
+
const queued = await until(() => getRuns(review, 'commit'), runs => runs.length === 1, 'real managed Git hook');
|
|
71
|
+
assert.equal(queued[0].trigger.commitSha, source);
|
|
72
|
+
assert.equal(queued[0].status, 'queued');
|
|
73
|
+
assert.equal((await status()).workspace, null);
|
|
74
|
+
const events = await bridge.readEvents({ journalId, fromSequence: 1 });
|
|
75
|
+
assert.ok(events.some(event => event.schema === 'git-commit-boundary/v1' && event.commitSha === source));
|
|
76
|
+
await appendBoundary();
|
|
77
|
+
await appendBoundary({ projectId: 'project-another-repo', commitSha: baseline });
|
|
78
|
+
await appendBoundary({ branch: 'different-branch', commitSha: baseline });
|
|
79
|
+
const lastBoundary = await bridge.getHighWatermark({ journalId });
|
|
80
|
+
await until(() => fixture.call('consumer'), result => result.cursors[journalId] === lastBoundary, 'all journal events processed');
|
|
81
|
+
const workflowState = JSON.parse(fs.readFileSync(path.join(options.dataDir, 'workflow-data', 'workflow', 'state.json'), 'utf8'));
|
|
82
|
+
assert.ok(workflowState.consumer.gaps.some(gap => gap.journalId === journalId && gap.reason === 'retained-prefix'));
|
|
83
|
+
assert.equal((await getRuns(review, 'commit')).length, 1);
|
|
84
|
+
|
|
85
|
+
const devFile = path.join(repo, 'work-in-progress.txt');
|
|
86
|
+
fs.writeFileSync(devFile, 'Development workspace only\n');
|
|
87
|
+
await control(false);
|
|
88
|
+
await until(status, data => data.waitReason === 'original-busy', 'uncommitted original work held');
|
|
89
|
+
assert.equal(fs.readFileSync(devFile, 'utf8'), 'Development workspace only\n');
|
|
90
|
+
assert.equal((await status()).workspace, null);
|
|
91
|
+
fs.unlinkSync(devFile);
|
|
92
|
+
|
|
93
|
+
const first = await waitRun(queued[0].runId);
|
|
94
|
+
assert.equal(first.status, 'succeeded', JSON.stringify(first));
|
|
95
|
+
assert.equal(first.delivery, 'candidate');
|
|
96
|
+
assert.equal(first.baseSha, source);
|
|
97
|
+
assert.deepEqual(first.receipts.map(receipt => [receipt.phase, receipt.exitCode]), [['check', 1], ['repair', 0], ['check', 0]]);
|
|
98
|
+
assert.equal(git(repo, 'rev-parse', first.candidateRef), first.commitSha);
|
|
99
|
+
assert.equal(git(repo, 'rev-parse', first.commitSha + '^'), source);
|
|
100
|
+
assert.equal(git(repo, 'show', first.commitSha + ':policy.txt'), 'PASS');
|
|
101
|
+
assert.equal(git(repo, 'rev-parse', 'HEAD'), source);
|
|
102
|
+
assert.equal(fs.readFileSync(path.join(repo, 'policy.txt'), 'utf8'), 'FAIL\n');
|
|
103
|
+
assert.equal(upstream(), baseline);
|
|
104
|
+
const workspace = (await status()).workspace;
|
|
105
|
+
assert.ok(workspace && workspace !== repo);
|
|
106
|
+
assert.equal(git(repo, 'worktree', 'list', '--porcelain').split(/\r?\n/).filter(line => line.startsWith('worktree ')).length, 2);
|
|
107
|
+
|
|
108
|
+
await fixture.restartWorkflow();
|
|
109
|
+
assert.equal((await status()).workspace, workspace);
|
|
110
|
+
await appendBoundary();
|
|
111
|
+
assert.equal((await getRuns(review, 'commit')).length, 1, 'dedupe persists across service restart');
|
|
112
|
+
review = await save({ ...review, expectedRevision: review.revision, delivery: 'push' });
|
|
113
|
+
await assert.rejects(save({ ...review, expectedRevision: review.revision - 1 }), /409/);
|
|
114
|
+
fs.writeFileSync(path.join(repo, 'second-source.txt'), 'This local commit must stay local\n');
|
|
115
|
+
await gitAsync(repo, 'add', 'second-source.txt');
|
|
116
|
+
await gitAsync(repo, 'commit', '-qm', 'second unpublished source commit');
|
|
117
|
+
const next = await until(() => getRuns(review, 'commit'), runs => runs.length === 2, 'second Git boundary');
|
|
118
|
+
const unpushed = await waitRun(next[0].runId);
|
|
119
|
+
assert.equal(unpushed.delivery, 'remote-changed', JSON.stringify(unpushed));
|
|
120
|
+
assert.equal(upstream(), baseline);
|
|
121
|
+
assert.equal((await status()).workspace, workspace);
|
|
122
|
+
|
|
123
|
+
fakeTime = new Date('2031-01-20T00:58:00.000Z');
|
|
124
|
+
await control(true);
|
|
125
|
+
const schedule = { kind: 'daily', at: '09:00' };
|
|
126
|
+
const formatter = await save({ title: '日常格式整理', toolId: 'format', trigger: schedule, delivery: 'push' });
|
|
127
|
+
const docs = await save({ title: '更新项目文档', toolId: 'docs', trigger: schedule, delivery: 'push' });
|
|
128
|
+
assert.equal((await status()).queueLength, 0);
|
|
129
|
+
fakeTime = new Date('2031-01-20T01:00:00.000Z');
|
|
130
|
+
const dailyQueue = await until(status, data => data.queueLength === 2, '09:00 China time schedule');
|
|
131
|
+
const formatQueued = dailyQueue.runs.find(run => run.jobId === formatter.jobId);
|
|
132
|
+
const docsQueued = dailyQueue.runs.find(run => run.jobId === docs.jobId);
|
|
133
|
+
assert.deepEqual(formatQueued.trigger, { kind: 'daily', date: '2031-01-20', at: '09:00', timeZone: 'Asia/Shanghai' });
|
|
134
|
+
await control(false);
|
|
135
|
+
const formatted = await waitRun(formatQueued.runId);
|
|
136
|
+
const documented = await waitRun(docsQueued.runId);
|
|
137
|
+
assert.equal(formatted.delivery, 'pushed', JSON.stringify(formatted));
|
|
138
|
+
assert.equal(formatted.baseSha, baseline);
|
|
139
|
+
assert.equal(documented.delivery, 'pushed', JSON.stringify(documented));
|
|
140
|
+
assert.equal(documented.baseSha, formatted.commitSha, 'second write fetches the completed first write');
|
|
141
|
+
assert.equal(upstream(), documented.commitSha);
|
|
142
|
+
assert.equal(git(remote, 'show', 'main:docs/usage.md'), '# Formatted repository');
|
|
143
|
+
assert.equal(git(repo, 'status', '--porcelain'), '');
|
|
144
|
+
assert.equal((await status()).workspace, workspace);
|
|
145
|
+
fakeTime = new Date('2031-01-20T01:10:00.000Z');
|
|
146
|
+
await fixture.restartWorkflow();
|
|
147
|
+
const noOp = await runNow(formatter, 'manual-idempotent');
|
|
148
|
+
assert.equal((await runNow(formatter, 'manual-idempotent')).runId, noOp.runId);
|
|
149
|
+
assert.equal((await waitRun(noOp.runId)).delivery, 'no-changes');
|
|
150
|
+
assert.equal((await getRuns(formatter, 'daily')).length, 1);
|
|
151
|
+
assert.equal((await getRuns(docs, 'daily')).length, 1);
|
|
152
|
+
|
|
153
|
+
const reject = await save({ title: '无法修复的规则', toolId: 'reject', trigger: { kind: 'manual' } });
|
|
154
|
+
const failed = await waitRun((await runNow(reject)).runId);
|
|
155
|
+
assert.equal(failed.status, 'failed');
|
|
156
|
+
assert.equal(failed.reason, 'review-findings');
|
|
157
|
+
assert.deepEqual(failed.receipts.map(item => item.exitCode), [1, 0, 1]);
|
|
158
|
+
assert.equal(failed.commitSha, undefined);
|
|
159
|
+
const heldRun = await runNow(formatter);
|
|
160
|
+
await until(status, data => data.waitReason === 'workspace-dirty', 'dirty maintenance worktree held');
|
|
161
|
+
const unresolved = path.join(workspace, 'unresolved.txt');
|
|
162
|
+
assert.match(fs.readFileSync(unresolved, 'utf8'), /Keep this/);
|
|
163
|
+
fs.renameSync(unresolved, path.join(options.dataDir, 'preserved-failed-review.txt'));
|
|
164
|
+
assert.equal((await waitRun(heldRun.runId)).delivery, 'no-changes');
|
|
165
|
+
|
|
166
|
+
const timeout = await save({ title: '超时后保护', toolId: 'timeout', trigger: { kind: 'manual' } });
|
|
167
|
+
const interrupted = await waitRun((await runNow(timeout)).runId);
|
|
168
|
+
assert.equal(interrupted.status, 'interrupted');
|
|
169
|
+
assert.equal(interrupted.receipts[0].error, 'command-timeout');
|
|
170
|
+
assert.equal((await status()).hold.runId, interrupted.runId);
|
|
171
|
+
const queuedAfterTimeout = await runNow(formatter);
|
|
172
|
+
assert.equal((await detail(queuedAfterTimeout.runId)).status, 'queued');
|
|
173
|
+
await assert.rejects(control(false, { clearHold: true, holdRunId: 'stale' }), /409/);
|
|
174
|
+
const leftovers = path.join(workspace, 'timed-out.txt');
|
|
175
|
+
fs.renameSync(leftovers, path.join(options.dataDir, 'preserved-timeout.txt'));
|
|
176
|
+
await control(false, { clearHold: true, holdRunId: interrupted.runId });
|
|
177
|
+
assert.equal((await waitRun(queuedAfterTimeout.runId)).delivery, 'no-changes');
|
|
178
|
+
const pushProbe = await save({ title: '本机授权变更', toolId: 'probe', trigger: { kind: 'manual' }, delivery: 'push' });
|
|
179
|
+
const registry = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
180
|
+
fs.writeFileSync(configPath, JSON.stringify({ ...registry, allowPush: false }));
|
|
181
|
+
await fixture.restartWorkflow();
|
|
182
|
+
const candidate = await waitRun((await runNow(pushProbe)).runId);
|
|
183
|
+
assert.equal(candidate.delivery, 'candidate');
|
|
184
|
+
assert.equal(git(repo, 'show', candidate.commitSha + ':push-permission.txt'), 'This candidate should stay local');
|
|
185
|
+
assert.equal(upstream(), documented.commitSha);
|
|
186
|
+
assert.equal(git(repo, 'status', '--porcelain'), '');
|
|
187
|
+
assert.equal(git(repo, 'worktree', 'list', '--porcelain').split(/\r?\n/).filter(line => line.startsWith('worktree ')).length, 2);
|
|
188
|
+
console.log(JSON.stringify({
|
|
189
|
+
passed: ['real managed Git hook and Bridge', 'commit repair and bounded retry', 'busy and dirty guards',
|
|
190
|
+
'persistent trigger dedupe', 'worktree reuse', 'schedule and serial remote baselines', 'true fast-forward push',
|
|
191
|
+
'unpushed source stays local', 'push permission revocation', 'timeout hold and resume', 'JSON, origin and job permissions'],
|
|
192
|
+
workspace, reviewCommit: first.commitSha, remoteTip: documented.commitSha,
|
|
193
|
+
}));
|
|
194
|
+
} finally {
|
|
195
|
+
const closed = await fixture.close();
|
|
196
|
+
assert.ok(closed.every(item => item.status === 'fulfilled'), JSON.stringify(closed));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
main().catch(error => { console.error(error.stack); process.exitCode = 1; });
|
|
@@ -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
|
|
|
@@ -4,11 +4,13 @@ const fs = require('node:fs');
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const vm = require('node:vm');
|
|
6
6
|
const source = fs.readFileSync(path.join(__dirname, '../../ui/product.js'), 'utf8');
|
|
7
|
-
const code = source.slice(source.indexOf(' function
|
|
8
|
-
const messages = [], frame = { ready: false },
|
|
7
|
+
const code = source.slice(source.indexOf(' function postTheme('), source.indexOf(' function setView('));
|
|
8
|
+
const messages = [], frame = { ready: false }, workflow = { ready: true };
|
|
9
|
+
const state = { epoch: 1, scope: 'project' };
|
|
9
10
|
const project = { projectId: 'a', workspacePath: '/workspace', modules: { terminal: { projectId: 'context-a' } } };
|
|
10
|
-
const ctx = vm.createContext({ state, frames: { terminal: frame }, activeProject: () => project,
|
|
11
|
-
document: { documentElement: { dataset: { theme: 'light' } } },
|
|
11
|
+
const ctx = vm.createContext({ state, frames: { terminal: frame, workflow }, activeProject: () => project,
|
|
12
|
+
document: { documentElement: { dataset: { theme: 'light' } } },
|
|
13
|
+
getComputedStyle: () => ({ getPropertyValue: name => name === '--accent' ? ' #3a775a ' : '' }),
|
|
12
14
|
post: (_key, message) => messages.push(message) });
|
|
13
15
|
vm.runInContext(code, ctx);
|
|
14
16
|
vm.runInContext('frameContext("terminal")', ctx);
|
|
@@ -19,4 +21,7 @@ assert.equal(messages.filter(m => m.type === 'kb:select-project').length, 1, 'id
|
|
|
19
21
|
state.epoch++;
|
|
20
22
|
vm.runInContext('frameContext("terminal")', ctx);
|
|
21
23
|
assert.equal(messages.filter(m => m.type === 'kb:select-project').length, 2, 'a real selection still reaches the iframe');
|
|
24
|
+
assert.ok(messages.filter(m => m.type === 'kb:theme').every(message => !message.palette), 'terminal theme message preserves its fields');
|
|
25
|
+
vm.runInContext('frameContext("workflow"); frameContext("workflow")', ctx);
|
|
26
|
+
assert.equal(messages.filter(m => m.palette?.accent === '#3a775a').length, 1, 'Workflow receives the palette with its context once');
|
|
22
27
|
console.log('workbench-context-receipts-test PASS');
|
|
@@ -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": "053791a9188ebc8229e362ce2d7cc0ea42abac9c4a312491d8854a203529ebcc",
|
|
7
7
|
"ui/live-client.js": "0d81fa894c629bb839e1931fc3c5ebad4d831aae8232d6ce8c0f542e9e3559e8",
|
|
8
|
-
"ui/product.css": "
|
|
8
|
+
"ui/product.css": "904b367da6efa96a668d400735d08923a07a2df427f82176214ccfbc602ca361",
|
|
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": "4df2c9c6002f25eef02c35870a77d1935f75807ce0e461d140c735101f15196e",
|
|
15
|
+
"plugins/project-knowledge/.codex-plugin/plugin.json": "39d4945045f8d5ba6360656b3dfeaff95ce20beaa11d30e7edee8af1269a24ec",
|
|
16
|
+
"plugins/project-knowledge/.mcp.json": "cacdfc3e4b357e367e30ae067a85f40fc8cd4268477910d3bffedf60f8c1103a",
|
|
17
17
|
"ui/version-info.js": "01a82217b031de54b80d6c7974da9c70888c4c90a046bd4248a808f7989ddce7",
|
|
18
18
|
"ui/version-info.css": "209fad8e42b661f72d2aba3280e1ca47768b5cefb776fe5459538d34fbad120f"
|
|
19
19
|
},
|
|
@@ -267,30 +267,31 @@
|
|
|
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/
|
|
288
|
+
"src/memories.js": "4c170b0079ab7bba24e15c7aa50f77788b324f75a591ff3930c35dfa639ca9e7",
|
|
289
|
+
"src/memory-eligibility.js": "0cc68807e0d113d52c2a2455f8f629c1e04e922b24813d02eaff9e7509208f2f",
|
|
290
|
+
"src/memory-groups.js": "6dda17be0469b731c4d45c4aade7fc0c37fb6065cd924e7c7b03bd8e7e230c61",
|
|
291
|
+
"src/memory-migration.js": "89ca4e9ec0ecfe4839ff5e37b7e9a0fd6df51238b8b555051fed4b88db9bc4b8",
|
|
292
|
+
"src/retrieval-policy.json": "4c2ce26e6c99330eb58c375da8f480ca9bc5f603b13e02712d66a267cd546e61",
|
|
292
293
|
"src/retrieval-ranking.js": "43f61504bca5e5fd9fdaf7234e775b25dd97d2777ef4615394e8069c7371e75e",
|
|
293
|
-
"src/retrieval.js": "
|
|
294
|
+
"src/retrieval.js": "6b6b057f58cd3d91088f3f402806c68c77cbc6079290d51307e8301f79069255",
|
|
294
295
|
"src/retry-scheduler.js": "81285c30fdc04e78139f89a956ff12f7cc95df46124632e7586cdbe9f8834a88",
|
|
295
296
|
"src/runtime/atomic-file.js": "9846b4b69db5ded811acf19a1181ef93615d93efaa542b858e552a7f3124ad23",
|
|
296
297
|
"src/runtime/automation-config.js": "2794aea67e3604db9b69dcaef6d303d0b5163b7e998a9730b93797f306c679cc",
|
|
@@ -311,7 +312,7 @@
|
|
|
311
312
|
"src/runtime/README.md": "9be676eca76a7857b34d7357194e6f0ee733c22e61d962d53984715dbec7f673",
|
|
312
313
|
"src/runtime/scanner.js": "fdcf87aedb8df037a595fa5271185427d80c66d5a82a218409e8d8bd149d591a",
|
|
313
314
|
"src/server.js": "626cb8741fa3f2c725a2fe364f5c9fd80d93db9a7090cf3368e24ed1681a7354",
|
|
314
|
-
"src/store.js": "
|
|
315
|
+
"src/store.js": "da3c36fea9a03d723836f2994adbdd64aaf840f519ee253e9900e253c805789b",
|
|
315
316
|
"ui/app.css": "7ad370c269e60a7b5ec907d81a607b2d16bd07b2d7c22a81f102dab51eeb2889",
|
|
316
317
|
"ui/app.js": "e9ecb0125d5f2a8bb30a58c4d278fe0737ee2540ecfb065f97f453495cfc792d",
|
|
317
318
|
"ui/index.html": "ce3565cfefd4838b11d37a91a906ef26ca5a1834844fe3f7c897b56851a3c418"
|
|
@@ -320,26 +321,30 @@
|
|
|
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.3",
|
|
324
325
|
"files": {
|
|
325
326
|
"LICENSE": "c1b9df1275e769f3dbab000d1e457a2d4b0f28eb5da6c77e48dc37eeba202ed7",
|
|
326
327
|
"README.md": "0ee483525831969a3855d942cbb2388d0c6a72e160bfa3c4fd33ee1bc729d1c7",
|
|
327
|
-
"docs/contract.md": "
|
|
328
|
-
"package.json": "
|
|
328
|
+
"docs/contract.md": "2b750eae9998f2ee19953769c56fb046e31cfa105ad2eee351ec63764bb3572f",
|
|
329
|
+
"package.json": "a2a86aabd55bc62c62d6c0953fd30cbedcac7ba9f33854298e843c47f29225c7",
|
|
329
330
|
"src/bin.js": "1feb264c5f2df3302846d604a3a58c51d991d3736ee46c31d658e50978946618",
|
|
330
331
|
"src/checks.js": "adffca98f9717a23bc6a611ecc387b15626b187a2e37a65cb658ac917cf3b1bb",
|
|
331
|
-
"src/consumer.js": "
|
|
332
|
+
"src/consumer.js": "0f25dcda53d25f82a8c83e637cb3de64e9e5b5014a74531383c8244c094d5500",
|
|
332
333
|
"src/digests.js": "dd90e639d21c3b59a604e3280f214d0b4ed178e3c659c18b90d31b5479913332",
|
|
333
334
|
"src/domain.js": "2edd3170002a592fc17f09456074b3c3c7d48dcd608efb64e9e76b314cd9a361",
|
|
334
335
|
"src/errors.js": "1868330aa021b3dba5e92061dbb41e15a94f4cb0746f870c49aac4bf6119d708",
|
|
335
|
-
"src/identity.js": "
|
|
336
|
-
"src/
|
|
336
|
+
"src/identity.js": "89a3023b84c82f37aa2647033632463940da48ae9b60cf329e3c29259cc6367c",
|
|
337
|
+
"src/maintenance-config.js": "4edb8f033894344b27cb7a57e5444259a90781e90009b54e34b939a4be7aa0b9",
|
|
338
|
+
"src/maintenance-runner.js": "2e8a38b597a6396abdea8c2ff015f80fe2f3587f6ef7b6a92fbed6feb4154c69",
|
|
339
|
+
"src/maintenance.js": "10e536c8bc534adbbe055e1fc94232d8b3c796891cc5c801c77f10909d118a2b",
|
|
340
|
+
"src/review-native.js": "47ca1ba2c424116bcdce66526d1bafb90f560b945f8b4fd58a6732e252aa7a7f",
|
|
341
|
+
"src/server.js": "e5db984d61025a22fbd729d3dc1ebcf6bfcdfedc499c33e1bcb89637e039ac38",
|
|
337
342
|
"src/snapshots.js": "e4d3dca2d9193a536f9c24fb9f572aff58eb1031f2caac71ba8531d4b47db7b0",
|
|
338
343
|
"src/store.js": "5c7d5e1415c326fec192bc2e6824b93abda1236e23b1304afe11f52754d96500",
|
|
339
344
|
"src/tasks.js": "95a043d7c9a25cb266a9ec7f21b8502dc96e13b441b0e4c884c4f91996f558ed",
|
|
340
|
-
"ui/app.css": "
|
|
341
|
-
"ui/app.js": "
|
|
342
|
-
"ui/index.html": "
|
|
345
|
+
"ui/app.css": "c64fc049febb5a461bd902b08de491e030b53ffc0d2c6c8a5366ec0b88b27843",
|
|
346
|
+
"ui/app.js": "de7601e903486498719e8be749cc0d457a281a6f73867a999d63eb7171c579b2",
|
|
347
|
+
"ui/index.html": "23177779fefb0e0cc194c102df3a29a86559101944610c6f09587ef472ec5ae0"
|
|
343
348
|
}
|
|
344
349
|
}
|
|
345
350
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanqianx/project-knowledge",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
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.3",
|
|
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.1",
|
|
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.1"
|
|
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
|
|
package/ui/product.css
CHANGED
|
@@ -58,3 +58,23 @@ html[data-skin=steel][data-theme=dark]{--page:#171a1f;--surface:#20252d;--surfac
|
|
|
58
58
|
.status-group{background:var(--accent-soft)}
|
|
59
59
|
@media(max-width:900px){.memory-layout{grid-template-columns:170px minmax(0,1fr)}.grid2{grid-template-columns:1fr}.result-row{grid-template-columns:1fr}.result-row>small{text-align:left;max-width:none}}
|
|
60
60
|
@media(max-width:640px){.memory-layout{display:block}.memory-folders{margin-bottom:16px}.memory-folders hr{display:none}.project-name{min-width:130px}.dragbar{display:none}}
|
|
61
|
+
|
|
62
|
+
@media (max-width: 800px) {
|
|
63
|
+
.app:has(#view-team.active) { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); }
|
|
64
|
+
.app:has(#view-team.active) > .sidebar { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; border-right:0; border-bottom:1px solid var(--line); }
|
|
65
|
+
.app:has(#view-team.active) .sidebar .brand { min-width:0; padding:9px 12px; }
|
|
66
|
+
.app:has(#view-team.active) .sidebar .brain-label { display:none; }
|
|
67
|
+
.app:has(#view-team.active) .sidebar nav { grid-column:1/-1; display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:3px; padding:0 8px 7px; }
|
|
68
|
+
.app:has(#view-team.active) .sidebar nav button { min-width:0; justify-content:center; gap:4px; padding:6px; white-space:nowrap; }
|
|
69
|
+
.app:has(#view-team.active) .sidebar .system-button { grid-column:2; grid-row:1; margin:0 9px 0 0; padding:6px 8px; }
|
|
70
|
+
.app:has(#view-team.active) .system-button small { display:none; }
|
|
71
|
+
.app:has(#view-team.active) .topbar { height:57px; gap:8px; padding:0 12px; }
|
|
72
|
+
.app:has(#view-team.active) .topbar > div:first-child { flex:1; min-width:0; }
|
|
73
|
+
.app:has(#view-team.active) #breadcrumb { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
74
|
+
.app:has(#view-team.active) .topbar .spacer { display:none; }
|
|
75
|
+
.app:has(#view-team.active) .topbar select { width:min(48%,220px); }
|
|
76
|
+
}
|
|
77
|
+
@media (max-width: 560px) {
|
|
78
|
+
.app:has(#view-team.active) .sidebar nav { grid-template-columns:repeat(3,minmax(0,1fr)); }
|
|
79
|
+
.app:has(#view-team.active) .sidebar .system-button b { max-width:12ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
80
|
+
}
|