@staff0rd/assist 0.818.0 → 0.819.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.818.0",
9
+ version: "0.819.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -7710,12 +7710,46 @@ function hasLocalChanges() {
7710
7710
  import {
7711
7711
  existsSync as existsSync26,
7712
7712
  mkdirSync as mkdirSync5,
7713
- readFileSync as readFileSync18,
7713
+ readFileSync as readFileSync19,
7714
7714
  unlinkSync as unlinkSync3,
7715
7715
  writeFileSync as writeFileSync16
7716
7716
  } from "fs";
7717
7717
  import { homedir as homedir7 } from "os";
7718
7718
  import { join as join29 } from "path";
7719
+
7720
+ // src/commands/backlog/bootedAt.ts
7721
+ import { uptime } from "os";
7722
+ function bootedAt() {
7723
+ return Date.now() - uptime() * 1e3;
7724
+ }
7725
+
7726
+ // src/commands/backlog/processStartedAt.ts
7727
+ import { readFileSync as readFileSync18 } from "fs";
7728
+ var clockTicksPerSecond = 100;
7729
+ function processStartedAt(pid) {
7730
+ try {
7731
+ const stat5 = readFileSync18(`/proc/${pid}/stat`, "utf8");
7732
+ const fields = stat5.slice(stat5.lastIndexOf(")") + 2).split(" ");
7733
+ const ticks = Number(fields[19]);
7734
+ if (!Number.isFinite(ticks)) return void 0;
7735
+ return bootedAt() + ticks / clockTicksPerSecond * 1e3;
7736
+ } catch {
7737
+ return void 0;
7738
+ }
7739
+ }
7740
+
7741
+ // src/commands/backlog/isStaleLock.ts
7742
+ var clockSlackMs = 5e3;
7743
+ function isStaleLock(pid, timestamp6) {
7744
+ if (typeof timestamp6 !== "string") return false;
7745
+ const lockedAt = Date.parse(timestamp6);
7746
+ if (Number.isNaN(lockedAt)) return false;
7747
+ if (lockedAt < bootedAt() - clockSlackMs) return true;
7748
+ const startedAt = processStartedAt(pid);
7749
+ return startedAt !== void 0 && startedAt > lockedAt + clockSlackMs;
7750
+ }
7751
+
7752
+ // src/commands/backlog/acquireLock.ts
7719
7753
  function getLocksDir() {
7720
7754
  return join29(homedir7(), ".assist", "locks");
7721
7755
  }
