@dialecte/cli 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lookups.js CHANGED
@@ -65,7 +65,7 @@ var CORE_PACKAGE_NAME = "@dialecte/core";
65
65
 
66
66
  // src/lib/api/source-functions.constants.ts
67
67
  var SOURCE_INDEX_FILE = "dialecte-source-index.json";
68
- var SOURCE_INDEX_SCHEMA = 1;
68
+ var SOURCE_INDEX_SCHEMA = 2;
69
69
  var SOURCE_FOLDER = "src";
70
70
  var SOURCE_FILE_PATTERN = /(?<!\.d)\.ts$/;
71
71
  var SOURCE_PATH_MARK = "#";
@@ -343,9 +343,18 @@ function firstPerPackage(indexes) {
343
343
  );
344
344
  }
345
345
  function parseApiJson(path) {
346
+ let text;
347
+ try {
348
+ text = readFileSync2(path, "utf8");
349
+ } catch (error) {
350
+ return { problem: error instanceof Error ? error.message : String(error) };
351
+ }
352
+ return parseApiJsonText(text);
353
+ }
354
+ function parseApiJsonText(text) {
346
355
  let value;
347
356
  try {
348
- value = JSON.parse(readFileSync2(path, "utf8"));
357
+ value = JSON.parse(text);
349
358
  } catch (error) {
350
359
  return { problem: error instanceof Error ? error.message : String(error) };
351
360
  }
@@ -1256,11 +1265,273 @@ function singleFileHost(source) {
1256
1265
  };
1257
1266
  }
1258
1267
 
1259
- // src/lib/api/source-file-functions.ts
1268
+ // src/lib/api/read-keys.ts
1269
+ import { createHash } from "crypto";
1270
+
1271
+ // src/lib/api/read-keys.constants.ts
1272
+ var ATTRIBUTE_READERS = [
1273
+ "getAttribute",
1274
+ "getAttributes",
1275
+ "readAttribute",
1276
+ "readAttributes"
1277
+ ];
1278
+ var ATTRIBUTE_BINDING_PATTERN = /^(?:attributes|attrs|\w*Attributes)$/;
1279
+ var TAG_PROPERTIES = ["tagName", "tag"];
1280
+ var ITERATING_METHODS = [
1281
+ "map",
1282
+ "flatMap",
1283
+ "forEach",
1284
+ "filter",
1285
+ "some",
1286
+ "every"
1287
+ ];
1288
+ var NAMED_SET_PATTERN = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$|^[A-Z]{2,}$/;
1289
+ var TOKEN_SEPARATOR = "\0";
1290
+
1291
+ // src/lib/api/read-keys.ts
1260
1292
  import ts5 from "typescript";
