@staff0rd/assist 0.1226.1 → 0.1227.0
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/dist/.build-files +109 -109
- package/dist/{addActivity-WJKCXFFQ.js → addActivity-JRAHUUXZ.js} +4 -4
- package/dist/{addPhase-FCUFJU2C.js → addPhase-RXMC6KKV.js} +8 -8
- package/dist/{advise-G2OU45ZJ.js → advise-7VSDCQMB.js} +7 -7
- package/dist/{ask-HU23YKRK.js → ask-XOYV75UD.js} +5 -5
- package/dist/{askCheck-2DO2YPCV.js → askCheck-AIZIY63N.js} +12 -12
- package/dist/{askDesign-AW6DZDD5.js → askDesign-4H3NS726.js} +7 -7
- package/dist/{askQuestion-2AVDU7K3.js → askQuestion-YW4VEUJK.js} +4 -4
- package/dist/{branch-PVVYH5PW.js → branch-D24SMBC7.js} +6 -6
- package/dist/built-version +1 -1
- package/dist/{chunk-4KIWZE6L.js → chunk-4BQZ65QP.js} +2 -2
- package/dist/{chunk-ESOMHI4A.js → chunk-4CB7MIIA.js} +1 -1
- package/dist/{chunk-FNEBHLRA.js → chunk-5IJZ7IMN.js} +4 -4
- package/dist/{chunk-6Z5A6IR3.js → chunk-5LMPNIA6.js} +1 -1
- package/dist/{chunk-CZZR4A3M.js → chunk-67ZGDTLS.js} +2 -2
- package/dist/{chunk-HXZQ64MY.js → chunk-6FABCRXK.js} +8 -8
- package/dist/{chunk-6CVGPCIX.js → chunk-6J6LMIAZ.js} +2 -2
- package/dist/{chunk-V3WEX475.js → chunk-7QKIU4J6.js} +1 -1
- package/dist/{chunk-MPMNMT7R.js → chunk-AJYGACYK.js} +1 -1
- package/dist/{chunk-L3NQEY2A.js → chunk-ANWVOA4Y.js} +1 -1
- package/dist/{chunk-EN4GUAJN.js → chunk-APR23G2L.js} +1 -1
- package/dist/{chunk-DZNGTNBE.js → chunk-AXRZJ564.js} +1 -1
- package/dist/{chunk-ANO2DTZQ.js → chunk-BBRCRGGZ.js} +2 -2
- package/dist/{chunk-XOCRMXTJ.js → chunk-BPHJD6WG.js} +1 -1
- package/dist/{chunk-QXQVZXWB.js → chunk-CUVOZKBH.js} +1 -1
- package/dist/{chunk-IXU3HNPK.js → chunk-EYDTZB3C.js} +7 -7
- package/dist/{chunk-KHHBKYBD.js → chunk-FQV62GZZ.js} +1 -1
- package/dist/{chunk-UZWSCPAO.js → chunk-GJFTADBZ.js} +1 -1
- package/dist/{chunk-B7V52ERW.js → chunk-GY3IZXOI.js} +1 -1
- package/dist/{chunk-GMUBETSU.js → chunk-H3LTWKTD.js} +2 -11
- package/dist/{chunk-ASTJWYWL.js → chunk-H6MJ5HH3.js} +2 -2
- package/dist/{chunk-FGAFY5FV.js → chunk-IWQEVVOM.js} +1 -1
- package/dist/{chunk-QFBWUL4O.js → chunk-JUS2VN4V.js} +4 -4
- package/dist/{chunk-NVMMQ2CH.js → chunk-L2THWBKM.js} +2 -2
- package/dist/{chunk-GEHEJMHR.js → chunk-LCW2ITRX.js} +1 -1
- package/dist/{chunk-UYJIXQHJ.js → chunk-LUWQTG2F.js} +1 -1
- package/dist/{chunk-AR4PXFLV.js → chunk-LV367MST.js} +1 -1
- package/dist/{chunk-U572JQMZ.js → chunk-LX62NQOS.js} +1 -1
- package/dist/{chunk-YWRRBEIG.js → chunk-M73QHITE.js} +4 -4
- package/dist/{chunk-YOGFNYVD.js → chunk-MJPOSDML.js} +2 -2
- package/dist/{chunk-JQG4UT5A.js → chunk-N4BNRDK2.js} +1 -1
- package/dist/{chunk-ATBTW52C.js → chunk-NXYMAQ4Z.js} +1 -1
- package/dist/{chunk-A6I3ZMDH.js → chunk-OC6VTXDA.js} +1 -1
- package/dist/{chunk-KDRQBUAY.js → chunk-ONQ6MO47.js} +1 -1
- package/dist/{chunk-RVX67NKA.js → chunk-OYOJN65U.js} +2 -2
- package/dist/{chunk-I3ZRJ3C7.js → chunk-PLIRNETU.js} +2 -2
- package/dist/{chunk-R75YUFD3.js → chunk-Q6SINEMV.js} +1 -1
- package/dist/{chunk-VKMH4WCM.js → chunk-QSXE3JSO.js} +1 -1
- package/dist/{chunk-5FOLBCWJ.js → chunk-R6GDVCBH.js} +1 -1
- package/dist/{chunk-EUCFTM2F.js → chunk-RVRQJ7Y4.js} +496 -394
- package/dist/{chunk-OI5M5KLY.js → chunk-SGIJJYLS.js} +3 -3
- package/dist/{chunk-R2JNHRB4.js → chunk-SXJP3TAP.js} +1 -1
- package/dist/{chunk-5K3J2ZIP.js → chunk-SZYLBBKA.js} +1 -1
- package/dist/{chunk-74S54O2J.js → chunk-UOFXNSGZ.js} +1 -1
- package/dist/{chunk-VOMQJC2G.js → chunk-UTEU2LTC.js} +2 -2
- package/dist/{chunk-2IMSOUP4.js → chunk-X7YK2DX4.js} +1 -1
- package/dist/{chunk-54ACF6SA.js → chunk-XPKMXE5G.js} +1 -1
- package/dist/{chunk-UU2FV576.js → chunk-XT7MM4OX.js} +7 -7
- package/dist/{chunk-7ORXMQKM.js → chunk-Z2RMEPKX.js} +1 -1
- package/dist/{chunk-5MHSC7XK.js → chunk-ZF2X6EWO.js} +1 -1
- package/dist/{cliHook-IJSYDI35.js → cliHook-URMXDHRI.js} +9 -9
- package/dist/{cliHookCheck-LW65BRGS.js → cliHookCheck-HAMZ6N7P.js} +4 -4
- package/dist/{codexHook-CNNUONVN.js → codexHook-DQ2HIAZV.js} +12 -12
- package/dist/commands/sessions/web/bundle.js +181 -181
- package/dist/{comment-TFGXBDK5.js → comment-QCXXFHAE.js} +6 -6
- package/dist/{commentIssue-JPJGSAOB.js → commentIssue-MF42XVP5.js} +5 -5
- package/dist/{commit-BS6KHIR6.js → commit-Q34LZSMC.js} +9 -9
- package/dist/{createIssue-LKMYVJ74.js → createIssue-2DSC5YPL.js} +4 -4
- package/dist/{doctorNodes-HKK5ZP4I.js → doctorNodes-A2275MKU.js} +3 -3
- package/dist/{done-CNIZAH52.js → done-BIQWGSUR.js} +7 -7
- package/dist/{edit-HQQCQVO5.js → edit-OFDAZJXM.js} +4 -4
- package/dist/{editHook-ZWGMUKCH.js → editHook-3CTLTJAE.js} +9 -9
- package/dist/{editIssue-U247BW6F.js → editIssue-GHHFCOEM.js} +4 -4
- package/dist/{editIssueComment-V4E6E3JT.js → editIssueComment-B2NHIXTK.js} +5 -5
- package/dist/{fixConflict-LIUQCMP7.js → fixConflict-D7AQD7GL.js} +9 -9
- package/dist/{harnessFollowUps-GUL2JEGZ.js → harnessFollowUps-6WANGM6U.js} +1 -1
- package/dist/index.js +66 -66
- package/dist/{launchMode-JSSZ3DLS.js → launchMode-X7RSVTJJ.js} +19 -19
- package/dist/{list-6NHAPSCV.js → list-TUCQVPFB.js} +8 -8
- package/dist/{migrate-XMEYPFSJ.js → migrate-4EUROOTE.js} +5 -5
- package/dist/{next-NMZ4UYCL.js → next-VETMLMP2.js} +18 -18
- package/dist/{phaseDone-6LWYT4A4.js → phaseDone-5MD7KEN7.js} +8 -8
- package/dist/{piHook-CVJF55AO.js → piHook-JX6REEPL.js} +9 -9
- package/dist/{postSlackMessage-X5QM2Y6U.js → postSlackMessage-UE4HOBVZ.js} +5 -5
- package/dist/{propose-JMH555II.js → propose-XUDMMSEA.js} +9 -9
- package/dist/{raise-6IRIWUH5.js → raise-JHVINPVB.js} +4 -4
- package/dist/{refine-NCUDNGNK.js → refine-VVTUN7OT.js} +20 -20
- package/dist/{reply-EOZ2MMOO.js → reply-NKVUQ7CW.js} +5 -5
- package/dist/{restartNode-WJAFDOJR.js → restartNode-XLNZ5J2Y.js} +5 -5
- package/dist/{review-IZ4KFJJB.js → review-UPEIF37T.js} +13 -13
- package/dist/{reviewPrComments-DLKTH372.js → reviewPrComments-FRM5AGVR.js} +9 -9
- package/dist/{rewindPhase-KQVS5ZBR.js → rewindPhase-3I7PN4OW.js} +11 -11
- package/dist/{rulesAdd-KREYXS4F.js → rulesAdd-QAZYI7XE.js} +5 -5
- package/dist/{run-C2ASSPJD.js → run-KL5BXRA6.js} +16 -16
- package/dist/{run-G4AQNOSH.js → run-XVF5XT7I.js} +16 -16
- package/dist/{runDaemon-SLZFGRBM.js → runDaemon-FMB67AWD.js} +71 -54
- package/dist/{runExtract-4BGVMV4H.js → runExtract-JW544PRR.js} +4 -4
- package/dist/{runParallelPhase-SBFLYBLY.js → runParallelPhase-O7UPAQ63.js} +11 -11
- package/dist/{runRefine-XZBPOP4I.js → runRefine-K5E4MKNE.js} +20 -20
- package/dist/{scan-5UFH4ICQ.js → scan-MH2TAEXU.js} +6 -6
- package/dist/{schemaConfirm-BXFM2472.js → schemaConfirm-NITAQHBQ.js} +4 -4
- package/dist/{schemaLock-I46X5EFX.js → schemaLock-JXKR2STW.js} +4 -4
- package/dist/{schemaUnlock-N337LSZD.js → schemaUnlock-MQJ3NI7V.js} +4 -4
- package/dist/{search-EQ55NZEX.js → search-J3FONX65.js} +8 -8
- package/dist/{show-KD7EKQLP.js → show-E3QF5WHR.js} +5 -5
- package/dist/{show-7ID5EFBV.js → show-UXY6K72Q.js} +6 -6
- package/dist/{signExtension-ITZLMK2F.js → signExtension-FT5TRDKU.js} +1 -1
- package/dist/{slack-KE7URAIF.js → slack-4LSOREGH.js} +5 -5
- package/dist/{updateNode-PEKMUFIK.js → updateNode-IXZ2BIFA.js} +5 -5
- package/dist/{updatePlan-ZQYVVJK3.js → updatePlan-OBEHMLM7.js} +9 -9
- package/dist/{web-ATWY5GMW.js → web-MJFRLFK7.js} +19 -19
- package/dist/{web-AIVREYIR.js → web-SJTEG7FR.js} +19 -19
- package/dist/{wontfix-VKIRGLUI.js → wontfix-3ZPBKWVM.js} +5 -5
- package/package.json +1 -1
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
harnessCapability,
|
|
20
20
|
sdkAgentEnv
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-QSXE3JSO.js";
|
|
22
22
|
import {
|
|
23
23
|
harnessCapabilityDeclarations,
|
|
24
24
|
supported,
|
|
25
25
|
unsupported
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-H3LTWKTD.js";
|
|
27
27
|
import {
|
|
28
28
|
harnessLabel,
|
|
29
29
|
resolveHarness
|
|
@@ -121,15 +121,245 @@ function buildArgs(prompt, options) {
|
|
|
121
121
|
return prompt ? [prompt] : [];
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
// src/
|
|
124
|
+
// src/shared/harnessAdapters/exportClaudeTranscript.ts
|
|
125
|
+
import { readFile } from "fs/promises";
|
|
126
|
+
|
|
127
|
+
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
128
|
+
import * as path3 from "path";
|
|
129
|
+
|
|
130
|
+
// src/commands/sessions/shared/parseSessionFile.ts
|
|
125
131
|
import * as fs from "fs";
|
|
132
|
+
|
|
133
|
+
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
134
|
+
var KNOWN = [
|
|
135
|
+
"draft",
|
|
136
|
+
"next",
|
|
137
|
+
"bug",
|
|
138
|
+
"refine",
|
|
139
|
+
"review",
|
|
140
|
+
"run",
|
|
141
|
+
"update"
|
|
142
|
+
];
|
|
143
|
+
function deriveHistoryFields(commandName, commandArgs, name) {
|
|
144
|
+
const fields = {};
|
|
145
|
+
const sessionType = deriveSessionType(commandName, name);
|
|
146
|
+
if (sessionType) fields.sessionType = sessionType;
|
|
147
|
+
const itemMatch = commandArgs.match(/^(\d+)\b\s*/);
|
|
148
|
+
if (itemMatch) fields.itemId = Number(itemMatch[1]);
|
|
149
|
+
const prompt = commandArgs.slice(itemMatch?.[0].length ?? 0).trim();
|
|
150
|
+
if (prompt) fields.prompt = prompt;
|
|
151
|
+
return fields;
|
|
152
|
+
}
|
|
153
|
+
function deriveSessionType(commandName, name) {
|
|
154
|
+
if (commandName === "review-pr-comments" || commandName === "fix-conflict")
|
|
155
|
+
return "review";
|
|
156
|
+
if (KNOWN.includes(commandName))
|
|
157
|
+
return commandName;
|
|
158
|
+
if (commandName || name) return "prompt";
|
|
159
|
+
return void 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/commands/sessions/shared/deriveProject.ts
|
|
163
|
+
import * as path from "path";
|
|
164
|
+
function deriveProject(cwd, filePath, origin) {
|
|
165
|
+
if (!cwd) return dirNameToProject(filePath);
|
|
166
|
+
return origin === "windows" ? path.win32.basename(cwd) : path.basename(cwd);
|
|
167
|
+
}
|
|
168
|
+
function dirNameToProject(filePath) {
|
|
169
|
+
const dirName = path.basename(path.dirname(filePath));
|
|
170
|
+
const parts = dirName.split("--");
|
|
171
|
+
return parts[parts.length - 1].replace(/-/g, "/");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/commands/sessions/shared/backlogRunMarkers.ts
|
|
175
|
+
function backlogRunMarkers(text) {
|
|
176
|
+
const match = text.match(/backlog item a(\d+):[ \t]*([^\n]*)/);
|
|
177
|
+
if (!match) return { commandName: "", commandArgs: "" };
|
|
178
|
+
const title = match[2].trim();
|
|
179
|
+
return {
|
|
180
|
+
commandName: "next",
|
|
181
|
+
commandArgs: title ? `${match[1]} ${title}` : match[1]
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/commands/sessions/shared/parseFirstUserEntry.ts
|
|
186
|
+
function parseFirstUserEntry(entry) {
|
|
187
|
+
const raw = messageText(entry);
|
|
188
|
+
const commandName = matchMarker(raw, "command-name").replace(/^\//, "");
|
|
189
|
+
const commandArgs = matchMarker(raw, "command-args");
|
|
190
|
+
const name = stripMarkers(raw);
|
|
191
|
+
if (commandName) return { name, commandName, commandArgs };
|
|
192
|
+
return { name, ...backlogRunMarkers(raw) };
|
|
193
|
+
}
|
|
194
|
+
function messageText(entry) {
|
|
195
|
+
const msg = entry.message;
|
|
196
|
+
const content = msg?.content;
|
|
197
|
+
return typeof content === "string" ? content : Array.isArray(content) ? content.find((c) => c.type === "text")?.text ?? "" : "";
|
|
198
|
+
}
|
|
199
|
+
function matchMarker(text, tag) {
|
|
200
|
+
const match = text.match(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`));
|
|
201
|
+
return match ? match[1].trim() : "";
|
|
202
|
+
}
|
|
203
|
+
function stripMarkers(text) {
|
|
204
|
+
return text.replace(/<command-[^>]*>[^<]*<\/command-[^>]*>/g, "").trim().slice(0, 80);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/commands/sessions/shared/extractSessionMeta.ts
|
|
208
|
+
function extractSessionMeta(lines) {
|
|
209
|
+
let reachedFirstPrompt = false;
|
|
210
|
+
let sessionId = "";
|
|
211
|
+
let cwd = "";
|
|
212
|
+
let timestamp = "";
|
|
213
|
+
let name = "";
|
|
214
|
+
let commandName = "";
|
|
215
|
+
let commandArgs = "";
|
|
216
|
+
for (const line of lines) {
|
|
217
|
+
const entry = safeParse(line);
|
|
218
|
+
if (!entry) continue;
|
|
219
|
+
sessionId ||= strField(entry, "sessionId");
|
|
220
|
+
timestamp ||= strField(entry, "timestamp");
|
|
221
|
+
cwd ||= strField(entry, "cwd");
|
|
222
|
+
if (entry.type === "user" && !entry.isMeta) {
|
|
223
|
+
({ name, commandName, commandArgs } = parseFirstUserEntry(entry));
|
|
224
|
+
reachedFirstPrompt = true;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
sessionId,
|
|
230
|
+
cwd,
|
|
231
|
+
timestamp,
|
|
232
|
+
name,
|
|
233
|
+
commandName,
|
|
234
|
+
commandArgs,
|
|
235
|
+
reachedFirstPrompt
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function strField(entry, key) {
|
|
239
|
+
const value = entry[key];
|
|
240
|
+
return typeof value === "string" ? value : "";
|
|
241
|
+
}
|
|
242
|
+
function safeParse(line) {
|
|
243
|
+
try {
|
|
244
|
+
return JSON.parse(line);
|
|
245
|
+
} catch {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/commands/sessions/shared/readSessionMeta.ts
|
|
251
|
+
var GROWING_HEAD_SIZES = [16384, 262144, 2097152];
|
|
252
|
+
async function readSessionMeta(handle) {
|
|
253
|
+
let meta = extractSessionMeta([]);
|
|
254
|
+
for (const size of GROWING_HEAD_SIZES) {
|
|
255
|
+
const buf = Buffer.alloc(size);
|
|
256
|
+
const { bytesRead } = await handle.read(buf, 0, size, 0);
|
|
257
|
+
meta = extractSessionMeta(
|
|
258
|
+
buf.toString("utf8", 0, bytesRead).split("\n").filter(Boolean)
|
|
259
|
+
);
|
|
260
|
+
if (bytesRead < size || meta.reachedFirstPrompt) break;
|
|
261
|
+
}
|
|
262
|
+
return meta;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/commands/sessions/shared/parseSessionFile.ts
|
|
266
|
+
async function parseSessionFile(filePath, origin = "wsl") {
|
|
267
|
+
let handle;
|
|
268
|
+
try {
|
|
269
|
+
handle = await fs.promises.open(filePath, "r");
|
|
270
|
+
const meta = await readSessionMeta(handle);
|
|
271
|
+
if (!meta.sessionId) return null;
|
|
272
|
+
const lastActivity = (await fs.promises.stat(filePath)).mtime.toISOString();
|
|
273
|
+
return {
|
|
274
|
+
sessionId: meta.sessionId,
|
|
275
|
+
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
276
|
+
project: deriveProject(meta.cwd, filePath, origin),
|
|
277
|
+
cwd: meta.cwd,
|
|
278
|
+
timestamp: meta.timestamp || lastActivity,
|
|
279
|
+
lastActivity,
|
|
280
|
+
origin,
|
|
281
|
+
...deriveHistoryFields(meta.commandName, meta.commandArgs, meta.name)
|
|
282
|
+
};
|
|
283
|
+
} catch {
|
|
284
|
+
return null;
|
|
285
|
+
} finally {
|
|
286
|
+
await handle?.close();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/commands/sessions/shared/discoverSessionJsonlPaths.ts
|
|
291
|
+
import * as fs2 from "fs";
|
|
292
|
+
import * as os from "os";
|
|
126
293
|
import * as path2 from "path";
|
|
294
|
+
async function discoverSessionJsonlPaths() {
|
|
295
|
+
const results = [];
|
|
296
|
+
await Promise.all(
|
|
297
|
+
sessionRoots().map(async ({ dir, origin }) => {
|
|
298
|
+
let projectDirs;
|
|
299
|
+
try {
|
|
300
|
+
projectDirs = await fs2.promises.readdir(dir);
|
|
301
|
+
} catch {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
await Promise.all(
|
|
305
|
+
projectDirs.map(async (dirName) => {
|
|
306
|
+
const dirPath = path2.join(dir, dirName);
|
|
307
|
+
let entries;
|
|
308
|
+
try {
|
|
309
|
+
entries = await fs2.promises.readdir(dirPath);
|
|
310
|
+
} catch {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
for (const file of entries) {
|
|
314
|
+
if (file.endsWith(".jsonl"))
|
|
315
|
+
results.push({ path: path2.join(dirPath, file), origin });
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
);
|
|
319
|
+
})
|
|
320
|
+
);
|
|
321
|
+
return results;
|
|
322
|
+
}
|
|
323
|
+
function sessionRoots() {
|
|
324
|
+
return [
|
|
325
|
+
{ dir: path2.join(os.homedir(), ".claude", "projects"), origin: "wsl" }
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
330
|
+
async function findSessionJsonlPath(sessionId) {
|
|
331
|
+
const paths = await discoverSessionJsonlPaths();
|
|
332
|
+
const direct = paths.find(
|
|
333
|
+
(p) => path3.basename(p.path, ".jsonl") === sessionId
|
|
334
|
+
);
|
|
335
|
+
if (direct) return direct.path;
|
|
336
|
+
for (const p of paths) {
|
|
337
|
+
const meta = await parseSessionFile(p.path, p.origin);
|
|
338
|
+
if (meta?.sessionId === sessionId) return p.path;
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/shared/harnessAdapters/exportClaudeTranscript.ts
|
|
344
|
+
async function exportClaudeTranscript(id) {
|
|
345
|
+
const path15 = await findSessionJsonlPath(id);
|
|
346
|
+
if (!path15) throw new Error(`no transcript found for ${id}`);
|
|
347
|
+
return { id, transcript: await readFile(path15, "utf8") };
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/shared/harnessAdapters/placeClaudeTranscript.ts
|
|
351
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
352
|
+
import { join as join4 } from "path";
|
|
353
|
+
|
|
354
|
+
// src/commands/sessions/shared/findTranscriptPathSync.ts
|
|
355
|
+
import * as fs3 from "fs";
|
|
356
|
+
import * as path5 from "path";
|
|
127
357
|
|
|
128
358
|
// src/commands/sessions/shared/claudeProjectsRoot.ts
|
|
129
|
-
import * as
|
|
130
|
-
import * as
|
|
359
|
+
import * as os2 from "os";
|
|
360
|
+
import * as path4 from "path";
|
|
131
361
|
function claudeProjectsRoot() {
|
|
132
|
-
return
|
|
362
|
+
return path4.join(os2.homedir(), ".claude", "projects");
|
|
133
363
|
}
|
|
134
364
|
function projectSlug(cwd) {
|
|
135
365
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
@@ -137,42 +367,54 @@ function projectSlug(cwd) {
|
|
|
137
367
|
|
|
138
368
|
// src/commands/sessions/shared/findTranscriptPathSync.ts
|
|
139
369
|
function projectDirForCwd(cwd) {
|
|
140
|
-
return
|
|
370
|
+
return path5.join(claudeProjectsRoot(), projectSlug(cwd));
|
|
141
371
|
}
|
|
142
372
|
function transcriptPathFor(cwd, claudeSessionId) {
|
|
143
|
-
return
|
|
373
|
+
return path5.join(projectDirForCwd(cwd), `${claudeSessionId}.jsonl`);
|
|
144
374
|
}
|
|
145
375
|
function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
146
376
|
const direct = transcriptPathFor(cwd, claudeSessionId);
|
|
147
|
-
if (
|
|
377
|
+
if (fs3.existsSync(direct)) return direct;
|
|
148
378
|
const dir = projectDirForCwd(cwd);
|
|
149
379
|
let files;
|
|
150
380
|
try {
|
|
151
|
-
files =
|
|
381
|
+
files = fs3.readdirSync(dir);
|
|
152
382
|
} catch {
|
|
153
383
|
return null;
|
|
154
384
|
}
|
|
155
385
|
for (const file of files) {
|
|
156
386
|
if (!file.endsWith(".jsonl")) continue;
|
|
157
|
-
if (headContainsSessionId(
|
|
158
|
-
return
|
|
387
|
+
if (headContainsSessionId(path5.join(dir, file), claudeSessionId))
|
|
388
|
+
return path5.join(dir, file);
|
|
159
389
|
}
|
|
160
390
|
return null;
|
|
161
391
|
}
|
|
162
392
|
function headContainsSessionId(filePath, claudeSessionId) {
|
|
163
393
|
let fd;
|
|
164
394
|
try {
|
|
165
|
-
fd =
|
|
395
|
+
fd = fs3.openSync(filePath, "r");
|
|
166
396
|
const buf = Buffer.alloc(16384);
|
|
167
|
-
const bytesRead =
|
|
397
|
+
const bytesRead = fs3.readSync(fd, buf, 0, buf.length, 0);
|
|
168
398
|
return buf.toString("utf8", 0, bytesRead).includes(claudeSessionId);
|
|
169
399
|
} catch {
|
|
170
400
|
return false;
|
|
171
401
|
} finally {
|
|
172
|
-
if (fd !== void 0)
|
|
402
|
+
if (fd !== void 0) fs3.closeSync(fd);
|
|
173
403
|
}
|
|
174
404
|
}
|
|
175
405
|
|
|
406
|
+
// src/shared/harnessAdapters/placeClaudeTranscript.ts
|
|
407
|
+
async function placeClaudeTranscript(conversation, cwd) {
|
|
408
|
+
const dir = projectDirForCwd(cwd);
|
|
409
|
+
const dest = join4(dir, `${conversation.id}.jsonl`);
|
|
410
|
+
await mkdir(dir, { recursive: true });
|
|
411
|
+
await writeFile(dest, conversation.transcript);
|
|
412
|
+
daemonLog(
|
|
413
|
+
`transcript ${conversation.id} placed at ${dest} so ${cwd} can resume it`
|
|
414
|
+
);
|
|
415
|
+
return dest;
|
|
416
|
+
}
|
|
417
|
+
|
|
176
418
|
// src/commands/sessions/daemon/hasTranscriptOnDisk.ts
|
|
177
419
|
function hasTranscriptOnDisk(session) {
|
|
178
420
|
return !!session.cwd && !!session.claudeSessionId && !!findTranscriptPathSync(session.cwd, session.claudeSessionId);
|
|
@@ -202,7 +444,7 @@ function withHarnessPath(env, binDir = harnessBinDir()) {
|
|
|
202
444
|
|
|
203
445
|
// src/shared/nodeRuntime/findEnginesPin.ts
|
|
204
446
|
import { readFileSync } from "fs";
|
|
205
|
-
import { dirname as
|
|
447
|
+
import { dirname as dirname3, join as join5, resolve } from "path";
|
|
206
448
|
function readEngines(file) {
|
|
207
449
|
try {
|
|
208
450
|
const pkg = JSON.parse(readFileSync(file, "utf8"));
|
|
@@ -216,10 +458,10 @@ function findEnginesPin(dir, root) {
|
|
|
216
458
|
const top = resolve(root);
|
|
217
459
|
let current = resolve(dir);
|
|
218
460
|
for (; ; ) {
|
|
219
|
-
const file =
|
|
461
|
+
const file = join5(current, "package.json");
|
|
220
462
|
const spec = readEngines(file);
|
|
221
463
|
if (spec) return { file, spec };
|
|
222
|
-
const parent =
|
|
464
|
+
const parent = dirname3(current);
|
|
223
465
|
if (current === top || parent === current) return void 0;
|
|
224
466
|
current = parent;
|
|
225
467
|
}
|
|
@@ -227,7 +469,7 @@ function findEnginesPin(dir, root) {
|
|
|
227
469
|
|
|
228
470
|
// src/shared/nodeRuntime/findNodePin.ts
|
|
229
471
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
230
|
-
import { dirname as
|
|
472
|
+
import { dirname as dirname4, join as join6, resolve as resolve2 } from "path";
|
|
231
473
|
var PIN_FILES = [".node-version", ".nvmrc"];
|
|
232
474
|
function readPin(file) {
|
|
233
475
|
if (!existsSync2(file)) return void 0;
|
|
@@ -242,11 +484,11 @@ function findNodePin(dir, root) {
|
|
|
242
484
|
let current = resolve2(dir);
|
|
243
485
|
for (; ; ) {
|
|
244
486
|
for (const name of PIN_FILES) {
|
|
245
|
-
const file =
|
|
487
|
+
const file = join6(current, name);
|
|
246
488
|
const spec = readPin(file);
|
|
247
489
|
if (spec) return { file, spec };
|
|
248
490
|
}
|
|
249
|
-
const parent =
|
|
491
|
+
const parent = dirname4(current);
|
|
250
492
|
if (current === top || parent === current) return void 0;
|
|
251
493
|
current = parent;
|
|
252
494
|
}
|
|
@@ -254,12 +496,12 @@ function findNodePin(dir, root) {
|
|
|
254
496
|
|
|
255
497
|
// src/shared/nodeRuntime/findRepoRoot.ts
|
|
256
498
|
import { existsSync as existsSync3 } from "fs";
|
|
257
|
-
import { dirname as
|
|
499
|
+
import { dirname as dirname5, join as join7, resolve as resolve3 } from "path";
|
|
258
500
|
function findRepoRoot(dir) {
|
|
259
501
|
let current = resolve3(dir);
|
|
260
502
|
for (; ; ) {
|
|
261
|
-
if (existsSync3(
|
|
262
|
-
const parent =
|
|
503
|
+
if (existsSync3(join7(current, ".git"))) return current;
|
|
504
|
+
const parent = dirname5(current);
|
|
263
505
|
if (parent === current) return void 0;
|
|
264
506
|
current = parent;
|
|
265
507
|
}
|
|
@@ -302,14 +544,14 @@ function sessionBinDirs(cwd, sessionId, deps = {
|
|
|
302
544
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
303
545
|
import { chmodSync, existsSync as existsSync4, statSync } from "fs";
|
|
304
546
|
import { createRequire } from "module";
|
|
305
|
-
import
|
|
547
|
+
import path6 from "path";
|
|
306
548
|
var require2 = createRequire(import.meta.url);
|
|
307
549
|
var ensured = false;
|
|
308
550
|
function ensureSpawnHelperExecutable() {
|
|
309
551
|
if (ensured || process.platform !== "darwin") return;
|
|
310
552
|
ensured = true;
|
|
311
|
-
const ptyRoot =
|
|
312
|
-
const helper =
|
|
553
|
+
const ptyRoot = path6.join(path6.dirname(require2.resolve("node-pty")), "..");
|
|
554
|
+
const helper = path6.join(
|
|
313
555
|
ptyRoot,
|
|
314
556
|
"prebuilds",
|
|
315
557
|
`${process.platform}-${process.arch}`,
|
|
@@ -390,283 +632,67 @@ function viewerSize() {
|
|
|
390
632
|
remembered ??= readSavedSize();
|
|
391
633
|
return remembered ?? DEFAULT_SIZE;
|
|
392
634
|
}
|
|
393
|
-
function readSavedSize() {
|
|
394
|
-
try {
|
|
395
|
-
const { cols, rows } = JSON.parse(
|
|
396
|
-
readFileSync3(daemonPaths.viewerSize, "utf8")
|
|
397
|
-
);
|
|
398
|
-
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
399
|
-
return { cols, rows };
|
|
400
|
-
} catch {
|
|
401
|
-
}
|
|
402
|
-
return void 0;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// src/commands/sessions/daemon/spawnPty.ts
|
|
406
|
-
var MissingCwdError = class extends Error {
|
|
407
|
-
constructor(cwd) {
|
|
408
|
-
super(`working directory no longer exists: ${cwd}`);
|
|
409
|
-
this.cwd = cwd;
|
|
410
|
-
this.name = "MissingCwdError";
|
|
411
|
-
}
|
|
412
|
-
cwd;
|
|
413
|
-
};
|
|
414
|
-
function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
415
|
-
refuseMissingCwd(cwd, sessionId);
|
|
416
|
-
ensureSpawnHelperExecutable();
|
|
417
|
-
const dir = cwd ?? process.cwd();
|
|
418
|
-
const binDirs = sessionBinDirs(dir, sessionId);
|
|
419
|
-
const command = resolvePtyCommand(args, binDirs);
|
|
420
|
-
return pty.spawn(command.file, command.args, {
|
|
421
|
-
name: "xterm-256color",
|
|
422
|
-
...viewerSize(),
|
|
423
|
-
cwd: dir,
|
|
424
|
-
env: withHarnessPath(
|
|
425
|
-
sessionChildEnv(process.env, sessionId, extraEnv),
|
|
426
|
-
binDirs
|
|
427
|
-
)
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function refuseMissingCwd(cwd, sessionId) {
|
|
431
|
-
if (!cwd || existsSync5(cwd)) return;
|
|
432
|
-
daemonLog(
|
|
433
|
-
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
434
|
-
);
|
|
435
|
-
throw new MissingCwdError(cwd);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// src/commands/sessions/daemon/spawnClaude.ts
|
|
439
|
-
function spawnClaude2(opts2 = {}) {
|
|
440
|
-
return spawnPty(buildArgs2(opts2), opts2.cwd, opts2.sessionId);
|
|
441
|
-
}
|
|
442
|
-
function buildArgs2(opts2) {
|
|
443
|
-
const base = ["claude", "--settings", ensureHooksSettings()];
|
|
444
|
-
if (opts2.appendSystemPromptFile)
|
|
445
|
-
base.push("--append-system-prompt-file", opts2.appendSystemPromptFile);
|
|
446
|
-
if (opts2.auto) base.push("--permission-mode", "auto");
|
|
447
|
-
if (opts2.model) base.push("--model", opts2.model);
|
|
448
|
-
if (opts2.resumeSessionId) {
|
|
449
|
-
return opts2.prompt ? [...base, "--resume", opts2.resumeSessionId, opts2.prompt] : [...base, "--resume", opts2.resumeSessionId];
|
|
450
|
-
}
|
|
451
|
-
if (opts2.claudeSessionId) base.push("--session-id", opts2.claudeSessionId);
|
|
452
|
-
if (opts2.prompt) return [...base, opts2.prompt];
|
|
453
|
-
return base;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
457
|
-
import * as path6 from "path";
|
|
458
|
-
|
|
459
|
-
// src/commands/sessions/shared/parseSessionFile.ts
|
|
460
|
-
import * as fs2 from "fs";
|
|
461
|
-
|
|
462
|
-
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
463
|
-
var KNOWN = [
|
|
464
|
-
"draft",
|
|
465
|
-
"next",
|
|
466
|
-
"bug",
|
|
467
|
-
"refine",
|
|
468
|
-
"review",
|
|
469
|
-
"run",
|
|
470
|
-
"update"
|
|
471
|
-
];
|
|
472
|
-
function deriveHistoryFields(commandName, commandArgs, name) {
|
|
473
|
-
const fields = {};
|
|
474
|
-
const sessionType = deriveSessionType(commandName, name);
|
|
475
|
-
if (sessionType) fields.sessionType = sessionType;
|
|
476
|
-
const itemMatch = commandArgs.match(/^(\d+)\b\s*/);
|
|
477
|
-
if (itemMatch) fields.itemId = Number(itemMatch[1]);
|
|
478
|
-
const prompt = commandArgs.slice(itemMatch?.[0].length ?? 0).trim();
|
|
479
|
-
if (prompt) fields.prompt = prompt;
|
|
480
|
-
return fields;
|
|
481
|
-
}
|
|
482
|
-
function deriveSessionType(commandName, name) {
|
|
483
|
-
if (commandName === "review-pr-comments" || commandName === "fix-conflict")
|
|
484
|
-
return "review";
|
|
485
|
-
if (KNOWN.includes(commandName))
|
|
486
|
-
return commandName;
|
|
487
|
-
if (commandName || name) return "prompt";
|
|
488
|
-
return void 0;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// src/commands/sessions/shared/deriveProject.ts
|
|
492
|
-
import * as path4 from "path";
|
|
493
|
-
function deriveProject(cwd, filePath, origin) {
|
|
494
|
-
if (!cwd) return dirNameToProject(filePath);
|
|
495
|
-
return origin === "windows" ? path4.win32.basename(cwd) : path4.basename(cwd);
|
|
496
|
-
}
|
|
497
|
-
function dirNameToProject(filePath) {
|
|
498
|
-
const dirName = path4.basename(path4.dirname(filePath));
|
|
499
|
-
const parts = dirName.split("--");
|
|
500
|
-
return parts[parts.length - 1].replace(/-/g, "/");
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// src/commands/sessions/shared/backlogRunMarkers.ts
|
|
504
|
-
function backlogRunMarkers(text) {
|
|
505
|
-
const match = text.match(/backlog item a(\d+):[ \t]*([^\n]*)/);
|
|
506
|
-
if (!match) return { commandName: "", commandArgs: "" };
|
|
507
|
-
const title = match[2].trim();
|
|
508
|
-
return {
|
|
509
|
-
commandName: "next",
|
|
510
|
-
commandArgs: title ? `${match[1]} ${title}` : match[1]
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// src/commands/sessions/shared/parseFirstUserEntry.ts
|
|
515
|
-
function parseFirstUserEntry(entry) {
|
|
516
|
-
const raw = messageText(entry);
|
|
517
|
-
const commandName = matchMarker(raw, "command-name").replace(/^\//, "");
|
|
518
|
-
const commandArgs = matchMarker(raw, "command-args");
|
|
519
|
-
const name = stripMarkers(raw);
|
|
520
|
-
if (commandName) return { name, commandName, commandArgs };
|
|
521
|
-
return { name, ...backlogRunMarkers(raw) };
|
|
522
|
-
}
|
|
523
|
-
function messageText(entry) {
|
|
524
|
-
const msg = entry.message;
|
|
525
|
-
const content = msg?.content;
|
|
526
|
-
return typeof content === "string" ? content : Array.isArray(content) ? content.find((c) => c.type === "text")?.text ?? "" : "";
|
|
527
|
-
}
|
|
528
|
-
function matchMarker(text, tag) {
|
|
529
|
-
const match = text.match(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`));
|
|
530
|
-
return match ? match[1].trim() : "";
|
|
531
|
-
}
|
|
532
|
-
function stripMarkers(text) {
|
|
533
|
-
return text.replace(/<command-[^>]*>[^<]*<\/command-[^>]*>/g, "").trim().slice(0, 80);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/commands/sessions/shared/extractSessionMeta.ts
|
|
537
|
-
function extractSessionMeta(lines) {
|
|
538
|
-
let reachedFirstPrompt = false;
|
|
539
|
-
let sessionId = "";
|
|
540
|
-
let cwd = "";
|
|
541
|
-
let timestamp = "";
|
|
542
|
-
let name = "";
|
|
543
|
-
let commandName = "";
|
|
544
|
-
let commandArgs = "";
|
|
545
|
-
for (const line of lines) {
|
|
546
|
-
const entry = safeParse(line);
|
|
547
|
-
if (!entry) continue;
|
|
548
|
-
sessionId ||= strField(entry, "sessionId");
|
|
549
|
-
timestamp ||= strField(entry, "timestamp");
|
|
550
|
-
cwd ||= strField(entry, "cwd");
|
|
551
|
-
if (entry.type === "user" && !entry.isMeta) {
|
|
552
|
-
({ name, commandName, commandArgs } = parseFirstUserEntry(entry));
|
|
553
|
-
reachedFirstPrompt = true;
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return {
|
|
558
|
-
sessionId,
|
|
559
|
-
cwd,
|
|
560
|
-
timestamp,
|
|
561
|
-
name,
|
|
562
|
-
commandName,
|
|
563
|
-
commandArgs,
|
|
564
|
-
reachedFirstPrompt
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
function strField(entry, key) {
|
|
568
|
-
const value = entry[key];
|
|
569
|
-
return typeof value === "string" ? value : "";
|
|
570
|
-
}
|
|
571
|
-
function safeParse(line) {
|
|
572
|
-
try {
|
|
573
|
-
return JSON.parse(line);
|
|
574
|
-
} catch {
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// src/commands/sessions/shared/readSessionMeta.ts
|
|
580
|
-
var GROWING_HEAD_SIZES = [16384, 262144, 2097152];
|
|
581
|
-
async function readSessionMeta(handle) {
|
|
582
|
-
let meta = extractSessionMeta([]);
|
|
583
|
-
for (const size of GROWING_HEAD_SIZES) {
|
|
584
|
-
const buf = Buffer.alloc(size);
|
|
585
|
-
const { bytesRead } = await handle.read(buf, 0, size, 0);
|
|
586
|
-
meta = extractSessionMeta(
|
|
587
|
-
buf.toString("utf8", 0, bytesRead).split("\n").filter(Boolean)
|
|
588
|
-
);
|
|
589
|
-
if (bytesRead < size || meta.reachedFirstPrompt) break;
|
|
590
|
-
}
|
|
591
|
-
return meta;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// src/commands/sessions/shared/parseSessionFile.ts
|
|
595
|
-
async function parseSessionFile(filePath, origin = "wsl") {
|
|
596
|
-
let handle;
|
|
635
|
+
function readSavedSize() {
|
|
597
636
|
try {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
sessionId: meta.sessionId,
|
|
604
|
-
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
605
|
-
project: deriveProject(meta.cwd, filePath, origin),
|
|
606
|
-
cwd: meta.cwd,
|
|
607
|
-
timestamp: meta.timestamp || lastActivity,
|
|
608
|
-
lastActivity,
|
|
609
|
-
origin,
|
|
610
|
-
...deriveHistoryFields(meta.commandName, meta.commandArgs, meta.name)
|
|
611
|
-
};
|
|
637
|
+
const { cols, rows } = JSON.parse(
|
|
638
|
+
readFileSync3(daemonPaths.viewerSize, "utf8")
|
|
639
|
+
);
|
|
640
|
+
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
641
|
+
return { cols, rows };
|
|
612
642
|
} catch {
|
|
613
|
-
return null;
|
|
614
|
-
} finally {
|
|
615
|
-
await handle?.close();
|
|
616
643
|
}
|
|
644
|
+
return void 0;
|
|
617
645
|
}
|
|
618
646
|
|
|
619
|
-
// src/commands/sessions/
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
if (file.endsWith(".jsonl"))
|
|
644
|
-
results.push({ path: path5.join(dirPath, file), origin });
|
|
645
|
-
}
|
|
646
|
-
})
|
|
647
|
-
);
|
|
648
|
-
})
|
|
649
|
-
);
|
|
650
|
-
return results;
|
|
647
|
+
// src/commands/sessions/daemon/spawnPty.ts
|
|
648
|
+
var MissingCwdError = class extends Error {
|
|
649
|
+
constructor(cwd) {
|
|
650
|
+
super(`working directory no longer exists: ${cwd}`);
|
|
651
|
+
this.cwd = cwd;
|
|
652
|
+
this.name = "MissingCwdError";
|
|
653
|
+
}
|
|
654
|
+
cwd;
|
|
655
|
+
};
|
|
656
|
+
function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
657
|
+
refuseMissingCwd(cwd, sessionId);
|
|
658
|
+
ensureSpawnHelperExecutable();
|
|
659
|
+
const dir = cwd ?? process.cwd();
|
|
660
|
+
const binDirs = sessionBinDirs(dir, sessionId);
|
|
661
|
+
const command = resolvePtyCommand(args, binDirs);
|
|
662
|
+
return pty.spawn(command.file, command.args, {
|
|
663
|
+
name: "xterm-256color",
|
|
664
|
+
...viewerSize(),
|
|
665
|
+
cwd: dir,
|
|
666
|
+
env: withHarnessPath(
|
|
667
|
+
sessionChildEnv(process.env, sessionId, extraEnv),
|
|
668
|
+
binDirs
|
|
669
|
+
)
|
|
670
|
+
});
|
|
651
671
|
}
|
|
652
|
-
function
|
|
653
|
-
return
|
|
654
|
-
|
|
655
|
-
|
|
672
|
+
function refuseMissingCwd(cwd, sessionId) {
|
|
673
|
+
if (!cwd || existsSync5(cwd)) return;
|
|
674
|
+
daemonLog(
|
|
675
|
+
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
676
|
+
);
|
|
677
|
+
throw new MissingCwdError(cwd);
|
|
656
678
|
}
|
|
657
679
|
|
|
658
|
-
// src/commands/sessions/
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
);
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
680
|
+
// src/commands/sessions/daemon/spawnClaude.ts
|
|
681
|
+
function spawnClaude2(opts2 = {}) {
|
|
682
|
+
return spawnPty(buildArgs2(opts2), opts2.cwd, opts2.sessionId);
|
|
683
|
+
}
|
|
684
|
+
function buildArgs2(opts2) {
|
|
685
|
+
const base = ["claude", "--settings", ensureHooksSettings()];
|
|
686
|
+
if (opts2.appendSystemPromptFile)
|
|
687
|
+
base.push("--append-system-prompt-file", opts2.appendSystemPromptFile);
|
|
688
|
+
if (opts2.auto) base.push("--permission-mode", "auto");
|
|
689
|
+
if (opts2.model) base.push("--model", opts2.model);
|
|
690
|
+
if (opts2.resumeSessionId) {
|
|
691
|
+
return opts2.prompt ? [...base, "--resume", opts2.resumeSessionId, opts2.prompt] : [...base, "--resume", opts2.resumeSessionId];
|
|
668
692
|
}
|
|
669
|
-
|
|
693
|
+
if (opts2.claudeSessionId) base.push("--session-id", opts2.claudeSessionId);
|
|
694
|
+
if (opts2.prompt) return [...base, opts2.prompt];
|
|
695
|
+
return base;
|
|
670
696
|
}
|
|
671
697
|
|
|
672
698
|
// src/shared/harnessAdapters/buildSlashCommand.ts
|
|
@@ -677,7 +703,7 @@ function buildSlashCommand(slashCommand, description) {
|
|
|
677
703
|
|
|
678
704
|
// src/shared/harnessAdapters/carryTranscriptToTree.ts
|
|
679
705
|
import { copyFileSync, existsSync as existsSync6, mkdirSync as mkdirSync2 } from "fs";
|
|
680
|
-
import { join as
|
|
706
|
+
import { join as join8 } from "path";
|
|
681
707
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
682
708
|
const dir = projectDirForCwd(toCwd);
|
|
683
709
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -686,7 +712,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
686
712
|
);
|
|
687
713
|
return;
|
|
688
714
|
}
|
|
689
|
-
const dest =
|
|
715
|
+
const dest = join8(dir, `${claudeSessionId}.jsonl`);
|
|
690
716
|
if (existsSync6(dest)) {
|
|
691
717
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
692
718
|
return;
|
|
@@ -714,12 +740,12 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
714
740
|
// src/shared/harnessAdapters/claudeConnectorProbe.ts
|
|
715
741
|
import { readFileSync as readFileSync4 } from "fs";
|
|
716
742
|
import { homedir as homedir3 } from "os";
|
|
717
|
-
import { join as
|
|
743
|
+
import { join as join9 } from "path";
|
|
718
744
|
function knownConnectedConnectors() {
|
|
719
745
|
const dir = process.env.CLAUDE_CONFIG_DIR ?? homedir3();
|
|
720
746
|
try {
|
|
721
747
|
const state = JSON.parse(
|
|
722
|
-
readFileSync4(
|
|
748
|
+
readFileSync4(join9(dir, ".claude.json"), "utf8")
|
|
723
749
|
);
|
|
724
750
|
const list = state.claudeAiMcpEverConnected;
|
|
725
751
|
return Array.isArray(list) ? list.filter((name) => typeof name === "string") : void 0;
|
|
@@ -2201,6 +2227,8 @@ var claudeAdapter = {
|
|
|
2201
2227
|
boundId: ({ claudeSessionId }) => claudeSessionId,
|
|
2202
2228
|
toRef: (claudeSessionId, cwd) => ({ cwd, claudeSessionId }),
|
|
2203
2229
|
relocate: carryTranscriptToTree,
|
|
2230
|
+
exportTranscript: exportClaudeTranscript,
|
|
2231
|
+
importTranscript: placeClaudeTranscript,
|
|
2204
2232
|
reader: claudeConversationReader,
|
|
2205
2233
|
interruptedTasks: claudeInterruptedTasks
|
|
2206
2234
|
},
|
|
@@ -2253,6 +2281,131 @@ function sdkUsageSink() {
|
|
|
2253
2281
|
return sink;
|
|
2254
2282
|
}
|
|
2255
2283
|
|
|
2284
|
+
// src/shared/harnessAdapters/exportCodexRollout.ts
|
|
2285
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
2286
|
+
import { relative, sep } from "path";
|
|
2287
|
+
|
|
2288
|
+
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
2289
|
+
import { existsSync as existsSync7 } from "fs";
|
|
2290
|
+
import * as path7 from "path";
|
|
2291
|
+
function codexSessionsDir() {
|
|
2292
|
+
return path7.join(harnesses.codex.homeDir, "sessions");
|
|
2293
|
+
}
|
|
2294
|
+
function hasCodexSessions() {
|
|
2295
|
+
return existsSync7(codexSessionsDir());
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
2299
|
+
import * as path9 from "path";
|
|
2300
|
+
|
|
2301
|
+
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
2302
|
+
import * as fs5 from "fs";
|
|
2303
|
+
import * as path8 from "path";
|
|
2304
|
+
var DATE_DEPTH = 3;
|
|
2305
|
+
function isCodexRolloutFile(name) {
|
|
2306
|
+
return name.startsWith("rollout-") && name.endsWith(".jsonl");
|
|
2307
|
+
}
|
|
2308
|
+
async function discoverCodexRolloutPaths() {
|
|
2309
|
+
if (!hasCodexSessions()) return [];
|
|
2310
|
+
return collect(codexSessionsDir(), DATE_DEPTH);
|
|
2311
|
+
}
|
|
2312
|
+
async function collect(dir, depth) {
|
|
2313
|
+
let entries;
|
|
2314
|
+
try {
|
|
2315
|
+
entries = await fs5.promises.readdir(dir, { withFileTypes: true });
|
|
2316
|
+
} catch {
|
|
2317
|
+
return [];
|
|
2318
|
+
}
|
|
2319
|
+
const nested = await Promise.all(
|
|
2320
|
+
entries.map((entry) => collectEntry(dir, entry, depth))
|
|
2321
|
+
);
|
|
2322
|
+
return nested.flat();
|
|
2323
|
+
}
|
|
2324
|
+
async function collectEntry(dir, entry, depth) {
|
|
2325
|
+
const full = path8.join(dir, entry.name);
|
|
2326
|
+
if (entry.isDirectory()) return depth > 0 ? collect(full, depth - 1) : [];
|
|
2327
|
+
return isCodexRolloutFile(entry.name) ? [full] : [];
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
2331
|
+
async function findCodexRolloutPath(sessionId) {
|
|
2332
|
+
if (!sessionId) return null;
|
|
2333
|
+
const paths = await discoverCodexRolloutPaths();
|
|
2334
|
+
const suffix = `-${sessionId}.jsonl`;
|
|
2335
|
+
return paths.find((file) => path9.basename(file).endsWith(suffix)) ?? null;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
// src/shared/harnessAdapters/exportCodexRollout.ts
|
|
2339
|
+
async function exportCodexRollout(id) {
|
|
2340
|
+
const file = await findCodexRolloutPath(id);
|
|
2341
|
+
if (!file) throw new Error(`no Codex rollout found for ${id}`);
|
|
2342
|
+
return {
|
|
2343
|
+
id,
|
|
2344
|
+
transcript: await readFile2(file, "utf8"),
|
|
2345
|
+
path: relative(codexSessionsDir(), file).split(sep)
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
// src/shared/harnessAdapters/placeCodexRollout.ts
|
|
2350
|
+
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
2351
|
+
import { dirname as dirname6, join as join12 } from "path";
|
|
2352
|
+
|
|
2353
|
+
// src/shared/harnessAdapters/relocateCodexRollout.ts
|
|
2354
|
+
var CWD_ENTRIES = /* @__PURE__ */ new Set(["session_meta", "turn_context"]);
|
|
2355
|
+
function replaceCwd(value, from, to) {
|
|
2356
|
+
if (value === from) return to;
|
|
2357
|
+
if (Array.isArray(value)) return value.map((v) => replaceCwd(v, from, to));
|
|
2358
|
+
if (value && typeof value === "object")
|
|
2359
|
+
return Object.fromEntries(
|
|
2360
|
+
Object.entries(value).map(([k, v]) => [k, replaceCwd(v, from, to)])
|
|
2361
|
+
);
|
|
2362
|
+
return value;
|
|
2363
|
+
}
|
|
2364
|
+
function parse(line) {
|
|
2365
|
+
try {
|
|
2366
|
+
const parsed = JSON.parse(line);
|
|
2367
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
2368
|
+
} catch {
|
|
2369
|
+
return void 0;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
function sourceCwd(lines) {
|
|
2373
|
+
for (const line of lines) {
|
|
2374
|
+
const entry = parse(line);
|
|
2375
|
+
if (entry?.type !== "session_meta") continue;
|
|
2376
|
+
const cwd = entry.payload?.cwd;
|
|
2377
|
+
return typeof cwd === "string" ? cwd : void 0;
|
|
2378
|
+
}
|
|
2379
|
+
return void 0;
|
|
2380
|
+
}
|
|
2381
|
+
function relocateCodexRollout(transcript, toCwd) {
|
|
2382
|
+
const lines = transcript.split("\n");
|
|
2383
|
+
const from = sourceCwd(lines);
|
|
2384
|
+
if (!from || from === toCwd) return transcript;
|
|
2385
|
+
return lines.map((line) => {
|
|
2386
|
+
const entry = parse(line);
|
|
2387
|
+
if (!entry || !CWD_ENTRIES.has(entry.type)) return line;
|
|
2388
|
+
return JSON.stringify({
|
|
2389
|
+
...entry,
|
|
2390
|
+
payload: replaceCwd(entry.payload, from, toCwd)
|
|
2391
|
+
});
|
|
2392
|
+
}).join("\n");
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
// src/shared/harnessAdapters/placeCodexRollout.ts
|
|
2396
|
+
async function placeCodexRollout(conversation, cwd) {
|
|
2397
|
+
const name = conversation.path?.at(-1);
|
|
2398
|
+
if (!name?.startsWith("rollout-") || !name.endsWith(`-${conversation.id}.jsonl`))
|
|
2399
|
+
throw new Error(`no Codex rollout file name for ${conversation.id}`);
|
|
2400
|
+
const dest = join12(codexSessionsDir(), ...conversation.path ?? []);
|
|
2401
|
+
await mkdir2(dirname6(dest), { recursive: true });
|
|
2402
|
+
await writeFile2(dest, relocateCodexRollout(conversation.transcript, cwd));
|
|
2403
|
+
daemonLog(
|
|
2404
|
+
`Codex rollout ${conversation.id} placed at ${dest} so ${cwd} can resume it`
|
|
2405
|
+
);
|
|
2406
|
+
return dest;
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2256
2409
|
// src/shared/resolveCodexModel.ts
|
|
2257
2410
|
var CODEX_DEFAULT_MODEL = "codex-default";
|
|
2258
2411
|
function resolveCodexModel(raw) {
|
|
@@ -2317,9 +2470,9 @@ function codexIsolatedHookArgs() {
|
|
|
2317
2470
|
// src/shared/codexSandboxArgs.ts
|
|
2318
2471
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
2319
2472
|
import { homedir as homedir4 } from "os";
|
|
2320
|
-
import { join as
|
|
2473
|
+
import { join as join13 } from "path";
|
|
2321
2474
|
function codexSandboxArgs() {
|
|
2322
|
-
const assistHome =
|
|
2475
|
+
const assistHome = join13(homedir4(), ".assist");
|
|
2323
2476
|
mkdirSync3(assistHome, { recursive: true });
|
|
2324
2477
|
return [
|
|
2325
2478
|
"-c",
|
|
@@ -2344,22 +2497,22 @@ function codexSessionEnvArgs(env) {
|
|
|
2344
2497
|
}
|
|
2345
2498
|
|
|
2346
2499
|
// src/commands/sessions/daemon/codexDeveloperInstructionsArgs.ts
|
|
2347
|
-
import * as
|
|
2500
|
+
import * as fs6 from "fs";
|
|
2348
2501
|
function codexDeveloperInstructionsArgs(file) {
|
|
2349
2502
|
if (!file) return [];
|
|
2350
|
-
const text = JSON.stringify(
|
|
2503
|
+
const text = JSON.stringify(fs6.readFileSync(file, "utf8"));
|
|
2351
2504
|
return ["-c", `developer_instructions=${text}`];
|
|
2352
2505
|
}
|
|
2353
2506
|
|
|
2354
2507
|
// src/shared/prepareCodexHookTrust.ts
|
|
2355
2508
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
2356
|
-
import * as
|
|
2357
|
-
import * as
|
|
2509
|
+
import * as fs7 from "fs";
|
|
2510
|
+
import * as path10 from "path";
|
|
2358
2511
|
var TIMEOUT_MS = 3e4;
|
|
2359
2512
|
var verified;
|
|
2360
2513
|
function fingerprint(configPath) {
|
|
2361
2514
|
try {
|
|
2362
|
-
const stat =
|
|
2515
|
+
const stat = fs7.statSync(configPath);
|
|
2363
2516
|
return `${stat.mtimeMs}:${stat.size}`;
|
|
2364
2517
|
} catch {
|
|
2365
2518
|
return void 0;
|
|
@@ -2367,7 +2520,7 @@ function fingerprint(configPath) {
|
|
|
2367
2520
|
}
|
|
2368
2521
|
function hasManagedBlock(configPath) {
|
|
2369
2522
|
try {
|
|
2370
|
-
return
|
|
2523
|
+
return fs7.readFileSync(configPath, "utf8").includes(MANAGED_BLOCK_BEGIN);
|
|
2371
2524
|
} catch {
|
|
2372
2525
|
return false;
|
|
2373
2526
|
}
|
|
@@ -2384,7 +2537,7 @@ function runTrust() {
|
|
|
2384
2537
|
});
|
|
2385
2538
|
}
|
|
2386
2539
|
function prepareCodexHookTrust() {
|
|
2387
|
-
const configPath =
|
|
2540
|
+
const configPath = path10.join(harnesses.codex.homeDir, "config.toml");
|
|
2388
2541
|
if (!hasManagedBlock(configPath)) return void 0;
|
|
2389
2542
|
if (verified && verified === fingerprint(configPath)) return void 0;
|
|
2390
2543
|
const result = runTrust();
|
|
@@ -2398,8 +2551,8 @@ function prepareCodexHookTrust() {
|
|
|
2398
2551
|
|
|
2399
2552
|
// src/shared/trustCodexProject.ts
|
|
2400
2553
|
import { execFileSync } from "child_process";
|
|
2401
|
-
import * as
|
|
2402
|
-
import * as
|
|
2554
|
+
import * as fs8 from "fs";
|
|
2555
|
+
import * as path11 from "path";
|
|
2403
2556
|
function repoRoot(cwd) {
|
|
2404
2557
|
try {
|
|
2405
2558
|
const commonDir = execFileSync(
|
|
@@ -2407,7 +2560,7 @@ function repoRoot(cwd) {
|
|
|
2407
2560
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
2408
2561
|
{ cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
|
|
2409
2562
|
).trim();
|
|
2410
|
-
return
|
|
2563
|
+
return path11.dirname(commonDir);
|
|
2411
2564
|
} catch {
|
|
2412
2565
|
return void 0;
|
|
2413
2566
|
}
|
|
@@ -2415,16 +2568,16 @@ function repoRoot(cwd) {
|
|
|
2415
2568
|
function trustCodexProject(cwd) {
|
|
2416
2569
|
const root = repoRoot(cwd ?? process.cwd());
|
|
2417
2570
|
if (!root) return void 0;
|
|
2418
|
-
const configPath =
|
|
2419
|
-
const existing =
|
|
2571
|
+
const configPath = path11.join(harnesses.codex.homeDir, "config.toml");
|
|
2572
|
+
const existing = fs8.existsSync(configPath) ? fs8.readFileSync(configPath, "utf8") : "";
|
|
2420
2573
|
const header = `[projects.${JSON.stringify(root)}]`;
|
|
2421
2574
|
if (existing.includes(header)) return void 0;
|
|
2422
2575
|
const base = existing.replace(/\s*$/, "");
|
|
2423
2576
|
const entry = `${header}
|
|
2424
2577
|
trust_level = "trusted"
|
|
2425
2578
|
`;
|
|
2426
|
-
|
|
2427
|
-
|
|
2579
|
+
fs8.mkdirSync(path11.dirname(configPath), { recursive: true });
|
|
2580
|
+
fs8.writeFileSync(configPath, base ? `${base}
|
|
2428
2581
|
|
|
2429
2582
|
${entry}` : entry);
|
|
2430
2583
|
return root;
|
|
@@ -2468,58 +2621,6 @@ function codexArgs(opts2) {
|
|
|
2468
2621
|
return prompt;
|
|
2469
2622
|
}
|
|
2470
2623
|
|
|
2471
|
-
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
2472
|
-
import * as path11 from "path";
|
|
2473
|
-
|
|
2474
|
-
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
2475
|
-
import * as fs8 from "fs";
|
|
2476
|
-
import * as path10 from "path";
|
|
2477
|
-
|
|
2478
|
-
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
2479
|
-
import { existsSync as existsSync8 } from "fs";
|
|
2480
|
-
import * as path9 from "path";
|
|
2481
|
-
function codexSessionsDir() {
|
|
2482
|
-
return path9.join(harnesses.codex.homeDir, "sessions");
|
|
2483
|
-
}
|
|
2484
|
-
function hasCodexSessions() {
|
|
2485
|
-
return existsSync8(codexSessionsDir());
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
2489
|
-
var DATE_DEPTH = 3;
|
|
2490
|
-
function isCodexRolloutFile(name) {
|
|
2491
|
-
return name.startsWith("rollout-") && name.endsWith(".jsonl");
|
|
2492
|
-
}
|
|
2493
|
-
async function discoverCodexRolloutPaths() {
|
|
2494
|
-
if (!hasCodexSessions()) return [];
|
|
2495
|
-
return collect(codexSessionsDir(), DATE_DEPTH);
|
|
2496
|
-
}
|
|
2497
|
-
async function collect(dir, depth) {
|
|
2498
|
-
let entries;
|
|
2499
|
-
try {
|
|
2500
|
-
entries = await fs8.promises.readdir(dir, { withFileTypes: true });
|
|
2501
|
-
} catch {
|
|
2502
|
-
return [];
|
|
2503
|
-
}
|
|
2504
|
-
const nested = await Promise.all(
|
|
2505
|
-
entries.map((entry) => collectEntry(dir, entry, depth))
|
|
2506
|
-
);
|
|
2507
|
-
return nested.flat();
|
|
2508
|
-
}
|
|
2509
|
-
async function collectEntry(dir, entry, depth) {
|
|
2510
|
-
const full = path10.join(dir, entry.name);
|
|
2511
|
-
if (entry.isDirectory()) return depth > 0 ? collect(full, depth - 1) : [];
|
|
2512
|
-
return isCodexRolloutFile(entry.name) ? [full] : [];
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
|
-
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
2516
|
-
async function findCodexRolloutPath(sessionId) {
|
|
2517
|
-
if (!sessionId) return null;
|
|
2518
|
-
const paths = await discoverCodexRolloutPaths();
|
|
2519
|
-
const suffix = `-${sessionId}.jsonl`;
|
|
2520
|
-
return paths.find((file) => path11.basename(file).endsWith(suffix)) ?? null;
|
|
2521
|
-
}
|
|
2522
|
-
|
|
2523
2624
|
// src/commands/sessions/shared/codex/findCodexRolloutPathSync.ts
|
|
2524
2625
|
import * as fs9 from "fs";
|
|
2525
2626
|
import * as path12 from "path";
|
|
@@ -2668,7 +2769,7 @@ async function touchedSince(file, sinceMs) {
|
|
|
2668
2769
|
}
|
|
2669
2770
|
|
|
2670
2771
|
// src/shared/harnessAdapters/codexConversationReader.ts
|
|
2671
|
-
import { basename as basename4, dirname as
|
|
2772
|
+
import { basename as basename4, dirname as dirname8 } from "path";
|
|
2672
2773
|
|
|
2673
2774
|
// src/commands/sessions/shared/codex/deriveCodexRolloutStatus.ts
|
|
2674
2775
|
var TURN_END_EVENTS = /* @__PURE__ */ new Set(["task_complete", "turn_aborted"]);
|
|
@@ -3534,7 +3635,7 @@ var codexConversationReader = {
|
|
|
3534
3635
|
locate: ({ harnessSessionId }) => harnessSessionId ? findCodexRolloutPathSync(harnessSessionId) : null,
|
|
3535
3636
|
watchTarget: (ref) => {
|
|
3536
3637
|
const path15 = codexConversationReader.locate(ref);
|
|
3537
|
-
return path15 ? { dir:
|
|
3638
|
+
return path15 ? { dir: dirname8(path15), file: basename4(path15) } : null;
|
|
3538
3639
|
},
|
|
3539
3640
|
events: (entries) => entries.flatMap(entryEvents),
|
|
3540
3641
|
lifecycle: (entries) => ({
|
|
@@ -3647,7 +3748,7 @@ function codexSandboxMode(allowEdits) {
|
|
|
3647
3748
|
|
|
3648
3749
|
// src/shared/readCodexRulePerms.ts
|
|
3649
3750
|
import { existsSync as existsSync9, readdirSync as readdirSync3, readFileSync as readFileSync9 } from "fs";
|
|
3650
|
-
import { join as
|
|
3751
|
+
import { join as join18 } from "path";
|
|
3651
3752
|
|
|
3652
3753
|
// src/shared/readPatternList.ts
|
|
3653
3754
|
function readString(text, start) {
|
|
@@ -3727,15 +3828,15 @@ function parseCodexRules(text) {
|
|
|
3727
3828
|
function ruleFiles(dir) {
|
|
3728
3829
|
if (!existsSync9(dir)) return [];
|
|
3729
3830
|
try {
|
|
3730
|
-
return readdirSync3(dir).filter((name) => name.endsWith(".rules")).sort().map((name) =>
|
|
3831
|
+
return readdirSync3(dir).filter((name) => name.endsWith(".rules")).sort().map((name) => join18(dir, name));
|
|
3731
3832
|
} catch {
|
|
3732
3833
|
return [];
|
|
3733
3834
|
}
|
|
3734
3835
|
}
|
|
3735
3836
|
function readCodexRulePerms(key) {
|
|
3736
3837
|
const dirs = [
|
|
3737
|
-
|
|
3738
|
-
|
|
3838
|
+
join18(harnesses.codex.homeDir, "rules"),
|
|
3839
|
+
join18(process.cwd(), ".codex", "rules")
|
|
3739
3840
|
];
|
|
3740
3841
|
return dirs.flatMap(ruleFiles).flatMap((file) => {
|
|
3741
3842
|
try {
|
|
@@ -4014,6 +4115,8 @@ var codexAdapter = {
|
|
|
4014
4115
|
toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId }),
|
|
4015
4116
|
discover: resolveCodexSessionId,
|
|
4016
4117
|
relocate: codexRelocate,
|
|
4118
|
+
exportTranscript: exportCodexRollout,
|
|
4119
|
+
importTranscript: placeCodexRollout,
|
|
4017
4120
|
reader: codexConversationReader
|
|
4018
4121
|
},
|
|
4019
4122
|
toolOperations: codexToolOperations,
|
|
@@ -4489,12 +4592,12 @@ function dedupeProcessEmit(emit) {
|
|
|
4489
4592
|
}
|
|
4490
4593
|
|
|
4491
4594
|
// src/commands/sessions/daemon/sdk/procSampler/readUptimeTicks.ts
|
|
4492
|
-
import { readFile } from "fs/promises";
|
|
4493
|
-
import { join as
|
|
4595
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
4596
|
+
import { join as join20 } from "path";
|
|
4494
4597
|
var CLOCK_TICKS_PER_SECOND = 100;
|
|
4495
4598
|
async function readUptimeTicks(procRoot) {
|
|
4496
4599
|
try {
|
|
4497
|
-
const text = await
|
|
4600
|
+
const text = await readFile3(join20(procRoot, "uptime"), "utf8");
|
|
4498
4601
|
return Math.floor(Number.parseFloat(text) * CLOCK_TICKS_PER_SECOND);
|
|
4499
4602
|
} catch {
|
|
4500
4603
|
return void 0;
|
|
@@ -4502,8 +4605,8 @@ async function readUptimeTicks(procRoot) {
|
|
|
4502
4605
|
}
|
|
4503
4606
|
|
|
4504
4607
|
// src/commands/sessions/daemon/sdk/procSampler/sampleLeafProcess.ts
|
|
4505
|
-
import { readdir, readFile as
|
|
4506
|
-
import { join as
|
|
4608
|
+
import { readdir, readFile as readFile5 } from "fs/promises";
|
|
4609
|
+
import { join as join22 } from "path";
|
|
4507
4610
|
|
|
4508
4611
|
// src/commands/sessions/daemon/sdk/procSampler/findLeafProcess.ts
|
|
4509
4612
|
function outranks(stat, depth, best) {
|
|
@@ -4533,11 +4636,11 @@ function findLeafProcess(stats, rootPid, minStartTicks) {
|
|
|
4533
4636
|
}
|
|
4534
4637
|
|
|
4535
4638
|
// src/commands/sessions/daemon/sdk/procSampler/readProcStat.ts
|
|
4536
|
-
import { readFile as
|
|
4537
|
-
import { join as
|
|
4639
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
4640
|
+
import { join as join21 } from "path";
|
|
4538
4641
|
async function readProcStat(procRoot, pid) {
|
|
4539
4642
|
try {
|
|
4540
|
-
const text = await
|
|
4643
|
+
const text = await readFile4(join21(procRoot, String(pid), "stat"), "utf8");
|
|
4541
4644
|
const fields = text.slice(text.lastIndexOf(")") + 2).split(" ");
|
|
4542
4645
|
return {
|
|
4543
4646
|
pid,
|
|
@@ -4577,7 +4680,7 @@ function trimProcessCommand(argv) {
|
|
|
4577
4680
|
// src/commands/sessions/daemon/sdk/procSampler/sampleLeafProcess.ts
|
|
4578
4681
|
async function readText(path15) {
|
|
4579
4682
|
try {
|
|
4580
|
-
return await
|
|
4683
|
+
return await readFile5(path15, "utf8");
|
|
4581
4684
|
} catch {
|
|
4582
4685
|
return void 0;
|
|
4583
4686
|
}
|
|
@@ -4597,10 +4700,10 @@ async function sampleLeafProcess(procRoot, rootPid, minStartTicks) {
|
|
|
4597
4700
|
minStartTicks
|
|
4598
4701
|
);
|
|
4599
4702
|
if (!leaf) return void 0;
|
|
4600
|
-
const dir =
|
|
4703
|
+
const dir = join22(procRoot, String(leaf.pid));
|
|
4601
4704
|
const [cmdline, io] = await Promise.all([
|
|
4602
|
-
readText(
|
|
4603
|
-
readText(
|
|
4705
|
+
readText(join22(dir, "cmdline")),
|
|
4706
|
+
readText(join22(dir, "io"))
|
|
4604
4707
|
]);
|
|
4605
4708
|
const command = trimProcessCommand(cmdline?.split("\0") ?? []);
|
|
4606
4709
|
if (!command) return void 0;
|
|
@@ -5337,12 +5440,12 @@ function codexSdkConfig(args) {
|
|
|
5337
5440
|
// src/commands/sessions/daemon/sdk/codex/codexSdkExecutable.ts
|
|
5338
5441
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
5339
5442
|
import { homedir as homedir5 } from "os";
|
|
5340
|
-
import { join as
|
|
5443
|
+
import { join as join23 } from "path";
|
|
5341
5444
|
function codexSdkExecutable() {
|
|
5342
5445
|
if (process.platform === "win32") return void 0;
|
|
5343
|
-
const dir =
|
|
5446
|
+
const dir = join23(homedir5(), ".assist", "codex-sdk");
|
|
5344
5447
|
mkdirSync5(dir, { recursive: true });
|
|
5345
|
-
const shim =
|
|
5448
|
+
const shim = join23(dir, "codex");
|
|
5346
5449
|
const args = [harnesses.codex.command, ...codexIsolatedHookArgs()].join(" ");
|
|
5347
5450
|
writeFileSync5(shim, `#!/bin/sh
|
|
5348
5451
|
exec ${args} "$@"
|
|
@@ -5656,7 +5759,10 @@ function harnessAdapter(kind) {
|
|
|
5656
5759
|
}
|
|
5657
5760
|
|
|
5658
5761
|
export {
|
|
5659
|
-
|
|
5762
|
+
deriveHistoryFields,
|
|
5763
|
+
backlogRunMarkers,
|
|
5764
|
+
parseSessionFile,
|
|
5765
|
+
discoverSessionJsonlPaths,
|
|
5660
5766
|
withHarnessPath,
|
|
5661
5767
|
findNodePin,
|
|
5662
5768
|
sessionBinDirs,
|
|
@@ -5667,10 +5773,6 @@ export {
|
|
|
5667
5773
|
viewerSize,
|
|
5668
5774
|
spawnPty,
|
|
5669
5775
|
refuseMissingCwd,
|
|
5670
|
-
deriveHistoryFields,
|
|
5671
|
-
backlogRunMarkers,
|
|
5672
|
-
parseSessionFile,
|
|
5673
|
-
discoverSessionJsonlPaths,
|
|
5674
5776
|
withoutResumeSession,
|
|
5675
5777
|
readTranscriptTail,
|
|
5676
5778
|
readTranscriptTailSync,
|
|
@@ -5688,8 +5790,8 @@ export {
|
|
|
5688
5790
|
quoteForLog,
|
|
5689
5791
|
workflowQueryEnv,
|
|
5690
5792
|
setSdkUsageSink,
|
|
5691
|
-
resolveCodexModel,
|
|
5692
5793
|
discoverCodexRolloutPaths,
|
|
5794
|
+
resolveCodexModel,
|
|
5693
5795
|
parseRolloutEntry,
|
|
5694
5796
|
codexRolloutMeta,
|
|
5695
5797
|
readCodexHeadLines,
|