@sanqianx/project-knowledge 5.0.30 → 5.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +21 -0
  3. package/_site/_test/appearance-settings-test.js +148 -0
  4. package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
  5. package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
  6. package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
  7. package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
  8. package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
  9. package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
  10. package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
  11. package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
  12. package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
  13. package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
  14. package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
  15. package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
  16. package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
  17. package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
  18. package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
  19. package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
  20. package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
  21. package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
  22. package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
  23. package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
  24. package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
  25. package/_site/_test/helpers/qa-r45-harness.js +94 -0
  26. package/_site/_test/helpers/qa-r48-env.js +64 -0
  27. package/_site/_test/helpers/qa-r51-env.cjs +77 -0
  28. package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
  29. package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
  30. package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
  31. package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
  32. package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
  33. package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
  34. package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
  35. package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
  36. package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
  37. package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
  38. package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
  39. package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
  40. package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
  41. package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
  42. package/_site/_test/parallel-memory-injection-probe.js +411 -0
  43. package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
  44. package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
  45. package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
  46. package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
  47. package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
  48. package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
  49. package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
  50. package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
  51. package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
  52. package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
  53. package/_site/_test/t07d-git-rel-coverage-test.js +224 -0
  54. package/_site/_test/t07e-qta-coverage-test.js +195 -0
  55. package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
  56. package/_site/lib/server-app.js +11 -2
  57. package/_site/lib/settings-store.js +43 -1
  58. package/module-runtime-manifest.json +6 -6
  59. package/package.json +1 -1
  60. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  61. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  62. package/plugins/project-knowledge/.mcp.json +1 -1
  63. package/ui/index.html +18 -1
  64. package/ui/product.css +6 -2
  65. package/ui/product.js +86 -1
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+ // P-LOG-ACCEPTANCE-01 LOG-003 probe: API-level reproduction of the first-failure
3
+ // wait (project-scope entry count) without the browser, to bisect fixture/API
4
+ // vs UI. Lane-exclusive file, evidence-only, not a regression test.
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const crypto = require('node:crypto');
9
+
10
+ const LANE_TEMP_BASE = 'D:/SanQian.Xu/.project-knowledge-test-temp';
11
+ fs.mkdirSync(LANE_TEMP_BASE, { recursive: true });
12
+ const laneTmp = fs.mkdtempSync(path.join(LANE_TEMP_BASE, 'log003-probe-'));
13
+ process.env.TEMP = process.env.TMP = process.env.TMPDIR = laneTmp;
14
+
15
+ const { spawnServer } = require('./helpers/spawn-server');
16
+ const { waitFor } = require('./helpers/cdp-browser');
17
+ const freePort = require('./helpers/free-port');
18
+ const { createLoggingAcceptanceFixture, writeProjectLogs } = require('./helpers/parallel-logging-acceptance-fixture');
19
+
20
+ const ROOT = path.resolve(__dirname, '../..');
21
+ const PROJECT_A = 'project-log003-alpha';
22
+ const PROJECT_B = 'project-log003-beta';
23
+ const run = crypto.randomBytes(6).toString('hex');
24
+ const OP_ALPHA = `op-log003-alpha-${run}`;
25
+
26
+ async function main() {
27
+ const fixture = await createLoggingAcceptanceFixture({
28
+ caseId: 'log003-probe',
29
+ projects: [
30
+ { projectId: PROJECT_A, displayName: 'LOG003甲项目' },
31
+ { projectId: PROJECT_B, displayName: 'LOG003乙项目' },
32
+ ],
33
+ });
34
+ await writeProjectLogs(fixture.logger, PROJECT_A, [
35
+ ...Array.from({ length: 4 }, (_, index) => ({ level: index % 2 ? 'warn' : 'info', event: `log003.alpha.flow.${index}`, message: `甲项目流程记录 ${index}`, operationId: OP_ALPHA })),
36
+ ...Array.from({ length: 6 }, (_, index) => ({ level: 'info', event: `log003.alpha.other.${index}`, message: `甲项目普通记录 ${index}`, operationId: `op-log003-alpha-other-${run}-${index}` })),
37
+ ]);
38
+ await writeProjectLogs(fixture.logger, PROJECT_B, [
39
+ ...Array.from({ length: 8 }, (_, index) => ({ level: 'info', event: `log003.beta.${index}`, message: `乙项目记录 ${index}`, operationId: `op-log003-beta-${run}-${index}` })),
40
+ ]);
41
+ await fixture.logger.info('log003.system.note', '系统范围记录', {});
42
+ await fixture.logger.close();
43
+
44
+ const walkLogs = dir => {
45
+ const out = [];
46
+ const visit = p => {
47
+ for (const name of fs.readdirSync(p)) {
48
+ const full = path.join(p, name);
49
+ if (fs.statSync(full).isDirectory()) visit(full); else out.push(path.relative(dir, full));
50
+ }
51
+ };
52
+ visit(dir);
53
+ return out;
54
+ };
55
+ console.log('DISK logs tree:', JSON.stringify(walkLogs(path.join(fixture.dataDir, 'logs'))));
56
+
57
+ const port = await freePort();
58
+ const base = `http://127.0.0.1:${port}`;
59
+ const server = spawnServer({ root: ROOT, port, dataDir: fixture.dataDir, tag: 'log003-probe', stdio: 'ignore' });
60
+ try {
61
+ await waitFor(async () => { try { return (await fetch(`${base}/api/health`)).ok; } catch { return false; } }, 'probe server', 20000);
62
+ const get = async suffix => {
63
+ const res = await fetch(`${base}/api/logs${suffix}`);
64
+ const body = await res.json();
65
+ return { status: res.status, count: (body.entries || []).length, levels: [...new Set((body.entries || []).map(e => e.level))], projects: [...new Set((body.entries || []).map(e => e.projectId))] };
66
+ };
67
+ console.log('PROJECT A:', JSON.stringify(await get(`?pageSize=100&projectId=${PROJECT_A}`)));
68
+ console.log('PROJECT B:', JSON.stringify(await get(`?pageSize=100&projectId=${PROJECT_B}`)));
69
+ console.log('ALL:', JSON.stringify(await get('?pageSize=100')));
70
+ console.log('Q-OP-A:', JSON.stringify(await get(`?pageSize=100&q=${encodeURIComponent(OP_ALPHA)}`)));
71
+ const projects = await (await fetch(`${base}/api/projects`)).json();
72
+ console.log('REGISTRY:', JSON.stringify(projects));
73
+ } finally {
74
+ try { await server.cleanup(); } finally { fixture.cleanup(); }
75
+ }
76
+ }
77
+
78
+ main().then(() => { console.log('PROBE-DONE'); process.exit(0); }, error => { console.error('PROBE-FAIL', error); process.exit(1); });
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+ // P-LOG-ACCEPTANCE-01 LOG-004 probe: find which real APIs append project-
3
+ // attributed records (needed as the live-insert mechanism at the query/
4
+ // subscribe boundary). Lane-exclusive, evidence-only.
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+
9
+ const LANE_TEMP_BASE = 'D:/SanQian.Xu/.project-knowledge-test-temp';
10
+ fs.mkdirSync(LANE_TEMP_BASE, { recursive: true });
11
+ const laneTmp = fs.mkdtempSync(path.join(LANE_TEMP_BASE, 'log004-probe-'));
12
+ process.env.TEMP = process.env.TMP = process.env.TMPDIR = laneTmp;
13
+
14
+ const { spawnServer } = require('./helpers/spawn-server');
15
+ const { waitFor } = require('./helpers/cdp-browser');
16
+ const freePort = require('./helpers/free-port');
17
+ const { createLoggingAcceptanceFixture } = require('./helpers/parallel-logging-acceptance-fixture');
18
+
19
+ const ROOT = path.resolve(__dirname, '../..');
20
+ const PROJECT_A = 'project-log004-alpha';
21
+
22
+ async function main() {
23
+ const fixture = await createLoggingAcceptanceFixture({
24
+ caseId: 'log004-probe',
25
+ projects: [{ projectId: PROJECT_A, displayName: 'LOG004甲项目' }],
26
+ });
27
+ await fixture.logger.close();
28
+
29
+ const port = await freePort();
30
+ const base = `http://127.0.0.1:${port}`;
31
+ const server = spawnServer({ root: ROOT, port, dataDir: fixture.dataDir, tag: 'log004-probe' });
32
+ const serverStderr = []; const serverStdout = [];
33
+ server.child.stderr.on('data', chunk => serverStderr.push(String(chunk)));
34
+ server.child.stdout.on('data', chunk => serverStdout.push(String(chunk)));
35
+ server.child.on('exit', (code, signal) => out.push({ call: 'SERVER-EXIT', status: `code=${code} signal=${signal}` }));
36
+ const out = [];
37
+ try {
38
+ await waitFor(async () => { try { return (await fetch(`${base}/api/health`)).ok; } catch { return false; } }, 'probe server', 20000);
39
+ const day = new Date().toISOString().slice(0, 10);
40
+ const projectFile = path.join(fixture.dataDir, 'logs', 'projects', PROJECT_A, `${day}.jsonl`);
41
+ const systemFile = path.join(fixture.dataDir, 'logs', 'system', `${day}.jsonl`);
42
+ const lines = file => (fs.existsSync(file) ? fs.readFileSync(file, 'utf8').trim().split('\n').filter(Boolean) : []);
43
+ const projectEvents = () => lines(projectFile).map(l => JSON.parse(l).event);
44
+ const systemEvents = () => lines(systemFile).map(l => JSON.parse(l).event);
45
+ const projectRecords = () => lines(projectFile).map(l => JSON.parse(l));
46
+ let projBefore = projectEvents().length, sysBefore = systemEvents().length;
47
+
48
+ const candidates = [
49
+ ['GET /api/engine/snapshot?projectId', () => fetch(`${base}/api/engine/snapshot?summary=1&limit=50&projectId=${PROJECT_A}`).then(r => r.status)],
50
+ ['GET /api/projects/<id>', () => fetch(`${base}/api/projects/${PROJECT_A}`).then(r => r.status)],
51
+ ['GET /api/logs?projectId', () => fetch(`${base}/api/logs?pageSize=100&projectId=${PROJECT_A}`).then(r => r.status)],
52
+ ['GET /api/logs/export?projectId', () => fetch(`${base}/api/logs/export?projectId=${PROJECT_A}`).then(r => r.status)],
53
+ ['GET /api/engine/runs?projectId', () => fetch(`${base}/api/engine/runs?projectId=${PROJECT_A}`).then(r => r.status)],
54
+ ];
55
+ for (const [name, call] of candidates) {
56
+ const status = await call();
57
+ await new Promise(r => setTimeout(r, 400));
58
+ const projNow = projectEvents().length, sysNow = systemEvents().length;
59
+ out.push({ call: name, status, projectRecordsAdded: projNow - projBefore, systemRecordsAdded: sysNow - sysBefore, projectEvents: projectEvents().slice(projBefore), systemEvents: systemEvents().slice(sysBefore).slice(0, 3) });
60
+ projBefore = projNow; sysBefore = sysNow;
61
+ }
62
+
63
+ // Hook POST stability: does POST /api/hooks/post-commit keep the server healthy?
64
+ for (let i = 1; i <= 3; i += 1) {
65
+ const op = `op-log004-probe-live-${i}-${Date.now()}`;
66
+ let hookStatus = 'throw';
67
+ try {
68
+ const res = await fetch(`${base}/api/hooks/post-commit`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ schema: 'hook-event/v2', projectId: PROJECT_A, repoRoot: fixture.projects[0].repo.path, operationId: op }) });
69
+ hookStatus = `${res.status} ${JSON.stringify(await res.json().catch(() => null))}`;
70
+ } catch (error) { hookStatus = `throw ${error.message}`; }
71
+ await new Promise(r => setTimeout(r, 600));
72
+ let health = 'down';
73
+ try { health = (await fetch(`${base}/api/health`)).status; } catch (error) { health = `throw ${error.message}`; }
74
+ const projNow = projectEvents().length;
75
+ out.push({ call: `POST /api/hooks/post-commit #${i}`, status: hookStatus, healthAfter: health, projectRecordsAdded: projNow - projBefore, projectRecords: projectRecords().slice(projBefore) });
76
+ projBefore = projNow;
77
+ }
78
+ } finally {
79
+ try { await server.cleanup(); } finally { fixture.cleanup(); }
80
+ }
81
+ fs.writeFileSync(path.join(laneTmp, 'probe-result.json'), JSON.stringify({ out, serverStderr: serverStderr.join(''), serverStdout: serverStdout.join('') }, null, 2));
82
+ console.log(JSON.stringify(out.map(row => ({ call: row.call, status: row.status, proj: row.projectRecordsAdded, sys: row.systemRecordsAdded, projEvents: row.projectEvents }))));
83
+ }
84
+
85
+ main().then(() => process.exit(0), error => { console.error('PROBE-FAIL', error); process.exit(1); });
@@ -0,0 +1,238 @@
1
+ 'use strict';
2
+ // _site/_test/parallel-memory-capture-r3-cap001-probe.js
3
+ //
4
+ // CAP-001 三能力独立 — the external-Agent integration case of
5
+ // qa-autopilot/config/test-cases.json.
6
+ //
7
+ // steps: 检查 Knowledge Integration、Automatic Context、Development Capture。
8
+ // expected: 检测到命令不等于已安装。/ 三能力分别真实验证。
9
+ // evidence: 实际命令与退出码 / UI、接口、磁盘对应证据 / 源HEAD、文件哈希、测试夹具ID
10
+ //
11
+ // WHAT IS REAL HERE
12
+ //
13
+ // * the product server is the real one, on its own port, with its own data
14
+ // dir, its own knowledge dir and its own Bridge journal home;
15
+ // * the browser is a real Chrome (CDP) with its own profile;
16
+ // * the "接入" action is a real click on the real UI control, and the
17
+ // product really runs the real native client CLI (`claude plugin
18
+ // marketplace add` + `claude plugin install`) against an ISOLATED home
19
+ // directory — not a stub, not a dry run;
20
+ // * the three capabilities are then verified INDEPENDENTLY, each against
21
+ // its own artefact on disk: the installed plugin (Knowledge
22
+ // Integration), the plugin's own pre-read files (Automatic Context) and
23
+ // the Bridge hook entries (Development Capture).
24
+ //
25
+ // The developer's real HOME is digested before and after the run and the
26
+ // comparison is part of the evidence: nothing may leak out of the isolated
27
+ // home.
28
+ //
29
+ // WHY THIS FILE IS NOT NAMED *-test.js
30
+ //
31
+ // The case needs the native Claude Code CLI to exist on the machine. The
32
+ // offline CI suite collects every *_test.js and would report a false
33
+ // failure on a runner without that CLI, so the case runs through the
34
+ // product probe entry point (qa-autopilot/tools/product-probes/) instead.
35
+
36
+ const fs = require('node:fs');
37
+ const path = require('node:path');
38
+ const assert = require('node:assert/strict');
39
+ const { execFileSync } = require('node:child_process');
40
+
41
+ const { startCapHarness, ROOT } = require('./helpers/parallel-memory-capture-r3-cap-shell');
42
+
43
+ const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_TEST_EVIDENCE_DIR) : null;
44
+ const CLIENT = 'claude';
45
+
46
+ function gitHead() {
47
+ try {
48
+ return execFileSync('git', ['-C', ROOT, 'rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim();
49
+ } catch { return null; }
50
+ }
51
+
52
+ function repoFileHashes(files) {
53
+ return files.map(file => {
54
+ const full = path.join(ROOT, file);
55
+ let sha256 = null;
56
+ try {
57
+ sha256 = require('node:crypto').createHash('sha256').update(fs.readFileSync(full)).digest('hex');
58
+ } catch { sha256 = null; }
59
+ return { file, exists: fs.existsSync(full), sha256 };
60
+ });
61
+ }
62
+
63
+ async function main() {
64
+ const harness = await startCapHarness({ tag: 'cap001', evidenceDir: EVIDENCE || undefined });
65
+ const evidence = [];
66
+ try {
67
+ // ------------------------------------------------------------------
68
+ // 1. The real UI, before anything is installed.
69
+ // ------------------------------------------------------------------
70
+ await harness.openSystemDrawer();
71
+ const rowBefore = await harness.agentRow(CLIENT);
72
+ assert.ok(rowBefore, `the ${CLIENT} row must be rendered: ${JSON.stringify(await harness.agentRows())}`);
73
+ const statusBefore = await harness.settledStatus();
74
+ const clientBefore = harness.statusClient(statusBefore, CLIENT);
75
+ assert.ok(clientBefore, `the ${CLIENT} status must be reported: ${JSON.stringify(statusBefore)}`);
76
+
77
+ // "检测到命令" is the product's own wording for "the CLI is on PATH".
78
+ // It is exactly what must NOT be mistaken for "the client is connected".
79
+ assert.equal(clientBefore.available, true, 'the native CLI really is detected');
80
+ assert.equal(rowBefore.details.join(' ').includes('检测到命令'), true, `the row must show the detected command: ${JSON.stringify(rowBefore)}`);
81
+ assert.notEqual(rowBefore.badge, '已接入', 'a detected command must not read as an installed client');
82
+ assert.equal(rowBefore.badge, '未接入', `the row must read as not connected: ${JSON.stringify(rowBefore)}`);
83
+ assert.notEqual(clientBefore.knowledgeIntegration.state, 'installed', 'Knowledge Integration is not installed yet');
84
+ assert.notEqual(clientBefore.automaticContext.configured, true, 'Automatic Context is not configured yet');
85
+ assert.notEqual(clientBefore.developmentCapture.installed, true, 'Development Capture is not installed yet');
86
+ assert.equal(clientBefore.summary, 'disconnected', 'the product must not report the client as connected');
87
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'cap001-before.png'));
88
+
89
+ // ------------------------------------------------------------------
90
+ // 2. The real 接入 click on the real UI.
91
+ // ------------------------------------------------------------------
92
+ await harness.nativeClick(`[data-agent-switch="install"][data-agent-client="${CLIENT}"]`);
93
+ await harness.waitFor(
94
+ () => harness.run("document.getElementById('agentCaptureFeedback').textContent.trim().length > 0 && !document.getElementById('agentCaptureFeedback').textContent.includes('正在接入')"),
95
+ 'the 接入 action answers in the UI',
96
+ 180000,
97
+ );
98
+ const feedback = await harness.feedback();
99
+ const installCall = await harness.lastInstallCall();
100
+ assert.ok(installCall, 'the UI really sent an install request');
101
+ assert.equal(installCall.status, 200, `the install request answers 200: ${JSON.stringify(installCall)}`);
102
+ assert.equal(installCall.response.complete, true, `the install must complete: ${JSON.stringify(installCall.response)}`);
103
+ const operationId = installCall.response.operationId;
104
+ assert.ok(operationId, 'the install must report an operation id');
105
+
106
+ // ------------------------------------------------------------------
107
+ // 3. The three capabilities, each verified on its own artefact.
108
+ // ------------------------------------------------------------------
109
+ const statusAfter = await harness.settledStatus();
110
+ const clientAfter = harness.statusClient(statusAfter, CLIENT);
111
+ assert.ok(clientAfter, `the ${CLIENT} status must be reported after the install`);
112
+ await harness.waitFor(
113
+ () => harness.run(`(() => { const row = [...document.querySelectorAll('#agentCaptureList .agent-capture-row')].find(item => item.querySelector('[data-agent-switch]') && item.querySelector('[data-agent-switch]').dataset.agentClient === ${JSON.stringify(CLIENT)}); return Boolean(row) && row.querySelector('.status').textContent === '已接入'; })()`),
114
+ 'the row shows the client as connected',
115
+ 90000,
116
+ );
117
+ const rowAfter = await harness.agentRow(CLIENT);
118
+ assert.equal(rowAfter.badge, '已接入', `the row must read as connected: ${JSON.stringify(rowAfter)}`);
119
+ assert.equal(rowAfter.switch.action, 'uninstall', 'the switch must offer the removal now');
120
+
121
+ // (a) Knowledge Integration — the real plugin really is installed.
122
+ const plugin = harness.pluginEvidence();
123
+ assert.equal(plugin.installedVersion, '5.0.24', `the plugin version must be the shipped one: ${JSON.stringify(plugin.installedPlugins)}`);
124
+ assert.equal(plugin.installPathExists, true, 'the installed plugin directory really exists');
125
+ assert.equal(clientAfter.knowledgeIntegration.state, 'installed', 'the product reports Knowledge Integration as installed');
126
+
127
+ // (b) Automatic Context — the plugin's own pre-read files are really
128
+ // the product's files, byte for byte.
129
+ assert.equal(plugin.allFilesIdentical, true, `the pre-read files must be identical: ${JSON.stringify(plugin.files)}`);
130
+ assert.equal(clientAfter.automaticContext.configured, true, 'the product reports Automatic Context as configured');
131
+ assert.equal(clientAfter.automaticContext.state, 'configured', `the product reports the Automatic Context state: ${JSON.stringify(clientAfter.automaticContext)}`);
132
+
133
+ // (c) Development Capture — the real Bridge hook entries really point at
134
+ // a Bridge entry that exists on disk.
135
+ const hooks = harness.ownedHookEntries();
136
+ const events = [...new Set(hooks.map(entry => entry.event))].sort();
137
+ assert.deepEqual(events, ['Stop', 'UserPromptSubmit'], `both capture events must be wired: ${JSON.stringify(hooks)}`);
138
+ for (const event of events) {
139
+ const owned = hooks.filter(entry => entry.event === event);
140
+ assert.equal(owned.length, 1, `the ${event} hook must exist exactly once: ${JSON.stringify(owned)}`);
141
+ assert.equal(owned[0].shimExists, true, `the ${event} hook must point at a real Bridge entry: ${JSON.stringify(owned[0])}`);
142
+ }
143
+ assert.equal(clientAfter.developmentCapture.installed, true, 'the product reports Development Capture as installed');
144
+ assert.equal(clientAfter.summary, 'connected', 'the product reports the client as connected');
145
+
146
+ // The real commands the product ran, with their real exit codes, read
147
+ // from the product's own diagnostics log.
148
+ const commandLog = await harness.productApi('GET', '/api/logs?q=integration.command_completed&pageSize=50');
149
+ assert.equal(commandLog.status, 200, `the diagnostics log must be readable: ${JSON.stringify(commandLog.body)}`);
150
+ const commands = (commandLog.body.entries || [])
151
+ .filter(entry => String(entry.event || '').includes('integration.command'))
152
+ .map(entry => ({
153
+ event: entry.event,
154
+ level: entry.level,
155
+ client: entry.context && entry.context.client ? entry.context.client : null,
156
+ status: entry.context && entry.context.status !== undefined ? entry.context.status : null,
157
+ argumentCount: entry.context && entry.context.argumentCount !== undefined ? entry.context.argumentCount : null,
158
+ argsHash: entry.context && entry.context.argsHash ? entry.context.argsHash : null,
159
+ }));
160
+ assert.ok(commands.length > 0, 'the product must record the native commands it really ran');
161
+ assert.equal(commands.every(entry => entry.status === 0), true, `every native command must have exited 0: ${JSON.stringify(commands)}`);
162
+
163
+ // ------------------------------------------------------------------
164
+ // 4. Nothing leaked into the developer's real home.
165
+ //
166
+ // The developer's own Claude Code and Codex sessions run while the case
167
+ // runs, so transcripts, logs and caches change on their own. The claim
168
+ // that matters is therefore about the client's CONFIGURATION surface —
169
+ // the files an integration writes into — and about every changed file
170
+ // outside the known runtime set, which must be empty.
171
+ // ------------------------------------------------------------------
172
+ const configAfter = harness.digestRealClientConfigs();
173
+ const configComparison = harness.compareConfigSurface(harness.realHomeBefore, configAfter);
174
+ assert.equal(configComparison.byteIdentical, true, `the real client configuration must be untouched: ${JSON.stringify({ changedFiles: configComparison.changedFiles, changedDirs: configComparison.changedDirs })}`);
175
+
176
+ const treeComparison = harness.compareRealTrees(harness.realTreesBefore, harness.digestRealClientTrees());
177
+ assert.deepEqual(treeComparison.leaks, [], `nothing outside the runtime set may change in the real home: ${JSON.stringify(treeComparison.leaks)}`);
178
+ assert.deepEqual(treeComparison.configChanges, [], `no configuration file may change in the real home: ${JSON.stringify(treeComparison.configChanges)}`);
179
+
180
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'cap001-after.png'));
181
+
182
+ evidence.push({
183
+ case: 'CAP-001',
184
+ fixture: { tag: 'cap001', fixtureDir: harness.fixture, isolatedHome: harness.homeDir, port: Number(harness.base.split(':').pop()) },
185
+ source: { repoRoot: ROOT, gitHead: gitHead(), pluginFiles: repoFileHashes(['plugins/project-knowledge/hooks/claude.json', 'plugins/project-knowledge/scripts/context-hook.cjs', 'plugins/project-knowledge/.mcp.json', 'plugins/project-knowledge/.claude-plugin/plugin.json']) },
186
+ before: {
187
+ ui: { badge: rowBefore.badge, details: rowBefore.details, switch: rowBefore.switch },
188
+ api: { available: clientBefore.available, configFound: clientBefore.configFound, summary: clientBefore.summary, knowledgeIntegration: clientBefore.knowledgeIntegration, automaticContext: clientBefore.automaticContext, developmentCapture: clientBefore.developmentCapture },
189
+ claim: 'the command is detected, nothing is installed',
190
+ },
191
+ action: {
192
+ control: `[data-agent-switch="install"][data-agent-client="${CLIENT}"]`,
193
+ realClick: true,
194
+ feedback,
195
+ request: installCall.request,
196
+ httpStatus: installCall.status,
197
+ operationId,
198
+ complete: installCall.response.complete,
199
+ },
200
+ after: {
201
+ ui: { badge: rowAfter.badge, details: rowAfter.details, switch: rowAfter.switch },
202
+ api: { summary: clientAfter.summary, knowledgeIntegration: clientAfter.knowledgeIntegration, automaticContext: clientAfter.automaticContext, developmentCapture: clientAfter.developmentCapture },
203
+ },
204
+ capabilities: {
205
+ knowledgeIntegration: { state: clientAfter.knowledgeIntegration.state, installedVersion: plugin.installedVersion, installPath: plugin.installPath, installPathExists: plugin.installPathExists, marketplaceSource: plugin.marketplaceSource, installedPluginsFile: plugin.indexFile },
206
+ automaticContext: { state: clientAfter.automaticContext.state, configured: clientAfter.automaticContext.configured, files: plugin.files, allFilesIdentical: plugin.allFilesIdentical },
207
+ developmentCapture: { state: clientAfter.developmentCapture.state, installed: clientAfter.developmentCapture.installed, ownedHookEntries: hooks, events },
208
+ },
209
+ nativeCommands: commands,
210
+ realHomeIsolation: {
211
+ configuration: {
212
+ byteIdentical: configComparison.byteIdentical,
213
+ changedFiles: configComparison.changedFiles,
214
+ changedDirs: configComparison.changedDirs,
215
+ },
216
+ tree: {
217
+ leaks: treeComparison.leaks,
218
+ configChanges: treeComparison.configChanges,
219
+ runtimeChangeCount: treeComparison.runtimeChanges,
220
+ changed: treeComparison.changed,
221
+ },
222
+ scopeLabel: 'honest: the developer\'s own live client sessions keep writing transcripts and caches in the real home while the case runs; the isolation claim is about the client configuration surface and about every changed file outside the known runtime set',
223
+ },
224
+ scopeLabel: 'honest: the native client CLI really ran against an isolated home; no model turn was performed',
225
+ });
226
+
227
+ if (harness.evidence) {
228
+ fs.mkdirSync(harness.evidence, { recursive: true });
229
+ fs.writeFileSync(path.join(harness.evidence, 'cap001-three-capabilities.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
230
+ }
231
+
232
+ console.log('parallel-memory-capture-r3-cap001-probe PASS (the detected command was not an installed client; after the real 接入 click the three capabilities are verified independently on disk)');
233
+ } finally {
234
+ await harness.cleanup();
235
+ }
236
+ }
237
+
238
+ main().catch(error => { console.error(error.stack || error.message); process.exitCode = 1; });