terminal-pilot 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cli.js +390 -241
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +7 -2
  4. package/dist/commands/close-session.js.map +4 -4
  5. package/dist/commands/create-session.js +7 -2
  6. package/dist/commands/create-session.js.map +4 -4
  7. package/dist/commands/fill.js +7 -2
  8. package/dist/commands/fill.js.map +4 -4
  9. package/dist/commands/get-session.js +7 -2
  10. package/dist/commands/get-session.js.map +4 -4
  11. package/dist/commands/index.js +29 -24
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +13 -8
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +15 -10
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +7 -2
  18. package/dist/commands/list-sessions.js.map +4 -4
  19. package/dist/commands/press-key.js +7 -2
  20. package/dist/commands/press-key.js.map +4 -4
  21. package/dist/commands/read-history.js +7 -2
  22. package/dist/commands/read-history.js.map +4 -4
  23. package/dist/commands/read-screen.js +7 -2
  24. package/dist/commands/read-screen.js.map +4 -4
  25. package/dist/commands/resize.js +7 -2
  26. package/dist/commands/resize.js.map +4 -4
  27. package/dist/commands/runtime.js +6 -1
  28. package/dist/commands/runtime.js.map +4 -4
  29. package/dist/commands/screenshot.js +11 -6
  30. package/dist/commands/screenshot.js.map +4 -4
  31. package/dist/commands/send-signal.js +7 -2
  32. package/dist/commands/send-signal.js.map +4 -4
  33. package/dist/commands/type.js +7 -2
  34. package/dist/commands/type.js.map +4 -4
  35. package/dist/commands/uninstall.js +16 -11
  36. package/dist/commands/uninstall.js.map +4 -4
  37. package/dist/commands/wait-for-exit.js +7 -2
  38. package/dist/commands/wait-for-exit.js.map +4 -4
  39. package/dist/commands/wait-for.js +7 -2
  40. package/dist/commands/wait-for.js.map +4 -4
  41. package/dist/testing/cli-repl.js +390 -241
  42. package/dist/testing/cli-repl.js.map +4 -4
  43. package/dist/testing/qa-cli.js +402 -253
  44. package/dist/testing/qa-cli.js.map +4 -4
  45. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { realpath } from "node:fs/promises";
5
- import path11 from "node:path";
6
- import { fileURLToPath as fileURLToPath4 } from "node:url";
5
+ import path12 from "node:path";
6
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
7
7
 
8
8
  // ../toolcraft/src/cli.ts