@@ -7734,9 +7768,10 @@ function foreignLockHolder(itemId2) {
7734
7768
  const lockPath = getLockPath(itemId2);
7735
7769
  if (!existsSync26(lockPath)) return null;
7736
7770
  try {
7737
- const lock2 = JSON.parse(readFileSync18(lockPath, "utf8"));
7771
+ const lock2 = JSON.parse(readFileSync19(lockPath, "utf8"));
7738
7772
  if (typeof lock2.pid !== "number" || lock2.pid === process.pid) return null;
7739
7773
  if (!isProcessAlive(lock2.pid)) return null;
7774
+ if (isStaleLock(lock2.pid, lock2.timestamp)) return null;
7740
7775
  return { pid: lock2.pid, timestamp: lock2.timestamp };
7741
7776
  } catch {
7742
7777
  return null;
@@ -8567,7 +8602,7 @@ function spawnHarness(harness, prompt, options2 = {}) {
8567
8602
  import { existsSync as existsSync30, unwatchFile, watchFile } from "fs";
8568
8603
 
8569
8604
  // src/commands/backlog/readSignal.ts
8570
- import { existsSync as existsSync29, readFileSync as readFileSync20 } from "fs";
8605
+ import { existsSync as existsSync29, readFileSync as readFileSync21 } from "fs";
8571
8606
 
8572
8607
  // src/commands/backlog/writeSignal.ts
8573
8608
  import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync20 } from "fs";
@@ -8579,7 +8614,7 @@ import chalk66 from "chalk";
8579
8614
  import {
8580
8615
  existsSync as existsSync28,
8581
8616
  mkdirSync as mkdirSync8,
8582
- readFileSync as readFileSync19,
8617
+ readFileSync as readFileSync20,
8583
8618
  rmSync,
8584
8619
  writeFileSync as writeFileSync19
8585
8620
  } from "fs";
@@ -8599,7 +8634,7 @@ function readSignalOwner(itemId2) {
8599
8634
  const path108 = getOwnerPath(itemId2);
8600
8635
  if (!existsSync28(path108)) return void 0;
8601
8636
  try {
8602
- const parsed = JSON.parse(readFileSync19(path108, "utf8"));
8637
+ const parsed = JSON.parse(readFileSync20(path108, "utf8"));
8603
8638
  return parsed.sessionId;
8604
8639
  } catch {
8605
8640
  return void 0;
@@ -8657,7 +8692,7 @@ function readSignal() {
8657
8692
  const path108 = getSignalPath();
8658
8693
  if (!path108 || !existsSync29(path108)) return void 0;
8659
8694
  try {
8660
- return JSON.parse(readFileSync20(path108, "utf8"));
8695
+ return JSON.parse(readFileSync21(path108, "utf8"));
8661
8696
  } catch {
8662
8697
  return void 0;
8663
8698
  }
@@ -8833,7 +8868,7 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
8833
8868
  }
8834
8869
 
8835
8870
  // src/shared/emitActivity.ts
8836
- import { mkdirSync as mkdirSync10, readFileSync as readFileSync21, rmSync as rmSync2, writeFileSync as writeFileSync21 } from "fs";
8871
+ import { mkdirSync as mkdirSync10, readFileSync as readFileSync22, rmSync as rmSync2, writeFileSync as writeFileSync21 } from "fs";
8837
8872
  import { homedir as homedir12 } from "os";
8838
8873
  import { dirname as dirname18, join as join34 } from "path";
8839
8874
  import { z as z8 } from "zod";
@@ -8862,7 +8897,7 @@ function emitActivity(activity2) {
8862
8897
  }
8863
8898
  function readActivity(path108) {
8864
8899
  try {
8865
- return JSON.parse(readFileSync21(path108, "utf8"));
8900
+ return JSON.parse(readFileSync22(path108, "utf8"));
8866
8901
  } catch {
8867
8902
  return void 0;
8868
8903
  }
@@ -11696,7 +11731,7 @@ function attachSessionSocket(server, ctx) {
11696
11731
 
11697
11732
  // src/shared/createBundleHandler.ts
11698
11733
  import { createHash } from "crypto";
11699
- import { readFileSync as readFileSync22, statSync as statSync5 } from "fs";
11734
+ import { readFileSync as readFileSync23, statSync as statSync5 } from "fs";
11700
11735
  import { dirname as dirname21, join as join40 } from "path";
11701
11736
  import { fileURLToPath as fileURLToPath4 } from "url";
11702
11737
  function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
@@ -11705,7 +11740,7 @@ function createBundleHandler(importMetaUrl, bundlePath, contentType = "applicati
11705
11740
  return (req, res) => {
11706
11741
  const mtimeMs = statSync5(file).mtimeMs;
11707
11742
  if (cache6?.mtimeMs !== mtimeMs) {
11708
- const body = readFileSync22(file, "utf8");
11743
+ const body = readFileSync23(file, "utf8");
11709
11744
  const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
11710
11745
  cache6 = { body, etag, mtimeMs };
11711
11746
  }
@@ -13816,7 +13851,7 @@ function handleServerRuns(req, res) {
13816
13851
 
13817
13852
  // src/commands/sessions/web/getReviewSynthesis.ts
13818
13853
  import { execFile as execFile6 } from "child_process";
13819
- import { readFileSync as readFileSync23 } from "fs";
13854
+ import { readFileSync as readFileSync24 } from "fs";
13820
13855
  import { homedir as homedir15 } from "os";
13821
13856
  import { basename as basename12, join as join42 } from "path";
13822
13857
  import { promisify as promisify5 } from "util";
@@ -13864,7 +13899,7 @@ async function getReviewSynthesis(req, res) {
13864
13899
  respondJson(res, 404, { error: "No synthesis found" });
13865
13900
  return;
13866
13901
  }
13867
- respondJson(res, 200, { synthesis: readFileSync23(path108, "utf8") });
13902
+ respondJson(res, 200, { synthesis: readFileSync24(path108, "utf8") });
13868
13903
  } catch {
13869
13904
  respondJson(res, 404, { error: "No synthesis found" });
13870
13905
  }
@@ -15152,7 +15187,7 @@ async function nextPickup(req, res) {
15152
15187
  import path29 from "path";
15153
15188
 
15154
15189
  // src/commands/rules/readScopedRules.ts
15155
- import { existsSync as existsSync37, readFileSync as readFileSync24 } from "fs";
15190
+ import { existsSync as existsSync37, readFileSync as readFileSync25 } from "fs";
15156
15191
  import path28 from "path";
15157
15192
 
15158
15193
  // src/commands/rules/rulesSectionRange.ts
@@ -15224,7 +15259,7 @@ function scopedClaudeFiles(target) {
15224
15259
  }
15225
15260
  function readScopedRules(target) {
15226
15261
  return scopedClaudeFiles(target).flatMap(
15227
- (source) => parseRulesSection(readFileSync24(source, "utf8")).map((rule) => ({
15262
+ (source) => parseRulesSection(readFileSync25(source, "utf8")).map((rule) => ({
15228
15263
  ...rule,
15229
15264
  source
15230
15265
  }))
@@ -18095,7 +18130,7 @@ async function writeFileContent(req, res) {
18095
18130
 
18096
18131
  // src/commands/sessions/web/createCssHandler.ts
18097
18132
  import { createHash as createHash3 } from "crypto";
18098
- import { readFileSync as readFileSync25 } from "fs";
18133
+ import { readFileSync as readFileSync26 } from "fs";
18099
18134
  import { createRequire } from "module";
18100
18135
  var require2 = createRequire(import.meta.url);
18101
18136
  function createCssHandler(packageEntry) {
@@ -18103,7 +18138,7 @@ function createCssHandler(packageEntry) {
18103
18138
  return (req, res) => {
18104
18139
  if (!cache6) {
18105
18140
  const resolved = require2.resolve(packageEntry);
18106
- const body = readFileSync25(resolved, "utf8");
18141
+ const body = readFileSync26(resolved, "utf8");
18107
18142
  const etag = `"${createHash3("sha256").update(body).digest("hex").slice(0, 16)}"`;
18108
18143
  cache6 = { body, etag };
18109
18144
  }
@@ -19253,7 +19288,7 @@ function tokenize(command) {
19253
19288
  }
19254
19289
 
19255
19290
  // src/commands/cliHook/isGhGraphqlIssueMutation.ts
19256
- import { readFileSync as readFileSync26 } from "fs";
19291
+ import { readFileSync as readFileSync27 } from "fs";
19257
19292
  var ISSUE_MUTATION = /\bmutation\b[\s\S]*(?:issue|comment|label|assign|reaction|milestone)/i;
19258
19293
  var FIELD_FLAGS = ["-f", "-F", "--field", "--raw-field"];
19259
19294
  function isGhGraphqlIssueMutation(args, command) {
@@ -19289,7 +19324,7 @@ function readSourceOrCommandText(source, command) {
19289
19324
  const path108 = source.slice(1);
19290
19325
  if (path108 === "-") return command;
19291
19326
  try {
19292
- return readFileSync26(path108, "utf8");
19327
+ return readFileSync27(path108, "utf8");
19293
19328
  } catch {
19294
19329
  return command;
19295
19330
  }
@@ -19659,7 +19694,7 @@ function extractGraphqlQuery(args) {
19659
19694
  }
19660
19695
 
19661
19696
  // src/shared/loadCliReads.ts
19662
- import { existsSync as existsSync42, readFileSync as readFileSync27, writeFileSync as writeFileSync23 } from "fs";
19697
+ import { existsSync as existsSync42, readFileSync as readFileSync28, writeFileSync as writeFileSync23 } from "fs";
19663
19698
  import { dirname as dirname26, resolve as resolve16 } from "path";
19664
19699
  import { fileURLToPath as fileURLToPath5 } from "url";
19665
19700
  var __filename3 = fileURLToPath5(import.meta.url);
@@ -19669,7 +19704,7 @@ function packageRoot() {
19669
19704
  }
19670
19705
  function readLines(path108) {
19671
19706
  if (!existsSync42(path108)) return [];
19672
- return readFileSync27(path108, "utf8").split("\n").filter((line) => line.trim() !== "");
19707
+ return readFileSync28(path108, "utf8").split("\n").filter((line) => line.trim() !== "");
19673
19708
  }
19674
19709
  var cachedReads;
19675
19710
  var cachedWrites;
@@ -19715,7 +19750,7 @@ function findCliWrite(command) {
19715
19750
  }
19716
19751
 
19717
19752
  // src/shared/readSettingsPerms.ts
19718
- import { existsSync as existsSync43, readFileSync as readFileSync28 } from "fs";
19753
+ import { existsSync as existsSync43, readFileSync as readFileSync29 } from "fs";
19719
19754
  import { homedir as homedir17 } from "os";
19720
19755
  import { join as join48 } from "path";
19721
19756
  function readSettingsPerms(key) {
@@ -19733,7 +19768,7 @@ function readSettingsPerms(key) {
19733
19768
  function readPermissionArray(filePath, key) {
19734
19769
  if (!existsSync43(filePath)) return [];
19735
19770
  try {
19736
- const data = JSON.parse(readFileSync28(filePath, "utf8"));
19771
+ const data = JSON.parse(readFileSync29(filePath, "utf8"));
19737
19772
  const arr = data?.permissions?.[key];
19738
19773
  return Array.isArray(arr) ? arr.filter((e) => typeof e === "string") : [];
19739
19774
  } catch {
@@ -20088,7 +20123,7 @@ ${reasons.join("\n")}`);
20088
20123
  }
20089
20124
 
20090
20125
  // src/commands/permitCliReads.ts
20091
- import { existsSync as existsSync44, mkdirSync as mkdirSync14, readFileSync as readFileSync29, writeFileSync as writeFileSync24 } from "fs";
20126
+ import { existsSync as existsSync44, mkdirSync as mkdirSync14, readFileSync as readFileSync30, writeFileSync as writeFileSync24 } from "fs";
20092
20127
  import { homedir as homedir19 } from "os";
20093
20128
  import { join as join50 } from "path";
20094
20129
 
@@ -20358,7 +20393,7 @@ function logPath(cli) {
20358
20393
  function readCache(cli) {
20359
20394
  const path108 = logPath(cli);
20360
20395
  if (!existsSync44(path108)) return void 0;
20361
- return readFileSync29(path108, "utf8");
20396
+ return readFileSync30(path108, "utf8");
20362
20397
  }
20363
20398
  function writeCache(cli, output) {
20364
20399
  const dir = join50(homedir19(), ".assist");
@@ -20492,7 +20527,7 @@ function registerCliHook(program2) {
20492
20527
  }
20493
20528
 
20494
20529
  // src/commands/codeComment/codeCommentConfirm.ts
20495
- import { existsSync as existsSync46, readFileSync as readFileSync31, unlinkSync as unlinkSync8, writeFileSync as writeFileSync25 } from "fs";
20530
+ import { existsSync as existsSync46, readFileSync as readFileSync32, unlinkSync as unlinkSync8, writeFileSync as writeFileSync25 } from "fs";
20496
20531
  import chalk121 from "chalk";
20497
20532
 
20498
20533
  // src/shared/isHashCommentFile.ts
@@ -20557,12 +20592,12 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
20557
20592
  }
20558
20593
 
20559
20594
  // src/commands/codeComment/readPinState.ts
20560
- import { existsSync as existsSync45, readFileSync as readFileSync30 } from "fs";
20595
+ import { existsSync as existsSync45, readFileSync as readFileSync31 } from "fs";
20561
20596
  function readPinState(pin2) {
20562
20597
  const path108 = getPinStatePath(pin2);
20563
20598
  if (!existsSync45(path108)) return void 0;
20564
20599
  try {
20565
- const state = JSON.parse(readFileSync30(path108, "utf8"));
20600
+ const state = JSON.parse(readFileSync31(path108, "utf8"));
20566
20601
  if (state.pin !== pin2) return void 0;
20567
20602
  return state;
20568
20603
  } catch {
@@ -20584,7 +20619,7 @@ function codeCommentConfirm(pin2) {
20584
20619
  process.exitCode = 1;
20585
20620
  return;
20586
20621
  }
20587
- const original = readFileSync31(state.file, "utf8");
20622
+ const original = readFileSync32(state.file, "utf8");
20588
20623
  const lines2 = original.split("\n");
20589
20624
  const index2 = state.line - 1;
20590
20625
  if (index2 > lines2.length) {
@@ -22699,12 +22734,12 @@ function getMigrationApprovalPath(migrationId) {
22699
22734
  }
22700
22735
 
22701
22736
  // src/commands/dbMigration/readMigrationPinState.ts
22702
- import { existsSync as existsSync50, readFileSync as readFileSync32 } from "fs";
22737
+ import { existsSync as existsSync50, readFileSync as readFileSync33 } from "fs";
22703
22738
  function readMigrationPinState(pin2) {
22704
22739
  const path108 = getMigrationPinPath(pin2);
22705
22740
  if (!existsSync50(path108)) return void 0;
22706
22741
  try {
22707
- const state = JSON.parse(readFileSync32(path108, "utf8"));
22742
+ const state = JSON.parse(readFileSync33(path108, "utf8"));
22708
22743
  if (state.pin !== pin2) return void 0;
22709
22744
  if (!Number.isInteger(state.migrationId)) return void 0;
22710
22745
  return state;
@@ -22791,7 +22826,7 @@ function registerDbMigration(parent) {
22791
22826
  }
22792
22827
 
22793
22828
  // src/commands/deploy/redirect.ts
22794
- import { existsSync as existsSync51, readFileSync as readFileSync33, writeFileSync as writeFileSync29 } from "fs";
22829
+ import { existsSync as existsSync51, readFileSync as readFileSync34, writeFileSync as writeFileSync29 } from "fs";
22795
22830
  import chalk149 from "chalk";
22796
22831
  var TRAILING_SLASH_SCRIPT = ` <script>
22797
22832
  if (!window.location.pathname.endsWith('/')) {
@@ -22804,7 +22839,7 @@ function redirect() {
22804
22839
  console.log(chalk149.yellow("No index.html found"));
22805
22840
  return;
22806
22841
  }
22807
- const content = readFileSync33(indexPath, "utf8");
22842
+ const content = readFileSync34(indexPath, "utf8");
22808
22843
  if (content.includes("window.location.pathname.endsWith('/')")) {
22809
22844
  console.log(chalk149.dim("Trailing slash script already present"));
22810
22845
  return;
@@ -22847,7 +22882,7 @@ import { execSync as execSync32 } from "child_process";
22847
22882
  import chalk150 from "chalk";
22848
22883
 
22849
22884
  // src/shared/getRepoName.ts
22850
- import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
22885
+ import { existsSync as existsSync52, readFileSync as readFileSync35 } from "fs";
22851
22886
  import { basename as basename16, join as join63 } from "path";
22852
22887
  function getRepoName() {
22853
22888
  const config = loadConfig();
@@ -22857,7 +22892,7 @@ function getRepoName() {
22857
22892
  const packageJsonPath = join63(process.cwd(), "package.json");
22858
22893
  if (existsSync52(packageJsonPath)) {
22859
22894
  try {
22860
- const content = readFileSync34(packageJsonPath, "utf8");
22895
+ const content = readFileSync35(packageJsonPath, "utf8");
22861
22896
  const pkg = JSON.parse(content);
22862
22897
  if (pkg.name) {
22863
22898
  return pkg.name;
@@ -22869,7 +22904,7 @@ function getRepoName() {
22869
22904
  }
22870
22905
 
22871
22906
  // src/commands/devlog/loadDevlogEntries.ts
22872
- import { readdirSync as readdirSync7, readFileSync as readFileSync35 } from "fs";
22907
+ import { readdirSync as readdirSync7, readFileSync as readFileSync36 } from "fs";
22873
22908
  import { join as join64 } from "path";
22874
22909
  var DEVLOG_DIR = join64(BLOG_REPO_ROOT, "src/content/devlog");
22875
22910
  function extractFrontmatter(content) {
@@ -22899,7 +22934,7 @@ function readDevlogFiles(callback) {
22899
22934
  try {
22900
22935
  const files = readdirSync7(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
22901
22936
  for (const file of files) {
22902
- const content = readFileSync35(join64(DEVLOG_DIR, file), "utf8");
22937
+ const content = readFileSync36(join64(DEVLOG_DIR, file), "utf8");
22903
22938
  const parsed = parseFrontmatter(content, file);
22904
22939
  if (parsed) callback(parsed);
22905
22940
  }
@@ -23412,11 +23447,11 @@ async function checkBuildLocksCommand() {
23412
23447
  }
23413
23448
 
23414
23449
  // src/commands/dotnet/buildTree.ts
23415
- import { readFileSync as readFileSync36 } from "fs";
23450
+ import { readFileSync as readFileSync37 } from "fs";
23416
23451
  import path36 from "path";
23417
23452
  var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
23418
23453
  function getProjectRefs(csprojPath) {
23419
- const content = readFileSync36(csprojPath, "utf8");
23454
+ const content = readFileSync37(csprojPath, "utf8");
23420
23455
  const refs = [];
23421
23456
  for (const match of content.matchAll(PROJECT_REF_RE)) {
23422
23457
  refs.push(match[1].replace(/\\/g, "/"));
@@ -23433,7 +23468,7 @@ function buildTree(csprojPath, repoRoot2, visited = /* @__PURE__ */ new Set()) {
23433
23468
  for (const ref of getProjectRefs(abs)) {
23434
23469
  const childAbs = path36.resolve(dir, ref);
23435
23470
  try {
23436
- readFileSync36(childAbs);
23471
+ readFileSync37(childAbs);
23437
23472
  node.children.push(buildTree(childAbs, repoRoot2, visited));
23438
23473
  } catch {
23439
23474
  node.children.push({
@@ -23458,7 +23493,7 @@ function collectAllDeps(node) {
23458
23493
  }
23459
23494
 
23460
23495
  // src/commands/dotnet/findContainingSolutions.ts
23461
- import { readdirSync as readdirSync9, readFileSync as readFileSync37, statSync as statSync9 } from "fs";
23496
+ import { readdirSync as readdirSync9, readFileSync as readFileSync38, statSync as statSync9 } from "fs";
23462
23497
  import path37 from "path";
23463
23498
  function findSlnFiles(dir, maxDepth, depth = 0) {
23464
23499
  if (depth > maxDepth) return [];
@@ -23493,7 +23528,7 @@ function findContainingSolutions(csprojPath, repoRoot2) {
23493
23528
  const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
23494
23529
  for (const sln of slnFiles) {
23495
23530
  try {
23496
- const content = readFileSync37(sln, "utf8");
23531
+ const content = readFileSync38(sln, "utf8");
23497
23532
  if (pattern2.test(content)) {
23498
23533
  matches.push(path37.relative(repoRoot2, sln));
23499
23534
  }
@@ -23811,7 +23846,7 @@ function parseInspectReport(json) {
23811
23846
 
23812
23847
  // src/commands/dotnet/runInspectCode.ts
23813
23848
  import { execSync as execSync36 } from "child_process";
23814
- import { existsSync as existsSync55, readFileSync as readFileSync38, unlinkSync as unlinkSync10 } from "fs";
23849
+ import { existsSync as existsSync55, readFileSync as readFileSync39, unlinkSync as unlinkSync10 } from "fs";
23815
23850
  import { tmpdir as tmpdir4 } from "os";
23816
23851
  import path40 from "path";
23817
23852
  import chalk164 from "chalk";
@@ -23846,7 +23881,7 @@ function runInspectCode(slnPath, include, swea) {
23846
23881
  console.error(chalk164.red("Report file not generated"));
23847
23882
  process.exit(1);
23848
23883
  }
23849
- const xml = readFileSync38(reportPath, "utf8");
23884
+ const xml = readFileSync39(reportPath, "utf8");
23850
23885
  unlinkSync10(reportPath);
23851
23886
  return xml;
23852
23887
  }
@@ -26201,14 +26236,14 @@ function fetchIssueToWorkingFile(number, repo) {
26201
26236
  }
26202
26237
 
26203
26238
  // src/commands/github/issue/resumeIssueBody.ts
26204
- import { existsSync as existsSync57, readFileSync as readFileSync39 } from "fs";
26239
+ import { existsSync as existsSync57, readFileSync as readFileSync40 } from "fs";
26205
26240
  function resumeIssueBody(slug2, number, updatedAt) {
26206
26241
  const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
26207
26242
  if (!existsSync57(bodyPath) || !existsSync57(metaPath)) return void 0;
26208
26243
  try {
26209
- const meta = JSON.parse(readFileSync39(metaPath, "utf8"));
26244
+ const meta = JSON.parse(readFileSync40(metaPath, "utf8"));
26210
26245
  if (meta.updatedAt !== updatedAt) return void 0;
26211
- return readFileSync39(bodyPath, "utf8");
26246
+ return readFileSync40(bodyPath, "utf8");
26212
26247
  } catch {
26213
26248
  return void 0;
26214
26249
  }
@@ -27113,7 +27148,6 @@ var persistedSessionSchema = z10.object({
27113
27148
  divergenceEscalation: z10.boolean().optional(),
27114
27149
  design: z10.boolean().optional(),
27115
27150
  auto: z10.boolean().optional(),
27116
- autoRun: z10.boolean().optional(),
27117
27151
  autoAdvance: z10.boolean().optional(),
27118
27152
  reviewStarted: z10.boolean().optional(),
27119
27153
  launchedFrom: z10.string().optional(),
@@ -27146,7 +27180,6 @@ function toPersistedSession(session) {
27146
27180
  divergenceEscalation: session.divergenceEscalation,
27147
27181
  design: session.design,
27148
27182
  auto: session.auto,
27149
- autoRun: session.autoRun,
27150
27183
  autoAdvance: session.autoAdvance,
27151
27184
  reviewStarted: session.reviewStarted,
27152
27185
  launchedFrom: session.launchedFrom,
@@ -27717,7 +27750,7 @@ import { resolve as resolve20 } from "path";
27717
27750
  import chalk179 from "chalk";
27718
27751
 
27719
27752
  // src/commands/mermaid/exportFile.ts
27720
- import { readFileSync as readFileSync40, writeFileSync as writeFileSync33 } from "fs";
27753
+ import { readFileSync as readFileSync41, writeFileSync as writeFileSync33 } from "fs";
27721
27754
  import { basename as basename21, extname as extname4, resolve as resolve19 } from "path";
27722
27755
  import chalk178 from "chalk";
27723
27756
 
@@ -27743,7 +27776,7 @@ async function renderBlock(krokiUrl, source) {
27743
27776
 
27744
27777
  // src/commands/mermaid/exportFile.ts
27745
27778
  async function exportFile(file, outDir, krokiUrl, onlyIndex) {
27746
- const content = readFileSync40(file, "utf8");
27779
+ const content = readFileSync41(file, "utf8");
27747
27780
  const blocks = extractMermaidBlocks(content);
27748
27781
  const stem = basename21(file, extname4(file));
27749
27782
  if (onlyIndex !== void 0) {
@@ -27955,14 +27988,14 @@ function applyIgnore(texts, ignore3) {
27955
27988
  }
27956
27989
 
27957
27990
  // src/commands/miro/readIgnoreList.ts
27958
- import { existsSync as existsSync62, readFileSync as readFileSync41 } from "fs";
27991
+ import { existsSync as existsSync62, readFileSync as readFileSync42 } from "fs";
27959
27992
  import { parse as parse2 } from "yaml";
27960
27993
  function readIgnoreList(file) {
27961
27994
  if (!existsSync62(file))
27962
27995
  throw new MiroExtractError(
27963
27996
  `No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
27964
27997
  );
27965
- const parsed = parse2(readFileSync41(file, "utf8"));
27998
+ const parsed = parse2(readFileSync42(file, "utf8"));
27966
27999
  if (parsed === null || parsed === void 0) return [];
27967
28000
  if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string"))
27968
28001
  throw new MiroExtractError(
@@ -28142,7 +28175,7 @@ async function pickAnchors(sessionId, items2) {
28142
28175
  }
28143
28176
 
28144
28177
  // src/commands/miro/readMiroItems.ts
28145
- import { readFileSync as readFileSync42 } from "fs";
28178
+ import { readFileSync as readFileSync43 } from "fs";
28146
28179
  function tryParse(text18) {
28147
28180
  try {
28148
28181
  return JSON.parse(text18);
@@ -28171,7 +28204,7 @@ function parsePages(raw, file) {
28171
28204
  return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
28172
28205
  }
28173
28206
  function readMiroItems(file) {
28174
- const items2 = parsePages(readFileSync42(file, "utf8"), file).flatMap(
28207
+ const items2 = parsePages(readFileSync43(file, "utf8"), file).flatMap(
28175
28208
  (page) => page.data ?? []
28176
28209
  );
28177
28210
  if (items2.length === 0)
@@ -28567,7 +28600,7 @@ import { join as join77 } from "path";
28567
28600
  import chalk184 from "chalk";
28568
28601
 
28569
28602
  // src/commands/netcap/extractPostsFromCapture.ts
28570
- import { readFileSync as readFileSync43 } from "fs";
28603
+ import { readFileSync as readFileSync44 } from "fs";
28571
28604
 
28572
28605
  // src/commands/netcap/parseRscRows.ts
28573
28606
  var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
@@ -28963,7 +28996,7 @@ function extractVoyagerPosts(body) {
28963
28996
 
28964
28997
  // src/commands/netcap/extractPostsFromCapture.ts
28965
28998
  function captureEntries(captureFile) {
28966
- const lines2 = readFileSync43(captureFile, "utf8").split("\n").filter(Boolean);
28999
+ const lines2 = readFileSync44(captureFile, "utf8").split("\n").filter(Boolean);
28967
29000
  const entries = [];
28968
29001
  for (const line of lines2) {
28969
29002
  let entry;
@@ -29374,7 +29407,7 @@ import { tmpdir as tmpdir6 } from "os";
29374
29407
  import { join as join79 } from "path";
29375
29408
 
29376
29409
  // src/commands/prs/loadCommentsCache.ts
29377
- import { existsSync as existsSync63, readFileSync as readFileSync44, unlinkSync as unlinkSync13 } from "fs";
29410
+ import { existsSync as existsSync63, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
29378
29411
  import { parse as parse3 } from "yaml";
29379
29412
 
29380
29413
  // src/commands/prs/commentsCachePath.ts
@@ -29397,7 +29430,7 @@ function loadCommentsCache(org, repo, prNumber) {
29397
29430
  if (!existsSync63(cachePath)) {
29398
29431
  return null;
29399
29432
  }
29400
- const content = readFileSync44(cachePath, "utf8");
29433
+ const content = readFileSync45(cachePath, "utf8");
29401
29434
  return parse3(content);
29402
29435
  }
29403
29436
  function deleteCommentsCache(org, repo, prNumber) {
@@ -31055,7 +31088,7 @@ function registerPrsStatus(prsCommand) {
31055
31088
  }
31056
31089
 
31057
31090
  // src/commands/readTime/readTime.ts
31058
- import { readFileSync as readFileSync45 } from "fs";
31091
+ import { readFileSync as readFileSync46 } from "fs";
31059
31092
 
31060
31093
  // src/commands/readTime/countReadingWords.ts
31061
31094
  var FENCE_PATTERN = /^\s*(```|~~~)/;
@@ -31216,7 +31249,7 @@ async function loadBody(target) {
31216
31249
  }
31217
31250
  function readDraftFile(path108) {
31218
31251
  try {
31219
- return readFileSync45(path108, "utf8");
31252
+ return readFileSync46(path108, "utf8");
31220
31253
  } catch {
31221
31254
  console.error(`Error: Could not read \`${path108}\`.`);
31222
31255
  console.error(
@@ -31714,10 +31747,10 @@ function checkStreamGraph(streams) {
31714
31747
  }
31715
31748
 
31716
31749
  // src/commands/releases/readStreamsInput.ts
31717
- import { readFileSync as readFileSync46 } from "fs";
31750
+ import { readFileSync as readFileSync47 } from "fs";
31718
31751
  import { parse as parse4 } from "yaml";
31719
31752
  function readSource2(source) {
31720
- return readFileSync46(source === "-" ? 0 : source, "utf8");
31753
+ return readFileSync47(source === "-" ? 0 : source, "utf8");
31721
31754
  }
31722
31755
  function readStreamsInput(source) {
31723
31756
  let parsed;
@@ -32540,7 +32573,7 @@ function buildLimitsSegment(rateLimits) {
32540
32573
  }
32541
32574
 
32542
32575
  // src/commands/readGitBranch.ts
32543
- import { readFileSync as readFileSync47, statSync as statSync11 } from "fs";
32576
+ import { readFileSync as readFileSync48, statSync as statSync11 } from "fs";
32544
32577
  import { isAbsolute as isAbsolute6, join as join83, resolve as resolve25 } from "path";
32545
32578
  function resolveGitDir(cwd) {
32546
32579
  const dotGit = join83(cwd, ".git");
@@ -32555,7 +32588,7 @@ function resolveGitDir(cwd) {
32555
32588
  }
32556
32589
  let contents;
32557
32590
  try {
32558
- contents = readFileSync47(dotGit, "utf8");
32591
+ contents = readFileSync48(dotGit, "utf8");
32559
32592
  } catch {
32560
32593
  return null;
32561
32594
  }
@@ -32573,7 +32606,7 @@ function readGitBranch(cwd) {
32573
32606
  }
32574
32607
  let head;
32575
32608
  try {
32576
- head = readFileSync47(join83(gitDir, "HEAD"), "utf8");
32609
+ head = readFileSync48(join83(gitDir, "HEAD"), "utf8");
32577
32610
  } catch {
32578
32611
  return null;
32579
32612
  }
@@ -35342,7 +35375,7 @@ function capHighLevelTestSources(files) {
35342
35375
  }
35343
35376
 
35344
35377
  // src/commands/review/highLevel/collectHighLevelTests.ts
35345
- import { existsSync as existsSync65, readFileSync as readFileSync48 } from "fs";
35378
+ import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
35346
35379
  import { join as join84 } from "path";
35347
35380
  import { minimatch as minimatch6 } from "minimatch";
35348
35381
 
@@ -35462,7 +35495,7 @@ function testFile(file, repoRoot2) {
35462
35495
  const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
35463
35496
  const tests = extractTestHierarchy(
35464
35497
  file.path,
35465
- readFileSync48(absolute2, "utf8"),
35498
+ readFileSync49(absolute2, "utf8"),
35466
35499
  changed
35467
35500
  );
35468
35501
  if (tests.length === 0) return [];
@@ -35690,7 +35723,7 @@ function fetchHighLevelPr(prNumber, repo) {
35690
35723
  }
35691
35724
 
35692
35725
  // src/commands/review/highLevel/loadHighLevelReview.ts
35693
- import { existsSync as existsSync66, readFileSync as readFileSync49 } from "fs";
35726
+ import { existsSync as existsSync66, readFileSync as readFileSync50 } from "fs";
35694
35727
 
35695
35728
  // src/commands/review/highLevel/highLevelReviewPath.ts
35696
35729
  import { join as join85 } from "path";
@@ -35711,7 +35744,7 @@ function loadHighLevelReview(repo, headRef, headSha) {
35711
35744
  const path108 = highLevelReviewPath(repo, headRef, headSha);
35712
35745
  if (!existsSync66(path108)) return void 0;
35713
35746
  try {
35714
- return JSON.parse(readFileSync49(path108, "utf8"));
35747
+ return JSON.parse(readFileSync50(path108, "utf8"));
35715
35748
  } catch {
35716
35749
  return void 0;
35717
35750
  }
@@ -36096,7 +36129,7 @@ async function runHighLevelReview(number, options2 = {}) {
36096
36129
  }
36097
36130
 
36098
36131
  // src/commands/review/ci/writeJobSummary.ts
36099
- import { appendFileSync as appendFileSync2, readFileSync as readFileSync50 } from "fs";
36132
+ import { appendFileSync as appendFileSync2, readFileSync as readFileSync51 } from "fs";
36100
36133
 
36101
36134
  // src/commands/review/carriedUnanchoredFindings.ts
36102
36135
  function carriedUnanchoredFindings(unanchored) {
@@ -36427,14 +36460,14 @@ function selectPostableFindings(markdown, prInfo) {
36427
36460
  // src/commands/review/ci/writeJobSummary.ts
36428
36461
  function writeJobSummary(synthesisPath, prInfo, summaryPath) {
36429
36462
  if (!summaryPath) return;
36430
- const markdown = readFileSync50(synthesisPath, "utf8");
36463
+ const markdown = readFileSync51(synthesisPath, "utf8");
36431
36464
  const { unanchored } = selectPostableFindings(markdown, prInfo);
36432
36465
  appendFileSync2(summaryPath, `${buildReviewSummary(markdown, unanchored)}
36433
36466
  `);
36434
36467
  }
36435
36468
 
36436
36469
  // src/commands/review/postReviewToPr.ts
36437
- import { readFileSync as readFileSync51 } from "fs";
36470
+ import { readFileSync as readFileSync52 } from "fs";
36438
36471
 
36439
36472
  // src/commands/review/chainAddressComments.ts
36440
36473
  function chainAddressComments(prNumber, announce) {
@@ -36588,7 +36621,7 @@ async function confirmPost(prNumber, work, options2) {
36588
36621
  return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
36589
36622
  }
36590
36623
  async function postFindingsToPr(prInfo, synthesisPath, options2) {
36591
- const markdown = readFileSync51(synthesisPath, "utf8");
36624
+ const markdown = readFileSync52(synthesisPath, "utf8");
36592
36625
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
36593
36626
  const carried = carriedUnanchoredFindings(unanchored);
36594
36627
  if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
@@ -37605,7 +37638,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
37605
37638
  }
37606
37639
 
37607
37640
  // src/commands/review/synthesise.ts
37608
- import { readFileSync as readFileSync52 } from "fs";
37641
+ import { readFileSync as readFileSync53 } from "fs";
37609
37642
 
37610
37643
  // src/commands/review/buildSynthesisStdin.ts
37611
37644
  var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
@@ -37674,7 +37707,7 @@ Files:
37674
37707
 
37675
37708
  // src/commands/review/synthesise.ts
37676
37709
  function printSummary2(synthesisPath) {
37677
- const markdown = readFileSync52(synthesisPath, "utf8");
37710
+ const markdown = readFileSync53(synthesisPath, "utf8");
37678
37711
  console.log("");
37679
37712
  console.log(buildReviewSummary(markdown));
37680
37713
  console.log("");
@@ -38294,7 +38327,7 @@ function registerReview(program2) {
38294
38327
  }
38295
38328
 
38296
38329
  // src/commands/rules/addRule.ts
38297
- import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync44 } from "fs";
38330
+ import { existsSync as existsSync72, readFileSync as readFileSync57, writeFileSync as writeFileSync44 } from "fs";
38298
38331
  import path87 from "path";
38299
38332
  import chalk242 from "chalk";
38300
38333
 
@@ -38319,7 +38352,7 @@ function insertRuleBullet(content, rule) {
38319
38352
  }
38320
38353
 
38321
38354
  // src/commands/rules/nextRuleCode.ts
38322
- import { readFileSync as readFileSync53 } from "fs";
38355
+ import { readFileSync as readFileSync54 } from "fs";
38323
38356
 
38324
38357
  // src/commands/rules/findClaudeFiles.ts
38325
38358
  import { readdirSync as readdirSync13 } from "fs";
@@ -38343,7 +38376,7 @@ function findClaudeFiles(dir) {
38343
38376
  var CODE_PREFIX = "R";
38344
38377
  function nextRuleCode(root2) {
38345
38378
  const numbers = findClaudeFiles(root2).flatMap(
38346
- (file) => parseRulesSection(readFileSync53(file, "utf8")).map(
38379
+ (file) => parseRulesSection(readFileSync54(file, "utf8")).map(
38347
38380
  (rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
38348
38381
  )
38349
38382
  );
@@ -38369,15 +38402,15 @@ function resolveRuleScope(target) {
38369
38402
  }
38370
38403
 
38371
38404
  // src/commands/rules/updateScopedRulesIndex.ts
38372
- import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync43 } from "fs";
38405
+ import { existsSync as existsSync71, readFileSync as readFileSync56, writeFileSync as writeFileSync43 } from "fs";
38373
38406
  import path86 from "path";
38374
38407
 
38375
38408
  // src/commands/rules/scopedRuleDirectories.ts
38376
- import { readFileSync as readFileSync54 } from "fs";
38409
+ import { readFileSync as readFileSync55 } from "fs";
38377
38410
  import path85 from "path";
38378
38411
  function scopedRuleDirectories(root2) {
38379
38412
  return findClaudeFiles(root2).filter(
38380
- (file) => path85.dirname(file) !== root2 && parseRulesSection(readFileSync54(file, "utf8")).length > 0
38413
+ (file) => path85.dirname(file) !== root2 && parseRulesSection(readFileSync55(file, "utf8")).length > 0
38381
38414
  ).map(
38382
38415
  (file) => `${path85.relative(root2, path85.dirname(file)).split(path85.sep).join("/")}/`
38383
38416
  ).sort();
@@ -38419,7 +38452,7 @@ function upsertScopedRulesPointer(content, directories) {
38419
38452
  function updateScopedRulesIndex(root2) {
38420
38453
  const directories = scopedRuleDirectories(root2);
38421
38454
  const rootFile = path86.join(root2, "CLAUDE.md");
38422
- const before = existsSync71(rootFile) ? readFileSync55(rootFile, "utf8") : "";
38455
+ const before = existsSync71(rootFile) ? readFileSync56(rootFile, "utf8") : "";
38423
38456
  const after = upsertScopedRulesPointer(before, directories);
38424
38457
  if (after !== before) writeFileSync43(rootFile, after);
38425
38458
  return directories;
@@ -38427,7 +38460,7 @@ function updateScopedRulesIndex(root2) {
38427
38460
 
38428
38461
  // src/commands/rules/addRule.ts
38429
38462
  function read2(file) {
38430
- return existsSync72(file) ? readFileSync56(file, "utf8") : "";
38463
+ return existsSync72(file) ? readFileSync57(file, "utf8") : "";
38431
38464
  }
38432
38465
  function addRule(text18, options2) {
38433
38466
  const rule = text18.trim();
@@ -38962,12 +38995,12 @@ import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync46 } from "fs";
38962
38995
  import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync45 } from "fs";
38963
38996
 
38964
38997
  // src/commands/slack/readSlackParts.ts
38965
- import { readFileSync as readFileSync57 } from "fs";
38998
+ import { readFileSync as readFileSync58 } from "fs";
38966
38999
  function readSlackParts(files) {
38967
39000
  return files.map((file) => {
38968
39001
  let contents;
38969
39002
  try {
38970
- contents = readFileSync57(file, "utf8");
39003
+ contents = readFileSync58(file, "utf8");
38971
39004
  } catch {
38972
39005
  console.error(`Error: Part file not found: ${file}`);
38973
39006
  process.exit(1);
@@ -40078,9 +40111,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
40078
40111
  }
40079
40112
 
40080
40113
  // src/commands/transcript/convert/readCleanedCues.ts
40081
- import { readFileSync as readFileSync62 } from "fs";
40114
+ import { readFileSync as readFileSync63 } from "fs";
40082
40115
  function readCleanedCues(inputPath) {
40083
- return deduplicateCues(parseVtt(readFileSync62(inputPath, "utf8")));
40116
+ return deduplicateCues(parseVtt(readFileSync63(inputPath, "utf8")));
40084
40117
  }
40085
40118
 
40086
40119
  // src/commands/transcript/clean.ts
@@ -40854,7 +40887,7 @@ function configKeys2() {
40854
40887
  }
40855
40888
 
40856
40889
  // src/commands/verify/forbiddenStrings.ts
40857
- import { existsSync as existsSync81, readFileSync as readFileSync63 } from "fs";
40890
+ import { existsSync as existsSync81, readFileSync as readFileSync64 } from "fs";
40858
40891
 
40859
40892
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
40860
40893
  import { minimatch as minimatch10 } from "minimatch";
@@ -40901,7 +40934,7 @@ function forbiddenStrings() {
40901
40934
  }
40902
40935
  let parsed;
40903
40936
  try {
40904
- parsed = JSON.parse(readFileSync63(file, "utf8"));
40937
+ parsed = JSON.parse(readFileSync64(file, "utf8"));
40905
40938
  } catch (error) {
40906
40939
  console.log(`Could not parse ${file}: ${error.message}`);
40907
40940
  process.exit(1);
@@ -40971,7 +41004,7 @@ Total: ${lines2.length} hardcoded color(s)`);
40971
41004
  }
40972
41005
 
40973
41006
  // src/commands/verify/migrations.ts
40974
- import { readFileSync as readFileSync64 } from "fs";
41007
+ import { readFileSync as readFileSync65 } from "fs";
40975
41008
  import path103 from "path";
40976
41009
 
40977
41010
  // src/commands/verify/migrations/checkAppendOnly.ts
@@ -41136,7 +41169,7 @@ function migrations2() {
41136
41169
  if (ref) {
41137
41170
  const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
41138
41171
  const current = new Map(
41139
- files.map((file) => [file, readFileSync64(path103.join(dir, file), "utf8")])
41172
+ files.map((file) => [file, readFileSync65(path103.join(dir, file), "utf8")])
41140
41173
  );
41141
41174
  for (const finding of checkAppendOnly(baseline, current)) {
41142
41175
  problems.push(
@@ -42148,7 +42181,7 @@ async function auth() {
42148
42181
 
42149
42182
  // src/commands/roam/postRoamActivity.ts
42150
42183
  import { execFileSync as execFileSync22 } from "child_process";
42151
- import { readdirSync as readdirSync22, readFileSync as readFileSync65, statSync as statSync14 } from "fs";
42184
+ import { readdirSync as readdirSync22, readFileSync as readFileSync66, statSync as statSync14 } from "fs";
42152
42185
  import { join as join102 } from "path";
42153
42186
  function findPortFile(roamDir) {
42154
42187
  let entries;
@@ -42179,7 +42212,7 @@ function postRoamActivity(app, event) {
42179
42212
  if (!portFile) return;
42180
42213
  let port;
42181
42214
  try {
42182
- port = readFileSync65(portFile, "utf8").trim();
42215
+ port = readFileSync66(portFile, "utf8").trim();
42183
42216
  } catch {
42184
42217
  return;
42185
42218
  }
@@ -42648,11 +42681,11 @@ function applyLine(result, pending, line) {
42648
42681
  }
42649
42682
 
42650
42683
  // src/commands/sessions/daemon/readDaemonPidFile.ts
42651
- import { readFileSync as readFileSync66 } from "fs";
42684
+ import { readFileSync as readFileSync67 } from "fs";
42652
42685
  function readDaemonPidFile() {
42653
42686
  try {
42654
42687
  const pid = Number.parseInt(
42655
- readFileSync66(daemonPaths.pid, "utf8").trim(),
42688
+ readFileSync67(daemonPaths.pid, "utf8").trim(),
42656
42689
  10
42657
42690
  );
42658
42691
  return Number.isInteger(pid) ? pid : void 0;
@@ -42993,7 +43026,6 @@ function toSessionInfo(session) {
42993
43026
  claudeSessionId,
42994
43027
  harnessSessionId,
42995
43028
  restored,
42996
- autoRun,
42997
43029
  autoAdvance,
42998
43030
  starred,
42999
43031
  design,
@@ -43019,7 +43051,6 @@ function toSessionInfo(session) {
43019
43051
  harnessSessionId,
43020
43052
  repoGroup: repoGroupForCwd(cwd),
43021
43053
  restored,
43022
- autoRun,
43023
43054
  autoAdvance,
43024
43055
  starred,
43025
43056
  design,
@@ -43186,13 +43217,6 @@ function writeToSession(sessions, id, data, onStatusChange, viewer = {}) {
43186
43217
  watchPromptSubmit(s, data, onStatusChange);
43187
43218
  if (!response) claimViewer(s, viewer, "input");
43188
43219
  }
43189
- function setAutoRun(sessions, id, enabled) {
43190
- const s = sessions.get(id);
43191
- if (!s) return false;
43192
- s.autoRun = enabled;
43193
- daemonLog(`session ${id} autorun ${enabled ? "on" : "off"}`);
43194
- return true;
43195
- }
43196
43220
  function setStarred2(sessions, id, starred) {
43197
43221
  const s = sessions.get(id);
43198
43222
  if (!s) return false;
@@ -43739,14 +43763,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
43739
43763
  }
43740
43764
 
43741
43765
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
43742
- import { readFileSync as readFileSync68, writeFileSync as writeFileSync56 } from "fs";
43766
+ import { readFileSync as readFileSync69, writeFileSync as writeFileSync56 } from "fs";
43743
43767
  var KEEP_TAIL = 256 * 1024;
43744
43768
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
43745
43769
  function trimWatcherLog(cwd) {
43746
43770
  const path108 = watcherLogPath(cwd);
43747
43771
  let log2;
43748
43772
  try {
43749
- log2 = readFileSync68(path108, "utf8");
43773
+ log2 = readFileSync69(path108, "utf8");
43750
43774
  } catch {
43751
43775
  return;
43752
43776
  }
@@ -46018,38 +46042,9 @@ function applyUsageRecord(sessions, windows, notify2, claudeSessionId, transcrip
46018
46042
  notify2();
46019
46043
  }
46020
46044
 
46021
- // src/commands/sessions/daemon/shouldAutoRun.ts
46022
- function shouldAutoRun(session, status2 = session.status) {
46023
- if (!session.autoRun) return { run: false, reason: null };
46024
- if (status2 !== "done")
46025
- return {
46026
- run: false,
46027
- reason: `session status is "${status2}", not "done"`
46028
- };
46029
- if (session.commandType !== "assist")
46030
- return {
46031
- run: false,
46032
- reason: `command type is "${session.commandType}", not "assist"`
46033
- };
46034
- const cmd = session.assistArgs?.[0];
46035
- if (!isDraftCommand(cmd))
46036
- return {
46037
- run: false,
46038
- reason: `command "${cmd ?? "(none)"}" is not draft/bug/refine`
46039
- };
46040
- const itemId2 = session.activity?.itemId;
46041
- if (itemId2 == null)
46042
- return {
46043
- run: false,
46044
- reason: "no itemId in activity (draft did not create an item)"
46045
- };
46046
- return { run: true, itemId: itemId2 };
46047
- }
46048
-
46049
46045
  // src/commands/sessions/daemon/endsStreamLife.ts
46050
46046
  function endsStreamLife(session, status2, sharedWithOtherAgents) {
46051
46047
  if (status2 !== "done" || !session.worktree) return false;
46052
- if (shouldAutoRun(session, status2).run) return false;
46053
46048
  if (!sharedWithOtherAgents(session)) return true;
46054
46049
  daemonLog(
46055
46050
  `session ${session.id} done in ${session.worktree.path}: workspace kept, other agents are still working there`
@@ -46079,17 +46074,6 @@ function finishStatusChange(session, status2, exitCode, deps2) {
46079
46074
  if (status2 === "waiting")
46080
46075
  startTranscriptTitleGeneration(session, deps2.notify);
46081
46076
  if (status2 !== "stopped") session.undurable = void 0;
46082
- const autoRun = shouldAutoRun(session);
46083
- if (autoRun.run) {
46084
- deps2.reuseForRun(session, autoRun.itemId);
46085
- deps2.notify();
46086
- return;
46087
- }
46088
- if (status2 === "done" && autoRun.reason != null) {
46089
- daemonLog(
46090
- `session ${session.id} auto-run enabled but skipped (exit ${exitCode ?? "none"}): ${autoRun.reason}`
46091
- );
46092
- }
46093
46077
  if (shouldAutoDismiss(session, exitCode)) deps2.dismiss(session.id);
46094
46078
  else deps2.notify();
46095
46079
  }
@@ -46124,184 +46108,6 @@ function makeStatusChangeHandler(sessions, deps2) {
46124
46108
  );
46125
46109
  }
46126
46110
 
46127
- // src/commands/sessions/daemon/attachReusedRun.ts
46128
- function attachReusedRun(session, alloc, clients, onStatusChange, tree) {
46129
- broadcast(clients, { type: "clear", sessionId: session.id });
46130
- if (alloc)
46131
- bindNewWorktree(
46132
- session,
46133
- alloc,
46134
- tree?.notify ?? (() => {
46135
- }),
46136
- tree?.startHeld
46137
- );
46138
- else wirePtyEvents(session, clients, onStatusChange);
46139
- }
46140
-
46141
- // src/commands/sessions/daemon/resetCardForRun.ts
46142
- function resetCardForRun(session, assistArgs) {
46143
- session.pty?.kill();
46144
- session.gitWatcher?.close();
46145
- session.gitWatcher = void 0;
46146
- session.undurable = void 0;
46147
- session.assistArgs = assistArgs;
46148
- session.name = `assist ${assistArgs.join(" ")}`;
46149
- session.commandType = "assist";
46150
- session.activity = void 0;
46151
- removeActivity(session.id);
46152
- session.scrollback = "";
46153
- session.startedAt = Date.now();
46154
- session.runningMs = 0;
46155
- session.runningSince = null;
46156
- session.usageSeeded = false;
46157
- setStatus2(session, "running");
46158
- session.restored = void 0;
46159
- session.launchedFrom = void 0;
46160
- }
46161
-
46162
- // src/commands/sessions/daemon/refuseSpawn.ts
46163
- function refuseSpawn(session, error, clients, onStatusChange, stage = "respawned") {
46164
- const reason4 = error instanceof Error ? error.message : String(error);
46165
- session.pty = null;
46166
- session.pendingStart = void 0;
46167
- session.error = reason4;
46168
- daemonLog(
46169
- `session ${session.id} ("${session.name}") not ${stage}: ${reason4}`
46170
- );
46171
- broadcast(clients, { type: "clear", sessionId: session.id });
46172
- emitSessionOutput(
46173
- session,
46174
- clients,
46175
- `\r
46176
- \x1B[31mCannot start this session: ${reason4}\x1B[0m\r
46177
- `
46178
- );
46179
- onStatusChange(session, "error");
46180
- }
46181
-
46182
- // src/commands/sessions/daemon/startReusedRunPty.ts
46183
- function startReusedRunPty(session, assistArgs, itemId2, hold, clients, onStatusChange) {
46184
- try {
46185
- Object.assign(
46186
- session,
46187
- startOrHoldPty(
46188
- () => spawnPty(["assist", ...assistArgs], session.cwd, session.id),
46189
- hold
46190
- )
46191
- );
46192
- } catch (error) {
46193
- refuseSpawn(
46194
- session,
46195
- error,
46196
- clients,
46197
- onStatusChange,
46198
- `reused for backlog run ${itemId2}`
46199
- );
46200
- return false;
46201
- }
46202
- return true;
46203
- }
46204
-
46205
- // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
46206
- var ITEM_ID = /^a?\d+$/;
46207
- function isBacklogRunArgs(args) {
46208
- const [command, subcommand, ...rest] = args;
46209
- if (command !== "backlog" || subcommand !== "run") return false;
46210
- return rest.some((arg) => ITEM_ID.test(arg));
46211
- }
46212
-
46213
- // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
46214
- var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
46215
- "review",
46216
- "review-pr-comments",
46217
- "fix-conflict"
46218
- ]);
46219
- function isPrCheckoutArgs(args) {
46220
- const [command, ...rest] = args;
46221
- if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
46222
- return rest.some((arg) => /^[1-9]\d*$/.test(arg));
46223
- }
46224
-
46225
- // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
46226
- function isCommittingArgs(args) {
46227
- return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
46228
- }
46229
-
46230
- // src/commands/sessions/daemon/worktree/planReuseTree.ts
46231
- function planReuseTree(session, ctx, options2 = {}) {
46232
- if (!ctx || !session.cwd || session.worktree) return void 0;
46233
- const alloc = allocateTree(
46234
- session.cwd,
46235
- boundTreeRoots(ctx.sessions, session),
46236
- options2
46237
- );
46238
- if (alloc.kind !== "worktree" || !alloc.cwd) return void 0;
46239
- daemonLog(
46240
- `session ${session.id} moved from ${session.cwd} to ${alloc.cwd} for its chained run`
46241
- );
46242
- return alloc;
46243
- }
46244
-
46245
- // src/commands/sessions/daemon/failChainedRun.ts
46246
- function failChainedRun(session, itemId2, error, clients, tree) {
46247
- const reason4 = error instanceof Error ? error.message : String(error);
46248
- session.pty = null;
46249
- session.error = `backlog run ${itemId2} could not start: ${reason4}`;
46250
- setStatus2(session, "error");
46251
- daemonLog(
46252
- `session ${session.id} not reused for backlog run ${itemId2}: workspace allocation failed: ${reason4}`
46253
- );
46254
- broadcast(clients, { type: "clear", sessionId: session.id });
46255
- emitSessionOutput(
46256
- session,
46257
- clients,
46258
- `\r
46259
- \x1B[31m${session.error}\x1B[0m\r
46260
- `
46261
- );
46262
- tree?.notify();
46263
- }
46264
-
46265
- // src/commands/sessions/daemon/reuseSessionForRun.ts
46266
- function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
46267
- const assistArgs = ["backlog", "run", String(itemId2)];
46268
- resetCardForRun(session, assistArgs);
46269
- let alloc;
46270
- try {
46271
- alloc = planReuseTree(session, tree, {
46272
- commits: isCommittingArgs(assistArgs),
46273
- backlogRun: true
46274
- });
46275
- } catch (error) {
46276
- failChainedRun(session, itemId2, error, clients, tree);
46277
- return;
46278
- }
46279
- if (alloc) session.cwd = alloc.cwd;
46280
- const started = startReusedRunPty(
46281
- session,
46282
- assistArgs,
46283
- itemId2,
46284
- alloc !== void 0,
46285
- clients,
46286
- onStatusChange
46287
- );
46288
- if (!started) return;
46289
- attachReusedRun(session, alloc, clients, onStatusChange, tree);
46290
- daemonLog(
46291
- `session ${session.id} reused for backlog run ${itemId2}: ${session.name}`
46292
- );
46293
- }
46294
-
46295
- // src/commands/sessions/daemon/managerStatusChangeHandler.ts
46296
- function managerStatusChangeHandler(sessions, clients, dismiss, notify2, treeCtx) {
46297
- const handler = makeStatusChangeHandler(sessions, {
46298
- dismiss,
46299
- notify: notify2,
46300
- reuseForRun: (session, itemId2) => reuseSessionForRun(session, itemId2, clients, handler, treeCtx())
46301
- });
46302
- return handler;
46303
- }
46304
-
46305
46111
  // src/commands/sessions/daemon/applySetStatus.ts
46306
46112
  function applySetStatus(sessions, id, status2, source, onStatusChange, rebind) {
46307
46113
  const session = sessions.get(id);
@@ -46351,6 +46157,26 @@ function setStatusFromHook(sessions, report, notify2, onStatusChange) {
46351
46157
  );
46352
46158
  }
46353
46159
 
46160
+ // src/commands/sessions/daemon/refuseSpawn.ts
46161
+ function refuseSpawn(session, error, clients, onStatusChange, stage = "respawned") {
46162
+ const reason4 = error instanceof Error ? error.message : String(error);
46163
+ session.pty = null;
46164
+ session.pendingStart = void 0;
46165
+ session.error = reason4;
46166
+ daemonLog(
46167
+ `session ${session.id} ("${session.name}") not ${stage}: ${reason4}`
46168
+ );
46169
+ broadcast(clients, { type: "clear", sessionId: session.id });
46170
+ emitSessionOutput(
46171
+ session,
46172
+ clients,
46173
+ `\r
46174
+ \x1B[31mCannot start this session: ${reason4}\x1B[0m\r
46175
+ `
46176
+ );
46177
+ onStatusChange(session, "error");
46178
+ }
46179
+
46354
46180
  // src/commands/sessions/daemon/respawnSession.ts
46355
46181
  function respawnSession(session, respawn, status2, clients, onStatusChange) {
46356
46182
  session.gitWatcher?.close();
@@ -46592,7 +46418,6 @@ function restoreBase(id, persisted) {
46592
46418
  divergenceEscalation: persisted.divergenceEscalation,
46593
46419
  design: persisted.design,
46594
46420
  auto: persisted.auto,
46595
- autoRun: persisted.autoRun,
46596
46421
  autoAdvance: restoredAutoAdvance(id, persisted),
46597
46422
  reviewStarted: persisted.reviewStarted,
46598
46423
  launchedFrom: persisted.launchedFrom
@@ -48297,6 +48122,31 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
48297
48122
  };
48298
48123
  }
48299
48124
 
48125
+ // src/commands/sessions/daemon/worktree/isBacklogRunArgs.ts
48126
+ var ITEM_ID = /^a?\d+$/;
48127
+ function isBacklogRunArgs(args) {
48128
+ const [command, subcommand, ...rest] = args;
48129
+ if (command !== "backlog" || subcommand !== "run") return false;
48130
+ return rest.some((arg) => ITEM_ID.test(arg));
48131
+ }
48132
+
48133
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
48134
+ var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
48135
+ "review",
48136
+ "review-pr-comments",
48137
+ "fix-conflict"
48138
+ ]);
48139
+ function isPrCheckoutArgs(args) {
48140
+ const [command, ...rest] = args;
48141
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
48142
+ return rest.some((arg) => /^[1-9]\d*$/.test(arg));
48143
+ }
48144
+
48145
+ // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
48146
+ function isCommittingArgs(args) {
48147
+ return isPrCheckoutArgs(args) || isBacklogRunArgs(args);
48148
+ }
48149
+
48300
48150
  // src/commands/sessions/daemon/worktree/spawnInTree.ts
48301
48151
  function spawnInTree(ctx, { prompt, cwd, design, auto, harness, inPlace }, context) {
48302
48152
  return allocateAndBind(
@@ -48523,13 +48373,10 @@ var SessionManager = class {
48523
48373
  resume(sessionId, cwd, name, harness) {
48524
48374
  return resumeInTree(this.treeCtx(), sessionId, cwd, name, harness);
48525
48375
  }
48526
- onStatusChange = managerStatusChangeHandler(
48527
- this.sessions,
48528
- this.clients,
48529
- (id) => this.dismissSession(id),
48530
- () => this.notify(),
48531
- () => this.treeCtx()
48532
- );
48376
+ onStatusChange = makeStatusChangeHandler(this.sessions, {
48377
+ dismiss: (id) => this.dismissSession(id),
48378
+ notify: () => this.notify()
48379
+ });
48533
48380
  io = new SessionIo(
48534
48381
  this.sessions,
48535
48382
  () => this.onStatusChange,
@@ -48565,9 +48412,6 @@ var SessionManager = class {
48565
48412
  stopSession(id) {
48566
48413
  stopServerSession(this.sessions, id);
48567
48414
  }
48568
- setAutoRun(id, enabled) {
48569
- if (setAutoRun(this.sessions, id, enabled)) this.notify();
48570
- }
48571
48415
  setTitle(id, title) {
48572
48416
  this.update((sessions) => setSessionTitle(sessions, id, title));
48573
48417
  }
@@ -49141,9 +48985,6 @@ function setSessionCwd(sessions, id, cwd) {
49141
48985
 
49142
48986
  // src/commands/sessions/daemon/sessionSettingHandlers.ts
49143
48987
  var sessionSettingHandlers = {
49144
- "set-autorun": routed(
49145
- (_client, m, d) => m.setAutoRun(d.sessionId, d.enabled)
49146
- ),
49147
48988
  "set-autoadvance": routed(
49148
48989
  (_client, m, d) => m.update(
49149
48990
  (sessions) => setAutoAdvance(
@@ -49329,7 +49170,7 @@ function handleConnection(socket, manager) {
49329
49170
  import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync58 } from "fs";
49330
49171
 
49331
49172
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
49332
- import { readFileSync as readFileSync69 } from "fs";
49173
+ import { readFileSync as readFileSync70 } from "fs";
49333
49174
  var WATCHDOG_INTERVAL_MS = 5e3;
49334
49175
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
49335
49176
  const timer = setInterval(() => {
@@ -49340,7 +49181,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
49340
49181
  }
49341
49182
  function ownsPidFile() {
49342
49183
  try {
49343
- return readFileSync69(daemonPaths.pid, "utf8").trim() === String(process.pid);
49184
+ return readFileSync70(daemonPaths.pid, "utf8").trim() === String(process.pid);
49344
49185
  } catch {
49345
49186
  return false;
49346
49187
  }