@jaromil/gestalt 0.20.4 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/gestalt.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // GESTALT_CLI_VERSION='0.20.4'
2
+ // GESTALT_CLI_VERSION='0.22.0'
3
3
  // GESTALT_UPDATED_MANAGER_API='1'
4
4
  /*! tuiuiu.js
5
5
  MIT License
@@ -60,8 +60,8 @@ var __commonJS = (cb, mod) => function __require2() {
60
60
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
61
61
  };
62
62
  var __export = (target, all) => {
63
- for (var name2 in all)
64
- __defProp(target, name2, { get: all[name2], enumerable: true });
63
+ for (var name3 in all)
64
+ __defProp(target, name3, { get: all[name3], enumerable: true });
65
65
  };
66
66
  var __copyProps = (to, from, except, desc) => {
67
67
  if (from && typeof from === "object" || typeof from === "function") {
@@ -304,17 +304,17 @@ try {
304
304
  import { constants } from "node:fs";
305
305
  import { access, readFile, realpath, stat } from "node:fs/promises";
306
306
  import path3 from "node:path";
307
- function environmentValue(environment, name2) {
308
- const matches = Object.keys(environment).filter((key2) => process.platform === "win32" ? key2.toUpperCase() === name2 : key2 === name2);
309
- if (matches.length > 1) throw new Error(`Ambiguous case aliases for ${name2}`);
307
+ function environmentValue(environment, name3) {
308
+ const matches = Object.keys(environment).filter((key2) => process.platform === "win32" ? key2.toUpperCase() === name3 : key2 === name3);
309
+ if (matches.length > 1) throw new Error(`Ambiguous case aliases for ${name3}`);
310
310
  const key = matches[0];
311
311
  return key ? environment[key] : void 0;
312
312
  }
313
313
  async function commandTarget(executable) {
314
314
  if (!/\.(cmd|bat)$/i.test(executable)) return { executable, prefix: [] };
315
- const source = (await readFile(executable, "utf8")).replace(/\r\n/g, "\n");
315
+ const source2 = (await readFile(executable, "utf8")).replace(/\r\n/g, "\n");
316
316
  const template = /^@ECHO off\nGOTO start\n:find_dp0\nSET dp0=%~dp0\nEXIT \/b\n:start\nSETLOCAL\nCALL :find_dp0\n\nIF EXIST "%dp0%\\node\.exe" \(\n SET "_prog=%dp0%\\node\.exe"\n\) ELSE \(\n SET "_prog=node"\n(?<inside> SET PATHEXT=%PATHEXT:;\.JS;=;%\n)?\)\n\nendLocal & goto #_undefined_# 2>NUL \|\| title %COMSPEC% & (?<outside>set PATHEXT=%PATHEXT:;\.JS;=;% & )?"%_prog%" "%dp0%\\(?<entry>[^"\r\n%]+)" %\*\n$/;
317
- const match = source.match(template);
317
+ const match = source2.match(template);
318
318
  const entry = match?.groups?.entry;
319
319
  if (!entry || Boolean(match?.groups?.inside) === Boolean(match?.groups?.outside))
320
320
  throw new Error("Unsupported batch shim; a standard npm Node shim is required");
@@ -327,14 +327,14 @@ var NativeExecutables;
327
327
  var init_executables = __esm({
328
328
  "src/cli/platform/executables.ts"() {
329
329
  NativeExecutables = class {
330
- async resolve(name2, environment) {
331
- if (!name2 || name2.includes("\0")) throw new Error("Invalid executable name");
332
- const explicit = /[\\/]/.test(name2) || path3.isAbsolute(name2);
333
- if (explicit && !path3.isAbsolute(name2)) throw new Error("Explicit executable path must be absolute");
334
- const extensions = process.platform === "win32" && !path3.extname(name2) ? (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext)) : [""];
330
+ async resolve(name3, environment) {
331
+ if (!name3 || name3.includes("\0")) throw new Error("Invalid executable name");
332
+ const explicit = /[\\/]/.test(name3) || path3.isAbsolute(name3);
333
+ if (explicit && !path3.isAbsolute(name3)) throw new Error("Explicit executable path must be absolute");
334
+ const extensions = process.platform === "win32" && !path3.extname(name3) ? (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext)) : [""];
335
335
  const directories = explicit ? [""] : (environmentValue(environment, "PATH") ?? "").split(path3.delimiter).map((value) => value.replace(/^"(.*)"$/, "$1")).filter((value) => path3.isAbsolute(value));
336
336
  for (const directory of directories) for (const extension of extensions) {
337
- const candidate = explicit ? name2 + extension : path3.join(directory, name2 + extension);
337
+ const candidate = explicit ? name3 + extension : path3.join(directory, name3 + extension);
338
338
  try {
339
339
  if (!(await stat(candidate)).isFile()) continue;
340
340
  await access(candidate, process.platform === "win32" ? constants.F_OK : constants.X_OK);
@@ -440,8 +440,8 @@ function packet(kind, bytes = new Uint8Array()) {
440
440
  body.set(bytes, 5);
441
441
  return body;
442
442
  }
443
- function boundedInteger(value, minimum, maximum, name2) {
444
- if (!Number.isSafeInteger(value) || value < minimum || value > maximum) throw new Error(`Invalid ${name2}`);
443
+ function boundedInteger(value, minimum, maximum, name3) {
444
+ if (!Number.isSafeInteger(value) || value < minimum || value > maximum) throw new Error(`Invalid ${name3}`);
445
445
  return value;
446
446
  }
447
447
  function recoveredOwnershipClaim(lease) {
@@ -598,9 +598,9 @@ var init_processes = __esm({
598
598
  else throw new Error("Invalid native process result");
599
599
  finishResult(result);
600
600
  } else if (kind === "D") {
601
- const name2 = bytes.toString();
602
- if (process.platform === "darwin" || !result || nativeEmpty || name2 !== expectedBackend) throw new Error("Invalid native empty-ownership proof");
603
- backend = name2;
601
+ const name3 = bytes.toString();
602
+ if (process.platform === "darwin" || !result || nativeEmpty || name3 !== expectedBackend) throw new Error("Invalid native empty-ownership proof");
603
+ backend = name3;
604
604
  nativeEmpty = true;
605
605
  } else if (kind === "U") {
606
606
  if (process.platform !== "darwin") throw new Error("Unexpected best-effort ownership result");
@@ -1241,7 +1241,7 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
1241
1241
  }
1242
1242
  function scratchDiscoveryEnvironment3(environment = process.env) {
1243
1243
  const result = { ...environment };
1244
- if (Object.hasOwn(result, scratchVariable)) for (const name2 of scratchNames) delete result[name2];
1244
+ if (Object.hasOwn(result, scratchVariable)) for (const name3 of scratchNames) delete result[name3];
1245
1245
  return result;
1246
1246
  }
1247
1247
  function scratchPublish(file, value, initial = false) {
@@ -1296,10 +1296,10 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
1296
1296
  function scratchLeaseRecords(context) {
1297
1297
  const directory = scratchPath.join(context.directory, "leases");
1298
1298
  scratchPrivate(directory);
1299
- return scratchFs.readdirSync(directory).map((name2) => {
1300
- scratchAssert(scratchUuid(name2.replace(/\.json$/, "")) && name2.endsWith(".json"));
1301
- const value = scratchJson3(scratchPath.join(directory, name2));
1302
- scratchAssert(value?.schemaVersion === 1 && value.ownerId === context.ownerId && value.workspacePath === context.workspacePath && name2 === value.leaseId + ".json" && ["active", "released"].includes(value.state) && scratchUuid(value.processIdentity) && typeof value.createdAt === "string" && Number.isFinite(Date.parse(value.createdAt)) && typeof value.updatedAt === "string" && Number.isFinite(Date.parse(value.updatedAt)) && Array.isArray(value.consumers) && value.consumers.every(scratchId) && (value.state !== "released" || value.consumers.length === 0));
1299
+ return scratchFs.readdirSync(directory).map((name3) => {
1300
+ scratchAssert(scratchUuid(name3.replace(/\.json$/, "")) && name3.endsWith(".json"));
1301
+ const value = scratchJson3(scratchPath.join(directory, name3));
1302
+ scratchAssert(value?.schemaVersion === 1 && value.ownerId === context.ownerId && value.workspacePath === context.workspacePath && name3 === value.leaseId + ".json" && ["active", "released"].includes(value.state) && scratchUuid(value.processIdentity) && typeof value.createdAt === "string" && Number.isFinite(Date.parse(value.createdAt)) && typeof value.updatedAt === "string" && Number.isFinite(Date.parse(value.updatedAt)) && Array.isArray(value.consumers) && value.consumers.every(scratchId) && (value.state !== "released" || value.consumers.length === 0));
1303
1303
  return value;
1304
1304
  });
1305
1305
  }
@@ -1377,9 +1377,9 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
1377
1377
  const expected = scratchDirectoryIdentity(path32);
1378
1378
  scratchPrivate(path32);
1379
1379
  scratchAssert(scratchFs.readdirSync(path32).length === 0);
1380
- for (const name2 of [".controller-lock", ".association-lock"]) {
1380
+ for (const name3 of [".controller-lock", ".association-lock"]) {
1381
1381
  try {
1382
- scratchFs.lstatSync(scratchPath.join(context.directory, name2));
1382
+ scratchFs.lstatSync(scratchPath.join(context.directory, name3));
1383
1383
  } catch (error) {
1384
1384
  if (error.code === "ENOENT") continue;
1385
1385
  throw error;
@@ -1417,9 +1417,9 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
1417
1417
  const ancestor = scratchAncestorOwner(context);
1418
1418
  const marker = scratchJson3(context.markerPath);
1419
1419
  scratchAssert(marker.ownerKind === "mobile-session");
1420
- for (const name2 of [".controller-lock", ".association-lock", ".containment-lock"]) {
1420
+ for (const name3 of [".controller-lock", ".association-lock", ".containment-lock"]) {
1421
1421
  try {
1422
- scratchFs.lstatSync(scratchPath.join(context.directory, name2));
1422
+ scratchFs.lstatSync(scratchPath.join(context.directory, name3));
1423
1423
  } catch (error) {
1424
1424
  if (error.code === "ENOENT") continue;
1425
1425
  throw error;
@@ -1495,15 +1495,15 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
1495
1495
  const values = {};
1496
1496
  let confirmed = false;
1497
1497
  for (let index = 0; index < options.length; index++) {
1498
- const name2 = options[index];
1499
- if (name2 === "--confirm-quiescent") {
1498
+ const name3 = options[index];
1499
+ if (name3 === "--confirm-quiescent") {
1500
1500
  scratchAssert(!confirmed);
1501
1501
  confirmed = true;
1502
1502
  continue;
1503
1503
  }
1504
- scratchAssert(["--cwd", "--owner", "--expect"].includes(name2) && !Object.hasOwn(values, name2));
1504
+ scratchAssert(["--cwd", "--owner", "--expect"].includes(name3) && !Object.hasOwn(values, name3));
1505
1505
  scratchAssert(typeof options[index + 1] === "string" && !options[index + 1].startsWith("--"));
1506
- values[name2] = options[++index];
1506
+ values[name3] = options[++index];
1507
1507
  }
1508
1508
  scratchAssert(values["--cwd"] && (action.endsWith("-publication") ? !values["--owner"] : values["--owner"]));
1509
1509
  if (action.endsWith("-publication")) {
@@ -1873,9 +1873,9 @@ var init_context = __esm({
1873
1873
  this.inheritedSignal?.removeEventListener("abort", inheritedAbort);
1874
1874
  };
1875
1875
  }
1876
- async require(name2) {
1877
- const executable = await this.executables.resolve(name2, this.environment);
1878
- if (!executable) throw new Error(`${name2} is required and was not found on PATH`);
1876
+ async require(name3) {
1877
+ const executable = await this.executables.resolve(name3, this.environment);
1878
+ if (!executable) throw new Error(`${name3} is required and was not found on PATH`);
1879
1879
  return executable;
1880
1880
  }
1881
1881
  async requireOwnership() {
@@ -1980,9 +1980,9 @@ var init_context = __esm({
1980
1980
  await this.storage(root);
1981
1981
  }
1982
1982
  }
1983
- async run(name2, argv, options = {}) {
1983
+ async run(name3, argv, options = {}) {
1984
1984
  this.check();
1985
- const executable = await this.require(name2), commands = await this.managedCommands();
1985
+ const executable = await this.require(name3), commands = await this.managedCommands();
1986
1986
  const environment = options.environment || this.environment;
1987
1987
  if (options.timeoutMs !== void 0 && (!Number.isInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 12e4))
1988
1988
  throw new Error("command timeout must be 1..120000 ms");
@@ -2036,7 +2036,7 @@ var init_context = __esm({
2036
2036
  }
2037
2037
  this.check();
2038
2038
  if (outputFailure) throw outputFailure;
2039
- if (status !== 0) throw new CommandFailure(`${name2} failed (exit ${status})`, status);
2039
+ if (status !== 0) throw new CommandFailure(`${name3} failed (exit ${status})`, status);
2040
2040
  const captured = Buffer.concat(chunks);
2041
2041
  return options.binary ? captured : captured.toString("utf8");
2042
2042
  }
@@ -2064,7 +2064,7 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2064
2064
  writing = writing.then(() => context.streams.stdout(Buffer.from(String(value) + "\n")));
2065
2065
  } };
2066
2066
  const overridden = Object.hasOwn(process2.env, "GESTALT_SKILLS_SOURCE");
2067
- const source = overridden ? process2.env.GESTALT_SKILLS_SOURCE : canonicalSource;
2067
+ const source2 = overridden ? process2.env.GESTALT_SKILLS_SOURCE : canonicalSource;
2068
2068
  const ref = process2.env.GESTALT_SKILLS_REF ?? defaultRef;
2069
2069
  const hash = (bytes) => crypto2.createHash("sha256").update(bytes).digest("hex");
2070
2070
  const fail = (message2) => {
@@ -2193,9 +2193,9 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2193
2193
  function treeFiles(directory, prefix = "", directories = []) {
2194
2194
  plainDirectory(directory);
2195
2195
  const files = [];
2196
- for (const name2 of fs.readdirSync(directory)) {
2197
- const relative = prefix ? `${prefix}/${name2}` : name2;
2198
- const file = path14.join(directory, name2), info = fs.lstatSync(file);
2196
+ for (const name3 of fs.readdirSync(directory)) {
2197
+ const relative = prefix ? `${prefix}/${name3}` : name3;
2198
+ const file = path14.join(directory, name3), info = fs.lstatSync(file);
2199
2199
  if (info.isDirectory() && !info.isSymbolicLink()) {
2200
2200
  directories.push(relative);
2201
2201
  files.push(...treeFiles(file, relative, directories));
@@ -2232,11 +2232,11 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2232
2232
  }
2233
2233
  return { manifest, receipt };
2234
2234
  }
2235
- function target(name2) {
2236
- return path14.join(root, "skills", name2);
2235
+ function target(name3) {
2236
+ return path14.join(root, "skills", name3);
2237
2237
  }
2238
- function linkValue(name2) {
2239
- const file = path14.join(discovery, name2), info = exists(file);
2238
+ function linkValue(name3) {
2239
+ const file = path14.join(discovery, name3), info = exists(file);
2240
2240
  if (!info) return null;
2241
2241
  if (!info.isSymbolicLink()) fail(`skill collision: ${file}; move the unrelated entry before retrying`);
2242
2242
  return fs.readlinkSync(file);
@@ -2266,11 +2266,11 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2266
2266
  if (!ownsCandidate()) fail("recovery found an unrelated collection; preserved transaction for inspection");
2267
2267
  fs.rmSync(root, { recursive: true });
2268
2268
  }
2269
- for (const { name: name2, before } of owner.journal.links) {
2270
- const current = linkValue(name2);
2269
+ for (const { name: name3, before } of owner.journal.links) {
2270
+ const current = linkValue(name3);
2271
2271
  if (current === before) continue;
2272
- if (current !== null && current !== target(name2)) fail(`recovery found a changed discovery entry: ${name2}`);
2273
- const file = path14.join(discovery, name2);
2272
+ if (current !== null && current !== target(name3)) fail(`recovery found a changed discovery entry: ${name3}`);
2273
+ const file = path14.join(discovery, name3);
2274
2274
  if (current !== null) fs.unlinkSync(file);
2275
2275
  if (before !== null) fs.symlinkSync(before, file, globalThis.process.platform === "win32" ? "junction" : "dir");
2276
2276
  }
@@ -2344,7 +2344,7 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2344
2344
  report.version = installed2.receipt.version;
2345
2345
  report.revision = installed2.receipt.revision;
2346
2346
  report.verifiedSource = installed2.receipt.verifiedSource;
2347
- for (const { name: name2 } of installed2.manifest.skills) if (linkValue(name2) !== target(name2)) fail(`missing or changed discovery link: ${name2}`);
2347
+ for (const { name: name3 } of installed2.manifest.skills) if (linkValue(name3) !== target(name3)) fail(`missing or changed discovery link: ${name3}`);
2348
2348
  report.status = "ready";
2349
2349
  report.integrity = "ok";
2350
2350
  report.recoveryCommand = null;
@@ -2393,11 +2393,11 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2393
2393
  return bytes;
2394
2394
  }
2395
2395
  async function install() {
2396
- if (typeof source !== "string" || !source || /[\x00-\x1f\x7f]/.test(source)) fail("invalid collection source");
2397
- if (!path14.isAbsolute(source)) {
2396
+ if (typeof source2 !== "string" || !source2 || /[\x00-\x1f\x7f]/.test(source2)) fail("invalid collection source");
2397
+ if (!path14.isAbsolute(source2)) {
2398
2398
  let url;
2399
2399
  try {
2400
- url = new URL(source);
2400
+ url = new URL(source2);
2401
2401
  } catch {
2402
2402
  fail("collection source must be HTTPS or an absolute local test repository");
2403
2403
  }
@@ -2416,7 +2416,7 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2416
2416
  const repository = path14.join(stage2, "repository"), candidate = path14.join(stage2, "candidate");
2417
2417
  await git(["init", "--bare", "--template=", repository]);
2418
2418
  const inRepo = (args) => ["--git-dir", repository, ...args];
2419
- await git(inRepo(["-c", "protocol.file.allow=always", "fetch", "--depth=1", "--no-tags", "--no-recurse-submodules", "--", source, ref]));
2419
+ await git(inRepo(["-c", "protocol.file.allow=always", "fetch", "--depth=1", "--no-tags", "--no-recurse-submodules", "--", source2, ref]));
2420
2420
  const revision = (await git(inRepo(["rev-parse", "--verify", "FETCH_HEAD^{commit}"]))).toString().trim();
2421
2421
  if (!/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(revision)) fail("download did not resolve to an immutable revision");
2422
2422
  const tree = (await git(inRepo(["ls-tree", "-r", "-z", revision]))).toString("utf8").split("\0").filter(Boolean);
@@ -2424,19 +2424,19 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2424
2424
  for (const entry of tree) {
2425
2425
  const match = /^(100644|100755) blob ([a-f0-9]+)\t(.+)$/.exec(entry);
2426
2426
  if (!match) {
2427
- const name2 = entry.slice(entry.indexOf(" ") + 1);
2428
- if (name2 === "manifest.json" || name2 === "LICENSE" || name2.startsWith("skills/")) fail("collection contains a symbolic link or unsupported file");
2427
+ const name3 = entry.slice(entry.indexOf(" ") + 1);
2428
+ if (name3 === "manifest.json" || name3 === "LICENSE" || name3.startsWith("skills/")) fail("collection contains a symbolic link or unsupported file");
2429
2429
  continue;
2430
2430
  }
2431
2431
  blobs.set(match[3], { oid: match[2], mode: match[1] });
2432
2432
  }
2433
- async function blob(name2) {
2434
- if (!blobs.has(name2)) fail(`package is missing ${name2}`);
2435
- return await git(inRepo(["cat-file", "blob", blobs.get(name2).oid]), 4 * 1024 * 1024);
2433
+ async function blob(name3) {
2434
+ if (!blobs.has(name3)) fail(`package is missing ${name3}`);
2435
+ return await git(inRepo(["cat-file", "blob", blobs.get(name3).oid]), 4 * 1024 * 1024);
2436
2436
  }
2437
2437
  const manifestBytes = await blob("manifest.json");
2438
2438
  const manifest = parseManifest(manifestBytes), inventory = validateManifest(manifest);
2439
- if (!same([...blobs.keys()].filter((name2) => name2.startsWith("skills/")).sort(), [...inventory].sort())) fail("manifest does not cover every bundled skill file");
2439
+ if (!same([...blobs.keys()].filter((name3) => name3.startsWith("skills/")).sort(), [...inventory].sort())) fail("manifest does not cover every bundled skill file");
2440
2440
  fs.mkdirSync(candidate);
2441
2441
  let totalBytes = 0;
2442
2442
  for (const file of manifest.skills.flatMap((skill) => skill.files)) {
@@ -2454,13 +2454,13 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2454
2454
  const receipt = {
2455
2455
  schemaVersion: 1,
2456
2456
  repository: manifest.repository,
2457
- source,
2457
+ source: source2,
2458
2458
  revision,
2459
2459
  version: manifest.version,
2460
2460
  manifestSha256: hash(manifestBytes),
2461
2461
  managedRoot: root,
2462
2462
  discoveryRoot: discovery,
2463
- verifiedSource: !overridden && source === canonicalSource,
2463
+ verifiedSource: !overridden && source2 === canonicalSource,
2464
2464
  skills: manifest.skills,
2465
2465
  packageFiles: [{ path: "LICENSE", sha256: hash(license) }],
2466
2466
  installedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -2469,14 +2469,14 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2469
2469
  fs.writeFileSync(path14.join(candidate, "receipt.json"), JSON.stringify(receipt, null, 2) + "\n", { mode: 384 });
2470
2470
  const oldNames = new Set(previous?.manifest.skills.map((skill) => skill.name) ?? []);
2471
2471
  const newNames = new Set(manifest.skills.map((skill) => skill.name));
2472
- const links = [.../* @__PURE__ */ new Set([...oldNames, ...newNames])].sort().map((name2) => {
2473
- const before = linkValue(name2);
2474
- if (before !== null && (!oldNames.has(name2) || before !== target(name2))) fail(`skill collision: ${path14.join(discovery, name2)}; preserve the existing entry before retrying`);
2475
- return { name: name2, before };
2472
+ const links = [.../* @__PURE__ */ new Set([...oldNames, ...newNames])].sort().map((name3) => {
2473
+ const before = linkValue(name3);
2474
+ if (before !== null && (!oldNames.has(name3) || before !== target(name3))) fail(`skill collision: ${path14.join(discovery, name3)}; preserve the existing entry before retrying`);
2475
+ return { name: name3, before };
2476
2476
  });
2477
2477
  const current = inspectInstalled();
2478
2478
  if (!same(current, previous)) fail("managed collection changed during download; retry");
2479
- if (previous && previous.receipt.revision === revision && previous.receipt.manifestSha256 === receipt.manifestSha256 && previous.receipt.source === source && previous.receipt.verifiedSource === receipt.verifiedSource && links.every((link2) => link2.before === target(link2.name))) {
2479
+ if (previous && previous.receipt.revision === revision && previous.receipt.manifestSha256 === receipt.manifestSha256 && previous.receipt.source === source2 && previous.receipt.verifiedSource === receipt.verifiedSource && links.every((link2) => link2.before === target(link2.name))) {
2480
2480
  console2.log(`Gestalt skills ${manifest.version} (${revision}): unchanged`);
2481
2481
  return;
2482
2482
  }
@@ -2489,11 +2489,11 @@ async function manageSkills(context, operation, outputMode = "text", recovery =
2489
2489
  await checkpoint();
2490
2490
  fs.renameSync(candidate, root);
2491
2491
  await checkpoint();
2492
- for (const { name: name2, before } of links) {
2493
- if (linkValue(name2) !== before) fail(`discovery entry changed during update: ${name2}`);
2494
- if (newNames.has(name2)) {
2495
- if (before === null) fs.symlinkSync(target(name2), path14.join(discovery, name2), globalThis.process.platform === "win32" ? "junction" : "dir");
2496
- } else if (before !== null) fs.unlinkSync(path14.join(discovery, name2));
2492
+ for (const { name: name3, before } of links) {
2493
+ if (linkValue(name3) !== before) fail(`discovery entry changed during update: ${name3}`);
2494
+ if (newNames.has(name3)) {
2495
+ if (before === null) fs.symlinkSync(target(name3), path14.join(discovery, name3), globalThis.process.platform === "win32" ? "junction" : "dir");
2496
+ } else if (before !== null) fs.unlinkSync(path14.join(discovery, name3));
2497
2497
  await checkpoint();
2498
2498
  }
2499
2499
  owner.committed = true;
@@ -2623,19 +2623,19 @@ var init_commands = __esm({
2623
2623
  this.injected = injected;
2624
2624
  this.terminal = terminal;
2625
2625
  }
2626
- async resolve(name2) {
2627
- return this.resolver.resolve(name2, this.invocation.environment);
2626
+ async resolve(name3) {
2627
+ return this.resolver.resolve(name3, this.invocation.environment);
2628
2628
  }
2629
- async launch(name2, argv, streams = this.streams, environment = this.invocation.environment, cwd = this.invocation.cwd) {
2630
- return this.launchCommand(name2, argv, streams, environment, cwd);
2629
+ async launch(name3, argv, streams = this.streams, environment = this.invocation.environment, cwd = this.invocation.cwd) {
2630
+ return this.launchCommand(name3, argv, streams, environment, cwd);
2631
2631
  }
2632
- async launchTerminal(name2, argv, environment = this.invocation.environment, cwd = this.invocation.cwd) {
2632
+ async launchTerminal(name3, argv, environment = this.invocation.environment, cwd = this.invocation.cwd) {
2633
2633
  if (!this.terminal) throw new Error("Interactive Codex requires a terminal on stdin and stdout");
2634
2634
  const restore = this.terminal.enter();
2635
2635
  let unresize = () => {
2636
2636
  };
2637
2637
  try {
2638
- const lease = await this.launchCommand(name2, argv, this.streams, environment, cwd, this.terminal.size());
2638
+ const lease = await this.launchCommand(name3, argv, this.streams, environment, cwd, this.terminal.size());
2639
2639
  unresize = this.terminal.onResize(() => {
2640
2640
  void lease.resize(this.terminal.size()).catch(() => lease.stop());
2641
2641
  });
@@ -2650,10 +2650,10 @@ var init_commands = __esm({
2650
2650
  throw error;
2651
2651
  }
2652
2652
  }
2653
- async launchCommand(name2, argv, streams, environment, cwd, terminal) {
2653
+ async launchCommand(name3, argv, streams, environment, cwd, terminal) {
2654
2654
  if (this.interrupted) throw new Error("runtime interrupted before command launch");
2655
- const executable = await this.resolve(name2);
2656
- if (!executable) throw new Error(`${name2} is required and was not found on PATH`);
2655
+ const executable = await this.resolve(name3);
2656
+ if (!executable) throw new Error(`${name3} is required and was not found on PATH`);
2657
2657
  const helper = path16.join(path16.dirname(this.manager), "native", process.platform === "win32" ? "gestalt-owned-process.exe" : "gestalt-owned-process");
2658
2658
  if (!this.injected && !await this.resolve(helper)) throw new Error(`target-built native process ownership helper is required: ${helper}; install the matching native Gestalt artifact`);
2659
2659
  const owner = scratchContext2(environment), borrower = owner ? scratchBorrow2(owner, "manager-runtime") : null;
@@ -2725,7 +2725,7 @@ var init_commands = __esm({
2725
2725
  async stop() {
2726
2726
  await Promise.allSettled([...this.active].map((lease) => lease.stop()));
2727
2727
  }
2728
- async capture(name2, argv, environment = diagnosticEnvironment(this.invocation.environment), limit = 1024 * 1024, timeout = 1e4) {
2728
+ async capture(name3, argv, environment = diagnosticEnvironment(this.invocation.environment), limit = 1024 * 1024, timeout = 1e4) {
2729
2729
  const output = [], errors = [];
2730
2730
  let bytes = 0, exceeded = false;
2731
2731
  let lease;
@@ -2736,7 +2736,7 @@ var init_commands = __esm({
2736
2736
  void lease?.stop();
2737
2737
  } else target.push(Buffer.from(chunk));
2738
2738
  };
2739
- lease = await this.launch(name2, argv, { stdin: (async function* () {
2739
+ lease = await this.launch(name3, argv, { stdin: (async function* () {
2740
2740
  })(), stdout: receive(output), stderr: receive(errors) }, environment);
2741
2741
  const timer = setTimeout(() => {
2742
2742
  exceeded = true;
@@ -2819,7 +2819,7 @@ var init_child = __esm({
2819
2819
  });
2820
2820
 
2821
2821
  // src/cli/skill-profiles/directories.ts
2822
- import { constants as constants6 } from "node:fs";
2822
+ import { constants as constants7 } from "node:fs";
2823
2823
  import { open as open5 } from "node:fs/promises";
2824
2824
  import path26 from "node:path";
2825
2825
  async function checkSkillProfileDirectories(gestaltHome, repairOwnedModes = false) {
@@ -2835,7 +2835,7 @@ async function checkSkillProfileDirectories(gestaltHome, repairOwnedModes = fals
2835
2835
  const mode = (info.mode & 4095).toString(8);
2836
2836
  const diagnostic = `Skill profile directory ${directory} has mode ${mode}. Remove group and other write access with chmod go-w on this directory.`;
2837
2837
  if (!repairOwnedModes) throw new Error(diagnostic);
2838
- const handle = await open5(directory, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
2838
+ const handle = await open5(directory, constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW);
2839
2839
  try {
2840
2840
  const current = await handle.stat();
2841
2841
  if (current.dev !== info.dev || current.ino !== info.ino || current.uid !== uid)
@@ -2857,10 +2857,10 @@ var init_directories = __esm({
2857
2857
  // src/cli/skill-profiles/model.ts
2858
2858
  import path27 from "node:path";
2859
2859
  function profileName2(value) {
2860
- const name2 = value.trim().toLowerCase().replace(/[\s_]+/g, "-");
2861
- if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(name2) || process.platform === "win32" && /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/.test(name2))
2860
+ const name3 = value.trim().toLowerCase().replace(/[\s_]+/g, "-");
2861
+ if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(name3) || process.platform === "win32" && /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/.test(name3))
2862
2862
  throw new Error("Enter a skill profile name of 1\u201363 letters, digits or hyphens.");
2863
- return name2;
2863
+ return name3;
2864
2864
  }
2865
2865
  function skillKey(value) {
2866
2866
  return process.platform === "win32" ? path27.win32.normalize(value).toLowerCase() : path27.normalize(value);
@@ -2909,7 +2909,7 @@ function profileDocument(profile) {
2909
2909
  return {
2910
2910
  version: profile.browser === void 0 ? 1 : 2,
2911
2911
  name: profile.name,
2912
- skills: profile.skills.map(({ path: path32, name: name2, enabled }) => ({ name: name2, path: path32, enabled })),
2912
+ skills: profile.skills.map(({ path: path32, name: name3, enabled }) => ({ name: name3, path: path32, enabled })),
2913
2913
  ...profile.browser === void 0 ? {} : { capabilities: { playwright: { enabled: profile.browser } } }
2914
2914
  };
2915
2915
  }
@@ -3348,8 +3348,8 @@ var require_directives = __commonJS({
3348
3348
  this.atNextDocument = false;
3349
3349
  }
3350
3350
  const parts = line.trim().split(/[ \t]+/);
3351
- const name2 = parts.shift();
3352
- switch (name2) {
3351
+ const name3 = parts.shift();
3352
+ switch (name3) {
3353
3353
  case "%TAG": {
3354
3354
  if (parts.length !== 2) {
3355
3355
  onError(0, "%TAG directive should contain exactly two parts");
@@ -3377,7 +3377,7 @@ var require_directives = __commonJS({
3377
3377
  }
3378
3378
  }
3379
3379
  default:
3380
- onError(0, `Unknown directive ${name2}`, true);
3380
+ onError(0, `Unknown directive ${name3}`, true);
3381
3381
  return false;
3382
3382
  }
3383
3383
  }
@@ -3387,26 +3387,26 @@ var require_directives = __commonJS({
3387
3387
  * @returns Resolved tag, which may also be the non-specific tag `'!'` or a
3388
3388
  * `'!local'` tag, or `null` if unresolvable.
3389
3389
  */
3390
- tagName(source, onError) {
3391
- if (source === "!")
3390
+ tagName(source2, onError) {
3391
+ if (source2 === "!")
3392
3392
  return "!";
3393
- if (source[0] !== "!") {
3394
- onError(`Not a valid tag: ${source}`);
3393
+ if (source2[0] !== "!") {
3394
+ onError(`Not a valid tag: ${source2}`);
3395
3395
  return null;
3396
3396
  }
3397
- if (source[1] === "<") {
3398
- const verbatim = source.slice(2, -1);
3397
+ if (source2[1] === "<") {
3398
+ const verbatim = source2.slice(2, -1);
3399
3399
  if (verbatim === "!" || verbatim === "!!") {
3400
- onError(`Verbatim tags aren't resolved, so ${source} is invalid.`);
3400
+ onError(`Verbatim tags aren't resolved, so ${source2} is invalid.`);
3401
3401
  return null;
3402
3402
  }
3403
- if (source[source.length - 1] !== ">")
3403
+ if (source2[source2.length - 1] !== ">")
3404
3404
  onError("Verbatim tags must end with a >");
3405
3405
  return verbatim;
3406
3406
  }
3407
- const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s);
3407
+ const [, handle, suffix] = source2.match(/^(.*!)([^!]*)$/s);
3408
3408
  if (!suffix)
3409
- onError(`The ${source} tag has no suffix`);
3409
+ onError(`The ${source2} tag has no suffix`);
3410
3410
  const prefix = this.tags[handle];
3411
3411
  if (prefix) {
3412
3412
  try {
@@ -3417,8 +3417,8 @@ var require_directives = __commonJS({
3417
3417
  }
3418
3418
  }
3419
3419
  if (handle === "!")
3420
- return source;
3421
- onError(`Could not resolve tag: ${source}`);
3420
+ return source2;
3421
+ onError(`Could not resolve tag: ${source2}`);
3422
3422
  return null;
3423
3423
  }
3424
3424
  /**
@@ -3486,9 +3486,9 @@ var require_anchors = __commonJS({
3486
3486
  }
3487
3487
  function findNewAnchor(prefix, exclude) {
3488
3488
  for (let i = 1; true; ++i) {
3489
- const name2 = `${prefix}${i}`;
3490
- if (!exclude.has(name2))
3491
- return name2;
3489
+ const name3 = `${prefix}${i}`;
3490
+ if (!exclude.has(name3))
3491
+ return name3;
3492
3492
  }
3493
3493
  }
3494
3494
  function createNodeAnchors(doc, prefix) {
@@ -3496,8 +3496,8 @@ var require_anchors = __commonJS({
3496
3496
  const sourceObjects = /* @__PURE__ */ new Map();
3497
3497
  let prevAnchors = null;
3498
3498
  return {
3499
- onAnchor: (source) => {
3500
- aliasObjects.push(source);
3499
+ onAnchor: (source2) => {
3500
+ aliasObjects.push(source2);
3501
3501
  prevAnchors ?? (prevAnchors = anchorNames(doc));
3502
3502
  const anchor = findNewAnchor(prefix, prevAnchors);
3503
3503
  prevAnchors.add(anchor);
@@ -3509,13 +3509,13 @@ var require_anchors = __commonJS({
3509
3509
  * the nodes have been created.
3510
3510
  */
3511
3511
  setAnchors: () => {
3512
- for (const source of aliasObjects) {
3513
- const ref = sourceObjects.get(source);
3512
+ for (const source2 of aliasObjects) {
3513
+ const ref = sourceObjects.get(source2);
3514
3514
  if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
3515
3515
  ref.node.anchor = ref.anchor;
3516
3516
  } else {
3517
3517
  const error = new Error("Failed to resolve repeated object (this should not happen)");
3518
- error.source = source;
3518
+ error.source = source2;
3519
3519
  throw error;
3520
3520
  }
3521
3521
  }
@@ -3661,9 +3661,9 @@ var require_Alias = __commonJS({
3661
3661
  var Node = require_Node();
3662
3662
  var toJS = require_toJS();
3663
3663
  var Alias = class extends Node.NodeBase {
3664
- constructor(source) {
3664
+ constructor(source2) {
3665
3665
  super(identity.ALIAS);
3666
- this.source = source;
3666
+ this.source = source2;
3667
3667
  Object.defineProperty(this, "tag", {
3668
3668
  set() {
3669
3669
  throw new Error("Alias nodes cannot have tags");
@@ -3704,15 +3704,15 @@ var require_Alias = __commonJS({
3704
3704
  if (!ctx)
3705
3705
  return { source: this.source };
3706
3706
  const { anchors: anchors2, doc, maxAliasCount } = ctx;
3707
- const source = this.resolve(doc, ctx);
3708
- if (!source) {
3707
+ const source2 = this.resolve(doc, ctx);
3708
+ if (!source2) {
3709
3709
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
3710
3710
  throw new ReferenceError(msg);
3711
3711
  }
3712
- let data = anchors2.get(source);
3712
+ let data = anchors2.get(source2);
3713
3713
  if (!data) {
3714
- toJS.toJS(source, null, ctx);
3715
- data = anchors2.get(source);
3714
+ toJS.toJS(source2, null, ctx);
3715
+ data = anchors2.get(source2);
3716
3716
  }
3717
3717
  if (data?.res === void 0) {
3718
3718
  const msg = "This should not happen: Alias anchor was not resolved?";
@@ -3721,7 +3721,7 @@ var require_Alias = __commonJS({
3721
3721
  if (maxAliasCount >= 0) {
3722
3722
  data.count += 1;
3723
3723
  if (data.aliasCount === 0)
3724
- data.aliasCount = getAliasCount(doc, source, anchors2);
3724
+ data.aliasCount = getAliasCount(doc, source2, anchors2);
3725
3725
  if (data.count * data.aliasCount > maxAliasCount) {
3726
3726
  const msg = "Excessive alias count indicates a resource exhaustion attack";
3727
3727
  throw new ReferenceError(msg);
@@ -3745,8 +3745,8 @@ var require_Alias = __commonJS({
3745
3745
  };
3746
3746
  function getAliasCount(doc, node, anchors2) {
3747
3747
  if (identity.isAlias(node)) {
3748
- const source = node.resolve(doc);
3749
- const anchor = anchors2 && source && anchors2.get(source);
3748
+ const source2 = node.resolve(doc);
3749
+ const anchor = anchors2 && source2 && anchors2.get(source2);
3750
3750
  return anchor ? anchor.count * anchor.aliasCount : 0;
3751
3751
  } else if (identity.isCollection(node)) {
3752
3752
  let count = 0;
@@ -4523,8 +4523,8 @@ var require_stringify = __commonJS({
4523
4523
  tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
4524
4524
  }
4525
4525
  if (!tagObj) {
4526
- const name2 = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
4527
- throw new Error(`Tag not resolved for ${name2} value`);
4526
+ const name3 = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
4527
+ throw new Error(`Tag not resolved for ${name3} value`);
4528
4528
  }
4529
4529
  return tagObj;
4530
4530
  }
@@ -4749,21 +4749,21 @@ var require_merge = __commonJS({
4749
4749
  };
4750
4750
  var isMergeKey = (ctx, key) => (merge.identify(key) || identity.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default);
4751
4751
  function addMergeToJSMap(ctx, map, value) {
4752
- const source = resolveAliasValue(ctx, value);
4753
- if (identity.isSeq(source))
4754
- for (const it of source.items)
4752
+ const source2 = resolveAliasValue(ctx, value);
4753
+ if (identity.isSeq(source2))
4754
+ for (const it of source2.items)
4755
4755
  mergeValue(ctx, map, it);
4756
- else if (Array.isArray(source))
4757
- for (const it of source)
4756
+ else if (Array.isArray(source2))
4757
+ for (const it of source2)
4758
4758
  mergeValue(ctx, map, it);
4759
4759
  else
4760
- mergeValue(ctx, map, source);
4760
+ mergeValue(ctx, map, source2);
4761
4761
  }
4762
4762
  function mergeValue(ctx, map, value) {
4763
- const source = resolveAliasValue(ctx, value);
4764
- if (!identity.isMap(source))
4763
+ const source2 = resolveAliasValue(ctx, value);
4764
+ if (!identity.isMap(source2))
4765
4765
  throw new Error("Merge sources must be maps or map aliases");
4766
- const srcMap = source.toJSON(null, ctx, Map);
4766
+ const srcMap = source2.toJSON(null, ctx, Map);
4767
4767
  for (const [key, value2] of srcMap) {
4768
4768
  if (map instanceof Map) {
4769
4769
  if (!map.has(key))
@@ -5380,7 +5380,7 @@ var require_null = __commonJS({
5380
5380
  tag: "tag:yaml.org,2002:null",
5381
5381
  test: /^(?:~|[Nn]ull|NULL)?$/,
5382
5382
  resolve: () => new Scalar.Scalar(null),
5383
- stringify: ({ source }, ctx) => typeof source === "string" && nullTag.test.test(source) ? source : ctx.options.nullStr
5383
+ stringify: ({ source: source2 }, ctx) => typeof source2 === "string" && nullTag.test.test(source2) ? source2 : ctx.options.nullStr
5384
5384
  };
5385
5385
  exports.nullTag = nullTag;
5386
5386
  }
@@ -5397,11 +5397,11 @@ var require_bool = __commonJS({
5397
5397
  tag: "tag:yaml.org,2002:bool",
5398
5398
  test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
5399
5399
  resolve: (str) => new Scalar.Scalar(str[0] === "t" || str[0] === "T"),
5400
- stringify({ source, value }, ctx) {
5401
- if (source && boolTag.test.test(source)) {
5402
- const sv = source[0] === "t" || source[0] === "T";
5400
+ stringify({ source: source2, value }, ctx) {
5401
+ if (source2 && boolTag.test.test(source2)) {
5402
+ const sv = source2[0] === "t" || source2[0] === "T";
5403
5403
  if (value === sv)
5404
- return source;
5404
+ return source2;
5405
5405
  }
5406
5406
  return value ? ctx.options.trueStr : ctx.options.falseStr;
5407
5407
  }
@@ -5850,10 +5850,10 @@ var require_bool2 = __commonJS({
5850
5850
  "node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) {
5851
5851
  "use strict";
5852
5852
  var Scalar = require_Scalar();
5853
- function boolStringify({ value, source }, ctx) {
5853
+ function boolStringify({ value, source: source2 }, ctx) {
5854
5854
  const boolObj = value ? trueTag : falseTag;
5855
- if (source && boolObj.test.test(source))
5856
- return source;
5855
+ if (source2 && boolObj.test.test(source2))
5856
+ return source2;
5857
5857
  return value ? ctx.options.trueStr : ctx.options.falseStr;
5858
5858
  }
5859
5859
  var trueTag = {
@@ -6523,11 +6523,11 @@ var require_Document = __commonJS({
6523
6523
  * `name` will be used as a prefix for a new unique anchor.
6524
6524
  * If `name` is undefined, the generated anchor will use 'a' as a prefix.
6525
6525
  */
6526
- createAlias(node, name2) {
6526
+ createAlias(node, name3) {
6527
6527
  if (!node.anchor) {
6528
6528
  const prev = anchors.anchorNames(this);
6529
6529
  node.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
6530
- !name2 || prev.has(name2) ? anchors.findNewAnchor(name2 || "a", prev) : name2;
6530
+ !name3 || prev.has(name3) ? anchors.findNewAnchor(name3 || "a", prev) : name3;
6531
6531
  }
6532
6532
  return new Alias.Alias(node.anchor);
6533
6533
  }
@@ -6746,9 +6746,9 @@ var require_errors = __commonJS({
6746
6746
  "node_modules/yaml/dist/errors.js"(exports) {
6747
6747
  "use strict";
6748
6748
  var YAMLError = class extends Error {
6749
- constructor(name2, pos, code, message2) {
6749
+ constructor(name3, pos, code, message2) {
6750
6750
  super();
6751
- this.name = name2;
6751
+ this.name = name3;
6752
6752
  this.code = code;
6753
6753
  this.message = message2;
6754
6754
  this.pos = pos;
@@ -7185,7 +7185,7 @@ var require_resolve_end = __commonJS({
7185
7185
  let hasSpace = false;
7186
7186
  let sep = "";
7187
7187
  for (const token of end) {
7188
- const { source, type } = token;
7188
+ const { source: source2, type } = token;
7189
7189
  switch (type) {
7190
7190
  case "space":
7191
7191
  hasSpace = true;
@@ -7193,7 +7193,7 @@ var require_resolve_end = __commonJS({
7193
7193
  case "comment": {
7194
7194
  if (reqSpace && !hasSpace)
7195
7195
  onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
7196
- const cb = source.substring(1) || " ";
7196
+ const cb = source2.substring(1) || " ";
7197
7197
  if (!comment)
7198
7198
  comment = cb;
7199
7199
  else
@@ -7203,13 +7203,13 @@ var require_resolve_end = __commonJS({
7203
7203
  }
7204
7204
  case "newline":
7205
7205
  if (comment)
7206
- sep += source;
7206
+ sep += source2;
7207
7207
  hasSpace = true;
7208
7208
  break;
7209
7209
  default:
7210
7210
  onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`);
7211
7211
  }
7212
- offset += source.length;
7212
+ offset += source2.length;
7213
7213
  }
7214
7214
  }
7215
7215
  return { comment, offset };
@@ -7388,8 +7388,8 @@ var require_resolve_flow_collection = __commonJS({
7388
7388
  if (ce?.source === expectedEnd)
7389
7389
  cePos = ce.offset + ce.source.length;
7390
7390
  else {
7391
- const name2 = fcName[0].toUpperCase() + fcName.substring(1);
7392
- const msg = atRoot ? `${name2} must end with a ${expectedEnd}` : `${name2} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
7391
+ const name3 = fcName[0].toUpperCase() + fcName.substring(1);
7392
+ const msg = atRoot ? `${name3} must end with a ${expectedEnd}` : `${name3} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
7393
7393
  onError(offset, atRoot ? "MISSING_CHAR" : "BAD_INDENT", msg);
7394
7394
  if (ce && ce.source.length !== 1)
7395
7395
  ee.unshift(ce);
@@ -7591,13 +7591,13 @@ var require_resolve_block_scalar = __commonJS({
7591
7591
  onError(props[0], "IMPOSSIBLE", "Block scalar header not found");
7592
7592
  return null;
7593
7593
  }
7594
- const { source } = props[0];
7595
- const mode = source[0];
7594
+ const { source: source2 } = props[0];
7595
+ const mode = source2[0];
7596
7596
  let indent = 0;
7597
7597
  let chomp = "";
7598
7598
  let error = -1;
7599
- for (let i = 1; i < source.length; ++i) {
7600
- const ch = source[i];
7599
+ for (let i = 1; i < source2.length; ++i) {
7600
+ const ch = source2[i];
7601
7601
  if (!chomp && (ch === "-" || ch === "+"))
7602
7602
  chomp = ch;
7603
7603
  else {
@@ -7609,10 +7609,10 @@ var require_resolve_block_scalar = __commonJS({
7609
7609
  }
7610
7610
  }
7611
7611
  if (error !== -1)
7612
- onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
7612
+ onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source2}`);
7613
7613
  let hasSpace = false;
7614
7614
  let comment = "";
7615
- let length = source.length;
7615
+ let length = source2.length;
7616
7616
  for (let i = 1; i < props.length; ++i) {
7617
7617
  const token = props[i];
7618
7618
  switch (token.type) {
@@ -7646,8 +7646,8 @@ var require_resolve_block_scalar = __commonJS({
7646
7646
  }
7647
7647
  return { mode, indent, chomp, comment, length };
7648
7648
  }
7649
- function splitLines(source) {
7650
- const split = source.split(/\n( *)/);
7649
+ function splitLines(source2) {
7650
+ const split = source2.split(/\n( *)/);
7651
7651
  const first = split[0];
7652
7652
  const m = first.match(/^( *)/);
7653
7653
  const line0 = m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first];
@@ -7667,22 +7667,22 @@ var require_resolve_flow_scalar = __commonJS({
7667
7667
  var Scalar = require_Scalar();
7668
7668
  var resolveEnd = require_resolve_end();
7669
7669
  function resolveFlowScalar(scalar, strict, onError) {
7670
- const { offset, type, source, end } = scalar;
7670
+ const { offset, type, source: source2, end } = scalar;
7671
7671
  let _type;
7672
7672
  let value;
7673
7673
  const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
7674
7674
  switch (type) {
7675
7675
  case "scalar":
7676
7676
  _type = Scalar.Scalar.PLAIN;
7677
- value = plainValue(source, _onError);
7677
+ value = plainValue(source2, _onError);
7678
7678
  break;
7679
7679
  case "single-quoted-scalar":
7680
7680
  _type = Scalar.Scalar.QUOTE_SINGLE;
7681
- value = singleQuotedValue(source, _onError);
7681
+ value = singleQuotedValue(source2, _onError);
7682
7682
  break;
7683
7683
  case "double-quoted-scalar":
7684
7684
  _type = Scalar.Scalar.QUOTE_DOUBLE;
7685
- value = doubleQuotedValue(source, _onError);
7685
+ value = doubleQuotedValue(source2, _onError);
7686
7686
  break;
7687
7687
  /* istanbul ignore next should not happen */
7688
7688
  default:
@@ -7691,10 +7691,10 @@ var require_resolve_flow_scalar = __commonJS({
7691
7691
  value: "",
7692
7692
  type: null,
7693
7693
  comment: "",
7694
- range: [offset, offset + source.length, offset + source.length]
7694
+ range: [offset, offset + source2.length, offset + source2.length]
7695
7695
  };
7696
7696
  }
7697
- const valueEnd = offset + source.length;
7697
+ const valueEnd = offset + source2.length;
7698
7698
  const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError);
7699
7699
  return {
7700
7700
  value,
@@ -7703,9 +7703,9 @@ var require_resolve_flow_scalar = __commonJS({
7703
7703
  range: [offset, valueEnd, re.offset]
7704
7704
  };
7705
7705
  }
7706
- function plainValue(source, onError) {
7706
+ function plainValue(source2, onError) {
7707
7707
  let badChar = "";
7708
- switch (source[0]) {
7708
+ switch (source2[0]) {
7709
7709
  /* istanbul ignore next should not happen */
7710
7710
  case " ":
7711
7711
  badChar = "a tab character";
@@ -7718,25 +7718,25 @@ var require_resolve_flow_scalar = __commonJS({
7718
7718
  break;
7719
7719
  case "|":
7720
7720
  case ">": {
7721
- badChar = `block scalar indicator ${source[0]}`;
7721
+ badChar = `block scalar indicator ${source2[0]}`;
7722
7722
  break;
7723
7723
  }
7724
7724
  case "@":
7725
7725
  case "`": {
7726
- badChar = `reserved character ${source[0]}`;
7726
+ badChar = `reserved character ${source2[0]}`;
7727
7727
  break;
7728
7728
  }
7729
7729
  }
7730
7730
  if (badChar)
7731
7731
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
7732
- return foldLines(source);
7732
+ return foldLines(source2);
7733
7733
  }
7734
- function singleQuotedValue(source, onError) {
7735
- if (source[source.length - 1] !== "'" || source.length === 1)
7736
- onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
7737
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
7734
+ function singleQuotedValue(source2, onError) {
7735
+ if (source2[source2.length - 1] !== "'" || source2.length === 1)
7736
+ onError(source2.length, "MISSING_CHAR", "Missing closing 'quote");
7737
+ return foldLines(source2.slice(1, -1)).replace(/''/g, "'");
7738
7738
  }
7739
- function foldLines(source) {
7739
+ function foldLines(source2) {
7740
7740
  let first, line;
7741
7741
  try {
7742
7742
  first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
@@ -7745,14 +7745,14 @@ var require_resolve_flow_scalar = __commonJS({
7745
7745
  first = /(.*?)[ \t]*\r?\n/sy;
7746
7746
  line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
7747
7747
  }
7748
- let match = first.exec(source);
7748
+ let match = first.exec(source2);
7749
7749
  if (!match)
7750
- return source;
7750
+ return source2;
7751
7751
  let res = match[1];
7752
7752
  let sep = " ";
7753
7753
  let pos = first.lastIndex;
7754
7754
  line.lastIndex = pos;
7755
- while (match = line.exec(source)) {
7755
+ while (match = line.exec(source2)) {
7756
7756
  if (match[1] === "") {
7757
7757
  if (sep === "\n")
7758
7758
  res += sep;
@@ -7766,66 +7766,66 @@ var require_resolve_flow_scalar = __commonJS({
7766
7766
  }
7767
7767
  const last = /[ \t]*(.*)/sy;
7768
7768
  last.lastIndex = pos;
7769
- match = last.exec(source);
7769
+ match = last.exec(source2);
7770
7770
  return res + sep + (match?.[1] ?? "");
7771
7771
  }
7772
- function doubleQuotedValue(source, onError) {
7772
+ function doubleQuotedValue(source2, onError) {
7773
7773
  let res = "";
7774
- for (let i = 1; i < source.length - 1; ++i) {
7775
- const ch = source[i];
7776
- if (ch === "\r" && source[i + 1] === "\n")
7774
+ for (let i = 1; i < source2.length - 1; ++i) {
7775
+ const ch = source2[i];
7776
+ if (ch === "\r" && source2[i + 1] === "\n")
7777
7777
  continue;
7778
7778
  if (ch === "\n") {
7779
- const { fold, offset } = foldNewline(source, i);
7779
+ const { fold, offset } = foldNewline(source2, i);
7780
7780
  res += fold;
7781
7781
  i = offset;
7782
7782
  } else if (ch === "\\") {
7783
- let next = source[++i];
7783
+ let next = source2[++i];
7784
7784
  const cc = escapeCodes[next];
7785
7785
  if (cc)
7786
7786
  res += cc;
7787
7787
  else if (next === "\n") {
7788
- next = source[i + 1];
7788
+ next = source2[i + 1];
7789
7789
  while (next === " " || next === " ")
7790
- next = source[++i + 1];
7791
- } else if (next === "\r" && source[i + 1] === "\n") {
7792
- next = source[++i + 1];
7790
+ next = source2[++i + 1];
7791
+ } else if (next === "\r" && source2[i + 1] === "\n") {
7792
+ next = source2[++i + 1];
7793
7793
  while (next === " " || next === " ")
7794
- next = source[++i + 1];
7794
+ next = source2[++i + 1];
7795
7795
  } else if (next === "x" || next === "u" || next === "U") {
7796
7796
  const length = next === "x" ? 2 : next === "u" ? 4 : 8;
7797
- res += parseCharCode(source, i + 1, length, onError);
7797
+ res += parseCharCode(source2, i + 1, length, onError);
7798
7798
  i += length;
7799
7799
  } else {
7800
- const raw = source.substr(i - 1, 2);
7800
+ const raw = source2.substr(i - 1, 2);
7801
7801
  onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
7802
7802
  res += raw;
7803
7803
  }
7804
7804
  } else if (ch === " " || ch === " ") {
7805
7805
  const wsStart = i;
7806
- let next = source[i + 1];
7806
+ let next = source2[i + 1];
7807
7807
  while (next === " " || next === " ")
7808
- next = source[++i + 1];
7809
- if (next !== "\n" && !(next === "\r" && source[i + 2] === "\n"))
7810
- res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
7808
+ next = source2[++i + 1];
7809
+ if (next !== "\n" && !(next === "\r" && source2[i + 2] === "\n"))
7810
+ res += i > wsStart ? source2.slice(wsStart, i + 1) : ch;
7811
7811
  } else {
7812
7812
  res += ch;
7813
7813
  }
7814
7814
  }
7815
- if (source[source.length - 1] !== '"' || source.length === 1)
7816
- onError(source.length, "MISSING_CHAR", 'Missing closing "quote');
7815
+ if (source2[source2.length - 1] !== '"' || source2.length === 1)
7816
+ onError(source2.length, "MISSING_CHAR", 'Missing closing "quote');
7817
7817
  return res;
7818
7818
  }
7819
- function foldNewline(source, offset) {
7819
+ function foldNewline(source2, offset) {
7820
7820
  let fold = "";
7821
- let ch = source[offset + 1];
7821
+ let ch = source2[offset + 1];
7822
7822
  while (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
7823
- if (ch === "\r" && source[offset + 2] !== "\n")
7823
+ if (ch === "\r" && source2[offset + 2] !== "\n")
7824
7824
  break;
7825
7825
  if (ch === "\n")
7826
7826
  fold += "\n";
7827
7827
  offset += 1;
7828
- ch = source[offset + 1];
7828
+ ch = source2[offset + 1];
7829
7829
  }
7830
7830
  if (!fold)
7831
7831
  fold = " ";
@@ -7864,14 +7864,14 @@ var require_resolve_flow_scalar = __commonJS({
7864
7864
  "\\": "\\",
7865
7865
  " ": " "
7866
7866
  };
7867
- function parseCharCode(source, offset, length, onError) {
7868
- const cc = source.substr(offset, length);
7867
+ function parseCharCode(source2, offset, length, onError) {
7868
+ const cc = source2.substr(offset, length);
7869
7869
  const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
7870
7870
  const code = ok ? parseInt(cc, 16) : NaN;
7871
7871
  try {
7872
7872
  return String.fromCodePoint(code);
7873
7873
  } catch {
7874
- const raw = source.substr(offset - 2, length + 2);
7874
+ const raw = source2.substr(offset - 2, length + 2);
7875
7875
  onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
7876
7876
  return raw;
7877
7877
  }
@@ -8079,13 +8079,13 @@ var require_compose_node = __commonJS({
8079
8079
  }
8080
8080
  return node;
8081
8081
  }
8082
- function composeAlias({ options }, { offset, source, end }, onError) {
8083
- const alias = new Alias.Alias(source.substring(1));
8082
+ function composeAlias({ options }, { offset, source: source2, end }, onError) {
8083
+ const alias = new Alias.Alias(source2.substring(1));
8084
8084
  if (alias.source === "")
8085
8085
  onError(offset, "BAD_ALIAS", "Alias cannot be an empty string");
8086
8086
  if (alias.source.endsWith(":"))
8087
- onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
8088
- const valueEnd = offset + source.length;
8087
+ onError(offset + source2.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
8088
+ const valueEnd = offset + source2.length;
8089
8089
  const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
8090
8090
  alias.range = [offset, valueEnd, re.offset];
8091
8091
  if (re.comment)
@@ -8156,18 +8156,18 @@ var require_composer = __commonJS({
8156
8156
  return [src, src + 1];
8157
8157
  if (Array.isArray(src))
8158
8158
  return src.length === 2 ? src : [src[0], src[1]];
8159
- const { offset, source } = src;
8160
- return [offset, offset + (typeof source === "string" ? source.length : 1)];
8159
+ const { offset, source: source2 } = src;
8160
+ return [offset, offset + (typeof source2 === "string" ? source2.length : 1)];
8161
8161
  }
8162
8162
  function parsePrelude(prelude) {
8163
8163
  let comment = "";
8164
8164
  let atComment = false;
8165
8165
  let afterEmptyLine = false;
8166
8166
  for (let i = 0; i < prelude.length; ++i) {
8167
- const source = prelude[i];
8168
- switch (source[0]) {
8167
+ const source2 = prelude[i];
8168
+ switch (source2[0]) {
8169
8169
  case "#":
8170
- comment += (comment === "" ? "" : afterEmptyLine ? "\n\n" : "\n") + (source.substring(1) || " ");
8170
+ comment += (comment === "" ? "" : afterEmptyLine ? "\n\n" : "\n") + (source2.substring(1) || " ");
8171
8171
  atComment = true;
8172
8172
  afterEmptyLine = false;
8173
8173
  break;
@@ -8191,8 +8191,8 @@ var require_composer = __commonJS({
8191
8191
  this.prelude = [];
8192
8192
  this.errors = [];
8193
8193
  this.warnings = [];
8194
- this.onError = (source, code, message2, warning) => {
8195
- const pos = getErrorPos(source);
8194
+ this.onError = (source2, code, message2, warning) => {
8195
+ const pos = getErrorPos(source2);
8196
8196
  if (warning)
8197
8197
  this.warnings.push(new errors.YAMLWarning(pos, code, message2));
8198
8198
  else
@@ -8378,7 +8378,7 @@ var require_cst_scalar = __commonJS({
8378
8378
  }
8379
8379
  function createScalarToken(value, context) {
8380
8380
  const { implicitKey = false, indent, inFlow = false, offset = -1, type = "PLAIN" } = context;
8381
- const source = stringifyString.stringifyString({ type, value }, {
8381
+ const source2 = stringifyString.stringifyString({ type, value }, {
8382
8382
  implicitKey,
8383
8383
  indent: indent > 0 ? " ".repeat(indent) : "",
8384
8384
  inFlow,
@@ -8387,12 +8387,12 @@ var require_cst_scalar = __commonJS({
8387
8387
  const end = context.end ?? [
8388
8388
  { type: "newline", offset: -1, indent, source: "\n" }
8389
8389
  ];
8390
- switch (source[0]) {
8390
+ switch (source2[0]) {
8391
8391
  case "|":
8392
8392
  case ">": {
8393
- const he = source.indexOf("\n");
8394
- const head = source.substring(0, he);
8395
- const body = source.substring(he + 1) + "\n";
8393
+ const he = source2.indexOf("\n");
8394
+ const head = source2.substring(0, he);
8395
+ const body = source2.substring(he + 1) + "\n";
8396
8396
  const props = [
8397
8397
  { type: "block-scalar-header", offset, indent, source: head }
8398
8398
  ];
@@ -8401,11 +8401,11 @@ var require_cst_scalar = __commonJS({
8401
8401
  return { type: "block-scalar", offset, indent, props, source: body };
8402
8402
  }
8403
8403
  case '"':
8404
- return { type: "double-quoted-scalar", offset, indent, source, end };
8404
+ return { type: "double-quoted-scalar", offset, indent, source: source2, end };
8405
8405
  case "'":
8406
- return { type: "single-quoted-scalar", offset, indent, source, end };
8406
+ return { type: "single-quoted-scalar", offset, indent, source: source2, end };
8407
8407
  default:
8408
- return { type: "scalar", offset, indent, source, end };
8408
+ return { type: "scalar", offset, indent, source: source2, end };
8409
8409
  }
8410
8410
  }
8411
8411
  function setScalarValue(token, value, context = {}) {
@@ -8431,31 +8431,31 @@ var require_cst_scalar = __commonJS({
8431
8431
  default:
8432
8432
  type = "PLAIN";
8433
8433
  }
8434
- const source = stringifyString.stringifyString({ type, value }, {
8434
+ const source2 = stringifyString.stringifyString({ type, value }, {
8435
8435
  implicitKey: implicitKey || indent === null,
8436
8436
  indent: indent !== null && indent > 0 ? " ".repeat(indent) : "",
8437
8437
  inFlow,
8438
8438
  options: { blockQuote: true, lineWidth: -1 }
8439
8439
  });
8440
- switch (source[0]) {
8440
+ switch (source2[0]) {
8441
8441
  case "|":
8442
8442
  case ">":
8443
- setBlockScalarValue(token, source);
8443
+ setBlockScalarValue(token, source2);
8444
8444
  break;
8445
8445
  case '"':
8446
- setFlowScalarValue(token, source, "double-quoted-scalar");
8446
+ setFlowScalarValue(token, source2, "double-quoted-scalar");
8447
8447
  break;
8448
8448
  case "'":
8449
- setFlowScalarValue(token, source, "single-quoted-scalar");
8449
+ setFlowScalarValue(token, source2, "single-quoted-scalar");
8450
8450
  break;
8451
8451
  default:
8452
- setFlowScalarValue(token, source, "scalar");
8452
+ setFlowScalarValue(token, source2, "scalar");
8453
8453
  }
8454
8454
  }
8455
- function setBlockScalarValue(token, source) {
8456
- const he = source.indexOf("\n");
8457
- const head = source.substring(0, he);
8458
- const body = source.substring(he + 1) + "\n";
8455
+ function setBlockScalarValue(token, source2) {
8456
+ const he = source2.indexOf("\n");
8457
+ const head = source2.substring(0, he);
8458
+ const body = source2.substring(he + 1) + "\n";
8459
8459
  if (token.type === "block-scalar") {
8460
8460
  const header2 = token.props[0];
8461
8461
  if (header2.type !== "block-scalar-header")
@@ -8490,31 +8490,31 @@ var require_cst_scalar = __commonJS({
8490
8490
  }
8491
8491
  return false;
8492
8492
  }
8493
- function setFlowScalarValue(token, source, type) {
8493
+ function setFlowScalarValue(token, source2, type) {
8494
8494
  switch (token.type) {
8495
8495
  case "scalar":
8496
8496
  case "double-quoted-scalar":
8497
8497
  case "single-quoted-scalar":
8498
8498
  token.type = type;
8499
- token.source = source;
8499
+ token.source = source2;
8500
8500
  break;
8501
8501
  case "block-scalar": {
8502
8502
  const end = token.props.slice(1);
8503
- let oa = source.length;
8503
+ let oa = source2.length;
8504
8504
  if (token.props[0].type === "block-scalar-header")
8505
8505
  oa -= token.props[0].source.length;
8506
8506
  for (const tok of end)
8507
8507
  tok.offset += oa;
8508
8508
  delete token.props;
8509
- Object.assign(token, { type, source, end });
8509
+ Object.assign(token, { type, source: source2, end });
8510
8510
  break;
8511
8511
  }
8512
8512
  case "block-map":
8513
8513
  case "block-seq": {
8514
- const offset = token.offset + source.length;
8514
+ const offset = token.offset + source2.length;
8515
8515
  const nl = { type: "newline", offset, indent: token.indent, source: "\n" };
8516
8516
  delete token.items;
8517
- Object.assign(token, { type, source, end: [nl] });
8517
+ Object.assign(token, { type, source: source2, end: [nl] });
8518
8518
  break;
8519
8519
  }
8520
8520
  default: {
@@ -8523,7 +8523,7 @@ var require_cst_scalar = __commonJS({
8523
8523
  for (const key of Object.keys(token))
8524
8524
  if (key !== "type" && key !== "offset")
8525
8525
  delete token[key];
8526
- Object.assign(token, { type, indent, source, end });
8526
+ Object.assign(token, { type, indent, source: source2, end });
8527
8527
  }
8528
8528
  }
8529
8529
  }
@@ -8683,8 +8683,8 @@ var require_cst = __commonJS({
8683
8683
  return JSON.stringify(token);
8684
8684
  }
8685
8685
  }
8686
- function tokenType(source) {
8687
- switch (source) {
8686
+ function tokenType(source2) {
8687
+ switch (source2) {
8688
8688
  case BOM:
8689
8689
  return "byte-order-mark";
8690
8690
  case DOCUMENT:
@@ -8718,7 +8718,7 @@ var require_cst = __commonJS({
8718
8718
  case ",":
8719
8719
  return "comma";
8720
8720
  }
8721
- switch (source[0]) {
8721
+ switch (source2[0]) {
8722
8722
  case " ":
8723
8723
  case " ":
8724
8724
  return "space";
@@ -8800,11 +8800,11 @@ var require_lexer = __commonJS({
8800
8800
  *
8801
8801
  * @returns A generator of lexical tokens
8802
8802
  */
8803
- *lex(source, incomplete = false) {
8804
- if (source) {
8805
- if (typeof source !== "string")
8803
+ *lex(source2, incomplete = false) {
8804
+ if (source2) {
8805
+ if (typeof source2 !== "string")
8806
8806
  throw TypeError("source is not a string");
8807
- this.buffer = this.buffer ? this.buffer + source : source;
8807
+ this.buffer = this.buffer ? this.buffer + source2 : source2;
8808
8808
  this.lineEndPos = null;
8809
8809
  }
8810
8810
  this.atEnd = !incomplete;
@@ -9449,12 +9449,12 @@ var require_parser = __commonJS({
9449
9449
  }
9450
9450
  return prev.splice(i, prev.length);
9451
9451
  }
9452
- function arrayPushArray(target, source) {
9453
- if (source.length < 1e5)
9454
- Array.prototype.push.apply(target, source);
9452
+ function arrayPushArray(target, source2) {
9453
+ if (source2.length < 1e5)
9454
+ Array.prototype.push.apply(target, source2);
9455
9455
  else
9456
- for (let i = 0; i < source.length; ++i)
9457
- target.push(source[i]);
9456
+ for (let i = 0; i < source2.length; ++i)
9457
+ target.push(source2[i]);
9458
9458
  }
9459
9459
  function fixFlowSeqItems(fc) {
9460
9460
  if (fc.start.type === "flow-seq-start") {
@@ -9500,10 +9500,10 @@ var require_parser = __commonJS({
9500
9500
  *
9501
9501
  * @returns A generator of tokens representing each directive, document, and other structure.
9502
9502
  */
9503
- *parse(source, incomplete = false) {
9503
+ *parse(source2, incomplete = false) {
9504
9504
  if (this.onNewLine && this.offset === 0)
9505
9505
  this.onNewLine(0);
9506
- for (const lexeme of this.lexer.lex(source, incomplete))
9506
+ for (const lexeme of this.lexer.lex(source2, incomplete))
9507
9507
  yield* this.next(lexeme);
9508
9508
  if (!incomplete)
9509
9509
  yield* this.end();
@@ -9511,21 +9511,21 @@ var require_parser = __commonJS({
9511
9511
  /**
9512
9512
  * Advance the parser by the `source` of one lexical token.
9513
9513
  */
9514
- *next(source) {
9515
- this.source = source;
9514
+ *next(source2) {
9515
+ this.source = source2;
9516
9516
  if (node_process.env.LOG_TOKENS)
9517
- console.log("|", cst.prettyToken(source));
9517
+ console.log("|", cst.prettyToken(source2));
9518
9518
  if (this.atScalar) {
9519
9519
  this.atScalar = false;
9520
9520
  yield* this.step();
9521
- this.offset += source.length;
9521
+ this.offset += source2.length;
9522
9522
  return;
9523
9523
  }
9524
- const type = cst.tokenType(source);
9524
+ const type = cst.tokenType(source2);
9525
9525
  if (!type) {
9526
- const message2 = `Not a YAML token: ${source}`;
9527
- yield* this.pop({ type: "error", offset: this.offset, message: message2, source });
9528
- this.offset += source.length;
9526
+ const message2 = `Not a YAML token: ${source2}`;
9527
+ yield* this.pop({ type: "error", offset: this.offset, message: message2, source: source2 });
9528
+ this.offset += source2.length;
9529
9529
  } else if (type === "scalar") {
9530
9530
  this.atNewLine = false;
9531
9531
  this.atScalar = true;
@@ -9538,17 +9538,17 @@ var require_parser = __commonJS({
9538
9538
  this.atNewLine = true;
9539
9539
  this.indent = 0;
9540
9540
  if (this.onNewLine)
9541
- this.onNewLine(this.offset + source.length);
9541
+ this.onNewLine(this.offset + source2.length);
9542
9542
  break;
9543
9543
  case "space":
9544
- if (this.atNewLine && source[0] === " ")
9545
- this.indent += source.length;
9544
+ if (this.atNewLine && source2[0] === " ")
9545
+ this.indent += source2.length;
9546
9546
  break;
9547
9547
  case "explicit-key-ind":
9548
9548
  case "map-value-ind":
9549
9549
  case "seq-item-ind":
9550
9550
  if (this.atNewLine)
9551
- this.indent += source.length;
9551
+ this.indent += source2.length;
9552
9552
  break;
9553
9553
  case "doc-mode":
9554
9554
  case "flow-error-end":
@@ -9556,7 +9556,7 @@ var require_parser = __commonJS({
9556
9556
  default:
9557
9557
  this.atNewLine = false;
9558
9558
  }
9559
- this.offset += source.length;
9559
+ this.offset += source2.length;
9560
9560
  }
9561
9561
  }
9562
9562
  /** Call at end of input to push out any remaining constructions */
@@ -10268,26 +10268,26 @@ var require_public_api = __commonJS({
10268
10268
  const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter() || null;
10269
10269
  return { lineCounter: lineCounter$1, prettyErrors };
10270
10270
  }
10271
- function parseAllDocuments(source, options = {}) {
10271
+ function parseAllDocuments(source2, options = {}) {
10272
10272
  const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
10273
10273
  const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
10274
10274
  const composer$1 = new composer.Composer(options);
10275
- const docs = Array.from(composer$1.compose(parser$1.parse(source)));
10275
+ const docs = Array.from(composer$1.compose(parser$1.parse(source2)));
10276
10276
  if (prettyErrors && lineCounter2)
10277
10277
  for (const doc of docs) {
10278
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
10279
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
10278
+ doc.errors.forEach(errors.prettifyError(source2, lineCounter2));
10279
+ doc.warnings.forEach(errors.prettifyError(source2, lineCounter2));
10280
10280
  }
10281
10281
  if (docs.length > 0)
10282
10282
  return docs;
10283
10283
  return Object.assign([], { empty: true }, composer$1.streamInfo());
10284
10284
  }
10285
- function parseDocument2(source, options = {}) {
10285
+ function parseDocument2(source2, options = {}) {
10286
10286
  const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
10287
10287
  const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
10288
10288
  const composer$1 = new composer.Composer(options);
10289
10289
  let doc = null;
10290
- for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
10290
+ for (const _doc of composer$1.compose(parser$1.parse(source2), true, source2.length)) {
10291
10291
  if (!doc)
10292
10292
  doc = _doc;
10293
10293
  else if (doc.options.logLevel !== "silent") {
@@ -10296,8 +10296,8 @@ var require_public_api = __commonJS({
10296
10296
  }
10297
10297
  }
10298
10298
  if (prettyErrors && lineCounter2) {
10299
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
10300
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
10299
+ doc.errors.forEach(errors.prettifyError(source2, lineCounter2));
10300
+ doc.warnings.forEach(errors.prettifyError(source2, lineCounter2));
10301
10301
  }
10302
10302
  return doc;
10303
10303
  }
@@ -10402,8 +10402,8 @@ var require_dist = __commonJS({
10402
10402
  });
10403
10403
 
10404
10404
  // src/cli/skill-profiles/yaml.ts
10405
- function parseProfileYaml(source) {
10406
- const document = (0, import_yaml.parseDocument)(source, { prettyErrors: false, strict: true, uniqueKeys: true });
10405
+ function parseProfileYaml(source2) {
10406
+ const document = (0, import_yaml.parseDocument)(source2, { prettyErrors: false, strict: true, uniqueKeys: true });
10407
10407
  if (document.errors.length) throw new Error("Invalid skill profile YAML.");
10408
10408
  return decodeProfile(document.toJS());
10409
10409
  }
@@ -10498,9 +10498,9 @@ var init_store = __esm({
10498
10498
  await rm6(temporary, { force: true });
10499
10499
  }
10500
10500
  }
10501
- async delete(name2) {
10501
+ async delete(name3) {
10502
10502
  await this.checkRoot();
10503
- const file = path29.join(this.root, `${profileName2(name2)}.yml`);
10503
+ const file = path29.join(this.root, `${profileName2(name3)}.yml`);
10504
10504
  const current = await optionalStat(file);
10505
10505
  if (!current) return false;
10506
10506
  if (!current.isFile() || current.nlink !== 1) throw new Error("Refusing to delete a linked or special profile file.");
@@ -11878,19 +11878,19 @@ var init_dirty = __esm({
11878
11878
  });
11879
11879
 
11880
11880
  // node_modules/tuiuiu.js/dist/core/layout.js
11881
- function normalizeNonNegativeLayoutNumber(value, name2) {
11881
+ function normalizeNonNegativeLayoutNumber(value, name3) {
11882
11882
  if (value === void 0)
11883
11883
  return 0;
11884
11884
  if (!Number.isFinite(value)) {
11885
- throw new RangeError(`${name2} must be a finite number`);
11885
+ throw new RangeError(`${name3} must be a finite number`);
11886
11886
  }
11887
11887
  return Math.max(0, Math.floor(value));
11888
11888
  }
11889
- function normalizeLayoutFactor(value, name2) {
11889
+ function normalizeLayoutFactor(value, name3) {
11890
11890
  if (value === void 0)
11891
11891
  return 0;
11892
11892
  if (!Number.isFinite(value) || value < 0) {
11893
- throw new RangeError(`${name2} must be a finite non-negative number`);
11893
+ throw new RangeError(`${name3} must be a finite non-negative number`);
11894
11894
  }
11895
11895
  return value;
11896
11896
  }
@@ -12764,9 +12764,9 @@ function hookWarnOnce(key, message2) {
12764
12764
  _hookWarned.add(key);
12765
12765
  console.warn(`[tuiuiu] ${message2}`);
12766
12766
  }
12767
- function createComponentOwner(name2, parent, definition, identity) {
12767
+ function createComponentOwner(name3, parent, definition, identity) {
12768
12768
  return {
12769
- name: name2,
12769
+ name: name3,
12770
12770
  parent,
12771
12771
  definition,
12772
12772
  identity,
@@ -12962,17 +12962,17 @@ function registerHookCleanup(cleanup, index = getCurrentHookIndex()) {
12962
12962
  ref.owner.hookCleanups.delete(id);
12963
12963
  };
12964
12964
  }
12965
- function renderOwnedComponent(definition, name2, key, render2) {
12965
+ function renderOwnedComponent(definition, name3, key, render2) {
12966
12966
  const runtime = getHookRuntimeState();
12967
12967
  const parent = runtime.currentOwner;
12968
12968
  if (!runtime.isRendering || !parent) {
12969
- throw new Error(`[tuiuiu] ${name2} is stateful and must be evaluated inside render(() => ...).`);
12969
+ throw new Error(`[tuiuiu] ${name3} is stateful and must be evaluated inside render(() => ...).`);
12970
12970
  }
12971
12971
  let identity;
12972
12972
  if (key === void 0) {
12973
12973
  const ordinal = parent.unkeyedCounts.get(definition) ?? 0;
12974
12974
  if (ordinal > 0 && process.env.NODE_ENV !== "production") {
12975
- throw new Error(`[tuiuiu] Multiple unkeyed ${name2} components share the same owner. Pass a stable \`key\` to every repeated stateful component.`);
12975
+ throw new Error(`[tuiuiu] Multiple unkeyed ${name3} components share the same owner. Pass a stable \`key\` to every repeated stateful component.`);
12976
12976
  }
12977
12977
  parent.unkeyedCounts.set(definition, ordinal + 1);
12978
12978
  identity = `unkeyed:${ordinal}`;
@@ -12987,10 +12987,10 @@ function renderOwnedComponent(definition, name2, key, render2) {
12987
12987
  let owner = byIdentity.get(identity);
12988
12988
  const wasNew = !owner;
12989
12989
  if (!owner) {
12990
- owner = createComponentOwner(name2, parent, definition, identity);
12990
+ owner = createComponentOwner(name3, parent, definition, identity);
12991
12991
  byIdentity.set(identity, owner);
12992
12992
  } else if (owner.lastRenderedGeneration === runtime.renderGeneration) {
12993
- throw new Error(`[tuiuiu] Duplicate ${name2} component key: ${String(key)}`);
12993
+ throw new Error(`[tuiuiu] Duplicate ${name3} component key: ${String(key)}`);
12994
12994
  }
12995
12995
  owner.disposed = false;
12996
12996
  const previousGeneration = owner.lastRenderedGeneration;
@@ -14230,11 +14230,11 @@ function isTerminalImageSource(value) {
14230
14230
  function toTerminalImageSource(sourceOrImageData) {
14231
14231
  return isTerminalImageSource(sourceOrImageData) ? sourceOrImageData : createTerminalImageSource(sourceOrImageData);
14232
14232
  }
14233
- function scaleDimension(source, from, to) {
14234
- if (source <= 0 || from <= 0 || to <= 0) {
14233
+ function scaleDimension(source2, from, to) {
14234
+ if (source2 <= 0 || from <= 0 || to <= 0) {
14235
14235
  return 1;
14236
14236
  }
14237
- return Math.max(1, Math.round(source * (to / from)));
14237
+ return Math.max(1, Math.round(source2 * (to / from)));
14238
14238
  }
14239
14239
  function createTerminalImageSource(imageData, options = {}) {
14240
14240
  const cellSize = normalizeCellSize(options.cellSize ?? getGraphicsCapabilities().cellSize);
@@ -14249,37 +14249,37 @@ function createTerminalImageSource(imageData, options = {}) {
14249
14249
  };
14250
14250
  }
14251
14251
  function planImageRender(sourceOrImageData, options = {}) {
14252
- const source = isTerminalImageSource(sourceOrImageData) ? sourceOrImageData : createTerminalImageSource(sourceOrImageData, { cellSize: options.cellSize });
14252
+ const source2 = isTerminalImageSource(sourceOrImageData) ? sourceOrImageData : createTerminalImageSource(sourceOrImageData, { cellSize: options.cellSize });
14253
14253
  const fit = options.fit ?? "contain";
14254
14254
  const requestedWidth = options.width ? Math.max(1, Math.round(options.width)) : void 0;
14255
14255
  const requestedHeight = options.height ? Math.max(1, Math.round(options.height)) : void 0;
14256
- let targetColumns = requestedWidth ?? source.desiredColumns;
14257
- let targetRows = requestedHeight ?? source.desiredRows;
14258
- let renderColumns = source.desiredColumns;
14259
- let renderRows = source.desiredRows;
14260
- let resizedPixelWidth = source.width;
14261
- let resizedPixelHeight = source.height;
14256
+ let targetColumns = requestedWidth ?? source2.desiredColumns;
14257
+ let targetRows = requestedHeight ?? source2.desiredRows;
14258
+ let renderColumns = source2.desiredColumns;
14259
+ let renderRows = source2.desiredRows;
14260
+ let resizedPixelWidth = source2.width;
14261
+ let resizedPixelHeight = source2.height;
14262
14262
  let visiblePixels = {
14263
14263
  x: 0,
14264
14264
  y: 0,
14265
- width: source.width,
14266
- height: source.height
14265
+ width: source2.width,
14266
+ height: source2.height
14267
14267
  };
14268
14268
  if (requestedWidth !== void 0 && requestedHeight === void 0) {
14269
14269
  renderColumns = requestedWidth;
14270
- renderRows = scaleDimension(source.desiredRows, source.desiredColumns, renderColumns);
14270
+ renderRows = scaleDimension(source2.desiredRows, source2.desiredColumns, renderColumns);
14271
14271
  targetColumns = renderColumns;
14272
14272
  targetRows = renderRows;
14273
- resizedPixelWidth = renderColumns * source.cellSize.width;
14274
- resizedPixelHeight = renderRows * source.cellSize.height;
14273
+ resizedPixelWidth = renderColumns * source2.cellSize.width;
14274
+ resizedPixelHeight = renderRows * source2.cellSize.height;
14275
14275
  visiblePixels = { x: 0, y: 0, width: resizedPixelWidth, height: resizedPixelHeight };
14276
14276
  } else if (requestedHeight !== void 0 && requestedWidth === void 0) {
14277
14277
  renderRows = requestedHeight;
14278
- renderColumns = scaleDimension(source.desiredColumns, source.desiredRows, renderRows);
14278
+ renderColumns = scaleDimension(source2.desiredColumns, source2.desiredRows, renderRows);
14279
14279
  targetColumns = renderColumns;
14280
14280
  targetRows = renderRows;
14281
- resizedPixelWidth = renderColumns * source.cellSize.width;
14282
- resizedPixelHeight = renderRows * source.cellSize.height;
14281
+ resizedPixelWidth = renderColumns * source2.cellSize.width;
14282
+ resizedPixelHeight = renderRows * source2.cellSize.height;
14283
14283
  visiblePixels = { x: 0, y: 0, width: resizedPixelWidth, height: resizedPixelHeight };
14284
14284
  } else if (requestedWidth !== void 0 && requestedHeight !== void 0) {
14285
14285
  targetColumns = requestedWidth;
@@ -14288,69 +14288,69 @@ function planImageRender(sourceOrImageData, options = {}) {
14288
14288
  case "fill":
14289
14289
  renderColumns = targetColumns;
14290
14290
  renderRows = targetRows;
14291
- resizedPixelWidth = renderColumns * source.cellSize.width;
14292
- resizedPixelHeight = renderRows * source.cellSize.height;
14291
+ resizedPixelWidth = renderColumns * source2.cellSize.width;
14292
+ resizedPixelHeight = renderRows * source2.cellSize.height;
14293
14293
  visiblePixels = { x: 0, y: 0, width: resizedPixelWidth, height: resizedPixelHeight };
14294
14294
  break;
14295
14295
  case "cover": {
14296
- const scale = Math.max(targetColumns / Math.max(1, source.desiredColumns), targetRows / Math.max(1, source.desiredRows));
14297
- const scaledColumns = Math.max(1, Math.round(source.desiredColumns * scale));
14298
- const scaledRows = Math.max(1, Math.round(source.desiredRows * scale));
14296
+ const scale = Math.max(targetColumns / Math.max(1, source2.desiredColumns), targetRows / Math.max(1, source2.desiredRows));
14297
+ const scaledColumns = Math.max(1, Math.round(source2.desiredColumns * scale));
14298
+ const scaledRows = Math.max(1, Math.round(source2.desiredRows * scale));
14299
14299
  renderColumns = targetColumns;
14300
14300
  renderRows = targetRows;
14301
- resizedPixelWidth = scaledColumns * source.cellSize.width;
14302
- resizedPixelHeight = scaledRows * source.cellSize.height;
14301
+ resizedPixelWidth = scaledColumns * source2.cellSize.width;
14302
+ resizedPixelHeight = scaledRows * source2.cellSize.height;
14303
14303
  visiblePixels = {
14304
- x: Math.max(0, Math.floor((resizedPixelWidth - targetColumns * source.cellSize.width) / 2)),
14305
- y: Math.max(0, Math.floor((resizedPixelHeight - targetRows * source.cellSize.height) / 2)),
14306
- width: targetColumns * source.cellSize.width,
14307
- height: targetRows * source.cellSize.height
14304
+ x: Math.max(0, Math.floor((resizedPixelWidth - targetColumns * source2.cellSize.width) / 2)),
14305
+ y: Math.max(0, Math.floor((resizedPixelHeight - targetRows * source2.cellSize.height) / 2)),
14306
+ width: targetColumns * source2.cellSize.width,
14307
+ height: targetRows * source2.cellSize.height
14308
14308
  };
14309
14309
  break;
14310
14310
  }
14311
14311
  case "crop":
14312
- renderColumns = Math.min(source.desiredColumns, targetColumns);
14313
- renderRows = Math.min(source.desiredRows, targetRows);
14314
- resizedPixelWidth = source.width;
14315
- resizedPixelHeight = source.height;
14312
+ renderColumns = Math.min(source2.desiredColumns, targetColumns);
14313
+ renderRows = Math.min(source2.desiredRows, targetRows);
14314
+ resizedPixelWidth = source2.width;
14315
+ resizedPixelHeight = source2.height;
14316
14316
  visiblePixels = {
14317
14317
  x: 0,
14318
14318
  y: 0,
14319
- width: Math.min(source.width, renderColumns * source.cellSize.width),
14320
- height: Math.min(source.height, renderRows * source.cellSize.height)
14319
+ width: Math.min(source2.width, renderColumns * source2.cellSize.width),
14320
+ height: Math.min(source2.height, renderRows * source2.cellSize.height)
14321
14321
  };
14322
14322
  break;
14323
14323
  case "none":
14324
- renderColumns = Math.min(source.desiredColumns, targetColumns);
14325
- renderRows = Math.min(source.desiredRows, targetRows);
14326
- resizedPixelWidth = source.width;
14327
- resizedPixelHeight = source.height;
14324
+ renderColumns = Math.min(source2.desiredColumns, targetColumns);
14325
+ renderRows = Math.min(source2.desiredRows, targetRows);
14326
+ resizedPixelWidth = source2.width;
14327
+ resizedPixelHeight = source2.height;
14328
14328
  visiblePixels = {
14329
14329
  x: 0,
14330
14330
  y: 0,
14331
- width: Math.min(source.width, renderColumns * source.cellSize.width),
14332
- height: Math.min(source.height, renderRows * source.cellSize.height)
14331
+ width: Math.min(source2.width, renderColumns * source2.cellSize.width),
14332
+ height: Math.min(source2.height, renderRows * source2.cellSize.height)
14333
14333
  };
14334
14334
  break;
14335
14335
  case "contain":
14336
14336
  default: {
14337
- const scale = Math.min(targetColumns / Math.max(1, source.desiredColumns), targetRows / Math.max(1, source.desiredRows));
14338
- renderColumns = Math.max(1, Math.round(source.desiredColumns * scale));
14339
- renderRows = Math.max(1, Math.round(source.desiredRows * scale));
14340
- resizedPixelWidth = renderColumns * source.cellSize.width;
14341
- resizedPixelHeight = renderRows * source.cellSize.height;
14337
+ const scale = Math.min(targetColumns / Math.max(1, source2.desiredColumns), targetRows / Math.max(1, source2.desiredRows));
14338
+ renderColumns = Math.max(1, Math.round(source2.desiredColumns * scale));
14339
+ renderRows = Math.max(1, Math.round(source2.desiredRows * scale));
14340
+ resizedPixelWidth = renderColumns * source2.cellSize.width;
14341
+ resizedPixelHeight = renderRows * source2.cellSize.height;
14342
14342
  visiblePixels = { x: 0, y: 0, width: resizedPixelWidth, height: resizedPixelHeight };
14343
14343
  break;
14344
14344
  }
14345
14345
  }
14346
14346
  } else {
14347
- resizedPixelWidth = source.desiredColumns * source.cellSize.width;
14348
- resizedPixelHeight = source.desiredRows * source.cellSize.height;
14347
+ resizedPixelWidth = source2.desiredColumns * source2.cellSize.width;
14348
+ resizedPixelHeight = source2.desiredRows * source2.cellSize.height;
14349
14349
  visiblePixels = { x: 0, y: 0, width: resizedPixelWidth, height: resizedPixelHeight };
14350
14350
  }
14351
14351
  return {
14352
14352
  fit,
14353
- cellSize: source.cellSize,
14353
+ cellSize: source2.cellSize,
14354
14354
  targetColumns,
14355
14355
  targetRows,
14356
14356
  renderColumns,
@@ -14580,12 +14580,12 @@ var init_graphics = __esm({
14580
14580
  * Transmit image data to terminal
14581
14581
  */
14582
14582
  transmit(imageData, options = {}) {
14583
- const source = toTerminalImageSource(imageData);
14584
- const plan = planImageRender(source, options);
14583
+ const source2 = toTerminalImageSource(imageData);
14584
+ const plan = planImageRender(source2, options);
14585
14585
  const cols = options.width ?? plan.renderColumns;
14586
14586
  const rows = options.height ?? plan.renderRows;
14587
14587
  const imageId = Number.isInteger(options.imageId) && options.imageId && options.imageId > 0 ? `,i=${options.imageId}` : "";
14588
- const pngData = encodePng(source);
14588
+ const pngData = encodePng(source2);
14589
14589
  const base64Data = base64Encode(pngData);
14590
14590
  const CHUNK_SIZE = 4096;
14591
14591
  const chunks = [];
@@ -14649,9 +14649,9 @@ var init_graphics = __esm({
14649
14649
  * Encode image as Sixel
14650
14650
  */
14651
14651
  encode(imageData, options = {}) {
14652
- const source = toTerminalImageSource(imageData);
14653
- const plan = planImageRender(source, options);
14654
- const scaled = options.width !== void 0 || options.height !== void 0 ? scaleImage({ width: source.width, height: source.height, pixels: source.pixels }, plan.resizedPixelWidth, plan.resizedPixelHeight) : source;
14652
+ const source2 = toTerminalImageSource(imageData);
14653
+ const plan = planImageRender(source2, options);
14654
+ const scaled = options.width !== void 0 || options.height !== void 0 ? scaleImage({ width: source2.width, height: source2.height, pixels: source2.pixels }, plan.resizedPixelWidth, plan.resizedPixelHeight) : source2;
14655
14655
  const { width, height, pixels } = scaled;
14656
14656
  const palette14 = buildPalette(pixels, 256);
14657
14657
  let output = "\x1BPq";
@@ -14696,8 +14696,8 @@ var init_graphics = __esm({
14696
14696
  };
14697
14697
  halfblockGraphics = {
14698
14698
  render(imageData, options = {}) {
14699
- const source = toTerminalImageSource(imageData);
14700
- const plan = planImageRender(source, options);
14699
+ const source2 = toTerminalImageSource(imageData);
14700
+ const plan = planImageRender(source2, options);
14701
14701
  const sampleWidth = Math.max(1, plan.renderColumns);
14702
14702
  const sampleHeight = Math.max(1, plan.renderRows * 2);
14703
14703
  const scaled = scaleImage(imageData, sampleWidth, sampleHeight);
@@ -16781,8 +16781,8 @@ function cacheMaterializedStructuralDrawCommands(signature, materialized, materi
16781
16781
  entry.materialized = materialized;
16782
16782
  entry.materializedSignature = materializedSignature;
16783
16783
  }
16784
- function appendCachedDrawCommands(target, source) {
16785
- for (const command of source) {
16784
+ function appendCachedDrawCommands(target, source2) {
16785
+ for (const command of source2) {
16786
16786
  target.push(command);
16787
16787
  }
16788
16788
  }
@@ -16832,10 +16832,10 @@ function createTerminalImageCommand(current, absX, absY, width, height, props) {
16832
16832
  }
16833
16833
  const metadata = props.__terminalImage;
16834
16834
  const graphicsCapabilities = getGraphicsCapabilities();
16835
- const source = isTerminalImageSourceLike(metadata.source) ? metadata.source : createTerminalImageSource(metadata.source, { cellSize: graphicsCapabilities.cellSize });
16835
+ const source2 = isTerminalImageSourceLike(metadata.source) ? metadata.source : createTerminalImageSource(metadata.source, { cellSize: graphicsCapabilities.cellSize });
16836
16836
  const requestedProtocol = metadata.options?.protocol ?? graphicsCapabilities.protocol;
16837
16837
  const protocol = resolveRenderableGraphicsProtocol(requestedProtocol);
16838
- const plan = planImageRender(source, {
16838
+ const plan = planImageRender(source2, {
16839
16839
  ...metadata.options,
16840
16840
  width: metadata.options?.width ?? contentWidth,
16841
16841
  height: metadata.options?.height ?? contentHeight
@@ -16855,7 +16855,7 @@ function createTerminalImageCommand(current, absX, absY, width, height, props) {
16855
16855
  height: renderHeight,
16856
16856
  instanceKey: metadata.protocolState?.instanceKey,
16857
16857
  kittyImageId: metadata.protocolState?.kittyImageId,
16858
- source,
16858
+ source: source2,
16859
16859
  fit: plan.fit,
16860
16860
  threshold: metadata.options?.threshold,
16861
16861
  dither: metadata.options?.dither,
@@ -17337,8 +17337,8 @@ var init_progressive_state = __esm({
17337
17337
  });
17338
17338
 
17339
17339
  // node_modules/tuiuiu.js/dist/core/capabilities.js
17340
- function detectTerminalCapabilities(source = {}) {
17341
- const env = source.env ?? process.env;
17340
+ function detectTerminalCapabilities(source2 = {}) {
17341
+ const env = source2.env ?? process.env;
17342
17342
  const term = env.TERM || "";
17343
17343
  const colorTerm = env.COLORTERM || "";
17344
17344
  const termProgram = env.TERM_PROGRAM || "";
@@ -17371,7 +17371,7 @@ function detectTerminalCapabilities(source = {}) {
17371
17371
  const italic = caps.italic || term.includes("xterm") || term.includes("kitty") || term.includes("alacritty") || termProgram === "iTerm.app" || termProgram === "Hyper";
17372
17372
  const strikethrough = caps.strikethrough || italic;
17373
17373
  const hyperlinks = caps.hyperlinks || termProgram === "iTerm.app" || term.includes("kitty") || !!env.WT_SESSION || termProgram === "vscode" && parseInt(termProgramVersion, 10) >= 1;
17374
- const stdout = source.stdout ?? process.stdout;
17374
+ const stdout = source2.stdout ?? process.stdout;
17375
17375
  const columns = stdout.columns || 80;
17376
17376
  const rows = stdout.rows || 24;
17377
17377
  const nerdFonts = hasNerdFonts();
@@ -17465,14 +17465,14 @@ function attachResizeListener(state) {
17465
17465
  });
17466
17466
  stdout.on("resize", state.resizeListener);
17467
17467
  }
17468
- function configureTerminalCapabilitySource(source) {
17468
+ function configureTerminalCapabilitySource(source2) {
17469
17469
  const state = getCapabilityRuntimeState();
17470
17470
  const previousStdout = state.source.stdout ?? process.stdout;
17471
17471
  if (state.resizeListener) {
17472
17472
  previousStdout.off("resize", state.resizeListener);
17473
17473
  state.resizeListener = null;
17474
17474
  }
17475
- state.source = { ...source };
17475
+ state.source = { ...source2 };
17476
17476
  state.cachedCapabilities = null;
17477
17477
  state.cachedProgressiveVersion = -1;
17478
17478
  attachResizeListener(state);
@@ -18292,12 +18292,12 @@ var init_buffer = __esm({
18292
18292
  this.addDamage(0, 0, this.width, this.height);
18293
18293
  }
18294
18294
  /** Copy content from another buffer */
18295
- copyFrom(source, srcX = 0, srcY = 0, dstX = 0, dstY = 0, width, height) {
18296
- const w = width ?? source.width;
18297
- const h = height ?? source.height;
18295
+ copyFrom(source2, srcX = 0, srcY = 0, dstX = 0, dstY = 0, width, height) {
18296
+ const w = width ?? source2.width;
18297
+ const h = height ?? source2.height;
18298
18298
  for (let y = 0; y < h; y++) {
18299
18299
  for (let x = 0; x < w; x++) {
18300
- const srcCell = source.get(srcX + x, srcY + y);
18300
+ const srcCell = source2.get(srcX + x, srcY + y);
18301
18301
  if (srcCell) {
18302
18302
  this.set(dstX + x, dstY + y, cloneCell(srcCell));
18303
18303
  }
@@ -18545,7 +18545,7 @@ function textSpansEqual(left, right) {
18545
18545
  return left.every((span, index) => span.text === right[index].text && STYLE_KEYS.every((key) => span.style?.[key] === right[index].style?.[key]));
18546
18546
  }
18547
18547
  function layoutTextSpans(spans, columns, wrap) {
18548
- const source = spans.map((span) => span.text).join("");
18548
+ const source2 = spans.map((span) => span.text).join("");
18549
18549
  const ranges = [];
18550
18550
  let end = 0;
18551
18551
  for (const span of spans) {
@@ -18566,7 +18566,7 @@ function layoutTextSpans(spans, columns, wrap) {
18566
18566
  };
18567
18567
  const rows = [];
18568
18568
  let sourceBase = 0;
18569
- for (const line of source.split("\n")) {
18569
+ for (const line of source2.split("\n")) {
18570
18570
  let searchFrom = 0;
18571
18571
  for (const fitted of fitTextToWidth(line, columns, wrap)) {
18572
18572
  const truncated = columns > 0 && wrap?.startsWith("truncate") && stringWidth(line) > columns;
@@ -26143,10 +26143,10 @@ function getContrastColor(color) {
26143
26143
  }
26144
26144
  return "white";
26145
26145
  }
26146
- function getColor(name2, shade = 500) {
26147
- const palette14 = colors[name2];
26146
+ function getColor(name3, shade = 500) {
26147
+ const palette14 = colors[name3];
26148
26148
  if (!palette14)
26149
- return name2;
26149
+ return name3;
26150
26150
  if (typeof palette14 === "string")
26151
26151
  return palette14;
26152
26152
  return palette14[shade] ?? palette14[500];
@@ -27895,8 +27895,8 @@ function applyEncodedKey(key, keyCode, associatedText = "") {
27895
27895
  }
27896
27896
  return associatedText || String.fromCodePoint(keyCode);
27897
27897
  }
27898
- function applyKeyName(key, name2) {
27899
- switch (name2) {
27898
+ function applyKeyName(key, name3) {
27899
+ switch (name3) {
27900
27900
  case "up":
27901
27901
  key.upArrow = true;
27902
27902
  break;
@@ -29610,14 +29610,14 @@ var init_use_focus = __esm({
29610
29610
 
29611
29611
  // node_modules/tuiuiu.js/dist/core/input-stream.js
29612
29612
  import { StringDecoder } from "node:string_decoder";
29613
- function validatePositiveSafeInteger(value, name2) {
29613
+ function validatePositiveSafeInteger(value, name3) {
29614
29614
  if (!Number.isSafeInteger(value) || value < 1) {
29615
- throw new Error(`[tuiuiu] ${name2} must be a positive safe integer`);
29615
+ throw new Error(`[tuiuiu] ${name3} must be a positive safe integer`);
29616
29616
  }
29617
29617
  }
29618
- function validateNonNegativeSafeInteger(value, name2) {
29618
+ function validateNonNegativeSafeInteger(value, name3) {
29619
29619
  if (!Number.isSafeInteger(value) || value < 0) {
29620
- throw new Error(`[tuiuiu] ${name2} must be a non-negative safe integer`);
29620
+ throw new Error(`[tuiuiu] ${name3} must be a non-negative safe integer`);
29621
29621
  }
29622
29622
  }
29623
29623
  function incompleteEscapeStart(input) {
@@ -30715,17 +30715,17 @@ var init_computed_node = __esm({
30715
30715
  });
30716
30716
 
30717
30717
  // node_modules/tuiuiu.js/dist/app/component.js
30718
- function component(name2, render2) {
30719
- if (!name2.trim()) {
30718
+ function component(name3, render2) {
30719
+ if (!name3.trim()) {
30720
30720
  throw new Error("[tuiuiu] component() requires a non-empty display name");
30721
30721
  }
30722
30722
  const definition = {};
30723
30723
  const owned = (input = {}, ...args) => {
30724
30724
  const { key, ...props } = input;
30725
- return renderOwnedComponent(definition, name2, key, () => render2(props, ...args));
30725
+ return renderOwnedComponent(definition, name3, key, () => render2(props, ...args));
30726
30726
  };
30727
30727
  Object.defineProperty(owned, "displayName", {
30728
- value: name2,
30728
+ value: name3,
30729
30729
  enumerable: true
30730
30730
  });
30731
30731
  return owned;
@@ -32257,8 +32257,8 @@ function createTextViewport(document, initial) {
32257
32257
  const display = (text) => displayParts(segmentGraphemes(text));
32258
32258
  const reflow = (logicalLine) => {
32259
32259
  const current = document.line(logicalLine);
32260
- const source = { ...current, text: current.text.split("").join("") };
32261
- const graphemes = segmentGraphemes(source.text);
32260
+ const source2 = { ...current, text: current.text.split("").join("") };
32261
+ const graphemes = segmentGraphemes(source2.text);
32262
32262
  const nextRows = [];
32263
32263
  let first = 0;
32264
32264
  do {
@@ -32279,19 +32279,19 @@ function createTextViewport(document, initial) {
32279
32279
  }
32280
32280
  if (options.wrap === "word" && next < graphemes.length && wordBreak > first)
32281
32281
  next = wordBreak;
32282
- const start = graphemes[first]?.index ?? source.text.length;
32282
+ const start = graphemes[first]?.index ?? source2.text.length;
32283
32283
  const end = next > first ? graphemes[next - 1].end : start;
32284
- const text = source.text.slice(start, end);
32284
+ const text = source2.text.slice(start, end);
32285
32285
  nextRows.push(Object.freeze({
32286
32286
  text,
32287
- start: source.start + start,
32288
- end: source.start + end,
32287
+ start: source2.start + start,
32288
+ end: source2.start + end,
32289
32289
  logicalLine,
32290
32290
  ...displayParts(graphemes, first, next)
32291
32291
  }));
32292
32292
  first = next;
32293
32293
  } while (first < graphemes.length);
32294
- return { source, rows: Object.freeze(nextRows) };
32294
+ return { source: source2, rows: Object.freeze(nextRows) };
32295
32295
  };
32296
32296
  const logicalLineAt = (offset) => {
32297
32297
  let low = 0;
@@ -35541,7 +35541,7 @@ async function editProfiles(ports, screen2 = "alternate") {
35541
35541
  break;
35542
35542
  }
35543
35543
  case "name": {
35544
- const name2 = await app.prompts.input("Save as", { default: active.name, validate: (value2) => {
35544
+ const name3 = await app.prompts.input("Save as", { default: active.name, validate: (value2) => {
35545
35545
  try {
35546
35546
  profileName2(value2);
35547
35547
  return true;
@@ -35549,23 +35549,23 @@ async function editProfiles(ports, screen2 = "alternate") {
35549
35549
  return message(error);
35550
35550
  }
35551
35551
  } });
35552
- setDraft({ ...active, name: profileName2(name2) });
35552
+ setDraft({ ...active, name: profileName2(name3) });
35553
35553
  break;
35554
35554
  }
35555
35555
  case "browser":
35556
35556
  setDraft({ ...active, browser: !active.browser });
35557
35557
  break;
35558
35558
  case "save": {
35559
- const name2 = profileName2(active.name || await app.prompts.input("Save as"));
35560
- if (name2 !== active.selected && list.profiles.some((profile) => profile.name === name2) && !await confirm(`Replace ${name2}?`)) return;
35559
+ const name3 = profileName2(active.name || await app.prompts.input("Save as"));
35560
+ if (name3 !== active.selected && list.profiles.some((profile) => profile.name === name3) && !await confirm(`Replace ${name3}?`)) return;
35561
35561
  await ports.save({
35562
- name: name2,
35562
+ name: name3,
35563
35563
  skills: [...active.skills, ...active.missing],
35564
35564
  ...active.browser !== void 0 ? { browser: active.browser } : {}
35565
35565
  });
35566
35566
  list = await ports.list();
35567
- setDraft({ ...active, selected: name2, name: name2, empty: false });
35568
- setStatus(`Saved ${name2}.`);
35567
+ setDraft({ ...active, selected: name3, name: name3, empty: false });
35568
+ setStatus(`Saved ${name3}.`);
35569
35569
  break;
35570
35570
  }
35571
35571
  case "delete":
@@ -35752,7 +35752,7 @@ async function profilePorts(invocation, streams, discovery = []) {
35752
35752
  defaults: () => store.defaults(cwd),
35753
35753
  discover: () => discoverSkills({ ...invocation, cwd }, streams, discovery),
35754
35754
  save: (profile) => store.save(profile),
35755
- delete: (name2) => store.delete(name2)
35755
+ delete: (name3) => store.delete(name3)
35756
35756
  };
35757
35757
  }
35758
35758
  async function manageSkillProfiles(invocation, streams, interactive) {
@@ -35772,8 +35772,8 @@ async function prepareProfileLaunch(invocation, streams, interactive) {
35772
35772
  const ports = await profilePorts({ ...invocation, cwd: options.cwd }, streams, options.discovery);
35773
35773
  let profile;
35774
35774
  if (options.profile) {
35775
- const name2 = profileName2(options.profile);
35776
- profile = (await ports.list()).profiles.find((entry) => entry.name === name2);
35775
+ const name3 = profileName2(options.profile);
35776
+ profile = (await ports.list()).profiles.find((entry) => entry.name === name3);
35777
35777
  if (!profile) throw new Error(`Unknown skill profile: ${options.profile}`);
35778
35778
  } else {
35779
35779
  while (true) {
@@ -35838,6 +35838,7 @@ var internalCommandNames = [
35838
35838
  ];
35839
35839
  var commandAliases = { "--help": "help", "-h": "help", "--version": "version", "-V": "version" };
35840
35840
  var retiredCommandNames = ["xerj"];
35841
+ var updateComponents = ["all", "gestalt", "mobile", "serena", "playwright"];
35841
35842
 
35842
35843
  // src/cli/dispatch.ts
35843
35844
  async function runCli(invocation, streams, metadata, handlers = {}) {
@@ -35876,9 +35877,10 @@ async function runCli(invocation, streams, metadata, handlers = {}) {
35876
35877
  import path19 from "node:path";
35877
35878
 
35878
35879
  // src/cli/setup/agents.ts
35879
- import { mkdir as mkdir3, readFile as readFile3, realpath as realpath5, rename as rename3, rm, stat as stat3, unlink as unlink3 } from "node:fs/promises";
35880
+ import { cp, mkdir as mkdir3, readFile as readFile3, realpath as realpath5, rename as rename3, rm, stat as stat3, unlink as unlink3 } from "node:fs/promises";
35880
35881
  import path10 from "node:path";
35881
- import { pathToFileURL } from "node:url";
35882
+ import { constants as constants4 } from "node:fs";
35883
+ import { isDeepStrictEqual } from "node:util";
35882
35884
 
35883
35885
  // node_modules/smol-toml/dist/error.js
35884
35886
  function getLineColFromPtr(string2, ptr) {
@@ -36820,23 +36822,104 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false, strictTemporal
36820
36822
  return str;
36821
36823
  }
36822
36824
 
36825
+ // src/cli/setup/agents-pin.mjs
36826
+ var name = "dyne-gestalt-agents";
36827
+ var source = "https://github.com/dyne/gestalt-agents.git";
36828
+ var sha = /^[a-f0-9]{40}$/;
36829
+ async function planAgentsPin({ marketplace, marketplaceName, config, mode, readProvenance, git, installedGitDir, windowsRevision }) {
36830
+ if (marketplace !== "dyne/gestalt-agents" || marketplaceName !== name) return null;
36831
+ const entry = parse(config).marketplaces?.[name];
36832
+ if (entry && (entry.source_type !== "git" || entry.source !== source)) return null;
36833
+ if (entry?.ref !== void 0) {
36834
+ const provenance = await readProvenance();
36835
+ let owned;
36836
+ try {
36837
+ owned = JSON.parse(provenance ?? "null")?.managedAgentsRef;
36838
+ } catch (error) {
36839
+ if (!(error instanceof SyntaxError)) throw error;
36840
+ }
36841
+ if (entry.ref !== owned) return null;
36842
+ }
36843
+ let ref;
36844
+ if (entry && mode === "install" && (entry.ref || installedGitDir)) {
36845
+ ref = entry.ref ?? (await git(["--git-dir", installedGitDir, "rev-parse", "--verify", "HEAD^{commit}"])).trim();
36846
+ } else if (windowsRevision) {
36847
+ ref = windowsRevision;
36848
+ } else {
36849
+ const tags = await git(["ls-remote", "--tags", "--sort=-version:refname", source, "refs/tags/v*"]);
36850
+ const releases = /* @__PURE__ */ new Map();
36851
+ for (const row of tags.split(/\r?\n/)) {
36852
+ const match = /^([a-f0-9]{40})\s+refs\/tags\/(v\d+\.\d+\.\d+)(\^\{\})?$/.exec(row);
36853
+ if (match && (match[3] || !releases.has(match[2]))) releases.set(match[2], match[1]);
36854
+ }
36855
+ ref = releases.values().next().value;
36856
+ }
36857
+ if (!sha.test(ref ?? "")) throw new Error("Cannot determine an immutable Gestalt Agents release commit");
36858
+ return { ref, fresh: !entry, changing: entry?.ref !== ref };
36859
+ }
36860
+ function verifyAgentsPin(text, revision, ref) {
36861
+ const entry = parse(text).marketplaces?.[name];
36862
+ if (entry?.source_type !== "git" || entry.source !== source || entry.ref !== ref || revision.trim() !== ref)
36863
+ throw new Error("Codex did not activate the selected Gestalt Agents commit and ref");
36864
+ }
36865
+ function setAgentsRef(text, ref, same) {
36866
+ const expected = parse(text);
36867
+ const entry = expected.marketplaces[name];
36868
+ if (entry.ref === ref) return text;
36869
+ const old = entry.ref;
36870
+ entry.ref = ref;
36871
+ function accepts(candidate) {
36872
+ try {
36873
+ return same(parse(candidate), expected);
36874
+ } catch {
36875
+ return false;
36876
+ }
36877
+ }
36878
+ if (old !== void 0) {
36879
+ for (const match of text.matchAll(/(["'])([a-f0-9]{40})\1/g)) {
36880
+ if (match[2] !== old) continue;
36881
+ const start = match.index + 1;
36882
+ const candidate = text.slice(0, start) + ref + text.slice(start + old.length);
36883
+ if (accepts(candidate)) return candidate;
36884
+ }
36885
+ } else {
36886
+ const newline = text.includes("\r\n") ? "\r\n" : "\n";
36887
+ for (const match of text.matchAll(/(?:["']source_type["']|\bsource_type)\s*=\s*(?:"git"|'git')/g)) {
36888
+ const end = match.index + match[0].length;
36889
+ const lineEnd = text.indexOf("\n", end);
36890
+ const next = lineEnd < 0 ? text.length : lineEnd + 1;
36891
+ for (const prefix of ["", name + ".", "marketplaces." + name + "."]) {
36892
+ const assignment = prefix + 'ref = "' + ref + '"';
36893
+ const inline = text.slice(0, end) + ", " + assignment + text.slice(end);
36894
+ if (accepts(inline)) return inline;
36895
+ const line = text.slice(0, next) + (lineEnd < 0 ? newline : "") + assignment + newline + text.slice(next);
36896
+ if (accepts(line)) return line;
36897
+ }
36898
+ }
36899
+ }
36900
+ throw new Error("Cannot record the Gestalt Agents ref without changing other Codex settings");
36901
+ }
36902
+
36903
+ // src/cli/setup/agents.ts
36904
+ import { pathToFileURL } from "node:url";
36905
+
36823
36906
  // src/cli/runtime/approvals.mjs
36824
36907
  import { join } from "node:path";
36825
36908
  function managedToolApproval(server) {
36826
36909
  return { ...server, ...!server.url ? { env_vars: [.../* @__PURE__ */ new Set([...server.env_vars ?? [], "GESTALT_SESSION_TMP_CONTEXT", "TMPDIR", "TMP", "TEMP"])] } : {}, default_tools_approval_mode: "approve", ...server.tools ? { tools: Object.fromEntries(
36827
- Object.entries(server.tools).map(([name2, tool]) => [name2, tool && typeof tool === "object" && Object.hasOwn(tool, "approval_mode") ? { ...tool, approval_mode: "approve" } : tool])
36910
+ Object.entries(server.tools).map(([name3, tool]) => [name3, tool && typeof tool === "object" && Object.hasOwn(tool, "approval_mode") ? { ...tool, approval_mode: "approve" } : tool])
36828
36911
  ) } : {} };
36829
36912
  }
36830
- function isGestaltManagedMcp(name2, server, owner) {
36913
+ function isGestaltManagedMcp(name3, server, owner) {
36831
36914
  if (!server || typeof server !== "object" || server.url) return false;
36832
36915
  const components = { "gestalt-serena": "serena", "gestalt-playwright": "playwright" };
36833
- if (Object.hasOwn(components, name2)) return !server.command && !server.args || [owner.manager, "gestalt"].includes(server.command) && server.args?.[0] === components[name2] && server.args?.[1] === "mcp";
36834
- return name2 === "context-mode" && ["node", "node.exe"].includes(String(server.command).replaceAll("\\", "/").split("/").at(-1)) && server.args?.includes(join(owner.codexHome, "bin/context-mode-mcp.mjs"));
36916
+ if (Object.hasOwn(components, name3)) return !server.command && !server.args || [owner.manager, "gestalt"].includes(server.command) && server.args?.[0] === components[name3] && server.args?.[1] === "mcp";
36917
+ return name3 === "context-mode" && ["node", "node.exe"].includes(String(server.command).replaceAll("\\", "/").split("/").at(-1)) && server.args?.includes(join(owner.codexHome, "bin/context-mode-mcp.mjs"));
36835
36918
  }
36836
36919
  function managedMcpApprovals(config, owner) {
36837
36920
  const result = { ...config };
36838
- if (config.mcp_servers) result.mcp_servers = Object.fromEntries(Object.entries(config.mcp_servers).map(([name2, server]) => [name2, isGestaltManagedMcp(name2, server, owner) ? managedToolApproval(server) : server]));
36839
- if (config.plugins) result.plugins = Object.fromEntries(Object.entries(config.plugins).map(([name2, plugin]) => [name2, name2 === "context-mode@dyne-gestalt-agents" && plugin?.mcp_servers ? { ...plugin, mcp_servers: Object.fromEntries(
36921
+ if (config.mcp_servers) result.mcp_servers = Object.fromEntries(Object.entries(config.mcp_servers).map(([name3, server]) => [name3, isGestaltManagedMcp(name3, server, owner) ? managedToolApproval(server) : server]));
36922
+ if (config.plugins) result.plugins = Object.fromEntries(Object.entries(config.plugins).map(([name3, plugin]) => [name3, name3 === "context-mode@dyne-gestalt-agents" && plugin?.mcp_servers ? { ...plugin, mcp_servers: Object.fromEntries(
36840
36923
  Object.entries(plugin.mcp_servers).map(([serverName, server]) => [serverName, serverName === "context-mode" ? managedToolApproval(server) : server])
36841
36924
  ) } : plugin]));
36842
36925
  return result;
@@ -36861,24 +36944,24 @@ function managedMcpOverrides(config, baseline, owner) {
36861
36944
  effective = merge(effective, value);
36862
36945
  }
36863
36946
  const approved = managedMcpApprovals({ [section]: effective }, owner)[section];
36864
- const changed = Object.fromEntries(Object.entries(approved).filter(([name2, server]) => JSON.stringify(server) !== JSON.stringify(effective[name2])));
36865
- for (const name2 of Object.keys(changed)) for (const key of Object.keys(result))
36866
- if (key === section + "." + name2 || key.startsWith(section + "." + name2 + ".")) delete result[key];
36947
+ const changed = Object.fromEntries(Object.entries(approved).filter(([name3, server]) => JSON.stringify(server) !== JSON.stringify(effective[name3])));
36948
+ for (const name3 of Object.keys(changed)) for (const key of Object.keys(result))
36949
+ if (key === section + "." + name3 || key.startsWith(section + "." + name3 + ".")) delete result[key];
36867
36950
  if (Object.keys(changed).length || config?.[section]) result[section] = merge(config?.[section] ?? {}, changed);
36868
36951
  }
36869
36952
  return result;
36870
36953
  }
36871
36954
 
36872
36955
  // src/cli/setup/configuration.mjs
36873
- function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp", cacheRoots = []) {
36874
- parse(source);
36875
- const newline = source.match(/\r\n|\n|\r/)?.[0] ?? "\n";
36956
+ function permissionConfiguration(source2, homeReadRoots, temporaryRoot = "/tmp", cacheRoots = []) {
36957
+ parse(source2);
36958
+ const newline = source2.match(/\r\n|\n|\r/)?.[0] ?? "\n";
36876
36959
  const retained = [];
36877
36960
  let rootSection = true;
36878
36961
  let removingSection = false;
36879
36962
  let permissionsPosition;
36880
36963
  let statement = "";
36881
- for (const line of source.match(/[^\r\n]*(?:\r\n|\n|\r|$)/g) ?? []) {
36964
+ for (const line of source2.match(/[^\r\n]*(?:\r\n|\n|\r|$)/g) ?? []) {
36882
36965
  if (!line) continue;
36883
36966
  statement += line;
36884
36967
  let parsed;
@@ -36935,8 +37018,8 @@ function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp",
36935
37018
  parse(output);
36936
37019
  return output;
36937
37020
  }
36938
- function approvalConfiguration(source, managerPath, codexHome) {
36939
- const config = parse(source);
37021
+ function approvalConfiguration(source2, managerPath, codexHome) {
37022
+ const config = parse(source2);
36940
37023
  const expected = managedMcpApprovals(config, { manager: managerPath, codexHome });
36941
37024
  const changes = [];
36942
37025
  const changed = (before, after, path32 = []) => {
@@ -36946,8 +37029,8 @@ function approvalConfiguration(source, managerPath, codexHome) {
36946
37029
  }
36947
37030
  };
36948
37031
  changed(config, expected);
36949
- if (!changes.length) return source;
36950
- let output = source;
37032
+ if (!changes.length) return source2;
37033
+ let output = source2;
36951
37034
  for (const fullPath of changes) {
36952
37035
  const path32 = fullPath.slice(0, -1), key = fullPath.at(-1);
36953
37036
  const value = fullPath.reduce((item, key2) => item[key2], expected);
@@ -36986,7 +37069,7 @@ function approvalConfiguration(source, managerPath, codexHome) {
36986
37069
  close = original.indexOf("]", close + 1);
36987
37070
  }
36988
37071
  if (close < 0 || !Array.isArray(parsed)) throw new Error("Invalid environment array");
36989
- const missing = value.filter((name2) => !parsed.includes(name2));
37072
+ const missing = value.filter((name3) => !parsed.includes(name3));
36990
37073
  if (!missing.length) return section;
36991
37074
  let separator = "";
36992
37075
  if (parsed.length) try {
@@ -37096,12 +37179,12 @@ async function acquireSetupGate(storage) {
37096
37179
  init_context();
37097
37180
  var setupCapabilities = ["async-owned-commands-v1", "host-filesystem-v1", "shared-context-v1"];
37098
37181
  var windowsAgentsRevision = "b4f783d75c0543010c665072bf7aef07f74f973f";
37099
- async function moveMarketplaceCache(source, destination) {
37100
- const entry = await optionalStat(source);
37182
+ async function moveMarketplaceCache(source2, destination) {
37183
+ const entry = await optionalStat(source2);
37101
37184
  if (!entry) return false;
37102
- if (!entry.isDirectory() || await realpath5(source) !== source)
37103
- throw new Error(`marketplace cache is not a direct directory: ${source}`);
37104
- await rename3(source, destination);
37185
+ if (!entry.isDirectory() || await realpath5(source2) !== source2)
37186
+ throw new Error(`marketplace cache is not a direct directory: ${source2}`);
37187
+ await rename3(source2, destination);
37105
37188
  return true;
37106
37189
  }
37107
37190
  function installedPlugins(text) {
@@ -37113,10 +37196,10 @@ function installedPlugins(text) {
37113
37196
  async function verifyAgents(context) {
37114
37197
  const { codexHome, gestaltHome, marketplaceName } = context.paths;
37115
37198
  const plugins = installedPlugins(await context.run("codex", ["plugin", "list", "--marketplace", marketplaceName, "--json"], { capture: true }));
37116
- const version2 = (name2) => {
37117
- const value = plugins.find((plugin) => plugin?.name === name2 && plugin.installed !== false)?.version;
37199
+ const version2 = (name3) => {
37200
+ const value = plugins.find((plugin) => plugin?.name === name3 && plugin.installed !== false)?.version;
37118
37201
  if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9.+_-]*$/.test(value) || value.includes(".."))
37119
- throw new Error(`${name2} plugin is not installed after marketplace setup`);
37202
+ throw new Error(`${name3} plugin is not installed after marketplace setup`);
37120
37203
  return value;
37121
37204
  };
37122
37205
  const gestaltVersion = version2("gestalt"), contextVersion = version2("context-mode");
@@ -37147,7 +37230,7 @@ async function claimHomes(storages) {
37147
37230
  for (const release of releases.reverse()) await release();
37148
37231
  };
37149
37232
  }
37150
- async function setupAgents(context, _mode, extraSkills) {
37233
+ async function setupAgents(context, mode, extraSkills) {
37151
37234
  if (Number(process.versions.node.split(".")[0]) < 24) throw new Error(`Node.js 24 or newer is required; found ${process.versions.node}`);
37152
37235
  await context.require("npm");
37153
37236
  await context.require("codex");
@@ -37158,10 +37241,10 @@ async function setupAgents(context, _mode, extraSkills) {
37158
37241
  const cache = path10.join(codexHome, ".tmp/marketplaces", marketplaceName);
37159
37242
  let releaseGate = null;
37160
37243
  let stage2 = null, original = null, snapshotReady = false, preserve = false, retainLocks = false;
37161
- let registering = false, savedCache = null;
37244
+ let restoreCache = false, savedCache = null;
37162
37245
  const configFile = path10.join(codexHome, "config.toml");
37163
37246
  const normalize2 = async () => {
37164
- const before = await readProfile(configFile), source = before?.bytes.toString("utf8") ?? "";
37247
+ const before = await readProfile(configFile), source2 = before?.bytes.toString("utf8") ?? "";
37165
37248
  const { LOCALAPPDATA, XDG_CACHE_HOME, XDG_RUNTIME_DIR } = context.environment;
37166
37249
  const windows = process.platform === "win32";
37167
37250
  const localAppData = LOCALAPPDATA || path10.join(userHome, "AppData/Local");
@@ -37175,8 +37258,8 @@ async function setupAgents(context, _mode, extraSkills) {
37175
37258
  const cacheRoots = [cacheDir];
37176
37259
  if (!windows && XDG_RUNTIME_DIR && path10.isAbsolute(XDG_RUNTIME_DIR))
37177
37260
  cacheRoots.push(path10.join(XDG_RUNTIME_DIR, "ccache-tmp"));
37178
- const readRoots = [.../* @__PURE__ */ new Set([codexHome, gestaltHome, ...[".agents", ".local", ".config"].map((name2) => path10.join(userHome, name2))])];
37179
- const output = permissionConfiguration(approvalConfiguration(source, manager, codexHome), readRoots, temporaryRoot, cacheRoots);
37261
+ const readRoots = [.../* @__PURE__ */ new Set([codexHome, gestaltHome, ...[".agents", ".local", ".config"].map((name3) => path10.join(userHome, name3))])];
37262
+ const output = permissionConfiguration(approvalConfiguration(source2, manager, codexHome), readRoots, temporaryRoot, cacheRoots);
37180
37263
  if (!readRoots.includes(cacheDir)) {
37181
37264
  await mkdir3(cacheDir, { recursive: true, mode: 448 }).catch((error) => {
37182
37265
  if (!["EACCES", "EPERM", "EROFS", "ENOTDIR", "EEXIST"].includes(error.code ?? "")) throw error;
@@ -37194,12 +37277,42 @@ async function setupAgents(context, _mode, extraSkills) {
37194
37277
  if (original) await codexStorage.replaceFile(path10.join(stage2, "config.toml"), original.bytes);
37195
37278
  snapshotReady = true;
37196
37279
  await normalize2();
37197
- await releaseGate();
37198
- releaseGate = null;
37199
37280
  const override = context.environment.GESTALT_AGENTS_SOURCE;
37200
37281
  const sourceRoot = override ? await realpath5(override) : cache;
37201
37282
  const setup = path10.join(sourceRoot, "gestalt-setup.mjs");
37202
- const marketplaces = original && parse(original.bytes.toString("utf8")).marketplaces;
37283
+ const config = await readProfile(configFile);
37284
+ const text = config.bytes.toString("utf8");
37285
+ const marketplaces = parse(text).marketplaces;
37286
+ const gitDir = path10.join(cache, ".git");
37287
+ const git = (args) => context.run("git", args, { capture: true, timeoutMs: 6e4 });
37288
+ const provenanceFile = path10.join(codexHome, ".gestalt-setup-provenance.json");
37289
+ const windowsRevision = process.platform === "win32" && !context.environment.GESTALT_MARKETPLACE ? windowsAgentsRevision : void 0;
37290
+ const pin = override ? null : await planAgentsPin({
37291
+ marketplace,
37292
+ marketplaceName,
37293
+ config: text,
37294
+ mode,
37295
+ git,
37296
+ readProvenance: async () => {
37297
+ const previous = await readProfile(provenanceFile);
37298
+ return previous?.bytes.toString("utf8");
37299
+ },
37300
+ installedGitDir: (await optionalStat(gitDir))?.isDirectory() ? gitDir : void 0,
37301
+ windowsRevision
37302
+ });
37303
+ if (pin?.changing && !pin.fresh) {
37304
+ if (await optionalStat(cache)) {
37305
+ if (await realpath5(cache) !== cache) throw new Error("Agents marketplace cache is redirected");
37306
+ const backup = path10.join(stage2, "previous-marketplace");
37307
+ await cp(cache, backup, { recursive: true, verbatimSymlinks: true, preserveTimestamps: true, mode: constants4.COPYFILE_FICLONE });
37308
+ savedCache = backup;
37309
+ }
37310
+ restoreCache = true;
37311
+ }
37312
+ if (pin && !pin.fresh)
37313
+ await replaceProfile(codexStorage, configFile, Buffer.from(setAgentsRef(text, pin.ref, isDeepStrictEqual)), config);
37314
+ await releaseGate();
37315
+ releaseGate = null;
37203
37316
  if (override) {
37204
37317
  await context.log(`add marketplace ${sourceRoot} in ${codexHome}`);
37205
37318
  await context.run("codex", ["plugin", "marketplace", "add", sourceRoot]);
@@ -37207,13 +37320,20 @@ async function setupAgents(context, _mode, extraSkills) {
37207
37320
  await context.log(`upgrade marketplace ${marketplaceName} in ${codexHome}`);
37208
37321
  await context.run("codex", ["plugin", "marketplace", "upgrade", marketplaceName]);
37209
37322
  } else {
37210
- const source = process.platform === "win32" && !context.environment.GESTALT_MARKETPLACE ? `${marketplace}@${windowsAgentsRevision}` : marketplace;
37323
+ const revision = pin?.ref ?? windowsRevision;
37324
+ const source2 = revision ? `${marketplace}@${revision}` : marketplace;
37211
37325
  const backup = path10.join(stage2, "previous-marketplace");
37212
37326
  if (await moveMarketplaceCache(cache, backup)) savedCache = backup;
37213
- registering = true;
37214
- await context.log(`add marketplace ${source} in ${codexHome}`);
37215
- await context.run("codex", ["plugin", "marketplace", "add", source]);
37216
- }
37327
+ restoreCache = true;
37328
+ await context.log(`add marketplace ${source2} in ${codexHome}`);
37329
+ await context.run("codex", ["plugin", "marketplace", "add", source2]);
37330
+ if (pin) await context.run("codex", ["plugin", "marketplace", "upgrade", marketplaceName]);
37331
+ }
37332
+ if (pin) verifyAgentsPin(
37333
+ await readFile3(configFile, "utf8"),
37334
+ await git(["--git-dir", gitDir, "rev-parse", "--verify", "HEAD^{commit}"]),
37335
+ pin.ref
37336
+ );
37217
37337
  if (!(await optionalStat(setup))?.isFile() || await realpath5(setup) !== setup)
37218
37338
  throw new Error(`marketplace native Node setup is missing or redirected: ${setup}; update Gestalt Agents to a native-capable release`);
37219
37339
  const owner = path10.join(sourceRoot, "scripts/setup-agents.mjs");
@@ -37281,6 +37401,7 @@ async function setupAgents(context, _mode, extraSkills) {
37281
37401
  schemaVersion: 1,
37282
37402
  scope: "setup-artifacts-only",
37283
37403
  runtimeEnforcement: false,
37404
+ ...pin ? { managedAgentsRef: pin.ref } : {},
37284
37405
  manager: { version: context.version, sha256: digest(await readFile3(manager)) },
37285
37406
  delegatedSetupSha256: setupDigest,
37286
37407
  delegatedApi: { apiVersion: 1, capabilities: setupCapabilities, ownerSha256: ownerDigest, mode: "managed", ownership: "released" },
@@ -37321,7 +37442,7 @@ async function setupAgents(context, _mode, extraSkills) {
37321
37442
  const current = await readProfile(configFile);
37322
37443
  if (original) await replaceProfile(codexStorage, configFile, original.bytes, current);
37323
37444
  else if (current) await unlink3(configFile);
37324
- if (registering && stage2) {
37445
+ if (restoreCache && stage2) {
37325
37446
  await moveMarketplaceCache(cache, path10.join(stage2, "failed-marketplace"));
37326
37447
  if (savedCache) await rename3(savedCache, cache);
37327
37448
  }
@@ -37348,7 +37469,7 @@ init_paths();
37348
37469
  init_executables();
37349
37470
  init_context();
37350
37471
  import { randomUUID as randomUUID5 } from "node:crypto";
37351
- import { cp, readFile as readFile4, realpath as realpath6, rename as rename4, rm as rm2 } from "node:fs/promises";
37472
+ import { cp as cp2, readFile as readFile4, realpath as realpath6, rename as rename4, rm as rm2 } from "node:fs/promises";
37352
37473
  import path11 from "node:path";
37353
37474
  function mobileHostSupport(platform = process.platform) {
37354
37475
  if (platform === "linux" || platform === "darwin") return { supported: true, prerequisite: null };
@@ -37376,12 +37497,12 @@ async function installMobile(context, explicit = false) {
37376
37497
  if (!old.isDirectory() || old.isSymbolicLink()) throw new Error("Mobile package root must be a directory without links");
37377
37498
  await storage.assertPrivate(destination, "directory");
37378
37499
  const paths2 = new NativePaths();
37379
- await cp(destination, stage2, {
37500
+ await cp2(destination, stage2, {
37380
37501
  recursive: true,
37381
37502
  dereference: false,
37382
37503
  verbatimSymlinks: true,
37383
- filter: async (source) => {
37384
- await paths2.assertContained(destination, await realpath6(source));
37504
+ filter: async (source2) => {
37505
+ await paths2.assertContained(destination, await realpath6(source2));
37385
37506
  return true;
37386
37507
  }
37387
37508
  });
@@ -37576,7 +37697,7 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
37576
37697
  return info?.isFile() && info.nlink === 1 && (!process.getuid || info.uid === process.getuid()) ? info : null;
37577
37698
  };
37578
37699
  const owned = (server) => server && !server.url && typeof server.command === "string" && isAbsolute(server.command) && canonical(server.command) === executable && Array.isArray(server.args) && JSON.stringify(server.args) === '["xerj","mcp"]';
37579
- const related = (name2, server) => /xerj/i.test(name2) || server?.args?.[0] === "xerj";
37700
+ const related = (name3, server) => /xerj/i.test(name3) || server?.args?.[0] === "xerj";
37580
37701
  const stable = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
37581
37702
  function migrate(path32) {
37582
37703
  if (!exists(path32)) return;
@@ -37593,21 +37714,21 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
37593
37714
  notice("configuration");
37594
37715
  return;
37595
37716
  }
37596
- const names = Object.entries(config.mcp_servers ?? {}).filter(([name2, server]) => {
37717
+ const names = Object.entries(config.mcp_servers ?? {}).filter(([name3, server]) => {
37597
37718
  if (owned(server)) return true;
37598
- if (related(name2, server)) notice("configuration");
37719
+ if (related(name3, server)) notice("configuration");
37599
37720
  return false;
37600
- }).map(([name2]) => name2);
37721
+ }).map(([name3]) => name3);
37601
37722
  if (!names.length) return;
37602
37723
  const expected = structuredClone(config);
37603
- for (const name2 of names) delete expected.mcp_servers[name2];
37724
+ for (const name3 of names) delete expected.mcp_servers[name3];
37604
37725
  let removing = false;
37605
37726
  const output = bytes.split(/(?<=\n)/).filter((line) => {
37606
37727
  if (/^[ \t]*\[/.test(line)) {
37607
37728
  removing = false;
37608
37729
  try {
37609
37730
  const table = parse(line + "\n__gestalt_retirement_marker = true\n");
37610
- removing = names.some((name2) => table.mcp_servers?.[name2]);
37731
+ removing = names.some((name3) => table.mcp_servers?.[name3]);
37611
37732
  } catch {
37612
37733
  }
37613
37734
  }
@@ -37647,15 +37768,15 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
37647
37768
  }
37648
37769
  }
37649
37770
  if (codex) {
37650
- for (const name2 of readdirSync(codex).sort())
37651
- if (name2 === "config.toml" || /^[a-zA-Z0-9_-]+\.config\.toml$/.test(name2)) migrate(join2(codex, name2));
37771
+ for (const name3 of readdirSync(codex).sort())
37772
+ if (name3 === "config.toml" || /^[a-zA-Z0-9_-]+\.config\.toml$/.test(name3)) migrate(join2(codex, name3));
37652
37773
  if (exists(join2(codex, "xerj-data", ".lifecycle"))) notice("process records");
37653
37774
  }
37654
37775
  if (home && exists(join2(home, "run"))) {
37655
37776
  const run = join2(home, "run");
37656
37777
  if (!exists(run).isDirectory()) notice("restart descriptors");
37657
- else for (const name2 of readdirSync(run)) if (/^mobile-[1-9][0-9]*\.restart$/.test(name2)) {
37658
- const file = join2(run, name2);
37778
+ else for (const name3 of readdirSync(run)) if (/^mobile-[1-9][0-9]*\.restart$/.test(name3)) {
37779
+ const file = join2(run, name3);
37659
37780
  if (!plain(file)) {
37660
37781
  notice("restart descriptors");
37661
37782
  continue;
@@ -37818,9 +37939,9 @@ async function json(file) {
37818
37939
  if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.size > 1024 * 1024) throw new Error(`invalid metadata file: ${file}`);
37819
37940
  return JSON.parse(await readFile8(file, "utf8"));
37820
37941
  }
37821
- function pluginVersion(inventory, name2) {
37942
+ function pluginVersion(inventory, name3) {
37822
37943
  const installed2 = Array.isArray(inventory) ? inventory : inventory?.installed;
37823
- const entry = installed2?.find((entry2) => entry2?.name === name2 && entry2.installed !== false);
37944
+ const entry = installed2?.find((entry2) => entry2?.name === name3 && entry2.installed !== false);
37824
37945
  return typeof entry?.version === "string" && entry.version.length > 0 && entry.version.length < 256 && !/[\x00-\x1f\x7f\\/]/.test(entry.version) && entry.version !== "." && entry.version !== ".." ? entry.version : null;
37825
37946
  }
37826
37947
  var DiagnosticContext = class {
@@ -37840,8 +37961,8 @@ var DiagnosticContext = class {
37840
37961
  await this.streams.stdout(Buffer.from(label.padEnd(24) + value + "\n"));
37841
37962
  }
37842
37963
  /** Reject unsupported shims before asking the command owner to launch a probe. */
37843
- async probeTarget(name2) {
37844
- const executable = await this.commands.resolve(name2);
37964
+ async probeTarget(name3) {
37965
+ const executable = await this.commands.resolve(name3);
37845
37966
  if (!executable) return null;
37846
37967
  try {
37847
37968
  return await commandTarget(executable);
@@ -37849,9 +37970,9 @@ var DiagnosticContext = class {
37849
37970
  return null;
37850
37971
  }
37851
37972
  }
37852
- async query(name2, argv) {
37973
+ async query(name3, argv) {
37853
37974
  if (!this.commandQueries) return null;
37854
- const target = await this.probeTarget(name2);
37975
+ const target = await this.probeTarget(name3);
37855
37976
  if (!target) return null;
37856
37977
  try {
37857
37978
  const result = await this.commands.capture(target.executable, [...target.prefix, ...argv]);
@@ -37874,13 +37995,13 @@ var DiagnosticContext = class {
37874
37995
  } catch {
37875
37996
  }
37876
37997
  const installed2 = [];
37877
- for (const name2 of ["gestalt", "context-mode"]) {
37878
- const version2 = pluginVersion([{ name: name2, version: this.invocation.environment[name2 === "gestalt" ? "GESTALT_AGENTS_VERSION" : "GESTALT_CONTEXT_MODE_VERSION"] || prepared?.packageVersion }], name2);
37998
+ for (const name3 of ["gestalt", "context-mode"]) {
37999
+ const version2 = pluginVersion([{ name: name3, version: this.invocation.environment[name3 === "gestalt" ? "GESTALT_AGENTS_VERSION" : "GESTALT_CONTEXT_MODE_VERSION"] || prepared?.packageVersion }], name3);
37879
38000
  if (!version2) continue;
37880
- const override = this.invocation.environment[name2 === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT"];
38001
+ const override = this.invocation.environment[name3 === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT"];
37881
38002
  try {
37882
- const manifest = await json(path18.join(override || path18.join(this.paths.codexHome, "plugins/cache", this.paths.marketplaceName, name2, version2), ".codex-plugin/plugin.json"));
37883
- if (manifest.name === name2 && manifest.version === version2) installed2.push({ name: name2, version: version2, enabled: config?.plugins?.[name2 + "@" + this.paths.marketplaceName]?.enabled !== false });
38003
+ const manifest = await json(path18.join(override || path18.join(this.paths.codexHome, "plugins/cache", this.paths.marketplaceName, name3, version2), ".codex-plugin/plugin.json"));
38004
+ if (manifest.name === name3 && manifest.version === version2) installed2.push({ name: name3, version: version2, enabled: config?.plugins?.[name3 + "@" + this.paths.marketplaceName]?.enabled !== false });
37884
38005
  } catch {
37885
38006
  }
37886
38007
  }
@@ -37894,10 +38015,10 @@ var DiagnosticContext = class {
37894
38015
  return null;
37895
38016
  }
37896
38017
  }
37897
- async executableVersion(name2) {
37898
- const executable = await this.commands.resolve(name2);
38018
+ async executableVersion(name3) {
38019
+ const executable = await this.commands.resolve(name3);
37899
38020
  if (!executable) return null;
37900
- if (name2 === "npm" && process.platform === "win32" && path18.basename(executable).toLowerCase() === "npm.cmd") {
38021
+ if (name3 === "npm" && process.platform === "win32" && path18.basename(executable).toLowerCase() === "npm.cmd") {
37901
38022
  try {
37902
38023
  const root = path18.join(path18.dirname(executable), "node_modules/npm");
37903
38024
  const manifest = await json(path18.join(root, "package.json"));
@@ -37906,14 +38027,14 @@ var DiagnosticContext = class {
37906
38027
  } catch {
37907
38028
  }
37908
38029
  }
37909
- if (this.commandQueries) return this.query(name2, ["--version"]);
38030
+ if (this.commandQueries) return this.query(name3, ["--version"]);
37910
38031
  try {
37911
38032
  const target = await commandTarget(executable);
37912
38033
  let directory = path18.dirname(target.prefix[0] || executable);
37913
38034
  for (let depth = 0; depth < 7; depth++) {
37914
38035
  try {
37915
38036
  const manifest = await json(path18.join(directory, "package.json"));
37916
- if ((manifest.name === "@openai/codex" || manifest.name?.startsWith("@openai/codex-")) && name2 === "codex" && typeof manifest.version === "string" && /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(manifest.version))
38037
+ if ((manifest.name === "@openai/codex" || manifest.name?.startsWith("@openai/codex-")) && name3 === "codex" && typeof manifest.version === "string" && /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(manifest.version))
37917
38038
  return manifest.version + " (package metadata; command not run)";
37918
38039
  } catch {
37919
38040
  }
@@ -37925,10 +38046,10 @@ var DiagnosticContext = class {
37925
38046
  }
37926
38047
  return "PRESENT (version not probed)";
37927
38048
  }
37928
- async version(name2, inventory) {
37929
- const inherited = this.invocation.environment[name2 === "gestalt" ? "GESTALT_AGENTS_VERSION" : "GESTALT_CONTEXT_MODE_VERSION"];
37930
- const value = inherited ? pluginVersion([{ name: name2, version: inherited }], name2) : pluginVersion(inventory ?? await this.inventory(), name2);
37931
- if (!value) throw new Error(`cannot resolve the installed ${name2} plugin version; codex or a session version is required`);
38049
+ async version(name3, inventory) {
38050
+ const inherited = this.invocation.environment[name3 === "gestalt" ? "GESTALT_AGENTS_VERSION" : "GESTALT_CONTEXT_MODE_VERSION"];
38051
+ const value = inherited ? pluginVersion([{ name: name3, version: inherited }], name3) : pluginVersion(inventory ?? await this.inventory(), name3);
38052
+ if (!value) throw new Error(`cannot resolve the installed ${name3} plugin version; codex or a session version is required`);
37932
38053
  return value;
37933
38054
  }
37934
38055
  async runtime(version2) {
@@ -37944,7 +38065,7 @@ var DiagnosticContext = class {
37944
38065
  mobile() {
37945
38066
  return this.invocation.environment.GESTALT_MOBILE_BIN || path18.join(this.paths.gestaltHome, "mobile/node_modules/.bin", process.platform === "win32" ? "gestalt-mobile.cmd" : "gestalt-mobile");
37946
38067
  }
37947
- async managedPath(name2) {
38068
+ async managedPath(name3) {
37948
38069
  const p = this.paths, env = this.invocation.environment;
37949
38070
  const fixed = {
37950
38071
  bin: path18.join(p.gestaltHome, "bin"),
@@ -37954,13 +38075,13 @@ var DiagnosticContext = class {
37954
38075
  "codex-home": p.codexHome,
37955
38076
  "gestalt-home": p.gestaltHome
37956
38077
  };
37957
- if (Object.hasOwn(fixed, name2)) return fixed[name2];
37958
- if (name2 === "context-mode" || name2 === "context-mode-runtime") return this.runtime();
37959
- if (name2 === "context-mode-plugin" || name2 === "gestalt-plugin") {
37960
- const plugin = name2 === "gestalt-plugin" ? "gestalt" : "context-mode", key = plugin === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT";
38078
+ if (Object.hasOwn(fixed, name3)) return fixed[name3];
38079
+ if (name3 === "context-mode" || name3 === "context-mode-runtime") return this.runtime();
38080
+ if (name3 === "context-mode-plugin" || name3 === "gestalt-plugin") {
38081
+ const plugin = name3 === "gestalt-plugin" ? "gestalt" : "context-mode", key = plugin === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT";
37961
38082
  return env[key] || path18.join(p.codexHome, "plugins/cache", p.marketplaceName, plugin, await this.version(plugin));
37962
38083
  }
37963
- throw new Error(`unknown managed path: ${name2} (expected bin, org-plan, context-mode-cli, mobile, context-mode, context-mode-plugin, gestalt-plugin, codex-home, or gestalt-home)`);
38084
+ throw new Error(`unknown managed path: ${name3} (expected bin, org-plan, context-mode-cli, mobile, context-mode, context-mode-plugin, gestalt-plugin, codex-home, or gestalt-home)`);
37964
38085
  }
37965
38086
  };
37966
38087
  async function verifyContextRuntime(context) {
@@ -37990,14 +38111,14 @@ async function version(context, metadata) {
37990
38111
  if (mobile !== null) await context.print("Gestalt Mobile", mobile);
37991
38112
  }
37992
38113
  const inventory = await context.inventory();
37993
- for (const [name2, label] of [["gestalt", "Gestalt Agents"], ["context-mode", "Context Mode"]]) {
37994
- const value = pluginVersion(inventory, name2);
38114
+ for (const [name3, label] of [["gestalt", "Gestalt Agents"], ["context-mode", "Context Mode"]]) {
38115
+ const value = pluginVersion(inventory, name3);
37995
38116
  if (value) await context.print(label, value);
37996
38117
  }
37997
38118
  const skillsContext = new SetupContext(context.invocation, context.streams, context.paths, metadata.version);
37998
38119
  await manageSkills(skillsContext, "status", "version");
37999
- for (const [name2, label] of [["codex", "Codex CLI"], ["kimi", "Kimi CLI"]]) {
38000
- const value = await context.executableVersion(name2);
38120
+ for (const [name3, label] of [["codex", "Codex CLI"], ["kimi", "Kimi CLI"]]) {
38121
+ const value = await context.executableVersion(name3);
38001
38122
  if (value !== null) await context.print(label, value);
38002
38123
  }
38003
38124
  if (process.platform === "win32") {
@@ -38008,7 +38129,7 @@ async function version(context, metadata) {
38008
38129
  let serena;
38009
38130
  try {
38010
38131
  const descriptor = await json(path18.join(context.paths.gestaltHome, "serena/active.json"));
38011
- if (descriptor.schemaVersion !== 1 || descriptor.contractVersion !== 1 && descriptor.version !== "1.7.0" || !/^\d+\.\d+\.\d+$/.test(descriptor.version) || !Array.isArray(descriptor.tools) || !["find_symbol", "get_symbols_overview", "replace_symbol_body"].every((name2) => descriptor.tools.some((tool) => tool.name === name2 && tool.inputSchema))) throw new Error("invalid Serena installation");
38132
+ if (descriptor.schemaVersion !== 1 || descriptor.contractVersion !== 1 && descriptor.version !== "1.7.0" || !/^\d+\.\d+\.\d+$/.test(descriptor.version) || !Array.isArray(descriptor.tools) || !["find_symbol", "get_symbols_overview", "replace_symbol_body"].every((name3) => descriptor.tools.some((tool) => tool.name === name3 && tool.inputSchema))) throw new Error("invalid Serena installation");
38012
38133
  const py = await context.query(descriptor.python, ["-I", "-B", "-c", 'import importlib.metadata,json,sys;print(json.dumps({"serena":importlib.metadata.version("serena-agent"),"python":".".join(map(str,sys.version_info[:3]))}))']);
38013
38134
  const uv = await context.query(descriptor.uv, ["--version"]), value = JSON.parse(py ?? "null"), match = uv?.match(/^uv (\d+\.\d+\.\d+)(?:[ (]|$)/);
38014
38135
  if (value?.serena === descriptor.version && /^3\.13\.\d+$/.test(value.python) && match) serena = { serena: value.serena, python: value.python, uv: match[1] };
@@ -38063,7 +38184,7 @@ function supervisionCompatibility(agents, mobile) {
38063
38184
  if (!manifest || manifest.schemaVersion !== 1 || manifest.component !== component2 || manifest.supervisionContract !== 1 || !Array.isArray(manifest.capabilities) || manifest.capabilities.some((value) => typeof value !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) || capabilities.some((value) => !manifest.capabilities.includes(value))) return { ready: false, message: `INCOMPATIBLE (${component2} capability manifest; update both packages, then restart Mobile)`, model: "NOT VERIFIED" };
38064
38185
  }
38065
38186
  const a = agents.modelPolicyContract, m = mobile.modelPolicyContract;
38066
- if (!a && !m && !agents.capabilities.some((name2) => name2.startsWith("l1-model-policy-")) && !mobile.capabilities.some((name2) => name2.startsWith("l1-model-policy-")))
38187
+ if (!a && !m && !agents.capabilities.some((name3) => name3.startsWith("l1-model-policy-")) && !mobile.capabilities.some((name3) => name3.startsWith("l1-model-policy-")))
38067
38188
  return { ready: true, message: "ready (v1; offline manifests)", model: "LEGACY (base supervision only)" };
38068
38189
  const declared = [agents, mobile].every((value) => value.capabilities.includes("l1-model-policy-v1") && value.capabilities.includes("l2-report-boundary") && value.modelPolicyContract?.version === 1 && value.modelPolicyContract.runtimeEnforcement === false);
38069
38190
  if (declared && a.scope === "configured-launch-and-retention" && m.scope === a.scope && a.defaultAssurance === "configured" && m.defaultAssurance === "configured" && a.strictAttestation === false && m.strictAttestation === false)
@@ -38099,9 +38220,9 @@ async function doctor(context, argv, metadata) {
38099
38220
  await context.print("Agents marketplace", setup?.isFile() ? "present" : "MISSING");
38100
38221
  if (!setup?.isFile()) failed = true;
38101
38222
  const inventory = await context.inventory();
38102
- for (const name2 of ["gestalt", "context-mode"]) {
38103
- const value = pluginVersion(inventory, name2);
38104
- await context.print(name2 === "gestalt" ? "Gestalt plugins" : "Context-mode plugin", value ?? "NOT VERIFIED");
38223
+ for (const name3 of ["gestalt", "context-mode"]) {
38224
+ const value = pluginVersion(inventory, name3);
38225
+ await context.print(name3 === "gestalt" ? "Gestalt plugins" : "Context-mode plugin", value ?? "NOT VERIFIED");
38105
38226
  if (!value) failed = true;
38106
38227
  }
38107
38228
  let runtime;
@@ -38141,10 +38262,10 @@ async function doctor(context, argv, metadata) {
38141
38262
  try {
38142
38263
  const config = parse(await readFile8(path18.join(context.paths.codexHome, "config.toml"), "utf8"));
38143
38264
  const removed = /* @__PURE__ */ new Set(["GESTALT_SESSION_TMP_CONTEXT", "TMPDIR", "TMP", "TEMP"]);
38144
- for (const [name2, server] of Object.entries(config.mcp_servers ?? {})) {
38145
- if (!isGestaltManagedMcp(name2, server, { manager: context.paths.manager, codexHome: context.paths.codexHome })) continue;
38265
+ for (const [name3, server] of Object.entries(config.mcp_servers ?? {})) {
38266
+ if (!isGestaltManagedMcp(name3, server, { manager: context.paths.manager, codexHome: context.paths.codexHome })) continue;
38146
38267
  const names = server.env_vars ?? [], retained = names.filter((key) => !removed.has(key) || Object.hasOwn(context.invocation.environment, key));
38147
- if (retained.length !== names.length) args.push("-c", "mcp_servers." + name2 + ".env_vars=" + JSON.stringify(retained));
38268
+ if (retained.length !== names.length) args.push("-c", "mcp_servers." + name3 + ".env_vars=" + JSON.stringify(retained));
38148
38269
  }
38149
38270
  } catch {
38150
38271
  }
@@ -38173,9 +38294,9 @@ async function doctor(context, argv, metadata) {
38173
38294
  if (probe && !sandbox.ready) failed = true;
38174
38295
  if (sandbox.diagnostic) await context.streams.stdout(Buffer.from(sandbox.diagnostic + "\n"));
38175
38296
  if (sandbox.retained) await context.print("Retained probe state", sandbox.retained);
38176
- for (const [name2, label] of [["serena", "Serena"], ["playwright", "Playwright"]]) {
38177
- const present = await optionalStat(path18.join(context.paths.gestaltHome, name2, "active.json"));
38178
- await context.print(label, process.platform === "win32" ? "DEFERRED (native optional feature; retained metadata is not readiness)" : present ? "INSTALLED; native component readiness requires its component doctor" : `NOT INSTALLED (optional; gestalt ${name2} install)`);
38297
+ for (const [name3, label] of [["serena", "Serena"], ["playwright", "Playwright"]]) {
38298
+ const present = await optionalStat(path18.join(context.paths.gestaltHome, name3, "active.json"));
38299
+ await context.print(label, process.platform === "win32" ? "DEFERRED (native optional feature; retained metadata is not readiness)" : present ? "INSTALLED; native component readiness requires its component doctor" : `NOT INSTALLED (optional; gestalt ${name3} install)`);
38179
38300
  if (present && process.platform !== "win32") failed = true;
38180
38301
  }
38181
38302
  if (failed) await context.streams.stderr(Buffer.from("\nDiagnostics reported a problem; follow the failing check's guidance above. Use 'gestalt install' or 'gestalt update' only for missing or incompatible managed components.\n"));
@@ -38215,18 +38336,18 @@ function parseUpdateOptions(argv) {
38215
38336
  }
38216
38337
  if (token === "--help" || token === "-h") return { component: component2, extra, help: true };
38217
38338
  if (token === "--component") {
38218
- if (!argv[index + 1]) throw new Error("--component requires all, gestalt, serena, or playwright");
38339
+ if (!argv[index + 1]) throw new Error("--component requires all, gestalt, mobile, serena, or playwright");
38219
38340
  if (selected) throw new Error("select only one update component");
38220
38341
  component2 = argv[++index];
38221
38342
  selected = true;
38222
- } else if (["all", "gestalt", "serena", "playwright"].includes(token)) {
38343
+ } else if (updateComponents.some((name3) => name3 === token)) {
38223
38344
  if (selected) throw new Error("select only one update component");
38224
38345
  component2 = token;
38225
38346
  selected = true;
38226
38347
  } else throw new Error(`unknown update option or component: ${token} (run 'gestalt update --help')`);
38227
38348
  }
38228
38349
  if (component2 === "xerj") throw new Error(retirement);
38229
- if (!["all", "gestalt", "serena", "playwright"].includes(component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, serena, or playwright)`);
38350
+ if (!updateComponents.some((name3) => name3 === component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, mobile, serena, or playwright)`);
38230
38351
  if (extra && !["all", "gestalt"].includes(component2)) throw new Error("--extra-skills requires the all or gestalt update component");
38231
38352
  return { component: component2, extra, help: false };
38232
38353
  }
@@ -38308,6 +38429,12 @@ async function runInstall(context, extra, operations = defaults, platform = proc
38308
38429
  }
38309
38430
  async function runUpdate(context, options, originalArgv, resumed, operations = defaults, platform = process.platform) {
38310
38431
  requireSelection(options.component, platform);
38432
+ if (options.component === "mobile") {
38433
+ await operations.mobile(context);
38434
+ await context.log("update complete (mobile)");
38435
+ context.check();
38436
+ return false;
38437
+ }
38311
38438
  if (options.component === "all" || options.component === "gestalt") {
38312
38439
  if (await operations.manager(context, originalArgv, resumed)) return true;
38313
38440
  await context.prepareHomes();
@@ -38440,11 +38567,11 @@ init_skills_owner();
38440
38567
  // src/cli/runtime/skills-transfer.ts
38441
38568
  import path21 from "node:path";
38442
38569
  import { randomUUID as randomUUID8 } from "node:crypto";
38443
- import { cp as cp2, link, lstat as lstat11, mkdir as mkdir6, readFile as readFile9, readdir as readdir2, realpath as realpath9, rename as rename6, rm as rm5, symlink, unlink as unlink5, writeFile as writeFile3 } from "node:fs/promises";
38570
+ import { cp as cp3, link, lstat as lstat11, mkdir as mkdir6, readFile as readFile9, readdir as readdir2, realpath as realpath9, rename as rename6, rm as rm5, symlink, unlink as unlink5, writeFile as writeFile3 } from "node:fs/promises";
38444
38571
 
38445
38572
  // src/cli/platform/archive.ts
38446
38573
  init_windows_system();
38447
- import { constants as constants4 } from "node:fs";
38574
+ import { constants as constants5 } from "node:fs";
38448
38575
  import { lstat as lstat10, open as open4, readdir, mkdir as mkdir5, realpath as realpath8, writeFile as writeFile2 } from "node:fs/promises";
38449
38576
  import path20 from "node:path";
38450
38577
  import { gunzipSync, gzipSync } from "node:zlib";
@@ -38452,7 +38579,7 @@ var maximumArchive = 64 * 1024 * 1024;
38452
38579
  var maximumPayload = 256 * 1024 * 1024;
38453
38580
  var maximumMembers = 1e4;
38454
38581
  var privateFileMode = (mode) => 384 | mode & 64;
38455
- function name(value) {
38582
+ function name2(value) {
38456
38583
  const normalized = value.replace(/\/$/, "");
38457
38584
  if (!normalized || Buffer.byteLength(normalized) > 4096 || /[\\\x00-\x1f\x7f:]/.test(normalized) || normalized.split("/").some((part) => !part || part === "." || part === ".." || /[. ]$/.test(part) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part))) throw new Error("Unsafe archive member path");
38458
38585
  return normalized;
@@ -38512,7 +38639,7 @@ function parse2(bytes) {
38512
38639
  offset += Math.ceil(storedSize / 512) * 512;
38513
38640
  continue;
38514
38641
  }
38515
- const prefix = field(header2, 345, 155), member = name(nextPath ?? (prefix ? prefix + "/" : "") + field(header2, 0, 100));
38642
+ const prefix = field(header2, 345, 155), member = name2(nextPath ?? (prefix ? prefix + "/" : "") + field(header2, 0, 100));
38516
38643
  const size = nextSize ?? storedSize;
38517
38644
  nextPath = void 0;
38518
38645
  nextSize = void 0;
@@ -38535,7 +38662,7 @@ function parse2(bytes) {
38535
38662
  async function readArchive(file) {
38536
38663
  const info = await lstat10(file);
38537
38664
  if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.size > maximumArchive) throw new Error("Archive must be an ordinary bounded file");
38538
- const handle = await open4(file, constants4.O_RDONLY | (constants4.O_NOFOLLOW || 0));
38665
+ const handle = await open4(file, constants5.O_RDONLY | (constants5.O_NOFOLLOW || 0));
38539
38666
  try {
38540
38667
  const actual = await handle.stat();
38541
38668
  if (actual.dev !== info.dev || actual.ino !== info.ino || actual.size !== info.size) throw new Error("Archive identity changed");
@@ -38557,7 +38684,7 @@ var NativeArchives = class {
38557
38684
  return (await readArchive(archive)).map(({ path: path32, kind }) => ({ path: path32, kind }));
38558
38685
  }
38559
38686
  async extract(archive, stagingDirectory, expectedRoot) {
38560
- const entries = await readArchive(archive), root = name(expectedRoot);
38687
+ const entries = await readArchive(archive), root = name2(expectedRoot);
38561
38688
  if (root.includes("/") || entries.some((entry) => entry.path !== root && !entry.path.startsWith(root + "/")))
38562
38689
  throw new Error("Unexpected archive root");
38563
38690
  const directory = await realpath8(stagingDirectory), info = await lstat10(stagingDirectory);
@@ -38594,7 +38721,7 @@ var NativeArchives = class {
38594
38721
  header2.write(text + "\0", offset, length, "ascii");
38595
38722
  };
38596
38723
  const visit = async (file, relative) => {
38597
- const member = name(relative), info = await lstat10(file);
38724
+ const member = name2(relative), info = await lstat10(file);
38598
38725
  if (info.isSymbolicLink() || !info.isDirectory() && !info.isFile() || info.isFile() && info.nlink !== 1) throw new Error("Archive source contains a link or special file");
38599
38726
  if (++count > maximumMembers || (total += info.isFile() ? info.size : 0) > maximumPayload / 2) throw new Error("Archive source exceeds supported size");
38600
38727
  const header2 = Buffer.alloc(512);
@@ -38620,7 +38747,7 @@ var NativeArchives = class {
38620
38747
  number(header2, 148, 8, header2.reduce((sum, byte) => sum + byte, 0));
38621
38748
  entries.push(header2);
38622
38749
  if (info.isFile()) {
38623
- const handle = await open4(file, constants4.O_RDONLY | (constants4.O_NOFOLLOW || 0));
38750
+ const handle = await open4(file, constants5.O_RDONLY | (constants5.O_NOFOLLOW || 0));
38624
38751
  try {
38625
38752
  const actual = await handle.stat();
38626
38753
  if (actual.ino !== info.ino || actual.dev !== info.dev || actual.size !== info.size) throw new Error("Archive source changed");
@@ -38665,9 +38792,9 @@ async function ordinaryTree(root) {
38665
38792
  if (/[\x00-\x1f\x7f]/.test(root)) throw new Error("skill archive path contains control characters");
38666
38793
  if (info.isDirectory()) for (const entry of await readdir2(root)) await ordinaryTree(path21.join(root, entry));
38667
38794
  }
38668
- async function copyTree(source, destination) {
38669
- await ordinaryTree(source);
38670
- await cp2(source, destination, {
38795
+ async function copyTree(source2, destination) {
38796
+ await ordinaryTree(source2);
38797
+ await cp3(source2, destination, {
38671
38798
  recursive: true,
38672
38799
  dereference: false,
38673
38800
  errorOnExist: false,
@@ -38708,15 +38835,15 @@ async function exportSkills(context, argv) {
38708
38835
  await mkdir6(bundle, { mode: 448 });
38709
38836
  for (let index = 0; index < categories.length; index++) {
38710
38837
  context.check();
38711
- const source = destinations[index], destination = path21.join(bundle, categories[index]);
38838
+ const source2 = destinations[index], destination = path21.join(bundle, categories[index]);
38712
38839
  await mkdir6(destination, { mode: 448 });
38713
- const info = await optionalStat(source);
38840
+ const info = await optionalStat(source2);
38714
38841
  if (!info) continue;
38715
- if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`skill root must be a directory without links: ${source}`);
38716
- for (const entry of (await readdir2(source)).sort()) {
38842
+ if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`skill root must be a directory without links: ${source2}`);
38843
+ for (const entry of (await readdir2(source2)).sort()) {
38717
38844
  context.check();
38718
38845
  if (entry === ".system") continue;
38719
- let file = path21.join(source, entry), materialized = false;
38846
+ let file = path21.join(source2, entry), materialized = false;
38720
38847
  const item = await lstat11(file);
38721
38848
  if (index === 3) {
38722
38849
  if (!/\.ya?ml$/.test(entry)) continue;
@@ -38782,22 +38909,22 @@ async function importSkills(context, argv) {
38782
38909
  const manifest = JSON.parse(await readFile9(manifestFile, "utf8"));
38783
38910
  if (manifest.format !== archiveRoot || manifest.version !== 1 || !manifest.sourceRoots || typeof manifest.sourceRoots !== "object") throw new Error("unsupported skills archive manifest");
38784
38911
  const destinations = roots(context), sources = categories.map((category) => path21.join(bundle, category));
38785
- const replacements = [manifest.sourceRoots.userSkillsRoot, manifest.sourceRoots.managedSkillsRoot, manifest.sourceRoots.codexSkillsRoot].map((source, index) => {
38786
- if (typeof source !== "string" || !path21.posix.isAbsolute(source) && !path21.win32.isAbsolute(source) || source === path21.posix.parse(source).root || source === path21.win32.parse(source).root || /[\x00-\x1f\x7f]/.test(source)) throw new Error("skills archive contains an invalid source root");
38787
- return [source, destinations[index]];
38912
+ const replacements = [manifest.sourceRoots.userSkillsRoot, manifest.sourceRoots.managedSkillsRoot, manifest.sourceRoots.codexSkillsRoot].map((source2, index) => {
38913
+ if (typeof source2 !== "string" || !path21.posix.isAbsolute(source2) && !path21.win32.isAbsolute(source2) || source2 === path21.posix.parse(source2).root || source2 === path21.win32.parse(source2).root || /[\x00-\x1f\x7f]/.test(source2)) throw new Error("skills archive contains an invalid source root");
38914
+ return [source2, destinations[index]];
38788
38915
  }).sort((a, b) => b[0].length - a[0].length);
38789
38916
  for (let index = 0; index < sources.length; index++) {
38790
- const source = sources[index];
38791
- await ordinaryTree(source);
38792
- for (const entry of await readdir2(source)) {
38793
- const file = path21.join(source, entry), info = await lstat11(file);
38917
+ const source2 = sources[index];
38918
+ await ordinaryTree(source2);
38919
+ for (const entry of await readdir2(source2)) {
38920
+ const file = path21.join(source2, entry), info = await lstat11(file);
38794
38921
  if (index === 3) {
38795
38922
  if (!profileName.test(entry) || !info.isFile()) throw new Error("invalid skill profile archive entry");
38796
38923
  } else if (!skillName.test(entry) || !info.isDirectory() || !(await optionalStat(path21.join(file, "SKILL.md")))?.isFile()) throw new Error("invalid skill in archive");
38797
38924
  }
38798
38925
  if (await optionalStat(destinations[index])) {
38799
38926
  await context.storage(destinations[index]);
38800
- for (const entry of await readdir2(source)) {
38927
+ for (const entry of await readdir2(source2)) {
38801
38928
  const target = path21.join(destinations[index], entry);
38802
38929
  if (await optionalStat(target)) await ordinaryTree(target);
38803
38930
  }
@@ -38805,9 +38932,9 @@ async function importSkills(context, argv) {
38805
38932
  }
38806
38933
  for (let index = 0; index < sources.length; index++) {
38807
38934
  context.check();
38808
- const destination = destinations[index], source = sources[index];
38935
+ const destination = destinations[index], source2 = sources[index];
38809
38936
  const storage = await context.storage(destination);
38810
- for (const entry of await readdir2(source)) {
38937
+ for (const entry of await readdir2(source2)) {
38811
38938
  context.check();
38812
38939
  const target = path21.join(destination, entry), original = Boolean(await optionalStat(target));
38813
38940
  const candidate = path21.join(destination, `.skills-import-${randomUUID8()}`);
@@ -38816,14 +38943,14 @@ async function importSkills(context, argv) {
38816
38943
  promotions.push(record2);
38817
38944
  await transaction.storage.replaceFile(path21.join(transaction.directory, "journal.json"), Buffer.from(JSON.stringify({ schemaVersion: 1, promotions }) + "\n"));
38818
38945
  if (index === 3) {
38819
- let text = await readFile9(path21.join(source, entry), "utf8");
38946
+ let text = await readFile9(path21.join(source2, entry), "utf8");
38820
38947
  for (const [from, to] of replacements) text = text.replaceAll(from, to);
38821
38948
  await storage.replaceFile(candidate, Buffer.from(text));
38822
38949
  profileCount++;
38823
38950
  } else {
38824
38951
  await storage.createDirectory(candidate);
38825
38952
  if (original) await copyTree(target, candidate);
38826
- await copyTree(path21.join(source, entry), candidate);
38953
+ await copyTree(path21.join(source2, entry), candidate);
38827
38954
  skillCount++;
38828
38955
  }
38829
38956
  context.check();
@@ -39402,8 +39529,8 @@ async function launchCapabilities(commands, invocation, manager) {
39402
39529
  process2.stderr.write(data);
39403
39530
  tail = (tail + data.toString()).slice(-8192);
39404
39531
  for (const diagnostic of tail.matchAll(/required MCP servers failed to initialize:([^\r\n]*)/g))
39405
- for (const name2 of ["gestalt-serena"])
39406
- if (new RegExp(`(?:^|[\\s,;])${name2}:`).test(diagnostic[1])) startupFailed.add(name2);
39532
+ for (const name3 of ["gestalt-serena"])
39533
+ if (new RegExp(`(?:^|[\\s,;])${name3}:`).test(diagnostic[1])) startupFailed.add(name3);
39407
39534
  });
39408
39535
  const result2 = await new Promise((resolve2) => {
39409
39536
  child.once("error", (error) => {
@@ -39502,8 +39629,8 @@ async function launchCapabilities(commands, invocation, manager) {
39502
39629
  const serenaSkill = state?.skills.find((entry) => entry.name === "gestalt:serena");
39503
39630
  const serenaReserved = servers[serenaName];
39504
39631
  const serenaConflict = serenaReserved && (serenaReserved.env && Object.keys(serenaReserved.env).length || serenaReserved.enabled === false || serenaReserved.enabled_tools || serenaReserved.disabled_tools?.length || Object.values(serenaReserved.tools ?? {}).some((tool) => tool.enabled !== void 0));
39505
- const serenaAliases = Object.entries(servers).filter(([name2, config]) => name2 !== serenaName && config.command === manager && config.args?.[0] === "serena" && config.args?.[1] === "mcp").map(([name2]) => name2);
39506
- const aliases = serenaAliases.length ? [`mcp_servers=${toml(Object.fromEntries(serenaAliases.map((name2) => [name2, { enabled: false }])))}`] : [];
39632
+ const serenaAliases = Object.entries(servers).filter(([name3, config]) => name3 !== serenaName && config.command === manager && config.args?.[0] === "serena" && config.args?.[1] === "mcp").map(([name3]) => name3);
39633
+ const aliases = serenaAliases.length ? [`mcp_servers=${toml(Object.fromEntries(serenaAliases.map((name3) => [name3, { enabled: false }])))}`] : [];
39507
39634
  const capabilities = [{
39508
39635
  name: serenaName,
39509
39636
  skillName: "gestalt:serena",
@@ -39586,8 +39713,8 @@ async function launchCapabilities(commands, invocation, manager) {
39586
39713
  if (error.code === "ENOENT") continue;
39587
39714
  throw error;
39588
39715
  }
39589
- for (const name2 of names.filter((name3) => name3.endsWith(".toml")).sort()) {
39590
- const path32 = resolve(folder, name2), text = await readFile10(path32, "utf8");
39716
+ for (const name3 of names.filter((name4) => name4.endsWith(".toml")).sort()) {
39717
+ const path32 = resolve(folder, name3), text = await readFile10(path32, "utf8");
39591
39718
  const role = parse(text);
39592
39719
  if (typeof role.name !== "string" || typeof role.developer_instructions !== "string") continue;
39593
39720
  let action = "append";
@@ -39670,8 +39797,8 @@ async function launchCapabilities(commands, invocation, manager) {
39670
39797
  return false;
39671
39798
  }
39672
39799
  };
39673
- const playwrightAliases = Object.entries(servers).filter(([name2, config]) => name2 !== playwrightName && config.command === manager && config.args?.[0] === "playwright" && config.args?.[1] === "mcp").map(([name2]) => name2);
39674
- if (playwrightAliases.length) aliases.push(`mcp_servers=${toml(Object.fromEntries(playwrightAliases.map((name2) => [name2, { enabled: false }])))}`);
39800
+ const playwrightAliases = Object.entries(servers).filter(([name3, config]) => name3 !== playwrightName && config.command === manager && config.args?.[0] === "playwright" && config.args?.[1] === "mcp").map(([name3]) => name3);
39801
+ if (playwrightAliases.length) aliases.push(`mcp_servers=${toml(Object.fromEntries(playwrightAliases.map((name3) => [name3, { enabled: false }])))}`);
39675
39802
  if (playwrightConsent) playwrightNotice("native-browser-component-required");
39676
39803
  const serenaRules = [...state?.config?.skills?.config ?? [], ...rules].filter((rule) => rule.name === "gestalt:serena" || rule.path === serenaSkill?.path);
39677
39804
  if (common && serenaSkill && serenaSkill.enabled !== false && serenaRules.at(-1)?.enabled !== false)
@@ -39683,14 +39810,14 @@ async function launchCapabilities(commands, invocation, manager) {
39683
39810
  expectedHookCount = 0;
39684
39811
  const approved = managedMcpApprovals(state?.config ?? {}, { manager, codexHome: environment.CODEX_HOME });
39685
39812
  const approvalFlags = [];
39686
- for (const [name2, server] of Object.entries(approved.mcp_servers ?? {})) if (isGestaltManagedMcp(name2, server, { manager, codexHome: environment.CODEX_HOME })) {
39687
- approvalFlags.push(`mcp_servers.${name2}=${toml(server)}`);
39813
+ for (const [name3, server] of Object.entries(approved.mcp_servers ?? {})) if (isGestaltManagedMcp(name3, server, { manager, codexHome: environment.CODEX_HOME })) {
39814
+ approvalFlags.push(`mcp_servers.${name3}=${toml(server)}`);
39688
39815
  }
39689
- for (const [name2, plugin] of Object.entries(approved.plugins ?? {})) if (name2 === "context-mode@dyne-gestalt-agents") {
39816
+ for (const [name3, plugin] of Object.entries(approved.plugins ?? {})) if (name3 === "context-mode@dyne-gestalt-agents") {
39690
39817
  for (const [server, options] of Object.entries(plugin.mcp_servers ?? {})) if (server === "context-mode") {
39691
- approvalFlags.push(`plugins.${name2}.mcp_servers.${server}.default_tools_approval_mode="approve"`);
39818
+ approvalFlags.push(`plugins.${name3}.mcp_servers.${server}.default_tools_approval_mode="approve"`);
39692
39819
  for (const [tool, setting] of Object.entries(options.tools ?? {})) if (setting?.approval_mode === "approve")
39693
- approvalFlags.push(`plugins.${name2}.mcp_servers.${server}.tools.${tool}.approval_mode="approve"`);
39820
+ approvalFlags.push(`plugins.${name3}.mcp_servers.${server}.tools.${tool}.approval_mode="approve"`);
39694
39821
  }
39695
39822
  }
39696
39823
  const selectors = [
@@ -39828,9 +39955,9 @@ function cliHandler(owned = false, port, terminal) {
39828
39955
  }
39829
39956
 
39830
39957
  // src/cli/runtime/index.ts
39831
- function deferredTool(name2) {
39958
+ function deferredTool(name3) {
39832
39959
  return async (_invocation, streams) => {
39833
- await streams.stderr(Buffer.from(`gestalt: native ${name2} support is deferred in this core release; use an existing supported Unix Gestalt installation for ${name2}. Gestalt CLI and Agents remain available. No profile or installation was changed.
39960
+ await streams.stderr(Buffer.from(`gestalt: native ${name3} support is deferred in this core release; use an existing supported Unix Gestalt installation for ${name3}. Gestalt CLI and Agents remain available. No profile or installation was changed.
39834
39961
  `));
39835
39962
  return 1;
39836
39963
  };
@@ -39860,7 +39987,7 @@ function createRuntimeHandlers(metadata, terminal, ownershipHelper) {
39860
39987
 
39861
39988
  // src/cli/platform/interactive.ts
39862
39989
  init_processes();
39863
- import { constants as constants5, accessSync, statSync as statSync2 } from "node:fs";
39990
+ import { constants as constants6, accessSync, statSync as statSync2 } from "node:fs";
39864
39991
  import path25 from "node:path";
39865
39992
  function interactiveBackendFor(platform) {
39866
39993
  if (platform === "win32") return "windows-owned";
@@ -39879,7 +40006,7 @@ function selectInteractiveRuntime(artifacts) {
39879
40006
  if (typeof process.execve !== "function") throw new Error("This Node runtime lacks Unix process replacement; use the existing Unix Gestalt entry");
39880
40007
  if (!path25.isAbsolute(invocation.cwd)) throw new Error("Unix compatibility cwd must be absolute");
39881
40008
  if (!statSync2(manager).isFile()) throw new Error("Unix compatibility manager must be a regular executable file");
39882
- accessSync(manager, constants5.X_OK);
40009
+ accessSync(manager, constants6.X_OK);
39883
40010
  const environment = {};
39884
40011
  for (const [key, value] of Object.entries(invocation.environment)) if (value !== void 0) environment[key] = value;
39885
40012
  const previous = process.cwd();
@@ -39905,7 +40032,7 @@ function packagedWindowsHelper() {
39905
40032
  async function continueUpdatedManager(invocation, streams, options) {
39906
40033
  if (options.commands?.apiVersion !== 1 || typeof options.commands.launch !== "function" || !options.signal || invocation.argv[0] !== "__updated-manager") throw new Error("invalid managed updated-manager handoff");
39907
40034
  let unknown = false;
39908
- const metadata = { version: "0.20.4", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
40035
+ const metadata = { version: "0.22.0", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n mobile Gestalt Mobile package only.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
39909
40036
  const status = await runCli(
39910
40037
  { argv: [...invocation.argv], cwd: invocation.cwd, environment: { ...invocation.environment } },
39911
40038
  streams,
@@ -39956,7 +40083,7 @@ async function main2() {
39956
40083
  const selected = selectInteractiveRuntime({ legacyManager: fileURLToPath7(new URL("./legacy/gestalt", import.meta.url)) });
39957
40084
  if (selected.kind === "unix-compatibility") selected.exec({ argv, cwd: process.cwd(), environment });
39958
40085
  }
39959
- const metadata = { version: "0.20.4", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
40086
+ const metadata = { version: "0.22.0", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n mobile Gestalt Mobile package only.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
39960
40087
  const ownershipHelper = packagedWindowsHelper();
39961
40088
  return runCli(
39962
40089
  { argv, cwd: process.cwd(), environment },