@staff0rd/assist 0.529.0 → 0.530.1
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/dist/commands/sessions/web/bundle.js +394 -394
- package/dist/index.js +110 -97
- 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.530.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -4256,7 +4256,7 @@ var sessionsConfigHelp = [
|
|
|
4256
4256
|
{
|
|
4257
4257
|
key: "worktree.watcher",
|
|
4258
4258
|
setter: "assist config set worktree.watcher true -g --repo",
|
|
4259
|
-
note: "a backlog run also starts one starred claude session in the clone running /watch, so the built version stays current while the run works in its worktree; requires worktree.enabled
|
|
4259
|
+
note: "a backlog run also starts one starred claude session in the clone running /watch, so the built version stays current while the run works in its worktree; requires worktree.enabled, a /watch command in the repo and an auto-build run entry (default off)"
|
|
4260
4260
|
},
|
|
4261
4261
|
{
|
|
4262
4262
|
key: "worktree.trunk",
|
|
@@ -30108,6 +30108,10 @@ function setStatus2(session, newStatus) {
|
|
|
30108
30108
|
session.runningSince = newStatus === "running" ? now : null;
|
|
30109
30109
|
session.waitingSince = newStatus === "waiting" ? now : null;
|
|
30110
30110
|
session.status = newStatus;
|
|
30111
|
+
if (newStatus !== "running" && session.verifying) {
|
|
30112
|
+
session.verifying = false;
|
|
30113
|
+
daemonLog(`session ${session.id} verifying cleared: status=${newStatus}`);
|
|
30114
|
+
}
|
|
30111
30115
|
if (newStatus === "waiting") {
|
|
30112
30116
|
daemonLog(
|
|
30113
30117
|
`session ${session.id} waiting since ${new Date(now).toISOString()}`
|
|
@@ -32637,6 +32641,20 @@ function runRetry(sessions, id, replace, deps2) {
|
|
|
32637
32641
|
return null;
|
|
32638
32642
|
}
|
|
32639
32643
|
|
|
32644
|
+
// src/commands/sessions/daemon/attachReusedRun.ts
|
|
32645
|
+
function attachReusedRun(session, alloc, clients, onStatusChange, tree) {
|
|
32646
|
+
broadcast(clients, { type: "clear", sessionId: session.id });
|
|
32647
|
+
if (alloc)
|
|
32648
|
+
bindNewWorktree(
|
|
32649
|
+
session,
|
|
32650
|
+
alloc,
|
|
32651
|
+
tree?.notify ?? (() => {
|
|
32652
|
+
}),
|
|
32653
|
+
tree?.startHeld
|
|
32654
|
+
);
|
|
32655
|
+
else wirePtyEvents(session, clients, onStatusChange);
|
|
32656
|
+
}
|
|
32657
|
+
|
|
32640
32658
|
// src/commands/sessions/daemon/resetCardForRun.ts
|
|
32641
32659
|
function resetCardForRun(session, assistArgs) {
|
|
32642
32660
|
session.pty?.kill();
|
|
@@ -32680,25 +32698,28 @@ function startReusedRunPty(session, assistArgs, itemId2, hold, clients, onStatus
|
|
|
32680
32698
|
return true;
|
|
32681
32699
|
}
|
|
32682
32700
|
|
|
32683
|
-
// src/commands/sessions/daemon/
|
|
32684
|
-
|
|
32685
|
-
|
|
32686
|
-
|
|
32687
|
-
|
|
32688
|
-
return
|
|
32689
|
-
|
|
32690
|
-
|
|
32691
|
-
|
|
32692
|
-
|
|
32693
|
-
|
|
32694
|
-
|
|
32695
|
-
|
|
32696
|
-
|
|
32697
|
-
|
|
32698
|
-
|
|
32699
|
-
|
|
32700
|
-
|
|
32701
|
-
|
|
32701
|
+
// src/commands/sessions/daemon/createWatcherSession.ts
|
|
32702
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
32703
|
+
var WATCH_PROMPT = "/watch";
|
|
32704
|
+
function createWatcherSession(id, cwd) {
|
|
32705
|
+
const claudeSessionId = randomUUID11();
|
|
32706
|
+
return {
|
|
32707
|
+
...sessionBase(id, "running"),
|
|
32708
|
+
name: `Session ${id}`,
|
|
32709
|
+
commandType: "claude",
|
|
32710
|
+
pty: spawnClaude2({
|
|
32711
|
+
prompt: WATCH_PROMPT,
|
|
32712
|
+
cwd,
|
|
32713
|
+
sessionId: id,
|
|
32714
|
+
claudeSessionId,
|
|
32715
|
+
auto: true
|
|
32716
|
+
}),
|
|
32717
|
+
cwd,
|
|
32718
|
+
claudeSessionId,
|
|
32719
|
+
initialPrompt: WATCH_PROMPT,
|
|
32720
|
+
starred: true,
|
|
32721
|
+
watcher: true
|
|
32722
|
+
};
|
|
32702
32723
|
}
|
|
32703
32724
|
|
|
32704
32725
|
// src/commands/sessions/daemon/worktree/boundTreeRoots.ts
|
|
@@ -32731,6 +32752,68 @@ function releaseReason(durability, session) {
|
|
|
32731
32752
|
return `free for allocation: session ${session.id} finished and its work is landed`;
|
|
32732
32753
|
}
|
|
32733
32754
|
|
|
32755
|
+
// src/commands/sessions/daemon/worktree/allocateAndBind.ts
|
|
32756
|
+
function allocateAndBind(ctx, cwd, create, options2 = {}) {
|
|
32757
|
+
const alloc = allocateTree(cwd, boundTreeRoots(ctx.sessions), options2);
|
|
32758
|
+
const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
|
|
32759
|
+
const id = ctx.spawnWith((sid) => create(sid, alloc.cwd, needsSeeding));
|
|
32760
|
+
bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
|
|
32761
|
+
return id;
|
|
32762
|
+
}
|
|
32763
|
+
|
|
32764
|
+
// src/commands/sessions/daemon/worktree/ensureWatcher.ts
|
|
32765
|
+
function ensureWatcher(ctx, cwd) {
|
|
32766
|
+
if (!cwd) return void 0;
|
|
32767
|
+
const repoRoot2 = findRepoRoot(cwd) ?? cwd;
|
|
32768
|
+
const cfg = worktreeConfigFor(repoRoot2);
|
|
32769
|
+
if (!cfg.enabled || cfg.watcher !== true) return void 0;
|
|
32770
|
+
const clone = mainWorktree(repoRoot2) ?? repoRoot2;
|
|
32771
|
+
const live = liveWatcherFor(ctx.sessions, clone);
|
|
32772
|
+
if (live) {
|
|
32773
|
+
daemonLog(
|
|
32774
|
+
`no watcher spawned for the clone ${clone}: session ${live.id} is already watching it (${live.status})`
|
|
32775
|
+
);
|
|
32776
|
+
return void 0;
|
|
32777
|
+
}
|
|
32778
|
+
const id = allocateAndBind(
|
|
32779
|
+
ctx,
|
|
32780
|
+
clone,
|
|
32781
|
+
(sid, resolvedCwd) => createWatcherSession(sid, resolvedCwd ?? clone),
|
|
32782
|
+
{ inPlace: true }
|
|
32783
|
+
);
|
|
32784
|
+
daemonLog(
|
|
32785
|
+
`spawned watcher session ${id} running /watch in the clone ${clone}`
|
|
32786
|
+
);
|
|
32787
|
+
return id;
|
|
32788
|
+
}
|
|
32789
|
+
function liveWatcherFor(sessions, clone) {
|
|
32790
|
+
for (const session of sessions.values())
|
|
32791
|
+
if (session.watcher === true && session.cwd === clone && session.status !== "stopped" && session.status !== "error")
|
|
32792
|
+
return session;
|
|
32793
|
+
return void 0;
|
|
32794
|
+
}
|
|
32795
|
+
|
|
32796
|
+
// src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
|
|
32797
|
+
var ITEM_ID = /^a?\d+$/;
|
|
32798
|
+
function isBacklogRunArgs(args) {
|
|
32799
|
+
const [command, subcommand, ...rest] = args;
|
|
32800
|
+
if (command !== "backlog" || subcommand !== "run") return false;
|
|
32801
|
+
return rest.some((arg) => ITEM_ID.test(arg));
|
|
32802
|
+
}
|
|
32803
|
+
|
|
32804
|
+
// src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
|
|
32805
|
+
var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set(["review", "review-pr-comments"]);
|
|
32806
|
+
function isPrCheckoutArgs(args) {
|
|
32807
|
+
const [command, ...rest] = args;
|
|
32808
|
+
if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
|
|
32809
|
+
return rest.some((arg) => /^[1-9]\d*$/.test(arg));
|
|
32810
|
+
}
|
|
32811
|
+
|
|
32812
|
+
// src/commands/sessions/daemon/worktree/isCommittingArgs.ts
|
|
32813
|
+
function isCommittingArgs(args) {
|
|
32814
|
+
return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
|
|
32815
|
+
}
|
|
32816
|
+
|
|
32734
32817
|
// src/commands/sessions/daemon/worktree/planReuseTree.ts
|
|
32735
32818
|
function planReuseTree(session, ctx, options2 = {}) {
|
|
32736
32819
|
if (!ctx || !session.cwd || session.worktree) return void 0;
|
|
@@ -32769,6 +32852,7 @@ function failChainedRun(session, itemId2, error, clients, tree) {
|
|
|
32769
32852
|
// src/commands/sessions/daemon/reuseSessionForRun.ts
|
|
32770
32853
|
function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
|
|
32771
32854
|
const assistArgs = ["backlog", "run", String(itemId2)];
|
|
32855
|
+
const originCwd = session.cwd;
|
|
32772
32856
|
resetCardForRun(session, assistArgs);
|
|
32773
32857
|
let alloc;
|
|
32774
32858
|
try {
|
|
@@ -32789,16 +32873,8 @@ function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
|
|
|
32789
32873
|
onStatusChange
|
|
32790
32874
|
);
|
|
32791
32875
|
if (!started) return;
|
|
32792
|
-
|
|
32793
|
-
|
|
32794
|
-
bindNewWorktree(
|
|
32795
|
-
session,
|
|
32796
|
-
alloc,
|
|
32797
|
-
tree?.notify ?? (() => {
|
|
32798
|
-
}),
|
|
32799
|
-
tree?.startHeld
|
|
32800
|
-
);
|
|
32801
|
-
else wirePtyEvents(session, clients, onStatusChange);
|
|
32876
|
+
if (tree) ensureWatcher(tree, originCwd);
|
|
32877
|
+
attachReusedRun(session, alloc, clients, onStatusChange, tree);
|
|
32802
32878
|
daemonLog(
|
|
32803
32879
|
`session ${session.id} reused for backlog run ${itemId2}: ${session.name}`
|
|
32804
32880
|
);
|
|
@@ -33669,71 +33745,6 @@ function resumeSession(id, sessionId, cwd, name, holdPty) {
|
|
|
33669
33745
|
};
|
|
33670
33746
|
}
|
|
33671
33747
|
|
|
33672
|
-
// src/commands/sessions/daemon/worktree/allocateAndBind.ts
|
|
33673
|
-
function allocateAndBind(ctx, cwd, create, options2 = {}) {
|
|
33674
|
-
const alloc = allocateTree(cwd, boundTreeRoots(ctx.sessions), options2);
|
|
33675
|
-
const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
|
|
33676
|
-
const id = ctx.spawnWith((sid) => create(sid, alloc.cwd, needsSeeding));
|
|
33677
|
-
bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
|
|
33678
|
-
return id;
|
|
33679
|
-
}
|
|
33680
|
-
|
|
33681
|
-
// src/commands/sessions/daemon/createWatcherSession.ts
|
|
33682
|
-
import { randomUUID as randomUUID11 } from "crypto";
|
|
33683
|
-
var WATCH_PROMPT = "/watch";
|
|
33684
|
-
function createWatcherSession(id, cwd) {
|
|
33685
|
-
const claudeSessionId = randomUUID11();
|
|
33686
|
-
return {
|
|
33687
|
-
...sessionBase(id, "running"),
|
|
33688
|
-
name: `Session ${id}`,
|
|
33689
|
-
commandType: "claude",
|
|
33690
|
-
pty: spawnClaude2({
|
|
33691
|
-
prompt: WATCH_PROMPT,
|
|
33692
|
-
cwd,
|
|
33693
|
-
sessionId: id,
|
|
33694
|
-
claudeSessionId,
|
|
33695
|
-
auto: true
|
|
33696
|
-
}),
|
|
33697
|
-
cwd,
|
|
33698
|
-
claudeSessionId,
|
|
33699
|
-
initialPrompt: WATCH_PROMPT,
|
|
33700
|
-
starred: true,
|
|
33701
|
-
watcher: true
|
|
33702
|
-
};
|
|
33703
|
-
}
|
|
33704
|
-
|
|
33705
|
-
// src/commands/sessions/daemon/worktree/ensureWatcher.ts
|
|
33706
|
-
function ensureWatcher(ctx, cwd) {
|
|
33707
|
-
if (!cwd) return void 0;
|
|
33708
|
-
const repoRoot2 = findRepoRoot(cwd) ?? cwd;
|
|
33709
|
-
const cfg = worktreeConfigFor(repoRoot2);
|
|
33710
|
-
if (!cfg.enabled || cfg.watcher !== true) return void 0;
|
|
33711
|
-
const clone = mainWorktree(repoRoot2) ?? repoRoot2;
|
|
33712
|
-
const live = liveWatcherFor(ctx.sessions, clone);
|
|
33713
|
-
if (live) {
|
|
33714
|
-
daemonLog(
|
|
33715
|
-
`no watcher spawned for the clone ${clone}: session ${live.id} is already watching it (${live.status})`
|
|
33716
|
-
);
|
|
33717
|
-
return void 0;
|
|
33718
|
-
}
|
|
33719
|
-
const id = allocateAndBind(
|
|
33720
|
-
ctx,
|
|
33721
|
-
clone,
|
|
33722
|
-
(sid, resolvedCwd) => createWatcherSession(sid, resolvedCwd ?? clone),
|
|
33723
|
-
{ inPlace: true }
|
|
33724
|
-
);
|
|
33725
|
-
daemonLog(
|
|
33726
|
-
`spawned watcher session ${id} running /watch in the clone ${clone}`
|
|
33727
|
-
);
|
|
33728
|
-
return id;
|
|
33729
|
-
}
|
|
33730
|
-
function liveWatcherFor(sessions, clone) {
|
|
33731
|
-
for (const session of sessions.values())
|
|
33732
|
-
if (session.watcher === true && session.cwd === clone && session.status !== "stopped" && session.status !== "error")
|
|
33733
|
-
return session;
|
|
33734
|
-
return void 0;
|
|
33735
|
-
}
|
|
33736
|
-
|
|
33737
33748
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
33738
33749
|
import { existsSync as existsSync76 } from "fs";
|
|
33739
33750
|
|
|
@@ -34299,7 +34310,9 @@ var messageHandlers = {
|
|
|
34299
34310
|
),
|
|
34300
34311
|
"set-active": (_client, m, d) => m.active.set(d.cwd, d.sessionId),
|
|
34301
34312
|
"set-status": handleSetStatus,
|
|
34302
|
-
"verify-started": (
|
|
34313
|
+
"verify-started": routed(
|
|
34314
|
+
(client, m, d) => m.verify.start(client, d.sessionId)
|
|
34315
|
+
),
|
|
34303
34316
|
"pr-preview": (client, m, d) => m.prPreview.set(client, d),
|
|
34304
34317
|
"pr-decision": (_client, m, d) => m.prPreview.decide(d),
|
|
34305
34318
|
"ui-status": (_client, _m, d) => daemonLog(`ui rendered: id=${d.sessionId} status=${d.status}`)
|