@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,587 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Lane helpers for the P-WB-RUNTIME batch (WB-004 / WB-005 / WB-008).
|
|
3
|
+
//
|
|
4
|
+
// The batch drives the REAL 0.13.6 agent-terminal UI in a REAL browser
|
|
5
|
+
// against the REAL installed module, hosted as an isolated child process:
|
|
6
|
+
//
|
|
7
|
+
// * the host child reuses the frozen lane host (helpers/parallel-workbench-host.js)
|
|
8
|
+
// read-only; it gets its own data dir, workspace, HOME, CLAUDE_CONFIG_DIR,
|
|
9
|
+
// temp dir and port;
|
|
10
|
+
// * the browser gets its own user-data-dir below the same isolated root,
|
|
11
|
+
// so no developer profile, cookie or extension is touched;
|
|
12
|
+
// * the original subscription profile is served through the frozen read-only
|
|
13
|
+
// facade — the credential stays in the host's memory and never reaches a
|
|
14
|
+
// file, a log or a report.
|
|
15
|
+
//
|
|
16
|
+
// The recorder below is deliberately transparent: it logs every event the
|
|
17
|
+
// product receives, verbatim, and it can deliver a recorded event a second
|
|
18
|
+
// time to the very same stream. It never filters, reorders or repairs
|
|
19
|
+
// anything — whether a stale event is honoured or dropped is decided by the
|
|
20
|
+
// product, not by the driver.
|
|
21
|
+
const fs = require('node:fs');
|
|
22
|
+
const path = require('node:path');
|
|
23
|
+
const crypto = require('node:crypto');
|
|
24
|
+
const { spawnSync } = require('node:child_process');
|
|
25
|
+
const fixture = require('./parallel-workbench-fixture');
|
|
26
|
+
const sourceMap = require('./parallel-workbench-source-map');
|
|
27
|
+
const { launchCdpBrowser } = require('./cdp-browser');
|
|
28
|
+
const { findChromeDetailed } = require('./find-chrome');
|
|
29
|
+
|
|
30
|
+
const API_BASE = '/api/claude-workbench/v1';
|
|
31
|
+
|
|
32
|
+
function sha256File(file) {
|
|
33
|
+
try { return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); } catch { return null; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Installed in the page before any product script runs. It wraps EventSource
|
|
37
|
+
// so that every delivered event is recorded, and it exposes a replay that
|
|
38
|
+
// re-delivers a recorded event to the same stream.
|
|
39
|
+
const RECORDER_SOURCE = `
|
|
40
|
+
(function () {
|
|
41
|
+
if (window.__wbRecorder) return;
|
|
42
|
+
var Native = window.EventSource;
|
|
43
|
+
var recorder = { log: [], streams: [] };
|
|
44
|
+
window.__wbRecorder = recorder;
|
|
45
|
+
function RecordingEventSource(url, init) {
|
|
46
|
+
var stream = new Native(url, init);
|
|
47
|
+
recorder.streams.push({ stream: stream, url: String(url) });
|
|
48
|
+
var nativeAdd = stream.addEventListener.bind(stream);
|
|
49
|
+
stream.addEventListener = function (type, fn, options) {
|
|
50
|
+
if (typeof fn === 'function' && type !== 'message') {
|
|
51
|
+
var wrapped = function (event) {
|
|
52
|
+
try { recorder.log.push({ type: event.type, data: String(event.data), at: Date.now() }); } catch (error) {}
|
|
53
|
+
return fn.call(stream, event);
|
|
54
|
+
};
|
|
55
|
+
return nativeAdd(type, wrapped, options);
|
|
56
|
+
}
|
|
57
|
+
return nativeAdd(type, fn, options);
|
|
58
|
+
};
|
|
59
|
+
return stream;
|
|
60
|
+
}
|
|
61
|
+
RecordingEventSource.prototype = Native.prototype;
|
|
62
|
+
window.EventSource = RecordingEventSource;
|
|
63
|
+
window.__wbReplay = function (index, urlPattern) {
|
|
64
|
+
var entry = recorder.log[index];
|
|
65
|
+
if (!entry) return { replayed: false, reason: 'no recorded event at that index' };
|
|
66
|
+
var delivered = 0;
|
|
67
|
+
for (var i = 0; i < recorder.streams.length; i++) {
|
|
68
|
+
var target = recorder.streams[i];
|
|
69
|
+
if (urlPattern && target.url.indexOf(urlPattern) < 0) continue;
|
|
70
|
+
try {
|
|
71
|
+
target.stream.dispatchEvent(new MessageEvent(entry.type, { data: entry.data, lastEventId: '' }));
|
|
72
|
+
delivered += 1;
|
|
73
|
+
} catch (error) {}
|
|
74
|
+
}
|
|
75
|
+
return { replayed: true, type: entry.type, delivered: delivered, urlPattern: urlPattern || null };
|
|
76
|
+
};
|
|
77
|
+
})();
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
function wait(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
|
|
81
|
+
|
|
82
|
+
async function waitUntil(fn, label, timeoutMs = 30000, intervalMs = 100) {
|
|
83
|
+
const deadline = Date.now() + timeoutMs;
|
|
84
|
+
let last;
|
|
85
|
+
while (Date.now() < deadline) {
|
|
86
|
+
try {
|
|
87
|
+
const value = await fn();
|
|
88
|
+
if (value) return value;
|
|
89
|
+
last = value;
|
|
90
|
+
} catch (error) { last = error && error.message; }
|
|
91
|
+
await wait(intervalMs);
|
|
92
|
+
}
|
|
93
|
+
const detail = last === undefined ? '' : ` (last: ${typeof last === 'string' ? last : JSON.stringify(last)})`;
|
|
94
|
+
throw new Error(`timed out after ${timeoutMs}ms waiting for ${label}${detail}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function getJson(url, options) {
|
|
98
|
+
const response = await fetch(url, { ...options, signal: AbortSignal.timeout(30000) });
|
|
99
|
+
const body = await response.json().catch(() => null);
|
|
100
|
+
return { status: response.status, ok: response.ok, body };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// --- the isolated host ----------------------------------------------------
|
|
104
|
+
|
|
105
|
+
async function startHost(options = {}) {
|
|
106
|
+
const moduleRoot = options.moduleRoot || fixture.resolveHostModuleRoot();
|
|
107
|
+
if (!moduleRoot) throw new Error('no claude-ai-workbench module copy was found to host');
|
|
108
|
+
// A restart of the SAME host keeps the layout (data dir, browser profile)
|
|
109
|
+
// and may keep the port, so the page origin — and with it the browser
|
|
110
|
+
// storage the product uses for drafts — stays the same.
|
|
111
|
+
const layout = options.layout || fixture.createIsolationLayout(options.prefix || 'parallel-wb-runtime');
|
|
112
|
+
const port = options.port || await fixture.freePort();
|
|
113
|
+
const base = `http://127.0.0.1:${port}`;
|
|
114
|
+
const child = fixture.spawnNode([path.join(__dirname, 'parallel-workbench-host.js')], fixture.hostEnv(layout, {
|
|
115
|
+
PK_WB_MODULE_ROOT: moduleRoot,
|
|
116
|
+
PK_WB_HOST_PORT: String(port),
|
|
117
|
+
PK_WB_HOST_DATA_DIR: layout.dataDir,
|
|
118
|
+
PK_WB_HOST_WORKSPACE: layout.workspace,
|
|
119
|
+
PK_WB_HOST_MODE: options.mode || 'standalone',
|
|
120
|
+
PK_WB_PROFILE_SOURCE: options.profileSource || 'real-readonly',
|
|
121
|
+
...(options.engineUrl ? { PK_WB_ENGINE_URL: options.engineUrl } : {}),
|
|
122
|
+
}));
|
|
123
|
+
await fixture.waitForHttp(`${base}${API_BASE}/health`, 30000);
|
|
124
|
+
return { layout, moduleRoot, port, base, child };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function stopHost(host) {
|
|
128
|
+
if (!host || !host.child) return;
|
|
129
|
+
host.child.child.kill();
|
|
130
|
+
await host.child.exited;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// --- the real browser -----------------------------------------------------
|
|
134
|
+
|
|
135
|
+
async function openBrowser(base, layout, options = {}) {
|
|
136
|
+
const chrome = findChromeDetailed().path;
|
|
137
|
+
const profileDir = path.join(layout.root, 'browser-profile');
|
|
138
|
+
const browser = await launchCdpBrowser({
|
|
139
|
+
chrome,
|
|
140
|
+
profileDir,
|
|
141
|
+
url: 'about:blank',
|
|
142
|
+
width: 1360,
|
|
143
|
+
height: 900,
|
|
144
|
+
launchAttempts: 2,
|
|
145
|
+
});
|
|
146
|
+
await browser.send('Page.addScriptToEvaluateOnNewDocument', { source: RECORDER_SOURCE });
|
|
147
|
+
const target = `${base}/agent-terminal/?apiBase=${encodeURIComponent(API_BASE)}`;
|
|
148
|
+
await browser.send('Page.navigate', { url: target });
|
|
149
|
+
await waitUntil(
|
|
150
|
+
async () => browser.evaluate("document.readyState === 'complete' && !!window.__wbRecorder && !!document.getElementById('chat-input')"),
|
|
151
|
+
'the agent terminal page',
|
|
152
|
+
30000,
|
|
153
|
+
);
|
|
154
|
+
return { browser, chrome, profileDir, target };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function reloadPage(browser) {
|
|
158
|
+
await browser.send('Page.reload', { ignoreCache: false });
|
|
159
|
+
await waitUntil(
|
|
160
|
+
async () => browser.evaluate("document.readyState === 'complete' && !!window.__wbRecorder && !!document.getElementById('chat-input')"),
|
|
161
|
+
'the reloaded agent terminal page',
|
|
162
|
+
30000,
|
|
163
|
+
);
|
|
164
|
+
// The product script defines its own `state`; the page is only usable once
|
|
165
|
+
// that global exists, not merely when the document finished loading.
|
|
166
|
+
await waitUntil(
|
|
167
|
+
async () => browser.evaluate("typeof state !== 'undefined' && !!state"),
|
|
168
|
+
'the product state of the reloaded page',
|
|
169
|
+
30000,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// --- the product's own state, read from the page --------------------------
|
|
174
|
+
|
|
175
|
+
const READ_STATE = `(() => {
|
|
176
|
+
const send = document.getElementById('btn-send');
|
|
177
|
+
const status = document.getElementById('session-status');
|
|
178
|
+
const statusText = document.getElementById('session-status-text');
|
|
179
|
+
const col = document.getElementById('stream-col');
|
|
180
|
+
const input = document.getElementById('chat-input');
|
|
181
|
+
const tray = document.querySelector('.composer .attach-tray');
|
|
182
|
+
const modelLabel = document.getElementById('model-label');
|
|
183
|
+
const activeProj = document.querySelector('#project-list .proj.active');
|
|
184
|
+
return {
|
|
185
|
+
sendTitle: send ? send.title : null,
|
|
186
|
+
busy: send ? send.title === '停止' : null,
|
|
187
|
+
statusHidden: status ? status.hidden : null,
|
|
188
|
+
statusText: statusText ? statusText.textContent : null,
|
|
189
|
+
inputValue: input ? input.value : null,
|
|
190
|
+
inputDisabled: input ? input.disabled : null,
|
|
191
|
+
streamText: col ? col.textContent : '',
|
|
192
|
+
assistantMessages: col ? Array.from(col.querySelectorAll('.msg.ai')).map(node => node.textContent) : [],
|
|
193
|
+
userMessages: col ? Array.from(col.querySelectorAll('.msg.user')).map(node => node.textContent) : [],
|
|
194
|
+
attachments: tray ? Array.from(tray.querySelectorAll('.attachment-item')).map(node => node.textContent.trim()) : [],
|
|
195
|
+
modelLabel: modelLabel ? modelLabel.textContent : null,
|
|
196
|
+
activeProjectId: activeProj ? activeProj.dataset.project : null,
|
|
197
|
+
product: typeof state === 'undefined' ? null : {
|
|
198
|
+
activeProjectId: state.activeProjectId,
|
|
199
|
+
activeSessionId: state.activeSessionId,
|
|
200
|
+
busy: state.busy,
|
|
201
|
+
sessionState: state.sessionState || null,
|
|
202
|
+
liveRevision: state.liveRevision || 0,
|
|
203
|
+
attachmentCount: (state.attachments || []).length,
|
|
204
|
+
currentProfileId: state.currentProfileId === undefined ? 'undefined' : state.currentProfileId,
|
|
205
|
+
currentModel: state.currentModel,
|
|
206
|
+
projects: (state.projects || []).map(project => ({ id: project.id, name: project.name })),
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
})()`;
|
|
210
|
+
|
|
211
|
+
async function readState(browser) {
|
|
212
|
+
return browser.evaluate(READ_STATE);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function waitForState(browser, predicate, label, timeoutMs = 30000, intervalMs = 100) {
|
|
216
|
+
return waitUntil(async () => {
|
|
217
|
+
const state = await readState(browser);
|
|
218
|
+
return predicate(state) ? state : null;
|
|
219
|
+
}, label, timeoutMs, intervalMs);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// --- UI actions (the product's own controls) ------------------------------
|
|
223
|
+
|
|
224
|
+
async function selectModel(browser, profileName, modelId, options = {}) {
|
|
225
|
+
await browser.evaluate("document.getElementById('btn-model').click()");
|
|
226
|
+
const scan = `(() => {
|
|
227
|
+
const pop = document.getElementById('pop-model');
|
|
228
|
+
const groups = pop && pop.querySelector('.pop-groups');
|
|
229
|
+
if (!groups) return null;
|
|
230
|
+
const items = [];
|
|
231
|
+
let profile = null;
|
|
232
|
+
for (const child of Array.from(groups.children)) {
|
|
233
|
+
if (child.tagName === 'BUTTON') {
|
|
234
|
+
const label = ((child.querySelector('.grow') || child).textContent || '').trim();
|
|
235
|
+
items.push({ profile, label, disabled: child.disabled === true });
|
|
236
|
+
} else if (child.classList.contains('pop-group')) {
|
|
237
|
+
profile = (child.textContent || '').trim();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { items };
|
|
241
|
+
})()`;
|
|
242
|
+
const menu = await waitUntil(async () => {
|
|
243
|
+
const found = await browser.evaluate(scan);
|
|
244
|
+
return found && found.items.length ? found : null;
|
|
245
|
+
}, 'the model menu', options.timeoutMs || 30000);
|
|
246
|
+
const match = menu.items.find(item => item.profile && item.profile.includes(profileName) && item.label.includes(modelId));
|
|
247
|
+
if (!match) throw new Error(`the model menu has no ${profileName} / ${modelId} entry: ${JSON.stringify(menu.items)}`);
|
|
248
|
+
if (match.disabled) throw new Error(`the ${profileName} / ${modelId} entry is disabled`);
|
|
249
|
+
const clicked = await browser.evaluate(`(() => {
|
|
250
|
+
const profileName = ${JSON.stringify(profileName)};
|
|
251
|
+
const modelId = ${JSON.stringify(modelId)};
|
|
252
|
+
const groups = document.querySelector('#pop-model .pop-groups');
|
|
253
|
+
let profile = null;
|
|
254
|
+
for (const child of Array.from(groups.children)) {
|
|
255
|
+
if (child.tagName === 'BUTTON') {
|
|
256
|
+
const label = ((child.querySelector('.grow') || child).textContent || '').trim();
|
|
257
|
+
if (profile && profile.includes(profileName) && label.includes(modelId)) { child.click(); return { clicked: true, label }; }
|
|
258
|
+
} else if (child.classList.contains('pop-group')) {
|
|
259
|
+
profile = (child.textContent || '').trim();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return { clicked: false };
|
|
263
|
+
})()`);
|
|
264
|
+
if (!clicked.clicked) throw new Error(`the ${profileName} / ${modelId} entry could not be clicked`);
|
|
265
|
+
await waitForState(browser, state => state.product && state.product.currentModel === modelId, `the ${modelId} selection`, 15000);
|
|
266
|
+
return clicked;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function selectProject(browser, projectId) {
|
|
270
|
+
const clicked = await clickProjectHead(browser, projectId);
|
|
271
|
+
await waitForState(browser, state => state.activeProjectId === projectId, `the ${projectId} project to become active`, 15000);
|
|
272
|
+
return clicked;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// The native folder picker opens a blocking OS dialog, which a headless
|
|
276
|
+
// browser cannot answer. The product ships a manual fallback form for
|
|
277
|
+
// exactly that case; this drives that form, so the project is still created
|
|
278
|
+
// by the product's own handler and the product's own client call.
|
|
279
|
+
async function createProjectThroughForm(browser, rootPath, options = {}) {
|
|
280
|
+
const prepared = await browser.evaluate(`(() => {
|
|
281
|
+
const modal = document.getElementById('modal-add-proj');
|
|
282
|
+
const path = document.getElementById('np-path');
|
|
283
|
+
const confirm = document.getElementById('np-confirm');
|
|
284
|
+
modal.classList.add('open');
|
|
285
|
+
path.value = ${JSON.stringify(rootPath)};
|
|
286
|
+
path.dispatchEvent(new Event('input', { bubbles: true }));
|
|
287
|
+
return { confirmDisabled: confirm.disabled === true, derivedName: document.getElementById('np-name').value };
|
|
288
|
+
})()`);
|
|
289
|
+
if (prepared.confirmDisabled) throw new Error(`the add-project form refused the path ${rootPath}`);
|
|
290
|
+
const before = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => node.dataset.project)");
|
|
291
|
+
await browser.evaluate("document.getElementById('np-confirm').click()");
|
|
292
|
+
const after = await waitUntil(async () => {
|
|
293
|
+
const ids = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => node.dataset.project)");
|
|
294
|
+
const added = ids.filter(id => !before.includes(id));
|
|
295
|
+
return added.length ? added : null;
|
|
296
|
+
}, 'the new project to appear in the sidebar', 15000);
|
|
297
|
+
return { projectId: after[0], derivedName: prepared.derivedName };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// The isolated host ships a context workspace but no project entry, so the
|
|
301
|
+
// sidebar starts empty. The project is created through the product's own
|
|
302
|
+
// add-project form, on an isolated directory of this run.
|
|
303
|
+
async function ensureProject(browser, rootPath, options = {}) {
|
|
304
|
+
const projects = await browser.evaluate("Array.from(document.querySelectorAll('#project-list .proj')).map(node => ({ id: node.dataset.project, name: ((node.querySelector('.p-name') || {}).textContent || '').trim() }))");
|
|
305
|
+
const wanted = options.name ? projects.find(project => project.name === options.name) : null;
|
|
306
|
+
if (wanted) return { projectId: wanted.id, created: false, name: wanted.name };
|
|
307
|
+
fs.mkdirSync(rootPath, { recursive: true });
|
|
308
|
+
const created = await createProjectThroughForm(browser, rootPath, options);
|
|
309
|
+
return { ...created, created: true };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function typeText(browser, text) {
|
|
313
|
+
const typed = await browser.evaluate(`(() => {
|
|
314
|
+
const input = document.getElementById('chat-input');
|
|
315
|
+
input.value = ${JSON.stringify(text)};
|
|
316
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
317
|
+
return input.value;
|
|
318
|
+
})()`);
|
|
319
|
+
if (typed !== text) throw new Error('the composer did not accept the typed text');
|
|
320
|
+
return typed;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async function clickSend(browser) {
|
|
324
|
+
await browser.evaluate("document.getElementById('btn-send').click()");
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async function clickNewSession(browser) {
|
|
328
|
+
await browser.evaluate("document.getElementById('btn-new-session').click()");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// The product's own sidebar: a session is opened by clicking its row, and a
|
|
332
|
+
// project is switched by clicking its head. Both are real UI actions.
|
|
333
|
+
async function clickProjectHead(browser, projectId) {
|
|
334
|
+
const selector = `#project-list .proj[data-project="${String(projectId).replace(/"/g, '\\"')}"] .proj-item`;
|
|
335
|
+
await waitUntil(async () => browser.evaluate(`!!document.querySelector(${JSON.stringify(selector)})`), `the project ${projectId} in the sidebar`, 20000);
|
|
336
|
+
const clicked = await browser.evaluate(`(() => {
|
|
337
|
+
const node = document.querySelector(${JSON.stringify(selector)});
|
|
338
|
+
if (!node) return { clicked: false };
|
|
339
|
+
node.click();
|
|
340
|
+
return { clicked: true };
|
|
341
|
+
})()`);
|
|
342
|
+
if (!clicked.clicked) throw new Error(`the project ${projectId} has no head in the sidebar`);
|
|
343
|
+
return clicked;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async function openSessionRow(browser, projectId, sessionId) {
|
|
347
|
+
await clickProjectHead(browser, projectId);
|
|
348
|
+
await waitForState(browser, state => state.activeProjectId === projectId, `the ${projectId} project to become active`, 15000);
|
|
349
|
+
// The head click also toggles the expansion, so the session list may be
|
|
350
|
+
// collapsed; a second head click on the already active project expands it
|
|
351
|
+
// again without switching anything.
|
|
352
|
+
const expanded = await browser.evaluate(`(() => {
|
|
353
|
+
const id = ${JSON.stringify(projectId)};
|
|
354
|
+
const list = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list');
|
|
355
|
+
return list ? !list.hidden : null;
|
|
356
|
+
})()`);
|
|
357
|
+
if (expanded === false) {
|
|
358
|
+
await clickProjectHead(browser, projectId);
|
|
359
|
+
await waitUntil(async () => {
|
|
360
|
+
const hidden = await browser.evaluate(`(() => {
|
|
361
|
+
const id = ${JSON.stringify(projectId)};
|
|
362
|
+
const list = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list');
|
|
363
|
+
return list ? list.hidden : null;
|
|
364
|
+
})()`);
|
|
365
|
+
return hidden === false ? true : null;
|
|
366
|
+
}, `the session list of ${projectId} to be expanded`, 15000);
|
|
367
|
+
}
|
|
368
|
+
const ready = await waitUntil(async () => {
|
|
369
|
+
const found = await browser.evaluate(`(() => {
|
|
370
|
+
const id = ${JSON.stringify(projectId)};
|
|
371
|
+
const session = ${JSON.stringify(sessionId)};
|
|
372
|
+
const row = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list .session[data-session="' + session.replace(/"/g, '\\\\"') + '"]');
|
|
373
|
+
return row ? { found: true, title: (row.querySelector('.s-title') || {}).textContent || '' } : null;
|
|
374
|
+
})()`);
|
|
375
|
+
return found;
|
|
376
|
+
}, `the session ${sessionId} to be listed under ${projectId}`, 20000);
|
|
377
|
+
await browser.evaluate(`(() => {
|
|
378
|
+
const id = ${JSON.stringify(projectId)};
|
|
379
|
+
const session = ${JSON.stringify(sessionId)};
|
|
380
|
+
const row = document.querySelector('#project-list .proj[data-project="' + id.replace(/"/g, '\\\\"') + '"] .sess-list .session[data-session="' + session.replace(/"/g, '\\\\"') + '"]');
|
|
381
|
+
row.click();
|
|
382
|
+
return true;
|
|
383
|
+
})()`);
|
|
384
|
+
await waitForState(browser, state => state.product && state.product.activeSessionId === sessionId, `the session ${sessionId} to open`, 20000);
|
|
385
|
+
return ready;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// The product's own browser storage for drafts, read raw. Nothing is written
|
|
389
|
+
// through it here: the product writes it, this only looks.
|
|
390
|
+
async function readDraftStorage(browser) {
|
|
391
|
+
return browser.evaluate(`(() => {
|
|
392
|
+
const key = ${JSON.stringify(`kb.workbench.session-drafts:${API_BASE}`)};
|
|
393
|
+
const raw = localStorage.getItem(key) || '';
|
|
394
|
+
let parsed = null;
|
|
395
|
+
try { parsed = JSON.parse(raw || '{}'); } catch { parsed = null; }
|
|
396
|
+
const keys = Object.keys(parsed || {});
|
|
397
|
+
return { key, raw, parsed, keys, entryCount: keys.length };
|
|
398
|
+
})()`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// A real file goes into the real <input type="file">; the product's own
|
|
402
|
+
// change handler reads it.
|
|
403
|
+
async function attachFile(browser, fileName, content, mediaType = 'text/plain') {
|
|
404
|
+
const result = await browser.evaluate(`(() => {
|
|
405
|
+
const input = document.getElementById('file-input');
|
|
406
|
+
const file = new File([${JSON.stringify(content)}], ${JSON.stringify(fileName)}, { type: ${JSON.stringify(mediaType)} });
|
|
407
|
+
const transfer = new DataTransfer();
|
|
408
|
+
transfer.items.add(file);
|
|
409
|
+
input.files = transfer.files;
|
|
410
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
411
|
+
return { files: input.files.length };
|
|
412
|
+
})()`);
|
|
413
|
+
await waitForState(browser, state => state.attachments.length > 0, `the attachment ${fileName} to reach the tray`, 15000);
|
|
414
|
+
return result;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async function recordedEvents(browser) {
|
|
418
|
+
return browser.evaluate("Array.from((window.__wbRecorder && window.__wbRecorder.log) || []).map((entry, index) => ({ index, type: entry.type, data: entry.data, at: entry.at }))");
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function replayRecordedEvent(browser, index, urlPattern) {
|
|
422
|
+
return browser.evaluate(`window.__wbReplay(${Number(index)}, ${urlPattern === undefined || urlPattern === null ? 'null' : JSON.stringify(urlPattern)})`);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// --- the module's own session contract ------------------------------------
|
|
426
|
+
|
|
427
|
+
function sessionEventsUrl(base, sessionId, after = 0) {
|
|
428
|
+
const suffix = after > 0 ? `?after=${encodeURIComponent(after)}` : '';
|
|
429
|
+
return `${base}${API_BASE}/sessions/${encodeURIComponent(sessionId)}/events${suffix}`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Consume a session's SSE stream and count the events by type. This is the
|
|
433
|
+
// product's own event contract, read from outside the browser.
|
|
434
|
+
function consumeSessionEvents(url, onEvent, until, timeoutMs) {
|
|
435
|
+
const controller = new AbortController();
|
|
436
|
+
const timer = setTimeout(() => controller.abort(new Error(`event stream timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
437
|
+
let done = null;
|
|
438
|
+
const finished = new Promise(resolve => { done = resolve; });
|
|
439
|
+
(async () => {
|
|
440
|
+
try {
|
|
441
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
442
|
+
if (!response.ok) throw new Error(`event stream HTTP ${response.status}`);
|
|
443
|
+
const reader = response.body.getReader();
|
|
444
|
+
const decoder = new TextDecoder();
|
|
445
|
+
let buffer = '';
|
|
446
|
+
for (;;) {
|
|
447
|
+
const { value, done: streamDone } = await reader.read();
|
|
448
|
+
if (streamDone) break;
|
|
449
|
+
buffer += decoder.decode(value, { stream: true });
|
|
450
|
+
let index;
|
|
451
|
+
while ((index = buffer.indexOf('\n')) >= 0) {
|
|
452
|
+
const line = buffer.slice(0, index).replace(/\r$/, '');
|
|
453
|
+
buffer = buffer.slice(index + 1);
|
|
454
|
+
if (!line.startsWith('data:')) continue;
|
|
455
|
+
const payload = line.slice(5).trim();
|
|
456
|
+
if (!payload) continue;
|
|
457
|
+
let event;
|
|
458
|
+
try { event = JSON.parse(payload); } catch { continue; }
|
|
459
|
+
try { onEvent(event); } catch { /* listener errors never kill the stream */ }
|
|
460
|
+
if (until && until(event)) { controller.abort(); return; }
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
} catch { /* aborted or ended */ }
|
|
464
|
+
finally { done && done(); }
|
|
465
|
+
})();
|
|
466
|
+
return { finished, stop: () => controller.abort() };
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// --- the process census ----------------------------------------------------
|
|
470
|
+
//
|
|
471
|
+
// Only the subtree of THIS test's host child is inspected. Nothing outside it
|
|
472
|
+
// is ever enumerated by name, signalled or stopped.
|
|
473
|
+
function listProcesses() {
|
|
474
|
+
const script = "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine | ConvertTo-Json -Compress -Depth 2";
|
|
475
|
+
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], {
|
|
476
|
+
encoding: 'utf8', timeout: 60000, windowsHide: true, maxBuffer: 32 * 1024 * 1024,
|
|
477
|
+
});
|
|
478
|
+
if (result.status !== 0 || !result.stdout) return [];
|
|
479
|
+
let parsed;
|
|
480
|
+
try { parsed = JSON.parse(result.stdout); } catch { return []; }
|
|
481
|
+
if (!Array.isArray(parsed)) parsed = [parsed];
|
|
482
|
+
return parsed.map(entry => ({
|
|
483
|
+
pid: Number(entry.ProcessId),
|
|
484
|
+
ppid: Number(entry.ParentProcessId),
|
|
485
|
+
name: String(entry.Name || ''),
|
|
486
|
+
commandLine: String(entry.CommandLine || ''),
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function descendantProcesses(rootPid) {
|
|
491
|
+
const all = listProcesses();
|
|
492
|
+
const byParent = new Map();
|
|
493
|
+
for (const entry of all) {
|
|
494
|
+
if (!byParent.has(entry.ppid)) byParent.set(entry.ppid, []);
|
|
495
|
+
byParent.get(entry.ppid).push(entry);
|
|
496
|
+
}
|
|
497
|
+
const found = [];
|
|
498
|
+
const stack = [Number(rootPid)];
|
|
499
|
+
const seen = new Set();
|
|
500
|
+
while (stack.length) {
|
|
501
|
+
const pid = stack.pop();
|
|
502
|
+
for (const child of byParent.get(pid) || []) {
|
|
503
|
+
if (seen.has(child.pid)) continue;
|
|
504
|
+
seen.add(child.pid);
|
|
505
|
+
found.push(child);
|
|
506
|
+
stack.push(child.pid);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return found;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// The runtime the module spawns for a session is a node process running the
|
|
513
|
+
// Claude CLI. Only names and pids leave this function.
|
|
514
|
+
function runtimeProcesses(rootPid) {
|
|
515
|
+
return descendantProcesses(rootPid)
|
|
516
|
+
.filter(entry => /^(node|claude|bun|deno)/i.test(entry.name))
|
|
517
|
+
.map(entry => ({
|
|
518
|
+
pid: entry.pid,
|
|
519
|
+
ppid: entry.ppid,
|
|
520
|
+
name: entry.name,
|
|
521
|
+
// The command line carries the session identity of the runtime; it is
|
|
522
|
+
// truncated and holds no credential (the credential lives in the env).
|
|
523
|
+
commandLine: String(entry.commandLine || '').slice(0, 300),
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// --- evidence helpers -----------------------------------------------------
|
|
528
|
+
|
|
529
|
+
function moduleIdentity(moduleRoot) {
|
|
530
|
+
const identity = sourceMap.packageIdentity(moduleRoot) || {};
|
|
531
|
+
return {
|
|
532
|
+
label: moduleRoot === sourceMap.resolveInstalledProductPackage()
|
|
533
|
+
? 'currently-installed-package:installed-product'
|
|
534
|
+
: 'currently-installed-package:repository-pin',
|
|
535
|
+
root: moduleRoot,
|
|
536
|
+
name: identity.name || null,
|
|
537
|
+
version: identity.version || null,
|
|
538
|
+
uiFiles: {
|
|
539
|
+
'apps/agent-terminal/app.js': sha256File(path.join(moduleRoot, 'apps', 'agent-terminal', 'app.js')),
|
|
540
|
+
'apps/agent-terminal/index.html': sha256File(path.join(moduleRoot, 'apps', 'agent-terminal', 'index.html')),
|
|
541
|
+
'packages/client/index.js': sha256File(path.join(moduleRoot, 'packages', 'client', 'index.js')),
|
|
542
|
+
'src/backend/lib/claude-cli-runner.js': sha256File(path.join(moduleRoot, 'src', 'backend', 'lib', 'claude-cli-runner.js')),
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function writeEvidence(target, payload) {
|
|
548
|
+
if (!target) return null;
|
|
549
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
550
|
+
fs.writeFileSync(target, JSON.stringify(payload, null, 2), 'utf8');
|
|
551
|
+
return target;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
module.exports = {
|
|
555
|
+
API_BASE,
|
|
556
|
+
RECORDER_SOURCE,
|
|
557
|
+
wait,
|
|
558
|
+
waitUntil,
|
|
559
|
+
getJson,
|
|
560
|
+
startHost,
|
|
561
|
+
stopHost,
|
|
562
|
+
openBrowser,
|
|
563
|
+
reloadPage,
|
|
564
|
+
readState,
|
|
565
|
+
waitForState,
|
|
566
|
+
selectModel,
|
|
567
|
+
selectProject,
|
|
568
|
+
createProjectThroughForm,
|
|
569
|
+
ensureProject,
|
|
570
|
+
typeText,
|
|
571
|
+
clickSend,
|
|
572
|
+
clickNewSession,
|
|
573
|
+
clickProjectHead,
|
|
574
|
+
openSessionRow,
|
|
575
|
+
readDraftStorage,
|
|
576
|
+
attachFile,
|
|
577
|
+
recordedEvents,
|
|
578
|
+
replayRecordedEvent,
|
|
579
|
+
sessionEventsUrl,
|
|
580
|
+
consumeSessionEvents,
|
|
581
|
+
listProcesses,
|
|
582
|
+
descendantProcesses,
|
|
583
|
+
runtimeProcesses,
|
|
584
|
+
moduleIdentity,
|
|
585
|
+
writeEvidence,
|
|
586
|
+
sha256File,
|
|
587
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// P-ENGINE-OFFLINE-AUDIT-R45 lane harness (ENG-007 offline compensation
|
|
4
|
+
// boundary audit). Wraps the audited P-ENG-FINAL harness READ-ONLY: this file
|
|
5
|
+
// adds nothing but (1) driver-process environment isolation applied BEFORE the
|
|
6
|
+
// wrapped harness is required, and (2) a post-commit hook variant whose real
|
|
7
|
+
// bridge CLI is reachable but whose bridge home is an unwritable destination
|
|
8
|
+
// ("hook 不可达" fault: the CLI runs and fails, the journal never hears about
|
|
9
|
+
// the commit, Git itself is not blocked).
|
|
10
|
+
//
|
|
11
|
+
// Portability: no hardcoded drive letters. Temp/evidence roots resolve from
|
|
12
|
+
// R45_TEMP_ROOT / R45_EVIDENCE_ROOT when set, otherwise the OS temp dir and
|
|
13
|
+
// the repo-relative ignored artifacts dir. The wrapped harness additionally
|
|
14
|
+
// refuses temp roots inside the repository.
|
|
15
|
+
|
|
16
|
+
const fs = require('node:fs');
|
|
17
|
+
const os = require('node:os');
|
|
18
|
+
const path = require('node:path');
|
|
19
|
+
|
|
20
|
+
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
21
|
+
|
|
22
|
+
// ---------- step 1: isolate the driver process environment ----------
|
|
23
|
+
const TEMP_ROOT = path.resolve(process.env.R45_TEMP_ROOT || process.env.PK_TEST_TEMP_ROOT || path.join(os.tmpdir(), 'r45-engine-offline'));
|
|
24
|
+
const EVIDENCE_ROOT = path.resolve(process.env.R45_EVIDENCE_ROOT || path.join(REPO_ROOT, 'qa-autopilot', 'artifacts', 'parallel-20261023', 'engine-offline-audit-r45', 'evidence'));
|
|
25
|
+
|
|
26
|
+
if (TEMP_ROOT === REPO_ROOT || TEMP_ROOT.startsWith(REPO_ROOT + path.sep)) {
|
|
27
|
+
throw new Error(`R45 temp root must live outside the repository (got ${TEMP_ROOT})`);
|
|
28
|
+
}
|
|
29
|
+
fs.mkdirSync(TEMP_ROOT, { recursive: true });
|
|
30
|
+
fs.mkdirSync(EVIDENCE_ROOT, { recursive: true });
|
|
31
|
+
|
|
32
|
+
const ISO = path.join(TEMP_ROOT, 'iso');
|
|
33
|
+
for (const dir of ['home', 'appdata', 'localappdata', 'tmp', 'codex', 'claude', 'workbench', 'bridge', 'kb-data', 'kb-knowledge']) {
|
|
34
|
+
fs.mkdirSync(path.join(ISO, dir, Math.random().toString(36).slice(2)), { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
function oneOf(name) {
|
|
37
|
+
const dir = path.join(ISO, name);
|
|
38
|
+
return fs.readdirSync(dir)[0] ? path.join(dir, fs.readdirSync(dir)[0]) : dir;
|
|
39
|
+
}
|
|
40
|
+
const envIsolation = {
|
|
41
|
+
HOME: oneOf('home'), USERPROFILE: oneOf('home'),
|
|
42
|
+
APPDATA: oneOf('appdata'), LOCALAPPDATA: oneOf('localappdata'),
|
|
43
|
+
TEMP: oneOf('tmp'), TMP: oneOf('tmp'),
|
|
44
|
+
CODEX_HOME: oneOf('codex'), CLAUDE_CONFIG_DIR: oneOf('claude'),
|
|
45
|
+
CLAUDE_AI_WORKBENCH_DATA_DIR: oneOf('workbench'),
|
|
46
|
+
AI_CODING_EVENT_BRIDGE_HOME: oneOf('bridge'),
|
|
47
|
+
KB_DATA_DIR: oneOf('kb-data'), KB_KNOWLEDGE_DATA_DIR: oneOf('kb-knowledge'),
|
|
48
|
+
PK_TEST_TEMP_ROOT: TEMP_ROOT,
|
|
49
|
+
};
|
|
50
|
+
for (const [name, value] of Object.entries(envIsolation)) process.env[name] = value;
|
|
51
|
+
// resolved-containment assertion for every isolated root
|
|
52
|
+
const resolved = Object.fromEntries(Object.entries(envIsolation).map(([k, v]) => [k, path.resolve(v)]));
|
|
53
|
+
for (const [k, v] of Object.entries(resolved)) {
|
|
54
|
+
const root = path.resolve(TEMP_ROOT);
|
|
55
|
+
if (v !== root && !v.startsWith(root + path.sep)) {
|
|
56
|
+
throw new Error(`containment failure: ${k} -> ${v} escapes ${TEMP_ROOT}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ---------- step 2: require the audited harness (read-only reuse) ----------
|
|
61
|
+
const FINAL = require('./parallel-engine-final-harness.js');
|
|
62
|
+
|
|
63
|
+
// ---------- step 3: hook variants owned by this lane ----------
|
|
64
|
+
// dead-home: a regular FILE occupies the bridge home path, so the real CLI
|
|
65
|
+
// process starts, cannot create its journal destination, exits non-zero, and
|
|
66
|
+
// the hook propagates that fault. 'ok' matches the audited harness behaviour
|
|
67
|
+
// (real CLI, real home, output silenced) but is installed by this lane so the
|
|
68
|
+
// wrapped installer is never modified.
|
|
69
|
+
function installHookVariant(repoPath, { home, mode }) {
|
|
70
|
+
const hookPath = path.join(repoPath, '.git', 'hooks', 'post-commit');
|
|
71
|
+
const slash = value => value.replace(/\\/g, '/');
|
|
72
|
+
const line = `"${slash(process.execPath)}" "${slash(FINAL.BRIDGE_CLI)}" --home "${slash(home)}" --cwd "${slash(repoPath)}"`;
|
|
73
|
+
const script = mode === 'ok'
|
|
74
|
+
? ['#!/bin/sh', `${line} >/dev/null 2>&1`, 'exit 1', ''].join('\n')
|
|
75
|
+
: ['#!/bin/sh', line, 'exit 1', ''].join('\n');
|
|
76
|
+
fs.mkdirSync(path.dirname(hookPath), { recursive: true });
|
|
77
|
+
fs.writeFileSync(hookPath, script, { mode: 0o755 });
|
|
78
|
+
return { hookPath, mode, content: script };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function makeDeadHome(lane) {
|
|
82
|
+
const dead = path.join(lane, 'dead-bridge-home');
|
|
83
|
+
fs.writeFileSync(dead, 'not a directory: the bridge journal destination is unreachable\n');
|
|
84
|
+
return dead;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
...FINAL,
|
|
89
|
+
TEMP_ROOT,
|
|
90
|
+
EVIDENCE_ROOT,
|
|
91
|
+
ENV_ISOLATION_RESOLVED: resolved,
|
|
92
|
+
installHookVariant,
|
|
93
|
+
makeDeadHome,
|
|
94
|
+
};
|