@staff0rd/assist 0.1060.0 → 0.1060.3
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/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +240 -240
- package/dist/index.js +100 -68
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.1060.
|
|
9
|
+
version: "0.1060.3",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -50481,20 +50481,13 @@ function serverRunMeta(runName, cwd) {
|
|
|
50481
50481
|
};
|
|
50482
50482
|
}
|
|
50483
50483
|
|
|
50484
|
-
// src/commands/sessions/daemon/
|
|
50485
|
-
import * as fs53 from "fs";
|
|
50484
|
+
// src/commands/sessions/daemon/designSystemPromptPath.ts
|
|
50486
50485
|
import * as path107 from "path";
|
|
50487
50486
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
50488
50487
|
var __filename5 = fileURLToPath10(import.meta.url);
|
|
50489
50488
|
var __dirname6 = path107.dirname(__filename5);
|
|
50490
|
-
function
|
|
50491
|
-
|
|
50492
|
-
__dirname6,
|
|
50493
|
-
"..",
|
|
50494
|
-
"claude",
|
|
50495
|
-
"design-system-prompt.md"
|
|
50496
|
-
);
|
|
50497
|
-
return fs53.readFileSync(promptPath, "utf8");
|
|
50489
|
+
function designSystemPromptPath() {
|
|
50490
|
+
return path107.join(__dirname6, "..", "claude", "design-system-prompt.md");
|
|
50498
50491
|
}
|
|
50499
50492
|
|
|
50500
50493
|
// src/commands/sessions/daemon/spawnClaude.ts
|
|
@@ -50504,7 +50497,7 @@ function spawnClaude2(opts = {}) {
|
|
|
50504
50497
|
function buildArgs3(opts) {
|
|
50505
50498
|
const base = ["claude", "--settings", ensureHooksSettings()];
|
|
50506
50499
|
if (opts.design) {
|
|
50507
|
-
base.push("--append-system-prompt",
|
|
50500
|
+
base.push("--append-system-prompt-file", designSystemPromptPath());
|
|
50508
50501
|
base.push("--permission-mode", "auto");
|
|
50509
50502
|
} else if (opts.auto) {
|
|
50510
50503
|
base.push("--permission-mode", "auto");
|
|
@@ -50714,14 +50707,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
50714
50707
|
}
|
|
50715
50708
|
|
|
50716
50709
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
50717
|
-
import { readFileSync as
|
|
50710
|
+
import { readFileSync as readFileSync75, writeFileSync as writeFileSync60 } from "fs";
|
|
50718
50711
|
var KEEP_TAIL = 256 * 1024;
|
|
50719
50712
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
50720
50713
|
function trimWatcherLog(cwd) {
|
|
50721
50714
|
const path109 = watcherLogPath(cwd);
|
|
50722
50715
|
let log2;
|
|
50723
50716
|
try {
|
|
50724
|
-
log2 =
|
|
50717
|
+
log2 = readFileSync75(path109, "utf8");
|
|
50725
50718
|
} catch {
|
|
50726
50719
|
return;
|
|
50727
50720
|
}
|
|
@@ -50809,7 +50802,16 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
50809
50802
|
}
|
|
50810
50803
|
|
|
50811
50804
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
50805
|
+
import { existsSync as existsSync97 } from "fs";
|
|
50806
|
+
|
|
50807
|
+
// src/commands/sessions/daemon/worktree/holdsNoCheckout.ts
|
|
50812
50808
|
import { existsSync as existsSync96 } from "fs";
|
|
50809
|
+
import { join as join113 } from "path";
|
|
50810
|
+
function holdsNoCheckout(path109) {
|
|
50811
|
+
return existsSync96(path109) && !existsSync96(join113(path109, ".git"));
|
|
50812
|
+
}
|
|
50813
|
+
|
|
50814
|
+
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
50813
50815
|
var treeIsGone = { durable: true, gone: true };
|
|
50814
50816
|
function treeDurability(state) {
|
|
50815
50817
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -50817,8 +50819,9 @@ function treeDurability(state) {
|
|
|
50817
50819
|
return { durable: false, reason: "unpushed commits" };
|
|
50818
50820
|
return { durable: true };
|
|
50819
50821
|
}
|
|
50820
|
-
function* durabilityProbes() {
|
|
50822
|
+
function* durabilityProbes(cwd) {
|
|
50821
50823
|
const status2 = yield ["status", "--porcelain"];
|
|
50824
|
+
if (!status2.ok && notACheckout(cwd, status2.error)) return treeIsGone;
|
|
50822
50825
|
if (!status2.ok)
|
|
50823
50826
|
return { durable: false, reason: `tree state unreadable: ${status2.error}` };
|
|
50824
50827
|
const dirty = status2.out !== "";
|
|
@@ -50839,16 +50842,19 @@ function* durabilityProbes() {
|
|
|
50839
50842
|
localOnlyCommits: !remoteBranches.ok || remoteBranches.out === ""
|
|
50840
50843
|
});
|
|
50841
50844
|
}
|
|
50845
|
+
function notACheckout(cwd, error) {
|
|
50846
|
+
return holdsNoCheckout(cwd) && /not a git repository/i.test(error);
|
|
50847
|
+
}
|
|
50842
50848
|
async function checkDurability(cwd) {
|
|
50843
|
-
if (!
|
|
50844
|
-
const probes = durabilityProbes();
|
|
50849
|
+
if (!existsSync97(cwd)) return treeIsGone;
|
|
50850
|
+
const probes = durabilityProbes(cwd);
|
|
50845
50851
|
let step3 = probes.next();
|
|
50846
50852
|
while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
|
|
50847
50853
|
return step3.value;
|
|
50848
50854
|
}
|
|
50849
50855
|
function checkDurabilitySync(cwd) {
|
|
50850
|
-
if (!
|
|
50851
|
-
const probes = durabilityProbes();
|
|
50856
|
+
if (!existsSync97(cwd)) return treeIsGone;
|
|
50857
|
+
const probes = durabilityProbes(cwd);
|
|
50852
50858
|
let step3 = probes.next();
|
|
50853
50859
|
while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
|
|
50854
50860
|
return step3.value;
|
|
@@ -50880,7 +50886,7 @@ function releaseReason(durability, session) {
|
|
|
50880
50886
|
if (!durability.durable)
|
|
50881
50887
|
return `still held by finished session ${session.id}: ${durability.reason}`;
|
|
50882
50888
|
if (durability.gone)
|
|
50883
|
-
return `free for allocation: session ${session.id}'s directory is gone from disk \u2014 nothing to land, not landed work`;
|
|
50889
|
+
return `free for allocation: session ${session.id}'s directory is gone from disk or holds no git checkout \u2014 nothing to land, not landed work`;
|
|
50884
50890
|
return `free for allocation: session ${session.id} finished and its work is landed`;
|
|
50885
50891
|
}
|
|
50886
50892
|
|
|
@@ -51131,17 +51137,17 @@ function setStatus2(session, newStatus) {
|
|
|
51131
51137
|
}
|
|
51132
51138
|
|
|
51133
51139
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
51134
|
-
import { existsSync as
|
|
51140
|
+
import { existsSync as existsSync99 } from "fs";
|
|
51135
51141
|
import { basename as basename32 } from "path";
|
|
51136
51142
|
|
|
51137
51143
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
51138
|
-
import { existsSync as
|
|
51139
|
-
import { join as
|
|
51144
|
+
import { existsSync as existsSync98 } from "fs";
|
|
51145
|
+
import { join as join115 } from "path";
|
|
51140
51146
|
|
|
51141
51147
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
51142
51148
|
import { statSync as statSync16 } from "fs";
|
|
51143
51149
|
import { rm as rm3 } from "fs/promises";
|
|
51144
|
-
import { join as
|
|
51150
|
+
import { join as join114 } from "path";
|
|
51145
51151
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
51146
51152
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
51147
51153
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -51159,17 +51165,18 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
51159
51165
|
retryDelay: 200
|
|
51160
51166
|
});
|
|
51161
51167
|
} catch (error) {
|
|
51168
|
+
const failure = deleteFailure(worktreePath, error);
|
|
51162
51169
|
daemonLog(
|
|
51163
|
-
`worktree ${worktreePath} directory delete failed, left in place for the next reconcile: ${
|
|
51170
|
+
`worktree ${worktreePath} directory delete failed, left in place for the next reconcile: ${failure}`
|
|
51164
51171
|
);
|
|
51165
|
-
return { removed: false, reason:
|
|
51172
|
+
return { removed: false, reason: failure };
|
|
51166
51173
|
}
|
|
51167
51174
|
daemonLog(`worktree ${worktreePath} directory deleted directly`);
|
|
51168
51175
|
await pruneBookkeeping(clone, worktreePath);
|
|
51169
51176
|
return { removed: true };
|
|
51170
51177
|
}
|
|
51171
51178
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
51172
|
-
return statSync16(
|
|
51179
|
+
return statSync16(join114(worktreePath, ".git"), {
|
|
51173
51180
|
throwIfNoEntry: false
|
|
51174
51181
|
})?.isDirectory() === true;
|
|
51175
51182
|
}
|
|
@@ -51185,6 +51192,11 @@ async function pruneBookkeeping(clone, worktreePath) {
|
|
|
51185
51192
|
);
|
|
51186
51193
|
}
|
|
51187
51194
|
}
|
|
51195
|
+
function deleteFailure(worktreePath, error) {
|
|
51196
|
+
const code = error?.code;
|
|
51197
|
+
if (code !== "EACCES" && code !== "EPERM") return reason(error);
|
|
51198
|
+
return `${worktreePath} holds files owned by another user (e.g. root, from a Docker bind mount) that assist cannot delete; remove it with \`sudo rm -rf ${worktreePath}\` (${reason(error)})`;
|
|
51199
|
+
}
|
|
51188
51200
|
function reason(error) {
|
|
51189
51201
|
return error instanceof Error ? error.message : String(error);
|
|
51190
51202
|
}
|
|
@@ -51205,7 +51217,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
51205
51217
|
);
|
|
51206
51218
|
}
|
|
51207
51219
|
function strandedReason(worktreePath, cause) {
|
|
51208
|
-
if (!
|
|
51220
|
+
if (!existsSync98(join115(worktreePath, ".git")))
|
|
51209
51221
|
return "its .git link is already gone";
|
|
51210
51222
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
51211
51223
|
return "git no longer recognises it as a working tree";
|
|
@@ -51257,7 +51269,7 @@ function reason3(error) {
|
|
|
51257
51269
|
|
|
51258
51270
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
51259
51271
|
async function reapWorktree(worktreePath, force = false) {
|
|
51260
|
-
if (!
|
|
51272
|
+
if (!existsSync99(worktreePath)) {
|
|
51261
51273
|
forgetWorktree(worktreePath);
|
|
51262
51274
|
daemonLog(
|
|
51263
51275
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -51282,7 +51294,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
51282
51294
|
}
|
|
51283
51295
|
function owningClone(worktreePath) {
|
|
51284
51296
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
51285
|
-
if (recorded &&
|
|
51297
|
+
if (recorded && existsSync99(recorded)) return recorded;
|
|
51286
51298
|
const detected = mainWorktree(worktreePath);
|
|
51287
51299
|
if (detected) return detected;
|
|
51288
51300
|
daemonLog(
|
|
@@ -51309,7 +51321,9 @@ async function discardTree(session, discarded, notify2) {
|
|
|
51309
51321
|
if (session.worktree) {
|
|
51310
51322
|
const removal = await reapWorktree(session.worktree.path, true);
|
|
51311
51323
|
if (!removal.removed) {
|
|
51312
|
-
|
|
51324
|
+
if (holdsNoCheckout(session.worktree.path))
|
|
51325
|
+
releaseUndeletableLeftover(session, removal.reason, notify2);
|
|
51326
|
+
else holdFailedDiscard(session, removal.reason, notify2);
|
|
51313
51327
|
return;
|
|
51314
51328
|
}
|
|
51315
51329
|
session.releasedFromClone = session.worktree.clone;
|
|
@@ -51329,6 +51343,24 @@ function holdFailedDiscard(session, reason4, notify2) {
|
|
|
51329
51343
|
setStatus2(session, "stopped");
|
|
51330
51344
|
notify2();
|
|
51331
51345
|
}
|
|
51346
|
+
function releaseUndeletableLeftover(session, reason4, notify2) {
|
|
51347
|
+
const path109 = session.worktree?.path;
|
|
51348
|
+
daemonLog(
|
|
51349
|
+
`session ${session.id} discard could not delete ${path109}, which holds no git checkout and so no work: ${reason4}; card released to error so it can be dismissed`
|
|
51350
|
+
);
|
|
51351
|
+
const message3 = `Discard could not delete ${path109}: ${reason4}`;
|
|
51352
|
+
if (session.worktree) session.releasedFromClone = session.worktree.clone;
|
|
51353
|
+
session.worktree = void 0;
|
|
51354
|
+
session.closing = void 0;
|
|
51355
|
+
session.undurable = void 0;
|
|
51356
|
+
session.error = message3;
|
|
51357
|
+
session.subtitle = message3;
|
|
51358
|
+
session.scrollback += `\r
|
|
51359
|
+
\x1B[31m${message3}\x1B[0m\r
|
|
51360
|
+
`;
|
|
51361
|
+
setStatus2(session, "error");
|
|
51362
|
+
notify2();
|
|
51363
|
+
}
|
|
51332
51364
|
|
|
51333
51365
|
// src/commands/sessions/daemon/killPtyTree.ts
|
|
51334
51366
|
function killPtyTree(pty2) {
|
|
@@ -51505,7 +51537,7 @@ function pidList(pids) {
|
|
|
51505
51537
|
}
|
|
51506
51538
|
|
|
51507
51539
|
// src/commands/sessions/daemon/worktree/readOccupant.ts
|
|
51508
|
-
import { readFileSync as
|
|
51540
|
+
import { readFileSync as readFileSync76 } from "fs";
|
|
51509
51541
|
var VSCODE_PATHS = [
|
|
51510
51542
|
"/.vscode-server/",
|
|
51511
51543
|
"/.vscode-server-insiders/",
|
|
@@ -51540,7 +51572,7 @@ function parentPid(stat5) {
|
|
|
51540
51572
|
}
|
|
51541
51573
|
function readProc(procRoot, pid, file) {
|
|
51542
51574
|
try {
|
|
51543
|
-
return
|
|
51575
|
+
return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
|
|
51544
51576
|
} catch {
|
|
51545
51577
|
return void 0;
|
|
51546
51578
|
}
|
|
@@ -51560,7 +51592,7 @@ async function closeBlockReason(sessionId2, tree) {
|
|
|
51560
51592
|
if (!durability.durable) return { reason: durability.reason, live: false };
|
|
51561
51593
|
if (durability.gone) {
|
|
51562
51594
|
daemonLog(
|
|
51563
|
-
`session ${sessionId2} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
|
|
51595
|
+
`session ${sessionId2} closing: worktree ${tree.path} is gone from disk or holds no git checkout \u2014 released with nothing to land, not landed work`
|
|
51564
51596
|
);
|
|
51565
51597
|
return void 0;
|
|
51566
51598
|
}
|
|
@@ -51569,12 +51601,12 @@ async function closeBlockReason(sessionId2, tree) {
|
|
|
51569
51601
|
}
|
|
51570
51602
|
|
|
51571
51603
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
51572
|
-
import { existsSync as
|
|
51604
|
+
import { existsSync as existsSync100, watch } from "fs";
|
|
51573
51605
|
var DEBOUNCE_MS = 500;
|
|
51574
51606
|
var POLL_MS5 = 3e4;
|
|
51575
51607
|
function watchGitState(cwd, onChange) {
|
|
51576
51608
|
const common = gitCommonDir(cwd);
|
|
51577
|
-
if (!common || !
|
|
51609
|
+
if (!common || !existsSync100(common)) return void 0;
|
|
51578
51610
|
const watchers = [
|
|
51579
51611
|
watchGitDir(common, onChange),
|
|
51580
51612
|
pollGitState(cwd, onChange)
|
|
@@ -52297,10 +52329,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
52297
52329
|
}
|
|
52298
52330
|
|
|
52299
52331
|
// src/commands/sessions/daemon/exitReason.ts
|
|
52300
|
-
import { existsSync as
|
|
52332
|
+
import { existsSync as existsSync101 } from "fs";
|
|
52301
52333
|
import { resolve as resolve33 } from "path";
|
|
52302
52334
|
function exitDetail(session) {
|
|
52303
|
-
if (session.cwd && !
|
|
52335
|
+
if (session.cwd && !existsSync101(session.cwd))
|
|
52304
52336
|
return `working directory ${session.cwd} no longer exists`;
|
|
52305
52337
|
return missingRunConfigCwd(session);
|
|
52306
52338
|
}
|
|
@@ -52314,7 +52346,7 @@ function missingRunConfigCwd(session) {
|
|
|
52314
52346
|
const config = resolveRunConfig(session.runName, dir);
|
|
52315
52347
|
if (!config?.cwd) return void 0;
|
|
52316
52348
|
const configured = resolve33(runConfigBaseDirFrom(dir), config.cwd);
|
|
52317
|
-
if (
|
|
52349
|
+
if (existsSync101(configured)) return void 0;
|
|
52318
52350
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
52319
52351
|
}
|
|
52320
52352
|
|
|
@@ -52362,7 +52394,7 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
52362
52394
|
}
|
|
52363
52395
|
|
|
52364
52396
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
52365
|
-
import { existsSync as
|
|
52397
|
+
import { existsSync as existsSync102, mkdirSync as mkdirSync41, watch as watch2 } from "fs";
|
|
52366
52398
|
import { dirname as dirname50 } from "path";
|
|
52367
52399
|
|
|
52368
52400
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -52447,7 +52479,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
52447
52479
|
if (timer) clearTimeout(timer);
|
|
52448
52480
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
52449
52481
|
});
|
|
52450
|
-
if (
|
|
52482
|
+
if (existsSync102(path109)) read3();
|
|
52451
52483
|
}
|
|
52452
52484
|
function refreshActivity(session) {
|
|
52453
52485
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -52527,7 +52559,7 @@ function reportSilentFailure(session, clients) {
|
|
|
52527
52559
|
}
|
|
52528
52560
|
|
|
52529
52561
|
// src/commands/sessions/shared/codex/resolveCodexSessionId.ts
|
|
52530
|
-
import * as
|
|
52562
|
+
import * as fs53 from "fs";
|
|
52531
52563
|
var META_LINES = 5;
|
|
52532
52564
|
async function resolveCodexSessionId(cwd, sinceMs) {
|
|
52533
52565
|
if (!cwd) return null;
|
|
@@ -52556,7 +52588,7 @@ async function startedIn(file, cwd, sinceMs) {
|
|
|
52556
52588
|
}
|
|
52557
52589
|
async function touchedSince(file, sinceMs) {
|
|
52558
52590
|
try {
|
|
52559
|
-
return (await
|
|
52591
|
+
return (await fs53.promises.stat(file)).mtimeMs >= sinceMs;
|
|
52560
52592
|
} catch {
|
|
52561
52593
|
return false;
|
|
52562
52594
|
}
|
|
@@ -53114,7 +53146,7 @@ function makeSessionSpawner(sessions, clients, counter, onStatusChange, notify2)
|
|
|
53114
53146
|
}
|
|
53115
53147
|
|
|
53116
53148
|
// src/commands/sessions/shared/transcriptUsage.ts
|
|
53117
|
-
import * as
|
|
53149
|
+
import * as fs54 from "fs";
|
|
53118
53150
|
function transcriptUsage(lines2) {
|
|
53119
53151
|
const byId = /* @__PURE__ */ new Map();
|
|
53120
53152
|
for (const line of lines2) {
|
|
@@ -53138,7 +53170,7 @@ function transcriptUsage(lines2) {
|
|
|
53138
53170
|
return [...byId.values()];
|
|
53139
53171
|
}
|
|
53140
53172
|
async function readTranscriptUsage(transcriptPath2) {
|
|
53141
|
-
const content = await
|
|
53173
|
+
const content = await fs54.promises.readFile(transcriptPath2, "utf8");
|
|
53142
53174
|
return transcriptUsage(content.split("\n"));
|
|
53143
53175
|
}
|
|
53144
53176
|
|
|
@@ -54725,7 +54757,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
54725
54757
|
}
|
|
54726
54758
|
|
|
54727
54759
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
54728
|
-
import { existsSync as
|
|
54760
|
+
import { existsSync as existsSync104 } from "fs";
|
|
54729
54761
|
import { basename as basename35 } from "path";
|
|
54730
54762
|
|
|
54731
54763
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -54746,9 +54778,9 @@ function accountedTrees(sessions) {
|
|
|
54746
54778
|
}
|
|
54747
54779
|
|
|
54748
54780
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
54749
|
-
import { existsSync as
|
|
54781
|
+
import { existsSync as existsSync103 } from "fs";
|
|
54750
54782
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
54751
|
-
if (!
|
|
54783
|
+
if (!existsSync103(clone)) {
|
|
54752
54784
|
for (const { path: path109 } of paths) forgetWorktree(path109);
|
|
54753
54785
|
daemonLog(
|
|
54754
54786
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -54914,7 +54946,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
54914
54946
|
);
|
|
54915
54947
|
continue;
|
|
54916
54948
|
}
|
|
54917
|
-
if (!
|
|
54949
|
+
if (!existsSync104(path109)) {
|
|
54918
54950
|
logVanishedTree(sessions, path109);
|
|
54919
54951
|
vanished.set(clone, [
|
|
54920
54952
|
...vanished.get(clone) ?? [],
|
|
@@ -56114,7 +56146,7 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
|
56114
56146
|
}
|
|
56115
56147
|
|
|
56116
56148
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
56117
|
-
import { existsSync as
|
|
56149
|
+
import { existsSync as existsSync107 } from "fs";
|
|
56118
56150
|
|
|
56119
56151
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
56120
56152
|
function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
|
|
@@ -56145,11 +56177,11 @@ function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
|
|
|
56145
56177
|
}
|
|
56146
56178
|
|
|
56147
56179
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
56148
|
-
import { existsSync as
|
|
56180
|
+
import { existsSync as existsSync106 } from "fs";
|
|
56149
56181
|
|
|
56150
56182
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
56151
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
56152
|
-
import { join as
|
|
56183
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync105, mkdirSync as mkdirSync43 } from "fs";
|
|
56184
|
+
import { join as join116 } from "path";
|
|
56153
56185
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
56154
56186
|
const dir = projectDirForCwd(toCwd);
|
|
56155
56187
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -56158,8 +56190,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
56158
56190
|
);
|
|
56159
56191
|
return;
|
|
56160
56192
|
}
|
|
56161
|
-
const dest =
|
|
56162
|
-
if (
|
|
56193
|
+
const dest = join116(dir, `${claudeSessionId}.jsonl`);
|
|
56194
|
+
if (existsSync105(dest)) {
|
|
56163
56195
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
56164
56196
|
return;
|
|
56165
56197
|
}
|
|
@@ -56210,7 +56242,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
56210
56242
|
}
|
|
56211
56243
|
function cloneForReapedTree(missingCwd) {
|
|
56212
56244
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
56213
|
-
if (!clone || !
|
|
56245
|
+
if (!clone || !existsSync106(clone))
|
|
56214
56246
|
throw new Error(
|
|
56215
56247
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
56216
56248
|
);
|
|
@@ -56219,7 +56251,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
56219
56251
|
|
|
56220
56252
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
56221
56253
|
function resumeInTree(ctx, sessionId2, cwd, name, harness) {
|
|
56222
|
-
if (!
|
|
56254
|
+
if (!existsSync107(cwd))
|
|
56223
56255
|
return resumeInReplacementTree(ctx, sessionId2, cwd, name, harness);
|
|
56224
56256
|
const id = ctx.spawnWith(
|
|
56225
56257
|
(sid) => resumeSession(sid, sessionId2, cwd, name, void 0, harness)
|
|
@@ -56549,7 +56581,7 @@ var handleHelloRequest = (client, m, d) => {
|
|
|
56549
56581
|
};
|
|
56550
56582
|
|
|
56551
56583
|
// src/commands/sessions/daemon/historySearch/findTranscriptMatch.ts
|
|
56552
|
-
import * as
|
|
56584
|
+
import * as fs55 from "fs";
|
|
56553
56585
|
import * as readline5 from "readline";
|
|
56554
56586
|
|
|
56555
56587
|
// src/commands/sessions/daemon/historySearch/historySnippet.ts
|
|
@@ -56670,7 +56702,7 @@ function queryPattern(query) {
|
|
|
56670
56702
|
async function findTranscriptMatch(filePath, harness, query) {
|
|
56671
56703
|
const pattern2 = queryPattern(query);
|
|
56672
56704
|
const mayMatch = rawLinePrefilter(query);
|
|
56673
|
-
const stream =
|
|
56705
|
+
const stream = fs55.createReadStream(filePath, { encoding: "utf8" });
|
|
56674
56706
|
const reader = readline5.createInterface({
|
|
56675
56707
|
input: stream,
|
|
56676
56708
|
crlfDelay: Infinity
|
|
@@ -56768,7 +56800,7 @@ function creator(isNew, spawn13) {
|
|
|
56768
56800
|
}
|
|
56769
56801
|
|
|
56770
56802
|
// src/commands/sessions/shared/codex/codexRolloutUsage.ts
|
|
56771
|
-
import * as
|
|
56803
|
+
import * as fs56 from "fs";
|
|
56772
56804
|
|
|
56773
56805
|
// src/commands/sessions/shared/codex/applyTokenInfo.ts
|
|
56774
56806
|
function applyTokenInfo(usage, byId, conversationId, rawInfo) {
|
|
@@ -56831,7 +56863,7 @@ function codexRolloutUsage(lines2) {
|
|
|
56831
56863
|
return usage;
|
|
56832
56864
|
}
|
|
56833
56865
|
async function readCodexRolloutUsage(rolloutPath) {
|
|
56834
|
-
const content = await
|
|
56866
|
+
const content = await fs56.promises.readFile(rolloutPath, "utf8");
|
|
56835
56867
|
return codexRolloutUsage(content.split("\n"));
|
|
56836
56868
|
}
|
|
56837
56869
|
function sessionMetaId(entry) {
|
|
@@ -57048,7 +57080,7 @@ var inboxHandlers = {
|
|
|
57048
57080
|
};
|
|
57049
57081
|
|
|
57050
57082
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
57051
|
-
import * as
|
|
57083
|
+
import * as fs57 from "fs";
|
|
57052
57084
|
|
|
57053
57085
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
57054
57086
|
import * as path108 from "path";
|
|
@@ -57069,7 +57101,7 @@ async function parseTranscript(sessionId2) {
|
|
|
57069
57101
|
}
|
|
57070
57102
|
async function readMessages(filePath, parse5) {
|
|
57071
57103
|
try {
|
|
57072
|
-
const raw = await
|
|
57104
|
+
const raw = await fs57.promises.readFile(filePath, "utf8");
|
|
57073
57105
|
return parse5(raw.split("\n"));
|
|
57074
57106
|
} catch {
|
|
57075
57107
|
return [];
|
|
@@ -57488,7 +57520,7 @@ function isPrCheckoutArgs(args) {
|
|
|
57488
57520
|
|
|
57489
57521
|
// src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
|
|
57490
57522
|
import { execFile as execFile14 } from "child_process";
|
|
57491
|
-
import { existsSync as
|
|
57523
|
+
import { existsSync as existsSync108 } from "fs";
|
|
57492
57524
|
function prHeadBranch2(number, cwd) {
|
|
57493
57525
|
const { headBranch } = prCliCommands(number, cwd);
|
|
57494
57526
|
return new Promise((resolve34) => {
|
|
@@ -57502,12 +57534,12 @@ function prHeadBranch2(number, cwd) {
|
|
|
57502
57534
|
}
|
|
57503
57535
|
async function prCheckoutHolder(assistArgs, cwd) {
|
|
57504
57536
|
const number = prCheckoutNumber(assistArgs);
|
|
57505
|
-
if (!number || !cwd || !
|
|
57537
|
+
if (!number || !cwd || !existsSync108(cwd)) return void 0;
|
|
57506
57538
|
const headRef = await prHeadBranch2(number, cwd);
|
|
57507
57539
|
if (!headRef) return void 0;
|
|
57508
57540
|
const listing = await gitOrNull(cwd, ["worktree", "list", "--porcelain"]);
|
|
57509
57541
|
const holder = listing ? worktreeWithBranch(listing, headRef) : null;
|
|
57510
|
-
if (!holder || !
|
|
57542
|
+
if (!holder || !existsSync108(holder)) return void 0;
|
|
57511
57543
|
daemonLog(
|
|
57512
57544
|
`pr #${number} assist ${assistArgs[0]} launched in its checkout ${holder}: head branch ${headRef} is already checked out there, so no worktree is allocated`
|
|
57513
57545
|
);
|
|
@@ -57727,7 +57759,7 @@ function handleConnection(socket, manager) {
|
|
|
57727
57759
|
import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync62 } from "fs";
|
|
57728
57760
|
|
|
57729
57761
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
57730
|
-
import { readFileSync as
|
|
57762
|
+
import { readFileSync as readFileSync77 } from "fs";
|
|
57731
57763
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
57732
57764
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
57733
57765
|
const timer = setInterval(() => {
|
|
@@ -57738,7 +57770,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
57738
57770
|
}
|
|
57739
57771
|
function ownsPidFile() {
|
|
57740
57772
|
try {
|
|
57741
|
-
return
|
|
57773
|
+
return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
57742
57774
|
} catch {
|
|
57743
57775
|
return false;
|
|
57744
57776
|
}
|