@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,43 +564,44 @@ function getAgentDirs() {
481
564
  return legacy === primary ? [primary] : [primary, legacy];
482
565
  }
483
566
  function getProjectConfigDirs(cwd) {
484
- return CONFIG_DIR_NAMES.map((name) => join3(cwd, name));
567
+ return CONFIG_DIR_NAMES.map((name) => join4(cwd, name));
485
568
  }
486
569
  function getAgentConfigPaths(...segments) {
487
- return getAgentDirs().map((dir) => join3(dir, ...segments));
570
+ return getAgentDirs().map((dir) => join4(dir, ...segments));
488
571
  }
489
572
  function getProjectConfigPaths(cwd, ...segments) {
490
- return getProjectConfigDirs(cwd).map((dir) => join3(dir, ...segments));
573
+ return getProjectConfigDirs(cwd).map((dir) => join4(dir, ...segments));
491
574
  }
492
575
  function getCustomThemesDir() {
493
- return join3(getAgentDir(), "themes");
576
+ return join4(getAgentDir(), "themes");
494
577
  }
495
578
  function getAuthPath() {
496
- return join3(getAgentDir(), "auth.json");
579
+ return join4(getAgentDir(), "auth.json");
497
580
  }
498
581
  function getBinDir() {
499
- return join3(getAgentDir(), "bin");
582
+ return join4(getAgentDir(), "bin");
500
583
  }
501
584
  function getSessionsDir() {
502
- return join3(getAgentDir(), "sessions");
585
+ return join4(getAgentDir(), "sessions");
503
586
  }
504
587
  function getDebugLogPath() {
505
- return join3(getAgentDir(), `${APP_NAME}-debug.log`);
588
+ return join4(getAgentDir(), `${APP_NAME}-debug.log`);
506
589
  }
507
590
  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/";
