fathom-cli 0.1.3 → 0.1.7
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 +27 -9
- package/dist/index.js +619 -426
- package/dist/index.js.map +1 -1
- package/package.json +16 -15
package/dist/index.js
CHANGED
|
@@ -127,6 +127,7 @@ var require_extend = __commonJS({
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
// src/index.ts
|
|
130
|
+
import "dotenv/config";
|
|
130
131
|
import { Command as Command15 } from "commander";
|
|
131
132
|
|
|
132
133
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
@@ -788,41 +789,41 @@ var ZodType = class {
|
|
|
788
789
|
get description() {
|
|
789
790
|
return this._def.description;
|
|
790
791
|
}
|
|
791
|
-
_getType(
|
|
792
|
-
return getParsedType(
|
|
792
|
+
_getType(input2) {
|
|
793
|
+
return getParsedType(input2.data);
|
|
793
794
|
}
|
|
794
|
-
_getOrReturnCtx(
|
|
795
|
+
_getOrReturnCtx(input2, ctx) {
|
|
795
796
|
return ctx || {
|
|
796
|
-
common:
|
|
797
|
-
data:
|
|
798
|
-
parsedType: getParsedType(
|
|
797
|
+
common: input2.parent.common,
|
|
798
|
+
data: input2.data,
|
|
799
|
+
parsedType: getParsedType(input2.data),
|
|
799
800
|
schemaErrorMap: this._def.errorMap,
|
|
800
|
-
path:
|
|
801
|
-
parent:
|
|
801
|
+
path: input2.path,
|
|
802
|
+
parent: input2.parent
|
|
802
803
|
};
|
|
803
804
|
}
|
|
804
|
-
_processInputParams(
|
|
805
|
+
_processInputParams(input2) {
|
|
805
806
|
return {
|
|
806
807
|
status: new ParseStatus(),
|
|
807
808
|
ctx: {
|
|
808
|
-
common:
|
|
809
|
-
data:
|
|
810
|
-
parsedType: getParsedType(
|
|
809
|
+
common: input2.parent.common,
|
|
810
|
+
data: input2.data,
|
|
811
|
+
parsedType: getParsedType(input2.data),
|
|
811
812
|
schemaErrorMap: this._def.errorMap,
|
|
812
|
-
path:
|
|
813
|
-
parent:
|
|
813
|
+
path: input2.path,
|
|
814
|
+
parent: input2.parent
|
|
814
815
|
}
|
|
815
816
|
};
|
|
816
817
|
}
|
|
817
|
-
_parseSync(
|
|
818
|
-
const result = this._parse(
|
|
818
|
+
_parseSync(input2) {
|
|
819
|
+
const result = this._parse(input2);
|
|
819
820
|
if (isAsync(result)) {
|
|
820
821
|
throw new Error("Synchronous parse encountered promise.");
|
|
821
822
|
}
|
|
822
823
|
return result;
|
|
823
824
|
}
|
|
824
|
-
_parseAsync(
|
|
825
|
-
const result = this._parse(
|
|
825
|
+
_parseAsync(input2) {
|
|
826
|
+
const result = this._parse(input2);
|
|
826
827
|
return Promise.resolve(result);
|
|
827
828
|
}
|
|
828
829
|
parse(data, params) {
|
|
@@ -1148,13 +1149,13 @@ function isValidCidr(ip, version) {
|
|
|
1148
1149
|
return false;
|
|
1149
1150
|
}
|
|
1150
1151
|
var ZodString = class _ZodString extends ZodType {
|
|
1151
|
-
_parse(
|
|
1152
|
+
_parse(input2) {
|
|
1152
1153
|
if (this._def.coerce) {
|
|
1153
|
-
|
|
1154
|
+
input2.data = String(input2.data);
|
|
1154
1155
|
}
|
|
1155
|
-
const parsedType = this._getType(
|
|
1156
|
+
const parsedType = this._getType(input2);
|
|
1156
1157
|
if (parsedType !== ZodParsedType.string) {
|
|
1157
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1158
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1158
1159
|
addIssueToContext(ctx2, {
|
|
1159
1160
|
code: ZodIssueCode.invalid_type,
|
|
1160
1161
|
expected: ZodParsedType.string,
|
|
@@ -1166,8 +1167,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1166
1167
|
let ctx = void 0;
|
|
1167
1168
|
for (const check of this._def.checks) {
|
|
1168
1169
|
if (check.kind === "min") {
|
|
1169
|
-
if (
|
|
1170
|
-
ctx = this._getOrReturnCtx(
|
|
1170
|
+
if (input2.data.length < check.value) {
|
|
1171
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1171
1172
|
addIssueToContext(ctx, {
|
|
1172
1173
|
code: ZodIssueCode.too_small,
|
|
1173
1174
|
minimum: check.value,
|
|
@@ -1179,8 +1180,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1179
1180
|
status.dirty();
|
|
1180
1181
|
}
|
|
1181
1182
|
} else if (check.kind === "max") {
|
|
1182
|
-
if (
|
|
1183
|
-
ctx = this._getOrReturnCtx(
|
|
1183
|
+
if (input2.data.length > check.value) {
|
|
1184
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1184
1185
|
addIssueToContext(ctx, {
|
|
1185
1186
|
code: ZodIssueCode.too_big,
|
|
1186
1187
|
maximum: check.value,
|
|
@@ -1192,10 +1193,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1192
1193
|
status.dirty();
|
|
1193
1194
|
}
|
|
1194
1195
|
} else if (check.kind === "length") {
|
|
1195
|
-
const tooBig =
|
|
1196
|
-
const tooSmall =
|
|
1196
|
+
const tooBig = input2.data.length > check.value;
|
|
1197
|
+
const tooSmall = input2.data.length < check.value;
|
|
1197
1198
|
if (tooBig || tooSmall) {
|
|
1198
|
-
ctx = this._getOrReturnCtx(
|
|
1199
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1199
1200
|
if (tooBig) {
|
|
1200
1201
|
addIssueToContext(ctx, {
|
|
1201
1202
|
code: ZodIssueCode.too_big,
|
|
@@ -1218,8 +1219,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1218
1219
|
status.dirty();
|
|
1219
1220
|
}
|
|
1220
1221
|
} else if (check.kind === "email") {
|
|
1221
|
-
if (!emailRegex.test(
|
|
1222
|
-
ctx = this._getOrReturnCtx(
|
|
1222
|
+
if (!emailRegex.test(input2.data)) {
|
|
1223
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1223
1224
|
addIssueToContext(ctx, {
|
|
1224
1225
|
validation: "email",
|
|
1225
1226
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1231,8 +1232,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1231
1232
|
if (!emojiRegex) {
|
|
1232
1233
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1233
1234
|
}
|
|
1234
|
-
if (!emojiRegex.test(
|
|
1235
|
-
ctx = this._getOrReturnCtx(
|
|
1235
|
+
if (!emojiRegex.test(input2.data)) {
|
|
1236
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1236
1237
|
addIssueToContext(ctx, {
|
|
1237
1238
|
validation: "emoji",
|
|
1238
1239
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1241,8 +1242,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1241
1242
|
status.dirty();
|
|
1242
1243
|
}
|
|
1243
1244
|
} else if (check.kind === "uuid") {
|
|
1244
|
-
if (!uuidRegex.test(
|
|
1245
|
-
ctx = this._getOrReturnCtx(
|
|
1245
|
+
if (!uuidRegex.test(input2.data)) {
|
|
1246
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1246
1247
|
addIssueToContext(ctx, {
|
|
1247
1248
|
validation: "uuid",
|
|
1248
1249
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1251,8 +1252,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1251
1252
|
status.dirty();
|
|
1252
1253
|
}
|
|
1253
1254
|
} else if (check.kind === "nanoid") {
|
|
1254
|
-
if (!nanoidRegex.test(
|
|
1255
|
-
ctx = this._getOrReturnCtx(
|
|
1255
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
1256
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1256
1257
|
addIssueToContext(ctx, {
|
|
1257
1258
|
validation: "nanoid",
|
|
1258
1259
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1261,8 +1262,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1261
1262
|
status.dirty();
|
|
1262
1263
|
}
|
|
1263
1264
|
} else if (check.kind === "cuid") {
|
|
1264
|
-
if (!cuidRegex.test(
|
|
1265
|
-
ctx = this._getOrReturnCtx(
|
|
1265
|
+
if (!cuidRegex.test(input2.data)) {
|
|
1266
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1266
1267
|
addIssueToContext(ctx, {
|
|
1267
1268
|
validation: "cuid",
|
|
1268
1269
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1271,8 +1272,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1271
1272
|
status.dirty();
|
|
1272
1273
|
}
|
|
1273
1274
|
} else if (check.kind === "cuid2") {
|
|
1274
|
-
if (!cuid2Regex.test(
|
|
1275
|
-
ctx = this._getOrReturnCtx(
|
|
1275
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
1276
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1276
1277
|
addIssueToContext(ctx, {
|
|
1277
1278
|
validation: "cuid2",
|
|
1278
1279
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1281,8 +1282,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1281
1282
|
status.dirty();
|
|
1282
1283
|
}
|
|
1283
1284
|
} else if (check.kind === "ulid") {
|
|
1284
|
-
if (!ulidRegex.test(
|
|
1285
|
-
ctx = this._getOrReturnCtx(
|
|
1285
|
+
if (!ulidRegex.test(input2.data)) {
|
|
1286
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1286
1287
|
addIssueToContext(ctx, {
|
|
1287
1288
|
validation: "ulid",
|
|
1288
1289
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1292,9 +1293,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1292
1293
|
}
|
|
1293
1294
|
} else if (check.kind === "url") {
|
|
1294
1295
|
try {
|
|
1295
|
-
new URL(
|
|
1296
|
+
new URL(input2.data);
|
|
1296
1297
|
} catch {
|
|
1297
|
-
ctx = this._getOrReturnCtx(
|
|
1298
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1298
1299
|
addIssueToContext(ctx, {
|
|
1299
1300
|
validation: "url",
|
|
1300
1301
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1304,9 +1305,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1304
1305
|
}
|
|
1305
1306
|
} else if (check.kind === "regex") {
|
|
1306
1307
|
check.regex.lastIndex = 0;
|
|
1307
|
-
const testResult = check.regex.test(
|
|
1308
|
+
const testResult = check.regex.test(input2.data);
|
|
1308
1309
|
if (!testResult) {
|
|
1309
|
-
ctx = this._getOrReturnCtx(
|
|
1310
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1310
1311
|
addIssueToContext(ctx, {
|
|
1311
1312
|
validation: "regex",
|
|
1312
1313
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1315,10 +1316,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1315
1316
|
status.dirty();
|
|
1316
1317
|
}
|
|
1317
1318
|
} else if (check.kind === "trim") {
|
|
1318
|
-
|
|
1319
|
+
input2.data = input2.data.trim();
|
|
1319
1320
|
} else if (check.kind === "includes") {
|
|
1320
|
-
if (!
|
|
1321
|
-
ctx = this._getOrReturnCtx(
|
|
1321
|
+
if (!input2.data.includes(check.value, check.position)) {
|
|
1322
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1322
1323
|
addIssueToContext(ctx, {
|
|
1323
1324
|
code: ZodIssueCode.invalid_string,
|
|
1324
1325
|
validation: { includes: check.value, position: check.position },
|
|
@@ -1327,12 +1328,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1327
1328
|
status.dirty();
|
|
1328
1329
|
}
|
|
1329
1330
|
} else if (check.kind === "toLowerCase") {
|
|
1330
|
-
|
|
1331
|
+
input2.data = input2.data.toLowerCase();
|
|
1331
1332
|
} else if (check.kind === "toUpperCase") {
|
|
1332
|
-
|
|
1333
|
+
input2.data = input2.data.toUpperCase();
|
|
1333
1334
|
} else if (check.kind === "startsWith") {
|
|
1334
|
-
if (!
|
|
1335
|
-
ctx = this._getOrReturnCtx(
|
|
1335
|
+
if (!input2.data.startsWith(check.value)) {
|
|
1336
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1336
1337
|
addIssueToContext(ctx, {
|
|
1337
1338
|
code: ZodIssueCode.invalid_string,
|
|
1338
1339
|
validation: { startsWith: check.value },
|
|
@@ -1341,8 +1342,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1341
1342
|
status.dirty();
|
|
1342
1343
|
}
|
|
1343
1344
|
} else if (check.kind === "endsWith") {
|
|
1344
|
-
if (!
|
|
1345
|
-
ctx = this._getOrReturnCtx(
|
|
1345
|
+
if (!input2.data.endsWith(check.value)) {
|
|
1346
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1346
1347
|
addIssueToContext(ctx, {
|
|
1347
1348
|
code: ZodIssueCode.invalid_string,
|
|
1348
1349
|
validation: { endsWith: check.value },
|
|
@@ -1352,8 +1353,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1352
1353
|
}
|
|
1353
1354
|
} else if (check.kind === "datetime") {
|
|
1354
1355
|
const regex = datetimeRegex(check);
|
|
1355
|
-
if (!regex.test(
|
|
1356
|
-
ctx = this._getOrReturnCtx(
|
|
1356
|
+
if (!regex.test(input2.data)) {
|
|
1357
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1357
1358
|
addIssueToContext(ctx, {
|
|
1358
1359
|
code: ZodIssueCode.invalid_string,
|
|
1359
1360
|
validation: "datetime",
|
|
@@ -1363,8 +1364,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1363
1364
|
}
|
|
1364
1365
|
} else if (check.kind === "date") {
|
|
1365
1366
|
const regex = dateRegex;
|
|
1366
|
-
if (!regex.test(
|
|
1367
|
-
ctx = this._getOrReturnCtx(
|
|
1367
|
+
if (!regex.test(input2.data)) {
|
|
1368
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1368
1369
|
addIssueToContext(ctx, {
|
|
1369
1370
|
code: ZodIssueCode.invalid_string,
|
|
1370
1371
|
validation: "date",
|
|
@@ -1374,8 +1375,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1374
1375
|
}
|
|
1375
1376
|
} else if (check.kind === "time") {
|
|
1376
1377
|
const regex = timeRegex(check);
|
|
1377
|
-
if (!regex.test(
|
|
1378
|
-
ctx = this._getOrReturnCtx(
|
|
1378
|
+
if (!regex.test(input2.data)) {
|
|
1379
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1379
1380
|
addIssueToContext(ctx, {
|
|
1380
1381
|
code: ZodIssueCode.invalid_string,
|
|
1381
1382
|
validation: "time",
|
|
@@ -1384,8 +1385,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1384
1385
|
status.dirty();
|
|
1385
1386
|
}
|
|
1386
1387
|
} else if (check.kind === "duration") {
|
|
1387
|
-
if (!durationRegex.test(
|
|
1388
|
-
ctx = this._getOrReturnCtx(
|
|
1388
|
+
if (!durationRegex.test(input2.data)) {
|
|
1389
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1389
1390
|
addIssueToContext(ctx, {
|
|
1390
1391
|
validation: "duration",
|
|
1391
1392
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1394,8 +1395,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1394
1395
|
status.dirty();
|
|
1395
1396
|
}
|
|
1396
1397
|
} else if (check.kind === "ip") {
|
|
1397
|
-
if (!isValidIP(
|
|
1398
|
-
ctx = this._getOrReturnCtx(
|
|
1398
|
+
if (!isValidIP(input2.data, check.version)) {
|
|
1399
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1399
1400
|
addIssueToContext(ctx, {
|
|
1400
1401
|
validation: "ip",
|
|
1401
1402
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1404,8 +1405,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1404
1405
|
status.dirty();
|
|
1405
1406
|
}
|
|
1406
1407
|
} else if (check.kind === "jwt") {
|
|
1407
|
-
if (!isValidJWT(
|
|
1408
|
-
ctx = this._getOrReturnCtx(
|
|
1408
|
+
if (!isValidJWT(input2.data, check.alg)) {
|
|
1409
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1409
1410
|
addIssueToContext(ctx, {
|
|
1410
1411
|
validation: "jwt",
|
|
1411
1412
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1414,8 +1415,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1414
1415
|
status.dirty();
|
|
1415
1416
|
}
|
|
1416
1417
|
} else if (check.kind === "cidr") {
|
|
1417
|
-
if (!isValidCidr(
|
|
1418
|
-
ctx = this._getOrReturnCtx(
|
|
1418
|
+
if (!isValidCidr(input2.data, check.version)) {
|
|
1419
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1419
1420
|
addIssueToContext(ctx, {
|
|
1420
1421
|
validation: "cidr",
|
|
1421
1422
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1424,8 +1425,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1424
1425
|
status.dirty();
|
|
1425
1426
|
}
|
|
1426
1427
|
} else if (check.kind === "base64") {
|
|
1427
|
-
if (!base64Regex.test(
|
|
1428
|
-
ctx = this._getOrReturnCtx(
|
|
1428
|
+
if (!base64Regex.test(input2.data)) {
|
|
1429
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1429
1430
|
addIssueToContext(ctx, {
|
|
1430
1431
|
validation: "base64",
|
|
1431
1432
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1434,8 +1435,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1434
1435
|
status.dirty();
|
|
1435
1436
|
}
|
|
1436
1437
|
} else if (check.kind === "base64url") {
|
|
1437
|
-
if (!base64urlRegex.test(
|
|
1438
|
-
ctx = this._getOrReturnCtx(
|
|
1438
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
1439
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1439
1440
|
addIssueToContext(ctx, {
|
|
1440
1441
|
validation: "base64url",
|
|
1441
1442
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1447,7 +1448,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1447
1448
|
util.assertNever(check);
|
|
1448
1449
|
}
|
|
1449
1450
|
}
|
|
1450
|
-
return { status: status.value, value:
|
|
1451
|
+
return { status: status.value, value: input2.data };
|
|
1451
1452
|
}
|
|
1452
1453
|
_regex(regex, validation, message) {
|
|
1453
1454
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1708,13 +1709,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1708
1709
|
this.max = this.lte;
|
|
1709
1710
|
this.step = this.multipleOf;
|
|
1710
1711
|
}
|
|
1711
|
-
_parse(
|
|
1712
|
+
_parse(input2) {
|
|
1712
1713
|
if (this._def.coerce) {
|
|
1713
|
-
|
|
1714
|
+
input2.data = Number(input2.data);
|
|
1714
1715
|
}
|
|
1715
|
-
const parsedType = this._getType(
|
|
1716
|
+
const parsedType = this._getType(input2);
|
|
1716
1717
|
if (parsedType !== ZodParsedType.number) {
|
|
1717
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1718
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1718
1719
|
addIssueToContext(ctx2, {
|
|
1719
1720
|
code: ZodIssueCode.invalid_type,
|
|
1720
1721
|
expected: ZodParsedType.number,
|
|
@@ -1726,8 +1727,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1726
1727
|
const status = new ParseStatus();
|
|
1727
1728
|
for (const check of this._def.checks) {
|
|
1728
1729
|
if (check.kind === "int") {
|
|
1729
|
-
if (!util.isInteger(
|
|
1730
|
-
ctx = this._getOrReturnCtx(
|
|
1730
|
+
if (!util.isInteger(input2.data)) {
|
|
1731
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1731
1732
|
addIssueToContext(ctx, {
|
|
1732
1733
|
code: ZodIssueCode.invalid_type,
|
|
1733
1734
|
expected: "integer",
|
|
@@ -1737,9 +1738,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1737
1738
|
status.dirty();
|
|
1738
1739
|
}
|
|
1739
1740
|
} else if (check.kind === "min") {
|
|
1740
|
-
const tooSmall = check.inclusive ?
|
|
1741
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1741
1742
|
if (tooSmall) {
|
|
1742
|
-
ctx = this._getOrReturnCtx(
|
|
1743
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1743
1744
|
addIssueToContext(ctx, {
|
|
1744
1745
|
code: ZodIssueCode.too_small,
|
|
1745
1746
|
minimum: check.value,
|
|
@@ -1751,9 +1752,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1751
1752
|
status.dirty();
|
|
1752
1753
|
}
|
|
1753
1754
|
} else if (check.kind === "max") {
|
|
1754
|
-
const tooBig = check.inclusive ?
|
|
1755
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1755
1756
|
if (tooBig) {
|
|
1756
|
-
ctx = this._getOrReturnCtx(
|
|
1757
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1757
1758
|
addIssueToContext(ctx, {
|
|
1758
1759
|
code: ZodIssueCode.too_big,
|
|
1759
1760
|
maximum: check.value,
|
|
@@ -1765,8 +1766,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1765
1766
|
status.dirty();
|
|
1766
1767
|
}
|
|
1767
1768
|
} else if (check.kind === "multipleOf") {
|
|
1768
|
-
if (floatSafeRemainder(
|
|
1769
|
-
ctx = this._getOrReturnCtx(
|
|
1769
|
+
if (floatSafeRemainder(input2.data, check.value) !== 0) {
|
|
1770
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1770
1771
|
addIssueToContext(ctx, {
|
|
1771
1772
|
code: ZodIssueCode.not_multiple_of,
|
|
1772
1773
|
multipleOf: check.value,
|
|
@@ -1775,8 +1776,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1775
1776
|
status.dirty();
|
|
1776
1777
|
}
|
|
1777
1778
|
} else if (check.kind === "finite") {
|
|
1778
|
-
if (!Number.isFinite(
|
|
1779
|
-
ctx = this._getOrReturnCtx(
|
|
1779
|
+
if (!Number.isFinite(input2.data)) {
|
|
1780
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1780
1781
|
addIssueToContext(ctx, {
|
|
1781
1782
|
code: ZodIssueCode.not_finite,
|
|
1782
1783
|
message: check.message
|
|
@@ -1787,7 +1788,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1787
1788
|
util.assertNever(check);
|
|
1788
1789
|
}
|
|
1789
1790
|
}
|
|
1790
|
-
return { status: status.value, value:
|
|
1791
|
+
return { status: status.value, value: input2.data };
|
|
1791
1792
|
}
|
|
1792
1793
|
gte(value, message) {
|
|
1793
1794
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1939,25 +1940,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1939
1940
|
this.min = this.gte;
|
|
1940
1941
|
this.max = this.lte;
|
|
1941
1942
|
}
|
|
1942
|
-
_parse(
|
|
1943
|
+
_parse(input2) {
|
|
1943
1944
|
if (this._def.coerce) {
|
|
1944
1945
|
try {
|
|
1945
|
-
|
|
1946
|
+
input2.data = BigInt(input2.data);
|
|
1946
1947
|
} catch {
|
|
1947
|
-
return this._getInvalidInput(
|
|
1948
|
+
return this._getInvalidInput(input2);
|
|
1948
1949
|
}
|
|
1949
1950
|
}
|
|
1950
|
-
const parsedType = this._getType(
|
|
1951
|
+
const parsedType = this._getType(input2);
|
|
1951
1952
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1952
|
-
return this._getInvalidInput(
|
|
1953
|
+
return this._getInvalidInput(input2);
|
|
1953
1954
|
}
|
|
1954
1955
|
let ctx = void 0;
|
|
1955
1956
|
const status = new ParseStatus();
|
|
1956
1957
|
for (const check of this._def.checks) {
|
|
1957
1958
|
if (check.kind === "min") {
|
|
1958
|
-
const tooSmall = check.inclusive ?
|
|
1959
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1959
1960
|
if (tooSmall) {
|
|
1960
|
-
ctx = this._getOrReturnCtx(
|
|
1961
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1961
1962
|
addIssueToContext(ctx, {
|
|
1962
1963
|
code: ZodIssueCode.too_small,
|
|
1963
1964
|
type: "bigint",
|
|
@@ -1968,9 +1969,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1968
1969
|
status.dirty();
|
|
1969
1970
|
}
|
|
1970
1971
|
} else if (check.kind === "max") {
|
|
1971
|
-
const tooBig = check.inclusive ?
|
|
1972
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1972
1973
|
if (tooBig) {
|
|
1973
|
-
ctx = this._getOrReturnCtx(
|
|
1974
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1974
1975
|
addIssueToContext(ctx, {
|
|
1975
1976
|
code: ZodIssueCode.too_big,
|
|
1976
1977
|
type: "bigint",
|
|
@@ -1981,8 +1982,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1981
1982
|
status.dirty();
|
|
1982
1983
|
}
|
|
1983
1984
|
} else if (check.kind === "multipleOf") {
|
|
1984
|
-
if (
|
|
1985
|
-
ctx = this._getOrReturnCtx(
|
|
1985
|
+
if (input2.data % check.value !== BigInt(0)) {
|
|
1986
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1986
1987
|
addIssueToContext(ctx, {
|
|
1987
1988
|
code: ZodIssueCode.not_multiple_of,
|
|
1988
1989
|
multipleOf: check.value,
|
|
@@ -1994,10 +1995,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1994
1995
|
util.assertNever(check);
|
|
1995
1996
|
}
|
|
1996
1997
|
}
|
|
1997
|
-
return { status: status.value, value:
|
|
1998
|
+
return { status: status.value, value: input2.data };
|
|
1998
1999
|
}
|
|
1999
|
-
_getInvalidInput(
|
|
2000
|
-
const ctx = this._getOrReturnCtx(
|
|
2000
|
+
_getInvalidInput(input2) {
|
|
2001
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2001
2002
|
addIssueToContext(ctx, {
|
|
2002
2003
|
code: ZodIssueCode.invalid_type,
|
|
2003
2004
|
expected: ZodParsedType.bigint,
|
|
@@ -2106,13 +2107,13 @@ ZodBigInt.create = (params) => {
|
|
|
2106
2107
|
});
|
|
2107
2108
|
};
|
|
2108
2109
|
var ZodBoolean = class extends ZodType {
|
|
2109
|
-
_parse(
|
|
2110
|
+
_parse(input2) {
|
|
2110
2111
|
if (this._def.coerce) {
|
|
2111
|
-
|
|
2112
|
+
input2.data = Boolean(input2.data);
|
|
2112
2113
|
}
|
|
2113
|
-
const parsedType = this._getType(
|
|
2114
|
+
const parsedType = this._getType(input2);
|
|
2114
2115
|
if (parsedType !== ZodParsedType.boolean) {
|
|
2115
|
-
const ctx = this._getOrReturnCtx(
|
|
2116
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2116
2117
|
addIssueToContext(ctx, {
|
|
2117
2118
|
code: ZodIssueCode.invalid_type,
|
|
2118
2119
|
expected: ZodParsedType.boolean,
|
|
@@ -2120,7 +2121,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
2120
2121
|
});
|
|
2121
2122
|
return INVALID;
|
|
2122
2123
|
}
|
|
2123
|
-
return OK(
|
|
2124
|
+
return OK(input2.data);
|
|
2124
2125
|
}
|
|
2125
2126
|
};
|
|
2126
2127
|
ZodBoolean.create = (params) => {
|
|
@@ -2131,13 +2132,13 @@ ZodBoolean.create = (params) => {
|
|
|
2131
2132
|
});
|
|
2132
2133
|
};
|
|
2133
2134
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2134
|
-
_parse(
|
|
2135
|
+
_parse(input2) {
|
|
2135
2136
|
if (this._def.coerce) {
|
|
2136
|
-
|
|
2137
|
+
input2.data = new Date(input2.data);
|
|
2137
2138
|
}
|
|
2138
|
-
const parsedType = this._getType(
|
|
2139
|
+
const parsedType = this._getType(input2);
|
|
2139
2140
|
if (parsedType !== ZodParsedType.date) {
|
|
2140
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2141
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2141
2142
|
addIssueToContext(ctx2, {
|
|
2142
2143
|
code: ZodIssueCode.invalid_type,
|
|
2143
2144
|
expected: ZodParsedType.date,
|
|
@@ -2145,8 +2146,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2145
2146
|
});
|
|
2146
2147
|
return INVALID;
|
|
2147
2148
|
}
|
|
2148
|
-
if (Number.isNaN(
|
|
2149
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2149
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
2150
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2150
2151
|
addIssueToContext(ctx2, {
|
|
2151
2152
|
code: ZodIssueCode.invalid_date
|
|
2152
2153
|
});
|
|
@@ -2156,8 +2157,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2156
2157
|
let ctx = void 0;
|
|
2157
2158
|
for (const check of this._def.checks) {
|
|
2158
2159
|
if (check.kind === "min") {
|
|
2159
|
-
if (
|
|
2160
|
-
ctx = this._getOrReturnCtx(
|
|
2160
|
+
if (input2.data.getTime() < check.value) {
|
|
2161
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2161
2162
|
addIssueToContext(ctx, {
|
|
2162
2163
|
code: ZodIssueCode.too_small,
|
|
2163
2164
|
message: check.message,
|
|
@@ -2169,8 +2170,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2169
2170
|
status.dirty();
|
|
2170
2171
|
}
|
|
2171
2172
|
} else if (check.kind === "max") {
|
|
2172
|
-
if (
|
|
2173
|
-
ctx = this._getOrReturnCtx(
|
|
2173
|
+
if (input2.data.getTime() > check.value) {
|
|
2174
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2174
2175
|
addIssueToContext(ctx, {
|
|
2175
2176
|
code: ZodIssueCode.too_big,
|
|
2176
2177
|
message: check.message,
|
|
@@ -2187,7 +2188,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2187
2188
|
}
|
|
2188
2189
|
return {
|
|
2189
2190
|
status: status.value,
|
|
2190
|
-
value: new Date(
|
|
2191
|
+
value: new Date(input2.data.getTime())
|
|
2191
2192
|
};
|
|
2192
2193
|
}
|
|
2193
2194
|
_addCheck(check) {
|
|
@@ -2240,10 +2241,10 @@ ZodDate.create = (params) => {
|
|
|
2240
2241
|
});
|
|
2241
2242
|
};
|
|
2242
2243
|
var ZodSymbol = class extends ZodType {
|
|
2243
|
-
_parse(
|
|
2244
|
-
const parsedType = this._getType(
|
|
2244
|
+
_parse(input2) {
|
|
2245
|
+
const parsedType = this._getType(input2);
|
|
2245
2246
|
if (parsedType !== ZodParsedType.symbol) {
|
|
2246
|
-
const ctx = this._getOrReturnCtx(
|
|
2247
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2247
2248
|
addIssueToContext(ctx, {
|
|
2248
2249
|
code: ZodIssueCode.invalid_type,
|
|
2249
2250
|
expected: ZodParsedType.symbol,
|
|
@@ -2251,7 +2252,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
2251
2252
|
});
|
|
2252
2253
|
return INVALID;
|
|
2253
2254
|
}
|
|
2254
|
-
return OK(
|
|
2255
|
+
return OK(input2.data);
|
|
2255
2256
|
}
|
|
2256
2257
|
};
|
|
2257
2258
|
ZodSymbol.create = (params) => {
|
|
@@ -2261,10 +2262,10 @@ ZodSymbol.create = (params) => {
|
|
|
2261
2262
|
});
|
|
2262
2263
|
};
|
|
2263
2264
|
var ZodUndefined = class extends ZodType {
|
|
2264
|
-
_parse(
|
|
2265
|
-
const parsedType = this._getType(
|
|
2265
|
+
_parse(input2) {
|
|
2266
|
+
const parsedType = this._getType(input2);
|
|
2266
2267
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2267
|
-
const ctx = this._getOrReturnCtx(
|
|
2268
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2268
2269
|
addIssueToContext(ctx, {
|
|
2269
2270
|
code: ZodIssueCode.invalid_type,
|
|
2270
2271
|
expected: ZodParsedType.undefined,
|
|
@@ -2272,7 +2273,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
2272
2273
|
});
|
|
2273
2274
|
return INVALID;
|
|
2274
2275
|
}
|
|
2275
|
-
return OK(
|
|
2276
|
+
return OK(input2.data);
|
|
2276
2277
|
}
|
|
2277
2278
|
};
|
|
2278
2279
|
ZodUndefined.create = (params) => {
|
|
@@ -2282,10 +2283,10 @@ ZodUndefined.create = (params) => {
|
|
|
2282
2283
|
});
|
|
2283
2284
|
};
|
|
2284
2285
|
var ZodNull = class extends ZodType {
|
|
2285
|
-
_parse(
|
|
2286
|
-
const parsedType = this._getType(
|
|
2286
|
+
_parse(input2) {
|
|
2287
|
+
const parsedType = this._getType(input2);
|
|
2287
2288
|
if (parsedType !== ZodParsedType.null) {
|
|
2288
|
-
const ctx = this._getOrReturnCtx(
|
|
2289
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2289
2290
|
addIssueToContext(ctx, {
|
|
2290
2291
|
code: ZodIssueCode.invalid_type,
|
|
2291
2292
|
expected: ZodParsedType.null,
|
|
@@ -2293,7 +2294,7 @@ var ZodNull = class extends ZodType {
|
|
|
2293
2294
|
});
|
|
2294
2295
|
return INVALID;
|
|
2295
2296
|
}
|
|
2296
|
-
return OK(
|
|
2297
|
+
return OK(input2.data);
|
|
2297
2298
|
}
|
|
2298
2299
|
};
|
|
2299
2300
|
ZodNull.create = (params) => {
|
|
@@ -2307,8 +2308,8 @@ var ZodAny = class extends ZodType {
|
|
|
2307
2308
|
super(...arguments);
|
|
2308
2309
|
this._any = true;
|
|
2309
2310
|
}
|
|
2310
|
-
_parse(
|
|
2311
|
-
return OK(
|
|
2311
|
+
_parse(input2) {
|
|
2312
|
+
return OK(input2.data);
|
|
2312
2313
|
}
|
|
2313
2314
|
};
|
|
2314
2315
|
ZodAny.create = (params) => {
|
|
@@ -2322,8 +2323,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
2322
2323
|
super(...arguments);
|
|
2323
2324
|
this._unknown = true;
|
|
2324
2325
|
}
|
|
2325
|
-
_parse(
|
|
2326
|
-
return OK(
|
|
2326
|
+
_parse(input2) {
|
|
2327
|
+
return OK(input2.data);
|
|
2327
2328
|
}
|
|
2328
2329
|
};
|
|
2329
2330
|
ZodUnknown.create = (params) => {
|
|
@@ -2333,8 +2334,8 @@ ZodUnknown.create = (params) => {
|
|
|
2333
2334
|
});
|
|
2334
2335
|
};
|
|
2335
2336
|
var ZodNever = class extends ZodType {
|
|
2336
|
-
_parse(
|
|
2337
|
-
const ctx = this._getOrReturnCtx(
|
|
2337
|
+
_parse(input2) {
|
|
2338
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2338
2339
|
addIssueToContext(ctx, {
|
|
2339
2340
|
code: ZodIssueCode.invalid_type,
|
|
2340
2341
|
expected: ZodParsedType.never,
|
|
@@ -2350,10 +2351,10 @@ ZodNever.create = (params) => {
|
|
|
2350
2351
|
});
|
|
2351
2352
|
};
|
|
2352
2353
|
var ZodVoid = class extends ZodType {
|
|
2353
|
-
_parse(
|
|
2354
|
-
const parsedType = this._getType(
|
|
2354
|
+
_parse(input2) {
|
|
2355
|
+
const parsedType = this._getType(input2);
|
|
2355
2356
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2356
|
-
const ctx = this._getOrReturnCtx(
|
|
2357
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2357
2358
|
addIssueToContext(ctx, {
|
|
2358
2359
|
code: ZodIssueCode.invalid_type,
|
|
2359
2360
|
expected: ZodParsedType.void,
|
|
@@ -2361,7 +2362,7 @@ var ZodVoid = class extends ZodType {
|
|
|
2361
2362
|
});
|
|
2362
2363
|
return INVALID;
|
|
2363
2364
|
}
|
|
2364
|
-
return OK(
|
|
2365
|
+
return OK(input2.data);
|
|
2365
2366
|
}
|
|
2366
2367
|
};
|
|
2367
2368
|
ZodVoid.create = (params) => {
|
|
@@ -2371,8 +2372,8 @@ ZodVoid.create = (params) => {
|
|
|
2371
2372
|
});
|
|
2372
2373
|
};
|
|
2373
2374
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2374
|
-
_parse(
|
|
2375
|
-
const { ctx, status } = this._processInputParams(
|
|
2375
|
+
_parse(input2) {
|
|
2376
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
2376
2377
|
const def = this._def;
|
|
2377
2378
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
2378
2379
|
addIssueToContext(ctx, {
|
|
@@ -2512,10 +2513,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2512
2513
|
this._cached = { shape, keys };
|
|
2513
2514
|
return this._cached;
|
|
2514
2515
|
}
|
|
2515
|
-
_parse(
|
|
2516
|
-
const parsedType = this._getType(
|
|
2516
|
+
_parse(input2) {
|
|
2517
|
+
const parsedType = this._getType(input2);
|
|
2517
2518
|
if (parsedType !== ZodParsedType.object) {
|
|
2518
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2519
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2519
2520
|
addIssueToContext(ctx2, {
|
|
2520
2521
|
code: ZodIssueCode.invalid_type,
|
|
2521
2522
|
expected: ZodParsedType.object,
|
|
@@ -2523,7 +2524,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2523
2524
|
});
|
|
2524
2525
|
return INVALID;
|
|
2525
2526
|
}
|
|
2526
|
-
const { status, ctx } = this._processInputParams(
|
|
2527
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2527
2528
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2528
2529
|
const extraKeys = [];
|
|
2529
2530
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -2836,8 +2837,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
2836
2837
|
});
|
|
2837
2838
|
};
|
|
2838
2839
|
var ZodUnion = class extends ZodType {
|
|
2839
|
-
_parse(
|
|
2840
|
-
const { ctx } = this._processInputParams(
|
|
2840
|
+
_parse(input2) {
|
|
2841
|
+
const { ctx } = this._processInputParams(input2);
|
|
2841
2842
|
const options = this._def.options;
|
|
2842
2843
|
function handleResults(results) {
|
|
2843
2844
|
for (const result of results) {
|
|
@@ -2958,8 +2959,8 @@ var getDiscriminator = (type2) => {
|
|
|
2958
2959
|
}
|
|
2959
2960
|
};
|
|
2960
2961
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
2961
|
-
_parse(
|
|
2962
|
-
const { ctx } = this._processInputParams(
|
|
2962
|
+
_parse(input2) {
|
|
2963
|
+
const { ctx } = this._processInputParams(input2);
|
|
2963
2964
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2964
2965
|
addIssueToContext(ctx, {
|
|
2965
2966
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3072,8 +3073,8 @@ function mergeValues(a, b) {
|
|
|
3072
3073
|
}
|
|
3073
3074
|
}
|
|
3074
3075
|
var ZodIntersection = class extends ZodType {
|
|
3075
|
-
_parse(
|
|
3076
|
-
const { status, ctx } = this._processInputParams(
|
|
3076
|
+
_parse(input2) {
|
|
3077
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3077
3078
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
3078
3079
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
3079
3080
|
return INVALID;
|
|
@@ -3125,8 +3126,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
3125
3126
|
});
|
|
3126
3127
|
};
|
|
3127
3128
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3128
|
-
_parse(
|
|
3129
|
-
const { status, ctx } = this._processInputParams(
|
|
3129
|
+
_parse(input2) {
|
|
3130
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3130
3131
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
3131
3132
|
addIssueToContext(ctx, {
|
|
3132
3133
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3198,8 +3199,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3198
3199
|
get valueSchema() {
|
|
3199
3200
|
return this._def.valueType;
|
|
3200
3201
|
}
|
|
3201
|
-
_parse(
|
|
3202
|
-
const { status, ctx } = this._processInputParams(
|
|
3202
|
+
_parse(input2) {
|
|
3203
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3203
3204
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3204
3205
|
addIssueToContext(ctx, {
|
|
3205
3206
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3251,8 +3252,8 @@ var ZodMap = class extends ZodType {
|
|
|
3251
3252
|
get valueSchema() {
|
|
3252
3253
|
return this._def.valueType;
|
|
3253
3254
|
}
|
|
3254
|
-
_parse(
|
|
3255
|
-
const { status, ctx } = this._processInputParams(
|
|
3255
|
+
_parse(input2) {
|
|
3256
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3256
3257
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
3257
3258
|
addIssueToContext(ctx, {
|
|
3258
3259
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3311,8 +3312,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
3311
3312
|
});
|
|
3312
3313
|
};
|
|
3313
3314
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3314
|
-
_parse(
|
|
3315
|
-
const { status, ctx } = this._processInputParams(
|
|
3315
|
+
_parse(input2) {
|
|
3316
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3316
3317
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
3317
3318
|
addIssueToContext(ctx, {
|
|
3318
3319
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3400,8 +3401,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3400
3401
|
super(...arguments);
|
|
3401
3402
|
this.validate = this.implement;
|
|
3402
3403
|
}
|
|
3403
|
-
_parse(
|
|
3404
|
-
const { ctx } = this._processInputParams(
|
|
3404
|
+
_parse(input2) {
|
|
3405
|
+
const { ctx } = this._processInputParams(input2);
|
|
3405
3406
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3406
3407
|
addIssueToContext(ctx, {
|
|
3407
3408
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3504,8 +3505,8 @@ var ZodLazy = class extends ZodType {
|
|
|
3504
3505
|
get schema() {
|
|
3505
3506
|
return this._def.getter();
|
|
3506
3507
|
}
|
|
3507
|
-
_parse(
|
|
3508
|
-
const { ctx } = this._processInputParams(
|
|
3508
|
+
_parse(input2) {
|
|
3509
|
+
const { ctx } = this._processInputParams(input2);
|
|
3509
3510
|
const lazySchema = this._def.getter();
|
|
3510
3511
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3511
3512
|
}
|
|
@@ -3518,9 +3519,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
3518
3519
|
});
|
|
3519
3520
|
};
|
|
3520
3521
|
var ZodLiteral = class extends ZodType {
|
|
3521
|
-
_parse(
|
|
3522
|
-
if (
|
|
3523
|
-
const ctx = this._getOrReturnCtx(
|
|
3522
|
+
_parse(input2) {
|
|
3523
|
+
if (input2.data !== this._def.value) {
|
|
3524
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3524
3525
|
addIssueToContext(ctx, {
|
|
3525
3526
|
received: ctx.data,
|
|
3526
3527
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -3528,7 +3529,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
3528
3529
|
});
|
|
3529
3530
|
return INVALID;
|
|
3530
3531
|
}
|
|
3531
|
-
return { status: "valid", value:
|
|
3532
|
+
return { status: "valid", value: input2.data };
|
|
3532
3533
|
}
|
|
3533
3534
|
get value() {
|
|
3534
3535
|
return this._def.value;
|
|
@@ -3549,9 +3550,9 @@ function createZodEnum(values, params) {
|
|
|
3549
3550
|
});
|
|
3550
3551
|
}
|
|
3551
3552
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3552
|
-
_parse(
|
|
3553
|
-
if (typeof
|
|
3554
|
-
const ctx = this._getOrReturnCtx(
|
|
3553
|
+
_parse(input2) {
|
|
3554
|
+
if (typeof input2.data !== "string") {
|
|
3555
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3555
3556
|
const expectedValues = this._def.values;
|
|
3556
3557
|
addIssueToContext(ctx, {
|
|
3557
3558
|
expected: util.joinValues(expectedValues),
|
|
@@ -3563,8 +3564,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3563
3564
|
if (!this._cache) {
|
|
3564
3565
|
this._cache = new Set(this._def.values);
|
|
3565
3566
|
}
|
|
3566
|
-
if (!this._cache.has(
|
|
3567
|
-
const ctx = this._getOrReturnCtx(
|
|
3567
|
+
if (!this._cache.has(input2.data)) {
|
|
3568
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3568
3569
|
const expectedValues = this._def.values;
|
|
3569
3570
|
addIssueToContext(ctx, {
|
|
3570
3571
|
received: ctx.data,
|
|
@@ -3573,7 +3574,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3573
3574
|
});
|
|
3574
3575
|
return INVALID;
|
|
3575
3576
|
}
|
|
3576
|
-
return OK(
|
|
3577
|
+
return OK(input2.data);
|
|
3577
3578
|
}
|
|
3578
3579
|
get options() {
|
|
3579
3580
|
return this._def.values;
|
|
@@ -3614,9 +3615,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3614
3615
|
};
|
|
3615
3616
|
ZodEnum.create = createZodEnum;
|
|
3616
3617
|
var ZodNativeEnum = class extends ZodType {
|
|
3617
|
-
_parse(
|
|
3618
|
+
_parse(input2) {
|
|
3618
3619
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3619
|
-
const ctx = this._getOrReturnCtx(
|
|
3620
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3620
3621
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
3621
3622
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3622
3623
|
addIssueToContext(ctx, {
|
|
@@ -3629,7 +3630,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3629
3630
|
if (!this._cache) {
|
|
3630
3631
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3631
3632
|
}
|
|
3632
|
-
if (!this._cache.has(
|
|
3633
|
+
if (!this._cache.has(input2.data)) {
|
|
3633
3634
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3634
3635
|
addIssueToContext(ctx, {
|
|
3635
3636
|
received: ctx.data,
|
|
@@ -3638,7 +3639,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3638
3639
|
});
|
|
3639
3640
|
return INVALID;
|
|
3640
3641
|
}
|
|
3641
|
-
return OK(
|
|
3642
|
+
return OK(input2.data);
|
|
3642
3643
|
}
|
|
3643
3644
|
get enum() {
|
|
3644
3645
|
return this._def.values;
|
|
@@ -3655,8 +3656,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3655
3656
|
unwrap() {
|
|
3656
3657
|
return this._def.type;
|
|
3657
3658
|
}
|
|
3658
|
-
_parse(
|
|
3659
|
-
const { ctx } = this._processInputParams(
|
|
3659
|
+
_parse(input2) {
|
|
3660
|
+
const { ctx } = this._processInputParams(input2);
|
|
3660
3661
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
3661
3662
|
addIssueToContext(ctx, {
|
|
3662
3663
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3688,8 +3689,8 @@ var ZodEffects = class extends ZodType {
|
|
|
3688
3689
|
sourceType() {
|
|
3689
3690
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3690
3691
|
}
|
|
3691
|
-
_parse(
|
|
3692
|
-
const { status, ctx } = this._processInputParams(
|
|
3692
|
+
_parse(input2) {
|
|
3693
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3693
3694
|
const effect = this._def.effect || null;
|
|
3694
3695
|
const checkCtx = {
|
|
3695
3696
|
addIssue: (arg) => {
|
|
@@ -3821,12 +3822,12 @@ ZodEffects.createWithPreprocess = (preprocess2, schema2, params) => {
|
|
|
3821
3822
|
});
|
|
3822
3823
|
};
|
|
3823
3824
|
var ZodOptional = class extends ZodType {
|
|
3824
|
-
_parse(
|
|
3825
|
-
const parsedType = this._getType(
|
|
3825
|
+
_parse(input2) {
|
|
3826
|
+
const parsedType = this._getType(input2);
|
|
3826
3827
|
if (parsedType === ZodParsedType.undefined) {
|
|
3827
3828
|
return OK(void 0);
|
|
3828
3829
|
}
|
|
3829
|
-
return this._def.innerType._parse(
|
|
3830
|
+
return this._def.innerType._parse(input2);
|
|
3830
3831
|
}
|
|
3831
3832
|
unwrap() {
|
|
3832
3833
|
return this._def.innerType;
|
|
@@ -3840,12 +3841,12 @@ ZodOptional.create = (type2, params) => {
|
|
|
3840
3841
|
});
|
|
3841
3842
|
};
|
|
3842
3843
|
var ZodNullable = class extends ZodType {
|
|
3843
|
-
_parse(
|
|
3844
|
-
const parsedType = this._getType(
|
|
3844
|
+
_parse(input2) {
|
|
3845
|
+
const parsedType = this._getType(input2);
|
|
3845
3846
|
if (parsedType === ZodParsedType.null) {
|
|
3846
3847
|
return OK(null);
|
|
3847
3848
|
}
|
|
3848
|
-
return this._def.innerType._parse(
|
|
3849
|
+
return this._def.innerType._parse(input2);
|
|
3849
3850
|
}
|
|
3850
3851
|
unwrap() {
|
|
3851
3852
|
return this._def.innerType;
|
|
@@ -3859,8 +3860,8 @@ ZodNullable.create = (type2, params) => {
|
|
|
3859
3860
|
});
|
|
3860
3861
|
};
|
|
3861
3862
|
var ZodDefault = class extends ZodType {
|
|
3862
|
-
_parse(
|
|
3863
|
-
const { ctx } = this._processInputParams(
|
|
3863
|
+
_parse(input2) {
|
|
3864
|
+
const { ctx } = this._processInputParams(input2);
|
|
3864
3865
|
let data = ctx.data;
|
|
3865
3866
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
3866
3867
|
data = this._def.defaultValue();
|
|
@@ -3884,8 +3885,8 @@ ZodDefault.create = (type2, params) => {
|
|
|
3884
3885
|
});
|
|
3885
3886
|
};
|
|
3886
3887
|
var ZodCatch = class extends ZodType {
|
|
3887
|
-
_parse(
|
|
3888
|
-
const { ctx } = this._processInputParams(
|
|
3888
|
+
_parse(input2) {
|
|
3889
|
+
const { ctx } = this._processInputParams(input2);
|
|
3889
3890
|
const newCtx = {
|
|
3890
3891
|
...ctx,
|
|
3891
3892
|
common: {
|
|
@@ -3937,10 +3938,10 @@ ZodCatch.create = (type2, params) => {
|
|
|
3937
3938
|
});
|
|
3938
3939
|
};
|
|
3939
3940
|
var ZodNaN = class extends ZodType {
|
|
3940
|
-
_parse(
|
|
3941
|
-
const parsedType = this._getType(
|
|
3941
|
+
_parse(input2) {
|
|
3942
|
+
const parsedType = this._getType(input2);
|
|
3942
3943
|
if (parsedType !== ZodParsedType.nan) {
|
|
3943
|
-
const ctx = this._getOrReturnCtx(
|
|
3944
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3944
3945
|
addIssueToContext(ctx, {
|
|
3945
3946
|
code: ZodIssueCode.invalid_type,
|
|
3946
3947
|
expected: ZodParsedType.nan,
|
|
@@ -3948,7 +3949,7 @@ var ZodNaN = class extends ZodType {
|
|
|
3948
3949
|
});
|
|
3949
3950
|
return INVALID;
|
|
3950
3951
|
}
|
|
3951
|
-
return { status: "valid", value:
|
|
3952
|
+
return { status: "valid", value: input2.data };
|
|
3952
3953
|
}
|
|
3953
3954
|
};
|
|
3954
3955
|
ZodNaN.create = (params) => {
|
|
@@ -3959,8 +3960,8 @@ ZodNaN.create = (params) => {
|
|
|
3959
3960
|
};
|
|
3960
3961
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3961
3962
|
var ZodBranded = class extends ZodType {
|
|
3962
|
-
_parse(
|
|
3963
|
-
const { ctx } = this._processInputParams(
|
|
3963
|
+
_parse(input2) {
|
|
3964
|
+
const { ctx } = this._processInputParams(input2);
|
|
3964
3965
|
const data = ctx.data;
|
|
3965
3966
|
return this._def.type._parse({
|
|
3966
3967
|
data,
|
|
@@ -3973,8 +3974,8 @@ var ZodBranded = class extends ZodType {
|
|
|
3973
3974
|
}
|
|
3974
3975
|
};
|
|
3975
3976
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
3976
|
-
_parse(
|
|
3977
|
-
const { status, ctx } = this._processInputParams(
|
|
3977
|
+
_parse(input2) {
|
|
3978
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3978
3979
|
if (ctx.common.async) {
|
|
3979
3980
|
const handleAsync = async () => {
|
|
3980
3981
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -4028,8 +4029,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
4028
4029
|
}
|
|
4029
4030
|
};
|
|
4030
4031
|
var ZodReadonly = class extends ZodType {
|
|
4031
|
-
_parse(
|
|
4032
|
-
const result = this._def.innerType._parse(
|
|
4032
|
+
_parse(input2) {
|
|
4033
|
+
const result = this._def.innerType._parse(input2);
|
|
4033
4034
|
const freeze = (data) => {
|
|
4034
4035
|
if (isValid(data)) {
|
|
4035
4036
|
data.value = Object.freeze(data.value);
|
|
@@ -4545,10 +4546,10 @@ var VFile = class {
|
|
|
4545
4546
|
* @returns {undefined}
|
|
4546
4547
|
* Nothing.
|
|
4547
4548
|
*/
|
|
4548
|
-
set basename(
|
|
4549
|
-
assertNonEmpty(
|
|
4550
|
-
assertPart(
|
|
4551
|
-
this.path = default2.join(this.dirname || "",
|
|
4549
|
+
set basename(basename3) {
|
|
4550
|
+
assertNonEmpty(basename3, "basename");
|
|
4551
|
+
assertPart(basename3, "basename");
|
|
4552
|
+
this.path = default2.join(this.dirname || "", basename3);
|
|
4552
4553
|
}
|
|
4553
4554
|
/**
|
|
4554
4555
|
* Get the parent path (example: `'~'`).
|
|
@@ -4569,9 +4570,9 @@ var VFile = class {
|
|
|
4569
4570
|
* @returns {undefined}
|
|
4570
4571
|
* Nothing.
|
|
4571
4572
|
*/
|
|
4572
|
-
set dirname(
|
|
4573
|
+
set dirname(dirname4) {
|
|
4573
4574
|
assertPath(this.basename, "dirname");
|
|
4574
|
-
this.path = default2.join(
|
|
4575
|
+
this.path = default2.join(dirname4 || "", this.basename);
|
|
4575
4576
|
}
|
|
4576
4577
|
/**
|
|
4577
4578
|
* Get the extname (including dot) (example: `'.js'`).
|
|
@@ -5170,7 +5171,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
5170
5171
|
assertParser("process", this.parser || this.Parser);
|
|
5171
5172
|
assertCompiler("process", this.compiler || this.Compiler);
|
|
5172
5173
|
return done ? executor(void 0, done) : new Promise(executor);
|
|
5173
|
-
function executor(
|
|
5174
|
+
function executor(resolve15, reject) {
|
|
5174
5175
|
const realFile = vfile(file);
|
|
5175
5176
|
const parseTree = (
|
|
5176
5177
|
/** @type {HeadTree extends undefined ? Node : HeadTree} */
|
|
@@ -5201,8 +5202,8 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
5201
5202
|
function realDone(error, file2) {
|
|
5202
5203
|
if (error || !file2) {
|
|
5203
5204
|
reject(error);
|
|
5204
|
-
} else if (
|
|
5205
|
-
|
|
5205
|
+
} else if (resolve15) {
|
|
5206
|
+
resolve15(file2);
|
|
5206
5207
|
} else {
|
|
5207
5208
|
ok(done, "`done` is defined if `resolve` is not");
|
|
5208
5209
|
done(void 0, file2);
|
|
@@ -5304,7 +5305,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
5304
5305
|
file = void 0;
|
|
5305
5306
|
}
|
|
5306
5307
|
return done ? executor(void 0, done) : new Promise(executor);
|
|
5307
|
-
function executor(
|
|
5308
|
+
function executor(resolve15, reject) {
|
|
5308
5309
|
ok(
|
|
5309
5310
|
typeof file !== "function",
|
|
5310
5311
|
"`file` can\u2019t be a `done` anymore, we checked"
|
|
@@ -5318,8 +5319,8 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
5318
5319
|
);
|
|
5319
5320
|
if (error) {
|
|
5320
5321
|
reject(error);
|
|
5321
|
-
} else if (
|
|
5322
|
-
|
|
5322
|
+
} else if (resolve15) {
|
|
5323
|
+
resolve15(resultingTree);
|
|
5323
5324
|
} else {
|
|
5324
5325
|
ok(done, "`done` is defined if `resolve` is not");
|
|
5325
5326
|
done(void 0, resultingTree, file2);
|
|
@@ -8147,10 +8148,10 @@ function resolveAll(constructs2, events, context) {
|
|
|
8147
8148
|
const called = [];
|
|
8148
8149
|
let index2 = -1;
|
|
8149
8150
|
while (++index2 < constructs2.length) {
|
|
8150
|
-
const
|
|
8151
|
-
if (
|
|
8152
|
-
events =
|
|
8153
|
-
called.push(
|
|
8151
|
+
const resolve15 = constructs2[index2].resolveAll;
|
|
8152
|
+
if (resolve15 && !called.includes(resolve15)) {
|
|
8153
|
+
events = resolve15(events, context);
|
|
8154
|
+
called.push(resolve15);
|
|
8154
8155
|
}
|
|
8155
8156
|
}
|
|
8156
8157
|
return events;
|
|
@@ -13148,14 +13149,14 @@ function resolveYamlBinary(data) {
|
|
|
13148
13149
|
return bitlen % 8 === 0;
|
|
13149
13150
|
}
|
|
13150
13151
|
function constructYamlBinary(data) {
|
|
13151
|
-
var idx, tailbits,
|
|
13152
|
+
var idx, tailbits, input2 = data.replace(/[\r\n=]/g, ""), max = input2.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
13152
13153
|
for (idx = 0; idx < max; idx++) {
|
|
13153
13154
|
if (idx % 4 === 0 && idx) {
|
|
13154
13155
|
result.push(bits >> 16 & 255);
|
|
13155
13156
|
result.push(bits >> 8 & 255);
|
|
13156
13157
|
result.push(bits & 255);
|
|
13157
13158
|
}
|
|
13158
|
-
bits = bits << 6 | map2.indexOf(
|
|
13159
|
+
bits = bits << 6 | map2.indexOf(input2.charAt(idx));
|
|
13159
13160
|
}
|
|
13160
13161
|
tailbits = max % 4 * 6;
|
|
13161
13162
|
if (tailbits === 0) {
|
|
@@ -13388,8 +13389,8 @@ for (i = 0; i < 256; i++) {
|
|
|
13388
13389
|
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
13389
13390
|
}
|
|
13390
13391
|
var i;
|
|
13391
|
-
function State$1(
|
|
13392
|
-
this.input =
|
|
13392
|
+
function State$1(input2, options) {
|
|
13393
|
+
this.input = input2;
|
|
13393
13394
|
this.filename = options["filename"] || null;
|
|
13394
13395
|
this.schema = options["schema"] || _default;
|
|
13395
13396
|
this.onWarning = options["onWarning"] || null;
|
|
@@ -13398,7 +13399,7 @@ function State$1(input, options) {
|
|
|
13398
13399
|
this.listener = options["listener"] || null;
|
|
13399
13400
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
13400
13401
|
this.typeMap = this.schema.compiledTypeMap;
|
|
13401
|
-
this.length =
|
|
13402
|
+
this.length = input2.length;
|
|
13402
13403
|
this.position = 0;
|
|
13403
13404
|
this.line = 0;
|
|
13404
13405
|
this.lineStart = 0;
|
|
@@ -14402,19 +14403,19 @@ function readDocument(state) {
|
|
|
14402
14403
|
return;
|
|
14403
14404
|
}
|
|
14404
14405
|
}
|
|
14405
|
-
function loadDocuments(
|
|
14406
|
-
|
|
14406
|
+
function loadDocuments(input2, options) {
|
|
14407
|
+
input2 = String(input2);
|
|
14407
14408
|
options = options || {};
|
|
14408
|
-
if (
|
|
14409
|
-
if (
|
|
14410
|
-
|
|
14409
|
+
if (input2.length !== 0) {
|
|
14410
|
+
if (input2.charCodeAt(input2.length - 1) !== 10 && input2.charCodeAt(input2.length - 1) !== 13) {
|
|
14411
|
+
input2 += "\n";
|
|
14411
14412
|
}
|
|
14412
|
-
if (
|
|
14413
|
-
|
|
14413
|
+
if (input2.charCodeAt(0) === 65279) {
|
|
14414
|
+
input2 = input2.slice(1);
|
|
14414
14415
|
}
|
|
14415
14416
|
}
|
|
14416
|
-
var state = new State$1(
|
|
14417
|
-
var nullpos =
|
|
14417
|
+
var state = new State$1(input2, options);
|
|
14418
|
+
var nullpos = input2.indexOf("\0");
|
|
14418
14419
|
if (nullpos !== -1) {
|
|
14419
14420
|
state.position = nullpos;
|
|
14420
14421
|
throwError(state, "null byte is not allowed in input");
|
|
@@ -14429,12 +14430,12 @@ function loadDocuments(input, options) {
|
|
|
14429
14430
|
}
|
|
14430
14431
|
return state.documents;
|
|
14431
14432
|
}
|
|
14432
|
-
function loadAll$1(
|
|
14433
|
+
function loadAll$1(input2, iterator, options) {
|
|
14433
14434
|
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
14434
14435
|
options = iterator;
|
|
14435
14436
|
iterator = null;
|
|
14436
14437
|
}
|
|
14437
|
-
var documents = loadDocuments(
|
|
14438
|
+
var documents = loadDocuments(input2, options);
|
|
14438
14439
|
if (typeof iterator !== "function") {
|
|
14439
14440
|
return documents;
|
|
14440
14441
|
}
|
|
@@ -14442,8 +14443,8 @@ function loadAll$1(input, iterator, options) {
|
|
|
14442
14443
|
iterator(documents[index2]);
|
|
14443
14444
|
}
|
|
14444
14445
|
}
|
|
14445
|
-
function load$1(
|
|
14446
|
-
var documents = loadDocuments(
|
|
14446
|
+
function load$1(input2, options) {
|
|
14447
|
+
var documents = loadDocuments(input2, options);
|
|
14447
14448
|
if (documents.length === 0) {
|
|
14448
14449
|
return void 0;
|
|
14449
14450
|
} else if (documents.length === 1) {
|
|
@@ -15064,11 +15065,11 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
|
|
15064
15065
|
}
|
|
15065
15066
|
}
|
|
15066
15067
|
}
|
|
15067
|
-
function dump$1(
|
|
15068
|
+
function dump$1(input2, options) {
|
|
15068
15069
|
options = options || {};
|
|
15069
15070
|
var state = new State(options);
|
|
15070
|
-
if (!state.noRefs) getDuplicateReferences(
|
|
15071
|
-
var value =
|
|
15071
|
+
if (!state.noRefs) getDuplicateReferences(input2, state);
|
|
15072
|
+
var value = input2;
|
|
15072
15073
|
if (state.replacer) {
|
|
15073
15074
|
value = state.replacer.call({ "": value }, "", value);
|
|
15074
15075
|
}
|
|
@@ -15727,8 +15728,8 @@ var VERSION = "0.1.0";
|
|
|
15727
15728
|
|
|
15728
15729
|
// src/commands/analyze.ts
|
|
15729
15730
|
import { Command } from "commander";
|
|
15730
|
-
import { readFileSync as
|
|
15731
|
-
import { resolve as
|
|
15731
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync2 } from "fs";
|
|
15732
|
+
import { resolve as resolve3 } from "path";
|
|
15732
15733
|
import chalk2 from "chalk";
|
|
15733
15734
|
import Table from "cli-table3";
|
|
15734
15735
|
|
|
@@ -15904,18 +15905,46 @@ async function syncVelocity(data) {
|
|
|
15904
15905
|
}
|
|
15905
15906
|
}
|
|
15906
15907
|
|
|
15908
|
+
// src/project-config.ts
|
|
15909
|
+
import { readFileSync as readFileSync2, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
15910
|
+
import { resolve as resolve2, dirname } from "path";
|
|
15911
|
+
var CONFIG_PATH = resolve2(process.cwd(), ".claude", "te", "config.json");
|
|
15912
|
+
function readProjectConfig() {
|
|
15913
|
+
if (!existsSync(CONFIG_PATH)) return null;
|
|
15914
|
+
try {
|
|
15915
|
+
return JSON.parse(readFileSync2(CONFIG_PATH, "utf-8"));
|
|
15916
|
+
} catch {
|
|
15917
|
+
return null;
|
|
15918
|
+
}
|
|
15919
|
+
}
|
|
15920
|
+
function updateProjectConfig(updates) {
|
|
15921
|
+
const existing = readProjectConfig() ?? {
|
|
15922
|
+
project: "unnamed",
|
|
15923
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
15924
|
+
};
|
|
15925
|
+
const merged = { ...existing, ...updates };
|
|
15926
|
+
mkdirSync(dirname(CONFIG_PATH), { recursive: true });
|
|
15927
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(merged, null, 2) + "\n");
|
|
15928
|
+
}
|
|
15929
|
+
function getProjectName() {
|
|
15930
|
+
return readProjectConfig()?.project ?? "unnamed";
|
|
15931
|
+
}
|
|
15932
|
+
function getIntakeDir() {
|
|
15933
|
+
return readProjectConfig()?.intakeDir ?? "intake-specs";
|
|
15934
|
+
}
|
|
15935
|
+
|
|
15907
15936
|
// src/commands/analyze.ts
|
|
15908
15937
|
var analyzeCommand = new Command("analyze").description("Analyze a spec and generate estimate report + project scaffolding").argument("<spec>", "Path to the spec markdown file").option("-p, --project <name>", "Project name").option("-o, --output <dir>", "Output directory for reports", ".").option("--json", "Output report as JSON").action(async (specPath, options) => {
|
|
15909
|
-
const fullPath =
|
|
15910
|
-
if (!
|
|
15938
|
+
const fullPath = resolve3(specPath);
|
|
15939
|
+
if (!existsSync2(fullPath)) {
|
|
15911
15940
|
console.error(chalk2.red(`Spec file not found: ${fullPath}`));
|
|
15912
15941
|
process.exit(1);
|
|
15913
15942
|
}
|
|
15914
|
-
const content3 =
|
|
15943
|
+
const content3 = readFileSync3(fullPath, "utf-8");
|
|
15915
15944
|
const data = loadData();
|
|
15916
15945
|
console.log(chalk2.dim("Parsing spec..."));
|
|
15917
15946
|
const spec = parseSpec(content3);
|
|
15918
|
-
const projectName = options.project ?? spec.metadata.project ??
|
|
15947
|
+
const projectName = options.project ?? spec.metadata.project ?? getProjectName();
|
|
15919
15948
|
if (spec.features.length === 0) {
|
|
15920
15949
|
console.error(chalk2.red("No features found in spec. Use ### Feature: <name> headings."));
|
|
15921
15950
|
process.exit(1);
|
|
@@ -15931,13 +15960,13 @@ var analyzeCommand = new Command("analyze").description("Analyze a spec and gene
|
|
|
15931
15960
|
displayReport(report);
|
|
15932
15961
|
}
|
|
15933
15962
|
const registry = generateRegistry(projectName, spec.features, estimates);
|
|
15934
|
-
const outDir =
|
|
15935
|
-
const reportPath =
|
|
15936
|
-
|
|
15963
|
+
const outDir = resolve3(options.output);
|
|
15964
|
+
const reportPath = resolve3(outDir, `fathom-estimate-${projectName}.json`);
|
|
15965
|
+
writeFileSync2(reportPath, JSON.stringify(report, null, 2));
|
|
15937
15966
|
console.log(chalk2.dim(`
|
|
15938
15967
|
Report saved: ${reportPath}`));
|
|
15939
|
-
const registryPath =
|
|
15940
|
-
|
|
15968
|
+
const registryPath = resolve3(outDir, `fathom-registry-${projectName}.json`);
|
|
15969
|
+
writeFileSync2(registryPath, JSON.stringify(registry, null, 2));
|
|
15941
15970
|
console.log(chalk2.dim(`Registry saved: ${registryPath}`));
|
|
15942
15971
|
if (options.project) {
|
|
15943
15972
|
scaffoldProject(projectName, registry, outDir);
|
|
@@ -16004,12 +16033,12 @@ Total: ${report.totals.tokens.toLocaleString()} tokens \u2014 $${report.totals.c
|
|
|
16004
16033
|
}
|
|
16005
16034
|
}
|
|
16006
16035
|
function scaffoldProject(projectName, registry, baseDir) {
|
|
16007
|
-
const teDir =
|
|
16008
|
-
|
|
16009
|
-
const registryPath =
|
|
16010
|
-
|
|
16011
|
-
const configPath =
|
|
16012
|
-
|
|
16036
|
+
const teDir = resolve3(baseDir, ".claude", "te");
|
|
16037
|
+
mkdirSync2(teDir, { recursive: true });
|
|
16038
|
+
const registryPath = resolve3(teDir, "registry.json");
|
|
16039
|
+
writeFileSync2(registryPath, JSON.stringify(registry, null, 2));
|
|
16040
|
+
const configPath = resolve3(teDir, "config.json");
|
|
16041
|
+
writeFileSync2(
|
|
16013
16042
|
configPath,
|
|
16014
16043
|
JSON.stringify({ project: projectName, createdAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)
|
|
16015
16044
|
);
|
|
@@ -16081,13 +16110,13 @@ var pricingCommand = new Command2("pricing").description("Show current model pri
|
|
|
16081
16110
|
|
|
16082
16111
|
// src/commands/status.ts
|
|
16083
16112
|
import { Command as Command3 } from "commander";
|
|
16084
|
-
import { readFileSync as
|
|
16085
|
-
import { resolve as
|
|
16113
|
+
import { readFileSync as readFileSync4, existsSync as existsSync3 } from "fs";
|
|
16114
|
+
import { resolve as resolve4 } from "path";
|
|
16086
16115
|
import chalk4 from "chalk";
|
|
16087
16116
|
import Table3 from "cli-table3";
|
|
16088
16117
|
var statusCommand = new Command3("status").description("Show project status from registry + tracking data").option("-p, --project <name>", "Project name").option("--registry <path>", "Path to registry.json").action((options) => {
|
|
16089
|
-
const registryPath = options.registry ??
|
|
16090
|
-
if (!
|
|
16118
|
+
const registryPath = options.registry ?? resolve4(process.cwd(), ".claude", "te", "registry.json");
|
|
16119
|
+
if (!existsSync3(registryPath)) {
|
|
16091
16120
|
console.log(
|
|
16092
16121
|
chalk4.yellow(
|
|
16093
16122
|
"No registry found. Run `fathom analyze <spec> --project <name>` first."
|
|
@@ -16095,19 +16124,19 @@ var statusCommand = new Command3("status").description("Show project status from
|
|
|
16095
16124
|
);
|
|
16096
16125
|
return;
|
|
16097
16126
|
}
|
|
16098
|
-
const registry = JSON.parse(
|
|
16099
|
-
const projectName = options.project ?? registry.project ??
|
|
16100
|
-
const summaryPath =
|
|
16127
|
+
const registry = JSON.parse(readFileSync4(registryPath, "utf-8"));
|
|
16128
|
+
const projectName = options.project ?? registry.project ?? getProjectName();
|
|
16129
|
+
const summaryPath = resolve4(
|
|
16101
16130
|
process.cwd(),
|
|
16102
16131
|
".claude",
|
|
16103
16132
|
"te",
|
|
16104
16133
|
"tracking",
|
|
16105
16134
|
"summary.json"
|
|
16106
16135
|
);
|
|
16107
|
-
const hasTracking =
|
|
16136
|
+
const hasTracking = existsSync3(summaryPath);
|
|
16108
16137
|
const actuals = /* @__PURE__ */ new Map();
|
|
16109
16138
|
if (hasTracking) {
|
|
16110
|
-
const summary = JSON.parse(
|
|
16139
|
+
const summary = JSON.parse(readFileSync4(summaryPath, "utf-8"));
|
|
16111
16140
|
for (const s of summary.sessions) {
|
|
16112
16141
|
if (!s.featureId || s.status === "untagged") continue;
|
|
16113
16142
|
const existing = actuals.get(s.featureId) ?? { tokens: 0, sessions: 0 };
|
|
@@ -16170,13 +16199,13 @@ Total estimated: ${totalEstimated.toLocaleString()} tokens`));
|
|
|
16170
16199
|
|
|
16171
16200
|
// src/commands/track.ts
|
|
16172
16201
|
import { Command as Command4 } from "commander";
|
|
16173
|
-
import { readFileSync as
|
|
16174
|
-
import { resolve as
|
|
16202
|
+
import { readFileSync as readFileSync6, existsSync as existsSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
16203
|
+
import { resolve as resolve5 } from "path";
|
|
16175
16204
|
import chalk5 from "chalk";
|
|
16176
16205
|
import Table4 from "cli-table3";
|
|
16177
16206
|
|
|
16178
16207
|
// ../tracker/dist/index.js
|
|
16179
|
-
import { readFileSync as
|
|
16208
|
+
import { readFileSync as readFileSync5, readdirSync, existsSync as existsSync4 } from "fs";
|
|
16180
16209
|
import { join, basename } from "path";
|
|
16181
16210
|
import { homedir } from "os";
|
|
16182
16211
|
var SessionMessage = external_exports.object({
|
|
@@ -16230,7 +16259,7 @@ var Registry = external_exports.object({
|
|
|
16230
16259
|
generatedAt: external_exports.string()
|
|
16231
16260
|
});
|
|
16232
16261
|
function parseSessionFile(filePath) {
|
|
16233
|
-
const content3 =
|
|
16262
|
+
const content3 = readFileSync5(filePath, "utf-8");
|
|
16234
16263
|
const lines = content3.trim().split("\n").filter(Boolean);
|
|
16235
16264
|
if (lines.length === 0) return null;
|
|
16236
16265
|
let inputTokens = 0;
|
|
@@ -16312,7 +16341,7 @@ function parseSessionFile(filePath) {
|
|
|
16312
16341
|
}
|
|
16313
16342
|
function findSessionFiles(projectPath) {
|
|
16314
16343
|
const baseDir = projectPath ?? join(homedir(), ".claude", "projects");
|
|
16315
|
-
if (!
|
|
16344
|
+
if (!existsSync4(baseDir)) return [];
|
|
16316
16345
|
const files = [];
|
|
16317
16346
|
function walk(dir) {
|
|
16318
16347
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
@@ -16427,8 +16456,8 @@ function matchGlob(text3, pattern) {
|
|
|
16427
16456
|
// src/commands/track.ts
|
|
16428
16457
|
var trackCommand = new Command4("track").description("Import Claude Code sessions and auto-tag to features").option("-p, --project <name>", "Project name").option("--registry <path>", "Path to registry.json").option("--sessions-dir <path>", "Path to sessions directory").option("--backfill", "Process all existing sessions (not just new)").action(
|
|
16429
16458
|
async (options) => {
|
|
16430
|
-
const registryPath = options.registry ??
|
|
16431
|
-
if (!
|
|
16459
|
+
const registryPath = options.registry ?? resolve5(process.cwd(), ".claude", "te", "registry.json");
|
|
16460
|
+
if (!existsSync5(registryPath)) {
|
|
16432
16461
|
console.log(
|
|
16433
16462
|
chalk5.yellow(
|
|
16434
16463
|
"No registry found. Run `fathom analyze <spec> --project <name>` first."
|
|
@@ -16437,9 +16466,9 @@ var trackCommand = new Command4("track").description("Import Claude Code session
|
|
|
16437
16466
|
return;
|
|
16438
16467
|
}
|
|
16439
16468
|
const registry = JSON.parse(
|
|
16440
|
-
|
|
16469
|
+
readFileSync6(registryPath, "utf-8")
|
|
16441
16470
|
);
|
|
16442
|
-
const projectName = options.project ?? registry.project ??
|
|
16471
|
+
const projectName = options.project ?? registry.project ?? getProjectName();
|
|
16443
16472
|
console.log(chalk5.dim("Scanning for sessions..."));
|
|
16444
16473
|
const sessionFiles = findSessionFiles(options.sessionsDir);
|
|
16445
16474
|
if (sessionFiles.length === 0) {
|
|
@@ -16448,14 +16477,14 @@ var trackCommand = new Command4("track").description("Import Claude Code session
|
|
|
16448
16477
|
);
|
|
16449
16478
|
return;
|
|
16450
16479
|
}
|
|
16451
|
-
const trackingDir =
|
|
16480
|
+
const trackingDir = resolve5(
|
|
16452
16481
|
process.cwd(),
|
|
16453
16482
|
".claude",
|
|
16454
16483
|
"te",
|
|
16455
16484
|
"tracking",
|
|
16456
16485
|
"sessions"
|
|
16457
16486
|
);
|
|
16458
|
-
const summaryPath =
|
|
16487
|
+
const summaryPath = resolve5(
|
|
16459
16488
|
process.cwd(),
|
|
16460
16489
|
".claude",
|
|
16461
16490
|
"te",
|
|
@@ -16463,8 +16492,8 @@ var trackCommand = new Command4("track").description("Import Claude Code session
|
|
|
16463
16492
|
"summary.json"
|
|
16464
16493
|
);
|
|
16465
16494
|
const trackedIds = /* @__PURE__ */ new Set();
|
|
16466
|
-
if (!options.backfill &&
|
|
16467
|
-
const summary = JSON.parse(
|
|
16495
|
+
if (!options.backfill && existsSync5(summaryPath)) {
|
|
16496
|
+
const summary = JSON.parse(readFileSync6(summaryPath, "utf-8"));
|
|
16468
16497
|
for (const s of summary.sessions ?? []) {
|
|
16469
16498
|
trackedIds.add(s.sessionId);
|
|
16470
16499
|
}
|
|
@@ -16530,7 +16559,7 @@ Total: ${totalTokens.toLocaleString()} tokens across ${results.length} sessions`
|
|
|
16530
16559
|
`Tags: ${autoTagged} auto-tagged, ${likely} likely, ${untagged} untagged`
|
|
16531
16560
|
)
|
|
16532
16561
|
);
|
|
16533
|
-
|
|
16562
|
+
mkdirSync3(trackingDir, { recursive: true });
|
|
16534
16563
|
const sessionRecords = results.map(({ session, tag }) => ({
|
|
16535
16564
|
sessionId: session.sessionId,
|
|
16536
16565
|
featureId: tag.featureId,
|
|
@@ -16547,11 +16576,11 @@ Total: ${totalTokens.toLocaleString()} tokens across ${results.length} sessions`
|
|
|
16547
16576
|
trackedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16548
16577
|
}));
|
|
16549
16578
|
let existing = { sessions: [] };
|
|
16550
|
-
if (
|
|
16551
|
-
existing = JSON.parse(
|
|
16579
|
+
if (existsSync5(summaryPath)) {
|
|
16580
|
+
existing = JSON.parse(readFileSync6(summaryPath, "utf-8"));
|
|
16552
16581
|
}
|
|
16553
16582
|
existing.sessions.push(...sessionRecords);
|
|
16554
|
-
|
|
16583
|
+
writeFileSync3(
|
|
16555
16584
|
summaryPath,
|
|
16556
16585
|
JSON.stringify(
|
|
16557
16586
|
{
|
|
@@ -16601,20 +16630,20 @@ Tracking saved: ${summaryPath}`));
|
|
|
16601
16630
|
|
|
16602
16631
|
// src/commands/reconcile.ts
|
|
16603
16632
|
import { Command as Command5 } from "commander";
|
|
16604
|
-
import { readFileSync as
|
|
16605
|
-
import { resolve as
|
|
16633
|
+
import { readFileSync as readFileSync7, existsSync as existsSync6 } from "fs";
|
|
16634
|
+
import { resolve as resolve6 } from "path";
|
|
16606
16635
|
import chalk6 from "chalk";
|
|
16607
16636
|
import Table5 from "cli-table3";
|
|
16608
16637
|
var reconcileCommand = new Command5("reconcile").description("Compare estimates vs actuals per feature").option("-p, --project <name>", "Project name").option("--registry <path>", "Path to registry.json").action(async (options) => {
|
|
16609
|
-
const registryPath = options.registry ??
|
|
16610
|
-
const summaryPath =
|
|
16638
|
+
const registryPath = options.registry ?? resolve6(process.cwd(), ".claude", "te", "registry.json");
|
|
16639
|
+
const summaryPath = resolve6(
|
|
16611
16640
|
process.cwd(),
|
|
16612
16641
|
".claude",
|
|
16613
16642
|
"te",
|
|
16614
16643
|
"tracking",
|
|
16615
16644
|
"summary.json"
|
|
16616
16645
|
);
|
|
16617
|
-
if (!
|
|
16646
|
+
if (!existsSync6(registryPath)) {
|
|
16618
16647
|
console.log(
|
|
16619
16648
|
chalk6.yellow(
|
|
16620
16649
|
"No registry found. Run `fathom analyze <spec> --project <name>` first."
|
|
@@ -16622,7 +16651,7 @@ var reconcileCommand = new Command5("reconcile").description("Compare estimates
|
|
|
16622
16651
|
);
|
|
16623
16652
|
return;
|
|
16624
16653
|
}
|
|
16625
|
-
if (!
|
|
16654
|
+
if (!existsSync6(summaryPath)) {
|
|
16626
16655
|
console.log(
|
|
16627
16656
|
chalk6.yellow(
|
|
16628
16657
|
"No tracking data found. Run `fathom track --project <name>` first."
|
|
@@ -16630,9 +16659,9 @@ var reconcileCommand = new Command5("reconcile").description("Compare estimates
|
|
|
16630
16659
|
);
|
|
16631
16660
|
return;
|
|
16632
16661
|
}
|
|
16633
|
-
const registry = JSON.parse(
|
|
16634
|
-
const summary = JSON.parse(
|
|
16635
|
-
const projectName = options.project ?? registry.project ??
|
|
16662
|
+
const registry = JSON.parse(readFileSync7(registryPath, "utf-8"));
|
|
16663
|
+
const summary = JSON.parse(readFileSync7(summaryPath, "utf-8"));
|
|
16664
|
+
const projectName = options.project ?? registry.project ?? getProjectName();
|
|
16636
16665
|
const data = loadData();
|
|
16637
16666
|
const actuals = /* @__PURE__ */ new Map();
|
|
16638
16667
|
for (const session of summary.sessions) {
|
|
@@ -16753,8 +16782,8 @@ Overall: ${totalActual.toLocaleString()} / ${totalEstimated.toLocaleString()} to
|
|
|
16753
16782
|
|
|
16754
16783
|
// src/commands/setup.ts
|
|
16755
16784
|
import { Command as Command6 } from "commander";
|
|
16756
|
-
import { writeFileSync as
|
|
16757
|
-
import { resolve as
|
|
16785
|
+
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, existsSync as existsSync7 } from "fs";
|
|
16786
|
+
import { resolve as resolve7 } from "path";
|
|
16758
16787
|
import chalk7 from "chalk";
|
|
16759
16788
|
var setupCommand = new Command6("setup").description("Scaffold .claude/ skill + hooks + registry for an existing project").option("-p, --project <name>", "Project name", "unnamed").action((options) => {
|
|
16760
16789
|
const projectName = options.project;
|
|
@@ -16762,15 +16791,15 @@ var setupCommand = new Command6("setup").description("Scaffold .claude/ skill +
|
|
|
16762
16791
|
console.log(chalk7.bold(`
|
|
16763
16792
|
Fathom \u2014 Setup: ${projectName}`));
|
|
16764
16793
|
console.log(chalk7.dim("\u2500".repeat(50)));
|
|
16765
|
-
const teDir =
|
|
16766
|
-
const trackingDir =
|
|
16767
|
-
const slicesDir =
|
|
16768
|
-
|
|
16769
|
-
|
|
16794
|
+
const teDir = resolve7(baseDir, ".claude", "te");
|
|
16795
|
+
const trackingDir = resolve7(teDir, "tracking", "sessions");
|
|
16796
|
+
const slicesDir = resolve7(teDir, "slices");
|
|
16797
|
+
mkdirSync4(trackingDir, { recursive: true });
|
|
16798
|
+
mkdirSync4(slicesDir, { recursive: true });
|
|
16770
16799
|
console.log(chalk7.green(" \u2713 .claude/te/ directory structure"));
|
|
16771
|
-
const configPath =
|
|
16772
|
-
if (!
|
|
16773
|
-
|
|
16800
|
+
const configPath = resolve7(teDir, "config.json");
|
|
16801
|
+
if (!existsSync7(configPath)) {
|
|
16802
|
+
writeFileSync4(
|
|
16774
16803
|
configPath,
|
|
16775
16804
|
JSON.stringify(
|
|
16776
16805
|
{ project: projectName, createdAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
@@ -16782,9 +16811,9 @@ Fathom \u2014 Setup: ${projectName}`));
|
|
|
16782
16811
|
} else {
|
|
16783
16812
|
console.log(chalk7.dim(" \xB7 config.json (exists)"));
|
|
16784
16813
|
}
|
|
16785
|
-
const registryPath =
|
|
16786
|
-
if (!
|
|
16787
|
-
|
|
16814
|
+
const registryPath = resolve7(teDir, "registry.json");
|
|
16815
|
+
if (!existsSync7(registryPath)) {
|
|
16816
|
+
writeFileSync4(
|
|
16788
16817
|
registryPath,
|
|
16789
16818
|
JSON.stringify(
|
|
16790
16819
|
{
|
|
@@ -16800,9 +16829,9 @@ Fathom \u2014 Setup: ${projectName}`));
|
|
|
16800
16829
|
} else {
|
|
16801
16830
|
console.log(chalk7.dim(" \xB7 registry.json (exists)"));
|
|
16802
16831
|
}
|
|
16803
|
-
const summaryPath =
|
|
16804
|
-
if (!
|
|
16805
|
-
|
|
16832
|
+
const summaryPath = resolve7(teDir, "tracking", "summary.json");
|
|
16833
|
+
if (!existsSync7(summaryPath)) {
|
|
16834
|
+
writeFileSync4(
|
|
16806
16835
|
summaryPath,
|
|
16807
16836
|
JSON.stringify(
|
|
16808
16837
|
{
|
|
@@ -16818,21 +16847,21 @@ Fathom \u2014 Setup: ${projectName}`));
|
|
|
16818
16847
|
} else {
|
|
16819
16848
|
console.log(chalk7.dim(" \xB7 tracking/summary.json (exists)"));
|
|
16820
16849
|
}
|
|
16821
|
-
const skillDir =
|
|
16822
|
-
|
|
16823
|
-
const skillPath =
|
|
16824
|
-
if (!
|
|
16850
|
+
const skillDir = resolve7(baseDir, ".claude", "skills", "fathom");
|
|
16851
|
+
mkdirSync4(skillDir, { recursive: true });
|
|
16852
|
+
const skillPath = resolve7(skillDir, "SKILL.md");
|
|
16853
|
+
if (!existsSync7(skillPath)) {
|
|
16825
16854
|
const skillContent = generateSkill(projectName);
|
|
16826
|
-
|
|
16855
|
+
writeFileSync4(skillPath, skillContent);
|
|
16827
16856
|
console.log(chalk7.green(" \u2713 skills/fathom/SKILL.md"));
|
|
16828
16857
|
} else {
|
|
16829
16858
|
console.log(chalk7.dim(" \xB7 skills/fathom/SKILL.md (exists)"));
|
|
16830
16859
|
}
|
|
16831
|
-
const refsDir =
|
|
16832
|
-
|
|
16833
|
-
const profilesRefPath =
|
|
16834
|
-
if (!
|
|
16835
|
-
|
|
16860
|
+
const refsDir = resolve7(skillDir, "references");
|
|
16861
|
+
mkdirSync4(refsDir, { recursive: true });
|
|
16862
|
+
const profilesRefPath = resolve7(refsDir, "task-profiles.md");
|
|
16863
|
+
if (!existsSync7(profilesRefPath)) {
|
|
16864
|
+
writeFileSync4(
|
|
16836
16865
|
profilesRefPath,
|
|
16837
16866
|
"# Task Profiles\n\nCalibrated profiles will appear here after running `fathom calibrate`.\n"
|
|
16838
16867
|
);
|
|
@@ -16840,11 +16869,11 @@ Fathom \u2014 Setup: ${projectName}`));
|
|
|
16840
16869
|
} else {
|
|
16841
16870
|
console.log(chalk7.dim(" \xB7 references/task-profiles.md (exists)"));
|
|
16842
16871
|
}
|
|
16843
|
-
const hooksDir =
|
|
16844
|
-
|
|
16845
|
-
const hookPath =
|
|
16846
|
-
if (!
|
|
16847
|
-
|
|
16872
|
+
const hooksDir = resolve7(baseDir, ".claude", "hooks");
|
|
16873
|
+
mkdirSync4(hooksDir, { recursive: true });
|
|
16874
|
+
const hookPath = resolve7(hooksDir, "te-session-sync.sh");
|
|
16875
|
+
if (!existsSync7(hookPath)) {
|
|
16876
|
+
writeFileSync4(
|
|
16848
16877
|
hookPath,
|
|
16849
16878
|
generateHookScript(projectName),
|
|
16850
16879
|
{ mode: 493 }
|
|
@@ -16853,8 +16882,8 @@ Fathom \u2014 Setup: ${projectName}`));
|
|
|
16853
16882
|
} else {
|
|
16854
16883
|
console.log(chalk7.dim(" \xB7 hooks/te-session-sync.sh (exists)"));
|
|
16855
16884
|
}
|
|
16856
|
-
const settingsPath =
|
|
16857
|
-
if (!
|
|
16885
|
+
const settingsPath = resolve7(baseDir, ".claude", "settings.json");
|
|
16886
|
+
if (!existsSync7(settingsPath)) {
|
|
16858
16887
|
console.log(
|
|
16859
16888
|
chalk7.yellow(
|
|
16860
16889
|
"\n \u26A0 No .claude/settings.json found. Add hook config manually if needed."
|
|
@@ -16910,20 +16939,20 @@ function generateHookScript(projectName) {
|
|
|
16910
16939
|
|
|
16911
16940
|
// src/commands/calibrate.ts
|
|
16912
16941
|
import { Command as Command7 } from "commander";
|
|
16913
|
-
import { readFileSync as
|
|
16914
|
-
import { resolve as
|
|
16942
|
+
import { readFileSync as readFileSync9, existsSync as existsSync8 } from "fs";
|
|
16943
|
+
import { resolve as resolve8 } from "path";
|
|
16915
16944
|
import chalk8 from "chalk";
|
|
16916
16945
|
import Table6 from "cli-table3";
|
|
16917
16946
|
var calibrateCommand = new Command7("calibrate").description("Show calibration drift and profile adjustment suggestions").option("-p, --project <name>", "Project name").option("--registry <path>", "Path to registry.json").action(async (options) => {
|
|
16918
|
-
const registryPath = options.registry ??
|
|
16919
|
-
const summaryPath =
|
|
16947
|
+
const registryPath = options.registry ?? resolve8(process.cwd(), ".claude", "te", "registry.json");
|
|
16948
|
+
const summaryPath = resolve8(
|
|
16920
16949
|
process.cwd(),
|
|
16921
16950
|
".claude",
|
|
16922
16951
|
"te",
|
|
16923
16952
|
"tracking",
|
|
16924
16953
|
"summary.json"
|
|
16925
16954
|
);
|
|
16926
|
-
if (!
|
|
16955
|
+
if (!existsSync8(registryPath) || !existsSync8(summaryPath)) {
|
|
16927
16956
|
console.log(
|
|
16928
16957
|
chalk8.yellow(
|
|
16929
16958
|
"Need both registry and tracking data. Run `fathom analyze` then `fathom track` first."
|
|
@@ -16931,9 +16960,9 @@ var calibrateCommand = new Command7("calibrate").description("Show calibration d
|
|
|
16931
16960
|
);
|
|
16932
16961
|
return;
|
|
16933
16962
|
}
|
|
16934
|
-
const registry = JSON.parse(
|
|
16935
|
-
const summary = JSON.parse(
|
|
16936
|
-
const projectName = options.project ?? registry.project ??
|
|
16963
|
+
const registry = JSON.parse(readFileSync9(registryPath, "utf-8"));
|
|
16964
|
+
const summary = JSON.parse(readFileSync9(summaryPath, "utf-8"));
|
|
16965
|
+
const projectName = options.project ?? registry.project ?? getProjectName();
|
|
16937
16966
|
const actuals = /* @__PURE__ */ new Map();
|
|
16938
16967
|
for (const session of summary.sessions) {
|
|
16939
16968
|
if (!session.featureId || session.status === "untagged") continue;
|
|
@@ -17126,16 +17155,16 @@ var estimateCommand = new Command8("estimate").description("Quick single-feature
|
|
|
17126
17155
|
|
|
17127
17156
|
// src/commands/validate.ts
|
|
17128
17157
|
import { Command as Command9 } from "commander";
|
|
17129
|
-
import { readFileSync as
|
|
17130
|
-
import { resolve as
|
|
17158
|
+
import { readFileSync as readFileSync10, existsSync as existsSync9 } from "fs";
|
|
17159
|
+
import { resolve as resolve9 } from "path";
|
|
17131
17160
|
import chalk10 from "chalk";
|
|
17132
17161
|
var validateCommand = new Command9("validate").description("Validate a spec file format without running full analysis").argument("<spec>", "Path to the spec markdown file").action((specPath) => {
|
|
17133
|
-
const fullPath =
|
|
17134
|
-
if (!
|
|
17162
|
+
const fullPath = resolve9(specPath);
|
|
17163
|
+
if (!existsSync9(fullPath)) {
|
|
17135
17164
|
console.error(chalk10.red(`Spec file not found: ${fullPath}`));
|
|
17136
17165
|
process.exit(1);
|
|
17137
17166
|
}
|
|
17138
|
-
const content3 =
|
|
17167
|
+
const content3 = readFileSync10(fullPath, "utf-8");
|
|
17139
17168
|
console.log(chalk10.bold("\nFathom \u2014 Validate Spec"));
|
|
17140
17169
|
console.log(chalk10.dim("\u2500".repeat(50)));
|
|
17141
17170
|
console.log(chalk10.dim(`File: ${fullPath}`));
|
|
@@ -17204,8 +17233,8 @@ var validateCommand = new Command9("validate").description("Validate a spec file
|
|
|
17204
17233
|
|
|
17205
17234
|
// src/commands/velocity.ts
|
|
17206
17235
|
import { Command as Command10 } from "commander";
|
|
17207
|
-
import { readFileSync as
|
|
17208
|
-
import { resolve as
|
|
17236
|
+
import { readFileSync as readFileSync11, existsSync as existsSync10 } from "fs";
|
|
17237
|
+
import { resolve as resolve10 } from "path";
|
|
17209
17238
|
import chalk11 from "chalk";
|
|
17210
17239
|
import Table7 from "cli-table3";
|
|
17211
17240
|
|
|
@@ -17511,15 +17540,15 @@ function percentileRange(values) {
|
|
|
17511
17540
|
// src/commands/velocity.ts
|
|
17512
17541
|
var velocityCommand = new Command10("velocity").description("Show velocity metrics and benchmarks").option("-p, --project <name>", "Project name").option("--registry <path>", "Path to registry.json").option("--benchmarks", "Show benchmarks by complexity + category").action(
|
|
17513
17542
|
async (options) => {
|
|
17514
|
-
const registryPath = options.registry ??
|
|
17515
|
-
const summaryPath =
|
|
17543
|
+
const registryPath = options.registry ?? resolve10(process.cwd(), ".claude", "te", "registry.json");
|
|
17544
|
+
const summaryPath = resolve10(
|
|
17516
17545
|
process.cwd(),
|
|
17517
17546
|
".claude",
|
|
17518
17547
|
"te",
|
|
17519
17548
|
"tracking",
|
|
17520
17549
|
"summary.json"
|
|
17521
17550
|
);
|
|
17522
|
-
if (!
|
|
17551
|
+
if (!existsSync10(registryPath) || !existsSync10(summaryPath)) {
|
|
17523
17552
|
console.log(
|
|
17524
17553
|
chalk11.yellow(
|
|
17525
17554
|
"Need both registry and tracking data. Run `fathom analyze` then `fathom track` first."
|
|
@@ -17527,9 +17556,9 @@ var velocityCommand = new Command10("velocity").description("Show velocity metri
|
|
|
17527
17556
|
);
|
|
17528
17557
|
return;
|
|
17529
17558
|
}
|
|
17530
|
-
const registry = JSON.parse(
|
|
17531
|
-
const summary = JSON.parse(
|
|
17532
|
-
const projectName = options.project ?? registry.project ??
|
|
17559
|
+
const registry = JSON.parse(readFileSync11(registryPath, "utf-8"));
|
|
17560
|
+
const summary = JSON.parse(readFileSync11(summaryPath, "utf-8"));
|
|
17561
|
+
const projectName = options.project ?? registry.project ?? getProjectName();
|
|
17533
17562
|
const data = loadData();
|
|
17534
17563
|
const featureDataMap = /* @__PURE__ */ new Map();
|
|
17535
17564
|
for (const feature of registry.features) {
|
|
@@ -17665,10 +17694,11 @@ Fathom \u2014 Velocity: ${projectName}`));
|
|
|
17665
17694
|
|
|
17666
17695
|
// src/commands/intake.ts
|
|
17667
17696
|
import { Command as Command11 } from "commander";
|
|
17668
|
-
import { readFileSync as
|
|
17669
|
-
import { resolve as
|
|
17697
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync5, existsSync as existsSync11, mkdirSync as mkdirSync5, readdirSync as readdirSync2, statSync } from "fs";
|
|
17698
|
+
import { resolve as resolve11, basename as basename2, dirname as dirname3 } from "path";
|
|
17670
17699
|
import chalk12 from "chalk";
|
|
17671
17700
|
import Table8 from "cli-table3";
|
|
17701
|
+
import { input, confirm, select } from "@inquirer/prompts";
|
|
17672
17702
|
|
|
17673
17703
|
// ../intake/dist/index.js
|
|
17674
17704
|
var ExtractedItem = external_exports.object({
|
|
@@ -17831,49 +17861,80 @@ function enrichSlices(items, options = {}) {
|
|
|
17831
17861
|
function slugify2(s) {
|
|
17832
17862
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
17833
17863
|
}
|
|
17834
|
-
function formatSlice(slice) {
|
|
17864
|
+
function formatSlice(slice, index2) {
|
|
17865
|
+
const modelShort = slice.recommendedModel.replace("claude-", "").replace(/-\d+-\d+$/, "");
|
|
17835
17866
|
const lines = [
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
"---",
|
|
17867
|
+
`### ${index2 + 1}. ${slice.name}`,
|
|
17868
|
+
"",
|
|
17869
|
+
`**Complexity:** ${slice.complexity} | **Category:** ${slice.category} | **Priority:** ${slice.priority}`,
|
|
17840
17870
|
"",
|
|
17841
|
-
|
|
17842
|
-
|
|
17843
|
-
`- **Priority**: ${slice.priority}`,
|
|
17844
|
-
`- **Complexity**: ${slice.complexity}`,
|
|
17845
|
-
`- **Description**: ${slice.description}`
|
|
17871
|
+
`> ${slice.description}`,
|
|
17872
|
+
""
|
|
17846
17873
|
];
|
|
17847
17874
|
if (slice.rootCause) {
|
|
17848
|
-
lines.push(
|
|
17849
|
-
}
|
|
17850
|
-
lines.push(
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
);
|
|
17875
|
+
lines.push(`**Root Cause:** ${slice.rootCause}`, "");
|
|
17876
|
+
}
|
|
17877
|
+
lines.push("#### Tasks");
|
|
17878
|
+
for (const task of slice.aiTasks) {
|
|
17879
|
+
lines.push(`- [ ] ${task}`);
|
|
17880
|
+
}
|
|
17881
|
+
lines.push("");
|
|
17882
|
+
lines.push("#### Acceptance Criteria");
|
|
17883
|
+
const criteria = slice.acceptanceCriteria.split(/[.;]/).map((c) => c.trim()).filter((c) => c.length > 0);
|
|
17884
|
+
for (const criterion of criteria) {
|
|
17885
|
+
lines.push(`- [ ] ${criterion}`);
|
|
17886
|
+
}
|
|
17887
|
+
lines.push("");
|
|
17888
|
+
lines.push("#### Estimate");
|
|
17889
|
+
lines.push(`- **Tokens:** ~${slice.estimatedTokens.toLocaleString()}`);
|
|
17890
|
+
lines.push(`- **Cost:** $${slice.estimatedCost.toFixed(2)}`);
|
|
17891
|
+
lines.push(`- **Recommended model:** ${modelShort}`);
|
|
17856
17892
|
if (slice.velocityBenchmark) {
|
|
17857
17893
|
const vb = slice.velocityBenchmark;
|
|
17858
17894
|
lines.push(
|
|
17859
|
-
`- **Velocity
|
|
17895
|
+
`- **Velocity benchmark:** ~${vb.avgSessions.toFixed(1)} sessions, ~${vb.avgDays.toFixed(1)} days (based on ${vb.dataPoints} similar tasks)`
|
|
17860
17896
|
);
|
|
17861
17897
|
}
|
|
17862
17898
|
return lines.join("\n");
|
|
17863
17899
|
}
|
|
17864
17900
|
function formatAsMarkdown(result) {
|
|
17901
|
+
const date = result.createdAt.slice(0, 10);
|
|
17865
17902
|
const lines = [
|
|
17866
|
-
`#
|
|
17903
|
+
`# ${result.project} \u2014 Spec`,
|
|
17867
17904
|
"",
|
|
17868
|
-
|
|
17869
|
-
`> Total estimate: ~${result.totalEstimatedTokens.toLocaleString()} tokens, $${result.totalEstimatedCost.toFixed(2)}`,
|
|
17905
|
+
`Generated by Fathom on ${date}`,
|
|
17870
17906
|
"",
|
|
17871
|
-
|
|
17907
|
+
"## Summary",
|
|
17908
|
+
"",
|
|
17909
|
+
`| | |`,
|
|
17910
|
+
`|---|---|`,
|
|
17911
|
+
`| **Work items** | ${result.slices.length} |`,
|
|
17912
|
+
`| **Total tokens** | ~${result.totalEstimatedTokens.toLocaleString()} |`,
|
|
17913
|
+
`| **Total cost** | $${result.totalEstimatedCost.toFixed(2)} |`,
|
|
17914
|
+
`| **Source** | ${result.source} |`,
|
|
17915
|
+
"",
|
|
17916
|
+
"## Priority Order",
|
|
17872
17917
|
""
|
|
17873
17918
|
];
|
|
17874
|
-
|
|
17875
|
-
|
|
17919
|
+
const p1 = result.slices.filter((s) => s.priority === "P0" || s.priority === "P1");
|
|
17920
|
+
const p2 = result.slices.filter((s) => s.priority === "P2");
|
|
17921
|
+
const p3 = result.slices.filter((s) => s.priority === "P3");
|
|
17922
|
+
if (p1.length > 0) {
|
|
17923
|
+
lines.push(`**Must-have (${p1.length}):** ${p1.map((s) => s.name).join(", ")}`);
|
|
17924
|
+
}
|
|
17925
|
+
if (p2.length > 0) {
|
|
17926
|
+
lines.push(`**Should-have (${p2.length}):** ${p2.map((s) => s.name).join(", ")}`);
|
|
17927
|
+
}
|
|
17928
|
+
if (p3.length > 0) {
|
|
17929
|
+
lines.push(`**Nice-to-have (${p3.length}):** ${p3.map((s) => s.name).join(", ")}`);
|
|
17930
|
+
}
|
|
17931
|
+
lines.push("", "---", "", "## Features", "");
|
|
17932
|
+
for (let i = 0; i < result.slices.length; i++) {
|
|
17933
|
+
lines.push(formatSlice(result.slices[i], i));
|
|
17876
17934
|
lines.push("");
|
|
17935
|
+
if (i < result.slices.length - 1) {
|
|
17936
|
+
lines.push("---", "");
|
|
17937
|
+
}
|
|
17877
17938
|
}
|
|
17878
17939
|
return lines.join("\n");
|
|
17879
17940
|
}
|
|
@@ -17891,30 +17952,108 @@ function formatSliceTable(slices) {
|
|
|
17891
17952
|
}
|
|
17892
17953
|
|
|
17893
17954
|
// src/commands/intake.ts
|
|
17894
|
-
|
|
17955
|
+
function findLocalMarkdownFiles() {
|
|
17956
|
+
try {
|
|
17957
|
+
const cwd = process.cwd();
|
|
17958
|
+
return readdirSync2(cwd).filter((f) => /\.(md|txt|mdx)$/i.test(f) && !f.startsWith(".")).map((f) => ({ name: f, mtime: statSync(resolve11(cwd, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime).map((f) => f.name);
|
|
17959
|
+
} catch {
|
|
17960
|
+
return [];
|
|
17961
|
+
}
|
|
17962
|
+
}
|
|
17963
|
+
var intakeCommand = new Command11("intake").description("Extract work items from raw feedback, bug reports, or meeting notes").argument("[text]", "Raw text input to analyze").option("-f, --file <path>", "Read input from a file").option("-p, --project <name>", "Project name").option("-o, --output <path>", "Write markdown spec to file").option("--json", "Output as JSON").option("--markdown", "Output as markdown to stdout").action(async (text3, options) => {
|
|
17964
|
+
const cwd = process.cwd();
|
|
17965
|
+
let projectName = options.project ?? getProjectName();
|
|
17966
|
+
if (projectName === "unnamed") {
|
|
17967
|
+
projectName = await input({
|
|
17968
|
+
message: "Project name:",
|
|
17969
|
+
default: basename2(cwd)
|
|
17970
|
+
});
|
|
17971
|
+
updateProjectConfig({ project: projectName });
|
|
17972
|
+
}
|
|
17895
17973
|
let rawInput;
|
|
17974
|
+
let source;
|
|
17896
17975
|
if (options.file) {
|
|
17897
|
-
const filePath =
|
|
17898
|
-
if (!
|
|
17976
|
+
const filePath = resolve11(options.file);
|
|
17977
|
+
if (!existsSync11(filePath)) {
|
|
17899
17978
|
console.error(chalk12.red(`File not found: ${filePath}`));
|
|
17900
17979
|
process.exit(1);
|
|
17901
17980
|
}
|
|
17902
|
-
rawInput =
|
|
17981
|
+
rawInput = readFileSync12(filePath, "utf-8");
|
|
17982
|
+
source = "file";
|
|
17903
17983
|
} else if (text3) {
|
|
17904
17984
|
rawInput = text3;
|
|
17985
|
+
source = "text";
|
|
17905
17986
|
} else {
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17987
|
+
const localFiles = findLocalMarkdownFiles();
|
|
17988
|
+
if (localFiles.length > 0) {
|
|
17989
|
+
const fileChoices = localFiles.slice(0, 8).map((f) => ({
|
|
17990
|
+
name: f,
|
|
17991
|
+
value: f
|
|
17992
|
+
}));
|
|
17993
|
+
fileChoices.push(
|
|
17994
|
+
{ name: "Other file...", value: "__other__" },
|
|
17995
|
+
{ name: "Type/paste text instead", value: "__text__" }
|
|
17996
|
+
);
|
|
17997
|
+
const chosen = await select({
|
|
17998
|
+
message: `Input source (${localFiles.length} file${localFiles.length === 1 ? "" : "s"} found in ${basename2(cwd)}):`,
|
|
17999
|
+
choices: fileChoices
|
|
18000
|
+
});
|
|
18001
|
+
if (chosen === "__text__") {
|
|
18002
|
+
rawInput = await input({
|
|
18003
|
+
message: "Paste your feedback / requirements:"
|
|
18004
|
+
});
|
|
18005
|
+
source = "text";
|
|
18006
|
+
} else if (chosen === "__other__") {
|
|
18007
|
+
const filePath = await input({
|
|
18008
|
+
message: "Path to input file:",
|
|
18009
|
+
default: cwd + "/"
|
|
18010
|
+
});
|
|
18011
|
+
const resolved = resolve11(filePath.trim());
|
|
18012
|
+
if (!existsSync11(resolved)) {
|
|
18013
|
+
console.error(chalk12.red(`File not found: ${resolved}`));
|
|
18014
|
+
process.exit(1);
|
|
18015
|
+
}
|
|
18016
|
+
rawInput = readFileSync12(resolved, "utf-8");
|
|
18017
|
+
source = "file";
|
|
18018
|
+
} else {
|
|
18019
|
+
rawInput = readFileSync12(resolve11(chosen), "utf-8");
|
|
18020
|
+
source = "file";
|
|
18021
|
+
}
|
|
18022
|
+
} else {
|
|
18023
|
+
const inputType = await select({
|
|
18024
|
+
message: "How would you like to provide input?",
|
|
18025
|
+
choices: [
|
|
18026
|
+
{ name: "Enter a file path", value: "file" },
|
|
18027
|
+
{ name: "Type/paste text", value: "text" }
|
|
18028
|
+
]
|
|
18029
|
+
});
|
|
18030
|
+
if (inputType === "file") {
|
|
18031
|
+
const filePath = await input({
|
|
18032
|
+
message: "Path to input file:",
|
|
18033
|
+
default: cwd + "/"
|
|
18034
|
+
});
|
|
18035
|
+
const resolved = resolve11(filePath.trim());
|
|
18036
|
+
if (!existsSync11(resolved)) {
|
|
18037
|
+
console.error(chalk12.red(`File not found: ${resolved}`));
|
|
18038
|
+
process.exit(1);
|
|
18039
|
+
}
|
|
18040
|
+
rawInput = readFileSync12(resolved, "utf-8");
|
|
18041
|
+
source = "file";
|
|
18042
|
+
} else {
|
|
18043
|
+
rawInput = await input({
|
|
18044
|
+
message: "Paste your feedback / requirements:"
|
|
18045
|
+
});
|
|
18046
|
+
source = "text";
|
|
18047
|
+
}
|
|
18048
|
+
}
|
|
17910
18049
|
}
|
|
17911
18050
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
17912
18051
|
console.error(chalk12.red("ANTHROPIC_API_KEY environment variable is required."));
|
|
18052
|
+
console.error(chalk12.dim(" Add it to your .env file or export it:"));
|
|
17913
18053
|
console.error(chalk12.dim(" export ANTHROPIC_API_KEY=sk-ant-..."));
|
|
17914
18054
|
process.exit(1);
|
|
17915
18055
|
}
|
|
17916
|
-
|
|
17917
|
-
console.log(chalk12.dim("Extracting work items via Claude..."));
|
|
18056
|
+
console.log(chalk12.dim("\nExtracting work items via Claude..."));
|
|
17918
18057
|
let items;
|
|
17919
18058
|
try {
|
|
17920
18059
|
items = await extractWorkItems(rawInput);
|
|
@@ -17929,11 +18068,11 @@ var intakeCommand = new Command11("intake").description("Extract work items from
|
|
|
17929
18068
|
console.log(chalk12.green(`Extracted ${items.length} work item${items.length === 1 ? "" : "s"}`));
|
|
17930
18069
|
console.log(chalk12.dim("Enriching with estimates..."));
|
|
17931
18070
|
const data = loadData();
|
|
17932
|
-
const slices = enrichSlices(items, { data, project:
|
|
18071
|
+
const slices = enrichSlices(items, { data, project: projectName });
|
|
17933
18072
|
const totalTokens = slices.reduce((s, sl) => s + sl.estimatedTokens, 0);
|
|
17934
18073
|
const totalCost = slices.reduce((s, sl) => s + sl.estimatedCost, 0);
|
|
17935
18074
|
const result = {
|
|
17936
|
-
project:
|
|
18075
|
+
project: projectName,
|
|
17937
18076
|
source,
|
|
17938
18077
|
rawInput,
|
|
17939
18078
|
slices,
|
|
@@ -17945,12 +18084,22 @@ var intakeCommand = new Command11("intake").description("Extract work items from
|
|
|
17945
18084
|
console.log(JSON.stringify(result, null, 2));
|
|
17946
18085
|
return;
|
|
17947
18086
|
}
|
|
18087
|
+
if (options.output) {
|
|
18088
|
+
const outPath = resolve11(options.output);
|
|
18089
|
+
mkdirSync5(dirname3(outPath), { recursive: true });
|
|
18090
|
+
writeFileSync5(outPath, formatAsMarkdown(result));
|
|
18091
|
+
console.log(chalk12.green(`
|
|
18092
|
+
Spec written to ${outPath}`));
|
|
18093
|
+
await doConvexSync(result, rawInput, source, projectName);
|
|
18094
|
+
return;
|
|
18095
|
+
}
|
|
17948
18096
|
if (options.markdown) {
|
|
17949
18097
|
console.log(formatAsMarkdown(result));
|
|
18098
|
+
await doConvexSync(result, rawInput, source, projectName);
|
|
17950
18099
|
return;
|
|
17951
18100
|
}
|
|
17952
18101
|
console.log(chalk12.bold(`
|
|
17953
|
-
Fathom \u2014 Intake Analysis: ${
|
|
18102
|
+
Fathom \u2014 Intake Analysis: ${projectName}`));
|
|
17954
18103
|
console.log(chalk12.dim("\u2500".repeat(60)));
|
|
17955
18104
|
const tableRows = formatSliceTable(slices);
|
|
17956
18105
|
const table = new Table8({
|
|
@@ -17983,13 +18132,57 @@ Fathom \u2014 Intake Analysis: ${options.project}`));
|
|
|
17983
18132
|
chalk12.bold(`
|
|
17984
18133
|
Total: ${totalTokens.toLocaleString()} tokens \u2014 $${totalCost.toFixed(2)}`)
|
|
17985
18134
|
);
|
|
17986
|
-
|
|
17987
|
-
|
|
18135
|
+
const intakeDir = getIntakeDir();
|
|
18136
|
+
const datestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
18137
|
+
const defaultFile = `${intakeDir}/${projectName}-intake-${datestamp}.md`;
|
|
18138
|
+
const saveAction = await select({
|
|
18139
|
+
message: "What would you like to do with this spec?",
|
|
18140
|
+
choices: [
|
|
18141
|
+
{ name: `Save to ${defaultFile}`, value: "default" },
|
|
18142
|
+
{ name: "Save to a custom location", value: "custom" },
|
|
18143
|
+
{ name: "Print markdown to console", value: "print" },
|
|
18144
|
+
{ name: "Skip (don't save)", value: "skip" }
|
|
18145
|
+
]
|
|
18146
|
+
});
|
|
18147
|
+
if (saveAction === "default" || saveAction === "custom") {
|
|
18148
|
+
let outPath;
|
|
18149
|
+
if (saveAction === "custom") {
|
|
18150
|
+
const customPath = await input({
|
|
18151
|
+
message: "Output file path:",
|
|
18152
|
+
default: defaultFile
|
|
18153
|
+
});
|
|
18154
|
+
outPath = resolve11(customPath);
|
|
18155
|
+
} else {
|
|
18156
|
+
outPath = resolve11(defaultFile);
|
|
18157
|
+
}
|
|
18158
|
+
mkdirSync5(dirname3(outPath), { recursive: true });
|
|
18159
|
+
writeFileSync5(outPath, formatAsMarkdown(result));
|
|
18160
|
+
console.log(chalk12.green(`
|
|
18161
|
+
Spec written to ${outPath}`));
|
|
18162
|
+
const chosenDir = dirname3(outPath);
|
|
18163
|
+
const resolvedDefaultDir = resolve11(intakeDir);
|
|
18164
|
+
if (chosenDir !== resolvedDefaultDir) {
|
|
18165
|
+
const remember = await confirm({
|
|
18166
|
+
message: `Use "${dirname3(outPath).replace(resolve11(".") + "/", "")}" as default output directory next time?`,
|
|
18167
|
+
default: true
|
|
18168
|
+
});
|
|
18169
|
+
if (remember) {
|
|
18170
|
+
const relativeDir = dirname3(outPath).replace(resolve11(".") + "/", "");
|
|
18171
|
+
updateProjectConfig({ intakeDir: relativeDir });
|
|
18172
|
+
console.log(chalk12.dim(` Saved to .claude/te/config.json`));
|
|
18173
|
+
}
|
|
18174
|
+
}
|
|
18175
|
+
} else if (saveAction === "print") {
|
|
18176
|
+
console.log("\n" + formatAsMarkdown(result));
|
|
18177
|
+
}
|
|
18178
|
+
await doConvexSync(result, rawInput, source, projectName);
|
|
18179
|
+
});
|
|
18180
|
+
async function doConvexSync(result, rawInput, source, projectName) {
|
|
17988
18181
|
const synced = await syncIntake({
|
|
17989
|
-
projectName
|
|
18182
|
+
projectName,
|
|
17990
18183
|
rawInput,
|
|
17991
18184
|
source,
|
|
17992
|
-
extractedSlices: slices.map((s) => ({
|
|
18185
|
+
extractedSlices: result.slices.map((s) => ({
|
|
17993
18186
|
sliceId: s.sliceId,
|
|
17994
18187
|
name: s.name,
|
|
17995
18188
|
category: s.category,
|
|
@@ -18003,23 +18196,23 @@ Use --markdown to generate spec slices, --json for raw output.`));
|
|
|
18003
18196
|
}))
|
|
18004
18197
|
});
|
|
18005
18198
|
logConvexStatus(synced);
|
|
18006
|
-
}
|
|
18199
|
+
}
|
|
18007
18200
|
|
|
18008
18201
|
// src/commands/init.ts
|
|
18009
18202
|
import { Command as Command12 } from "commander";
|
|
18010
|
-
import { writeFileSync as
|
|
18011
|
-
import { resolve as
|
|
18203
|
+
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync12 } from "fs";
|
|
18204
|
+
import { resolve as resolve12 } from "path";
|
|
18012
18205
|
import chalk13 from "chalk";
|
|
18013
18206
|
var initCommand = new Command12("init").description("Initialize Fathom global config").option("--convex-url <url>", "Convex deployment URL").option("--team <name>", "Team name").action((options) => {
|
|
18014
|
-
const configDir =
|
|
18207
|
+
const configDir = resolve12(
|
|
18015
18208
|
process.env.HOME ?? process.env.USERPROFILE ?? ".",
|
|
18016
18209
|
".config",
|
|
18017
18210
|
"fathom"
|
|
18018
18211
|
);
|
|
18019
|
-
|
|
18020
|
-
const configPath =
|
|
18212
|
+
mkdirSync6(configDir, { recursive: true });
|
|
18213
|
+
const configPath = resolve12(configDir, "config.json");
|
|
18021
18214
|
let existing = {};
|
|
18022
|
-
if (
|
|
18215
|
+
if (existsSync12(configPath)) {
|
|
18023
18216
|
try {
|
|
18024
18217
|
existing = JSON.parse(
|
|
18025
18218
|
__require("fs").readFileSync(configPath, "utf-8")
|
|
@@ -18033,7 +18226,7 @@ var initCommand = new Command12("init").description("Initialize Fathom global co
|
|
|
18033
18226
|
...options.team && { team: options.team },
|
|
18034
18227
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
18035
18228
|
};
|
|
18036
|
-
|
|
18229
|
+
writeFileSync6(configPath, JSON.stringify(config, null, 2));
|
|
18037
18230
|
console.log(chalk13.bold("\nFathom \u2014 Init"));
|
|
18038
18231
|
console.log(chalk13.dim("\u2500".repeat(40)));
|
|
18039
18232
|
if (options.convexUrl) {
|
|
@@ -18053,50 +18246,50 @@ var initCommand = new Command12("init").description("Initialize Fathom global co
|
|
|
18053
18246
|
|
|
18054
18247
|
// src/commands/rename.ts
|
|
18055
18248
|
import { Command as Command13 } from "commander";
|
|
18056
|
-
import { readFileSync as
|
|
18057
|
-
import { resolve as
|
|
18249
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync7, existsSync as existsSync13 } from "fs";
|
|
18250
|
+
import { resolve as resolve13 } from "path";
|
|
18058
18251
|
import chalk14 from "chalk";
|
|
18059
18252
|
var renameCommand = new Command13("rename").description("Rename the project in all .claude/te/ config files").argument("<name>", "New project name").action((name) => {
|
|
18060
18253
|
const baseDir = process.cwd();
|
|
18061
|
-
const teDir =
|
|
18062
|
-
if (!
|
|
18254
|
+
const teDir = resolve13(baseDir, ".claude", "te");
|
|
18255
|
+
if (!existsSync13(teDir)) {
|
|
18063
18256
|
console.error(
|
|
18064
18257
|
chalk14.red("\n Error: .claude/te/ not found. Run `fathom setup` first.\n")
|
|
18065
18258
|
);
|
|
18066
18259
|
process.exit(1);
|
|
18067
18260
|
}
|
|
18068
18261
|
const jsonFiles = [
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18262
|
+
resolve13(teDir, "config.json"),
|
|
18263
|
+
resolve13(teDir, "registry.json"),
|
|
18264
|
+
resolve13(teDir, "tracking", "summary.json")
|
|
18072
18265
|
];
|
|
18073
18266
|
let oldName = "unnamed";
|
|
18074
18267
|
let updated = 0;
|
|
18075
18268
|
for (const filePath of jsonFiles) {
|
|
18076
|
-
if (!
|
|
18077
|
-
const data = JSON.parse(
|
|
18269
|
+
if (!existsSync13(filePath)) continue;
|
|
18270
|
+
const data = JSON.parse(readFileSync13(filePath, "utf-8"));
|
|
18078
18271
|
if (data.project) {
|
|
18079
18272
|
oldName = data.project;
|
|
18080
18273
|
data.project = name;
|
|
18081
|
-
|
|
18274
|
+
writeFileSync7(filePath, JSON.stringify(data, null, 2) + "\n");
|
|
18082
18275
|
updated++;
|
|
18083
18276
|
}
|
|
18084
18277
|
}
|
|
18085
|
-
const skillPath =
|
|
18086
|
-
if (
|
|
18087
|
-
const content3 =
|
|
18278
|
+
const skillPath = resolve13(baseDir, ".claude", "skills", "fathom", "SKILL.md");
|
|
18279
|
+
if (existsSync13(skillPath)) {
|
|
18280
|
+
const content3 = readFileSync13(skillPath, "utf-8");
|
|
18088
18281
|
const newContent = content3.replaceAll(oldName, name);
|
|
18089
18282
|
if (newContent !== content3) {
|
|
18090
|
-
|
|
18283
|
+
writeFileSync7(skillPath, newContent);
|
|
18091
18284
|
updated++;
|
|
18092
18285
|
}
|
|
18093
18286
|
}
|
|
18094
|
-
const hookPath =
|
|
18095
|
-
if (
|
|
18096
|
-
const content3 =
|
|
18287
|
+
const hookPath = resolve13(baseDir, ".claude", "hooks", "te-session-sync.sh");
|
|
18288
|
+
if (existsSync13(hookPath)) {
|
|
18289
|
+
const content3 = readFileSync13(hookPath, "utf-8");
|
|
18097
18290
|
const newContent = content3.replaceAll(oldName, name);
|
|
18098
18291
|
if (newContent !== content3) {
|
|
18099
|
-
|
|
18292
|
+
writeFileSync7(hookPath, newContent);
|
|
18100
18293
|
updated++;
|
|
18101
18294
|
}
|
|
18102
18295
|
}
|
|
@@ -18109,8 +18302,8 @@ var renameCommand = new Command13("rename").description("Rename the project in a
|
|
|
18109
18302
|
|
|
18110
18303
|
// src/commands/research.ts
|
|
18111
18304
|
import { Command as Command14 } from "commander";
|
|
18112
|
-
import { writeFileSync as
|
|
18113
|
-
import { resolve as
|
|
18305
|
+
import { writeFileSync as writeFileSync8, existsSync as existsSync14 } from "fs";
|
|
18306
|
+
import { resolve as resolve14 } from "path";
|
|
18114
18307
|
import chalk15 from "chalk";
|
|
18115
18308
|
|
|
18116
18309
|
// src/fetchers/types.ts
|
|
@@ -18411,9 +18604,9 @@ function generateAgentsYaml(recommendations) {
|
|
|
18411
18604
|
|
|
18412
18605
|
// src/commands/research.ts
|
|
18413
18606
|
function findDataDir2() {
|
|
18414
|
-
const bundled =
|
|
18415
|
-
if (
|
|
18416
|
-
return
|
|
18607
|
+
const bundled = resolve14(import.meta.dirname ?? __dirname, "data");
|
|
18608
|
+
if (existsSync14(resolve14(bundled, "models.yaml"))) return bundled;
|
|
18609
|
+
return resolve14(import.meta.dirname ?? __dirname, "../../../../data");
|
|
18417
18610
|
}
|
|
18418
18611
|
var researchCommand = new Command14("research").description("Check and update model pricing data (fetches live data)").option("--update", "Update local data files with latest pricing").option("--sync", "Also sync updated pricing to Convex").option("--check", "Check for differences without updating (default)").option("--offline", "Skip remote fetches, use local data only").option("--verbose", "Show fetch sources and timing details").action(async (options) => {
|
|
18419
18612
|
console.log(chalk15.bold("\nFathom \u2014 Research: Model Pricing"));
|
|
@@ -18463,12 +18656,12 @@ var researchCommand = new Command14("research").description("Check and update mo
|
|
|
18463
18656
|
displayRecommendations(mergeResult);
|
|
18464
18657
|
if (options.update) {
|
|
18465
18658
|
const dataDir = findDataDir2();
|
|
18466
|
-
const modelsPath =
|
|
18467
|
-
const agentsPath =
|
|
18468
|
-
|
|
18659
|
+
const modelsPath = resolve14(dataDir, "models.yaml");
|
|
18660
|
+
const agentsPath = resolve14(dataDir, "agents.yaml");
|
|
18661
|
+
writeFileSync8(modelsPath, generateModelsYaml(mergeResult.models.merged));
|
|
18469
18662
|
console.log(chalk15.green(`
|
|
18470
18663
|
Updated: ${modelsPath}`));
|
|
18471
|
-
|
|
18664
|
+
writeFileSync8(agentsPath, generateAgentsYaml(mergeResult.recommendations.merged));
|
|
18472
18665
|
console.log(chalk15.green(` Updated: ${agentsPath}`));
|
|
18473
18666
|
}
|
|
18474
18667
|
if (options.sync) {
|