@staff0rd/assist 0.865.0 → 0.865.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.865.0",
9
+ version: "0.865.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -27643,9 +27643,10 @@ function spawnInstall(worktreePath, cwd, command, where, onDone) {
27643
27643
  }
27644
27644
 
27645
27645
  // src/commands/sessions/daemon/worktree/runInstall.ts
27646
- function runInstall(worktreePath, clone, install, onSeeded) {
27646
+ function runInstall(worktreePath, clone, install, onSeeded, onInstalling = () => {
27647
+ }) {
27647
27648
  if (Array.isArray(install)) {
27648
- installPaths(worktreePath, install, onSeeded);
27649
+ installPaths(worktreePath, install, onSeeded, onInstalling);
27649
27650
  return;
27650
27651
  }
27651
27652
  const command = resolveInstallCommand(clone, install);
@@ -27653,9 +27654,10 @@ function runInstall(worktreePath, clone, install, onSeeded) {
27653
27654
  onSeeded();
27654
27655
  return;
27655
27656
  }
27657
+ onInstalling();
27656
27658
  spawnInstall(worktreePath, worktreePath, command, "", () => onSeeded());
27657
27659
  }
27658
- function installPaths(worktreePath, paths, onSeeded) {
27660
+ function installPaths(worktreePath, paths, onSeeded, onInstalling) {
27659
27661
  const next3 = (index2) => {
27660
27662
  const rel = paths[index2];
27661
27663
  if (rel === void 0) {
@@ -27671,6 +27673,7 @@ function installPaths(worktreePath, paths, onSeeded) {
27671
27673
  onSeeded();
27672
27674
  return;
27673
27675
  }
27676
+ onInstalling(rel);
27674
27677
  spawnInstall(worktreePath, dir, command, ` in ${rel}`, (outcome) => {
27675
27678
  if (outcome.ok && !outcome.stopped) {
27676
27679
  next3(index2 + 1);
@@ -27688,10 +27691,10 @@ function installPaths(worktreePath, paths, onSeeded) {
27688
27691
 
27689
27692
  // src/commands/sessions/daemon/worktree/seedWorktree.ts
27690
27693
  function seedWorktree(worktreePath, clone, onSeeded = () => {
27691
- }) {
27694
+ }, onInstalling) {
27692
27695
  const cfg = worktreeConfigFor(clone);
27693
27696
  copyConfigFiles(worktreePath, clone, cfg.copy);
27694
- runInstall(worktreePath, clone, cfg.install, onSeeded);
27697
+ runInstall(worktreePath, clone, cfg.install, onSeeded, onInstalling);
27695
27698
  }
27696
27699
  function copyConfigFiles(worktreePath, clone, copy) {
27697
27700
  for (const rel of copy) {
@@ -27788,22 +27791,27 @@ async function reportCwdToDaemon(cwd) {
27788
27791
  }
27789
27792
  }
27790
27793
 
27791
- // src/commands/review/worktreeHoldingBranch.ts
27792
- function worktreeHoldingBranch(cwd, branch2) {
27793
- const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
27794
- if (!listing) return null;
27795
- const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
27794
+ // src/commands/sessions/daemon/worktree/worktreeWithBranch.ts
27795
+ function worktreeWithBranch(listing, branch2) {
27796
27796
  let path109 = null;
27797
27797
  for (const line of listing.split("\n")) {
27798
27798
  const trimmed = line.trim();
27799
27799
  if (trimmed.startsWith("worktree "))
27800
27800
  path109 = trimmed.slice("worktree ".length).trim();
27801
- else if (trimmed === `branch refs/heads/${branch2}`)
27802
- return path109 && path109 !== here ? path109 : null;
27801
+ else if (trimmed === `branch refs/heads/${branch2}`) return path109;
27803
27802
  }
27804
27803
  return null;
27805
27804
  }
27806
27805
 
27806
+ // src/commands/review/worktreeHoldingBranch.ts
27807
+ function worktreeHoldingBranch(cwd, branch2) {
27808
+ const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
27809
+ if (!listing) return null;
27810
+ const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
27811
+ const path109 = worktreeWithBranch(listing, branch2);
27812
+ return path109 && path109 !== here ? path109 : null;
27813
+ }
27814
+
27807
27815
  // src/commands/review/checkoutPr.ts
27808
27816
  function currentBranch4() {
27809
27817
  return gitSyncOrNull(process.cwd(), ["rev-parse", "--abbrev-ref", "HEAD"]);
@@ -43862,6 +43870,7 @@ function toSessionInfo(session) {
43862
43870
  starred,
43863
43871
  design,
43864
43872
  verifying,
43873
+ seeding,
43865
43874
  pendingPrPreview,
43866
43875
  undurable,
43867
43876
  lastUserMessage,
@@ -43888,6 +43897,7 @@ function toSessionInfo(session) {
43888
43897
  starred,
43889
43898
  design,
43890
43899
  verifying,
43900
+ seeding,
43891
43901
  pendingPrPreview,
43892
43902
  undurable,
43893
43903
  lastUserMessage,
@@ -44720,7 +44730,18 @@ function bindNewWorktree(session, alloc, notify2, startHeld = () => {
44720
44730
  return;
44721
44731
  session.worktree = { path: alloc.cwd, clone: alloc.clone };
44722
44732
  if (alloc.created)
44723
- seedWorktree(alloc.cwd, alloc.clone, () => startHeld(session));
44733
+ seedWorktree(
44734
+ alloc.cwd,
44735
+ alloc.clone,
44736
+ () => {
44737
+ session.seeding = void 0;
44738
+ startHeld(session);
44739
+ },
44740
+ (path109) => {
44741
+ session.seeding = `Installing dependencies${path109 ? ` in ${path109}` : ""}\u2026`;
44742
+ notify2();
44743
+ }
44744
+ );
44724
44745
  notify2();
44725
44746
  }
44726
44747
  function bindRestoredWorktrees(sessions) {
@@ -49310,16 +49331,21 @@ function isBacklogRunArgs(args) {
49310
49331
  return rest.some((arg) => ITEM_ID.test(arg));
49311
49332
  }
49312
49333
 
49313
- // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
49334
+ // src/commands/sessions/daemon/worktree/prCheckoutNumber.ts
49314
49335
  var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
49315
49336
  "review",
49316
49337
  "review-pr-comments",
49317
49338
  "fix-conflict"
49318
49339
  ]);
49319
- function isPrCheckoutArgs(args) {
49340
+ function prCheckoutNumber(args) {
49320
49341
  const [command, ...rest] = args;
49321
- if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
49322
- return rest.some((arg) => /^[1-9]\d*$/.test(arg));
49342
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return void 0;
49343
+ return rest.find((arg) => /^[1-9]\d*$/.test(arg));
49344
+ }
49345
+
49346
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
49347
+ function isPrCheckoutArgs(args) {
49348
+ return prCheckoutNumber(args) !== void 0;
49323
49349
  }
49324
49350
 
49325
49351
  // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
@@ -49974,15 +50000,27 @@ async function handleSearchHistory(client, data) {
49974
50000
 
49975
50001
  // src/commands/sessions/daemon/creator.ts
49976
50002
  function creator(isNew, spawn12) {
49977
- return (client, m, d) => {
49978
- if (m.links.route(client, d)) return;
49979
- const result = spawn12(m, d);
50003
+ const reply2 = (client, result) => {
49980
50004
  if (typeof result !== "string") {
49981
50005
  sendTo(client, { type: "error", message: result.error });
49982
50006
  return;
49983
50007
  }
49984
50008
  sendTo(client, { type: "created", sessionId: result, isNew });
49985
50009
  };
50010
+ return (client, m, d) => {
50011
+ if (m.links.route(client, d)) return;
50012
+ const result = spawn12(m, d);
50013
+ if (result instanceof Promise)
50014
+ result.then(
50015
+ (resolved) => reply2(client, resolved),
50016
+ (error) => {
50017
+ const reason4 = error instanceof Error ? error.message : String(error);
50018
+ daemonLog(`${d.type} failed: ${reason4}`);
50019
+ reply2(client, { error: `${d.type} failed: ${reason4}` });
50020
+ }
50021
+ );
50022
+ else reply2(client, result);
50023
+ };
49986
50024
  }
49987
50025
 
49988
50026
  // src/commands/sessions/shared/codex/codexRolloutUsage.ts
@@ -50415,6 +50453,52 @@ var sessionSettingHandlers = {
50415
50453
  )
50416
50454
  };
50417
50455
 
50456
+ // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
50457
+ import { execFile as execFile13 } from "child_process";
50458
+ import { existsSync as existsSync100 } from "fs";
50459
+ function prHeadBranch2(number, cwd) {
50460
+ return new Promise((resolve30) => {
50461
+ execFile13(
50462
+ "gh",
50463
+ ["pr", "view", number, "--json", "headRefName", "-q", ".headRefName"],
50464
+ { cwd, encoding: "utf8", windowsHide: true },
50465
+ (error, stdout) => resolve30(error ? null : stdout.trim() || null)
50466
+ );
50467
+ });
50468
+ }
50469
+ async function prCheckoutHolder(assistArgs, cwd) {
50470
+ const number = prCheckoutNumber(assistArgs);
50471
+ if (!number || !cwd || !existsSync100(cwd)) return void 0;
50472
+ const headRef = await prHeadBranch2(number, cwd);
50473
+ if (!headRef) return void 0;
50474
+ const listing = await gitOrNull(cwd, ["worktree", "list", "--porcelain"]);
50475
+ const holder = listing ? worktreeWithBranch(listing, headRef) : null;
50476
+ if (!holder || !existsSync100(holder)) return void 0;
50477
+ daemonLog(
50478
+ `pr #${number} assist ${assistArgs[0]} launched in its checkout ${holder}: head branch ${headRef} is already checked out there, so no worktree is allocated`
50479
+ );
50480
+ return holder;
50481
+ }
50482
+
50483
+ // src/commands/sessions/daemon/spawnAssistCreate.ts
50484
+ function spawnAssistCreate(m, d) {
50485
+ const assistArgs = d.assistArgs ?? [];
50486
+ const cwd = d.cwd;
50487
+ const inPlace = d.inPlace === true;
50488
+ const spawn12 = (holder) => m.spawnAssist(
50489
+ assistArgs,
50490
+ holder ?? cwd,
50491
+ {
50492
+ title: d.title,
50493
+ subtitle: d.subtitle,
50494
+ inPlace: inPlace || holder !== void 0
50495
+ },
50496
+ spawnContextFrom(d)
50497
+ );
50498
+ if (inPlace || !isPrCheckoutArgs(assistArgs)) return spawn12();
50499
+ return prCheckoutHolder(assistArgs, cwd).then(spawn12);
50500
+ }
50501
+
50418
50502
  // src/commands/sessions/daemon/spawnCreate.ts
50419
50503
  function spawnCreate(m, d) {
50420
50504
  const design = d.design === true;
@@ -50461,19 +50545,7 @@ var messageHandlers = {
50461
50545
  },
50462
50546
  create: creator(true, spawnCreate),
50463
50547
  "create-run": handleCreateRun,
50464
- "create-assist": creator(
50465
- true,
50466
- (m, d) => m.spawnAssist(
50467
- d.assistArgs ?? [],
50468
- d.cwd,
50469
- {
50470
- title: d.title,
50471
- subtitle: d.subtitle,
50472
- inPlace: d.inPlace === true
50473
- },
50474
- spawnContextFrom(d)
50475
- )
50476
- ),
50548
+ "create-assist": creator(true, spawnAssistCreate),
50477
50549
  resume: creator(
50478
50550
  false,
50479
50551
  (m, d) => m.resume(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.865.0",
3
+ "version": "0.865.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {