@staff0rd/assist 0.818.1 → 0.819.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/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.1",
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,
@@ -35517,12 +35515,17 @@ var SAME_REPO_PATTERN2 = /(?<![\w/#-])#\d+\b/g;
35517
35515
  function firstMatch(body, pattern2) {
35518
35516
  return body.match(pattern2)?.[0] ?? null;
35519
35517
  }
35520
- function checkDescriptionLinksIssue(body) {
35518
+ function checkDescriptionLinksIssue(body, linkedIssues) {
35519
+ if (linkedIssues[0])
35520
+ return {
35521
+ status: "pass",
35522
+ reason: `Development-linked to ${linkedIssues[0]}`
35523
+ };
35521
35524
  const reference = firstMatch(body, ISSUE_URL_PATTERN) ?? firstMatch(body, CROSS_REPO_PATTERN) ?? firstMatch(body, SAME_REPO_PATTERN2);
35522
35525
  if (!reference)
35523
35526
  return {
35524
35527
  status: "fail",
35525
- reason: "no GitHub issue reference (`#123`, `owner/repo#123`, or an issue URL) in the description"
35528
+ reason: "no GitHub issue reference (`#123`, `owner/repo#123`, or an issue URL) in the description and no Development-linked issue"
35526
35529
  };
35527
35530
  return { status: "pass", reason: `links ${reference}` };
35528
35531
  }
@@ -35627,8 +35630,8 @@ var highLevelChecklist = [
35627
35630
  {
35628
35631
  id: "description-links-issue",
35629
35632
  kind: "deterministic",
35630
- title: "Description links the GitHub issue the PR resolves",
35631
- backing: "GitHub issue references in the PR body"
35633
+ title: "PR links the GitHub issue it resolves",
35634
+ backing: "A Development-linked issue or a GitHub issue reference in the PR body"
35632
35635
  },
35633
35636
  {
35634
35637
  id: "ui-evidence",
@@ -35666,7 +35669,7 @@ var highLevelChecklist = [
35666
35669
  var evaluators = {
35667
35670
  "description-what-why": (subject) => checkDescriptionSections(subject.body),
35668
35671
  "description-word-cap": (subject) => checkDescriptionWordCap(subject.body, subject.config.descriptionWordCap),
35669
- "description-links-issue": (subject) => checkDescriptionLinksIssue(subject.body),
35672
+ "description-links-issue": (subject) => checkDescriptionLinksIssue(subject.body, subject.linkedIssues),
35670
35673
  "ui-evidence": (subject) => checkUiEvidence(subject.body, subject.changedFiles, subject.config.uiPaths)
35671
35674
  };
35672
35675
  function evaluateHighLevelChecks(subject) {
@@ -35712,7 +35715,7 @@ function fetchHighLevelFiles(prNumber, repo) {
35712
35715
  import { execSync as execSync57 } from "child_process";
35713
35716
  function fetchHighLevelPr(prNumber, repo) {
35714
35717
  const raw = execSync57(
35715
- `gh pr view ${prNumber} --json title,body,headRefName,headRefOid -R ${repo.org}/${repo.repo}`,
35718
+ `gh pr view ${prNumber} --json title,body,headRefName,headRefOid,closingIssuesReferences -R ${repo.org}/${repo.repo}`,
35716
35719
  { encoding: "utf8" }
35717
35720
  );
35718
35721
  const pr = JSON.parse(raw);
@@ -35720,7 +35723,10 @@ function fetchHighLevelPr(prNumber, repo) {
35720
35723
  title: pr.title ?? "",
35721
35724
  body: pr.body ?? "",
35722
35725
  headRef: pr.headRefName,
35723
- headSha: pr.headRefOid
35726
+ headSha: pr.headRefOid,
35727
+ linkedIssues: pr.closingIssuesReferences.map(
35728
+ (issue) => `${issue.repository.owner.login}/${issue.repository.name}#${issue.number}`
35729
+ )
35724
35730
  };
35725
35731
  }
35726
35732
 
@@ -35786,6 +35792,7 @@ function gatherHighLevelSubject(prNumber, force) {
35786
35792
  headSha: pr.headSha,
35787
35793
  checks: evaluateHighLevelChecks({
35788
35794
  body: pr.body,
35795
+ linkedIssues: pr.linkedIssues,
35789
35796
  changedFiles: files.map((file) => file.path),
35790
35797
  config
35791
35798
  }),
@@ -43028,7 +43035,6 @@ function toSessionInfo(session) {
43028
43035
  claudeSessionId,
43029
43036
  harnessSessionId,
43030
43037
  restored,
43031
- autoRun,
43032
43038
  autoAdvance,
43033
43039
  starred,
43034
43040
  design,
@@ -43054,7 +43060,6 @@ function toSessionInfo(session) {
43054
43060
  harnessSessionId,
43055
43061
  repoGroup: repoGroupForCwd(cwd),
43056
43062
  restored,
43057
- autoRun,
43058
43063
  autoAdvance,
43059
43064
  starred,
43060
43065
  design,
@@ -43221,13 +43226,6 @@ function writeToSession(sessions, id, data, onStatusChange, viewer = {}) {
43221
43226
  watchPromptSubmit(s, data, onStatusChange);
43222
43227
  if (!response) claimViewer(s, viewer, "input");
43223
43228
  }
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
43229
  function setStarred2(sessions, id, starred) {
43232
43230
  const s = sessions.get(id);
43233
43231
  if (!s) return false;
@@ -46053,38 +46051,9 @@ function applyUsageRecord(sessions, windows, notify2, claudeSessionId, transcrip
46053
46051
  notify2();
46054
46052
  }
46055
46053
 
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
46054
  // src/commands/sessions/daemon/endsStreamLife.ts
46085
46055
  function endsStreamLife(session, status2, sharedWithOtherAgents) {
46086
46056
  if (status2 !== "done" || !session.worktree) return false;
46087
- if (shouldAutoRun(session, status2).run) return false;
46088
46057
  if (!sharedWithOtherAgents(session)) return true;
46089
46058
  daemonLog(
46090
46059
  `session ${session.id} done in ${session.worktree.path}: workspace kept, other agents are still working there`
@@ -46114,17 +46083,6 @@ function finishStatusChange(session, status2, exitCode, deps2) {
46114
46083
  if (status2 === "waiting")
46115
46084
  startTranscriptTitleGeneration(session, deps2.notify);
46116
46085
  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
46086
  if (shouldAutoDismiss(session, exitCode)) deps2.dismiss(session.id);
46129
46087
  else deps2.notify();
46130
46088
  }
@@ -46159,184 +46117,6 @@ function makeStatusChangeHandler(sessions, deps2) {
46159
46117
  );
46160
46118
  }
46161
46119
 
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
46120
  // src/commands/sessions/daemon/applySetStatus.ts
46341
46121
  function applySetStatus(sessions, id, status2, source, onStatusChange, rebind) {
46342
46122
  const session = sessions.get(id);
@@ -46386,6 +46166,26 @@ function setStatusFromHook(sessions, report, notify2, onStatusChange) {
46386
46166
  );
46387
46167
  }
46388
46168
 
46169
+ // src/commands/sessions/daemon/refuseSpawn.ts
46170
+ function refuseSpawn(session, error, clients, onStatusChange, stage = "respawned") {
46171
+ const reason4 = error instanceof Error ? error.message : String(error);
46172
+ session.pty = null;
46173
+ session.pendingStart = void 0;
46174
+ session.error = reason4;
46175
+ daemonLog(
46176
+ `session ${session.id} ("${session.name}") not ${stage}: ${reason4}`
46177
+ );
46178
+ broadcast(clients, { type: "clear", sessionId: session.id });
46179
+ emitSessionOutput(
46180
+ session,
46181
+ clients,
46182
+ `\r
46183
+ \x1B[31mCannot start this session: ${reason4}\x1B[0m\r
46184
+ `
46185
+ );
46186
+ onStatusChange(session, "error");
46187
+ }
46188
+
46389
46189
  // src/commands/sessions/daemon/respawnSession.ts
46390
46190
  function respawnSession(session, respawn, status2, clients, onStatusChange) {
46391
46191
  session.gitWatcher?.close();
@@ -46627,7 +46427,6 @@ function restoreBase(id, persisted) {
46627
46427
  divergenceEscalation: persisted.divergenceEscalation,
46628
46428
  design: persisted.design,
46629
46429
  auto: persisted.auto,
46630
- autoRun: persisted.autoRun,
46631
46430
  autoAdvance: restoredAutoAdvance(id, persisted),
46632
46431
  reviewStarted: persisted.reviewStarted,
46633
46432
  launchedFrom: persisted.launchedFrom
@@ -48332,6 +48131,31 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
48332
48131
  };
48333
48132
  }
48334
48133
 
48134
+ // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
48135
+ var ITEM_ID = /^a?\d+$/;
48136
+ function isBacklogRunArgs(args) {
48137
+ const [command, subcommand, ...rest] = args;
48138
+ if (command !== "backlog" || subcommand !== "run") return false;
48139
+ return rest.some((arg) => ITEM_ID.test(arg));
48140
+ }
48141
+
48142
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
48143
+ var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
48144
+ "review",
48145
+ "review-pr-comments",
48146
+ "fix-conflict"
48147
+ ]);
48148
+ function isPrCheckoutArgs(args) {
48149
+ const [command, ...rest] = args;
48150
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
48151
+ return rest.some((arg) => /^[1-9]\d*$/.test(arg));
48152
+ }
48153
+
48154
+ // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
48155
+ function isCommittingArgs(args) {
48156
+ return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
48157
+ }
48158
+
48335
48159
  // src/commands/sessions/daemon/worktree/spawnInTree.ts
48336
48160
  function spawnInTree(ctx, { prompt, cwd, design, auto, harness, inPlace }, context) {
48337
48161
  return allocateAndBind(
@@ -48558,13 +48382,10 @@ var SessionManager = class {
48558
48382
  resume(sessionId, cwd, name, harness) {
48559
48383
  return resumeInTree(this.treeCtx(), sessionId, cwd, name, harness);
48560
48384
  }
48561
- onStatusChange = managerStatusChangeHandler(
48562
- this.sessions,
48563
- this.clients,
48564
- (id) => this.dismissSession(id),
48565
- () => this.notify(),
48566
- () => this.treeCtx()
48567
- );
48385
+ onStatusChange = makeStatusChangeHandler(this.sessions, {
48386
+ dismiss: (id) => this.dismissSession(id),
48387
+ notify: () => this.notify()
48388
+ });
48568
48389
  io = new SessionIo(
48569
48390
  this.sessions,
48570
48391
  () => this.onStatusChange,
@@ -48600,9 +48421,6 @@ var SessionManager = class {
48600
48421
  stopSession(id) {
48601
48422
  stopServerSession(this.sessions, id);
48602
48423
  }
48603
- setAutoRun(id, enabled) {
48604
- if (setAutoRun(this.sessions, id, enabled)) this.notify();
48605
- }
48606
48424
  setTitle(id, title) {
48607
48425
  this.update((sessions) => setSessionTitle(sessions, id, title));
48608
48426
  }
@@ -49176,9 +48994,6 @@ function setSessionCwd(sessions, id, cwd) {
49176
48994
 
49177
48995
  // src/commands/sessions/daemon/sessionSettingHandlers.ts
49178
48996
  var sessionSettingHandlers = {
49179
- "set-autorun": routed(
49180
- (_client, m, d) => m.setAutoRun(d.sessionId, d.enabled)
49181
- ),
49182
48997
  "set-autoadvance": routed(
49183
48998
  (_client, m, d) => m.update(
49184
48999
  (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.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {