holycodex 0.11.0 → 0.11.3-dev.155.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/THIRD-PARTY-NOTICES.md +2 -0
- package/dist/cli.js +873 -358
- package/package.json +8 -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,6 +1906,98 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1907
1906
|
result.value = merged.data;
|
|
1908
1907
|
return result;
|
|
1909
1908
|
}
|
|
1909
|
+
var $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
|
|
1910
|
+
$ZodType.init(inst, def);
|
|
1911
|
+
const items = def.items;
|
|
1912
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1913
|
+
const input = payload.value;
|
|
1914
|
+
if (!Array.isArray(input)) {
|
|
1915
|
+
payload.issues.push({
|
|
1916
|
+
input,
|
|
1917
|
+
inst,
|
|
1918
|
+
expected: "tuple",
|
|
1919
|
+
code: "invalid_type"
|
|
1920
|
+
});
|
|
1921
|
+
return payload;
|
|
1922
|
+
}
|
|
1923
|
+
payload.value = [];
|
|
1924
|
+
const proms = [];
|
|
1925
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
1926
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
1927
|
+
if (!def.rest) {
|
|
1928
|
+
if (input.length < optinStart) {
|
|
1929
|
+
payload.issues.push({
|
|
1930
|
+
code: "too_small",
|
|
1931
|
+
minimum: optinStart,
|
|
1932
|
+
inclusive: true,
|
|
1933
|
+
input,
|
|
1934
|
+
inst,
|
|
1935
|
+
origin: "array"
|
|
1936
|
+
});
|
|
1937
|
+
return payload;
|
|
1938
|
+
}
|
|
1939
|
+
if (input.length > items.length) payload.issues.push({
|
|
1940
|
+
code: "too_big",
|
|
1941
|
+
maximum: items.length,
|
|
1942
|
+
inclusive: true,
|
|
1943
|
+
input,
|
|
1944
|
+
inst,
|
|
1945
|
+
origin: "array"
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
const itemResults = new Array(items.length);
|
|
1949
|
+
for (let i = 0; i < items.length; i++) {
|
|
1950
|
+
const r = items[i]._zod.run({
|
|
1951
|
+
value: input[i],
|
|
1952
|
+
issues: []
|
|
1953
|
+
}, ctx);
|
|
1954
|
+
if (r instanceof Promise) proms.push(r.then((rr) => {
|
|
1955
|
+
itemResults[i] = rr;
|
|
1956
|
+
}));
|
|
1957
|
+
else itemResults[i] = r;
|
|
1958
|
+
}
|
|
1959
|
+
if (def.rest) {
|
|
1960
|
+
let i = items.length - 1;
|
|
1961
|
+
const rest = input.slice(items.length);
|
|
1962
|
+
for (const el of rest) {
|
|
1963
|
+
i++;
|
|
1964
|
+
const result = def.rest._zod.run({
|
|
1965
|
+
value: el,
|
|
1966
|
+
issues: []
|
|
1967
|
+
}, ctx);
|
|
1968
|
+
if (result instanceof Promise) proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
1969
|
+
else handleTupleResult(result, payload, i);
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
if (proms.length) return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
1973
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1974
|
+
};
|
|
1975
|
+
});
|
|
1976
|
+
function getTupleOptStart(items, key) {
|
|
1977
|
+
for (let i = items.length - 1; i >= 0; i--) if (items[i]._zod[key] !== "optional") return i + 1;
|
|
1978
|
+
return 0;
|
|
1979
|
+
}
|
|
1980
|
+
function handleTupleResult(result, final, index) {
|
|
1981
|
+
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1982
|
+
final.value[index] = result.value;
|
|
1983
|
+
}
|
|
1984
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1985
|
+
for (let i = 0; i < items.length; i++) {
|
|
1986
|
+
const r = itemResults[i];
|
|
1987
|
+
const isPresent = i < input.length;
|
|
1988
|
+
if (r.issues.length) {
|
|
1989
|
+
if (!isPresent && i >= optoutStart) {
|
|
1990
|
+
final.value.length = i;
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1993
|
+
final.issues.push(...prefixIssues(i, r.issues));
|
|
1994
|
+
}
|
|
1995
|
+
final.value[i] = r.value;
|
|
1996
|
+
}
|
|
1997
|
+
for (let i = final.value.length - 1; i >= input.length; i--) if (items[i]._zod.optout === "optional" && final.value[i] === void 0) final.value.length = i;
|
|
1998
|
+
else break;
|
|
1999
|
+
return final;
|
|
2000
|
+
}
|
|
1910
2001
|
var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
1911
2002
|
$ZodType.init(inst, def);
|
|
1912
2003
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3281,6 +3372,44 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3281
3372
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3282
3373
|
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
3283
3374
|
};
|
|
3375
|
+
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
3376
|
+
const json = _json;
|
|
3377
|
+
const def = schema._zod.def;
|
|
3378
|
+
json.type = "array";
|
|
3379
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
3380
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
3381
|
+
const prefixItems = def.items.map((x, i) => process$2(x, ctx, {
|
|
3382
|
+
...params,
|
|
3383
|
+
path: [
|
|
3384
|
+
...params.path,
|
|
3385
|
+
prefixPath,
|
|
3386
|
+
i
|
|
3387
|
+
]
|
|
3388
|
+
}));
|
|
3389
|
+
const rest = def.rest ? process$2(def.rest, ctx, {
|
|
3390
|
+
...params,
|
|
3391
|
+
path: [
|
|
3392
|
+
...params.path,
|
|
3393
|
+
restPath,
|
|
3394
|
+
...ctx.target === "openapi-3.0" ? [def.items.length] : []
|
|
3395
|
+
]
|
|
3396
|
+
}) : null;
|
|
3397
|
+
if (ctx.target === "draft-2020-12") {
|
|
3398
|
+
json.prefixItems = prefixItems;
|
|
3399
|
+
if (rest) json.items = rest;
|
|
3400
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
3401
|
+
json.items = { anyOf: prefixItems };
|
|
3402
|
+
if (rest) json.items.anyOf.push(rest);
|
|
3403
|
+
json.minItems = prefixItems.length;
|
|
3404
|
+
if (!rest) json.maxItems = prefixItems.length;
|
|
3405
|
+
} else {
|
|
3406
|
+
json.items = prefixItems;
|
|
3407
|
+
if (rest) json.additionalItems = rest;
|
|
3408
|
+
}
|
|
3409
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
3410
|
+
if (typeof minimum === "number") json.minItems = minimum;
|
|
3411
|
+
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3412
|
+
};
|
|
3284
3413
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
3285
3414
|
const json = _json;
|
|
3286
3415
|
const def = schema._zod.def;
|
|
@@ -3965,14 +4094,6 @@ function strictObject(shape, params) {
|
|
|
3965
4094
|
...normalizeParams(params)
|
|
3966
4095
|
});
|
|
3967
4096
|
}
|
|
3968
|
-
function looseObject(shape, params) {
|
|
3969
|
-
return new ZodObject({
|
|
3970
|
-
type: "object",
|
|
3971
|
-
shape,
|
|
3972
|
-
catchall: unknown(),
|
|
3973
|
-
...normalizeParams(params)
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
4097
|
var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
3977
4098
|
$ZodUnion.init(inst, def);
|
|
3978
4099
|
ZodType.init(inst, def);
|
|
@@ -4010,6 +4131,24 @@ function intersection(left, right) {
|
|
|
4010
4131
|
right
|
|
4011
4132
|
});
|
|
4012
4133
|
}
|
|
4134
|
+
var ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def) => {
|
|
4135
|
+
$ZodTuple.init(inst, def);
|
|
4136
|
+
ZodType.init(inst, def);
|
|
4137
|
+
inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
|
|
4138
|
+
inst.rest = (rest) => inst.clone({
|
|
4139
|
+
...inst._zod.def,
|
|
4140
|
+
rest
|
|
4141
|
+
});
|
|
4142
|
+
});
|
|
4143
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
4144
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
4145
|
+
return new ZodTuple({
|
|
4146
|
+
type: "tuple",
|
|
4147
|
+
items,
|
|
4148
|
+
rest: hasRest ? _paramsOrRest : null,
|
|
4149
|
+
...normalizeParams(hasRest ? _params : _paramsOrRest)
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4013
4152
|
var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
4014
4153
|
$ZodRecord.init(inst, def);
|
|
4015
4154
|
ZodType.init(inst, def);
|
|
@@ -4252,13 +4391,13 @@ function superRefine(fn, params) {
|
|
|
4252
4391
|
}
|
|
4253
4392
|
//#endregion
|
|
4254
4393
|
//#region packages/cli/src/catalog.ts
|
|
4255
|
-
var VERSION = "0.11.
|
|
4394
|
+
var VERSION = "0.11.3-dev.155.1";
|
|
4256
4395
|
var SKILLS = [
|
|
4257
4396
|
"ast-grep",
|
|
4258
4397
|
"babysit-ci",
|
|
4259
|
-
"caveman",
|
|
4260
4398
|
"code-review",
|
|
4261
4399
|
"compress",
|
|
4400
|
+
"context7-cli",
|
|
4262
4401
|
"debugging",
|
|
4263
4402
|
"handoff",
|
|
4264
4403
|
"lsp",
|
|
@@ -4268,7 +4407,8 @@ var SKILLS = [
|
|
|
4268
4407
|
"programming",
|
|
4269
4408
|
"refactor",
|
|
4270
4409
|
"remove-slop",
|
|
4271
|
-
"rules"
|
|
4410
|
+
"rules",
|
|
4411
|
+
"workflows"
|
|
4272
4412
|
];
|
|
4273
4413
|
var AGENTS = _enum([
|
|
4274
4414
|
"explorer",
|
|
@@ -4310,6 +4450,46 @@ var ModelRouteSchema = discriminatedUnion("model", [
|
|
|
4310
4450
|
reasoningEffort: ReasoningEffortSchema
|
|
4311
4451
|
})
|
|
4312
4452
|
]);
|
|
4453
|
+
var WORKFLOW_STAGES = [
|
|
4454
|
+
"analysis",
|
|
4455
|
+
"research",
|
|
4456
|
+
"implementation",
|
|
4457
|
+
"verification"
|
|
4458
|
+
];
|
|
4459
|
+
var WorkflowStageSchema = _enum(WORKFLOW_STAGES);
|
|
4460
|
+
var WorkflowLimitsSchema = strictObject({
|
|
4461
|
+
concurrency: number().int().positive(),
|
|
4462
|
+
totalCalls: number().int().positive(),
|
|
4463
|
+
workflowDepth: number().int().positive(),
|
|
4464
|
+
retries: number().int().nonnegative(),
|
|
4465
|
+
loopIterations: number().int().positive(),
|
|
4466
|
+
fanOut: number().int().positive(),
|
|
4467
|
+
maxConcurrency: number().int().positive(),
|
|
4468
|
+
maxCalls: number().int().positive(),
|
|
4469
|
+
maxRetries: number().int().nonnegative()
|
|
4470
|
+
});
|
|
4471
|
+
var WorkflowPolicySchema = strictObject({
|
|
4472
|
+
permittedRoutes: strictObject({
|
|
4473
|
+
explorer: record(WorkflowStageSchema, array(ModelRouteSchema).min(1)),
|
|
4474
|
+
librarian: record(WorkflowStageSchema, array(ModelRouteSchema).min(1)),
|
|
4475
|
+
worker: record(WorkflowStageSchema, array(ModelRouteSchema).min(1))
|
|
4476
|
+
}),
|
|
4477
|
+
verbosity: literal("low"),
|
|
4478
|
+
serviceTiers: tuple([literal("default"), literal("fast")]),
|
|
4479
|
+
limits: WorkflowLimitsSchema,
|
|
4480
|
+
projectedUsage: strictObject({
|
|
4481
|
+
standard: number().positive(),
|
|
4482
|
+
fast: number().positive()
|
|
4483
|
+
}),
|
|
4484
|
+
runtime: strictObject({
|
|
4485
|
+
maxSeconds: number().int().positive(),
|
|
4486
|
+
maxRuntimeMs: number().int().positive()
|
|
4487
|
+
}),
|
|
4488
|
+
softSizeGuidance: strictObject({
|
|
4489
|
+
maxInputTokens: number().int().positive(),
|
|
4490
|
+
maxScriptBytes: number().int().positive()
|
|
4491
|
+
})
|
|
4492
|
+
});
|
|
4313
4493
|
var RoutingPresetSchema = strictObject({
|
|
4314
4494
|
root: ModelRouteSchema,
|
|
4315
4495
|
agents: strictObject({
|
|
@@ -4317,10 +4497,7 @@ var RoutingPresetSchema = strictObject({
|
|
|
4317
4497
|
librarian: ModelRouteSchema,
|
|
4318
4498
|
worker: ModelRouteSchema
|
|
4319
4499
|
}),
|
|
4320
|
-
|
|
4321
|
-
maxSubagents: number().int().nonnegative(),
|
|
4322
|
-
maxDepth: literal(1)
|
|
4323
|
-
})
|
|
4500
|
+
workflow: WorkflowPolicySchema
|
|
4324
4501
|
});
|
|
4325
4502
|
var ModelRoutingPlansSchema = strictObject({
|
|
4326
4503
|
go: RoutingPresetSchema,
|
|
@@ -4330,6 +4507,31 @@ var ModelRoutingPlansSchema = strictObject({
|
|
|
4330
4507
|
"pro-5x": RoutingPresetSchema,
|
|
4331
4508
|
"pro-20x": RoutingPresetSchema
|
|
4332
4509
|
});
|
|
4510
|
+
function workflowFor(agents, limits, projectedUsage, maxSeconds, maxInputTokens) {
|
|
4511
|
+
return {
|
|
4512
|
+
permittedRoutes: Object.fromEntries(AGENTS.map((agent) => [agent, Object.fromEntries(WORKFLOW_STAGES.map((stage) => [stage, [agents[agent]]]))])),
|
|
4513
|
+
verbosity: "low",
|
|
4514
|
+
serviceTiers: ["default", "fast"],
|
|
4515
|
+
limits: {
|
|
4516
|
+
...limits,
|
|
4517
|
+
maxConcurrency: limits.concurrency,
|
|
4518
|
+
maxCalls: limits.totalCalls,
|
|
4519
|
+
maxRetries: limits.retries
|
|
4520
|
+
},
|
|
4521
|
+
projectedUsage: {
|
|
4522
|
+
standard: projectedUsage,
|
|
4523
|
+
fast: projectedUsage * 2
|
|
4524
|
+
},
|
|
4525
|
+
runtime: {
|
|
4526
|
+
maxSeconds,
|
|
4527
|
+
maxRuntimeMs: maxSeconds * 1e3
|
|
4528
|
+
},
|
|
4529
|
+
softSizeGuidance: {
|
|
4530
|
+
maxInputTokens,
|
|
4531
|
+
maxScriptBytes: Math.min(maxInputTokens, 4 * 1024 * 1024)
|
|
4532
|
+
}
|
|
4533
|
+
};
|
|
4534
|
+
}
|
|
4333
4535
|
var DEFAULT_PLAN = "plus";
|
|
4334
4536
|
var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
4335
4537
|
go: {
|
|
@@ -4351,10 +4553,27 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4351
4553
|
reasoningEffort: "high"
|
|
4352
4554
|
}
|
|
4353
4555
|
},
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4556
|
+
workflow: workflowFor({
|
|
4557
|
+
explorer: {
|
|
4558
|
+
model: "gpt-5.6-luna",
|
|
4559
|
+
reasoningEffort: "high"
|
|
4560
|
+
},
|
|
4561
|
+
librarian: {
|
|
4562
|
+
model: "gpt-5.6-luna",
|
|
4563
|
+
reasoningEffort: "high"
|
|
4564
|
+
},
|
|
4565
|
+
worker: {
|
|
4566
|
+
model: "gpt-5.6-luna",
|
|
4567
|
+
reasoningEffort: "high"
|
|
4568
|
+
}
|
|
4569
|
+
}, {
|
|
4570
|
+
concurrency: 1,
|
|
4571
|
+
totalCalls: 4,
|
|
4572
|
+
workflowDepth: 2,
|
|
4573
|
+
retries: 0,
|
|
4574
|
+
loopIterations: 1,
|
|
4575
|
+
fanOut: 1
|
|
4576
|
+
}, 4, 120, 2e4)
|
|
4358
4577
|
},
|
|
4359
4578
|
"plus-low": {
|
|
4360
4579
|
root: {
|
|
@@ -4375,10 +4594,27 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4375
4594
|
reasoningEffort: "high"
|
|
4376
4595
|
}
|
|
4377
4596
|
},
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4597
|
+
workflow: workflowFor({
|
|
4598
|
+
explorer: {
|
|
4599
|
+
model: "gpt-5.6-luna",
|
|
4600
|
+
reasoningEffort: "high"
|
|
4601
|
+
},
|
|
4602
|
+
librarian: {
|
|
4603
|
+
model: "gpt-5.6-luna",
|
|
4604
|
+
reasoningEffort: "high"
|
|
4605
|
+
},
|
|
4606
|
+
worker: {
|
|
4607
|
+
model: "gpt-5.6-luna",
|
|
4608
|
+
reasoningEffort: "high"
|
|
4609
|
+
}
|
|
4610
|
+
}, {
|
|
4611
|
+
concurrency: 2,
|
|
4612
|
+
totalCalls: 8,
|
|
4613
|
+
workflowDepth: 3,
|
|
4614
|
+
retries: 1,
|
|
4615
|
+
loopIterations: 2,
|
|
4616
|
+
fanOut: 2
|
|
4617
|
+
}, 8, 300, 3e4)
|
|
4382
4618
|
},
|
|
4383
4619
|
plus: {
|
|
4384
4620
|
root: {
|
|
@@ -4399,10 +4635,27 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4399
4635
|
reasoningEffort: "high"
|
|
4400
4636
|
}
|
|
4401
4637
|
},
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4638
|
+
workflow: workflowFor({
|
|
4639
|
+
explorer: {
|
|
4640
|
+
model: "gpt-5.6-luna",
|
|
4641
|
+
reasoningEffort: "high"
|
|
4642
|
+
},
|
|
4643
|
+
librarian: {
|
|
4644
|
+
model: "gpt-5.6-luna",
|
|
4645
|
+
reasoningEffort: "high"
|
|
4646
|
+
},
|
|
4647
|
+
worker: {
|
|
4648
|
+
model: "gpt-5.6-luna",
|
|
4649
|
+
reasoningEffort: "high"
|
|
4650
|
+
}
|
|
4651
|
+
}, {
|
|
4652
|
+
concurrency: 3,
|
|
4653
|
+
totalCalls: 16,
|
|
4654
|
+
workflowDepth: 4,
|
|
4655
|
+
retries: 2,
|
|
4656
|
+
loopIterations: 3,
|
|
4657
|
+
fanOut: 3
|
|
4658
|
+
}, 16, 600, 5e4)
|
|
4406
4659
|
},
|
|
4407
4660
|
"plus-high": {
|
|
4408
4661
|
root: {
|
|
@@ -4423,10 +4676,27 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4423
4676
|
reasoningEffort: "xhigh"
|
|
4424
4677
|
}
|
|
4425
4678
|
},
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4679
|
+
workflow: workflowFor({
|
|
4680
|
+
explorer: {
|
|
4681
|
+
model: "gpt-5.6-luna",
|
|
4682
|
+
reasoningEffort: "high"
|
|
4683
|
+
},
|
|
4684
|
+
librarian: {
|
|
4685
|
+
model: "gpt-5.6-luna",
|
|
4686
|
+
reasoningEffort: "high"
|
|
4687
|
+
},
|
|
4688
|
+
worker: {
|
|
4689
|
+
model: "gpt-5.6-luna",
|
|
4690
|
+
reasoningEffort: "xhigh"
|
|
4691
|
+
}
|
|
4692
|
+
}, {
|
|
4693
|
+
concurrency: 4,
|
|
4694
|
+
totalCalls: 24,
|
|
4695
|
+
workflowDepth: 5,
|
|
4696
|
+
retries: 3,
|
|
4697
|
+
loopIterations: 4,
|
|
4698
|
+
fanOut: 4
|
|
4699
|
+
}, 24, 900, 7e4)
|
|
4430
4700
|
},
|
|
4431
4701
|
"pro-5x": {
|
|
4432
4702
|
root: {
|
|
@@ -4447,10 +4717,27 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4447
4717
|
reasoningEffort: "xhigh"
|
|
4448
4718
|
}
|
|
4449
4719
|
},
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4720
|
+
workflow: workflowFor({
|
|
4721
|
+
explorer: {
|
|
4722
|
+
model: "gpt-5.6-luna",
|
|
4723
|
+
reasoningEffort: "high"
|
|
4724
|
+
},
|
|
4725
|
+
librarian: {
|
|
4726
|
+
model: "gpt-5.6-luna",
|
|
4727
|
+
reasoningEffort: "high"
|
|
4728
|
+
},
|
|
4729
|
+
worker: {
|
|
4730
|
+
model: "gpt-5.6-luna",
|
|
4731
|
+
reasoningEffort: "xhigh"
|
|
4732
|
+
}
|
|
4733
|
+
}, {
|
|
4734
|
+
concurrency: 6,
|
|
4735
|
+
totalCalls: 40,
|
|
4736
|
+
workflowDepth: 6,
|
|
4737
|
+
retries: 3,
|
|
4738
|
+
loopIterations: 5,
|
|
4739
|
+
fanOut: 5
|
|
4740
|
+
}, 40, 1200, 1e5)
|
|
4454
4741
|
},
|
|
4455
4742
|
"pro-20x": {
|
|
4456
4743
|
root: {
|
|
@@ -4471,12 +4758,31 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4471
4758
|
reasoningEffort: "max"
|
|
4472
4759
|
}
|
|
4473
4760
|
},
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4761
|
+
workflow: workflowFor({
|
|
4762
|
+
explorer: {
|
|
4763
|
+
model: "gpt-5.6-luna",
|
|
4764
|
+
reasoningEffort: "high"
|
|
4765
|
+
},
|
|
4766
|
+
librarian: {
|
|
4767
|
+
model: "gpt-5.6-luna",
|
|
4768
|
+
reasoningEffort: "high"
|
|
4769
|
+
},
|
|
4770
|
+
worker: {
|
|
4771
|
+
model: "gpt-5.6-luna",
|
|
4772
|
+
reasoningEffort: "max"
|
|
4773
|
+
}
|
|
4774
|
+
}, {
|
|
4775
|
+
concurrency: 8,
|
|
4776
|
+
totalCalls: 80,
|
|
4777
|
+
workflowDepth: 8,
|
|
4778
|
+
retries: 4,
|
|
4779
|
+
loopIterations: 8,
|
|
4780
|
+
fanOut: 8
|
|
4781
|
+
}, 80, 2400, 15e4)
|
|
4478
4782
|
}
|
|
4479
4783
|
});
|
|
4784
|
+
Object.fromEntries(PLAN_NAMES.map((plan) => [plan, MODEL_ROUTING_PLANS[plan].workflow]));
|
|
4785
|
+
Object.fromEntries(PLAN_NAMES.map((plan) => [plan, MODEL_ROUTING_PLANS[plan].workflow.limits]));
|
|
4480
4786
|
MODEL_ROUTING_PLANS[DEFAULT_PLAN].root;
|
|
4481
4787
|
MODEL_ROUTING_PLANS[DEFAULT_PLAN].agents;
|
|
4482
4788
|
var LEGACY_MANAGED_AGENT_MODEL_HISTORY = {
|
|
@@ -4739,37 +5045,125 @@ var GENERATED_RUNTIMES = [
|
|
|
4739
5045
|
"git-bash.js",
|
|
4740
5046
|
"git-bash-resolver.js",
|
|
4741
5047
|
"LICENSE-LSP-MIT.txt",
|
|
5048
|
+
"LICENSE-QUICKJS-EMSCRIPTEN-MIT.txt",
|
|
4742
5049
|
"lsp.js",
|
|
4743
|
-
"
|
|
4744
|
-
"
|
|
5050
|
+
"rules.js",
|
|
5051
|
+
"workflow.js",
|
|
5052
|
+
"workflow-evaluator.js"
|
|
4745
5053
|
];
|
|
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
|
-
}
|
|
5054
|
+
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.";
|
|
5055
|
+
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.";
|
|
5056
|
+
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
5057
|
/** Returns packaged runtime files required on a platform. */
|
|
4768
5058
|
function requiredPackageRuntimes(platform) {
|
|
4769
5059
|
return platform === "win32" ? GENERATED_RUNTIMES : GENERATED_RUNTIMES.filter((file) => file !== "git-bash.js");
|
|
4770
5060
|
}
|
|
4771
5061
|
//#endregion
|
|
4772
|
-
//#region packages/
|
|
5062
|
+
//#region packages/cli/src/arguments.ts
|
|
5063
|
+
var INSTALL_FLAGS = /* @__PURE__ */ new Set([
|
|
5064
|
+
"--plan",
|
|
5065
|
+
"--max-subagents",
|
|
5066
|
+
"--codex-autonomous",
|
|
5067
|
+
"--no-codex-autonomous",
|
|
5068
|
+
"--dangerous-codex-autonomous",
|
|
5069
|
+
"--fast",
|
|
5070
|
+
"--fast-all",
|
|
5071
|
+
"--no-fast",
|
|
5072
|
+
"--json",
|
|
5073
|
+
"--verbose"
|
|
5074
|
+
]);
|
|
5075
|
+
var SHARED_FLAGS = /* @__PURE__ */ new Set(["--json"]);
|
|
5076
|
+
/** Strictly parses command-specific HolyCodex CLI arguments. */
|
|
5077
|
+
function parseCliArguments(args) {
|
|
5078
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") return base("help");
|
|
5079
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
5080
|
+
if (args.length !== 1) throw new Error("--version does not accept other arguments.");
|
|
5081
|
+
return base("version");
|
|
5082
|
+
}
|
|
5083
|
+
const command = args[0];
|
|
5084
|
+
if (command !== "install" && command !== "doctor" && command !== "cleanup") throw new Error(`Unknown command: ${command ?? ""}`);
|
|
5085
|
+
if (args[1] === "--help" || args[1] === "-h") {
|
|
5086
|
+
if (args.length !== 2) throw new Error("--help does not accept other arguments.");
|
|
5087
|
+
return {
|
|
5088
|
+
...base("help"),
|
|
5089
|
+
command
|
|
5090
|
+
};
|
|
5091
|
+
}
|
|
5092
|
+
const allowed = command === "install" ? INSTALL_FLAGS : SHARED_FLAGS;
|
|
5093
|
+
const values = /* @__PURE__ */ new Map();
|
|
5094
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
5095
|
+
const token = args[index];
|
|
5096
|
+
if (token === "-v") {
|
|
5097
|
+
if (!allowed.has("--verbose")) throw new Error(`Option -v is not valid for ${command}.`);
|
|
5098
|
+
if (values.has("--verbose")) throw new Error("Repeated option: --verbose");
|
|
5099
|
+
values.set("--verbose", true);
|
|
5100
|
+
continue;
|
|
5101
|
+
}
|
|
5102
|
+
if (token === void 0 || !token.startsWith("--")) throw new Error(`Unexpected positional argument: ${token ?? ""}`);
|
|
5103
|
+
const separator = token.indexOf("=");
|
|
5104
|
+
const name = separator < 0 ? token : token.slice(0, separator);
|
|
5105
|
+
if (!allowed.has(name)) throw new Error(`Option ${name} is not valid for ${command}.`);
|
|
5106
|
+
if (values.has(name)) throw new Error(`Repeated option: ${name}`);
|
|
5107
|
+
if (name !== "--plan" && name !== "--max-subagents") {
|
|
5108
|
+
if (separator >= 0) throw new Error(`${name} does not accept a value.`);
|
|
5109
|
+
values.set(name, true);
|
|
5110
|
+
continue;
|
|
5111
|
+
}
|
|
5112
|
+
const value = separator < 0 ? args[++index] : token.slice(separator + 1);
|
|
5113
|
+
if (value === void 0 || value === "" || separator < 0 && value.startsWith("--")) throw new Error(`Missing value for ${name}.`);
|
|
5114
|
+
values.set(name, value);
|
|
5115
|
+
}
|
|
5116
|
+
const autonomyFlags = [
|
|
5117
|
+
"--codex-autonomous",
|
|
5118
|
+
"--no-codex-autonomous",
|
|
5119
|
+
"--dangerous-codex-autonomous"
|
|
5120
|
+
].filter((flag) => values.has(flag));
|
|
5121
|
+
if (autonomyFlags.length > 1) throw new Error(`Conflicting autonomy flags: ${autonomyFlags.join(", ")}`);
|
|
5122
|
+
const fastFlags = [
|
|
5123
|
+
"--fast",
|
|
5124
|
+
"--fast-all",
|
|
5125
|
+
"--no-fast"
|
|
5126
|
+
].filter((flag) => values.has(flag));
|
|
5127
|
+
if (fastFlags.length > 1) throw new Error(`Conflicting Fast flags: ${fastFlags.join(", ")}`);
|
|
5128
|
+
const planValue = values.get("--plan") ?? "plus";
|
|
5129
|
+
const plan = PlanNameSchema.safeParse(planValue);
|
|
5130
|
+
if (!plan.success) throw new Error(`Unknown plan: ${String(planValue)}. Valid plans: ${PLAN_NAMES.join(", ")}.`);
|
|
5131
|
+
const maxValue = values.get("--max-subagents");
|
|
5132
|
+
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.`);
|
|
5133
|
+
const autonomy = values.has("--dangerous-codex-autonomous") ? {
|
|
5134
|
+
requested: true,
|
|
5135
|
+
mode: "dangerous"
|
|
5136
|
+
} : values.has("--codex-autonomous") ? {
|
|
5137
|
+
requested: true,
|
|
5138
|
+
mode: "autonomous"
|
|
5139
|
+
} : values.has("--no-codex-autonomous") ? {
|
|
5140
|
+
requested: true,
|
|
5141
|
+
mode: "default"
|
|
5142
|
+
} : { requested: false };
|
|
5143
|
+
const fast = FastModeSchema.parse(values.has("--fast-all") ? "fast-all" : values.has("--fast") ? "fast" : "standard");
|
|
5144
|
+
return {
|
|
5145
|
+
action: "run",
|
|
5146
|
+
command,
|
|
5147
|
+
json: values.has("--json"),
|
|
5148
|
+
plan: plan.data,
|
|
5149
|
+
...maxValue === void 0 ? {} : { maxSubagents: Number(maxValue) },
|
|
5150
|
+
autonomy,
|
|
5151
|
+
fast,
|
|
5152
|
+
verbose: values.has("--verbose")
|
|
5153
|
+
};
|
|
5154
|
+
}
|
|
5155
|
+
function base(action) {
|
|
5156
|
+
return {
|
|
5157
|
+
action,
|
|
5158
|
+
json: false,
|
|
5159
|
+
plan: DEFAULT_PLAN,
|
|
5160
|
+
autonomy: { requested: false },
|
|
5161
|
+
fast: "standard",
|
|
5162
|
+
verbose: false
|
|
5163
|
+
};
|
|
5164
|
+
}
|
|
5165
|
+
//#endregion
|
|
5166
|
+
//#region packages/git-bash/src/git-bash-resolver.ts
|
|
4773
5167
|
var GIT_BASH_ENV_KEY = "HOLYCODEX_GIT_BASH_PATH";
|
|
4774
5168
|
var PROGRAM_FILES = "C:\\Program Files\\Git\\bin\\bash.exe";
|
|
4775
5169
|
var PROGRAM_FILES_X86 = "C:\\Program Files (x86)\\Git\\bin\\bash.exe";
|
|
@@ -4850,7 +5244,7 @@ function missing(checkedPaths) {
|
|
|
4850
5244
|
};
|
|
4851
5245
|
}
|
|
4852
5246
|
//#endregion
|
|
4853
|
-
//#region packages/
|
|
5247
|
+
//#region packages/runtime-core/src/process.ts
|
|
4854
5248
|
var TRUNCATED_MARKER = "\n... diagnostic output truncated ...\n";
|
|
4855
5249
|
var defaultManagedProcessRuntime = {
|
|
4856
5250
|
terminationGraceMs: 2e3,
|
|
@@ -4915,11 +5309,13 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4915
5309
|
let matched = false;
|
|
4916
5310
|
let settled = false;
|
|
4917
5311
|
let forceKillTimeout;
|
|
5312
|
+
let finalResolutionTimeout;
|
|
4918
5313
|
const finish = (exitCode, error, errorCode) => {
|
|
4919
5314
|
if (settled) return;
|
|
4920
5315
|
settled = true;
|
|
4921
5316
|
clearTimeout(timeout);
|
|
4922
5317
|
if (forceKillTimeout !== void 0) clearTimeout(forceKillTimeout);
|
|
5318
|
+
if (finalResolutionTimeout !== void 0) clearTimeout(finalResolutionTimeout);
|
|
4923
5319
|
resolve({
|
|
4924
5320
|
exitCode,
|
|
4925
5321
|
stdout: outputText(stdout),
|
|
@@ -4938,6 +5334,8 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4938
5334
|
runtime.kill(child, input.platform, "SIGKILL");
|
|
4939
5335
|
}, runtime.terminationGraceMs);
|
|
4940
5336
|
forceKillTimeout.unref();
|
|
5337
|
+
finalResolutionTimeout = setTimeout(() => finish(child.exitCode, "Managed process did not emit close after termination."), input.finalResolutionMs ?? runtime.terminationGraceMs * 2);
|
|
5338
|
+
finalResolutionTimeout.unref();
|
|
4941
5339
|
};
|
|
4942
5340
|
const inspectMatch = () => {
|
|
4943
5341
|
if (matched || input.matchOutput === void 0) return;
|
|
@@ -4968,7 +5366,9 @@ async function runManagedProcess(input, runtime = defaultManagedProcessRuntime)
|
|
|
4968
5366
|
/** Terminates process tree. */
|
|
4969
5367
|
function killProcessTree(child, platform, signal = "SIGTERM", runTaskkill = (command, args) => spawnSync(command, [...args], {
|
|
4970
5368
|
stdio: "ignore",
|
|
4971
|
-
windowsHide: true
|
|
5369
|
+
windowsHide: true,
|
|
5370
|
+
timeout: 2e3,
|
|
5371
|
+
killSignal: "SIGKILL"
|
|
4972
5372
|
})) {
|
|
4973
5373
|
if (platform === "win32" && child.pid !== void 0) {
|
|
4974
5374
|
const result = runTaskkill("taskkill", [
|
|
@@ -5224,7 +5624,7 @@ var ORIGINAL_ROOT = "# holycodex original root: ";
|
|
|
5224
5624
|
var ORIGINAL_TABLE_KEY = "# holycodex original table key: ";
|
|
5225
5625
|
var PLAN_PREFIX = "# holycodex plan: ";
|
|
5226
5626
|
var FAST_MODE_PREFIX = "# holycodex fast: ";
|
|
5227
|
-
var
|
|
5627
|
+
var WORKFLOW_POLICY_PREFIX = "# holycodex workflow-policy: ";
|
|
5228
5628
|
var OLD_NAMESPACES = [
|
|
5229
5629
|
"marketplaces.sisyphuslabs",
|
|
5230
5630
|
"plugins.\"omo@sisyphuslabs\"",
|
|
@@ -5311,6 +5711,13 @@ function nextTableBoundary(input) {
|
|
|
5311
5711
|
if (managedHeader < 0) return header;
|
|
5312
5712
|
return Math.min(header, managedHeader);
|
|
5313
5713
|
}
|
|
5714
|
+
function tableSource(input, table) {
|
|
5715
|
+
const match = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*(?:#.*)?$`, "m").exec(input);
|
|
5716
|
+
if (match === null) return void 0;
|
|
5717
|
+
const tail = input.slice(match.index + match[0].length);
|
|
5718
|
+
const end = nextTableBoundary(tail);
|
|
5719
|
+
return end < 0 ? tail : tail.slice(0, end);
|
|
5720
|
+
}
|
|
5314
5721
|
function rootValue(input, key) {
|
|
5315
5722
|
if (key === "status_line") return rootTomlStringArraySource(input, key);
|
|
5316
5723
|
return new RegExp(`^\\s*${key}\\s*=.*$`, "m").exec(input)?.[0];
|
|
@@ -5336,38 +5743,57 @@ function readManagedFastMode(input) {
|
|
|
5336
5743
|
const value = new RegExp(`^${FAST_MODE_PREFIX}(.+)$`, "m").exec(input)?.[1]?.trim();
|
|
5337
5744
|
return FastModeSchema.safeParse(value).data;
|
|
5338
5745
|
}
|
|
5339
|
-
/** Reads
|
|
5340
|
-
function
|
|
5341
|
-
const raw = new RegExp(`^${
|
|
5342
|
-
if (raw === void 0) return
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
value
|
|
5347
|
-
|
|
5746
|
+
/** Reads the plan-authoritative workflow policy metadata from managed configuration. */
|
|
5747
|
+
function readManagedWorkflowPolicy(input) {
|
|
5748
|
+
const raw = new RegExp(`^${WORKFLOW_POLICY_PREFIX.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(.+)$`, "m").exec(input)?.[1];
|
|
5749
|
+
if (raw === void 0) return void 0;
|
|
5750
|
+
try {
|
|
5751
|
+
const value = JSON.parse(raw);
|
|
5752
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
5753
|
+
const record = value;
|
|
5754
|
+
const plan = PLAN_NAMES.find((name) => name === record.plan);
|
|
5755
|
+
const limits = record.limits;
|
|
5756
|
+
const usage = record.projectedUsage;
|
|
5757
|
+
const runtime = record.runtime;
|
|
5758
|
+
const size = record.softSizeGuidance;
|
|
5759
|
+
if (plan === void 0 || typeof limits !== "object" || limits === null || typeof usage !== "object" || usage === null || typeof runtime !== "object" || runtime === null || typeof size !== "object" || size === null) return void 0;
|
|
5760
|
+
return {
|
|
5761
|
+
plan,
|
|
5762
|
+
limits,
|
|
5763
|
+
projectedUsage: usage,
|
|
5764
|
+
runtime,
|
|
5765
|
+
softSizeGuidance: size
|
|
5766
|
+
};
|
|
5767
|
+
} catch {
|
|
5768
|
+
return;
|
|
5769
|
+
}
|
|
5348
5770
|
}
|
|
5349
5771
|
/** Identifies explicit Root route overrides preserved from active managed configuration. */
|
|
5350
5772
|
function readPreservedRootOverrides(input) {
|
|
5351
5773
|
const managedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
|
|
5352
5774
|
if (managedRoot === void 0) return {
|
|
5353
5775
|
model: false,
|
|
5354
|
-
reasoningEffort: false
|
|
5776
|
+
reasoningEffort: false,
|
|
5777
|
+
webSearch: false
|
|
5355
5778
|
};
|
|
5356
5779
|
const plan = readManagedPlan(managedRoot);
|
|
5357
5780
|
const model = rootTomlString(input, "model");
|
|
5358
5781
|
const reasoningEffort = rootTomlString(input, "model_reasoning_effort");
|
|
5359
5782
|
if (plan === void 0 || model === void 0 || reasoningEffort === void 0) return {
|
|
5360
5783
|
model: false,
|
|
5361
|
-
reasoningEffort: false
|
|
5784
|
+
reasoningEffort: false,
|
|
5785
|
+
webSearch: false
|
|
5362
5786
|
};
|
|
5363
5787
|
if (MANAGED_ROOT_MODEL_HISTORY_BY_PLAN[plan].some((route) => route.model === model && route.reasoningEffort === reasoningEffort)) return {
|
|
5364
5788
|
model: false,
|
|
5365
|
-
reasoningEffort: false
|
|
5789
|
+
reasoningEffort: false,
|
|
5790
|
+
webSearch: rootTomlString(managedRoot, "web_search") !== "live"
|
|
5366
5791
|
};
|
|
5367
5792
|
const preset = MODEL_ROUTING_PLANS[plan].root;
|
|
5368
5793
|
return {
|
|
5369
5794
|
model: model !== preset.model,
|
|
5370
|
-
reasoningEffort: reasoningEffort !== preset.reasoningEffort
|
|
5795
|
+
reasoningEffort: reasoningEffort !== preset.reasoningEffort,
|
|
5796
|
+
webSearch: rootTomlString(managedRoot, "web_search") !== "live"
|
|
5371
5797
|
};
|
|
5372
5798
|
}
|
|
5373
5799
|
function preserveManagedRootPreferences(input, base) {
|
|
@@ -5378,7 +5804,11 @@ function preserveManagedRootPreferences(input, base) {
|
|
|
5378
5804
|
const tables = firstTable < 0 ? "" : base.slice(firstTable);
|
|
5379
5805
|
let updatedRoot = root.trim();
|
|
5380
5806
|
const overrides = readPreservedRootOverrides(input);
|
|
5381
|
-
for (const [key, preserve] of [
|
|
5807
|
+
for (const [key, preserve] of [
|
|
5808
|
+
["model", overrides.model],
|
|
5809
|
+
["model_reasoning_effort", overrides.reasoningEffort],
|
|
5810
|
+
["web_search", overrides.webSearch]
|
|
5811
|
+
]) {
|
|
5382
5812
|
const live = rootValue(managedRoot, key)?.trim();
|
|
5383
5813
|
if (!preserve || live === void 0) continue;
|
|
5384
5814
|
if (rootValue(root, key)?.trim() === live) continue;
|
|
@@ -5395,7 +5825,7 @@ function mergedStatusLine(original) {
|
|
|
5395
5825
|
return `[${items.map((item) => JSON.stringify(item)).join(", ")}]`;
|
|
5396
5826
|
}
|
|
5397
5827
|
/** Installs config. */
|
|
5398
|
-
function installConfig(input, mode, _platform, plan = DEFAULT_PLAN,
|
|
5828
|
+
function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, _legacyMaxSubagents, fastMode = "standard") {
|
|
5399
5829
|
const request = normalizeRequestedAutonomy(mode);
|
|
5400
5830
|
const priorAutonomy = readAutonomyMetadata(input);
|
|
5401
5831
|
const previousOriginalRoot = readOriginalRootMetadata(input);
|
|
@@ -5416,6 +5846,7 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5416
5846
|
const hadOriginalRoot = /^# holycodex original root:/m.test(input);
|
|
5417
5847
|
const permissionLines = originalPermissionLines ?? (legacyGeneratedRoot !== void 0 && previousOriginalRoot === void 0 ? [] : previousOriginalRoot === void 0 ? hadManagedAutonomy && !hadOriginalRoot ? [] : readPermissionLines(root) : readPermissionLines(previousOriginalRoot));
|
|
5418
5848
|
const controlled = [
|
|
5849
|
+
"web_search",
|
|
5419
5850
|
"approval_policy",
|
|
5420
5851
|
"approvals_reviewer",
|
|
5421
5852
|
"sandbox_mode",
|
|
@@ -5426,6 +5857,7 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5426
5857
|
...request.requested ? ["default_permissions"] : []
|
|
5427
5858
|
].map((key) => rootValue(root, key));
|
|
5428
5859
|
const preservedRoot = [
|
|
5860
|
+
"web_search",
|
|
5429
5861
|
"approval_policy",
|
|
5430
5862
|
"approvals_reviewer",
|
|
5431
5863
|
"sandbox_mode",
|
|
@@ -5439,79 +5871,143 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
5439
5871
|
const hasModel = /^\s*model\s*=/m.test(preservedRoot);
|
|
5440
5872
|
const hasEffort = /^\s*model_reasoning_effort\s*=/m.test(preservedRoot);
|
|
5441
5873
|
const rootRoute = MODEL_ROUTING_PLANS[plan].root;
|
|
5442
|
-
const effectiveMaxSubagents = maxSubagents ?? MODEL_ROUTING_PLANS[plan].usage.maxSubagents;
|
|
5443
5874
|
const model = hasModel ? "" : `model = "${rootRoute.model}"\n`;
|
|
5444
5875
|
const effort = hasEffort ? "" : `model_reasoning_effort = "${rootRoute.reasoningEffort}"\n`;
|
|
5445
5876
|
const originalSource = previousOriginalRoot === void 0 ? priorAutonomy === void 0 && legacyGeneratedRoot === void 0 ? originalControlled : "" : removePermissionLines(previousOriginalRoot);
|
|
5446
5877
|
const original = originalSource ? `${ORIGINAL_ROOT}${Buffer.from(originalSource).toString("base64")}\n` : "";
|
|
5447
|
-
const maxSubagentsMetadata = maxSubagents === void 0 ? "" : `${MAX_SUBAGENTS_PREFIX}${maxSubagents}\n`;
|
|
5448
5878
|
const rootServiceTier = fastMode === "fast-all" ? "fast" : "default";
|
|
5449
|
-
const
|
|
5879
|
+
const priorManagedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
|
|
5880
|
+
const webSearch = readPreservedRootOverrides(input).webSearch ? rootTomlString(priorManagedRoot ?? "", "web_search") ?? "live" : "live";
|
|
5881
|
+
const statusLine = mergedStatusLine(rootValue(root, "status_line") ?? rootTomlStringArraySource(tableSource(base, "tui") ?? "", "status_line"));
|
|
5882
|
+
const workflow = MODEL_ROUTING_PLANS[plan].workflow;
|
|
5883
|
+
const rootBlock = `${START}\n${PLAN_PREFIX}${plan}\n${FAST_MODE_PREFIX}${fastMode}\n${WORKFLOW_POLICY_PREFIX}${JSON.stringify({
|
|
5884
|
+
plan,
|
|
5885
|
+
limits: workflow.limits,
|
|
5886
|
+
projectedUsage: workflow.projectedUsage,
|
|
5887
|
+
runtime: workflow.runtime,
|
|
5888
|
+
softSizeGuidance: workflow.softSizeGuidance
|
|
5889
|
+
})}\n${AUTONOMY_METADATA_PREFIX}${effectiveAutonomy}\n${original}${originalPermissionMetadata(permissionLines)}${model}${effort}web_search = ${JSON.stringify(webSearch)}\nmodel_verbosity = "low"\nservice_tier = "${rootServiceTier}"\n${rootPermissionLines.join("\n")}\n${END}`;
|
|
5450
5890
|
let configured = `${preservedRoot ? `${preservedRoot}\n` : ""}${rootBlock}${tables ? `\n\n${tables}` : ""}`;
|
|
5891
|
+
const legacyMultiAgentV2 = /\bmulti_agent_v2\s*=\s*(true|false)/.exec(configured)?.[1];
|
|
5451
5892
|
configured = injectTableKeys(configured, "features", [
|
|
5452
5893
|
["default_mode_request_user_input", "true"],
|
|
5453
5894
|
["multi_agent", "true"],
|
|
5454
|
-
["multi_agent_v2",
|
|
5895
|
+
...legacyMultiAgentV2 === void 0 ? [] : [["multi_agent_v2", legacyMultiAgentV2]]
|
|
5455
5896
|
]);
|
|
5456
|
-
|
|
5457
|
-
configured = injectTableKeys(configured, "
|
|
5897
|
+
configured = injectTableKeys(configured, "agents", [["max_concurrent_threads_per_session", String(workflow.limits.concurrency + 1)]]);
|
|
5898
|
+
configured = injectTableKeys(configured, "tui", [["status_line", statusLine]]);
|
|
5458
5899
|
if (effectiveAutonomy !== "dangerous") configured = injectTableKeys(configured, "sandbox_workspace_write", [["network_access", "true"]]);
|
|
5459
|
-
configured = injectTableKeys(configured, "desktop", [["
|
|
5900
|
+
configured = injectTableKeys(configured, "desktop", [["show-context-window-usage", "true"]]);
|
|
5460
5901
|
if (_platform === "win32") configured = injectTableKeys(configured, "windows", [["sandbox", "\"unelevated\""]]);
|
|
5461
5902
|
for (const agent of AGENTS) configured = injectTableKeys(configured, `agents.${agent}`, [["config_file", `"holycodex/agents/${agent}.toml"`]]);
|
|
5462
5903
|
const plugin = `${START}\n[plugins."holycodex@holycodex"]\nenabled = true\n${END}`;
|
|
5463
5904
|
return `${configured.trim()}\n\n${plugin}\n`;
|
|
5464
5905
|
}
|
|
5465
5906
|
//#endregion
|
|
5907
|
+
//#region packages/cli/src/context7.ts
|
|
5908
|
+
var RUNNERS = [
|
|
5909
|
+
{
|
|
5910
|
+
executable: "nubx",
|
|
5911
|
+
command: "nubx",
|
|
5912
|
+
prefix: ["-y"]
|
|
5913
|
+
},
|
|
5914
|
+
{
|
|
5915
|
+
executable: "nub",
|
|
5916
|
+
command: "nub",
|
|
5917
|
+
prefix: ["dlx"]
|
|
5918
|
+
},
|
|
5919
|
+
{
|
|
5920
|
+
executable: "bunx",
|
|
5921
|
+
command: "bunx",
|
|
5922
|
+
prefix: []
|
|
5923
|
+
},
|
|
5924
|
+
{
|
|
5925
|
+
executable: "bun",
|
|
5926
|
+
command: "bun",
|
|
5927
|
+
prefix: ["x"]
|
|
5928
|
+
},
|
|
5929
|
+
{
|
|
5930
|
+
executable: "pnpmx",
|
|
5931
|
+
command: "pnpmx",
|
|
5932
|
+
prefix: []
|
|
5933
|
+
},
|
|
5934
|
+
{
|
|
5935
|
+
executable: "pnpm",
|
|
5936
|
+
command: "pnpm",
|
|
5937
|
+
prefix: ["dlx"]
|
|
5938
|
+
},
|
|
5939
|
+
{
|
|
5940
|
+
executable: "npmx",
|
|
5941
|
+
command: "npmx",
|
|
5942
|
+
prefix: ["--yes"]
|
|
5943
|
+
},
|
|
5944
|
+
{
|
|
5945
|
+
executable: "npm",
|
|
5946
|
+
command: "npx",
|
|
5947
|
+
prefix: ["--yes"]
|
|
5948
|
+
},
|
|
5949
|
+
{
|
|
5950
|
+
executable: "yarn",
|
|
5951
|
+
command: "yarn",
|
|
5952
|
+
prefix: ["dlx"]
|
|
5953
|
+
}
|
|
5954
|
+
];
|
|
5955
|
+
/** Constructs the supported direct Context7 invocation for the first available runner. */
|
|
5956
|
+
function context7Command(args, executableExists = executableOnPath, env = process.env) {
|
|
5957
|
+
const runner = RUNNERS.find((candidate) => executableExists(candidate.executable));
|
|
5958
|
+
if (runner === void 0) return void 0;
|
|
5959
|
+
return {
|
|
5960
|
+
command: runner.command,
|
|
5961
|
+
args: [
|
|
5962
|
+
...runner.prefix,
|
|
5963
|
+
"ctx7@latest",
|
|
5964
|
+
...args
|
|
5965
|
+
],
|
|
5966
|
+
env: {
|
|
5967
|
+
...env,
|
|
5968
|
+
CI: env.CI ?? "1"
|
|
5969
|
+
}
|
|
5970
|
+
};
|
|
5971
|
+
}
|
|
5972
|
+
/** Reports whether an executable can be resolved from PATH. */
|
|
5973
|
+
function executableOnPath(name) {
|
|
5974
|
+
const path = process.env.PATH;
|
|
5975
|
+
if (path === void 0) return false;
|
|
5976
|
+
const extensions = process.platform === "win32" ? [
|
|
5977
|
+
".exe",
|
|
5978
|
+
".cmd",
|
|
5979
|
+
".bat",
|
|
5980
|
+
""
|
|
5981
|
+
] : [""];
|
|
5982
|
+
for (const directory of path.split(delimiter)) for (const extension of extensions) try {
|
|
5983
|
+
if (process.getBuiltinModule("node:fs").existsSync(`${directory}/${name}${extension}`)) return true;
|
|
5984
|
+
} catch {
|
|
5985
|
+
continue;
|
|
5986
|
+
}
|
|
5987
|
+
return false;
|
|
5988
|
+
}
|
|
5989
|
+
//#endregion
|
|
5466
5990
|
//#region packages/cli/src/doctor.ts
|
|
5467
|
-
var
|
|
5468
|
-
|
|
5991
|
+
var DOCTOR_LSP_IDLE_SHUTDOWN_MS = 1e3;
|
|
5992
|
+
var COMPATIBILITY_KEYS = ["desktop.show-context-window-usage"];
|
|
5993
|
+
async function runCommand(name, args, env) {
|
|
5469
5994
|
const result = await runManagedProcess({
|
|
5470
5995
|
command: name,
|
|
5471
5996
|
args,
|
|
5472
|
-
platform,
|
|
5473
|
-
timeoutMs:
|
|
5474
|
-
maxOutputChars: 64 * 1024
|
|
5997
|
+
platform: process.platform,
|
|
5998
|
+
timeoutMs: 15e3,
|
|
5999
|
+
maxOutputChars: 64 * 1024,
|
|
6000
|
+
...env === void 0 ? {} : { env }
|
|
5475
6001
|
});
|
|
5476
6002
|
return {
|
|
5477
6003
|
ok: result.exitCode === 0 && !result.timedOut && result.error === void 0,
|
|
5478
6004
|
output: `${result.stdout}\n${result.stderr}`.trim() || result.error || ""
|
|
5479
6005
|
};
|
|
5480
6006
|
}
|
|
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
6007
|
var defaultRuntime$1 = {
|
|
5512
6008
|
platform: process.platform,
|
|
5513
|
-
command:
|
|
5514
|
-
|
|
6009
|
+
command: runCommand,
|
|
6010
|
+
executable: executableOnPath,
|
|
5515
6011
|
gitBash: resolveGitBashForCurrentProcess
|
|
5516
6012
|
};
|
|
5517
6013
|
function check(id, status, code, detail, fix) {
|
|
@@ -5523,14 +6019,6 @@ function check(id, status, code, detail, fix) {
|
|
|
5523
6019
|
...fix === void 0 ? {} : { fix }
|
|
5524
6020
|
};
|
|
5525
6021
|
}
|
|
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
6022
|
async function missingFiles(root, paths) {
|
|
5535
6023
|
const missing = [];
|
|
5536
6024
|
for (const path of paths) try {
|
|
@@ -5540,138 +6028,93 @@ async function missingFiles(root, paths) {
|
|
|
5540
6028
|
}
|
|
5541
6029
|
return missing;
|
|
5542
6030
|
}
|
|
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";
|
|
6031
|
+
function tableBody(config, table) {
|
|
6032
|
+
return new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
|
|
5547
6033
|
}
|
|
5548
|
-
function
|
|
5549
|
-
const body =
|
|
5550
|
-
return body === void 0 ? void 0 :
|
|
5551
|
-
}
|
|
5552
|
-
function tableStringArray(config, table, key) {
|
|
5553
|
-
const body = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*$([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(config)?.[1];
|
|
5554
|
-
return body === void 0 ? void 0 : rootTomlStringArray(body, key);
|
|
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);
|
|
6034
|
+
function tableValue(config, table, key) {
|
|
6035
|
+
const body = tableBody(config, table);
|
|
6036
|
+
return body === void 0 ? void 0 : new RegExp(`^\\s*${key.replaceAll("-", "\\-")}\\s*=\\s*(.+?)\\s*$`, "m").exec(body)?.[1];
|
|
5560
6037
|
}
|
|
5561
6038
|
function autonomy(config) {
|
|
5562
6039
|
const approval = rootTomlString(config, "approval_policy");
|
|
5563
|
-
const
|
|
6040
|
+
const reviewer = rootTomlString(config, "approvals_reviewer");
|
|
5564
6041
|
const sandbox = rootTomlString(config, "sandbox_mode");
|
|
5565
|
-
const network =
|
|
5566
|
-
if (approval === "on-request" &&
|
|
5567
|
-
if (approval === "never" &&
|
|
5568
|
-
if (approval === "never" &&
|
|
6042
|
+
const network = tableValue(config, "sandbox_workspace_write", "network_access");
|
|
6043
|
+
if (approval === "on-request" && reviewer === "auto_review" && sandbox === "workspace-write" && network === "true") return "safe-workspace";
|
|
6044
|
+
if (approval === "never" && reviewer === void 0 && sandbox === "workspace-write" && network === "true") return "autonomous-workspace";
|
|
6045
|
+
if (approval === "never" && reviewer === void 0 && sandbox === "danger-full-access") return "dangerous";
|
|
5569
6046
|
return "unknown";
|
|
5570
6047
|
}
|
|
5571
|
-
/** Runs
|
|
6048
|
+
/** Runs installation, configuration, runtime, and override health checks. */
|
|
5572
6049
|
async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex"), runtime = defaultRuntime$1) {
|
|
5573
6050
|
const checks = [];
|
|
5574
6051
|
const pluginRoot = join(home, "plugins", "cache", "holycodex", "holycodex", VERSION);
|
|
5575
6052
|
const agentRoot = join(home, "holycodex", "agents");
|
|
5576
6053
|
const configPath = join(home, "config.toml");
|
|
5577
6054
|
let config = "";
|
|
5578
|
-
let configAvailable = true;
|
|
5579
6055
|
try {
|
|
5580
6056
|
config = await readFile(configPath, "utf8");
|
|
5581
6057
|
} catch {
|
|
5582
|
-
|
|
6058
|
+
checks.push(check("config", "error", "config-missing", `Missing ${configPath}.`, "Run holycodex install."));
|
|
5583
6059
|
}
|
|
5584
6060
|
const missing = await missingFiles(pluginRoot, [
|
|
5585
6061
|
".codex-plugin/plugin.json",
|
|
5586
|
-
".mcp.json",
|
|
5587
|
-
"LICENSE-OH-MY-OPENCODE-SLIM-MIT.txt",
|
|
5588
6062
|
"hooks/hooks.json",
|
|
5589
6063
|
...requiredPackageRuntimes(runtime.platform).map((file) => `runtime/${file}`),
|
|
5590
6064
|
...AGENTS.map((name) => `agents/${name}.toml`),
|
|
5591
6065
|
...SKILLS.map((name) => `skills/${name}/SKILL.md`)
|
|
5592
6066
|
]);
|
|
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
|
-
}
|
|
6067
|
+
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."));
|
|
6068
|
+
const webSearchOverride = readPreservedRootOverrides(config).webSearch;
|
|
6069
|
+
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."));
|
|
6070
|
+
const status = rootTomlStringArray(config, "status_line") ?? rootTomlStringArray(tableBody(config, "tui") ?? "", "status_line");
|
|
6071
|
+
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."));
|
|
6072
|
+
checks.push(check("screenshot", "ok", "screenshot-default-preserved", "HolyCodex does not override the enabled Codex screenshot default."));
|
|
6073
|
+
const context7 = context7Command(["--version"], runtime.executable);
|
|
6074
|
+
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."));
|
|
6075
|
+
else checks.push(check("context7", "ok", "context7-cli-ready", `${context7.command} constructs a valid direct ctx7@latest command.`));
|
|
6076
|
+
const lsp = await runtime.command(process.execPath, [
|
|
6077
|
+
join(pluginRoot, "runtime", "lsp.js"),
|
|
6078
|
+
"status",
|
|
6079
|
+
"--json"
|
|
6080
|
+
], {
|
|
6081
|
+
...process.env,
|
|
6082
|
+
HOLYCODEX_LSP_IDLE_SHUTDOWN_MS: String(DOCTOR_LSP_IDLE_SHUTDOWN_MS),
|
|
6083
|
+
HOLYCODEX_LSP_IDLE_CHECK_INTERVAL_MS: "50"
|
|
6084
|
+
});
|
|
6085
|
+
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
6086
|
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);
|
|
6087
|
+
const resolution = runtime.gitBash();
|
|
6088
|
+
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));
|
|
6089
|
+
}
|
|
5640
6090
|
const plan = readManagedPlan(config);
|
|
5641
|
-
|
|
5642
|
-
const
|
|
5643
|
-
const
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
checks.push(
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
checks.push(
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
if (
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
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);
|
|
6091
|
+
const overrides = readPreservedRootOverrides(config);
|
|
6092
|
+
const fast = readManagedFastMode(config);
|
|
6093
|
+
const workflow = readManagedWorkflowPolicy(config);
|
|
6094
|
+
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} workflow policy is active with permitted stage routes.`));
|
|
6095
|
+
checks.push(plan === void 0 || workflow === void 0 ? check("workflow", "error", "workflow-settings-missing", "Managed workflow settings are missing or invalid.", "Reinstall HolyCodex.") : JSON.stringify(workflow) === JSON.stringify({
|
|
6096
|
+
plan,
|
|
6097
|
+
limits: MODEL_ROUTING_PLANS[plan].workflow.limits,
|
|
6098
|
+
projectedUsage: MODEL_ROUTING_PLANS[plan].workflow.projectedUsage,
|
|
6099
|
+
runtime: MODEL_ROUTING_PLANS[plan].workflow.runtime,
|
|
6100
|
+
softSizeGuidance: MODEL_ROUTING_PLANS[plan].workflow.softSizeGuidance
|
|
6101
|
+
}) ? check("workflow", "ok", "workflow-settings-ready", `${plan} workflow limits, projected usage, runtime, and size guidance match the catalog.`) : check("workflow", "error", "workflow-settings-drift", `${plan} workflow settings do not match the authoritative catalog.`, "Reinstall HolyCodex."));
|
|
6102
|
+
checks.push(missing.includes("runtime/workflow.js") ? check("workflow-runtime", "error", "workflow-runtime-missing", "The isolated workflow runtime is missing.", "Reinstall HolyCodex.") : check("workflow-runtime", "ok", "workflow-runtime-ready", "The isolated workflow runtime is present."));
|
|
6103
|
+
const manifest = await readFile(join(pluginRoot, ".codex-plugin", "plugin.json"), "utf8").catch(() => "");
|
|
6104
|
+
const mcpManifest = await access(join(pluginRoot, ".mcp.json")).then(() => true).catch(() => false);
|
|
6105
|
+
checks.push(!mcpManifest && !manifest.includes("mcpServers") && !manifest.includes("MCP Tools") ? check("mcp", "ok", "mcp-free", "The installation does not declare MCP servers or tools.") : check("mcp", "error", "mcp-declared", "The installation declares MCP servers or tools.", "Reinstall HolyCodex from a MCP-free package."));
|
|
6106
|
+
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."));
|
|
6107
|
+
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."));
|
|
6108
|
+
if (plan !== void 0) for (const agent of AGENTS) {
|
|
6109
|
+
const source = await readFile(join(agentRoot, `${agent}.toml`), "utf8").catch(() => "");
|
|
6110
|
+
const expected = MODEL_ROUTING_PLANS[plan].agents[agent];
|
|
6111
|
+
const overridden = rootTomlString(source, "model") !== expected.model || rootTomlString(source, "model_reasoning_effort") !== expected.reasoningEffort;
|
|
6112
|
+
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
6113
|
}
|
|
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."));
|
|
6114
|
+
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
6115
|
return {
|
|
5673
|
-
healthy:
|
|
5674
|
-
autonomy:
|
|
6116
|
+
healthy: checks.every((item) => item.status !== "error"),
|
|
6117
|
+
autonomy: autonomy(config),
|
|
5675
6118
|
checks
|
|
5676
6119
|
};
|
|
5677
6120
|
}
|
|
@@ -5821,8 +6264,14 @@ function deduplicate(candidates) {
|
|
|
5821
6264
|
}
|
|
5822
6265
|
//#endregion
|
|
5823
6266
|
//#region packages/cli/src/codex-security.ts
|
|
5824
|
-
var CODEX_SECURITY_PLUGIN =
|
|
5825
|
-
|
|
6267
|
+
var CODEX_SECURITY_PLUGIN = {
|
|
6268
|
+
id: "codex-security@openai-curated",
|
|
6269
|
+
marketplace: "openai-curated"
|
|
6270
|
+
};
|
|
6271
|
+
var COMPUTER_USE_PLUGIN = {
|
|
6272
|
+
id: "computer-use@openai-bundled",
|
|
6273
|
+
marketplace: "openai-bundled"
|
|
6274
|
+
};
|
|
5826
6275
|
var CODEX_PLUGIN_OPERATIONAL_TIMEOUT_MS = 15e3;
|
|
5827
6276
|
var CODEX_PACKAGE_BOOTSTRAP_TIMEOUT_MS = 12e4;
|
|
5828
6277
|
var MAX_CODEX_CATALOG_DIAGNOSTIC_CHARS = 256 * 1024;
|
|
@@ -5863,6 +6312,14 @@ var FATAL_POLICY_CODES = /* @__PURE__ */ new Set([
|
|
|
5863
6312
|
]);
|
|
5864
6313
|
/** Installs or enables the official Codex Security plugin without failing HolyCodex installation. */
|
|
5865
6314
|
async function installCodexSecurity(runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
6315
|
+
return installOfficialPlugin(CODEX_SECURITY_PLUGIN, runProcess, platform, env, options);
|
|
6316
|
+
}
|
|
6317
|
+
/** Installs or enables the official Computer Use plugin without failing HolyCodex installation. */
|
|
6318
|
+
async function installComputerUse(runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
6319
|
+
return installOfficialPlugin(COMPUTER_USE_PLUGIN, runProcess, platform, env, options);
|
|
6320
|
+
}
|
|
6321
|
+
/** Installs or enables one official Codex plugin through a verified catalog entry. */
|
|
6322
|
+
async function installOfficialPlugin(plugin, runProcess = runManagedProcess, platform = process.platform, env = process.env, options = {}) {
|
|
5866
6323
|
const runtimeFacts = options.runtimeFacts ?? (runProcess === runManagedProcess ? defaultCodexLauncherRuntimeFacts(platform) : void 0);
|
|
5867
6324
|
const candidates = createCodexLauncherCandidates({
|
|
5868
6325
|
...options.injected === void 0 ? {} : { injected: options.injected },
|
|
@@ -5882,7 +6339,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5882
6339
|
continue;
|
|
5883
6340
|
}
|
|
5884
6341
|
if (installedOutcome.kind === "fatal") return skipped(installedOutcome.reason, attemptedLaunchers);
|
|
5885
|
-
const installedPlugin = findPlugin(installedOutcome.catalog);
|
|
6342
|
+
const installedPlugin = findPlugin(installedOutcome.catalog, plugin.id);
|
|
5886
6343
|
if (installedPlugin?.installed === true && installedPlugin.enabled === true) return {
|
|
5887
6344
|
status: "already-installed",
|
|
5888
6345
|
launcherSource: launcher.source
|
|
@@ -5900,7 +6357,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5900
6357
|
continue;
|
|
5901
6358
|
}
|
|
5902
6359
|
if (catalogOutcome.kind === "fatal") return skipped(catalogOutcome.reason, attemptedLaunchers);
|
|
5903
|
-
if (findPlugin(catalogOutcome.catalog) === void 0) {
|
|
6360
|
+
if (findPlugin(catalogOutcome.catalog, plugin.id) === void 0) {
|
|
5904
6361
|
const marketplaceOutcome = inspectMarketplaceResult(await runCodexPlugin(runProcess, launcher, [
|
|
5905
6362
|
"plugin",
|
|
5906
6363
|
"marketplace",
|
|
@@ -5912,14 +6369,14 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5912
6369
|
continue;
|
|
5913
6370
|
}
|
|
5914
6371
|
if (marketplaceOutcome.kind === "fatal") return skipped(marketplaceOutcome.reason, attemptedLaunchers);
|
|
5915
|
-
fallbackReasons.push(marketplaceOutcome.marketplaces.includes(
|
|
6372
|
+
fallbackReasons.push(marketplaceOutcome.marketplaces.includes(plugin.marketplace) ? "plugin-not-offered" : "marketplace-unavailable");
|
|
5916
6373
|
continue;
|
|
5917
6374
|
}
|
|
5918
6375
|
}
|
|
5919
6376
|
const addOutcome = inspectAddResult(await runCodexPlugin(runProcess, launcher, [
|
|
5920
6377
|
"plugin",
|
|
5921
6378
|
"add",
|
|
5922
|
-
|
|
6379
|
+
plugin.id,
|
|
5923
6380
|
"--json"
|
|
5924
6381
|
], platform, env, "add"), launcher);
|
|
5925
6382
|
if (addOutcome.kind === "fallback") {
|
|
@@ -5937,7 +6394,7 @@ async function installCodexSecurity(runProcess = runManagedProcess, platform = p
|
|
|
5937
6394
|
continue;
|
|
5938
6395
|
}
|
|
5939
6396
|
if (verification.kind === "fatal") return skipped(verification.reason, attemptedLaunchers);
|
|
5940
|
-
const verifiedPlugin = findPlugin(verification.catalog);
|
|
6397
|
+
const verifiedPlugin = findPlugin(verification.catalog, plugin.id);
|
|
5941
6398
|
if (verifiedPlugin?.installed !== true || verifiedPlugin.enabled !== true) {
|
|
5942
6399
|
fallbackReasons.push("verification-failed");
|
|
5943
6400
|
continue;
|
|
@@ -6024,8 +6481,8 @@ function inspectMarketplaceResult(result, launcher) {
|
|
|
6024
6481
|
marketplaces
|
|
6025
6482
|
};
|
|
6026
6483
|
}
|
|
6027
|
-
function findPlugin(catalog) {
|
|
6028
|
-
return catalog.plugins.find(({ id }) => id ===
|
|
6484
|
+
function findPlugin(catalog, pluginId) {
|
|
6485
|
+
return catalog.plugins.find(({ id }) => id === pluginId);
|
|
6029
6486
|
}
|
|
6030
6487
|
function classifyFailure(result, launcher) {
|
|
6031
6488
|
if (result.error !== void 0) {
|
|
@@ -6363,6 +6820,7 @@ var defaultRuntime = {
|
|
|
6363
6820
|
gitBash: resolveGitBashForCurrentProcess,
|
|
6364
6821
|
runProcess: runManagedProcess
|
|
6365
6822
|
};
|
|
6823
|
+
var BACKUP_RETENTION = 5;
|
|
6366
6824
|
function paths(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")) {
|
|
6367
6825
|
const marketplaceCache = join(home, "plugins", "cache", "holycodex");
|
|
6368
6826
|
const cacheRoot = join(marketplaceCache, "holycodex");
|
|
@@ -6390,43 +6848,87 @@ function assertGitBashReady(platform, resolution) {
|
|
|
6390
6848
|
}
|
|
6391
6849
|
/** Provides install. */
|
|
6392
6850
|
async function install(options, runtime = defaultRuntime) {
|
|
6851
|
+
notify(options, "prerequisites", "Checking prerequisites", "running");
|
|
6393
6852
|
assertGitBashReady(runtime.platform, runtime.gitBash());
|
|
6853
|
+
notify(options, "prerequisites", "Checking prerequisites", "complete");
|
|
6394
6854
|
const plan = options.plan ?? "plus";
|
|
6395
6855
|
const target = paths();
|
|
6396
6856
|
const root = backupRoot();
|
|
6857
|
+
notify(options, "backup", "Backing up existing installation", "running");
|
|
6858
|
+
const configBackup = await backup(target.config, root);
|
|
6859
|
+
const cacheBackup = await backup(target.marketplaceCache, root);
|
|
6860
|
+
const agentsBackup = await backup(target.agents, root);
|
|
6397
6861
|
const backups = [
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6862
|
+
configBackup,
|
|
6863
|
+
cacheBackup,
|
|
6864
|
+
agentsBackup,
|
|
6401
6865
|
...await Promise.all(target.legacy.map((path) => backup(path, root)))
|
|
6402
6866
|
].filter((path) => path !== void 0);
|
|
6867
|
+
notify(options, "backup", "Backing up existing installation", "complete", `${backups.length} saved`);
|
|
6868
|
+
notify(options, "configuration", "Preparing configuration", "running");
|
|
6403
6869
|
const existingConfig = await readText(target.config);
|
|
6404
6870
|
const previousPlan = readManagedPlan(existingConfig);
|
|
6405
6871
|
const fastMode = options.fast ?? "standard";
|
|
6406
6872
|
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);
|
|
6873
|
+
notify(options, "configuration", "Preparing configuration", "complete", plan);
|
|
6874
|
+
notify(options, "staging", "Staging plugin and agent files", "running");
|
|
6415
6875
|
const existingAgentPreferences = await readAgentPreferences(target.agents, previousPlan);
|
|
6416
|
-
await
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
});
|
|
6420
|
-
await
|
|
6421
|
-
await
|
|
6422
|
-
await
|
|
6876
|
+
const staging = await mkdtemp(join(tmpdir(), "holycodex-stage-"));
|
|
6877
|
+
const stagedCache = join(staging, "cache");
|
|
6878
|
+
const stagedAgents = join(staging, "agents");
|
|
6879
|
+
await cp(pluginRoot, stagedCache, { recursive: true });
|
|
6880
|
+
await writeInstalledAgents(join(stagedCache, "agents"), runtime.platform, plan, fastMode);
|
|
6881
|
+
await cp(join(pluginRoot, "agents"), stagedAgents, { recursive: true });
|
|
6882
|
+
await writeInstalledAgents(stagedAgents, runtime.platform, plan, fastMode);
|
|
6883
|
+
await preserveAgentPreferences(stagedAgents, existingAgentPreferences, plan, fastMode);
|
|
6884
|
+
notify(options, "staging", "Staging plugin and agent files", "complete");
|
|
6885
|
+
notify(options, "validation", "Validating staged installation", "running");
|
|
6886
|
+
await validateStaging(stagedCache, stagedAgents);
|
|
6887
|
+
notify(options, "validation", "Validating staged installation", "complete");
|
|
6423
6888
|
const removedLegacy = [];
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6889
|
+
let codexSecurity;
|
|
6890
|
+
let computerUse;
|
|
6891
|
+
try {
|
|
6892
|
+
notify(options, "managed-files", "Installing managed files", "running");
|
|
6893
|
+
await atomicWrite(target.config, config);
|
|
6894
|
+
await rm(target.cache, {
|
|
6895
|
+
recursive: true,
|
|
6896
|
+
force: true
|
|
6897
|
+
});
|
|
6898
|
+
await mkdir(dirname(target.cache), { recursive: true });
|
|
6899
|
+
await cp(stagedCache, target.cache, { recursive: true });
|
|
6900
|
+
await rm(target.agents, {
|
|
6901
|
+
recursive: true,
|
|
6902
|
+
force: true
|
|
6903
|
+
});
|
|
6904
|
+
await cp(stagedAgents, target.agents, { recursive: true });
|
|
6905
|
+
for (const path of target.legacy) {
|
|
6906
|
+
if (!await exists(path)) continue;
|
|
6907
|
+
await rm(path, { recursive: true });
|
|
6908
|
+
removedLegacy.push(path);
|
|
6909
|
+
}
|
|
6910
|
+
notify(options, "managed-files", "Installing managed files", "complete");
|
|
6911
|
+
notify(options, "codex-security", "Installing Codex Security", "running");
|
|
6912
|
+
codexSecurity = await installCodexSecurity(runtime.runProcess, runtime.platform, process.env);
|
|
6913
|
+
notify(options, "codex-security", "Installing Codex Security", "complete", pluginProgressDetail(codexSecurity));
|
|
6914
|
+
notify(options, "computer-use", "Installing Computer Use", "running");
|
|
6915
|
+
computerUse = await installComputerUse(runtime.runProcess, runtime.platform, process.env);
|
|
6916
|
+
notify(options, "computer-use", "Installing Computer Use", "complete", pluginProgressDetail(computerUse));
|
|
6917
|
+
notify(options, "cleanup", "Removing obsolete caches", "running");
|
|
6918
|
+
await removeObsoleteVersionCaches(target.cacheRoot);
|
|
6919
|
+
notify(options, "cleanup", "Removing obsolete caches", "complete");
|
|
6920
|
+
} catch (error) {
|
|
6921
|
+
await restoreTarget(target.config, configBackup);
|
|
6922
|
+
await restoreTarget(target.marketplaceCache, cacheBackup);
|
|
6923
|
+
await restoreTarget(target.agents, agentsBackup);
|
|
6924
|
+
throw error;
|
|
6925
|
+
} finally {
|
|
6926
|
+
await rm(staging, {
|
|
6927
|
+
recursive: true,
|
|
6928
|
+
force: true
|
|
6929
|
+
});
|
|
6428
6930
|
}
|
|
6429
|
-
|
|
6931
|
+
await pruneBackupHistory();
|
|
6430
6932
|
return {
|
|
6431
6933
|
action: "install",
|
|
6432
6934
|
changed: [
|
|
@@ -6438,9 +6940,55 @@ async function install(options, runtime = defaultRuntime) {
|
|
|
6438
6940
|
backups,
|
|
6439
6941
|
plan,
|
|
6440
6942
|
codexSecurity,
|
|
6441
|
-
|
|
6943
|
+
computerUse
|
|
6442
6944
|
};
|
|
6443
6945
|
}
|
|
6946
|
+
function notify(options, step, label, status, detail) {
|
|
6947
|
+
options.onProgress?.({
|
|
6948
|
+
step,
|
|
6949
|
+
label,
|
|
6950
|
+
status,
|
|
6951
|
+
...detail === void 0 ? {} : { detail }
|
|
6952
|
+
});
|
|
6953
|
+
}
|
|
6954
|
+
function pluginProgressDetail(result) {
|
|
6955
|
+
if (result.status === "skipped") return `skipped: ${result.reason}`;
|
|
6956
|
+
return result.launcherSource === void 0 ? result.status : `${result.status} via ${result.launcherSource}`;
|
|
6957
|
+
}
|
|
6958
|
+
async function validateStaging(cache, agents) {
|
|
6959
|
+
const required = [
|
|
6960
|
+
join(cache, ".codex-plugin", "plugin.json"),
|
|
6961
|
+
join(cache, "skills", "context7-cli", "SKILL.md"),
|
|
6962
|
+
join(cache, "runtime", "lsp.js"),
|
|
6963
|
+
...AGENTS.map((agent) => join(agents, `${agent}.toml`))
|
|
6964
|
+
];
|
|
6965
|
+
const missing = [];
|
|
6966
|
+
for (const path of required) if (!await exists(path)) missing.push(path);
|
|
6967
|
+
if (missing.length > 0) throw new Error(`Staged HolyCodex installation is incomplete: ${missing.join(", ")}`);
|
|
6968
|
+
}
|
|
6969
|
+
async function restoreTarget(target, source) {
|
|
6970
|
+
await rm(target, {
|
|
6971
|
+
recursive: true,
|
|
6972
|
+
force: true
|
|
6973
|
+
});
|
|
6974
|
+
if (source !== void 0) await cp(source, target, { recursive: true });
|
|
6975
|
+
}
|
|
6976
|
+
async function removeObsoleteVersionCaches(cacheRoot) {
|
|
6977
|
+
if (!await exists(cacheRoot)) return;
|
|
6978
|
+
for (const entry of await readdir(cacheRoot)) if (entry !== "0.11.3-dev.155.1") await rm(join(cacheRoot, entry), {
|
|
6979
|
+
recursive: true,
|
|
6980
|
+
force: true
|
|
6981
|
+
});
|
|
6982
|
+
}
|
|
6983
|
+
async function pruneBackupHistory() {
|
|
6984
|
+
const root = join(tmpdir(), "holycodex-backups");
|
|
6985
|
+
if (!await exists(root)) return;
|
|
6986
|
+
const entries = (await readdir(root)).sort().reverse();
|
|
6987
|
+
await Promise.allSettled(entries.slice(BACKUP_RETENTION, 6).map((entry) => rm(join(root, entry), {
|
|
6988
|
+
recursive: true,
|
|
6989
|
+
force: true
|
|
6990
|
+
})));
|
|
6991
|
+
}
|
|
6444
6992
|
var AGENT_MANAGED_KEYS = /* @__PURE__ */ new Set([
|
|
6445
6993
|
"model",
|
|
6446
6994
|
"model_reasoning_effort",
|
|
@@ -6448,7 +6996,6 @@ var AGENT_MANAGED_KEYS = /* @__PURE__ */ new Set([
|
|
|
6448
6996
|
"service_tier"
|
|
6449
6997
|
]);
|
|
6450
6998
|
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
6999
|
async function readAgentPreferences(root, previousPlan) {
|
|
6453
7000
|
const preferences = {};
|
|
6454
7001
|
await Promise.all(AGENTS.map(async (agent) => {
|
|
@@ -6513,26 +7060,27 @@ function mergeCustomAgentSettings(input, custom) {
|
|
|
6513
7060
|
if (custom.tables !== void 0 && !output.includes(custom.tables)) output = `${output.trimEnd()}\n\n${custom.tables}`;
|
|
6514
7061
|
return `${output.trimEnd()}\n`;
|
|
6515
7062
|
}
|
|
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
7063
|
async function writeInstalledAgents(root, platform, plan, fastMode) {
|
|
6521
7064
|
await Promise.all(AGENTS.map(async (agent) => {
|
|
6522
7065
|
const path = join(root, `${agent}.toml`);
|
|
6523
7066
|
const route = MODEL_ROUTING_PLANS[plan].agents[agent];
|
|
6524
7067
|
let source = await readText(path);
|
|
7068
|
+
source = composeAgentPolicies(source, platform);
|
|
6525
7069
|
source = replaceTomlString(source, "model", route.model);
|
|
6526
7070
|
source = replaceTomlString(source, "model_reasoning_effort", route.reasoningEffort);
|
|
6527
7071
|
source = replaceTomlString(source, "model_verbosity", "low");
|
|
6528
7072
|
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, ""));
|
|
7073
|
+
await atomicWrite(path, source);
|
|
6534
7074
|
}));
|
|
6535
7075
|
}
|
|
7076
|
+
function composeAgentPolicies(input, platform) {
|
|
7077
|
+
const policy = [
|
|
7078
|
+
LITE_WRITING_POLICY,
|
|
7079
|
+
CONTEXT7_POLICY,
|
|
7080
|
+
...platform === "win32" ? [WINDOWS_SHELL_POLICY] : []
|
|
7081
|
+
].join("\n\n");
|
|
7082
|
+
return input.replace(/(developer_instructions\s*=\s*"""\r?\n)/, `$1${policy}\n\n`);
|
|
7083
|
+
}
|
|
6536
7084
|
/** Provides cleanup. */
|
|
6537
7085
|
async function cleanup(_options) {
|
|
6538
7086
|
const target = paths();
|
|
@@ -6596,17 +7144,21 @@ function renderHelp(version, color) {
|
|
|
6596
7144
|
const title = paint(color, `${BOLD}${CYAN}`, `HolyCodex ${version}`);
|
|
6597
7145
|
const section = (text) => paint(color, BOLD, text);
|
|
6598
7146
|
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 --
|
|
7147
|
+
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
|
|
7148
|
+
--json Print machine-readable output\n`;
|
|
6600
7149
|
}
|
|
6601
7150
|
/** Renders install-specific model plan and option help. */
|
|
6602
7151
|
function renderInstallHelp(version, color) {
|
|
6603
7152
|
const title = paint(color, `${BOLD}${CYAN}`, `HolyCodex ${version}`);
|
|
6604
7153
|
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
|
|
7154
|
+
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
|
|
7155
|
+
--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
7156
|
}
|
|
6607
7157
|
/** Renders error. */
|
|
6608
7158
|
function renderError(message, color) {
|
|
6609
|
-
|
|
7159
|
+
const label = paint(color, `${BOLD}${RED}`, "✗ ERROR");
|
|
7160
|
+
const hint = paint(color, DIM, "Run holycodex --help for usage.");
|
|
7161
|
+
return `${color ? "\r\x1B[2K" : ""}${label} ${message}\n ${hint}\n`;
|
|
6610
7162
|
}
|
|
6611
7163
|
/** Renders doctor. */
|
|
6612
7164
|
function renderDoctor(result, color) {
|
|
@@ -6622,14 +7174,17 @@ function renderRunResult(result, color) {
|
|
|
6622
7174
|
const action = result.action === "install" ? "Updated" : "Removed";
|
|
6623
7175
|
const empty = result.action === "install" ? "changes" : "removal";
|
|
6624
7176
|
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}${
|
|
7177
|
+
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`;
|
|
7178
|
+
}
|
|
7179
|
+
function renderOfficialPlugins(result) {
|
|
7180
|
+
return [renderOfficialPlugin("Codex Security", result.codexSecurity), renderOfficialPlugin("Computer Use", result.computerUse)].join("");
|
|
6626
7181
|
}
|
|
6627
|
-
function
|
|
6628
|
-
if (
|
|
6629
|
-
if (
|
|
6630
|
-
if (
|
|
6631
|
-
if (
|
|
6632
|
-
return `\n Skipped official
|
|
7182
|
+
function renderOfficialPlugin(name, plugin) {
|
|
7183
|
+
if (plugin === void 0) return "";
|
|
7184
|
+
if (plugin.status === "installed") return `\n Installed official ${name} plugin.`;
|
|
7185
|
+
if (plugin.status === "enabled") return `\n Enabled existing official ${name} plugin.`;
|
|
7186
|
+
if (plugin.status === "already-installed") return `\n Official ${name} plugin is already installed and enabled.`;
|
|
7187
|
+
return `\n Skipped official ${name} plugin: ${CODEX_SECURITY_SKIP_MESSAGES[plugin.reason]}`;
|
|
6633
7188
|
}
|
|
6634
7189
|
var CODEX_SECURITY_SKIP_MESSAGES = {
|
|
6635
7190
|
"codex-unavailable": "no usable Codex launcher was found.",
|
|
@@ -6645,6 +7200,13 @@ var CODEX_SECURITY_SKIP_MESSAGES = {
|
|
|
6645
7200
|
unsupported: "the available Codex launchers do not support plugin installation.",
|
|
6646
7201
|
"download-failed": "the latest Codex package could not be downloaded."
|
|
6647
7202
|
};
|
|
7203
|
+
/** Renders one concise installation progress transition. */
|
|
7204
|
+
function renderInstallProgress(event, color, isTTY, verbose) {
|
|
7205
|
+
const detail = verbose && event.detail !== void 0 ? ` ${paint(color, DIM, event.detail)}` : "";
|
|
7206
|
+
if (event.status === "running") return isTTY ? `\r${paint(color, CYAN, "●")} ${event.label}` : "";
|
|
7207
|
+
const line = `${paint(color, GREEN, "✓")} ${event.label}${detail}`;
|
|
7208
|
+
return isTTY ? `\r\u001B[2K${line}\n` : ` ${line}\n`;
|
|
7209
|
+
}
|
|
6648
7210
|
/** Renders notice. */
|
|
6649
7211
|
function renderNotice(kind, message, color) {
|
|
6650
7212
|
return `${paint(color, kind === "warning" ? RED : YELLOW, `! ${kind === "warning" ? "WARNING" : "NOTICE"}`)} ${message}\n`;
|
|
@@ -6652,88 +7214,41 @@ function renderNotice(kind, message, color) {
|
|
|
6652
7214
|
//#endregion
|
|
6653
7215
|
//#region packages/cli/src/cli.ts
|
|
6654
7216
|
async function main() {
|
|
6655
|
-
const
|
|
7217
|
+
const parsed = parseCliArguments(process$1.argv.slice(2));
|
|
6656
7218
|
const stdoutColor = supportsColor(process$1.stdout.isTTY, process$1.env.NO_COLOR);
|
|
6657
7219
|
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));
|
|
7220
|
+
if (parsed.action === "help") {
|
|
7221
|
+
process$1.stdout.write(parsed.command === "install" ? renderInstallHelp(VERSION, stdoutColor) : renderHelp(VERSION, stdoutColor));
|
|
6661
7222
|
return;
|
|
6662
7223
|
}
|
|
6663
|
-
if (
|
|
7224
|
+
if (parsed.action === "version") {
|
|
6664
7225
|
process$1.stdout.write(`${VERSION}\n`);
|
|
6665
7226
|
return;
|
|
6666
7227
|
}
|
|
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
7228
|
const options = {
|
|
6711
|
-
autonomy,
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
plan,
|
|
6715
|
-
|
|
7229
|
+
autonomy: parsed.autonomy,
|
|
7230
|
+
fast: parsed.fast,
|
|
7231
|
+
json: parsed.json,
|
|
7232
|
+
plan: parsed.plan,
|
|
7233
|
+
verbose: parsed.verbose,
|
|
7234
|
+
...parsed.command === "install" && !parsed.json ? { onProgress: (event) => process$1.stdout.write(renderInstallProgress(event, stdoutColor, process$1.stdout.isTTY === true, parsed.verbose)) } : {},
|
|
7235
|
+
...parsed.maxSubagents === void 0 ? {} : { maxSubagents: parsed.maxSubagents }
|
|
6716
7236
|
};
|
|
6717
|
-
if (command === "doctor") {
|
|
7237
|
+
if (parsed.command === "doctor") {
|
|
6718
7238
|
const result = await doctor();
|
|
6719
|
-
process$1.stdout.write(
|
|
7239
|
+
process$1.stdout.write(parsed.json ? `${JSON.stringify(result)}\n` : renderDoctor(result, stdoutColor));
|
|
6720
7240
|
if (!result.healthy) process$1.exitCode = 1;
|
|
6721
7241
|
return;
|
|
6722
7242
|
}
|
|
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));
|
|
7243
|
+
if (parsed.autonomy.requested && parsed.autonomy.mode === "dangerous") process$1.stderr.write(renderNotice("warning", "Dangerous autonomy disables approvals and filesystem sandboxing.", stderrColor));
|
|
7244
|
+
const result = parsed.command === "install" ? await install(options) : await cleanup(options);
|
|
7245
|
+
process$1.stdout.write(parsed.json ? `${JSON.stringify(result)}\n` : renderRunResult(result, stdoutColor));
|
|
6731
7246
|
}
|
|
6732
7247
|
try {
|
|
6733
7248
|
await main();
|
|
6734
7249
|
} catch (error) {
|
|
6735
|
-
const
|
|
6736
|
-
process$1.stderr.write(renderError(formatCliError(error),
|
|
7250
|
+
const color = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
|
|
7251
|
+
process$1.stderr.write(renderError(formatCliError(error), color));
|
|
6737
7252
|
process$1.exitCode = 1;
|
|
6738
7253
|
}
|
|
6739
7254
|
//#endregion
|