@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
|
@@ -35,7 +35,7 @@ const { applyDriverIsolation } = require('./parallel-qa-engine-endpoint-isolate'
|
|
|
35
35
|
const { guardedCreateEngineServer, createEngineVectorStandin } = require('./parallel-qa-engine-endpoint-guard');
|
|
36
36
|
|
|
37
37
|
const ROOT = path.resolve(__dirname, '../../..');
|
|
38
|
-
const LIVE_PORTS = new Set([5757, 5790, 8787, 8790]);
|
|
38
|
+
const LIVE_PORTS = new Set([5757, 5760, 5790, 5810, 8787, 8790]);
|
|
39
39
|
|
|
40
40
|
function git(cwd, args) {
|
|
41
41
|
const result = spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', windowsHide: true, env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
|
|
@@ -361,6 +361,15 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
|
|
|
361
361
|
return snapshot.body.memories || [];
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
+
const addGroup = async (name, projectIds) => {
|
|
365
|
+
const created = await engineApi('POST', '/api/memory-groups', { name });
|
|
366
|
+
assert.equal(created.status, 200, JSON.stringify(created.body));
|
|
367
|
+
const { group } = created.body;
|
|
368
|
+
const binding = await engineApi('POST', `/api/memory-groups/${group.id}/project-bindings`, { addProjectIds: projectIds });
|
|
369
|
+
assert.equal(binding.status, 200, JSON.stringify(binding.body));
|
|
370
|
+
return group;
|
|
371
|
+
};
|
|
372
|
+
|
|
364
373
|
/** The memories the engine would inject into a task for one project. */
|
|
365
374
|
const injectedMemories = async projectId => {
|
|
366
375
|
const context = await engineApi('POST', '/api/context', { projectId, query: '长期记忆', task: 'memory-lane' });
|
|
@@ -373,17 +382,16 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
|
|
|
373
382
|
* quotes the real human event, the quote contains the memory text, and it
|
|
374
383
|
* declares why the text is a durable, cross-project owner preference.
|
|
375
384
|
*/
|
|
376
|
-
const memoryCandidate = ({ text, event
|
|
385
|
+
const memoryCandidate = ({ text, event }) => ({
|
|
377
386
|
text,
|
|
378
387
|
quote: text,
|
|
379
|
-
scopeType,
|
|
380
388
|
sourceEventId: event.eventId,
|
|
381
389
|
sourceHash: event.contentHash,
|
|
382
390
|
eligibility: {
|
|
383
391
|
durable: true,
|
|
384
392
|
crossProject: true,
|
|
385
393
|
reason: '人工明确表达的长期偏好',
|
|
386
|
-
scopeReason:
|
|
394
|
+
scopeReason: '跨项目可复用的约定',
|
|
387
395
|
},
|
|
388
396
|
});
|
|
389
397
|
|
|
@@ -392,7 +400,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
|
|
|
392
400
|
* conversation event bound to it, the stand-in analyzer's manifest and the
|
|
393
401
|
* engine's own promotion and capture.
|
|
394
402
|
*/
|
|
395
|
-
const produceCandidate = async ({ repo, projectId, text,
|
|
403
|
+
const produceCandidate = async ({ repo, projectId, text, inputOrigin = 'human', file = 'src/candidate.js' }) => {
|
|
396
404
|
const head = commitFile(repo, file, `// ${text}\n`, 'candidate commit');
|
|
397
405
|
const event = await ingestUserEvent({
|
|
398
406
|
projectId,
|
|
@@ -401,7 +409,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
|
|
|
401
409
|
inputOrigin,
|
|
402
410
|
});
|
|
403
411
|
plan.document = `# 冻结证据\n\n${text}\n`;
|
|
404
|
-
plan.memoryCandidates = [memoryCandidate({ text, event
|
|
412
|
+
plan.memoryCandidates = [memoryCandidate({ text, event })];
|
|
405
413
|
const run = await triggerRun(projectId, head);
|
|
406
414
|
return { run, event, commitSha: head, capture: run.memoryCapture };
|
|
407
415
|
};
|
|
@@ -473,7 +481,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
|
|
|
473
481
|
nativeClick, pressKey, pressTab, pressEnter, typeText,
|
|
474
482
|
importProject, addDomain, ingestUserEvent, triggerRun,
|
|
475
483
|
brainScopePath, domainScopePath, productMemories, injectedMemories,
|
|
476
|
-
memoryCandidate, produceCandidate,
|
|
484
|
+
addGroup, memoryCandidate, produceCandidate,
|
|
477
485
|
cleanup,
|
|
478
486
|
};
|
|
479
487
|
}
|
|
@@ -45,7 +45,7 @@ const os = require('node:os');
|
|
|
45
45
|
const path = require('node:path');
|
|
46
46
|
|
|
47
47
|
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
48
|
-
const PROTECTED_PORTS = new Set([5757, 5760, 5789, 5790, 8787, 8790]);
|
|
48
|
+
const PROTECTED_PORTS = new Set([5757, 5760, 5789, 5790, 5810, 8787, 8790]);
|
|
49
49
|
|
|
50
50
|
// Captured at module load, before any isolation rebuilds the environment.
|
|
51
51
|
const LIVE_HOME = process.env.USERPROFILE || process.env.HOME || os.homedir();
|
|
@@ -194,6 +194,8 @@ function applyDriverIsolation({ prefix = 'pk-qa-engine-endpoint', captureChrome
|
|
|
194
194
|
|
|
195
195
|
const parsed = path.parse(layout.home);
|
|
196
196
|
const envMap = {
|
|
197
|
+
// Chromium 使用 locale 编码下载文件名。 / Chromium uses the locale for download filenames.
|
|
198
|
+
...(process.platform === 'linux' ? { LANG: 'C.UTF-8' } : {}),
|
|
197
199
|
HOME: layout.home,
|
|
198
200
|
USERPROFILE: layout.home,
|
|
199
201
|
HOMEDRIVE: parsed.root,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const http = require('node:http');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { execFileSync, execFile } = require('node:child_process');
|
|
7
|
+
const { promisify } = require('node:util');
|
|
8
|
+
|
|
9
|
+
const command = promisify(execFile);
|
|
10
|
+
const host = '127.0.0.1';
|
|
11
|
+
const BRIDGE_PACKAGE = '@sanqianx/ai-coding-event-bridge-console';
|
|
12
|
+
|
|
13
|
+
function git(repo, ...args) {
|
|
14
|
+
return execFileSync('git', args, { cwd: repo, encoding: 'utf8', windowsHide: true, timeout: 30_000 }).trim();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function gitAsync(repo, ...args) {
|
|
18
|
+
const { stdout } = await command('git', args, { cwd: repo, encoding: 'utf8', windowsHide: true, timeout: 30_000 });
|
|
19
|
+
return stdout.trim();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function prepareMaintenanceFixture({ sandbox, coreInstall, workflowData, projectId }) {
|
|
23
|
+
const repo = path.join(sandbox, 'repos', projectId);
|
|
24
|
+
const remote = path.join(sandbox, 'isolated upstream.git');
|
|
25
|
+
const emptyHooks = path.join(sandbox, 'empty-hooks');
|
|
26
|
+
for (const directory of [repo, remote, emptyHooks]) fs.mkdirSync(directory, { recursive: true });
|
|
27
|
+
git(remote, 'init', '-q', '--bare', '-b', 'main');
|
|
28
|
+
git(repo, 'init', '-q', '-b', 'main');
|
|
29
|
+
git(repo, 'config', '--local', 'core.hooksPath', emptyHooks);
|
|
30
|
+
git(repo, 'config', '--local', 'user.name', 'Synthetic Maintenance QA');
|
|
31
|
+
git(repo, 'config', '--local', 'user.email', 'maintenance-qa@example.invalid');
|
|
32
|
+
git(repo, 'config', '--local', 'core.autocrlf', 'false');
|
|
33
|
+
fs.writeFileSync(path.join(repo, 'policy.txt'), 'PASS\n');
|
|
34
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Isolated maintenance fixture\n');
|
|
35
|
+
git(repo, 'add', '.');
|
|
36
|
+
git(repo, 'commit', '-qm', 'fixture baseline');
|
|
37
|
+
const baseline = git(repo, 'rev-parse', 'HEAD');
|
|
38
|
+
git(repo, 'remote', 'add', 'origin', remote);
|
|
39
|
+
git(repo, 'push', '-u', 'origin', 'main');
|
|
40
|
+
git(repo, 'config', '--local', 'core.hooksPath', '.git/hooks');
|
|
41
|
+
|
|
42
|
+
const tool = path.join(sandbox, 'install', 'tool.js');
|
|
43
|
+
fs.copyFileSync(path.join(__dirname, 'single-repo-maintenance-tool.js'), tool);
|
|
44
|
+
const cli = mode => [process.execPath, tool, mode];
|
|
45
|
+
const configPath = path.join(workflowData, 'workflow', 'maintenance.json');
|
|
46
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
47
|
+
fs.writeFileSync(configPath, JSON.stringify({
|
|
48
|
+
version: 1, projectId, repoPath: repo, branch: 'main', remote: 'origin', allowPush: true,
|
|
49
|
+
tools: [
|
|
50
|
+
{ id: 'review', name: '示例代码规则', kind: 'review', check: cli('check'), repair: cli('repair') },
|
|
51
|
+
{ id: 'format', name: '示例格式整理器', kind: 'apply', apply: cli('format') },
|
|
52
|
+
{ id: 'docs', name: '示例文档工具', kind: 'apply', apply: cli('docs') },
|
|
53
|
+
{ id: 'reject', name: '示例未通过规则', kind: 'review', check: cli('reject'), repair: cli('stubborn'), maxRepairs: 1 },
|
|
54
|
+
{ id: 'timeout', name: '示例超时命令', kind: 'apply', apply: cli('timeout'), timeoutSeconds: 1 },
|
|
55
|
+
{ id: 'probe', name: '示例推送授权检查', kind: 'apply', apply: cli('record') },
|
|
56
|
+
],
|
|
57
|
+
}, null, 2));
|
|
58
|
+
|
|
59
|
+
const bridgeInstall = path.join(sandbox, 'install', 'bridge');
|
|
60
|
+
const bridgeSource = path.dirname(require.resolve(BRIDGE_PACKAGE + '/package.json'));
|
|
61
|
+
fs.mkdirSync(bridgeInstall);
|
|
62
|
+
for (const item of ['package.json', 'src']) fs.cpSync(path.join(bridgeSource, item), path.join(bridgeInstall, item), { recursive: true });
|
|
63
|
+
const bridgeHome = process.env.AI_CODING_EVENT_BRIDGE_HOME;
|
|
64
|
+
const bridgeModule = path.join(bridgeInstall, 'src', 'bridge', 'index.js');
|
|
65
|
+
const { createBridge, resolveRepoContext, projectRegistry, projectJournalDir, Journal } = require(bridgeModule);
|
|
66
|
+
const { createConsoleServer } = require(path.join(bridgeInstall, 'src', 'server'));
|
|
67
|
+
const bridge = createBridge({ homeDir: bridgeHome });
|
|
68
|
+
const server = http.createServer(createConsoleServer({ home: bridgeHome }));
|
|
69
|
+
|
|
70
|
+
function installHook(dataDir, port) {
|
|
71
|
+
const { installHook } = require(path.join(coreInstall, '_site', 'lib', 'hook-manager'));
|
|
72
|
+
const { writeEndpoint } = require(path.join(coreInstall, '_site', 'lib', 'runtime-endpoint'));
|
|
73
|
+
writeEndpoint(dataDir, { host, port, pid: process.pid });
|
|
74
|
+
return installHook({
|
|
75
|
+
projectId, repoPath: repo, dataDir, bridgeHomeDir: bridgeHome, bridgeModulePath: bridgeModule,
|
|
76
|
+
triggerScriptPath: path.join(coreInstall, '_site', 'scripts', 'hook-trigger.js'),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function appendBoundary(overrides = {}) {
|
|
80
|
+
const { repoIdentity } = await resolveRepoContext(repo);
|
|
81
|
+
return bridge.appendCommitBoundary({
|
|
82
|
+
projectId, repoIdentity, commitSha: git(repo, 'rev-parse', 'HEAD'), branch: 'main', ...overrides,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function registerProject() {
|
|
86
|
+
const project = await projectRegistry.addProject({ home: bridgeHome, path: repo, store: path.join(sandbox, 'bridge project store') });
|
|
87
|
+
const old = await appendBoundary();
|
|
88
|
+
await new Journal(projectJournalDir(project)).trimThrough(old.sequence);
|
|
89
|
+
return project.id;
|
|
90
|
+
}
|
|
91
|
+
return { repo, remote, baseline, configPath, projectId, server, bridge, installHook, appendBoundary, registerProject, git, gitAsync };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = { prepareMaintenanceFixture };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
const input = JSON.parse(fs.readFileSync(0, 'utf8'));
|
|
8
|
+
assert.equal(input.schema, 'ai-team-maintenance/v1');
|
|
9
|
+
assert.equal(fs.realpathSync(input.workspace), fs.realpathSync(process.cwd()));
|
|
10
|
+
assert.equal(typeof input.member.instructions, 'string');
|
|
11
|
+
assert.equal(process.env.KB_WORKFLOW_RUNTIME_TOKEN, undefined);
|
|
12
|
+
assert.equal(process.env.GIT_DIR, undefined);
|
|
13
|
+
const mode = process.argv[2];
|
|
14
|
+
|
|
15
|
+
switch (mode) {
|
|
16
|
+
case 'check':
|
|
17
|
+
assert.equal(input.phase, 'check');
|
|
18
|
+
assert.deepEqual(input.member.memoryGroupIds, ['group-code']);
|
|
19
|
+
if (fs.readFileSync('policy.txt', 'utf8').trim() !== 'PASS') {
|
|
20
|
+
console.log(JSON.stringify({ path: 'policy.txt', expected: 'PASS' }));
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
case 'repair':
|
|
25
|
+
assert.equal(input.phase, 'repair');
|
|
26
|
+
assert.equal(JSON.parse(input.findings.stdout.text).path, 'policy.txt');
|
|
27
|
+
fs.writeFileSync('policy.txt', 'PASS\n');
|
|
28
|
+
break;
|
|
29
|
+
case 'format':
|
|
30
|
+
assert.equal(input.phase, 'apply');
|
|
31
|
+
fs.writeFileSync('formatted.txt', 'one line\n');
|
|
32
|
+
console.log('format completed');
|
|
33
|
+
break;
|
|
34
|
+
case 'docs':
|
|
35
|
+
assert.equal(input.phase, 'apply');
|
|
36
|
+
assert.ok(fs.existsSync('formatted.txt'), 'docs reads the updated remote baseline');
|
|
37
|
+
fs.mkdirSync('docs', { recursive: true });
|
|
38
|
+
fs.writeFileSync(path.join('docs', 'usage.md'), '# Formatted repository\n');
|
|
39
|
+
break;
|
|
40
|
+
case 'reject':
|
|
41
|
+
console.log('Additional fixes required');
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
break;
|
|
44
|
+
case 'stubborn':
|
|
45
|
+
fs.writeFileSync('unresolved.txt', 'Keep this after failed review\n');
|
|
46
|
+
break;
|
|
47
|
+
case 'timeout':
|
|
48
|
+
fs.writeFileSync('timed-out.txt', 'Keep this after timeout\n');
|
|
49
|
+
setTimeout(() => {}, 10_000);
|
|
50
|
+
break;
|
|
51
|
+
case 'record':
|
|
52
|
+
fs.writeFileSync('push-permission.txt', 'This candidate should stay local\n');
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
throw new Error('Unknown fixture tool action.');
|
|
56
|
+
}
|
|
@@ -51,7 +51,7 @@ async function main() {
|
|
|
51
51
|
await harness.browser.send('Input.insertText', { text: '开发时保护日常服务' });
|
|
52
52
|
await harness.nativeClick('#memoryForm textarea[name=text]');
|
|
53
53
|
await harness.browser.send('Input.insertText', { text: MULTILINE_BODY });
|
|
54
|
-
|
|
54
|
+
assert.equal(await harness.run("Boolean(document.querySelector('#memoryForm [name=scopeType], #memoryForm [name=scopeTarget]'))"), false);
|
|
55
55
|
await harness.run("(() => { const sel = document.getElementById('memoryForm').elements.groupId; sel.value = [...sel.options].find(o => o.text.includes('通用约定'))?.value || ''; return sel.value !== ''; })()");
|
|
56
56
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
57
57
|
await harness.waitFor(() => harness.run("document.getElementById('appDialog').open === false"), 'the memory editor closes');
|
|
@@ -124,7 +124,7 @@ async function main() {
|
|
|
124
124
|
await harness.waitFor(() => harness.run("[...document.querySelectorAll('.memory-folders button')].some(b => b.textContent.includes('通用约定')) && [...document.querySelectorAll('.memory-item')].some(el => el.textContent.includes('开发时保护日常服务'))"), 'the group and its memory survive a reload');
|
|
125
125
|
|
|
126
126
|
// ---------- 7. 候选审核:确认并加入组合 ----------
|
|
127
|
-
await harness.produceCandidate({ repo: repoA, projectId: projectIdA, text: '界面变更先给可点击的预览,确认流程后再实施。'
|
|
127
|
+
await harness.produceCandidate({ repo: repoA, projectId: projectIdA, text: '界面变更先给可点击的预览,确认流程后再实施。' });
|
|
128
128
|
await harness.nativeClick('nav [data-view="home"]');
|
|
129
129
|
await harness.waitFor(() => harness.run("document.getElementById('homeContent').textContent.includes('待确认记忆') && document.getElementById('homeCount') !== null"), 'the home overview renders');
|
|
130
130
|
await harness.waitFor(() => harness.run("document.body.textContent.includes('界面变更先给可点击的预览')"), 'the candidate preview shows on home');
|
|
@@ -134,7 +134,31 @@ async function main() {
|
|
|
134
134
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
135
135
|
await harness.waitFor(() => harness.run("document.getElementById('appDialog').open === false"), 'the review dialog closes');
|
|
136
136
|
const confirmed = (await harness.engineApi('GET', `/api/memories?status=confirmed&groupId=${group.id}&limit=10`)).body;
|
|
137
|
-
assert.ok(confirmed.memories.some(m => m.text.includes('可点击的预览')), 'the confirmed candidate
|
|
137
|
+
assert.ok(confirmed.memories.some(m => m.text.includes('可点击的预览') && m.scopeType === 'group'), 'the confirmed candidate activates through its group');
|
|
138
|
+
|
|
139
|
+
await harness.produceCandidate({ repo: repoB, projectId: projectIdB, text: '验收包必须包含独立的操作清单。' });
|
|
140
|
+
await harness.nativeClick('nav [data-view="memory"]');
|
|
141
|
+
await harness.nativeClick('[data-memory-tab="candidate"]');
|
|
142
|
+
await harness.selectOption('#candidateProjectFilter', projectIdB);
|
|
143
|
+
await harness.waitFor(() => harness.run("document.getElementById('memoryContent').textContent.includes('独立的操作清单')"), 'the candidate filter selects by source project before it is assigned to a group');
|
|
144
|
+
await harness.selectOption('#candidateProjectFilter', projectIdA);
|
|
145
|
+
await harness.waitFor(() => harness.run("!document.getElementById('memoryContent').textContent.includes('独立的操作清单')"), 'another project does not show this candidate');
|
|
146
|
+
|
|
147
|
+
const downloadDir = path.join(harness.fixture, 'downloads');
|
|
148
|
+
fs.mkdirSync(downloadDir);
|
|
149
|
+
await harness.browser.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: downloadDir });
|
|
150
|
+
await harness.nativeClick('nav [data-view="projects"]');
|
|
151
|
+
await harness.nativeClick(`[data-action="project-detail"][data-id="${projectIdA}"]`);
|
|
152
|
+
await harness.waitFor(() => harness.run("Boolean(document.querySelector('[data-action=export-memories]:not([disabled])'))"), 'the effective memory page enables its export control');
|
|
153
|
+
await harness.nativeClick('[data-action="export-memories"]:not([disabled])');
|
|
154
|
+
const download = await harness.waitFor(
|
|
155
|
+
() => fs.readdirSync(downloadDir).find(name => name.endsWith('-MEMORY.md')),
|
|
156
|
+
'the browser downloads the complete project Markdown',
|
|
157
|
+
);
|
|
158
|
+
const exported = fs.readFileSync(path.join(downloadDir, download), 'utf8');
|
|
159
|
+
assert.match(exported, /^# 项目甲 · 生效记忆/);
|
|
160
|
+
assert.ok(exported.includes(MULTILINE_BODY), 'the download keeps the multiline memory intact');
|
|
161
|
+
assert.doesNotMatch(exported, /独立的操作清单/, 'pending candidates are absent from the export');
|
|
138
162
|
|
|
139
163
|
// ---------- 8. 首页组合入口 ----------
|
|
140
164
|
await harness.nativeClick('nav [data-view="home"]');
|
|
@@ -168,8 +168,8 @@ async function main() {
|
|
|
168
168
|
|
|
169
169
|
// 1. Two real candidates through the real pipeline: A will be ignored,
|
|
170
170
|
// B stays candidate and is the healthy-page contrast.
|
|
171
|
-
const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A,
|
|
172
|
-
const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B,
|
|
171
|
+
const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, file: 'src/r4-candidate-a.js' });
|
|
172
|
+
const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, file: 'src/r4-candidate-b.js' });
|
|
173
173
|
assert.equal(producedA.capture.accepted, 1, `run A admitted one candidate: ${JSON.stringify(producedA.capture)}`);
|
|
174
174
|
assert.equal(producedB.capture.accepted, 1, `run B admitted one candidate: ${JSON.stringify(producedB.capture)}`);
|
|
175
175
|
const memories = await harness.productMemories();
|
|
@@ -164,18 +164,18 @@ async function scenarioOriginExclusion(lane, evidence, commands) {
|
|
|
164
164
|
|
|
165
165
|
// ---- C01: the open item is blocked explicitly, the implementation is intact ----
|
|
166
166
|
const injected = await callJson(engineUrl, '/api/memories', {
|
|
167
|
-
text: '注入来源证据的记忆',
|
|
167
|
+
text: '注入来源证据的记忆', evidence: { projectId: PROJECT_ID, commitSha: sha },
|
|
168
168
|
});
|
|
169
169
|
assert.equal(injected.status, 400, `evidence injection must be refused (status ${injected.status})`);
|
|
170
170
|
assert.equal(injected.body?.error, 'INVALID_ARGUMENT', `unexpected error code ${injected.body?.error}`);
|
|
171
|
-
assert.match(String(injected.body?.message || ''),
|
|
171
|
+
assert.match(String(injected.body?.message || ''), /只支持填写标题、记忆内容、所属智脑和组合/, 'the refusal states the C01 rule explicitly');
|
|
172
172
|
|
|
173
173
|
// A manual memory (explicit user confirmation) still stores no evidence.
|
|
174
174
|
const brainScope = await callJson(engineUrl, '/api/scopes', {
|
|
175
175
|
scopes: [{ id: 'brain-default', kind: 'brain', brainId: 'brain-default', name: '默认智脑', knowledgePath: brainPath }],
|
|
176
176
|
}, { headers: { authorization: 'Bearer eng012-lane-token' } });
|
|
177
177
|
assert.equal(brainScope.status, 200, `brain scope binding failed: ${JSON.stringify(brainScope.body)}`);
|
|
178
|
-
const manual = await callJson(engineUrl, '/api/memories', { text: MANUAL_TEXT
|
|
178
|
+
const manual = await callJson(engineUrl, '/api/memories', { text: MANUAL_TEXT });
|
|
179
179
|
assert.equal(manual.status, 200, `manual memory creation failed: ${JSON.stringify(manual.body)}`);
|
|
180
180
|
assert.equal(manual.body?.memory?.sourceType, 'manual');
|
|
181
181
|
assert.equal(manual.body?.memory?.evidence, null, 'a manual record stores no evidence');
|
|
@@ -334,7 +334,7 @@ async function main() {
|
|
|
334
334
|
'expected1 维护/委派不能自动成为人类长期偏好': 'PASS',
|
|
335
335
|
'expected2 C01未定项不得自动删除实现': 'PASS',
|
|
336
336
|
originExclusion: 'the frozen commit conversation snapshot carries both origins; the engine rejected the delegated candidate with SOURCE_NOT_HUMAN and kept the human one as a plain candidate - nothing was confirmed automatically',
|
|
337
|
-
c01Block: 'POST /api/memories with an injected source-evidence field is refused with INVALID_ARGUMENT (
|
|
337
|
+
c01Block: 'POST /api/memories with an injected source-evidence field is refused with INVALID_ARGUMENT (only editable memory fields are accepted); a manual memory is stored with evidence null and sourceType manual, so the MEM-008 implementation was not deleted',
|
|
338
338
|
noImplementationDeletion: 'a manifest that tries to delete an implementation file is refused by the promotion path (PATH_OUTSIDE_ROOT); the run fails, no knowledge operation is applied and the implementation files stay byte-identical',
|
|
339
339
|
analyzerStandin: 'deterministic stand-in that deliberately emits both the human and the delegated candidate - NO real model output covered',
|
|
340
340
|
vectorService: 'real vector-hub server, deterministic test embeddings - paid embedding API NOT covered',
|
|
@@ -107,6 +107,7 @@ async function main() {
|
|
|
107
107
|
try {
|
|
108
108
|
const repo = makeRepo(harness.fixture, 'memcand-repo', { 'README.md': '# 候选甲\n' });
|
|
109
109
|
const { projectId } = await harness.importProject(repo, '候选甲');
|
|
110
|
+
const group = await harness.addGroup('候选甲约定', [projectId]);
|
|
110
111
|
await harness.requestRegistryRefresh();
|
|
111
112
|
// The new home page no longer lists projects; the registry projection is
|
|
112
113
|
// surfaced by the topbar project selector instead.
|
|
@@ -117,7 +118,7 @@ async function main() {
|
|
|
117
118
|
);
|
|
118
119
|
|
|
119
120
|
// ---------------------------------------------------------------- MEM-003
|
|
120
|
-
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT
|
|
121
|
+
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
|
|
121
122
|
assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
|
|
122
123
|
assert.deepEqual(produced.capture.rejected, [], 'the real gate rejected nothing for a human source');
|
|
123
124
|
|
|
@@ -125,8 +126,8 @@ async function main() {
|
|
|
125
126
|
assert.ok(stored, 'the candidate really exists in the engine');
|
|
126
127
|
assert.equal(stored.status, 'candidate', 'the automatic memory is saved as a candidate');
|
|
127
128
|
assert.notEqual(stored.sourceType, 'manual', 'an automatic candidate is not a manual memory');
|
|
128
|
-
assert.equal(stored.scopeType, '
|
|
129
|
-
assert.
|
|
129
|
+
assert.equal(stored.scopeType, 'group');
|
|
130
|
+
assert.deepEqual(stored.groups, [], 'the candidate has no assignment');
|
|
130
131
|
assert.equal(stored.evidence.projectId, projectId, 'the frozen source names the source project');
|
|
131
132
|
assert.equal(stored.evidence.commitSha, produced.commitSha, 'the frozen source names the real commit');
|
|
132
133
|
assert.ok(stored.evidence.entryId, 'the frozen source names the promoted entry');
|
|
@@ -223,6 +224,7 @@ async function main() {
|
|
|
223
224
|
'the review dialog is open again',
|
|
224
225
|
10000,
|
|
225
226
|
);
|
|
227
|
+
await harness.selectOption('#reviewForm select[name=groupId]', group.id);
|
|
226
228
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
227
229
|
await harness.waitFor(
|
|
228
230
|
() => harness.run("document.getElementById('appDialog').open === false"),
|
|
@@ -231,7 +233,7 @@ async function main() {
|
|
|
231
233
|
);
|
|
232
234
|
const patch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).pop();
|
|
233
235
|
assert.ok(patch, 'the shell really patched the candidate');
|
|
234
|
-
assert.deepEqual(patch.body, { status: 'confirmed' }, 'the confirmation
|
|
236
|
+
assert.deepEqual(patch.body, { status: 'confirmed', groupId: group.id }, 'the confirmation assigns the chosen combination');
|
|
235
237
|
assert.equal(patch.status, 200, `the confirmation answers 200: ${JSON.stringify(patch.body)}`);
|
|
236
238
|
const patchBody = await harness.network.body(patch);
|
|
237
239
|
assert.ok(patchBody && patchBody.memory, `the confirmation answers with the memory: ${JSON.stringify(patchBody)}`);
|
|
@@ -268,7 +270,7 @@ async function main() {
|
|
|
268
270
|
});
|
|
269
271
|
|
|
270
272
|
// ---------------------------------------------------------------- MEM-005
|
|
271
|
-
const second = await harness.produceCandidate({ repo, projectId, text: IGNORED_TEXT,
|
|
273
|
+
const second = await harness.produceCandidate({ repo, projectId, text: IGNORED_TEXT, file: 'src/ignored.js' });
|
|
272
274
|
assert.equal(second.capture.accepted, 1, `the second real run admitted one candidate: ${JSON.stringify(second.capture)}`);
|
|
273
275
|
const toIgnore = (await harness.productMemories()).find(memory => memory.text === IGNORED_TEXT);
|
|
274
276
|
assert.ok(toIgnore, 'the second candidate really exists in the engine');
|
|
@@ -138,7 +138,7 @@ async function main() {
|
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
// 1. A real candidate through the real pipeline.
|
|
141
|
-
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT
|
|
141
|
+
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
|
|
142
142
|
assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
|
|
143
143
|
const candidate = (await harness.productMemories()).find(memory => memory.text === CANDIDATE_TEXT);
|
|
144
144
|
assert.ok(candidate, 'the candidate really exists in the engine');
|
|
@@ -161,8 +161,8 @@ async function main() {
|
|
|
161
161
|
|
|
162
162
|
// 1. Two real candidates through the real pipeline: A will be ignored,
|
|
163
163
|
// B stays candidate and is the healthy-page contrast.
|
|
164
|
-
const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A,
|
|
165
|
-
const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B,
|
|
164
|
+
const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, file: 'src/r4-candidate-a.js' });
|
|
165
|
+
const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, file: 'src/r4-candidate-b.js' });
|
|
166
166
|
assert.equal(producedA.capture.accepted, 1, `run A admitted one candidate: ${JSON.stringify(producedA.capture)}`);
|
|
167
167
|
assert.equal(producedB.capture.accepted, 1, `run B admitted one candidate: ${JSON.stringify(producedB.capture)}`);
|
|
168
168
|
const memories = await harness.productMemories();
|
|
@@ -73,7 +73,7 @@ async function main() {
|
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
// A real candidate through the real pipeline (commit + event + run + gate).
|
|
76
|
-
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT
|
|
76
|
+
const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
|
|
77
77
|
assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
|
|
78
78
|
const stored = (await harness.productMemories()).find(m => m.text === CANDIDATE_TEXT);
|
|
79
79
|
assert.ok(stored, 'the candidate really exists in the engine');
|
|
@@ -43,9 +43,7 @@
|
|
|
43
43
|
// N 随引擎版本由 2000 变为 8000(MEMORY_TEXT_LIMIT),断言语义不变。
|
|
44
44
|
// * 旧 UI 的默认作用域=当前项目;新表单默认=组合记忆。MEM-001 的「项目
|
|
45
45
|
// 作用域存储」语义保持:在表单里显式选择 适用范围=项目 +
|
|
46
|
-
//
|
|
47
|
-
// [data-role="scope-target"] select[name="scopeTarget"]),存储的
|
|
48
|
-
// scopeType/scopeId 另用 engineApi GET /api/memories 复核。
|
|
46
|
+
// 选择已应用到当前项目的组合,存储结果透过引擎 API 复核。
|
|
49
47
|
// * 「导入项目已列出」等待:旧首页项目面板(homeContent 含项目名)已删除,
|
|
50
48
|
// 等价为顶栏 #projectSelect 选项里出现项目名(同一 registry projection)。
|
|
51
49
|
// * 其余引擎断言(POST 200、confirmed/manual/evidence null、磁盘记忆文件
|
|
@@ -90,6 +88,7 @@ async function main() {
|
|
|
90
88
|
const { projectId } = await harness.importProject(repo, '记忆甲');
|
|
91
89
|
|
|
92
90
|
// The shell has to know the project before it can bind a project scope.
|
|
91
|
+
const group = await harness.addGroup('记忆甲约定', [projectId]);
|
|
93
92
|
await harness.requestRegistryRefresh();
|
|
94
93
|
// The new home page no longer lists projects; the registry projection is
|
|
95
94
|
// surfaced by the topbar project selector instead.
|
|
@@ -164,11 +163,11 @@ async function main() {
|
|
|
164
163
|
assert.equal(postsAfter, postsBefore, 'the shell must not send a request for a blank body');
|
|
165
164
|
|
|
166
165
|
// The backend refuses the same blank body on its own.
|
|
167
|
-
const backendBlank = await harness.productApi('POST', '/api/engine/memories', { text: ' ',
|
|
166
|
+
const backendBlank = await harness.productApi('POST', '/api/engine/memories', { text: ' ', brainId: 'brain-default' });
|
|
168
167
|
assert.equal(backendBlank.status, 400, `the engine refuses a blank body: ${JSON.stringify(backendBlank.body)}`);
|
|
169
168
|
assert.equal(backendBlank.body.error, 'INVALID_ARGUMENT', 'the engine reports an invalid argument');
|
|
170
169
|
assert.match(String(backendBlank.body.message), /记忆内容必须为 1–8000 个字符。/, 'the engine names the length rule (MEMORY_TEXT_LIMIT is 8000 in the current engine)');
|
|
171
|
-
const backendBlankEngine = await harness.engineApi('POST', '/api/memories', { text: ' ',
|
|
170
|
+
const backendBlankEngine = await harness.engineApi('POST', '/api/memories', { text: ' ', brainId: 'brain-default' });
|
|
172
171
|
assert.equal(backendBlankEngine.status, 400, `the engine behind the proxy refuses it too: ${JSON.stringify(backendBlankEngine.body)}`);
|
|
173
172
|
|
|
174
173
|
const afterBlank = await harness.productMemories();
|
|
@@ -195,18 +194,8 @@ async function main() {
|
|
|
195
194
|
const body = await harness.run("document.getElementById('memoryForm').elements.text.value");
|
|
196
195
|
assert.equal(body, MEMORY_TEXT, 'the real body reached the textarea');
|
|
197
196
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// chosen explicitly through the real selects.
|
|
201
|
-
await harness.selectOption('#memoryForm select[name="scopeType"]', 'project');
|
|
202
|
-
await harness.waitFor(
|
|
203
|
-
() => harness.run("document.querySelector('#memoryForm [data-role=\"scope-target\"]').hidden === false"),
|
|
204
|
-
'the project scope target select is shown',
|
|
205
|
-
10000,
|
|
206
|
-
);
|
|
207
|
-
const targetOptions = await harness.run("Array.from(document.querySelector('#memoryForm [data-role=\"scope-target\"] select[name=\"scopeTarget\"]').options).map(o => o.value)");
|
|
208
|
-
assert.ok(targetOptions.includes(projectId), `the project scope offers ${projectId}: ${JSON.stringify(targetOptions)}`);
|
|
209
|
-
await harness.selectOption('#memoryForm [data-role="scope-target"] select[name="scopeTarget"]', projectId);
|
|
197
|
+
assert.equal(await harness.run("document.querySelector('#memoryForm select[name=scopeType]')"), null);
|
|
198
|
+
await harness.selectOption('#memoryForm select[name="groupId"]', group.id);
|
|
210
199
|
|
|
211
200
|
const postsBeforeSave = harness.network.find(entry => entry.method === 'POST' && entry.url.includes('/api/engine/memories')).length;
|
|
212
201
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
@@ -227,15 +216,15 @@ async function main() {
|
|
|
227
216
|
assert.equal(created.evidence, null, 'a manual memory invents no evidence');
|
|
228
217
|
assert.equal(created.text, MEMORY_TEXT, 'the saved text is the text that was typed');
|
|
229
218
|
assert.equal(created.title, MEMORY_TITLE, 'the saved title is the title that was typed');
|
|
230
|
-
assert.equal(created.scopeType, '
|
|
231
|
-
assert.
|
|
219
|
+
assert.equal(created.scopeType, 'group');
|
|
220
|
+
assert.deepEqual(created.groups.map(item => item.id), [group.id]);
|
|
232
221
|
assert.ok(created.id, 'the memory has an id');
|
|
233
222
|
|
|
234
223
|
// The engine's own record confirms the stored scope pair.
|
|
235
224
|
const engineRecord = (await harness.engineApi('GET', '/api/memories')).body.memories.find(memory => memory.id === created.id);
|
|
236
225
|
assert.ok(engineRecord, 'the engine really stored the memory');
|
|
237
|
-
assert.equal(engineRecord.scopeType, '
|
|
238
|
-
assert.
|
|
226
|
+
assert.equal(engineRecord.scopeType, 'group');
|
|
227
|
+
assert.deepEqual(engineRecord.groups.map(item => item.id), [group.id]);
|
|
239
228
|
assert.equal(engineRecord.status, 'confirmed', 'the engine stores the memory as confirmed');
|
|
240
229
|
|
|
241
230
|
// The memory is listed in the real UI (the 记忆库 tab lists confirmed
|
|
@@ -249,7 +238,7 @@ async function main() {
|
|
|
249
238
|
|
|
250
239
|
// The memory file really holds the memory.
|
|
251
240
|
const brainScope = harness.brainScopePath();
|
|
252
|
-
const memoryFile = path.join(brainScope, 'memories', '
|
|
241
|
+
const memoryFile = path.join(brainScope, 'memories', 'groups', `${group.id}.md`);
|
|
253
242
|
assert.ok(fs.existsSync(memoryFile), `the memory file exists: ${memoryFile}`);
|
|
254
243
|
const fileText = fs.readFileSync(memoryFile, 'utf8');
|
|
255
244
|
assert.ok(fileText.includes(created.id), 'the memory file names the memory');
|
|
@@ -274,8 +263,8 @@ async function main() {
|
|
|
274
263
|
assert.ok(kept, 'the memory survives the reload');
|
|
275
264
|
assert.equal(kept.status, 'confirmed', 'the memory is still confirmed after the reload');
|
|
276
265
|
assert.equal(kept.text, MEMORY_TEXT, 'the memory text survives the reload');
|
|
277
|
-
assert.equal(kept.scopeType, '
|
|
278
|
-
assert.
|
|
266
|
+
assert.equal(kept.scopeType, 'group');
|
|
267
|
+
assert.deepEqual(kept.groups.map(item => item.id), [group.id]);
|
|
279
268
|
assert.equal(kept.syncStatus, 'ready', 'the memory file is in sync');
|
|
280
269
|
|
|
281
270
|
evidence.push({
|
|
@@ -294,7 +283,7 @@ async function main() {
|
|
|
294
283
|
fs.writeFileSync(path.join(harness.evidence, 'mem001-manual.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
|
|
295
284
|
}
|
|
296
285
|
|
|
297
|
-
console.log(`parallel-memory-manual-test PASS (MEM-001 confirmed with
|
|
286
|
+
console.log(`parallel-memory-manual-test PASS (MEM-001 confirmed with a project-bound combination + survives a real reload; MEM-002 refused by native required and by the shell without a request, and by the engine with 400)`);
|
|
298
287
|
} finally {
|
|
299
288
|
await harness.cleanup();
|
|
300
289
|
}
|