@staff0rd/assist 0.848.0 → 0.850.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.848.0",
9
+ version: "0.850.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -27402,6 +27402,7 @@ var persistedSessionSchema = z10.object({
27402
27402
  design: z10.boolean().optional(),
27403
27403
  auto: z10.boolean().optional(),
27404
27404
  autoAdvance: z10.boolean().optional(),
27405
+ autoStart: z10.boolean().optional(),
27405
27406
  reviewStarted: z10.boolean().optional(),
27406
27407
  launchedFrom: z10.string().optional(),
27407
27408
  interrupted: z10.object({ reason: z10.string(), at: z10.number() }).optional(),
@@ -27434,6 +27435,7 @@ function toPersistedSession(session) {
27434
27435
  design: session.design,
27435
27436
  auto: session.auto,
27436
27437
  autoAdvance: session.autoAdvance,
27438
+ autoStart: session.autoStart,
27437
27439
  reviewStarted: session.reviewStarted,
27438
27440
  launchedFrom: session.launchedFrom,
27439
27441
  interrupted: session.interrupted,
@@ -36906,20 +36908,22 @@ function runReviewSubmission(mutation, body) {
36906
36908
  const prId = getCurrentPrNodeId();
36907
36909
  runGhGraphql(mutation, { prId, body });
36908
36910
  console.log("Submitted review.");
36911
+ return true;
36909
36912
  } catch (error) {
36910
36913
  if (isGhNotInstalled(error)) {
36911
36914
  console.error("Error: GitHub CLI (gh) is not installed.");
36912
- return;
36915
+ return false;
36913
36916
  }
36914
36917
  const message3 = error instanceof Error ? error.message : String(error);
36915
36918
  console.error(`Failed to submit review: ${message3}`);
36919
+ return false;
36916
36920
  }
36917
36921
  }
36918
36922
 
36919
36923
  // src/commands/review/submitBodyOnlyReview.ts
36920
36924
  var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
36921
36925
  function submitBodyOnlyReview(body) {
36922
- runReviewSubmission(MUTATION6, body);
36926
+ return runReviewSubmission(MUTATION6, body);
36923
36927
  }
36924
36928
 
36925
36929
  // src/commands/review/submitFailedReview.ts
@@ -38468,12 +38472,6 @@ async function postFindings(findings) {
38468
38472
  return { posted, failed: failed3 };
38469
38473
  }
38470
38474
 
38471
- // src/commands/review/submitPendingReview.ts
38472
- var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
38473
- function submitPendingReview(body) {
38474
- runReviewSubmission(MUTATION7, body);
38475
- }
38476
-
38477
38475
  // src/commands/review/buildReviewBody.ts
