@staff0rd/assist 0.1104.0 → 0.1105.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.1104.0",
9
+ version: "0.1105.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -5582,10 +5582,46 @@ function buildSlashCommand(slashCommand, description) {
5582
5582
  return trimmed ? `/${slashCommand} ${trimmed}` : `/${slashCommand}`;
5583
5583
  }
5584
5584
 
5585
+ // src/shared/harnessAdapters/carryTranscriptToTree.ts
5586
+ import { copyFileSync, existsSync as existsSync16, mkdirSync as mkdirSync4 } from "fs";
5587
+ import { join as join17 } from "path";
5588
+ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
5589
+ const dir = projectDirForCwd(toCwd);
5590
+ if (dir === projectDirForCwd(fromCwd)) {
5591
+ daemonLog(
5592
+ `transcript ${claudeSessionId} already lives in ${dir}: resuming in the original worktree path`
5593
+ );
5594
+ return;
5595
+ }
5596
+ const dest = join17(dir, `${claudeSessionId}.jsonl`);
5597
+ if (existsSync16(dest)) {
5598
+ daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
5599
+ return;
5600
+ }
5601
+ const source = findTranscriptPathSync(fromCwd, claudeSessionId);
5602
+ if (!source) {
5603
+ daemonLog(
5604
+ `transcript ${claudeSessionId} not found under ${projectDirForCwd(fromCwd)}: resuming in ${toCwd} without it`
5605
+ );
5606
+ return;
5607
+ }
5608
+ try {
5609
+ mkdirSync4(dir, { recursive: true });
5610
+ copyFileSync(source, dest);
5611
+ daemonLog(
5612
+ `transcript ${source} copied to ${dest} so ${toCwd} can resume it`
5613
+ );
5614
+ } catch (error) {
5615
+ daemonLog(
5616
+ `transcript ${claudeSessionId} could not be copied to ${dir}: ${error instanceof Error ? error.message : String(error)}`
5617
+ );
5618
+ }
5619
+ }
5620
+
5585
5621
  // src/shared/harnessAdapters/claudeConnectorProbe.ts
5586
5622
  import { readFileSync as readFileSync7 } from "fs";
5587
5623
  import { homedir as homedir8 } from "os";
5588
- import { join as join17 } from "path";
5624
+ import { join as join18 } from "path";
5589
5625
 
5590
5626
  // src/shared/harnessAdapters/unsupported.ts
5591
5627
  var supported = { supported: true };
