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