@staff0rd/assist 0.730.1 → 0.731.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/README.md +1 -1
- package/claude/advice/show-links.md +6 -0
- package/dist/commands/sessions/web/bundle.js +285 -285
- package/dist/index.js +206 -49
- 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.
|
|
9
|
+
version: "0.731.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -579,6 +579,7 @@ var adviceFragmentTitles = {
|
|
|
579
579
|
markdown: "Writing markdown",
|
|
580
580
|
refactor: "Renaming and extracting TypeScript",
|
|
581
581
|
"settings-json": "Editing claude/settings.json",
|
|
582
|
+
"show-links": "Showing long links, paths and snippets",
|
|
582
583
|
verify: "Verifying a change"
|
|
583
584
|
};
|
|
584
585
|
var adviceFragmentNames = [
|
|
@@ -594,6 +595,7 @@ var adviceFragmentNames = [
|
|
|
594
595
|
"markdown",
|
|
595
596
|
"refactor",
|
|
596
597
|
"settings-json",
|
|
598
|
+
"show-links",
|
|
597
599
|
"verify"
|
|
598
600
|
];
|
|
599
601
|
|
|
@@ -7539,12 +7541,18 @@ async function prepareRun(id, resumeSessionId) {
|
|
|
7539
7541
|
|
|
7540
7542
|
// src/commands/backlog/reportDuplicateRun.ts
|
|
7541
7543
|
import chalk62 from "chalk";
|
|
7544
|
+
|
|
7545
|
+
// src/commands/backlog/duplicateRunExitCode.ts
|
|
7546
|
+
var duplicateRunExitCode = 75;
|
|
7547
|
+
|
|
7548
|
+
// src/commands/backlog/reportDuplicateRun.ts
|
|
7542
7549
|
function reportDuplicateRun(itemId2, holder) {
|
|
7543
7550
|
const since = holder.timestamp ? `, started ${holder.timestamp}` : "";
|
|
7544
7551
|
const reason4 = `another session is already running it (pid ${holder.pid}${since}); close that session before running it again`;
|
|
7545
7552
|
console.log(chalk62.yellow(`Already running: ${formatItemId(itemId2)}`));
|
|
7546
7553
|
console.log(chalk62.dim(`Refusing to start a second run \u2014 ${reason4}.`));
|
|
7547
7554
|
appendDaemonLog(`backlog run ${itemId2}: refused \u2014 ${reason4}`);
|
|
7555
|
+
process.exitCode = duplicateRunExitCode;
|
|
7548
7556
|
}
|
|
7549
7557
|
|
|
7550
7558
|
// src/commands/backlog/consumePause.ts
|
|
@@ -36240,32 +36248,60 @@ import { randomUUID as randomUUID19 } from "crypto";
|
|
|
36240
36248
|
async function sendShowPreview(request) {
|
|
36241
36249
|
const socket = await connectToDaemon();
|
|
36242
36250
|
await new Promise((resolve26, reject) => {
|
|
36243
|
-
|
|
36244
|
-
|
|
36251
|
+
const finish2 = (error) => {
|
|
36252
|
+
socket.destroy();
|
|
36253
|
+
if (error) reject(error);
|
|
36254
|
+
else resolve26();
|
|
36255
|
+
};
|
|
36256
|
+
readSocketLines(socket, (line) => {
|
|
36257
|
+
const reply2 = parseReply(line);
|
|
36258
|
+
if (reply2?.type === "error") finish2(new Error(reply2.message));
|
|
36259
|
+
if (reply2?.requestId !== request.requestId) return;
|
|
36260
|
+
if (reply2.type === "show-ack") finish2();
|
|
36261
|
+
if (reply2.type === "show-refused") finish2(new Error(reply2.message));
|
|
36262
|
+
});
|
|
36263
|
+
socket.on("error", (error) => finish2(error));
|
|
36264
|
+
socket.on(
|
|
36265
|
+
"close",
|
|
36266
|
+
() => finish2(new Error("daemon closed before acknowledging the show"))
|
|
36267
|
+
);
|
|
36268
|
+
socket.write(
|
|
36245
36269
|
`${JSON.stringify({ type: "pr-preview", kind: "show", prNumber: null, ...request })}
|
|
36246
|
-
|
|
36247
|
-
() => {
|
|
36248
|
-
socket.destroy();
|
|
36249
|
-
resolve26();
|
|
36250
|
-
}
|
|
36270
|
+
`
|
|
36251
36271
|
);
|
|
36252
36272
|
});
|
|
36253
36273
|
}
|
|
36274
|
+
function parseReply(line) {
|
|
36275
|
+
try {
|
|
36276
|
+
return JSON.parse(line);
|
|
36277
|
+
} catch {
|
|
36278
|
+
return null;
|
|
36279
|
+
}
|
|
36280
|
+
}
|
|
36254
36281
|
|
|
36255
36282
|
// src/commands/show.ts
|
|
36256
36283
|
async function show2(options2) {
|
|
36257
36284
|
const body = await readBodyArgument(options2.body);
|
|
36285
|
+
if (body.trim().length === 0) {
|
|
36286
|
+
console.error("Error: --body is empty; there is nothing to show.");
|
|
36287
|
+
process.exit(1);
|
|
36288
|
+
}
|
|
36258
36289
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
36259
36290
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) {
|
|
36260
36291
|
console.log(body);
|
|
36261
36292
|
return;
|
|
36262
36293
|
}
|
|
36263
|
-
|
|
36264
|
-
|
|
36265
|
-
|
|
36266
|
-
|
|
36267
|
-
|
|
36268
|
-
|
|
36294
|
+
try {
|
|
36295
|
+
await sendShowPreview({
|
|
36296
|
+
sessionId,
|
|
36297
|
+
requestId: randomUUID19(),
|
|
36298
|
+
title: options2.title ?? "Show",
|
|
36299
|
+
body
|
|
36300
|
+
});
|
|
36301
|
+
} catch (error) {
|
|
36302
|
+
console.error(`Error: ${error.message}`);
|
|
36303
|
+
process.exit(1);
|
|
36304
|
+
}
|
|
36269
36305
|
console.log("Opened in the assist web UI preview pane.");
|
|
36270
36306
|
}
|
|
36271
36307
|
|
|
@@ -41128,6 +41164,55 @@ function closeGateApplies(sessions, session) {
|
|
|
41128
41164
|
return worktreeConfigFor(session.cwd).enabled === true;
|
|
41129
41165
|
}
|
|
41130
41166
|
|
|
41167
|
+
// src/commands/sessions/daemon/worktree/liveProcessesInTree.ts
|
|
41168
|
+
import { readdirSync as readdirSync23, readlinkSync } from "fs";
|
|
41169
|
+
import { sep as sep3 } from "path";
|
|
41170
|
+
function liveProcessesInTree(treePath, procRoot = "/proc") {
|
|
41171
|
+
let entries;
|
|
41172
|
+
try {
|
|
41173
|
+
entries = readdirSync23(procRoot);
|
|
41174
|
+
} catch {
|
|
41175
|
+
return [];
|
|
41176
|
+
}
|
|
41177
|
+
const pids = [];
|
|
41178
|
+
for (const entry of entries) {
|
|
41179
|
+
const pid = Number(entry);
|
|
41180
|
+
if (!Number.isInteger(pid) || pid === process.pid) continue;
|
|
41181
|
+
const cwd = processCwd(`${procRoot}/${entry}/cwd`);
|
|
41182
|
+
if (cwd && (cwd === treePath || cwd.startsWith(treePath + sep3)))
|
|
41183
|
+
pids.push(pid);
|
|
41184
|
+
}
|
|
41185
|
+
return pids;
|
|
41186
|
+
}
|
|
41187
|
+
function processCwd(link3) {
|
|
41188
|
+
try {
|
|
41189
|
+
return readlinkSync(link3);
|
|
41190
|
+
} catch {
|
|
41191
|
+
return void 0;
|
|
41192
|
+
}
|
|
41193
|
+
}
|
|
41194
|
+
|
|
41195
|
+
// src/commands/sessions/daemon/worktree/liveOccupantReason.ts
|
|
41196
|
+
function liveOccupantReason(treePath) {
|
|
41197
|
+
stopInstall(treePath);
|
|
41198
|
+
const pids = liveProcessesInTree(treePath);
|
|
41199
|
+
if (pids.length === 0) return void 0;
|
|
41200
|
+
return `a live process is still running in it (pid ${pids.join(", ")})`;
|
|
41201
|
+
}
|
|
41202
|
+
|
|
41203
|
+
// src/commands/sessions/daemon/worktree/closeBlockReason.ts
|
|
41204
|
+
async function closeBlockReason(sessionId, tree) {
|
|
41205
|
+
const durability = await checkDurability(tree.path);
|
|
41206
|
+
if (!durability.durable) return durability.reason;
|
|
41207
|
+
if (durability.gone) {
|
|
41208
|
+
daemonLog(
|
|
41209
|
+
`session ${sessionId} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
|
|
41210
|
+
);
|
|
41211
|
+
return void 0;
|
|
41212
|
+
}
|
|
41213
|
+
return tree.removable ? liveOccupantReason(tree.path) : void 0;
|
|
41214
|
+
}
|
|
41215
|
+
|
|
41131
41216
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
41132
41217
|
import { existsSync as existsSync91, watch } from "fs";
|
|
41133
41218
|
var DEBOUNCE_MS = 500;
|
|
@@ -41175,15 +41260,11 @@ async function resolveCloseDurability(session, finalize, notify2) {
|
|
|
41175
41260
|
finalize();
|
|
41176
41261
|
return;
|
|
41177
41262
|
}
|
|
41178
|
-
const
|
|
41179
|
-
if (
|
|
41180
|
-
holdStopped(session, tree,
|
|
41263
|
+
const blocked = await closeBlockReason(session.id, tree);
|
|
41264
|
+
if (blocked) {
|
|
41265
|
+
holdStopped(session, tree, blocked, finalize, notify2);
|
|
41181
41266
|
return;
|
|
41182
41267
|
}
|
|
41183
|
-
if (durability.gone)
|
|
41184
|
-
daemonLog(
|
|
41185
|
-
`session ${session.id} closing: worktree ${tree.path} is gone from disk \u2014 released with nothing to land, not landed work`
|
|
41186
|
-
);
|
|
41187
41268
|
if (tree.removable) await reapWorktree(tree.path);
|
|
41188
41269
|
if (session.worktree) session.releasedFromClone = session.worktree.clone;
|
|
41189
41270
|
session.worktree = void 0;
|
|
@@ -41382,6 +41463,31 @@ function decidePrPreview(sessions, waiters, notify2, d) {
|
|
|
41382
41463
|
notify2();
|
|
41383
41464
|
}
|
|
41384
41465
|
|
|
41466
|
+
// src/commands/sessions/daemon/parsePreviewMetadata.ts
|
|
41467
|
+
function parsePreviewMetadata(value) {
|
|
41468
|
+
if (!Array.isArray(value)) return void 0;
|
|
41469
|
+
const items2 = value.flatMap((entry) => {
|
|
41470
|
+
const { label: label2, value: text18 } = entry ?? {};
|
|
41471
|
+
return typeof label2 === "string" && typeof text18 === "string" ? [{ label: label2, value: text18 }] : [];
|
|
41472
|
+
});
|
|
41473
|
+
return items2.length > 0 ? items2 : void 0;
|
|
41474
|
+
}
|
|
41475
|
+
|
|
41476
|
+
// src/commands/sessions/daemon/buildPrPreview.ts
|
|
41477
|
+
function buildPrPreview(d, kind, prNumber) {
|
|
41478
|
+
const draft = d.draft === true;
|
|
41479
|
+
return {
|
|
41480
|
+
requestId: d.requestId,
|
|
41481
|
+
title: d.title,
|
|
41482
|
+
body: d.body,
|
|
41483
|
+
prNumber,
|
|
41484
|
+
kind,
|
|
41485
|
+
itemType: kind === "backlog-item" ? d.itemType === "bug" ? "bug" : "story" : void 0,
|
|
41486
|
+
draft: kind === "pr" && prNumber === null ? draft : void 0,
|
|
41487
|
+
metadata: parsePreviewMetadata(d.metadata)
|
|
41488
|
+
};
|
|
41489
|
+
}
|
|
41490
|
+
|
|
41385
41491
|
// src/commands/sessions/daemon/isPreviewKind.ts
|
|
41386
41492
|
var PREVIEW_KINDS = [
|
|
41387
41493
|
"pr",
|
|
@@ -41400,16 +41506,6 @@ function isPreviewKind(value) {
|
|
|
41400
41506
|
return PREVIEW_KINDS.includes(value);
|
|
41401
41507
|
}
|
|
41402
41508
|
|
|
41403
|
-
// src/commands/sessions/daemon/parsePreviewMetadata.ts
|
|
41404
|
-
function parsePreviewMetadata(value) {
|
|
41405
|
-
if (!Array.isArray(value)) return void 0;
|
|
41406
|
-
const items2 = value.flatMap((entry) => {
|
|
41407
|
-
const { label: label2, value: text18 } = entry ?? {};
|
|
41408
|
-
return typeof label2 === "string" && typeof text18 === "string" ? [{ label: label2, value: text18 }] : [];
|
|
41409
|
-
});
|
|
41410
|
-
return items2.length > 0 ? items2 : void 0;
|
|
41411
|
-
}
|
|
41412
|
-
|
|
41413
41509
|
// src/commands/sessions/daemon/previewTargetLabel.ts
|
|
41414
41510
|
function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
41415
41511
|
if (kind === "backlog-comment") return "backlog comment";
|
|
@@ -41426,6 +41522,27 @@ function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
|
41426
41522
|
return draft ? "create draft" : "create";
|
|
41427
41523
|
}
|
|
41428
41524
|
|
|
41525
|
+
// src/commands/sessions/daemon/refuseShowOverApproval.ts
|
|
41526
|
+
function refuseShowOverApproval(session, client, d) {
|
|
41527
|
+
const pending = session.pendingPrPreview;
|
|
41528
|
+
if (!pending || pending.kind === "show") return false;
|
|
41529
|
+
const target = previewTargetLabel(
|
|
41530
|
+
pending.kind ?? "pr",
|
|
41531
|
+
pending.itemType ?? "story",
|
|
41532
|
+
pending.prNumber,
|
|
41533
|
+
pending.draft === true
|
|
41534
|
+
);
|
|
41535
|
+
daemonLog(
|
|
41536
|
+
`pr-preview show refused: id=${session.id} requestId=${d.requestId} pending=${target}`
|
|
41537
|
+
);
|
|
41538
|
+
sendTo(client, {
|
|
41539
|
+
type: "show-refused",
|
|
41540
|
+
requestId: d.requestId,
|
|
41541
|
+
message: `A ${target} preview is awaiting approval in this session's preview pane; approve or reject it before showing anything else.`
|
|
41542
|
+
});
|
|
41543
|
+
return true;
|
|
41544
|
+
}
|
|
41545
|
+
|
|
41429
41546
|
// src/commands/sessions/daemon/setPrPreview.ts
|
|
41430
41547
|
function setPrPreview(sessions, waiters, notify2, client, d) {
|
|
41431
41548
|
const id = d.sessionId;
|
|
@@ -41440,20 +41557,17 @@ function setPrPreview(sessions, waiters, notify2, client, d) {
|
|
|
41440
41557
|
}
|
|
41441
41558
|
const prNumber = typeof d.prNumber === "number" ? d.prNumber : null;
|
|
41442
41559
|
const kind = isPreviewKind(d.kind) ? d.kind : "pr";
|
|
41443
|
-
|
|
41444
|
-
|
|
41445
|
-
|
|
41446
|
-
requestId: d.requestId
|
|
41447
|
-
|
|
41448
|
-
|
|
41449
|
-
prNumber,
|
|
41560
|
+
if (kind === "show" && refuseShowOverApproval(session, client, d)) return;
|
|
41561
|
+
session.pendingPrPreview = buildPrPreview(d, kind, prNumber);
|
|
41562
|
+
if (kind === "show")
|
|
41563
|
+
sendTo(client, { type: "show-ack", requestId: d.requestId });
|
|
41564
|
+
else waiters.set(id, client);
|
|
41565
|
+
const target = previewTargetLabel(
|
|
41450
41566
|
kind,
|
|
41451
|
-
itemType
|
|
41452
|
-
|
|
41453
|
-
|
|
41454
|
-
|
|
41455
|
-
if (kind !== "show") waiters.set(id, client);
|
|
41456
|
-
const target = previewTargetLabel(kind, itemType, prNumber, draft);
|
|
41567
|
+
d.itemType === "bug" ? "bug" : "story",
|
|
41568
|
+
prNumber,
|
|
41569
|
+
d.draft === true
|
|
41570
|
+
);
|
|
41457
41571
|
daemonLog(
|
|
41458
41572
|
`pr-preview set: id=${id} requestId=${d.requestId} kind=${kind} target=${target}`
|
|
41459
41573
|
);
|
|
@@ -41685,6 +41799,17 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
41685
41799
|
return true;
|
|
41686
41800
|
}
|
|
41687
41801
|
|
|
41802
|
+
// src/commands/sessions/daemon/handleRefusedRun.ts
|
|
41803
|
+
function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
41804
|
+
if (exitCode !== duplicateRunExitCode) return false;
|
|
41805
|
+
session.error = session.restored ? "not resumed: the original backlog run is still alive (orphaned by a daemon restart); stop it before restarting this session" : "refused: another session is already running this backlog item";
|
|
41806
|
+
daemonLog(
|
|
41807
|
+
`session ${session.id} ("${session.name}") duplicate backlog run refused; keeping its worktree for the live original: ${session.error}`
|
|
41808
|
+
);
|
|
41809
|
+
onStatusChange(session, "error", exitCode);
|
|
41810
|
+
return true;
|
|
41811
|
+
}
|
|
41812
|
+
|
|
41688
41813
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
41689
41814
|
import { existsSync as existsSync93, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
41690
41815
|
import { dirname as dirname42 } from "path";
|
|
@@ -41816,6 +41941,7 @@ function handlePtyExit(session, exitCode, onStatusChange) {
|
|
|
41816
41941
|
}
|
|
41817
41942
|
if (handleStoppedExit(session, exitCode, onStatusChange)) return;
|
|
41818
41943
|
refreshActivity(session);
|
|
41944
|
+
if (handleRefusedRun(session, exitCode, onStatusChange)) return;
|
|
41819
41945
|
if (handleFailedResume(session, exitCode, onStatusChange)) return;
|
|
41820
41946
|
const priorStatus = session.status;
|
|
41821
41947
|
if (exitCode !== 0) {
|
|
@@ -43124,7 +43250,7 @@ function deferralNotice(persisted, cap2) {
|
|
|
43124
43250
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
43125
43251
|
import { realpathSync as realpathSync3 } from "fs";
|
|
43126
43252
|
import { tmpdir as tmpdir10 } from "os";
|
|
43127
|
-
import { sep as
|
|
43253
|
+
import { sep as sep4 } from "path";
|
|
43128
43254
|
function tempRoots() {
|
|
43129
43255
|
const raw = tmpdir10();
|
|
43130
43256
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
@@ -43137,7 +43263,7 @@ function tempRoots() {
|
|
|
43137
43263
|
}
|
|
43138
43264
|
function underTempRoot(path106) {
|
|
43139
43265
|
return tempRoots().some(
|
|
43140
|
-
(root2) => path106.startsWith(root2.endsWith(
|
|
43266
|
+
(root2) => path106.startsWith(root2.endsWith(sep4) ? root2 : root2 + sep4)
|
|
43141
43267
|
);
|
|
43142
43268
|
}
|
|
43143
43269
|
|
|
@@ -44365,6 +44491,19 @@ function connectLinkWebSocket(url, handlers) {
|
|
|
44365
44491
|
});
|
|
44366
44492
|
}
|
|
44367
44493
|
|
|
44494
|
+
// src/commands/sessions/daemon/links/guardLinkCallback.ts
|
|
44495
|
+
function guardLinkCallback(label2, callback) {
|
|
44496
|
+
return (...args) => {
|
|
44497
|
+
try {
|
|
44498
|
+
callback(...args);
|
|
44499
|
+
} catch (error) {
|
|
44500
|
+
daemonLog(
|
|
44501
|
+
`${label2} threw; ignored so the daemon keeps running: ${error instanceof Error ? error.message : String(error)}`
|
|
44502
|
+
);
|
|
44503
|
+
}
|
|
44504
|
+
};
|
|
44505
|
+
}
|
|
44506
|
+
|
|
44368
44507
|
// src/commands/sessions/daemon/links/selfUpdatePeer.ts
|
|
44369
44508
|
var SELF_UPDATE_TIMEOUT_MS = 10 * 6e4;
|
|
44370
44509
|
async function selfUpdatePeer(url) {
|
|
@@ -44508,7 +44647,19 @@ var sshTunnelFor = (spec) => spec.ssh ? new SshTunnel(spec.name, spec.ssh) : voi
|
|
|
44508
44647
|
// src/commands/sessions/daemon/links/linkDeps.ts
|
|
44509
44648
|
function linkDeps(options2, callbacks) {
|
|
44510
44649
|
return {
|
|
44511
|
-
|
|
44650
|
+
viewers: callbacks.viewers,
|
|
44651
|
+
onSessionsChanged: guardLinkCallback(
|
|
44652
|
+
"links: sessions-changed handler",
|
|
44653
|
+
callbacks.onSessionsChanged
|
|
44654
|
+
),
|
|
44655
|
+
onStateChanged: guardLinkCallback(
|
|
44656
|
+
"links: state-changed handler",
|
|
44657
|
+
callbacks.onStateChanged
|
|
44658
|
+
),
|
|
44659
|
+
onHistoryChanged: guardLinkCallback(
|
|
44660
|
+
"links: history-changed handler",
|
|
44661
|
+
callbacks.onHistoryChanged
|
|
44662
|
+
),
|
|
44512
44663
|
transport: options2.transport ?? connectLinkWebSocket,
|
|
44513
44664
|
tunnel: options2.tunnel ?? sshTunnelFor,
|
|
44514
44665
|
heal: options2.heal ?? selfUpdatePeer,
|
|
@@ -45013,8 +45164,14 @@ async function openLink(ctx) {
|
|
|
45013
45164
|
if (ctx.disposed) return;
|
|
45014
45165
|
daemonLog(`link ${ctx.spec.name} ws: connecting to ${ctx.spec.url}`);
|
|
45015
45166
|
const socket = await ctx.deps.transport(ctx.spec.url, {
|
|
45016
|
-
onLine: (
|
|
45017
|
-
|
|
45167
|
+
onLine: guardLinkCallback(
|
|
45168
|
+
`link ${ctx.spec.name} ws: line handler`,
|
|
45169
|
+
(line) => onLinkLine(ctx, line)
|
|
45170
|
+
),
|
|
45171
|
+
onClose: guardLinkCallback(
|
|
45172
|
+
`link ${ctx.spec.name} ws: close handler`,
|
|
45173
|
+
(reason4) => onLinkClose(ctx, socket, reason4)
|
|
45174
|
+
)
|
|
45018
45175
|
});
|
|
45019
45176
|
if (ctx.disposed) return socket.close();
|
|
45020
45177
|
ctx.socket = socket;
|