@staff0rd/assist 0.490.1 → 0.490.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/commands/sessions/web/bundle.js +223 -223
- package/dist/index.js +90 -67
- 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.490.
|
|
9
|
+
version: "0.490.3",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -28936,38 +28936,22 @@ function createRunSession(id, runName, runArgs, cwd, meta = serverRunMeta(runNam
|
|
|
28936
28936
|
};
|
|
28937
28937
|
}
|
|
28938
28938
|
|
|
28939
|
-
// src/commands/sessions/daemon/
|
|
28940
|
-
function
|
|
28941
|
-
|
|
28942
|
-
|
|
28943
|
-
|
|
28939
|
+
// src/commands/sessions/daemon/setStatus.ts
|
|
28940
|
+
function setStatus2(session, newStatus) {
|
|
28941
|
+
const now = Date.now();
|
|
28942
|
+
if (session.status === "running" && session.runningSince != null) {
|
|
28943
|
+
session.runningMs += now - session.runningSince;
|
|
28944
28944
|
}
|
|
28945
|
-
|
|
28946
|
-
|
|
28947
|
-
|
|
28948
|
-
|
|
28949
|
-
|
|
28950
|
-
|
|
28951
|
-
|
|
28945
|
+
session.runningSince = newStatus === "running" ? now : null;
|
|
28946
|
+
session.waitingSince = newStatus === "waiting" ? now : null;
|
|
28947
|
+
session.status = newStatus;
|
|
28948
|
+
if (newStatus === "waiting") {
|
|
28949
|
+
daemonLog(
|
|
28950
|
+
`session ${session.id} waiting since ${new Date(now).toISOString()}`
|
|
28951
|
+
);
|
|
28952
28952
|
}
|
|
28953
28953
|
}
|
|
28954
28954
|
|
|
28955
|
-
// src/commands/sessions/daemon/worktree/treeUnderClose.ts
|
|
28956
|
-
function treeUnderClose(session) {
|
|
28957
|
-
if (session.worktree) return { path: session.worktree.path, removable: true };
|
|
28958
|
-
if (session.cwd) return { path: session.cwd, removable: false };
|
|
28959
|
-
return void 0;
|
|
28960
|
-
}
|
|
28961
|
-
|
|
28962
|
-
// src/commands/sessions/daemon/worktree/otherTreeHolders.ts
|
|
28963
|
-
function otherTreeHolders(sessions, session) {
|
|
28964
|
-
const tree = treeUnderClose(session)?.path;
|
|
28965
|
-
if (!tree) return [];
|
|
28966
|
-
return [...sessions.values()].filter(
|
|
28967
|
-
(s) => s.id !== session.id && treeUnderClose(s)?.path === tree
|
|
28968
|
-
);
|
|
28969
|
-
}
|
|
28970
|
-
|
|
28971
28955
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
28972
28956
|
import { existsSync as existsSync64 } from "fs";
|
|
28973
28957
|
import { basename as basename18 } from "path";
|
|
@@ -28982,10 +28966,11 @@ import { rm as rm2 } from "fs/promises";
|
|
|
28982
28966
|
import { join as join74 } from "path";
|
|
28983
28967
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
28984
28968
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
28969
|
+
const refusal = "it is a clone of its own, not a linked worktree";
|
|
28985
28970
|
daemonLog(
|
|
28986
|
-
`worktree ${worktreePath} not deleted directly (${why}):
|
|
28971
|
+
`worktree ${worktreePath} not deleted directly (${why}): ${refusal}`
|
|
28987
28972
|
);
|
|
28988
|
-
return false;
|
|
28973
|
+
return { removed: false, reason: refusal };
|
|
28989
28974
|
}
|
|
28990
28975
|
daemonLog(`worktree ${worktreePath} deleting its directory directly: ${why}`);
|
|
28991
28976
|
try {
|
|
@@ -28999,11 +28984,11 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
28999
28984
|
daemonLog(
|
|
29000
28985
|
`worktree ${worktreePath} directory delete failed, left in place for the next reconcile: ${reason(error)}`
|
|
29001
28986
|
);
|
|
29002
|
-
return false;
|
|
28987
|
+
return { removed: false, reason: reason(error) };
|
|
29003
28988
|
}
|
|
29004
28989
|
daemonLog(`worktree ${worktreePath} directory deleted directly`);
|
|
29005
28990
|
await pruneBookkeeping(clone, worktreePath);
|
|
29006
|
-
return true;
|
|
28991
|
+
return { removed: true };
|
|
29007
28992
|
}
|
|
29008
28993
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
29009
28994
|
return statSync12(join74(worktreePath, ".git"), {
|
|
@@ -29033,7 +29018,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
29033
29018
|
daemonLog(
|
|
29034
29019
|
`worktree ${worktreePath} left in place for the next reconcile: ${reason2(cause)}`
|
|
29035
29020
|
);
|
|
29036
|
-
return false;
|
|
29021
|
+
return { removed: false, reason: reason2(cause) };
|
|
29037
29022
|
}
|
|
29038
29023
|
return await deleteTreeDirectly(
|
|
29039
29024
|
clone,
|
|
@@ -29062,7 +29047,7 @@ async function removeTree(clone, worktreePath, force) {
|
|
|
29062
29047
|
]);
|
|
29063
29048
|
try {
|
|
29064
29049
|
await remove2(force);
|
|
29065
|
-
return true;
|
|
29050
|
+
return { removed: true };
|
|
29066
29051
|
} catch (error) {
|
|
29067
29052
|
daemonLog(`worktree ${worktreePath} removal failed: ${reason3(error)}`);
|
|
29068
29053
|
if (force)
|
|
@@ -29080,7 +29065,7 @@ async function removeIgnoringLeftovers(clone, remove2, worktreePath) {
|
|
|
29080
29065
|
daemonLog(
|
|
29081
29066
|
`worktree ${worktreePath} removed on retry; only ignored files remained, its work is landed`
|
|
29082
29067
|
);
|
|
29083
|
-
return true;
|
|
29068
|
+
return { removed: true };
|
|
29084
29069
|
} catch (error) {
|
|
29085
29070
|
daemonLog(
|
|
29086
29071
|
`worktree ${worktreePath} forced removal failed: ${reason3(error)}`
|
|
@@ -29095,23 +29080,27 @@ function reason3(error) {
|
|
|
29095
29080
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
29096
29081
|
async function reapWorktree(worktreePath, force = false) {
|
|
29097
29082
|
if (!existsSync64(worktreePath)) {
|
|
29098
|
-
|
|
29099
|
-
|
|
29083
|
+
forgetWorktree(worktreePath);
|
|
29084
|
+
daemonLog(
|
|
29085
|
+
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
29086
|
+
);
|
|
29087
|
+
return { removed: true };
|
|
29100
29088
|
}
|
|
29101
29089
|
if (!force) {
|
|
29102
29090
|
const durability = await checkDurability(worktreePath);
|
|
29103
29091
|
if (!durability.durable) {
|
|
29104
29092
|
daemonLog(`worktree ${worktreePath} not reaped: ${durability.reason}`);
|
|
29105
|
-
return false;
|
|
29093
|
+
return { removed: false, reason: durability.reason };
|
|
29106
29094
|
}
|
|
29107
29095
|
}
|
|
29108
29096
|
stopInstall(worktreePath);
|
|
29109
29097
|
const clone = owningClone(worktreePath);
|
|
29110
|
-
|
|
29098
|
+
const removal = await removeTree(clone, worktreePath, force);
|
|
29099
|
+
if (!removal.removed) return removal;
|
|
29111
29100
|
await deleteWorktreeBranch(clone, basename18(worktreePath));
|
|
29112
29101
|
forgetWorktree(worktreePath);
|
|
29113
29102
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
29114
|
-
return
|
|
29103
|
+
return removal;
|
|
29115
29104
|
}
|
|
29116
29105
|
function owningClone(worktreePath) {
|
|
29117
29106
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
@@ -29137,6 +29126,63 @@ async function deleteWorktreeBranch(clone, branch2) {
|
|
|
29137
29126
|
}
|
|
29138
29127
|
}
|
|
29139
29128
|
|
|
29129
|
+
// src/commands/sessions/daemon/discardTree.ts
|
|
29130
|
+
async function discardTree(session, discarded, notify2) {
|
|
29131
|
+
if (session.worktree) {
|
|
29132
|
+
const removal = await reapWorktree(session.worktree.path, true);
|
|
29133
|
+
if (!removal.removed) {
|
|
29134
|
+
holdFailedDiscard(session, removal.reason, notify2);
|
|
29135
|
+
return;
|
|
29136
|
+
}
|
|
29137
|
+
session.worktree = void 0;
|
|
29138
|
+
}
|
|
29139
|
+
discarded();
|
|
29140
|
+
}
|
|
29141
|
+
function holdFailedDiscard(session, reason4, notify2) {
|
|
29142
|
+
daemonLog(
|
|
29143
|
+
`session ${session.id} discard failed for ${session.worktree?.path}: ${reason4}; card kept so the workspace is not orphaned invisibly`
|
|
29144
|
+
);
|
|
29145
|
+
session.closing = void 0;
|
|
29146
|
+
session.undurable = {
|
|
29147
|
+
reason: `discard failed: ${reason4}`,
|
|
29148
|
+
removesTree: true
|
|
29149
|
+
};
|
|
29150
|
+
setStatus2(session, "stopped");
|
|
29151
|
+
notify2();
|
|
29152
|
+
}
|
|
29153
|
+
|
|
29154
|
+
// src/commands/sessions/daemon/killPtyTree.ts
|
|
29155
|
+
function killPtyTree(pty2) {
|
|
29156
|
+
if (process.platform === "win32") {
|
|
29157
|
+
pty2.kill();
|
|
29158
|
+
return;
|
|
29159
|
+
}
|
|
29160
|
+
try {
|
|
29161
|
+
process.kill(-pty2.pid, "SIGHUP");
|
|
29162
|
+
} catch {
|
|
29163
|
+
try {
|
|
29164
|
+
pty2.kill();
|
|
29165
|
+
} catch {
|
|
29166
|
+
}
|
|
29167
|
+
}
|
|
29168
|
+
}
|
|
29169
|
+
|
|
29170
|
+
// src/commands/sessions/daemon/worktree/treeUnderClose.ts
|
|
29171
|
+
function treeUnderClose(session) {
|
|
29172
|
+
if (session.worktree) return { path: session.worktree.path, removable: true };
|
|
29173
|
+
if (session.cwd) return { path: session.cwd, removable: false };
|
|
29174
|
+
return void 0;
|
|
29175
|
+
}
|
|
29176
|
+
|
|
29177
|
+
// src/commands/sessions/daemon/worktree/otherTreeHolders.ts
|
|
29178
|
+
function otherTreeHolders(sessions, session) {
|
|
29179
|
+
const tree = treeUnderClose(session)?.path;
|
|
29180
|
+
if (!tree) return [];
|
|
29181
|
+
return [...sessions.values()].filter(
|
|
29182
|
+
(s) => s.id !== session.id && treeUnderClose(s)?.path === tree
|
|
29183
|
+
);
|
|
29184
|
+
}
|
|
29185
|
+
|
|
29140
29186
|
// src/commands/sessions/daemon/dismissSession.ts
|
|
29141
29187
|
function dismissSession(sessions, id) {
|
|
29142
29188
|
const s = sessions.get(id);
|
|
@@ -29185,22 +29231,6 @@ function closeGateApplies(sessions, session) {
|
|
|
29185
29231
|
return worktreeConfigFor(session.cwd).enabled === true;
|
|
29186
29232
|
}
|
|
29187
29233
|
|
|
29188
|
-
// src/commands/sessions/daemon/setStatus.ts
|
|
29189
|
-
function setStatus2(session, newStatus) {
|
|
29190
|
-
const now = Date.now();
|
|
29191
|
-
if (session.status === "running" && session.runningSince != null) {
|
|
29192
|
-
session.runningMs += now - session.runningSince;
|
|
29193
|
-
}
|
|
29194
|
-
session.runningSince = newStatus === "running" ? now : null;
|
|
29195
|
-
session.waitingSince = newStatus === "waiting" ? now : null;
|
|
29196
|
-
session.status = newStatus;
|
|
29197
|
-
if (newStatus === "waiting") {
|
|
29198
|
-
daemonLog(
|
|
29199
|
-
`session ${session.id} waiting since ${new Date(now).toISOString()}`
|
|
29200
|
-
);
|
|
29201
|
-
}
|
|
29202
|
-
}
|
|
29203
|
-
|
|
29204
29234
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
29205
29235
|
import { existsSync as existsSync65, watch } from "fs";
|
|
29206
29236
|
var DEBOUNCE_MS = 500;
|
|
@@ -29297,19 +29327,13 @@ function dismissSessionGated(sessions, id, notify2, discard = false) {
|
|
|
29297
29327
|
const removeCard = () => {
|
|
29298
29328
|
if (dismissSession(sessions, id)) notify2();
|
|
29299
29329
|
};
|
|
29300
|
-
const
|
|
29301
|
-
if (s.worktree) {
|
|
29302
|
-
await reapWorktree(s.worktree.path, true);
|
|
29303
|
-
s.worktree = void 0;
|
|
29304
|
-
}
|
|
29305
|
-
removeCard();
|
|
29306
|
-
};
|
|
29330
|
+
const settle = discard ? () => void discardTree(s, removeCard, notify2) : () => void resolveCloseDurability(s, removeCard, notify2);
|
|
29307
29331
|
s.closing = true;
|
|
29308
29332
|
daemonLog(
|
|
29309
29333
|
`session ${id} closing: ${discard ? "discarding" : "checking durability of"} ${tree.path}`
|
|
29310
29334
|
);
|
|
29311
29335
|
if (s.pty) {
|
|
29312
|
-
s.pendingDismiss =
|
|
29336
|
+
s.pendingDismiss = settle;
|
|
29313
29337
|
daemonLog(
|
|
29314
29338
|
`session ${id} ${discard ? "discard" : "dismiss"} requested: killing process tree first`
|
|
29315
29339
|
);
|
|
@@ -29318,8 +29342,7 @@ function dismissSessionGated(sessions, id, notify2, discard = false) {
|
|
|
29318
29342
|
return;
|
|
29319
29343
|
}
|
|
29320
29344
|
notify2();
|
|
29321
|
-
|
|
29322
|
-
else void resolveCloseDurability(s, removeCard, notify2);
|
|
29345
|
+
settle();
|
|
29323
29346
|
}
|
|
29324
29347
|
|
|
29325
29348
|
// src/commands/sessions/daemon/drainSessions.ts
|