@jaromil/gestalt 0.20.3 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -81,6 +81,12 @@ Use `gestalt cli --skill-profile NAME` to select a saved profile directly or
|
|
|
81
81
|
`gestalt cli --no-skill-profile` to use the native Codex selection. Piped and
|
|
82
82
|
administrative commands run without the picker.
|
|
83
83
|
|
|
84
|
+
Use `gestalt cli --cwd DIR` to open the picker and start Codex in that workspace.
|
|
85
|
+
On Unix, loading profiles removes group and other write permission from the
|
|
86
|
+
user's own `~/.gestalt` and `~/.gestalt/skill-profiles` directories when needed.
|
|
87
|
+
`gestalt doctor` reports the offending path and mode without changing either
|
|
88
|
+
directory. A custom `GESTALT_HOME` requires manual permission changes.
|
|
89
|
+
|
|
84
90
|
Update the npm-installed command with:
|
|
85
91
|
|
|
86
92
|
```sh
|
package/lib/gestalt.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// GESTALT_CLI_VERSION='0.
|
|
2
|
+
// GESTALT_CLI_VERSION='0.21.0'
|
|
3
3
|
// GESTALT_UPDATED_MANAGER_API='1'
|
|
4
4
|
/*! tuiuiu.js
|
|
5
5
|
MIT License
|
|
@@ -1155,11 +1155,11 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1155
1155
|
}
|
|
1156
1156
|
function scratchWorkspacePublication(workspace, publish) {
|
|
1157
1157
|
scratchStableNamespace(workspace);
|
|
1158
|
-
const
|
|
1158
|
+
const path32 = scratchPath.join(workspace, ".gestalt-scratch-lock");
|
|
1159
1159
|
let claimed = false;
|
|
1160
1160
|
for (let attempt = 0; attempt < 100; attempt++) {
|
|
1161
1161
|
try {
|
|
1162
|
-
scratchFs.mkdirSync(
|
|
1162
|
+
scratchFs.mkdirSync(path32, { mode: 448 });
|
|
1163
1163
|
claimed = true;
|
|
1164
1164
|
break;
|
|
1165
1165
|
} catch (error) {
|
|
@@ -1168,8 +1168,8 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
1170
|
if (!claimed) throw Error("SESSION_SCRATCH_BUSY");
|
|
1171
|
-
scratchPrivate(
|
|
1172
|
-
const fd = scratchOpenDirectory(
|
|
1171
|
+
scratchPrivate(path32);
|
|
1172
|
+
const fd = scratchOpenDirectory(path32);
|
|
1173
1173
|
const held = scratchDirectoryStat(fd);
|
|
1174
1174
|
try {
|
|
1175
1175
|
const parents = scratchManagedAncestors(workspace).map((ancestor) => ancestor.context.workspacePath);
|
|
@@ -1179,9 +1179,9 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1179
1179
|
return result;
|
|
1180
1180
|
} finally {
|
|
1181
1181
|
try {
|
|
1182
|
-
const current = scratchFs.lstatSync(
|
|
1182
|
+
const current = scratchFs.lstatSync(path32, { bigint: true });
|
|
1183
1183
|
scratchAssert(current.isDirectory() && !current.isSymbolicLink() && current.dev === held.dev && current.ino === held.ino && current.birthtimeNs === held.birthtimeNs);
|
|
1184
|
-
scratchFs.rmdirSync(
|
|
1184
|
+
scratchFs.rmdirSync(path32);
|
|
1185
1185
|
} finally {
|
|
1186
1186
|
scratchCloseDirectory(fd);
|
|
1187
1187
|
}
|
|
@@ -1373,10 +1373,10 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1373
1373
|
const context = scratchOwnerContext(workspace, ownerId);
|
|
1374
1374
|
const ancestor = scratchAncestorOwner(context);
|
|
1375
1375
|
scratchAssert(scratchJson3(context.markerPath).ownerKind === "mobile-session");
|
|
1376
|
-
const
|
|
1377
|
-
const expected = scratchDirectoryIdentity(
|
|
1378
|
-
scratchPrivate(
|
|
1379
|
-
scratchAssert(scratchFs.readdirSync(
|
|
1376
|
+
const path32 = scratchPath.join(context.directory, ".containment-lock");
|
|
1377
|
+
const expected = scratchDirectoryIdentity(path32);
|
|
1378
|
+
scratchPrivate(path32);
|
|
1379
|
+
scratchAssert(scratchFs.readdirSync(path32).length === 0);
|
|
1380
1380
|
for (const name2 of [".controller-lock", ".association-lock"]) {
|
|
1381
1381
|
try {
|
|
1382
1382
|
scratchFs.lstatSync(scratchPath.join(context.directory, name2));
|
|
@@ -1393,7 +1393,7 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1393
1393
|
leases: scratchFs.existsSync(scratchPath.join(context.directory, "leases")) ? scratchLeaseRecords(context).sort((left, right) => left.leaseId.localeCompare(right.leaseId)) : [],
|
|
1394
1394
|
lockIdentity: expected
|
|
1395
1395
|
}, (_, value) => typeof value === "bigint" ? value.toString() : value)).digest("hex");
|
|
1396
|
-
return { context, ancestor, path:
|
|
1396
|
+
return { context, ancestor, path: path32, expected, token };
|
|
1397
1397
|
}
|
|
1398
1398
|
function scratchRecoverContainment(workspace, ownerId, token) {
|
|
1399
1399
|
scratchAssert(typeof token === "string" && /^[a-f0-9]{64}$/.test(token));
|
|
@@ -1430,8 +1430,8 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1430
1430
|
const leases = scratchLeaseRecords(context).sort((a, b) => a.leaseId.localeCompare(b.leaseId));
|
|
1431
1431
|
const active = leases.filter((lease) => lease.state === "active");
|
|
1432
1432
|
scratchAssert(active.length > 0 && active.every((lease) => lease.consumers.length === 1 && ["serena-mcp", "playwright-mcp"].includes(lease.consumers[0])));
|
|
1433
|
-
const fileIdentity = (
|
|
1434
|
-
const info = scratchFs.lstatSync(
|
|
1433
|
+
const fileIdentity = (path32) => {
|
|
1434
|
+
const info = scratchFs.lstatSync(path32, { bigint: true });
|
|
1435
1435
|
return { dev: info.dev, ino: info.ino, birth: info.birthtimeNs };
|
|
1436
1436
|
};
|
|
1437
1437
|
const token = scratchCrypto.createHash("sha256").update(JSON.stringify({
|
|
@@ -1460,10 +1460,10 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1460
1460
|
}
|
|
1461
1461
|
function scratchPublicationSnapshot(workspace) {
|
|
1462
1462
|
scratchCanonical(workspace);
|
|
1463
|
-
const
|
|
1464
|
-
scratchPrivate(
|
|
1465
|
-
scratchAssert(scratchFs.readdirSync(
|
|
1466
|
-
const expected = scratchDirectoryIdentity(
|
|
1463
|
+
const path32 = scratchPath.join(workspace, ".gestalt-scratch-lock");
|
|
1464
|
+
scratchPrivate(path32);
|
|
1465
|
+
scratchAssert(scratchFs.readdirSync(path32).length === 0);
|
|
1466
|
+
const expected = scratchDirectoryIdentity(path32);
|
|
1467
1467
|
const token = scratchCrypto.createHash("sha256").update(JSON.stringify({
|
|
1468
1468
|
workspace: scratchDirectoryIdentity(workspace),
|
|
1469
1469
|
lock: expected,
|
|
@@ -1473,7 +1473,7 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1473
1473
|
leases: scratchFs.existsSync(scratchPath.join(ancestor.context.directory, "leases")) ? scratchLeaseRecords(ancestor.context).sort((a, b) => a.leaseId.localeCompare(b.leaseId)) : []
|
|
1474
1474
|
}))
|
|
1475
1475
|
}, (_, value) => typeof value === "bigint" ? value.toString() : value)).digest("hex");
|
|
1476
|
-
return { path:
|
|
1476
|
+
return { path: path32, expected, token };
|
|
1477
1477
|
}
|
|
1478
1478
|
function scratchRecoverPublication(workspace, token) {
|
|
1479
1479
|
scratchAssert(typeof token === "string" && /^[a-f0-9]{64}$/.test(token));
|
|
@@ -1539,17 +1539,17 @@ function createScratchOwner(privateProbe = scratchPath.join(scratchPath.dirname(
|
|
|
1539
1539
|
const selected = scratchDirectoryIdentity(workspace), ancestors = scratchManagedAncestors(workspace), claims = [];
|
|
1540
1540
|
try {
|
|
1541
1541
|
for (const ancestor of ancestors) {
|
|
1542
|
-
const
|
|
1542
|
+
const path32 = scratchPath.join(ancestor.context.directory, ".containment-lock");
|
|
1543
1543
|
try {
|
|
1544
|
-
scratchFs.mkdirSync(
|
|
1544
|
+
scratchFs.mkdirSync(path32, { mode: 448 });
|
|
1545
1545
|
} catch (error) {
|
|
1546
1546
|
if (error.code === "EEXIST") throw new Error("SESSION_SCRATCH_CONTAINMENT_BUSY");
|
|
1547
1547
|
throw error;
|
|
1548
1548
|
}
|
|
1549
|
-
const claim = { path:
|
|
1549
|
+
const claim = { path: path32, identity: scratchDirectoryIdentity(path32), fd: void 0 };
|
|
1550
1550
|
claims.push(claim);
|
|
1551
|
-
scratchPrivate(
|
|
1552
|
-
claim.fd = scratchOpenDirectory(
|
|
1551
|
+
scratchPrivate(path32);
|
|
1552
|
+
claim.fd = scratchOpenDirectory(path32);
|
|
1553
1553
|
const held = scratchDirectoryStat(claim.fd);
|
|
1554
1554
|
scratchAssert(scratchSameDirectory(claim.identity, { dev: held.dev, ino: held.ino, birth: held.birthtimeNs }));
|
|
1555
1555
|
scratchRevalidateAncestor(ancestor);
|
|
@@ -2818,8 +2818,44 @@ var init_child = __esm({
|
|
|
2818
2818
|
}
|
|
2819
2819
|
});
|
|
2820
2820
|
|
|
2821
|
-
// src/cli/skill-profiles/
|
|
2821
|
+
// src/cli/skill-profiles/directories.ts
|
|
2822
|
+
import { constants as constants6 } from "node:fs";
|
|
2823
|
+
import { open as open5 } from "node:fs/promises";
|
|
2822
2824
|
import path26 from "node:path";
|
|
2825
|
+
async function checkSkillProfileDirectories(gestaltHome, repairOwnedModes = false) {
|
|
2826
|
+
for (const directory of [gestaltHome, path26.join(gestaltHome, "skill-profiles")]) {
|
|
2827
|
+
const info = await optionalStat(directory);
|
|
2828
|
+
if (!info) continue;
|
|
2829
|
+
if (info.isSymbolicLink()) throw new Error(`Skill profiles require a directory, but ${directory} is a symbolic link.`);
|
|
2830
|
+
if (!info.isDirectory()) throw new Error(`Skill profiles require a directory at ${directory}.`);
|
|
2831
|
+
if (!process.getuid) continue;
|
|
2832
|
+
const uid = process.getuid();
|
|
2833
|
+
if (info.uid !== uid) throw new Error(`Skill profile directory ${directory} is owned by UID ${info.uid}, expected UID ${uid}.`);
|
|
2834
|
+
if (!(info.mode & 18)) continue;
|
|
2835
|
+
const mode = (info.mode & 4095).toString(8);
|
|
2836
|
+
const diagnostic = `Skill profile directory ${directory} has mode ${mode}. Remove group and other write access with chmod go-w on this directory.`;
|
|
2837
|
+
if (!repairOwnedModes) throw new Error(diagnostic);
|
|
2838
|
+
const handle = await open5(directory, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
|
|
2839
|
+
try {
|
|
2840
|
+
const current = await handle.stat();
|
|
2841
|
+
if (current.dev !== info.dev || current.ino !== info.ino || current.uid !== uid)
|
|
2842
|
+
throw new Error(`Skill profile directory changed during startup: ${directory}`);
|
|
2843
|
+
await handle.chmod(current.mode & 4095 & ~18);
|
|
2844
|
+
const checked = await optionalStat(directory);
|
|
2845
|
+
if (!checked || checked.ino !== current.ino || checked.dev !== current.dev || checked.uid !== uid || checked.mode & 18) throw new Error(diagnostic);
|
|
2846
|
+
} finally {
|
|
2847
|
+
await handle.close();
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
var init_directories = __esm({
|
|
2852
|
+
"src/cli/skill-profiles/directories.ts"() {
|
|
2853
|
+
init_context();
|
|
2854
|
+
}
|
|
2855
|
+
});
|
|
2856
|
+
|
|
2857
|
+
// src/cli/skill-profiles/model.ts
|
|
2858
|
+
import path27 from "node:path";
|
|
2823
2859
|
function profileName2(value) {
|
|
2824
2860
|
const name2 = value.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
2825
2861
|
if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(name2) || process.platform === "win32" && /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/.test(name2))
|
|
@@ -2827,19 +2863,19 @@ function profileName2(value) {
|
|
|
2827
2863
|
return name2;
|
|
2828
2864
|
}
|
|
2829
2865
|
function skillKey(value) {
|
|
2830
|
-
return process.platform === "win32" ?
|
|
2866
|
+
return process.platform === "win32" ? path27.win32.normalize(value).toLowerCase() : path27.normalize(value);
|
|
2831
2867
|
}
|
|
2832
2868
|
function durableKey(value) {
|
|
2833
|
-
const components = skillKey(value).split(
|
|
2869
|
+
const components = skillKey(value).split(path27.sep);
|
|
2834
2870
|
const index = components.lastIndexOf("plugins");
|
|
2835
2871
|
if (index < 0 || components[index + 1] !== "cache" || components[index + 5] !== "skills") return;
|
|
2836
|
-
return [...components.slice(0, index + 4), ...components.slice(index + 5)].join(
|
|
2872
|
+
return [...components.slice(0, index + 4), ...components.slice(index + 5)].join(path27.sep);
|
|
2837
2873
|
}
|
|
2838
2874
|
function record(value) {
|
|
2839
2875
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
2840
2876
|
}
|
|
2841
2877
|
function validSkillPath(value) {
|
|
2842
|
-
return typeof value === "string" &&
|
|
2878
|
+
return typeof value === "string" && path27.isAbsolute(value) && path27.normalize(value) === value && !/[\x00-\x1f\x7f]/.test(value);
|
|
2843
2879
|
}
|
|
2844
2880
|
function decodeProfile(value) {
|
|
2845
2881
|
const input = record(value);
|
|
@@ -2873,7 +2909,7 @@ function profileDocument(profile) {
|
|
|
2873
2909
|
return {
|
|
2874
2910
|
version: profile.browser === void 0 ? 1 : 2,
|
|
2875
2911
|
name: profile.name,
|
|
2876
|
-
skills: profile.skills.map(({ path:
|
|
2912
|
+
skills: profile.skills.map(({ path: path32, name: name2, enabled }) => ({ name: name2, path: path32, enabled })),
|
|
2877
2913
|
...profile.browser === void 0 ? {} : { capabilities: { playwright: { enabled: profile.browser } } }
|
|
2878
2914
|
};
|
|
2879
2915
|
}
|
|
@@ -2905,7 +2941,7 @@ function profileSkillRules(catalog, selection) {
|
|
|
2905
2941
|
if (selection === void 0) return { rules: catalog.map((skill) => ({ path: skill.path, enabled: mandatory(skill) })), missing: [] };
|
|
2906
2942
|
const { skills, missing } = reconcileSkills(catalog, selection);
|
|
2907
2943
|
const fixed = catalog.filter(mandatory);
|
|
2908
|
-
const rules = [...skills.map(({ path:
|
|
2944
|
+
const rules = [...skills.map(({ path: path32, enabled }) => ({ path: path32, enabled })), ...fixed.map(({ path: path32 }) => ({ path: path32, enabled: true }))];
|
|
2909
2945
|
return { rules, missing };
|
|
2910
2946
|
}
|
|
2911
2947
|
var managedSkill;
|
|
@@ -2919,7 +2955,7 @@ var init_model = __esm({
|
|
|
2919
2955
|
import { spawn as spawn3 } from "node:child_process";
|
|
2920
2956
|
import { createInterface as createInterface3 } from "node:readline";
|
|
2921
2957
|
import { realpath as realpath11 } from "node:fs/promises";
|
|
2922
|
-
import
|
|
2958
|
+
import path28 from "node:path";
|
|
2923
2959
|
function skillCatalog(result, cwd) {
|
|
2924
2960
|
const data = record(result)?.data;
|
|
2925
2961
|
const entry = Array.isArray(data) && data.map(record).find((item) => typeof item?.cwd === "string" && skillKey(item.cwd) === skillKey(cwd));
|
|
@@ -3019,10 +3055,10 @@ async function discoverSkills(invocation, streams, args) {
|
|
|
3019
3055
|
if (await manageSkills(context, "status", "json") !== 0) return catalog;
|
|
3020
3056
|
const status = record(JSON.parse(report));
|
|
3021
3057
|
if (status?.verifiedSource !== true || typeof status.managedRoot !== "string") return catalog;
|
|
3022
|
-
const root =
|
|
3058
|
+
const root = path28.join(status.managedRoot, "skills");
|
|
3023
3059
|
return { ...catalog, skills: await Promise.all(catalog.skills.map(async (skill) => {
|
|
3024
3060
|
const actual = await realpath11(skill.path).catch(() => skill.path);
|
|
3025
|
-
const parts =
|
|
3061
|
+
const parts = path28.relative(root, actual).split(path28.sep);
|
|
3026
3062
|
return { ...skill, verified: parts.length === 2 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(parts[0] ?? "") && parts[1] === "SKILL.md" };
|
|
3027
3063
|
})) };
|
|
3028
3064
|
}
|
|
@@ -3115,17 +3151,17 @@ var require_visit = __commonJS({
|
|
|
3115
3151
|
visit.BREAK = BREAK;
|
|
3116
3152
|
visit.SKIP = SKIP;
|
|
3117
3153
|
visit.REMOVE = REMOVE;
|
|
3118
|
-
function visit_(key, node, visitor,
|
|
3119
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
3154
|
+
function visit_(key, node, visitor, path32) {
|
|
3155
|
+
const ctrl = callVisitor(key, node, visitor, path32);
|
|
3120
3156
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
3121
|
-
replaceNode(key,
|
|
3122
|
-
return visit_(key, ctrl, visitor,
|
|
3157
|
+
replaceNode(key, path32, ctrl);
|
|
3158
|
+
return visit_(key, ctrl, visitor, path32);
|
|
3123
3159
|
}
|
|
3124
3160
|
if (typeof ctrl !== "symbol") {
|
|
3125
3161
|
if (identity.isCollection(node)) {
|
|
3126
|
-
|
|
3162
|
+
path32 = Object.freeze(path32.concat(node));
|
|
3127
3163
|
for (let i = 0; i < node.items.length; ++i) {
|
|
3128
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
3164
|
+
const ci = visit_(i, node.items[i], visitor, path32);
|
|
3129
3165
|
if (typeof ci === "number")
|
|
3130
3166
|
i = ci - 1;
|
|
3131
3167
|
else if (ci === BREAK)
|
|
@@ -3136,13 +3172,13 @@ var require_visit = __commonJS({
|
|
|
3136
3172
|
}
|
|
3137
3173
|
}
|
|
3138
3174
|
} else if (identity.isPair(node)) {
|
|
3139
|
-
|
|
3140
|
-
const ck = visit_("key", node.key, visitor,
|
|
3175
|
+
path32 = Object.freeze(path32.concat(node));
|
|
3176
|
+
const ck = visit_("key", node.key, visitor, path32);
|
|
3141
3177
|
if (ck === BREAK)
|
|
3142
3178
|
return BREAK;
|
|
3143
3179
|
else if (ck === REMOVE)
|
|
3144
3180
|
node.key = null;
|
|
3145
|
-
const cv = visit_("value", node.value, visitor,
|
|
3181
|
+
const cv = visit_("value", node.value, visitor, path32);
|
|
3146
3182
|
if (cv === BREAK)
|
|
3147
3183
|
return BREAK;
|
|
3148
3184
|
else if (cv === REMOVE)
|
|
@@ -3163,17 +3199,17 @@ var require_visit = __commonJS({
|
|
|
3163
3199
|
visitAsync.BREAK = BREAK;
|
|
3164
3200
|
visitAsync.SKIP = SKIP;
|
|
3165
3201
|
visitAsync.REMOVE = REMOVE;
|
|
3166
|
-
async function visitAsync_(key, node, visitor,
|
|
3167
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
3202
|
+
async function visitAsync_(key, node, visitor, path32) {
|
|
3203
|
+
const ctrl = await callVisitor(key, node, visitor, path32);
|
|
3168
3204
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
3169
|
-
replaceNode(key,
|
|
3170
|
-
return visitAsync_(key, ctrl, visitor,
|
|
3205
|
+
replaceNode(key, path32, ctrl);
|
|
3206
|
+
return visitAsync_(key, ctrl, visitor, path32);
|
|
3171
3207
|
}
|
|
3172
3208
|
if (typeof ctrl !== "symbol") {
|
|
3173
3209
|
if (identity.isCollection(node)) {
|
|
3174
|
-
|
|
3210
|
+
path32 = Object.freeze(path32.concat(node));
|
|
3175
3211
|
for (let i = 0; i < node.items.length; ++i) {
|
|
3176
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
3212
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path32);
|
|
3177
3213
|
if (typeof ci === "number")
|
|
3178
3214
|
i = ci - 1;
|
|
3179
3215
|
else if (ci === BREAK)
|
|
@@ -3184,13 +3220,13 @@ var require_visit = __commonJS({
|
|
|
3184
3220
|
}
|
|
3185
3221
|
}
|
|
3186
3222
|
} else if (identity.isPair(node)) {
|
|
3187
|
-
|
|
3188
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
3223
|
+
path32 = Object.freeze(path32.concat(node));
|
|
3224
|
+
const ck = await visitAsync_("key", node.key, visitor, path32);
|
|
3189
3225
|
if (ck === BREAK)
|
|
3190
3226
|
return BREAK;
|
|
3191
3227
|
else if (ck === REMOVE)
|
|
3192
3228
|
node.key = null;
|
|
3193
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
3229
|
+
const cv = await visitAsync_("value", node.value, visitor, path32);
|
|
3194
3230
|
if (cv === BREAK)
|
|
3195
3231
|
return BREAK;
|
|
3196
3232
|
else if (cv === REMOVE)
|
|
@@ -3217,23 +3253,23 @@ var require_visit = __commonJS({
|
|
|
3217
3253
|
}
|
|
3218
3254
|
return visitor;
|
|
3219
3255
|
}
|
|
3220
|
-
function callVisitor(key, node, visitor,
|
|
3256
|
+
function callVisitor(key, node, visitor, path32) {
|
|
3221
3257
|
if (typeof visitor === "function")
|
|
3222
|
-
return visitor(key, node,
|
|
3258
|
+
return visitor(key, node, path32);
|
|
3223
3259
|
if (identity.isMap(node))
|
|
3224
|
-
return visitor.Map?.(key, node,
|
|
3260
|
+
return visitor.Map?.(key, node, path32);
|
|
3225
3261
|
if (identity.isSeq(node))
|
|
3226
|
-
return visitor.Seq?.(key, node,
|
|
3262
|
+
return visitor.Seq?.(key, node, path32);
|
|
3227
3263
|
if (identity.isPair(node))
|
|
3228
|
-
return visitor.Pair?.(key, node,
|
|
3264
|
+
return visitor.Pair?.(key, node, path32);
|
|
3229
3265
|
if (identity.isScalar(node))
|
|
3230
|
-
return visitor.Scalar?.(key, node,
|
|
3266
|
+
return visitor.Scalar?.(key, node, path32);
|
|
3231
3267
|
if (identity.isAlias(node))
|
|
3232
|
-
return visitor.Alias?.(key, node,
|
|
3268
|
+
return visitor.Alias?.(key, node, path32);
|
|
3233
3269
|
return void 0;
|
|
3234
3270
|
}
|
|
3235
|
-
function replaceNode(key,
|
|
3236
|
-
const parent =
|
|
3271
|
+
function replaceNode(key, path32, node) {
|
|
3272
|
+
const parent = path32[path32.length - 1];
|
|
3237
3273
|
if (identity.isCollection(parent)) {
|
|
3238
3274
|
parent.items[key] = node;
|
|
3239
3275
|
} else if (identity.isPair(parent)) {
|
|
@@ -3843,10 +3879,10 @@ var require_Collection = __commonJS({
|
|
|
3843
3879
|
var createNode = require_createNode();
|
|
3844
3880
|
var identity = require_identity();
|
|
3845
3881
|
var Node = require_Node();
|
|
3846
|
-
function collectionFromPath(schema,
|
|
3882
|
+
function collectionFromPath(schema, path32, value) {
|
|
3847
3883
|
let v = value;
|
|
3848
|
-
for (let i =
|
|
3849
|
-
const k =
|
|
3884
|
+
for (let i = path32.length - 1; i >= 0; --i) {
|
|
3885
|
+
const k = path32[i];
|
|
3850
3886
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
3851
3887
|
const a = [];
|
|
3852
3888
|
a[k] = v;
|
|
@@ -3865,7 +3901,7 @@ var require_Collection = __commonJS({
|
|
|
3865
3901
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
3866
3902
|
});
|
|
3867
3903
|
}
|
|
3868
|
-
var isEmptyPath = (
|
|
3904
|
+
var isEmptyPath = (path32) => path32 == null || typeof path32 === "object" && !!path32[Symbol.iterator]().next().done;
|
|
3869
3905
|
var Collection = class extends Node.NodeBase {
|
|
3870
3906
|
constructor(type, schema) {
|
|
3871
3907
|
super(type);
|
|
@@ -3895,11 +3931,11 @@ var require_Collection = __commonJS({
|
|
|
3895
3931
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
3896
3932
|
* that already exists in the map.
|
|
3897
3933
|
*/
|
|
3898
|
-
addIn(
|
|
3899
|
-
if (isEmptyPath(
|
|
3934
|
+
addIn(path32, value) {
|
|
3935
|
+
if (isEmptyPath(path32))
|
|
3900
3936
|
this.add(value);
|
|
3901
3937
|
else {
|
|
3902
|
-
const [key, ...rest] =
|
|
3938
|
+
const [key, ...rest] = path32;
|
|
3903
3939
|
const node = this.get(key, true);
|
|
3904
3940
|
if (identity.isCollection(node))
|
|
3905
3941
|
node.addIn(rest, value);
|
|
@@ -3913,8 +3949,8 @@ var require_Collection = __commonJS({
|
|
|
3913
3949
|
* Removes a value from the collection.
|
|
3914
3950
|
* @returns `true` if the item was found and removed.
|
|
3915
3951
|
*/
|
|
3916
|
-
deleteIn(
|
|
3917
|
-
const [key, ...rest] =
|
|
3952
|
+
deleteIn(path32) {
|
|
3953
|
+
const [key, ...rest] = path32;
|
|
3918
3954
|
if (rest.length === 0)
|
|
3919
3955
|
return this.delete(key);
|
|
3920
3956
|
const node = this.get(key, true);
|
|
@@ -3928,8 +3964,8 @@ var require_Collection = __commonJS({
|
|
|
3928
3964
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3929
3965
|
* `true` (collections are always returned intact).
|
|
3930
3966
|
*/
|
|
3931
|
-
getIn(
|
|
3932
|
-
const [key, ...rest] =
|
|
3967
|
+
getIn(path32, keepScalar) {
|
|
3968
|
+
const [key, ...rest] = path32;
|
|
3933
3969
|
const node = this.get(key, true);
|
|
3934
3970
|
if (rest.length === 0)
|
|
3935
3971
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -3947,8 +3983,8 @@ var require_Collection = __commonJS({
|
|
|
3947
3983
|
/**
|
|
3948
3984
|
* Checks if the collection includes a value with the key `key`.
|
|
3949
3985
|
*/
|
|
3950
|
-
hasIn(
|
|
3951
|
-
const [key, ...rest] =
|
|
3986
|
+
hasIn(path32) {
|
|
3987
|
+
const [key, ...rest] = path32;
|
|
3952
3988
|
if (rest.length === 0)
|
|
3953
3989
|
return this.has(key);
|
|
3954
3990
|
const node = this.get(key, true);
|
|
@@ -3958,8 +3994,8 @@ var require_Collection = __commonJS({
|
|
|
3958
3994
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
3959
3995
|
* boolean to add/remove the item from the set.
|
|
3960
3996
|
*/
|
|
3961
|
-
setIn(
|
|
3962
|
-
const [key, ...rest] =
|
|
3997
|
+
setIn(path32, value) {
|
|
3998
|
+
const [key, ...rest] = path32;
|
|
3963
3999
|
if (rest.length === 0) {
|
|
3964
4000
|
this.set(key, value);
|
|
3965
4001
|
} else {
|
|
@@ -6474,9 +6510,9 @@ var require_Document = __commonJS({
|
|
|
6474
6510
|
this.contents.add(value);
|
|
6475
6511
|
}
|
|
6476
6512
|
/** Adds a value to the document. */
|
|
6477
|
-
addIn(
|
|
6513
|
+
addIn(path32, value) {
|
|
6478
6514
|
if (assertCollection(this.contents))
|
|
6479
|
-
this.contents.addIn(
|
|
6515
|
+
this.contents.addIn(path32, value);
|
|
6480
6516
|
}
|
|
6481
6517
|
/**
|
|
6482
6518
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -6551,14 +6587,14 @@ var require_Document = __commonJS({
|
|
|
6551
6587
|
* Removes a value from the document.
|
|
6552
6588
|
* @returns `true` if the item was found and removed.
|
|
6553
6589
|
*/
|
|
6554
|
-
deleteIn(
|
|
6555
|
-
if (Collection.isEmptyPath(
|
|
6590
|
+
deleteIn(path32) {
|
|
6591
|
+
if (Collection.isEmptyPath(path32)) {
|
|
6556
6592
|
if (this.contents == null)
|
|
6557
6593
|
return false;
|
|
6558
6594
|
this.contents = null;
|
|
6559
6595
|
return true;
|
|
6560
6596
|
}
|
|
6561
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
6597
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path32) : false;
|
|
6562
6598
|
}
|
|
6563
6599
|
/**
|
|
6564
6600
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -6573,10 +6609,10 @@ var require_Document = __commonJS({
|
|
|
6573
6609
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
6574
6610
|
* `true` (collections are always returned intact).
|
|
6575
6611
|
*/
|
|
6576
|
-
getIn(
|
|
6577
|
-
if (Collection.isEmptyPath(
|
|
6612
|
+
getIn(path32, keepScalar) {
|
|
6613
|
+
if (Collection.isEmptyPath(path32))
|
|
6578
6614
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
6579
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
6615
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path32, keepScalar) : void 0;
|
|
6580
6616
|
}
|
|
6581
6617
|
/**
|
|
6582
6618
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -6587,10 +6623,10 @@ var require_Document = __commonJS({
|
|
|
6587
6623
|
/**
|
|
6588
6624
|
* Checks if the document includes a value at `path`.
|
|
6589
6625
|
*/
|
|
6590
|
-
hasIn(
|
|
6591
|
-
if (Collection.isEmptyPath(
|
|
6626
|
+
hasIn(path32) {
|
|
6627
|
+
if (Collection.isEmptyPath(path32))
|
|
6592
6628
|
return this.contents !== void 0;
|
|
6593
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
6629
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path32) : false;
|
|
6594
6630
|
}
|
|
6595
6631
|
/**
|
|
6596
6632
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -6607,13 +6643,13 @@ var require_Document = __commonJS({
|
|
|
6607
6643
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
6608
6644
|
* boolean to add/remove the item from the set.
|
|
6609
6645
|
*/
|
|
6610
|
-
setIn(
|
|
6611
|
-
if (Collection.isEmptyPath(
|
|
6646
|
+
setIn(path32, value) {
|
|
6647
|
+
if (Collection.isEmptyPath(path32)) {
|
|
6612
6648
|
this.contents = value;
|
|
6613
6649
|
} else if (this.contents == null) {
|
|
6614
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
6650
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path32), value);
|
|
6615
6651
|
} else if (assertCollection(this.contents)) {
|
|
6616
|
-
this.contents.setIn(
|
|
6652
|
+
this.contents.setIn(path32, value);
|
|
6617
6653
|
}
|
|
6618
6654
|
}
|
|
6619
6655
|
/**
|
|
@@ -8573,9 +8609,9 @@ var require_cst_visit = __commonJS({
|
|
|
8573
8609
|
visit.BREAK = BREAK;
|
|
8574
8610
|
visit.SKIP = SKIP;
|
|
8575
8611
|
visit.REMOVE = REMOVE;
|
|
8576
|
-
visit.itemAtPath = (cst,
|
|
8612
|
+
visit.itemAtPath = (cst, path32) => {
|
|
8577
8613
|
let item = cst;
|
|
8578
|
-
for (const [field2, index] of
|
|
8614
|
+
for (const [field2, index] of path32) {
|
|
8579
8615
|
const tok = item?.[field2];
|
|
8580
8616
|
if (tok && "items" in tok) {
|
|
8581
8617
|
item = tok.items[index];
|
|
@@ -8584,23 +8620,23 @@ var require_cst_visit = __commonJS({
|
|
|
8584
8620
|
}
|
|
8585
8621
|
return item;
|
|
8586
8622
|
};
|
|
8587
|
-
visit.parentCollection = (cst,
|
|
8588
|
-
const parent = visit.itemAtPath(cst,
|
|
8589
|
-
const field2 =
|
|
8623
|
+
visit.parentCollection = (cst, path32) => {
|
|
8624
|
+
const parent = visit.itemAtPath(cst, path32.slice(0, -1));
|
|
8625
|
+
const field2 = path32[path32.length - 1][0];
|
|
8590
8626
|
const coll = parent?.[field2];
|
|
8591
8627
|
if (coll && "items" in coll)
|
|
8592
8628
|
return coll;
|
|
8593
8629
|
throw new Error("Parent collection not found");
|
|
8594
8630
|
};
|
|
8595
|
-
function _visit(
|
|
8596
|
-
let ctrl = visitor(item,
|
|
8631
|
+
function _visit(path32, item, visitor) {
|
|
8632
|
+
let ctrl = visitor(item, path32);
|
|
8597
8633
|
if (typeof ctrl === "symbol")
|
|
8598
8634
|
return ctrl;
|
|
8599
8635
|
for (const field2 of ["key", "value"]) {
|
|
8600
8636
|
const token = item[field2];
|
|
8601
8637
|
if (token && "items" in token) {
|
|
8602
8638
|
for (let i = 0; i < token.items.length; ++i) {
|
|
8603
|
-
const ci = _visit(Object.freeze(
|
|
8639
|
+
const ci = _visit(Object.freeze(path32.concat([[field2, i]])), token.items[i], visitor);
|
|
8604
8640
|
if (typeof ci === "number")
|
|
8605
8641
|
i = ci - 1;
|
|
8606
8642
|
else if (ci === BREAK)
|
|
@@ -8611,10 +8647,10 @@ var require_cst_visit = __commonJS({
|
|
|
8611
8647
|
}
|
|
8612
8648
|
}
|
|
8613
8649
|
if (typeof ctrl === "function" && field2 === "key")
|
|
8614
|
-
ctrl = ctrl(item,
|
|
8650
|
+
ctrl = ctrl(item, path32);
|
|
8615
8651
|
}
|
|
8616
8652
|
}
|
|
8617
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
8653
|
+
return typeof ctrl === "function" ? ctrl(item, path32) : ctrl;
|
|
8618
8654
|
}
|
|
8619
8655
|
exports.visit = visit;
|
|
8620
8656
|
}
|
|
@@ -10385,26 +10421,27 @@ var init_yaml = __esm({
|
|
|
10385
10421
|
// src/cli/skill-profiles/store.ts
|
|
10386
10422
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
10387
10423
|
import { mkdir as mkdir7, readFile as readFile11, readdir as readdir3, rename as rename7, rm as rm6, writeFile as writeFile4 } from "node:fs/promises";
|
|
10388
|
-
import
|
|
10424
|
+
import path29 from "node:path";
|
|
10389
10425
|
var FileSkillProfiles;
|
|
10390
10426
|
var init_store = __esm({
|
|
10391
10427
|
"src/cli/skill-profiles/store.ts"() {
|
|
10392
10428
|
init_context();
|
|
10429
|
+
init_directories();
|
|
10393
10430
|
init_model();
|
|
10394
10431
|
init_yaml();
|
|
10395
10432
|
FileSkillProfiles = class {
|
|
10433
|
+
root;
|
|
10434
|
+
context;
|
|
10396
10435
|
constructor(context) {
|
|
10397
10436
|
this.context = context;
|
|
10398
|
-
this.root =
|
|
10437
|
+
this.root = path29.join(context.paths.gestaltHome, "skill-profiles");
|
|
10399
10438
|
}
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
throw new Error(`Skill profiles need an owned directory: ${directory}`);
|
|
10407
|
-
}
|
|
10439
|
+
checkRoot() {
|
|
10440
|
+
const { gestaltHome, userHome } = this.context.paths;
|
|
10441
|
+
const defaultHome = path29.join(userHome, ".gestalt");
|
|
10442
|
+
const configuredHome = this.context.invocation.environment.GESTALT_HOME || defaultHome;
|
|
10443
|
+
const repair = gestaltHome === defaultHome && configuredHome === defaultHome;
|
|
10444
|
+
return checkSkillProfileDirectories(gestaltHome, repair);
|
|
10408
10445
|
}
|
|
10409
10446
|
/** Ignore missing documents, preserving parse failures as named diagnostics. */
|
|
10410
10447
|
async read(file) {
|
|
@@ -10424,7 +10461,7 @@ var init_store = __esm({
|
|
|
10424
10461
|
for (const file of files.sort()) {
|
|
10425
10462
|
if (!file.endsWith(".yml") || file.startsWith(".")) continue;
|
|
10426
10463
|
try {
|
|
10427
|
-
const selected = await this.read(
|
|
10464
|
+
const selected = await this.read(path29.join(this.root, file));
|
|
10428
10465
|
if (!selected) continue;
|
|
10429
10466
|
if (`${selected.name}.yml` !== file) throw new Error("Profile name differs from its filename.");
|
|
10430
10467
|
profiles.push(selected);
|
|
@@ -10435,14 +10472,14 @@ var init_store = __esm({
|
|
|
10435
10472
|
return { profiles, warnings };
|
|
10436
10473
|
}
|
|
10437
10474
|
async defaults(workspace) {
|
|
10438
|
-
return this.read(
|
|
10475
|
+
return this.read(path29.join(workspace, "gestalt-skills.yml"));
|
|
10439
10476
|
}
|
|
10440
10477
|
/** Atomically replace the named profile without exposing a partially written YAML file. */
|
|
10441
10478
|
async save(profile) {
|
|
10442
10479
|
const bytes = Buffer.from(serializeProfileYaml(profile));
|
|
10443
10480
|
if (bytes.length > 64 * 1024) throw new Error("The skill profile exceeds 64 KiB.");
|
|
10444
10481
|
await this.checkRoot();
|
|
10445
|
-
const file =
|
|
10482
|
+
const file = path29.join(this.root, `${profileName2(profile.name)}.yml`);
|
|
10446
10483
|
const previous = await optionalStat(file);
|
|
10447
10484
|
if (previous && (!previous.isFile() || previous.nlink !== 1)) throw new Error("Refusing to overwrite a linked or special profile file.");
|
|
10448
10485
|
if (process.platform === "win32") {
|
|
@@ -10453,7 +10490,7 @@ var init_store = __esm({
|
|
|
10453
10490
|
}
|
|
10454
10491
|
await mkdir7(this.root, { recursive: true, mode: 448 });
|
|
10455
10492
|
await this.checkRoot();
|
|
10456
|
-
const temporary =
|
|
10493
|
+
const temporary = path29.join(this.root, `.profile-${randomUUID10()}.tmp`);
|
|
10457
10494
|
await writeFile4(temporary, bytes, { flag: "wx", mode: 384 });
|
|
10458
10495
|
try {
|
|
10459
10496
|
await rename7(temporary, file);
|
|
@@ -10463,7 +10500,7 @@ var init_store = __esm({
|
|
|
10463
10500
|
}
|
|
10464
10501
|
async delete(name2) {
|
|
10465
10502
|
await this.checkRoot();
|
|
10466
|
-
const file =
|
|
10503
|
+
const file = path29.join(this.root, `${profileName2(name2)}.yml`);
|
|
10467
10504
|
const current = await optionalStat(file);
|
|
10468
10505
|
if (!current) return false;
|
|
10469
10506
|
if (!current.isFile() || current.nlink !== 1) throw new Error("Refusing to delete a linked or special profile file.");
|
|
@@ -10479,13 +10516,13 @@ var init_store = __esm({
|
|
|
10479
10516
|
});
|
|
10480
10517
|
|
|
10481
10518
|
// src/cli/skill-profiles/launch-options.ts
|
|
10482
|
-
import
|
|
10519
|
+
import path30 from "node:path";
|
|
10483
10520
|
function skillLaunchOptions(input, cwd) {
|
|
10484
10521
|
const args = input[0] === "--" ? input.slice(1) : input;
|
|
10485
10522
|
const argv = [], discovery = [];
|
|
10486
10523
|
let profile, skip = false, native = false, explicitSkills = false, position;
|
|
10487
10524
|
for (let index = 0; index < args.length; index++) {
|
|
10488
|
-
|
|
10525
|
+
let argument = args[index];
|
|
10489
10526
|
if (argument === "--") {
|
|
10490
10527
|
argv.push(...args.slice(index));
|
|
10491
10528
|
break;
|
|
@@ -10500,12 +10537,16 @@ function skillLaunchOptions(input, cwd) {
|
|
|
10500
10537
|
if (!profile || profile.startsWith("-")) throw new Error("--skill-profile requires a saved profile name.");
|
|
10501
10538
|
continue;
|
|
10502
10539
|
}
|
|
10540
|
+
if (!position || !nativeCommands.has(position)) {
|
|
10541
|
+
if (argument === "--cwd") argument = "--cd";
|
|
10542
|
+
else if (argument.startsWith("--cwd=")) argument = "--cd=" + argument.slice("--cwd=".length);
|
|
10543
|
+
}
|
|
10503
10544
|
const pair = ["-C", "--cd", "-p", "--profile", "-c", "--config", "--enable", "--disable"].includes(argument);
|
|
10504
10545
|
const next = pair || valueFlags.has(argument) || argument === "--remote" ? args[++index] : void 0;
|
|
10505
10546
|
argv.push(argument, ...next === void 0 ? [] : [next]);
|
|
10506
10547
|
const option = (short, long) => argument === short || argument === long ? next : argument.startsWith(`${long}=`) ? argument.slice(long.length + 1) : argument.startsWith(short) && argument.length > short.length ? argument.slice(short.length) : void 0;
|
|
10507
10548
|
const directory = option("-C", "--cd");
|
|
10508
|
-
if (directory !== void 0) cwd =
|
|
10549
|
+
if (directory !== void 0) cwd = path30.resolve(cwd, directory);
|
|
10509
10550
|
const codexProfile = option("-p", "--profile");
|
|
10510
10551
|
if (codexProfile !== void 0) discovery.push("--profile", codexProfile);
|
|
10511
10552
|
const config = option("-c", "--config");
|
|
@@ -14596,10 +14637,10 @@ var init_graphics = __esm({
|
|
|
14596
14637
|
/**
|
|
14597
14638
|
* Display image from file path (if accessible to terminal)
|
|
14598
14639
|
*/
|
|
14599
|
-
displayFile(
|
|
14640
|
+
displayFile(path32, options = {}) {
|
|
14600
14641
|
const width = options.width ? `width=${options.width}` : "width=auto";
|
|
14601
14642
|
const height = options.height ? `height=${options.height}` : "height=auto";
|
|
14602
|
-
const encodedPath = Buffer.from(
|
|
14643
|
+
const encodedPath = Buffer.from(path32).toString("base64");
|
|
14603
14644
|
return `\x1B]1337;File=inline=1;${width};${height}:${encodedPath}\x07`;
|
|
14604
14645
|
}
|
|
14605
14646
|
};
|
|
@@ -15158,8 +15199,8 @@ function getCommonMistakeDocsPath(code) {
|
|
|
15158
15199
|
return `docs/resources/common-mistakes.md#${getCommonMistake(code).anchor}`;
|
|
15159
15200
|
}
|
|
15160
15201
|
function getCommonMistakeReference(code) {
|
|
15161
|
-
const
|
|
15162
|
-
return `See ${
|
|
15202
|
+
const path32 = getCommonMistakeDocsPath(code);
|
|
15203
|
+
return `See ${path32} or tuiuiu://guide/common-mistakes.`;
|
|
15163
15204
|
}
|
|
15164
15205
|
var commonMistakes;
|
|
15165
15206
|
var init_common_mistakes = __esm({
|
|
@@ -15328,26 +15369,26 @@ Computed(() => {
|
|
|
15328
15369
|
});
|
|
15329
15370
|
|
|
15330
15371
|
// node_modules/tuiuiu.js/dist/core/dev-warnings.js
|
|
15331
|
-
import
|
|
15372
|
+
import path31 from "node:path";
|
|
15332
15373
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
15333
15374
|
function isDevWarningEnabled() {
|
|
15334
15375
|
return process.env.NODE_ENV !== "production";
|
|
15335
15376
|
}
|
|
15336
15377
|
function normalizeMaybeFileUrl(value) {
|
|
15337
15378
|
if (value.startsWith("file://")) {
|
|
15338
|
-
return
|
|
15379
|
+
return path31.normalize(fileURLToPath5(value));
|
|
15339
15380
|
}
|
|
15340
|
-
return
|
|
15381
|
+
return path31.normalize(value);
|
|
15341
15382
|
}
|
|
15342
15383
|
function isInternalLibraryPath(filePath) {
|
|
15343
|
-
const normalized =
|
|
15384
|
+
const normalized = path31.normalize(filePath);
|
|
15344
15385
|
if (!normalized.startsWith(packageRoot)) {
|
|
15345
15386
|
return false;
|
|
15346
15387
|
}
|
|
15347
|
-
return normalized.includes(`${
|
|
15388
|
+
return normalized.includes(`${path31.sep}src${path31.sep}`) || normalized.includes(`${path31.sep}dist${path31.sep}`);
|
|
15348
15389
|
}
|
|
15349
15390
|
function formatDisplayPath(site) {
|
|
15350
|
-
const relative =
|
|
15391
|
+
const relative = path31.relative(process.cwd(), site.filePath);
|
|
15351
15392
|
const displayPath = relative && !relative.startsWith("..") ? relative : site.filePath;
|
|
15352
15393
|
if (site.line === void 0) {
|
|
15353
15394
|
return displayPath;
|
|
@@ -15423,9 +15464,9 @@ var init_dev_warnings = __esm({
|
|
|
15423
15464
|
init_common_mistakes();
|
|
15424
15465
|
init_context2();
|
|
15425
15466
|
warnedKeys = /* @__PURE__ */ new Set();
|
|
15426
|
-
currentFilePath =
|
|
15427
|
-
srcRoot =
|
|
15428
|
-
packageRoot =
|
|
15467
|
+
currentFilePath = path31.normalize(fileURLToPath5(import.meta.url));
|
|
15468
|
+
srcRoot = path31.dirname(path31.dirname(currentFilePath));
|
|
15469
|
+
packageRoot = path31.dirname(srcRoot);
|
|
15429
15470
|
signalCreationSuppressionDepth = 0;
|
|
15430
15471
|
}
|
|
15431
15472
|
});
|
|
@@ -35797,6 +35838,7 @@ var internalCommandNames = [
|
|
|
35797
35838
|
];
|
|
35798
35839
|
var commandAliases = { "--help": "help", "-h": "help", "--version": "version", "-V": "version" };
|
|
35799
35840
|
var retiredCommandNames = ["xerj"];
|
|
35841
|
+
var updateComponents = ["all", "gestalt", "mobile", "serena", "playwright"];
|
|
35800
35842
|
|
|
35801
35843
|
// src/cli/dispatch.ts
|
|
35802
35844
|
async function runCli(invocation, streams, metadata, handlers = {}) {
|
|
@@ -36866,7 +36908,7 @@ function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp",
|
|
|
36866
36908
|
'default_permissions = "workspace-git"'
|
|
36867
36909
|
];
|
|
36868
36910
|
const writeRoots = /* @__PURE__ */ new Set([temporaryRoot, ...cacheRoots]);
|
|
36869
|
-
for (const
|
|
36911
|
+
for (const path32 of homeReadRoots) writeRoots.delete(path32);
|
|
36870
36912
|
const profile = [
|
|
36871
36913
|
"[permissions.workspace-git]",
|
|
36872
36914
|
'description = "Workspace and Git writable with local test support"',
|
|
@@ -36878,8 +36920,8 @@ function permissionConfiguration(source, homeReadRoots, temporaryRoot = "/tmp",
|
|
|
36878
36920
|
"allow_local_binding = true",
|
|
36879
36921
|
"",
|
|
36880
36922
|
"[permissions.workspace-git.filesystem]",
|
|
36881
|
-
...[...writeRoots].map((
|
|
36882
|
-
...homeReadRoots.map((
|
|
36923
|
+
...[...writeRoots].map((path32) => `${JSON.stringify(path32)} = "write"`),
|
|
36924
|
+
...homeReadRoots.map((path32) => `${JSON.stringify(path32)} = "read"`),
|
|
36883
36925
|
"",
|
|
36884
36926
|
'[permissions.workspace-git.filesystem.":workspace_roots"]',
|
|
36885
36927
|
'"." = "write"',
|
|
@@ -36898,27 +36940,27 @@ function approvalConfiguration(source, managerPath, codexHome) {
|
|
|
36898
36940
|
const config = parse(source);
|
|
36899
36941
|
const expected = managedMcpApprovals(config, { manager: managerPath, codexHome });
|
|
36900
36942
|
const changes = [];
|
|
36901
|
-
const changed = (before, after,
|
|
36943
|
+
const changed = (before, after, path32 = []) => {
|
|
36902
36944
|
for (const [key, value] of Object.entries(after ?? {})) {
|
|
36903
|
-
if (value && typeof value === "object" && !Array.isArray(value)) changed(before?.[key], value, [...
|
|
36904
|
-
else if (JSON.stringify(before?.[key]) !== JSON.stringify(value) && ["default_tools_approval_mode", "approval_mode", "env_vars"].includes(key)) changes.push([...
|
|
36945
|
+
if (value && typeof value === "object" && !Array.isArray(value)) changed(before?.[key], value, [...path32, key]);
|
|
36946
|
+
else if (JSON.stringify(before?.[key]) !== JSON.stringify(value) && ["default_tools_approval_mode", "approval_mode", "env_vars"].includes(key)) changes.push([...path32, key]);
|
|
36905
36947
|
}
|
|
36906
36948
|
};
|
|
36907
36949
|
changed(config, expected);
|
|
36908
36950
|
if (!changes.length) return source;
|
|
36909
36951
|
let output = source;
|
|
36910
36952
|
for (const fullPath of changes) {
|
|
36911
|
-
const
|
|
36953
|
+
const path32 = fullPath.slice(0, -1), key = fullPath.at(-1);
|
|
36912
36954
|
const value = fullPath.reduce((item, key2) => item[key2], expected);
|
|
36913
36955
|
const rendered = stringify({ [key]: value }).trimEnd();
|
|
36914
|
-
const header2 = "[" +
|
|
36956
|
+
const header2 = "[" + path32.map((key2) => JSON.stringify(key2)).join(".") + "]";
|
|
36915
36957
|
let inserted = false;
|
|
36916
36958
|
output = output.split(/(?=^[ \t]*\[)/m).map((section) => {
|
|
36917
36959
|
const line = section.split("\n")[0];
|
|
36918
36960
|
if (inserted || line.trimStart().startsWith("[[")) return section;
|
|
36919
36961
|
try {
|
|
36920
36962
|
let table = parse(line + "\n__gestalt_marker = true");
|
|
36921
|
-
for (const key2 of
|
|
36963
|
+
for (const key2 of path32) table = table?.[key2];
|
|
36922
36964
|
if (table?.__gestalt_marker !== true) return section;
|
|
36923
36965
|
inserted = true;
|
|
36924
36966
|
const assignment = new RegExp("^[ \\t]*" + key + "[ \\t]*=[^\\n]*", "m");
|
|
@@ -37514,37 +37556,37 @@ import { isAbsolute } from "node:path";
|
|
|
37514
37556
|
function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
|
|
37515
37557
|
const notices = /* @__PURE__ */ new Set();
|
|
37516
37558
|
const notice = (kind) => notices.add(kind);
|
|
37517
|
-
const exists = (
|
|
37559
|
+
const exists = (path32) => {
|
|
37518
37560
|
try {
|
|
37519
|
-
return lstatSync2(
|
|
37561
|
+
return lstatSync2(path32);
|
|
37520
37562
|
} catch (error) {
|
|
37521
37563
|
if (error.code === "ENOENT") return null;
|
|
37522
37564
|
throw error;
|
|
37523
37565
|
}
|
|
37524
37566
|
};
|
|
37525
|
-
const canonical = (
|
|
37567
|
+
const canonical = (path32) => {
|
|
37526
37568
|
try {
|
|
37527
|
-
return realpathSync(
|
|
37569
|
+
return realpathSync(path32);
|
|
37528
37570
|
} catch {
|
|
37529
37571
|
return null;
|
|
37530
37572
|
}
|
|
37531
37573
|
};
|
|
37532
37574
|
const codex = canonical(selectedCodex), home = canonical(selectedHome), executable = canonical(manager);
|
|
37533
|
-
const plain = (
|
|
37534
|
-
const info = exists(
|
|
37575
|
+
const plain = (path32) => {
|
|
37576
|
+
const info = exists(path32);
|
|
37535
37577
|
return info?.isFile() && info.nlink === 1 && (!process.getuid || info.uid === process.getuid()) ? info : null;
|
|
37536
37578
|
};
|
|
37537
37579
|
const owned = (server) => server && !server.url && typeof server.command === "string" && isAbsolute(server.command) && canonical(server.command) === executable && Array.isArray(server.args) && JSON.stringify(server.args) === '["xerj","mcp"]';
|
|
37538
37580
|
const related = (name2, server) => /xerj/i.test(name2) || server?.args?.[0] === "xerj";
|
|
37539
37581
|
const stable = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
|
|
37540
|
-
function migrate(
|
|
37541
|
-
if (!exists(
|
|
37542
|
-
const info = plain(
|
|
37582
|
+
function migrate(path32) {
|
|
37583
|
+
if (!exists(path32)) return;
|
|
37584
|
+
const info = plain(path32);
|
|
37543
37585
|
if (!info) {
|
|
37544
37586
|
notice("configuration");
|
|
37545
37587
|
return;
|
|
37546
37588
|
}
|
|
37547
|
-
const bytes = readFileSync(
|
|
37589
|
+
const bytes = readFileSync(path32, "utf8");
|
|
37548
37590
|
let config;
|
|
37549
37591
|
try {
|
|
37550
37592
|
config = parse(bytes);
|
|
@@ -37583,7 +37625,7 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
|
|
|
37583
37625
|
return;
|
|
37584
37626
|
}
|
|
37585
37627
|
if (bytes === output) return;
|
|
37586
|
-
const temporary = join2(dirname(
|
|
37628
|
+
const temporary = join2(dirname(path32), ".gestalt-retirement-" + randomBytes2(12).toString("hex"));
|
|
37587
37629
|
let handle;
|
|
37588
37630
|
try {
|
|
37589
37631
|
handle = openSync2(temporary, "wx", 384);
|
|
@@ -37592,10 +37634,10 @@ function retireManagedConfiguration(selectedCodex, selectedHome, manager) {
|
|
|
37592
37634
|
fsyncSync(handle);
|
|
37593
37635
|
closeSync2(handle);
|
|
37594
37636
|
handle = void 0;
|
|
37595
|
-
const current = plain(
|
|
37596
|
-
if (!current || current.dev !== info.dev || current.ino !== info.ino || readFileSync(
|
|
37637
|
+
const current = plain(path32);
|
|
37638
|
+
if (!current || current.dev !== info.dev || current.ino !== info.ino || readFileSync(path32, "utf8") !== bytes)
|
|
37597
37639
|
throw new Error("configuration changed during Xerj retirement; retry update");
|
|
37598
|
-
renameSync(temporary,
|
|
37640
|
+
renameSync(temporary, path32);
|
|
37599
37641
|
} finally {
|
|
37600
37642
|
if (handle !== void 0) closeSync2(handle);
|
|
37601
37643
|
try {
|
|
@@ -38174,18 +38216,18 @@ function parseUpdateOptions(argv) {
|
|
|
38174
38216
|
}
|
|
38175
38217
|
if (token === "--help" || token === "-h") return { component: component2, extra, help: true };
|
|
38176
38218
|
if (token === "--component") {
|
|
38177
|
-
if (!argv[index + 1]) throw new Error("--component requires all, gestalt, serena, or playwright");
|
|
38219
|
+
if (!argv[index + 1]) throw new Error("--component requires all, gestalt, mobile, serena, or playwright");
|
|
38178
38220
|
if (selected) throw new Error("select only one update component");
|
|
38179
38221
|
component2 = argv[++index];
|
|
38180
38222
|
selected = true;
|
|
38181
|
-
} else if (
|
|
38223
|
+
} else if (updateComponents.some((name2) => name2 === token)) {
|
|
38182
38224
|
if (selected) throw new Error("select only one update component");
|
|
38183
38225
|
component2 = token;
|
|
38184
38226
|
selected = true;
|
|
38185
38227
|
} else throw new Error(`unknown update option or component: ${token} (run 'gestalt update --help')`);
|
|
38186
38228
|
}
|
|
38187
38229
|
if (component2 === "xerj") throw new Error(retirement);
|
|
38188
|
-
if (!
|
|
38230
|
+
if (!updateComponents.some((name2) => name2 === component2)) throw new Error(`unknown update component: ${component2} (choose all, gestalt, mobile, serena, or playwright)`);
|
|
38189
38231
|
if (extra && !["all", "gestalt"].includes(component2)) throw new Error("--extra-skills requires the all or gestalt update component");
|
|
38190
38232
|
return { component: component2, extra, help: false };
|
|
38191
38233
|
}
|
|
@@ -38267,6 +38309,12 @@ async function runInstall(context, extra, operations = defaults, platform = proc
|
|
|
38267
38309
|
}
|
|
38268
38310
|
async function runUpdate(context, options, originalArgv, resumed, operations = defaults, platform = process.platform) {
|
|
38269
38311
|
requireSelection(options.component, platform);
|
|
38312
|
+
if (options.component === "mobile") {
|
|
38313
|
+
await operations.mobile(context);
|
|
38314
|
+
await context.log("update complete (mobile)");
|
|
38315
|
+
context.check();
|
|
38316
|
+
return false;
|
|
38317
|
+
}
|
|
38270
38318
|
if (options.component === "all" || options.component === "gestalt") {
|
|
38271
38319
|
if (await operations.manager(context, originalArgv, resumed)) return true;
|
|
38272
38320
|
await context.prepareHomes();
|
|
@@ -38513,7 +38561,7 @@ async function readArchive(file) {
|
|
|
38513
38561
|
}
|
|
38514
38562
|
var NativeArchives = class {
|
|
38515
38563
|
async list(archive) {
|
|
38516
|
-
return (await readArchive(archive)).map(({ path:
|
|
38564
|
+
return (await readArchive(archive)).map(({ path: path32, kind }) => ({ path: path32, kind }));
|
|
38517
38565
|
}
|
|
38518
38566
|
async extract(archive, stagingDirectory, expectedRoot) {
|
|
38519
38567
|
const entries = await readArchive(archive), root = name(expectedRoot);
|
|
@@ -39475,12 +39523,12 @@ async function launchCapabilities(commands, invocation, manager) {
|
|
|
39475
39523
|
const diagnoseSerena = (reason) => process2.stderr.write(`gestalt: serena unavailable (${reason}); continuing with native code tools
|
|
39476
39524
|
`);
|
|
39477
39525
|
const usableGuidance = async (entry) => {
|
|
39478
|
-
const
|
|
39479
|
-
const manifest = JSON.parse(await readFile10(resolve(
|
|
39526
|
+
const path32 = await realpath10(entry.path);
|
|
39527
|
+
const manifest = JSON.parse(await readFile10(resolve(path32, "../../../.codex-plugin/plugin.json"), "utf8"));
|
|
39480
39528
|
const nativeVersion = /(?:codex[^0-9]*)?0\.(\d+)\./.exec(state.version);
|
|
39481
39529
|
if (manifest.name !== "gestalt" || manifest.skills !== "./skills/" || !nativeVersion || Number(nativeVersion[1]) < 160)
|
|
39482
39530
|
throw new Error("incompatible-runtime");
|
|
39483
|
-
return await readFile10(
|
|
39531
|
+
return await readFile10(path32, "utf8");
|
|
39484
39532
|
};
|
|
39485
39533
|
const common = state && !remote && state.config?.skills?.include_instructions !== false && state.config?.features?.hooks === true;
|
|
39486
39534
|
const startupNotice = (reason) => process2.stderr.write(`gestalt: startup guidance unavailable (${reason}); retaining legacy instructions
|
|
@@ -39546,7 +39594,7 @@ async function launchCapabilities(commands, invocation, manager) {
|
|
|
39546
39594
|
throw error;
|
|
39547
39595
|
}
|
|
39548
39596
|
for (const name2 of names.filter((name3) => name3.endsWith(".toml")).sort()) {
|
|
39549
|
-
const
|
|
39597
|
+
const path32 = resolve(folder, name2), text = await readFile10(path32, "utf8");
|
|
39550
39598
|
const role = parse(text);
|
|
39551
39599
|
if (typeof role.name !== "string" || typeof role.developer_instructions !== "string") continue;
|
|
39552
39600
|
let action = "append";
|
|
@@ -39556,7 +39604,7 @@ async function launchCapabilities(commands, invocation, manager) {
|
|
|
39556
39604
|
} catch {
|
|
39557
39605
|
action = "migration-required";
|
|
39558
39606
|
}
|
|
39559
|
-
const policy = { path:
|
|
39607
|
+
const policy = { path: path32, digest: createHash4("sha256").update(text).digest("hex"), action };
|
|
39560
39608
|
rolePolicies[role.name] = rolePolicies[role.name] ? { action: "ambiguous-role" } : policy;
|
|
39561
39609
|
}
|
|
39562
39610
|
}
|
|
@@ -39853,6 +39901,8 @@ function selectInteractiveRuntime(artifacts) {
|
|
|
39853
39901
|
}
|
|
39854
39902
|
|
|
39855
39903
|
// src/cli/main.ts
|
|
39904
|
+
init_context();
|
|
39905
|
+
init_directories();
|
|
39856
39906
|
var SESSION_SCRATCH_API_VERSION = 1;
|
|
39857
39907
|
var UPDATED_MANAGER_API_VERSION = 1;
|
|
39858
39908
|
var UPDATED_MANAGER_API_CAPABILITIES = ["host-filesystem-v1", "async-owned-commands-v1", "cancellation-v1"];
|
|
@@ -39862,7 +39912,7 @@ function packagedWindowsHelper() {
|
|
|
39862
39912
|
async function continueUpdatedManager(invocation, streams, options) {
|
|
39863
39913
|
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");
|
|
39864
39914
|
let unknown = false;
|
|
39865
|
-
const metadata = { version: "0.
|
|
39915
|
+
const metadata = { version: "0.21.0", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n mobile Gestalt Mobile package only.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
|
|
39866
39916
|
const status = await runCli(
|
|
39867
39917
|
{ argv: [...invocation.argv], cwd: invocation.cwd, environment: { ...invocation.environment } },
|
|
39868
39918
|
streams,
|
|
@@ -39896,6 +39946,10 @@ async function main2() {
|
|
|
39896
39946
|
let argv = process.argv.slice(2);
|
|
39897
39947
|
const environment = { ...process.env };
|
|
39898
39948
|
delete environment.GESTALT_LAUNCH_SKILL_RULES;
|
|
39949
|
+
if (subcommand === "doctor") {
|
|
39950
|
+
const paths2 = await setupPaths(environment);
|
|
39951
|
+
await checkSkillProfileDirectories(paths2.gestaltHome);
|
|
39952
|
+
}
|
|
39899
39953
|
if (subcommand === "skill-profiles" || subcommand === "cli") {
|
|
39900
39954
|
const { manageSkillProfiles: manageSkillProfiles2, prepareProfileLaunch: prepareProfileLaunch2 } = await Promise.resolve().then(() => (init_commands2(), commands_exports));
|
|
39901
39955
|
const request = { argv: argv.slice(1), cwd: process.cwd(), environment };
|
|
@@ -39909,7 +39963,7 @@ async function main2() {
|
|
|
39909
39963
|
const selected = selectInteractiveRuntime({ legacyManager: fileURLToPath7(new URL("./legacy/gestalt", import.meta.url)) });
|
|
39910
39964
|
if (selected.kind === "unix-compatibility") selected.exec({ argv, cwd: process.cwd(), environment });
|
|
39911
39965
|
}
|
|
39912
|
-
const metadata = { version: "0.
|
|
39966
|
+
const metadata = { version: "0.21.0", help: "Usage: gestalt <command> [options]\n\nManage Gestalt Agents and Gestalt Mobile in isolated, user-owned directories.\n\nCommands:\n install [--extra-skills] Install or reconcile Agents, optional skills, and Mobile.\n agents install, update Install or reconcile Agents and context-mode only.\n update [COMPONENT] [--extra-skills]\n Update all installed managed components (default).\n update-restart [COMPONENT] [--extra-skills]\n Update from a live Mobile session, then restart Mobile.\n cli [--] [args...] Start Codex with ~/.codex-gestalt as CODEX_HOME.\n mobile [--] [args...] Start the managed Gestalt Mobile executable.\n Workspace defaults to ~/gestalt; override with --cwd ROOT.\n mobile reset-passkeys --public-origin ORIGIN --confirm\n Reset the local Mobile passkeys and browser sessions for a new hostname.\n scratch inspect --cwd ROOT --owner ID\n Inspect an empty Mobile containment fence (read-only).\n scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent\n Offline recovery after all owner processes have stopped.\n playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.\n playwright update [VERSION] [--prune-offline]\n Reuse a matching release; prune older ones after browser shutdown.\n playwright version [--json] Read versioned installation metadata.\n playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.\n playwright mcp --cwd ROOT Managed headless stdio (workspace profile).\n serena install Install private uv, Python 3.13 and tested Serena.\n serena update [VERSION] [--prune-offline]\n Update Serena; optionally remove inactive releases after shutdown.\n serena version, -V Read installed package metadata without creating state.\n serena doctor [--cwd ROOT] Check install, sandbox, MCP tools and optional language readiness.\n serena index --cwd ROOT Explicit native symbol/cache warmup for one project.\n serena mcp --cwd ROOT Confined workspace MCP; always Codex context and editing mode.\n path [NAME|--json] Print managed executable and runtime paths.\n skills install, update Maintain the optional Dyne.org skill collection only.\n skills status [--json] Read installed version, revision and integrity.\n skills-export [ARCHIVE] Export installed skills and skill profiles.\n skills-import ARCHIVE Import a skills archive into this installation.\n doctor [--cwd ROOT] Check prerequisites and installation.\n version Print manager and detected component versions.\n help Show this help.\n\nUpdate components (also accepted as --component COMPONENT):\n all Gestalt core plus installed Serena and Playwright (default).\n gestalt Manager, Agents, Mobile, and context-mode runtime.\n mobile Gestalt Mobile package only.\n serena Latest stable Serena and its private uv/Python tooling.\n playwright Stable Playwright MCP package; Chrome is externally maintained.\n\nOptional components absent from this installation are skipped by 'all'.\nSelecting serena or playwright explicitly installs or updates that component only.\n--extra-skills applies only to all or gestalt; it adds curated third-party skills.\nNode, npm, Codex, Kimi, and system language servers are externally maintained.\n\nEnvironment:\n CODEX_HOME Isolated Codex home (default: ~/.codex-gestalt).\n GESTALT_HOME Runtime and Mobile root (default: ~/.gestalt).\n GESTALT_INSTALL_BASE_URL Manager update source (default: https://dyne.github.io/gestalt).\n GESTALT_MARKETPLACE Marketplace source (default: dyne/gestalt-agents).\n GESTALT_MARKETPLACE_NAME Codex checkout name (default: dyne-gestalt-agents).\n GESTALT_MOBILE_VERSION npm version or tag (default: latest).\n GESTALT_SKILLS_SOURCE Collection source override (always unverified).\n GESTALT_SKILLS_REF Collection Git ref or immutable revision (default: main).\n" };
|
|
39913
39967
|
const ownershipHelper = packagedWindowsHelper();
|
|
39914
39968
|
return runCli(
|
|
39915
39969
|
{ 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.
|
|
6
|
+
readonly GESTALT_CLI_VERSION='0.21.0'
|
|
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'
|
|
@@ -844,7 +844,8 @@ Commands:
|
|
|
844
844
|
scratch recover --cwd ROOT --owner ID --expect TOKEN --confirm-quiescent
|
|
845
845
|
Offline recovery after all owner processes have stopped.
|
|
846
846
|
playwright install [VERSION] Install MCP; add missing system Chrome on Debian amd64.
|
|
847
|
-
playwright update [VERSION]
|
|
847
|
+
playwright update [VERSION] [--prune-offline]
|
|
848
|
+
Reuse a matching release; prune older ones after browser shutdown.
|
|
848
849
|
playwright version [--json] Read versioned installation metadata.
|
|
849
850
|
playwright doctor [--json] [--launch] [--executable-path PATH] Check package and Chrome; optionally test a local page.
|
|
850
851
|
playwright mcp --cwd ROOT Managed headless stdio (workspace profile).
|
|
@@ -867,6 +868,7 @@ Commands:
|
|
|
867
868
|
Update components (also accepted as --component COMPONENT):
|
|
868
869
|
all Gestalt core plus installed Serena and Playwright (default).
|
|
869
870
|
gestalt Manager, Agents, Mobile, and context-mode runtime.
|
|
871
|
+
mobile Gestalt Mobile package only.
|
|
870
872
|
serena Latest stable Serena and its private uv/Python tooling.
|
|
871
873
|
playwright Stable Playwright MCP package; Chrome is externally maintained.
|
|
872
874
|
|
|
@@ -1680,13 +1682,62 @@ async function catalog(executable) {
|
|
|
1680
1682
|
send({jsonrpc:'2.0',id:1,method:'initialize',params:{protocolVersion:'2024-11-05',capabilities:{},clientInfo:{name:'gestalt-install-probe',version:'1'}}});
|
|
1681
1683
|
});
|
|
1682
1684
|
}
|
|
1683
|
-
|
|
1685
|
+
// Called under .install-lock. Only --prune-offline authorizes removal.
|
|
1686
|
+
function checkInactiveReleases(prune) {
|
|
1687
|
+
const active = installed();
|
|
1688
|
+
let retained = 0;
|
|
1689
|
+
for (const entry of fs.readdirSync(root,{withFileTypes:true})) {
|
|
1690
|
+
const match = /^release-(\d+\.\d+\.\d+)-[A-Za-z0-9]{6}$/.exec(entry.name);
|
|
1691
|
+
const candidate = path.join(root,entry.name);
|
|
1692
|
+
if (!match || !entry.isDirectory() || candidate === active.release) continue;
|
|
1693
|
+
// Historical releases have no per-release descriptor. Recognize their
|
|
1694
|
+
// private manifest, installed package and pinned npm lock before removal.
|
|
1695
|
+
try {
|
|
1696
|
+
const info = fs.lstatSync(candidate);
|
|
1697
|
+
if ((process.getuid && info.uid !== process.getuid()) || (info.mode & 0o077)) continue;
|
|
1698
|
+
const manifest = json(path.join(candidate,'package.json'));
|
|
1699
|
+
const pkg = json(path.join(candidate,'node_modules/@playwright/mcp/package.json'));
|
|
1700
|
+
const pin = json(path.join(candidate,'package-lock.json'),4*1024*1024).packages?.['node_modules/@playwright/mcp'];
|
|
1701
|
+
if (manifest.private !== true || manifest.dependencies?.['@playwright/mcp'] !== match[1] ||
|
|
1702
|
+
pkg.version !== match[1] || pin?.version !== match[1] || !integrity.test(pin.integrity)) continue;
|
|
1703
|
+
} catch { continue; }
|
|
1704
|
+
if (!prune) { retained++; continue; }
|
|
1705
|
+
try { fs.rmSync(candidate,{recursive:true}); }
|
|
1706
|
+
catch { fail('Playwright release is active, but inactive release cleanup failed: '+entry.name); }
|
|
1707
|
+
console.error('gestalt: removed inactive Playwright release '+entry.name);
|
|
1708
|
+
}
|
|
1709
|
+
if (retained) {
|
|
1710
|
+
const noun = retained === 1 ? 'release' : 'releases';
|
|
1711
|
+
console.error(`gestalt: keeping ${retained} inactive Playwright ${noun} for existing clients. After stopping managed browsers, run gestalt playwright update ${active.version} --prune-offline`);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
async function reusePlaywright(version, expectedIntegrity) {
|
|
1715
|
+
try {
|
|
1716
|
+
const active = installed();
|
|
1717
|
+
if (active.version !== version || (expectedIntegrity && active.integrity !== expectedIntegrity)) return false;
|
|
1718
|
+
// The pinned entry point can still be intact after a dependency was removed.
|
|
1719
|
+
await validatePlaywrightCli(active.executable);
|
|
1720
|
+
} catch { return false; }
|
|
1721
|
+
console.error('gestalt: reusing validated Playwright '+version);
|
|
1722
|
+
return true;
|
|
1723
|
+
}
|
|
1724
|
+
async function validatePlaywrightCli(executable) {
|
|
1725
|
+
const help = await run(process.execPath,[executable,'--help']);
|
|
1726
|
+
for (const option of ['--headless','--user-data-dir','--executable-path','--no-webmcp'])
|
|
1727
|
+
if (!help.includes(option)) fail('incompatible upstream CLI');
|
|
1728
|
+
}
|
|
1729
|
+
async function install(version, prune) {
|
|
1684
1730
|
if (version && !stable.test(version)) fail('Playwright version must be stable major.minor.patch');
|
|
1685
1731
|
if (Number(process.versions.node.split('.')[0]) < 20) fail('Playwright requires Node >=20');
|
|
1686
1732
|
if (!['linux','darwin'].includes(process.platform)) fail('Playwright supports Linux and macOS');
|
|
1687
1733
|
directory(root);
|
|
1688
1734
|
lock = path.join(root,'.install-lock');
|
|
1689
1735
|
try {fs.mkdirSync(lock,{mode:0o700});} catch {lock=null;fail('Playwright install already running; verify installer exited before removing stale .install-lock');}
|
|
1736
|
+
const requestedVersion = version;
|
|
1737
|
+
if (requestedVersion && await reusePlaywright(requestedVersion)) {
|
|
1738
|
+
checkInactiveReleases(prune);
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1690
1741
|
stage = fs.mkdtempSync(path.join(root,'release-'+(version || 'stable')+'-'));
|
|
1691
1742
|
fs.writeFileSync(path.join(stage,'npmrc'),'',{mode:0o600});
|
|
1692
1743
|
const npmEnv = {...runtimeEnv(),npm_config_cache:path.join(stage,'cache'),npm_config_userconfig:path.join(stage,'npmrc'),npm_config_globalconfig:'/dev/null',npm_config_registry:'https://registry.npmjs.org/',npm_config_engine_strict:'true',npm_config_ignore_scripts:'true',npm_config_update_notifier:'false'};
|
|
@@ -1694,6 +1745,10 @@ async function install(version) {
|
|
|
1694
1745
|
const release = JSON.parse(await npm(['view','@playwright/mcp@'+(version || 'latest'),'--json']));
|
|
1695
1746
|
if (!stable.test(release.version) || (version && release.version !== version) || !integrity.test(release.dist?.integrity)) fail('invalid stable release metadata');
|
|
1696
1747
|
version=release.version;
|
|
1748
|
+
if (!requestedVersion && await reusePlaywright(version,release.dist.integrity)) {
|
|
1749
|
+
checkInactiveReleases(prune);
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1697
1752
|
// Use a version-bearing final location before generating lock metadata.
|
|
1698
1753
|
const finalStage=path.join(root,'release-'+version+'-'+path.basename(stage).split('-').at(-1));
|
|
1699
1754
|
if (finalStage !== stage) {fs.renameSync(stage,finalStage);stage=finalStage;npmEnv.npm_config_cache=path.join(stage,'cache');npmEnv.npm_config_userconfig=path.join(stage,'npmrc');}
|
|
@@ -1707,8 +1762,7 @@ async function install(version) {
|
|
|
1707
1762
|
const executable=path.join(stage,'node_modules/@playwright/mcp/cli.js');
|
|
1708
1763
|
const pkg=json(path.join(stage,'node_modules/@playwright/mcp/package.json'));
|
|
1709
1764
|
if(pkg.version!==version) fail('package version mismatch');
|
|
1710
|
-
|
|
1711
|
-
for(const option of ['--headless','--user-data-dir','--executable-path','--no-webmcp']) if(!help.includes(option)) fail('incompatible upstream CLI');
|
|
1765
|
+
await validatePlaywrightCli(executable);
|
|
1712
1766
|
const toolSchemas=await catalog(executable),tools=toolSchemas.map(t=>t.name);
|
|
1713
1767
|
const descriptor={schemaVersion:1,contractVersion:1,version,integrity:release.dist.integrity,node:'>=20',release:stage,
|
|
1714
1768
|
lockSha256:hash(fs.readFileSync(packageLock)),executableSha256:hash(fs.readFileSync(executable)),tools,toolSchemas};
|
|
@@ -1717,14 +1771,17 @@ async function install(version) {
|
|
|
1717
1771
|
fs.writeFileSync(staged,JSON.stringify(descriptor)+'\n',{mode:0o600});
|
|
1718
1772
|
fs.renameSync(staged,path.join(root,'active.json'));
|
|
1719
1773
|
stage=null; console.error('gestalt: installed Playwright '+version+' (Chrome externally maintained)');
|
|
1774
|
+
checkInactiveReleases(prune);
|
|
1720
1775
|
}
|
|
1721
1776
|
(async()=>{
|
|
1722
1777
|
safe(root);
|
|
1723
|
-
if (['help','-h','--help'].includes(action)) { console.log('Usage: gestalt playwright install [VERSION] | update [VERSION] | version [--json] | doctor [--json] [--launch] [--cwd ROOT] [--executable-path PATH] | mcp --cwd ROOT [--executable-path PATH]\
|
|
1778
|
+
if (['help','-h','--help'].includes(action)) { console.log('Usage: gestalt playwright install [VERSION] | update [VERSION] [--prune-offline] | version [--json] | doctor [--json] [--launch] [--cwd ROOT] [--executable-path PATH] | mcp --cwd ROOT [--executable-path PATH]\nStop all managed Playwright clients before using --prune-offline to keep only the active release. Install adds missing system Chrome on Debian amd64. Chrome is externally maintained; update, startup and doctor never download it. --launch tests a disposable local page.'); return; }
|
|
1724
1779
|
if (['install','update'].includes(action)) {
|
|
1725
|
-
|
|
1780
|
+
const prune = action === 'update' && args.at(-1) === '--prune-offline';
|
|
1781
|
+
if (prune) args.pop();
|
|
1782
|
+
if(args.length>1)fail('usage: gestalt playwright '+action+' [VERSION]'+(action==='update'?' [--prune-offline]':''));
|
|
1726
1783
|
if(action==='install' && !args.length) {try {installed(); console.error('gestalt: Playwright already installed and validated');return;}catch{}}
|
|
1727
|
-
await install(args[0] || (action === 'install' ? '0.0.83' : undefined));return;
|
|
1784
|
+
await install(args[0] || (action === 'install' ? '0.0.83' : undefined),prune);return;
|
|
1728
1785
|
}
|
|
1729
1786
|
if(action==='version') {
|
|
1730
1787
|
if(args.length && !(args.length===1 && args[0]==='--json')) fail('usage: gestalt playwright version [--json]');
|
|
@@ -2008,6 +2065,7 @@ try {
|
|
|
2008
2065
|
!Array.isArray(d.tools) || !['find_symbol','get_symbols_overview','replace_symbol_body'].every(n => d.tools.some(t => t.name === n && t.inputSchema))) throw Error();
|
|
2009
2066
|
for (const p of [d.python, d.executable, d.uv]) fs.accessSync(p, fs.constants.X_OK);
|
|
2010
2067
|
if (!fs.statSync(d.pythonInstallDir).isDirectory()) throw Error();
|
|
2068
|
+
if (process.argv[3] === 'installed') { console.log(d.version); process.exit(0); }
|
|
2011
2069
|
const py = spawnSync(d.python, ['-I', '-B', '-c',
|
|
2012
2070
|
'import importlib.metadata, json, sys; print(json.dumps({"serena":importlib.metadata.version("serena-agent"),"python":".".join(map(str,sys.version_info[:3]))}))'],
|
|
2013
2071
|
{encoding:'utf8',timeout:5000,maxBuffer:65536});
|
|
@@ -3586,7 +3644,7 @@ NODE
|
|
|
3586
3644
|
install_mobile() {
|
|
3587
3645
|
check_node_version
|
|
3588
3646
|
require_command npm
|
|
3589
|
-
mkdir -p -- "$mobile_root"
|
|
3647
|
+
(umask 077; mkdir -p -- "$mobile_root")
|
|
3590
3648
|
log "installing gestalt-mobile@${mobile_version} under $mobile_root"
|
|
3591
3649
|
npm install \
|
|
3592
3650
|
--prefix "$mobile_root" \
|
|
@@ -3956,6 +4014,11 @@ command_install() {
|
|
|
3956
4014
|
command_update() {
|
|
3957
4015
|
parse_update_options "$@"
|
|
3958
4016
|
case $update_component in
|
|
4017
|
+
mobile)
|
|
4018
|
+
install_mobile
|
|
4019
|
+
log 'update complete (mobile)'
|
|
4020
|
+
return 0
|
|
4021
|
+
;;
|
|
3959
4022
|
all | gestalt)
|
|
3960
4023
|
update_manager
|
|
3961
4024
|
prepare_agents_homes
|
|
@@ -4005,13 +4068,13 @@ parse_update_options() {
|
|
|
4005
4068
|
--extra-skills) include_extra_skills=true ;;
|
|
4006
4069
|
-h | --help) usage; exit 0 ;;
|
|
4007
4070
|
--component)
|
|
4008
|
-
(($# >= 2)) || die '--component requires all, gestalt, serena, or playwright'
|
|
4071
|
+
(($# >= 2)) || die '--component requires all, gestalt, mobile, serena, or playwright'
|
|
4009
4072
|
[[ $component_selected == false ]] || die 'select only one update component'
|
|
4010
4073
|
update_component=$2
|
|
4011
4074
|
component_selected=true
|
|
4012
4075
|
shift
|
|
4013
4076
|
;;
|
|
4014
|
-
all | gestalt | serena | playwright)
|
|
4077
|
+
all | gestalt | mobile | serena | playwright)
|
|
4015
4078
|
[[ $component_selected == false ]] || die 'select only one update component'
|
|
4016
4079
|
update_component=$1
|
|
4017
4080
|
component_selected=true
|
|
@@ -4022,8 +4085,8 @@ parse_update_options() {
|
|
|
4022
4085
|
done
|
|
4023
4086
|
case $update_component in
|
|
4024
4087
|
xerj) die 'Xerj has been retired; run gestalt update to migrate managed configuration. User data is retained.' ;;
|
|
4025
|
-
all | gestalt | serena | playwright) ;;
|
|
4026
|
-
*) die "unknown update component: $update_component (choose all, gestalt, serena, or playwright)" ;;
|
|
4088
|
+
all | gestalt | mobile | serena | playwright) ;;
|
|
4089
|
+
*) die "unknown update component: $update_component (choose all, gestalt, mobile, serena, or playwright)" ;;
|
|
4027
4090
|
esac
|
|
4028
4091
|
[[ $include_extra_skills == false || $update_component == all || $update_component == gestalt ]] ||
|
|
4029
4092
|
die '--extra-skills requires the all or gestalt update component'
|
|
@@ -5313,7 +5376,7 @@ prepare_codex_approval_launcher() {
|
|
|
5313
5376
|
done
|
|
5314
5377
|
native_codex=$(PATH="$native_path" command -v codex) || die 'native Codex executable is missing'
|
|
5315
5378
|
[[ $native_codex == /* && -x $native_codex ]] || die 'native Codex executable must have an absolute path'
|
|
5316
|
-
mkdir -p -- "$gestalt_home/run"
|
|
5379
|
+
(umask 077; mkdir -p -- "$gestalt_home/run")
|
|
5317
5380
|
launcher_root=$(mktemp -d "$gestalt_home/run/codex-approval.XXXXXXXX")
|
|
5318
5381
|
codex_approval_launcher=$launcher_root/bin
|
|
5319
5382
|
mkdir -m 700 -- "$codex_approval_launcher"
|
|
@@ -5497,9 +5560,7 @@ command_mobile() {
|
|
|
5497
5560
|
GESTALT_AGENTS_VERSION="$gestalt_agents_version" \
|
|
5498
5561
|
GESTALT_AGENTS_PLUGIN_ROOT="$gestalt_plugin_root" \
|
|
5499
5562
|
GESTALT_CONTEXT_MODE_VERSION="$context_mode_version" \
|
|
5500
|
-
GESTALT_SERENA_VERSION="$(serena_versions
|
|
5501
|
-
GESTALT_UV_VERSION="$(serena_versions uv 2>/dev/null || true)" \
|
|
5502
|
-
GESTALT_SERENA_PYTHON_VERSION="$(serena_versions python 2>/dev/null || true)" \
|
|
5563
|
+
GESTALT_SERENA_VERSION="$(serena_versions installed 2>/dev/null || true)" \
|
|
5503
5564
|
GESTALT_CONTEXT_MODE_PLUGIN_ROOT="$context_mode_plugin_root" \
|
|
5504
5565
|
GESTALT_CONTEXT_MODE_RUNTIME="$context_mode_runtime" \
|
|
5505
5566
|
GESTALT_MOBILE_BIN="$mobile_bin" \
|
|
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": "a3bc5f298001dfc680a30074ceb929765c4d1b11628d3201c9c11ffd880503e7",
|
|
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-
|
|
26
|
+
"observedAt": "2026-12-06T03:24:45.126Z",
|
|
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.
|
|
4
|
+
"version": "0.21.0",
|
|
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": "de602d1e2cb46270ecee14c3994961746fbcfccc"
|
|
48
48
|
}
|