38478
38476
  function buildReviewBody(markdown, unanchored, ciFooter) {
38479
38477
  return appendCiFooter(
@@ -38482,11 +38480,23 @@ function buildReviewBody(markdown, unanchored, ciFooter) {
38482
38480
  );
38483
38481
  }
38484
38482
 
38485
- // src/commands/review/postAndMaybeSubmit.ts
38486
- function submitReview(body, posted) {
38487
- if (posted > 0) submitPendingReview(body);
38488
- else submitBodyOnlyReview(body);
38483
+ // src/commands/review/submitPendingReview.ts
38484
+ var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
38485
+ function submitPendingReview(body) {
38486
+ return runReviewSubmission(MUTATION7, body);
38489
38487
  }
38488
+
38489
+ // src/commands/review/submitReview.ts
38490
+ function submitReview(body, result) {
38491
+ if (result.posted > 0) return submitPendingReview(body);
38492
+ if (submitPendingLeftByFailedThreads(body, result)) return true;
38493
+ return submitBodyOnlyReview(body);
38494
+ }
38495
+ function submitPendingLeftByFailedThreads(body, result) {
38496
+ return result.failed > 0 && submitPendingReview(body);
38497
+ }
38498
+
38499
+ // src/commands/review/postAndMaybeSubmit.ts
38490
38500
  async function decideSubmit(options2) {
38491
38501
  if (!options2.prompt) return options2.submit;
38492
38502
  await setSessionStatus("waiting");
@@ -38505,11 +38515,13 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
38505
38515
  return { posted: 0, submitted: false };
38506
38516
  const shouldSubmit = await decideSubmit(options2);
38507
38517
  if (shouldSubmit) {
38508
- submitReview(
38518
+ const submitted = submitReview(
38509
38519
  buildReviewBody(markdown, unanchored, options2.ciFooter),
38510
- result.posted
38520
+ result
38511
38521
  );
38512
- return { posted: result.posted, submitted: true };
38522
+ if (!submitted && options2.ciFooter)
38523
+ throw new Error("the review could not be submitted to the PR");
38524
+ return { posted: result.posted, submitted };
38513
38525
  }
38514
38526
  console.log("Leaving the review unsubmitted.");
38515
38527
  return { posted: result.posted, submitted: false };
@@ -43610,6 +43622,7 @@ function toSessionInfo(session) {
43610
43622
  harnessSessionId,
43611
43623
  restored,
43612
43624
  autoAdvance,
43625
+ autoStart,
43613
43626
  starred,
43614
43627
  design,
43615
43628
  verifying,
@@ -43635,6 +43648,7 @@ function toSessionInfo(session) {
43635
43648
  repoGroup: repoGroupForCwd(cwd),
43636
43649
  restored,
43637
43650
  autoAdvance,
43651
+ autoStart,
43638
43652
  starred,
43639
43653
  design,
43640
43654
  verifying,
@@ -43879,6 +43893,13 @@ function setAutoAdvance(sessions, id, enabled) {
43879
43893
  daemonLog(`session ${id} autoadvance ${enabled ? "on" : "off"}`);
43880
43894
  return true;
43881
43895
  }
43896
+ function setAutoStart(sessions, id, enabled) {
43897
+ const s = sessions.get(id);
43898
+ if (!s) return false;
43899
+ s.autoStart = enabled;
43900
+ daemonLog(`session ${id} autostart ${enabled ? "on" : "off"}`);
43901
+ return true;
43902
+ }
43882
43903
 
43883
43904
  // src/commands/sessions/daemon/SessionIo.ts
43884
43905
  var SessionIo = class {
@@ -45339,6 +45360,22 @@ function decidePrPreview(sessions, waiters, notify2, d) {
45339
45360
  notify2();
45340
45361
  }
45341
45362
 
45363
+ // src/commands/sessions/daemon/autoStartPreview.ts
45364
+ function autoStartPreview(sessions, waiters, notify2, session) {
45365
+ const preview = session.pendingPrPreview;
45366
+ if (!session.autoStart || !preview?.canStart) return false;
45367
+ daemonLog(
45368
+ `pr-preview auto-start: id=${session.id} requestId=${preview.requestId} (approving with autostart)`
45369
+ );
45370
+ decidePrPreview(sessions, waiters, notify2, {
45371
+ sessionId: session.id,
45372
+ requestId: preview.requestId,
45373
+ decision: "approve",
45374
+ autostart: true
45375
+ });
45376
+ return true;
45377
+ }
45378
+
45342
45379
  // src/commands/sessions/daemon/parsePreviewMetadata.ts
45343
45380
  function parsePreviewMetadata(value) {
45344
45381
  if (!Array.isArray(value)) return void 0;
@@ -45458,6 +45495,7 @@ function setPrPreview(sessions, waiters, notify2, client, d) {
45458
45495
  daemonLog(
45459
45496
  `pr-preview set: id=${id} requestId=${d.requestId} kind=${kind} target=${target} screenshots=${session.pendingPrPreview.screenshots?.length ?? 0}`
45460
45497
  );
45498
+ if (autoStartPreview(sessions, waiters, notify2, session)) return;
45461
45499
  notify2();
45462
45500
  }
45463
45501
 
@@ -47247,6 +47285,7 @@ function restoreBase(id, persisted) {
47247
47285
  design: persisted.design,
47248
47286
  auto: persisted.auto,
47249
47287
  autoAdvance: restoredAutoAdvance(id, persisted),
47288
+ autoStart: persisted.autoStart,
47250
47289
  reviewStarted: persisted.reviewStarted,
47251
47290
  launchedFrom: persisted.launchedFrom
47252
47291
  };
@@ -49836,6 +49875,15 @@ var sessionSettingHandlers = {
49836
49875
  )
49837
49876
  )
49838
49877
  ),
49878
+ "set-autostart": routed(
49879
+ (_client, m, d) => m.update(
49880
+ (sessions) => setAutoStart(
49881
+ sessions,
49882
+ d.sessionId,
49883
+ d.enabled
49884
+ )
49885
+ )
49886
+ ),
49839
49887
  rename: routed(
49840
49888
  (_client, m, d) => m.setTitle(d.sessionId, d.title ?? "")
49841
49889
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.848.0",
3
+ "version": "0.850.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {