@staff0rd/assist 0.502.2 → 0.503.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.502.2",
9
+ version: "0.503.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -13289,7 +13289,8 @@ function parsePreviewDecision(line, requestId) {
13289
13289
  reason: msg.reason,
13290
13290
  comments: Array.isArray(msg.comments) ? msg.comments : void 0,
13291
13291
  screenshots: Array.isArray(msg.screenshots) ? msg.screenshots : void 0,
13292
- reviewAfter: msg.reviewAfter === true
13292
+ reviewAfter: msg.reviewAfter === true,
13293
+ announceAfter: msg.announceAfter === true
13293
13294
  }
13294
13295
  };
13295
13296
  } catch {
@@ -22090,19 +22091,6 @@ function appendScreenshots(body, screenshots) {
22090
22091
  ${screenshots.join("\n\n")}`;
22091
22092
  }
22092
22093
 
22093
- // src/commands/review/startChainedSession.ts
22094
- async function startChainedSession(label2, start3) {
22095
- if (process.env.ASSIST_SESSION !== "1") return;
22096
- try {
22097
- await start3();
22098
- console.log(`Started ${label2}.`);
22099
- } catch (error) {
22100
- console.error(
22101
- `Warning: could not start ${label2}: ${error instanceof Error ? error.message : String(error)}`
22102
- );
22103
- }
22104
- }
22105
-
22106
22094
  // src/commands/sessions/shared/requestSession.ts
22107
22095
  function parseIncoming(line, type) {
22108
22096
  try {
@@ -22143,29 +22131,86 @@ function requestSession(message3) {
22143
22131
  });
22144
22132
  }
22145
22133
 
22134
+ // src/commands/sessions/shared/requestClaudeSession.ts
22135
+ function requestClaudeSession(prompt, cwd, options2) {
22136
+ return requestSession({
22137
+ type: "create",
22138
+ prompt,
22139
+ cwd,
22140
+ inPlace: options2?.inPlace === true
22141
+ });
22142
+ }
22143
+
22144
+ // src/commands/review/startChainedSession.ts
22145
+ async function startChainedSession(label2, start3) {
22146
+ if (process.env.ASSIST_SESSION !== "1") return;
22147
+ try {
22148
+ await start3();
22149
+ console.log(`Started ${label2}.`);
22150
+ } catch (error) {
22151
+ console.error(
22152
+ `Warning: could not start ${label2}: ${error instanceof Error ? error.message : String(error)}`
22153
+ );
22154
+ }
22155
+ }
22156
+
22157
+ // src/commands/review/announcePr.ts
22158
+ function announcePr(prNumber) {
22159
+ return startChainedSession(
22160
+ `a Slack announce session for PR #${prNumber}`,
22161
+ () => requestClaudeSession(
22162
+ `/prs-slack ${prNumber} --no-confirm`,
22163
+ process.cwd(),
22164
+ { inPlace: true }
22165
+ )
22166
+ );
22167
+ }
22168
+
22146
22169
  // src/commands/sessions/shared/requestAssistSession.ts
22147
22170
  function requestAssistSession(assistArgs, cwd) {
22148
22171
  return requestSession({ type: "create-assist", assistArgs, cwd });
22149
22172
  }
22150
22173
 
22151
22174
  // src/commands/prs/chainReviewAndPost.ts
22152
- function chainReviewAndPost(prNumber) {
22153
- return startChainedSession("a Review + Post session for the PR", () => {
22154
- const number = prNumber ?? findCurrentPrNumber();
22155
- if (number === null)
22156
- throw new Error("no pull request found for the current branch");
22157
- return requestAssistSession(
22158
- [
22159
- "review",
22160
- "--no-prompt",
22161
- "--submit",
22162
- String(number),
22163
- "--address-comments",
22164
- "--announce"
22165
- ],
22166
- process.cwd()
22167
- );
22168
- });
22175
+ function chainReviewAndPost(prNumber, announce) {
22176
+ const args = [
22177
+ "review",
22178
+ "--no-prompt",
22179
+ "--submit",
22180
+ String(prNumber),
22181
+ "--address-comments"
22182
+ ];
22183
+ if (announce) args.push("--announce");
22184
+ return startChainedSession(
22185
+ `a Review + Post session for PR #${prNumber}`,
22186
+ () => requestAssistSession(args, process.cwd())
22187
+ );
22188
+ }
22189
+
22190
+ // src/commands/prs/chainAfterRaise.ts
22191
+ async function chainAfterRaise(prNumber, choice) {
22192
+ const review2 = choice.reviewAfter === true;
22193
+ const announce = choice.announceAfter === true;
22194
+ if (!review2 && !announce) return;
22195
+ if (process.env.ASSIST_SESSION !== "1") return;
22196
+ const number = resolvePrNumber(prNumber);
22197
+ if (number === null) return;
22198
+ if (review2) await chainReviewAndPost(number, announce);
22199
+ else await announcePr(number);
22200
+ }
22201
+ function resolvePrNumber(prNumber) {
22202
+ if (prNumber !== null) return prNumber;
22203
+ try {
22204
+ const found = findCurrentPrNumber();
22205
+ if (found === null) warn("no pull request found for the current branch");
22206
+ return found;
22207
+ } catch (error) {
22208
+ warn(error instanceof Error ? error.message : String(error));
22209
+ return null;
22210
+ }
22211
+ }
22212
+ function warn(reason4) {
22213
+ console.error(`Warning: could not chain sessions after raising: ${reason4}`);
22169
22214
  }
22170
22215
 
22171
22216
  // src/commands/prs/previewAndPlace.ts
@@ -22179,7 +22224,7 @@ async function previewAndPlace(args) {
22179
22224
  });
22180
22225
  const body = appendScreenshots(args.body, decision.screenshots ?? []);
22181
22226
  await placePr(args.prNumber, args.title, body, args.options);
22182
- if (decision.reviewAfter === true) await chainReviewAndPost(args.prNumber);
22227
+ await chainAfterRaise(args.prNumber, decision);
22183
22228
  }
22184
22229
 
22185
22230
  // src/commands/prs/raise.ts
@@ -24813,22 +24858,6 @@ function gatherContext() {
24813
24858
  };
24814
24859
  }
24815
24860
 
24816
- // src/commands/sessions/shared/requestClaudeSession.ts
24817
- function requestClaudeSession(prompt, cwd) {
24818
- return requestSession({ type: "create", prompt, cwd });
24819
- }
24820
-
24821
- // src/commands/review/announcePr.ts
24822
- function announcePr(prNumber) {
24823
- return startChainedSession(
24824
- `a Slack announce session for PR #${prNumber}`,
24825
- () => requestClaudeSession(
24826
- `/prs-slack ${prNumber} --no-confirm`,
24827
- process.cwd()
24828
- )
24829
- );
24830
- }
24831
-
24832
24861
  // src/commands/review/postReviewToPr.ts
24833
24862
  import { readFileSync as readFileSync41 } from "fs";
24834
24863
 
@@ -25182,6 +25211,26 @@ function selectPostableFindings(markdown, prInfo) {
25182
25211
  return inDiff;
25183
25212
  }
25184
25213
 
