@atlasharness/atlascode 0.1.82 → 0.1.83

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.
Files changed (2) hide show
  1. package/dist/cli.js +896 -399
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -33374,6 +33374,7 @@ var init_load = __esm(() => {
33374
33374
  import {
33375
33375
  appendFile as fsAppendFile,
33376
33376
  mkdir,
33377
+ open as fsOpen2,
33377
33378
  stat as stat2
33378
33379
  } from "fs/promises";
33379
33380
  import { appendFileSync, closeSync as closeSync2, fstatSync, mkdirSync as mkdirSync2, openSync as openSync2, readSync as readSync2 } from "fs";
@@ -33524,11 +33525,14 @@ class Project {
33524
33525
  }
33525
33526
  async appendToFile(filePath, data) {
33526
33527
  try {
33528
+ const needsSeparator = await transcriptTailNeedsSeparator(filePath);
33529
+ const payload = needsSeparator ? `
33530
+ ` + data : data;
33527
33531
  try {
33528
- await fsAppendFile(filePath, data, { mode: 384 });
33532
+ await fsAppendFile(filePath, payload, { mode: 384 });
33529
33533
  } catch {
33530
33534
  await mkdir(dirname6(filePath), { recursive: true, mode: 448 });
33531
- await fsAppendFile(filePath, data, { mode: 384 });
33535
+ await fsAppendFile(filePath, payload, { mode: 384 });
33532
33536
  }
33533
33537
  } catch (err) {
33534
33538
  const code = err?.code;
@@ -33865,11 +33869,13 @@ class Project {
33865
33869
  function appendEntryToFile(fullPath, entry) {
33866
33870
  const line = jsonStringify(entry) + `
33867
33871
  `;
33872
+ const payload = transcriptTailNeedsSeparatorSync(fullPath) ? `
33873
+ ` + line : line;
33868
33874
  try {
33869
- appendFileSync(fullPath, line, { mode: 384 });
33875
+ appendFileSync(fullPath, payload, { mode: 384 });
33870
33876
  } catch {
33871
33877
  mkdirSync2(dirname6(fullPath), { mode: 448 });
33872
- appendFileSync(fullPath, line, { mode: 384 });
33878
+ appendFileSync(fullPath, payload, { mode: 384 });
33873
33879
  }
33874
33880
  }
33875
33881
  function readFileTailSync(fullPath) {
@@ -33891,6 +33897,42 @@ function readFileTailSync(fullPath) {
33891
33897
  }
33892
33898
  }
33893
33899
  }
33900
+ async function transcriptTailNeedsSeparator(fullPath) {
33901
+ let fh;
33902
+ try {
33903
+ const st = await stat2(fullPath);
33904
+ if (!st.isFile() || st.size === 0)
33905
+ return false;
33906
+ fh = await fsOpen2(fullPath, "r");
33907
+ const buf = Buffer.alloc(1);
33908
+ const { bytesRead } = await fh.read(buf, 0, 1, st.size - 1);
33909
+ return bytesRead === 1 && buf[0] !== 10;
33910
+ } catch {
33911
+ return false;
33912
+ } finally {
33913
+ await fh?.close().catch(() => {});
33914
+ }
33915
+ }
33916
+ function transcriptTailNeedsSeparatorSync(fullPath) {
33917
+ let fd;
33918
+ try {
33919
+ fd = openSync2(fullPath, "r");
33920
+ const st = fstatSync(fd);
33921
+ if (st.size === 0)
33922
+ return false;
33923
+ const buf = Buffer.alloc(1);
33924
+ const bytesRead = readSync2(fd, buf, 0, 1, st.size - 1);
33925
+ return bytesRead === 1 && buf[0] !== 10;
33926
+ } catch {
33927
+ return false;
33928
+ } finally {
33929
+ if (fd !== undefined) {
33930
+ try {
33931
+ closeSync2(fd);
33932
+ } catch {}
33933
+ }
33934
+ }
33935
+ }
33894
33936
  function projectInstance() {
33895
33937
  return getProject();
33896
33938
  }
@@ -75904,6 +75946,16 @@ async function resolveGitDir(startPath) {
75904
75946
  if (content.startsWith("gitdir:")) {
75905
75947
  const rawDir = content.slice("gitdir:".length).trim();
75906
75948
  const resolved = resolve13(root, rawDir);
75949
+ try {
75950
+ const dirStat = await stat6(resolved);
75951
+ if (!dirStat.isDirectory()) {
75952
+ resolveGitDirCache.set(cwd, null);
75953
+ return null;
75954
+ }
75955
+ } catch {
75956
+ resolveGitDirCache.set(cwd, null);
75957
+ return null;
75958
+ }
75907
75959
  resolveGitDirCache.set(cwd, resolved);
75908
75960
  return resolved;
75909
75961
  }
@@ -75925,6 +75977,9 @@ function isSafeRefName(name) {
75925
75977
  if (name.split("/").some((c) => c === "." || c === "")) {
75926
75978
  return false;
75927
75979
  }
75980
+ if (name.split("/").some((c) => c.startsWith(".") || c.endsWith(".lock"))) {
75981
+ return false;
75982
+ }
75928
75983
  if (!/^[a-zA-Z0-9/._+@-]+$/.test(name)) {
75929
75984
  return false;
75930
75985
  }
@@ -75934,6 +75989,16 @@ function isValidGitSha(s) {
75934
75989
  return /^[0-9a-f]{40}$/.test(s) || /^[0-9a-f]{64}$/.test(s);
75935
75990
  }
75936
75991
  async function readGitHead(gitDir) {
75992
+ const head = await readGitHeadFromFiles(gitDir);
75993
+ if (head) {
75994
+ return head;
75995
+ }
75996
+ if (await isReftableStorage(gitDir)) {
75997
+ return readGitHeadViaGit(gitDir);
75998
+ }
75999
+ return null;
76000
+ }
76001
+ async function readGitHeadFromFiles(gitDir) {
75937
76002
  try {
75938
76003
  const content = (await readFile9(join29(gitDir, "HEAD"), "utf-8")).trim();
75939
76004
  if (content.startsWith("ref:")) {
@@ -75959,6 +76024,43 @@ async function readGitHead(gitDir) {
75959
76024
  return null;
75960
76025
  }
75961
76026
  }
76027
+ async function isReftableStorage(gitDir) {
76028
+ const dirs = [gitDir];
76029
+ const commonDir = await getCommonDir(gitDir);
76030
+ if (commonDir && commonDir !== gitDir) {
76031
+ dirs.push(commonDir);
76032
+ }
76033
+ for (const dir of dirs) {
76034
+ if (await parseGitConfigValue(dir, "extensions", null, "refstorage") === "reftable") {
76035
+ return true;
76036
+ }
76037
+ }
76038
+ return false;
76039
+ }
76040
+ async function readGitHeadViaGit(gitDir) {
76041
+ const sym = await execFileNoThrowWithCwd(gitExe(), ["--git-dir", gitDir, "symbolic-ref", "-q", "HEAD"], { stdin: "ignore", env: { ...process.env, ...GIT_NO_PROMPT_ENV } });
76042
+ if (sym.code === 0) {
76043
+ const ref = sym.stdout.trim();
76044
+ if (ref.startsWith("refs/heads/")) {
76045
+ const name = ref.slice("refs/heads/".length);
76046
+ return isSafeRefName(name) ? { type: "branch", name } : null;
76047
+ }
76048
+ if (!isSafeRefName(ref)) {
76049
+ return null;
76050
+ }
76051
+ const sha = await resolveRef(gitDir, ref);
76052
+ return sha ? { type: "detached", sha } : { type: "detached", sha: "" };
76053
+ }
76054
+ if (sym.code !== 1) {
76055
+ return null;
76056
+ }
76057
+ const rev = await execFileNoThrowWithCwd(gitExe(), ["--git-dir", gitDir, "rev-parse", "--verify", "--quiet", "HEAD"], { stdin: "ignore", env: { ...process.env, ...GIT_NO_PROMPT_ENV } });
76058
+ if (rev.code !== 0) {
76059
+ return null;
76060
+ }
76061
+ const sha = rev.stdout.trim();
76062
+ return isValidGitSha(sha) ? { type: "detached", sha } : null;
76063
+ }
75962
76064
  async function resolveRef(gitDir, ref) {
75963
76065
  const result = await resolveRefInDir(gitDir, ref);
75964
76066
  if (result) {
@@ -75966,7 +76068,18 @@ async function resolveRef(gitDir, ref) {
75966
76068
  }
75967
76069
  const commonDir = await getCommonDir(gitDir);
75968
76070
  if (commonDir && commonDir !== gitDir) {
75969
- return resolveRefInDir(commonDir, ref);
76071
+ const common = await resolveRefInDir(commonDir, ref);
76072
+ if (common) {
76073
+ return common;
76074
+ }
76075
+ }
76076
+ if (await isReftableStorage(gitDir) && isSafeRefName(ref)) {
76077
+ const rev = await execFileNoThrowWithCwd(gitExe(), ["--git-dir", gitDir, "rev-parse", "--verify", "--quiet", ref], { stdin: "ignore", env: { ...process.env, ...GIT_NO_PROMPT_ENV } });
76078
+ if (rev.code !== 0) {
76079
+ return null;
76080
+ }
76081
+ const sha = rev.stdout.trim();
76082
+ return isValidGitSha(sha) ? sha : null;
75970
76083
  }
75971
76084
  return null;
75972
76085
  }
@@ -76032,6 +76145,20 @@ async function readWorktreeHeadSha(worktreePath) {
76032
76145
  }
76033
76146
  return head.sha;
76034
76147
  }
76148
+ async function readCheckoutHeadSha(checkoutPath) {
76149
+ const gitDir = await resolveGitDir(checkoutPath);
76150
+ if (!gitDir) {
76151
+ return null;
76152
+ }
76153
+ const head = await readGitHead(gitDir);
76154
+ if (!head) {
76155
+ return null;
76156
+ }
76157
+ if (head.type === "branch") {
76158
+ return resolveRef(gitDir, `refs/heads/${head.name}`);
76159
+ }
76160
+ return head.sha;
76161
+ }
76035
76162
  function parseWorktreeListPorcelain(out) {
76036
76163
  const entries = [];
76037
76164
  let current = null;
@@ -76299,11 +76426,14 @@ var init_git = __esm(() => {
76299
76426
  // src/engine/worktree/worktree.ts
76300
76427
  import {
76301
76428
  copyFile,
76429
+ lstat,
76302
76430
  mkdir as mkdir10,
76303
76431
  readdir as readdir4,
76432
+ readFile as readFile10,
76304
76433
  realpath as realpath2,
76305
76434
  stat as stat7,
76306
76435
  symlink as symlink2,
76436
+ unlink as unlink5,
76307
76437
  utimes
76308
76438
  } from "fs/promises";
76309
76439
  import { basename as basename7, dirname as dirname16, join as join30, resolve as resolve14 } from "path";
@@ -76368,11 +76498,61 @@ function generateTmuxSessionName(repoPath, branch) {
76368
76498
  const combined = `${repoName}_${branch}`;
76369
76499
  return combined.replace(/[/.]/g, "_");
76370
76500
  }
76501
+ async function isRegisteredWorktreeTarget(worktreePath) {
76502
+ try {
76503
+ const ptr = (await readFile10(join30(worktreePath, ".git"), "utf-8")).trim();
76504
+ if (!ptr.startsWith("gitdir:"))
76505
+ return false;
76506
+ const gitDir = resolve14(worktreePath, ptr.slice("gitdir:".length).trim());
76507
+ const backlink = (await readFile10(join30(gitDir, "gitdir"), "utf-8")).trim();
76508
+ return resolve14(dirname16(backlink)) === resolve14(worktreePath);
76509
+ } catch {
76510
+ return false;
76511
+ }
76512
+ }
76513
+ async function inspectWorktreeTarget(worktreePath) {
76514
+ let entries;
76515
+ try {
76516
+ const st = await stat7(worktreePath);
76517
+ if (!st.isDirectory())
76518
+ return "occupied";
76519
+ entries = await readdir4(worktreePath);
76520
+ } catch (e) {
76521
+ return getErrnoCode(e) === "ENOENT" ? "clear" : "occupied";
76522
+ }
76523
+ if (entries.length === 0)
76524
+ return "clear";
76525
+ if (entries.length > 1 || entries[0] !== ".git")
76526
+ return "occupied";
76527
+ const dotGit = join30(worktreePath, ".git");
76528
+ try {
76529
+ const st = await lstat(dotGit);
76530
+ if (!st.isFile())
76531
+ return "occupied";
76532
+ } catch {
76533
+ return "occupied";
76534
+ }
76535
+ let content;
76536
+ try {
76537
+ content = (await readFile10(dotGit, "utf-8")).trim();
76538
+ } catch {
76539
+ return "occupied";
76540
+ }
76541
+ if (!content.startsWith("gitdir:"))
76542
+ return "occupied";
76543
+ const gitdirTarget = resolve14(worktreePath, content.slice("gitdir:".length).trim());
76544
+ try {
76545
+ await stat7(gitdirTarget);
76546
+ return "occupied";
76547
+ } catch {
76548
+ return "repair-dangling-pointer";
76549
+ }
76550
+ }
76371
76551
  async function getOrCreateWorktree(repoRoot, slug, options) {
76372
76552
  const worktreePath = worktreePathFor(repoRoot, slug);
76373
76553
  const worktreeBranch = worktreeBranchName(slug);
76374
76554
  const existingHead = await readWorktreeHeadSha(worktreePath);
76375
- if (existingHead) {
76555
+ if (existingHead && await isRegisteredWorktreeTarget(worktreePath)) {
76376
76556
  return {
76377
76557
  worktreePath,
76378
76558
  worktreeBranch,
@@ -76380,6 +76560,20 @@ async function getOrCreateWorktree(repoRoot, slug, options) {
76380
76560
  existed: true
76381
76561
  };
76382
76562
  }
76563
+ const targetState = await inspectWorktreeTarget(worktreePath);
76564
+ if (targetState === "repair-dangling-pointer") {
76565
+ await unlink5(join30(worktreePath, ".git"));
76566
+ } else if (targetState === "occupied") {
76567
+ throw new Error(`Worktree path "${worktreePath}" already exists and is not a safe-to-repair worktree leftover; refusing to overwrite it (data preserved)`);
76568
+ }
76569
+ let sourceCheckout = options?.sourceCheckout ?? null;
76570
+ if (!sourceCheckout && resolve14(process.cwd()) !== resolve14(repoRoot)) {
76571
+ const callingCwd = process.cwd();
76572
+ const headCommit = await readCheckoutHeadSha(callingCwd);
76573
+ if (headCommit) {
76574
+ sourceCheckout = { cwd: callingCwd, headCommit };
76575
+ }
76576
+ }
76383
76577
  await mkdir10(worktreesDir(repoRoot), { recursive: true });
76384
76578
  const fetchEnv = { ...process.env, ...GIT_NO_PROMPT_ENV };
76385
76579
  let baseBranch;
@@ -76406,22 +76600,35 @@ async function getOrCreateWorktree(repoRoot, slug, options) {
76406
76600
  }
76407
76601
  }
76408
76602
  if (!baseSha) {
76409
- const { stdout, code: shaCode } = await execFileNoThrowWithCwd(gitExe(), ["rev-parse", baseBranch], { cwd: repoRoot });
76410
- if (shaCode !== 0) {
76411
- throw new Error(`Failed to resolve base branch "${baseBranch}": git rev-parse failed`);
76603
+ if (baseBranch === "HEAD" && sourceCheckout) {
76604
+ const { code: verifyCode } = await execFileNoThrowWithCwd(gitExe(), ["rev-parse", "--verify", `${sourceCheckout.headCommit}^{commit}`], { cwd: repoRoot });
76605
+ if (verifyCode !== 0) {
76606
+ throw new Error(`Failed to resolve source checkout HEAD ${sourceCheckout.headCommit} as a commit in the repository; refusing to silently fall back to the canonical HEAD`);
76607
+ }
76608
+ baseSha = sourceCheckout.headCommit;
76609
+ } else {
76610
+ const { stdout, code: shaCode } = await execFileNoThrowWithCwd(gitExe(), ["rev-parse", "--verify", `${baseBranch}^{commit}`], { cwd: repoRoot });
76611
+ if (shaCode !== 0) {
76612
+ throw new Error(`Failed to resolve base branch "${baseBranch}": git rev-parse failed`);
76613
+ }
76614
+ baseSha = stdout.trim();
76412
76615
  }
76413
- baseSha = stdout.trim();
76414
76616
  }
76415
76617
  const sparsePaths = getWorktreeSettings().sparsePaths;
76416
76618
  const addArgs = ["worktree", "add"];
76417
76619
  if (sparsePaths?.length) {
76418
76620
  addArgs.push("--no-checkout");
76419
76621
  }
76420
- addArgs.push("-B", worktreeBranch, worktreePath, baseBranch);
76622
+ addArgs.push("-B", worktreeBranch, worktreePath, `${baseSha}^{commit}`);
76421
76623
  const { code: createCode, stderr: createStderr } = await execFileNoThrowWithCwd(gitExe(), addArgs, { cwd: repoRoot });
76422
76624
  if (createCode !== 0) {
76423
76625
  throw new Error(`Failed to create worktree: ${createStderr}`);
76424
76626
  }
76627
+ const actualHead = await readWorktreeHeadSha(worktreePath);
76628
+ if (actualHead !== baseSha) {
76629
+ await execFileNoThrowWithCwd(gitExe(), ["worktree", "remove", "--force", worktreePath], { cwd: repoRoot });
76630
+ throw new Error(`Worktree base divergence: created worktree HEAD ${actualHead ?? "<unreadable>"} does not match the selected base ${baseSha}; the worktree was removed`);
76631
+ }
76425
76632
  if (sparsePaths?.length) {
76426
76633
  const tearDown = async (msg) => {
76427
76634
  await execFileNoThrowWithCwd(gitExe(), ["worktree", "remove", "--force", worktreePath], { cwd: repoRoot });
@@ -76810,7 +77017,7 @@ function memoize2(fn, resolver) {
76810
77017
 
76811
77018
  // src/engine/skill/markdownLoader.ts
76812
77019
  import { statSync as statSync5 } from "fs";
76813
- import { lstat, readdir as readdir5, readFile as readFile10, stat as stat8, realpath as realpath3 } from "fs/promises";
77020
+ import { lstat as lstat2, readdir as readdir5, readFile as readFile11, stat as stat8, realpath as realpath3 } from "fs/promises";
76814
77021
  import { homedir as homedir12 } from "os";
76815
77022
  import { dirname as dirname17, join as join31, resolve as resolve15 } from "path";
76816
77023
  function extractDescriptionFromMarkdown(content, defaultDescription = "Custom item") {
@@ -76857,7 +77064,7 @@ function parseSlashCommandToolsFromFrontmatter(toolsValue) {
76857
77064
  }
76858
77065
  async function getFileIdentity(filePath) {
76859
77066
  try {
76860
- const stats = await lstat(filePath, { bigint: true });
77067
+ const stats = await lstat2(filePath, { bigint: true });
76861
77068
  if (stats.dev === 0n && stats.ino === 0n) {
76862
77069
  return null;
76863
77070
  }
@@ -76969,7 +77176,7 @@ async function loadMarkdownFiles(dir) {
76969
77176
  }
76970
77177
  const results = await Promise.all(files.map(async (filePath) => {
76971
77178
  try {
76972
- const rawContent = await readFile10(filePath, { encoding: "utf-8" });
77179
+ const rawContent = await readFile11(filePath, { encoding: "utf-8" });
76973
77180
  const { frontmatter, content } = parseFrontmatter(rawContent, filePath);
76974
77181
  return {
76975
77182
  filePath,
@@ -78679,10 +78886,10 @@ var init_mcpJsonRpc = __esm(() => {
78679
78886
  });
78680
78887
 
78681
78888
  // src/mcp/mcpConfig.ts
78682
- import { readFile as readFile11 } from "node:fs/promises";
78889
+ import { readFile as readFile12 } from "node:fs/promises";
78683
78890
  async function loadProjectMcpJson(path) {
78684
78891
  try {
78685
- const raw = await readFile11(path, "utf8");
78892
+ const raw = await readFile12(path, "utf8");
78686
78893
  const parsed = JSON.parse(raw);
78687
78894
  if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
78688
78895
  return parsed;
@@ -80097,7 +80304,13 @@ var init_enterWorktreeTool = __esm(() => {
80097
80304
  throw new Error("Already in a worktree session");
80098
80305
  }
80099
80306
  const mainRepoRoot = findCanonicalGitRoot(getCwdState());
80307
+ let sourceCheckout;
80100
80308
  if (mainRepoRoot && mainRepoRoot !== getCwdState()) {
80309
+ const callingCwd = getCwdState();
80310
+ const headCommit = await readCheckoutHeadSha(callingCwd);
80311
+ if (headCommit) {
80312
+ sourceCheckout = { cwd: callingCwd, headCommit };
80313
+ }
80101
80314
  process.chdir(mainRepoRoot);
80102
80315
  setCwd(mainRepoRoot);
80103
80316
  }
@@ -80116,7 +80329,7 @@ var init_enterWorktreeTool = __esm(() => {
80116
80329
  };
80117
80330
  }
80118
80331
  const slug = input.name ?? randomUUID15();
80119
- const worktreeSession = await createWorktreeForSession(getSessionId(), slug);
80332
+ const worktreeSession = await createWorktreeForSession(getSessionId(), slug, undefined, sourceCheckout ? { sourceCheckout } : undefined);
80120
80333
  process.chdir(worktreeSession.worktreePath);
80121
80334
  setCwd(worktreeSession.worktreePath);
80122
80335
  setOriginalCwd(getCwdState());
@@ -87395,7 +87608,7 @@ var init_headlessSessionEnd = __esm(() => {
87395
87608
 
87396
87609
  // src/cli/print.ts
87397
87610
  import { randomUUID as randomUUID21 } from "crypto";
87398
- import { readFile as readFile12 } from "node:fs/promises";
87611
+ import { readFile as readFile13 } from "node:fs/promises";
87399
87612
  import { join as join37, resolve as resolve16 } from "path";
87400
87613
  function bridgeMcpToolClientLocal(client) {
87401
87614
  return {
@@ -87468,7 +87681,7 @@ async function parseMcpConfigItemsLocal(items) {
87468
87681
  object = JSON.parse(trimmed);
87469
87682
  } catch {
87470
87683
  try {
87471
- const raw = await readFile12(resolve16(trimmed), "utf8");
87684
+ const raw = await readFile13(resolve16(trimmed), "utf8");
87472
87685
  object = JSON.parse(raw);
87473
87686
  } catch {
87474
87687
  object = null;
@@ -88416,7 +88629,7 @@ async function updateHandler(options = {}) {
88416
88629
  var init_update = () => {};
88417
88630
 
88418
88631
  // src/cli/mcpConfigWrite.ts
88419
- import { chmod, open as open5, rename, stat as stat11, unlink as unlink5 } from "node:fs/promises";
88632
+ import { chmod, open as open5, rename, stat as stat11, unlink as unlink6 } from "node:fs/promises";
88420
88633
  import { join as join39 } from "node:path";
88421
88634
  function scopeToSettingsSource(scope) {
88422
88635
  return scope === "local" ? "localSettings" : "userSettings";
@@ -88575,7 +88788,7 @@ async function writeMcpjsonFile(config) {
88575
88788
  await rename(tempPath, mcpJsonPath);
88576
88789
  } catch (e) {
88577
88790
  try {
88578
- await unlink5(tempPath);
88791
+ await unlink6(tempPath);
88579
88792
  } catch {}
88580
88793
  throw e;
88581
88794
  }
@@ -100631,11 +100844,11 @@ var init_execFileNoThrow2 = __esm(() => {
100631
100844
  });
100632
100845
 
100633
100846
  // src/tui/utils/git/gitConfigParser.ts
100634
- import { readFile as readFile15 } from "fs/promises";
100847
+ import { readFile as readFile16 } from "fs/promises";
100635
100848
  import { join as join46 } from "path";
100636
100849
  async function parseGitConfigValue2(gitDir, section, subsection, key) {
100637
100850
  try {
100638
- const config = await readFile15(join46(gitDir, "config"), "utf-8");
100851
+ const config = await readFile16(join46(gitDir, "config"), "utf-8");
100639
100852
  return parseConfigString2(config, section, subsection, key);
100640
100853
  } catch {
100641
100854
  return null;
@@ -100801,8 +101014,11 @@ var init_gitConfigParser = () => {};
100801
101014
 
100802
101015
  // src/tui/utils/git/gitFilesystem.ts
100803
101016
  import { unwatchFile, watchFile } from "fs";
100804
- import { readdir as readdir7, readFile as readFile16, stat as stat13 } from "fs/promises";
101017
+ import { readdir as readdir7, readFile as readFile17, stat as stat13 } from "fs/promises";
100805
101018
  import { join as join47, resolve as resolve18 } from "path";
101019
+ function gitExePath() {
101020
+ return process.env.ATLAS_GIT_EXE ?? "git";
101021
+ }
100806
101022
  function clearResolveGitDirCache() {
100807
101023
  resolveGitDirCache2.clear();
100808
101024
  }
@@ -100821,10 +101037,20 @@ async function resolveGitDir2(startPath) {
100821
101037
  try {
100822
101038
  const st = await stat13(gitPath);
100823
101039
  if (st.isFile()) {
100824
- const content = (await readFile16(gitPath, "utf-8")).trim();
101040
+ const content = (await readFile17(gitPath, "utf-8")).trim();
100825
101041
  if (content.startsWith("gitdir:")) {
100826
101042
  const rawDir = content.slice("gitdir:".length).trim();
100827
101043
  const resolved = resolve18(root, rawDir);
101044
+ try {
101045
+ const dirStat = await stat13(resolved);
101046
+ if (!dirStat.isDirectory()) {
101047
+ resolveGitDirCache2.set(cwd, null);
101048
+ return null;
101049
+ }
101050
+ } catch {
101051
+ resolveGitDirCache2.set(cwd, null);
101052
+ return null;
101053
+ }
100828
101054
  resolveGitDirCache2.set(cwd, resolved);
100829
101055
  return resolved;
100830
101056
  }
@@ -100846,6 +101072,9 @@ function isSafeRefName2(name) {
100846
101072
  if (name.split("/").some((c) => c === "." || c === "")) {
100847
101073
  return false;
100848
101074
  }
101075
+ if (name.split("/").some((c) => c.startsWith(".") || c.endsWith(".lock"))) {
101076
+ return false;
101077
+ }
100849
101078
  if (!/^[a-zA-Z0-9/._+@-]+$/.test(name)) {
100850
101079
  return false;
100851
101080
  }
@@ -100855,8 +101084,18 @@ function isValidGitSha2(s) {
100855
101084
  return /^[0-9a-f]{40}$/.test(s) || /^[0-9a-f]{64}$/.test(s);
100856
101085
  }
100857
101086
  async function readGitHead2(gitDir) {
101087
+ const head = await readGitHeadFromFiles2(gitDir);
101088
+ if (head) {
101089
+ return head;
101090
+ }
101091
+ if (await isReftableStorage2(gitDir)) {
101092
+ return readGitHeadViaGit2(gitDir);
101093
+ }
101094
+ return null;
101095
+ }
101096
+ async function readGitHeadFromFiles2(gitDir) {
100858
101097
  try {
100859
- const content = (await readFile16(join47(gitDir, "HEAD"), "utf-8")).trim();
101098
+ const content = (await readFile17(join47(gitDir, "HEAD"), "utf-8")).trim();
100860
101099
  if (content.startsWith("ref:")) {
100861
101100
  const ref = content.slice("ref:".length).trim();
100862
101101
  if (ref.startsWith("refs/heads/")) {
@@ -100880,6 +101119,43 @@ async function readGitHead2(gitDir) {
100880
101119
  return null;
100881
101120
  }
100882
101121
  }
101122
+ async function isReftableStorage2(gitDir) {
101123
+ const dirs = [gitDir];
101124
+ const commonDir = await getCommonDir2(gitDir);
101125
+ if (commonDir && commonDir !== gitDir) {
101126
+ dirs.push(commonDir);
101127
+ }
101128
+ for (const dir of dirs) {
101129
+ if (await parseGitConfigValue2(dir, "extensions", null, "refstorage") === "reftable") {
101130
+ return true;
101131
+ }
101132
+ }
101133
+ return false;
101134
+ }
101135
+ async function readGitHeadViaGit2(gitDir) {
101136
+ const sym = await execFileNoThrow3(gitExePath(), ["--git-dir", gitDir, "symbolic-ref", "-q", "HEAD"], { stdin: "ignore", useCwd: false, env: { ...process.env, ...GIT_NO_PROMPT_ENV2 } });
101137
+ if (sym.code === 0) {
101138
+ const ref = sym.stdout.trim();
101139
+ if (ref.startsWith("refs/heads/")) {
101140
+ const name = ref.slice("refs/heads/".length);
101141
+ return isSafeRefName2(name) ? { type: "branch", name } : null;
101142
+ }
101143
+ if (!isSafeRefName2(ref)) {
101144
+ return null;
101145
+ }
101146
+ const sha = await resolveRef2(gitDir, ref);
101147
+ return sha ? { type: "detached", sha } : { type: "detached", sha: "" };
101148
+ }
101149
+ if (sym.code !== 1) {
101150
+ return null;
101151
+ }
101152
+ const rev = await execFileNoThrow3(gitExePath(), ["--git-dir", gitDir, "rev-parse", "--verify", "--quiet", "HEAD"], { stdin: "ignore", useCwd: false, env: { ...process.env, ...GIT_NO_PROMPT_ENV2 } });
101153
+ if (rev.code !== 0) {
101154
+ return null;
101155
+ }
101156
+ const sha = rev.stdout.trim();
101157
+ return isValidGitSha2(sha) ? { type: "detached", sha } : null;
101158
+ }
100883
101159
  async function resolveRef2(gitDir, ref) {
100884
101160
  const result = await resolveRefInDir2(gitDir, ref);
100885
101161
  if (result) {
@@ -100887,13 +101163,24 @@ async function resolveRef2(gitDir, ref) {
100887
101163
  }
100888
101164
  const commonDir = await getCommonDir2(gitDir);
100889
101165
  if (commonDir && commonDir !== gitDir) {
100890
- return resolveRefInDir2(commonDir, ref);
101166
+ const common = await resolveRefInDir2(commonDir, ref);
101167
+ if (common) {
101168
+ return common;
101169
+ }
101170
+ }
101171
+ if (await isReftableStorage2(gitDir) && isSafeRefName2(ref)) {
101172
+ const rev = await execFileNoThrow3(gitExePath(), ["--git-dir", gitDir, "rev-parse", "--verify", "--quiet", ref], { stdin: "ignore", useCwd: false, env: { ...process.env, ...GIT_NO_PROMPT_ENV2 } });
101173
+ if (rev.code !== 0) {
101174
+ return null;
101175
+ }
101176
+ const sha = rev.stdout.trim();
101177
+ return isValidGitSha2(sha) ? sha : null;
100891
101178
  }
100892
101179
  return null;
100893
101180
  }
100894
101181
  async function resolveRefInDir2(dir, ref) {
100895
101182
  try {
100896
- const content = (await readFile16(join47(dir, ref), "utf-8")).trim();
101183
+ const content = (await readFile17(join47(dir, ref), "utf-8")).trim();
100897
101184
  if (content.startsWith("ref:")) {
100898
101185
  const target = content.slice("ref:".length).trim();
100899
101186
  if (!isSafeRefName2(target)) {
@@ -100907,7 +101194,7 @@ async function resolveRefInDir2(dir, ref) {
100907
101194
  return content;
100908
101195
  } catch {}
100909
101196
  try {
100910
- const packed = await readFile16(join47(dir, "packed-refs"), "utf-8");
101197
+ const packed = await readFile17(join47(dir, "packed-refs"), "utf-8");
100911
101198
  for (const line of packed.split(`
100912
101199
  `)) {
100913
101200
  if (line.startsWith("#") || line.startsWith("^")) {
@@ -100927,7 +101214,7 @@ async function resolveRefInDir2(dir, ref) {
100927
101214
  }
100928
101215
  async function getCommonDir2(gitDir) {
100929
101216
  try {
100930
- const content = (await readFile16(join47(gitDir, "commondir"), "utf-8")).trim();
101217
+ const content = (await readFile17(join47(gitDir, "commondir"), "utf-8")).trim();
100931
101218
  return resolve18(gitDir, content);
100932
101219
  } catch {
100933
101220
  return null;
@@ -100935,7 +101222,7 @@ async function getCommonDir2(gitDir) {
100935
101222
  }
100936
101223
  async function readRawSymref2(gitDir, refPath, branchPrefix) {
100937
101224
  try {
100938
- const content = (await readFile16(join47(gitDir, refPath), "utf-8")).trim();
101225
+ const content = (await readFile17(join47(gitDir, refPath), "utf-8")).trim();
100939
101226
  if (content.startsWith("ref:")) {
100940
101227
  const target = content.slice("ref:".length).trim();
100941
101228
  if (target.startsWith(branchPrefix)) {
@@ -100981,6 +101268,11 @@ class GitFileWatcher {
100981
101268
  this.watchPath(join47(this.commonDir ?? this.gitDir, "config"), () => {
100982
101269
  this.invalidate();
100983
101270
  });
101271
+ if (await isReftableStorage2(this.gitDir)) {
101272
+ this.watchPath(join47(this.commonDir ?? this.gitDir, "reftable"), () => {
101273
+ this.invalidate();
101274
+ });
101275
+ }
100984
101276
  await this.watchCurrentBranchRef();
100985
101277
  registerCleanup3(async () => {
100986
101278
  this.stopWatching();
@@ -101144,7 +101436,7 @@ async function getHeadForDir(cwd) {
101144
101436
  async function readWorktreeHeadSha2(worktreePath) {
101145
101437
  let gitDir;
101146
101438
  try {
101147
- const ptr = (await readFile16(join47(worktreePath, ".git"), "utf-8")).trim();
101439
+ const ptr = (await readFile17(join47(worktreePath, ".git"), "utf-8")).trim();
101148
101440
  if (!ptr.startsWith("gitdir:")) {
101149
101441
  return null;
101150
101442
  }
@@ -101161,6 +101453,20 @@ async function readWorktreeHeadSha2(worktreePath) {
101161
101453
  }
101162
101454
  return head.sha;
101163
101455
  }
101456
+ async function readCheckoutHeadSha2(checkoutPath) {
101457
+ const gitDir = await resolveGitDir2(checkoutPath);
101458
+ if (!gitDir) {
101459
+ return null;
101460
+ }
101461
+ const head = await readGitHead2(gitDir);
101462
+ if (!head) {
101463
+ return null;
101464
+ }
101465
+ if (head.type === "branch") {
101466
+ return resolveRef2(gitDir, `refs/heads/${head.name}`);
101467
+ }
101468
+ return head.sha;
101469
+ }
101164
101470
  async function getRemoteUrlForDir(cwd) {
101165
101471
  const gitDir = await resolveGitDir2(cwd);
101166
101472
  if (!gitDir) {
@@ -101189,13 +101495,18 @@ async function getWorktreeCountFromFs() {
101189
101495
  return 1;
101190
101496
  }
101191
101497
  }
101192
- var resolveGitDirCache2, WATCH_INTERVAL_MS = 1000, gitWatcher;
101498
+ var GIT_NO_PROMPT_ENV2, resolveGitDirCache2, WATCH_INTERVAL_MS = 1000, gitWatcher;
101193
101499
  var init_gitFilesystem = __esm(() => {
101194
101500
  init_bootstrapState();
101195
101501
  init_cleanupRegistry3();
101196
101502
  init_cwd3();
101503
+ init_execFileNoThrow2();
101197
101504
  init_git2();
101198
101505
  init_gitConfigParser();
101506
+ GIT_NO_PROMPT_ENV2 = {
101507
+ GIT_TERMINAL_PROMPT: "0",
101508
+ GIT_ASKPASS: ""
101509
+ };
101199
101510
  resolveGitDirCache2 = new Map;
101200
101511
  gitWatcher = new GitFileWatcher;
101201
101512
  });
@@ -102221,7 +102532,7 @@ var init_git2 = __esm(() => {
102221
102532
  });
102222
102533
 
102223
102534
  // src/tui/utils/platform.ts
102224
- import { readdir as readdir8, readFile as readFile17 } from "fs/promises";
102535
+ import { readdir as readdir8, readFile as readFile18 } from "fs/promises";
102225
102536
  import { release as osRelease } from "os";
102226
102537
  var SUPPORTED_PLATFORMS2, getPlatform3, getWslVersion, getLinuxDistroInfo;
102227
102538
  var init_platform3 = __esm(() => {
@@ -102283,7 +102594,7 @@ var init_platform3 = __esm(() => {
102283
102594
  linuxKernel: osRelease()
102284
102595
  };
102285
102596
  try {
102286
- const content = await readFile17("/etc/os-release", "utf8");
102597
+ const content = await readFile18("/etc/os-release", "utf8");
102287
102598
  for (const line of content.split(`
102288
102599
  `)) {
102289
102600
  const match = line.match(/^(ID|VERSION_ID)=(.*)$/);
@@ -102419,7 +102730,7 @@ var init_getWorktreePathsPortable = __esm(() => {
102419
102730
  });
102420
102731
 
102421
102732
  // src/tui/utils/sessionStoragePortable.ts
102422
- import { open as fsOpen2, readdir as readdir9, realpath as realpath5, stat as stat14 } from "fs/promises";
102733
+ import { open as fsOpen3, readdir as readdir9, realpath as realpath5, stat as stat14 } from "fs/promises";
102423
102734
  function validateUuid(maybeUuid) {
102424
102735
  if (typeof maybeUuid !== "string")
102425
102736
  return null;
@@ -102484,7 +102795,7 @@ function extractLastJsonStringField2(text, key) {
102484
102795
  }
102485
102796
  async function readHeadAndTail(filePath, fileSize, buf) {
102486
102797
  try {
102487
- const fh = await fsOpen2(filePath, "r");
102798
+ const fh = await fsOpen3(filePath, "r");
102488
102799
  try {
102489
102800
  const headResult = await fh.read(buf, 0, LITE_READ_BUF_SIZE2, 0);
102490
102801
  if (headResult.bytesRead === 0)
@@ -102511,7 +102822,7 @@ async function scanMidForSessionTitle(filePath, fileSize) {
102511
102822
  if (scanLen <= 0)
102512
102823
  return;
102513
102824
  try {
102514
- const fh = await fsOpen2(filePath, "r");
102825
+ const fh = await fsOpen3(filePath, "r");
102515
102826
  try {
102516
102827
  const buf = Buffer.allocUnsafe(scanLen);
102517
102828
  const result = await fh.read(buf, 0, scanLen, scanStart);
@@ -102711,7 +103022,7 @@ async function readTranscriptForLoad2(filePath, fileSize) {
102711
103022
  straddleSnapTailEnd: 0
102712
103023
  };
102713
103024
  const chunk = Buffer.allocUnsafe(CHUNK_SIZE);
102714
- const fd = await fsOpen2(filePath, "r");
103025
+ const fd = await fsOpen3(filePath, "r");
102715
103026
  try {
102716
103027
  let filePos = 0;
102717
103028
  while (filePos < fileSize) {
@@ -121761,7 +122072,7 @@ function stripBOM2(content) {
121761
122072
  var UTF8_BOM = "\uFEFF";
121762
122073
 
121763
122074
  // src/tui/utils/json.ts
121764
- import { open as open6, readFile as readFile18, stat as stat15 } from "fs/promises";
122075
+ import { open as open6, readFile as readFile19, stat as stat15 } from "fs/promises";
121765
122076
  function parseJSONUncached(json, shouldLogError) {
121766
122077
  try {
121767
122078
  return { ok: true, value: JSON.parse(stripBOM2(json)) };
@@ -121863,7 +122174,7 @@ async function readJSONLFile(filePath) {
121863
122174
  try {
121864
122175
  const { size } = await stat15(filePath);
121865
122176
  if (size <= MAX_JSONL_READ_BYTES) {
121866
- return parseJSONL2(await readFile18(filePath));
122177
+ return parseJSONL2(await readFile19(filePath));
121867
122178
  }
121868
122179
  const fd = __using(__stack, await open6(filePath, "r"), 1);
121869
122180
  const buf = Buffer.allocUnsafe(MAX_JSONL_READ_BYTES);
@@ -124781,7 +125092,7 @@ var init_file = __esm(() => {
124781
125092
  });
124782
125093
 
124783
125094
  // src/tui/utils/git/gitignore.ts
124784
- import { appendFile as appendFile2, mkdir as mkdir14, readFile as readFile19, writeFile as writeFile10 } from "fs/promises";
125095
+ import { appendFile as appendFile2, mkdir as mkdir14, readFile as readFile20, writeFile as writeFile10 } from "fs/promises";
124785
125096
  import { homedir as homedir21 } from "os";
124786
125097
  import { dirname as dirname31, join as join58 } from "path";
124787
125098
  async function isPathGitignored2(filePath, cwd) {
@@ -124808,7 +125119,7 @@ async function addFileGlobRuleToGitignore(filename, cwd = getCwd()) {
124808
125119
  const configGitDir = dirname31(globalGitignorePath);
124809
125120
  await mkdir14(configGitDir, { recursive: true });
124810
125121
  try {
124811
- const content = await readFile19(globalGitignorePath, { encoding: "utf-8" });
125122
+ const content = await readFile20(globalGitignorePath, { encoding: "utf-8" });
124812
125123
  if (content.includes(gitignoreEntry)) {
124813
125124
  return;
124814
125125
  }
@@ -127387,7 +127698,7 @@ function peekForStdinData2(stream, ms) {
127387
127698
  }
127388
127699
 
127389
127700
  // src/tui/utils/debug.ts
127390
- import { appendFile as appendFile3, mkdir as mkdir15, symlink as symlink3, unlink as unlink6 } from "fs/promises";
127701
+ import { appendFile as appendFile3, mkdir as mkdir15, symlink as symlink3, unlink as unlink7 } from "fs/promises";
127391
127702
  import { dirname as dirname34, join as join62 } from "path";
127392
127703
  function enableDebugLogging() {
127393
127704
  const wasActive = isDebugMode() || isAtlasDev();
@@ -127540,7 +127851,7 @@ var init_debug = __esm(() => {
127540
127851
  const debugLogPath = getDebugLogPath();
127541
127852
  const debugLogsDir = dirname34(debugLogPath);
127542
127853
  const latestSymlinkPath = join62(debugLogsDir, "latest");
127543
- await unlink6(latestSymlinkPath).catch(() => {});
127854
+ await unlink7(latestSymlinkPath).catch(() => {});
127544
127855
  await symlink3(debugLogPath, latestSymlinkPath);
127545
127856
  } catch {}
127546
127857
  });
@@ -165110,7 +165421,7 @@ var init_mailbox3 = __esm(() => {
165110
165421
  });
165111
165422
 
165112
165423
  // node_modules/readdirp/index.js
165113
- import { lstat as lstat2, readdir as readdir10, realpath as realpath7, stat as stat18 } from "node:fs/promises";
165424
+ import { lstat as lstat3, readdir as readdir10, realpath as realpath7, stat as stat18 } from "node:fs/promises";
165114
165425
  import { join as pjoin, resolve as presolve, sep as psep } from "node:path";
165115
165426
  import { Readable as Readable6 } from "node:stream";
165116
165427
  function readdirp(root, options = {}) {
@@ -165207,7 +165518,7 @@ var init_readdirp = __esm(() => {
165207
165518
  const type = opts.type ?? defaultOptions.type;
165208
165519
  this._fileFilter = normalizeFilter(opts.fileFilter);
165209
165520
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
165210
- const statMethod = opts.lstat ? lstat2 : stat18;
165521
+ const statMethod = opts.lstat ? lstat3 : stat18;
165211
165522
  if (wantBigintFsStats) {
165212
165523
  this._stat = (path) => statMethod(path, { bigint: true });
165213
165524
  } else {
@@ -165334,7 +165645,7 @@ var init_readdirp = __esm(() => {
165334
165645
  const full = entry.fullPath;
165335
165646
  try {
165336
165647
  const entryRealPath = await realpath7(full);
165337
- const entryRealPathStats = await lstat2(entryRealPath);
165648
+ const entryRealPathStats = await lstat3(entryRealPath);
165338
165649
  if (entryRealPathStats.isFile()) {
165339
165650
  return "file";
165340
165651
  }
@@ -165362,7 +165673,7 @@ var init_readdirp = __esm(() => {
165362
165673
 
165363
165674
  // node_modules/chokidar/handler.js
165364
165675
  import { watch as fs_watch, unwatchFile as unwatchFile3, watchFile as watchFile3 } from "node:fs";
165365
- import { realpath as fsrealpath, lstat as lstat3, open as open8, stat as stat19 } from "node:fs/promises";
165676
+ import { realpath as fsrealpath, lstat as lstat4, open as open8, stat as stat19 } from "node:fs/promises";
165366
165677
  import { type as osType } from "node:os";
165367
165678
  import * as sp from "node:path";
165368
165679
  function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
@@ -165790,7 +166101,7 @@ var init_handler = __esm(() => {
165790
166101
  ERROR: "error"
165791
166102
  };
165792
166103
  EV = EVENTS;
165793
- statMethods = { lstat: lstat3, stat: stat19 };
166104
+ statMethods = { lstat: lstat4, stat: stat19 };
165794
166105
  HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
165795
166106
  binaryExtensions = new Set([
165796
166107
  "3dm",
@@ -167313,7 +167624,7 @@ var init_pluginOnlyPolicy = __esm(() => {
167313
167624
 
167314
167625
  // src/tui/utils/markdownConfigLoader.ts
167315
167626
  import { statSync as statSync9 } from "fs";
167316
- import { lstat as lstat4, readdir as readdir12, readFile as readFile20, realpath as realpath8, stat as stat22 } from "fs/promises";
167627
+ import { lstat as lstat5, readdir as readdir12, readFile as readFile21, realpath as realpath8, stat as stat22 } from "fs/promises";
167317
167628
  import { homedir as homedir23 } from "os";
167318
167629
  import { dirname as dirname40, join as join67, resolve as resolve30, sep as sep14 } from "path";
167319
167630
  function extractDescriptionFromMarkdown2(content, defaultDescription = "Custom item") {
@@ -167370,7 +167681,7 @@ function parseSlashCommandToolsFromFrontmatter2(toolsValue) {
167370
167681
  }
167371
167682
  async function getFileIdentity3(filePath) {
167372
167683
  try {
167373
- const stats = await lstat4(filePath, { bigint: true });
167684
+ const stats = await lstat5(filePath, { bigint: true });
167374
167685
  if (stats.dev === 0n && stats.ino === 0n) {
167375
167686
  return null;
167376
167687
  }
@@ -167497,7 +167808,7 @@ async function loadMarkdownFiles2(dir) {
167497
167808
  }
167498
167809
  const results = await Promise.all(files.map(async (filePath) => {
167499
167810
  try {
167500
- const rawContent = await readFile20(filePath, { encoding: "utf-8" });
167811
+ const rawContent = await readFile21(filePath, { encoding: "utf-8" });
167501
167812
  const { frontmatter, content } = parseFrontmatter2(rawContent, filePath);
167502
167813
  return {
167503
167814
  filePath,
@@ -171687,7 +171998,7 @@ var init_agentColorManager = __esm(() => {
171687
171998
  });
171688
171999
 
171689
172000
  // src/tui/tools/AgentTool/agentMemorySnapshot.ts
171690
- import { mkdir as mkdir16, readdir as readdir14, readFile as readFile21, unlink as unlink7, writeFile as writeFile11 } from "fs/promises";
172001
+ import { mkdir as mkdir16, readdir as readdir14, readFile as readFile22, unlink as unlink8, writeFile as writeFile11 } from "fs/promises";
171691
172002
  import { join as join72 } from "path";
171692
172003
  function getSnapshotDirForAgent(agentType) {
171693
172004
  return join72(getCwd(), getConfigDirName2(), SNAPSHOT_BASE, agentType);
@@ -171700,7 +172011,7 @@ function getSyncedJsonPath(agentType, scope) {
171700
172011
  }
171701
172012
  async function readJsonFile(path, schema) {
171702
172013
  try {
171703
- const content = await readFile21(path, { encoding: "utf-8" });
172014
+ const content = await readFile22(path, { encoding: "utf-8" });
171704
172015
  const result = schema.safeParse(jsonParse2(content));
171705
172016
  return result.success ? result.data : null;
171706
172017
  } catch {
@@ -171716,7 +172027,7 @@ async function copySnapshotToLocal(agentType, scope) {
171716
172027
  for (const dirent of files) {
171717
172028
  if (!dirent.isFile() || dirent.name === SNAPSHOT_JSON)
171718
172029
  continue;
171719
- const content = await readFile21(join72(snapshotMemDir, dirent.name), {
172030
+ const content = await readFile22(join72(snapshotMemDir, dirent.name), {
171720
172031
  encoding: "utf-8"
171721
172032
  });
171722
172033
  await writeFile11(join72(localMemDir, dirent.name), content);
@@ -180408,14 +180719,16 @@ var installPrepareCommitMsgHook = () => ({});
180408
180719
  // src/tui/utils/worktree.ts
180409
180720
  import {
180410
180721
  copyFile as copyFile2,
180722
+ lstat as lstat6,
180411
180723
  mkdir as mkdir17,
180412
180724
  readdir as readdir15,
180413
- readFile as readFile22,
180725
+ readFile as readFile23,
180414
180726
  stat as stat24,
180415
180727
  symlink as symlink4,
180728
+ unlink as unlink9,
180416
180729
  utimes as utimes2
180417
180730
  } from "fs/promises";
180418
- import { basename as basename17, dirname as dirname42, join as join73 } from "path";
180731
+ import { basename as basename17, dirname as dirname42, join as join73, resolve as resolve32 } from "path";
180419
180732
  function validateWorktreeSlug2(slug) {
180420
180733
  if (slug.length > MAX_WORKTREE_SLUG_LENGTH2) {
180421
180734
  throw new Error(`Invalid worktree name: must be ${MAX_WORKTREE_SLUG_LENGTH2} characters or fewer (got ${slug.length})`);
@@ -180474,11 +180787,61 @@ function worktreeBranchName2(slug) {
180474
180787
  function worktreePathFor2(repoRoot, slug) {
180475
180788
  return join73(worktreesDir2(repoRoot), flattenSlug2(slug));
180476
180789
  }
180790
+ async function isRegisteredWorktreeTarget2(worktreePath) {
180791
+ try {
180792
+ const ptr = (await readFile23(join73(worktreePath, ".git"), "utf-8")).trim();
180793
+ if (!ptr.startsWith("gitdir:"))
180794
+ return false;
180795
+ const gitDir = resolve32(worktreePath, ptr.slice("gitdir:".length).trim());
180796
+ const backlink = (await readFile23(join73(gitDir, "gitdir"), "utf-8")).trim();
180797
+ return resolve32(dirname42(backlink)) === resolve32(worktreePath);
180798
+ } catch {
180799
+ return false;
180800
+ }
180801
+ }
180802
+ async function inspectWorktreeTarget2(worktreePath) {
180803
+ let entries;
180804
+ try {
180805
+ const st = await stat24(worktreePath);
180806
+ if (!st.isDirectory())
180807
+ return "occupied";
180808
+ entries = await readdir15(worktreePath);
180809
+ } catch (e) {
180810
+ return getErrnoCode2(e) === "ENOENT" ? "clear" : "occupied";
180811
+ }
180812
+ if (entries.length === 0)
180813
+ return "clear";
180814
+ if (entries.length > 1 || entries[0] !== ".git")
180815
+ return "occupied";
180816
+ const dotGit = join73(worktreePath, ".git");
180817
+ try {
180818
+ const st = await lstat6(dotGit);
180819
+ if (!st.isFile())
180820
+ return "occupied";
180821
+ } catch {
180822
+ return "occupied";
180823
+ }
180824
+ let content;
180825
+ try {
180826
+ content = (await readFile23(dotGit, "utf-8")).trim();
180827
+ } catch {
180828
+ return "occupied";
180829
+ }
180830
+ if (!content.startsWith("gitdir:"))
180831
+ return "occupied";
180832
+ const gitdirTarget = resolve32(worktreePath, content.slice("gitdir:".length).trim());
180833
+ try {
180834
+ await stat24(gitdirTarget);
180835
+ return "occupied";
180836
+ } catch {
180837
+ return "repair-dangling-pointer";
180838
+ }
180839
+ }
180477
180840
  async function getOrCreateWorktree2(repoRoot, slug, options) {
180478
180841
  const worktreePath = worktreePathFor2(repoRoot, slug);
180479
180842
  const worktreeBranch = worktreeBranchName2(slug);
180480
180843
  const existingHead = await readWorktreeHeadSha2(worktreePath);
180481
- if (existingHead) {
180844
+ if (existingHead && await isRegisteredWorktreeTarget2(worktreePath)) {
180482
180845
  return {
180483
180846
  worktreePath,
180484
180847
  worktreeBranch,
@@ -180486,8 +180849,22 @@ async function getOrCreateWorktree2(repoRoot, slug, options) {
180486
180849
  existed: true
180487
180850
  };
180488
180851
  }
180852
+ const targetState = await inspectWorktreeTarget2(worktreePath);
180853
+ if (targetState === "repair-dangling-pointer") {
180854
+ await unlink9(join73(worktreePath, ".git"));
180855
+ } else if (targetState === "occupied") {
180856
+ throw new Error(`Worktree path "${worktreePath}" already exists and is not a safe-to-repair worktree leftover; refusing to overwrite it (data preserved)`);
180857
+ }
180858
+ let sourceCheckout = options?.sourceCheckout ?? null;
180859
+ if (!sourceCheckout && resolve32(getCwd()) !== resolve32(repoRoot)) {
180860
+ const callingCwd = getCwd();
180861
+ const headCommit = await readCheckoutHeadSha2(callingCwd);
180862
+ if (headCommit) {
180863
+ sourceCheckout = { cwd: callingCwd, headCommit };
180864
+ }
180865
+ }
180489
180866
  await mkdir17(worktreesDir2(repoRoot), { recursive: true });
180490
- const fetchEnv = { ...process.env, ...GIT_NO_PROMPT_ENV2 };
180867
+ const fetchEnv = { ...process.env, ...GIT_NO_PROMPT_ENV3 };
180491
180868
  let baseBranch;
180492
180869
  let baseSha = null;
180493
180870
  if (options?.prNumber) {
@@ -180512,22 +180889,35 @@ async function getOrCreateWorktree2(repoRoot, slug, options) {
180512
180889
  }
180513
180890
  }
180514
180891
  if (!baseSha) {
180515
- const { stdout, code: shaCode } = await execFileNoThrowWithCwd2(gitExe2(), ["rev-parse", baseBranch], { cwd: repoRoot });
180516
- if (shaCode !== 0) {
180517
- throw new Error(`Failed to resolve base branch "${baseBranch}": git rev-parse failed`);
180892
+ if (baseBranch === "HEAD" && sourceCheckout) {
180893
+ const { code: verifyCode } = await execFileNoThrowWithCwd2(gitExe2(), ["rev-parse", "--verify", `${sourceCheckout.headCommit}^{commit}`], { cwd: repoRoot });
180894
+ if (verifyCode !== 0) {
180895
+ throw new Error(`Failed to resolve source checkout HEAD ${sourceCheckout.headCommit} as a commit in the repository; refusing to silently fall back to the canonical HEAD`);
180896
+ }
180897
+ baseSha = sourceCheckout.headCommit;
180898
+ } else {
180899
+ const { stdout, code: shaCode } = await execFileNoThrowWithCwd2(gitExe2(), ["rev-parse", "--verify", `${baseBranch}^{commit}`], { cwd: repoRoot });
180900
+ if (shaCode !== 0) {
180901
+ throw new Error(`Failed to resolve base branch "${baseBranch}": git rev-parse failed`);
180902
+ }
180903
+ baseSha = stdout.trim();
180518
180904
  }
180519
- baseSha = stdout.trim();
180520
180905
  }
180521
180906
  const sparsePaths = getInitialSettings2().worktree?.sparsePaths;
180522
180907
  const addArgs = ["worktree", "add"];
180523
180908
  if (sparsePaths?.length) {
180524
180909
  addArgs.push("--no-checkout");
180525
180910
  }
180526
- addArgs.push("-B", worktreeBranch, worktreePath, baseBranch);
180911
+ addArgs.push("-B", worktreeBranch, worktreePath, `${baseSha}^{commit}`);
180527
180912
  const { code: createCode, stderr: createStderr } = await execFileNoThrowWithCwd2(gitExe2(), addArgs, { cwd: repoRoot });
180528
180913
  if (createCode !== 0) {
180529
180914
  throw new Error(`Failed to create worktree: ${createStderr}`);
180530
180915
  }
180916
+ const actualHead = await readWorktreeHeadSha2(worktreePath);
180917
+ if (actualHead !== baseSha) {
180918
+ await execFileNoThrowWithCwd2(gitExe2(), ["worktree", "remove", "--force", worktreePath], { cwd: repoRoot });
180919
+ throw new Error(`Worktree base divergence: created worktree HEAD ${actualHead ?? "<unreadable>"} does not match the selected base ${baseSha}; the worktree was removed`);
180920
+ }
180531
180921
  if (sparsePaths?.length) {
180532
180922
  const tearDown = async (msg) => {
180533
180923
  await execFileNoThrowWithCwd2(gitExe2(), ["worktree", "remove", "--force", worktreePath], { cwd: repoRoot });
@@ -180553,7 +180943,7 @@ async function getOrCreateWorktree2(repoRoot, slug, options) {
180553
180943
  async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
180554
180944
  let includeContent;
180555
180945
  try {
180556
- includeContent = await readFile22(join73(repoRoot, ".worktreeinclude"), "utf-8");
180946
+ includeContent = await readFile23(join73(repoRoot, ".worktreeinclude"), "utf-8");
180557
180947
  } catch {
180558
180948
  return [];
180559
180949
  }
@@ -180933,7 +181323,7 @@ async function cleanupStaleAgentWorktrees2(cutoffDate) {
180933
181323
  }
180934
181324
  return removed;
180935
181325
  }
180936
- var import_ignore, VALID_WORKTREE_SLUG_SEGMENT2, MAX_WORKTREE_SLUG_LENGTH2 = 64, currentWorktreeSession2 = null, GIT_NO_PROMPT_ENV2, EPHEMERAL_WORKTREE_PATTERNS2;
181326
+ var import_ignore, VALID_WORKTREE_SLUG_SEGMENT2, MAX_WORKTREE_SLUG_LENGTH2 = 64, currentWorktreeSession2 = null, GIT_NO_PROMPT_ENV3, EPHEMERAL_WORKTREE_PATTERNS2;
180937
181327
  var init_worktree4 = __esm(() => {
180938
181328
  init_shared();
180939
181329
  init_configDir();
@@ -180952,7 +181342,7 @@ var init_worktree4 = __esm(() => {
180952
181342
  init_detection2();
180953
181343
  import_ignore = __toESM(require_ignore(), 1);
180954
181344
  VALID_WORKTREE_SLUG_SEGMENT2 = /^[a-zA-Z0-9._-]+$/;
180955
- GIT_NO_PROMPT_ENV2 = {
181345
+ GIT_NO_PROMPT_ENV3 = {
180956
181346
  GIT_TERMINAL_PROMPT: "0",
180957
181347
  GIT_ASKPASS: ""
180958
181348
  };
@@ -189857,7 +190247,7 @@ var init_validate2 = __esm(() => {
189857
190247
 
189858
190248
  // src/tui/keybindings/loadUserBindings.ts
189859
190249
  import { readFileSync as readFileSync18 } from "fs";
189860
- import { readFile as readFile23, stat as stat26 } from "fs/promises";
190250
+ import { readFile as readFile24, stat as stat26 } from "fs/promises";
189861
190251
  import { dirname as dirname43, join as join75 } from "path";
189862
190252
  function isKeybindingCustomizationEnabled() {
189863
190253
  return getFeatureValue_CACHED_MAY_BE_STALE("atlas_keybinding_customization_release", false);
@@ -189890,7 +190280,7 @@ async function loadKeybindings() {
189890
190280
  }
189891
190281
  const userPath = getKeybindingsPath();
189892
190282
  try {
189893
- const content = await readFile23(userPath, "utf-8");
190283
+ const content = await readFile24(userPath, "utf-8");
189894
190284
  const parsed = jsonParse2(content);
189895
190285
  let userBlocks;
189896
190286
  if (typeof parsed === "object" && parsed !== null && "bindings" in parsed) {
@@ -194792,7 +195182,7 @@ var init_common2 = __esm(() => {
194792
195182
  });
194793
195183
 
194794
195184
  // src/tui/services/mcp/config.ts
194795
- import { chmod as chmod2, open as open9, rename as rename2, stat as stat27, unlink as unlink8 } from "fs/promises";
195185
+ import { chmod as chmod2, open as open9, rename as rename2, stat as stat27, unlink as unlink10 } from "fs/promises";
194796
195186
  import { dirname as dirname44, join as join77, parse as parse9 } from "path";
194797
195187
  function getEnterpriseMcpFilePath() {
194798
195188
  return join77(getManagedFilePath(), "managed-mcp.json");
@@ -194836,7 +195226,7 @@ async function writeMcpjsonFile2(config) {
194836
195226
  await rename2(tempPath, mcpJsonPath);
194837
195227
  } catch (e) {
194838
195228
  try {
194839
- await unlink8(tempPath);
195229
+ await unlink10(tempPath);
194840
195230
  } catch {}
194841
195231
  throw e;
194842
195232
  }
@@ -200539,7 +200929,7 @@ var init_IdeOnboardingDialog = __esm(() => {
200539
200929
 
200540
200930
  // src/tui/utils/ide.ts
200541
200931
  import { createConnection } from "net";
200542
- import { basename as basename19, join as join84, sep as pathSeparator, resolve as resolve32 } from "path";
200932
+ import { basename as basename19, join as join84, sep as pathSeparator, resolve as resolve33 } from "path";
200543
200933
  function isProcessRunning3(pid) {
200544
200934
  try {
200545
200935
  process.kill(pid, 0);
@@ -200681,7 +201071,7 @@ async function getIdeLockfilesPaths() {
200681
201071
  if (windowsHome) {
200682
201072
  const converter = new WindowsToWSLConverter(process.env.WSL_DISTRO_NAME);
200683
201073
  const wslPath = converter.toLocalPath(windowsHome);
200684
- paths.push(resolve32(wslPath, getConfigDirName2(), "ide"));
201074
+ paths.push(resolve33(wslPath, getConfigDirName2(), "ide"));
200685
201075
  }
200686
201076
  try {
200687
201077
  const usersDir = "/mnt/c/Users";
@@ -200823,14 +201213,14 @@ async function detectIDEs(includeInvalid) {
200823
201213
  if (!checkWSLDistroMatch(idePath, process.env.WSL_DISTRO_NAME)) {
200824
201214
  return false;
200825
201215
  }
200826
- const resolvedOriginal = resolve32(localPath).normalize("NFC");
201216
+ const resolvedOriginal = resolve33(localPath).normalize("NFC");
200827
201217
  if (cwd === resolvedOriginal || cwd.startsWith(resolvedOriginal + pathSeparator)) {
200828
201218
  return true;
200829
201219
  }
200830
201220
  const converter = new WindowsToWSLConverter(process.env.WSL_DISTRO_NAME);
200831
201221
  localPath = converter.toLocalPath(idePath);
200832
201222
  }
200833
- const resolvedPath = resolve32(localPath).normalize("NFC");
201223
+ const resolvedPath = resolve33(localPath).normalize("NFC");
200834
201224
  if (getPlatform3() === "windows") {
200835
201225
  const normalizedCwd = cwd.replace(/^[a-zA-Z]:/, (match) => match.toUpperCase());
200836
201226
  const normalizedResolvedPath = resolvedPath.replace(/^[a-zA-Z]:/, (match) => match.toUpperCase());
@@ -206335,7 +206725,7 @@ var init_ComputerUseApproval = __esm(() => {
206335
206725
  });
206336
206726
 
206337
206727
  // src/tui/utils/computerUse/computerUseLock.ts
206338
- import { mkdir as mkdir21, readFile as readFile24, unlink as unlink9, writeFile as writeFile14 } from "fs/promises";
206728
+ import { mkdir as mkdir21, readFile as readFile25, unlink as unlink11, writeFile as writeFile14 } from "fs/promises";
206339
206729
  import { join as join87 } from "path";
206340
206730
  function isComputerUseLock(value) {
206341
206731
  if (typeof value !== "object" || value === null)
@@ -206347,7 +206737,7 @@ function getLockPath2() {
206347
206737
  }
206348
206738
  async function readLock2() {
206349
206739
  try {
206350
- const raw = await readFile24(getLockPath2(), "utf8");
206740
+ const raw = await readFile25(getLockPath2(), "utf8");
206351
206741
  const parsed = jsonParse2(raw);
206352
206742
  return isComputerUseLock(parsed) ? parsed : undefined;
206353
206743
  } catch {
@@ -206388,7 +206778,7 @@ async function checkComputerUseLock() {
206388
206778
  return { kind: "blocked", by: existing.sessionId };
206389
206779
  }
206390
206780
  logForDebugging3(`Recovering stale computer-use lock from session ${existing.sessionId} (PID ${existing.pid})`);
206391
- await unlink9(getLockPath2()).catch(() => {});
206781
+ await unlink11(getLockPath2()).catch(() => {});
206392
206782
  return { kind: "free" };
206393
206783
  }
206394
206784
  async function tryAcquireComputerUseLock() {
@@ -206405,7 +206795,7 @@ async function tryAcquireComputerUseLock() {
206405
206795
  }
206406
206796
  const existing = await readLock2();
206407
206797
  if (!existing) {
206408
- await unlink9(getLockPath2()).catch(() => {});
206798
+ await unlink11(getLockPath2()).catch(() => {});
206409
206799
  if (await tryCreateExclusive2(lock)) {
206410
206800
  registerLockCleanup2();
206411
206801
  return FRESH;
@@ -206418,7 +206808,7 @@ async function tryAcquireComputerUseLock() {
206418
206808
  return { kind: "blocked", by: existing.sessionId };
206419
206809
  }
206420
206810
  logForDebugging3(`Recovering stale computer-use lock from session ${existing.sessionId} (PID ${existing.pid})`);
206421
- await unlink9(getLockPath2()).catch(() => {});
206811
+ await unlink11(getLockPath2()).catch(() => {});
206422
206812
  if (await tryCreateExclusive2(lock)) {
206423
206813
  registerLockCleanup2();
206424
206814
  return FRESH;
@@ -206432,7 +206822,7 @@ async function releaseComputerUseLock() {
206432
206822
  if (!existing || existing.sessionId !== getSessionId())
206433
206823
  return false;
206434
206824
  try {
206435
- await unlink9(getLockPath2());
206825
+ await unlink11(getLockPath2());
206436
206826
  logForDebugging3("Released computer-use lock");
206437
206827
  return true;
206438
206828
  } catch {
@@ -210444,7 +210834,7 @@ function createLinkedTransportPair() {
210444
210834
  }
210445
210835
 
210446
210836
  // src/tui/services/mcp/client.ts
210447
- import { mkdir as mkdir22, readFile as readFile25, unlink as unlink10, writeFile as writeFile15 } from "fs/promises";
210837
+ import { mkdir as mkdir22, readFile as readFile26, unlink as unlink12, writeFile as writeFile15 } from "fs/promises";
210448
210838
  import { dirname as dirname45, join as join88 } from "path";
210449
210839
  function isMcpSessionExpiredError(error) {
210450
210840
  const httpStatus = "code" in error ? error.code : undefined;
@@ -210466,7 +210856,7 @@ function getMcpAuthCachePath() {
210466
210856
  }
210467
210857
  function getMcpAuthCache() {
210468
210858
  if (!authCachePromise) {
210469
- authCachePromise = readFile25(getMcpAuthCachePath(), "utf-8").then((data) => jsonParse2(data)).catch(() => ({}));
210859
+ authCachePromise = readFile26(getMcpAuthCachePath(), "utf-8").then((data) => jsonParse2(data)).catch(() => ({}));
210470
210860
  }
210471
210861
  return authCachePromise;
210472
210862
  }
@@ -210490,7 +210880,7 @@ function setMcpAuthCacheEntry(serverId) {
210490
210880
  }
210491
210881
  function clearMcpAuthCache() {
210492
210882
  authCachePromise = null;
210493
- unlink10(getMcpAuthCachePath()).catch(() => {});
210883
+ unlink12(getMcpAuthCachePath()).catch(() => {});
210494
210884
  }
210495
210885
  function handleRemoteAuthFailure(name, serverRef, transportType) {
210496
210886
  const label = {
@@ -212396,13 +212786,13 @@ var init_LSPDiagnosticRegistry = __esm(() => {
212396
212786
  });
212397
212787
 
212398
212788
  // src/tui/utils/plugins/lspPluginIntegration.ts
212399
- import { readFile as readFile26 } from "fs/promises";
212400
- import { join as join89, relative as relative10, resolve as resolve33 } from "path";
212789
+ import { readFile as readFile27 } from "fs/promises";
212790
+ import { join as join89, relative as relative10, resolve as resolve34 } from "path";
212401
212791
  function validatePathWithinPlugin(pluginPath, relativePath) {
212402
- const resolvedPluginPath = resolve33(pluginPath);
212403
- const resolvedFilePath = resolve33(pluginPath, relativePath);
212792
+ const resolvedPluginPath = resolve34(pluginPath);
212793
+ const resolvedFilePath = resolve34(pluginPath, relativePath);
212404
212794
  const rel = relative10(resolvedPluginPath, resolvedFilePath);
212405
- if (rel.startsWith("..") || resolve33(rel) === rel) {
212795
+ if (rel.startsWith("..") || resolve34(rel) === rel) {
212406
212796
  return null;
212407
212797
  }
212408
212798
  return resolvedFilePath;
@@ -212411,7 +212801,7 @@ async function loadPluginLspServers(plugin, errors = []) {
212411
212801
  const servers = {};
212412
212802
  const lspJsonPath = join89(plugin.path, ".lsp.json");
212413
212803
  try {
212414
- const content = await readFile26(lspJsonPath, "utf-8");
212804
+ const content = await readFile27(lspJsonPath, "utf-8");
212415
212805
  const parsed = jsonParse2(content);
212416
212806
  const result = record(string2(), LspServerConfigSchema()).safeParse(parsed);
212417
212807
  if (result.success) {
@@ -212468,7 +212858,7 @@ async function loadLspServersFromManifest(declaration, pluginPath, pluginName, e
212468
212858
  continue;
212469
212859
  }
212470
212860
  try {
212471
- const content = await readFile26(validatedPath, "utf-8");
212861
+ const content = await readFile27(validatedPath, "utf-8");
212472
212862
  const parsed = jsonParse2(content);
212473
212863
  const result = record(string2(), LspServerConfigSchema()).safeParse(parsed);
212474
212864
  if (result.success) {
@@ -217515,9 +217905,9 @@ import {
217515
217905
  copyFile as copyFile3,
217516
217906
  link as link2,
217517
217907
  mkdir as mkdir23,
217518
- readFile as readFile27,
217908
+ readFile as readFile28,
217519
217909
  stat as stat29,
217520
- unlink as unlink11
217910
+ unlink as unlink13
217521
217911
  } from "fs/promises";
217522
217912
  import { dirname as dirname46, isAbsolute as isAbsolute19, join as join90, relative as relative11 } from "path";
217523
217913
  import { inspect as inspect3 } from "util";
@@ -217791,7 +218181,7 @@ async function applySnapshot(state, targetSnapshot) {
217791
218181
  }
217792
218182
  if (backupFileName === null) {
217793
218183
  try {
217794
- await unlink11(filePath);
218184
+ await unlink13(filePath);
217795
218185
  logForDebugging3(`FileHistory: [Rewind] Deleted ${filePath}`);
217796
218186
  filesChanged.push(filePath);
217797
218187
  } catch (e) {
@@ -217832,8 +218222,8 @@ async function checkOriginFileChanged(originalFile, backupFileName, originalStat
217832
218222
  return compareStatsAndContent(originalStats, backupStats, async () => {
217833
218223
  try {
217834
218224
  const [originalContent, backupContent] = await Promise.all([
217835
- readFile27(originalFile, "utf-8"),
217836
- readFile27(backupPath, "utf-8")
218225
+ readFile28(originalFile, "utf-8"),
218226
+ readFile28(backupPath, "utf-8")
217837
218227
  ]);
217838
218228
  return originalContent !== backupContent;
217839
218229
  } catch {
@@ -218094,7 +218484,7 @@ async function notifyVscodeSnapshotFilesUpdated(oldState, newState) {
218094
218484
  }
218095
218485
  async function readFileAsyncOrNull(path) {
218096
218486
  try {
218097
- return await readFile27(path, "utf-8");
218487
+ return await readFile28(path, "utf-8");
218098
218488
  } catch {
218099
218489
  return null;
218100
218490
  }
@@ -218204,13 +218594,13 @@ var init_detectRepository = __esm(() => {
218204
218594
  });
218205
218595
 
218206
218596
  // src/tui/utils/gitDiff.ts
218207
- import { access, readFile as readFile28 } from "fs/promises";
218597
+ import { access, readFile as readFile29 } from "fs/promises";
218208
218598
  import { dirname as dirname47, join as join91, relative as relative12, sep as sep17 } from "path";
218209
218599
  async function fetchGitDiff() {
218210
218600
  const isGit = await getIsGit();
218211
218601
  if (!isGit)
218212
218602
  return null;
218213
- if (await isInTransientGitState()) {
218603
+ if (await checkTransientGitState() !== "none") {
218214
218604
  return null;
218215
218605
  }
218216
218606
  const { stdout: shortstatOut, code: shortstatCode } = await execFileNoThrow3(gitExe2(), ["--no-optional-locks", "diff", "HEAD", "--shortstat"], { timeout: GIT_TIMEOUT_MS, preserveOutputOnError: false });
@@ -218244,7 +218634,7 @@ async function fetchGitDiffHunks() {
218244
218634
  const isGit = await getIsGit();
218245
218635
  if (!isGit)
218246
218636
  return new Map;
218247
- if (await isInTransientGitState()) {
218637
+ if (await checkTransientGitState() !== "none") {
218248
218638
  return new Map;
218249
218639
  }
218250
218640
  const { stdout: diffOut, code: diffCode } = await execFileNoThrow3(gitExe2(), ["--no-optional-locks", "diff", "HEAD"], { timeout: GIT_TIMEOUT_MS, preserveOutputOnError: false });
@@ -218346,18 +218736,19 @@ function parseGitDiff(stdout) {
218346
218736
  }
218347
218737
  return result;
218348
218738
  }
218349
- async function isInTransientGitState() {
218739
+ async function checkTransientGitState() {
218350
218740
  const gitDir = await getGitDir(getCwd());
218351
- if (!gitDir)
218352
- return false;
218353
- const transientFiles = [
218354
- "MERGE_HEAD",
218355
- "REBASE_HEAD",
218356
- "CHERRY_PICK_HEAD",
218357
- "REVERT_HEAD"
218358
- ];
218359
- const results = await Promise.all(transientFiles.map((file) => access(join91(gitDir, file)).then(() => true).catch(() => false)));
218360
- return results.some(Boolean);
218741
+ if (gitDir) {
218742
+ const fileHits = await Promise.all(TRANSIENT_GIT_REFS.map((file) => access(join91(gitDir, file)).then(() => true).catch(() => false)));
218743
+ if (fileHits.some(Boolean))
218744
+ return "transient";
218745
+ }
218746
+ const outcomes = await Promise.all(TRANSIENT_GIT_REFS.map((ref) => execFileNoThrow3(gitExe2(), ["--no-optional-locks", "rev-parse", "--verify", "--quiet", ref], { timeout: GIT_TIMEOUT_MS, preserveOutputOnError: false }).then((result) => result.code === 0 ? "transient" : result.code === 1 ? "none" : "unknown").catch(() => "unknown")));
218747
+ if (outcomes.some((o) => o === "transient"))
218748
+ return "transient";
218749
+ if (outcomes.some((o) => o === "unknown"))
218750
+ return "unknown";
218751
+ return "none";
218361
218752
  }
218362
218753
  async function fetchUntrackedFiles(maxFiles) {
218363
218754
  const { stdout, code } = await execFileNoThrow3(gitExe2(), ["--no-optional-locks", "ls-files", "--others", "--exclude-standard"], { timeout: GIT_TIMEOUT_MS, preserveOutputOnError: false });
@@ -218455,7 +218846,7 @@ async function generateSyntheticDiff(gitPath, absoluteFilePath) {
218455
218846
  if (!isFileWithinReadSizeLimit2(absoluteFilePath, MAX_DIFF_SIZE_BYTES)) {
218456
218847
  return null;
218457
218848
  }
218458
- const content = await readFile28(absoluteFilePath, "utf-8");
218849
+ const content = await readFile29(absoluteFilePath, "utf-8");
218459
218850
  const lines = content.split(`
218460
218851
  `);
218461
218852
  if (lines.length > 0 && lines.at(-1) === "") {
@@ -218478,13 +218869,19 @@ ${addedLines}`;
218478
218869
  return null;
218479
218870
  }
218480
218871
  }
218481
- var GIT_TIMEOUT_MS = 5000, MAX_FILES = 50, MAX_DIFF_SIZE_BYTES = 1e6, MAX_LINES_PER_FILE = 400, MAX_FILES_FOR_DETAILS = 500, SINGLE_FILE_DIFF_TIMEOUT_MS = 3000;
218872
+ var GIT_TIMEOUT_MS = 5000, MAX_FILES = 50, MAX_DIFF_SIZE_BYTES = 1e6, MAX_LINES_PER_FILE = 400, MAX_FILES_FOR_DETAILS = 500, TRANSIENT_GIT_REFS, SINGLE_FILE_DIFF_TIMEOUT_MS = 3000;
218482
218873
  var init_gitDiff = __esm(() => {
218483
218874
  init_cwd3();
218484
218875
  init_detectRepository();
218485
218876
  init_execFileNoThrow2();
218486
218877
  init_file();
218487
218878
  init_git2();
218879
+ TRANSIENT_GIT_REFS = [
218880
+ "MERGE_HEAD",
218881
+ "REBASE_HEAD",
218882
+ "CHERRY_PICK_HEAD",
218883
+ "REVERT_HEAD"
218884
+ ];
218488
218885
  });
218489
218886
 
218490
218887
  // src/tui/memdir/memoryTypes.ts
@@ -254038,7 +254435,7 @@ var init_readEditContext = __esm(() => {
254038
254435
  });
254039
254436
 
254040
254437
  // src/tui/tools/FileWriteTool/UI.tsx
254041
- import { isAbsolute as isAbsolute20, relative as relative14, resolve as resolve35 } from "path";
254438
+ import { isAbsolute as isAbsolute20, relative as relative14, resolve as resolve36 } from "path";
254042
254439
  function countLines(content) {
254043
254440
  const parts = content.split(EOL);
254044
254441
  return content.endsWith(EOL) ? parts.length - 1 : parts.length;
@@ -254362,7 +254759,7 @@ function WriteRejectionBody(t0) {
254362
254759
  }
254363
254760
  async function loadRejectionDiff(filePath, content) {
254364
254761
  try {
254365
- const fullFilePath = isAbsolute20(filePath) ? filePath : resolve35(getCwd(), filePath);
254762
+ const fullFilePath = isAbsolute20(filePath) ? filePath : resolve36(getCwd(), filePath);
254366
254763
  const handle = await openForScan(fullFilePath);
254367
254764
  if (handle === null)
254368
254765
  return {
@@ -256409,7 +256806,7 @@ var init_teammate2 = __esm(() => {
256409
256806
  });
256410
256807
 
256411
256808
  // src/tui/utils/tasks.ts
256412
- import { mkdir as mkdir24, readdir as readdir16, readFile as readFile29, unlink as unlink12, writeFile as writeFile16 } from "fs/promises";
256809
+ import { mkdir as mkdir24, readdir as readdir16, readFile as readFile30, unlink as unlink14, writeFile as writeFile16 } from "fs/promises";
256413
256810
  import { join as join94 } from "path";
256414
256811
  function setLeaderTeamName2(teamName) {
256415
256812
  if (leaderTeamName2 === teamName)
@@ -256434,7 +256831,7 @@ function getHighWaterMarkPath2(taskListId) {
256434
256831
  async function readHighWaterMark2(taskListId) {
256435
256832
  const path = getHighWaterMarkPath2(taskListId);
256436
256833
  try {
256437
- const content = (await readFile29(path, "utf-8")).trim();
256834
+ const content = (await readFile30(path, "utf-8")).trim();
256438
256835
  const value = parseInt(content, 10);
256439
256836
  return isNaN(value) ? 0 : value;
256440
256837
  } catch {
@@ -256474,7 +256871,7 @@ async function resetTaskList2(taskListId) {
256474
256871
  if (file.endsWith(".json") && !file.startsWith(".")) {
256475
256872
  const filePath = join94(dir, file);
256476
256873
  try {
256477
- await unlink12(filePath);
256874
+ await unlink14(filePath);
256478
256875
  } catch {}
256479
256876
  }
256480
256877
  }
@@ -256558,7 +256955,7 @@ async function createTask2(taskListId, taskData) {
256558
256955
  async function getTask2(taskListId, taskId) {
256559
256956
  const path = getTaskPath2(taskListId, taskId);
256560
256957
  try {
256561
- const content = await readFile29(path, "utf-8");
256958
+ const content = await readFile30(path, "utf-8");
256562
256959
  const data = jsonParse2(content);
256563
256960
  const parsed = TaskSchema2().safeParse(data);
256564
256961
  if (!parsed.success) {
@@ -256612,7 +257009,7 @@ async function deleteTask2(taskListId, taskId) {
256612
257009
  }
256613
257010
  }
256614
257011
  try {
256615
- await unlink12(path);
257012
+ await unlink14(path);
256616
257013
  } catch (e) {
256617
257014
  const code = getErrnoCode2(e);
256618
257015
  if (code === "ENOENT") {
@@ -258915,7 +259312,7 @@ var init_outputLimits2 = __esm(() => {
258915
259312
  });
258916
259313
 
258917
259314
  // src/tui/utils/task/TaskOutput.ts
258918
- import { unlink as unlink13 } from "fs/promises";
259315
+ import { unlink as unlink15 } from "fs/promises";
258919
259316
  var DEFAULT_MAX_MEMORY2, POLL_INTERVAL_MS3 = 1000, PROGRESS_TAIL_BYTES2 = 4096, TaskOutput3;
258920
259317
  var init_TaskOutput2 = __esm(() => {
258921
259318
  init_debug();
@@ -259144,7 +259541,7 @@ Output truncated (${sizeKB}KB total). Full output saved to: ${this.path}`;
259144
259541
  }
259145
259542
  async deleteOutputFile() {
259146
259543
  try {
259147
- await unlink13(this.path);
259544
+ await unlink15(this.path);
259148
259545
  } catch {}
259149
259546
  }
259150
259547
  clear() {
@@ -259160,7 +259557,7 @@ Output truncated (${sizeKB}KB total). Full output saved to: ${this.path}`;
259160
259557
  });
259161
259558
 
259162
259559
  // src/tui/utils/sessionEnvironment.ts
259163
- import { mkdir as mkdir25, readdir as readdir17, readFile as readFile30, writeFile as writeFile17 } from "fs/promises";
259560
+ import { mkdir as mkdir25, readdir as readdir17, readFile as readFile31, writeFile as writeFile17 } from "fs/promises";
259164
259561
  import { join as join95 } from "path";
259165
259562
  async function getSessionEnvDirPath() {
259166
259563
  const sessionEnvDir = join95(getAtlasConfigHomeDir3(), "session-env", getSessionId());
@@ -259199,7 +259596,7 @@ async function getSessionEnvironmentScript() {
259199
259596
  const envFile = process.env.ATLAS_SESSION_ENV_FILE;
259200
259597
  if (envFile) {
259201
259598
  try {
259202
- const envScript = (await readFile30(envFile, "utf8")).trim();
259599
+ const envScript = (await readFile31(envFile, "utf8")).trim();
259203
259600
  if (envScript) {
259204
259601
  scripts.push(envScript);
259205
259602
  logForDebugging3(`Session environment loaded from ATLAS_SESSION_ENV_FILE: ${envFile} (${envScript.length} chars)`);
@@ -259218,7 +259615,7 @@ async function getSessionEnvironmentScript() {
259218
259615
  for (const file of hookFiles) {
259219
259616
  const filePath = join95(sessionEnvDir, file);
259220
259617
  try {
259221
- const content = (await readFile30(filePath, "utf8")).trim();
259618
+ const content = (await readFile31(filePath, "utf8")).trim();
259222
259619
  if (content) {
259223
259620
  scripts.push(content);
259224
259621
  }
@@ -260259,7 +260656,7 @@ var init_powershellProvider = __esm(() => {
260259
260656
  import { execFileSync as execFileSync4, spawn as spawn9 } from "child_process";
260260
260657
  import { constants as fsConstants5, readFileSync as readFileSync19, unlinkSync as unlinkSync3 } from "fs";
260261
260658
  import { mkdir as mkdir27, open as open12, realpath as realpath10 } from "fs/promises";
260262
- import { isAbsolute as isAbsolute25, resolve as resolve36 } from "path";
260659
+ import { isAbsolute as isAbsolute25, resolve as resolve37 } from "path";
260263
260660
  import { join as posixJoin3 } from "path/posix";
260264
260661
  import { accessSync as accessSync2 } from "fs";
260265
260662
  function isExecutable2(shellPath) {
@@ -260448,7 +260845,7 @@ async function exec3(command, abortSignal, shellType, options) {
260448
260845
  }
260449
260846
  }
260450
260847
  function setCwd2(path, relativeTo) {
260451
- const resolved = isAbsolute25(path) ? path : resolve36(relativeTo || getFsImplementation2().cwd(), path);
260848
+ const resolved = isAbsolute25(path) ? path : resolve37(relativeTo || getFsImplementation2().cwd(), path);
260452
260849
  let physicalPath;
260453
260850
  try {
260454
260851
  physicalPath = getFsImplementation2().realpathSync(resolved);
@@ -260503,7 +260900,7 @@ var init_Shell2 = __esm(() => {
260503
260900
  });
260504
260901
 
260505
260902
  // src/tui/tools/BashTool/utils.ts
260506
- import { readFile as readFile31, stat as stat33 } from "fs/promises";
260903
+ import { readFile as readFile32, stat as stat33 } from "fs/promises";
260507
260904
  function stripEmptyLines2(content) {
260508
260905
  const lines = content.split(`
260509
260906
  `);
@@ -260555,7 +260952,7 @@ async function resizeShellImageOutput2(stdout, outputFilePath, outputFileSize) {
260555
260952
  const size = outputFileSize ?? (await stat33(outputFilePath)).size;
260556
260953
  if (size > MAX_IMAGE_FILE_SIZE2)
260557
260954
  return null;
260558
- source = await readFile31(outputFilePath, "utf8");
260955
+ source = await readFile32(outputFilePath, "utf8");
260559
260956
  }
260560
260957
  const parsed = parseDataUri2(source);
260561
260958
  if (!parsed)
@@ -261049,7 +261446,7 @@ var init_UI8 = __esm(() => {
261049
261446
  });
261050
261447
 
261051
261448
  // src/tui/tools/NotebookEditTool/NotebookEditTool.ts
261052
- import { extname as extname13, isAbsolute as isAbsolute26, resolve as resolve37 } from "path";
261449
+ import { extname as extname13, isAbsolute as isAbsolute26, resolve as resolve38 } from "path";
261053
261450
  var inputSchema12, outputSchema10, NotebookEditTool2;
261054
261451
  var init_NotebookEditTool = __esm(() => {
261055
261452
  init_shared();
@@ -261163,7 +261560,7 @@ var init_NotebookEditTool = __esm(() => {
261163
261560
  renderToolUseErrorMessage: renderToolUseErrorMessage5,
261164
261561
  renderToolResultMessage: renderToolResultMessage8,
261165
261562
  async validateInput({ notebook_path, cell_type, cell_id, edit_mode = "replace" }, toolUseContext) {
261166
- const fullPath = isAbsolute26(notebook_path) ? notebook_path : resolve37(getCwd(), notebook_path);
261563
+ const fullPath = isAbsolute26(notebook_path) ? notebook_path : resolve38(getCwd(), notebook_path);
261167
261564
  if (fullPath.startsWith("\\\\") || fullPath.startsWith("//")) {
261168
261565
  return { result: true };
261169
261566
  }
@@ -261262,7 +261659,7 @@ var init_NotebookEditTool = __esm(() => {
261262
261659
  cell_type,
261263
261660
  edit_mode: originalEditMode
261264
261661
  }, { readFileState, updateFileHistoryState }, _, parentMessage) {
261265
- const fullPath = isAbsolute26(notebook_path) ? notebook_path : resolve37(getCwd(), notebook_path);
261662
+ const fullPath = isAbsolute26(notebook_path) ? notebook_path : resolve38(getCwd(), notebook_path);
261266
261663
  if (fileHistoryEnabled()) {
261267
261664
  await fileHistoryTrackEdit(updateFileHistoryState, fullPath, parentMessage.uuid);
261268
261665
  }
@@ -263179,7 +263576,7 @@ var init_fileStateCache = __esm(() => {
263179
263576
  });
263180
263577
 
263181
263578
  // src/tui/utils/hooks/hooksSettings.ts
263182
- import { resolve as resolve38 } from "path";
263579
+ import { resolve as resolve39 } from "path";
263183
263580
  function isHookEqual(a, b) {
263184
263581
  if (a.type !== b.type)
263185
263582
  return false;
@@ -263230,7 +263627,7 @@ function getAllHooks(appState) {
263230
263627
  for (const source of sources) {
263231
263628
  const filePath = getSettingsFilePathForSource2(source);
263232
263629
  if (filePath) {
263233
- const resolvedPath = resolve38(filePath);
263630
+ const resolvedPath = resolve39(filePath);
263234
263631
  if (seenFiles.has(resolvedPath)) {
263235
263632
  continue;
263236
263633
  }
@@ -267369,7 +267766,7 @@ __export(exports_teammateMailbox, {
267369
267766
  sendShutdownRequestToMailbox: () => sendShutdownRequestToMailbox2,
267370
267767
  writeToMailbox: () => writeToMailbox2
267371
267768
  });
267372
- import { mkdir as mkdir28, readFile as readFile32, writeFile as writeFile18 } from "fs/promises";
267769
+ import { mkdir as mkdir28, readFile as readFile33, writeFile as writeFile18 } from "fs/promises";
267373
267770
  import { join as join100 } from "path";
267374
267771
  function getInboxPath2(agentName, teamName) {
267375
267772
  const team = teamName || getTeamName2() || "default";
@@ -267391,7 +267788,7 @@ async function readMailbox2(agentName, teamName) {
267391
267788
  const inboxPath = getInboxPath2(agentName, teamName);
267392
267789
  logForDebugging3(`[TeammateMailbox] readMailbox: path=${inboxPath}`);
267393
267790
  try {
267394
- const content = await readFile32(inboxPath, "utf-8");
267791
+ const content = await readFile33(inboxPath, "utf-8");
267395
267792
  const messages = jsonParse2(content);
267396
267793
  logForDebugging3(`[TeammateMailbox] readMailbox: read ${messages.length} message(s)`);
267397
267794
  return messages;
@@ -295743,7 +296140,7 @@ var init_listSessionsImpl = __esm(() => {
295743
296140
  });
295744
296141
 
295745
296142
  // src/tui/services/autoDream/consolidationLock.ts
295746
- import { mkdir as mkdir30, readFile as readFile33, stat as stat35, unlink as unlink14, utimes as utimes3, writeFile as writeFile20 } from "fs/promises";
296143
+ import { mkdir as mkdir30, readFile as readFile34, stat as stat35, unlink as unlink16, utimes as utimes3, writeFile as writeFile20 } from "fs/promises";
295747
296144
  import { join as join103 } from "path";
295748
296145
  function lockPath() {
295749
296146
  return join103(getAutoMemPath2(), LOCK_FILE);
@@ -295761,7 +296158,7 @@ async function tryAcquireConsolidationLock() {
295761
296158
  let mtimeMs;
295762
296159
  let holderPid;
295763
296160
  try {
295764
- const [s, raw] = await Promise.all([stat35(path), readFile33(path, "utf8")]);
296161
+ const [s, raw] = await Promise.all([stat35(path), readFile34(path, "utf8")]);
295765
296162
  mtimeMs = s.mtimeMs;
295766
296163
  const parsed = parseInt(raw.trim(), 10);
295767
296164
  holderPid = Number.isFinite(parsed) ? parsed : undefined;
@@ -295776,7 +296173,7 @@ async function tryAcquireConsolidationLock() {
295776
296173
  await writeFile20(path, String(process.pid));
295777
296174
  let verify;
295778
296175
  try {
295779
- verify = await readFile33(path, "utf8");
296176
+ verify = await readFile34(path, "utf8");
295780
296177
  } catch {
295781
296178
  return null;
295782
296179
  }
@@ -295788,7 +296185,7 @@ async function rollbackConsolidationLock(priorMtime) {
295788
296185
  const path = lockPath();
295789
296186
  try {
295790
296187
  if (priorMtime === 0) {
295791
- await unlink14(path);
296188
+ await unlink16(path);
295792
296189
  return;
295793
296190
  }
295794
296191
  await writeFile20(path, "");
@@ -300223,6 +300620,7 @@ var init_EnterWorktreeTool = __esm(() => {
300223
300620
  init_memoryFiles();
300224
300621
  init_cwd3();
300225
300622
  init_git2();
300623
+ init_gitFilesystem();
300226
300624
  init_plans();
300227
300625
  init_Shell2();
300228
300626
  init_sessionStorage();
@@ -300272,12 +300670,18 @@ var init_EnterWorktreeTool = __esm(() => {
300272
300670
  throw new Error("Already in a worktree session");
300273
300671
  }
300274
300672
  const mainRepoRoot = findCanonicalGitRoot2(getCwd());
300673
+ let sourceCheckout;
300275
300674
  if (mainRepoRoot && mainRepoRoot !== getCwd()) {
300675
+ const callingCwd = getCwd();
300676
+ const headCommit = await readCheckoutHeadSha2(callingCwd);
300677
+ if (headCommit) {
300678
+ sourceCheckout = { cwd: callingCwd, headCommit };
300679
+ }
300276
300680
  process.chdir(mainRepoRoot);
300277
300681
  setCwd2(mainRepoRoot);
300278
300682
  }
300279
300683
  const slug = input.name ?? getPlanSlug2();
300280
- const worktreeSession = await createWorktreeForSession2(getSessionId(), slug);
300684
+ const worktreeSession = await createWorktreeForSession2(getSessionId(), slug, undefined, sourceCheckout ? { sourceCheckout } : undefined);
300281
300685
  process.chdir(worktreeSession.worktreePath);
300282
300686
  setCwd2(worktreeSession.worktreePath);
300283
300687
  setOriginalCwd(getCwd());
@@ -301198,7 +301602,7 @@ __export(exports_voice2, {
301198
301602
  stopRecording: () => stopRecording
301199
301603
  });
301200
301604
  import { spawn as spawn10, spawnSync as spawnSync3 } from "child_process";
301201
- import { readFile as readFile34 } from "fs/promises";
301605
+ import { readFile as readFile35 } from "fs/promises";
301202
301606
  function loadAudioNapi() {
301203
301607
  audioNapiPromise ??= (async () => {
301204
301608
  const t0 = Date.now();
@@ -301253,7 +301657,7 @@ function _resetArecordProbeForTesting() {
301253
301657
  arecordProbe = null;
301254
301658
  }
301255
301659
  function linuxHasAlsaCards() {
301256
- linuxAlsaCardsMemo ??= readFile34("/proc/asound/cards", "utf8").then((cards) => {
301660
+ linuxAlsaCardsMemo ??= readFile35("/proc/asound/cards", "utf8").then((cards) => {
301257
301661
  const c = cards.trim();
301258
301662
  return c !== "" && !c.includes("no soundcards");
301259
301663
  }, () => false);
@@ -311276,7 +311680,7 @@ var init_registry3 = __esm(() => {
311276
311680
 
311277
311681
  // src/tui/utils/swarm/teamHelpers.ts
311278
311682
  import { mkdirSync as mkdirSync7, readFileSync as readFileSync21, writeFileSync as writeFileSync6 } from "fs";
311279
- import { mkdir as mkdir32, readFile as readFile35, rm as rm3, writeFile as writeFile23 } from "fs/promises";
311683
+ import { mkdir as mkdir32, readFile as readFile36, rm as rm3, writeFile as writeFile23 } from "fs/promises";
311280
311684
  import { join as join105 } from "path";
311281
311685
  function sanitizeName3(name) {
311282
311686
  return name.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
@@ -311300,7 +311704,7 @@ function readTeamFile2(teamName) {
311300
311704
  }
311301
311705
  async function readTeamFileAsync2(teamName) {
311302
311706
  try {
311303
- const content = await readFile35(getTeamFilePath2(teamName), "utf-8");
311707
+ const content = await readFile36(getTeamFilePath2(teamName), "utf-8");
311304
311708
  return jsonParse2(content);
311305
311709
  } catch (e) {
311306
311710
  if (getErrnoCode2(e) === "ENOENT")
@@ -311450,7 +311854,7 @@ async function destroyWorktree2(worktreePath) {
311450
311854
  const gitFilePath = join105(worktreePath, ".git");
311451
311855
  let mainRepoPath = null;
311452
311856
  try {
311453
- const gitFileContent = (await readFile35(gitFilePath, "utf-8")).trim();
311857
+ const gitFileContent = (await readFile36(gitFilePath, "utf-8")).trim();
311454
311858
  const match = gitFileContent.match(/^gitdir:\s*(.+)$/);
311455
311859
  if (match && match[1]) {
311456
311860
  const worktreeGitDir = match[1];
@@ -313693,7 +314097,7 @@ var exports_SpecParser = {};
313693
314097
  __export(exports_SpecParser, {
313694
314098
  SpecParser: () => SpecParser2
313695
314099
  });
313696
- import { readFile as readFile36 } from "fs/promises";
314100
+ import { readFile as readFile37 } from "fs/promises";
313697
314101
  var inputSchema42, outputSchema34, SpecParser2;
313698
314102
  var init_SpecParser = __esm(() => {
313699
314103
  init_v4();
@@ -313736,7 +314140,7 @@ var init_SpecParser = __esm(() => {
313736
314140
  let raw = inp.spec_source;
313737
314141
  let parsedFromFile = false;
313738
314142
  try {
313739
- const fileContent = await readFile36(inp.spec_source, "utf-8");
314143
+ const fileContent = await readFile37(inp.spec_source, "utf-8");
313740
314144
  raw = fileContent;
313741
314145
  parsedFromFile = true;
313742
314146
  } catch {}
@@ -316879,7 +317283,7 @@ var init_parser7 = __esm(() => {
316879
317283
  });
316880
317284
 
316881
317285
  // src/tui/tools/PowerShellTool/gitSafety.ts
316882
- import { basename as basename29, posix as posix7, resolve as resolve39, sep as sep23 } from "path";
317286
+ import { basename as basename29, posix as posix7, resolve as resolve40, sep as sep23 } from "path";
316883
317287
  function resolveCwdReentry(normalized) {
316884
317288
  if (!normalized.startsWith("../"))
316885
317289
  return normalized;
@@ -316927,7 +317331,7 @@ function normalizeGitPathArg(arg) {
316927
317331
  }
316928
317332
  function resolveEscapingPathToCwdRelative(n) {
316929
317333
  const cwd = getCwd();
316930
- const abs = resolve39(cwd, n);
317334
+ const abs = resolve40(cwd, n);
316931
317335
  const cwdWithSep = cwd.endsWith(sep23) ? cwd : cwd + sep23;
316932
317336
  const absLower = abs.toLowerCase();
316933
317337
  const cwdLower = cwd.toLowerCase();
@@ -318167,7 +318571,7 @@ var init_modeValidation3 = __esm(() => {
318167
318571
 
318168
318572
  // src/tui/tools/PowerShellTool/pathValidation.ts
318169
318573
  import { homedir as homedir29 } from "os";
318170
- import { isAbsolute as isAbsolute27, resolve as resolve40 } from "path";
318574
+ import { isAbsolute as isAbsolute27, resolve as resolve41 } from "path";
318171
318575
  function matchesParam(paramLower, paramList) {
318172
318576
  for (const p of paramList) {
318173
318577
  if (p === paramLower || paramLower.length > 1 && p.startsWith(paramLower)) {
@@ -318275,7 +318679,7 @@ function checkDenyRuleForGuessedPath(strippedPath, cwd, toolPermissionContext, o
318275
318679
  if (!strippedPath || strippedPath.includes("\x00"))
318276
318680
  return null;
318277
318681
  const tildeExpanded = expandTilde3(strippedPath);
318278
- const abs = isAbsolute27(tildeExpanded) ? tildeExpanded : resolve40(cwd, tildeExpanded);
318682
+ const abs = isAbsolute27(tildeExpanded) ? tildeExpanded : resolve41(cwd, tildeExpanded);
318279
318683
  const { resolvedPath } = safeResolvePath3(getFsImplementation2(), abs);
318280
318684
  const permissionType = operationType === "read" ? "read" : "edit";
318281
318685
  const denyRule = matchingRuleForInput2(resolvedPath, toolPermissionContext, permissionType, "deny");
@@ -318365,7 +318769,7 @@ function validatePath3(filePath, cwd, toolPermissionContext, operationType) {
318365
318769
  };
318366
318770
  }
318367
318771
  if (containsPathTraversal2(normalizedPath)) {
318368
- const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve40(cwd, normalizedPath);
318772
+ const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve41(cwd, normalizedPath);
318369
318773
  const { resolvedPath, isCanonical } = safeResolvePath3(getFsImplementation2(), absolutePath);
318370
318774
  const result = isPathAllowed2(resolvedPath, toolPermissionContext, operationType, isCanonical ? [resolvedPath] : undefined);
318371
318775
  return {
@@ -318375,7 +318779,7 @@ function validatePath3(filePath, cwd, toolPermissionContext, operationType) {
318375
318779
  };
318376
318780
  }
318377
318781
  const basePath = getGlobBaseDirectory2(normalizedPath);
318378
- const absoluteBasePath = isAbsolute27(basePath) ? basePath : resolve40(cwd, basePath);
318782
+ const absoluteBasePath = isAbsolute27(basePath) ? basePath : resolve41(cwd, basePath);
318379
318783
  const { resolvedPath } = safeResolvePath3(getFsImplementation2(), absoluteBasePath);
318380
318784
  const permissionType = operationType === "read" ? "read" : "edit";
318381
318785
  const denyRule = matchingRuleForInput2(resolvedPath, toolPermissionContext, permissionType, "deny");
@@ -318395,7 +318799,7 @@ function validatePath3(filePath, cwd, toolPermissionContext, operationType) {
318395
318799
  }
318396
318800
  };
318397
318801
  }
318398
- const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve40(cwd, normalizedPath);
318802
+ const absolutePath = isAbsolute27(normalizedPath) ? normalizedPath : resolve41(cwd, normalizedPath);
318399
318803
  const { resolvedPath, isCanonical } = safeResolvePath3(getFsImplementation2(), absolutePath);
318400
318804
  const result = isPathAllowed2(resolvedPath, toolPermissionContext, operationType, isCanonical ? [resolvedPath] : undefined);
318401
318805
  return {
@@ -320309,7 +320713,7 @@ var init_powershellSecurity = __esm(() => {
320309
320713
  });
320310
320714
 
320311
320715
  // src/tui/tools/PowerShellTool/powershellPermissions.ts
320312
- import { resolve as resolve41 } from "path";
320716
+ import { resolve as resolve42 } from "path";
320313
320717
  async function extractCommandName(command) {
320314
320718
  const trimmed = command.trim();
320315
320719
  if (!trimmed) {
@@ -320922,7 +321326,7 @@ async function powershellToolHasPermission(input, context) {
320922
321326
  const canonical = resolveToCanonical(element.name);
320923
321327
  if (canonical === "set-location" && element.args.length > 0) {
320924
321328
  const target = element.args.find((a) => a.length === 0 || !PS_TOKENIZER_DASH_CHARS.has(a[0]));
320925
- if (target && resolve41(getCwd(), target) === getCwd()) {
321329
+ if (target && resolve42(getCwd(), target) === getCwd()) {
320926
321330
  return false;
320927
321331
  }
320928
321332
  }
@@ -327496,7 +327900,7 @@ var init_toolSearch = __esm(() => {
327496
327900
 
327497
327901
  // src/tui/services/vcr.ts
327498
327902
  import { createHash as createHash8, randomUUID as randomUUID33 } from "crypto";
327499
- import { mkdir as mkdir34, readFile as readFile37, writeFile as writeFile24 } from "fs/promises";
327903
+ import { mkdir as mkdir34, readFile as readFile38, writeFile as writeFile24 } from "fs/promises";
327500
327904
  import { dirname as dirname57, join as join109 } from "path";
327501
327905
  function shouldUseVCR() {
327502
327906
  if (false) {}
@@ -327512,7 +327916,7 @@ async function withFixture(input, fixtureName, f) {
327512
327916
  const hash = createHash8("sha1").update(jsonStringify5(input)).digest("hex").slice(0, 12);
327513
327917
  const filename = join109(process.env.ATLAS_TEST_FIXTURES_ROOT ?? getCwd(), `fixtures/${fixtureName}-${hash}.json`);
327514
327918
  try {
327515
- const cached = jsonParse2(await readFile37(filename, { encoding: "utf8" }));
327919
+ const cached = jsonParse2(await readFile38(filename, { encoding: "utf8" }));
327516
327920
  return cached;
327517
327921
  } catch (e) {
327518
327922
  const code = getErrnoCode2(e);
@@ -327734,7 +328138,7 @@ var init_tokenEstimation = __esm(() => {
327734
328138
 
327735
328139
  // src/tui/utils/pdf.ts
327736
328140
  import { randomUUID as randomUUID34 } from "crypto";
327737
- import { mkdir as mkdir35, readdir as readdir19, readFile as readFile38 } from "fs/promises";
328141
+ import { mkdir as mkdir35, readdir as readdir19, readFile as readFile39 } from "fs/promises";
327738
328142
  import { join as join110 } from "path";
327739
328143
  async function readPDF2(filePath) {
327740
328144
  try {
@@ -327756,7 +328160,7 @@ async function readPDF2(filePath) {
327756
328160
  }
327757
328161
  };
327758
328162
  }
327759
- const fileBuffer = await readFile38(filePath);
328163
+ const fileBuffer = await readFile39(filePath);
327760
328164
  const header = fileBuffer.subarray(0, 5).toString("ascii");
327761
328165
  if (!header.startsWith("%PDF-")) {
327762
328166
  return {
@@ -327931,7 +328335,7 @@ var init_pdf2 = __esm(() => {
327931
328335
 
327932
328336
  // src/tui/utils/readFileInRange.ts
327933
328337
  import { createReadStream as createReadStream3, fstat as fstat2 } from "fs";
327934
- import { stat as fsStat3, readFile as readFile39 } from "fs/promises";
328338
+ import { stat as fsStat3, readFile as readFile40 } from "fs/promises";
327935
328339
  async function readFileInRange2(filePath, offset = 0, maxLines, maxBytes, signal, options) {
327936
328340
  signal?.throwIfAborted();
327937
328341
  const truncateOnByteLimit = options?.truncateOnByteLimit ?? false;
@@ -327943,7 +328347,7 @@ async function readFileInRange2(filePath, offset = 0, maxLines, maxBytes, signal
327943
328347
  if (!truncateOnByteLimit && maxBytes !== undefined && stats.size > maxBytes) {
327944
328348
  throw new FileTooLargeError2(stats.size, maxBytes);
327945
328349
  }
327946
- const text = await readFile39(filePath, { encoding: "utf8", signal });
328350
+ const text = await readFile40(filePath, { encoding: "utf8", signal });
327947
328351
  return readFileInRangeFast2(text, stats.mtimeMs, offset, maxLines, truncateOnByteLimit ? maxBytes : undefined);
327948
328352
  }
327949
328353
  return readFileInRangeStreaming2(filePath, offset, maxLines, maxBytes, truncateOnByteLimit, signal);
@@ -329357,7 +329761,7 @@ var init_findRelevantMemories = __esm(() => {
329357
329761
 
329358
329762
  // src/tui/utils/attachments.ts
329359
329763
  import { readdir as readdir21, stat as stat37 } from "fs/promises";
329360
- import { dirname as dirname58, parse as parse12, relative as relative21, resolve as resolve42 } from "path";
329764
+ import { dirname as dirname58, parse as parse12, relative as relative21, resolve as resolve43 } from "path";
329361
329765
  import { randomUUID as randomUUID35 } from "crypto";
329362
329766
  async function getAttachments(input, toolUseContext, ideSelection, queuedCommands, messages, querySource, options) {
329363
329767
  if (isEnvTruthy2(process.env.ATLAS_DISABLE_ATTACHMENTS) || isEnvTruthy2(process.env.ATLAS_SIMPLE)) {
@@ -329778,7 +330182,7 @@ async function getSelectedLinesFromIDE(ideSelection, toolUseContext) {
329778
330182
  ];
329779
330183
  }
329780
330184
  function getDirectoriesToProcess(targetPath, originalCwd) {
329781
- const targetDir = dirname58(resolve42(targetPath));
330185
+ const targetDir = dirname58(resolve43(targetPath));
329782
330186
  const nestedDirs = [];
329783
330187
  let currentDir = targetDir;
329784
330188
  while (currentDir !== originalCwd && currentDir !== parse12(currentDir).root) {
@@ -330077,7 +330481,7 @@ async function getDynamicSkillAttachments(toolUseContext) {
330077
330481
  const candidates = entries.filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => e.name);
330078
330482
  const checked = await Promise.all(candidates.map(async (name) => {
330079
330483
  try {
330080
- await stat37(resolve42(skillDir, name, "SKILL.md"));
330484
+ await stat37(resolve43(skillDir, name, "SKILL.md"));
330081
330485
  return name;
330082
330486
  } catch {
330083
330487
  return null;
@@ -331504,9 +331908,9 @@ var init_zip = __esm(() => {
331504
331908
  import { randomBytes as randomBytes14 } from "crypto";
331505
331909
  import {
331506
331910
  chmod as chmod4,
331507
- lstat as lstat5,
331911
+ lstat as lstat7,
331508
331912
  readdir as readdir22,
331509
- readFile as readFile40,
331913
+ readFile as readFile41,
331510
331914
  rename as rename3,
331511
331915
  rm as rm5,
331512
331916
  stat as stat38,
@@ -331590,7 +331994,7 @@ async function collectFilesForZip(baseDir, relativePath, files, visited) {
331590
331994
  const relPath = relativePath ? `${relativePath}/${entry}` : entry;
331591
331995
  let fileStat;
331592
331996
  try {
331593
- fileStat = await lstat5(fullPath);
331997
+ fileStat = await lstat7(fullPath);
331594
331998
  } catch {
331595
331999
  continue;
331596
332000
  }
@@ -331609,7 +332013,7 @@ async function collectFilesForZip(baseDir, relativePath, files, visited) {
331609
332013
  await collectFilesForZip(baseDir, relPath, files, visited);
331610
332014
  } else if (fileStat.isFile()) {
331611
332015
  try {
331612
- const content = await readFile40(fullPath);
332016
+ const content = await readFile41(fullPath);
331613
332017
  files[relPath] = [
331614
332018
  new Uint8Array(content),
331615
332019
  { os: 3, attrs: (fileStat.mode & 65535) << 16 }
@@ -331655,7 +332059,7 @@ var init_zipCache = __esm(() => {
331655
332059
  });
331656
332060
 
331657
332061
  // src/tui/utils/plugins/cacheUtils.ts
331658
- import { readdir as readdir23, rm as rm6, stat as stat39, unlink as unlink15, writeFile as writeFile26 } from "fs/promises";
332062
+ import { readdir as readdir23, rm as rm6, stat as stat39, unlink as unlink17, writeFile as writeFile26 } from "fs/promises";
331659
332063
  import { join as join115 } from "path";
331660
332064
  function clearAllPluginCaches() {
331661
332065
  clearPluginCache();
@@ -331716,7 +332120,7 @@ function getOrphanedAtPath(versionPath) {
331716
332120
  async function removeOrphanedAtMarker(versionPath) {
331717
332121
  const orphanedAtPath = getOrphanedAtPath(versionPath);
331718
332122
  try {
331719
- await unlink15(orphanedAtPath);
332123
+ await unlink17(orphanedAtPath);
331720
332124
  } catch (error) {
331721
332125
  const code = getErrnoCode2(error);
331722
332126
  if (code === "ENOENT")
@@ -332143,11 +332547,11 @@ var init_marketplaceHelpers = __esm(() => {
332143
332547
  });
332144
332548
 
332145
332549
  // src/tui/utils/plugins/officialMarketplaceGcs.ts
332146
- import { chmod as chmod5, mkdir as mkdir36, readFile as readFile41, rename as rename4, rm as rm7, writeFile as writeFile27 } from "fs/promises";
332147
- import { dirname as dirname61, join as join116, resolve as resolve43, sep as sep24 } from "path";
332550
+ import { chmod as chmod5, mkdir as mkdir36, readFile as readFile42, rename as rename4, rm as rm7, writeFile as writeFile27 } from "fs/promises";
332551
+ import { dirname as dirname61, join as join116, resolve as resolve44, sep as sep24 } from "path";
332148
332552
  async function fetchOfficialMarketplaceFromGcs(installLocation, marketplacesCacheDir) {
332149
- const cacheDir = resolve43(marketplacesCacheDir);
332150
- const resolvedLoc = resolve43(installLocation);
332553
+ const cacheDir = resolve44(marketplacesCacheDir);
332554
+ const resolvedLoc = resolve44(installLocation);
332151
332555
  if (resolvedLoc !== cacheDir && !resolvedLoc.startsWith(cacheDir + sep24)) {
332152
332556
  logForDebugging3(`fetchOfficialMarketplaceFromGcs: refusing path outside cache dir: ${installLocation}`, { level: "error" });
332153
332557
  return null;
@@ -332168,7 +332572,7 @@ async function fetchOfficialMarketplaceFromGcs(installLocation, marketplacesCach
332168
332572
  throw new Error("latest pointer returned empty body");
332169
332573
  }
332170
332574
  const sentinelPath = join116(installLocation, ".gcs-sha");
332171
- const currentSha = await readFile41(sentinelPath, "utf8").then((s) => s.trim(), () => null);
332575
+ const currentSha = await readFile42(sentinelPath, "utf8").then((s) => s.trim(), () => null);
332172
332576
  if (currentSha === sha) {
332173
332577
  outcome = "noop";
332174
332578
  return sha;
@@ -332281,7 +332685,7 @@ var init_ascendMarketplace = __esm(() => {
332281
332685
  });
332282
332686
 
332283
332687
  // src/tui/utils/plugins/orphanScanner.ts
332284
- import { join as join117, resolve as resolve44, sep as sep25 } from "path";
332688
+ import { join as join117, resolve as resolve45, sep as sep25 } from "path";
332285
332689
  function normalizeRepoRef(ref) {
332286
332690
  let u = ref.trim();
332287
332691
  const ssh = u.match(/^git@([^:]+):(.+)$/);
@@ -332325,7 +332729,7 @@ async function readOrphanManifestName(dirPath) {
332325
332729
  }
332326
332730
  async function scanOrphanedMarketplaces() {
332327
332731
  const fs = getFsImplementation2();
332328
- const cacheDir = resolve44(getMarketplacesCacheDir());
332732
+ const cacheDir = resolve45(getMarketplacesCacheDir());
332329
332733
  let entries;
332330
332734
  try {
332331
332735
  entries = await fs.readdir(cacheDir);
@@ -332333,8 +332737,8 @@ async function scanOrphanedMarketplaces() {
332333
332737
  return [];
332334
332738
  }
332335
332739
  const config = await loadKnownMarketplacesConfigSafe();
332336
- const registered = new Set(Object.values(config).map((e) => resolve44(e.installLocation)));
332337
- const seedDirs = getPluginSeedDirs().map((d) => resolve44(d));
332740
+ const registered = new Set(Object.values(config).map((e) => resolve45(e.installLocation)));
332741
+ const seedDirs = getPluginSeedDirs().map((d) => resolve45(d));
332338
332742
  const orphans = [];
332339
332743
  for (const entry of entries) {
332340
332744
  if (!entry.isDirectory())
@@ -332372,7 +332776,7 @@ var init_orphanScanner = __esm(() => {
332372
332776
 
332373
332777
  // src/tui/utils/plugins/marketplaceManager.ts
332374
332778
  import { writeFile as writeFile28 } from "fs/promises";
332375
- import { basename as basename35, dirname as dirname62, isAbsolute as isAbsolute31, join as join118, resolve as resolve45, sep as sep26 } from "path";
332779
+ import { basename as basename35, dirname as dirname62, isAbsolute as isAbsolute31, join as join118, resolve as resolve46, sep as sep26 } from "path";
332376
332780
  function getKnownMarketplacesFile() {
332377
332781
  return join118(getPluginsDirectory(), "known_marketplaces.json");
332378
332782
  }
@@ -332578,7 +332982,7 @@ function getPluginGitTimeoutMs() {
332578
332982
  }
332579
332983
  async function gitPull(cwd, ref, options) {
332580
332984
  logForDebugging3(`git pull: cwd=${cwd} ref=${ref ?? "default"}`);
332581
- const env = { ...process.env, ...GIT_NO_PROMPT_ENV3 };
332985
+ const env = { ...process.env, ...GIT_NO_PROMPT_ENV4 };
332582
332986
  const credentialArgs = options?.disableCredentialHelper ? ["-c", "credential.helper="] : [];
332583
332987
  if (ref) {
332584
332988
  const fetchResult = await execFileNoThrowWithCwd2(gitExe2(), [...credentialArgs, "fetch", "origin", ref], { cwd, timeout: getPluginGitTimeoutMs(), stdin: "ignore", env });
@@ -332726,7 +333130,7 @@ async function gitClone(gitUrl, targetPath, ref, sparsePaths) {
332726
333130
  const result = await execFileNoThrowWithCwd2(gitExe2(), args, {
332727
333131
  timeout: timeoutMs,
332728
333132
  stdin: "ignore",
332729
- env: { ...process.env, ...GIT_NO_PROMPT_ENV3 }
333133
+ env: { ...process.env, ...GIT_NO_PROMPT_ENV4 }
332730
333134
  });
332731
333135
  const redacted = redactUrlCredentials(gitUrl);
332732
333136
  if (gitUrl !== redacted) {
@@ -332741,7 +333145,7 @@ async function gitClone(gitUrl, targetPath, ref, sparsePaths) {
332741
333145
  cwd: targetPath,
332742
333146
  timeout: timeoutMs,
332743
333147
  stdin: "ignore",
332744
- env: { ...process.env, ...GIT_NO_PROMPT_ENV3 }
333148
+ env: { ...process.env, ...GIT_NO_PROMPT_ENV4 }
332745
333149
  });
332746
333150
  if (sparseResult.code !== 0) {
332747
333151
  return {
@@ -332753,7 +333157,7 @@ async function gitClone(gitUrl, targetPath, ref, sparsePaths) {
332753
333157
  cwd: targetPath,
332754
333158
  timeout: timeoutMs,
332755
333159
  stdin: "ignore",
332756
- env: { ...process.env, ...GIT_NO_PROMPT_ENV3 }
333160
+ env: { ...process.env, ...GIT_NO_PROMPT_ENV4 }
332757
333161
  });
332758
333162
  if (checkoutResult.code !== 0) {
332759
333163
  return {
@@ -332845,7 +333249,7 @@ function safeCallProgress(onProgress, message) {
332845
333249
  }
332846
333250
  }
332847
333251
  async function reconcileSparseCheckout(cwd, sparsePaths) {
332848
- const env = { ...process.env, ...GIT_NO_PROMPT_ENV3 };
333252
+ const env = { ...process.env, ...GIT_NO_PROMPT_ENV4 };
332849
333253
  if (sparsePaths && sparsePaths.length > 0) {
332850
333254
  return execFileNoThrowWithCwd2(gitExe2(), ["sparse-checkout", "set", "--cone", "--", ...sparsePaths], { cwd, timeout: getPluginGitTimeoutMs(), stdin: "ignore", env });
332851
333255
  }
@@ -333170,14 +333574,14 @@ async function loadAndCacheMarketplace(source, onProgress) {
333170
333574
  break;
333171
333575
  }
333172
333576
  case "file": {
333173
- const absPath = resolve45(source.path);
333577
+ const absPath = resolve46(source.path);
333174
333578
  marketplacePath = absPath;
333175
333579
  temporaryCachePath = dirname62(dirname62(absPath));
333176
333580
  cleanupNeeded = false;
333177
333581
  break;
333178
333582
  }
333179
333583
  case "directory": {
333180
- const absPath = resolve45(source.path);
333584
+ const absPath = resolve46(source.path);
333181
333585
  marketplacePath = findManifestInDir(absPath, "marketplace.json");
333182
333586
  temporaryCachePath = absPath;
333183
333587
  cleanupNeeded = false;
@@ -333209,8 +333613,8 @@ async function loadAndCacheMarketplace(source, onProgress) {
333209
333613
  throw new Error(`Failed to parse marketplace file at ${marketplacePath}: ${errorMessage2(e)}`);
333210
333614
  }
333211
333615
  const finalCachePath = join118(cacheDir, marketplace.name);
333212
- const resolvedFinal = resolve45(finalCachePath);
333213
- const resolvedCacheDir = resolve45(cacheDir);
333616
+ const resolvedFinal = resolve46(finalCachePath);
333617
+ const resolvedCacheDir = resolve46(cacheDir);
333214
333618
  if (!resolvedFinal.startsWith(resolvedCacheDir + sep26)) {
333215
333619
  throw new Error(`Marketplace name '${marketplace.name}' resolves to a path outside the cache directory`);
333216
333620
  }
@@ -333259,7 +333663,7 @@ async function captureResolvedSha(source, cachePath) {
333259
333663
  async function addMarketplaceSource(source, onProgress) {
333260
333664
  let resolvedSource = source;
333261
333665
  if (isLocalMarketplaceSource(source) && !isAbsolute31(source.path)) {
333262
- resolvedSource = { ...source, path: resolve45(source.path) };
333666
+ resolvedSource = { ...source, path: resolve46(source.path) };
333263
333667
  }
333264
333668
  if (!isSourceAllowedByPolicy(resolvedSource)) {
333265
333669
  if (isSourceInBlocklist(resolvedSource)) {
@@ -333308,9 +333712,9 @@ Tip: The shorthand "${resolvedSource.repo}" assumes github.com. ` + `For interna
333308
333712
  }
333309
333713
  logForDebugging3(`Marketplace '${marketplace.name}' exists with different source — overwriting`);
333310
333714
  if (!isLocalMarketplaceSource(oldEntry.source)) {
333311
- const cacheDir = resolve45(getMarketplacesCacheDir());
333312
- const resolvedOld = resolve45(oldEntry.installLocation);
333313
- const resolvedNew = resolve45(cachePath);
333715
+ const cacheDir = resolve46(getMarketplacesCacheDir());
333716
+ const resolvedOld = resolve46(oldEntry.installLocation);
333717
+ const resolvedNew = resolve46(cachePath);
333314
333718
  if (resolvedOld === resolvedNew) {} else if (resolvedOld === cacheDir || resolvedOld.startsWith(cacheDir + sep26)) {
333315
333719
  const fs = getFsImplementation2();
333316
333720
  await fs.rm(oldEntry.installLocation, { recursive: true, force: true });
@@ -333332,7 +333736,7 @@ Tip: The shorthand "${resolvedSource.repo}" assumes github.com. ` + `For interna
333332
333736
  }
333333
333737
  async function adoptOrphanMarketplace(dirName, overrideName) {
333334
333738
  const fs = getFsImplementation2();
333335
- const cacheDir = resolve45(getMarketplacesCacheDir());
333739
+ const cacheDir = resolve46(getMarketplacesCacheDir());
333336
333740
  const dirPath = join118(cacheDir, dirName);
333337
333741
  if (!fs.existsSync(dirPath) || !fs.statSync(dirPath).isDirectory()) {
333338
333742
  throw new Error(`No marketplace directory named '${dirName}' in ${cacheDir}. ` + `Run \`plugin marketplace list\` to see unregistered directories.`);
@@ -333362,7 +333766,7 @@ async function adoptOrphanMarketplace(dirName, overrideName) {
333362
333766
  await updateKnownMarketplacesConfig((existing) => {
333363
333767
  const prior = existing[name];
333364
333768
  if (prior) {
333365
- if (resolve45(prior.installLocation) === resolve45(dirPath)) {
333769
+ if (resolve46(prior.installLocation) === resolve46(dirPath)) {
333366
333770
  return;
333367
333771
  }
333368
333772
  throw new Error(`Marketplace name '${name}' is already registered at ` + `${prior.installLocation}. Remove it first ` + `(\`plugin marketplace remove ${name}\`) or adopt under a different name.`);
@@ -333593,8 +333997,8 @@ async function refreshMarketplace(name, onProgress, options) {
333593
333997
  throw new Error(`Marketplace '${name}' is seed-managed (${seedDir}) and its content is ` + `controlled by the seed image. To update: ask your admin to update the seed.`);
333594
333998
  }
333595
333999
  if (!isLocalMarketplaceSource(source)) {
333596
- const cacheDir = resolve45(getMarketplacesCacheDir());
333597
- const resolvedLoc = resolve45(installLocation);
334000
+ const cacheDir = resolve46(getMarketplacesCacheDir());
334001
+ const resolvedLoc = resolve46(installLocation);
333598
334002
  if (resolvedLoc !== cacheDir && !resolvedLoc.startsWith(cacheDir + sep26)) {
333599
334003
  throw new Error(`Marketplace '${name}' has a corrupted installLocation ` + `(${installLocation}) — expected a path inside ${cacheDir}. ` + `This can happen after cross-platform path writes or manual edits ` + `to known_marketplaces.json. ` + `Run: claude plugin marketplace remove "${name}" and re-add it.`);
333600
334004
  }
@@ -333701,7 +334105,7 @@ async function setMarketplaceAutoUpdate(name, autoUpdate) {
333701
334105
  }
333702
334106
  logForDebugging3(`Set autoUpdate=${autoUpdate} for marketplace: ${name}`);
333703
334107
  }
333704
- var knownMarketplacesRmwChain, GIT_NO_PROMPT_ENV3, DEFAULT_PLUGIN_GIT_TIMEOUT_MS, GIT_SHA_RE, getMarketplace;
334108
+ var knownMarketplacesRmwChain, GIT_NO_PROMPT_ENV4, DEFAULT_PLUGIN_GIT_TIMEOUT_MS, GIT_SHA_RE, getMarketplace;
333705
334109
  var init_marketplaceManager = __esm(() => {
333706
334110
  init_axios2();
333707
334111
  init_configDir();
@@ -333732,7 +334136,7 @@ var init_marketplaceManager = __esm(() => {
333732
334136
  init_pluginOptionsStorage();
333733
334137
  init_schemas3();
333734
334138
  knownMarketplacesRmwChain = Promise.resolve();
333735
- GIT_NO_PROMPT_ENV3 = {
334139
+ GIT_NO_PROMPT_ENV4 = {
333736
334140
  GIT_TERMINAL_PROMPT: "0",
333737
334141
  GIT_ASKPASS: ""
333738
334142
  };
@@ -334344,7 +334748,7 @@ var init_mtimeAwareMemoize = () => {};
334344
334748
 
334345
334749
  // src/tui/utils/plugins/installCounts.ts
334346
334750
  import { randomBytes as randomBytes15 } from "crypto";
334347
- import { readFile as readFile42, rename as rename5, unlink as unlink16, writeFile as writeFile29 } from "fs/promises";
334751
+ import { readFile as readFile43, rename as rename5, unlink as unlink18, writeFile as writeFile29 } from "fs/promises";
334348
334752
  import { join as join120 } from "path";
334349
334753
  function normalizeStatsBase(raw) {
334350
334754
  if (!raw)
@@ -334385,7 +334789,7 @@ function getInstallCountsCachePath() {
334385
334789
  async function loadInstallCountsCache() {
334386
334790
  const cachePath = getInstallCountsCachePath();
334387
334791
  try {
334388
- const content = await readFile42(cachePath, { encoding: "utf-8" });
334792
+ const content = await readFile43(cachePath, { encoding: "utf-8" });
334389
334793
  const parsed = jsonParse2(content);
334390
334794
  if (typeof parsed !== "object" || parsed === null || !("version" in parsed) || !("entries" in parsed)) {
334391
334795
  logForDebugging3("Install counts cache has invalid structure");
@@ -334431,7 +334835,7 @@ async function saveInstallCountsCache(cache) {
334431
334835
  } catch (error) {
334432
334836
  logError3(error);
334433
334837
  try {
334434
- await unlink16(tempPath);
334838
+ await unlink18(tempPath);
334435
334839
  } catch {}
334436
334840
  }
334437
334841
  }
@@ -334598,14 +335002,14 @@ var init_pluginVersioning = __esm(() => {
334598
335002
  // src/tui/utils/plugins/pluginInstallationHelpers.ts
334599
335003
  import { randomBytes as randomBytes16 } from "crypto";
334600
335004
  import { rename as rename6, rm as rm8 } from "fs/promises";
334601
- import { dirname as dirname64, join as join121, resolve as resolve46, sep as sep27 } from "path";
335005
+ import { dirname as dirname64, join as join121, resolve as resolve47, sep as sep27 } from "path";
334602
335006
  function getCurrentTimestamp() {
334603
335007
  return new Date().toISOString();
334604
335008
  }
334605
335009
  function validatePathWithinBase(basePath, relativePath) {
334606
- const resolvedPath = resolve46(basePath, relativePath);
334607
- const normalizedBase = resolve46(basePath) + sep27;
334608
- if (!resolvedPath.startsWith(normalizedBase) && resolvedPath !== resolve46(basePath)) {
335010
+ const resolvedPath = resolve47(basePath, relativePath);
335011
+ const normalizedBase = resolve47(basePath) + sep27;
335012
+ if (!resolvedPath.startsWith(normalizedBase) && resolvedPath !== resolve47(basePath)) {
334609
335013
  throw new Error(`Path traversal detected: "${relativePath}" would escape the base directory`);
334610
335014
  }
334611
335015
  return resolvedPath;
@@ -334837,7 +335241,7 @@ var init_pluginInstallationHelpers = __esm(() => {
334837
335241
  import {
334838
335242
  copyFile as copyFile6,
334839
335243
  readdir as readdir24,
334840
- readFile as readFile43,
335244
+ readFile as readFile44,
334841
335245
  readlink,
334842
335246
  realpath as realpath12,
334843
335247
  rename as rename7,
@@ -334846,7 +335250,7 @@ import {
334846
335250
  stat as stat40,
334847
335251
  symlink as symlink5
334848
335252
  } from "fs/promises";
334849
- import { basename as basename36, dirname as dirname65, join as join122, relative as relative22, resolve as resolve47, sep as sep28 } from "path";
335253
+ import { basename as basename36, dirname as dirname65, join as join122, relative as relative22, resolve as resolve48, sep as sep28 } from "path";
334850
335254
  function getPluginCachePath() {
334851
335255
  return join122(getPluginsDirectory(), "cache");
334852
335256
  }
@@ -335237,7 +335641,7 @@ async function cachePlugin(source, options) {
335237
335641
  let manifest;
335238
335642
  if (await pathExists2(manifestPath)) {
335239
335643
  try {
335240
- const content = await readFile43(manifestPath, { encoding: "utf-8" });
335644
+ const content = await readFile44(manifestPath, { encoding: "utf-8" });
335241
335645
  const parsed = jsonParse2(content);
335242
335646
  const result = PluginManifestSchema().safeParse(parsed);
335243
335647
  if (result.success) {
@@ -335261,7 +335665,7 @@ async function cachePlugin(source, options) {
335261
335665
  }
335262
335666
  } else if (await pathExists2(legacyManifestPath)) {
335263
335667
  try {
335264
- const content = await readFile43(legacyManifestPath, {
335668
+ const content = await readFile44(legacyManifestPath, {
335265
335669
  encoding: "utf-8"
335266
335670
  });
335267
335671
  const parsed = jsonParse2(content);
@@ -335311,7 +335715,7 @@ async function loadPluginManifest(manifestPath, pluginName, source) {
335311
335715
  };
335312
335716
  }
335313
335717
  try {
335314
- const content = await readFile43(manifestPath, { encoding: "utf-8" });
335718
+ const content = await readFile44(manifestPath, { encoding: "utf-8" });
335315
335719
  const parsedJson = jsonParse2(content);
335316
335720
  const result = PluginManifestSchema().safeParse(parsedJson);
335317
335721
  if (result.success) {
@@ -335337,7 +335741,7 @@ async function loadPluginHooks2(hooksConfigPath, pluginName) {
335337
335741
  if (!await pathExists2(hooksConfigPath)) {
335338
335742
  throw new Error(`Hooks file not found at ${hooksConfigPath} for plugin ${pluginName}. If the manifest declares hooks, the file must exist.`);
335339
335743
  }
335340
- const content = await readFile43(hooksConfigPath, { encoding: "utf-8" });
335744
+ const content = await readFile44(hooksConfigPath, { encoding: "utf-8" });
335341
335745
  const rawHooksConfig = jsonParse2(content);
335342
335746
  const validatedPluginHooks = PluginHooksSchema().parse(rawHooksConfig);
335343
335747
  return validatedPluginHooks.hooks;
@@ -335640,7 +336044,7 @@ function parsePluginSettings(raw) {
335640
336044
  async function loadPluginSettings(pluginPath, manifest) {
335641
336045
  const settingsJsonPath = join122(pluginPath, "settings.json");
335642
336046
  try {
335643
- const content = await readFile43(settingsJsonPath, { encoding: "utf-8" });
336047
+ const content = await readFile44(settingsJsonPath, { encoding: "utf-8" });
335644
336048
  const parsed = jsonParse2(content);
335645
336049
  if (isRecord(parsed)) {
335646
336050
  const filtered = parsePluginSettings(parsed);
@@ -336200,7 +336604,7 @@ async function loadSessionOnlyPlugins(sessionPluginPaths) {
336200
336604
  const errors = [];
336201
336605
  for (const [index, pluginPath] of sessionPluginPaths.entries()) {
336202
336606
  try {
336203
- const resolvedPath = resolve47(pluginPath);
336607
+ const resolvedPath = resolve48(pluginPath);
336204
336608
  if (!await pathExists2(resolvedPath)) {
336205
336609
  logForDebugging3(`Plugin path does not exist: ${resolvedPath}, skipping`, { level: "warn" });
336206
336610
  errors.push({
@@ -341339,7 +341743,7 @@ __export(exports_permissionSetup, {
341339
341743
  verifyAutoModeGateAccess: () => verifyAutoModeGateAccess
341340
341744
  });
341341
341745
  import { relative as relative23 } from "path";
341342
- import { resolve as resolve48 } from "path";
341746
+ import { resolve as resolve49 } from "path";
341343
341747
  function isDangerousBashPermission(toolName, ruleContent) {
341344
341748
  if (toolName !== BASH_TOOL_NAME2) {
341345
341749
  return false;
@@ -341611,7 +342015,7 @@ function isSymlinkTo2({
341611
342015
  originalCwd
341612
342016
  }) {
341613
342017
  const { resolvedPath: resolvedProcessPwd, isSymlink: isProcessPwdSymlink } = safeResolvePath3(getFsImplementation2(), processPwd);
341614
- return isProcessPwdSymlink ? resolvedProcessPwd === resolve48(originalCwd) : false;
342018
+ return isProcessPwdSymlink ? resolvedProcessPwd === resolve49(originalCwd) : false;
341615
342019
  }
341616
342020
  function initialPermissionModeFromCLI2({
341617
342021
  permissionModeCli,
@@ -342670,7 +343074,7 @@ __export(exports_terminalSetup, {
342670
343074
  shouldOfferTerminalSetup: () => shouldOfferTerminalSetup
342671
343075
  });
342672
343076
  import { randomBytes as randomBytes18 } from "crypto";
342673
- import { copyFile as copyFile7, mkdir as mkdir37, readFile as readFile44, writeFile as writeFile30 } from "fs/promises";
343077
+ import { copyFile as copyFile7, mkdir as mkdir37, readFile as readFile45, writeFile as writeFile30 } from "fs/promises";
342674
343078
  import { homedir as homedir31, platform as platform3 } from "os";
342675
343079
  import { dirname as dirname66, join as join124 } from "path";
342676
343080
  import { pathToFileURL as pathToFileURL8 } from "url";
@@ -342816,7 +343220,7 @@ async function installBindingsForVSCodeTerminal(editor = "VSCode", theme) {
342816
343220
  let keybindings = [];
342817
343221
  let fileExists = false;
342818
343222
  try {
342819
- content = await readFile44(keybindingsPath, {
343223
+ content = await readFile45(keybindingsPath, {
342820
343224
  encoding: "utf-8"
342821
343225
  });
342822
343226
  fileExists = true;
@@ -342963,7 +343367,7 @@ chars = "\\u001B\\r"`;
342963
343367
  let configExists = false;
342964
343368
  for (const path of configPaths) {
342965
343369
  try {
342966
- configContent = await readFile44(path, {
343370
+ configContent = await readFile45(path, {
342967
343371
  encoding: "utf-8"
342968
343372
  });
342969
343373
  configPath = path;
@@ -343025,7 +343429,7 @@ async function installBindingsForZed(theme) {
343025
343429
  let keymapContent = "[]";
343026
343430
  let fileExists = false;
343027
343431
  try {
343028
- keymapContent = await readFile44(keymapPath, {
343432
+ keymapContent = await readFile45(keymapPath, {
343029
343433
  encoding: "utf-8"
343030
343434
  });
343031
343435
  fileExists = true;
@@ -343097,7 +343501,7 @@ var init_terminalSetup = __esm(() => {
343097
343501
 
343098
343502
  // src/tui/utils/pasteStore.ts
343099
343503
  import { createHash as createHash10 } from "crypto";
343100
- import { mkdir as mkdir38, readdir as readdir25, readFile as readFile45, stat as stat42, unlink as unlink17, writeFile as writeFile31 } from "fs/promises";
343504
+ import { mkdir as mkdir38, readdir as readdir25, readFile as readFile46, stat as stat42, unlink as unlink19, writeFile as writeFile31 } from "fs/promises";
343101
343505
  import { join as join125 } from "path";
343102
343506
  function getPasteStoreDir() {
343103
343507
  return join125(getAtlasConfigHomeDir3(), PASTE_STORE_DIR);
@@ -343122,7 +343526,7 @@ async function storePastedText(hash, content) {
343122
343526
  async function retrievePastedText(hash) {
343123
343527
  try {
343124
343528
  const pastePath = getPastePath(hash);
343125
- return await readFile45(pastePath, { encoding: "utf8" });
343529
+ return await readFile46(pastePath, { encoding: "utf8" });
343126
343530
  } catch (error) {
343127
343531
  if (!isENOENT2(error)) {
343128
343532
  logForDebugging3(`Failed to retrieve paste ${hash}: ${error}`);
@@ -343147,7 +343551,7 @@ async function cleanupOldPastes(cutoffDate) {
343147
343551
  try {
343148
343552
  const stats = await stat42(filePath);
343149
343553
  if (stats.mtimeMs < cutoffTime) {
343150
- await unlink17(filePath);
343554
+ await unlink19(filePath);
343151
343555
  logForDebugging3(`Cleaned up old paste: ${filePath}`);
343152
343556
  }
343153
343557
  } catch {}
@@ -347209,7 +347613,7 @@ var init_btw2 = __esm(() => {
347209
347613
  });
347210
347614
 
347211
347615
  // src/tui/components/Feedback.tsx
347212
- import { readFile as readFile46, stat as stat43 } from "fs/promises";
347616
+ import { readFile as readFile47, stat as stat43 } from "fs/promises";
347213
347617
  function redactSensitiveInfo(text) {
347214
347618
  let redacted = text;
347215
347619
  redacted = redacted.replace(/"(sk-ant[^\s"']{24,})"/g, '"[REDACTED_API_KEY]"');
@@ -347248,7 +347652,7 @@ async function loadRawTranscriptJsonl() {
347248
347652
  });
347249
347653
  return null;
347250
347654
  }
347251
- return await readFile46(transcriptPath, "utf-8");
347655
+ return await readFile47(transcriptPath, "utf-8");
347252
347656
  } catch {
347253
347657
  return null;
347254
347658
  }
@@ -351081,7 +351485,7 @@ var init_localInstaller = __esm(() => {
351081
351485
  });
351082
351486
 
351083
351487
  // src/tui/utils/shellConfig.ts
351084
- import { open as open14, readFile as readFile47, stat as stat44 } from "fs/promises";
351488
+ import { open as open14, readFile as readFile48, stat as stat44 } from "fs/promises";
351085
351489
  import { homedir as osHomedir } from "os";
351086
351490
  import { join as join132 } from "path";
351087
351491
  function getShellConfigPaths(options) {
@@ -351116,7 +351520,7 @@ function filterAtlasAliases(lines) {
351116
351520
  }
351117
351521
  async function readFileLines(filePath) {
351118
351522
  try {
351119
- const content = await readFile47(filePath, { encoding: "utf8" });
351523
+ const content = await readFile48(filePath, { encoding: "utf8" });
351120
351524
  return content.split(`
351121
351525
  `);
351122
351526
  } catch (e) {
@@ -351459,7 +351863,7 @@ var init_autoUpdater = __esm(() => {
351459
351863
  });
351460
351864
 
351461
351865
  // src/tui/utils/nativeInstaller/packageManagers.ts
351462
- import { readFile as readFile48 } from "fs/promises";
351866
+ import { readFile as readFile49 } from "fs/promises";
351463
351867
  function isDistroFamily(osRelease, families) {
351464
351868
  return families.includes(osRelease.id) || osRelease.idLike.some((like) => families.includes(like));
351465
351869
  }
@@ -351517,7 +351921,7 @@ var init_packageManagers = __esm(() => {
351517
351921
  init_platform3();
351518
351922
  getOsRelease = memoize_default(async () => {
351519
351923
  try {
351520
- const content = await readFile48("/etc/os-release", "utf8");
351924
+ const content = await readFile49("/etc/os-release", "utf8");
351521
351925
  const idMatch = content.match(/^ID=["']?(\S+?)["']?\s*$/m);
351522
351926
  const idLikeMatch = content.match(/^ID_LIKE=["']?(.+?)["']?\s*$/m);
351523
351927
  return {
@@ -351638,7 +352042,7 @@ var init_packageManagers = __esm(() => {
351638
352042
  });
351639
352043
 
351640
352044
  // src/tui/utils/doctorDiagnostic.ts
351641
- import { readFile as readFile49, realpath as realpath13 } from "fs/promises";
352045
+ import { readFile as readFile50, realpath as realpath13 } from "fs/promises";
351642
352046
  import { homedir as homedir33 } from "os";
351643
352047
  import { delimiter as delimiter2, join as join134, posix as posix8, win32 as win322 } from "path";
351644
352048
  function getNormalizedPaths() {
@@ -351794,7 +352198,7 @@ async function detectMultipleInstallations() {
351794
352198
  async function detectConfigurationIssues(type) {
351795
352199
  const warnings = [];
351796
352200
  try {
351797
- const raw = await readFile49(join134(getManagedFilePath(), "managed-settings.json"), "utf-8");
352201
+ const raw = await readFile50(join134(getManagedFilePath(), "managed-settings.json"), "utf-8");
351798
352202
  const parsed = jsonParse2(raw);
351799
352203
  const field = parsed && typeof parsed === "object" ? parsed.strictPluginOnlyCustomization : undefined;
351800
352204
  if (field !== undefined && typeof field !== "boolean") {
@@ -352293,7 +352697,7 @@ import {
352293
352697
  access as access5,
352294
352698
  chmod as chmod7,
352295
352699
  copyFile as copyFile8,
352296
- lstat as lstat6,
352700
+ lstat as lstat8,
352297
352701
  mkdir as mkdir40,
352298
352702
  readdir as readdir26,
352299
352703
  readlink as readlink2,
@@ -352303,11 +352707,11 @@ import {
352303
352707
  rmdir as rmdir2,
352304
352708
  stat as stat45,
352305
352709
  symlink as symlink6,
352306
- unlink as unlink18,
352710
+ unlink as unlink20,
352307
352711
  writeFile as writeFile36
352308
352712
  } from "fs/promises";
352309
352713
  import { homedir as homedir34 } from "os";
352310
- import { basename as basename42, delimiter as delimiter3, dirname as dirname69, join as join137, resolve as resolve49 } from "path";
352714
+ import { basename as basename42, delimiter as delimiter3, dirname as dirname69, join as join137, resolve as resolve50 } from "path";
352311
352715
  function getPlatform4() {
352312
352716
  const os = env5.platform;
352313
352717
  const arch = process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
@@ -352435,7 +352839,7 @@ async function atomicMoveToInstallPath(stagedBinaryPath, installPath) {
352435
352839
  logForDebugging3(`Atomically installed binary to ${installPath}`);
352436
352840
  } catch (error) {
352437
352841
  try {
352438
- await unlink18(tempInstallPath);
352842
+ await unlink20(tempInstallPath);
352439
352843
  } catch {}
352440
352844
  throw error;
352441
352845
  }
@@ -352610,7 +353014,7 @@ async function updateSymlink(symlinkPath, targetPath) {
352610
353014
  try {
352611
353015
  await copyFile8(targetPath, symlinkPath);
352612
353016
  try {
352613
- await unlink18(oldFileName);
353017
+ await unlink20(oldFileName);
352614
353018
  } catch {}
352615
353019
  } catch (copyError) {
352616
353020
  try {
@@ -352655,13 +353059,13 @@ async function updateSymlink(symlinkPath, targetPath) {
352655
353059
  if (symlinkExists) {
352656
353060
  try {
352657
353061
  const currentTarget = await readlink2(symlinkPath);
352658
- const resolvedCurrentTarget = resolve49(dirname69(symlinkPath), currentTarget);
352659
- const resolvedTargetPath = resolve49(targetPath);
353062
+ const resolvedCurrentTarget = resolve50(dirname69(symlinkPath), currentTarget);
353063
+ const resolvedTargetPath = resolve50(targetPath);
352660
353064
  if (resolvedCurrentTarget === resolvedTargetPath) {
352661
353065
  return false;
352662
353066
  }
352663
353067
  } catch {}
352664
- await unlink18(symlinkPath);
353068
+ await unlink20(symlinkPath);
352665
353069
  }
352666
353070
  } catch (error) {
352667
353071
  logError3(new Error(`Failed to check/remove existing symlink: ${error}`));
@@ -352674,7 +353078,7 @@ async function updateSymlink(symlinkPath, targetPath) {
352674
353078
  return true;
352675
353079
  } catch (error) {
352676
353080
  try {
352677
- await unlink18(tempSymlink);
353081
+ await unlink20(tempSymlink);
352678
353082
  } catch {}
352679
353083
  logError3(new Error(`Failed to create symlink from ${symlinkPath} to ${targetPath}: ${error}`));
352680
353084
  return false;
@@ -352696,7 +353100,7 @@ async function checkInstall(force = false) {
352696
353100
  const dirs = getBaseDirectories();
352697
353101
  const messages = [];
352698
353102
  const localBinDir = dirname69(dirs.executable);
352699
- const resolvedLocalBinPath = resolve49(localBinDir);
353103
+ const resolvedLocalBinPath = resolve50(localBinDir);
352700
353104
  const platform = getPlatform4();
352701
353105
  const isWindows = platform.startsWith("win32");
352702
353106
  try {
@@ -352719,7 +353123,7 @@ async function checkInstall(force = false) {
352719
353123
  } else {
352720
353124
  try {
352721
353125
  const target = await readlink2(dirs.executable);
352722
- const absoluteTarget = resolve49(dirname69(dirs.executable), target);
353126
+ const absoluteTarget = resolve50(dirname69(dirs.executable), target);
352723
353127
  if (!await isPossibleClaudeBinary(absoluteTarget)) {
352724
353128
  messages.push({
352725
353129
  message: `AtlasCode symlink points to missing or invalid binary: ${target}`,
@@ -352747,7 +353151,7 @@ async function checkInstall(force = false) {
352747
353151
  }
352748
353152
  const isInCurrentPath = (process.env.PATH || "").split(delimiter3).some((entry) => {
352749
353153
  try {
352750
- const resolvedEntry = resolve49(entry);
353154
+ const resolvedEntry = resolve50(entry);
352751
353155
  if (isWindows) {
352752
353156
  return resolvedEntry.toLowerCase() === resolvedLocalBinPath.toLowerCase();
352753
353157
  }
@@ -352826,7 +353230,7 @@ async function installLatestImpl(channelOrVersion, forceReinstall = false) {
352826
353230
  async function getVersionFromSymlink(symlinkPath) {
352827
353231
  try {
352828
353232
  const target = await readlink2(symlinkPath);
352829
- const absoluteTarget = resolve49(dirname69(symlinkPath), target);
353233
+ const absoluteTarget = resolve50(dirname69(symlinkPath), target);
352830
353234
  if (await isPossibleClaudeBinary(absoluteTarget)) {
352831
353235
  return absoluteTarget;
352832
353236
  }
@@ -352842,7 +353246,7 @@ async function lockCurrentVersion() {
352842
353246
  if (!process.execPath.includes(dirs.versions)) {
352843
353247
  return;
352844
353248
  }
352845
- const versionPath = resolve49(process.execPath);
353249
+ const versionPath = resolve50(process.execPath);
352846
353250
  try {
352847
353251
  const lockfilePath = getLockFilePathFromVersionPath(dirs, versionPath);
352848
353252
  await mkdir40(dirs.locks, { recursive: true });
@@ -352894,7 +353298,7 @@ async function forceRemoveLock(versionFilePath) {
352894
353298
  const dirs = getBaseDirectories();
352895
353299
  const lockfilePath = getLockFilePathFromVersionPath(dirs, versionFilePath);
352896
353300
  try {
352897
- await unlink18(lockfilePath);
353301
+ await unlink20(lockfilePath);
352898
353302
  logForDebugging3(`Force-removed lock file at ${lockfilePath}`);
352899
353303
  } catch (error) {
352900
353304
  logForDebugging3(`Failed to force-remove lock file: ${errorMessage2(error)}`);
@@ -352913,7 +353317,7 @@ async function cleanupOldVersions() {
352913
353317
  if (!/atlas\.exe\.old\.\d+$/.test(file))
352914
353318
  continue;
352915
353319
  try {
352916
- await unlink18(join137(executableDir, file));
353320
+ await unlink20(join137(executableDir, file));
352917
353321
  cleanedCount++;
352918
353322
  } catch {}
352919
353323
  }
@@ -352971,7 +353375,7 @@ async function cleanupOldVersions() {
352971
353375
  try {
352972
353376
  const stats = await stat45(entryPath);
352973
353377
  if (stats.mtime.getTime() < oneHourAgo) {
352974
- await unlink18(entryPath);
353378
+ await unlink20(entryPath);
352975
353379
  tempFilesCleanedCount++;
352976
353380
  logForDebugging3(`Cleaned up orphaned temp install file: ${entry}`);
352977
353381
  }
@@ -352988,7 +353392,7 @@ async function cleanupOldVersions() {
352988
353392
  versionFiles.push({
352989
353393
  name: entry,
352990
353394
  path: entryPath,
352991
- resolvedPath: resolve49(entryPath),
353395
+ resolvedPath: resolve50(entryPath),
352992
353396
  mtime: stats.mtime
352993
353397
  });
352994
353398
  } catch {}
@@ -353003,7 +353407,7 @@ async function cleanupOldVersions() {
353003
353407
  const currentBinaryPath = process.execPath;
353004
353408
  const protectedVersions = new Set;
353005
353409
  if (currentBinaryPath && currentBinaryPath.includes(dirs.versions)) {
353006
- protectedVersions.add(resolve49(currentBinaryPath));
353410
+ protectedVersions.add(resolve50(currentBinaryPath));
353007
353411
  }
353008
353412
  const currentSymlinkVersion = await getVersionFromSymlink(dirs.executable);
353009
353413
  if (currentSymlinkVersion) {
@@ -353042,7 +353446,7 @@ async function cleanupOldVersions() {
353042
353446
  await Promise.all(versionsToDelete.map(async (version) => {
353043
353447
  try {
353044
353448
  const deleted = await tryWithVersionLock(version.path, async () => {
353045
- await unlink18(version.path);
353449
+ await unlink20(version.path);
353046
353450
  });
353047
353451
  if (deleted) {
353048
353452
  deletedCount++;
@@ -353063,7 +353467,7 @@ async function cleanupOldVersions() {
353063
353467
  }
353064
353468
  async function isNpmSymlink(executablePath) {
353065
353469
  let targetPath = executablePath;
353066
- const stats = await lstat6(executablePath);
353470
+ const stats = await lstat8(executablePath);
353067
353471
  if (stats.isSymbolicLink()) {
353068
353472
  targetPath = await realpath14(executablePath);
353069
353473
  }
@@ -353076,7 +353480,7 @@ async function removeInstalledSymlink() {
353076
353480
  logForDebugging3(`Skipping removal of ${dirs.executable} - appears to be npm-managed`);
353077
353481
  return;
353078
353482
  }
353079
- await unlink18(dirs.executable);
353483
+ await unlink20(dirs.executable);
353080
353484
  logForDebugging3(`Removed atlas symlink at ${dirs.executable}`);
353081
353485
  } catch (error) {
353082
353486
  if (isENOENT2(error)) {
@@ -353131,7 +353535,7 @@ async function manualRemoveNpmPackage(packageName) {
353131
353535
  let manuallyRemoved = false;
353132
353536
  async function tryRemove(filePath, description) {
353133
353537
  try {
353134
- await unlink18(filePath);
353538
+ await unlink20(filePath);
353135
353539
  logForDebugging3(`Manually removed ${description}: ${filePath}`);
353136
353540
  return true;
353137
353541
  } catch {
@@ -359487,7 +359891,7 @@ var init_useTurnDiffs = __esm(() => {
359487
359891
  });
359488
359892
 
359489
359893
  // src/tui/components/diff/DiffDetailView.tsx
359490
- import { resolve as resolve50 } from "path";
359894
+ import { resolve as resolve51 } from "path";
359491
359895
  function DiffDetailView(t0) {
359492
359896
  const $ = import_compiler_runtime130.c(53);
359493
359897
  const {
@@ -359520,7 +359924,7 @@ function DiffDetailView(t0) {
359520
359924
  let content;
359521
359925
  let t2;
359522
359926
  if ($[1] !== filePath) {
359523
- const fullPath = resolve50(getCwd(), filePath);
359927
+ const fullPath = resolve51(getCwd(), filePath);
359524
359928
  content = readFileSafe2(fullPath);
359525
359929
  t2 = content?.split(`
359526
359930
  `)[0] ?? null;
@@ -373034,7 +373438,7 @@ var init_mcp7 = __esm(() => {
373034
373438
  });
373035
373439
 
373036
373440
  // src/tui/utils/releaseNotes.ts
373037
- import { mkdir as mkdir44, readFile as readFile50, writeFile as writeFile39 } from "fs/promises";
373441
+ import { mkdir as mkdir44, readFile as readFile51, writeFile as writeFile39 } from "fs/promises";
373038
373442
  import { dirname as dirname71, join as join140 } from "path";
373039
373443
  function getChangelogCachePath() {
373040
373444
  return join140(getAtlasConfigHomeDir3(), "cache", "changelog.md");
@@ -373084,7 +373488,7 @@ async function getStoredChangelog() {
373084
373488
  }
373085
373489
  const cachePath = getChangelogCachePath();
373086
373490
  try {
373087
- const content = await readFile50(cachePath, "utf-8");
373491
+ const content = await readFile51(cachePath, "utf-8");
373088
373492
  changelogMemoryCache = content;
373089
373493
  return content;
373090
373494
  } catch {
@@ -391041,7 +391445,7 @@ __export(exports_thinkback, {
391041
391445
  call: () => call35,
391042
391446
  playAnimation: () => playAnimation
391043
391447
  });
391044
- import { readFile as readFile51 } from "fs/promises";
391448
+ import { readFile as readFile52 } from "fs/promises";
391045
391449
  import { join as join143 } from "path";
391046
391450
  function getMarketplaceName() {
391047
391451
  return OFFICIAL_MARKETPLACE_NAME;
@@ -391070,7 +391474,7 @@ async function playAnimation(skillDir) {
391070
391474
  const dataPath = join143(skillDir, "year_in_review.js");
391071
391475
  const playerPath = join143(skillDir, "player.js");
391072
391476
  try {
391073
- await readFile51(dataPath);
391477
+ await readFile52(dataPath);
391074
391478
  } catch (e) {
391075
391479
  if (isENOENT2(e)) {
391076
391480
  return {
@@ -391085,7 +391489,7 @@ async function playAnimation(skillDir) {
391085
391489
  };
391086
391490
  }
391087
391491
  try {
391088
- await readFile51(playerPath);
391492
+ await readFile52(playerPath);
391089
391493
  } catch (e) {
391090
391494
  if (isENOENT2(e)) {
391091
391495
  return {
@@ -396164,7 +396568,7 @@ __export(exports_branch, {
396164
396568
  getUniqueForkName: () => getUniqueForkName
396165
396569
  });
396166
396570
  import { randomUUID as randomUUID39 } from "crypto";
396167
- import { mkdir as mkdir45, readFile as readFile52, writeFile as writeFile40 } from "fs/promises";
396571
+ import { mkdir as mkdir45, readFile as readFile53, writeFile as writeFile40 } from "fs/promises";
396168
396572
  function deriveFirstPrompt(firstUserMessage) {
396169
396573
  const content = firstUserMessage?.message?.content;
396170
396574
  if (!content)
@@ -396183,7 +396587,7 @@ async function createFork(customTitle, target) {
396183
396587
  await mkdir45(projectDir, { recursive: true, mode: 448 });
396184
396588
  let transcriptContent;
396185
396589
  try {
396186
- transcriptContent = await readFile52(currentTranscriptPath);
396590
+ transcriptContent = await readFile53(currentTranscriptPath);
396187
396591
  } catch {
396188
396592
  throw new Error("No conversation to branch");
396189
396593
  }
@@ -396505,7 +396909,7 @@ var init_types16 = __esm(() => {
396505
396909
  });
396506
396910
 
396507
396911
  // src/tui/components/agents/agentFileUtils.ts
396508
- import { mkdir as mkdir46, open as open15, unlink as unlink19 } from "fs/promises";
396912
+ import { mkdir as mkdir46, open as open15, unlink as unlink21 } from "fs/promises";
396509
396913
  import { join as join145 } from "path";
396510
396914
  function formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt, color, model, memory, effort) {
396511
396915
  const escapedWhenToUse = whenToUse.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\\\n");
@@ -396621,7 +397025,7 @@ async function deleteAgentFromFile(agent) {
396621
397025
  }
396622
397026
  const filePath = getActualAgentFilePath(agent);
396623
397027
  try {
396624
- await unlink19(filePath);
397028
+ await unlink21(filePath);
396625
397029
  } catch (e) {
396626
397030
  const code = getErrnoCode2(e);
396627
397031
  if (code !== "ENOENT") {
@@ -402476,7 +402880,7 @@ var init_refresh = __esm(() => {
402476
402880
 
402477
402881
  // src/tui/utils/plugins/parseMarketplaceInput.ts
402478
402882
  import { homedir as homedir37 } from "os";
402479
- import { resolve as resolve51 } from "path";
402883
+ import { resolve as resolve52 } from "path";
402480
402884
  function matchKnownGitHost(hostname) {
402481
402885
  const host = hostname.toLowerCase();
402482
402886
  for (const known of KNOWN_GIT_HOSTS) {
@@ -402528,7 +402932,7 @@ async function parseMarketplaceInput(input) {
402528
402932
  const isWindows = process.platform === "win32";
402529
402933
  const isWindowsPath = isWindows && (trimmed.startsWith(".\\") || trimmed.startsWith("..\\") || /^[a-zA-Z]:[/\\]/.test(trimmed));
402530
402934
  if (trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("/") || trimmed.startsWith("~") || isWindowsPath) {
402531
- const resolvedPath = resolve51(trimmed.startsWith("~") ? trimmed.replace(/^~/, homedir37()) : trimmed);
402935
+ const resolvedPath = resolve52(trimmed.startsWith("~") ? trimmed.replace(/^~/, homedir37()) : trimmed);
402532
402936
  let stats;
402533
402937
  try {
402534
402938
  stats = await fs.stat(resolvedPath);
@@ -405493,7 +405897,7 @@ var init_DiscoverPlugins = __esm(() => {
405493
405897
  });
405494
405898
 
405495
405899
  // src/tui/utils/plugins/skillSearch.ts
405496
- import { readdir as readdir27, readFile as readFile53, stat as stat46 } from "fs/promises";
405900
+ import { readdir as readdir27, readFile as readFile54, stat as stat46 } from "fs/promises";
405497
405901
  import { join as join146 } from "path";
405498
405902
  async function searchSkillsAcrossMarketplaces(query) {
405499
405903
  const config = await loadKnownMarketplacesConfig();
@@ -405541,7 +405945,7 @@ async function searchSkillsAcrossMarketplaces(query) {
405541
405945
  seen.add(skillFile);
405542
405946
  let content;
405543
405947
  try {
405544
- content = await readFile53(skillFile, { encoding: "utf-8" });
405948
+ content = await readFile54(skillFile, { encoding: "utf-8" });
405545
405949
  } catch {
405546
405950
  continue;
405547
405951
  }
@@ -407036,7 +407440,7 @@ var init_ManageMarketplaces = __esm(() => {
407036
407440
 
407037
407441
  // src/tui/utils/plugins/pluginFlagging.ts
407038
407442
  import { randomBytes as randomBytes19 } from "crypto";
407039
- import { readFile as readFile54, rename as rename10, unlink as unlink20, writeFile as writeFile41 } from "fs/promises";
407443
+ import { readFile as readFile55, rename as rename10, unlink as unlink22, writeFile as writeFile41 } from "fs/promises";
407040
407444
  import { join as join147 } from "path";
407041
407445
  function getFlaggedPluginsPath() {
407042
407446
  return join147(getPluginsDirectory(), FLAGGED_PLUGINS_FILENAME);
@@ -407063,7 +407467,7 @@ function parsePluginsData(content) {
407063
407467
  }
407064
407468
  async function readFromDisk() {
407065
407469
  try {
407066
- const content = await readFile54(getFlaggedPluginsPath(), {
407470
+ const content = await readFile55(getFlaggedPluginsPath(), {
407067
407471
  encoding: "utf-8"
407068
407472
  });
407069
407473
  return parsePluginsData(content);
@@ -407086,7 +407490,7 @@ async function writeToDisk(plugins) {
407086
407490
  } catch (error) {
407087
407491
  logError3(error);
407088
407492
  try {
407089
- await unlink20(tempPath);
407493
+ await unlink22(tempPath);
407090
407494
  } catch {}
407091
407495
  }
407092
407496
  }
@@ -410451,7 +410855,7 @@ async function createPluginReleaseTag(pluginId, explicitTag) {
410451
410855
  message: `Refusing to create tag '${resolved.got}': the plugin manifest declares version '${resolved.expected}'. Use 'plugin tag ${found.matchedId} --tag ${resolved.expected}' (or v${resolved.expected}).`
410452
410856
  };
410453
410857
  }
410454
- const gitEnv = { ...process.env, ...GIT_NO_PROMPT_ENV4 };
410858
+ const gitEnv = { ...process.env, ...GIT_NO_PROMPT_ENV5 };
410455
410859
  const repoCheck = await execFileNoThrowWithCwd2(gitExe2(), ["rev-parse", "--git-dir"], {
410456
410860
  cwd: installPath,
410457
410861
  timeout: GIT_TIMEOUT_MS2,
@@ -410499,13 +410903,13 @@ async function createPluginReleaseTag(pluginId, explicitTag) {
410499
410903
  installPath
410500
410904
  };
410501
410905
  }
410502
- var GIT_NO_PROMPT_ENV4, GIT_TIMEOUT_MS2 = 30000;
410906
+ var GIT_NO_PROMPT_ENV5, GIT_TIMEOUT_MS2 = 30000;
410503
410907
  var init_pluginTag = __esm(() => {
410504
410908
  init_fsOperations();
410505
410909
  init_git2();
410506
410910
  init_execFileNoThrow2();
410507
410911
  init_installedPluginsManager();
410508
- GIT_NO_PROMPT_ENV4 = {
410912
+ GIT_NO_PROMPT_ENV5 = {
410509
410913
  GIT_TERMINAL_PROMPT: "0",
410510
410914
  GIT_ASKPASS: ""
410511
410915
  };
@@ -410579,7 +410983,7 @@ var init_TagPlugin = __esm(() => {
410579
410983
  });
410580
410984
 
410581
410985
  // src/tui/utils/plugins/validatePlugin.ts
410582
- import { readdir as readdir29, readFile as readFile56, stat as stat48 } from "fs/promises";
410986
+ import { readdir as readdir29, readFile as readFile57, stat as stat48 } from "fs/promises";
410583
410987
  import * as path24 from "path";
410584
410988
  function detectManifestType(filePath) {
410585
410989
  const fileName = path24.basename(filePath);
@@ -410619,7 +411023,7 @@ async function validatePluginManifest(filePath) {
410619
411023
  const absolutePath = path24.resolve(filePath);
410620
411024
  let content;
410621
411025
  try {
410622
- content = await readFile56(absolutePath, { encoding: "utf-8" });
411026
+ content = await readFile57(absolutePath, { encoding: "utf-8" });
410623
411027
  } catch (error) {
410624
411028
  const code = getErrnoCode2(error);
410625
411029
  let message;
@@ -410743,7 +411147,7 @@ async function validateMarketplaceManifest(filePath) {
410743
411147
  const absolutePath = path24.resolve(filePath);
410744
411148
  let content;
410745
411149
  try {
410746
- content = await readFile56(absolutePath, { encoding: "utf-8" });
411150
+ content = await readFile57(absolutePath, { encoding: "utf-8" });
410747
411151
  } catch (error) {
410748
411152
  const code = getErrnoCode2(error);
410749
411153
  let message;
@@ -410829,7 +411233,7 @@ async function validateMarketplaceManifest(filePath) {
410829
411233
  const pluginJsonPath = findManifestInDir(path24.join(marketplaceRoot, entry.source), "plugin.json");
410830
411234
  let manifestVersion;
410831
411235
  try {
410832
- const raw = await readFile56(pluginJsonPath, { encoding: "utf-8" });
411236
+ const raw = await readFile57(pluginJsonPath, { encoding: "utf-8" });
410833
411237
  const parsed = jsonParse2(raw);
410834
411238
  if (typeof parsed.version === "string") {
410835
411239
  manifestVersion = parsed.version;
@@ -410877,7 +411281,7 @@ async function validateMarketplaceManifest(filePath) {
410877
411281
  for (const skillFile of skillFiles) {
410878
411282
  let content;
410879
411283
  try {
410880
- content = await readFile56(skillFile, { encoding: "utf-8" });
411284
+ content = await readFile57(skillFile, { encoding: "utf-8" });
410881
411285
  } catch (e) {
410882
411286
  if (isENOENT2(e))
410883
411287
  continue;
@@ -411004,7 +411408,7 @@ function validateComponentFile(filePath, content, fileType) {
411004
411408
  async function validateHooksJson(filePath) {
411005
411409
  let content;
411006
411410
  try {
411007
- content = await readFile56(filePath, { encoding: "utf-8" });
411411
+ content = await readFile57(filePath, { encoding: "utf-8" });
411008
411412
  } catch (e) {
411009
411413
  const code = getErrnoCode2(e);
411010
411414
  if (code === "ENOENT") {
@@ -411097,7 +411501,7 @@ async function validatePluginContents(pluginDir) {
411097
411501
  for (const filePath of files) {
411098
411502
  let content;
411099
411503
  try {
411100
- content = await readFile56(filePath, { encoding: "utf-8" });
411504
+ content = await readFile57(filePath, { encoding: "utf-8" });
411101
411505
  } catch (e) {
411102
411506
  if (isENOENT2(e))
411103
411507
  continue;
@@ -411166,7 +411570,7 @@ async function validateManifest(filePath) {
411166
411570
  return validateMarketplaceManifest(filePath);
411167
411571
  case "unknown": {
411168
411572
  try {
411169
- const content = await readFile56(absolutePath, { encoding: "utf-8" });
411573
+ const content = await readFile57(absolutePath, { encoding: "utf-8" });
411170
411574
  const parsed = jsonParse2(content);
411171
411575
  if (Array.isArray(parsed.plugins)) {
411172
411576
  return validateMarketplaceManifest(filePath);
@@ -413301,7 +413705,7 @@ var init_rewind = __esm(() => {
413301
413705
 
413302
413706
  // src/tui/utils/heapDumpService.ts
413303
413707
  import { createWriteStream as createWriteStream3, writeFileSync as writeFileSync8 } from "fs";
413304
- import { readdir as readdir30, readFile as readFile57, writeFile as writeFile42 } from "fs/promises";
413708
+ import { readdir as readdir30, readFile as readFile58, writeFile as writeFile42 } from "fs/promises";
413305
413709
  import { join as join152 } from "path";
413306
413710
  import { pipeline as pipeline2 } from "stream/promises";
413307
413711
  import {
@@ -413326,7 +413730,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
413326
413730
  } catch {}
413327
413731
  let smapsRollup;
413328
413732
  try {
413329
- smapsRollup = await readFile57("/proc/self/smaps_rollup", "utf8");
413733
+ smapsRollup = await readFile58("/proc/self/smaps_rollup", "utf8");
413330
413734
  } catch {}
413331
413735
  const nativeMemory = usage.rss - usage.heapUsed;
413332
413736
  const bytesPerSecond = uptimeSeconds > 0 ? usage.rss / uptimeSeconds : 0;
@@ -414861,6 +415265,47 @@ var init_bundledSkills2 = __esm(() => {
414861
415265
  SAFE_WRITE_FLAGS2 = process.platform === "win32" ? "wx" : fsConstants8.O_WRONLY | fsConstants8.O_CREAT | fsConstants8.O_EXCL | O_NOFOLLOW3;
414862
415266
  });
414863
415267
 
415268
+ // src/tui/utils/worktreeChangeSummary.ts
415269
+ async function inspectWorktreeChanges(worktreePath, originalHeadCommit) {
415270
+ try {
415271
+ const status = await execFileNoThrow3(gitExe2(), [
415272
+ "-C",
415273
+ worktreePath,
415274
+ "status",
415275
+ "--porcelain"
415276
+ ]);
415277
+ if (status.code !== 0) {
415278
+ return null;
415279
+ }
415280
+ const changedFiles = status.stdout.split(`
415281
+ `).filter((line) => line.trim() !== "").length;
415282
+ if (!originalHeadCommit) {
415283
+ return null;
415284
+ }
415285
+ const revList = await execFileNoThrow3(gitExe2(), [
415286
+ "-C",
415287
+ worktreePath,
415288
+ "rev-list",
415289
+ "--count",
415290
+ `${originalHeadCommit}..HEAD`
415291
+ ]);
415292
+ if (revList.code !== 0) {
415293
+ return null;
415294
+ }
415295
+ const commitsStr = revList.stdout.trim();
415296
+ if (!/^\d+$/.test(commitsStr)) {
415297
+ return null;
415298
+ }
415299
+ return { changedFiles, commits: parseInt(commitsStr, 10) };
415300
+ } catch {
415301
+ return null;
415302
+ }
415303
+ }
415304
+ var init_worktreeChangeSummary = __esm(() => {
415305
+ init_execFileNoThrow2();
415306
+ init_git2();
415307
+ });
415308
+
414864
415309
  // src/tui/components/WorktreeExitDialog.tsx
414865
415310
  function recordWorktreeExit() {
414866
415311
  (init_sessionStorage(), __toCommonJS(exports_sessionStorage)).saveWorktreeState(null);
@@ -414870,46 +415315,43 @@ function WorktreeExitDialog({
414870
415315
  onCancel
414871
415316
  }) {
414872
415317
  const [status, setStatus] = import_react166.useState("loading");
414873
- const [changes, setChanges] = import_react166.useState([]);
415318
+ const [changedFiles, setChangedFiles] = import_react166.useState(0);
414874
415319
  const [commitCount, setCommitCount] = import_react166.useState(0);
415320
+ const [stateUnknown, setStateUnknown] = import_react166.useState(false);
414875
415321
  const [resultMessage, setResultMessage] = import_react166.useState();
414876
415322
  const worktreeSession = getCurrentWorktreeSession2();
414877
415323
  import_react166.useEffect(() => {
414878
415324
  async function loadChanges() {
414879
- let changeLines = [];
414880
- const gitStatus = await execFileNoThrow3("git", ["status", "--porcelain"]);
414881
- if (gitStatus.stdout) {
414882
- changeLines = gitStatus.stdout.split(`
414883
- `).filter((_) => _.trim() !== "");
414884
- setChanges(changeLines);
414885
- }
414886
- if (worktreeSession) {
414887
- const {
414888
- stdout: commitsStr
414889
- } = await execFileNoThrow3("git", ["rev-list", "--count", `${worktreeSession.originalHeadCommit}..HEAD`]);
414890
- const count = parseInt(commitsStr.trim()) || 0;
414891
- setCommitCount(count);
414892
- if (changeLines.length === 0 && count === 0) {
414893
- setStatus("removing");
414894
- cleanupWorktree2().then(() => {
414895
- process.chdir(worktreeSession.originalCwd);
414896
- setCwd2(worktreeSession.originalCwd);
414897
- recordWorktreeExit();
414898
- getPlansDirectory2.cache.clear?.();
414899
- setResultMessage("Worktree removed (no changes)");
414900
- }).catch((error) => {
414901
- logForDebugging3(`Failed to clean up worktree: ${error}`, {
414902
- level: "error"
414903
- });
414904
- setResultMessage("Worktree cleanup failed, exiting anyway");
414905
- }).then(() => {
414906
- setStatus("done");
415325
+ if (!worktreeSession) {
415326
+ return;
415327
+ }
415328
+ const summary = await inspectWorktreeChanges(worktreeSession.worktreePath, worktreeSession.originalHeadCommit);
415329
+ if (summary === null) {
415330
+ setStateUnknown(true);
415331
+ setStatus("asking");
415332
+ return;
415333
+ }
415334
+ setChangedFiles(summary.changedFiles);
415335
+ setCommitCount(summary.commits);
415336
+ if (summary.changedFiles === 0 && summary.commits === 0) {
415337
+ setStatus("removing");
415338
+ cleanupWorktree2().then(() => {
415339
+ process.chdir(worktreeSession.originalCwd);
415340
+ setCwd2(worktreeSession.originalCwd);
415341
+ recordWorktreeExit();
415342
+ getPlansDirectory2.cache.clear?.();
415343
+ setResultMessage("Worktree removed (no changes)");
415344
+ }).catch((error) => {
415345
+ logForDebugging3(`Failed to clean up worktree: ${error}`, {
415346
+ level: "error"
414907
415347
  });
414908
- return;
414909
- } else {
414910
- setStatus("asking");
414911
- }
415348
+ setResultMessage("Worktree cleanup failed, exiting anyway");
415349
+ }).then(() => {
415350
+ setStatus("done");
415351
+ });
415352
+ return;
414912
415353
  }
415354
+ setStatus("asking");
414913
415355
  }
414914
415356
  loadChanges();
414915
415357
  }, [worktreeSession]);
@@ -414976,11 +415418,13 @@ function WorktreeExitDialog({
414976
415418
  return;
414977
415419
  }
414978
415420
  const tmuxNote = hasTmux ? " Tmux session terminated." : "";
414979
- if (commitCount > 0 && changes.length > 0) {
415421
+ if (stateUnknown) {
415422
+ setResultMessage(`Worktree removed. Worktree state could not be verified before removal.${tmuxNote}`);
415423
+ } else if (commitCount > 0 && changedFiles > 0) {
414980
415424
  setResultMessage(`Worktree removed. ${commitCount} ${commitCount === 1 ? "commit" : "commits"} and uncommitted changes were discarded.${tmuxNote}`);
414981
415425
  } else if (commitCount > 0) {
414982
415426
  setResultMessage(`Worktree removed. ${commitCount} ${commitCount === 1 ? "commit" : "commits"} on ${worktreeSession.worktreeBranch} ${commitCount === 1 ? "was" : "were"} discarded.${tmuxNote}`);
414983
- } else if (changes.length > 0) {
415427
+ } else if (changedFiles > 0) {
414984
415428
  setResultMessage(`Worktree removed. Uncommitted changes were discarded.${tmuxNote}`);
414985
415429
  } else {
414986
415430
  setResultMessage(`Worktree removed.${tmuxNote}`);
@@ -415013,13 +415457,15 @@ function WorktreeExitDialog({
415013
415457
  }, undefined, true, undefined, this);
415014
415458
  }
415015
415459
  const branchName = worktreeSession.worktreeBranch;
415016
- const hasUncommitted = changes.length > 0;
415460
+ const hasUncommitted = changedFiles > 0;
415017
415461
  const hasCommits = commitCount > 0;
415018
415462
  let subtitle = "";
415019
- if (hasUncommitted && hasCommits) {
415020
- subtitle = `You have ${changes.length} uncommitted ${changes.length === 1 ? "file" : "files"} and ${commitCount} ${commitCount === 1 ? "commit" : "commits"} on ${branchName}. All will be lost if you remove.`;
415463
+ if (stateUnknown) {
415464
+ subtitle = `Could not verify the worktree state at ${worktreeSession.worktreePath}. Keep it to stay safe, or remove it only if you are certain it holds no work.`;
415465
+ } else if (hasUncommitted && hasCommits) {
415466
+ subtitle = `You have ${changedFiles} uncommitted ${changedFiles === 1 ? "file" : "files"} and ${commitCount} ${commitCount === 1 ? "commit" : "commits"} on ${branchName}. All will be lost if you remove.`;
415021
415467
  } else if (hasUncommitted) {
415022
- subtitle = `You have ${changes.length} uncommitted ${changes.length === 1 ? "file" : "files"}. These will be lost if you remove the worktree.`;
415468
+ subtitle = `You have ${changedFiles} uncommitted ${changedFiles === 1 ? "file" : "files"}. These will be lost if you remove the worktree.`;
415023
415469
  } else if (hasCommits) {
415024
415470
  subtitle = `You have ${commitCount} ${commitCount === 1 ? "commit" : "commits"} on ${branchName}. The branch will be deleted if you remove the worktree.`;
415025
415471
  } else {
@@ -415032,7 +415478,7 @@ function WorktreeExitDialog({
415032
415478
  }
415033
415479
  handleSelect("keep");
415034
415480
  }
415035
- const removeDescription = hasUncommitted || hasCommits ? "All changes and commits will be lost." : "Clean up the worktree directory.";
415481
+ const removeDescription = stateUnknown ? "Unverified worktree — removal may discard work." : hasUncommitted || hasCommits ? "All changes and commits will be lost." : "Clean up the worktree directory.";
415036
415482
  const hasTmuxSession = Boolean(worktreeSession.tmuxSessionName);
415037
415483
  const options = hasTmuxSession ? [{
415038
415484
  label: "Keep worktree and tmux session",
@@ -415071,10 +415517,10 @@ var import_react166, jsx_dev_runtime303;
415071
415517
  var init_WorktreeExitDialog = __esm(() => {
415072
415518
  init_debug();
415073
415519
  init_ink2();
415074
- init_execFileNoThrow2();
415075
415520
  init_plans();
415076
415521
  init_Shell2();
415077
415522
  init_worktree4();
415523
+ init_worktreeChangeSummary();
415078
415524
  init_select();
415079
415525
  init_Dialog();
415080
415526
  init_Spinner();
@@ -415133,7 +415579,7 @@ var init_ExitFlow = __esm(() => {
415133
415579
  });
415134
415580
 
415135
415581
  // src/tui/utils/concurrentSessions.ts
415136
- import { chmod as chmod8, mkdir as mkdir48, readdir as readdir31, readFile as readFile58, unlink as unlink21, writeFile as writeFile43 } from "fs/promises";
415582
+ import { chmod as chmod8, mkdir as mkdir48, readdir as readdir31, readFile as readFile59, unlink as unlink23, writeFile as writeFile43 } from "fs/promises";
415137
415583
  import { join as join154 } from "path";
415138
415584
  function getSessionsDir() {
415139
415585
  return join154(getAtlasConfigHomeDir3(), "sessions");
@@ -415157,7 +415603,7 @@ async function registerSession2() {
415157
415603
  const pidFile = join154(dir, `${process.pid}.json`);
415158
415604
  registerCleanup3(async () => {
415159
415605
  try {
415160
- await unlink21(pidFile);
415606
+ await unlink23(pidFile);
415161
415607
  } catch {}
415162
415608
  });
415163
415609
  try {
@@ -415189,7 +415635,7 @@ async function registerSession2() {
415189
415635
  async function updatePidFile(patch) {
415190
415636
  const pidFile = join154(getSessionsDir(), `${process.pid}.json`);
415191
415637
  try {
415192
- const data = jsonParse2(await readFile58(pidFile, "utf8"));
415638
+ const data = jsonParse2(await readFile59(pidFile, "utf8"));
415193
415639
  await writeFile43(pidFile, jsonStringify5({ ...data, ...patch }));
415194
415640
  } catch (e) {
415195
415641
  logForDebugging3(`[concurrentSessions] updatePidFile failed: ${errorMessage2(e)}`);
@@ -415228,7 +415674,7 @@ async function countConcurrentSessions2() {
415228
415674
  if (isProcessRunning2(pid)) {
415229
415675
  count++;
415230
415676
  } else if (getPlatform3() !== "wsl") {
415231
- unlink21(join154(dir, file)).catch(() => {});
415677
+ unlink23(join154(dir, file)).catch(() => {});
415232
415678
  }
415233
415679
  }
415234
415680
  return count;
@@ -417219,7 +417665,7 @@ var init_ansiToPng = __esm(() => {
417219
417665
  });
417220
417666
 
417221
417667
  // src/tui/utils/screenshotClipboard.ts
417222
- import { mkdir as mkdir49, unlink as unlink22, writeFile as writeFile44 } from "fs/promises";
417668
+ import { mkdir as mkdir49, unlink as unlink24, writeFile as writeFile44 } from "fs/promises";
417223
417669
  import { tmpdir as tmpdir10 } from "os";
417224
417670
  import { join as join158 } from "path";
417225
417671
  async function copyAnsiToClipboard(ansiText, options) {
@@ -417231,7 +417677,7 @@ async function copyAnsiToClipboard(ansiText, options) {
417231
417677
  await writeFile44(pngPath, pngBuffer);
417232
417678
  const result = await copyPngToClipboard(pngPath);
417233
417679
  try {
417234
- await unlink22(pngPath);
417680
+ await unlink24(pngPath);
417235
417681
  } catch {}
417236
417682
  return result;
417237
417683
  } catch (error) {
@@ -420344,8 +420790,8 @@ __export(exports_insights, {
420344
420790
  import {
420345
420791
  mkdir as mkdir50,
420346
420792
  readdir as readdir32,
420347
- readFile as readFile59,
420348
- unlink as unlink23,
420793
+ readFile as readFile60,
420794
+ unlink as unlink25,
420349
420795
  writeFile as writeFile45
420350
420796
  } from "fs/promises";
420351
420797
  import { extname as extname16, join as join160 } from "path";
@@ -420705,11 +421151,11 @@ async function formatTranscriptWithSummarization(log) {
420705
421151
  async function loadCachedFacets(sessionId) {
420706
421152
  const facetPath = join160(getFacetsDir(), `${sessionId}.json`);
420707
421153
  try {
420708
- const content = await readFile59(facetPath, { encoding: "utf-8" });
421154
+ const content = await readFile60(facetPath, { encoding: "utf-8" });
420709
421155
  const parsed = jsonParse2(content);
420710
421156
  if (!isValidSessionFacets(parsed)) {
420711
421157
  try {
420712
- await unlink23(facetPath);
421158
+ await unlink25(facetPath);
420713
421159
  } catch {}
420714
421160
  return null;
420715
421161
  }
@@ -420731,7 +421177,7 @@ async function saveFacets(facets) {
420731
421177
  async function loadCachedSessionMeta(sessionId) {
420732
421178
  const metaPath = join160(getSessionMetaDir(), `${sessionId}.json`);
420733
421179
  try {
420734
- const content = await readFile59(metaPath, { encoding: "utf-8" });
421180
+ const content = await readFile60(metaPath, { encoding: "utf-8" });
420735
421181
  return jsonParse2(content);
420736
421182
  } catch {
420737
421183
  return null;
@@ -422787,12 +423233,12 @@ __export(exports_sessionStorage, {
422787
423233
  import { closeSync as closeSync7, fstatSync as fstatSync2, openSync as openSync7, readSync as readSync6 } from "fs";
422788
423234
  import {
422789
423235
  appendFile as fsAppendFile2,
422790
- open as fsOpen3,
423236
+ open as fsOpen4,
422791
423237
  mkdir as mkdir51,
422792
423238
  readdir as readdir33,
422793
- readFile as readFile60,
423239
+ readFile as readFile61,
422794
423240
  stat as stat49,
422795
- unlink as unlink24,
423241
+ unlink as unlink26,
422796
423242
  writeFile as writeFile46
422797
423243
  } from "fs/promises";
422798
423244
  import { basename as basename48, dirname as dirname76, join as join161 } from "path";
@@ -422846,7 +423292,7 @@ async function writeAgentMetadata(agentId, metadata) {
422846
423292
  async function readAgentMetadata(agentId) {
422847
423293
  const path = getAgentMetadataPath(agentId);
422848
423294
  try {
422849
- const raw = await readFile60(path, "utf-8");
423295
+ const raw = await readFile61(path, "utf-8");
422850
423296
  return JSON.parse(raw);
422851
423297
  } catch (e) {
422852
423298
  if (isFsInaccessible2(e))
@@ -422973,11 +423419,14 @@ class Project2 {
422973
423419
  }, this.FLUSH_INTERVAL_MS);
422974
423420
  }
422975
423421
  async appendToFile(filePath, data) {
423422
+ const needsSeparator = await transcriptTailNeedsSeparator2(filePath);
423423
+ const payload = needsSeparator ? `
423424
+ ` + data : data;
422976
423425
  try {
422977
- await fsAppendFile2(filePath, data, { mode: 384 });
423426
+ await fsAppendFile2(filePath, payload, { mode: 384 });
422978
423427
  } catch {
422979
423428
  await mkdir51(dirname76(filePath), { recursive: true, mode: 448 });
422980
- await fsAppendFile2(filePath, data, { mode: 384 });
423429
+ await fsAppendFile2(filePath, payload, { mode: 384 });
422981
423430
  }
422982
423431
  }
422983
423432
  async drainWriteQueue() {
@@ -423140,7 +423589,7 @@ class Project2 {
423140
423589
  return;
423141
423590
  try {
423142
423591
  let fileSize = 0;
423143
- const fh = await fsOpen3(this.sessionFile, "r+");
423592
+ const fh = await fsOpen4(this.sessionFile, "r+");
423144
423593
  try {
423145
423594
  const { size } = await fh.stat();
423146
423595
  fileSize = size;
@@ -423175,7 +423624,7 @@ class Project2 {
423175
423624
  logForDebugging3(`Skipping tombstone removal: session file too large (${formatFileSize3(fileSize)})`, { level: "warn" });
423176
423625
  return;
423177
423626
  }
423178
- const content = await readFile60(this.sessionFile, { encoding: "utf-8" });
423627
+ const content = await readFile61(this.sessionFile, { encoding: "utf-8" });
423179
423628
  const lines = content.split(`
423180
423629
  `).filter((line) => {
423181
423630
  if (!line.trim())
@@ -423875,11 +424324,13 @@ function appendEntryToFile2(fullPath, entry) {
423875
424324
  const fs = getFsImplementation2();
423876
424325
  const line = jsonStringify5(entry) + `
423877
424326
  `;
424327
+ const payload = transcriptTailNeedsSeparatorSync2(fullPath) ? `
424328
+ ` + line : line;
423878
424329
  try {
423879
- fs.appendFileSync(fullPath, line, { mode: 384 });
424330
+ fs.appendFileSync(fullPath, payload, { mode: 384 });
423880
424331
  } catch {
423881
424332
  fs.mkdirSync(dirname76(fullPath), { mode: 448 });
423882
- fs.appendFileSync(fullPath, line, { mode: 384 });
424333
+ fs.appendFileSync(fullPath, payload, { mode: 384 });
423883
424334
  }
423884
424335
  }
423885
424336
  function readFileTailSync2(fullPath) {
@@ -423901,6 +424352,42 @@ function readFileTailSync2(fullPath) {
423901
424352
  }
423902
424353
  }
423903
424354
  }
424355
+ async function transcriptTailNeedsSeparator2(fullPath) {
424356
+ let fh;
424357
+ try {
424358
+ const st = await stat49(fullPath);
424359
+ if (!st.isFile() || st.size === 0)
424360
+ return false;
424361
+ fh = await fsOpen4(fullPath, "r");
424362
+ const buf = Buffer.alloc(1);
424363
+ const { bytesRead } = await fh.read(buf, 0, 1, st.size - 1);
424364
+ return bytesRead === 1 && buf[0] !== 10;
424365
+ } catch {
424366
+ return false;
424367
+ } finally {
424368
+ await fh?.close().catch(() => {});
424369
+ }
424370
+ }
424371
+ function transcriptTailNeedsSeparatorSync2(fullPath) {
424372
+ let fd;
424373
+ try {
424374
+ fd = openSync7(fullPath, "r");
424375
+ const st = fstatSync2(fd);
424376
+ if (st.size === 0)
424377
+ return false;
424378
+ const buf = Buffer.alloc(1);
424379
+ const bytesRead = readSync6(fd, buf, 0, 1, st.size - 1);
424380
+ return bytesRead === 1 && buf[0] !== 10;
424381
+ } catch {
424382
+ return false;
424383
+ } finally {
424384
+ if (fd !== undefined) {
424385
+ try {
424386
+ closeSync7(fd);
424387
+ } catch {}
424388
+ }
424389
+ }
424390
+ }
423904
424391
  async function saveCustomTitle(sessionId, customTitle, fullPath, source = "user") {
423905
424392
  const resolvedPath = fullPath ?? getTranscriptPathForSession3(sessionId);
423906
424393
  appendEntryToFile2(resolvedPath, {
@@ -424388,7 +424875,7 @@ async function loadTranscriptFile2(filePath, opts) {
424388
424875
  }
424389
424876
  }
424390
424877
  }
424391
- buf ??= await readFile60(filePath);
424878
+ buf ??= await readFile61(filePath);
424392
424879
  if (!opts?.keepAllLeaves && !hasPreservedSegment && !isEnvTruthy2(process.env.ATLAS_DISABLE_PRECOMPACT_SKIP) && buf.length > SKIP_PRECOMPACT_THRESHOLD2) {
424393
424880
  buf = walkChainBeforeParse2(buf);
424394
424881
  }
@@ -425318,7 +425805,7 @@ var init_sessionStorage = __esm(() => {
425318
425805
  // src/tui/utils/plans.ts
425319
425806
  import { randomUUID as randomUUID40 } from "crypto";
425320
425807
  import { copyFile as copyFile9, writeFile as writeFile47 } from "fs/promises";
425321
- import { join as join162, resolve as resolve54, sep as sep35 } from "path";
425808
+ import { join as join162, resolve as resolve55, sep as sep35 } from "path";
425322
425809
  function getPlanSlug2(sessionId) {
425323
425810
  const id = sessionId ?? getSessionId();
425324
425811
  const cache = getPlanSlugCache();
@@ -425528,7 +426015,7 @@ var init_plans = __esm(() => {
425528
426015
  let plansPath;
425529
426016
  if (settingsDir) {
425530
426017
  const cwd = getCwd();
425531
- const resolved = resolve54(cwd, settingsDir);
426018
+ const resolved = resolve55(cwd, settingsDir);
425532
426019
  if (!resolved.startsWith(cwd + sep35) && resolved !== cwd) {
425533
426020
  logError3(new Error(`plansDirectory must be within project root: ${settingsDir}`));
425534
426021
  plansPath = join162(getAtlasConfigHomeDir3(), "plans");
@@ -425550,7 +426037,7 @@ var init_plans = __esm(() => {
425550
426037
  // src/tui/utils/permissions/filesystem.ts
425551
426038
  import { randomBytes as randomBytes21 } from "crypto";
425552
426039
  import { homedir as homedir38, tmpdir as tmpdir11 } from "os";
425553
- import { join as join163, normalize as normalize15, posix as posix9, resolve as resolve55, sep as sep36 } from "path";
426040
+ import { join as join163, normalize as normalize15, posix as posix9, resolve as resolve56, sep as sep36 } from "path";
425554
426041
  function normalizeCaseForComparison2(path) {
425555
426042
  return path.toLowerCase();
425556
426043
  }
@@ -425778,7 +426265,7 @@ function isActiveWorktreeCwd2(cwd) {
425778
426265
  });
425779
426266
  const gitdirMatch = content.match(/^gitdir:\s*(.+)$/m);
425780
426267
  if (gitdirMatch?.[1]) {
425781
- const gitdir = resolve55(cwd, gitdirMatch[1].trim());
426268
+ const gitdir = resolve56(cwd, gitdirMatch[1].trim());
425782
426269
  active = gitdir.lastIndexOf(sep36 + ".git" + sep36 + "worktrees" + sep36) > 0;
425783
426270
  }
425784
426271
  } catch {
@@ -426490,7 +426977,7 @@ import {
426490
426977
  open as open19,
426491
426978
  stat as stat50,
426492
426979
  symlink as symlink7,
426493
- unlink as unlink25
426980
+ unlink as unlink27
426494
426981
  } from "fs/promises";
426495
426982
  import { join as join164 } from "path";
426496
426983
  function getTaskOutputDir2() {
@@ -426672,7 +427159,7 @@ function initTaskOutputAsSymlink(taskId, targetPath) {
426672
427159
  try {
426673
427160
  await symlink7(targetPath, outputPath);
426674
427161
  } catch {
426675
- await unlink25(outputPath);
427162
+ await unlink27(outputPath);
426676
427163
  await symlink7(targetPath, outputPath);
426677
427164
  }
426678
427165
  return outputPath;
@@ -433908,7 +434395,7 @@ var init_summarizeFallback = __esm(() => {
433908
434395
  });
433909
434396
 
433910
434397
  // src/tui/services/SessionMemory/prompts.ts
433911
- import { readFile as readFile61 } from "fs/promises";
434398
+ import { readFile as readFile62 } from "fs/promises";
433912
434399
  import { join as join165 } from "path";
433913
434400
  function getDefaultUpdatePrompt() {
433914
434401
  return `IMPORTANT: This message and these instructions are NOT part of the actual user conversation. Do NOT include any references to "note-taking", "session notes extraction", or these update instructions in the notes content.
@@ -433952,7 +434439,7 @@ REMEMBER: Use the Edit tool in parallel and stop. Do not continue after the edit
433952
434439
  async function loadSessionMemoryTemplate() {
433953
434440
  const templatePath = join165(getAtlasConfigHomeDir3(), "session-memory", "config", "template.md");
433954
434441
  try {
433955
- return await readFile61(templatePath, { encoding: "utf-8" });
434442
+ return await readFile62(templatePath, { encoding: "utf-8" });
433956
434443
  } catch (e) {
433957
434444
  const code = getErrnoCode2(e);
433958
434445
  if (code === "ENOENT") {
@@ -433965,7 +434452,7 @@ async function loadSessionMemoryTemplate() {
433965
434452
  async function loadSessionMemoryPrompt() {
433966
434453
  const promptPath = join165(getAtlasConfigHomeDir3(), "session-memory", "config", "prompt.md");
433967
434454
  try {
433968
- return await readFile61(promptPath, { encoding: "utf-8" });
434455
+ return await readFile62(promptPath, { encoding: "utf-8" });
433969
434456
  } catch (e) {
433970
434457
  const code = getErrnoCode2(e);
433971
434458
  if (code === "ENOENT") {
@@ -452165,7 +452652,7 @@ var init_useUpdateNotification = __esm(() => {
452165
452652
  });
452166
452653
 
452167
452654
  // src/tui/utils/updateCheck.ts
452168
- import { mkdir as mkdir53, readFile as readFile62, writeFile as writeFile48 } from "node:fs/promises";
452655
+ import { mkdir as mkdir53, readFile as readFile63, writeFile as writeFile48 } from "node:fs/promises";
452169
452656
  import { homedir as homedir40 } from "node:os";
452170
452657
  import { join as join169 } from "node:path";
452171
452658
  function buildUpdateUpgradeCommand() {
@@ -452194,7 +452681,7 @@ function createDiskUpdateCache(dir) {
452194
452681
  return {
452195
452682
  async read() {
452196
452683
  try {
452197
- const raw = await readFile62(getUpdateCachePath(dir), "utf8");
452684
+ const raw = await readFile63(getUpdateCachePath(dir), "utf8");
452198
452685
  const parsed = JSON.parse(raw);
452199
452686
  if ((parsed.latest === null || typeof parsed.latest === "string") && typeof parsed.checkedAtMs === "number") {
452200
452687
  return { latest: parsed.latest, checkedAtMs: parsed.checkedAtMs };
@@ -469379,7 +469866,7 @@ var init_coordinatorHandler = __esm(() => {
469379
469866
  });
469380
469867
 
469381
469868
  // src/tui/utils/permissions/sessionPermissionRules.ts
469382
- import { mkdir as mkdir54, readFile as readFile63, rename as rename11, writeFile as writeFile49 } from "fs/promises";
469869
+ import { mkdir as mkdir54, readFile as readFile64, rename as rename11, writeFile as writeFile49 } from "fs/promises";
469383
469870
  import { dirname as dirname80, join as join173 } from "path";
469384
469871
  function sessionRulesPath(sessionId, projectDir) {
469385
469872
  return join173(projectDir, `${sessionId}${SESSION_RULES_FILE_SUFFIX}`);
@@ -469420,7 +469907,7 @@ function isSessionAddRules(u) {
469420
469907
  }
469421
469908
  async function readSessionPermissionRules(sessionId, projectDir) {
469422
469909
  try {
469423
- const raw = await readFile63(sessionRulesPath(sessionId, projectDir), "utf8");
469910
+ const raw = await readFile64(sessionRulesPath(sessionId, projectDir), "utf8");
469424
469911
  return parseSessionRulesJson(raw);
469425
469912
  } catch (e) {
469426
469913
  logForDebugging3(`readSessionPermissionRules: no/corrupt sidecar for ${sessionId}: ${e}`);
@@ -473716,11 +474203,11 @@ var init_builtinMarketplaceSnapshots = __esm(() => {
473716
474203
  // src/tui/utils/plugins/marketplaceSnapshotFallback.ts
473717
474204
  import {
473718
474205
  mkdir as mkdir55,
473719
- readFile as readFile64,
474206
+ readFile as readFile65,
473720
474207
  rm as rm11,
473721
474208
  writeFile as writeFile50
473722
474209
  } from "fs/promises";
473723
- import { join as join175, resolve as resolve57, sep as sep41 } from "path";
474210
+ import { join as join175, resolve as resolve58, sep as sep41 } from "path";
473724
474211
  function getBuiltinSnapshotRoot() {
473725
474212
  return join175(getMarketplacesCacheDir(), "builtin-snapshots");
473726
474213
  }
@@ -473732,7 +474219,7 @@ function isBuiltinSnapshotEntry(entry) {
473732
474219
  return false;
473733
474220
  if (entry.source.source !== "directory")
473734
474221
  return false;
473735
- const root = resolve57(getBuiltinSnapshotRoot()) + sep41;
474222
+ const root = resolve58(getBuiltinSnapshotRoot()) + sep41;
473736
474223
  return entry.installLocation.startsWith(root);
473737
474224
  }
473738
474225
  async function installBuiltinSnapshotFallback(marketplaceName) {
@@ -473778,7 +474265,7 @@ async function materializeSnapshot(snapshotDir, manifest) {
473778
474265
  await mkdir55(join175(snapshotDir, manifestDirName), { recursive: true });
473779
474266
  const content = jsonStringify5(manifest, null, 2);
473780
474267
  await writeFile50(manifestPath, content, { encoding: "utf-8" });
473781
- const roundTrip = JSON.parse(await readFile64(manifestPath, "utf-8"));
474268
+ const roundTrip = JSON.parse(await readFile65(manifestPath, "utf-8"));
473782
474269
  PluginMarketplaceSchema().parse(roundTrip);
473783
474270
  }
473784
474271
  var init_marketplaceSnapshotFallback = __esm(() => {
@@ -476253,7 +476740,7 @@ var init_usePluginAutoupdateNotification = __esm(() => {
476253
476740
  });
476254
476741
 
476255
476742
  // src/tui/utils/plugins/reconciler.ts
476256
- import { isAbsolute as isAbsolute34, resolve as resolve58 } from "path";
476743
+ import { isAbsolute as isAbsolute34, resolve as resolve59 } from "path";
476257
476744
  function diffMarketplaces(declared, materialized, opts) {
476258
476745
  const missing = [];
476259
476746
  const sourceChanged = [];
@@ -476366,7 +476853,7 @@ function normalizeSource(source, projectRoot) {
476366
476853
  const canonicalRoot = findCanonicalGitRoot2(base);
476367
476854
  return {
476368
476855
  ...source,
476369
- path: resolve58(canonicalRoot ?? base, source.path)
476856
+ path: resolve59(canonicalRoot ?? base, source.path)
476370
476857
  };
476371
476858
  }
476372
476859
  return source;
@@ -479358,7 +479845,7 @@ var init_cronJitterConfig2 = __esm(() => {
479358
479845
  });
479359
479846
 
479360
479847
  // src/tui/utils/cronTasksLock.ts
479361
- import { mkdir as mkdir56, readFile as readFile65, unlink as unlink26, writeFile as writeFile51 } from "fs/promises";
479848
+ import { mkdir as mkdir56, readFile as readFile66, unlink as unlink28, writeFile as writeFile51 } from "fs/promises";
479362
479849
  import { dirname as dirname83, join as join178 } from "path";
479363
479850
  function getLockPath3(dir) {
479364
479851
  return join178(dir ?? getProjectRoot(), LOCK_FILE_REL2);
@@ -479366,7 +479853,7 @@ function getLockPath3(dir) {
479366
479853
  async function readLock3(dir) {
479367
479854
  let raw;
479368
479855
  try {
479369
- raw = await readFile65(getLockPath3(dir), "utf8");
479856
+ raw = await readFile66(getLockPath3(dir), "utf8");
479370
479857
  } catch {
479371
479858
  return;
479372
479859
  }
@@ -479435,7 +479922,7 @@ async function tryAcquireSchedulerLock2(opts) {
479435
479922
  if (existing) {
479436
479923
  logForDebugging3(`[ScheduledTasks] recovering stale scheduler lock from PID ${existing.pid}`);
479437
479924
  }
479438
- await unlink26(getLockPath3(dir)).catch(() => {});
479925
+ await unlink28(getLockPath3(dir)).catch(() => {});
479439
479926
  if (await tryCreateExclusive3(lock, dir)) {
479440
479927
  lastBlockedBy2 = undefined;
479441
479928
  registerLockCleanup3(opts);
@@ -479453,7 +479940,7 @@ async function releaseSchedulerLock2(opts) {
479453
479940
  if (!existing || existing.sessionId !== sessionId)
479454
479941
  return;
479455
479942
  try {
479456
- await unlink26(getLockPath3(dir));
479943
+ await unlink28(getLockPath3(dir));
479457
479944
  logForDebugging3("[ScheduledTasks] released scheduler lock");
479458
479945
  } catch {}
479459
479946
  }
@@ -490697,6 +491184,7 @@ async function setup(cwd, permissionMode, allowDangerouslySkipPermissions, workt
490697
491184
  }
490698
491185
  const slug = worktreePRNumber ? `pr-${worktreePRNumber}` : worktreeName ?? getPlanSlug2();
490699
491186
  let tmuxSessionName;
491187
+ let sourceCheckout;
490700
491188
  if (inGit) {
490701
491189
  const mainRepoRoot = findCanonicalGitRoot2(getCwd());
490702
491190
  if (!mainRepoRoot) {
@@ -490705,6 +491193,11 @@ async function setup(cwd, permissionMode, allowDangerouslySkipPermissions, workt
490705
491193
  process.exit(1);
490706
491194
  }
490707
491195
  if (mainRepoRoot !== (findGitRoot2(getCwd()) ?? getCwd())) {
491196
+ const callingCwd = getCwd();
491197
+ const headCommit = await readCheckoutHeadSha2(callingCwd);
491198
+ if (headCommit) {
491199
+ sourceCheckout = { cwd: callingCwd, headCommit };
491200
+ }
490708
491201
  logForDiagnosticsNoPII("info", "worktree_resolved_to_main_repo");
490709
491202
  process.chdir(mainRepoRoot);
490710
491203
  setCwd2(mainRepoRoot);
@@ -490715,7 +491208,10 @@ async function setup(cwd, permissionMode, allowDangerouslySkipPermissions, workt
490715
491208
  }
490716
491209
  let worktreeSession;
490717
491210
  try {
490718
- worktreeSession = await createWorktreeForSession2(getSessionId(), slug, tmuxSessionName, worktreePRNumber ? { prNumber: worktreePRNumber } : undefined);
491211
+ worktreeSession = await createWorktreeForSession2(getSessionId(), slug, tmuxSessionName, worktreePRNumber || sourceCheckout ? {
491212
+ ...worktreePRNumber ? { prNumber: worktreePRNumber } : {},
491213
+ ...sourceCheckout ? { sourceCheckout } : {}
491214
+ } : undefined);
490719
491215
  } catch (error) {
490720
491216
  process.stderr.write(source_default.red(`Error creating worktree: ${errorMessage2(error)}
490721
491217
  `));
@@ -490817,6 +491313,7 @@ var init_setup4 = __esm(() => {
490817
491313
  init_envUtils2();
490818
491314
  init_errors4();
490819
491315
  init_git2();
491316
+ init_gitFilesystem();
490820
491317
  init_fileChangedWatcher();
490821
491318
  init_hooksConfigSnapshot();
490822
491319
  init_hooks7();
@@ -491656,7 +492153,7 @@ var init_mcp8 = __esm(() => {
491656
492153
  });
491657
492154
 
491658
492155
  // src/tui/utils/atlasDesktop.ts
491659
- import { readdir as readdir34, readFile as readFile66, stat as stat55 } from "fs/promises";
492156
+ import { readdir as readdir34, readFile as readFile67, stat as stat55 } from "fs/promises";
491660
492157
  import { homedir as homedir48 } from "os";
491661
492158
  import { join as join185 } from "path";
491662
492159
  async function getDesktopConfigPath() {
@@ -491704,7 +492201,7 @@ async function readDesktopMcpServers() {
491704
492201
  const configPath = await getDesktopConfigPath();
491705
492202
  let configContent;
491706
492203
  try {
491707
- configContent = await readFile66(configPath, { encoding: "utf8" });
492204
+ configContent = await readFile67(configPath, { encoding: "utf8" });
491708
492205
  } catch (e) {
491709
492206
  const code = getErrnoCode2(e);
491710
492207
  if (code === "ENOENT") {
@@ -492145,12 +492642,12 @@ var init_auth6 = __esm(() => {
492145
492642
  });
492146
492643
 
492147
492644
  // src/tui/utils/plugins/marketplacePublish.ts
492148
- import { cp, mkdir as mkdir57, readFile as readFile67, rm as rm12, writeFile as writeFile54 } from "fs/promises";
492645
+ import { cp, mkdir as mkdir57, readFile as readFile68, rm as rm12, writeFile as writeFile54 } from "fs/promises";
492149
492646
  import {
492150
492647
  dirname as dirname87,
492151
492648
  join as join186,
492152
492649
  relative as relative38,
492153
- resolve as resolve59,
492650
+ resolve as resolve60,
492154
492651
  sep as sep43
492155
492652
  } from "path";
492156
492653
  function git(marketplaceDir, args, timeoutMs = 2 * 60 * 1000) {
@@ -492163,8 +492660,8 @@ function gitFailureMessage(res) {
492163
492660
  return (res.stderr || res.error || `exit code ${res.code}`).trim();
492164
492661
  }
492165
492662
  async function publishPluginToMarketplace(opts) {
492166
- const pluginDir = resolve59(opts.pluginDir);
492167
- const marketplaceDir = resolve59(opts.marketplaceDir);
492663
+ const pluginDir = resolve60(opts.pluginDir);
492664
+ const marketplaceDir = resolve60(opts.marketplaceDir);
492168
492665
  const notes = [];
492169
492666
  if (pluginDir === marketplaceDir || pluginDir.startsWith(marketplaceDir + sep43)) {
492170
492667
  throw new Error(`Cannot publish "${pluginDir}": the plugin directory must not live inside the target marketplace (${marketplaceDir})`);
@@ -492172,7 +492669,7 @@ async function publishPluginToMarketplace(opts) {
492172
492669
  const pluginManifestPath = findManifestInDir(pluginDir, "plugin.json");
492173
492670
  let pluginManifestRaw;
492174
492671
  try {
492175
- pluginManifestRaw = await readFile67(pluginManifestPath, {
492672
+ pluginManifestRaw = await readFile68(pluginManifestPath, {
492176
492673
  encoding: "utf-8"
492177
492674
  });
492178
492675
  } catch {
@@ -492197,7 +492694,7 @@ async function publishPluginToMarketplace(opts) {
492197
492694
  const marketplaceManifestPath = findManifestInDir(marketplaceDir, "marketplace.json");
492198
492695
  let marketplaceRaw;
492199
492696
  try {
492200
- marketplaceRaw = await readFile67(marketplaceManifestPath, {
492697
+ marketplaceRaw = await readFile68(marketplaceManifestPath, {
492201
492698
  encoding: "utf-8"
492202
492699
  });
492203
492700
  } catch {
@@ -492295,9 +492792,9 @@ var init_marketplacePublish = __esm(() => {
492295
492792
  import { userInfo as userInfo2 } from "os";
492296
492793
  import { existsSync as existsSync15 } from "fs";
492297
492794
  import { mkdir as mkdir58, writeFile as writeFile55 } from "fs/promises";
492298
- import { dirname as dirname88, join as join187, resolve as resolve60 } from "path";
492795
+ import { dirname as dirname88, join as join187, resolve as resolve61 } from "path";
492299
492796
  async function scaffoldMarketplace(opts) {
492300
- const targetDir = resolve60(opts.targetDir);
492797
+ const targetDir = resolve61(opts.targetDir);
492301
492798
  const name = opts.name.trim();
492302
492799
  const manifestDirName = getPluginManifestDirs()[0];
492303
492800
  const marketplaceManifestPath = join187(targetDir, manifestDirName, "marketplace.json");
@@ -492383,7 +492880,7 @@ var init_marketplaceScaffold = __esm(() => {
492383
492880
  });
492384
492881
 
492385
492882
  // src/tui/cli/handlers/plugins.ts
492386
- import { basename as basename65, dirname as dirname89, resolve as resolve61 } from "path";
492883
+ import { basename as basename65, dirname as dirname89, resolve as resolve62 } from "path";
492387
492884
  function handleMarketplaceError(error, action) {
492388
492885
  logError3(error);
492389
492886
  cliError2(`${figures_default.cross} Failed to ${action}: ${errorMessage2(error)}`);
@@ -492735,7 +493232,7 @@ async function marketplaceUpdateHandler(name, options) {
492735
493232
  async function marketplaceScaffoldHandler(options) {
492736
493233
  if (options.cowork)
492737
493234
  setUseCoworkPlugins(true);
492738
- const targetDir = resolve61(options.target ?? process.cwd());
493235
+ const targetDir = resolve62(options.target ?? process.cwd());
492739
493236
  try {
492740
493237
  const result = await scaffoldMarketplace({
492741
493238
  name: options.name,
@@ -492760,8 +493257,8 @@ async function marketplacePublishHandler(options) {
492760
493257
  setUseCoworkPlugins(true);
492761
493258
  try {
492762
493259
  const result = await publishPluginToMarketplace({
492763
- pluginDir: resolve61(options.plugin),
492764
- marketplaceDir: resolve61(options.marketplace),
493260
+ pluginDir: resolve62(options.plugin),
493261
+ marketplaceDir: resolve62(options.marketplace),
492765
493262
  version: options.version,
492766
493263
  push: options.push
492767
493264
  });
@@ -493979,7 +494476,7 @@ var init_update2 = __esm(() => {
493979
494476
 
493980
494477
  // src/tui/main.tsx
493981
494478
  import { readFileSync as readFileSync25 } from "fs";
493982
- import { resolve as resolve62 } from "path";
494479
+ import { resolve as resolve63 } from "path";
493983
494480
  function logManagedSettings() {
493984
494481
  try {
493985
494482
  const policySettings = getSettingsForSource2("policySettings");
@@ -494556,12 +495053,12 @@ ${getTmuxInstallInstructions3()}
494556
495053
  process.exit(1);
494557
495054
  }
494558
495055
  try {
494559
- const filePath = resolve62(options.systemPromptFile);
495056
+ const filePath = resolve63(options.systemPromptFile);
494560
495057
  systemPrompt = readFileSync25(filePath, "utf8");
494561
495058
  } catch (error) {
494562
495059
  const code = getErrnoCode2(error);
494563
495060
  if (code === "ENOENT") {
494564
- process.stderr.write(source_default.red(`Error: System prompt file not found: ${resolve62(options.systemPromptFile)}
495061
+ process.stderr.write(source_default.red(`Error: System prompt file not found: ${resolve63(options.systemPromptFile)}
494565
495062
  `));
494566
495063
  process.exit(1);
494567
495064
  }
@@ -494578,12 +495075,12 @@ ${getTmuxInstallInstructions3()}
494578
495075
  process.exit(1);
494579
495076
  }
494580
495077
  try {
494581
- const filePath = resolve62(options.appendSystemPromptFile);
495078
+ const filePath = resolve63(options.appendSystemPromptFile);
494582
495079
  appendSystemPrompt = readFileSync25(filePath, "utf8");
494583
495080
  } catch (error) {
494584
495081
  const code = getErrnoCode2(error);
494585
495082
  if (code === "ENOENT") {
494586
- process.stderr.write(source_default.red(`Error: Append system prompt file not found: ${resolve62(options.appendSystemPromptFile)}
495083
+ process.stderr.write(source_default.red(`Error: Append system prompt file not found: ${resolve63(options.appendSystemPromptFile)}
494587
495084
  `));
494588
495085
  process.exit(1);
494589
495086
  }
@@ -494633,7 +495130,7 @@ ${addendum}` : addendum;
494633
495130
  errors = result.errors;
494634
495131
  }
494635
495132
  } else {
494636
- const configPath = resolve62(configItem);
495133
+ const configPath = resolve63(configItem);
494637
495134
  const result = parseMcpConfigFromFilePath({
494638
495135
  filePath: configPath,
494639
495136
  expandVars: true,
@@ -496280,7 +496777,7 @@ function createInMemorySandboxDeps() {
496280
496777
  // src/atlascode/adapters/sessionMemoryPortAdapter.ts
496281
496778
  init_engine();
496282
496779
  init_shared();
496283
- import { mkdir as mkdir12, readFile as readFile13, writeFile as writeFile8 } from "fs/promises";
496780
+ import { mkdir as mkdir12, readFile as readFile14, writeFile as writeFile8 } from "fs/promises";
496284
496781
  import { dirname as dirname22, join as join41 } from "path";
496285
496782
  function sessionMemoryPath() {
496286
496783
  const env = getSessionEnv();
@@ -496290,7 +496787,7 @@ function createSessionMemoryPort() {
496290
496787
  return {
496291
496788
  async load() {
496292
496789
  try {
496293
- return await readFile13(sessionMemoryPath(), "utf-8");
496790
+ return await readFile14(sessionMemoryPath(), "utf-8");
496294
496791
  } catch (e) {
496295
496792
  if (isFsInaccessible(e))
496296
496793
  return null;
@@ -496924,7 +497421,7 @@ function getAscendExecutor() {
496924
497421
  return _instance;
496925
497422
  }
496926
497423
  // src/ascend/tools/SpecParser.ts
496927
- import { readFile as readFile14 } from "node:fs/promises";
497424
+ import { readFile as readFile15 } from "node:fs/promises";
496928
497425
 
496929
497426
  // src/ascend/tools/constants.ts
496930
497427
  var SPEC_PARSER_TOOL_NAME = "AscendSpecParser";
@@ -496992,7 +497489,7 @@ var SpecParser = {
496992
497489
  let raw = inp.spec_source;
496993
497490
  let parsedFromFile = false;
496994
497491
  try {
496995
- const fileContent = await readFile14(inp.spec_source, "utf-8");
497492
+ const fileContent = await readFile15(inp.spec_source, "utf-8");
496996
497493
  raw = fileContent;
496997
497494
  parsedFromFile = true;
496998
497495
  } catch {}