@staff0rd/assist 0.818.1 → 0.819.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/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.818.1",
9
+ version: "0.819.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -27148,7 +27148,6 @@ var persistedSessionSchema = z10.object({
27148
27148
  divergenceEscalation: z10.boolean().optional(),
27149
27149
  design: z10.boolean().optional(),
27150
27150
  auto: z10.boolean().optional(),
27151
- autoRun: z10.boolean().optional(),
27152
27151
  autoAdvance: z10.boolean().optional(),
27153
27152
  reviewStarted: z10.boolean().optional(),
27154
27153
  launchedFrom: z10.string().optional(),
@@ -27181,7 +27180,6 @@ function toPersistedSession(session) {
27181
27180
  divergenceEscalation: session.divergenceEscalation,
27182
27181
  design: session.design,
27183
27182
  auto: session.auto,
27184
- autoRun: session.autoRun,
27185
27183
  autoAdvance: session.autoAdvance,
27186
27184
  reviewStarted: session.reviewStarted,
27187
27185
  launchedFrom: session.launchedFrom,
@@ -43028,7 +43026,6 @@ function toSessionInfo(session) {
43028
43026
  claudeSessionId,
43029
43027
  harnessSessionId,
43030
43028
  restored,
43031
- autoRun,
43032
43029
  autoAdvance,
43033
43030
  starred,
43034
43031
  design,
@@ -43054,7 +43051,6 @@ function toSessionInfo(session) {
43054
43051
  harnessSessionId,
43055
43052
  repoGroup: repoGroupForCwd(cwd),
43056
43053
  restored,
43057
- autoRun,
43058
43054
  autoAdvance,
43059
43055
  starred,
43060
43056
  design,
@@ -43221,13 +43217,6 @@ function writeToSession(sessions, id, data, onStatusChange, viewer = {}) {
43221
43217
  watchPromptSubmit(s, data, onStatusChange);
43222
43218
  if (!response) claimViewer(s, viewer, "input");
43223
43219
  }
43224
- function setAutoRun(sessions, id, enabled) {
43225
- const s = sessions.get(id);
43226
- if (!s) return false;
43227
- s.autoRun = enabled;
43228
- daemonLog(`session ${id} autorun ${enabled ? "on" : "off"}`);
43229
- return true;
43230
- }
43231
43220
  function setStarred2(sessions, id, starred) {
43232
43221
  const s = sessions.get(id);
43233
43222
  if (!s) return false;
@@ -46053,38 +46042,9 @@ function applyUsageRecord(sessions, windows, notify2, claudeSessionId, transcrip
46053
46042
  notify2();
46054
46043
  }
46055
46044
 
46056
- // src/commands/sessions/daemon/shouldAutoRun.ts
46057
- function shouldAutoRun(session, status2 = session.status) {
46058
- if (!session.autoRun) return { run: false, reason: null };
46059
- if (status2 !== "done")
46060
- return {
46061
- run: false,
46062
- reason: `session status is "${status2}", not "done"`
46063
- };
46064
- if (session.commandType !== "assist")
46065
- return {
46066
- run: false,
46067
- reason: `command type is "${session.commandType}", not "assist"`
46068
- };
46069
- const cmd = session.assistArgs?.[0];
46070
- if (!isDraftCommand(cmd))
46071
- return {
46072
- run: false,
46073
- reason: `command "${cmd ?? "(none)"}" is not draft/bug/refine`
46074
- };
46075
- const itemId2 = session.activity?.itemId;
46076
- if (itemId2 == null)
46077
- return {
46078
- run: false,
46079
- reason: "no itemId in activity (draft did not create an item)"
46080
- };
46081
- return { run: true, itemId: itemId2 };
46082
- }
46083
-
46084
46045
  // src/commands/sessions/daemon/endsStreamLife.ts
46085
46046
  function endsStreamLife(session, status2, sharedWithOtherAgents) {
46086
46047
  if (status2 !== "done" || !session.worktree) return false;
46087
- if (shouldAutoRun(session, status2).run) return false;
46088
46048
  if (!sharedWithOtherAgents(session)) return true;
46089
46049
  daemonLog(
46090
46050
  `session ${session.id} done in ${session.worktree.path}: workspace kept, other agents are still working there`
@@ -46114,17 +46074,6 @@ function finishStatusChange(session, status2, exitCode, deps2) {
46114
46074
  if (status2 === "waiting")
46115
46075
  startTranscriptTitleGeneration(session, deps2.notify);
46116
46076
  if (status2 !== "stopped") session.undurable = void 0;
46117
- const autoRun = shouldAutoRun(session);
46118
- if (autoRun.run) {
46119
- deps2.reuseForRun(session, autoRun.itemId);
46120
- deps2.notify();
46121
- return;
46122
- }
46123
- if (status2 === "done" && autoRun.reason != null) {
46124
- daemonLog(
46125
- `session ${session.id} auto-run enabled but skipped (exit ${exitCode ?? "none"}): ${autoRun.reason}`
46126
- );
46127
- }
46128
46077
  if (shouldAutoDismiss(session, exitCode)) deps2.dismiss(session.id);
46129
46078
  else deps2.notify();
46130
46079
  }
@@ -46159,184 +46108,6 @@ function makeStatusChangeHandler(sessions, deps2) {
46159
46108
  );
46160
46109
  }
46161
46110
 
46162
- // src/commands/sessions/daemon/attachReusedRun.ts
46163
- function attachReusedRun(session, alloc, clients, onStatusChange, tree) {
46164
- broadcast(clients, { type: "clear", sessionId: session.id });
46165
- if (alloc)
46166
- bindNewWorktree(
46167
- session,
46168
- alloc,
46169
- tree?.notify ?? (() => {
46170
- }),
46171
- tree?.startHeld
46172
- );
46173
- else wirePtyEvents(session, clients, onStatusChange);
46174
- }
46175
-
46176
- // src/commands/sessions/daemon/resetCardForRun.ts
46177
- function resetCardForRun(session, assistArgs) {
46178
- session.pty?.kill();
46179
- session.gitWatcher?.close();
46180
- session.gitWatcher = void 0;
46181
- session.undurable = void 0;
46182
- session.assistArgs = assistArgs;
46183
- session.name = `assist ${assistArgs.join(" ")}`;
46184
- session.commandType = "assist";
46185
- session.activity = void 0;
46186
- removeActivity(session.id);
46187
- session.scrollback = "";
46188
- session.startedAt = Date.now();
46189
- session.runningMs = 0;
46190
- session.runningSince = null;
46191
- session.usageSeeded = false;
46192
- setStatus2(session, "running");
46193
- session.restored = void 0;
46194
- session.launchedFrom = void 0;
46195
- }
46196
-
46197
- // src/commands/sessions/daemon/refuseSpawn.ts
46198
- function refuseSpawn(session, error, clients, onStatusChange, stage = "respawned") {
46199
- const reason4 = error instanceof Error ? error.message : String(error);
46200
- session.pty = null;
46201
- session.pendingStart = void 0;
46202
- session.error = reason4;
46203
- daemonLog(
46204
- `session ${session.id} ("${session.name}") not ${stage}: ${reason4}`
46205
- );
46206
- broadcast(clients, { type: "clear", sessionId: session.id });
46207
- emitSessionOutput(
46208
- session,
46209
- clients,
46210
- `\r
46211
- \x1B[31mCannot start this session: ${reason4}\x1B[0m\r
46212
- `
46213
- );
46214
- onStatusChange(session, "error");
46215
- }
46216
-
46217
- // src/commands/sessions/daemon/startReusedRunPty.ts
46218
- function startReusedRunPty(session, assistArgs, itemId2, hold, clients, onStatusChange) {
46219
- try {
46220
- Object.assign(
46221
- session,
46222
- startOrHoldPty(
46223
- () => spawnPty(["assist", ...assistArgs], session.cwd, session.id),
46224
- hold
46225
- )
46226
- );
46227
- } catch (error) {
46228
- refuseSpawn(
46229
- session,
46230
- error,
46231
- clients,
46232
- onStatusChange,
46233
- `reused for backlog run ${itemId2}`
46234
- );
46235
- return false;
46236
- }
46237
- return true;
46238
- }
46239
-
46240
- // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
46241
- var ITEM_ID = /^a?\d+$/;
46242
- function isBacklogRunArgs(args) {
46243
- const [command, subcommand, ...rest] = args;
46244
- if (command !== "backlog" || subcommand !== "run") return false;
46245
- return rest.some((arg) => ITEM_ID.test(arg));
46246
- }
46247
-
46248
- // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
46249
- var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
46250
- "review",
46251
- "review-pr-comments",
46252
- "fix-conflict"
46253
- ]);
46254
- function isPrCheckoutArgs(args) {
46255
- const [command, ...rest] = args;
46256
- if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
46257
- return rest.some((arg) => /^[1-9]\d*$/.test(arg));
46258
- }
46259
-
46260
- // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
46261
- function isCommittingArgs(args) {
46262
- return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
46263
- }
46264
-
46265
- // src/commands/sessions/daemon/worktree/planReuseTree.ts
46266
- function planReuseTree(session, ctx, options2 = {}) {
46267
- if (!ctx || !session.cwd || session.worktree) return void 0;
46268
- const alloc = allocateTree(
46269
- session.cwd,
46270
- boundTreeRoots(ctx.sessions, session),
46271
- options2
46272
- );
46273
- if (alloc.kind !== "worktree" || !alloc.cwd) return void 0;
46274
- daemonLog(
46275
- `session ${session.id} moved from ${session.cwd} to ${alloc.cwd} for its chained run`
46276
- );
46277
- return alloc;
46278
- }
46279
-
46280
- // src/commands/sessions/daemon/failChainedRun.ts
46281
- function failChainedRun(session, itemId2, error, clients, tree) {
46282
- const reason4 = error instanceof Error ? error.message : String(error);
46283
- session.pty = null;
46284
- session.error = `backlog run ${itemId2} could not start: ${reason4}`;
46285
- setStatus2(session, "error");
46286
- daemonLog(
46287
- `session ${session.id} not reused for backlog run ${itemId2}: workspace allocation failed: ${reason4}`
46288
- );
46289
- broadcast(clients, { type: "clear", sessionId: session.id });
46290
- emitSessionOutput(
46291
- session,
46292
- clients,
46293
- `\r
46294
- \x1B[31m${session.error}\x1B[0m\r
46295
- `
46296
- );
46297
- tree?.notify();
46298
- }
46299
-
46300
- // src/commands/sessions/daemon/reuseSessionForRun.ts
46301
- function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
46302
- const assistArgs = ["backlog", "run", String(itemId2)];
46303
- resetCardForRun(session, assistArgs);
46304
- let alloc;
46305
- try {
46306
- alloc = planReuseTree(session, tree, {
46307
- commits: isCommittingArgs(assistArgs),
46308
- backlogRun: true
46309
- });
46310
- } catch (error) {
46311
- failChainedRun(session, itemId2, error, clients, tree);
46312
- return;
46313
- }
46314
- if (alloc) session.cwd = alloc.cwd;
46315
- const started = startReusedRunPty(
46316
- session,
46317
- assistArgs,
46318
- itemId2,
46319
- alloc !== void 0,
46320
- clients,
46321
- onStatusChange
46322
- );
46323
- if (!started) return;
46324
- attachReusedRun(session, alloc, clients, onStatusChange, tree);
46325
- daemonLog(
46326
- `session ${session.id} reused for backlog run ${itemId2}: ${session.name}`
46327
- );
46328
- }
46329
-
46330
- // src/commands/sessions/daemon/managerStatusChangeHandler.ts
46331
- function managerStatusChangeHandler(sessions, clients, dismiss, notify2, treeCtx) {
46332
- const handler = makeStatusChangeHandler(sessions, {
46333
- dismiss,
46334
- notify: notify2,
46335
- reuseForRun: (session, itemId2) => reuseSessionForRun(session, itemId2, clients, handler, treeCtx())
46336
- });
46337
- return handler;
46338
- }
46339
-
46340
46111
  // src/commands/sessions/daemon/applySetStatus.ts
46341
46112
  function applySetStatus(sessions, id, status2, source, onStatusChange, rebind) {
46342
46113
  const session = sessions.get(id);
@@ -46386,6 +46157,26 @@ function setStatusFromHook(sessions, report, notify2, onStatusChange) {
46386
46157
  );
46387
46158
  }
46388
46159
 
46160
+ // src/commands/sessions/daemon/refuseSpawn.ts
46161
+ function refuseSpawn(session, error, clients, onStatusChange, stage = "respawned") {
46162
+ const reason4 = error instanceof Error ? error.message : String(error);
46163
+ session.pty = null;
46164
+ session.pendingStart = void 0;
46165
+ session.error = reason4;
46166
+ daemonLog(
46167
+ `session ${session.id} ("${session.name}") not ${stage}: ${reason4}`
46168
+ );
46169
+ broadcast(clients, { type: "clear", sessionId: session.id });
46170
+ emitSessionOutput(
46171
+ session,
46172
+ clients,
46173
+ `\r
46174
+ \x1B[31mCannot start this session: ${reason4}\x1B[0m\r
46175
+ `
46176
+ );
46177
+ onStatusChange(session, "error");
46178
+ }
46179
+
46389
46180
  // src/commands/sessions/daemon/respawnSession.ts
46390
46181
  function respawnSession(session, respawn, status2, clients, onStatusChange) {
46391
46182
  session.gitWatcher?.close();
@@ -46627,7 +46418,6 @@ function restoreBase(id, persisted) {
46627
46418
  divergenceEscalation: persisted.divergenceEscalation,
46628
46419
  design: persisted.design,
46629
46420
  auto: persisted.auto,
46630
- autoRun: persisted.autoRun,
46631
46421
  autoAdvance: restoredAutoAdvance(id, persisted),
46632
46422
  reviewStarted: persisted.reviewStarted,
46633
46423
  launchedFrom: persisted.launchedFrom
@@ -48332,6 +48122,31 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
48332
48122
  };
48333
48123
  }
48334
48124
 
48125
+ // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
48126
+ var ITEM_ID = /^a?\d+$/;
48127
+ function isBacklogRunArgs(args) {
48128
+ const [command, subcommand, ...rest] = args;
48129
+ if (command !== "backlog" || subcommand !== "run") return false;
48130
+ return rest.some((arg) => ITEM_ID.test(arg));
48131
+ }
48132
+
48133
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
48134
+ var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
48135
+ "review",
48136
+ "review-pr-comments",
48137
+ "fix-conflict"
48138
+ ]);
48139
+ function isPrCheckoutArgs(args) {
48140
+ const [command, ...rest] = args;
48141
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
48142
+ return rest.some((arg) => /^[1-9]\d*$/.test(arg));
48143
+ }
48144
+
48145
+ // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
48146
+ function isCommittingArgs(args) {
48147
+ return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
48148
+ }
48149
+
48335
48150
  // src/commands/sessions/daemon/worktree/spawnInTree.ts