25214
+ // src/commands/review/stillOnReviewedPr.ts
25215
+ function currentPrNumber() {
25216
+ try {
25217
+ return findCurrentPrNumber();
25218
+ } catch (error) {
25219
+ console.error(
25220
+ `Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
25221
+ );
25222
+ return null;
25223
+ }
25224
+ }
25225
+ function stillOnReviewedPr(prNumber) {
25226
+ const current = currentPrNumber();
25227
+ if (current === prNumber) return true;
25228
+ console.error(
25229
+ `Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
25230
+ );
25231
+ return false;
25232
+ }
25233
+
25185
25234
  // src/commands/review/postReviewToPr.ts
25186
25235
  var NOTHING_POSTED = { posted: 0, submitted: false };
25187
25236
  async function confirmPost(prNumber, count8, options2) {
@@ -25202,8 +25251,8 @@ async function postFindingsToPr(prInfo, synthesisPath, options2) {
25202
25251
  }
25203
25252
  return postAndMaybeSubmit(inDiff, markdown, options2);
25204
25253
  }
25205
- async function postReviewToPr(synthesisPath, options2) {
25206
- const prInfo = fetchPrDiffInfo();
25254
+ async function postReviewToPr(synthesisPath, prInfo, options2) {
25255
+ if (!stillOnReviewedPr(prInfo.prNumber)) return;
25207
25256
  const outcome = await postFindingsToPr(prInfo, synthesisPath, options2);
25208
25257
  await chainAfterReview(prInfo.prNumber, outcome, options2);
25209
25258
  }
@@ -25309,10 +25358,10 @@ function nonPostingSession(options2) {
25309
25358
  if (options2.refine) return runRefineSession;
25310
25359
  return null;
25311
25360
  }
25312
- async function handlePostSynthesis(synthesisPath, prNumber, options2) {
25361
+ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
25313
25362
  const session = nonPostingSession(options2);
25314
25363
  if (!session) {
25315
- await postReviewToPr(synthesisPath, {
25364
+ await postReviewToPr(synthesisPath, prInfo, {
25316
25365
  prompt: options2.prompt,
25317
25366
  submit: options2.submit,
25318
25367
  addressComments: options2.addressComments,
@@ -25321,7 +25370,7 @@ async function handlePostSynthesis(synthesisPath, prNumber, options2) {
25321
25370
  return;
25322
25371
  }
25323
25372
  await session(synthesisPath);
25324
- if (options2.announce) await announcePr(prNumber);
25373
+ if (options2.announce) await announcePr(prInfo.prNumber);
25325
25374
  }
25326
25375
 
25327
25376
  // src/commands/review/prepareReviewDir.ts
@@ -26250,8 +26299,8 @@ function setupReviewDir(repoRoot, context, force) {
26250
26299
  console.log(`Review folder: ${paths.reviewDir}`);
26251
26300
  return paths;
26252
26301
  }
26253
- function runPostSynthesis(synthesisPath, prNumber, options2) {
26254
- return handlePostSynthesis(synthesisPath, prNumber, {
26302
+ function runPostSynthesis(synthesisPath, prInfo, options2) {
26303
+ return handlePostSynthesis(synthesisPath, prInfo, {
26255
26304
  refine: options2.refine ?? false,
26256
26305
  apply: options2.apply ?? false,
26257
26306
  backlog: options2.backlog ?? false,
@@ -26268,7 +26317,7 @@ async function reviewPr(repoRoot, options2) {
26268
26317
  verbose: options2.verbose ?? false
26269
26318
  });
26270
26319
  if (synthesisOk)
26271
- await runPostSynthesis(paths.synthesisPath, context.prNumber, options2);
26320
+ await runPostSynthesis(paths.synthesisPath, context, options2);
26272
26321
  console.log(`Done. Review folder: ${paths.reviewDir}`);
26273
26322
  }
26274
26323
 
@@ -30013,7 +30062,7 @@ function decidePrPreview(sessions, waiters, notify2, d) {
30013
30062
  const commentCount = Array.isArray(d.comments) ? d.comments.length : 0;
30014
30063
  const screenshotCount = Array.isArray(d.screenshots) ? d.screenshots.length : 0;
30015
30064
  daemonLog(
30016
- `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${commentCount} screenshots=${screenshotCount} reviewAfter=${d.reviewAfter === true}`
30065
+ `pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${commentCount} screenshots=${screenshotCount} reviewAfter=${d.reviewAfter === true} announceAfter=${d.announceAfter === true}`
30017
30066
  );
30018
30067
  const waiter = waiters.get(id);
30019
30068
  if (waiter)
@@ -30024,7 +30073,8 @@ function decidePrPreview(sessions, waiters, notify2, d) {
30024
30073
  reason: d.reason,
30025
30074
  comments: d.comments,
30026
30075
  screenshots: d.screenshots,
30027
- reviewAfter: d.reviewAfter
30076
+ reviewAfter: d.reviewAfter,
30077
+ announceAfter: d.announceAfter
30028
30078
  });
30029
30079
  waiters.delete(id);
30030
30080
  session.pendingPrPreview = void 0;
@@ -32823,7 +32873,7 @@ function resumeSession(id, sessionId, cwd, name) {
32823
32873
  };
32824
32874
  }
32825
32875
 
32826
- // src/commands/sessions/daemon/worktree/spawnInTree.ts
32876
+ // src/commands/sessions/daemon/worktree/allocateAndBind.ts
32827
32877
  function allocateAndBind(ctx, cwd, create, options2 = {}) {
32828
32878
  const alloc = allocateTree(cwd, boundTreeRoots(ctx.sessions), options2);
32829
32879
  const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
@@ -32831,11 +32881,14 @@ function allocateAndBind(ctx, cwd, create, options2 = {}) {
32831
32881
  bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
32832
32882
  return id;
32833
32883
  }
32834
- function spawnInTree(ctx, prompt, cwd, design, harness) {
32884
+
32885
+ // src/commands/sessions/daemon/worktree/spawnInTree.ts
32886
+ function spawnInTree(ctx, prompt, cwd, design, harness, inPlace) {
32835
32887
  return allocateAndBind(
32836
32888
  ctx,
32837
32889
  cwd,
32838
- (sid, resolvedCwd, holdUntilSeeded) => createSession(sid, prompt, resolvedCwd, design, harness, holdUntilSeeded)
32890
+ (sid, resolvedCwd, holdUntilSeeded) => createSession(sid, prompt, resolvedCwd, design, harness, holdUntilSeeded),
32891
+ { inPlace }
32839
32892
  );
32840
32893
  }
32841
32894
  function spawnAssistInTree(ctx, assistArgs, cwd, meta) {
@@ -32976,8 +33029,8 @@ var SessionManager = class {
32976
33029
  this.onStatusChange
32977
33030
  );
32978
33031
  }
32979
- spawn(prompt, cwd, design, harness) {
32980
- return spawnInTree(this.treeCtx(), prompt, cwd, design, harness);
33032
+ spawn(prompt, cwd, design, harness, inPlace) {
33033
+ return spawnInTree(this.treeCtx(), prompt, cwd, design, harness, inPlace);
32981
33034
  }
32982
33035
  addAgent(targetId, prompt, harness) {
32983
33036
  return addAgentToStream(this.treeCtx(), targetId, prompt, harness);
@@ -33287,7 +33340,13 @@ function spawnCreate(m, d) {
33287
33340
  `create: falling back to a fresh isolated session (cwd=${d.cwd ?? ""})`
33288
33341
  );
33289
33342
  }
33290
- return m.spawn(prompt, d.cwd, design, harness);
33343
+ return m.spawn(
33344
+ prompt,
33345
+ d.cwd,
33346
+ design,
33347
+ harness,
33348
+ d.inPlace === true
33349
+ );
33291
33350
  }
33292
33351
 
33293
33352
  // src/commands/sessions/daemon/messageHandlers.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.502.2",
3
+ "version": "0.503.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {