@dialecte/cli 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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
  }
@@ -527,6 +536,8 @@ import { basename as basename2, dirname as dirname3, isAbsolute as isAbsolute2,
527
536
 
528
537
  // src/lib/git.constants.ts
529
538
  var GIT_READ_ENVIRONMENT = { GIT_OPTIONAL_LOCKS: "0" };
539
+ var GIT_FLOOR = [2, 38];
540
+ var GIT_VERSION_PATTERN = /^git version (?<version>(?<major>\d+)\.(?<minor>\d+)\S*)/;
530
541
 
531
542
  // src/lib/worktree/worktree.constants.ts
532
543
  var MINUTE_MS = 60 * 1e3;
@@ -566,6 +577,20 @@ function gitFolderOf(root) {
566
577
  function isInWorkTree(root) {
567
578
  return tryReadGit({ root, args: ["rev-parse", "--is-inside-work-tree"] })?.trim() === "true";
568
579
  }
580
+ function gitVersionOf(params) {
581
+ const line = params.text.trim();
582
+ const groups = GIT_VERSION_PATTERN.exec(line)?.groups;
583
+ if (groups?.version === void 0) return void 0;
584
+ return { major: Number(groups.major), minor: Number(groups.minor), version: groups.version, line };
585
+ }
586
+ function belowGitFloor(params) {
587
+ const [floorMajor, floorMinor] = GIT_FLOOR;
588
+ const { major, minor } = params.version;
589
+ return major < floorMajor || major === floorMajor && minor < floorMinor;
590
+ }
591
+ function readGitVersion(params) {
592
+ return readGit({ root: params.root, args: ["--version"] });
593
+ }
569
594
 
570
595
  // src/lib/gate/step-source.ts
571
596
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
@@ -722,6 +747,7 @@ var TEMPORARY_FILE_SUFFIX_PATTERN = /^\.tmp-(\d+)-\d+$/;
722
747
  var WRITABLE_MODE = 420;
723
748
  var PERMISSION_BITS = 511;
724
749
  var REPLACED_LINK_REFUSAL = "refused to replace a symbolic link";
750
+ var GIT_ENTRY = ".git";
725
751
 
726
752
  // src/lib/store/publish.ts
727
753
  import {
@@ -806,6 +832,7 @@ var DECISION_STATES = [
806
832
  "accepted <reason>",
807
833
  "logged <where>"
808
834
  ];
835
+ var LOT_COMMAND = "lot";
809
836
  var CHOICE_OPTIONS = ["by"];
810
837
  var DECIDE_USAGE = `lot decide: expected <id|folder> <finding> <state...>; states: ${DECISION_STATES.join(", ")}`;
811
838
  var SNAPSHOT_OPTIONS = ["round", "by", "reason"];
@@ -1256,11 +1283,273 @@ function singleFileHost(source) {
1256
1283
  };
1257
1284
  }
1258
1285
 
1259
- // src/lib/api/source-file-functions.ts
1286
+ // src/lib/api/read-keys.ts
1287
+ import { createHash } from "crypto";
1288
+
1289
+ // src/lib/api/read-keys.constants.ts
1290
+ var ATTRIBUTE_READERS = [
1291
+ "getAttribute",
1292
+ "getAttributes",
1293
+ "readAttribute",
1294
+ "readAttributes"
1295
+ ];
1296
+ var ATTRIBUTE_BINDING_PATTERN = /^(?:attributes|attrs|\w*Attributes)$/;
1297
+ var TAG_PROPERTIES = ["tagName", "tag"];
1298
+ var ITERATING_METHODS = [
1299
+ "map",
1300
+ "flatMap",
1301
+ "forEach",
1302
+ "filter",
1303
+ "some",
1304
+ "every"
1305
+ ];
1306
+ var NAMED_SET_PATTERN = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$|^[A-Z]{2,}$/;
1307
+ var TOKEN_SEPARATOR = "\0";
1308
+
1309
+ // src/lib/api/read-keys.ts
1260
1310
  import ts5 from "typescript";
1311
+ function readKeysOf(params) {
1312
+ const elements = /* @__PURE__ */ new Set();
1313
+ const attributes = /* @__PURE__ */ new Set();
1314
+ const sets = /* @__PURE__ */ new Set();
1315
+ const bindings = attributeBindingsOf(params.node);
1316
+ let readsAttributes = false;
1317
+ function visit(node) {
1318
+ elementOf(node)?.forEach((element) => elements.add(element));
1319
+ if (ts5.isCallExpression(node) && isAttributeReader(node)) {
1320
+ readsAttributes = true;
1321
+ for (const argument of node.arguments)
1322
+ attributesOfArgument(argument).forEach((name) => attributes.add(name));
1323
+ }
1324
+ attributeOfAccess({ node, bindings })?.forEach((name) => attributes.add(name));
1325
+ const set = namedSetOf(node);
1326
+ if (set !== void 0) sets.add(set);
1327
+ ts5.forEachChild(node, visit);
1328
+ }
1329
+ visit(params.node);
1330
+ const namedSets = readsAttributes ? [...sets] : [];
1331
+ for (const set of namedSets) params.lists.get(set)?.forEach((name) => attributes.add(name));
1332
+ return {
1333
+ elements: [...elements].sort(),
1334
+ attributes: [...attributes].sort(),
1335
+ namedSets: namedSets.filter((set) => !params.lists.has(set)).sort()
1336
+ };
1337
+ }
1338
+ function callsOf(params) {
1339
+ const calls = /* @__PURE__ */ new Map();
1340
+ function visit(node) {
1341
+ if (ts5.isCallExpression(node) && ts5.isIdentifier(node.expression)) {
1342
+ const name = node.expression.text;
1343
+ const specifier = params.imported.get(name);
1344
+ if (!calls.has(name))
1345
+ calls.set(name, specifier === void 0 ? { name } : { name, specifier });
1346
+ }
1347
+ ts5.forEachChild(node, visit);
1348
+ }
1349
+ visit(params.node);
1350
+ return [...calls.values()];
1351
+ }
1352
+ function tokenHashOf(params) {
1353
+ const tokens = params.texts.flatMap(tokensOf);
1354
+ return {
1355
+ hash: createHash("sha256").update(tokens.join(TOKEN_SEPARATOR)).digest("hex"),
1356
+ count: tokens.length
1357
+ };
1358
+ }
1359
+ function typeReferencesOf(nodes) {
1360
+ const names = /* @__PURE__ */ new Set();
1361
+ function visit(node) {
1362
+ if (ts5.isTypeReferenceNode(node)) names.add(node.typeName.getText());
1363
+ ts5.forEachChild(node, visit);
1364
+ }
1365
+ nodes.forEach(visit);
1366
+ return [...names].sort();
1367
+ }
1368
+ function importsOf(source) {
1369
+ return source.statements.flatMap(function importOf(statement) {
1370
+ const line = source.getLineAndCharacterOfPosition(statement.getStart(source)).line + 1;
1371
+ if (ts5.isImportDeclaration(statement)) return importDeclarationOf({ statement, line });
1372
+ if (ts5.isExportDeclaration(statement)) return exportDeclarationOf({ statement, line });
1373
+ return [];
1374
+ });
1375
+ }
1376
+ function typesOf(source) {
1377
+ return source.statements.flatMap(function typeOf2(statement) {
1378
+ if (!ts5.isTypeAliasDeclaration(statement) && !ts5.isInterfaceDeclaration(statement)) return [];
1379
+ return [
1380
+ { name: statement.name.text, hash: tokenHashOf({ texts: [statement.getText(source)] }).hash }
1381
+ ];
1382
+ });
1383
+ }
1384
+ function stringListsOf(source) {
1385
+ const lists = /* @__PURE__ */ new Map();
1386
+ for (const statement of source.statements) {
1387
+ if (!ts5.isVariableStatement(statement)) continue;
1388
+ for (const declaration of statement.declarationList.declarations) {
1389
+ const value = withoutAssertion(declaration.initializer);
1390
+ if (!ts5.isIdentifier(declaration.name) || value === void 0) continue;
1391
+ if (!ts5.isArrayLiteralExpression(value)) continue;
1392
+ if (!value.elements.every(ts5.isStringLiteral)) continue;
1393
+ lists.set(
1394
+ declaration.name.text,
1395
+ value.elements.map((element) => element.text)
1396
+ );
1397
+ }
1398
+ }
1399
+ return lists;
1400
+ }
1401
+ function localSpecifiersOf(imports) {
1402
+ return new Map(
1403
+ imports.filter((found) => !found.reexport).flatMap((found) => found.names.map((name) => [name.local, found.specifier]))
1404
+ );
1405
+ }
1406
+ function importDeclarationOf(params) {
1407
+ const { statement, line } = params;
1408
+ const clause = statement.importClause;
1409
+ if (clause === void 0 || clause.isTypeOnly || !ts5.isStringLiteral(statement.moduleSpecifier))
1410
+ return [];
1411
+ const specifier = statement.moduleSpecifier.text;
1412
+ const bindings = clause.namedBindings;
1413
+ if (bindings !== void 0 && ts5.isNamespaceImport(bindings))
1414
+ return [
1415
+ {
1416
+ specifier,
1417
+ line,
1418
+ names: [{ imported: "*", local: bindings.name.text }],
1419
+ reexport: false,
1420
+ all: true
1421
+ }
1422
+ ];
1423
+ const named = bindings === void 0 ? [] : bindings.elements.filter((element) => !element.isTypeOnly).map((element) => ({
1424
+ imported: (element.propertyName ?? element.name).text,
1425
+ local: element.name.text
1426
+ }));
1427
+ const names = clause.name === void 0 ? named : [{ imported: "default", local: clause.name.text }, ...named];
1428
+ return names.length ? [{ specifier, line, names, reexport: false }] : [];
1429
+ }
1430
+ function exportDeclarationOf(params) {
1431
+ const { statement, line } = params;
1432
+ const module = statement.moduleSpecifier;
1433
+ if (module === void 0 || statement.isTypeOnly || !ts5.isStringLiteral(module)) return [];
1434
+ const specifier = module.text;
1435
+ const clause = statement.exportClause;
1436
+ if (clause === void 0) return [{ specifier, line, names: [], reexport: true, all: true }];
1437
+ if (ts5.isNamespaceExport(clause))
1438
+ return [
1439
+ {
1440
+ specifier,
1441
+ line,
1442
+ names: [{ imported: "*", local: clause.name.text }],
1443
+ reexport: true,
1444
+ all: true
1445
+ }
1446
+ ];
1447
+ const names = clause.elements.filter((element) => !element.isTypeOnly).map((element) => ({
1448
+ imported: (element.propertyName ?? element.name).text,
1449
+ local: element.name.text
1450
+ }));
1451
+ return [{ specifier, line, names, reexport: true }];
1452
+ }
1453
+ function tokensOf(text) {
1454
+ const scanner = ts5.createScanner(ts5.ScriptTarget.Latest, true, ts5.LanguageVariant.Standard, text);
1455
+ const tokens = [];
1456
+ for (let kind = scanner.scan(); kind !== ts5.SyntaxKind.EndOfFileToken; kind = scanner.scan())
1457
+ if (kind !== ts5.SyntaxKind.SemicolonToken) tokens.push(scanner.getTokenText());
1458
+ return tokens;
1459
+ }
1460
+ function elementOf(node) {
1461
+ if (ts5.isBinaryExpression(node) && isEquality(node.operatorToken.kind)) {
1462
+ const literal = [node.left, node.right].find(ts5.isStringLiteral);
1463
+ const other = literal === node.left ? node.right : node.left;
1464
+ if (literal !== void 0 && isTagAccess(other)) return [literal.text];
1465
+ }
1466
+ if (ts5.isPropertyAssignment(node) && ts5.isIdentifier(node.name) && TAG_PROPERTIES.includes(node.name.text) && ts5.isStringLiteral(node.initializer))
1467
+ return [node.initializer.text];
1468
+ if ((ts5.isTypeReferenceNode(node) || ts5.isCallExpression(node)) && node.typeArguments !== void 0)
1469
+ return node.typeArguments.flatMap(stringLiteralTypeOf);
1470
+ return void 0;
1471
+ }
1472
+ function isEquality(kind) {
1473
+ return kind === ts5.SyntaxKind.EqualsEqualsEqualsToken || kind === ts5.SyntaxKind.ExclamationEqualsEqualsToken || kind === ts5.SyntaxKind.EqualsEqualsToken || kind === ts5.SyntaxKind.ExclamationEqualsToken;
1474
+ }
1475
+ function isTagAccess(node) {
1476
+ return ts5.isPropertyAccessExpression(node) && TAG_PROPERTIES.includes(node.name.text);
1477
+ }
1478
+ function stringLiteralTypeOf(node) {
1479
+ return ts5.isLiteralTypeNode(node) && ts5.isStringLiteral(node.literal) ? [node.literal.text] : [];
1480
+ }
1481
+ function isAttributeReader(node) {
1482
+ const callee = node.expression;
1483
+ const name = ts5.isIdentifier(callee) ? callee.text : ts5.isPropertyAccessExpression(callee) ? callee.name.text : void 0;
1484
+ return name !== void 0 && ATTRIBUTE_READERS.includes(name);
1485
+ }
1486
+ function attributesOfArgument(argument) {
1487
+ if (ts5.isStringLiteral(argument)) return [argument.text];
1488
+ if (!ts5.isObjectLiteralExpression(argument)) return [];
1489
+ return argument.properties.flatMap(function attributesOfProperty(property) {
1490
+ if (!ts5.isPropertyAssignment(property) || !ts5.isIdentifier(property.name)) return [];
1491
+ const value = withoutAssertion(property.initializer);
1492
+ if (property.name.text === "name" && value !== void 0 && ts5.isStringLiteral(value))
1493
+ return [value.text];
1494
+ if (property.name.text === "names" && value !== void 0 && ts5.isArrayLiteralExpression(value))
1495
+ return value.elements.filter(ts5.isStringLiteral).map((element) => element.text);
1496
+ return [];
1497
+ });
1498
+ }
1499
+ function attributeBindingsOf(node) {
1500
+ const bindings = /* @__PURE__ */ new Set();
1501
+ function visit(child) {
1502
+ if ((ts5.isParameter(child) || ts5.isVariableDeclaration(child)) && ts5.isIdentifier(child.name)) {
1503
+ const typeName2 = child.type !== void 0 && ts5.isTypeReferenceNode(child.type) ? child.type.typeName.getText() : "";
1504
+ if (ATTRIBUTE_BINDING_PATTERN.test(typeName2)) bindings.add(child.name.text);
1505
+ }
1506
+ ts5.forEachChild(child, visit);
1507
+ }
1508
+ visit(node);
1509
+ return bindings;
1510
+ }
1511
+ function isAttributeBinding(params) {
1512
+ const { node } = params;
1513
+ if (ts5.isIdentifier(node))
1514
+ return ATTRIBUTE_BINDING_PATTERN.test(node.text) || params.bindings.has(node.text);
1515
+ return ts5.isPropertyAccessExpression(node) && ATTRIBUTE_BINDING_PATTERN.test(node.name.text);
1516
+ }
1517
+ function attributeOfAccess(params) {
1518
+ const { node, bindings } = params;
1519
+ if (ts5.isPropertyAccessExpression(node) && isAttributeBinding({ node: node.expression, bindings }))
1520
+ return [node.name.text];
1521
+ if (ts5.isElementAccessExpression(node) && ts5.isStringLiteral(node.argumentExpression) && isAttributeBinding({ node: node.expression, bindings }))
1522
+ return [node.argumentExpression.text];
1523
+ if (ts5.isVariableDeclaration(node) && ts5.isObjectBindingPattern(node.name) && node.initializer !== void 0 && isAttributeBinding({ node: node.initializer, bindings }))
1524
+ return node.name.elements.flatMap(function nameOf(element) {
1525
+ const key = element.propertyName ?? element.name;
1526
+ return ts5.isIdentifier(key) ? [key.text] : [];
1527
+ });
1528
+ return void 0;
1529
+ }
1530
+ function namedSetOf(node) {
1531
+ if (ts5.isPropertyAccessExpression(node) && ITERATING_METHODS.includes(node.name.text) && ts5.isIdentifier(node.expression) && NAMED_SET_PATTERN.test(node.expression.text))
1532
+ return node.expression.text;
1533
+ if (ts5.isForOfStatement(node) && ts5.isIdentifier(node.expression) && NAMED_SET_PATTERN.test(node.expression.text))
1534
+ return node.expression.text;
1535
+ if (ts5.isCallExpression(node) && isAttributeReader(node))
1536
+ return node.arguments.find(
1537
+ (argument) => ts5.isIdentifier(argument) && NAMED_SET_PATTERN.test(argument.text)
1538
+ )?.text;
1539
+ return void 0;
1540
+ }
1541
+ function withoutAssertion(node) {
1542
+ if (node === void 0) return void 0;
1543
+ if (ts5.isAsExpression(node) || ts5.isSatisfiesExpression(node))
1544
+ return withoutAssertion(node.expression);
1545
+ return node;
1546
+ }
1547
+
1548
+ // src/lib/api/source-file-functions.ts
1549
+ import ts6 from "typescript";
1261
1550
  function parseSourceFile(params) {
1262
1551
  const { file, text } = params;
1263
- const source = ts5.createSourceFile(file, text, ts5.ScriptTarget.Latest, true);
1552
+ const source = ts6.createSourceFile(file, text, ts6.ScriptTarget.Latest, true);
1264
1553
  const syntaxError = firstSyntaxErrorOf({ source });
1265
1554
  if (syntaxError !== void 0)
1266
1555
  return {
@@ -1270,7 +1559,46 @@ function parseSourceFile(params) {
1270
1559
  return {
1271
1560
  entries: exportedFunctionsOf(source).map(function entryOfFunction(found) {
1272
1561
  return sourceEntry({ file, source, found });
1273
- })
1562
+ }),
1563
+ facts: factsOf(source)
1564
+ };
1565
+ }
1566
+ function factsOf(source) {
1567
+ const imports = importsOf(source);
1568
+ const imported = localSpecifiersOf(imports);
1569
+ const lists = stringListsOf(source);
1570
+ const listed = locallyExportedNames(source);
1571
+ return {
1572
+ functions: topLevelFunctionsOf(source).map(function functionFactsOf(found) {
1573
+ const { node } = found;
1574
+ const signature = tokenHashOf({
1575
+ texts: [
1576
+ ...(node.typeParameters ?? []).map((part) => part.getText(source)),
1577
+ ...node.parameters.map((part) => part.getText(source)),
1578
+ ...node.type ? [node.type.getText(source)] : []
1579
+ ]
1580
+ });
1581
+ const body = tokenHashOf({ texts: node.body ? [node.body.getText(source)] : [] });
1582
+ const summary = summaryOf(
1583
+ ts6.getJSDocCommentsAndTags(found.documented).filter(ts6.isJSDoc).at(-1)
1584
+ );
1585
+ return {
1586
+ name: found.name,
1587
+ line: source.getLineAndCharacterOfPosition(found.declaration.getStart(source)).line + 1,
1588
+ exportedAs: [
1589
+ .../* @__PURE__ */ new Set([...found.exported ? [found.name] : [], ...listed.get(found.name) ?? []])
1590
+ ],
1591
+ ...summary !== void 0 && { summary },
1592
+ signatureHash: signature.hash,
1593
+ bodyHash: body.hash,
1594
+ bodyTokenCount: body.count,
1595
+ signatureTypes: typeReferencesOf([...node.parameters, ...node.type ? [node.type] : []]),
1596
+ readKeys: readKeysOf({ node, lists }),
1597
+ calls: callsOf({ node, imported })
1598
+ };
1599
+ }),
1600
+ imports,
1601
+ types: typesOf(source)
1274
1602
  };
1275
1603
  }
1276
1604
  function exportedFunctionsOf(source) {
@@ -1290,9 +1618,9 @@ function exportedFunctionsOf(source) {
1290
1618
  function locallyExportedNames(source) {
1291
1619
  const names = /* @__PURE__ */ new Map();
1292
1620
  for (const statement of source.statements) {
1293
- if (!ts5.isExportDeclaration(statement) || statement.moduleSpecifier !== void 0) continue;
1621
+ if (!ts6.isExportDeclaration(statement) || statement.moduleSpecifier !== void 0) continue;
1294
1622
  if (statement.isTypeOnly || statement.exportClause === void 0) continue;
1295
- if (!ts5.isNamedExports(statement.exportClause)) continue;
1623
+ if (!ts6.isNamedExports(statement.exportClause)) continue;
1296
1624
  for (const element of statement.exportClause.elements) {
1297
1625
  if (element.isTypeOnly) continue;
1298
1626
  const local = (element.propertyName ?? element.name).text;
@@ -1305,7 +1633,7 @@ function topLevelFunctionsOf(source) {
1305
1633
  const found = [];
1306
1634
  const overloads = /* @__PURE__ */ new Map();
1307
1635
  for (const statement of source.statements) {
1308
- if (ts5.isFunctionDeclaration(statement) && statement.name !== void 0) {
1636
+ if (ts6.isFunctionDeclaration(statement) && statement.name !== void 0) {
1309
1637
  const name = statement.name.text;
1310
1638
  const set = [...overloads.get(name) ?? [], statement];
1311
1639
  if (statement.body === void 0) {
@@ -1320,7 +1648,7 @@ function topLevelFunctionsOf(source) {
1320
1648
  documented: set.find(hasJsDoc) ?? statement,
1321
1649
  exported: set.some(isExported)
1322
1650
  });
1323
- } else if (ts5.isVariableStatement(statement) && statement.declarationList.flags & ts5.NodeFlags.Const)
1651
+ } else if (ts6.isVariableStatement(statement) && statement.declarationList.flags & ts6.NodeFlags.Const)
1324
1652
  found.push(...constFunctionsOf(statement));
1325
1653
  }
1326
1654
  return found;
@@ -1330,23 +1658,23 @@ function constFunctionsOf(statement) {
1330
1658
  return statement.declarationList.declarations.flatMap(
1331
1659
  function functionOfDeclaration(declaration) {
1332
1660
  const { initializer, name } = declaration;
1333
- if (!ts5.isIdentifier(name) || initializer === void 0) return [];
1334
- if (!ts5.isArrowFunction(initializer) && !ts5.isFunctionExpression(initializer)) return [];
1661
+ if (!ts6.isIdentifier(name) || initializer === void 0) return [];
1662
+ if (!ts6.isArrowFunction(initializer) && !ts6.isFunctionExpression(initializer)) return [];
1335
1663
  return [{ name: name.text, node: initializer, declaration, documented: statement, exported }];
1336
1664
  }
1337
1665
  );
1338
1666
  }
1339
1667
  function hasJsDoc(node) {
1340
- return ts5.getJSDocCommentsAndTags(node).some(ts5.isJSDoc);
1668
+ return ts6.getJSDocCommentsAndTags(node).some(ts6.isJSDoc);
1341
1669
  }
1342
1670
  function isExported(statement) {
1343
- return ts5.canHaveModifiers(statement) && (ts5.getModifiers(statement) ?? []).some(function isExportKeyword(modifier) {
1344
- return modifier.kind === ts5.SyntaxKind.ExportKeyword;
1671
+ return ts6.canHaveModifiers(statement) && (ts6.getModifiers(statement) ?? []).some(function isExportKeyword(modifier) {
1672
+ return modifier.kind === ts6.SyntaxKind.ExportKeyword;
1345
1673
  });
1346
1674
  }
1347
1675
  function sourceEntry(params) {
1348
1676
  const { file, source, found } = params;
1349
- const jsDoc = ts5.getJSDocCommentsAndTags(found.documented).filter(ts5.isJSDoc).at(-1);
1677
+ const jsDoc = ts6.getJSDocCommentsAndTags(found.documented).filter(ts6.isJSDoc).at(-1);
1350
1678
  const line = source.getLineAndCharacterOfPosition(found.declaration.getStart(source)).line + 1;
1351
1679
  return {
1352
1680
  path: `${file}#${found.name}`,
@@ -1361,58 +1689,58 @@ function sourceEntry(params) {
1361
1689
  };
1362
1690
  }
1363
1691
  function summaryOf(jsDoc) {
1364
- const text = (ts5.getTextOfJSDocComment(jsDoc?.comment) ?? "").replace(/\s+/g, " ").trim();
1692
+ const text = (ts6.getTextOfJSDocComment(jsDoc?.comment) ?? "").replace(/\s+/g, " ").trim();
1365
1693
  return text === "" ? void 0 : firstSentence(text);
1366
1694
  }
1367
1695
  function intentsOf2(jsDoc) {
1368
1696
  return (jsDoc?.tags ?? []).filter(function isIntentTag(tag) {
1369
1697
  return tag.tagName.text === INTENT_TAG;
1370
1698
  }).flatMap(function intentsOfTag(tag) {
1371
- return parseIntentText(ts5.getTextOfJSDocComment(tag.comment) ?? "");
1699
+ return parseIntentText(ts6.getTextOfJSDocComment(tag.comment) ?? "");
1372
1700
  });
1373
1701
  }
1374
1702
  function signatureOf2(params) {
1375
1703
  const { source, node } = params;
1376
1704
  function print(part) {
1377
- return oneLine(SIGNATURE_PRINTER.printNode(ts5.EmitHint.Unspecified, part, source));
1705
+ return oneLine(SIGNATURE_PRINTER.printNode(ts6.EmitHint.Unspecified, part, source));
1378
1706
  }
1379
1707
  const typeParameters = node.typeParameters ? `<${node.typeParameters.map(print).join(", ")}>` : "";
1380
1708
  const returnType = node.type ? `: ${print(node.type)}` : "";
1381
1709
  return `${typeParameters}(${node.parameters.map(print).join(", ")})${returnType}`;
1382
1710
  }
1383
1711
  function oneLine(printed2) {
1384
- const scanner = ts5.createScanner(
1385
- ts5.ScriptTarget.Latest,
1712
+ const scanner = ts6.createScanner(
1713
+ ts6.ScriptTarget.Latest,
1386
1714
  false,
1387
- ts5.LanguageVariant.Standard,
1715
+ ts6.LanguageVariant.Standard,
1388
1716
  printed2
1389
1717
  );
1390
1718
  const tokens = [];
1391
1719
  const open = [];
1392
1720
  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) {
1721
+ for (let kind = scanner.scan(); kind !== ts6.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
1722
+ if (kind === ts6.SyntaxKind.WhitespaceTrivia || kind === ts6.SyntaxKind.NewLineTrivia) {
1395
1723
  spaced = tokens.length > 0;
1396
1724
  continue;
1397
1725
  }
1398
- if (kind === ts5.SyntaxKind.CloseBraceToken && open.at(-1) === ts5.SyntaxKind.TemplateHead) {
1726
+ if (kind === ts6.SyntaxKind.CloseBraceToken && open.at(-1) === ts6.SyntaxKind.TemplateHead) {
1399
1727
  kind = scanner.reScanTemplateToken(false);
1400
- if (kind === ts5.SyntaxKind.TemplateTail) open.pop();
1401
- } else if (kind === ts5.SyntaxKind.OpenBraceToken || kind === ts5.SyntaxKind.TemplateHead)
1728
+ if (kind === ts6.SyntaxKind.TemplateTail) open.pop();
1729
+ } else if (kind === ts6.SyntaxKind.OpenBraceToken || kind === ts6.SyntaxKind.TemplateHead)
1402
1730
  open.push(kind);
1403
- else if (kind === ts5.SyntaxKind.CloseBraceToken) open.pop();
1731
+ else if (kind === ts6.SyntaxKind.CloseBraceToken) open.pop();
1404
1732
  tokens.push({ kind, text: scanner.getTokenText(), spaced });
1405
1733
  spaced = false;
1406
1734
  }
1407
1735
  return tokens.filter(function keptToken(token, index) {
1408
- return !(token.kind === ts5.SyntaxKind.SemicolonToken && tokens[index + 1]?.kind === ts5.SyntaxKind.CloseBraceToken);
1736
+ return !(token.kind === ts6.SyntaxKind.SemicolonToken && tokens[index + 1]?.kind === ts6.SyntaxKind.CloseBraceToken);
1409
1737
  }).map(function textOfToken(token) {
1410
1738
  return token.spaced ? ` ${token.text}` : token.text;
1411
1739
  }).join("");
1412
1740
  }
1413
1741
 
1414
1742
  // src/lib/api/source-index.ts
1415
- import { createHash } from "crypto";
1743
+ import { createHash as createHash2 } from "crypto";
1416
1744
  import { readFileSync as readFileSync10 } from "fs";
1417
1745
  import { join as join17 } from "path";
1418
1746
 
@@ -1457,7 +1785,7 @@ function indexSourceFiles(params) {
1457
1785
  const answer = files.map(function parseChangedFile(file) {
1458
1786
  const key = `${prefix}${file}`;
1459
1787
  const bytes = readFileSync10(join17(root, file));
1460
- const hash = createHash("sha256").update(bytes).digest("hex");
1788
+ const hash = createHash2("sha256").update(bytes).digest("hex");
1461
1789
  const known = cached?.files[key];
1462
1790
  if (known !== void 0 && known.hash === hash) {
1463
1791
  next.files[key] = known;
@@ -1500,8 +1828,8 @@ function isCache(value) {
1500
1828
  if (schema !== SOURCE_INDEX_SCHEMA || typeof files !== "object" || files === null) return false;
1501
1829
  return Object.values(files).every(function isCachedFile(file) {
1502
1830
  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");
1831
+ const { hash, entries, note, facts } = file;
1832
+ return typeof hash === "string" && Array.isArray(entries) && entries.every(isCachedEntry) && (note === void 0 || typeof note === "string") && (facts === void 0 || isCachedFacts(facts));
1505
1833
  });
1506
1834
  }
1507
1835
  function isCachedEntry(value) {
@@ -1514,8 +1842,17 @@ function isStringList(value) {
1514
1842
  return typeof item === "string";
1515
1843
  });
1516
1844
  }
1845
+ function isCachedFacts(value) {
1846
+ if (typeof value !== "object" || value === null) return false;
1847
+ const { functions, imports, types } = value;
1848
+ return Array.isArray(functions) && Array.isArray(imports) && Array.isArray(types);
1849
+ }
1517
1850
  function parsedOf(known) {
1518
- return known.note === void 0 ? { entries: known.entries } : { entries: known.entries, note: known.note };
1851
+ return {
1852
+ entries: known.entries,
1853
+ ...known.facts !== void 0 && { facts: known.facts },
1854
+ ...known.note !== void 0 && { note: known.note }
1855
+ };
1519
1856
  }
1520
1857
  function writeCache(params) {
1521
1858
  try {
@@ -1550,9 +1887,10 @@ function listSourceFiles(root) {
1550
1887
  }) : listTreeFiles(join18(root, SOURCE_FOLDER)).map(function pathFromRoot(file) {
1551
1888
  return `${SOURCE_FOLDER}/${file}`;
1552
1889
  });
1553
- return files.filter(function isSourceFile(file) {
1554
- return SOURCE_FILE_PATTERN.test(file) && !TEST_FILE_PATTERN.test(file);
1555
- }).sort(TEXT_COLLATOR.compare);
1890
+ return files.filter(isSourceFilePath).sort(TEXT_COLLATOR.compare);
1891
+ }
1892
+ function isSourceFilePath(file) {
1893
+ return file.startsWith(`${SOURCE_FOLDER}/`) && SOURCE_FILE_PATTERN.test(file) && !TEST_FILE_PATTERN.test(file);
1556
1894
  }
1557
1895
 
1558
1896
  // src/lib/api/source-lookup.ts
@@ -1835,12 +2173,692 @@ function packagesText(indexes) {
1835
2173
  return indexes.length ? [...new Set(indexes.map((index) => index.package))].join(", ") : "no installed package (none ships skills/<name>/references/api.json)";
1836
2174
  }
1837
2175
 
2176
+ // src/lib/command-map/renamed.constants.ts
2177
+ var RENAMED_FORMS = [
2178
+ { command: "record", verb: "review", lotVerb: "finding" },
2179
+ { command: "record", verb: "decision", lotVerb: "decide" },
2180
+ { command: "record", verb: "snapshot", lotVerb: "snapshot" },
2181
+ { command: "record", verb: "choice", lotVerb: "choice" },
2182
+ { command: "record", verb: "standard", lotVerb: "standard" },
2183
+ { command: "review", verb: "delta", lotVerb: "delta" },
2184
+ { command: "recap", lotVerb: "recap" }
2185
+ ];
2186
+
2187
+ // src/lib/review-rounds/review-round-verbs.ts
2188
+ function lotFormsOf(command) {
2189
+ return RENAMED_FORMS.filter((form) => form.command === command).map((form) => `${LOT_COMMAND} ${form.lotVerb}`).join(" | ");
2190
+ }
2191
+ function renamedEntriesOf() {
2192
+ return {
2193
+ record: { renamedTo: lotFormsOf("record") },
2194
+ review: { renamedTo: lotFormsOf("review") },
2195
+ recap: { renamedTo: lotFormsOf("recap") }
2196
+ };
2197
+ }
2198
+
2199
+ // src/lib/command-map/command-map.constants.ts
2200
+ var ZERO_CONFIG_FLAGS = {
2201
+ overrides: [
2202
+ "--namespace <Name>",
2203
+ "--entry <import>",
2204
+ "--constants-dir <dir>",
2205
+ "--out <dir>",
2206
+ "--version <v>",
2207
+ "--tsconfig <f>"
2208
+ ],
2209
+ formatting: ["--format-config <path>", "--no-format"]
2210
+ };
2211
+ var GLOBAL_HELP_NOTES = [
2212
+ "Exit codes: 0 an answer or green, 1 nothing found or a failed check, 2 usage or refused;",
2213
+ "a command says when it differs. --help or -h before -- prints that command only, runs nothing.",
2214
+ "",
2215
+ "Zero-config (coverage, bench, narrowing, audit): namespace = capitalized package name, versions",
2216
+ "from src/<version>/definition/; core is benched through a built-in test dialect. Override in the",
2217
+ 'package.json "dialecte" field or with flags:',
2218
+ ` ${ZERO_CONFIG_FLAGS.overrides.join(" ")}`,
2219
+ `Generated files are formatted with the package's oxfmt: ${ZERO_CONFIG_FLAGS.formatting.join(" | ")}.`,
2220
+ "Env: RUNS=5 dialecte bench (repetitions for the min); COVERAGE_CHILD_CAP=N (cap child edges)."
2221
+ ];
2222
+ var COMMAND_MAP = {
2223
+ api: {
2224
+ family: "Discover",
2225
+ summary: "Find a method by what you need (find), read its contract (show)",
2226
+ usage: [
2227
+ 'dialecte api find "<need>" [--source] [--package <name>] [--limit 5] [--json]',
2228
+ "dialecte api show <path> [--package <name>] [--json]",
2229
+ "dialecte api show <file>#<name> [--json]"
2230
+ ],
2231
+ notes: [
2232
+ "find - the methods whose intents, summary or name match the need, best first",
2233
+ "show - signature, summary, intents, routes, declaration, example (info.of, tx.addChild)",
2234
+ "--source - also the exported functions of the own package src/ (show src/lib/git.ts#readGit), cached in the git folder"
2235
+ ],
2236
+ exitCodes: [],
2237
+ example: 'dialecte api find "add a child element"'
2238
+ },
2239
+ members: {
2240
+ family: "Discover",
2241
+ summary: "The members of an expression of the live types (doc.query, tx.lifecycle)",
2242
+ usage: ["dialecte members <expression> [--package <name>] [--version <v>] [--json]"],
2243
+ notes: [
2244
+ "one line per member of doc.query, doc.query.reference, tx.lifecycle.extract...; in an app, of the installed dialecte (--package / --version when several)"
2245
+ ],
2246
+ exitCodes: [],
2247
+ example: "dialecte members doc.query"
2248
+ },
2249
+ schema: {
2250
+ family: "Discover",
2251
+ summary: "What an element may hold and where: parents, children, attributes",
2252
+ usage: ["dialecte schema <Tag> [--under <Parent>] [--package <name>] [--json]"],
2253
+ notes: [
2254
+ "parents, children with how often, attributes, type, documentation; an unknown tag answers the closest",
2255
+ "a tag declared several ways is printed per declaration, with the parents holding each; --under <Parent> picks the one that parent holds"
2256
+ ],
2257
+ exitCodes: [],
2258
+ example: "dialecte schema Bay"
2259
+ },
2260
+ explain: {
2261
+ family: "Discover",
2262
+ summary: "What an error or diagnostic code means, when it is raised, the usual fix",
2263
+ usage: ["dialecte explain <code | key> [--package <name>] [--json]"],
2264
+ notes: [],
2265
+ exitCodes: [],
2266
+ example: "dialecte explain CONCURRENT_TRANSACTION"
2267
+ },
2268
+ standard: {
2269
+ family: "Discover",
2270
+ summary: "Index and search the standards kept on this machine (DIALECTE_STANDARD: one folder per standard); the index lives in the cache",
2271
+ usage: [
2272
+ "dialecte standard index [--standard <id>] [--package <name>] [--rebuild] [--json]",
2273
+ 'dialecte standard find "<terms>" [--standard <id>] [--package <name>] [--about <Tag>] [--limit <n>] [--json]',
2274
+ "dialecte standard show <file id>:<from>-<to> [--json]",
2275
+ "dialecte standard eval <gold.jsonl> [--standard <id>] [--package <name>] [--angles] [--packs [--effort low|medium|high]] [--reports <asks folder>] [--json]"
2276
+ ],
2277
+ notes: [
2278
+ "the vocabulary - the tags, attributes and enumeration values of the installed dialectes (--package <name>: that one only); index, find and eval print it first",
2279
+ "index - builds (or reuses) the index of each standard folder, prints its quality per file",
2280
+ "find - the ranked slices of whole lines that hold the terms, then the clauses they refer to [linked]; --about <Tag> adds a tag of the installed dialectes",
2281
+ "show - the normalised text of a range of original lines; a file id is <standard id>/<file name without .md>",
2282
+ "eval - recall at 5 and 10 of find over a local gold file of { question, about?, expected: [{ file, quote }] } lines; the expected quotes are alternatives; --angles runs each question through the ask ladder (no fact read or written, no ask kept) and scores its merged slices; each gold line may also hold kind (fact | polarity | exception | not-in-text), answer and status",
2283
+ "eval --packs - the recall at 5 and 10 of the slices the round-1 readers are given (the ask ladder, no fact read or written, no ask kept, nothing written): reader A in its order, and the A and B slices together (A1, B1, A2, B2, a slice met twice kept once); --effort low|medium|high sets the readers (default medium)",
2284
+ "eval --reports - the agreed-wrong rate of recorded asks: the asks of an asks folder whose question equals a gold question are judged by their last answered round (a not-in-text item the readers did not agree not-in-text, an item with an answer they agreed not-in-text, a gold answer starting yes or no and the other verdict, a value its gold answer does not hold: wrong; no rule decides the rest: unjudged); rate = wrong over agreed and wrong, null (printed -) when nothing is judged; runs outside a package, writes nothing",
2285
+ "eval --json - schema 1; packs: { readerA: { recallAt5, recallAt10 }, union: { ... } } only with --packs, reports: { agreed, wrong, unjudged, rate } only with --reports",
2286
+ "the standard is never copied into a repository: its index is in $XDG_CACHE_HOME/dialecte (else ~/.cache/dialecte)",
2287
+ "the card's standard line - a lot's standard.json in state outside (its asks answered outside the documents) warns, and fails at effort high unless the record's confirmed flag is true (a person confirmed every outside answer; lot standard ... outside writes it false): the flag decides, never the note text"
2288
+ ],
2289
+ exitCodes: [
2290
+ "1 index: no indexable file \xB7 find: nothing matched \xB7 show: only blank or dropped lines \xB7 eval: no item with an expected quote \xB7 a file changed during the build",
2291
+ "2 usage \xB7 no standard configured \xB7 a root or cache inside a git work tree \xB7 colliding ids \xB7 an unknown standard, file, --package or --about tag \xB7 eval: a gold line that is not an item (kind not one of the four), --effort not low, medium or high or without --packs, --packs outside a package with a dialecte installed, a --reports folder that does not exist"
2292
+ ],
2293
+ example: 'dialecte standard find "data object" --limit 5'
2294
+ },
2295
+ facts: {
2296
+ family: "Discover",
2297
+ summary: "List, show and forget the facts the agents recorded, kept in the data folder (one ledger per person, never in a repository)",
2298
+ usage: [
2299
+ "dialecte facts list [--about <Tag>] [--state <state>|all] [--json]",
2300
+ "dialecte facts show <id> [--json]",
2301
+ "dialecte facts forget <id> --reason <text> [--json]"
2302
+ ],
2303
+ notes: [
2304
+ "the ledger is $XDG_DATA_HOME/dialecte/facts (else ~/.local/share/dialecte/facts): one file per fact (F-<n>.json) and its history (F-<n>.history.jsonl); nothing is ever deleted",
2305
+ "list - every question's current fact, whatever its state; --state valid | stale | unverifiable | unchecked | forgotten: the current facts in that state now; orphan: the fact files no question points to; all: every fact file, superseded and unreadable ones included; --about <Tag>: the facts about that tag",
2306
+ "states - valid; stale (a source moved since: a standard's files, a dialecte's definition); unverifiable (a source cannot be compared now); unchecked (from outside the documents, or a person's answer given without them); forgotten",
2307
+ "show - the question, the answer, its source and effort, its state now, its sources, how many pieces of evidence, and its history in order",
2308
+ "forget - marks the fact forgotten, its reason in the history (cut at 200 characters); the file is kept; forgetting it again writes nothing"
2309
+ ],
2310
+ exitCodes: [
2311
+ "1 show, forget: no fact of that id (the closest ids named) or a fact file that is not readable JSON",
2312
+ "2 usage \xB7 the ledger inside a git work tree (set XDG_DATA_HOME to a folder outside the repository)"
2313
+ ],
2314
+ example: "dialecte facts list --state stale"
2315
+ },
2316
+ ask: {
2317
+ family: "Discover",
2318
+ summary: "Answer a question about a dialecte: a fact recorded before, the definition, the catalogues and api indexes, else the slices of the standard for readers",
2319
+ usage: [
2320
+ 'dialecte ask "<question>" [--about [<Parent>/]<Tag>[@<attr>] | --code <code> | --method <path>] [--kind <kind>] [--decision] [--package <name>] [--effort low|medium|high] [--lot <id|folder>] [--limit <n>] [--no-facts] [--no-standard] [--person-only] [--json]',
2321
+ "dialecte ask pack <ask-id> [--out <dir>] [--outside] [--web] [--lot <id|folder>] [--json]",
2322
+ "dialecte ask verdict <ask-id> [<report.json>...] [--missing <letter>]... [--adjudicator] [--lot <id|folder>] [--json]",
2323
+ 'dialecte ask answer <ask-id> "<answer>" --by <who> [--verdict yes|no|depends|value] [--cite <file id>:<from>-<to> --quote "<quote>"] [--lot <id|folder>] [--json]'
2324
+ ],
2325
+ notes: [
2326
+ "the ladder - rung 0 a fact of the same question (reused at its effort or above), rung 1 the definition (a structural question: children, parents, required, values, default, fixed, type, variants, documentation), rung 2 the catalogues (a code) and the api indexes (a method), rung 3 the slices of the standard found from the angles of the question",
2327
+ "--about [<Parent>/]<Tag>[@<attr>], --code, --method name the subject; --kind forces the kind; --decision skips rung 1 (a choice the definition does not make)",
2328
+ "--decision reads the definition as the boundary of what is valid (boundary: <answer> (definition), never the answer): a stored schema fact is a candidate only; a standard or person fact answers inside it; one naming what the XSD rejects is cut to the boundary (a list) or takes its answer, and a ! conflict: line flags it (standard-vs-xsd, exit 0): the XSD wins, fix it and ask again",
2329
+ "an answer from rung 1 or 2 is recorded as a fact in $XDG_DATA_HOME/dialecte/facts at the ask effort; --no-facts reads and records none",
2330
+ "an ask is a folder A-<n> holding ask.json (the --json object, schema: 1, with boundary and conflict): with --lot <id|folder> in <lot folder>/asks/ (a store lot by index, name or folder, or a hand-over folder outside every repository), inside a lot worktree in its lot, else in $XDG_STATE_HOME/dialecte/asks/",
2331
+ "the events (ask.parsed, ask.rung, ask.fact, ask.state, ask.pack, ask.answer) go to the lot events.jsonl, else $XDG_STATE_HOME/dialecte/asks/events.jsonl; they hold the question length and key hash, never its text; ask.state says conflict: true|false, never what conflicts; ask.pack the round, the readers and skipped; ask.answer rung 6, the reader miss and citeRefused, never the answer or a quote",
2332
+ "the documents - the DIALECTE_STANDARD folder whose id matches the dialecte standard name; without one the ask goes to outside readers (--no-standard is refused while documents are readable)",
2333
+ "--effort - a lot ask takes the lot effort; elsewhere --effort, else medium",
2334
+ "pack - the next round of readers of an ask (the ask folder keeps request.json beside ask.json: what the ask read): rounds/round-<r>/ gets reader-<A|B|C>.md and .json (the slices with their line numbers, the report schema, a nonce each) and pack.json; A reads by rank, B by angle family, C (high) as B without the top slice, each up to 1,500 non-noise lines; a later round gives no slice a reader of the same letter had; pack again on an open round prints the same briefs; --out copies them; --outside [--web] for an ask without documents",
2335
+ "verdict - checks the reports of the open round, one report file per reader the round gave (refused ones too; else exit 2, nothing recorded) (each cite inside a slice given to its reader, each quote in its lines, each nonce used once: rounds/round-<r>/used/<nonce>) and writes rounds/round-<r>/verdict.json; reports agree on the verdict, the value and a shared line or clause: low 2 readers 1 round, medium 2 readers 2 rounds, high 3 readers 3 rounds (a verified dissent is another round); nothing verified searches again while something is left, up to 5 rounds; an agreed answer is recorded as a fact (the union of the verified cites, the shortest answer; a --decision ask held inside the boundary); outside readers answer in one round, all agreeing, recorded unchecked by source (model, web) unless the definition says otherwise",
2336
+ "the adjudicator - at high, readers that never agree or a polarity conflict go to the adjudicator: ask pack writes rounds/round-<r>/adjudicator.md and .json (the reports with their checks, the union of their cited ranges, a nonce); its report goes through the same checks with ask verdict <id> <report.json> --adjudicator: verified, the fact (rung 5); else a person",
2337
+ "answer - the person answers an ask that is not answered, or confirms one the outside readers answered (a person fact superseding the outside one, unchecked while the ask read no documents; <ask>/confirm.json marks it confirmed; a second confirmation refused) (rung 6); --verdict yes|no|depends|value keeps that verdict on the person fact (value: the answer as the value), else it says person; a person fact by <who> (unchecked: true when the ask read no documents, or under --person-only), answer.json in the ask folder; --cite (with --quote) is checked as a reader cite and recorded as a reader miss (given or not to a reader, and the round), a refused cite named (citeRefused) while the answer is still recorded; an ask of a store lot that reaches the person raises one question on the lot (its text <ask-id>: <question>, at most 500 characters, the full text in its details), and lot answer on it records the same person fact; in a hand-over folder or outside a lot the ask answer command is printed",
2338
+ "the lot note - after ask, verdict and answer, a lot's standard.json is recomputed from every ask's latest state (consulted; outside when any ask past rung 2 went outside, every ask listed, with confirmed: true and ending (all confirmed) when a person answered or confirmed each outside ask, else (all unchecked)), under <lot folder>/standard.json.lock; a lot whose asks all stopped at rungs 0-2 records nothing; a verdict run holds rounds/round-<r>/verdict.claim while it runs, a second run on that round is refused; ask verdict and ask answer hold <ask>/ask.claim, so one of them records the ask's fact, the other is refused (in progress); a retry after a crash closes the ask on the fact already recorded"
2339
+ ],
2340
+ exitCodes: [
2341
+ "1 no rung answers and a person answers next (--person-only) \xB7 pack: nothing new to give (the round skipped, the adjudicator or the person next) \xB7 verdict: the person next (no agreement, nothing found, the adjudicator refused)",
2342
+ "2 usage \xB7 an unknown --about tag or attribute (the closest named) \xB7 several dialectes without --package \xB7 two standard folders of one key \xB7 --no-standard with documents \xB7 --effort other than the lot effort \xB7 a --lot folder inside a repository \xB7 pack: an unknown or answered ask, no request.json, a file changed since the ask, --outside on a documents ask or the reverse \xB7 verdict: an answered ask, no round open, a closed round, every report of another ask or round or unreadable, --adjudicator on an ask not waiting for it, a round another verdict run holds (nothing recorded) \xB7 answer: an unknown or answered ask, no --by, --cite without --quote (nothing recorded)",
2343
+ "3 readers answer next: dialecte ask pack <id> (the slices of the documents, or --outside without them) \xB7 verdict: another round, or the adjudicator (dialecte ask pack <id> writes its brief)"
2344
+ ],
2345
+ example: 'dialecte ask "children of Bay"'
2346
+ },
2347
+ run: {
2348
+ family: "Use",
2349
+ summary: "Run a script against an in-memory project of the installed dialecte; one structured outcome",
2350
+ usage: [
2351
+ "dialecte run <script.ts> [--in <file>] [--out <file>] [--prepare] [--expect <file>]",
2352
+ "dialecte run <script.ts> [--seed <n>] [--now <iso>] [--package <name>] [--timeout <ms>] [--json]"
2353
+ ],
2354
+ notes: [
2355
+ "the script's default export gets { project, doc, documentId, dialecte, helpers, utils }; ids seeded",
2356
+ "--prepare - stages the first transaction and commits nothing",
2357
+ "--expect - checks a JSON array of { tag, where?, under?, count? }",
2358
+ "Node 22.18+: .ts scripts run through Node's built-in type stripping"
2359
+ ],
2360
+ exitCodes: ["1 the script failed or an expectation was not met"],
2361
+ example: "dialecte run add-part.ts --in assembly.xml --expect expected.json"
2362
+ },
2363
+ fixture: {
2364
+ family: "Use",
2365
+ summary: "The smallest valid XML document holding an element, built by the installed dialecte's engine",
2366
+ usage: ["dialecte fixture <Tag> [--under A/B] [--package <name>] [--out <file>] [--json]"],
2367
+ notes: [
2368
+ "the chain from the root (or --under), required children and attributes, hooks applied; the same bytes every time; an unknown tag answers the closest"
2369
+ ],
2370
+ exitCodes: [],
2371
+ example: "dialecte fixture AAA_1 --package @dialecte/core/test"
2372
+ },
2373
+ new: {
2374
+ family: "Use",
2375
+ summary: "Scaffold in the house style",
2376
+ usage: ["dialecte new verb <namespace> <query|transaction> <name> [--version <v>]"],
2377
+ notes: ["verb, types, red test (only: true), barrel export, namespace registration"],
2378
+ exitCodes: [],
2379
+ example: "dialecte new verb parts query findPart"
2380
+ },
2381
+ lot: {
2382
+ family: "Grow",
2383
+ summary: "A lot: started from a brief into the lot store, its declaration .dialecte/lot.json, and its review rounds in its lot or hand-over folder",
2384
+ usage: [
2385
+ "dialecte lot start <brief.json> [--effort low|medium|high] [--overlap-ok] [--by <who> --reason <text>] [--dry-run] [--simulate <scenario>] [--json]",
2386
+ "dialecte lot start <brief.json> --on <lot> [the options above]",
2387
+ "dialecte lot status <id> [--json]",
2388
+ "dialecte lot forecast [<id>] [--json] [--against <lot>]",
2389
+ "dialecte lot risk <id|folder> [--json]",
2390
+ "dialecte lot risk <id|folder> --effort low|medium|high [--class high|medium|light] --by <who> [--reason <text>]",
2391
+ "dialecte lot wait <id> [--timeout <seconds>] [--json]",
2392
+ 'dialecte lot answer <id> <question> "<answer>" [--by <who>] [--json]',
2393
+ "dialecte lot result <id> [--json]",
2394
+ "dialecte lot stop <id> --reason <text> [--by <who>] [--json]",
2395
+ "dialecte lot scope <id> [--drop <path>]... [--add <path>]... [--overlap-ok] --by <who> --reason <text>",
2396
+ "dialecte lot station <id> start <station> [--step <n>] [--round <n>] [--attempt <n>] [--agent <name>] [--executor host|command] [--vendor <name>] [--model <name>] [--tier <name>] [--effort <word>] [--session <id>] [--skill <name|path>]... [--skill-asked <name|path>]... [--event <id>] [--json]",
2397
+ "dialecte lot station <id> end <station> [--run <run>] [--step <n>] [--round <n>] [--attempt <n>] [--agent <name>] [--vendor <name>] [--model <name>] [--tier <name>] [--effort <word>] [--session <id>] [--skill <name|path>]... [--skill-asked <name|path>]... [--event <id>] [--tokens-in <n>] [--tokens-out <n>] [--tokens-cache-read <n>] [--tokens-cache-write <n>] [--tokens-total <n>] [--money <amount> <currency>] [--duration <seconds>] [--exit <n>] [--verdict <word>] [--suite <name>=<runs>]... [--json]",
2398
+ "dialecte lot station <id> --from <file.json> [--json]",
2399
+ "dialecte lot exempt <reason>",
2400
+ "dialecte lot accept <case> <reason> | lot accept --remove <case>",
2401
+ "dialecte lot revised <case|file|glob> <reason> | lot revised --remove <case|file|glob>",
2402
+ "dialecte lot gone <file|glob> <reason> | lot gone --remove <file|glob>",
2403
+ "dialecte lot moved <case> <case> <reason> | lot moved <file> <file|glob> <reason> | lot moved --remove <from> <to>",
2404
+ "dialecte lot mutation <off|changed|audit|gate>",
2405
+ "dialecte lot finding <id|folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding>",
2406
+ "dialecte lot decide <id|folder> <finding> <open | fix-to-verify | fixed <round> [note] | accepted <reason> | logged <where>>",
2407
+ "dialecte lot snapshot <id|folder> --round <n> [--beyond-cap --by <who> --reason <text>]",
2408
+ "dialecte lot choice <id|folder> --by <who> <decision>",
2409
+ "dialecte lot standard <id|folder> consulted <note> | not-consulted <reason> | outside <note>",
2410
+ "dialecte lot delta <id|folder> --round <n> [--worktree] [--json]",
2411
+ "dialecte lot recap <id|folder>",
2412
+ "dialecte lot verify <id|folder> --by <who> --note <text>",
2413
+ "dialecte lot report <id> [--json]",
2414
+ "dialecte lot report --feature <name> [--simulated] [--json]",
2415
+ "dialecte lot export <id> <dir> [--json]",
2416
+ "dialecte lot brief <id> --from <brief.json> --by <who> --reason <text>",
2417
+ "dialecte lot pr <id> [--print] [--json]",
2418
+ "dialecte lot review <id> [--no-open] | lot review <id> --pull --round <n>",
2419
+ "dialecte lot approve <id> --by <who> [--reason <text>]",
2420
+ "dialecte lot design <id> [--from <file> | --from-plan | --approve --by <who> [--reason <text>] | --waive --by <who> --reason <text>] [--json]",
2421
+ "dialecte lot land <id>",
2422
+ "dialecte lot close <hand-over name|lot id|index>... [--json]",
2423
+ "dialecte lot prune [<id>...] [--feature <name>] [--all] [--yes] [--json]"
2424
+ ],
2425
+ notes: [
2426
+ "start - checks the brief (every refusal at once, exit 2), claims the next index, publishes the lot folder in <git common folder>/dialecte-lots/, makes the numbered worktree at the base commit with its .dialecte/lot link; --dry-run checks (the store list included), names the lot and the start to run next, writing nothing; exit 1 when the worktree cannot be made (the lot failed, nothing removed, next: lot stop); a link that cannot be made leaves the lot working with a note; every --json exit is JSON, a usage error { error, usage, next: null } included",
2427
+ "start - --on <lot> starts the lot on another open lot of the same repository (a stack): its branch is cut at that lot's branch tip, its stack.json records the parent only (where it forks is read from git when it lands), and the parent's scope is its base, never an overlap, at the start and at lot scope --add (every other open lot's still is); a parent that is unknown, damaged, not working or ready, of another repository or without its branch is refused before anything is written, before any other fault of the brief; lot status shows a stack line, on <parent> (#<pull request>, <state>), the parent read through the one lot reader: merged once its landing is proven (its landed fact, git or the host), else its pull request as the host holds it (open, draft, queued, closed, or the host cannot say: <why>), the hand-over card on <parent> (#<pull request>) from files only; on <parent> (no pull request yet) without one",
2428
+ "start - a scope meeting another open lot goes ahead when that lot's work reads (its forecast against main, run and never written: a new lot has no work, so no conflict can exist), printed shares <met> with <lot> (forecast clean); still refused: a damaged lot or one whose scope cannot be read, a met lock file (exclusive: a lock file is never shared), a forecast that cannot run (forecast unknown: <reason>); after the start the new lot's own forecast is recorded (trigger start); the re-check after the start refuses only what still refuses (a lot that published meanwhile but has no worktree on disk yet has no work: the start goes on)",
2429
+ "start - --overlap-ok accepts an overlap the start refuses, for an overlap that names its paths (a lot whose scope cannot be read stays refused; a damaged other lot whose scope reads is accepted, its damage recorded beside the go-ahead); it takes --by <who> --reason <text>, the same go-ahead as an effort below the class; each accepted overlap is a line of the lot folder's overlaps.jsonl (the other lot, the met pairs, who and why), printed by the start and its dry run (! overlaps <lot>: ...) and shown on the card's scope line as a warning; on an overlap the forecast cleared it is recorded all the same, printed --overlap-ok not needed: the forecast cleared <lot>; the re-check after the start refuses a held lot the go-ahead did not name",
2430
+ "start - the effort: the risk class of the brief's scope (high when an entry reaches the package's dialecte.risk.high list) sets the default (high, medium or low); on a terminal, without --json or --dry-run, the effort is asked with that default; an effort below the class (from --effort, the brief or the answer) is refused (exit 2, nothing written) without --by <who> --reason <text>, which are recorded on an effort line in risk.jsonl with the class's derived line, the start printing ! effort <e> below risk class <c> (by <who>: <reason>)",
2431
+ "--simulate - start a simulated lot that plays one of the scenarios (ready, question, person, two-questions, limit, failure, slow) under wait: no worktree, no branch, no registry entry; it never blocks a real lot",
2432
+ "brief - a working or ready real lot takes a new brief whose only changes are its public text (the summary, the issue, step titles and behaviours); any other change is refused naming the field, nothing written; the new brief passes the start's field and public-text checks; it replaces the stored brief and a brief transition records the sha256 of the old and new brief, --by and --reason, the state and position kept; the same brief again answers already, nothing written; a simulated lot is refused; brief.json edited any other way reads as damage",
2433
+ "pr - renders the lot's pull request from its records through the repository's .github/pull_request_template.md: the title is the brief's first commit message, the body its summary and other commit messages, step titles and behaviours, the changelog fragments the lot adds, tests.json (a part of another tree reads stale), review.jsonl (findings and how each closed, the verdicts by reviewer kind, never a name; a row value its writer never writes refused), the risk class and effort, the overlaps it accepted (the other lot by its index, and why), the issue it closes, and the author's checklist ticked from the records; a missing record reads not recorded; the record text is checked first (a reference, a forbidden word, a plan entry id, a link or a path outside the tree refused, naming the word and the record); the open pull request (landing.json's, else the branch's newest) is edited only when its title or body reads otherwise, a person's part after the kept marker kept (a body without that heading holding a person's text refused, never dropped); a damaged lot refused; --print prints and sends nothing; no pull request yet prints the text and names lot land; --json { title, body, pullRequest, head, sent }",
2434
+ "review - the private half of the lot's review, read-only (nothing written): the lot's state and branch, its pull request (landing.json's) with the head it is at, the head the lot landed and the worktree's HEAD, its checks, the brief's goal and steps (title, spec, behaviours), tests.json's tdd counts and gate run, decisions.md, every finding of the ledger with its text and state, the standard line, and what lot approve would refuse (or the approve command when it would approve); then opens the pull request's changed files in the browser (--no-open names the page only; an opener that fails is named, never an exit); a lot without a landing prints its private half and names lot land <id>, the host never asked",
2435
+ "review --pull - the pull request's line comments come back as findings of round <n> in the lot's findings ledger: a thread's first comment only (replies discuss it), each once (pulled-comments.jsonl records the comment and its finding; a second pull answers already), its severity from a leading blocking:, should-fix: or nit: (dropped from the text, kept when it is all the comment says), else should-fix, at its path:line (the path alone for a comment on the file), its lines joined into one; review.jsonl written again; private points stay off the pull request: lot finding records them",
2436
+ "approve - a person's approval of the lot's pull request: refused (exit 1, nothing recorded, nothing queued) unless the lot is at work, the pull request landing.json names is open at the head the lot landed and the worktree is at that head too (an unpushed commit refuses), its checks ran on that head and are green (a check run again counts by its newest run; a failing or pending check, or none yet, refuses) and no finding but a nit is open (open, or a fix still to verify), and its text renders over the live body; then appends { schema, at, by, reason?, number, head } to the lot folder's approvals.jsonl, which review.jsonl shows as a person's approve verdict with that head (a pull request text rendered on another head, after a later commit or a rebase, leaves it out; the body names it by kind only, never the name; the orchestrator in any casing is recorded as orchestrator), renders the pull request's text again from the records, makes a draft ready and queues it (gh pr merge --auto; a lot started with --on whose pull request still merges into its parent's branch queues as a stack up to it, gh stack merge, and only on a host with stacks once the parent's pull request, read by the parent's branch, is queued (auto-merge on or in the merge queue), refused otherwise before anything is recorded: approve the parent first, or land it again once the parent merged); the only verb that queues, lot land never does; a queue the host refuses keeps the approval (exit 1) and the same approval run again answers already approved, writing nothing, and queues; --by orchestrator (in any case) approves the cli's own lots only (the package named @dialecte/cli), every other package waits for a person (exit 2); a forbidden word in --by or --reason, or a --by holding what a public record never holds, refused (exit 2) before the host is asked; a lot without a landing names lot land <id>",
2437
+ "design - a lot's design (design before code): --from <file> records it by the sha256 of its bytes, appending { schema, at, kind: recorded, file, hash, from } to the lot folder's design.jsonl and keeping its copy as design/<hash>.md (the copy rules once the source is gone); a file missing, empty, not UTF-8 or under a scratch root, the system's temporary folder, /tmp or /private/tmp (wiped there) is refused (exit 2), nothing written, and a file outside every git work tree is recorded (plans live there); without a worktree the lot is read at the base recorded at its start, a ! line saying so; --from-plan records the spec of the plan entry the lot carries out, refused when another lot or fix entry of its block names the same spec (write this lot's own design) or the lot carries out no entry with a spec; --approve --by <who> [--reason <text>] appends an approval of the last recorded hash with the need it was given against, refused when nothing is recorded or the source exists with other bytes (record it again); --waive --by <who> --reason <text> appends a waiver with the current need, refused on a lot that needs no design; both refused from the lot's own worktree or its review throwaway (approve from the main checkout), and on a --by or --reason holding a forbidden word or a --by holding what a public record never holds (exit 2); the orchestrator in any casing is recorded as orchestrator; a lot no longer at work is refused (exit 1); without an option it prints design <state>[ by <kind>][ \xB7 <reasons>] and the next command, --json { required, reasons, state, by, uncovered } (by the kind, never a name)",
2438
+ "design - the need, computed by every reader and never stored: required when a scope entry (or a path) lies in a dialecte.risk.high area or is broader than one, or the lot carries out a plan entry of kind lot; an approval or a waiver holds only for the need it was given against (a reason of a new kind or glob reads unapproved or missing again); a recorded design gates the lot whatever its need; states approved, waived, unapproved (shown not approved), stale (shown stale since its approval: the source edited after its approval), missing, not-required (shown not required); lot start and its dry run print design required (<reasons>) or design not required, lot forecast and lot status the state line, the hand-over card a design line (passed or a warning, never failed), review.jsonl a design row and the pull request body Design: <state> by <kind>",
2439
+ "design - the gate: while a lot's required design is missing, unapproved or stale, tdd red in its own worktree refuses (exit 2, nothing run), gate --hook's design step fails a commit of the lot's branch, from any worktree, holding a production path (first, whatever dialecte.gate.hook declares; a refused design recorded in the lot's events; a commit of tests or docs only passes; a first or merge commit and a review throwaway on <lot branch>-round-<n> skip it; a branch no lot names gives no line), lot land refuses after its rebase (nothing pushed), handover write refuses a store lot (nothing written), lot approve names design <state> among its reasons and the card's design line, read at the card's worktree, fails (handover run refuses); each reads the shared areas of the lot base its run resolved, through git, over the scope, the change's paths since that base and the staged or landed ones; a refusing path without the lot's worktree refuses; lot land records the base's shared areas again after its rebase",
2440
+ "land - a lot started with --on lands as a stack: its pull request is based on the parent's branch, its body's depends-on part names the parent's pull request (a parent without one is refused: land it first); the host's stacks are probed once (gh stack): with them, the pull request is linked on the parent's (gh stack link); without, a note says why; it is never queued (lot approve queues it); before each landing it is rebased onto the parent branch's newest tip (the local branch or origin's) when it does not hold it, from its fork point (git merge-base --fork-point: only its own commits move, whatever the parent's amend or rebase); once the parent merged (its landing state: a merge, a squash read offline, or its pull request merged; never the registry's committed alone, which a hand-over run writes before anything reaches the base), the parent's landed fact is recorded and the child is rebased with git rebase --onto origin/<base> <fork point>, only its own commits moved, and its pull request retargeted to the base when the host did not; when the host already rewrote its branch on origin (a native stack), it follows that rewrite (local commits beyond its last push rebased onto it, that head the lease); a conflict names its files, the rebase undone, nothing pushed, exit 2",
2441
+ "land - the lot lands through its pull request: its committed HEAD (uncommitted files stay in the worktree, named), rebased onto origin/<base> when behind (a conflict undone and named, nothing pushed; with uncommitted tracked changes it is pushed as committed, the rebase left for a clean worktree), pushed with a lease, its title and body rendered from the lot's records through the repository's .github/pull_request_template.md on the rebased head before the push (as lot pr renders them; records that do not render, or a base branch origin does not hold, push nothing), its pull request opened with them as a draft or reused (edited when its title or body reads otherwise, a person's part after the kept marker kept), never queued: CI runs on every push and lot approve, a person's step, queues it; a reused pull request queued or ready whose head to push no person approved (approvals.jsonl) is taken back out of the queue before the push (auto-merge off, gh pr merge --disable-auto; a draft again, gh pr ready --undo), since an approval is for one head: a rebase that only moves the sha takes it out too, and every landing checks, so one stopped after its push heals on the next (a refusal there pushes nothing); --draft, from when lot land queued, is refused (exit 2) naming the change; the landing (number, url, branch, pushed tip) recorded in <lot folder>/landing.json; a lot already merged (its pull request merged, or its tip or its work in origin/<base>: a squash read offline) is committed: its landed fact written in <lot folder>/landed.json, its hand-over entry committed, the commits made since named (they land in a new lot), the close line printed, nothing pushed; a branch with no commit beyond origin's base is refused before any push; the committed HEAD is forecast against origin/<base> just fetched (git merge-tree, before any entry, rebase or push): a conflict refuses naming its files and ranges, a forecast that cannot run refuses (fails closed), a lot on an open parent is not compared; the lot's forecast against every other open lot is recorded (trigger land) and each pair it does not clear printed (! <lot>: <why>), for information only; the pushed head is kept in landing.json at once, so a pull request the host refused to open does not make the next push one outside lot land; the host is GitHub through gh, which never prompts",
2442
+ "status - the state derived from the lot records (working, input-required, ready, committed, canceled, failed), the worktree and link checks, and the exact next command (and an also: line); a working real lot adds a station line (station <what> \xB7 round <r>/<cap> \xB7 effort <level>), the next station walked from its station events and checks (step events, else the worktree's tdd ledger and gate records), its next is that station's command and also keeps the manual line, which lot start prints as its next too; the manual line depends on the repository's landing flow: lot land <name> in a CI-first repository, handover write in any other; --json adds station and rounds (review, cap, beyondCap, independent) and effort { level, source, riskClass, below } (source risk-line for an effort recorded by lot risk; an effort below its risk class adds a ! effort <e> below risk class <c> line, ending (by <who>: <reason>) or (no go-ahead recorded)); --json adds forecast { main, pairs }: the newest main line of forecast.jsonl and, per other open lot, the newer of its own line against that lot and that lot's line against it (files only); a lot whose records do not hold reads damaged with its reason and next: lot stop (exit 6); a lot git reads merged (its tip or its work in origin/<base>, a squash included) shows committed, nothing written; writes nothing; exit 2 for an unknown or ambiguous id",
2443
+ "forecast - the conflict forecast of a lot's work (its worktree's HEAD plus its uncommitted work, as one snapshot commit made on a copy of its index with a fixed identity and date; the worktree's index, refs and files never written, ignored files left out) against main (origin/<base> as last fetched, never fetched here) and against every other open lot of its store, each by git merge-tree --write-tree, without a checkout: clean, conflict (each path with its kind, content with the line ranges between the markers), exclusive (every conflicted path a lock file) or unknown with its reason (git older than 2.38, a damaged lot, worktree of <lot> missing, <ref> does not resolve, snapshot of <lot> failed, merge-tree failed, forecast of <lot> over 20 s: each git step is limited to 20 seconds); each line also lists the files both sides changed (shares); a path that conflicts against main for either lot is shown once, on the main line; the verdict is the worst line (unknown > conflict > exclusive > clean); default lot: the one whose worktree holds the current folder; --against <lot> compares with main and that lot only; appends the run to the lot folder's forecast.jsonl (one line per comparison, one write, each line at most 4,096 bytes: 10 shared paths, 10 conflict paths, 3 ranges per path, the rest counted in moreShared and more) and a forecast event (its trigger: start, scope, gate, forecast or land, the verbs that record a run); a pair whose lots both change a lock file reads exclusive even when it merges clean; a gate --fast or --full run in a lot's worktree forecasts the lot as its last step and prints forecast: <verdict> with one ! <against>: <why> line per comparison it does not clear (a warning only: the gate's verdict and exit never change); the card shows a conflicts line on a conflict or an unknown, a pair seen from either lot (the newer line wins), and its scope line names each open lot it shares entries with (forecast <verdict>, <age>); --json { lot, verdict, lines }; exit 0 clean, 1 a conflict or an exclusive path (or the run could not be written), 3 unknown, 2 usage, an unknown id, a damaged, closed or simulated lot, or --against the lot itself or a lot of another store; a clean forecast does not promise a semantic merge, three lots landing together, or work not written yet",
2444
+ "risk - reads the lot folder's (or hand-over folder's) risk.jsonl and the worktree's diff against the lot's base, writing nothing: the risk class derived now with its reasons (high: a changed file in the package's dialecte.risk.high list, the base's and the worktree's together, an added destructive call or git argument on a line that is not a comment alone, a runtime package (one with an exports map) whose API index changed or whose export source changed against the base without its index; light: docs, a version bump, or at most 40 changed lines in at most 3 files; medium otherwise; a declared reason reads <file>: declared [<glob>]), the effort recorded, the cap of review rounds, a ! line when the effort is below the class, ending (by <who>: <reason>) or (no go-ahead recorded); a derivation that cannot run (no commit to compare to) falls back to the last derived line, else class unknown, and ends with ! risk class not derived: <reason>, exit 0; --json the same as one object, under a versioned JSON schema (lot-risk.schema.json, version 1); exit 2 for usage, an unknown id or a damaged store lot (lot risk: <name> damaged: <reason>)",
2445
+ "risk --effort - appends one effort line { schema, kind: effort, at, effort, class?, by, reason? } to risk.jsonl (the last line wins); the same effort, class and reason as the last line answers already, nothing written; an effort below the class needs --reason; a derivation that cannot run compares against the last derived line, or nothing, and records; --by is required; --json is refused here; refused (exit 2, nothing written) for usage, below without --reason, a forbidden word, a damaged store lot, or a lot that is committed, canceled or failed; exit 1 when the line cannot be written",
2446
+ "wait - returns the status as soon as the lot needs someone (exit 0 ready or committed, 1 failed or canceled, 3 input-required, 4 a limit) or --timeout is reached (5); a damaged lot at once (6); a real lot is read every second and nothing written, a simulated lot is played to its next blocking point, and answered at once when nothing is left to play (5 while it works)",
2447
+ "answer - records the answer to an open question once (the same answer again: already); a person question needs --by <who>; a damaged lot takes none (exit 2); runs the onAnswered hooks; next: lot wait",
2448
+ "result - never blocks, writes nothing: a ready or committed lot gives its hand-over (card, show and run lines), worktree, branch and answered questions; failed or canceled the last reason (exit 1); input-required the open questions (3); working exit 5; damaged exit 6",
2449
+ "stop - ends the lot: refused once committed; a pending hand-over is abandoned first (refused while its run is in progress), then a canceled transition with the reason and --by (caller without it); already canceled exits 0 writing nothing; moves no worktree and deletes nothing; a damaged lot has its folder moved to <git common folder>/dialecte-lots-aside/ with a stopped.json (refused while a live run marker holds it), its index kept claimed",
2450
+ "scope - changes a started lot's scope on the record, its brief left as published; --by and --reason are required on every call; --drop removes scope entries (an entry, or a folder and the entries inside it), --add widens the scope (a path inside a held entry is recorded as its own entry; only an equal entry answers already holds, nothing written, exit 0); --drop and --add may come in one call to narrow a folder to files: one append, the drop line first; a drop is refused for a path that is no entry or lies inside a wider one, a worktree that cannot be read, a drop leaving the lot no scope, or a file the lot's worktree changed inside a dropped entry that no entry left covers (an equal entry, a literal folder holding it, or a glob matching it; the call's adds count); an add is refused when a path is no valid scope entry, or when it meets another open lot's scope and that lot still holds it: the lot's work is forecast against it (trigger scope, recorded only once the add stands) and a clean pair adds with no overlap record; a forecast conflict (its files and ranges), a met lock file, a forecast that cannot run, or a damaged or unreadable lot refuse, unless --overlap-ok accepts an overlap that names its paths (a damaged lot whose scope reads too, its damage recorded) (recorded in overlaps.jsonl before the add with the other lot, the met pairs, --by and --reason, undone with a taken-back add; a lot whose scope cannot be read stays refused; --overlap-ok without --add is refused); a call whose lines would pass the line limit is refused; an add a lot started or widened meanwhile meets is taken back by an undo line, the entries a drop of the same call removed put back (exit 2), a take-back that would pass the line limit refusing the call first (exit 2), a take-back that cannot be written exiting 1 naming the paths and that lot; each change is one line of scope-changes.jsonl ({ schema, at, op, paths, by?, reason? }) and a scope.changed event; the effective scope (the brief's with the changes) is what the overlap guard, lot status and the card read; a damaged, simulated, committed, canceled or failed lot, a forbidden word and a change line that does not read are refused (exit 2), nothing written; a line that cannot be written exits 1",
2451
+ "station - appends one station event (by: host) to the lot's events.jsonl, never rewriting a line: start answers its run and the end command; end pairs with --run, else with the one open start of its station, step, round and attempt (several: refused), else repeats the last such end carrying a cost field with the same fields (already, nothing written), else is recorded alone (started: null); --event <id> again answers the first event (already) or is refused when its fields differ; start is refused on a committed, canceled or failed lot, end is accepted in every state; a simulated lot writes simulated: true; text fields refuse control, line-break and direction characters, vendor, model, tier, effort and session at most 80 characters, step, round and attempt 1-999, tokens, runs and duration non-negative, at most 50 skills (hash: sha256 of the path or of the synced <folder>/<name>/SKILL.md, else null), a verdict of approve, back, fix-then-repass, fixed, disagreed, answered, failed, limit; a line over 4,096 bytes is refused; --from takes the same fields plus phase (start|end) as one JSON object, unknown keys refused, every fault at once; --json { recorded: new|already, run, next }",
2452
+ "--by - one line, not empty, checked before the lot is read (answer and stop)",
2453
+ "<id> - an index (171 = 0171), a full name, a lot folder or .dialecte/lot; a write verb needs an index unique across every store of the store list, a word naming an existing folder is that folder",
2454
+ "exempt|accept|revised|gone|moved|mutation - write .dialecte/lot.json at the package root (tab JSON), keeping the rest",
2455
+ "moved - a case of the lot moved by a split or a rename of its file or describe after its red (its own title is part of its test call): two cases, or a file (never a glob) and the file or glob its cases moved to under the same names, several files into one each with its entry; tdd red carries the red (flag moved) when the test call and the test code it reads are as that red froze them and it does not pass on the base production, else refuses",
2456
+ "accept - a case is <file>::<name>",
2457
+ "revised - a file or a glob covers every case of its files",
2458
+ "--remove - drops the accept, revised, gone or moved entry written exactly so (a list left empty leaves the file); an entry its list does not hold is refused, naming the closest ones, nothing written",
2459
+ "mutation - absent: changed when the diff touches the declared scope, off otherwise; gate = changed that the hand-over waits for",
2460
+ "finding - appends R<n>-<k> open to <folder>/findings-ledger.md (made when absent)",
2461
+ "decide - rewrites that finding's state cell, every other byte kept",
2462
+ "snapshot - copies what git status lists to round-<n>/, the deletions to round-<n>.deleted, HEAD to round-<n>.base, { schema, at, stateHash } to round-<n>.state; the folder is a lot folder or stays outside every repository; -- ends the options; the risk class is derived again from the diff first and appended to risk.jsonl as a derived line only when the snapshot goes ahead, a refused snapshot writing nothing (a derivation that cannot run prints ! risk class not derived: <reason> and appends nothing); the cap of review rounds is the rounds of the higher of the effort's class and the class derived now (else the last derived line's) (low or light 1, medium 2, high 3; the effort is the last line of lot risk --effort, else the lot's; a class above the effort prints ! risk class now <class> (<reason>): cap <cap>); with no effort recorded the cap is 1 and a later round is refused (exit 2) naming dialecte lot risk <folder> --effort low|medium|high --by <who>; a round above the cap of an effort is refused (exit 2), naming what set the cap ((effort <e>), or (effort <e>, risk class <c>) when a class raised it), unless --beyond-cap --by <who> --reason <text> gives the go-ahead, written to decisions.md as round <n> beyond the cap of <cap>: <reason> before the snapshot (once: a retry finds it); --beyond-cap within the cap, --by or --reason without it, and --by or --reason holding a forbidden word are refused (exit 2), nothing written",
2463
+ "choice - appends | decision | who | yyyy-mm-dd | to <folder>/decisions.md (made when absent)",
2464
+ "standard - writes <folder>/standard.json (state, note, time), read by the card's standard line; outside (the lot's asks answered outside the documents, written by ask itself) warns, and fails at effort high unless the record's confirmed flag is true (written by ask once a person confirmed every outside answer; by hand false): the flag decides, never the note text",
2465
+ "delta - per file, the diff from round-<n-1>/ to the worktree now; --worktree adds a throwaway worktree holding round n-1 and prints its removal command",
2466
+ "recap - the <details> part of a pull request from the hand-over's records only; writes nothing",
2467
+ "verify - run inside the lot's worktree: appends { schema, at, by, note, state } to <folder>/verify.jsonl in one write, state the worktree's state hash; a change of the tree after the last round-<n>/ snapshot is a late fix: the card warns and handover run refuses it (exit 2) until a verify covers the current state (one later change needs a new verify); a snapshot with no round-<n>.state (an older cli) is not checked; no snapshot yet (nothing is late), --by or --note missing, blank or not one line, or holding a forbidden word are refused (exit 2), nothing written",
2468
+ "report - reads files only (no git, no process, nothing written): the lot's stations, tokens, money, time, suites per station by time, heavy steps, folders and review rounds from its events.jsonl, transitions, ledger and cards.log; a number nobody reported is unknown, never 0, and a step family whose runs may be unrecorded reads unknown with the reason; --feature lists every lot of that feature in every store (simulated ones counted apart, listed by --simulated; a lot whose folder is gone is read from its cards.log line); next: the lot's own next command",
2469
+ "export - copies a lot folder to <dir>/<full name>/ without asks/ (links kept as links, those pointing outside it named), adding the lot's cards.log lines and registry entry; refused for a <dir> inside a git work tree and for an existing <dir>/<full name>; every copied file compared by size and sha256 (events.jsonl as a prefix) before the rename, one more copy on a difference; the source is never written",
2470
+ "prune - removes what a committed or canceled lot leaves behind, each item on its own proof: the lots named by id, else the lots of --feature in every store of the list, else every lot of every store (--all), else every lot of the store of the folder it runs from; base branches fetched first; per lot its line (state, landing) and one line per item - its worktree (the same proof as lot close: kept with why), its review throwaways (recorded by a step's throwaway-add, or cut by hand at a commit of the lot with no commit of their own: they go when every changed path is held by a commit, else kept naming the path held nowhere), its branch and its throwaways' branches; an open lot's items are kept, reason lot <name> <state>; a branch is kept while it is the base, the branch the main checkout is on, an open lot's branch, the stack parent of an open lot, a pending hand-over's or a stash's, while deleting it would lose a commit (a canceled lot's names its commits and the command to delete it anyway), and goes after its worktree when one checks it out; a lot whose worktree is gone and whose landing is not proven is listed stale with the command to stop it; without --yes the plan only; --yes acts in order (worktrees, throwaways, branches), each proof read again at the move: a throwaway proved again after its move, a branch deleted at its proved tip only (git update-ref -d), a branch still parked in the trash listed waiting for the trash; a throwaway's --force removal starts only after its second proof, so a file written into it in that moment goes with it; a deleted branch is restorable with git branch <branch> <tip> (its removing line in cards.log holds the tip) until git's garbage collection, its upstream config is not restored; worktrees git refused to delete from the trash for more than ten minutes are listed with their git status and the forced removal, a throwaway its second proof left in the trash with why and the command that moves it back; a git read an item's decision rests on that fails keeps the item (could not read <what>: <git's error>), never reads as empty; ids, --feature and --all exclude each other; exit 1 when an item meant to go was kept (one another run removed since the plan is no failure), 2 for a usage error or an id that names no lot or more than one",
2471
+ "close - closes a lot or a hand-over: a hand-over of the registry (by name or index), or a lot (its id, name or index), with no registry entry needed; first the landing of every lot the arguments reach (the lot named, the lot an entry registers, the open lots naming an entry's worktree and branch) is read, with the host asked for every lot it reads (one never pushed by lot land, its branch deleted on origin after the merge, included): merged (its tip on the base, its pull request merged - the one landing.json names, else the newest of its branch whose head the branch reached, a pull request opened by hand included - or its work contained in origin/<base>, a squash read offline) writes its landed fact in <lot folder>/landed.json, commits its pending entry (a lot with none is closed as the lot itself: no registry entry is made) and every outcome reaching it carries the line landed on <base> at <commit>: <how>, landed in --json; a lot named by its id that is open is kept with lot <name> <state>: why (its work not in the base, its pull request closed, the commits it holds since part of it landed, or the host's silence); a lot whose branch and worktree are gone reads its landing from the latest card line of its own or of a hand-over on its branch whose entry names its worktree, written since the lot was made; a canceled lot closes, its landing never read; then for each committed or abandoned hand-over, and each committed or canceled lot named by its id: its final record first, the card line in the repository's cards.log (a catch-up one when none exists, for every hand-over of the worktree, read back), then a removing line, then its worktree moved to .worktrees/_trash/ and removed in the background by git worktree remove without --force (git refuses one written into since the check: it stays in .worktrees/_trash/), its node_modules parked in .worktrees/_pool-<repository>-<n>, its caches to their own _trash/ entries, then a removed line (trashed or kept); a commit dropped from its branch (reset or rebased away), held by the branch reflog alone, is named under the closed line: git expires it with that reflog (gc.reflogExpireUnreachable), as it would have with the worktree's; a landed or canceled lot's own .dialecte/lot.json (its .dialecte/lot link naming the lot's folder) archived in that folder first, as lot.json, or lot.landed.json beside a lot.json holding other bytes, never over one, kept when both hold other bytes; kept first when an open lot names it (reason lot <name> <state>), then with why when it is the main checkout, on another branch than the hand-over's, locked, another hand-over of the same worktree is neither committed nor abandoned, a link from outside it points into it, dirty, a landed lot holds commits made since its landing (<n> commit(s) made since its landing: <commits>), its removal would lose a commit (<n> commit(s) its removal would lose: <commits>: a commit only its HEAD or HEAD reflog reaches, that no surviving branch, branch reflog, tag, landed tip or remote-tracking ref holds, nor the same change at the same place (a commit of theirs with the same diff, its hunk line numbers included) - a commit made on a detached HEAD), it holds ignored files its removal would delete that nothing else holds (rebuilt folders, dialecte.rebuiltIgnored folders, the .dialecte/lot link, an empty or archived .dialecte/lot.json and copies byte-equal to the main checkout's go), a process or a mutation run works there, lot close itself runs from inside it, or the processes are not known, or the final record cannot be kept or the lot's commit is not known; the branch never touched; a hand-over already closed, or a lot whose worktree a recorded removal moved, answers already closed, exit 0, nothing moved (a lot whose worktree is gone with no such removal: nothing to close), its lot's landed fact still recorded when the host proves the merge (its landed line beside already closed); exit 1 when one is kept, 2 when a name or index is neither a hand-over nor a lot (the others are still closed)"
2472
+ ],
2473
+ exitCodes: [
2474
+ "1 risk --effort: the line could not be written",
2475
+ "2 risk: usage; unknown id; a damaged store lot; --effort below the class without --reason, no --by, a forbidden word, a lot that is committed, canceled or failed",
2476
+ "2 start: an effort below the risk class without --by and --reason",
2477
+ "1 station: the event could not be written",
2478
+ "2 station: usage; refused (a field, the lot state, open starts, --event with other fields, over 4,096 bytes); --run naming no start",
2479
+ "1 report: --feature names no lot",
2480
+ "2 report: usage; unknown or ambiguous id",
2481
+ "1 export: the check failed twice, nothing left",
2482
+ "2 export: usage; refused",
2483
+ "3 wait, result: input-required",
2484
+ "4 wait: an agent failed or hit a limit, run again",
2485
+ "5 wait --timeout, result: still working",
2486
+ "6 status, wait, result: the lot is damaged: a person must look"
2487
+ ],
2488
+ example: 'dialecte lot finding ../handover --round 1 --severity nit --at src/a.ts:3 "a finding"'
2489
+ },
2490
+ inbox: {
2491
+ family: "Grow",
2492
+ summary: "What waits on someone across every lot store: health findings, questions for a person, questions for a caller, ready hand-overs, failed lots",
2493
+ usage: ["dialecte inbox [--repository <name>] [--simulated] [--json]"],
2494
+ notes: [
2495
+ "reads every store of the store list and the store of the current folder, and the cli scratch folders of the temporary folder, files only: first one line per health finding, red first (duplicate work, landing time and slow worktree adds of the last 24 hours; stalled runs, idle worktrees and leaked scratch folders as they are now), <\u2717|!> health <repository>[ <lot>] <rule>: <finding> next: <command>; a red finding waits, an amber one is listed only",
2496
+ "then one line per waiting lot (one per open question), grouped person, caller, ready, failed and by index, each with its exact next command; then working <n> \xB7 simulated <m>; a lot whose records do not read is a damaged line",
2497
+ "--repository - the lots and the health findings of the repository folder of that name only (the basename, exactly), the counts too; the health of no other repository and no scratch folder is read",
2498
+ "--simulated - the simulated lots that wait are listed in their groups (they are only counted without it)",
2499
+ "--json - { waiting: the status of each waiting lot, working, simulated, damaged, skipped: the stores not read (only when one is), health: the findings (empty when none) }"
2500
+ ],
2501
+ exitCodes: ["1 no lot waits, no lot is damaged and no health finding is red"],
2502
+ example: "dialecte inbox --repository scl"
2503
+ },
2504
+ health: {
2505
+ family: "Grow",
2506
+ summary: "What went wrong lately across every lot store: duplicate work, slow landings, stalled runs, idle worktrees and leaked scratch folders",
2507
+ usage: ["dialecte health [--since <date|duration>] [--repository <name>] [--json]"],
2508
+ notes: [
2509
+ "reads every store of the store list and the store of the current folder (each once), and the cli scratch folders of the temporary folder, files only: a header with the red and amber counts, then one block per finding (red first, newest first, idle worktrees and leaked scratch after the runs) with its detail lines and its next command; with no finding, one ok line naming the rules",
2510
+ "--since - the window of the duplicate work, landing time and worktree add rules: <n>h, <n>d, a date (its midnight UTC) or a date and time with its zone; default 7d",
2511
+ "--repository - the findings of the repository folder of that name only (the basename, exactly); the scratch folders, which belong to no repository, are left out",
2512
+ "--json - { since, findings, counts: { red, amber } }"
2513
+ ],
2514
+ exitCodes: ["1 a red finding"],
2515
+ example: "dialecte health --since 24h"
2516
+ },
2517
+ plan: {
2518
+ family: "Plan",
2519
+ summary: "What can start now in a plan's lot block, whether the block is valid, a mark on an entry",
2520
+ usage: [
2521
+ "dialecte plan next <plan.md> [--json] [--all]",
2522
+ "dialecte plan check <plan.md> [--json]",
2523
+ "dialecte plan mark <plan.md> <id> done --by <who> [--reason <text>]",
2524
+ "dialecte plan mark <plan.md> <id> done --landed <sha> --by <who> --reason <text>",
2525
+ "dialecte plan mark <plan.md> <id> superseded --by <who> --reason <text> [--replaced-by <id>]..."
2526
+ ],
2527
+ notes: [
2528
+ "the block - one fenced ```json dialecte-lots block in the plan, or the file <plan without .md>.lots.json beside it (both or neither: refused); each entry's id, kind (lot, fix, spec, person), dependsOn, scope per repository, heavy steps, brief and match (branch, handover, feature); unknown keys refused, every fault at once",
2529
+ "next - proposes only, starts and writes nothing: the state of each entry read from the stores, the hand-over registries and the worktrees of its repositories (files only, no git process: a lot reads committed by its registry entry or its landed fact, landed.json, which lot land, lot close and worktree prune write once its landing is merged), the open lots, the lots that can start in critical-path order (shares:, merge:, unverified, stacks, next command), the held ones with each scope pair met (a ready lot meeting an open lot is proposed with shares: <pair> (<lot>, forecast clean) when the last forecast that lot recorded is known and shows no conflict inside the met entries; it stays held on a met lock file, a conflict inside the met entries, or an open lot with no known forecast; two ready lots that meet are both proposed), the landed lots (lot <name> committed: hand-over committed in <folder>, branch on <target>; until lot close closes that hand-over), person entries without a mark, the spec work, what each entry waits for, the parked ones, the live heavy steps with the load against twice the cores and the available memory against 2 GB (advice only); --all lists the done entries; --json { plan, repositories, counts, entries, proposals, held, landed, specWork, heavy, unknown }",
2530
+ "check - the block parses and every repository is a git main checkout (two names for one common folder refused); one line when valid; --json { plan, valid, faults }",
2531
+ "mark - a person entry only: appends { plan, id, state: done, by, reason, at } to <state>/dialecte/plans/<sha256 of the plan's real path, 16 hex>.jsonl, once (again: already); per machine; --landed <sha> for a lot or fix entry landed outside the lot store (a lot landed by hand, or stopped after its work landed in another lot): one --landed per repository of the entry (<repository>:<sha>; a bare <sha> for an entry of one repository); origin fetched, each commit must be on origin's base branch of its repository and change a path of the entry's scope there; the mark records { landed: [{ commit, repository }] } and the entry reads done by them (realizedBy kind landed); an entry its records already say done takes none (answered, nothing recorded); a lot or fix entry takes no plain mark, a person entry no --landed",
2532
+ "mark superseded - an entry of any kind other entries replaced: appends { plan, id, state: superseded, by, reason, at, replacedBy } (each --replaced-by an id of the block, never the entry itself; replacedBy [] when none is given), once (again: already); --reason required, --landed refused; the entry reads done (realizedBy kind superseded, name the --by), so nothing waits on it; the replacing entries do not take over its dependents (a dependent that needs their work names them in its dependsOn); --all lists it as <id> (superseded by <ids>); an entry its records already say done takes none (answered, nothing recorded)"
2533
+ ],
2534
+ exitCodes: [
2535
+ "1 next: no lot or fix can start now (spec work may still be listed)",
2536
+ "2 usage; no block or an invalid one (every fault listed); a repository that is not a git checkout; mark: a lot or fix entry without --landed (or without --reason), a person entry with it, a commit not on the base branch of origin, an unknown id; superseded without --reason, with --landed, or a --replaced-by not in the block or the entry itself; --replaced-by with done"
2537
+ ],
2538
+ example: "dialecte plan next 33-LOT-ENGINE.md"
2539
+ },
2540
+ gate: {
2541
+ family: "Check",
2542
+ summary: "The package's Definition of Done with the real counts",
2543
+ usage: [
2544
+ "dialecte gate [--fast | --full] [--base <ref>] [--no-reuse] [--declare <path>]... [--json]",
2545
+ "dialecte gate --hook [--no-reuse]",
2546
+ "dialecte gate --release [--base <ref>] [--no-reuse] [--json]"
2547
+ ],
2548
+ notes: [
2549
+ 'steps from package.json "dialecte": { "gate", "generatedDocs" } or the defaults; --full then runs npm run type-narrowing when the package has that script and no step runs it (a skip line when it lacks it); refuses while a hand-over script holds the repository',
2550
+ "--fast - the default; starts with the worktree's hygiene (nothing staged, no stash on its branch, new files declared)",
2551
+ "in a lot's own worktree, --fast and --full end with the lot's conflict forecast against main and every open lot (as lot forecast, recorded with trigger gate): forecast: <verdict>, then one ! <against>: <why> line per comparison it does not clear, said before the notes and the verdict; --json adds forecast { verdict, lines }; a warning only, the gate's verdict and exit never change; none in a review throwaway, none for --release",
2552
+ "a failing vitest test step is rerun once, serially, on its failing files: passing there it is flagged flaky in parallel",
2553
+ "the default lists end with a scoped rules step (dialecte rules); a step whose run starts with the word dialecte runs as the gate's own cli (its node and entry file, never node_modules/.bin), its line ending (dialecte <version>); a missing dialecte bin fails that step, never the gate",
2554
+ "a green record of the same tree, install and steps answers the steps after a fresh tdd step; --no-reuse runs them",
2555
+ "--full and --release hold the machine awake while they run (macOS: caffeinate -i -w <pid>; DIALECTE_KEEP_AWAKE=0 turns it off); a run that spanned a sleep keeps sleptMs on its record and the card says it",
2556
+ '--hook - in a commit hook, no test suite (CI runs it on every push): with "dialecte.gate.hook" declared, the tdd receipts of the lot first (every new or changed case since the lot base proven red then green, unchanged, accepted or revised, its newest green at the production as committed; a stale green names dialecte tdd green (measured from the lot base); a first or merge commit skips it), then the declared steps (the cli: check, then rules on the touched files); without one, every step of --full, a scoped one against the hook base; each step answered by a green record (any mode) of the committed tree and install that ran it as it is now, else run; the running line names the steps it runs',
2557
+ '--release - alone: "dialecte.gate.release" (default: the --full steps), every scoped step against the empty tree (--base feeds only the tdd step); records dialecte-gate-release.json; each of its steps answers a hook step of the same step hash (a scoped one at any base: it checked everything); its green record answers a rehearsal, contrib and the card when the list covers full (same name, run, counts and changedOnly for every full step)',
2558
+ `scoped steps ("scoped": true) get DIALECTE_GATE_BASE, _TREE, _CHANGED (the changed paths byte for byte, NUL-separated, relative to the repository top as git diff --name-only names them; a declared failing path is relative to the package root) and _SELECTION, where they write { schema: 1, base, tree, changed, selected: [{ id, reasons }], skipped: [{ id, reason }] } (both lists required, reasons non-empty); the base is --base <ref>, else the merge-base with the base branch (the first found: "dialecte.baseBranch", origin/HEAD, main, master; each local, else on origin), else the empty tree; a local base branch holding commits origin's lacks: a note naming the count, the base read from origin's; select from the working files; without the gate (no DIALECTE_GATE_SELECTION): select everything`,
2559
+ 'a step whose run is npm run <script> the package lacks is not wired: a default step fails a --full or --release run (a --fast one says it and goes on), a declared step fails in every mode; then no step runs, the others read not run: a step of the list is not wired; "dialecte": { "gate": { "skip": { "<default step>": "<reason>" } } } (dialecte.gate.skip) opts a default step out, a warning with its reason',
2560
+ `a scoped step: an empty selection exits 0 without starting vitest (nothing selected since <base> (<n> paths changed)); a non-empty one on a counts: "tests" step that runs no test fails; a failed scoped step counting tests is rerun once serially on a test failure (a failed test, a FAIL line, vitest's error markers), whatever runs it: the failing files (after -- through npm run), then --no-file-parallelism, and it must select the same ids (one vitest invocation, or --passWithNoTests on each); the selection may declare "failing": [paths relative to the package] the record keeps with the ones the output names; "heavy": true marks a heavy suite, outside the command hash`
2561
+ ],
2562
+ exitCodes: [
2563
+ "2 an option the usage lines do not name, or --base / --declare given last without its value: the usage printed (--json: { error, usage, next: null }); no step run"
2564
+ ],
2565
+ example: "dialecte gate --full"
2566
+ },
2567
+ tdd: {
2568
+ family: "Check",
2569
+ summary: "Receipts that each new test failed on an assertion before the code, then passed untouched",
2570
+ usage: [
2571
+ "dialecte tdd red [<test file>]... [--base <ref>] [--json]",
2572
+ "dialecte tdd green [<test file> | <test file>::<case name>]... [--base <ref>]",
2573
+ "dialecte tdd status [--base <ref>] [--json] [--flags] | tdd status --legend"
2574
+ ],
2575
+ notes: [
2576
+ "red - every case of the changed test files must fail on an assertion (or a stub's 'not implemented' inside an asserting expect); a passing new case, a missing export, a type or syntax error, a timeout, a .only is refused; the files without a refusal are frozen",
2577
+ "green - each case with a red receipt, its test code as frozen, production changed since its red, passes; records a green receipt",
2578
+ "status - per case red, green, unchanged, missing receipt, test edited after red, flags",
2579
+ "base - the change is measured from the lot base: HEAD's fork point from the base branch (the newer of the local branch and origin's), or from an open stack parent's line; HEAD only when no base branch is found; a green taken before a rebase still counts after it",
2580
+ "--base - measure from where HEAD left the ref given instead of the lot base",
2581
+ "declarations - a gone or moved entry of the lot file naming a path the change leaves unchanged, or one known nowhere (not at the base, not now, not in the receipts), is refused before any run, naming its lot gone --remove or lot moved --remove; a test file deleted on disk is a deleted file, never read",
2582
+ "--legend - the tdd terms of the hand-over card"
2583
+ ],
2584
+ exitCodes: [],
2585
+ example: "dialecte tdd green"
2586
+ },
2587
+ rules: {
2588
+ family: "Check",
2589
+ summary: "Code-rules self-check of the changed files (syntax tree, not greps)",
2590
+ usage: ["dialecte rules [<files...>] [--json]", "dialecte rules --base <ref> [--json]"],
2591
+ notes: [
2592
+ "types / constants in their files, named functions, no await in an argument, object parameters, full words, no standard citation (nor, in a contributor profile, a plan tag, acceptance criterion or ticket number); temporary-root-shared; raw-git-repository on test and test support files (a git clone / git init argument list in a git call, init --bare aside: make the repository through a test helper that gives it an identity; allowable); bare-tmpdir on production files (every temporary folder under one scratch root; allowable); their messages name the cli helpers only in the cli",
2593
+ "a contributor: no consumer name nor forbidden word (git config dialecte.forbiddenWords and $XDG_CONFIG_HOME/dialecte/forbidden-words, else ~/.config/dialecte/forbidden-words; whole words, any case); no list: one line, and the check is not run",
2594
+ "without files: the changed list a scoped gate step hands (DIALECTE_GATE_CHANGED), else the files changed against HEAD and the new ones; a file it cannot read or parse is an error",
2595
+ "quality rules: argument-mutation, query-in-loop, long-function on implementation files; table-branch, without-export-xml, export-without-queries, fixture-builder, plan-tag on test-shaped files; on test-shaped Dialecte changes: xml-splice, xml-replace, transaction-spy, act-repeats-call, act-snapshot, act-format-check, inline-document-long, expected-fixture, fixture-case-comment (warning), test-file-long, fixture-file-long, fixtures-module, fixture-builder an error; in an app only Dialecte-change script files are judged, the others counted in one line (a contributor package is never an app); with the gate base, an error on a line the change did not add is a warning; without a gate base, or with an empty-tree one (as gate --release hands), the order every caller shares: in the worktree of a store lot its lot base read from git (its fork point from the base branch, or from the line of the lot it was started on while that lot is open; never the base recorded at its start, which a rebase leaves behind; with no base branch found, the newest of the commit it recorded at its start, when HEAD holds it, and a release tag descending from that commit, else no base), else the merge-base with the base branch (skipped, for an empty-tree base and for a run without a gate base, when it is the commit of HEAD), else the last release tag <name>@v<version>, else no base and every error kept; a lot base that cannot be read (its stack parent unreadable) is no base, never the merge-base, said in a rules: no base (<why>) line by every run that reads the order: without a gate base, with an empty-tree one, and on the contrib rules row; a run without a gate base prints one line naming it (rules: base <sha> (the lot <name> | the merge-base with <branch> | the merge-base with the base branch | the release tag <tag>), or rules: no base (<why>) when the lot base cannot be read)",
2596
+ "changelog-edit (an error), in a package keeping a changes/ folder: CHANGELOG.md edited without the package version bumped; write the entry in changes/<lot>.md (dialecte changelog)",
2597
+ "released-changelog (an error, no opt-out), on CHANGELOG.md in every package: a released ## [<version>] section the change altered - lines added, removed or reordered, the section removed, or its heading repeated - judged against the base branch and where the change left it (a section main corrected after the branch point, or a release the branch predates, is no finding); the release base a rehearsal hands its hooks (DIALECTE_RELEASE_BASE, to the scoped rules step alone) replaces the base branch; no base branch: one line, not judged (--json: releasedChangelogNotJudged)",
2598
+ "--base <ref>: the files changed from the merge-base of <ref> and HEAD to the worktree are judged (deletions left out; uncommitted ones in), that merge-base the base of the softening as a gate base would be; files given with it, or a ref naming no commit, exit 2",
2599
+ "base-aware rules (warnings, against the base the run judges the change from: --base, else the lot base, else, in a run that is no scoped gate step, the base branch merge-base; never a release tag, an empty tree nor the gate base): duplicate-read, an added function reading the same element and three or more attributes as an existing one (a named set counts three), or whose name shares two words with an existing function it does not call (generic words such as read, list, file, path or name left out); shared-export-changed, an export imported by a file of another folder (a sub-folder included) newly shared, re-signed (its parameters, return type, or a sibling .types.ts type they name), its body changed, or removed; docs-not-updated, in a contributor library (no bin), a public api.json entry added, re-signed or removed whose doc page (doc/ Markdown or README naming its last two route segments, or its whole route in a code span) the change did not touch; one line names where they stand: quality: since <short> (lot | base-branch | flag), quality: not run (no lot) in a scoped gate step outside any lot, no line when there is no base or no package.json; notes under it: public API: <route> removed: still named by <pages>, ! public API unknown (<why>), aliases changed, when a tsconfig or Vite config changed (the base edges read with the aliases of the tree); a run that judged the whole change writes dialecte-quality.json in the worktree git folder; contrib never runs them",
2600
+ "--json: dialecteChanges (the verdict of each file), notJudged, baseLine, qualityLine, quality (the base, the examined files, duplicates, sharedExports, publicApi, docs); described by rules.schema.json (schema 1)",
2601
+ "opt-out: // dialecte-allow <rule>[, <rule>]: <reason> (15 characters at least) on the line or the line before (for argument-mutation, long-function also in the comments before the function, its doc comment included; for act-repeats-call, act-snapshot, act-format-check inside an act also the line before the act); fixture-file-long: <!-- dialecte-allow fixture-file-long: <reason> --> on the first line of the fixture; invalid-allow, unused-allow; --json counts the findings silenced per rule in allowed",
2602
+ "an API index that cannot be read: query-in-loop does not run, one line names the file and why",
2603
+ "not judged: an alias of a parameter or of a query (aliases are not followed); query-in-loop is syntactic and one level (a read in a function the loop calls is not seen); a table imported from a sibling file; plan-tag flags round, step or station followed by a number in a title (reword it, or opt out); fixture-builder reads a <word> placeholder in a template string as XML (opt out); act-repeats-call counts a call after an early-return arm that makes the same call as two; a *Query-named binding that is no query, or a run with no readable API index (no core groups), can make a unit of a call chain"
2604
+ ],
2605
+ exitCodes: [],
2606
+ example: "dialecte rules src/commands/lot.ts"
2607
+ },
2608
+ contrib: {
2609
+ family: "Check",
2610
+ summary: "The contributor checks of a dialecte package (profile contributor)",
2611
+ usage: ["dialecte contrib [--no-reuse] [--json]"],
2612
+ notes: [
2613
+ 'after gate --full and before handover: rules on the changed files (against the base of the lot, the order the rules step of the gate shares: the lot base of the store lot read from git (its fork point, never the base recorded at its start), else the merge-base with the base branch, as the rules step of the gate takes it, else the last release tag <name>@v<version>, every error kept without any; a rehearsal against the tip its last merge lot merges, else the gate base of the repository at the HEAD of the lots file: an error on a line the base holds is a warning), the "dialecte": { "contrib": { "steps" } } (default: npm run doc:build with the generatedDocs restored, npm run type-bench:check), npm run type-narrowing when the package has that script and no step runs it (a skip line when it lacks it), no dependency named by a local folder, the mutation line when a scope is declared',
2614
+ "the changelog row (after rules): first the released CHANGELOG.md sections, on every run, changed by the lot or not (a merge brings them): a section altered against the base branch and where the change left it fails the row, naming it (rules: released-changelog); the record is keyed on the base's and the merge-base's CHANGELOG.md, so a release on main runs the row again; then in a package keeping changes/, a change that edits README.md, a page under doc/ or a file the package lists in dialecte.changelog.asking (a folder ends in /; the cli lists its command map) adds a changelog fragment changes/<lot>.md, or a no-entry note changes/<lot>.none.md saying why; else it fails naming the file",
2615
+ "a step a green gate --full of this tree and install passed with the same command is not run again; --no-reuse runs every row",
2616
+ 'a step whose run is npm run <script> the package lacks is not wired: it fails, default or declared; then no row runs, the others read not run: a step of the list is not wired; "dialecte": { "contrib": { "skip": { "<default step>": "<reason>" } } } (dialecte.contrib.skip) opts a default step out, a warning with its reason'
2617
+ ],
2618
+ exitCodes: ["2 refused in a consumer (nothing written)"],
2619
+ example: "dialecte contrib"
2620
+ },
2621
+ changelog: {
2622
+ family: "Check",
2623
+ summary: "Changelog fragments (changes/<lot>.md): check them, or fold them into CHANGELOG.md for a release",
2624
+ usage: [
2625
+ "dialecte changelog check [--base <revision>]",
2626
+ "dialecte changelog release <x.y.z> [--date YYYY-MM-DD]"
2627
+ ],
2628
+ notes: [
2629
+ "a fragment: one changes/<name>.md per lot (a no-entry note changes/<name>.none.md holds why a visible change has none), its entries under the changelog headings ### Added, Changed, Deprecated, Removed, Fixed, Security; a package keeping a changes/ folder edits CHANGELOG.md only in a release (rules: changelog-edit)",
2630
+ "check - every fragment readable (a known heading, no loose text, no empty or repeated section), the Unreleased part of CHANGELOG.md, then its released sections: none altered against the base branch and where the change left it (rules: released-changelog); --base <revision> judges against that commit alone, the one the change goes onto (the CI check step hands the merge queue's base, or a pull request merge ref's first parent)",
2631
+ "release - writes ## [<x.y.z>] - <date> (default today, local) under an emptied ## [Unreleased] (written above the first version when missing): the Unreleased summary and entries first, then each fragment in file name order, section by section, one entry per line; deletes the fragments and the no-entry notes; nothing written when a fragment or the Unreleased part cannot be read"
2632
+ ],
2633
+ exitCodes: [
2634
+ "1 a fragment or the Unreleased part cannot be read, a released section is altered (check), the release is refused (no CHANGELOG.md, version already there, nothing to release), or a fragment could not be deleted",
2635
+ "2 usage: no verb, a version that is no x.y.z, a date that is no YYYY-MM-DD; --base names no commit of the repository"
2636
+ ],
2637
+ example: "dialecte changelog release 0.8.0"
2638
+ },
2639
+ ci: {
2640
+ family: "Check",
2641
+ summary: "The CI files shipped as a template: write them into the package, report drift, run the publish guard",
2642
+ usage: ["dialecte ci sync [--dry-run]", "dialecte ci check", "dialecte ci publish-decision"],
2643
+ notes: [
2644
+ "the template: the workflows (ci.yml, publish.yml and their reusables), .github/pull_request_template.md, .nvmrc and changes/.gitkeep; ci.yml selects its jobs from package.json: type-perf with a type-bench:check script, docs with a doc:build script, the Playwright install with a playwright dependency, the npm run skills:check step of the check job with a skills:check script; the check job always runs rules --base of the cli over the change (the base sha of the merge queue, else HEAD^1, skipped on a dispatch), where --no-verify cannot skip it; a build script is required (publish.yml builds the package)",
2645
+ "the repository owns .github/workflows/_test.yml (ci.yml calls it: a workflow_call trigger; a mode input of type string gets pr on a pull request, full in the merge queue) and every other workflow file the template does not name; they are listed, never written",
2646
+ "sync - writes what differs from the template, deletes the retired files (pr.yml, _lint.yml) and the reusables no job of the package calls; an update prints its diff; a second run is in step; --dry-run writes nothing",
2647
+ "check - the same comparison, read-only: each drifted file with its diff, then the fix; the template's _check.yml runs it on every pull request",
2648
+ "publish-decision - the publish guard of the push to main (BEFORE, GITHUB_OUTPUT): publish above npm's latest, a pre-release under next, a missing release tag pushed alone, a failed npm query refused",
2649
+ "publish.yml keeps its name and its push trigger: npm trusted publishing names the file"
2650
+ ],
2651
+ exitCodes: [
2652
+ "1 sync: the own _test.yml is missing or breaks the contract (the managed files are written); check: drift or a broken contract; publish-decision: refused, or BEFORE, GITHUB_OUTPUT, package.json or git failed",
2653
+ "2 usage, no package.json, a package.json with no name or no build script"
2654
+ ],
2655
+ example: "dialecte ci sync --dry-run"
2656
+ },
2657
+ mutants: {
2658
+ family: "Check",
2659
+ summary: "Mutation testing of the declared scope; survivors tracked until handled",
2660
+ usage: [
2661
+ "dialecte mutants run [--mode changed|audit] [--base <ref>]",
2662
+ "dialecte mutants status [--json]",
2663
+ "dialecte mutants schedule <follow-up> <key>... | schedule <follow-up> --all-new [--json]",
2664
+ "dialecte mutants abandon <run id> [--json]",
2665
+ "dialecte mutants migrate [--json]",
2666
+ "dialecte mutants judge [--file <file>] [--json]",
2667
+ "dialecte mutants record (--key <key>... | --file <file>) --family <family> --reason <text> [--removable] [--json]",
2668
+ "dialecte mutants drop <run id> [--json]"
2669
+ ],
2670
+ notes: [
2671
+ `run - Stryker on package.json "dialecte": { "mutation" }; changed = the scope lines changed since the merge base, audit = the whole scope; without --mode the lot's switch decides`,
2672
+ "status - running runs with their age, died runs, new survivors by lot, scheduled by follow-up",
2673
+ "judge - per file, the new survivors with the code around each, its covering tests, a family guess",
2674
+ "record - writes .dialecte/mutation-records.json, then moves the survivors to recorded"
2675
+ ],
2676
+ exitCodes: ["1 run: only when Stryker fails, never on survivors"],
2677
+ example: "dialecte mutants run --mode changed"
2678
+ },
2679
+ handover: {
2680
+ family: "Hand over",
2681
+ summary: "The guarded commit-by-lots hand-over a human runs, from a lots file",
2682
+ usage: [
2683
+ "dialecte handover write <lots.json> [--release] [--target <branch>] [--out <id|folder>] [--rehash] [--json]",
2684
+ "dialecte handover show [<name|folder>] [--json]",
2685
+ "dialecte handover review <name|index|folder> [--json] [--print]",
2686
+ "dialecte handover run [<name|folder>] [--rehearse [--keep] [--full]] [--resume-merge] [--not-a-lot --by <who> --reason <text>]",
2687
+ "dialecte handover abandon [<name|folder>]",
2688
+ "dialecte handover list [--root <dir>] [--json]",
2689
+ "dialecte handover --legend"
2690
+ ],
2691
+ notes: [
2692
+ "write - the hand-over folder (lots.json, snapshot, one-line commit.sh) and its card, registered in <git common dir>/dialecte-handover/<name>.json under the real path of the folder; handover <lots.json> is the same; --out <id> writes into the lot folder, refused (exit 2, nothing written) for a simulated, canceled or failed lot, an open question, a lots file of another worktree or branch; any folder whose hand-over is committed is refused",
2693
+ "write --target <branch> - the branch the lots land on, recorded as target in lots.json (default: the base branch resolved at write time); a branch with neither a local nor an origin ref is refused (exit 2, nothing written)",
2694
+ "show - the card again, recomputed, nothing written; without an argument the newest of the branch; BLOCKED with a ! line when the target branch moved past the hand-over (merge it first); BLOCKED with a \u2717 processes line naming the processes left running in the worktree (no terminal, not under an editor, not named in git config dialecte.personProcesses); BLOCKED with a \u2717 merges line when a merge lot not committed yet has no recorded tree, worded as run refuses it",
2695
+ "review - opens the hand-over's worktree in a new editor window, started detached (a hand-over holding a merge lot first writes review/lot.diff, the lot's change against head, and opens it too); the editor: git config dialecte.editor in the worktree (its words, no flag added), else the first known editor found on PATH, else code; never $EDITOR; --print prints the command line and starts nothing, --json answers { editor, command, opened }; refused (exit 2) for an unknown hand-over, a worktree that is gone, an editor not found",
2696
+ "run - what commit.sh runs: each guard with its time, each lot announced, the hook live, the card; without a folder the one registered hand-over still to run; --rehearse commits in a scratch clone; refuses a canceled lot (exit 2); the lot guard refuses a hand-over folder that is not a lot of the store (exit 2) unless --not-a-lot --by <who> --reason <text> gives the go-ahead, recorded first as a not a store lot: row of its decisions.md (an existing row counts), and always a simulated or damaged lot; a rehearsal prints ! and goes on; holds the machine awake while it runs, and a run that spanned a sleep says so on the DONE card; a run that committed lots archives every non-empty lot file of the worktree (the root's and each tracked package's) in the folder, lots/<package path>/ for a package, lot.landed.json beside a lot.json holding other bytes, and empties it; a run that committed none leaves them as they are",
2697
+ "abandon - marks a hand-over that will not run (abandoned.json) and releases its lock; refuses a lot folder (exit 2): rewrite it with write --rehash --out <full name>, end the lot with lot stop",
2698
+ "list - every hand-over folder: repository, worktree, branch, lots, age, state",
2699
+ "--legend - every term of the card, what it means, whether to look"
2700
+ ],
2701
+ exitCodes: [
2702
+ "2 every verb: an option its usage lines do not name, or a value option given last without its value: the usage printed (--json: { error, usage, next: null } where the verb takes --json); nothing read or written",
2703
+ "2 run: the target branch moved past the hand-over (merge it first) or has no ref, a process left running in the worktree or a process list not known, a gate config the cli cannot run, a canceled lot, a hand-over that is not a lot of the store (without --not-a-lot), a simulated or damaged lot, --not-a-lot without --by and --reason (or --by/--reason without it), a forbidden word in --by or --reason; nothing committed",
2704
+ "2 write: a --target branch with neither a local nor an origin ref, no base branch found without --target, an --out the lot folder refuses; nothing written"
2705
+ ],
2706
+ example: "dialecte handover write ../handover/lots.json"
2707
+ },
2708
+ worktree: {
2709
+ family: "Workspace",
2710
+ summary: "A worktree ready to work in; prune what a merge left",
2711
+ usage: [
2712
+ "dialecte worktree add <repository> <branch> [--from <ref>] [--json]",
2713
+ "dialecte worktree prune [--root <workspace>] [--yes] [--json]",
2714
+ "dialecte worktree prune [--root <workspace>] --reclaim [--dry-run] [--older-than <days>]"
2715
+ ],
2716
+ notes: [
2717
+ "add - under the workspace's .worktrees/: hooks folder, the links its file: and link: dependencies need to sibling checkouts, node_modules taken from the pool when an entry matches package-lock.json's lock key, else a near entry (at most 5 packages off) completed by npm install --prefer-offline --no-save, else npm ci, a copy-on-write copy only when npm ci fails (the reason on the card), read against package-lock.json (the npm ci to run when it differs), hygiene baseline",
2718
+ "prune - merged worktrees and branches, committed hand-overs, rehearsal clones: the commands with their cd; a worktree whose folder is gone is kept while its HEAD reflog holds work nothing else does (git worktree prune would delete that reflog), and git worktree prune waits while one is kept; a store lot's items (its worktree, its review throwaways <lot worktree>-round-<n> and -verify, its branch and theirs) are never removed here and no landing is read: an open lot's are kept, reason lot <name> <state>, a committed or canceled lot's are listed lot <name> <state>: its own item, removed by dialecte lot prune <name>; a worktree whose branch's work is not in the base is kept (not landed: its work is not in <base>); a worktree or a branch whose removal would lose a commit is kept with its commits (<n> commit(s) its removal would lose: <commits>; a surviving branch, branch reflog, tag, landed tip or remote-tracking ref holds a commit, or the same change at the same place (a commit with the same diff, its hunk line numbers included); deleting a branch takes its reflog); a worktree a process works in is kept (a process works in it: pid <pid>; processes not known: kept with why); ignored entries are read as lot close reads them: rebuilt folders, .dialecte/ views and copies of the main checkout's files go, anything else keeps the worktree (ignored files git worktree remove would delete: <paths>); a rehearsal clone is kept while its marker is missing or unparsable, or its pid runs; --yes runs them after a confirmation on a terminal; committed hand-over folders and finished rehearsal clones go to the trash like the other items: the plan shows the move (mkdir -p <trash> && mv <folder> <trash>/), --yes makes it; a move that cannot be made is a \u2717 line, nothing deleted; the pool (.worktrees/_pool-<repository>-<n>) and the trash (.worktrees/_trash/) are counted, never touched",
2719
+ "prune --reclaim - every worktree idle for --older-than days (default 2: no write to its index, HEAD or reflog since), not the main checkout, not locked, named by no open lot (a failed lot keeps) nor open hand-over, worked in by no process, reached by no link: its node_modules parked in the pool when its lock key is the main checkout's and it installs that lock, else sent to .worktrees/_trash/, its code never touched, a -round-<n> review throwaway's too; a node_modules that is a link is never moved; every rule checked again just before each move; one line per worktree, the total (worktrees, files, size) last; --dry-run moves nothing; --dry-run or --older-than without --reclaim, or an --older-than that is no positive whole number, exit 2"
2720
+ ],
2721
+ exitCodes: [
2722
+ "0 add: the worktree exists, whatever the links and the lockfile say",
2723
+ "1 add: a new branch without --from, and the base branch refused (a dialecte.baseBranch set to a branch that exists nowhere, local or on origin, or no base branch found); no worktree made"
2724
+ ],
2725
+ example: "dialecte worktree add cli feat/my-change"
2726
+ },
2727
+ doctor: {
2728
+ family: "Workspace",
2729
+ summary: "Installed versions, core API generation, skills in sync, local checkouts",
2730
+ usage: [
2731
+ "dialecte doctor [--json]",
2732
+ "dialecte doctor --brief",
2733
+ "dialecte doctor --host [--vendor <name>]"
2734
+ ],
2735
+ notes: [
2736
+ "what to fix before trusting what you read",
2737
+ "--brief - the session-start form, nothing when in sync, one line per problem",
2738
+ "--host - runs every read of the repository's host once, for real, through the cli's own code (the newest merged pull request, its checks and queued state, a reference pull request's line comments, the stack extension), then the tool versions against the recorded ones and git against its floor; only those lines; network by name; --vendor <name> probes that vendor whatever the origin"
2739
+ ],
2740
+ exitCodes: [
2741
+ "1 a warning",
2742
+ "0 --brief, always",
2743
+ "1 --host: an error (a read refused, a changed answer, git below its floor, no vendor); a warning (nothing to probe, a part not installed, an older tool) never fails",
2744
+ "2 --host: usage (--vendor given without a vendor name)"
2745
+ ],
2746
+ example: "dialecte doctor --brief"
2747
+ },
2748
+ models: {
2749
+ family: "Workspace",
2750
+ summary: "Which model each tier (fast, standard, strong, frontier) means for the project's vendor",
2751
+ usage: ["dialecte models [--vendor <anthropic|openai|google>] [--json]"],
2752
+ notes: [],
2753
+ exitCodes: ["1 an unknown vendor", "2 no vendor known"],
2754
+ example: "dialecte models --vendor openai"
2755
+ },
2756
+ skills: {
2757
+ family: "Workspace",
2758
+ summary: "Agent skills shipped in skills/<name>/: sync | generate | check | changed",
2759
+ usage: [
2760
+ "dialecte skills sync [--agent claude,copilot,agents] [--copy] [--from <workspace>] [--contributing | --no-contributing] [--vendor <id>] [--no-session-check] [--agents-file | --no-agents-file]",
2761
+ "dialecte skills generate [zero-config flags]",
2762
+ "dialecte skills check [--workspace <dir>] [zero-config flags]",
2763
+ "dialecte skills changed [--base <ref>]"
2764
+ ],
2765
+ notes: [
2766
+ "sync - install the consumer skills of your dependencies (or of local checkouts) for your agents; --contributing adds the contributor skills, remembered until --no-contributing; remembers the model vendor; with the contributor skills, a doctor --brief session-start check in AGENTS.md and the station agents (--no-session-check leaves the check out); a missing AGENTS.md is created only on a yes or with --agents-file, the section is never removed, and --no-agents-file leaves AGENTS.md alone",
2767
+ "generate - rewrite the generated blocks (verb map, method index, hook files) from the source",
2768
+ "check - fail on a cited API / path / npm script / cli invocation that does not exist, or a stale block",
2769
+ "changed - per skill, hand-written change (evals due) or generated blocks only"
2770
+ ],
2771
+ exitCodes: [],
2772
+ example: "dialecte skills sync --agent claude"
2773
+ },
2774
+ corpus: {
2775
+ family: "Workspace",
2776
+ summary: "The open-licence corpora fetched into a cache, and the licensed ones of config.yml",
2777
+ usage: [
2778
+ "dialecte corpus fetch [<id>...] [--json]",
2779
+ "dialecte corpus list [--json]",
2780
+ "dialecte corpus check [--json]",
2781
+ "dialecte corpus add <name> --xsd <path> [--instances <folder>]"
2782
+ ],
2783
+ notes: [
2784
+ "fetch - the sources of the shipped manifest (every one, or the ids named): each refused without its licence, terms and a known verdict, with an id that names an entry of the cache itself, or with a download not pinned by a sha256; each download (no redirect followed, at most 512 MiB, aborted after 120 s without data) checked against its pin (a kept one in _downloads/ first, so a run without network rebuilds), its archive members kept and stripped (at most 1 GiB inflated), a member outside its folder refusing the source, then exclude, marker, substitute and wrappers; written to <cache>/<id>/ and named in manifest.lock.json once in place; a refused source changes nothing of what it had; one fetch writes a cache at a time (fetch.lock: another running fetch refuses the run); the cache: $DIALECTE_CORPORA_DIR, else corpora/ in the cli cache folder ($XDG_CACHE_HOME/dialecte, else ~/.cache/dialecte); never committed",
2785
+ "list - every open source (fetched; stale: from another manifest entry, without a lock entry the cli reads, or a locked file gone; or missing) and every licensed entry of config.yml corpora: (present or missing), with its verdict, entry schemas, instances (a folder and its globs) and instance count; exit 0 whatever is missing; --json (version 1) is the reader for a validation tier",
2786
+ "check - a fetched source whose files no longer match its fetch (edited, missing, added) or its manifest entry, and a licensed entry whose files are missing, one line each",
2787
+ "add - writes corpora.<name> of the personal config.yml with absolute paths, its comments kept; refused for a name holding a dot or a path that does not exist"
2788
+ ],
2789
+ exitCodes: [
2790
+ "0 list: whatever is missing",
2791
+ "1 fetch: a source refused; check: a problem named",
2792
+ "2 fetch: an unknown source id; add: no --xsd, a name holding a dot, a path that does not exist; a refused config.yml"
2793
+ ],
2794
+ example: "dialecte corpus list --json"
2795
+ },
2796
+ bench: {
2797
+ family: "Maintain",
2798
+ summary: "Measure type-instantiation cost (tsc --extendedDiagnostics); --check to gate CI",
2799
+ usage: ["dialecte bench [--check] [zero-config flags]"],
2800
+ notes: [
2801
+ "writes benchmarks/types/baseline.json; --check fails on a >5% instantiation regression",
2802
+ "tsgo (TypeScript 7+) runs with one checker (--checkers 1), so a file set always gives the same count; the baseline records the compiler and its exact version",
2803
+ "--check gives no verdict against a baseline from another compiler or version, or one that records none: re-baseline in its own commit"
2804
+ ],
2805
+ exitCodes: [
2806
+ "1 --check: an instantiation regression past 5%",
2807
+ "2 --check: no baseline.json to compare with (run dialecte bench to write it)",
2808
+ "3 --check: a baseline from another compiler or version, or one that records no compiler"
2809
+ ],
2810
+ example: "dialecte bench --check"
2811
+ },
2812
+ coverage: {
2813
+ family: "Maintain",
2814
+ summary: "Generate type-coverage probes (surface, valid calls, deep, full method surface with extensions)",
2815
+ usage: ["dialecte coverage [zero-config flags] [--format-config <path> | --no-format]"],
2816
+ notes: [],
2817
+ exitCodes: [],
2818
+ example: "dialecte coverage"
2819
+ },
2820
+ narrowing: {
2821
+ family: "Maintain",
2822
+ summary: "Gate: assert schema-derived type narrowing still holds (IntelliSense safety net)",
2823
+ usage: ["dialecte narrowing [zero-config flags]"],
2824
+ notes: [],
2825
+ exitCodes: [],
2826
+ example: "dialecte narrowing"
2827
+ },
2828
+ audit: {
2829
+ family: "Maintain",
2830
+ summary: "Render the public type surface and flag readability issues (C1-C6)",
2831
+ usage: ["dialecte audit [zero-config flags] [--format-config <path> | --no-format]"],
2832
+ notes: ["writes benchmarks/types/readability-audit.md"],
2833
+ exitCodes: [],
2834
+ example: "dialecte audit"
2835
+ },
2836
+ text: {
2837
+ family: "Maintain",
2838
+ summary: "The human part of a GitHub text, before it is posted",
2839
+ usage: ["dialecte text check <file> [--kind pr|issue|comment|commit]"],
2840
+ notes: [
2841
+ "the lines before <details: headings What changes, Why, How to check it (then Watch out) for pr and issue, none for comment and commit; word cap 150 | 200 | 80 | 100, headings and code blocks not counted; a commit subject of 72 at most"
2842
+ ],
2843
+ exitCodes: [],
2844
+ example: "dialecte text check pr.md --kind pr"
2845
+ },
2846
+ // the renamed commands: one key per command of the renamed forms, derived from that table
2847
+ ...renamedEntriesOf()
2848
+ };
2849
+
1838
2850
  // src/lib/doctor/answer-doctor.ts
1839
2851
  function answerDoctor(params) {
1840
2852
  const exitCode = params.lines.some((line) => line.status !== "ok") ? 1 : 0;
1841
2853
  if (params.json) return { output: endedOf(jsonOf({ lines: params.lines }, " ")), exitCode };
1842
2854
  return { output: endedTextOf2(params.lines.map(renderLine)), exitCode };
1843
2855
  }
2856
+ function answerHostDoctor(params) {
2857
+ const exitCode = params.lines.some(function isError(line) {
2858
+ return line.status === "error";
2859
+ }) ? 1 : 0;
2860
+ return { output: endedTextOf2(params.lines.map(renderLine)), exitCode };
2861
+ }
1844
2862
  function answerDoctorBrief(lines) {
1845
2863
  return {
1846
2864
  output: endedTextOf2(lines.filter((line) => line.status !== "ok").map(renderLine)),
@@ -1898,6 +2916,21 @@ var PROFILE_SUBJECT = "profile";
1898
2916
  var CONSUMER_ALLOWS_REFERENCES = "allowReferences is the consumer default: remove it";
1899
2917
  var CONTRIBUTOR_GATE_STEPS = "dialecte.gate.full holds {steps}: dialecte contrib runs them, move them to dialecte.contrib.steps (or drop them for the defaults)";
1900
2918
  var CONTRIBUTOR_SKILLS_NOT_SYNCED = "{folder} lacks the contributor skills: dialecte skills sync installs them in a contributor";
2919
+ var GIT_SUBJECT = "git";
2920
+ var HOST_VERSION_TEXTS = {
2921
+ asRecorded: "{version}, as recorded",
2922
+ newer: "{version}, newer than the recorded {recorded}",
2923
+ older: "{version}, older than the recorded {recorded}: a read may differ from the record",
2924
+ absent: "{absent} is not installed (recorded {recorded})",
2925
+ gitFloor: "git {floor} or later needed, found {line}"
2926
+ };
2927
+ var UPGRADE_TOOL_FIX = "upgrade {tool} to {recorded} or later";
2928
+ var HOST_SUBJECT = "host";
2929
+ var HOST_USAGE_START = "dialecte doctor --host";
2930
+ var VENDOR_NEEDS_NAME = "doctor: --vendor needs a vendor name";
2931
+ var VENDOR_EQUALS_FORM = "doctor: --vendor takes its name as the next word, not after =";
2932
+ var VENDOR_EQUALS_PREFIX = "--vendor=";
2933
+ var LEADING_DIGITS = /^\d+/;
1901
2934
 
1902
2935
  // src/lib/doctor/profile-lines.ts
1903
2936
  import { existsSync as existsSync16 } from "fs";
@@ -2229,164 +3262,1792 @@ function diagnose(context) {
2229
3262
  ...context.brief ? [] : localCheckouts(context)
2230
3263
  ];
2231
3264
  }
2232
- function installedPackages(cwd) {
2233
- const declared = declaredVersions(cwd);
2234
- return Object.keys(declared).filter((name) => name.startsWith(DIALECTE_SCOPE)).sort(TEXT_COLLATOR.compare).map(function packageLine(name) {
2235
- const version = installedVersion({ cwd, name });
2236
- if (version === void 0)
2237
- return { status: "warning", subject: name, detail: "not installed", fix: INSTALL_COMMAND };
2238
- const pinned = declared[name];
2239
- if (/^\d/.test(pinned) && pinned !== version)
2240
- return {
2241
- status: "warning",
2242
- subject: name,
2243
- detail: `${version} installed, ${pinned} declared`,
2244
- fix: INSTALL_COMMAND
2245
- };
2246
- return { status: "ok", subject: name, detail: version };
3265
+ function installedPackages(cwd) {
3266
+ const declared = declaredVersions(cwd);
3267
+ return Object.keys(declared).filter((name) => name.startsWith(DIALECTE_SCOPE)).sort(TEXT_COLLATOR.compare).map(function packageLine(name) {
3268
+ const version = installedVersion({ cwd, name });
3269
+ if (version === void 0)
3270
+ return { status: "warning", subject: name, detail: "not installed", fix: INSTALL_COMMAND };
3271
+ const pinned = declared[name];
3272
+ if (/^\d/.test(pinned) && pinned !== version)
3273
+ return {
3274
+ status: "warning",
3275
+ subject: name,
3276
+ detail: `${version} installed, ${pinned} declared`,
3277
+ fix: INSTALL_COMMAND
3278
+ };
3279
+ return { status: "ok", subject: name, detail: version };
3280
+ });
3281
+ }
3282
+ function coreGenerations(cwd) {
3283
+ const dialectes = dependencyNames(cwd).sort(TEXT_COLLATOR.compare).flatMap(function dialecteOnCore(name) {
3284
+ const folder = findInstalledPackage({ cwd, name });
3285
+ return folder && dependsOnCore(folder) ? [{ name, folder }] : [];
3286
+ });
3287
+ const appCore = installedVersion({ cwd, name: CORE_PACKAGE2 });
3288
+ const owners = dialectes.length ? dialectes : [{ name: void 0, folder: cwd }];
3289
+ return owners.flatMap(function generationLine({ name, folder }) {
3290
+ const version = installedVersion({ cwd: folder, name: CORE_PACKAGE2 });
3291
+ if (version === void 0) return [];
3292
+ const [major = 0, minor = 0] = version.split(".").map(Number);
3293
+ const generation = CORE_API_GENERATIONS.find(
3294
+ ({ from }) => major > from[0] || major === from[0] && minor >= from[1]
3295
+ );
3296
+ if (!generation) return [];
3297
+ const says = `${generation.name}: ${generation.says}`;
3298
+ if (name && appCore !== void 0 && appCore !== version)
3299
+ return [
3300
+ {
3301
+ status: "warning",
3302
+ subject: "core API",
3303
+ detail: `${name} on core ${version}, your app on core ${appCore}: two cores side by side (${says})`,
3304
+ fix: ALIGN_CORE_FIX
3305
+ }
3306
+ ];
3307
+ const owner = name ? `${name} on core ${version}` : `core ${version}`;
3308
+ return [{ status: "ok", subject: "core API", detail: `${owner} - ${says}` }];
3309
+ });
3310
+ }
3311
+ function skills(cwd) {
3312
+ const { sources } = discoverSkillSources({ cwd });
3313
+ if (sources.length === 0)
3314
+ return [{ status: "ok", subject: "skills", detail: "no dependency ships skills" }];
3315
+ const synced = Object.values(AGENT_SKILL_FOLDERS).filter(
3316
+ (folder) => existsSync19(join24(cwd, folder, MANIFEST_FILE))
3317
+ );
3318
+ if (synced.length === 0)
3319
+ return [
3320
+ {
3321
+ status: "warning",
3322
+ subject: "skills",
3323
+ detail: `not installed for your agents (${sources.map((source) => source.name).join(", ")} shipped)`,
3324
+ fix: SYNC_COMMAND
3325
+ }
3326
+ ];
3327
+ const contributor = isContributor(cwd);
3328
+ return synced.map(function syncLine(folder) {
3329
+ const manifest = readSyncManifest(join24(cwd, folder));
3330
+ const expected = selectAudience({
3331
+ sources,
3332
+ contributing: contributor || manifest.contributing === true
3333
+ }).selected;
3334
+ const missing = expected.map((source) => source.name).filter((name) => !manifest.installed.includes(name));
3335
+ if (missing.length)
3336
+ return {
3337
+ status: "warning",
3338
+ subject: "skills",
3339
+ detail: `${folder} lacks ${missing.join(", ")}`,
3340
+ fix: SYNC_COMMAND
3341
+ };
3342
+ const stale = expected.flatMap(function staleCopy(source) {
3343
+ const recorded = manifest.versions[source.name];
3344
+ if (isLink(join24(cwd, folder, source.name)) || source.version === void 0) return [];
3345
+ if (recorded?.version === source.version) return [];
3346
+ return [
3347
+ `${source.name} of ${source.origin} ${recorded?.version ?? "an unknown version"}, ${source.version} installed`
3348
+ ];
3349
+ });
3350
+ if (stale.length)
3351
+ return {
3352
+ status: "warning",
3353
+ subject: "skills",
3354
+ detail: `${folder} holds ${stale.join("; ")}`,
3355
+ fix: SYNC_COMMAND
3356
+ };
3357
+ return { status: "ok", subject: "skills", detail: `${folder} in sync with node_modules` };
3358
+ });
3359
+ }
3360
+ function isContributor(cwd) {
3361
+ try {
3362
+ return readProfile(cwd) === "contributor";
3363
+ } catch {
3364
+ return false;
3365
+ }
3366
+ }
3367
+ function isLink(path) {
3368
+ try {
3369
+ return lstatSync5(path).isSymbolicLink();
3370
+ } catch {
3371
+ return false;
3372
+ }
3373
+ }
3374
+ function dependsOnCore(folder) {
3375
+ const manifest = JSON.parse(readFileSync13(join24(folder, "package.json"), "utf8"));
3376
+ return manifest.name !== CORE_PACKAGE2 && (manifest.dependencies?.[CORE_PACKAGE2] !== void 0 || manifest.peerDependencies?.[CORE_PACKAGE2] !== void 0);
3377
+ }
3378
+ function localCheckouts(context) {
3379
+ const roots = [
3380
+ ...new Set([context.dialecteRoot, dirname11(resolve5(context.cwd))].filter(isDefined2))
3381
+ ];
3382
+ return roots.map(function checkoutLine(root) {
3383
+ const names = existsSync19(root) ? readdirSync10(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && join24(root, entry.name) !== resolve5(context.cwd)).filter((entry) => packageName(join24(root, entry.name))?.startsWith(DIALECTE_SCOPE)).map((entry) => entry.name).sort(TEXT_COLLATOR.compare) : [];
3384
+ return {
3385
+ status: "ok",
3386
+ subject: "checkouts",
3387
+ detail: names.length ? `${root}: ${names.slice(0, CHECKOUT_LIST_LIMIT).join(", ")}${names.length > CHECKOUT_LIST_LIMIT ? ` and ${names.length - CHECKOUT_LIST_LIMIT} more` : ""}` : `none in ${root} (the installed packages are the source)`
3388
+ };
3389
+ });
3390
+ }
3391
+ function declaredVersions(cwd) {
3392
+ const manifest = JSON.parse(readFileSync13(join24(cwd, "package.json"), "utf8"));
3393
+ const names = dependencyNames(cwd);
3394
+ return Object.fromEntries(
3395
+ names.map((name) => [
3396
+ name,
3397
+ String(
3398
+ manifest.dependencies?.[name] ?? manifest.devDependencies?.[name] ?? manifest.peerDependencies?.[name]
3399
+ )
3400
+ ])
3401
+ );
3402
+ }
3403
+ function installedVersion(params) {
3404
+ const folder = findInstalledPackage(params);
3405
+ if (!folder || !existsSync19(join24(folder, "package.json"))) return void 0;
3406
+ const version = JSON.parse(readFileSync13(join24(folder, "package.json"), "utf8")).version;
3407
+ return typeof version === "string" ? version : void 0;
3408
+ }
3409
+ function packageName(folder) {
3410
+ const path = join24(folder, "package.json");
3411
+ if (!existsSync19(path)) return void 0;
3412
+ const name = JSON.parse(readFileSync13(path, "utf8")).name;
3413
+ return typeof name === "string" ? name : void 0;
3414
+ }
3415
+ function isDefined2(value) {
3416
+ return value !== void 0;
3417
+ }
3418
+
3419
+ // src/lib/host/host.constants.ts
3420
+ var HOST_VENDOR_NAMES = ["github"];
3421
+ var HOST_READ_TIMEOUT_MS = 1e4;
3422
+ var HOST_WRITE_TIMEOUT_MS = 6e4;
3423
+ var BROWSER_OPENERS = {
3424
+ darwin: ["open"],
3425
+ win32: ["rundll32", "url.dll,FileProtocolHandler"],
3426
+ default: ["xdg-open"]
3427
+ };
3428
+ var OPEN_TIMEOUT_MS = 1e4;
3429
+ var HOST_READ_METHODS = [
3430
+ "readPullRequest",
3431
+ "readChecks",
3432
+ "readQueued",
3433
+ "probeStacks"
3434
+ ];
3435
+
3436
+ // src/lib/knowledge/standard/fill-message.constants.ts
3437
+ var PLACEHOLDER_PATTERN = /\{([^{}]+)\}/g;
3438
+
3439
+ // src/lib/knowledge/standard/fill-message.ts
3440
+ function fillMessage(params) {
3441
+ const { template, values } = params;
3442
+ return template.replace(
3443
+ PLACEHOLDER_PATTERN,
3444
+ function valueOf2(placeholder, name) {
3445
+ return Object.hasOwn(values, name) ? values[name] : placeholder;
3446
+ }
3447
+ );
3448
+ }
3449
+
3450
+ // src/lib/doctor/host-lines.ts
3451
+ function hostLines(params) {
3452
+ const { root, vendor, run } = params;
3453
+ const host = readAdapterOf({ host: params.host });
3454
+ const found = vendor.subject.find({ root, host, run, subject: vendor.subject.call });
3455
+ const reads = Object.entries(vendor.probes).map(function probeRead([subject, probe]) {
3456
+ return probe({
3457
+ root,
3458
+ host,
3459
+ run,
3460
+ subject,
3461
+ ...found.pullRequest !== void 0 && { pullRequest: found.pullRequest }
3462
+ });
3463
+ });
3464
+ return [
3465
+ found.line,
3466
+ ...reads,
3467
+ ...versionLines({ root, vendor, describe: params.describe }),
3468
+ gitLine({ root, readGitVersion: params.readGitVersion })
3469
+ ];
3470
+ }
3471
+ function readAdapterOf(params) {
3472
+ return Object.fromEntries(
3473
+ HOST_READ_METHODS.map(function readMethod(name) {
3474
+ return [name, params.host[name]];
3475
+ })
3476
+ );
3477
+ }
3478
+ function versionLines(params) {
3479
+ const { root, vendor } = params;
3480
+ return Object.entries(vendor.recordedVersions).map(function versionLine([part, recorded]) {
3481
+ const subject = `${vendor.tool} ${part}`;
3482
+ const answer = params.describe.versionOf({ root, selector: part });
3483
+ if ("absent" in answer)
3484
+ return {
3485
+ status: "warning",
3486
+ subject,
3487
+ detail: fillMessage({
3488
+ template: HOST_VERSION_TEXTS.absent,
3489
+ values: { absent: answer.absent, recorded }
3490
+ })
3491
+ };
3492
+ if ("refusal" in answer) return { status: "error", subject, detail: answer.refusal };
3493
+ const values = { version: answer.version, recorded };
3494
+ const order = compareVersions({ left: answer.version, right: recorded });
3495
+ if (order < 0)
3496
+ return {
3497
+ status: "warning",
3498
+ subject,
3499
+ detail: fillMessage({ template: HOST_VERSION_TEXTS.older, values }),
3500
+ fix: fillMessage({ template: UPGRADE_TOOL_FIX, values: { tool: subject, recorded } })
3501
+ };
3502
+ return {
3503
+ status: "ok",
3504
+ subject,
3505
+ detail: fillMessage({
3506
+ template: order > 0 ? HOST_VERSION_TEXTS.newer : HOST_VERSION_TEXTS.asRecorded,
3507
+ values
3508
+ })
3509
+ };
3510
+ });
3511
+ }
3512
+ function compareVersions(params) {
3513
+ const left = numbersOfVersion({ version: params.left });
3514
+ const right = numbersOfVersion({ version: params.right });
3515
+ for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
3516
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
3517
+ if (difference !== 0) return Math.sign(difference);
3518
+ }
3519
+ return 0;
3520
+ }
3521
+ function numbersOfVersion(params) {
3522
+ return params.version.split(".").map(function leadingNumber(part) {
3523
+ const digits = LEADING_DIGITS.exec(part)?.[0];
3524
+ return digits === void 0 ? 0 : Number(digits);
3525
+ });
3526
+ }
3527
+ function gitLine(params) {
3528
+ let text;
3529
+ try {
3530
+ text = params.readGitVersion({ root: params.root });
3531
+ } catch (error) {
3532
+ return {
3533
+ status: "error",
3534
+ subject: GIT_SUBJECT,
3535
+ detail: error instanceof Error ? error.message : String(error)
3536
+ };
3537
+ }
3538
+ const version = gitVersionOf({ text });
3539
+ if (version !== void 0 && !belowGitFloor({ version }))
3540
+ return { status: "ok", subject: GIT_SUBJECT, detail: version.line };
3541
+ return {
3542
+ status: "error",
3543
+ subject: GIT_SUBJECT,
3544
+ detail: fillMessage({
3545
+ template: HOST_VERSION_TEXTS.gitFloor,
3546
+ values: { floor: GIT_FLOOR.join("."), line: version?.line ?? (text.trim() || "nothing") }
3547
+ })
3548
+ };
3549
+ }
3550
+
3551
+ // src/lib/host/select-host.ts
3552
+ import { spawnSync as spawnSync6 } from "child_process";
3553
+ import { existsSync as existsSync22 } from "fs";
3554
+ import { homedir } from "os";
3555
+
3556
+ // src/lib/config/config-checks.ts
3557
+ function isMapping(value) {
3558
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3559
+ }
3560
+ function stringProblem(value) {
3561
+ return typeof value === "string" ? void 0 : "must be a text";
3562
+ }
3563
+ function hostVendorProblem(value) {
3564
+ const names = HOST_VENDOR_NAMES;
3565
+ return stringProblem(value) ?? (names.includes(String(value)) ? void 0 : `must be one of the known vendors: ${names.join(", ")}`);
3566
+ }
3567
+ function stringListProblem(value) {
3568
+ return Array.isArray(value) && value.every((item) => typeof item === "string") ? void 0 : "must be a list of texts";
3569
+ }
3570
+ function mappingProblem(value) {
3571
+ return isMapping(value) ? void 0 : "must be a mapping";
3572
+ }
3573
+ function unknownFieldProblem(params) {
3574
+ const unknown = Object.keys(params.value).find((field) => !params.allowed.includes(field));
3575
+ return unknown === void 0 ? void 0 : `has an unknown field '${unknown}' (allowed: ${params.allowed.join(", ")})`;
3576
+ }
3577
+ function referencesProblem(value) {
3578
+ if (!isMapping(value)) return "must be a mapping of allow and patterns";
3579
+ const unknown = unknownFieldProblem({ value, allowed: ["allow", "patterns"] });
3580
+ if (unknown !== void 0) return unknown;
3581
+ for (const field of ["allow", "patterns"]) {
3582
+ if (value[field] === void 0) continue;
3583
+ const problem = stringListProblem(value[field]);
3584
+ if (problem !== void 0) return `${field} ${problem}`;
3585
+ }
3586
+ return void 0;
3587
+ }
3588
+ function loadProblem(value) {
3589
+ if (!isMapping(value)) return "must be a mapping of budget";
3590
+ const unknown = unknownFieldProblem({ value, allowed: ["budget"] });
3591
+ if (unknown !== void 0) return unknown;
3592
+ const budget = value.budget;
3593
+ if (budget === void 0) return void 0;
3594
+ return typeof budget === "number" && Number.isInteger(budget) && budget >= 1 ? void 0 : "budget must be a whole number of 1 or more";
3595
+ }
3596
+ function corpusProblem(value) {
3597
+ if (!isMapping(value)) return "must be a mapping of xsd and instances";
3598
+ const unknown = unknownFieldProblem({ value, allowed: ["xsd", "instances"] });
3599
+ if (unknown !== void 0) return unknown;
3600
+ if (typeof value.xsd !== "string") return "needs xsd, the path of its XSD";
3601
+ if (value.instances !== void 0 && typeof value.instances !== "string")
3602
+ return "instances must be a text (a folder)";
3603
+ return void 0;
3604
+ }
3605
+ function corporaProblem(value) {
3606
+ if (!isMapping(value)) return "must be a mapping of corpus names";
3607
+ for (const [name, corpus] of Object.entries(value)) {
3608
+ const problem = corpusProblem(corpus);
3609
+ if (problem !== void 0) return `corpus '${name}' ${problem}`;
3610
+ }
3611
+ return void 0;
3612
+ }
3613
+
3614
+ // src/lib/config/config-keys.constants.ts
3615
+ var CONFIG_KEY_ENTRIES = [
3616
+ {
3617
+ key: "profile",
3618
+ layer: "project",
3619
+ repoOverride: false,
3620
+ description: "`contributor` (a package of the Dialecte family) or `consumer` (an app; the default).",
3621
+ problemOf: stringProblem
3622
+ },
3623
+ {
3624
+ key: "baseBranch",
3625
+ layer: "project",
3626
+ repoOverride: false,
3627
+ description: "The branch work is merged into (`main` when not said).",
3628
+ problemOf: stringProblem
3629
+ },
3630
+ {
3631
+ key: "gate",
3632
+ layer: "project",
3633
+ repoOverride: false,
3634
+ description: "Steps replacing the default ones of `dialecte gate` (fast, full, release, skip).",
3635
+ problemOf: mappingProblem
3636
+ },
3637
+ {
3638
+ key: "contrib",
3639
+ layer: "project",
3640
+ repoOverride: false,
3641
+ description: "The package steps of `dialecte contrib` (steps, skip).",
3642
+ problemOf: mappingProblem
3643
+ },
3644
+ {
3645
+ key: "tdd",
3646
+ layer: "project",
3647
+ repoOverride: false,
3648
+ description: "`dialecte tdd` settings (production: folders whose files are production code).",
3649
+ problemOf: mappingProblem
3650
+ },
3651
+ {
3652
+ key: "references",
3653
+ layer: "project",
3654
+ repoOverride: false,
3655
+ description: "allow: labels of generic patterns committed on purpose; patterns: regular expressions never committed.",
3656
+ problemOf: referencesProblem
3657
+ },
3658
+ {
3659
+ key: "mutation",
3660
+ layer: "project",
3661
+ repoOverride: false,
3662
+ description: "Mutation testing settings.",
3663
+ problemOf: mappingProblem
3664
+ },
3665
+ {
3666
+ key: "generatedDocs",
3667
+ layer: "project",
3668
+ repoOverride: false,
3669
+ description: "Files a docs build rewrites, restored byte for byte after `gate --full`.",
3670
+ problemOf: stringListProblem
3671
+ },
3672
+ {
3673
+ key: "risk",
3674
+ layer: "project",
3675
+ repoOverride: false,
3676
+ description: "Lot risk settings (high: globs of the shared concepts: a change there makes a lot high risk and needs an approved design).",
3677
+ problemOf: mappingProblem
3678
+ },
3679
+ {
3680
+ key: "rebuiltIgnored",
3681
+ layer: "project",
3682
+ repoOverride: false,
3683
+ description: "Ignored folders a build or a run rebuilds (`coverage/`): a worktree removal may delete them.",
3684
+ problemOf: stringListProblem
3685
+ },
3686
+ {
3687
+ key: "tsconfig",
3688
+ layer: "project",
3689
+ repoOverride: false,
3690
+ description: "The tsconfig of the type benchmarks.",
3691
+ problemOf: stringProblem
3692
+ },
3693
+ {
3694
+ key: "namespace",
3695
+ layer: "project",
3696
+ repoOverride: false,
3697
+ description: "The hydrated namespace of the dialect (the capitalized package name when not said).",
3698
+ problemOf: stringProblem
3699
+ },
3700
+ {
3701
+ key: "entry",
3702
+ layer: "project",
3703
+ repoOverride: false,
3704
+ description: "The import the type benchmarks read the dialect from.",
3705
+ problemOf: stringProblem
3706
+ },
3707
+ {
3708
+ key: "constantsDir",
3709
+ layer: "project",
3710
+ repoOverride: false,
3711
+ description: "The folder holding the generated constants of the dialect.",
3712
+ problemOf: stringProblem
3713
+ },
3714
+ {
3715
+ key: "out",
3716
+ layer: "project",
3717
+ repoOverride: false,
3718
+ description: "The folder the type benchmarks are written to.",
3719
+ problemOf: stringProblem
3720
+ },
3721
+ {
3722
+ key: "editor",
3723
+ layer: "personal",
3724
+ repoOverride: true,
3725
+ description: "The command opening a file in your editor.",
3726
+ problemOf: stringProblem
3727
+ },
3728
+ {
3729
+ key: "host",
3730
+ layer: "personal",
3731
+ repoOverride: true,
3732
+ description: "The host vendor of a repository whose origin names none (a self-hosted host), one of the known vendors.",
3733
+ problemOf: hostVendorProblem
3734
+ },
3735
+ {
3736
+ key: "load",
3737
+ layer: "personal",
3738
+ repoOverride: true,
3739
+ description: "Machine load settings (budget: a whole number of 1 or more).",
3740
+ problemOf: loadProblem
3741
+ },
3742
+ {
3743
+ key: "personProcesses",
3744
+ layer: "personal",
3745
+ repoOverride: true,
3746
+ description: "Your own tools' process names (a terminal, an editor), never counted as left behind in a worktree.",
3747
+ problemOf: stringListProblem
3748
+ },
3749
+ {
3750
+ key: "forbiddenWords",
3751
+ layer: "personal",
3752
+ repoOverride: true,
3753
+ description: "Words never committed, checked by `dialecte rules`.",
3754
+ problemOf: stringListProblem
3755
+ },
3756
+ {
3757
+ key: "consumerNames",
3758
+ layer: "personal",
3759
+ repoOverride: true,
3760
+ description: "The tools that consume a contributor package, which its committed text never names.",
3761
+ problemOf: stringListProblem
3762
+ },
3763
+ {
3764
+ key: "corpora",
3765
+ layer: "personal",
3766
+ repoOverride: false,
3767
+ description: "Licensed corpora by name: { xsd: path, instances?: folder }, never committed.",
3768
+ problemOf: corporaProblem
3769
+ }
3770
+ ];
3771
+ var CONFIG_KEYS = CONFIG_KEY_ENTRIES;
3772
+
3773
+ // src/lib/config/repo-key-of.ts
3774
+ import { existsSync as existsSync20, realpathSync as realpathSync4 } from "fs";
3775
+ import { dirname as dirname12, join as join25, posix, win32 } from "path";
3776
+
3777
+ // src/lib/config/find-old-homes.constants.ts
3778
+ var FORBIDDEN_WORDS_CONFIG_KEY = "forbiddenWords";
3779
+ var OLD_HOMES_LAST_READER = "cli 0.7";
3780
+ var GIT_KEY_NOTE = `git config {gitKey}: config.yml already holds it; run git config --unset {gitKey} once every repository is past ${OLD_HOMES_LAST_READER}`;
3781
+ var FORBIDDEN_WORDS_FILE_PROBLEM = `this file is no longer read and {file} ${FORBIDDEN_WORDS_CONFIG_KEY} lacks '{word}': add every word of this file there`;
3782
+ var FORBIDDEN_WORDS_FILE_NOTE = `{file}: config.yml ${FORBIDDEN_WORDS_CONFIG_KEY} already holds its words; delete it once every repository is past ${OLD_HOMES_LAST_READER}`;
3783
+ var GIT_KEY_EMPTY_NOTE = `git config {gitKey}: empty, nothing to migrate; run git config --unset {gitKey} once every repository is past ${OLD_HOMES_LAST_READER}`;
3784
+
3785
+ // src/lib/config/config.constants.ts
3786
+ var PROJECT_CONFIG_FILE_NAME = ".dialecterc";
3787
+ var PERSONAL_CONFIG_FOLDER_NAME = "dialecte";
3788
+ var PERSONAL_CONFIG_FILE_NAME = "config.yml";
3789
+ var CONFIG_SCHEMA_VERSION = 1;
3790
+ var CONFIG_SCHEMA_KEY = "schema";
3791
+ var CONFIG_REPOS_KEY = "repos";
3792
+ var REMOTE_SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
3793
+ var FILE_URL_SCHEME = /^file:\/\//i;
3794
+ var FILE_URL_DRIVE = /^\/([a-zA-Z]:)/;
3795
+ var REMOTE_SCP_FORM = /^(?:[^@/]+@)?([^:/]+):(.*)$/;
3796
+ var REMOTE_FORMS_BY_SCHEME = {
3797
+ https: "https",
3798
+ http: "https",
3799
+ "git+https": "https",
3800
+ ssh: "ssh",
3801
+ "git+ssh": "ssh",
3802
+ "ssh+git": "ssh"
3803
+ };
3804
+ var CASE_FOLDING_PLATFORMS = ["win32", "darwin"];
3805
+ var CONFIG_LAYER_FILE_LABELS = {
3806
+ project: ".dialecterc",
3807
+ personal: "the personal config.yml"
3808
+ };
3809
+ var CONFIG_SOURCE_RANKS = [
3810
+ "repo",
3811
+ "personal",
3812
+ "project"
3813
+ ];
3814
+ var CONFIG_LAYERS = ["project", "personal"];
3815
+ var DUPLICATE_REPOS_ENTRY_PROBLEM = "repos entry '{repo}' names the same repository as an earlier entry: only the first is used";
3816
+
3817
+ // src/lib/config/normalize-remote.ts
3818
+ function hostAndPathOf(url) {
3819
+ const withoutScheme = url.replace(REMOTE_SCHEME, "");
3820
+ const scp = url === withoutScheme ? REMOTE_SCP_FORM.exec(url) : null;
3821
+ if (scp !== null) return { host: scp[1], path: scp[2], form: "scp" };
3822
+ const scheme = url.slice(0, url.length - withoutScheme.length).replace("://", "");
3823
+ const form = REMOTE_FORMS_BY_SCHEME[scheme.toLowerCase()];
3824
+ const slash = withoutScheme.indexOf("/");
3825
+ const authority = slash === -1 ? withoutScheme : withoutScheme.slice(0, slash);
3826
+ const path = slash === -1 ? "" : withoutScheme.slice(slash + 1);
3827
+ const host = authority.slice(authority.lastIndexOf("@") + 1).replace(/:\d*$/, "");
3828
+ return { host, path, ...form !== void 0 && { form } };
3829
+ }
3830
+ function normalizeRemote(url) {
3831
+ const { host, path } = hostAndPathOf(url.trim());
3832
+ const trimmedPath = path.replace(/^\/+|\/+$/g, "").replace(/\.git$/, "").replace(/\/+$/, "");
3833
+ return `${host.toLowerCase()}/${trimmedPath}`;
3834
+ }
3835
+
3836
+ // src/lib/config/repo-key-of.ts
3837
+ function comparablePathOf(params) {
3838
+ return CASE_FOLDING_PLATFORMS.includes(params.platform) ? params.path.toLowerCase() : params.path;
3839
+ }
3840
+ function comparableWrittenPathOf(params) {
3841
+ const flavour = params.platform === "win32" ? win32 : posix;
3842
+ const normalized = flavour.normalize(params.path);
3843
+ const isRoot = normalized === flavour.parse(normalized).root;
3844
+ const trimmed = !isRoot && normalized.endsWith(flavour.sep) ? normalized.slice(0, -flavour.sep.length) : normalized;
3845
+ return comparablePathOf({ path: trimmed, platform: params.platform });
3846
+ }
3847
+ function repositoryTopOf(folder) {
3848
+ let current = folder;
3849
+ while (!existsSync20(join25(current, GIT_ENTRY))) {
3850
+ const parent = dirname12(current);
3851
+ if (parent === current) return folder;
3852
+ current = parent;
3853
+ }
3854
+ return current;
3855
+ }
3856
+ function pathOfFileUrl(params) {
3857
+ const path = decodeURIComponent(new URL(params.url).pathname);
3858
+ if (params.platform !== "win32") return path;
3859
+ return win32.normalize(path.replace(FILE_URL_DRIVE, "$1"));
3860
+ }
3861
+ function normalizeRepoKey(params) {
3862
+ const { key, platform } = params;
3863
+ if (FILE_URL_SCHEME.test(key))
3864
+ return comparableWrittenPathOf({ path: pathOfFileUrl({ url: key, platform }), platform });
3865
+ return isPathKey(key) ? comparableWrittenPathOf({ path: key, platform }) : normalizeRemote(key);
3866
+ }
3867
+ function isPathKey(key) {
3868
+ return posix.isAbsolute(key) || win32.isAbsolute(key);
3869
+ }
3870
+ function remoteOf(origin) {
3871
+ if (FILE_URL_SCHEME.test(origin) || isPathKey(origin)) return void 0;
3872
+ const { host, form } = hostAndPathOf(origin);
3873
+ return form === void 0 || host === "" ? void 0 : { host: host.toLowerCase(), form };
3874
+ }
3875
+ function repoKeyOf(params) {
3876
+ const origin = tryReadGit({ root: params.root, args: ["remote", "get-url", "origin"] })?.trim();
3877
+ if (origin) {
3878
+ const key = normalizeRepoKey({ key: origin, platform: params.platform });
3879
+ const remote = remoteOf(origin);
3880
+ return { key, from: "remote", ...remote !== void 0 && { remote } };
3881
+ }
3882
+ const path = repositoryTopOf(realpathSync4(params.root));
3883
+ return { key: comparablePathOf({ path, platform: params.platform }), from: "path" };
3884
+ }
3885
+
3886
+ // src/lib/config/resolve-config.ts
3887
+ import { join as join26 } from "path";
3888
+
3889
+ // src/lib/config/check-config-entry.ts
3890
+ function refusalOf(params) {
3891
+ const { entry, spec } = params;
3892
+ if (spec.layer !== params.layer)
3893
+ return `'${entry.key}' is a ${spec.layer} setting: it belongs in ${CONFIG_LAYER_FILE_LABELS[spec.layer]}, not in ${CONFIG_LAYER_FILE_LABELS[params.layer]}`;
3894
+ if (params.inRepos && !spec.repoOverride)
3895
+ return `'${entry.key}' cannot be set per repository: set it at the top level of ${CONFIG_LAYER_FILE_LABELS.personal}`;
3896
+ const problem = spec.problemOf(entry.value);
3897
+ return problem === void 0 ? void 0 : `'${entry.key}' ${problem}`;
3898
+ }
3899
+ function checkConfigEntry(params) {
3900
+ const { entry, layer } = params;
3901
+ const spec = params.keys.find((candidate) => candidate.key === entry.key);
3902
+ if (spec !== void 0) {
3903
+ const problem = refusalOf({ entry, spec, layer, inRepos: params.inRepos });
3904
+ return problem === void 0 ? { verdict: "accepted" } : { verdict: "refused", problem };
3905
+ }
3906
+ if (layer === "project" && entry.key === CONFIG_REPOS_KEY)
3907
+ return {
3908
+ verdict: "refused",
3909
+ problem: `'repos' holds personal overrides: it belongs in ${CONFIG_LAYER_FILE_LABELS.personal}, never in a committed file`
3910
+ };
3911
+ return { verdict: "unknown", problem: `'${entry.key}' is not a ${layer} setting (unknown key)` };
3912
+ }
3913
+
3914
+ // src/lib/config/personal-config-file-of.ts
3915
+ import { posix as posix3, win32 as win323 } from "path";
3916
+
3917
+ // src/lib/config/personal-config-folder-of.ts
3918
+ import { posix as posix2, win32 as win322 } from "path";
3919
+ function personalConfigFolderOf(params) {
3920
+ const xdg = params.environment.XDG_CONFIG_HOME;
3921
+ if (params.platform === "win32") {
3922
+ const appData = params.environment.APPDATA;
3923
+ const base = xdg || appData || win322.join(params.home, "AppData", "Roaming");
3924
+ return win322.join(base, PERSONAL_CONFIG_FOLDER_NAME);
3925
+ }
3926
+ return posix2.join(xdg || posix2.join(params.home, ".config"), PERSONAL_CONFIG_FOLDER_NAME);
3927
+ }
3928
+
3929
+ // src/lib/config/personal-config-file-of.ts
3930
+ function personalConfigFileOf(params) {
3931
+ const join34 = params.platform === "win32" ? win323.join : posix3.join;
3932
+ return join34(personalConfigFolderOf(params), PERSONAL_CONFIG_FILE_NAME);
3933
+ }
3934
+
3935
+ // src/lib/config/read-config-file.ts
3936
+ import { existsSync as existsSync21, readFileSync as readFileSync14 } from "fs";
3937
+
3938
+ // src/lib/error-reason.ts
3939
+ function errorReasonOf(error) {
3940
+ if (error instanceof Error && "code" in error && typeof error.code === "string") return error.code;
3941
+ return error instanceof Error ? error.message : String(error);
3942
+ }
3943
+
3944
+ // src/lib/config/read-config-file.ts
3945
+ import { isMap, isNode, isScalar, LineCounter, parseDocument, YAMLMap } from "yaml";
3946
+ function lineOfPair(params) {
3947
+ const start = isNode(params.pair.key) ? params.pair.key.range?.[0] : void 0;
3948
+ return start === void 0 ? 1 : params.parsed.lineCounter.linePos(start).line;
3949
+ }
3950
+ function keyOfPair(pair) {
3951
+ return String(isScalar(pair.key) ? pair.key.value : pair.key);
3952
+ }
3953
+ function valueOfPair(params) {
3954
+ const value = params.pair.value;
3955
+ return isNode(value) ? value.toJS(params.parsed.document) : value;
3956
+ }
3957
+ function entriesOf(params) {
3958
+ return params.map.items.filter((pair) => !(params.skipSchema && keyOfPair(pair) === CONFIG_SCHEMA_KEY)).map((pair) => ({
3959
+ key: keyOfPair(pair),
3960
+ value: valueOfPair({ parsed: params.parsed, pair }),
3961
+ line: lineOfPair({ parsed: params.parsed, pair })
3962
+ }));
3963
+ }
3964
+ function reposOf(params) {
3965
+ const { parsed, pair } = params;
3966
+ const file = parsed.file;
3967
+ if (!isMap(pair.value)) {
3968
+ const line = lineOfPair({ parsed, pair });
3969
+ return {
3970
+ repos: [],
3971
+ findings: [
3972
+ { file, line, key: CONFIG_REPOS_KEY, problem: "repos must be a mapping of repositories" }
3973
+ ]
3974
+ };
3975
+ }
3976
+ const repos = [];
3977
+ const findings = [];
3978
+ for (const repoPair of pair.value.items) {
3979
+ const repo = keyOfPair(repoPair);
3980
+ const line = lineOfPair({ parsed, pair: repoPair });
3981
+ if (isMap(repoPair.value))
3982
+ repos.push({
3983
+ repo,
3984
+ line,
3985
+ entries: entriesOf({ parsed, map: repoPair.value, skipSchema: false })
3986
+ });
3987
+ else
3988
+ findings.push({
3989
+ file,
3990
+ line,
3991
+ key: CONFIG_REPOS_KEY,
3992
+ problem: `repos entry '${repo}' must be a mapping of settings`
3993
+ });
3994
+ }
3995
+ return { repos, findings };
3996
+ }
3997
+ function schemaFindings(params) {
3998
+ const pair = params.map.items.find((item) => keyOfPair(item) === CONFIG_SCHEMA_KEY);
3999
+ const file = params.parsed.file;
4000
+ const key = CONFIG_SCHEMA_KEY;
4001
+ if (pair === void 0)
4002
+ return [
4003
+ {
4004
+ file,
4005
+ line: 1,
4006
+ key,
4007
+ problem: `schema is missing: write schema: ${CONFIG_SCHEMA_VERSION} first`
4008
+ }
4009
+ ];
4010
+ const value = valueOfPair({ parsed: params.parsed, pair });
4011
+ if (value === CONFIG_SCHEMA_VERSION) return [];
4012
+ const line = lineOfPair({ parsed: params.parsed, pair });
4013
+ return [
4014
+ {
4015
+ file,
4016
+ line,
4017
+ key,
4018
+ problem: `schema ${JSON.stringify(value) ?? String(value)} is not the version this cli reads (${CONFIG_SCHEMA_VERSION})`
4019
+ }
4020
+ ];
4021
+ }
4022
+ function readMapping(params) {
4023
+ const { parsed, map } = params;
4024
+ const reposPair = params.layer === "personal" ? map.items.find((pair) => keyOfPair(pair) === CONFIG_REPOS_KEY) : void 0;
4025
+ const entries = entriesOf({ parsed, map, skipSchema: true }).filter(
4026
+ (entry) => reposPair === void 0 || entry.key !== CONFIG_REPOS_KEY
4027
+ );
4028
+ const reposRead = reposPair === void 0 ? { repos: [], findings: [] } : reposOf({ parsed, pair: reposPair });
4029
+ const findings = [...schemaFindings({ parsed, map }), ...reposRead.findings];
4030
+ return { missing: false, file: parsed.file, entries, repos: reposRead.repos, findings };
4031
+ }
4032
+ function refusedRead(params) {
4033
+ return { missing: false, file: params.file, entries: [], repos: [], findings: [params] };
4034
+ }
4035
+ function textOrReason(file) {
4036
+ try {
4037
+ return { text: readFileSync14(file, "utf8") };
4038
+ } catch (error) {
4039
+ return { reason: errorReasonOf(error) };
4040
+ }
4041
+ }
4042
+ function readConfigFile(params) {
4043
+ const file = params.file;
4044
+ if (!existsSync21(file)) return { missing: true, file };
4045
+ const read = textOrReason(file);
4046
+ if ("reason" in read)
4047
+ return refusedRead({ file, line: 0, problem: `cannot be read: ${read.reason}` });
4048
+ const lineCounter = new LineCounter();
4049
+ const document = parseDocument(read.text, { lineCounter, prettyErrors: false });
4050
+ const error = document.errors[0];
4051
+ if (error !== void 0) {
4052
+ const line = lineCounter.linePos(error.pos[0]).line;
4053
+ return refusedRead({ file, line, problem: `not valid YAML: ${error.message.split("\n")[0]}` });
4054
+ }
4055
+ const contents = document.contents;
4056
+ if (contents !== null && !isMap(contents))
4057
+ return refusedRead({ file, line: 1, problem: "not a mapping of settings at top level" });
4058
+ const parsed = { file, document, lineCounter };
4059
+ return readMapping({ parsed, map: contents ?? new YAMLMap(), layer: params.layer });
4060
+ }
4061
+
4062
+ // src/lib/config/resolve-config.ts
4063
+ function readEntries(params) {
4064
+ const checks = [];
4065
+ const candidates = [];
4066
+ for (const entry of params.entries) {
4067
+ const result = checkConfigEntry({ ...params, entry });
4068
+ const source = params.sourceOf(entry);
4069
+ if (result.verdict === "accepted") {
4070
+ if (source !== void 0) candidates.push({ key: entry.key, value: entry.value, source });
4071
+ continue;
4072
+ }
4073
+ const finding = { file: params.file, line: entry.line, key: entry.key, problem: result.problem };
4074
+ checks.push({ finding, refused: result.verdict === "refused" });
4075
+ }
4076
+ return { checks, candidates };
4077
+ }
4078
+ function readRepos(params) {
4079
+ const { file } = params;
4080
+ const seen = /* @__PURE__ */ new Set();
4081
+ return params.repos.map((repoEntry) => {
4082
+ const repo = normalizeRepoKey({ key: repoEntry.repo, platform: params.platform });
4083
+ const duplicate = seen.has(repo);
4084
+ seen.add(repo);
4085
+ const matches = !duplicate && repo === params.repoKey;
4086
+ const read = readEntries({
4087
+ entries: repoEntry.entries,
4088
+ file,
4089
+ layer: params.layer,
4090
+ inRepos: true,
4091
+ keys: params.keys,
4092
+ sourceOf: (entry) => matches ? { kind: "repo", file, line: entry.line, repo } : void 0
4093
+ });
4094
+ if (!duplicate) return read;
4095
+ const finding = {
4096
+ file,
4097
+ line: repoEntry.line,
4098
+ key: CONFIG_REPOS_KEY,
4099
+ problem: DUPLICATE_REPOS_ENTRY_PROBLEM.replace("{repo}", repoEntry.repo)
4100
+ };
4101
+ return { ...read, checks: [{ finding, refused: false }, ...read.checks] };
4102
+ });
4103
+ }
4104
+ function readLayer(params) {
4105
+ const { file, layer, keys } = params;
4106
+ const read = readConfigFile({ file, layer });
4107
+ if (read.missing) return { checks: [], candidates: [] };
4108
+ const fileChecks = read.findings.map((finding) => ({ finding, refused: true }));
4109
+ const top = readEntries({
4110
+ entries: read.entries,
4111
+ file,
4112
+ layer,
4113
+ inRepos: false,
4114
+ keys,
4115
+ sourceOf: (entry) => ({ kind: layer, file, line: entry.line })
4116
+ });
4117
+ const repos = readRepos({ ...params, repos: read.repos });
4118
+ const parts = [top, ...repos];
4119
+ const candidates = fileChecks.length > 0 ? [] : parts.flatMap((part) => part.candidates);
4120
+ const checks = [...fileChecks, ...parts.flatMap((part) => part.checks)].sort(
4121
+ (left, right) => left.finding.line - right.finding.line
4122
+ );
4123
+ return { checks, candidates };
4124
+ }
4125
+ function valueOf(params) {
4126
+ const { spec } = params;
4127
+ const variableText = spec.environment === void 0 ? void 0 : params.environment[spec.environment];
4128
+ if (spec.environment !== void 0 && variableText !== void 0 && variableText !== "")
4129
+ return {
4130
+ key: spec.key,
4131
+ value: variableText,
4132
+ source: { kind: "environment", variable: spec.environment }
4133
+ };
4134
+ const ofKey = params.candidates.filter((candidate) => candidate.key === spec.key);
4135
+ for (const kind of CONFIG_SOURCE_RANKS) {
4136
+ const found = ofKey.find((candidate) => candidate.source.kind === kind);
4137
+ if (found !== void 0) return found;
4138
+ }
4139
+ return void 0;
4140
+ }
4141
+ function resolveConfig(context) {
4142
+ const keys = context.keys ?? CONFIG_KEYS;
4143
+ const layers = context.layers ?? CONFIG_LAYERS;
4144
+ const projectFile = join26(context.root, PROJECT_CONFIG_FILE_NAME);
4145
+ const personalFile = personalConfigFileOf(context);
4146
+ const repoKey = layers.includes("personal") ? repoKeyOf({ root: context.root, platform: context.platform }) : void 0;
4147
+ const repo = repoKey && { key: repoKey.key, from: repoKey.from };
4148
+ const layerOf = { keys, repoKey: repo?.key, platform: context.platform };
4149
+ const files = { project: projectFile, personal: personalFile };
4150
+ const reads = CONFIG_LAYERS.filter((layer) => layers.includes(layer)).map(
4151
+ (layer) => readLayer({ ...layerOf, file: files[layer], layer })
4152
+ );
4153
+ const checks = reads.flatMap((read) => read.checks);
4154
+ const candidates = reads.flatMap((read) => read.candidates);
4155
+ const values = keys.filter((spec) => layers.includes(spec.layer)).map((spec) => valueOf({ spec, environment: context.environment, candidates })).filter((value) => value !== void 0);
4156
+ return {
4157
+ projectFile,
4158
+ personalFile,
4159
+ repo,
4160
+ values,
4161
+ refusals: checks.filter((check) => check.refused).map((check) => check.finding),
4162
+ findings: checks.map((check) => check.finding)
4163
+ };
4164
+ }
4165
+
4166
+ // src/lib/host/github/github.constants.ts
4167
+ var GITHUB_VENDOR_NAME = "github";
4168
+ var GITHUB_REMOTE_HOSTS = ["github.com", "ssh.github.com"];
4169
+ var GH_COMMAND = "gh";
4170
+ var QUEUED_QUERY = "query($owner:String!,$repo:String!,$number:Int!){repository(owner:$owner,name:$repo){pullRequest(number:$number){isInMergeQueue autoMergeRequest{enabledAt}}}}";
4171
+ var HOST_ENVIRONMENT = {
4172
+ GH_PROMPT_DISABLED: "1",
4173
+ GIT_TERMINAL_PROMPT: "0",
4174
+ // what gh writes is parsed: never coloured, whatever the caller's terminal asks
4175
+ NO_COLOR: "1",
4176
+ CLICOLOR_FORCE: "0",
4177
+ GH_FORCE_TTY: ""
4178
+ };
4179
+ var NO_PULL_REQUEST_PATTERN = /no (open )?pull requests? found/i;
4180
+ var REVIEW_COMMENTS_ENDPOINT = "repos/{owner}/{repo}/pulls/{number}/comments";
4181
+ var REVIEW_COMMENTS_JQ = ".[] | {id, path, line: (.line // .original_line), body, replyTo: .in_reply_to_id}";
4182
+ var PASSING_CONCLUSIONS = ["SUCCESS", "NEUTRAL", "SKIPPED"];
4183
+ var COMPLETED_STATUS = "COMPLETED";
4184
+ var PASSING_STATUS_STATE = "SUCCESS";
4185
+ var PENDING_STATUS_STATES = ["PENDING", "EXPECTED"];
4186
+ var STATUS_CONTEXT_TYPE = "StatusContext";
4187
+ var GH_STACK = "stack";
4188
+ var NO_STACKS_REASON = "gh stack is not installed";
4189
+ var FILES_TAB_SUFFIX = "/files";
4190
+ var REVIEW_PROBE = { owner: "cli", repo: "cli", number: "15071" };
4191
+ var NO_SUCH_BRANCH = "zz-dialecte-no-such-branch-probe";
4192
+ var GITHUB_SUBJECT_CALL = "listMergedPullRequests";
4193
+ var MERGED_STATE = "merged";
4194
+ var ONE_PULL_REQUEST = "1";
4195
+ var GH_STACK_INSTALL = "gh extension install github/gh-stack";
4196
+ var GITHUB_PROBE_TEXTS = {
4197
+ nothingToProbe: "gh pr list: no merged pull request, nothing to probe",
4198
+ notTheJson: "gh pr list: not the JSON it writes: {text}",
4199
+ newestMerged: "pull request #{number}, the newest merged",
4200
+ needsPullRequest: "no merged pull request to read: nothing to probe",
4201
+ pullRequestRead: "#{number} read; a branch with none reads as no pull request",
4202
+ pullRequestNone: "#{number} reads as no pull request",
4203
+ noPullRequestTextChanged: "the text gh prints for no pull request changed: {refusal}",
4204
+ checksRead: "#{number}: checks {state}",
4205
+ queuedRead: "#{number}: queued {queued}",
4206
+ commentsRead: "{reference}: {count} comments, {lines} on a line, {replies} replies",
4207
+ commentKeysChanged: "review-comment keys changed: {reference} reads {lines} comments on a line and {replies} replies, at least one of each expected",
4208
+ stacksOn: "gh stack answers",
4209
+ stacksOff: "{why}: stacks off"
4210
+ };
4211
+
4212
+ // src/lib/host/github/github-calls.constants.ts
4213
+ var GITHUB_CALLS = {
4214
+ viewPullRequest: {
4215
+ words: ["pr", "view"],
4216
+ flags: [],
4217
+ kind: "read",
4218
+ fields: [
4219
+ "number",
4220
+ "url",
4221
+ "title",
4222
+ "body",
4223
+ "state",
4224
+ "isDraft",
4225
+ "autoMergeRequest",
4226
+ "headRefOid",
4227
+ "baseRefName"
4228
+ ]
4229
+ },
4230
+ viewChecks: {
4231
+ words: ["pr", "view"],
4232
+ flags: [],
4233
+ kind: "read",
4234
+ fields: ["headRefOid", "statusCheckRollup"]
4235
+ },
4236
+ listMergedPullRequests: {
4237
+ words: ["pr", "list"],
4238
+ flags: ["--state", "--limit"],
4239
+ kind: "read",
4240
+ fields: ["number"]
4241
+ },
4242
+ createPullRequest: {
4243
+ words: ["pr", "create"],
4244
+ flags: ["--base", "--head", "--title", "--body", "--draft"],
4245
+ kind: "write"
4246
+ },
4247
+ readyPullRequest: { words: ["pr", "ready"], flags: ["--undo"], kind: "write" },
4248
+ mergePullRequest: { words: ["pr", "merge"], flags: ["--auto", "--disable-auto"], kind: "write" },
4249
+ editPullRequest: {
4250
+ words: ["pr", "edit"],
4251
+ flags: ["--base", "--title", "--body-file"],
4252
+ kind: "write"
4253
+ },
4254
+ closePullRequest: { words: ["pr", "close"], flags: [], kind: "write" },
4255
+ reviewComments: {
4256
+ words: ["api"],
4257
+ flags: ["--paginate"],
4258
+ kind: "read",
4259
+ endpoint: REVIEW_COMMENTS_ENDPOINT,
4260
+ filter: REVIEW_COMMENTS_JQ
4261
+ },
4262
+ queuedState: {
4263
+ words: ["api"],
4264
+ flags: ["-F"],
4265
+ kind: "read",
4266
+ endpoint: "graphql",
4267
+ graphql: QUEUED_QUERY,
4268
+ filter: ".data.repository.pullRequest"
4269
+ },
4270
+ stackHelp: { words: [GH_STACK], flags: ["--help"], kind: "read" },
4271
+ stackLink: { words: [GH_STACK, "link"], flags: [], kind: "write" },
4272
+ stackMerge: { words: [GH_STACK, "merge"], flags: ["--yes", "--squash"], kind: "write" }
4273
+ };
4274
+
4275
+ // src/lib/host/github/github-contract.constants.ts
4276
+ var GITHUB_RECORDED_VERSIONS = { cli: "2.104.0", stack: "0.3.0" };
4277
+
4278
+ // src/lib/host/github/github-host.ts
4279
+ import { spawnSync as spawnSync5 } from "child_process";
4280
+
4281
+ // src/lib/host/github/github-reads.ts
4282
+ function checksOf(params) {
4283
+ const parsed = objectOf(params.text);
4284
+ if (parsed === void 0 || typeof parsed.headRefOid !== "string")
4285
+ return { refusal: `gh pr view: no head in ${params.text.slice(0, 80)}` };
4286
+ const rollup = newestRuns(Array.isArray(parsed.statusCheckRollup) ? parsed.statusCheckRollup : []);
4287
+ const failing = [];
4288
+ const pending = [];
4289
+ for (const check of rollup) {
4290
+ const outcome = outcomeOf(check);
4291
+ const name = String(check.name ?? check.context ?? "");
4292
+ if (outcome === "failing") failing.push(name);
4293
+ else if (outcome === "pending") pending.push(name);
4294
+ }
4295
+ const state = failing.length > 0 ? "failing" : pending.length > 0 ? "pending" : rollup.length === 0 ? "none" : "green";
4296
+ return { head: parsed.headRefOid, state, failing, pending };
4297
+ }
4298
+ function reviewCommentsOf(params) {
4299
+ const comments = [];
4300
+ for (const line of params.text.split("\n")) {
4301
+ if (line.trim() === "") continue;
4302
+ const parsed = objectOf(line);
4303
+ if (parsed === void 0 || typeof parsed.id !== "number" || typeof parsed.path !== "string" || typeof parsed.body !== "string")
4304
+ return { refusal: `gh api: not a review comment: ${line.slice(0, 80)}` };
4305
+ comments.push({
4306
+ id: parsed.id,
4307
+ path: parsed.path,
4308
+ ...typeof parsed.line === "number" && { line: parsed.line },
4309
+ body: parsed.body,
4310
+ ...typeof parsed.replyTo === "number" && { replyTo: parsed.replyTo }
4311
+ });
4312
+ }
4313
+ return comments;
4314
+ }
4315
+ function newestRuns(rollup) {
4316
+ const newest = /* @__PURE__ */ new Map();
4317
+ for (const entry of rollup) {
4318
+ const check = typeof entry === "object" && entry !== null ? entry : {};
4319
+ const key = check.__typename === STATUS_CONTEXT_TYPE ? `${STATUS_CONTEXT_TYPE}:${String(check.context ?? "")}` : `${String(check.workflowName ?? "")}:${String(check.name ?? "")}`;
4320
+ const kept = newest.get(key);
4321
+ if (kept === void 0 || isNewer({ check, than: kept })) newest.set(key, check);
4322
+ }
4323
+ return [...newest.values()];
4324
+ }
4325
+ function isNewer(params) {
4326
+ const running = isRunning(params.check);
4327
+ if (running !== isRunning(params.than)) return running;
4328
+ return timeOf(params.check) >= timeOf(params.than);
4329
+ }
4330
+ function isRunning(check) {
4331
+ return check.__typename !== STATUS_CONTEXT_TYPE && check.status !== COMPLETED_STATUS;
4332
+ }
4333
+ function timeOf(check) {
4334
+ return String(check.startedAt ?? check.completedAt ?? "");
4335
+ }
4336
+ function outcomeOf(check) {
4337
+ if (check.__typename === STATUS_CONTEXT_TYPE) {
4338
+ const state = String(check.state ?? "");
4339
+ if (state === PASSING_STATUS_STATE) return "passed";
4340
+ return PENDING_STATUS_STATES.includes(state) ? "pending" : "failing";
4341
+ }
4342
+ if (check.status !== COMPLETED_STATUS) return "pending";
4343
+ return PASSING_CONCLUSIONS.includes(String(check.conclusion)) ? "passed" : "failing";
4344
+ }
4345
+ function objectOf(text) {
4346
+ try {
4347
+ const parsed = JSON.parse(text);
4348
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
4349
+ } catch {
4350
+ return void 0;
4351
+ }
4352
+ }
4353
+
4354
+ // src/lib/host/github/run-gh.ts
4355
+ import { spawnSync as spawnSync4 } from "child_process";
4356
+
4357
+ // src/lib/host/github/github-describe.constants.ts
4358
+ var HELP_FLAG_SECTIONS = ["FLAGS", "INHERITED FLAGS", "Flags:"];
4359
+ var HELP_FLAG_LINE = /^\s+(?:(-[A-Za-z0-9]),\s+)?(--[A-Za-z0-9][\w-]*)/;
4360
+ var JSON_FIELD_LINE = /^\s+(\w+)\s*$/;
4361
+ var INTROSPECTED_TYPE_SELECTION = "{name fields(includeDeprecated:true){name args{name} type{name ofType{name ofType{name ofType{name}}}}}}";
4362
+ var VERSION_PATTERN = /\bversion\s+v?(\d+\.\d+\.\d+)/;
4363
+ var UNKNOWN_COMMAND_PATTERN = /unknown command "([^"]+)" for "/;
4364
+ var VERSION_FLAG = "--version";
4365
+ var HELP_FLAG = "--help";
4366
+ var JSON_FLAG = "--json";
4367
+ var QUERY_FIELD_FLAG = "-f";
4368
+ var TOOL_SELECTOR = "cli";
4369
+ var FILTER_FLAG = "--jq";
4370
+
4371
+ // src/lib/host/github/github-describe.ts
4372
+ function flagsOfHelp(params) {
4373
+ const lines = params.text.split(/\r?\n/);
4374
+ const flags = [];
4375
+ const aliases = [];
4376
+ let inSection = false;
4377
+ for (const line of lines) {
4378
+ if (isFlagSection({ line })) {
4379
+ inSection = true;
4380
+ continue;
4381
+ }
4382
+ if (line.trim() === "" || !/^\s/.test(line)) {
4383
+ inSection = false;
4384
+ continue;
4385
+ }
4386
+ const match = inSection ? HELP_FLAG_LINE.exec(line) : null;
4387
+ if (!match) continue;
4388
+ const [, short, long] = match;
4389
+ if (short) {
4390
+ flags.push(short);
4391
+ aliases.push({ short, long });
4392
+ }
4393
+ flags.push(long);
4394
+ }
4395
+ return { flags, aliases };
4396
+ }
4397
+ function isFlagSection(params) {
4398
+ const heading = params.line.trimEnd();
4399
+ return HELP_FLAG_SECTIONS.some(function isHeading(section) {
4400
+ return section === heading;
4401
+ });
4402
+ }
4403
+ function fieldsOfJsonList(params) {
4404
+ return params.text.split(/\r?\n/).flatMap(function fieldOfLine(line) {
4405
+ const match = JSON_FIELD_LINE.exec(line);
4406
+ return match?.[1] === void 0 ? [] : [match[1]];
4407
+ });
4408
+ }
4409
+ function introspectionQueryOf(params) {
4410
+ return `{__type(name:${JSON.stringify(params.name)})${INTROSPECTED_TYPE_SELECTION}}`;
4411
+ }
4412
+ function fieldsOfIntrospection(params) {
4413
+ const answer = parsedIntrospection({ text: params.text });
4414
+ const fields = answer?.data?.__type?.fields;
4415
+ if (!fields) return void 0;
4416
+ return Object.fromEntries(
4417
+ fields.map(function entryOfField(field) {
4418
+ return [
4419
+ field.name,
4420
+ {
4421
+ type: namedTypeOf({ ref: field.type }),
4422
+ args: field.args.map(function nameOfArg(arg) {
4423
+ return arg.name;
4424
+ })
4425
+ }
4426
+ ];
4427
+ })
4428
+ );
4429
+ }
4430
+ function parsedIntrospection(params) {
4431
+ try {
4432
+ const parsed = JSON.parse(params.text);
4433
+ return typeof parsed === "object" && parsed !== null ? parsed : void 0;
4434
+ } catch {
4435
+ return void 0;
4436
+ }
4437
+ }
4438
+ function namedTypeOf(params) {
4439
+ const { ref } = params;
4440
+ if (ref.name !== null) return ref.name;
4441
+ return ref.ofType ? namedTypeOf({ ref: ref.ofType }) : "";
4442
+ }
4443
+ function versionOfText(params) {
4444
+ return VERSION_PATTERN.exec(params.text)?.[1];
4445
+ }
4446
+
4447
+ // src/lib/host/github/run-gh.ts
4448
+ function impliedFlagsOf(spec) {
4449
+ return [
4450
+ ...spec.fields === void 0 ? [] : [JSON_FLAG, spec.fields.join(",")],
4451
+ ...spec.graphql === void 0 ? [] : [QUERY_FIELD_FLAG, `query=${spec.graphql}`],
4452
+ ...spec.filter === void 0 ? [] : [FILTER_FLAG, spec.filter]
4453
+ ];
4454
+ }
4455
+ function runGh(params) {
4456
+ const spec = GITHUB_CALLS[params.call];
4457
+ const args = [
4458
+ ...spec.words,
4459
+ ...spec.endpoint === void 0 ? [] : [endpointOf({ endpoint: spec.endpoint, values: params.values ?? {} })],
4460
+ ...params.positional ?? [],
4461
+ ...optionArgsOf(params.options ?? {}),
4462
+ ...impliedFlagsOf(spec)
4463
+ ];
4464
+ const run = spawnGh({
4465
+ root: params.root,
4466
+ args,
4467
+ timeout: spec.kind === "read" ? HOST_READ_TIMEOUT_MS : HOST_WRITE_TIMEOUT_MS,
4468
+ input: params.input
4469
+ });
4470
+ if (run.status === 0) return { output: run.stdout };
4471
+ return refusalOf2({ run, args });
4472
+ }
4473
+ function endpointOf(params) {
4474
+ return params.endpoint.replaceAll(/\{(\w+)\}/g, function fill(placeholder, name) {
4475
+ return params.values[name] ?? placeholder;
4476
+ });
4477
+ }
4478
+ function optionArgsOf(options) {
4479
+ return Object.entries(options).flatMap(function argsOfOption([flag, value]) {
4480
+ if (value === void 0) return [];
4481
+ if (value === true) return [flag];
4482
+ if (typeof value === "string") return [flag, value];
4483
+ return value.flatMap(function repeat(each) {
4484
+ return [flag, each];
4485
+ });
4486
+ });
4487
+ }
4488
+ function helpOf(params) {
4489
+ const args = [...params.words, HELP_FLAG];
4490
+ const run = spawnGh({ root: params.root, args, timeout: HOST_READ_TIMEOUT_MS });
4491
+ if (run.status !== 0) return refusalOf2({ run, args });
4492
+ return { raw: run.stdout, ...flagsOfHelp({ text: run.stdout }) };
4493
+ }
4494
+ function fieldsOf(params) {
4495
+ const args = [...params.words, JSON_FLAG];
4496
+ const run = spawnGh({ root: params.root, args, timeout: HOST_READ_TIMEOUT_MS });
4497
+ const fields = run.error ? [] : fieldsOfJsonList({ text: run.stderr });
4498
+ if (!fields.length) return refusalOf2({ run, args });
4499
+ return { raw: run.stderr, fields };
4500
+ }
4501
+ function typeOf(params) {
4502
+ const args = [
4503
+ ...GITHUB_CALLS.queuedState.words,
4504
+ GITHUB_CALLS.queuedState.endpoint,
4505
+ QUERY_FIELD_FLAG,
4506
+ `query=${introspectionQueryOf({ name: params.name })}`
4507
+ ];
4508
+ const run = spawnGh({ root: params.root, args, timeout: HOST_READ_TIMEOUT_MS });
4509
+ if (run.status !== 0) return refusalOf2({ run, args });
4510
+ const fields = fieldsOfIntrospection({ text: run.stdout });
4511
+ if (!fields)
4512
+ return { refusal: `${GH_COMMAND} ${args.slice(0, 2).join(" ")}: no type ${params.name}` };
4513
+ return { raw: run.stdout, fields };
4514
+ }
4515
+ function versionOf(params) {
4516
+ const args = [...params.selector === TOOL_SELECTOR ? [] : [params.selector], VERSION_FLAG];
4517
+ const run = spawnGh({ root: params.root, args, timeout: HOST_READ_TIMEOUT_MS });
4518
+ if (run.status !== 0) {
4519
+ const refusal = refusalOf2({ run, args });
4520
+ return run.error === void 0 && UNKNOWN_COMMAND_PATTERN.test(run.stderr) ? { ...refusal, absent: `${GH_COMMAND}-${params.selector}` } : refusal;
4521
+ }
4522
+ const version = versionOfText({ text: run.stdout });
4523
+ if (version === void 0)
4524
+ return { refusal: `${GH_COMMAND} ${args.join(" ")}: no version printed` };
4525
+ return { raw: run.stdout, version };
4526
+ }
4527
+ function spawnGh(params) {
4528
+ return spawnSync4(GH_COMMAND, params.args, {
4529
+ cwd: params.root,
4530
+ encoding: "utf8",
4531
+ timeout: params.timeout,
4532
+ ...params.input === void 0 ? { stdio: ["ignore", "pipe", "pipe"] } : { input: params.input },
4533
+ env: { ...process.env, ...HOST_ENVIRONMENT }
4534
+ });
4535
+ }
4536
+ function refusalOf2(params) {
4537
+ const { run, args } = params;
4538
+ const reason = run.error?.message ?? (run.stderr?.trim().split("\n")[0] || `exit ${run.status}`);
4539
+ return { refusal: `${GH_COMMAND} ${args.slice(0, 2).join(" ")}: ${reason}` };
4540
+ }
4541
+
4542
+ // src/lib/host/github/github-host.ts
4543
+ function createGithubHost() {
4544
+ const host = {
4545
+ readPullRequest: function readPullRequest(params) {
4546
+ const run = runGh({
4547
+ root: params.root,
4548
+ call: "viewPullRequest",
4549
+ positional: [params.ref]
4550
+ });
4551
+ if ("refusal" in run) return NO_PULL_REQUEST_PATTERN.test(run.refusal) ? void 0 : run;
4552
+ return pullRequestOf({ text: run.output });
4553
+ },
4554
+ openPullRequest: function openPullRequest(params) {
4555
+ const created = runGh({
4556
+ root: params.root,
4557
+ call: "createPullRequest",
4558
+ options: {
4559
+ "--base": params.base,
4560
+ "--head": params.branch,
4561
+ "--title": params.title,
4562
+ "--body": params.body,
4563
+ "--draft": params.draft || void 0
4564
+ }
4565
+ });
4566
+ if ("refusal" in created) return created;
4567
+ const read = host.readPullRequest({ root: params.root, ref: params.branch });
4568
+ return read ?? { refusal: `the pull request of ${params.branch} was opened but cannot be read` };
4569
+ },
4570
+ editPullRequest: editOnGithub,
4571
+ closePullRequest: closeOnGithub,
4572
+ readChecks: readChecksOnGithub,
4573
+ readReviewComments: readCommentsOnGithub,
4574
+ openFiles: openFilesTab,
4575
+ probeStacks: probeStacksOnGithub,
4576
+ linkStack: linkStackOnGithub,
4577
+ queueStack: queueStackOnGithub,
4578
+ retargetPullRequest: retargetOnGithub,
4579
+ draftPullRequest: draftOnGithub,
4580
+ readQueued: readQueuedOnGithub,
4581
+ queuePullRequest: function queuePullRequest(params) {
4582
+ const number = String(params.number);
4583
+ if (params.draft) {
4584
+ const ready = runGh({
4585
+ root: params.root,
4586
+ call: "readyPullRequest",
4587
+ positional: [number]
4588
+ });
4589
+ if ("refusal" in ready) return ready;
4590
+ }
4591
+ const queued = runGh({
4592
+ root: params.root,
4593
+ call: "mergePullRequest",
4594
+ positional: [number],
4595
+ options: { "--auto": true }
4596
+ });
4597
+ return "refusal" in queued ? queued : void 0;
4598
+ }
4599
+ };
4600
+ return host;
4601
+ }
4602
+ function draftOnGithub(params) {
4603
+ const number = String(params.number);
4604
+ if (params.queued) {
4605
+ const unqueued = runGh({
4606
+ root: params.root,
4607
+ call: "mergePullRequest",
4608
+ positional: [number],
4609
+ options: { "--disable-auto": true }
4610
+ });
4611
+ if ("refusal" in unqueued) return unqueued;
4612
+ }
4613
+ if (params.draft) return void 0;
4614
+ const drafted = runGh({
4615
+ root: params.root,
4616
+ call: "readyPullRequest",
4617
+ positional: [number],
4618
+ options: { "--undo": true }
4619
+ });
4620
+ return "refusal" in drafted ? drafted : void 0;
4621
+ }
4622
+ function probeStacksOnGithub(params) {
4623
+ const run = runGh({
4624
+ root: params.root,
4625
+ call: "stackHelp",
4626
+ options: { "--help": true }
4627
+ });
4628
+ return "refusal" in run ? { stacks: false, why: NO_STACKS_REASON } : { stacks: true };
4629
+ }
4630
+ function linkStackOnGithub(params) {
4631
+ const linked = runGh({
4632
+ root: params.root,
4633
+ call: "stackLink",
4634
+ positional: [params.parent, params.child]
4635
+ });
4636
+ return "refusal" in linked ? linked : void 0;
4637
+ }
4638
+ function queueStackOnGithub(params) {
4639
+ if (params.draft) {
4640
+ const ready = runGh({
4641
+ root: params.root,
4642
+ call: "readyPullRequest",
4643
+ positional: [String(params.number)]
4644
+ });
4645
+ if ("refusal" in ready) return ready;
4646
+ }
4647
+ const queued = runGh({
4648
+ root: params.root,
4649
+ call: "stackMerge",
4650
+ positional: [String(params.number)],
4651
+ options: { "--yes": true, "--squash": true }
4652
+ });
4653
+ return "refusal" in queued ? queued : void 0;
4654
+ }
4655
+ function retargetOnGithub(params) {
4656
+ const edited = runGh({
4657
+ root: params.root,
4658
+ call: "editPullRequest",
4659
+ positional: [String(params.number)],
4660
+ options: { "--base": params.base }
4661
+ });
4662
+ return "refusal" in edited ? edited : void 0;
4663
+ }
4664
+ function readChecksOnGithub(params) {
4665
+ const run = runGh({
4666
+ root: params.root,
4667
+ call: "viewChecks",
4668
+ positional: [String(params.number)]
2247
4669
  });
4670
+ return "refusal" in run ? run : checksOf({ text: run.output });
2248
4671
  }
2249
- function coreGenerations(cwd) {
2250
- const dialectes = dependencyNames(cwd).sort(TEXT_COLLATOR.compare).flatMap(function dialecteOnCore(name) {
2251
- const folder = findInstalledPackage({ cwd, name });
2252
- return folder && dependsOnCore(folder) ? [{ name, folder }] : [];
4672
+ function readReviewCommentsWith(params) {
4673
+ const run = params.run({
4674
+ root: params.root,
4675
+ call: "reviewComments",
4676
+ values: params.values,
4677
+ options: { "--paginate": true }
2253
4678
  });
2254
- const appCore = installedVersion({ cwd, name: CORE_PACKAGE2 });
2255
- const owners = dialectes.length ? dialectes : [{ name: void 0, folder: cwd }];
2256
- return owners.flatMap(function generationLine({ name, folder }) {
2257
- const version = installedVersion({ cwd: folder, name: CORE_PACKAGE2 });
2258
- if (version === void 0) return [];
2259
- const [major = 0, minor = 0] = version.split(".").map(Number);
2260
- const generation = CORE_API_GENERATIONS.find(
2261
- ({ from }) => major > from[0] || major === from[0] && minor >= from[1]
2262
- );
2263
- if (!generation) return [];
2264
- const says = `${generation.name}: ${generation.says}`;
2265
- if (name && appCore !== void 0 && appCore !== version)
2266
- return [
2267
- {
2268
- status: "warning",
2269
- subject: "core API",
2270
- detail: `${name} on core ${version}, your app on core ${appCore}: two cores side by side (${says})`,
2271
- fix: ALIGN_CORE_FIX
2272
- }
2273
- ];
2274
- const owner = name ? `${name} on core ${version}` : `core ${version}`;
2275
- return [{ status: "ok", subject: "core API", detail: `${owner} - ${says}` }];
4679
+ return "refusal" in run ? run : reviewCommentsOf({ text: run.output });
4680
+ }
4681
+ function readCommentsOnGithub(params) {
4682
+ return readReviewCommentsWith({
4683
+ run: runGh,
4684
+ root: params.root,
4685
+ values: { number: String(params.number) }
2276
4686
  });
2277
4687
  }
2278
- function skills(cwd) {
2279
- const { sources } = discoverSkillSources({ cwd });
2280
- if (sources.length === 0)
2281
- return [{ status: "ok", subject: "skills", detail: "no dependency ships skills" }];
2282
- const synced = Object.values(AGENT_SKILL_FOLDERS).filter(
2283
- (folder) => existsSync19(join24(cwd, folder, MANIFEST_FILE))
2284
- );
2285
- if (synced.length === 0)
2286
- return [
2287
- {
2288
- status: "warning",
2289
- subject: "skills",
2290
- detail: `not installed for your agents (${sources.map((source) => source.name).join(", ")} shipped)`,
2291
- fix: SYNC_COMMAND
2292
- }
2293
- ];
2294
- const contributor = isContributor(cwd);
2295
- return synced.map(function syncLine(folder) {
2296
- const manifest = readSyncManifest(join24(cwd, folder));
2297
- const expected = selectAudience({
2298
- sources,
2299
- contributing: contributor || manifest.contributing === true
2300
- }).selected;
2301
- const missing = expected.map((source) => source.name).filter((name) => !manifest.installed.includes(name));
2302
- if (missing.length)
2303
- return {
2304
- status: "warning",
2305
- subject: "skills",
2306
- detail: `${folder} lacks ${missing.join(", ")}`,
2307
- fix: SYNC_COMMAND
2308
- };
2309
- const stale = expected.flatMap(function staleCopy(source) {
2310
- const recorded = manifest.versions[source.name];
2311
- if (isLink(join24(cwd, folder, source.name)) || source.version === void 0) return [];
2312
- if (recorded?.version === source.version) return [];
2313
- return [
2314
- `${source.name} of ${source.origin} ${recorded?.version ?? "an unknown version"}, ${source.version} installed`
2315
- ];
2316
- });
2317
- if (stale.length)
2318
- return {
2319
- status: "warning",
2320
- subject: "skills",
2321
- detail: `${folder} holds ${stale.join("; ")}`,
2322
- fix: SYNC_COMMAND
2323
- };
2324
- return { status: "ok", subject: "skills", detail: `${folder} in sync with node_modules` };
4688
+ function openFilesTab(params) {
4689
+ const [command, ...words] = BROWSER_OPENERS[process.platform] ?? BROWSER_OPENERS.default;
4690
+ const run = spawnSync5(command, [...words, `${params.url}${FILES_TAB_SUFFIX}`], {
4691
+ cwd: params.root,
4692
+ encoding: "utf8",
4693
+ timeout: OPEN_TIMEOUT_MS,
4694
+ stdio: ["ignore", "ignore", "pipe"]
2325
4695
  });
4696
+ if (run.status === 0) return void 0;
4697
+ const reason = run.error?.message ?? (run.stderr.trim().split("\n")[0] || `exit ${run.status}`);
4698
+ return { refusal: `${command}: ${reason}` };
2326
4699
  }
2327
- function isContributor(cwd) {
4700
+ function editOnGithub(params) {
4701
+ const edited = runGh({
4702
+ root: params.root,
4703
+ call: "editPullRequest",
4704
+ positional: [String(params.number)],
4705
+ options: { "--title": params.title, "--body-file": "-" },
4706
+ input: params.body
4707
+ });
4708
+ return "refusal" in edited ? edited : void 0;
4709
+ }
4710
+ function closeOnGithub(params) {
4711
+ const closed = runGh({
4712
+ root: params.root,
4713
+ call: "closePullRequest",
4714
+ positional: [String(params.number)]
4715
+ });
4716
+ return "refusal" in closed ? closed : void 0;
4717
+ }
4718
+ function readQueuedOnGithub(params) {
4719
+ const run = runGh({
4720
+ root: params.root,
4721
+ call: "queuedState",
4722
+ options: { "-F": ["owner={owner}", "repo={repo}", `number=${params.number}`] }
4723
+ });
4724
+ if ("refusal" in run) return run;
2328
4725
  try {
2329
- return readProfile(cwd) === "contributor";
4726
+ const parsed = JSON.parse(run.output);
4727
+ return {
4728
+ queued: parsed.isInMergeQueue === true || parsed.autoMergeRequest !== null && parsed.autoMergeRequest !== void 0
4729
+ };
2330
4730
  } catch {
2331
- return false;
4731
+ return { refusal: `gh api graphql: not the JSON it writes: ${run.output.slice(0, 80)}` };
2332
4732
  }
2333
4733
  }
2334
- function isLink(path) {
4734
+ function pullRequestOf(params) {
2335
4735
  try {
2336
- return lstatSync5(path).isSymbolicLink();
4736
+ const parsed = JSON.parse(params.text);
4737
+ if (typeof parsed.number !== "number" || typeof parsed.state !== "string" || typeof parsed.url !== "string" || parsed.url === "")
4738
+ return { refusal: `gh pr view: no number, state or url in ${params.text.slice(0, 80)}` };
4739
+ const state = parsed.state.toLowerCase();
4740
+ const url = parsed.url;
4741
+ return {
4742
+ number: parsed.number,
4743
+ url,
4744
+ title: String(parsed.title ?? ""),
4745
+ body: String(parsed.body ?? ""),
4746
+ state: state === "merged" ? "merged" : state === "closed" ? "closed" : "open",
4747
+ draft: parsed.isDraft === true,
4748
+ // auto-merge on; the merge queue itself is read where it decides (readQueued): gh pr view cannot say
4749
+ queued: parsed.autoMergeRequest !== null && parsed.autoMergeRequest !== void 0,
4750
+ head: String(parsed.headRefOid ?? ""),
4751
+ ...typeof parsed.baseRefName === "string" && { base: parsed.baseRefName },
4752
+ filesUrl: `${url}${FILES_TAB_SUFFIX}`
4753
+ };
2337
4754
  } catch {
2338
- return false;
4755
+ return { refusal: `gh pr view: not the JSON it writes: ${params.text.slice(0, 80)}` };
2339
4756
  }
2340
4757
  }
2341
- function dependsOnCore(folder) {
2342
- const manifest = JSON.parse(readFileSync13(join24(folder, "package.json"), "utf8"));
2343
- return manifest.name !== CORE_PACKAGE2 && (manifest.dependencies?.[CORE_PACKAGE2] !== void 0 || manifest.peerDependencies?.[CORE_PACKAGE2] !== void 0);
4758
+
4759
+ // src/lib/host/github/github-probes.ts
4760
+ function newestMergedPullRequest(params) {
4761
+ const answer = params.run({
4762
+ root: params.root,
4763
+ call: GITHUB_SUBJECT_CALL,
4764
+ options: { "--state": MERGED_STATE, "--limit": ONE_PULL_REQUEST }
4765
+ });
4766
+ if ("refusal" in answer) return answer;
4767
+ const listed = listOf({ text: answer.output });
4768
+ if (listed === void 0)
4769
+ return {
4770
+ refusal: fillMessage({
4771
+ template: GITHUB_PROBE_TEXTS.notTheJson,
4772
+ values: { text: answer.output.slice(0, 80) }
4773
+ })
4774
+ };
4775
+ const [first] = listed;
4776
+ if (first === void 0) return { refusal: GITHUB_PROBE_TEXTS.nothingToProbe };
4777
+ return { number: first };
2344
4778
  }
2345
- function localCheckouts(context) {
2346
- const roots = [
2347
- ...new Set([context.dialecteRoot, dirname11(resolve5(context.cwd))].filter(isDefined2))
2348
- ];
2349
- return roots.map(function checkoutLine(root) {
2350
- const names = existsSync19(root) ? readdirSync10(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && join24(root, entry.name) !== resolve5(context.cwd)).filter((entry) => packageName(join24(root, entry.name))?.startsWith(DIALECTE_SCOPE)).map((entry) => entry.name).sort(TEXT_COLLATOR.compare) : [];
4779
+ function listOf(params) {
4780
+ try {
4781
+ const parsed = JSON.parse(params.text);
4782
+ if (!Array.isArray(parsed)) return void 0;
4783
+ const numbers = parsed.map(function numberOf(entry) {
4784
+ return typeof entry === "object" && entry !== null && "number" in entry ? entry.number : void 0;
4785
+ });
4786
+ return numbers.every(function isNumber(each) {
4787
+ return typeof each === "number";
4788
+ }) ? numbers : void 0;
4789
+ } catch {
4790
+ return void 0;
4791
+ }
4792
+ }
4793
+ function findMergedPullRequest(params) {
4794
+ const found = newestMergedPullRequest({ run: params.run, root: params.root });
4795
+ if ("refusal" in found)
2351
4796
  return {
4797
+ line: {
4798
+ status: found.refusal === GITHUB_PROBE_TEXTS.nothingToProbe ? "warning" : "error",
4799
+ subject: params.subject,
4800
+ detail: found.refusal
4801
+ }
4802
+ };
4803
+ return {
4804
+ line: {
2352
4805
  status: "ok",
2353
- subject: "checkouts",
2354
- detail: names.length ? `${root}: ${names.slice(0, CHECKOUT_LIST_LIMIT).join(", ")}${names.length > CHECKOUT_LIST_LIMIT ? ` and ${names.length - CHECKOUT_LIST_LIMIT} more` : ""}` : `none in ${root} (the installed packages are the source)`
4806
+ subject: params.subject,
4807
+ detail: fillMessage({
4808
+ template: GITHUB_PROBE_TEXTS.newestMerged,
4809
+ values: { number: String(found.number) }
4810
+ })
4811
+ },
4812
+ pullRequest: found.number
4813
+ };
4814
+ }
4815
+ var GITHUB_SUBJECT = {
4816
+ call: GITHUB_SUBJECT_CALL,
4817
+ find: findMergedPullRequest
4818
+ };
4819
+ function needsPullRequest(params) {
4820
+ return { status: "warning", subject: params.subject, detail: GITHUB_PROBE_TEXTS.needsPullRequest };
4821
+ }
4822
+ function probeViewPullRequest(params) {
4823
+ if (params.pullRequest === void 0) return needsPullRequest(params);
4824
+ const number = String(params.pullRequest);
4825
+ const read = params.host.readPullRequest({ root: params.root, ref: number });
4826
+ if (read !== void 0 && "refusal" in read)
4827
+ return { status: "error", subject: params.subject, detail: read.refusal };
4828
+ if (read === void 0)
4829
+ return {
4830
+ status: "error",
4831
+ subject: params.subject,
4832
+ detail: fillMessage({ template: GITHUB_PROBE_TEXTS.pullRequestNone, values: { number } })
2355
4833
  };
4834
+ const none = params.host.readPullRequest({ root: params.root, ref: NO_SUCH_BRANCH });
4835
+ if (none !== void 0)
4836
+ return {
4837
+ status: "error",
4838
+ subject: params.subject,
4839
+ detail: fillMessage({
4840
+ template: GITHUB_PROBE_TEXTS.noPullRequestTextChanged,
4841
+ values: { refusal: "refusal" in none ? none.refusal : `#${none.number}` }
4842
+ })
4843
+ };
4844
+ return {
4845
+ status: "ok",
4846
+ subject: params.subject,
4847
+ detail: fillMessage({ template: GITHUB_PROBE_TEXTS.pullRequestRead, values: { number } })
4848
+ };
4849
+ }
4850
+ function probeViewChecks(params) {
4851
+ if (params.pullRequest === void 0) return needsPullRequest(params);
4852
+ const checks = params.host.readChecks({ root: params.root, number: params.pullRequest });
4853
+ if ("refusal" in checks)
4854
+ return { status: "error", subject: params.subject, detail: checks.refusal };
4855
+ return {
4856
+ status: "ok",
4857
+ subject: params.subject,
4858
+ detail: fillMessage({
4859
+ template: GITHUB_PROBE_TEXTS.checksRead,
4860
+ values: { number: String(params.pullRequest), state: checks.state }
4861
+ })
4862
+ };
4863
+ }
4864
+ function probeQueuedState(params) {
4865
+ if (params.pullRequest === void 0) return needsPullRequest(params);
4866
+ const queued = params.host.readQueued({ root: params.root, number: params.pullRequest });
4867
+ if ("refusal" in queued)
4868
+ return { status: "error", subject: params.subject, detail: queued.refusal };
4869
+ return {
4870
+ status: "ok",
4871
+ subject: params.subject,
4872
+ detail: fillMessage({
4873
+ template: GITHUB_PROBE_TEXTS.queuedRead,
4874
+ values: { number: String(params.pullRequest), queued: String(queued.queued) }
4875
+ })
4876
+ };
4877
+ }
4878
+ function probeReviewComments(params) {
4879
+ const comments = readReviewCommentsWith({
4880
+ run: params.run,
4881
+ root: params.root,
4882
+ values: REVIEW_PROBE
2356
4883
  });
4884
+ if ("refusal" in comments)
4885
+ return { status: "error", subject: params.subject, detail: comments.refusal };
4886
+ const values = {
4887
+ reference: `${REVIEW_PROBE.owner}/${REVIEW_PROBE.repo}#${REVIEW_PROBE.number}`,
4888
+ count: String(comments.length),
4889
+ lines: String(
4890
+ comments.filter(function onALine(comment) {
4891
+ return comment.line !== void 0;
4892
+ }).length
4893
+ ),
4894
+ replies: String(
4895
+ comments.filter(function isReply(comment) {
4896
+ return comment.replyTo !== void 0;
4897
+ }).length
4898
+ )
4899
+ };
4900
+ if (values.lines === "0" || values.replies === "0")
4901
+ return {
4902
+ status: "error",
4903
+ subject: params.subject,
4904
+ detail: fillMessage({ template: GITHUB_PROBE_TEXTS.commentKeysChanged, values })
4905
+ };
4906
+ return {
4907
+ status: "ok",
4908
+ subject: params.subject,
4909
+ detail: fillMessage({ template: GITHUB_PROBE_TEXTS.commentsRead, values })
4910
+ };
2357
4911
  }
2358
- function declaredVersions(cwd) {
2359
- const manifest = JSON.parse(readFileSync13(join24(cwd, "package.json"), "utf8"));
2360
- const names = dependencyNames(cwd);
2361
- return Object.fromEntries(
2362
- names.map((name) => [
2363
- name,
2364
- String(
2365
- manifest.dependencies?.[name] ?? manifest.devDependencies?.[name] ?? manifest.peerDependencies?.[name]
2366
- )
2367
- ])
2368
- );
4912
+ function probeStackHelp(params) {
4913
+ const support = params.host.probeStacks({ root: params.root });
4914
+ if (support.stacks)
4915
+ return { status: "ok", subject: params.subject, detail: GITHUB_PROBE_TEXTS.stacksOn };
4916
+ return {
4917
+ status: "warning",
4918
+ subject: params.subject,
4919
+ detail: fillMessage({ template: GITHUB_PROBE_TEXTS.stacksOff, values: { why: support.why } }),
4920
+ fix: GH_STACK_INSTALL
4921
+ };
2369
4922
  }
2370
- function installedVersion(params) {
2371
- const folder = findInstalledPackage(params);
2372
- if (!folder || !existsSync19(join24(folder, "package.json"))) return void 0;
2373
- const version = JSON.parse(readFileSync13(join24(folder, "package.json"), "utf8")).version;
2374
- return typeof version === "string" ? version : void 0;
4923
+ var GITHUB_PROBES = {
4924
+ viewPullRequest: probeViewPullRequest,
4925
+ viewChecks: probeViewChecks,
4926
+ queuedState: probeQueuedState,
4927
+ reviewComments: probeReviewComments,
4928
+ stackHelp: probeStackHelp
4929
+ };
4930
+
4931
+ // src/lib/host/github/github-vendor.ts
4932
+ var GITHUB_DESCRIBE = { helpOf, fieldsOf, typeOf, versionOf };
4933
+ var GITHUB_VENDOR = {
4934
+ name: GITHUB_VENDOR_NAME,
4935
+ tool: GH_COMMAND,
4936
+ remoteHosts: GITHUB_REMOTE_HOSTS,
4937
+ calls: GITHUB_CALLS,
4938
+ recordedVersions: GITHUB_RECORDED_VERSIONS,
4939
+ subject: GITHUB_SUBJECT,
4940
+ probes: GITHUB_PROBES,
4941
+ run: runGh,
4942
+ describe: GITHUB_DESCRIBE,
4943
+ createAdapter: createGithubHost
4944
+ };
4945
+
4946
+ // src/lib/host/host-vendors.constants.ts
4947
+ var HOST_VENDORS = [GITHUB_VENDOR];
4948
+
4949
+ // src/lib/host/select-host.constants.ts
4950
+ var SSH_COMMAND = "ssh";
4951
+ var SSH_CONFIG_FLAG = "-G";
4952
+ var SSH_END_OF_OPTIONS = "--";
4953
+ var SSH_CONFIG_TIMEOUT_MS = 5e3;
4954
+ var SSH_HOSTNAME_KEY = "hostname";
4955
+ var HOST_CONFIG_KEY = "host";
4956
+ var NO_VENDOR_REFUSAL = "no host vendor for {origin}: it is none of the known vendors ({vendors}); set the key `host` to one of them in the personal config.yml";
4957
+ var UNKNOWN_VENDOR_REFUSAL = "no host vendor named {name}: the known vendors are {vendors}";
4958
+ var NO_REMOTE_ORIGIN = "a repository with no remote origin";
4959
+
4960
+ // src/lib/host/select-host.ts
4961
+ function hostnameOfSshConfig(params) {
4962
+ for (const line of params.text.split("\n")) {
4963
+ const [key, value] = line.trim().split(/\s+/, 2);
4964
+ if (key === SSH_HOSTNAME_KEY && value !== void 0) return value;
4965
+ }
4966
+ return void 0;
2375
4967
  }
2376
- function packageName(folder) {
2377
- const path = join24(folder, "package.json");
2378
- if (!existsSync19(path)) return void 0;
2379
- const name = JSON.parse(readFileSync13(path, "utf8")).name;
2380
- return typeof name === "string" ? name : void 0;
4968
+ function sshHostnameOf(params) {
4969
+ const run = spawnSync6(SSH_COMMAND, [SSH_CONFIG_FLAG, SSH_END_OF_OPTIONS, params.alias], {
4970
+ encoding: "utf8",
4971
+ timeout: SSH_CONFIG_TIMEOUT_MS,
4972
+ stdio: ["ignore", "pipe", "pipe"]
4973
+ });
4974
+ return run.status === 0 ? hostnameOfSshConfig({ text: run.stdout }) : void 0;
2381
4975
  }
2382
- function isDefined2(value) {
2383
- return value !== void 0;
4976
+ function hostKeyOf(params) {
4977
+ const resolved = resolveConfig({
4978
+ root: params.root,
4979
+ environment: process.env,
4980
+ platform: process.platform,
4981
+ home: homedir(),
4982
+ keys: CONFIG_KEYS.filter(function isHostKey(spec) {
4983
+ return spec.key === HOST_CONFIG_KEY;
4984
+ }),
4985
+ layers: ["personal"]
4986
+ });
4987
+ const value = resolved.values.find(function isHostValue(each) {
4988
+ return each.key === HOST_CONFIG_KEY;
4989
+ })?.value;
4990
+ return typeof value === "string" ? value : void 0;
4991
+ }
4992
+ function vendorOfRemoteHost(params) {
4993
+ if (params.host === void 0) return void 0;
4994
+ const lowered = params.host.toLowerCase();
4995
+ return HOST_VENDORS.find(function servesHost(vendor) {
4996
+ return vendor.remoteHosts.includes(lowered);
4997
+ });
4998
+ }
4999
+ function selectionOf(params) {
5000
+ const { remote } = repoKeyOf({ root: params.root, platform: process.platform });
5001
+ const host = remote?.host;
5002
+ const byOrigin = vendorOfRemoteHost({ host });
5003
+ if (byOrigin !== void 0) return { vendor: byOrigin, host };
5004
+ if (remote !== void 0 && remote.form !== "https") {
5005
+ const sshHostname = params.sshHostname ?? sshHostnameOf;
5006
+ const byAlias = vendorOfRemoteHost({ host: sshHostname({ alias: remote.host }) });
5007
+ if (byAlias !== void 0) return { vendor: byAlias, host };
5008
+ }
5009
+ const readHostKey = params.readHostKey ?? hostKeyOf;
5010
+ const name = readHostKey({ root: params.root });
5011
+ const named = name === void 0 ? void 0 : vendorNamed({ name });
5012
+ return { vendor: named !== void 0 && "vendor" in named ? named.vendor : void 0, host };
5013
+ }
5014
+ function knownVendorNames() {
5015
+ return HOST_VENDORS.map(function nameOf(vendor) {
5016
+ return vendor.name;
5017
+ }).join(", ");
5018
+ }
5019
+ function vendorNamed(params) {
5020
+ const vendor = HOST_VENDORS.find(function isNamed(each) {
5021
+ return each.name === params.name;
5022
+ });
5023
+ if (vendor !== void 0) return { vendor };
5024
+ return {
5025
+ refusal: fillMessage({
5026
+ template: UNKNOWN_VENDOR_REFUSAL,
5027
+ values: { name: params.name, vendors: knownVendorNames() }
5028
+ })
5029
+ };
5030
+ }
5031
+ function vendorOrRefusalOf(params) {
5032
+ const { vendor, host } = selectionOf(params);
5033
+ return vendor === void 0 ? { refusal: noVendorReason({ host }) } : { vendor };
5034
+ }
5035
+ function noVendorReason(params) {
5036
+ return fillMessage({
5037
+ template: NO_VENDOR_REFUSAL,
5038
+ values: {
5039
+ origin: params.host ?? NO_REMOTE_ORIGIN,
5040
+ vendors: knownVendorNames()
5041
+ }
5042
+ });
2384
5043
  }
2385
5044
 
2386
5045
  // src/commands/doctor.ts
2387
5046
  function runDoctor(params) {
2388
- const { argv, cliVersion, ...rest } = params;
5047
+ const { argv, cliVersion, hostLines: hostLines2, ...rest } = params;
2389
5048
  if (hasFlag([...argv], "brief")) return runBrief({ ...rest, cliVersion });
5049
+ if (hasFlag([...argv], "host"))
5050
+ return runHost({ argv, cwd: params.cwd, hostLines: hostLines2 ?? realHostLines });
2390
5051
  const missing = missingPackage({ cwd: params.cwd });
2391
5052
  if (missing) return missing;
2392
5053
  return answerDoctor({
@@ -2394,6 +5055,48 @@ function runDoctor(params) {
2394
5055
  json: hasFlag([...argv], "json")
2395
5056
  });
2396
5057
  }
5058
+ function runHost(params) {
5059
+ const argv = [...params.argv];
5060
+ if (argv.some(isVendorEqualsForm)) return vendorUsageError({ why: VENDOR_EQUALS_FORM });
5061
+ if (hasFlag(argv, "vendor") && !vendorNameGiven({ argv }))
5062
+ return vendorUsageError({ why: VENDOR_NEEDS_NAME });
5063
+ const selected = selectedVendorOf({ argv: params.argv, cwd: params.cwd });
5064
+ if ("refusal" in selected)
5065
+ return answerHostDoctor({
5066
+ lines: [{ status: "error", subject: HOST_SUBJECT, detail: selected.refusal }]
5067
+ });
5068
+ return answerHostDoctor({
5069
+ lines: params.hostLines({ root: params.cwd, vendor: selected.vendor })
5070
+ });
5071
+ }
5072
+ function selectedVendorOf(params) {
5073
+ const name = getArg([...params.argv], "vendor");
5074
+ return name === void 0 ? vendorOrRefusalOf({ root: params.cwd }) : vendorNamed({ name });
5075
+ }
5076
+ function vendorNameGiven(params) {
5077
+ const name = getArg(params.argv, "vendor");
5078
+ return name !== void 0 && !name.startsWith("-");
5079
+ }
5080
+ function vendorUsageError(params) {
5081
+ const usage = COMMAND_MAP.doctor.usage.filter(function isHostUsage(line) {
5082
+ return line.startsWith(HOST_USAGE_START);
5083
+ });
5084
+ return { output: textOf([params.why, ...usage, ""]), exitCode: 2 };
5085
+ }
5086
+ function isVendorEqualsForm(word) {
5087
+ return word.startsWith(VENDOR_EQUALS_PREFIX);
5088
+ }
5089
+ function realHostLines(params) {
5090
+ const { root, vendor } = params;
5091
+ return hostLines({
5092
+ root,
5093
+ vendor,
5094
+ host: vendor.createAdapter(),
5095
+ run: vendor.run,
5096
+ describe: vendor.describe,
5097
+ readGitVersion
5098
+ });
5099
+ }
2397
5100
  function runBrief(context) {
2398
5101
  try {
2399
5102
  return answerDoctorBrief(
@@ -2479,9 +5182,9 @@ function namespaceOf(packageName2) {
2479
5182
  }
2480
5183
 
2481
5184
  // src/lib/schema/load-dialectes.ts
2482
- import { existsSync as existsSync20, readFileSync as readFileSync14 } from "fs";
5185
+ import { existsSync as existsSync23, readFileSync as readFileSync15 } from "fs";
2483
5186
  import { createRequire } from "module";
2484
- import { join as join25 } from "path";
5187
+ import { join as join27 } from "path";
2485
5188
  import { pathToFileURL } from "url";
2486
5189
 
2487
5190
  // src/lib/schema/schema.constants.ts
@@ -2532,7 +5235,7 @@ async function loadDialecte(params) {
2532
5235
  if (config) break;
2533
5236
  }
2534
5237
  if (!config) return void 0;
2535
- const readersFile = createRequire(join25(params.folder, "package.json")).resolve(CORE_READERS_ENTRY);
5238
+ const readersFile = createRequire(join27(params.folder, "package.json")).resolve(CORE_READERS_ENTRY);
2536
5239
  const readers = await import(pathToFileURL(readersFile).href);
2537
5240
  if (!isCoreReaders(readers))
2538
5241
  throw new Error(
@@ -2551,8 +5254,8 @@ function readStandard(manifest) {
2551
5254
  return standard;
2552
5255
  }
2553
5256
  function readManifest(folder) {
2554
- const path = join25(folder, "package.json");
2555
- return existsSync20(path) ? JSON.parse(readFileSync14(path, "utf8")) : void 0;
5257
+ const path = join27(folder, "package.json");
5258
+ return existsSync23(path) ? JSON.parse(readFileSync15(path, "utf8")) : void 0;
2556
5259
  }
2557
5260
  function isBuiltOnCore(manifest) {
2558
5261
  return manifest.name !== CORE_PACKAGE3 && (manifest.dependencies?.[CORE_PACKAGE3] !== void 0 || manifest.peerDependencies?.[CORE_PACKAGE3] !== void 0);
@@ -2562,9 +5265,9 @@ function entryFiles(params) {
2562
5265
  const targets = exports === void 0 ? main ? [[".", main]] : [] : typeof exports === "string" ? [[".", exports]] : Object.entries(exports);
2563
5266
  return targets.filter(([subpath]) => !subpath.split("/").includes("test") && !subpath.includes("*")).flatMap(([, target]) => {
2564
5267
  const file = fileOf(target);
2565
- return file && file.endsWith("js") ? [join25(params.folder, file)] : [];
5268
+ return file && file.endsWith("js") ? [join27(params.folder, file)] : [];
2566
5269
  }).map(function existingFile(file) {
2567
- if (!existsSync20(file))
5270
+ if (!existsSync23(file))
2568
5271
  throw new Error(`entry file not found: ${file} (is the package built?)`);
2569
5272
  return file;
2570
5273
  });
@@ -3000,7 +5703,7 @@ function renderAnswer(answer) {
3000
5703
  `${element.tag} under ${under}: declaration ${element.declaration}, one of ${element.declarations} ways`,
3001
5704
  ...renderElement(element)
3002
5705
  ];
3003
- const heading = under === void 0 ? `${element.tag} is declared ${element.declarations} ways - pick one with --under <Parent>` : `${element.tag} under ${under}: declarations ${listOf(answer.ways.map((way) => way.id))} of ${element.declarations}, the parent does not decide`;
5706
+ const heading = under === void 0 ? `${element.tag} is declared ${element.declarations} ways - pick one with --under <Parent>` : `${element.tag} under ${under}: declarations ${listOf2(answer.ways.map((way) => way.id))} of ${element.declarations}, the parent does not decide`;
3004
5707
  return [
3005
5708
  heading,
3006
5709
  ...answer.ways.flatMap((way, index) => [...index === 0 ? [] : [""], ...renderWay(way)])
@@ -3009,7 +5712,7 @@ function renderAnswer(answer) {
3009
5712
  function renderWay(way) {
3010
5713
  return [`declaration ${way.id}${way.global ? " global" : ""}`, ...renderElement(way.element)];
3011
5714
  }
3012
- function listOf(words) {
5715
+ function listOf2(words) {
3013
5716
  if (words.length < 2) return words.join("");
3014
5717
  return `${words.slice(0, -1).join(", ")} and ${words[words.length - 1]}`;
3015
5718
  }
@@ -3093,13 +5796,13 @@ async function readSchemaDialectes(params) {
3093
5796
  }
3094
5797
 
3095
5798
  // src/lib/knowledge/ask/load-standard-indexes.ts
3096
- import { createHash as createHash5 } from "crypto";
3097
- import { readFileSync as readFileSync18 } from "fs";
5799
+ import { createHash as createHash6 } from "crypto";
5800
+ import { readFileSync as readFileSync19 } from "fs";
3098
5801
 
3099
5802
  // src/lib/knowledge/standard/ensure-standard-index.ts
3100
- import { createHash as createHash2 } from "crypto";
3101
- import { existsSync as existsSync22, readdirSync as readdirSync11, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync5 } from "fs";
3102
- import { join as join27 } from "path";
5803
+ import { createHash as createHash3 } from "crypto";
5804
+ import { existsSync as existsSync25, readdirSync as readdirSync11, readFileSync as readFileSync17, renameSync as renameSync5, rmSync as rmSync5 } from "fs";
5805
+ import { join as join29 } from "path";
3103
5806
 
3104
5807
  // src/lib/progress/format-duration.ts
3105
5808
  function formatDuration(milliseconds) {
@@ -3111,20 +5814,6 @@ function formatDuration(milliseconds) {
3111
5814
  return `${Math.floor(minutes / 60)} h ${minutes % 60} m`;
3112
5815
  }
3113
5816
 
3114
- // src/lib/knowledge/standard/fill-message.constants.ts
3115
- var PLACEHOLDER_PATTERN = /\{([^{}]+)\}/g;
3116
-
3117
- // src/lib/knowledge/standard/fill-message.ts
3118
- function fillMessage(params) {
3119
- const { template, values } = params;
3120
- return template.replace(
3121
- PLACEHOLDER_PATTERN,
3122
- function valueOf(placeholder, name) {
3123
- return Object.hasOwn(values, name) ? values[name] : placeholder;
3124
- }
3125
- );
3126
- }
3127
-
3128
5817
  // src/lib/knowledge/standard/standard-index.constants.ts
3129
5818
  var CAPTION_WORDS = {
3130
5819
  table: ["Ta", "ble"].join(""),
@@ -4242,11 +6931,11 @@ var FILE_CHANGED_MESSAGE = "{name} ({id}) changed while the index was built: not
4242
6931
  var BUILD_STEP_NAME = "standard index";
4243
6932
 
4244
6933
  // src/lib/knowledge/standard/standard-index-folder.ts
4245
- import { existsSync as existsSync21, mkdirSync as mkdirSync6, readFileSync as readFileSync15, renameSync as renameSync4, writeFileSync as writeFileSync5 } from "fs";
4246
- import { join as join26 } from "path";
6934
+ import { existsSync as existsSync24, mkdirSync as mkdirSync6, readFileSync as readFileSync16, renameSync as renameSync4, writeFileSync as writeFileSync5 } from "fs";
6935
+ import { join as join28 } from "path";
4247
6936
  function writeIndexFolder(params) {
4248
6937
  const { folder, manifest, search } = params;
4249
- mkdirSync6(join26(folder, LINES_FOLDER), { recursive: true });
6938
+ mkdirSync6(join28(folder, LINES_FOLDER), { recursive: true });
4250
6939
  for (const file of search.files)
4251
6940
  writeFileSync5(
4252
6941
  linesPathOf({ folder, fileId: file.fileId }),
@@ -4264,27 +6953,27 @@ function writeIndexFolder(params) {
4264
6953
  crossReferences: perFile({ files: search.files, value: (file) => file.crossReferences })
4265
6954
  };
4266
6955
  for (const part of PER_FILE_PARTS)
4267
- writeJson({ path: join26(folder, INDEX_FILES[part]), content: parts[part] });
6956
+ writeJson({ path: join28(folder, INDEX_FILES[part]), content: parts[part] });
4268
6957
  const words = {
4269
6958
  words: search.words,
4270
6959
  units: search.units,
4271
6960
  lineUnits: search.lineUnits
4272
6961
  };
4273
- writeJson({ path: join26(folder, INDEX_FILES.words), content: words });
4274
- writeJson({ path: join26(folder, INDEX_FILES.manifest), content: manifest });
6962
+ writeJson({ path: join28(folder, INDEX_FILES.words), content: words });
6963
+ writeJson({ path: join28(folder, INDEX_FILES.manifest), content: manifest });
4275
6964
  }
4276
6965
  function isCompleteIndexFolder(params) {
4277
- return existsSync21(join26(params.folder, INDEX_FILES.manifest));
6966
+ return existsSync24(join28(params.folder, INDEX_FILES.manifest));
4278
6967
  }
4279
6968
  function readIndexFolder(params) {
4280
6969
  const { folder } = params;
4281
- const manifest = readJson({ path: join26(folder, INDEX_FILES.manifest) });
6970
+ const manifest = readJson({ path: join28(folder, INDEX_FILES.manifest) });
4282
6971
  const parts = {
4283
- quality: readJson({ path: join26(folder, INDEX_FILES.quality) }),
4284
- headings: readJson({ path: join26(folder, INDEX_FILES.headings) }),
4285
- definitions: readJson({ path: join26(folder, INDEX_FILES.definitions) }),
4286
- tables: readJson({ path: join26(folder, INDEX_FILES.tables) }),
4287
- crossReferences: readJson({ path: join26(folder, INDEX_FILES.crossReferences) })
6972
+ quality: readJson({ path: join28(folder, INDEX_FILES.quality) }),
6973
+ headings: readJson({ path: join28(folder, INDEX_FILES.headings) }),
6974
+ definitions: readJson({ path: join28(folder, INDEX_FILES.definitions) }),
6975
+ tables: readJson({ path: join28(folder, INDEX_FILES.tables) }),
6976
+ crossReferences: readJson({ path: join28(folder, INDEX_FILES.crossReferences) })
4288
6977
  };
4289
6978
  const files = manifest.files.map((entry) => {
4290
6979
  const { noiseRanges, ...quality } = parts.quality[entry.id];
@@ -4300,10 +6989,10 @@ function readIndexFolder(params) {
4300
6989
  quality
4301
6990
  };
4302
6991
  });
4303
- return { manifest, files, words: readJson({ path: join26(folder, INDEX_FILES.words) }) };
6992
+ return { manifest, files, words: readJson({ path: join28(folder, INDEX_FILES.words) }) };
4304
6993
  }
4305
6994
  function tagsPathOf(params) {
4306
- return join26(params.folder, `${TAGS_FILE_PREFIX}${params.installedHash}${JSON_EXTENSION}`);
6995
+ return join28(params.folder, `${TAGS_FILE_PREFIX}${params.installedHash}${JSON_EXTENSION}`);
4307
6996
  }
4308
6997
  function writeTagsFile(params) {
4309
6998
  const temporary = `${params.path}${TEMPORARY_INFIX2}${process.pid}`;
@@ -4315,10 +7004,10 @@ function readTagsFile(params) {
4315
7004
  }
4316
7005
  function linesPathOf(params) {
4317
7006
  const name = params.fileId.slice(params.fileId.indexOf(FILE_ID_SEPARATOR) + 1);
4318
- return join26(params.folder, LINES_FOLDER, `${name}${LINES_EXTENSION}`);
7007
+ return join28(params.folder, LINES_FOLDER, `${name}${LINES_EXTENSION}`);
4319
7008
  }
4320
7009
  function readLines(params) {
4321
- return readFileSync15(linesPathOf(params), "utf8").split("\n").filter((line) => line !== "").map((line) => JSON.parse(line));
7010
+ return readFileSync16(linesPathOf(params), "utf8").split("\n").filter((line) => line !== "").map((line) => JSON.parse(line));
4322
7011
  }
4323
7012
  function perFile(params) {
4324
7013
  return Object.fromEntries(params.files.map((file) => [file.fileId, params.value(file)]));
@@ -4328,17 +7017,17 @@ function writeJson(params) {
4328
7017
  `);
4329
7018
  }
4330
7019
  function readJson(params) {
4331
- return JSON.parse(readFileSync15(params.path, "utf8"));
7020
+ return JSON.parse(readFileSync16(params.path, "utf8"));
4332
7021
  }
4333
7022
 
4334
7023
  // src/lib/knowledge/standard/ensure-standard-index.ts
4335
7024
  async function ensureStandardIndex(params) {
4336
7025
  const startedAt = Date.now();
4337
7026
  const { standard, installed } = params;
4338
- const folder = join27(params.cacheRoot, CACHE_LOCATION.standardFolder, standard.id);
7027
+ const folder = join29(params.cacheRoot, CACHE_LOCATION.standardFolder, standard.id);
4339
7028
  const hashed = standard.files.map(hashedFileOf);
4340
7029
  const manifestHash = manifestHashOf({ hashed });
4341
- const target = join27(folder, manifestHash);
7030
+ const target = join29(folder, manifestHash);
4342
7031
  const ready = { standardId: standard.id, manifestHash, startedAt, target, installed };
4343
7032
  if (!params.rebuild && isCompleteIndexFolder({ folder: target }))
4344
7033
  return readyAnswer({ ...ready, state: "reused" });
@@ -4385,7 +7074,7 @@ function readyAnswer(params) {
4385
7074
  };
4386
7075
  }
4387
7076
  function hashedFileOf(file) {
4388
- const bytes = readFileSync16(file.path);
7077
+ const bytes = readFileSync17(file.path);
4389
7078
  return {
4390
7079
  id: file.id,
4391
7080
  name: file.name,
@@ -4403,7 +7092,7 @@ async function buildInto(params) {
4403
7092
  const files = [];
4404
7093
  for (const file of hashed) {
4405
7094
  await nextTurn();
4406
- const bytes = readFileSync16(file.path);
7095
+ const bytes = readFileSync17(file.path);
4407
7096
  params.afterFileRead?.({ path: file.path });
4408
7097
  if (sha256Of(bytes) !== file.sha256) return abortedBy(file);
4409
7098
  files.push(indexStandardText({ fileId: file.id, text: bytes.toString("utf8") }));
@@ -4427,7 +7116,7 @@ async function buildInto(params) {
4427
7116
  path: tagsPathOf({ folder: params.folder, installedHash: installed.installedHash }),
4428
7117
  content: { vocabulary: installed.vocabulary, tagLinks: search.tagLinks }
4429
7118
  });
4430
- const moved = hashed.find((file) => sha256Of(readFileSync16(file.path)) !== file.sha256);
7119
+ const moved = hashed.find((file) => sha256Of(readFileSync17(file.path)) !== file.sha256);
4431
7120
  return moved ? abortedBy(moved) : { kind: "built", search };
4432
7121
  }
4433
7122
  function placeFolder(params) {
@@ -4490,7 +7179,7 @@ function readSearchIndex(params) {
4490
7179
  };
4491
7180
  if (installed.installedHash === void 0) return search;
4492
7181
  const path = tagsPathOf({ folder, installedHash: installed.installedHash });
4493
- if (existsSync22(path)) return { ...search, tagLinks: readTagsFile({ path }).tagLinks };
7182
+ if (existsSync25(path)) return { ...search, tagLinks: readTagsFile({ path }).tagLinks };
4494
7183
  const tagLinks = tagLinksOf({
4495
7184
  files,
4496
7185
  units: words.units,
@@ -4501,11 +7190,11 @@ function readSearchIndex(params) {
4501
7190
  return { ...search, tagLinks };
4502
7191
  }
4503
7192
  function removeStaleTemporaryFolders(params) {
4504
- if (!existsSync22(params.folder)) return;
7193
+ if (!existsSync25(params.folder)) return;
4505
7194
  for (const name of readdirSync11(params.folder)) {
4506
7195
  const pid = LEFT_FOLDER_PATTERN.exec(name)?.[1];
4507
7196
  if (pid !== void 0 && !isProcessAlive(Number(pid)))
4508
- rmSync5(join27(params.folder, name), { recursive: true, force: true });
7197
+ rmSync5(join29(params.folder, name), { recursive: true, force: true });
4509
7198
  }
4510
7199
  }
4511
7200
  function abortedBy(file) {
@@ -4523,16 +7212,16 @@ function nextTurn() {
4523
7212
  });
4524
7213
  }
4525
7214
  function sha256Of(content) {
4526
- return createHash2("sha256").update(content).digest("hex");
7215
+ return createHash3("sha256").update(content).digest("hex");
4527
7216
  }
4528
7217
 
4529
7218
  // src/lib/knowledge/standard/read-installed-vocabulary.ts
4530
- import { createHash as createHash3 } from "crypto";
4531
- import { existsSync as existsSync23 } from "fs";
4532
- import { join as join28 } from "path";
7219
+ import { createHash as createHash4 } from "crypto";
7220
+ import { existsSync as existsSync26 } from "fs";
7221
+ import { join as join30 } from "path";
4533
7222
  async function readInstalledVocabulary(params) {
4534
7223
  const { cwd, packageName: packageName2 } = params;
4535
- const installed = existsSync23(join28(cwd, PACKAGE_MANIFEST)) ? (await loadDialectes({ cwd })).dialectes : [];
7224
+ const installed = existsSync26(join30(cwd, PACKAGE_MANIFEST)) ? (await loadDialectes({ cwd })).dialectes : [];
4536
7225
  const selected = packageName2 === void 0 ? installed : installed.filter((dialecte) => dialecte.packageName === packageName2);
4537
7226
  if (packageName2 !== void 0 && selected.length === 0)
4538
7227
  return {
@@ -4557,7 +7246,7 @@ function vocabularyOf(params) {
4557
7246
  for (const value of readers.enumeratedValues(datatype)) values.add(value);
4558
7247
  }
4559
7248
  }
4560
- const packages = dialectes.map((dialecte) => `${dialecte.packageName}@${versionOf({ cwd, dialecte })}`).sort();
7249
+ const packages = dialectes.map((dialecte) => `${dialecte.packageName}@${versionOf2({ cwd, dialecte })}`).sort();
4561
7250
  return {
4562
7251
  vocabulary: {
4563
7252
  tags: [...tags].sort(),
@@ -4565,10 +7254,10 @@ function vocabularyOf(params) {
4565
7254
  values: [...values].sort()
4566
7255
  },
4567
7256
  packages,
4568
- installedHash: createHash3("sha256").update(packages.join(INSTALLED_LIST_SEPARATOR)).digest("hex").slice(0, INSTALLED_HASH_LENGTH)
7257
+ installedHash: createHash4("sha256").update(packages.join(INSTALLED_LIST_SEPARATOR)).digest("hex").slice(0, INSTALLED_HASH_LENGTH)
4569
7258
  };
4570
7259
  }
4571
- function versionOf(params) {
7260
+ function versionOf2(params) {
4572
7261
  const own = readManifest(params.cwd);
4573
7262
  const folder = own?.name === params.dialecte.packageName ? params.cwd : findInstalledPackage({ cwd: params.cwd, name: params.dialecte.packageName });
4574
7263
  return (folder === void 0 ? void 0 : readManifest(folder)?.version) ?? "";
@@ -4582,8 +7271,8 @@ function emptyInstalledVocabulary() {
4582
7271
  }
4583
7272
 
4584
7273
  // src/lib/knowledge/standard/read-standard-input.ts
4585
- import { existsSync as existsSync25, readdirSync as readdirSync12, realpathSync as realpathSync5, statSync as statSync7 } from "fs";
4586
- import { join as join30 } from "path";
7274
+ import { existsSync as existsSync28, readdirSync as readdirSync12, realpathSync as realpathSync6, statSync as statSync7 } from "fs";
7275
+ import { join as join32 } from "path";
4587
7276
 
4588
7277
  // src/lib/standard/read-standard-root.ts
4589
7278
  import { resolve as resolve6 } from "path";
@@ -4656,20 +7345,20 @@ function standardFoldersOf(params) {
4656
7345
  }
4657
7346
 
4658
7347
  // src/lib/knowledge/standard/work-tree-holding.ts
4659
- import { existsSync as existsSync24, realpathSync as realpathSync4 } from "fs";
4660
- import { dirname as dirname12, join as join29 } from "path";
7348
+ import { existsSync as existsSync27, realpathSync as realpathSync5 } from "fs";
7349
+ import { dirname as dirname13, join as join31 } from "path";
4661
7350
  function workTreeHolding(params) {
4662
- let folder = realpathSync4(nearestExisting(params.path));
7351
+ let folder = realpathSync5(nearestExisting(params.path));
4663
7352
  for (; ; ) {
4664
- if (existsSync24(join29(folder, GIT_ENTRY2))) return folder;
4665
- const parent = dirname12(folder);
7353
+ if (existsSync27(join31(folder, GIT_ENTRY2))) return folder;
7354
+ const parent = dirname13(folder);
4666
7355
  if (parent === folder) return void 0;
4667
7356
  folder = parent;
4668
7357
  }
4669
7358
  }
4670
7359
  function nearestExisting(path) {
4671
7360
  let existing = path;
4672
- while (!existsSync24(existing)) existing = dirname12(existing);
7361
+ while (!existsSync27(existing)) existing = dirname13(existing);
4673
7362
  return existing;
4674
7363
  }
4675
7364
 
@@ -4681,7 +7370,7 @@ function readStandardInput(params) {
4681
7370
  return refused(rootRefusal ?? INPUT_MESSAGES.notSet, STANDARD_LAYOUT);
4682
7371
  const workTree = workTreeRefusal({ path: root });
4683
7372
  if (workTree) return refused(workTree);
4684
- const entries = entriesOf({ folder: root });
7373
+ const entries = entriesOf2({ folder: root });
4685
7374
  const topLevelFiles = entries.filter((entry) => entry.kind === "file" && entry.name.endsWith(STANDARD_FILE_EXTENSION)).filter((entry) => !entry.name.startsWith(HIDDEN_NAME_START)).map((entry) => entry.name).sort();
4686
7375
  if (topLevelFiles.length > 0)
4687
7376
  return refused(
@@ -4716,10 +7405,10 @@ function readStandardInput(params) {
4716
7405
  );
4717
7406
  const selected = [];
4718
7407
  for (const named of chosen) {
4719
- const folder = join30(root, named.name);
7408
+ const folder = join32(root, named.name);
4720
7409
  const folderRefusal = workTreeRefusal({ path: folder });
4721
7410
  if (folderRefusal) return refused(folderRefusal);
4722
- const files = standardFilesOf({ standardId: named.id, entries: entriesOf({ folder }) });
7411
+ const files = standardFilesOf({ standardId: named.id, entries: entriesOf2({ folder }) });
4723
7412
  if (files.kind === "collision")
4724
7413
  return refused(
4725
7414
  fillMessage({
@@ -4730,7 +7419,7 @@ function readStandardInput(params) {
4730
7419
  selected.push({
4731
7420
  ...named,
4732
7421
  folder,
4733
- files: files.kept.map((file) => ({ ...file, path: join30(folder, file.name) }))
7422
+ files: files.kept.map((file) => ({ ...file, path: join32(folder, file.name) }))
4734
7423
  });
4735
7424
  }
4736
7425
  return { kind: "input", input: { root, known, selected } };
@@ -4742,17 +7431,17 @@ function workTreeRefusal(params) {
4742
7431
  function refusalOfRoot(params) {
4743
7432
  const { root } = params;
4744
7433
  if (root === void 0) return INPUT_MESSAGES.notSet;
4745
- if (!existsSync25(root))
7434
+ if (!existsSync28(root))
4746
7435
  return fillMessage({ template: INPUT_MESSAGES.missing, values: { path: root } });
4747
7436
  if (!statSync7(root).isDirectory())
4748
7437
  return fillMessage({ template: INPUT_MESSAGES.notFolder, values: { path: root } });
4749
7438
  return void 0;
4750
7439
  }
4751
- function entriesOf(params) {
7440
+ function entriesOf2(params) {
4752
7441
  return readdirSync12(params.folder).flatMap((name) => {
4753
- const path = join30(params.folder, name);
4754
- if (!existsSync25(path)) return [];
4755
- const stats = statSync7(realpathSync5(path));
7442
+ const path = join32(params.folder, name);
7443
+ if (!existsSync28(path)) return [];
7444
+ const stats = statSync7(realpathSync6(path));
4756
7445
  if (stats.isDirectory()) return [{ name, kind: "folder" }];
4757
7446
  return stats.isFile() ? [{ name, kind: "file" }] : [];
4758
7447
  });
@@ -4762,18 +7451,18 @@ function refused(message, layout) {
4762
7451
  }
4763
7452
 
4764
7453
  // src/lib/knowledge/standard/standard-cache-root.ts
4765
- import { homedir } from "os";
4766
- import { join as join31 } from "path";
7454
+ import { homedir as homedir2 } from "os";
7455
+ import { join as join33 } from "path";
4767
7456
  function standardCacheRoot(params) {
4768
7457
  const { environment } = params;
4769
7458
  const cacheHome = environment[CACHE_LOCATION.environmentVariable];
4770
- const base = cacheHome ? cacheHome : join31(environment[CACHE_LOCATION.homeVariable] || homedir(), CACHE_LOCATION.homeFolder);
4771
- return join31(base, CACHE_LOCATION.toolFolder);
7459
+ const base = cacheHome ? cacheHome : join33(environment[CACHE_LOCATION.homeVariable] || homedir2(), CACHE_LOCATION.homeFolder);
7460
+ return join33(base, CACHE_LOCATION.toolFolder);
4772
7461
  }
4773
7462
 
4774
7463
  // src/lib/knowledge/standard/standard-files-key.ts
4775
- import { createHash as createHash4 } from "crypto";
4776
- import { readFileSync as readFileSync17 } from "fs";
7464
+ import { createHash as createHash5 } from "crypto";
7465
+ import { readFileSync as readFileSync18 } from "fs";
4777
7466
 
4778
7467
  // src/lib/stable-json.ts
4779
7468
  function stableJson(value) {
@@ -4820,7 +7509,7 @@ function standardFilesKey(params) {
4820
7509
  return `${STANDARD_FILES_KEY_PREFIX}${sha256Of2(stableJson(pairs))}`;
4821
7510
  }
4822
7511
  function sha256Of2(content) {
4823
- return createHash4("sha256").update(content).digest("hex");
7512
+ return createHash5("sha256").update(content).digest("hex");
4824
7513
  }
4825
7514
 
4826
7515
  // src/lib/knowledge/ask/ask.constants.ts
@@ -4923,11 +7612,11 @@ async function loadStandardIndexes(params) {
4923
7612
  }
4924
7613
  function filesReadOf(params) {
4925
7614
  return params.standard.files.map(function fileReadOf(file) {
4926
- const bytes = readFileSync18(file.path);
7615
+ const bytes = readFileSync19(file.path);
4927
7616
  return {
4928
7617
  manifest: {
4929
7618
  id: file.id,
4930
- sha256: createHash5(SETUP_HASH_ALGORITHM).update(bytes).digest(SETUP_HASH_ENCODING),
7619
+ sha256: createHash6(SETUP_HASH_ALGORITHM).update(bytes).digest(SETUP_HASH_ENCODING),
4931
7620
  lines: params.search.files.find((index) => index.fileId === file.id)?.lineCount ?? 0
4932
7621
  },
4933
7622
  lines: bytes.toString("utf8").split(LINE_BREAK_PATTERN)