@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +21 -0
- package/_site/_test/appearance-settings-test.js +148 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
- package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
- package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
- package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
- package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
- package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
- package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
- package/_site/_test/helpers/qa-r45-harness.js +94 -0
- package/_site/_test/helpers/qa-r48-env.js +64 -0
- package/_site/_test/helpers/qa-r51-env.cjs +77 -0
- package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
- package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
- package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
- package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
- package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
- package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
- package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
- package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
- package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
- package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
- package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
- package/_site/_test/parallel-memory-injection-probe.js +411 -0
- package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
- package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
- package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
- package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
- package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
- package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
- package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
- package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
- package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
- package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
- package/_site/_test/t07d-git-rel-coverage-test.js +224 -0
- package/_site/_test/t07e-qta-coverage-test.js +195 -0
- package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
- package/_site/lib/server-app.js +11 -2
- package/_site/lib/settings-store.js +43 -1
- package/module-runtime-manifest.json +6 -6
- package/package.json +1 -1
- 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/ui/index.html +18 -1
- package/ui/product.css +6 -2
- package/ui/product.js +86 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// _site/_test/helpers/parallel-memory-capture-r3-shell.js
|
|
3
|
+
//
|
|
4
|
+
// Lane helper for the P-MEMORY-CAPTURE-R3 batch.
|
|
5
|
+
//
|
|
6
|
+
// The P-MEMORY-01 harness (helpers/parallel-memory-shell.js) and the two
|
|
7
|
+
// stand-ins it drives are FROZEN and owned by the Leader. This lane REUSES
|
|
8
|
+
// them READ-ONLY: they are imported, never edited, never copied over, and
|
|
9
|
+
// their SHA-256 is written into every evidence file, so a later integration
|
|
10
|
+
// by the Leader is detectable instead of silent.
|
|
11
|
+
//
|
|
12
|
+
// What this helper adds on top of the frozen harness:
|
|
13
|
+
// * provenance() - the frozen sources this lane depends on;
|
|
14
|
+
// * sourceFingerprint()- a comparable fingerprint of ONE frozen memory
|
|
15
|
+
// source: the promoted entry file on disk, the Git commit it came from
|
|
16
|
+
// and the frozen conversation event;
|
|
17
|
+
// * memoryFrozenFields()/compareFrozen() - the subset of a memory record
|
|
18
|
+
// that an ignore action must never rewrite;
|
|
19
|
+
// * engineStateOnDisk()- the engine's own persisted projection, so
|
|
20
|
+
// "the status survived a reload" can be proven at rest and not only
|
|
21
|
+
// through a live in-memory projection.
|
|
22
|
+
|
|
23
|
+
const crypto = require('node:crypto');
|
|
24
|
+
const fs = require('node:fs');
|
|
25
|
+
const path = require('node:path');
|
|
26
|
+
const { spawnSync } = require('node:child_process');
|
|
27
|
+
|
|
28
|
+
const FROZEN_SOURCES = [
|
|
29
|
+
{ piece: 'memory lane harness (reused read-only)', file: require.resolve('./parallel-memory-shell') },
|
|
30
|
+
{ piece: 'memory lane stand-in analyzer (reused read-only)', file: require.resolve('./parallel-memory-analyzer') },
|
|
31
|
+
{ piece: 'memory lane event-bridge stand-in (reused read-only)', file: require.resolve('./parallel-memory-event-bridge') },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
function sha256File(file) {
|
|
35
|
+
try { return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); } catch { return null; }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function sha256Text(text) {
|
|
39
|
+
return crypto.createHash('sha256').update(String(text)).digest('hex');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function relativeToRoot(file) {
|
|
43
|
+
return path.relative(path.resolve(__dirname, '..', '..', '..'), file).replace(/\\/g, '/');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The frozen sources this lane depends on, with the hash of each file. */
|
|
47
|
+
function provenance() {
|
|
48
|
+
return FROZEN_SOURCES.map(source => ({
|
|
49
|
+
piece: source.piece,
|
|
50
|
+
source: relativeToRoot(source.file),
|
|
51
|
+
sourceSha256: sha256File(source.file),
|
|
52
|
+
sourceExists: fs.existsSync(source.file),
|
|
53
|
+
usage: 'imported read-only; never edited by this lane',
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function gitText(cwd, args) {
|
|
58
|
+
const result = spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', windowsHide: true });
|
|
59
|
+
if (result.status !== 0) return null;
|
|
60
|
+
return String(result.stdout || '').trim();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A comparable fingerprint of the frozen source of one memory candidate.
|
|
65
|
+
*
|
|
66
|
+
* The three artefacts are the ones the product shows as 来源依据: the
|
|
67
|
+
* promoted entry file, the commit it was promoted from and the frozen
|
|
68
|
+
* conversation event. A later comparison proves that ignoring the candidate
|
|
69
|
+
* rewrote none of them.
|
|
70
|
+
*/
|
|
71
|
+
function sourceFingerprint({ knowledgePath, entryId, repoPath, commitSha, eventId, events }) {
|
|
72
|
+
const entryFile = entryId && knowledgePath ? path.resolve(knowledgePath, entryId) : null;
|
|
73
|
+
const entry = { path: entryFile, exists: false, sha256: null, bytes: null };
|
|
74
|
+
if (entryFile && fs.existsSync(entryFile)) {
|
|
75
|
+
const bytes = fs.readFileSync(entryFile);
|
|
76
|
+
entry.exists = true;
|
|
77
|
+
entry.sha256 = crypto.createHash('sha256').update(bytes).digest('hex');
|
|
78
|
+
entry.bytes = bytes.length;
|
|
79
|
+
}
|
|
80
|
+
const git = { commitSha: commitSha || null, commitExists: false, tree: null };
|
|
81
|
+
if (repoPath && commitSha) {
|
|
82
|
+
git.commitExists = gitText(repoPath, ['cat-file', '-t', commitSha]) === 'commit';
|
|
83
|
+
git.tree = gitText(repoPath, ['rev-parse', `${commitSha}^{tree}`]);
|
|
84
|
+
}
|
|
85
|
+
const found = (events || []).find(event => event.eventId === eventId) || null;
|
|
86
|
+
const event = found ? {
|
|
87
|
+
eventId: found.eventId,
|
|
88
|
+
contentHash: found.contentHash,
|
|
89
|
+
inputOrigin: found.inputOrigin,
|
|
90
|
+
role: found.role || null,
|
|
91
|
+
} : null;
|
|
92
|
+
return { entry, git, event };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The part of a memory record that an ignore action must never rewrite.
|
|
97
|
+
*
|
|
98
|
+
* The status is deliberately NOT part of it: ignoring is exactly the action
|
|
99
|
+
* that changes the status, and the engine itself refuses any other field.
|
|
100
|
+
*/
|
|
101
|
+
function memoryFrozenFields(memory) {
|
|
102
|
+
if (!memory) return null;
|
|
103
|
+
return {
|
|
104
|
+
id: memory.id,
|
|
105
|
+
text: memory.text,
|
|
106
|
+
evidence: {
|
|
107
|
+
projectId: memory.evidence ? memory.evidence.projectId : null,
|
|
108
|
+
commitSha: memory.evidence ? memory.evidence.commitSha : null,
|
|
109
|
+
entryId: memory.evidence ? memory.evidence.entryId : null,
|
|
110
|
+
quote: memory.evidence ? memory.evidence.quote : null,
|
|
111
|
+
},
|
|
112
|
+
sourceEventId: memory.sourceEventId || null,
|
|
113
|
+
sourceHash: memory.sourceHash || null,
|
|
114
|
+
eligibility: memory.eligibility || null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Compare the frozen source of one memory before and after an action. */
|
|
119
|
+
function compareFrozen(before, after) {
|
|
120
|
+
const diffs = [];
|
|
121
|
+
const same = (label, left, right) => {
|
|
122
|
+
const equal = JSON.stringify(left) === JSON.stringify(right);
|
|
123
|
+
if (!equal) diffs.push(label);
|
|
124
|
+
return equal;
|
|
125
|
+
};
|
|
126
|
+
const entrySha256Same = same('entry.sha256', before.source.entry.sha256, after.source.entry.sha256);
|
|
127
|
+
const entryBytesSame = same('entry.bytes', before.source.entry.bytes, after.source.entry.bytes);
|
|
128
|
+
const gitTreeSame = same('git.tree', before.source.git.tree, after.source.git.tree);
|
|
129
|
+
const gitCommitSame = same('git.commitSha', before.source.git.commitSha, after.source.git.commitSha);
|
|
130
|
+
const eventHashSame = same('event.contentHash', before.source.event && before.source.event.contentHash, after.source.event && after.source.event.contentHash);
|
|
131
|
+
const eventIdSame = same('event.eventId', before.source.event && before.source.event.eventId, after.source.event && after.source.event.eventId);
|
|
132
|
+
const memorySame = same('memory.frozenFields', before.memory, after.memory);
|
|
133
|
+
return {
|
|
134
|
+
identical: diffs.length === 0,
|
|
135
|
+
diffs,
|
|
136
|
+
entrySha256Same,
|
|
137
|
+
entryBytesSame,
|
|
138
|
+
gitTreeSame,
|
|
139
|
+
gitCommitSame,
|
|
140
|
+
eventHashSame,
|
|
141
|
+
eventIdSame,
|
|
142
|
+
memoryFrozenFieldsSame: memorySame,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The engine's own persisted projection, read from its state file.
|
|
148
|
+
*
|
|
149
|
+
* This is the "at rest" truth: a live projection could be an in-memory
|
|
150
|
+
* artefact of a running process, the file is what survives a restart.
|
|
151
|
+
*/
|
|
152
|
+
function engineStateOnDisk(engine) {
|
|
153
|
+
const file = engine && engine.store ? engine.store.file : null;
|
|
154
|
+
if (!file || !fs.existsSync(file)) return { file, exists: false, memories: [] };
|
|
155
|
+
let parsed = null;
|
|
156
|
+
try { parsed = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { parsed = null; }
|
|
157
|
+
return {
|
|
158
|
+
file,
|
|
159
|
+
exists: true,
|
|
160
|
+
sha256: sha256File(file),
|
|
161
|
+
memories: parsed && Array.isArray(parsed.memories) ? parsed.memories : [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = {
|
|
166
|
+
FROZEN_SOURCES,
|
|
167
|
+
sha256File,
|
|
168
|
+
sha256Text,
|
|
169
|
+
relativeToRoot,
|
|
170
|
+
provenance,
|
|
171
|
+
gitText,
|
|
172
|
+
sourceFingerprint,
|
|
173
|
+
memoryFrozenFields,
|
|
174
|
+
compareFrozen,
|
|
175
|
+
engineStateOnDisk,
|
|
176
|
+
};
|