9
- import { access as access2, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
10
- import path6 from "node:path";
9
+ import { access as access2, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
10
+ import path7 from "node:path";
11
11
  import { Command as CommanderCommand, CommanderError, InvalidArgumentError, Option } from "commander";
12
12
 
13
13
  // ../design-system/src/tokens/colors.ts
@@ -666,7 +666,7 @@ async function confirm2(opts) {
666
666
  import chalk16 from "chalk";
667
667
 
668
668
  // ../toolcraft/src/index.ts
669
- import { fileURLToPath } from "node:url";
669
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
670
670
 
671
671
  // ../toolcraft/src/user-error.ts
672
672
  var UserError = class extends Error {
@@ -835,6 +835,62 @@ var S = {
835
835
  Json
836
836
  };
837
837
 
838
+ // ../toolcraft/src/package-metadata.ts
839
+ import { existsSync, readFileSync, statSync } from "node:fs";
840
+ import path from "node:path";
841
+ import { fileURLToPath } from "node:url";
842
+ function pathFromInput(from) {
843
+ if (from instanceof URL) {
844
+ return fileURLToPath(from);
845
+ }
846
+ if (from.startsWith("file:")) {
847
+ return fileURLToPath(from);
848
+ }
849
+ return path.resolve(from);
850
+ }
851
+ function getSearchDirectory(from) {
852
+ const resolved = pathFromInput(from);
853
+ try {
854
+ return statSync(resolved).isDirectory() ? resolved : path.dirname(resolved);
855
+ } catch {
856
+ return path.dirname(resolved);
857
+ }
858
+ }
859
+ function readPackageMetadata(packageJsonPath) {
860
+ const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
861
+ const metadata = { path: packageJsonPath };
862
+ if (typeof parsed.name === "string") {
863
+ metadata.name = parsed.name;
864
+ }
865
+ if (typeof parsed.version === "string") {
866
+ metadata.version = parsed.version;
867
+ }
868
+ return metadata;
869
+ }
870
+ function findPackageMetadata(from) {
871
+ let current = getSearchDirectory(from);
872
+ while (true) {
873
+ const packageJsonPath = path.join(current, "package.json");
874
+ if (existsSync(packageJsonPath)) {
875
+ return readPackageMetadata(packageJsonPath);
876
+ }
877
+ const parent = path.dirname(current);
878
+ if (parent === current) {
879
+ return void 0;
880
+ }
881
+ current = parent;
882
+ }
883
+ }
884
+ function findEntrypointPackageMetadata(entrypoint) {
885
+ if (entrypoint === void 0 || entrypoint.length === 0) {
886
+ return void 0;
887
+ }
888
+ if (!path.isAbsolute(entrypoint) && !entrypoint.startsWith("file:")) {
889
+ return void 0;
890
+ }
891
+ return findPackageMetadata(entrypoint);
892
+ }
893
+
838
894
  // ../toolcraft/src/index.ts
839
895
  var commandConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.command.config");
840
896
  var groupConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.group.config");
@@ -920,7 +976,7 @@ function validateRenameMap(rename2) {
920
976
  function parseStackPath(candidate) {
921
977
  if (candidate.startsWith("file://")) {
922
978
  try {
923
- return fileURLToPath(candidate);
979
+ return fileURLToPath2(candidate);
924
980
  } catch {
925
981
  return void 0;
926
982
  }
@@ -1275,7 +1331,7 @@ function getCommandSourcePath(command) {
1275
1331
  import * as fsPromises2 from "node:fs/promises";
1276
1332
 
1277
1333
  // ../task-list/src/backends/markdown-dir.ts
1278
- import path2 from "node:path";
1334
+ import path3 from "node:path";
1279
1335
 
1280
1336
  // ../file-lock/src/lock.ts
1281
1337
  import * as fsPromises from "node:fs/promises";
@@ -1323,21 +1379,82 @@ function backoff(attempt, minTimeout, maxTimeout) {
1323
1379
  function hasErrorCode(error2, code) {
1324
1380
  return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
1325
1381
  }
1382
+ function hasAnyErrorCode(error2, codes) {
1383
+ return codes.some((code) => hasErrorCode(error2, code));
1384
+ }
1385
+ function isPidRunning(pid) {
1386
+ try {
1387
+ process.kill(pid, 0);
1388
+ return true;
1389
+ } catch (error2) {
1390
+ return !hasErrorCode(error2, "ESRCH");
1391
+ }
1392
+ }
1326
1393
  function createDefaultFs() {
1327
1394
  return {
1328
- open: (path12, flags) => fsPromises.open(path12, flags),
1395
+ open: (path13, flags) => fsPromises.open(path13, flags),
1396
+ readFile: (path13, encoding) => fsPromises.readFile(path13, encoding),
1329
1397
  stat: fsPromises.stat,
1330
1398
  unlink: fsPromises.unlink
1331
1399
  };
1332
1400
  }
1333
- async function removeLockFile(fs2, lockPath) {
1401
+ async function removeLockFile(fs2, lockPath, signal) {
1402
+ for (let attempt = 0; attempt <= 4; attempt += 1) {
1403
+ throwIfAborted(signal);
1404
+ try {
1405
+ await fs2.unlink(lockPath);
1406
+ return;
1407
+ } catch (error2) {
1408
+ if (hasErrorCode(error2, "ENOENT")) {
1409
+ return;
1410
+ }
1411
+ if (!hasAnyErrorCode(error2, ["EPERM", "EBUSY"]) || attempt === 4) {
1412
+ throw error2;
1413
+ }
1414
+ }
1415
+ await sleep(25 * 2 ** attempt, signal);
1416
+ }
1417
+ }
1418
+ function parseLockMetadata(content) {
1419
+ try {
1420
+ const parsed = JSON.parse(content);
1421
+ if (!parsed || typeof parsed !== "object" || !("host" in parsed) || !("pid" in parsed)) {
1422
+ return void 0;
1423
+ }
1424
+ const { host, pid } = parsed;
1425
+ if (typeof host === "string" && typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0) {
1426
+ return {
1427
+ host,
1428
+ pid
1429
+ };
1430
+ }
1431
+ } catch (ignoredError) {
1432
+ void ignoredError;
1433
+ }
1434
+ return void 0;
1435
+ }
1436
+ async function readLockMetadata(fs2, lockPath) {
1437
+ if (!fs2.readFile) {
1438
+ return void 0;
1439
+ }
1334
1440
  try {
1335
- await fs2.unlink(lockPath);
1441
+ return parseLockMetadata(await fs2.readFile(lockPath, "utf8"));
1336
1442
  } catch (error2) {
1337
- if (!hasErrorCode(error2, "ENOENT")) {
1338
- throw error2;
1443
+ if (hasErrorCode(error2, "ENOENT")) {
1444
+ return null;
1339
1445
  }
1446
+ return void 0;
1447
+ }
1448
+ }
1449
+ async function shouldReclaimLock(options) {
1450
+ const metadata = await readLockMetadata(options.fs, options.lockPath);
1451
+ if (metadata === null) {
1452
+ return "missing";
1453
+ }
1454
+ if (metadata?.host === os.hostname()) {
1455
+ return !options.isPidRunning(metadata.pid);
1340
1456
  }
1457
+ return Date.now() - options.stat.mtimeMs > options.staleMs;
1341
1458
  }
1342
1459
  async function writeLockMetadata(handle) {
1343
1460
  try {
@@ -1359,7 +1476,8 @@ async function acquireFileLock(filePath, options = {}) {
1359
1476
  const retries = options.retries ?? 20;
1360
1477
  const minTimeout = options.minTimeout ?? 25;
1361
1478
  const maxTimeout = options.maxTimeout ?? 250;
1362
- const staleMs = options.staleMs ?? 3e4;
1479
+ const staleMs = options.staleMs ?? 1e3;
1480
+ const pidIsRunning = options.isPidRunning ?? isPidRunning;
1363
1481
  const lockPath = `${filePath}.lock`;
1364
1482
  let attempt = 0;
1365
1483
  while (attempt <= retries) {
@@ -1373,7 +1491,7 @@ async function acquireFileLock(filePath, options = {}) {
1373
1491
  return;
1374
1492
  }
1375
1493
  released = true;
1376
- await removeLockFile(fs2, lockPath);
1494
+ await removeLockFile(fs2, lockPath, options.signal);
1377
1495
  };
1378
1496
  } catch (error2) {
1379
1497
  if (!hasErrorCode(error2, "EEXIST")) {
@@ -1389,8 +1507,18 @@ async function acquireFileLock(filePath, options = {}) {
1389
1507
  }
1390
1508
  throw statError;
1391
1509
  }
1392
- if (Date.now() - stat3.mtimeMs > staleMs) {
1393
- await removeLockFile(fs2, lockPath);
1510
+ const reclaimLock = await shouldReclaimLock({
1511
+ fs: fs2,
1512
+ isPidRunning: pidIsRunning,
1513
+ lockPath,
1514
+ staleMs,
1515
+ stat: stat3
1516
+ });
1517
+ if (reclaimLock === "missing") {
1518
+ continue;
1519
+ }
1520
+ if (reclaimLock) {
1521
+ await removeLockFile(fs2, lockPath, options.signal);
1394
1522
  continue;
1395
1523
  }
1396
1524
  if (attempt >= retries) {
@@ -1582,7 +1710,7 @@ function resolveStateMachine(stateMachine) {
1582
1710
  }
1583
1711
 
1584
1712
  // ../task-list/src/backends/utils.ts
1585
- import path from "node:path";
1713
+ import path2 from "node:path";
1586
1714
  var tmpFileCounter = 0;
1587
1715
  function hasErrorCode2(error2, code) {
1588
1716
  return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
@@ -1615,7 +1743,7 @@ async function statIfExists(fs2, filePath) {
1615
1743
  async function writeAtomically(fs2, filePath, content) {
1616
1744
  const tempPath = `${filePath}.tmp-${process.pid}-${tmpFileCounter}`;
1617
1745
  tmpFileCounter += 1;
1618
- await fs2.mkdir(path.dirname(filePath), { recursive: true });
1746
+ await fs2.mkdir(path2.dirname(filePath), { recursive: true });
1619
1747
  try {
1620
1748
  await fs2.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
1621
1749
  await fs2.rename(tempPath, filePath);
@@ -1662,16 +1790,16 @@ function parseQualifiedId(qualifiedId) {
1662
1790
  };
1663
1791
  }
1664
1792
  function listPath(rootPath, list) {
1665
- return path2.join(rootPath, list);
1793
+ return path3.join(rootPath, list);
1666
1794
  }
1667
1795
  function archiveDirectoryPath(rootPath, list) {
1668
- return path2.join(listPath(rootPath, list), ARCHIVE_DIRECTORY_NAME);
1796
+ return path3.join(listPath(rootPath, list), ARCHIVE_DIRECTORY_NAME);
1669
1797
  }
1670
1798
  function activeTaskPath(rootPath, list, id) {
1671
- return path2.join(listPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
1799
+ return path3.join(listPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
1672
1800
  }
1673
1801
  function archivedTaskPath(rootPath, list, id) {
1674
- return path2.join(archiveDirectoryPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
1802
+ return path3.join(archiveDirectoryPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
1675
1803
  }
1676
1804
  function isMarkdownFile(entryName) {
1677
1805
  return entryName.endsWith(MARKDOWN_EXTENSION);
@@ -1903,7 +2031,7 @@ function createTasksView(deps, list) {
1903
2031
  if (isHiddenEntry(entryName) || isLockFile(entryName) || !isMarkdownFile(entryName)) {
1904
2032
  continue;
1905
2033
  }
1906
- const entryPath = path2.join(directoryPath, entryName);
2034
+ const entryPath = path3.join(directoryPath, entryName);
1907
2035
  const entryStat = await statIfExists(deps.fs, entryPath);
1908
2036
  if (!entryStat?.isFile()) {
1909
2037
  continue;
@@ -2058,7 +2186,7 @@ async function markdownDirBackend(deps) {
2058
2186
  if (entryName === ARCHIVE_DIRECTORY_NAME || isHiddenEntry(entryName) || isLockFile(entryName)) {
2059
2187
  continue;
2060
2188
  }
2061
- const entryPath = path2.join(deps.path, entryName);
2189
+ const entryPath = path3.join(deps.path, entryName);
2062
2190
  const entryStat = await statIfExists(deps.fs, entryPath);
2063
2191
  if (entryStat?.isDirectory()) {
2064
2192
  result.push(entryName);
@@ -2758,7 +2886,7 @@ function areEqualStrings(left, right) {
2758
2886
  }
2759
2887
 
2760
2888
  // ../toolcraft/src/human-in-loop/runner.ts
2761
- import { access, readFile, writeFile } from "node:fs/promises";
2889
+ import { access, readFile as readFile2, writeFile } from "node:fs/promises";
2762
2890
 
2763
2891
  // ../toolcraft/src/human-in-loop/default-provider.ts
2764
2892
  import process2 from "node:process";
@@ -3057,13 +3185,13 @@ function createHandlerContext(command, params17) {
3057
3185
  }
3058
3186
  function createFs() {
3059
3187
  return {
3060
- readFile: async (path12, encoding = "utf8") => readFile(path12, { encoding }),
3061
- writeFile: async (path12, contents) => {
3062
- await writeFile(path12, contents);
3188
+ readFile: async (path13, encoding = "utf8") => readFile2(path13, { encoding }),
3189
+ writeFile: async (path13, contents) => {
3190
+ await writeFile(path13, contents);
3063
3191
  },
3064
- exists: async (path12) => {
3192
+ exists: async (path13) => {
3065
3193
  try {
3066
- await access(path12);
3194
+ await access(path13);
3067
3195
  return true;
3068
3196
  } catch {
3069
3197
  return false;
@@ -3315,23 +3443,23 @@ function escapeMarkdownCell(value) {
3315
3443
  }
3316
3444
 
3317
3445
  // ../toolcraft/src/mcp-proxy.ts
3318
- import { existsSync } from "node:fs";
3319
- import { mkdir, readFile as readFile2, rename, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
3320
- import path5 from "node:path";
3446
+ import { existsSync as existsSync2 } from "node:fs";
3447
+ import { mkdir, readFile as readFile3, rename, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
3448
+ import path6 from "node:path";
3321
3449
 
3322
3450
  // ../tiny-mcp-client/src/internal.ts
3323
3451
  import { spawn as spawn3 } from "node:child_process";
3324
3452
  import { PassThrough as PassThrough2 } from "node:stream";
3325
3453
 
3326
- // ../mcp-oauth/src/client/auth-store-session-store.ts
3454
+ // ../mcp-oauth/dist/client/auth-store-session-store.js
3327
3455
  import crypto from "node:crypto";
3328
- import path4 from "node:path";
3456
+ import path5 from "node:path";
3329
3457
 
3330
3458
  // ../auth-store/src/encrypted-file-store.ts
3331
3459
  import { createCipheriv, createDecipheriv, randomBytes as randomBytes2, scrypt } from "node:crypto";
3332
3460
  import { promises as fs } from "node:fs";
3333
3461
  import { homedir, hostname as hostname2, userInfo } from "node:os";
3334
- import path3 from "node:path";
3462
+ import path4 from "node:path";
3335
3463
  var derivedKeyCache = /* @__PURE__ */ new Map();
3336
3464
  var ENCRYPTION_ALGORITHM = "aes-256-gcm";
3337
3465
  var ENCRYPTION_VERSION = 1;
@@ -3349,7 +3477,7 @@ var EncryptedFileStore = class {
3349
3477
  constructor(input) {
3350
3478
  this.fs = input.fs ?? fs;
3351
3479
  this.salt = input.salt;
3352
- this.filePath = input.filePath ?? path3.join(
3480
+ this.filePath = input.filePath ?? path4.join(
3353
3481
  (input.getHomeDirectory ?? homedir)(),
3354
3482
  input.defaultDirectory ?? ".auth-store",
3355
3483
  input.defaultFileName ?? "credentials.enc"
@@ -3402,7 +3530,7 @@ var EncryptedFileStore = class {
3402
3530
  authTag: authTag.toString("base64"),
3403
3531
  ciphertext: ciphertext.toString("base64")
3404
3532
  };
3405
- await this.fs.mkdir(path3.dirname(this.filePath), { recursive: true });
3533
+ await this.fs.mkdir(path4.dirname(this.filePath), { recursive: true });
3406
3534
  await this.fs.writeFile(this.filePath, JSON.stringify(document), {
3407
3535
  encoding: "utf8"
3408
3536
  });
@@ -3640,7 +3768,7 @@ function resolveBackend(input) {
3640
3768
  return "file";
3641
3769
  }
3642
3770
 
3643
- // ../mcp-oauth/src/resource-indicator.ts
3771
+ // ../mcp-oauth/dist/resource-indicator.js
3644
3772
  function canonicalizeResourceIndicator(value) {
3645
3773
  let url;
3646
3774
  try {
@@ -3652,7 +3780,7 @@ function canonicalizeResourceIndicator(value) {
3652
3780
  return url.toString();
3653
3781
  }
3654
3782
 
3655
- // ../mcp-oauth/src/client/auth-store-session-store.ts
3783
+ // ../mcp-oauth/dist/client/auth-store-session-store.js
3656
3784
  var DEFAULT_FILE_SALT = "poe-code:mcp-oauth:v1";
3657
3785
  var DEFAULT_FILE_DIRECTORY = ".poe-code/mcp-oauth";
3658
3786
  var DEFAULT_KEYCHAIN_SERVICE = "poe-code-mcp-oauth";
@@ -3709,7 +3837,7 @@ function createAuthStoreClientStore(options) {
3709
3837
  }
3710
3838
  function createNamedSecretStore(key2, options, defaults) {
3711
3839
  const hash = crypto.createHash("sha256").update(key2).digest("hex");
3712
- const parsedFilePath = options.fileStore?.filePath === void 0 ? null : path4.parse(options.fileStore.filePath);
3840
+ const parsedFilePath = options.fileStore?.filePath === void 0 ? null : path5.parse(options.fileStore.filePath);
3713
3841
  const fileStore = {
3714
3842
  ...options.fileStore,
3715
3843
  salt: options.fileStore?.salt ?? defaults.salt,
@@ -3724,37 +3852,29 @@ function createNamedSecretStore(key2, options, defaults) {
3724
3852
  return createSecretStore({ ...options, fileStore, keychainStore }).store;
3725
3853
  }
3726
3854
  function createResourceSecretStore(resource, options) {
3727
- return createNamedSecretStore(
3728
- canonicalizeResourceIndicator(resource),
3729
- options,
3730
- {
3731
- salt: DEFAULT_FILE_SALT,
3732
- directory: DEFAULT_FILE_DIRECTORY,
3733
- service: DEFAULT_KEYCHAIN_SERVICE,
3734
- accountPrefix: "provider"
3735
- }
3736
- );
3855
+ return createNamedSecretStore(canonicalizeResourceIndicator(resource), options, {
3856
+ salt: DEFAULT_FILE_SALT,
3857
+ directory: DEFAULT_FILE_DIRECTORY,
3858
+ service: DEFAULT_KEYCHAIN_SERVICE,
3859
+ accountPrefix: "provider"
3860
+ });
3737
3861
  }
3738
3862
  function createIssuerSecretStore(issuer, options) {
3739
- return createNamedSecretStore(
3740
- issuer,
3741
- options,
3742
- {
3743
- salt: DEFAULT_CLIENT_FILE_SALT,
3744
- directory: DEFAULT_CLIENT_FILE_DIRECTORY,
3745
- service: DEFAULT_CLIENT_KEYCHAIN_SERVICE,
3746
- accountPrefix: "issuer"
3747
- }
3748
- );
3863
+ return createNamedSecretStore(issuer, options, {
3864
+ salt: DEFAULT_CLIENT_FILE_SALT,
3865
+ directory: DEFAULT_CLIENT_FILE_DIRECTORY,
3866
+ service: DEFAULT_CLIENT_KEYCHAIN_SERVICE,
3867
+ accountPrefix: "issuer"
3868
+ });
3749
3869
  }
3750
3870
 
3751
- // ../mcp-oauth/src/client/default-oauth-client-provider.ts
3871
+ // ../mcp-oauth/dist/client/default-oauth-client-provider.js
3752
3872
  import { URL as URL2 } from "node:url";
3753
3873
 
3754
- // ../mcp-oauth/src/client/loopback-authorization.ts
3874
+ // ../mcp-oauth/dist/client/loopback-authorization.js
3755
3875
  import http from "node:http";
3756
3876
 
3757
- // ../mcp-oauth/src/client/authorization-state.ts
3877
+ // ../mcp-oauth/dist/client/authorization-state.js
3758
3878
  import crypto2 from "node:crypto";
3759
3879
  function createAuthorizationState(input) {
3760
3880
  const payload = {
@@ -3784,7 +3904,7 @@ function parseAuthorizationState(value) {
3784
3904
  }
3785
3905
  }
3786
3906
 
3787
- // ../mcp-oauth/src/client/loopback-authorization.ts
3907
+ // ../mcp-oauth/dist/client/loopback-authorization.js
3788
3908
  async function createLoopbackAuthorizationSession(options = {}) {
3789
3909
  const callbackPath = options.callbackPath ?? "/callback";
3790
3910
  const server = options.createServer ? options.createServer() : http.createServer();
@@ -3857,10 +3977,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
3857
3977
  return;
3858
3978
  }
3859
3979
  try {
3860
- const code = validateAuthorizationCallbackParameters(
3861
- callbackParameters,
3862
- expectedAuthorization
3863
- );
3980
+ const code = validateAuthorizationCallbackParameters(callbackParameters, expectedAuthorization);
3864
3981
  settle(() => resolve(code));
3865
3982
  } catch (error2) {
3866
3983
  settle(() => reject(error2 instanceof Error ? error2 : new Error(String(error2))));
@@ -3943,7 +4060,7 @@ function buildSuccessPage(landingPage) {
3943
4060
  ].join("");
3944
4061
  }
3945
4062
 
3946
- // ../mcp-oauth/src/client/pkce.ts
4063
+ // ../mcp-oauth/dist/client/pkce.js
3947
4064
  import crypto3 from "node:crypto";
3948
4065
  function generateCodeVerifier() {
3949
4066
  return crypto3.randomBytes(32).toString("base64url");
@@ -3952,7 +4069,7 @@ function generateCodeChallenge(verifier) {
3952
4069
  return crypto3.createHash("sha256").update(verifier).digest("base64url");
3953
4070
  }
3954
4071
 
3955
- // ../mcp-oauth/src/client/token-endpoint.ts
4072
+ // ../mcp-oauth/dist/client/token-endpoint.js
3956
4073
  var OAuthError = class extends Error {
3957
4074
  error;
3958
4075
  errorDescription;
@@ -4082,7 +4199,7 @@ function normalizeBearerTokenType(value) {
4082
4199
  return value.toLowerCase() === "bearer" ? "Bearer" : null;
4083
4200
  }
4084
4201
 
4085
- // ../mcp-oauth/src/client/default-oauth-client-provider.ts
4202
+ // ../mcp-oauth/dist/client/default-oauth-client-provider.js
4086
4203
  function createOAuthClientProvider(options) {
4087
4204
  if (isProviderOptions(options)) {
4088
4205
  return options.provider;
@@ -4116,16 +4233,10 @@ function createDefaultOAuthClientProvider(options) {
4116
4233
  const resource = canonicalizeResourceIndicator(input.discovery.resource);
4117
4234
  assertRequestMatchesResource(requestUrl, resource);
4118
4235
  const forceRefresh = hasCachedAccessToken(await loadSession(resource)) && input.challenge?.params.error === "invalid_token";
4119
- const session = await ensureAuthorizedSession(
4120
- resource,
4121
- {
4122
- ...input.discovery,
4123
- resource
4124
- },
4125
- input.fetch,
4126
- true,
4127
- forceRefresh
4128
- );
4236
+ const session = await ensureAuthorizedSession(resource, {
4237
+ ...input.discovery,
4238
+ resource
4239
+ }, input.fetch, true, forceRefresh);
4129
4240
  if (session?.tokens?.accessToken === void 0) {
4130
4241
  return { action: "fail" };
4131
4242
  }
@@ -4190,11 +4301,7 @@ function createDefaultOAuthClientProvider(options) {
4190
4301
  await saveSession(resource, clearedSession);
4191
4302
  return clearedSession;
4192
4303
  }
4193
- if (shouldReRegisterStoredDynamicClient(
4194
- error2,
4195
- await loadRegisteredClient(discovery.authorizationServer),
4196
- false
4197
- )) {
4304
+ if (shouldReRegisterStoredDynamicClient(error2, await loadRegisteredClient(discovery.authorizationServer), false)) {
4198
4305
  await clearRegisteredClient(discovery.authorizationServer);
4199
4306
  await clearSession(resource);
4200
4307
  return null;
@@ -4353,10 +4460,7 @@ function createDefaultOAuthClientProvider(options) {
4353
4460
  };
4354
4461
  }
4355
4462
  }
4356
- const registrationBody = buildClientRegistrationBody(
4357
- getClientMetadata(options.client),
4358
- redirectUri
4359
- );
4463
+ const registrationBody = buildClientRegistrationBody(getClientMetadata(options.client), redirectUri);
4360
4464
  const response = await fetch2(registrationEndpoint, {
4361
4465
  method: "POST",
4362
4466
  headers: {
@@ -4480,9 +4584,7 @@ function buildAuthorizationUrl(input) {
4480
4584
  }
4481
4585
  function assertS256PkceSupport(metadata) {
4482
4586
  if (!metadata.code_challenge_methods_supported.includes("S256")) {
4483
- throw new Error(
4484
- "Authorization server metadata must advertise code_challenge_methods_supported including S256"
4485
- );
4587
+ throw new Error("Authorization server metadata must advertise code_challenge_methods_supported including S256");
4486
4588
  }
4487
4589
  }
4488
4590
  function normalizeHostname(hostname3) {
@@ -4520,9 +4622,7 @@ function assertNoAccessTokenInUrl(value, label) {
4520
4622
  }
4521
4623
  function assertRequestMatchesResource(requestUrl, resource) {
4522
4624
  if (requestUrl !== resource) {
4523
- throw new Error(
4524
- `OAuth request URL ${requestUrl} does not match discovered resource ${resource}`
4525
- );
4625
+ throw new Error(`OAuth request URL ${requestUrl} does not match discovered resource ${resource}`);
4526
4626
  }
4527
4627
  }
4528
4628
  function buildClientRegistrationBody(metadata, redirectUri) {
@@ -4566,13 +4666,8 @@ function shouldReRegisterStoredDynamicClient(error2, client, alreadyAttempted) {
4566
4666
  return true;
4567
4667
  }
4568
4668
 
4569
- // ../mcp-oauth/src/server/jwks-token-verifier.ts
4570
- import {
4571
- decodeProtectedHeader,
4572
- errors,
4573
- importJWK,
4574
- jwtVerify
4575
- } from "jose";
4669
+ // ../mcp-oauth/dist/server/jwks-token-verifier.js
4670
+ import { decodeProtectedHeader, errors, importJWK, jwtVerify } from "jose";
4576
4671
 
4577
4672
  // ../tiny-mcp-client/src/oauth-discovery.ts
4578
4673
  function defaultOAuthMetadataFetch(input, init) {
@@ -6647,9 +6742,9 @@ function mergeJsonSchemas(base, overlay) {
6647
6742
  ...mergedRequired === void 0 ? {} : { required: mergedRequired }
6648
6743
  };
6649
6744
  }
6650
- function hasSelfReferencingRef(schema, root, path12 = "#", activePaths = /* @__PURE__ */ new Set()) {
6745
+ function hasSelfReferencingRef(schema, root, path13 = "#", activePaths = /* @__PURE__ */ new Set()) {
6651
6746
  const nextActivePaths = new Set(activePaths);
6652
- nextActivePaths.add(path12);
6747
+ nextActivePaths.add(path13);
6653
6748
  const localRefPath = getLocalRefPath(schema.$ref);
6654
6749
  if (localRefPath !== void 0) {
6655
6750
  if (nextActivePaths.has(localRefPath)) {
@@ -6660,13 +6755,13 @@ function hasSelfReferencingRef(schema, root, path12 = "#", activePaths = /* @__P
6660
6755
  return true;
6661
6756
  }
6662
6757
  }
6663
- if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${path12}/items`, nextActivePaths)) {
6758
+ if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${path13}/items`, nextActivePaths)) {
6664
6759
  return true;
6665
6760
  }
6666
6761
  if (typeof schema.additionalProperties === "object" && schema.additionalProperties !== null && hasSelfReferencingRef(
6667
6762
  schema.additionalProperties,
6668
6763
  root,
6669
- `${path12}/additionalProperties`,
6764
+ `${path13}/additionalProperties`,
6670
6765
  nextActivePaths
6671
6766
  )) {
6672
6767
  return true;
@@ -6675,7 +6770,7 @@ function hasSelfReferencingRef(schema, root, path12 = "#", activePaths = /* @__P
6675
6770
  if (hasSelfReferencingRef(
6676
6771
  childSchema,
6677
6772
  root,
6678
- `${path12}/properties/${escapeJsonPointerSegment(key2)}`,
6773
+ `${path13}/properties/${escapeJsonPointerSegment(key2)}`,
6679
6774
  nextActivePaths
6680
6775
  )) {
6681
6776
  return true;
@@ -6685,19 +6780,19 @@ function hasSelfReferencingRef(schema, root, path12 = "#", activePaths = /* @__P
6685
6780
  if (hasSelfReferencingRef(
6686
6781
  childSchema,
6687
6782
  root,
6688
- `${path12}/$defs/${escapeJsonPointerSegment(key2)}`,
6783
+ `${path13}/$defs/${escapeJsonPointerSegment(key2)}`,
6689
6784
  nextActivePaths
6690
6785
  )) {
6691
6786
  return true;
6692
6787
  }
6693
6788
  }
6694
6789
  for (const [index, childSchema] of (schema.oneOf ?? []).entries()) {
6695
- if (hasSelfReferencingRef(childSchema, root, `${path12}/oneOf/${index}`, nextActivePaths)) {
6790
+ if (hasSelfReferencingRef(childSchema, root, `${path13}/oneOf/${index}`, nextActivePaths)) {
6696
6791
  return true;
6697
6792
  }
6698
6793
  }
6699
6794
  for (const [index, childSchema] of (schema.anyOf ?? []).entries()) {
6700
- if (hasSelfReferencingRef(childSchema, root, `${path12}/anyOf/${index}`, nextActivePaths)) {
6795
+ if (hasSelfReferencingRef(childSchema, root, `${path13}/anyOf/${index}`, nextActivePaths)) {
6701
6796
  return true;
6702
6797
  }
6703
6798
  }
@@ -6713,14 +6808,14 @@ function getLocalRefPath(ref) {
6713
6808
  return ref.startsWith("#/") ? ref : void 0;
6714
6809
  }
6715
6810
  function resolveLocalRef(root, ref) {
6716
- const path12 = getLocalRefPath(ref);
6717
- if (path12 === void 0) {
6811
+ const path13 = getLocalRefPath(ref);
6812
+ if (path13 === void 0) {
6718
6813
  return void 0;
6719
6814
  }
6720
- if (path12 === "#") {
6815
+ if (path13 === "#") {
6721
6816
  return root;
6722
6817
  }
6723
- const segments = path12.slice(2).split("/").map(unescapeJsonPointerSegment);
6818
+ const segments = path13.slice(2).split("/").map(unescapeJsonPointerSegment);
6724
6819
  let current = root;
6725
6820
  for (const segment of segments) {
6726
6821
  if (Array.isArray(current)) {
@@ -6958,7 +7053,7 @@ async function ensureConnected(connection) {
6958
7053
  }
6959
7054
  async function readCache(cachePath) {
6960
7055
  try {
6961
- const raw = await readFile2(cachePath, "utf8");
7056
+ const raw = await readFile3(cachePath, "utf8");
6962
7057
  const parsed = JSON.parse(raw);
6963
7058
  if (parsed === null || typeof parsed !== "object" || !Array.isArray(parsed.tools) || parsed.upstream === void 0 || typeof parsed.upstream.name !== "string" || typeof parsed.upstream.version !== "string") {
6964
7059
  return void 0;
@@ -6979,7 +7074,7 @@ async function readCache(cachePath) {
6979
7074
  }
6980
7075
  }
6981
7076
  async function writeCache(cachePath, cache) {
6982
- const directory = path5.dirname(cachePath);
7077
+ const directory = path6.dirname(cachePath);
6983
7078
  const tempPath = `${cachePath}.tmp`;
6984
7079
  await mkdir(directory, { recursive: true });
6985
7080
  await writeFile2(tempPath, `${JSON.stringify(cache, null, 2)}
@@ -7065,7 +7160,7 @@ function isRefreshRequested(name, refresh) {
7065
7160
  }
7066
7161
  return refresh?.has(name) === true;
7067
7162
  }
7068
- async function resolveSingleProxy(group) {
7163
+ async function resolveSingleProxy(group, options) {
7069
7164
  const internal = getInternalGroupConfig2(group);
7070
7165
  const config = internal.mcp;
7071
7166
  if (config === void 0) {
@@ -7073,7 +7168,7 @@ async function resolveSingleProxy(group) {
7073
7168
  }
7074
7169
  const name = group.name;
7075
7170
  try {
7076
- const cachePath = resolveCachePath(name);
7171
+ const cachePath = resolveCachePath(name, options.projectRoot);
7077
7172
  const refresh = parseRefreshEnv(process.env.TOOLCRAFT_MCP_REFRESH);
7078
7173
  let cache;
7079
7174
  if (isRefreshRequested(name, refresh)) {
@@ -7122,14 +7217,14 @@ function collectProxyGroups(root) {
7122
7217
  }
7123
7218
  function resolveCachePath(name, projectRoot) {
7124
7219
  if (projectRoot !== void 0) {
7125
- return path5.join(projectRoot, ".toolcraft", "mcp", `${name}.json`);
7220
+ return path6.join(projectRoot, ".toolcraft", "mcp", `${name}.json`);
7126
7221
  }
7127
7222
  let current = process.cwd();
7128
7223
  while (true) {
7129
- if (existsSync(path5.join(current, "package.json"))) {
7130
- return path5.join(current, ".toolcraft", "mcp", `${name}.json`);
7224
+ if (existsSync2(path6.join(current, "package.json"))) {
7225
+ return path6.join(current, ".toolcraft", "mcp", `${name}.json`);
7131
7226
  }
7132
- const parent = path5.dirname(current);
7227
+ const parent = path6.dirname(current);
7133
7228
  if (parent === current) {
7134
7229
  throw new Error(
7135
7230
  `Could not find package.json above "${process.cwd()}" while resolving MCP cache path.`
@@ -7167,9 +7262,9 @@ async function dialUpstream(name, config) {
7167
7262
  await client.connect(transport);
7168
7263
  return client;
7169
7264
  }
7170
- async function resolveMcpProxies(root) {
7265
+ async function resolveMcpProxies(root, options = {}) {
7171
7266
  const groups = collectProxyGroups(root);
7172
- await Promise.all(groups.map((group) => resolveSingleProxy(group)));
7267
+ await Promise.all(groups.map((group) => resolveSingleProxy(group, options)));
7173
7268
  }
7174
7269
 
7175
7270
  // ../toolcraft/src/number-schema.ts
@@ -7349,7 +7444,7 @@ function inferProgramName(argv) {
7349
7444
  if (typeof entrypoint !== "string" || entrypoint.length === 0) {
7350
7445
  return "toolcraft";
7351
7446
  }
7352
- const parsed = path6.parse(entrypoint);
7447
+ const parsed = path7.parse(entrypoint);
7353
7448
  return parsed.name.length > 0 ? parsed.name : "toolcraft";
7354
7449
  }
7355
7450
  function normalizeRoots(roots, argv) {
@@ -7407,11 +7502,11 @@ function formatSegment(segment, casing) {
7407
7502
  const separator = casing === "snake" ? "_" : "-";
7408
7503
  return splitWords(segment).join(separator);
7409
7504
  }
7410
- function toOptionFlag(path12, casing) {
7411
- return `--${path12.map((segment) => formatSegment(segment, casing)).join(".")}`;
7505
+ function toOptionFlag(path13, casing) {
7506
+ return `--${path13.map((segment) => formatSegment(segment, casing)).join(".")}`;
7412
7507
  }
7413
- function toOptionAttribute(path12, casing) {
7414
- return path12.map((segment) => {
7508
+ function toOptionAttribute(path13, casing) {
7509
+ return path13.map((segment) => {
7415
7510
  const formatted = formatSegment(segment, casing);
7416
7511
  if (casing === "snake") {
7417
7512
  return formatted;
@@ -7422,23 +7517,23 @@ function toOptionAttribute(path12, casing) {
7422
7517
  ).join("");
7423
7518
  }).join(".");
7424
7519
  }
7425
- function toDisplayPath(path12) {
7426
- return path12.join(".");
7520
+ function toDisplayPath(path13) {
7521
+ return path13.join(".");
7427
7522
  }
7428
- function toUnionKindControlPath(path12) {
7429
- if (path12.length === 0) {
7523
+ function toUnionKindControlPath(path13) {
7524
+ if (path13.length === 0) {
7430
7525
  return ["kind"];
7431
7526
  }
7432
- const head = path12.slice(0, -1);
7433
- const tail = path12[path12.length - 1] ?? "";
7527
+ const head = path13.slice(0, -1);
7528
+ const tail = path13[path13.length - 1] ?? "";
7434
7529
  return [...head, `${tail}Kind`];
7435
7530
  }
7436
- function toUnionKindDisplayPath(path12) {
7437
- if (path12.length === 0) {
7531
+ function toUnionKindDisplayPath(path13) {
7532
+ if (path13.length === 0) {
7438
7533
  return "kind";
7439
7534
  }
7440
- const head = path12.slice(0, -1);
7441
- const tail = path12[path12.length - 1] ?? "";
7535
+ const head = path13.slice(0, -1);
7536
+ const tail = path13[path13.length - 1] ?? "";
7442
7537
  return [...head, `${tail}-kind`].join(".");
7443
7538
  }
7444
7539
  function createSyntheticEnumSchema(values) {
@@ -7454,19 +7549,19 @@ function getRequiredBranchFingerprint(branch, casing) {
7454
7549
  const requiredKeys = Object.entries(branch.shape).filter(([, schema]) => schema.kind !== "optional").map(([key2]) => formatSegment(key2, casing)).sort();
7455
7550
  return requiredKeys.join("+");
7456
7551
  }
7457
- function collectFields(schema, casing, path12 = [], inheritedOptional = false, variantContext) {
7552
+ function collectFields(schema, casing, globalLongOptionFlags, path13 = [], inheritedOptional = false, variantContext) {
7458
7553
  const collected = {
7459
7554
  dynamicFields: [],
7460
7555
  fields: [],
7461
7556
  variants: []
7462
7557
  };
7463
7558
  for (const [key2, rawChildSchema] of Object.entries(schema.shape)) {
7464
- const nextPath = [...path12, key2];
7559
+ const nextPath = [...path13, key2];
7465
7560
  const runtimeOptional = inheritedOptional || rawChildSchema.kind === "optional";
7466
7561
  const childSchema = unwrapOptional(rawChildSchema);
7467
7562
  const requiredWhenActive = rawChildSchema.kind !== "optional" && childSchema.default === void 0;
7468
7563
  if (childSchema.kind === "object") {
7469
- const nested = collectFields(childSchema, casing, nextPath, runtimeOptional, variantContext);
7564
+ const nested = collectFields(childSchema, casing, globalLongOptionFlags, nextPath, runtimeOptional, variantContext);
7470
7565
  collected.dynamicFields.push(...nested.dynamicFields);
7471
7566
  collected.fields.push(...nested.fields);
7472
7567
  collected.variants.push(...nested.variants);
@@ -7480,7 +7575,7 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7480
7575
  path: [...nextPath, childSchema.discriminator],
7481
7576
  displayPath: toDisplayPath([...nextPath, childSchema.discriminator]),
7482
7577
  optionAttribute: toOptionAttribute([...nextPath, childSchema.discriminator], casing),
7483
- commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing),
7578
+ commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing, globalLongOptionFlags),
7484
7579
  optionFlag: toOptionFlag([...nextPath, childSchema.discriminator], casing),
7485
7580
  shortFlag: void 0,
7486
7581
  schema: createSyntheticEnumSchema(branchIds),
@@ -7493,7 +7588,7 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7493
7588
  collected.fields.push(controlField);
7494
7589
  const branches = [];
7495
7590
  for (const [branchId, branchSchema] of Object.entries(childSchema.branches)) {
7496
- const branch = collectFields(branchSchema, casing, nextPath, true, {
7591
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
7497
7592
  id: variantId,
7498
7593
  branchId
7499
7594
  });
@@ -7527,7 +7622,7 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7527
7622
  path: controlPath,
7528
7623
  displayPath: controlDisplayPath,
7529
7624
  optionAttribute: toOptionAttribute(controlPath, casing),
7530
- commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing),
7625
+ commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing, globalLongOptionFlags),
7531
7626
  optionFlag: toOptionFlag(controlPath, casing),
7532
7627
  shortFlag: void 0,
7533
7628
  schema: createSyntheticEnumSchema(branchIds),
@@ -7542,7 +7637,7 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7542
7637
  const branches = [];
7543
7638
  childSchema.branches.forEach((branchSchema, index) => {
7544
7639
  const branchId = branchIds[index] ?? "";
7545
- const branch = collectFields(branchSchema, casing, nextPath, true, {
7640
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
7546
7641
  id: variantId,
7547
7642
  branchId
7548
7643
  });
@@ -7609,7 +7704,7 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7609
7704
  path: nextPath,
7610
7705
  displayPath: toDisplayPath(nextPath),
7611
7706
  optionAttribute: toOptionAttribute(nextPath, casing),
7612
- commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing),
7707
+ commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing, globalLongOptionFlags),
7613
7708
  optionFlag: toOptionFlag(nextPath, casing),
7614
7709
  shortFlag: childSchema.short,
7615
7710
  schema: childSchema,
@@ -7624,10 +7719,10 @@ function collectFields(schema, casing, path12 = [], inheritedOptional = false, v
7624
7719
  }
7625
7720
  return collected;
7626
7721
  }
7627
- function toCommanderOptionAttribute(path12, casing) {
7628
- const optionAttribute = toOptionAttribute(path12, casing);
7629
- const optionFlag = toOptionFlag(path12, casing);
7630
- if (!GLOBAL_LONG_OPTION_FLAGS.has(optionFlag)) {
7722
+ function toCommanderOptionAttribute(path13, casing, globalLongOptionFlags) {
7723
+ const optionAttribute = toOptionAttribute(path13, casing);
7724
+ const optionFlag = toOptionFlag(path13, casing);
7725
+ if (!globalLongOptionFlags.has(optionFlag)) {
7631
7726
  return optionAttribute;
7632
7727
  }
7633
7728
  return `param_${optionAttribute}`;
@@ -7657,8 +7752,8 @@ function assignPositionals(fields, positional) {
7657
7752
  });
7658
7753
  return fields;
7659
7754
  }
7660
- function formatOptionFlags(field) {
7661
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
7755
+ function formatOptionFlags(field, globalLongOptionFlags) {
7756
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
7662
7757
  if (collidesWithGlobalFlag) {
7663
7758
  if (field.shortFlag === void 0) {
7664
7759
  throw new UserError(
@@ -7776,9 +7871,9 @@ function parseArrayValue(value, schema, label) {
7776
7871
  }
7777
7872
  return splitArrayInput(value).map((item) => parseScalarValue(item, itemSchema, label));
7778
7873
  }
7779
- function createOption(field) {
7780
- const flags = formatOptionFlags(field);
7781
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
7874
+ function createOption(field, globalLongOptionFlags) {
7875
+ const flags = formatOptionFlags(field, globalLongOptionFlags);
7876
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
7782
7877
  const commanderValue = (value) => value === null ? NULL_OPTION_VALUE : value;
7783
7878
  if (field.schema.kind === "boolean") {
7784
7879
  if (collidesWithGlobalFlag) {
@@ -7823,7 +7918,10 @@ function createOption(field) {
7823
7918
  );
7824
7919
  return [option];
7825
7920
  }
7826
- var GLOBAL_LONG_OPTION_FLAGS = /* @__PURE__ */ new Set(["--preset", "--yes", "--output", "--verbose"]);
7921
+ var ALWAYS_GLOBAL_LONG_OPTION_FLAGS = ["--yes", "--output", "--verbose"];
7922
+ function getGlobalLongOptionFlags(presetsEnabled) {
7923
+ return new Set(presetsEnabled ? ["--preset", ...ALWAYS_GLOBAL_LONG_OPTION_FLAGS] : ALWAYS_GLOBAL_LONG_OPTION_FLAGS);
7924
+ }
7827
7925
  function createCommanderOption(flags, description, field) {
7828
7926
  const option = new Option(flags, description);
7829
7927
  if (field.commanderOptionAttribute !== field.optionAttribute) {
@@ -7917,14 +8015,14 @@ function describeSchemaType(schema) {
7917
8015
  throw new UserError("Unsupported CLI schema kind.");
7918
8016
  }
7919
8017
  }
7920
- function formatHelpFieldFlags(field) {
8018
+ function formatHelpFieldFlags(field, globalLongOptionFlags) {
7921
8019
  if (field.positionalIndex !== void 0) {
7922
8020
  return formatPositionalToken(field);
7923
8021
  }
7924
8022
  if (field.schema.kind === "boolean") {
7925
- return `${formatOptionFlags(field)} [value]`;
8023
+ return `${formatOptionFlags(field, globalLongOptionFlags)} [value]`;
7926
8024
  }
7927
- return `${formatOptionFlags(field)} <${describeSchemaType(field.schema)}>`;
8025
+ return `${formatOptionFlags(field, globalLongOptionFlags)} <${describeSchemaType(field.schema)}>`;
7928
8026
  }
7929
8027
  function appendHelpMetadata(description, metadata) {
7930
8028
  if (metadata.length === 0) {
@@ -8066,18 +8164,52 @@ function formatSecretDescription(secret) {
8066
8164
  }
8067
8165
  return secret.optional === true ? "Optional secret" : "Required secret";
8068
8166
  }
8069
- function formatCommandRows(group, scope) {
8070
- return getVisibleChildren(group, scope).map((child) => ({
8071
- name: child.aliases.length === 0 ? child.name : `${child.name} (${child.aliases.join(", ")})`,
8072
- description: child.description ?? ""
8073
- }));
8167
+ function wrapOptionalCommandParameterToken(token, optional) {
8168
+ return optional ? `[${token}]` : token;
8074
8169
  }
8075
- function formatGlobalOptionRows(showVersion) {
8076
- const rows = [
8077
- {
8170
+ function formatCommandDynamicParameterTokens(field, casing) {
8171
+ const optional = field.optional || field.hasDefault;
8172
+ return formatDynamicHelpFields(field, casing).map(
8173
+ (row) => wrapOptionalCommandParameterToken(row.flags, optional)
8174
+ );
8175
+ }
8176
+ function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
8177
+ const collected = collectFields(command.params, casing, globalLongOptionFlags);
8178
+ const fields = assignPositionals(collected.fields, command.positional);
8179
+ return fields.map(
8180
+ (field) => wrapOptionalCommandParameterToken(
8181
+ formatHelpFieldFlags(field, globalLongOptionFlags),
8182
+ field.positionalIndex === void 0 && (field.optional || field.hasDefault)
8183
+ )
8184
+ ).concat(collected.dynamicFields.flatMap((field) => formatCommandDynamicParameterTokens(field, casing)));
8185
+ }
8186
+ function formatCommandRowName(node, depth, casing, globalLongOptionFlags) {
8187
+ const baseName = node.aliases.length === 0 ? node.name : `${node.name} (${node.aliases.join(", ")})`;
8188
+ const parameterTokens = node.kind === "command" ? formatCommandParameterTokens(node, casing, globalLongOptionFlags) : [];
8189
+ const name = parameterTokens.length === 0 ? baseName : `${baseName} ${parameterTokens.join(" ")}`;
8190
+ return `${" ".repeat(depth)}${name}`;
8191
+ }
8192
+ function formatCommandRows(group, scope, casing, globalLongOptionFlags, depth = 0) {
8193
+ return getVisibleChildren(group, scope).flatMap((child) => {
8194
+ const row = {
8195
+ name: formatCommandRowName(child, depth, casing, globalLongOptionFlags),
8196
+ description: child.description ?? ""
8197
+ };
8198
+ if (child.kind === "command") {
8199
+ return [row];
8200
+ }
8201
+ return [row, ...formatCommandRows(child, scope, casing, globalLongOptionFlags, depth + 1)];
8202
+ });
8203
+ }
8204
+ function formatGlobalOptionRows(showVersion, presetsEnabled) {
8205
+ const rows = [];
8206
+ if (presetsEnabled) {
8207
+ rows.push({
8078
8208
  flags: "--preset <path>",
8079
8209
  description: "Load parameter defaults from a JSON file"
8080
- },
8210
+ });
8211
+ }
8212
+ rows.push(
8081
8213
  {
8082
8214
  flags: "--yes",
8083
8215
  description: "Accept defaults, skip prompts"
@@ -8090,7 +8222,7 @@ function formatGlobalOptionRows(showVersion) {
8090
8222
  flags: "-h, --help",
8091
8223
  description: "Show help"
8092
8224
  }
8093
- ];
8225
+ );
8094
8226
  if (showVersion) {
8095
8227
  rows.push({
8096
8228
  flags: "--version",
@@ -8109,15 +8241,16 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
8109
8241
  const subPath = breadcrumb.slice(1).join(" ");
8110
8242
  return subPath ? `${rootUsageName} ${subPath} ${suffix}` : `${rootUsageName} ${suffix}`;
8111
8243
  }
8112
- function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
8244
+ function renderGroupHelp(group, breadcrumb, scope, casing, showVersion, presetsEnabled, rootUsageName) {
8113
8245
  const sections = [];
8114
- const commandRows = formatCommandRows(group, scope);
8246
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
8247
+ const commandRows = formatCommandRows(group, scope, casing, globalLongOptionFlags);
8115
8248
  if (commandRows.length > 0) {
8116
8249
  sections.push(`${text.section("Commands:")}
8117
8250
  ${formatCommandList(commandRows)}`);
8118
8251
  }
8119
8252
  sections.push(`${text.section("Global options:")}
8120
- ${formatOptionList(formatGlobalOptionRows(showVersion))}`);
8253
+ ${formatOptionList(formatGlobalOptionRows(showVersion, presetsEnabled))}`);
8121
8254
  return renderHelpDocument({
8122
8255
  breadcrumb,
8123
8256
  usageLine: buildUsageLine(breadcrumb, rootUsageName, "[options] [command]"),
@@ -8126,12 +8259,13 @@ ${formatOptionList(formatGlobalOptionRows(showVersion))}`);
8126
8259
  sections
8127
8260
  });
8128
8261
  }
8129
- function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
8262
+ function renderLeafHelp(command, breadcrumb, casing, presetsEnabled, rootUsageName) {
8130
8263
  const sections = [];
8131
- const collected = collectFields(command.params, casing);
8264
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
8265
+ const collected = collectFields(command.params, casing, globalLongOptionFlags);
8132
8266
  const fields = assignPositionals(collected.fields, command.positional);
8133
8267
  const optionRows = fields.map((field) => ({
8134
- flags: formatHelpFieldFlags(field),
8268
+ flags: formatHelpFieldFlags(field, globalLongOptionFlags),
8135
8269
  description: formatHelpFieldDescription(field)
8136
8270
  })).concat(collected.dynamicFields.flatMap((field) => formatDynamicHelpFields(field, casing)));
8137
8271
  if (optionRows.length > 0) {
@@ -8139,7 +8273,7 @@ function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
8139
8273
  ${formatOptionList(optionRows)}`);
8140
8274
  }
8141
8275
  sections.push(`${text.section("Global options:")}
8142
- ${formatOptionList(formatGlobalOptionRows(false))}`);
8276
+ ${formatOptionList(formatGlobalOptionRows(false, presetsEnabled))}`);
8143
8277
  const secretRows = formatSecretRows(command.secrets);
8144
8278
  if (secretRows.length > 0) {
8145
8279
  sections.push(`${text.section("Secrets (via environment):")}
@@ -8178,25 +8312,33 @@ async function renderGeneratedHelp(root, argv, options) {
8178
8312
  const output = resolveHelpOutput(argv);
8179
8313
  const casing = options.casing ?? "kebab";
8180
8314
  await withOutputFormat2(output, async () => {
8181
- const rendered = target.node.kind === "group" ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== void 0, options.rootUsageName) : renderLeafHelp(target.node, target.breadcrumb, casing, options.rootUsageName);
8315
+ const rendered = target.node.kind === "group" ? renderGroupHelp(
8316
+ target.node,
8317
+ target.breadcrumb,
8318
+ "cli",
8319
+ casing,
8320
+ options.version !== void 0,
8321
+ options.presets === true,
8322
+ options.rootUsageName
8323
+ ) : renderLeafHelp(target.node, target.breadcrumb, casing, options.presets === true, options.rootUsageName);
8182
8324
  process.stdout.write(rendered);
8183
8325
  });
8184
8326
  }
8185
- function createNodeCommand(node, casing, execute, pathSegments = []) {
8327
+ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presetsEnabled, pathSegments = []) {
8186
8328
  const nextPathSegments = [...pathSegments, node.name];
8187
8329
  if (node.kind === "command") {
8188
8330
  if (!node.scope.includes("cli")) {
8189
8331
  return null;
8190
8332
  }
8191
8333
  const command = new CommanderCommand(node.name);
8192
- const collected = collectFields(node.params, casing);
8334
+ const collected = collectFields(node.params, casing, globalLongOptionFlags);
8193
8335
  const fields = assignPositionals(collected.fields, node.positional);
8194
8336
  if (node.description !== void 0) {
8195
8337
  command.description(node.description);
8196
8338
  }
8197
8339
  node.aliases.forEach((alias) => command.alias(alias));
8198
8340
  command.addHelpCommand(false);
8199
- addGlobalOptions(command);
8341
+ addGlobalOptions(command, presetsEnabled);
8200
8342
  command.allowExcessArguments(true);
8201
8343
  if (collected.dynamicFields.length > 0) {
8202
8344
  command.allowUnknownOption(true);
@@ -8206,7 +8348,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
8206
8348
  command.argument(formatPositionalToken(field));
8207
8349
  continue;
8208
8350
  }
8209
- for (const option of createOption(field)) {
8351
+ for (const option of createOption(field, globalLongOptionFlags)) {
8210
8352
  command.addOption(option);
8211
8353
  }
8212
8354
  }
@@ -8220,6 +8362,7 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
8220
8362
  dynamicFields: collected.dynamicFields,
8221
8363
  fields,
8222
8364
  positionalValues,
8365
+ presetsEnabled,
8223
8366
  rawArgv: actionCommand.args,
8224
8367
  actionCommand,
8225
8368
  variants: collected.variants
@@ -8230,22 +8373,25 @@ function createNodeCommand(node, casing, execute, pathSegments = []) {
8230
8373
  if (!isNodeVisibleInScope(node, "cli")) {
8231
8374
  return null;
8232
8375
  }
8233
- const visibleChildren = node.children.map((child) => createNodeCommand(child, casing, execute, nextPathSegments)).filter((child) => child !== null);
8376
+ const visibleChildren = node.children.map((child) => createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled, nextPathSegments)).filter((child) => child !== null);
8234
8377
  const group = new CommanderCommand(node.name);
8235
8378
  if (node.description !== void 0) {
8236
8379
  group.description(node.description);
8237
8380
  }
8238
8381
  node.aliases.forEach((alias) => group.alias(alias));
8239
8382
  group.addHelpCommand(false);
8240
- addGlobalOptions(group);
8383
+ addGlobalOptions(group, presetsEnabled);
8241
8384
  for (const child of visibleChildren) {
8242
8385
  const isDefaultChild = node.default !== void 0 && node.default.scope.includes("cli") && (child.name() === node.default.name || child.aliases().includes(node.default.name));
8243
8386
  group.addCommand(child, isDefaultChild ? { isDefault: true } : void 0);
8244
8387
  }
8245
8388
  return group;
8246
8389
  }
8247
- function addGlobalOptions(command) {
8248
- command.option("--preset <path>", "Load parameter defaults from a JSON file.").option("--yes", "Accept defaults and skip prompts.").option("--output <format>", "Output format.", (value) => {
8390
+ function addGlobalOptions(command, presetsEnabled) {
8391
+ if (presetsEnabled) {
8392
+ command.option("--preset <path>", "Load parameter defaults from a JSON file.");
8393
+ }
8394
+ command.option("--yes", "Accept defaults and skip prompts.").option("--output <format>", "Output format.", (value) => {
8249
8395
  if (value === "rich" || value === "md" || value === "json") {
8250
8396
  return value;
8251
8397
  }
@@ -8255,10 +8401,10 @@ function addGlobalOptions(command) {
8255
8401
  throw new InvalidArgumentError('Invalid value for "--output". Expected one of: rich, md, markdown, json.');
8256
8402
  }).option("--verbose", "Print stack traces for unexpected errors.");
8257
8403
  }
8258
- function setNestedValue(target, path12, value) {
8404
+ function setNestedValue(target, path13, value) {
8259
8405
  let cursor = target;
8260
- for (let index = 0; index < path12.length - 1; index += 1) {
8261
- const segment = path12[index] ?? "";
8406
+ for (let index = 0; index < path13.length - 1; index += 1) {
8407
+ const segment = path13[index] ?? "";
8262
8408
  const existing = cursor[segment];
8263
8409
  if (typeof existing === "object" && existing !== null) {
8264
8410
  cursor = existing;
@@ -8268,7 +8414,7 @@ function setNestedValue(target, path12, value) {
8268
8414
  cursor[segment] = next;
8269
8415
  cursor = next;
8270
8416
  }
8271
- const leaf = path12[path12.length - 1];
8417
+ const leaf = path13[path13.length - 1];
8272
8418
  if (leaf !== void 0) {
8273
8419
  cursor[leaf] = value;
8274
8420
  }
@@ -8370,13 +8516,13 @@ async function withOutputFormat2(output, fn) {
8370
8516
  }
8371
8517
  function createFs2() {
8372
8518
  return {
8373
- readFile: async (path12, encoding = "utf8") => readFile3(path12, { encoding }),
8374
- writeFile: async (path12, contents) => {
8375
- await writeFile3(path12, contents);
8519
+ readFile: async (path13, encoding = "utf8") => readFile4(path13, { encoding }),
8520
+ writeFile: async (path13, contents) => {
8521
+ await writeFile3(path13, contents);
8376
8522
  },
8377
- exists: async (path12) => {
8523
+ exists: async (path13) => {
8378
8524
  try {
8379
- await access2(path12);
8525
+ await access2(path13);
8380
8526
  return true;
8381
8527
  } catch {
8382
8528
  return false;
@@ -8397,9 +8543,9 @@ function isPlainObject2(value) {
8397
8543
  function hasFieldValue(value) {
8398
8544
  return value !== void 0;
8399
8545
  }
8400
- function hasNestedField(fields, path12) {
8546
+ function hasNestedField(fields, path13) {
8401
8547
  return fields.some(
8402
- (field) => path12.length < field.path.length && path12.every((segment, index) => field.path[index] === segment)
8548
+ (field) => path13.length < field.path.length && path13.every((segment, index) => field.path[index] === segment)
8403
8549
  );
8404
8550
  }
8405
8551
  function describeExpectedPresetValue(schema) {
@@ -8474,7 +8620,7 @@ function validatePresetFieldValue(value, field, presetPath) {
8474
8620
  async function loadPresetValues(fields, presetPath) {
8475
8621
  let rawPreset;
8476
8622
  try {
8477
- rawPreset = await readFile3(presetPath, {
8623
+ rawPreset = await readFile4(presetPath, {
8478
8624
  encoding: "utf8"
8479
8625
  });
8480
8626
  } catch (error2) {
@@ -8495,9 +8641,9 @@ async function loadPresetValues(fields, presetPath) {
8495
8641
  }
8496
8642
  const fieldByPath = new Map(fields.map((field) => [field.displayPath, field]));
8497
8643
  const presetValues = {};
8498
- function visitObject(current, path12) {
8644
+ function visitObject(current, path13) {
8499
8645
  for (const [key2, value] of Object.entries(current)) {
8500
- const nextPath = [...path12, key2];
8646
+ const nextPath = [...path13, key2];
8501
8647
  const displayPath = toDisplayPath(nextPath);
8502
8648
  const field = fieldByPath.get(displayPath);
8503
8649
  if (field !== void 0) {
@@ -8695,8 +8841,8 @@ function createFixtureService(definition) {
8695
8841
  );
8696
8842
  }
8697
8843
  function resolveFixturePath(commandPath) {
8698
- const parsed = path6.parse(commandPath);
8699
- return path6.join(parsed.dir, `${parsed.name}.fixture.json`);
8844
+ const parsed = path7.parse(commandPath);
8845
+ return path7.join(parsed.dir, `${parsed.name}.fixture.json`);
8700
8846
  }
8701
8847
  function selectFixtureScenario(scenarios, selector) {
8702
8848
  if (isNumericFixtureSelector(selector)) {
@@ -8723,7 +8869,7 @@ async function loadFixtureScenario(command, selector) {
8723
8869
  const fixturePath = resolveFixturePath(commandPath);
8724
8870
  let rawFixture;
8725
8871
  try {
8726
- rawFixture = await readFile3(fixturePath, {
8872
+ rawFixture = await readFile4(fixturePath, {
8727
8873
  encoding: "utf8"
8728
8874
  });
8729
8875
  } catch {
@@ -8819,8 +8965,8 @@ function validateServices(services) {
8819
8965
  }
8820
8966
  }
8821
8967
  }
8822
- function getNestedValue(target, path12) {
8823
- return path12.reduce(
8968
+ function getNestedValue(target, path13) {
8969
+ return path13.reduce(
8824
8970
  (current, segment) => current !== null && typeof current === "object" ? current[segment] : void 0,
8825
8971
  target
8826
8972
  );
@@ -9286,7 +9432,7 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
9286
9432
  optionValues,
9287
9433
  state.rawArgv,
9288
9434
  state.casing,
9289
- resolvedFlags.preset,
9435
+ state.presetsEnabled ? resolvedFlags.preset : void 0,
9290
9436
  shouldPrompt
9291
9437
  );
9292
9438
  const context = {
@@ -9350,10 +9496,11 @@ function handleRunError(error2, verbose) {
9350
9496
  }
9351
9497
  async function runCLI(roots, options = {}) {
9352
9498
  const root = mergeApprovalsGroup(normalizeRoots(roots, process.argv));
9353
- await resolveMcpProxies(root);
9499
+ await resolveMcpProxies(root, { projectRoot: options.projectRoot });
9354
9500
  const casing = options.casing ?? "kebab";
9355
9501
  const services = options.services ?? {};
9356
9502
  const runtimeOptions = options.humanInLoop ?? {};
9503
+ const version = options.version ?? findEntrypointPackageMetadata(process.argv[1])?.version;
9357
9504
  const servicesWithBuiltIns = {
9358
9505
  ...services,
9359
9506
  runtimeOptions,
@@ -9364,7 +9511,7 @@ async function runCLI(roots, options = {}) {
9364
9511
  };
9365
9512
  validateServices(services);
9366
9513
  if (hasHelpFlag(process.argv)) {
9367
- await renderGeneratedHelp(root, process.argv, options);
9514
+ await renderGeneratedHelp(root, process.argv, { ...options, version });
9368
9515
  return;
9369
9516
  }
9370
9517
  const program = new CommanderCommand();
@@ -9372,9 +9519,11 @@ async function runCLI(roots, options = {}) {
9372
9519
  program.exitOverride();
9373
9520
  program.showHelpAfterError();
9374
9521
  program.addHelpCommand(false);
9375
- addGlobalOptions(program);
9376
- if (options.version !== void 0) {
9377
- program.version(options.version, "--version");
9522
+ const presetsEnabled = options.presets === true;
9523
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
9524
+ addGlobalOptions(program, presetsEnabled);
9525
+ if (version !== void 0) {
9526
+ program.version(version, "--version");
9378
9527
  }
9379
9528
  let lastActionCommand;
9380
9529
  const execute = async (state) => {
@@ -9382,7 +9531,7 @@ async function runCLI(roots, options = {}) {
9382
9531
  await executeCommand(state, servicesWithBuiltIns, requirementOptions, runtimeOptions);
9383
9532
  };
9384
9533
  for (const child of root.children) {
9385
- const command = createNodeCommand(child, casing, execute);
9534
+ const command = createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled);
9386
9535
  if (command === null) {
9387
9536
  continue;
9388
9537
  }
@@ -10680,7 +10829,7 @@ var getSession = defineCommand({
10680
10829
 
10681
10830
  // ../agent-skill-config/src/configs.ts
10682
10831
  import os2 from "node:os";
10683
- import path7 from "node:path";
10832
+ import path8 from "node:path";
10684
10833
 
10685
10834
  // ../agent-defs/src/agents/claude-code.ts
10686
10835
  var claudeCodeAgent = {
@@ -11201,20 +11350,20 @@ function getConfigFormat(pathOrFormat) {
11201
11350
  }
11202
11351
  return formatRegistry[formatName];
11203
11352
  }
11204
- function detectFormat(path12) {
11205
- const ext = getExtension(path12);
11353
+ function detectFormat(path13) {
11354
+ const ext = getExtension(path13);
11206
11355
  return extensionMap[ext];
11207
11356
  }
11208
- function getExtension(path12) {
11209
- const lastDot = path12.lastIndexOf(".");
11357
+ function getExtension(path13) {
11358
+ const lastDot = path13.lastIndexOf(".");
11210
11359
  if (lastDot === -1) {
11211
11360
  return "";
11212
11361
  }
11213
- return path12.slice(lastDot).toLowerCase();
11362
+ return path13.slice(lastDot).toLowerCase();
11214
11363
  }
11215
11364
 
11216
11365
  // ../config-mutations/src/execution/path-utils.ts
11217
- import path8 from "node:path";
11366
+ import path9 from "node:path";
11218
11367
  function expandHome(targetPath, homeDir) {
11219
11368
  if (!targetPath?.startsWith("~")) {
11220
11369
  return targetPath;
@@ -11231,7 +11380,7 @@ function expandHome(targetPath, homeDir) {
11231
11380
  remainder = remainder.slice(1);
11232
11381
  }
11233
11382
  }
11234
- return remainder.length === 0 ? homeDir : path8.join(homeDir, remainder);
11383
+ return remainder.length === 0 ? homeDir : path9.join(homeDir, remainder);
11235
11384
  }
11236
11385
  function validateHomePath(targetPath) {
11237
11386
  if (typeof targetPath !== "string" || targetPath.length === 0) {
@@ -11249,12 +11398,12 @@ function resolvePath(rawPath, homeDir, pathMapper) {
11249
11398
  if (!pathMapper) {
11250
11399
  return expanded;
11251
11400
  }
11252
- const rawDirectory = path8.dirname(expanded);
11401
+ const rawDirectory = path9.dirname(expanded);
11253
11402
  const mappedDirectory = pathMapper.mapTargetDirectory({
11254
11403
  targetDirectory: rawDirectory
11255
11404
  });
11256
- const filename = path8.basename(expanded);
11257
- return filename.length === 0 ? mappedDirectory : path8.join(mappedDirectory, filename);
11405
+ const filename = path9.basename(expanded);
11406
+ return filename.length === 0 ? mappedDirectory : path9.join(mappedDirectory, filename);
11258
11407
  }
11259
11408
 
11260
11409
  // ../config-mutations/src/fs-utils.ts
@@ -11861,9 +12010,9 @@ import Mustache2 from "mustache";
11861
12010
  var originalEscape = Mustache2.escape;
11862
12011
 
11863
12012
  // ../agent-skill-config/src/templates.ts
11864
- import { readFile as readFile4, stat as stat2 } from "node:fs/promises";
11865
- import path9 from "node:path";
11866
- import { fileURLToPath as fileURLToPath2 } from "node:url";
12013
+ import { readFile as readFile5, stat as stat2 } from "node:fs/promises";
12014
+ import path10 from "node:path";
12015
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
11867
12016
 
11868
12017
  // ../agent-skill-config/src/apply.ts
11869
12018
  var UnsupportedAgentError = class extends Error {
@@ -11921,9 +12070,9 @@ async function installSkill(agentId, skill, options) {
11921
12070
 
11922
12071
  // src/commands/installer.ts
11923
12072
  import os3 from "node:os";
11924
- import path10 from "node:path";
12073
+ import path11 from "node:path";
11925
12074
  import * as nodeFs from "node:fs/promises";
11926
- import { readFile as readFile5 } from "node:fs/promises";
12075
+ import { readFile as readFile6 } from "node:fs/promises";
11927
12076
  var DEFAULT_INSTALL_AGENT = "claude-code";
11928
12077
  var DEFAULT_INSTALL_SCOPE = "local";
11929
12078
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
@@ -11973,7 +12122,7 @@ async function loadTerminalPilotTemplate() {
11973
12122
  ];
11974
12123
  for (const candidate of candidates) {
11975
12124
  try {
11976
- terminalPilotTemplateCache = await readFile5(candidate, "utf8");
12125
+ terminalPilotTemplateCache = await readFile6(candidate, "utf8");
11977
12126
  return terminalPilotTemplateCache;
11978
12127
  } catch (error2) {
11979
12128
  if (!isNotFoundError2(error2)) {
@@ -11988,7 +12137,7 @@ function resolveHomeRelativePath(targetPath, homeDir) {
11988
12137
  return homeDir;
11989
12138
  }
11990
12139
  if (targetPath.startsWith("~/")) {
11991
- return path10.join(homeDir, targetPath.slice(2));
12140
+ return path11.join(homeDir, targetPath.slice(2));
11992
12141
  }
11993
12142
  return targetPath;
11994
12143
  }
@@ -11998,12 +12147,12 @@ function getSkillFolderWithHome(agent, scope, cwd, homeDir) {
11998
12147
  throwUnsupportedAgent(agent);
11999
12148
  }
12000
12149
  return {
12001
- displayPath: path10.join(
12150
+ displayPath: path11.join(
12002
12151
  scope === "global" ? config.globalSkillDir : config.localSkillDir,
12003
12152
  TERMINAL_PILOT_SKILL_NAME
12004
12153
  ),
12005
- fullPath: path10.join(
12006
- scope === "global" ? resolveHomeRelativePath(config.globalSkillDir, homeDir) : path10.resolve(cwd, config.localSkillDir),
12154
+ fullPath: path11.join(
12155
+ scope === "global" ? resolveHomeRelativePath(config.globalSkillDir, homeDir) : path11.resolve(cwd, config.localSkillDir),
12007
12156
  TERMINAL_PILOT_SKILL_NAME
12008
12157
  )
12009
12158
  };
@@ -12407,18 +12556,18 @@ function parseAnsi2(input) {
12407
12556
  import { Resvg } from "@resvg/resvg-js";
12408
12557
 
12409
12558
  // ../terminal-png/src/font.ts
12410
- import { readFileSync } from "node:fs";
12559
+ import { readFileSync as readFileSync2 } from "node:fs";
12411
12560
  import { createRequire as createRequire2 } from "node:module";
12412
12561
  import { dirname as dirname2, join as join2 } from "node:path";
12413
- import { fileURLToPath as fileURLToPath3 } from "node:url";
12562
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
12414
12563
  var require2 = createRequire2(import.meta.url);
12415
12564
  var fontPackageRoot = dirname2(require2.resolve("jetbrains-mono/package.json"));
12416
12565
  var webfontRoot = join2(fontPackageRoot, "fonts/webfonts");
12417
12566
  function readWebfontBase64(filename) {
12418
- return readFileSync(join2(webfontRoot, filename)).toString("base64");
12567
+ return readFileSync2(join2(webfontRoot, filename)).toString("base64");
12419
12568
  }
12420
12569
  function resolveAssetPath(filename) {
12421
- return fileURLToPath3(new URL(`../assets/${filename}`, import.meta.url));
12570
+ return fileURLToPath4(new URL(`../assets/${filename}`, import.meta.url));
12422
12571
  }
12423
12572
  function createFontFace(base64, weight, style) {
12424
12573
  return `@font-face {
@@ -13114,9 +13263,9 @@ async function isDirectExecution(argv) {
13114
13263
  return false;
13115
13264
  }
13116
13265
  try {
13117
- const modulePath = fileURLToPath4(import.meta.url);
13266
+ const modulePath = fileURLToPath5(import.meta.url);
13118
13267
  const [resolvedEntryPoint, resolvedModulePath] = await Promise.all([
13119
- realpath(path11.resolve(entryPoint)),
13268
+ realpath(path12.resolve(entryPoint)),
13120
13269
  realpath(modulePath)
13121
13270
  ]);
13122
13271
  return resolvedEntryPoint === resolvedModulePath;