1293
+ function readKeysOf(params) {
1294
+ const elements = /* @__PURE__ */ new Set();
1295
+ const attributes = /* @__PURE__ */ new Set();
1296
+ const sets = /* @__PURE__ */ new Set();
1297
+ const bindings = attributeBindingsOf(params.node);
1298
+ let readsAttributes = false;
1299
+ function visit(node) {
1300
+ elementOf(node)?.forEach((element) => elements.add(element));
1301
+ if (ts5.isCallExpression(node) && isAttributeReader(node)) {
1302
+ readsAttributes = true;
1303
+ for (const argument of node.arguments)
1304
+ attributesOfArgument(argument).forEach((name) => attributes.add(name));
1305
+ }
1306
+ attributeOfAccess({ node, bindings })?.forEach((name) => attributes.add(name));
1307
+ const set = namedSetOf(node);
1308
+ if (set !== void 0) sets.add(set);
1309
+ ts5.forEachChild(node, visit);
1310
+ }
1311
+ visit(params.node);
1312
+ const namedSets = readsAttributes ? [...sets] : [];
1313
+ for (const set of namedSets) params.lists.get(set)?.forEach((name) => attributes.add(name));
1314
+ return {
1315
+ elements: [...elements].sort(),
1316
+ attributes: [...attributes].sort(),
1317
+ namedSets: namedSets.filter((set) => !params.lists.has(set)).sort()
1318
+ };
1319
+ }
1320
+ function callsOf(params) {
1321
+ const calls = /* @__PURE__ */ new Map();
1322
+ function visit(node) {
1323
+ if (ts5.isCallExpression(node) && ts5.isIdentifier(node.expression)) {
1324
+ const name = node.expression.text;
1325
+ const specifier = params.imported.get(name);
1326
+ if (!calls.has(name))
1327
+ calls.set(name, specifier === void 0 ? { name } : { name, specifier });
1328
+ }
1329
+ ts5.forEachChild(node, visit);
1330
+ }
1331
+ visit(params.node);
1332
+ return [...calls.values()];
1333
+ }
1334
+ function tokenHashOf(params) {
1335
+ const tokens = params.texts.flatMap(tokensOf);
1336
+ return {
1337
+ hash: createHash("sha256").update(tokens.join(TOKEN_SEPARATOR)).digest("hex"),
1338
+ count: tokens.length
1339
+ };
1340
+ }
1341
+ function typeReferencesOf(nodes) {
1342
+ const names = /* @__PURE__ */ new Set();
1343
+ function visit(node) {
1344
+ if (ts5.isTypeReferenceNode(node)) names.add(node.typeName.getText());
1345
+ ts5.forEachChild(node, visit);
1346
+ }
1347
+ nodes.forEach(visit);
1348
+ return [...names].sort();
1349
+ }
1350
+ function importsOf(source) {
1351
+ return source.statements.flatMap(function importOf(statement) {
1352
+ const line = source.getLineAndCharacterOfPosition(statement.getStart(source)).line + 1;
1353
+ if (ts5.isImportDeclaration(statement)) return importDeclarationOf({ statement, line });
1354
+ if (ts5.isExportDeclaration(statement)) return exportDeclarationOf({ statement, line });
1355
+ return [];
1356
+ });
1357
+ }
1358
+ function typesOf(source) {
1359
+ return source.statements.flatMap(function typeOf(statement) {
1360
+ if (!ts5.isTypeAliasDeclaration(statement) && !ts5.isInterfaceDeclaration(statement)) return [];
1361
+ return [
1362
+ { name: statement.name.text, hash: tokenHashOf({ texts: [statement.getText(source)] }).hash }
1363
+ ];
1364
+ });
1365
+ }
1366
+ function stringListsOf(source) {
1367
+ const lists = /* @__PURE__ */ new Map();
1368
+ for (const statement of source.statements) {
1369
+ if (!ts5.isVariableStatement(statement)) continue;
1370
+ for (const declaration of statement.declarationList.declarations) {
1371
+ const value = withoutAssertion(declaration.initializer);
1372
+ if (!ts5.isIdentifier(declaration.name) || value === void 0) continue;
1373
+ if (!ts5.isArrayLiteralExpression(value)) continue;
1374
+ if (!value.elements.every(ts5.isStringLiteral)) continue;
1375
+ lists.set(
1376
+ declaration.name.text,
1377
+ value.elements.map((element) => element.text)
1378
+ );
1379
+ }
1380
+ }
1381
+ return lists;
1382
+ }
1383
+ function localSpecifiersOf(imports) {
1384
+ return new Map(
1385
+ imports.filter((found) => !found.reexport).flatMap((found) => found.names.map((name) => [name.local, found.specifier]))
1386
+ );
1387
+ }
1388
+ function importDeclarationOf(params) {
1389
+ const { statement, line } = params;
1390
+ const clause = statement.importClause;
1391
+ if (clause === void 0 || clause.isTypeOnly || !ts5.isStringLiteral(statement.moduleSpecifier))
1392
+ return [];
1393
+ const specifier = statement.moduleSpecifier.text;
1394
+ const bindings = clause.namedBindings;
1395
+ if (bindings !== void 0 && ts5.isNamespaceImport(bindings))
1396
+ return [
1397
+ {
1398
+ specifier,
1399
+ line,
1400
+ names: [{ imported: "*", local: bindings.name.text }],
1401
+ reexport: false,
1402
+ all: true
1403
+ }
1404
+ ];
1405
+ const named = bindings === void 0 ? [] : bindings.elements.filter((element) => !element.isTypeOnly).map((element) => ({
1406
+ imported: (element.propertyName ?? element.name).text,
1407
+ local: element.name.text
1408
+ }));
1409
+ const names = clause.name === void 0 ? named : [{ imported: "default", local: clause.name.text }, ...named];
1410
+ return names.length ? [{ specifier, line, names, reexport: false }] : [];
1411
+ }
1412
+ function exportDeclarationOf(params) {
1413
+ const { statement, line } = params;
1414
+ const module = statement.moduleSpecifier;
1415
+ if (module === void 0 || statement.isTypeOnly || !ts5.isStringLiteral(module)) return [];
1416
+ const specifier = module.text;
1417
+ const clause = statement.exportClause;
1418
+ if (clause === void 0) return [{ specifier, line, names: [], reexport: true, all: true }];
1419
+ if (ts5.isNamespaceExport(clause))
1420
+ return [
1421
+ {
1422
+ specifier,
1423
+ line,
1424
+ names: [{ imported: "*", local: clause.name.text }],
1425
+ reexport: true,
1426
+ all: true
1427
+ }
1428
+ ];
1429
+ const names = clause.elements.filter((element) => !element.isTypeOnly).map((element) => ({
1430
+ imported: (element.propertyName ?? element.name).text,
1431
+ local: element.name.text
1432
+ }));
1433
+ return [{ specifier, line, names, reexport: true }];
1434
+ }
1435
+ function tokensOf(text) {
1436
+ const scanner = ts5.createScanner(ts5.ScriptTarget.Latest, true, ts5.LanguageVariant.Standard, text);
1437
+ const tokens = [];
1438
+ for (let kind = scanner.scan(); kind !== ts5.SyntaxKind.EndOfFileToken; kind = scanner.scan())
1439
+ if (kind !== ts5.SyntaxKind.SemicolonToken) tokens.push(scanner.getTokenText());
1440
+ return tokens;
1441
+ }
1442
+ function elementOf(node) {
1443
+ if (ts5.isBinaryExpression(node) && isEquality(node.operatorToken.kind)) {
1444
+ const literal = [node.left, node.right].find(ts5.isStringLiteral);
1445
+ const other = literal === node.left ? node.right : node.left;
1446
+ if (literal !== void 0 && isTagAccess(other)) return [literal.text];
1447
+ }
1448
+ if (ts5.isPropertyAssignment(node) && ts5.isIdentifier(node.name) && TAG_PROPERTIES.includes(node.name.text) && ts5.isStringLiteral(node.initializer))
1449
+ return [node.initializer.text];
1450
+ if ((ts5.isTypeReferenceNode(node) || ts5.isCallExpression(node)) && node.typeArguments !== void 0)
1451
+ return node.typeArguments.flatMap(stringLiteralTypeOf);
1452
+ return void 0;
1453
+ }
1454
+ function isEquality(kind) {
1455
+ return kind === ts5.SyntaxKind.EqualsEqualsEqualsToken || kind === ts5.SyntaxKind.ExclamationEqualsEqualsToken || kind === ts5.SyntaxKind.EqualsEqualsToken || kind === ts5.SyntaxKind.ExclamationEqualsToken;
1456
+ }
1457
+ function isTagAccess(node) {
1458
+ return ts5.isPropertyAccessExpression(node) && TAG_PROPERTIES.includes(node.name.text);
1459
+ }
1460
+ function stringLiteralTypeOf(node) {
1461
+ return ts5.isLiteralTypeNode(node) && ts5.isStringLiteral(node.literal) ? [node.literal.text] : [];
1462
+ }
1463
+ function isAttributeReader(node) {
1464
+ const callee = node.expression;
1465
+ const name = ts5.isIdentifier(callee) ? callee.text : ts5.isPropertyAccessExpression(callee) ? callee.name.text : void 0;
1466
+ return name !== void 0 && ATTRIBUTE_READERS.includes(name);
1467
+ }
1468
+ function attributesOfArgument(argument) {
1469
+ if (ts5.isStringLiteral(argument)) return [argument.text];
1470
+ if (!ts5.isObjectLiteralExpression(argument)) return [];
1471
+ return argument.properties.flatMap(function attributesOfProperty(property) {
1472
+ if (!ts5.isPropertyAssignment(property) || !ts5.isIdentifier(property.name)) return [];
1473
+ const value = withoutAssertion(property.initializer);
1474
+ if (property.name.text === "name" && value !== void 0 && ts5.isStringLiteral(value))
1475
+ return [value.text];
1476
+ if (property.name.text === "names" && value !== void 0 && ts5.isArrayLiteralExpression(value))
1477
+ return value.elements.filter(ts5.isStringLiteral).map((element) => element.text);
1478
+ return [];
1479
+ });
1480
+ }
1481
+ function attributeBindingsOf(node) {
1482
+ const bindings = /* @__PURE__ */ new Set();
1483
+ function visit(child) {
1484
+ if ((ts5.isParameter(child) || ts5.isVariableDeclaration(child)) && ts5.isIdentifier(child.name)) {
1485
+ const typeName2 = child.type !== void 0 && ts5.isTypeReferenceNode(child.type) ? child.type.typeName.getText() : "";
1486
+ if (ATTRIBUTE_BINDING_PATTERN.test(typeName2)) bindings.add(child.name.text);
1487
+ }
1488
+ ts5.forEachChild(child, visit);
1489
+ }
1490
+ visit(node);
1491
+ return bindings;
1492
+ }
1493
+ function isAttributeBinding(params) {
1494
+ const { node } = params;
1495
+ if (ts5.isIdentifier(node))
1496
+ return ATTRIBUTE_BINDING_PATTERN.test(node.text) || params.bindings.has(node.text);
1497
+ return ts5.isPropertyAccessExpression(node) && ATTRIBUTE_BINDING_PATTERN.test(node.name.text);
1498
+ }
1499
+ function attributeOfAccess(params) {
1500
+ const { node, bindings } = params;
1501
+ if (ts5.isPropertyAccessExpression(node) && isAttributeBinding({ node: node.expression, bindings }))
1502
+ return [node.name.text];
1503
+ if (ts5.isElementAccessExpression(node) && ts5.isStringLiteral(node.argumentExpression) && isAttributeBinding({ node: node.expression, bindings }))
1504
+ return [node.argumentExpression.text];
1505
+ if (ts5.isVariableDeclaration(node) && ts5.isObjectBindingPattern(node.name) && node.initializer !== void 0 && isAttributeBinding({ node: node.initializer, bindings }))
1506
+ return node.name.elements.flatMap(function nameOf(element) {
1507
+ const key = element.propertyName ?? element.name;
1508
+ return ts5.isIdentifier(key) ? [key.text] : [];
1509
+ });
1510
+ return void 0;
1511
+ }
1512
+ function namedSetOf(node) {
1513
+ if (ts5.isPropertyAccessExpression(node) && ITERATING_METHODS.includes(node.name.text) && ts5.isIdentifier(node.expression) && NAMED_SET_PATTERN.test(node.expression.text))
1514
+ return node.expression.text;
1515
+ if (ts5.isForOfStatement(node) && ts5.isIdentifier(node.expression) && NAMED_SET_PATTERN.test(node.expression.text))
1516
+ return node.expression.text;
1517
+ if (ts5.isCallExpression(node) && isAttributeReader(node))
1518
+ return node.arguments.find(
1519
+ (argument) => ts5.isIdentifier(argument) && NAMED_SET_PATTERN.test(argument.text)
1520
+ )?.text;
1521
+ return void 0;
1522
+ }
1523
+ function withoutAssertion(node) {
1524
+ if (node === void 0) return void 0;
1525
+ if (ts5.isAsExpression(node) || ts5.isSatisfiesExpression(node))
1526
+ return withoutAssertion(node.expression);
1527
+ return node;
1528
+ }
1529
+
1530
+ // src/lib/api/source-file-functions.ts
1531
+ import ts6 from "typescript";
1261
1532
  function parseSourceFile(params) {
1262
1533
  const { file, text } = params;
1263
- const source = ts5.createSourceFile(file, text, ts5.ScriptTarget.Latest, true);
1534
+ const source = ts6.createSourceFile(file, text, ts6.ScriptTarget.Latest, true);
1264
1535
  const syntaxError = firstSyntaxErrorOf({ source });
1265
1536
  if (syntaxError !== void 0)
1266
1537
  return {
@@ -1270,7 +1541,46 @@ function parseSourceFile(params) {
1270
1541
  return {
1271
1542
  entries: exportedFunctionsOf(source).map(function entryOfFunction(found) {
1272
1543
  return sourceEntry({ file, source, found });
1273
- })
1544
+ }),
1545
+ facts: factsOf(source)
1546
+ };
1547
+ }
1548
+ function factsOf(source) {
1549
+ const imports = importsOf(source);
1550
+ const imported = localSpecifiersOf(imports);
1551
+ const lists = stringListsOf(source);
1552
+ const listed = locallyExportedNames(source);
1553
+ return {
1554
+ functions: topLevelFunctionsOf(source).map(function functionFactsOf(found) {
1555
+ const { node } = found;
1556
+ const signature = tokenHashOf({
1557
+ texts: [
1558
+ ...(node.typeParameters ?? []).map((part) => part.getText(source)),
1559
+ ...node.parameters.map((part) => part.getText(source)),
1560
+ ...node.type ? [node.type.getText(source)] : []
1561
+ ]
1562
+ });
1563
+ const body = tokenHashOf({ texts: node.body ? [node.body.getText(source)] : [] });
1564
+ const summary = summaryOf(
1565
+ ts6.getJSDocCommentsAndTags(found.documented).filter(ts6.isJSDoc).at(-1)
1566
+ );
1567
+ return {
1568
+ name: found.name,
1569
+ line: source.getLineAndCharacterOfPosition(found.declaration.getStart(source)).line + 1,
1570
+ exportedAs: [
1571
+ .../* @__PURE__ */ new Set([...found.exported ? [found.name] : [], ...listed.get(found.name) ?? []])
1572
+ ],
1573
+ ...summary !== void 0 && { summary },
1574
+ signatureHash: signature.hash,
1575
+ bodyHash: body.hash,
1576
+ bodyTokenCount: body.count,
1577
+ signatureTypes: typeReferencesOf([...node.parameters, ...node.type ? [node.type] : []]),
1578
+ readKeys: readKeysOf({ node, lists }),
1579
+ calls: callsOf({ node, imported })
1580
+ };
1581
+ }),
1582
+ imports,
1583
+ types: typesOf(source)
1274
1584
  };
1275
1585
  }
1276
1586
  function exportedFunctionsOf(source) {
@@ -1290,9 +1600,9 @@ function exportedFunctionsOf(source) {
1290
1600
  function locallyExportedNames(source) {
1291
1601
  const names = /* @__PURE__ */ new Map();
1292
1602
  for (const statement of source.statements) {
1293
- if (!ts5.isExportDeclaration(statement) || statement.moduleSpecifier !== void 0) continue;
1603
+ if (!ts6.isExportDeclaration(statement) || statement.moduleSpecifier !== void 0) continue;
1294
1604
  if (statement.isTypeOnly || statement.exportClause === void 0) continue;
1295
- if (!ts5.isNamedExports(statement.exportClause)) continue;
1605
+ if (!ts6.isNamedExports(statement.exportClause)) continue;
1296
1606
  for (const element of statement.exportClause.elements) {
1297
1607
  if (element.isTypeOnly) continue;
1298
1608
  const local = (element.propertyName ?? element.name).text;
@@ -1305,7 +1615,7 @@ function topLevelFunctionsOf(source) {
1305
1615
  const found = [];
1306
1616
  const overloads = /* @__PURE__ */ new Map();
1307
1617
  for (const statement of source.statements) {
1308
- if (ts5.isFunctionDeclaration(statement) && statement.name !== void 0) {
1618
+ if (ts6.isFunctionDeclaration(statement) && statement.name !== void 0) {
1309
1619
  const name = statement.name.text;
1310
1620
  const set = [...overloads.get(name) ?? [], statement];
1311
1621
  if (statement.body === void 0) {
@@ -1320,7 +1630,7 @@ function topLevelFunctionsOf(source) {
1320
1630
  documented: set.find(hasJsDoc) ?? statement,
1321
1631
  exported: set.some(isExported)
1322
1632
  });
1323
- } else if (ts5.isVariableStatement(statement) && statement.declarationList.flags & ts5.NodeFlags.Const)
1633
+ } else if (ts6.isVariableStatement(statement) && statement.declarationList.flags & ts6.NodeFlags.Const)
1324
1634
  found.push(...constFunctionsOf(statement));
1325
1635
  }
1326
1636
  return found;
@@ -1330,23 +1640,23 @@ function constFunctionsOf(statement) {
1330
1640
  return statement.declarationList.declarations.flatMap(
1331
1641
  function functionOfDeclaration(declaration) {
1332
1642
  const { initializer, name } = declaration;
1333
- if (!ts5.isIdentifier(name) || initializer === void 0) return [];
1334
- if (!ts5.isArrowFunction(initializer) && !ts5.isFunctionExpression(initializer)) return [];
1643
+ if (!ts6.isIdentifier(name) || initializer === void 0) return [];
1644
+ if (!ts6.isArrowFunction(initializer) && !ts6.isFunctionExpression(initializer)) return [];
1335
1645
  return [{ name: name.text, node: initializer, declaration, documented: statement, exported }];
1336
1646
  }
1337
1647
  );
1338
1648
  }
1339
1649
  function hasJsDoc(node) {
1340
- return ts5.getJSDocCommentsAndTags(node).some(ts5.isJSDoc);
1650
+ return ts6.getJSDocCommentsAndTags(node).some(ts6.isJSDoc);
1341
1651
  }
1342
1652
  function isExported(statement) {
1343
- return ts5.canHaveModifiers(statement) && (ts5.getModifiers(statement) ?? []).some(function isExportKeyword(modifier) {
1344
- return modifier.kind === ts5.SyntaxKind.ExportKeyword;
1653
+ return ts6.canHaveModifiers(statement) && (ts6.getModifiers(statement) ?? []).some(function isExportKeyword(modifier) {
1654
+ return modifier.kind === ts6.SyntaxKind.ExportKeyword;
1345
1655
  });
1346
1656
  }
1347
1657
  function sourceEntry(params) {
1348
1658
  const { file, source, found } = params;
1349
- const jsDoc = ts5.getJSDocCommentsAndTags(found.documented).filter(ts5.isJSDoc).at(-1);
1659
+ const jsDoc = ts6.getJSDocCommentsAndTags(found.documented).filter(ts6.isJSDoc).at(-1);
1350
1660
  const line = source.getLineAndCharacterOfPosition(found.declaration.getStart(source)).line + 1;
1351
1661
  return {
1352
1662
  path: `${file}#${found.name}`,
@@ -1361,58 +1671,58 @@ function sourceEntry(params) {
1361
1671
  };
1362
1672
  }
1363
1673
  function summaryOf(jsDoc) {
1364
- const text = (ts5.getTextOfJSDocComment(jsDoc?.comment) ?? "").replace(/\s+/g, " ").trim();
1674
+ const text = (ts6.getTextOfJSDocComment(jsDoc?.comment) ?? "").replace(/\s+/g, " ").trim();
1365
1675
  return text === "" ? void 0 : firstSentence(text);
1366
1676
  }
1367
1677
  function intentsOf2(jsDoc) {
1368
1678
  return (jsDoc?.tags ?? []).filter(function isIntentTag(tag) {
1369
1679
  return tag.tagName.text === INTENT_TAG;
1370
1680
  }).flatMap(function intentsOfTag(tag) {
1371
- return parseIntentText(ts5.getTextOfJSDocComment(tag.comment) ?? "");
1681
+ return parseIntentText(ts6.getTextOfJSDocComment(tag.comment) ?? "");
1372
1682
  });
1373
1683
  }
1374
1684
  function signatureOf2(params) {
1375
1685
  const { source, node } = params;
1376
1686
  function print(part) {
1377
- return oneLine(SIGNATURE_PRINTER.printNode(ts5.EmitHint.Unspecified, part, source));
1687
+ return oneLine(SIGNATURE_PRINTER.printNode(ts6.EmitHint.Unspecified, part, source));
1378
1688
  }
1379
1689
  const typeParameters = node.typeParameters ? `<${node.typeParameters.map(print).join(", ")}>` : "";
1380
1690
  const returnType = node.type ? `: ${print(node.type)}` : "";
1381
1691
  return `${typeParameters}(${node.parameters.map(print).join(", ")})${returnType}`;
1382
1692
  }
1383
1693
  function oneLine(printed2) {
1384
- const scanner = ts5.createScanner(
1385
- ts5.ScriptTarget.Latest,
1694
+ const scanner = ts6.createScanner(
1695
+ ts6.ScriptTarget.Latest,
1386
1696
  false,
1387
- ts5.LanguageVariant.Standard,
1697
+ ts6.LanguageVariant.Standard,
1388
1698
  printed2
1389
1699
  );
1390
1700
  const tokens = [];
1391
1701
  const open = [];
1392
1702
  let spaced = false;
1393
- for (let kind = scanner.scan(); kind !== ts5.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
1394
- if (kind === ts5.SyntaxKind.WhitespaceTrivia || kind === ts5.SyntaxKind.NewLineTrivia) {
1703
+ for (let kind = scanner.scan(); kind !== ts6.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
1704
+ if (kind === ts6.SyntaxKind.WhitespaceTrivia || kind === ts6.SyntaxKind.NewLineTrivia) {
1395
1705
  spaced = tokens.length > 0;
1396
1706
  continue;
1397
1707
  }
1398
- if (kind === ts5.SyntaxKind.CloseBraceToken && open.at(-1) === ts5.SyntaxKind.TemplateHead) {
1708
+ if (kind === ts6.SyntaxKind.CloseBraceToken && open.at(-1) === ts6.SyntaxKind.TemplateHead) {
1399
1709
  kind = scanner.reScanTemplateToken(false);
1400
- if (kind === ts5.SyntaxKind.TemplateTail) open.pop();
1401
- } else if (kind === ts5.SyntaxKind.OpenBraceToken || kind === ts5.SyntaxKind.TemplateHead)
1710
+ if (kind === ts6.SyntaxKind.TemplateTail) open.pop();
1711
+ } else if (kind === ts6.SyntaxKind.OpenBraceToken || kind === ts6.SyntaxKind.TemplateHead)
1402
1712
  open.push(kind);
1403
- else if (kind === ts5.SyntaxKind.CloseBraceToken) open.pop();
1713
+ else if (kind === ts6.SyntaxKind.CloseBraceToken) open.pop();
1404
1714
  tokens.push({ kind, text: scanner.getTokenText(), spaced });
1405
1715
  spaced = false;
1406
1716
  }
1407
1717
  return tokens.filter(function keptToken(token, index) {
1408
- return !(token.kind === ts5.SyntaxKind.SemicolonToken && tokens[index + 1]?.kind === ts5.SyntaxKind.CloseBraceToken);
1718
+ return !(token.kind === ts6.SyntaxKind.SemicolonToken && tokens[index + 1]?.kind === ts6.SyntaxKind.CloseBraceToken);
1409
1719
  }).map(function textOfToken(token) {
1410
1720
  return token.spaced ? ` ${token.text}` : token.text;
1411
1721
  }).join("");
1412
1722
  }
1413
1723
 
1414
1724
  // src/lib/api/source-index.ts
1415
- import { createHash } from "crypto";
1725
+ import { createHash as createHash2 } from "crypto";
1416
1726
  import { readFileSync as readFileSync10 } from "fs";
1417
1727
  import { join as join17 } from "path";
1418
1728
 
@@ -1457,7 +1767,7 @@ function indexSourceFiles(params) {
1457
1767
  const answer = files.map(function parseChangedFile(file) {
1458
1768
  const key = `${prefix}${file}`;
1459
1769
  const bytes = readFileSync10(join17(root, file));
1460
- const hash = createHash("sha256").update(bytes).digest("hex");
1770
+ const hash = createHash2("sha256").update(bytes).digest("hex");
1461
1771
  const known = cached?.files[key];
1462
1772
  if (known !== void 0 && known.hash === hash) {
1463
1773
  next.files[key] = known;
@@ -1500,8 +1810,8 @@ function isCache(value) {
1500
1810
  if (schema !== SOURCE_INDEX_SCHEMA || typeof files !== "object" || files === null) return false;
1501
1811
  return Object.values(files).every(function isCachedFile(file) {
1502
1812
  if (typeof file !== "object" || file === null) return false;
1503
- const { hash, entries, note } = file;
1504
- return typeof hash === "string" && Array.isArray(entries) && entries.every(isCachedEntry) && (note === void 0 || typeof note === "string");
1813
+ const { hash, entries, note, facts } = file;
1814
+ return typeof hash === "string" && Array.isArray(entries) && entries.every(isCachedEntry) && (note === void 0 || typeof note === "string") && (facts === void 0 || isCachedFacts(facts));
1505
1815
  });
1506
1816
  }
1507
1817
  function isCachedEntry(value) {
@@ -1514,8 +1824,17 @@ function isStringList(value) {
1514
1824
  return typeof item === "string";
1515
1825
  });
1516
1826
  }
1827
+ function isCachedFacts(value) {
1828
+ if (typeof value !== "object" || value === null) return false;
1829
+ const { functions, imports, types } = value;
1830
+ return Array.isArray(functions) && Array.isArray(imports) && Array.isArray(types);
1831
+ }
1517
1832
  function parsedOf(known) {
1518
- return known.note === void 0 ? { entries: known.entries } : { entries: known.entries, note: known.note };
1833
+ return {
1834
+ entries: known.entries,
1835
+ ...known.facts !== void 0 && { facts: known.facts },
1836
+ ...known.note !== void 0 && { note: known.note }
1837
+ };
1519
1838
  }
1520
1839
  function writeCache(params) {
1521
1840
  try {
@@ -1550,9 +1869,10 @@ function listSourceFiles(root) {
1550
1869
  }) : listTreeFiles(join18(root, SOURCE_FOLDER)).map(function pathFromRoot(file) {
1551
1870
  return `${SOURCE_FOLDER}/${file}`;
1552
1871
  });
1553
- return files.filter(function isSourceFile(file) {
1554
- return SOURCE_FILE_PATTERN.test(file) && !TEST_FILE_PATTERN.test(file);
1555
- }).sort(TEXT_COLLATOR.compare);
1872
+ return files.filter(isSourceFilePath).sort(TEXT_COLLATOR.compare);
1873
+ }
1874
+ function isSourceFilePath(file) {
1875
+ return file.startsWith(`${SOURCE_FOLDER}/`) && SOURCE_FILE_PATTERN.test(file) && !TEST_FILE_PATTERN.test(file);
1556
1876
  }
1557
1877
 
1558
1878
  // src/lib/api/source-lookup.ts
@@ -3093,11 +3413,11 @@ async function readSchemaDialectes(params) {
3093
3413
  }
3094
3414
 
3095
3415
  // src/lib/knowledge/ask/load-standard-indexes.ts
3096
- import { createHash as createHash5 } from "crypto";
3416
+ import { createHash as createHash6 } from "crypto";
3097
3417
  import { readFileSync as readFileSync18 } from "fs";
3098
3418
 
3099
3419
  // src/lib/knowledge/standard/ensure-standard-index.ts
3100
- import { createHash as createHash2 } from "crypto";
3420
+ import { createHash as createHash3 } from "crypto";
3101
3421
  import { existsSync as existsSync22, readdirSync as readdirSync11, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync5 } from "fs";
3102
3422
  import { join as join27 } from "path";
3103
3423
 
@@ -4523,11 +4843,11 @@ function nextTurn() {
4523
4843
  });
4524
4844
  }
4525
4845
  function sha256Of(content) {
4526
- return createHash2("sha256").update(content).digest("hex");
4846
+ return createHash3("sha256").update(content).digest("hex");
4527
4847
  }
4528
4848
 
4529
4849
  // src/lib/knowledge/standard/read-installed-vocabulary.ts
4530
- import { createHash as createHash3 } from "crypto";
4850
+ import { createHash as createHash4 } from "crypto";
4531
4851
  import { existsSync as existsSync23 } from "fs";
4532
4852
  import { join as join28 } from "path";
4533
4853
  async function readInstalledVocabulary(params) {
@@ -4565,7 +4885,7 @@ function vocabularyOf(params) {
4565
4885
  values: [...values].sort()
4566
4886
  },
4567
4887
  packages,
4568
- installedHash: createHash3("sha256").update(packages.join(INSTALLED_LIST_SEPARATOR)).digest("hex").slice(0, INSTALLED_HASH_LENGTH)
4888
+ installedHash: createHash4("sha256").update(packages.join(INSTALLED_LIST_SEPARATOR)).digest("hex").slice(0, INSTALLED_HASH_LENGTH)
4569
4889
  };
4570
4890
  }
4571
4891
  function versionOf(params) {
@@ -4772,7 +5092,7 @@ function standardCacheRoot(params) {
4772
5092
  }
4773
5093
 
4774
5094
  // src/lib/knowledge/standard/standard-files-key.ts
4775
- import { createHash as createHash4 } from "crypto";
5095
+ import { createHash as createHash5 } from "crypto";
4776
5096
  import { readFileSync as readFileSync17 } from "fs";
4777
5097
 
4778
5098
  // src/lib/stable-json.ts
@@ -4820,7 +5140,7 @@ function standardFilesKey(params) {
4820
5140
  return `${STANDARD_FILES_KEY_PREFIX}${sha256Of2(stableJson(pairs))}`;
4821
5141
  }
4822
5142
  function sha256Of2(content) {
4823
- return createHash4("sha256").update(content).digest("hex");
5143
+ return createHash5("sha256").update(content).digest("hex");
4824
5144
  }
4825
5145
 
4826
5146
  // src/lib/knowledge/ask/ask.constants.ts
@@ -4927,7 +5247,7 @@ function filesReadOf(params) {
4927
5247
  return {
4928
5248
  manifest: {
4929
5249
  id: file.id,
4930
- sha256: createHash5(SETUP_HASH_ALGORITHM).update(bytes).digest(SETUP_HASH_ENCODING),
5250
+ sha256: createHash6(SETUP_HASH_ALGORITHM).update(bytes).digest(SETUP_HASH_ENCODING),
4931
5251
  lines: params.search.files.find((index) => index.fileId === file.id)?.lineCount ?? 0
4932
5252
  },
4933
5253
  lines: bytes.toString("utf8").split(LINE_BREAK_PATTERN)
@@ -17,9 +17,31 @@
17
17
  },
18
18
  "noForbiddenWordsList": { "type": "string" },
19
19
  "queryInLoopNotRun": { "type": "string" },
20
+ "releasedChangelogNotJudged": { "type": "string" },
20
21
  "dialecteChanges": { "type": "array", "items": { "$ref": "#/$defs/dialecteChange" } },
21
22
  "notJudged": { "type": "integer", "minimum": 1 },
22
- "baseLine": { "type": "string" }
23
+ "baseLine": { "type": "string" },
24
+ "qualityLine": { "type": "string" },
25
+ "quality": {
26
+ "type": "object",
27
+ "required": ["base", "examined", "duplicates", "sharedExports", "publicApi", "docs"],
28
+ "properties": {
29
+ "base": {
30
+ "type": "object",
31
+ "required": ["commit", "source"],
32
+ "properties": {
33
+ "commit": { "type": "string" },
34
+ "source": { "enum": ["lot", "base-branch", "flag"] }
35
+ }
36
+ },
37
+ "examined": { "type": "array", "items": { "type": "string" } },
38
+ "duplicates": { "type": "array", "items": { "type": "object" } },
39
+ "sharedExports": { "type": "array", "items": { "type": "object" } },
40
+ "publicApi": { "type": "object", "required": ["kind"] },
41
+ "docs": { "type": "array", "items": { "type": "object" } },
42
+ "aliasesChanged": { "type": "boolean" }
43
+ }
44
+ }
23
45
  },
24
46
  "$defs": {
25
47
  "finding": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialecte/cli",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Dialecte CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "files": [
14
14
  "dist",
15
+ "templates",
15
16
  "README.md"
16
17
  ],
17
18
  "type": "module",
@@ -146,11 +147,23 @@
146
147
  "src/lib/worktree/prune-worktrees.ts",
147
148
  "src/lib/handover/commit-lots.ts",
148
149
  "src/lib/handover/run-handover-folder.ts",
150
+ "src/lib/handover/archived-declarations.ts",
151
+ "src/lib/worktree/lot-files.ts",
149
152
  "src/lib/handover/close-handovers.ts",
150
153
  "src/lib/handover/abandon-handover.ts",
151
154
  "src/lib/handover/handover-store.ts",
152
155
  "src/lib/handover/handover-lock.ts",
153
- "src/lib/handover/sync-node-modules.ts"
156
+ "src/lib/handover/sync-node-modules.ts",
157
+ "src/lib/landing/**",
158
+ "src/lib/gate-records/**",
159
+ "src/lib/pr/**",
160
+ "src/lib/plan/**",
161
+ "src/lib/risk/**",
162
+ "src/lib/design/**",
163
+ "src/lib/gate/hook-gate.ts",
164
+ "src/lib/gate/hook-tdd.ts",
165
+ "src/lib/gate/hook-design.ts",
166
+ "src/lib/tdd/check-tdd-receipts.ts"
154
167
  ]
155
168
  },
156
169
  "stepEvents": 1,