@dialecte/cli 0.2.0 → 0.2.1

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.
Files changed (3) hide show
  1. package/README.md +22 -2
  2. package/dist/cli.js +695 -536
  3. package/package.json +3 -2
package/dist/cli.js CHANGED
@@ -4415,7 +4415,17 @@ import { join as join34 } from "path";
4415
4415
 
4416
4416
  // src/lib/gate-records/check-key.ts
4417
4417
  import { createHash as createHash2 } from "crypto";
4418
- import { existsSync as existsSync17, lstatSync as lstatSync5, readdirSync as readdirSync7, readFileSync as readFileSync12, realpathSync as realpathSync3 } from "fs";
4418
+ import {
4419
+ copyFileSync,
4420
+ existsSync as existsSync17,
4421
+ lstatSync as lstatSync5,
4422
+ mkdtempSync as mkdtempSync2,
4423
+ readdirSync as readdirSync7,
4424
+ readFileSync as readFileSync12,
4425
+ realpathSync as realpathSync3,
4426
+ rmSync as rmSync6
4427
+ } from "fs";
4428
+ import { tmpdir as tmpdir2 } from "os";
4419
4429
  import { basename as basename2, join as join22, relative as relative3, resolve as resolve7 } from "path";
4420
4430
 
4421
4431
  // src/lib/git-hooks.ts
@@ -4469,7 +4479,7 @@ function readGit(params) {
4469
4479
  encoding: "utf8",
4470
4480
  maxBuffer: 1e8,
4471
4481
  // a status or diff never refreshes the index behind a commit running at the same time
4472
- env: { ...process.env, ...GIT_READ_ENVIRONMENT }
4482
+ env: { ...process.env, ...GIT_READ_ENVIRONMENT, ...params.environment }
4473
4483
  });
4474
4484
  if (result.status !== 0)
4475
4485
  throw new Error(`git ${params.args.join(" ")}: ${(result.stderr || result.stdout).trim()}`);
@@ -4592,11 +4602,164 @@ function readPackageJson(root) {
4592
4602
  return existsSync15(path) ? JSON.parse(readFileSync11(path, "utf8")) : {};
4593
4603
  }
4594
4604
 
4605
+ // src/lib/review-rounds/worktree-state.ts
4606
+ import { spawnSync as spawnSync4 } from "child_process";
4607
+ import { existsSync as existsSync16, lstatSync as lstatSync4, readdirSync as readdirSync6, statSync as statSync4 } from "fs";
4608
+ import { dirname as dirname10, join as join20 } from "path";
4609
+
4610
+ // src/lib/review-rounds/review-rounds.constants.ts
4611
+ var LEDGER_FILE = "findings-ledger.md";
4612
+ var LEDGER_TABLE_HEAD = "| id | round | severity | file:line | finding | state |\n|---|---|---|---|---|---|\n";
4613
+ var SEVERITY_SPELLINGS = {
4614
+ blocking: "blocking",
4615
+ "should-fix": "should fix",
4616
+ "should fix": "should fix",
4617
+ nit: "nit"
4618
+ };
4619
+ var FINDING_ID_PATTERN = /^R(\d+)-(\d+)$/;
4620
+ var ROUND_PATTERN = /^[1-9]\d*$/;
4621
+ var CELL_SEPARATOR_PATTERN = /(?<!\\)\|/;
4622
+ var LINE_BREAK_PATTERN = /[\r\n]/;
4623
+ var DECISION_STATES = [
4624
+ "open",
4625
+ "fix-to-verify",
4626
+ "fixed <round> [note]",
4627
+ "accepted <reason>",
4628
+ "logged <where>"
4629
+ ];
4630
+ var RECORD_USAGE = "record: review <folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding> | decision <folder> <id> <state...> | snapshot <folder> --round <n> | choice <folder> --by <who> <decision>";
4631
+ var RECORD_CHOICE_USAGE = "record choice: expected <folder> --by <who> <decision>";
4632
+ var CHOICE_OPTIONS = ["by"];
4633
+ var DECISIONS_FILE = "decisions.md";
4634
+ var DECISIONS_FIRST_CELL = "decision";
4635
+ var DECISIONS_TABLE_HEAD = "| decision | by | when |\n|---|---|---|\n";
4636
+ var RECORD_REVIEW_USAGE = "record review: expected <folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding>";
4637
+ var RECORD_DECISION_USAGE = `record decision: expected <folder> <id> <state...>; states: ${DECISION_STATES.join(", ")}`;
4638
+ var RECORD_SNAPSHOT_USAGE = "record snapshot: expected <folder> --round <n>";
4639
+ var REVIEW_USAGE = "review: delta <folder> --round <n> (n >= 2: round 1 is a full review) [--worktree] [--json]";
4640
+ var REVIEW_DELTA_USAGE = "review delta: expected <folder> --round <n> (n >= 2: round 1 is a full review) [--worktree] [--json]";
4641
+ var RECORD_REVIEW_OPTIONS = ["round", "severity", "at"];
4642
+ var ROUND_OPTIONS = ["round"];
4643
+ var REVIEW_DELTA_FLAGS = ["worktree", "json"];
4644
+ var PARTIAL_SUFFIX = ".partial";
4645
+ var PLAIN_DIFF_OPTIONS = ["--no-color", "--no-ext-diff", "--no-textconv"];
4646
+ var NO_FILE = "/dev/null";
4647
+ var DELTA_FILE_MARK = "\u2500\u2500";
4648
+ var GITLINK_MODE = "160000 ";
4649
+
4650
+ // src/lib/review-rounds/worktree-state.ts
4651
+ function workTreeTopOf(folder) {
4652
+ const result = spawnSync4("git", ["rev-parse", "--show-toplevel"], {
4653
+ cwd: folder,
4654
+ encoding: "utf8"
4655
+ });
4656
+ const top = result.status === 0 ? result.stdout.trim() : "";
4657
+ return top || void 0;
4658
+ }
4659
+ function handoverFolderRefusal(folder) {
4660
+ let existing = folder;
4661
+ while (!existsSync16(existing) && dirname10(existing) !== existing) existing = dirname10(existing);
4662
+ const lookFrom = statSync4(existing).isDirectory() ? existing : dirname10(existing);
4663
+ const gitFolder = gitFolderHolding(lookFrom);
4664
+ if (gitFolder)
4665
+ return `${folder} is inside the git folder ${gitFolder}: a hand-over folder stays outside every repository`;
4666
+ const top = workTreeTopOf(lookFrom);
4667
+ if (!top) return void 0;
4668
+ return `${folder} is inside the repository ${top}: a hand-over folder stays outside every repository`;
4669
+ }
4670
+ function gitFolderHolding(folder) {
4671
+ const result = spawnSync4("git", ["rev-parse", "--is-inside-git-dir", "--absolute-git-dir"], {
4672
+ cwd: folder,
4673
+ encoding: "utf8"
4674
+ });
4675
+ if (result.status !== 0) return void 0;
4676
+ const [inside, gitFolder] = result.stdout.trim().split("\n");
4677
+ return inside === "true" ? gitFolder : void 0;
4678
+ }
4679
+ function listStatusPaths(root) {
4680
+ const fields = readGit({
4681
+ root,
4682
+ args: ["status", "--porcelain", "-z", "--untracked-files=all"]
4683
+ }).split("\0");
4684
+ const paths = /* @__PURE__ */ new Set();
4685
+ const nestedRepositories = [];
4686
+ for (let index = 0; index < fields.length; index++) {
4687
+ const field = fields[index];
4688
+ if (field.length < 4) continue;
4689
+ const status = field.slice(0, 2);
4690
+ const found = [field.slice(3)];
4691
+ if (status[0] === "R" || status[0] === "C") found.push(fields[++index]);
4692
+ for (const path of found) {
4693
+ if (path.endsWith("/")) nestedRepositories.push(path);
4694
+ else if (!LOT_FILE_PATTERN.test(path)) paths.add(path);
4695
+ }
4696
+ }
4697
+ return { paths: [...paths], nestedRepositories };
4698
+ }
4699
+ function listHeadFiles(root) {
4700
+ const head = { files: /* @__PURE__ */ new Set(), submodules: /* @__PURE__ */ new Set() };
4701
+ for (const entry of readGit({
4702
+ root,
4703
+ args: ["ls-tree", "-r", "-z", "--full-tree", "HEAD"]
4704
+ }).split("\0")) {
4705
+ const tab = entry.indexOf(" ");
4706
+ if (tab < 0) continue;
4707
+ const path = entry.slice(tab + 1);
4708
+ if (entry.startsWith(GITLINK_MODE)) head.submodules.add(path);
4709
+ else head.files.add(path);
4710
+ }
4711
+ return head;
4712
+ }
4713
+ function listIndexSubmodules(root) {
4714
+ const submodules = /* @__PURE__ */ new Set();
4715
+ for (const entry of readGit({ root, args: ["ls-files", "--stage", "-z"] }).split("\0")) {
4716
+ const tab = entry.indexOf(" ");
4717
+ if (tab >= 0 && entry.startsWith(GITLINK_MODE)) submodules.add(entry.slice(tab + 1));
4718
+ }
4719
+ return submodules;
4720
+ }
4721
+ function readWorktreeState(root) {
4722
+ const head = listHeadFiles(root);
4723
+ return {
4724
+ status: listStatusPaths(root),
4725
+ head,
4726
+ submodules: /* @__PURE__ */ new Set([...head.submodules, ...listIndexSubmodules(root)])
4727
+ };
4728
+ }
4729
+ function worktreeStateRefusal(params) {
4730
+ const { status } = params.state;
4731
+ const submodules = status.paths.filter((path) => params.state.submodules.has(path));
4732
+ const repositories = [...status.nestedRepositories, ...submodules];
4733
+ if (repositories.length === 0) return void 0;
4734
+ return `${repositories.join(", ")} in ${params.root}: a nested repository or a submodule is no file of the lot`;
4735
+ }
4736
+ function isFileOrLink(path) {
4737
+ try {
4738
+ return !lstatSync4(path).isDirectory();
4739
+ } catch {
4740
+ return false;
4741
+ }
4742
+ }
4743
+ function listTreeFiles(folder) {
4744
+ const found = [];
4745
+ walkFolder({ folder, relative: "", found });
4746
+ return found.sort();
4747
+ }
4748
+ function walkFolder(params) {
4749
+ for (const name of readdirSync6(join20(params.folder, params.relative))) {
4750
+ const path = params.relative ? `${params.relative}/${name}` : name;
4751
+ if (lstatSync4(join20(params.folder, path)).isDirectory())
4752
+ walkFolder({ folder: params.folder, relative: path, found: params.found });
4753
+ else params.found.push(path);
4754
+ }
4755
+ }
4756
+
4595
4757
  // src/lib/gate-records/gate-records.constants.ts
4596
4758
  var GATE_RECORD_FILE = "dialecte-gate-{mode}.json";
4597
4759
  var RULES_RECORD_FILE = "dialecte-rules.json";
4598
4760
  var UNRECORDED_STEPS = ["hygiene"];
4599
4761
  var STATE_EXCLUDED_PATTERN = /(^|\/)\.dialecte\//;
4762
+ var COMMIT_INDEX_FOLDER_PREFIX = "dialecte-commit-index-";
4600
4763
  var CARD_GATE_MARKS = { passed: "\u2713", warning: "!", failed: "\u2717" };
4601
4764
  var DETAIL_SEPARATOR = " \xB7 ";
4602
4765
  var GATE_LINE_NAME = "gate";
@@ -4604,6 +4767,8 @@ var RULES_LINE_NAME = "rules";
4604
4767
  var REVIEW_LINE_NAME = "review";
4605
4768
  var NEVER_RUN_DETAIL = "never run on this tree";
4606
4769
  var HOOK_RECORD_DETAIL = "commit hook";
4770
+ var HOOK_REUSED_NOTE = "reused gate --full of {at} (HEAD {head})";
4771
+ var HOOK_REUSED_DETAIL = "reused by the hook";
4607
4772
  var HOOK_RECORD_MODE = "hook";
4608
4773
  var TREE_CHANGED_SUFFIX = " (the tree changed since)";
4609
4774
  var NOT_RUN_HERE_DETAIL = "not run here ({reason})";
@@ -4638,10 +4803,10 @@ var CHECK_KEY_FIELDS = ["tree", "lockHash", "commandHash", "linked"];
4638
4803
  import { createHash } from "crypto";
4639
4804
 
4640
4805
  // src/lib/handover/trial-base.ts
4641
- import { spawnSync as spawnSync4 } from "child_process";
4806
+ import { spawnSync as spawnSync5 } from "child_process";
4642
4807
  import { mkdtempSync, rmSync as rmSync5 } from "fs";
4643
4808
  import { tmpdir } from "os";
4644
- import { join as join20 } from "path";
4809
+ import { join as join21 } from "path";
4645
4810
 
4646
4811
  // src/lib/handover/handover.constants.ts
4647
4812
  var HANDOVER_LOCK_FILE = "dialecte-handover.lock";
@@ -4843,9 +5008,9 @@ function addMerge(params) {
4843
5008
  }
