holycodex 0.11.0 → 0.11.3
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 +3 -1
- package/dist/cli.js +480 -476
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process$1 from "node:process";
|
|
2
|
-
import { access, copyFile, cp, lstat, mkdir, readFile, readdir, readlink, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { access, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir, readlink, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { homedir, tmpdir } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
4
|
+
import { delimiter, dirname, join } from "node:path";
|
|
5
5
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
@@ -81,7 +81,6 @@ function cached(getter) {
|
|
|
81
81
|
Object.defineProperty(this, "value", { value });
|
|
82
82
|
return value;
|
|
83
83
|
}
|
|
84
|
-
throw new Error("cached value already set");
|
|
85
84
|
} };
|
|
86
85
|
}
|
|
87
86
|
function nullish(input) {
|
|
@@ -1907,115 +1906,6 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1907
1906
|
result.value = merged.data;
|
|
1908
1907
|
return result;
|
|
1909
1908
|
}
|
|
1910
|
-
var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
1911
|
-
$ZodType.init(inst, def);
|
|
1912
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1913
|
-
const input = payload.value;
|
|
1914
|
-
if (!isPlainObject(input)) {
|
|
1915
|
-
payload.issues.push({
|
|
1916
|
-
expected: "record",
|
|
1917
|
-
code: "invalid_type",
|
|
1918
|
-
input,
|
|
1919
|
-
inst
|
|
1920
|
-
});
|
|
1921
|
-
return payload;
|
|
1922
|
-
}
|
|
1923
|
-
const proms = [];
|
|
1924
|
-
const values = def.keyType._zod.values;
|
|
1925
|
-
if (values) {
|
|
1926
|
-
payload.value = {};
|
|
1927
|
-
const recordKeys = /* @__PURE__ */ new Set();
|
|
1928
|
-
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1929
|
-
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1930
|
-
const keyResult = def.keyType._zod.run({
|
|
1931
|
-
value: key,
|
|
1932
|
-
issues: []
|
|
1933
|
-
}, ctx);
|
|
1934
|
-
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
1935
|
-
if (keyResult.issues.length) {
|
|
1936
|
-
payload.issues.push({
|
|
1937
|
-
code: "invalid_key",
|
|
1938
|
-
origin: "record",
|
|
1939
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
1940
|
-
input: key,
|
|
1941
|
-
path: [key],
|
|
1942
|
-
inst
|
|
1943
|
-
});
|
|
1944
|
-
continue;
|
|
1945
|
-
}
|
|
1946
|
-
const outKey = keyResult.value;
|
|
1947
|
-
const result = def.valueType._zod.run({
|
|
1948
|
-
value: input[key],
|
|
1949
|
-
issues: []
|
|
1950
|
-
}, ctx);
|
|
1951
|
-
if (result instanceof Promise) proms.push(result.then((result) => {
|
|
1952
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1953
|
-
payload.value[outKey] = result.value;
|
|
1954
|
-
}));
|
|
1955
|
-
else {
|
|
1956
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1957
|
-
payload.value[outKey] = result.value;
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
let unrecognized;
|
|
1961
|
-
for (const key in input) if (!recordKeys.has(key)) {
|
|
1962
|
-
unrecognized = unrecognized ?? [];
|
|
1963
|
-
unrecognized.push(key);
|
|
1964
|
-
}
|
|
1965
|
-
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
1966
|
-
code: "unrecognized_keys",
|
|
1967
|
-
input,
|
|
1968
|
-
inst,
|
|
1969
|
-
keys: unrecognized
|
|
1970
|
-
});
|
|
1971
|
-
} else {
|
|
1972
|
-
payload.value = {};
|
|
1973
|
-
for (const key of Reflect.ownKeys(input)) {
|
|
1974
|
-
if (key === "__proto__") continue;
|
|
1975
|
-
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
1976
|
-
let keyResult = def.keyType._zod.run({
|
|
1977
|
-
value: key,
|
|
1978
|
-
issues: []
|
|
1979
|
-
}, ctx);
|
|
1980
|
-
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
1981
|
-
if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
|
|
1982
|
-
const retryResult = def.keyType._zod.run({
|
|
1983
|
-
value: Number(key),
|
|
1984
|
-
issues: []
|
|
1985
|
-
}, ctx);
|
|
1986
|
-
if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
1987
|
-
if (retryResult.issues.length === 0) keyResult = retryResult;
|
|
1988
|
-
}
|
|
1989
|
-
if (keyResult.issues.length) {
|
|
1990
|
-
if (def.mode === "loose") payload.value[key] = input[key];
|
|
1991
|
-
else payload.issues.push({
|
|
1992
|
-
code: "invalid_key",
|
|
1993
|
-
origin: "record",
|
|
1994
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
1995
|
-
input: key,
|
|
1996
|
-
path: [key],
|
|
1997
|
-
inst
|
|
1998
|
-
});
|
|
1999
|
-
continue;
|
|
2000
|
-
}
|
|
2001
|
-
const result = def.valueType._zod.run({
|
|
2002
|
-
value: input[key],
|
|
2003
|
-
issues: []
|
|
2004
|
-
}, ctx);
|
|
2005
|
-
if (result instanceof Promise) proms.push(result.then((result) => {
|
|
2006
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2007
|
-
payload.value[keyResult.value] = result.value;
|
|
2008
|
-
}));
|
|
2009
|
-
else {
|
|
2010
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2011
|
-
payload.value[keyResult.value] = result.value;
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
2016
|
-
return payload;
|
|
2017
|
-
};
|
|
2018
|
-
});
|
|
2019
1909
|
var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
2020
1910
|
$ZodType.init(inst, def);
|
|
2021
1911
|
const values = getEnumValues(def.entries);
|
|
@@ -3281,39 +3171,6 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3281
3171
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3282
3172
|
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
3283
3173
|
};
|
|
3284
|
-
var recordProcessor = (schema, ctx, _json, params) => {
|
|
3285
|
-
const json = _json;
|
|
3286
|
-
const def = schema._zod.def;
|
|
3287
|
-
json.type = "object";
|
|
3288
|
-
const keyType = def.keyType;
|
|
3289
|
-
const patterns = keyType._zod.bag?.patterns;
|
|
3290
|
-
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
3291
|
-
const valueSchema = process$2(def.valueType, ctx, {
|
|
3292
|
-
...params,
|
|
3293
|
-
path: [
|
|
3294
|
-
...params.path,
|
|
3295
|
-
"patternProperties",
|
|
3296
|
-
"*"
|
|
3297
|
-
]
|
|
3298
|
-
});
|
|
3299
|
-
json.patternProperties = {};
|
|
3300
|
-
for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
|
|
3301
|
-
} else {
|
|
3302
|
-
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$2(def.keyType, ctx, {
|
|
3303
|
-
...params,
|
|
3304
|
-
path: [...params.path, "propertyNames"]
|
|
3305
|
-
});
|
|
3306
|
-
json.additionalProperties = process$2(def.valueType, ctx, {
|
|
3307
|
-
...params,
|
|
3308
|
-
path: [...params.path, "additionalProperties"]
|
|
3309
|
-
});
|
|
3310
|
-
}
|
|
3311
|
-
const keyValues = keyType._zod.values;
|
|
3312
|
-
if (keyValues) {
|
|
3313
|
-
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
3314
|
-
if (validKeyValues.length > 0) json.required = validKeyValues;
|
|
3315
|
-
}
|
|
3316
|
-
};
|
|
3317
3174
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3318
3175
|
const def = schema._zod.def;
|
|
3319
3176
|
const inner = process$2(def.innerType, ctx, params);
|
|
@@ -3965,14 +3822,6 @@ function strictObject(shape, params) {
|
|
|
3965
3822
|
...normalizeParams(params)
|
|
3966
3823
|
});
|
|
3967
3824
|
}
|
|
3968
|
-
function looseObject(shape, params) {
|
|
3969
|
-
return new ZodObject({
|
|
3970
|
-
type: "object",
|
|
3971
|
-
shape,
|
|
3972
|
-
catchall: unknown(),
|
|
3973
|
-
...normalizeParams(params)
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
3825
|
var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
3977
3826
|
$ZodUnion.init(inst, def);
|
|
3978
3827
|
ZodType.init(inst, def);
|
|
@@ -4010,27 +3859,6 @@ function intersection(left, right) {
|
|
|
4010
3859
|
right
|
|
4011
3860
|
});
|
|
4012
3861
|
}
|
|
4013
|
-
var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
4014
|
-
$ZodRecord.init(inst, def);
|
|
4015
|
-
ZodType.init(inst, def);
|
|
4016
|
-
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
4017
|
-
inst.keyType = def.keyType;
|
|
4018
|
-
inst.valueType = def.valueType;
|
|
4019
|
-
});
|
|
4020
|
-
function record(keyType, valueType, params) {
|
|
4021
|
-
if (!valueType || !valueType._zod) return new ZodRecord({
|
|
4022
|
-
type: "record",
|
|
4023
|
-
keyType: string(),
|
|
4024
|
-
valueType: keyType,
|
|
4025
|
-
...normalizeParams(valueType)
|
|
4026
|
-
});
|
|
4027
|
-
return new ZodRecord({
|
|
4028
|
-
type: "record",
|
|
4029
|
-
keyType,
|
|
4030
|
-
valueType,
|
|
4031
|
-
...normalizeParams(params)
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4034
3862
|
var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
4035
3863
|
$ZodEnum.init(inst, def);
|
|
4036
3864
|
ZodType.init(inst, def);
|
|
@@ -4252,13 +4080,13 @@ function superRefine(fn, params) {
|
|
|
4252
4080
|
}
|
|
4253
4081
|
//#endregion
|
|
4254
4082
|
//#region packages/cli/src/catalog.ts
|
|
4255
|
-
var VERSION = "0.11.
|
|
4083
|
+
var VERSION = "0.11.3";
|
|
4256
4084
|
var SKILLS = [
|
|
4257
4085
|
"ast-grep",
|
|
4258
4086
|
"babysit-ci",
|
|
4259
|
-
"caveman",
|
|
4260
4087
|
"code-review",
|
|
4261
4088
|
"compress",
|
|
4089
|
+
"context7-cli",
|
|
4262
4090
|
"debugging",
|
|
4263
4091
|
"handoff",
|
|
4264
4092
|
"lsp",
|
|
@@ -4740,36 +4568,121 @@ var GENERATED_RUNTIMES = [
|
|
|
4740
4568
|
"git-bash-resolver.js",
|
|
4741
4569
|
"LICENSE-LSP-MIT.txt",
|
|
4742
4570
|
"lsp.js",
|
|
4743
|
-
"mcp-stdio-core.js",
|
|
4744
4571
|
"rules.js"
|
|
4745
4572
|
];
|
|
4746
|
-
var WINDOWS_SHELL_POLICY = "On native Windows,
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
return {
|
|
4750
|
-
...platform === "win32" ? { git_bash: {
|
|
4751
|
-
command: "node",
|
|
4752
|
-
args: ["runtime/git-bash.js", "mcp"],
|
|
4753
|
-
cwd: ".",
|
|
4754
|
-
enabled_tools: ["run"]
|
|
4755
|
-
} } : {},
|
|
4756
|
-
lsp: {
|
|
4757
|
-
command: "node",
|
|
4758
|
-
args: ["runtime/lsp.js", "mcp"],
|
|
4759
|
-
cwd: "."
|
|
4760
|
-
},
|
|
4761
|
-
context7: {
|
|
4762
|
-
command: "bunx",
|
|
4763
|
-
args: ["@upstash/context7-mcp"]
|
|
4764
|
-
}
|
|
4765
|
-
};
|
|
4766
|
-
}
|
|
4573
|
+
var WINDOWS_SHELL_POLICY = "On native Windows, run every shell command through the bundled Git Bash launcher, including Git, package, build, test, script and POSIX commands. Never execute task commands through PowerShell or cmd. If Git Bash cannot be resolved, stop and report the blocker. On non-Windows, use the native shell normally.";
|
|
4574
|
+
var LITE_WRITING_POLICY = "Communicate grammatically and concisely. Omit filler, hedging, repetition, decoration, self-reference, style announcements and tool narration. Preserve exact technical terms, APIs, commands, paths, errors and commit keywords. Use fuller grammar for safety, ambiguity, clarification and ordered instructions. Apply this policy only to agent communication, never to literal authored or transformed content, UI or accessibility labels, help text, errors, logs, tests, fixtures, documentation, comments, commit or PR text, authored prompts, translations, quotations, generated content, public APIs, or existing repository and product voice.";
|
|
4575
|
+
var CONTEXT7_POLICY = "Within assigned scope, use the Context7 CLI skill first for current library, framework, SDK and API documentation. Use live web search for releases, dates, broader research, missing Context7 coverage and corroboration. Context7 does not authorize scope expansion.";
|
|
4767
4576
|
/** Returns packaged runtime files required on a platform. */
|
|
4768
4577
|
function requiredPackageRuntimes(platform) {
|
|
4769
4578
|
return platform === "win32" ? GENERATED_RUNTIMES : GENERATED_RUNTIMES.filter((file) => file !== "git-bash.js");
|
|
4770
4579
|
}
|
|
4771
4580
|
//#endregion
|
|
4772
|
-
//#region packages/
|
|
4581
|
+
//#region packages/cli/src/arguments.ts
|
|
4582
|
+
var INSTALL_FLAGS = /* @__PURE__ */ new Set([
|
|
4583
|
+
"--plan",
|
|
4584
|
+
"--max-subagents",
|
|
4585
|
+
"--codex-autonomous",
|
|
4586
|
+
"--no-codex-autonomous",
|
|
4587
|
+
"--dangerous-codex-autonomous",
|
|
4588
|
+
"--fast",
|
|
4589
|
+
"--fast-all",
|
|
4590
|
+
"--no-fast",
|
|
4591
|
+
"--json",
|
|
4592
|
+
"--verbose"
|
|
4593
|
+
]);
|
|
4594
|
+
var SHARED_FLAGS = /* @__PURE__ */ new Set(["--json"]);
|
|
4595
|
+
/** Strictly parses command-specific HolyCodex CLI arguments. */
|
|
4596
|
+
function parseCliArguments(args) {
|
|
4597
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") return base("help");
|
|
4598
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
4599
|
+
if (args.length !== 1) throw new Error("--version does not accept other arguments.");
|
|
4600
|
+
return base("version");
|
|
4601
|
+
}
|
|
4602
|
+
const command = args[0];
|
|
4603
|
+
if (command !== "install" && command !== "doctor" && command !== "cleanup") throw new Error(`Unknown command: ${command ?? ""}`);
|
|
4604
|
+
if (args[1] === "--help" || args[1] === "-h") {
|
|
4605
|
+
if (args.length !== 2) throw new Error("--help does not accept other arguments.");
|
|
4606
|
+
return {
|
|
4607
|
+
...base("help"),
|
|
4608
|
+
command
|
|
4609
|
+
};
|
|
4610
|
+
}
|
|
4611
|
+
const allowed = command === "install" ? INSTALL_FLAGS : SHARED_FLAGS;
|
|
4612
|
+
const values = /* @__PURE__ */ new Map();
|
|
4613
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
4614
|
+
const token = args[index];
|
|
4615
|
+
if (token === "-v") {
|
|
4616
|
+
if (!allowed.has("--verbose")) throw new Error(`Option -v is not valid for ${command}.`);
|
|
4617
|
+
if (values.has("--verbose")) throw new Error("Repeated option: --verbose");
|
|
4618
|
+
values.set("--verbose", true);
|
|
4619
|
+
continue;
|
|
4620
|
+
}
|
|
4621
|
+
if (token === void 0 || !token.startsWith("--")) throw new Error(`Unexpected positional argument: ${token ?? ""}`);
|
|
4622
|
+
const separator = token.indexOf("=");
|
|
4623
|
+
const name = separator < 0 ? token : token.slice(0, separator);
|
|
4624
|
+
if (!allowed.has(name)) throw new Error(`Option ${name} is not valid for ${command}.`);
|
|
4625
|
+
if (values.has(name)) throw new Error(`Repeated option: ${name}`);
|
|
4626
|
+
if (name !== "--plan" && name !== "--max-subagents") {
|
|
4627
|
+
if (separator >= 0) throw new Error(`${name} does not accept a value.`);
|
|
4628
|
+
values.set(name, true);
|
|
4629
|
+
continue;
|
|
4630
|
+
}
|
|
4631
|
+
const value = separator < 0 ? args[++index] : token.slice(separator + 1);
|
|
4632
|
+
if (value === void 0 || value === "" || separator < 0 && value.startsWith("--")) throw new Error(`Missing value for ${name}.`);
|
|
4633
|
+
values.set(name, value);
|
|
4634
|
+
}
|
|
4635
|
+
const autonomyFlags = [
|
|
4636
|
+
"--codex-autonomous",
|
|
4637
|
+
"--no-codex-autonomous",
|
|
4638
|
+
"--dangerous-codex-autonomous"
|
|
4639
|
+
].filter((flag) => values.has(flag));
|
|
4640
|
+
if (autonomyFlags.length > 1) throw new Error(`Conflicting autonomy flags: ${autonomyFlags.join(", ")}`);
|
|
4641
|
+
const fastFlags = [
|
|
4642
|
+
"--fast",
|
|
4643
|
+
"--fast-all",
|
|
4644
|
+
"--no-fast"
|
|
4645
|
+
].filter((flag) => values.has(flag));
|
|
4646
|
+
if (fastFlags.length > 1) throw new Error(`Conflicting Fast flags: ${fastFlags.join(", ")}`);
|
|
4647
|
+
const planValue = values.get("--plan") ?? "plus";
|
|
4648
|
+
const plan = PlanNameSchema.safeParse(planValue);
|
|
4649
|
+
if (!plan.success) throw new Error(`Unknown plan: ${String(planValue)}. Valid plans: ${PLAN_NAMES.join(", ")}.`);
|
|
4650
|
+
const maxValue = values.get("--max-subagents");
|
|
4651
|
+
if (maxValue !== void 0 && (typeof maxValue !== "string" || !/^\d+$/.test(maxValue) || Number(maxValue) > 3)) throw new Error(`Invalid --max-subagents value: ${String(maxValue)}. Expected an integer from 0 through 3.`);
|
|
4652
|
+
const autonomy = values.has("--dangerous-codex-autonomous") ? {
|
|
4653
|
+
requested: true,
|
|
4654
|
+
mode: "dangerous"
|
|
4655
|
+
} : values.has("--codex-autonomous") ? {
|
|
4656
|
+
requested: true,
|
|
4657
|
+
mode: "autonomous"
|
|
4658
|
+
} : values.has("--no-codex-autonomous") ? {
|
|
4659
|
+
requested: true,
|
|
4660
|
+
mode: "default"
|
|
4661
|
+
} : { requested: false };
|
|
4662
|
+
const fast = FastModeSchema.parse(values.has("--fast-all") ? "fast-all" : values.has("--fast") ? "fast" : "standard");
|
|
4663
|
+
return {
|
|
4664
|
+
action: "run",
|
|
4665
|
+
command,
|
|
4666
|
+
json: values.has("--json"),
|
|
4667
|
+
plan: plan.data,
|
|
4668
|
+
...maxValue === void 0 ? {} : { maxSubagents: Number(maxValue) },
|
|
4669
|
+
autonomy,
|
|
4670
|
+
fast,
|
|
4671
|
+
verbose: values.has("--verbose")
|
|
4672
|
+
};
|
|
4673
|
+
}
|
|
4674
|
+
function base(action) {
|
|
4675
|
+
return {
|
|
4676
|
+
action,
|
|
4677
|
+
json: false,
|
|
4678
|
+
plan: DEFAULT_PLAN,
|
|
4679
|
+
autonomy: { requested: false },
|
|
4680
|
+
fast: "standard",
|
|
4681
|
+
verbose: false
|
|
4682
|
+
};
|
|
4683
|
+
}
|
|
4684
|
+
//#endregion
|
|
4685
|
+
//#region packages/git-bash/src/git-bash-resolver.ts
|
|
4773
4686
|
var GIT_BASH_ENV_KEY = "HOLYCODEX_GIT_BASH_PATH";
|
|
4774
4687
|
var PROGRAM_FILES = "C:\\Program Files\\Git\\bin\\bash.exe";
|
|
4775
4688
|
var PROGRAM_FILES_X86 = "C:\\Program Files (x86)\\Git\\bin\\bash.exe";
|
|
@@ -4850,7 +4763,7 @@ function missing(checkedPaths) {
|
|
|
4850
4763
|
};
|
|
4851
4764
|
}
|
|
4852
4765
|
//#endregion
|
|
4853
|
-
//#region packages/
|
|
4766
|
+
//#region packages/runtime-core/src/process.ts
|
|
4854
4767
|
var TRUNCATED_MARKER = "\n... diagnostic output truncated ...\n";
|
|
4855
4768
|
var defaultManagedProcessRuntime = {
|
|
4856
4769
|
terminationGraceMs: 2e3,
|
|
@@ -4915,11 +4828,13 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4915
4828
|
let matched = false;
|
|
4916
4829
|
let settled = false;
|
|
4917
4830
|
let forceKillTimeout;
|
|
4831
|
+
let finalResolutionTimeout;
|
|
4918
4832
|
const finish = (exitCode, error, errorCode) => {
|
|
4919
4833
|
if (settled) return;
|
|
4920
4834
|
settled = true;
|
|
4921
4835
|
clearTimeout(timeout);
|
|
4922
4836
|
if (forceKillTimeout !== void 0) clearTimeout(forceKillTimeout);
|
|
4837
|
+
if (finalResolutionTimeout !== void 0) clearTimeout(finalResolutionTimeout);
|
|
4923
4838
|
resolve({
|
|
4924
4839
|
exitCode,
|
|
4925
4840
|
stdout: outputText(stdout),
|
|
@@ -4938,6 +4853,8 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4938
4853
|
runtime.kill(child, input.platform, "SIGKILL");
|
|
4939
4854
|
}, runtime.terminationGraceMs);
|
|
4940
4855
|
forceKillTimeout.unref();
|
|
4856
|
+
finalResolutionTimeout = setTimeout(() => finish(child.exitCode, "Managed process did not emit close after termination."), input.finalResolutionMs ?? runtime.terminationGraceMs * 2);
|
|
4857
|
+
finalResolutionTimeout.unref();
|
|
4941
4858
|
};
|
|
4942
4859
|
const inspectMatch = () => {
|
|
4943
4860
|
if (matched || input.matchOutput === void 0) return;
|
|
@@ -4968,7 +4885,9 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4968
4885
|
/** Terminates process tree. */
|
|
4969
4886
|
function killProcessTree(child, platform, signal = "SIGTERM", runTaskkill = (command, args) => spawnSync(command, [...args], {
|
|
4970
4887
|
stdio: "ignore",
|
|
4971
|
-
windowsHide: true
|
|
4888
|
+
windowsHide: true,
|
|
4889
|
+
timeout: 2e3,
|
|
4890
|
+
killSignal: "SIGKILL"
|
|
4972
4891
|
})) {
|
|
4973
4892
|
if (platform === "win32" && child.pid !== void 0) {
|
|
4974
4893
|
const result = runTaskkill("taskkill", [
|
|
@@ -5311,6 +5230,13 @@ function nextTableBoundary(input) {
|
|
|
5311
5230
|
if (managedHeader < 0) return header;
|
|
5312
5231
|
return Math.min(header, managedHeader);
|
|
5313
5232
|
}
|
|
5233
|
+
function tableSource(input, table) {
|
|
5234
|
+
const match = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*(?:#.*)?$`, "m").exec(input);
|
|
5235
|
+
if (match === null) return void 0;
|
|
5236
|
+
const tail = input.slice(match.index + match[0].length);
|
|
5237
|
+
const end = nextTableBoundary(tail);
|
|
5238
|
+
return end < 0 ? tail : tail.slice(0, end);
|
|
5239
|
+
}
|
|
5314
5240
|
function rootValue(input, key) {
|
|
5315
5241
|
if (key === "status_line") return rootTomlStringArraySource(input, key);
|
|
5316
5242
|
return new RegExp(`^\\s*${key}\\s*=.*$`, "m").exec(input)?.[0];
|
|
@@ -5351,23 +5277,27 @@ function readPreservedRootOverrides(input) {
|
|
|
5351
5277
|
const managedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
|
|
5352
5278
|
if (managedRoot === void 0) return {
|
|
5353
5279
|
model: false,
|
|
5354
|
-
reasoningEffort: false
|
|
5280
|
+
reasoningEffort: false,
|
|
5281
|
+
webSearch: false
|
|
5355
5282
|
};
|
|
5356
5283
|
const plan = readManagedPlan(managedRoot);
|
|
5357
5284
|
const model = rootTomlString(input, "model");
|
|
5358
5285
|
const reasoningEffort = rootTomlString(input, "model_reasoning_effort");
|
|
5359
5286
|
if (plan === void 0 || model === void 0 || reasoningEffort === void 0) return {
|
|
5360
5287
|
model: false,
|
|
5361
|
-
reasoningEffort: false
|
|
5288
|
+
reasoningEffort: false,
|
|
5289
|
+
webSearch: false
|
|
5362
5290
|
};
|
|
5363
5291
|
if (MANAGED_ROOT_MODEL_HISTORY_BY_PLAN[plan].some((route) => route.model === model && route.reasoningEffort === reasoningEffort)) return {
|
|
5364
5292
|
model: false,
|
|
5365
|
-
reasoningEffort: false
|
|
5293
|
+
reasoningEffort: false,
|
|
5294
|
+
webSearch: rootTomlString(managedRoot, "web_search") !== "live"
|
|
5366
5295
|
};
|
|
5367
5296
|
const preset = MODEL_ROUTING_PLANS[plan].root;
|
|
5368
5297
|
return {
|
|
5369
5298
|
model: model !== preset.model,
|
|
5370
|
-
reasoningEffort: reasoningEffort !== preset.reasoningEffort
|
|
5299
|
+
reasoningEffort: reasoningEffort !== preset.reasoningEffort,
|
|
5300
|
+
webSearch: rootTomlString(managedRoot, "web_search") !== "live"
|
|
5371
5301
|
};
|
|
5372
5302
|
}
|
|
5373
5303
|
function preserveManagedRootPreferences(input, base) {
|
|
@@ -5378,7 +5308,11 @@ function preserveManagedRootPreferences(input, base) {
|
|
|
5378
5308
|
const tables = firstTable < 0 ? "" : base.slice(firstTable);
|
|
5379
5309
|
let updatedRoot = root.trim();
|
|
5380
5310
|
const overrides = readPreservedRootOverrides(input);
|
|
5381
|
-
for (const [key, preserve] of [
|
|
5311
|
+
for (const [key, preserve] of [
|
|
5312
|
+
["model", overrides.model],
|
|
5313
|
+
["model_reasoning_effort", overrides.reasoningEffort],
|
|
5314
|
+
["web_search", overrides.webSearch]
|
|
5315
|
+
]) {
|
|
5382
5316
|
const live = rootValue(managedRoot, key)?.trim();
|
|
5383
5317
|
if (!preserve || live === void 0) continue;
|
|
5384
5318
|
if (rootValue(root, key)?.trim() === live) continue;
|
|
@@ -5416,6 +5350,7 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5416
5350
|
const hadOriginalRoot = /^# holycodex original root:/m.test(input);
|
|
5417
5351
|
const permissionLines = originalPermissionLines ?? (legacyGeneratedRoot !== void 0 && previousOriginalRoot === void 0 ? [] : previousOriginalRoot === void 0 ? hadManagedAutonomy && !hadOriginalRoot ? [] : readPermissionLines(root) : readPermissionLines(previousOriginalRoot));
|
|
5418
5352
|
const controlled = [
|
|
5353
|
+
"web_search",
|
|
5419
5354
|
"approval_policy",
|
|
5420
5355
|
"approvals_reviewer",
|
|
5421
5356
|
"sandbox_mode",
|
|
@@ -5426,6 +5361,7 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5426
5361
|
...request.requested ? ["default_permissions"] : []
|
|
5427
5362
|
].map((key) => rootValue(root, key));
|
|
5428
5363
|
const preservedRoot = [
|
|
5364
|
+
"web_search",
|
|
5429
5365
|
"approval_policy",
|
|
5430
5366
|
"approvals_reviewer",
|
|
5431
5367
|
"sandbox_mode",
|
|
@@ -5446,72 +5382,131 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5446
5382
|
const original = originalSource ? `${ORIGINAL_ROOT}${Buffer.from(originalSource).toString("base64")}\n` : "";
|
|
5447
5383
|
const maxSubagentsMetadata = maxSubagents === void 0 ? "" : `${MAX_SUBAGENTS_PREFIX}${maxSubagents}\n`;
|
|
5448
5384
|
const rootServiceTier = fastMode === "fast-all" ? "fast" : "default";
|
|
5449
|
-
const
|
|
5385
|
+
const priorManagedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
|
|
5386
|
+
const webSearch = readPreservedRootOverrides(input).webSearch ? rootTomlString(priorManagedRoot ?? "", "web_search") ?? "live" : "live";
|
|
5387
|
+
const statusLine = mergedStatusLine(rootValue(root, "status_line") ?? rootTomlStringArraySource(tableSource(base, "tui") ?? "", "status_line"));
|
|
5388
|
+
const rootBlock = `${START}\n${PLAN_PREFIX}${plan}\n${FAST_MODE_PREFIX}${fastMode}\n${AUTONOMY_METADATA_PREFIX}${effectiveAutonomy}\n${maxSubagentsMetadata}${original}${originalPermissionMetadata(permissionLines)}${model}${effort}web_search = ${JSON.stringify(webSearch)}\nmodel_verbosity = "low"\nservice_tier = "${rootServiceTier}"\n${rootPermissionLines.join("\n")}\n${END}`;
|
|
5450
5389
|
let configured = `${preservedRoot ? `${preservedRoot}\n` : ""}${rootBlock}${tables ? `\n\n${tables}` : ""}`;
|
|
5390
|
+
const legacyMultiAgentV2 = /\bmulti_agent_v2\s*=\s*(true|false)/.exec(configured)?.[1];
|
|
5451
5391
|
configured = injectTableKeys(configured, "features", [
|
|
5452
5392
|
["default_mode_request_user_input", "true"],
|
|
5453
5393
|
["multi_agent", "true"],
|
|
5454
|
-
["multi_agent_v2",
|
|
5394
|
+
...legacyMultiAgentV2 === void 0 ? [] : [["multi_agent_v2", legacyMultiAgentV2]]
|
|
5455
5395
|
]);
|
|
5456
5396
|
const usage = MODEL_ROUTING_PLANS[plan].usage;
|
|
5457
|
-
configured = injectTableKeys(configured, "agents", [["
|
|
5397
|
+
configured = injectTableKeys(configured, "agents", [["max_concurrent_threads_per_session", String(effectiveMaxSubagents + 1)], ["max_depth", String(usage.maxDepth)]]);
|
|
5398
|
+
configured = injectTableKeys(configured, "tui", [["status_line", statusLine]]);
|
|
5458
5399
|
if (effectiveAutonomy !== "dangerous") configured = injectTableKeys(configured, "sandbox_workspace_write", [["network_access", "true"]]);
|
|
5459
|
-
configured = injectTableKeys(configured, "desktop", [["
|
|
5400
|
+
configured = injectTableKeys(configured, "desktop", [["show-context-window-usage", "true"]]);
|
|
5460
5401
|
if (_platform === "win32") configured = injectTableKeys(configured, "windows", [["sandbox", "\"unelevated\""]]);
|
|
5461
5402
|
for (const agent of AGENTS) configured = injectTableKeys(configured, `agents.${agent}`, [["config_file", `"holycodex/agents/${agent}.toml"`]]);
|
|
5462
5403
|
const plugin = `${START}\n[plugins."holycodex@holycodex"]\nenabled = true\n${END}`;
|
|
5463
5404
|
return `${configured.trim()}\n\n${plugin}\n`;
|
|
5464
5405
|
}
|
|
5465
5406
|
//#endregion
|
|
5407
|
+
//#region packages/cli/src/context7.ts
|
|
5408
|
+
var RUNNERS = [
|
|
5409
|
+
{
|
|
5410
|
+
executable: "nubx",
|
|
5411
|
+
command: "nubx",
|
|
5412
|
+
prefix: ["-y"]
|
|
5413
|
+
},
|
|
5414
|
+
{
|
|
5415
|
+
executable: "nub",
|
|
5416
|
+
command: "nub",
|
|
5417
|
+
prefix: ["dlx"]
|
|
5418
|
+
},
|
|
5419
|
+
{
|
|
5420
|
+
executable: "bunx",
|
|
5421
|
+
command: "bunx",
|
|
5422
|
+
prefix: []
|
|
5423
|
+
},
|
|
5424
|
+
{
|
|
5425
|
+
executable: "bun",
|
|
5426
|
+
command: "bun",
|
|
5427
|
+
prefix: ["x"]
|
|
5428
|
+
},
|
|
5429
|
+
{
|
|
5430
|
+
executable: "pnpmx",
|
|
5431
|
+
command: "pnpmx",
|
|
5432
|
+
prefix: []
|
|
5433
|
+
},
|
|
5434
|
+
{
|
|
5435
|
+
executable: "pnpm",
|
|
5436
|
+
command: "pnpm",
|
|
5437
|
+
prefix: ["dlx"]
|
|
5438
|
+
},
|
|
5439
|
+
{
|
|
5440
|
+
executable: "npmx",
|
|
5441
|
+
command: "npmx",
|
|
5442
|
+
prefix: ["--yes"]
|
|
5443
|
+
},
|
|
5444
|
+
{
|
|
5445
|
+
executable: "npm",
|
|
5446
|
+
command: "npx",
|
|
5447
|
+
prefix: ["--yes"]
|
|
5448
|
+
},
|
|
5449
|
+
{
|
|
5450
|
+
executable: "yarn",
|
|
5451
|
+
command: "yarn",
|
|
5452
|
+
prefix: ["dlx"]
|
|
5453
|
+
}
|
|
5454
|
+
];
|
|
5455
|
+
/** Constructs the supported direct Context7 invocation for the first available runner. */
|
|
5456
|
+
function context7Command(args, executableExists = executableOnPath, env = process.env) {
|
|
5457
|
+
const runner = RUNNERS.find((candidate) => executableExists(candidate.executable));
|
|
5458
|
+
if (runner === void 0) return void 0;
|
|
5459
|
+
return {
|
|
5460
|
+
command: runner.command,
|
|
5461
|
+
args: [
|
|
5462
|
+
...runner.prefix,
|
|
5463
|
+
"ctx7@latest",
|
|
5464
|
+
...args
|
|
5465
|
+
],
|
|
5466
|
+
env: {
|
|
5467
|
+
...env,
|
|
5468
|
+
CI: env.CI ?? "1"
|
|
5469
|
+
}
|
|
5470
|
+
};
|
|
5471
|
+
}
|
|
5472
|
+
/** Reports whether an executable can be resolved from PATH. */
|
|
5473
|
+
function executableOnPath(name) {
|
|
5474
|
+
const path = process.env.PATH;
|
|
5475
|
+
if (path === void 0) return false;
|
|
5476
|
+
const extensions = process.platform === "win32" ? [
|
|
5477
|
+
".exe",
|
|
5478
|
+
".cmd",
|
|
5479
|
+
".bat",
|
|
5480
|
+
""
|
|
5481
|
+
] : [""];
|
|
5482
|
+
for (const directory of path.split(delimiter)) for (const extension of extensions) try {
|
|
5483
|
+
if (process.getBuiltinModule("node:fs").existsSync(`${directory}/${name}${extension}`)) return true;
|
|
5484
|
+
} catch {
|
|
5485
|
+
continue;
|
|
5486
|
+
}
|
|
5487
|
+
return false;
|
|
5488
|
+
}
|
|
5489
|
+
//#endregion
|
|
5466
5490
|
//#region packages/cli/src/doctor.ts
|
|
5467
|
-
var
|
|
5468
|
-
async function runCommand(name, args,
|
|
5491
|
+
var COMPATIBILITY_KEYS = ["desktop.show-context-window-usage"];
|
|
5492
|
+
async function runCommand(name, args, env) {
|
|
5469
5493
|
const result = await runManagedProcess({
|
|
5470
5494
|
command: name,
|
|
5471
5495
|
args,
|
|
5472
|
-
platform,
|
|
5473
|
-
timeoutMs:
|
|
5474
|
-
maxOutputChars: 64 * 1024
|
|
5496
|
+
platform: process.platform,
|
|
5497
|
+
timeoutMs: 15e3,
|
|
5498
|
+
maxOutputChars: 64 * 1024,
|
|
5499
|
+
...env === void 0 ? {} : { env }
|
|
5475
5500
|
});
|
|
5476
5501
|
return {
|
|
5477
5502
|
ok: result.exitCode === 0 && !result.timedOut && result.error === void 0,
|
|
5478
5503
|
output: `${result.stdout}\n${result.stderr}`.trim() || result.error || ""
|
|
5479
5504
|
};
|
|
5480
5505
|
}
|
|
5481
|
-
async function startContext7(platform) {
|
|
5482
|
-
const result = await runManagedProcess({
|
|
5483
|
-
command: "bunx",
|
|
5484
|
-
args: ["@upstash/context7-mcp"],
|
|
5485
|
-
platform,
|
|
5486
|
-
timeoutMs: 15e3,
|
|
5487
|
-
maxOutputChars: 128 * 1024,
|
|
5488
|
-
stdin: `${JSON.stringify({
|
|
5489
|
-
jsonrpc: "2.0",
|
|
5490
|
-
id: 1,
|
|
5491
|
-
method: "initialize",
|
|
5492
|
-
params: {
|
|
5493
|
-
protocolVersion: "2025-03-26",
|
|
5494
|
-
capabilities: {},
|
|
5495
|
-
clientInfo: {
|
|
5496
|
-
name: "holycodex-doctor",
|
|
5497
|
-
version: VERSION
|
|
5498
|
-
}
|
|
5499
|
-
}
|
|
5500
|
-
})}\n`,
|
|
5501
|
-
matchOutput: (output) => output.includes("\"serverInfo\"") || output.includes("\"capabilities\"")
|
|
5502
|
-
});
|
|
5503
|
-
const diagnostic = `${result.stdout}\n${result.stderr}`.trim() || result.error || "";
|
|
5504
|
-
return {
|
|
5505
|
-
ok: result.matched && !result.timedOut,
|
|
5506
|
-
timedOut: result.timedOut,
|
|
5507
|
-
packageFailure: /(?:404|failed to resolve|package.*not found|error: GET)/i.test(diagnostic),
|
|
5508
|
-
detail: diagnostic
|
|
5509
|
-
};
|
|
5510
|
-
}
|
|
5511
5506
|
var defaultRuntime$1 = {
|
|
5512
5507
|
platform: process.platform,
|
|
5513
|
-
command:
|
|
5514
|
-
|
|
5508
|
+
command: runCommand,
|
|
5509
|
+
executable: executableOnPath,
|
|
5515
5510
|
gitBash: resolveGitBashForCurrentProcess
|
|
5516
5511
|
};
|
|
5517
5512
|
function check(id, status, code, detail, fix) {
|
|
@@ -5523,14 +5518,6 @@ function check(id, status, code, detail, fix) {
|
|
|
5523
5518
|
...fix === void 0 ? {} : { fix }
|
|
5524
5519
|
};
|
|
5525
5520
|
}
|
|
5526
|
-
function mcpConfigMatches(actual, expected) {
|
|
5527
|
-
const expectedEntries = Object.entries(expected);
|
|
5528
|
-
if (Object.keys(actual).length !== expectedEntries.length) return false;
|
|
5529
|
-
return expectedEntries.every(([key, expectedValue]) => {
|
|
5530
|
-
const actualValue = actual[key];
|
|
5531
|
-
return Array.isArray(expectedValue) ? Array.isArray(actualValue) && actualValue.length === expectedValue.length && actualValue.every((value, index) => value === expectedValue[index]) : actualValue === expectedValue;
|
|
5532
|
-
});
|
|
5533
|
-
}
|
|
5534
5521
|
async function missingFiles(root, paths) {
|
|
5535
5522
|
const missing = [];
|
|
5536
5523
|
for (const path of paths) try {
|
|
@@ -5540,138 +5527,82 @@ async function missingFiles(root, paths) {
|
|
|
5540
5527
|
}
|
|
5541
5528
|
return missing;
|
|
5542
5529
|
}
|
|
5543
|
-
function
|
|
5544
|
-
|
|
5545
|
-
const value = body === void 0 ? void 0 : new RegExp(`^\\s*${key}\\s*=\\s*(true|false)`, "m").exec(body)?.[1];
|
|
5546
|
-
return value === void 0 ? void 0 : value === "true";
|
|
5547
|
-
}
|
|
5548
|
-
function tableString(config, table, key) {
|
|
5549
|
-
const body = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
|
|
5550
|
-
return body === void 0 ? void 0 : rootTomlString(body, key);
|
|
5530
|
+
function tableBody(config, table) {
|
|
5531
|
+
return new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
|
|
5551
5532
|
}
|
|
5552
|
-
function
|
|
5553
|
-
const body =
|
|
5554
|
-
return body === void 0 ? void 0 :
|
|
5555
|
-
}
|
|
5556
|
-
function tableInteger(config, table, key) {
|
|
5557
|
-
const body = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
|
|
5558
|
-
const value = body === void 0 ? void 0 : new RegExp(`^\\s*${key}\\s*=\\s*(\\d+)`, "m").exec(body)?.[1];
|
|
5559
|
-
return value === void 0 ? void 0 : Number(value);
|
|
5533
|
+
function tableValue(config, table, key) {
|
|
5534
|
+
const body = tableBody(config, table);
|
|
5535
|
+
return body === void 0 ? void 0 : new RegExp(`^\\s*${key.replaceAll("-", "\\-")}\\s*=\\s*(.+?)\\s*$`, "m").exec(body)?.[1];
|
|
5560
5536
|
}
|
|
5561
5537
|
function autonomy(config) {
|
|
5562
5538
|
const approval = rootTomlString(config, "approval_policy");
|
|
5563
|
-
const
|
|
5539
|
+
const reviewer = rootTomlString(config, "approvals_reviewer");
|
|
5564
5540
|
const sandbox = rootTomlString(config, "sandbox_mode");
|
|
5565
|
-
const network =
|
|
5566
|
-
if (approval === "on-request" &&
|
|
5567
|
-
if (approval === "never" &&
|
|
5568
|
-
if (approval === "never" &&
|
|
5541
|
+
const network = tableValue(config, "sandbox_workspace_write", "network_access");
|
|
5542
|
+
if (approval === "on-request" && reviewer === "auto_review" && sandbox === "workspace-write" && network === "true") return "safe-workspace";
|
|
5543
|
+
if (approval === "never" && reviewer === void 0 && sandbox === "workspace-write" && network === "true") return "autonomous-workspace";
|
|
5544
|
+
if (approval === "never" && reviewer === void 0 && sandbox === "danger-full-access") return "dangerous";
|
|
5569
5545
|
return "unknown";
|
|
5570
5546
|
}
|
|
5571
|
-
/** Runs
|
|
5547
|
+
/** Runs installation, configuration, runtime, and override health checks. */
|
|
5572
5548
|
async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex"), runtime = defaultRuntime$1) {
|
|
5573
5549
|
const checks = [];
|
|
5574
5550
|
const pluginRoot = join(home, "plugins", "cache", "holycodex", "holycodex", VERSION);
|
|
5575
5551
|
const agentRoot = join(home, "holycodex", "agents");
|
|
5576
5552
|
const configPath = join(home, "config.toml");
|
|
5577
5553
|
let config = "";
|
|
5578
|
-
let configAvailable = true;
|
|
5579
5554
|
try {
|
|
5580
5555
|
config = await readFile(configPath, "utf8");
|
|
5581
5556
|
} catch {
|
|
5582
|
-
|
|
5557
|
+
checks.push(check("config", "error", "config-missing", `Missing ${configPath}.`, "Run holycodex install."));
|
|
5583
5558
|
}
|
|
5584
5559
|
const missing = await missingFiles(pluginRoot, [
|
|
5585
5560
|
".codex-plugin/plugin.json",
|
|
5586
|
-
".mcp.json",
|
|
5587
|
-
"LICENSE-OH-MY-OPENCODE-SLIM-MIT.txt",
|
|
5588
5561
|
"hooks/hooks.json",
|
|
5589
5562
|
...requiredPackageRuntimes(runtime.platform).map((file) => `runtime/${file}`),
|
|
5590
5563
|
...AGENTS.map((name) => `agents/${name}.toml`),
|
|
5591
5564
|
...SKILLS.map((name) => `skills/${name}/SKILL.md`)
|
|
5592
5565
|
]);
|
|
5593
|
-
checks.push(missing.length === 0 ? check("package", "ok", "package-ready", `Plugin ${VERSION},
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
const
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
} else if (runtime.platform !== "win32" && gitBashConfig !== void 0) checks.push(check("mcp-git_bash-config", "error", "unexpected-git-bash-mcp", "Git Bash MCP must not be installed on non-Windows platforms.", "Reinstall HolyCodex for this platform."));
|
|
5613
|
-
const context7 = servers?.context7;
|
|
5614
|
-
const expectedContext7 = effectiveMcpServers(runtime.platform).context7;
|
|
5615
|
-
const obsoleteAuth = context7 !== void 0 && [
|
|
5616
|
-
"headers",
|
|
5617
|
-
"env",
|
|
5618
|
-
"authorization",
|
|
5619
|
-
"apiKey"
|
|
5620
|
-
].some((key) => key in context7);
|
|
5621
|
-
if (context7 === void 0) checks.push(check("context7-config", "error", "missing-context7", "Context7 is not configured.", "Reinstall HolyCodex."));
|
|
5622
|
-
else if (string().safeParse(context7.url).success) checks.push(check("context7-config", "error", "obsolete-context7-remote", "Context7 still uses a hosted URL.", "Reinstall to use local bunx Context7."));
|
|
5623
|
-
else if (obsoleteAuth) checks.push(check("context7-config", "error", "obsolete-context7-auth", "Context7 contains obsolete authentication settings.", "Remove auth settings and reinstall."));
|
|
5624
|
-
else if (expectedContext7 === void 0 || !mcpConfigMatches(context7, expectedContext7)) checks.push(check("context7-config", "error", "invalid-context7-config", "Context7 launch configuration is stale or contains unsupported settings.", "Repair .mcp.json or reinstall."));
|
|
5625
|
-
else checks.push(check("context7-config", "ok", "local-context7-config", "Local no-auth Context7 is configured."));
|
|
5626
|
-
const bun = await runtime.command("bun", ["--version"]);
|
|
5627
|
-
const bunx = await runtime.command("bunx", ["--version"]);
|
|
5628
|
-
checks.push(bun.ok ? check("bun", "ok", "bun-ready", `Bun ${bun.output || "available"}.`) : check("bun", "error", "missing-bun", "Bun is unavailable.", "Install or repair Bun."));
|
|
5629
|
-
checks.push(bunx.ok ? check("bunx", "ok", "bunx-ready", `bunx ${bunx.output || "available"}.`) : check("bunx", "error", "missing-bunx", "bunx is unavailable.", "Repair the Bun installation."));
|
|
5630
|
-
if (bun.ok && bunx.ok && checks.some((item) => item.code === "local-context7-config")) {
|
|
5631
|
-
const started = await runtime.context7();
|
|
5632
|
-
checks.push(started.ok && !started.timedOut ? check("context7-startup", "ok", "context7-healthy", "Context7 completed a bounded MCP handshake.") : started.packageFailure ? check("context7-startup", "error", "context7-package-resolution-failed", started.detail || "Context7 package resolution failed.", "Check network/package availability.") : check("context7-startup", "error", "context7-startup-failed", started.detail || "Context7 did not complete an MCP handshake within 15 seconds.", runtime.platform === "win32" ? "Run bunx @upstash/context7-mcp in Git Bash." : "Run bunx @upstash/context7-mcp in the native shell."));
|
|
5633
|
-
}
|
|
5566
|
+
checks.push(missing.length === 0 ? check("package", "ok", "package-ready", `Plugin ${VERSION}, runtimes, agents, and ${SKILLS.length} skills are present.`) : check("package", "error", "package-incomplete", `Missing ${missing.join(", ")}.`, "Reinstall HolyCodex."));
|
|
5567
|
+
const webSearchOverride = readPreservedRootOverrides(config).webSearch;
|
|
5568
|
+
checks.push(rootTomlString(config, "web_search") === "live" ? check("web-search", "ok", "live-web-search", "Managed web search defaults to live.") : webSearchOverride ? check("web-search", "ok", "web-search-override", "An intentional user web-search override is preserved.") : check("web-search", "error", "web-search-not-live", "Managed web search is not live.", "Reinstall HolyCodex."));
|
|
5569
|
+
const status = rootTomlStringArray(config, "status_line") ?? rootTomlStringArray(tableBody(config, "tui") ?? "", "status_line");
|
|
5570
|
+
checks.push(status?.includes("context-remaining") ? check("context-visibility", "ok", "context-visible", "Context-window usage remains visible.") : check("context-visibility", "error", "context-hidden", "The status line does not show context remaining.", "Reinstall HolyCodex."));
|
|
5571
|
+
checks.push(check("screenshot", "ok", "screenshot-default-preserved", "HolyCodex does not override the enabled Codex screenshot default."));
|
|
5572
|
+
const context7 = context7Command(["--version"], runtime.executable);
|
|
5573
|
+
if (context7 === void 0) checks.push(check("context7", "error", "context7-runner-missing", "No supported direct Context7 runner is available.", "Install nub, Bun, pnpm, npm, or Yarn."));
|
|
5574
|
+
else checks.push(check("context7", "ok", "context7-cli-ready", `${context7.command} constructs a valid direct ctx7@latest command.`));
|
|
5575
|
+
const lsp = await runtime.command(process.execPath, [
|
|
5576
|
+
join(pluginRoot, "runtime", "lsp.js"),
|
|
5577
|
+
"status",
|
|
5578
|
+
"--json"
|
|
5579
|
+
], {
|
|
5580
|
+
...process.env,
|
|
5581
|
+
HOLYCODEX_LSP_IDLE_SHUTDOWN_MS: "0",
|
|
5582
|
+
HOLYCODEX_LSP_IDLE_CHECK_INTERVAL_MS: "50"
|
|
5583
|
+
});
|
|
5584
|
+
checks.push(lsp.ok ? check("lsp", "ok", "lsp-cli-ready", "The LSP CLI and daemon are reachable.") : check("lsp", "error", "lsp-cli-failed", lsp.output || "LSP CLI failed.", "Reinstall HolyCodex and inspect the reported daemon log."));
|
|
5634
5585
|
if (runtime.platform === "win32") {
|
|
5635
|
-
const
|
|
5636
|
-
checks.push(
|
|
5637
|
-
}
|
|
5638
|
-
if (!configAvailable) checks.push(check("codex-config", "error", "missing-codex-config", `Missing ${configPath}.`, "Run holycodex install."));
|
|
5639
|
-
const mode = autonomy(config);
|
|
5586
|
+
const resolution = runtime.gitBash();
|
|
5587
|
+
checks.push(resolution.found ? check("git-bash", "ok", "git-bash-launcher-ready", `Git Bash resolves at ${resolution.path}; the bundled launcher is present.`) : check("git-bash", "error", "git-bash-unavailable", resolution.installHint, resolution.installHint));
|
|
5588
|
+
}
|
|
5640
5589
|
const plan = readManagedPlan(config);
|
|
5641
|
-
|
|
5642
|
-
const
|
|
5643
|
-
const
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
checks.push(tableBoolean(config, "features", "default_mode_request_user_input") === true ? check("user-input", "ok", "user-input-ready", "default_mode_request_user_input is enabled.") : check("user-input", "error", "user-input-disabled", "default_mode_request_user_input is not enabled.", "Rerun holycodex install."));
|
|
5653
|
-
checks.push(tableStringArray(config, "desktop", "enabled-reasoning-efforts")?.join(",") === "low,medium,high,xhigh,max" ? check("desktop-reasoning", "ok", "desktop-reasoning-ready", "Desktop exposes low through max reasoning efforts.") : check("desktop-reasoning", "error", "desktop-reasoning-stale", "Desktop reasoning choices must include low through max.", "Reinstall HolyCodex."));
|
|
5654
|
-
checks.push(tableBoolean(config, "desktop", "show-context-window-usage") === true ? check("desktop-context-usage", "ok", "desktop-context-usage-ready", "Desktop context-window usage is visible.") : check("desktop-context-usage", "error", "desktop-context-usage-hidden", "Desktop context-window usage is not enabled.", "Reinstall HolyCodex."));
|
|
5655
|
-
checks.push(rootTomlStringArray(config, "status_line")?.includes("context-remaining") === true ? check("context-visibility", "warning", "context-visible-support-unverified", "status_line includes context-remaining. Current official Codex config documents this item, but publishes no minimum compatible Codex version.") : check("context-visibility", "error", "context-hidden", "status_line does not include context-remaining.", "Rerun holycodex install."));
|
|
5656
|
-
const codex = await runtime.command("codex", ["--version"]);
|
|
5657
|
-
checks.push(codex.ok ? check("codex", "ok", "codex-version", codex.output || "Codex is available.") : check("codex", "warning", "codex-version-unavailable", "Codex version could not be read; status-line compatibility cannot be independently confirmed."));
|
|
5658
|
-
if (runtime.platform === "win32") checks.push(tableString(config, "windows", "sandbox") === "unelevated" ? check("windows-sandbox", "ok", "windows-sandbox-ready", "Windows sandbox runs unelevated.") : check("windows-sandbox", "error", "windows-sandbox-stale", "Windows sandbox must run unelevated.", "Reinstall HolyCodex on Windows."));
|
|
5659
|
-
const agentModelFailures = [];
|
|
5660
|
-
const agentTierValues = [];
|
|
5661
|
-
for (const agent of AGENTS) try {
|
|
5662
|
-
const text = await readFile(join(agentRoot, `${agent}.toml`), "utf8");
|
|
5663
|
-
const expected = plan === void 0 ? void 0 : MODEL_ROUTING_PLANS[plan].agents[agent];
|
|
5664
|
-
if (expected === void 0 || rootTomlString(text, "model") !== expected.model || rootTomlString(text, "model_reasoning_effort") !== expected.reasoningEffort) agentModelFailures.push(agent);
|
|
5665
|
-
agentTierValues.push(rootTomlString(text, "service_tier"));
|
|
5666
|
-
} catch {
|
|
5667
|
-
agentModelFailures.push(agent);
|
|
5590
|
+
const overrides = readPreservedRootOverrides(config);
|
|
5591
|
+
const fast = readManagedFastMode(config);
|
|
5592
|
+
const max = readManagedMaxSubagents(config);
|
|
5593
|
+
checks.push(plan === void 0 ? check("routes", "error", "route-plan-missing", "Managed route plan metadata is missing.", "Reinstall HolyCodex.") : check("routes", "ok", "routes-ready", `${plan} routes are active${max.configured ? ` with max-subagents=${max.value ?? "invalid"}` : ""}.`));
|
|
5594
|
+
checks.push(overrides.model || overrides.reasoningEffort ? check("root-overrides", "ok", "root-overrides-preserved", "Intentional Root model or reasoning overrides are preserved and healthy.") : check("root-overrides", "ok", "root-managed-defaults", "Root uses managed route defaults."));
|
|
5595
|
+
if (plan !== void 0 && fast === void 0) checks.push(check("fast", "warning", "fast-metadata-missing", "Fast metadata is missing; doctor will not guess a service tier.", "Reinstall with an explicit Fast mode."));
|
|
5596
|
+
if (plan !== void 0) for (const agent of AGENTS) {
|
|
5597
|
+
const source = await readFile(join(agentRoot, `${agent}.toml`), "utf8").catch(() => "");
|
|
5598
|
+
const expected = MODEL_ROUTING_PLANS[plan].agents[agent];
|
|
5599
|
+
const overridden = rootTomlString(source, "model") !== expected.model || rootTomlString(source, "model_reasoning_effort") !== expected.reasoningEffort;
|
|
5600
|
+
checks.push(check(`agent-${agent}`, "ok", overridden ? "agent-override-preserved" : "agent-managed-default", overridden ? `${agent} has an intentional healthy route override.` : `${agent} uses managed route defaults.`));
|
|
5668
5601
|
}
|
|
5669
|
-
|
|
5670
|
-
const expectedAgentTier = managedFastMode === "standard" ? "default" : "fast";
|
|
5671
|
-
if (agentTierValues.some((value) => value !== void 0)) checks.push(agentTierValues.every((value) => value === expectedAgentTier) ? check("agent-service-tiers", "ok", "agent-service-tiers-ready", `Specialist service tiers use ${expectedAgentTier}.`) : check("agent-service-tiers", "error", "agent-service-tiers-stale", `Specialist service tiers must use ${expectedAgentTier}.`, "Reinstall HolyCodex."));
|
|
5602
|
+
for (const key of COMPATIBILITY_KEYS) if (config.includes(key.split(".")[1] ?? key)) checks.push(check(`compat-${key}`, "warning", "compatibility-sensitive-key", `${key} is compatibility-sensitive and isolated from supported managed Codex keys.`));
|
|
5672
5603
|
return {
|
|
5673
|
-
healthy:
|
|
5674
|
-
autonomy:
|
|
5604
|
+
healthy: checks.every((item) => item.status !== "error"),
|
|
5605
|
+
autonomy: autonomy(config),
|
|
5675
5606
|
checks
|
|
5676
5607
|
};
|
|
5677
5608
|
}
|
|
@@ -5821,8 +5752,14 @@ function deduplicate(candidates) {
|
|
|
5821
5752
|
}
|
|
5822
5753
|
//#endregion
|
|
5823
5754
|
//#region packages/cli/src/codex-security.ts
|
|
5824
|
-
var CODEX_SECURITY_PLUGIN =
|
|
5825
|
-
|
|
5755
|
+
var CODEX_SECURITY_PLUGIN = {
|
|
5756
|
+
id: "codex-security@openai-curated",
|
|
5757
|
+
marketplace: "openai-curated"
|
|
5758
|
+
};
|
|
5759
|
+
var COMPUTER_USE_PLUGIN = {
|
|
5760
|
+
id: "computer-use@openai-bundled",
|
|
5761
|
+
marketplace: "openai-bundled"
|
|
5762
|
+
};
|
|
5826
5763
|
var CODEX_PLUGIN_OPERATIONAL_TIMEOUT_MS = 15e3;
|
|
5827
5764
|
var CODEX_PACKAGE_BOOTSTRAP_TIMEOUT_MS = 12e4;
|
|
5828
5765
|
var MAX_CODEX_CATALOG_DIAGNOSTIC_CHARS = 256 * 1024;
|
|
@@ -5863,6 +5800,14 @@ var FATAL_POLICY_CODES = /* @__PURE__ */ new Set([
|
|
|
5863
5800
|
]);
|
|
5864
5801
|
/** Installs or enables the official Codex Security plugin without failing HolyCodex installation. */
|
|
5865
5802
|
async function installCodexSecurity(runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
5803
|
+
return installOfficialPlugin(CODEX_SECURITY_PLUGIN, runProcess, platform, env, options);
|
|
5804
|
+
}
|
|
5805
|
+
/** Installs or enables the official Computer Use plugin without failing HolyCodex installation. */
|
|
5806
|
+
async function installComputerUse(runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
5807
|
+
return installOfficialPlugin(COMPUTER_USE_PLUGIN, runProcess, platform, env, options);
|
|
5808
|
+
}
|
|
5809
|
+
/** Installs or enables one official Codex plugin through a verified catalog entry. */
|
|
5810
|
+
async function installOfficialPlugin(plugin, runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
5866
5811
|
const runtimeFacts = options.runtimeFacts ?? (runProcess === runManagedProcess ? defaultCodexLauncherRuntimeFacts(platform) : void 0);
|
|
5867
5812
|
const candidates = createCodexLauncherCandidates({
|
|
5868
5813
|
...options.injected === void 0 ? {} : { injected: options.injected },
|
|
@@ -5882,7 +5827,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5882
5827
|
continue;
|
|
5883
5828
|
}
|
|
5884
5829
|
if (installedOutcome.kind === "fatal") return skipped(installedOutcome.reason, attemptedLaunchers);
|
|
5885
|
-
const installedPlugin = findPlugin(installedOutcome.catalog);
|
|
5830
|
+
const installedPlugin = findPlugin(installedOutcome.catalog, plugin.id);
|
|
5886
5831
|
if (installedPlugin?.installed === true && installedPlugin.enabled === true) return {
|
|
5887
5832
|
status: "already-installed",
|
|
5888
5833
|
launcherSource: launcher.source
|
|
@@ -5900,7 +5845,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5900
5845
|
continue;
|
|
5901
5846
|
}
|
|
5902
5847
|
if (catalogOutcome.kind === "fatal") return skipped(catalogOutcome.reason, attemptedLaunchers);
|
|
5903
|
-
if (findPlugin(catalogOutcome.catalog) === void 0) {
|
|
5848
|
+
if (findPlugin(catalogOutcome.catalog, plugin.id) === void 0) {
|
|
5904
5849
|
const marketplaceOutcome = inspectMarketplaceResult(await runCodexPlugin(runProcess, launcher, [
|
|
5905
5850
|
"plugin",
|
|
5906
5851
|
"marketplace",
|
|
@@ -5912,14 +5857,14 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5912
5857
|
continue;
|
|
5913
5858
|
}
|
|
5914
5859
|
if (marketplaceOutcome.kind === "fatal") return skipped(marketplaceOutcome.reason, attemptedLaunchers);
|
|
5915
|
-
fallbackReasons.push(marketplaceOutcome.marketplaces.includes(
|
|
5860
|
+
fallbackReasons.push(marketplaceOutcome.marketplaces.includes(plugin.marketplace) ? "plugin-not-offered" : "marketplace-unavailable");
|
|
5916
5861
|
continue;
|
|
5917
5862
|
}
|
|
5918
5863
|
}
|
|
5919
5864
|
const addOutcome = inspectAddResult(await runCodexPlugin(runProcess, launcher, [
|
|
5920
5865
|
"plugin",
|
|
5921
5866
|
"add",
|
|
5922
|
-
|
|
5867
|
+
plugin.id,
|
|
5923
5868
|
"--json"
|
|
5924
5869
|
], platform, env, "add"), launcher);
|
|
5925
5870
|
if (addOutcome.kind === "fallback") {
|
|
@@ -5937,7 +5882,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5937
5882
|
continue;
|
|
5938
5883
|
}
|
|
5939
5884
|
if (verification.kind === "fatal") return skipped(verification.reason, attemptedLaunchers);
|
|
5940
|
-
const verifiedPlugin = findPlugin(verification.catalog);
|
|
5885
|
+
const verifiedPlugin = findPlugin(verification.catalog, plugin.id);
|
|
5941
5886
|
if (verifiedPlugin?.installed !== true || verifiedPlugin.enabled !== true) {
|
|
5942
5887
|
fallbackReasons.push("verification-failed");
|
|
5943
5888
|
continue;
|
|
@@ -6024,8 +5969,8 @@ function inspectMarketplaceResult(result, launcher) {
|
|
|
6024
5969
|
marketplaces
|
|
6025
5970
|
};
|
|
6026
5971
|
}
|
|
6027
|
-
function findPlugin(catalog) {
|
|
6028
|
-
return catalog.plugins.find(({ id }) => id ===
|
|
5972
|
+
function findPlugin(catalog, pluginId) {
|
|
5973
|
+
return catalog.plugins.find(({ id }) => id === pluginId);
|
|
6029
5974
|
}
|
|
6030
5975
|
function classifyFailure(result, launcher) {
|
|
6031
5976
|
if (result.error !== void 0) {
|
|
@@ -6363,6 +6308,7 @@ var defaultRuntime = {
|
|
|
6363
6308
|
gitBash: resolveGitBashForCurrentProcess,
|
|
6364
6309
|
runProcess: runManagedProcess
|
|
6365
6310
|
};
|
|
6311
|
+
var BACKUP_RETENTION = 5;
|
|
6366
6312
|
function paths(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")) {
|
|
6367
6313
|
const marketplaceCache = join(home, "plugins", "cache", "holycodex");
|
|
6368
6314
|
const cacheRoot = join(marketplaceCache, "holycodex");
|
|
@@ -6390,43 +6336,87 @@ function assertGitBashReady(platform, resolution) {
|
|
|
6390
6336
|
}
|
|
6391
6337
|
/** Provides install. */
|
|
6392
6338
|
async function install(options, runtime = defaultRuntime) {
|
|
6339
|
+
notify(options, "prerequisites", "Checking prerequisites", "running");
|
|
6393
6340
|
assertGitBashReady(runtime.platform, runtime.gitBash());
|
|
6341
|
+
notify(options, "prerequisites", "Checking prerequisites", "complete");
|
|
6394
6342
|
const plan = options.plan ?? "plus";
|
|
6395
6343
|
const target = paths();
|
|
6396
6344
|
const root = backupRoot();
|
|
6345
|
+
notify(options, "backup", "Backing up existing installation", "running");
|
|
6346
|
+
const configBackup = await backup(target.config, root);
|
|
6347
|
+
const cacheBackup = await backup(target.marketplaceCache, root);
|
|
6348
|
+
const agentsBackup = await backup(target.agents, root);
|
|
6397
6349
|
const backups = [
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6350
|
+
configBackup,
|
|
6351
|
+
cacheBackup,
|
|
6352
|
+
agentsBackup,
|
|
6401
6353
|
...await Promise.all(target.legacy.map((path) => backup(path, root)))
|
|
6402
6354
|
].filter((path) => path !== void 0);
|
|
6355
|
+
notify(options, "backup", "Backing up existing installation", "complete", `${backups.length} saved`);
|
|
6356
|
+
notify(options, "configuration", "Preparing configuration", "running");
|
|
6403
6357
|
const existingConfig = await readText(target.config);
|
|
6404
6358
|
const previousPlan = readManagedPlan(existingConfig);
|
|
6405
6359
|
const fastMode = options.fast ?? "standard";
|
|
6406
6360
|
const config = installConfig(existingConfig, options.autonomy, runtime.platform, plan, options.maxSubagents, fastMode);
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
recursive: true,
|
|
6410
|
-
force: true
|
|
6411
|
-
});
|
|
6412
|
-
await mkdir(dirname(target.cache), { recursive: true });
|
|
6413
|
-
await cp(pluginRoot, target.cache, { recursive: true });
|
|
6414
|
-
await writePlatformPlugin(target.cache, runtime.platform, plan, fastMode);
|
|
6361
|
+
notify(options, "configuration", "Preparing configuration", "complete", plan);
|
|
6362
|
+
notify(options, "staging", "Staging plugin and agent files", "running");
|
|
6415
6363
|
const existingAgentPreferences = await readAgentPreferences(target.agents, previousPlan);
|
|
6416
|
-
await
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
});
|
|
6420
|
-
await
|
|
6421
|
-
await
|
|
6422
|
-
await
|
|
6364
|
+
const staging = await mkdtemp(join(tmpdir(), "holycodex-stage-"));
|
|
6365
|
+
const stagedCache = join(staging, "cache");
|
|
6366
|
+
const stagedAgents = join(staging, "agents");
|
|
6367
|
+
await cp(pluginRoot, stagedCache, { recursive: true });
|
|
6368
|
+
await writeInstalledAgents(join(stagedCache, "agents"), runtime.platform, plan, fastMode);
|
|
6369
|
+
await cp(join(pluginRoot, "agents"), stagedAgents, { recursive: true });
|
|
6370
|
+
await writeInstalledAgents(stagedAgents, runtime.platform, plan, fastMode);
|
|
6371
|
+
await preserveAgentPreferences(stagedAgents, existingAgentPreferences, plan, fastMode);
|
|
6372
|
+
notify(options, "staging", "Staging plugin and agent files", "complete");
|
|
6373
|
+
notify(options, "validation", "Validating staged installation", "running");
|
|
6374
|
+
await validateStaging(stagedCache, stagedAgents);
|
|
6375
|
+
notify(options, "validation", "Validating staged installation", "complete");
|
|
6423
6376
|
const removedLegacy = [];
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6377
|
+
let codexSecurity;
|
|
6378
|
+
let computerUse;
|
|
6379
|
+
try {
|
|
6380
|
+
notify(options, "managed-files", "Installing managed files", "running");
|
|
6381
|
+
await atomicWrite(target.config, config);
|
|
6382
|
+
await rm(target.cache, {
|
|
6383
|
+
recursive: true,
|
|
6384
|
+
force: true
|
|
6385
|
+
});
|
|
6386
|
+
await mkdir(dirname(target.cache), { recursive: true });
|
|
6387
|
+
await cp(stagedCache, target.cache, { recursive: true });
|
|
6388
|
+
await rm(target.agents, {
|
|
6389
|
+
recursive: true,
|
|
6390
|
+
force: true
|
|
6391
|
+
});
|
|
6392
|
+
await cp(stagedAgents, target.agents, { recursive: true });
|
|
6393
|
+
for (const path of target.legacy) {
|
|
6394
|
+
if (!await exists(path)) continue;
|
|
6395
|
+
await rm(path, { recursive: true });
|
|
6396
|
+
removedLegacy.push(path);
|
|
6397
|
+
}
|
|
6398
|
+
notify(options, "managed-files", "Installing managed files", "complete");
|
|
6399
|
+
notify(options, "codex-security", "Installing Codex Security", "running");
|
|
6400
|
+
codexSecurity = await installCodexSecurity(runtime.runProcess, runtime.platform, process.env);
|
|
6401
|
+
notify(options, "codex-security", "Installing Codex Security", "complete", pluginProgressDetail(codexSecurity));
|
|
6402
|
+
notify(options, "computer-use", "Installing Computer Use", "running");
|
|
6403
|
+
computerUse = await installComputerUse(runtime.runProcess, runtime.platform, process.env);
|
|
6404
|
+
notify(options, "computer-use", "Installing Computer Use", "complete", pluginProgressDetail(computerUse));
|
|
6405
|
+
notify(options, "cleanup", "Removing obsolete caches", "running");
|
|
6406
|
+
await removeObsoleteVersionCaches(target.cacheRoot);
|
|
6407
|
+
notify(options, "cleanup", "Removing obsolete caches", "complete");
|
|
6408
|
+
} catch (error) {
|
|
6409
|
+
await restoreTarget(target.config, configBackup);
|
|
6410
|
+
await restoreTarget(target.marketplaceCache, cacheBackup);
|
|
6411
|
+
await restoreTarget(target.agents, agentsBackup);
|
|
6412
|
+
throw error;
|
|
6413
|
+
} finally {
|
|
6414
|
+
await rm(staging, {
|
|
6415
|
+
recursive: true,
|
|
6416
|
+
force: true
|
|
6417
|
+
});
|
|
6428
6418
|
}
|
|
6429
|
-
|
|
6419
|
+
await pruneBackupHistory();
|
|
6430
6420
|
return {
|
|
6431
6421
|
action: "install",
|
|
6432
6422
|
changed: [
|
|
@@ -6438,9 +6428,56 @@ async function install(options, runtime = defaultRuntime) {
|
|
|
6438
6428
|
backups,
|
|
6439
6429
|
plan,
|
|
6440
6430
|
codexSecurity,
|
|
6431
|
+
computerUse,
|
|
6441
6432
|
...options.maxSubagents === void 0 ? {} : { maxSubagents: options.maxSubagents }
|
|
6442
6433
|
};
|
|
6443
6434
|
}
|
|
6435
|
+
function notify(options, step, label, status, detail) {
|
|
6436
|
+
options.onProgress?.({
|
|
6437
|
+
step,
|
|
6438
|
+
label,
|
|
6439
|
+
status,
|
|
6440
|
+
...detail === void 0 ? {} : { detail }
|
|
6441
|
+
});
|
|
6442
|
+
}
|
|
6443
|
+
function pluginProgressDetail(result) {
|
|
6444
|
+
if (result.status === "skipped") return `skipped: ${result.reason}`;
|
|
6445
|
+
return result.launcherSource === void 0 ? result.status : `${result.status} via ${result.launcherSource}`;
|
|
6446
|
+
}
|
|
6447
|
+
async function validateStaging(cache, agents) {
|
|
6448
|
+
const required = [
|
|
6449
|
+
join(cache, ".codex-plugin", "plugin.json"),
|
|
6450
|
+
join(cache, "skills", "context7-cli", "SKILL.md"),
|
|
6451
|
+
join(cache, "runtime", "lsp.js"),
|
|
6452
|
+
...AGENTS.map((agent) => join(agents, `${agent}.toml`))
|
|
6453
|
+
];
|
|
6454
|
+
const missing = [];
|
|
6455
|
+
for (const path of required) if (!await exists(path)) missing.push(path);
|
|
6456
|
+
if (missing.length > 0) throw new Error(`Staged HolyCodex installation is incomplete: ${missing.join(", ")}`);
|
|
6457
|
+
}
|
|
6458
|
+
async function restoreTarget(target, source) {
|
|
6459
|
+
await rm(target, {
|
|
6460
|
+
recursive: true,
|
|
6461
|
+
force: true
|
|
6462
|
+
});
|
|
6463
|
+
if (source !== void 0) await cp(source, target, { recursive: true });
|
|
6464
|
+
}
|
|
6465
|
+
async function removeObsoleteVersionCaches(cacheRoot) {
|
|
6466
|
+
if (!await exists(cacheRoot)) return;
|
|
6467
|
+
for (const entry of await readdir(cacheRoot)) if (entry !== "0.11.3") await rm(join(cacheRoot, entry), {
|
|
6468
|
+
recursive: true,
|
|
6469
|
+
force: true
|
|
6470
|
+
});
|
|
6471
|
+
}
|
|
6472
|
+
async function pruneBackupHistory() {
|
|
6473
|
+
const root = join(tmpdir(), "holycodex-backups");
|
|
6474
|
+
if (!await exists(root)) return;
|
|
6475
|
+
const entries = (await readdir(root)).sort().reverse();
|
|
6476
|
+
await Promise.allSettled(entries.slice(BACKUP_RETENTION, 6).map((entry) => rm(join(root, entry), {
|
|
6477
|
+
recursive: true,
|
|
6478
|
+
force: true
|
|
6479
|
+
})));
|
|
6480
|
+
}
|
|
6444
6481
|
var AGENT_MANAGED_KEYS = /* @__PURE__ */ new Set([
|
|
6445
6482
|
"model",
|
|
6446
6483
|
"model_reasoning_effort",
|
|
@@ -6448,7 +6485,6 @@ var AGENT_MANAGED_KEYS = /* @__PURE__ */ new Set([
|
|
|
6448
6485
|
"service_tier"
|
|
6449
6486
|
]);
|
|
6450
6487
|
var AGENT_BUNDLED_KEYS = /* @__PURE__ */ new Set(["description", "developer_instructions"]);
|
|
6451
|
-
var COMPACT_WINDOWS_SHELL_POLICY = /^On native Windows, resolve `mcp__git_bash__run` before shell use;[^\r\n]*never use PowerShell\/cmd\.\r?\n\r?\n/m;
|
|
6452
6488
|
async function readAgentPreferences(root, previousPlan) {
|
|
6453
6489
|
const preferences = {};
|
|
6454
6490
|
await Promise.all(AGENTS.map(async (agent) => {
|
|
@@ -6513,26 +6549,27 @@ function mergeCustomAgentSettings(input, custom) {
|
|
|
6513
6549
|
if (custom.tables !== void 0 && !output.includes(custom.tables)) output = `${output.trimEnd()}\n\n${custom.tables}`;
|
|
6514
6550
|
return `${output.trimEnd()}\n`;
|
|
6515
6551
|
}
|
|
6516
|
-
async function writePlatformPlugin(root, platform, plan, fastMode) {
|
|
6517
|
-
await atomicWrite(join(root, ".mcp.json"), `${JSON.stringify({ mcpServers: effectiveMcpServers(platform) }, null, 2)}\n`);
|
|
6518
|
-
await writeInstalledAgents(join(root, "agents"), platform, plan, fastMode);
|
|
6519
|
-
}
|
|
6520
6552
|
async function writeInstalledAgents(root, platform, plan, fastMode) {
|
|
6521
6553
|
await Promise.all(AGENTS.map(async (agent) => {
|
|
6522
6554
|
const path = join(root, `${agent}.toml`);
|
|
6523
6555
|
const route = MODEL_ROUTING_PLANS[plan].agents[agent];
|
|
6524
6556
|
let source = await readText(path);
|
|
6557
|
+
source = composeAgentPolicies(source, platform);
|
|
6525
6558
|
source = replaceTomlString(source, "model", route.model);
|
|
6526
6559
|
source = replaceTomlString(source, "model_reasoning_effort", route.reasoningEffort);
|
|
6527
6560
|
source = replaceTomlString(source, "model_verbosity", "low");
|
|
6528
6561
|
source = replaceOrAppendTomlString(source, "service_tier", fastMode === "standard" ? "default" : "fast");
|
|
6529
|
-
|
|
6530
|
-
await atomicWrite(path, source);
|
|
6531
|
-
return;
|
|
6532
|
-
}
|
|
6533
|
-
await atomicWrite(path, source.replace(`${WINDOWS_SHELL_POLICY}\r\n\r\n`, "").replace(`${WINDOWS_SHELL_POLICY}\n\n`, "").replace(COMPACT_WINDOWS_SHELL_POLICY, ""));
|
|
6562
|
+
await atomicWrite(path, source);
|
|
6534
6563
|
}));
|
|
6535
6564
|
}
|
|
6565
|
+
function composeAgentPolicies(input, platform) {
|
|
6566
|
+
const policy = [
|
|
6567
|
+
LITE_WRITING_POLICY,
|
|
6568
|
+
CONTEXT7_POLICY,
|
|
6569
|
+
...platform === "win32" ? [WINDOWS_SHELL_POLICY] : []
|
|
6570
|
+
].join("\n\n");
|
|
6571
|
+
return input.replace(/(developer_instructions\s*=\s*"""\r?\n)/, `$1${policy}\n\n`);
|
|
6572
|
+
}
|
|
6536
6573
|
/** Provides cleanup. */
|
|
6537
6574
|
async function cleanup(_options) {
|
|
6538
6575
|
const target = paths();
|
|
@@ -6596,17 +6633,21 @@ function renderHelp(version, color) {
|
|
|
6596
6633
|
const title = paint(color, `${BOLD}${CYAN}`, `HolyCodex ${version}`);
|
|
6597
6634
|
const section = (text) => paint(color, BOLD, text);
|
|
6598
6635
|
const muted = (text) => paint(color, DIM, text);
|
|
6599
|
-
return `${title}\n${muted("Lean Codex toolkit installer and doctor")}\n\n${section("USAGE")}\n holycodex <command> [options]\n\n${section("COMMANDS")}\n install Install or update HolyCodex\n cleanup Remove HolyCodex-owned state\n doctor Diagnose installation and runtime\n\n${section("OPTIONS")}\n --plan <plan> Model routing plan for install: ${PLAN_HELP}\n Default: ${DEFAULT_PLAN}\n --max-subagents <count> Override concurrent direct subagents for install\n --fast Use Fast for generated subagents only\n --fast-all Use Fast for Root and generated subagents\n --no-fast Use Standard for Root and generated subagents\n -h, --help Show help\n -v, --version Show version\n --no-tui Accepted; commands remain noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n --
|
|
6636
|
+
return `${title}\n${muted("Lean Codex toolkit installer and doctor")}\n\n${section("USAGE")}\n holycodex <command> [options]\n\n${section("COMMANDS")}\n install Install or update HolyCodex\n cleanup Remove HolyCodex-owned state\n doctor Diagnose installation and runtime\n\n${section("OPTIONS")}\n --plan <plan> Model routing plan for install: ${PLAN_HELP}\n Default: ${DEFAULT_PLAN}\n --max-subagents <count> Override concurrent direct subagents for install\n --fast Use Fast for generated subagents only\n --fast-all Use Fast for Root and generated subagents\n --no-fast Use Standard for Root and generated subagents\n -h, --help Show help\n -v, --version Show version\n --no-tui Accepted; commands remain noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n install --verbose Show detailed install steps
|
|
6637
|
+
--json Print machine-readable output\n`;
|
|
6600
6638
|
}
|
|
6601
6639
|
/** Renders install-specific model plan and option help. */
|
|
6602
6640
|
function renderInstallHelp(version, color) {
|
|
6603
6641
|
const title = paint(color, `${BOLD}${CYAN}`, `HolyCodex ${version}`);
|
|
6604
6642
|
const section = (text) => paint(color, BOLD, text);
|
|
6605
|
-
return `${title}\n\n${section("Usage:")}\n holycodex install [options]\n\n${section("Options:")}\n --plan <plan> Model routing plan: ${PLAN_HELP}\n Default: ${DEFAULT_PLAN}\n --max-subagents <count> Override concurrent direct subagents\n --fast Use Fast for generated subagents only\n --fast-all Use Fast for Root and generated subagents\n --no-fast Use Standard for Root and generated subagents\n
|
|
6643
|
+
return `${title}\n\n${section("Usage:")}\n holycodex install [options]\n\n${section("Options:")}\n --plan <plan> Model routing plan: ${PLAN_HELP}\n Default: ${DEFAULT_PLAN}\n --max-subagents <count> Override concurrent direct subagents\n --fast Use Fast for generated subagents only\n --fast-all Use Fast for Root and generated subagents\n --no-fast Use Standard for Root and generated subagents\n -v, --verbose Show detailed install steps
|
|
6644
|
+
--json Print machine-readable output\n --no-tui Accepted; install remains noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n -h, --help Show help\n\nPlans provide increasing expected model usage and capability. Fast flags are mutually exclusive.\n\n${section("Examples:")}\n bunx holycodex install\n bunx holycodex install --plan go\n bunx holycodex install --plan plus-low --fast\n bunx holycodex install --plan plus-high\n bunx holycodex install --plan pro-5x --fast-all\n bunx holycodex install --plan pro-20x --no-fast\n`;
|
|
6606
6645
|
}
|
|
6607
6646
|
/** Renders error. */
|
|
6608
6647
|
function renderError(message, color) {
|
|
6609
|
-
|
|
6648
|
+
const label = paint(color, `${BOLD}${RED}`, "✗ ERROR");
|
|
6649
|
+
const hint = paint(color, DIM, "Run holycodex --help for usage.");
|
|
6650
|
+
return `${color ? "\r\x1B[2K" : ""}${label} ${message}\n ${hint}\n`;
|
|
6610
6651
|
}
|
|
6611
6652
|
/** Renders doctor. */
|
|
6612
6653
|
function renderDoctor(result, color) {
|
|
@@ -6622,14 +6663,17 @@ function renderRunResult(result, color) {
|
|
|
6622
6663
|
const action = result.action === "install" ? "Updated" : "Removed";
|
|
6623
6664
|
const empty = result.action === "install" ? "changes" : "removal";
|
|
6624
6665
|
const backup = result.backups.length === 0 ? "" : `\n Existing HolyCodex files were backed up before ${result.action === "install" ? "replacement" : "cleanup"}.`;
|
|
6625
|
-
return `${title}\n ${result.changed.length === 0 ? `No HolyCodex-managed files needed ${empty}.` : `${action} HolyCodex configuration, plugin files, and agent profiles.`}${backup}${
|
|
6666
|
+
return `${title}\n ${result.changed.length === 0 ? `No HolyCodex-managed files needed ${empty}.` : `${action} HolyCodex configuration, plugin files, and agent profiles.`}${backup}${renderOfficialPlugins(result)}\n`;
|
|
6626
6667
|
}
|
|
6627
|
-
function
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
if (
|
|
6632
|
-
return `\n
|
|
6668
|
+
function renderOfficialPlugins(result) {
|
|
6669
|
+
return [renderOfficialPlugin("Codex Security", result.codexSecurity), renderOfficialPlugin("Computer Use", result.computerUse)].join("");
|
|
6670
|
+
}
|
|
6671
|
+
function renderOfficialPlugin(name, plugin) {
|
|
6672
|
+
if (plugin === void 0) return "";
|
|
6673
|
+
if (plugin.status === "installed") return `\n Installed official ${name} plugin.`;
|
|
6674
|
+
if (plugin.status === "enabled") return `\n Enabled existing official ${name} plugin.`;
|
|
6675
|
+
if (plugin.status === "already-installed") return `\n Official ${name} plugin is already installed and enabled.`;
|
|
6676
|
+
return `\n Skipped official ${name} plugin: ${CODEX_SECURITY_SKIP_MESSAGES[plugin.reason]}`;
|
|
6633
6677
|
}
|
|
6634
6678
|
var CODEX_SECURITY_SKIP_MESSAGES = {
|
|
6635
6679
|
"codex-unavailable": "no usable Codex launcher was found.",
|
|
@@ -6645,6 +6689,13 @@ var CODEX_SECURITY_SKIP_MESSAGES = {
|
|
|
6645
6689
|
unsupported: "the available Codex launchers do not support plugin installation.",
|
|
6646
6690
|
"download-failed": "the latest Codex package could not be downloaded."
|
|
6647
6691
|
};
|
|
6692
|
+
/** Renders one concise installation progress transition. */
|
|
6693
|
+
function renderInstallProgress(event, color, isTTY, verbose) {
|
|
6694
|
+
const detail = verbose && event.detail !== void 0 ? ` ${paint(color, DIM, event.detail)}` : "";
|
|
6695
|
+
if (event.status === "running") return isTTY ? `\r${paint(color, CYAN, "●")} ${event.label}` : "";
|
|
6696
|
+
const line = `${paint(color, GREEN, "✓")} ${event.label}${detail}`;
|
|
6697
|
+
return isTTY ? `\r\u001B[2K${line}\n` : ` ${line}\n`;
|
|
6698
|
+
}
|
|
6648
6699
|
/** Renders notice. */
|
|
6649
6700
|
function renderNotice(kind, message, color) {
|
|
6650
6701
|
return `${paint(color, kind === "warning" ? RED : YELLOW, `! ${kind === "warning" ? "WARNING" : "NOTICE"}`)} ${message}\n`;
|
|
@@ -6652,88 +6703,41 @@ function renderNotice(kind, message, color) {
|
|
|
6652
6703
|
//#endregion
|
|
6653
6704
|
//#region packages/cli/src/cli.ts
|
|
6654
6705
|
async function main() {
|
|
6655
|
-
const
|
|
6706
|
+
const parsed = parseCliArguments(process$1.argv.slice(2));
|
|
6656
6707
|
const stdoutColor = supportsColor(process$1.stdout.isTTY, process$1.env.NO_COLOR);
|
|
6657
6708
|
const stderrColor = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
process$1.stdout.write(command === "install" ? renderInstallHelp(VERSION, stdoutColor) : renderHelp(VERSION, stdoutColor));
|
|
6709
|
+
if (parsed.action === "help") {
|
|
6710
|
+
process$1.stdout.write(parsed.command === "install" ? renderInstallHelp(VERSION, stdoutColor) : renderHelp(VERSION, stdoutColor));
|
|
6661
6711
|
return;
|
|
6662
6712
|
}
|
|
6663
|
-
if (
|
|
6713
|
+
if (parsed.action === "version") {
|
|
6664
6714
|
process$1.stdout.write(`${VERSION}\n`);
|
|
6665
6715
|
return;
|
|
6666
6716
|
}
|
|
6667
|
-
if (args.flatMap((arg, index) => arg === "--plan" ? [index] : []).length > 1) throw new Error("--plan may be specified only once.");
|
|
6668
|
-
const planFlagIndex = args.indexOf("--plan");
|
|
6669
|
-
const planValue = planFlagIndex < 0 ? DEFAULT_PLAN : args[planFlagIndex + 1];
|
|
6670
|
-
if (planValue === void 0 || planValue.startsWith("-") || planValue === command) throw new Error(`Missing --plan value. Valid plans: ${PLAN_NAMES.join(", ")}.`);
|
|
6671
|
-
const parsedPlan = PlanNameSchema.safeParse(planValue);
|
|
6672
|
-
if (!parsedPlan.success) throw new Error(`Unknown plan: ${planValue}. Valid plans: ${PLAN_NAMES.join(", ")}.`);
|
|
6673
|
-
const plan = parsedPlan.data;
|
|
6674
|
-
if (args.flatMap((arg, index) => arg === "--max-subagents" ? [index] : []).length > 1) throw new Error("--max-subagents may be specified only once.");
|
|
6675
|
-
const maxSubagentsIndex = args.indexOf("--max-subagents");
|
|
6676
|
-
const maxSubagentsValue = maxSubagentsIndex < 0 ? void 0 : args[maxSubagentsIndex + 1];
|
|
6677
|
-
if (maxSubagentsIndex >= 0 && (maxSubagentsValue === void 0 || maxSubagentsValue.startsWith("--") || maxSubagentsValue === command)) throw new Error("Missing --max-subagents value. Expected a nonnegative integer.");
|
|
6678
|
-
if (maxSubagentsValue !== void 0 && !/^\d+$/.test(maxSubagentsValue)) throw new Error(`Invalid --max-subagents value: ${maxSubagentsValue}. Expected a nonnegative integer.`);
|
|
6679
|
-
const maxSubagents = maxSubagentsValue === void 0 ? void 0 : Number(maxSubagentsValue);
|
|
6680
|
-
const autonomyFlags = args.filter((arg) => [
|
|
6681
|
-
"--codex-autonomous",
|
|
6682
|
-
"--no-codex-autonomous",
|
|
6683
|
-
"--dangerous-codex-autonomous"
|
|
6684
|
-
].includes(arg));
|
|
6685
|
-
if (autonomyFlags.length > 1) {
|
|
6686
|
-
process$1.stderr.write(renderError(`Conflicting autonomy flags: ${autonomyFlags.join(", ")}`, stderrColor));
|
|
6687
|
-
process$1.exitCode = 1;
|
|
6688
|
-
return;
|
|
6689
|
-
}
|
|
6690
|
-
const fastFlags = args.filter((arg) => [
|
|
6691
|
-
"--fast",
|
|
6692
|
-
"--fast-all",
|
|
6693
|
-
"--no-fast"
|
|
6694
|
-
].includes(arg));
|
|
6695
|
-
if (fastFlags.length > 1) {
|
|
6696
|
-
process$1.stderr.write(renderError(`Conflicting fast flags: ${fastFlags.join(", ")}`, stderrColor));
|
|
6697
|
-
process$1.exitCode = 1;
|
|
6698
|
-
return;
|
|
6699
|
-
}
|
|
6700
|
-
const autonomy = args.includes("--dangerous-codex-autonomous") ? {
|
|
6701
|
-
requested: true,
|
|
6702
|
-
mode: "dangerous"
|
|
6703
|
-
} : args.includes("--codex-autonomous") ? {
|
|
6704
|
-
requested: true,
|
|
6705
|
-
mode: "autonomous"
|
|
6706
|
-
} : args.includes("--no-codex-autonomous") ? {
|
|
6707
|
-
requested: true,
|
|
6708
|
-
mode: "default"
|
|
6709
|
-
} : { requested: false };
|
|
6710
6717
|
const options = {
|
|
6711
|
-
autonomy,
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
plan,
|
|
6715
|
-
|
|
6718
|
+
autonomy: parsed.autonomy,
|
|
6719
|
+
fast: parsed.fast,
|
|
6720
|
+
json: parsed.json,
|
|
6721
|
+
plan: parsed.plan,
|
|
6722
|
+
verbose: parsed.verbose,
|
|
6723
|
+
...parsed.command === "install" && !parsed.json ? { onProgress: (event) => process$1.stdout.write(renderInstallProgress(event, stdoutColor, process$1.stdout.isTTY === true, parsed.verbose)) } : {},
|
|
6724
|
+
...parsed.maxSubagents === void 0 ? {} : { maxSubagents: parsed.maxSubagents }
|
|
6716
6725
|
};
|
|
6717
|
-
if (command === "doctor") {
|
|
6726
|
+
if (parsed.command === "doctor") {
|
|
6718
6727
|
const result = await doctor();
|
|
6719
|
-
process$1.stdout.write(
|
|
6728
|
+
process$1.stdout.write(parsed.json ? `${JSON.stringify(result)}\n` : renderDoctor(result, stdoutColor));
|
|
6720
6729
|
if (!result.healthy) process$1.exitCode = 1;
|
|
6721
6730
|
return;
|
|
6722
6731
|
}
|
|
6723
|
-
if (autonomy.requested && autonomy.mode === "dangerous") process$1.stderr.write(renderNotice("warning", "Dangerous autonomy disables approvals and filesystem sandboxing.", stderrColor));
|
|
6724
|
-
const result = command === "install" ? await install(options) :
|
|
6725
|
-
|
|
6726
|
-
process$1.stderr.write(renderError(`Unknown command: ${command ?? args[0] ?? ""}`, stderrColor));
|
|
6727
|
-
process$1.exitCode = 1;
|
|
6728
|
-
return;
|
|
6729
|
-
}
|
|
6730
|
-
process$1.stdout.write(options.json ? `${JSON.stringify(result)}\n` : renderRunResult(result, stdoutColor));
|
|
6732
|
+
if (parsed.autonomy.requested && parsed.autonomy.mode === "dangerous") process$1.stderr.write(renderNotice("warning", "Dangerous autonomy disables approvals and filesystem sandboxing.", stderrColor));
|
|
6733
|
+
const result = parsed.command === "install" ? await install(options) : await cleanup(options);
|
|
6734
|
+
process$1.stdout.write(parsed.json ? `${JSON.stringify(result)}\n` : renderRunResult(result, stdoutColor));
|
|
6731
6735
|
}
|
|
6732
6736
|
try {
|
|
6733
6737
|
await main();
|
|
6734
6738
|
} catch (error) {
|
|
6735
|
-
const
|
|
6736
|
-
process$1.stderr.write(renderError(formatCliError(error),
|
|
6739
|
+
const color = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
|
|
6740
|
+
process$1.stderr.write(renderError(formatCliError(error), color));
|
|
6737
6741
|
process$1.exitCode = 1;
|
|
6738
6742
|
}
|
|
6739
6743
|
//#endregion
|