@bastani/atomic 0.9.16-alpha.3 → 0.9.16-alpha.4

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.
@@ -16,6 +16,96 @@ var __export = (target, all) => {
16
16
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
17
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
18
 
19
+ // src/core/builtin-install-layout.ts
20
+ function requiredEntriesForBuiltin(dirName) {
21
+ return [INSTALLED_EXTENSION_ENTRIES[dirName], SOURCE_EXTENSION_ENTRIES[dirName]];
22
+ }
23
+ var BUILTIN_PACKAGE_DIR_NAMES, SOURCE_EXTENSION_ENTRIES, INSTALLED_EXTENSION_ENTRIES;
24
+ var init_builtin_install_layout = __esm(() => {
25
+ BUILTIN_PACKAGE_DIR_NAMES = ["workflows", "subagents", "mcp", "web-access", "intercom"];
26
+ SOURCE_EXTENSION_ENTRIES = {
27
+ workflows: "src/extension/index.ts",
28
+ subagents: "src/extension/index.ts",
29
+ mcp: "index.ts",
30
+ "web-access": "index.ts",
31
+ intercom: "index.ts"
32
+ };
33
+ INSTALLED_EXTENSION_ENTRIES = {
34
+ workflows: "src/extension/index.bundle.mjs",
35
+ subagents: "src/extension/index.bundle.mjs",
36
+ mcp: "index.bundle.mjs",
37
+ "web-access": "index.bundle.mjs",
38
+ intercom: "index.bundle.mjs"
39
+ };
40
+ });
41
+
42
+ // src/config-package-identity.ts
43
+ import { existsSync, readFileSync } from "fs";
44
+ import { dirname, join } from "path";
45
+ function isCompanionBuiltinPackageName(name) {
46
+ return name !== undefined && COMPANION_BUILTIN_PACKAGE_NAMES.includes(name);
47
+ }
48
+ function packageJsonDefinesAppIdentity(pkg) {
49
+ if (pkg.name === "@bastani/atomic" || pkg.name === "@mariozechner/pi")
50
+ return true;
51
+ return pkg.atomicConfig !== undefined || pkg.piConfig !== undefined;
52
+ }
53
+ function resolvePackageDirFrom(startDir) {
54
+ let dir = startDir;
55
+ let firstPackageDir;
56
+ while (dir !== dirname(dir)) {
57
+ const packageJsonPath = join(dir, "package.json");
58
+ if (existsSync(packageJsonPath)) {
59
+ firstPackageDir ??= dir;
60
+ if (shouldUsePackageDir(readPackageIdentity(packageJsonPath))) {
61
+ return dir;
62
+ }
63
+ }
64
+ dir = dirname(dir);
65
+ }
66
+ return firstPackageDir ?? startDir;
67
+ }
68
+ function shouldUsePackageDir(pkg) {
69
+ if (packageJsonDefinesAppIdentity(pkg))
70
+ return true;
71
+ return !isCompanionBuiltinPackageName(pkg.name);
72
+ }
73
+ function isJsonValue(value) {
74
+ if (value === null || typeof value === "boolean" || typeof value === "string")
75
+ return true;
76
+ if (typeof value === "number")
77
+ return Number.isFinite(value);
78
+ if (Array.isArray(value))
79
+ return value.every(isJsonValue);
80
+ if (typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype)
81
+ return false;
82
+ return Object.values(value).every(isJsonValue);
83
+ }
84
+ function isJsonObject(value) {
85
+ return value !== null && typeof value === "object" && !Array.isArray(value);
86
+ }
87
+ function readPackageIdentity(packageJsonPath) {
88
+ try {
89
+ const parsed = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
90
+ if (!isJsonValue(parsed) || !isJsonObject(parsed))
91
+ return {};
92
+ const name = parsed.name;
93
+ const atomicConfig = parsed.atomicConfig;
94
+ const piConfig = parsed.piConfig;
95
+ return {
96
+ ...typeof name === "string" ? { name } : {},
97
+ ...atomicConfig !== undefined && isJsonObject(atomicConfig) ? { atomicConfig } : {},
98
+ ...piConfig !== undefined && isJsonObject(piConfig) ? { piConfig } : {}
99
+ };
100
+ } catch {}
101
+ return {};
102
+ }
103
+ var COMPANION_BUILTIN_PACKAGE_NAMES;
104
+ var init_config_package_identity = __esm(() => {
105
+ init_builtin_install_layout();
106
+ COMPANION_BUILTIN_PACKAGE_NAMES = BUILTIN_PACKAGE_DIR_NAMES.map((dirName) => `@bastani/${dirName}`);
107
+ });
108
+
19
109
  // src/utils/agent-attribution.ts
20
110
  var ATOMIC_AI_AGENT = "atomic";
21
111
 
@@ -196,7 +286,7 @@ var init_child_process = __esm(() => {
196
286
  // src/utils/paths.ts
197
287
  import { realpathSync } from "node:fs";
198
288
  import { homedir } from "node:os";
199
- import { isAbsolute, join, resolve as nodeResolvePath, relative, sep } from "node:path";
289
+ import { isAbsolute, join as join2, resolve as nodeResolvePath, relative, sep } from "node:path";
200
290
  import { fileURLToPath } from "node:url";
201
291
  function getHomeDir() {
202
292
  if (process.platform === "win32") {
@@ -249,7 +339,7 @@ function normalizePath(input, options = {}) {
249
339
  if (normalized === "~")
250
340
  return home;
251
341
  if (normalized.startsWith("~/") || process.platform === "win32" && normalized.startsWith("~\\")) {
252
- return join(home, normalized.slice(2));
342
+ return join2(home, normalized.slice(2));
253
343
  }
254
344
  }
255
345
  if (/^file:\/\//.test(normalized)) {
@@ -291,20 +381,20 @@ var init_paths = __esm(() => {
291
381
  });
292
382
 
293
383
  // src/utils/split-launcher.ts
294
- import { dirname, join as join2 } from "node:path";
384
+ import { dirname as dirname2, join as join3 } from "node:path";
295
385
  import { fileURLToPath as fileURLToPath2 } from "node:url";
296
386
  function isSplitLauncherRuntime() {
297
387
  return process.env.ATOMIC_CODING_AGENT === "true" && /(?:^|[\\/])atomic(?:\.exe)?$/i.test(process.execPath);
298
388
  }
299
389
  function splitLauncherDir() {
300
- return dirname(process.execPath);
390
+ return dirname2(process.execPath);
301
391
  }
302
392
  function moduleFileFromMetaUrl(metaUrl, execRelativeFile) {
303
393
  try {
304
394
  return fileURLToPath2(metaUrl);
305
395
  } catch (error) {
306
396
  if (isSplitLauncherRuntime())
307
- return join2(splitLauncherDir(), execRelativeFile);
397
+ return join3(splitLauncherDir(), execRelativeFile);
308
398
  throw error;
309
399
  }
310
400
  }
@@ -316,24 +406,17 @@ var init_config_self_update = __esm(() => {
316
406
  });
317
407
 
318
408
  // src/config.ts
319
- import { existsSync, readFileSync } from "fs";
320
- import { dirname as dirname2, join as join3, resolve } from "path";
409
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
410
+ import { dirname as dirname3, join as join4, resolve } from "path";
321
411
  function getPackageDir() {
322
412
  const envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;
323
413
  if (envDir) {
324
414
  return normalizePath(envDir);
325
415
  }
326
416
  if (isBunBinary) {
327
- return dirname2(process.execPath);
328
- }
329
- let dir = __dirname2;
330
- while (dir !== dirname2(dir)) {
331
- if (existsSync(join3(dir, "package.json"))) {
332
- return dir;
333
- }
334
- dir = dirname2(dir);
417
+ return dirname3(process.execPath);
335
418
  }
336
- return __dirname2;
419
+ return resolvePackageDirFrom(__dirname2);
337
420
  }
338
421
  function getModuleAssetRoot() {
339
422
  const hasPackageDirOverride = !!(process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR);
@@ -341,43 +424,43 @@ function getModuleAssetRoot() {
341
424
  return __dirname2;
342
425
  }
343
426
  const packageDir = getPackageDir();
344
- return join3(packageDir, existsSync(join3(packageDir, "src")) ? "src" : "dist");
427
+ return join4(packageDir, existsSync2(join4(packageDir, "src")) ? "src" : "dist");
345
428
  }
346
429
  function getThemesDir() {
347
430
  if (isBunBinary) {
348
- return join3(getPackageDir(), "theme");
431
+ return join4(getPackageDir(), "theme");
349
432
  }
350
- return join3(getModuleAssetRoot(), "modes", "interactive", "theme");
433
+ return join4(getModuleAssetRoot(), "modes", "interactive", "theme");
351
434
  }
352
435
  function getExportTemplateDir() {
353
436
  if (isBunBinary) {
354
- return join3(getPackageDir(), "export-html");
437
+ return join4(getPackageDir(), "export-html");
355
438
  }
356
- return join3(getModuleAssetRoot(), "core", "export-html");
439
+ return join4(getModuleAssetRoot(), "core", "export-html");
357
440
  }
358
441
  function getPackageJsonPath() {
359
- return join3(getPackageDir(), "package.json");
442
+ return join4(getPackageDir(), "package.json");
360
443
  }
361
444
  function getReadmePath() {
362
- return resolve(join3(getPackageDir(), "README.md"));
445
+ return resolve(join4(getPackageDir(), "README.md"));
363
446
  }
364
447
  function getDocsPath() {
365
- return resolve(join3(getPackageDir(), "docs"));
448
+ return resolve(join4(getPackageDir(), "docs"));
366
449
  }
367
450
  function getExamplesPath() {
368
- return resolve(join3(getPackageDir(), "examples"));
451
+ return resolve(join4(getPackageDir(), "examples"));
369
452
  }
370
453
  function getChangelogPath() {
371
- return resolve(join3(getPackageDir(), "CHANGELOG.md"));
454
+ return resolve(join4(getPackageDir(), "CHANGELOG.md"));
372
455
  }
373
456
  function getInteractiveAssetsDir() {
374
457
  if (isBunBinary) {
375
- return join3(getPackageDir(), "assets");
458
+ return join4(getPackageDir(), "assets");
376
459
  }
377
- return join3(getModuleAssetRoot(), "modes", "interactive", "assets");
460
+ return join4(getModuleAssetRoot(), "modes", "interactive", "assets");
378
461
  }
379
462
  function getBundledInteractiveAssetPath(name) {
380
- return join3(getInteractiveAssetsDir(), name);
463
+ return join4(getInteractiveAssetsDir(), name);
381
464
  }
382
465
  function appNameFromPackageName(packageName) {
383
466
  const localName = packageName?.split("/").pop()?.trim();
@@ -467,10 +550,10 @@ function getAgentDir() {
467
550
  if (envDir) {
468
551
  return expandTildePath(envDir);
469
552
  }
470
- return join3(getHomeDir(), CONFIG_DIR_NAME, "agent");
553
+ return join4(getHomeDir(), CONFIG_DIR_NAME, "agent");
471
554
  }
472
555
  function getLegacyAgentDir() {
473
- return join3(getHomeDir(), LEGACY_CONFIG_DIR_NAME, "agent");
556
+ return join4(getHomeDir(), LEGACY_CONFIG_DIR_NAME, "agent");
474
557
  }
475
558
  function getAgentDirs() {
476
559
  const primary = getAgentDir();
@@ -481,49 +564,50 @@ function getAgentDirs() {
481
564
  return legacy === primary ? [primary] : [primary, legacy];
482
565
  }
483
566
  function getUserConfigDirs() {
484
- return CONFIG_DIR_NAMES.map((name) => join3(getHomeDir(), name));
567
+ return CONFIG_DIR_NAMES.map((name) => join4(getHomeDir(), name));
485
568
  }
486
569
  function getProjectConfigDirs(cwd) {
487
- return CONFIG_DIR_NAMES.map((name) => join3(cwd, name));
570
+ return CONFIG_DIR_NAMES.map((name) => join4(cwd, name));
488
571
  }
489
572
  function getUserConfigPaths(...segments) {
490
- return getUserConfigDirs().map((dir) => join3(dir, ...segments));
573
+ return getUserConfigDirs().map((dir) => join4(dir, ...segments));
491
574
  }
492
575
  function getAgentConfigPaths(...segments) {
493
- return getAgentDirs().map((dir) => join3(dir, ...segments));
576
+ return getAgentDirs().map((dir) => join4(dir, ...segments));
494
577
  }
495
578
  function getProjectConfigPaths(cwd, ...segments) {
496
- return getProjectConfigDirs(cwd).map((dir) => join3(dir, ...segments));
579
+ return getProjectConfigDirs(cwd).map((dir) => join4(dir, ...segments));
497
580
  }
498
581
  function getCustomThemesDir() {
499
- return join3(getAgentDir(), "themes");
582
+ return join4(getAgentDir(), "themes");
500
583
  }
501
584
  function getAuthPath() {
502
- return join3(getAgentDir(), "auth.json");
585
+ return join4(getAgentDir(), "auth.json");
503
586
  }
504
587
  function getBinDir() {
505
- return join3(getAgentDir(), "bin");
588
+ return join4(getAgentDir(), "bin");
506
589
  }
507
590
  function getSessionsDir() {
508
- return join3(getAgentDir(), "sessions");
591
+ return join4(getAgentDir(), "sessions");
509
592
  }
510
593
  function getDebugLogPath() {
511
- return join3(getAgentDir(), `${APP_NAME}-debug.log`);
594
+ return join4(getAgentDir(), `${APP_NAME}-debug.log`);
512
595
  }
513
596
  var __filename2, __dirname2, bunFsMarkers, isBunBinary, isBundledBuild, isBunRuntime, pkg, PACKAGE_NAME, packageAppName, appConfig, APP_NAME, APP_TITLE, CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAME = ".pi", CONFIG_DIR_NAMES, VERSION, CHANGELOG_URL, ENV_PREFIX, LEGACY_ENV_PREFIX = "PI", ENV_AGENT_DIR, ENV_SESSION_DIR, ENV_PACKAGE_DIR, ENV_OFFLINE, ENV_SKIP_VERSION_CHECK, ENV_STARTUP_BENCHMARK, ENV_TELEMETRY, ENV_SHARE_VIEWER_URL, ENV_CLEAR_ON_SHRINK, ENV_HARDWARE_CURSOR, ENV_TIMING, ENV_CODEX_FAST_MODE, WORKFLOW_STAGE_SUBAGENT_GUARD_ENV, DEFAULT_SHARE_VIEWER_URL = "https://pi.dev/session/";
514
597
  var init_config = __esm(() => {
598
+ init_config_package_identity();
515
599
  init_paths();
516
600
  init_split_launcher();
517
601
  init_config_self_update();
518
602
  __filename2 = moduleFileFromMetaUrl(import.meta.url, "app.js");
519
- __dirname2 = dirname2(__filename2);
603
+ __dirname2 = dirname3(__filename2);
520
604
  bunFsMarkers = ["$bunfs", "~BUN", "%7EBUN"];
521
605
  isBunBinary = isSplitLauncherRuntime() || [import.meta.url, process.argv[1] ?? ""].some((candidate) => bunFsMarkers.some((marker) => candidate.includes(marker)));
522
606
  isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === "1";
523
607
  isBunRuntime = !!process.versions.bun;
524
608
  pkg = {};
525
609
  try {
526
- pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
610
+ pkg = JSON.parse(readFileSync2(getPackageJsonPath(), "utf-8"));
527
611
  } catch (e) {
528
612
  const err = e;
529
613
  if (err.code !== "ENOENT")
@@ -1661,14 +1745,14 @@ var init_planner_outcome = __esm(() => {
1661
1745
  // src/core/compaction/range-planner-diagnostics.ts
1662
1746
  import { uuidv7 } from "@bastani/pi-ai";
1663
1747
  import { chmodSync, writeFileSync } from "fs";
1664
- import { basename, dirname as dirname3, join as join4 } from "path";
1748
+ import { basename, dirname as dirname4, join as join5 } from "path";
1665
1749
  function writeSidecar(sessionFilePath, kind, payload) {
1666
- const dir = dirname3(sessionFilePath);
1750
+ const dir = dirname4(sessionFilePath);
1667
1751
  const base = basename(sessionFilePath, ".jsonl");
1668
1752
  const timestamp = Date.now();
1669
1753
  const body = JSON.stringify(payload, null, 2);
1670
1754
  for (let attempt = 0;attempt < 4; attempt++) {
1671
- const filePath = join4(dir, `${base}-compaction-${kind}-${timestamp}-${uuidv7()}.json`);
1755
+ const filePath = join5(dir, `${base}-compaction-${kind}-${timestamp}-${uuidv7()}.json`);
1672
1756
  try {
1673
1757
  writeFileSync(filePath, body, { encoding: "utf-8", mode: 384, flag: "wx" });
1674
1758
  try {
@@ -3014,7 +3098,7 @@ function generateId(byId) {
3014
3098
  var init_session_manager_validation = () => {};
3015
3099
 
3016
3100
  // src/core/session-manager-entries.ts
3017
- import { join as join5 } from "path";
3101
+ import { join as join6 } from "path";
3018
3102
  function entryBase(byId, parentId) {
3019
3103
  return {
3020
3104
  id: generateId(byId),
@@ -3041,7 +3125,7 @@ function createSessionHeader(id, cwd, timestamp = new Date().toISOString(), pare
3041
3125
  }
3042
3126
  function createSessionFilePath(sessionDir, timestamp, sessionId) {
3043
3127
  const fileTimestamp = timestamp.replace(/[:.]/g, "-");
3044
- return join5(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);
3128
+ return join6(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);
3045
3129
  }
3046
3130
  function createMessageEntry(message, byId, parentId) {
3047
3131
  return {
@@ -3172,17 +3256,17 @@ var init_session_manager_entries = __esm(() => {
3172
3256
  });
3173
3257
 
3174
3258
  // src/core/session-manager-paths.ts
3175
- import { existsSync as existsSync2, mkdirSync } from "fs";
3176
- import { join as join6 } from "path";
3259
+ import { existsSync as existsSync3, mkdirSync } from "fs";
3260
+ import { join as join7 } from "path";
3177
3261
  function getDefaultSessionDirPath(cwd, agentDir = getAgentDir()) {
3178
3262
  const resolvedCwd = resolvePath(cwd);
3179
3263
  const resolvedAgentDir = resolvePath(agentDir);
3180
3264
  const safePath = `--${resolvedCwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
3181
- return join6(resolvedAgentDir, "sessions", safePath);
3265
+ return join7(resolvedAgentDir, "sessions", safePath);
3182
3266
  }
3183
3267
  function getDefaultSessionDir(cwd, agentDir = getAgentDir()) {
3184
3268
  const sessionDir = getDefaultSessionDirPath(cwd, agentDir);
3185
- if (!existsSync2(sessionDir)) {
3269
+ if (!existsSync3(sessionDir)) {
3186
3270
  mkdirSync(sessionDir, { recursive: true });
3187
3271
  }
3188
3272
  return sessionDir;
@@ -3196,7 +3280,7 @@ var init_session_manager_paths = __esm(() => {
3196
3280
  import {
3197
3281
  appendFileSync,
3198
3282
  closeSync,
3199
- existsSync as existsSync3,
3283
+ existsSync as existsSync4,
3200
3284
  mkdirSync as mkdirSync2,
3201
3285
  openSync,
3202
3286
  readdirSync,
@@ -3206,7 +3290,7 @@ import {
3206
3290
  unlinkSync,
3207
3291
  writeFileSync as writeFileSync2
3208
3292
  } from "fs";
3209
- import { join as join7 } from "path";
3293
+ import { join as join8 } from "path";
3210
3294
  import { StringDecoder } from "string_decoder";
3211
3295
  function parseSessionEntryLine(line) {
3212
3296
  if (!line.trim())
@@ -3219,7 +3303,7 @@ function parseSessionEntryLine(line) {
3219
3303
  }
3220
3304
  function loadEntriesFromFile(filePath) {
3221
3305
  const resolvedFilePath = normalizePath(filePath);
3222
- if (!existsSync3(resolvedFilePath))
3306
+ if (!existsSync4(resolvedFilePath))
3223
3307
  return [];
3224
3308
  const entries = [];
3225
3309
  const fd = openSync(resolvedFilePath, "r");
@@ -3314,7 +3398,7 @@ function findMostRecentSession(sessionDir, cwd, includeInternal = false) {
3314
3398
  const resolvedSessionDir = normalizePath(sessionDir);
3315
3399
  const resolvedCwd = cwd ? resolvePath(cwd) : undefined;
3316
3400
  try {
3317
- const files = readdirSync(resolvedSessionDir).filter((f) => f.endsWith(".jsonl")).map((f) => join7(resolvedSessionDir, f)).map((path) => ({ path, header: readSessionHeader(path) })).filter((file) => file.header !== null && (!resolvedCwd || sessionCwdMatches(getSessionHeaderCwd(file.header), resolvedCwd)) && (includeInternal || !isInternalHeader(file.header))).map(({ path }) => ({ path, mtime: statSync(path).mtime })).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
3401
+ const files = readdirSync(resolvedSessionDir).filter((f) => f.endsWith(".jsonl")).map((f) => join8(resolvedSessionDir, f)).map((path) => ({ path, header: readSessionHeader(path) })).filter((file) => file.header !== null && (!resolvedCwd || sessionCwdMatches(getSessionHeaderCwd(file.header), resolvedCwd)) && (includeInternal || !isInternalHeader(file.header))).map(({ path }) => ({ path, mtime: statSync(path).mtime })).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
3318
3402
  return files[0]?.path || null;
3319
3403
  } catch {
3320
3404
  return null;
@@ -3329,7 +3413,7 @@ function writeSessionEntries(filePath, entries) {
3329
3413
  writeFileSync2(filePath, serializeSessionEntries(entries));
3330
3414
  }
3331
3415
  function appendSessionPayload(filePath, payload) {
3332
- const existed = existsSync3(filePath);
3416
+ const existed = existsSync4(filePath);
3333
3417
  const offset = existed ? statSync(filePath).size : 0;
3334
3418
  try {
3335
3419
  appendFileSync(filePath, payload);
@@ -3337,7 +3421,7 @@ function appendSessionPayload(filePath, payload) {
3337
3421
  try {
3338
3422
  if (existed)
3339
3423
  truncateSync(filePath, offset);
3340
- else if (existsSync3(filePath))
3424
+ else if (existsSync4(filePath))
3341
3425
  unlinkSync(filePath);
3342
3426
  } catch (rollbackError) {
3343
3427
  throw new AggregateError([writeError, rollbackError], "Session append and rollback failed");
@@ -3367,7 +3451,7 @@ function persistAppendedEntry(filePath, entries, entry, flushed) {
3367
3451
  return true;
3368
3452
  }
3369
3453
  function ensureDirectory(dir) {
3370
- if (!existsSync3(dir)) {
3454
+ if (!existsSync4(dir)) {
3371
3455
  mkdirSync2(dir, { recursive: true });
3372
3456
  }
3373
3457
  }
@@ -3379,7 +3463,7 @@ var init_session_manager_storage = __esm(() => {
3379
3463
  });
3380
3464
 
3381
3465
  // src/core/session-manager-archive.ts
3382
- import { join as join8 } from "path";
3466
+ import { join as join9 } from "path";
3383
3467
  function createBackupSnapshot(sessionFile, entries, label = "compact") {
3384
3468
  if (!sessionFile)
3385
3469
  return;
@@ -3470,7 +3554,7 @@ function forkSessionFromFile(sourcePath, targetCwd, sessionDir, options) {
3470
3554
  }
3471
3555
  const newSessionId = options?.id ?? createSessionId();
3472
3556
  const timestamp = new Date().toISOString();
3473
- const newSessionFile = join8(dir, `${timestamp.replace(/[:.]/g, "-")}_${newSessionId}.jsonl`);
3557
+ const newSessionFile = join9(dir, `${timestamp.replace(/[:.]/g, "-")}_${newSessionId}.jsonl`);
3474
3558
  const newHeader = createSessionHeader(newSessionId, resolvedTargetCwd, timestamp, resolvedSourcePath, options?.internal, options?.workflow);
3475
3559
  appendSessionEntry(newSessionFile, newHeader);
3476
3560
  for (const entry of sourceEntries) {
@@ -3568,9 +3652,9 @@ var init_session_manager_migrations = __esm(() => {
3568
3652
  });
3569
3653
 
3570
3654
  // src/core/session-manager-list.ts
3571
- import { existsSync as existsSync4 } from "fs";
3655
+ import { existsSync as existsSync5 } from "fs";
3572
3656
  import { readdir, readFile, stat } from "fs/promises";
3573
- import { join as join9 } from "path";
3657
+ import { join as join10 } from "path";
3574
3658
  function isMessageWithContent(message) {
3575
3659
  return typeof message.role === "string" && "content" in message;
3576
3660
  }
@@ -3719,12 +3803,12 @@ async function buildSessionInfo(filePath) {
3719
3803
  }
3720
3804
  async function listSessionsFromDir(dir, onProgress, progressOffset = 0, progressTotal, includeInternal = false) {
3721
3805
  const sessions = [];
3722
- if (!existsSync4(dir)) {
3806
+ if (!existsSync5(dir)) {
3723
3807
  return sessions;
3724
3808
  }
3725
3809
  try {
3726
3810
  const dirEntries = await readdir(dir);
3727
- const files = dirEntries.filter((f) => f.endsWith(".jsonl")).map((f) => join9(dir, f));
3811
+ const files = dirEntries.filter((f) => f.endsWith(".jsonl")).map((f) => join10(dir, f));
3728
3812
  const total = progressTotal ?? files.length;
3729
3813
  let loaded = 0;
3730
3814
  const results = await mapSessionFilesCooperatively(files, includeInternal, () => {
@@ -3757,17 +3841,17 @@ async function listAllSessions(sessionDirOrOnProgress, onProgress, includeIntern
3757
3841
  }
3758
3842
  const sessionsDir = getSessionsDir();
3759
3843
  try {
3760
- if (!existsSync4(sessionsDir)) {
3844
+ if (!existsSync5(sessionsDir)) {
3761
3845
  return [];
3762
3846
  }
3763
3847
  const entries = await readdir(sessionsDir, { withFileTypes: true });
3764
- const dirs = entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => join9(sessionsDir, entry.name));
3848
+ const dirs = entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => join10(sessionsDir, entry.name));
3765
3849
  let totalFiles = 0;
3766
3850
  const dirFiles = [];
3767
3851
  for (const dir of dirs) {
3768
3852
  try {
3769
3853
  const files = (await readdir(dir)).filter((f) => f.endsWith(".jsonl"));
3770
- dirFiles.push(files.map((f) => join9(dir, f)));
3854
+ dirFiles.push(files.map((f) => join10(dir, f)));
3771
3855
  totalFiles += files.length;
3772
3856
  } catch {
3773
3857
  dirFiles.push([]);
@@ -3804,7 +3888,7 @@ var init_session_manager_list = __esm(() => {
3804
3888
  });
3805
3889
 
3806
3890
  // src/core/session-manager-core.ts
3807
- import { existsSync as existsSync5, statSync as statSync2 } from "fs";
3891
+ import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3808
3892
  import { resolve as resolve2 } from "path";
3809
3893
 
3810
3894
  class SessionManager {
@@ -3837,7 +3921,7 @@ class SessionManager {
3837
3921
  }
3838
3922
  _setSessionFile(sessionFile, preloadedFileEntries) {
3839
3923
  this.sessionFile = resolvePath(sessionFile);
3840
- if (existsSync5(this.sessionFile)) {
3924
+ if (existsSync6(this.sessionFile)) {
3841
3925
  this.fileEntries = preloadedFileEntries ?? loadEntriesFromFile(this.sessionFile);
3842
3926
  if (this.fileEntries.length === 0) {
3843
3927
  const explicitPath = this.sessionFile;
@@ -4558,7 +4642,7 @@ var init_agent_session_auto_compaction = __esm(() => {
4558
4642
  });
4559
4643
 
4560
4644
  // src/utils/shell.ts
4561
- import { existsSync as existsSync6 } from "node:fs";
4645
+ import { existsSync as existsSync7 } from "node:fs";
4562
4646
  import { delimiter } from "node:path";
4563
4647
  import { spawn, spawnSync } from "child_process";
4564
4648
  function isLegacyWslBashPath(path) {
@@ -4578,7 +4662,7 @@ function findBashOnPath() {
4578
4662
  });
4579
4663
  if (result.status === 0 && result.stdout) {
4580
4664
  const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
4581
- if (firstMatch && existsSync6(firstMatch)) {
4665
+ if (firstMatch && existsSync7(firstMatch)) {
4582
4666
  return firstMatch;
4583
4667
  }
4584
4668
  }
@@ -4602,7 +4686,7 @@ function findBashOnPath() {
4602
4686
  }
4603
4687
  function getShellConfig(customShellPath) {
4604
4688
  if (customShellPath) {
4605
- if (existsSync6(customShellPath)) {
4689
+ if (existsSync7(customShellPath)) {
4606
4690
  return getBashShellConfig(customShellPath);
4607
4691
  }
4608
4692
  throw new Error(`Custom shell path not found: ${customShellPath}`);
@@ -4618,7 +4702,7 @@ function getShellConfig(customShellPath) {
4618
4702
  paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
4619
4703
  }
4620
4704
  for (const path of paths) {
4621
- if (existsSync6(path)) {
4705
+ if (existsSync7(path)) {
4622
4706
  return getBashShellConfig(path);
4623
4707
  }
4624
4708
  }
@@ -4635,7 +4719,7 @@ function getShellConfig(customShellPath) {
4635
4719
  ${paths.map((p) => ` ${p}`).join(`
4636
4720
  `)}`);
4637
4721
  }
4638
- if (existsSync6("/bin/bash")) {
4722
+ if (existsSync7("/bin/bash")) {
4639
4723
  return getBashShellConfig("/bin/bash");
4640
4724
  }
4641
4725
  const bashOnPath = findBashOnPath();
@@ -4889,7 +4973,7 @@ var init_windows_directory_security = __esm(() => {
4889
4973
  import { createHash } from "node:crypto";
4890
4974
  import { chmodSync as chmodSync2, lstatSync, mkdirSync as mkdirSync3, realpathSync as realpathSync2, rmSync } from "node:fs";
4891
4975
  import { tmpdir, userInfo } from "node:os";
4892
- import { dirname as dirname4, join as join10, sep as sep2 } from "node:path";
4976
+ import { dirname as dirname5, join as join11, sep as sep2 } from "node:path";
4893
4977
  function sanitizeTempPathComponent(value, fallback) {
4894
4978
  const collapsed = value.replace(/[^a-zA-Z0-9._-]+/g, "_");
4895
4979
  let start = 0;
@@ -4946,11 +5030,11 @@ function baseTempDirs() {
4946
5030
  }
4947
5031
  function getTempRootDir() {
4948
5032
  const app = sanitizeTempPathComponent(APP_NAME, "atomic");
4949
- return join10(baseTempDirs().raw, `${app}-${ownerComponent()}`);
5033
+ return join11(baseTempDirs().raw, `${app}-${ownerComponent()}`);
4950
5034
  }
4951
5035
  function resolveSessionTempDirPath(sessionId) {
4952
5036
  const id = sessionId ?? activeSessionId ?? `pid-${process.pid}`;
4953
- return join10(getTempRootDir(), sanitizeTempPathComponent(id, FALLBACK_SESSION_COMPONENT));
5037
+ return join11(getTempRootDir(), sanitizeTempPathComponent(id, FALLBACK_SESSION_COMPONENT));
4954
5038
  }
4955
5039
  function isRealDirectory(path) {
4956
5040
  try {
@@ -5024,7 +5108,7 @@ function canonicalTempChild(dir, base) {
5024
5108
  for (const candidate of [base.raw, base.canonical]) {
5025
5109
  const prefix = `${candidate}${sep2}`;
5026
5110
  if (dir.startsWith(prefix)) {
5027
- return join10(base.canonical, dir.slice(prefix.length));
5111
+ return join11(base.canonical, dir.slice(prefix.length));
5028
5112
  }
5029
5113
  }
5030
5114
  return;
@@ -5037,13 +5121,13 @@ function ensureTempDir(dir) {
5037
5121
  const parts = checkedDir.slice(prefix.length).split(sep2).filter((part) => part.length > 0);
5038
5122
  let current = base.canonical;
5039
5123
  for (const part of parts.slice(0, -1)) {
5040
- current = join10(current, part);
5124
+ current = join11(current, part);
5041
5125
  ensureOwnedDirectory(current);
5042
5126
  }
5043
5127
  ensureLeafDirectory(checkedDir);
5044
5128
  } else {
5045
5129
  if (!(ensuredDirs.has(dir) && isRealDirectory(dir))) {
5046
- mkdirSync3(dirname4(dir), { recursive: true, mode: SESSION_TEMP_DIR_MODE });
5130
+ mkdirSync3(dirname5(dir), { recursive: true, mode: SESSION_TEMP_DIR_MODE });
5047
5131
  ensureLeafDirectory(dir);
5048
5132
  }
5049
5133
  }
@@ -5489,7 +5573,7 @@ var init_truncate = __esm(() => {
5489
5573
 
5490
5574
  // src/core/bash-executor.ts
5491
5575
  import { randomBytes } from "node:crypto";
5492
- import { join as join11 } from "node:path";
5576
+ import { join as join12 } from "node:path";
5493
5577
  async function executeBashWithOperations(command, cwd, operations, options) {
5494
5578
  const outputChunks = [];
5495
5579
  let outputBytes = 0;
@@ -5505,7 +5589,7 @@ async function executeBashWithOperations(command, cwd, operations, options) {
5505
5589
  try {
5506
5590
  const dir = ensureSessionTempDir(options?.sessionTempDir);
5507
5591
  const id = randomBytes(8).toString("hex");
5508
- tempFilePath = join11(dir, `${APP_NAME}-bash-${id}.log`);
5592
+ tempFilePath = join12(dir, `${APP_NAME}-bash-${id}.log`);
5509
5593
  tempFile = new PersistedOutputFile(tempFilePath);
5510
5594
  } catch {
5511
5595
  tempFileUnavailable = true;
@@ -7314,10 +7398,10 @@ var init_bash_session_environment = __esm(() => {
7314
7398
 
7315
7399
  // src/core/tools/output-accumulator.ts
7316
7400
  import { randomBytes as randomBytes2 } from "node:crypto";
7317
- import { join as join14 } from "node:path";
7401
+ import { join as join15 } from "node:path";
7318
7402
  function defaultTempFilePath(prefix, tempDir) {
7319
7403
  const id = randomBytes2(8).toString("hex");
7320
- return join14(ensureSessionTempDir(tempDir), `${prefix}-${id}.log`);
7404
+ return join15(ensureSessionTempDir(tempDir), `${prefix}-${id}.log`);
7321
7405
  }
7322
7406
  function byteLength(text) {
7323
7407
  return Buffer.byteLength(text, "utf-8");
@@ -7599,9 +7683,9 @@ var init_search_native = __esm(() => {
7599
7683
  });
7600
7684
 
7601
7685
  // src/core/tools/resource-selectors.ts
7602
- import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync3, realpathSync as realpathSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
7686
+ import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync4, realpathSync as realpathSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
7603
7687
  import { createRequire as createRequire3 } from "node:module";
7604
- import { dirname as dirname5, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3 } from "node:path";
7688
+ import { dirname as dirname6, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3 } from "node:path";
7605
7689
  import { deflateRawSync, gunzipSync, gzipSync, inflateRawSync } from "node:zlib";
7606
7690
  function toSqliteBindValues(params) {
7607
7691
  return params.map((param) => typeof param === "boolean" ? param ? 1 : 0 : param);
@@ -7639,9 +7723,9 @@ function sqliteDatabase() {
7639
7723
  }
7640
7724
  }
7641
7725
  function existingSqliteFile(path3) {
7642
- if (!existsSync9(path3))
7726
+ if (!existsSync10(path3))
7643
7727
  return;
7644
- return readFileSync3(path3).subarray(0, 16).toString("binary") === "SQLite format 3\x00";
7728
+ return readFileSync4(path3).subarray(0, 16).toString("binary") === "SQLite format 3\x00";
7645
7729
  }
7646
7730
  function sqliteSelectorForPath(value, cwd) {
7647
7731
  const selector = parseSqliteSelector(value);
@@ -7755,7 +7839,7 @@ function readZipEntriesFromBuffer(buf, label) {
7755
7839
  return entries;
7756
7840
  }
7757
7841
  function readZipEntries(path3) {
7758
- return readZipEntriesFromBuffer(readFileSync3(path3), path3);
7842
+ return readZipEntriesFromBuffer(readFileSync4(path3), path3);
7759
7843
  }
7760
7844
  function writeZipEntries(path3, entries) {
7761
7845
  const locals = [], centrals = [];
@@ -7794,7 +7878,7 @@ function writeZipEntries(path3, entries) {
7794
7878
  writeFileSync3(path3, Buffer.concat([...locals, ...centrals, eocd]));
7795
7879
  }
7796
7880
  function parseTar(path3) {
7797
- const raw = readFileSync3(path3);
7881
+ const raw = readFileSync4(path3);
7798
7882
  if (raw.length > MAX_TAR_ARCHIVE_BYTES)
7799
7883
  throw new Error(`Archive too large: ${path3}`);
7800
7884
  const buf = isGzipTar(path3) ? gunzipSync(raw, { maxOutputLength: MAX_TAR_ARCHIVE_BYTES }) : raw;
@@ -7866,7 +7950,7 @@ function listArchiveDirectory(names, memberPath) {
7866
7950
  `);
7867
7951
  }
7868
7952
  function readZipSelector(path3, memberPath) {
7869
- const buf = readFileSync3(path3);
7953
+ const buf = readFileSync4(path3);
7870
7954
  let eocd = -1;
7871
7955
  for (let i = buf.length - 22;i >= 0; i--)
7872
7956
  if (buf.readUInt32LE(i) === 101010256) {
@@ -7928,7 +8012,7 @@ function validateArchiveMemberPath(memberPath) {
7928
8012
  throw new Error(`Invalid archive member path: ${memberPath}`);
7929
8013
  }
7930
8014
  function writeZipEntrySelective(path3, memberPath, data) {
7931
- const source = existsSync9(path3) ? readFileSync3(path3) : Buffer.alloc(0);
8015
+ const source = existsSync10(path3) ? readFileSync4(path3) : Buffer.alloc(0);
7932
8016
  const locals = [], centrals = [];
7933
8017
  let offset = 0;
7934
8018
  if (source.length > 0) {
@@ -7964,7 +8048,7 @@ function writeZipEntrySelective(path3, memberPath, data) {
7964
8048
  }
7965
8049
  const tmp = `${path3}.atomic-entry-${Date.now()}`;
7966
8050
  writeZipEntries(tmp, new Map([[memberPath, data]]));
7967
- const built = readFileSync3(tmp);
8051
+ const built = readFileSync4(tmp);
7968
8052
  rmSync2(tmp, { force: true });
7969
8053
  const eocdStart = built.length - 22, localLen = built.readUInt32LE(eocdStart + 16), centralSizeOne = built.readUInt32LE(eocdStart + 12);
7970
8054
  const central = Buffer.from(built.subarray(localLen, localLen + centralSizeOne));
@@ -7982,12 +8066,12 @@ function writeZipEntrySelective(path3, memberPath, data) {
7982
8066
  }
7983
8067
  function writeArchiveSelector(selector, content) {
7984
8068
  validateArchiveMemberPath(selector.memberPath);
7985
- mkdirSync4(dirname5(selector.archivePath), { recursive: true });
8069
+ mkdirSync4(dirname6(selector.archivePath), { recursive: true });
7986
8070
  if (isZipArchive(selector.archivePath)) {
7987
8071
  writeZipEntrySelective(selector.archivePath, selector.memberPath, Buffer.from(content));
7988
8072
  return;
7989
8073
  }
7990
- const entries = existsSync9(selector.archivePath) ? parseTar(selector.archivePath) : new Map;
8074
+ const entries = existsSync10(selector.archivePath) ? parseTar(selector.archivePath) : new Map;
7991
8075
  entries.set(selector.memberPath, Buffer.from(content));
7992
8076
  writeTar(selector.archivePath, entries);
7993
8077
  }
@@ -8123,8 +8207,8 @@ function isContained(root, candidate) {
8123
8207
  }
8124
8208
  function nearestExistingAncestor(pathValue) {
8125
8209
  let current = pathValue;
8126
- while (!existsSync9(current)) {
8127
- const parent = dirname5(current);
8210
+ while (!existsSync10(current)) {
8211
+ const parent = dirname6(current);
8128
8212
  if (parent === current)
8129
8213
  return current;
8130
8214
  current = parent;
@@ -8149,7 +8233,7 @@ function fallbackInternalPath(value, cwd) {
8149
8233
  const skill = value.match(/^skill:\/\/([^/]+)(?:\/(.*))?$/);
8150
8234
  if (skill) {
8151
8235
  const name = skill[1] ?? "", rest = skill[2] || "SKILL.md";
8152
- return [".agents/skills", "packages/subagents/skills", "packages/workflows/skills"].map((base) => resolveContainedPath(resolveContainedLocalPath(cwd, base, "skill:// resource"), `${name}/${rest}`, "skill:// resource")).find((candidate) => existsSync9(candidate));
8236
+ return [".agents/skills", "packages/subagents/skills", "packages/workflows/skills"].map((base) => resolveContainedPath(resolveContainedLocalPath(cwd, base, "skill:// resource"), `${name}/${rest}`, "skill:// resource")).find((candidate) => existsSync10(candidate));
8153
8237
  }
8154
8238
  const local = value.match(/^local:\/\/(.+)$/);
8155
8239
  if (local)
@@ -8167,9 +8251,9 @@ async function readInternalSelector(value, cwd, context) {
8167
8251
  if (Buffer.isBuffer(routed))
8168
8252
  return routed.toString("utf8");
8169
8253
  const resolved = await resolveViaRouter(value, cwd, context);
8170
- if (!resolved || !existsSync9(resolved))
8254
+ if (!resolved || !existsSync10(resolved))
8171
8255
  throw new Error(`Internal resource not found or no session router supports it: ${value}`);
8172
- return readFileSync3(resolved, "utf8");
8256
+ return readFileSync4(resolved, "utf8");
8173
8257
  }
8174
8258
  async function writeInternalSelector(value, cwd, content, context) {
8175
8259
  const router = routerFromContext(context);
@@ -8180,7 +8264,7 @@ async function writeInternalSelector(value, cwd, content, context) {
8180
8264
  const resolved = await resolveViaRouter(value, cwd, context);
8181
8265
  if (!resolved)
8182
8266
  throw new Error(`Unsupported writable internal resource without a session router: ${value}`);
8183
- mkdirSync4(dirname5(resolved), { recursive: true });
8267
+ mkdirSync4(dirname6(resolved), { recursive: true });
8184
8268
  writeFileSync3(resolved, content);
8185
8269
  }
8186
8270
  async function searchInternalSelector(value, cwd, pattern, ignoreCase = false, literal = false, context, contextBefore = 1, contextAfter = 3) {
@@ -8462,7 +8546,7 @@ function parseLooseJsonObject(content) {
8462
8546
  function writeSqliteSelector(selector, content) {
8463
8547
  if (!selector.table)
8464
8548
  throw new Error("SQLite write target must include a table name");
8465
- if (!existsSync9(selector.databasePath))
8549
+ if (!existsSync10(selector.databasePath))
8466
8550
  throw new Error(`SQLite database does not exist: ${selector.databasePath}`);
8467
8551
  if (content.trim() === "") {
8468
8552
  if (!selector.rowId)
@@ -9235,12 +9319,12 @@ var init_agent_session_bash = __esm(() => {
9235
9319
  });
9236
9320
 
9237
9321
  // src/core/auth-guidance.ts
9238
- import { join as join15 } from "node:path";
9322
+ import { join as join16 } from "node:path";
9239
9323
  function getProviderLoginHelp() {
9240
9324
  return [
9241
9325
  "Use /login to log into a provider via OAuth or API key. See:",
9242
- ` ${join15(getDocsPath(), "providers.md")}`,
9243
- ` ${join15(getDocsPath(), "models.md")}`
9326
+ ` ${join16(getDocsPath(), "providers.md")}`,
9327
+ ` ${join16(getDocsPath(), "models.md")}`
9244
9328
  ].join(`
9245
9329
  `);
9246
9330
  }
@@ -10417,10 +10501,10 @@ function getUsageCostBreakdown(entries) {
10417
10501
  }
10418
10502
 
10419
10503
  // src/core/export-html/template-script.ts
10420
- import { readFileSync as readFileSync4 } from "fs";
10421
- import { join as join16 } from "path";
10504
+ import { readFileSync as readFileSync5 } from "fs";
10505
+ import { join as join17 } from "path";
10422
10506
  function readExportHtmlTemplateScript(templateDir) {
10423
- return EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS.map((fileName) => readFileSync4(join16(templateDir, "template-js", fileName), "utf-8")).join("");
10507
+ return EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS.map((fileName) => readFileSync5(join17(templateDir, "template-js", fileName), "utf-8")).join("");
10424
10508
  }
10425
10509
  var EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS;
10426
10510
  var init_template_script = __esm(() => {
@@ -10439,8 +10523,8 @@ __export(exports_export_html, {
10439
10523
  exportFromFile: () => exportFromFile,
10440
10524
  exportSessionToHtml: () => exportSessionToHtml
10441
10525
  });
10442
- import { existsSync as existsSync10, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
10443
- import { basename as basename2, join as join17 } from "path";
10526
+ import { existsSync as existsSync11, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
10527
+ import { basename as basename2, join as join18 } from "path";
10444
10528
  function parseColor(color) {
10445
10529
  const hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
10446
10530
  if (hexMatch) {
@@ -10515,11 +10599,11 @@ function generateThemeVars(themeName) {
10515
10599
  }
10516
10600
  function generateHtml(sessionData, themeName) {
10517
10601
  const templateDir = getExportTemplateDir();
10518
- const template = readFileSync5(join17(templateDir, "template.html"), "utf-8");
10519
- const templateCss = readFileSync5(join17(templateDir, "template.css"), "utf-8");
10602
+ const template = readFileSync6(join18(templateDir, "template.html"), "utf-8");
10603
+ const templateCss = readFileSync6(join18(templateDir, "template.css"), "utf-8");
10520
10604
  const templateJs = readExportHtmlTemplateScript(templateDir);
10521
- const markedJs = readFileSync5(join17(templateDir, "vendor", "marked.min.js"), "utf-8");
10522
- const hljsJs = readFileSync5(join17(templateDir, "vendor", "highlight.min.js"), "utf-8");
10605
+ const markedJs = readFileSync6(join18(templateDir, "vendor", "marked.min.js"), "utf-8");
10606
+ const hljsJs = readFileSync6(join18(templateDir, "vendor", "highlight.min.js"), "utf-8");
10523
10607
  const themeVars = generateThemeVars(themeName);
10524
10608
  const colors = getResolvedThemeColors(themeName);
10525
10609
  const themeExport = getThemeExportColors(themeName);
@@ -10570,7 +10654,7 @@ async function exportSessionToHtml(sm, state, options) {
10570
10654
  if (!sessionFile) {
10571
10655
  throw new Error("Cannot export in-memory session to HTML");
10572
10656
  }
10573
- if (!existsSync10(sessionFile)) {
10657
+ if (!existsSync11(sessionFile)) {
10574
10658
  throw new Error("Nothing to export yet - start a conversation first");
10575
10659
  }
10576
10660
  const entries = sm.getEntries();
@@ -10601,7 +10685,7 @@ async function exportSessionToHtml(sm, state, options) {
10601
10685
  async function exportFromFile(inputPath, options) {
10602
10686
  const opts = typeof options === "string" ? { outputPath: options } : options || {};
10603
10687
  const resolvedInputPath = resolvePath(inputPath);
10604
- if (!existsSync10(resolvedInputPath)) {
10688
+ if (!existsSync11(resolvedInputPath)) {
10605
10689
  throw new Error(`File not found: ${resolvedInputPath}`);
10606
10690
  }
10607
10691
  const sm = SessionManager.open(resolvedInputPath);
@@ -10903,8 +10987,8 @@ var init_tool_renderer = __esm(() => {
10903
10987
  });
10904
10988
 
10905
10989
  // src/core/agent-session-export.ts
10906
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "node:fs";
10907
- import { dirname as dirname6 } from "node:path";
10990
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "node:fs";
10991
+ import { dirname as dirname7 } from "node:path";
10908
10992
  function getSessionStats() {
10909
10993
  let userMessages = 0;
10910
10994
  let assistantMessages = 0;
@@ -11008,8 +11092,8 @@ async function exportToHtml(outputPath, options = {}) {
11008
11092
  }
11009
11093
  function exportToJsonl(outputPath) {
11010
11094
  const filePath = resolvePath(outputPath ?? `session-${new Date().toISOString().replace(/[:.]/g, "-")}.jsonl`, process.cwd());
11011
- const dir = dirname6(filePath);
11012
- if (!existsSync11(dir)) {
11095
+ const dir = dirname7(filePath);
11096
+ if (!existsSync12(dir)) {
11013
11097
  mkdirSync5(dir, { recursive: true });
11014
11098
  }
11015
11099
  const header = {
@@ -11093,8 +11177,8 @@ var init_loader_runtime = __esm(() => {
11093
11177
  });
11094
11178
 
11095
11179
  // src/core/tools/artifacts.ts
11096
- import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, writeFileSync as writeFileSync6 } from "node:fs";
11097
- import { join as join18 } from "node:path";
11180
+ import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync3, writeFileSync as writeFileSync6 } from "node:fs";
11181
+ import { join as join19 } from "node:path";
11098
11182
 
11099
11183
  class ArtifactManager {
11100
11184
  #nextId = 0;
@@ -11111,7 +11195,7 @@ class ArtifactManager {
11111
11195
  return;
11112
11196
  this.#initialized = true;
11113
11197
  let max = -1;
11114
- if (existsSync12(this.#dir)) {
11198
+ if (existsSync13(this.#dir)) {
11115
11199
  for (const name of readdirSync3(this.#dir)) {
11116
11200
  const match = name.match(/^(\d+)\..*\.log$/);
11117
11201
  if (match) {
@@ -11126,30 +11210,30 @@ class ArtifactManager {
11126
11210
  allocate(toolType) {
11127
11211
  this.#init();
11128
11212
  const id = String(this.#nextId++);
11129
- const path3 = join18(this.#dir, `${id}.${toolType}.log`);
11213
+ const path3 = join19(this.#dir, `${id}.${toolType}.log`);
11130
11214
  return { path: path3, id };
11131
11215
  }
11132
11216
  save(content, toolType) {
11133
11217
  this.#init();
11134
11218
  const { path: path3, id } = this.allocate(toolType);
11135
- if (!existsSync12(this.#dir))
11219
+ if (!existsSync13(this.#dir))
11136
11220
  mkdirSync6(this.#dir, { recursive: true });
11137
11221
  writeFileSync6(path3, content, "utf8");
11138
11222
  return id;
11139
11223
  }
11140
11224
  resolve(id) {
11141
11225
  this.#init();
11142
- if (!existsSync12(this.#dir))
11226
+ if (!existsSync13(this.#dir))
11143
11227
  return;
11144
11228
  const prefix = `${id}.`;
11145
11229
  for (const name of readdirSync3(this.#dir))
11146
11230
  if (name.startsWith(prefix) && name.endsWith(".log"))
11147
- return join18(this.#dir, name);
11231
+ return join19(this.#dir, name);
11148
11232
  return;
11149
11233
  }
11150
11234
  list() {
11151
11235
  this.#init();
11152
- if (!existsSync12(this.#dir))
11236
+ if (!existsSync13(this.#dir))
11153
11237
  return [];
11154
11238
  const ids = [];
11155
11239
  for (const name of readdirSync3(this.#dir)) {
@@ -11174,7 +11258,7 @@ var init_artifacts = __esm(() => {
11174
11258
  });
11175
11259
 
11176
11260
  // src/core/tools/artifact-protocol.ts
11177
- import { existsSync as existsSync13, readFileSync as readFileSync6 } from "node:fs";
11261
+ import { existsSync as existsSync14, readFileSync as readFileSync7 } from "node:fs";
11178
11262
  function registerArtifactDir(dir) {
11179
11263
  activeArtifactDirs.add(dir);
11180
11264
  }
@@ -11219,9 +11303,9 @@ function createArtifactRouter(getPinnedDirs) {
11219
11303
  if (!/^artifact:\/\//i.test(url))
11220
11304
  return;
11221
11305
  const path3 = resolveArtifactUrl(url, getPinnedDirs());
11222
- if (!path3 || !existsSync13(path3))
11306
+ if (!path3 || !existsSync14(path3))
11223
11307
  throw new Error(`Artifact not found: ${url}`);
11224
- return readFileSync6(path3, "utf8");
11308
+ return readFileSync7(path3, "utf8");
11225
11309
  }
11226
11310
  };
11227
11311
  }
@@ -11232,7 +11316,7 @@ var init_artifact_protocol = __esm(() => {
11232
11316
  });
11233
11317
 
11234
11318
  // src/core/extensions/runner-context.ts
11235
- import { join as join19 } from "node:path";
11319
+ import { join as join20 } from "node:path";
11236
11320
  function deepFrozenCopy(value) {
11237
11321
  if (Array.isArray(value))
11238
11322
  return Object.freeze(value.map(deepFrozenCopy));
@@ -11292,7 +11376,7 @@ function createExtensionContext(source) {
11292
11376
  const sessionDir = source.getSessionManager().getSessionDir();
11293
11377
  if (!sessionDir)
11294
11378
  return;
11295
- const artifactsDir = join19(sessionDir, "artifacts");
11379
+ const artifactsDir = join20(sessionDir, "artifacts");
11296
11380
  registerArtifactDir(artifactsDir);
11297
11381
  return createArtifactRouter(() => [artifactsDir]);
11298
11382
  },
@@ -12205,7 +12289,7 @@ var init_runner = __esm(() => {
12205
12289
 
12206
12290
  // src/core/skill-catalog.ts
12207
12291
  import { createHash as createHash2 } from "node:crypto";
12208
- import { basename as basename3, dirname as dirname7, sep as sep3 } from "node:path";
12292
+ import { basename as basename3, dirname as dirname8, sep as sep3 } from "node:path";
12209
12293
  function candidateId(skill) {
12210
12294
  return `skill_${createHash2("sha256").update(canonicalizePath(skill.filePath)).digest("hex").slice(0, 20)}`;
12211
12295
  }
@@ -12249,7 +12333,7 @@ function sourceLabel(skill) {
12249
12333
  }
12250
12334
  const pathParts = canonicalizePath(skill.filePath).split(sep3).filter(Boolean);
12251
12335
  const configPart = [...pathParts].reverse().find((part) => part === ".atomic" || part === ".pi" || part === ".agents");
12252
- return configPart ? configPart.slice(1) : readableToken(basename3(skill.sourceInfo.baseDir ?? dirname7(skill.filePath)));
12336
+ return configPart ? configPart.slice(1) : readableToken(basename3(skill.sourceInfo.baseDir ?? dirname8(skill.filePath)));
12253
12337
  }
12254
12338
  function uniquePathLabels(candidates) {
12255
12339
  const labels = new Map(candidates.map((candidate) => [candidate.id, sourceLabel(candidate.skill)]));
@@ -12263,7 +12347,7 @@ function uniquePathLabels(candidates) {
12263
12347
  for (const [label, matching] of byLabel) {
12264
12348
  if (matching.length === 1)
12265
12349
  continue;
12266
- const pathParts = matching.map((candidate) => canonicalizePath(dirname7(candidate.skill.filePath)).split(sep3).filter(Boolean));
12350
+ const pathParts = matching.map((candidate) => canonicalizePath(dirname8(candidate.skill.filePath)).split(sep3).filter(Boolean));
12267
12351
  for (let depth = 1;depth <= Math.max(...pathParts.map((parts) => parts.length)); depth++) {
12268
12352
  const suffixes = pathParts.map((parts) => parts.slice(-depth).join("/"));
12269
12353
  if (new Set(suffixes).size !== suffixes.length)
@@ -12436,7 +12520,7 @@ var init_skill_catalog = __esm(() => {
12436
12520
  });
12437
12521
 
12438
12522
  // src/core/agent-session-extension-bindings.ts
12439
- import { basename as basename4, dirname as dirname8 } from "node:path";
12523
+ import { basename as basename4, dirname as dirname9 } from "node:path";
12440
12524
  import { resetApiProviders } from "@bastani/pi-ai/compat";
12441
12525
  async function bindExtensions(bindings) {
12442
12526
  if (bindings.uiContext !== undefined) {
@@ -12484,7 +12568,7 @@ function buildExtensionResourcePaths(entries) {
12484
12568
  const extension = extensions.find((candidate) => candidate.path === entry.extensionPath || candidate.resolvedPath === entry.extensionPath || candidate.sourceInfo.path === entry.extensionPath);
12485
12569
  const sourceInfo = extension?.sourceInfo;
12486
12570
  const source = sourceInfo?.source ?? this.getExtensionSourceLabel(entry.extensionPath);
12487
- const baseDir = sourceInfo?.baseDir ?? (entry.extensionPath.startsWith("<") ? undefined : dirname8(entry.extensionPath));
12571
+ const baseDir = sourceInfo?.baseDir ?? (entry.extensionPath.startsWith("<") ? undefined : dirname9(entry.extensionPath));
12488
12572
  return {
12489
12573
  path: entry.path,
12490
12574
  metadata: {
@@ -13581,7 +13665,7 @@ var init_frontmatter = () => {};
13581
13665
 
13582
13666
  // src/utils/changelog.ts
13583
13667
  import path3 from "node:path";
13584
- import { existsSync as existsSync14, readFileSync as readFileSync7 } from "fs";
13668
+ import { existsSync as existsSync15, readFileSync as readFileSync8 } from "fs";
13585
13669
  function parsedVersionFromMatch(match) {
13586
13670
  return {
13587
13671
  version: match[1],
@@ -13675,11 +13759,11 @@ function normalizeChangelogLinks(markdown, version) {
13675
13759
  });
13676
13760
  }
13677
13761
  function parseChangelog(changelogPath) {
13678
- if (!existsSync14(changelogPath)) {
13762
+ if (!existsSync15(changelogPath)) {
13679
13763
  return [];
13680
13764
  }
13681
13765
  try {
13682
- const content = readFileSync7(changelogPath, "utf-8");
13766
+ const content = readFileSync8(changelogPath, "utf-8");
13683
13767
  const lines = content.split(`
13684
13768
  `);
13685
13769
  const entries = [];
@@ -14178,7 +14262,7 @@ var init_prompt_templates = __esm(() => {
14178
14262
  });
14179
14263
 
14180
14264
  // src/core/agent-session-prompt.ts
14181
- import { readFileSync as readFileSync8 } from "node:fs";
14265
+ import { readFileSync as readFileSync9 } from "node:fs";
14182
14266
  async function tryExecuteSessionSlashCommand(session, text) {
14183
14267
  if (!text.startsWith("/"))
14184
14268
  return false;
@@ -14450,7 +14534,7 @@ function _expandSkillCommand(text) {
14450
14534
  }
14451
14535
  const { skill, id } = resolution.candidate;
14452
14536
  try {
14453
- const content = readFileSync8(skill.filePath, "utf-8");
14537
+ const content = readFileSync9(skill.filePath, "utf-8");
14454
14538
  const body = stripFrontmatter(content).trim();
14455
14539
  const skillBlock = `<skill name="${selector}" location="${skill.filePath}" candidate="${id}">
14456
14540
  References are relative to ${skill.baseDir}.
@@ -16544,7 +16628,7 @@ function assertToolPairingInvariant(messages) {
16544
16628
  import { Buffer as Buffer3 } from "node:buffer";
16545
16629
  import { constants as constants2 } from "node:fs";
16546
16630
  import { chmod, lstat, mkdir, open } from "node:fs/promises";
16547
- import { join as join21 } from "node:path";
16631
+ import { join as join22 } from "node:path";
16548
16632
  function getPersistenceThreshold(declaredMaxResultSizeChars) {
16549
16633
  if (declaredMaxResultSizeChars === undefined) {
16550
16634
  return DEFAULT_MAX_RESULT_SIZE_CHARS;
@@ -16633,14 +16717,14 @@ function sanitizePathComponent(value, fallback) {
16633
16717
  }
16634
16718
  async function ensureToolResultsDir(input) {
16635
16719
  if (input.sessionDir?.trim()) {
16636
- const dir = join21(input.sessionDir, TOOL_RESULTS_SUBDIR);
16720
+ const dir = join22(input.sessionDir, TOOL_RESULTS_SUBDIR);
16637
16721
  await mkdir(dir, { recursive: true, mode: SESSION_TEMP_DIR_MODE });
16638
16722
  if (process.platform !== "win32") {
16639
16723
  await chmod(dir, SESSION_TEMP_DIR_MODE);
16640
16724
  }
16641
16725
  return dir;
16642
16726
  }
16643
- return ensureTempDir(join21(resolveSessionTempDirPath(input.sessionId), TOOL_RESULTS_SUBDIR));
16727
+ return ensureTempDir(join22(resolveSessionTempDirPath(input.sessionId), TOOL_RESULTS_SUBDIR));
16644
16728
  }
16645
16729
  function isOwnedByCurrentUser(uid) {
16646
16730
  const currentUid = typeof process.getuid === "function" ? process.getuid() : undefined;
@@ -16706,7 +16790,7 @@ async function persistToolOutput(input) {
16706
16790
  } catch {
16707
16791
  return;
16708
16792
  }
16709
- const filepath = join21(dir, `${sanitizePathComponent(input.toolCallId, "tool-result")}.txt`);
16793
+ const filepath = join22(dir, `${sanitizePathComponent(input.toolCallId, "tool-result")}.txt`);
16710
16794
  try {
16711
16795
  const handle = await open(filepath, "wx", SESSION_TEMP_FILE_MODE);
16712
16796
  try {
@@ -16958,7 +17042,7 @@ var init_loader_core = __esm(() => {
16958
17042
  });
16959
17043
 
16960
17044
  // src/core/package-manager-manifest.ts
16961
- import { join as join22 } from "node:path";
17045
+ import { join as join23 } from "node:path";
16962
17046
  function isRecord(value) {
16963
17047
  return typeof value === "object" && value !== null && !Array.isArray(value);
16964
17048
  }
@@ -16981,9 +17065,9 @@ function getManifestFromPackageJson(pkg2) {
16981
17065
  }
16982
17066
  function conventionDirsForResource(packageRoot, resourceType) {
16983
17067
  if (resourceType === "workflows") {
16984
- return [join22(packageRoot, "workflows"), join22(packageRoot, "workflow")];
17068
+ return [join23(packageRoot, "workflows"), join23(packageRoot, "workflow")];
16985
17069
  }
16986
- return [join22(packageRoot, resourceType)];
17070
+ return [join23(packageRoot, resourceType)];
16987
17071
  }
16988
17072
  function manifestEntriesForResource(manifest, resourceType) {
16989
17073
  if (!manifest)
@@ -17169,14 +17253,14 @@ var init_model_registry = __esm(() => {
17169
17253
  });
17170
17254
 
17171
17255
  // src/core/tools/ask-user-question/config.ts
17172
- import { existsSync as existsSync15, readFileSync as readFileSync9 } from "node:fs";
17256
+ import { existsSync as existsSync16, readFileSync as readFileSync10 } from "node:fs";
17173
17257
  import { homedir as homedir4 } from "node:os";
17174
- import { join as join23 } from "node:path";
17258
+ import { join as join24 } from "node:path";
17175
17259
  function loadConfig() {
17176
- if (!existsSync15(CONFIG_PATH))
17260
+ if (!existsSync16(CONFIG_PATH))
17177
17261
  return {};
17178
17262
  try {
17179
- const parsed = JSON.parse(readFileSync9(CONFIG_PATH, "utf-8"));
17263
+ const parsed = JSON.parse(readFileSync10(CONFIG_PATH, "utf-8"));
17180
17264
  if (parsed === null || typeof parsed !== "object")
17181
17265
  return {};
17182
17266
  return parsed;
@@ -17199,8 +17283,8 @@ function validateGuidanceFields(fields) {
17199
17283
  }
17200
17284
  var CONFIG_DIR, CONFIG_PATH;
17201
17285
  var init_config2 = __esm(() => {
17202
- CONFIG_DIR = join23(homedir4(), ".config", "rpiv-ask-user-question");
17203
- CONFIG_PATH = join23(CONFIG_DIR, "config.json");
17286
+ CONFIG_DIR = join24(homedir4(), ".config", "rpiv-ask-user-question");
17287
+ CONFIG_PATH = join24(CONFIG_DIR, "config.json");
17204
17288
  });
17205
17289
 
17206
17290
  // src/core/tools/ask-user-question/view/component-binding.ts
@@ -19704,7 +19788,7 @@ var init_chat_message_renderer = __esm(() => {
19704
19788
 
19705
19789
  // src/utils/clipboard-native.ts
19706
19790
  import { createRequire as createRequire6 } from "module";
19707
- import { dirname as dirname10, join as join24 } from "path";
19791
+ import { dirname as dirname11, join as join25 } from "path";
19708
19792
  import { pathToFileURL as pathToFileURL3 } from "url";
19709
19793
  function loadClipboardNative(requires = [moduleRequire, executableDirRequire]) {
19710
19794
  for (const requireClipboard of requires) {
@@ -19717,7 +19801,7 @@ function loadClipboardNative(requires = [moduleRequire, executableDirRequire]) {
19717
19801
  var moduleRequire, executableDirRequire, hasDisplay, clipboard;
19718
19802
  var init_clipboard_native = __esm(() => {
19719
19803
  moduleRequire = createRequire6(import.meta.url);
19720
- executableDirRequire = createRequire6(pathToFileURL3(join24(dirname10(process.execPath), "package.json")).href);
19804
+ executableDirRequire = createRequire6(pathToFileURL3(join25(dirname11(process.execPath), "package.json")).href);
19721
19805
  hasDisplay = process.platform !== "linux" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);
19722
19806
  clipboard = !process.env.TERMUX_VERSION && hasDisplay ? loadClipboardNative() : null;
19723
19807
  });
@@ -19725,9 +19809,9 @@ var init_clipboard_native = __esm(() => {
19725
19809
  // src/utils/clipboard-image.ts
19726
19810
  import { spawnSync as spawnSync3 } from "child_process";
19727
19811
  import { randomUUID as randomUUID2 } from "crypto";
19728
- import { readFileSync as readFileSync10, unlinkSync as unlinkSync2 } from "fs";
19812
+ import { readFileSync as readFileSync11, unlinkSync as unlinkSync2 } from "fs";
19729
19813
  import { tmpdir as tmpdir2 } from "os";
19730
- import { join as join25 } from "path";
19814
+ import { join as join26 } from "path";
19731
19815
  function isWaylandSession(env = process.env) {
19732
19816
  return Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === "wayland";
19733
19817
  }
@@ -19817,14 +19901,14 @@ function isWSL(env = process.env) {
19817
19901
  return true;
19818
19902
  }
19819
19903
  try {
19820
- const release = readFileSync10("/proc/version", "utf-8");
19904
+ const release = readFileSync11("/proc/version", "utf-8");
19821
19905
  return /microsoft|wsl/i.test(release);
19822
19906
  } catch {
19823
19907
  return false;
19824
19908
  }
19825
19909
  }
19826
19910
  function readClipboardImageViaPowerShell() {
19827
- const tmpFile = join25(tmpdir2(), `pi-wsl-clip-${randomUUID2()}.png`);
19911
+ const tmpFile = join26(tmpdir2(), `pi-wsl-clip-${randomUUID2()}.png`);
19828
19912
  try {
19829
19913
  const winPathResult = runCommand("wslpath", ["-w", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });
19830
19914
  if (!winPathResult.ok) {
@@ -19852,7 +19936,7 @@ function readClipboardImageViaPowerShell() {
19852
19936
  if (output !== "ok") {
19853
19937
  return null;
19854
19938
  }
19855
- const bytes = readFileSync10(tmpFile);
19939
+ const bytes = readFileSync11(tmpFile);
19856
19940
  if (bytes.length === 0) {
19857
19941
  return null;
19858
19942
  }
@@ -20065,9 +20149,9 @@ var init_clipboard = __esm(() => {
20065
20149
 
20066
20150
  // src/modes/interactive/external-editor.ts
20067
20151
  import { spawn as spawn4 } from "node:child_process";
20068
- import { mkdtempSync, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
20152
+ import { mkdtempSync, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
20069
20153
  import { tmpdir as tmpdir3 } from "node:os";
20070
- import { join as join26 } from "node:path";
20154
+ import { join as join27 } from "node:path";
20071
20155
  function parseEditorCommand(command) {
20072
20156
  const args = [];
20073
20157
  let current = "";
@@ -20132,8 +20216,8 @@ function resolveExternalEditorCommand(configuredCommand, environment = process.e
20132
20216
  return platform2 === "win32" ? "notepad" : "nano";
20133
20217
  }
20134
20218
  async function editInExternalEditor(request) {
20135
- const directory = mkdtempSync(join26(tmpdir3(), `${APP_NAME}-editor-`));
20136
- const filePath = join26(directory, "prompt.md");
20219
+ const directory = mkdtempSync(join27(tmpdir3(), `${APP_NAME}-editor-`));
20220
+ const filePath = join27(directory, "prompt.md");
20137
20221
  try {
20138
20222
  writeFileSync7(filePath, request.content, {
20139
20223
  encoding: "utf-8",
@@ -20157,7 +20241,7 @@ ${APP_NAME} will resume when the editor exits.
20157
20241
  return { status: "failed" };
20158
20242
  return {
20159
20243
  status: "complete",
20160
- content: readFileSync11(filePath, "utf-8").replace(/\n$/, "")
20244
+ content: readFileSync12(filePath, "utf-8").replace(/\n$/, "")
20161
20245
  };
20162
20246
  } finally {
20163
20247
  try {
@@ -23211,8 +23295,8 @@ import {
23211
23295
  TUI_KEYBINDINGS,
23212
23296
  KeybindingsManager as TuiKeybindingsManager
23213
23297
  } from "@earendil-works/pi-tui";
23214
- import { existsSync as existsSync16, readFileSync as readFileSync12 } from "fs";
23215
- import { join as join28 } from "path";
23298
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "fs";
23299
+ import { join as join29 } from "path";
23216
23300
  function isRecord2(value) {
23217
23301
  return typeof value === "object" && value !== null && !Array.isArray(value);
23218
23302
  }
@@ -23264,10 +23348,10 @@ function orderKeybindingsConfig(config) {
23264
23348
  return ordered;
23265
23349
  }
23266
23350
  function loadRawConfig(path7) {
23267
- if (!existsSync16(path7))
23351
+ if (!existsSync17(path7))
23268
23352
  return;
23269
23353
  try {
23270
- const parsed = JSON.parse(readFileSync12(path7, "utf-8"));
23354
+ const parsed = JSON.parse(readFileSync13(path7, "utf-8"));
23271
23355
  return isRecord2(parsed) ? parsed : undefined;
23272
23356
  } catch {
23273
23357
  return;
@@ -23488,7 +23572,7 @@ var init_keybindings = __esm(() => {
23488
23572
  this.configPath = configPath;
23489
23573
  }
23490
23574
  static create(agentDir = getAgentDir()) {
23491
- const configPath = join28(agentDir, "keybindings.json");
23575
+ const configPath = join29(agentDir, "keybindings.json");
23492
23576
  const userBindings = KeybindingsManager.loadFromFile(configPath);
23493
23577
  return new KeybindingsManager(userBindings, configPath);
23494
23578
  }
@@ -23511,7 +23595,7 @@ var init_keybindings = __esm(() => {
23511
23595
 
23512
23596
  // src/modes/interactive/components/session-selector-delete.ts
23513
23597
  import { spawnSync as spawnSync4 } from "node:child_process";
23514
- import { existsSync as existsSync17 } from "node:fs";
23598
+ import { existsSync as existsSync18 } from "node:fs";
23515
23599
  import { unlink } from "node:fs/promises";
23516
23600
  async function deleteSessionFile(sessionPath) {
23517
23601
  const trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath];
@@ -23530,7 +23614,7 @@ async function deleteSessionFile(sessionPath) {
23530
23614
  return null;
23531
23615
  return `trash: ${parts.join(" · ").slice(0, 200)}`;
23532
23616
  };
23533
- if (trashResult.status === 0 || !existsSync17(sessionPath)) {
23617
+ if (trashResult.status === 0 || !existsSync18(sessionPath)) {
23534
23618
  return { ok: true, method: "trash" };
23535
23619
  }
23536
23620
  try {
@@ -26407,8 +26491,8 @@ function parseJsonFileContent(input) {
26407
26491
  }
26408
26492
 
26409
26493
  // src/core/trust-manager.ts
26410
- import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "node:fs";
26411
- import { dirname as dirname11, join as join29 } from "node:path";
26494
+ import { existsSync as existsSync19, mkdirSync as mkdirSync7, readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "node:fs";
26495
+ import { dirname as dirname12, join as join30 } from "node:path";
26412
26496
  import lockfile from "proper-lockfile";
26413
26497
  function normalizeCwd(cwd) {
26414
26498
  return canonicalizePath(resolvePath(cwd));
@@ -26420,7 +26504,7 @@ function findNearestTrustEntry(data, cwd) {
26420
26504
  if (value === true || value === false) {
26421
26505
  return { path: currentDir, decision: value };
26422
26506
  }
26423
- const parentDir = dirname11(currentDir);
26507
+ const parentDir = dirname12(currentDir);
26424
26508
  if (parentDir === currentDir) {
26425
26509
  return null;
26426
26510
  }
@@ -26432,7 +26516,7 @@ function getProjectTrustPath(cwd) {
26432
26516
  }
26433
26517
  function getProjectTrustParentPath(cwd) {
26434
26518
  const trustPath = getProjectTrustPath(cwd);
26435
- const parentDir = dirname11(trustPath);
26519
+ const parentDir = dirname12(trustPath);
26436
26520
  return parentDir === trustPath ? undefined : parentDir;
26437
26521
  }
26438
26522
  function getProjectTrustOptions(cwd, options) {
@@ -26467,12 +26551,12 @@ function getProjectTrustOptions(cwd, options) {
26467
26551
  return trustOptions;
26468
26552
  }
26469
26553
  function readTrustFile(path7) {
26470
- if (!existsSync18(path7)) {
26554
+ if (!existsSync19(path7)) {
26471
26555
  return {};
26472
26556
  }
26473
26557
  let parsed;
26474
26558
  try {
26475
- parsed = parseJsonFileContent(readFileSync13(path7, "utf-8"));
26559
+ parsed = parseJsonFileContent(readFileSync14(path7, "utf-8"));
26476
26560
  } catch (error) {
26477
26561
  const message = error instanceof Error ? error.message : String(error);
26478
26562
  throw new Error(`Failed to read trust store ${path7}: ${message}`);
@@ -26497,12 +26581,12 @@ function writeTrustFile(path7, data) {
26497
26581
  sorted[key] = value;
26498
26582
  }
26499
26583
  }
26500
- mkdirSync7(dirname11(path7), { recursive: true });
26584
+ mkdirSync7(dirname12(path7), { recursive: true });
26501
26585
  writeFileSync9(path7, `${JSON.stringify(sorted, null, 2)}
26502
26586
  `, "utf-8");
26503
26587
  }
26504
26588
  function acquireTrustLockSync(path7) {
26505
- const trustDir = dirname11(path7);
26589
+ const trustDir = dirname12(path7);
26506
26590
  mkdirSync7(trustDir, { recursive: true });
26507
26591
  const maxAttempts = 10;
26508
26592
  const delayMs = 20;
@@ -26536,22 +26620,22 @@ function withTrustFileLock(path7, fn) {
26536
26620
  function hasTrustRequiringConfigResources(cwd) {
26537
26621
  const projectCwd = canonicalizePath(resolvePath(cwd));
26538
26622
  return CONFIG_DIR_NAMES.some((configDirName) => {
26539
- const configDir = join29(projectCwd, configDirName);
26540
- return TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync18(join29(configDir, entry)));
26623
+ const configDir = join30(projectCwd, configDirName);
26624
+ return TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync19(join30(configDir, entry)));
26541
26625
  });
26542
26626
  }
26543
26627
  function hasTrustRequiringProjectResources(cwd) {
26544
26628
  if (hasTrustRequiringConfigResources(cwd)) {
26545
26629
  return true;
26546
26630
  }
26547
- const userGlobalSkillsDir = canonicalizePath(resolvePath(join29(getHomeDir(), ".agents", "skills")));
26631
+ const userGlobalSkillsDir = canonicalizePath(resolvePath(join30(getHomeDir(), ".agents", "skills")));
26548
26632
  let currentDir = canonicalizePath(resolvePath(cwd));
26549
26633
  while (true) {
26550
- const skillsDir = canonicalizePath(resolvePath(join29(currentDir, ".agents", "skills")));
26551
- if (skillsDir !== userGlobalSkillsDir && existsSync18(skillsDir)) {
26634
+ const skillsDir = canonicalizePath(resolvePath(join30(currentDir, ".agents", "skills")));
26635
+ if (skillsDir !== userGlobalSkillsDir && existsSync19(skillsDir)) {
26552
26636
  return true;
26553
26637
  }
26554
- const parentDir = dirname11(currentDir);
26638
+ const parentDir = dirname12(currentDir);
26555
26639
  if (parentDir === currentDir) {
26556
26640
  return false;
26557
26641
  }
@@ -26562,7 +26646,7 @@ function hasTrustRequiringProjectResources(cwd) {
26562
26646
  class ProjectTrustStore {
26563
26647
  trustPath;
26564
26648
  constructor(agentDir) {
26565
- this.trustPath = join29(resolvePath(agentDir), "trust.json");
26649
+ this.trustPath = join30(resolvePath(agentDir), "trust.json");
26566
26650
  }
26567
26651
  get(cwd) {
26568
26652
  return this.getEntry(cwd)?.decision ?? null;
@@ -31331,7 +31415,7 @@ var init_hashline = __esm(() => {
31331
31415
  });
31332
31416
 
31333
31417
  // src/core/tools/notebook.ts
31334
- import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
31418
+ import { existsSync as existsSync20, readFileSync as readFileSync15 } from "node:fs";
31335
31419
  function isNotebookPath(absolutePath) {
31336
31420
  return /\.ipynb$/i.test(absolutePath);
31337
31421
  }
@@ -31433,11 +31517,11 @@ function applyNotebookEditableText(notebook, text, displayPath) {
31433
31517
  return next;
31434
31518
  }
31435
31519
  function readEditableNotebookText(absolutePath, displayPath) {
31436
- const notebook = existsSync19(absolutePath) ? parseNotebookSafe(readFileSync14(absolutePath, "utf8"), displayPath) : emptyNotebook();
31520
+ const notebook = existsSync20(absolutePath) ? parseNotebookSafe(readFileSync15(absolutePath, "utf8"), displayPath) : emptyNotebook();
31437
31521
  return notebookToEditableText(notebook);
31438
31522
  }
31439
31523
  function serializeEditedNotebookText(absolutePath, displayPath, text) {
31440
- const notebook = existsSync19(absolutePath) ? parseNotebookSafe(readFileSync14(absolutePath, "utf8"), displayPath) : emptyNotebook();
31524
+ const notebook = existsSync20(absolutePath) ? parseNotebookSafe(readFileSync15(absolutePath, "utf8"), displayPath) : emptyNotebook();
31441
31525
  const next = applyNotebookEditableText(notebook, text, displayPath);
31442
31526
  return JSON.stringify(next, null, 1);
31443
31527
  }
@@ -31768,10 +31852,10 @@ var init_management_http = __esm(() => {
31768
31852
 
31769
31853
  // src/utils/tools-manager.ts
31770
31854
  import { spawnSync as spawnSync5 } from "child_process";
31771
- import { chmodSync as chmodSync3, existsSync as existsSync20, mkdirSync as mkdirSync8, readdirSync as readdirSync5, renameSync, rmSync as rmSync4 } from "fs";
31855
+ import { chmodSync as chmodSync3, existsSync as existsSync21, mkdirSync as mkdirSync8, readdirSync as readdirSync5, renameSync, rmSync as rmSync4 } from "fs";
31772
31856
  import { writeFile } from "fs/promises";
31773
31857
  import { arch, platform as platform2 } from "os";
31774
- import { join as join30 } from "path";
31858
+ import { join as join31 } from "path";
31775
31859
  function isOfflineModeEnabled() {
31776
31860
  const value = getEnvValue(ENV_OFFLINE);
31777
31861
  if (!value)
@@ -31790,8 +31874,8 @@ function getToolPath(tool) {
31790
31874
  const config = TOOLS[tool];
31791
31875
  if (!config)
31792
31876
  return null;
31793
- const localPath = join30(TOOLS_DIR, config.binaryName + (platform2() === "win32" ? ".exe" : ""));
31794
- if (existsSync20(localPath)) {
31877
+ const localPath = join31(TOOLS_DIR, config.binaryName + (platform2() === "win32" ? ".exe" : ""));
31878
+ if (existsSync21(localPath)) {
31795
31879
  return localPath;
31796
31880
  }
31797
31881
  const systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];
@@ -31830,7 +31914,7 @@ function findBinaryRecursively(rootDir, binaryFileName) {
31830
31914
  continue;
31831
31915
  const entries = readdirSync5(currentDir, { withFileTypes: true });
31832
31916
  for (const entry of entries) {
31833
- const fullPath = join30(currentDir, entry.name);
31917
+ const fullPath = join31(currentDir, entry.name);
31834
31918
  if (entry.isFile() && entry.name === binaryFileName) {
31835
31919
  return fullPath;
31836
31920
  }
@@ -31871,8 +31955,8 @@ function extractTarGzArchive(archivePath, extractDir, assetName) {
31871
31955
  function getWindowsTarCommand() {
31872
31956
  const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
31873
31957
  if (systemRoot) {
31874
- const systemTar = join30(systemRoot, "System32", "tar.exe");
31875
- if (existsSync20(systemTar)) {
31958
+ const systemTar = join31(systemRoot, "System32", "tar.exe");
31959
+ if (existsSync21(systemTar)) {
31876
31960
  return systemTar;
31877
31961
  }
31878
31962
  }
@@ -31925,11 +32009,11 @@ async function downloadTool(tool) {
31925
32009
  }
31926
32010
  mkdirSync8(TOOLS_DIR, { recursive: true });
31927
32011
  const downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;
31928
- const archivePath = join30(TOOLS_DIR, assetName);
32012
+ const archivePath = join31(TOOLS_DIR, assetName);
31929
32013
  const binaryExt = plat === "win32" ? ".exe" : "";
31930
- const binaryPath = join30(TOOLS_DIR, config.binaryName + binaryExt);
32014
+ const binaryPath = join31(TOOLS_DIR, config.binaryName + binaryExt);
31931
32015
  await downloadFile(downloadUrl, archivePath);
31932
- const extractDir = join30(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
32016
+ const extractDir = join31(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
31933
32017
  mkdirSync8(extractDir, { recursive: true });
31934
32018
  try {
31935
32019
  if (assetName.endsWith(".tar.gz")) {
@@ -31940,9 +32024,9 @@ async function downloadTool(tool) {
31940
32024
  throw new Error(`Unsupported archive format: ${assetName}`);
31941
32025
  }
31942
32026
  const binaryFileName = config.binaryName + binaryExt;
31943
- const extractedDir = join30(extractDir, assetName.replace(/\.(tar\.gz|zip)$/, ""));
31944
- const extractedBinaryCandidates = [join30(extractedDir, binaryFileName), join30(extractDir, binaryFileName)];
31945
- let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync20(candidate));
32027
+ const extractedDir = join31(extractDir, assetName.replace(/\.(tar\.gz|zip)$/, ""));
32028
+ const extractedBinaryCandidates = [join31(extractedDir, binaryFileName), join31(extractDir, binaryFileName)];
32029
+ let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync21(candidate));
31946
32030
  if (!extractedBinary) {
31947
32031
  extractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;
31948
32032
  }
@@ -33530,7 +33614,7 @@ var init_read_selectors = __esm(() => {
33530
33614
  });
33531
33615
 
33532
33616
  // src/core/tools/read-document-extract.ts
33533
- import { existsSync as existsSync21 } from "node:fs";
33617
+ import { existsSync as existsSync22 } from "node:fs";
33534
33618
  function isDocumentPath(pathValue) {
33535
33619
  return DOCUMENT_EXTENSIONS.test(pathValue);
33536
33620
  }
@@ -33727,7 +33811,7 @@ function documentExtension(source) {
33727
33811
  }
33728
33812
  async function extractMarkitDocument(buffer, source) {
33729
33813
  const ext = documentExtension(source);
33730
- const result = existsSync21(source) ? await convertFileWithMarkit(source) : await convertBufferWithMarkit(buffer, ext);
33814
+ const result = existsSync22(source) ? await convertFileWithMarkit(source) : await convertBufferWithMarkit(buffer, ext);
33731
33815
  return result.ok ? result.content : `[Cannot read ${ext} file: ${result.error || "conversion failed"}]`;
33732
33816
  }
33733
33817
  async function extractDocumentMarkdown(buffer, source) {
@@ -34590,7 +34674,7 @@ var init_read_url = __esm(() => {
34590
34674
  });
34591
34675
 
34592
34676
  // src/core/tools/read.ts
34593
- import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute6, relative as relative7, resolve as resolvePath5, sep as sep6 } from "node:path";
34677
+ import { basename as basename5, dirname as dirname13, isAbsolute as isAbsolute6, relative as relative7, resolve as resolvePath5, sep as sep6 } from "node:path";
34594
34678
  import { Text as Text32 } from "@earendil-works/pi-tui";
34595
34679
  import { constants as constants5 } from "fs";
34596
34680
  import { access as fsAccess3, readFile as fsReadFile2, stat as fsStat4 } from "fs/promises";
@@ -34668,7 +34752,7 @@ function oversizedReadResult(details) {
34668
34752
  };
34669
34753
  }
34670
34754
  function getPiDocsClassification(absolutePath) {
34671
- const packageRoot = dirname12(getReadmePath());
34755
+ const packageRoot = dirname13(getReadmePath());
34672
34756
  const relativePath = relative7(resolvePath5(packageRoot), resolvePath5(absolutePath));
34673
34757
  if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${sep6}`) || isAbsolute6(relativePath)) {
34674
34758
  return;
@@ -34686,7 +34770,7 @@ function getCompactReadClassification(args, cwd) {
34686
34770
  const absolutePath = resolveToCwd(rawPath, cwd);
34687
34771
  const fileName = basename5(absolutePath);
34688
34772
  if (fileName === "SKILL.md") {
34689
- return { kind: "skill", label: basename5(dirname12(absolutePath)) || fileName };
34773
+ return { kind: "skill", label: basename5(dirname13(absolutePath)) || fileName };
34690
34774
  }
34691
34775
  const docsClassification = getPiDocsClassification(absolutePath);
34692
34776
  if (docsClassification)
@@ -35846,22 +35930,22 @@ function filterSearchOutputByLineRange(text, ranges, contextBefore = 1, contextA
35846
35930
  }
35847
35931
 
35848
35932
  // src/core/tools/search.ts
35849
- import { existsSync as existsSync22 } from "node:fs";
35933
+ import { existsSync as existsSync23 } from "node:fs";
35850
35934
  import { readFile as fsReadFile4, stat as fsStat6 } from "node:fs/promises";
35851
- import { dirname as dirname13, join as join31, resolve as resolvePath6 } from "node:path";
35935
+ import { dirname as dirname14, join as join32, resolve as resolvePath6 } from "node:path";
35852
35936
  import { Text as Text34 } from "@earendil-works/pi-tui";
35853
35937
  import { Type as Type9 } from "typebox";
35854
35938
  function delimiterInExistingSearchGlobRoot(value, cwd) {
35855
35939
  const selector = splitLineRangeSelector(value);
35856
35940
  const parsed = splitPathLikeGlob(selector.path);
35857
- return !!parsed.glob && /[;,\s]/.test(parsed.basePath) && existsSync22(resolveToCwd(parsed.basePath, cwd));
35941
+ return !!parsed.glob && /[;,\s]/.test(parsed.basePath) && existsSync23(resolveToCwd(parsed.basePath, cwd));
35858
35942
  }
35859
35943
  function archiveSelectorExists(value, cwd) {
35860
35944
  const archive = parseArchiveSelector(value);
35861
35945
  if (!archive)
35862
35946
  return false;
35863
35947
  const resolved = resolveArchiveSelector(archive, cwd);
35864
- if (!existsSync22(resolved.archivePath))
35948
+ if (!existsSync23(resolved.archivePath))
35865
35949
  return false;
35866
35950
  if (!resolved.memberPath)
35867
35951
  return true;
@@ -35877,7 +35961,7 @@ function searchPathResolvable(value, cwd) {
35877
35961
  if (archive)
35878
35962
  return archiveSelectorExists(selector.path, cwd);
35879
35963
  const sqlite = sqliteSelectorForPath(selector.path, cwd);
35880
- return !!sqlite || /^(?:skill|agent|artifact|history|issue|local|memory|pr|conflict|omp|rule|mcp|vault):\/\//.test(selector.path) || existsSync22(resolveToCwd(splitPathLikeGlob(selector.path).basePath, cwd));
35964
+ return !!sqlite || /^(?:skill|agent|artifact|history|issue|local|memory|pr|conflict|omp|rule|mcp|vault):\/\//.test(selector.path) || existsSync23(resolveToCwd(splitPathLikeGlob(selector.path).basePath, cwd));
35881
35965
  }
35882
35966
  function normalizePaths(pathsValue, cwd) {
35883
35967
  const inputs = Array.isArray(pathsValue) ? pathsValue.length > 0 ? pathsValue : ["."] : pathsValue === undefined ? ["."] : [pathsValue];
@@ -35889,7 +35973,7 @@ function normalizePaths(pathsValue, cwd) {
35889
35973
  continue;
35890
35974
  }
35891
35975
  const resourceLike = /^[a-z]+:\/\//i.test(raw) || /^[^:]+\.(?:zip|jar|tar|tgz|gz|sqlite|db):/i.test(raw);
35892
- if (existsSync22(resolveToCwd(splitLineRangeSelector(raw).path, cwd)) || delimiterInExistingSearchGlobRoot(raw, cwd) || archiveSelectorExists(raw, cwd)) {
35976
+ if (existsSync23(resolveToCwd(splitLineRangeSelector(raw).path, cwd)) || delimiterInExistingSearchGlobRoot(raw, cwd) || archiveSelectorExists(raw, cwd)) {
35893
35977
  expanded.push(raw);
35894
35978
  continue;
35895
35979
  }
@@ -36074,7 +36158,7 @@ async function addHashlineHeadersToSearchOutput(text, cwd, targetPath, hashlineS
36074
36158
  const rendered = [];
36075
36159
  let lastDir = "";
36076
36160
  for (const group of groups) {
36077
- let absolutePath = targetIsFile ? searchRoot : join31(searchRoot, group.path);
36161
+ let absolutePath = targetIsFile ? searchRoot : join32(searchRoot, group.path);
36078
36162
  try {
36079
36163
  await fsReadFile4(absolutePath);
36080
36164
  } catch {
@@ -36083,7 +36167,7 @@ async function addHashlineHeadersToSearchOutput(text, cwd, targetPath, hashlineS
36083
36167
  try {
36084
36168
  const content = await fsReadFile4(absolutePath, "utf-8");
36085
36169
  const snapshot = recordHashlineSnapshot(absolutePath, cwd, content, hashlineStore);
36086
- const dir = dirname13(snapshot.displayPath);
36170
+ const dir = dirname14(snapshot.displayPath);
36087
36171
  if (dir !== "." && dir !== lastDir) {
36088
36172
  rendered.push(`# ${dir}/`);
36089
36173
  lastDir = dir;
@@ -36748,7 +36832,7 @@ var init_todos_locks = __esm(() => {
36748
36832
 
36749
36833
  // src/core/tools/todos-storage.ts
36750
36834
  import crypto3 from "node:crypto";
36751
- import { existsSync as existsSync23 } from "node:fs";
36835
+ import { existsSync as existsSync24 } from "node:fs";
36752
36836
  import fs7 from "node:fs/promises";
36753
36837
  import path11 from "node:path";
36754
36838
  function parseFrontMatter(text, idFallback) {
@@ -36880,7 +36964,7 @@ async function generateTodoId(todosDir) {
36880
36964
  for (let attempt = 0;attempt < 10; attempt += 1) {
36881
36965
  const id = crypto3.randomBytes(4).toString("hex");
36882
36966
  const todoPath = getTodoPath(todosDir, id);
36883
- if (!existsSync23(todoPath))
36967
+ if (!existsSync24(todoPath))
36884
36968
  return id;
36885
36969
  }
36886
36970
  throw new Error("Failed to generate unique todo id");
@@ -36915,7 +36999,7 @@ async function listTodos(todosDir) {
36915
36999
  return sortTodos(todos);
36916
37000
  }
36917
37001
  async function ensureTodoExists(filePath, id) {
36918
- if (!existsSync23(filePath))
37002
+ if (!existsSync24(filePath))
36919
37003
  return null;
36920
37004
  return readTodoFile(filePath, id);
36921
37005
  }
@@ -36934,7 +37018,7 @@ var init_todos_storage = __esm(() => {
36934
37018
  });
36935
37019
 
36936
37020
  // src/core/tools/todos-mutations.ts
36937
- import { existsSync as existsSync24 } from "node:fs";
37021
+ import { existsSync as existsSync25 } from "node:fs";
36938
37022
  import fs8 from "node:fs/promises";
36939
37023
  async function claimTodoAssignment(todosDir, id, ctx, force = false) {
36940
37024
  const validated = validateTodoId(id);
@@ -36943,7 +37027,7 @@ async function claimTodoAssignment(todosDir, id, ctx, force = false) {
36943
37027
  }
36944
37028
  const normalizedId = validated.id;
36945
37029
  const filePath = getTodoPath(todosDir, normalizedId);
36946
- if (!existsSync24(filePath)) {
37030
+ if (!existsSync25(filePath)) {
36947
37031
  return { error: `Todo ${displayTodoId(id)} not found` };
36948
37032
  }
36949
37033
  const sessionId = ctx.sessionManager.getSessionId();
@@ -36974,7 +37058,7 @@ async function releaseTodoAssignment(todosDir, id, ctx, force = false) {
36974
37058
  }
36975
37059
  const normalizedId = validated.id;
36976
37060
  const filePath = getTodoPath(todosDir, normalizedId);
36977
- if (!existsSync24(filePath)) {
37061
+ if (!existsSync25(filePath)) {
36978
37062
  return { error: `Todo ${displayTodoId(id)} not found` };
36979
37063
  }
36980
37064
  const sessionId = ctx.sessionManager.getSessionId();
@@ -37003,7 +37087,7 @@ async function deleteTodo(todosDir, id, ctx) {
37003
37087
  }
37004
37088
  const normalizedId = validated.id;
37005
37089
  const filePath = getTodoPath(todosDir, normalizedId);
37006
- if (!existsSync24(filePath)) {
37090
+ if (!existsSync25(filePath)) {
37007
37091
  return { error: `Todo ${displayTodoId(id)} not found` };
37008
37092
  }
37009
37093
  return withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37175,7 +37259,7 @@ var init_todos_render = __esm(() => {
37175
37259
  });
37176
37260
 
37177
37261
  // src/core/tools/todos-execute.ts
37178
- import { existsSync as existsSync25 } from "node:fs";
37262
+ import { existsSync as existsSync26 } from "node:fs";
37179
37263
  function todoActionResult(action, text, detailsError) {
37180
37264
  return {
37181
37265
  content: [{ type: "text", text }],
@@ -37259,7 +37343,7 @@ async function executeUpdateAction(todosDir, params, ctx) {
37259
37343
  const normalizedId = validated.id;
37260
37344
  const displayId = formatTodoId(normalizedId);
37261
37345
  const filePath = getTodoPath(todosDir, normalizedId);
37262
- if (!existsSync25(filePath)) {
37346
+ if (!existsSync26(filePath)) {
37263
37347
  return todoActionResult("update", `Todo ${displayId} not found`, "not found");
37264
37348
  }
37265
37349
  const result = await withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37296,7 +37380,7 @@ async function executeAppendAction(todosDir, params, ctx) {
37296
37380
  const normalizedId = validated.id;
37297
37381
  const displayId = formatTodoId(normalizedId);
37298
37382
  const filePath = getTodoPath(todosDir, normalizedId);
37299
- if (!existsSync25(filePath)) {
37383
+ if (!existsSync26(filePath)) {
37300
37384
  return todoActionResult("append", `Todo ${displayId} not found`, "not found");
37301
37385
  }
37302
37386
  const result = await withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37416,7 +37500,7 @@ import {
37416
37500
  stat as fsStat7,
37417
37501
  writeFile as fsWriteFile2
37418
37502
  } from "fs/promises";
37419
- import { dirname as dirname14, join as join32 } from "path";
37503
+ import { dirname as dirname15, join as join33 } from "path";
37420
37504
  import { Type as Type11 } from "typebox";
37421
37505
  async function findConflictBlocks(root, limit = 100) {
37422
37506
  const out = [];
@@ -37424,7 +37508,7 @@ async function findConflictBlocks(root, limit = 100) {
37424
37508
  for (const entry of await fsReaddir2(dir, { withFileTypes: true }).catch(() => [])) {
37425
37509
  if (out.length >= limit || entry.name === ".git" || entry.name === "node_modules")
37426
37510
  continue;
37427
- const full = join32(dir, entry.name);
37511
+ const full = join33(dir, entry.name);
37428
37512
  if (entry.isDirectory())
37429
37513
  await walk(full);
37430
37514
  else if (entry.isFile()) {
@@ -37714,7 +37798,7 @@ ${headers[0]}` : ""}` }],
37714
37798
  };
37715
37799
  }
37716
37800
  const absolutePath = resolveToCwd(path12, cwd);
37717
- const dir = dirname14(absolutePath);
37801
+ const dir = dirname15(absolutePath);
37718
37802
  return withFileMutationQueue(absolutePath, async () => {
37719
37803
  const throwIfAborted2 = () => {
37720
37804
  if (signal?.aborted)
@@ -38221,20 +38305,20 @@ import {
38221
38305
  lstatSync as lstatSync2,
38222
38306
  openSync as openSync3,
38223
38307
  readdirSync as readdirSync6,
38224
- readFileSync as readFileSync15,
38308
+ readFileSync as readFileSync16,
38225
38309
  renameSync as renameSync2,
38226
38310
  rmSync as rmSync5,
38227
38311
  statSync as statSync6,
38228
38312
  unlinkSync as unlinkSync4,
38229
38313
  writeSync
38230
38314
  } from "node:fs";
38231
- import { join as join33 } from "node:path";
38315
+ import { join as join34 } from "node:path";
38232
38316
  function getCleanupControlRoot() {
38233
- return join33(getTempRootDir(), CLEANUP_CONTROL_SUBDIR);
38317
+ return join34(getTempRootDir(), CLEANUP_CONTROL_SUBDIR);
38234
38318
  }
38235
38319
  function getCleanupControlDir(target, controlRoot) {
38236
38320
  const key = createHash3("sha256").update(target).digest("hex").slice(0, 16);
38237
- return join33(controlRoot ?? getCleanupControlRoot(), key);
38321
+ return join34(controlRoot ?? getCleanupControlRoot(), key);
38238
38322
  }
38239
38323
  function sameFileIdentity2(left, right) {
38240
38324
  return left.dev === right.dev && left.ino === right.ino;
@@ -38361,7 +38445,7 @@ function breakStaleLock(lockPath, observedMtimeMs) {
38361
38445
  }
38362
38446
  function ownsCleanupLock(lockPath, lock) {
38363
38447
  try {
38364
- return pathIdentifiesFile(lockPath, lock) && readFileSync15(lockPath, "utf-8") === lock.token && pathIdentifiesFile(lockPath, lock);
38448
+ return pathIdentifiesFile(lockPath, lock) && readFileSync16(lockPath, "utf-8") === lock.token && pathIdentifiesFile(lockPath, lock);
38365
38449
  } catch {
38366
38450
  return false;
38367
38451
  }
@@ -38450,7 +38534,7 @@ function scanFreshness(entryPath, cutoff, depth = 0) {
38450
38534
  }
38451
38535
  let foundUnknown = false;
38452
38536
  for (const child of children) {
38453
- const freshness = scanFreshness(join33(entryPath, child), cutoff, depth + 1);
38537
+ const freshness = scanFreshness(join34(entryPath, child), cutoff, depth + 1);
38454
38538
  if (freshness === "fresh") {
38455
38539
  return "fresh";
38456
38540
  }
@@ -38468,11 +38552,11 @@ function withCleanupGate(controlDir, options, scan) {
38468
38552
  } catch {
38469
38553
  return "locked";
38470
38554
  }
38471
- const markerPath = join33(controlDir, CLEANUP_MARKER_FILE);
38555
+ const markerPath = join34(controlDir, CLEANUP_MARKER_FILE);
38472
38556
  if (markerIsFresh(markerPath, now, throttleMs)) {
38473
38557
  return "throttled";
38474
38558
  }
38475
- const lockPath = join33(controlDir, CLEANUP_LOCK_FILE);
38559
+ const lockPath = join34(controlDir, CLEANUP_LOCK_FILE);
38476
38560
  const token = acquireCleanupLock(lockPath, now, SESSION_TEMP_CLEANUP_LOCK_STALE_MS);
38477
38561
  if (token === null) {
38478
38562
  return "locked";
@@ -38523,7 +38607,7 @@ function sweepSessionTempRoot(root = getTempRootDir(), options = {}) {
38523
38607
  if (isCleanupArtifact(entry)) {
38524
38608
  continue;
38525
38609
  }
38526
- const entryPath = join33(root, entry);
38610
+ const entryPath = join34(root, entry);
38527
38611
  if (gate.protectedPaths.has(entryPath)) {
38528
38612
  continue;
38529
38613
  }
@@ -38548,7 +38632,7 @@ function sweepSessionTempRoot(root = getTempRootDir(), options = {}) {
38548
38632
  });
38549
38633
  }
38550
38634
  function reapToolResultsDir(parent, cutoff, protectedPaths) {
38551
- const toolResultsDir = join33(parent, TOOL_RESULTS_SUBDIR);
38635
+ const toolResultsDir = join34(parent, TOOL_RESULTS_SUBDIR);
38552
38636
  if (protectedPaths.has(toolResultsDir) || !isRealDirectory2(toolResultsDir)) {
38553
38637
  return;
38554
38638
  }
@@ -38573,7 +38657,7 @@ function sweepToolResultsRoot(sessionsRoot, options = {}) {
38573
38657
  return;
38574
38658
  }
38575
38659
  for (const entry of entries) {
38576
- const projectDir = join33(sessionsRoot, entry);
38660
+ const projectDir = join34(sessionsRoot, entry);
38577
38661
  if (!isRealDirectory2(projectDir) || gate.protectedPaths.has(projectDir)) {
38578
38662
  continue;
38579
38663
  }
@@ -38814,7 +38898,7 @@ function parseSkillBlock(text) {
38814
38898
  }
38815
38899
 
38816
38900
  // src/core/agent-session.ts
38817
- import { join as join34 } from "node:path";
38901
+ import { join as join35 } from "node:path";
38818
38902
 
38819
38903
  class AgentSessionBase {
38820
38904
  agent;
@@ -38937,7 +39021,7 @@ class AgentSessionBase {
38937
39021
  const sessionDir = this.sessionManager.getSessionDir() || undefined;
38938
39022
  this._tempStorageLease = acquireProtectedPaths([
38939
39023
  setActiveSessionTempId(sessionId),
38940
- ...sessionDir ? [join34(sessionDir, TOOL_RESULTS_SUBDIR)] : []
39024
+ ...sessionDir ? [join35(sessionDir, TOOL_RESULTS_SUBDIR)] : []
38941
39025
  ]);
38942
39026
  const customSessionDir = this.sessionManager.usesDefaultSessionDir() ? undefined : sessionDir;
38943
39027
  scheduleSessionTempCleanup(customSessionDir ? { sessionDirs: [customSessionDir] } : {});
@@ -38996,30 +39080,8 @@ var init_auth_storage = __esm(() => {
38996
39080
  init_auth_storage_backends();
38997
39081
  });
38998
39082
 
38999
- // src/core/builtin-install-layout.ts
39000
- function requiredEntriesForBuiltin(dirName) {
39001
- return [INSTALLED_EXTENSION_ENTRIES[dirName], SOURCE_EXTENSION_ENTRIES[dirName]];
39002
- }
39003
- var SOURCE_EXTENSION_ENTRIES, INSTALLED_EXTENSION_ENTRIES;
39004
- var init_builtin_install_layout = __esm(() => {
39005
- SOURCE_EXTENSION_ENTRIES = {
39006
- workflows: "src/extension/index.ts",
39007
- subagents: "src/extension/index.ts",
39008
- mcp: "index.ts",
39009
- "web-access": "index.ts",
39010
- intercom: "index.ts"
39011
- };
39012
- INSTALLED_EXTENSION_ENTRIES = {
39013
- workflows: "src/extension/index.bundle.mjs",
39014
- subagents: "src/extension/index.bundle.mjs",
39015
- mcp: "index.bundle.mjs",
39016
- "web-access": "index.bundle.mjs",
39017
- intercom: "index.bundle.mjs"
39018
- };
39019
- });
39020
-
39021
39083
  // src/core/builtin-packages.ts
39022
- import { join as join35, resolve as resolve8 } from "node:path";
39084
+ import { join as join36, resolve as resolve8 } from "node:path";
39023
39085
  var WORKSPACE_BUILTINS, BUILTIN_PACKAGES;
39024
39086
  var init_builtin_packages = __esm(() => {
39025
39087
  init_config();
@@ -39036,7 +39098,7 @@ var init_builtin_packages = __esm(() => {
39036
39098
  packageName: spec.packageName,
39037
39099
  distDirName: spec.distDirName,
39038
39100
  requiredEntries: requiredEntriesForBuiltin(spec.distDirName),
39039
- sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join35(packageDir, "..", spec.workspaceDirName), join35(here, "..", "..", "..", spec.workspaceDirName)] : []
39101
+ sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join36(packageDir, "..", spec.workspaceDirName), join36(here, "..", "..", "..", spec.workspaceDirName)] : []
39040
39102
  }));
39041
39103
  });
39042
39104
 
@@ -39287,14 +39349,14 @@ var init_git_env = __esm(() => {
39287
39349
  });
39288
39350
 
39289
39351
  // src/core/package-manager-env.ts
39290
- import { readFileSync as readFileSync16 } from "node:fs";
39352
+ import { readFileSync as readFileSync17 } from "node:fs";
39291
39353
  import { basename as basename6 } from "node:path";
39292
39354
  function getEnv() {
39293
39355
  if (process.platform !== "linux" || Object.keys(process.env).length > 0) {
39294
39356
  return process.env;
39295
39357
  }
39296
39358
  try {
39297
- const data = readFileSync16("/proc/self/environ", "utf-8");
39359
+ const data = readFileSync17("/proc/self/environ", "utf-8");
39298
39360
  const env = {};
39299
39361
  for (const entry of data.split("\x00")) {
39300
39362
  const idx = entry.indexOf("=");
@@ -39526,13 +39588,13 @@ var NETWORK_TIMEOUT_MS2 = 1e4, UPDATE_CHECK_CONCURRENCY = 4, GIT_UPDATE_CONCURRE
39526
39588
  // src/core/package-manager-paths.ts
39527
39589
  import { createHash as createHash4 } from "node:crypto";
39528
39590
  import { homedir as homedir6, tmpdir as tmpdir5 } from "node:os";
39529
- import { join as join36 } from "node:path";
39591
+ import { join as join37 } from "node:path";
39530
39592
  function getHomeDir2() {
39531
39593
  return process.env.HOME || homedir6();
39532
39594
  }
39533
39595
  function getTemporaryDir(prefix, suffix) {
39534
39596
  const hash = createHash4("sha256").update(`${prefix}-${suffix ?? ""}`).digest("hex").slice(0, 8);
39535
- return join36(tmpdir5(), `${APP_NAME}-extensions`, prefix, hash, suffix ?? "");
39597
+ return join37(tmpdir5(), `${APP_NAME}-extensions`, prefix, hash, suffix ?? "");
39536
39598
  }
39537
39599
  function getBaseDirsForScope(context, scope) {
39538
39600
  if (scope === "project") {
@@ -39557,27 +39619,27 @@ function getNpmInstallRoot(context, scope, temporary) {
39557
39619
  return getTemporaryDir("npm");
39558
39620
  }
39559
39621
  if (scope === "project") {
39560
- return join36(context.cwd, CONFIG_DIR_NAME, "npm");
39622
+ return join37(context.cwd, CONFIG_DIR_NAME, "npm");
39561
39623
  }
39562
- return join36(context.agentDir, "npm");
39624
+ return join37(context.agentDir, "npm");
39563
39625
  }
39564
39626
  function getGitInstallPath(context, source, scope) {
39565
39627
  if (scope === "temporary") {
39566
39628
  return getTemporaryDir(`git-${source.host}`, source.path);
39567
39629
  }
39568
39630
  if (scope === "project") {
39569
- return join36(context.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
39631
+ return join37(context.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
39570
39632
  }
39571
- return join36(context.agentDir, "git", source.host, source.path);
39633
+ return join37(context.agentDir, "git", source.host, source.path);
39572
39634
  }
39573
39635
  function getGitInstallRoot(context, scope) {
39574
39636
  if (scope === "temporary") {
39575
39637
  return;
39576
39638
  }
39577
39639
  if (scope === "project") {
39578
- return join36(context.cwd, CONFIG_DIR_NAME, "git");
39640
+ return join37(context.cwd, CONFIG_DIR_NAME, "git");
39579
39641
  }
39580
- return join36(context.agentDir, "git");
39642
+ return join37(context.agentDir, "git");
39581
39643
  }
39582
39644
  var init_package_manager_paths = __esm(() => {
39583
39645
  init_config();
@@ -39585,8 +39647,8 @@ var init_package_manager_paths = __esm(() => {
39585
39647
  });
39586
39648
 
39587
39649
  // src/core/package-manager-npm.ts
39588
- import { existsSync as existsSync26, mkdirSync as mkdirSync9, readFileSync as readFileSync17, writeFileSync as writeFileSync10 } from "node:fs";
39589
- import { basename as basename7, dirname as dirname15, join as join37 } from "node:path";
39650
+ import { existsSync as existsSync27, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "node:fs";
39651
+ import { basename as basename7, dirname as dirname16, join as join38 } from "node:path";
39590
39652
  import { maxSatisfying, rcompare, satisfies } from "semver";
39591
39653
  function getNpmCommand(context) {
39592
39654
  const configuredCommand = context.settingsManager.getNpmCommand();
@@ -39653,7 +39715,7 @@ async function installNpm(context, source, scope, temporary) {
39653
39715
  }
39654
39716
  async function uninstallNpm(context, source, scope) {
39655
39717
  const installRoot = getNpmInstallRoot(context, scope, false);
39656
- if (!existsSync26(installRoot)) {
39718
+ if (!existsSync27(installRoot)) {
39657
39719
  return;
39658
39720
  }
39659
39721
  if (getPackageManagerName(context) === "bun") {
@@ -39668,23 +39730,23 @@ async function installNpmBatch(context, specs, scope) {
39668
39730
  await runNpmCommand(context, getNpmInstallArgs(context, specs, installRoot));
39669
39731
  }
39670
39732
  function ensureNpmProject(installRoot) {
39671
- if (!existsSync26(installRoot)) {
39733
+ if (!existsSync27(installRoot)) {
39672
39734
  mkdirSync9(installRoot, { recursive: true });
39673
39735
  }
39674
39736
  markPathIgnoredByCloudSync(installRoot);
39675
39737
  ensureGitIgnore(installRoot);
39676
- const packageJsonPath = join37(installRoot, "package.json");
39677
- if (!existsSync26(packageJsonPath)) {
39738
+ const packageJsonPath = join38(installRoot, "package.json");
39739
+ if (!existsSync27(packageJsonPath)) {
39678
39740
  const pkgJson = { name: `${APP_NAME}-extensions`, private: true };
39679
39741
  writeFileSync10(packageJsonPath, JSON.stringify(pkgJson, null, 2), "utf-8");
39680
39742
  }
39681
39743
  }
39682
39744
  function ensureGitIgnore(dir) {
39683
- if (!existsSync26(dir)) {
39745
+ if (!existsSync27(dir)) {
39684
39746
  mkdirSync9(dir, { recursive: true });
39685
39747
  }
39686
- const ignorePath = join37(dir, ".gitignore");
39687
- if (!existsSync26(ignorePath)) {
39748
+ const ignorePath = join38(dir, ".gitignore");
39749
+ if (!existsSync27(ignorePath)) {
39688
39750
  writeFileSync10(ignorePath, `*
39689
39751
  !.gitignore
39690
39752
  `, "utf-8");
@@ -39692,12 +39754,12 @@ function ensureGitIgnore(dir) {
39692
39754
  }
39693
39755
  function getManagedNpmInstallPath(context, source, scope) {
39694
39756
  if (scope === "temporary") {
39695
- return join37(getNpmInstallRoot(context, scope, true), "node_modules", source.name);
39757
+ return join38(getNpmInstallRoot(context, scope, true), "node_modules", source.name);
39696
39758
  }
39697
39759
  if (scope === "project") {
39698
- return join37(context.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
39760
+ return join38(context.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
39699
39761
  }
39700
- return join37(context.agentDir, "npm", "node_modules", source.name);
39762
+ return join38(context.agentDir, "npm", "node_modules", source.name);
39701
39763
  }
39702
39764
  function getGlobalNpmRoot(context) {
39703
39765
  const npmCommand = getNpmCommand(context);
@@ -39707,7 +39769,7 @@ function getGlobalNpmRoot(context) {
39707
39769
  }
39708
39770
  if (getPackageManagerName(context) === "bun") {
39709
39771
  const binDir = runNpmCommandSync(context, ["pm", "bin", "-g"]).trim();
39710
- context.globalNpmRoot = join37(dirname15(binDir), "install", "global", "node_modules");
39772
+ context.globalNpmRoot = join38(dirname16(binDir), "install", "global", "node_modules");
39711
39773
  } else {
39712
39774
  context.globalNpmRoot = runNpmCommandSync(context, ["root", "-g"]).trim();
39713
39775
  }
@@ -39733,28 +39795,28 @@ function getLegacyGlobalNpmInstallPath(context, source) {
39733
39795
  if (pnpmPath)
39734
39796
  return pnpmPath;
39735
39797
  const globalRoot = context.driver?.getGlobalNpmRoot ? context.driver.getGlobalNpmRoot() : getGlobalNpmRoot(context);
39736
- return join37(globalRoot, source.name);
39798
+ return join38(globalRoot, source.name);
39737
39799
  } catch {
39738
39800
  return;
39739
39801
  }
39740
39802
  }
39741
39803
  function getNpmInstallPath(context, source, scope) {
39742
39804
  const managedPath = getManagedNpmInstallPath(context, source, scope);
39743
- if (scope !== "user" || existsSync26(managedPath)) {
39805
+ if (scope !== "user" || existsSync27(managedPath)) {
39744
39806
  return managedPath;
39745
39807
  }
39746
39808
  const legacyPath = getLegacyGlobalNpmInstallPath(context, source);
39747
- return legacyPath && existsSync26(legacyPath) ? legacyPath : managedPath;
39809
+ return legacyPath && existsSync27(legacyPath) ? legacyPath : managedPath;
39748
39810
  }
39749
39811
  function getExistingNpmInstallPath(context, source, scope) {
39750
39812
  const candidates = [getNpmInstallPath(context, source, scope)];
39751
39813
  if (scope === "project") {
39752
39814
  for (const configDir of getProjectConfigDirs(context.cwd)) {
39753
- candidates.push(join37(configDir, "npm", "node_modules", source.name));
39815
+ candidates.push(join38(configDir, "npm", "node_modules", source.name));
39754
39816
  }
39755
39817
  }
39756
39818
  for (const candidate of Array.from(new Set(candidates))) {
39757
- if (existsSync26(candidate))
39819
+ if (existsSync27(candidate))
39758
39820
  return candidate;
39759
39821
  }
39760
39822
  return;
@@ -39791,11 +39853,11 @@ async function npmHasAvailableUpdate(context, source, installedPath) {
39791
39853
  }
39792
39854
  }
39793
39855
  function getInstalledNpmVersion(installedPath) {
39794
- const packageJsonPath = join37(installedPath, "package.json");
39795
- if (!existsSync26(packageJsonPath))
39856
+ const packageJsonPath = join38(installedPath, "package.json");
39857
+ if (!existsSync27(packageJsonPath))
39796
39858
  return;
39797
39859
  try {
39798
- const content = readFileSync17(packageJsonPath, "utf-8");
39860
+ const content = readFileSync18(packageJsonPath, "utf-8");
39799
39861
  const pkg2 = JSON.parse(content);
39800
39862
  return pkg2.version;
39801
39863
  } catch {
@@ -39850,8 +39912,8 @@ async function withProgress(context, action, source, message, operation) {
39850
39912
  }
39851
39913
 
39852
39914
  // src/core/package-manager-git.ts
39853
- import { existsSync as existsSync27, mkdirSync as mkdirSync10, readdirSync as readdirSync7, readFileSync as readFileSync18, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "node:fs";
39854
- import { basename as basename8, dirname as dirname16, join as join38, resolve as resolve9, sep as sep7 } from "node:path";
39915
+ import { existsSync as existsSync28, mkdirSync as mkdirSync10, readdirSync as readdirSync7, readFileSync as readFileSync19, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "node:fs";
39916
+ import { basename as basename8, dirname as dirname17, join as join39, resolve as resolve9, sep as sep7 } from "node:path";
39855
39917
  function runGitProcess(context, command, args, options) {
39856
39918
  return context.driver ? context.driver.runCommand(command, args, options) : runCommand2(command, args, options);
39857
39919
  }
@@ -39880,28 +39942,28 @@ function getExistingGitInstallPath(context, source, scope) {
39880
39942
  const candidates = [getGitInstallPath(context, source, scope)];
39881
39943
  if (scope === "project") {
39882
39944
  for (const configDir of getProjectConfigDirs(context.cwd)) {
39883
- candidates.push(join38(configDir, "git", source.host, source.path));
39945
+ candidates.push(join39(configDir, "git", source.host, source.path));
39884
39946
  }
39885
39947
  } else if (scope === "user") {
39886
39948
  for (const agentDir of getBaseDirsForScope(context, "user")) {
39887
- candidates.push(join38(agentDir, "git", source.host, source.path));
39949
+ candidates.push(join39(agentDir, "git", source.host, source.path));
39888
39950
  }
39889
39951
  }
39890
39952
  for (const candidate of Array.from(new Set(candidates))) {
39891
- if (existsSync27(candidate))
39953
+ if (existsSync28(candidate))
39892
39954
  return candidate;
39893
39955
  }
39894
39956
  return;
39895
39957
  }
39896
39958
  function getGitUpdateMarkerPath(targetDir) {
39897
- return join38(dirname16(targetDir), `.${basename8(targetDir)}.${APP_NAME}-update-incomplete`);
39959
+ return join39(dirname17(targetDir), `.${basename8(targetDir)}.${APP_NAME}-update-incomplete`);
39898
39960
  }
39899
39961
  function hasMissingGitDependencies(targetDir) {
39900
- const packageJsonPath = join38(targetDir, "package.json");
39901
- if (!existsSync27(packageJsonPath))
39962
+ const packageJsonPath = join39(targetDir, "package.json");
39963
+ if (!existsSync28(packageJsonPath))
39902
39964
  return false;
39903
39965
  try {
39904
- const manifest = JSON.parse(readFileSync18(packageJsonPath, "utf-8"));
39966
+ const manifest = JSON.parse(readFileSync19(packageJsonPath, "utf-8"));
39905
39967
  if (!manifest.dependencies || typeof manifest.dependencies !== "object" || Array.isArray(manifest.dependencies)) {
39906
39968
  return false;
39907
39969
  }
@@ -39910,7 +39972,7 @@ function hasMissingGitDependencies(targetDir) {
39910
39972
  const dependencyPath = resolve9(nodeModulesDir, name);
39911
39973
  if (!dependencyPath.startsWith(`${nodeModulesDir}${sep7}`))
39912
39974
  return false;
39913
- return !existsSync27(dependencyPath);
39975
+ return !existsSync28(dependencyPath);
39914
39976
  });
39915
39977
  } catch {
39916
39978
  return false;
@@ -39928,7 +39990,7 @@ async function cleanAndInstallGitDependencies(context, targetDir, markerPath) {
39928
39990
  await repairMissingGitDependencies(context, targetDir).catch(() => {});
39929
39991
  throw error;
39930
39992
  }
39931
- if (existsSync27(join38(targetDir, "package.json"))) {
39993
+ if (existsSync28(join39(targetDir, "package.json"))) {
39932
39994
  await runNpmCommand(context, getGitDependencyInstallArgs(context), { cwd: targetDir });
39933
39995
  }
39934
39996
  rmSync6(markerPath, { force: true });
@@ -39936,7 +39998,7 @@ async function cleanAndInstallGitDependencies(context, targetDir, markerPath) {
39936
39998
  async function installGit(context, source, scope) {
39937
39999
  const safeRef = source.ref ? getSafeGitRef(source.ref) : undefined;
39938
40000
  const targetDir = getGitInstallPath(context, source, scope);
39939
- if (existsSync27(targetDir)) {
40001
+ if (existsSync28(targetDir)) {
39940
40002
  if (safeRef) {
39941
40003
  await ensureGitRef(context, targetDir, ["fetch", "origin", "--", safeRef], "FETCH_HEAD");
39942
40004
  return;
@@ -39949,7 +40011,7 @@ async function installGit(context, source, scope) {
39949
40011
  if (gitRoot) {
39950
40012
  ensureGitIgnore(gitRoot);
39951
40013
  }
39952
- mkdirSync10(dirname16(targetDir), { recursive: true });
40014
+ mkdirSync10(dirname17(targetDir), { recursive: true });
39953
40015
  rmSync6(getGitUpdateMarkerPath(targetDir), { force: true });
39954
40016
  const cloneUrl = source.repo;
39955
40017
  if (!/^[A-Za-z0-9._~:@/%+-]+$/.test(cloneUrl)) {
@@ -39960,8 +40022,8 @@ async function installGit(context, source, scope) {
39960
40022
  if (safeRef) {
39961
40023
  await runGitProcess(context, "git", ["checkout", safeRef], { cwd: targetDir });
39962
40024
  }
39963
- const packageJsonPath = join38(targetDir, "package.json");
39964
- if (existsSync27(packageJsonPath)) {
40025
+ const packageJsonPath = join39(targetDir, "package.json");
40026
+ if (existsSync28(packageJsonPath)) {
39965
40027
  await runNpmCommand(context, getGitDependencyInstallArgs(context), { cwd: targetDir });
39966
40028
  }
39967
40029
  } catch (error) {
@@ -39973,7 +40035,7 @@ async function installGit(context, source, scope) {
39973
40035
  async function updateGit(context, source, scope) {
39974
40036
  const safeRef = source.ref ? getSafeGitRef(source.ref) : undefined;
39975
40037
  const targetDir = getExistingGitInstallPath(context, source, scope) ?? getGitInstallPath(context, source, scope);
39976
- if (!existsSync27(targetDir)) {
40038
+ if (!existsSync28(targetDir)) {
39977
40039
  await installGit(context, source, scope);
39978
40040
  return;
39979
40041
  }
@@ -39997,7 +40059,7 @@ async function ensureGitRef(context, targetDir, fetchArgs, ref) {
39997
40059
  });
39998
40060
  const markerPath = getGitUpdateMarkerPath(targetDir);
39999
40061
  if (localHead.trim() === targetHead.trim()) {
40000
- if (existsSync27(markerPath)) {
40062
+ if (existsSync28(markerPath)) {
40001
40063
  await cleanAndInstallGitDependencies(context, targetDir, markerPath);
40002
40064
  } else {
40003
40065
  await repairMissingGitDependencies(context, targetDir);
@@ -40028,10 +40090,10 @@ function pruneEmptyGitParents(targetDir, installRoot) {
40028
40090
  if (!installRoot)
40029
40091
  return;
40030
40092
  const resolvedRoot = resolve9(installRoot);
40031
- let current = dirname16(targetDir);
40093
+ let current = dirname17(targetDir);
40032
40094
  while (current.startsWith(resolvedRoot) && current !== resolvedRoot) {
40033
- if (!existsSync27(current)) {
40034
- current = dirname16(current);
40095
+ if (!existsSync28(current)) {
40096
+ current = dirname17(current);
40035
40097
  continue;
40036
40098
  }
40037
40099
  const entries = readdirSync7(current);
@@ -40042,7 +40104,7 @@ function pruneEmptyGitParents(targetDir, installRoot) {
40042
40104
  } catch {
40043
40105
  break;
40044
40106
  }
40045
- current = dirname16(current);
40107
+ current = dirname17(current);
40046
40108
  }
40047
40109
  }
40048
40110
  async function gitHasAvailableUpdate(context, installedPath) {
@@ -40497,7 +40559,7 @@ var init_package_manager_source = __esm(() => {
40497
40559
  });
40498
40560
 
40499
40561
  // src/core/package-manager-operations.ts
40500
- import { existsSync as existsSync28 } from "node:fs";
40562
+ import { existsSync as existsSync29 } from "node:fs";
40501
40563
  async function install2(context, source, options) {
40502
40564
  const parsed = parseSource(source);
40503
40565
  const scope = options?.local ? "project" : "user";
@@ -40513,7 +40575,7 @@ async function install2(context, source, options) {
40513
40575
  }
40514
40576
  if (parsed.type === "local") {
40515
40577
  const resolved = resolveManagerPath(context, parsed.path);
40516
- if (!existsSync28(resolved)) {
40578
+ if (!existsSync29(resolved)) {
40517
40579
  throw new Error(`Path does not exist: ${resolved}`);
40518
40580
  }
40519
40581
  return;
@@ -40623,7 +40685,7 @@ async function updateConfiguredSources(context, sources) {
40623
40685
  }
40624
40686
  async function shouldUpdateNpmSource(context, source, scope) {
40625
40687
  const installedPath = getManagedNpmInstallPath(context, source, scope);
40626
- const installedVersion = existsSync28(installedPath) ? getInstalledNpmVersion(installedPath) : undefined;
40688
+ const installedVersion = existsSync29(installedPath) ? getInstalledNpmVersion(installedPath) : undefined;
40627
40689
  if (!installedVersion)
40628
40690
  return true;
40629
40691
  try {
@@ -40660,7 +40722,7 @@ async function checkForAvailableUpdates(context) {
40660
40722
  return;
40661
40723
  if (parsed.type === "npm") {
40662
40724
  const installedPath2 = getNpmInstallPath(context, parsed, entry.scope);
40663
- if (!existsSync28(installedPath2))
40725
+ if (!existsSync29(installedPath2))
40664
40726
  return;
40665
40727
  const hasUpdate2 = await npmHasAvailableUpdate(context, parsed, installedPath2);
40666
40728
  if (!hasUpdate2)
@@ -40758,7 +40820,7 @@ var init_package_manager_resource_accumulator = __esm(() => {
40758
40820
  });
40759
40821
 
40760
40822
  // src/core/package-manager-resource-patterns.ts
40761
- import { basename as basename9, dirname as dirname17, relative as relative9, sep as sep8 } from "node:path";
40823
+ import { basename as basename9, dirname as dirname18, relative as relative9, sep as sep8 } from "node:path";
40762
40824
  import { minimatch } from "minimatch";
40763
40825
  function toPosixPath4(p) {
40764
40826
  return p.split(sep8).join("/");
@@ -40789,7 +40851,7 @@ function matchesAnyPattern(filePath, patterns, baseDir) {
40789
40851
  const name = basename9(filePath);
40790
40852
  const filePathPosix = toPosixPath4(filePath);
40791
40853
  const isSkillFile = name === "SKILL.md";
40792
- const parentDir = isSkillFile ? dirname17(filePath) : undefined;
40854
+ const parentDir = isSkillFile ? dirname18(filePath) : undefined;
40793
40855
  const parentRel = isSkillFile ? toPosixPath4(relative9(baseDir, parentDir)) : undefined;
40794
40856
  const parentName = isSkillFile ? basename9(parentDir) : undefined;
40795
40857
  const parentDirPosix = isSkillFile ? toPosixPath4(parentDir) : undefined;
@@ -40814,7 +40876,7 @@ function matchesAnyExactPattern(filePath, patterns, baseDir) {
40814
40876
  const name = basename9(filePath);
40815
40877
  const filePathPosix = toPosixPath4(filePath);
40816
40878
  const isSkillFile = name === "SKILL.md";
40817
- const parentDir = isSkillFile ? dirname17(filePath) : undefined;
40879
+ const parentDir = isSkillFile ? dirname18(filePath) : undefined;
40818
40880
  const parentRel = isSkillFile ? toPosixPath4(relative9(baseDir, parentDir)) : undefined;
40819
40881
  const parentDirPosix = isSkillFile ? toPosixPath4(parentDir) : undefined;
40820
40882
  return patterns.some((pattern) => {
@@ -40915,7 +40977,7 @@ var init_package_manager_types = __esm(() => {
40915
40977
 
40916
40978
  // src/core/package-manager-resource-files.ts
40917
40979
  import { access as access2, readdir as readdir3, readFile as readFile2, stat as stat3 } from "node:fs/promises";
40918
- import { dirname as dirname18, join as join39, relative as relative10, resolve as resolve10, sep as sep9 } from "node:path";
40980
+ import { dirname as dirname19, join as join40, relative as relative10, resolve as resolve10, sep as sep9 } from "node:path";
40919
40981
  import ignore2 from "ignore";
40920
40982
  async function exists(path12) {
40921
40983
  try {
@@ -40946,7 +41008,7 @@ async function addIgnoreRules(ig, dir, rootDir) {
40946
41008
  const prefix = relativeDir ? `${toPosixPath4(relativeDir)}/` : "";
40947
41009
  for (const filename of IGNORE_FILE_NAMES) {
40948
41010
  try {
40949
- const content = await readFile2(join39(dir, filename), "utf-8");
41011
+ const content = await readFile2(join40(dir, filename), "utf-8");
40950
41012
  const patterns = content.split(/\r?\n/).map((line) => prefixIgnorePattern(line, prefix)).filter((line) => Boolean(line));
40951
41013
  if (patterns.length > 0)
40952
41014
  ig.add(patterns);
@@ -40954,7 +41016,7 @@ async function addIgnoreRules(ig, dir, rootDir) {
40954
41016
  }
40955
41017
  }
40956
41018
  async function getEntryInfo(dir, name, isDirectory, isFileEntry, isSymlink) {
40957
- const fullPath = join39(dir, name);
41019
+ const fullPath = join40(dir, name);
40958
41020
  let isDir = isDirectory;
40959
41021
  let isFile = isFileEntry;
40960
41022
  if (isSymlink) {
@@ -41044,9 +41106,9 @@ async function collectAutoSkillEntries(dir, mode) {
41044
41106
  async function findGitRepoRoot(startDir) {
41045
41107
  let dir = resolve10(startDir);
41046
41108
  while (true) {
41047
- if (await exists(join39(dir, ".git")))
41109
+ if (await exists(join40(dir, ".git")))
41048
41110
  return dir;
41049
- const parent = dirname18(dir);
41111
+ const parent = dirname19(dir);
41050
41112
  if (parent === dir)
41051
41113
  return null;
41052
41114
  dir = parent;
@@ -41058,10 +41120,10 @@ async function collectAncestorAgentsSkillDirs(startDir) {
41058
41120
  const gitRepoRoot = await findGitRepoRoot(resolvedStartDir);
41059
41121
  let dir = resolvedStartDir;
41060
41122
  while (true) {
41061
- skillDirs.push(join39(dir, ".agents", "skills"));
41123
+ skillDirs.push(join40(dir, ".agents", "skills"));
41062
41124
  if (gitRepoRoot && dir === gitRepoRoot)
41063
41125
  break;
41064
- const parent = dirname18(dir);
41126
+ const parent = dirname19(dir);
41065
41127
  if (parent === dir)
41066
41128
  break;
41067
41129
  dir = parent;
@@ -41100,7 +41162,7 @@ async function collectAutoThemeEntries(dir) {
41100
41162
  return collectFlatEntries(dir, ".json");
41101
41163
  }
41102
41164
  async function resolveExtensionEntries(dir) {
41103
- const packageJsonPath = join39(dir, "package.json");
41165
+ const packageJsonPath = join40(dir, "package.json");
41104
41166
  if (await exists(packageJsonPath)) {
41105
41167
  try {
41106
41168
  const manifest = getManifestFromPackageJson(JSON.parse(await readFile2(packageJsonPath, "utf-8")));
@@ -41116,8 +41178,8 @@ async function resolveExtensionEntries(dir) {
41116
41178
  }
41117
41179
  } catch {}
41118
41180
  }
41119
- const indexTs = join39(dir, "index.ts");
41120
- const indexJs = join39(dir, "index.js");
41181
+ const indexTs = join40(dir, "index.ts");
41182
+ const indexJs = join40(dir, "index.js");
41121
41183
  if (await exists(indexTs))
41122
41184
  return [indexTs];
41123
41185
  if (await exists(indexJs))
@@ -41175,7 +41237,7 @@ var init_package_manager_resource_files = __esm(() => {
41175
41237
  });
41176
41238
 
41177
41239
  // src/core/package-manager-auto-resources.ts
41178
- import { dirname as dirname19, join as join40, resolve as resolve11 } from "node:path";
41240
+ import { dirname as dirname20, join as join41, resolve as resolve11 } from "node:path";
41179
41241
  async function collectProjectLocalResources(sourceRoot, accumulator, filter, metadata) {
41180
41242
  let found = false;
41181
41243
  const projectMetadata = { ...metadata, origin: "top-level", borrowedProjectLocal: true };
@@ -41190,14 +41252,14 @@ async function collectProjectLocalResources(sourceRoot, accumulator, filter, met
41190
41252
  };
41191
41253
  for (const configDir of getProjectConfigDirs(sourceRoot)) {
41192
41254
  const configMetadata = { ...projectMetadata, baseDir: configDir };
41193
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), configMetadata, filter?.extensions);
41194
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), configMetadata, filter?.skills);
41195
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), configMetadata, filter?.prompts);
41196
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), configMetadata, filter?.themes);
41197
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), configMetadata, filter?.workflows);
41198
- }
41199
- const agentsSkillsDir = join40(sourceRoot, ".agents", "skills");
41200
- addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: dirname19(agentsSkillsDir) }, filter?.skills);
41255
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), configMetadata, filter?.extensions);
41256
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), configMetadata, filter?.skills);
41257
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), configMetadata, filter?.prompts);
41258
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), configMetadata, filter?.themes);
41259
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), configMetadata, filter?.workflows);
41260
+ }
41261
+ const agentsSkillsDir = join41(sourceRoot, ".agents", "skills");
41262
+ addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: dirname20(agentsSkillsDir) }, filter?.skills);
41201
41263
  return found;
41202
41264
  }
41203
41265
  async function addAutoDiscoveredResources(context, accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir) {
@@ -41224,7 +41286,7 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41224
41286
  };
41225
41287
  const userConfigDirs = getBaseDirsForScope(context, "user");
41226
41288
  const projectConfigDirs = getBaseDirsForScope(context, "project");
41227
- const userAgentsSkillsDir = join40(getHomeDir2(), ".agents", "skills");
41289
+ const userAgentsSkillsDir = join41(getHomeDir2(), ".agents", "skills");
41228
41290
  const projectTrusted = context.settingsManager.isProjectTrusted();
41229
41291
  const projectAgentsSkillDirs = projectTrusted ? (await collectAncestorAgentsSkillDirs(context.cwd)).filter((dir) => resolve11(dir) !== resolve11(userAgentsSkillsDir)) : [];
41230
41292
  const addResources = (resourceType, paths, metadata, overrides, baseDir) => {
@@ -41239,15 +41301,15 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41239
41301
  baseDir: configDir,
41240
41302
  configurationOrigin: index === 0 ? "atomic" : "inherited-pi"
41241
41303
  };
41242
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), metadata, projectOverrides.extensions, configDir);
41243
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), metadata, projectOverrides.skills, configDir);
41244
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), metadata, projectOverrides.prompts, configDir);
41245
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), metadata, projectOverrides.themes, configDir);
41246
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), metadata, projectOverrides.workflows, configDir);
41304
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), metadata, projectOverrides.extensions, configDir);
41305
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), metadata, projectOverrides.skills, configDir);
41306
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), metadata, projectOverrides.prompts, configDir);
41307
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), metadata, projectOverrides.themes, configDir);
41308
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), metadata, projectOverrides.workflows, configDir);
41247
41309
  }
41248
41310
  }
41249
41311
  for (const agentsSkillsDir of projectAgentsSkillDirs) {
41250
- const agentsBaseDir = dirname19(agentsSkillsDir);
41312
+ const agentsBaseDir = dirname20(agentsSkillsDir);
41251
41313
  addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: agentsBaseDir }, projectOverrides.skills, agentsBaseDir);
41252
41314
  }
41253
41315
  for (const [index, configDir] of userConfigDirs.entries()) {
@@ -41256,13 +41318,13 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41256
41318
  baseDir: configDir,
41257
41319
  configurationOrigin: index === 0 ? "atomic" : "inherited-pi"
41258
41320
  };
41259
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), metadata, userOverrides.extensions, configDir);
41260
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), metadata, userOverrides.skills, configDir);
41261
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), metadata, userOverrides.prompts, configDir);
41262
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), metadata, userOverrides.themes, configDir);
41263
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), metadata, userOverrides.workflows, configDir);
41321
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), metadata, userOverrides.extensions, configDir);
41322
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), metadata, userOverrides.skills, configDir);
41323
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), metadata, userOverrides.prompts, configDir);
41324
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), metadata, userOverrides.themes, configDir);
41325
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), metadata, userOverrides.workflows, configDir);
41264
41326
  }
41265
- const userAgentsBaseDir = dirname19(userAgentsSkillsDir);
41327
+ const userAgentsBaseDir = dirname20(userAgentsSkillsDir);
41266
41328
  addResources("skills", await collectAutoSkillEntries(userAgentsSkillsDir, "agents"), { ...userMetadata, baseDir: userAgentsBaseDir }, userOverrides.skills, userAgentsBaseDir);
41267
41329
  }
41268
41330
  var init_package_manager_auto_resources = __esm(() => {
@@ -41431,7 +41493,7 @@ var init_package_manager_resource_collector = __esm(() => {
41431
41493
 
41432
41494
  // src/core/package-manager-resolver.ts
41433
41495
  import { access as access4, stat as stat5 } from "node:fs/promises";
41434
- import { dirname as dirname20, isAbsolute as isAbsolute7, join as join41 } from "node:path";
41496
+ import { dirname as dirname21, isAbsolute as isAbsolute7, join as join42 } from "node:path";
41435
41497
  async function exists3(path12) {
41436
41498
  try {
41437
41499
  await access4(path12);
@@ -41454,7 +41516,7 @@ async function resolvePackages(context, onMissing) {
41454
41516
  const packageSources = dedupePackages(context, allPackages);
41455
41517
  await resolvePackageSources(context, packageSources, accumulator, onMissing, { settingsField: "packages" });
41456
41518
  const globalBaseDir = context.agentDir;
41457
- const projectBaseDir = join41(context.cwd, CONFIG_DIR_NAME);
41519
+ const projectBaseDir = join42(context.cwd, CONFIG_DIR_NAME);
41458
41520
  const globalBaseDirs = getBaseDirsForScope(context, "user");
41459
41521
  const projectBaseDirs = getBaseDirsForScope(context, "project");
41460
41522
  for (const resourceType of ["extensions", "skills", "prompts", "themes", "workflows"]) {
@@ -41589,7 +41651,7 @@ async function resolveLocalExtensionSource(source, accumulator, filter, metadata
41589
41651
  try {
41590
41652
  const stats = await stat5(resolved);
41591
41653
  if (stats.isFile()) {
41592
- addResource(accumulator.extensions, resolved, { ...metadata, baseDir: dirname20(resolved) }, true);
41654
+ addResource(accumulator.extensions, resolved, { ...metadata, baseDir: dirname21(resolved) }, true);
41593
41655
  return;
41594
41656
  }
41595
41657
  if (stats.isDirectory()) {
@@ -41620,7 +41682,7 @@ var init_package_manager_resolver = __esm(() => {
41620
41682
  });
41621
41683
 
41622
41684
  // src/core/package-manager-settings.ts
41623
- import { existsSync as existsSync29 } from "node:fs";
41685
+ import { existsSync as existsSync30 } from "node:fs";
41624
41686
  function addSourceToSettings(context, source, options) {
41625
41687
  const scope = options?.local ? "project" : "user";
41626
41688
  const currentSettings = scope === "project" ? context.settingsManager.getProjectSettings() : context.settingsManager.getGlobalSettings();
@@ -41674,7 +41736,7 @@ function getInstalledPath(context, source, scope) {
41674
41736
  }
41675
41737
  for (const baseDir of getBaseDirsForScope(context, scope)) {
41676
41738
  const path12 = resolvePathFromBase(parsed.path, baseDir);
41677
- if (existsSync29(path12))
41739
+ if (existsSync30(path12))
41678
41740
  return path12;
41679
41741
  }
41680
41742
  return;
@@ -41898,29 +41960,29 @@ var init_package_manager = __esm(() => {
41898
41960
 
41899
41961
  // src/core/footer-data-provider.ts
41900
41962
  import { execFile, spawnSync as spawnSync6 } from "child_process";
41901
- import { existsSync as existsSync30, readFileSync as readFileSync19, statSync as statSync7, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
41902
- import { dirname as dirname21, join as join42, resolve as resolve13 } from "path";
41963
+ import { existsSync as existsSync31, readFileSync as readFileSync20, statSync as statSync7, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
41964
+ import { dirname as dirname22, join as join43, resolve as resolve13 } from "path";
41903
41965
  function findGitPaths(cwd) {
41904
41966
  let dir = cwd;
41905
41967
  while (true) {
41906
- const gitPath = join42(dir, ".git");
41907
- if (existsSync30(gitPath)) {
41968
+ const gitPath = join43(dir, ".git");
41969
+ if (existsSync31(gitPath)) {
41908
41970
  try {
41909
41971
  const stat6 = statSync7(gitPath);
41910
41972
  if (stat6.isFile()) {
41911
- const content = readFileSync19(gitPath, "utf8").trim();
41973
+ const content = readFileSync20(gitPath, "utf8").trim();
41912
41974
  if (content.startsWith("gitdir: ")) {
41913
41975
  const gitDir = resolve13(dir, content.slice(8).trim());
41914
- const headPath = join42(gitDir, "HEAD");
41915
- if (!existsSync30(headPath))
41976
+ const headPath = join43(gitDir, "HEAD");
41977
+ if (!existsSync31(headPath))
41916
41978
  return null;
41917
- const commonDirPath = join42(gitDir, "commondir");
41918
- const commonGitDir = existsSync30(commonDirPath) ? resolve13(gitDir, readFileSync19(commonDirPath, "utf8").trim()) : gitDir;
41979
+ const commonDirPath = join43(gitDir, "commondir");
41980
+ const commonGitDir = existsSync31(commonDirPath) ? resolve13(gitDir, readFileSync20(commonDirPath, "utf8").trim()) : gitDir;
41919
41981
  return { repoDir: dir, commonGitDir, headPath };
41920
41982
  }
41921
41983
  } else if (stat6.isDirectory()) {
41922
- const headPath = join42(gitPath, "HEAD");
41923
- if (!existsSync30(headPath))
41984
+ const headPath = join43(gitPath, "HEAD");
41985
+ if (!existsSync31(headPath))
41924
41986
  return null;
41925
41987
  return { repoDir: dir, commonGitDir: gitPath, headPath };
41926
41988
  }
@@ -41928,7 +41990,7 @@ function findGitPaths(cwd) {
41928
41990
  return null;
41929
41991
  }
41930
41992
  }
41931
- const parent = dirname21(dir);
41993
+ const parent = dirname22(dir);
41932
41994
  if (parent === dir)
41933
41995
  return null;
41934
41996
  dir = parent;
@@ -42112,7 +42174,7 @@ class FooterDataProvider {
42112
42174
  try {
42113
42175
  if (!this.gitPaths)
42114
42176
  return null;
42115
- const content = readFileSync19(this.gitPaths.headPath, "utf8").trim();
42177
+ const content = readFileSync20(this.gitPaths.headPath, "utf8").trim();
42116
42178
  if (content.startsWith("ref: refs/heads/")) {
42117
42179
  const branch = content.slice(16);
42118
42180
  return branch === ".invalid" ? resolveBranchWithGitSync(this.gitPaths.repoDir) ?? "detached" : branch;
@@ -42126,7 +42188,7 @@ class FooterDataProvider {
42126
42188
  try {
42127
42189
  if (!this.gitPaths)
42128
42190
  return null;
42129
- const content = readFileSync19(this.gitPaths.headPath, "utf8").trim();
42191
+ const content = readFileSync20(this.gitPaths.headPath, "utf8").trim();
42130
42192
  if (content.startsWith("ref: refs/heads/")) {
42131
42193
  const branch = content.slice(16);
42132
42194
  return branch === ".invalid" ? await resolveBranchWithGitAsync(this.gitPaths.repoDir) ?? "detached" : branch;
@@ -42197,12 +42259,12 @@ class FooterDataProvider {
42197
42259
  this.scheduleGitWatcherRetry();
42198
42260
  }
42199
42261
  readReftableTablesListFingerprint() {
42200
- if (!this.reftableTablesListPath || !existsSync30(this.reftableTablesListPath)) {
42262
+ if (!this.reftableTablesListPath || !existsSync31(this.reftableTablesListPath)) {
42201
42263
  return null;
42202
42264
  }
42203
42265
  try {
42204
42266
  const stat6 = statSync7(this.reftableTablesListPath);
42205
- const content = readFileSync19(this.reftableTablesListPath, "utf8");
42267
+ const content = readFileSync20(this.reftableTablesListPath, "utf8");
42206
42268
  return `${stat6.size}:${stat6.mtimeMs}:${stat6.ctimeMs}:${content}`;
42207
42269
  } catch {
42208
42270
  return null;
@@ -42229,7 +42291,7 @@ class FooterDataProvider {
42229
42291
  if (!this.gitPaths)
42230
42292
  return;
42231
42293
  const pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);
42232
- this.headWatcher = watchWithErrorHandler(dirname21(this.gitPaths.headPath), (_eventType, filename) => {
42294
+ this.headWatcher = watchWithErrorHandler(dirname22(this.gitPaths.headPath), (_eventType, filename) => {
42233
42295
  if (!filename || filename === "HEAD") {
42234
42296
  this.scheduleRefresh();
42235
42297
  }
@@ -42246,9 +42308,9 @@ class FooterDataProvider {
42246
42308
  if (!this.headWatcher && !this.headWatchFileListener) {
42247
42309
  return;
42248
42310
  }
42249
- const reftableDir = join42(this.gitPaths.commonGitDir, "reftable");
42250
- if (existsSync30(reftableDir)) {
42251
- this.reftableTablesListPath = join42(reftableDir, "tables.list");
42311
+ const reftableDir = join43(this.gitPaths.commonGitDir, "reftable");
42312
+ if (existsSync31(reftableDir)) {
42313
+ this.reftableTablesListPath = join43(reftableDir, "tables.list");
42252
42314
  this.reftableTablesListFingerprint = this.readReftableTablesListFingerprint();
42253
42315
  this.reftableWatcher = watchWithErrorHandler(reftableDir, (_eventType, filename) => {
42254
42316
  this.handleReftableDirectoryEvent(filename);
@@ -42259,7 +42321,7 @@ class FooterDataProvider {
42259
42321
  this.handleGitWatcherError();
42260
42322
  });
42261
42323
  const tablesListPath = this.reftableTablesListPath;
42262
- if (tablesListPath && existsSync30(tablesListPath)) {
42324
+ if (tablesListPath && existsSync31(tablesListPath)) {
42263
42325
  this.reftableTablesListWatcher = watchWithErrorHandler(tablesListPath, () => {
42264
42326
  this.scheduleReftableRefresh();
42265
42327
  }, (error) => {
@@ -42384,8 +42446,8 @@ function deepMergeSettings(base, overrides) {
42384
42446
  }
42385
42447
 
42386
42448
  // src/core/settings-storage.ts
42387
- import { existsSync as existsSync31, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
42388
- import { dirname as dirname22, join as join43 } from "path";
42449
+ import { existsSync as existsSync32, mkdirSync as mkdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync12 } from "fs";
42450
+ import { dirname as dirname23, join as join44 } from "path";
42389
42451
  import lockfile3 from "proper-lockfile";
42390
42452
 
42391
42453
  class FileSettingsStorage {
@@ -42396,18 +42458,18 @@ class FileSettingsStorage {
42396
42458
  constructor(cwd, agentDir, options) {
42397
42459
  const resolvedCwd = resolvePath(cwd);
42398
42460
  const resolvedAgentDir = resolvePath(agentDir);
42399
- this.globalSettingsPath = join43(resolvedAgentDir, "settings.json");
42400
- this.projectSettingsPath = join43(resolvedCwd, CONFIG_DIR_NAME, "settings.json");
42461
+ this.globalSettingsPath = join44(resolvedAgentDir, "settings.json");
42462
+ this.projectSettingsPath = join44(resolvedCwd, CONFIG_DIR_NAME, "settings.json");
42401
42463
  this.globalReadPaths = (options?.globalReadPaths ?? [this.globalSettingsPath]).map((path12) => normalizePath(path12));
42402
42464
  this.projectReadPaths = (options?.projectReadPaths ?? [this.projectSettingsPath]).map((path12) => normalizePath(path12));
42403
42465
  }
42404
42466
  getFieldOrigin(scope, field2) {
42405
42467
  const readPaths = scope === "global" ? this.globalReadPaths : this.projectReadPaths;
42406
42468
  for (const [index, readPath] of readPaths.entries()) {
42407
- if (!existsSync31(readPath))
42469
+ if (!existsSync32(readPath))
42408
42470
  continue;
42409
42471
  try {
42410
- const parsed = parseJsonFileContent(readFileSync20(readPath, "utf-8"));
42472
+ const parsed = parseJsonFileContent(readFileSync21(readPath, "utf-8"));
42411
42473
  if (Object.hasOwn(parsed, field2)) {
42412
42474
  return index === 0 ? "primary" : "legacy";
42413
42475
  }
@@ -42441,9 +42503,9 @@ class FileSettingsStorage {
42441
42503
  let found = false;
42442
42504
  for (let i = readPaths.length - 1;i >= 0; i--) {
42443
42505
  const readPath = readPaths[i];
42444
- if (!existsSync31(readPath))
42506
+ if (!existsSync32(readPath))
42445
42507
  continue;
42446
- const parsed = parseJsonFileContent(readFileSync20(readPath, "utf-8"));
42508
+ const parsed = parseJsonFileContent(readFileSync21(readPath, "utf-8"));
42447
42509
  merged = deepMergeSettings(merged, parsed);
42448
42510
  found = true;
42449
42511
  }
@@ -42452,21 +42514,21 @@ class FileSettingsStorage {
42452
42514
  withLock(scope, fn) {
42453
42515
  const path12 = scope === "global" ? this.globalSettingsPath : this.projectSettingsPath;
42454
42516
  const readPaths = scope === "global" ? this.globalReadPaths : this.projectReadPaths;
42455
- const dir = dirname22(path12);
42517
+ const dir = dirname23(path12);
42456
42518
  let release;
42457
42519
  try {
42458
- const fileExists2 = existsSync31(path12);
42520
+ const fileExists2 = existsSync32(path12);
42459
42521
  if (fileExists2) {
42460
42522
  release = this.acquireLockSyncWithRetry(path12);
42461
42523
  }
42462
42524
  const current = this.readMergedSettings(readPaths);
42463
42525
  const next = fn(current);
42464
42526
  if (next !== undefined) {
42465
- if (!existsSync31(dir)) {
42527
+ if (!existsSync32(dir)) {
42466
42528
  mkdirSync11(dir, { recursive: true });
42467
42529
  }
42468
42530
  if (!release) {
42469
- if (!existsSync31(path12))
42531
+ if (!existsSync32(path12))
42470
42532
  writeFileSync12(path12, "{}", "utf-8");
42471
42533
  release = this.acquireLockSyncWithRetry(path12);
42472
42534
  }
@@ -42506,7 +42568,7 @@ var init_settings_storage = __esm(() => {
42506
42568
  });
42507
42569
 
42508
42570
  // src/core/settings-manager-core.ts
42509
- import { join as join44 } from "path";
42571
+ import { join as join45 } from "path";
42510
42572
 
42511
42573
  class SettingsManager {
42512
42574
  storage;
@@ -42544,7 +42606,7 @@ class SettingsManager {
42544
42606
  }
42545
42607
  static create(cwd, agentDir = getAgentDir(), options = {}) {
42546
42608
  const storage = new FileSettingsStorage(cwd, agentDir, {
42547
- globalReadPaths: agentDir === getAgentDir() ? getAgentConfigPaths("settings.json") : [join44(agentDir, "settings.json")],
42609
+ globalReadPaths: agentDir === getAgentDir() ? getAgentConfigPaths("settings.json") : [join45(agentDir, "settings.json")],
42548
42610
  projectReadPaths: getProjectConfigPaths(cwd, "settings.json")
42549
42611
  });
42550
42612
  return SettingsManager.fromStorage(storage, options);
@@ -44258,14 +44320,14 @@ var init_agent_session_runtime_auth = __esm(() => {
44258
44320
  });
44259
44321
 
44260
44322
  // src/core/session-cwd.ts
44261
- import { existsSync as existsSync32 } from "node:fs";
44323
+ import { existsSync as existsSync33 } from "node:fs";
44262
44324
  function getMissingSessionCwdIssue(sessionManager, fallbackCwd) {
44263
44325
  const sessionFile = sessionManager.getSessionFile();
44264
44326
  if (!sessionFile) {
44265
44327
  return;
44266
44328
  }
44267
44329
  const sessionCwd = sessionManager.getCwd();
44268
- if (!sessionCwd || existsSync32(sessionCwd)) {
44330
+ if (!sessionCwd || existsSync33(sessionCwd)) {
44269
44331
  return;
44270
44332
  }
44271
44333
  return {
@@ -44317,8 +44379,8 @@ var init_agent_session_services = __esm(() => {
44317
44379
  });
44318
44380
 
44319
44381
  // src/core/agent-session-runtime.ts
44320
- import { copyFileSync, existsSync as existsSync33, mkdirSync as mkdirSync12 } from "node:fs";
44321
- import { basename as basename10, join as join45, resolve as resolve14 } from "node:path";
44382
+ import { copyFileSync, existsSync as existsSync34, mkdirSync as mkdirSync12 } from "node:fs";
44383
+ import { basename as basename10, join as join46, resolve as resolve14 } from "node:path";
44322
44384
  import { modelsAreEqual as modelsAreEqual5 } from "@bastani/pi-ai/compat";
44323
44385
  function extractUserMessageText(content) {
44324
44386
  if (typeof content === "string") {
@@ -44534,7 +44596,7 @@ class AgentSessionRuntime {
44534
44596
  await this.finishSessionReplacement(options?.withSession);
44535
44597
  return { cancelled: false, selectedText };
44536
44598
  }
44537
- if (!existsSync33(currentSessionFile)) {
44599
+ if (!existsSync34(currentSessionFile)) {
44538
44600
  throw new Error("This session has not been saved yet. Wait for the first assistant response before cloning or forking it.");
44539
44601
  }
44540
44602
  const sessionManager2 = SessionManager.open(currentSessionFile, sessionDir);
@@ -44570,14 +44632,14 @@ class AgentSessionRuntime {
44570
44632
  }
44571
44633
  async importFromJsonl(inputPath, cwdOverride) {
44572
44634
  const resolvedPath = resolvePath(inputPath);
44573
- if (!existsSync33(resolvedPath)) {
44635
+ if (!existsSync34(resolvedPath)) {
44574
44636
  throw new SessionImportFileNotFoundError(resolvedPath);
44575
44637
  }
44576
44638
  const sessionDir = this.session.sessionManager.getSessionDir();
44577
- if (!existsSync33(sessionDir)) {
44639
+ if (!existsSync34(sessionDir)) {
44578
44640
  mkdirSync12(sessionDir, { recursive: true });
44579
44641
  }
44580
- const destinationPath = join45(sessionDir, basename10(resolvedPath));
44642
+ const destinationPath = join46(sessionDir, basename10(resolvedPath));
44581
44643
  const beforeResult = await this.emitBeforeSwitch("resume", destinationPath);
44582
44644
  if (beforeResult.cancelled) {
44583
44645
  return beforeResult;
@@ -56392,9 +56454,9 @@ var init_result_renderers = __esm(() => {
56392
56454
  // dist/builtin/web-access/chrome-cookies.ts
56393
56455
  import { execFile as execFile2 } from "node:child_process";
56394
56456
  import { pbkdf2Sync, createDecipheriv } from "node:crypto";
56395
- import { copyFileSync as copyFileSync2, existsSync as existsSync34, mkdtempSync as mkdtempSync2, rmSync as rmSync7 } from "node:fs";
56457
+ import { copyFileSync as copyFileSync2, existsSync as existsSync35, mkdtempSync as mkdtempSync2, rmSync as rmSync7 } from "node:fs";
56396
56458
  import { tmpdir as tmpdir6, homedir as homedir7, platform as platform3 } from "node:os";
56397
- import { join as join46 } from "node:path";
56459
+ import { join as join47 } from "node:path";
56398
56460
  async function getGoogleCookies(options) {
56399
56461
  const currentPlatform = platform3();
56400
56462
  const configs = currentPlatform === "darwin" ? MACOS_BROWSER_CONFIGS : currentPlatform === "linux" ? LINUX_BROWSER_CONFIGS : [];
@@ -56404,8 +56466,8 @@ async function getGoogleCookies(options) {
56404
56466
  const profile = options?.profile ?? "Default";
56405
56467
  const hosts = GOOGLE_ORIGINS.map((origin) => new URL(origin).hostname);
56406
56468
  for (const config of configs) {
56407
- const cookiesPath = join46(homedir7(), config.baseDir, profile, "Cookies");
56408
- if (!existsSync34(cookiesPath))
56469
+ const cookiesPath = join47(homedir7(), config.baseDir, profile, "Cookies");
56470
+ if (!existsSync35(cookiesPath))
56409
56471
  continue;
56410
56472
  const password = await readBrowserPassword(config, currentPlatform);
56411
56473
  if (!password) {
@@ -56413,9 +56475,9 @@ async function getGoogleCookies(options) {
56413
56475
  continue;
56414
56476
  }
56415
56477
  const key = pbkdf2Sync(password, "saltysalt", currentPlatform === "darwin" ? 1003 : 1, 16, "sha1");
56416
- const tempDir = mkdtempSync2(join46(tmpdir6(), "pi-chrome-cookies-"));
56478
+ const tempDir = mkdtempSync2(join47(tmpdir6(), "pi-chrome-cookies-"));
56417
56479
  try {
56418
- const tempDb = join46(tempDir, "Cookies");
56480
+ const tempDb = join47(tempDir, "Cookies");
56419
56481
  copyFileSync2(cookiesPath, tempDb);
56420
56482
  copySidecar(cookiesPath, tempDb, "-wal");
56421
56483
  copySidecar(cookiesPath, tempDb, "-shm");
@@ -56614,7 +56676,7 @@ function expandHosts(host) {
56614
56676
  }
56615
56677
  function copySidecar(srcDb, targetDb, suffix) {
56616
56678
  const sidecar = `${srcDb}${suffix}`;
56617
- if (!existsSync34(sidecar))
56679
+ if (!existsSync35(sidecar))
56618
56680
  return;
56619
56681
  try {
56620
56682
  copyFileSync2(sidecar, `${targetDb}${suffix}`);
@@ -56675,9 +56737,9 @@ var init_chrome_cookies = __esm(() => {
56675
56737
  });
56676
56738
 
56677
56739
  // dist/builtin/web-access/config-paths.ts
56678
- import { existsSync as existsSync35 } from "node:fs";
56740
+ import { existsSync as existsSync36 } from "node:fs";
56679
56741
  function findReadableConfigPath(paths = WEB_SEARCH_CONFIG_PATHS) {
56680
- return paths.find((path13) => existsSync35(path13)) ?? paths[0] ?? WEB_SEARCH_CONFIG_PATH;
56742
+ return paths.find((path13) => existsSync36(path13)) ?? paths[0] ?? WEB_SEARCH_CONFIG_PATH;
56681
56743
  }
56682
56744
  var WEB_SEARCH_CONFIG_PATHS, WEB_SEARCH_CONFIG_PATH, EXA_USAGE_PATHS, EXA_USAGE_PATH;
56683
56745
  var init_config_paths = __esm(() => {
@@ -56689,7 +56751,7 @@ var init_config_paths = __esm(() => {
56689
56751
  });
56690
56752
 
56691
56753
  // dist/builtin/web-access/gemini-web-config.ts
56692
- import { existsSync as existsSync36, readFileSync as readFileSync22 } from "node:fs";
56754
+ import { existsSync as existsSync37, readFileSync as readFileSync23 } from "node:fs";
56693
56755
  function normalizeChromeProfile(value) {
56694
56756
  if (typeof value !== "string")
56695
56757
  return;
@@ -56699,11 +56761,11 @@ function normalizeChromeProfile(value) {
56699
56761
  function loadConfig2() {
56700
56762
  if (cachedConfig)
56701
56763
  return cachedConfig;
56702
- if (!existsSync36(CONFIG_PATH2)) {
56764
+ if (!existsSync37(CONFIG_PATH2)) {
56703
56765
  cachedConfig = {};
56704
56766
  return cachedConfig;
56705
56767
  }
56706
- const rawText = readFileSync22(CONFIG_PATH2, "utf-8");
56768
+ const rawText = readFileSync23(CONFIG_PATH2, "utf-8");
56707
56769
  let raw;
56708
56770
  try {
56709
56771
  raw = JSON.parse(rawText);
@@ -56735,7 +56797,7 @@ var init_gemini_web_config = __esm(() => {
56735
56797
  });
56736
56798
 
56737
56799
  // dist/builtin/web-access/gemini-web.ts
56738
- import { readFileSync as readFileSync23 } from "node:fs";
56800
+ import { readFileSync as readFileSync24 } from "node:fs";
56739
56801
  import { basename as basename11 } from "node:path";
56740
56802
  async function isGeminiWebAvailable(chromeProfile) {
56741
56803
  if (!isBrowserCookieAccessAllowed())
@@ -56924,7 +56986,7 @@ function decodeEmailEscapes(value) {
56924
56986
  return value.replace(/\\u0040/gi, "@").replace(/\\x40/gi, "@").replace(/&#64;/gi, "@").replace(/&commat;/gi, "@").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
56925
56987
  }
56926
56988
  async function uploadFile(filePath, cookieHeader, signal) {
56927
- const data = readFileSync23(filePath);
56989
+ const data = readFileSync24(filePath);
56928
56990
  const fileName = basename11(filePath);
56929
56991
  const boundary = "----FormBoundary" + Math.random().toString(36).slice(2);
56930
56992
  const header = `--${boundary}\r
@@ -57345,17 +57407,17 @@ var init_exa_mcp = __esm(() => {
57345
57407
  });
57346
57408
 
57347
57409
  // dist/builtin/web-access/exa.ts
57348
- import { existsSync as existsSync37, mkdirSync as mkdirSync13, readFileSync as readFileSync24, writeFileSync as writeFileSync13 } from "node:fs";
57410
+ import { existsSync as existsSync38, mkdirSync as mkdirSync13, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "node:fs";
57349
57411
  import { homedir as homedir8 } from "node:os";
57350
- import { join as join47 } from "node:path";
57412
+ import { join as join48 } from "node:path";
57351
57413
  function loadConfig3() {
57352
57414
  if (cachedConfig2)
57353
57415
  return cachedConfig2;
57354
- if (!existsSync37(CONFIG_PATH3)) {
57416
+ if (!existsSync38(CONFIG_PATH3)) {
57355
57417
  cachedConfig2 = {};
57356
57418
  return cachedConfig2;
57357
57419
  }
57358
- const raw = readFileSync24(CONFIG_PATH3, "utf-8");
57420
+ const raw = readFileSync25(CONFIG_PATH3, "utf-8");
57359
57421
  try {
57360
57422
  cachedConfig2 = JSON.parse(raw);
57361
57423
  return cachedConfig2;
@@ -57388,9 +57450,9 @@ function normalizeUsage(raw) {
57388
57450
  return { month: parsedMonth, count: Math.max(0, Math.floor(parsedCount)) };
57389
57451
  }
57390
57452
  function readUsage() {
57391
- if (!existsSync37(USAGE_PATH))
57453
+ if (!existsSync38(USAGE_PATH))
57392
57454
  return { month: getCurrentMonth(), count: 0 };
57393
- const raw = readFileSync24(USAGE_PATH, "utf-8");
57455
+ const raw = readFileSync25(USAGE_PATH, "utf-8");
57394
57456
  try {
57395
57457
  return normalizeUsage(JSON.parse(raw));
57396
57458
  } catch (err) {
@@ -57399,8 +57461,8 @@ function readUsage() {
57399
57461
  }
57400
57462
  }
57401
57463
  function writeUsage(usage) {
57402
- const dir = join47(homedir8(), CONFIG_DIR_NAME);
57403
- if (!existsSync37(dir))
57464
+ const dir = join48(homedir8(), CONFIG_DIR_NAME);
57465
+ if (!existsSync38(dir))
57404
57466
  mkdirSync13(dir, { recursive: true });
57405
57467
  writeFileSync13(USAGE_PATH, JSON.stringify(usage, null, 2) + `
57406
57468
  `);
@@ -57597,15 +57659,15 @@ var init_exa = __esm(() => {
57597
57659
  });
57598
57660
 
57599
57661
  // dist/builtin/web-access/gemini-api.ts
57600
- import { existsSync as existsSync38, readFileSync as readFileSync25 } from "node:fs";
57662
+ import { existsSync as existsSync39, readFileSync as readFileSync26 } from "node:fs";
57601
57663
  function loadConfig4() {
57602
57664
  if (cachedConfig3)
57603
57665
  return cachedConfig3;
57604
- if (!existsSync38(CONFIG_PATH4)) {
57666
+ if (!existsSync39(CONFIG_PATH4)) {
57605
57667
  cachedConfig3 = {};
57606
57668
  return cachedConfig3;
57607
57669
  }
57608
- const raw = readFileSync25(CONFIG_PATH4, "utf-8");
57670
+ const raw = readFileSync26(CONFIG_PATH4, "utf-8");
57609
57671
  try {
57610
57672
  cachedConfig3 = JSON.parse(raw);
57611
57673
  return cachedConfig3;
@@ -57674,15 +57736,15 @@ var init_gemini_api = __esm(() => {
57674
57736
  });
57675
57737
 
57676
57738
  // dist/builtin/web-access/perplexity.ts
57677
- import { existsSync as existsSync39, readFileSync as readFileSync26 } from "node:fs";
57739
+ import { existsSync as existsSync40, readFileSync as readFileSync27 } from "node:fs";
57678
57740
  function loadConfig5() {
57679
57741
  if (cachedConfig4)
57680
57742
  return cachedConfig4;
57681
- if (!existsSync39(CONFIG_PATH5)) {
57743
+ if (!existsSync40(CONFIG_PATH5)) {
57682
57744
  cachedConfig4 = {};
57683
57745
  return cachedConfig4;
57684
57746
  }
57685
- const content = readFileSync26(CONFIG_PATH5, "utf-8");
57747
+ const content = readFileSync27(CONFIG_PATH5, "utf-8");
57686
57748
  try {
57687
57749
  cachedConfig4 = JSON.parse(content);
57688
57750
  return cachedConfig4;
@@ -57830,13 +57892,13 @@ function resolveWorkflow(input2, hasUI) {
57830
57892
  }
57831
57893
 
57832
57894
  // dist/builtin/web-access/web-search-config.ts
57833
- import { existsSync as existsSync40, mkdirSync as mkdirSync14, readFileSync as readFileSync27, writeFileSync as writeFileSync14 } from "node:fs";
57895
+ import { existsSync as existsSync41, mkdirSync as mkdirSync14, readFileSync as readFileSync28, writeFileSync as writeFileSync14 } from "node:fs";
57834
57896
  import { homedir as homedir9 } from "node:os";
57835
- import { join as join48 } from "node:path";
57897
+ import { join as join49 } from "node:path";
57836
57898
  function loadConfig6() {
57837
- if (!existsSync40(WEB_SEARCH_CONFIG_READ_PATH))
57899
+ if (!existsSync41(WEB_SEARCH_CONFIG_READ_PATH))
57838
57900
  return {};
57839
- const raw = readFileSync27(WEB_SEARCH_CONFIG_READ_PATH, "utf-8");
57901
+ const raw = readFileSync28(WEB_SEARCH_CONFIG_READ_PATH, "utf-8");
57840
57902
  try {
57841
57903
  return JSON.parse(raw);
57842
57904
  } catch (err) {
@@ -57847,8 +57909,8 @@ function loadConfig6() {
57847
57909
  function saveConfig(updates) {
57848
57910
  let config = {};
57849
57911
  const existingConfigPath = findReadableConfigPath();
57850
- if (existsSync40(existingConfigPath)) {
57851
- const raw = readFileSync27(existingConfigPath, "utf-8");
57912
+ if (existsSync41(existingConfigPath)) {
57913
+ const raw = readFileSync28(existingConfigPath, "utf-8");
57852
57914
  try {
57853
57915
  config = JSON.parse(raw);
57854
57916
  } catch (err) {
@@ -57857,8 +57919,8 @@ function saveConfig(updates) {
57857
57919
  }
57858
57920
  }
57859
57921
  Object.assign(config, updates);
57860
- const dir = join48(homedir9(), CONFIG_DIR_NAME);
57861
- if (!existsSync40(dir))
57922
+ const dir = join49(homedir9(), CONFIG_DIR_NAME);
57923
+ if (!existsSync41(dir))
57862
57924
  mkdirSync14(dir, { recursive: true });
57863
57925
  writeFileSync14(WEB_SEARCH_CONFIG_PATH2, JSON.stringify(config, null, 2) + `
57864
57926
  `);
@@ -57958,7 +58020,7 @@ var init_web_search_config = __esm(() => {
57958
58020
  init_gemini_api();
57959
58021
  init_gemini_web();
57960
58022
  init_perplexity();
57961
- WEB_SEARCH_CONFIG_PATH2 = getUserConfigPaths("web-search.json")[0] ?? join48(homedir9(), CONFIG_DIR_NAME, "web-search.json");
58023
+ WEB_SEARCH_CONFIG_PATH2 = getUserConfigPaths("web-search.json")[0] ?? join49(homedir9(), CONFIG_DIR_NAME, "web-search.json");
57962
58024
  WEB_SEARCH_CONFIG_READ_PATH = findReadableConfigPath();
57963
58025
  DEFAULT_SHORTCUTS = { curate: "ctrl+shift+s", activity: "ctrl+shift+w" };
57964
58026
  });
@@ -58315,7 +58377,7 @@ function extractRSCContent(html) {
58315
58377
  // dist/builtin/web-access/pdf-extract.ts
58316
58378
  import { getDocumentProxy } from "unpdf";
58317
58379
  import { writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
58318
- import { join as join49, basename as basename12 } from "node:path";
58380
+ import { join as join50, basename as basename12 } from "node:path";
58319
58381
  import { homedir as homedir10 } from "node:os";
58320
58382
  async function extractPDFToMarkdown(buffer, url, options = {}) {
58321
58383
  const {
@@ -58373,7 +58435,7 @@ async function extractPDFToMarkdown(buffer, url, options = {}) {
58373
58435
  const content = lines.join(`
58374
58436
  `);
58375
58437
  const outputFilename = filename || sanitizeFilename(title) + ".md";
58376
- const outputPath = join49(outputDir, outputFilename);
58438
+ const outputPath = join50(outputDir, outputFilename);
58377
58439
  await mkdir2(outputDir, { recursive: true });
58378
58440
  await writeFile2(outputPath, content, "utf-8");
58379
58441
  return {
@@ -58416,7 +58478,7 @@ function isPDF(url, contentType) {
58416
58478
  }
58417
58479
  var DEFAULT_MAX_PAGES = 100, DEFAULT_OUTPUT_DIR;
58418
58480
  var init_pdf_extract = __esm(() => {
58419
- DEFAULT_OUTPUT_DIR = join49(homedir10(), "Downloads");
58481
+ DEFAULT_OUTPUT_DIR = join50(homedir10(), "Downloads");
58420
58482
  });
58421
58483
 
58422
58484
  // dist/builtin/web-access/flat-string.ts
@@ -58591,7 +58653,7 @@ var init_github_api = __esm(() => {
58591
58653
  });
58592
58654
 
58593
58655
  // dist/builtin/web-access/github-config.ts
58594
- import { existsSync as existsSync41, readFileSync as readFileSync28 } from "node:fs";
58656
+ import { existsSync as existsSync42, readFileSync as readFileSync29 } from "node:fs";
58595
58657
  function normalizeEnabled(value, fallback) {
58596
58658
  return typeof value === "boolean" ? value : fallback;
58597
58659
  }
@@ -58615,11 +58677,11 @@ function loadGitHubConfig() {
58615
58677
  cloneTimeoutSeconds: 30,
58616
58678
  clonePath: "/tmp/atomic-github-repos"
58617
58679
  };
58618
- if (!existsSync41(CONFIG_PATH6)) {
58680
+ if (!existsSync42(CONFIG_PATH6)) {
58619
58681
  cachedConfig5 = defaults;
58620
58682
  return cachedConfig5;
58621
58683
  }
58622
- const rawText = readFileSync28(CONFIG_PATH6, "utf-8");
58684
+ const rawText = readFileSync29(CONFIG_PATH6, "utf-8");
58623
58685
  let raw;
58624
58686
  try {
58625
58687
  raw = JSON.parse(rawText);
@@ -58801,15 +58863,15 @@ var init_github_config = __esm(() => {
58801
58863
  });
58802
58864
 
58803
58865
  // dist/builtin/web-access/github-extract.ts
58804
- import { existsSync as existsSync42, readFileSync as readFileSync29, rmSync as rmSync8, statSync as statSync8, readdirSync as readdirSync8, openSync as openSync4, readSync as readSync2, closeSync as closeSync4, realpathSync as realpathSync5 } from "node:fs";
58866
+ import { existsSync as existsSync43, readFileSync as readFileSync30, rmSync as rmSync8, statSync as statSync8, readdirSync as readdirSync8, openSync as openSync4, readSync as readSync2, closeSync as closeSync4, realpathSync as realpathSync5 } from "node:fs";
58805
58867
  import { execFile as execFile4 } from "node:child_process";
58806
- import { extname, join as join50, resolve as resolvePath7, sep as pathSep } from "node:path";
58868
+ import { extname, join as join51, resolve as resolvePath7, sep as pathSep } from "node:path";
58807
58869
  function cacheKey2(owner, repo, ref) {
58808
58870
  return ref ? `${owner}/${repo}@${ref}` : `${owner}/${repo}`;
58809
58871
  }
58810
58872
  function cloneDir(config, owner, repo, ref) {
58811
58873
  const dirName = ref ? `${repo}@${ref}` : repo;
58812
- return join50(config.clonePath, owner, dirName);
58874
+ return join51(config.clonePath, owner, dirName);
58813
58875
  }
58814
58876
  function execClone(args, localPath, timeoutMs, signal) {
58815
58877
  return new Promise((resolve15) => {
@@ -58890,7 +58952,7 @@ function resolveWithinRepo(rootPath, relativePath) {
58890
58952
  if (!candidate.startsWith(rootPrefix))
58891
58953
  return null;
58892
58954
  }
58893
- if (!existsSync42(candidate))
58955
+ if (!existsSync43(candidate))
58894
58956
  return candidate;
58895
58957
  try {
58896
58958
  const realRoot = realpathSync5(normalizedRoot);
@@ -58905,7 +58967,7 @@ function resolveWithinRepo(rootPath, relativePath) {
58905
58967
  }
58906
58968
  function readTextFile(path13) {
58907
58969
  try {
58908
- return readFileSync29(path13, "utf-8");
58970
+ return readFileSync30(path13, "utf-8");
58909
58971
  } catch {
58910
58972
  return null;
58911
58973
  }
@@ -58994,10 +59056,10 @@ function buildDirListing(rootPath, subPath) {
58994
59056
  function readReadme(localPath) {
58995
59057
  const candidates = ["README.md", "readme.md", "README", "README.txt", "README.rst"];
58996
59058
  for (const name of candidates) {
58997
- const readmePath = join50(localPath, name);
58998
- if (existsSync42(readmePath)) {
59059
+ const readmePath = join51(localPath, name);
59060
+ if (existsSync43(readmePath)) {
58999
59061
  try {
59000
- const content = readFileSync29(readmePath, "utf-8");
59062
+ const content = readFileSync30(readmePath, "utf-8");
59001
59063
  return content.length > 8192 ? flattenTruncatedString(content.slice(0, 8192) + `
59002
59064
 
59003
59065
  [README truncated at 8K chars]`) : content;
@@ -59029,7 +59091,7 @@ function generateContent(localPath, info) {
59029
59091
  if (info.type === "tree") {
59030
59092
  const dirPath = info.path || "";
59031
59093
  const fullDirPath = resolveWithinRepo(localPath, dirPath);
59032
- if (!fullDirPath || !existsSync42(fullDirPath)) {
59094
+ if (!fullDirPath || !existsSync43(fullDirPath)) {
59033
59095
  lines.push(`Path \`${dirPath}\` not found in clone. Showing repository root instead.`);
59034
59096
  lines.push("");
59035
59097
  lines.push("## Structure");
@@ -59046,7 +59108,7 @@ function generateContent(localPath, info) {
59046
59108
  if (info.type === "blob") {
59047
59109
  const filePath = info.path || "";
59048
59110
  const fullFilePath = resolveWithinRepo(localPath, filePath);
59049
- if (!fullFilePath || !existsSync42(fullFilePath)) {
59111
+ if (!fullFilePath || !existsSync43(fullFilePath)) {
59050
59112
  lines.push(`Path \`${filePath}\` not found in clone. Showing repository root instead.`);
59051
59113
  lines.push("");
59052
59114
  lines.push("## Structure");
@@ -59326,7 +59388,7 @@ var init_subprocess = __esm(() => {
59326
59388
  });
59327
59389
 
59328
59390
  // dist/builtin/web-access/youtube-extract.ts
59329
- import { existsSync as existsSync43, readFileSync as readFileSync30 } from "node:fs";
59391
+ import { existsSync as existsSync44, readFileSync as readFileSync31 } from "node:fs";
59330
59392
  function shouldRethrow(err) {
59331
59393
  const message = err instanceof Error ? err.message : String(err);
59332
59394
  return message.startsWith("Failed to parse ");
@@ -59343,11 +59405,11 @@ function normalizeEnabled2(value, fallback) {
59343
59405
  function loadYouTubeConfig() {
59344
59406
  if (cachedConfig6)
59345
59407
  return cachedConfig6;
59346
- if (!existsSync43(CONFIG_PATH7)) {
59408
+ if (!existsSync44(CONFIG_PATH7)) {
59347
59409
  cachedConfig6 = { ...defaults };
59348
59410
  return cachedConfig6;
59349
59411
  }
59350
- const rawText = readFileSync30(CONFIG_PATH7, "utf-8");
59412
+ const rawText = readFileSync31(CONFIG_PATH7, "utf-8");
59351
59413
  let raw;
59352
59414
  try {
59353
59415
  raw = JSON.parse(rawText);
@@ -59689,9 +59751,9 @@ var init_gemini_url_context = __esm(() => {
59689
59751
  });
59690
59752
 
59691
59753
  // dist/builtin/web-access/video-extract.ts
59692
- import { existsSync as existsSync44, readFileSync as readFileSync31, readdirSync as readdirSync9, statSync as statSync9 } from "node:fs";
59754
+ import { existsSync as existsSync45, readFileSync as readFileSync32, readdirSync as readdirSync9, statSync as statSync9 } from "node:fs";
59693
59755
  import { readFile as readFile4 } from "node:fs/promises";
59694
- import { resolve as resolve15, extname as extname2, basename as basename13, join as join51, dirname as dirname23 } from "node:path";
59756
+ import { resolve as resolve15, extname as extname2, basename as basename13, join as join52, dirname as dirname24 } from "node:path";
59695
59757
  function shouldRethrow3(err) {
59696
59758
  const message = err instanceof Error ? err.message : String(err);
59697
59759
  return message.startsWith("Failed to parse ");
@@ -59713,11 +59775,11 @@ function normalizeMaxSizeMB(value, fallback) {
59713
59775
  function loadVideoConfig() {
59714
59776
  if (cachedVideoConfig)
59715
59777
  return cachedVideoConfig;
59716
- if (!existsSync44(CONFIG_PATH8)) {
59778
+ if (!existsSync45(CONFIG_PATH8)) {
59717
59779
  cachedVideoConfig = { ...VIDEO_CONFIG_DEFAULTS };
59718
59780
  return cachedVideoConfig;
59719
59781
  }
59720
- const rawText = readFileSync31(CONFIG_PATH8, "utf-8");
59782
+ const rawText = readFileSync32(CONFIG_PATH8, "utf-8");
59721
59783
  let raw;
59722
59784
  try {
59723
59785
  raw = JSON.parse(rawText);
@@ -59770,16 +59832,16 @@ function isVideoFile(input2) {
59770
59832
  }
59771
59833
  function resolveFilePath(filePath) {
59772
59834
  const absolutePath = resolve15(filePath);
59773
- if (existsSync44(absolutePath))
59835
+ if (existsSync45(absolutePath))
59774
59836
  return absolutePath;
59775
- const dir = dirname23(absolutePath);
59837
+ const dir = dirname24(absolutePath);
59776
59838
  const base = basename13(absolutePath);
59777
- if (!existsSync44(dir))
59839
+ if (!existsSync45(dir))
59778
59840
  return null;
59779
59841
  try {
59780
59842
  const normalizedBase = normalizeSpaces(base);
59781
59843
  const match = readdirSync9(dir).find((f) => normalizeSpaces(f) === normalizedBase);
59782
- return match ? join51(dir, match) : null;
59844
+ return match ? join52(dir, match) : null;
59783
59845
  } catch {
59784
59846
  return null;
59785
59847
  }
@@ -65024,15 +65086,15 @@ var init_curator_server = __esm(() => {
65024
65086
  });
65025
65087
 
65026
65088
  // dist/builtin/web-access/gemini-search.ts
65027
- import { existsSync as existsSync45, readFileSync as readFileSync32 } from "node:fs";
65089
+ import { existsSync as existsSync46, readFileSync as readFileSync33 } from "node:fs";
65028
65090
  function getSearchConfig() {
65029
65091
  if (cachedSearchConfig)
65030
65092
  return cachedSearchConfig;
65031
- if (!existsSync45(CONFIG_PATH9)) {
65093
+ if (!existsSync46(CONFIG_PATH9)) {
65032
65094
  cachedSearchConfig = { searchProvider: "auto", searchModel: undefined };
65033
65095
  return cachedSearchConfig;
65034
65096
  }
65035
- const rawText = readFileSync32(CONFIG_PATH9, "utf-8");
65097
+ const rawText = readFileSync33(CONFIG_PATH9, "utf-8");
65036
65098
  let raw;
65037
65099
  try {
65038
65100
  raw = JSON.parse(rawText);
@@ -65839,10 +65901,10 @@ var init_web_search_summary = __esm(() => {
65839
65901
  });
65840
65902
 
65841
65903
  // dist/builtin/web-access/web-search-browser.ts
65842
- import { existsSync as existsSync46 } from "node:fs";
65904
+ import { existsSync as existsSync47 } from "node:fs";
65843
65905
  import { createRequire as createRequire7 } from "node:module";
65844
65906
  import { platform as platform4 } from "node:os";
65845
- import { join as join52 } from "node:path";
65907
+ import { join as join53 } from "node:path";
65846
65908
  async function openInBrowser(pi, url) {
65847
65909
  const plat = platform4();
65848
65910
  const result = plat === "darwin" ? await pi.exec("open", [url]) : plat === "win32" ? await pi.exec("cmd", ["/c", "start", "", url]) : await pi.exec("xdg-open", [url]);
@@ -65860,8 +65922,8 @@ async function findGlimpseMjs() {
65860
65922
  timeoutMs: 5000,
65861
65923
  maxStdoutBytes: 64 * 1024
65862
65924
  });
65863
- const entry = join52(stdout.toString("utf8").trim(), "glimpseui", "src", "glimpse.mjs");
65864
- if (existsSync46(entry))
65925
+ const entry = join53(stdout.toString("utf8").trim(), "glimpseui", "src", "glimpse.mjs");
65926
+ if (existsSync47(entry))
65865
65927
  return entry;
65866
65928
  } catch {}
65867
65929
  return null;
@@ -67013,9 +67075,9 @@ var init_index_heavy = __esm(() => {
67013
67075
 
67014
67076
  // dist/builtin/web-access/index.ts
67015
67077
  init_result_renderers();
67016
- import { existsSync as existsSync47, readFileSync as readFileSync33 } from "node:fs";
67078
+ import { existsSync as existsSync48, readFileSync as readFileSync34 } from "node:fs";
67017
67079
  import { homedir as homedir11 } from "node:os";
67018
- import { join as join53 } from "node:path";
67080
+ import { join as join54 } from "node:path";
67019
67081
  import { Text as Text46 } from "@earendil-works/pi-tui";
67020
67082
  import { Type as Type15 } from "typebox";
67021
67083
 
@@ -67139,11 +67201,11 @@ function renderHeavyToolResult(loadedHeavy, name, args) {
67139
67201
  }
67140
67202
  function getInitialShortcutConfig() {
67141
67203
  const defaults2 = { curate: "ctrl+shift+s", activity: "ctrl+shift+w" };
67142
- for (const configPath of [join53(homedir11(), ".atomic", "web-search.json"), join53(homedir11(), ".pi", "web-search.json")]) {
67204
+ for (const configPath of [join54(homedir11(), ".atomic", "web-search.json"), join54(homedir11(), ".pi", "web-search.json")]) {
67143
67205
  try {
67144
- if (!existsSync47(configPath))
67206
+ if (!existsSync48(configPath))
67145
67207
  continue;
67146
- const parsed = JSON.parse(readFileSync33(configPath, "utf8"));
67208
+ const parsed = JSON.parse(readFileSync34(configPath, "utf8"));
67147
67209
  return {
67148
67210
  curate: parsed.shortcuts?.curate?.trim() || defaults2.curate,
67149
67211
  activity: parsed.shortcuts?.activity?.trim() || defaults2.activity