@sanqianx/project-knowledge 5.0.29 → 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 +16 -16
- package/package.json +2 -2
- 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,314 @@
|
|
|
1
|
+
// _site/_test/helpers/parallel-dock-isolation-r3-ui.js
|
|
2
|
+
//
|
|
3
|
+
// Lane-exclusive real-UI driver for P-DOCK-ISOLATION-R3. Derived from the
|
|
4
|
+
// R1 helper (parallel-dock-acceptance-ui.js, read-only reference).
|
|
5
|
+
//
|
|
6
|
+
// All interactions happen in a REAL browser against REAL pages:
|
|
7
|
+
// - the product page (pkb) with the real workbench iframe inside it,
|
|
8
|
+
// - the workbench module's own shipped panel host proof page, loaded from
|
|
9
|
+
// the same isolated module, used as a real host for the
|
|
10
|
+
// two-simultaneous-panel case.
|
|
11
|
+
// Observation is additive only: extra window message listeners that record
|
|
12
|
+
// kb:* traffic, plus real DOM reads. Nothing in the product or the module is
|
|
13
|
+
// wrapped, replaced or removed.
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
|
|
20
|
+
const { launchCdpBrowser, waitFor } = require('./cdp-browser');
|
|
21
|
+
const { findChrome } = require('./find-chrome');
|
|
22
|
+
|
|
23
|
+
// Records every kb:* message that crosses a window boundary, including the
|
|
24
|
+
// requestId, so a host-issued protocol request can be matched with its
|
|
25
|
+
// reply. Additive: it never intercepts or rewrites a message.
|
|
26
|
+
const LISTENER = (slot) => `(() => {
|
|
27
|
+
if (window.${slot}) return true;
|
|
28
|
+
window.${slot} = [];
|
|
29
|
+
window.addEventListener('message', ev => {
|
|
30
|
+
const data = ev.data;
|
|
31
|
+
if (!data || typeof data.type !== 'string' || !data.type.startsWith('kb:')) return;
|
|
32
|
+
window.${slot}.push({
|
|
33
|
+
t: Date.now(), type: data.type,
|
|
34
|
+
requestId: data.requestId || null,
|
|
35
|
+
panelId: data.panelId || null, providerId: data.providerId || null,
|
|
36
|
+
version: data.version === undefined ? null : data.version,
|
|
37
|
+
ok: data.ok === undefined ? null : data.ok,
|
|
38
|
+
code: data.code || null, error: data.error || null,
|
|
39
|
+
sessionId: data.sessionId || null, projectId: data.projectId || null,
|
|
40
|
+
activeProjectId: data.activeProjectId || null,
|
|
41
|
+
reason: data.reason || null,
|
|
42
|
+
panels: Array.isArray(data.panels) ? data.panels.map(p => ({
|
|
43
|
+
panelId: p.panelId, providerId: p.providerId, panelType: p.panelType || null,
|
|
44
|
+
open: p.open, active: p.active, ready: p.ready, error: p.error || null,
|
|
45
|
+
contentVersion: p.content && p.content.version !== undefined ? p.content.version : null,
|
|
46
|
+
contentAck: p.content && p.content.ack ? { version: p.content.ack.version, ok: p.content.ack.ok, error: p.content.ack.error || null } : null,
|
|
47
|
+
scope: p.scope || null,
|
|
48
|
+
})) : null,
|
|
49
|
+
providers: Array.isArray(data.providers) ? data.providers.map(p => ({ providerId: p.providerId, panelType: p.panelType || null, title: p.title || null })) : null,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
})()`;
|
|
54
|
+
|
|
55
|
+
function termExpr(body) {
|
|
56
|
+
return `(() => {
|
|
57
|
+
const frame = document.getElementById('workFrame');
|
|
58
|
+
const doc = frame && frame.contentDocument;
|
|
59
|
+
if (!doc) return null;
|
|
60
|
+
${body}
|
|
61
|
+
})()`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function frameEval(browser, body) {
|
|
65
|
+
return browser.evaluate(termExpr(body));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function openWorkView(browser, productUrl, { timeoutMs = 90000 } = {}) {
|
|
69
|
+
await waitFor(() => browser.evaluate(`!!document.querySelector('[data-select-project]')`), 'product project list on home', timeoutMs);
|
|
70
|
+
await browser.evaluate(`document.querySelector('[data-select-project]').click(); true`);
|
|
71
|
+
await waitFor(() => browser.evaluate(`document.getElementById('workEmpty') && document.getElementById('workEmpty').hidden === true`), 'active project', 20000);
|
|
72
|
+
await browser.evaluate(`document.querySelector('[data-view="work"]').click(); true`);
|
|
73
|
+
await waitFor(() => browser.evaluate(`(() => { const f = document.getElementById('workFrame'); return !!(f && f.src); })()`), 'work frame src', 20000);
|
|
74
|
+
await waitFor(() => frameEval(browser, `return !!doc.getElementById('btn-new-session');`), 'terminal iframe loaded', timeoutMs);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function installProductLog(browser) {
|
|
78
|
+
await browser.evaluate(LISTENER('__r3ProductLog'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function installTerminalLog(browser) {
|
|
82
|
+
await waitFor(() => browser.evaluate(`(() => {
|
|
83
|
+
const frame = document.getElementById('workFrame');
|
|
84
|
+
const win = frame && frame.contentWindow;
|
|
85
|
+
if (!win) return false;
|
|
86
|
+
if (win.__r3TermLog) return true;
|
|
87
|
+
win.__r3TermLog = [];
|
|
88
|
+
win.addEventListener('message', ev => {
|
|
89
|
+
const data = ev.data;
|
|
90
|
+
if (!data || typeof data.type !== 'string' || !data.type.startsWith('kb:')) return;
|
|
91
|
+
win.__r3TermLog.push({
|
|
92
|
+
t: Date.now(), type: data.type,
|
|
93
|
+
requestId: data.requestId || null,
|
|
94
|
+
panelId: data.panelId || null, providerId: data.providerId || null,
|
|
95
|
+
version: data.version === undefined ? null : data.version,
|
|
96
|
+
ok: data.ok === undefined ? null : data.ok,
|
|
97
|
+
code: data.code || null, error: data.error || null,
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
})()`), 'terminal message listener', 15000);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function getLogs(browser) {
|
|
105
|
+
const productLog = await browser.evaluate(`window.__r3ProductLog ? window.__r3ProductLog.slice() : []`);
|
|
106
|
+
const termLog = await frameEval(browser, `return (frame.contentWindow.__r3TermLog || []).slice();`);
|
|
107
|
+
return { productLog, termLog };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function dockSnapshot(browser) {
|
|
111
|
+
return frameEval(browser, `return (() => {
|
|
112
|
+
const toggle = doc.getElementById('btn-dock-toggle');
|
|
113
|
+
const dock = doc.getElementById('right-dock');
|
|
114
|
+
const tabs = Array.from(doc.querySelectorAll('.rd-tabs .rd-tab')).map((item, index) => ({
|
|
115
|
+
index,
|
|
116
|
+
label: (item.querySelector('.rd-tab-label') || { textContent: '' }).textContent || '',
|
|
117
|
+
title: item.title || '',
|
|
118
|
+
active: item.classList.contains('active'),
|
|
119
|
+
selected: item.querySelector('.rd-tab-open') ? item.querySelector('.rd-tab-open').getAttribute('aria-selected') === 'true' : false,
|
|
120
|
+
dot: (item.querySelector('.rd-dot') || { className: '' }).className || '',
|
|
121
|
+
hasClose: !!item.querySelector('.rd-tab-close'),
|
|
122
|
+
}));
|
|
123
|
+
return {
|
|
124
|
+
toggleHidden: !toggle || toggle.hidden,
|
|
125
|
+
expanded: toggle ? toggle.getAttribute('aria-expanded') : null,
|
|
126
|
+
toggleTitle: toggle ? toggle.title : null,
|
|
127
|
+
dockHidden: !dock || dock.hidden,
|
|
128
|
+
dockOpenClass: !!doc.querySelector('.dock-open'),
|
|
129
|
+
tabCount: tabs.length,
|
|
130
|
+
tabs,
|
|
131
|
+
hostFrames: doc.querySelectorAll('.rd-host-frame').length,
|
|
132
|
+
hostFrameTitles: Array.from(doc.querySelectorAll('.rd-host-frame')).map(frame => frame.getAttribute('title') || ''),
|
|
133
|
+
launcherPanes: doc.querySelectorAll('.rd-launcher').length,
|
|
134
|
+
};
|
|
135
|
+
})();`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function termClick(browser, body, label, timeoutMs = 15000) {
|
|
139
|
+
await waitFor(() => frameEval(browser, body), label, timeoutMs);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function newSessionViaUi(browser) {
|
|
143
|
+
await termClick(browser, `const n = doc.getElementById('btn-new-session'); if (!n) return false; n.click(); return true;`, 'new-session button');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function clickSessionRow(browser, sessionId) {
|
|
147
|
+
await termClick(browser, `const n = doc.querySelector('[data-session="${sessionId}"]'); if (!n) return false; n.scrollIntoView({block:'center'}); n.click(); return true;`, `session row ${sessionId}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function clickDockToggle(browser) {
|
|
151
|
+
await termClick(browser, `const n = doc.getElementById('btn-dock-toggle'); if (!n || n.hidden) return false; n.click(); return true;`, 'dock toggle button');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function clickPlus(browser) {
|
|
155
|
+
await termClick(browser, `const n = doc.querySelector('.rd-plus'); if (!n) return false; n.click(); return true;`, 'dock + button');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function clickLauncherKnowledgeRow(browser) {
|
|
159
|
+
await termClick(browser, `const n = doc.querySelector('.rd-launcher .rd-picker-host-row'); if (!n) return false; n.click(); return true;`, 'launcher knowledge row');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function clickTabByLabel(browser, label) {
|
|
163
|
+
await termClick(browser, `const row = Array.from(doc.querySelectorAll('.rd-tabs .rd-tab')).find(item => ((item.querySelector('.rd-tab-label') || { textContent: '' }).textContent || '') === '${label}'); if (!row) return false; row.click(); return true;`, `tab ${label}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function closeTabByLabel(browser, label) {
|
|
167
|
+
await termClick(browser, `const row = Array.from(doc.querySelectorAll('.rd-tabs .rd-tab')).find(item => ((item.querySelector('.rd-tab-label') || { textContent: '' }).textContent || '') === '${label}'); if (!row) return false; row.querySelector('.rd-tab-close').click(); return true;`, `close tab ${label}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function sessionRowExists(browser, sessionId) {
|
|
171
|
+
return frameEval(browser, `return !!doc.querySelector('[data-session="${sessionId}"]');`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// The newest kb:panel/state is authoritative: after a close the workbench
|
|
175
|
+
// posts panels: [] and the provider must be absent from it.
|
|
176
|
+
function latestPanelState(productLog) {
|
|
177
|
+
for (let i = productLog.length - 1; i >= 0; i -= 1) {
|
|
178
|
+
const entry = productLog[i];
|
|
179
|
+
if (entry.type === 'kb:panel/state') return entry;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function knowledgePanelOf(productLog, providerId) {
|
|
185
|
+
const state = latestPanelState(productLog);
|
|
186
|
+
if (!state || !Array.isArray(state.panels)) return null;
|
|
187
|
+
return state.panels.find(panel => panel.providerId === providerId) || null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Real host-side protocol request: the host window posts the message to the
|
|
191
|
+
// workbench frame and waits for the workbench's own reply. The request is a
|
|
192
|
+
// legitimate protocol input (the same channel the product uses for its
|
|
193
|
+
// knowledge panel), never a DOM/listener manipulation.
|
|
194
|
+
let hostRequestSeq = 0;
|
|
195
|
+
async function hostPanelRequest(browser, type, payload = {}, { timeoutMs = 15000 } = {}) {
|
|
196
|
+
const requestId = `r3-${++hostRequestSeq}-${Date.now()}`;
|
|
197
|
+
const message = { type, requestId, ...payload };
|
|
198
|
+
const sent = await browser.evaluate(`(() => {
|
|
199
|
+
const frame = document.getElementById('workFrame');
|
|
200
|
+
if (!frame || !frame.contentWindow) return false;
|
|
201
|
+
frame.contentWindow.postMessage(${JSON.stringify(message)}, location.origin);
|
|
202
|
+
return true;
|
|
203
|
+
})()`);
|
|
204
|
+
if (!sent) throw new Error(`host protocol request ${type} could not be posted (no workFrame)`);
|
|
205
|
+
return waitFor(() => getLogs(browser).then(logs => {
|
|
206
|
+
const reply = logs.productLog.find(entry => entry.requestId === requestId && entry.type !== type);
|
|
207
|
+
return reply || null;
|
|
208
|
+
}), `host protocol reply for ${type}`, timeoutMs);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Real reload of the embedded workbench iframe (the browser re-runs the
|
|
212
|
+
// whole app boot, exactly like a user refreshing the frame).
|
|
213
|
+
async function reloadWorkFrame(browser) {
|
|
214
|
+
const before = await browser.evaluate(`(() => { const f = document.getElementById('workFrame'); return f ? f.src : null; })()`);
|
|
215
|
+
await browser.evaluate(`(() => { const f = document.getElementById('workFrame'); if (!f) return false; f.src = f.src; return true; })()`);
|
|
216
|
+
await waitFor(() => browser.evaluate(`(() => { const f = document.getElementById('workFrame'); return !!(f && f.src); })()`), 'work frame src after reload', 20000);
|
|
217
|
+
return before;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ---- the module's own shipped panel host proof page ----------------------
|
|
221
|
+
|
|
222
|
+
async function openPanelProofHost(browser, url, { timeoutMs = 60000 } = {}) {
|
|
223
|
+
// The embedded terminal posts kb:ready as soon as it boots, which can be
|
|
224
|
+
// before a post-navigation listener is installed. Install the recorder for
|
|
225
|
+
// every new document first so no early protocol message is missed.
|
|
226
|
+
await browser.send('Page.addScriptToEvaluateOnNewDocument', { source: LISTENER('__r3ProofLog') });
|
|
227
|
+
await browser.send('Page.navigate', { url });
|
|
228
|
+
await waitFor(() => browser.evaluate(`document.readyState === 'complete'`), 'proof host page load', timeoutMs);
|
|
229
|
+
await browser.evaluate(LISTENER('__r3ProofLog'));
|
|
230
|
+
await waitFor(() => browser.evaluate(`!!document.getElementById('terminal-frame')`), 'proof host terminal frame', timeoutMs);
|
|
231
|
+
await waitFor(() => browser.evaluate(`(() => {
|
|
232
|
+
const log = window.__r3ProofLog || [];
|
|
233
|
+
return log.some(entry => entry.type === 'kb:ready');
|
|
234
|
+
})()`), 'proof host kb:ready', timeoutMs);
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function proofLogs(browser) {
|
|
239
|
+
return browser.evaluate(`window.__r3ProofLog ? window.__r3ProofLog.slice() : []`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function clickProofButton(browser, id) {
|
|
243
|
+
return browser.evaluate(`(() => { const n = document.getElementById(${JSON.stringify(id)}); if (!n || n.disabled) return false; n.click(); return true; })()`);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function proofStatus(browser) {
|
|
247
|
+
return browser.evaluate(`(() => {
|
|
248
|
+
const status = document.getElementById('panel-status');
|
|
249
|
+
const lines = Array.from(document.querySelectorAll('#state-log .line')).map(n => (n.textContent || '').trim());
|
|
250
|
+
return { status: status ? status.textContent : null, lines };
|
|
251
|
+
})()`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Host-role protocol request issued from the proof host page itself.
|
|
255
|
+
async function proofHostRequest(browser, type, payload = {}, { timeoutMs = 15000 } = {}) {
|
|
256
|
+
const requestId = `r3-proof-${++hostRequestSeq}-${Date.now()}`;
|
|
257
|
+
const message = { type, requestId, ...payload };
|
|
258
|
+
const sent = await browser.evaluate(`(() => {
|
|
259
|
+
const frame = document.getElementById('terminal-frame');
|
|
260
|
+
if (!frame || !frame.contentWindow) return false;
|
|
261
|
+
frame.contentWindow.postMessage(${JSON.stringify(message)}, location.origin);
|
|
262
|
+
return true;
|
|
263
|
+
})()`);
|
|
264
|
+
if (!sent) throw new Error(`proof host protocol request ${type} could not be posted`);
|
|
265
|
+
return waitFor(() => proofLogs(browser).then(logs => {
|
|
266
|
+
const reply = logs.find(entry => entry.requestId === requestId && entry.type !== type);
|
|
267
|
+
return reply || null;
|
|
268
|
+
}), `proof host protocol reply for ${type}`, timeoutMs);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
async function failureContext(browser) {
|
|
272
|
+
const out = {};
|
|
273
|
+
const grab = async (key, expr) => {
|
|
274
|
+
try { out[key] = await browser.evaluate(expr); } catch (error) { out[key] = `unavailable: ${error.message}`; }
|
|
275
|
+
};
|
|
276
|
+
await grab('url', 'location.href');
|
|
277
|
+
await grab('frameSrc', `(() => { const f = document.getElementById('workFrame'); return f ? f.src : null; })()`);
|
|
278
|
+
try { out.logs = await getLogs(browser); } catch (error) { out.logs = `unavailable: ${error.message}`; }
|
|
279
|
+
try {
|
|
280
|
+
out.terminalDom = await frameEval(browser, `return (() => {
|
|
281
|
+
const btn = doc.getElementById('btn-new-session');
|
|
282
|
+
const sessions = Array.from(doc.querySelectorAll('[data-session]')).map(n => ({ id: n.getAttribute('data-session'), text: (n.textContent || '').replace(/\\s+/g, ' ').slice(0, 60) }));
|
|
283
|
+
return {
|
|
284
|
+
newSessionButton: btn ? { hidden: btn.hidden, disabled: btn.disabled, text: (btn.textContent || '').slice(0, 40) } : null,
|
|
285
|
+
sessionRows: sessions,
|
|
286
|
+
bodySnippet: (doc.body.textContent || '').replace(/\\s+/g, ' ').slice(0, 600),
|
|
287
|
+
};
|
|
288
|
+
})();`);
|
|
289
|
+
} catch (error) { out.terminalDom = `unavailable: ${error.message}`; }
|
|
290
|
+
return out;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function evidenceWriter(artifactsDir, baseName) {
|
|
294
|
+
fs.mkdirSync(artifactsDir, { recursive: true });
|
|
295
|
+
return {
|
|
296
|
+
write(value) {
|
|
297
|
+
const file = path.join(artifactsDir, baseName);
|
|
298
|
+
fs.writeFileSync(file, JSON.stringify(value, null, 2), 'utf8');
|
|
299
|
+
return file;
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
module.exports = {
|
|
305
|
+
launchCdpBrowser, waitFor, findChrome,
|
|
306
|
+
openWorkView, installProductLog, installTerminalLog, dockSnapshot,
|
|
307
|
+
newSessionViaUi, clickSessionRow, sessionRowExists,
|
|
308
|
+
clickDockToggle, clickPlus, clickLauncherKnowledgeRow,
|
|
309
|
+
clickTabByLabel, closeTabByLabel,
|
|
310
|
+
getLogs, frameEval, evidenceWriter, failureContext,
|
|
311
|
+
hostPanelRequest, reloadWorkFrame,
|
|
312
|
+
latestPanelState, knowledgePanelOf,
|
|
313
|
+
openPanelProofHost, proofLogs, clickProofButton, proofStatus, proofHostRequest,
|
|
314
|
+
};
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// P-ENGINE-RECONCILE-R4 lane-exclusive harness (batch parallel-20261023).
|
|
4
|
+
//
|
|
5
|
+
// Self-contained: it does NOT require the frozen R3 helpers (those are frozen
|
|
6
|
+
// for the Leader to integrate). Everything the R4 probe needs is real:
|
|
7
|
+
//
|
|
8
|
+
// * real fixture Git repositories (isolated git config, repo-local hooks only)
|
|
9
|
+
// * a REAL post-commit hook (separate OS process running the real
|
|
10
|
+
// ai-coding-event-bridge commit-boundary CLI from the pinned package);
|
|
11
|
+
// the "broken" mode points at a non-existent CLI so the hook FAILS for
|
|
12
|
+
// real and the commit never reaches the journal
|
|
13
|
+
// * the real ai-coding-event-bridge console server (in-process, isolated
|
|
14
|
+
// --home journal; pinned @sanqianx package by default, a source checkout
|
|
15
|
+
// only through PK_TEST_BRIDGE_ROOT)
|
|
16
|
+
// * the real vector-hub server (in-process, isolated root + deterministic
|
|
17
|
+
// test embeddings: the paid embedding API is NOT exercised; pinned
|
|
18
|
+
// @sanqianx/vector-hub by default, a source checkout only through
|
|
19
|
+
// PK_TEST_VECTOR_ROOT)
|
|
20
|
+
// * the knowledge-engine under test (in-process, isolated data dir): the
|
|
21
|
+
// VENDORED bytes by default, a source checkout only through
|
|
22
|
+
// PK_TEST_ENGINE_ROOT (the candidate host for the R4 fix)
|
|
23
|
+
//
|
|
24
|
+
// Isolation: lane temp root at PK_TEST_TEMP_ROOT or os.tmpdir() (never inside
|
|
25
|
+
// the repository), ephemeral 127.0.0.1 ports, scrubbed child env (no
|
|
26
|
+
// KB_*/KNOWLEDGE_*/ANTHROPIC_*/CLAUDE*/GLM/MINIMAX leakage), isolated
|
|
27
|
+
// HOME/USERPROFILE/APPDATA/TEMP, GIT_CONFIG_NOSYSTEM=1 and GIT_CONFIG_GLOBAL
|
|
28
|
+
// pointed at a non-existent file (the user's global git config and hooks are
|
|
29
|
+
// never read or written).
|
|
30
|
+
|
|
31
|
+
const { spawnSync } = require('node:child_process');
|
|
32
|
+
const fs = require('node:fs');
|
|
33
|
+
const http = require('node:http');
|
|
34
|
+
const os = require('node:os');
|
|
35
|
+
const path = require('node:path');
|
|
36
|
+
const crypto = require('node:crypto');
|
|
37
|
+
|
|
38
|
+
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
39
|
+
const VENDORED_ENGINE_ROOT = path.join(REPO_ROOT, '_modules', 'knowledge-engine');
|
|
40
|
+
const VENDORED_ENGINE_VERSION = '0.2.7-rc.10';
|
|
41
|
+
|
|
42
|
+
function resolveRuntimeRoot(envVar, pinnedDir, pinnedVersion) {
|
|
43
|
+
const fromEnv = process.env[envVar];
|
|
44
|
+
const root = path.resolve(fromEnv || pinnedDir);
|
|
45
|
+
if (!fs.existsSync(root)) {
|
|
46
|
+
throw new Error(`runtime root ${root} does not exist (${fromEnv ? `${envVar} override` : `pinned ${pinnedVersion} install`} is missing)`);
|
|
47
|
+
}
|
|
48
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
49
|
+
if (!fromEnv && manifest.version !== pinnedVersion) {
|
|
50
|
+
throw new Error(`pinned runtime at ${root} is ${manifest.version}, expected ${pinnedVersion}`);
|
|
51
|
+
}
|
|
52
|
+
return { root, version: manifest.version, origin: fromEnv ? `env ${envVar}` : 'pinned package' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The engine under test. Default = the vendored bytes shipped in this repo
|
|
56
|
+
// (the PINNED bytes). PK_TEST_ENGINE_ROOT points at a source checkout of the
|
|
57
|
+
// module (the CANDIDATE bytes that carry the R4 fix).
|
|
58
|
+
function resolveEngineRoot() {
|
|
59
|
+
const fromEnv = process.env.PK_TEST_ENGINE_ROOT;
|
|
60
|
+
const root = path.resolve(fromEnv || VENDORED_ENGINE_ROOT);
|
|
61
|
+
if (!fs.existsSync(path.join(root, 'src', 'server.js'))) {
|
|
62
|
+
throw new Error(`engine root ${root} has no src/server.js (${fromEnv ? 'PK_TEST_ENGINE_ROOT override' : 'vendored copy'} is missing)`);
|
|
63
|
+
}
|
|
64
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
65
|
+
return {
|
|
66
|
+
root,
|
|
67
|
+
version: manifest.version,
|
|
68
|
+
origin: fromEnv ? 'env PK_TEST_ENGINE_ROOT (candidate source checkout)' : 'vendored _modules copy (pinned bytes)',
|
|
69
|
+
candidate: Boolean(fromEnv),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const BRIDGE = resolveRuntimeRoot('PK_TEST_BRIDGE_ROOT', path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'ai-coding-event-bridge-console'), '0.7.2');
|
|
74
|
+
const VECTOR = resolveRuntimeRoot('PK_TEST_VECTOR_ROOT', path.join(REPO_ROOT, 'node_modules', '@sanqianx', 'vector-hub'), '1.0.8-rc.8');
|
|
75
|
+
const BRIDGE_ROOT = BRIDGE.root;
|
|
76
|
+
const BRIDGE_CLI = path.join(BRIDGE_ROOT, 'src', 'bridge', 'bin', 'commit-boundary.js');
|
|
77
|
+
const VECTOR_ROOT = VECTOR.root;
|
|
78
|
+
|
|
79
|
+
// Temp root: PK_TEST_TEMP_ROOT or the OS temp dir; never inside the repository.
|
|
80
|
+
const TEMP_ROOT = (() => {
|
|
81
|
+
const base = path.resolve(process.env.PK_TEST_TEMP_ROOT || path.join(os.tmpdir(), 'project-knowledge-engine-r4-test'));
|
|
82
|
+
if (base === REPO_ROOT || base.startsWith(REPO_ROOT + path.sep)) {
|
|
83
|
+
throw new Error(`temp root must live outside the repository (got ${base})`);
|
|
84
|
+
}
|
|
85
|
+
return base;
|
|
86
|
+
})();
|
|
87
|
+
|
|
88
|
+
function ensureTempRoot() {
|
|
89
|
+
fs.mkdirSync(TEMP_ROOT, { recursive: true });
|
|
90
|
+
return TEMP_ROOT;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function makeLaneDir(label) {
|
|
94
|
+
ensureTempRoot();
|
|
95
|
+
return fs.mkdtempSync(path.join(TEMP_ROOT, `${label}-`));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Scrubbed environment: no profile/quota/credential leakage, isolated HOME and
|
|
99
|
+
// TEMP, isolated git config. Nothing here relies on the caller unsetting vars.
|
|
100
|
+
function isolatedEnv(extra = {}) {
|
|
101
|
+
const home = extra.ISOLATED_HOME || path.join(ensureTempRoot(), 'isolated-home');
|
|
102
|
+
fs.mkdirSync(home, { recursive: true });
|
|
103
|
+
const env = { ...process.env };
|
|
104
|
+
for (const name of Object.keys(env)) {
|
|
105
|
+
if (/^(KB_|KNOWLEDGE_|ANTHROPIC_|CLAUDE|OPENAI_|CODEX|MINIMAX|GLM|AI_CODING_EVENT_BRIDGE|PK_TEST_)/i.test(name)) delete env[name];
|
|
106
|
+
}
|
|
107
|
+
const tmp = path.join(ensureTempRoot(), 'tmp');
|
|
108
|
+
fs.mkdirSync(tmp, { recursive: true });
|
|
109
|
+
env.HOME = home;
|
|
110
|
+
env.USERPROFILE = home;
|
|
111
|
+
env.APPDATA = path.join(home, 'AppData', 'Roaming');
|
|
112
|
+
env.LOCALAPPDATA = path.join(home, 'AppData', 'Local');
|
|
113
|
+
env.TEMP = tmp;
|
|
114
|
+
env.TMP = tmp;
|
|
115
|
+
env.TMPDIR = tmp;
|
|
116
|
+
env.GIT_CONFIG_NOSYSTEM = '1';
|
|
117
|
+
env.GIT_CONFIG_GLOBAL = path.join(home, 'does-not-exist.gitconfig');
|
|
118
|
+
env.AI_CODING_EVENT_BRIDGE_HOME = path.join(home, 'bridge-home');
|
|
119
|
+
env.BRIDGE_CONSOLE_PICK_FOLDER = '0';
|
|
120
|
+
return { ...env, ...extra };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// git with the isolated config; returns {code, stdout, stderr} so a driver can
|
|
124
|
+
// assert the real exit code of a commit whose hook failed.
|
|
125
|
+
function gitRun(repoPath, args) {
|
|
126
|
+
const result = spawnSync('git', args, { cwd: repoPath, windowsHide: true, encoding: 'utf8', env: isolatedEnv() });
|
|
127
|
+
return { code: result.status, stdout: (result.stdout || '').trim(), stderr: (result.stderr || '').trim() };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function git(repoPath, args) {
|
|
131
|
+
const result = gitRun(repoPath, args);
|
|
132
|
+
if (result.code !== 0) throw new Error(`git ${args.join(' ')} failed (${result.code}): ${result.stderr}`);
|
|
133
|
+
return result.stdout;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Real fixture repository: init + baseline + one labeled commit per entry.
|
|
137
|
+
function buildFixtureRepo(root, name, commits = []) {
|
|
138
|
+
const repoPath = path.join(root, `repo-${name}`);
|
|
139
|
+
fs.mkdirSync(repoPath, { recursive: true });
|
|
140
|
+
git(repoPath, ['init', '-q']);
|
|
141
|
+
git(repoPath, ['config', 'user.email', 'engine-reconcile-r4@test.invalid']);
|
|
142
|
+
git(repoPath, ['config', 'user.name', 'P-ENGINE-RECONCILE-R4']);
|
|
143
|
+
fs.writeFileSync(path.join(repoPath, 'README.md'), `# ${name}\n\nFixture repository.\n`);
|
|
144
|
+
git(repoPath, ['add', '.']);
|
|
145
|
+
git(repoPath, ['commit', '-qm', 'baseline']);
|
|
146
|
+
const baseline = git(repoPath, ['rev-parse', 'HEAD']);
|
|
147
|
+
const shas = {};
|
|
148
|
+
for (const label of commits) {
|
|
149
|
+
fs.writeFileSync(path.join(repoPath, `${label}.txt`), `change ${name} ${label}\n${label.repeat(64)}\n`);
|
|
150
|
+
git(repoPath, ['add', '.']);
|
|
151
|
+
git(repoPath, ['commit', '-qm', `feature ${label}`]);
|
|
152
|
+
shas[label] = git(repoPath, ['rev-parse', 'HEAD']);
|
|
153
|
+
}
|
|
154
|
+
return { repoPath, baseline, shas };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Real git hook inside the FIXTURE repository only (.git/hooks/post-commit).
|
|
158
|
+
// mode 'ok' -> the real bridge commit-boundary CLI captures the boundary.
|
|
159
|
+
// mode 'broken' -> the CLI path does not exist, so the hook fails for real and
|
|
160
|
+
// the commit never reaches the journal (never captured).
|
|
161
|
+
// The user's global git config and global hooks are never touched.
|
|
162
|
+
function installPostCommitHook(repoPath, { home, mode = 'ok' }) {
|
|
163
|
+
const hookPath = path.join(repoPath, '.git', 'hooks', 'post-commit');
|
|
164
|
+
const slash = value => value.replace(/\\/g, '/');
|
|
165
|
+
const cli = mode === 'ok' ? slash(BRIDGE_CLI) : slash(path.join(BRIDGE_ROOT, 'src', 'bridge', 'bin', 'commit-boundary.missing.js'));
|
|
166
|
+
const script = [
|
|
167
|
+
'#!/bin/sh',
|
|
168
|
+
mode === 'ok'
|
|
169
|
+
? `"${slash(process.execPath)}" "${cli}" --home "${slash(home)}" --cwd "${slash(repoPath)}" >/dev/null 2>&1`
|
|
170
|
+
: `"${slash(process.execPath)}" "${cli}" --home "${slash(home)}" --cwd "${slash(repoPath)}"`,
|
|
171
|
+
'exit 1',
|
|
172
|
+
'',
|
|
173
|
+
].join('\n');
|
|
174
|
+
fs.mkdirSync(path.dirname(hookPath), { recursive: true });
|
|
175
|
+
fs.writeFileSync(hookPath, script, { mode: 0o755 });
|
|
176
|
+
return { hookPath, mode, content: script };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Real bridge console + journal, isolated home, ephemeral loopback port.
|
|
180
|
+
function startBridge(home) {
|
|
181
|
+
fs.mkdirSync(home, { recursive: true });
|
|
182
|
+
const { createBridge, projectRegistry, resolveRepoContext } = require(path.join(BRIDGE_ROOT, 'src', 'bridge'));
|
|
183
|
+
const { createConsoleServer } = require(path.join(BRIDGE_ROOT, 'src', 'server'));
|
|
184
|
+
const bridge = createBridge({ homeDir: home });
|
|
185
|
+
const server = http.createServer(createConsoleServer({ home }));
|
|
186
|
+
return {
|
|
187
|
+
home, bridge, projectRegistry, resolveRepoContext, server,
|
|
188
|
+
async listen() {
|
|
189
|
+
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
|
190
|
+
return `http://127.0.0.1:${server.address().port}`;
|
|
191
|
+
},
|
|
192
|
+
async close() { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); },
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Real vector-hub server on an isolated root. Embeddings are deterministic test
|
|
197
|
+
// vectors (the paid embedding API is NOT exercised - stated as a boundary).
|
|
198
|
+
function startVector(root) {
|
|
199
|
+
fs.mkdirSync(root, { recursive: true });
|
|
200
|
+
const { HubManager } = require(path.join(VECTOR_ROOT, 'dist', 'cjs', 'server', 'manager'));
|
|
201
|
+
const { createServer } = require(path.join(VECTOR_ROOT, 'dist', 'cjs', 'server', 'server'));
|
|
202
|
+
const embeddingsFactory = () => ({
|
|
203
|
+
maxTokens: 500,
|
|
204
|
+
async createEmbeddings(inputs) {
|
|
205
|
+
const texts = Array.isArray(inputs) ? inputs : [inputs];
|
|
206
|
+
return { status: 'success', output: texts.map((text, index) => [1, 0, index / 1000]) };
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
return HubManager.load({
|
|
210
|
+
rootPath: path.join(root, 'indexes'),
|
|
211
|
+
configPath: path.join(root, 'vector-config.json'),
|
|
212
|
+
embeddingsFactory,
|
|
213
|
+
}).then(async manager => {
|
|
214
|
+
await manager.saveSettings({ provider: 'minimax', apiKey: 'embedding-test-marker' });
|
|
215
|
+
const server = http.createServer(createServer(manager));
|
|
216
|
+
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
|
217
|
+
return {
|
|
218
|
+
manager, server,
|
|
219
|
+
url: `http://127.0.0.1:${server.address().port}`,
|
|
220
|
+
async close() { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); manager.close?.(); },
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// The engine under test, in-process, isolated data dir.
|
|
226
|
+
function startEngine({ dataDir, bridgeUrl, vectorUrl, analyzer, debug = true, consume = true, runtimeToken = null, engineRoot = null }) {
|
|
227
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
228
|
+
const root = path.resolve(engineRoot || resolveEngineRoot().root);
|
|
229
|
+
const { createEngineServer } = require(path.join(root, 'src', 'server.js'));
|
|
230
|
+
const runtime = createEngineServer({ dataDir, consume, debug, analyzer, bridgeUrl, vectorUrl, runtimeToken });
|
|
231
|
+
return {
|
|
232
|
+
runtime, engineRoot: root,
|
|
233
|
+
async listen() {
|
|
234
|
+
await runtime.ready;
|
|
235
|
+
await new Promise(resolve => runtime.server.listen(0, '127.0.0.1', resolve));
|
|
236
|
+
return `http://127.0.0.1:${runtime.server.address().port}`;
|
|
237
|
+
},
|
|
238
|
+
async close() { await runtime.close(); },
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Real capture of a commit boundary through the pinned bridge CLI. This is the
|
|
243
|
+
// SAME code path the post-commit hook runs - no API-created task is used to
|
|
244
|
+
// stand in for a hook failure.
|
|
245
|
+
function captureBoundary({ home, repoPath, sha }) {
|
|
246
|
+
const result = spawnSync(process.execPath, [BRIDGE_CLI, '--home', home, '--cwd', repoPath, '--sha', sha], {
|
|
247
|
+
cwd: repoPath, windowsHide: true, encoding: 'utf8', env: isolatedEnv(),
|
|
248
|
+
});
|
|
249
|
+
let parsed = null;
|
|
250
|
+
try { parsed = JSON.parse(result.stdout); } catch { parsed = null; }
|
|
251
|
+
return { code: result.status, stdout: (result.stdout || '').trim(), stderr: (result.stderr || '').trim(), payload: parsed };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function findJournalFiles(root) {
|
|
255
|
+
const out = [];
|
|
256
|
+
const walk = dir => {
|
|
257
|
+
if (!fs.existsSync(dir)) return;
|
|
258
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
259
|
+
const absolute = path.join(dir, entry.name);
|
|
260
|
+
if (entry.isDirectory()) walk(absolute);
|
|
261
|
+
else if (entry.name === 'events.jsonl') out.push(absolute);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
walk(root);
|
|
265
|
+
return out;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Every git-commit-boundary event physically present in the journals on disk.
|
|
269
|
+
function boundaryEvents(...roots) {
|
|
270
|
+
const events = [];
|
|
271
|
+
for (const file of roots.flatMap(root => findJournalFiles(root))) {
|
|
272
|
+
for (const line of fs.readFileSync(file, 'utf8').split('\n').filter(Boolean)) {
|
|
273
|
+
const event = JSON.parse(line);
|
|
274
|
+
if (event.schema === 'git-commit-boundary/v1') events.push(event);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return events;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async function waitUntil(fn, timeoutMs, describe) {
|
|
281
|
+
const started = Date.now();
|
|
282
|
+
for (;;) {
|
|
283
|
+
const value = await fn();
|
|
284
|
+
if (value) return value;
|
|
285
|
+
if (Date.now() - started > timeoutMs) throw new Error(`waitUntil timed out after ${timeoutMs}ms: ${describe}`);
|
|
286
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function readJsonl(file) {
|
|
291
|
+
if (!fs.existsSync(file)) return [];
|
|
292
|
+
return fs.readFileSync(file, 'utf8').split('\n').filter(Boolean).map(line => JSON.parse(line));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function saveEvidence(dir, name, value) {
|
|
296
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
297
|
+
fs.writeFileSync(path.join(dir, name), `${JSON.stringify(value, null, 2)}\n`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function hashText(value) {
|
|
301
|
+
return crypto.createHash('sha256').update(value).digest('hex');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function hashFile(file) {
|
|
305
|
+
if (!fs.existsSync(file)) return null;
|
|
306
|
+
return hashFileSync(file);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function hashFileSync(file) {
|
|
310
|
+
return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
module.exports = {
|
|
314
|
+
REPO_ROOT,
|
|
315
|
+
VENDORED_ENGINE_ROOT,
|
|
316
|
+
VENDORED_ENGINE_VERSION,
|
|
317
|
+
resolveEngineRoot,
|
|
318
|
+
RUNTIME_IDENTITY: { bridge: BRIDGE, vector: VECTOR },
|
|
319
|
+
BRIDGE_ROOT,
|
|
320
|
+
BRIDGE_CLI,
|
|
321
|
+
VECTOR_ROOT,
|
|
322
|
+
TEMP_ROOT,
|
|
323
|
+
ensureTempRoot,
|
|
324
|
+
makeLaneDir,
|
|
325
|
+
isolatedEnv,
|
|
326
|
+
git,
|
|
327
|
+
gitRun,
|
|
328
|
+
buildFixtureRepo,
|
|
329
|
+
installPostCommitHook,
|
|
330
|
+
startBridge,
|
|
331
|
+
startVector,
|
|
332
|
+
startEngine,
|
|
333
|
+
captureBoundary,
|
|
334
|
+
boundaryEvents,
|
|
335
|
+
waitUntil,
|
|
336
|
+
readJsonl,
|
|
337
|
+
saveEvidence,
|
|
338
|
+
hashText,
|
|
339
|
+
hashFile,
|
|
340
|
+
};
|