508
591
  var init_config = __esm(() => {
592
+ init_config_package_identity();
509
593
  init_paths();
510
594
  init_split_launcher();
511
595
  init_config_self_update();
512
596
  __filename2 = moduleFileFromMetaUrl(import.meta.url, "app.js");
513
- __dirname2 = dirname2(__filename2);
597
+ __dirname2 = dirname3(__filename2);
514
598
  bunFsMarkers = ["$bunfs", "~BUN", "%7EBUN"];
515
599
  isBunBinary = isSplitLauncherRuntime() || [import.meta.url, process.argv[1] ?? ""].some((candidate) => bunFsMarkers.some((marker) => candidate.includes(marker)));
516
600
  isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === "1";
517
601
  isBunRuntime = !!process.versions.bun;
518
602
  pkg = {};
519
603
  try {
520
- pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
604
+ pkg = JSON.parse(readFileSync2(getPackageJsonPath(), "utf-8"));
521
605
  } catch (e) {
522
606
  const err = e;
523
607
  if (err.code !== "ENOENT")
@@ -1655,14 +1739,14 @@ var init_planner_outcome = __esm(() => {
1655
1739
  // src/core/compaction/range-planner-diagnostics.ts
1656
1740
  import { uuidv7 } from "@bastani/pi-ai";
1657
1741
  import { chmodSync, writeFileSync } from "fs";
1658
- import { basename, dirname as dirname3, join as join4 } from "path";
1742
+ import { basename, dirname as dirname4, join as join5 } from "path";
1659
1743
  function writeSidecar(sessionFilePath, kind, payload) {
1660
- const dir = dirname3(sessionFilePath);
1744
+ const dir = dirname4(sessionFilePath);
1661
1745
  const base = basename(sessionFilePath, ".jsonl");
1662
1746
  const timestamp = Date.now();
1663
1747
  const body = JSON.stringify(payload, null, 2);
1664
1748
  for (let attempt = 0;attempt < 4; attempt++) {
1665
- const filePath = join4(dir, `${base}-compaction-${kind}-${timestamp}-${uuidv7()}.json`);
1749
+ const filePath = join5(dir, `${base}-compaction-${kind}-${timestamp}-${uuidv7()}.json`);
1666
1750
  try {
1667
1751
  writeFileSync(filePath, body, { encoding: "utf-8", mode: 384, flag: "wx" });
1668
1752
  try {
@@ -3008,7 +3092,7 @@ function generateId(byId) {
3008
3092
  var init_session_manager_validation = () => {};
3009
3093
 
3010
3094
  // src/core/session-manager-entries.ts
3011
- import { join as join5 } from "path";
3095
+ import { join as join6 } from "path";
3012
3096
  function entryBase(byId, parentId) {
3013
3097
  return {
3014
3098
  id: generateId(byId),
@@ -3035,7 +3119,7 @@ function createSessionHeader(id, cwd, timestamp = new Date().toISOString(), pare
3035
3119
  }
3036
3120
  function createSessionFilePath(sessionDir, timestamp, sessionId) {
3037
3121
  const fileTimestamp = timestamp.replace(/[:.]/g, "-");
3038
- return join5(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);
3122
+ return join6(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);
3039
3123
  }
3040
3124
  function createMessageEntry(message, byId, parentId) {
3041
3125
  return {
@@ -3166,17 +3250,17 @@ var init_session_manager_entries = __esm(() => {
3166
3250
  });
3167
3251
 
3168
3252
  // src/core/session-manager-paths.ts
3169
- import { existsSync as existsSync2, mkdirSync } from "fs";
3170
- import { join as join6 } from "path";
3253
+ import { existsSync as existsSync3, mkdirSync } from "fs";
3254
+ import { join as join7 } from "path";
3171
3255
  function getDefaultSessionDirPath(cwd, agentDir = getAgentDir()) {
3172
3256
  const resolvedCwd = resolvePath(cwd);
3173
3257
  const resolvedAgentDir = resolvePath(agentDir);
3174
3258
  const safePath = `--${resolvedCwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
3175
- return join6(resolvedAgentDir, "sessions", safePath);
3259
+ return join7(resolvedAgentDir, "sessions", safePath);
3176
3260
  }
3177
3261
  function getDefaultSessionDir(cwd, agentDir = getAgentDir()) {
3178
3262
  const sessionDir = getDefaultSessionDirPath(cwd, agentDir);
3179
- if (!existsSync2(sessionDir)) {
3263
+ if (!existsSync3(sessionDir)) {
3180
3264
  mkdirSync(sessionDir, { recursive: true });
3181
3265
  }
3182
3266
  return sessionDir;
@@ -3190,7 +3274,7 @@ var init_session_manager_paths = __esm(() => {
3190
3274
  import {
3191
3275
  appendFileSync,
3192
3276
  closeSync,
3193
- existsSync as existsSync3,
3277
+ existsSync as existsSync4,
3194
3278
  mkdirSync as mkdirSync2,
3195
3279
  openSync,
3196
3280
  readdirSync,
@@ -3200,7 +3284,7 @@ import {
3200
3284
  unlinkSync,
3201
3285
  writeFileSync as writeFileSync2
3202
3286
  } from "fs";
3203
- import { join as join7 } from "path";
3287
+ import { join as join8 } from "path";
3204
3288
  import { StringDecoder } from "string_decoder";
3205
3289
  function parseSessionEntryLine(line) {
3206
3290
  if (!line.trim())
@@ -3213,7 +3297,7 @@ function parseSessionEntryLine(line) {
3213
3297
  }
3214
3298
  function loadEntriesFromFile(filePath) {
3215
3299
  const resolvedFilePath = normalizePath(filePath);
3216
- if (!existsSync3(resolvedFilePath))
3300
+ if (!existsSync4(resolvedFilePath))
3217
3301
  return [];
3218
3302
  const entries = [];
3219
3303
  const fd = openSync(resolvedFilePath, "r");
@@ -3308,7 +3392,7 @@ function findMostRecentSession(sessionDir, cwd, includeInternal = false) {
3308
3392
  const resolvedSessionDir = normalizePath(sessionDir);
3309
3393
  const resolvedCwd = cwd ? resolvePath(cwd) : undefined;
3310
3394
  try {
3311
- 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());
3395
+ 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());
3312
3396
  return files[0]?.path || null;
3313
3397
  } catch {
3314
3398
  return null;
@@ -3323,7 +3407,7 @@ function writeSessionEntries(filePath, entries) {
3323
3407
  writeFileSync2(filePath, serializeSessionEntries(entries));
3324
3408
  }
3325
3409
  function appendSessionPayload(filePath, payload) {
3326
- const existed = existsSync3(filePath);
3410
+ const existed = existsSync4(filePath);
3327
3411
  const offset = existed ? statSync(filePath).size : 0;
3328
3412
  try {
3329
3413
  appendFileSync(filePath, payload);
@@ -3331,7 +3415,7 @@ function appendSessionPayload(filePath, payload) {
3331
3415
  try {
3332
3416
  if (existed)
3333
3417
  truncateSync(filePath, offset);
3334
- else if (existsSync3(filePath))
3418
+ else if (existsSync4(filePath))
3335
3419
  unlinkSync(filePath);
3336
3420
  } catch (rollbackError) {
3337
3421
  throw new AggregateError([writeError, rollbackError], "Session append and rollback failed");
@@ -3361,7 +3445,7 @@ function persistAppendedEntry(filePath, entries, entry, flushed) {
3361
3445
  return true;
3362
3446
  }
3363
3447
  function ensureDirectory(dir) {
3364
- if (!existsSync3(dir)) {
3448
+ if (!existsSync4(dir)) {
3365
3449
  mkdirSync2(dir, { recursive: true });
3366
3450
  }
3367
3451
  }
@@ -3373,7 +3457,7 @@ var init_session_manager_storage = __esm(() => {
3373
3457
  });
3374
3458
 
3375
3459
  // src/core/session-manager-archive.ts
3376
- import { join as join8 } from "path";
3460
+ import { join as join9 } from "path";
3377
3461
  function createBackupSnapshot(sessionFile, entries, label = "compact") {
3378
3462
  if (!sessionFile)
3379
3463
  return;
@@ -3464,7 +3548,7 @@ function forkSessionFromFile(sourcePath, targetCwd, sessionDir, options) {
3464
3548
  }
3465
3549
  const newSessionId = options?.id ?? createSessionId();
3466
3550
  const timestamp = new Date().toISOString();
3467
- const newSessionFile = join8(dir, `${timestamp.replace(/[:.]/g, "-")}_${newSessionId}.jsonl`);
3551
+ const newSessionFile = join9(dir, `${timestamp.replace(/[:.]/g, "-")}_${newSessionId}.jsonl`);
3468
3552
  const newHeader = createSessionHeader(newSessionId, resolvedTargetCwd, timestamp, resolvedSourcePath, options?.internal, options?.workflow);
3469
3553
  appendSessionEntry(newSessionFile, newHeader);
3470
3554
  for (const entry of sourceEntries) {
@@ -3562,9 +3646,9 @@ var init_session_manager_migrations = __esm(() => {
3562
3646
  });
3563
3647
 
3564
3648
  // src/core/session-manager-list.ts
3565
- import { existsSync as existsSync4 } from "fs";
3649
+ import { existsSync as existsSync5 } from "fs";
3566
3650
  import { readdir, readFile, stat } from "fs/promises";
3567
- import { join as join9 } from "path";
3651
+ import { join as join10 } from "path";
3568
3652
  function isMessageWithContent(message) {
3569
3653
  return typeof message.role === "string" && "content" in message;
3570
3654
  }
@@ -3713,12 +3797,12 @@ async function buildSessionInfo(filePath) {
3713
3797
  }
3714
3798
  async function listSessionsFromDir(dir, onProgress, progressOffset = 0, progressTotal, includeInternal = false) {
3715
3799
  const sessions = [];
3716
- if (!existsSync4(dir)) {
3800
+ if (!existsSync5(dir)) {
3717
3801
  return sessions;
3718
3802
  }
3719
3803
  try {
3720
3804
  const dirEntries = await readdir(dir);
3721
- const files = dirEntries.filter((f) => f.endsWith(".jsonl")).map((f) => join9(dir, f));
3805
+ const files = dirEntries.filter((f) => f.endsWith(".jsonl")).map((f) => join10(dir, f));
3722
3806
  const total = progressTotal ?? files.length;
3723
3807
  let loaded = 0;
3724
3808
  const results = await mapSessionFilesCooperatively(files, includeInternal, () => {
@@ -3751,17 +3835,17 @@ async function listAllSessions(sessionDirOrOnProgress, onProgress, includeIntern
3751
3835
  }
3752
3836
  const sessionsDir = getSessionsDir();
3753
3837
  try {
3754
- if (!existsSync4(sessionsDir)) {
3838
+ if (!existsSync5(sessionsDir)) {
3755
3839
  return [];
3756
3840
  }
3757
3841
  const entries = await readdir(sessionsDir, { withFileTypes: true });
3758
- const dirs = entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => join9(sessionsDir, entry.name));
3842
+ const dirs = entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => join10(sessionsDir, entry.name));
3759
3843
  let totalFiles = 0;
3760
3844
  const dirFiles = [];
3761
3845
  for (const dir of dirs) {
3762
3846
  try {
3763
3847
  const files = (await readdir(dir)).filter((f) => f.endsWith(".jsonl"));
3764
- dirFiles.push(files.map((f) => join9(dir, f)));
3848
+ dirFiles.push(files.map((f) => join10(dir, f)));
3765
3849
  totalFiles += files.length;
3766
3850
  } catch {
3767
3851
  dirFiles.push([]);
@@ -3798,7 +3882,7 @@ var init_session_manager_list = __esm(() => {
3798
3882
  });
3799
3883
 
3800
3884
  // src/core/session-manager-core.ts
3801
- import { existsSync as existsSync5, statSync as statSync2 } from "fs";
3885
+ import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3802
3886
  import { resolve as resolve2 } from "path";
3803
3887
 
3804
3888
  class SessionManager {
@@ -3831,7 +3915,7 @@ class SessionManager {
3831
3915
  }
3832
3916
  _setSessionFile(sessionFile, preloadedFileEntries) {
3833
3917
  this.sessionFile = resolvePath(sessionFile);
3834
- if (existsSync5(this.sessionFile)) {
3918
+ if (existsSync6(this.sessionFile)) {
3835
3919
  this.fileEntries = preloadedFileEntries ?? loadEntriesFromFile(this.sessionFile);
3836
3920
  if (this.fileEntries.length === 0) {
3837
3921
  const explicitPath = this.sessionFile;
@@ -4552,7 +4636,7 @@ var init_agent_session_auto_compaction = __esm(() => {
4552
4636
  });
4553
4637
 
4554
4638
  // src/utils/shell.ts
4555
- import { existsSync as existsSync6 } from "node:fs";
4639
+ import { existsSync as existsSync7 } from "node:fs";
4556
4640
  import { delimiter } from "node:path";
4557
4641
  import { spawn, spawnSync } from "child_process";
4558
4642
  function isLegacyWslBashPath(path) {
@@ -4572,7 +4656,7 @@ function findBashOnPath() {
4572
4656
  });
4573
4657
  if (result.status === 0 && result.stdout) {
4574
4658
  const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
4575
- if (firstMatch && existsSync6(firstMatch)) {
4659
+ if (firstMatch && existsSync7(firstMatch)) {
4576
4660
  return firstMatch;
4577
4661
  }
4578
4662
  }
@@ -4596,7 +4680,7 @@ function findBashOnPath() {
4596
4680
  }
4597
4681
  function getShellConfig(customShellPath) {
4598
4682
  if (customShellPath) {
4599
- if (existsSync6(customShellPath)) {
4683
+ if (existsSync7(customShellPath)) {
4600
4684
  return getBashShellConfig(customShellPath);
4601
4685
  }
4602
4686
  throw new Error(`Custom shell path not found: ${customShellPath}`);
@@ -4612,7 +4696,7 @@ function getShellConfig(customShellPath) {
4612
4696
  paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
4613
4697
  }
4614
4698
  for (const path of paths) {
4615
- if (existsSync6(path)) {
4699
+ if (existsSync7(path)) {
4616
4700
  return getBashShellConfig(path);
4617
4701
  }
4618
4702
  }
@@ -4629,7 +4713,7 @@ function getShellConfig(customShellPath) {
4629
4713
  ${paths.map((p) => ` ${p}`).join(`
4630
4714
  `)}`);
4631
4715
  }
4632
- if (existsSync6("/bin/bash")) {
4716
+ if (existsSync7("/bin/bash")) {
4633
4717
  return getBashShellConfig("/bin/bash");
4634
4718
  }
4635
4719
  const bashOnPath = findBashOnPath();
@@ -4883,7 +4967,7 @@ var init_windows_directory_security = __esm(() => {
4883
4967
  import { createHash } from "node:crypto";
4884
4968
  import { chmodSync as chmodSync2, lstatSync, mkdirSync as mkdirSync3, realpathSync as realpathSync2, rmSync } from "node:fs";
4885
4969
  import { tmpdir, userInfo } from "node:os";
4886
- import { dirname as dirname4, join as join10, sep as sep2 } from "node:path";
4970
+ import { dirname as dirname5, join as join11, sep as sep2 } from "node:path";
4887
4971
  function sanitizeTempPathComponent(value, fallback) {
4888
4972
  const collapsed = value.replace(/[^a-zA-Z0-9._-]+/g, "_");
4889
4973
  let start = 0;
@@ -4940,11 +5024,11 @@ function baseTempDirs() {
4940
5024
  }
4941
5025
  function getTempRootDir() {
4942
5026
  const app = sanitizeTempPathComponent(APP_NAME, "atomic");
4943
- return join10(baseTempDirs().raw, `${app}-${ownerComponent()}`);
5027
+ return join11(baseTempDirs().raw, `${app}-${ownerComponent()}`);
4944
5028
  }
4945
5029
  function resolveSessionTempDirPath(sessionId) {
4946
5030
  const id = sessionId ?? activeSessionId ?? `pid-${process.pid}`;
4947
- return join10(getTempRootDir(), sanitizeTempPathComponent(id, FALLBACK_SESSION_COMPONENT));
5031
+ return join11(getTempRootDir(), sanitizeTempPathComponent(id, FALLBACK_SESSION_COMPONENT));
4948
5032
  }
4949
5033
  function isRealDirectory(path) {
4950
5034
  try {
@@ -5018,7 +5102,7 @@ function canonicalTempChild(dir, base) {
5018
5102
  for (const candidate of [base.raw, base.canonical]) {
5019
5103
  const prefix = `${candidate}${sep2}`;
5020
5104
  if (dir.startsWith(prefix)) {
5021
- return join10(base.canonical, dir.slice(prefix.length));
5105
+ return join11(base.canonical, dir.slice(prefix.length));
5022
5106
  }
5023
5107
  }
5024
5108
  return;
@@ -5031,13 +5115,13 @@ function ensureTempDir(dir) {
5031
5115
  const parts = checkedDir.slice(prefix.length).split(sep2).filter((part) => part.length > 0);
5032
5116
  let current = base.canonical;
5033
5117
  for (const part of parts.slice(0, -1)) {
5034
- current = join10(current, part);
5118
+ current = join11(current, part);
5035
5119
  ensureOwnedDirectory(current);
5036
5120
  }
5037
5121
  ensureLeafDirectory(checkedDir);
5038
5122
  } else {
5039
5123
  if (!(ensuredDirs.has(dir) && isRealDirectory(dir))) {
5040
- mkdirSync3(dirname4(dir), { recursive: true, mode: SESSION_TEMP_DIR_MODE });
5124
+ mkdirSync3(dirname5(dir), { recursive: true, mode: SESSION_TEMP_DIR_MODE });
5041
5125
  ensureLeafDirectory(dir);
5042
5126
  }
5043
5127
  }
@@ -5483,7 +5567,7 @@ var init_truncate = __esm(() => {
5483
5567
 
5484
5568
  // src/core/bash-executor.ts
5485
5569
  import { randomBytes } from "node:crypto";
5486
- import { join as join11 } from "node:path";
5570
+ import { join as join12 } from "node:path";
5487
5571
  async function executeBashWithOperations(command, cwd, operations, options) {
5488
5572
  const outputChunks = [];
5489
5573
  let outputBytes = 0;
@@ -5499,7 +5583,7 @@ async function executeBashWithOperations(command, cwd, operations, options) {
5499
5583
  try {
5500
5584
  const dir = ensureSessionTempDir(options?.sessionTempDir);
5501
5585
  const id = randomBytes(8).toString("hex");
5502
- tempFilePath = join11(dir, `${APP_NAME}-bash-${id}.log`);
5586
+ tempFilePath = join12(dir, `${APP_NAME}-bash-${id}.log`);
5503
5587
  tempFile = new PersistedOutputFile(tempFilePath);
5504
5588
  } catch {
5505
5589
  tempFileUnavailable = true;
@@ -7308,10 +7392,10 @@ var init_bash_session_environment = __esm(() => {
7308
7392
 
7309
7393
  // src/core/tools/output-accumulator.ts
7310
7394
  import { randomBytes as randomBytes2 } from "node:crypto";
7311
- import { join as join14 } from "node:path";
7395
+ import { join as join15 } from "node:path";
7312
7396
  function defaultTempFilePath(prefix, tempDir) {
7313
7397
  const id = randomBytes2(8).toString("hex");
7314
- return join14(ensureSessionTempDir(tempDir), `${prefix}-${id}.log`);
7398
+ return join15(ensureSessionTempDir(tempDir), `${prefix}-${id}.log`);
7315
7399
  }
7316
7400
  function byteLength(text) {
7317
7401
  return Buffer.byteLength(text, "utf-8");
@@ -7593,9 +7677,9 @@ var init_search_native = __esm(() => {
7593
7677
  });
7594
7678
 
7595
7679
  // src/core/tools/resource-selectors.ts
7596
- import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync3, realpathSync as realpathSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
7680
+ import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync4, realpathSync as realpathSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
7597
7681
  import { createRequire as createRequire3 } from "node:module";
7598
- import { dirname as dirname5, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3 } from "node:path";
7682
+ import { dirname as dirname6, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3 } from "node:path";
7599
7683
  import { deflateRawSync, gunzipSync, gzipSync, inflateRawSync } from "node:zlib";
7600
7684
  function toSqliteBindValues(params) {
7601
7685
  return params.map((param) => typeof param === "boolean" ? param ? 1 : 0 : param);
@@ -7633,9 +7717,9 @@ function sqliteDatabase() {
7633
7717
  }
7634
7718
  }
7635
7719
  function existingSqliteFile(path3) {
7636
- if (!existsSync9(path3))
7720
+ if (!existsSync10(path3))
7637
7721
  return;
7638
- return readFileSync3(path3).subarray(0, 16).toString("binary") === "SQLite format 3\x00";
7722
+ return readFileSync4(path3).subarray(0, 16).toString("binary") === "SQLite format 3\x00";
7639
7723
  }
7640
7724
  function sqliteSelectorForPath(value, cwd) {
7641
7725
  const selector = parseSqliteSelector(value);
@@ -7749,7 +7833,7 @@ function readZipEntriesFromBuffer(buf, label) {
7749
7833
  return entries;
7750
7834
  }
7751
7835
  function readZipEntries(path3) {
7752
- return readZipEntriesFromBuffer(readFileSync3(path3), path3);
7836
+ return readZipEntriesFromBuffer(readFileSync4(path3), path3);
7753
7837
  }
7754
7838
  function writeZipEntries(path3, entries) {
7755
7839
  const locals = [], centrals = [];
@@ -7788,7 +7872,7 @@ function writeZipEntries(path3, entries) {
7788
7872
  writeFileSync3(path3, Buffer.concat([...locals, ...centrals, eocd]));
7789
7873
  }
7790
7874
  function parseTar(path3) {
7791
- const raw = readFileSync3(path3);
7875
+ const raw = readFileSync4(path3);
7792
7876
  if (raw.length > MAX_TAR_ARCHIVE_BYTES)
7793
7877
  throw new Error(`Archive too large: ${path3}`);
7794
7878
  const buf = isGzipTar(path3) ? gunzipSync(raw, { maxOutputLength: MAX_TAR_ARCHIVE_BYTES }) : raw;
@@ -7860,7 +7944,7 @@ function listArchiveDirectory(names, memberPath) {
7860
7944
  `);
7861
7945
  }
7862
7946
  function readZipSelector(path3, memberPath) {
7863
- const buf = readFileSync3(path3);
7947
+ const buf = readFileSync4(path3);
7864
7948
  let eocd = -1;
7865
7949
  for (let i = buf.length - 22;i >= 0; i--)
7866
7950
  if (buf.readUInt32LE(i) === 101010256) {
@@ -7922,7 +8006,7 @@ function validateArchiveMemberPath(memberPath) {
7922
8006
  throw new Error(`Invalid archive member path: ${memberPath}`);
7923
8007
  }
7924
8008
  function writeZipEntrySelective(path3, memberPath, data) {
7925
- const source = existsSync9(path3) ? readFileSync3(path3) : Buffer.alloc(0);
8009
+ const source = existsSync10(path3) ? readFileSync4(path3) : Buffer.alloc(0);
7926
8010
  const locals = [], centrals = [];
7927
8011
  let offset = 0;
7928
8012
  if (source.length > 0) {
@@ -7958,7 +8042,7 @@ function writeZipEntrySelective(path3, memberPath, data) {
7958
8042
  }
7959
8043
  const tmp = `${path3}.atomic-entry-${Date.now()}`;
7960
8044
  writeZipEntries(tmp, new Map([[memberPath, data]]));
7961
- const built = readFileSync3(tmp);
8045
+ const built = readFileSync4(tmp);
7962
8046
  rmSync2(tmp, { force: true });
7963
8047
  const eocdStart = built.length - 22, localLen = built.readUInt32LE(eocdStart + 16), centralSizeOne = built.readUInt32LE(eocdStart + 12);
7964
8048
  const central = Buffer.from(built.subarray(localLen, localLen + centralSizeOne));
@@ -7976,12 +8060,12 @@ function writeZipEntrySelective(path3, memberPath, data) {
7976
8060
  }
7977
8061
  function writeArchiveSelector(selector, content) {
7978
8062
  validateArchiveMemberPath(selector.memberPath);
7979
- mkdirSync4(dirname5(selector.archivePath), { recursive: true });
8063
+ mkdirSync4(dirname6(selector.archivePath), { recursive: true });
7980
8064
  if (isZipArchive(selector.archivePath)) {
7981
8065
  writeZipEntrySelective(selector.archivePath, selector.memberPath, Buffer.from(content));
7982
8066
  return;
7983
8067
  }
7984
- const entries = existsSync9(selector.archivePath) ? parseTar(selector.archivePath) : new Map;
8068
+ const entries = existsSync10(selector.archivePath) ? parseTar(selector.archivePath) : new Map;
7985
8069
  entries.set(selector.memberPath, Buffer.from(content));
7986
8070
  writeTar(selector.archivePath, entries);
7987
8071
  }
@@ -8117,8 +8201,8 @@ function isContained(root, candidate) {
8117
8201
  }
8118
8202
  function nearestExistingAncestor(pathValue) {
8119
8203
  let current = pathValue;
8120
- while (!existsSync9(current)) {
8121
- const parent = dirname5(current);
8204
+ while (!existsSync10(current)) {
8205
+ const parent = dirname6(current);
8122
8206
  if (parent === current)
8123
8207
  return current;
8124
8208
  current = parent;
@@ -8143,7 +8227,7 @@ function fallbackInternalPath(value, cwd) {
8143
8227
  const skill = value.match(/^skill:\/\/([^/]+)(?:\/(.*))?$/);
8144
8228
  if (skill) {
8145
8229
  const name = skill[1] ?? "", rest = skill[2] || "SKILL.md";
8146
- 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));
8230
+ 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));
8147
8231
  }
8148
8232
  const local = value.match(/^local:\/\/(.+)$/);
8149
8233
  if (local)
@@ -8161,9 +8245,9 @@ async function readInternalSelector(value, cwd, context) {
8161
8245
  if (Buffer.isBuffer(routed))
8162
8246
  return routed.toString("utf8");
8163
8247
  const resolved = await resolveViaRouter(value, cwd, context);
8164
- if (!resolved || !existsSync9(resolved))
8248
+ if (!resolved || !existsSync10(resolved))
8165
8249
  throw new Error(`Internal resource not found or no session router supports it: ${value}`);
8166
- return readFileSync3(resolved, "utf8");
8250
+ return readFileSync4(resolved, "utf8");
8167
8251
  }
8168
8252
  async function writeInternalSelector(value, cwd, content, context) {
8169
8253
  const router = routerFromContext(context);
@@ -8174,7 +8258,7 @@ async function writeInternalSelector(value, cwd, content, context) {
8174
8258
  const resolved = await resolveViaRouter(value, cwd, context);
8175
8259
  if (!resolved)
8176
8260
  throw new Error(`Unsupported writable internal resource without a session router: ${value}`);
8177
- mkdirSync4(dirname5(resolved), { recursive: true });
8261
+ mkdirSync4(dirname6(resolved), { recursive: true });
8178
8262
  writeFileSync3(resolved, content);
8179
8263
  }
8180
8264
  async function searchInternalSelector(value, cwd, pattern, ignoreCase = false, literal = false, context, contextBefore = 1, contextAfter = 3) {
@@ -8456,7 +8540,7 @@ function parseLooseJsonObject(content) {
8456
8540
  function writeSqliteSelector(selector, content) {
8457
8541
  if (!selector.table)
8458
8542
  throw new Error("SQLite write target must include a table name");
8459
- if (!existsSync9(selector.databasePath))
8543
+ if (!existsSync10(selector.databasePath))
8460
8544
  throw new Error(`SQLite database does not exist: ${selector.databasePath}`);
8461
8545
  if (content.trim() === "") {
8462
8546
  if (!selector.rowId)
@@ -9229,12 +9313,12 @@ var init_agent_session_bash = __esm(() => {
9229
9313
  });
9230
9314
 
9231
9315
  // src/core/auth-guidance.ts
9232
- import { join as join15 } from "node:path";
9316
+ import { join as join16 } from "node:path";
9233
9317
  function getProviderLoginHelp() {
9234
9318
  return [
9235
9319
  "Use /login to log into a provider via OAuth or API key. See:",
9236
- ` ${join15(getDocsPath(), "providers.md")}`,
9237
- ` ${join15(getDocsPath(), "models.md")}`
9320
+ ` ${join16(getDocsPath(), "providers.md")}`,
9321
+ ` ${join16(getDocsPath(), "models.md")}`
9238
9322
  ].join(`
9239
9323
  `);
9240
9324
  }
@@ -10411,10 +10495,10 @@ function getUsageCostBreakdown(entries) {
10411
10495
  }
10412
10496
 
10413
10497
  // src/core/export-html/template-script.ts
10414
- import { readFileSync as readFileSync4 } from "fs";
10415
- import { join as join16 } from "path";
10498
+ import { readFileSync as readFileSync5 } from "fs";
10499
+ import { join as join17 } from "path";
10416
10500
  function readExportHtmlTemplateScript(templateDir) {
10417
- return EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS.map((fileName) => readFileSync4(join16(templateDir, "template-js", fileName), "utf-8")).join("");
10501
+ return EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS.map((fileName) => readFileSync5(join17(templateDir, "template-js", fileName), "utf-8")).join("");
10418
10502
  }
10419
10503
  var EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS;
10420
10504
  var init_template_script = __esm(() => {
@@ -10433,8 +10517,8 @@ __export(exports_export_html, {
10433
10517
  exportFromFile: () => exportFromFile,
10434
10518
  exportSessionToHtml: () => exportSessionToHtml
10435
10519
  });
10436
- import { existsSync as existsSync10, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
10437
- import { basename as basename2, join as join17 } from "path";
10520
+ import { existsSync as existsSync11, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
10521
+ import { basename as basename2, join as join18 } from "path";
10438
10522
  function parseColor(color) {
10439
10523
  const hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
10440
10524
  if (hexMatch) {
@@ -10509,11 +10593,11 @@ function generateThemeVars(themeName) {
10509
10593
  }
10510
10594
  function generateHtml(sessionData, themeName) {
10511
10595
  const templateDir = getExportTemplateDir();
10512
- const template = readFileSync5(join17(templateDir, "template.html"), "utf-8");
10513
- const templateCss = readFileSync5(join17(templateDir, "template.css"), "utf-8");
10596
+ const template = readFileSync6(join18(templateDir, "template.html"), "utf-8");
10597
+ const templateCss = readFileSync6(join18(templateDir, "template.css"), "utf-8");
10514
10598
  const templateJs = readExportHtmlTemplateScript(templateDir);
10515
- const markedJs = readFileSync5(join17(templateDir, "vendor", "marked.min.js"), "utf-8");
10516
- const hljsJs = readFileSync5(join17(templateDir, "vendor", "highlight.min.js"), "utf-8");
10599
+ const markedJs = readFileSync6(join18(templateDir, "vendor", "marked.min.js"), "utf-8");
10600
+ const hljsJs = readFileSync6(join18(templateDir, "vendor", "highlight.min.js"), "utf-8");
10517
10601
  const themeVars = generateThemeVars(themeName);
10518
10602
  const colors = getResolvedThemeColors(themeName);
10519
10603
  const themeExport = getThemeExportColors(themeName);
@@ -10564,7 +10648,7 @@ async function exportSessionToHtml(sm, state, options) {
10564
10648
  if (!sessionFile) {
10565
10649
  throw new Error("Cannot export in-memory session to HTML");
10566
10650
  }
10567
- if (!existsSync10(sessionFile)) {
10651
+ if (!existsSync11(sessionFile)) {
10568
10652
  throw new Error("Nothing to export yet - start a conversation first");
10569
10653
  }
10570
10654
  const entries = sm.getEntries();
@@ -10595,7 +10679,7 @@ async function exportSessionToHtml(sm, state, options) {
10595
10679
  async function exportFromFile(inputPath, options) {
10596
10680
  const opts = typeof options === "string" ? { outputPath: options } : options || {};
10597
10681
  const resolvedInputPath = resolvePath(inputPath);
10598
- if (!existsSync10(resolvedInputPath)) {
10682
+ if (!existsSync11(resolvedInputPath)) {
10599
10683
  throw new Error(`File not found: ${resolvedInputPath}`);
10600
10684
  }
10601
10685
  const sm = SessionManager.open(resolvedInputPath);
@@ -10897,8 +10981,8 @@ var init_tool_renderer = __esm(() => {
10897
10981
  });
10898
10982
 
10899
10983
  // src/core/agent-session-export.ts
10900
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "node:fs";
10901
- import { dirname as dirname6 } from "node:path";
10984
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "node:fs";
10985
+ import { dirname as dirname7 } from "node:path";
10902
10986
  function getSessionStats() {
10903
10987
  let userMessages = 0;
10904
10988
  let assistantMessages = 0;
@@ -11002,8 +11086,8 @@ async function exportToHtml(outputPath, options = {}) {
11002
11086
  }
11003
11087
  function exportToJsonl(outputPath) {
11004
11088
  const filePath = resolvePath(outputPath ?? `session-${new Date().toISOString().replace(/[:.]/g, "-")}.jsonl`, process.cwd());
11005
- const dir = dirname6(filePath);
11006
- if (!existsSync11(dir)) {
11089
+ const dir = dirname7(filePath);
11090
+ if (!existsSync12(dir)) {
11007
11091
  mkdirSync5(dir, { recursive: true });
11008
11092
  }
11009
11093
  const header = {
@@ -11087,8 +11171,8 @@ var init_loader_runtime = __esm(() => {
11087
11171
  });
11088
11172
 
11089
11173
  // src/core/tools/artifacts.ts
11090
- import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, writeFileSync as writeFileSync6 } from "node:fs";
11091
- import { join as join18 } from "node:path";
11174
+ import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync3, writeFileSync as writeFileSync6 } from "node:fs";
11175
+ import { join as join19 } from "node:path";
11092
11176
 
11093
11177
  class ArtifactManager {
11094
11178
  #nextId = 0;
@@ -11105,7 +11189,7 @@ class ArtifactManager {
11105
11189
  return;
11106
11190
  this.#initialized = true;
11107
11191
  let max = -1;
11108
- if (existsSync12(this.#dir)) {
11192
+ if (existsSync13(this.#dir)) {
11109
11193
  for (const name of readdirSync3(this.#dir)) {
11110
11194
  const match = name.match(/^(\d+)\..*\.log$/);
11111
11195
  if (match) {
@@ -11120,30 +11204,30 @@ class ArtifactManager {
11120
11204
  allocate(toolType) {
11121
11205
  this.#init();
11122
11206
  const id = String(this.#nextId++);
11123
- const path3 = join18(this.#dir, `${id}.${toolType}.log`);
11207
+ const path3 = join19(this.#dir, `${id}.${toolType}.log`);
11124
11208
  return { path: path3, id };
11125
11209
  }
11126
11210
  save(content, toolType) {
11127
11211
  this.#init();
11128
11212
  const { path: path3, id } = this.allocate(toolType);
11129
- if (!existsSync12(this.#dir))
11213
+ if (!existsSync13(this.#dir))
11130
11214
  mkdirSync6(this.#dir, { recursive: true });
11131
11215
  writeFileSync6(path3, content, "utf8");
11132
11216
  return id;
11133
11217
  }
11134
11218
  resolve(id) {
11135
11219
  this.#init();
11136
- if (!existsSync12(this.#dir))
11220
+ if (!existsSync13(this.#dir))
11137
11221
  return;
11138
11222
  const prefix = `${id}.`;
11139
11223
  for (const name of readdirSync3(this.#dir))
11140
11224
  if (name.startsWith(prefix) && name.endsWith(".log"))
11141
- return join18(this.#dir, name);
11225
+ return join19(this.#dir, name);
11142
11226
  return;
11143
11227
  }
11144
11228
  list() {
11145
11229
  this.#init();
11146
- if (!existsSync12(this.#dir))
11230
+ if (!existsSync13(this.#dir))
11147
11231
  return [];
11148
11232
  const ids = [];
11149
11233
  for (const name of readdirSync3(this.#dir)) {
@@ -11168,7 +11252,7 @@ var init_artifacts = __esm(() => {
11168
11252
  });
11169
11253
 
11170
11254
  // src/core/tools/artifact-protocol.ts
11171
- import { existsSync as existsSync13, readFileSync as readFileSync6 } from "node:fs";
11255
+ import { existsSync as existsSync14, readFileSync as readFileSync7 } from "node:fs";
11172
11256
  function registerArtifactDir(dir) {
11173
11257
  activeArtifactDirs.add(dir);
11174
11258
  }
@@ -11213,9 +11297,9 @@ function createArtifactRouter(getPinnedDirs) {
11213
11297
  if (!/^artifact:\/\//i.test(url))
11214
11298
  return;
11215
11299
  const path3 = resolveArtifactUrl(url, getPinnedDirs());
11216
- if (!path3 || !existsSync13(path3))
11300
+ if (!path3 || !existsSync14(path3))
11217
11301
  throw new Error(`Artifact not found: ${url}`);
11218
- return readFileSync6(path3, "utf8");
11302
+ return readFileSync7(path3, "utf8");
11219
11303
  }
11220
11304
  };
11221
11305
  }
@@ -11226,7 +11310,7 @@ var init_artifact_protocol = __esm(() => {
11226
11310
  });
11227
11311
 
11228
11312
  // src/core/extensions/runner-context.ts
11229
- import { join as join19 } from "node:path";
11313
+ import { join as join20 } from "node:path";
11230
11314
  function deepFrozenCopy(value) {
11231
11315
  if (Array.isArray(value))
11232
11316
  return Object.freeze(value.map(deepFrozenCopy));
@@ -11286,7 +11370,7 @@ function createExtensionContext(source) {
11286
11370
  const sessionDir = source.getSessionManager().getSessionDir();
11287
11371
  if (!sessionDir)
11288
11372
  return;
11289
- const artifactsDir = join19(sessionDir, "artifacts");
11373
+ const artifactsDir = join20(sessionDir, "artifacts");
11290
11374
  registerArtifactDir(artifactsDir);
11291
11375
  return createArtifactRouter(() => [artifactsDir]);
11292
11376
  },
@@ -12199,7 +12283,7 @@ var init_runner = __esm(() => {
12199
12283
 
12200
12284
  // src/core/skill-catalog.ts
12201
12285
  import { createHash as createHash2 } from "node:crypto";
12202
- import { basename as basename3, dirname as dirname7, sep as sep3 } from "node:path";
12286
+ import { basename as basename3, dirname as dirname8, sep as sep3 } from "node:path";
12203
12287
  function candidateId(skill) {
12204
12288
  return `skill_${createHash2("sha256").update(canonicalizePath(skill.filePath)).digest("hex").slice(0, 20)}`;
12205
12289
  }
@@ -12243,7 +12327,7 @@ function sourceLabel(skill) {
12243
12327
  }
12244
12328
  const pathParts = canonicalizePath(skill.filePath).split(sep3).filter(Boolean);
12245
12329
  const configPart = [...pathParts].reverse().find((part) => part === ".atomic" || part === ".pi" || part === ".agents");
12246
- return configPart ? configPart.slice(1) : readableToken(basename3(skill.sourceInfo.baseDir ?? dirname7(skill.filePath)));
12330
+ return configPart ? configPart.slice(1) : readableToken(basename3(skill.sourceInfo.baseDir ?? dirname8(skill.filePath)));
12247
12331
  }
12248
12332
  function uniquePathLabels(candidates) {
12249
12333
  const labels = new Map(candidates.map((candidate) => [candidate.id, sourceLabel(candidate.skill)]));
@@ -12257,7 +12341,7 @@ function uniquePathLabels(candidates) {
12257
12341
  for (const [label, matching] of byLabel) {
12258
12342
  if (matching.length === 1)
12259
12343
  continue;
12260
- const pathParts = matching.map((candidate) => canonicalizePath(dirname7(candidate.skill.filePath)).split(sep3).filter(Boolean));
12344
+ const pathParts = matching.map((candidate) => canonicalizePath(dirname8(candidate.skill.filePath)).split(sep3).filter(Boolean));
12261
12345
  for (let depth = 1;depth <= Math.max(...pathParts.map((parts) => parts.length)); depth++) {
12262
12346
  const suffixes = pathParts.map((parts) => parts.slice(-depth).join("/"));
12263
12347
  if (new Set(suffixes).size !== suffixes.length)
@@ -12430,7 +12514,7 @@ var init_skill_catalog = __esm(() => {
12430
12514
  });
12431
12515
 
12432
12516
  // src/core/agent-session-extension-bindings.ts
12433
- import { basename as basename4, dirname as dirname8 } from "node:path";
12517
+ import { basename as basename4, dirname as dirname9 } from "node:path";
12434
12518
  import { resetApiProviders } from "@bastani/pi-ai/compat";
12435
12519
  async function bindExtensions(bindings) {
12436
12520
  if (bindings.uiContext !== undefined) {
@@ -12478,7 +12562,7 @@ function buildExtensionResourcePaths(entries) {
12478
12562
  const extension = extensions.find((candidate) => candidate.path === entry.extensionPath || candidate.resolvedPath === entry.extensionPath || candidate.sourceInfo.path === entry.extensionPath);
12479
12563
  const sourceInfo = extension?.sourceInfo;
12480
12564
  const source = sourceInfo?.source ?? this.getExtensionSourceLabel(entry.extensionPath);
12481
- const baseDir = sourceInfo?.baseDir ?? (entry.extensionPath.startsWith("<") ? undefined : dirname8(entry.extensionPath));
12565
+ const baseDir = sourceInfo?.baseDir ?? (entry.extensionPath.startsWith("<") ? undefined : dirname9(entry.extensionPath));
12482
12566
  return {
12483
12567
  path: entry.path,
12484
12568
  metadata: {
@@ -13575,7 +13659,7 @@ var init_frontmatter = () => {};
13575
13659
 
13576
13660
  // src/utils/changelog.ts
13577
13661
  import path3 from "node:path";
13578
- import { existsSync as existsSync14, readFileSync as readFileSync7 } from "fs";
13662
+ import { existsSync as existsSync15, readFileSync as readFileSync8 } from "fs";
13579
13663
  function parsedVersionFromMatch(match) {
13580
13664
  return {
13581
13665
  version: match[1],
@@ -13669,11 +13753,11 @@ function normalizeChangelogLinks(markdown, version) {
13669
13753
  });
13670
13754
  }
13671
13755
  function parseChangelog(changelogPath) {
13672
- if (!existsSync14(changelogPath)) {
13756
+ if (!existsSync15(changelogPath)) {
13673
13757
  return [];
13674
13758
  }
13675
13759
  try {
13676
- const content = readFileSync7(changelogPath, "utf-8");
13760
+ const content = readFileSync8(changelogPath, "utf-8");
13677
13761
  const lines = content.split(`
13678
13762
  `);
13679
13763
  const entries = [];
@@ -14172,7 +14256,7 @@ var init_prompt_templates = __esm(() => {
14172
14256
  });
14173
14257
 
14174
14258
  // src/core/agent-session-prompt.ts
14175
- import { readFileSync as readFileSync8 } from "node:fs";
14259
+ import { readFileSync as readFileSync9 } from "node:fs";
14176
14260
  async function tryExecuteSessionSlashCommand(session, text) {
14177
14261
  if (!text.startsWith("/"))
14178
14262
  return false;
@@ -14444,7 +14528,7 @@ function _expandSkillCommand(text) {
14444
14528
  }
14445
14529
  const { skill, id } = resolution.candidate;
14446
14530
  try {
14447
- const content = readFileSync8(skill.filePath, "utf-8");
14531
+ const content = readFileSync9(skill.filePath, "utf-8");
14448
14532
  const body = stripFrontmatter(content).trim();
14449
14533
  const skillBlock = `<skill name="${selector}" location="${skill.filePath}" candidate="${id}">
14450
14534
  References are relative to ${skill.baseDir}.
@@ -16538,7 +16622,7 @@ function assertToolPairingInvariant(messages) {
16538
16622
  import { Buffer as Buffer3 } from "node:buffer";
16539
16623
  import { constants as constants2 } from "node:fs";
16540
16624
  import { chmod, lstat, mkdir, open } from "node:fs/promises";
16541
- import { join as join21 } from "node:path";
16625
+ import { join as join22 } from "node:path";
16542
16626
  function getPersistenceThreshold(declaredMaxResultSizeChars) {
16543
16627
  if (declaredMaxResultSizeChars === undefined) {
16544
16628
  return DEFAULT_MAX_RESULT_SIZE_CHARS;
@@ -16627,14 +16711,14 @@ function sanitizePathComponent(value, fallback) {
16627
16711
  }
16628
16712
  async function ensureToolResultsDir(input) {
16629
16713
  if (input.sessionDir?.trim()) {
16630
- const dir = join21(input.sessionDir, TOOL_RESULTS_SUBDIR);
16714
+ const dir = join22(input.sessionDir, TOOL_RESULTS_SUBDIR);
16631
16715
  await mkdir(dir, { recursive: true, mode: SESSION_TEMP_DIR_MODE });
16632
16716
  if (process.platform !== "win32") {
16633
16717
  await chmod(dir, SESSION_TEMP_DIR_MODE);
16634
16718
  }
16635
16719
  return dir;
16636
16720
  }
16637
- return ensureTempDir(join21(resolveSessionTempDirPath(input.sessionId), TOOL_RESULTS_SUBDIR));
16721
+ return ensureTempDir(join22(resolveSessionTempDirPath(input.sessionId), TOOL_RESULTS_SUBDIR));
16638
16722
  }
16639
16723
  function isOwnedByCurrentUser(uid) {
16640
16724
  const currentUid = typeof process.getuid === "function" ? process.getuid() : undefined;
@@ -16700,7 +16784,7 @@ async function persistToolOutput(input) {
16700
16784
  } catch {
16701
16785
  return;
16702
16786
  }
16703
- const filepath = join21(dir, `${sanitizePathComponent(input.toolCallId, "tool-result")}.txt`);
16787
+ const filepath = join22(dir, `${sanitizePathComponent(input.toolCallId, "tool-result")}.txt`);
16704
16788
  try {
16705
16789
  const handle = await open(filepath, "wx", SESSION_TEMP_FILE_MODE);
16706
16790
  try {
@@ -16952,7 +17036,7 @@ var init_loader_core = __esm(() => {
16952
17036
  });
16953
17037
 
16954
17038
  // src/core/package-manager-manifest.ts
16955
- import { join as join22 } from "node:path";
17039
+ import { join as join23 } from "node:path";
16956
17040
  function isRecord(value) {
16957
17041
  return typeof value === "object" && value !== null && !Array.isArray(value);
16958
17042
  }
@@ -16975,9 +17059,9 @@ function getManifestFromPackageJson(pkg2) {
16975
17059
  }
16976
17060
  function conventionDirsForResource(packageRoot, resourceType) {
16977
17061
  if (resourceType === "workflows") {
16978
- return [join22(packageRoot, "workflows"), join22(packageRoot, "workflow")];
17062
+ return [join23(packageRoot, "workflows"), join23(packageRoot, "workflow")];
16979
17063
  }
16980
- return [join22(packageRoot, resourceType)];
17064
+ return [join23(packageRoot, resourceType)];
16981
17065
  }
16982
17066
  function manifestEntriesForResource(manifest, resourceType) {
16983
17067
  if (!manifest)
@@ -17163,14 +17247,14 @@ var init_model_registry = __esm(() => {
17163
17247
  });
17164
17248
 
17165
17249
  // src/core/tools/ask-user-question/config.ts
17166
- import { existsSync as existsSync15, readFileSync as readFileSync9 } from "node:fs";
17250
+ import { existsSync as existsSync16, readFileSync as readFileSync10 } from "node:fs";
17167
17251
  import { homedir as homedir4 } from "node:os";
17168
- import { join as join23 } from "node:path";
17252
+ import { join as join24 } from "node:path";
17169
17253
  function loadConfig() {
17170
- if (!existsSync15(CONFIG_PATH))
17254
+ if (!existsSync16(CONFIG_PATH))
17171
17255
  return {};
17172
17256
  try {
17173
- const parsed = JSON.parse(readFileSync9(CONFIG_PATH, "utf-8"));
17257
+ const parsed = JSON.parse(readFileSync10(CONFIG_PATH, "utf-8"));
17174
17258
  if (parsed === null || typeof parsed !== "object")
17175
17259
  return {};
17176
17260
  return parsed;
@@ -17193,8 +17277,8 @@ function validateGuidanceFields(fields) {
17193
17277
  }
17194
17278
  var CONFIG_DIR, CONFIG_PATH;
17195
17279
  var init_config2 = __esm(() => {
17196
- CONFIG_DIR = join23(homedir4(), ".config", "rpiv-ask-user-question");
17197
- CONFIG_PATH = join23(CONFIG_DIR, "config.json");
17280
+ CONFIG_DIR = join24(homedir4(), ".config", "rpiv-ask-user-question");
17281
+ CONFIG_PATH = join24(CONFIG_DIR, "config.json");
17198
17282
  });
17199
17283
 
17200
17284
  // src/core/tools/ask-user-question/view/component-binding.ts
@@ -19698,7 +19782,7 @@ var init_chat_message_renderer = __esm(() => {
19698
19782
 
19699
19783
  // src/utils/clipboard-native.ts
19700
19784
  import { createRequire as createRequire6 } from "module";
19701
- import { dirname as dirname10, join as join24 } from "path";
19785
+ import { dirname as dirname11, join as join25 } from "path";
19702
19786
  import { pathToFileURL as pathToFileURL3 } from "url";
19703
19787
  function loadClipboardNative(requires = [moduleRequire, executableDirRequire]) {
19704
19788
  for (const requireClipboard of requires) {
@@ -19711,7 +19795,7 @@ function loadClipboardNative(requires = [moduleRequire, executableDirRequire]) {
19711
19795
  var moduleRequire, executableDirRequire, hasDisplay, clipboard;
19712
19796
  var init_clipboard_native = __esm(() => {
19713
19797
  moduleRequire = createRequire6(import.meta.url);
19714
- executableDirRequire = createRequire6(pathToFileURL3(join24(dirname10(process.execPath), "package.json")).href);
19798
+ executableDirRequire = createRequire6(pathToFileURL3(join25(dirname11(process.execPath), "package.json")).href);
19715
19799
  hasDisplay = process.platform !== "linux" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);
19716
19800
  clipboard = !process.env.TERMUX_VERSION && hasDisplay ? loadClipboardNative() : null;
19717
19801
  });
@@ -19719,9 +19803,9 @@ var init_clipboard_native = __esm(() => {
19719
19803
  // src/utils/clipboard-image.ts
19720
19804
  import { spawnSync as spawnSync3 } from "child_process";
19721
19805
  import { randomUUID as randomUUID2 } from "crypto";
19722
- import { readFileSync as readFileSync10, unlinkSync as unlinkSync2 } from "fs";
19806
+ import { readFileSync as readFileSync11, unlinkSync as unlinkSync2 } from "fs";
19723
19807
  import { tmpdir as tmpdir2 } from "os";
19724
- import { join as join25 } from "path";
19808
+ import { join as join26 } from "path";
19725
19809
  function isWaylandSession(env = process.env) {
19726
19810
  return Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === "wayland";
19727
19811
  }
@@ -19811,14 +19895,14 @@ function isWSL(env = process.env) {
19811
19895
  return true;
19812
19896
  }
19813
19897
  try {
19814
- const release = readFileSync10("/proc/version", "utf-8");
19898
+ const release = readFileSync11("/proc/version", "utf-8");
19815
19899
  return /microsoft|wsl/i.test(release);
19816
19900
  } catch {
19817
19901
  return false;
19818
19902
  }
19819
19903
  }
19820
19904
  function readClipboardImageViaPowerShell() {
19821
- const tmpFile = join25(tmpdir2(), `pi-wsl-clip-${randomUUID2()}.png`);
19905
+ const tmpFile = join26(tmpdir2(), `pi-wsl-clip-${randomUUID2()}.png`);
19822
19906
  try {
19823
19907
  const winPathResult = runCommand("wslpath", ["-w", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });
19824
19908
  if (!winPathResult.ok) {
@@ -19846,7 +19930,7 @@ function readClipboardImageViaPowerShell() {
19846
19930
  if (output !== "ok") {
19847
19931
  return null;
19848
19932
  }
19849
- const bytes = readFileSync10(tmpFile);
19933
+ const bytes = readFileSync11(tmpFile);
19850
19934
  if (bytes.length === 0) {
19851
19935
  return null;
19852
19936
  }
@@ -20059,9 +20143,9 @@ var init_clipboard = __esm(() => {
20059
20143
 
20060
20144
  // src/modes/interactive/external-editor.ts
20061
20145
  import { spawn as spawn4 } from "node:child_process";
20062
- import { mkdtempSync, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
20146
+ import { mkdtempSync, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
20063
20147
  import { tmpdir as tmpdir3 } from "node:os";
20064
- import { join as join26 } from "node:path";
20148
+ import { join as join27 } from "node:path";
20065
20149
  function parseEditorCommand(command) {
20066
20150
  const args = [];
20067
20151
  let current = "";
@@ -20126,8 +20210,8 @@ function resolveExternalEditorCommand(configuredCommand, environment = process.e
20126
20210
  return platform2 === "win32" ? "notepad" : "nano";
20127
20211
  }
20128
20212
  async function editInExternalEditor(request) {
20129
- const directory = mkdtempSync(join26(tmpdir3(), `${APP_NAME}-editor-`));
20130
- const filePath = join26(directory, "prompt.md");
20213
+ const directory = mkdtempSync(join27(tmpdir3(), `${APP_NAME}-editor-`));
20214
+ const filePath = join27(directory, "prompt.md");
20131
20215
  try {
20132
20216
  writeFileSync7(filePath, request.content, {
20133
20217
  encoding: "utf-8",
@@ -20151,7 +20235,7 @@ ${APP_NAME} will resume when the editor exits.
20151
20235
  return { status: "failed" };
20152
20236
  return {
20153
20237
  status: "complete",
20154
- content: readFileSync11(filePath, "utf-8").replace(/\n$/, "")
20238
+ content: readFileSync12(filePath, "utf-8").replace(/\n$/, "")
20155
20239
  };
20156
20240
  } finally {
20157
20241
  try {
@@ -23205,8 +23289,8 @@ import {
23205
23289
  TUI_KEYBINDINGS,
23206
23290
  KeybindingsManager as TuiKeybindingsManager
23207
23291
  } from "@earendil-works/pi-tui";
23208
- import { existsSync as existsSync16, readFileSync as readFileSync12 } from "fs";
23209
- import { join as join28 } from "path";
23292
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "fs";
23293
+ import { join as join29 } from "path";
23210
23294
  function isRecord2(value) {
23211
23295
  return typeof value === "object" && value !== null && !Array.isArray(value);
23212
23296
  }
@@ -23258,10 +23342,10 @@ function orderKeybindingsConfig(config) {
23258
23342
  return ordered;
23259
23343
  }
23260
23344
  function loadRawConfig(path7) {
23261
- if (!existsSync16(path7))
23345
+ if (!existsSync17(path7))
23262
23346
  return;
23263
23347
  try {
23264
- const parsed = JSON.parse(readFileSync12(path7, "utf-8"));
23348
+ const parsed = JSON.parse(readFileSync13(path7, "utf-8"));
23265
23349
  return isRecord2(parsed) ? parsed : undefined;
23266
23350
  } catch {
23267
23351
  return;
@@ -23482,7 +23566,7 @@ var init_keybindings = __esm(() => {
23482
23566
  this.configPath = configPath;
23483
23567
  }
23484
23568
  static create(agentDir = getAgentDir()) {
23485
- const configPath = join28(agentDir, "keybindings.json");
23569
+ const configPath = join29(agentDir, "keybindings.json");
23486
23570
  const userBindings = KeybindingsManager.loadFromFile(configPath);
23487
23571
  return new KeybindingsManager(userBindings, configPath);
23488
23572
  }
@@ -23505,7 +23589,7 @@ var init_keybindings = __esm(() => {
23505
23589
 
23506
23590
  // src/modes/interactive/components/session-selector-delete.ts
23507
23591
  import { spawnSync as spawnSync4 } from "node:child_process";
23508
- import { existsSync as existsSync17 } from "node:fs";
23592
+ import { existsSync as existsSync18 } from "node:fs";
23509
23593
  import { unlink } from "node:fs/promises";
23510
23594
  async function deleteSessionFile(sessionPath) {
23511
23595
  const trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath];
@@ -23524,7 +23608,7 @@ async function deleteSessionFile(sessionPath) {
23524
23608
  return null;
23525
23609
  return `trash: ${parts.join(" · ").slice(0, 200)}`;
23526
23610
  };
23527
- if (trashResult.status === 0 || !existsSync17(sessionPath)) {
23611
+ if (trashResult.status === 0 || !existsSync18(sessionPath)) {
23528
23612
  return { ok: true, method: "trash" };
23529
23613
  }
23530
23614
  try {
@@ -26401,8 +26485,8 @@ function parseJsonFileContent(input) {
26401
26485
  }
26402
26486
 
26403
26487
  // src/core/trust-manager.ts
26404
- import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "node:fs";
26405
- import { dirname as dirname11, join as join29 } from "node:path";
26488
+ import { existsSync as existsSync19, mkdirSync as mkdirSync7, readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "node:fs";
26489
+ import { dirname as dirname12, join as join30 } from "node:path";
26406
26490
  import lockfile from "proper-lockfile";
26407
26491
  function normalizeCwd(cwd) {
26408
26492
  return canonicalizePath(resolvePath(cwd));
@@ -26414,7 +26498,7 @@ function findNearestTrustEntry(data, cwd) {
26414
26498
  if (value === true || value === false) {
26415
26499
  return { path: currentDir, decision: value };
26416
26500
  }
26417
- const parentDir = dirname11(currentDir);
26501
+ const parentDir = dirname12(currentDir);
26418
26502
  if (parentDir === currentDir) {
26419
26503
  return null;
26420
26504
  }
@@ -26426,7 +26510,7 @@ function getProjectTrustPath(cwd) {
26426
26510
  }
26427
26511
  function getProjectTrustParentPath(cwd) {
26428
26512
  const trustPath = getProjectTrustPath(cwd);
26429
- const parentDir = dirname11(trustPath);
26513
+ const parentDir = dirname12(trustPath);
26430
26514
  return parentDir === trustPath ? undefined : parentDir;
26431
26515
  }
26432
26516
  function getProjectTrustOptions(cwd, options) {
@@ -26461,12 +26545,12 @@ function getProjectTrustOptions(cwd, options) {
26461
26545
  return trustOptions;
26462
26546
  }
26463
26547
  function readTrustFile(path7) {
26464
- if (!existsSync18(path7)) {
26548
+ if (!existsSync19(path7)) {
26465
26549
  return {};
26466
26550
  }
26467
26551
  let parsed;
26468
26552
  try {
26469
- parsed = parseJsonFileContent(readFileSync13(path7, "utf-8"));
26553
+ parsed = parseJsonFileContent(readFileSync14(path7, "utf-8"));
26470
26554
  } catch (error) {
26471
26555
  const message = error instanceof Error ? error.message : String(error);
26472
26556
  throw new Error(`Failed to read trust store ${path7}: ${message}`);
@@ -26491,12 +26575,12 @@ function writeTrustFile(path7, data) {
26491
26575
  sorted[key] = value;
26492
26576
  }
26493
26577
  }
26494
- mkdirSync7(dirname11(path7), { recursive: true });
26578
+ mkdirSync7(dirname12(path7), { recursive: true });
26495
26579
  writeFileSync9(path7, `${JSON.stringify(sorted, null, 2)}
26496
26580
  `, "utf-8");
26497
26581
  }
26498
26582
  function acquireTrustLockSync(path7) {
26499
- const trustDir = dirname11(path7);
26583
+ const trustDir = dirname12(path7);
26500
26584
  mkdirSync7(trustDir, { recursive: true });
26501
26585
  const maxAttempts = 10;
26502
26586
  const delayMs = 20;
@@ -26530,22 +26614,22 @@ function withTrustFileLock(path7, fn) {
26530
26614
  function hasTrustRequiringConfigResources(cwd) {
26531
26615
  const projectCwd = canonicalizePath(resolvePath(cwd));
26532
26616
  return CONFIG_DIR_NAMES.some((configDirName) => {
26533
- const configDir = join29(projectCwd, configDirName);
26534
- return TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync18(join29(configDir, entry)));
26617
+ const configDir = join30(projectCwd, configDirName);
26618
+ return TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync19(join30(configDir, entry)));
26535
26619
  });
26536
26620
  }
26537
26621
  function hasTrustRequiringProjectResources(cwd) {
26538
26622
  if (hasTrustRequiringConfigResources(cwd)) {
26539
26623
  return true;
26540
26624
  }
26541
- const userGlobalSkillsDir = canonicalizePath(resolvePath(join29(getHomeDir(), ".agents", "skills")));
26625
+ const userGlobalSkillsDir = canonicalizePath(resolvePath(join30(getHomeDir(), ".agents", "skills")));
26542
26626
  let currentDir = canonicalizePath(resolvePath(cwd));
26543
26627
  while (true) {
26544
- const skillsDir = canonicalizePath(resolvePath(join29(currentDir, ".agents", "skills")));
26545
- if (skillsDir !== userGlobalSkillsDir && existsSync18(skillsDir)) {
26628
+ const skillsDir = canonicalizePath(resolvePath(join30(currentDir, ".agents", "skills")));
26629
+ if (skillsDir !== userGlobalSkillsDir && existsSync19(skillsDir)) {
26546
26630
  return true;
26547
26631
  }
26548
- const parentDir = dirname11(currentDir);
26632
+ const parentDir = dirname12(currentDir);
26549
26633
  if (parentDir === currentDir) {
26550
26634
  return false;
26551
26635
  }
@@ -26556,7 +26640,7 @@ function hasTrustRequiringProjectResources(cwd) {
26556
26640
  class ProjectTrustStore {
26557
26641
  trustPath;
26558
26642
  constructor(agentDir) {
26559
- this.trustPath = join29(resolvePath(agentDir), "trust.json");
26643
+ this.trustPath = join30(resolvePath(agentDir), "trust.json");
26560
26644
  }
26561
26645
  get(cwd) {
26562
26646
  return this.getEntry(cwd)?.decision ?? null;
@@ -31325,7 +31409,7 @@ var init_hashline = __esm(() => {
31325
31409
  });
31326
31410
 
31327
31411
  // src/core/tools/notebook.ts
31328
- import { existsSync as existsSync19, readFileSync as readFileSync14 } from "node:fs";
31412
+ import { existsSync as existsSync20, readFileSync as readFileSync15 } from "node:fs";
31329
31413
  function isNotebookPath(absolutePath) {
31330
31414
  return /\.ipynb$/i.test(absolutePath);
31331
31415
  }
@@ -31427,11 +31511,11 @@ function applyNotebookEditableText(notebook, text, displayPath) {
31427
31511
  return next;
31428
31512
  }
31429
31513
  function readEditableNotebookText(absolutePath, displayPath) {
31430
- const notebook = existsSync19(absolutePath) ? parseNotebookSafe(readFileSync14(absolutePath, "utf8"), displayPath) : emptyNotebook();
31514
+ const notebook = existsSync20(absolutePath) ? parseNotebookSafe(readFileSync15(absolutePath, "utf8"), displayPath) : emptyNotebook();
31431
31515
  return notebookToEditableText(notebook);
31432
31516
  }
31433
31517
  function serializeEditedNotebookText(absolutePath, displayPath, text) {
31434
- const notebook = existsSync19(absolutePath) ? parseNotebookSafe(readFileSync14(absolutePath, "utf8"), displayPath) : emptyNotebook();
31518
+ const notebook = existsSync20(absolutePath) ? parseNotebookSafe(readFileSync15(absolutePath, "utf8"), displayPath) : emptyNotebook();
31435
31519
  const next = applyNotebookEditableText(notebook, text, displayPath);
31436
31520
  return JSON.stringify(next, null, 1);
31437
31521
  }
@@ -31762,10 +31846,10 @@ var init_management_http = __esm(() => {
31762
31846
 
31763
31847
  // src/utils/tools-manager.ts
31764
31848
  import { spawnSync as spawnSync5 } from "child_process";
31765
- import { chmodSync as chmodSync3, existsSync as existsSync20, mkdirSync as mkdirSync8, readdirSync as readdirSync5, renameSync, rmSync as rmSync4 } from "fs";
31849
+ import { chmodSync as chmodSync3, existsSync as existsSync21, mkdirSync as mkdirSync8, readdirSync as readdirSync5, renameSync, rmSync as rmSync4 } from "fs";
31766
31850
  import { writeFile } from "fs/promises";
31767
31851
  import { arch, platform as platform2 } from "os";
31768
- import { join as join30 } from "path";
31852
+ import { join as join31 } from "path";
31769
31853
  function isOfflineModeEnabled() {
31770
31854
  const value = getEnvValue(ENV_OFFLINE);
31771
31855
  if (!value)
@@ -31784,8 +31868,8 @@ function getToolPath(tool) {
31784
31868
  const config = TOOLS[tool];
31785
31869
  if (!config)
31786
31870
  return null;
31787
- const localPath = join30(TOOLS_DIR, config.binaryName + (platform2() === "win32" ? ".exe" : ""));
31788
- if (existsSync20(localPath)) {
31871
+ const localPath = join31(TOOLS_DIR, config.binaryName + (platform2() === "win32" ? ".exe" : ""));
31872
+ if (existsSync21(localPath)) {
31789
31873
  return localPath;
31790
31874
  }
31791
31875
  const systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];
@@ -31824,7 +31908,7 @@ function findBinaryRecursively(rootDir, binaryFileName) {
31824
31908
  continue;
31825
31909
  const entries = readdirSync5(currentDir, { withFileTypes: true });
31826
31910
  for (const entry of entries) {
31827
- const fullPath = join30(currentDir, entry.name);
31911
+ const fullPath = join31(currentDir, entry.name);
31828
31912
  if (entry.isFile() && entry.name === binaryFileName) {
31829
31913
  return fullPath;
31830
31914
  }
@@ -31865,8 +31949,8 @@ function extractTarGzArchive(archivePath, extractDir, assetName) {
31865
31949
  function getWindowsTarCommand() {
31866
31950
  const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
31867
31951
  if (systemRoot) {
31868
- const systemTar = join30(systemRoot, "System32", "tar.exe");
31869
- if (existsSync20(systemTar)) {
31952
+ const systemTar = join31(systemRoot, "System32", "tar.exe");
31953
+ if (existsSync21(systemTar)) {
31870
31954
  return systemTar;
31871
31955
  }
31872
31956
  }
@@ -31919,11 +32003,11 @@ async function downloadTool(tool) {
31919
32003
  }
31920
32004
  mkdirSync8(TOOLS_DIR, { recursive: true });
31921
32005
  const downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;
31922
- const archivePath = join30(TOOLS_DIR, assetName);
32006
+ const archivePath = join31(TOOLS_DIR, assetName);
31923
32007
  const binaryExt = plat === "win32" ? ".exe" : "";
31924
- const binaryPath = join30(TOOLS_DIR, config.binaryName + binaryExt);
32008
+ const binaryPath = join31(TOOLS_DIR, config.binaryName + binaryExt);
31925
32009
  await downloadFile(downloadUrl, archivePath);
31926
- const extractDir = join30(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
32010
+ const extractDir = join31(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
31927
32011
  mkdirSync8(extractDir, { recursive: true });
31928
32012
  try {
31929
32013
  if (assetName.endsWith(".tar.gz")) {
@@ -31934,9 +32018,9 @@ async function downloadTool(tool) {
31934
32018
  throw new Error(`Unsupported archive format: ${assetName}`);
31935
32019
  }
31936
32020
  const binaryFileName = config.binaryName + binaryExt;
31937
- const extractedDir = join30(extractDir, assetName.replace(/\.(tar\.gz|zip)$/, ""));
31938
- const extractedBinaryCandidates = [join30(extractedDir, binaryFileName), join30(extractDir, binaryFileName)];
31939
- let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync20(candidate));
32021
+ const extractedDir = join31(extractDir, assetName.replace(/\.(tar\.gz|zip)$/, ""));
32022
+ const extractedBinaryCandidates = [join31(extractedDir, binaryFileName), join31(extractDir, binaryFileName)];
32023
+ let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync21(candidate));
31940
32024
  if (!extractedBinary) {
31941
32025
  extractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;
31942
32026
  }
@@ -33524,7 +33608,7 @@ var init_read_selectors = __esm(() => {
33524
33608
  });
33525
33609
 
33526
33610
  // src/core/tools/read-document-extract.ts
33527
- import { existsSync as existsSync21 } from "node:fs";
33611
+ import { existsSync as existsSync22 } from "node:fs";
33528
33612
  function isDocumentPath(pathValue) {
33529
33613
  return DOCUMENT_EXTENSIONS.test(pathValue);
33530
33614
  }
@@ -33721,7 +33805,7 @@ function documentExtension(source) {
33721
33805
  }
33722
33806
  async function extractMarkitDocument(buffer, source) {
33723
33807
  const ext = documentExtension(source);
33724
- const result = existsSync21(source) ? await convertFileWithMarkit(source) : await convertBufferWithMarkit(buffer, ext);
33808
+ const result = existsSync22(source) ? await convertFileWithMarkit(source) : await convertBufferWithMarkit(buffer, ext);
33725
33809
  return result.ok ? result.content : `[Cannot read ${ext} file: ${result.error || "conversion failed"}]`;
33726
33810
  }
33727
33811
  async function extractDocumentMarkdown(buffer, source) {
@@ -34584,7 +34668,7 @@ var init_read_url = __esm(() => {
34584
34668
  });
34585
34669
 
34586
34670
  // src/core/tools/read.ts
34587
- import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute6, relative as relative7, resolve as resolvePath5, sep as sep6 } from "node:path";
34671
+ import { basename as basename5, dirname as dirname13, isAbsolute as isAbsolute6, relative as relative7, resolve as resolvePath5, sep as sep6 } from "node:path";
34588
34672
  import { Text as Text32 } from "@earendil-works/pi-tui";
34589
34673
  import { constants as constants5 } from "fs";
34590
34674
  import { access as fsAccess3, readFile as fsReadFile2, stat as fsStat4 } from "fs/promises";
@@ -34662,7 +34746,7 @@ function oversizedReadResult(details) {
34662
34746
  };
34663
34747
  }
34664
34748
  function getPiDocsClassification(absolutePath) {
34665
- const packageRoot = dirname12(getReadmePath());
34749
+ const packageRoot = dirname13(getReadmePath());
34666
34750
  const relativePath = relative7(resolvePath5(packageRoot), resolvePath5(absolutePath));
34667
34751
  if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${sep6}`) || isAbsolute6(relativePath)) {
34668
34752
  return;
@@ -34680,7 +34764,7 @@ function getCompactReadClassification(args, cwd) {
34680
34764
  const absolutePath = resolveToCwd(rawPath, cwd);
34681
34765
  const fileName = basename5(absolutePath);
34682
34766
  if (fileName === "SKILL.md") {
34683
- return { kind: "skill", label: basename5(dirname12(absolutePath)) || fileName };
34767
+ return { kind: "skill", label: basename5(dirname13(absolutePath)) || fileName };
34684
34768
  }
34685
34769
  const docsClassification = getPiDocsClassification(absolutePath);
34686
34770
  if (docsClassification)
@@ -35840,22 +35924,22 @@ function filterSearchOutputByLineRange(text, ranges, contextBefore = 1, contextA
35840
35924
  }
35841
35925
 
35842
35926
  // src/core/tools/search.ts
35843
- import { existsSync as existsSync22 } from "node:fs";
35927
+ import { existsSync as existsSync23 } from "node:fs";
35844
35928
  import { readFile as fsReadFile4, stat as fsStat6 } from "node:fs/promises";
35845
- import { dirname as dirname13, join as join31, resolve as resolvePath6 } from "node:path";
35929
+ import { dirname as dirname14, join as join32, resolve as resolvePath6 } from "node:path";
35846
35930
  import { Text as Text34 } from "@earendil-works/pi-tui";
35847
35931
  import { Type as Type9 } from "typebox";
35848
35932
  function delimiterInExistingSearchGlobRoot(value, cwd) {
35849
35933
  const selector = splitLineRangeSelector(value);
35850
35934
  const parsed = splitPathLikeGlob(selector.path);
35851
- return !!parsed.glob && /[;,\s]/.test(parsed.basePath) && existsSync22(resolveToCwd(parsed.basePath, cwd));
35935
+ return !!parsed.glob && /[;,\s]/.test(parsed.basePath) && existsSync23(resolveToCwd(parsed.basePath, cwd));
35852
35936
  }
35853
35937
  function archiveSelectorExists(value, cwd) {
35854
35938
  const archive = parseArchiveSelector(value);
35855
35939
  if (!archive)
35856
35940
  return false;
35857
35941
  const resolved = resolveArchiveSelector(archive, cwd);
35858
- if (!existsSync22(resolved.archivePath))
35942
+ if (!existsSync23(resolved.archivePath))
35859
35943
  return false;
35860
35944
  if (!resolved.memberPath)
35861
35945
  return true;
@@ -35871,7 +35955,7 @@ function searchPathResolvable(value, cwd) {
35871
35955
  if (archive)
35872
35956
  return archiveSelectorExists(selector.path, cwd);
35873
35957
  const sqlite = sqliteSelectorForPath(selector.path, cwd);
35874
- 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));
35958
+ 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));
35875
35959
  }
35876
35960
  function normalizePaths(pathsValue, cwd) {
35877
35961
  const inputs = Array.isArray(pathsValue) ? pathsValue.length > 0 ? pathsValue : ["."] : pathsValue === undefined ? ["."] : [pathsValue];
@@ -35883,7 +35967,7 @@ function normalizePaths(pathsValue, cwd) {
35883
35967
  continue;
35884
35968
  }
35885
35969
  const resourceLike = /^[a-z]+:\/\//i.test(raw) || /^[^:]+\.(?:zip|jar|tar|tgz|gz|sqlite|db):/i.test(raw);
35886
- if (existsSync22(resolveToCwd(splitLineRangeSelector(raw).path, cwd)) || delimiterInExistingSearchGlobRoot(raw, cwd) || archiveSelectorExists(raw, cwd)) {
35970
+ if (existsSync23(resolveToCwd(splitLineRangeSelector(raw).path, cwd)) || delimiterInExistingSearchGlobRoot(raw, cwd) || archiveSelectorExists(raw, cwd)) {
35887
35971
  expanded.push(raw);
35888
35972
  continue;
35889
35973
  }
@@ -36068,7 +36152,7 @@ async function addHashlineHeadersToSearchOutput(text, cwd, targetPath, hashlineS
36068
36152
  const rendered = [];
36069
36153
  let lastDir = "";
36070
36154
  for (const group of groups) {
36071
- let absolutePath = targetIsFile ? searchRoot : join31(searchRoot, group.path);
36155
+ let absolutePath = targetIsFile ? searchRoot : join32(searchRoot, group.path);
36072
36156
  try {
36073
36157
  await fsReadFile4(absolutePath);
36074
36158
  } catch {
@@ -36077,7 +36161,7 @@ async function addHashlineHeadersToSearchOutput(text, cwd, targetPath, hashlineS
36077
36161
  try {
36078
36162
  const content = await fsReadFile4(absolutePath, "utf-8");
36079
36163
  const snapshot = recordHashlineSnapshot(absolutePath, cwd, content, hashlineStore);
36080
- const dir = dirname13(snapshot.displayPath);
36164
+ const dir = dirname14(snapshot.displayPath);
36081
36165
  if (dir !== "." && dir !== lastDir) {
36082
36166
  rendered.push(`# ${dir}/`);
36083
36167
  lastDir = dir;
@@ -36742,7 +36826,7 @@ var init_todos_locks = __esm(() => {
36742
36826
 
36743
36827
  // src/core/tools/todos-storage.ts
36744
36828
  import crypto3 from "node:crypto";
36745
- import { existsSync as existsSync23 } from "node:fs";
36829
+ import { existsSync as existsSync24 } from "node:fs";
36746
36830
  import fs7 from "node:fs/promises";
36747
36831
  import path11 from "node:path";
36748
36832
  function parseFrontMatter(text, idFallback) {
@@ -36874,7 +36958,7 @@ async function generateTodoId(todosDir) {
36874
36958
  for (let attempt = 0;attempt < 10; attempt += 1) {
36875
36959
  const id = crypto3.randomBytes(4).toString("hex");
36876
36960
  const todoPath = getTodoPath(todosDir, id);
36877
- if (!existsSync23(todoPath))
36961
+ if (!existsSync24(todoPath))
36878
36962
  return id;
36879
36963
  }
36880
36964
  throw new Error("Failed to generate unique todo id");
@@ -36909,7 +36993,7 @@ async function listTodos(todosDir) {
36909
36993
  return sortTodos(todos);
36910
36994
  }
36911
36995
  async function ensureTodoExists(filePath, id) {
36912
- if (!existsSync23(filePath))
36996
+ if (!existsSync24(filePath))
36913
36997
  return null;
36914
36998
  return readTodoFile(filePath, id);
36915
36999
  }
@@ -36928,7 +37012,7 @@ var init_todos_storage = __esm(() => {
36928
37012
  });
36929
37013
 
36930
37014
  // src/core/tools/todos-mutations.ts
36931
- import { existsSync as existsSync24 } from "node:fs";
37015
+ import { existsSync as existsSync25 } from "node:fs";
36932
37016
  import fs8 from "node:fs/promises";
36933
37017
  async function claimTodoAssignment(todosDir, id, ctx, force = false) {
36934
37018
  const validated = validateTodoId(id);
@@ -36937,7 +37021,7 @@ async function claimTodoAssignment(todosDir, id, ctx, force = false) {
36937
37021
  }
36938
37022
  const normalizedId = validated.id;
36939
37023
  const filePath = getTodoPath(todosDir, normalizedId);
36940
- if (!existsSync24(filePath)) {
37024
+ if (!existsSync25(filePath)) {
36941
37025
  return { error: `Todo ${displayTodoId(id)} not found` };
36942
37026
  }
36943
37027
  const sessionId = ctx.sessionManager.getSessionId();
@@ -36968,7 +37052,7 @@ async function releaseTodoAssignment(todosDir, id, ctx, force = false) {
36968
37052
  }
36969
37053
  const normalizedId = validated.id;
36970
37054
  const filePath = getTodoPath(todosDir, normalizedId);
36971
- if (!existsSync24(filePath)) {
37055
+ if (!existsSync25(filePath)) {
36972
37056
  return { error: `Todo ${displayTodoId(id)} not found` };
36973
37057
  }
36974
37058
  const sessionId = ctx.sessionManager.getSessionId();
@@ -36997,7 +37081,7 @@ async function deleteTodo(todosDir, id, ctx) {
36997
37081
  }
36998
37082
  const normalizedId = validated.id;
36999
37083
  const filePath = getTodoPath(todosDir, normalizedId);
37000
- if (!existsSync24(filePath)) {
37084
+ if (!existsSync25(filePath)) {
37001
37085
  return { error: `Todo ${displayTodoId(id)} not found` };
37002
37086
  }
37003
37087
  return withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37169,7 +37253,7 @@ var init_todos_render = __esm(() => {
37169
37253
  });
37170
37254
 
37171
37255
  // src/core/tools/todos-execute.ts
37172
- import { existsSync as existsSync25 } from "node:fs";
37256
+ import { existsSync as existsSync26 } from "node:fs";
37173
37257
  function todoActionResult(action, text, detailsError) {
37174
37258
  return {
37175
37259
  content: [{ type: "text", text }],
@@ -37253,7 +37337,7 @@ async function executeUpdateAction(todosDir, params, ctx) {
37253
37337
  const normalizedId = validated.id;
37254
37338
  const displayId = formatTodoId(normalizedId);
37255
37339
  const filePath = getTodoPath(todosDir, normalizedId);
37256
- if (!existsSync25(filePath)) {
37340
+ if (!existsSync26(filePath)) {
37257
37341
  return todoActionResult("update", `Todo ${displayId} not found`, "not found");
37258
37342
  }
37259
37343
  const result = await withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37290,7 +37374,7 @@ async function executeAppendAction(todosDir, params, ctx) {
37290
37374
  const normalizedId = validated.id;
37291
37375
  const displayId = formatTodoId(normalizedId);
37292
37376
  const filePath = getTodoPath(todosDir, normalizedId);
37293
- if (!existsSync25(filePath)) {
37377
+ if (!existsSync26(filePath)) {
37294
37378
  return todoActionResult("append", `Todo ${displayId} not found`, "not found");
37295
37379
  }
37296
37380
  const result = await withTodoLock(todosDir, normalizedId, ctx, async () => {
@@ -37410,7 +37494,7 @@ import {
37410
37494
  stat as fsStat7,
37411
37495
  writeFile as fsWriteFile2
37412
37496
  } from "fs/promises";
37413
- import { dirname as dirname14, join as join32 } from "path";
37497
+ import { dirname as dirname15, join as join33 } from "path";
37414
37498
  import { Type as Type11 } from "typebox";
37415
37499
  async function findConflictBlocks(root, limit = 100) {
37416
37500
  const out = [];
@@ -37418,7 +37502,7 @@ async function findConflictBlocks(root, limit = 100) {
37418
37502
  for (const entry of await fsReaddir2(dir, { withFileTypes: true }).catch(() => [])) {
37419
37503
  if (out.length >= limit || entry.name === ".git" || entry.name === "node_modules")
37420
37504
  continue;
37421
- const full = join32(dir, entry.name);
37505
+ const full = join33(dir, entry.name);
37422
37506
  if (entry.isDirectory())
37423
37507
  await walk(full);
37424
37508
  else if (entry.isFile()) {
@@ -37708,7 +37792,7 @@ ${headers[0]}` : ""}` }],
37708
37792
  };
37709
37793
  }
37710
37794
  const absolutePath = resolveToCwd(path12, cwd);
37711
- const dir = dirname14(absolutePath);
37795
+ const dir = dirname15(absolutePath);
37712
37796
  return withFileMutationQueue(absolutePath, async () => {
37713
37797
  const throwIfAborted2 = () => {
37714
37798
  if (signal?.aborted)
@@ -38215,20 +38299,20 @@ import {
38215
38299
  lstatSync as lstatSync2,
38216
38300
  openSync as openSync3,
38217
38301
  readdirSync as readdirSync6,
38218
- readFileSync as readFileSync15,
38302
+ readFileSync as readFileSync16,
38219
38303
  renameSync as renameSync2,
38220
38304
  rmSync as rmSync5,
38221
38305
  statSync as statSync6,
38222
38306
  unlinkSync as unlinkSync4,
38223
38307
  writeSync
38224
38308
  } from "node:fs";
38225
- import { join as join33 } from "node:path";
38309
+ import { join as join34 } from "node:path";
38226
38310
  function getCleanupControlRoot() {
38227
- return join33(getTempRootDir(), CLEANUP_CONTROL_SUBDIR);
38311
+ return join34(getTempRootDir(), CLEANUP_CONTROL_SUBDIR);
38228
38312
  }
38229
38313
  function getCleanupControlDir(target, controlRoot) {
38230
38314
  const key = createHash3("sha256").update(target).digest("hex").slice(0, 16);
38231
- return join33(controlRoot ?? getCleanupControlRoot(), key);
38315
+ return join34(controlRoot ?? getCleanupControlRoot(), key);
38232
38316
  }
38233
38317
  function sameFileIdentity2(left, right) {
38234
38318
  return left.dev === right.dev && left.ino === right.ino;
@@ -38355,7 +38439,7 @@ function breakStaleLock(lockPath, observedMtimeMs) {
38355
38439
  }
38356
38440
  function ownsCleanupLock(lockPath, lock) {
38357
38441
  try {
38358
- return pathIdentifiesFile(lockPath, lock) && readFileSync15(lockPath, "utf-8") === lock.token && pathIdentifiesFile(lockPath, lock);
38442
+ return pathIdentifiesFile(lockPath, lock) && readFileSync16(lockPath, "utf-8") === lock.token && pathIdentifiesFile(lockPath, lock);
38359
38443
  } catch {
38360
38444
  return false;
38361
38445
  }
@@ -38444,7 +38528,7 @@ function scanFreshness(entryPath, cutoff, depth = 0) {
38444
38528
  }
38445
38529
  let foundUnknown = false;
38446
38530
  for (const child of children) {
38447
- const freshness = scanFreshness(join33(entryPath, child), cutoff, depth + 1);
38531
+ const freshness = scanFreshness(join34(entryPath, child), cutoff, depth + 1);
38448
38532
  if (freshness === "fresh") {
38449
38533
  return "fresh";
38450
38534
  }
@@ -38462,11 +38546,11 @@ function withCleanupGate(controlDir, options, scan) {
38462
38546
  } catch {
38463
38547
  return "locked";
38464
38548
  }
38465
- const markerPath = join33(controlDir, CLEANUP_MARKER_FILE);
38549
+ const markerPath = join34(controlDir, CLEANUP_MARKER_FILE);
38466
38550
  if (markerIsFresh(markerPath, now, throttleMs)) {
38467
38551
  return "throttled";
38468
38552
  }
38469
- const lockPath = join33(controlDir, CLEANUP_LOCK_FILE);
38553
+ const lockPath = join34(controlDir, CLEANUP_LOCK_FILE);
38470
38554
  const token = acquireCleanupLock(lockPath, now, SESSION_TEMP_CLEANUP_LOCK_STALE_MS);
38471
38555
  if (token === null) {
38472
38556
  return "locked";
@@ -38517,7 +38601,7 @@ function sweepSessionTempRoot(root = getTempRootDir(), options = {}) {
38517
38601
  if (isCleanupArtifact(entry)) {
38518
38602
  continue;
38519
38603
  }
38520
- const entryPath = join33(root, entry);
38604
+ const entryPath = join34(root, entry);
38521
38605
  if (gate.protectedPaths.has(entryPath)) {
38522
38606
  continue;
38523
38607
  }
@@ -38542,7 +38626,7 @@ function sweepSessionTempRoot(root = getTempRootDir(), options = {}) {
38542
38626
  });
38543
38627
  }
38544
38628
  function reapToolResultsDir(parent, cutoff, protectedPaths) {
38545
- const toolResultsDir = join33(parent, TOOL_RESULTS_SUBDIR);
38629
+ const toolResultsDir = join34(parent, TOOL_RESULTS_SUBDIR);
38546
38630
  if (protectedPaths.has(toolResultsDir) || !isRealDirectory2(toolResultsDir)) {
38547
38631
  return;
38548
38632
  }
@@ -38567,7 +38651,7 @@ function sweepToolResultsRoot(sessionsRoot, options = {}) {
38567
38651
  return;
38568
38652
  }
38569
38653
  for (const entry of entries) {
38570
- const projectDir = join33(sessionsRoot, entry);
38654
+ const projectDir = join34(sessionsRoot, entry);
38571
38655
  if (!isRealDirectory2(projectDir) || gate.protectedPaths.has(projectDir)) {
38572
38656
  continue;
38573
38657
  }
@@ -38808,7 +38892,7 @@ function parseSkillBlock(text) {
38808
38892
  }
38809
38893
 
38810
38894
  // src/core/agent-session.ts
38811
- import { join as join34 } from "node:path";
38895
+ import { join as join35 } from "node:path";
38812
38896
 
38813
38897
  class AgentSessionBase {
38814
38898
  agent;
@@ -38931,7 +39015,7 @@ class AgentSessionBase {
38931
39015
  const sessionDir = this.sessionManager.getSessionDir() || undefined;
38932
39016
  this._tempStorageLease = acquireProtectedPaths([
38933
39017
  setActiveSessionTempId(sessionId),
38934
- ...sessionDir ? [join34(sessionDir, TOOL_RESULTS_SUBDIR)] : []
39018
+ ...sessionDir ? [join35(sessionDir, TOOL_RESULTS_SUBDIR)] : []
38935
39019
  ]);
38936
39020
  const customSessionDir = this.sessionManager.usesDefaultSessionDir() ? undefined : sessionDir;
38937
39021
  scheduleSessionTempCleanup(customSessionDir ? { sessionDirs: [customSessionDir] } : {});
@@ -38990,30 +39074,8 @@ var init_auth_storage = __esm(() => {
38990
39074
  init_auth_storage_backends();
38991
39075
  });
38992
39076
 
38993
- // src/core/builtin-install-layout.ts
38994
- function requiredEntriesForBuiltin(dirName) {
38995
- return [INSTALLED_EXTENSION_ENTRIES[dirName], SOURCE_EXTENSION_ENTRIES[dirName]];
38996
- }
38997
- var SOURCE_EXTENSION_ENTRIES, INSTALLED_EXTENSION_ENTRIES;
38998
- var init_builtin_install_layout = __esm(() => {
38999
- SOURCE_EXTENSION_ENTRIES = {
39000
- workflows: "src/extension/index.ts",
39001
- subagents: "src/extension/index.ts",
39002
- mcp: "index.ts",
39003
- "web-access": "index.ts",
39004
- intercom: "index.ts"
39005
- };
39006
- INSTALLED_EXTENSION_ENTRIES = {
39007
- workflows: "src/extension/index.bundle.mjs",
39008
- subagents: "src/extension/index.bundle.mjs",
39009
- mcp: "index.bundle.mjs",
39010
- "web-access": "index.bundle.mjs",
39011
- intercom: "index.bundle.mjs"
39012
- };
39013
- });
39014
-
39015
39077
  // src/core/builtin-packages.ts
39016
- import { join as join35, resolve as resolve8 } from "node:path";
39078
+ import { join as join36, resolve as resolve8 } from "node:path";
39017
39079
  var WORKSPACE_BUILTINS, BUILTIN_PACKAGES;
39018
39080
  var init_builtin_packages = __esm(() => {
39019
39081
  init_config();
@@ -39030,7 +39092,7 @@ var init_builtin_packages = __esm(() => {
39030
39092
  packageName: spec.packageName,
39031
39093
  distDirName: spec.distDirName,
39032
39094
  requiredEntries: requiredEntriesForBuiltin(spec.distDirName),
39033
- sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join35(packageDir, "..", spec.workspaceDirName), join35(here, "..", "..", "..", spec.workspaceDirName)] : []
39095
+ sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join36(packageDir, "..", spec.workspaceDirName), join36(here, "..", "..", "..", spec.workspaceDirName)] : []
39034
39096
  }));
39035
39097
  });
39036
39098
 
@@ -39288,14 +39350,14 @@ var init_git_env = __esm(() => {
39288
39350
  });
39289
39351
 
39290
39352
  // src/core/package-manager-env.ts
39291
- import { readFileSync as readFileSync16 } from "node:fs";
39353
+ import { readFileSync as readFileSync17 } from "node:fs";
39292
39354
  import { basename as basename6 } from "node:path";
39293
39355
  function getEnv() {
39294
39356
  if (process.platform !== "linux" || Object.keys(process.env).length > 0) {
39295
39357
  return process.env;
39296
39358
  }
39297
39359
  try {
39298
- const data = readFileSync16("/proc/self/environ", "utf-8");
39360
+ const data = readFileSync17("/proc/self/environ", "utf-8");
39299
39361
  const env = {};
39300
39362
  for (const entry of data.split("\x00")) {
39301
39363
  const idx = entry.indexOf("=");
@@ -39527,13 +39589,13 @@ var NETWORK_TIMEOUT_MS2 = 1e4, UPDATE_CHECK_CONCURRENCY = 4, GIT_UPDATE_CONCURRE
39527
39589
  // src/core/package-manager-paths.ts
39528
39590
  import { createHash as createHash4 } from "node:crypto";
39529
39591
  import { homedir as homedir6, tmpdir as tmpdir5 } from "node:os";
39530
- import { join as join36 } from "node:path";
39592
+ import { join as join37 } from "node:path";
39531
39593
  function getHomeDir2() {
39532
39594
  return process.env.HOME || homedir6();
39533
39595
  }
39534
39596
  function getTemporaryDir(prefix, suffix) {
39535
39597
  const hash = createHash4("sha256").update(`${prefix}-${suffix ?? ""}`).digest("hex").slice(0, 8);
39536
- return join36(tmpdir5(), `${APP_NAME}-extensions`, prefix, hash, suffix ?? "");
39598
+ return join37(tmpdir5(), `${APP_NAME}-extensions`, prefix, hash, suffix ?? "");
39537
39599
  }
39538
39600
  function getBaseDirsForScope(context, scope) {
39539
39601
  if (scope === "project") {
@@ -39558,27 +39620,27 @@ function getNpmInstallRoot(context, scope, temporary) {
39558
39620
  return getTemporaryDir("npm");
39559
39621
  }
39560
39622
  if (scope === "project") {
39561
- return join36(context.cwd, CONFIG_DIR_NAME, "npm");
39623
+ return join37(context.cwd, CONFIG_DIR_NAME, "npm");
39562
39624
  }
39563
- return join36(context.agentDir, "npm");
39625
+ return join37(context.agentDir, "npm");
39564
39626
  }
39565
39627
  function getGitInstallPath(context, source, scope) {
39566
39628
  if (scope === "temporary") {
39567
39629
  return getTemporaryDir(`git-${source.host}`, source.path);
39568
39630
  }
39569
39631
  if (scope === "project") {
39570
- return join36(context.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
39632
+ return join37(context.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
39571
39633
  }
39572
- return join36(context.agentDir, "git", source.host, source.path);
39634
+ return join37(context.agentDir, "git", source.host, source.path);
39573
39635
  }
39574
39636
  function getGitInstallRoot(context, scope) {
39575
39637
  if (scope === "temporary") {
39576
39638
  return;
39577
39639
  }
39578
39640
  if (scope === "project") {
39579
- return join36(context.cwd, CONFIG_DIR_NAME, "git");
39641
+ return join37(context.cwd, CONFIG_DIR_NAME, "git");
39580
39642
  }
39581
- return join36(context.agentDir, "git");
39643
+ return join37(context.agentDir, "git");
39582
39644
  }
39583
39645
  var init_package_manager_paths = __esm(() => {
39584
39646
  init_config();
@@ -39586,8 +39648,8 @@ var init_package_manager_paths = __esm(() => {
39586
39648
  });
39587
39649
 
39588
39650
  // src/core/package-manager-npm.ts
39589
- import { existsSync as existsSync26, mkdirSync as mkdirSync9, readFileSync as readFileSync17, writeFileSync as writeFileSync10 } from "node:fs";
39590
- import { basename as basename7, dirname as dirname15, join as join37 } from "node:path";
39651
+ import { existsSync as existsSync27, mkdirSync as mkdirSync9, readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "node:fs";
39652
+ import { basename as basename7, dirname as dirname16, join as join38 } from "node:path";
39591
39653
  import { maxSatisfying, rcompare, satisfies } from "semver";
39592
39654
  function getNpmCommand(context) {
39593
39655
  const configuredCommand = context.settingsManager.getNpmCommand();
@@ -39654,7 +39716,7 @@ async function installNpm(context, source, scope, temporary) {
39654
39716
  }
39655
39717
  async function uninstallNpm(context, source, scope) {
39656
39718
  const installRoot = getNpmInstallRoot(context, scope, false);
39657
- if (!existsSync26(installRoot)) {
39719
+ if (!existsSync27(installRoot)) {
39658
39720
  return;
39659
39721
  }
39660
39722
  if (getPackageManagerName(context) === "bun") {
@@ -39669,23 +39731,23 @@ async function installNpmBatch(context, specs, scope) {
39669
39731
  await runNpmCommand(context, getNpmInstallArgs(context, specs, installRoot));
39670
39732
  }
39671
39733
  function ensureNpmProject(installRoot) {
39672
- if (!existsSync26(installRoot)) {
39734
+ if (!existsSync27(installRoot)) {
39673
39735
  mkdirSync9(installRoot, { recursive: true });
39674
39736
  }
39675
39737
  markPathIgnoredByCloudSync(installRoot);
39676
39738
  ensureGitIgnore(installRoot);
39677
- const packageJsonPath = join37(installRoot, "package.json");
39678
- if (!existsSync26(packageJsonPath)) {
39739
+ const packageJsonPath = join38(installRoot, "package.json");
39740
+ if (!existsSync27(packageJsonPath)) {
39679
39741
  const pkgJson = { name: `${APP_NAME}-extensions`, private: true };
39680
39742
  writeFileSync10(packageJsonPath, JSON.stringify(pkgJson, null, 2), "utf-8");
39681
39743
  }
39682
39744
  }
39683
39745
  function ensureGitIgnore(dir) {
39684
- if (!existsSync26(dir)) {
39746
+ if (!existsSync27(dir)) {
39685
39747
  mkdirSync9(dir, { recursive: true });
39686
39748
  }
39687
- const ignorePath = join37(dir, ".gitignore");
39688
- if (!existsSync26(ignorePath)) {
39749
+ const ignorePath = join38(dir, ".gitignore");
39750
+ if (!existsSync27(ignorePath)) {
39689
39751
  writeFileSync10(ignorePath, `*
39690
39752
  !.gitignore
39691
39753
  `, "utf-8");
@@ -39693,12 +39755,12 @@ function ensureGitIgnore(dir) {
39693
39755
  }
39694
39756
  function getManagedNpmInstallPath(context, source, scope) {
39695
39757
  if (scope === "temporary") {
39696
- return join37(getNpmInstallRoot(context, scope, true), "node_modules", source.name);
39758
+ return join38(getNpmInstallRoot(context, scope, true), "node_modules", source.name);
39697
39759
  }
39698
39760
  if (scope === "project") {
39699
- return join37(context.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
39761
+ return join38(context.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
39700
39762
  }
39701
- return join37(context.agentDir, "npm", "node_modules", source.name);
39763
+ return join38(context.agentDir, "npm", "node_modules", source.name);
39702
39764
  }
39703
39765
  function getGlobalNpmRoot(context) {
39704
39766
  const npmCommand = getNpmCommand(context);
@@ -39708,7 +39770,7 @@ function getGlobalNpmRoot(context) {
39708
39770
  }
39709
39771
  if (getPackageManagerName(context) === "bun") {
39710
39772
  const binDir = runNpmCommandSync(context, ["pm", "bin", "-g"]).trim();
39711
- context.globalNpmRoot = join37(dirname15(binDir), "install", "global", "node_modules");
39773
+ context.globalNpmRoot = join38(dirname16(binDir), "install", "global", "node_modules");
39712
39774
  } else {
39713
39775
  context.globalNpmRoot = runNpmCommandSync(context, ["root", "-g"]).trim();
39714
39776
  }
@@ -39734,28 +39796,28 @@ function getLegacyGlobalNpmInstallPath(context, source) {
39734
39796
  if (pnpmPath)
39735
39797
  return pnpmPath;
39736
39798
  const globalRoot = context.driver?.getGlobalNpmRoot ? context.driver.getGlobalNpmRoot() : getGlobalNpmRoot(context);
39737
- return join37(globalRoot, source.name);
39799
+ return join38(globalRoot, source.name);
39738
39800
  } catch {
39739
39801
  return;
39740
39802
  }
39741
39803
  }
39742
39804
  function getNpmInstallPath(context, source, scope) {
39743
39805
  const managedPath = getManagedNpmInstallPath(context, source, scope);
39744
- if (scope !== "user" || existsSync26(managedPath)) {
39806
+ if (scope !== "user" || existsSync27(managedPath)) {
39745
39807
  return managedPath;
39746
39808
  }
39747
39809
  const legacyPath = getLegacyGlobalNpmInstallPath(context, source);
39748
- return legacyPath && existsSync26(legacyPath) ? legacyPath : managedPath;
39810
+ return legacyPath && existsSync27(legacyPath) ? legacyPath : managedPath;
39749
39811
  }
39750
39812
  function getExistingNpmInstallPath(context, source, scope) {
39751
39813
  const candidates = [getNpmInstallPath(context, source, scope)];
39752
39814
  if (scope === "project") {
39753
39815
  for (const configDir of getProjectConfigDirs(context.cwd)) {
39754
- candidates.push(join37(configDir, "npm", "node_modules", source.name));
39816
+ candidates.push(join38(configDir, "npm", "node_modules", source.name));
39755
39817
  }
39756
39818
  }
39757
39819
  for (const candidate of Array.from(new Set(candidates))) {
39758
- if (existsSync26(candidate))
39820
+ if (existsSync27(candidate))
39759
39821
  return candidate;
39760
39822
  }
39761
39823
  return;
@@ -39792,11 +39854,11 @@ async function npmHasAvailableUpdate(context, source, installedPath) {
39792
39854
  }
39793
39855
  }
39794
39856
  function getInstalledNpmVersion(installedPath) {
39795
- const packageJsonPath = join37(installedPath, "package.json");
39796
- if (!existsSync26(packageJsonPath))
39857
+ const packageJsonPath = join38(installedPath, "package.json");
39858
+ if (!existsSync27(packageJsonPath))
39797
39859
  return;
39798
39860
  try {
39799
- const content = readFileSync17(packageJsonPath, "utf-8");
39861
+ const content = readFileSync18(packageJsonPath, "utf-8");
39800
39862
  const pkg2 = JSON.parse(content);
39801
39863
  return pkg2.version;
39802
39864
  } catch {
@@ -39851,8 +39913,8 @@ async function withProgress(context, action, source, message, operation) {
39851
39913
  }
39852
39914
 
39853
39915
  // src/core/package-manager-git.ts
39854
- import { existsSync as existsSync27, mkdirSync as mkdirSync10, readdirSync as readdirSync7, readFileSync as readFileSync18, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "node:fs";
39855
- import { basename as basename8, dirname as dirname16, join as join38, resolve as resolve9, sep as sep7 } from "node:path";
39916
+ import { existsSync as existsSync28, mkdirSync as mkdirSync10, readdirSync as readdirSync7, readFileSync as readFileSync19, rmSync as rmSync6, writeFileSync as writeFileSync11 } from "node:fs";
39917
+ import { basename as basename8, dirname as dirname17, join as join39, resolve as resolve9, sep as sep7 } from "node:path";
39856
39918
  function runGitProcess(context, command, args, options) {
39857
39919
  return context.driver ? context.driver.runCommand(command, args, options) : runCommand2(command, args, options);
39858
39920
  }
@@ -39881,28 +39943,28 @@ function getExistingGitInstallPath(context, source, scope) {
39881
39943
  const candidates = [getGitInstallPath(context, source, scope)];
39882
39944
  if (scope === "project") {
39883
39945
  for (const configDir of getProjectConfigDirs(context.cwd)) {
39884
- candidates.push(join38(configDir, "git", source.host, source.path));
39946
+ candidates.push(join39(configDir, "git", source.host, source.path));
39885
39947
  }
39886
39948
  } else if (scope === "user") {
39887
39949
  for (const agentDir of getBaseDirsForScope(context, "user")) {
39888
- candidates.push(join38(agentDir, "git", source.host, source.path));
39950
+ candidates.push(join39(agentDir, "git", source.host, source.path));
39889
39951
  }
39890
39952
  }
39891
39953
  for (const candidate of Array.from(new Set(candidates))) {
39892
- if (existsSync27(candidate))
39954
+ if (existsSync28(candidate))
39893
39955
  return candidate;
39894
39956
  }
39895
39957
  return;
39896
39958
  }
39897
39959
  function getGitUpdateMarkerPath(targetDir) {
39898
- return join38(dirname16(targetDir), `.${basename8(targetDir)}.${APP_NAME}-update-incomplete`);
39960
+ return join39(dirname17(targetDir), `.${basename8(targetDir)}.${APP_NAME}-update-incomplete`);
39899
39961
  }
39900
39962
  function hasMissingGitDependencies(targetDir) {
39901
- const packageJsonPath = join38(targetDir, "package.json");
39902
- if (!existsSync27(packageJsonPath))
39963
+ const packageJsonPath = join39(targetDir, "package.json");
39964
+ if (!existsSync28(packageJsonPath))
39903
39965
  return false;
39904
39966
  try {
39905
- const manifest = JSON.parse(readFileSync18(packageJsonPath, "utf-8"));
39967
+ const manifest = JSON.parse(readFileSync19(packageJsonPath, "utf-8"));
39906
39968
  if (!manifest.dependencies || typeof manifest.dependencies !== "object" || Array.isArray(manifest.dependencies)) {
39907
39969
  return false;
39908
39970
  }
@@ -39911,7 +39973,7 @@ function hasMissingGitDependencies(targetDir) {
39911
39973
  const dependencyPath = resolve9(nodeModulesDir, name);
39912
39974
  if (!dependencyPath.startsWith(`${nodeModulesDir}${sep7}`))
39913
39975
  return false;
39914
- return !existsSync27(dependencyPath);
39976
+ return !existsSync28(dependencyPath);
39915
39977
  });
39916
39978
  } catch {
39917
39979
  return false;
@@ -39929,7 +39991,7 @@ async function cleanAndInstallGitDependencies(context, targetDir, markerPath) {
39929
39991
  await repairMissingGitDependencies(context, targetDir).catch(() => {});
39930
39992
  throw error;
39931
39993
  }
39932
- if (existsSync27(join38(targetDir, "package.json"))) {
39994
+ if (existsSync28(join39(targetDir, "package.json"))) {
39933
39995
  await runNpmCommand(context, getGitDependencyInstallArgs(context), { cwd: targetDir });
39934
39996
  }
39935
39997
  rmSync6(markerPath, { force: true });
@@ -39937,7 +39999,7 @@ async function cleanAndInstallGitDependencies(context, targetDir, markerPath) {
39937
39999
  async function installGit(context, source, scope) {
39938
40000
  const safeRef = source.ref ? getSafeGitRef(source.ref) : undefined;
39939
40001
  const targetDir = getGitInstallPath(context, source, scope);
39940
- if (existsSync27(targetDir)) {
40002
+ if (existsSync28(targetDir)) {
39941
40003
  if (safeRef) {
39942
40004
  await ensureGitRef(context, targetDir, ["fetch", "origin", "--", safeRef], "FETCH_HEAD");
39943
40005
  return;
@@ -39950,7 +40012,7 @@ async function installGit(context, source, scope) {
39950
40012
  if (gitRoot) {
39951
40013
  ensureGitIgnore(gitRoot);
39952
40014
  }
39953
- mkdirSync10(dirname16(targetDir), { recursive: true });
40015
+ mkdirSync10(dirname17(targetDir), { recursive: true });
39954
40016
  rmSync6(getGitUpdateMarkerPath(targetDir), { force: true });
39955
40017
  const cloneUrl = source.repo;
39956
40018
  if (!/^[A-Za-z0-9._~:@/%+-]+$/.test(cloneUrl)) {
@@ -39961,8 +40023,8 @@ async function installGit(context, source, scope) {
39961
40023
  if (safeRef) {
39962
40024
  await runGitProcess(context, "git", ["checkout", safeRef], { cwd: targetDir });
39963
40025
  }
39964
- const packageJsonPath = join38(targetDir, "package.json");
39965
- if (existsSync27(packageJsonPath)) {
40026
+ const packageJsonPath = join39(targetDir, "package.json");
40027
+ if (existsSync28(packageJsonPath)) {
39966
40028
  await runNpmCommand(context, getGitDependencyInstallArgs(context), { cwd: targetDir });
39967
40029
  }
39968
40030
  } catch (error) {
@@ -39974,7 +40036,7 @@ async function installGit(context, source, scope) {
39974
40036
  async function updateGit(context, source, scope) {
39975
40037
  const safeRef = source.ref ? getSafeGitRef(source.ref) : undefined;
39976
40038
  const targetDir = getExistingGitInstallPath(context, source, scope) ?? getGitInstallPath(context, source, scope);
39977
- if (!existsSync27(targetDir)) {
40039
+ if (!existsSync28(targetDir)) {
39978
40040
  await installGit(context, source, scope);
39979
40041
  return;
39980
40042
  }
@@ -39998,7 +40060,7 @@ async function ensureGitRef(context, targetDir, fetchArgs, ref) {
39998
40060
  });
39999
40061
  const markerPath = getGitUpdateMarkerPath(targetDir);
40000
40062
  if (localHead.trim() === targetHead.trim()) {
40001
- if (existsSync27(markerPath)) {
40063
+ if (existsSync28(markerPath)) {
40002
40064
  await cleanAndInstallGitDependencies(context, targetDir, markerPath);
40003
40065
  } else {
40004
40066
  await repairMissingGitDependencies(context, targetDir);
@@ -40029,10 +40091,10 @@ function pruneEmptyGitParents(targetDir, installRoot) {
40029
40091
  if (!installRoot)
40030
40092
  return;
40031
40093
  const resolvedRoot = resolve9(installRoot);
40032
- let current = dirname16(targetDir);
40094
+ let current = dirname17(targetDir);
40033
40095
  while (current.startsWith(resolvedRoot) && current !== resolvedRoot) {
40034
- if (!existsSync27(current)) {
40035
- current = dirname16(current);
40096
+ if (!existsSync28(current)) {
40097
+ current = dirname17(current);
40036
40098
  continue;
40037
40099
  }
40038
40100
  const entries = readdirSync7(current);
@@ -40043,7 +40105,7 @@ function pruneEmptyGitParents(targetDir, installRoot) {
40043
40105
  } catch {
40044
40106
  break;
40045
40107
  }
40046
- current = dirname16(current);
40108
+ current = dirname17(current);
40047
40109
  }
40048
40110
  }
40049
40111
  async function gitHasAvailableUpdate(context, installedPath) {
@@ -40498,7 +40560,7 @@ var init_package_manager_source = __esm(() => {
40498
40560
  });
40499
40561
 
40500
40562
  // src/core/package-manager-operations.ts
40501
- import { existsSync as existsSync28 } from "node:fs";
40563
+ import { existsSync as existsSync29 } from "node:fs";
40502
40564
  async function install2(context, source, options) {
40503
40565
  const parsed = parseSource(source);
40504
40566
  const scope = options?.local ? "project" : "user";
@@ -40514,7 +40576,7 @@ async function install2(context, source, options) {
40514
40576
  }
40515
40577
  if (parsed.type === "local") {
40516
40578
  const resolved = resolveManagerPath(context, parsed.path);
40517
- if (!existsSync28(resolved)) {
40579
+ if (!existsSync29(resolved)) {
40518
40580
  throw new Error(`Path does not exist: ${resolved}`);
40519
40581
  }
40520
40582
  return;
@@ -40624,7 +40686,7 @@ async function updateConfiguredSources(context, sources) {
40624
40686
  }
40625
40687
  async function shouldUpdateNpmSource(context, source, scope) {
40626
40688
  const installedPath = getManagedNpmInstallPath(context, source, scope);
40627
- const installedVersion = existsSync28(installedPath) ? getInstalledNpmVersion(installedPath) : undefined;
40689
+ const installedVersion = existsSync29(installedPath) ? getInstalledNpmVersion(installedPath) : undefined;
40628
40690
  if (!installedVersion)
40629
40691
  return true;
40630
40692
  try {
@@ -40661,7 +40723,7 @@ async function checkForAvailableUpdates(context) {
40661
40723
  return;
40662
40724
  if (parsed.type === "npm") {
40663
40725
  const installedPath2 = getNpmInstallPath(context, parsed, entry.scope);
40664
- if (!existsSync28(installedPath2))
40726
+ if (!existsSync29(installedPath2))
40665
40727
  return;
40666
40728
  const hasUpdate2 = await npmHasAvailableUpdate(context, parsed, installedPath2);
40667
40729
  if (!hasUpdate2)
@@ -40759,7 +40821,7 @@ var init_package_manager_resource_accumulator = __esm(() => {
40759
40821
  });
40760
40822
 
40761
40823
  // src/core/package-manager-resource-patterns.ts
40762
- import { basename as basename9, dirname as dirname17, relative as relative9, sep as sep8 } from "node:path";
40824
+ import { basename as basename9, dirname as dirname18, relative as relative9, sep as sep8 } from "node:path";
40763
40825
  import { minimatch } from "minimatch";
40764
40826
  function toPosixPath4(p) {
40765
40827
  return p.split(sep8).join("/");
@@ -40790,7 +40852,7 @@ function matchesAnyPattern(filePath, patterns, baseDir) {
40790
40852
  const name = basename9(filePath);
40791
40853
  const filePathPosix = toPosixPath4(filePath);
40792
40854
  const isSkillFile = name === "SKILL.md";
40793
- const parentDir = isSkillFile ? dirname17(filePath) : undefined;
40855
+ const parentDir = isSkillFile ? dirname18(filePath) : undefined;
40794
40856
  const parentRel = isSkillFile ? toPosixPath4(relative9(baseDir, parentDir)) : undefined;
40795
40857
  const parentName = isSkillFile ? basename9(parentDir) : undefined;
40796
40858
  const parentDirPosix = isSkillFile ? toPosixPath4(parentDir) : undefined;
@@ -40815,7 +40877,7 @@ function matchesAnyExactPattern(filePath, patterns, baseDir) {
40815
40877
  const name = basename9(filePath);
40816
40878
  const filePathPosix = toPosixPath4(filePath);
40817
40879
  const isSkillFile = name === "SKILL.md";
40818
- const parentDir = isSkillFile ? dirname17(filePath) : undefined;
40880
+ const parentDir = isSkillFile ? dirname18(filePath) : undefined;
40819
40881
  const parentRel = isSkillFile ? toPosixPath4(relative9(baseDir, parentDir)) : undefined;
40820
40882
  const parentDirPosix = isSkillFile ? toPosixPath4(parentDir) : undefined;
40821
40883
  return patterns.some((pattern) => {
@@ -40916,7 +40978,7 @@ var init_package_manager_types = __esm(() => {
40916
40978
 
40917
40979
  // src/core/package-manager-resource-files.ts
40918
40980
  import { access as access2, readdir as readdir3, readFile as readFile2, stat as stat3 } from "node:fs/promises";
40919
- import { dirname as dirname18, join as join39, relative as relative10, resolve as resolve10, sep as sep9 } from "node:path";
40981
+ import { dirname as dirname19, join as join40, relative as relative10, resolve as resolve10, sep as sep9 } from "node:path";
40920
40982
  import ignore2 from "ignore";
40921
40983
  async function exists(path12) {
40922
40984
  try {
@@ -40947,7 +41009,7 @@ async function addIgnoreRules(ig, dir, rootDir) {
40947
41009
  const prefix = relativeDir ? `${toPosixPath4(relativeDir)}/` : "";
40948
41010
  for (const filename of IGNORE_FILE_NAMES) {
40949
41011
  try {
40950
- const content = await readFile2(join39(dir, filename), "utf-8");
41012
+ const content = await readFile2(join40(dir, filename), "utf-8");
40951
41013
  const patterns = content.split(/\r?\n/).map((line) => prefixIgnorePattern(line, prefix)).filter((line) => Boolean(line));
40952
41014
  if (patterns.length > 0)
40953
41015
  ig.add(patterns);
@@ -40955,7 +41017,7 @@ async function addIgnoreRules(ig, dir, rootDir) {
40955
41017
  }
40956
41018
  }
40957
41019
  async function getEntryInfo(dir, name, isDirectory, isFileEntry, isSymlink) {
40958
- const fullPath = join39(dir, name);
41020
+ const fullPath = join40(dir, name);
40959
41021
  let isDir = isDirectory;
40960
41022
  let isFile = isFileEntry;
40961
41023
  if (isSymlink) {
@@ -41045,9 +41107,9 @@ async function collectAutoSkillEntries(dir, mode) {
41045
41107
  async function findGitRepoRoot(startDir) {
41046
41108
  let dir = resolve10(startDir);
41047
41109
  while (true) {
41048
- if (await exists(join39(dir, ".git")))
41110
+ if (await exists(join40(dir, ".git")))
41049
41111
  return dir;
41050
- const parent = dirname18(dir);
41112
+ const parent = dirname19(dir);
41051
41113
  if (parent === dir)
41052
41114
  return null;
41053
41115
  dir = parent;
@@ -41059,10 +41121,10 @@ async function collectAncestorAgentsSkillDirs(startDir) {
41059
41121
  const gitRepoRoot = await findGitRepoRoot(resolvedStartDir);
41060
41122
  let dir = resolvedStartDir;
41061
41123
  while (true) {
41062
- skillDirs.push(join39(dir, ".agents", "skills"));
41124
+ skillDirs.push(join40(dir, ".agents", "skills"));
41063
41125
  if (gitRepoRoot && dir === gitRepoRoot)
41064
41126
  break;
41065
- const parent = dirname18(dir);
41127
+ const parent = dirname19(dir);
41066
41128
  if (parent === dir)
41067
41129
  break;
41068
41130
  dir = parent;
@@ -41101,7 +41163,7 @@ async function collectAutoThemeEntries(dir) {
41101
41163
  return collectFlatEntries(dir, ".json");
41102
41164
  }
41103
41165
  async function resolveExtensionEntries(dir) {
41104
- const packageJsonPath = join39(dir, "package.json");
41166
+ const packageJsonPath = join40(dir, "package.json");
41105
41167
  if (await exists(packageJsonPath)) {
41106
41168
  try {
41107
41169
  const manifest = getManifestFromPackageJson(JSON.parse(await readFile2(packageJsonPath, "utf-8")));
@@ -41117,8 +41179,8 @@ async function resolveExtensionEntries(dir) {
41117
41179
  }
41118
41180
  } catch {}
41119
41181
  }
41120
- const indexTs = join39(dir, "index.ts");
41121
- const indexJs = join39(dir, "index.js");
41182
+ const indexTs = join40(dir, "index.ts");
41183
+ const indexJs = join40(dir, "index.js");
41122
41184
  if (await exists(indexTs))
41123
41185
  return [indexTs];
41124
41186
  if (await exists(indexJs))
@@ -41176,7 +41238,7 @@ var init_package_manager_resource_files = __esm(() => {
41176
41238
  });
41177
41239
 
41178
41240
  // src/core/package-manager-auto-resources.ts
41179
- import { dirname as dirname19, join as join40, resolve as resolve11 } from "node:path";
41241
+ import { dirname as dirname20, join as join41, resolve as resolve11 } from "node:path";
41180
41242
  async function collectProjectLocalResources(sourceRoot, accumulator, filter, metadata) {
41181
41243
  let found = false;
41182
41244
  const projectMetadata = { ...metadata, origin: "top-level", borrowedProjectLocal: true };
@@ -41191,14 +41253,14 @@ async function collectProjectLocalResources(sourceRoot, accumulator, filter, met
41191
41253
  };
41192
41254
  for (const configDir of getProjectConfigDirs(sourceRoot)) {
41193
41255
  const configMetadata = { ...projectMetadata, baseDir: configDir };
41194
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), configMetadata, filter?.extensions);
41195
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), configMetadata, filter?.skills);
41196
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), configMetadata, filter?.prompts);
41197
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), configMetadata, filter?.themes);
41198
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), configMetadata, filter?.workflows);
41199
- }
41200
- const agentsSkillsDir = join40(sourceRoot, ".agents", "skills");
41201
- addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: dirname19(agentsSkillsDir) }, filter?.skills);
41256
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), configMetadata, filter?.extensions);
41257
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), configMetadata, filter?.skills);
41258
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), configMetadata, filter?.prompts);
41259
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), configMetadata, filter?.themes);
41260
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), configMetadata, filter?.workflows);
41261
+ }
41262
+ const agentsSkillsDir = join41(sourceRoot, ".agents", "skills");
41263
+ addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: dirname20(agentsSkillsDir) }, filter?.skills);
41202
41264
  return found;
41203
41265
  }
41204
41266
  async function addAutoDiscoveredResources(context, accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir) {
@@ -41225,7 +41287,7 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41225
41287
  };
41226
41288
  const userConfigDirs = getBaseDirsForScope(context, "user");
41227
41289
  const projectConfigDirs = getBaseDirsForScope(context, "project");
41228
- const userAgentsSkillsDir = join40(getHomeDir2(), ".agents", "skills");
41290
+ const userAgentsSkillsDir = join41(getHomeDir2(), ".agents", "skills");
41229
41291
  const projectTrusted = context.settingsManager.isProjectTrusted();
41230
41292
  const projectAgentsSkillDirs = projectTrusted ? (await collectAncestorAgentsSkillDirs(context.cwd)).filter((dir) => resolve11(dir) !== resolve11(userAgentsSkillsDir)) : [];
41231
41293
  const addResources = (resourceType, paths, metadata, overrides, baseDir) => {
@@ -41240,15 +41302,15 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41240
41302
  baseDir: configDir,
41241
41303
  configurationOrigin: index === 0 ? "atomic" : "inherited-pi"
41242
41304
  };
41243
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), metadata, projectOverrides.extensions, configDir);
41244
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), metadata, projectOverrides.skills, configDir);
41245
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), metadata, projectOverrides.prompts, configDir);
41246
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), metadata, projectOverrides.themes, configDir);
41247
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), metadata, projectOverrides.workflows, configDir);
41305
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), metadata, projectOverrides.extensions, configDir);
41306
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), metadata, projectOverrides.skills, configDir);
41307
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), metadata, projectOverrides.prompts, configDir);
41308
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), metadata, projectOverrides.themes, configDir);
41309
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), metadata, projectOverrides.workflows, configDir);
41248
41310
  }
41249
41311
  }
41250
41312
  for (const agentsSkillsDir of projectAgentsSkillDirs) {
41251
- const agentsBaseDir = dirname19(agentsSkillsDir);
41313
+ const agentsBaseDir = dirname20(agentsSkillsDir);
41252
41314
  addResources("skills", await collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: agentsBaseDir }, projectOverrides.skills, agentsBaseDir);
41253
41315
  }
41254
41316
  for (const [index, configDir] of userConfigDirs.entries()) {
@@ -41257,13 +41319,13 @@ async function addAutoDiscoveredResources(context, accumulator, globalSettings,
41257
41319
  baseDir: configDir,
41258
41320
  configurationOrigin: index === 0 ? "atomic" : "inherited-pi"
41259
41321
  };
41260
- addResources("extensions", await collectAutoExtensionEntries(join40(configDir, "extensions")), metadata, userOverrides.extensions, configDir);
41261
- addResources("skills", await collectAutoSkillEntries(join40(configDir, "skills"), "pi"), metadata, userOverrides.skills, configDir);
41262
- addResources("prompts", await collectAutoPromptEntries(join40(configDir, "prompts")), metadata, userOverrides.prompts, configDir);
41263
- addResources("themes", await collectAutoThemeEntries(join40(configDir, "themes")), metadata, userOverrides.themes, configDir);
41264
- addResources("workflows", await collectResourceFiles(join40(configDir, "workflows"), "workflows"), metadata, userOverrides.workflows, configDir);
41322
+ addResources("extensions", await collectAutoExtensionEntries(join41(configDir, "extensions")), metadata, userOverrides.extensions, configDir);
41323
+ addResources("skills", await collectAutoSkillEntries(join41(configDir, "skills"), "pi"), metadata, userOverrides.skills, configDir);
41324
+ addResources("prompts", await collectAutoPromptEntries(join41(configDir, "prompts")), metadata, userOverrides.prompts, configDir);
41325
+ addResources("themes", await collectAutoThemeEntries(join41(configDir, "themes")), metadata, userOverrides.themes, configDir);
41326
+ addResources("workflows", await collectResourceFiles(join41(configDir, "workflows"), "workflows"), metadata, userOverrides.workflows, configDir);
41265
41327
  }
41266
- const userAgentsBaseDir = dirname19(userAgentsSkillsDir);
41328
+ const userAgentsBaseDir = dirname20(userAgentsSkillsDir);
41267
41329
  addResources("skills", await collectAutoSkillEntries(userAgentsSkillsDir, "agents"), { ...userMetadata, baseDir: userAgentsBaseDir }, userOverrides.skills, userAgentsBaseDir);
41268
41330
  }
41269
41331
  var init_package_manager_auto_resources = __esm(() => {
@@ -41432,7 +41494,7 @@ var init_package_manager_resource_collector = __esm(() => {
41432
41494
 
41433
41495
  // src/core/package-manager-resolver.ts
41434
41496
  import { access as access4, stat as stat5 } from "node:fs/promises";
41435
- import { dirname as dirname20, isAbsolute as isAbsolute7, join as join41 } from "node:path";
41497
+ import { dirname as dirname21, isAbsolute as isAbsolute7, join as join42 } from "node:path";
41436
41498
  async function exists3(path12) {
41437
41499
  try {
41438
41500
  await access4(path12);
@@ -41455,7 +41517,7 @@ async function resolvePackages(context, onMissing) {
41455
41517
  const packageSources = dedupePackages(context, allPackages);
41456
41518
  await resolvePackageSources(context, packageSources, accumulator, onMissing, { settingsField: "packages" });
41457
41519
  const globalBaseDir = context.agentDir;
41458
- const projectBaseDir = join41(context.cwd, CONFIG_DIR_NAME);
41520
+ const projectBaseDir = join42(context.cwd, CONFIG_DIR_NAME);
41459
41521
  const globalBaseDirs = getBaseDirsForScope(context, "user");
41460
41522
  const projectBaseDirs = getBaseDirsForScope(context, "project");
41461
41523
  for (const resourceType of ["extensions", "skills", "prompts", "themes", "workflows"]) {
@@ -41590,7 +41652,7 @@ async function resolveLocalExtensionSource(source, accumulator, filter, metadata
41590
41652
  try {
41591
41653
  const stats = await stat5(resolved);
41592
41654
  if (stats.isFile()) {
41593
- addResource(accumulator.extensions, resolved, { ...metadata, baseDir: dirname20(resolved) }, true);
41655
+ addResource(accumulator.extensions, resolved, { ...metadata, baseDir: dirname21(resolved) }, true);
41594
41656
  return;
41595
41657
  }
41596
41658
  if (stats.isDirectory()) {
@@ -41621,7 +41683,7 @@ var init_package_manager_resolver = __esm(() => {
41621
41683
  });
41622
41684
 
41623
41685
  // src/core/package-manager-settings.ts
41624
- import { existsSync as existsSync29 } from "node:fs";
41686
+ import { existsSync as existsSync30 } from "node:fs";
41625
41687
  function addSourceToSettings(context, source, options) {
41626
41688
  const scope = options?.local ? "project" : "user";
41627
41689
  const currentSettings = scope === "project" ? context.settingsManager.getProjectSettings() : context.settingsManager.getGlobalSettings();
@@ -41675,7 +41737,7 @@ function getInstalledPath(context, source, scope) {
41675
41737
  }
41676
41738
  for (const baseDir of getBaseDirsForScope(context, scope)) {
41677
41739
  const path12 = resolvePathFromBase(parsed.path, baseDir);
41678
- if (existsSync29(path12))
41740
+ if (existsSync30(path12))
41679
41741
  return path12;
41680
41742
  }
41681
41743
  return;
@@ -41899,29 +41961,29 @@ var init_package_manager = __esm(() => {
41899
41961
 
41900
41962
  // src/core/footer-data-provider.ts
41901
41963
  import { execFile, spawnSync as spawnSync6 } from "child_process";
41902
- import { existsSync as existsSync30, readFileSync as readFileSync19, statSync as statSync7, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
41903
- import { dirname as dirname21, join as join42, resolve as resolve13 } from "path";
41964
+ import { existsSync as existsSync31, readFileSync as readFileSync20, statSync as statSync7, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
41965
+ import { dirname as dirname22, join as join43, resolve as resolve13 } from "path";
41904
41966
  function findGitPaths(cwd) {
41905
41967
  let dir = cwd;
41906
41968
  while (true) {
41907
- const gitPath = join42(dir, ".git");
41908
- if (existsSync30(gitPath)) {
41969
+ const gitPath = join43(dir, ".git");
41970
+ if (existsSync31(gitPath)) {
41909
41971
  try {
41910
41972
  const stat6 = statSync7(gitPath);
41911
41973
  if (stat6.isFile()) {
41912
- const content = readFileSync19(gitPath, "utf8").trim();
41974
+ const content = readFileSync20(gitPath, "utf8").trim();
41913
41975
  if (content.startsWith("gitdir: ")) {
41914
41976
  const gitDir = resolve13(dir, content.slice(8).trim());
41915
- const headPath = join42(gitDir, "HEAD");
41916
- if (!existsSync30(headPath))
41977
+ const headPath = join43(gitDir, "HEAD");
41978
+ if (!existsSync31(headPath))
41917
41979
  return null;
41918
- const commonDirPath = join42(gitDir, "commondir");
41919
- const commonGitDir = existsSync30(commonDirPath) ? resolve13(gitDir, readFileSync19(commonDirPath, "utf8").trim()) : gitDir;
41980
+ const commonDirPath = join43(gitDir, "commondir");
41981
+ const commonGitDir = existsSync31(commonDirPath) ? resolve13(gitDir, readFileSync20(commonDirPath, "utf8").trim()) : gitDir;
41920
41982
  return { repoDir: dir, commonGitDir, headPath };
41921
41983
  }
41922
41984
  } else if (stat6.isDirectory()) {
41923
- const headPath = join42(gitPath, "HEAD");
41924
- if (!existsSync30(headPath))
41985
+ const headPath = join43(gitPath, "HEAD");
41986
+ if (!existsSync31(headPath))
41925
41987
  return null;
41926
41988
  return { repoDir: dir, commonGitDir: gitPath, headPath };
41927
41989
  }
@@ -41929,7 +41991,7 @@ function findGitPaths(cwd) {
41929
41991
  return null;
41930
41992
  }
41931
41993
  }
41932
- const parent = dirname21(dir);
41994
+ const parent = dirname22(dir);
41933
41995
  if (parent === dir)
41934
41996
  return null;
41935
41997
  dir = parent;
@@ -42113,7 +42175,7 @@ class FooterDataProvider {
42113
42175
  try {
42114
42176
  if (!this.gitPaths)
42115
42177
  return null;
42116
- const content = readFileSync19(this.gitPaths.headPath, "utf8").trim();
42178
+ const content = readFileSync20(this.gitPaths.headPath, "utf8").trim();
42117
42179
  if (content.startsWith("ref: refs/heads/")) {
42118
42180
  const branch = content.slice(16);
42119
42181
  return branch === ".invalid" ? resolveBranchWithGitSync(this.gitPaths.repoDir) ?? "detached" : branch;
@@ -42127,7 +42189,7 @@ class FooterDataProvider {
42127
42189
  try {
42128
42190
  if (!this.gitPaths)
42129
42191
  return null;
42130
- const content = readFileSync19(this.gitPaths.headPath, "utf8").trim();
42192
+ const content = readFileSync20(this.gitPaths.headPath, "utf8").trim();
42131
42193
  if (content.startsWith("ref: refs/heads/")) {
42132
42194
  const branch = content.slice(16);
42133
42195
  return branch === ".invalid" ? await resolveBranchWithGitAsync(this.gitPaths.repoDir) ?? "detached" : branch;
@@ -42198,12 +42260,12 @@ class FooterDataProvider {
42198
42260
  this.scheduleGitWatcherRetry();
42199
42261
  }
42200
42262
  readReftableTablesListFingerprint() {
42201
- if (!this.reftableTablesListPath || !existsSync30(this.reftableTablesListPath)) {
42263
+ if (!this.reftableTablesListPath || !existsSync31(this.reftableTablesListPath)) {
42202
42264
  return null;
42203
42265
  }
42204
42266
  try {
42205
42267
  const stat6 = statSync7(this.reftableTablesListPath);
42206
- const content = readFileSync19(this.reftableTablesListPath, "utf8");
42268
+ const content = readFileSync20(this.reftableTablesListPath, "utf8");
42207
42269
  return `${stat6.size}:${stat6.mtimeMs}:${stat6.ctimeMs}:${content}`;
42208
42270
  } catch {
42209
42271
  return null;
@@ -42230,7 +42292,7 @@ class FooterDataProvider {
42230
42292
  if (!this.gitPaths)
42231
42293
  return;
42232
42294
  const pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);
42233
- this.headWatcher = watchWithErrorHandler(dirname21(this.gitPaths.headPath), (_eventType, filename) => {
42295
+ this.headWatcher = watchWithErrorHandler(dirname22(this.gitPaths.headPath), (_eventType, filename) => {
42234
42296
  if (!filename || filename === "HEAD") {
42235
42297
  this.scheduleRefresh();
42236
42298
  }
@@ -42247,9 +42309,9 @@ class FooterDataProvider {
42247
42309
  if (!this.headWatcher && !this.headWatchFileListener) {
42248
42310
  return;
42249
42311
  }
42250
- const reftableDir = join42(this.gitPaths.commonGitDir, "reftable");
42251
- if (existsSync30(reftableDir)) {
42252
- this.reftableTablesListPath = join42(reftableDir, "tables.list");
42312
+ const reftableDir = join43(this.gitPaths.commonGitDir, "reftable");
42313
+ if (existsSync31(reftableDir)) {
42314
+ this.reftableTablesListPath = join43(reftableDir, "tables.list");
42253
42315
  this.reftableTablesListFingerprint = this.readReftableTablesListFingerprint();
42254
42316
  this.reftableWatcher = watchWithErrorHandler(reftableDir, (_eventType, filename) => {
42255
42317
  this.handleReftableDirectoryEvent(filename);
@@ -42260,7 +42322,7 @@ class FooterDataProvider {
42260
42322
  this.handleGitWatcherError();
42261
42323
  });
42262
42324
  const tablesListPath = this.reftableTablesListPath;
42263
- if (tablesListPath && existsSync30(tablesListPath)) {
42325
+ if (tablesListPath && existsSync31(tablesListPath)) {
42264
42326
  this.reftableTablesListWatcher = watchWithErrorHandler(tablesListPath, () => {
42265
42327
  this.scheduleReftableRefresh();
42266
42328
  }, (error) => {
@@ -42385,8 +42447,8 @@ function deepMergeSettings(base, overrides) {
42385
42447
  }
42386
42448
 
42387
42449
  // src/core/settings-storage.ts
42388
- import { existsSync as existsSync31, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
42389
- import { dirname as dirname22, join as join43 } from "path";
42450
+ import { existsSync as existsSync32, mkdirSync as mkdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync12 } from "fs";
42451
+ import { dirname as dirname23, join as join44 } from "path";
42390
42452
  import lockfile3 from "proper-lockfile";
42391
42453
 
42392
42454
  class FileSettingsStorage {
@@ -42397,18 +42459,18 @@ class FileSettingsStorage {
42397
42459
  constructor(cwd, agentDir, options) {
42398
42460
  const resolvedCwd = resolvePath(cwd);
42399
42461
  const resolvedAgentDir = resolvePath(agentDir);
42400
- this.globalSettingsPath = join43(resolvedAgentDir, "settings.json");
42401
- this.projectSettingsPath = join43(resolvedCwd, CONFIG_DIR_NAME, "settings.json");
42462
+ this.globalSettingsPath = join44(resolvedAgentDir, "settings.json");
42463
+ this.projectSettingsPath = join44(resolvedCwd, CONFIG_DIR_NAME, "settings.json");
42402
42464
  this.globalReadPaths = (options?.globalReadPaths ?? [this.globalSettingsPath]).map((path12) => normalizePath(path12));
42403
42465
  this.projectReadPaths = (options?.projectReadPaths ?? [this.projectSettingsPath]).map((path12) => normalizePath(path12));
42404
42466
  }
42405
42467
  getFieldOrigin(scope, field2) {
42406
42468
  const readPaths = scope === "global" ? this.globalReadPaths : this.projectReadPaths;
42407
42469
  for (const [index, readPath] of readPaths.entries()) {
42408
- if (!existsSync31(readPath))
42470
+ if (!existsSync32(readPath))
42409
42471
  continue;
42410
42472
  try {
42411
- const parsed = parseJsonFileContent(readFileSync20(readPath, "utf-8"));
42473
+ const parsed = parseJsonFileContent(readFileSync21(readPath, "utf-8"));
42412
42474
  if (Object.hasOwn(parsed, field2)) {
42413
42475
  return index === 0 ? "primary" : "legacy";
42414
42476
  }
@@ -42442,9 +42504,9 @@ class FileSettingsStorage {
42442
42504
  let found = false;
42443
42505
  for (let i = readPaths.length - 1;i >= 0; i--) {
42444
42506
  const readPath = readPaths[i];
42445
- if (!existsSync31(readPath))
42507
+ if (!existsSync32(readPath))
42446
42508
  continue;
42447
- const parsed = parseJsonFileContent(readFileSync20(readPath, "utf-8"));
42509
+ const parsed = parseJsonFileContent(readFileSync21(readPath, "utf-8"));
42448
42510
  merged = deepMergeSettings(merged, parsed);
42449
42511
  found = true;
42450
42512
  }
@@ -42453,21 +42515,21 @@ class FileSettingsStorage {
42453
42515
  withLock(scope, fn) {
42454
42516
  const path12 = scope === "global" ? this.globalSettingsPath : this.projectSettingsPath;
42455
42517
  const readPaths = scope === "global" ? this.globalReadPaths : this.projectReadPaths;
42456
- const dir = dirname22(path12);
42518
+ const dir = dirname23(path12);
42457
42519
  let release;
42458
42520
  try {
42459
- const fileExists2 = existsSync31(path12);
42521
+ const fileExists2 = existsSync32(path12);
42460
42522
  if (fileExists2) {
42461
42523
  release = this.acquireLockSyncWithRetry(path12);
42462
42524
  }
42463
42525
  const current = this.readMergedSettings(readPaths);
42464
42526
  const next = fn(current);
42465
42527
  if (next !== undefined) {
42466
- if (!existsSync31(dir)) {
42528
+ if (!existsSync32(dir)) {
42467
42529
  mkdirSync11(dir, { recursive: true });
42468
42530
  }
42469
42531
  if (!release) {
42470
- if (!existsSync31(path12))
42532
+ if (!existsSync32(path12))
42471
42533
  writeFileSync12(path12, "{}", "utf-8");
42472
42534
  release = this.acquireLockSyncWithRetry(path12);
42473
42535
  }
@@ -42507,7 +42569,7 @@ var init_settings_storage = __esm(() => {
42507
42569
  });
42508
42570
 
42509
42571
  // src/core/settings-manager-core.ts
42510
- import { join as join44 } from "path";
42572
+ import { join as join45 } from "path";
42511
42573
 
42512
42574
  class SettingsManager {
42513
42575
  storage;
@@ -42545,7 +42607,7 @@ class SettingsManager {
42545
42607
  }
42546
42608
  static create(cwd, agentDir = getAgentDir(), options = {}) {
42547
42609
  const storage = new FileSettingsStorage(cwd, agentDir, {
42548
- globalReadPaths: agentDir === getAgentDir() ? getAgentConfigPaths("settings.json") : [join44(agentDir, "settings.json")],
42610
+ globalReadPaths: agentDir === getAgentDir() ? getAgentConfigPaths("settings.json") : [join45(agentDir, "settings.json")],
42549
42611
  projectReadPaths: getProjectConfigPaths(cwd, "settings.json")
42550
42612
  });
42551
42613
  return SettingsManager.fromStorage(storage, options);
@@ -44259,14 +44321,14 @@ var init_agent_session_runtime_auth = __esm(() => {
44259
44321
  });
44260
44322
 
44261
44323
  // src/core/session-cwd.ts
44262
- import { existsSync as existsSync32 } from "node:fs";
44324
+ import { existsSync as existsSync33 } from "node:fs";
44263
44325
  function getMissingSessionCwdIssue(sessionManager, fallbackCwd) {
44264
44326
  const sessionFile = sessionManager.getSessionFile();
44265
44327
  if (!sessionFile) {
44266
44328
  return;
44267
44329
  }
44268
44330
  const sessionCwd = sessionManager.getCwd();
44269
- if (!sessionCwd || existsSync32(sessionCwd)) {
44331
+ if (!sessionCwd || existsSync33(sessionCwd)) {
44270
44332
  return;
44271
44333
  }
44272
44334
  return {
@@ -44318,8 +44380,8 @@ var init_agent_session_services = __esm(() => {
44318
44380
  });
44319
44381
 
44320
44382
  // src/core/agent-session-runtime.ts
44321
- import { copyFileSync, existsSync as existsSync33, mkdirSync as mkdirSync12 } from "node:fs";
44322
- import { basename as basename10, join as join45, resolve as resolve14 } from "node:path";
44383
+ import { copyFileSync, existsSync as existsSync34, mkdirSync as mkdirSync12 } from "node:fs";
44384
+ import { basename as basename10, join as join46, resolve as resolve14 } from "node:path";
44323
44385
  import { modelsAreEqual as modelsAreEqual5 } from "@bastani/pi-ai/compat";
44324
44386
  function extractUserMessageText(content) {
44325
44387
  if (typeof content === "string") {
@@ -44535,7 +44597,7 @@ class AgentSessionRuntime {
44535
44597
  await this.finishSessionReplacement(options?.withSession);
44536
44598
  return { cancelled: false, selectedText };
44537
44599
  }
44538
- if (!existsSync33(currentSessionFile)) {
44600
+ if (!existsSync34(currentSessionFile)) {
44539
44601
  throw new Error("This session has not been saved yet. Wait for the first assistant response before cloning or forking it.");
44540
44602
  }
44541
44603
  const sessionManager2 = SessionManager.open(currentSessionFile, sessionDir);
@@ -44571,14 +44633,14 @@ class AgentSessionRuntime {
44571
44633
  }
44572
44634
  async importFromJsonl(inputPath, cwdOverride) {
44573
44635
  const resolvedPath = resolvePath(inputPath);
44574
- if (!existsSync33(resolvedPath)) {
44636
+ if (!existsSync34(resolvedPath)) {
44575
44637
  throw new SessionImportFileNotFoundError(resolvedPath);
44576
44638
  }
44577
44639
  const sessionDir = this.session.sessionManager.getSessionDir();
44578
- if (!existsSync33(sessionDir)) {
44640
+ if (!existsSync34(sessionDir)) {
44579
44641
  mkdirSync12(sessionDir, { recursive: true });
44580
44642
  }
44581
- const destinationPath = join45(sessionDir, basename10(resolvedPath));
44643
+ const destinationPath = join46(sessionDir, basename10(resolvedPath));
44582
44644
  const beforeResult = await this.emitBeforeSwitch("resume", destinationPath);
44583
44645
  if (beforeResult.cancelled) {
44584
44646
  return beforeResult;
@@ -56173,7 +56235,7 @@ function createMessageReader(onMessage, onError) {
56173
56235
 
56174
56236
  // dist/builtin/intercom/broker/paths.ts
56175
56237
  import { homedir as homedir7 } from "os";
56176
- import { join as join46 } from "path";
56238
+ import { join as join47 } from "path";
56177
56239
  function getHomeDir3() {
56178
56240
  if (process.platform === "win32") {
56179
56241
  if (process.env.USERPROFILE)
@@ -56190,7 +56252,7 @@ function expandTildePath2(path13) {
56190
56252
  if (path13 === "~")
56191
56253
  return getHomeDir3();
56192
56254
  if (path13.startsWith("~/") || process.platform === "win32" && path13.startsWith("~\\")) {
56193
- return join46(getHomeDir3(), path13.slice(2));
56255
+ return join47(getHomeDir3(), path13.slice(2));
56194
56256
  }
56195
56257
  return path13;
56196
56258
  }
@@ -56201,28 +56263,28 @@ function getAgentDir2() {
56201
56263
  const piAgentDir = process.env.PI_CODING_AGENT_DIR;
56202
56264
  if (piAgentDir)
56203
56265
  return expandTildePath2(piAgentDir);
56204
- return join46(getHomeDir3(), ".atomic", "agent");
56266
+ return join47(getHomeDir3(), ".atomic", "agent");
56205
56267
  }
56206
56268
  function sanitizePipeSegment(value) {
56207
56269
  return value.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "default";
56208
56270
  }
56209
56271
  function getIntercomDirPath(agentDir = getAgentDir2()) {
56210
- return join46(agentDir, "intercom");
56272
+ return join47(agentDir, "intercom");
56211
56273
  }
56212
56274
  function getBrokerPidPath(agentDir = getAgentDir2()) {
56213
- return join46(getIntercomDirPath(agentDir), "broker.pid");
56275
+ return join47(getIntercomDirPath(agentDir), "broker.pid");
56214
56276
  }
56215
56277
  function getBrokerSpawnLockPath(agentDir = getAgentDir2()) {
56216
- return join46(getIntercomDirPath(agentDir), "broker.spawn.lock");
56278
+ return join47(getIntercomDirPath(agentDir), "broker.spawn.lock");
56217
56279
  }
56218
56280
  function getBrokerLogPath(agentDir = getAgentDir2()) {
56219
- return join46(getIntercomDirPath(agentDir), "broker.log");
56281
+ return join47(getIntercomDirPath(agentDir), "broker.log");
56220
56282
  }
56221
56283
  function getBrokerSocketPath(platform3 = process.platform, agentDir = getAgentDir2()) {
56222
56284
  if (platform3 === "win32") {
56223
56285
  return `\\\\.\\pipe\\pi-intercom-${sanitizePipeSegment(agentDir)}`;
56224
56286
  }
56225
- return join46(getIntercomDirPath(agentDir), "broker.sock");
56287
+ return join47(getIntercomDirPath(agentDir), "broker.sock");
56226
56288
  }
56227
56289
  var init_paths2 = () => {};
56228
56290
 
@@ -56916,23 +56978,23 @@ var init_client = __esm(() => {
56916
56978
 
56917
56979
  // dist/builtin/intercom/broker/spawn.ts
56918
56980
  import { spawn as spawn9 } from "child_process";
56919
- import { closeSync as closeSync4, existsSync as existsSync34, mkdirSync as mkdirSync13, openSync as openSync4, readFileSync as readFileSync22, readSync as readSync2, statSync as statSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync13 } from "fs";
56920
- import { join as join47, dirname as dirname23 } from "path";
56981
+ import { closeSync as closeSync4, existsSync as existsSync35, mkdirSync as mkdirSync13, openSync as openSync4, readFileSync as readFileSync23, readSync as readSync2, statSync as statSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync13 } from "fs";
56982
+ import { join as join48, dirname as dirname24 } from "path";
56921
56983
  import { fileURLToPath as fileURLToPath4 } from "url";
56922
56984
  import { createRequire as createRequire7 } from "module";
56923
56985
  import net2 from "net";
56924
56986
  function isIntercomPackageRoot(dir) {
56925
- return existsSync34(join47(dir, "package.json")) && existsSync34(join47(dir, "broker"));
56987
+ return existsSync35(join48(dir, "package.json")) && existsSync35(join48(dir, "broker"));
56926
56988
  }
56927
56989
  function resolveIntercomPackageRoot(moduleHref) {
56928
- const here = dirname23(fileURLToPath4(moduleHref));
56990
+ const here = dirname24(fileURLToPath4(moduleHref));
56929
56991
  if (isIntercomPackageRoot(here))
56930
56992
  return here;
56931
- return join47(here, "..");
56993
+ return join48(here, "..");
56932
56994
  }
56933
56995
  function resolveBrokerEntrypoint(packageRoot) {
56934
- const bundled = join47(packageRoot, "broker", "broker.bundle.mjs");
56935
- return existsSync34(bundled) ? bundled : join47(packageRoot, "broker", "broker.ts");
56996
+ const bundled = join48(packageRoot, "broker", "broker.bundle.mjs");
56997
+ return existsSync35(bundled) ? bundled : join48(packageRoot, "broker", "broker.ts");
56936
56998
  }
56937
56999
  function sleep2(ms) {
56938
57000
  return new Promise((resolve15) => setTimeout(resolve15, ms));
@@ -56943,14 +57005,14 @@ function getCurrentBrokerRuntime() {
56943
57005
  return isBunBinary ? "bun-binary" : "bun-source";
56944
57006
  }
56945
57007
  function requireFromExtensionDir(extensionDir) {
56946
- return createRequire7(join47(extensionDir, "package.json"));
57008
+ return createRequire7(join48(extensionDir, "package.json"));
56947
57009
  }
56948
57010
  function getJitiCliPath(extensionDir = EXTENSION_DIR) {
56949
57011
  try {
56950
57012
  const jitiPackage = requireFromExtensionDir(extensionDir).resolve("jiti/package.json");
56951
- return join47(dirname23(jitiPackage), "lib", "jiti-cli.mjs");
57013
+ return join48(dirname24(jitiPackage), "lib", "jiti-cli.mjs");
56952
57014
  } catch {
56953
- return join47(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
57015
+ return join48(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
56954
57016
  }
56955
57017
  }
56956
57018
  function getDefaultBrokerRunnerPath(extensionDir) {
@@ -56972,7 +57034,7 @@ function quoteWindowsArg(value) {
56972
57034
  return `"${value.replace(/"/g, '""')}"`;
56973
57035
  }
56974
57036
  function getWindowsHiddenLauncherPath(intercomDir = INTERCOM_DIR) {
56975
- return join47(intercomDir, "broker-launch.vbs");
57037
+ return join48(intercomDir, "broker-launch.vbs");
56976
57038
  }
56977
57039
  function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
56978
57040
  return brokerCommand === "npx" && brokerArgs.length === 2 && brokerArgs[0] === "--no-install" && brokerArgs[1] === "tsx";
@@ -56999,7 +57061,7 @@ function getWindowsHiddenLauncherScript(commandLine) {
56999
57061
  `);
57000
57062
  }
57001
57063
  function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHiddenLauncherPath()) {
57002
- mkdirSync13(dirname23(launcherPath), { recursive: true });
57064
+ mkdirSync13(dirname24(launcherPath), { recursive: true });
57003
57065
  writeFileSync13(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
57004
57066
  return launcherPath;
57005
57067
  }
@@ -57038,7 +57100,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore")
57038
57100
  };
57039
57101
  }
57040
57102
  function resetBrokerLog(logPath = BROKER_LOG) {
57041
- mkdirSync13(dirname23(logPath), { recursive: true });
57103
+ mkdirSync13(dirname24(logPath), { recursive: true });
57042
57104
  closeSync4(openSync4(logPath, "w"));
57043
57105
  }
57044
57106
  function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTES) {
@@ -57143,10 +57205,10 @@ async function isBrokerRunning() {
57143
57205
  if (await checkSocketConnectable()) {
57144
57206
  return true;
57145
57207
  }
57146
- if (!existsSync34(BROKER_PID))
57208
+ if (!existsSync35(BROKER_PID))
57147
57209
  return false;
57148
57210
  try {
57149
- const pid = parseInt(readFileSync22(BROKER_PID, "utf-8").trim(), 10);
57211
+ const pid = parseInt(readFileSync23(BROKER_PID, "utf-8").trim(), 10);
57150
57212
  if (!Number.isFinite(pid))
57151
57213
  return false;
57152
57214
  process.kill(pid, 0);
@@ -57204,11 +57266,11 @@ ${Date.now()}
57204
57266
  return false;
57205
57267
  }
57206
57268
  function isSpawnLockStale() {
57207
- if (!existsSync34(BROKER_SPAWN_LOCK)) {
57269
+ if (!existsSync35(BROKER_SPAWN_LOCK)) {
57208
57270
  return false;
57209
57271
  }
57210
57272
  try {
57211
- const [pidLine = "", createdAtLine = "0"] = readFileSync22(BROKER_SPAWN_LOCK, "utf-8").trim().split(`
57273
+ const [pidLine = "", createdAtLine = "0"] = readFileSync23(BROKER_SPAWN_LOCK, "utf-8").trim().split(`
57212
57274
  `);
57213
57275
  const pid = Number.parseInt(pidLine, 10);
57214
57276
  const createdAt = Number.parseInt(createdAtLine, 10);
@@ -57323,13 +57385,13 @@ class InlineMessageComponent {
57323
57385
  var init_inline_message = () => {};
57324
57386
 
57325
57387
  // dist/builtin/intercom/config.ts
57326
- import { existsSync as existsSync35, readFileSync as readFileSync23 } from "fs";
57388
+ import { existsSync as existsSync36, readFileSync as readFileSync24 } from "fs";
57327
57389
  function loadConfig2() {
57328
- if (!existsSync35(CONFIG_PATH2)) {
57390
+ if (!existsSync36(CONFIG_PATH2)) {
57329
57391
  return { ...defaults };
57330
57392
  }
57331
57393
  try {
57332
- const raw = readFileSync23(CONFIG_PATH2, "utf-8");
57394
+ const raw = readFileSync24(CONFIG_PATH2, "utf-8");
57333
57395
  const parsed = JSON.parse(raw);
57334
57396
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
57335
57397
  throw new Error("Config must be a JSON object");
@@ -57399,7 +57461,7 @@ var CONFIG_PATHS, CONFIG_PATH2, DEFAULT_BROKER_COMMAND = "npx", DEFAULT_BROKER_A
57399
57461
  var init_config3 = __esm(() => {
57400
57462
  init_src();
57401
57463
  CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
57402
- CONFIG_PATH2 = CONFIG_PATHS.find((path13) => existsSync35(path13)) ?? CONFIG_PATHS[0];
57464
+ CONFIG_PATH2 = CONFIG_PATHS.find((path13) => existsSync36(path13)) ?? CONFIG_PATHS[0];
57403
57465
  DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
57404
57466
  defaults = {
57405
57467
  brokerCommand: DEFAULT_BROKER_COMMAND,