@kontextmind/kxm 0.7.150 → 0.7.152

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.
@@ -32,11 +32,31 @@ function escapeRegExp(value) {
32
32
  return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
33
33
  }
34
34
 
35
+ // Node's glob returns backslashes on Windows. Lane membership compares posix paths.
36
+ export function toPosixPath(file) {
37
+ return file.replaceAll("\\", "/");
38
+ }
39
+
40
+ export function normalizeUnitFiles(files) {
41
+ return files.map((file) => toPosixPath(file)).sort();
42
+ }
43
+
44
+ export function planUnitFiles(files) {
45
+ const normalized = normalizeUnitFiles(files);
46
+ if (!normalized.includes(ENGINE_FILE)) throw new Error(`${ENGINE_FILE} is missing`);
47
+ for (const file of SERIAL_FILES) {
48
+ if (!normalized.includes(file)) throw new Error(`${file} is missing`);
49
+ }
50
+ const reserved = new Set([ENGINE_FILE, ...SERIAL_FILES]);
51
+ const light = normalized.filter((file) => !reserved.has(file));
52
+ return { files: normalized, serial: [...SERIAL_FILES], light };
53
+ }
54
+
35
55
  export function listUnitFiles(root) {
36
- return [
56
+ return normalizeUnitFiles([
37
57
  ...globSync("test/core/*.test.ts", { cwd: root }),
38
58
  ...globSync("packages/core/*/tests/unit/*.test.ts", { cwd: root }),
39
- ].map((file) => file.replaceAll("\\", "/")).sort();
59
+ ]);
40
60
  }
41
61
 
42
62
  export function extractTestPatterns(source) {
@@ -96,19 +116,13 @@ export function planEngineShard(root, index, total = SHARD_TOTAL) {
96
116
  }
97
117
 
98
118
  export function planSerial(root) {
99
- const files = listUnitFiles(root);
100
- if (!files.includes(ENGINE_FILE)) throw new Error(`${ENGINE_FILE} is missing`);
101
- for (const file of SERIAL_FILES) {
102
- if (!files.includes(file)) throw new Error(`${file} is missing`);
103
- }
104
- return [...SERIAL_FILES];
119
+ return planUnitFiles(listUnitFiles(root)).serial;
105
120
  }
106
121
 
107
122
  export function planLight(root) {
108
- const serial = new Set(SERIAL_FILES);
109
- const files = listUnitFiles(root).filter((file) => file !== ENGINE_FILE && !serial.has(file));
110
- if (files.length === 0) throw new Error("light lane has no unit files");
111
- return files;
123
+ const { light } = planUnitFiles(listUnitFiles(root));
124
+ if (light.length === 0) throw new Error("light lane has no unit files");
125
+ return light;
112
126
  }
113
127
 
114
128
  export function coverageOfShards(root, total = SHARD_TOTAL) {
@@ -117,7 +131,9 @@ export function coverageOfShards(root, total = SHARD_TOTAL) {
117
131
  const plan = planEngineShard(root, index, total);
118
132
  for (const pattern of plan.patterns) heavy.set(pattern.source, (heavy.get(pattern.source) ?? 0) + 1);
119
133
  }
120
- return { files: listUnitFiles(root), serial: planSerial(root), light: planLight(root), heavy };
134
+ const lanes = planUnitFiles(listUnitFiles(root));
135
+ if (lanes.light.length === 0) throw new Error("light lane has no unit files");
136
+ return { files: lanes.files, serial: lanes.serial, light: lanes.light, heavy };
121
137
  }
122
138
 
123
139
  function runNode(args, label, children) {