@jaromil/gestalt 0.18.0 → 0.18.1

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.18.0'
2
+ // GESTALT_CLI_VERSION='0.18.1'
3
3
  // GESTALT_UPDATED_MANAGER_API='1'
4
4
  /*! tuiuiu.js
5
5
  MIT License
@@ -2564,13 +2564,13 @@ __export(scratch_runtime_exports, {
2564
2564
  scratchReleaseReady: () => scratchReleaseReady2,
2565
2565
  scratchSocketPath: () => scratchSocketPath2
2566
2566
  });
2567
- import path16 from "node:path";
2567
+ import path15 from "node:path";
2568
2568
  import { fileURLToPath as fileURLToPath4 } from "node:url";
2569
2569
  var runtimeReadProbe, scratchContext2, scratchEnvironment2, scratchDiscoveryEnvironment2, scratchAllocate2, scratchBorrow2, scratchRelease2, scratchReleaseReady2, scratchRecoveryCommand2, scratchAssociate2, scratchJson2, scratchSocketPath2;
2570
2570
  var init_scratch_runtime = __esm({
2571
2571
  "src/cli/runtime/scratch-runtime.mjs"() {
2572
2572
  init_scratch_owner();
2573
- runtimeReadProbe = process.platform === "win32" ? path16.join(path16.dirname(fileURLToPath4(import.meta.url)), "native/gestalt-owned-process.exe") : void 0;
2573
+ runtimeReadProbe = process.platform === "win32" ? path15.join(path15.dirname(fileURLToPath4(import.meta.url)), "native/gestalt-owned-process.exe") : void 0;
2574
2574
  ({
2575
2575
  scratchContext: scratchContext2,
2576
2576
  scratchEnvironment: scratchEnvironment2,
@@ -2588,7 +2588,7 @@ var init_scratch_runtime = __esm({
2588
2588
  });
2589
2589
 
2590
2590
  // src/cli/runtime/commands.ts
2591
- import path17 from "node:path";
2591
+ import path16 from "node:path";
2592
2592
  import { randomUUID as randomUUID6 } from "node:crypto";
2593
2593
  function diagnosticEnvironment(environment) {
2594
2594
  return scratchEnvironment2(environment);
@@ -2649,7 +2649,7 @@ var init_commands = __esm({
2649
2649
  if (this.interrupted) throw new Error("runtime interrupted before command launch");
2650
2650
  const executable = await this.resolve(name2);
2651
2651
  if (!executable) throw new Error(`${name2} is required and was not found on PATH`);
2652
- const helper = path17.join(path17.dirname(this.manager), "native", process.platform === "win32" ? "gestalt-owned-process.exe" : "gestalt-owned-process");
2652
+ const helper = path16.join(path16.dirname(this.manager), "native", process.platform === "win32" ? "gestalt-owned-process.exe" : "gestalt-owned-process");
2653
2653
  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`);
2654
2654
  const owner = scratchContext2(environment), borrower = owner ? scratchBorrow2(owner, "manager-runtime") : null;
2655
2655
  let raw;
@@ -35827,7 +35827,7 @@ async function runCli(invocation, streams, metadata, handlers = {}) {
35827
35827
  }
35828
35828
 
35829
35829
  // src/cli/setup/commands.ts
35830
- import path15 from "node:path";
35830
+ import path19 from "node:path";
35831
35831
 
35832
35832
  // src/cli/setup/agents.ts
35833
35833
  import { readFile as readFile3, realpath as realpath5, rename as rename3, rm, unlink as unlink3 } from "node:fs/promises";
@@ -37692,211 +37692,9 @@ async function restartWorker(context, args, update) {
37692
37692
  // src/cli/setup/commands.ts
37693
37693
  init_scratch_context();
37694
37694
  init_skills_owner();
37695
- var retirement = "Xerj has been retired; run gestalt update to migrate managed configuration. User data is retained.";
37696
- function parseUpdateOptions(argv) {
37697
- let component2 = "all", selected = false, extra = false;
37698
- for (let index = 0; index < argv.length; index++) {
37699
- const token = argv[index];
37700
- if (token === "xerj") throw new Error(retirement);
37701
- if (token === "--extra-skills") {
37702
- extra = true;
37703
- continue;
37704
- }
37705
- if (token === "--help" || token === "-h") return { component: component2, extra, help: true };
37706
- if (token === "--component") {
37707
- if (!argv[index + 1]) throw new Error("--component requires all, gestalt, serena, or playwright");
37708
- if (selected) throw new Error("select only one update component");
37709
- component2 = argv[++index];
37710
- selected = true;
37711
- } else if (["all", "gestalt", "serena", "playwright"].includes(token)) {
37712
- if (selected) throw new Error("select only one update component");
37713
- component2 = token;
37714
- selected = true;
37715
- } else throw new Error(`unknown update option or component: ${token} (run 'gestalt update --help')`);
37716
- }
37717
- if (component2 === "xerj") throw new Error(retirement);
37718
- if (!["all", "gestalt", "serena", "playwright"].includes(component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, serena, or playwright)`);
37719
- if (extra && !["all", "gestalt"].includes(component2)) throw new Error("--extra-skills requires the all or gestalt update component");
37720
- return { component: component2, extra, help: false };
37721
- }
37722
- function parseSetupOptions(argv) {
37723
- let extra = false;
37724
- for (const token of argv) {
37725
- if (token === "--extra-skills") extra = true;
37726
- else if (token === "--help" || token === "-h") return { extra, help: true };
37727
- else throw new Error(`unknown setup option: ${token}`);
37728
- }
37729
- return { extra, help: false };
37730
- }
37731
- var defaults = {
37732
- agents: setupAgents,
37733
- skills: async (context, mode) => {
37734
- await context.require("git");
37735
- const unlisten = context.listen();
37736
- try {
37737
- await manageSkills(context, mode);
37738
- } finally {
37739
- unlisten();
37740
- }
37741
- },
37742
- mobile: (context) => installMobile(context),
37743
- manager: updateManager,
37744
- component: async (_context, component2) => {
37745
- throw new Error(`native ${component2} update is not available in this development artifact`);
37746
- }
37747
- };
37748
- function deferredSelection(component2, platform) {
37749
- if (platform !== "win32" || !["serena", "playwright", "mobile"].includes(component2)) return;
37750
- const prerequisite = component2 === "mobile" ? mobileHostSupport(platform).prerequisite : `use an existing supported Unix Gestalt installation for ${component2}`;
37751
- return `native ${component2} support is deferred in this core release; ${prerequisite}`;
37752
- }
37753
- function requireSelection(component2, platform) {
37754
- const message2 = deferredSelection(component2, platform);
37755
- if (message2) throw new Error(message2);
37756
- }
37757
- async function optionalMobile(context, operations, platform) {
37758
- const support = mobileHostSupport(platform);
37759
- if (support.supported) return operations.mobile(context);
37760
- await context.log(`Mobile omitted: ${support.prerequisite}; Gestalt CLI and Agents remain available`);
37761
- return false;
37762
- }
37763
- async function deferredOmission(context, component2, platform) {
37764
- await context.log(`${component2 === "serena" ? "Serena" : "Playwright"} omitted: ${deferredSelection(component2, platform)}`);
37765
- }
37766
- async function runInstall(context, extra, operations = defaults, platform = process.platform) {
37767
- await context.prepareHomes();
37768
- await operations.skills(context, "install");
37769
- await operations.agents(context, "install", extra);
37770
- const mobile = await optionalMobile(context, operations, platform);
37771
- if (platform === "win32") for (const component2 of ["serena", "playwright"])
37772
- await deferredOmission(context, component2, platform);
37773
- await context.log(mobile === false ? "installation complete; run 'gestalt doctor', then 'gestalt cli'" : "installation complete; run 'gestalt doctor', then 'gestalt cli' or 'gestalt mobile'");
37774
- }
37775
- async function runUpdate(context, options, originalArgv, resumed, operations = defaults, platform = process.platform) {
37776
- requireSelection(options.component, platform);
37777
- if (options.component === "all" || options.component === "gestalt") {
37778
- if (await operations.manager(context, originalArgv, resumed)) return true;
37779
- await context.prepareHomes();
37780
- for (const notice of retireManagedConfiguration(context.paths.codexHome, context.paths.gestaltHome, context.paths.manager))
37781
- await context.log(`Xerj retirement: ${notice} preserved; review legacy Xerj entries/processes manually, then retry update. User data and binaries are retained.`);
37782
- await operations.skills(context, "update");
37783
- await operations.agents(context, "upgrade", options.extra);
37784
- const mobile = await optionalMobile(context, operations, platform);
37785
- const summary = mobile === false ? "Agents, optional skills, and context-mode" : "Agents, optional skills, Mobile, and context-mode";
37786
- await context.log(context.environment.GESTALT_MANAGER_DISTRIBUTION === "npm" ? `${summary} are up to date; update the manager with npm install -g @jaromil/gestalt@latest` : `manager, ${summary} are up to date`);
37787
- }
37788
- for (const component2 of ["serena", "playwright"]) {
37789
- if (platform === "win32") {
37790
- if (options.component === "all") await deferredOmission(context, component2, platform);
37791
- continue;
37792
- }
37793
- if (options.component === component2 || options.component === "all" && await optionalStat(path15.join(context.paths.gestaltHome, component2, "active.json")))
37794
- await operations.component(context, component2);
37795
- else if (options.component === "all") await context.log(component2 === "serena" ? "skipping Serena (not installed; use gestalt update serena to install)" : "skipping Playwright (not installed; use gestalt playwright install)");
37796
- }
37797
- await context.log(`update complete (${options.component})`);
37798
- return false;
37799
- }
37800
- function createSetupHandlers(metadata, operations = defaults, resumed = false, managed, platform = process.platform, ownershipHelper) {
37801
- const selectionGuard = (handler) => async (invocation, streams) => {
37802
- if (!invocation.argv.some((token) => ["--help", "-h", "xerj"].includes(token))) {
37803
- for (const token of invocation.argv) {
37804
- const component2 = token.startsWith("--component=") ? token.slice("--component=".length) : token;
37805
- const message2 = deferredSelection(component2, platform);
37806
- if (message2) {
37807
- await streams.stderr(Buffer.from(`gestalt: ${message2}. No profile or installation was changed.
37808
- `));
37809
- return 1;
37810
- }
37811
- }
37812
- }
37813
- return handler(invocation, streams);
37814
- };
37815
- const wrap = (command, body) => async (invocation, streams) => {
37816
- let context;
37817
- try {
37818
- const environment = scratchEnvironment(invocation.environment);
37819
- context = new SetupContext(
37820
- { ...invocation, environment },
37821
- streams,
37822
- await setupPaths(environment, ownershipHelper),
37823
- metadata.version,
37824
- managed?.commands,
37825
- managed?.signal
37826
- );
37827
- context.check();
37828
- return await body(context, invocation.argv);
37829
- } catch (error) {
37830
- await streams.stderr(Buffer.from(`gestalt: ${error instanceof Error ? error.message : `${command} failed`}
37831
- `));
37832
- return error instanceof CommandFailure ? error.status : 1;
37833
- } finally {
37834
- if (context) {
37835
- await context.stopActive();
37836
- if (!context.canRollback()) managed?.unknown();
37837
- }
37838
- }
37839
- };
37840
- return {
37841
- agents: wrap("agents", async (context, argv) => {
37842
- if (!argv.length || argv.length === 1 && ["help", "-h", "--help"].includes(argv[0])) {
37843
- await context.streams.stdout(Buffer.from("Usage: gestalt agents install|update\nInstall or reconcile Gestalt Agents and their context-mode runtime.\n"));
37844
- return 0;
37845
- }
37846
- if (argv.length !== 1 || !["install", "update"].includes(argv[0])) throw new Error("usage: gestalt agents install|update");
37847
- await operations.agents(context, argv[0] === "install" ? "install" : "upgrade", false);
37848
- return 0;
37849
- }),
37850
- install: selectionGuard(wrap("install", async (context, argv) => {
37851
- const options = parseSetupOptions(argv);
37852
- if (options.help) {
37853
- await context.streams.stdout(Buffer.from(metadata.help));
37854
- return 0;
37855
- }
37856
- await runInstall(context, options.extra, operations, platform);
37857
- return 0;
37858
- })),
37859
- update: selectionGuard(wrap("update", async (context, argv) => {
37860
- const options = parseUpdateOptions(argv);
37861
- if (options.help) {
37862
- await context.streams.stdout(Buffer.from(metadata.help));
37863
- return 0;
37864
- }
37865
- await runUpdate(context, options, ["update", ...argv], resumed, operations, platform);
37866
- return 0;
37867
- })),
37868
- "update-restart": selectionGuard(wrap("update-restart", async (context, argv) => {
37869
- const options = parseUpdateOptions(argv);
37870
- if (options.help) {
37871
- await context.streams.stdout(Buffer.from(metadata.help));
37872
- return 0;
37873
- }
37874
- await scheduleRestart(context, options.component, options.extra);
37875
- return 0;
37876
- })),
37877
- "__updated-manager": async (invocation, streams) => {
37878
- const [command, ...argv] = invocation.argv;
37879
- const handlers = createSetupHandlers(metadata, operations, true, managed, platform, ownershipHelper);
37880
- const handler = command && Object.hasOwn(handlers, command) ? handlers[command] : void 0;
37881
- if (!handler || command === "__updated-manager") {
37882
- await streams.stderr(Buffer.from("gestalt: invalid updated-manager continuation\n"));
37883
- return 1;
37884
- }
37885
- return handler({ ...invocation, argv }, streams);
37886
- },
37887
- "__update-restart-worker": wrap("__update-restart-worker", async (context, argv) => restartWorker(context, argv, (worker, component2, extra) => runUpdate(
37888
- worker,
37889
- parseUpdateOptions([component2, ...extra ? ["--extra-skills"] : []]),
37890
- ["__update-restart-worker", ...argv],
37891
- resumed,
37892
- operations,
37893
- platform
37894
- )))
37895
- };
37896
- }
37897
37695
 
37898
37696
  // src/cli/runtime/diagnostics.ts
37899
- import path19 from "node:path";
37697
+ import path18 from "node:path";
37900
37698
  import { lstat as lstat9, readFile as readFile8, realpath as realpath7 } from "node:fs/promises";
37901
37699
  init_context();
37902
37700
  init_commands();
@@ -37906,7 +37704,7 @@ init_storage();
37906
37704
  init_commands();
37907
37705
  import { randomUUID as randomUUID7 } from "node:crypto";
37908
37706
  import { readFile as readFile7, rm as rm4 } from "node:fs/promises";
37909
- import path18 from "node:path";
37707
+ import path17 from "node:path";
37910
37708
  import { tmpdir as tmpdir2 } from "node:os";
37911
37709
  async function probeSandbox(context) {
37912
37710
  const userNamespaces = {};
@@ -37921,7 +37719,7 @@ async function probeSandbox(context) {
37921
37719
  if (Object.hasOwn(context.invocation.environment, "GESTALT_SESSION_TMP_CONTEXT") || Object.hasOwn(process.env, "GESTALT_SESSION_TMP_CONTEXT"))
37922
37720
  return { ...base, ready: false, reason: "sandbox-check-unavailable", diagnostic: "An inherited session temporary owner is active. Run gestalt doctor from a native host shell to probe an isolated Codex home without changing session leases." };
37923
37721
  if (!await context.commands.resolve("codex")) return { ...base, ready: false, reason: "codex-not-found" };
37924
- const directory = path18.join(tmpdir2(), "gestalt-sandbox-doctor-" + randomUUID7());
37722
+ const directory = path17.join(tmpdir2(), "gestalt-sandbox-doctor-" + randomUUID7());
37925
37723
  let created = false, released = false;
37926
37724
  try {
37927
37725
  const storage = await NativePrivateStorage.open(directory, context.paths.unixProbe);
@@ -37979,11 +37777,22 @@ var DiagnosticContext = class {
37979
37777
  async print(label, value) {
37980
37778
  await this.streams.stdout(Buffer.from(label.padEnd(24) + value + "\n"));
37981
37779
  }
37780
+ /** Reject unsupported shims before asking the command owner to launch a probe. */
37781
+ async probeTarget(name2) {
37782
+ const executable = await this.commands.resolve(name2);
37783
+ if (!executable) return null;
37784
+ try {
37785
+ return await commandTarget(executable);
37786
+ } catch {
37787
+ return null;
37788
+ }
37789
+ }
37982
37790
  async query(name2, argv) {
37983
37791
  if (!this.commandQueries) return null;
37984
- if (!await this.commands.resolve(name2)) return null;
37792
+ const target = await this.probeTarget(name2);
37793
+ if (!target) return null;
37985
37794
  try {
37986
- const result = await this.commands.capture(name2, argv);
37795
+ const result = await this.commands.capture(target.executable, [...target.prefix, ...argv]);
37987
37796
  if (result.status !== 0) return null;
37988
37797
  if (result.claim.kind !== "released" && process.platform !== "darwin") return null;
37989
37798
  return result.stdout.trim();
@@ -37995,11 +37804,11 @@ var DiagnosticContext = class {
37995
37804
  if (!this.commandQueries) {
37996
37805
  let prepared, config;
37997
37806
  try {
37998
- prepared = await json(path19.join(this.paths.gestaltHome, "runtime/context-mode/.context-mode-prepared.json"));
37807
+ prepared = await json(path18.join(this.paths.gestaltHome, "runtime/context-mode/.context-mode-prepared.json"));
37999
37808
  } catch {
38000
37809
  }
38001
37810
  try {
38002
- config = parse(await readFile8(path19.join(this.paths.codexHome, "config.toml"), "utf8"));
37811
+ config = parse(await readFile8(path18.join(this.paths.codexHome, "config.toml"), "utf8"));
38003
37812
  } catch {
38004
37813
  }
38005
37814
  const installed2 = [];
@@ -38008,7 +37817,7 @@ var DiagnosticContext = class {
38008
37817
  if (!version2) continue;
38009
37818
  const override = this.invocation.environment[name2 === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT"];
38010
37819
  try {
38011
- const manifest = await json(path19.join(override || path19.join(this.paths.codexHome, "plugins/cache", this.paths.marketplaceName, name2, version2), ".codex-plugin/plugin.json"));
37820
+ const manifest = await json(path18.join(override || path18.join(this.paths.codexHome, "plugins/cache", this.paths.marketplaceName, name2, version2), ".codex-plugin/plugin.json"));
38012
37821
  if (manifest.name === name2 && manifest.version === version2) installed2.push({ name: name2, version: version2, enabled: config?.plugins?.[name2 + "@" + this.paths.marketplaceName]?.enabled !== false });
38013
37822
  } catch {
38014
37823
  }
@@ -38024,20 +37833,29 @@ var DiagnosticContext = class {
38024
37833
  }
38025
37834
  }
38026
37835
  async executableVersion(name2) {
38027
- if (this.commandQueries) return this.query(name2, ["--version"]);
38028
37836
  const executable = await this.commands.resolve(name2);
38029
37837
  if (!executable) return null;
37838
+ if (name2 === "npm" && process.platform === "win32" && path18.basename(executable).toLowerCase() === "npm.cmd") {
37839
+ try {
37840
+ const root = path18.join(path18.dirname(executable), "node_modules/npm");
37841
+ const manifest = await json(path18.join(root, "package.json"));
37842
+ if (manifest.name === "npm" && manifest.bin?.npm === "bin/npm-cli.js" && typeof manifest.version === "string" && /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(manifest.version) && (await lstat9(path18.join(root, "bin/npm-cli.js"))).isFile())
37843
+ return manifest.version + " (package metadata; command not run)";
37844
+ } catch {
37845
+ }
37846
+ }
37847
+ if (this.commandQueries) return this.query(name2, ["--version"]);
38030
37848
  try {
38031
37849
  const target = await commandTarget(executable);
38032
- let directory = path19.dirname(target.prefix[0] || executable);
37850
+ let directory = path18.dirname(target.prefix[0] || executable);
38033
37851
  for (let depth = 0; depth < 7; depth++) {
38034
37852
  try {
38035
- const manifest = await json(path19.join(directory, "package.json"));
37853
+ const manifest = await json(path18.join(directory, "package.json"));
38036
37854
  if ((manifest.name === "@openai/codex" || manifest.name?.startsWith("@openai/codex-")) && name2 === "codex" && typeof manifest.version === "string" && /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(manifest.version))
38037
37855
  return manifest.version + " (package metadata; command not run)";
38038
37856
  } catch {
38039
37857
  }
38040
- const parent = path19.dirname(directory);
37858
+ const parent = path18.dirname(directory);
38041
37859
  if (parent === directory) break;
38042
37860
  directory = parent;
38043
37861
  }
@@ -38054,22 +37872,22 @@ var DiagnosticContext = class {
38054
37872
  async runtime(version2) {
38055
37873
  const environment = this.invocation.environment;
38056
37874
  if (environment.GESTALT_CONTEXT_MODE_RUNTIME) return environment.GESTALT_CONTEXT_MODE_RUNTIME;
38057
- const root = path19.join(this.paths.gestaltHome, "runtime/context-mode");
38058
- if (!await optionalStat(path19.join(root, ".context-mode-prepared.json"))) {
38059
- const legacy = path19.join(root, version2 ?? await this.version("context-mode"), [process.platform, process.arch, "node-" + process.versions.modules].join("-"));
38060
- if (await optionalStat(path19.join(legacy, ".context-mode-prepared.json"))) return legacy;
37875
+ const root = path18.join(this.paths.gestaltHome, "runtime/context-mode");
37876
+ if (!await optionalStat(path18.join(root, ".context-mode-prepared.json"))) {
37877
+ const legacy = path18.join(root, version2 ?? await this.version("context-mode"), [process.platform, process.arch, "node-" + process.versions.modules].join("-"));
37878
+ if (await optionalStat(path18.join(legacy, ".context-mode-prepared.json"))) return legacy;
38061
37879
  }
38062
37880
  return root;
38063
37881
  }
38064
37882
  mobile() {
38065
- return this.invocation.environment.GESTALT_MOBILE_BIN || path19.join(this.paths.gestaltHome, "mobile/node_modules/.bin", process.platform === "win32" ? "gestalt-mobile.cmd" : "gestalt-mobile");
37883
+ return this.invocation.environment.GESTALT_MOBILE_BIN || path18.join(this.paths.gestaltHome, "mobile/node_modules/.bin", process.platform === "win32" ? "gestalt-mobile.cmd" : "gestalt-mobile");
38066
37884
  }
38067
37885
  async managedPath(name2) {
38068
37886
  const p = this.paths, env = this.invocation.environment;
38069
37887
  const fixed = {
38070
- bin: path19.join(p.gestaltHome, "bin"),
38071
- "org-plan": path19.join(p.gestaltHome, "bin/org-plan"),
38072
- "context-mode-cli": path19.join(p.gestaltHome, "bin/context-mode"),
37888
+ bin: path18.join(p.gestaltHome, "bin"),
37889
+ "org-plan": path18.join(p.gestaltHome, "bin/org-plan"),
37890
+ "context-mode-cli": path18.join(p.gestaltHome, "bin/context-mode"),
38073
37891
  mobile: this.mobile(),
38074
37892
  "codex-home": p.codexHome,
38075
37893
  "gestalt-home": p.gestaltHome
@@ -38078,7 +37896,7 @@ var DiagnosticContext = class {
38078
37896
  if (name2 === "context-mode" || name2 === "context-mode-runtime") return this.runtime();
38079
37897
  if (name2 === "context-mode-plugin" || name2 === "gestalt-plugin") {
38080
37898
  const plugin = name2 === "gestalt-plugin" ? "gestalt" : "context-mode", key = plugin === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT";
38081
- return env[key] || path19.join(p.codexHome, "plugins/cache", p.marketplaceName, plugin, await this.version(plugin));
37899
+ return env[key] || path18.join(p.codexHome, "plugins/cache", p.marketplaceName, plugin, await this.version(plugin));
38082
37900
  }
38083
37901
  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
37902
  }
@@ -38086,7 +37904,7 @@ var DiagnosticContext = class {
38086
37904
  async function verifyContextRuntime(context) {
38087
37905
  const inventory = await context.inventory(), gestalt = await context.version("gestalt", inventory), version2 = await context.version("context-mode", inventory);
38088
37906
  if (gestalt !== version2) throw new Error(`plugin version skew after marketplace setup: gestalt=${gestalt} context-mode=${version2}`);
38089
- const runtime = await context.runtime(version2), marker = await json(path19.join(runtime, ".context-mode-prepared.json"));
37907
+ const runtime = await context.runtime(version2), marker = await json(path18.join(runtime, ".context-mode-prepared.json"));
38090
37908
  if (marker.packageVersion !== version2 || marker.platform !== process.platform || marker.arch !== process.arch || marker.nodeModulesAbi !== process.versions.modules)
38091
37909
  throw new Error(`context-mode ${version2} runtime is not prepared for this target/Node ABI: ${runtime}`);
38092
37910
  const installed2 = (Array.isArray(inventory) ? inventory : inventory?.installed) ?? [];
@@ -38094,11 +37912,11 @@ async function verifyContextRuntime(context) {
38094
37912
  throw new Error("context-mode plugin source must remain disabled; run gestalt install or gestalt update to restore the native MCP bridge");
38095
37913
  let value;
38096
37914
  try {
38097
- value = context.commandQueries ? JSON.parse(await context.query("codex", ["mcp", "get", "context-mode", "--json"]) ?? "null") : parse(await readFile8(path19.join(context.paths.codexHome, "config.toml"), "utf8")).mcp_servers?.["context-mode"];
37915
+ value = context.commandQueries ? JSON.parse(await context.query("codex", ["mcp", "get", "context-mode", "--json"]) ?? "null") : parse(await readFile8(path18.join(context.paths.codexHome, "config.toml"), "utf8")).mcp_servers?.["context-mode"];
38098
37916
  } catch {
38099
37917
  }
38100
37918
  const command = value?.transport?.command ?? value?.command, args = value?.transport?.args ?? value?.args;
38101
- if ((context.commandQueries ? value?.enabled !== true : !value || value.enabled === false) || !["node", "node.exe", process.execPath].includes(command) || !Array.isArray(args) || args.length !== 1 || args[0] !== path19.join(context.paths.codexHome, "bin/context-mode-mcp.mjs"))
37919
+ if ((context.commandQueries ? value?.enabled !== true : !value || value.enabled === false) || !["node", "node.exe", process.execPath].includes(command) || !Array.isArray(args) || args.length !== 1 || args[0] !== path18.join(context.paths.codexHome, "bin/context-mode-mcp.mjs"))
38102
37920
  throw new Error("context-mode native MCP bridge is missing or disabled; run gestalt install or gestalt update");
38103
37921
  return runtime;
38104
37922
  }
@@ -38125,7 +37943,7 @@ async function version(context, metadata) {
38125
37943
  }
38126
37944
  let serena;
38127
37945
  try {
38128
- const descriptor = await json(path19.join(context.paths.gestaltHome, "serena/active.json"));
37946
+ const descriptor = await json(path18.join(context.paths.gestaltHome, "serena/active.json"));
38129
37947
  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");
38130
37948
  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]))}))']);
38131
37949
  const uv = await context.query(descriptor.uv, ["--version"]), value = JSON.parse(py ?? "null"), match = uv?.match(/^uv (\d+\.\d+\.\d+)(?:[ (]|$)/);
@@ -38135,7 +37953,7 @@ async function version(context, metadata) {
38135
37953
  await context.print("Serena", serena?.serena ?? "NOT INSTALLED (optional)");
38136
37954
  let browser = "NOT INSTALLED (optional)", browserPresent = false;
38137
37955
  try {
38138
- const descriptor = await json(path19.join(context.paths.gestaltHome, "playwright/active.json"));
37956
+ const descriptor = await json(path18.join(context.paths.gestaltHome, "playwright/active.json"));
38139
37957
  browserPresent = true;
38140
37958
  browser = descriptor.schemaVersion === 1 && descriptor.contractVersion === 1 && /^\d+\.\d+\.\d+$/.test(descriptor.version) ? descriptor.version : "INVALID INSTALLATION";
38141
37959
  } catch {
@@ -38197,7 +38015,7 @@ async function doctor(context, argv, metadata) {
38197
38015
  else if (argv[index] === "--cwd" && selected === void 0 && argv[index + 1] !== void 0) selected = argv[++index];
38198
38016
  else throw new Error("usage: gestalt doctor [--cwd ROOT] [--probe-sandbox]");
38199
38017
  }
38200
- const workspace = await realpath7(selected ? path19.resolve(context.invocation.cwd, selected) : context.invocation.cwd);
38018
+ const workspace = await realpath7(selected ? path18.resolve(context.invocation.cwd, selected) : context.invocation.cwd);
38201
38019
  if (!(await lstat9(workspace)).isDirectory()) throw new Error("doctor workspace must be an existing directory");
38202
38020
  let failed = false;
38203
38021
  await context.streams.stdout(Buffer.from(`Gestalt manager ${metadata.version}
@@ -38212,8 +38030,8 @@ async function doctor(context, argv, metadata) {
38212
38030
  await context.print(label, value ?? "MISSING OR UNVERIFIED");
38213
38031
  if (value === null) failed = true;
38214
38032
  }
38215
- const marketplace = path19.join(context.paths.codexHome, ".tmp/marketplaces", context.paths.marketplaceName);
38216
- const setup = await optionalStat(path19.join(marketplace, "scripts/setup-agents.mjs")) || await optionalStat(path19.join(marketplace, "gestalt-setup.mjs")) || await optionalStat(path19.join(marketplace, "gestalt-setup.sh"));
38033
+ const marketplace = path18.join(context.paths.codexHome, ".tmp/marketplaces", context.paths.marketplaceName);
38034
+ const setup = await optionalStat(path18.join(marketplace, "scripts/setup-agents.mjs")) || await optionalStat(path18.join(marketplace, "gestalt-setup.mjs")) || await optionalStat(path18.join(marketplace, "gestalt-setup.sh"));
38217
38035
  await context.print("Agents marketplace", setup?.isFile() ? "present" : "MISSING");
38218
38036
  if (!setup?.isFile()) failed = true;
38219
38037
  const inventory = await context.inventory();
@@ -38235,8 +38053,8 @@ async function doctor(context, argv, metadata) {
38235
38053
  if (mobile === null && process.platform !== "win32") failed = true;
38236
38054
  let agentsManifest, mobileManifest;
38237
38055
  for (const [component2, file] of [
38238
- ["agents", path19.join(marketplace, "plugins/gestalt/gestalt-supervision-capabilities.json")],
38239
- ["mobile", path19.join(context.paths.gestaltHome, "mobile/node_modules/gestalt-mobile/gestalt-supervision-capabilities.json")]
38056
+ ["agents", path18.join(marketplace, "plugins/gestalt/gestalt-supervision-capabilities.json")],
38057
+ ["mobile", path18.join(context.paths.gestaltHome, "mobile/node_modules/gestalt-mobile/gestalt-supervision-capabilities.json")]
38240
38058
  ]) {
38241
38059
  try {
38242
38060
  if ((await lstat9(file)).size > 16384) throw new Error("manifest exceeds supported size");
@@ -38253,10 +38071,11 @@ async function doctor(context, argv, metadata) {
38253
38071
  await context.streams.stdout(Buffer.from("\nOptional skill collection\n"));
38254
38072
  const skillsContext = new SetupContext(context.invocation, context.streams, context.paths, metadata.version);
38255
38073
  if (await manageSkills(skillsContext, "status") !== 0) failed = true;
38256
- if (context.commandQueries && await context.commands.resolve("codex")) {
38074
+ const codex = context.commandQueries ? await context.probeTarget("codex") : null;
38075
+ if (codex) {
38257
38076
  const args = ["doctor", "--summary", "--ascii", "--no-color"];
38258
38077
  try {
38259
- const config = parse(await readFile8(path19.join(context.paths.codexHome, "config.toml"), "utf8"));
38078
+ const config = parse(await readFile8(path18.join(context.paths.codexHome, "config.toml"), "utf8"));
38260
38079
  const removed = /* @__PURE__ */ new Set(["GESTALT_SESSION_TMP_CONTEXT", "TMPDIR", "TMP", "TEMP"]);
38261
38080
  for (const [name2, server] of Object.entries(config.mcp_servers ?? {})) {
38262
38081
  if (!isGestaltManagedMcp(name2, server, { manager: context.paths.manager, codexHome: context.paths.codexHome })) continue;
@@ -38266,14 +38085,14 @@ async function doctor(context, argv, metadata) {
38266
38085
  } catch {
38267
38086
  }
38268
38087
  await context.streams.stdout(Buffer.from("\nCodex doctor\n"));
38269
- const result = await context.commands.capture("codex", args);
38088
+ const result = await context.commands.capture(codex.executable, [...codex.prefix, ...args]);
38270
38089
  await context.streams.stdout(Buffer.from(result.stdout));
38271
38090
  await context.streams.stderr(Buffer.from(result.stderr));
38272
38091
  if (result.status !== 0 || result.claim.kind !== "released" && process.platform !== "darwin") failed = true;
38273
38092
  }
38274
- if (context.commandQueries && runtime && await optionalStat(path19.join(runtime, "cli.bundle.mjs"))) {
38093
+ if (context.commandQueries && runtime && await optionalStat(path18.join(runtime, "cli.bundle.mjs"))) {
38275
38094
  await context.streams.stdout(Buffer.from("\nContext-mode doctor\n"));
38276
- const result = await context.commands.capture(process.execPath, [path19.join(runtime, "cli.bundle.mjs"), "doctor"], { ...diagnosticEnvironment(context.invocation.environment), CONTEXT_MODE_PLATFORM: "codex", CONTEXT_MODE_WORKSPACE: workspace });
38095
+ const result = await context.commands.capture(process.execPath, [path18.join(runtime, "cli.bundle.mjs"), "doctor"], { ...diagnosticEnvironment(context.invocation.environment), CONTEXT_MODE_PLATFORM: "codex", CONTEXT_MODE_WORKSPACE: workspace });
38277
38096
  await context.streams.stdout(Buffer.from(result.stdout));
38278
38097
  await context.streams.stderr(Buffer.from(result.stderr));
38279
38098
  if (result.status !== 0) failed = true;
@@ -38291,7 +38110,7 @@ async function doctor(context, argv, metadata) {
38291
38110
  if (sandbox.diagnostic) await context.streams.stdout(Buffer.from(sandbox.diagnostic + "\n"));
38292
38111
  if (sandbox.retained) await context.print("Retained probe state", sandbox.retained);
38293
38112
  for (const [name2, label] of [["serena", "Serena"], ["playwright", "Playwright"]]) {
38294
- const present = await optionalStat(path19.join(context.paths.gestaltHome, name2, "active.json"));
38113
+ const present = await optionalStat(path18.join(context.paths.gestaltHome, name2, "active.json"));
38295
38114
  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)`);
38296
38115
  if (present && process.platform !== "win32") failed = true;
38297
38116
  }
@@ -38319,6 +38138,234 @@ function createDiagnosticHandlers(metadata, port, ownershipHelper) {
38319
38138
  return { path: wrap(paths), version: wrap((context) => version(context, metadata)), doctor: wrap((context, argv) => doctor(context, argv, metadata)) };
38320
38139
  }
38321
38140
 
38141
+ // src/cli/setup/commands.ts
38142
+ var retirement = "Xerj has been retired; run gestalt update to migrate managed configuration. User data is retained.";
38143
+ function parseUpdateOptions(argv) {
38144
+ let component2 = "all", selected = false, extra = false;
38145
+ for (let index = 0; index < argv.length; index++) {
38146
+ const token = argv[index];
38147
+ if (token === "xerj") throw new Error(retirement);
38148
+ if (token === "--extra-skills") {
38149
+ extra = true;
38150
+ continue;
38151
+ }
38152
+ if (token === "--help" || token === "-h") return { component: component2, extra, help: true };
38153
+ if (token === "--component") {
38154
+ if (!argv[index + 1]) throw new Error("--component requires all, gestalt, serena, or playwright");
38155
+ if (selected) throw new Error("select only one update component");
38156
+ component2 = argv[++index];
38157
+ selected = true;
38158
+ } else if (["all", "gestalt", "serena", "playwright"].includes(token)) {
38159
+ if (selected) throw new Error("select only one update component");
38160
+ component2 = token;
38161
+ selected = true;
38162
+ } else throw new Error(`unknown update option or component: ${token} (run 'gestalt update --help')`);
38163
+ }
38164
+ if (component2 === "xerj") throw new Error(retirement);
38165
+ if (!["all", "gestalt", "serena", "playwright"].includes(component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, serena, or playwright)`);
38166
+ if (extra && !["all", "gestalt"].includes(component2)) throw new Error("--extra-skills requires the all or gestalt update component");
38167
+ return { component: component2, extra, help: false };
38168
+ }
38169
+ function parseSetupOptions(argv) {
38170
+ let extra = false;
38171
+ for (const token of argv) {
38172
+ if (token === "--extra-skills") extra = true;
38173
+ else if (token === "--help" || token === "-h") return { extra, help: true };
38174
+ else throw new Error(`unknown setup option: ${token}`);
38175
+ }
38176
+ return { extra, help: false };
38177
+ }
38178
+ var defaults = {
38179
+ agents: setupAgents,
38180
+ skills: async (context, mode) => {
38181
+ await context.require("git");
38182
+ const unlisten = context.listen();
38183
+ try {
38184
+ await manageSkills(context, mode);
38185
+ } finally {
38186
+ unlisten();
38187
+ }
38188
+ },
38189
+ mobile: (context) => installMobile(context),
38190
+ manager: updateManager,
38191
+ component: async (_context, component2) => {
38192
+ throw new Error(`native ${component2} update is not available in this development artifact`);
38193
+ },
38194
+ diagnostics: runUpdateDiagnostics
38195
+ };
38196
+ async function runUpdateDiagnostics(context) {
38197
+ await context.log("running post-update diagnostics");
38198
+ const stopListening = context.listen();
38199
+ let diagnostic;
38200
+ try {
38201
+ diagnostic = new DiagnosticContext(
38202
+ context.paths,
38203
+ { ...context.invocation, environment: context.environment },
38204
+ context.streams,
38205
+ await context.managedCommands(),
38206
+ true
38207
+ );
38208
+ if (await doctor(diagnostic, [], { version: context.version }) !== 0)
38209
+ await context.log("post-update diagnostics reported a problem; see the checks above");
38210
+ } catch (error) {
38211
+ await context.log(`post-update diagnostics could not complete: ${error instanceof Error ? error.message : String(error)}`);
38212
+ } finally {
38213
+ await diagnostic?.commands.stop();
38214
+ stopListening();
38215
+ }
38216
+ context.check();
38217
+ }
38218
+ function deferredSelection(component2, platform) {
38219
+ if (platform !== "win32" || !["serena", "playwright", "mobile"].includes(component2)) return;
38220
+ const prerequisite = component2 === "mobile" ? mobileHostSupport(platform).prerequisite : `use an existing supported Unix Gestalt installation for ${component2}`;
38221
+ return `native ${component2} support is deferred in this core release; ${prerequisite}`;
38222
+ }
38223
+ function requireSelection(component2, platform) {
38224
+ const message2 = deferredSelection(component2, platform);
38225
+ if (message2) throw new Error(message2);
38226
+ }
38227
+ async function optionalMobile(context, operations, platform) {
38228
+ const support = mobileHostSupport(platform);
38229
+ if (support.supported) return operations.mobile(context);
38230
+ await context.log(`Mobile omitted: ${support.prerequisite}; Gestalt CLI and Agents remain available`);
38231
+ return false;
38232
+ }
38233
+ async function deferredOmission(context, component2, platform) {
38234
+ await context.log(`${component2 === "serena" ? "Serena" : "Playwright"} omitted: ${deferredSelection(component2, platform)}`);
38235
+ }
38236
+ async function runInstall(context, extra, operations = defaults, platform = process.platform) {
38237
+ await context.prepareHomes();
38238
+ await operations.skills(context, "install");
38239
+ await operations.agents(context, "install", extra);
38240
+ const mobile = await optionalMobile(context, operations, platform);
38241
+ if (platform === "win32") for (const component2 of ["serena", "playwright"])
38242
+ await deferredOmission(context, component2, platform);
38243
+ await context.log(mobile === false ? "installation complete; run 'gestalt doctor', then 'gestalt cli'" : "installation complete; run 'gestalt doctor', then 'gestalt cli' or 'gestalt mobile'");
38244
+ }
38245
+ async function runUpdate(context, options, originalArgv, resumed, operations = defaults, platform = process.platform) {
38246
+ requireSelection(options.component, platform);
38247
+ if (options.component === "all" || options.component === "gestalt") {
38248
+ if (await operations.manager(context, originalArgv, resumed)) return true;
38249
+ await context.prepareHomes();
38250
+ for (const notice of retireManagedConfiguration(context.paths.codexHome, context.paths.gestaltHome, context.paths.manager))
38251
+ await context.log(`Xerj retirement: ${notice} preserved; review legacy Xerj entries/processes manually, then retry update. User data and binaries are retained.`);
38252
+ await operations.skills(context, "update");
38253
+ await operations.agents(context, "upgrade", options.extra);
38254
+ const mobile = await optionalMobile(context, operations, platform);
38255
+ const summary = mobile === false ? "Agents, optional skills, and context-mode" : "Agents, optional skills, Mobile, and context-mode";
38256
+ await context.log(context.environment.GESTALT_MANAGER_DISTRIBUTION === "npm" ? `${summary} are up to date; update the manager with npm install -g @jaromil/gestalt@latest` : `manager, ${summary} are up to date`);
38257
+ }
38258
+ for (const component2 of ["serena", "playwright"]) {
38259
+ if (platform === "win32") {
38260
+ if (options.component === "all") await deferredOmission(context, component2, platform);
38261
+ continue;
38262
+ }
38263
+ if (options.component === component2 || options.component === "all" && await optionalStat(path19.join(context.paths.gestaltHome, component2, "active.json")))
38264
+ await operations.component(context, component2);
38265
+ else if (options.component === "all") await context.log(component2 === "serena" ? "skipping Serena (not installed; use gestalt update serena to install)" : "skipping Playwright (not installed; use gestalt playwright install)");
38266
+ }
38267
+ if (options.component === "all" || options.component === "gestalt") await operations.diagnostics?.(context);
38268
+ await context.log(`update complete (${options.component})`);
38269
+ return false;
38270
+ }
38271
+ function createSetupHandlers(metadata, operations = defaults, resumed = false, managed, platform = process.platform, ownershipHelper) {
38272
+ const selectionGuard = (handler) => async (invocation, streams) => {
38273
+ if (!invocation.argv.some((token) => ["--help", "-h", "xerj"].includes(token))) {
38274
+ for (const token of invocation.argv) {
38275
+ const component2 = token.startsWith("--component=") ? token.slice("--component=".length) : token;
38276
+ const message2 = deferredSelection(component2, platform);
38277
+ if (message2) {
38278
+ await streams.stderr(Buffer.from(`gestalt: ${message2}. No profile or installation was changed.
38279
+ `));
38280
+ return 1;
38281
+ }
38282
+ }
38283
+ }
38284
+ return handler(invocation, streams);
38285
+ };
38286
+ const wrap = (command, body) => async (invocation, streams) => {
38287
+ let context;
38288
+ try {
38289
+ const environment = scratchEnvironment(invocation.environment);
38290
+ context = new SetupContext(
38291
+ { ...invocation, environment },
38292
+ streams,
38293
+ await setupPaths(environment, ownershipHelper),
38294
+ metadata.version,
38295
+ managed?.commands,
38296
+ managed?.signal
38297
+ );
38298
+ context.check();
38299
+ return await body(context, invocation.argv);
38300
+ } catch (error) {
38301
+ await streams.stderr(Buffer.from(`gestalt: ${error instanceof Error ? error.message : `${command} failed`}
38302
+ `));
38303
+ return error instanceof CommandFailure ? error.status : 1;
38304
+ } finally {
38305
+ if (context) {
38306
+ await context.stopActive();
38307
+ if (!context.canRollback()) managed?.unknown();
38308
+ }
38309
+ }
38310
+ };
38311
+ return {
38312
+ agents: wrap("agents", async (context, argv) => {
38313
+ if (!argv.length || argv.length === 1 && ["help", "-h", "--help"].includes(argv[0])) {
38314
+ await context.streams.stdout(Buffer.from("Usage: gestalt agents install|update\nInstall or reconcile Gestalt Agents and their context-mode runtime.\n"));
38315
+ return 0;
38316
+ }
38317
+ if (argv.length !== 1 || !["install", "update"].includes(argv[0])) throw new Error("usage: gestalt agents install|update");
38318
+ await operations.agents(context, argv[0] === "install" ? "install" : "upgrade", false);
38319
+ return 0;
38320
+ }),
38321
+ install: selectionGuard(wrap("install", async (context, argv) => {
38322
+ const options = parseSetupOptions(argv);
38323
+ if (options.help) {
38324
+ await context.streams.stdout(Buffer.from(metadata.help));
38325
+ return 0;
38326
+ }
38327
+ await runInstall(context, options.extra, operations, platform);
38328
+ return 0;
38329
+ })),
38330
+ update: selectionGuard(wrap("update", async (context, argv) => {
38331
+ const options = parseUpdateOptions(argv);
38332
+ if (options.help) {
38333
+ await context.streams.stdout(Buffer.from(metadata.help));
38334
+ return 0;
38335
+ }
38336
+ await runUpdate(context, options, ["update", ...argv], resumed, operations, platform);
38337
+ return 0;
38338
+ })),
38339
+ "update-restart": selectionGuard(wrap("update-restart", async (context, argv) => {
38340
+ const options = parseUpdateOptions(argv);
38341
+ if (options.help) {
38342
+ await context.streams.stdout(Buffer.from(metadata.help));
38343
+ return 0;
38344
+ }
38345
+ await scheduleRestart(context, options.component, options.extra);
38346
+ return 0;
38347
+ })),
38348
+ "__updated-manager": async (invocation, streams) => {
38349
+ const [command, ...argv] = invocation.argv;
38350
+ const handlers = createSetupHandlers(metadata, operations, true, managed, platform, ownershipHelper);
38351
+ const handler = command && Object.hasOwn(handlers, command) ? handlers[command] : void 0;
38352
+ if (!handler || command === "__updated-manager") {
38353
+ await streams.stderr(Buffer.from("gestalt: invalid updated-manager continuation\n"));
38354
+ return 1;
38355
+ }
38356
+ return handler({ ...invocation, argv }, streams);
38357
+ },
38358
+ "__update-restart-worker": wrap("__update-restart-worker", async (context, argv) => restartWorker(context, argv, (worker, component2, extra) => runUpdate(
38359
+ worker,
38360
+ parseUpdateOptions([component2, ...extra ? ["--extra-skills"] : []]),
38361
+ ["__update-restart-worker", ...argv],
38362
+ resumed,
38363
+ operations,
38364
+ platform
38365
+ )))
38366
+ };
38367
+ }
38368
+
38322
38369
  // src/cli/runtime/skills.ts
38323
38370
  init_context();
38324
38371
  init_scratch_context();
@@ -39640,7 +39687,7 @@ async function launchCapabilities(commands, invocation, manager) {
39640
39687
 
39641
39688
  // src/cli/runtime/cli.ts
39642
39689
  var administrative = ["-h", "--help", "-V", "--version", "help", "login", "logout", "plugin", "mcp", "doctor", "features", "completion"];
39643
- function cliHandler(metadata, owned = false, port, terminal) {
39690
+ function cliHandler(owned = false, port, terminal) {
39644
39691
  return async (invocation, streams) => {
39645
39692
  let commands, unlisten;
39646
39693
  let primary = null;
@@ -39677,14 +39724,10 @@ function cliHandler(metadata, owned = false, port, terminal) {
39677
39724
  unlisten = commands.listen();
39678
39725
  const codex = await commands.resolve("codex");
39679
39726
  if (!codex) throw new Error("codex is required and was not found on PATH");
39680
- const diagnostic = new DiagnosticContext(paths2, selected, streams, port);
39681
39727
  const required = new DiagnosticContext(paths2, selected, streams, port, true), unlistenDiagnostic = required.commands.listen();
39682
39728
  try {
39683
- await streams.stderr(Buffer.from("gestalt: running startup diagnostics\n"));
39684
- if (await doctor(diagnostic, [], metadata) !== 0)
39685
- await streams.stderr(Buffer.from("gestalt: startup diagnostics reported a problem; launch will continue after required runtime checks\n"));
39686
- if (required.commands.interrupted) return required.commands.interrupted;
39687
39729
  await verifyContextRuntime(required);
39730
+ if (required.commands.interrupted) return required.commands.interrupted;
39688
39731
  } finally {
39689
39732
  await required.commands.stop();
39690
39733
  unlistenDiagnostic();
@@ -39735,8 +39778,8 @@ function createRuntimeHandlers(metadata, terminal, ownershipHelper) {
39735
39778
  scratch: scratchHandler,
39736
39779
  "__scratch-hook": scratchHookHandler,
39737
39780
  "__codex-app-server": appServerHandler(),
39738
- cli: cliHandler(metadata, false, void 0, terminal),
39739
- "__cli-owned": cliHandler(metadata, true, void 0, terminal),
39781
+ cli: cliHandler(false, void 0, terminal),
39782
+ "__cli-owned": cliHandler(true, void 0, terminal),
39740
39783
  serena: deferredTool("serena"),
39741
39784
  playwright: deferredTool("playwright"),
39742
39785
  mobile: async (invocation, streams) => {
@@ -39794,7 +39837,7 @@ function packagedWindowsHelper() {
39794
39837
  async function continueUpdatedManager(invocation, streams, options) {
39795
39838
  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");
39796
39839
  let unknown = false;
39797
- const metadata = { version: "0.18.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 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] Stage, verify and activate an explicit package update.\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] Validate and activate a release; retain prior tooling.\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" };
39840
+ const metadata = { version: "0.18.1", 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 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] Stage, verify and activate an explicit package update.\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] Validate and activate a release; retain prior tooling.\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" };
39798
39841
  const status = await runCli(
39799
39842
  { argv: [...invocation.argv], cwd: invocation.cwd, environment: { ...invocation.environment } },
39800
39843
  streams,
@@ -39841,7 +39884,7 @@ async function main2() {
39841
39884
  const selected = selectInteractiveRuntime({ legacyManager: fileURLToPath7(new URL("./legacy/gestalt", import.meta.url)) });
39842
39885
  if (selected.kind === "unix-compatibility") selected.exec({ argv, cwd: process.cwd(), environment });
39843
39886
  }
39844
- const metadata = { version: "0.18.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 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] Stage, verify and activate an explicit package update.\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] Validate and activate a release; retain prior tooling.\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" };
39887
+ const metadata = { version: "0.18.1", 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 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] Stage, verify and activate an explicit package update.\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] Validate and activate a release; retain prior tooling.\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" };
39845
39888
  const ownershipHelper = packagedWindowsHelper();
39846
39889
  return runCli(
39847
39890
  { argv, cwd: process.cwd(), environment },
@@ -3,7 +3,7 @@
3
3
  set -Eeuo pipefail
4
4
  IFS=$'\n\t'
5
5
 
6
- readonly GESTALT_CLI_VERSION='0.18.0'
6
+ readonly GESTALT_CLI_VERSION='0.18.1'
7
7
  readonly DEFAULT_INSTALL_BASE_URL='https://dyne.github.io/gestalt'
8
8
  readonly DEFAULT_MARKETPLACE='dyne/gestalt-agents'
9
9
  readonly DEFAULT_MARKETPLACE_NAME='dyne-gestalt-agents'
@@ -3906,6 +3906,16 @@ command_update() {
3906
3906
  elif [[ $update_component == all ]]; then
3907
3907
  log 'skipping Playwright (not installed; use gestalt playwright install)'
3908
3908
  fi
3909
+ log 'running post-update diagnostics'
3910
+ if ! (
3911
+ case $update_component in
3912
+ all | gestalt) command_doctor ;;
3913
+ serena) run_doctor_command 'Serena doctor' command_serena doctor ;;
3914
+ playwright) run_doctor_command 'Playwright doctor' command_playwright doctor ;;
3915
+ esac
3916
+ ); then
3917
+ log 'post-update diagnostics reported a problem; see the checks above'
3918
+ fi
3909
3919
  log "update complete ($update_component)"
3910
3920
  }
3911
3921
 
@@ -5198,7 +5208,6 @@ command_cli() {
5198
5208
  command_cli_owned() {
5199
5209
  check_node_version
5200
5210
  require_command codex
5201
- run_startup_diagnostics
5202
5211
  verify_context_mode_installation
5203
5212
  forwarded_args=("$@")
5204
5213
  resolve_manager_target
@@ -5330,7 +5339,7 @@ command_mobile() {
5330
5339
  local mobile_restart_dir mobile_restart_state mobile_restart_staged restart_cwd
5331
5340
  local context_mode_runtime context_mode_plugin_root gestalt_plugin_root
5332
5341
  local plugin_inventory='' gestalt_agents_version='' context_mode_version=''
5333
- local mobile_workspace=$PWD mobile_arg_index
5342
+ local mobile_arg_index
5334
5343
 
5335
5344
  strip_separator "$@"
5336
5345
  # Reject obsolete manually supplied options before installation or startup.
@@ -5344,12 +5353,6 @@ command_mobile() {
5344
5353
  log 'Gestalt Mobile is not installed; installing it now'
5345
5354
  install_mobile
5346
5355
  fi
5347
- for ((mobile_arg_index = 0; mobile_arg_index < ${#forwarded_args[@]}; mobile_arg_index++)); do
5348
- if [[ ${forwarded_args[mobile_arg_index]} == --cwd && -d ${forwarded_args[mobile_arg_index+1]:-} ]]; then
5349
- mobile_workspace=${forwarded_args[mobile_arg_index+1]}
5350
- fi
5351
- done
5352
- run_startup_diagnostics --cwd "$mobile_workspace"
5353
5356
  plugin_inventory=$(CODEX_HOME=$codex_home codex plugin list \
5354
5357
  --marketplace "$marketplace_name" --json 2>/dev/null) || plugin_inventory=''
5355
5358
  if [[ -n $plugin_inventory ]]; then
@@ -5432,8 +5435,9 @@ command_version() {
5432
5435
  print_check 'Serena' "${value:-NOT INSTALLED (optional)}"
5433
5436
  value=$(command_playwright version 2>/dev/null || true)
5434
5437
  print_check 'Playwright' "${value:-NOT INSTALLED (optional)}"
5435
- value=$(command_playwright doctor 2>/dev/null || true)
5436
- print_check 'Playwright readiness' "$value"
5438
+ if [[ -n $value ]]; then
5439
+ print_check 'Playwright readiness' 'NOT PROBED (use gestalt playwright doctor)'
5440
+ fi
5437
5441
  value=$(serena_versions uv 2>/dev/null || true)
5438
5442
  print_check 'uv (Serena)' "${value:-NOT INSTALLED (optional)}"
5439
5443
  value=$(serena_versions python 2>/dev/null || true)
@@ -5794,13 +5798,6 @@ run_doctor_command() {
5794
5798
  return 1
5795
5799
  }
5796
5800
 
5797
- run_startup_diagnostics() {
5798
- log 'running startup diagnostics'
5799
- if ! command_doctor "$@"; then
5800
- log 'startup diagnostics reported a problem; launch will continue after required runtime checks'
5801
- fi
5802
- }
5803
-
5804
5801
  run_codex_doctor() {
5805
5802
  # Session scratch forwarding is required for session launches, but is optional
5806
5803
  # for an operator's read-only diagnostics. Do not invent an owner or edit config.
@@ -5961,7 +5958,7 @@ command_doctor() {
5961
5958
  printf "\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" >&2
5962
5959
  return 1
5963
5960
  fi
5964
- printf "\nAll startup diagnostics passed.\n"
5961
+ printf "\nAll diagnostics passed.\n"
5965
5962
  }
5966
5963
 
5967
5964
  main() {
@@ -2,7 +2,7 @@
2
2
  "source": "src/cli/platform/native/owned-process.c",
3
3
  "license": "MIT (full license in source)",
4
4
  "sourceSha256": "8b8499245e4213e3e842497f815d4b0d19685bcd806b461fdacb66119500ad58",
5
- "artifactSha256": "ce58be5db135f849e8ed83cbab0249d2656d4db0403a0c06a7e4c08affed6ff8",
5
+ "artifactSha256": "e7bf178c8c19d7e6ef9e7005b28339e1e2041fee7188a4126730df04f6431947",
6
6
  "platform": "win32",
7
7
  "architecture": "x64",
8
8
  "node": "v24.22.3",
@@ -23,7 +23,7 @@
23
23
  "advapi32.lib",
24
24
  "netapi32.lib"
25
25
  ],
26
- "observedAt": "2026-11-22T14:49:31.451Z",
26
+ "observedAt": "2026-11-23T07:18:44.884Z",
27
27
  "sourceInputs": [
28
28
  {
29
29
  "path": "src/cli/platform/native/owned-process.c",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jaromil/gestalt",
3
3
  "type": "module",
4
- "version": "0.18.0",
4
+ "version": "0.18.1",
5
5
  "description": "Manage Gestalt's isolated Codex profile, agent skills and Mobile installation",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "author": "Dyne.org foundation",
@@ -44,5 +44,5 @@
44
44
  "access": "public",
45
45
  "registry": "https://registry.npmjs.org/"
46
46
  },
47
- "gitHead": "e1ddc3ce599d789109ebce6fce8002a155e12aae"
47
+ "gitHead": "42e48ca2fa173ac06cccdbd3d9b35efdd8fb3ea6"
48
48
  }