@@ -5598,7 +5634,7 @@ function knownConnectedConnectors() {
5598
5634
  const dir = process.env.CLAUDE_CONFIG_DIR ?? homedir8();
5599
5635
  try {
5600
5636
  const state = JSON.parse(
5601
- readFileSync7(join17(dir, ".claude.json"), "utf8")
5637
+ readFileSync7(join18(dir, ".claude.json"), "utf8")
5602
5638
  );
5603
5639
  const list7 = state.claudeAiMcpEverConnected;
5604
5640
  return Array.isArray(list7) ? list7.filter((name2) => typeof name2 === "string") : void 0;
@@ -6846,6 +6882,7 @@ var harnessCapabilityDeclarations = {
6846
6882
  claude: {
6847
6883
  "skills.native": supported,
6848
6884
  "conversation.resume": supported,
6885
+ "conversation.relocate": supported,
6849
6886
  "conversation.preassignId": supported,
6850
6887
  "transcript.read": supported,
6851
6888
  "oneShot.text": supported,
@@ -6862,6 +6899,7 @@ var harnessCapabilityDeclarations = {
6862
6899
  codex: {
6863
6900
  "skills.native": supported,
6864
6901
  "conversation.resume": supported,
6902
+ "conversation.relocate": supported,
6865
6903
  "conversation.preassignId": unsupported(
6866
6904
  "Codex assigns its own conversation id when its rollout starts",
6867
6905
  "assist binds the Codex conversation id from the rollout after launch"
@@ -6901,6 +6939,11 @@ var harnessCapabilityDeclarations = {
6901
6939
  "restart starts a fresh pi conversation; pick Claude or Codex to keep the conversation across restarts",
6902
6940
  "a696"
6903
6941
  ),
6942
+ "conversation.relocate": unsupported(
6943
+ "pi sessions cannot be resumed, so a pi conversation cannot continue in a replacement worktree",
6944
+ "start a fresh session in the replacement worktree; pick Claude or Codex to keep the conversation across worktree replacement",
6945
+ "a696"
6946
+ ),
6904
6947
  "conversation.preassignId": unsupported(
6905
6948
  "pi does not accept a caller-assigned conversation id",
6906
6949
  "the session card tracks pi without a conversation id"
@@ -6964,6 +7007,7 @@ var claudeAdapter = {
6964
7007
  current: () => process.env.CLAUDE_CODE_SESSION_ID || void 0,
6965
7008
  boundId: ({ claudeSessionId }) => claudeSessionId,
6966
7009
  toRef: (claudeSessionId, cwd) => ({ cwd, claudeSessionId }),
7010
+ relocate: carryTranscriptToTree,
6967
7011
  reader: claudeConversationReader
6968
7012
  },
6969
7013
  toolOperations: claudeToolOperations,
@@ -6979,10 +7023,19 @@ var claudeAdapter = {
6979
7023
  allowEdits: allowEdits ?? true,
6980
7024
  resumeSessionId: conversationId
6981
7025
  }),
6982
- interactive: ({ sessionId: sessionId2, conversationId, prompt, cwd, design, auto }) => spawnClaude({
7026
+ interactive: ({
7027
+ sessionId: sessionId2,
7028
+ conversationId,
7029
+ resumeId,
7030
+ prompt,
7031
+ cwd,
7032
+ design,
7033
+ auto
7034
+ }) => spawnClaude({
6983
7035
  prompt,
6984
7036
  cwd,
6985
7037
  sessionId: sessionId2,
7038
+ resumeSessionId: resumeId,
6986
7039
  claudeSessionId: conversationId,
6987
7040
  design,
6988
7041
  auto
@@ -7101,13 +7154,13 @@ import * as fs4 from "fs";
7101
7154
  import * as path11 from "path";
7102
7155
 
7103
7156
  // src/commands/sessions/shared/codex/codexSessionsDir.ts
7104
- import { existsSync as existsSync16 } from "fs";
7157
+ import { existsSync as existsSync17 } from "fs";
7105
7158
  import * as path10 from "path";
7106
7159
  function codexSessionsDir() {
7107
7160
  return path10.join(harnesses.codex.homeDir, "sessions");
7108
7161
  }
7109
7162
  function hasCodexSessions() {
7110
- return existsSync16(codexSessionsDir());
7163
+ return existsSync17(codexSessionsDir());
7111
7164
  }
7112
7165
 
7113
7166
  // src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
@@ -7251,7 +7304,12 @@ async function readCodexHeadLines(filePath, maxLines = DEFAULT_MAX_LINES) {
7251
7304
 
7252
7305
  // src/commands/sessions/shared/codex/resolveCodexSessionId.ts
7253
7306
  var META_LINES = 5;
7254
- async function resolveCodexSessionId(cwd, sinceMs) {
7307
+ async function resolveCodexSessionId({
7308
+ cwd,
7309
+ launchedAt,
7310
+ sinceMs,
7311
+ claimed
7312
+ }) {
7255
7313
  if (!cwd) return null;
7256
7314
  const paths = await discoverCodexRolloutPaths();
7257
7315
  const touched = await Promise.all(
@@ -7260,14 +7318,17 @@ async function resolveCodexSessionId(cwd, sinceMs) {
7260
7318
  const candidates = await Promise.all(
7261
7319
  paths.filter((_, index3) => touched[index3]).map((file) => startedIn(file, cwd, sinceMs))
7262
7320
  );
7263
- return newestSessionId(candidates);
7321
+ return firstUnclaimedRolloutAfterLaunch(
7322
+ candidates.filter(
7323
+ (candidate) => !!candidate && !claimed.has(candidate.sessionId)
7324
+ ),
7325
+ launchedAt
7326
+ );
7264
7327
  }
7265
- function newestSessionId(candidates) {
7266
- let best = null;
7267
- for (const candidate of candidates)
7268
- if (candidate && (!best || candidate.startedAt > best.startedAt))
7269
- best = candidate;
7270
- return best?.sessionId ?? null;
7328
+ function firstUnclaimedRolloutAfterLaunch(rollouts, launchedAt) {
7329
+ const byStart = [...rollouts].sort((a, b) => a.startedAt - b.startedAt);
7330
+ const afterLaunch = byStart.find((r) => r.startedAt >= launchedAt);
7331
+ return (afterLaunch ?? byStart.at(-1))?.sessionId ?? null;
7271
7332
  }
7272
7333
  async function startedIn(file, cwd, sinceMs) {
7273
7334
  const meta = codexRolloutMeta(await readCodexHeadLines(file, META_LINES));
@@ -7552,8 +7613,8 @@ var codexConversationReader = {
7552
7613
  };
7553
7614
 
7554
7615
  // src/shared/readCodexRulePerms.ts
7555
- import { existsSync as existsSync17, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
7556
- import { join as join22 } from "path";
7616
+ import { existsSync as existsSync18, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
7617
+ import { join as join23 } from "path";
7557
7618
 
7558
7619
  // src/shared/readPatternList.ts
7559
7620
  function readString(text19, start2) {
@@ -7631,17 +7692,17 @@ function parseCodexRules(text19) {
7631
7692
 
7632
7693
  // src/shared/readCodexRulePerms.ts
7633
7694
  function ruleFiles(dir) {
7634
- if (!existsSync17(dir)) return [];
7695
+ if (!existsSync18(dir)) return [];
7635
7696
  try {
7636
- return readdirSync5(dir).filter((name2) => name2.endsWith(".rules")).sort().map((name2) => join22(dir, name2));
7697
+ return readdirSync5(dir).filter((name2) => name2.endsWith(".rules")).sort().map((name2) => join23(dir, name2));
7637
7698
  } catch {
7638
7699
  return [];
7639
7700
  }
7640
7701
  }
7641
7702
  function readCodexRulePerms(key) {
7642
7703
  const dirs = [
7643
- join22(harnesses.codex.homeDir, "rules"),
7644
- join22(process.cwd(), ".codex", "rules")
7704
+ join23(harnesses.codex.homeDir, "rules"),
7705
+ join23(process.cwd(), ".codex", "rules")
7645
7706
  ];
7646
7707
  return dirs.flatMap(ruleFiles).flatMap((file) => {
7647
7708
  try {
@@ -7730,8 +7791,15 @@ async function codexOneShot(prompt, { timeout, effort = "low", cwd }) {
7730
7791
  return (await run5).stdout;
7731
7792
  }
7732
7793
 
7794
+ // src/shared/harnessAdapters/codexRelocate.ts
7795
+ function codexRelocate(conversationId, fromCwd, toCwd) {
7796
+ daemonLog(
7797
+ `Codex conversation ${conversationId} resumes in ${toCwd} from its rollout, which is stored by id rather than under ${fromCwd}`
7798
+ );
7799
+ }
7800
+
7733
7801
  // src/commands/review/runCodexReviewer.ts
7734
- import { existsSync as existsSync18, unlinkSync as unlinkSync2 } from "fs";
7802
+ import { existsSync as existsSync19, unlinkSync as unlinkSync2 } from "fs";
7735
7803
 
7736
7804
  // src/commands/review/parseCodexUsage.ts
7737
7805
  function parseCodexUsage(usage) {
@@ -7820,7 +7888,7 @@ async function runCodexReviewer(spec) {
7820
7888
  ...override.args.length > 0 ? { env: override.env } : {},
7821
7889
  onLine
7822
7890
  });
7823
- if (result.exitCode !== 0 && existsSync18(spec.outputPath)) {
7891
+ if (result.exitCode !== 0 && existsSync19(spec.outputPath)) {
7824
7892
  unlinkSync2(spec.outputPath);
7825
7893
  }
7826
7894
  const finalised = finaliseReviewerRun(
@@ -7938,6 +8006,7 @@ var codexAdapter = {
7938
8006
  boundId: ({ harnessSessionId }) => harnessSessionId,
7939
8007
  toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId }),
7940
8008
  discover: resolveCodexSessionId,
8009
+ relocate: codexRelocate,
7941
8010
  reader: codexConversationReader
7942
8011
  },
7943
8012
  toolOperations: codexToolOperations,
@@ -7949,7 +8018,7 @@ var codexAdapter = {
7949
8018
  sandbox: sandbox(allowEdits),
7950
8019
  resumeSessionId: conversationId
7951
8020
  }),
7952
- interactive: ({ sessionId: sessionId2, prompt, cwd }) => spawnCodex({ prompt, cwd, sessionId: sessionId2 }),
8021
+ interactive: ({ sessionId: sessionId2, resumeId, prompt, cwd }) => spawnCodex({ prompt, cwd, sessionId: sessionId2, resumeSessionId: resumeId }),
7953
8022
  oneShot: codexOneShot,
7954
8023
  structured: codexStructuredRun,
7955
8024
  connectorRun: rejectConnectorRun("Codex"),
@@ -8036,13 +8105,14 @@ var piAdapter = {
8036
8105
  locate: () => Promise.resolve(null),
8037
8106
  current: () => void 0,
8038
8107
  boundId: () => void 0,
8039
- toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId })
8108
+ toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId }),
8109
+ relocate: cannotResume
8040
8110
  },
8041
8111
  toolOperations: piToolOperations,
8042
8112
  launchSkill: (skill, args, { cwd }) => spawnPi2(buildSlashCommand(skill, args), { cwd }),
8043
8113
  launchPrompt: (prompt, { cwd }) => spawnPi2(prompt, { cwd }),
8044
8114
  resume: cannotResume,
8045
- interactive: ({ sessionId: sessionId2, prompt, cwd }) => spawnPi({ prompt, cwd, sessionId: sessionId2 }),
8115
+ interactive: ({ sessionId: sessionId2, resumeId, prompt, cwd }) => resumeId ? cannotResume() : spawnPi({ prompt, cwd, sessionId: sessionId2 }),
8046
8116
  oneShot: noOneShot,
8047
8117
  structured: noOneShot,
8048
8118
  connectorRun: rejectConnectorRun("pi"),
@@ -8401,12 +8471,12 @@ async function diffScopes(req, res) {
8401
8471
  }
8402
8472
 
8403
8473
  // src/commands/sessions/daemon/recordPromptJournal.ts
8404
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4 } from "fs";
8474
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5 } from "fs";
8405
8475
  import { dirname as dirname9 } from "path";
8406
8476
  function recordPromptJournal(entry) {
8407
8477
  const line = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), ...entry });
8408
8478
  try {
8409
- mkdirSync4(dirname9(daemonPaths.promptJournal), { recursive: true });
8479
+ mkdirSync5(dirname9(daemonPaths.promptJournal), { recursive: true });
8410
8480
  appendFileSync2(daemonPaths.promptJournal, `${line}
8411
8481
  `);
8412
8482
  } catch {
@@ -8579,11 +8649,11 @@ async function fileContent(req, res) {
8579
8649
  import { basename as basename7 } from "path";
8580
8650
 
8581
8651
  // src/commands/sessions/web/fromGithub/listClones.ts
8582
- import { existsSync as existsSync19, readdirSync as readdirSync6 } from "fs";
8583
- import { join as join23 } from "path";
8652
+ import { existsSync as existsSync20, readdirSync as readdirSync6 } from "fs";
8653
+ import { join as join24 } from "path";
8584
8654
  function listClones(baseDir) {
8585
- if (!existsSync19(baseDir)) return [];
8586
- return readdirSync6(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join23(baseDir, entry.name)).filter((dir) => existsSync19(join23(dir, ".git"))).sort();
8655
+ if (!existsSync20(baseDir)) return [];
8656
+ return readdirSync6(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join24(baseDir, entry.name)).filter((dir) => existsSync20(join24(dir, ".git"))).sort();
8587
8657
  }
8588
8658
 
8589
8659
  // src/commands/sessions/web/fromGithub/getClones.ts
@@ -8742,8 +8812,8 @@ function azureDevopsRepoUrl({ org, project, repo }) {
8742
8812
  }
8743
8813
 
8744
8814
  // src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
8745
- import { existsSync as existsSync20, readdirSync as readdirSync7 } from "fs";
8746
- import { join as join24 } from "path";
8815
+ import { existsSync as existsSync21, readdirSync as readdirSync7 } from "fs";
8816
+ import { join as join25 } from "path";
8747
8817
 
8748
8818
  // src/shared/azureDevops/parseAzureDevopsRemote.ts
8749
8819
  var HTTPS_DEV = /^https?:\/\/(?:[^@/]+@)?dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+)$/i;
@@ -8764,15 +8834,15 @@ function sameAzureDevopsRepo(a, b) {
8764
8834
 
8765
8835
  // src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
8766
8836
  function clonesRepo(dir, repo) {
8767
- if (!existsSync20(join24(dir, ".git"))) return false;
8837
+ if (!existsSync21(join25(dir, ".git"))) return false;
8768
8838
  const url = remoteUrl(dir).url;
8769
8839
  const remote = url ? parseAzureDevopsRemote(url) : null;
8770
8840
  return remote !== null && sameAzureDevopsRepo(remote, repo);
8771
8841
  }
8772
8842
  function findAzureDevopsClone(repo, baseDir) {
8773
- if (!existsSync20(baseDir)) return void 0;
8774
- const named = join24(baseDir, repo.repo);
8775
- const others = readdirSync7(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join24(baseDir, entry.name)).filter((dir) => dir !== named).sort();
8843
+ if (!existsSync21(baseDir)) return void 0;
8844
+ const named = join25(baseDir, repo.repo);
8845
+ const others = readdirSync7(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join25(baseDir, entry.name)).filter((dir) => dir !== named).sort();
8776
8846
  return [named, ...others].find((dir) => clonesRepo(dir, repo));
8777
8847
  }
8778
8848
 
@@ -10611,14 +10681,14 @@ function assertNoDuplicateRunNames(configs) {
10611
10681
  }
10612
10682
 
10613
10683
  // src/shared/findLinkedConfigPath.ts
10614
- import { existsSync as existsSync21 } from "fs";
10615
- import { join as join25, resolve as resolve5 } from "path";
10684
+ import { existsSync as existsSync22 } from "fs";
10685
+ import { join as join26, resolve as resolve5 } from "path";
10616
10686
  function findLinkedConfigPath(linkPath, fromDir) {
10617
10687
  const resolved = resolve5(fromDir, linkPath);
10618
- const claudePath = join25(resolved, ".claude", "assist.yml");
10619
- if (existsSync21(claudePath)) return claudePath;
10620
- const rootPath = join25(resolved, "assist.yml");
10621
- if (existsSync21(rootPath)) return rootPath;
10688
+ const claudePath = join26(resolved, ".claude", "assist.yml");
10689
+ if (existsSync22(claudePath)) return claudePath;
10690
+ const rootPath = join26(resolved, "assist.yml");
10691
+ if (existsSync22(rootPath)) return rootPath;
10622
10692
  throw new Error(`No assist.yml found in linked project: ${resolved}`);
10623
10693
  }
10624
10694
 
@@ -10708,18 +10778,18 @@ function handleServerRuns(req, res) {
10708
10778
  import { execFile as execFile6 } from "child_process";
10709
10779
  import { readFileSync as readFileSync9 } from "fs";
10710
10780
  import { homedir as homedir10 } from "os";
10711
- import { basename as basename10, join as join27 } from "path";
10781
+ import { basename as basename10, join as join28 } from "path";
10712
10782
  import { promisify as promisify6 } from "util";
10713
10783
 
10714
10784
  // src/commands/sessions/web/findSynthesisForBranch.ts
10715
- import { existsSync as existsSync22, readdirSync as readdirSync8, statSync as statSync6 } from "fs";
10716
- import { basename as basename9, dirname as dirname11, join as join26 } from "path";
10785
+ import { existsSync as existsSync23, readdirSync as readdirSync8, statSync as statSync6 } from "fs";
10786
+ import { basename as basename9, dirname as dirname11, join as join27 } from "path";
10717
10787
  function findSynthesisForBranch(repoReviewsDir, branch2) {
10718
- const branchKeyPath = join26(repoReviewsDir, `${branch2}-`);
10788
+ const branchKeyPath = join27(repoReviewsDir, `${branch2}-`);
10719
10789
  const parent = dirname11(branchKeyPath);
10720
10790
  const branchPrefix = basename9(branchKeyPath);
10721
- if (!existsSync22(parent)) return null;
10722
- const synthesisFiles = readdirSync8(parent).filter((name2) => name2.startsWith(branchPrefix)).map((name2) => join26(parent, name2, "synthesis.md")).filter((path110) => existsSync22(path110)).map((path110) => ({ path: path110, mtime: statSync6(path110).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
10791
+ if (!existsSync23(parent)) return null;
10792
+ const synthesisFiles = readdirSync8(parent).filter((name2) => name2.startsWith(branchPrefix)).map((name2) => join27(parent, name2, "synthesis.md")).filter((path110) => existsSync23(path110)).map((path110) => ({ path: path110, mtime: statSync6(path110).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
10723
10793
  return synthesisFiles[0]?.path ?? null;
10724
10794
  }
10725
10795
 
@@ -10737,7 +10807,7 @@ async function resolveSynthesisPath(cwd) {
10737
10807
  runGit2(cwd, ["rev-parse", "--show-toplevel"]),
10738
10808
  runGit2(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
10739
10809
  ]);
10740
- const repoReviewsDir = join27(
10810
+ const repoReviewsDir = join28(
10741
10811
  homedir10(),
10742
10812
  ".assist",
10743
10813
  "reviews",
@@ -11341,34 +11411,34 @@ function resolveRewindPlan(item) {
11341
11411
  }
11342
11412
 
11343
11413
  // src/commands/backlog/writeSignal.ts
11344
- import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
11414
+ import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
11345
11415
  import { homedir as homedir12 } from "os";
11346
- import { dirname as dirname13, join as join29 } from "path";
11416
+ import { dirname as dirname13, join as join30 } from "path";
11347
11417
  import chalk10 from "chalk";
11348
11418
 
11349
11419
  // src/commands/backlog/recordSignalOwner.ts
11350
11420
  import {
11351
- existsSync as existsSync23,
11352
- mkdirSync as mkdirSync5,
11421
+ existsSync as existsSync24,
11422
+ mkdirSync as mkdirSync6,
11353
11423
  readFileSync as readFileSync10,
11354
11424
  rmSync as rmSync3,
11355
11425
  writeFileSync as writeFileSync6
11356
11426
  } from "fs";
11357
11427
  import { homedir as homedir11 } from "os";
11358
- import { dirname as dirname12, join as join28 } from "path";
11428
+ import { dirname as dirname12, join as join29 } from "path";
11359
11429
  function getOwnerPath(itemId2) {
11360
- return join28(homedir11(), ".assist", "signals", `owner-${itemId2}.json`);
11430
+ return join29(homedir11(), ".assist", "signals", `owner-${itemId2}.json`);
11361
11431
  }
11362
11432
  function recordSignalOwner(itemId2) {
11363
11433
  const sessionId2 = process.env.ASSIST_SESSION_ID;
11364
11434
  if (!sessionId2) return;
11365
11435
  const path110 = getOwnerPath(itemId2);
11366
- mkdirSync5(dirname12(path110), { recursive: true });
11436
+ mkdirSync6(dirname12(path110), { recursive: true });
11367
11437
  writeFileSync6(path110, JSON.stringify({ sessionId: sessionId2 }));
11368
11438
  }
11369
11439
  function readSignalOwner(itemId2) {
11370
11440
  const path110 = getOwnerPath(itemId2);
11371
- if (!existsSync23(path110)) return void 0;
11441
+ if (!existsSync24(path110)) return void 0;
11372
11442
  try {
11373
11443
  const parsed = JSON.parse(readFileSync10(path110, "utf8"));
11374
11444
  return parsed.sessionId;
@@ -11387,7 +11457,7 @@ function clearSignalOwner(itemId2) {
11387
11457
  // src/commands/backlog/writeSignal.ts
11388
11458
  function getSignalPath(sessionId2 = process.env.ASSIST_SESSION_ID) {
11389
11459
  if (!sessionId2) return void 0;
11390
- return join29(homedir12(), ".assist", "signals", `signal-${sessionId2}.json`);
11460
+ return join30(homedir12(), ".assist", "signals", `signal-${sessionId2}.json`);
11391
11461
  }
11392
11462
  function resolveSignalTarget(event, data) {
11393
11463
  const caller = process.env.ASSIST_SESSION_ID;
@@ -11419,7 +11489,7 @@ function writeSignal(event, data) {
11419
11489
  const path110 = getSignalPath(target);
11420
11490
  if (!path110) return;
11421
11491
  const signal = { event, sessionId: target, ...data };
11422
- mkdirSync6(dirname13(path110), { recursive: true });
11492
+ mkdirSync7(dirname13(path110), { recursive: true });
11423
11493
  writeFileSync7(path110, JSON.stringify(signal));
11424
11494
  }
11425
11495
 
@@ -11892,6 +11962,21 @@ var sessionFeature = {
11892
11962
  label: "A new session",
11893
11963
  requires: [...editEnforcement]
11894
11964
  };
11965
+ var conversationResumeFeature = {
11966
+ id: "conversationResume",
11967
+ label: "Resuming a conversation",
11968
+ requires: ["conversation.resume"]
11969
+ };
11970
+ var conversationRecoveryFeature = {
11971
+ id: "conversationRecovery",
11972
+ label: "Resuming a conversation in a replacement worktree",
11973
+ requires: ["conversation.resume", "conversation.relocate"]
11974
+ };
11975
+ var divergenceEscalationFeature = {
11976
+ id: "divergenceEscalation",
11977
+ label: "Divergence escalation",
11978
+ requires: [...editEnforcement]
11979
+ };
11895
11980
  var previewQuestionsFeature = {
11896
11981
  id: "previewQuestions",
11897
11982
  label: "Preview-pane questions",
@@ -11951,6 +12036,9 @@ var harnessFeatures = [
11951
12036
  refineFeature,
11952
12037
  buildFeature,
11953
12038
  sessionFeature,
12039
+ conversationResumeFeature,
12040
+ conversationRecoveryFeature,
12041
+ divergenceEscalationFeature,
11954
12042
  branchSlugFeature,
11955
12043
  sessionTitleFeature,
11956
12044
  messagePreviewsFeature,
@@ -13287,7 +13375,7 @@ async function nextPickup(req, res) {
13287
13375
  import path18 from "path";
13288
13376
 
13289
13377
  // src/commands/rules/readScopedRules.ts
13290
- import { existsSync as existsSync25, readFileSync as readFileSync11 } from "fs";
13378
+ import { existsSync as existsSync26, readFileSync as readFileSync11 } from "fs";
13291
13379
  import path17 from "path";
13292
13380
 
13293
13381
  // src/commands/rules/rulesSectionRange.ts
@@ -13336,11 +13424,11 @@ function parseRulesSection(content) {
13336
13424
  }
13337
13425
 
13338
13426
  // src/commands/rules/scopeDirectory.ts
13339
- import { existsSync as existsSync24, statSync as statSync7 } from "fs";
13427
+ import { existsSync as existsSync25, statSync as statSync7 } from "fs";
13340
13428
  import path16 from "path";
13341
13429
  function scopeDirectory(target) {
13342
13430
  const resolved = path16.resolve(target);
13343
- return existsSync24(resolved) && statSync7(resolved).isDirectory() ? resolved : path16.dirname(resolved);
13431
+ return existsSync25(resolved) && statSync7(resolved).isDirectory() ? resolved : path16.dirname(resolved);
13344
13432
  }
13345
13433
 
13346
13434
  // src/commands/rules/readScopedRules.ts
@@ -13351,7 +13439,7 @@ function scopedClaudeFiles(target) {
13351
13439
  let current2 = startDir;
13352
13440
  while (true) {
13353
13441
  const candidate = path17.join(current2, "CLAUDE.md");
13354
- if (existsSync25(candidate)) files.push(candidate);
13442
+ if (existsSync26(candidate)) files.push(candidate);
13355
13443
  if (current2 === root2 || current2 === path17.dirname(current2)) break;
13356
13444
  current2 = path17.dirname(current2);
13357
13445
  }
@@ -14705,7 +14793,7 @@ async function revertDiffFile(req, res) {
14705
14793
 
14706
14794
  // src/commands/run/runCommandToCompletion.ts
14707
14795
  import { spawn as spawn6 } from "child_process";
14708
- import { existsSync as existsSync27 } from "fs";
14796
+ import { existsSync as existsSync28 } from "fs";
14709
14797
 
14710
14798
  // src/shared/expandEnv.ts
14711
14799
  import { homedir as homedir13 } from "os";
@@ -14720,15 +14808,15 @@ function expandEnv(env) {
14720
14808
 
14721
14809
  // src/commands/run/resolveCommand.ts
14722
14810
  import { execFileSync as execFileSync4 } from "child_process";
14723
- import { existsSync as existsSync26 } from "fs";
14724
- import { dirname as dirname14, join as join30, resolve as resolve10 } from "path";
14811
+ import { existsSync as existsSync27 } from "fs";
14812
+ import { dirname as dirname14, join as join31, resolve as resolve10 } from "path";
14725
14813
  function resolveCommand(command) {
14726
14814
  if (process.platform !== "win32" || command !== "bash") return command;
14727
14815
  try {
14728
14816
  const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
14729
14817
  const gitRoot = resolve10(dirname14(gitPath), "..");
14730
- const gitBash = join30(gitRoot, "bin", "bash.exe");
14731
- if (existsSync26(gitBash)) return gitBash;
14818
+ const gitBash = join31(gitRoot, "bin", "bash.exe");
14819
+ if (existsSync27(gitBash)) return gitBash;
14732
14820
  } catch {
14733
14821
  return command;
14734
14822
  }
@@ -14738,7 +14826,7 @@ function resolveCommand(command) {
14738
14826
  // src/commands/run/runCommandToCompletion.ts
14739
14827
  function runCommandToCompletion(command, args, env, cwd, quiet) {
14740
14828
  return new Promise((resolveResult) => {
14741
- if (cwd && !existsSync27(cwd)) {
14829
+ if (cwd && !existsSync28(cwd)) {
14742
14830
  resolveResult({
14743
14831
  kind: "failed",
14744
14832
  message: `Failed to execute command: cwd ${cwd} does not exist`
@@ -15980,11 +16068,11 @@ async function readUserConfig(orm) {
15980
16068
  }
15981
16069
 
15982
16070
  // src/shared/writeRepoConfigCache.ts
15983
- import { mkdirSync as mkdirSync7, renameSync as renameSync3, writeFileSync as writeFileSync8 } from "fs";
16071
+ import { mkdirSync as mkdirSync8, renameSync as renameSync3, writeFileSync as writeFileSync8 } from "fs";
15984
16072
  import { dirname as dirname15 } from "path";
15985
16073
  function writeRepoConfigCache(repos2, user = {}) {
15986
16074
  const path110 = repoConfigCachePath();
15987
- mkdirSync7(dirname15(path110), { recursive: true });
16075
+ mkdirSync8(dirname15(path110), { recursive: true });
15988
16076
  const cache7 = {
15989
16077
  refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
15990
16078
  repos: repos2,
@@ -16490,17 +16578,17 @@ var autoRestartWait = {
16490
16578
 
16491
16579
  // src/commands/extension/fetchLatestSignedExtension.ts
16492
16580
  import { readFile as readFile2 } from "fs/promises";
16493
- import { join as join32 } from "path";
16581
+ import { join as join33 } from "path";
16494
16582
 
16495
16583
  // src/commands/extension/extensionDir.ts
16496
- import { existsSync as existsSync28 } from "fs";
16497
- import { dirname as dirname16, join as join31 } from "path";
16584
+ import { existsSync as existsSync29 } from "fs";
16585
+ import { dirname as dirname16, join as join32 } from "path";
16498
16586
  import { fileURLToPath as fileURLToPath3 } from "url";
16499
16587
  var moduleDir = dirname16(fileURLToPath3(import.meta.url));
16500
16588
  function extensionDir() {
16501
- const bundled = join31(moduleDir, "commands", "extension", "extension");
16502
- if (existsSync28(bundled)) return bundled;
16503
- return join31(moduleDir, "..", "..", "..", "extension");
16589
+ const bundled = join32(moduleDir, "commands", "extension", "extension");
16590
+ if (existsSync29(bundled)) return bundled;
16591
+ return join32(moduleDir, "..", "..", "..", "extension");
16504
16592
  }
16505
16593
 
16506
16594
  // src/commands/extension/latestUpdate.ts
@@ -16512,7 +16600,7 @@ function latestUpdate(manifest, updates2) {
16512
16600
  // src/commands/extension/fetchLatestSignedExtension.ts
16513
16601
  async function fetchLatestSignedExtension() {
16514
16602
  const manifest = await readFile2(
16515
- join32(extensionDir(), "manifest.json"),
16603
+ join33(extensionDir(), "manifest.json"),
16516
16604
  "utf8"
16517
16605
  );
16518
16606
  const updateUrl = JSON.parse(manifest).browser_specific_settings.gecko.update_url;
@@ -16539,7 +16627,7 @@ function latestSignedExtension(now = Date.now()) {
16539
16627
  }
16540
16628
 
16541
16629
  // src/commands/watch/isBuildPending.ts
16542
- import { existsSync as existsSync30 } from "fs";
16630
+ import { existsSync as existsSync31 } from "fs";
16543
16631
 
16544
16632
  // src/commands/watch/gitMarkerPath.ts
16545
16633
  import { resolve as resolve11 } from "path";
@@ -16556,7 +16644,7 @@ function buildPendingPath(cwd) {
16556
16644
  }
16557
16645
 
16558
16646
  // src/commands/watch/readBuiltVersion.ts
16559
- import { join as join34 } from "path";
16647
+ import { join as join35 } from "path";
16560
16648
 
16561
16649
  // src/shared/readPackageJson.ts
16562
16650
  import * as fs10 from "fs";
@@ -16606,7 +16694,7 @@ function findPackageJsonWithVerifyScripts(startDir) {
16606
16694
  function readBuiltVersion(cwd) {
16607
16695
  try {
16608
16696
  const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
16609
- return readPackageJson(join34(root2, "package.json")).version ?? "unknown";
16697
+ return readPackageJson(join35(root2, "package.json")).version ?? "unknown";
16610
16698
  } catch {
16611
16699
  return "unknown";
16612
16700
  }
@@ -16614,11 +16702,11 @@ function readBuiltVersion(cwd) {
16614
16702
 
16615
16703
  // src/commands/watch/readDistVersion.ts
16616
16704
  import { readFileSync as readFileSync13 } from "fs";
16617
- import { join as join35 } from "path";
16705
+ import { join as join36 } from "path";
16618
16706
  function readDistVersion(cwd) {
16619
16707
  try {
16620
16708
  const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
16621
- return readFileSync13(join35(root2, "dist", "built-version"), "utf8").trim();
16709
+ return readFileSync13(join36(root2, "dist", "built-version"), "utf8").trim();
16622
16710
  } catch {
16623
16711
  return void 0;
16624
16712
  }
@@ -16633,7 +16721,7 @@ function isDistBehind(cwd) {
16633
16721
  // src/commands/watch/isBuildPending.ts
16634
16722
  function markedPending(cwd) {
16635
16723
  try {
16636
- return existsSync30(buildPendingPath(cwd));
16724
+ return existsSync31(buildPendingPath(cwd));
16637
16725
  } catch {
16638
16726
  return false;
16639
16727
  }
@@ -16729,7 +16817,7 @@ function stripAnsi(text19) {
16729
16817
  // src/commands/sessions/daemon/worktree/watcherLogPath.ts
16730
16818
  import { createHash } from "crypto";
16731
16819
  import { homedir as homedir14 } from "os";
16732
- import { basename as basename13, join as join36 } from "path";
16820
+ import { basename as basename13, join as join37 } from "path";
16733
16821
 
16734
16822
  // src/commands/sessions/daemon/worktree/canonicalTreePath.ts
16735
16823
  import { realpathSync } from "fs";
@@ -16746,8 +16834,8 @@ function canonicalTreePath(path110) {
16746
16834
  function watcherLogPath(cwd) {
16747
16835
  const clone = canonicalTreePath(cwd);
16748
16836
  const key = createHash("sha1").update(clone).digest("hex").slice(0, 8);
16749
- const dir = process.env.ASSIST_WATCHER_LOG_DIR ?? join36(homedir14(), ".assist", "watchers");
16750
- return join36(dir, `${basename13(clone) || "root"}-${key}.log`);
16837
+ const dir = process.env.ASSIST_WATCHER_LOG_DIR ?? join37(homedir14(), ".assist", "watchers");
16838
+ return join37(dir, `${basename13(clone) || "root"}-${key}.log`);
16751
16839
  }
16752
16840
 
16753
16841
  // src/commands/sessions/web/updates/readUpdateHistory.ts
@@ -16875,7 +16963,7 @@ async function readRequestBuffer(req, limit) {
16875
16963
 
16876
16964
  // src/commands/sessions/web/stageAttachment.ts
16877
16965
  import { mkdir, mkdtemp, writeFile } from "fs/promises";
16878
- import { extname as extname2, join as join37 } from "path";
16966
+ import { extname as extname2, join as join38 } from "path";
16879
16967
 
16880
16968
  // src/commands/sessions/web/ghAttachableExtensions.ts
16881
16969
  var ghAttachableExtensions = /* @__PURE__ */ new Set([
@@ -16907,9 +16995,9 @@ function safeBaseName(name2) {
16907
16995
  async function stageAttachment(name2, contentType, body) {
16908
16996
  const ext = pickExtension(name2, contentType);
16909
16997
  await mkdir(stagedAttachmentsDir, { recursive: true });
16910
- const dir = await mkdtemp(join37(stagedAttachmentsDir, "upload-"));
16998
+ const dir = await mkdtemp(join38(stagedAttachmentsDir, "upload-"));
16911
16999
  const alt = safeBaseName(name2);
16912
- const filePath = join37(dir, `${alt}.${ext}`);
17000
+ const filePath = join38(dir, `${alt}.${ext}`);
16913
17001
  await writeFile(filePath, body);
16914
17002
  return { dir, filePath, alt };
16915
17003
  }
@@ -16958,16 +17046,16 @@ import { readFile as readFile3, stat as stat3, writeFile as writeFile2 } from "f
16958
17046
 
16959
17047
  // src/commands/sessions/web/formatWithOxfmt.ts
16960
17048
  import { execFile as execFile12 } from "child_process";
16961
- import { existsSync as existsSync31 } from "fs";
16962
- import { dirname as dirname18, join as join38 } from "path";
17049
+ import { existsSync as existsSync32 } from "fs";
17050
+ import { dirname as dirname18, join as join39 } from "path";
16963
17051
  import { promisify as promisify13 } from "util";
16964
17052
  var execFileAsync11 = promisify13(execFile12);
16965
17053
  var TIMEOUT_MS = 15e3;
16966
17054
  function findOxfmtScript(root2) {
16967
17055
  let dir = root2;
16968
17056
  for (; ; ) {
16969
- const candidate = join38(dir, "node_modules", "oxfmt", "bin", "oxfmt");
16970
- if (existsSync31(candidate)) return candidate;
17057
+ const candidate = join39(dir, "node_modules", "oxfmt", "bin", "oxfmt");
17058
+ if (existsSync32(candidate)) return candidate;
16971
17059
  const parent = dirname18(dir);
16972
17060
  if (parent === dir) return void 0;
16973
17061
  dir = parent;
@@ -17039,10 +17127,10 @@ async function writeFileContent(req, res) {
17039
17127
  // src/shared/createBundleHandler.ts
17040
17128
  import { createHash as createHash2 } from "crypto";
17041
17129
  import { readFileSync as readFileSync14, statSync as statSync8 } from "fs";
17042
- import { dirname as dirname19, join as join39 } from "path";
17130
+ import { dirname as dirname19, join as join40 } from "path";
17043
17131
  import { fileURLToPath as fileURLToPath4 } from "url";
17044
17132
  function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
17045
- const file = join39(dirname19(fileURLToPath4(importMetaUrl)), bundlePath);
17133
+ const file = join40(dirname19(fileURLToPath4(importMetaUrl)), bundlePath);
17046
17134
  let cache7;
17047
17135
  return (req, res) => {
17048
17136
  const mtimeMs = statSync8(file).mtimeMs;
@@ -17478,9 +17566,9 @@ function scheduleReconnect() {
17478
17566
  }
17479
17567
 
17480
17568
  // src/commands/sessions/web/updates/autoRestart/autoRestartAttempts.ts
17481
- import { mkdirSync as mkdirSync8, readFileSync as readFileSync16, writeFileSync as writeFileSync9 } from "fs";
17482
- import { dirname as dirname20, join as join40 } from "path";
17483
- var defaultPath = join40(daemonPaths.dir, "auto-restart-attempts.json");
17569
+ import { mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync9 } from "fs";
17570
+ import { dirname as dirname20, join as join41 } from "path";
17571
+ var defaultPath = join41(daemonPaths.dir, "auto-restart-attempts.json");
17484
17572
  function read(path110) {
17485
17573
  try {
17486
17574
  return JSON.parse(readFileSync16(path110, "utf8"));
@@ -17493,7 +17581,7 @@ function autoRestartAttempts(port, path110 = defaultPath) {
17493
17581
  return {
17494
17582
  get: () => read(path110)[key],
17495
17583
  set: (built) => {
17496
- mkdirSync8(dirname20(path110), { recursive: true });
17584
+ mkdirSync9(dirname20(path110), { recursive: true });
17497
17585
  writeFileSync9(
17498
17586
  path110,
17499
17587
  `${JSON.stringify({ ...read(path110), [key]: built }, null, 2)}
@@ -17703,9 +17791,9 @@ function originForCwd(cwd) {
17703
17791
  }
17704
17792
 
17705
17793
  // src/commands/sessions/daemon/repoDirExists.ts
17706
- import { existsSync as existsSync32 } from "fs";
17794
+ import { existsSync as existsSync33 } from "fs";
17707
17795
  function repoDirExists(cwd) {
17708
- return existsSync32(cwd);
17796
+ return existsSync33(cwd);
17709
17797
  }
17710
17798
 
17711
17799
  // src/commands/sessions/daemon/worktree/git.ts
@@ -17806,7 +17894,7 @@ function gitCommonDir(cwd) {
17806
17894
  var REGISTRY_FILE = "worktrees.json";
17807
17895
  function readWorktreeRegistry() {
17808
17896
  const data = loadJson(REGISTRY_FILE);
17809
- return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path110, record3]) => ({ path: path110, ...record3 }));
17897
+ return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path110, { reaped: _reaped, ...record3 }]) => ({ path: path110, ...record3 }));
17810
17898
  }
17811
17899
  function worktreeAttributionIncludingReaped(path110) {
17812
17900
  const record3 = loadJson(REGISTRY_FILE)[path110];
@@ -17817,6 +17905,13 @@ function recordWorktree(path110, clone, origin) {
17817
17905
  data[path110] = { clone, origin };
17818
17906
  saveJson(REGISTRY_FILE, data);
17819
17907
  }
17908
+ function recordWorktreeHarness(path110, harness) {
17909
+ const data = loadJson(REGISTRY_FILE);
17910
+ const record3 = data[path110];
17911
+ if (!record3 || record3.reaped || record3.harness === harness) return;
17912
+ data[path110] = { ...record3, harness };
17913
+ saveJson(REGISTRY_FILE, data);
17914
+ }
17820
17915
  function forgetWorktree(path110) {
17821
17916
  const data = loadJson(REGISTRY_FILE);
17822
17917
  const record3 = data[path110];
@@ -18197,17 +18292,17 @@ import * as path21 from "path";
18197
18292
  import chalk21 from "chalk";
18198
18293
 
18199
18294
  // src/commands/verify/addToKnipIgnoreBinaries.ts
18200
- import { existsSync as existsSync33, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
18201
- import { join as join41 } from "path";
18295
+ import { existsSync as existsSync34, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
18296
+ import { join as join42 } from "path";
18202
18297
  import chalk20 from "chalk";
18203
18298
  function loadKnipConfig(knipJsonPath) {
18204
- if (existsSync33(knipJsonPath)) {
18299
+ if (existsSync34(knipJsonPath)) {
18205
18300
  return JSON.parse(readFileSync17(knipJsonPath, "utf8"));
18206
18301
  }
18207
18302
  return { $schema: "https://unpkg.com/knip@5/schema.json" };
18208
18303
  }
18209
18304
  function addToKnipIgnoreBinaries(cwd, binary) {
18210
- const knipJsonPath = join41(cwd, "knip.json");
18305
+ const knipJsonPath = join42(cwd, "knip.json");
18211
18306
  try {
18212
18307
  const knipConfig = loadKnipConfig(knipJsonPath);
18213
18308
  const ignoreBinaries = knipConfig.ignoreBinaries ?? [];
@@ -18254,7 +18349,7 @@ import * as path23 from "path";
18254
18349
  import chalk26 from "chalk";
18255
18350
 
18256
18351
  // src/commands/format/init.ts
18257
- import { existsSync as existsSync34, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
18352
+ import { existsSync as existsSync35, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
18258
18353
  import chalk24 from "chalk";
18259
18354
 
18260
18355
  // src/utils/printDiff.ts
@@ -18297,7 +18392,7 @@ async function init() {
18297
18392
  const newContent = `${JSON.stringify(oxfmtrc_template_default, null, " ")}
18298
18393
  `;
18299
18394
  const configPath = ".oxfmtrc.json";
18300
- const oldContent = existsSync34(configPath) ? readFileSync18(configPath, "utf8") : "";
18395
+ const oldContent = existsSync35(configPath) ? readFileSync18(configPath, "utf8") : "";
18301
18396
  if (oldContent === newContent) {
18302
18397
  console.log(".oxfmtrc.json already has the baseline formatter config");
18303
18398
  return;
@@ -18320,15 +18415,15 @@ async function init() {
18320
18415
  }
18321
18416
 
18322
18417
  // src/commands/lint/init.ts
18323
- import { existsSync as existsSync37, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "fs";
18418
+ import { existsSync as existsSync38, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "fs";
18324
18419
  import chalk25 from "chalk";
18325
18420
 
18326
18421
  // src/shared/removeEslint.ts
18327
18422
  import { execSync as execSync7 } from "child_process";
18328
- import { existsSync as existsSync36, readFileSync as readFileSync19, writeFileSync as writeFileSync13 } from "fs";
18423
+ import { existsSync as existsSync37, readFileSync as readFileSync19, writeFileSync as writeFileSync13 } from "fs";
18329
18424
 
18330
18425
  // src/shared/removeEslint/removeEslintConfigFiles.ts
18331
- import { existsSync as existsSync35, unlinkSync as unlinkSync3 } from "fs";
18426
+ import { existsSync as existsSync36, unlinkSync as unlinkSync3 } from "fs";
18332
18427
  var ESLINT_CONFIG_FILES = [
18333
18428
  "eslint.config.js",
18334
18429
  "eslint.config.mjs",
@@ -18344,7 +18439,7 @@ var ESLINT_CONFIG_FILES = [
18344
18439
  function removeEslintConfigFiles() {
18345
18440
  let removed = false;
18346
18441
  for (const configFile of ESLINT_CONFIG_FILES) {
18347
- if (existsSync35(configFile)) {
18442
+ if (existsSync36(configFile)) {
18348
18443
  unlinkSync3(configFile);
18349
18444
  console.log(`Removed ${configFile}`);
18350
18445
  removed = true;
@@ -18366,7 +18461,7 @@ function removeEslint(options2 = {}) {
18366
18461
  }
18367
18462
  function removeEslintFromPackageJson(options2) {
18368
18463
  const packageJsonPath = "package.json";
18369
- if (!existsSync36(packageJsonPath)) {
18464
+ if (!existsSync37(packageJsonPath)) {
18370
18465
  return false;
18371
18466
  }
18372
18467
  const packageJson = JSON.parse(readFileSync19(packageJsonPath, "utf8"));
@@ -18433,7 +18528,7 @@ async function writeOxlintConfig() {
18433
18528
  const newContent = `${JSON.stringify(oxlintrc_template_default, null, " ")}
18434
18529
  `;
18435
18530
  const configPath = ".oxlintrc.json";
18436
- const oldContent = existsSync37(configPath) ? readFileSync20(configPath, "utf8") : "";
18531
+ const oldContent = existsSync38(configPath) ? readFileSync20(configPath, "utf8") : "";
18437
18532
  if (oldContent === newContent) {
18438
18533
  console.log(".oxlintrc.json already has the baseline linter config");
18439
18534
  return;
@@ -19161,7 +19256,7 @@ function initPackageJson(name2) {
19161
19256
  }
19162
19257
 
19163
19258
  // src/commands/new/registerNew/newCli/writeCliTemplate.ts
19164
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync19 } from "fs";
19259
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync19 } from "fs";
19165
19260
  function writeCliTemplate(name2) {
19166
19261
  console.log("Writing tsconfig.json...");
19167
19262
  writeFileSync19(
@@ -19202,7 +19297,7 @@ export default defineConfig({
19202
19297
  `
19203
19298
  );
19204
19299
  console.log("Writing src/index.ts...");
19205
- mkdirSync10("src", { recursive: true });
19300
+ mkdirSync11("src", { recursive: true });
19206
19301
  writeFileSync19(
19207
19302
  "src/index.ts",
19208
19303
  `#!/usr/bin/env node
@@ -19231,7 +19326,7 @@ async function newCli() {
19231
19326
 
19232
19327
  // src/commands/new/registerNew/newProject.ts
19233
19328
  import { execSync as execSync14 } from "child_process";
19234
- import { existsSync as existsSync42, readFileSync as readFileSync24, writeFileSync as writeFileSync21 } from "fs";
19329
+ import { existsSync as existsSync43, readFileSync as readFileSync24, writeFileSync as writeFileSync21 } from "fs";
19235
19330
 
19236
19331
  // src/commands/deploy/init.ts
19237
19332
  import { execSync as execSync13 } from "child_process";
@@ -19239,14 +19334,14 @@ import chalk36 from "chalk";
19239
19334
  import enquirer3 from "enquirer";
19240
19335
 
19241
19336
  // src/commands/deploy/init/updateWorkflow.ts
19242
- import { existsSync as existsSync41, mkdirSync as mkdirSync11, readFileSync as readFileSync23, writeFileSync as writeFileSync20 } from "fs";
19243
- import { dirname as dirname28, join as join48 } from "path";
19337
+ import { existsSync as existsSync42, mkdirSync as mkdirSync12, readFileSync as readFileSync23, writeFileSync as writeFileSync20 } from "fs";
19338
+ import { dirname as dirname28, join as join49 } from "path";
19244
19339
  import { fileURLToPath as fileURLToPath5 } from "url";
19245
19340
  import chalk35 from "chalk";
19246
19341
  var WORKFLOW_PATH = ".github/workflows/build.yml";
19247
19342
  var __dirname4 = dirname28(fileURLToPath5(import.meta.url));
19248
19343
  function getExistingSiteId() {
19249
- if (!existsSync41(WORKFLOW_PATH)) {
19344
+ if (!existsSync42(WORKFLOW_PATH)) {
19250
19345
  return null;
19251
19346
  }
19252
19347
  const content = readFileSync23(WORKFLOW_PATH, "utf8");
@@ -19254,17 +19349,17 @@ function getExistingSiteId() {
19254
19349
  return match ? match[1] : null;
19255
19350
  }
19256
19351
  function getTemplateContent(siteId) {
19257
- const templatePath = join48(__dirname4, "commands/deploy/build.yml");
19352
+ const templatePath = join49(__dirname4, "commands/deploy/build.yml");
19258
19353
  const template = readFileSync23(templatePath, "utf8");
19259
19354
  return template.replace("{{NETLIFY_SITE_ID}}", siteId);
19260
19355
  }
19261
19356
  async function updateWorkflow(siteId) {
19262
19357
  const newContent = getTemplateContent(siteId);
19263
19358
  const workflowDir = ".github/workflows";
19264
- if (!existsSync41(workflowDir)) {
19265
- mkdirSync11(workflowDir, { recursive: true });
19359
+ if (!existsSync42(workflowDir)) {
19360
+ mkdirSync12(workflowDir, { recursive: true });
19266
19361
  }
19267
- if (existsSync41(WORKFLOW_PATH)) {
19362
+ if (existsSync42(WORKFLOW_PATH)) {
19268
19363
  const oldContent = readFileSync23(WORKFLOW_PATH, "utf8");
19269
19364
  if (oldContent === newContent) {
19270
19365
  console.log(chalk35.green("build.yml is already up to date"));
@@ -19359,7 +19454,7 @@ async function newProject() {
19359
19454
  }
19360
19455
  function addViteBaseConfig() {
19361
19456
  const viteConfigPath = "vite.config.ts";
19362
- if (!existsSync42(viteConfigPath)) {
19457
+ if (!existsSync43(viteConfigPath)) {
19363
19458
  console.log("No vite.config.ts found, skipping base config");
19364
19459
  return;
19365
19460
  }
@@ -19562,17 +19657,17 @@ function adviceContextFor(cwd, env = process.env) {
19562
19657
 
19563
19658
  // src/commands/advise/loadAdviceFragments.ts
19564
19659
  import { readdirSync as readdirSync9, readFileSync as readFileSync25 } from "fs";
19565
- import { basename as basename15, join as join50 } from "path";
19660
+ import { basename as basename15, join as join51 } from "path";
19566
19661
 
19567
19662
  // src/commands/advise/adviceDir.ts
19568
- import { existsSync as existsSync43 } from "fs";
19569
- import { dirname as dirname29, join as join49 } from "path";
19663
+ import { existsSync as existsSync44 } from "fs";
19664
+ import { dirname as dirname29, join as join50 } from "path";
19570
19665
  import { fileURLToPath as fileURLToPath6 } from "url";
19571
19666
  function adviceDir() {
19572
19667
  let current2 = dirname29(fileURLToPath6(import.meta.url));
19573
19668
  while (current2 !== dirname29(current2)) {
19574
- const candidate = join49(current2, "claude", "advice");
19575
- if (existsSync43(candidate)) return candidate;
19669
+ const candidate = join50(current2, "claude", "advice");
19670
+ if (existsSync44(candidate)) return candidate;
19576
19671
  current2 = dirname29(current2);
19577
19672
  }
19578
19673
  throw new Error("Could not locate the shipped claude/advice directory");
@@ -19604,7 +19699,7 @@ function loadAdviceFragments(dir = adviceDir()) {
19604
19699
  return readdirSync9(dir).filter((file) => file.endsWith(".md")).sort().map(
19605
19700
  (file) => parseAdviceFragment(
19606
19701
  basename15(file, ".md"),
19607
- readFileSync25(join50(dir, file), "utf8")
19702
+ readFileSync25(join51(dir, file), "utf8")
19608
19703
  )
19609
19704
  );
19610
19705
  }
@@ -19638,13 +19733,13 @@ function renderAdviceBody(fragment, context) {
19638
19733
  }
19639
19734
 
19640
19735
  // src/commands/advise/adviceConditions.ts
19641
- import { existsSync as existsSync44 } from "fs";
19642
- import { join as join51 } from "path";
19736
+ import { existsSync as existsSync45 } from "fs";
19737
+ import { join as join52 } from "path";
19643
19738
  function repoFile(file, label) {
19644
19739
  return {
19645
19740
  whenMet: `the repo has ${label}`,
19646
19741
  whenUnmet: `the repo has no ${label}`,
19647
- matches: ({ rootDir }) => existsSync44(join51(rootDir, file))
19742
+ matches: ({ rootDir }) => existsSync45(join52(rootDir, file))
19648
19743
  };
19649
19744
  }
19650
19745
  var adviceConditions = {
@@ -19670,11 +19765,11 @@ var adviceConditions = {
19670
19765
  },
19671
19766
  typescript: repoFile("tsconfig.json", "a tsconfig.json"),
19672
19767
  filenameConvention: repoFile(
19673
- join51("oxlint-rules", "filenameConvention.ts"),
19768
+ join52("oxlint-rules", "filenameConvention.ts"),
19674
19769
  "oxlint-rules/filenameConvention.ts"
19675
19770
  ),
19676
19771
  claudeSettings: repoFile(
19677
- join51("claude", "settings.json"),
19772
+ join52("claude", "settings.json"),
19678
19773
  "claude/settings.json"
19679
19774
  ),
19680
19775
  verify: {
@@ -20590,7 +20685,7 @@ function registerAskQuestion(program) {
20590
20685
 
20591
20686
  // src/commands/registerBackup.ts
20592
20687
  import { mkdir as mkdir3, stat as stat4 } from "fs/promises";
20593
- import { join as join53, resolve as resolve16 } from "path";
20688
+ import { join as join54, resolve as resolve16 } from "path";
20594
20689
  import chalk41 from "chalk";
20595
20690
 
20596
20691
  // src/shared/db/recordBackup.ts
@@ -20604,7 +20699,7 @@ async function recordBackup(db, {
20604
20699
 
20605
20700
  // src/commands/backup/scheduleBackup.ts
20606
20701
  import { mkdir as mkdir2 } from "fs/promises";
20607
- import { join as join52 } from "path";
20702
+ import { join as join53 } from "path";
20608
20703
  import chalk39 from "chalk";
20609
20704
 
20610
20705
  // src/commands/backup/readCrontab.ts
@@ -20746,7 +20841,7 @@ async function scheduleBackup({
20746
20841
  const cronExpr = durationToCron(every);
20747
20842
  const dir = expandTilde(loadConfig().backup.dir);
20748
20843
  await mkdir2(dir, { recursive: true });
20749
- const logPath2 = join52(dir, "cron.log");
20844
+ const logPath2 = join53(dir, "cron.log");
20750
20845
  const cronLine = `${cronExpr} ${resolveAssistCommand()} backup >> ${logPath2} 2>&1`;
20751
20846
  writeCrontab(upsertScheduleBlock(readCrontab(), every, cronLine));
20752
20847
  console.error(
@@ -20925,7 +21020,7 @@ async function backup({ out }) {
20925
21020
  await mkdir3(dir, { recursive: true });
20926
21021
  const start2 = Date.now();
20927
21022
  const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
20928
- const filePath = resolve16(join53(dir, `backup-${timestamp9}.dump`));
21023
+ const filePath = resolve16(join54(dir, `backup-${timestamp9}.dump`));
20929
21024
  await exportBacklog(filePath);
20930
21025
  const { size } = await stat4(filePath);
20931
21026
  const durationMs = Date.now() - start2;
@@ -21436,7 +21531,7 @@ function registerAssociateJiraCommand(cmd) {
21436
21531
 
21437
21532
  // src/commands/backlog/cloneRepo.ts
21438
21533
  import { spawnSync as spawnSync5 } from "child_process";
21439
- import { existsSync as existsSync46 } from "fs";
21534
+ import { existsSync as existsSync47 } from "fs";
21440
21535
  import { mkdir as mkdir4 } from "fs/promises";
21441
21536
  import chalk48 from "chalk";
21442
21537
 
@@ -21472,7 +21567,7 @@ async function cloneRepo(originRaw) {
21472
21567
  if (!target) {
21473
21568
  return fail3(`Could not derive a repository name from "${origin}".`);
21474
21569
  }
21475
- if (existsSync46(target)) {
21570
+ if (existsSync47(target)) {
21476
21571
  return fail3(`Clone target already exists: ${target}`);
21477
21572
  }
21478
21573
  await mkdir4(baseDir, { recursive: true });
@@ -21818,7 +21913,7 @@ function ensureRemoteOrigin() {
21818
21913
  import { spawnSync as spawnSync6 } from "child_process";
21819
21914
  import { mkdtempSync, readFileSync as readFileSync27, unlinkSync as unlinkSync4, writeFileSync as writeFileSync22 } from "fs";
21820
21915
  import { tmpdir as tmpdir2 } from "os";
21821
- import { join as join55 } from "path";
21916
+ import { join as join56 } from "path";
21822
21917
  import enquirer4 from "enquirer";
21823
21918
  async function promptType() {
21824
21919
  const { type } = await enquirer4.prompt({
@@ -21858,8 +21953,8 @@ async function promptDescription() {
21858
21953
  }
21859
21954
  function openEditor() {
21860
21955
  const editor = process.env.EDITOR || process.env.VISUAL || "vi";
21861
- const dir = mkdtempSync(join55(tmpdir2(), "assist-"));
21862
- const filePath = join55(dir, "description.md");
21956
+ const dir = mkdtempSync(join56(tmpdir2(), "assist-"));
21957
+ const filePath = join56(dir, "description.md");
21863
21958
  writeFileSync22(filePath, "");
21864
21959
  const result = spawnSync6(editor, [filePath], { stdio: "inherit" });
21865
21960
  if (result.status !== 0) {
@@ -22300,7 +22395,7 @@ function startProposedRun(id, startOn) {
22300
22395
  import { randomUUID as randomUUID10 } from "crypto";
22301
22396
 
22302
22397
  // src/commands/backlog/propose/mutateLedger.ts
22303
- import { mkdirSync as mkdirSync12, readFileSync as readFileSync28, renameSync as renameSync4, writeFileSync as writeFileSync23 } from "fs";
22398
+ import { mkdirSync as mkdirSync13, readFileSync as readFileSync28, renameSync as renameSync4, writeFileSync as writeFileSync23 } from "fs";
22304
22399
  import { dirname as dirname30 } from "path";
22305
22400
  function readLedger(path110) {
22306
22401
  try {
@@ -22313,7 +22408,7 @@ function readLedger(path110) {
22313
22408
  function mutateLedger(path110, mutate) {
22314
22409
  const ledger = readLedger(path110);
22315
22410
  mutate(ledger);
22316
- mkdirSync12(dirname30(path110), { recursive: true });
22411
+ mkdirSync13(dirname30(path110), { recursive: true });
22317
22412
  const tmp = `${path110}.${process.pid}.tmp`;
22318
22413
  writeFileSync23(tmp, JSON.stringify(ledger));
22319
22414
  renameSync4(tmp, path110);
@@ -22344,9 +22439,9 @@ async function findPredecessor(path110, token, startedAt) {
22344
22439
 
22345
22440
  // src/commands/backlog/propose/proposalLedgerPath.ts
22346
22441
  import { homedir as homedir15 } from "os";
22347
- import { join as join56 } from "path";
22442
+ import { join as join57 } from "path";
22348
22443
  function proposalLedgerPath(sessionId2) {
22349
- return join56(homedir15(), ".assist", "proposals", `session-${sessionId2}.json`);
22444
+ return join57(homedir15(), ".assist", "proposals", `session-${sessionId2}.json`);
22350
22445
  }
22351
22446
 
22352
22447
  // src/commands/backlog/propose/trackProposal.ts
@@ -22702,7 +22797,7 @@ import chalk69 from "chalk";
22702
22797
 
22703
22798
  // src/shared/waitForIndexUnlocked.ts
22704
22799
  import { execSync as execSync18 } from "child_process";
22705
- import { existsSync as existsSync47 } from "fs";
22800
+ import { existsSync as existsSync48 } from "fs";
22706
22801
  import { resolve as resolve17 } from "path";
22707
22802
  var POLL_MS2 = 200;
22708
22803
  function indexLockPath() {
@@ -22723,7 +22818,7 @@ function waitForIndexUnlocked(timeoutMs) {
22723
22818
  const lock2 = indexLockPath();
22724
22819
  if (!lock2) return true;
22725
22820
  const deadline = Date.now() + timeoutMs;
22726
- while (existsSync47(lock2)) {
22821
+ while (existsSync48(lock2)) {
22727
22822
  if (Date.now() >= deadline) return false;
22728
22823
  sleepSync(POLL_MS2);
22729
22824
  }
@@ -22839,14 +22934,14 @@ function hasLocalChanges() {
22839
22934
 
22840
22935
  // src/commands/backlog/acquireLock.ts
22841
22936
  import {
22842
- existsSync as existsSync48,
22843
- mkdirSync as mkdirSync13,
22937
+ existsSync as existsSync49,
22938
+ mkdirSync as mkdirSync14,
22844
22939
  readFileSync as readFileSync30,
22845
22940
  unlinkSync as unlinkSync5,
22846
22941
  writeFileSync as writeFileSync24
22847
22942
  } from "fs";
22848
22943
  import { homedir as homedir16 } from "os";
22849
- import { join as join57 } from "path";
22944
+ import { join as join58 } from "path";
22850
22945
 
22851
22946
  // src/commands/backlog/bootedAt.ts
22852
22947
  import { uptime } from "os";
@@ -22882,10 +22977,10 @@ function isStaleLock(pid, timestamp9) {
22882
22977
 
22883
22978
  // src/commands/backlog/acquireLock.ts
22884
22979
  function getLocksDir() {
22885
- return join57(homedir16(), ".assist", "locks");
22980
+ return join58(homedir16(), ".assist", "locks");
22886
22981
  }
22887
22982
  function getLockPath(itemId2) {
22888
- return join57(getLocksDir(), `lock-${itemId2}.json`);
22983
+ return join58(getLocksDir(), `lock-${itemId2}.json`);
22889
22984
  }
22890
22985
  function isProcessAlive(pid) {
22891
22986
  try {
@@ -22897,7 +22992,7 @@ function isProcessAlive(pid) {
22897
22992
  }
22898
22993
  function foreignLockHolder(itemId2) {
22899
22994
  const lockPath = getLockPath(itemId2);
22900
- if (!existsSync48(lockPath)) return null;
22995
+ if (!existsSync49(lockPath)) return null;
22901
22996
  try {
22902
22997
  const lock2 = JSON.parse(readFileSync30(lockPath, "utf8"));
22903
22998
  if (typeof lock2.pid !== "number" || lock2.pid === process.pid) return null;
@@ -22912,7 +23007,7 @@ function isLockedByOther(itemId2) {
22912
23007
  return foreignLockHolder(itemId2) !== null;
22913
23008
  }
22914
23009
  function acquireLock(itemId2) {
22915
- mkdirSync13(getLocksDir(), { recursive: true });
23010
+ mkdirSync14(getLocksDir(), { recursive: true });
22916
23011
  writeFileSync24(
22917
23012
  getLockPath(itemId2),
22918
23013
  JSON.stringify({ pid: process.pid, timestamp: (/* @__PURE__ */ new Date()).toISOString() })
@@ -23343,24 +23438,24 @@ async function resumeDoneConversation({ item, resumeSessionId }, spawnOptions) {
23343
23438
  }
23344
23439
 
23345
23440
  // src/commands/backlog/consumePause.ts
23346
- import { existsSync as existsSync49, mkdirSync as mkdirSync14, unlinkSync as unlinkSync6, writeFileSync as writeFileSync25 } from "fs";
23441
+ import { existsSync as existsSync50, mkdirSync as mkdirSync15, unlinkSync as unlinkSync6, writeFileSync as writeFileSync25 } from "fs";
23347
23442
  import { homedir as homedir17 } from "os";
23348
- import { join as join58 } from "path";
23443
+ import { join as join59 } from "path";
23349
23444
  function getControlsDir() {
23350
- return join58(homedir17(), ".assist", "controls");
23445
+ return join59(homedir17(), ".assist", "controls");
23351
23446
  }
23352
23447
  function getPausePath(itemId2) {
23353
- return join58(getControlsDir(), `pause-${itemId2}.json`);
23448
+ return join59(getControlsDir(), `pause-${itemId2}.json`);
23354
23449
  }
23355
23450
  function requestPause(itemId2) {
23356
- mkdirSync14(getControlsDir(), { recursive: true });
23451
+ mkdirSync15(getControlsDir(), { recursive: true });
23357
23452
  writeFileSync25(
23358
23453
  getPausePath(itemId2),
23359
23454
  JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString() })
23360
23455
  );
23361
23456
  }
23362
23457
  function isPausePending(itemId2) {
23363
- return existsSync49(getPausePath(itemId2));
23458
+ return existsSync50(getPausePath(itemId2));
23364
23459
  }
23365
23460
  function clearPause(itemId2) {
23366
23461
  try {
@@ -23370,7 +23465,7 @@ function clearPause(itemId2) {
23370
23465
  }
23371
23466
  function consumePause(itemId2) {
23372
23467
  const pausePath = getPausePath(itemId2);
23373
- if (!existsSync49(pausePath)) return false;
23468
+ if (!existsSync50(pausePath)) return false;
23374
23469
  try {
23375
23470
  unlinkSync6(pausePath);
23376
23471
  } catch {
@@ -23530,13 +23625,13 @@ function logHookFired(status2, sessionId2, source) {
23530
23625
  }
23531
23626
 
23532
23627
  // src/commands/backlog/watchForMarker.ts
23533
- import { existsSync as existsSync51, unwatchFile, watchFile } from "fs";
23628
+ import { existsSync as existsSync52, unwatchFile, watchFile } from "fs";
23534
23629
 
23535
23630
  // src/commands/backlog/readSignal.ts
23536
- import { existsSync as existsSync50, readFileSync as readFileSync31 } from "fs";
23631
+ import { existsSync as existsSync51, readFileSync as readFileSync31 } from "fs";
23537
23632
  function readSignal() {
23538
23633
  const path110 = getSignalPath();
23539
- if (!path110 || !existsSync50(path110)) return void 0;
23634
+ if (!path110 || !existsSync51(path110)) return void 0;
23540
23635
  try {
23541
23636
  return JSON.parse(readFileSync31(path110, "utf8"));
23542
23637
  } catch {
@@ -23550,7 +23645,7 @@ function watchForMarker(child, options2) {
23550
23645
  const statusPath = getSignalPath();
23551
23646
  if (!statusPath) return { killedOnMarker: () => killed };
23552
23647
  watchFile(statusPath, { interval: 1e3 }, () => {
23553
- if (!existsSync51(statusPath)) return;
23648
+ if (!existsSync52(statusPath)) return;
23554
23649
  const signal = readSignal();
23555
23650
  if (!signal) return;
23556
23651
  if (signal.event === "done" && !options2?.actOnDone) return;
@@ -23606,7 +23701,7 @@ function launchPhaseSession(item, phaseNumber, phase, phaseLabel2, claudeSession
23606
23701
  }
23607
23702
 
23608
23703
  // src/commands/backlog/resolvePhaseResult.ts
23609
- import { existsSync as existsSync52, unlinkSync as unlinkSync7 } from "fs";
23704
+ import { existsSync as existsSync53, unlinkSync as unlinkSync7 } from "fs";
23610
23705
  import chalk78 from "chalk";
23611
23706
 
23612
23707
  // src/commands/backlog/handleIncompletePhase.ts
@@ -23628,7 +23723,7 @@ async function handleIncompletePhase() {
23628
23723
  // src/commands/backlog/resolvePhaseResult.ts
23629
23724
  function cleanupSignal() {
23630
23725
  const statusPath = getSignalPath();
23631
- if (statusPath && existsSync52(statusPath)) {
23726
+ if (statusPath && existsSync53(statusPath)) {
23632
23727
  unlinkSync7(statusPath);
23633
23728
  }
23634
23729
  }
@@ -23639,7 +23734,7 @@ async function isTerminalStatus(itemId2) {
23639
23734
  }
23640
23735
  async function resolvePhaseResult(phaseIndex, itemId2) {
23641
23736
  const signalPath = getSignalPath();
23642
- if (!signalPath || !existsSync52(signalPath)) {
23737
+ if (!signalPath || !existsSync53(signalPath)) {
23643
23738
  if (await isTerminalStatus(itemId2)) return { kind: "abort" };
23644
23739
  const action = await handleIncompletePhase();
23645
23740
  if (action === "abort") return { kind: "abort" };
@@ -23724,9 +23819,9 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
23724
23819
  }
23725
23820
 
23726
23821
  // src/shared/emitActivity.ts
23727
- import { mkdirSync as mkdirSync15, readFileSync as readFileSync32, rmSync as rmSync4, writeFileSync as writeFileSync26 } from "fs";
23822
+ import { mkdirSync as mkdirSync16, readFileSync as readFileSync32, rmSync as rmSync4, writeFileSync as writeFileSync26 } from "fs";
23728
23823
  import { homedir as homedir18 } from "os";
23729
- import { dirname as dirname31, join as join59 } from "path";
23824
+ import { dirname as dirname31, join as join60 } from "path";
23730
23825
  import { z as z17 } from "zod";
23731
23826
  var activitySchema = z17.object({
23732
23827
  kind: z17.enum(["command", "backlog"]),
@@ -23744,13 +23839,13 @@ var activitySchema = z17.object({
23744
23839
  startedAt: z17.number()
23745
23840
  });
23746
23841
  function activityPath(sessionId2) {
23747
- return join59(homedir18(), ".assist", "activity", `activity-${sessionId2}.json`);
23842
+ return join60(homedir18(), ".assist", "activity", `activity-${sessionId2}.json`);
23748
23843
  }
23749
23844
  function emitActivity(activity2) {
23750
23845
  const sessionId2 = process.env.ASSIST_ACTIVITY_ID;
23751
23846
  if (!sessionId2) return;
23752
23847
  const path110 = activityPath(sessionId2);
23753
- mkdirSync15(dirname31(path110), { recursive: true });
23848
+ mkdirSync16(dirname31(path110), { recursive: true });
23754
23849
  writeFileSync26(path110, JSON.stringify({ ...activity2, startedAt: Date.now() }));
23755
23850
  }
23756
23851
  function readActivity(path110) {
@@ -23766,12 +23861,12 @@ function reconcileActivity(sessionId2, activity2) {
23766
23861
  return;
23767
23862
  }
23768
23863
  const path110 = activityPath(sessionId2);
23769
- mkdirSync15(dirname31(path110), { recursive: true });
23864
+ mkdirSync16(dirname31(path110), { recursive: true });
23770
23865
  writeFileSync26(path110, JSON.stringify(activity2));
23771
23866
  }
23772
23867
  function writeActivityIfAbsent(sessionId2, activity2) {
23773
23868
  const path110 = activityPath(sessionId2);
23774
- mkdirSync15(dirname31(path110), { recursive: true });
23869
+ mkdirSync16(dirname31(path110), { recursive: true });
23775
23870
  try {
23776
23871
  writeFileSync26(path110, JSON.stringify(activity2), { flag: "wx" });
23777
23872
  return true;
@@ -26459,7 +26554,7 @@ function extractGraphqlQuery(args) {
26459
26554
  }
26460
26555
 
26461
26556
  // src/shared/loadCliReads.ts
26462
- import { existsSync as existsSync53, readFileSync as readFileSync34, writeFileSync as writeFileSync27 } from "fs";
26557
+ import { existsSync as existsSync54, readFileSync as readFileSync34, writeFileSync as writeFileSync27 } from "fs";
26463
26558
  import { dirname as dirname32, resolve as resolve18 } from "path";
26464
26559
  import { fileURLToPath as fileURLToPath7 } from "url";
26465
26560
  var __filename4 = fileURLToPath7(import.meta.url);
@@ -26468,7 +26563,7 @@ function packageRoot() {
26468
26563
  return __dirname5;
26469
26564
  }
26470
26565
  function readLines(path110) {
26471
- if (!existsSync53(path110)) return [];
26566
+ if (!existsSync54(path110)) return [];
26472
26567
  return readFileSync34(path110, "utf8").split("\n").filter((line) => line.trim() !== "");
26473
26568
  }
26474
26569
  var cachedReads;
@@ -26515,14 +26610,14 @@ function findCliWrite(command) {
26515
26610
  }
26516
26611
 
26517
26612
  // src/shared/readSettingsPerms.ts
26518
- import { existsSync as existsSync54, readFileSync as readFileSync35 } from "fs";
26613
+ import { existsSync as existsSync55, readFileSync as readFileSync35 } from "fs";
26519
26614
  import { homedir as homedir19 } from "os";
26520
- import { join as join60 } from "path";
26615
+ import { join as join61 } from "path";
26521
26616
  function readSettingsPerms(key) {
26522
26617
  const paths = [
26523
- join60(homedir19(), ".claude", "settings.json"),
26524
- join60(process.cwd(), ".claude", "settings.json"),
26525
- join60(process.cwd(), ".claude", "settings.local.json")
26618
+ join61(homedir19(), ".claude", "settings.json"),
26619
+ join61(process.cwd(), ".claude", "settings.json"),
26620
+ join61(process.cwd(), ".claude", "settings.local.json")
26526
26621
  ];
26527
26622
  const entries = [];
26528
26623
  for (const p of paths) {
@@ -26534,7 +26629,7 @@ function readSettingsPerms(key) {
26534
26629
  return entries;
26535
26630
  }
26536
26631
  function readPermissionArray(filePath, key) {
26537
- if (!existsSync54(filePath)) return [];
26632
+ if (!existsSync55(filePath)) return [];
26538
26633
  try {
26539
26634
  const data = JSON.parse(readFileSync35(filePath, "utf8"));
26540
26635
  const arr = data?.permissions?.[key];
@@ -26888,32 +26983,32 @@ async function decideDocsGuard({
26888
26983
  }
26889
26984
 
26890
26985
  // src/commands/schema/isSchemaLocked.ts
26891
- import { existsSync as existsSync55, readFileSync as readFileSync37 } from "fs";
26986
+ import { existsSync as existsSync56, readFileSync as readFileSync37 } from "fs";
26892
26987
 
26893
26988
  // src/commands/schema/getSchemaSessionApprovalPath.ts
26894
- import { join as join62 } from "path";
26989
+ import { join as join63 } from "path";
26895
26990
 
26896
26991
  // src/commands/codeComment/getRestrictedDir.ts
26897
26992
  import { homedir as homedir20 } from "os";
26898
- import { join as join61 } from "path";
26993
+ import { join as join62 } from "path";
26899
26994
  function getRestrictedDir() {
26900
- return join61(homedir20(), ".assist", "restricted");
26995
+ return join62(homedir20(), ".assist", "restricted");
26901
26996
  }
26902
26997
  function getPinStatePath(pin2) {
26903
- return join61(getRestrictedDir(), `code-comment-${pin2}.json`);
26998
+ return join62(getRestrictedDir(), `code-comment-${pin2}.json`);
26904
26999
  }
26905
27000
 
26906
27001
  // src/commands/schema/getSchemaSessionApprovalPath.ts
26907
27002
  var SESSION_ID = /^[\w-]+$/;
26908
27003
  function getSchemaSessionApprovalDir() {
26909
- return join62(getRestrictedDir(), "schema-sessions");
27004
+ return join63(getRestrictedDir(), "schema-sessions");
26910
27005
  }
26911
27006
  function getSchemaSessionApprovalPath(scope) {
26912
27007
  const { harness, conversationId } = scope;
26913
27008
  if (!SESSION_ID.test(conversationId) || !SESSION_ID.test(harness))
26914
27009
  return void 0;
26915
27010
  const name2 = harness === legacyDefaultHarness ? conversationId : `${harness}-${conversationId}`;
26916
- return join62(getSchemaSessionApprovalDir(), `${name2}.json`);
27011
+ return join63(getSchemaSessionApprovalDir(), `${name2}.json`);
26917
27012
  }
26918
27013
 
26919
27014
  // src/commands/schema/isSchemaLocked.ts
@@ -26934,7 +27029,7 @@ function hasSessionApproval(identity) {
26934
27029
  const { harness, conversationId } = identity;
26935
27030
  if (!conversationId) return false;
26936
27031
  const path110 = getSchemaSessionApprovalPath({ harness, conversationId });
26937
- return path110 !== void 0 && existsSync55(path110) && approvalMatches(path110, identity);
27032
+ return path110 !== void 0 && existsSync56(path110) && approvalMatches(path110, identity);
26938
27033
  }
26939
27034
  async function isSchemaLocked(identity = currentExecutionIdentity()) {
26940
27035
  if (!identity) return false;
@@ -27006,13 +27101,13 @@ async function decideToolOperations(operations2, identity) {
27006
27101
  import { basename as basename17 } from "path";
27007
27102
 
27008
27103
  // src/commands/cliHook/logDeniedToolCall.ts
27009
- import { mkdirSync as mkdirSync16 } from "fs";
27104
+ import { mkdirSync as mkdirSync17 } from "fs";
27010
27105
  import { homedir as homedir21 } from "os";
27011
- import { join as join63 } from "path";
27106
+ import { join as join64 } from "path";
27012
27107
  import Database from "better-sqlite3";
27013
27108
  var _db;
27014
27109
  function getDbDir() {
27015
- return join63(homedir21(), ".assist");
27110
+ return join64(homedir21(), ".assist");
27016
27111
  }
27017
27112
  function initSchema(db) {
27018
27113
  db.exec(`
@@ -27030,8 +27125,8 @@ function initSchema(db) {
27030
27125
  function openPromptsDb(dir) {
27031
27126
  if (_db) return _db;
27032
27127
  const dbDir = dir ?? getDbDir();
27033
- mkdirSync16(dbDir, { recursive: true });
27034
- const db = new Database(join63(dbDir, "assist.db"));
27128
+ mkdirSync17(dbDir, { recursive: true });
27129
+ const db = new Database(join64(dbDir, "assist.db"));
27035
27130
  db.pragma("journal_mode = WAL");
27036
27131
  initSchema(db);
27037
27132
  _db = db;
@@ -27135,9 +27230,9 @@ ${reasons.join("\n")}`);
27135
27230
  }
27136
27231
 
27137
27232
  // src/commands/permitCliReads.ts
27138
- import { existsSync as existsSync56, mkdirSync as mkdirSync17, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
27233
+ import { existsSync as existsSync57, mkdirSync as mkdirSync18, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
27139
27234
  import { homedir as homedir22 } from "os";
27140
- import { join as join64 } from "path";
27235
+ import { join as join65 } from "path";
27141
27236
 
27142
27237
  // src/commands/permitCliReads/assertCliExists.ts
27143
27238
  function assertCliExists(cli) {
@@ -27400,16 +27495,16 @@ function updateSettings(cli, commands) {
27400
27495
  // src/commands/permitCliReads.ts
27401
27496
  function logPath(cli) {
27402
27497
  const safeName = cli.replace(/\s+/g, "-");
27403
- return join64(homedir22(), ".assist", `cli-discover-${safeName}.log`);
27498
+ return join65(homedir22(), ".assist", `cli-discover-${safeName}.log`);
27404
27499
  }
27405
27500
  function readCache(cli) {
27406
27501
  const path110 = logPath(cli);
27407
- if (!existsSync56(path110)) return void 0;
27502
+ if (!existsSync57(path110)) return void 0;
27408
27503
  return readFileSync38(path110, "utf8");
27409
27504
  }
27410
27505
  function writeCache(cli, output) {
27411
- const dir = join64(homedir22(), ".assist");
27412
- mkdirSync17(dir, { recursive: true });
27506
+ const dir = join65(homedir22(), ".assist");
27507
+ mkdirSync18(dir, { recursive: true });
27413
27508
  writeFileSync28(logPath(cli), output);
27414
27509
  }
27415
27510
  async function permitCliReads(cli, options2 = { noCache: false }) {
@@ -27540,7 +27635,7 @@ function registerCliHook(program) {
27540
27635
  }
27541
27636
 
27542
27637
  // src/commands/codeComment/codeCommentConfirm.ts
27543
- import { existsSync as existsSync58, readFileSync as readFileSync40, unlinkSync as unlinkSync9, writeFileSync as writeFileSync29 } from "fs";
27638
+ import { existsSync as existsSync59, readFileSync as readFileSync40, unlinkSync as unlinkSync9, writeFileSync as writeFileSync29 } from "fs";
27544
27639
  import chalk122 from "chalk";
27545
27640
 
27546
27641
  // src/shared/isHashCommentFile.ts
@@ -27574,7 +27669,7 @@ function isHashCommentFile(filePath) {
27574
27669
 
27575
27670
  // src/commands/codeComment/sweepRestrictedDir.ts
27576
27671
  import { readdirSync as readdirSync11, statSync as statSync9, unlinkSync as unlinkSync8 } from "fs";
27577
- import { join as join65 } from "path";
27672
+ import { join as join66 } from "path";
27578
27673
  var STALE_AFTER_MS = 30 * 60 * 1e3;
27579
27674
  function sweepRestrictedDir(dir = getRestrictedDir()) {
27580
27675
  let entries;
@@ -27585,7 +27680,7 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
27585
27680
  }
27586
27681
  const cutoff = Date.now() - STALE_AFTER_MS;
27587
27682
  for (const entry of entries) {
27588
- const path110 = join65(dir, entry);
27683
+ const path110 = join66(dir, entry);
27589
27684
  try {
27590
27685
  if (statSync9(path110).mtimeMs < cutoff) unlinkSync8(path110);
27591
27686
  } catch {
@@ -27595,10 +27690,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
27595
27690
  }
27596
27691
 
27597
27692
  // src/commands/codeComment/readPinState.ts
27598
- import { existsSync as existsSync57, readFileSync as readFileSync39 } from "fs";
27693
+ import { existsSync as existsSync58, readFileSync as readFileSync39 } from "fs";
27599
27694
  function readPinState(pin2) {
27600
27695
  const path110 = getPinStatePath(pin2);
27601
- if (!existsSync57(path110)) return void 0;
27696
+ if (!existsSync58(path110)) return void 0;
27602
27697
  try {
27603
27698
  const state = JSON.parse(readFileSync39(path110, "utf8"));
27604
27699
  if (state.pin !== pin2) return void 0;
@@ -27617,7 +27712,7 @@ function codeCommentConfirm(pin2) {
27617
27712
  process.exitCode = 1;
27618
27713
  return;
27619
27714
  }
27620
- if (!existsSync58(state.file)) {
27715
+ if (!existsSync59(state.file)) {
27621
27716
  console.error(chalk122.red(`Target file no longer exists: ${state.file}`));
27622
27717
  process.exitCode = 1;
27623
27718
  return;
@@ -27676,7 +27771,7 @@ function validateCommentText(raw, isHash = false) {
27676
27771
  }
27677
27772
 
27678
27773
  // src/commands/codeComment/issuePin.ts
27679
- import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync30 } from "fs";
27774
+ import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync30 } from "fs";
27680
27775
  import { randomInt } from "crypto";
27681
27776
 
27682
27777
  // src/commands/notify/deliverPinNotification.ts
@@ -27761,7 +27856,7 @@ async function deliverPinNotification(notification) {
27761
27856
  // src/commands/codeComment/issuePin.ts
27762
27857
  function issuePin(file, lineNumber, text19) {
27763
27858
  const pin2 = generatePin();
27764
- mkdirSync18(getRestrictedDir(), { recursive: true });
27859
+ mkdirSync19(getRestrictedDir(), { recursive: true });
27765
27860
  sweepRestrictedDir();
27766
27861
  writeFileSync30(
27767
27862
  getPinStatePath(pin2),
@@ -29847,16 +29942,16 @@ async function browserRun(options2) {
29847
29942
  }
29848
29943
 
29849
29944
  // src/commands/browser/browserSnapshot.ts
29850
- import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync31 } from "fs";
29945
+ import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync31 } from "fs";
29851
29946
  import { dirname as dirname33 } from "path";
29852
29947
 
29853
29948
  // src/commands/browser/snapshotPath.ts
29854
29949
  import { homedir as homedir23 } from "os";
29855
- import { join as join66 } from "path";
29950
+ import { join as join67 } from "path";
29856
29951
  function snapshotPath(tabUrl, now) {
29857
29952
  const host = new URL(tabUrl).host.replace(/[^\w.-]/g, "-");
29858
29953
  const timestamp9 = now.toISOString().replace(/[:.]/g, "-");
29859
- return join66(homedir23(), ".assist", "browser", `${host}-${timestamp9}.html`);
29954
+ return join67(homedir23(), ".assist", "browser", `${host}-${timestamp9}.html`);
29860
29955
  }
29861
29956
 
29862
29957
  // src/commands/browser/browserSnapshot.ts
@@ -29866,7 +29961,7 @@ async function browserSnapshot(options2) {
29866
29961
  url: options2.url
29867
29962
  });
29868
29963
  const path110 = snapshotPath(result.tabUrl, /* @__PURE__ */ new Date());
29869
- mkdirSync19(dirname33(path110), { recursive: true });
29964
+ mkdirSync20(dirname33(path110), { recursive: true });
29870
29965
  writeFileSync31(path110, result.html);
29871
29966
  console.log(`snapshot: ${path110}`);
29872
29967
  }
@@ -30063,28 +30158,28 @@ async function printExtensionUrl() {
30063
30158
  // src/commands/extension/signExtension.ts
30064
30159
  import { rm as rm2 } from "fs/promises";
30065
30160
  import { homedir as homedir24, tmpdir as tmpdir4 } from "os";
30066
- import { join as join72 } from "path";
30161
+ import { join as join73 } from "path";
30067
30162
  import chalk156 from "chalk";
30068
30163
 
30069
30164
  // src/commands/extension/copySignedXpi.ts
30070
30165
  import { copyFile } from "fs/promises";
30071
- import { join as join67 } from "path";
30166
+ import { join as join68 } from "path";
30072
30167
  var SIGNED_XPI_NAME = "assist-extension.xpi";
30073
30168
  async function copySignedXpi(xpi, dir) {
30074
- const fixed2 = join67(dir, SIGNED_XPI_NAME);
30169
+ const fixed2 = join68(dir, SIGNED_XPI_NAME);
30075
30170
  if (fixed2 === xpi) return fixed2;
30076
30171
  await copyFile(xpi, fixed2);
30077
30172
  return fixed2;
30078
30173
  }
30079
30174
 
30080
30175
  // src/commands/extension/findSignedXpi.ts
30081
- import { existsSync as existsSync59 } from "fs";
30176
+ import { existsSync as existsSync60 } from "fs";
30082
30177
  import { readdir } from "fs/promises";
30083
- import { join as join68 } from "path";
30178
+ import { join as join69 } from "path";
30084
30179
  async function findSignedXpi(dir) {
30085
- if (!existsSync59(dir)) return null;
30180
+ if (!existsSync60(dir)) return null;
30086
30181
  const name2 = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
30087
- return name2 ? join68(dir, name2) : null;
30182
+ return name2 ? join69(dir, name2) : null;
30088
30183
  }
30089
30184
 
30090
30185
  // src/commands/extension/signedAddonInstallPath.ts
@@ -30106,11 +30201,11 @@ async function signedAddonInstallPath(xpi) {
30106
30201
  }
30107
30202
 
30108
30203
  // src/commands/extension/signPreflightProblem.ts
30109
- import { existsSync as existsSync60 } from "fs";
30110
- import { join as join69 } from "path";
30204
+ import { existsSync as existsSync61 } from "fs";
30205
+ import { join as join70 } from "path";
30111
30206
  var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
30112
30207
  function signPreflightProblem(source) {
30113
- if (!existsSync60(join69(source, "content.js")))
30208
+ if (!existsSync61(join70(source, "content.js")))
30114
30209
  return {
30115
30210
  message: `no content.js in ${source}`,
30116
30211
  hint: "run npm run build to bundle the content script"
@@ -30125,7 +30220,7 @@ function signPreflightProblem(source) {
30125
30220
 
30126
30221
  // src/commands/extension/stageExtension.ts
30127
30222
  import { cp as cp3, mkdir as mkdir5, readFile as readFile5, rm, writeFile as writeFile4 } from "fs/promises";
30128
- import { basename as basename18, join as join70 } from "path";
30223
+ import { basename as basename18, join as join71 } from "path";
30129
30224
 
30130
30225
  // src/commands/extension/stampManifestVersion.ts
30131
30226
  function stampManifestVersion(manifest, version2) {
@@ -30142,7 +30237,7 @@ async function stageExtension(source, staging, version2) {
30142
30237
  recursive: true,
30143
30238
  filter: (path110) => basename18(path110) !== "updates.json"
30144
30239
  });
30145
- const manifest = join70(staging, "manifest.json");
30240
+ const manifest = join71(staging, "manifest.json");
30146
30241
  const stamped = stampManifestVersion(
30147
30242
  await readFile5(manifest, "utf8"),
30148
30243
  version2
@@ -30152,7 +30247,7 @@ async function stageExtension(source, staging, version2) {
30152
30247
 
30153
30248
  // src/commands/extension/writeUpdateManifest.ts
30154
30249
  import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
30155
- import { join as join71 } from "path";
30250
+ import { join as join72 } from "path";
30156
30251
 
30157
30252
  // src/commands/extension/buildUpdateManifest.ts
30158
30253
  var RELEASE_DOWNLOAD_URL = "https://github.com/staff0rd/assist/releases/download";
@@ -30177,17 +30272,17 @@ function buildUpdateManifest(manifest, version2) {
30177
30272
  // src/commands/extension/writeUpdateManifest.ts
30178
30273
  async function writeUpdateManifest(source, dir, version2) {
30179
30274
  await writeFile5(
30180
- join71(dir, "updates.json"),
30275
+ join72(dir, "updates.json"),
30181
30276
  buildUpdateManifest(
30182
- await readFile6(join71(source, "manifest.json"), "utf8"),
30277
+ await readFile6(join72(source, "manifest.json"), "utf8"),
30183
30278
  version2
30184
30279
  )
30185
30280
  );
30186
30281
  }
30187
30282
 
30188
30283
  // src/commands/extension/signExtension.ts
30189
- var ARTIFACTS_DIR = join72(homedir24(), ".assist", "extension");
30190
- var STAGING_DIR = join72(tmpdir4(), "assist-extension");
30284
+ var ARTIFACTS_DIR = join73(homedir24(), ".assist", "extension");
30285
+ var STAGING_DIR = join73(tmpdir4(), "assist-extension");
30191
30286
  async function signExtension() {
30192
30287
  const source = extensionDir();
30193
30288
  const problem = signPreflightProblem(source);
@@ -30371,7 +30466,7 @@ function registerDb(program) {
30371
30466
  }
30372
30467
 
30373
30468
  // src/commands/deploy/redirect.ts
30374
- import { existsSync as existsSync61, readFileSync as readFileSync42, writeFileSync as writeFileSync32 } from "fs";
30469
+ import { existsSync as existsSync62, readFileSync as readFileSync42, writeFileSync as writeFileSync32 } from "fs";
30375
30470
  import chalk159 from "chalk";
30376
30471
  var TRAILING_SLASH_SCRIPT = ` <script>
30377
30472
  if (!window.location.pathname.endsWith('/')) {
@@ -30380,7 +30475,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
30380
30475
  </script>`;
30381
30476
  function redirect() {
30382
30477
  const indexPath = "index.html";
30383
- if (!existsSync61(indexPath)) {
30478
+ if (!existsSync62(indexPath)) {
30384
30479
  console.log(chalk159.yellow("No index.html found"));
30385
30480
  return;
30386
30481
  }
@@ -30479,9 +30574,9 @@ import { readFileSync as readFileSync43 } from "fs";
30479
30574
  import { parse as parseYaml3 } from "yaml";
30480
30575
 
30481
30576
  // src/commands/devlog/devEntryPath.ts
30482
- import { join as join73 } from "path";
30577
+ import { join as join74 } from "path";
30483
30578
  function devEntryPath(repoName, week, devDir) {
30484
- return join73(devDir, repoName, `${week.toLowerCase()}.md`);
30579
+ return join74(devDir, repoName, `${week.toLowerCase()}.md`);
30485
30580
  }
30486
30581
 
30487
30582
  // src/commands/devlog/loadDevEntry.ts
@@ -30593,15 +30688,15 @@ function findTargetWeek(weeks, { lastWeek, skip: skip3, today }) {
30593
30688
  import chalk162 from "chalk";
30594
30689
 
30595
30690
  // src/shared/getRepoName.ts
30596
- import { existsSync as existsSync62, readFileSync as readFileSync44 } from "fs";
30597
- import { basename as basename19, join as join74 } from "path";
30691
+ import { existsSync as existsSync63, readFileSync as readFileSync44 } from "fs";
30692
+ import { basename as basename19, join as join75 } from "path";
30598
30693
  function getRepoName() {
30599
30694
  const config = loadConfig();
30600
30695
  if (config.devlog?.name) {
30601
30696
  return config.devlog.name;
30602
30697
  }
30603
- const packageJsonPath = join74(process.cwd(), "package.json");
30604
- if (existsSync62(packageJsonPath)) {
30698
+ const packageJsonPath = join75(process.cwd(), "package.json");
30699
+ if (existsSync63(packageJsonPath)) {
30605
30700
  try {
30606
30701
  const content = readFileSync44(packageJsonPath, "utf8");
30607
30702
  const pkg = JSON.parse(content);
@@ -30679,7 +30774,7 @@ function list2(options2) {
30679
30774
 
30680
30775
  // src/commands/devlog/loadDevWeeks.ts
30681
30776
  import { readdirSync as readdirSync12 } from "fs";
30682
- import { join as join75 } from "path";
30777
+ import { join as join76 } from "path";
30683
30778
  var DEV_FILENAME_PATTERN = /^(\d{4})-w(\d{2})\.md$/;
30684
30779
  function parseDevWeekFilename(filename) {
30685
30780
  const match = filename.match(DEV_FILENAME_PATTERN);
@@ -30693,7 +30788,7 @@ function readFilenames(dir) {
30693
30788
  }
30694
30789
  }
30695
30790
  function loadDevWeeks(repoName, devDir) {
30696
- return readFilenames(join75(devDir, repoName)).map(parseDevWeekFilename).filter((week) => week !== null).sort();
30791
+ return readFilenames(join76(devDir, repoName)).map(parseDevWeekFilename).filter((week) => week !== null).sort();
30697
30792
  }
30698
30793
 
30699
30794
  // src/commands/devlog/next/displayNextEntry.ts
@@ -30958,14 +31053,14 @@ async function skip2(week, cwd = process.cwd()) {
30958
31053
  }
30959
31054
 
30960
31055
  // src/commands/devlog/slack/slack.ts
30961
- import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync36 } from "fs";
31056
+ import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync36 } from "fs";
30962
31057
  import chalk168 from "chalk";
30963
31058
 
30964
31059
  // src/commands/slack/postSlackMessage.ts
30965
- import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync35 } from "fs";
31060
+ import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync35 } from "fs";
30966
31061
 
30967
31062
  // src/commands/slack/previewSlackThreadParts.ts
30968
- import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync34 } from "fs";
31063
+ import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync34 } from "fs";
30969
31064
 
30970
31065
  // src/commands/slack/readSlackParts.ts
30971
31066
  import { readFileSync as readFileSync46 } from "fs";
@@ -31011,12 +31106,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
31011
31106
  }
31012
31107
 
31013
31108
  // src/commands/slack/slackWorkingFile.ts
31014
- import { join as join76 } from "path";
31109
+ import { join as join77 } from "path";
31015
31110
  function slackWorkingFile(channel, partIndex) {
31016
31111
  const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
31017
- const dir = join76(getStoreDir(), "slack");
31112
+ const dir = join77(getStoreDir(), "slack");
31018
31113
  const name2 = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
31019
- return { dir, bodyPath: join76(dir, `${name2}.md`) };
31114
+ return { dir, bodyPath: join77(dir, `${name2}.md`) };
31020
31115
  }
31021
31116
 
31022
31117
  // src/commands/slack/previewSlackThreadParts.ts
@@ -31028,7 +31123,7 @@ async function previewSlackThreadParts({
31028
31123
  }) {
31029
31124
  const bodies = readSlackParts(partFiles);
31030
31125
  const { dir } = slackWorkingFile(channel);
31031
- mkdirSync20(dir, { recursive: true });
31126
+ mkdirSync21(dir, { recursive: true });
31032
31127
  const paths = bodies.map((body, index3) => {
31033
31128
  const { bodyPath } = slackWorkingFile(channel, index3 + 1);
31034
31129
  writeFileSync34(bodyPath, `${body}
@@ -31082,7 +31177,7 @@ async function postSlackMessage(channelArg, options2) {
31082
31177
  process.exit(1);
31083
31178
  }
31084
31179
  const { dir, bodyPath } = slackWorkingFile(channel);
31085
- mkdirSync21(dir, { recursive: true });
31180
+ mkdirSync22(dir, { recursive: true });
31086
31181
  writeFileSync35(bodyPath, `${body}
31087
31182
  `);
31088
31183
  await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
@@ -31222,7 +31317,7 @@ function fail8(message4) {
31222
31317
  process.exit(1);
31223
31318
  }
31224
31319
  function writeParts(channel, parts2) {
31225
- mkdirSync22(slackWorkingFile(channel).dir, { recursive: true });
31320
+ mkdirSync23(slackWorkingFile(channel).dir, { recursive: true });
31226
31321
  return parts2.map((part, index3) => {
31227
31322
  const { bodyPath } = slackWorkingFile(channel, index3 + 1);
31228
31323
  writeFileSync36(bodyPath, `${part}
@@ -31266,7 +31361,7 @@ async function slack2(week) {
31266
31361
  }
31267
31362
 
31268
31363
  // src/commands/devlog/write.ts
31269
- import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync37 } from "fs";
31364
+ import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync37 } from "fs";
31270
31365
  import { dirname as dirname34 } from "path";
31271
31366
  import chalk169 from "chalk";
31272
31367
 
@@ -31361,7 +31456,7 @@ async function write() {
31361
31456
  const devDir = resolveDevDir();
31362
31457
  const repoName = getRepoName();
31363
31458
  const path110 = devEntryPath(repoName, result.data.week, devDir);
31364
- mkdirSync23(dirname34(path110), { recursive: true });
31459
+ mkdirSync24(dirname34(path110), { recursive: true });
31365
31460
  writeFileSync37(path110, formatDevEntry(repoName, result.data));
31366
31461
  console.log(chalk169.green(`Wrote ${path110}`));
31367
31462
  }
@@ -31558,19 +31653,19 @@ async function findPhaseUnlockItem(itemId2, phase) {
31558
31653
  }
31559
31654
 
31560
31655
  // src/commands/docs/getDocsUnlockPinPath.ts
31561
- import { join as join77 } from "path";
31656
+ import { join as join78 } from "path";
31562
31657
  function getDocsUnlockPinPath(pin2) {
31563
- return join77(getRestrictedDir(), `docs-unlock-pin-${pin2}.json`);
31658
+ return join78(getRestrictedDir(), `docs-unlock-pin-${pin2}.json`);
31564
31659
  }
31565
31660
 
31566
31661
  // src/commands/docs/readDocsUnlockPinState.ts
31567
- import { existsSync as existsSync63, readFileSync as readFileSync48 } from "fs";
31662
+ import { existsSync as existsSync64, readFileSync as readFileSync48 } from "fs";
31568
31663
  function isPositiveInteger(value) {
31569
31664
  return Number.isInteger(value) && value > 0;
31570
31665
  }
31571
31666
  function readDocsUnlockPinState(pin2) {
31572
31667
  const path110 = getDocsUnlockPinPath(pin2);
31573
- if (!existsSync63(path110)) return void 0;
31668
+ if (!existsSync64(path110)) return void 0;
31574
31669
  try {
31575
31670
  const state = JSON.parse(readFileSync48(path110, "utf8"));
31576
31671
  if (state.pin !== pin2) return void 0;
@@ -31616,7 +31711,7 @@ import chalk174 from "chalk";
31616
31711
 
31617
31712
  // src/commands/notify/issueUnlockPin.ts
31618
31713
  import { randomInt as randomInt2 } from "crypto";
31619
- import { mkdirSync as mkdirSync24, unlinkSync as unlinkSync11, writeFileSync as writeFileSync38 } from "fs";
31714
+ import { mkdirSync as mkdirSync25, unlinkSync as unlinkSync11, writeFileSync as writeFileSync38 } from "fs";
31620
31715
  async function issueUnlockPin({
31621
31716
  area,
31622
31717
  label,
@@ -31624,7 +31719,7 @@ async function issueUnlockPin({
31624
31719
  state
31625
31720
  }) {
31626
31721
  const pin2 = randomInt2(0, 1e3).toString().padStart(3, "0");
31627
- mkdirSync24(getRestrictedDir(), { recursive: true });
31722
+ mkdirSync25(getRestrictedDir(), { recursive: true });
31628
31723
  sweepRestrictedDir();
31629
31724
  const path110 = pinPath(pin2);
31630
31725
  writeFileSync38(path110, JSON.stringify({ ...state, pin: pin2 }));
@@ -31703,7 +31798,7 @@ import { unlinkSync as unlinkSync12 } from "fs";
31703
31798
  import chalk176 from "chalk";
31704
31799
 
31705
31800
  // src/commands/schema/approveSchemaUnlock.ts
31706
- import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync39 } from "fs";
31801
+ import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync39 } from "fs";
31707
31802
  import chalk175 from "chalk";
31708
31803
 
31709
31804
  // src/commands/schema/schemaHarnessLabel.ts
@@ -31734,7 +31829,7 @@ function approveSession({ harness, conversationId }) {
31734
31829
  const scope = { harness, conversationId };
31735
31830
  const path110 = getSchemaSessionApprovalPath(scope);
31736
31831
  if (!path110) return;
31737
- mkdirSync25(getSchemaSessionApprovalDir(), { recursive: true });
31832
+ mkdirSync26(getSchemaSessionApprovalDir(), { recursive: true });
31738
31833
  writeFileSync39(path110, JSON.stringify(scope));
31739
31834
  console.log(
31740
31835
  chalk175.green(
@@ -31748,13 +31843,13 @@ async function approveSchemaUnlock(state) {
31748
31843
  }
31749
31844
 
31750
31845
  // src/commands/schema/getSchemaUnlockPinPath.ts
31751
- import { join as join78 } from "path";
31846
+ import { join as join79 } from "path";
31752
31847
  function getSchemaUnlockPinPath(pin2) {
31753
- return join78(getRestrictedDir(), `schema-unlock-pin-${pin2}.json`);
31848
+ return join79(getRestrictedDir(), `schema-unlock-pin-${pin2}.json`);
31754
31849
  }
31755
31850
 
31756
31851
  // src/commands/schema/readSchemaUnlockPinState.ts
31757
- import { existsSync as existsSync64, readFileSync as readFileSync49 } from "fs";
31852
+ import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
31758
31853
  function isPositiveInteger2(value) {
31759
31854
  return Number.isInteger(value) && value > 0;
31760
31855
  }
@@ -31779,7 +31874,7 @@ function toState(raw) {
31779
31874
  }
31780
31875
  function readSchemaUnlockPinState(pin2) {
31781
31876
  const path110 = getSchemaUnlockPinPath(pin2);
31782
- if (!existsSync64(path110)) return void 0;
31877
+ if (!existsSync65(path110)) return void 0;
31783
31878
  try {
31784
31879
  const raw = JSON.parse(readFileSync49(path110, "utf8"));
31785
31880
  if (raw.pin !== pin2) return void 0;
@@ -31909,7 +32004,7 @@ function registerSchema(parent) {
31909
32004
 
31910
32005
  // src/commands/dotnet/checkBuildLocks.ts
31911
32006
  import { closeSync as closeSync6, openSync as openSync7, readdirSync as readdirSync14 } from "fs";
31912
- import { join as join79 } from "path";
32007
+ import { join as join80 } from "path";
31913
32008
  import chalk179 from "chalk";
31914
32009
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
31915
32010
  function isLockedDll(debugDir) {
@@ -31921,7 +32016,7 @@ function isLockedDll(debugDir) {
31921
32016
  }
31922
32017
  for (const file of files) {
31923
32018
  if (!file.toLowerCase().endsWith(".dll")) continue;
31924
- const dllPath = join79(debugDir, file);
32019
+ const dllPath = join80(debugDir, file);
31925
32020
  try {
31926
32021
  const fd = openSync7(dllPath, "r+");
31927
32022
  closeSync6(fd);
@@ -31939,13 +32034,13 @@ function findFirstLockedDll(dir) {
31939
32034
  return null;
31940
32035
  }
31941
32036
  if (entries.includes("bin")) {
31942
- const locked = isLockedDll(join79(dir, "bin", "Debug"));
32037
+ const locked = isLockedDll(join80(dir, "bin", "Debug"));
31943
32038
  if (locked) return locked;
31944
32039
  }
31945
32040
  for (const entry of entries) {
31946
32041
  if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
31947
32042
  continue;
31948
- const found = findFirstLockedDll(join79(dir, entry));
32043
+ const found = findFirstLockedDll(join80(dir, entry));
31949
32044
  if (found) return found;
31950
32045
  }
31951
32046
  return null;
@@ -32113,12 +32208,12 @@ function printJson(tree, totalCount, solutions) {
32113
32208
  }
32114
32209
 
32115
32210
  // src/commands/dotnet/resolveCsproj.ts
32116
- import { existsSync as existsSync65 } from "fs";
32211
+ import { existsSync as existsSync66 } from "fs";
32117
32212
  import path42 from "path";
32118
32213
  import chalk181 from "chalk";
32119
32214
  function resolveCsproj(csprojPath) {
32120
32215
  const resolved = path42.resolve(csprojPath);
32121
- if (!existsSync65(resolved)) {
32216
+ if (!existsSync66(resolved)) {
32122
32217
  console.error(chalk181.red(`File not found: ${resolved}`));
32123
32218
  process.exit(1);
32124
32219
  }
@@ -32286,17 +32381,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
32286
32381
  }
32287
32382
 
32288
32383
  // src/commands/dotnet/resolveSolution.ts
32289
- import { existsSync as existsSync66 } from "fs";
32384
+ import { existsSync as existsSync67 } from "fs";
32290
32385
  import path43 from "path";
32291
32386
  import chalk185 from "chalk";
32292
32387
 
32293
32388
  // src/commands/dotnet/findSolution.ts
32294
32389
  import { readdirSync as readdirSync16 } from "fs";
32295
- import { dirname as dirname35, join as join80 } from "path";
32390
+ import { dirname as dirname35, join as join81 } from "path";
32296
32391
  import chalk184 from "chalk";
32297
32392
  function findSlnInDir(dir) {
32298
32393
  try {
32299
- return readdirSync16(dir).filter((f) => f.endsWith(".sln")).map((f) => join80(dir, f));
32394
+ return readdirSync16(dir).filter((f) => f.endsWith(".sln")).map((f) => join81(dir, f));
32300
32395
  } catch {
32301
32396
  return [];
32302
32397
  }
@@ -32327,7 +32422,7 @@ function findSolution() {
32327
32422
  function resolveSolution(sln) {
32328
32423
  if (sln) {
32329
32424
  const resolved = path43.resolve(sln);
32330
- if (!existsSync66(resolved)) {
32425
+ if (!existsSync67(resolved)) {
32331
32426
  console.error(chalk185.red(`Solution file not found: ${resolved}`));
32332
32427
  process.exit(1);
32333
32428
  }
@@ -32367,7 +32462,7 @@ function parseInspectReport(json) {
32367
32462
 
32368
32463
  // src/commands/dotnet/runInspectCode.ts
32369
32464
  import { execSync as execSync40 } from "child_process";
32370
- import { existsSync as existsSync67, readFileSync as readFileSync52, unlinkSync as unlinkSync13 } from "fs";
32465
+ import { existsSync as existsSync68, readFileSync as readFileSync52, unlinkSync as unlinkSync13 } from "fs";
32371
32466
  import { tmpdir as tmpdir5 } from "os";
32372
32467
  import path44 from "path";
32373
32468
  import chalk186 from "chalk";
@@ -32398,7 +32493,7 @@ function runInspectCode(slnPath, include, swea) {
32398
32493
  console.error(chalk186.red("jb inspectcode failed"));
32399
32494
  process.exit(1);
32400
32495
  }
32401
- if (!existsSync67(reportPath)) {
32496
+ if (!existsSync68(reportPath)) {
32402
32497
  console.error(chalk186.red("Report file not generated"));
32403
32498
  process.exit(1);
32404
32499
  }
@@ -33304,7 +33399,7 @@ function aggregateCommitters(authorLists) {
33304
33399
  import { spawnSync as spawnSync7 } from "child_process";
33305
33400
  import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync40 } from "fs";
33306
33401
  import { tmpdir as tmpdir6 } from "os";
33307
- import { join as join81 } from "path";
33402
+ import { join as join82 } from "path";
33308
33403
  function buildArgs3(queryFile, vars) {
33309
33404
  const args = ["api", "graphql", "-F", `query=@${queryFile}`];
33310
33405
  for (const [key, value] of Object.entries(vars)) {
@@ -33314,7 +33409,7 @@ function buildArgs3(queryFile, vars) {
33314
33409
  return args;
33315
33410
  }
33316
33411
  function runGhGraphql(mutation, vars) {
33317
- const queryFile = join81(tmpdir6(), `gh-query-${Date.now()}.graphql`);
33412
+ const queryFile = join82(tmpdir6(), `gh-query-${Date.now()}.graphql`);
33318
33413
  writeFileSync40(queryFile, mutation);
33319
33414
  try {
33320
33415
  const result = spawnSync7("gh", buildArgs3(queryFile, vars), {
@@ -34753,24 +34848,24 @@ function slugFromUrl(url) {
34753
34848
  }
34754
34849
 
34755
34850
  // src/commands/github/issue/writeIssueWorkingFile.ts
34756
- import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync41 } from "fs";
34851
+ import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync41 } from "fs";
34757
34852
 
34758
34853
  // src/commands/github/issue/issueWorkingFile.ts
34759
- import { join as join82 } from "path";
34854
+ import { join as join83 } from "path";
34760
34855
  function issueWorkingFile(slug2, number) {
34761
34856
  const [owner = "unknown", repo = "unknown"] = slug2.split("/");
34762
- const dir = join82(getStoreDir(), "github-issues", owner, repo);
34857
+ const dir = join83(getStoreDir(), "github-issues", owner, repo);
34763
34858
  return {
34764
34859
  dir,
34765
- bodyPath: join82(dir, `${number}.md`),
34766
- metaPath: join82(dir, `${number}.json`)
34860
+ bodyPath: join83(dir, `${number}.md`),
34861
+ metaPath: join83(dir, `${number}.json`)
34767
34862
  };
34768
34863
  }
34769
34864
 
34770
34865
  // src/commands/github/issue/writeIssueWorkingFile.ts
34771
34866
  function writeIssueWorkingFile(slug2, number, target, updatedAt, body) {
34772
34867
  const { dir, bodyPath, metaPath } = issueWorkingFile(slug2, number);
34773
- mkdirSync26(dir, { recursive: true });
34868
+ mkdirSync27(dir, { recursive: true });
34774
34869
  writeFileSync41(bodyPath, body);
34775
34870
  writeFileSync41(
34776
34871
  metaPath,
@@ -34798,10 +34893,10 @@ function fetchIssueToWorkingFile(number, repo) {
34798
34893
  }
34799
34894
 
34800
34895
  // src/commands/github/issue/resumeIssueBody.ts
34801
- import { existsSync as existsSync68, readFileSync as readFileSync53 } from "fs";
34896
+ import { existsSync as existsSync69, readFileSync as readFileSync53 } from "fs";
34802
34897
  function resumeIssueBody(slug2, number, updatedAt) {
34803
34898
  const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
34804
- if (!existsSync68(bodyPath) || !existsSync68(metaPath)) return void 0;
34899
+ if (!existsSync69(bodyPath) || !existsSync69(metaPath)) return void 0;
34805
34900
  try {
34806
34901
  const meta = JSON.parse(readFileSync53(metaPath, "utf8"));
34807
34902
  if (meta.updatedAt !== updatedAt) return void 0;
@@ -35337,14 +35432,15 @@ function addScanUsage(a, b) {
35337
35432
  // src/commands/inbox/inboxFlagInstructions.ts
35338
35433
  function inboxFlagInstructions() {
35339
35434
  return [
35340
- "Do not flag anything from bots, apps, automated or notification systems (CI, calendars, ticketing, monitoring, no-reply addresses), newsletters or mailing lists.",
35435
+ "Do not flag purely automated messages with no person-written message to me: bots, apps, CI, calendars, ticketing, monitoring, newsletters or mailing lists.",
35436
+ `A notification email that relays a message a person wrote to me (such as a Teams chat @mention or reply, "<Name> mentioned you in your chat") is a person's message, not an automated one: judge the relayed message like any other and flag it when it needs my reply or action, even when it comes from a no-reply address.`,
35341
35437
  "Flag messages a person wrote to me that need me to reply or act. That includes messages that hand me something to act on without asking a question, such as a credential or secret to retrieve, a document to review, or a deadline to meet.",
35342
35438
  "Judge each message on its full content, never on a search snippet alone.",
35343
35439
  "",
35344
35440
  "For each flagged message return:",
35345
35441
  '- source: "gmail" or "slack"',
35346
35442
  "- messageId: the Gmail message id, or for Slack <channel_id>:<message ts>",
35347
- "- sender: the sender's name",
35443
+ "- sender: the sender's name; for a relayed message, the person who wrote it, never the notification address or service",
35348
35444
  "- summary: one sentence on the reply or action it needs from me",
35349
35445
  "- link: the Gmail message viewUrl or the Slack permalink",
35350
35446
  "- receivedAt: when it was sent, as an ISO 8601 timestamp",
@@ -35945,15 +36041,15 @@ function clearStalePrBranch(cwd, branch2) {
35945
36041
  }
35946
36042
 
35947
36043
  // src/commands/sessions/daemon/worktree/createWorktree.ts
35948
- import { existsSync as existsSync69 } from "fs";
36044
+ import { existsSync as existsSync70 } from "fs";
35949
36045
  import { basename as basename22, dirname as dirname37 } from "path";
35950
36046
 
35951
36047
  // src/commands/sessions/daemon/worktree/nextWorktreePath.ts
35952
- import { basename as basename21, join as join83 } from "path";
36048
+ import { basename as basename21, join as join84 } from "path";
35953
36049
  function nextWorktreePath(clone, base, isTaken) {
35954
36050
  const name2 = basename21(clone);
35955
36051
  for (let n = 2; n < 1e3; n++) {
35956
- const candidate = join83(base, `${name2}-${n}`);
36052
+ const candidate = join84(base, `${name2}-${n}`);
35957
36053
  if (!isTaken(candidate)) return candidate;
35958
36054
  }
35959
36055
  throw new Error(`no free worktree suffix for ${clone}`);
@@ -35977,7 +36073,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
35977
36073
  const base = strategy.root ? expandTilde(strategy.root) : dirname37(clone);
35978
36074
  const registered = new Set(listWorktreePaths(clone));
35979
36075
  const branches = new Set(listLocalBranches(clone));
35980
- const isTaken = (candidate) => registered.has(candidate) || existsSync69(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename22(candidate));
36076
+ const isTaken = (candidate) => registered.has(candidate) || existsSync70(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename22(candidate));
35981
36077
  const path110 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
35982
36078
  const ready = addWorktree(clone, path110, strategy.trunk);
35983
36079
  ready.catch(() => {
@@ -36217,8 +36313,8 @@ function persistedTreeRoots() {
36217
36313
  }
36218
36314
 
36219
36315
  // src/commands/sessions/daemon/worktree/seedWorktree.ts
36220
- import { copyFileSync, existsSync as existsSync71, mkdirSync as mkdirSync27 } from "fs";
36221
- import { dirname as dirname38, join as join85 } from "path";
36316
+ import { copyFileSync as copyFileSync2, existsSync as existsSync72, mkdirSync as mkdirSync28 } from "fs";
36317
+ import { dirname as dirname38, join as join86 } from "path";
36222
36318
 
36223
36319
  // src/commands/sessions/daemon/worktree/installPaths.ts
36224
36320
  import { resolve as resolve22 } from "path";
@@ -36248,14 +36344,14 @@ function pendingPathAction(enclosing, states2, paths, stopped) {
36248
36344
  }
36249
36345
 
36250
36346
  // src/commands/sessions/daemon/worktree/detectInstallCommand.ts
36251
- import { existsSync as existsSync70 } from "fs";
36252
- import { join as join84 } from "path";
36347
+ import { existsSync as existsSync71 } from "fs";
36348
+ import { join as join85 } from "path";
36253
36349
  function detectInstallCommand(dir) {
36254
- if (!existsSync70(join84(dir, "package.json"))) return null;
36255
- if (existsSync70(join84(dir, "pnpm-lock.yaml"))) return "pnpm install";
36256
- if (existsSync70(join84(dir, "yarn.lock"))) return "yarn install";
36257
- if (existsSync70(join84(dir, "bun.lockb"))) return "bun install";
36258
- if (existsSync70(join84(dir, "package-lock.json"))) return "npm ci";
36350
+ if (!existsSync71(join85(dir, "package.json"))) return null;
36351
+ if (existsSync71(join85(dir, "pnpm-lock.yaml"))) return "pnpm install";
36352
+ if (existsSync71(join85(dir, "yarn.lock"))) return "yarn install";
36353
+ if (existsSync71(join85(dir, "bun.lockb"))) return "bun install";
36354
+ if (existsSync71(join85(dir, "package-lock.json"))) return "npm ci";
36259
36355
  return "npm install";
36260
36356
  }
36261
36357
 
@@ -36447,12 +36543,12 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
36447
36543
  }
36448
36544
  function copyConfigFiles(worktreePath, clone, copy) {
36449
36545
  for (const rel of copy) {
36450
- const src = join85(clone, rel);
36451
- if (!existsSync71(src)) continue;
36452
- const dest = join85(worktreePath, rel);
36546
+ const src = join86(clone, rel);
36547
+ if (!existsSync72(src)) continue;
36548
+ const dest = join86(worktreePath, rel);
36453
36549
  try {
36454
- mkdirSync27(dirname38(dest), { recursive: true });
36455
- copyFileSync(src, dest);
36550
+ mkdirSync28(dirname38(dest), { recursive: true });
36551
+ copyFileSync2(src, dest);
36456
36552
  daemonLog(`worktree ${worktreePath} seeded ${rel}`);
36457
36553
  } catch (error) {
36458
36554
  daemonLog(
@@ -36938,7 +37034,7 @@ function registerLitellm(program) {
36938
37034
  }
36939
37035
 
36940
37036
  // src/commands/mermaidExport.ts
36941
- import { mkdirSync as mkdirSync28, readdirSync as readdirSync17 } from "fs";
37037
+ import { mkdirSync as mkdirSync29, readdirSync as readdirSync17 } from "fs";
36942
37038
  import { resolve as resolve24 } from "path";
36943
37039
  import chalk204 from "chalk";
36944
37040
 
@@ -37007,7 +37103,7 @@ function extractMermaidBlocks(markdown) {
37007
37103
  async function mermaidExport(file, options2 = {}) {
37008
37104
  const { mermaid } = loadConfig();
37009
37105
  const outDir = resolve24(process.cwd(), options2.out ?? ".");
37010
- mkdirSync28(outDir, { recursive: true });
37106
+ mkdirSync29(outDir, { recursive: true });
37011
37107
  if (options2.index !== void 0) {
37012
37108
  if (!Number.isInteger(options2.index) || options2.index < 1) {
37013
37109
  console.error(
@@ -37102,7 +37198,7 @@ function boardSource(raw, anchorId, options2) {
37102
37198
  import { stringify as stringify2 } from "yaml";
37103
37199
 
37104
37200
  // src/commands/miro/writeExtract.ts
37105
- import { mkdirSync as mkdirSync29, writeFileSync as writeFileSync43 } from "fs";
37201
+ import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync43 } from "fs";
37106
37202
  import { dirname as dirname39 } from "path";
37107
37203
  import { stringify } from "yaml";
37108
37204
  function headerLines(header) {
@@ -37116,7 +37212,7 @@ function headerLines(header) {
37116
37212
  ];
37117
37213
  }
37118
37214
  function writeExtract(file, header, texts) {
37119
- mkdirSync29(dirname39(file), { recursive: true });
37215
+ mkdirSync30(dirname39(file), { recursive: true });
37120
37216
  writeFileSync43(file, `${headerLines(header).join("\n")}
37121
37217
  ${stringify(texts)}`);
37122
37218
  }
@@ -37181,10 +37277,10 @@ function applyIgnore(texts, ignore3) {
37181
37277
  }
37182
37278
 
37183
37279
  // src/commands/miro/readIgnoreList.ts
37184
- import { existsSync as existsSync72, readFileSync as readFileSync55 } from "fs";
37280
+ import { existsSync as existsSync73, readFileSync as readFileSync55 } from "fs";
37185
37281
  import { parse as parse2 } from "yaml";
37186
37282
  function readIgnoreList(file) {
37187
- if (!existsSync72(file))
37283
+ if (!existsSync73(file))
37188
37284
  throw new MiroExtractError(
37189
37285
  `No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
37190
37286
  );
@@ -37669,15 +37765,15 @@ function createNetcapHandler(options2) {
37669
37765
  // src/commands/netcap/prepareExtensionForLoad.ts
37670
37766
  import { cp as cp4, readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
37671
37767
  import { networkInterfaces } from "os";
37672
- import { join as join87 } from "path";
37768
+ import { join as join88 } from "path";
37673
37769
  import chalk207 from "chalk";
37674
37770
 
37675
37771
  // src/commands/netcap/netcapExtensionDir.ts
37676
- import { dirname as dirname40, join as join86 } from "path";
37772
+ import { dirname as dirname40, join as join87 } from "path";
37677
37773
  import { fileURLToPath as fileURLToPath8 } from "url";
37678
37774
  var moduleDir2 = dirname40(fileURLToPath8(import.meta.url));
37679
37775
  function netcapExtensionDir() {
37680
- return join86(moduleDir2, "commands", "netcap", "netcap-extension");
37776
+ return join87(moduleDir2, "commands", "netcap", "netcap-extension");
37681
37777
  }
37682
37778
 
37683
37779
  // src/commands/netcap/prepareExtensionForLoad.ts
@@ -37692,7 +37788,7 @@ function lanIPv4() {
37692
37788
  return void 0;
37693
37789
  }
37694
37790
  async function configureBackground(dir, host, port, filter) {
37695
- const file = join87(dir, "background.js");
37791
+ const file = join88(dir, "background.js");
37696
37792
  const source = await readFile7(file, "utf8");
37697
37793
  await writeFile6(
37698
37794
  file,
@@ -37732,20 +37828,20 @@ async function prepareExtensionForLoad(port, filter = "") {
37732
37828
  }
37733
37829
 
37734
37830
  // src/commands/netcap/resolveNetcapOutPath.ts
37735
- import { isAbsolute as isAbsolute6, join as join89, resolve as resolve26 } from "path";
37831
+ import { isAbsolute as isAbsolute6, join as join90, resolve as resolve26 } from "path";
37736
37832
 
37737
37833
  // src/commands/netcap/defaultCapturePath.ts
37738
37834
  import { homedir as homedir25 } from "os";
37739
- import { join as join88 } from "path";
37835
+ import { join as join89 } from "path";
37740
37836
  function defaultCapturePath() {
37741
- return join88(homedir25(), ".assist", "netcap", "capture.jsonl");
37837
+ return join89(homedir25(), ".assist", "netcap", "capture.jsonl");
37742
37838
  }
37743
37839
 
37744
37840
  // src/commands/netcap/resolveNetcapOutPath.ts
37745
37841
  function resolveNetcapOutPath(out) {
37746
37842
  if (!out) return defaultCapturePath();
37747
37843
  const dir = isAbsolute6(out) ? out : resolve26(process.cwd(), out);
37748
- return join89(dir, "capture.jsonl");
37844
+ return join90(dir, "capture.jsonl");
37749
37845
  }
37750
37846
 
37751
37847
  // src/commands/netcap/netcap.ts
@@ -37792,7 +37888,7 @@ netcap stopped \u2014 captured ${count10} ${count10 === 1 ? "entry" : "entries"}
37792
37888
 
37793
37889
  // src/commands/netcap/netcapExtract.ts
37794
37890
  import { writeFileSync as writeFileSync44 } from "fs";
37795
- import { join as join90 } from "path";
37891
+ import { join as join91 } from "path";
37796
37892
  import chalk209 from "chalk";
37797
37893
 
37798
37894
  // src/commands/netcap/extractPostsFromCapture.ts
@@ -38237,7 +38333,7 @@ function extractPostsFromCapture(captureFile) {
38237
38333
  function netcapExtract(file) {
38238
38334
  const captureFile = file ?? defaultCapturePath();
38239
38335
  const posts = extractPostsFromCapture(captureFile);
38240
- const outFile = join90(captureFile, "..", "posts.json");
38336
+ const outFile = join91(captureFile, "..", "posts.json");
38241
38337
  writeFileSync44(outFile, `${JSON.stringify(posts, null, 2)}
38242
38338
  `);
38243
38339
  console.log(
@@ -38633,9 +38729,9 @@ async function comment2(path110, line, body, options2 = {}) {
38633
38729
 
38634
38730
  // src/commands/prs/commentsCachePath.ts
38635
38731
  import { homedir as homedir26 } from "os";
38636
- import { join as join91 } from "path";
38732
+ import { join as join92 } from "path";
38637
38733
  function commentsCachePath(org, repo, prNumber) {
38638
- return join91(
38734
+ return join92(
38639
38735
  homedir26(),
38640
38736
  ".assist",
38641
38737
  "pr-comments",
@@ -38646,16 +38742,16 @@ function commentsCachePath(org, repo, prNumber) {
38646
38742
  }
38647
38743
 
38648
38744
  // src/commands/prs/listComments/updateCommentsCache.ts
38649
- import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync45 } from "fs";
38745
+ import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync45 } from "fs";
38650
38746
  import { dirname as dirname42 } from "path";
38651
38747
  import { stringify as stringify3 } from "yaml";
38652
38748
 
38653
38749
  // src/commands/prs/loadCommentsCache.ts
38654
- import { existsSync as existsSync73, readFileSync as readFileSync58, unlinkSync as unlinkSync15 } from "fs";
38750
+ import { existsSync as existsSync74, readFileSync as readFileSync58, unlinkSync as unlinkSync15 } from "fs";
38655
38751
  import { parse as parse3 } from "yaml";
38656
38752
  function loadCommentsCache(org, repo, prNumber) {
38657
38753
  const cachePath = commentsCachePath(org, repo, prNumber);
38658
- if (!existsSync73(cachePath)) {
38754
+ if (!existsSync74(cachePath)) {
38659
38755
  return null;
38660
38756
  }
38661
38757
  const content = readFileSync58(cachePath, "utf8");
@@ -38663,7 +38759,7 @@ function loadCommentsCache(org, repo, prNumber) {
38663
38759
  }
38664
38760
  function deleteCommentsCache(org, repo, prNumber) {
38665
38761
  const cachePath = commentsCachePath(org, repo, prNumber);
38666
- if (existsSync73(cachePath)) {
38762
+ if (existsSync74(cachePath)) {
38667
38763
  unlinkSync15(cachePath);
38668
38764
  console.log("No more unresolved line comments. Cache dropped.");
38669
38765
  }
@@ -38671,10 +38767,10 @@ function deleteCommentsCache(org, repo, prNumber) {
38671
38767
 
38672
38768
  // src/commands/prs/removeStaleCommentsCaches.ts
38673
38769
  import { readdirSync as readdirSync18, unlinkSync as unlinkSync16 } from "fs";
38674
- import { join as join92 } from "path";
38770
+ import { join as join93 } from "path";
38675
38771
  var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
38676
38772
  function removeStaleCommentsCaches(cwd = process.cwd()) {
38677
- const dir = join92(cwd, ".assist");
38773
+ const dir = join93(cwd, ".assist");
38678
38774
  let entries;
38679
38775
  try {
38680
38776
  entries = readdirSync18(dir);
@@ -38682,14 +38778,14 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
38682
38778
  return;
38683
38779
  }
38684
38780
  for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
38685
- unlinkSync16(join92(dir, entry));
38781
+ unlinkSync16(join93(dir, entry));
38686
38782
  }
38687
38783
  }
38688
38784
 
38689
38785
  // src/commands/prs/listComments/updateCommentsCache.ts
38690
38786
  function writeCommentsCache(org, repo, prNumber, comments3) {
38691
38787
  const cachePath = commentsCachePath(org, repo, prNumber);
38692
- mkdirSync30(dirname42(cachePath), { recursive: true });
38788
+ mkdirSync31(dirname42(cachePath), { recursive: true });
38693
38789
  const cacheData = {
38694
38790
  prNumber,
38695
38791
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -38800,7 +38896,7 @@ function failAzureDevops(error) {
38800
38896
  import { execFileSync as execFileSync20 } from "child_process";
38801
38897
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync46 } from "fs";
38802
38898
  import { tmpdir as tmpdir7 } from "os";
38803
- import { join as join93 } from "path";
38899
+ import { join as join94 } from "path";
38804
38900
  function azDevopsInvokeArgs(request, inFile) {
38805
38901
  return [
38806
38902
  "devops",
@@ -38835,8 +38931,8 @@ function runAz2(args) {
38835
38931
  }
38836
38932
  function invokeAzDevops(request) {
38837
38933
  if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
38838
- const dir = mkdtempSync2(join93(tmpdir7(), "assist-az-"));
38839
- const inFile = join93(dir, "body.json");
38934
+ const dir = mkdtempSync2(join94(tmpdir7(), "assist-az-"));
38935
+ const inFile = join94(dir, "body.json");
38840
38936
  try {
38841
38937
  writeFileSync46(inFile, JSON.stringify(request.body));
38842
38938
  return runAz2(azDevopsInvokeArgs(request, inFile));
@@ -41968,9 +42064,9 @@ async function notify() {
41968
42064
 
41969
42065
  // src/commands/screenshot.ts
41970
42066
  import { execSync as execSync54 } from "child_process";
41971
- import { existsSync as existsSync74, mkdirSync as mkdirSync31, unlinkSync as unlinkSync17, writeFileSync as writeFileSync47 } from "fs";
42067
+ import { existsSync as existsSync75, mkdirSync as mkdirSync32, unlinkSync as unlinkSync17, writeFileSync as writeFileSync47 } from "fs";
41972
42068
  import { tmpdir as tmpdir8 } from "os";
41973
- import { join as join94, resolve as resolve28 } from "path";
42069
+ import { join as join95, resolve as resolve28 } from "path";
41974
42070
  import chalk236 from "chalk";
41975
42071
 
41976
42072
  // src/commands/screenshot/captureWindowPs1.ts
@@ -42100,14 +42196,14 @@ Write-Output $OutputPath
42100
42196
 
42101
42197
  // src/commands/screenshot.ts
42102
42198
  function buildOutputPath(outputDir, processName) {
42103
- if (!existsSync74(outputDir)) {
42104
- mkdirSync31(outputDir, { recursive: true });
42199
+ if (!existsSync75(outputDir)) {
42200
+ mkdirSync32(outputDir, { recursive: true });
42105
42201
  }
42106
42202
  const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
42107
42203
  return resolve28(outputDir, `${processName}-${timestamp9}.png`);
42108
42204
  }
42109
42205
  function runPowerShellScript(processName, outputPath) {
42110
- const scriptPath = join94(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
42206
+ const scriptPath = join95(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
42111
42207
  writeFileSync47(scriptPath, captureWindowPs1, "utf8");
42112
42208
  try {
42113
42209
  execSync54(
@@ -42209,9 +42305,9 @@ function buildLimitsSegment(rateLimits) {
42209
42305
 
42210
42306
  // src/commands/readGitBranch.ts
42211
42307
  import { readFileSync as readFileSync61, statSync as statSync12 } from "fs";
42212
- import { isAbsolute as isAbsolute7, join as join95, resolve as resolve29 } from "path";
42308
+ import { isAbsolute as isAbsolute7, join as join96, resolve as resolve29 } from "path";
42213
42309
  function resolveGitDir(cwd) {
42214
- const dotGit = join95(cwd, ".git");
42310
+ const dotGit = join96(cwd, ".git");
42215
42311
  let stat5;
42216
42312
  try {
42217
42313
  stat5 = statSync12(dotGit);
@@ -42241,7 +42337,7 @@ function readGitBranch(cwd) {
42241
42337
  }
42242
42338
  let head;
42243
42339
  try {
42244
- head = readFileSync61(join95(gitDir, "HEAD"), "utf8");
42340
+ head = readFileSync61(join96(gitDir, "HEAD"), "utf8");
42245
42341
  } catch {
42246
42342
  return null;
42247
42343
  }
@@ -45416,12 +45512,12 @@ function formatSlicingRequest(hunks) {
45416
45512
  }
45417
45513
 
45418
45514
  // src/commands/review/highLevel/highLevelReviewPath.ts
45419
- import { join as join96 } from "path";
45515
+ import { join as join97 } from "path";
45420
45516
  function slug(value) {
45421
45517
  return value.replace(/[^\w.-]+/g, "-");
45422
45518
  }
45423
45519
  function highLevelReviewPath(repo, headRef, headSha) {
45424
- return join96(
45520
+ return join97(
45425
45521
  getStoreDir(),
45426
45522
  "high-level-reviews",
45427
45523
  slug(repo),
@@ -45473,9 +45569,9 @@ function listHighLevelHunks(files) {
45473
45569
  }
45474
45570
 
45475
45571
  // src/commands/review/highLevel/readJsonFile.ts
45476
- import { existsSync as existsSync75, readFileSync as readFileSync62 } from "fs";
45572
+ import { existsSync as existsSync76, readFileSync as readFileSync62 } from "fs";
45477
45573
  function readJsonFile(path110) {
45478
- if (!existsSync75(path110)) return void 0;
45574
+ if (!existsSync76(path110)) return void 0;
45479
45575
  try {
45480
45576
  return JSON.parse(readFileSync62(path110, "utf8"));
45481
45577
  } catch {
@@ -45556,10 +45652,10 @@ function resolveHighLevelSlices(raw, hunks) {
45556
45652
  }
45557
45653
 
45558
45654
  // src/commands/review/highLevel/writeJsonFile.ts
45559
- import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync48 } from "fs";
45655
+ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
45560
45656
  import { dirname as dirname45 } from "path";
45561
45657
  function writeJsonFile(path110, data) {
45562
- mkdirSync32(dirname45(path110), { recursive: true });
45658
+ mkdirSync33(dirname45(path110), { recursive: true });
45563
45659
  writeFileSync48(path110, `${JSON.stringify(data, null, 2)}
45564
45660
  `);
45565
45661
  return path110;
@@ -46583,8 +46679,8 @@ function renderEntry(entry, frame) {
46583
46679
  import { format } from "util";
46584
46680
 
46585
46681
  // src/commands/review/createReviewLogSink.ts
46586
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync33 } from "fs";
46587
- import { join as join97 } from "path";
46682
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync34 } from "fs";
46683
+ import { join as join98 } from "path";
46588
46684
  var LOG_FILE = "review.log";
46589
46685
  function createReviewLogSink() {
46590
46686
  let logPath2;
@@ -46600,8 +46696,8 @@ function createReviewLogSink() {
46600
46696
  `);
46601
46697
  },
46602
46698
  attach(reviewDir) {
46603
- mkdirSync33(reviewDir, { recursive: true });
46604
- logPath2 = join97(reviewDir, LOG_FILE);
46699
+ mkdirSync34(reviewDir, { recursive: true });
46700
+ logPath2 = join98(reviewDir, LOG_FILE);
46605
46701
  const lines = [
46606
46702
  "",
46607
46703
  `=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
@@ -46940,7 +47036,7 @@ async function runReviewers(reviewers, context) {
46940
47036
  }
46941
47037
 
46942
47038
  // src/commands/review/synthesiseAfterReviewers.ts
46943
- import { existsSync as existsSync76, unlinkSync as unlinkSync18 } from "fs";
47039
+ import { existsSync as existsSync77, unlinkSync as unlinkSync18 } from "fs";
46944
47040
 
46945
47041
  // src/commands/review/synthesise.ts
46946
47042
  import { readFileSync as readFileSync64 } from "fs";
@@ -47174,7 +47270,7 @@ async function synthesise(paths, options2) {
47174
47270
  // src/commands/review/synthesiseAfterReviewers.ts
47175
47271
  async function synthesiseAfterReviewers(input) {
47176
47272
  const { paths, failures } = input;
47177
- if (input.anyFresh && existsSync76(paths.synthesisPath)) {
47273
+ if (input.anyFresh && existsSync77(paths.synthesisPath)) {
47178
47274
  unlinkSync18(paths.synthesisPath);
47179
47275
  }
47180
47276
  const synthesisResult = await synthesise(paths, { multi: input.multi });
@@ -47388,9 +47484,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
47388
47484
 
47389
47485
  // src/commands/review/buildReviewPaths.ts
47390
47486
  import { homedir as homedir27 } from "os";
47391
- import { basename as basename27, join as join98 } from "path";
47487
+ import { basename as basename27, join as join99 } from "path";
47392
47488
  function buildReviewPaths(repoRoot2, key) {
47393
- const reviewDir = join98(
47489
+ const reviewDir = join99(
47394
47490
  homedir27(),
47395
47491
  ".assist",
47396
47492
  "reviews",
@@ -47399,10 +47495,10 @@ function buildReviewPaths(repoRoot2, key) {
47399
47495
  );
47400
47496
  return {
47401
47497
  reviewDir,
47402
- requestPath: join98(reviewDir, "request.md"),
47403
- claudePath: join98(reviewDir, "claude.md"),
47404
- codexPath: join98(reviewDir, "codex.md"),
47405
- synthesisPath: join98(reviewDir, "synthesis.md")
47498
+ requestPath: join99(reviewDir, "request.md"),
47499
+ claudePath: join99(reviewDir, "claude.md"),
47500
+ codexPath: join99(reviewDir, "codex.md"),
47501
+ synthesisPath: join99(reviewDir, "synthesis.md")
47406
47502
  };
47407
47503
  }
47408
47504
 
@@ -47440,14 +47536,14 @@ function fetchExistingComments() {
47440
47536
  }
47441
47537
 
47442
47538
  // src/commands/review/prepareReviewDir.ts
47443
- import { existsSync as existsSync77, mkdirSync as mkdirSync34, unlinkSync as unlinkSync19, writeFileSync as writeFileSync49 } from "fs";
47539
+ import { existsSync as existsSync78, mkdirSync as mkdirSync35, unlinkSync as unlinkSync19, writeFileSync as writeFileSync49 } from "fs";
47444
47540
  function clearReviewFiles(paths) {
47445
47541
  for (const path110 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
47446
- if (existsSync77(path110)) unlinkSync19(path110);
47542
+ if (existsSync78(path110)) unlinkSync19(path110);
47447
47543
  }
47448
47544
  }
47449
47545
  function prepareReviewDir(paths, requestBody, force) {
47450
- mkdirSync34(paths.reviewDir, { recursive: true });
47546
+ mkdirSync35(paths.reviewDir, { recursive: true });
47451
47547
  if (force) clearReviewFiles(paths);
47452
47548
  writeFileSync49(paths.requestPath, requestBody);
47453
47549
  }
@@ -48345,7 +48441,7 @@ import path92 from "path";
48345
48441
  import chalk273 from "chalk";
48346
48442
 
48347
48443
  // src/commands/rules/updateScopedRulesIndex.ts
48348
- import { existsSync as existsSync78, readFileSync as readFileSync67, writeFileSync as writeFileSync50 } from "fs";
48444
+ import { existsSync as existsSync79, readFileSync as readFileSync67, writeFileSync as writeFileSync50 } from "fs";
48349
48445
  import path91 from "path";
48350
48446
 
48351
48447
  // src/commands/rules/scopedRuleDirectories.ts
@@ -48415,7 +48511,7 @@ function upsertScopedRulesPointer(content, directories) {
48415
48511
  function updateScopedRulesIndex(root2) {
48416
48512
  const directories = scopedRuleDirectories(root2);
48417
48513
  const rootFile = path91.join(root2, "CLAUDE.md");
48418
- const before = existsSync78(rootFile) ? readFileSync67(rootFile, "utf8") : "";
48514
+ const before = existsSync79(rootFile) ? readFileSync67(rootFile, "utf8") : "";
48419
48515
  const after = upsertScopedRulesPointer(before, directories);
48420
48516
  if (after !== before) writeFileSync50(rootFile, after);
48421
48517
  return directories;
@@ -48468,7 +48564,7 @@ function listRules(target, options2 = {}) {
48468
48564
  }
48469
48565
 
48470
48566
  // src/commands/rules/addRule.ts
48471
- import { existsSync as existsSync80, readFileSync as readFileSync69, writeFileSync as writeFileSync51 } from "fs";
48567
+ import { existsSync as existsSync81, readFileSync as readFileSync69, writeFileSync as writeFileSync51 } from "fs";
48472
48568
  import path95 from "path";
48473
48569
  import chalk275 from "chalk";
48474
48570
 
@@ -48505,7 +48601,7 @@ function nextRuleCode(root2) {
48505
48601
  }
48506
48602
 
48507
48603
  // src/commands/rules/resolveRuleScope.ts
48508
- import { existsSync as existsSync79 } from "fs";
48604
+ import { existsSync as existsSync80 } from "fs";
48509
48605
  import path94 from "path";
48510
48606
  function resolveRuleScope(target) {
48511
48607
  const resolved = path94.resolve(target);
@@ -48515,7 +48611,7 @@ function resolveRuleScope(target) {
48515
48611
  let current2 = startDir;
48516
48612
  while (true) {
48517
48613
  const candidate = path94.join(current2, "CLAUDE.md");
48518
- if (existsSync79(candidate)) return candidate;
48614
+ if (existsSync80(candidate)) return candidate;
48519
48615
  if (current2 === root2 || current2 === path94.dirname(current2)) break;
48520
48616
  current2 = path94.dirname(current2);
48521
48617
  }
@@ -48524,7 +48620,7 @@ function resolveRuleScope(target) {
48524
48620
 
48525
48621
  // src/commands/rules/addRule.ts
48526
48622
  function read3(file) {
48527
- return existsSync80(file) ? readFileSync69(file, "utf8") : "";
48623
+ return existsSync81(file) ? readFileSync69(file, "utf8") : "";
48528
48624
  }
48529
48625
  function addRule(text19, options2) {
48530
48626
  const rule = text19.trim();
@@ -49959,7 +50055,7 @@ function registerTestflight(program) {
49959
50055
  }
49960
50056
 
49961
50057
  // src/commands/transcript/clean.ts
49962
- import { existsSync as existsSync85 } from "fs";
50058
+ import { existsSync as existsSync86 } from "fs";
49963
50059
 
49964
50060
  // src/commands/transcript/convert/formatTimestamp.ts
49965
50061
  function pad2(value, width2) {
@@ -50237,7 +50333,7 @@ function clean(file, options2 = {}) {
50237
50333
  );
50238
50334
  process.exit(1);
50239
50335
  }
50240
- if (!existsSync85(file)) {
50336
+ if (!existsSync86(file)) {
50241
50337
  console.error(`Error: VTT file not found: ${file}`);
50242
50338
  process.exit(1);
50243
50339
  }
@@ -50320,21 +50416,21 @@ async function configure() {
50320
50416
  }
50321
50417
 
50322
50418
  // src/commands/transcript/list.ts
50323
- import { existsSync as existsSync86, readdirSync as readdirSync26, statSync as statSync14 } from "fs";
50324
- import { join as join110 } from "path";
50419
+ import { existsSync as existsSync87, readdirSync as readdirSync26, statSync as statSync14 } from "fs";
50420
+ import { join as join111 } from "path";
50325
50421
  function list5() {
50326
50422
  const { vttDir } = getTranscriptConfig();
50327
- if (!existsSync86(vttDir)) return;
50423
+ if (!existsSync87(vttDir)) return;
50328
50424
  for (const entry of readdirSync26(vttDir)) {
50329
50425
  if (!entry.endsWith(".vtt")) continue;
50330
- if (statSync14(join110(vttDir, entry)).isDirectory()) continue;
50426
+ if (statSync14(join111(vttDir, entry)).isDirectory()) continue;
50331
50427
  console.log(entry);
50332
50428
  }
50333
50429
  }
50334
50430
 
50335
50431
  // src/commands/transcript/move.ts
50336
- import { existsSync as existsSync87, mkdirSync as mkdirSync40, renameSync as renameSync5, writeFileSync as writeFileSync56 } from "fs";
50337
- import { basename as basename31, join as join111 } from "path";
50432
+ import { existsSync as existsSync88, mkdirSync as mkdirSync41, renameSync as renameSync5, writeFileSync as writeFileSync56 } from "fs";
50433
+ import { basename as basename31, join as join112 } from "path";
50338
50434
 
50339
50435
  // src/commands/transcript/convertVttToMarkdown.ts
50340
50436
  function convertVttToMarkdown(inputPath) {
@@ -50344,9 +50440,9 @@ function convertVttToMarkdown(inputPath) {
50344
50440
  // src/commands/transcript/move.ts
50345
50441
  var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
50346
50442
  function archiveRawVtt(vttDir, sourcePath, filename) {
50347
- const processedDir = join111(vttDir, "processed");
50348
- mkdirSync40(processedDir, { recursive: true });
50349
- renameSync5(sourcePath, join111(processedDir, filename));
50443
+ const processedDir = join112(vttDir, "processed");
50444
+ mkdirSync41(processedDir, { recursive: true });
50445
+ renameSync5(sourcePath, join112(processedDir, filename));
50350
50446
  }
50351
50447
  function move(file, options2) {
50352
50448
  const { date, client } = options2;
@@ -50356,25 +50452,25 @@ function move(file, options2) {
50356
50452
  }
50357
50453
  const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
50358
50454
  const filename = basename31(file);
50359
- const sourcePath = join111(vttDir, filename);
50360
- if (!existsSync87(sourcePath)) {
50455
+ const sourcePath = join112(vttDir, filename);
50456
+ if (!existsSync88(sourcePath)) {
50361
50457
  console.error(`Error: VTT file not found: ${sourcePath}`);
50362
50458
  process.exit(1);
50363
50459
  }
50364
50460
  const base = basename31(filename, ".vtt").replace(/ Transcription$/, "");
50365
50461
  const outputName = `${date} ${base}.md`;
50366
- const formattedDir = join111(transcriptsDir, client);
50367
- mkdirSync40(formattedDir, { recursive: true });
50368
- const formattedPath = join111(formattedDir, outputName);
50462
+ const formattedDir = join112(transcriptsDir, client);
50463
+ mkdirSync41(formattedDir, { recursive: true });
50464
+ const formattedPath = join112(formattedDir, outputName);
50369
50465
  writeFileSync56(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
50370
50466
  archiveRawVtt(vttDir, sourcePath, filename);
50371
- const summaryPath = join111(summaryDir, client, outputName);
50467
+ const summaryPath = join112(summaryDir, client, outputName);
50372
50468
  console.log(`Formatted transcript: ${formattedPath}`);
50373
50469
  console.log(`Summary target: ${summaryPath}`);
50374
50470
  }
50375
50471
 
50376
50472
  // src/commands/transcript/merge.ts
50377
- import { existsSync as existsSync88, writeFileSync as writeFileSync57 } from "fs";
50473
+ import { existsSync as existsSync89, writeFileSync as writeFileSync57 } from "fs";
50378
50474
  import { basename as basename32 } from "path";
50379
50475
 
50380
50476
  // src/commands/transcript/failTranscript.ts
@@ -50518,7 +50614,7 @@ function widenAudience(passages) {
50518
50614
 
50519
50615
  // src/commands/transcript/merge.ts
50520
50616
  function readSource3(file) {
50521
- if (!existsSync88(file)) failTranscript(`VTT file not found: ${file}`);
50617
+ if (!existsSync89(file)) failTranscript(`VTT file not found: ${file}`);
50522
50618
  const cues = readCleanedCues(file);
50523
50619
  if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
50524
50620
  return { path: file, name: basename32(file), cues };
@@ -50991,7 +51087,7 @@ function configKeys2() {
50991
51087
  }
50992
51088
 
50993
51089
  // src/commands/verify/forbiddenStrings.ts
50994
- import { existsSync as existsSync89, readFileSync as readFileSync76 } from "fs";
51090
+ import { existsSync as existsSync90, readFileSync as readFileSync76 } from "fs";
50995
51091
 
50996
51092
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
50997
51093
  import { minimatch as minimatch10 } from "minimatch";
@@ -51032,7 +51128,7 @@ function forbiddenStrings() {
51032
51128
  const cache7 = /* @__PURE__ */ new Map();
51033
51129
  const readJson = (file) => {
51034
51130
  if (cache7.has(file)) return cache7.get(file);
51035
- if (!existsSync89(file)) {
51131
+ if (!existsSync90(file)) {
51036
51132
  console.log(`Forbidden-strings file not found: ${file}`);
51037
51133
  process.exit(1);
51038
51134
  }
@@ -51463,7 +51559,7 @@ function clearBuildPending() {
51463
51559
  }
51464
51560
 
51465
51561
  // src/commands/watch/isSyncPending.ts
51466
- import { existsSync as existsSync90 } from "fs";
51562
+ import { existsSync as existsSync91 } from "fs";
51467
51563
 
51468
51564
  // src/commands/watch/syncPendingPath.ts
51469
51565
  function syncPendingPath(cwd) {
@@ -51473,7 +51569,7 @@ function syncPendingPath(cwd) {
51473
51569
  // src/commands/watch/isSyncPending.ts
51474
51570
  function isSyncPending() {
51475
51571
  try {
51476
- return existsSync90(syncPendingPath());
51572
+ return existsSync91(syncPendingPath());
51477
51573
  } catch {
51478
51574
  return false;
51479
51575
  }
@@ -51600,7 +51696,7 @@ function resolveParams(params, cliArgs) {
51600
51696
  }
51601
51697
 
51602
51698
  // src/commands/run/resolveRunCwd.ts
51603
- import { existsSync as existsSync91 } from "fs";
51699
+ import { existsSync as existsSync92 } from "fs";
51604
51700
  import { resolve as resolve31 } from "path";
51605
51701
  var MissingRunCwdError = class extends Error {
51606
51702
  constructor(runName, cwd) {
@@ -51615,7 +51711,7 @@ var MissingRunCwdError = class extends Error {
51615
51711
  function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
51616
51712
  if (!config.cwd) return void 0;
51617
51713
  const cwd = resolve31(baseDir, config.cwd);
51618
- if (!existsSync91(cwd)) throw new MissingRunCwdError(config.name, cwd);
51714
+ if (!existsSync92(cwd)) throw new MissingRunCwdError(config.name, cwd);
51619
51715
  return cwd;
51620
51716
  }
51621
51717
 
@@ -51950,10 +52046,10 @@ ${buildWatchReport(from)}`);
51950
52046
  }
51951
52047
 
51952
52048
  // src/commands/watch/consumeMarker.ts
51953
- import { existsSync as existsSync92, rmSync as rmSync14 } from "fs";
52049
+ import { existsSync as existsSync93, rmSync as rmSync14 } from "fs";
51954
52050
  function consumeMarker(path110) {
51955
52051
  try {
51956
- if (!existsSync92(path110)) return false;
52052
+ if (!existsSync93(path110)) return false;
51957
52053
  rmSync14(path110);
51958
52054
  return true;
51959
52055
  } catch {
@@ -52251,7 +52347,7 @@ function registerWatch(program) {
52251
52347
  // src/commands/roam/postRoamActivity.ts
52252
52348
  import { execFileSync as execFileSync31 } from "child_process";
52253
52349
  import { readdirSync as readdirSync28, readFileSync as readFileSync78, statSync as statSync15 } from "fs";
52254
- import { join as join112 } from "path";
52350
+ import { join as join113 } from "path";
52255
52351
  function findPortFile(roamDir) {
52256
52352
  let entries;
52257
52353
  try {
@@ -52260,7 +52356,7 @@ function findPortFile(roamDir) {
52260
52356
  return void 0;
52261
52357
  }
52262
52358
  const candidates = entries.filter((name2) => /^roam-local-api(-[^.]+)?\.port$/.test(name2)).map((name2) => {
52263
- const path110 = join112(roamDir, name2);
52359
+ const path110 = join113(roamDir, name2);
52264
52360
  try {
52265
52361
  return { path: path110, mtimeMs: statSync15(path110).mtimeMs };
52266
52362
  } catch {
@@ -52277,7 +52373,7 @@ var PID_BY_APP = {
52277
52373
  function postRoamActivity(app, event) {
52278
52374
  const appData = process.env.APPDATA;
52279
52375
  if (!appData) return;
52280
- const portFile = findPortFile(join112(appData, "Roam"));
52376
+ const portFile = findPortFile(join113(appData, "Roam"));
52281
52377
  if (!portFile) return;
52282
52378
  let port;
52283
52379
  try {
@@ -52460,7 +52556,7 @@ function link2() {
52460
52556
  }
52461
52557
 
52462
52558
  // src/commands/run/add.ts
52463
- import { mkdirSync as mkdirSync41, writeFileSync as writeFileSync61 } from "fs";
52559
+ import { mkdirSync as mkdirSync42, writeFileSync as writeFileSync61 } from "fs";
52464
52560
  import { dirname as dirname49 } from "path";
52465
52561
 
52466
52562
  // src/commands/run/editRepoRunList.ts
@@ -52636,11 +52732,11 @@ function requireParsedArgs() {
52636
52732
  }
52637
52733
 
52638
52734
  // src/commands/run/runCommandFilePath.ts
52639
- import { join as join113 } from "path";
52735
+ import { join as join114 } from "path";
52640
52736
  function runCommandFilePath(name2) {
52641
52737
  const segments = name2.split(":");
52642
52738
  const file = `${segments.pop()}.md`;
52643
- return join113(".claude", "commands", ...segments, file);
52739
+ return join114(".claude", "commands", ...segments, file);
52644
52740
  }
52645
52741
 
52646
52742
  // src/commands/run/add.ts
@@ -52657,7 +52753,7 @@ function saveProjectRunConfig(entry) {
52657
52753
  }
52658
52754
  function createCommandFile(name2) {
52659
52755
  const filePath = runCommandFilePath(name2);
52660
- mkdirSync41(dirname49(filePath), { recursive: true });
52756
+ mkdirSync42(dirname49(filePath), { recursive: true });
52661
52757
  const content = `---
52662
52758
  description: Run ${name2}
52663
52759
  ---
@@ -52784,8 +52880,8 @@ function registerRunAdd(runCommand) {
52784
52880
  }
52785
52881
 
52786
52882
  // src/commands/run/remove.ts
52787
- import { existsSync as existsSync93, readdirSync as readdirSync29, rmdirSync, unlinkSync as unlinkSync20 } from "fs";
52788
- import { dirname as dirname50, join as join114 } from "path";
52883
+ import { existsSync as existsSync94, readdirSync as readdirSync29, rmdirSync, unlinkSync as unlinkSync20 } from "fs";
52884
+ import { dirname as dirname50, join as join115 } from "path";
52789
52885
 
52790
52886
  // src/commands/run/removeRepoRunConfig.ts
52791
52887
  function isNamed(entry, name2) {
@@ -52803,17 +52899,17 @@ function removeRepoRunConfig(name2, repoName, cwd = process.cwd()) {
52803
52899
 
52804
52900
  // src/commands/run/remove.ts
52805
52901
  function removeEmptyNamespaceDirs(filePath) {
52806
- const root2 = join114(".claude", "commands");
52902
+ const root2 = join115(".claude", "commands");
52807
52903
  for (let dir = dirname50(filePath); dir !== root2; dir = dirname50(dir)) {
52808
- if (!existsSync93(dir) || readdirSync29(dir).length > 0) return;
52904
+ if (!existsSync94(dir) || readdirSync29(dir).length > 0) return;
52809
52905
  rmdirSync(dir);
52810
52906
  }
52811
52907
  }
52812
52908
  function deleteCommandFile(name2) {
52813
52909
  const filePath = runCommandFilePath(name2);
52814
- const legacyPath = join114(".claude", "commands", `${name2}.md`);
52910
+ const legacyPath = join115(".claude", "commands", `${name2}.md`);
52815
52911
  for (const path110 of /* @__PURE__ */ new Set([filePath, legacyPath])) {
52816
- if (existsSync93(path110)) {
52912
+ if (existsSync94(path110)) {
52817
52913
  unlinkSync20(path110);
52818
52914
  console.log(`Deleted command file: ${path110}`);
52819
52915
  }
@@ -53551,12 +53647,12 @@ function toSessionViewInfo({
53551
53647
  }
53552
53648
 
53553
53649
  // src/commands/sessions/daemon/worktree/joinRefusal.ts
53554
- import { existsSync as existsSync94 } from "fs";
53650
+ import { existsSync as existsSync95 } from "fs";
53555
53651
  function joinRefusal(session) {
53556
53652
  if (session.commandType === "run") return "a server run has no agent stream";
53557
53653
  if (session.closing === true) return "the session is closing";
53558
53654
  if (!session.cwd) return "the session has no working directory";
53559
- if (!existsSync94(session.cwd))
53655
+ if (!existsSync95(session.cwd))
53560
53656
  return "the session's workspace no longer exists";
53561
53657
  return void 0;
53562
53658
  }
@@ -53646,8 +53742,8 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
53646
53742
  }
53647
53743
 
53648
53744
  // src/commands/sessions/daemon/findServerParents.ts
53649
- import { existsSync as existsSync95 } from "fs";
53650
- import { join as join115, resolve as resolve32 } from "path";
53745
+ import { existsSync as existsSync96 } from "fs";
53746
+ import { join as join116, resolve as resolve32 } from "path";
53651
53747
  function isLive(session) {
53652
53748
  return !!session.pty && session.status !== "done" && session.status !== "error";
53653
53749
  }
@@ -53656,7 +53752,7 @@ function isLiveAgent(session) {
53656
53752
  }
53657
53753
  function serverRunDirs(sessions, file) {
53658
53754
  return new Set(
53659
- sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) => existsSync95(join115(dir, file)))
53755
+ sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) => existsSync96(join116(dir, file)))
53660
53756
  );
53661
53757
  }
53662
53758
  function findServerParents(sessions, file) {
@@ -54386,7 +54482,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
54386
54482
  }
54387
54483
 
54388
54484
  // src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
54389
- import { existsSync as existsSync96, rmSync as rmSync15, writeFileSync as writeFileSync62 } from "fs";
54485
+ import { existsSync as existsSync97, rmSync as rmSync15, writeFileSync as writeFileSync62 } from "fs";
54390
54486
  var paused;
54391
54487
  var wake;
54392
54488
  var holdReleased = false;
@@ -54399,7 +54495,7 @@ function persist2(value) {
54399
54495
  }
54400
54496
  var autoUpdateControl = {
54401
54497
  paused: () => {
54402
- paused ??= existsSync96(daemonPaths.autoUpdatePaused);
54498
+ paused ??= existsSync97(daemonPaths.autoUpdatePaused);
54403
54499
  return paused;
54404
54500
  },
54405
54501
  setPaused: (value) => {
@@ -54498,7 +54594,17 @@ var DIVERGED_EXIT_CODE = 3;
54498
54594
  async function settleLap(lap, { end, tail }, deps2) {
54499
54595
  const how = end.signal ? `killed by ${end.signal}` : `exited ${end.code}`;
54500
54596
  if (end.code === DIVERGED_EXIT_CODE) {
54501
- const held = deps2.escalate(tail);
54597
+ let held;
54598
+ try {
54599
+ held = deps2.escalate(tail);
54600
+ } catch (error) {
54601
+ const reason4 = error instanceof Error ? error.message : String(error);
54602
+ await backOff(
54603
+ `lap ${lap} ${how} (divergence); escalation refused: ${reason4.replaceAll("\n", " ")}`,
54604
+ deps2
54605
+ );
54606
+ return void 0;
54607
+ }
54502
54608
  deps2.note(`lap ${lap} ${how} (divergence); escalated to session ${held}`);
54503
54609
  return held;
54504
54610
  }
@@ -54556,12 +54662,12 @@ function trimWatcherLog(cwd) {
54556
54662
  }
54557
54663
 
54558
54664
  // src/commands/sessions/daemon/worktree/appendWatcherLog.ts
54559
- import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync42 } from "fs";
54665
+ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync43 } from "fs";
54560
54666
  import { dirname as dirname51 } from "path";
54561
54667
  function appendWatcherLog(cwd, data) {
54562
54668
  try {
54563
54669
  const path110 = watcherLogPath(cwd);
54564
- mkdirSync42(dirname51(path110), { recursive: true });
54670
+ mkdirSync43(dirname51(path110), { recursive: true });
54565
54671
  appendFileSync4(path110, data);
54566
54672
  } catch {
54567
54673
  }
@@ -54576,6 +54682,21 @@ function detectExistingWorktree(cwd) {
54576
54682
  return void 0;
54577
54683
  }
54578
54684
 
54685
+ // src/commands/sessions/daemon/worktree/noteWorktreeHarness.ts
54686
+ function noteWorktreeHarness(session) {
54687
+ const path110 = session.worktree?.path;
54688
+ if (!path110) return;
54689
+ const harness = session.commandType === "claude" ? resolveHarness(session.harness) : session.harness;
54690
+ if (!harness) return;
54691
+ try {
54692
+ recordWorktreeHarness(path110, harness);
54693
+ } catch (error) {
54694
+ daemonLog(
54695
+ `worktree ${path110} harness ${harness} not recorded for session ${session.id}: ${error instanceof Error ? error.message : String(error)}`
54696
+ );
54697
+ }
54698
+ }
54699
+
54579
54700
  // src/commands/sessions/daemon/worktree/refuseUnallocatedStart.ts
54580
54701
  function refuseUnallocatedStart(session, path110, error, startHeld) {
54581
54702
  const reason4 = error instanceof Error ? error.message : String(error);
@@ -54594,6 +54715,7 @@ function bindNewWorktree(session, alloc, notify2, startHeld = () => {
54594
54715
  if (alloc.kind !== "worktree" || !alloc.cwd || !alloc.clone || !session)
54595
54716
  return;
54596
54717
  session.worktree = { path: alloc.cwd, clone: alloc.clone };
54718
+ noteWorktreeHarness(session);
54597
54719
  if (alloc.created) {
54598
54720
  session.awaitingSeed = true;
54599
54721
  const { cwd, clone } = alloc;
@@ -54634,13 +54756,13 @@ function bindResumedWorktree(session, cwd, notify2) {
54634
54756
  }
54635
54757
 
54636
54758
  // src/commands/sessions/daemon/worktree/treeDurability.ts
54637
- import { existsSync as existsSync98 } from "fs";
54759
+ import { existsSync as existsSync99 } from "fs";
54638
54760
 
54639
54761
  // src/commands/sessions/daemon/worktree/holdsNoCheckout.ts
54640
- import { existsSync as existsSync97 } from "fs";
54641
- import { join as join116 } from "path";
54762
+ import { existsSync as existsSync98 } from "fs";
54763
+ import { join as join117 } from "path";
54642
54764
  function holdsNoCheckout(path110) {
54643
- return existsSync97(path110) && !existsSync97(join116(path110, ".git"));
54765
+ return existsSync98(path110) && !existsSync98(join117(path110, ".git"));
54644
54766
  }
54645
54767
 
54646
54768
  // src/commands/sessions/daemon/worktree/treeDurability.ts
@@ -54678,14 +54800,14 @@ function notACheckout(cwd, error) {
54678
54800
  return holdsNoCheckout(cwd) && /not a git repository/i.test(error);
54679
54801
  }
54680
54802
  async function checkDurability(cwd) {
54681
- if (!existsSync98(cwd)) return treeIsGone;
54803
+ if (!existsSync99(cwd)) return treeIsGone;
54682
54804
  const probes = durabilityProbes(cwd);
54683
54805
  let step3 = probes.next();
54684
54806
  while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
54685
54807
  return step3.value;
54686
54808
  }
54687
54809
  function checkDurabilitySync(cwd) {
54688
- if (!existsSync98(cwd)) return treeIsGone;
54810
+ if (!existsSync99(cwd)) return treeIsGone;
54689
54811
  const probes = durabilityProbes(cwd);
54690
54812
  let step3 = probes.next();
54691
54813
  while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
@@ -54790,18 +54912,27 @@ function escalateDivergence(ctx, cwd, output) {
54790
54912
  );
54791
54913
  return live.id;
54792
54914
  }
54915
+ const harness = loadConfigFrom(clone).harness.engine;
54916
+ const adapter = harnessAdapter(harness);
54917
+ const blocker = launchBlocker(adapter, divergenceEscalationFeature);
54918
+ if (blocker) {
54919
+ daemonLog(
54920
+ `auto-update diverged in the clone ${clone}: no escalation spawned, ${blocker.replaceAll("\n", " ")}`
54921
+ );
54922
+ throw new Error(blocker);
54923
+ }
54793
54924
  const prompt = divergencePrompt(clone, output);
54794
54925
  const id = allocateAndBind(
54795
54926
  ctx,
54796
54927
  clone,
54797
54928
  (sid, resolvedCwd) => ({
54798
- ...createSession(sid, { prompt, cwd: resolvedCwd ?? clone }),
54929
+ ...createSession(sid, { prompt, cwd: resolvedCwd ?? clone, harness }),
54799
54930
  divergenceEscalation: true
54800
54931
  }),
54801
54932
  { inPlace: true }
54802
54933
  );
54803
54934
  daemonLog(
54804
- `auto-update diverged in the clone ${clone}: spawned escalation session ${id} to diagnose it`
54935
+ `auto-update diverged in the clone ${clone}: spawned ${adapter.label} escalation session ${id} to diagnose it`
54805
54936
  );
54806
54937
  return id;
54807
54938
  }
@@ -54969,17 +55100,17 @@ function setStatus2(session, newStatus) {
54969
55100
  }
54970
55101
 
54971
55102
  // src/commands/sessions/daemon/worktree/reapWorktree.ts
54972
- import { existsSync as existsSync100 } from "fs";
55103
+ import { existsSync as existsSync101 } from "fs";
54973
55104
  import { basename as basename34 } from "path";
54974
55105
 
54975
55106
  // src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
54976
- import { existsSync as existsSync99 } from "fs";
54977
- import { join as join118 } from "path";
55107
+ import { existsSync as existsSync100 } from "fs";
55108
+ import { join as join119 } from "path";
54978
55109
 
54979
55110
  // src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
54980
55111
  import { statSync as statSync16 } from "fs";
54981
55112
  import { rm as rm3 } from "fs/promises";
54982
- import { join as join117 } from "path";
55113
+ import { join as join118 } from "path";
54983
55114
  async function deleteTreeDirectly(clone, worktreePath, why) {
54984
55115
  if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
54985
55116
  const refusal = "it is a clone of its own, not a linked worktree";
@@ -55008,7 +55139,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
55008
55139
  return { removed: true };
55009
55140
  }
55010
55141
  function holdsAGitDirectoryRatherThanALink(worktreePath) {
55011
- return statSync16(join117(worktreePath, ".git"), {
55142
+ return statSync16(join118(worktreePath, ".git"), {
55012
55143
  throwIfNoEntry: false
55013
55144
  })?.isDirectory() === true;
55014
55145
  }
@@ -55049,7 +55180,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
55049
55180
  );
55050
55181
  }
55051
55182
  function strandedReason(worktreePath, cause) {
55052
- if (!existsSync99(join118(worktreePath, ".git")))
55183
+ if (!existsSync100(join119(worktreePath, ".git")))
55053
55184
  return "its .git link is already gone";
55054
55185
  if (/not a working tree|not a git repository/i.test(reason2(cause)))
55055
55186
  return "git no longer recognises it as a working tree";
@@ -55101,7 +55232,7 @@ function reason3(error) {
55101
55232
 
55102
55233
  // src/commands/sessions/daemon/worktree/reapWorktree.ts
55103
55234
  async function reapWorktree(worktreePath, force = false) {
55104
- if (!existsSync100(worktreePath)) {
55235
+ if (!existsSync101(worktreePath)) {
55105
55236
  forgetWorktree(worktreePath);
55106
55237
  daemonLog(
55107
55238
  `worktree ${worktreePath} already gone; its record was forgotten`
@@ -55126,7 +55257,7 @@ async function reapWorktree(worktreePath, force = false) {
55126
55257
  }
55127
55258
  function owningClone(worktreePath) {
55128
55259
  const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
55129
- if (recorded && existsSync100(recorded)) return recorded;
55260
+ if (recorded && existsSync101(recorded)) return recorded;
55130
55261
  const detected = mainWorktree(worktreePath);
55131
55262
  if (detected) return detected;
55132
55263
  daemonLog(
@@ -55443,12 +55574,12 @@ async function closeBlockReason(sessionId2, tree) {
55443
55574
  }
55444
55575
 
55445
55576
  // src/commands/sessions/daemon/worktree/watchGitState.ts
55446
- import { existsSync as existsSync101, watch } from "fs";
55577
+ import { existsSync as existsSync102, watch } from "fs";
55447
55578
  var DEBOUNCE_MS = 500;
55448
55579
  var POLL_MS5 = 3e4;
55449
55580
  function watchGitState(cwd, onChange) {
55450
55581
  const common = gitCommonDir(cwd);
55451
- if (!common || !existsSync101(common)) return void 0;
55582
+ if (!common || !existsSync102(common)) return void 0;
55452
55583
  const watchers = [
55453
55584
  watchGitDir(common, onChange),
55454
55585
  pollGitState(cwd, onChange)
@@ -56189,10 +56320,10 @@ function emitSessionOutput(session, clients, data) {
56189
56320
  }
56190
56321
 
56191
56322
  // src/commands/sessions/daemon/exitReason.ts
56192
- import { existsSync as existsSync102 } from "fs";
56323
+ import { existsSync as existsSync103 } from "fs";
56193
56324
  import { resolve as resolve34 } from "path";
56194
56325
  function exitDetail(session) {
56195
- if (session.cwd && !existsSync102(session.cwd))
56326
+ if (session.cwd && !existsSync103(session.cwd))
56196
56327
  return `working directory ${session.cwd} no longer exists`;
56197
56328
  return missingRunConfigCwd(session);
56198
56329
  }
@@ -56206,7 +56337,7 @@ function missingRunConfigCwd(session) {
56206
56337
  const config = resolveRunConfig(session.runName, dir);
56207
56338
  if (!config?.cwd) return void 0;
56208
56339
  const configured = resolve34(runConfigBaseDirFrom(dir), config.cwd);
56209
- if (existsSync102(configured)) return void 0;
56340
+ if (existsSync103(configured)) return void 0;
56210
56341
  return `run config "${config.name}": cwd ${configured} does not exist`;
56211
56342
  }
56212
56343
 
@@ -56254,17 +56385,36 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
56254
56385
  }
56255
56386
 
56256
56387
  // src/commands/sessions/daemon/watchActivity.ts
56257
- import { existsSync as existsSync103, mkdirSync as mkdirSync43, watch as watch2 } from "fs";
56388
+ import { existsSync as existsSync104, mkdirSync as mkdirSync44, watch as watch2 } from "fs";
56258
56389
  import { dirname as dirname52 } from "path";
56259
56390
 
56260
56391
  // src/commands/sessions/daemon/applyActivityToSession.ts
56261
56392
  function applyActivityToSession(session, activity2) {
56262
56393
  session.activity = activity2;
56263
- if (activity2.harness) session.harness = activity2.harness;
56394
+ if (activity2.harness && activity2.harness !== session.harness) {
56395
+ session.harness = activity2.harness;
56396
+ noteWorktreeHarness(session);
56397
+ }
56264
56398
  if (activity2.claudeSessionId)
56265
56399
  session.claudeSessionId = activity2.claudeSessionId;
56266
56400
  }
56267
56401
 
56402
+ // src/commands/sessions/daemon/claimedByOthers.ts
56403
+ var boundBy = /* @__PURE__ */ new Map();
56404
+ function claimedByOthers(session) {
56405
+ const claimed = /* @__PURE__ */ new Set();
56406
+ for (const [conversationId, owner] of boundBy) {
56407
+ if (owner.harnessSessionId !== conversationId)
56408
+ boundBy.delete(conversationId);
56409
+ else if (owner !== session) claimed.add(conversationId);
56410
+ }
56411
+ return claimed;
56412
+ }
56413
+ function claimConversation(session, conversationId) {
56414
+ session.harnessSessionId = conversationId;
56415
+ boundBy.set(conversationId, session);
56416
+ }
56417
+
56268
56418
  // src/commands/sessions/daemon/recordBoundPhaseSession.ts
56269
56419
  import os6 from "os";
56270
56420
  async function recordBoundPhaseSession(session, conversationId) {
@@ -56290,6 +56440,19 @@ async function recordBoundPhaseSession(session, conversationId) {
56290
56440
  }
56291
56441
  }
56292
56442
 
56443
+ // src/commands/sessions/daemon/completeBinding.ts
56444
+ function completeBinding(session, bound, notify2, onBound) {
56445
+ const { conversationId, harnessLabel: harnessLabel2 } = bound;
56446
+ claimConversation(session, conversationId);
56447
+ daemonLog(
56448
+ `session ${session.id} bound to ${harnessLabel2} conversation ${conversationId}`
56449
+ );
56450
+ rememberSessionTitle(session);
56451
+ void recordBoundPhaseSession(session, conversationId);
56452
+ onBound?.(session);
56453
+ notify2();
56454
+ }
56455
+
56293
56456
  // src/commands/sessions/daemon/bindConversation.ts
56294
56457
  var POLL_MS6 = 1e3;
56295
56458
  var MAX_ATTEMPTS3 = 120;
@@ -56303,29 +56466,26 @@ function bindConversation(session, notify2, launchedAt = session.startedAt, onBo
56303
56466
  const bind = (latestBind.get(session) ?? 0) + 1;
56304
56467
  latestBind.set(session, bind);
56305
56468
  const superseded = () => !!adapter.conversation.boundId(session) || latestBind.get(session) !== bind;
56306
- const since = launchedAt - START_SLACK_MS;
56469
+ const sinceMs = launchedAt - START_SLACK_MS;
56307
56470
  let attemptsLeft = MAX_ATTEMPTS3;
56308
56471
  const schedule = () => setTimeout(() => void poll(), POLL_MS6).unref();
56309
56472
  const poll = async () => {
56310
56473
  if (superseded()) return;
56311
- const conversationId = await discover(cwd, since);
56474
+ const conversationId = await discover({
56475
+ cwd,
56476
+ launchedAt,
56477
+ sinceMs,
56478
+ claimed: claimedByOthers(session)
56479
+ });
56312
56480
  if (superseded()) return;
56313
- if (!conversationId) {
56314
- if (--attemptsLeft > 0) schedule();
56315
- else
56316
- daemonLog(
56317
- `session ${session.id} found no ${adapter.label} conversation to bind`
56318
- );
56319
- return;
56320
- }
56321
- session.harnessSessionId = conversationId;
56322
- daemonLog(
56323
- `session ${session.id} bound to ${adapter.label} conversation ${conversationId}`
56324
- );
56325
- rememberSessionTitle(session);
56326
- void recordBoundPhaseSession(session, conversationId);
56327
- onBound?.(session);
56328
- notify2();
56481
+ if (conversationId && !claimedByOthers(session).has(conversationId)) {
56482
+ const bound = { conversationId, harnessLabel: adapter.label };
56483
+ completeBinding(session, bound, notify2, onBound);
56484
+ } else if (--attemptsLeft > 0) schedule();
56485
+ else
56486
+ daemonLog(
56487
+ `session ${session.id} found no ${adapter.label} conversation to bind`
56488
+ );
56329
56489
  };
56330
56490
  schedule();
56331
56491
  }
@@ -56412,7 +56572,7 @@ function watchActivity(session, notify2, onConversation) {
56412
56572
  const path110 = activityPath(session.id);
56413
56573
  const dir = dirname52(path110);
56414
56574
  try {
56415
- mkdirSync43(dir, { recursive: true });
56575
+ mkdirSync44(dir, { recursive: true });
56416
56576
  } catch {
56417
56577
  return;
56418
56578
  }
@@ -56433,7 +56593,7 @@ function watchActivity(session, notify2, onConversation) {
56433
56593
  if (timer) clearTimeout(timer);
56434
56594
  timer = setTimeout(read4, DEBOUNCE_MS2);
56435
56595
  });
56436
- if (existsSync103(path110)) read4();
56596
+ if (existsSync104(path110)) read4();
56437
56597
  }
56438
56598
  function refreshActivity(session) {
56439
56599
  if (session.commandType !== "assist" || !session.cwd) return;
@@ -56516,10 +56676,10 @@ function reportSilentFailure(session, clients) {
56516
56676
  import { watch as watch3 } from "fs";
56517
56677
 
56518
56678
  // src/commands/sessions/daemon/ensureProjectDirExists.ts
56519
- import { mkdirSync as mkdirSync44 } from "fs";
56679
+ import { mkdirSync as mkdirSync45 } from "fs";
56520
56680
  function ensureProjectDirExists(dir, sessionId2) {
56521
56681
  try {
56522
- mkdirSync44(dir, { recursive: true });
56682
+ mkdirSync45(dir, { recursive: true });
56523
56683
  return true;
56524
56684
  } catch (error) {
56525
56685
  daemonLog(
@@ -57497,39 +57657,17 @@ function conversationResumeOutcome(session) {
57497
57657
  };
57498
57658
  }
57499
57659
 
57500
- // src/shared/harnessResumesConversation.ts
57501
- function harnessResumesConversation(harness) {
57502
- return harnessCapability(harness, "conversation.resume").supported;
57503
- }
57504
-
57505
- // src/commands/sessions/daemon/codexRespawnPlan.ts
57506
- function codexRespawnPlan(session) {
57507
- const { harnessSessionId, cwd, initialPrompt } = session;
57508
- if (harnessSessionId)
57509
- return {
57510
- spawn: () => spawnCodex({
57511
- resumeSessionId: harnessSessionId,
57512
- cwd,
57513
- sessionId: session.id
57514
- }),
57515
- status: "waiting"
57516
- };
57517
- if (!cwd && !initialPrompt) return null;
57518
- return {
57519
- spawn: () => spawnCodex({ prompt: initialPrompt, cwd, sessionId: session.id }),
57520
- status: initialPrompt ? "running" : "waiting"
57521
- };
57522
- }
57523
-
57524
57660
  // src/commands/sessions/daemon/interactiveRespawnPlan.ts
57525
- import { randomUUID as randomUUID25 } from "crypto";
57526
- function interactiveRespawnPlan(session, resumes) {
57527
- const { claudeSessionId, cwd, initialPrompt, design, auto } = session;
57528
- if (!resumes) return null;
57529
- if (claudeSessionId && hasTranscriptOnDisk(session))
57661
+ function interactiveRespawnPlan(session) {
57662
+ const adapter = harnessAdapter(session.harness);
57663
+ if (!resolveCapability(adapter.capabilities, "conversation.resume").supported)
57664
+ return null;
57665
+ const { cwd, initialPrompt, design, auto } = session;
57666
+ const resumeId = adapter.conversation.findResumable(session);
57667
+ if (resumeId)
57530
57668
  return {
57531
- spawn: () => spawnClaude({
57532
- resumeSessionId: claudeSessionId,
57669
+ spawn: () => adapter.interactive({
57670
+ resumeId,
57533
57671
  cwd,
57534
57672
  sessionId: session.id,
57535
57673
  design,
@@ -57537,21 +57675,22 @@ function interactiveRespawnPlan(session, resumes) {
57537
57675
  }),
57538
57676
  status: "waiting"
57539
57677
  };
57540
- if (initialPrompt) return freshClaudePlan(session, initialPrompt, cwd);
57541
- if (cwd) return freshClaudePlan(session, void 0, cwd);
57542
- return null;
57678
+ if (!initialPrompt && !cwd) return null;
57679
+ return freshPlan(session, adapter, initialPrompt);
57543
57680
  }
57544
- function freshClaudePlan(session, prompt, cwd) {
57545
- const claudeSessionId = randomUUID25();
57681
+ function freshPlan(session, adapter, prompt) {
57682
+ const conversationId = preassignedId(adapter);
57546
57683
  return {
57547
57684
  spawn: () => {
57548
- session.claudeSessionId = claudeSessionId;
57685
+ session.claudeSessionId = void 0;
57686
+ session.harnessSessionId = void 0;
57687
+ Object.assign(session, adapter.activityIdentity(conversationId));
57549
57688
  rememberSessionTitle(session);
57550
- return spawnClaude({
57689
+ return adapter.interactive({
57551
57690
  prompt,
57552
- cwd,
57691
+ cwd: session.cwd,
57553
57692
  sessionId: session.id,
57554
- claudeSessionId,
57693
+ conversationId,
57555
57694
  design: session.design,
57556
57695
  auto: session.auto
57557
57696
  });
@@ -57560,20 +57699,10 @@ function freshClaudePlan(session, prompt, cwd) {
57560
57699
  };
57561
57700
  }
57562
57701
 
57563
- // src/commands/sessions/daemon/interactiveHarnessRespawn.ts
57564
- function interactiveHarnessRespawn(session) {
57565
- if (resolveHarness(session.harness) === "codex")
57566
- return codexRespawnPlan(session);
57567
- return interactiveRespawnPlan(
57568
- session,
57569
- harnessResumesConversation(session.harness)
57570
- );
57571
- }
57572
-
57573
57702
  // src/commands/sessions/daemon/respawnPlan.ts
57574
57703
  function respawnPlan(session) {
57575
57704
  const { commandType, cwd, assistArgs } = session;
57576
- if (commandType === "claude") return interactiveHarnessRespawn(session);
57705
+ if (commandType === "claude") return interactiveRespawnPlan(session);
57577
57706
  if (commandType === "assist" && assistArgs) {
57578
57707
  const idle = session.status === "waiting";
57579
57708
  let resume;
@@ -58130,15 +58259,47 @@ function relaunchWrapperSession(id, persisted, base, status2) {
58130
58259
  return session;
58131
58260
  }
58132
58261
 
58133
- // src/commands/sessions/daemon/restoreCodexSession.ts
58134
- function restoreCodexSession(id, persisted, base, status2) {
58135
- if (!persisted.harnessSessionId) return null;
58262
+ // src/shared/harnessResumesConversation.ts
58263
+ function harnessResumesConversation(harness) {
58264
+ return harnessCapability(harness, "conversation.resume").supported;
58265
+ }
58266
+
58267
+ // src/commands/sessions/daemon/relaunchUnwrittenConversation.ts
58268
+ function relaunchUnwrittenConversation(adapter, { id, persisted, base }, plan2) {
58269
+ const conversationId = resolveCapability(
58270
+ adapter.capabilities,
58271
+ "conversation.preassignId"
58272
+ ).supported ? adapter.conversation.boundId(persisted) : void 0;
58273
+ const pty2 = adapter.interactive({
58274
+ conversationId,
58275
+ prompt: persisted.initialPrompt,
58276
+ cwd: persisted.cwd,
58277
+ sessionId: id,
58278
+ design: persisted.design,
58279
+ auto: persisted.auto
58280
+ });
58281
+ const idle = persisted.initialPrompt ? false : plan2.idle;
58282
+ return {
58283
+ ...idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2),
58284
+ claudeSessionId: void 0,
58285
+ harnessSessionId: void 0,
58286
+ ...adapter.activityIdentity(conversationId)
58287
+ };
58288
+ }
58289
+
58290
+ // src/commands/sessions/daemon/restoreConversation.ts
58291
+ function restoreConversation(adapter, restored, status2) {
58292
+ const { id, persisted, base } = restored;
58136
58293
  const plan2 = restoreResumePlan(persisted, status2);
58137
- const pty2 = spawnCodex({
58138
- resumeSessionId: persisted.harnessSessionId,
58294
+ const resumeId = adapter.conversation.findResumable(persisted);
58295
+ if (!resumeId) return relaunchUnwrittenConversation(adapter, restored, plan2);
58296
+ const pty2 = adapter.interactive({
58297
+ resumeId,
58139
58298
  prompt: resumePrompt(plan2),
58140
58299
  cwd: persisted.cwd,
58141
- sessionId: id
58300
+ sessionId: id,
58301
+ design: persisted.design,
58302
+ auto: persisted.auto
58142
58303
  });
58143
58304
  return plan2.idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
58144
58305
  }
@@ -58184,42 +58345,11 @@ function unresumableReason(harness) {
58184
58345
  return resume.supported ? `no ${adapter.conversation.idName} was recorded before the daemon stopped, so the conversation cannot be resumed` : `${resume.reason}, so the conversation cannot be restored`;
58185
58346
  }
58186
58347
 
58187
- // src/commands/sessions/daemon/resumeViaClaude.ts
58188
- function resumeViaClaude(id, persisted, base, status2) {
58189
- const mode = { design: persisted.design, auto: persisted.auto };
58190
- const plan2 = restoreResumePlan(persisted, status2);
58191
- const resumes = hasTranscriptOnDisk(persisted);
58192
- const pty2 = spawnClaude(
58193
- resumes ? {
58194
- resumeSessionId: persisted.claudeSessionId,
58195
- prompt: resumePrompt(plan2),
58196
- cwd: persisted.cwd,
58197
- sessionId: id,
58198
- ...mode
58199
- } : {
58200
- claudeSessionId: persisted.claudeSessionId,
58201
- prompt: persisted.initialPrompt,
58202
- cwd: persisted.cwd,
58203
- sessionId: id,
58204
- ...mode
58205
- }
58206
- );
58207
- const idle = resumes || !persisted.initialPrompt ? plan2.idle : false;
58208
- return idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
58209
- }
58210
-
58211
58348
  // src/commands/sessions/daemon/restoreInteractiveSession.ts
58212
- function isCodex2(harness) {
58213
- return resolveHarness(harness) === "codex";
58214
- }
58215
58349
  function restoreInteractiveSession(id, persisted, base, status2) {
58216
- if (persisted.commandType !== "run" && persisted.claudeSessionId && resolveHarness(persisted.harness) === "claude") {
58217
- return resumeViaClaude(id, persisted, base, status2);
58218
- }
58219
- if (persisted.commandType !== "run" && isCodex2(persisted.harness)) {
58220
- const resumed = restoreCodexSession(id, persisted, base, status2);
58221
- if (resumed) return resumed;
58222
- }
58350
+ const adapter = harnessAdapter(persisted.harness);
58351
+ if (persisted.commandType !== "run" && adapter.conversation.boundId(persisted) && harnessResumesConversation(persisted.harness))
58352
+ return restoreConversation(adapter, { id, persisted, base }, status2);
58223
58353
  if (persisted.commandType === "claude") {
58224
58354
  return unrecoverableClaude(id, persisted);
58225
58355
  }
@@ -58372,7 +58502,7 @@ function rearmStoppedSessions(sessions, notify2) {
58372
58502
  }
58373
58503
 
58374
58504
  // src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
58375
- import { existsSync as existsSync105 } from "fs";
58505
+ import { existsSync as existsSync106 } from "fs";
58376
58506
  import { basename as basename37 } from "path";
58377
58507
 
58378
58508
  // src/commands/sessions/daemon/worktree/accountedTrees.ts
@@ -58393,9 +58523,9 @@ function accountedTrees(sessions) {
58393
58523
  }
58394
58524
 
58395
58525
  // src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
58396
- import { existsSync as existsSync104 } from "fs";
58526
+ import { existsSync as existsSync105 } from "fs";
58397
58527
  async function reclaimVanishedWorktrees(clone, paths) {
58398
- if (!existsSync104(clone)) {
58528
+ if (!existsSync105(clone)) {
58399
58529
  for (const { path: path110 } of paths) forgetWorktree(path110);
58400
58530
  daemonLog(
58401
58531
  `clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
@@ -58494,7 +58624,7 @@ function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
58494
58624
  return;
58495
58625
  }
58496
58626
  daemonLog(
58497
- `orphaned worktree ${orphan.path} resurfaced as stopped session ${id}: ${reason4} (${held.summary})`
58627
+ `orphaned worktree ${orphan.path} resurfaced as stopped ${sessions.get(id)?.harness ?? "unknown-harness"} session ${id}: ${reason4} (${held.summary})`
58498
58628
  );
58499
58629
  const session = sessions.get(id);
58500
58630
  if (session) armStoppedSession(sessions, session, notify2);
@@ -58507,6 +58637,7 @@ function orphanedSession(id, recovered) {
58507
58637
  name: `recovered ${basename36(orphan.path)}`,
58508
58638
  subtitle: `${held.summary} in ${orphan.path}`,
58509
58639
  commandType: "claude",
58640
+ harness: orphan.harness ?? loadConfigFrom(orphan.clone).harness.engine,
58510
58641
  pty: null,
58511
58642
  cwd: orphan.path,
58512
58643
  worktree: { path: orphan.path, clone: orphan.clone },
@@ -58553,7 +58684,7 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
58553
58684
  async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
58554
58685
  const accounted = accountedTrees(sessions);
58555
58686
  const vanished = /* @__PURE__ */ new Map();
58556
- for (const { path: path110, clone } of readWorktreeRegistry()) {
58687
+ for (const { path: path110, clone, harness } of readWorktreeRegistry()) {
58557
58688
  if (underTempRoot(path110)) {
58558
58689
  forgetWorktree(path110);
58559
58690
  daemonLog(
@@ -58561,7 +58692,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
58561
58692
  );
58562
58693
  continue;
58563
58694
  }
58564
- if (!existsSync105(path110)) {
58695
+ if (!existsSync106(path110)) {
58565
58696
  logVanishedTree(sessions, path110);
58566
58697
  vanished.set(clone, [
58567
58698
  ...vanished.get(clone) ?? [],
@@ -58570,7 +58701,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
58570
58701
  continue;
58571
58702
  }
58572
58703
  if (accounted.has(path110)) continue;
58573
- await recoverOrphan(sessions, spawnWith, { path: path110, clone }, notify2);
58704
+ await recoverOrphan(sessions, spawnWith, { path: path110, clone, harness }, notify2);
58574
58705
  }
58575
58706
  for (const [clone, paths] of vanished)
58576
58707
  await reclaimVanishedWorktrees(clone, paths);
@@ -59712,8 +59843,16 @@ function addAgentToStream(ctx, targetId, request) {
59712
59843
  );
59713
59844
  return joinable;
59714
59845
  }
59846
+ const harness = request.harness ?? joinable.session.harness;
59847
+ const blocker = launchBlocker(harnessAdapter(harness), sessionFeature);
59848
+ if (blocker) {
59849
+ daemonLog(
59850
+ `create: cannot add an agent to session ${targetId}: ${blocker.replaceAll("\n", " ")}`
59851
+ );
59852
+ return { reason: blocker };
59853
+ }
59715
59854
  return {
59716
- sessionId: spawnIntoStream(ctx, joinable.session, request)
59855
+ sessionId: spawnIntoStream(ctx, joinable.session, { ...request, harness })
59717
59856
  };
59718
59857
  }
59719
59858
 
@@ -59826,7 +59965,7 @@ import { existsSync as existsSync108 } from "fs";
59826
59965
  // src/commands/sessions/daemon/resumeSession.ts
59827
59966
  function resumeSession(id, sessionId2, cwd, name2, holdPty, harness) {
59828
59967
  const startedAt = Date.now();
59829
- const codex = resolveHarness(harness) === "codex";
59968
+ const adapter = harnessAdapter(harness);
59830
59969
  return {
59831
59970
  id,
59832
59971
  name: name2 ? `${name2.slice(0, 36)} (R)` : `Resume ${sessionId2.slice(0, 8)}`,
@@ -59838,74 +59977,43 @@ function resumeSession(id, sessionId2, cwd, name2, holdPty, harness) {
59838
59977
  runningSince: null,
59839
59978
  waitingSince: startedAt,
59840
59979
  ...startOrHoldPty(
59841
- () => codex ? spawnCodex({ resumeSessionId: sessionId2, cwd, sessionId: id }) : spawnClaude({ resumeSessionId: sessionId2, cwd, sessionId: id }),
59980
+ () => adapter.interactive({ resumeId: sessionId2, cwd, sessionId: id }),
59842
59981
  holdPty
59843
59982
  ),
59844
59983
  scrollback: "",
59845
- cwd,
59846
59984
  /* why: bind the card to the conversation it is resuming so a daemon restart
59847
59985
  * re-resumes this same transcript, not whichever .jsonl a cwd poller would
59848
59986
  * have re-discovered (#413). */
59849
- claudeSessionId: codex ? void 0 : sessionId2,
59850
- harnessSessionId: codex ? sessionId2 : void 0
59987
+ ...adapter.conversation.toRef(sessionId2),
59988
+ cwd
59851
59989
  };
59852
59990
  }
59853
59991
 
59854
59992
  // src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
59855
59993
  import { existsSync as existsSync107 } from "fs";
59856
-
59857
- // src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
59858
- import { copyFileSync as copyFileSync4, existsSync as existsSync106, mkdirSync as mkdirSync45 } from "fs";
59859
- import { join as join119 } from "path";
59860
- function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
59861
- const dir = projectDirForCwd(toCwd);
59862
- if (dir === projectDirForCwd(fromCwd)) {
59863
- daemonLog(
59864
- `transcript ${claudeSessionId} already lives in ${dir}: resuming in the original worktree path`
59865
- );
59866
- return;
59867
- }
59868
- const dest = join119(dir, `${claudeSessionId}.jsonl`);
59869
- if (existsSync106(dest)) {
59870
- daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
59871
- return;
59872
- }
59873
- const source = findTranscriptPathSync(fromCwd, claudeSessionId);
59874
- if (!source) {
59875
- daemonLog(
59876
- `transcript ${claudeSessionId} not found under ${projectDirForCwd(fromCwd)}: resuming in ${toCwd} without it`
59877
- );
59878
- return;
59879
- }
59880
- try {
59881
- mkdirSync45(dir, { recursive: true });
59882
- copyFileSync4(source, dest);
59883
- daemonLog(
59884
- `transcript ${source} copied to ${dest} so ${toCwd} can resume it`
59885
- );
59886
- } catch (error) {
59994
+ function resumeInReplacementTree(ctx, conversationId, missingCwd, name2, harness) {
59995
+ const adapter = harnessAdapter(harness);
59996
+ const blocker = launchBlocker(adapter, conversationRecoveryFeature);
59997
+ if (blocker) {
59887
59998
  daemonLog(
59888
- `transcript ${claudeSessionId} could not be copied to ${dir}: ${error instanceof Error ? error.message : String(error)}`
59999
+ `resume ${conversationId} refused: its tree ${missingCwd} is gone and ${blocker.replaceAll("\n", " ")}`
59889
60000
  );
60001
+ throw new Error(blocker);
59890
60002
  }
59891
- }
59892
-
59893
- // src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
59894
- function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name2, harness) {
59895
60003
  const clone = cloneForReapedTree(missingCwd);
59896
60004
  daemonLog(
59897
- `resuming ${claudeSessionId}: its tree ${missingCwd} is gone, allocating from clone ${clone}`
60005
+ `resuming ${adapter.label} conversation ${conversationId}: its tree ${missingCwd} is gone, allocating from clone ${clone}`
59898
60006
  );
59899
60007
  return allocateAndBind(
59900
60008
  ctx,
59901
60009
  clone,
59902
60010
  (id, resolvedCwd, holdUntilSeeded) => {
59903
60011
  const cwd = resolvedCwd ?? clone;
59904
- carryTranscriptToTree(claudeSessionId, missingCwd, cwd);
59905
- daemonLog(`session ${id} resuming ${claudeSessionId} in ${cwd}`);
60012
+ adapter.conversation.relocate(conversationId, missingCwd, cwd);
60013
+ daemonLog(`session ${id} resuming ${conversationId} in ${cwd}`);
59906
60014
  return resumeSession(
59907
60015
  id,
59908
- claudeSessionId,
60016
+ conversationId,
59909
60017
  cwd,
59910
60018
  name2,
59911
60019
  holdUntilSeeded,
@@ -59928,6 +60036,14 @@ function cloneForReapedTree(missingCwd) {
59928
60036
  function resumeInTree(ctx, sessionId2, cwd, name2, harness) {
59929
60037
  if (!existsSync108(cwd))
59930
60038
  return resumeInReplacementTree(ctx, sessionId2, cwd, name2, harness);
60039
+ const blocker = launchBlocker(
60040
+ harnessAdapter(harness),
60041
+ conversationResumeFeature
60042
+ );
60043
+ if (blocker) {
60044
+ daemonLog(`resume ${sessionId2} refused: ${blocker.replaceAll("\n", " ")}`);
60045
+ throw new Error(blocker);
60046
+ }
59931
60047
  const id = ctx.spawnWith(
59932
60048
  (sid) => resumeSession(sid, sessionId2, cwd, name2, void 0, harness)
59933
60049
  );
@@ -60419,17 +60535,24 @@ function creator(isNew, spawn13) {
60419
60535
  }
60420
60536
  sendTo(client, { type: "created", sessionId: result, isNew, traceId });
60421
60537
  };
60538
+ const fail15 = (client, d, error) => {
60539
+ const reason4 = error instanceof Error ? error.message : String(error);
60540
+ daemonLog(`${d.type} failed: ${reason4}`);
60541
+ reply2(client, d, { error: `${d.type} failed: ${reason4}` });
60542
+ };
60422
60543
  return (client, m, d) => {
60423
60544
  if (m.links.route(client, d)) return;
60424
- const result = spawn13(m, d);
60545
+ let result;
60546
+ try {
60547
+ result = spawn13(m, d);
60548
+ } catch (error) {
60549
+ fail15(client, d, error);
60550
+ return;
60551
+ }
60425
60552
  if (result instanceof Promise)
60426
60553
  result.then(
60427
60554
  (resolved) => reply2(client, d, resolved),
60428
- (error) => {
60429
- const reason4 = error instanceof Error ? error.message : String(error);
60430
- daemonLog(`${d.type} failed: ${reason4}`);
60431
- reply2(client, d, { error: `${d.type} failed: ${reason4}` });
60432
- }
60555
+ (error) => fail15(client, d, error)
60433
60556
  );
60434
60557
  else reply2(client, d, result);
60435
60558
  };
@@ -61305,14 +61428,7 @@ function spawnAssistCreate(m, d) {
61305
61428
 
61306
61429
  // src/commands/sessions/daemon/spawnCreate.ts
61307
61430
  function sessionBlocker(harness) {
61308
- const adapter = harnessAdapter(harness);
61309
- const resolution = resolveFeature(sessionFeature, adapter);
61310
- if (resolution.available) return void 0;
61311
- return formatUnavailable(
61312
- sessionFeature.label,
61313
- adapter.label,
61314
- resolution.reasons
61315
- );
61431
+ return launchBlocker(harnessAdapter(harness), sessionFeature);
61316
61432
  }
61317
61433
  function spawnCreate(m, d) {
61318
61434
  const design = d.design === true;
@@ -61323,17 +61439,17 @@ function spawnCreate(m, d) {
61323
61439
  daemonLog(`create: design session (cwd=${d.cwd ?? ""})`);
61324
61440
  if (harness)
61325
61441
  daemonLog(`create: ${harness} session (cwd=${d.cwd ?? ""})`);
61326
- const blocker = sessionBlocker(harness);
61327
- if (blocker) {
61328
- daemonLog(`create: refused, ${blocker.replaceAll("\n", " ")}`);
61329
- return { error: blocker };
61330
- }
61331
61442
  const joinSessionId = design ? void 0 : d.joinSessionId;
61332
61443
  if (joinSessionId) {
61333
61444
  const joined = m.addAgent(joinSessionId, { prompt, harness, auto });
61334
61445
  if ("sessionId" in joined) return joined.sessionId;
61335
61446
  return { error: `Can't add an agent: ${joined.reason}.` };
61336
61447
  }
61448
+ const blocker = sessionBlocker(harness);
61449
+ if (blocker) {
61450
+ daemonLog(`create: refused, ${blocker.replaceAll("\n", " ")}`);
61451
+ return { error: blocker };
61452
+ }
61337
61453
  return m.spawn(
61338
61454
  {
61339
61455
  prompt,