holycodex 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +382 -22
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -92,6 +92,13 @@ function cleanRegex(source) {
|
|
|
92
92
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
93
93
|
return source.slice(start, end);
|
|
94
94
|
}
|
|
95
|
+
function floatSafeRemainder(val, step) {
|
|
96
|
+
const ratio = val / step;
|
|
97
|
+
const roundedRatio = Math.round(ratio);
|
|
98
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
99
|
+
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
100
|
+
return ratio - roundedRatio;
|
|
101
|
+
}
|
|
95
102
|
var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
96
103
|
function defineLazy(object, key, getter) {
|
|
97
104
|
let value = void 0;
|
|
@@ -196,7 +203,13 @@ function optionalKeys(shape) {
|
|
|
196
203
|
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
197
204
|
});
|
|
198
205
|
}
|
|
199
|
-
|
|
206
|
+
var NUMBER_FORMAT_RANGES = {
|
|
207
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
208
|
+
int32: [-2147483648, 2147483647],
|
|
209
|
+
uint32: [0, 4294967295],
|
|
210
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
211
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
212
|
+
};
|
|
200
213
|
function pick(schema, mask) {
|
|
201
214
|
const currDef = schema._zod.def;
|
|
202
215
|
const checks = currDef.checks;
|
|
@@ -599,7 +612,8 @@ var string$1 = (params) => {
|
|
|
599
612
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
600
613
|
return new RegExp(`^${regex}$`);
|
|
601
614
|
};
|
|
602
|
-
var
|
|
615
|
+
var integer = /^-?\d+$/;
|
|
616
|
+
var number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
603
617
|
var lowercase = /^[^A-Z]*$/;
|
|
604
618
|
var uppercase = /^[^a-z]*$/;
|
|
605
619
|
//#endregion
|
|
@@ -610,6 +624,145 @@ var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
|
610
624
|
inst._zod.def = def;
|
|
611
625
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
612
626
|
});
|
|
627
|
+
var numericOriginMap = {
|
|
628
|
+
number: "number",
|
|
629
|
+
bigint: "bigint",
|
|
630
|
+
object: "date"
|
|
631
|
+
};
|
|
632
|
+
var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
633
|
+
$ZodCheck.init(inst, def);
|
|
634
|
+
const origin = numericOriginMap[typeof def.value];
|
|
635
|
+
inst._zod.onattach.push((inst) => {
|
|
636
|
+
const bag = inst._zod.bag;
|
|
637
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
638
|
+
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
639
|
+
else bag.exclusiveMaximum = def.value;
|
|
640
|
+
});
|
|
641
|
+
inst._zod.check = (payload) => {
|
|
642
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
643
|
+
payload.issues.push({
|
|
644
|
+
origin,
|
|
645
|
+
code: "too_big",
|
|
646
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
647
|
+
input: payload.value,
|
|
648
|
+
inclusive: def.inclusive,
|
|
649
|
+
inst,
|
|
650
|
+
continue: !def.abort
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
});
|
|
654
|
+
var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
655
|
+
$ZodCheck.init(inst, def);
|
|
656
|
+
const origin = numericOriginMap[typeof def.value];
|
|
657
|
+
inst._zod.onattach.push((inst) => {
|
|
658
|
+
const bag = inst._zod.bag;
|
|
659
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
660
|
+
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
661
|
+
else bag.exclusiveMinimum = def.value;
|
|
662
|
+
});
|
|
663
|
+
inst._zod.check = (payload) => {
|
|
664
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
665
|
+
payload.issues.push({
|
|
666
|
+
origin,
|
|
667
|
+
code: "too_small",
|
|
668
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
669
|
+
input: payload.value,
|
|
670
|
+
inclusive: def.inclusive,
|
|
671
|
+
inst,
|
|
672
|
+
continue: !def.abort
|
|
673
|
+
});
|
|
674
|
+
};
|
|
675
|
+
});
|
|
676
|
+
var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
677
|
+
$ZodCheck.init(inst, def);
|
|
678
|
+
inst._zod.onattach.push((inst) => {
|
|
679
|
+
var _a;
|
|
680
|
+
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
681
|
+
});
|
|
682
|
+
inst._zod.check = (payload) => {
|
|
683
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
684
|
+
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
685
|
+
payload.issues.push({
|
|
686
|
+
origin: typeof payload.value,
|
|
687
|
+
code: "not_multiple_of",
|
|
688
|
+
divisor: def.value,
|
|
689
|
+
input: payload.value,
|
|
690
|
+
inst,
|
|
691
|
+
continue: !def.abort
|
|
692
|
+
});
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
696
|
+
$ZodCheck.init(inst, def);
|
|
697
|
+
def.format = def.format || "float64";
|
|
698
|
+
const isInt = def.format?.includes("int");
|
|
699
|
+
const origin = isInt ? "int" : "number";
|
|
700
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
701
|
+
inst._zod.onattach.push((inst) => {
|
|
702
|
+
const bag = inst._zod.bag;
|
|
703
|
+
bag.format = def.format;
|
|
704
|
+
bag.minimum = minimum;
|
|
705
|
+
bag.maximum = maximum;
|
|
706
|
+
if (isInt) bag.pattern = integer;
|
|
707
|
+
});
|
|
708
|
+
inst._zod.check = (payload) => {
|
|
709
|
+
const input = payload.value;
|
|
710
|
+
if (isInt) {
|
|
711
|
+
if (!Number.isInteger(input)) {
|
|
712
|
+
payload.issues.push({
|
|
713
|
+
expected: origin,
|
|
714
|
+
format: def.format,
|
|
715
|
+
code: "invalid_type",
|
|
716
|
+
continue: false,
|
|
717
|
+
input,
|
|
718
|
+
inst
|
|
719
|
+
});
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (!Number.isSafeInteger(input)) {
|
|
723
|
+
if (input > 0) payload.issues.push({
|
|
724
|
+
input,
|
|
725
|
+
code: "too_big",
|
|
726
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
727
|
+
note: "Integers must be within the safe integer range.",
|
|
728
|
+
inst,
|
|
729
|
+
origin,
|
|
730
|
+
inclusive: true,
|
|
731
|
+
continue: !def.abort
|
|
732
|
+
});
|
|
733
|
+
else payload.issues.push({
|
|
734
|
+
input,
|
|
735
|
+
code: "too_small",
|
|
736
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
737
|
+
note: "Integers must be within the safe integer range.",
|
|
738
|
+
inst,
|
|
739
|
+
origin,
|
|
740
|
+
inclusive: true,
|
|
741
|
+
continue: !def.abort
|
|
742
|
+
});
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (input < minimum) payload.issues.push({
|
|
747
|
+
origin: "number",
|
|
748
|
+
input,
|
|
749
|
+
code: "too_small",
|
|
750
|
+
minimum,
|
|
751
|
+
inclusive: true,
|
|
752
|
+
inst,
|
|
753
|
+
continue: !def.abort
|
|
754
|
+
});
|
|
755
|
+
if (input > maximum) payload.issues.push({
|
|
756
|
+
origin: "number",
|
|
757
|
+
input,
|
|
758
|
+
code: "too_big",
|
|
759
|
+
maximum,
|
|
760
|
+
inclusive: true,
|
|
761
|
+
inst,
|
|
762
|
+
continue: !def.abort
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
});
|
|
613
766
|
var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
614
767
|
var _a;
|
|
615
768
|
$ZodCheck.init(inst, def);
|
|
@@ -1231,6 +1384,30 @@ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1231
1384
|
});
|
|
1232
1385
|
};
|
|
1233
1386
|
});
|
|
1387
|
+
var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
1388
|
+
$ZodType.init(inst, def);
|
|
1389
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
1390
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1391
|
+
if (def.coerce) try {
|
|
1392
|
+
payload.value = Number(payload.value);
|
|
1393
|
+
} catch (_) {}
|
|
1394
|
+
const input = payload.value;
|
|
1395
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1396
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1397
|
+
payload.issues.push({
|
|
1398
|
+
expected: "number",
|
|
1399
|
+
code: "invalid_type",
|
|
1400
|
+
input,
|
|
1401
|
+
inst,
|
|
1402
|
+
...received ? { received } : {}
|
|
1403
|
+
});
|
|
1404
|
+
return payload;
|
|
1405
|
+
};
|
|
1406
|
+
});
|
|
1407
|
+
var $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1408
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
1409
|
+
$ZodNumber.init(inst, def);
|
|
1410
|
+
});
|
|
1234
1411
|
var $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
|
|
1235
1412
|
$ZodType.init(inst, def);
|
|
1236
1413
|
inst._zod.parse = (payload) => payload;
|
|
@@ -1801,7 +1978,7 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1801
1978
|
issues: []
|
|
1802
1979
|
}, ctx);
|
|
1803
1980
|
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
1804
|
-
if (typeof key === "string" && number.test(key) && keyResult.issues.length) {
|
|
1981
|
+
if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
|
|
1805
1982
|
const retryResult = def.keyType._zod.run({
|
|
1806
1983
|
value: Number(key),
|
|
1807
1984
|
issues: []
|
|
@@ -2428,6 +2605,24 @@ function _isoDuration(Class, params) {
|
|
|
2428
2605
|
});
|
|
2429
2606
|
}
|
|
2430
2607
|
// @__NO_SIDE_EFFECTS__
|
|
2608
|
+
function _number(Class, params) {
|
|
2609
|
+
return new Class({
|
|
2610
|
+
type: "number",
|
|
2611
|
+
checks: [],
|
|
2612
|
+
...normalizeParams(params)
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
// @__NO_SIDE_EFFECTS__
|
|
2616
|
+
function _int(Class, params) {
|
|
2617
|
+
return new Class({
|
|
2618
|
+
type: "number",
|
|
2619
|
+
check: "number_format",
|
|
2620
|
+
abort: false,
|
|
2621
|
+
format: "safeint",
|
|
2622
|
+
...normalizeParams(params)
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
// @__NO_SIDE_EFFECTS__
|
|
2431
2626
|
function _unknown(Class) {
|
|
2432
2627
|
return new Class({ type: "unknown" });
|
|
2433
2628
|
}
|
|
@@ -2439,6 +2634,50 @@ function _never(Class, params) {
|
|
|
2439
2634
|
});
|
|
2440
2635
|
}
|
|
2441
2636
|
// @__NO_SIDE_EFFECTS__
|
|
2637
|
+
function _lt(value, params) {
|
|
2638
|
+
return new $ZodCheckLessThan({
|
|
2639
|
+
check: "less_than",
|
|
2640
|
+
...normalizeParams(params),
|
|
2641
|
+
value,
|
|
2642
|
+
inclusive: false
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
// @__NO_SIDE_EFFECTS__
|
|
2646
|
+
function _lte(value, params) {
|
|
2647
|
+
return new $ZodCheckLessThan({
|
|
2648
|
+
check: "less_than",
|
|
2649
|
+
...normalizeParams(params),
|
|
2650
|
+
value,
|
|
2651
|
+
inclusive: true
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
// @__NO_SIDE_EFFECTS__
|
|
2655
|
+
function _gt(value, params) {
|
|
2656
|
+
return new $ZodCheckGreaterThan({
|
|
2657
|
+
check: "greater_than",
|
|
2658
|
+
...normalizeParams(params),
|
|
2659
|
+
value,
|
|
2660
|
+
inclusive: false
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
// @__NO_SIDE_EFFECTS__
|
|
2664
|
+
function _gte(value, params) {
|
|
2665
|
+
return new $ZodCheckGreaterThan({
|
|
2666
|
+
check: "greater_than",
|
|
2667
|
+
...normalizeParams(params),
|
|
2668
|
+
value,
|
|
2669
|
+
inclusive: true
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
// @__NO_SIDE_EFFECTS__
|
|
2673
|
+
function _multipleOf(value, params) {
|
|
2674
|
+
return new $ZodCheckMultipleOf({
|
|
2675
|
+
check: "multiple_of",
|
|
2676
|
+
...normalizeParams(params),
|
|
2677
|
+
value
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
// @__NO_SIDE_EFFECTS__
|
|
2442
2681
|
function _maxLength(maximum, params) {
|
|
2443
2682
|
return new $ZodCheckMaxLength({
|
|
2444
2683
|
check: "max_length",
|
|
@@ -2909,6 +3148,26 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
2909
3148
|
}))];
|
|
2910
3149
|
}
|
|
2911
3150
|
};
|
|
3151
|
+
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
3152
|
+
const json = _json;
|
|
3153
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
3154
|
+
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
3155
|
+
else json.type = "number";
|
|
3156
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3157
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3158
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3159
|
+
if (exMin) if (legacy) {
|
|
3160
|
+
json.minimum = exclusiveMinimum;
|
|
3161
|
+
json.exclusiveMinimum = true;
|
|
3162
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
3163
|
+
else if (typeof minimum === "number") json.minimum = minimum;
|
|
3164
|
+
if (exMax) if (legacy) {
|
|
3165
|
+
json.maximum = exclusiveMaximum;
|
|
3166
|
+
json.exclusiveMaximum = true;
|
|
3167
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
3168
|
+
else if (typeof maximum === "number") json.maximum = maximum;
|
|
3169
|
+
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
3170
|
+
};
|
|
2912
3171
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
2913
3172
|
json.not = {};
|
|
2914
3173
|
};
|
|
@@ -3524,6 +3783,74 @@ var ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
|
3524
3783
|
$ZodJWT.init(inst, def);
|
|
3525
3784
|
ZodStringFormat.init(inst, def);
|
|
3526
3785
|
});
|
|
3786
|
+
var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
3787
|
+
$ZodNumber.init(inst, def);
|
|
3788
|
+
ZodType.init(inst, def);
|
|
3789
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
3790
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
3791
|
+
gt(value, params) {
|
|
3792
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
3793
|
+
},
|
|
3794
|
+
gte(value, params) {
|
|
3795
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3796
|
+
},
|
|
3797
|
+
min(value, params) {
|
|
3798
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3799
|
+
},
|
|
3800
|
+
lt(value, params) {
|
|
3801
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
3802
|
+
},
|
|
3803
|
+
lte(value, params) {
|
|
3804
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3805
|
+
},
|
|
3806
|
+
max(value, params) {
|
|
3807
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3808
|
+
},
|
|
3809
|
+
int(params) {
|
|
3810
|
+
return this.check(int(params));
|
|
3811
|
+
},
|
|
3812
|
+
safe(params) {
|
|
3813
|
+
return this.check(int(params));
|
|
3814
|
+
},
|
|
3815
|
+
positive(params) {
|
|
3816
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
3817
|
+
},
|
|
3818
|
+
nonnegative(params) {
|
|
3819
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
3820
|
+
},
|
|
3821
|
+
negative(params) {
|
|
3822
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
3823
|
+
},
|
|
3824
|
+
nonpositive(params) {
|
|
3825
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
3826
|
+
},
|
|
3827
|
+
multipleOf(value, params) {
|
|
3828
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3829
|
+
},
|
|
3830
|
+
step(value, params) {
|
|
3831
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3832
|
+
},
|
|
3833
|
+
finite() {
|
|
3834
|
+
return this;
|
|
3835
|
+
}
|
|
3836
|
+
});
|
|
3837
|
+
const bag = inst._zod.bag;
|
|
3838
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3839
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3840
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
3841
|
+
inst.isFinite = true;
|
|
3842
|
+
inst.format = bag.format ?? null;
|
|
3843
|
+
});
|
|
3844
|
+
function number(params) {
|
|
3845
|
+
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
3846
|
+
}
|
|
3847
|
+
var ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
|
|
3848
|
+
$ZodNumberFormat.init(inst, def);
|
|
3849
|
+
ZodNumber.init(inst, def);
|
|
3850
|
+
});
|
|
3851
|
+
function int(params) {
|
|
3852
|
+
return /* @__PURE__ */ _int(ZodNumberFormat, params);
|
|
3853
|
+
}
|
|
3527
3854
|
var ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
3528
3855
|
$ZodUnknown.init(inst, def);
|
|
3529
3856
|
ZodType.init(inst, def);
|
|
@@ -3925,14 +4252,13 @@ function superRefine(fn, params) {
|
|
|
3925
4252
|
}
|
|
3926
4253
|
//#endregion
|
|
3927
4254
|
//#region packages/cli/src/catalog.ts
|
|
3928
|
-
var VERSION = "0.
|
|
4255
|
+
var VERSION = "0.9.0";
|
|
3929
4256
|
var SKILLS = [
|
|
3930
4257
|
"ast-grep",
|
|
3931
4258
|
"caveman",
|
|
3932
4259
|
"compress",
|
|
3933
4260
|
"debugging",
|
|
3934
4261
|
"define-goal",
|
|
3935
|
-
"frontend",
|
|
3936
4262
|
"handoff",
|
|
3937
4263
|
"lsp",
|
|
3938
4264
|
"lsp-setup",
|
|
@@ -3999,12 +4325,7 @@ var RoutingPresetSchema = strictObject({
|
|
|
3999
4325
|
worker: ModelRouteSchema
|
|
4000
4326
|
}),
|
|
4001
4327
|
usage: strictObject({
|
|
4002
|
-
maxSubagents:
|
|
4003
|
-
literal(0),
|
|
4004
|
-
literal(1),
|
|
4005
|
-
literal(2),
|
|
4006
|
-
literal(3)
|
|
4007
|
-
]),
|
|
4328
|
+
maxSubagents: number().int().nonnegative(),
|
|
4008
4329
|
maxDepth: literal(1)
|
|
4009
4330
|
})
|
|
4010
4331
|
});
|
|
@@ -4045,7 +4366,7 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4045
4366
|
"plus-low": {
|
|
4046
4367
|
root: {
|
|
4047
4368
|
model: "gpt-5.6-sol",
|
|
4048
|
-
reasoningEffort: "
|
|
4369
|
+
reasoningEffort: "low"
|
|
4049
4370
|
},
|
|
4050
4371
|
agents: {
|
|
4051
4372
|
explorer: {
|
|
@@ -4069,7 +4390,7 @@ var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
|
|
|
4069
4390
|
plus: {
|
|
4070
4391
|
root: {
|
|
4071
4392
|
model: "gpt-5.6-sol",
|
|
4072
|
-
reasoningEffort: "
|
|
4393
|
+
reasoningEffort: "medium"
|
|
4073
4394
|
},
|
|
4074
4395
|
agents: {
|
|
4075
4396
|
explorer: {
|
|
@@ -4705,7 +5026,7 @@ function readManagedPlan(input) {
|
|
|
4705
5026
|
function readManagedMaxSubagents(input) {
|
|
4706
5027
|
const raw = new RegExp(`^${MAX_SUBAGENTS_PREFIX}(.*)$`, "m").exec(input)?.[1]?.trim();
|
|
4707
5028
|
if (raw === void 0) return { configured: false };
|
|
4708
|
-
if (
|
|
5029
|
+
if (!/^\d+$/.test(raw)) return { configured: true };
|
|
4709
5030
|
return {
|
|
4710
5031
|
configured: true,
|
|
4711
5032
|
value: Number(raw)
|
|
@@ -4799,7 +5120,7 @@ function installConfig(input, mode, _platform, plan = DEFAULT_PLAN, maxSubagents
|
|
|
4799
5120
|
configured = injectTableKey(configured, "agents", "max_depth", String(usage.maxDepth));
|
|
4800
5121
|
if (mode !== "dangerous") configured = injectTableKey(configured, "sandbox_workspace_write", "network_access", "true");
|
|
4801
5122
|
for (const agent of AGENTS) configured = injectTableKey(configured, `agents.${agent}`, "config_file", `"holycodex/agents/${agent}.toml"`);
|
|
4802
|
-
const plugin = `${START}\n[
|
|
5123
|
+
const plugin = `${START}\n[plugins."holycodex@holycodex"]\nenabled = true\n${END}`;
|
|
4803
5124
|
return `${configured.trim()}\n\n${plugin}\n`;
|
|
4804
5125
|
}
|
|
4805
5126
|
//#endregion
|
|
@@ -5042,9 +5363,39 @@ async function readText(path) {
|
|
|
5042
5363
|
}
|
|
5043
5364
|
//#endregion
|
|
5044
5365
|
//#region packages/cli/src/install.ts
|
|
5366
|
+
var MARKETPLACE_ARGS = [
|
|
5367
|
+
"plugin",
|
|
5368
|
+
"marketplace",
|
|
5369
|
+
"add",
|
|
5370
|
+
"https://github.com/openai/plugins.git",
|
|
5371
|
+
"--ref",
|
|
5372
|
+
"main",
|
|
5373
|
+
"--sparse",
|
|
5374
|
+
".agents/plugins",
|
|
5375
|
+
"--json"
|
|
5376
|
+
];
|
|
5377
|
+
var PLUGIN_ARGS = [
|
|
5378
|
+
"plugin",
|
|
5379
|
+
"add",
|
|
5380
|
+
"build-web-apps@openai-curated",
|
|
5381
|
+
"--json"
|
|
5382
|
+
];
|
|
5045
5383
|
var defaultRuntime = {
|
|
5046
5384
|
platform: process.platform,
|
|
5047
|
-
gitBash: resolveGitBashForCurrentProcess
|
|
5385
|
+
gitBash: resolveGitBashForCurrentProcess,
|
|
5386
|
+
command: async (command, args) => {
|
|
5387
|
+
const result = await runManagedProcess({
|
|
5388
|
+
command,
|
|
5389
|
+
args,
|
|
5390
|
+
platform: process.platform,
|
|
5391
|
+
timeoutMs: 12e4,
|
|
5392
|
+
maxOutputChars: 64 * 1024
|
|
5393
|
+
});
|
|
5394
|
+
return {
|
|
5395
|
+
ok: result.exitCode === 0 && !result.timedOut && result.error === void 0,
|
|
5396
|
+
output: `${result.stdout}\n${result.stderr}`.trim() || result.error || "unknown error"
|
|
5397
|
+
};
|
|
5398
|
+
}
|
|
5048
5399
|
};
|
|
5049
5400
|
function paths(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")) {
|
|
5050
5401
|
const marketplaceCache = join(home, "plugins", "cache", "holycodex");
|
|
@@ -5071,9 +5422,19 @@ function assertGitBashReady(platform, resolution) {
|
|
|
5071
5422
|
if (platform !== "win32") return;
|
|
5072
5423
|
if (!resolution.found) throw new Error(resolution.installHint);
|
|
5073
5424
|
}
|
|
5425
|
+
/** Ensures the official Build Web Apps plugin is installed. */
|
|
5426
|
+
async function installBuildWebApps(runtime) {
|
|
5427
|
+
if (process.env.HOLYCODEX_TEST_SKIP_PACKAGE_RESOLUTION === "1") return;
|
|
5428
|
+
for (const args of [MARKETPLACE_ARGS, PLUGIN_ARGS]) {
|
|
5429
|
+
const result = await runtime.command("codex", args);
|
|
5430
|
+
if (result.ok) continue;
|
|
5431
|
+
throw new Error(`Could not install Build Web Apps with \`codex ${args.join(" ")}\`: ${result.output}. Verify Codex is installed and can access https://github.com/openai/plugins.git, then retry HolyCodex installation.`);
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5074
5434
|
/** Provides install. */
|
|
5075
5435
|
async function install(options, runtime = defaultRuntime) {
|
|
5076
5436
|
assertGitBashReady(runtime.platform, runtime.gitBash());
|
|
5437
|
+
await installBuildWebApps(runtime);
|
|
5077
5438
|
const plan = options.plan ?? "plus";
|
|
5078
5439
|
const target = paths();
|
|
5079
5440
|
const root = backupRoot();
|
|
@@ -5085,7 +5446,6 @@ async function install(options, runtime = defaultRuntime) {
|
|
|
5085
5446
|
].filter((path) => path !== void 0);
|
|
5086
5447
|
const existingConfig = await readText(target.config);
|
|
5087
5448
|
const previousPlan = readManagedPlan(existingConfig);
|
|
5088
|
-
const maxSubagents = options.maxSubagents ?? MODEL_ROUTING_PLANS[plan].usage.maxSubagents;
|
|
5089
5449
|
const config = installConfig(existingConfig, options.autonomy, runtime.platform, plan, options.maxSubagents);
|
|
5090
5450
|
await atomicWrite(target.config, config);
|
|
5091
5451
|
await rm(target.marketplaceCache, {
|
|
@@ -5119,7 +5479,7 @@ async function install(options, runtime = defaultRuntime) {
|
|
|
5119
5479
|
],
|
|
5120
5480
|
backups,
|
|
5121
5481
|
plan,
|
|
5122
|
-
maxSubagents
|
|
5482
|
+
...options.maxSubagents === void 0 ? {} : { maxSubagents: options.maxSubagents }
|
|
5123
5483
|
};
|
|
5124
5484
|
}
|
|
5125
5485
|
async function readAgentPreferences(root, previousPlan) {
|
|
@@ -5231,13 +5591,13 @@ function renderHelp(version, color) {
|
|
|
5231
5591
|
const title = paint(color, `${BOLD}${CYAN}`, `HOLYCODEX ${version}`);
|
|
5232
5592
|
const section = (text) => paint(color, BOLD, text);
|
|
5233
5593
|
const muted = (text) => paint(color, DIM, text);
|
|
5234
|
-
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 <
|
|
5594
|
+
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 -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 --json Print machine-readable output\n`;
|
|
5235
5595
|
}
|
|
5236
5596
|
/** Renders install-specific model plan and option help. */
|
|
5237
5597
|
function renderInstallHelp(version, color) {
|
|
5238
5598
|
const title = paint(color, `${BOLD}${CYAN}`, `HOLYCODEX ${version}`);
|
|
5239
5599
|
const section = (text) => paint(color, BOLD, text);
|
|
5240
|
-
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 <
|
|
5600
|
+
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 --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.\n\n${section("Examples:")}\n bunx holycodex install\n bunx holycodex install --plan go\n bunx holycodex install --plan plus-low\n bunx holycodex install --plan plus-high\n bunx holycodex install --plan pro-5x\n bunx holycodex install --plan pro-20x\n`;
|
|
5241
5601
|
}
|
|
5242
5602
|
/** Renders error. */
|
|
5243
5603
|
function renderError(message, color) {
|
|
@@ -5284,8 +5644,8 @@ async function main() {
|
|
|
5284
5644
|
if (args.flatMap((arg, index) => arg === "--max-subagents" ? [index] : []).length > 1) throw new Error("--max-subagents may be specified only once.");
|
|
5285
5645
|
const maxSubagentsIndex = args.indexOf("--max-subagents");
|
|
5286
5646
|
const maxSubagentsValue = maxSubagentsIndex < 0 ? void 0 : args[maxSubagentsIndex + 1];
|
|
5287
|
-
if (maxSubagentsIndex >= 0 && (maxSubagentsValue === void 0 || maxSubagentsValue.startsWith("
|
|
5288
|
-
if (maxSubagentsValue !== void 0 &&
|
|
5647
|
+
if (maxSubagentsIndex >= 0 && (maxSubagentsValue === void 0 || maxSubagentsValue.startsWith("--") || maxSubagentsValue === command)) throw new Error("Missing --max-subagents value. Expected a nonnegative integer.");
|
|
5648
|
+
if (maxSubagentsValue !== void 0 && !/^\d+$/.test(maxSubagentsValue)) throw new Error(`Invalid --max-subagents value: ${maxSubagentsValue}. Expected a nonnegative integer.`);
|
|
5289
5649
|
const maxSubagents = maxSubagentsValue === void 0 ? void 0 : Number(maxSubagentsValue);
|
|
5290
5650
|
const autonomyFlags = args.filter((arg) => [
|
|
5291
5651
|
"--codex-autonomous",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holycodex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Lean Codex-only agent toolkit installer and doctor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepack": "vp run --workspace-root build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@holycodex/plugin": "0.
|
|
42
|
+
"@holycodex/plugin": "0.9.0",
|
|
43
43
|
"zod": "^4.4.3"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|