48336
48151
  function spawnInTree(ctx, { prompt, cwd, design, auto, harness, inPlace }, context) {
48337
48152
  return allocateAndBind(
@@ -48558,13 +48373,10 @@ var SessionManager = class {
48558
48373
  resume(sessionId, cwd, name, harness) {
48559
48374
  return resumeInTree(this.treeCtx(), sessionId, cwd, name, harness);
48560
48375
  }
48561
- onStatusChange = managerStatusChangeHandler(
48562
- this.sessions,
48563
- this.clients,
48564
- (id) => this.dismissSession(id),
48565
- () => this.notify(),
48566
- () => this.treeCtx()
48567
- );
48376
+ onStatusChange = makeStatusChangeHandler(this.sessions, {
48377
+ dismiss: (id) => this.dismissSession(id),
48378
+ notify: () => this.notify()
48379
+ });
48568
48380
  io = new SessionIo(
48569
48381
  this.sessions,
48570
48382
  () => this.onStatusChange,
@@ -48600,9 +48412,6 @@ var SessionManager = class {
48600
48412
  stopSession(id) {
48601
48413
  stopServerSession(this.sessions, id);
48602
48414
  }
48603
- setAutoRun(id, enabled) {
48604
- if (setAutoRun(this.sessions, id, enabled)) this.notify();
48605
- }
48606
48415
  setTitle(id, title) {
48607
48416
  this.update((sessions) => setSessionTitle(sessions, id, title));
48608
48417
  }
@@ -49176,9 +48985,6 @@ function setSessionCwd(sessions, id, cwd) {
49176
48985
 
49177
48986
  // src/commands/sessions/daemon/sessionSettingHandlers.ts
49178
48987
  var sessionSettingHandlers = {
49179
- "set-autorun": routed(
49180
- (_client, m, d) => m.setAutoRun(d.sessionId, d.enabled)
49181
- ),
49182
48988
  "set-autoadvance": routed(
49183
48989
  (_client, m, d) => m.update(
49184
48990
  (sessions) => setAutoAdvance(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.818.1",
3
+ "version": "0.819.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {