@jaromil/gestalt 0.18.0 → 0.18.2
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.
|
|
2
|
+
// GESTALT_CLI_VERSION='0.18.2'
|
|
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
|
|
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" ?
|
|
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
|
|
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 =
|
|
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;
|
|
@@ -10379,7 +10379,7 @@ var init_yaml = __esm({
|
|
|
10379
10379
|
|
|
10380
10380
|
// src/cli/skill-profiles/store.ts
|
|
10381
10381
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
10382
|
-
import { mkdir as
|
|
10382
|
+
import { mkdir as mkdir7, readFile as readFile11, readdir as readdir3, rename as rename7, rm as rm6, writeFile as writeFile4 } from "node:fs/promises";
|
|
10383
10383
|
import path28 from "node:path";
|
|
10384
10384
|
var FileSkillProfiles;
|
|
10385
10385
|
var init_store = __esm({
|
|
@@ -10446,7 +10446,7 @@ var init_store = __esm({
|
|
|
10446
10446
|
await storage.replaceFile(file, bytes);
|
|
10447
10447
|
return;
|
|
10448
10448
|
}
|
|
10449
|
-
await
|
|
10449
|
+
await mkdir7(this.root, { recursive: true, mode: 448 });
|
|
10450
10450
|
await this.checkRoot();
|
|
10451
10451
|
const temporary = path28.join(this.root, `.profile-${randomUUID10()}.tmp`);
|
|
10452
10452
|
await writeFile4(temporary, bytes, { flag: "wx", mode: 384 });
|
|
@@ -35827,10 +35827,10 @@ async function runCli(invocation, streams, metadata, handlers = {}) {
|
|
|
35827
35827
|
}
|
|
35828
35828
|
|
|
35829
35829
|
// src/cli/setup/commands.ts
|
|
35830
|
-
import
|
|
35830
|
+
import path19 from "node:path";
|
|
35831
35831
|
|
|
35832
35832
|
// src/cli/setup/agents.ts
|
|
35833
|
-
import { readFile as readFile3, realpath as realpath5, rename as rename3, rm, unlink as unlink3 } from "node:fs/promises";
|
|
35833
|
+
import { mkdir as mkdir3, readFile as readFile3, realpath as realpath5, rename as rename3, rm, stat as stat3, unlink as unlink3 } from "node:fs/promises";
|
|
35834
35834
|
import path10 from "node:path";
|
|
35835
35835
|
import { pathToFileURL } from "node:url";
|
|
35836
35836
|
|
|
@@ -36824,7 +36824,7 @@ function managedMcpOverrides(config, baseline, owner) {
|
|
|
36824
36824
|
}
|
|
36825
36825
|
|
|
36826
36826
|
// src/cli/setup/configuration.mjs
|
|
36827
|
-
function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp") {
|
|
36827
|
+
function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp", cacheRoots = []) {
|
|
36828
36828
|
parse(source);
|
|
36829
36829
|
const newline = source.match(/\r\n|\n|\r/)?.[0] ?? "\n";
|
|
36830
36830
|
const retained = [];
|
|
@@ -36860,6 +36860,8 @@ function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp")
|
|
|
36860
36860
|
'approval_policy = "never"',
|
|
36861
36861
|
'default_permissions = "workspace-git"'
|
|
36862
36862
|
];
|
|
36863
|
+
const writeRoots = /* @__PURE__ */ new Set([temporaryRoot, ...cacheRoots]);
|
|
36864
|
+
for (const path31 of homeReadRoots) writeRoots.delete(path31);
|
|
36863
36865
|
const profile = [
|
|
36864
36866
|
"[permissions.workspace-git]",
|
|
36865
36867
|
'description = "Workspace and Git writable with local test support"',
|
|
@@ -36871,7 +36873,7 @@ function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp")
|
|
|
36871
36873
|
"allow_local_binding = true",
|
|
36872
36874
|
"",
|
|
36873
36875
|
"[permissions.workspace-git.filesystem]",
|
|
36874
|
-
`${JSON.stringify(
|
|
36876
|
+
...[...writeRoots].map((path31) => `${JSON.stringify(path31)} = "write"`),
|
|
36875
36877
|
...homeReadRoots.map((path31) => `${JSON.stringify(path31)} = "read"`),
|
|
36876
36878
|
"",
|
|
36877
36879
|
'[permissions.workspace-git.filesystem.":workspace_roots"]',
|
|
@@ -37114,12 +37116,26 @@ async function setupAgents(context, _mode, extraSkills) {
|
|
|
37114
37116
|
const configFile = path10.join(codexHome, "config.toml");
|
|
37115
37117
|
const normalize2 = async () => {
|
|
37116
37118
|
const before = await readProfile(configFile), source = before?.bytes.toString("utf8") ?? "";
|
|
37117
|
-
const
|
|
37118
|
-
const
|
|
37119
|
-
|
|
37120
|
-
|
|
37121
|
-
|
|
37122
|
-
);
|
|
37119
|
+
const { LOCALAPPDATA, XDG_CACHE_HOME, XDG_RUNTIME_DIR } = context.environment;
|
|
37120
|
+
const windows = process.platform === "win32";
|
|
37121
|
+
const localAppData = LOCALAPPDATA || path10.join(userHome, "AppData/Local");
|
|
37122
|
+
const temporaryRoot = windows ? path10.join(localAppData, "Temp") : "/tmp";
|
|
37123
|
+
const cacheHome = windows ? localAppData : XDG_CACHE_HOME && path10.isAbsolute(XDG_CACHE_HOME) ? XDG_CACHE_HOME : path10.join(userHome, process.platform === "darwin" ? "Library/Caches" : ".cache");
|
|
37124
|
+
const legacyCache = path10.join(userHome, ".ccache");
|
|
37125
|
+
const legacy = await stat3(legacyCache).catch((error) => {
|
|
37126
|
+
if (!absent2(error)) throw error;
|
|
37127
|
+
});
|
|
37128
|
+
const cacheDir = legacy?.isDirectory() ? legacyCache : path10.join(cacheHome, "ccache");
|
|
37129
|
+
const cacheRoots = [cacheDir];
|
|
37130
|
+
if (!windows && XDG_RUNTIME_DIR && path10.isAbsolute(XDG_RUNTIME_DIR))
|
|
37131
|
+
cacheRoots.push(path10.join(XDG_RUNTIME_DIR, "ccache-tmp"));
|
|
37132
|
+
const readRoots = [.../* @__PURE__ */ new Set([codexHome, gestaltHome, ...[".agents", ".local", ".config"].map((name2) => path10.join(userHome, name2))])];
|
|
37133
|
+
const output = permissionConfiguration(approvalConfiguration(source, manager, codexHome), readRoots, temporaryRoot, cacheRoots);
|
|
37134
|
+
if (!readRoots.includes(cacheDir)) {
|
|
37135
|
+
await mkdir3(cacheDir, { recursive: true, mode: 448 }).catch((error) => {
|
|
37136
|
+
if (!["EACCES", "EPERM", "EROFS", "ENOTDIR", "EEXIST"].includes(error.code ?? "")) throw error;
|
|
37137
|
+
});
|
|
37138
|
+
}
|
|
37123
37139
|
await replaceProfile(codexStorage, configFile, Buffer.from(output), before);
|
|
37124
37140
|
};
|
|
37125
37141
|
const unlisten = context.listen();
|
|
@@ -37363,7 +37379,7 @@ async function installMobile(context, explicit = false) {
|
|
|
37363
37379
|
}
|
|
37364
37380
|
|
|
37365
37381
|
// src/cli/setup/manager-update.ts
|
|
37366
|
-
import { chmod as chmod2, lstat as lstat7, mkdir as
|
|
37382
|
+
import { chmod as chmod2, lstat as lstat7, mkdir as mkdir4, mkdtemp, readFile as readFile5, rename as rename5, rm as rm3, writeFile } from "node:fs/promises";
|
|
37367
37383
|
import { tmpdir } from "node:os";
|
|
37368
37384
|
import path12 from "node:path";
|
|
37369
37385
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -37383,7 +37399,7 @@ async function updateManager(context, originalArgv, resumed) {
|
|
|
37383
37399
|
if (!current) throw new Error(`could not resolve manager executable: ${target}`);
|
|
37384
37400
|
const lockRoot = path12.join(directory, ".gestalt-manager-update.lock");
|
|
37385
37401
|
if (process.platform === "win32") await windowsSystem({ operation: "create-directory", path: lockRoot });
|
|
37386
|
-
else await
|
|
37402
|
+
else await mkdir4(lockRoot, { mode: 448 });
|
|
37387
37403
|
const storage = await NativePrivateStorage.open(lockRoot, context.paths.unixProbe, context.windowsReadHelper);
|
|
37388
37404
|
const lockIdentity = await lstat7(lockRoot, { bigint: true });
|
|
37389
37405
|
const scratch = await mkdtemp(path12.join(tmpdir(), "gestalt-update."));
|
|
@@ -37605,7 +37621,7 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
|
|
|
37605
37621
|
}
|
|
37606
37622
|
|
|
37607
37623
|
// src/cli/setup/restart.ts
|
|
37608
|
-
import { lstat as lstat8, open as open3, readFile as readFile6, rmdir as rmdir2, stat as
|
|
37624
|
+
import { lstat as lstat8, open as open3, readFile as readFile6, rmdir as rmdir2, stat as stat4, unlink as unlink4 } from "node:fs/promises";
|
|
37609
37625
|
import path13 from "node:path";
|
|
37610
37626
|
import { setTimeout as delay } from "node:timers/promises";
|
|
37611
37627
|
init_context();
|
|
@@ -37668,7 +37684,7 @@ async function restartWorker(context, args, update) {
|
|
|
37668
37684
|
const record2 = bytes.toString("utf8").slice(0, -1).split("\0");
|
|
37669
37685
|
const cwd = record2.shift();
|
|
37670
37686
|
const argv = retiredRestartArguments(record2);
|
|
37671
|
-
if (!path13.isAbsolute(cwd) || !(await
|
|
37687
|
+
if (!path13.isAbsolute(cwd) || !(await stat4(cwd)).isDirectory()) throw new Error(`the Gestalt Mobile restart directory is invalid: ${cwd}`);
|
|
37672
37688
|
if (await update(worker, component2, extra === "true")) return 0;
|
|
37673
37689
|
await relayContext(worker, relay, descriptor);
|
|
37674
37690
|
if (!(await readFile6(descriptor)).equals(bytes)) throw new Error("the Gestalt Mobile restart descriptor changed during update; relay preserved");
|
|
@@ -37692,211 +37708,9 @@ async function restartWorker(context, args, update) {
|
|
|
37692
37708
|
// src/cli/setup/commands.ts
|
|
37693
37709
|
init_scratch_context();
|
|
37694
37710
|
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
37711
|
|
|
37898
37712
|
// src/cli/runtime/diagnostics.ts
|
|
37899
|
-
import
|
|
37713
|
+
import path18 from "node:path";
|
|
37900
37714
|
import { lstat as lstat9, readFile as readFile8, realpath as realpath7 } from "node:fs/promises";
|
|
37901
37715
|
init_context();
|
|
37902
37716
|
init_commands();
|
|
@@ -37906,7 +37720,7 @@ init_storage();
|
|
|
37906
37720
|
init_commands();
|
|
37907
37721
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
37908
37722
|
import { readFile as readFile7, rm as rm4 } from "node:fs/promises";
|
|
37909
|
-
import
|
|
37723
|
+
import path17 from "node:path";
|
|
37910
37724
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
37911
37725
|
async function probeSandbox(context) {
|
|
37912
37726
|
const userNamespaces = {};
|
|
@@ -37921,7 +37735,7 @@ async function probeSandbox(context) {
|
|
|
37921
37735
|
if (Object.hasOwn(context.invocation.environment, "GESTALT_SESSION_TMP_CONTEXT") || Object.hasOwn(process.env, "GESTALT_SESSION_TMP_CONTEXT"))
|
|
37922
37736
|
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
37737
|
if (!await context.commands.resolve("codex")) return { ...base, ready: false, reason: "codex-not-found" };
|
|
37924
|
-
const directory =
|
|
37738
|
+
const directory = path17.join(tmpdir2(), "gestalt-sandbox-doctor-" + randomUUID7());
|
|
37925
37739
|
let created = false, released = false;
|
|
37926
37740
|
try {
|
|
37927
37741
|
const storage = await NativePrivateStorage.open(directory, context.paths.unixProbe);
|
|
@@ -37979,11 +37793,22 @@ var DiagnosticContext = class {
|
|
|
37979
37793
|
async print(label, value) {
|
|
37980
37794
|
await this.streams.stdout(Buffer.from(label.padEnd(24) + value + "\n"));
|
|
37981
37795
|
}
|
|
37796
|
+
/** Reject unsupported shims before asking the command owner to launch a probe. */
|
|
37797
|
+
async probeTarget(name2) {
|
|
37798
|
+
const executable = await this.commands.resolve(name2);
|
|
37799
|
+
if (!executable) return null;
|
|
37800
|
+
try {
|
|
37801
|
+
return await commandTarget(executable);
|
|
37802
|
+
} catch {
|
|
37803
|
+
return null;
|
|
37804
|
+
}
|
|
37805
|
+
}
|
|
37982
37806
|
async query(name2, argv) {
|
|
37983
37807
|
if (!this.commandQueries) return null;
|
|
37984
|
-
|
|
37808
|
+
const target = await this.probeTarget(name2);
|
|
37809
|
+
if (!target) return null;
|
|
37985
37810
|
try {
|
|
37986
|
-
const result = await this.commands.capture(
|
|
37811
|
+
const result = await this.commands.capture(target.executable, [...target.prefix, ...argv]);
|
|
37987
37812
|
if (result.status !== 0) return null;
|
|
37988
37813
|
if (result.claim.kind !== "released" && process.platform !== "darwin") return null;
|
|
37989
37814
|
return result.stdout.trim();
|
|
@@ -37995,11 +37820,11 @@ var DiagnosticContext = class {
|
|
|
37995
37820
|
if (!this.commandQueries) {
|
|
37996
37821
|
let prepared, config;
|
|
37997
37822
|
try {
|
|
37998
|
-
prepared = await json(
|
|
37823
|
+
prepared = await json(path18.join(this.paths.gestaltHome, "runtime/context-mode/.context-mode-prepared.json"));
|
|
37999
37824
|
} catch {
|
|
38000
37825
|
}
|
|
38001
37826
|
try {
|
|
38002
|
-
config = parse(await readFile8(
|
|
37827
|
+
config = parse(await readFile8(path18.join(this.paths.codexHome, "config.toml"), "utf8"));
|
|
38003
37828
|
} catch {
|
|
38004
37829
|
}
|
|
38005
37830
|
const installed2 = [];
|
|
@@ -38008,7 +37833,7 @@ var DiagnosticContext = class {
|
|
|
38008
37833
|
if (!version2) continue;
|
|
38009
37834
|
const override = this.invocation.environment[name2 === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT"];
|
|
38010
37835
|
try {
|
|
38011
|
-
const manifest = await json(
|
|
37836
|
+
const manifest = await json(path18.join(override || path18.join(this.paths.codexHome, "plugins/cache", this.paths.marketplaceName, name2, version2), ".codex-plugin/plugin.json"));
|
|
38012
37837
|
if (manifest.name === name2 && manifest.version === version2) installed2.push({ name: name2, version: version2, enabled: config?.plugins?.[name2 + "@" + this.paths.marketplaceName]?.enabled !== false });
|
|
38013
37838
|
} catch {
|
|
38014
37839
|
}
|
|
@@ -38024,20 +37849,29 @@ var DiagnosticContext = class {
|
|
|
38024
37849
|
}
|
|
38025
37850
|
}
|
|
38026
37851
|
async executableVersion(name2) {
|
|
38027
|
-
if (this.commandQueries) return this.query(name2, ["--version"]);
|
|
38028
37852
|
const executable = await this.commands.resolve(name2);
|
|
38029
37853
|
if (!executable) return null;
|
|
37854
|
+
if (name2 === "npm" && process.platform === "win32" && path18.basename(executable).toLowerCase() === "npm.cmd") {
|
|
37855
|
+
try {
|
|
37856
|
+
const root = path18.join(path18.dirname(executable), "node_modules/npm");
|
|
37857
|
+
const manifest = await json(path18.join(root, "package.json"));
|
|
37858
|
+
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())
|
|
37859
|
+
return manifest.version + " (package metadata; command not run)";
|
|
37860
|
+
} catch {
|
|
37861
|
+
}
|
|
37862
|
+
}
|
|
37863
|
+
if (this.commandQueries) return this.query(name2, ["--version"]);
|
|
38030
37864
|
try {
|
|
38031
37865
|
const target = await commandTarget(executable);
|
|
38032
|
-
let directory =
|
|
37866
|
+
let directory = path18.dirname(target.prefix[0] || executable);
|
|
38033
37867
|
for (let depth = 0; depth < 7; depth++) {
|
|
38034
37868
|
try {
|
|
38035
|
-
const manifest = await json(
|
|
37869
|
+
const manifest = await json(path18.join(directory, "package.json"));
|
|
38036
37870
|
if ((manifest.name === "@openai/codex" || manifest.name?.startsWith("@openai/codex-")) && name2 === "codex" && typeof manifest.version === "string" && /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(manifest.version))
|
|
38037
37871
|
return manifest.version + " (package metadata; command not run)";
|
|
38038
37872
|
} catch {
|
|
38039
37873
|
}
|
|
38040
|
-
const parent =
|
|
37874
|
+
const parent = path18.dirname(directory);
|
|
38041
37875
|
if (parent === directory) break;
|
|
38042
37876
|
directory = parent;
|
|
38043
37877
|
}
|
|
@@ -38054,22 +37888,22 @@ var DiagnosticContext = class {
|
|
|
38054
37888
|
async runtime(version2) {
|
|
38055
37889
|
const environment = this.invocation.environment;
|
|
38056
37890
|
if (environment.GESTALT_CONTEXT_MODE_RUNTIME) return environment.GESTALT_CONTEXT_MODE_RUNTIME;
|
|
38057
|
-
const root =
|
|
38058
|
-
if (!await optionalStat(
|
|
38059
|
-
const legacy =
|
|
38060
|
-
if (await optionalStat(
|
|
37891
|
+
const root = path18.join(this.paths.gestaltHome, "runtime/context-mode");
|
|
37892
|
+
if (!await optionalStat(path18.join(root, ".context-mode-prepared.json"))) {
|
|
37893
|
+
const legacy = path18.join(root, version2 ?? await this.version("context-mode"), [process.platform, process.arch, "node-" + process.versions.modules].join("-"));
|
|
37894
|
+
if (await optionalStat(path18.join(legacy, ".context-mode-prepared.json"))) return legacy;
|
|
38061
37895
|
}
|
|
38062
37896
|
return root;
|
|
38063
37897
|
}
|
|
38064
37898
|
mobile() {
|
|
38065
|
-
return this.invocation.environment.GESTALT_MOBILE_BIN ||
|
|
37899
|
+
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
37900
|
}
|
|
38067
37901
|
async managedPath(name2) {
|
|
38068
37902
|
const p = this.paths, env = this.invocation.environment;
|
|
38069
37903
|
const fixed = {
|
|
38070
|
-
bin:
|
|
38071
|
-
"org-plan":
|
|
38072
|
-
"context-mode-cli":
|
|
37904
|
+
bin: path18.join(p.gestaltHome, "bin"),
|
|
37905
|
+
"org-plan": path18.join(p.gestaltHome, "bin/org-plan"),
|
|
37906
|
+
"context-mode-cli": path18.join(p.gestaltHome, "bin/context-mode"),
|
|
38073
37907
|
mobile: this.mobile(),
|
|
38074
37908
|
"codex-home": p.codexHome,
|
|
38075
37909
|
"gestalt-home": p.gestaltHome
|
|
@@ -38078,7 +37912,7 @@ var DiagnosticContext = class {
|
|
|
38078
37912
|
if (name2 === "context-mode" || name2 === "context-mode-runtime") return this.runtime();
|
|
38079
37913
|
if (name2 === "context-mode-plugin" || name2 === "gestalt-plugin") {
|
|
38080
37914
|
const plugin = name2 === "gestalt-plugin" ? "gestalt" : "context-mode", key = plugin === "gestalt" ? "GESTALT_AGENTS_PLUGIN_ROOT" : "GESTALT_CONTEXT_MODE_PLUGIN_ROOT";
|
|
38081
|
-
return env[key] ||
|
|
37915
|
+
return env[key] || path18.join(p.codexHome, "plugins/cache", p.marketplaceName, plugin, await this.version(plugin));
|
|
38082
37916
|
}
|
|
38083
37917
|
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
37918
|
}
|
|
@@ -38086,7 +37920,7 @@ var DiagnosticContext = class {
|
|
|
38086
37920
|
async function verifyContextRuntime(context) {
|
|
38087
37921
|
const inventory = await context.inventory(), gestalt = await context.version("gestalt", inventory), version2 = await context.version("context-mode", inventory);
|
|
38088
37922
|
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(
|
|
37923
|
+
const runtime = await context.runtime(version2), marker = await json(path18.join(runtime, ".context-mode-prepared.json"));
|
|
38090
37924
|
if (marker.packageVersion !== version2 || marker.platform !== process.platform || marker.arch !== process.arch || marker.nodeModulesAbi !== process.versions.modules)
|
|
38091
37925
|
throw new Error(`context-mode ${version2} runtime is not prepared for this target/Node ABI: ${runtime}`);
|
|
38092
37926
|
const installed2 = (Array.isArray(inventory) ? inventory : inventory?.installed) ?? [];
|
|
@@ -38094,11 +37928,11 @@ async function verifyContextRuntime(context) {
|
|
|
38094
37928
|
throw new Error("context-mode plugin source must remain disabled; run gestalt install or gestalt update to restore the native MCP bridge");
|
|
38095
37929
|
let value;
|
|
38096
37930
|
try {
|
|
38097
|
-
value = context.commandQueries ? JSON.parse(await context.query("codex", ["mcp", "get", "context-mode", "--json"]) ?? "null") : parse(await readFile8(
|
|
37931
|
+
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
37932
|
} catch {
|
|
38099
37933
|
}
|
|
38100
37934
|
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] !==
|
|
37935
|
+
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
37936
|
throw new Error("context-mode native MCP bridge is missing or disabled; run gestalt install or gestalt update");
|
|
38103
37937
|
return runtime;
|
|
38104
37938
|
}
|
|
@@ -38125,7 +37959,7 @@ async function version(context, metadata) {
|
|
|
38125
37959
|
}
|
|
38126
37960
|
let serena;
|
|
38127
37961
|
try {
|
|
38128
|
-
const descriptor = await json(
|
|
37962
|
+
const descriptor = await json(path18.join(context.paths.gestaltHome, "serena/active.json"));
|
|
38129
37963
|
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
37964
|
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
37965
|
const uv = await context.query(descriptor.uv, ["--version"]), value = JSON.parse(py ?? "null"), match = uv?.match(/^uv (\d+\.\d+\.\d+)(?:[ (]|$)/);
|
|
@@ -38135,7 +37969,7 @@ async function version(context, metadata) {
|
|
|
38135
37969
|
await context.print("Serena", serena?.serena ?? "NOT INSTALLED (optional)");
|
|
38136
37970
|
let browser = "NOT INSTALLED (optional)", browserPresent = false;
|
|
38137
37971
|
try {
|
|
38138
|
-
const descriptor = await json(
|
|
37972
|
+
const descriptor = await json(path18.join(context.paths.gestaltHome, "playwright/active.json"));
|
|
38139
37973
|
browserPresent = true;
|
|
38140
37974
|
browser = descriptor.schemaVersion === 1 && descriptor.contractVersion === 1 && /^\d+\.\d+\.\d+$/.test(descriptor.version) ? descriptor.version : "INVALID INSTALLATION";
|
|
38141
37975
|
} catch {
|
|
@@ -38197,7 +38031,7 @@ async function doctor(context, argv, metadata) {
|
|
|
38197
38031
|
else if (argv[index] === "--cwd" && selected === void 0 && argv[index + 1] !== void 0) selected = argv[++index];
|
|
38198
38032
|
else throw new Error("usage: gestalt doctor [--cwd ROOT] [--probe-sandbox]");
|
|
38199
38033
|
}
|
|
38200
|
-
const workspace = await realpath7(selected ?
|
|
38034
|
+
const workspace = await realpath7(selected ? path18.resolve(context.invocation.cwd, selected) : context.invocation.cwd);
|
|
38201
38035
|
if (!(await lstat9(workspace)).isDirectory()) throw new Error("doctor workspace must be an existing directory");
|
|
38202
38036
|
let failed = false;
|
|
38203
38037
|
await context.streams.stdout(Buffer.from(`Gestalt manager ${metadata.version}
|
|
@@ -38212,8 +38046,8 @@ async function doctor(context, argv, metadata) {
|
|
|
38212
38046
|
await context.print(label, value ?? "MISSING OR UNVERIFIED");
|
|
38213
38047
|
if (value === null) failed = true;
|
|
38214
38048
|
}
|
|
38215
|
-
const marketplace =
|
|
38216
|
-
const setup = await optionalStat(
|
|
38049
|
+
const marketplace = path18.join(context.paths.codexHome, ".tmp/marketplaces", context.paths.marketplaceName);
|
|
38050
|
+
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
38051
|
await context.print("Agents marketplace", setup?.isFile() ? "present" : "MISSING");
|
|
38218
38052
|
if (!setup?.isFile()) failed = true;
|
|
38219
38053
|
const inventory = await context.inventory();
|
|
@@ -38235,8 +38069,8 @@ async function doctor(context, argv, metadata) {
|
|
|
38235
38069
|
if (mobile === null && process.platform !== "win32") failed = true;
|
|
38236
38070
|
let agentsManifest, mobileManifest;
|
|
38237
38071
|
for (const [component2, file] of [
|
|
38238
|
-
["agents",
|
|
38239
|
-
["mobile",
|
|
38072
|
+
["agents", path18.join(marketplace, "plugins/gestalt/gestalt-supervision-capabilities.json")],
|
|
38073
|
+
["mobile", path18.join(context.paths.gestaltHome, "mobile/node_modules/gestalt-mobile/gestalt-supervision-capabilities.json")]
|
|
38240
38074
|
]) {
|
|
38241
38075
|
try {
|
|
38242
38076
|
if ((await lstat9(file)).size > 16384) throw new Error("manifest exceeds supported size");
|
|
@@ -38253,10 +38087,11 @@ async function doctor(context, argv, metadata) {
|
|
|
38253
38087
|
await context.streams.stdout(Buffer.from("\nOptional skill collection\n"));
|
|
38254
38088
|
const skillsContext = new SetupContext(context.invocation, context.streams, context.paths, metadata.version);
|
|
38255
38089
|
if (await manageSkills(skillsContext, "status") !== 0) failed = true;
|
|
38256
|
-
|
|
38090
|
+
const codex = context.commandQueries ? await context.probeTarget("codex") : null;
|
|
38091
|
+
if (codex) {
|
|
38257
38092
|
const args = ["doctor", "--summary", "--ascii", "--no-color"];
|
|
38258
38093
|
try {
|
|
38259
|
-
const config = parse(await readFile8(
|
|
38094
|
+
const config = parse(await readFile8(path18.join(context.paths.codexHome, "config.toml"), "utf8"));
|
|
38260
38095
|
const removed = /* @__PURE__ */ new Set(["GESTALT_SESSION_TMP_CONTEXT", "TMPDIR", "TMP", "TEMP"]);
|
|
38261
38096
|
for (const [name2, server] of Object.entries(config.mcp_servers ?? {})) {
|
|
38262
38097
|
if (!isGestaltManagedMcp(name2, server, { manager: context.paths.manager, codexHome: context.paths.codexHome })) continue;
|
|
@@ -38266,14 +38101,14 @@ async function doctor(context, argv, metadata) {
|
|
|
38266
38101
|
} catch {
|
|
38267
38102
|
}
|
|
38268
38103
|
await context.streams.stdout(Buffer.from("\nCodex doctor\n"));
|
|
38269
|
-
const result = await context.commands.capture(
|
|
38104
|
+
const result = await context.commands.capture(codex.executable, [...codex.prefix, ...args]);
|
|
38270
38105
|
await context.streams.stdout(Buffer.from(result.stdout));
|
|
38271
38106
|
await context.streams.stderr(Buffer.from(result.stderr));
|
|
38272
38107
|
if (result.status !== 0 || result.claim.kind !== "released" && process.platform !== "darwin") failed = true;
|
|
38273
38108
|
}
|
|
38274
|
-
if (context.commandQueries && runtime && await optionalStat(
|
|
38109
|
+
if (context.commandQueries && runtime && await optionalStat(path18.join(runtime, "cli.bundle.mjs"))) {
|
|
38275
38110
|
await context.streams.stdout(Buffer.from("\nContext-mode doctor\n"));
|
|
38276
|
-
const result = await context.commands.capture(process.execPath, [
|
|
38111
|
+
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
38112
|
await context.streams.stdout(Buffer.from(result.stdout));
|
|
38278
38113
|
await context.streams.stderr(Buffer.from(result.stderr));
|
|
38279
38114
|
if (result.status !== 0) failed = true;
|
|
@@ -38291,7 +38126,7 @@ async function doctor(context, argv, metadata) {
|
|
|
38291
38126
|
if (sandbox.diagnostic) await context.streams.stdout(Buffer.from(sandbox.diagnostic + "\n"));
|
|
38292
38127
|
if (sandbox.retained) await context.print("Retained probe state", sandbox.retained);
|
|
38293
38128
|
for (const [name2, label] of [["serena", "Serena"], ["playwright", "Playwright"]]) {
|
|
38294
|
-
const present = await optionalStat(
|
|
38129
|
+
const present = await optionalStat(path18.join(context.paths.gestaltHome, name2, "active.json"));
|
|
38295
38130
|
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
38131
|
if (present && process.platform !== "win32") failed = true;
|
|
38297
38132
|
}
|
|
@@ -38319,6 +38154,234 @@ function createDiagnosticHandlers(metadata, port, ownershipHelper) {
|
|
|
38319
38154
|
return { path: wrap(paths), version: wrap((context) => version(context, metadata)), doctor: wrap((context, argv) => doctor(context, argv, metadata)) };
|
|
38320
38155
|
}
|
|
38321
38156
|
|
|
38157
|
+
// src/cli/setup/commands.ts
|
|
38158
|
+
var retirement = "Xerj has been retired; run gestalt update to migrate managed configuration. User data is retained.";
|
|
38159
|
+
function parseUpdateOptions(argv) {
|
|
38160
|
+
let component2 = "all", selected = false, extra = false;
|
|
38161
|
+
for (let index = 0; index < argv.length; index++) {
|
|
38162
|
+
const token = argv[index];
|
|
38163
|
+
if (token === "xerj") throw new Error(retirement);
|
|
38164
|
+
if (token === "--extra-skills") {
|
|
38165
|
+
extra = true;
|
|
38166
|
+
continue;
|
|
38167
|
+
}
|
|
38168
|
+
if (token === "--help" || token === "-h") return { component: component2, extra, help: true };
|
|
38169
|
+
if (token === "--component") {
|
|
38170
|
+
if (!argv[index + 1]) throw new Error("--component requires all, gestalt, serena, or playwright");
|
|
38171
|
+
if (selected) throw new Error("select only one update component");
|
|
38172
|
+
component2 = argv[++index];
|
|
38173
|
+
selected = true;
|
|
38174
|
+
} else if (["all", "gestalt", "serena", "playwright"].includes(token)) {
|
|
38175
|
+
if (selected) throw new Error("select only one update component");
|
|
38176
|
+
component2 = token;
|
|
38177
|
+
selected = true;
|
|
38178
|
+
} else throw new Error(`unknown update option or component: ${token} (run 'gestalt update --help')`);
|
|
38179
|
+
}
|
|
38180
|
+
if (component2 === "xerj") throw new Error(retirement);
|
|
38181
|
+
if (!["all", "gestalt", "serena", "playwright"].includes(component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, serena, or playwright)`);
|
|
38182
|
+
if (extra && !["all", "gestalt"].includes(component2)) throw new Error("--extra-skills requires the all or gestalt update component");
|
|
38183
|
+
return { component: component2, extra, help: false };
|
|
38184
|
+
}
|
|
38185
|
+
function parseSetupOptions(argv) {
|
|
38186
|
+
let extra = false;
|
|
38187
|
+
for (const token of argv) {
|
|
38188
|
+
if (token === "--extra-skills") extra = true;
|
|
38189
|
+
else if (token === "--help" || token === "-h") return { extra, help: true };
|
|
38190
|
+
else throw new Error(`unknown setup option: ${token}`);
|
|
38191
|
+
}
|
|
38192
|
+
return { extra, help: false };
|
|
38193
|
+
}
|
|
38194
|
+
var defaults = {
|
|
38195
|
+
agents: setupAgents,
|
|
38196
|
+
skills: async (context, mode) => {
|
|
38197
|
+
await context.require("git");
|
|
38198
|
+
const unlisten = context.listen();
|
|
38199
|
+
try {
|
|
38200
|
+
await manageSkills(context, mode);
|
|
38201
|
+
} finally {
|
|
38202
|
+
unlisten();
|
|
38203
|
+
}
|
|
38204
|
+
},
|
|
38205
|
+
mobile: (context) => installMobile(context),
|
|
38206
|
+
manager: updateManager,
|
|
38207
|
+
component: async (_context, component2) => {
|
|
38208
|
+
throw new Error(`native ${component2} update is not available in this development artifact`);
|
|
38209
|
+
},
|
|
38210
|
+
diagnostics: runUpdateDiagnostics
|
|
38211
|
+
};
|
|
38212
|
+
async function runUpdateDiagnostics(context) {
|
|
38213
|
+
await context.log("running post-update diagnostics");
|
|
38214
|
+
const stopListening = context.listen();
|
|
38215
|
+
let diagnostic;
|
|
38216
|
+
try {
|
|
38217
|
+
diagnostic = new DiagnosticContext(
|
|
38218
|
+
context.paths,
|
|
38219
|
+
{ ...context.invocation, environment: context.environment },
|
|
38220
|
+
context.streams,
|
|
38221
|
+
await context.managedCommands(),
|
|
38222
|
+
true
|
|
38223
|
+
);
|
|
38224
|
+
if (await doctor(diagnostic, [], { version: context.version }) !== 0)
|
|
38225
|
+
await context.log("post-update diagnostics reported a problem; see the checks above");
|
|
38226
|
+
} catch (error) {
|
|
38227
|
+
await context.log(`post-update diagnostics could not complete: ${error instanceof Error ? error.message : String(error)}`);
|
|
38228
|
+
} finally {
|
|
38229
|
+
await diagnostic?.commands.stop();
|
|
38230
|
+
stopListening();
|
|
38231
|
+
}
|
|
38232
|
+
context.check();
|
|
38233
|
+
}
|
|
38234
|
+
function deferredSelection(component2, platform) {
|
|
38235
|
+
if (platform !== "win32" || !["serena", "playwright", "mobile"].includes(component2)) return;
|
|
38236
|
+
const prerequisite = component2 === "mobile" ? mobileHostSupport(platform).prerequisite : `use an existing supported Unix Gestalt installation for ${component2}`;
|
|
38237
|
+
return `native ${component2} support is deferred in this core release; ${prerequisite}`;
|
|
38238
|
+
}
|
|
38239
|
+
function requireSelection(component2, platform) {
|
|
38240
|
+
const message2 = deferredSelection(component2, platform);
|
|
38241
|
+
if (message2) throw new Error(message2);
|
|
38242
|
+
}
|
|
38243
|
+
async function optionalMobile(context, operations, platform) {
|
|
38244
|
+
const support = mobileHostSupport(platform);
|
|
38245
|
+
if (support.supported) return operations.mobile(context);
|
|
38246
|
+
await context.log(`Mobile omitted: ${support.prerequisite}; Gestalt CLI and Agents remain available`);
|
|
38247
|
+
return false;
|
|
38248
|
+
}
|
|
38249
|
+
async function deferredOmission(context, component2, platform) {
|
|
38250
|
+
await context.log(`${component2 === "serena" ? "Serena" : "Playwright"} omitted: ${deferredSelection(component2, platform)}`);
|
|
38251
|
+
}
|
|
38252
|
+
async function runInstall(context, extra, operations = defaults, platform = process.platform) {
|
|
38253
|
+
await context.prepareHomes();
|
|
38254
|
+
await operations.skills(context, "install");
|
|
38255
|
+
await operations.agents(context, "install", extra);
|
|
38256
|
+
const mobile = await optionalMobile(context, operations, platform);
|
|
38257
|
+
if (platform === "win32") for (const component2 of ["serena", "playwright"])
|
|
38258
|
+
await deferredOmission(context, component2, platform);
|
|
38259
|
+
await context.log(mobile === false ? "installation complete; run 'gestalt doctor', then 'gestalt cli'" : "installation complete; run 'gestalt doctor', then 'gestalt cli' or 'gestalt mobile'");
|
|
38260
|
+
}
|
|
38261
|
+
async function runUpdate(context, options, originalArgv, resumed, operations = defaults, platform = process.platform) {
|
|
38262
|
+
requireSelection(options.component, platform);
|
|
38263
|
+
if (options.component === "all" || options.component === "gestalt") {
|
|
38264
|
+
if (await operations.manager(context, originalArgv, resumed)) return true;
|
|
38265
|
+
await context.prepareHomes();
|
|
38266
|
+
for (const notice of retireManagedConfiguration(context.paths.codexHome, context.paths.gestaltHome, context.paths.manager))
|
|
38267
|
+
await context.log(`Xerj retirement: ${notice} preserved; review legacy Xerj entries/processes manually, then retry update. User data and binaries are retained.`);
|
|
38268
|
+
await operations.skills(context, "update");
|
|
38269
|
+
await operations.agents(context, "upgrade", options.extra);
|
|
38270
|
+
const mobile = await optionalMobile(context, operations, platform);
|
|
38271
|
+
const summary = mobile === false ? "Agents, optional skills, and context-mode" : "Agents, optional skills, Mobile, and context-mode";
|
|
38272
|
+
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`);
|
|
38273
|
+
}
|
|
38274
|
+
for (const component2 of ["serena", "playwright"]) {
|
|
38275
|
+
if (platform === "win32") {
|
|
38276
|
+
if (options.component === "all") await deferredOmission(context, component2, platform);
|
|
38277
|
+
continue;
|
|
38278
|
+
}
|
|
38279
|
+
if (options.component === component2 || options.component === "all" && await optionalStat(path19.join(context.paths.gestaltHome, component2, "active.json")))
|
|
38280
|
+
await operations.component(context, component2);
|
|
38281
|
+
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)");
|
|
38282
|
+
}
|
|
38283
|
+
if (options.component === "all" || options.component === "gestalt") await operations.diagnostics?.(context);
|
|
38284
|
+
await context.log(`update complete (${options.component})`);
|
|
38285
|
+
return false;
|
|
38286
|
+
}
|
|
38287
|
+
function createSetupHandlers(metadata, operations = defaults, resumed = false, managed, platform = process.platform, ownershipHelper) {
|
|
38288
|
+
const selectionGuard = (handler) => async (invocation, streams) => {
|
|
38289
|
+
if (!invocation.argv.some((token) => ["--help", "-h", "xerj"].includes(token))) {
|
|
38290
|
+
for (const token of invocation.argv) {
|
|
38291
|
+
const component2 = token.startsWith("--component=") ? token.slice("--component=".length) : token;
|
|
38292
|
+
const message2 = deferredSelection(component2, platform);
|
|
38293
|
+
if (message2) {
|
|
38294
|
+
await streams.stderr(Buffer.from(`gestalt: ${message2}. No profile or installation was changed.
|
|
38295
|
+
`));
|
|
38296
|
+
return 1;
|
|
38297
|
+
}
|
|
38298
|
+
}
|
|
38299
|
+
}
|
|
38300
|
+
return handler(invocation, streams);
|
|
38301
|
+
};
|
|
38302
|
+
const wrap = (command, body) => async (invocation, streams) => {
|
|
38303
|
+
let context;
|
|
38304
|
+
try {
|
|
38305
|
+
const environment = scratchEnvironment(invocation.environment);
|
|
38306
|
+
context = new SetupContext(
|
|
38307
|
+
{ ...invocation, environment },
|
|
38308
|
+
streams,
|
|
38309
|
+
await setupPaths(environment, ownershipHelper),
|
|
38310
|
+
metadata.version,
|
|
38311
|
+
managed?.commands,
|
|
38312
|
+
managed?.signal
|
|
38313
|
+
);
|
|
38314
|
+
context.check();
|
|
38315
|
+
return await body(context, invocation.argv);
|
|
38316
|
+
} catch (error) {
|
|
38317
|
+
await streams.stderr(Buffer.from(`gestalt: ${error instanceof Error ? error.message : `${command} failed`}
|
|
38318
|
+
`));
|
|
38319
|
+
return error instanceof CommandFailure ? error.status : 1;
|
|
38320
|
+
} finally {
|
|
38321
|
+
if (context) {
|
|
38322
|
+
await context.stopActive();
|
|
38323
|
+
if (!context.canRollback()) managed?.unknown();
|
|
38324
|
+
}
|
|
38325
|
+
}
|
|
38326
|
+
};
|
|
38327
|
+
return {
|
|
38328
|
+
agents: wrap("agents", async (context, argv) => {
|
|
38329
|
+
if (!argv.length || argv.length === 1 && ["help", "-h", "--help"].includes(argv[0])) {
|
|
38330
|
+
await context.streams.stdout(Buffer.from("Usage: gestalt agents install|update\nInstall or reconcile Gestalt Agents and their context-mode runtime.\n"));
|
|
38331
|
+
return 0;
|
|
38332
|
+
}
|
|
38333
|
+
if (argv.length !== 1 || !["install", "update"].includes(argv[0])) throw new Error("usage: gestalt agents install|update");
|
|
38334
|
+
await operations.agents(context, argv[0] === "install" ? "install" : "upgrade", false);
|
|
38335
|
+
return 0;
|
|
38336
|
+
}),
|
|
38337
|
+
install: selectionGuard(wrap("install", async (context, argv) => {
|
|
38338
|
+
const options = parseSetupOptions(argv);
|
|
38339
|
+
if (options.help) {
|
|
38340
|
+
await context.streams.stdout(Buffer.from(metadata.help));
|
|
38341
|
+
return 0;
|
|
38342
|
+
}
|
|
38343
|
+
await runInstall(context, options.extra, operations, platform);
|
|
38344
|
+
return 0;
|
|
38345
|
+
})),
|
|
38346
|
+
update: selectionGuard(wrap("update", async (context, argv) => {
|
|
38347
|
+
const options = parseUpdateOptions(argv);
|
|
38348
|
+
if (options.help) {
|
|
38349
|
+
await context.streams.stdout(Buffer.from(metadata.help));
|
|
38350
|
+
return 0;
|
|
38351
|
+
}
|
|
38352
|
+
await runUpdate(context, options, ["update", ...argv], resumed, operations, platform);
|
|
38353
|
+
return 0;
|
|
38354
|
+
})),
|
|
38355
|
+
"update-restart": selectionGuard(wrap("update-restart", async (context, argv) => {
|
|
38356
|
+
const options = parseUpdateOptions(argv);
|
|
38357
|
+
if (options.help) {
|
|
38358
|
+
await context.streams.stdout(Buffer.from(metadata.help));
|
|
38359
|
+
return 0;
|
|
38360
|
+
}
|
|
38361
|
+
await scheduleRestart(context, options.component, options.extra);
|
|
38362
|
+
return 0;
|
|
38363
|
+
})),
|
|
38364
|
+
"__updated-manager": async (invocation, streams) => {
|
|
38365
|
+
const [command, ...argv] = invocation.argv;
|
|
38366
|
+
const handlers = createSetupHandlers(metadata, operations, true, managed, platform, ownershipHelper);
|
|
38367
|
+
const handler = command && Object.hasOwn(handlers, command) ? handlers[command] : void 0;
|
|
38368
|
+
if (!handler || command === "__updated-manager") {
|
|
38369
|
+
await streams.stderr(Buffer.from("gestalt: invalid updated-manager continuation\n"));
|
|
38370
|
+
return 1;
|
|
38371
|
+
}
|
|
38372
|
+
return handler({ ...invocation, argv }, streams);
|
|
38373
|
+
},
|
|
38374
|
+
"__update-restart-worker": wrap("__update-restart-worker", async (context, argv) => restartWorker(context, argv, (worker, component2, extra) => runUpdate(
|
|
38375
|
+
worker,
|
|
38376
|
+
parseUpdateOptions([component2, ...extra ? ["--extra-skills"] : []]),
|
|
38377
|
+
["__update-restart-worker", ...argv],
|
|
38378
|
+
resumed,
|
|
38379
|
+
operations,
|
|
38380
|
+
platform
|
|
38381
|
+
)))
|
|
38382
|
+
};
|
|
38383
|
+
}
|
|
38384
|
+
|
|
38322
38385
|
// src/cli/runtime/skills.ts
|
|
38323
38386
|
init_context();
|
|
38324
38387
|
init_scratch_context();
|
|
@@ -38327,12 +38390,12 @@ init_skills_owner();
|
|
|
38327
38390
|
// src/cli/runtime/skills-transfer.ts
|
|
38328
38391
|
import path21 from "node:path";
|
|
38329
38392
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
38330
|
-
import { cp as cp2, link, lstat as lstat11, mkdir as
|
|
38393
|
+
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";
|
|
38331
38394
|
|
|
38332
38395
|
// src/cli/platform/archive.ts
|
|
38333
38396
|
init_windows_system();
|
|
38334
38397
|
import { constants as constants4 } from "node:fs";
|
|
38335
|
-
import { lstat as lstat10, open as open4, readdir, mkdir as
|
|
38398
|
+
import { lstat as lstat10, open as open4, readdir, mkdir as mkdir5, realpath as realpath8, writeFile as writeFile2 } from "node:fs/promises";
|
|
38336
38399
|
import path20 from "node:path";
|
|
38337
38400
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
38338
38401
|
var maximumArchive = 64 * 1024 * 1024;
|
|
@@ -38456,7 +38519,7 @@ var NativeArchives = class {
|
|
|
38456
38519
|
for (const part of relative.split("/").filter(Boolean)) {
|
|
38457
38520
|
cursor = path20.join(cursor, part);
|
|
38458
38521
|
try {
|
|
38459
|
-
await
|
|
38522
|
+
await mkdir5(cursor, { mode: 448 });
|
|
38460
38523
|
} catch (error) {
|
|
38461
38524
|
if (error.code !== "EEXIST") throw error;
|
|
38462
38525
|
}
|
|
@@ -38592,11 +38655,11 @@ async function exportSkills(context, argv) {
|
|
|
38592
38655
|
let skillCount = 0, profileCount = 0;
|
|
38593
38656
|
const temporary = path21.join(parent, `.gestalt-skills-${randomUUID8()}.tar.gz`);
|
|
38594
38657
|
try {
|
|
38595
|
-
await
|
|
38658
|
+
await mkdir6(bundle, { mode: 448 });
|
|
38596
38659
|
for (let index = 0; index < categories.length; index++) {
|
|
38597
38660
|
context.check();
|
|
38598
38661
|
const source = destinations[index], destination = path21.join(bundle, categories[index]);
|
|
38599
|
-
await
|
|
38662
|
+
await mkdir6(destination, { mode: 448 });
|
|
38600
38663
|
const info = await optionalStat(source);
|
|
38601
38664
|
if (!info) continue;
|
|
38602
38665
|
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`skill root must be a directory without links: ${source}`);
|
|
@@ -39640,7 +39703,7 @@ async function launchCapabilities(commands, invocation, manager) {
|
|
|
39640
39703
|
|
|
39641
39704
|
// src/cli/runtime/cli.ts
|
|
39642
39705
|
var administrative = ["-h", "--help", "-V", "--version", "help", "login", "logout", "plugin", "mcp", "doctor", "features", "completion"];
|
|
39643
|
-
function cliHandler(
|
|
39706
|
+
function cliHandler(owned = false, port, terminal) {
|
|
39644
39707
|
return async (invocation, streams) => {
|
|
39645
39708
|
let commands, unlisten;
|
|
39646
39709
|
let primary = null;
|
|
@@ -39677,14 +39740,10 @@ function cliHandler(metadata, owned = false, port, terminal) {
|
|
|
39677
39740
|
unlisten = commands.listen();
|
|
39678
39741
|
const codex = await commands.resolve("codex");
|
|
39679
39742
|
if (!codex) throw new Error("codex is required and was not found on PATH");
|
|
39680
|
-
const diagnostic = new DiagnosticContext(paths2, selected, streams, port);
|
|
39681
39743
|
const required = new DiagnosticContext(paths2, selected, streams, port, true), unlistenDiagnostic = required.commands.listen();
|
|
39682
39744
|
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
39745
|
await verifyContextRuntime(required);
|
|
39746
|
+
if (required.commands.interrupted) return required.commands.interrupted;
|
|
39688
39747
|
} finally {
|
|
39689
39748
|
await required.commands.stop();
|
|
39690
39749
|
unlistenDiagnostic();
|
|
@@ -39735,8 +39794,8 @@ function createRuntimeHandlers(metadata, terminal, ownershipHelper) {
|
|
|
39735
39794
|
scratch: scratchHandler,
|
|
39736
39795
|
"__scratch-hook": scratchHookHandler,
|
|
39737
39796
|
"__codex-app-server": appServerHandler(),
|
|
39738
|
-
cli: cliHandler(
|
|
39739
|
-
"__cli-owned": cliHandler(
|
|
39797
|
+
cli: cliHandler(false, void 0, terminal),
|
|
39798
|
+
"__cli-owned": cliHandler(true, void 0, terminal),
|
|
39740
39799
|
serena: deferredTool("serena"),
|
|
39741
39800
|
playwright: deferredTool("playwright"),
|
|
39742
39801
|
mobile: async (invocation, streams) => {
|
|
@@ -39794,7 +39853,7 @@ function packagedWindowsHelper() {
|
|
|
39794
39853
|
async function continueUpdatedManager(invocation, streams, options) {
|
|
39795
39854
|
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
39855
|
let unknown = false;
|
|
39797
|
-
const metadata = { version: "0.18.
|
|
39856
|
+
const metadata = { version: "0.18.2", 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
39857
|
const status = await runCli(
|
|
39799
39858
|
{ argv: [...invocation.argv], cwd: invocation.cwd, environment: { ...invocation.environment } },
|
|
39800
39859
|
streams,
|
|
@@ -39841,7 +39900,7 @@ async function main2() {
|
|
|
39841
39900
|
const selected = selectInteractiveRuntime({ legacyManager: fileURLToPath7(new URL("./legacy/gestalt", import.meta.url)) });
|
|
39842
39901
|
if (selected.kind === "unix-compatibility") selected.exec({ argv, cwd: process.cwd(), environment });
|
|
39843
39902
|
}
|
|
39844
|
-
const metadata = { version: "0.18.
|
|
39903
|
+
const metadata = { version: "0.18.2", 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
39904
|
const ownershipHelper = packagedWindowsHelper();
|
|
39846
39905
|
return runCli(
|
|
39847
39906
|
{ argv, cwd: process.cwd(), environment },
|
package/lib/legacy/gestalt
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
set -Eeuo pipefail
|
|
4
4
|
IFS=$'\n\t'
|
|
5
5
|
|
|
6
|
-
readonly GESTALT_CLI_VERSION='0.18.
|
|
6
|
+
readonly GESTALT_CLI_VERSION='0.18.2'
|
|
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'
|
|
@@ -3339,14 +3339,24 @@ configure_codex_permissions() {
|
|
|
3339
3339
|
|
|
3340
3340
|
node --input-type=module - \
|
|
3341
3341
|
"$config_path" "${BASH_SOURCE[0]}" "$codex_home" "$gestalt_home" "$HOME/.agents" \
|
|
3342
|
-
"$HOME/.local" "$HOME/.config" <<'NODE'
|
|
3342
|
+
"$HOME/.local" "$HOME/.config" "$HOME" <<'NODE'
|
|
3343
3343
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
3344
|
-
import { dirname } from 'node:path';
|
|
3344
|
+
import { dirname, isAbsolute, join } from 'node:path';
|
|
3345
3345
|
import { runInNewContext } from 'node:vm';
|
|
3346
3346
|
|
|
3347
3347
|
const configPath = process.argv[2];
|
|
3348
3348
|
const managerPath = process.argv[3];
|
|
3349
|
-
const homeReadRoots = [...new Set(process.argv.slice(4))];
|
|
3349
|
+
const homeReadRoots = [...new Set(process.argv.slice(4, -1))];
|
|
3350
|
+
const userHome = process.argv.at(-1);
|
|
3351
|
+
const { XDG_CACHE_HOME, XDG_RUNTIME_DIR } = process.env;
|
|
3352
|
+
const legacyCache = join(userHome, '.ccache');
|
|
3353
|
+
const cacheHome = isAbsolute(XDG_CACHE_HOME || '') ? XDG_CACHE_HOME
|
|
3354
|
+
: join(userHome, process.platform === 'darwin' ? 'Library/Caches' : '.cache');
|
|
3355
|
+
const cacheDir = statSync(legacyCache, { throwIfNoEntry: false })?.isDirectory()
|
|
3356
|
+
? legacyCache : join(cacheHome, 'ccache');
|
|
3357
|
+
const writeRoots = new Set(['/tmp', cacheDir]);
|
|
3358
|
+
if (isAbsolute(XDG_RUNTIME_DIR || '')) writeRoots.add(join(XDG_RUNTIME_DIR, 'ccache-tmp'));
|
|
3359
|
+
for (const root of homeReadRoots) writeRoots.delete(root);
|
|
3350
3360
|
const bundle = readFileSync(managerPath, 'utf8').match(/^\/\/ BEGIN BUNDLED PROFILE TOML PARSER\n([\s\S]*?)^\/\/ END BUNDLED PROFILE TOML PARSER/m);
|
|
3351
3361
|
if (!bundle) throw new Error('Bundled TOML parser missing');
|
|
3352
3362
|
const { parse } = runInNewContext(bundle[1] + '\ngestaltProfileToml');
|
|
@@ -3396,7 +3406,7 @@ const profile = [
|
|
|
3396
3406
|
'allow_local_binding = true',
|
|
3397
3407
|
'',
|
|
3398
3408
|
'[permissions.workspace-git.filesystem]',
|
|
3399
|
-
|
|
3409
|
+
...[...writeRoots].map((path) => `${JSON.stringify(path)} = "write"`),
|
|
3400
3410
|
...homeReadRoots.map((path) => `${JSON.stringify(path)} = "read"`),
|
|
3401
3411
|
'',
|
|
3402
3412
|
'[permissions.workspace-git.filesystem.":workspace_roots"]',
|
|
@@ -3414,6 +3424,13 @@ if (before && !/[\r\n]$/.test(before)) before += newline;
|
|
|
3414
3424
|
const output = root.join(newline) + newline + before +
|
|
3415
3425
|
profile.filter(line => line !== '').join(newline) + newline + retained.slice(position).join('');
|
|
3416
3426
|
parse(output);
|
|
3427
|
+
if (writeRoots.has(cacheDir)) {
|
|
3428
|
+
// Codex needs an existing mount target for writes beneath a read-only home.
|
|
3429
|
+
try { mkdirSync(cacheDir, { recursive: true, mode: 0o700 }); }
|
|
3430
|
+
catch (error) {
|
|
3431
|
+
if (!['EACCES', 'EPERM', 'EROFS', 'ENOTDIR', 'EEXIST'].includes(error.code)) throw error;
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3417
3434
|
if (output === source) process.exit(0);
|
|
3418
3435
|
|
|
3419
3436
|
mkdirSync(dirname(configPath), { recursive: true });
|
|
@@ -3906,6 +3923,16 @@ command_update() {
|
|
|
3906
3923
|
elif [[ $update_component == all ]]; then
|
|
3907
3924
|
log 'skipping Playwright (not installed; use gestalt playwright install)'
|
|
3908
3925
|
fi
|
|
3926
|
+
log 'running post-update diagnostics'
|
|
3927
|
+
if ! (
|
|
3928
|
+
case $update_component in
|
|
3929
|
+
all | gestalt) command_doctor ;;
|
|
3930
|
+
serena) run_doctor_command 'Serena doctor' command_serena doctor ;;
|
|
3931
|
+
playwright) run_doctor_command 'Playwright doctor' command_playwright doctor ;;
|
|
3932
|
+
esac
|
|
3933
|
+
); then
|
|
3934
|
+
log 'post-update diagnostics reported a problem; see the checks above'
|
|
3935
|
+
fi
|
|
3909
3936
|
log "update complete ($update_component)"
|
|
3910
3937
|
}
|
|
3911
3938
|
|
|
@@ -5198,7 +5225,6 @@ command_cli() {
|
|
|
5198
5225
|
command_cli_owned() {
|
|
5199
5226
|
check_node_version
|
|
5200
5227
|
require_command codex
|
|
5201
|
-
run_startup_diagnostics
|
|
5202
5228
|
verify_context_mode_installation
|
|
5203
5229
|
forwarded_args=("$@")
|
|
5204
5230
|
resolve_manager_target
|
|
@@ -5330,7 +5356,7 @@ command_mobile() {
|
|
|
5330
5356
|
local mobile_restart_dir mobile_restart_state mobile_restart_staged restart_cwd
|
|
5331
5357
|
local context_mode_runtime context_mode_plugin_root gestalt_plugin_root
|
|
5332
5358
|
local plugin_inventory='' gestalt_agents_version='' context_mode_version=''
|
|
5333
|
-
local
|
|
5359
|
+
local mobile_arg_index
|
|
5334
5360
|
|
|
5335
5361
|
strip_separator "$@"
|
|
5336
5362
|
# Reject obsolete manually supplied options before installation or startup.
|
|
@@ -5344,12 +5370,6 @@ command_mobile() {
|
|
|
5344
5370
|
log 'Gestalt Mobile is not installed; installing it now'
|
|
5345
5371
|
install_mobile
|
|
5346
5372
|
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
5373
|
plugin_inventory=$(CODEX_HOME=$codex_home codex plugin list \
|
|
5354
5374
|
--marketplace "$marketplace_name" --json 2>/dev/null) || plugin_inventory=''
|
|
5355
5375
|
if [[ -n $plugin_inventory ]]; then
|
|
@@ -5432,8 +5452,9 @@ command_version() {
|
|
|
5432
5452
|
print_check 'Serena' "${value:-NOT INSTALLED (optional)}"
|
|
5433
5453
|
value=$(command_playwright version 2>/dev/null || true)
|
|
5434
5454
|
print_check 'Playwright' "${value:-NOT INSTALLED (optional)}"
|
|
5435
|
-
|
|
5436
|
-
|
|
5455
|
+
if [[ -n $value ]]; then
|
|
5456
|
+
print_check 'Playwright readiness' 'NOT PROBED (use gestalt playwright doctor)'
|
|
5457
|
+
fi
|
|
5437
5458
|
value=$(serena_versions uv 2>/dev/null || true)
|
|
5438
5459
|
print_check 'uv (Serena)' "${value:-NOT INSTALLED (optional)}"
|
|
5439
5460
|
value=$(serena_versions python 2>/dev/null || true)
|
|
@@ -5794,13 +5815,6 @@ run_doctor_command() {
|
|
|
5794
5815
|
return 1
|
|
5795
5816
|
}
|
|
5796
5817
|
|
|
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
5818
|
run_codex_doctor() {
|
|
5805
5819
|
# Session scratch forwarding is required for session launches, but is optional
|
|
5806
5820
|
# for an operator's read-only diagnostics. Do not invent an owner or edit config.
|
|
@@ -5961,7 +5975,7 @@ command_doctor() {
|
|
|
5961
5975
|
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
5976
|
return 1
|
|
5963
5977
|
fi
|
|
5964
|
-
printf "\nAll
|
|
5978
|
+
printf "\nAll diagnostics passed.\n"
|
|
5965
5979
|
}
|
|
5966
5980
|
|
|
5967
5981
|
main() {
|
|
Binary file
|
|
@@ -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": "
|
|
5
|
+
"artifactSha256": "dfb39729b94b3d6155640d6ce566a967076470617b13ad0b01ec97897babfdf7",
|
|
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-
|
|
26
|
+
"observedAt": "2026-11-24T00:22:51.067Z",
|
|
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.
|
|
4
|
+
"version": "0.18.2",
|
|
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": "
|
|
47
|
+
"gitHead": "1b55ecf70fb71bd1a0171a73bb13b242fe32aa40"
|
|
48
48
|
}
|