@staff0rd/assist 0.915.1 → 0.917.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.915.1",
9
+ version: "0.917.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -1306,6 +1306,7 @@ var assistConfigShape = {
1306
1306
  includeCommittedChanges: z6.boolean().default(true),
1307
1307
  floatWaiting: z6.boolean().default(true),
1308
1308
  floatWaitingAfterMs: z6.number().default(5e3),
1309
+ parkWaitingAfterMs: z6.number().default(3e5),
1309
1310
  maxLive: z6.number().default(24),
1310
1311
  newSessionMode: z6.enum(["draft", "bug", "prompt", "design"]).default("draft"),
1311
1312
  hotkeys: hotkeysSchema.optional()
@@ -6396,6 +6397,11 @@ var sessionsConfigHelp = [
6396
6397
  setter: "assist config set sessions.floatWaitingAfterMs 15000 -g",
6397
6398
  note: "how long a session must have been waiting on input before it floats (default: 5000ms)"
6398
6399
  },
6400
+ {
6401
+ key: "sessions.parkWaitingAfterMs",
6402
+ setter: "assist config set sessions.parkWaitingAfterMs 600000 -g",
6403
+ note: "how long every session in a repo group must have been waiting on input before the group collapses and parks at the bottom of the sidebar (default: 300000ms)"
6404
+ },
6399
6405
  {
6400
6406
  key: "sessions.maxLive",
6401
6407
  setter: "assist config set sessions.maxLive 24 -g",
@@ -10333,7 +10339,8 @@ async function nodeDoctor(req, res) {
10333
10339
  // src/commands/sessions/shared/sessionViewDefaults.ts
10334
10340
  var sessionViewDefaults = {
10335
10341
  floatWaiting: true,
10336
- floatWaitingAfterMs: 5e3
10342
+ floatWaitingAfterMs: 5e3,
10343
+ parkWaitingAfterMs: 3e5
10337
10344
  };
10338
10345
 
10339
10346
  // src/commands/sessions/web/sessionView.ts
@@ -10341,7 +10348,8 @@ function sessionView(_req, res) {
10341
10348
  const sessions = loadConfig().sessions;
10342
10349
  respondJson(res, 200, {
10343
10350
  floatWaiting: sessions?.floatWaiting ?? sessionViewDefaults.floatWaiting,
10344
- floatWaitingAfterMs: sessions?.floatWaitingAfterMs ?? sessionViewDefaults.floatWaitingAfterMs
10351
+ floatWaitingAfterMs: sessions?.floatWaitingAfterMs ?? sessionViewDefaults.floatWaitingAfterMs,
10352
+ parkWaitingAfterMs: sessions?.parkWaitingAfterMs ?? sessionViewDefaults.parkWaitingAfterMs
10345
10353
  });
10346
10354
  }
10347
10355
 
@@ -27267,11 +27275,8 @@ function fetchQuietly(cwd, intervalMs) {
27267
27275
  }
27268
27276
  }
27269
27277
 
27270
- // src/commands/sessions/daemon/worktree/planAllocation.ts
27278
+ // src/commands/sessions/daemon/worktree/nextWorktreePath.ts
27271
27279
  import { basename as basename18, join as join70 } from "path";
27272
- function planAllocation(clone, boundTreeRoots2) {
27273
- return boundTreeRoots2.has(clone) ? "spill" : "primary";
27274
- }
27275
27280
  function nextWorktreePath(clone, base, isTaken) {
27276
27281
  const name = basename18(clone);
27277
27282
  for (let n = 2; n < 1e3; n++) {
@@ -27328,81 +27333,6 @@ function keptInTree(cwd, reason4) {
27328
27333
  return { cwd, kind: "primary", created: false };
27329
27334
  }
27330
27335
 
27331
- // src/commands/sessions/daemon/worktree/treeDurability.ts
27332
- import { existsSync as existsSync60 } from "fs";
27333
- var treeIsGone = { durable: true, gone: true };
27334
- function treeDurability(state) {
27335
- if (state.dirty) return { durable: false, reason: "uncommitted changes" };
27336
- if (state.localOnlyCommits)
27337
- return { durable: false, reason: "unpushed commits" };
27338
- return { durable: true };
27339
- }
27340
- function* durabilityProbes() {
27341
- const status2 = yield ["status", "--porcelain"];
27342
- if (!status2.ok)
27343
- return { durable: false, reason: `tree state unreadable: ${status2.error}` };
27344
- const dirty = status2.out !== "";
27345
- const upstream = yield [
27346
- "rev-parse",
27347
- "--abbrev-ref",
27348
- "--symbolic-full-name",
27349
- "@{upstream}"
27350
- ];
27351
- if (upstream.ok && upstream.out) {
27352
- const ahead = yield ["rev-list", "--count", "@{upstream}..HEAD"];
27353
- if (ahead.ok && Number(ahead.out) === 0)
27354
- return treeDurability({ dirty, localOnlyCommits: false });
27355
- }
27356
- const remoteBranches = yield ["branch", "-r", "--contains", "HEAD"];
27357
- return treeDurability({
27358
- dirty,
27359
- localOnlyCommits: !remoteBranches.ok || remoteBranches.out === ""
27360
- });
27361
- }
27362
- async function checkDurability(cwd) {
27363
- if (!existsSync60(cwd)) return treeIsGone;
27364
- const probes = durabilityProbes();
27365
- let step3 = probes.next();
27366
- while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
27367
- return step3.value;
27368
- }
27369
- function checkDurabilitySync(cwd) {
27370
- if (!existsSync60(cwd)) return treeIsGone;
27371
- const probes = durabilityProbes();
27372
- let step3 = probes.next();
27373
- while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
27374
- return step3.value;
27375
- }
27376
-
27377
- // src/commands/sessions/daemon/worktree/reusesClone.ts
27378
- function reusesClone(clone, boundTreeRoots2, options2) {
27379
- if (planAllocation(clone, boundTreeRoots2) !== "primary") {
27380
- daemonLog(
27381
- `clone ${clone} is held by a live session \u2014 spilling to a worktree`
27382
- );
27383
- return false;
27384
- }
27385
- if (wouldDisturbWorkInProgress(clone, options2.forCheckout === true))
27386
- return false;
27387
- daemonLog(
27388
- `session kept in the clone ${clone}: no live session holds it${describeHolders(boundTreeRoots2)}`
27389
- );
27390
- return true;
27391
- }
27392
- function describeHolders(boundTreeRoots2) {
27393
- if (boundTreeRoots2.size === 0) return " and no tree is bound";
27394
- return ` (bound trees: ${[...boundTreeRoots2].join(", ")})`;
27395
- }
27396
- function wouldDisturbWorkInProgress(clone, forCheckout) {
27397
- if (!forCheckout) return false;
27398
- const durability = checkDurabilitySync(clone);
27399
- if (durability.durable) return false;
27400
- daemonLog(
27401
- `tree ${clone} not used for a PR checkout: ${durability.reason} \u2014 spilling to a worktree`
27402
- );
27403
- return true;
27404
- }
27405
-
27406
27336
  // src/commands/sessions/daemon/worktree/worktreeConfigFor.ts
27407
27337
  var DISABLED = {
27408
27338
  enabled: false,
@@ -27419,19 +27349,6 @@ function worktreeConfigFor(cwd) {
27419
27349
  }
27420
27350
  }
27421
27351
 
27422
- // src/commands/sessions/daemon/worktree/forcedSpillReason.ts
27423
- function forcedSpillReason(clone, trunk, options2) {
27424
- if (options2.replacesTree)
27425
- return `resumed session spilled out of the clone ${clone}: its worktree ${options2.replacesTree} is gone`;
27426
- if (options2.backlogRun === true)
27427
- return `backlog run spilled out of the clone ${clone}: backlog runs never use the clone`;
27428
- if (trunk === true && options2.commits === true)
27429
- return `committing session spilled out of the clone ${clone}: worktree.trunk is on, so a commit here would land on the local mainline`;
27430
- if (options2.assistCommand !== void 0)
27431
- return `assist ${options2.assistCommand} session spilled out of the clone ${clone}: only prompt sessions use the clone`;
27432
- return void 0;
27433
- }
27434
-
27435
27352
  // src/commands/sessions/daemon/worktree/allocateTree.ts
27436
27353
  function allocateTree(requestedCwd, boundTreeRoots2, options2 = {}) {
27437
27354
  if (!requestedCwd)
@@ -27451,16 +27368,15 @@ function allocateTree(requestedCwd, boundTreeRoots2, options2 = {}) {
27451
27368
  `worktree.enabled is off for ${repoRoot2}, so every session shares this tree`
27452
27369
  );
27453
27370
  const clone = canonicalTreePath(mainWorktree(repoRoot2) ?? repoRoot2);
27454
- const forcedSpill = forcedSpillReason(clone, cfg.trunk, options2);
27455
- if (forcedSpill) daemonLog(forcedSpill);
27456
- else if (reusesClone(clone, boundTreeRoots2, options2))
27457
- return { cwd: clone, kind: "primary", created: false, clone };
27458
27371
  const path108 = createWorktree(
27459
27372
  clone,
27460
27373
  { root: cfg.root, trunk: cfg.trunk },
27461
27374
  boundTreeRoots2,
27462
27375
  options2.replacesTree
27463
27376
  );
27377
+ daemonLog(
27378
+ `session spilled out of the clone ${clone} into ${path108}: worktree.enabled is on, so every session gets its own worktree`
27379
+ );
27464
27380
  return { cwd: path108, kind: "worktree", created: true, clone };
27465
27381
  }
27466
27382
 
@@ -27616,20 +27532,20 @@ function persistedTreeRoots() {
27616
27532
  }
27617
27533
 
27618
27534
  // src/commands/sessions/daemon/worktree/seedWorktree.ts
27619
- import { copyFileSync, existsSync as existsSync62, mkdirSync as mkdirSync19 } from "fs";
27535
+ import { copyFileSync, existsSync as existsSync61, mkdirSync as mkdirSync19 } from "fs";
27620
27536
  import { dirname as dirname32, join as join72 } from "path";
27621
27537
 
27622
27538
  // src/commands/sessions/daemon/worktree/runInstall.ts
27623
27539
  import { resolve as resolve18 } from "path";
27624
27540
 
27625
27541
  // src/commands/sessions/daemon/worktree/detectInstallCommand.ts
27626
- import { existsSync as existsSync61 } from "fs";
27542
+ import { existsSync as existsSync60 } from "fs";
27627
27543
  import { join as join71 } from "path";
27628
27544
  function detectInstallCommand(dir) {
27629
- if (!existsSync61(join71(dir, "package.json"))) return null;
27630
- if (existsSync61(join71(dir, "pnpm-lock.yaml"))) return "pnpm install";
27631
- if (existsSync61(join71(dir, "yarn.lock"))) return "yarn install";
27632
- if (existsSync61(join71(dir, "bun.lockb"))) return "bun install";
27545
+ if (!existsSync60(join71(dir, "package.json"))) return null;
27546
+ if (existsSync60(join71(dir, "pnpm-lock.yaml"))) return "pnpm install";
27547
+ if (existsSync60(join71(dir, "yarn.lock"))) return "yarn install";
27548
+ if (existsSync60(join71(dir, "bun.lockb"))) return "bun install";
27633
27549
  return "npm install";
27634
27550
  }
27635
27551
 
@@ -27795,7 +27711,7 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
27795
27711
  function copyConfigFiles(worktreePath, clone, copy) {
27796
27712
  for (const rel of copy) {
27797
27713
  const src = join72(clone, rel);
27798
- if (!existsSync62(src)) continue;
27714
+ if (!existsSync61(src)) continue;
27799
27715
  const dest = join72(worktreePath, rel);
27800
27716
  try {
27801
27717
  mkdirSync19(dirname32(dest), { recursive: true });
@@ -27825,10 +27741,7 @@ function seed(worktreePath, clone) {
27825
27741
  async function moveToPrCheckoutTree() {
27826
27742
  if (placedByDaemon()) return;
27827
27743
  const from = process.cwd();
27828
- const alloc = allocateTree(from, persistedTreeRoots(), {
27829
- forCheckout: true,
27830
- commits: true
27831
- });
27744
+ const alloc = allocateTree(from, persistedTreeRoots());
27832
27745
  if (!alloc.cwd || alloc.cwd === from) return;
27833
27746
  process.chdir(alloc.cwd);
27834
27747
  console.log(`Checking the PR out in ${alloc.cwd}`);
@@ -28406,10 +28319,10 @@ function applyIgnore(texts, ignore3) {
28406
28319
  }
28407
28320
 
28408
28321
  // src/commands/miro/readIgnoreList.ts
28409
- import { existsSync as existsSync63, readFileSync as readFileSync42 } from "fs";
28322
+ import { existsSync as existsSync62, readFileSync as readFileSync42 } from "fs";
28410
28323
  import { parse as parse2 } from "yaml";
28411
28324
  function readIgnoreList(file) {
28412
- if (!existsSync63(file))
28325
+ if (!existsSync62(file))
28413
28326
  throw new MiroExtractError(
28414
28327
  `No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
28415
28328
  );
@@ -29854,7 +29767,7 @@ import { execSync as execSync40 } from "child_process";
29854
29767
  import { execFileSync as execFileSync19 } from "child_process";
29855
29768
 
29856
29769
  // src/commands/prs/loadCommentsCache.ts
29857
- import { existsSync as existsSync64, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
29770
+ import { existsSync as existsSync63, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
29858
29771
  import { parse as parse3 } from "yaml";
29859
29772
 
29860
29773
  // src/commands/prs/commentsCachePath.ts
@@ -29874,7 +29787,7 @@ function commentsCachePath(org, repo, prNumber) {
29874
29787
  // src/commands/prs/loadCommentsCache.ts
29875
29788
  function loadCommentsCache(org, repo, prNumber) {
29876
29789
  const cachePath = commentsCachePath(org, repo, prNumber);
29877
- if (!existsSync64(cachePath)) {
29790
+ if (!existsSync63(cachePath)) {
29878
29791
  return null;
29879
29792
  }
29880
29793
  const content = readFileSync45(cachePath, "utf8");
@@ -29882,7 +29795,7 @@ function loadCommentsCache(org, repo, prNumber) {
29882
29795
  }
29883
29796
  function deleteCommentsCache(org, repo, prNumber) {
29884
29797
  const cachePath = commentsCachePath(org, repo, prNumber);
29885
- if (existsSync64(cachePath)) {
29798
+ if (existsSync63(cachePath)) {
29886
29799
  unlinkSync13(cachePath);
29887
29800
  console.log("No more unresolved line comments. Cache dropped.");
29888
29801
  }
@@ -32793,7 +32706,7 @@ async function notify() {
32793
32706
 
32794
32707
  // src/commands/screenshot.ts
32795
32708
  import { execSync as execSync49 } from "child_process";
32796
- import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as writeFileSync37 } from "fs";
32709
+ import { existsSync as existsSync64, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as writeFileSync37 } from "fs";
32797
32710
  import { tmpdir as tmpdir6 } from "os";
32798
32711
  import { join as join80, resolve as resolve24 } from "path";
32799
32712
  import chalk208 from "chalk";
@@ -32925,7 +32838,7 @@ Write-Output $OutputPath
32925
32838
 
32926
32839
  // src/commands/screenshot.ts
32927
32840
  function buildOutputPath(outputDir, processName) {
32928
- if (!existsSync65(outputDir)) {
32841
+ if (!existsSync64(outputDir)) {
32929
32842
  mkdirSync23(outputDir, { recursive: true });
32930
32843
  }
32931
32844
  const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
@@ -36383,9 +36296,9 @@ function highLevelDraftPath(repo, headRef, headSha) {
36383
36296
  }
36384
36297
 
36385
36298
  // src/commands/review/highLevel/readJsonFile.ts
36386
- import { existsSync as existsSync66, readFileSync as readFileSync49 } from "fs";
36299
+ import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
36387
36300
  function readJsonFile(path108) {
36388
- if (!existsSync66(path108)) return void 0;
36301
+ if (!existsSync65(path108)) return void 0;
36389
36302
  try {
36390
36303
  return JSON.parse(readFileSync49(path108, "utf8"));
36391
36304
  } catch {
@@ -38241,7 +38154,7 @@ async function runClaudeReviewer(spec) {
38241
38154
  }
38242
38155
 
38243
38156
  // src/commands/review/runCodexReviewer.ts
38244
- import { existsSync as existsSync67, unlinkSync as unlinkSync16 } from "fs";
38157
+ import { existsSync as existsSync66, unlinkSync as unlinkSync16 } from "fs";
38245
38158
 
38246
38159
  // src/commands/review/parseCodexUsage.ts
38247
38160
  function parseCodexUsage(usage) {
@@ -38330,7 +38243,7 @@ async function runCodexReviewer(spec) {
38330
38243
  ...override.args.length > 0 ? { env: override.env } : {},
38331
38244
  onLine
38332
38245
  });
38333
- if (result.exitCode !== 0 && existsSync67(spec.outputPath)) {
38246
+ if (result.exitCode !== 0 && existsSync66(spec.outputPath)) {
38334
38247
  unlinkSync16(spec.outputPath);
38335
38248
  }
38336
38249
  const finalised = finaliseReviewerRun(
@@ -38421,7 +38334,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
38421
38334
  }
38422
38335
 
38423
38336
  // src/commands/review/synthesiseAfterReviewers.ts
38424
- import { existsSync as existsSync68, unlinkSync as unlinkSync17 } from "fs";
38337
+ import { existsSync as existsSync67, unlinkSync as unlinkSync17 } from "fs";
38425
38338
 
38426
38339
  // src/commands/review/synthesise.ts
38427
38340
  import { readFileSync as readFileSync51 } from "fs";
@@ -38528,7 +38441,7 @@ async function synthesise(paths, options2) {
38528
38441
  // src/commands/review/synthesiseAfterReviewers.ts
38529
38442
  async function synthesiseAfterReviewers(input) {
38530
38443
  const { paths, failures } = input;
38531
- if (input.anyFresh && existsSync68(paths.synthesisPath)) {
38444
+ if (input.anyFresh && existsSync67(paths.synthesisPath)) {
38532
38445
  unlinkSync17(paths.synthesisPath);
38533
38446
  }
38534
38447
  const synthesisResult = await synthesise(paths, {
@@ -38809,10 +38722,10 @@ function fetchExistingComments() {
38809
38722
  }
38810
38723
 
38811
38724
  // src/commands/review/prepareReviewDir.ts
38812
- import { existsSync as existsSync69, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
38725
+ import { existsSync as existsSync68, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
38813
38726
  function clearReviewFiles(paths) {
38814
38727
  for (const path108 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
38815
- if (existsSync69(path108)) unlinkSync18(path108);
38728
+ if (existsSync68(path108)) unlinkSync18(path108);
38816
38729
  }
38817
38730
  }
38818
38731
  function prepareReviewDir(paths, requestBody, force) {
@@ -39466,7 +39379,7 @@ function registerReview(program) {
39466
39379
  }
39467
39380
 
39468
39381
  // src/commands/rules/addRule.ts
39469
- import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync42 } from "fs";
39382
+ import { existsSync as existsSync71, readFileSync as readFileSync56, writeFileSync as writeFileSync42 } from "fs";
39470
39383
  import path87 from "path";
39471
39384
  import chalk242 from "chalk";
39472
39385
 
@@ -39523,7 +39436,7 @@ function nextRuleCode(root2) {
39523
39436
  }
39524
39437
 
39525
39438
  // src/commands/rules/resolveRuleScope.ts
39526
- import { existsSync as existsSync70 } from "fs";
39439
+ import { existsSync as existsSync69 } from "fs";
39527
39440
  import path84 from "path";
39528
39441
  function resolveRuleScope(target) {
39529
39442
  const resolved = path84.resolve(target);
@@ -39533,7 +39446,7 @@ function resolveRuleScope(target) {
39533
39446
  let current = startDir;
39534
39447
  while (true) {
39535
39448
  const candidate = path84.join(current, "CLAUDE.md");
39536
- if (existsSync70(candidate)) return candidate;
39449
+ if (existsSync69(candidate)) return candidate;
39537
39450
  if (current === root2 || current === path84.dirname(current)) break;
39538
39451
  current = path84.dirname(current);
39539
39452
  }
@@ -39541,7 +39454,7 @@ function resolveRuleScope(target) {
39541
39454
  }
39542
39455
 
39543
39456
  // src/commands/rules/updateScopedRulesIndex.ts
39544
- import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync41 } from "fs";
39457
+ import { existsSync as existsSync70, readFileSync as readFileSync55, writeFileSync as writeFileSync41 } from "fs";
39545
39458
  import path86 from "path";
39546
39459
 
39547
39460
  // src/commands/rules/scopedRuleDirectories.ts
@@ -39591,7 +39504,7 @@ function upsertScopedRulesPointer(content, directories) {
39591
39504
  function updateScopedRulesIndex(root2) {
39592
39505
  const directories = scopedRuleDirectories(root2);
39593
39506
  const rootFile = path86.join(root2, "CLAUDE.md");
39594
- const before = existsSync71(rootFile) ? readFileSync55(rootFile, "utf8") : "";
39507
+ const before = existsSync70(rootFile) ? readFileSync55(rootFile, "utf8") : "";
39595
39508
  const after = upsertScopedRulesPointer(before, directories);
39596
39509
  if (after !== before) writeFileSync41(rootFile, after);
39597
39510
  return directories;
@@ -39599,7 +39512,7 @@ function updateScopedRulesIndex(root2) {
39599
39512
 
39600
39513
  // src/commands/rules/addRule.ts
39601
39514
  function read2(file) {
39602
- return existsSync72(file) ? readFileSync56(file, "utf8") : "";
39515
+ return existsSync71(file) ? readFileSync56(file, "utf8") : "";
39603
39516
  }
39604
39517
  function addRule(text17, options2) {
39605
39518
  const rule = text17.trim();
@@ -41011,7 +40924,7 @@ function registerSync(program) {
41011
40924
  }
41012
40925
 
41013
40926
  // src/commands/transcript/clean.ts
41014
- import { existsSync as existsSync77 } from "fs";
40927
+ import { existsSync as existsSync76 } from "fs";
41015
40928
 
41016
40929
  // src/commands/transcript/convert/formatTimestamp.ts
41017
40930
  function pad(value, width2) {
@@ -41289,7 +41202,7 @@ function clean(file, options2 = {}) {
41289
41202
  );
41290
41203
  process.exit(1);
41291
41204
  }
41292
- if (!existsSync77(file)) {
41205
+ if (!existsSync76(file)) {
41293
41206
  console.error(`Error: VTT file not found: ${file}`);
41294
41207
  process.exit(1);
41295
41208
  }
@@ -41372,11 +41285,11 @@ async function configure() {
41372
41285
  }
41373
41286
 
41374
41287
  // src/commands/transcript/list.ts
41375
- import { existsSync as existsSync78, readdirSync as readdirSync20, statSync as statSync12 } from "fs";
41288
+ import { existsSync as existsSync77, readdirSync as readdirSync20, statSync as statSync12 } from "fs";
41376
41289
  import { join as join97 } from "path";
41377
41290
  function list4() {
41378
41291
  const { vttDir } = getTranscriptConfig();
41379
- if (!existsSync78(vttDir)) return;
41292
+ if (!existsSync77(vttDir)) return;
41380
41293
  for (const entry of readdirSync20(vttDir)) {
41381
41294
  if (!entry.endsWith(".vtt")) continue;
41382
41295
  if (statSync12(join97(vttDir, entry)).isDirectory()) continue;
@@ -41385,7 +41298,7 @@ function list4() {
41385
41298
  }
41386
41299
 
41387
41300
  // src/commands/transcript/move.ts
41388
- import { existsSync as existsSync79, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as writeFileSync49 } from "fs";
41301
+ import { existsSync as existsSync78, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as writeFileSync49 } from "fs";
41389
41302
  import { basename as basename27, join as join98 } from "path";
41390
41303
 
41391
41304
  // src/commands/transcript/convertVttToMarkdown.ts
@@ -41409,7 +41322,7 @@ function move(file, options2) {
41409
41322
  const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
41410
41323
  const filename = basename27(file);
41411
41324
  const sourcePath = join98(vttDir, filename);
41412
- if (!existsSync79(sourcePath)) {
41325
+ if (!existsSync78(sourcePath)) {
41413
41326
  console.error(`Error: VTT file not found: ${sourcePath}`);
41414
41327
  process.exit(1);
41415
41328
  }
@@ -41426,7 +41339,7 @@ function move(file, options2) {
41426
41339
  }
41427
41340
 
41428
41341
  // src/commands/transcript/merge.ts
41429
- import { existsSync as existsSync80, writeFileSync as writeFileSync50 } from "fs";
41342
+ import { existsSync as existsSync79, writeFileSync as writeFileSync50 } from "fs";
41430
41343
  import { basename as basename28 } from "path";
41431
41344
 
41432
41345
  // src/commands/transcript/failTranscript.ts
@@ -41570,7 +41483,7 @@ function widenAudience(passages) {
41570
41483
 
41571
41484
  // src/commands/transcript/merge.ts
41572
41485
  function readSource3(file) {
41573
- if (!existsSync80(file)) failTranscript(`VTT file not found: ${file}`);
41486
+ if (!existsSync79(file)) failTranscript(`VTT file not found: ${file}`);
41574
41487
  const cues = readCleanedCues(file);
41575
41488
  if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
41576
41489
  return { path: file, name: basename28(file), cues };
@@ -42037,7 +41950,7 @@ function configKeys2() {
42037
41950
  }
42038
41951
 
42039
41952
  // src/commands/verify/forbiddenStrings.ts
42040
- import { existsSync as existsSync81, readFileSync as readFileSync63 } from "fs";
41953
+ import { existsSync as existsSync80, readFileSync as readFileSync63 } from "fs";
42041
41954
 
42042
41955
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
42043
41956
  import { minimatch as minimatch10 } from "minimatch";
@@ -42078,7 +41991,7 @@ function forbiddenStrings() {
42078
41991
  const cache7 = /* @__PURE__ */ new Map();
42079
41992
  const readJson = (file) => {
42080
41993
  if (cache7.has(file)) return cache7.get(file);
42081
- if (!existsSync81(file)) {
41994
+ if (!existsSync80(file)) {
42082
41995
  console.log(`Forbidden-strings file not found: ${file}`);
42083
41996
  process.exit(1);
42084
41997
  }
@@ -42766,7 +42679,7 @@ function resolveParams(params, cliArgs) {
42766
42679
  }
42767
42680
 
42768
42681
  // src/commands/run/resolveRunCwd.ts
42769
- import { existsSync as existsSync82 } from "fs";
42682
+ import { existsSync as existsSync81 } from "fs";
42770
42683
  import { resolve as resolve27 } from "path";
42771
42684
  var MissingRunCwdError = class extends Error {
42772
42685
  constructor(runName, cwd) {
@@ -42779,7 +42692,7 @@ var MissingRunCwdError = class extends Error {
42779
42692
  function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
42780
42693
  if (!config.cwd) return void 0;
42781
42694
  const cwd = resolve27(baseDir, config.cwd);
42782
- if (!existsSync82(cwd)) throw new MissingRunCwdError(config.name, cwd);
42695
+ if (!existsSync81(cwd)) throw new MissingRunCwdError(config.name, cwd);
42783
42696
  return cwd;
42784
42697
  }
42785
42698
 
@@ -42899,10 +42812,10 @@ ${buildWatchReport(from)}`);
42899
42812
  }
42900
42813
 
42901
42814
  // src/commands/watch/consumeMarker.ts
42902
- import { existsSync as existsSync83, rmSync as rmSync10 } from "fs";
42815
+ import { existsSync as existsSync82, rmSync as rmSync10 } from "fs";
42903
42816
  function consumeMarker(path108) {
42904
42817
  try {
42905
- if (!existsSync83(path108)) return false;
42818
+ if (!existsSync82(path108)) return false;
42906
42819
  rmSync10(path108);
42907
42820
  return true;
42908
42821
  } catch {
@@ -43833,7 +43746,7 @@ function registerRunAdd(runCommand) {
43833
43746
  }
43834
43747
 
43835
43748
  // src/commands/run/remove.ts
43836
- import { existsSync as existsSync84, unlinkSync as unlinkSync19 } from "fs";
43749
+ import { existsSync as existsSync83, unlinkSync as unlinkSync19 } from "fs";
43837
43750
  import { join as join101 } from "path";
43838
43751
 
43839
43752
  // src/commands/run/removeRepoRunConfig.ts
@@ -43853,7 +43766,7 @@ function removeRepoRunConfig(name, repoName, cwd = process.cwd()) {
43853
43766
  // src/commands/run/remove.ts
43854
43767
  function deleteCommandFile(name) {
43855
43768
  const filePath = join101(".claude", "commands", `${name}.md`);
43856
- if (existsSync84(filePath)) {
43769
+ if (existsSync83(filePath)) {
43857
43770
  unlinkSync19(filePath);
43858
43771
  console.log(`Deleted command file: ${filePath}`);
43859
43772
  }
@@ -44301,12 +44214,12 @@ function toSessionRunInfo({
44301
44214
  }
44302
44215
 
44303
44216
  // src/commands/sessions/daemon/worktree/joinRefusal.ts
44304
- import { existsSync as existsSync85 } from "fs";
44217
+ import { existsSync as existsSync84 } from "fs";
44305
44218
  function joinRefusal(session) {
44306
44219
  if (session.commandType === "run") return "a server run has no agent stream";
44307
44220
  if (session.closing === true) return "the session is closing";
44308
44221
  if (!session.cwd) return "the session has no working directory";
44309
- if (!existsSync85(session.cwd))
44222
+ if (!existsSync84(session.cwd))
44310
44223
  return "the session's workspace no longer exists";
44311
44224
  return void 0;
44312
44225
  }
@@ -44387,7 +44300,7 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
44387
44300
  }
44388
44301
 
44389
44302
  // src/commands/sessions/daemon/findServerParents.ts
44390
- import { existsSync as existsSync86 } from "fs";
44303
+ import { existsSync as existsSync85 } from "fs";
44391
44304
  import { join as join102, resolve as resolve29 } from "path";
44392
44305
  function isLive(session) {
44393
44306
  return !!session.pty && session.status !== "done" && session.status !== "error";
@@ -44397,7 +44310,7 @@ function isLiveAgent(session) {
44397
44310
  }
44398
44311
  function serverRunDirs(sessions, file) {
44399
44312
  return new Set(
44400
- sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync86(join102(dir, file)))
44313
+ sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync85(join102(dir, file)))
44401
44314
  );
44402
44315
  }
44403
44316
  function findServerParents(sessions, file) {
@@ -45013,11 +44926,11 @@ function sessionBase(id, status2) {
45013
44926
  }
45014
44927
 
45015
44928
  // src/commands/sessions/daemon/spawnPty.ts
45016
- import { existsSync as existsSync89 } from "fs";
44929
+ import { existsSync as existsSync88 } from "fs";
45017
44930
  import * as pty from "node-pty";
45018
44931
 
45019
44932
  // src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
45020
- import { chmodSync, existsSync as existsSync88, statSync as statSync14 } from "fs";
44933
+ import { chmodSync, existsSync as existsSync87, statSync as statSync14 } from "fs";
45021
44934
  import { createRequire as createRequire3 } from "module";
45022
44935
  import path105 from "path";
45023
44936
  var require4 = createRequire3(import.meta.url);
@@ -45032,7 +44945,7 @@ function ensureSpawnHelperExecutable() {
45032
44945
  `${process.platform}-${process.arch}`,
45033
44946
  "spawn-helper"
45034
44947
  );
45035
- if (!existsSync88(helper)) return;
44948
+ if (!existsSync87(helper)) return;
45036
44949
  const mode = statSync14(helper).mode;
45037
44950
  if ((mode & 73) === 0) chmodSync(helper, mode | 493);
45038
44951
  }
@@ -45088,7 +45001,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
45088
45001
  });
45089
45002
  }
45090
45003
  function refuseMissingCwd(cwd, sessionId) {
45091
- if (!cwd || existsSync89(cwd)) return;
45004
+ if (!cwd || existsSync88(cwd)) return;
45092
45005
  daemonLog(
45093
45006
  `${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
45094
45007
  );
@@ -45258,7 +45171,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
45258
45171
  }
45259
45172
 
45260
45173
  // src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
45261
- import { existsSync as existsSync90, rmSync as rmSync11, writeFileSync as writeFileSync54 } from "fs";
45174
+ import { existsSync as existsSync89, rmSync as rmSync11, writeFileSync as writeFileSync54 } from "fs";
45262
45175
  var paused;
45263
45176
  var wake;
45264
45177
  function persist2(value) {
@@ -45270,7 +45183,7 @@ function persist2(value) {
45270
45183
  }
45271
45184
  var autoUpdateControl = {
45272
45185
  paused: () => {
45273
- paused ??= existsSync90(daemonPaths.autoUpdatePaused);
45186
+ paused ??= existsSync89(daemonPaths.autoUpdatePaused);
45274
45187
  return paused;
45275
45188
  },
45276
45189
  setPaused: (value) => {
@@ -45466,6 +45379,52 @@ function bindResumedWorktree(session, cwd, notify2) {
45466
45379
  notify2();
45467
45380
  }
45468
45381
 
45382
+ // src/commands/sessions/daemon/worktree/treeDurability.ts
45383
+ import { existsSync as existsSync90 } from "fs";
45384
+ var treeIsGone = { durable: true, gone: true };
45385
+ function treeDurability(state) {
45386
+ if (state.dirty) return { durable: false, reason: "uncommitted changes" };
45387
+ if (state.localOnlyCommits)
45388
+ return { durable: false, reason: "unpushed commits" };
45389
+ return { durable: true };
45390
+ }
45391
+ function* durabilityProbes() {
45392
+ const status2 = yield ["status", "--porcelain"];
45393
+ if (!status2.ok)
45394
+ return { durable: false, reason: `tree state unreadable: ${status2.error}` };
45395
+ const dirty = status2.out !== "";
45396
+ const upstream = yield [
45397
+ "rev-parse",
45398
+ "--abbrev-ref",
45399
+ "--symbolic-full-name",
45400
+ "@{upstream}"
45401
+ ];
45402
+ if (upstream.ok && upstream.out) {
45403
+ const ahead = yield ["rev-list", "--count", "@{upstream}..HEAD"];
45404
+ if (ahead.ok && Number(ahead.out) === 0)
45405
+ return treeDurability({ dirty, localOnlyCommits: false });
45406
+ }
45407
+ const remoteBranches = yield ["branch", "-r", "--contains", "HEAD"];
45408
+ return treeDurability({
45409
+ dirty,
45410
+ localOnlyCommits: !remoteBranches.ok || remoteBranches.out === ""
45411
+ });
45412
+ }
45413
+ async function checkDurability(cwd) {
45414
+ if (!existsSync90(cwd)) return treeIsGone;
45415
+ const probes = durabilityProbes();
45416
+ let step3 = probes.next();
45417
+ while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
45418
+ return step3.value;
45419
+ }
45420
+ function checkDurabilitySync(cwd) {
45421
+ if (!existsSync90(cwd)) return treeIsGone;
45422
+ const probes = durabilityProbes();
45423
+ let step3 = probes.next();
45424
+ while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
45425
+ return step3.value;
45426
+ }
45427
+
45469
45428
  // src/commands/sessions/daemon/worktree/boundTreeRoots.ts
45470
45429
  function boundTreeRoots(sessions, exclude) {
45471
45430
  const roots = /* @__PURE__ */ new Set();
@@ -50090,36 +50049,6 @@ function addAgentToStream(ctx, targetId, request) {
50090
50049
  };
50091
50050
  }
50092
50051
 
50093
- // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
50094
- var ITEM_ID = /^a?\d+$/;
50095
- function isBacklogRunArgs(args) {
50096
- const [command, subcommand, ...rest] = args;
50097
- if (command !== "backlog" || subcommand !== "run") return false;
50098
- return rest.some((arg) => ITEM_ID.test(arg));
50099
- }
50100
-
50101
- // src/commands/sessions/daemon/worktree/prCheckoutNumber.ts
50102
- var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
50103
- "review",
50104
- "review-pr-comments",
50105
- "fix-conflict"
50106
- ]);
50107
- function prCheckoutNumber(args) {
50108
- const [command, ...rest] = args;
50109
- if (!command || !CHECKOUT_COMMANDS.has(command)) return void 0;
50110
- return rest.find((arg) => /^[1-9]\d*$/.test(arg));
50111
- }
50112
-
50113
- // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
50114
- function isPrCheckoutArgs(args) {
50115
- return prCheckoutNumber(args) !== void 0;
50116
- }
50117
-
50118
- // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
50119
- function isCommittingArgs(args) {
50120
- return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
50121
- }
50122
-
50123
50052
  // src/commands/sessions/daemon/worktree/spawnInTree.ts
50124
50053
  function spawnInTree(ctx, { prompt, cwd, design, auto, harness, inPlace }, context) {
50125
50054
  return allocateAndBind(
@@ -50142,13 +50071,7 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
50142
50071
  ctx,
50143
50072
  cwd,
50144
50073
  (sid, resolvedCwd, holdUntilSeeded) => createAssistSession(sid, assistArgs, resolvedCwd, meta, holdUntilSeeded),
50145
- {
50146
- forCheckout: isPrCheckoutArgs(assistArgs),
50147
- commits: isCommittingArgs(assistArgs),
50148
- backlogRun: isBacklogRunArgs(assistArgs),
50149
- assistCommand: assistArgs[0] ?? "",
50150
- inPlace: meta?.inPlace
50151
- },
50074
+ { inPlace: meta?.inPlace },
50152
50075
  context
50153
50076
  );
50154
50077
  }
@@ -51238,6 +51161,23 @@ var sessionSettingHandlers = {
51238
51161
  )
51239
51162
  };
51240
51163
 
51164
+ // src/commands/sessions/daemon/worktree/prCheckoutNumber.ts
51165
+ var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
51166
+ "review",
51167
+ "review-pr-comments",
51168
+ "fix-conflict"
51169
+ ]);
51170
+ function prCheckoutNumber(args) {
51171
+ const [command, ...rest] = args;
51172
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return void 0;
51173
+ return rest.find((arg) => /^[1-9]\d*$/.test(arg));
51174
+ }
51175
+
51176
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
51177
+ function isPrCheckoutArgs(args) {
51178
+ return prCheckoutNumber(args) !== void 0;
51179
+ }
51180
+
51241
51181
  // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
51242
51182
  import { execFile as execFile14 } from "child_process";
51243
51183
  import { existsSync as existsSync101 } from "fs";