4844
5009
  function buildTree(params) {
4845
5010
  const { root } = params;
4846
- const folder = mkdtempSync(join20(tmpdir(), TRIAL_INDEX_FOLDER_PREFIX));
5011
+ const folder = mkdtempSync(join21(tmpdir(), TRIAL_INDEX_FOLDER_PREFIX));
4847
5012
  try {
4848
- const indexFile = join20(folder, "index");
5013
+ const indexFile = join21(folder, "index");
4849
5014
  runGit({ root, indexFile, args: ["read-tree", params.tree] });
4850
5015
  if (params.input) runGit({ root, indexFile, args: params.args, input: params.input });
4851
5016
  return runGit({ root, indexFile, args: ["write-tree"] }).trim();
@@ -4874,7 +5039,7 @@ function modeOf(params) {
4874
5039
  }
4875
5040
  function runGit(params) {
4876
5041
  const { name, email } = TRIAL_BASE_IDENTITY;
4877
- const result = spawnSync4("git", params.args, {
5042
+ const result = spawnSync5("git", params.args, {
4878
5043
  cwd: params.root,
4879
5044
  encoding: "utf8",
4880
5045
  maxBuffer: 1e8,
@@ -4893,158 +5058,6 @@ function runGit(params) {
4893
5058
  return result.stdout;
4894
5059
  }
4895
5060
 
4896
- // src/lib/review-rounds/worktree-state.ts
4897
- import { spawnSync as spawnSync5 } from "child_process";
4898
- import { existsSync as existsSync16, lstatSync as lstatSync4, readdirSync as readdirSync6, statSync as statSync4 } from "fs";
4899
- import { dirname as dirname10, join as join21 } from "path";
4900
-
4901
- // src/lib/review-rounds/review-rounds.constants.ts
4902
- var LEDGER_FILE = "findings-ledger.md";
4903
- var LEDGER_TABLE_HEAD = "| id | round | severity | file:line | finding | state |\n|---|---|---|---|---|---|\n";
4904
- var SEVERITY_SPELLINGS = {
4905
- blocking: "blocking",
4906
- "should-fix": "should fix",
4907
- "should fix": "should fix",
4908
- nit: "nit"
4909
- };
4910
- var FINDING_ID_PATTERN = /^R(\d+)-(\d+)$/;
4911
- var ROUND_PATTERN = /^[1-9]\d*$/;
4912
- var CELL_SEPARATOR_PATTERN = /(?<!\\)\|/;
4913
- var LINE_BREAK_PATTERN = /[\r\n]/;
4914
- var DECISION_STATES = [
4915
- "open",
4916
- "fix-to-verify",
4917
- "fixed <round> [note]",
4918
- "accepted <reason>",
4919
- "logged <where>"
4920
- ];
4921
- var RECORD_USAGE = "record: review <folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding> | decision <folder> <id> <state...> | snapshot <folder> --round <n> | choice <folder> --by <who> <decision>";
4922
- var RECORD_CHOICE_USAGE = "record choice: expected <folder> --by <who> <decision>";
4923
- var CHOICE_OPTIONS = ["by"];
4924
- var DECISIONS_FILE = "decisions.md";
4925
- var DECISIONS_FIRST_CELL = "decision";
4926
- var DECISIONS_TABLE_HEAD = "| decision | by | when |\n|---|---|---|\n";
4927
- var RECORD_REVIEW_USAGE = "record review: expected <folder> --round <n> --severity <blocking|should-fix|nit> --at <file:line> <finding>";
4928
- var RECORD_DECISION_USAGE = `record decision: expected <folder> <id> <state...>; states: ${DECISION_STATES.join(", ")}`;
4929
- var RECORD_SNAPSHOT_USAGE = "record snapshot: expected <folder> --round <n>";
4930
- var REVIEW_USAGE = "review: delta <folder> --round <n> (n >= 2: round 1 is a full review) [--worktree] [--json]";
4931
- var REVIEW_DELTA_USAGE = "review delta: expected <folder> --round <n> (n >= 2: round 1 is a full review) [--worktree] [--json]";
4932
- var RECORD_REVIEW_OPTIONS = ["round", "severity", "at"];
4933
- var ROUND_OPTIONS = ["round"];
4934
- var REVIEW_DELTA_FLAGS = ["worktree", "json"];
4935
- var PARTIAL_SUFFIX = ".partial";
4936
- var PLAIN_DIFF_OPTIONS = ["--no-color", "--no-ext-diff", "--no-textconv"];
4937
- var NO_FILE = "/dev/null";
4938
- var DELTA_FILE_MARK = "\u2500\u2500";
4939
- var GITLINK_MODE = "160000 ";
4940
-
4941
- // src/lib/review-rounds/worktree-state.ts
4942
- function workTreeTopOf(folder) {
4943
- const result = spawnSync5("git", ["rev-parse", "--show-toplevel"], {
4944
- cwd: folder,
4945
- encoding: "utf8"
4946
- });
4947
- const top = result.status === 0 ? result.stdout.trim() : "";
4948
- return top || void 0;
4949
- }
4950
- function handoverFolderRefusal(folder) {
4951
- let existing = folder;
4952
- while (!existsSync16(existing) && dirname10(existing) !== existing) existing = dirname10(existing);
4953
- const lookFrom = statSync4(existing).isDirectory() ? existing : dirname10(existing);
4954
- const gitFolder = gitFolderHolding(lookFrom);
4955
- if (gitFolder)
4956
- return `${folder} is inside the git folder ${gitFolder}: a hand-over folder stays outside every repository`;
4957
- const top = workTreeTopOf(lookFrom);
4958
- if (!top) return void 0;
4959
- return `${folder} is inside the repository ${top}: a hand-over folder stays outside every repository`;
4960
- }
4961
- function gitFolderHolding(folder) {
4962
- const result = spawnSync5("git", ["rev-parse", "--is-inside-git-dir", "--absolute-git-dir"], {
4963
- cwd: folder,
4964
- encoding: "utf8"
4965
- });
4966
- if (result.status !== 0) return void 0;
4967
- const [inside, gitFolder] = result.stdout.trim().split("\n");
4968
- return inside === "true" ? gitFolder : void 0;
4969
- }
4970
- function listStatusPaths(root) {
4971
- const fields = readGit({
4972
- root,
4973
- args: ["status", "--porcelain", "-z", "--untracked-files=all"]
4974
- }).split("\0");
4975
- const paths = /* @__PURE__ */ new Set();
4976
- const nestedRepositories = [];
4977
- for (let index = 0; index < fields.length; index++) {
4978
- const field = fields[index];
4979
- if (field.length < 4) continue;
4980
- const status = field.slice(0, 2);
4981
- const found = [field.slice(3)];
4982
- if (status[0] === "R" || status[0] === "C") found.push(fields[++index]);
4983
- for (const path of found) {
4984
- if (path.endsWith("/")) nestedRepositories.push(path);
4985
- else if (!LOT_FILE_PATTERN.test(path)) paths.add(path);
4986
- }
4987
- }
4988
- return { paths: [...paths], nestedRepositories };
4989
- }
4990
- function listHeadFiles(root) {
4991
- const head = { files: /* @__PURE__ */ new Set(), submodules: /* @__PURE__ */ new Set() };
4992
- for (const entry of readGit({
4993
- root,
4994
- args: ["ls-tree", "-r", "-z", "--full-tree", "HEAD"]
4995
- }).split("\0")) {
4996
- const tab = entry.indexOf(" ");
4997
- if (tab < 0) continue;
4998
- const path = entry.slice(tab + 1);
4999
- if (entry.startsWith(GITLINK_MODE)) head.submodules.add(path);
5000
- else head.files.add(path);
5001
- }
5002
- return head;
5003
- }
5004
- function listIndexSubmodules(root) {
5005
- const submodules = /* @__PURE__ */ new Set();
5006
- for (const entry of readGit({ root, args: ["ls-files", "--stage", "-z"] }).split("\0")) {
5007
- const tab = entry.indexOf(" ");
5008
- if (tab >= 0 && entry.startsWith(GITLINK_MODE)) submodules.add(entry.slice(tab + 1));
5009
- }
5010
- return submodules;
5011
- }
5012
- function readWorktreeState(root) {
5013
- const head = listHeadFiles(root);
5014
- return {
5015
- status: listStatusPaths(root),
5016
- head,
5017
- submodules: /* @__PURE__ */ new Set([...head.submodules, ...listIndexSubmodules(root)])
5018
- };
5019
- }
5020
- function worktreeStateRefusal(params) {
5021
- const { status } = params.state;
5022
- const submodules = status.paths.filter((path) => params.state.submodules.has(path));
5023
- const repositories = [...status.nestedRepositories, ...submodules];
5024
- if (repositories.length === 0) return void 0;
5025
- return `${repositories.join(", ")} in ${params.root}: a nested repository or a submodule is no file of the lot`;
5026
- }
5027
- function isFileOrLink(path) {
5028
- try {
5029
- return !lstatSync4(path).isDirectory();
5030
- } catch {
5031
- return false;
5032
- }
5033
- }
5034
- function listTreeFiles(folder) {
5035
- const found = [];
5036
- walkFolder({ folder, relative: "", found });
5037
- return found.sort();
5038
- }
5039
- function walkFolder(params) {
5040
- for (const name of readdirSync6(join21(params.folder, params.relative))) {
5041
- const path = params.relative ? `${params.relative}/${name}` : name;
5042
- if (lstatSync4(join21(params.folder, path)).isDirectory())
5043
- walkFolder({ folder: params.folder, relative: path, found: params.found });
5044
- else params.found.push(path);
5045
- }
5046
- }
5047
-
5048
5061
  // src/lib/gate-records/state-hash.ts
5049
5062
  function computeStateHash(root) {
5050
5063
  return hashStateTree(computeStateTree(root));
@@ -5113,6 +5126,25 @@ function hashHookCommand(root) {
5113
5126
  }
5114
5127
  return hash.digest("hex");
5115
5128
  }
5129
+ function computeCommitKey(params) {
5130
+ return {
5131
+ tree: readIndexTree({ root: params.root, indexFile: params.indexFile }),
5132
+ ...readInstalledKey(params.root),
5133
+ commandHash: params.commandHash
5134
+ };
5135
+ }
5136
+ function readIndexTree(params) {
5137
+ const { root, indexFile } = params;
5138
+ const index = indexFile ? resolve7(workTreeTopOf(root) ?? root, indexFile) : readGit({ root, args: ["rev-parse", "--path-format=absolute", "--git-path", "index"] }).trim();
5139
+ const folder = mkdtempSync2(join22(tmpdir2(), COMMIT_INDEX_FOLDER_PREFIX));
5140
+ try {
5141
+ const copy = join22(folder, "index");
5142
+ if (existsSync17(index)) copyFileSync(index, copy);
5143
+ return readGit({ root, args: ["write-tree"], environment: { GIT_INDEX_FILE: copy } }).trim();
5144
+ } finally {
5145
+ rmSync6(folder, { recursive: true, force: true });
5146
+ }
5147
+ }
5116
5148
  function hashLinkedFolders(root) {
5117
5149
  const packageJson = readPackageJson(root);
5118
5150
  const linked = LINKED_DEPENDENCY_FIELDS.flatMap(
@@ -5471,6 +5503,15 @@ var FLAKY_NOTE = "flaky in parallel";
5471
5503
  var REAL_FAILURE_PREFIX = "real failure: ";
5472
5504
  var ARGUMENT_SEPARATOR_PATTERN = /(^|\s)--(\s|$)/;
5473
5505
  var NO_TEST_RAN_REASON = "no test ran";
5506
+ var GATE_HOOK_MODE_REFUSAL = "gate: --hook, --fast or --full, one of them";
5507
+ var GATE_HOOK_NO_TEST_STEP_LINE = "gate --hook: no test step in gate --full";
5508
+ var GATE_HOOK_REUSED_LINE = "gate --hook: tests reused from gate --full green on tree {tree} at {at} (HEAD {head})";
5509
+ var GATE_HOOK_REUSED_PATTERN = /^gate --hook: tests reused from gate --full green on tree (\S+) at (\S+) \(HEAD ([0-9a-f]+)\)$/m;
5510
+ var GATE_HOOK_RUNNING_LINE = "gate --hook: no green gate --full of tree {tree} with this install: running the tests";
5511
+ var GATE_HOOK_GREEN_LINE = "gate --hook: green";
5512
+ var GATE_HOOK_FAILED_LINE = "gate --hook: failed at {step}";
5513
+ var VITEST_TESTS_LINE = " Tests {counts} ({total})";
5514
+ var VITEST_COUNT_SEPARATOR = " | ";
5474
5515
 
5475
5516
  // src/lib/gate/gate-config.ts
5476
5517
  function resolveGateSteps(params) {
@@ -5478,7 +5519,7 @@ function resolveGateSteps(params) {
5478
5519
  }
5479
5520
 
5480
5521
  // src/lib/gate/run-gate.ts
5481
- import { existsSync as existsSync20, readFileSync as readFileSync15, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "fs";
5522
+ import { existsSync as existsSync20, readFileSync as readFileSync15, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
5482
5523
  import { join as join24 } from "path";
5483
5524
 
5484
5525
  // src/lib/progress/run-child.ts
@@ -5958,6 +5999,31 @@ function countOf(params) {
5958
5999
  const match = new RegExp(`(\\d+) ${params.word}`).exec(params.text);
5959
6000
  return match ? Number(match[1]) : 0;
5960
6001
  }
6002
+ function renderVitestTestsLine(counts) {
6003
+ if (!counts.tests) return void 0;
6004
+ const { passed, failed, skipped, total } = counts.tests;
6005
+ const parts = [
6006
+ failed ? `${failed} failed` : "",
6007
+ passed || !failed && !skipped ? `${passed} passed` : "",
6008
+ skipped ? `${skipped} skipped` : ""
6009
+ ].filter(Boolean);
6010
+ return VITEST_TESTS_LINE.replace("{counts}", parts.join(VITEST_COUNT_SEPARATOR)).replace(
6011
+ "{total}",
6012
+ String(total)
6013
+ );
6014
+ }
6015
+ function sumStepCounts(counts) {
6016
+ const tests = counts.flatMap((entry) => entry.tests ? [entry.tests] : []);
6017
+ if (tests.length === 0) return {};
6018
+ return {
6019
+ tests: tests.reduce((sum2, entry) => ({
6020
+ passed: sum2.passed + entry.passed,
6021
+ failed: sum2.failed + entry.failed,
6022
+ skipped: sum2.skipped + entry.skipped,
6023
+ total: sum2.total + entry.total
6024
+ }))
6025
+ };
6026
+ }
5961
6027
 
5962
6028
  // src/lib/gate/run-gate.ts
5963
6029
  async function runGateSteps(params) {
@@ -6133,18 +6199,77 @@ function restoreFiles(params) {
6133
6199
  if (before === void 0 && after === void 0) continue;
6134
6200
  if (before && after && before.equals(after)) continue;
6135
6201
  if (before) writeFileSync9(path, before);
6136
- else rmSync6(path, { force: true, recursive: true });
6202
+ else rmSync7(path, { force: true, recursive: true });
6137
6203
  restored.push(file);
6138
6204
  }
6139
6205
  return restored;
6140
6206
  }
6141
6207
 
6208
+ // src/lib/git-environment.ts
6209
+ import { existsSync as existsSync21, realpathSync as realpathSync4 } from "fs";
6210
+ import { resolve as resolve10 } from "path";
6211
+
6212
+ // src/lib/git-environment.constants.ts
6213
+ var REPOSITORY_ENVIRONMENT_VARIABLES = [
6214
+ // which repository and work tree: set by git for a hook, or by the user
6215
+ "GIT_DIR",
6216
+ "GIT_WORK_TREE",
6217
+ "GIT_COMMON_DIR",
6218
+ "GIT_IMPLICIT_WORK_TREE",
6219
+ "GIT_PREFIX",
6220
+ // which index: a pre-commit hook gets the commit's own index
6221
+ "GIT_INDEX_FILE",
6222
+ // where the objects are read and written
6223
+ "GIT_OBJECT_DIRECTORY",
6224
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
6225
+ // what the history looks like: shallow commits, grafts and replace refs
6226
+ "GIT_SHALLOW_FILE",
6227
+ "GIT_GRAFT_FILE",
6228
+ "GIT_NO_REPLACE_OBJECTS",
6229
+ "GIT_REPLACE_REF_BASE"
6230
+ ];
6231
+
6232
+ // src/lib/git-environment.ts
6233
+ function clearRepositoryEnvironment(environment) {
6234
+ const cleared = REPOSITORY_ENVIRONMENT_VARIABLES.filter((name) => environment[name] !== void 0);
6235
+ for (const name of cleared) delete environment[name];
6236
+ return cleared;
6237
+ }
6238
+ function namesAnotherRepository(params) {
6239
+ const { given, folder } = params;
6240
+ return namesAnotherFolder({ value: given.GIT_DIR, folder, question: "--absolute-git-dir" }) || namesAnotherFolder({ value: given.GIT_WORK_TREE, folder, question: "--show-toplevel" });
6241
+ }
6242
+ function namesAnotherFolder(params) {
6243
+ const { value, folder, question } = params;
6244
+ if (!value) return false;
6245
+ const own = askGit({ folder, args: ["rev-parse", question] });
6246
+ return own === void 0 || !isSamePath({ first: resolve10(folder, value), second: own });
6247
+ }
6248
+ function askGit(params) {
6249
+ try {
6250
+ return readGit({ root: params.folder, args: params.args }).trim();
6251
+ } catch {
6252
+ return void 0;
6253
+ }
6254
+ }
6255
+ function isSamePath(params) {
6256
+ const { first, second } = params;
6257
+ if (!existsSync21(first) || !existsSync21(second)) return first === second;
6258
+ return realpathSync4(first) === realpathSync4(second);
6259
+ }
6260
+ function ignoredRepositoryEnvironmentLine(cleared) {
6261
+ return `dialecte: ${cleared.join(", ")} ignored: the cli acts on the folder it runs in`;
6262
+ }
6263
+
6264
+ // src/lib/given-environment.constants.ts
6265
+ var GIVEN_ENVIRONMENT = Object.freeze({ ...process.env });
6266
+
6142
6267
  // src/lib/handover/handover-lock.ts
6143
- import { existsSync as existsSync23, readFileSync as readFileSync18 } from "fs";
6268
+ import { existsSync as existsSync24, readFileSync as readFileSync18 } from "fs";
6144
6269
  import { dirname as dirname12, join as join26 } from "path";
6145
6270
 
6146
6271
  // src/lib/handover/handover-run-marker.ts
6147
- import { existsSync as existsSync21, readFileSync as readFileSync16, rmSync as rmSync7, writeFileSync as writeFileSync10 } from "fs";
6272
+ import { existsSync as existsSync22, readFileSync as readFileSync16, rmSync as rmSync8, writeFileSync as writeFileSync10 } from "fs";
6148
6273
  import { join as join25 } from "path";
6149
6274
  function writeRunMarker(params) {
6150
6275
  const path = join25(params.folder, HANDOVER_RUN_MARKER_FILE);
@@ -6152,7 +6277,7 @@ function writeRunMarker(params) {
6152
6277
  writeFileSync10(path, `${JSON.stringify(marker)}
6153
6278
  `);
6154
6279
  function removeMarker() {
6155
- rmSync7(path, { force: true });
6280
+ rmSync8(path, { force: true });
6156
6281
  }
6157
6282
  const removeSignalHook = onSignalExit(removeMarker);
6158
6283
  return function release() {
@@ -6162,7 +6287,7 @@ function writeRunMarker(params) {
6162
6287
  }
6163
6288
  function readRunMarker(folder) {
6164
6289
  const path = join25(folder, HANDOVER_RUN_MARKER_FILE);
6165
- if (!existsSync21(path)) return void 0;
6290
+ if (!existsSync22(path)) return void 0;
6166
6291
  let marker;
6167
6292
  try {
6168
6293
  marker = JSON.parse(readFileSync16(path, "utf8"));
@@ -6174,10 +6299,10 @@ function readRunMarker(folder) {
6174
6299
  }
6175
6300
 
6176
6301
  // src/lib/handover/read-lots-file.ts
6177
- import { existsSync as existsSync22, readFileSync as readFileSync17 } from "fs";
6178
- import { dirname as dirname11, isAbsolute as isAbsolute3, resolve as resolve10 } from "path";
6302
+ import { existsSync as existsSync23, readFileSync as readFileSync17 } from "fs";
6303
+ import { dirname as dirname11, isAbsolute as isAbsolute3, resolve as resolve11 } from "path";
6179
6304
  function readLotsFile(path) {
6180
- if (!existsSync22(path)) return `${path} does not exist`;
6305
+ if (!existsSync23(path)) return `${path} does not exist`;
6181
6306
  let parsed2;
6182
6307
  try {
6183
6308
  parsed2 = JSON.parse(readFileSync17(path, "utf8"));
@@ -6195,7 +6320,7 @@ function readLotsFile(path) {
6195
6320
  return `${path} needs "lots": [{ "paths": [...], "message": "..." } or { "kind": "merge", "branch", "tip", "resolved": { "<path>": "<file>" or null }, "message", "tree"? }]`;
6196
6321
  return {
6197
6322
  ...parsed2,
6198
- repository: isAbsolute3(repository) ? repository : resolve10(dirname11(path), repository),
6323
+ repository: isAbsolute3(repository) ? repository : resolve11(dirname11(path), repository),
6199
6324
  branch,
6200
6325
  head,
6201
6326
  lots
@@ -6222,7 +6347,7 @@ function handoverLockPath(root) {
6222
6347
  }
6223
6348
  function readHandoverLock(root) {
6224
6349
  const lockPath = handoverLockPath(root);
6225
- return existsSync23(lockPath) ? readFileSync18(lockPath, "utf8").trim() : void 0;
6350
+ return existsSync24(lockPath) ? readFileSync18(lockPath, "utf8").trim() : void 0;
6226
6351
  }
6227
6352
  function handoverHoldRefusal(params) {
6228
6353
  return HANDOVER_HOLD_REFUSAL.replace("{script}", params.script).replace("{why}", params.why).replace("{lock}", params.lock);
@@ -6234,7 +6359,7 @@ function readHandoverHold(root) {
6234
6359
  function refusedFor(why) {
6235
6360
  return { held: true, refusal: handoverHoldRefusal({ ...holder, why }) };
6236
6361
  }
6237
- if (!existsSync23(script)) return refusedFor(HANDOVER_HOLD_REASONS.scriptGone);
6362
+ if (!existsSync24(script)) return refusedFor(HANDOVER_HOLD_REASONS.scriptGone);
6238
6363
  const folder = dirname12(script);
6239
6364
  const lotsFile = readLotsFile(join26(folder, HANDOVER_FILES.lots));
6240
6365
  if (typeof lotsFile === "string")
@@ -6642,7 +6767,7 @@ function shortMessage(message) {
6642
6767
  }
6643
6768
 
6644
6769
  // src/lib/tdd/lot-declaration.ts
6645
- import { existsSync as existsSync26, readFileSync as readFileSync21 } from "fs";
6770
+ import { existsSync as existsSync27, readFileSync as readFileSync21 } from "fs";
6646
6771
  import { join as join29 } from "path";
6647
6772
 
6648
6773
  // src/lib/tdd/match-glob.ts
@@ -6667,7 +6792,7 @@ function globExpression(glob) {
6667
6792
  }
6668
6793
 
6669
6794
  // src/lib/tdd/select-cases.ts
6670
- import { realpathSync as realpathSync4 } from "fs";
6795
+ import { realpathSync as realpathSync5 } from "fs";
6671
6796
  import { relative as relative4 } from "path";
6672
6797
 
6673
6798
  // src/lib/tdd/case-of-change.ts
@@ -6720,11 +6845,11 @@ function countWrittenAsString(params) {
6720
6845
 
6721
6846
  // src/lib/tdd/tdd-files.ts
6722
6847
  import { createHash as createHash3 } from "crypto";
6723
- import { existsSync as existsSync25, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
6848
+ import { existsSync as existsSync26, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
6724
6849
  import { join as join28 } from "path";
6725
6850
 
6726
6851
  // src/lib/worktree/hygiene.ts
6727
- import { existsSync as existsSync24, readFileSync as readFileSync19, writeFileSync as writeFileSync11 } from "fs";
6852
+ import { existsSync as existsSync25, readFileSync as readFileSync19, writeFileSync as writeFileSync11 } from "fs";
6728
6853
  import { join as join27 } from "path";
6729
6854
  function writeHygieneBaseline(params) {
6730
6855
  const { root } = params;
@@ -6793,12 +6918,12 @@ function readStashEntries(root) {
6793
6918
  }
6794
6919
  function readBaseline(root) {
6795
6920
  const path = hygieneBaselinePath(root);
6796
- if (!existsSync24(path)) return "missing";
6921
+ if (!existsSync25(path)) return "missing";
6797
6922
  return readHygieneBaseline(root) ?? "unreadable";
6798
6923
  }
6799
6924
  function readHygieneBaseline(root) {
6800
6925
  const path = hygieneBaselinePath(root);
6801
- if (!existsSync24(path)) return void 0;
6926
+ if (!existsSync25(path)) return void 0;
6802
6927
  try {
6803
6928
  return JSON.parse(readFileSync19(path, "utf8"));
6804
6929
  } catch {
@@ -6899,7 +7024,7 @@ function hashProduction(params) {
6899
7024
  for (const file of listRepositoryFiles({ root: params.root, folder: "." })) {
6900
7025
  if (!isProductionPath({ file, packageJson: params.packageJson })) continue;
6901
7026
  const path = join28(params.root, file);
6902
- hash.update(`${file}\0${existsSync25(path) ? hashFile(path) : DELETED_PRODUCTION_FILE}
7027
+ hash.update(`${file}\0${existsSync26(path) ? hashFile(path) : DELETED_PRODUCTION_FILE}
6903
7028
  `);
6904
7029
  }
6905
7030
  return hash.digest("hex");
@@ -6921,7 +7046,7 @@ function isProductionPath(params) {
6921
7046
  }
6922
7047
  function readLedger(root) {
6923
7048
  const path = ledgerPath(root);
6924
- if (!existsSync25(path)) return { version: LEDGER_VERSION, entries: [] };
7049
+ if (!existsSync26(path)) return { version: LEDGER_VERSION, entries: [] };
6925
7050
  let ledger;
6926
7051
  try {
6927
7052
  ledger = JSON.parse(readFileSync20(path, "utf8"));
@@ -6986,7 +7111,7 @@ function listChangedSince(params) {
6986
7111
  });
6987
7112
  const untracked = readGit({ root, args: ["ls-files", "--others", "--exclude-standard"] });
6988
7113
  return [...new Set(`${changed}
6989
- ${untracked}`.split("\n").filter(Boolean))].filter((file) => existsSync25(join28(root, file))).sort();
7114
+ ${untracked}`.split("\n").filter(Boolean))].filter((file) => existsSync26(join28(root, file))).sort();
6990
7115
  }
6991
7116
  function hashChangedTestCode(params) {
6992
7117
  return new Map(
@@ -7115,7 +7240,7 @@ function caseLabel(testCase) {
7115
7240
  return `${testCase.file}::${testCase.name}${testCase.project ? ` [${testCase.project}]` : ""}`;
7116
7241
  }
7117
7242
  function modulesOf(params) {
7118
- const realRoot = realpathSync4(params.root);
7243
+ const realRoot = realpathSync5(params.root);
7119
7244
  return params.modules.filter(
7120
7245
  (testModule) => relative4(realRoot, realPathOf(testModule.file)) === params.file
7121
7246
  );
@@ -7137,7 +7262,7 @@ function mergeModules(modules) {
7137
7262
  };
7138
7263
  }
7139
7264
  function productionFileJudge(params) {
7140
- const realRoot = realpathSync4(params.root);
7265
+ const realRoot = realpathSync5(params.root);
7141
7266
  return function isProductionFile(path) {
7142
7267
  const file = relative4(realRoot, realPathOf(path));
7143
7268
  return !file.startsWith("..") && !file.startsWith("/") && isProductionPath({ file, packageJson: params.packageJson });
@@ -7229,7 +7354,7 @@ function readDeclaredCases(params) {
7229
7354
  return entries;
7230
7355
  }
7231
7356
  function readLotDeclaration(path) {
7232
- if (!existsSync26(path)) return {};
7357
+ if (!existsSync27(path)) return {};
7233
7358
  let declaration;
7234
7359
  try {
7235
7360
  declaration = JSON.parse(readFileSync21(path, "utf8"));
@@ -7259,7 +7384,7 @@ function unknownKeyOf(params) {
7259
7384
  }
7260
7385
 
7261
7386
  // src/lib/tdd/tdd-state.ts
7262
- import { existsSync as existsSync30 } from "fs";
7387
+ import { existsSync as existsSync31 } from "fs";
7263
7388
  import { join as join33 } from "path";
7264
7389
 
7265
7390
  // src/lib/tdd/case-status.ts
@@ -7330,11 +7455,11 @@ function lastIndexOf(params) {
7330
7455
  }
7331
7456
 
7332
7457
  // src/lib/tdd/module-resolver.ts
7333
- import { existsSync as existsSync27, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as statSync5 } from "fs";
7334
- import { dirname as dirname13, isAbsolute as isAbsolute4, join as join30, normalize, relative as relative5, resolve as resolve11 } from "path";
7458
+ import { existsSync as existsSync28, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as statSync5 } from "fs";
7459
+ import { dirname as dirname13, isAbsolute as isAbsolute4, join as join30, normalize, relative as relative5, resolve as resolve12 } from "path";
7335
7460
  import ts6 from "typescript";
7336
7461
  function createModuleResolver(params) {
7337
- const root = resolve11(params.root);
7462
+ const root = resolve12(params.root);
7338
7463
  const compilerOptions = readPathsOptions(root);
7339
7464
  const pathPrefixes = compilerOptions.flatMap(
7340
7465
  (options) => Object.keys(options.paths ?? {}).map((key) => key.replace(/\*.*$/, ""))
@@ -7343,7 +7468,7 @@ function createModuleResolver(params) {
7343
7468
  return function resolveModule({ specifier, from }) {
7344
7469
  const absoluteFrom = join30(root, from);
7345
7470
  if (specifier.startsWith(".") || isAbsolute4(specifier))
7346
- return localOrUnresolved({ root, path: resolve11(dirname13(absoluteFrom), specifier) });
7471
+ return localOrUnresolved({ root, path: resolve12(dirname13(absoluteFrom), specifier) });
7347
7472
  for (const options of compilerOptions) {
7348
7473
  const resolved = ts6.resolveModuleName(specifier, absoluteFrom, options, ts6.sys).resolvedModule;
7349
7474
  if (resolved && !resolved.isExternalLibraryImport) {
@@ -7388,7 +7513,7 @@ function readViteAliases(root) {
7388
7513
  };
7389
7514
  var visit = visit2;
7390
7515
  const path = join30(root, name);
7391
- if (!existsSync27(path)) continue;
7516
+ if (!existsSync28(path)) continue;
7392
7517
  const source = ts6.createSourceFile(
7393
7518
  name,
7394
7519
  readFileSync22(path, "utf8"),
@@ -7419,7 +7544,7 @@ function aliasesOf(params) {
7419
7544
  }
7420
7545
  return entries.flatMap((entry) => {
7421
7546
  const target = entry.replacement ? pathLiteralOf(entry.replacement) : void 0;
7422
- return entry.find && target ? [{ find: entry.find, replacement: resolve11(root, target) }] : [];
7547
+ return entry.find && target ? [{ find: entry.find, replacement: resolve12(root, target) }] : [];
7423
7548
  });
7424
7549
  }
7425
7550
  function fieldOf(params) {
@@ -7461,12 +7586,12 @@ function isFile2(path) {
7461
7586
  }
7462
7587
 
7463
7588
  // src/lib/tdd/run-test-cases.ts
7464
- import { existsSync as existsSync28, mkdtempSync as mkdtempSync2, readFileSync as readFileSync23, rmSync as rmSync8 } from "fs";
7465
- import { tmpdir as tmpdir2 } from "os";
7589
+ import { existsSync as existsSync29, mkdtempSync as mkdtempSync3, readFileSync as readFileSync23, rmSync as rmSync9 } from "fs";
7590
+ import { tmpdir as tmpdir3 } from "os";
7466
7591
  import { dirname as dirname14, join as join31 } from "path";
7467
7592
  import { fileURLToPath as fileURLToPath2 } from "url";
7468
7593
  async function runTestCases(params) {
7469
- const folder = mkdtempSync2(join31(tmpdir2(), "dialecte-tdd-"));
7594
+ const folder = mkdtempSync3(join31(tmpdir3(), "dialecte-tdd-"));
7470
7595
  const reportPath = join31(folder, "report.json");
7471
7596
  const { filter } = params;
7472
7597
  const nameFilter = filter === "all" ? [] : ["-t", filter === "collect" ? COLLECT_ONLY_PATTERN : namePattern(filter.names)];
@@ -7501,14 +7626,14 @@ async function runTestCases(params) {
7501
7626
  ${execution.stalled.report}
7502
7627
  ${tail}`.trimEnd()
7503
7628
  };
7504
- if (!existsSync28(reportPath))
7629
+ if (!existsSync29(reportPath))
7505
7630
  return {
7506
7631
  failure: `vitest wrote no report (exit ${execution.exitCode ?? "none"}):
7507
7632
  ${tail}`
7508
7633
  };
7509
7634
  return JSON.parse(readFileSync23(reportPath, "utf8"));
7510
7635
  } finally {
7511
- rmSync8(folder, { recursive: true, force: true });
7636
+ rmSync9(folder, { recursive: true, force: true });
7512
7637
  }
7513
7638
  }
7514
7639
  function namePattern(names) {
@@ -7520,14 +7645,14 @@ function namePattern(names) {
7520
7645
  function reporterPath() {
7521
7646
  const folder = dirname14(fileURLToPath2(import.meta.url));
7522
7647
  const found = REPORTER_FILE_NAMES.map((name) => join31(folder, name)).find(
7523
- (path) => existsSync28(path)
7648
+ (path) => existsSync29(path)
7524
7649
  );
7525
7650
  if (!found) throw new Error(`the tdd reporter is missing next to ${folder}`);
7526
7651
  return found;
7527
7652
  }
7528
7653
 
7529
7654
  // src/lib/tdd/test-dependencies.ts
7530
- import { existsSync as existsSync29, readFileSync as readFileSync24 } from "fs";
7655
+ import { existsSync as existsSync30, readFileSync as readFileSync24 } from "fs";
7531
7656
  import { basename as basename3, dirname as dirname15, join as join32, posix } from "path";
7532
7657
  function listTestDependencies(params) {
7533
7658
  const { root } = params;
@@ -7573,7 +7698,7 @@ function listTestDependencies(params) {
7573
7698
  }
7574
7699
  }
7575
7700
  const snapshot = join32(dirname15(params.file), "__snapshots__", `${basename3(params.file)}.snap`);
7576
- if (existsSync29(join32(root, snapshot))) found.add(snapshot);
7701
+ if (existsSync30(join32(root, snapshot))) found.add(snapshot);
7577
7702
  return { dependencies: [...found].sort(), unresolved: [...unresolved].sort() };
7578
7703
  }
7579
7704
 
@@ -7664,7 +7789,7 @@ function findDeletedCases(params) {
7664
7789
  params.ledger.entries.flatMap((entry) => entry.kind === "freeze" ? [] : [entry.file])
7665
7790
  );
7666
7791
  for (const file of receiptFiles)
7667
- if (!existsSync30(join33(params.root, file)) && readAtBase({ ...params, file }) === void 0)
7792
+ if (!existsSync31(join33(params.root, file)) && readAtBase({ ...params, file }) === void 0)
7668
7793
  findings.push({ verb: "deleted", file, detail: "a new test file deleted after its receipts" });
7669
7794
  return findings;
7670
7795
  }
@@ -7791,16 +7916,34 @@ function testsWithVitest(packageJson) {
7791
7916
 
7792
7917
  // src/commands/gate.ts
7793
7918
  async function run7(argv) {
7919
+ const ignoredGivenRepository = namesAnotherRepository({
7920
+ given: GIVEN_ENVIRONMENT,
7921
+ folder: process.cwd()
7922
+ });
7923
+ const indexFile = ignoredGivenRepository ? void 0 : GIVEN_ENVIRONMENT.GIT_INDEX_FILE;
7794
7924
  const result = await runGate({
7795
7925
  cwd: process.cwd(),
7796
7926
  argv,
7797
- ...!hasFlag(argv, "json") && { live: openProcessLiveOutput() }
7927
+ ...!hasFlag(argv, "json") && { live: openProcessLiveOutput() },
7928
+ ...indexFile && { indexFile },
7929
+ ...ignoredGivenRepository && { reusable: false }
7798
7930
  });
7799
7931
  console.log(result.output);
7800
7932
  if (result.exitCode !== 0) process.exit(result.exitCode);
7801
7933
  }
7802
7934
  async function runGate(params) {
7803
7935
  const { cwd, argv } = params;
7936
+ if (hasFlag(argv, "hook")) {
7937
+ if (hasFlag(argv, "fast") || hasFlag(argv, "full"))
7938
+ return { exitCode: 2, output: GATE_HOOK_MODE_REFUSAL };
7939
+ return runHookGate({
7940
+ cwd,
7941
+ argv,
7942
+ indexFile: params.indexFile,
7943
+ reusable: params.reusable ?? true,
7944
+ live: params.live
7945
+ });
7946
+ }
7804
7947
  if (hasFlag(argv, "fast") && hasFlag(argv, "full"))
7805
7948
  return { exitCode: 2, output: "gate: --fast or --full, not both" };
7806
7949
  const mode = hasFlag(argv, "full") ? "full" : "fast";
@@ -7916,6 +8059,63 @@ async function runGate(params) {
7916
8059
  ].join("\n")
7917
8060
  };
7918
8061
  }
8062
+ async function runHookGate(params) {
8063
+ const { cwd } = params;
8064
+ const packageJson = readPackageJson(cwd);
8065
+ const fullSteps = resolveGateSteps({ packageJson, mode: "full" });
8066
+ const testSteps = fullSteps.filter((step) => step.counts === "tests");
8067
+ if (testSteps.length === 0) return { exitCode: 0, output: GATE_HOOK_NO_TEST_STEP_LINE };
8068
+ const key = computeCommitKey({
8069
+ root: cwd,
8070
+ commandHash: gateCommandHash({ root: cwd, steps: fullSteps }),
8071
+ ...params.indexFile && { indexFile: params.indexFile }
8072
+ });
8073
+ const shortTree = key.tree.slice(0, SHORT_SHA_LENGTH);
8074
+ const found = !params.reusable || hasFlag(params.argv, "no-reuse") ? void 0 : findReusableRecord({ root: cwd, mode: "full", key });
8075
+ if (found) {
8076
+ const { at, head } = originOfRecord(found);
8077
+ return {
8078
+ exitCode: 0,
8079
+ output: GATE_HOOK_REUSED_LINE.replace("{tree}", shortTree).replace("{at}", at).replace("{head}", head.slice(0, SHORT_SHA_LENGTH))
8080
+ };
8081
+ }
8082
+ const runningLine2 = GATE_HOOK_RUNNING_LINE.replace("{tree}", shortTree);
8083
+ const { live } = params;
8084
+ const progress = live ? createStepProgress({ live, clock: createSystemClock() }) : void 0;
8085
+ live?.writeLine(runningLine2);
8086
+ const results = await runGateSteps({
8087
+ root: cwd,
8088
+ steps: testSteps,
8089
+ packageJson,
8090
+ ...progress && {
8091
+ announce: function announce(step) {
8092
+ const running = progress.start({ name: step.name, detail: step.run });
8093
+ return function finished(result) {
8094
+ running.finish(...hookStepLines(result));
8095
+ };
8096
+ }
8097
+ }
8098
+ });
8099
+ const failed = results.find((result) => result.status === "failed");
8100
+ const summary = renderVitestTestsLine(sumStepCounts(results.map((result) => result.counts)));
8101
+ if (summary && live?.tty) live.writeLine(summary);
8102
+ return {
8103
+ exitCode: failed ? 1 : 0,
8104
+ output: [
8105
+ // on a terminal the lines are on the screen already
8106
+ ...live?.tty ? [] : [runningLine2, ...results.flatMap(hookStepLines)],
8107
+ ...summary && !live?.tty ? [summary] : [],
8108
+ failed ? GATE_HOOK_FAILED_LINE.replace("{step}", failed.step.name) : GATE_HOOK_GREEN_LINE,
8109
+ ...failed?.tail ? [`--- last lines of ${failed.step.name} ---`, failed.tail] : []
8110
+ ].join("\n")
8111
+ };
8112
+ }
8113
+ function hookStepLines(result) {
8114
+ return [
8115
+ renderStepLine(result),
8116
+ ...(result.details ?? []).map((line) => `${STEP_DETAIL_INDENT}${line}`)
8117
+ ];
8118
+ }
7919
8119
  function renderReuseLine(params) {
7920
8120
  const { at, head } = originOfRecord(params.record);
7921
8121
  return GATE_REUSED_LINE.replace("{mode}", params.mode).replace("{at}", at).replace("{head}", head.slice(0, SHORT_SHA_LENGTH));
@@ -8004,9 +8204,9 @@ function renderRerun(rerun) {
8004
8204
  }
8005
8205
 
8006
8206
  // src/commands/handover.ts
8007
- import { existsSync as existsSync51, realpathSync as realpathSync7 } from "fs";
8008
- import { tmpdir as tmpdir5 } from "os";
8009
- import { dirname as dirname24, join as join57, resolve as resolve17 } from "path";
8207
+ import { existsSync as existsSync52, realpathSync as realpathSync8 } from "fs";
8208
+ import { tmpdir as tmpdir6 } from "os";
8209
+ import { dirname as dirname24, join as join57, resolve as resolve18 } from "path";
8010
8210
 
8011
8211
  // src/lib/card/card.constants.ts
8012
8212
  var EMPHASIS_CODES = { passed: 32, warning: 33, failed: 31, strong: 1 };
@@ -8200,8 +8400,8 @@ function resolveCardColumns(params) {
8200
8400
 
8201
8401
  // src/lib/handover/handover-card.ts
8202
8402
  import { spawnSync as spawnSync9 } from "child_process";
8203
- import { closeSync as closeSync2, mkdtempSync as mkdtempSync3, openSync as openSync2, readFileSync as readFileSync33, rmSync as rmSync11 } from "fs";
8204
- import { tmpdir as tmpdir3 } from "os";
8403
+ import { closeSync as closeSync2, mkdtempSync as mkdtempSync4, openSync as openSync2, readFileSync as readFileSync33, rmSync as rmSync12 } from "fs";
8404
+ import { tmpdir as tmpdir4 } from "os";
8205
8405
  import { basename as basename5, join as join44 } from "path";
8206
8406
 
8207
8407
  // src/lib/counted.ts
@@ -8210,7 +8410,7 @@ function counted(params) {
8210
8410
  }
8211
8411
 
8212
8412
  // src/lib/gate-records/card-gates.ts
8213
- import { existsSync as existsSync36, readdirSync as readdirSync10, readFileSync as readFileSync29 } from "fs";
8413
+ import { existsSync as existsSync37, readdirSync as readdirSync10, readFileSync as readFileSync29 } from "fs";
8214
8414
  import { join as join40 } from "path";
8215
8415
 
8216
8416
  // src/lib/mutation/pending-verdict.constants.ts
@@ -8234,7 +8434,7 @@ var GATE_LOT_WITHOUT_RUN = "gate lot: run dialecte mutants run on this tree firs
8234
8434
  var INVALID_FOLDER_MODE = '{file}: "mutation" must be one of {modes}, not {value}';
8235
8435
 
8236
8436
  // src/lib/mutation/pending-verdict.ts
8237
- import { existsSync as existsSync34 } from "fs";
8437
+ import { existsSync as existsSync35 } from "fs";
8238
8438
  import { join as join39 } from "path";
8239
8439
 
8240
8440
  // src/lib/mutation/mutation.constants.ts
@@ -8385,13 +8585,13 @@ function isNonEmptyString(value) {
8385
8585
  import { randomBytes as randomBytes2 } from "crypto";
8386
8586
  import {
8387
8587
  closeSync,
8388
- existsSync as existsSync33,
8588
+ existsSync as existsSync34,
8389
8589
  linkSync,
8390
8590
  mkdirSync as mkdirSync9,
8391
8591
  openSync,
8392
8592
  readFileSync as readFileSync27,
8393
8593
  renameSync as renameSync3,
8394
- rmSync as rmSync9,
8594
+ rmSync as rmSync10,
8395
8595
  statSync as statSync6,
8396
8596
  writeSync
8397
8597
  } from "fs";
@@ -8680,11 +8880,11 @@ function shortHash(params) {
8680
8880
  }
8681
8881
 
8682
8882
  // src/lib/mutation/records-file.ts
8683
- import { existsSync as existsSync31, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
8883
+ import { existsSync as existsSync32, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
8684
8884
  import { dirname as dirname16, join as join35 } from "path";
8685
8885
  function readRecordsFile(params) {
8686
8886
  const path = join35(params.root, MUTATION_RECORDS_PATH);
8687
- if (!existsSync31(path)) return {};
8887
+ if (!existsSync32(path)) return {};
8688
8888
  try {
8689
8889
  return JSON.parse(readFileSync25(path, "utf8"));
8690
8890
  } catch (error) {
@@ -8701,7 +8901,7 @@ function writeRecordsFile(params) {
8701
8901
  // src/lib/mutation/run-store.ts
8702
8902
  import { randomBytes } from "crypto";
8703
8903
  import {
8704
- existsSync as existsSync32,
8904
+ existsSync as existsSync33,
8705
8905
  mkdirSync as mkdirSync8,
8706
8906
  readdirSync as readdirSync9,
8707
8907
  readFileSync as readFileSync26,
@@ -8753,7 +8953,7 @@ function readRuns(params) {
8753
8953
  }
8754
8954
  function readStoredRuns(root) {
8755
8955
  const folder = runsFolderOf(root);
8756
- if (!existsSync32(folder)) return [];
8956
+ if (!existsSync33(folder)) return [];
8757
8957
  return readdirSync9(folder).filter((file) => file.endsWith(".json")).flatMap((file) => {
8758
8958
  const entry = parseRunEntry(join36(folder, file));
8759
8959
  return entry ? [entry] : [];
@@ -8797,7 +8997,7 @@ function writeRunEntry(params) {
8797
8997
  }
8798
8998
  function readStoredRun(params) {
8799
8999
  const path = join36(runsFolderOf(params.root), `${params.runId}.json`);
8800
- return existsSync32(path) ? parseRunEntry(path) : void 0;
9000
+ return existsSync33(path) ? parseRunEntry(path) : void 0;
8801
9001
  }
8802
9002
  function parseRunEntry(path) {
8803
9003
  try {
@@ -8928,7 +9128,7 @@ function withLedgerLock(params) {
8928
9128
  }
8929
9129
  return result;
8930
9130
  } finally {
8931
- rmSync9(lock, { force: true });
9131
+ rmSync10(lock, { force: true });
8932
9132
  }
8933
9133
  }
8934
9134
  function foldMissedRuns(params) {
@@ -8947,7 +9147,7 @@ function compareRunsInFoldOrder(first, second) {
8947
9147
  function nothingMore() {
8948
9148
  }
8949
9149
  function recordsOfRun(run25) {
8950
- if (run25.packageRoot === void 0 || !existsSync33(run25.packageRoot)) return {};
9150
+ if (run25.packageRoot === void 0 || !existsSync34(run25.packageRoot)) return {};
8951
9151
  try {
8952
9152
  return readRecordsFile({ root: run25.packageRoot });
8953
9153
  } catch {
@@ -9049,7 +9249,7 @@ function createLock(lock) {
9049
9249
  `);
9050
9250
  } catch (error) {
9051
9251
  closeSync(descriptor);
9052
- rmSync9(lock, { force: true });
9252
+ rmSync10(lock, { force: true });
9053
9253
  throw error;
9054
9254
  }
9055
9255
  closeSync(descriptor);
@@ -9094,7 +9294,7 @@ function removeStaleLock(params) {
9094
9294
  throw error;
9095
9295
  }
9096
9296
  }
9097
- rmSync9(aside, { force: true });
9297
+ rmSync10(aside, { force: true });
9098
9298
  }
9099
9299
  function isThisProcess(holder) {
9100
9300
  return holder.pid === process.pid && (holder.startedAt === void 0 || holder.startedAt === processStartTime(process.pid));
@@ -9103,7 +9303,7 @@ function sleep(milliseconds) {
9103
9303
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
9104
9304
  }
9105
9305
  function readJson(params) {
9106
- return existsSync33(params.path) ? JSON.parse(readFileSync27(params.path, "utf8")) : params.empty;
9306
+ return existsSync34(params.path) ? JSON.parse(readFileSync27(params.path, "utf8")) : params.empty;
9107
9307
  }
9108
9308
  function ledgerKeyOf(params) {
9109
9309
  return `${params.packageName}${LEDGER_KEY_SEPARATOR}${params.key}`;
@@ -9176,7 +9376,7 @@ function pendingVerdict(params) {
9176
9376
  }
9177
9377
  function lotModeOf(params) {
9178
9378
  const archived = join39(params.folder, ARCHIVED_LOT_FILE);
9179
- if (!existsSync34(archived)) return readMutationMode({ root: params.root });
9379
+ if (!existsSync35(archived)) return readMutationMode({ root: params.root });
9180
9380
  const declaration = readLotDeclaration(archived);
9181
9381
  if ("failure" in declaration)
9182
9382
  return {
@@ -9217,7 +9417,7 @@ function hasReportedRunOn(params) {
9217
9417
  }
9218
9418
 
9219
9419
  // src/lib/review-rounds/findings-ledger.ts
9220
- import { existsSync as existsSync35, readFileSync as readFileSync28, writeFileSync as writeFileSync15 } from "fs";
9420
+ import { existsSync as existsSync36, readFileSync as readFileSync28, writeFileSync as writeFileSync15 } from "fs";
9221
9421
  function escapeCell(value) {
9222
9422
  return value.replace(/\|/g, "\\|");
9223
9423
  }
@@ -9262,7 +9462,7 @@ function roundOfRow(cells) {
9262
9462
  return id ? Number(id[1]) : void 0;
9263
9463
  }
9264
9464
  function appendFinding(params) {
9265
- const text = existsSync35(params.path) ? readFileSync28(params.path, "utf8") : "";
9465
+ const text = existsSync36(params.path) ? readFileSync28(params.path, "utf8") : "";
9266
9466
  const lines = text.split("\n");
9267
9467
  const table = findLedgerTable(lines);
9268
9468
  const numbers = (table?.rows ?? []).map(function numberInRound(row2) {
@@ -9438,6 +9638,8 @@ function lineOfStep(step) {
9438
9638
  status: "warning",
9439
9639
  detail: NOT_RUN_HERE_DETAIL.replace("{reason}", shortReason(step.reason ?? ""))
9440
9640
  };
9641
+ if (step.status === "passed" && step.reused)
9642
+ return { name, status: "passed", detail: HOOK_REUSED_DETAIL };
9441
9643
  const counts = renderCardCounts(step.counts);
9442
9644
  if (step.status === "failed")
9443
9645
  return {
@@ -9493,7 +9695,7 @@ function rulesLine(params) {
9493
9695
  }
9494
9696
  function reviewLine(folder) {
9495
9697
  const ledgerPath2 = join40(folder, LEDGER_FILE);
9496
- if (!existsSync36(ledgerPath2))
9698
+ if (!existsSync37(ledgerPath2))
9497
9699
  return { name: REVIEW_LINE_NAME, status: "warning", detail: NO_LEDGER_DETAIL };
9498
9700
  const lines = readFileSync29(ledgerPath2, "utf8").split("\n");
9499
9701
  const rows = findLedgerTable(lines)?.rows ?? [];
@@ -9597,13 +9799,13 @@ function lineCountOf(text) {
9597
9799
 
9598
9800
  // src/lib/handover/merge-lot.ts
9599
9801
  import { spawnSync as spawnSync8 } from "child_process";
9600
- import { copyFileSync, existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync32, rmSync as rmSync10, writeFileSync as writeFileSync17 } from "fs";
9802
+ import { copyFileSync as copyFileSync2, existsSync as existsSync39, mkdirSync as mkdirSync11, readFileSync as readFileSync32, rmSync as rmSync11, writeFileSync as writeFileSync17 } from "fs";
9601
9803
  import { dirname as dirname17, isAbsolute as isAbsolute5, join as join43 } from "path";
9602
9804
 
9603
9805
  // src/lib/handover/write-handover.ts
9604
9806
  import { createHash as createHash5 } from "crypto";
9605
- import { chmodSync, existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync31, writeFileSync as writeFileSync16 } from "fs";
9606
- import { join as join42, resolve as resolve12 } from "path";
9807
+ import { chmodSync, existsSync as existsSync38, mkdirSync as mkdirSync10, readFileSync as readFileSync31, writeFileSync as writeFileSync16 } from "fs";
9808
+ import { join as join42, resolve as resolve13 } from "path";
9607
9809
 
9608
9810
  // src/lib/handover/commit-script.ts
9609
9811
  function renderCommitScript(params) {
@@ -9634,7 +9836,7 @@ function writeHandover(params) {
9634
9836
  const { plan, out } = params;
9635
9837
  mkdirSync10(out, { recursive: true });
9636
9838
  const lotsCopy = join42(out, HANDOVER_FILES.lots);
9637
- if (resolve12(params.lotsPath) !== resolve12(lotsCopy) || !existsSync37(lotsCopy))
9839
+ if (resolve13(params.lotsPath) !== resolve13(lotsCopy) || !existsSync38(lotsCopy))
9638
9840
  writeFileSync16(lotsCopy, `${JSON.stringify(params.lotsFile, null, " ")}
9639
9841
  `);
9640
9842
  writeFileSync16(join42(out, HANDOVER_FILES.lotsHash), `${hashFile2(lotsCopy)}
@@ -9695,7 +9897,7 @@ function planMergeLot(params) {
9695
9897
  const resolutions = Object.entries(lot.resolved).sort(([left], [right]) => left.localeCompare(right)).flatMap(function resolutionOf([path, relative12]) {
9696
9898
  if (relative12 === null) return [{ path, removed: true }];
9697
9899
  const file = isAbsolute5(relative12) ? relative12 : join43(dirname17(params.lotsPath), relative12);
9698
- if (!existsSync38(file)) {
9900
+ if (!existsSync39(file)) {
9699
9901
  refusals.push(`merge lot ${number}: the resolution ${relative12} of ${path} does not exist`);
9700
9902
  return [];
9701
9903
  }
@@ -9789,13 +9991,13 @@ function runMergeLot(params) {
9789
9991
  readGit({ root, args: ["rm", "-q", "-f", "--", resolution.path] });
9790
9992
  continue;
9791
9993
  }
9792
- if (!existsSync38(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
9994
+ if (!existsSync39(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
9793
9995
  return {
9794
9996
  refusal: `the resolution of ${resolution.path} changed since the review: ${resolution.file}`
9795
9997
  };
9796
9998
  const target = join43(root, resolution.path);
9797
9999
  mkdirSync11(dirname17(target), { recursive: true });
9798
- copyFileSync(resolution.file, target);
10000
+ copyFileSync2(resolution.file, target);
9799
10001
  readGit({ root, args: ["add", "--", resolution.path] });
9800
10002
  }
9801
10003
  const unmerged = listNul({ root, args: ["diff", "--name-only", "-z", "--diff-filter=U"] });
@@ -9824,7 +10026,7 @@ function undoMerge(params) {
9824
10026
  }
9825
10027
  function readMergeMarker(root) {
9826
10028
  const path = mergeMarkerPath(root);
9827
- if (!existsSync38(path)) return void 0;
10029
+ if (!existsSync39(path)) return void 0;
9828
10030
  try {
9829
10031
  return JSON.parse(readFileSync32(path, "utf8")).tip;
9830
10032
  } catch {
@@ -9832,7 +10034,7 @@ function readMergeMarker(root) {
9832
10034
  }
9833
10035
  }
9834
10036
  function removeMergeMarker(root) {
9835
- rmSync10(mergeMarkerPath(root), { force: true });
10037
+ rmSync11(mergeMarkerPath(root), { force: true });
9836
10038
  }
9837
10039
  function stagedFilesWithMarkers(root) {
9838
10040
  return listNul({
@@ -9840,7 +10042,7 @@ function stagedFilesWithMarkers(root) {
9840
10042
  args: ["diff", "--cached", "--name-only", "-z", "--diff-filter=d"]
9841
10043
  }).filter(function holdsMarkers(file) {
9842
10044
  const path = join43(root, file);
9843
- if (!existsSync38(path)) return false;
10045
+ if (!existsSync39(path)) return false;
9844
10046
  const text = readFileSync32(path);
9845
10047
  return !text.subarray(0, BINARY_PROBE_LENGTH).includes(0) && CONFLICT_MARKER_PATTERN.test(text.toString("utf8"));
9846
10048
  });
@@ -9989,7 +10191,7 @@ function mergeLine(merge) {
9989
10191
  }
9990
10192
  function runsHandovers(params) {
9991
10193
  const [command, ...args] = HANDOVER_PROBE_COMMAND;
9992
- const folder = mkdtempSync3(join44(tmpdir3(), HANDOVER_PROBE_FOLDER_PREFIX));
10194
+ const folder = mkdtempSync4(join44(tmpdir4(), HANDOVER_PROBE_FOLDER_PREFIX));
9993
10195
  const answerPath = join44(folder, "answer.txt");
9994
10196
  const answer = openSync2(answerPath, "w");
9995
10197
  try {
@@ -10002,7 +10204,7 @@ function runsHandovers(params) {
10002
10204
  return probe.status === 0 && readFileSync33(answerPath, "utf8").includes(HANDOVER_PROBE_ANSWER);
10003
10205
  } finally {
10004
10206
  closeSync2(answer);
10005
- rmSync11(folder, { recursive: true, force: true });
10207
+ rmSync12(folder, { recursive: true, force: true });
10006
10208
  }
10007
10209
  }
10008
10210
  function tddSection(params) {
@@ -10335,7 +10537,7 @@ function optionalSection(params) {
10335
10537
 
10336
10538
  // src/lib/handover/list-handovers.ts
10337
10539
  import { spawnSync as spawnSync10 } from "child_process";
10338
- import { existsSync as existsSync40, lstatSync as lstatSync6, readdirSync as readdirSync11, realpathSync as realpathSync5, statSync as statSync7 } from "fs";
10540
+ import { existsSync as existsSync41, lstatSync as lstatSync6, readdirSync as readdirSync11, realpathSync as realpathSync6, statSync as statSync7 } from "fs";
10339
10541
  import { basename as basename6, join as join46 } from "path";
10340
10542
 
10341
10543
  // src/lib/handover/find-committed-lots.ts
@@ -10403,10 +10605,10 @@ function describeMismatch(params) {
10403
10605
  }
10404
10606
 
10405
10607
  // src/lib/handover/read-handover-folder.ts
10406
- import { existsSync as existsSync39, readFileSync as readFileSync34 } from "fs";
10407
- import { join as join45, resolve as resolve13 } from "path";
10608
+ import { existsSync as existsSync40, readFileSync as readFileSync34 } from "fs";
10609
+ import { join as join45, resolve as resolve14 } from "path";
10408
10610
  function readHandoverFolder(folder) {
10409
- const absoluteFolder = resolve13(folder);
10611
+ const absoluteFolder = resolve14(folder);
10410
10612
  const lotsFile = readLotsFile(join45(absoluteFolder, HANDOVER_FILES.lots));
10411
10613
  if (typeof lotsFile === "string") return lotsFile;
10412
10614
  const missing = [
@@ -10414,13 +10616,13 @@ function readHandoverFolder(folder) {
10414
10616
  HANDOVER_FILES.hashes,
10415
10617
  HANDOVER_FILES.deleted,
10416
10618
  HANDOVER_FILES.lotsHash
10417
- ].filter((name) => !existsSync39(join45(absoluteFolder, name)));
10619
+ ].filter((name) => !existsSync40(join45(absoluteFolder, name)));
10418
10620
  if (missing.length)
10419
10621
  return `${absoluteFolder} misses ${missing.join(", ")}: write it with \`dialecte handover <lots.json>\``;
10420
10622
  const files = readLines(join45(absoluteFolder, HANDOVER_FILES.files));
10421
10623
  const deleted = new Set(readLines(join45(absoluteFolder, HANDOVER_FILES.deleted)));
10422
10624
  const mergesPath = join45(absoluteFolder, HANDOVER_FILES.merges);
10423
- const merges = existsSync39(mergesPath) ? JSON.parse(readFileSync34(mergesPath, "utf8")) : {};
10625
+ const merges = existsSync40(mergesPath) ? JSON.parse(readFileSync34(mergesPath, "utf8")) : {};
10424
10626
  if (lotsFile.lots.some((lot, index) => isMergeLotPlan(lot) && !merges[index]))
10425
10627
  return `${absoluteFolder} misses the merge records (${HANDOVER_FILES.merges}): write it again with \`dialecte handover --rehash <lots.json>\``;
10426
10628
  if (Object.values(merges).some((merge) => typeof merge.onTree !== "string"))
@@ -10442,7 +10644,7 @@ function readHandoverFolder(folder) {
10442
10644
  }),
10443
10645
  snapshotLines: readLines(join45(absoluteFolder, HANDOVER_FILES.hashes)),
10444
10646
  lotsHash: readFileSync34(join45(absoluteFolder, HANDOVER_FILES.lotsHash), "utf8").trim(),
10445
- ...existsSync39(join45(absoluteFolder, HANDOVER_FILES.mergesHash)) && {
10647
+ ...existsSync40(join45(absoluteFolder, HANDOVER_FILES.mergesHash)) && {
10446
10648
  mergesHash: readFileSync34(join45(absoluteFolder, HANDOVER_FILES.mergesHash), "utf8").trim()
10447
10649
  }
10448
10650
  };
@@ -10455,7 +10657,7 @@ function readLines(path) {
10455
10657
  function listHandovers(params) {
10456
10658
  const folders = findHandoverFolders({ folder: params.root, depth: LIST_DEPTH });
10457
10659
  return onePerRealPath(folders).flatMap(function listing(folder) {
10458
- if (!existsSync40(join46(folder, HANDOVER_FILES.lots)))
10660
+ if (!existsSync41(join46(folder, HANDOVER_FILES.lots)))
10459
10661
  return [
10460
10662
  {
10461
10663
  folder,
@@ -10470,7 +10672,7 @@ function listHandovers(params) {
10470
10672
  const handover = readHandoverFolder(folder);
10471
10673
  if (typeof handover === "string") return [];
10472
10674
  const { lotsFile } = handover;
10473
- const repositoryExists = existsSync40(lotsFile.repository);
10675
+ const repositoryExists = existsSync41(lotsFile.repository);
10474
10676
  return [
10475
10677
  {
10476
10678
  folder,
@@ -10487,7 +10689,7 @@ function listHandovers(params) {
10487
10689
  function onePerRealPath(folders) {
10488
10690
  const byRealPath = /* @__PURE__ */ new Map();
10489
10691
  for (const folder of folders) {
10490
- const real = realpathSync5(folder);
10692
+ const real = realpathSync6(folder);
10491
10693
  const known = byRealPath.get(real);
10492
10694
  if (known === void 0 || lstatSync6(known).isSymbolicLink() && !lstatSync6(folder).isSymbolicLink())
10493
10695
  byRealPath.set(real, folder);
@@ -10522,9 +10724,9 @@ function newestScriptTime(folder) {
10522
10724
  }
10523
10725
  function findHandoverFolders(params) {
10524
10726
  const { folder } = params;
10525
- if (!existsSync40(folder)) return [];
10526
- const hasLots = existsSync40(join46(folder, HANDOVER_FILES.lots));
10527
- const found = hasLots && existsSync40(join46(folder, COMMIT_SCRIPT_FILE)) || !hasLots && listLegacyScripts(folder).length > 0 ? [folder] : [];
10727
+ if (!existsSync41(folder)) return [];
10728
+ const hasLots = existsSync41(join46(folder, HANDOVER_FILES.lots));
10729
+ const found = hasLots && existsSync41(join46(folder, COMMIT_SCRIPT_FILE)) || !hasLots && listLegacyScripts(folder).length > 0 ? [folder] : [];
10528
10730
  if (params.depth === 0) return found;
10529
10731
  for (const entry of readdirSync11(folder, { withFileTypes: true }))
10530
10732
  if (isFolder({ folder, entry }) && entry.name !== "node_modules" && !entry.name.startsWith("."))
@@ -10544,7 +10746,7 @@ function isFolder(params) {
10544
10746
  }
10545
10747
 
10546
10748
  // src/lib/handover/plan-handover.ts
10547
- import { existsSync as existsSync41 } from "fs";
10749
+ import { existsSync as existsSync42 } from "fs";
10548
10750
  import { join as join48 } from "path";
10549
10751
 
10550
10752
  // src/lib/handover/find-lot-references.ts
@@ -10685,8 +10887,8 @@ function planHandover(params) {
10685
10887
  pendingFiles.push(...files);
10686
10888
  return {
10687
10889
  message: lot.message,
10688
- files: files.filter((file) => existsSync41(join48(root, file))),
10689
- deletedFiles: files.filter((file) => !existsSync41(join48(root, file)))
10890
+ files: files.filter((file) => existsSync42(join48(root, file))),
10891
+ deletedFiles: files.filter((file) => !existsSync42(join48(root, file)))
10690
10892
  };
10691
10893
  });
10692
10894
  for (const file of changedFiles)
@@ -10705,12 +10907,12 @@ function readGitVersion() {
10705
10907
  import { spawnSync as spawnSync15 } from "child_process";
10706
10908
  import {
10707
10909
  cpSync as cpSync2,
10708
- existsSync as existsSync49,
10910
+ existsSync as existsSync50,
10709
10911
  mkdirSync as mkdirSync14,
10710
- mkdtempSync as mkdtempSync5,
10912
+ mkdtempSync as mkdtempSync6,
10711
10913
  readdirSync as readdirSync14,
10712
10914
  rmdirSync,
10713
- rmSync as rmSync17,
10915
+ rmSync as rmSync18,
10714
10916
  writeFileSync as writeFileSync21
10715
10917
  } from "fs";
10716
10918
  import { constants as constants2 } from "os";
@@ -10718,8 +10920,8 @@ import { basename as basename7, dirname as dirname22, isAbsolute as isAbsolute9,
10718
10920
 
10719
10921
  // src/lib/worktree/copy-node-modules.ts
10720
10922
  import { spawnSync as spawnSync11 } from "child_process";
10721
- import { existsSync as existsSync42, lstatSync as lstatSync7, readdirSync as readdirSync12, readlinkSync as readlinkSync2, rmSync as rmSync12, symlinkSync as symlinkSync2 } from "fs";
10722
- import { dirname as dirname18, isAbsolute as isAbsolute6, join as join49, relative as relative6, resolve as resolve14 } from "path";
10923
+ import { existsSync as existsSync43, lstatSync as lstatSync7, readdirSync as readdirSync12, readlinkSync as readlinkSync2, rmSync as rmSync13, symlinkSync as symlinkSync2 } from "fs";
10924
+ import { dirname as dirname18, isAbsolute as isAbsolute6, join as join49, relative as relative6, resolve as resolve15 } from "path";
10723
10925
  function copyNodeModules(params) {
10724
10926
  const { from, to } = params;
10725
10927
  const runCopy = params.runCopy ?? runCp;
@@ -10730,14 +10932,14 @@ function copyNodeModules(params) {
10730
10932
  for (const attempt of attempts) {
10731
10933
  const result = runCopy(attempt.args);
10732
10934
  if (result.signal) {
10733
- rmSync12(to, { recursive: true, force: true });
10935
+ rmSync13(to, { recursive: true, force: true });
10734
10936
  throw new Error(`copying ${from} was interrupted (${result.signal})`);
10735
10937
  }
10736
10938
  if (result.status === 0) {
10737
10939
  const relinked = relinkEscapingLinks({ from, to });
10738
10940
  return { method: attempt.method, relinked };
10739
10941
  }
10740
- rmSync12(to, { recursive: true, force: true });
10942
+ rmSync13(to, { recursive: true, force: true });
10741
10943
  }
10742
10944
  throw new Error(`cannot copy ${from} to ${to}`);
10743
10945
  }
@@ -10752,17 +10954,17 @@ function relinkEscapingLinks(params) {
10752
10954
  if (!lstatSync7(source).isSymbolicLink()) continue;
10753
10955
  const target = readlinkSync2(source);
10754
10956
  if (isAbsolute6(target)) continue;
10755
- const resolved = resolve14(dirname18(source), target);
10957
+ const resolved = resolve15(dirname18(source), target);
10756
10958
  if (!relative6(params.from, resolved).startsWith("..")) continue;
10757
10959
  const copy = join49(params.to, entry);
10758
- rmSync12(copy, { force: true });
10960
+ rmSync13(copy, { force: true });
10759
10961
  symlinkSync2(resolved, copy);
10760
10962
  relinked.push(entry);
10761
10963
  }
10762
10964
  return relinked;
10763
10965
  }
10764
10966
  function packageEntries(folder) {
10765
- if (!existsSync42(folder)) return [];
10967
+ if (!existsSync43(folder)) return [];
10766
10968
  return readdirSync12(folder).flatMap(function entriesOf(name) {
10767
10969
  if (!name.startsWith("@")) return [name];
10768
10970
  const scope = join49(folder, name);
@@ -10772,12 +10974,12 @@ function packageEntries(folder) {
10772
10974
  }
10773
10975
 
10774
10976
  // src/lib/handover/rehearsal-links.ts
10775
- import { existsSync as existsSync44, mkdirSync as mkdirSync12, rmSync as rmSync13, symlinkSync as symlinkSync4, unlinkSync as unlinkSync2 } from "fs";
10776
- import { dirname as dirname20, isAbsolute as isAbsolute8, resolve as resolve16 } from "path";
10977
+ import { existsSync as existsSync45, mkdirSync as mkdirSync12, rmSync as rmSync14, symlinkSync as symlinkSync4, unlinkSync as unlinkSync2 } from "fs";
10978
+ import { dirname as dirname20, isAbsolute as isAbsolute8, resolve as resolve17 } from "path";
10777
10979
 
10778
10980
  // src/lib/worktree/sibling-links.ts
10779
- import { existsSync as existsSync43, lstatSync as lstatSync8, readlinkSync as readlinkSync3, realpathSync as realpathSync6, symlinkSync as symlinkSync3 } from "fs";
10780
- import { dirname as dirname19, isAbsolute as isAbsolute7, join as join50, relative as relative7, resolve as resolve15, sep } from "path";
10981
+ import { existsSync as existsSync44, lstatSync as lstatSync8, readlinkSync as readlinkSync3, realpathSync as realpathSync7, symlinkSync as symlinkSync3 } from "fs";
10982
+ import { dirname as dirname19, isAbsolute as isAbsolute7, join as join50, relative as relative7, resolve as resolve16, sep } from "path";
10781
10983
 
10782
10984
  // src/lib/workspace.constants.ts
10783
10985
  var WORKSPACE_MARKERS = ["_commit-plan", ".worktrees"];
@@ -10794,8 +10996,8 @@ function linkSiblings(params) {
10794
10996
  for (const [dependency, spec] of Object.entries(packageJson[section] ?? {})) {
10795
10997
  const path = LOCAL_DEPENDENCY_PATTERN.exec(spec)?.[1];
10796
10998
  if (path === void 0 || isAbsolute7(path)) continue;
10797
- const link = resolve15(worktree, path);
10798
- const target = resolve15(repository, path);
10999
+ const link = resolve16(worktree, path);
11000
+ const target = resolve16(repository, path);
10799
11001
  if (link === worktree || isInside({ path: link, folder: worktree })) continue;
10800
11002
  if (!isInside({ path: link, folder: worktreesFolder })) {
10801
11003
  links.push({ dependency, link, target, outcome: "skipped: outside .worktrees/" });
@@ -10818,7 +11020,7 @@ function linkSiblings(params) {
10818
11020
  function linkOutcome(params) {
10819
11021
  const { link, target } = params;
10820
11022
  if (isPresent(link)) return describeExisting({ link, target });
10821
- if (!existsSync43(target)) return `skipped: ${target} missing`;
11023
+ if (!existsSync44(target)) return `skipped: ${target} missing`;
10822
11024
  const missingParent = topMissingFolder({ path: dirname19(link), above: params.worktreesFolder });
10823
11025
  if (missingParent) return `skipped: ${missingParent} missing`;
10824
11026
  params.beforeLink?.(link);
@@ -10841,7 +11043,7 @@ function describeExisting(params) {
10841
11043
  const { link, target } = params;
10842
11044
  const status = lstatSync8(link);
10843
11045
  if (!status.isSymbolicLink()) return `kept: a real ${status.isDirectory() ? "folder" : "file"}`;
10844
- if (existsSync43(target) && existsSync43(link) && realpathSync6(link) === realpathSync6(target))
11046
+ if (existsSync44(target) && existsSync44(link) && realpathSync7(link) === realpathSync7(target))
10845
11047
  return "present";
10846
11048
  return `kept: points to ${readlinkSync3(link)}, not ${target}`;
10847
11049
  }
@@ -10861,15 +11063,15 @@ function linkRehearsalSiblings(params) {
10861
11063
  for (const spec of Object.values(packageJson[section] ?? {})) {
10862
11064
  const path = LOCAL_DEPENDENCY_PATTERN.exec(spec)?.[1];
10863
11065
  if (path === void 0 || isAbsolute8(path)) continue;
10864
- const link = resolve16(clone, path);
11066
+ const link = resolve17(clone, path);
10865
11067
  if (link === clone || isInside({ path: link, folder: clone })) continue;
10866
11068
  if (!isInside({ path: link, folder })) {
10867
11069
  lines.push(` not linked: ${path} leaves the rehearsal folder`);
10868
11070
  continue;
10869
11071
  }
10870
- const target = resolve16(repository, path);
11072
+ const target = resolve17(repository, path);
10871
11073
  if (isPresent(link)) continue;
10872
- if (!existsSync44(target)) {
11074
+ if (!existsSync45(target)) {
10873
11075
  lines.push(` not linked: ${path} (${target} missing)`);
10874
11076
  continue;
10875
11077
  }
@@ -10883,7 +11085,7 @@ function linkRehearsalSiblings(params) {
10883
11085
  }
10884
11086
  function removeRehearsalFolder(params) {
10885
11087
  for (const link of params.links) if (isPresent(link)) unlinkSync2(link);
10886
- rmSync13(params.folder, { recursive: true, force: true });
11088
+ rmSync14(params.folder, { recursive: true, force: true });
10887
11089
  }
10888
11090
 
10889
11091
  // src/lib/handover/rehearsal-plan.ts
@@ -10998,17 +11200,17 @@ function fillReason(params) {
10998
11200
  }
10999
11201
 
11000
11202
  // src/lib/handover/run-handover-folder.ts
11001
- import { copyFileSync as copyFileSync2, existsSync as existsSync48, readFileSync as readFileSync38, rmSync as rmSync16, writeFileSync as writeFileSync20 } from "fs";
11203
+ import { copyFileSync as copyFileSync3, existsSync as existsSync49, readFileSync as readFileSync38, rmSync as rmSync17, writeFileSync as writeFileSync20 } from "fs";
11002
11204
  import { join as join54 } from "path";
11003
11205
 
11004
11206
  // src/lib/handover/check-handover-guards.ts
11005
11207
  import { spawnSync as spawnSync13 } from "child_process";
11006
- import { existsSync as existsSync46 } from "fs";
11208
+ import { existsSync as existsSync47 } from "fs";
11007
11209
  import { join as join52 } from "path";
11008
11210
 
11009
11211
  // src/lib/handover/sync-node-modules.ts
11010
11212
  import { spawnSync as spawnSync12 } from "child_process";
11011
- import { existsSync as existsSync45, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync37, rmSync as rmSync14, writeFileSync as writeFileSync18 } from "fs";
11213
+ import { existsSync as existsSync46, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync37, rmSync as rmSync15, writeFileSync as writeFileSync18 } from "fs";
11012
11214
  import { join as join51 } from "path";
11013
11215
  async function syncNodeModules(params) {
11014
11216
  const { root, clock } = params;
@@ -11020,7 +11222,7 @@ async function syncNodeModules(params) {
11020
11222
  const files = [PACKAGE_LOCK_FILE2, PACKAGE_MANIFEST_FILE].map((file) => ({
11021
11223
  file,
11022
11224
  path: join51(root, file),
11023
- working: existsSync45(join51(root, file)) ? readFileSync37(join51(root, file)) : void 0,
11225
+ working: existsSync46(join51(root, file)) ? readFileSync37(join51(root, file)) : void 0,
11024
11226
  staged: stagedBytes({ root, file })
11025
11227
  }));
11026
11228
  const overwritten = files.filter((entry) => entry.staged !== void 0);
@@ -11033,9 +11235,9 @@ async function syncNodeModules(params) {
11033
11235
  }
11034
11236
  function restore() {
11035
11237
  for (const { path, working } of overwritten)
11036
- if (working === void 0) rmSync14(path, { force: true });
11238
+ if (working === void 0) rmSync15(path, { force: true });
11037
11239
  else writeFileSync18(path, working);
11038
- rmSync14(backup, { recursive: true, force: true });
11240
+ rmSync15(backup, { recursive: true, force: true });
11039
11241
  }
11040
11242
  const removeSignalHook = onSignalExit(restore);
11041
11243
  let changed;
@@ -11048,7 +11250,7 @@ async function syncNodeModules(params) {
11048
11250
  refusal: `${INSTALL_COMMAND2.join(" ")} failed (exit ${installed.exitCode ?? "stalled"}): ${installed.output.trim().split("\n").slice(-3).join(" / ")}; node_modules is now incomplete (npm ci removes it first): the same command installs it again`
11049
11251
  };
11050
11252
  changed = overwritten.find(
11051
- ({ path, staged }) => !existsSync45(path) || !readFileSync37(path).equals(staged ?? Buffer.alloc(0))
11253
+ ({ path, staged }) => !existsSync46(path) || !readFileSync37(path).equals(staged ?? Buffer.alloc(0))
11052
11254
  )?.file;
11053
11255
  } finally {
11054
11256
  restore();
@@ -11067,11 +11269,11 @@ async function syncNodeModules(params) {
11067
11269
  }
11068
11270
  function restoreLeftoverBackup(root) {
11069
11271
  const backup = installBackupPath(root);
11070
- if (!existsSync45(backup)) return void 0;
11272
+ if (!existsSync46(backup)) return void 0;
11071
11273
  const names = readdirSync13(backup).filter((name) => name.endsWith(STAGED_SUFFIX)).map((name) => name.slice(0, -STAGED_SUFFIX.length));
11072
11274
  const stillStaged2 = names.every((name) => {
11073
11275
  const path = join51(root, name);
11074
- return existsSync45(path) && readFileSync37(path).equals(readFileSync37(join51(backup, `${name}${STAGED_SUFFIX}`)));
11276
+ return existsSync46(path) && readFileSync37(path).equals(readFileSync37(join51(backup, `${name}${STAGED_SUFFIX}`)));
11075
11277
  });
11076
11278
  if (!stillStaged2)
11077
11279
  return {
@@ -11079,10 +11281,10 @@ function restoreLeftoverBackup(root) {
11079
11281
  detail: `${backup} holds the working ${names.join(", ")} an interrupted install saved, and the working files changed since: compare them by hand, keep what is right, then delete ${backup}`
11080
11282
  };
11081
11283
  for (const name of names)
11082
- if (existsSync45(join51(backup, `${name}${ABSENT_SUFFIX}`)))
11083
- rmSync14(join51(root, name), { force: true });
11284
+ if (existsSync46(join51(backup, `${name}${ABSENT_SUFFIX}`)))
11285
+ rmSync15(join51(root, name), { force: true });
11084
11286
  else writeFileSync18(join51(root, name), readFileSync37(join51(backup, name)));
11085
- rmSync14(backup, { recursive: true, force: true });
11287
+ rmSync15(backup, { recursive: true, force: true });
11086
11288
  return {
11087
11289
  ok: true,
11088
11290
  detail: `${names.join(", ")} restored from ${backup}, which an interrupted install left`
@@ -11109,7 +11311,7 @@ function readStagedLockPackages(root) {
11109
11311
  }
11110
11312
  function installedVersion2(params) {
11111
11313
  const manifest = join51(params.root, params.path, "package.json");
11112
- return existsSync45(manifest) ? JSON.parse(readFileSync37(manifest, "utf8")).version : void 0;
11314
+ return existsSync46(manifest) ? JSON.parse(readFileSync37(manifest, "utf8")).version : void 0;
11113
11315
  }
11114
11316
  function nodeModulesAgainstStagedLock(root) {
11115
11317
  return readStagedLockPackages(root).flatMap(function differs([path, entry]) {
@@ -11150,7 +11352,7 @@ function checkHandoverGuards(params) {
11150
11352
  {
11151
11353
  name: "repository",
11152
11354
  check: function repositoryExists() {
11153
- return existsSync46(root) ? { ok: true, detail: root } : { ok: false, detail: `${root} does not exist` };
11355
+ return existsSync47(root) ? { ok: true, detail: root } : { ok: false, detail: `${root} does not exist` };
11154
11356
  }
11155
11357
  },
11156
11358
  {
@@ -11260,7 +11462,7 @@ function checkHandoverGuards(params) {
11260
11462
  const differing = handover.snapshotLines.filter(function differs(line) {
11261
11463
  const [hash, ...pathParts] = line.split(" ");
11262
11464
  const path = join52(root, pathParts.join(" "));
11263
- return !existsSync46(path) || hashFile2(path) !== hash;
11465
+ return !existsSync47(path) || hashFile2(path) !== hash;
11264
11466
  });
11265
11467
  return differing.length ? {
11266
11468
  ok: false,
@@ -11273,7 +11475,7 @@ function checkHandoverGuards(params) {
11273
11475
  name: "deleted",
11274
11476
  check: function deletedStayDeleted() {
11275
11477
  const deleted = lots.flatMap((lot) => lot.deletedFiles);
11276
- const back = deleted.filter((file) => existsSync46(join52(root, file)));
11478
+ const back = deleted.filter((file) => existsSync47(join52(root, file)));
11277
11479
  return back.length ? { ok: false, detail: "deleted in the snapshot and there again", lines: back } : { ok: true, detail: `${deleted.length} file(s) absent` };
11278
11480
  }
11279
11481
  },
@@ -11306,7 +11508,7 @@ function checkHandoverGuards(params) {
11306
11508
  }
11307
11509
  }
11308
11510
  ];
11309
- const leftover = existsSync46(root) ? restoreLeftoverBackup(root) : void 0;
11511
+ const leftover = existsSync47(root) ? restoreLeftoverBackup(root) : void 0;
11310
11512
  if (leftover) {
11311
11513
  write(`${leftover.ok ? "\u2713" : "\u2717"} ${"backup".padEnd(GUARD_NAME_WIDTH)} ${leftover.detail}`);
11312
11514
  if (!leftover.ok) return void 0;
@@ -11349,7 +11551,7 @@ function checkMerges(params) {
11349
11551
  detail: `lot ${number}: tree not recorded: rehearse first (\`--rehearse\` prints it), add it as "tree" to the lot, then \`dialecte handover --rehash\``
11350
11552
  };
11351
11553
  const changed = merge.resolutions.filter(
11352
- (resolution) => !("removed" in resolution) && (!existsSync46(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
11554
+ (resolution) => !("removed" in resolution) && (!existsSync47(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
11353
11555
  );
11354
11556
  if (changed.length)
11355
11557
  return {
@@ -11405,8 +11607,8 @@ function resolveCommit(params) {
11405
11607
  }
11406
11608
 
11407
11609
  // src/lib/handover/commit-lots.ts
11408
- import { appendFileSync, mkdtempSync as mkdtempSync4, rmSync as rmSync15, writeFileSync as writeFileSync19 } from "fs";
11409
- import { tmpdir as tmpdir4 } from "os";
11610
+ import { appendFileSync, mkdtempSync as mkdtempSync5, rmSync as rmSync16, writeFileSync as writeFileSync19 } from "fs";
11611
+ import { tmpdir as tmpdir5 } from "os";
11410
11612
  import { dirname as dirname21, join as join53 } from "path";
11411
11613
 
11412
11614
  // src/lib/progress/heartbeat.ts
@@ -11690,9 +11892,14 @@ function hookSummarySteps(params) {
11690
11892
  const stepFailed = failed.has(step);
11691
11893
  if (step.parent && !renderHookCounts(counts) && !stepFailed) return [];
11692
11894
  const tasks = step === failing ? failedTasks(step.lines).map((task) => ({ name: task, failed: true, counts: {} })) : [];
11693
- return [{ name: step.name, failed: stepFailed, counts }, ...tasks];
11895
+ const reused = readHookReuse(step.lines);
11896
+ return [{ name: step.name, failed: stepFailed, counts, ...reused && { reused } }, ...tasks];
11694
11897
  });
11695
11898
  }
11899
+ function readHookReuse(lines) {
11900
+ const match = GATE_HOOK_REUSED_PATTERN.exec(stripVTControlCharacters5(lines.join("\n")));
11901
+ return match ? { at: match[2], head: match[3] } : void 0;
11902
+ }
11696
11903
  function withoutRepeats(lines) {
11697
11904
  const flagged = /* @__PURE__ */ new Set();
11698
11905
  return lines.filter(function firstPrinted(line) {
@@ -11834,7 +12041,7 @@ function createHookLiveView(params) {
11834
12041
 
11835
12042
  // src/lib/handover/unstage-lot.ts
11836
12043
  import { spawnSync as spawnSync14 } from "child_process";
11837
- import { existsSync as existsSync47 } from "fs";
12044
+ import { existsSync as existsSync48 } from "fs";
11838
12045
  function unstageLot(params) {
11839
12046
  const { root, clock } = params;
11840
12047
  const giveUpAt = clock.now() + INDEX_LOCK_WAIT_MILLISECONDS;
@@ -11846,8 +12053,8 @@ function unstageLot(params) {
11846
12053
  if (reset.status === 0) return { unstaged: true };
11847
12054
  const lock = indexLockPath(root);
11848
12055
  const reason = (reset.stderr || reset.stdout || `git reset exited ${reset.status}`).trim().split("\n")[0];
11849
- if (!lock || !existsSync47(lock) || clock.now() >= giveUpAt)
11850
- return { unstaged: false, reason, ...lock && existsSync47(lock) && { lock } };
12056
+ if (!lock || !existsSync48(lock) || clock.now() >= giveUpAt)
12057
+ return { unstaged: false, reason, ...lock && existsSync48(lock) && { lock } };
11851
12058
  clock.sleep(INDEX_LOCK_RETRY_MILLISECONDS);
11852
12059
  }
11853
12060
  }
@@ -11915,7 +12122,7 @@ async function commitLots(params) {
11915
12122
  if (synced.note) write(` ${synced.note}`);
11916
12123
  const skipsHook = params.withoutHook?.has(number) ?? false;
11917
12124
  const hooked = !skipsHook && hasCommitHook(root);
11918
- const key = hooked ? computeCheckKey({ root, commandHash: hashHookCommand(root) }) : void 0;
12125
+ const key = hooked ? computeCommitKey({ root, commandHash: hashHookCommand(root) }) : void 0;
11919
12126
  const hookLog = createHookLog({ lot: number });
11920
12127
  const hookView = createHookLiveView({ running, tty, write, clock });
11921
12128
  const commit = await streamCommand({
@@ -11937,7 +12144,7 @@ async function commitLots(params) {
11937
12144
  });
11938
12145
  hookView.end();
11939
12146
  const hookRan = commit.output !== "" || hooked;
11940
- if (!hookRan) rmSync15(dirname21(hookLog), { recursive: true, force: true });
12147
+ if (!hookRan) rmSync16(dirname21(hookLog), { recursive: true, force: true });
11941
12148
  const hookOutcome = hookRan ? hookOutcomeLines({
11942
12149
  output: commit.output,
11943
12150
  passed: commit.exitCode === 0,
@@ -11998,10 +12205,18 @@ async function commitLots(params) {
11998
12205
  return commits;
11999
12206
  }
12000
12207
  function recordedHookStep(step) {
12001
- return { name: step.name, status: step.failed ? "failed" : "passed", counts: step.counts };
12208
+ return {
12209
+ name: step.name,
12210
+ status: step.failed ? "failed" : "passed",
12211
+ counts: step.counts,
12212
+ ...step.reused && {
12213
+ note: HOOK_REUSED_NOTE.replace("{at}", step.reused.at).replace("{head}", step.reused.head),
12214
+ reused: step.reused
12215
+ }
12216
+ };
12002
12217
  }
12003
12218
  function createHookLog(params) {
12004
- const path = join53(mkdtempSync4(join53(tmpdir4(), HOOK_LOG_FOLDER_PREFIX)), `lot-${params.lot}.log`);
12219
+ const path = join53(mkdtempSync5(join53(tmpdir5(), HOOK_LOG_FOLDER_PREFIX)), `lot-${params.lot}.log`);
12005
12220
  writeFileSync19(path, "");
12006
12221
  return path;
12007
12222
  }
@@ -12084,9 +12299,9 @@ async function runHandoverFolder(params) {
12084
12299
  function archiveLotFile(params) {
12085
12300
  const source = join54(params.root, LOT_FILE);
12086
12301
  const target = join54(params.folder, ARCHIVED_LOT_FILE);
12087
- if (!existsSync48(source) || existsSync48(target)) return void 0;
12302
+ if (!existsSync49(source) || existsSync49(target)) return void 0;
12088
12303
  if (isEmptyDeclaration(readFileSync38(source, "utf8"))) return void 0;
12089
- copyFileSync2(source, target);
12304
+ copyFileSync3(source, target);
12090
12305
  writeFileSync20(source, EMPTY_LOT_DECLARATION);
12091
12306
  return target;
12092
12307
  }
@@ -12100,8 +12315,8 @@ function isEmptyDeclaration(text) {
12100
12315
  }
12101
12316
  function releaseLock(params) {
12102
12317
  const lockPath = handoverLockPath(params.root);
12103
- if (existsSync48(lockPath) && readFileSync38(lockPath, "utf8").trim() === join54(params.folder, COMMIT_SCRIPT_FILE))
12104
- rmSync16(lockPath);
12318
+ if (existsSync49(lockPath) && readFileSync38(lockPath, "utf8").trim() === join54(params.folder, COMMIT_SCRIPT_FILE))
12319
+ rmSync17(lockPath);
12105
12320
  }
12106
12321
 
12107
12322
  // src/lib/handover/rehearse-handover.ts
@@ -12140,7 +12355,7 @@ async function rehearseHandover(params) {
12140
12355
  clock: params.clock
12141
12356
  });
12142
12357
  const repository = handover.lotsFile.repository;
12143
- const folder = mkdtempSync5(join55(params.scratchRoot, REHEARSAL_FOLDER_PREFIX));
12358
+ const folder = mkdtempSync6(join55(params.scratchRoot, REHEARSAL_FOLDER_PREFIX));
12144
12359
  const clone = join55(folder, basename7(repository));
12145
12360
  const hookTemporary = join55(folder, REHEARSAL_TEMPORARY_FOLDER);
12146
12361
  mkdirSync14(hookTemporary);
@@ -12256,11 +12471,11 @@ function prepareClone(params) {
12256
12471
  for (const file of changed) {
12257
12472
  const source = join55(repository, file);
12258
12473
  const target = join55(clone, file);
12259
- if (existsSync49(source)) {
12474
+ if (existsSync50(source)) {
12260
12475
  mkdirSync14(dirname22(target), { recursive: true });
12261
12476
  cpSync2(source, target);
12262
12477
  } else {
12263
- rmSync17(target, { force: true });
12478
+ rmSync18(target, { force: true });
12264
12479
  removeEmptiedFolders({ clone, folder: dirname22(target) });
12265
12480
  }
12266
12481
  }
@@ -12269,14 +12484,14 @@ function prepareClone(params) {
12269
12484
  if (hooks.configured && isAbsolute9(hooks.configured))
12270
12485
  readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
12271
12486
  else if (hooks.configured) {
12272
- if (existsSync49(hooks.folder))
12487
+ if (existsSync50(hooks.folder))
12273
12488
  cpSync2(hooks.folder, join55(clone, hooks.configured), { recursive: true });
12274
12489
  readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
12275
- } else if (existsSync49(hooks.folder))
12490
+ } else if (existsSync50(hooks.folder))
12276
12491
  cpSync2(hooks.folder, join55(clone, ".git", "hooks"), { recursive: true });
12277
12492
  write(` hooks: ${hooks.configured ?? "git hooks folder"} copied`);
12278
12493
  const nodeModules = join55(repository, "node_modules");
12279
- if (existsSync49(nodeModules)) {
12494
+ if (existsSync50(nodeModules)) {
12280
12495
  const copy = copyNodeModules({ from: nodeModules, to: join55(clone, "node_modules") });
12281
12496
  write(
12282
12497
  ` node_modules: ${copy.method}${copy.relinked.length ? `, ${copy.relinked.length} link(s) re-pointed` : ""}`
@@ -12285,7 +12500,7 @@ function prepareClone(params) {
12285
12500
  spawnSync15("git", ["update-index", "-q", "--refresh"], { cwd: clone });
12286
12501
  }
12287
12502
  function removeEmptiedFolders(params) {
12288
- for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) && existsSync49(folder); folder = dirname22(folder)) {
12503
+ for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) && existsSync50(folder); folder = dirname22(folder)) {
12289
12504
  if (readdirSync14(folder).length) return;
12290
12505
  rmdirSync(folder);
12291
12506
  }
@@ -12516,12 +12731,12 @@ function renderLegend(params) {
12516
12731
  }
12517
12732
 
12518
12733
  // src/lib/workspace.ts
12519
- import { existsSync as existsSync50 } from "fs";
12734
+ import { existsSync as existsSync51 } from "fs";
12520
12735
  import { dirname as dirname23, join as join56 } from "path";
12521
12736
  function findWorkspace(cwd) {
12522
12737
  let folder = cwd;
12523
12738
  for (; ; ) {
12524
- if (WORKSPACE_MARKERS.some((marker) => existsSync50(join56(folder, marker)))) return folder;
12739
+ if (WORKSPACE_MARKERS.some((marker) => existsSync51(join56(folder, marker)))) return folder;
12525
12740
  const parent = dirname23(folder);
12526
12741
  if (parent === folder) return void 0;
12527
12742
  folder = parent;
@@ -12546,7 +12761,7 @@ async function run8(argv) {
12546
12761
  columns,
12547
12762
  scratchRoot: rehearsalScratchRoot({
12548
12763
  platform: process.platform,
12549
- systemTemporaryFolder: tmpdir5()
12764
+ systemTemporaryFolder: tmpdir6()
12550
12765
  })
12551
12766
  });
12552
12767
  if (exitCode !== 0) process.exit(exitCode);
@@ -12554,7 +12769,7 @@ async function run8(argv) {
12554
12769
  }
12555
12770
  const result = argv[0] === "list" ? runHandoverList({ argv: argv.slice(1), cwd: process.cwd(), now: Date.now() }) : runHandover({
12556
12771
  argv,
12557
- cliPath: realpathSync7(process.argv[1]),
12772
+ cliPath: realpathSync8(process.argv[1]),
12558
12773
  colour,
12559
12774
  columns
12560
12775
  });
@@ -12573,17 +12788,17 @@ function runHandover(params) {
12573
12788
  };
12574
12789
  const [lotsPath] = positionalArguments({ argv, valueOptions: ["out"] });
12575
12790
  if (!lotsPath) return usage("handover: expected the path of a lots file");
12576
- const absoluteLotsPath = resolve17(lotsPath);
12791
+ const absoluteLotsPath = resolve18(lotsPath);
12577
12792
  const lotsFile = readLotsFile(absoluteLotsPath);
12578
12793
  if (typeof lotsFile === "string") return usage(`handover: ${lotsFile}`);
12579
- const out = resolve17(getArg(argv, "out") ?? dirname24(absoluteLotsPath));
12794
+ const out = resolve18(getArg(argv, "out") ?? dirname24(absoluteLotsPath));
12580
12795
  const scriptPath = join57(out, COMMIT_SCRIPT_FILE);
12581
- if (existsSync51(scriptPath) && !hasFlag(argv, "rehash"))
12796
+ if (existsSync52(scriptPath) && !hasFlag(argv, "rehash"))
12582
12797
  return usage(
12583
12798
  `handover: ${scriptPath} exists: pass --rehash to take the snapshot again after an edit`
12584
12799
  );
12585
12800
  const heldBy = readHandoverLock(lotsFile.repository);
12586
- if (heldBy && heldBy !== scriptPath && existsSync51(heldBy))
12801
+ if (heldBy && heldBy !== scriptPath && existsSync52(heldBy))
12587
12802
  return refused([
12588
12803
  handoverHoldRefusal({
12589
12804
  script: heldBy,
@@ -12633,7 +12848,7 @@ async function runHandoverRun(params) {
12633
12848
  const { argv, write } = params;
12634
12849
  const live = params.live ?? { tty: false, writeLine: write, rewriteLines: () => void 0 };
12635
12850
  const progress = createStepProgress({ live, clock: params.clock });
12636
- const cliPath = params.cliPath ?? realpathSync7(process.argv[1]);
12851
+ const cliPath = params.cliPath ?? realpathSync8(process.argv[1]);
12637
12852
  if (hasFlag(argv, "probe")) {
12638
12853
  write("handover run");
12639
12854
  return 0;
@@ -12685,9 +12900,9 @@ function runHandoverList(params) {
12685
12900
  const { argv, cwd } = params;
12686
12901
  const workspace = findWorkspace(cwd);
12687
12902
  const commitPlan = workspace && join57(workspace, COMMIT_PLAN_FOLDER);
12688
- const root = resolve17(
12903
+ const root = resolve18(
12689
12904
  cwd,
12690
- getArg(argv, "root") ?? (commitPlan && existsSync51(commitPlan) ? commitPlan : cwd)
12905
+ getArg(argv, "root") ?? (commitPlan && existsSync52(commitPlan) ? commitPlan : cwd)
12691
12906
  );
12692
12907
  const listings = listHandovers({ root, now: params.now });
12693
12908
  if (hasFlag(argv, "json")) return { exitCode: 0, output: JSON.stringify(listings, null, 2) };
@@ -12727,15 +12942,15 @@ function refused(reasons) {
12727
12942
  }
12728
12943
 
12729
12944
  // src/commands/lot.ts
12730
- import { existsSync as existsSync53, mkdirSync as mkdirSync15, readFileSync as readFileSync39, writeFileSync as writeFileSync22 } from "fs";
12945
+ import { existsSync as existsSync54, mkdirSync as mkdirSync15, readFileSync as readFileSync39, writeFileSync as writeFileSync22 } from "fs";
12731
12946
  import { dirname as dirname26, join as join59 } from "path";
12732
12947
 
12733
12948
  // src/lib/package-root.ts
12734
- import { existsSync as existsSync52 } from "fs";
12949
+ import { existsSync as existsSync53 } from "fs";
12735
12950
  import { dirname as dirname25, join as join58 } from "path";
12736
12951
  function packageRootOf(cwd) {
12737
12952
  for (let folder = cwd; ; folder = dirname25(folder)) {
12738
- if (existsSync52(join58(folder, "package.json"))) return folder;
12953
+ if (existsSync53(join58(folder, "package.json"))) return folder;
12739
12954
  if (dirname25(folder) === folder) return void 0;
12740
12955
  }
12741
12956
  }
@@ -12770,7 +12985,7 @@ function runLot(params) {
12770
12985
  if (!root) return { exitCode: 1, output: `lot: no package.json at or above ${params.cwd}` };
12771
12986
  const path = join59(root, LOT_FILE);
12772
12987
  let read = {};
12773
- if (existsSync53(path))
12988
+ if (existsSync54(path))
12774
12989
  try {
12775
12990
  read = JSON.parse(readFileSync39(path, "utf8"));
12776
12991
  } catch (error) {
@@ -12997,13 +13212,13 @@ function runModels(params) {
12997
13212
  }
12998
13213
 
12999
13214
  // src/commands/mutants.ts
13000
- import { existsSync as existsSync58, mkdirSync as mkdirSync18, readFileSync as readFileSync42, rmSync as rmSync20, writeFileSync as writeFileSync24 } from "fs";
13215
+ import { existsSync as existsSync59, mkdirSync as mkdirSync18, readFileSync as readFileSync42, rmSync as rmSync21, writeFileSync as writeFileSync24 } from "fs";
13001
13216
  import { createRequire as createRequire5 } from "module";
13002
- import { dirname as dirname29, join as join64, resolve as resolve18 } from "path";
13217
+ import { dirname as dirname29, join as join64, resolve as resolve19 } from "path";
13003
13218
  import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL4 } from "url";
13004
13219
 
13005
13220
  // src/lib/mutation/cache-key.ts
13006
- import { existsSync as existsSync54 } from "fs";
13221
+ import { existsSync as existsSync55 } from "fs";
13007
13222
 
13008
13223
  // src/lib/mutation/incremental-cache.constants.ts
13009
13224
  var INCREMENTAL_FILE_NAME = "incremental.json";
@@ -13029,7 +13244,7 @@ function computeIncrementalKey(params) {
13029
13244
  ...readInstalledKey(root),
13030
13245
  options: withoutPerRunFields(options),
13031
13246
  cliVersion,
13032
- ignorer: existsSync54(ignorerPlugin) ? hashFile(ignorerPlugin) : MISSING_KEY_INPUT
13247
+ ignorer: existsSync55(ignorerPlugin) ? hashFile(ignorerPlugin) : MISSING_KEY_INPUT
13033
13248
  };
13034
13249
  return hashText(JSON.stringify(withSortedKeys(keyed)));
13035
13250
  }
@@ -13056,11 +13271,11 @@ function withSortedKeys(value) {
13056
13271
 
13057
13272
  // src/lib/mutation/incremental-cache.ts
13058
13273
  import {
13059
- existsSync as existsSync55,
13274
+ existsSync as existsSync56,
13060
13275
  mkdirSync as mkdirSync16,
13061
13276
  readdirSync as readdirSync15,
13062
13277
  readFileSync as readFileSync40,
13063
- rmSync as rmSync18,
13278
+ rmSync as rmSync19,
13064
13279
  statSync as statSync8,
13065
13280
  writeFileSync as writeFileSync23
13066
13281
  } from "fs";
@@ -13100,7 +13315,7 @@ function evictOldFiles(params) {
13100
13315
  (first, second) => first.modified !== second.modified ? second.modified - first.modified : first.name < second.name ? 1 : -1
13101
13316
  );
13102
13317
  for (const old of files.slice(INCREMENTAL_FILES_KEPT_PER_PACKAGE - 1))
13103
- rmSync18(old.path, { force: true });
13318
+ rmSync19(old.path, { force: true });
13104
13319
  }
13105
13320
  function modifiedTimeOf(path) {
13106
13321
  try {
@@ -13110,7 +13325,7 @@ function modifiedTimeOf(path) {
13110
13325
  }
13111
13326
  }
13112
13327
  function readParsableText(path) {
13113
- if (!existsSync55(path)) return void 0;
13328
+ if (!existsSync56(path)) return void 0;
13114
13329
  try {
13115
13330
  const text = readFileSync40(path, "utf8");
13116
13331
  JSON.parse(text);
@@ -13237,7 +13452,7 @@ function readArguments(params) {
13237
13452
  }
13238
13453
 
13239
13454
  // src/lib/mutation/drop-run.ts
13240
- import { existsSync as existsSync56, rmSync as rmSync19 } from "fs";
13455
+ import { existsSync as existsSync57, rmSync as rmSync20 } from "fs";
13241
13456
  import { join as join61 } from "path";
13242
13457
  function dropRun(params) {
13243
13458
  const { root, runId, isAlive, startTimeOf, afterDecision } = params;
@@ -13248,7 +13463,7 @@ function dropRun(params) {
13248
13463
  work: function dropUnderLock(state) {
13249
13464
  const runs = readRuns({ root, isAlive, startTimeOf });
13250
13465
  const run25 = isRunId(runId) ? runs.find((entry) => entry.runId === runId) : void 0;
13251
- if (run25 === void 0 || !existsSync56(path))
13466
+ if (run25 === void 0 || !existsSync57(path))
13252
13467
  return {
13253
13468
  ok: false,
13254
13469
  reason: `no mutation run ${runId} in ${join61(store, MUTATION_RUNS_FOLDER)}`
@@ -13274,7 +13489,7 @@ function dropRun(params) {
13274
13489
  )
13275
13490
  };
13276
13491
  afterDecision?.();
13277
- rmSync19(path);
13492
+ rmSync20(path);
13278
13493
  return { ok: true };
13279
13494
  }
13280
13495
  });
@@ -13335,7 +13550,7 @@ function dropVerb(params) {
13335
13550
  }
13336
13551
 
13337
13552
  // src/lib/mutation/judge-packet.ts
13338
- import { existsSync as existsSync57, readFileSync as readFileSync41 } from "fs";
13553
+ import { existsSync as existsSync58, readFileSync as readFileSync41 } from "fs";
13339
13554
  import { join as join62 } from "path";
13340
13555
 
13341
13556
  // node_modules/@babel/parser/lib/index.js
@@ -27766,7 +27981,7 @@ function judgePackets(params) {
27766
27981
  const path = join62(root, each);
27767
27982
  return packetOf({
27768
27983
  file: each,
27769
- source: existsSync57(path) ? readFileSync41(path, "utf8") : void 0,
27984
+ source: existsSync58(path) ? readFileSync41(path, "utf8") : void 0,
27770
27985
  survivors: (byFile.get(each) ?? []).map(
27771
27986
  (item) => inputOf({ item, survivor: reported.get(item.key) })
27772
27987
  )
@@ -28264,7 +28479,7 @@ run ${entry.runId} stays running until this process ends, then reads as died: re
28264
28479
  ...mutantKeysOf({ report: tiers.report })
28265
28480
  });
28266
28481
  updateLedger({ root, run: finished, records, targets });
28267
- rmSync20(join64(root, workDir), { recursive: true, force: true });
28482
+ rmSync21(join64(root, workDir), { recursive: true, force: true });
28268
28483
  return { exitCode: 0, output: renderRun({ root, run: finished }) };
28269
28484
  }
28270
28485
  async function runTiers(params) {
@@ -28277,7 +28492,7 @@ async function runTiers(params) {
28277
28492
  cliVersion: readCliVersion(),
28278
28493
  ignorerPlugin: ignorerPluginPath({ distFolder: cliDistFolder() })
28279
28494
  });
28280
- const incrementalFile = resolve18(root, fastOptions.incrementalFile);
28495
+ const incrementalFile = resolve19(root, fastOptions.incrementalFile);
28281
28496
  const packageHash = packageHashOf({ root });
28282
28497
  seedIncrementalFile({ root, packageHash, key, incrementalFile });
28283
28498
  const fast = await runTier({ ...params, tier: "fast", options: fastOptions });
@@ -28337,8 +28552,8 @@ async function runTier(params) {
28337
28552
  return { failure: `Stryker failed in the ${tier} tier: ${error.message}` };
28338
28553
  }
28339
28554
  if (exitCode !== 0) return { failure: `Stryker exited ${exitCode} in the ${tier} tier` };
28340
- const reportPath = resolve18(root, options.jsonReporter.fileName);
28341
- if (!existsSync58(reportPath))
28555
+ const reportPath = resolve19(root, options.jsonReporter.fileName);
28556
+ if (!existsSync59(reportPath))
28342
28557
  return { failure: `Stryker wrote no report in the ${tier} tier (${reportPath})` };
28343
28558
  return { report: JSON.parse(readFileSync42(reportPath, "utf8")) };
28344
28559
  }
@@ -28528,9 +28743,9 @@ function migrateVerb(params) {
28528
28743
  if (typeof read === "string" || read.words.length > 0)
28529
28744
  return usageResult({ verb: "migrate", json, read });
28530
28745
  const legacyPath = join64(root, LEGACY_RECORDS_PATH);
28531
- if (!existsSync58(legacyPath))
28746
+ if (!existsSync59(legacyPath))
28532
28747
  return refused2({ verb: "migrate", json, reason: `no ${LEGACY_RECORDS_PATH} in ${root}` });
28533
- if (existsSync58(join64(root, MUTATION_RECORDS_PATH)))
28748
+ if (existsSync59(join64(root, MUTATION_RECORDS_PATH)))
28534
28749
  return refused2({
28535
28750
  verb: "migrate",
28536
28751
  json,
@@ -28552,7 +28767,7 @@ function migrateVerb(params) {
28552
28767
  }
28553
28768
  function readLineOf(params) {
28554
28769
  const path = join64(params.root, params.file);
28555
- if (!existsSync58(path)) return "";
28770
+ if (!existsSync59(path)) return "";
28556
28771
  return readFileSync42(path, "utf8").split("\n")[params.line - 1] ?? "";
28557
28772
  }
28558
28773
  function usage2(read) {
@@ -28576,8 +28791,8 @@ async function runStrykerOfPackage(params) {
28576
28791
 
28577
28792
  // src/commands/narrowing.ts
28578
28793
  import { spawnSync as spawnSync16 } from "child_process";
28579
- import { writeFileSync as writeFileSync25, mkdirSync as mkdirSync19, rmSync as rmSync21, existsSync as existsSync59 } from "fs";
28580
- import { join as join65, resolve as resolve19 } from "path";
28794
+ import { writeFileSync as writeFileSync25, mkdirSync as mkdirSync19, rmSync as rmSync22, existsSync as existsSync60 } from "fs";
28795
+ import { join as join65, resolve as resolve20 } from "path";
28581
28796
  async function run13(argv) {
28582
28797
  const ROOT = process.cwd();
28583
28798
  const tsc = resolveBin("tsc", "typescript", ROOT);
@@ -28590,12 +28805,12 @@ async function run13(argv) {
28590
28805
  );
28591
28806
  let failed = false;
28592
28807
  for (const target of targets) {
28593
- const schema = await loadSchema(resolve19(ROOT, target.constantsDir));
28594
- mkdirSync19(resolve19(ROOT, target.outDir), { recursive: true });
28808
+ const schema = await loadSchema(resolve20(ROOT, target.constantsDir));
28809
+ mkdirSync19(resolve20(ROOT, target.outDir), { recursive: true });
28595
28810
  const relFile = `${target.outDir}/narrowing.generated.test-d.ts`;
28596
28811
  writeFileSync25(join65(ROOT, relFile), genNarrowing({ schema, binding: target.binding }));
28597
28812
  const apiFile = `${target.outDir}/coverage.api.generated.ts`;
28598
- const include = existsSync59(join65(ROOT, apiFile)) ? [relFile, apiFile] : [relFile];
28813
+ const include = existsSync60(join65(ROOT, apiFile)) ? [relFile, apiFile] : [relFile];
28599
28814
  const tmp = `.narrow-${target.version}.tsconfig.json`;
28600
28815
  writeFileSync25(
28601
28816
  join65(ROOT, tmp),
@@ -28617,7 +28832,7 @@ async function run13(argv) {
28617
28832
  encoding: "utf8",
28618
28833
  maxBuffer: 1e8
28619
28834
  });
28620
- rmSync21(join65(ROOT, tmp), { force: true });
28835
+ rmSync22(join65(ROOT, tmp), { force: true });
28621
28836
  if (res.status === 0) {
28622
28837
  console.log(
28623
28838
  `\u2705 [${target.version}] narrowing holds \u2014 ${schema.elements.length} elements asserted`
@@ -28652,7 +28867,7 @@ var KIND_SHAPES = {
28652
28867
  var OPTIONS_WITH_VALUE = ["--version", "--format-config"];
28653
28868
 
28654
28869
  // src/lib/scaffold/new-verb.ts
28655
- import { existsSync as existsSync60, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync26 } from "fs";
28870
+ import { existsSync as existsSync61, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync26 } from "fs";
28656
28871
  import { dirname as dirname30, join as join66 } from "path";
28657
28872
 
28658
28873
  // src/lib/scaffold/edit-module.ts
@@ -28801,20 +29016,20 @@ function scaffoldVerb(params) {
28801
29016
  [`${kindFolder}/${file}.types.ts`]: renderTypesFile(names),
28802
29017
  [`${kindFolder}/${file}.test.ts`]: renderTestFile(names)
28803
29018
  };
28804
- const existing = Object.keys(newFiles).filter((path) => existsSync60(join66(root, path)));
29019
+ const existing = Object.keys(newFiles).filter((path) => existsSync61(join66(root, path)));
28805
29020
  if (existing.length) return `already there: ${existing.join(", ")}`;
28806
29021
  const edits = {};
28807
29022
  const barrel = `${kindFolder}/index.ts`;
28808
29023
  const exportLine = `export { ${name} } from './${file}'
28809
29024
  `;
28810
- if (existsSync60(join66(root, barrel)))
29025
+ if (existsSync61(join66(root, barrel)))
28811
29026
  edits[barrel] = withLine({ text: readText({ root, path: barrel }), line: exportLine });
28812
29027
  else newFiles[barrel] = exportLine;
28813
29028
  const group = `${namespace}${KIND_SHAPES[kind].group}`;
28814
29029
  const groupImport = `import * as ${group} from './${kind}'`;
28815
29030
  const groupProperty = `${KIND_SHAPES[kind].moduleKey}: ${group}`;
28816
29031
  const namespaceModule = `${namespaceFolder}/index.ts`;
28817
- if (!existsSync60(join66(root, namespaceModule))) {
29032
+ if (!existsSync61(join66(root, namespaceModule))) {
28818
29033
  newFiles[namespaceModule] = `${groupImport}
28819
29034
 
28820
29035
  export const ${namespace} = {
@@ -28822,7 +29037,7 @@ export const ${namespace} = {
28822
29037
  }
28823
29038
  `;
28824
29039
  const registry = `${extensionsFolder}/index.ts`;
28825
- if (!existsSync60(join66(root, registry))) return `no extension registry at ${registry}`;
29040
+ if (!existsSync61(join66(root, registry))) return `no extension registry at ${registry}`;
28826
29041
  const registered = addObjectProperty({
28827
29042
  source: addImportLine({
28828
29043
  source: readText({ root, path: registry }),
@@ -28833,7 +29048,7 @@ export const ${namespace} = {
28833
29048
  });
28834
29049
  if (registered === void 0) return `no *_EXTENSION_MODULES object in ${registry}`;
28835
29050
  edits[registry] = registered;
28836
- } else if (!existsSync60(join66(root, barrel))) {
29051
+ } else if (!existsSync61(join66(root, barrel))) {
28837
29052
  const extended = addObjectProperty({
28838
29053
  source: addImportLine({
28839
29054
  source: readText({ root, path: namespaceModule }),
@@ -28869,7 +29084,7 @@ ${line}`;
28869
29084
  }
28870
29085
  function readRootElement(params) {
28871
29086
  const path = join66(params.root, "src", params.version, "definition", "constants.generated.ts");
28872
- if (!existsSync60(path)) return "FILL_ROOT_ELEMENT";
29087
+ if (!existsSync61(path)) return "FILL_ROOT_ELEMENT";
28873
29088
  return ROOT_ELEMENT_PATTERN.exec(readFileSync43(path, "utf8"))?.[1] ?? "FILL_ROOT_ELEMENT";
28874
29089
  }
28875
29090
  function readText(params) {
@@ -28940,16 +29155,16 @@ function usage3(message) {
28940
29155
  }
28941
29156
 
28942
29157
  // src/commands/recap.ts
28943
- import { resolve as resolve20 } from "path";
29158
+ import { resolve as resolve21 } from "path";
28944
29159
 
28945
29160
  // src/lib/recap/read-recap-records.ts
28946
- import { existsSync as existsSync63, realpathSync as realpathSync8 } from "fs";
29161
+ import { existsSync as existsSync64, realpathSync as realpathSync9 } from "fs";
28947
29162
  import { basename as basename8, dirname as dirname31, join as join68 } from "path";
28948
29163
 
28949
29164
  // src/lib/review-rounds/decisions-file.ts
28950
- import { existsSync as existsSync61, readFileSync as readFileSync44 } from "fs";
29165
+ import { existsSync as existsSync62, readFileSync as readFileSync44 } from "fs";
28951
29166
  function appendDecision(params) {
28952
- const lines = (existsSync61(params.path) ? readFileSync44(params.path, "utf8") : "").split("\n");
29167
+ const lines = (existsSync62(params.path) ? readFileSync44(params.path, "utf8") : "").split("\n");
28953
29168
  appendTableRow({
28954
29169
  path: params.path,
28955
29170
  lines,
@@ -28960,7 +29175,7 @@ function appendDecision(params) {
28960
29175
  });
28961
29176
  }
28962
29177
  function readDecisions(path) {
28963
- if (!existsSync61(path)) return [];
29178
+ if (!existsSync62(path)) return [];
28964
29179
  const lines = readFileSync44(path, "utf8").split("\n");
28965
29180
  const table = findTable({ lines, firstCell: DECISIONS_FIRST_CELL });
28966
29181
  return (table?.rowLines ?? []).map(function decisionOf(line) {
@@ -28975,7 +29190,7 @@ function dayOf(date) {
28975
29190
  }
28976
29191
 
28977
29192
  // src/lib/recap/read-findings.ts
28978
- import { existsSync as existsSync62, readFileSync as readFileSync45 } from "fs";
29193
+ import { existsSync as existsSync63, readFileSync as readFileSync45 } from "fs";
28979
29194
  import { relative as relative8 } from "path";
28980
29195
 
28981
29196
  // src/lib/recap/recap.constants.ts
@@ -29065,7 +29280,7 @@ var RECAP_SCHEDULED_ITEM = "- `{file}:{line}` {mutation}: scheduled for {followU
29065
29280
 
29066
29281
  // src/lib/recap/read-findings.ts
29067
29282
  function readFindings(params) {
29068
- if (!existsSync62(params.path)) return void 0;
29283
+ if (!existsSync63(params.path)) return void 0;
29069
29284
  const lines = readFileSync45(params.path, "utf8").split("\n");
29070
29285
  const table = findTable({ lines, firstCell: "id" });
29071
29286
  if (!table) return [];
@@ -29184,14 +29399,14 @@ function readRecapRecords(params) {
29184
29399
  const { handover } = params;
29185
29400
  const { folder, lotsFile } = handover;
29186
29401
  const root = lotsFile.repository;
29187
- const repositoryExists = existsSync63(root);
29402
+ const repositoryExists = existsSync64(root);
29188
29403
  const user = readGitConfig({ root: repositoryExists ? root : params.cwd, key: "user.name" });
29189
29404
  if (!user)
29190
29405
  return NO_USER_NAME.replace(
29191
29406
  "{where}",
29192
29407
  repositoryExists ? "the repository" : "the current folder"
29193
29408
  );
29194
- const declarationPath = existsSync63(join68(folder, FOLDER_LOT_FILE)) ? join68(folder, FOLDER_LOT_FILE) : join68(root, LOT_FILE);
29409
+ const declarationPath = existsSync64(join68(folder, FOLDER_LOT_FILE)) ? join68(folder, FOLDER_LOT_FILE) : join68(root, LOT_FILE);
29195
29410
  const accepted = readCases({ path: declarationPath, list: "accept" });
29196
29411
  if (typeof accepted === "string") return accepted;
29197
29412
  const revised = readCases({ path: declarationPath, list: "revised" });
@@ -29254,7 +29469,7 @@ function pathBasesOf(params) {
29254
29469
  };
29255
29470
  }
29256
29471
  function spellingsOf(folder) {
29257
- const real = existsSync63(folder) ? realpathSync8(folder) : folder;
29472
+ const real = existsSync64(folder) ? realpathSync9(folder) : folder;
29258
29473
  return real === folder ? [folder] : [folder, real];
29259
29474
  }
29260
29475
  function readChecks(params) {
@@ -29428,7 +29643,7 @@ function runRecap(params) {
29428
29643
  if (typeof read === "string") return { exitCode: 2, output: `${RECAP_USAGE} (${read})` };
29429
29644
  if (read.words.length !== 1) return { exitCode: 2, output: RECAP_USAGE };
29430
29645
  try {
29431
- const handover = readHandoverFolder(resolve20(params.cwd, read.words[0]));
29646
+ const handover = readHandoverFolder(resolve21(params.cwd, read.words[0]));
29432
29647
  if (typeof handover === "string") return { exitCode: 1, output: `recap: ${handover}` };
29433
29648
  const records = readRecapRecords({ handover, cwd: params.cwd });
29434
29649
  if (typeof records === "string") return { exitCode: 1, output: `recap: ${records}` };
@@ -29439,20 +29654,20 @@ function runRecap(params) {
29439
29654
  }
29440
29655
 
29441
29656
  // src/commands/record.ts
29442
- import { existsSync as existsSync65, mkdirSync as mkdirSync22, readFileSync as readFileSync46, writeFileSync as writeFileSync28 } from "fs";
29443
- import { basename as basename9, join as join70, resolve as resolve21 } from "path";
29657
+ import { existsSync as existsSync66, mkdirSync as mkdirSync22, readFileSync as readFileSync46, writeFileSync as writeFileSync28 } from "fs";
29658
+ import { basename as basename9, join as join70, resolve as resolve22 } from "path";
29444
29659
 
29445
29660
  // src/lib/review-rounds/snapshot-round.ts
29446
29661
  import {
29447
29662
  chmodSync as chmodSync2,
29448
- copyFileSync as copyFileSync3,
29449
- existsSync as existsSync64,
29663
+ copyFileSync as copyFileSync4,
29664
+ existsSync as existsSync65,
29450
29665
  lstatSync as lstatSync9,
29451
29666
  mkdirSync as mkdirSync21,
29452
29667
  readdirSync as readdirSync16,
29453
29668
  readlinkSync as readlinkSync4,
29454
29669
  renameSync as renameSync4,
29455
- rmSync as rmSync22,
29670
+ rmSync as rmSync23,
29456
29671
  symlinkSync as symlinkSync5,
29457
29672
  writeFileSync as writeFileSync27
29458
29673
  } from "fs";
@@ -29467,17 +29682,17 @@ function roundNames(round) {
29467
29682
  function copyFileOrLink(params) {
29468
29683
  mkdirSync21(dirname32(params.to), { recursive: true });
29469
29684
  const stats = lstatSync9(params.from);
29470
- if (isFileOrLink(params.to)) rmSync22(params.to);
29685
+ if (isFileOrLink(params.to)) rmSync23(params.to);
29471
29686
  if (stats.isSymbolicLink()) symlinkSync5(readlinkSync4(params.from), params.to);
29472
29687
  else {
29473
- copyFileSync3(params.from, params.to);
29688
+ copyFileSync4(params.from, params.to);
29474
29689
  chmodSync2(params.to, stats.mode & 4095);
29475
29690
  }
29476
29691
  }
29477
29692
  function snapshotRefusal(params) {
29478
29693
  const names = roundNames(params.round);
29479
29694
  const existing = [names.folder, names.deleted, names.base].find(
29480
- (name) => existsSync64(join69(params.folder, name))
29695
+ (name) => existsSync65(join69(params.folder, name))
29481
29696
  );
29482
29697
  if (existing)
29483
29698
  return `${join69(params.folder, existing)} exists already: round ${params.round} was taken`;
@@ -29512,7 +29727,7 @@ function removeLeftovers(params) {
29512
29727
  const names = Object.values(roundNames(params.round));
29513
29728
  for (const entry of readdirSync16(params.folder))
29514
29729
  if (names.some((name) => entry.startsWith(`${name}${PARTIAL_SUFFIX}`)))
29515
- rmSync22(join69(params.folder, entry), { recursive: true, force: true });
29730
+ rmSync23(join69(params.folder, entry), { recursive: true, force: true });
29516
29731
  }
29517
29732
  function renameAll(params) {
29518
29733
  const renamed = [];
@@ -29558,7 +29773,7 @@ function recordChoice(params) {
29558
29773
  exitCode: 2,
29559
29774
  output: `${RECORD_CHOICE_USAGE} (the decision and --by are one line each)`
29560
29775
  };
29561
- const folder = resolve21(params.cwd, folderWord);
29776
+ const folder = resolve22(params.cwd, folderWord);
29562
29777
  const refusal = handoverFolderRefusal(folder);
29563
29778
  if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
29564
29779
  mkdirSync22(folder, { recursive: true });
@@ -29588,7 +29803,7 @@ function recordReview(params) {
29588
29803
  exitCode: 2,
29589
29804
  output: `${RECORD_REVIEW_USAGE} (the finding and --at are one non-empty line each)`
29590
29805
  };
29591
- const folder = resolve21(params.cwd, words[0]);
29806
+ const folder = resolve22(params.cwd, words[0]);
29592
29807
  const refusal = handoverFolderRefusal(folder);
29593
29808
  if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
29594
29809
  mkdirSync22(folder, { recursive: true });
@@ -29604,11 +29819,11 @@ function recordDecision(params) {
29604
29819
  return { exitCode: 2, output: RECORD_DECISION_USAGE };
29605
29820
  const decision = parseDecision(stateWords);
29606
29821
  if (typeof decision === "string") return { exitCode: 2, output: `record decision: ${decision}` };
29607
- const folder = resolve21(params.cwd, folderWord);
29822
+ const folder = resolve22(params.cwd, folderWord);
29608
29823
  const refusal = handoverFolderRefusal(folder);
29609
29824
  if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
29610
29825
  const ledger = join70(folder, LEDGER_FILE);
29611
- if (!existsSync65(ledger))
29826
+ if (!existsSync66(ledger))
29612
29827
  return {
29613
29828
  exitCode: 1,
29614
29829
  output: `record: no findings ledger ${ledger}: record review writes the first finding`
@@ -29642,7 +29857,7 @@ function recordSnapshot(params) {
29642
29857
  exitCode: 1,
29643
29858
  output: `record: ${params.cwd} is in no git work tree: run record snapshot inside the lot's worktree`
29644
29859
  };
29645
- const folder = resolve21(params.cwd, read.words[0]);
29860
+ const folder = resolve22(params.cwd, read.words[0]);
29646
29861
  const folderRefusal = handoverFolderRefusal(folder);
29647
29862
  if (folderRefusal) return { exitCode: 1, output: `record: ${folderRefusal}` };
29648
29863
  const state = readWorktreeState(root);
@@ -29656,28 +29871,28 @@ function recordSnapshot(params) {
29656
29871
  }
29657
29872
 
29658
29873
  // src/commands/review.ts
29659
- import { resolve as resolve23 } from "path";
29874
+ import { resolve as resolve24 } from "path";
29660
29875
 
29661
29876
  // src/lib/review-rounds/review-delta.ts
29662
29877
  import { spawnSync as spawnSync18 } from "child_process";
29663
- import { existsSync as existsSync69, readFileSync as readFileSync50, statSync as statSync9 } from "fs";
29878
+ import { existsSync as existsSync70, readFileSync as readFileSync50, statSync as statSync9 } from "fs";
29664
29879
  import { join as join74 } from "path";
29665
29880
 
29666
29881
  // src/lib/worktree/add-worktree.ts
29667
29882
  import { spawnSync as spawnSync17 } from "child_process";
29668
- import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as existsSync68, mkdirSync as mkdirSync23, readFileSync as readFileSync49 } from "fs";
29883
+ import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as existsSync69, mkdirSync as mkdirSync23, readFileSync as readFileSync49 } from "fs";
29669
29884
  import { basename as basename10, dirname as dirname33, isAbsolute as isAbsolute10, join as join73 } from "path";
29670
29885
 
29671
29886
  // src/lib/worktree/check-node-modules.ts
29672
- import { existsSync as existsSync67, readFileSync as readFileSync48, realpathSync as realpathSync9 } from "fs";
29673
- import { join as join72, resolve as resolve22 } from "path";
29887
+ import { existsSync as existsSync68, readFileSync as readFileSync48, realpathSync as realpathSync10 } from "fs";
29888
+ import { join as join72, resolve as resolve23 } from "path";
29674
29889
 
29675
29890
  // src/lib/worktree/locked-packages.ts
29676
- import { existsSync as existsSync66, readFileSync as readFileSync47 } from "fs";
29891
+ import { existsSync as existsSync67, readFileSync as readFileSync47 } from "fs";
29677
29892
  import { join as join71 } from "path";
29678
29893
  function readLockedPackages(params) {
29679
29894
  const path = join71(params.worktree, PACKAGE_LOCK_FILE);
29680
- if (!existsSync66(path)) return { notChecked: "no lockfile" };
29895
+ if (!existsSync67(path)) return { notChecked: "no lockfile" };
29681
29896
  let lockfile;
29682
29897
  try {
29683
29898
  lockfile = JSON.parse(readFileSync47(path, "utf8"));
@@ -29722,12 +29937,12 @@ function problemOf(params) {
29722
29937
  const installed = join72(params.worktree, key);
29723
29938
  if (entry.link) {
29724
29939
  const resolved = entry.resolved ?? "";
29725
- const target = resolve22(params.worktree, resolved);
29726
- if (!existsSync67(installed) || !existsSync67(target)) return `link to ${resolved} missing`;
29727
- return realpathSync9(installed) === realpathSync9(target) ? void 0 : `link to ${resolved} points elsewhere`;
29940
+ const target = resolve23(params.worktree, resolved);
29941
+ if (!existsSync68(installed) || !existsSync68(target)) return `link to ${resolved} missing`;
29942
+ return realpathSync10(installed) === realpathSync10(target) ? void 0 : `link to ${resolved} points elsewhere`;
29728
29943
  }
29729
29944
  const manifest = join72(installed, "package.json");
29730
- if (!existsSync67(manifest)) return "missing";
29945
+ if (!existsSync68(manifest)) return "missing";
29731
29946
  let version;
29732
29947
  try {
29733
29948
  version = JSON.parse(readFileSync48(manifest, "utf8")).version;
@@ -29752,7 +29967,7 @@ function addWorktree(params) {
29752
29967
  WORKTREES_FOLDER,
29753
29968
  `${basename10(repository)}-${branch.split("/").at(-1)}`
29754
29969
  );
29755
- if (existsSync68(worktree)) return `${worktree} exists already`;
29970
+ if (existsSync69(worktree)) return `${worktree} exists already`;
29756
29971
  const branchExists = spawnSync17("git", ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`], {
29757
29972
  cwd: repository
29758
29973
  }).status === 0;
@@ -29765,16 +29980,16 @@ function addWorktree(params) {
29765
29980
  });
29766
29981
  const hooks = readHooksFolder(repository);
29767
29982
  let copiedHooks;
29768
- if (hooks.configured && !isAbsolute10(hooks.configured) && existsSync68(hooks.folder)) {
29983
+ if (hooks.configured && !isAbsolute10(hooks.configured) && existsSync69(hooks.folder)) {
29769
29984
  const target = join73(worktree, hooks.configured);
29770
- if (!existsSync68(target)) cpSync3(hooks.folder, target, { recursive: true });
29985
+ if (!existsSync69(target)) cpSync3(hooks.folder, target, { recursive: true });
29771
29986
  copiedHooks = hooks.configured;
29772
29987
  }
29773
29988
  excludeLotFolder(worktree);
29774
29989
  const siblingLinks = linkSiblings({ worktree, repository });
29775
29990
  const checkout = params.from ? checkoutOf({ repository, branch: params.from }) : void 0;
29776
- const nodeModules = [checkout, repository].filter((folder) => folder !== void 0).map((folder) => join73(folder, "node_modules")).find((folder) => existsSync68(folder)) ?? join73(repository, "node_modules");
29777
- const copy = existsSync68(nodeModules) ? copyNodeModules({ from: nodeModules, to: join73(worktree, "node_modules") }) : void 0;
29991
+ const nodeModules = [checkout, repository].filter((folder) => folder !== void 0).map((folder) => join73(folder, "node_modules")).find((folder) => existsSync69(folder)) ?? join73(repository, "node_modules");
29992
+ const copy = existsSync69(nodeModules) ? copyNodeModules({ from: nodeModules, to: join73(worktree, "node_modules") }) : void 0;
29778
29993
  const nodeModulesCheck = checkNodeModules({ worktree });
29779
29994
  const lockfileRead = readLockedPackages({ worktree });
29780
29995
  const lockedPackages = "packages" in lockfileRead ? lockfileRead.packages.length : 0;
@@ -29809,7 +30024,7 @@ function excludeLotFolder(worktree) {
29809
30024
  root: worktree,
29810
30025
  args: ["rev-parse", "--path-format=absolute", "--git-path", "info/exclude"]
29811
30026
  }).trim();
29812
- const text = existsSync68(exclude) ? readFileSync49(exclude, "utf8") : "";
30027
+ const text = existsSync69(exclude) ? readFileSync49(exclude, "utf8") : "";
29813
30028
  if (text.split("\n").includes(LOT_FOLDER_EXCLUDE)) return;
29814
30029
  mkdirSync23(dirname33(exclude), { recursive: true });
29815
30030
  appendFileSync2(exclude, `${text && !text.endsWith("\n") ? "\n" : ""}${LOT_FOLDER_EXCLUDE}
@@ -29820,12 +30035,12 @@ function excludeLotFolder(worktree) {
29820
30035
  function previousRoundRefusal(params) {
29821
30036
  const names = roundNames(params.previous);
29822
30037
  const snapshot = join74(params.folder, names.folder);
29823
- if (!existsSync69(snapshot) || !statSync9(snapshot).isDirectory())
30038
+ if (!existsSync70(snapshot) || !statSync9(snapshot).isDirectory())
29824
30039
  return `no snapshot ${snapshot}: record snapshot --round ${params.previous} takes it`;
29825
- if (!existsSync69(join74(params.folder, names.deleted)))
30040
+ if (!existsSync70(join74(params.folder, names.deleted)))
29826
30041
  return `no ${join74(params.folder, names.deleted)}: record snapshot --round ${params.previous} writes it`;
29827
30042
  const baseFile = join74(params.folder, names.base);
29828
- if (!existsSync69(baseFile)) return void 0;
30043
+ if (!existsSync70(baseFile)) return void 0;
29829
30044
  const base = readFileSync50(baseFile, "utf8").trim();
29830
30045
  const head = readGit({ root: params.root, args: ["rev-parse", "HEAD"] }).trim();
29831
30046
  return base === head ? void 0 : `HEAD moved since round-${params.previous} (base ${base}, HEAD ${head})`;
@@ -30015,7 +30230,7 @@ function reviewDelta(params) {
30015
30230
  exitCode: 1,
30016
30231
  output: `review delta: ${params.cwd} is in no git work tree: run it inside the lot's worktree`
30017
30232
  };
30018
- const folder = resolve23(params.cwd, words[0]);
30233
+ const folder = resolve24(params.cwd, words[0]);
30019
30234
  const folderRefusal = handoverFolderRefusal(folder);
30020
30235
  if (folderRefusal) return { exitCode: 1, output: `review delta: ${folderRefusal}` };
30021
30236
  const state = readWorktreeState(root);
@@ -30030,7 +30245,7 @@ function reviewDelta(params) {
30030
30245
  };
30031
30246
  const delta = {
30032
30247
  round,
30033
- previous: resolve23(folder, `round-${previous}`),
30248
+ previous: resolve24(folder, `round-${previous}`),
30034
30249
  root,
30035
30250
  files: computeDelta({ root, folder, previous, state })
30036
30251
  };
@@ -30046,8 +30261,8 @@ function reviewDelta(params) {
30046
30261
  }
30047
30262
 
30048
30263
  // src/commands/rules.ts
30049
- import { existsSync as existsSync70, readFileSync as readFileSync51, statSync as statSync10 } from "fs";
30050
- import { resolve as resolve24 } from "path";
30264
+ import { existsSync as existsSync71, readFileSync as readFileSync51, statSync as statSync10 } from "fs";
30265
+ import { resolve as resolve25 } from "path";
30051
30266
 
30052
30267
  // src/lib/rules/check-code-rules.constants.ts
30053
30268
  var CODE_VISITED_KINDS = [
@@ -30313,7 +30528,7 @@ function runRules(params) {
30313
30528
  }
30314
30529
  const referencePatterns = readReferencePatterns(cwd);
30315
30530
  const findings = files.flatMap(
30316
- (file) => checkCodeRules({ file, text: readFileSync51(resolve24(cwd, file), "utf8"), referencePatterns })
30531
+ (file) => checkCodeRules({ file, text: readFileSync51(resolve25(cwd, file), "utf8"), referencePatterns })
30317
30532
  );
30318
30533
  const errors = findings.filter((finding) => finding.severity === "error").length;
30319
30534
  const warnings = findings.length - errors;
@@ -30326,9 +30541,9 @@ function runRules(params) {
30326
30541
  }
30327
30542
  function expandFolder(params) {
30328
30543
  const { cwd, path } = params;
30329
- if (!statSync10(resolve24(cwd, path)).isDirectory()) return [path];
30544
+ if (!statSync10(resolve25(cwd, path)).isDirectory()) return [path];
30330
30545
  return listRepositoryFiles({ root: cwd, folder: path }).filter(
30331
- (file) => TEXT_FILE_PATTERN.test(file) && existsSync70(resolve24(cwd, file))
30546
+ (file) => TEXT_FILE_PATTERN.test(file) && existsSync71(resolve25(cwd, file))
30332
30547
  );
30333
30548
  }
30334
30549
  function renderFinding(finding) {
@@ -30337,7 +30552,7 @@ function renderFinding(finding) {
30337
30552
 
30338
30553
  // src/commands/run.ts
30339
30554
  import { readFileSync as readFileSync52, writeFileSync as writeFileSync29 } from "fs";
30340
- import { resolve as resolve25 } from "path";
30555
+ import { resolve as resolve26 } from "path";
30341
30556
  import { pathToFileURL as pathToFileURL5 } from "url";
30342
30557
  async function run19(argv) {
30343
30558
  const exitCode = await runCommand({
@@ -30364,7 +30579,7 @@ ${RUN_USAGE}`);
30364
30579
  let expectations;
30365
30580
  let environment;
30366
30581
  try {
30367
- expectations = options.expectPath ? readExpectations({ path: resolve25(cwd, options.expectPath) }) : void 0;
30582
+ expectations = options.expectPath ? readExpectations({ path: resolve26(cwd, options.expectPath) }) : void 0;
30368
30583
  environment = await loadRunEnvironment({
30369
30584
  projectDirectory: cwd,
30370
30585
  packageName: options.packageName
@@ -30373,13 +30588,13 @@ ${RUN_USAGE}`);
30373
30588
  output.stderr(thrown instanceof Error ? thrown.message : String(thrown));
30374
30589
  return EXIT_USAGE;
30375
30590
  }
30376
- const input = options.inputPath ? readInput({ path: resolve25(cwd, options.inputPath) }) : void 0;
30591
+ const input = options.inputPath ? readInput({ path: resolve26(cwd, options.inputPath) }) : void 0;
30377
30592
  const restoreConsole = sendScriptLogsTo({ output });
30378
30593
  let result;
30379
30594
  try {
30380
30595
  result = await runScript({
30381
30596
  // imported once ids are seeded: what the module does at its top level is repeatable too
30382
- loadScript: () => loadScript({ path: resolve25(cwd, options.scriptPath) }),
30597
+ loadScript: () => loadScript({ path: resolve26(cwd, options.scriptPath) }),
30383
30598
  environment,
30384
30599
  mode: options.prepare ? "prepare" : "commit",
30385
30600
  seed: options.seed,
@@ -30398,7 +30613,7 @@ ${RUN_USAGE}`);
30398
30613
  const { outcome, file } = result;
30399
30614
  if (file && options.outPath) {
30400
30615
  const bytes = await file.arrayBuffer();
30401
- writeFileSync29(resolve25(cwd, options.outPath), Buffer.from(bytes));
30616
+ writeFileSync29(resolve26(cwd, options.outPath), Buffer.from(bytes));
30402
30617
  }
30403
30618
  output.stdout(options.json ? JSON.stringify(outcome, null, 2) : formatRunOutcome({ outcome }));
30404
30619
  return outcome.ok ? EXIT_OK : EXIT_FAILED;
@@ -30624,11 +30839,11 @@ async function readSchemaDialectes(params) {
30624
30839
  }
30625
30840
 
30626
30841
  // src/commands/skills.ts
30627
- import { existsSync as existsSync79, readdirSync as readdirSync19, readFileSync as readFileSync60, writeFileSync as writeFileSync32 } from "fs";
30842
+ import { existsSync as existsSync80, readdirSync as readdirSync19, readFileSync as readFileSync60, writeFileSync as writeFileSync32 } from "fs";
30628
30843
  import { dirname as dirname36, join as join83, relative as relative9, sep as sep2 } from "path";
30629
30844
 
30630
30845
  // src/lib/api/api-json.ts
30631
- import { existsSync as existsSync72, readFileSync as readFileSync54 } from "fs";
30846
+ import { existsSync as existsSync73, readFileSync as readFileSync54 } from "fs";
30632
30847
  import { join as join76 } from "path";
30633
30848
 
30634
30849
  // src/lib/skills/api-index.ts
@@ -30736,13 +30951,13 @@ function tableCell(text) {
30736
30951
  }
30737
30952
 
30738
30953
  // src/lib/api/find-example.ts
30739
- import { existsSync as existsSync71, readFileSync as readFileSync53 } from "fs";
30954
+ import { existsSync as existsSync72, readFileSync as readFileSync53 } from "fs";
30740
30955
  import { join as join75 } from "path";
30741
30956
  import ts9 from "typescript";
30742
30957
  function findTestExample(params) {
30743
30958
  const { file, position } = splitDeclaredAt(params.declaredAt);
30744
30959
  const testFile = join75(params.root, file.replace(/\.ts$/, ".test.ts"));
30745
- if (!file.endsWith(".ts") || !existsSync71(testFile)) return void 0;
30960
+ if (!file.endsWith(".ts") || !existsSync72(testFile)) return void 0;
30746
30961
  const functionName = declaredName({ path: join75(params.root, file), position });
30747
30962
  if (!functionName) return void 0;
30748
30963
  const source = ts9.createSourceFile(
@@ -30772,7 +30987,7 @@ function splitDeclaredAt(declaredAt) {
30772
30987
  };
30773
30988
  }
30774
30989
  function declaredName(params) {
30775
- if (!existsSync71(params.path)) return void 0;
30990
+ if (!existsSync72(params.path)) return void 0;
30776
30991
  const source = ts9.createSourceFile(
30777
30992
  params.path,
30778
30993
  readFileSync53(params.path, "utf8"),
@@ -30858,7 +31073,7 @@ function rootOf(path) {
30858
31073
  function lineOf(params) {
30859
31074
  const { file, position } = splitDeclaredAt(params.declaredAt);
30860
31075
  const path = join76(params.root, file);
30861
- if (!existsSync72(path)) return file;
31076
+ if (!existsSync73(path)) return file;
30862
31077
  const line = readFileSync54(path, "utf8").slice(0, position).split("\n").length;
30863
31078
  return `${file}:${line}`;
30864
31079
  }
@@ -30893,7 +31108,7 @@ function prompt(params) {
30893
31108
  }
30894
31109
 
30895
31110
  // src/lib/models/resolve-sync-vendor.ts
30896
- import { existsSync as existsSync75, readdirSync as readdirSync17, readFileSync as readFileSync56, statSync as statSync11 } from "fs";
31111
+ import { existsSync as existsSync76, readdirSync as readdirSync17, readFileSync as readFileSync56, statSync as statSync11 } from "fs";
30897
31112
  import { basename as basename11, dirname as dirname35, join as join79 } from "path";
30898
31113
 
30899
31114
  // src/lib/stations/session-check.constants.ts
@@ -30910,15 +31125,15 @@ var SESSION_CHECK_COMMAND_PATTERN = /^npx(?: --no-install)? @dialecte\/cli docto
30910
31125
  var MAX_CUTS = 50;
30911
31126
 
30912
31127
  // src/lib/stations/session-check.ts
30913
- import { existsSync as existsSync74, mkdirSync as mkdirSync24, readFileSync as readFileSync55, unlinkSync as unlinkSync3, writeFileSync as writeFileSync30 } from "fs";
31128
+ import { existsSync as existsSync75, mkdirSync as mkdirSync24, readFileSync as readFileSync55, unlinkSync as unlinkSync3, writeFileSync as writeFileSync30 } from "fs";
30914
31129
  import { dirname as dirname34, join as join78 } from "path";
30915
31130
 
30916
31131
  // src/lib/stations/station-manifest.ts
30917
- import { existsSync as existsSync73 } from "fs";
31132
+ import { existsSync as existsSync74 } from "fs";
30918
31133
  import { join as join77 } from "path";
30919
31134
  function updateStationManifest(params) {
30920
31135
  const { folder, patch } = params;
30921
- if (!existsSync73(join77(folder, MANIFEST_FILE))) return;
31136
+ if (!existsSync74(join77(folder, MANIFEST_FILE))) return;
30922
31137
  const manifest = readSyncManifest(folder);
30923
31138
  const { stationAgents, sessionCheck, settingsCreated, sessionCheckInserted, ...rest } = manifest;
30924
31139
  writeSyncManifest({
@@ -30941,7 +31156,7 @@ function syncSessionCheck(params) {
30941
31156
  const recorded = readSyncManifest(manifestFolder).sessionCheck === true;
30942
31157
  const path = join78(cwd, CLAUDE_SETTINGS_FILE);
30943
31158
  if (!enabled && !recorded) return "unchanged";
30944
- const exists = existsSync74(path);
31159
+ const exists = existsSync75(path);
30945
31160
  if (!exists && !enabled) {
30946
31161
  updateStationManifest({
30947
31162
  folder: manifestFolder,
@@ -31199,7 +31414,7 @@ function presentPaths(cwd) {
31199
31414
  const candidates = VENDOR_HOSTS.flatMap((host) => host.anyOf.flat());
31200
31415
  return new Set(
31201
31416
  candidates.filter(
31202
- (path) => existsSync75(join79(cwd, path)) && !holdsOnlySyncedSkills({ cwd, path })
31417
+ (path) => existsSync76(join79(cwd, path)) && !holdsOnlySyncedSkills({ cwd, path })
31203
31418
  )
31204
31419
  );
31205
31420
  }
@@ -31233,7 +31448,7 @@ function readManifestOrNothing(folder) {
31233
31448
  }
31234
31449
  }
31235
31450
  function isSyncedSkillsFolder(folder) {
31236
- if (!existsSync75(join79(folder, MANIFEST_FILE))) return false;
31451
+ if (!existsSync76(join79(folder, MANIFEST_FILE))) return false;
31237
31452
  const { installed } = readSyncManifest(folder);
31238
31453
  return readdirSync17(folder).every((entry) => entry === MANIFEST_FILE || installed.includes(entry));
31239
31454
  }
@@ -31408,7 +31623,7 @@ function isSkillFileOrFolder(params) {
31408
31623
  }
31409
31624
 
31410
31625
  // src/lib/skills/export-entries.ts
31411
- import { existsSync as existsSync76, readFileSync as readFileSync57 } from "fs";
31626
+ import { existsSync as existsSync77, readFileSync as readFileSync57 } from "fs";
31412
31627
  import { join as join80 } from "path";
31413
31628
 
31414
31629
  // src/lib/skills/export-entries.constants.ts
@@ -31464,7 +31679,7 @@ function sourceOf(params) {
31464
31679
  `${withoutExtension}${sourceExtension}`,
31465
31680
  `${withoutExtension}/index${sourceExtension}`
31466
31681
  ]);
31467
- const source = candidates.find((candidate) => existsSync76(join80(params.root, candidate)));
31682
+ const source = candidates.find((candidate) => existsSync77(join80(params.root, candidate)));
31468
31683
  if (source === void 0)
31469
31684
  throw new Error(
31470
31685
  `exports entry "${params.subpath}": no source at ${candidates.join(" nor at ")}`
@@ -31579,7 +31794,7 @@ function findUnclosedGeneratedBlocks(markdown) {
31579
31794
 
31580
31795
  // src/lib/skills/package-facts.ts
31581
31796
  import { spawnSync as spawnSync19 } from "child_process";
31582
- import { existsSync as existsSync77, readdirSync as readdirSync18, readFileSync as readFileSync58 } from "fs";
31797
+ import { existsSync as existsSync78, readdirSync as readdirSync18, readFileSync as readFileSync58 } from "fs";
31583
31798
  import { join as join81 } from "path";
31584
31799
 
31585
31800
  // src/lib/skills/package-facts.constants.ts
@@ -31600,14 +31815,14 @@ function listRepositoryPaths(root) {
31600
31815
  return gitFiles ? withFolders(gitFiles) : walkRepositoryPaths(root);
31601
31816
  }
31602
31817
  function listGitFiles(root) {
31603
- if (!existsSync77(join81(root, ".git"))) return void 0;
31818
+ if (!existsSync78(join81(root, ".git"))) return void 0;
31604
31819
  const result = spawnSync19("git", ["ls-files", "--cached", "--others", "--exclude-standard"], {
31605
31820
  cwd: root,
31606
31821
  encoding: "utf8",
31607
31822
  maxBuffer: 1e8
31608
31823
  });
31609
31824
  if (result.status !== 0) return void 0;
31610
- return result.stdout.split("\n").filter(Boolean).filter((path) => existsSync77(join81(root, path)));
31825
+ return result.stdout.split("\n").filter(Boolean).filter((path) => existsSync78(join81(root, path)));
31611
31826
  }
31612
31827
  function withFolders(files) {
31613
31828
  const paths = /* @__PURE__ */ new Set();
@@ -31635,12 +31850,12 @@ function walkRepositoryPaths(root) {
31635
31850
  }
31636
31851
  function readNpmScripts(root) {
31637
31852
  const path = join81(root, "package.json");
31638
- if (!existsSync77(path)) return /* @__PURE__ */ new Set();
31853
+ if (!existsSync78(path)) return /* @__PURE__ */ new Set();
31639
31854
  return new Set(Object.keys(JSON.parse(readFileSync58(path, "utf8")).scripts ?? {}));
31640
31855
  }
31641
31856
  function readWorkspaceFacts(workspaceRoot) {
31642
31857
  const packageFolders = readdirSync18(workspaceRoot, { withFileTypes: true }).filter(
31643
- (entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync77(join81(workspaceRoot, entry.name, "package.json"))
31858
+ (entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync78(join81(workspaceRoot, entry.name, "package.json"))
31644
31859
  ).map((entry) => entry.name).sort();
31645
31860
  return {
31646
31861
  repositoryPaths: packageFolders.flatMap(
@@ -31655,7 +31870,7 @@ function listHookConcernFiles(root) {
31655
31870
  const concernFilesByFolder = {};
31656
31871
  for (const version of discoverVersions(root)) {
31657
31872
  const hooksFolder = join81(root, "src", version, "hooks");
31658
- if (!existsSync77(hooksFolder)) continue;
31873
+ if (!existsSync78(hooksFolder)) continue;
31659
31874
  for (const folder of readdirSync18(hooksFolder, { withFileTypes: true })) {
31660
31875
  if (!folder.isDirectory()) continue;
31661
31876
  const files = readdirSync18(join81(hooksFolder, folder.name)).filter(
@@ -31671,12 +31886,12 @@ function listHookConcernFiles(root) {
31671
31886
 
31672
31887
  // src/lib/stations/sync-station-agents.ts
31673
31888
  import {
31674
- existsSync as existsSync78,
31889
+ existsSync as existsSync79,
31675
31890
  lstatSync as lstatSync10,
31676
31891
  mkdirSync as mkdirSync25,
31677
31892
  readFileSync as readFileSync59,
31678
31893
  rmdirSync as rmdirSync2,
31679
- rmSync as rmSync23,
31894
+ rmSync as rmSync24,
31680
31895
  writeFileSync as writeFileSync31
31681
31896
  } from "fs";
31682
31897
  import { join as join82 } from "path";
@@ -31698,14 +31913,14 @@ function syncStationAgents(params) {
31698
31913
  const produced = new Set(files.map((file) => file.name));
31699
31914
  for (const name of previous.filter((candidate) => !produced.has(candidate))) {
31700
31915
  const path = join82(agentsFolder, name);
31701
- if (!existsSync78(path) || !lstatSync10(path).isFile()) continue;
31702
- rmSync23(path);
31916
+ if (!existsSync79(path) || !lstatSync10(path).isFile()) continue;
31917
+ rmSync24(path);
31703
31918
  report.removed.push(name);
31704
31919
  }
31705
31920
  if (report.removed.length > 0) removeFolderIfEmpty(agentsFolder);
31706
31921
  for (const file of files) {
31707
31922
  const path = join82(agentsFolder, file.name);
31708
- if (existsSync78(path)) {
31923
+ if (existsSync79(path)) {
31709
31924
  if (readFileSync59(path, "utf8") === file.content) {
31710
31925
  owned.push(file.name);
31711
31926
  continue;
@@ -31996,7 +32211,7 @@ function readPackageName(cwd) {
31996
32211
  return typeof manifest.name === "string" ? manifest.name : "";
31997
32212
  }
31998
32213
  function holdsSameJson(params) {
31999
- if (!existsSync79(params.path)) return false;
32214
+ if (!existsSync80(params.path)) return false;
32000
32215
  try {
32001
32216
  return JSON.stringify(JSON.parse(readFileSync60(params.path, "utf8"))) === JSON.stringify(JSON.parse(params.content));
32002
32217
  } catch {
@@ -32635,8 +32850,8 @@ function isSubcommand3(word) {
32635
32850
  }
32636
32851
 
32637
32852
  // src/commands/text.ts
32638
- import { existsSync as existsSync80, readFileSync as readFileSync61 } from "fs";
32639
- import { resolve as resolve26 } from "path";
32853
+ import { existsSync as existsSync81, readFileSync as readFileSync61 } from "fs";
32854
+ import { resolve as resolve27 } from "path";
32640
32855
 
32641
32856
  // src/lib/text-check/text-check.constants.ts
32642
32857
  var TEXT_USAGE = "text: check <file> [--kind pr|issue|comment|commit]";
@@ -32855,8 +33070,8 @@ function runText2(params) {
32855
33070
  return { exitCode: 2, output: `${TEXT_CHECK_USAGE} (unknown kind ${kind})` };
32856
33071
  if (read.words.length !== 1) return { exitCode: 2, output: TEXT_CHECK_USAGE };
32857
33072
  const [file] = read.words;
32858
- const path = resolve26(params.cwd, file);
32859
- if (!existsSync80(path)) return { exitCode: 1, output: `text check: no file ${path}` };
33073
+ const path = resolve27(params.cwd, file);
33074
+ if (!existsSync81(path)) return { exitCode: 1, output: `text check: no file ${path}` };
32860
33075
  return renderTextCheck({
32861
33076
  file,
32862
33077
  kind,
@@ -32869,8 +33084,8 @@ function isTextKind(kind) {
32869
33084
 
32870
33085
  // src/commands/worktree.ts
32871
33086
  import { spawnSync as spawnSync21 } from "child_process";
32872
- import { tmpdir as tmpdir6 } from "os";
32873
- import { dirname as dirname38, join as join86, relative as relative11, resolve as resolve27 } from "path";
33087
+ import { tmpdir as tmpdir7 } from "os";
33088
+ import { dirname as dirname38, join as join86, relative as relative11, resolve as resolve28 } from "path";
32874
33089
  import { createInterface as createInterface2 } from "readline/promises";
32875
33090
 
32876
33091
  // src/lib/card/render-card.ts
@@ -32923,7 +33138,7 @@ function wrapText2(params) {
32923
33138
 
32924
33139
  // src/lib/worktree/prune-worktrees.ts
32925
33140
  import { spawnSync as spawnSync20 } from "child_process";
32926
- import { existsSync as existsSync81, lstatSync as lstatSync11, readdirSync as readdirSync20, readFileSync as readFileSync62, realpathSync as realpathSync10, statSync as statSync12 } from "fs";
33141
+ import { existsSync as existsSync82, lstatSync as lstatSync11, readdirSync as readdirSync20, readFileSync as readFileSync62, realpathSync as realpathSync11, statSync as statSync12 } from "fs";
32927
33142
  import { basename as basename12, dirname as dirname37, isAbsolute as isAbsolute11, join as join85, relative as relative10, sep as sep3 } from "path";
32928
33143
  function planPrune(params) {
32929
33144
  const scratchRoots = [
@@ -32943,7 +33158,7 @@ function planPrune(params) {
32943
33158
  (entry) => planRepository({ repository: join85(params.workspace, entry.name), handovers, links })
32944
33159
  );
32945
33160
  const scratch = scratchRoots.flatMap(function rehearsalsIn(scratchRoot) {
32946
- if (!existsSync81(scratchRoot)) return [];
33161
+ if (!existsSync82(scratchRoot)) return [];
32947
33162
  return readdirSync20(scratchRoot).filter((name) => name.startsWith(REHEARSAL_FOLDER_PREFIX)).sort().map((name) => planRehearsalClone({ scratchRoot, name, links }));
32948
33163
  });
32949
33164
  return { repositories, scratch };
@@ -32960,7 +33175,7 @@ function planRepository(params) {
32960
33175
  const pendingWorktrees = new Set(
32961
33176
  mine.filter(
32962
33177
  (handover) => !["committed", "repository missing"].includes(handoverStateOf(handover))
32963
- ).map((handover) => realpathSync10(handover.lotsFile.repository))
33178
+ ).map((handover) => realpathSync11(handover.lotsFile.repository))
32964
33179
  );
32965
33180
  const pendingBranches = new Set(
32966
33181
  mine.filter((handover) => handoverStateOf(handover) !== "committed").map((handover) => handover.lotsFile.branch)
@@ -32972,13 +33187,13 @@ function planRepository(params) {
32972
33187
  }).trim();
32973
33188
  const keptBranches = /* @__PURE__ */ new Set([baseBranch, checkedOut]);
32974
33189
  const ownedRuns = readRuns({ root: repository }).filter(
32975
- (run25) => (run25.state === "running" || run25.state === "died") && existsSync81(run25.worktree)
33190
+ (run25) => (run25.state === "running" || run25.state === "died") && existsSync82(run25.worktree)
32976
33191
  );
32977
33192
  const worktrees = listWorktrees(repository).slice(1).map((worktree) => ({
32978
33193
  ...worktree,
32979
33194
  name: spellUnder({ path: worktree.path, folder: dirname37(repository) })
32980
33195
  }));
32981
- const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !existsSync81(join85(name, ".git")));
33196
+ const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !existsSync82(join85(name, ".git")));
32982
33197
  for (const worktree of worktrees) {
32983
33198
  const { name } = worktree;
32984
33199
  if (isLink2(name)) {
@@ -32990,19 +33205,19 @@ function planRepository(params) {
32990
33205
  items.push({ kind: "worktree", name, kept: "detached HEAD" });
32991
33206
  continue;
32992
33207
  }
32993
- const kept = existsSync81(name) ? whyKeepWorktree({
33208
+ const kept = existsSync82(name) ? whyKeepWorktree({
32994
33209
  repository,
32995
33210
  worktree: name,
32996
33211
  branch: worktree.branch,
32997
33212
  baseBranch,
32998
- pending: pendingWorktrees.has(realpathSync10(name)),
33213
+ pending: pendingWorktrees.has(realpathSync11(name)),
32999
33214
  links: params.links,
33000
33215
  ownedRuns
33001
33216
  }) : void 0;
33002
33217
  if (kept) {
33003
33218
  keptBranches.add(worktree.branch);
33004
33219
  items.push({ kind: "worktree", name, kept: `${worktree.branch}: ${kept}` });
33005
- } else if (!existsSync81(name) && linkedWorktrees.length > 0) {
33220
+ } else if (!existsSync82(name) && linkedWorktrees.length > 0) {
33006
33221
  keptBranches.add(worktree.branch);
33007
33222
  items.push({
33008
33223
  kind: "worktree",
@@ -33013,7 +33228,7 @@ function planRepository(params) {
33013
33228
  items.push({
33014
33229
  kind: "worktree",
33015
33230
  name,
33016
- command: existsSync81(name) ? `${cd} git worktree remove ${shellQuote(name)}` : `${cd} git worktree prune`
33231
+ command: existsSync82(name) ? `${cd} git worktree remove ${shellQuote(name)}` : `${cd} git worktree prune`
33017
33232
  });
33018
33233
  }
33019
33234
  for (const branch of readGit({
@@ -33063,18 +33278,18 @@ function planRepository(params) {
33063
33278
  return { repository, baseBranch, items };
33064
33279
  }
33065
33280
  function findLinks(folder) {
33066
- if (!existsSync81(folder)) return [];
33281
+ if (!existsSync82(folder)) return [];
33067
33282
  return readdirSync20(folder, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink()).flatMap(function reach(entry) {
33068
33283
  const link = join85(folder, entry.name);
33069
33284
  try {
33070
- return [{ link, target: realpathSync10(link) }];
33285
+ return [{ link, target: realpathSync11(link) }];
33071
33286
  } catch {
33072
33287
  return [];
33073
33288
  }
33074
33289
  });
33075
33290
  }
33076
33291
  function linkReaching(params) {
33077
- const real = realpathSync10(params.folder);
33292
+ const real = realpathSync11(params.folder);
33078
33293
  return params.links.find(function reaches(link) {
33079
33294
  const fromFolder = relative10(real, link.target);
33080
33295
  return fromFolder === "" || fromFolder !== ".." && !fromFolder.startsWith(`..${sep3}`) && !isAbsolute11(fromFolder);
@@ -33101,7 +33316,7 @@ function isRemovableHandoverFolder(folder) {
33101
33316
  }
33102
33317
  function isMainCheckout(folder) {
33103
33318
  const gitFolder = join85(folder, ".git");
33104
- return existsSync81(gitFolder) && statSync12(gitFolder).isDirectory() && existsSync81(join85(gitFolder, "HEAD"));
33319
+ return existsSync82(gitFolder) && statSync12(gitFolder).isDirectory() && existsSync82(join85(gitFolder, "HEAD"));
33105
33320
  }
33106
33321
  function planRehearsalClone(params) {
33107
33322
  const clone = join85(params.scratchRoot, params.name);
@@ -33130,9 +33345,9 @@ function planRehearsalClone(params) {
33130
33345
  }
33131
33346
  function rehearsalMarkerPath(entry) {
33132
33347
  const ownMarker = join85(entry, ".git", REHEARSAL_MARKER_FILE);
33133
- if (existsSync81(ownMarker) || !isDirectory(entry)) return ownMarker;
33348
+ if (existsSync82(ownMarker) || !isDirectory(entry)) return ownMarker;
33134
33349
  const inside = readdirSync20(entry, { withFileTypes: true }).filter((child) => child.isDirectory()).map((child) => join85(entry, child.name, ".git", REHEARSAL_MARKER_FILE));
33135
- return inside.find((path) => existsSync81(path)) ?? ownMarker;
33350
+ return inside.find((path) => existsSync82(path)) ?? ownMarker;
33136
33351
  }
33137
33352
  function isDirectory(path) {
33138
33353
  try {
@@ -33142,7 +33357,7 @@ function isDirectory(path) {
33142
33357
  }
33143
33358
  }
33144
33359
  function readRehearsalMarker(path) {
33145
- if (!existsSync81(path)) return void 0;
33360
+ if (!existsSync82(path)) return void 0;
33146
33361
  try {
33147
33362
  const marker = JSON.parse(readFileSync62(path, "utf8"));
33148
33363
  return typeof marker.pid === "number" ? { pid: marker.pid } : void 0;
@@ -33153,8 +33368,8 @@ function readRehearsalMarker(path) {
33153
33368
  function whyKeepWorktree(params) {
33154
33369
  const reachedBy = linkReaching({ folder: params.worktree, links: params.links });
33155
33370
  if (reachedBy) return `the link ${reachedBy} points to it`;
33156
- const worktree = realpathSync10(params.worktree);
33157
- const owned = params.ownedRuns.find((run25) => realpathSync10(run25.worktree) === worktree);
33371
+ const worktree = realpathSync11(params.worktree);
33372
+ const owned = params.ownedRuns.find((run25) => realpathSync11(run25.worktree) === worktree);
33158
33373
  if (owned)
33159
33374
  return `${PRUNE_RUN_PREFIX}${owned.state === "running" ? runningLine(owned) : diedRunLine(owned)}`;
33160
33375
  const unmerged = unmergedCount({
@@ -33163,7 +33378,7 @@ function whyKeepWorktree(params) {
33163
33378
  baseBranch: params.baseBranch
33164
33379
  });
33165
33380
  if (unmerged > 0) return `${unmerged} commit(s) not in ${params.baseBranch}`;
33166
- if (params.pending || existsSync81(handoverLockPath(params.worktree)))
33381
+ if (params.pending || existsSync82(handoverLockPath(params.worktree)))
33167
33382
  return "a hand-over is pending in it";
33168
33383
  if (readGit({
33169
33384
  root: params.worktree,
@@ -33235,11 +33450,11 @@ function listWorktrees(repository) {
33235
33450
  });
33236
33451
  }
33237
33452
  function spellUnder(params) {
33238
- const realFolder = realpathSync10(params.folder);
33453
+ const realFolder = realpathSync11(params.folder);
33239
33454
  return params.path.startsWith(`${realFolder}/`) ? join85(params.folder, params.path.slice(realFolder.length + 1)) : params.path;
33240
33455
  }
33241
33456
  function isSameRepository(params) {
33242
- if (!existsSync81(params.worktree)) return false;
33457
+ if (!existsSync82(params.worktree)) return false;
33243
33458
  const common = spawnSync20("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], {
33244
33459
  cwd: params.worktree,
33245
33460
  encoding: "utf8"
@@ -33252,7 +33467,7 @@ function isSameRepository(params) {
33252
33467
  return common.stdout.trim() === mainCommon;
33253
33468
  }
33254
33469
  function handoverStateOf(handover) {
33255
- return existsSync81(handover.lotsFile.repository) ? handoverState(handover) : "repository missing";
33470
+ return existsSync82(handover.lotsFile.repository) ? handoverState(handover) : "repository missing";
33256
33471
  }
33257
33472
  function refExists(params) {
33258
33473
  return spawnSync20("git", ["rev-parse", "--verify", "--quiet", params.ref], { cwd: params.root }).status === 0;
@@ -33271,9 +33486,9 @@ async function run24(argv) {
33271
33486
  cwd: process.cwd(),
33272
33487
  scratchRoot: rehearsalScratchRoot({
33273
33488
  platform: process.platform,
33274
- systemTemporaryFolder: tmpdir6()
33489
+ systemTemporaryFolder: tmpdir7()
33275
33490
  }),
33276
- formerScratchRoot: tmpdir6(),
33491
+ formerScratchRoot: tmpdir7(),
33277
33492
  isTerminal: Boolean(process.stdin.isTTY && process.stdout.isTTY),
33278
33493
  confirm: askOnTerminal
33279
33494
  }) : {
@@ -33289,7 +33504,7 @@ function runWorktreeAdd(params) {
33289
33504
  if (!repository || !branch)
33290
33505
  return { exitCode: 2, output: "worktree add: expected <repository> <branch> [--from <ref>]" };
33291
33506
  const added = addWorktree({
33292
- repository: resolve27(params.cwd, repository),
33507
+ repository: resolve28(params.cwd, repository),
33293
33508
  branch,
33294
33509
  from: getArg(argv, "from"),
33295
33510
  now: params.now
@@ -33300,7 +33515,7 @@ function runWorktreeAdd(params) {
33300
33515
  }
33301
33516
  async function runWorktreePrune(params) {
33302
33517
  const { argv } = params;
33303
- const workspace = resolve27(
33518
+ const workspace = resolve28(
33304
33519
  params.cwd,
33305
33520
  getArg(argv, "root") ?? findWorkspace(params.cwd) ?? params.cwd
33306
33521
  );
@@ -33477,7 +33692,7 @@ Commands:
33477
33692
  fixture The smallest valid XML document holding an element, built by the installed dialecte's engine
33478
33693
  explain What an error or diagnostic code means, when it is raised, the usual fix
33479
33694
  rules Code-rules self-check of the changed files (syntax tree, not greps)
33480
- gate The package's Definition of Done with the real counts: --fast (default) | --full
33695
+ gate The package's Definition of Done with the real counts: --fast (default) | --full | --hook
33481
33696
  tdd Receipts that each new test failed on an assertion before the code, then passed untouched
33482
33697
  new Scaffold in the house style: new verb <namespace> <query|transaction> <name>
33483
33698
  handover The guarded commit-by-lots hand-over a human runs, from a lots file: write | run | list
@@ -33553,6 +33768,9 @@ Contributing (inside a dialecte repository):
33553
33768
  # passing there it is ok and flagged flaky in parallel, failing there a real failure;
33554
33769
  # a green record of the same tree, install and steps (any worktree of the
33555
33770
  # repository) answers the steps after a fresh tdd step; --no-reuse runs them
33771
+ dialecte gate --hook [--no-reuse]
33772
+ # in a commit hook: the test steps of --full, unless a green --full record of the
33773
+ # committed tree (the index git hands the hook), install and steps answers them
33556
33774
  dialecte tdd red [<test file>]... [--json]
33557
33775
  # every case of the changed test files: a failure on an assertion (or a stub's
33558
33776
  # 'not implemented', a TypeError of existing code, inside an asserting expect) is a
@@ -33647,65 +33865,6 @@ Contributing (inside a dialecte repository):
33647
33865
  Env: RUNS=5 dialecte bench (repetitions for the min); COVERAGE_CHILD_CAP=N (cap edges)
33648
33866
  `;
33649
33867
 
33650
- // src/lib/git-environment.ts
33651
- import { existsSync as existsSync82, realpathSync as realpathSync11 } from "fs";
33652
- import { resolve as resolve28 } from "path";
33653
-
33654
- // src/lib/git-environment.constants.ts
33655
- var REPOSITORY_ENVIRONMENT_VARIABLES = [
33656
- // which repository and work tree: set by git for a hook, or by the user
33657
- "GIT_DIR",
33658
- "GIT_WORK_TREE",
33659
- "GIT_COMMON_DIR",
33660
- "GIT_IMPLICIT_WORK_TREE",
33661
- "GIT_PREFIX",
33662
- // which index: a pre-commit hook gets the commit's own index
33663
- "GIT_INDEX_FILE",
33664
- // where the objects are read and written
33665
- "GIT_OBJECT_DIRECTORY",
33666
- "GIT_ALTERNATE_OBJECT_DIRECTORIES",
33667
- // what the history looks like: shallow commits, grafts and replace refs
33668
- "GIT_SHALLOW_FILE",
33669
- "GIT_GRAFT_FILE",
33670
- "GIT_NO_REPLACE_OBJECTS",
33671
- "GIT_REPLACE_REF_BASE"
33672
- ];
33673
-
33674
- // src/lib/git-environment.ts
33675
- function clearRepositoryEnvironment(environment) {
33676
- const cleared = REPOSITORY_ENVIRONMENT_VARIABLES.filter((name) => environment[name] !== void 0);
33677
- for (const name of cleared) delete environment[name];
33678
- return cleared;
33679
- }
33680
- function namesAnotherRepository(params) {
33681
- const { given, folder } = params;
33682
- return namesAnotherFolder({ value: given.GIT_DIR, folder, question: "--absolute-git-dir" }) || namesAnotherFolder({ value: given.GIT_WORK_TREE, folder, question: "--show-toplevel" });
33683
- }
33684
- function namesAnotherFolder(params) {
33685
- const { value, folder, question } = params;
33686
- if (!value) return false;
33687
- const own = askGit({ folder, args: ["rev-parse", question] });
33688
- return own === void 0 || !isSamePath({ first: resolve28(folder, value), second: own });
33689
- }
33690
- function askGit(params) {
33691
- try {
33692
- return readGit({ root: params.folder, args: params.args }).trim();
33693
- } catch {
33694
- return void 0;
33695
- }
33696
- }
33697
- function isSamePath(params) {
33698
- const { first, second } = params;
33699
- if (!existsSync82(first) || !existsSync82(second)) return first === second;
33700
- return realpathSync11(first) === realpathSync11(second);
33701
- }
33702
- function ignoredRepositoryEnvironmentLine(cleared) {
33703
- return `dialecte: ${cleared.join(", ")} ignored: the cli acts on the folder it runs in`;
33704
- }
33705
-
33706
- // src/lib/given-environment.constants.ts
33707
- var GIVEN_ENVIRONMENT = Object.freeze({ ...process.env });
33708
-
33709
33868
  // src/lib/parse-invocation.ts
33710
33869
  function parseInvocation(params) {
33711
33870
  const [command, ...rest] = params.argv;