@dialecte/cli 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -15
- package/dist/cli.js +1159 -782
- package/dist/lookups.js +291 -177
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -134,6 +134,8 @@ import { join as join2 } from "path";
|
|
|
134
134
|
var SKILLS_FOLDER = "skills";
|
|
135
135
|
var SKILL_NAME_PATTERN = /^(?=.{1,64}$)[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
136
136
|
var DESCRIPTION_MAX_LENGTH = 1024;
|
|
137
|
+
var SKILL_AUDIENCES = ["consumer", "contributor"];
|
|
138
|
+
var CONTRIBUTOR_AUDIENCE = "contributor";
|
|
137
139
|
var DIRECTIVE_PATTERN = /<!--\s*dialecte-skills\s+([\s\S]*?)-->/g;
|
|
138
140
|
var API_ROOTS = [
|
|
139
141
|
["doc.query.", "q"],
|
|
@@ -164,6 +166,7 @@ import {
|
|
|
164
166
|
readFileSync,
|
|
165
167
|
readlinkSync,
|
|
166
168
|
rmSync,
|
|
169
|
+
statSync,
|
|
167
170
|
symlinkSync,
|
|
168
171
|
unlinkSync,
|
|
169
172
|
writeFileSync
|
|
@@ -188,6 +191,112 @@ function realPathOf(path) {
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
|
|
194
|
+
// src/lib/skills/skill-file.ts
|
|
195
|
+
function readFrontmatter(markdown) {
|
|
196
|
+
const block = /^---\n([\s\S]*?)\n---/.exec(withUnixLineEndings(markdown))?.[1];
|
|
197
|
+
if (!block) return { name: void 0, description: void 0 };
|
|
198
|
+
return {
|
|
199
|
+
name: readField({ block, field: "name" }),
|
|
200
|
+
description: readField({ block, field: "description" }),
|
|
201
|
+
audience: readMetadataField({ block, field: "audience" })
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function readMetadataField(params) {
|
|
205
|
+
const lines = /^metadata:[ \t]*\n((?:[ \t]+.*\n?)*)/m.exec(`${params.block}
|
|
206
|
+
`)?.[1];
|
|
207
|
+
if (!lines) return void 0;
|
|
208
|
+
const indent = /^[ \t]+/.exec(lines)?.[0] ?? "";
|
|
209
|
+
const ownLines = lines.split("\n").filter((line) => line.startsWith(indent) && !/^[ \t]/.test(line.slice(indent.length))).map((line) => line.slice(indent.length));
|
|
210
|
+
return readField({ block: ownLines.join("\n"), field: params.field });
|
|
211
|
+
}
|
|
212
|
+
function readField(params) {
|
|
213
|
+
const match = new RegExp(`^${params.field}:[ \\t]*(.*)\\n?((?:[ \\t]+.*\\n?)*)`, "m").exec(
|
|
214
|
+
params.block
|
|
215
|
+
);
|
|
216
|
+
const line = match?.[1]?.trim();
|
|
217
|
+
if (line === void 0) return void 0;
|
|
218
|
+
const value = /^[>|][+-]?$/.test(line) ? (match?.[2] ?? "").split("\n").map((continuation) => continuation.trim()).filter(Boolean).join(" ") : line;
|
|
219
|
+
if (value === "") return void 0;
|
|
220
|
+
return value.replace(/^(['"])(.*)\1$/, "$2");
|
|
221
|
+
}
|
|
222
|
+
function withUnixLineEndings(text) {
|
|
223
|
+
return text.replace(/\r\n/g, "\n");
|
|
224
|
+
}
|
|
225
|
+
function validateFrontmatter(params) {
|
|
226
|
+
const { name, description, audience } = params.frontmatter;
|
|
227
|
+
const messages = [];
|
|
228
|
+
if (!name || !SKILL_NAME_PATTERN.test(name))
|
|
229
|
+
messages.push(
|
|
230
|
+
`name "${name ?? ""}" must be lowercase letters, digits and single hyphens (1-64)`
|
|
231
|
+
);
|
|
232
|
+
else if (name !== params.folderName)
|
|
233
|
+
messages.push(`name "${name}" must match its folder "${params.folderName}"`);
|
|
234
|
+
if (!description || description.length > DESCRIPTION_MAX_LENGTH)
|
|
235
|
+
messages.push(`description is required (1-${DESCRIPTION_MAX_LENGTH} characters)`);
|
|
236
|
+
if (audience !== void 0 && !SKILL_AUDIENCES.includes(audience))
|
|
237
|
+
messages.push(`metadata.audience "${audience}" must be ${SKILL_AUDIENCES.join(" or ")}`);
|
|
238
|
+
return messages;
|
|
239
|
+
}
|
|
240
|
+
function extractClaims(text) {
|
|
241
|
+
const markdown = withUnixLineEndings(text);
|
|
242
|
+
const prose = markdown.replace(ANY_FENCE_PATTERN, "");
|
|
243
|
+
const inlineCode = [...prose.matchAll(INLINE_CODE_PATTERN)].map((match) => match[1].trim());
|
|
244
|
+
const directives = readDirectives(prose.replace(INLINE_CODE_PATTERN, ""));
|
|
245
|
+
const codeCalls = [...markdown.matchAll(CODE_FENCE_PATTERN)].flatMap(
|
|
246
|
+
(fence) => [...fence[1].matchAll(CODE_CALL_PATTERN)].map((call) => call[1])
|
|
247
|
+
);
|
|
248
|
+
return {
|
|
249
|
+
apiPaths: unique([...inlineCode, ...codeCalls].map(normalizeApiPath)),
|
|
250
|
+
repositoryPaths: unique(inlineCode.map(toRepositoryPath)),
|
|
251
|
+
npmScripts: unique(inlineCode.map(readNpmScript)),
|
|
252
|
+
links: unique(
|
|
253
|
+
[...prose.matchAll(/\]\(([^)\s]+)\)/g)].map(
|
|
254
|
+
(match) => /^[a-z]+:|^#/.test(match[1]) ? void 0 : match[1].split("#")[0]
|
|
255
|
+
)
|
|
256
|
+
),
|
|
257
|
+
ignored: directives.ignored,
|
|
258
|
+
describesWorkspace: directives.describesWorkspace
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function readNpmScript(code2) {
|
|
262
|
+
const words = /^npm run (.+)$/.exec(code2)?.[1].split(/\s+/);
|
|
263
|
+
if (!words) return void 0;
|
|
264
|
+
let index = 0;
|
|
265
|
+
while (words[index]?.startsWith("-")) index += NPM_OPTIONS_WITH_VALUE.has(words[index]) ? 2 : 1;
|
|
266
|
+
const script = words[index];
|
|
267
|
+
return script !== void 0 && /^[\w:.-]+$/.test(script) ? script : void 0;
|
|
268
|
+
}
|
|
269
|
+
function readDirectives(markdown) {
|
|
270
|
+
const ignored = [];
|
|
271
|
+
let describesWorkspace = false;
|
|
272
|
+
for (const match of markdown.matchAll(DIRECTIVE_PATTERN)) {
|
|
273
|
+
const body = match[1].trim();
|
|
274
|
+
if (body === "workspace") describesWorkspace = true;
|
|
275
|
+
else if (body.startsWith("ignore:"))
|
|
276
|
+
ignored.push(...body.slice("ignore:".length).trim().split(/\s+/));
|
|
277
|
+
}
|
|
278
|
+
return { ignored, describesWorkspace };
|
|
279
|
+
}
|
|
280
|
+
function normalizeApiPath(code2) {
|
|
281
|
+
const expression = code2.split("(")[0];
|
|
282
|
+
if (!/^[\w.]+$/.test(expression) || expression === "doc.query") return void 0;
|
|
283
|
+
if (FILE_EXTENSION_PATTERN.test(expression)) return void 0;
|
|
284
|
+
for (const [prefix2, root] of API_ROOTS) {
|
|
285
|
+
if (!expression.startsWith(prefix2)) continue;
|
|
286
|
+
const member = expression.slice(prefix2.length);
|
|
287
|
+
return member ? `${root}.${member}` : void 0;
|
|
288
|
+
}
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
function toRepositoryPath(code2) {
|
|
292
|
+
if (!/^[\w.-]+(\/[\w.-]+)+\/?$/.test(code2)) return void 0;
|
|
293
|
+
if (/^(node_modules|https?:)/.test(code2) || code2.startsWith(".")) return void 0;
|
|
294
|
+
return code2.replace(/\/$/, "");
|
|
295
|
+
}
|
|
296
|
+
function unique(values) {
|
|
297
|
+
return [...new Set(values.filter((value) => Boolean(value)))];
|
|
298
|
+
}
|
|
299
|
+
|
|
191
300
|
// src/lib/skills/sync-skills.constants.ts
|
|
192
301
|
var MANIFEST_FILE = ".dialecte-skills.json";
|
|
193
302
|
var COPY_MARKER_FILE = ".dialecte-skill";
|
|
@@ -243,15 +352,32 @@ function skillsOf(params) {
|
|
|
243
352
|
const skillsFolder = join(params.folder, SKILLS_FOLDER);
|
|
244
353
|
if (!existsSync(skillsFolder)) return [];
|
|
245
354
|
const version = packageVersion(params.folder);
|
|
246
|
-
return readdirSync(skillsFolder, { withFileTypes: true }).filter(
|
|
247
|
-
(entry) => entry.isDirectory() && existsSync(join(skillsFolder, entry.name, "SKILL.md"))
|
|
248
|
-
).map((entry) => ({
|
|
355
|
+
return readdirSync(skillsFolder, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isFile(join(skillsFolder, entry.name, "SKILL.md"))).map((entry) => ({
|
|
249
356
|
name: entry.name,
|
|
250
357
|
path: join(skillsFolder, entry.name),
|
|
251
358
|
origin: params.origin,
|
|
252
|
-
...version === void 0 ? {} : { version }
|
|
359
|
+
...version === void 0 ? {} : { version },
|
|
360
|
+
audience: audienceOf(join(skillsFolder, entry.name, "SKILL.md"))
|
|
253
361
|
}));
|
|
254
362
|
}
|
|
363
|
+
function isFile(path) {
|
|
364
|
+
return existsSync(path) && statSync(path).isFile();
|
|
365
|
+
}
|
|
366
|
+
function audienceOf(skillFile) {
|
|
367
|
+
try {
|
|
368
|
+
const { audience } = readFrontmatter(readFileSync(skillFile, "utf8"));
|
|
369
|
+
return audience === CONTRIBUTOR_AUDIENCE ? "contributor" : "consumer";
|
|
370
|
+
} catch {
|
|
371
|
+
return "consumer";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function selectAudience(params) {
|
|
375
|
+
if (params.contributing) return { selected: [...params.sources], leftOut: [] };
|
|
376
|
+
return {
|
|
377
|
+
selected: params.sources.filter((source) => source.audience === "consumer"),
|
|
378
|
+
leftOut: params.sources.filter((source) => source.audience === "contributor")
|
|
379
|
+
};
|
|
380
|
+
}
|
|
255
381
|
function packageVersion(folder) {
|
|
256
382
|
const path = join(folder, "package.json");
|
|
257
383
|
if (!existsSync(path)) return void 0;
|
|
@@ -272,7 +398,7 @@ function syncSkills(params) {
|
|
|
272
398
|
const entry = join(targetFolder, name);
|
|
273
399
|
if (!isOwnedEntry({ path: entry, name, listedInManifest: true, sourcePath: void 0 }))
|
|
274
400
|
continue;
|
|
275
|
-
if (params.keepUnshipped) {
|
|
401
|
+
if (params.keepUnshipped && !params.leftOut?.includes(name)) {
|
|
276
402
|
installed.push(name);
|
|
277
403
|
if (previous.versions[name]) versions[name] = previous.versions[name];
|
|
278
404
|
continue;
|
|
@@ -308,6 +434,7 @@ function syncSkills(params) {
|
|
|
308
434
|
installed,
|
|
309
435
|
versions,
|
|
310
436
|
vendor: params.vendor ?? previous.vendor,
|
|
437
|
+
...params.contributing ? { contributing: true } : {},
|
|
311
438
|
stationAgents: previous.stationAgents,
|
|
312
439
|
sessionCheck: previous.sessionCheck,
|
|
313
440
|
settingsCreated: previous.settingsCreated,
|
|
@@ -363,6 +490,7 @@ function readSyncManifest(targetFolder) {
|
|
|
363
490
|
installed,
|
|
364
491
|
versions,
|
|
365
492
|
...typeof manifest.vendor === "string" ? { vendor: manifest.vendor } : {},
|
|
493
|
+
...manifest.contributing === true ? { contributing: true } : {},
|
|
366
494
|
...stationAgents ? { stationAgents } : {},
|
|
367
495
|
...manifest.sessionCheck === true ? { sessionCheck: true } : {},
|
|
368
496
|
...manifest.settingsCreated === true ? { settingsCreated: true } : {},
|
|
@@ -373,6 +501,7 @@ function writeSyncManifest(params) {
|
|
|
373
501
|
const {
|
|
374
502
|
versions,
|
|
375
503
|
vendor,
|
|
504
|
+
contributing,
|
|
376
505
|
stationAgents,
|
|
377
506
|
sessionCheck,
|
|
378
507
|
settingsCreated,
|
|
@@ -383,6 +512,7 @@ function writeSyncManifest(params) {
|
|
|
383
512
|
installed,
|
|
384
513
|
...versions && Object.keys(versions).length ? { versions } : {},
|
|
385
514
|
...vendor === void 0 ? {} : { vendor },
|
|
515
|
+
...contributing ? { contributing } : {},
|
|
386
516
|
...stationAgents?.length ? { stationAgents } : {},
|
|
387
517
|
...sessionCheck ? { sessionCheck } : {},
|
|
388
518
|
...settingsCreated ? { settingsCreated } : {},
|
|
@@ -509,7 +639,7 @@ function toJson(value) {
|
|
|
509
639
|
}
|
|
510
640
|
|
|
511
641
|
// src/lib/config.ts
|
|
512
|
-
import { readFileSync as readFileSync3, existsSync as existsSync3, readdirSync as readdirSync3, statSync } from "fs";
|
|
642
|
+
import { readFileSync as readFileSync3, existsSync as existsSync3, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
|
|
513
643
|
import { join as join3 } from "path";
|
|
514
644
|
var getArg = (argv, name) => {
|
|
515
645
|
const i = argv.indexOf(`--${name}`);
|
|
@@ -540,7 +670,7 @@ function discoverNamespace(cwd) {
|
|
|
540
670
|
function discoverVersions(cwd) {
|
|
541
671
|
const src = join3(cwd, "src");
|
|
542
672
|
if (!existsSync3(src)) return [];
|
|
543
|
-
return readdirSync3(src).filter((v) =>
|
|
673
|
+
return readdirSync3(src).filter((v) => statSync2(join3(src, v)).isDirectory()).filter(
|
|
544
674
|
(v) => existsSync3(join3(src, v, "definition", "constants.generated.ts")) && existsSync3(join3(src, v, "definition", "definition.generated.ts"))
|
|
545
675
|
).sort();
|
|
546
676
|
}
|
|
@@ -1917,7 +2047,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
|
|
|
1917
2047
|
import { join as join11 } from "path";
|
|
1918
2048
|
|
|
1919
2049
|
// src/lib/models/remembered-vendor.ts
|
|
1920
|
-
import { existsSync as existsSync8, statSync as
|
|
2050
|
+
import { existsSync as existsSync8, statSync as statSync3 } from "fs";
|
|
1921
2051
|
import { join as join10 } from "path";
|
|
1922
2052
|
|
|
1923
2053
|
// src/lib/models/model-tiers.constants.ts
|
|
@@ -1995,7 +2125,7 @@ function readRememberedVendor(cwd) {
|
|
|
1995
2125
|
entries.push({
|
|
1996
2126
|
folder,
|
|
1997
2127
|
vendor,
|
|
1998
|
-
writtenAt:
|
|
2128
|
+
writtenAt: statSync3(join10(cwd, folder, MANIFEST_FILE)).mtimeMs
|
|
1999
2129
|
});
|
|
2000
2130
|
}
|
|
2001
2131
|
entries.sort((first, second) => second.writtenAt - first.writtenAt);
|
|
@@ -2013,135 +2143,113 @@ var CLAUDE_MODEL_ALIASES = ["haiku", "sonnet", "opus", "fable"];
|
|
|
2013
2143
|
var READ_TOOLS = ["Read", "Glob", "Grep", "Skill"];
|
|
2014
2144
|
var REVIEW_TOOLS = ["Read", "Glob", "Grep", "Bash", "Skill"];
|
|
2015
2145
|
var EDIT_TOOLS = ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "Skill"];
|
|
2016
|
-
var
|
|
2146
|
+
var CLAUDE_TOOLS_BY_ACCESS = {
|
|
2147
|
+
read: READ_TOOLS,
|
|
2148
|
+
review: REVIEW_TOOLS,
|
|
2149
|
+
edit: EDIT_TOOLS
|
|
2150
|
+
};
|
|
2151
|
+
var LOAD_SKILLS_LINE = "Read that section first: it says which skills you load (`dialecte-lot`, `dialecte-contributing`, `dialecte`). The skills are the source of truth; this file only sets your envelope.";
|
|
2017
2152
|
var NEVER_LINE = "Never: commit, stage (`git add`), push, merge, `git stash`, `git reset`, `git restore`, `git checkout --`, `rm`; nothing outside the worktree your brief names. Your brief is your whole context.";
|
|
2018
2153
|
var GENERATED_NOTE = "Generated by `npx @dialecte/cli skills sync` from `dialecte models`; the next sync overwrites it.";
|
|
2019
2154
|
var STATIONS = [
|
|
2020
2155
|
{
|
|
2021
2156
|
name: "test-writer",
|
|
2022
2157
|
tier: "standard",
|
|
2023
|
-
|
|
2024
|
-
description: "Dialecte lot, test station of one brief step: writes the tests (and stubs) from the brief and the existing code, then proves them red with `dialecte tdd red`. Give it the brief step."
|
|
2025
|
-
role: [
|
|
2026
|
-
"You are the test station of a Dialecte lot (`dialecte-lot`): you write the tests of one brief step from the spec, never the production code.",
|
|
2027
|
-
"You may add stubs whose body throws `not implemented: <name>` so the tests compile; call them inside `expect(...)`.",
|
|
2028
|
-
"Run `dialecte tdd red` until every case is red on an assertion, and answer with its output."
|
|
2029
|
-
]
|
|
2158
|
+
access: "edit",
|
|
2159
|
+
description: "Dialecte lot, test station of one brief step: writes the tests (and stubs) from the brief and the existing code, then proves them red with `dialecte tdd red`. Give it the brief step."
|
|
2030
2160
|
},
|
|
2031
2161
|
{
|
|
2032
2162
|
name: "test-reviewer",
|
|
2033
2163
|
tier: "strong",
|
|
2034
|
-
|
|
2035
|
-
description: "Dialecte lot, test review before any code: reads only the tests against the brief (does each pin a behaviour, would a plausible wrong implementation fail it). Read-only."
|
|
2036
|
-
role: [
|
|
2037
|
-
"You are the test review of a Dialecte lot (`dialecte-lot`): you read the tests of the step against the brief, before any production code.",
|
|
2038
|
-
"You modify nothing (`dialecte tdd status` is the one command to run). Answer per test: the behaviour it pins, a plausible wrong implementation it lets through, a verdict."
|
|
2039
|
-
]
|
|
2164
|
+
access: "review",
|
|
2165
|
+
description: "Dialecte lot, test review before any code: reads only the tests against the brief (does each pin a behaviour, would a plausible wrong implementation fail it). Read-only."
|
|
2040
2166
|
},
|
|
2041
2167
|
{
|
|
2042
2168
|
name: "implementer",
|
|
2043
2169
|
tier: "standard",
|
|
2044
|
-
|
|
2045
|
-
description: "Dialecte lot, Station 1 (implement) on a mechanical or fully specified lot: production code only until `dialecte tdd green`, then the fast gate. Give it the brief."
|
|
2046
|
-
role: [
|
|
2047
|
-
"You are the implementer of a Dialecte lot: Station 1 of `dialecte-lot`, step mode.",
|
|
2048
|
-
"The tests are written and red: change production code only until `dialecte tdd green` passes; a test you find wrong goes back to the test station with the reason. Run the fast gate, and answer with the implement report shape of the skill."
|
|
2049
|
-
]
|
|
2170
|
+
access: "edit",
|
|
2171
|
+
description: "Dialecte lot, Station 1 (implement) on a mechanical or fully specified lot: production code only until `dialecte tdd green`, then the fast gate. Give it the brief."
|
|
2050
2172
|
},
|
|
2051
2173
|
{
|
|
2052
2174
|
name: "implementer-strong",
|
|
2053
2175
|
tier: "strong",
|
|
2054
|
-
|
|
2055
|
-
description: "Dialecte lot, Station 1 (implement) on a design-heavy lot: production code only until `dialecte tdd green`, then the fast gate. Give it the brief."
|
|
2056
|
-
role: [
|
|
2057
|
-
"You are the implementer of a design-heavy Dialecte lot: Station 1 of `dialecte-lot`, step mode.",
|
|
2058
|
-
"The tests are written and red: change production code only until `dialecte tdd green` passes; a test you find wrong goes back to the test station with the reason. Run the fast gate, and answer with the implement report shape of the skill."
|
|
2059
|
-
]
|
|
2176
|
+
access: "edit",
|
|
2177
|
+
description: "Dialecte lot, Station 1 (implement) on a design-heavy lot: production code only until `dialecte tdd green`, then the fast gate. Give it the brief."
|
|
2060
2178
|
},
|
|
2061
2179
|
{
|
|
2062
2180
|
name: "reviewer",
|
|
2063
2181
|
tier: "strong",
|
|
2064
|
-
|
|
2065
|
-
description: "Dialecte lot, Station 3 (independent review): pass 1 correctness, pass 2 fit, read-only. Give it the brief and the diff, not the implementer conclusions."
|
|
2066
|
-
role: [
|
|
2067
|
-
"You are the reviewer of a Dialecte lot: Station 3 of `dialecte-lot`, a different agent from the implementer.",
|
|
2068
|
-
"You modify nothing: you read the diff and run the tests. Answer with the review report shape of the skill (both passes, a verdict)."
|
|
2069
|
-
]
|
|
2182
|
+
access: "review",
|
|
2183
|
+
description: "Dialecte lot, Station 3 (independent review): pass 1 correctness, pass 2 fit, read-only. Give it the brief and the diff, not the implementer conclusions."
|
|
2070
2184
|
},
|
|
2071
2185
|
{
|
|
2072
2186
|
name: "fixer",
|
|
2073
2187
|
tier: "standard",
|
|
2074
|
-
|
|
2075
|
-
description: "Dialecte lot, Station 4 (fix mode) on wording and naming findings: fixed, disagreed or escalated per finding. Give it the findings."
|
|
2076
|
-
role: [
|
|
2077
|
-
"You are the implementer in fix mode: Station 4 of `dialecte-lot`.",
|
|
2078
|
-
"For each finding answer fixed, disagreed (one line why) or needs the user; never drop one."
|
|
2079
|
-
]
|
|
2188
|
+
access: "edit",
|
|
2189
|
+
description: "Dialecte lot, Station 4 (fix mode) on wording and naming findings: fixed, disagreed or escalated per finding. Give it the findings."
|
|
2080
2190
|
},
|
|
2081
2191
|
{
|
|
2082
2192
|
name: "eval-runner",
|
|
2083
2193
|
tier: "standard",
|
|
2084
|
-
|
|
2085
|
-
description: "Runs one skill-eval case of a Dialecte skill, with or without the skill, and leaves the outputs the graders read."
|
|
2086
|
-
role: [
|
|
2087
|
-
"You run one skill-eval case of `dialecte-lot` (a skill text change goes through skill-creator evals).",
|
|
2088
|
-
"Follow the case prompt exactly, with or without the skill as your brief says, and write only the outputs it names."
|
|
2089
|
-
]
|
|
2194
|
+
access: "edit",
|
|
2195
|
+
description: "Runs one skill-eval case of a Dialecte skill, with or without the skill, and leaves the outputs the graders read."
|
|
2090
2196
|
},
|
|
2091
2197
|
{
|
|
2092
2198
|
name: "grader",
|
|
2093
|
-
tier: "
|
|
2094
|
-
|
|
2095
|
-
description: "Grades the output of a skill-eval run against one grader file, pass or fail with the evidence. Read-only."
|
|
2096
|
-
role: [
|
|
2097
|
-
"You grade the output of a skill-eval run against the grader files your brief names.",
|
|
2098
|
-
"You read, never run or change anything: answer pass or fail per grader, with the line that shows it."
|
|
2099
|
-
]
|
|
2199
|
+
tier: "strong",
|
|
2200
|
+
access: "read",
|
|
2201
|
+
description: "Grades the output of a skill-eval run against one grader file, pass or fail with the evidence. Read-only."
|
|
2100
2202
|
},
|
|
2101
2203
|
{
|
|
2102
2204
|
name: "standard-reader",
|
|
2103
2205
|
tier: "standard",
|
|
2104
|
-
|
|
2105
|
-
description: "Independent reader of the IEC standard markdown for one question, with line references. Read-only."
|
|
2106
|
-
role: [
|
|
2107
|
-
'You read the standard for one question: "Reading the standard" of `dialecte-contributing`.',
|
|
2108
|
-
"You read the standard markdown only, answer with line references, and never rely on what another agent concluded."
|
|
2109
|
-
]
|
|
2206
|
+
access: "read",
|
|
2207
|
+
description: "Independent reader of the IEC standard markdown for one question, with line references. Read-only."
|
|
2110
2208
|
},
|
|
2111
2209
|
{
|
|
2112
2210
|
name: "searcher",
|
|
2113
2211
|
tier: "fast",
|
|
2114
|
-
|
|
2115
|
-
description: "Finds where something lives in a Dialecte repository (files, symbols, API paths) and answers with paths and line numbers. Read-only."
|
|
2116
|
-
role: [
|
|
2117
|
-
"You locate code, files or documentation for the question your brief asks, in the Dialecte repositories it names.",
|
|
2118
|
-
"You read, never change anything: answer with absolute paths and line numbers, nothing speculative."
|
|
2119
|
-
]
|
|
2212
|
+
access: "read",
|
|
2213
|
+
description: "Finds where something lives in a Dialecte repository (files, symbols, API paths) and answers with paths and line numbers. Read-only."
|
|
2120
2214
|
}
|
|
2121
2215
|
];
|
|
2122
2216
|
var STATION_AGENT_FILE_PATTERN = /^dialecte-[a-z]+(-[a-z]+)*\.md$/;
|
|
2123
2217
|
var LOT_SKILL = "dialecte-lot";
|
|
2218
|
+
var STATIONS_PAGE_PATH = `${AGENT_SKILL_FOLDERS.claude}/${LOT_SKILL}/references/stations.md`;
|
|
2219
|
+
var BRIEF_DEFINED_STATIONS = ["eval-runner", "grader"];
|
|
2124
2220
|
|
|
2125
2221
|
// src/lib/stations/render-station-agent.ts
|
|
2126
2222
|
function claudeModelAlias(modelName) {
|
|
2127
2223
|
const alias = modelName.split(" ")[0].toLowerCase();
|
|
2128
2224
|
return CLAUDE_MODEL_ALIASES.includes(alias) ? alias : void 0;
|
|
2129
2225
|
}
|
|
2226
|
+
function stationLines(params) {
|
|
2227
|
+
const { station } = params;
|
|
2228
|
+
const play = `You play the \`${station.name}\` station of \`${LOT_SKILL}\`:`;
|
|
2229
|
+
if (BRIEF_DEFINED_STATIONS.includes(station.name))
|
|
2230
|
+
return [
|
|
2231
|
+
`${play} your brief carries your definition and names the only skill text you read; read no other.`,
|
|
2232
|
+
""
|
|
2233
|
+
];
|
|
2234
|
+
return [
|
|
2235
|
+
`${play} its definition is ${STATIONS_PAGE_PATH}, section \`${station.name}\`.`,
|
|
2236
|
+
"",
|
|
2237
|
+
LOAD_SKILLS_LINE,
|
|
2238
|
+
""
|
|
2239
|
+
];
|
|
2240
|
+
}
|
|
2130
2241
|
function renderStationAgent(params) {
|
|
2131
2242
|
const { station, model } = params;
|
|
2132
2243
|
return [
|
|
2133
2244
|
"---",
|
|
2134
2245
|
`name: ${STATION_AGENT_PREFIX}${station.name}`,
|
|
2135
2246
|
`description: ${JSON.stringify(station.description)}`,
|
|
2136
|
-
`tools: ${station.
|
|
2247
|
+
`tools: ${CLAUDE_TOOLS_BY_ACCESS[station.access].join(", ")}`,
|
|
2137
2248
|
`model: ${model}`,
|
|
2138
2249
|
"---",
|
|
2139
2250
|
`<!-- ${GENERATED_NOTE} -->`,
|
|
2140
2251
|
"",
|
|
2141
|
-
...station
|
|
2142
|
-
"",
|
|
2143
|
-
LOAD_SKILLS_LINE,
|
|
2144
|
-
"",
|
|
2252
|
+
...stationLines({ station }),
|
|
2145
2253
|
NEVER_LINE,
|
|
2146
2254
|
""
|
|
2147
2255
|
].join("\n");
|
|
@@ -2283,7 +2391,11 @@ function skills(cwd) {
|
|
|
2283
2391
|
];
|
|
2284
2392
|
return synced.map(function syncLine(folder) {
|
|
2285
2393
|
const manifest = readSyncManifest(join12(cwd, folder));
|
|
2286
|
-
const
|
|
2394
|
+
const expected = selectAudience({
|
|
2395
|
+
sources,
|
|
2396
|
+
contributing: manifest.contributing === true
|
|
2397
|
+
}).selected;
|
|
2398
|
+
const missing = expected.map((source) => source.name).filter((name) => !manifest.installed.includes(name));
|
|
2287
2399
|
if (missing.length)
|
|
2288
2400
|
return {
|
|
2289
2401
|
status: "warning",
|
|
@@ -2291,7 +2403,7 @@ function skills(cwd) {
|
|
|
2291
2403
|
detail: `${folder} lacks ${missing.join(", ")}`,
|
|
2292
2404
|
fix: SYNC_COMMAND
|
|
2293
2405
|
};
|
|
2294
|
-
const stale =
|
|
2406
|
+
const stale = expected.flatMap(function staleCopy(source) {
|
|
2295
2407
|
const recorded = manifest.versions[source.name];
|
|
2296
2408
|
if (isLink(join12(cwd, folder, source.name)) || source.version === void 0) return [];
|
|
2297
2409
|
if (recorded?.version === source.version) return [];
|
|
@@ -3463,7 +3575,7 @@ function fillKeyFields(params) {
|
|
|
3463
3575
|
let changed = false;
|
|
3464
3576
|
for (const keyed of selectNodes({ scope, paths: constraint.selector })) {
|
|
3465
3577
|
for (const field of fields) {
|
|
3466
|
-
if (
|
|
3578
|
+
if (readField2({ node: keyed, field }) !== void 0) continue;
|
|
3467
3579
|
if ("text" in field)
|
|
3468
3580
|
return { problem: `key ${constraint.name}: ${keyed.tagName} has no text to key on` };
|
|
3469
3581
|
const offered = attributeValues({
|
|
@@ -3496,12 +3608,12 @@ function pointReferences(params) {
|
|
|
3496
3608
|
if ("problem" in keyFields) return keyFields;
|
|
3497
3609
|
let changed = false;
|
|
3498
3610
|
for (const referring of selectNodes({ scope, paths: constraint.selector })) {
|
|
3499
|
-
const values = fields.map((field) =>
|
|
3611
|
+
const values = fields.map((field) => readField2({ node: referring, field }));
|
|
3500
3612
|
if (values.some((value) => value === void 0)) continue;
|
|
3501
3613
|
const targets = selectNodes({ scope, paths: key.selector });
|
|
3502
3614
|
const isPointed = targets.some(
|
|
3503
3615
|
(target) => keyFields.readers.every(
|
|
3504
|
-
(field, index) =>
|
|
3616
|
+
(field, index) => readField2({ node: target, field }) === values[index]
|
|
3505
3617
|
)
|
|
3506
3618
|
);
|
|
3507
3619
|
if (isPointed) continue;
|
|
@@ -3585,7 +3697,7 @@ function repeatsIdentity(params) {
|
|
|
3585
3697
|
const { root, node, attribute, value } = params;
|
|
3586
3698
|
function entryOf(params2) {
|
|
3587
3699
|
return params2.fields.map(
|
|
3588
|
-
(field) => params2.of === node && "attribute" in field && field.attribute === attribute ? value :
|
|
3700
|
+
(field) => params2.of === node && "attribute" in field && field.attribute === attribute ? value : readField2({ node: params2.of, field })
|
|
3589
3701
|
);
|
|
3590
3702
|
}
|
|
3591
3703
|
for (const scope of descendantsAndSelf({ node: root }))
|
|
@@ -3713,7 +3825,7 @@ function fieldReaders(params) {
|
|
|
3713
3825
|
}
|
|
3714
3826
|
return { readers };
|
|
3715
3827
|
}
|
|
3716
|
-
function
|
|
3828
|
+
function readField2(params) {
|
|
3717
3829
|
const { node, field } = params;
|
|
3718
3830
|
return "text" in field ? node.text : node.attributes.get(field.attribute);
|
|
3719
3831
|
}
|
|
@@ -4411,7 +4523,7 @@ function parseFixtureOptions(params) {
|
|
|
4411
4523
|
}
|
|
4412
4524
|
|
|
4413
4525
|
// src/commands/gate.ts
|
|
4414
|
-
import { join as
|
|
4526
|
+
import { join as join35 } from "path";
|
|
4415
4527
|
|
|
4416
4528
|
// src/lib/gate-records/check-key.ts
|
|
4417
4529
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -4429,7 +4541,7 @@ import { tmpdir as tmpdir2 } from "os";
|
|
|
4429
4541
|
import { basename as basename2, join as join22, relative as relative3, resolve as resolve7 } from "path";
|
|
4430
4542
|
|
|
4431
4543
|
// src/lib/git-hooks.ts
|
|
4432
|
-
import { existsSync as existsSync14, statSync as
|
|
4544
|
+
import { existsSync as existsSync14, statSync as statSync4 } from "fs";
|
|
4433
4545
|
import { dirname as dirname9, isAbsolute as isAbsolute2, join as join18 } from "path";
|
|
4434
4546
|
|
|
4435
4547
|
// src/lib/git-hooks.constants.ts
|
|
@@ -4575,20 +4687,20 @@ function hasCommitHook(root) {
|
|
|
4575
4687
|
}
|
|
4576
4688
|
function listCommitHookFiles(root) {
|
|
4577
4689
|
const { folder } = readHooksFolder(root);
|
|
4578
|
-
const husky =
|
|
4690
|
+
const husky = isFile2(join18(folder, HUSKY_RUNNER_FILE));
|
|
4579
4691
|
return COMMIT_HOOK_NAMES.flatMap(function hookFileOf(name) {
|
|
4580
|
-
if (husky) return
|
|
4692
|
+
if (husky) return isFile2(join18(dirname9(folder), name)) ? [join18(dirname9(folder), name)] : [];
|
|
4581
4693
|
try {
|
|
4582
|
-
const status =
|
|
4694
|
+
const status = statSync4(join18(folder, name));
|
|
4583
4695
|
return status.isFile() && (status.mode & 73) !== 0 ? [join18(folder, name)] : [];
|
|
4584
4696
|
} catch {
|
|
4585
4697
|
return [];
|
|
4586
4698
|
}
|
|
4587
4699
|
});
|
|
4588
4700
|
}
|
|
4589
|
-
function
|
|
4701
|
+
function isFile2(path) {
|
|
4590
4702
|
try {
|
|
4591
|
-
return
|
|
4703
|
+
return statSync4(path).isFile();
|
|
4592
4704
|
} catch {
|
|
4593
4705
|
return false;
|
|
4594
4706
|
}
|
|
@@ -4604,7 +4716,7 @@ function readPackageJson(root) {
|
|
|
4604
4716
|
|
|
4605
4717
|
// src/lib/review-rounds/worktree-state.ts
|
|
4606
4718
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
4607
|
-
import { existsSync as existsSync16, lstatSync as lstatSync4, readdirSync as readdirSync6, statSync as
|
|
4719
|
+
import { existsSync as existsSync16, lstatSync as lstatSync4, readdirSync as readdirSync6, statSync as statSync5 } from "fs";
|
|
4608
4720
|
import { dirname as dirname10, join as join20 } from "path";
|
|
4609
4721
|
|
|
4610
4722
|
// src/lib/review-rounds/review-rounds.constants.ts
|
|
@@ -4659,7 +4771,7 @@ function workTreeTopOf(folder) {
|
|
|
4659
4771
|
function handoverFolderRefusal(folder) {
|
|
4660
4772
|
let existing = folder;
|
|
4661
4773
|
while (!existsSync16(existing) && dirname10(existing) !== existing) existing = dirname10(existing);
|
|
4662
|
-
const lookFrom =
|
|
4774
|
+
const lookFrom = statSync5(existing).isDirectory() ? existing : dirname10(existing);
|
|
4663
4775
|
const gitFolder = gitFolderHolding(lookFrom);
|
|
4664
4776
|
if (gitFolder)
|
|
4665
4777
|
return `${folder} is inside the git folder ${gitFolder}: a hand-over folder stays outside every repository`;
|
|
@@ -5322,6 +5434,9 @@ var MESSAGE_LINES = 6;
|
|
|
5322
5434
|
var PROVES_NOTHING = "it ran green: this test proves nothing yet";
|
|
5323
5435
|
var FROZEN_AFTER_RED = "tests are frozen after red; go back to the test station";
|
|
5324
5436
|
var VITEST_COMMAND = ["npx", "--no-install", "vitest", "run"];
|
|
5437
|
+
var VITEST_BIN_PATH = ["node_modules", ".bin", "vitest"];
|
|
5438
|
+
var VITEST_RUN_ARGUMENT = "run";
|
|
5439
|
+
var REPOSITORY_MARKER = ".git";
|
|
5325
5440
|
var RUN_OUTPUT_TAIL_LINES = 20;
|
|
5326
5441
|
var NO_RED_RECEIPT = "no red receipt: the test station runs tdd red first";
|
|
5327
5442
|
var TDD_SUBCOMMANDS = ["red", "green", "status"];
|
|
@@ -7384,8 +7499,8 @@ function unknownKeyOf(params) {
|
|
|
7384
7499
|
}
|
|
7385
7500
|
|
|
7386
7501
|
// src/lib/tdd/tdd-state.ts
|
|
7387
|
-
import { existsSync as
|
|
7388
|
-
import { join as
|
|
7502
|
+
import { existsSync as existsSync32 } from "fs";
|
|
7503
|
+
import { join as join34 } from "path";
|
|
7389
7504
|
|
|
7390
7505
|
// src/lib/tdd/case-status.ts
|
|
7391
7506
|
function caseStatusOf(params) {
|
|
@@ -7455,7 +7570,7 @@ function lastIndexOf(params) {
|
|
|
7455
7570
|
}
|
|
7456
7571
|
|
|
7457
7572
|
// src/lib/tdd/module-resolver.ts
|
|
7458
|
-
import { existsSync as existsSync28, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as
|
|
7573
|
+
import { existsSync as existsSync28, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as statSync6 } from "fs";
|
|
7459
7574
|
import { dirname as dirname13, isAbsolute as isAbsolute4, join as join30, normalize, relative as relative5, resolve as resolve12 } from "path";
|
|
7460
7575
|
import ts6 from "typescript";
|
|
7461
7576
|
function createModuleResolver(params) {
|
|
@@ -7572,31 +7687,58 @@ function localOrUnresolved(params) {
|
|
|
7572
7687
|
...MODULE_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
7573
7688
|
...MODULE_EXTENSIONS.map((extension) => join30(base, `index${extension}`))
|
|
7574
7689
|
];
|
|
7575
|
-
const found = candidates.find(
|
|
7690
|
+
const found = candidates.find(isFile3);
|
|
7576
7691
|
if (!found) return { kind: "unresolved" };
|
|
7577
7692
|
const file = relative5(params.root, found);
|
|
7578
7693
|
return file.startsWith("..") || file.startsWith("node_modules/") ? { kind: "package" } : { kind: "local", file };
|
|
7579
7694
|
}
|
|
7580
|
-
function
|
|
7695
|
+
function isFile3(path) {
|
|
7581
7696
|
try {
|
|
7582
|
-
return
|
|
7697
|
+
return statSync6(path).isFile();
|
|
7583
7698
|
} catch {
|
|
7584
7699
|
return false;
|
|
7585
7700
|
}
|
|
7586
7701
|
}
|
|
7587
7702
|
|
|
7588
7703
|
// src/lib/tdd/run-test-cases.ts
|
|
7589
|
-
import { existsSync as
|
|
7704
|
+
import { existsSync as existsSync30, mkdtempSync as mkdtempSync3, readFileSync as readFileSync23, rmSync as rmSync9 } from "fs";
|
|
7590
7705
|
import { tmpdir as tmpdir3 } from "os";
|
|
7591
|
-
import { dirname as
|
|
7706
|
+
import { dirname as dirname15, join as join32 } from "path";
|
|
7592
7707
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7708
|
+
|
|
7709
|
+
// src/lib/tdd/package-vitest.ts
|
|
7710
|
+
import { existsSync as existsSync29 } from "fs";
|
|
7711
|
+
import { dirname as dirname14, join as join31 } from "path";
|
|
7712
|
+
function resolvePackageVitest(params) {
|
|
7713
|
+
const binary = findBinary({ root: params.root });
|
|
7714
|
+
if (binary) return { command: binary, arguments: [VITEST_RUN_ARGUMENT] };
|
|
7715
|
+
const [command, ...commandArguments] = VITEST_COMMAND;
|
|
7716
|
+
return { command, arguments: commandArguments };
|
|
7717
|
+
}
|
|
7718
|
+
function findBinary(params) {
|
|
7719
|
+
const folders = walkedFolders({ root: params.root });
|
|
7720
|
+
return folders.map((folder) => join31(folder, ...VITEST_BIN_PATH)).find((path) => existsSync29(path));
|
|
7721
|
+
}
|
|
7722
|
+
function walkedFolders(params) {
|
|
7723
|
+
const folders = [];
|
|
7724
|
+
let folder = params.root;
|
|
7725
|
+
for (; ; ) {
|
|
7726
|
+
folders.push(folder);
|
|
7727
|
+
if (existsSync29(join31(folder, REPOSITORY_MARKER))) return folders;
|
|
7728
|
+
const parent = dirname14(folder);
|
|
7729
|
+
if (parent === folder) return [params.root];
|
|
7730
|
+
folder = parent;
|
|
7731
|
+
}
|
|
7732
|
+
}
|
|
7733
|
+
|
|
7734
|
+
// src/lib/tdd/run-test-cases.ts
|
|
7593
7735
|
async function runTestCases(params) {
|
|
7594
|
-
const folder = mkdtempSync3(
|
|
7595
|
-
const reportPath =
|
|
7736
|
+
const folder = mkdtempSync3(join32(tmpdir3(), "dialecte-tdd-"));
|
|
7737
|
+
const reportPath = join32(folder, "report.json");
|
|
7596
7738
|
const { filter } = params;
|
|
7597
7739
|
const nameFilter = filter === "all" ? [] : ["-t", filter === "collect" ? COLLECT_ONLY_PATTERN : namePattern(filter.names)];
|
|
7598
7740
|
try {
|
|
7599
|
-
const
|
|
7741
|
+
const { command, arguments: commandArguments } = resolvePackageVitest({ root: params.root });
|
|
7600
7742
|
const execution = await runChild({
|
|
7601
7743
|
command,
|
|
7602
7744
|
args: [
|
|
@@ -7626,7 +7768,7 @@ async function runTestCases(params) {
|
|
|
7626
7768
|
${execution.stalled.report}
|
|
7627
7769
|
${tail}`.trimEnd()
|
|
7628
7770
|
};
|
|
7629
|
-
if (!
|
|
7771
|
+
if (!existsSync30(reportPath))
|
|
7630
7772
|
return {
|
|
7631
7773
|
failure: `vitest wrote no report (exit ${execution.exitCode ?? "none"}):
|
|
7632
7774
|
${tail}`
|
|
@@ -7643,17 +7785,17 @@ function namePattern(names) {
|
|
|
7643
7785
|
return `^(?:${alternatives.join("|")})$`;
|
|
7644
7786
|
}
|
|
7645
7787
|
function reporterPath() {
|
|
7646
|
-
const folder =
|
|
7647
|
-
const found = REPORTER_FILE_NAMES.map((name) =>
|
|
7648
|
-
(path) =>
|
|
7788
|
+
const folder = dirname15(fileURLToPath2(import.meta.url));
|
|
7789
|
+
const found = REPORTER_FILE_NAMES.map((name) => join32(folder, name)).find(
|
|
7790
|
+
(path) => existsSync30(path)
|
|
7649
7791
|
);
|
|
7650
7792
|
if (!found) throw new Error(`the tdd reporter is missing next to ${folder}`);
|
|
7651
7793
|
return found;
|
|
7652
7794
|
}
|
|
7653
7795
|
|
|
7654
7796
|
// src/lib/tdd/test-dependencies.ts
|
|
7655
|
-
import { existsSync as
|
|
7656
|
-
import { basename as basename3, dirname as
|
|
7797
|
+
import { existsSync as existsSync31, readFileSync as readFileSync24 } from "fs";
|
|
7798
|
+
import { basename as basename3, dirname as dirname16, join as join33, posix } from "path";
|
|
7657
7799
|
function listTestDependencies(params) {
|
|
7658
7800
|
const { root } = params;
|
|
7659
7801
|
const found = /* @__PURE__ */ new Set();
|
|
@@ -7665,7 +7807,7 @@ function listTestDependencies(params) {
|
|
|
7665
7807
|
while (queue.length) {
|
|
7666
7808
|
while (queue.length) {
|
|
7667
7809
|
const current = queue.shift() ?? "";
|
|
7668
|
-
const text = readFileSync24(
|
|
7810
|
+
const text = readFileSync24(join33(root, current), "utf8");
|
|
7669
7811
|
texts.push(text);
|
|
7670
7812
|
if (!SOURCE_FILE_PATTERN.test(current)) continue;
|
|
7671
7813
|
for (const specifier of moduleSpecifiers({ text, file: current })) {
|
|
@@ -7683,13 +7825,13 @@ function listTestDependencies(params) {
|
|
|
7683
7825
|
queue.push(resolved);
|
|
7684
7826
|
} else if (!productionRead.has(resolved)) {
|
|
7685
7827
|
productionRead.add(resolved);
|
|
7686
|
-
texts.push(readFileSync24(
|
|
7828
|
+
texts.push(readFileSync24(join33(root, resolved), "utf8"));
|
|
7687
7829
|
}
|
|
7688
7830
|
}
|
|
7689
7831
|
}
|
|
7690
7832
|
for (const candidate of params.changedTestCode) {
|
|
7691
7833
|
if (followed.has(candidate)) continue;
|
|
7692
|
-
const withFolder = posix.join(basename3(
|
|
7834
|
+
const withFolder = posix.join(basename3(dirname16(candidate)), basename3(candidate));
|
|
7693
7835
|
if (texts.some((text) => text.includes(withFolder))) {
|
|
7694
7836
|
found.add(candidate);
|
|
7695
7837
|
followed.add(candidate);
|
|
@@ -7697,8 +7839,8 @@ function listTestDependencies(params) {
|
|
|
7697
7839
|
} else if (texts.some((text) => text.includes(basename3(candidate)))) found.add(candidate);
|
|
7698
7840
|
}
|
|
7699
7841
|
}
|
|
7700
|
-
const snapshot =
|
|
7701
|
-
if (
|
|
7842
|
+
const snapshot = join33(dirname16(params.file), "__snapshots__", `${basename3(params.file)}.snap`);
|
|
7843
|
+
if (existsSync31(join33(root, snapshot))) found.add(snapshot);
|
|
7702
7844
|
return { dependencies: [...found].sort(), unresolved: [...unresolved].sort() };
|
|
7703
7845
|
}
|
|
7704
7846
|
|
|
@@ -7789,12 +7931,12 @@ function findDeletedCases(params) {
|
|
|
7789
7931
|
params.ledger.entries.flatMap((entry) => entry.kind === "freeze" ? [] : [entry.file])
|
|
7790
7932
|
);
|
|
7791
7933
|
for (const file of receiptFiles)
|
|
7792
|
-
if (!
|
|
7934
|
+
if (!existsSync32(join34(params.root, file)) && readAtBase({ ...params, file }) === void 0)
|
|
7793
7935
|
findings.push({ verb: "deleted", file, detail: "a new test file deleted after its receipts" });
|
|
7794
7936
|
return findings;
|
|
7795
7937
|
}
|
|
7796
|
-
function findingLine(
|
|
7797
|
-
return `${
|
|
7938
|
+
function findingLine(finding2) {
|
|
7939
|
+
return `${finding2.verb} ${finding2.file} ${finding2.detail}`;
|
|
7798
7940
|
}
|
|
7799
7941
|
|
|
7800
7942
|
// src/lib/tdd/check-tdd-receipts.ts
|
|
@@ -7868,7 +8010,7 @@ async function checkTddReceipts(params) {
|
|
|
7868
8010
|
),
|
|
7869
8011
|
...gone.filter(
|
|
7870
8012
|
(entry) => !state.findings.some(
|
|
7871
|
-
(
|
|
8013
|
+
(finding2) => finding2.verb === "gone" && entryNamesFile({ entry: entry.file, file: finding2.file })
|
|
7872
8014
|
)
|
|
7873
8015
|
).map(
|
|
7874
8016
|
(entry) => `unused gone entry ${entry.file} no test call of the base gone without a title in a file it names (${entry.reason})`
|
|
@@ -7953,7 +8095,7 @@ async function runGate(params) {
|
|
|
7953
8095
|
const underHandover = "folder" in hold ? [
|
|
7954
8096
|
GATE_UNDER_HANDOVER.replace("{folder}", hold.folder).replace(
|
|
7955
8097
|
"{lots}",
|
|
7956
|
-
|
|
8098
|
+
join35(hold.folder, HANDOVER_FILES.lots)
|
|
7957
8099
|
)
|
|
7958
8100
|
] : [];
|
|
7959
8101
|
const packageJson = readPackageJson(cwd);
|
|
@@ -8206,7 +8348,7 @@ function renderRerun(rerun) {
|
|
|
8206
8348
|
// src/commands/handover.ts
|
|
8207
8349
|
import { existsSync as existsSync52, realpathSync as realpathSync8 } from "fs";
|
|
8208
8350
|
import { tmpdir as tmpdir6 } from "os";
|
|
8209
|
-
import { dirname as
|
|
8351
|
+
import { dirname as dirname25, join as join59, resolve as resolve18 } from "path";
|
|
8210
8352
|
|
|
8211
8353
|
// src/lib/card/card.constants.ts
|
|
8212
8354
|
var EMPHASIS_CODES = { passed: 32, warning: 33, failed: 31, strong: 1 };
|
|
@@ -8399,10 +8541,7 @@ function resolveCardColumns(params) {
|
|
|
8399
8541
|
}
|
|
8400
8542
|
|
|
8401
8543
|
// src/lib/handover/handover-card.ts
|
|
8402
|
-
import {
|
|
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";
|
|
8405
|
-
import { basename as basename5, join as join44 } from "path";
|
|
8544
|
+
import { basename as basename5 } from "path";
|
|
8406
8545
|
|
|
8407
8546
|
// src/lib/counted.ts
|
|
8408
8547
|
function counted(params) {
|
|
@@ -8410,8 +8549,8 @@ function counted(params) {
|
|
|
8410
8549
|
}
|
|
8411
8550
|
|
|
8412
8551
|
// src/lib/gate-records/card-gates.ts
|
|
8413
|
-
import { existsSync as
|
|
8414
|
-
import { join as
|
|
8552
|
+
import { existsSync as existsSync38, readdirSync as readdirSync10, readFileSync as readFileSync29 } from "fs";
|
|
8553
|
+
import { join as join41 } from "path";
|
|
8415
8554
|
|
|
8416
8555
|
// src/lib/mutation/pending-verdict.constants.ts
|
|
8417
8556
|
var MUTATION_GATE_NAME = "mutation";
|
|
@@ -8434,8 +8573,8 @@ var GATE_LOT_WITHOUT_RUN = "gate lot: run dialecte mutants run on this tree firs
|
|
|
8434
8573
|
var INVALID_FOLDER_MODE = '{file}: "mutation" must be one of {modes}, not {value}';
|
|
8435
8574
|
|
|
8436
8575
|
// src/lib/mutation/pending-verdict.ts
|
|
8437
|
-
import { existsSync as
|
|
8438
|
-
import { join as
|
|
8576
|
+
import { existsSync as existsSync36 } from "fs";
|
|
8577
|
+
import { join as join40 } from "path";
|
|
8439
8578
|
|
|
8440
8579
|
// src/lib/mutation/mutation.constants.ts
|
|
8441
8580
|
var MUTATION_RECORDS_PATH = ".dialecte/mutation-records.json";
|
|
@@ -8585,17 +8724,17 @@ function isNonEmptyString(value) {
|
|
|
8585
8724
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
8586
8725
|
import {
|
|
8587
8726
|
closeSync,
|
|
8588
|
-
existsSync as
|
|
8727
|
+
existsSync as existsSync35,
|
|
8589
8728
|
linkSync,
|
|
8590
8729
|
mkdirSync as mkdirSync9,
|
|
8591
8730
|
openSync,
|
|
8592
8731
|
readFileSync as readFileSync27,
|
|
8593
8732
|
renameSync as renameSync3,
|
|
8594
8733
|
rmSync as rmSync10,
|
|
8595
|
-
statSync as
|
|
8734
|
+
statSync as statSync7,
|
|
8596
8735
|
writeSync
|
|
8597
8736
|
} from "fs";
|
|
8598
|
-
import { join as
|
|
8737
|
+
import { join as join38 } from "path";
|
|
8599
8738
|
|
|
8600
8739
|
// src/lib/process-start-time.ts
|
|
8601
8740
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
@@ -8880,11 +9019,11 @@ function shortHash(params) {
|
|
|
8880
9019
|
}
|
|
8881
9020
|
|
|
8882
9021
|
// src/lib/mutation/records-file.ts
|
|
8883
|
-
import { existsSync as
|
|
8884
|
-
import { dirname as
|
|
9022
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync13 } from "fs";
|
|
9023
|
+
import { dirname as dirname17, join as join36 } from "path";
|
|
8885
9024
|
function readRecordsFile(params) {
|
|
8886
|
-
const path =
|
|
8887
|
-
if (!
|
|
9025
|
+
const path = join36(params.root, MUTATION_RECORDS_PATH);
|
|
9026
|
+
if (!existsSync33(path)) return {};
|
|
8888
9027
|
try {
|
|
8889
9028
|
return JSON.parse(readFileSync25(path, "utf8"));
|
|
8890
9029
|
} catch (error) {
|
|
@@ -8892,8 +9031,8 @@ function readRecordsFile(params) {
|
|
|
8892
9031
|
}
|
|
8893
9032
|
}
|
|
8894
9033
|
function writeRecordsFile(params) {
|
|
8895
|
-
const path =
|
|
8896
|
-
mkdirSync7(
|
|
9034
|
+
const path = join36(params.root, MUTATION_RECORDS_PATH);
|
|
9035
|
+
mkdirSync7(dirname17(path), { recursive: true });
|
|
8897
9036
|
writeFileSync13(path, `${JSON.stringify(params.records, null, " ")}
|
|
8898
9037
|
`);
|
|
8899
9038
|
}
|
|
@@ -8901,14 +9040,14 @@ function writeRecordsFile(params) {
|
|
|
8901
9040
|
// src/lib/mutation/run-store.ts
|
|
8902
9041
|
import { randomBytes } from "crypto";
|
|
8903
9042
|
import {
|
|
8904
|
-
existsSync as
|
|
9043
|
+
existsSync as existsSync34,
|
|
8905
9044
|
mkdirSync as mkdirSync8,
|
|
8906
9045
|
readdirSync as readdirSync9,
|
|
8907
9046
|
readFileSync as readFileSync26,
|
|
8908
9047
|
renameSync as renameSync2,
|
|
8909
9048
|
writeFileSync as writeFileSync14
|
|
8910
9049
|
} from "fs";
|
|
8911
|
-
import { basename as basename4, join as
|
|
9050
|
+
import { basename as basename4, join as join37 } from "path";
|
|
8912
9051
|
function startRun(params) {
|
|
8913
9052
|
const { root, pid, lot, tree, mode, base, targets } = params;
|
|
8914
9053
|
const startedAt = (params.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
@@ -8953,9 +9092,9 @@ function readRuns(params) {
|
|
|
8953
9092
|
}
|
|
8954
9093
|
function readStoredRuns(root) {
|
|
8955
9094
|
const folder = runsFolderOf(root);
|
|
8956
|
-
if (!
|
|
9095
|
+
if (!existsSync34(folder)) return [];
|
|
8957
9096
|
return readdirSync9(folder).filter((file) => file.endsWith(".json")).flatMap((file) => {
|
|
8958
|
-
const entry = parseRunEntry(
|
|
9097
|
+
const entry = parseRunEntry(join37(folder, file));
|
|
8959
9098
|
return entry ? [entry] : [];
|
|
8960
9099
|
}).sort((first, second) => first.startedAt.localeCompare(second.startedAt));
|
|
8961
9100
|
}
|
|
@@ -8973,7 +9112,7 @@ function abandonRun(params) {
|
|
|
8973
9112
|
return { ok: true };
|
|
8974
9113
|
}
|
|
8975
9114
|
function mutationStoreFolderOf(root) {
|
|
8976
|
-
return
|
|
9115
|
+
return join37(commonGitFolderOf(root), MUTATION_STORE_FOLDER);
|
|
8977
9116
|
}
|
|
8978
9117
|
function packageNameOf(root) {
|
|
8979
9118
|
return readPackageJson(root).name ?? basename4(root);
|
|
@@ -8984,20 +9123,20 @@ function writeAtomically(params) {
|
|
|
8984
9123
|
renameSync2(written, params.path);
|
|
8985
9124
|
}
|
|
8986
9125
|
function runsFolderOf(root) {
|
|
8987
|
-
return
|
|
9126
|
+
return join37(mutationStoreFolderOf(root), MUTATION_RUNS_FOLDER);
|
|
8988
9127
|
}
|
|
8989
9128
|
function writeRunEntry(params) {
|
|
8990
9129
|
const folder = runsFolderOf(params.root);
|
|
8991
9130
|
mkdirSync8(folder, { recursive: true });
|
|
8992
9131
|
writeAtomically({
|
|
8993
|
-
path:
|
|
9132
|
+
path: join37(folder, `${params.entry.runId}.json`),
|
|
8994
9133
|
text: `${JSON.stringify(params.entry, null, " ")}
|
|
8995
9134
|
`
|
|
8996
9135
|
});
|
|
8997
9136
|
}
|
|
8998
9137
|
function readStoredRun(params) {
|
|
8999
|
-
const path =
|
|
9000
|
-
return
|
|
9138
|
+
const path = join37(runsFolderOf(params.root), `${params.runId}.json`);
|
|
9139
|
+
return existsSync34(path) ? parseRunEntry(path) : void 0;
|
|
9001
9140
|
}
|
|
9002
9141
|
function parseRunEntry(path) {
|
|
9003
9142
|
try {
|
|
@@ -9101,13 +9240,13 @@ function withLedgerLock(params) {
|
|
|
9101
9240
|
const { root, given, work } = params;
|
|
9102
9241
|
const folder = mutationStoreFolderOf(root);
|
|
9103
9242
|
mkdirSync9(folder, { recursive: true });
|
|
9104
|
-
const lock =
|
|
9243
|
+
const lock = join38(folder, MUTATION_LEDGER_LOCK_FILE);
|
|
9105
9244
|
takeLock(lock);
|
|
9106
9245
|
try {
|
|
9107
9246
|
const state = {
|
|
9108
|
-
ledger: readJson({ path:
|
|
9247
|
+
ledger: readJson({ path: join38(folder, MUTATION_LEDGER_FILE), empty: {} }),
|
|
9109
9248
|
applied: new Set(
|
|
9110
|
-
readJson({ path:
|
|
9249
|
+
readJson({ path: join38(folder, MUTATION_APPLIED_RUNS_FILE), empty: [] })
|
|
9111
9250
|
),
|
|
9112
9251
|
// the ledger file exists once anything took it in: a reader of a fresh store writes nothing
|
|
9113
9252
|
changed: false
|
|
@@ -9116,12 +9255,12 @@ function withLedgerLock(params) {
|
|
|
9116
9255
|
const result = work(state);
|
|
9117
9256
|
if (state.changed) {
|
|
9118
9257
|
writeAtomically({
|
|
9119
|
-
path:
|
|
9258
|
+
path: join38(folder, MUTATION_LEDGER_FILE),
|
|
9120
9259
|
text: `${JSON.stringify(state.ledger, null, " ")}
|
|
9121
9260
|
`
|
|
9122
9261
|
});
|
|
9123
9262
|
writeAtomically({
|
|
9124
|
-
path:
|
|
9263
|
+
path: join38(folder, MUTATION_APPLIED_RUNS_FILE),
|
|
9125
9264
|
text: `${JSON.stringify([...state.applied], null, " ")}
|
|
9126
9265
|
`
|
|
9127
9266
|
});
|
|
@@ -9147,7 +9286,7 @@ function compareRunsInFoldOrder(first, second) {
|
|
|
9147
9286
|
function nothingMore() {
|
|
9148
9287
|
}
|
|
9149
9288
|
function recordsOfRun(run25) {
|
|
9150
|
-
if (run25.packageRoot === void 0 || !
|
|
9289
|
+
if (run25.packageRoot === void 0 || !existsSync35(run25.packageRoot)) return {};
|
|
9151
9290
|
try {
|
|
9152
9291
|
return readRecordsFile({ root: run25.packageRoot });
|
|
9153
9292
|
} catch {
|
|
@@ -9270,7 +9409,7 @@ function isStaleLock(params) {
|
|
|
9270
9409
|
if (holder !== void 0)
|
|
9271
9410
|
return !isOwnerProcessAlive({ pid: holder.pid, startedAt: holder.startedAt });
|
|
9272
9411
|
try {
|
|
9273
|
-
return Date.now() -
|
|
9412
|
+
return Date.now() - statSync7(lock).mtimeMs > LEDGER_LOCK_ORPHAN_MS;
|
|
9274
9413
|
} catch {
|
|
9275
9414
|
return false;
|
|
9276
9415
|
}
|
|
@@ -9303,7 +9442,7 @@ function sleep(milliseconds) {
|
|
|
9303
9442
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
|
|
9304
9443
|
}
|
|
9305
9444
|
function readJson(params) {
|
|
9306
|
-
return
|
|
9445
|
+
return existsSync35(params.path) ? JSON.parse(readFileSync27(params.path, "utf8")) : params.empty;
|
|
9307
9446
|
}
|
|
9308
9447
|
function ledgerKeyOf(params) {
|
|
9309
9448
|
return `${params.packageName}${LEDGER_KEY_SEPARATOR}${params.key}`;
|
|
@@ -9317,9 +9456,9 @@ function locationOf(survivor) {
|
|
|
9317
9456
|
}
|
|
9318
9457
|
|
|
9319
9458
|
// src/lib/mutation/lot-mode.ts
|
|
9320
|
-
import { join as
|
|
9459
|
+
import { join as join39 } from "path";
|
|
9321
9460
|
function readMutationMode(params) {
|
|
9322
|
-
const declaration = readLotDeclaration(
|
|
9461
|
+
const declaration = readLotDeclaration(join39(params.root, LOT_FILE));
|
|
9323
9462
|
if ("failure" in declaration) return { kind: "invalid", reason: declaration.failure };
|
|
9324
9463
|
const { mutation } = declaration;
|
|
9325
9464
|
if (mutation === void 0) return { kind: "default" };
|
|
@@ -9375,8 +9514,8 @@ function pendingVerdict(params) {
|
|
|
9375
9514
|
};
|
|
9376
9515
|
}
|
|
9377
9516
|
function lotModeOf(params) {
|
|
9378
|
-
const archived =
|
|
9379
|
-
if (!
|
|
9517
|
+
const archived = join40(params.folder, ARCHIVED_LOT_FILE);
|
|
9518
|
+
if (!existsSync36(archived)) return readMutationMode({ root: params.root });
|
|
9380
9519
|
const declaration = readLotDeclaration(archived);
|
|
9381
9520
|
if ("failure" in declaration)
|
|
9382
9521
|
return {
|
|
@@ -9417,7 +9556,7 @@ function hasReportedRunOn(params) {
|
|
|
9417
9556
|
}
|
|
9418
9557
|
|
|
9419
9558
|
// src/lib/review-rounds/findings-ledger.ts
|
|
9420
|
-
import { existsSync as
|
|
9559
|
+
import { existsSync as existsSync37, readFileSync as readFileSync28, writeFileSync as writeFileSync15 } from "fs";
|
|
9421
9560
|
function escapeCell(value) {
|
|
9422
9561
|
return value.replace(/\|/g, "\\|");
|
|
9423
9562
|
}
|
|
@@ -9462,7 +9601,7 @@ function roundOfRow(cells) {
|
|
|
9462
9601
|
return id ? Number(id[1]) : void 0;
|
|
9463
9602
|
}
|
|
9464
9603
|
function appendFinding(params) {
|
|
9465
|
-
const text =
|
|
9604
|
+
const text = existsSync37(params.path) ? readFileSync28(params.path, "utf8") : "";
|
|
9466
9605
|
const lines = text.split("\n");
|
|
9467
9606
|
const table = findLedgerTable(lines);
|
|
9468
9607
|
const numbers = (table?.rows ?? []).map(function numberInRound(row2) {
|
|
@@ -9694,8 +9833,8 @@ function rulesLine(params) {
|
|
|
9694
9833
|
});
|
|
9695
9834
|
}
|
|
9696
9835
|
function reviewLine(folder) {
|
|
9697
|
-
const ledgerPath2 =
|
|
9698
|
-
if (!
|
|
9836
|
+
const ledgerPath2 = join41(folder, LEDGER_FILE);
|
|
9837
|
+
if (!existsSync38(ledgerPath2))
|
|
9699
9838
|
return { name: REVIEW_LINE_NAME, status: "warning", detail: NO_LEDGER_DETAIL };
|
|
9700
9839
|
const lines = readFileSync29(ledgerPath2, "utf8").split("\n");
|
|
9701
9840
|
const rows = findLedgerTable(lines)?.rows ?? [];
|
|
@@ -9741,8 +9880,34 @@ function snapshotRounds(folder) {
|
|
|
9741
9880
|
}
|
|
9742
9881
|
|
|
9743
9882
|
// src/lib/handover/lot-size.ts
|
|
9744
|
-
import {
|
|
9745
|
-
|
|
9883
|
+
import { join as join43 } from "path";
|
|
9884
|
+
|
|
9885
|
+
// src/lib/handover/committed-bytes.ts
|
|
9886
|
+
import { spawnSync as spawnSync8 } from "child_process";
|
|
9887
|
+
import { lstatSync as lstatSync6, readFileSync as readFileSync30, readlinkSync as readlinkSync2 } from "fs";
|
|
9888
|
+
import { join as join42 } from "path";
|
|
9889
|
+
function readCommittedBytes(path) {
|
|
9890
|
+
return lstatSync6(path).isSymbolicLink() ? Buffer.from(readlinkSync2(path)) : readFileSync30(path);
|
|
9891
|
+
}
|
|
9892
|
+
function gitBlobIds(params) {
|
|
9893
|
+
return params.files.map(function blobIdOf(file) {
|
|
9894
|
+
const path = join42(params.root, file);
|
|
9895
|
+
const linked = lstatSync6(path).isSymbolicLink();
|
|
9896
|
+
const result = spawnSync8(
|
|
9897
|
+
"git",
|
|
9898
|
+
linked ? ["hash-object", "--stdin"] : ["hash-object", "--", file],
|
|
9899
|
+
{
|
|
9900
|
+
cwd: params.root,
|
|
9901
|
+
encoding: "utf8",
|
|
9902
|
+
input: linked ? readlinkSync2(path) : void 0
|
|
9903
|
+
}
|
|
9904
|
+
);
|
|
9905
|
+
if (result.status !== 0) throw new Error(`git hash-object ${file}: ${result.stderr.trim()}`);
|
|
9906
|
+
return result.stdout.trim();
|
|
9907
|
+
});
|
|
9908
|
+
}
|
|
9909
|
+
|
|
9910
|
+
// src/lib/handover/lot-size.ts
|
|
9746
9911
|
function workingTreeSizeOf(params) {
|
|
9747
9912
|
const tracked = new Set(
|
|
9748
9913
|
readGit({
|
|
@@ -9758,7 +9923,7 @@ function workingTreeSizeOf(params) {
|
|
|
9758
9923
|
})
|
|
9759
9924
|
) : { insertions: 0, deletions: 0 };
|
|
9760
9925
|
for (const file of params.files.filter((path) => !tracked.has(path)))
|
|
9761
|
-
size.insertions += lineCountOf(
|
|
9926
|
+
size.insertions += lineCountOf(readCommittedBytes(join43(params.root, file)).toString("utf8"));
|
|
9762
9927
|
return size;
|
|
9763
9928
|
}
|
|
9764
9929
|
function commitSizeOf(params) {
|
|
@@ -9798,14 +9963,14 @@ function lineCountOf(text) {
|
|
|
9798
9963
|
}
|
|
9799
9964
|
|
|
9800
9965
|
// src/lib/handover/merge-lot.ts
|
|
9801
|
-
import { spawnSync as
|
|
9802
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
9803
|
-
import { dirname as
|
|
9966
|
+
import { spawnSync as spawnSync9 } from "child_process";
|
|
9967
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync40, mkdirSync as mkdirSync11, readFileSync as readFileSync31, rmSync as rmSync11, writeFileSync as writeFileSync17 } from "fs";
|
|
9968
|
+
import { dirname as dirname18, isAbsolute as isAbsolute5, join as join45 } from "path";
|
|
9804
9969
|
|
|
9805
9970
|
// src/lib/handover/write-handover.ts
|
|
9806
9971
|
import { createHash as createHash5 } from "crypto";
|
|
9807
|
-
import { chmodSync, existsSync as
|
|
9808
|
-
import { join as
|
|
9972
|
+
import { chmodSync, existsSync as existsSync39, mkdirSync as mkdirSync10, writeFileSync as writeFileSync16 } from "fs";
|
|
9973
|
+
import { join as join44, resolve as resolve13 } from "path";
|
|
9809
9974
|
|
|
9810
9975
|
// src/lib/handover/commit-script.ts
|
|
9811
9976
|
function renderCommitScript(params) {
|
|
@@ -9835,43 +10000,43 @@ function renderCommitScript(params) {
|
|
|
9835
10000
|
function writeHandover(params) {
|
|
9836
10001
|
const { plan, out } = params;
|
|
9837
10002
|
mkdirSync10(out, { recursive: true });
|
|
9838
|
-
const lotsCopy =
|
|
9839
|
-
if (resolve13(params.lotsPath) !== resolve13(lotsCopy) || !
|
|
10003
|
+
const lotsCopy = join44(out, HANDOVER_FILES.lots);
|
|
10004
|
+
if (resolve13(params.lotsPath) !== resolve13(lotsCopy) || !existsSync39(lotsCopy))
|
|
9840
10005
|
writeFileSync16(lotsCopy, `${JSON.stringify(params.lotsFile, null, " ")}
|
|
9841
10006
|
`);
|
|
9842
|
-
writeFileSync16(
|
|
10007
|
+
writeFileSync16(join44(out, HANDOVER_FILES.lotsHash), `${hashFile2(lotsCopy)}
|
|
9843
10008
|
`);
|
|
9844
10009
|
const existing = plan.lots.flatMap((lot) => lot.files).sort();
|
|
9845
10010
|
writeFileSync16(
|
|
9846
|
-
|
|
10011
|
+
join44(out, HANDOVER_FILES.files),
|
|
9847
10012
|
linesOf(plan.lots.flatMap((lot) => [...lot.files, ...lot.deletedFiles]).sort())
|
|
9848
10013
|
);
|
|
9849
10014
|
writeFileSync16(
|
|
9850
|
-
|
|
9851
|
-
linesOf(existing.map((file) => `${hashFile2(
|
|
10015
|
+
join44(out, HANDOVER_FILES.hashes),
|
|
10016
|
+
linesOf(existing.map((file) => `${hashFile2(join44(plan.repository, file))} ${file}`))
|
|
9852
10017
|
);
|
|
9853
10018
|
writeFileSync16(
|
|
9854
|
-
|
|
10019
|
+
join44(out, HANDOVER_FILES.deleted),
|
|
9855
10020
|
linesOf(plan.lots.flatMap((lot) => lot.deletedFiles).sort())
|
|
9856
10021
|
);
|
|
9857
10022
|
const merges = Object.fromEntries(
|
|
9858
10023
|
plan.lots.flatMap((lot, index) => lot.merge ? [[String(index), lot.merge]] : [])
|
|
9859
10024
|
);
|
|
9860
10025
|
if (Object.keys(merges).length) {
|
|
9861
|
-
const mergesPath =
|
|
10026
|
+
const mergesPath = join44(out, HANDOVER_FILES.merges);
|
|
9862
10027
|
writeFileSync16(mergesPath, `${JSON.stringify(merges, null, " ")}
|
|
9863
10028
|
`);
|
|
9864
|
-
writeFileSync16(
|
|
10029
|
+
writeFileSync16(join44(out, HANDOVER_FILES.mergesHash), `${hashFile2(mergesPath)}
|
|
9865
10030
|
`);
|
|
9866
10031
|
}
|
|
9867
|
-
const scriptPath =
|
|
10032
|
+
const scriptPath = join44(out, COMMIT_SCRIPT_FILE);
|
|
9868
10033
|
writeFileSync16(scriptPath, renderCommitScript({ plan, folder: out, cliPath: params.cliPath }));
|
|
9869
10034
|
chmodSync(scriptPath, 493);
|
|
9870
10035
|
writeFileSync16(handoverLockPath(plan.repository), `${scriptPath}
|
|
9871
10036
|
`);
|
|
9872
10037
|
}
|
|
9873
10038
|
function hashFile2(path) {
|
|
9874
|
-
return createHash5("sha256").update(
|
|
10039
|
+
return createHash5("sha256").update(readCommittedBytes(path)).digest("hex");
|
|
9875
10040
|
}
|
|
9876
10041
|
function linesOf(lines) {
|
|
9877
10042
|
return lines.length ? `${lines.join("\n")}
|
|
@@ -9896,12 +10061,12 @@ function planMergeLot(params) {
|
|
|
9896
10061
|
);
|
|
9897
10062
|
const resolutions = Object.entries(lot.resolved).sort(([left], [right]) => left.localeCompare(right)).flatMap(function resolutionOf([path, relative12]) {
|
|
9898
10063
|
if (relative12 === null) return [{ path, removed: true }];
|
|
9899
|
-
const file = isAbsolute5(relative12) ? relative12 :
|
|
9900
|
-
if (!
|
|
10064
|
+
const file = isAbsolute5(relative12) ? relative12 : join45(dirname18(params.lotsPath), relative12);
|
|
10065
|
+
if (!existsSync40(file)) {
|
|
9901
10066
|
refusals.push(`merge lot ${number}: the resolution ${relative12} of ${path} does not exist`);
|
|
9902
10067
|
return [];
|
|
9903
10068
|
}
|
|
9904
|
-
if (CONFLICT_MARKER_PATTERN.test(
|
|
10069
|
+
if (CONFLICT_MARKER_PATTERN.test(readFileSync31(file, "utf8")))
|
|
9905
10070
|
refusals.push(
|
|
9906
10071
|
`merge lot ${number}: conflict markers in ${relative12}, the resolution of ${path}`
|
|
9907
10072
|
);
|
|
@@ -9943,7 +10108,7 @@ function planMergeLot(params) {
|
|
|
9943
10108
|
};
|
|
9944
10109
|
}
|
|
9945
10110
|
function trialMerge(params) {
|
|
9946
|
-
const trial =
|
|
10111
|
+
const trial = spawnSync9(
|
|
9947
10112
|
"git",
|
|
9948
10113
|
["merge-tree", "--write-tree", "-z", "--no-messages", params.base, params.tip],
|
|
9949
10114
|
{ cwd: params.root, encoding: "utf8" }
|
|
@@ -9968,7 +10133,7 @@ function runMergeLot(params) {
|
|
|
9968
10133
|
refusal: `HEAD holds tree ${headTree.slice(0, 12)}, not ${merge.onTree.slice(0, 12)}, the tree the lots before it left when the merge was trial-merged: an earlier lot committed other content (a hook staged files of its own?), nothing merged: see what the lots before it committed (\`git show --stat HEAD\`), then write the hand-over again from this HEAD for the lots left`
|
|
9969
10134
|
};
|
|
9970
10135
|
writeMergeMarker({ root, tip: merge.tip });
|
|
9971
|
-
const merged =
|
|
10136
|
+
const merged = spawnSync9("git", ["merge", "--no-ff", "--no-commit", merge.tip], {
|
|
9972
10137
|
cwd: root,
|
|
9973
10138
|
encoding: "utf8"
|
|
9974
10139
|
});
|
|
@@ -9991,12 +10156,12 @@ function runMergeLot(params) {
|
|
|
9991
10156
|
readGit({ root, args: ["rm", "-q", "-f", "--", resolution.path] });
|
|
9992
10157
|
continue;
|
|
9993
10158
|
}
|
|
9994
|
-
if (!
|
|
10159
|
+
if (!existsSync40(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
|
|
9995
10160
|
return {
|
|
9996
10161
|
refusal: `the resolution of ${resolution.path} changed since the review: ${resolution.file}`
|
|
9997
10162
|
};
|
|
9998
|
-
const target =
|
|
9999
|
-
mkdirSync11(
|
|
10163
|
+
const target = join45(root, resolution.path);
|
|
10164
|
+
mkdirSync11(dirname18(target), { recursive: true });
|
|
10000
10165
|
copyFileSync2(resolution.file, target);
|
|
10001
10166
|
readGit({ root, args: ["add", "--", resolution.path] });
|
|
10002
10167
|
}
|
|
@@ -10018,7 +10183,7 @@ function undoMerge(params) {
|
|
|
10018
10183
|
removeMergeMarker(root);
|
|
10019
10184
|
return ` nothing changed; fix the cause, then ${resume}`;
|
|
10020
10185
|
}
|
|
10021
|
-
const aborted =
|
|
10186
|
+
const aborted = spawnSync9("git", ["merge", "--abort"], { cwd: root, encoding: "utf8" });
|
|
10022
10187
|
if (aborted.status !== 0)
|
|
10023
10188
|
return ` git merge --abort failed (${aborted.stderr.trim()}): look at the repository before running again`;
|
|
10024
10189
|
removeMergeMarker(root);
|
|
@@ -10026,9 +10191,9 @@ function undoMerge(params) {
|
|
|
10026
10191
|
}
|
|
10027
10192
|
function readMergeMarker(root) {
|
|
10028
10193
|
const path = mergeMarkerPath(root);
|
|
10029
|
-
if (!
|
|
10194
|
+
if (!existsSync40(path)) return void 0;
|
|
10030
10195
|
try {
|
|
10031
|
-
return JSON.parse(
|
|
10196
|
+
return JSON.parse(readFileSync31(path, "utf8")).tip;
|
|
10032
10197
|
} catch {
|
|
10033
10198
|
return void 0;
|
|
10034
10199
|
}
|
|
@@ -10041,14 +10206,14 @@ function stagedFilesWithMarkers(root) {
|
|
|
10041
10206
|
root,
|
|
10042
10207
|
args: ["diff", "--cached", "--name-only", "-z", "--diff-filter=d"]
|
|
10043
10208
|
}).filter(function holdsMarkers(file) {
|
|
10044
|
-
const path =
|
|
10045
|
-
if (!
|
|
10046
|
-
const text =
|
|
10209
|
+
const path = join45(root, file);
|
|
10210
|
+
if (!existsSync40(path)) return false;
|
|
10211
|
+
const text = readCommittedBytes(path);
|
|
10047
10212
|
return !text.subarray(0, BINARY_PROBE_LENGTH).includes(0) && CONFLICT_MARKER_PATTERN.test(text.toString("utf8"));
|
|
10048
10213
|
});
|
|
10049
10214
|
}
|
|
10050
10215
|
function commitOf(params) {
|
|
10051
|
-
const result =
|
|
10216
|
+
const result = spawnSync9(
|
|
10052
10217
|
"git",
|
|
10053
10218
|
["rev-parse", "--verify", "--quiet", `${params.revision}^{commit}`],
|
|
10054
10219
|
{ cwd: params.root, encoding: "utf8" }
|
|
@@ -10102,7 +10267,7 @@ function mergedBranchesOf(lots) {
|
|
|
10102
10267
|
function buildHandoverCard(params) {
|
|
10103
10268
|
const { root } = params;
|
|
10104
10269
|
const commitRoot = params.commitRoot ?? root;
|
|
10105
|
-
const ownCli = params.done || params.cliPath === void 0 ||
|
|
10270
|
+
const ownCli = params.done || params.cliPath === void 0 || params.probe({ root, timeout: params.probeTimeout ?? HANDOVER_PROBE_TIMEOUT_MILLISECONDS });
|
|
10106
10271
|
const stateTree = computeStateTree(root);
|
|
10107
10272
|
const stateHash = hashStateTree(stateTree);
|
|
10108
10273
|
const gates = buildCardGateLines({
|
|
@@ -10189,24 +10354,6 @@ function mergeLine(merge) {
|
|
|
10189
10354
|
merge.tree ? `tree ${merge.tree.slice(0, CARD_SHA_LENGTH)}` : TREE_NOT_RECORDED
|
|
10190
10355
|
].join(CARD_PART_SEPARATOR);
|
|
10191
10356
|
}
|
|
10192
|
-
function runsHandovers(params) {
|
|
10193
|
-
const [command, ...args] = HANDOVER_PROBE_COMMAND;
|
|
10194
|
-
const folder = mkdtempSync4(join44(tmpdir4(), HANDOVER_PROBE_FOLDER_PREFIX));
|
|
10195
|
-
const answerPath = join44(folder, "answer.txt");
|
|
10196
|
-
const answer = openSync2(answerPath, "w");
|
|
10197
|
-
try {
|
|
10198
|
-
const probe = spawnSync9(command, args, {
|
|
10199
|
-
cwd: params.root,
|
|
10200
|
-
stdio: ["ignore", answer, "ignore"],
|
|
10201
|
-
timeout: params.timeout,
|
|
10202
|
-
killSignal: "SIGKILL"
|
|
10203
|
-
});
|
|
10204
|
-
return probe.status === 0 && readFileSync33(answerPath, "utf8").includes(HANDOVER_PROBE_ANSWER);
|
|
10205
|
-
} finally {
|
|
10206
|
-
closeSync2(answer);
|
|
10207
|
-
rmSync12(folder, { recursive: true, force: true });
|
|
10208
|
-
}
|
|
10209
|
-
}
|
|
10210
10357
|
function tddSection(params) {
|
|
10211
10358
|
const { root, judged } = params;
|
|
10212
10359
|
const lines = [];
|
|
@@ -10537,8 +10684,8 @@ function optionalSection(params) {
|
|
|
10537
10684
|
|
|
10538
10685
|
// src/lib/handover/list-handovers.ts
|
|
10539
10686
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
10540
|
-
import { existsSync as
|
|
10541
|
-
import { basename as basename6, join as
|
|
10687
|
+
import { existsSync as existsSync42, lstatSync as lstatSync7, readdirSync as readdirSync11, realpathSync as realpathSync6, statSync as statSync8 } from "fs";
|
|
10688
|
+
import { basename as basename6, join as join47 } from "path";
|
|
10542
10689
|
|
|
10543
10690
|
// src/lib/handover/find-committed-lots.ts
|
|
10544
10691
|
function findCommittedLots(params) {
|
|
@@ -10600,29 +10747,29 @@ function describeMismatch(params) {
|
|
|
10600
10747
|
root,
|
|
10601
10748
|
args: ["rev-parse", ...lot.files.map((file) => `${commit}:${file}`)]
|
|
10602
10749
|
}).split("\n").filter(Boolean);
|
|
10603
|
-
const workingBlobs =
|
|
10750
|
+
const workingBlobs = gitBlobIds({ root, files: lot.files });
|
|
10604
10751
|
return committedBlobs.join("\n") === workingBlobs.join("\n") ? void 0 : "other content than the reviewed files";
|
|
10605
10752
|
}
|
|
10606
10753
|
|
|
10607
10754
|
// src/lib/handover/read-handover-folder.ts
|
|
10608
|
-
import { existsSync as
|
|
10609
|
-
import { join as
|
|
10755
|
+
import { existsSync as existsSync41, readFileSync as readFileSync32 } from "fs";
|
|
10756
|
+
import { join as join46, resolve as resolve14 } from "path";
|
|
10610
10757
|
function readHandoverFolder(folder) {
|
|
10611
10758
|
const absoluteFolder = resolve14(folder);
|
|
10612
|
-
const lotsFile = readLotsFile(
|
|
10759
|
+
const lotsFile = readLotsFile(join46(absoluteFolder, HANDOVER_FILES.lots));
|
|
10613
10760
|
if (typeof lotsFile === "string") return lotsFile;
|
|
10614
10761
|
const missing = [
|
|
10615
10762
|
HANDOVER_FILES.files,
|
|
10616
10763
|
HANDOVER_FILES.hashes,
|
|
10617
10764
|
HANDOVER_FILES.deleted,
|
|
10618
10765
|
HANDOVER_FILES.lotsHash
|
|
10619
|
-
].filter((name) => !
|
|
10766
|
+
].filter((name) => !existsSync41(join46(absoluteFolder, name)));
|
|
10620
10767
|
if (missing.length)
|
|
10621
10768
|
return `${absoluteFolder} misses ${missing.join(", ")}: write it with \`dialecte handover <lots.json>\``;
|
|
10622
|
-
const files = readLines(
|
|
10623
|
-
const deleted = new Set(readLines(
|
|
10624
|
-
const mergesPath =
|
|
10625
|
-
const merges =
|
|
10769
|
+
const files = readLines(join46(absoluteFolder, HANDOVER_FILES.files));
|
|
10770
|
+
const deleted = new Set(readLines(join46(absoluteFolder, HANDOVER_FILES.deleted)));
|
|
10771
|
+
const mergesPath = join46(absoluteFolder, HANDOVER_FILES.merges);
|
|
10772
|
+
const merges = existsSync41(mergesPath) ? JSON.parse(readFileSync32(mergesPath, "utf8")) : {};
|
|
10626
10773
|
if (lotsFile.lots.some((lot, index) => isMergeLotPlan(lot) && !merges[index]))
|
|
10627
10774
|
return `${absoluteFolder} misses the merge records (${HANDOVER_FILES.merges}): write it again with \`dialecte handover --rehash <lots.json>\``;
|
|
10628
10775
|
if (Object.values(merges).some((merge) => typeof merge.onTree !== "string"))
|
|
@@ -10642,22 +10789,22 @@ function readHandoverFolder(folder) {
|
|
|
10642
10789
|
deletedFiles: covered.filter((file) => deleted.has(file))
|
|
10643
10790
|
};
|
|
10644
10791
|
}),
|
|
10645
|
-
snapshotLines: readLines(
|
|
10646
|
-
lotsHash:
|
|
10647
|
-
...
|
|
10648
|
-
mergesHash:
|
|
10792
|
+
snapshotLines: readLines(join46(absoluteFolder, HANDOVER_FILES.hashes)),
|
|
10793
|
+
lotsHash: readFileSync32(join46(absoluteFolder, HANDOVER_FILES.lotsHash), "utf8").trim(),
|
|
10794
|
+
...existsSync41(join46(absoluteFolder, HANDOVER_FILES.mergesHash)) && {
|
|
10795
|
+
mergesHash: readFileSync32(join46(absoluteFolder, HANDOVER_FILES.mergesHash), "utf8").trim()
|
|
10649
10796
|
}
|
|
10650
10797
|
};
|
|
10651
10798
|
}
|
|
10652
10799
|
function readLines(path) {
|
|
10653
|
-
return
|
|
10800
|
+
return readFileSync32(path, "utf8").split("\n").filter(Boolean);
|
|
10654
10801
|
}
|
|
10655
10802
|
|
|
10656
10803
|
// src/lib/handover/list-handovers.ts
|
|
10657
10804
|
function listHandovers(params) {
|
|
10658
10805
|
const folders = findHandoverFolders({ folder: params.root, depth: LIST_DEPTH });
|
|
10659
10806
|
return onePerRealPath(folders).flatMap(function listing(folder) {
|
|
10660
|
-
if (!
|
|
10807
|
+
if (!existsSync42(join47(folder, HANDOVER_FILES.lots)))
|
|
10661
10808
|
return [
|
|
10662
10809
|
{
|
|
10663
10810
|
folder,
|
|
@@ -10672,7 +10819,7 @@ function listHandovers(params) {
|
|
|
10672
10819
|
const handover = readHandoverFolder(folder);
|
|
10673
10820
|
if (typeof handover === "string") return [];
|
|
10674
10821
|
const { lotsFile } = handover;
|
|
10675
|
-
const repositoryExists =
|
|
10822
|
+
const repositoryExists = existsSync42(lotsFile.repository);
|
|
10676
10823
|
return [
|
|
10677
10824
|
{
|
|
10678
10825
|
folder,
|
|
@@ -10680,7 +10827,7 @@ function listHandovers(params) {
|
|
|
10680
10827
|
worktree: lotsFile.repository,
|
|
10681
10828
|
branch: lotsFile.branch,
|
|
10682
10829
|
lots: lotsFile.lots.length,
|
|
10683
|
-
age: params.now -
|
|
10830
|
+
age: params.now - statSync8(join47(folder, COMMIT_SCRIPT_FILE)).mtimeMs,
|
|
10684
10831
|
state: repositoryExists ? handoverState(handover) : "repository missing"
|
|
10685
10832
|
}
|
|
10686
10833
|
];
|
|
@@ -10691,7 +10838,7 @@ function onePerRealPath(folders) {
|
|
|
10691
10838
|
for (const folder of folders) {
|
|
10692
10839
|
const real = realpathSync6(folder);
|
|
10693
10840
|
const known = byRealPath.get(real);
|
|
10694
|
-
if (known === void 0 ||
|
|
10841
|
+
if (known === void 0 || lstatSync7(known).isSymbolicLink() && !lstatSync7(folder).isSymbolicLink())
|
|
10695
10842
|
byRealPath.set(real, folder);
|
|
10696
10843
|
}
|
|
10697
10844
|
const kept = new Set(byRealPath.values());
|
|
@@ -10720,18 +10867,18 @@ function listLegacyScripts(folder) {
|
|
|
10720
10867
|
return readdirSync11(folder).filter((name) => LEGACY_SCRIPT_PATTERN.test(name));
|
|
10721
10868
|
}
|
|
10722
10869
|
function newestScriptTime(folder) {
|
|
10723
|
-
return Math.max(...listLegacyScripts(folder).map((name) =>
|
|
10870
|
+
return Math.max(...listLegacyScripts(folder).map((name) => statSync8(join47(folder, name)).mtimeMs));
|
|
10724
10871
|
}
|
|
10725
10872
|
function findHandoverFolders(params) {
|
|
10726
10873
|
const { folder } = params;
|
|
10727
|
-
if (!
|
|
10728
|
-
const hasLots =
|
|
10729
|
-
const found = hasLots &&
|
|
10874
|
+
if (!existsSync42(folder)) return [];
|
|
10875
|
+
const hasLots = existsSync42(join47(folder, HANDOVER_FILES.lots));
|
|
10876
|
+
const found = hasLots && existsSync42(join47(folder, COMMIT_SCRIPT_FILE)) || !hasLots && listLegacyScripts(folder).length > 0 ? [folder] : [];
|
|
10730
10877
|
if (params.depth === 0) return found;
|
|
10731
10878
|
for (const entry of readdirSync11(folder, { withFileTypes: true }))
|
|
10732
10879
|
if (isFolder({ folder, entry }) && entry.name !== "node_modules" && !entry.name.startsWith("."))
|
|
10733
10880
|
found.push(
|
|
10734
|
-
...findHandoverFolders({ folder:
|
|
10881
|
+
...findHandoverFolders({ folder: join47(folder, entry.name), depth: params.depth - 1 })
|
|
10735
10882
|
);
|
|
10736
10883
|
return found.sort();
|
|
10737
10884
|
}
|
|
@@ -10739,30 +10886,29 @@ function isFolder(params) {
|
|
|
10739
10886
|
if (params.entry.isDirectory()) return true;
|
|
10740
10887
|
if (!params.entry.isSymbolicLink()) return false;
|
|
10741
10888
|
try {
|
|
10742
|
-
return
|
|
10889
|
+
return statSync8(join47(params.folder, params.entry.name)).isDirectory();
|
|
10743
10890
|
} catch {
|
|
10744
10891
|
return false;
|
|
10745
10892
|
}
|
|
10746
10893
|
}
|
|
10747
10894
|
|
|
10748
10895
|
// src/lib/handover/plan-handover.ts
|
|
10749
|
-
import {
|
|
10750
|
-
import { join as join48 } from "path";
|
|
10896
|
+
import { join as join49 } from "path";
|
|
10751
10897
|
|
|
10752
10898
|
// src/lib/handover/find-lot-references.ts
|
|
10753
|
-
import {
|
|
10754
|
-
import { join as join47 } from "path";
|
|
10899
|
+
import { join as join48 } from "path";
|
|
10755
10900
|
|
|
10756
10901
|
// src/lib/rules/committed-text.constants.ts
|
|
10757
10902
|
var GENERIC_REFERENCE_PATTERNS = [
|
|
10758
|
-
{ label: "plan tag", source: "\\blot [A-Z0-9]" },
|
|
10759
|
-
{ label: "acceptance criterion", source: "\\bAC[0-9]" },
|
|
10903
|
+
{ label: "plan tag", source: "\\blot [A-Z0-9]", allowable: true },
|
|
10904
|
+
{ label: "acceptance criterion", source: "\\bAC[0-9]", allowable: true },
|
|
10760
10905
|
// digits up to a word boundary: `#1234ab`, a colour, is not a ticket; nor a hash glued to a word
|
|
10761
10906
|
// (`abc#123`) or ending a character reference (` `)
|
|
10762
10907
|
{
|
|
10763
10908
|
label: "ticket number",
|
|
10764
10909
|
source: "(^|[^&A-Za-z0-9_])#[0-9]{3,}\\b",
|
|
10765
|
-
leadingBoundary: true
|
|
10910
|
+
leadingBoundary: true,
|
|
10911
|
+
allowable: true
|
|
10766
10912
|
},
|
|
10767
10913
|
{ label: "section citation", source: "\xA7 ?[0-9]" },
|
|
10768
10914
|
{ label: "table citation", source: "Tables? [0-9]" },
|
|
@@ -10795,8 +10941,19 @@ function findReferences(params) {
|
|
|
10795
10941
|
function readReferencePatterns(root) {
|
|
10796
10942
|
const packageJson = readPackageJson(root);
|
|
10797
10943
|
const declared = packageJson.dialecte?.referencePatterns ?? [];
|
|
10944
|
+
const allowed = packageJson.dialecte?.allowReferences ?? [];
|
|
10945
|
+
if (!Array.isArray(allowed) || allowed.some((label) => typeof label !== "string"))
|
|
10946
|
+
throw new Error('dialecte.allowReferences: a list of labels, such as ["ticket number"]');
|
|
10947
|
+
const allowable = GENERIC_REFERENCE_PATTERNS.filter((pattern) => pattern.allowable).map(
|
|
10948
|
+
(pattern) => pattern.label
|
|
10949
|
+
);
|
|
10950
|
+
const refused3 = allowed.filter((label) => !allowable.includes(label));
|
|
10951
|
+
if (refused3.length)
|
|
10952
|
+
throw new Error(
|
|
10953
|
+
`dialecte.allowReferences: ${refused3.join(", ")} can never be allowed (only a tag can); allowable: ${allowable.join(", ")}`
|
|
10954
|
+
);
|
|
10798
10955
|
return [
|
|
10799
|
-
...GENERIC_REFERENCE_PATTERNS,
|
|
10956
|
+
...GENERIC_REFERENCE_PATTERNS.filter((pattern) => !allowed.includes(pattern.label)),
|
|
10800
10957
|
...declared.map((source) => ({
|
|
10801
10958
|
label: `reference declared by ${packageJson.name ?? "the package"}`,
|
|
10802
10959
|
source
|
|
@@ -10818,7 +10975,7 @@ function findLotReferences(params) {
|
|
|
10818
10975
|
`lot ${index + 1} message, line ${reference.line}: ${reference.label} \`${reference.text}\``
|
|
10819
10976
|
);
|
|
10820
10977
|
for (const file of lot.files) {
|
|
10821
|
-
const content =
|
|
10978
|
+
const content = readCommittedBytes(join48(root, file));
|
|
10822
10979
|
if (isBinary(content) || !isReferenceChecked(file)) continue;
|
|
10823
10980
|
for (const reference of findReferences({
|
|
10824
10981
|
text: content.toString("utf8"),
|
|
@@ -10887,8 +11044,8 @@ function planHandover(params) {
|
|
|
10887
11044
|
pendingFiles.push(...files);
|
|
10888
11045
|
return {
|
|
10889
11046
|
message: lot.message,
|
|
10890
|
-
files: files.filter((file) =>
|
|
10891
|
-
deletedFiles: files.filter((file) => !
|
|
11047
|
+
files: files.filter((file) => isPresent(join49(root, file))),
|
|
11048
|
+
deletedFiles: files.filter((file) => !isPresent(join49(root, file)))
|
|
10892
11049
|
};
|
|
10893
11050
|
});
|
|
10894
11051
|
for (const file of changedFiles)
|
|
@@ -10908,20 +11065,23 @@ import { spawnSync as spawnSync15 } from "child_process";
|
|
|
10908
11065
|
import {
|
|
10909
11066
|
cpSync as cpSync2,
|
|
10910
11067
|
existsSync as existsSync50,
|
|
11068
|
+
lstatSync as lstatSync10,
|
|
10911
11069
|
mkdirSync as mkdirSync14,
|
|
10912
|
-
mkdtempSync as
|
|
11070
|
+
mkdtempSync as mkdtempSync5,
|
|
10913
11071
|
readdirSync as readdirSync14,
|
|
11072
|
+
readlinkSync as readlinkSync5,
|
|
10914
11073
|
rmdirSync,
|
|
10915
|
-
rmSync as
|
|
11074
|
+
rmSync as rmSync17,
|
|
11075
|
+
symlinkSync as symlinkSync5,
|
|
10916
11076
|
writeFileSync as writeFileSync21
|
|
10917
11077
|
} from "fs";
|
|
10918
11078
|
import { constants as constants2 } from "os";
|
|
10919
|
-
import { basename as basename7, dirname as
|
|
11079
|
+
import { basename as basename7, dirname as dirname23, isAbsolute as isAbsolute9, join as join56 } from "path";
|
|
10920
11080
|
|
|
10921
11081
|
// src/lib/worktree/copy-node-modules.ts
|
|
10922
11082
|
import { spawnSync as spawnSync11 } from "child_process";
|
|
10923
|
-
import { existsSync as existsSync43, lstatSync as
|
|
10924
|
-
import { dirname as
|
|
11083
|
+
import { existsSync as existsSync43, lstatSync as lstatSync8, readdirSync as readdirSync12, readlinkSync as readlinkSync3, rmSync as rmSync12, symlinkSync as symlinkSync2 } from "fs";
|
|
11084
|
+
import { dirname as dirname19, isAbsolute as isAbsolute6, join as join50, relative as relative6, resolve as resolve15 } from "path";
|
|
10925
11085
|
function copyNodeModules(params) {
|
|
10926
11086
|
const { from, to } = params;
|
|
10927
11087
|
const runCopy = params.runCopy ?? runCp;
|
|
@@ -10932,14 +11092,14 @@ function copyNodeModules(params) {
|
|
|
10932
11092
|
for (const attempt of attempts) {
|
|
10933
11093
|
const result = runCopy(attempt.args);
|
|
10934
11094
|
if (result.signal) {
|
|
10935
|
-
|
|
11095
|
+
rmSync12(to, { recursive: true, force: true });
|
|
10936
11096
|
throw new Error(`copying ${from} was interrupted (${result.signal})`);
|
|
10937
11097
|
}
|
|
10938
11098
|
if (result.status === 0) {
|
|
10939
11099
|
const relinked = relinkEscapingLinks({ from, to });
|
|
10940
11100
|
return { method: attempt.method, relinked };
|
|
10941
11101
|
}
|
|
10942
|
-
|
|
11102
|
+
rmSync12(to, { recursive: true, force: true });
|
|
10943
11103
|
}
|
|
10944
11104
|
throw new Error(`cannot copy ${from} to ${to}`);
|
|
10945
11105
|
}
|
|
@@ -10950,14 +11110,14 @@ function runCp(args) {
|
|
|
10950
11110
|
function relinkEscapingLinks(params) {
|
|
10951
11111
|
const relinked = [];
|
|
10952
11112
|
for (const entry of packageEntries(params.from)) {
|
|
10953
|
-
const source =
|
|
10954
|
-
if (!
|
|
10955
|
-
const target =
|
|
11113
|
+
const source = join50(params.from, entry);
|
|
11114
|
+
if (!lstatSync8(source).isSymbolicLink()) continue;
|
|
11115
|
+
const target = readlinkSync3(source);
|
|
10956
11116
|
if (isAbsolute6(target)) continue;
|
|
10957
|
-
const resolved = resolve15(
|
|
11117
|
+
const resolved = resolve15(dirname19(source), target);
|
|
10958
11118
|
if (!relative6(params.from, resolved).startsWith("..")) continue;
|
|
10959
|
-
const copy =
|
|
10960
|
-
|
|
11119
|
+
const copy = join50(params.to, entry);
|
|
11120
|
+
rmSync12(copy, { force: true });
|
|
10961
11121
|
symlinkSync2(resolved, copy);
|
|
10962
11122
|
relinked.push(entry);
|
|
10963
11123
|
}
|
|
@@ -10967,19 +11127,19 @@ function packageEntries(folder) {
|
|
|
10967
11127
|
if (!existsSync43(folder)) return [];
|
|
10968
11128
|
return readdirSync12(folder).flatMap(function entriesOf(name) {
|
|
10969
11129
|
if (!name.startsWith("@")) return [name];
|
|
10970
|
-
const scope =
|
|
10971
|
-
if (
|
|
11130
|
+
const scope = join50(folder, name);
|
|
11131
|
+
if (lstatSync8(scope).isSymbolicLink()) return [name];
|
|
10972
11132
|
return readdirSync12(scope).map((inner) => `${name}/${inner}`);
|
|
10973
11133
|
});
|
|
10974
11134
|
}
|
|
10975
11135
|
|
|
10976
11136
|
// src/lib/handover/rehearsal-links.ts
|
|
10977
|
-
import { existsSync as existsSync45, mkdirSync as mkdirSync12, rmSync as
|
|
10978
|
-
import { dirname as
|
|
11137
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync12, rmSync as rmSync13, symlinkSync as symlinkSync4, unlinkSync as unlinkSync2 } from "fs";
|
|
11138
|
+
import { dirname as dirname21, isAbsolute as isAbsolute8, resolve as resolve17 } from "path";
|
|
10979
11139
|
|
|
10980
11140
|
// src/lib/worktree/sibling-links.ts
|
|
10981
|
-
import { existsSync as existsSync44, lstatSync as
|
|
10982
|
-
import { dirname as
|
|
11141
|
+
import { existsSync as existsSync44, lstatSync as lstatSync9, readlinkSync as readlinkSync4, realpathSync as realpathSync7, symlinkSync as symlinkSync3 } from "fs";
|
|
11142
|
+
import { dirname as dirname20, isAbsolute as isAbsolute7, join as join51, relative as relative7, resolve as resolve16, sep } from "path";
|
|
10983
11143
|
|
|
10984
11144
|
// src/lib/workspace.constants.ts
|
|
10985
11145
|
var WORKSPACE_MARKERS = ["_commit-plan", ".worktrees"];
|
|
@@ -10989,7 +11149,7 @@ var WORKTREES_FOLDER = ".worktrees";
|
|
|
10989
11149
|
// src/lib/worktree/sibling-links.ts
|
|
10990
11150
|
function linkSiblings(params) {
|
|
10991
11151
|
const { worktree, repository } = params;
|
|
10992
|
-
const worktreesFolder =
|
|
11152
|
+
const worktreesFolder = join51(dirname20(repository), WORKTREES_FOLDER);
|
|
10993
11153
|
const packageJson = readPackageJson(worktree);
|
|
10994
11154
|
const links = [];
|
|
10995
11155
|
for (const section of DEPENDENCY_SECTIONS)
|
|
@@ -11021,11 +11181,11 @@ function linkOutcome(params) {
|
|
|
11021
11181
|
const { link, target } = params;
|
|
11022
11182
|
if (isPresent(link)) return describeExisting({ link, target });
|
|
11023
11183
|
if (!existsSync44(target)) return `skipped: ${target} missing`;
|
|
11024
|
-
const missingParent = topMissingFolder({ path:
|
|
11184
|
+
const missingParent = topMissingFolder({ path: dirname20(link), above: params.worktreesFolder });
|
|
11025
11185
|
if (missingParent) return `skipped: ${missingParent} missing`;
|
|
11026
11186
|
params.beforeLink?.(link);
|
|
11027
11187
|
try {
|
|
11028
|
-
symlinkSync3(relative7(
|
|
11188
|
+
symlinkSync3(relative7(dirname20(link), target), link);
|
|
11029
11189
|
return "created";
|
|
11030
11190
|
} catch (error) {
|
|
11031
11191
|
const code2 = error.code;
|
|
@@ -11035,17 +11195,17 @@ function linkOutcome(params) {
|
|
|
11035
11195
|
}
|
|
11036
11196
|
function topMissingFolder(params) {
|
|
11037
11197
|
let missing;
|
|
11038
|
-
for (let folder = params.path; folder !== params.above && folder !==
|
|
11198
|
+
for (let folder = params.path; folder !== params.above && folder !== dirname20(folder) && !isPresent(folder); folder = dirname20(folder))
|
|
11039
11199
|
missing = folder;
|
|
11040
11200
|
return missing;
|
|
11041
11201
|
}
|
|
11042
11202
|
function describeExisting(params) {
|
|
11043
11203
|
const { link, target } = params;
|
|
11044
|
-
const status =
|
|
11204
|
+
const status = lstatSync9(link);
|
|
11045
11205
|
if (!status.isSymbolicLink()) return `kept: a real ${status.isDirectory() ? "folder" : "file"}`;
|
|
11046
11206
|
if (existsSync44(target) && existsSync44(link) && realpathSync7(link) === realpathSync7(target))
|
|
11047
11207
|
return "present";
|
|
11048
|
-
return `kept: points to ${
|
|
11208
|
+
return `kept: points to ${readlinkSync4(link)}, not ${target}`;
|
|
11049
11209
|
}
|
|
11050
11210
|
function isInside(params) {
|
|
11051
11211
|
const fromFolder = relative7(params.folder, params.path);
|
|
@@ -11075,7 +11235,7 @@ function linkRehearsalSiblings(params) {
|
|
|
11075
11235
|
lines.push(` not linked: ${path} (${target} missing)`);
|
|
11076
11236
|
continue;
|
|
11077
11237
|
}
|
|
11078
|
-
mkdirSync12(
|
|
11238
|
+
mkdirSync12(dirname21(link), { recursive: true });
|
|
11079
11239
|
symlinkSync4(target, link);
|
|
11080
11240
|
links.push(link);
|
|
11081
11241
|
linked.push(path);
|
|
@@ -11085,15 +11245,15 @@ function linkRehearsalSiblings(params) {
|
|
|
11085
11245
|
}
|
|
11086
11246
|
function removeRehearsalFolder(params) {
|
|
11087
11247
|
for (const link of params.links) if (isPresent(link)) unlinkSync2(link);
|
|
11088
|
-
|
|
11248
|
+
rmSync13(params.folder, { recursive: true, force: true });
|
|
11089
11249
|
}
|
|
11090
11250
|
|
|
11091
11251
|
// src/lib/handover/rehearsal-plan.ts
|
|
11092
|
-
import { readFileSync as
|
|
11252
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
11093
11253
|
function planRehearsal(params) {
|
|
11094
11254
|
const root = params.handover.lotsFile.repository;
|
|
11095
11255
|
const trees = listLotTrees({ root, lots: params.handover.lots });
|
|
11096
|
-
const hookText = listCommitHookFiles(root).map((file) =>
|
|
11256
|
+
const hookText = listCommitHookFiles(root).map((file) => readFileSync33(file, "utf8")).join("\n");
|
|
11097
11257
|
const context = {
|
|
11098
11258
|
root,
|
|
11099
11259
|
branch: params.handover.lotsFile.branch,
|
|
@@ -11200,18 +11360,18 @@ function fillReason(params) {
|
|
|
11200
11360
|
}
|
|
11201
11361
|
|
|
11202
11362
|
// src/lib/handover/run-handover-folder.ts
|
|
11203
|
-
import { copyFileSync as copyFileSync3, existsSync as existsSync49, readFileSync as
|
|
11204
|
-
import { join as
|
|
11363
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync49, readFileSync as readFileSync35, rmSync as rmSync16, writeFileSync as writeFileSync20 } from "fs";
|
|
11364
|
+
import { join as join55 } from "path";
|
|
11205
11365
|
|
|
11206
11366
|
// src/lib/handover/check-handover-guards.ts
|
|
11207
11367
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
11208
11368
|
import { existsSync as existsSync47 } from "fs";
|
|
11209
|
-
import { join as
|
|
11369
|
+
import { join as join53 } from "path";
|
|
11210
11370
|
|
|
11211
11371
|
// src/lib/handover/sync-node-modules.ts
|
|
11212
11372
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
11213
|
-
import { existsSync as existsSync46, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as
|
|
11214
|
-
import { join as
|
|
11373
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync34, rmSync as rmSync14, writeFileSync as writeFileSync18 } from "fs";
|
|
11374
|
+
import { join as join52 } from "path";
|
|
11215
11375
|
async function syncNodeModules(params) {
|
|
11216
11376
|
const { root, clock } = params;
|
|
11217
11377
|
const lockChanged = spawnSync12("git", ["diff", "--cached", "--quiet", "--", PACKAGE_LOCK_FILE2], { cwd: root }).status === 1;
|
|
@@ -11221,23 +11381,23 @@ async function syncNodeModules(params) {
|
|
|
11221
11381
|
const startedAt = clock.now();
|
|
11222
11382
|
const files = [PACKAGE_LOCK_FILE2, PACKAGE_MANIFEST_FILE].map((file) => ({
|
|
11223
11383
|
file,
|
|
11224
|
-
path:
|
|
11225
|
-
working: existsSync46(
|
|
11384
|
+
path: join52(root, file),
|
|
11385
|
+
working: existsSync46(join52(root, file)) ? readFileSync34(join52(root, file)) : void 0,
|
|
11226
11386
|
staged: stagedBytes({ root, file })
|
|
11227
11387
|
}));
|
|
11228
11388
|
const overwritten = files.filter((entry) => entry.staged !== void 0);
|
|
11229
11389
|
const backup = installBackupPath(root);
|
|
11230
11390
|
mkdirSync13(backup, { recursive: true });
|
|
11231
11391
|
for (const { file, working, staged } of overwritten) {
|
|
11232
|
-
if (working === void 0) writeFileSync18(
|
|
11233
|
-
else writeFileSync18(
|
|
11234
|
-
writeFileSync18(
|
|
11392
|
+
if (working === void 0) writeFileSync18(join52(backup, `${file}${ABSENT_SUFFIX}`), "");
|
|
11393
|
+
else writeFileSync18(join52(backup, file), working);
|
|
11394
|
+
writeFileSync18(join52(backup, `${file}${STAGED_SUFFIX}`), staged ?? "");
|
|
11235
11395
|
}
|
|
11236
11396
|
function restore() {
|
|
11237
11397
|
for (const { path, working } of overwritten)
|
|
11238
|
-
if (working === void 0)
|
|
11398
|
+
if (working === void 0) rmSync14(path, { force: true });
|
|
11239
11399
|
else writeFileSync18(path, working);
|
|
11240
|
-
|
|
11400
|
+
rmSync14(backup, { recursive: true, force: true });
|
|
11241
11401
|
}
|
|
11242
11402
|
const removeSignalHook = onSignalExit(restore);
|
|
11243
11403
|
let changed;
|
|
@@ -11250,7 +11410,7 @@ async function syncNodeModules(params) {
|
|
|
11250
11410
|
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`
|
|
11251
11411
|
};
|
|
11252
11412
|
changed = overwritten.find(
|
|
11253
|
-
({ path, staged }) => !existsSync46(path) || !
|
|
11413
|
+
({ path, staged }) => !existsSync46(path) || !readFileSync34(path).equals(staged ?? Buffer.alloc(0))
|
|
11254
11414
|
)?.file;
|
|
11255
11415
|
} finally {
|
|
11256
11416
|
restore();
|
|
@@ -11272,8 +11432,8 @@ function restoreLeftoverBackup(root) {
|
|
|
11272
11432
|
if (!existsSync46(backup)) return void 0;
|
|
11273
11433
|
const names = readdirSync13(backup).filter((name) => name.endsWith(STAGED_SUFFIX)).map((name) => name.slice(0, -STAGED_SUFFIX.length));
|
|
11274
11434
|
const stillStaged2 = names.every((name) => {
|
|
11275
|
-
const path =
|
|
11276
|
-
return existsSync46(path) &&
|
|
11435
|
+
const path = join52(root, name);
|
|
11436
|
+
return existsSync46(path) && readFileSync34(path).equals(readFileSync34(join52(backup, `${name}${STAGED_SUFFIX}`)));
|
|
11277
11437
|
});
|
|
11278
11438
|
if (!stillStaged2)
|
|
11279
11439
|
return {
|
|
@@ -11281,10 +11441,10 @@ function restoreLeftoverBackup(root) {
|
|
|
11281
11441
|
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}`
|
|
11282
11442
|
};
|
|
11283
11443
|
for (const name of names)
|
|
11284
|
-
if (existsSync46(
|
|
11285
|
-
|
|
11286
|
-
else writeFileSync18(
|
|
11287
|
-
|
|
11444
|
+
if (existsSync46(join52(backup, `${name}${ABSENT_SUFFIX}`)))
|
|
11445
|
+
rmSync14(join52(root, name), { force: true });
|
|
11446
|
+
else writeFileSync18(join52(root, name), readFileSync34(join52(backup, name)));
|
|
11447
|
+
rmSync14(backup, { recursive: true, force: true });
|
|
11288
11448
|
return {
|
|
11289
11449
|
ok: true,
|
|
11290
11450
|
detail: `${names.join(", ")} restored from ${backup}, which an interrupted install left`
|
|
@@ -11310,8 +11470,8 @@ function readStagedLockPackages(root) {
|
|
|
11310
11470
|
return Object.entries(lock.packages ?? {}).filter(([path]) => path.startsWith("node_modules/"));
|
|
11311
11471
|
}
|
|
11312
11472
|
function installedVersion2(params) {
|
|
11313
|
-
const manifest =
|
|
11314
|
-
return existsSync46(manifest) ? JSON.parse(
|
|
11473
|
+
const manifest = join52(params.root, params.path, "package.json");
|
|
11474
|
+
return existsSync46(manifest) ? JSON.parse(readFileSync34(manifest, "utf8")).version : void 0;
|
|
11315
11475
|
}
|
|
11316
11476
|
function nodeModulesAgainstStagedLock(root) {
|
|
11317
11477
|
return readStagedLockPackages(root).flatMap(function differs([path, entry]) {
|
|
@@ -11363,13 +11523,13 @@ function checkHandoverGuards(params) {
|
|
|
11363
11523
|
ok: false,
|
|
11364
11524
|
detail: `${HANDOVER_FILES.mergesHash} is missing: write it again with --rehash after a review`
|
|
11365
11525
|
};
|
|
11366
|
-
const mergesAsReviewed = handover.mergesHash === void 0 || hashFile2(
|
|
11526
|
+
const mergesAsReviewed = handover.mergesHash === void 0 || hashFile2(join53(handover.folder, HANDOVER_FILES.merges)) === handover.mergesHash;
|
|
11367
11527
|
if (!mergesAsReviewed)
|
|
11368
11528
|
return {
|
|
11369
11529
|
ok: false,
|
|
11370
11530
|
detail: `${HANDOVER_FILES.merges} changed since the hand-over was written: \`dialecte handover --rehash <lots.json>\` after a review`
|
|
11371
11531
|
};
|
|
11372
|
-
return hashFile2(
|
|
11532
|
+
return hashFile2(join53(handover.folder, HANDOVER_FILES.lots)) === handover.lotsHash ? { ok: true, detail: `${lots.length} lot(s) as reviewed` } : {
|
|
11373
11533
|
ok: false,
|
|
11374
11534
|
detail: "lots.json changed since the hand-over was written: `dialecte handover --rehash <lots.json>` after a review"
|
|
11375
11535
|
};
|
|
@@ -11461,8 +11621,8 @@ function checkHandoverGuards(params) {
|
|
|
11461
11621
|
check: function filesAsReviewed() {
|
|
11462
11622
|
const differing = handover.snapshotLines.filter(function differs(line) {
|
|
11463
11623
|
const [hash, ...pathParts] = line.split(" ");
|
|
11464
|
-
const path =
|
|
11465
|
-
return !
|
|
11624
|
+
const path = join53(root, pathParts.join(" "));
|
|
11625
|
+
return !isPresent(path) || hashFile2(path) !== hash;
|
|
11466
11626
|
});
|
|
11467
11627
|
return differing.length ? {
|
|
11468
11628
|
ok: false,
|
|
@@ -11475,7 +11635,7 @@ function checkHandoverGuards(params) {
|
|
|
11475
11635
|
name: "deleted",
|
|
11476
11636
|
check: function deletedStayDeleted() {
|
|
11477
11637
|
const deleted = lots.flatMap((lot) => lot.deletedFiles);
|
|
11478
|
-
const back = deleted.filter((file) =>
|
|
11638
|
+
const back = deleted.filter((file) => isPresent(join53(root, file)));
|
|
11479
11639
|
return back.length ? { ok: false, detail: "deleted in the snapshot and there again", lines: back } : { ok: true, detail: `${deleted.length} file(s) absent` };
|
|
11480
11640
|
}
|
|
11481
11641
|
},
|
|
@@ -11607,9 +11767,9 @@ function resolveCommit(params) {
|
|
|
11607
11767
|
}
|
|
11608
11768
|
|
|
11609
11769
|
// src/lib/handover/commit-lots.ts
|
|
11610
|
-
import { appendFileSync, mkdtempSync as
|
|
11611
|
-
import { tmpdir as
|
|
11612
|
-
import { dirname as
|
|
11770
|
+
import { appendFileSync, mkdtempSync as mkdtempSync4, rmSync as rmSync15, writeFileSync as writeFileSync19 } from "fs";
|
|
11771
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
11772
|
+
import { dirname as dirname22, join as join54 } from "path";
|
|
11613
11773
|
|
|
11614
11774
|
// src/lib/progress/heartbeat.ts
|
|
11615
11775
|
function startHeartbeat(params) {
|
|
@@ -12144,7 +12304,7 @@ async function commitLots(params) {
|
|
|
12144
12304
|
});
|
|
12145
12305
|
hookView.end();
|
|
12146
12306
|
const hookRan = commit.output !== "" || hooked;
|
|
12147
|
-
if (!hookRan)
|
|
12307
|
+
if (!hookRan) rmSync15(dirname22(hookLog), { recursive: true, force: true });
|
|
12148
12308
|
const hookOutcome = hookRan ? hookOutcomeLines({
|
|
12149
12309
|
output: commit.output,
|
|
12150
12310
|
passed: commit.exitCode === 0,
|
|
@@ -12216,7 +12376,7 @@ function recordedHookStep(step) {
|
|
|
12216
12376
|
};
|
|
12217
12377
|
}
|
|
12218
12378
|
function createHookLog(params) {
|
|
12219
|
-
const path =
|
|
12379
|
+
const path = join54(mkdtempSync4(join54(tmpdir4(), HOOK_LOG_FOLDER_PREFIX)), `lot-${params.lot}.log`);
|
|
12220
12380
|
writeFileSync19(path, "");
|
|
12221
12381
|
return path;
|
|
12222
12382
|
}
|
|
@@ -12280,6 +12440,7 @@ async function runHandoverFolder(params) {
|
|
|
12280
12440
|
lots,
|
|
12281
12441
|
commits,
|
|
12282
12442
|
cliPath: params.cliPath,
|
|
12443
|
+
probe: params.probe,
|
|
12283
12444
|
// the repository's hand-over is done only by a real run that committed every lot
|
|
12284
12445
|
done: !rehearsal && commits.length === lots.length
|
|
12285
12446
|
});
|
|
@@ -12297,10 +12458,10 @@ async function runHandoverFolder(params) {
|
|
|
12297
12458
|
return committed ? 0 : 1;
|
|
12298
12459
|
}
|
|
12299
12460
|
function archiveLotFile(params) {
|
|
12300
|
-
const source =
|
|
12301
|
-
const target =
|
|
12461
|
+
const source = join55(params.root, LOT_FILE);
|
|
12462
|
+
const target = join55(params.folder, ARCHIVED_LOT_FILE);
|
|
12302
12463
|
if (!existsSync49(source) || existsSync49(target)) return void 0;
|
|
12303
|
-
if (isEmptyDeclaration(
|
|
12464
|
+
if (isEmptyDeclaration(readFileSync35(source, "utf8"))) return void 0;
|
|
12304
12465
|
copyFileSync3(source, target);
|
|
12305
12466
|
writeFileSync20(source, EMPTY_LOT_DECLARATION);
|
|
12306
12467
|
return target;
|
|
@@ -12315,8 +12476,8 @@ function isEmptyDeclaration(text) {
|
|
|
12315
12476
|
}
|
|
12316
12477
|
function releaseLock(params) {
|
|
12317
12478
|
const lockPath = handoverLockPath(params.root);
|
|
12318
|
-
if (existsSync49(lockPath) &&
|
|
12319
|
-
|
|
12479
|
+
if (existsSync49(lockPath) && readFileSync35(lockPath, "utf8").trim() === join55(params.folder, COMMIT_SCRIPT_FILE))
|
|
12480
|
+
rmSync16(lockPath);
|
|
12320
12481
|
}
|
|
12321
12482
|
|
|
12322
12483
|
// src/lib/handover/rehearse-handover.ts
|
|
@@ -12324,7 +12485,7 @@ async function rehearseHandover(params) {
|
|
|
12324
12485
|
const { handover, write } = params;
|
|
12325
12486
|
const decisions = decideLots({ handover, full: params.full ?? false });
|
|
12326
12487
|
writeFileSync21(
|
|
12327
|
-
|
|
12488
|
+
join56(handover.folder, REHEARSAL_DECISIONS_FILE),
|
|
12328
12489
|
`${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), lots: decisions }, null, 2)}
|
|
12329
12490
|
`
|
|
12330
12491
|
);
|
|
@@ -12342,6 +12503,7 @@ async function rehearseHandover(params) {
|
|
|
12342
12503
|
write,
|
|
12343
12504
|
clock: params.clock,
|
|
12344
12505
|
colour: params.colour,
|
|
12506
|
+
probe: params.probe,
|
|
12345
12507
|
progress: params.progress,
|
|
12346
12508
|
tty: params.tty,
|
|
12347
12509
|
columns: params.columns,
|
|
@@ -12355,9 +12517,9 @@ async function rehearseHandover(params) {
|
|
|
12355
12517
|
clock: params.clock
|
|
12356
12518
|
});
|
|
12357
12519
|
const repository = handover.lotsFile.repository;
|
|
12358
|
-
const folder =
|
|
12359
|
-
const clone =
|
|
12360
|
-
const hookTemporary =
|
|
12520
|
+
const folder = mkdtempSync5(join56(params.scratchRoot, REHEARSAL_FOLDER_PREFIX));
|
|
12521
|
+
const clone = join56(folder, basename7(repository));
|
|
12522
|
+
const hookTemporary = join56(folder, REHEARSAL_TEMPORARY_FOLDER);
|
|
12361
12523
|
mkdirSync14(hookTemporary);
|
|
12362
12524
|
write(`rehearsal in ${clone}`);
|
|
12363
12525
|
const links = [];
|
|
@@ -12396,6 +12558,7 @@ async function rehearseHandover(params) {
|
|
|
12396
12558
|
write,
|
|
12397
12559
|
clock: params.clock,
|
|
12398
12560
|
colour: params.colour,
|
|
12561
|
+
probe: params.probe,
|
|
12399
12562
|
progress,
|
|
12400
12563
|
tty: params.tty,
|
|
12401
12564
|
columns: params.columns,
|
|
@@ -12454,12 +12617,12 @@ function prepareClone(params) {
|
|
|
12454
12617
|
const { repository, clone, write } = params;
|
|
12455
12618
|
const head = readGit({ root: repository, args: ["rev-parse", "HEAD"] }).trim();
|
|
12456
12619
|
readGit({
|
|
12457
|
-
root:
|
|
12620
|
+
root: dirname23(clone),
|
|
12458
12621
|
args: ["clone", "-q", "--shared", "--no-checkout", repository, clone]
|
|
12459
12622
|
});
|
|
12460
12623
|
readGit({ root: clone, args: ["checkout", "-q", "-B", params.branch, head] });
|
|
12461
12624
|
writeFileSync21(
|
|
12462
|
-
|
|
12625
|
+
join56(clone, ".git", REHEARSAL_MARKER_FILE),
|
|
12463
12626
|
`${JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
12464
12627
|
`
|
|
12465
12628
|
);
|
|
@@ -12469,14 +12632,17 @@ function prepareClone(params) {
|
|
|
12469
12632
|
}
|
|
12470
12633
|
const changed = listChangedFiles({ root: repository, withDeleted: true });
|
|
12471
12634
|
for (const file of changed) {
|
|
12472
|
-
const source =
|
|
12473
|
-
const target =
|
|
12474
|
-
if (
|
|
12475
|
-
mkdirSync14(
|
|
12476
|
-
|
|
12635
|
+
const source = join56(repository, file);
|
|
12636
|
+
const target = join56(clone, file);
|
|
12637
|
+
if (isPresent(source)) {
|
|
12638
|
+
mkdirSync14(dirname23(target), { recursive: true });
|
|
12639
|
+
if (lstatSync10(source).isSymbolicLink()) {
|
|
12640
|
+
rmSync17(target, { force: true });
|
|
12641
|
+
symlinkSync5(readlinkSync5(source), target);
|
|
12642
|
+
} else cpSync2(source, target);
|
|
12477
12643
|
} else {
|
|
12478
|
-
|
|
12479
|
-
removeEmptiedFolders({ clone, folder:
|
|
12644
|
+
rmSync17(target, { force: true });
|
|
12645
|
+
removeEmptiedFolders({ clone, folder: dirname23(target) });
|
|
12480
12646
|
}
|
|
12481
12647
|
}
|
|
12482
12648
|
write(` working tree: ${changed.length} changed file(s) on top of ${head.slice(0, 12)}`);
|
|
@@ -12485,14 +12651,14 @@ function prepareClone(params) {
|
|
|
12485
12651
|
readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
|
|
12486
12652
|
else if (hooks.configured) {
|
|
12487
12653
|
if (existsSync50(hooks.folder))
|
|
12488
|
-
cpSync2(hooks.folder,
|
|
12654
|
+
cpSync2(hooks.folder, join56(clone, hooks.configured), { recursive: true });
|
|
12489
12655
|
readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
|
|
12490
12656
|
} else if (existsSync50(hooks.folder))
|
|
12491
|
-
cpSync2(hooks.folder,
|
|
12657
|
+
cpSync2(hooks.folder, join56(clone, ".git", "hooks"), { recursive: true });
|
|
12492
12658
|
write(` hooks: ${hooks.configured ?? "git hooks folder"} copied`);
|
|
12493
|
-
const nodeModules =
|
|
12659
|
+
const nodeModules = join56(repository, "node_modules");
|
|
12494
12660
|
if (existsSync50(nodeModules)) {
|
|
12495
|
-
const copy = copyNodeModules({ from: nodeModules, to:
|
|
12661
|
+
const copy = copyNodeModules({ from: nodeModules, to: join56(clone, "node_modules") });
|
|
12496
12662
|
write(
|
|
12497
12663
|
` node_modules: ${copy.method}${copy.relinked.length ? `, ${copy.relinked.length} link(s) re-pointed` : ""}`
|
|
12498
12664
|
);
|
|
@@ -12500,12 +12666,36 @@ function prepareClone(params) {
|
|
|
12500
12666
|
spawnSync15("git", ["update-index", "-q", "--refresh"], { cwd: clone });
|
|
12501
12667
|
}
|
|
12502
12668
|
function removeEmptiedFolders(params) {
|
|
12503
|
-
for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) && existsSync50(folder); folder =
|
|
12669
|
+
for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) && existsSync50(folder); folder = dirname23(folder)) {
|
|
12504
12670
|
if (readdirSync14(folder).length) return;
|
|
12505
12671
|
rmdirSync(folder);
|
|
12506
12672
|
}
|
|
12507
12673
|
}
|
|
12508
12674
|
|
|
12675
|
+
// src/lib/handover/repository-cli-probe.ts
|
|
12676
|
+
import { spawnSync as spawnSync16 } from "child_process";
|
|
12677
|
+
import { closeSync as closeSync2, mkdtempSync as mkdtempSync6, openSync as openSync2, readFileSync as readFileSync36, rmSync as rmSync18 } from "fs";
|
|
12678
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
12679
|
+
import { join as join57 } from "path";
|
|
12680
|
+
function probeRepositoryCli(params) {
|
|
12681
|
+
const [command, ...args] = HANDOVER_PROBE_COMMAND;
|
|
12682
|
+
const folder = mkdtempSync6(join57(tmpdir5(), HANDOVER_PROBE_FOLDER_PREFIX));
|
|
12683
|
+
const answerPath = join57(folder, "answer.txt");
|
|
12684
|
+
const answer = openSync2(answerPath, "w");
|
|
12685
|
+
try {
|
|
12686
|
+
const probe = spawnSync16(command, args, {
|
|
12687
|
+
cwd: params.root,
|
|
12688
|
+
stdio: ["ignore", answer, "ignore"],
|
|
12689
|
+
timeout: params.timeout,
|
|
12690
|
+
killSignal: "SIGKILL"
|
|
12691
|
+
});
|
|
12692
|
+
return probe.status === 0 && readFileSync36(answerPath, "utf8").includes(HANDOVER_PROBE_ANSWER);
|
|
12693
|
+
} finally {
|
|
12694
|
+
closeSync2(answer);
|
|
12695
|
+
rmSync18(folder, { recursive: true, force: true });
|
|
12696
|
+
}
|
|
12697
|
+
}
|
|
12698
|
+
|
|
12509
12699
|
// src/lib/legend/legend.constants.ts
|
|
12510
12700
|
var VERDICT_TERMS = [
|
|
12511
12701
|
{
|
|
@@ -12732,12 +12922,12 @@ function renderLegend(params) {
|
|
|
12732
12922
|
|
|
12733
12923
|
// src/lib/workspace.ts
|
|
12734
12924
|
import { existsSync as existsSync51 } from "fs";
|
|
12735
|
-
import { dirname as
|
|
12925
|
+
import { dirname as dirname24, join as join58 } from "path";
|
|
12736
12926
|
function findWorkspace(cwd) {
|
|
12737
12927
|
let folder = cwd;
|
|
12738
12928
|
for (; ; ) {
|
|
12739
|
-
if (WORKSPACE_MARKERS.some((marker) => existsSync51(
|
|
12740
|
-
const parent =
|
|
12929
|
+
if (WORKSPACE_MARKERS.some((marker) => existsSync51(join58(folder, marker)))) return folder;
|
|
12930
|
+
const parent = dirname24(folder);
|
|
12741
12931
|
if (parent === folder) return void 0;
|
|
12742
12932
|
folder = parent;
|
|
12743
12933
|
}
|
|
@@ -12759,6 +12949,7 @@ async function run8(argv) {
|
|
|
12759
12949
|
clock: createSystemClock(),
|
|
12760
12950
|
colour,
|
|
12761
12951
|
columns,
|
|
12952
|
+
probe: probeRepositoryCli,
|
|
12762
12953
|
scratchRoot: rehearsalScratchRoot({
|
|
12763
12954
|
platform: process.platform,
|
|
12764
12955
|
systemTemporaryFolder: tmpdir6()
|
|
@@ -12771,7 +12962,8 @@ async function run8(argv) {
|
|
|
12771
12962
|
argv,
|
|
12772
12963
|
cliPath: realpathSync8(process.argv[1]),
|
|
12773
12964
|
colour,
|
|
12774
|
-
columns
|
|
12965
|
+
columns,
|
|
12966
|
+
probe: probeRepositoryCli
|
|
12775
12967
|
});
|
|
12776
12968
|
(result.exitCode === 0 ? console.log : console.error)(result.output);
|
|
12777
12969
|
if (result.exitCode !== 0) process.exit(result.exitCode);
|
|
@@ -12791,8 +12983,8 @@ function runHandover(params) {
|
|
|
12791
12983
|
const absoluteLotsPath = resolve18(lotsPath);
|
|
12792
12984
|
const lotsFile = readLotsFile(absoluteLotsPath);
|
|
12793
12985
|
if (typeof lotsFile === "string") return usage(`handover: ${lotsFile}`);
|
|
12794
|
-
const out = resolve18(getArg(argv, "out") ??
|
|
12795
|
-
const scriptPath =
|
|
12986
|
+
const out = resolve18(getArg(argv, "out") ?? dirname25(absoluteLotsPath));
|
|
12987
|
+
const scriptPath = join59(out, COMMIT_SCRIPT_FILE);
|
|
12796
12988
|
if (existsSync52(scriptPath) && !hasFlag(argv, "rehash"))
|
|
12797
12989
|
return usage(
|
|
12798
12990
|
`handover: ${scriptPath} exists: pass --rehash to take the snapshot again after an edit`
|
|
@@ -12824,7 +13016,8 @@ function runHandover(params) {
|
|
|
12824
13016
|
lots: plan.lots,
|
|
12825
13017
|
commits: [],
|
|
12826
13018
|
cliPath: params.cliPath,
|
|
12827
|
-
probeTimeout: params.probeTimeout
|
|
13019
|
+
probeTimeout: params.probeTimeout,
|
|
13020
|
+
probe: params.probe
|
|
12828
13021
|
});
|
|
12829
13022
|
if (hasFlag(argv, "json"))
|
|
12830
13023
|
return {
|
|
@@ -12870,6 +13063,7 @@ async function runHandoverRun(params) {
|
|
|
12870
13063
|
write,
|
|
12871
13064
|
clock: params.clock,
|
|
12872
13065
|
colour: params.colour,
|
|
13066
|
+
probe: params.probe,
|
|
12873
13067
|
scratchRoot: params.scratchRoot,
|
|
12874
13068
|
keep: hasFlag(argv, "keep"),
|
|
12875
13069
|
progress,
|
|
@@ -12886,6 +13080,7 @@ async function runHandoverRun(params) {
|
|
|
12886
13080
|
write,
|
|
12887
13081
|
clock: params.clock,
|
|
12888
13082
|
colour: params.colour,
|
|
13083
|
+
probe: params.probe,
|
|
12889
13084
|
progress,
|
|
12890
13085
|
tty: live.tty,
|
|
12891
13086
|
columns: params.columns ?? live.columns,
|
|
@@ -12899,7 +13094,7 @@ async function runHandoverRun(params) {
|
|
|
12899
13094
|
function runHandoverList(params) {
|
|
12900
13095
|
const { argv, cwd } = params;
|
|
12901
13096
|
const workspace = findWorkspace(cwd);
|
|
12902
|
-
const commitPlan = workspace &&
|
|
13097
|
+
const commitPlan = workspace && join59(workspace, COMMIT_PLAN_FOLDER);
|
|
12903
13098
|
const root = resolve18(
|
|
12904
13099
|
cwd,
|
|
12905
13100
|
getArg(argv, "root") ?? (commitPlan && existsSync52(commitPlan) ? commitPlan : cwd)
|
|
@@ -12942,16 +13137,16 @@ function refused(reasons) {
|
|
|
12942
13137
|
}
|
|
12943
13138
|
|
|
12944
13139
|
// src/commands/lot.ts
|
|
12945
|
-
import { existsSync as existsSync54, mkdirSync as mkdirSync15, readFileSync as
|
|
12946
|
-
import { dirname as
|
|
13140
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync15, readFileSync as readFileSync37, writeFileSync as writeFileSync22 } from "fs";
|
|
13141
|
+
import { dirname as dirname27, join as join61 } from "path";
|
|
12947
13142
|
|
|
12948
13143
|
// src/lib/package-root.ts
|
|
12949
13144
|
import { existsSync as existsSync53 } from "fs";
|
|
12950
|
-
import { dirname as
|
|
13145
|
+
import { dirname as dirname26, join as join60 } from "path";
|
|
12951
13146
|
function packageRootOf(cwd) {
|
|
12952
|
-
for (let folder = cwd; ; folder =
|
|
12953
|
-
if (existsSync53(
|
|
12954
|
-
if (
|
|
13147
|
+
for (let folder = cwd; ; folder = dirname26(folder)) {
|
|
13148
|
+
if (existsSync53(join60(folder, "package.json"))) return folder;
|
|
13149
|
+
if (dirname26(folder) === folder) return void 0;
|
|
12955
13150
|
}
|
|
12956
13151
|
}
|
|
12957
13152
|
|
|
@@ -12983,11 +13178,11 @@ function runLot(params) {
|
|
|
12983
13178
|
};
|
|
12984
13179
|
const root = packageRootOf(params.cwd);
|
|
12985
13180
|
if (!root) return { exitCode: 1, output: `lot: no package.json at or above ${params.cwd}` };
|
|
12986
|
-
const path =
|
|
13181
|
+
const path = join61(root, LOT_FILE);
|
|
12987
13182
|
let read = {};
|
|
12988
13183
|
if (existsSync54(path))
|
|
12989
13184
|
try {
|
|
12990
|
-
read = JSON.parse(
|
|
13185
|
+
read = JSON.parse(readFileSync37(path, "utf8"));
|
|
12991
13186
|
} catch (error) {
|
|
12992
13187
|
return {
|
|
12993
13188
|
exitCode: 1,
|
|
@@ -13012,7 +13207,7 @@ function runLot(params) {
|
|
|
13012
13207
|
declaration.gone = known ? entries.map((entry) => entry.file === file ? { file, reason } : entry) : [...entries, { file, reason }];
|
|
13013
13208
|
} else if (verb === "mutation") declaration.mutation = words[0];
|
|
13014
13209
|
else declaration.tdd = `exempt: ${words[0]}`;
|
|
13015
|
-
mkdirSync15(
|
|
13210
|
+
mkdirSync15(dirname27(path), { recursive: true });
|
|
13016
13211
|
writeFileSync22(path, `${JSON.stringify(declaration, null, " ")}
|
|
13017
13212
|
`);
|
|
13018
13213
|
return { exitCode: 0, output: `lot: ${path} written` };
|
|
@@ -13095,16 +13290,78 @@ function memberLine(member) {
|
|
|
13095
13290
|
return member.summary ? ` ${member.name}() ${shortSummary(member.summary)}` : ` ${member.name}()`;
|
|
13096
13291
|
}
|
|
13097
13292
|
|
|
13293
|
+
// src/lib/namespace-of.ts
|
|
13294
|
+
function namespaceOf(packageName3) {
|
|
13295
|
+
const name = packageName3.split("/").pop() || "dialecte";
|
|
13296
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
13297
|
+
}
|
|
13298
|
+
|
|
13299
|
+
// src/lib/api/installed-bindings.constants.ts
|
|
13300
|
+
var VERSION_SUBPATH_PATTERN = /^\.\/[^/*]+$/;
|
|
13301
|
+
var TEST_ENTRY = "test";
|
|
13302
|
+
var NO_DIALECTE_INSTALLED = "no dialecte installed here (a dependency built on @dialecte/core exporting ./<version> with ./<version>/test): pass --namespace <Name> --entry <module>\n";
|
|
13303
|
+
|
|
13304
|
+
// src/lib/api/installed-bindings.ts
|
|
13305
|
+
function findInstalledBindings(params) {
|
|
13306
|
+
return dependencyNames(params.cwd).flatMap(function bindingsOf(name) {
|
|
13307
|
+
const folder = findInstalledPackage({ cwd: params.cwd, name });
|
|
13308
|
+
const manifest = folder ? readManifest(folder) : void 0;
|
|
13309
|
+
if (!manifest?.name || !isBuiltOnCore(manifest)) return [];
|
|
13310
|
+
const packageName3 = manifest.name;
|
|
13311
|
+
return versionsOf(manifest).map((version) => ({
|
|
13312
|
+
packageName: packageName3,
|
|
13313
|
+
version,
|
|
13314
|
+
binding: {
|
|
13315
|
+
kind: "namespace",
|
|
13316
|
+
name: namespaceOf(packageName3),
|
|
13317
|
+
import: `${packageName3}/${version}`
|
|
13318
|
+
}
|
|
13319
|
+
}));
|
|
13320
|
+
});
|
|
13321
|
+
}
|
|
13322
|
+
function versionsOf(manifest) {
|
|
13323
|
+
const subpaths = typeof manifest.exports === "object" ? Object.keys(manifest.exports) : [];
|
|
13324
|
+
return subpaths.filter((subpath) => VERSION_SUBPATH_PATTERN.test(subpath)).filter((subpath) => subpaths.includes(`${subpath}/${TEST_ENTRY}`)).map((subpath) => subpath.slice(2));
|
|
13325
|
+
}
|
|
13326
|
+
function chooseInstalledBinding(params) {
|
|
13327
|
+
if (params.bindings.length === 0) return { kind: "output", message: NO_DIALECTE_INSTALLED };
|
|
13328
|
+
const matching = params.bindings.filter(
|
|
13329
|
+
(binding) => (params.packageName === void 0 || binding.packageName === params.packageName) && (params.version === void 0 || binding.version === params.version)
|
|
13330
|
+
);
|
|
13331
|
+
if (matching.length === 1) return { kind: "binding", binding: matching[0] };
|
|
13332
|
+
if (matching.length === 0) {
|
|
13333
|
+
const named = [
|
|
13334
|
+
...params.packageName === void 0 ? [] : [`--package ${params.packageName}`],
|
|
13335
|
+
...params.version === void 0 ? [] : [`--version ${params.version}`]
|
|
13336
|
+
].join(" ");
|
|
13337
|
+
return {
|
|
13338
|
+
kind: "output",
|
|
13339
|
+
message: `no installed dialecte matches ${named}; installed:
|
|
13340
|
+
${listLines(params.bindings)}`
|
|
13341
|
+
};
|
|
13342
|
+
}
|
|
13343
|
+
return {
|
|
13344
|
+
kind: "output",
|
|
13345
|
+
message: `several dialectes are installed: pass --package <name> [--version <v>]
|
|
13346
|
+
${listLines(matching)}`
|
|
13347
|
+
};
|
|
13348
|
+
}
|
|
13349
|
+
function listLines(bindings) {
|
|
13350
|
+
return bindings.map((binding) => ` ${binding.packageName} --version ${binding.version}
|
|
13351
|
+
`).join("");
|
|
13352
|
+
}
|
|
13353
|
+
|
|
13098
13354
|
// src/commands/members.constants.ts
|
|
13099
13355
|
var MEMBERS_VALUE_OPTIONS = [
|
|
13100
13356
|
"namespace",
|
|
13101
13357
|
"entry",
|
|
13358
|
+
"package",
|
|
13102
13359
|
"version",
|
|
13103
13360
|
"tsconfig",
|
|
13104
13361
|
"constants-dir",
|
|
13105
13362
|
"out"
|
|
13106
13363
|
];
|
|
13107
|
-
var MEMBERS_USAGE = "usage: dialecte members <expression> [--json] [--version <v>] (in an app
|
|
13364
|
+
var MEMBERS_USAGE = "usage: dialecte members <expression> [--json] [--package <name>] [--version <v>] (in an app the installed dialecte is found; --namespace <Name> --entry <module exporting it> override)";
|
|
13108
13365
|
|
|
13109
13366
|
// src/commands/skills.constants.ts
|
|
13110
13367
|
var METHOD_DISCOVERY_DEPTH = 3;
|
|
@@ -13130,12 +13387,16 @@ function readMemberEntries(params) {
|
|
|
13130
13387
|
if (missing) return { kind: "output", output: missing };
|
|
13131
13388
|
const { argv, cwd } = params;
|
|
13132
13389
|
const [expression] = positionalArguments({ argv, valueOptions: MEMBERS_VALUE_OPTIONS });
|
|
13133
|
-
const
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
`, exitCode: 2 }
|
|
13390
|
+
const usage4 = {
|
|
13391
|
+
kind: "output",
|
|
13392
|
+
output: { output: `${MEMBERS_USAGE}
|
|
13393
|
+
`, exitCode: 2 }
|
|
13394
|
+
};
|
|
13395
|
+
if (!expression) return usage4;
|
|
13396
|
+
const binding = readBinding({ argv, cwd });
|
|
13397
|
+
if (binding.kind === "output") return binding;
|
|
13137
13398
|
const entries = discoverMethods({
|
|
13138
|
-
entrySource: discoveryEntry(
|
|
13399
|
+
entrySource: discoveryEntry(binding.binding),
|
|
13139
13400
|
tsconfig: tsconfigOf(argv, cwd),
|
|
13140
13401
|
root: cwd,
|
|
13141
13402
|
// one level below the expression, so each group it holds is counted
|
|
@@ -13143,6 +13404,17 @@ function readMemberEntries(params) {
|
|
|
13143
13404
|
});
|
|
13144
13405
|
return { kind: "entries", entries, expression };
|
|
13145
13406
|
}
|
|
13407
|
+
function readBinding(params) {
|
|
13408
|
+
const [target] = resolveTargets(params.argv, params.cwd);
|
|
13409
|
+
if (target) return { kind: "binding", binding: target.binding };
|
|
13410
|
+
const choice = chooseInstalledBinding({
|
|
13411
|
+
bindings: findInstalledBindings({ cwd: params.cwd }),
|
|
13412
|
+
packageName: getArg(params.argv, "package"),
|
|
13413
|
+
version: getArg(params.argv, "version")
|
|
13414
|
+
});
|
|
13415
|
+
if (choice.kind === "binding") return { kind: "binding", binding: choice.binding.binding };
|
|
13416
|
+
return { kind: "output", output: { output: choice.message, exitCode: 2 } };
|
|
13417
|
+
}
|
|
13146
13418
|
|
|
13147
13419
|
// src/lib/models/answer-models.ts
|
|
13148
13420
|
function answerModels(params) {
|
|
@@ -13212,9 +13484,9 @@ function runModels(params) {
|
|
|
13212
13484
|
}
|
|
13213
13485
|
|
|
13214
13486
|
// src/commands/mutants.ts
|
|
13215
|
-
import { existsSync as existsSync59, mkdirSync as mkdirSync18, readFileSync as
|
|
13487
|
+
import { existsSync as existsSync59, mkdirSync as mkdirSync18, readFileSync as readFileSync40, rmSync as rmSync21, writeFileSync as writeFileSync24 } from "fs";
|
|
13216
13488
|
import { createRequire as createRequire5 } from "module";
|
|
13217
|
-
import { dirname as
|
|
13489
|
+
import { dirname as dirname30, join as join66, resolve as resolve19 } from "path";
|
|
13218
13490
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL4 } from "url";
|
|
13219
13491
|
|
|
13220
13492
|
// src/lib/mutation/cache-key.ts
|
|
@@ -13274,19 +13546,19 @@ import {
|
|
|
13274
13546
|
existsSync as existsSync56,
|
|
13275
13547
|
mkdirSync as mkdirSync16,
|
|
13276
13548
|
readdirSync as readdirSync15,
|
|
13277
|
-
readFileSync as
|
|
13549
|
+
readFileSync as readFileSync38,
|
|
13278
13550
|
rmSync as rmSync19,
|
|
13279
|
-
statSync as
|
|
13551
|
+
statSync as statSync9,
|
|
13280
13552
|
writeFileSync as writeFileSync23
|
|
13281
13553
|
} from "fs";
|
|
13282
|
-
import { dirname as
|
|
13554
|
+
import { dirname as dirname28, join as join62 } from "path";
|
|
13283
13555
|
function incrementalCachePathOf(params) {
|
|
13284
|
-
return
|
|
13556
|
+
return join62(storeFolderOf2(params.root), `${params.packageHash}-${params.key}.json`);
|
|
13285
13557
|
}
|
|
13286
13558
|
function seedIncrementalFile(params) {
|
|
13287
13559
|
const text = readParsableText(incrementalCachePathOf(params));
|
|
13288
13560
|
if (text === void 0) return "cold";
|
|
13289
|
-
mkdirSync16(
|
|
13561
|
+
mkdirSync16(dirname28(params.incrementalFile), { recursive: true });
|
|
13290
13562
|
writeFileSync23(params.incrementalFile, text);
|
|
13291
13563
|
return "warm";
|
|
13292
13564
|
}
|
|
@@ -13294,21 +13566,21 @@ function storeIncrementalFile(params) {
|
|
|
13294
13566
|
const text = readParsableText(params.incrementalFile);
|
|
13295
13567
|
if (text === void 0) return false;
|
|
13296
13568
|
const path = incrementalCachePathOf(params);
|
|
13297
|
-
mkdirSync16(
|
|
13569
|
+
mkdirSync16(dirname28(path), { recursive: true });
|
|
13298
13570
|
writeAtomically({ path, text });
|
|
13299
|
-
evictOldFiles({ folder:
|
|
13571
|
+
evictOldFiles({ folder: dirname28(path), packageHash: params.packageHash, kept: path });
|
|
13300
13572
|
return true;
|
|
13301
13573
|
}
|
|
13302
13574
|
function storeFolderOf2(root) {
|
|
13303
|
-
return
|
|
13575
|
+
return join62(mutationStoreFolderOf(root), INCREMENTAL_STORE_FOLDER);
|
|
13304
13576
|
}
|
|
13305
13577
|
function evictOldFiles(params) {
|
|
13306
13578
|
const { folder, packageHash, kept } = params;
|
|
13307
13579
|
const prefix2 = `${packageHash}-`;
|
|
13308
13580
|
const files = readdirSync15(folder).filter((name) => name.startsWith(prefix2) && name.endsWith(".json")).map((name) => ({
|
|
13309
13581
|
name,
|
|
13310
|
-
path:
|
|
13311
|
-
modified: modifiedTimeOf(
|
|
13582
|
+
path: join62(folder, name),
|
|
13583
|
+
modified: modifiedTimeOf(join62(folder, name))
|
|
13312
13584
|
})).filter(
|
|
13313
13585
|
(file) => file.modified !== void 0
|
|
13314
13586
|
).filter((file) => file.path !== kept).sort(
|
|
@@ -13319,7 +13591,7 @@ function evictOldFiles(params) {
|
|
|
13319
13591
|
}
|
|
13320
13592
|
function modifiedTimeOf(path) {
|
|
13321
13593
|
try {
|
|
13322
|
-
return
|
|
13594
|
+
return statSync9(path).mtimeMs;
|
|
13323
13595
|
} catch {
|
|
13324
13596
|
return void 0;
|
|
13325
13597
|
}
|
|
@@ -13327,7 +13599,7 @@ function modifiedTimeOf(path) {
|
|
|
13327
13599
|
function readParsableText(path) {
|
|
13328
13600
|
if (!existsSync56(path)) return void 0;
|
|
13329
13601
|
try {
|
|
13330
|
-
const text =
|
|
13602
|
+
const text = readFileSync38(path, "utf8");
|
|
13331
13603
|
JSON.parse(text);
|
|
13332
13604
|
return text;
|
|
13333
13605
|
} catch {
|
|
@@ -13453,11 +13725,11 @@ function readArguments(params) {
|
|
|
13453
13725
|
|
|
13454
13726
|
// src/lib/mutation/drop-run.ts
|
|
13455
13727
|
import { existsSync as existsSync57, rmSync as rmSync20 } from "fs";
|
|
13456
|
-
import { join as
|
|
13728
|
+
import { join as join63 } from "path";
|
|
13457
13729
|
function dropRun(params) {
|
|
13458
13730
|
const { root, runId, isAlive, startTimeOf, afterDecision } = params;
|
|
13459
13731
|
const store = mutationStoreFolderOf(root);
|
|
13460
|
-
const path =
|
|
13732
|
+
const path = join63(store, MUTATION_RUNS_FOLDER, `${runId}.json`);
|
|
13461
13733
|
return withLedgerLock({
|
|
13462
13734
|
root,
|
|
13463
13735
|
work: function dropUnderLock(state) {
|
|
@@ -13466,7 +13738,7 @@ function dropRun(params) {
|
|
|
13466
13738
|
if (run25 === void 0 || !existsSync57(path))
|
|
13467
13739
|
return {
|
|
13468
13740
|
ok: false,
|
|
13469
|
-
reason: `no mutation run ${runId} in ${
|
|
13741
|
+
reason: `no mutation run ${runId} in ${join63(store, MUTATION_RUNS_FOLDER)}`
|
|
13470
13742
|
};
|
|
13471
13743
|
if (run25.state === "running")
|
|
13472
13744
|
return {
|
|
@@ -13550,8 +13822,8 @@ function dropVerb(params) {
|
|
|
13550
13822
|
}
|
|
13551
13823
|
|
|
13552
13824
|
// src/lib/mutation/judge-packet.ts
|
|
13553
|
-
import { existsSync as existsSync58, readFileSync as
|
|
13554
|
-
import { join as
|
|
13825
|
+
import { existsSync as existsSync58, readFileSync as readFileSync39 } from "fs";
|
|
13826
|
+
import { join as join64 } from "path";
|
|
13555
13827
|
|
|
13556
13828
|
// node_modules/@babel/parser/lib/index.js
|
|
13557
13829
|
var Position = class {
|
|
@@ -27978,10 +28250,10 @@ function judgePackets(params) {
|
|
|
27978
28250
|
const byFile = /* @__PURE__ */ new Map();
|
|
27979
28251
|
for (const item of pending) byFile.set(item.file, [...byFile.get(item.file) ?? [], item]);
|
|
27980
28252
|
return [...byFile.keys()].sort().map((each) => {
|
|
27981
|
-
const path =
|
|
28253
|
+
const path = join64(root, each);
|
|
27982
28254
|
return packetOf({
|
|
27983
28255
|
file: each,
|
|
27984
|
-
source: existsSync58(path) ?
|
|
28256
|
+
source: existsSync58(path) ? readFileSync39(path, "utf8") : void 0,
|
|
27985
28257
|
survivors: (byFile.get(each) ?? []).map(
|
|
27986
28258
|
(item) => inputOf({ item, survivor: reported.get(item.key) })
|
|
27987
28259
|
)
|
|
@@ -28147,7 +28419,7 @@ function judgeVerb(params) {
|
|
|
28147
28419
|
|
|
28148
28420
|
// src/lib/mutation/records-write.ts
|
|
28149
28421
|
import { mkdirSync as mkdirSync17 } from "fs";
|
|
28150
|
-
import { dirname as
|
|
28422
|
+
import { dirname as dirname29, join as join65 } from "path";
|
|
28151
28423
|
function recordKeys(params) {
|
|
28152
28424
|
const { root, keys, family, removable, afterRecordsWritten } = params;
|
|
28153
28425
|
const reason = params.reason.trim();
|
|
@@ -28211,8 +28483,8 @@ function writeRecords(params) {
|
|
|
28211
28483
|
);
|
|
28212
28484
|
for (const item of items)
|
|
28213
28485
|
(next[item.file] ??= {})[item.key] = recordOf({ item, family, reason, removable });
|
|
28214
|
-
const path =
|
|
28215
|
-
mkdirSync17(
|
|
28486
|
+
const path = join65(root, MUTATION_RECORDS_PATH);
|
|
28487
|
+
mkdirSync17(dirname29(path), { recursive: true });
|
|
28216
28488
|
writeAtomically({ path, text: `${JSON.stringify(sortedRecords(next), null, " ")}
|
|
28217
28489
|
` });
|
|
28218
28490
|
}
|
|
@@ -28384,7 +28656,7 @@ async function runMutants(params) {
|
|
|
28384
28656
|
}
|
|
28385
28657
|
}
|
|
28386
28658
|
function ignorerPluginPath(params) {
|
|
28387
|
-
return
|
|
28659
|
+
return join66(params.distFolder, IGNORER_PLUGIN_FILE);
|
|
28388
28660
|
}
|
|
28389
28661
|
async function runVerb(params) {
|
|
28390
28662
|
const { root, runStryker, startTimeOf } = params;
|
|
@@ -28401,7 +28673,7 @@ async function runVerb(params) {
|
|
|
28401
28673
|
if (declared.kind === "none")
|
|
28402
28674
|
return {
|
|
28403
28675
|
exitCode: 1,
|
|
28404
|
-
output: `mutants run: ${
|
|
28676
|
+
output: `mutants run: ${join66(root, "package.json")} declares no dialecte.mutation: declare its scope and fast tier first`
|
|
28405
28677
|
};
|
|
28406
28678
|
if (declared.kind === "invalid") return { exitCode: 1, output: `mutants run: ${declared.reason}` };
|
|
28407
28679
|
const { declaration } = declared;
|
|
@@ -28453,8 +28725,8 @@ async function runVerb(params) {
|
|
|
28453
28725
|
startTimeOf
|
|
28454
28726
|
});
|
|
28455
28727
|
const workDir = `${MUTANTS_WORK_FOLDER}/${entry.runId}`;
|
|
28456
|
-
mkdirSync18(
|
|
28457
|
-
writeFileSync24(
|
|
28728
|
+
mkdirSync18(join66(root, workDir), { recursive: true });
|
|
28729
|
+
writeFileSync24(join66(root, workDir, EMPTY_STRYKER_CONFIG_FILE), "{}\n");
|
|
28458
28730
|
const records = readRecordsFile({ root });
|
|
28459
28731
|
const tiers = await runTiers({
|
|
28460
28732
|
root,
|
|
@@ -28479,7 +28751,7 @@ run ${entry.runId} stays running until this process ends, then reads as died: re
|
|
|
28479
28751
|
...mutantKeysOf({ report: tiers.report })
|
|
28480
28752
|
});
|
|
28481
28753
|
updateLedger({ root, run: finished, records, targets });
|
|
28482
|
-
rmSync21(
|
|
28754
|
+
rmSync21(join66(root, workDir), { recursive: true, force: true });
|
|
28483
28755
|
return { exitCode: 0, output: renderRun({ root, run: finished }) };
|
|
28484
28756
|
}
|
|
28485
28757
|
async function runTiers(params) {
|
|
@@ -28555,7 +28827,7 @@ async function runTier(params) {
|
|
|
28555
28827
|
const reportPath = resolve19(root, options.jsonReporter.fileName);
|
|
28556
28828
|
if (!existsSync59(reportPath))
|
|
28557
28829
|
return { failure: `Stryker wrote no report in the ${tier} tier (${reportPath})` };
|
|
28558
|
-
return { report: JSON.parse(
|
|
28830
|
+
return { report: JSON.parse(readFileSync40(reportPath, "utf8")) };
|
|
28559
28831
|
}
|
|
28560
28832
|
function runModeOf(params) {
|
|
28561
28833
|
const { asked, setting, touchesScope } = params;
|
|
@@ -28742,16 +29014,16 @@ function migrateVerb(params) {
|
|
|
28742
29014
|
const read = readArguments({ argv: params.argv, valueOptions: [], flags: ["json"] });
|
|
28743
29015
|
if (typeof read === "string" || read.words.length > 0)
|
|
28744
29016
|
return usageResult({ verb: "migrate", json, read });
|
|
28745
|
-
const legacyPath =
|
|
29017
|
+
const legacyPath = join66(root, LEGACY_RECORDS_PATH);
|
|
28746
29018
|
if (!existsSync59(legacyPath))
|
|
28747
29019
|
return refused2({ verb: "migrate", json, reason: `no ${LEGACY_RECORDS_PATH} in ${root}` });
|
|
28748
|
-
if (existsSync59(
|
|
29020
|
+
if (existsSync59(join66(root, MUTATION_RECORDS_PATH)))
|
|
28749
29021
|
return refused2({
|
|
28750
29022
|
verb: "migrate",
|
|
28751
29023
|
json,
|
|
28752
29024
|
reason: `${MUTATION_RECORDS_PATH} already exists in ${root}: nothing overwritten`
|
|
28753
29025
|
});
|
|
28754
|
-
const legacy = JSON.parse(
|
|
29026
|
+
const legacy = JSON.parse(readFileSync40(legacyPath, "utf8"));
|
|
28755
29027
|
const records = migrateRecords({ legacy, readLine: (line) => readLineOf({ root, ...line }) });
|
|
28756
29028
|
writeRecordsFile({ root, records });
|
|
28757
29029
|
const count = Object.values(records).reduce(
|
|
@@ -28766,9 +29038,9 @@ function migrateVerb(params) {
|
|
|
28766
29038
|
});
|
|
28767
29039
|
}
|
|
28768
29040
|
function readLineOf(params) {
|
|
28769
|
-
const path =
|
|
29041
|
+
const path = join66(params.root, params.file);
|
|
28770
29042
|
if (!existsSync59(path)) return "";
|
|
28771
|
-
return
|
|
29043
|
+
return readFileSync40(path, "utf8").split("\n")[params.line - 1] ?? "";
|
|
28772
29044
|
}
|
|
28773
29045
|
function usage2(read) {
|
|
28774
29046
|
return usageResult({ read });
|
|
@@ -28777,11 +29049,11 @@ function newDate() {
|
|
|
28777
29049
|
return /* @__PURE__ */ new Date();
|
|
28778
29050
|
}
|
|
28779
29051
|
function cliDistFolder() {
|
|
28780
|
-
const start =
|
|
28781
|
-
return
|
|
29052
|
+
const start = dirname30(fileURLToPath3(import.meta.url));
|
|
29053
|
+
return join66(packageRootOf(start) ?? start, CLI_DIST_FOLDER);
|
|
28782
29054
|
}
|
|
28783
29055
|
async function runStrykerOfPackage(params) {
|
|
28784
|
-
const requireFromPackage = createRequire5(
|
|
29056
|
+
const requireFromPackage = createRequire5(join66(process.cwd(), "package.json"));
|
|
28785
29057
|
const entry = requireFromPackage.resolve("@stryker-mutator/core");
|
|
28786
29058
|
const strykerModule = await import(pathToFileURL4(entry).href);
|
|
28787
29059
|
const stryker = new strykerModule.Stryker(params.options);
|
|
@@ -28790,9 +29062,9 @@ async function runStrykerOfPackage(params) {
|
|
|
28790
29062
|
}
|
|
28791
29063
|
|
|
28792
29064
|
// src/commands/narrowing.ts
|
|
28793
|
-
import { spawnSync as
|
|
29065
|
+
import { spawnSync as spawnSync17 } from "child_process";
|
|
28794
29066
|
import { writeFileSync as writeFileSync25, mkdirSync as mkdirSync19, rmSync as rmSync22, existsSync as existsSync60 } from "fs";
|
|
28795
|
-
import { join as
|
|
29067
|
+
import { join as join67, resolve as resolve20 } from "path";
|
|
28796
29068
|
async function run13(argv) {
|
|
28797
29069
|
const ROOT = process.cwd();
|
|
28798
29070
|
const tsc = resolveBin("tsc", "typescript", ROOT);
|
|
@@ -28808,12 +29080,12 @@ async function run13(argv) {
|
|
|
28808
29080
|
const schema = await loadSchema(resolve20(ROOT, target.constantsDir));
|
|
28809
29081
|
mkdirSync19(resolve20(ROOT, target.outDir), { recursive: true });
|
|
28810
29082
|
const relFile = `${target.outDir}/narrowing.generated.test-d.ts`;
|
|
28811
|
-
writeFileSync25(
|
|
29083
|
+
writeFileSync25(join67(ROOT, relFile), genNarrowing({ schema, binding: target.binding }));
|
|
28812
29084
|
const apiFile = `${target.outDir}/coverage.api.generated.ts`;
|
|
28813
|
-
const include = existsSync60(
|
|
29085
|
+
const include = existsSync60(join67(ROOT, apiFile)) ? [relFile, apiFile] : [relFile];
|
|
28814
29086
|
const tmp = `.narrow-${target.version}.tsconfig.json`;
|
|
28815
29087
|
writeFileSync25(
|
|
28816
|
-
|
|
29088
|
+
join67(ROOT, tmp),
|
|
28817
29089
|
JSON.stringify({
|
|
28818
29090
|
extends: `./${tsconfig}`,
|
|
28819
29091
|
compilerOptions: {
|
|
@@ -28827,12 +29099,12 @@ async function run13(argv) {
|
|
|
28827
29099
|
include
|
|
28828
29100
|
})
|
|
28829
29101
|
);
|
|
28830
|
-
const res =
|
|
29102
|
+
const res = spawnSync17(tsc.path, ["-p", tmp, "--noEmit"], {
|
|
28831
29103
|
cwd: ROOT,
|
|
28832
29104
|
encoding: "utf8",
|
|
28833
29105
|
maxBuffer: 1e8
|
|
28834
29106
|
});
|
|
28835
|
-
rmSync22(
|
|
29107
|
+
rmSync22(join67(ROOT, tmp), { force: true });
|
|
28836
29108
|
if (res.status === 0) {
|
|
28837
29109
|
console.log(
|
|
28838
29110
|
`\u2705 [${target.version}] narrowing holds \u2014 ${schema.elements.length} elements asserted`
|
|
@@ -28849,7 +29121,7 @@ ${res.stdout || ""}${res.stderr || ""}`
|
|
|
28849
29121
|
}
|
|
28850
29122
|
|
|
28851
29123
|
// src/commands/new-verb.ts
|
|
28852
|
-
import { join as
|
|
29124
|
+
import { join as join69 } from "path";
|
|
28853
29125
|
|
|
28854
29126
|
// src/lib/scaffold/new-verb.constants.ts
|
|
28855
29127
|
var VERB_KINDS = ["query", "transaction"];
|
|
@@ -28867,8 +29139,8 @@ var KIND_SHAPES = {
|
|
|
28867
29139
|
var OPTIONS_WITH_VALUE = ["--version", "--format-config"];
|
|
28868
29140
|
|
|
28869
29141
|
// src/lib/scaffold/new-verb.ts
|
|
28870
|
-
import { existsSync as existsSync61, mkdirSync as mkdirSync20, readFileSync as
|
|
28871
|
-
import { dirname as
|
|
29142
|
+
import { existsSync as existsSync61, mkdirSync as mkdirSync20, readFileSync as readFileSync41, writeFileSync as writeFileSync26 } from "fs";
|
|
29143
|
+
import { dirname as dirname31, join as join68 } from "path";
|
|
28872
29144
|
|
|
28873
29145
|
// src/lib/scaffold/edit-module.ts
|
|
28874
29146
|
import ts7 from "typescript";
|
|
@@ -29016,20 +29288,20 @@ function scaffoldVerb(params) {
|
|
|
29016
29288
|
[`${kindFolder}/${file}.types.ts`]: renderTypesFile(names),
|
|
29017
29289
|
[`${kindFolder}/${file}.test.ts`]: renderTestFile(names)
|
|
29018
29290
|
};
|
|
29019
|
-
const existing = Object.keys(newFiles).filter((path) => existsSync61(
|
|
29291
|
+
const existing = Object.keys(newFiles).filter((path) => existsSync61(join68(root, path)));
|
|
29020
29292
|
if (existing.length) return `already there: ${existing.join(", ")}`;
|
|
29021
29293
|
const edits = {};
|
|
29022
29294
|
const barrel = `${kindFolder}/index.ts`;
|
|
29023
29295
|
const exportLine = `export { ${name} } from './${file}'
|
|
29024
29296
|
`;
|
|
29025
|
-
if (existsSync61(
|
|
29297
|
+
if (existsSync61(join68(root, barrel)))
|
|
29026
29298
|
edits[barrel] = withLine({ text: readText({ root, path: barrel }), line: exportLine });
|
|
29027
29299
|
else newFiles[barrel] = exportLine;
|
|
29028
29300
|
const group = `${namespace}${KIND_SHAPES[kind].group}`;
|
|
29029
29301
|
const groupImport = `import * as ${group} from './${kind}'`;
|
|
29030
29302
|
const groupProperty = `${KIND_SHAPES[kind].moduleKey}: ${group}`;
|
|
29031
29303
|
const namespaceModule = `${namespaceFolder}/index.ts`;
|
|
29032
|
-
if (!existsSync61(
|
|
29304
|
+
if (!existsSync61(join68(root, namespaceModule))) {
|
|
29033
29305
|
newFiles[namespaceModule] = `${groupImport}
|
|
29034
29306
|
|
|
29035
29307
|
export const ${namespace} = {
|
|
@@ -29037,7 +29309,7 @@ export const ${namespace} = {
|
|
|
29037
29309
|
}
|
|
29038
29310
|
`;
|
|
29039
29311
|
const registry = `${extensionsFolder}/index.ts`;
|
|
29040
|
-
if (!existsSync61(
|
|
29312
|
+
if (!existsSync61(join68(root, registry))) return `no extension registry at ${registry}`;
|
|
29041
29313
|
const registered = addObjectProperty({
|
|
29042
29314
|
source: addImportLine({
|
|
29043
29315
|
source: readText({ root, path: registry }),
|
|
@@ -29048,7 +29320,7 @@ export const ${namespace} = {
|
|
|
29048
29320
|
});
|
|
29049
29321
|
if (registered === void 0) return `no *_EXTENSION_MODULES object in ${registry}`;
|
|
29050
29322
|
edits[registry] = registered;
|
|
29051
|
-
} else if (!existsSync61(
|
|
29323
|
+
} else if (!existsSync61(join68(root, barrel))) {
|
|
29052
29324
|
const extended = addObjectProperty({
|
|
29053
29325
|
source: addImportLine({
|
|
29054
29326
|
source: readText({ root, path: namespaceModule }),
|
|
@@ -29062,8 +29334,8 @@ export const ${namespace} = {
|
|
|
29062
29334
|
edits[namespaceModule] = extended;
|
|
29063
29335
|
}
|
|
29064
29336
|
for (const [path, text] of Object.entries({ ...newFiles, ...edits })) {
|
|
29065
|
-
mkdirSync20(
|
|
29066
|
-
writeFileSync26(
|
|
29337
|
+
mkdirSync20(dirname31(join68(root, path)), { recursive: true });
|
|
29338
|
+
writeFileSync26(join68(root, path), text);
|
|
29067
29339
|
}
|
|
29068
29340
|
return {
|
|
29069
29341
|
written: Object.keys(newFiles).sort(),
|
|
@@ -29083,12 +29355,12 @@ function withLine(params) {
|
|
|
29083
29355
|
${line}`;
|
|
29084
29356
|
}
|
|
29085
29357
|
function readRootElement(params) {
|
|
29086
|
-
const path =
|
|
29358
|
+
const path = join68(params.root, "src", params.version, "definition", "constants.generated.ts");
|
|
29087
29359
|
if (!existsSync61(path)) return "FILL_ROOT_ELEMENT";
|
|
29088
|
-
return ROOT_ELEMENT_PATTERN.exec(
|
|
29360
|
+
return ROOT_ELEMENT_PATTERN.exec(readFileSync41(path, "utf8"))?.[1] ?? "FILL_ROOT_ELEMENT";
|
|
29089
29361
|
}
|
|
29090
29362
|
function readText(params) {
|
|
29091
|
-
return
|
|
29363
|
+
return readFileSync41(join68(params.root, params.path), "utf8");
|
|
29092
29364
|
}
|
|
29093
29365
|
function kebabCase(name) {
|
|
29094
29366
|
return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -29129,7 +29401,7 @@ function runNewVerb(params) {
|
|
|
29129
29401
|
return { exitCode: 1, output: `new verb: ${result}, nothing written` };
|
|
29130
29402
|
const formatted = formatFiles({
|
|
29131
29403
|
root: cwd,
|
|
29132
|
-
files: [...result.written, ...result.edited].map((path) =>
|
|
29404
|
+
files: [...result.written, ...result.edited].map((path) => join69(cwd, path)),
|
|
29133
29405
|
options: formatOptsFromArgv(argv)
|
|
29134
29406
|
});
|
|
29135
29407
|
if (!formatted)
|
|
@@ -29159,12 +29431,12 @@ import { resolve as resolve21 } from "path";
|
|
|
29159
29431
|
|
|
29160
29432
|
// src/lib/recap/read-recap-records.ts
|
|
29161
29433
|
import { existsSync as existsSync64, realpathSync as realpathSync9 } from "fs";
|
|
29162
|
-
import { basename as basename8, dirname as
|
|
29434
|
+
import { basename as basename8, dirname as dirname32, join as join70 } from "path";
|
|
29163
29435
|
|
|
29164
29436
|
// src/lib/review-rounds/decisions-file.ts
|
|
29165
|
-
import { existsSync as existsSync62, readFileSync as
|
|
29437
|
+
import { existsSync as existsSync62, readFileSync as readFileSync42 } from "fs";
|
|
29166
29438
|
function appendDecision(params) {
|
|
29167
|
-
const lines = (existsSync62(params.path) ?
|
|
29439
|
+
const lines = (existsSync62(params.path) ? readFileSync42(params.path, "utf8") : "").split("\n");
|
|
29168
29440
|
appendTableRow({
|
|
29169
29441
|
path: params.path,
|
|
29170
29442
|
lines,
|
|
@@ -29176,7 +29448,7 @@ function appendDecision(params) {
|
|
|
29176
29448
|
}
|
|
29177
29449
|
function readDecisions(path) {
|
|
29178
29450
|
if (!existsSync62(path)) return [];
|
|
29179
|
-
const lines =
|
|
29451
|
+
const lines = readFileSync42(path, "utf8").split("\n");
|
|
29180
29452
|
const table = findTable({ lines, firstCell: DECISIONS_FIRST_CELL });
|
|
29181
29453
|
return (table?.rowLines ?? []).map(function decisionOf(line) {
|
|
29182
29454
|
const [decision = "", by = "", when = ""] = (tableCells(lines[line]) ?? []).map(unescapeCell);
|
|
@@ -29190,7 +29462,7 @@ function dayOf(date) {
|
|
|
29190
29462
|
}
|
|
29191
29463
|
|
|
29192
29464
|
// src/lib/recap/read-findings.ts
|
|
29193
|
-
import { existsSync as existsSync63, readFileSync as
|
|
29465
|
+
import { existsSync as existsSync63, readFileSync as readFileSync43 } from "fs";
|
|
29194
29466
|
import { relative as relative8 } from "path";
|
|
29195
29467
|
|
|
29196
29468
|
// src/lib/recap/recap.constants.ts
|
|
@@ -29281,7 +29553,7 @@ var RECAP_SCHEDULED_ITEM = "- `{file}:{line}` {mutation}: scheduled for {followU
|
|
|
29281
29553
|
// src/lib/recap/read-findings.ts
|
|
29282
29554
|
function readFindings(params) {
|
|
29283
29555
|
if (!existsSync63(params.path)) return void 0;
|
|
29284
|
-
const lines =
|
|
29556
|
+
const lines = readFileSync43(params.path, "utf8").split("\n");
|
|
29285
29557
|
const table = findTable({ lines, firstCell: "id" });
|
|
29286
29558
|
if (!table) return [];
|
|
29287
29559
|
const headerLine = table.lastLine - table.rowLines.length - 1;
|
|
@@ -29290,9 +29562,9 @@ function readFindings(params) {
|
|
|
29290
29562
|
for (const line of lines.slice(headerLine + 2)) {
|
|
29291
29563
|
const cells = tableCells(line)?.map(unescapeCell);
|
|
29292
29564
|
if (!cells || cells.length !== cellCount) continue;
|
|
29293
|
-
const
|
|
29294
|
-
if (typeof
|
|
29295
|
-
findings.push(
|
|
29565
|
+
const finding2 = readFinding({ cells, bases: params.bases });
|
|
29566
|
+
if (typeof finding2 === "string") return finding2;
|
|
29567
|
+
findings.push(finding2);
|
|
29296
29568
|
}
|
|
29297
29569
|
return findings;
|
|
29298
29570
|
}
|
|
@@ -29406,13 +29678,13 @@ function readRecapRecords(params) {
|
|
|
29406
29678
|
"{where}",
|
|
29407
29679
|
repositoryExists ? "the repository" : "the current folder"
|
|
29408
29680
|
);
|
|
29409
|
-
const declarationPath = existsSync64(
|
|
29681
|
+
const declarationPath = existsSync64(join70(folder, FOLDER_LOT_FILE)) ? join70(folder, FOLDER_LOT_FILE) : join70(root, LOT_FILE);
|
|
29410
29682
|
const accepted = readCases({ path: declarationPath, list: "accept" });
|
|
29411
29683
|
if (typeof accepted === "string") return accepted;
|
|
29412
29684
|
const revised = readCases({ path: declarationPath, list: "revised" });
|
|
29413
29685
|
if (typeof revised === "string") return revised;
|
|
29414
29686
|
const findings = readFindings({
|
|
29415
|
-
path:
|
|
29687
|
+
path: join70(folder, LEDGER_FILE),
|
|
29416
29688
|
bases: pathBasesOf({ root, repositoryExists })
|
|
29417
29689
|
});
|
|
29418
29690
|
if (typeof findings === "string") return findings;
|
|
@@ -29439,7 +29711,7 @@ function readRecapRecords(params) {
|
|
|
29439
29711
|
findings,
|
|
29440
29712
|
accepted,
|
|
29441
29713
|
revised,
|
|
29442
|
-
decisions: readDecisions(
|
|
29714
|
+
decisions: readDecisions(join70(folder, DECISIONS_FILE)),
|
|
29443
29715
|
user
|
|
29444
29716
|
};
|
|
29445
29717
|
}
|
|
@@ -29461,8 +29733,8 @@ function readCommits(params) {
|
|
|
29461
29733
|
}
|
|
29462
29734
|
function pathBasesOf(params) {
|
|
29463
29735
|
const { root, repositoryExists } = params;
|
|
29464
|
-
const parent =
|
|
29465
|
-
const workspace = !repositoryExists && basename8(parent) === WORKTREES_FOLDER ?
|
|
29736
|
+
const parent = dirname32(repositoryExists ? mainCheckoutOf(root) : root);
|
|
29737
|
+
const workspace = !repositoryExists && basename8(parent) === WORKTREES_FOLDER ? dirname32(parent) : parent;
|
|
29466
29738
|
return {
|
|
29467
29739
|
repository: spellingsOf(root),
|
|
29468
29740
|
workspace: spellingsOf(workspace)
|
|
@@ -29577,24 +29849,24 @@ function itemText(params) {
|
|
|
29577
29849
|
function reviewLines(records) {
|
|
29578
29850
|
const findings = records.findings ?? [];
|
|
29579
29851
|
if (findings.length === 0) return [EMPTY_SECTION.review];
|
|
29580
|
-
const rounds = [...new Set(findings.map((
|
|
29852
|
+
const rounds = [...new Set(findings.map((finding2) => finding2.round))].sort(
|
|
29581
29853
|
(first, second) => first - second
|
|
29582
29854
|
);
|
|
29583
29855
|
const outcomes = FINDING_OUTCOMES.flatMap(function outcomeCount(outcome) {
|
|
29584
|
-
const count = findings.filter((
|
|
29856
|
+
const count = findings.filter((finding2) => finding2.outcome === outcome).length;
|
|
29585
29857
|
return count ? [`${count} ${outcome}`] : [];
|
|
29586
29858
|
});
|
|
29587
29859
|
const highest = rounds.at(-1) ?? 0;
|
|
29588
29860
|
return [
|
|
29589
29861
|
`${counted({ count: highest, noun: "round" })}, ${counted({ count: findings.length, noun: "finding" })}: ${outcomes.join(", ")}.`,
|
|
29590
29862
|
...rounds.flatMap(
|
|
29591
|
-
(round) => roundLines({ round, findings: findings.filter((
|
|
29863
|
+
(round) => roundLines({ round, findings: findings.filter((finding2) => finding2.round === round) })
|
|
29592
29864
|
)
|
|
29593
29865
|
];
|
|
29594
29866
|
}
|
|
29595
29867
|
function roundLines(params) {
|
|
29596
29868
|
const severities = ROUND_SEVERITIES.flatMap(function severityCount(entry) {
|
|
29597
|
-
const count = params.findings.filter((
|
|
29869
|
+
const count = params.findings.filter((finding2) => finding2.severity === entry.severity).length;
|
|
29598
29870
|
if (!count) return [];
|
|
29599
29871
|
return [entry.plural ? counted({ count, noun: entry.severity }) : `${count} ${entry.severity}`];
|
|
29600
29872
|
});
|
|
@@ -29602,7 +29874,7 @@ function roundLines(params) {
|
|
|
29602
29874
|
return [
|
|
29603
29875
|
`- Round ${params.round}: ${counted({ count: params.findings.length, noun: "finding" })}${severitiesText}`,
|
|
29604
29876
|
...params.findings.map(
|
|
29605
|
-
(
|
|
29877
|
+
(finding2) => ` - ${finding2.outcome} ${finding2.id}: ${[finding2.severity, atText(finding2.at), finding2.finding].filter(Boolean).join(" ")}`
|
|
29606
29878
|
)
|
|
29607
29879
|
];
|
|
29608
29880
|
}
|
|
@@ -29612,8 +29884,8 @@ function atText(at) {
|
|
|
29612
29884
|
function decisionLines(records) {
|
|
29613
29885
|
const by = `(by ${ASSISTANT})`;
|
|
29614
29886
|
const lines = [
|
|
29615
|
-
...(records.findings ?? []).filter((
|
|
29616
|
-
(
|
|
29887
|
+
...(records.findings ?? []).filter((finding2) => finding2.outcome === "accepted").map(
|
|
29888
|
+
(finding2) => `- ${DECISION_PREFIXES.kept} ${finding2.id} ${finding2.finding} - ${finding2.reason ?? ""} ${by}`
|
|
29617
29889
|
),
|
|
29618
29890
|
...records.accepted.map(
|
|
29619
29891
|
(entry) => `- ${DECISION_PREFIXES.accepted} ${entry.case} - ${entry.reason} ${by}`
|
|
@@ -29626,8 +29898,8 @@ function decisionLines(records) {
|
|
|
29626
29898
|
return lines.length ? lines : [EMPTY_SECTION.decisions];
|
|
29627
29899
|
}
|
|
29628
29900
|
function followUpLines(records) {
|
|
29629
|
-
const lines = (records.findings ?? []).filter((
|
|
29630
|
-
(
|
|
29901
|
+
const lines = (records.findings ?? []).filter((finding2) => finding2.outcome === "logged").map(
|
|
29902
|
+
(finding2) => `- ${finding2.id}: ${finding2.finding}${finding2.at ? ` (${atText(finding2.at)})` : ""}`
|
|
29631
29903
|
);
|
|
29632
29904
|
return lines.length ? lines : [EMPTY_SECTION.followUps];
|
|
29633
29905
|
}
|
|
@@ -29654,24 +29926,24 @@ function runRecap(params) {
|
|
|
29654
29926
|
}
|
|
29655
29927
|
|
|
29656
29928
|
// src/commands/record.ts
|
|
29657
|
-
import { existsSync as existsSync66, mkdirSync as mkdirSync22, readFileSync as
|
|
29658
|
-
import { basename as basename9, join as
|
|
29929
|
+
import { existsSync as existsSync66, mkdirSync as mkdirSync22, readFileSync as readFileSync44, writeFileSync as writeFileSync28 } from "fs";
|
|
29930
|
+
import { basename as basename9, join as join72, resolve as resolve22 } from "path";
|
|
29659
29931
|
|
|
29660
29932
|
// src/lib/review-rounds/snapshot-round.ts
|
|
29661
29933
|
import {
|
|
29662
29934
|
chmodSync as chmodSync2,
|
|
29663
29935
|
copyFileSync as copyFileSync4,
|
|
29664
29936
|
existsSync as existsSync65,
|
|
29665
|
-
lstatSync as
|
|
29937
|
+
lstatSync as lstatSync11,
|
|
29666
29938
|
mkdirSync as mkdirSync21,
|
|
29667
29939
|
readdirSync as readdirSync16,
|
|
29668
|
-
readlinkSync as
|
|
29940
|
+
readlinkSync as readlinkSync6,
|
|
29669
29941
|
renameSync as renameSync4,
|
|
29670
29942
|
rmSync as rmSync23,
|
|
29671
|
-
symlinkSync as
|
|
29943
|
+
symlinkSync as symlinkSync6,
|
|
29672
29944
|
writeFileSync as writeFileSync27
|
|
29673
29945
|
} from "fs";
|
|
29674
|
-
import { dirname as
|
|
29946
|
+
import { dirname as dirname33, join as join71 } from "path";
|
|
29675
29947
|
function roundNames(round) {
|
|
29676
29948
|
return {
|
|
29677
29949
|
folder: `round-${round}`,
|
|
@@ -29680,10 +29952,10 @@ function roundNames(round) {
|
|
|
29680
29952
|
};
|
|
29681
29953
|
}
|
|
29682
29954
|
function copyFileOrLink(params) {
|
|
29683
|
-
mkdirSync21(
|
|
29684
|
-
const stats =
|
|
29955
|
+
mkdirSync21(dirname33(params.to), { recursive: true });
|
|
29956
|
+
const stats = lstatSync11(params.from);
|
|
29685
29957
|
if (isFileOrLink(params.to)) rmSync23(params.to);
|
|
29686
|
-
if (stats.isSymbolicLink())
|
|
29958
|
+
if (stats.isSymbolicLink()) symlinkSync6(readlinkSync6(params.from), params.to);
|
|
29687
29959
|
else {
|
|
29688
29960
|
copyFileSync4(params.from, params.to);
|
|
29689
29961
|
chmodSync2(params.to, stats.mode & 4095);
|
|
@@ -29692,10 +29964,10 @@ function copyFileOrLink(params) {
|
|
|
29692
29964
|
function snapshotRefusal(params) {
|
|
29693
29965
|
const names = roundNames(params.round);
|
|
29694
29966
|
const existing = [names.folder, names.deleted, names.base].find(
|
|
29695
|
-
(name) => existsSync65(
|
|
29967
|
+
(name) => existsSync65(join71(params.folder, name))
|
|
29696
29968
|
);
|
|
29697
29969
|
if (existing)
|
|
29698
|
-
return `${
|
|
29970
|
+
return `${join71(params.folder, existing)} exists already: round ${params.round} was taken`;
|
|
29699
29971
|
return worktreeStateRefusal({ root: params.root, state: params.state });
|
|
29700
29972
|
}
|
|
29701
29973
|
function takeSnapshot(params) {
|
|
@@ -29706,19 +29978,19 @@ function takeSnapshot(params) {
|
|
|
29706
29978
|
const base = readGit({ root, args: ["rev-parse", "HEAD"] }).trim();
|
|
29707
29979
|
const copied = [];
|
|
29708
29980
|
const deleted = [];
|
|
29709
|
-
const partial =
|
|
29981
|
+
const partial = join71(folder, `${names.folder}${PARTIAL_SUFFIX}`);
|
|
29710
29982
|
mkdirSync21(partial);
|
|
29711
29983
|
for (const path of params.state.status.paths) {
|
|
29712
|
-
if (isFileOrLink(
|
|
29713
|
-
copyFileOrLink({ from:
|
|
29984
|
+
if (isFileOrLink(join71(root, path))) {
|
|
29985
|
+
copyFileOrLink({ from: join71(root, path), to: join71(partial, path) });
|
|
29714
29986
|
copied.push(path);
|
|
29715
29987
|
} else if (params.state.head.files.has(path)) deleted.push(path);
|
|
29716
29988
|
}
|
|
29717
29989
|
writeFileSync27(
|
|
29718
|
-
|
|
29990
|
+
join71(folder, `${names.deleted}${PARTIAL_SUFFIX}`),
|
|
29719
29991
|
deleted.sort().map((path) => `${path}\0`).join("")
|
|
29720
29992
|
);
|
|
29721
|
-
writeFileSync27(
|
|
29993
|
+
writeFileSync27(join71(folder, `${names.base}${PARTIAL_SUFFIX}`), `${base}
|
|
29722
29994
|
`);
|
|
29723
29995
|
renameAll({ folder, names: [names.deleted, names.base, names.folder] });
|
|
29724
29996
|
return { copied: copied.length, deleted: deleted.length, base };
|
|
@@ -29727,18 +29999,18 @@ function removeLeftovers(params) {
|
|
|
29727
29999
|
const names = Object.values(roundNames(params.round));
|
|
29728
30000
|
for (const entry of readdirSync16(params.folder))
|
|
29729
30001
|
if (names.some((name) => entry.startsWith(`${name}${PARTIAL_SUFFIX}`)))
|
|
29730
|
-
rmSync23(
|
|
30002
|
+
rmSync23(join71(params.folder, entry), { recursive: true, force: true });
|
|
29731
30003
|
}
|
|
29732
30004
|
function renameAll(params) {
|
|
29733
30005
|
const renamed = [];
|
|
29734
30006
|
try {
|
|
29735
30007
|
for (const name of params.names) {
|
|
29736
|
-
renameSync4(
|
|
30008
|
+
renameSync4(join71(params.folder, `${name}${PARTIAL_SUFFIX}`), join71(params.folder, name));
|
|
29737
30009
|
renamed.push(name);
|
|
29738
30010
|
}
|
|
29739
30011
|
} catch (error) {
|
|
29740
30012
|
for (const name of renamed)
|
|
29741
|
-
renameSync4(
|
|
30013
|
+
renameSync4(join71(params.folder, name), join71(params.folder, `${name}${PARTIAL_SUFFIX}`));
|
|
29742
30014
|
throw error;
|
|
29743
30015
|
}
|
|
29744
30016
|
}
|
|
@@ -29777,7 +30049,7 @@ function recordChoice(params) {
|
|
|
29777
30049
|
const refusal = handoverFolderRefusal(folder);
|
|
29778
30050
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29779
30051
|
mkdirSync22(folder, { recursive: true });
|
|
29780
|
-
const path =
|
|
30052
|
+
const path = join72(folder, DECISIONS_FILE);
|
|
29781
30053
|
appendDecision({
|
|
29782
30054
|
path,
|
|
29783
30055
|
title: basename9(folder),
|
|
@@ -29796,9 +30068,9 @@ function recordReview(params) {
|
|
|
29796
30068
|
const severityWord = values.get("severity") ?? "";
|
|
29797
30069
|
const severity = Object.hasOwn(SEVERITY_SPELLINGS, severityWord) ? SEVERITY_SPELLINGS[severityWord] : void 0;
|
|
29798
30070
|
const at = values.get("at") ?? "";
|
|
29799
|
-
const
|
|
30071
|
+
const finding2 = words[1] ?? "";
|
|
29800
30072
|
if (words.length !== 2 || round === void 0 || severity === void 0) return usage4;
|
|
29801
|
-
if (!
|
|
30073
|
+
if (!finding2 || !at || LINE_BREAK_PATTERN.test(finding2) || LINE_BREAK_PATTERN.test(at))
|
|
29802
30074
|
return {
|
|
29803
30075
|
exitCode: 2,
|
|
29804
30076
|
output: `${RECORD_REVIEW_USAGE} (the finding and --at are one non-empty line each)`
|
|
@@ -29807,8 +30079,8 @@ function recordReview(params) {
|
|
|
29807
30079
|
const refusal = handoverFolderRefusal(folder);
|
|
29808
30080
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29809
30081
|
mkdirSync22(folder, { recursive: true });
|
|
29810
|
-
const ledger =
|
|
29811
|
-
const id = appendFinding({ path: ledger, title: basename9(folder), round, severity, at, finding });
|
|
30082
|
+
const ledger = join72(folder, LEDGER_FILE);
|
|
30083
|
+
const id = appendFinding({ path: ledger, title: basename9(folder), round, severity, at, finding: finding2 });
|
|
29812
30084
|
return { exitCode: 0, output: `record: ${id} open - ${ledger}` };
|
|
29813
30085
|
}
|
|
29814
30086
|
function recordDecision(params) {
|
|
@@ -29822,13 +30094,13 @@ function recordDecision(params) {
|
|
|
29822
30094
|
const folder = resolve22(params.cwd, folderWord);
|
|
29823
30095
|
const refusal = handoverFolderRefusal(folder);
|
|
29824
30096
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29825
|
-
const ledger =
|
|
30097
|
+
const ledger = join72(folder, LEDGER_FILE);
|
|
29826
30098
|
if (!existsSync66(ledger))
|
|
29827
30099
|
return {
|
|
29828
30100
|
exitCode: 1,
|
|
29829
30101
|
output: `record: no findings ledger ${ledger}: record review writes the first finding`
|
|
29830
30102
|
};
|
|
29831
|
-
const lines =
|
|
30103
|
+
const lines = readFileSync44(ledger, "utf8").split("\n");
|
|
29832
30104
|
const rows = findLedgerTable(lines)?.rows ?? [];
|
|
29833
30105
|
const row = rows.find((candidate) => candidate.id === id);
|
|
29834
30106
|
if (!row)
|
|
@@ -29874,35 +30146,35 @@ function recordSnapshot(params) {
|
|
|
29874
30146
|
import { resolve as resolve24 } from "path";
|
|
29875
30147
|
|
|
29876
30148
|
// src/lib/review-rounds/review-delta.ts
|
|
29877
|
-
import { spawnSync as
|
|
29878
|
-
import { existsSync as existsSync70, readFileSync as
|
|
29879
|
-
import { join as
|
|
30149
|
+
import { spawnSync as spawnSync19 } from "child_process";
|
|
30150
|
+
import { existsSync as existsSync70, readFileSync as readFileSync48, statSync as statSync10 } from "fs";
|
|
30151
|
+
import { join as join76 } from "path";
|
|
29880
30152
|
|
|
29881
30153
|
// src/lib/worktree/add-worktree.ts
|
|
29882
|
-
import { spawnSync as
|
|
29883
|
-
import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as existsSync69, mkdirSync as mkdirSync23, readFileSync as
|
|
29884
|
-
import { basename as basename10, dirname as
|
|
30154
|
+
import { spawnSync as spawnSync18 } from "child_process";
|
|
30155
|
+
import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as existsSync69, mkdirSync as mkdirSync23, readFileSync as readFileSync47 } from "fs";
|
|
30156
|
+
import { basename as basename10, dirname as dirname34, isAbsolute as isAbsolute10, join as join75 } from "path";
|
|
29885
30157
|
|
|
29886
30158
|
// src/lib/worktree/check-node-modules.ts
|
|
29887
|
-
import { existsSync as existsSync68, readFileSync as
|
|
29888
|
-
import { join as
|
|
30159
|
+
import { existsSync as existsSync68, readFileSync as readFileSync46, realpathSync as realpathSync10 } from "fs";
|
|
30160
|
+
import { join as join74, resolve as resolve23 } from "path";
|
|
29889
30161
|
|
|
29890
30162
|
// src/lib/worktree/locked-packages.ts
|
|
29891
|
-
import { existsSync as existsSync67, readFileSync as
|
|
29892
|
-
import { join as
|
|
30163
|
+
import { existsSync as existsSync67, readFileSync as readFileSync45 } from "fs";
|
|
30164
|
+
import { join as join73 } from "path";
|
|
29893
30165
|
function readLockedPackages(params) {
|
|
29894
|
-
const path =
|
|
30166
|
+
const path = join73(params.worktree, PACKAGE_LOCK_FILE);
|
|
29895
30167
|
if (!existsSync67(path)) return { notChecked: "no lockfile" };
|
|
29896
30168
|
let lockfile;
|
|
29897
30169
|
try {
|
|
29898
|
-
lockfile = JSON.parse(
|
|
30170
|
+
lockfile = JSON.parse(readFileSync45(path, "utf8"));
|
|
29899
30171
|
} catch {
|
|
29900
30172
|
return { notChecked: "unreadable" };
|
|
29901
30173
|
}
|
|
29902
30174
|
if (typeof lockfile?.packages !== "object" || lockfile.packages === null)
|
|
29903
30175
|
return { notChecked: "has no packages map" };
|
|
29904
30176
|
return {
|
|
29905
|
-
packages: Object.entries(lockfile.packages).filter(([key, entry]) => key.startsWith(NODE_MODULES_PREFIX) && !entry.inBundle).filter(([key, entry]) => !mayBeLeftOut(entry) || isPresent(
|
|
30177
|
+
packages: Object.entries(lockfile.packages).filter(([key, entry]) => key.startsWith(NODE_MODULES_PREFIX) && !entry.inBundle).filter(([key, entry]) => !mayBeLeftOut(entry) || isPresent(join73(params.worktree, key))).map(([key, entry]) => ({ key, entry }))
|
|
29906
30178
|
};
|
|
29907
30179
|
}
|
|
29908
30180
|
function mayBeLeftOut(entry) {
|
|
@@ -29934,18 +30206,18 @@ function checkNodeModules(params) {
|
|
|
29934
30206
|
}
|
|
29935
30207
|
function problemOf(params) {
|
|
29936
30208
|
const { key, entry } = params.locked;
|
|
29937
|
-
const installed =
|
|
30209
|
+
const installed = join74(params.worktree, key);
|
|
29938
30210
|
if (entry.link) {
|
|
29939
30211
|
const resolved = entry.resolved ?? "";
|
|
29940
30212
|
const target = resolve23(params.worktree, resolved);
|
|
29941
30213
|
if (!existsSync68(installed) || !existsSync68(target)) return `link to ${resolved} missing`;
|
|
29942
30214
|
return realpathSync10(installed) === realpathSync10(target) ? void 0 : `link to ${resolved} points elsewhere`;
|
|
29943
30215
|
}
|
|
29944
|
-
const manifest =
|
|
30216
|
+
const manifest = join74(installed, "package.json");
|
|
29945
30217
|
if (!existsSync68(manifest)) return "missing";
|
|
29946
30218
|
let version;
|
|
29947
30219
|
try {
|
|
29948
|
-
version = JSON.parse(
|
|
30220
|
+
version = JSON.parse(readFileSync46(manifest, "utf8")).version;
|
|
29949
30221
|
} catch {
|
|
29950
30222
|
return "package.json unreadable";
|
|
29951
30223
|
}
|
|
@@ -29962,13 +30234,13 @@ function packageName2(key) {
|
|
|
29962
30234
|
function addWorktree(params) {
|
|
29963
30235
|
const { branch } = params;
|
|
29964
30236
|
const repository = mainCheckoutOf(params.repository);
|
|
29965
|
-
const worktree =
|
|
29966
|
-
|
|
30237
|
+
const worktree = join75(
|
|
30238
|
+
dirname34(repository),
|
|
29967
30239
|
WORKTREES_FOLDER,
|
|
29968
30240
|
`${basename10(repository)}-${branch.split("/").at(-1)}`
|
|
29969
30241
|
);
|
|
29970
30242
|
if (existsSync69(worktree)) return `${worktree} exists already`;
|
|
29971
|
-
const branchExists =
|
|
30243
|
+
const branchExists = spawnSync18("git", ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
29972
30244
|
cwd: repository
|
|
29973
30245
|
}).status === 0;
|
|
29974
30246
|
if (branchExists && params.from)
|
|
@@ -29981,15 +30253,15 @@ function addWorktree(params) {
|
|
|
29981
30253
|
const hooks = readHooksFolder(repository);
|
|
29982
30254
|
let copiedHooks;
|
|
29983
30255
|
if (hooks.configured && !isAbsolute10(hooks.configured) && existsSync69(hooks.folder)) {
|
|
29984
|
-
const target =
|
|
30256
|
+
const target = join75(worktree, hooks.configured);
|
|
29985
30257
|
if (!existsSync69(target)) cpSync3(hooks.folder, target, { recursive: true });
|
|
29986
30258
|
copiedHooks = hooks.configured;
|
|
29987
30259
|
}
|
|
29988
30260
|
excludeLotFolder(worktree);
|
|
29989
30261
|
const siblingLinks = linkSiblings({ worktree, repository });
|
|
29990
30262
|
const checkout = params.from ? checkoutOf({ repository, branch: params.from }) : void 0;
|
|
29991
|
-
const nodeModules = [checkout, repository].filter((folder) => folder !== void 0).map((folder) =>
|
|
29992
|
-
const copy = existsSync69(nodeModules) ? copyNodeModules({ from: nodeModules, to:
|
|
30263
|
+
const nodeModules = [checkout, repository].filter((folder) => folder !== void 0).map((folder) => join75(folder, "node_modules")).find((folder) => existsSync69(folder)) ?? join75(repository, "node_modules");
|
|
30264
|
+
const copy = existsSync69(nodeModules) ? copyNodeModules({ from: nodeModules, to: join75(worktree, "node_modules") }) : void 0;
|
|
29993
30265
|
const nodeModulesCheck = checkNodeModules({ worktree });
|
|
29994
30266
|
const lockfileRead = readLockedPackages({ worktree });
|
|
29995
30267
|
const lockedPackages = "packages" in lockfileRead ? lockfileRead.packages.length : 0;
|
|
@@ -30024,9 +30296,9 @@ function excludeLotFolder(worktree) {
|
|
|
30024
30296
|
root: worktree,
|
|
30025
30297
|
args: ["rev-parse", "--path-format=absolute", "--git-path", "info/exclude"]
|
|
30026
30298
|
}).trim();
|
|
30027
|
-
const text = existsSync69(exclude) ?
|
|
30299
|
+
const text = existsSync69(exclude) ? readFileSync47(exclude, "utf8") : "";
|
|
30028
30300
|
if (text.split("\n").includes(LOT_FOLDER_EXCLUDE)) return;
|
|
30029
|
-
mkdirSync23(
|
|
30301
|
+
mkdirSync23(dirname34(exclude), { recursive: true });
|
|
30030
30302
|
appendFileSync2(exclude, `${text && !text.endsWith("\n") ? "\n" : ""}${LOT_FOLDER_EXCLUDE}
|
|
30031
30303
|
`);
|
|
30032
30304
|
}
|
|
@@ -30034,23 +30306,23 @@ function excludeLotFolder(worktree) {
|
|
|
30034
30306
|
// src/lib/review-rounds/review-delta.ts
|
|
30035
30307
|
function previousRoundRefusal(params) {
|
|
30036
30308
|
const names = roundNames(params.previous);
|
|
30037
|
-
const snapshot =
|
|
30038
|
-
if (!existsSync70(snapshot) || !
|
|
30309
|
+
const snapshot = join76(params.folder, names.folder);
|
|
30310
|
+
if (!existsSync70(snapshot) || !statSync10(snapshot).isDirectory())
|
|
30039
30311
|
return `no snapshot ${snapshot}: record snapshot --round ${params.previous} takes it`;
|
|
30040
|
-
if (!existsSync70(
|
|
30041
|
-
return `no ${
|
|
30042
|
-
const baseFile =
|
|
30312
|
+
if (!existsSync70(join76(params.folder, names.deleted)))
|
|
30313
|
+
return `no ${join76(params.folder, names.deleted)}: record snapshot --round ${params.previous} writes it`;
|
|
30314
|
+
const baseFile = join76(params.folder, names.base);
|
|
30043
30315
|
if (!existsSync70(baseFile)) return void 0;
|
|
30044
|
-
const base =
|
|
30316
|
+
const base = readFileSync48(baseFile, "utf8").trim();
|
|
30045
30317
|
const head = readGit({ root: params.root, args: ["rev-parse", "HEAD"] }).trim();
|
|
30046
30318
|
return base === head ? void 0 : `HEAD moved since round-${params.previous} (base ${base}, HEAD ${head})`;
|
|
30047
30319
|
}
|
|
30048
30320
|
function readDeletedPaths(params) {
|
|
30049
|
-
return
|
|
30321
|
+
return readFileSync48(join76(params.folder, roundNames(params.previous).deleted), "utf8").split("\0").filter(Boolean);
|
|
30050
30322
|
}
|
|
30051
30323
|
function computeDelta(params) {
|
|
30052
30324
|
const { root, previous } = params;
|
|
30053
|
-
const snapshot =
|
|
30325
|
+
const snapshot = join76(params.folder, roundNames(previous).folder);
|
|
30054
30326
|
const inPrevious = new Set(listTreeFiles(snapshot));
|
|
30055
30327
|
const inDeleted = new Set(readDeletedPaths(params));
|
|
30056
30328
|
const atHead = params.state.head.files;
|
|
@@ -30060,7 +30332,7 @@ function computeDelta(params) {
|
|
|
30060
30332
|
const sides = {
|
|
30061
30333
|
inPrevious: inPrevious.has(path),
|
|
30062
30334
|
inDeleted: inDeleted.has(path),
|
|
30063
|
-
inWorktree: isFileOrLink(
|
|
30335
|
+
inWorktree: isFileOrLink(join76(root, path)),
|
|
30064
30336
|
atBase: atHead.has(path)
|
|
30065
30337
|
};
|
|
30066
30338
|
const diff = diffOf({ root, snapshot, path, sides, previous });
|
|
@@ -30070,8 +30342,8 @@ function computeDelta(params) {
|
|
|
30070
30342
|
}
|
|
30071
30343
|
function diffOf(params) {
|
|
30072
30344
|
const { sides } = params;
|
|
30073
|
-
const current =
|
|
30074
|
-
const before =
|
|
30345
|
+
const current = join76(params.root, params.path);
|
|
30346
|
+
const before = join76(params.snapshot, params.path);
|
|
30075
30347
|
if (sides.inPrevious)
|
|
30076
30348
|
return sides.inWorktree ? {
|
|
30077
30349
|
form: `round-${params.previous} \u2192 worktree`,
|
|
@@ -30115,7 +30387,7 @@ function diffFiles(params) {
|
|
|
30115
30387
|
});
|
|
30116
30388
|
}
|
|
30117
30389
|
function runDiff(params) {
|
|
30118
|
-
const result =
|
|
30390
|
+
const result = spawnSync19("git", ["-c", "core.quotePath=false", ...params.args], {
|
|
30119
30391
|
cwd: params.cwd,
|
|
30120
30392
|
encoding: "utf8",
|
|
30121
30393
|
maxBuffer: 1e9
|
|
@@ -30127,7 +30399,7 @@ function runDiff(params) {
|
|
|
30127
30399
|
return result.stdout;
|
|
30128
30400
|
}
|
|
30129
30401
|
function currentBranchOf2(root) {
|
|
30130
|
-
const result =
|
|
30402
|
+
const result = spawnSync19("git", ["symbolic-ref", "--short", "-q", "HEAD"], {
|
|
30131
30403
|
cwd: root,
|
|
30132
30404
|
encoding: "utf8"
|
|
30133
30405
|
});
|
|
@@ -30155,10 +30427,10 @@ function addThrowaway(params) {
|
|
|
30155
30427
|
removal: removalCommand({ main: added.repository, path: added.worktree, branch })
|
|
30156
30428
|
};
|
|
30157
30429
|
const names = roundNames(params.previous);
|
|
30158
|
-
const deletedFile =
|
|
30159
|
-
const snapshot =
|
|
30430
|
+
const deletedFile = join76(params.folder, names.deleted);
|
|
30431
|
+
const snapshot = join76(params.folder, names.folder);
|
|
30160
30432
|
try {
|
|
30161
|
-
if (
|
|
30433
|
+
if (statSync10(deletedFile).size > 0)
|
|
30162
30434
|
readGit({
|
|
30163
30435
|
root: added.worktree,
|
|
30164
30436
|
args: [
|
|
@@ -30171,7 +30443,7 @@ function addThrowaway(params) {
|
|
|
30171
30443
|
});
|
|
30172
30444
|
for (const path of listTreeFiles(snapshot))
|
|
30173
30445
|
if (!LOT_FILE_PATTERN.test(path))
|
|
30174
|
-
copyFileOrLink({ from:
|
|
30446
|
+
copyFileOrLink({ from: join76(snapshot, path), to: join76(added.worktree, path) });
|
|
30175
30447
|
} catch (error) {
|
|
30176
30448
|
return `${error.message}; the throwaway worktree is half made, remove it: ${throwaway.removal}`;
|
|
30177
30449
|
}
|
|
@@ -30261,7 +30533,7 @@ function reviewDelta(params) {
|
|
|
30261
30533
|
}
|
|
30262
30534
|
|
|
30263
30535
|
// src/commands/rules.ts
|
|
30264
|
-
import { existsSync as existsSync71, readFileSync as
|
|
30536
|
+
import { existsSync as existsSync71, readFileSync as readFileSync49, statSync as statSync11 } from "fs";
|
|
30265
30537
|
import { resolve as resolve25 } from "path";
|
|
30266
30538
|
|
|
30267
30539
|
// src/lib/rules/check-code-rules.constants.ts
|
|
@@ -30304,8 +30576,8 @@ function checkCodeRules(params) {
|
|
|
30304
30576
|
const kind = fileKindOf(file);
|
|
30305
30577
|
const sourceFile = ts8.createSourceFile(file, text, ts8.ScriptTarget.Latest, true);
|
|
30306
30578
|
const findings = [];
|
|
30307
|
-
function report(
|
|
30308
|
-
const { node, ...rest } =
|
|
30579
|
+
function report(finding2) {
|
|
30580
|
+
const { node, ...rest } = finding2;
|
|
30309
30581
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
30310
30582
|
findings.push({ file, line: position.line + 1, column: position.character + 1, ...rest });
|
|
30311
30583
|
}
|
|
@@ -30528,9 +30800,9 @@ function runRules(params) {
|
|
|
30528
30800
|
}
|
|
30529
30801
|
const referencePatterns = readReferencePatterns(cwd);
|
|
30530
30802
|
const findings = files.flatMap(
|
|
30531
|
-
(file) => checkCodeRules({ file, text:
|
|
30803
|
+
(file) => checkCodeRules({ file, text: readFileSync49(resolve25(cwd, file), "utf8"), referencePatterns })
|
|
30532
30804
|
);
|
|
30533
|
-
const errors = findings.filter((
|
|
30805
|
+
const errors = findings.filter((finding2) => finding2.severity === "error").length;
|
|
30534
30806
|
const warnings = findings.length - errors;
|
|
30535
30807
|
if (givenFiles.length === 0) recordRules({ root: cwd, files, errors, warnings });
|
|
30536
30808
|
const output = json ? JSON.stringify({ files, errors, warnings, findings }, null, 2) : [
|
|
@@ -30541,17 +30813,17 @@ function runRules(params) {
|
|
|
30541
30813
|
}
|
|
30542
30814
|
function expandFolder(params) {
|
|
30543
30815
|
const { cwd, path } = params;
|
|
30544
|
-
if (!
|
|
30816
|
+
if (!statSync11(resolve25(cwd, path)).isDirectory()) return [path];
|
|
30545
30817
|
return listRepositoryFiles({ root: cwd, folder: path }).filter(
|
|
30546
30818
|
(file) => TEXT_FILE_PATTERN.test(file) && existsSync71(resolve25(cwd, file))
|
|
30547
30819
|
);
|
|
30548
30820
|
}
|
|
30549
|
-
function renderFinding(
|
|
30550
|
-
return `${
|
|
30821
|
+
function renderFinding(finding2) {
|
|
30822
|
+
return `${finding2.file}:${finding2.line}:${finding2.column} ${finding2.severity} ${finding2.rule} ${finding2.message}`;
|
|
30551
30823
|
}
|
|
30552
30824
|
|
|
30553
30825
|
// src/commands/run.ts
|
|
30554
|
-
import { readFileSync as
|
|
30826
|
+
import { readFileSync as readFileSync50, writeFileSync as writeFileSync29 } from "fs";
|
|
30555
30827
|
import { resolve as resolve26 } from "path";
|
|
30556
30828
|
import { pathToFileURL as pathToFileURL5 } from "url";
|
|
30557
30829
|
async function run19(argv) {
|
|
@@ -30659,7 +30931,7 @@ async function loadScript(params) {
|
|
|
30659
30931
|
return loaded.default;
|
|
30660
30932
|
}
|
|
30661
30933
|
function readExpectations(params) {
|
|
30662
|
-
const parsed2 = JSON.parse(
|
|
30934
|
+
const parsed2 = JSON.parse(readFileSync50(params.path, "utf8"));
|
|
30663
30935
|
const isExpectationList = Array.isArray(parsed2) && parsed2.every(
|
|
30664
30936
|
(entry) => typeof entry === "object" && entry !== null && typeof entry.tag === "string"
|
|
30665
30937
|
);
|
|
@@ -30671,7 +30943,7 @@ function readExpectations(params) {
|
|
|
30671
30943
|
}
|
|
30672
30944
|
function readInput(params) {
|
|
30673
30945
|
const { path } = params;
|
|
30674
|
-
return new File([
|
|
30946
|
+
return new File([readFileSync50(path)], path.slice(path.lastIndexOf("/") + 1), {
|
|
30675
30947
|
type: "application/xml"
|
|
30676
30948
|
});
|
|
30677
30949
|
}
|
|
@@ -30839,12 +31111,12 @@ async function readSchemaDialectes(params) {
|
|
|
30839
31111
|
}
|
|
30840
31112
|
|
|
30841
31113
|
// src/commands/skills.ts
|
|
30842
|
-
import { existsSync as
|
|
30843
|
-
import { dirname as
|
|
31114
|
+
import { existsSync as existsSync81, readdirSync as readdirSync19, readFileSync as readFileSync59, writeFileSync as writeFileSync33 } from "fs";
|
|
31115
|
+
import { dirname as dirname37, join as join86, relative as relative9, sep as sep2 } from "path";
|
|
30844
31116
|
|
|
30845
31117
|
// src/lib/api/api-json.ts
|
|
30846
|
-
import { existsSync as existsSync73, readFileSync as
|
|
30847
|
-
import { join as
|
|
31118
|
+
import { existsSync as existsSync73, readFileSync as readFileSync52 } from "fs";
|
|
31119
|
+
import { join as join78 } from "path";
|
|
30848
31120
|
|
|
30849
31121
|
// src/lib/skills/api-index.ts
|
|
30850
31122
|
function renderApiIndex(entries) {
|
|
@@ -30951,18 +31223,18 @@ function tableCell(text) {
|
|
|
30951
31223
|
}
|
|
30952
31224
|
|
|
30953
31225
|
// src/lib/api/find-example.ts
|
|
30954
|
-
import { existsSync as existsSync72, readFileSync as
|
|
30955
|
-
import { join as
|
|
31226
|
+
import { existsSync as existsSync72, readFileSync as readFileSync51 } from "fs";
|
|
31227
|
+
import { join as join77 } from "path";
|
|
30956
31228
|
import ts9 from "typescript";
|
|
30957
31229
|
function findTestExample(params) {
|
|
30958
31230
|
const { file, position } = splitDeclaredAt(params.declaredAt);
|
|
30959
|
-
const testFile =
|
|
31231
|
+
const testFile = join77(params.root, file.replace(/\.ts$/, ".test.ts"));
|
|
30960
31232
|
if (!file.endsWith(".ts") || !existsSync72(testFile)) return void 0;
|
|
30961
|
-
const functionName = declaredName({ path:
|
|
31233
|
+
const functionName = declaredName({ path: join77(params.root, file), position });
|
|
30962
31234
|
if (!functionName) return void 0;
|
|
30963
31235
|
const source = ts9.createSourceFile(
|
|
30964
31236
|
testFile,
|
|
30965
|
-
|
|
31237
|
+
readFileSync51(testFile, "utf8"),
|
|
30966
31238
|
ts9.ScriptTarget.Latest,
|
|
30967
31239
|
true
|
|
30968
31240
|
);
|
|
@@ -30990,7 +31262,7 @@ function declaredName(params) {
|
|
|
30990
31262
|
if (!existsSync72(params.path)) return void 0;
|
|
30991
31263
|
const source = ts9.createSourceFile(
|
|
30992
31264
|
params.path,
|
|
30993
|
-
|
|
31265
|
+
readFileSync51(params.path, "utf8"),
|
|
30994
31266
|
ts9.ScriptTarget.Latest,
|
|
30995
31267
|
true
|
|
30996
31268
|
);
|
|
@@ -31072,9 +31344,9 @@ function rootOf(path) {
|
|
|
31072
31344
|
}
|
|
31073
31345
|
function lineOf(params) {
|
|
31074
31346
|
const { file, position } = splitDeclaredAt(params.declaredAt);
|
|
31075
|
-
const path =
|
|
31347
|
+
const path = join78(params.root, file);
|
|
31076
31348
|
if (!existsSync73(path)) return file;
|
|
31077
|
-
const line =
|
|
31349
|
+
const line = readFileSync52(path, "utf8").slice(0, position).split("\n").length;
|
|
31078
31350
|
return `${file}:${line}`;
|
|
31079
31351
|
}
|
|
31080
31352
|
function renderApiJson(apiJson) {
|
|
@@ -31108,8 +31380,8 @@ function prompt(params) {
|
|
|
31108
31380
|
}
|
|
31109
31381
|
|
|
31110
31382
|
// src/lib/models/resolve-sync-vendor.ts
|
|
31111
|
-
import { existsSync as
|
|
31112
|
-
import { basename as basename11, dirname as
|
|
31383
|
+
import { existsSync as existsSync77, readdirSync as readdirSync17, readFileSync as readFileSync55, statSync as statSync12 } from "fs";
|
|
31384
|
+
import { basename as basename11, dirname as dirname36, join as join82 } from "path";
|
|
31113
31385
|
|
|
31114
31386
|
// src/lib/stations/session-check.constants.ts
|
|
31115
31387
|
var SESSION_CHECK_COMMAND = "npx --no-install @dialecte/cli doctor --brief";
|
|
@@ -31124,16 +31396,92 @@ var SESSION_CHECK_GROUP = {
|
|
|
31124
31396
|
var SESSION_CHECK_COMMAND_PATTERN = /^npx(?: --no-install)? @dialecte\/cli doctor --brief$/;
|
|
31125
31397
|
var MAX_CUTS = 50;
|
|
31126
31398
|
|
|
31399
|
+
// src/lib/stations/agents-file-check.constants.ts
|
|
31400
|
+
var AGENTS_FILE = "AGENTS.md";
|
|
31401
|
+
var AGENTS_CHECK_START = "<!-- dialecte-skills:session-check -->";
|
|
31402
|
+
var AGENTS_CHECK_END = "<!-- /dialecte-skills:session-check -->";
|
|
31403
|
+
var AGENTS_CHECK_LINE = `At the start of a session, run \`${SESSION_CHECK_COMMAND}\`: nothing printed means the Dialecte skills are in sync; otherwise each line is a problem with its fix.`;
|
|
31404
|
+
|
|
31405
|
+
// src/lib/stations/agents-file-check.ts
|
|
31406
|
+
import { existsSync as existsSync74, readFileSync as readFileSync53, unlinkSync as unlinkSync3, writeFileSync as writeFileSync30 } from "fs";
|
|
31407
|
+
import { join as join79 } from "path";
|
|
31408
|
+
function syncAgentsFileCheck(params) {
|
|
31409
|
+
const { cwd, enabled } = params;
|
|
31410
|
+
const path = join79(cwd, AGENTS_FILE);
|
|
31411
|
+
const exists = existsSync74(path);
|
|
31412
|
+
const text = exists ? readFileSync53(path, "utf8") : "";
|
|
31413
|
+
const found = findSection(text);
|
|
31414
|
+
if (found === "unclosed") return "unclosed";
|
|
31415
|
+
if (enabled) return addOrUpdate({ path, text, span: found });
|
|
31416
|
+
if (found === void 0) return "unchanged";
|
|
31417
|
+
const without = withoutSection({ text, span: found });
|
|
31418
|
+
if (without.trim() === "") unlinkSync3(path);
|
|
31419
|
+
else writeFileSync30(path, without);
|
|
31420
|
+
return "removed";
|
|
31421
|
+
}
|
|
31422
|
+
function holdsOnlyTheAgentsCheck(text) {
|
|
31423
|
+
const span = findSection(text);
|
|
31424
|
+
if (span === void 0 || span === "unclosed") return false;
|
|
31425
|
+
return `${text.slice(0, span.start)}${text.slice(span.end)}`.trim() === "";
|
|
31426
|
+
}
|
|
31427
|
+
function findSection(text) {
|
|
31428
|
+
const starts = occurrencesOf({ text, marker: AGENTS_CHECK_START });
|
|
31429
|
+
const ends = occurrencesOf({ text, marker: AGENTS_CHECK_END });
|
|
31430
|
+
if (starts.length === 0 && ends.length === 0) return void 0;
|
|
31431
|
+
if (starts.length !== 1 || ends.length !== 1 || starts[0] > ends[0]) return "unclosed";
|
|
31432
|
+
return { start: starts[0], end: ends[0] + AGENTS_CHECK_END.length };
|
|
31433
|
+
}
|
|
31434
|
+
function occurrencesOf(params) {
|
|
31435
|
+
const offsets = [];
|
|
31436
|
+
let from = params.text.indexOf(params.marker);
|
|
31437
|
+
while (from >= 0) {
|
|
31438
|
+
offsets.push(from);
|
|
31439
|
+
from = params.text.indexOf(params.marker, from + params.marker.length);
|
|
31440
|
+
}
|
|
31441
|
+
return offsets;
|
|
31442
|
+
}
|
|
31443
|
+
function eolOf(text) {
|
|
31444
|
+
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
31445
|
+
}
|
|
31446
|
+
function addOrUpdate(params) {
|
|
31447
|
+
const { path, text, span } = params;
|
|
31448
|
+
const eol = eolOf(text);
|
|
31449
|
+
const section = `${AGENTS_CHECK_START}${eol}${AGENTS_CHECK_LINE}${eol}${AGENTS_CHECK_END}`;
|
|
31450
|
+
if (span === void 0) {
|
|
31451
|
+
writeFileSync30(path, `${text}${separatorBefore({ text, eol })}${section}${eol}`);
|
|
31452
|
+
return "added";
|
|
31453
|
+
}
|
|
31454
|
+
if (text.slice(span.start, span.end) === section) return "unchanged";
|
|
31455
|
+
writeFileSync30(path, `${text.slice(0, span.start)}${section}${text.slice(span.end)}`);
|
|
31456
|
+
return "updated";
|
|
31457
|
+
}
|
|
31458
|
+
function separatorBefore(params) {
|
|
31459
|
+
const { text, eol } = params;
|
|
31460
|
+
if (text === "") return "";
|
|
31461
|
+
return text.endsWith("\n") ? eol : `${eol}${eol}`;
|
|
31462
|
+
}
|
|
31463
|
+
function withoutSection(params) {
|
|
31464
|
+
const { text, span } = params;
|
|
31465
|
+
const eol = eolOf(text);
|
|
31466
|
+
let before = text.slice(0, span.start);
|
|
31467
|
+
let after = text.slice(span.end);
|
|
31468
|
+
const startsLine = before === "" || before.endsWith("\n");
|
|
31469
|
+
if (startsLine && after.startsWith(eol)) after = after.slice(eol.length);
|
|
31470
|
+
if (before.endsWith(`${eol}${eol}`)) before = before.slice(0, -eol.length);
|
|
31471
|
+
else if (before === "" && after.startsWith(eol)) after = after.slice(eol.length);
|
|
31472
|
+
return `${before}${after}`;
|
|
31473
|
+
}
|
|
31474
|
+
|
|
31127
31475
|
// src/lib/stations/session-check.ts
|
|
31128
|
-
import { existsSync as
|
|
31129
|
-
import { dirname as
|
|
31476
|
+
import { existsSync as existsSync76, mkdirSync as mkdirSync24, readFileSync as readFileSync54, unlinkSync as unlinkSync4, writeFileSync as writeFileSync31 } from "fs";
|
|
31477
|
+
import { dirname as dirname35, join as join81 } from "path";
|
|
31130
31478
|
|
|
31131
31479
|
// src/lib/stations/station-manifest.ts
|
|
31132
|
-
import { existsSync as
|
|
31133
|
-
import { join as
|
|
31480
|
+
import { existsSync as existsSync75 } from "fs";
|
|
31481
|
+
import { join as join80 } from "path";
|
|
31134
31482
|
function updateStationManifest(params) {
|
|
31135
31483
|
const { folder, patch } = params;
|
|
31136
|
-
if (!
|
|
31484
|
+
if (!existsSync75(join80(folder, MANIFEST_FILE))) return;
|
|
31137
31485
|
const manifest = readSyncManifest(folder);
|
|
31138
31486
|
const { stationAgents, sessionCheck, settingsCreated, sessionCheckInserted, ...rest } = manifest;
|
|
31139
31487
|
writeSyncManifest({
|
|
@@ -31152,11 +31500,11 @@ function updateStationManifest(params) {
|
|
|
31152
31500
|
import { findNodeAtLocation, getNodeValue, parse as parse3, parseTree } from "jsonc-parser";
|
|
31153
31501
|
function syncSessionCheck(params) {
|
|
31154
31502
|
const { cwd, enabled } = params;
|
|
31155
|
-
const manifestFolder =
|
|
31503
|
+
const manifestFolder = join81(cwd, AGENT_SKILL_FOLDERS.claude);
|
|
31156
31504
|
const recorded = readSyncManifest(manifestFolder).sessionCheck === true;
|
|
31157
|
-
const path =
|
|
31505
|
+
const path = join81(cwd, CLAUDE_SETTINGS_FILE);
|
|
31158
31506
|
if (!enabled && !recorded) return "unchanged";
|
|
31159
|
-
const exists =
|
|
31507
|
+
const exists = existsSync76(path);
|
|
31160
31508
|
if (!exists && !enabled) {
|
|
31161
31509
|
updateStationManifest({
|
|
31162
31510
|
folder: manifestFolder,
|
|
@@ -31164,7 +31512,7 @@ function syncSessionCheck(params) {
|
|
|
31164
31512
|
});
|
|
31165
31513
|
return "unchanged";
|
|
31166
31514
|
}
|
|
31167
|
-
const text = exists ?
|
|
31515
|
+
const text = exists ? readFileSync54(path, "utf8") : NEW_SETTINGS_FILE;
|
|
31168
31516
|
const settings = parseSettings(text);
|
|
31169
31517
|
if (settings === void 0) return "invalid";
|
|
31170
31518
|
if (!hasValidHooks(settings)) return "invalid-hooks";
|
|
@@ -31183,9 +31531,9 @@ function syncSessionCheck(params) {
|
|
|
31183
31531
|
return present ? "removed" : "unchanged";
|
|
31184
31532
|
}
|
|
31185
31533
|
if (present) return recorded ? "unchanged" : "kept";
|
|
31186
|
-
mkdirSync24(
|
|
31534
|
+
mkdirSync24(dirname35(path), { recursive: true });
|
|
31187
31535
|
const added = withCheck(text);
|
|
31188
|
-
|
|
31536
|
+
writeFileSync31(path, added.text);
|
|
31189
31537
|
updateStationManifest({
|
|
31190
31538
|
folder: manifestFolder,
|
|
31191
31539
|
patch: {
|
|
@@ -31199,8 +31547,8 @@ function syncSessionCheck(params) {
|
|
|
31199
31547
|
function writeOrDelete(params) {
|
|
31200
31548
|
const left = parseSettings(params.text);
|
|
31201
31549
|
if (params.created && left !== void 0 && Object.keys(left).length === 0)
|
|
31202
|
-
|
|
31203
|
-
else
|
|
31550
|
+
unlinkSync4(params.path);
|
|
31551
|
+
else writeFileSync31(params.path, params.text);
|
|
31204
31552
|
}
|
|
31205
31553
|
function parseSettings(text) {
|
|
31206
31554
|
const errors = [];
|
|
@@ -31395,15 +31743,10 @@ function resolveSyncVendor(params) {
|
|
|
31395
31743
|
candidates: detection.kind === "choose" ? detection.candidates : [...VENDOR_IDS]
|
|
31396
31744
|
};
|
|
31397
31745
|
const howToSet = `Pass \`--vendor <${VENDOR_IDS.join("|")}>\` to set it.`;
|
|
31398
|
-
|
|
31399
|
-
return {
|
|
31400
|
-
kind: "unset",
|
|
31401
|
-
notice: `skills sync: no vendor remembered for the models (\`dialecte models\`). ${howToSet}
|
|
31402
|
-
`
|
|
31403
|
-
};
|
|
31746
|
+
const detected = detection.kind === "choose" ? ` Several agents or a multi-vendor host were detected (${detection.candidates.join(", ")}).` : "";
|
|
31404
31747
|
return {
|
|
31405
|
-
kind: "
|
|
31406
|
-
|
|
31748
|
+
kind: "unset",
|
|
31749
|
+
notice: `skills sync: no vendor remembered for the models (\`dialecte models\`).${detected} ${howToSet}
|
|
31407
31750
|
`
|
|
31408
31751
|
};
|
|
31409
31752
|
}
|
|
@@ -31414,30 +31757,33 @@ function presentPaths(cwd) {
|
|
|
31414
31757
|
const candidates = VENDOR_HOSTS.flatMap((host) => host.anyOf.flat());
|
|
31415
31758
|
return new Set(
|
|
31416
31759
|
candidates.filter(
|
|
31417
|
-
(path) =>
|
|
31760
|
+
(path) => existsSync77(join82(cwd, path)) && !holdsOnlySyncedSkills({ cwd, path })
|
|
31418
31761
|
)
|
|
31419
31762
|
);
|
|
31420
31763
|
}
|
|
31421
31764
|
function holdsOnlySyncedSkills(params) {
|
|
31422
31765
|
const skillFolders = Object.values(AGENT_SKILL_FOLDERS);
|
|
31423
|
-
if (skillFolders.includes(params.path)) return isSyncedSkillsFolder(
|
|
31424
|
-
|
|
31425
|
-
|
|
31426
|
-
|
|
31766
|
+
if (skillFolders.includes(params.path)) return isSyncedSkillsFolder(join82(params.cwd, params.path));
|
|
31767
|
+
const stat = statSync12(join82(params.cwd, params.path));
|
|
31768
|
+
if (params.path === AGENTS_FILE)
|
|
31769
|
+
return stat.isFile() && holdsOnlyTheAgentsCheck(readFileSync55(join82(params.cwd, params.path), "utf8"));
|
|
31770
|
+
if (!stat.isDirectory()) return false;
|
|
31771
|
+
const entries = readdirSync17(join82(params.cwd, params.path));
|
|
31772
|
+
const ownSkillFolders2 = skillFolders.filter((folder) => dirname36(folder) === params.path);
|
|
31427
31773
|
return entries.length > 0 && entries.every(
|
|
31428
31774
|
(entry) => ownSkillFolders2.some(
|
|
31429
|
-
(folder) => basename11(folder) === entry && isSyncedSkillsFolder(
|
|
31775
|
+
(folder) => basename11(folder) === entry && isSyncedSkillsFolder(join82(params.cwd, folder))
|
|
31430
31776
|
) || isSyncedClaudeExtra({ cwd: params.cwd, folder: params.path, entry })
|
|
31431
31777
|
);
|
|
31432
31778
|
}
|
|
31433
31779
|
function isSyncedClaudeExtra(params) {
|
|
31434
|
-
if (params.folder !==
|
|
31435
|
-
const manifest = readManifestOrNothing(
|
|
31436
|
-
const path =
|
|
31437
|
-
if (path ===
|
|
31780
|
+
if (params.folder !== dirname36(AGENT_SKILL_FOLDERS.claude)) return false;
|
|
31781
|
+
const manifest = readManifestOrNothing(join82(params.cwd, AGENT_SKILL_FOLDERS.claude));
|
|
31782
|
+
const path = join82(params.cwd, params.folder, params.entry);
|
|
31783
|
+
if (path === join82(params.cwd, CLAUDE_AGENTS_FOLDER))
|
|
31438
31784
|
return readdirSync17(path).every((file) => manifest.stationAgents?.includes(file));
|
|
31439
|
-
if (path ===
|
|
31440
|
-
return manifest.sessionCheck === true && holdsOnlyTheCheck(
|
|
31785
|
+
if (path === join82(params.cwd, CLAUDE_SETTINGS_FILE))
|
|
31786
|
+
return manifest.sessionCheck === true && holdsOnlyTheCheck(readFileSync55(path, "utf8"));
|
|
31441
31787
|
return false;
|
|
31442
31788
|
}
|
|
31443
31789
|
function readManifestOrNothing(folder) {
|
|
@@ -31448,7 +31794,7 @@ function readManifestOrNothing(folder) {
|
|
|
31448
31794
|
}
|
|
31449
31795
|
}
|
|
31450
31796
|
function isSyncedSkillsFolder(folder) {
|
|
31451
|
-
if (!
|
|
31797
|
+
if (!existsSync77(join82(folder, MANIFEST_FILE))) return false;
|
|
31452
31798
|
const { installed } = readSyncManifest(folder);
|
|
31453
31799
|
return readdirSync17(folder).every((entry) => entry === MANIFEST_FILE || installed.includes(entry));
|
|
31454
31800
|
}
|
|
@@ -31463,101 +31809,6 @@ var GENERATED_MARKER_PATTERN = /<!-- (?:dialecte-skills:generated ([\w-]+)|\/dia
|
|
|
31463
31809
|
var STRONG_UNDERSCORE_PATTERN = /__(?=\S)(.+?)(?<=\S)__/g;
|
|
31464
31810
|
var EMPHASIS_UNDERSCORE_PATTERN = /(^|[^\w_])_(?=\S)([^_\n]+?)(?<=\S)_(?![\w_])/g;
|
|
31465
31811
|
|
|
31466
|
-
// src/lib/skills/skill-file.ts
|
|
31467
|
-
function readFrontmatter(markdown) {
|
|
31468
|
-
const block = /^---\n([\s\S]*?)\n---/.exec(withUnixLineEndings(markdown))?.[1];
|
|
31469
|
-
if (!block) return { name: void 0, description: void 0 };
|
|
31470
|
-
return {
|
|
31471
|
-
name: readField2({ block, field: "name" }),
|
|
31472
|
-
description: readField2({ block, field: "description" })
|
|
31473
|
-
};
|
|
31474
|
-
}
|
|
31475
|
-
function readField2(params) {
|
|
31476
|
-
const match = new RegExp(`^${params.field}:[ \\t]*(.*)\\n?((?:[ \\t]+.*\\n?)*)`, "m").exec(
|
|
31477
|
-
params.block
|
|
31478
|
-
);
|
|
31479
|
-
const line = match?.[1]?.trim();
|
|
31480
|
-
if (line === void 0) return void 0;
|
|
31481
|
-
const value = /^[>|][+-]?$/.test(line) ? (match?.[2] ?? "").split("\n").map((continuation) => continuation.trim()).filter(Boolean).join(" ") : line;
|
|
31482
|
-
if (value === "") return void 0;
|
|
31483
|
-
return value.replace(/^(['"])(.*)\1$/, "$2");
|
|
31484
|
-
}
|
|
31485
|
-
function withUnixLineEndings(text) {
|
|
31486
|
-
return text.replace(/\r\n/g, "\n");
|
|
31487
|
-
}
|
|
31488
|
-
function validateFrontmatter(params) {
|
|
31489
|
-
const { name, description } = params.frontmatter;
|
|
31490
|
-
const messages = [];
|
|
31491
|
-
if (!name || !SKILL_NAME_PATTERN.test(name))
|
|
31492
|
-
messages.push(
|
|
31493
|
-
`name "${name ?? ""}" must be lowercase letters, digits and single hyphens (1-64)`
|
|
31494
|
-
);
|
|
31495
|
-
else if (name !== params.folderName)
|
|
31496
|
-
messages.push(`name "${name}" must match its folder "${params.folderName}"`);
|
|
31497
|
-
if (!description || description.length > DESCRIPTION_MAX_LENGTH)
|
|
31498
|
-
messages.push(`description is required (1-${DESCRIPTION_MAX_LENGTH} characters)`);
|
|
31499
|
-
return messages;
|
|
31500
|
-
}
|
|
31501
|
-
function extractClaims(text) {
|
|
31502
|
-
const markdown = withUnixLineEndings(text);
|
|
31503
|
-
const prose = markdown.replace(ANY_FENCE_PATTERN, "");
|
|
31504
|
-
const inlineCode = [...prose.matchAll(INLINE_CODE_PATTERN)].map((match) => match[1].trim());
|
|
31505
|
-
const directives = readDirectives(prose.replace(INLINE_CODE_PATTERN, ""));
|
|
31506
|
-
const codeCalls = [...markdown.matchAll(CODE_FENCE_PATTERN)].flatMap(
|
|
31507
|
-
(fence) => [...fence[1].matchAll(CODE_CALL_PATTERN)].map((call) => call[1])
|
|
31508
|
-
);
|
|
31509
|
-
return {
|
|
31510
|
-
apiPaths: unique([...inlineCode, ...codeCalls].map(normalizeApiPath)),
|
|
31511
|
-
repositoryPaths: unique(inlineCode.map(toRepositoryPath)),
|
|
31512
|
-
npmScripts: unique(inlineCode.map(readNpmScript)),
|
|
31513
|
-
links: unique(
|
|
31514
|
-
[...prose.matchAll(/\]\(([^)\s]+)\)/g)].map(
|
|
31515
|
-
(match) => /^[a-z]+:|^#/.test(match[1]) ? void 0 : match[1].split("#")[0]
|
|
31516
|
-
)
|
|
31517
|
-
),
|
|
31518
|
-
ignored: directives.ignored,
|
|
31519
|
-
describesWorkspace: directives.describesWorkspace
|
|
31520
|
-
};
|
|
31521
|
-
}
|
|
31522
|
-
function readNpmScript(code2) {
|
|
31523
|
-
const words = /^npm run (.+)$/.exec(code2)?.[1].split(/\s+/);
|
|
31524
|
-
if (!words) return void 0;
|
|
31525
|
-
let index = 0;
|
|
31526
|
-
while (words[index]?.startsWith("-")) index += NPM_OPTIONS_WITH_VALUE.has(words[index]) ? 2 : 1;
|
|
31527
|
-
const script = words[index];
|
|
31528
|
-
return script !== void 0 && /^[\w:.-]+$/.test(script) ? script : void 0;
|
|
31529
|
-
}
|
|
31530
|
-
function readDirectives(markdown) {
|
|
31531
|
-
const ignored = [];
|
|
31532
|
-
let describesWorkspace = false;
|
|
31533
|
-
for (const match of markdown.matchAll(DIRECTIVE_PATTERN)) {
|
|
31534
|
-
const body = match[1].trim();
|
|
31535
|
-
if (body === "workspace") describesWorkspace = true;
|
|
31536
|
-
else if (body.startsWith("ignore:"))
|
|
31537
|
-
ignored.push(...body.slice("ignore:".length).trim().split(/\s+/));
|
|
31538
|
-
}
|
|
31539
|
-
return { ignored, describesWorkspace };
|
|
31540
|
-
}
|
|
31541
|
-
function normalizeApiPath(code2) {
|
|
31542
|
-
const expression = code2.split("(")[0];
|
|
31543
|
-
if (!/^[\w.]+$/.test(expression) || expression === "doc.query") return void 0;
|
|
31544
|
-
if (FILE_EXTENSION_PATTERN.test(expression)) return void 0;
|
|
31545
|
-
for (const [prefix2, root] of API_ROOTS) {
|
|
31546
|
-
if (!expression.startsWith(prefix2)) continue;
|
|
31547
|
-
const member = expression.slice(prefix2.length);
|
|
31548
|
-
return member ? `${root}.${member}` : void 0;
|
|
31549
|
-
}
|
|
31550
|
-
return void 0;
|
|
31551
|
-
}
|
|
31552
|
-
function toRepositoryPath(code2) {
|
|
31553
|
-
if (!/^[\w.-]+(\/[\w.-]+)+\/?$/.test(code2)) return void 0;
|
|
31554
|
-
if (/^(node_modules|https?:)/.test(code2) || code2.startsWith(".")) return void 0;
|
|
31555
|
-
return code2.replace(/\/$/, "");
|
|
31556
|
-
}
|
|
31557
|
-
function unique(values) {
|
|
31558
|
-
return [...new Set(values.filter((value) => Boolean(value)))];
|
|
31559
|
-
}
|
|
31560
|
-
|
|
31561
31812
|
// src/lib/skills/check-skill-page.ts
|
|
31562
31813
|
function checkSkillPage(params) {
|
|
31563
31814
|
const { file, markdown, folderName, siblingFiles, facts, workspaceFacts } = params;
|
|
@@ -31622,9 +31873,77 @@ function isSkillFileOrFolder(params) {
|
|
|
31622
31873
|
return [...params.siblingFiles].some((siblingFile) => siblingFile.startsWith(`${target}/`));
|
|
31623
31874
|
}
|
|
31624
31875
|
|
|
31876
|
+
// src/lib/skills/check-station-definitions.constants.ts
|
|
31877
|
+
var STATIONS_FILE = "skills/dialecte-lot/references/stations.md";
|
|
31878
|
+
var SECTION_BOUNDARY_PATTERN = /^#{1,3}\s/;
|
|
31879
|
+
var STATION_HEADING_PATTERN = /^###\s+(\S+)\s*$/;
|
|
31880
|
+
var FENCE_PATTERN = /^\s*(```|~~~)/;
|
|
31881
|
+
var DEFINITION_LINE_PATTERN = /^- (Tier|Access): /;
|
|
31882
|
+
|
|
31883
|
+
// src/lib/skills/check-station-definitions.ts
|
|
31884
|
+
function checkStationDefinitions(params) {
|
|
31885
|
+
if (params.markdown === void 0)
|
|
31886
|
+
return [finding(`missing: it defines the stations the cli writes agents for`)];
|
|
31887
|
+
const sections = readSections(params.markdown);
|
|
31888
|
+
const findings = STATIONS.flatMap((station) => checkStation({ station, sections }));
|
|
31889
|
+
const known = new Set(STATIONS.map((station) => station.name));
|
|
31890
|
+
for (const section of sections)
|
|
31891
|
+
if (!known.has(section.name) && holdsDefinitionLine(section))
|
|
31892
|
+
findings.push(finding(`section "${section.name}" is no station of the cli`));
|
|
31893
|
+
return findings;
|
|
31894
|
+
}
|
|
31895
|
+
function finding(message) {
|
|
31896
|
+
return { file: STATIONS_FILE, severity: "error", message };
|
|
31897
|
+
}
|
|
31898
|
+
function holdsDefinitionLine(section) {
|
|
31899
|
+
return section.lines.some((line) => DEFINITION_LINE_PATTERN.test(line));
|
|
31900
|
+
}
|
|
31901
|
+
function readSections(markdown) {
|
|
31902
|
+
const sections = [];
|
|
31903
|
+
let current;
|
|
31904
|
+
let fenced = false;
|
|
31905
|
+
for (const line of markdown.replace(/\r\n/g, "\n").split("\n")) {
|
|
31906
|
+
if (FENCE_PATTERN.test(line)) fenced = !fenced;
|
|
31907
|
+
if (fenced || FENCE_PATTERN.test(line)) continue;
|
|
31908
|
+
const name = STATION_HEADING_PATTERN.exec(line)?.[1];
|
|
31909
|
+
if (name !== void 0) {
|
|
31910
|
+
current = { name, lines: [] };
|
|
31911
|
+
sections.push(current);
|
|
31912
|
+
} else if (SECTION_BOUNDARY_PATTERN.test(line)) current = void 0;
|
|
31913
|
+
else current?.lines.push(line);
|
|
31914
|
+
}
|
|
31915
|
+
return sections;
|
|
31916
|
+
}
|
|
31917
|
+
function checkStation(params) {
|
|
31918
|
+
const { station } = params;
|
|
31919
|
+
const own = params.sections.filter((section) => section.name === station.name);
|
|
31920
|
+
if (own.length === 0) return [finding(`station "${station.name}" has no section`)];
|
|
31921
|
+
if (own.length > 1) return [finding(`station "${station.name}" has more than one section`)];
|
|
31922
|
+
return [
|
|
31923
|
+
...checkLine({ station, section: own[0], label: "Tier", expected: station.tier }),
|
|
31924
|
+
...checkLine({ station, section: own[0], label: "Access", expected: station.access })
|
|
31925
|
+
];
|
|
31926
|
+
}
|
|
31927
|
+
function checkLine(params) {
|
|
31928
|
+
const { station, section, label, expected } = params;
|
|
31929
|
+
const pattern = new RegExp(`^- ${label}: (\\S+)\\s*$`);
|
|
31930
|
+
const found = section.lines.map((line) => pattern.exec(line)?.[1]).find((value) => value);
|
|
31931
|
+
if (found === void 0)
|
|
31932
|
+
return [
|
|
31933
|
+
finding(
|
|
31934
|
+
`station "${station.name}": no \`- ${label}: <value>\` line (the cli has ${expected})`
|
|
31935
|
+
)
|
|
31936
|
+
];
|
|
31937
|
+
if (found !== expected)
|
|
31938
|
+
return [
|
|
31939
|
+
finding(`station "${station.name}": ${label} line says ${found}, the cli has ${expected}`)
|
|
31940
|
+
];
|
|
31941
|
+
return [];
|
|
31942
|
+
}
|
|
31943
|
+
|
|
31625
31944
|
// src/lib/skills/export-entries.ts
|
|
31626
|
-
import { existsSync as
|
|
31627
|
-
import { join as
|
|
31945
|
+
import { existsSync as existsSync78, readFileSync as readFileSync56 } from "fs";
|
|
31946
|
+
import { join as join83 } from "path";
|
|
31628
31947
|
|
|
31629
31948
|
// src/lib/skills/export-entries.constants.ts
|
|
31630
31949
|
var SOURCE_FOLDER = "src";
|
|
@@ -31639,7 +31958,7 @@ var SUBPATH_PATTERN_MARKER = "*";
|
|
|
31639
31958
|
// src/lib/skills/export-entries.ts
|
|
31640
31959
|
function readExportEntries(params) {
|
|
31641
31960
|
const manifest = JSON.parse(
|
|
31642
|
-
|
|
31961
|
+
readFileSync56(join83(params.root, "package.json"), "utf8")
|
|
31643
31962
|
);
|
|
31644
31963
|
const packageName3 = typeof manifest.name === "string" ? manifest.name : "";
|
|
31645
31964
|
return Object.entries(subpathsOf(manifest.exports)).flatMap(
|
|
@@ -31679,7 +31998,7 @@ function sourceOf(params) {
|
|
|
31679
31998
|
`${withoutExtension}${sourceExtension}`,
|
|
31680
31999
|
`${withoutExtension}/index${sourceExtension}`
|
|
31681
32000
|
]);
|
|
31682
|
-
const source = candidates.find((candidate) =>
|
|
32001
|
+
const source = candidates.find((candidate) => existsSync78(join83(params.root, candidate)));
|
|
31683
32002
|
if (source === void 0)
|
|
31684
32003
|
throw new Error(
|
|
31685
32004
|
`exports entry "${params.subpath}": no source at ${candidates.join(" nor at ")}`
|
|
@@ -31793,9 +32112,9 @@ function findUnclosedGeneratedBlocks(markdown) {
|
|
|
31793
32112
|
}
|
|
31794
32113
|
|
|
31795
32114
|
// src/lib/skills/package-facts.ts
|
|
31796
|
-
import { spawnSync as
|
|
31797
|
-
import { existsSync as
|
|
31798
|
-
import { join as
|
|
32115
|
+
import { spawnSync as spawnSync20 } from "child_process";
|
|
32116
|
+
import { existsSync as existsSync79, readdirSync as readdirSync18, readFileSync as readFileSync57 } from "fs";
|
|
32117
|
+
import { join as join84 } from "path";
|
|
31799
32118
|
|
|
31800
32119
|
// src/lib/skills/package-facts.constants.ts
|
|
31801
32120
|
var EXCLUDED_FOLDERS = [
|
|
@@ -31815,14 +32134,14 @@ function listRepositoryPaths(root) {
|
|
|
31815
32134
|
return gitFiles ? withFolders(gitFiles) : walkRepositoryPaths(root);
|
|
31816
32135
|
}
|
|
31817
32136
|
function listGitFiles(root) {
|
|
31818
|
-
if (!
|
|
31819
|
-
const result =
|
|
32137
|
+
if (!existsSync79(join84(root, ".git"))) return void 0;
|
|
32138
|
+
const result = spawnSync20("git", ["ls-files", "--cached", "--others", "--exclude-standard"], {
|
|
31820
32139
|
cwd: root,
|
|
31821
32140
|
encoding: "utf8",
|
|
31822
32141
|
maxBuffer: 1e8
|
|
31823
32142
|
});
|
|
31824
32143
|
if (result.status !== 0) return void 0;
|
|
31825
|
-
return result.stdout.split("\n").filter(Boolean).filter((path) =>
|
|
32144
|
+
return result.stdout.split("\n").filter(Boolean).filter((path) => existsSync79(join84(root, path)));
|
|
31826
32145
|
}
|
|
31827
32146
|
function withFolders(files) {
|
|
31828
32147
|
const paths = /* @__PURE__ */ new Set();
|
|
@@ -31836,7 +32155,7 @@ function withFolders(files) {
|
|
|
31836
32155
|
function walkRepositoryPaths(root) {
|
|
31837
32156
|
const paths = [];
|
|
31838
32157
|
function walk(relativeFolder) {
|
|
31839
|
-
for (const entry of readdirSync18(
|
|
32158
|
+
for (const entry of readdirSync18(join84(root, relativeFolder), { withFileTypes: true })) {
|
|
31840
32159
|
const path = relativeFolder ? `${relativeFolder}/${entry.name}` : entry.name;
|
|
31841
32160
|
if (entry.isDirectory()) {
|
|
31842
32161
|
if (EXCLUDED_FOLDERS.includes(entry.name) || EXCLUDED_FOLDERS.includes(path)) continue;
|
|
@@ -31849,31 +32168,31 @@ function walkRepositoryPaths(root) {
|
|
|
31849
32168
|
return paths.sort();
|
|
31850
32169
|
}
|
|
31851
32170
|
function readNpmScripts(root) {
|
|
31852
|
-
const path =
|
|
31853
|
-
if (!
|
|
31854
|
-
return new Set(Object.keys(JSON.parse(
|
|
32171
|
+
const path = join84(root, "package.json");
|
|
32172
|
+
if (!existsSync79(path)) return /* @__PURE__ */ new Set();
|
|
32173
|
+
return new Set(Object.keys(JSON.parse(readFileSync57(path, "utf8")).scripts ?? {}));
|
|
31855
32174
|
}
|
|
31856
32175
|
function readWorkspaceFacts(workspaceRoot) {
|
|
31857
32176
|
const packageFolders = readdirSync18(workspaceRoot, { withFileTypes: true }).filter(
|
|
31858
|
-
(entry) => entry.isDirectory() && !entry.name.startsWith(".") &&
|
|
32177
|
+
(entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync79(join84(workspaceRoot, entry.name, "package.json"))
|
|
31859
32178
|
).map((entry) => entry.name).sort();
|
|
31860
32179
|
return {
|
|
31861
32180
|
repositoryPaths: packageFolders.flatMap(
|
|
31862
|
-
(folder) => listRepositoryPaths(
|
|
32181
|
+
(folder) => listRepositoryPaths(join84(workspaceRoot, folder)).map((path) => `${folder}/${path}`)
|
|
31863
32182
|
),
|
|
31864
32183
|
npmScripts: new Set(
|
|
31865
|
-
packageFolders.flatMap((folder) => [...readNpmScripts(
|
|
32184
|
+
packageFolders.flatMap((folder) => [...readNpmScripts(join84(workspaceRoot, folder))])
|
|
31866
32185
|
)
|
|
31867
32186
|
};
|
|
31868
32187
|
}
|
|
31869
32188
|
function listHookConcernFiles(root) {
|
|
31870
32189
|
const concernFilesByFolder = {};
|
|
31871
32190
|
for (const version of discoverVersions(root)) {
|
|
31872
|
-
const hooksFolder =
|
|
31873
|
-
if (!
|
|
32191
|
+
const hooksFolder = join84(root, "src", version, "hooks");
|
|
32192
|
+
if (!existsSync79(hooksFolder)) continue;
|
|
31874
32193
|
for (const folder of readdirSync18(hooksFolder, { withFileTypes: true })) {
|
|
31875
32194
|
if (!folder.isDirectory()) continue;
|
|
31876
|
-
const files = readdirSync18(
|
|
32195
|
+
const files = readdirSync18(join84(hooksFolder, folder.name)).filter(
|
|
31877
32196
|
(file) => file.endsWith(".ts") && !NOT_A_CONCERN_FILE.test(file)
|
|
31878
32197
|
);
|
|
31879
32198
|
concernFilesByFolder[folder.name] = [
|
|
@@ -31886,19 +32205,19 @@ function listHookConcernFiles(root) {
|
|
|
31886
32205
|
|
|
31887
32206
|
// src/lib/stations/sync-station-agents.ts
|
|
31888
32207
|
import {
|
|
31889
|
-
existsSync as
|
|
31890
|
-
lstatSync as
|
|
32208
|
+
existsSync as existsSync80,
|
|
32209
|
+
lstatSync as lstatSync12,
|
|
31891
32210
|
mkdirSync as mkdirSync25,
|
|
31892
|
-
readFileSync as
|
|
32211
|
+
readFileSync as readFileSync58,
|
|
31893
32212
|
rmdirSync as rmdirSync2,
|
|
31894
32213
|
rmSync as rmSync24,
|
|
31895
|
-
writeFileSync as
|
|
32214
|
+
writeFileSync as writeFileSync32
|
|
31896
32215
|
} from "fs";
|
|
31897
|
-
import { join as
|
|
32216
|
+
import { join as join85 } from "path";
|
|
31898
32217
|
function syncStationAgents(params) {
|
|
31899
32218
|
const { cwd, plan } = params;
|
|
31900
|
-
const manifestFolder =
|
|
31901
|
-
const agentsFolder =
|
|
32219
|
+
const manifestFolder = join85(cwd, AGENT_SKILL_FOLDERS.claude);
|
|
32220
|
+
const agentsFolder = join85(cwd, CLAUDE_AGENTS_FOLDER);
|
|
31902
32221
|
const previous = (readSyncManifest(manifestFolder).stationAgents ?? []).filter(
|
|
31903
32222
|
(name) => STATION_AGENT_FILE_PATTERN.test(name)
|
|
31904
32223
|
);
|
|
@@ -31912,16 +32231,16 @@ function syncStationAgents(params) {
|
|
|
31912
32231
|
const owned = [];
|
|
31913
32232
|
const produced = new Set(files.map((file) => file.name));
|
|
31914
32233
|
for (const name of previous.filter((candidate) => !produced.has(candidate))) {
|
|
31915
|
-
const path =
|
|
31916
|
-
if (!
|
|
32234
|
+
const path = join85(agentsFolder, name);
|
|
32235
|
+
if (!existsSync80(path) || !lstatSync12(path).isFile()) continue;
|
|
31917
32236
|
rmSync24(path);
|
|
31918
32237
|
report.removed.push(name);
|
|
31919
32238
|
}
|
|
31920
32239
|
if (report.removed.length > 0) removeFolderIfEmpty(agentsFolder);
|
|
31921
32240
|
for (const file of files) {
|
|
31922
|
-
const path =
|
|
31923
|
-
if (
|
|
31924
|
-
if (
|
|
32241
|
+
const path = join85(agentsFolder, file.name);
|
|
32242
|
+
if (existsSync80(path)) {
|
|
32243
|
+
if (readFileSync58(path, "utf8") === file.content) {
|
|
31925
32244
|
owned.push(file.name);
|
|
31926
32245
|
continue;
|
|
31927
32246
|
}
|
|
@@ -31931,7 +32250,7 @@ function syncStationAgents(params) {
|
|
|
31931
32250
|
}
|
|
31932
32251
|
}
|
|
31933
32252
|
mkdirSync25(agentsFolder, { recursive: true });
|
|
31934
|
-
|
|
32253
|
+
writeFileSync32(path, file.content);
|
|
31935
32254
|
owned.push(file.name);
|
|
31936
32255
|
report.written.push(file.name);
|
|
31937
32256
|
}
|
|
@@ -31976,7 +32295,6 @@ function isSubcommand2(value) {
|
|
|
31976
32295
|
}
|
|
31977
32296
|
async function runSyncCommand(params) {
|
|
31978
32297
|
const choice = await chooseVendor(params);
|
|
31979
|
-
if (choice.exitCode === 2) return { output: choice.output, exitCode: 2 };
|
|
31980
32298
|
runSync({ argv: params.argv, cwd: params.cwd, vendor: choice.vendor });
|
|
31981
32299
|
return { output: choice.output, exitCode: 0 };
|
|
31982
32300
|
}
|
|
@@ -31991,17 +32309,15 @@ async function chooseVendor(params) {
|
|
|
31991
32309
|
cwd: params.cwd,
|
|
31992
32310
|
interactive: params.interactive
|
|
31993
32311
|
});
|
|
31994
|
-
if (resolution.kind === "set") return { vendor: resolution.vendor, output: warnings
|
|
32312
|
+
if (resolution.kind === "set") return { vendor: resolution.vendor, output: warnings };
|
|
31995
32313
|
if (resolution.kind === "unset")
|
|
31996
|
-
return { vendor: void 0, output: warnings + resolution.notice
|
|
31997
|
-
if (resolution.kind === "fail")
|
|
31998
|
-
return { vendor: void 0, output: warnings + resolution.output, exitCode: 2 };
|
|
32314
|
+
return { vendor: void 0, output: warnings + resolution.notice };
|
|
31999
32315
|
const vendor = await askVendor({
|
|
32000
32316
|
candidates: resolution.candidates,
|
|
32001
32317
|
input: params.input,
|
|
32002
32318
|
output: params.output
|
|
32003
32319
|
});
|
|
32004
|
-
return { vendor, output: warnings
|
|
32320
|
+
return { vendor, output: warnings };
|
|
32005
32321
|
}
|
|
32006
32322
|
function runSync(params) {
|
|
32007
32323
|
const { argv, cwd } = params;
|
|
@@ -32011,24 +32327,51 @@ function runSync(params) {
|
|
|
32011
32327
|
throw new Error(
|
|
32012
32328
|
`skills sync: unknown agent ${unknownAgents.join(", ")} (known: ${Object.keys(AGENT_SKILL_FOLDERS).join(", ")})`
|
|
32013
32329
|
);
|
|
32330
|
+
if (hasFlag(argv, "contributing") && hasFlag(argv, "no-contributing"))
|
|
32331
|
+
throw new Error("skills sync: --contributing and --no-contributing exclude each other");
|
|
32014
32332
|
if (params.vendor !== void 0)
|
|
32015
32333
|
for (const folder of listManifestFolders(cwd))
|
|
32016
|
-
rememberVendor({ folder:
|
|
32017
|
-
const
|
|
32334
|
+
rememberVendor({ folder: join86(cwd, folder), vendor: params.vendor });
|
|
32335
|
+
const targetFolders = agents.map((agent) => join86(cwd, AGENT_SKILL_FOLDERS[agent]));
|
|
32336
|
+
const contributing = isContributingSync({ argv, targetFolders });
|
|
32337
|
+
const discovered = discoverSkillSources({ cwd, from: getArg(argv, "from") });
|
|
32338
|
+
const { missingDependencies } = discovered;
|
|
32339
|
+
const { selected: sources, leftOut } = selectAudience({
|
|
32340
|
+
sources: discovered.sources,
|
|
32341
|
+
contributing
|
|
32342
|
+
});
|
|
32343
|
+
const leftOutNames = leftOut.map((source) => source.name);
|
|
32018
32344
|
const report = syncSkills({
|
|
32019
32345
|
sources,
|
|
32020
|
-
targetFolders
|
|
32346
|
+
targetFolders,
|
|
32021
32347
|
mode: hasFlag(argv, "copy") ? "copy" : "link",
|
|
32022
32348
|
keepUnshipped: missingDependencies.length > 0,
|
|
32023
|
-
vendor: params.vendor
|
|
32349
|
+
vendor: params.vendor,
|
|
32350
|
+
leftOut: leftOutNames,
|
|
32351
|
+
contributing
|
|
32024
32352
|
});
|
|
32025
32353
|
for (const source of sources) console.log(`\u2705 ${source.name} (${source.origin})`);
|
|
32026
|
-
for (const name of report.removed)
|
|
32354
|
+
for (const name of report.removed)
|
|
32355
|
+
console.log(
|
|
32356
|
+
leftOutNames.includes(name) ? `\u{1F5D1} ${name} (contributor skill: --contributing installs it)` : `\u{1F5D1} ${name} (no longer shipped)`
|
|
32357
|
+
);
|
|
32358
|
+
const notInstalled = leftOutNames.filter((name) => !report.removed.includes(name));
|
|
32359
|
+
if (notInstalled.length)
|
|
32360
|
+
console.log(
|
|
32361
|
+
`contributor skills not installed: ${notInstalled.join(", ")} (to change a dialecte package: --contributing)`
|
|
32362
|
+
);
|
|
32027
32363
|
syncClaudeCodeExtras({
|
|
32028
32364
|
argv,
|
|
32029
32365
|
cwd,
|
|
32030
32366
|
claudeIsTarget: agents.includes("claude"),
|
|
32031
|
-
vendor: params.vendor
|
|
32367
|
+
vendor: params.vendor,
|
|
32368
|
+
lotLeftOut: leftOutNames.includes(LOT_SKILL)
|
|
32369
|
+
});
|
|
32370
|
+
syncAgentsCheck({
|
|
32371
|
+
argv,
|
|
32372
|
+
cwd,
|
|
32373
|
+
// the check points at the doctor of the cli: enabled while this sync keeps dialecte-lot in any target
|
|
32374
|
+
enabled: targetFolders.some((folder) => readSyncManifest(folder).installed.includes(LOT_SKILL))
|
|
32032
32375
|
});
|
|
32033
32376
|
for (const path of report.conflicts)
|
|
32034
32377
|
console.warn(`\u26A0\uFE0F ${path} exists and was not installed by sync: left untouched`);
|
|
@@ -32039,9 +32382,14 @@ function runSync(params) {
|
|
|
32039
32382
|
if (sources.length === 0 && missingDependencies.length === 0)
|
|
32040
32383
|
console.log("No dependency ships skills (look for skills/<name>/SKILL.md).");
|
|
32041
32384
|
}
|
|
32385
|
+
function isContributingSync(params) {
|
|
32386
|
+
if (hasFlag(params.argv, "contributing")) return true;
|
|
32387
|
+
if (hasFlag(params.argv, "no-contributing")) return false;
|
|
32388
|
+
return params.targetFolders.some((folder) => readSyncManifest(folder).contributing === true);
|
|
32389
|
+
}
|
|
32042
32390
|
function syncClaudeCodeExtras(params) {
|
|
32043
32391
|
const { argv, cwd, claudeIsTarget } = params;
|
|
32044
|
-
const manifest = readSyncManifest(
|
|
32392
|
+
const manifest = readSyncManifest(join86(cwd, AGENT_SKILL_FOLDERS.claude));
|
|
32045
32393
|
const vendor = params.vendor ?? manifest.vendor;
|
|
32046
32394
|
const hasLot = claudeIsTarget && manifest.installed.includes(LOT_SKILL);
|
|
32047
32395
|
const plan = hasLot ? planStationAgents({ vendor: vendor !== void 0 && isVendorId(vendor) ? vendor : void 0 }) : { kind: "files", files: [] };
|
|
@@ -32052,7 +32400,9 @@ function syncClaudeCodeExtras(params) {
|
|
|
32052
32400
|
for (const path of agents.conflicts)
|
|
32053
32401
|
console.warn(`\u26A0\uFE0F ${path} exists and was not written by sync: left untouched`);
|
|
32054
32402
|
if (claudeIsTarget && !hasLot)
|
|
32055
|
-
console.log(
|
|
32403
|
+
console.log(
|
|
32404
|
+
params.lotLeftOut ? "no station agents: they come with the contributor skills (--contributing)" : `no station agents: no dependency ships the ${LOT_SKILL} skill`
|
|
32405
|
+
);
|
|
32056
32406
|
if (hasLot && agents.skippedReason) console.log(agents.skippedReason);
|
|
32057
32407
|
const session = syncSessionCheck({
|
|
32058
32408
|
cwd,
|
|
@@ -32074,6 +32424,20 @@ function syncClaudeCodeExtras(params) {
|
|
|
32074
32424
|
`\u26A0\uFE0F ${CLAUDE_SETTINGS_FILE}: "hooks" is not an object or "hooks.SessionStart" is not a list: session-start check not added or removed`
|
|
32075
32425
|
);
|
|
32076
32426
|
}
|
|
32427
|
+
function syncAgentsCheck(params) {
|
|
32428
|
+
const state = syncAgentsFileCheck({
|
|
32429
|
+
cwd: params.cwd,
|
|
32430
|
+
enabled: params.enabled && !hasFlag(params.argv, "no-session-check")
|
|
32431
|
+
});
|
|
32432
|
+
if (state === "added")
|
|
32433
|
+
console.log(`\u2705 ${AGENTS_FILE}: session-start check (${SESSION_CHECK_COMMAND})`);
|
|
32434
|
+
if (state === "updated") console.log(`\u2705 ${AGENTS_FILE}: session-start check updated`);
|
|
32435
|
+
if (state === "removed") console.log(`\u{1F5D1} ${AGENTS_FILE}: session-start check removed`);
|
|
32436
|
+
if (state === "unclosed")
|
|
32437
|
+
console.warn(
|
|
32438
|
+
`\u26A0\uFE0F ${AGENTS_FILE}: the dialecte session-check section is not closed: left as it is`
|
|
32439
|
+
);
|
|
32440
|
+
}
|
|
32077
32441
|
function generatePages(params) {
|
|
32078
32442
|
const { cwd } = params;
|
|
32079
32443
|
const blocks = renderBlocks({ cwd, methods: params.methods });
|
|
@@ -32094,12 +32458,12 @@ function generatePages(params) {
|
|
|
32094
32458
|
console.error(`\u274C ${page.file}: unknown generated block "${kind}"`);
|
|
32095
32459
|
}
|
|
32096
32460
|
if (findStaleGeneratedKinds({ markdown, blocks }).length === 0) continue;
|
|
32097
|
-
|
|
32461
|
+
writeFileSync33(join86(cwd, page.file), result.markdown);
|
|
32098
32462
|
written.push(page.file);
|
|
32099
32463
|
console.log(`\u270F\uFE0F ${page.file}`);
|
|
32100
32464
|
}
|
|
32101
32465
|
for (const apiJson of staleApiJsonFiles({ cwd, methods: params.methods })) {
|
|
32102
|
-
|
|
32466
|
+
writeFileSync33(join86(cwd, apiJson.file), apiJson.content);
|
|
32103
32467
|
written.push(apiJson.file);
|
|
32104
32468
|
console.log(`\u270F\uFE0F ${apiJson.file}`);
|
|
32105
32469
|
}
|
|
@@ -32153,17 +32517,19 @@ function checkPages(params) {
|
|
|
32153
32517
|
message: `generated block "${kind}" is stale: run \`dialecte skills generate\``
|
|
32154
32518
|
});
|
|
32155
32519
|
}
|
|
32520
|
+
if (pages.some((page) => page.skillName === LOT_SKILL))
|
|
32521
|
+
findings.push(...checkStationDefinitions({ markdown: readStationsPage(cwd) }));
|
|
32156
32522
|
for (const apiJson of staleApiJsonFiles({ cwd, methods }))
|
|
32157
32523
|
findings.push({
|
|
32158
32524
|
file: apiJson.file,
|
|
32159
32525
|
severity: "error",
|
|
32160
32526
|
message: "missing or stale: run `dialecte skills generate`"
|
|
32161
32527
|
});
|
|
32162
|
-
for (const
|
|
32163
|
-
(
|
|
32164
|
-
`${
|
|
32528
|
+
for (const finding2 of findings)
|
|
32529
|
+
(finding2.severity === "error" ? console.error : console.warn)(
|
|
32530
|
+
`${finding2.severity === "error" ? "\u274C" : "\u26A0\uFE0F "} ${finding2.file}: ${finding2.message}`
|
|
32165
32531
|
);
|
|
32166
|
-
const errors = findings.filter((
|
|
32532
|
+
const errors = findings.filter((finding2) => finding2.severity === "error").length;
|
|
32167
32533
|
const methodCount = methods.filter((method) => method.entry === void 0).length;
|
|
32168
32534
|
const exportCount = indexedMethods(methods).filter(
|
|
32169
32535
|
({ entry }) => entry.entry !== void 0
|
|
@@ -32197,8 +32563,8 @@ function staleApiJsonFiles(params) {
|
|
|
32197
32563
|
const content = renderApiJson(
|
|
32198
32564
|
buildApiJson({ packageName: readPackageName(cwd), methods: params.methods, root: cwd })
|
|
32199
32565
|
);
|
|
32200
|
-
return pagesWithIndex.map((page) => ({ file: `${
|
|
32201
|
-
(apiJson) => !holdsSameJson({ path:
|
|
32566
|
+
return pagesWithIndex.map((page) => ({ file: `${dirname37(page.file)}/${API_JSON_FILE}`, content })).filter(
|
|
32567
|
+
(apiJson) => !holdsSameJson({ path: join86(cwd, apiJson.file), content: apiJson.content })
|
|
32202
32568
|
);
|
|
32203
32569
|
}
|
|
32204
32570
|
function holdsGeneratedBlock(params) {
|
|
@@ -32207,13 +32573,13 @@ function holdsGeneratedBlock(params) {
|
|
|
32207
32573
|
);
|
|
32208
32574
|
}
|
|
32209
32575
|
function readPackageName(cwd) {
|
|
32210
|
-
const manifest = JSON.parse(
|
|
32576
|
+
const manifest = JSON.parse(readFileSync59(join86(cwd, "package.json"), "utf8"));
|
|
32211
32577
|
return typeof manifest.name === "string" ? manifest.name : "";
|
|
32212
32578
|
}
|
|
32213
32579
|
function holdsSameJson(params) {
|
|
32214
|
-
if (!
|
|
32580
|
+
if (!existsSync81(params.path)) return false;
|
|
32215
32581
|
try {
|
|
32216
|
-
return JSON.stringify(JSON.parse(
|
|
32582
|
+
return JSON.stringify(JSON.parse(readFileSync59(params.path, "utf8"))) === JSON.stringify(JSON.parse(params.content));
|
|
32217
32583
|
} catch {
|
|
32218
32584
|
return false;
|
|
32219
32585
|
}
|
|
@@ -32228,11 +32594,15 @@ function renderBlocks(params) {
|
|
|
32228
32594
|
intents: renderIntentIndex(params.methods)
|
|
32229
32595
|
};
|
|
32230
32596
|
}
|
|
32597
|
+
function readStationsPage(cwd) {
|
|
32598
|
+
const path = join86(cwd, STATIONS_FILE);
|
|
32599
|
+
return existsSync81(path) ? readFileSync59(path, "utf8") : void 0;
|
|
32600
|
+
}
|
|
32231
32601
|
function readPage(params) {
|
|
32232
|
-
return
|
|
32602
|
+
return readFileSync59(join86(params.cwd, params.page.file), "utf8").replace(/\r\n/g, "\n");
|
|
32233
32603
|
}
|
|
32234
32604
|
function listSkillPages(cwd) {
|
|
32235
|
-
const skillsRoot =
|
|
32605
|
+
const skillsRoot = join86(cwd, SKILLS_FOLDER);
|
|
32236
32606
|
let skillNames;
|
|
32237
32607
|
try {
|
|
32238
32608
|
skillNames = readdirSync19(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -32240,7 +32610,7 @@ function listSkillPages(cwd) {
|
|
|
32240
32610
|
return [];
|
|
32241
32611
|
}
|
|
32242
32612
|
return skillNames.flatMap(
|
|
32243
|
-
(skillName) => listRepositoryPaths(
|
|
32613
|
+
(skillName) => listRepositoryPaths(join86(skillsRoot, skillName)).filter((path) => path.endsWith(".md") && !path.startsWith("evals/")).map((path) => ({
|
|
32244
32614
|
file: `${SKILLS_FOLDER}/${skillName}/${path}`,
|
|
32245
32615
|
skillName,
|
|
32246
32616
|
isSkillFile: path === "SKILL.md"
|
|
@@ -32248,22 +32618,22 @@ function listSkillPages(cwd) {
|
|
|
32248
32618
|
);
|
|
32249
32619
|
}
|
|
32250
32620
|
function siblingFilesOf(params) {
|
|
32251
|
-
const skillFolder =
|
|
32252
|
-
const pageFolder =
|
|
32621
|
+
const skillFolder = join86(params.cwd, SKILLS_FOLDER, params.skillName);
|
|
32622
|
+
const pageFolder = dirname37(join86(params.cwd, params.page));
|
|
32253
32623
|
return new Set(
|
|
32254
32624
|
listRepositoryPaths(skillFolder).map(
|
|
32255
|
-
(path) => relative9(pageFolder,
|
|
32625
|
+
(path) => relative9(pageFolder, join86(skillFolder, path)).split(sep2).join("/")
|
|
32256
32626
|
)
|
|
32257
32627
|
);
|
|
32258
32628
|
}
|
|
32259
32629
|
|
|
32260
32630
|
// src/lib/tdd/production-states.ts
|
|
32261
|
-
import { join as
|
|
32631
|
+
import { join as join87 } from "path";
|
|
32262
32632
|
function readProductionState(params) {
|
|
32263
32633
|
const { root, base, packageJson } = params;
|
|
32264
32634
|
const files = {};
|
|
32265
32635
|
for (const file of listChangedSince({ root, base }))
|
|
32266
|
-
if (isProductionPath({ file, packageJson })) files[file] = hashFile(
|
|
32636
|
+
if (isProductionPath({ file, packageJson })) files[file] = hashFile(join87(root, file));
|
|
32267
32637
|
const deleted = readGit({
|
|
32268
32638
|
root,
|
|
32269
32639
|
args: ["diff", "--name-only", "--relative", "--no-renames", "--diff-filter=D", base]
|
|
@@ -32850,7 +33220,7 @@ function isSubcommand3(word) {
|
|
|
32850
33220
|
}
|
|
32851
33221
|
|
|
32852
33222
|
// src/commands/text.ts
|
|
32853
|
-
import { existsSync as
|
|
33223
|
+
import { existsSync as existsSync82, readFileSync as readFileSync60 } from "fs";
|
|
32854
33224
|
import { resolve as resolve27 } from "path";
|
|
32855
33225
|
|
|
32856
33226
|
// src/lib/text-check/text-check.constants.ts
|
|
@@ -32871,7 +33241,7 @@ var SUBJECT_MAX_LENGTH = 72;
|
|
|
32871
33241
|
var RECAP_START = "<details";
|
|
32872
33242
|
var HEADING_PATTERN = /^ {0,3}(#{1,6})(?:[ \t]+(.*))?$/;
|
|
32873
33243
|
var CLOSING_HASHES_PATTERN = /(^|[ \t]+)#+[ \t]*$/;
|
|
32874
|
-
var
|
|
33244
|
+
var FENCE_PATTERN2 = /^ {0,3}(`{3,}|~{3,})/;
|
|
32875
33245
|
var WORD_PATTERN = /[\p{L}\p{N}]/u;
|
|
32876
33246
|
var PROBLEM_TEXT = {
|
|
32877
33247
|
beforeFirstHeading: "text before the first heading",
|
|
@@ -32913,7 +33283,7 @@ function readHumanPart(text) {
|
|
|
32913
33283
|
for (const [index, raw] of text.split("\n").entries()) {
|
|
32914
33284
|
const line = raw.replace(/\r$/, "");
|
|
32915
33285
|
if (line.trim().startsWith(RECAP_START)) break;
|
|
32916
|
-
const fenceMark =
|
|
33286
|
+
const fenceMark = FENCE_PATTERN2.exec(line)?.[1];
|
|
32917
33287
|
if (fence !== void 0) {
|
|
32918
33288
|
if (fenceMark && fenceMark[0] === fence[0] && fenceMark.length >= fence.length && !line.trim().slice(fenceMark.length).trim())
|
|
32919
33289
|
fence = void 0;
|
|
@@ -33071,11 +33441,11 @@ function runText2(params) {
|
|
|
33071
33441
|
if (read.words.length !== 1) return { exitCode: 2, output: TEXT_CHECK_USAGE };
|
|
33072
33442
|
const [file] = read.words;
|
|
33073
33443
|
const path = resolve27(params.cwd, file);
|
|
33074
|
-
if (!
|
|
33444
|
+
if (!existsSync82(path)) return { exitCode: 1, output: `text check: no file ${path}` };
|
|
33075
33445
|
return renderTextCheck({
|
|
33076
33446
|
file,
|
|
33077
33447
|
kind,
|
|
33078
|
-
check: checkText({ text:
|
|
33448
|
+
check: checkText({ text: readFileSync60(path, "utf8"), kind })
|
|
33079
33449
|
});
|
|
33080
33450
|
}
|
|
33081
33451
|
function isTextKind(kind) {
|
|
@@ -33083,9 +33453,9 @@ function isTextKind(kind) {
|
|
|
33083
33453
|
}
|
|
33084
33454
|
|
|
33085
33455
|
// src/commands/worktree.ts
|
|
33086
|
-
import { spawnSync as
|
|
33456
|
+
import { spawnSync as spawnSync22 } from "child_process";
|
|
33087
33457
|
import { tmpdir as tmpdir7 } from "os";
|
|
33088
|
-
import { dirname as
|
|
33458
|
+
import { dirname as dirname39, join as join89, relative as relative11, resolve as resolve28 } from "path";
|
|
33089
33459
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
33090
33460
|
|
|
33091
33461
|
// src/lib/card/render-card.ts
|
|
@@ -33137,9 +33507,9 @@ function wrapText2(params) {
|
|
|
33137
33507
|
}
|
|
33138
33508
|
|
|
33139
33509
|
// src/lib/worktree/prune-worktrees.ts
|
|
33140
|
-
import { spawnSync as
|
|
33141
|
-
import { existsSync as
|
|
33142
|
-
import { basename as basename12, dirname as
|
|
33510
|
+
import { spawnSync as spawnSync21 } from "child_process";
|
|
33511
|
+
import { existsSync as existsSync83, lstatSync as lstatSync13, readdirSync as readdirSync20, readFileSync as readFileSync61, realpathSync as realpathSync11, statSync as statSync13 } from "fs";
|
|
33512
|
+
import { basename as basename12, dirname as dirname38, isAbsolute as isAbsolute11, join as join88, relative as relative10, sep as sep3 } from "path";
|
|
33143
33513
|
function planPrune(params) {
|
|
33144
33514
|
const scratchRoots = [
|
|
33145
33515
|
.../* @__PURE__ */ new Set([params.scratchRoot, params.formerScratchRoot ?? params.scratchRoot])
|
|
@@ -33150,15 +33520,15 @@ function planPrune(params) {
|
|
|
33150
33520
|
});
|
|
33151
33521
|
const links = [
|
|
33152
33522
|
params.workspace,
|
|
33153
|
-
|
|
33154
|
-
|
|
33523
|
+
join88(params.workspace, WORKTREES_FOLDER),
|
|
33524
|
+
join88(params.workspace, COMMIT_PLAN_FOLDER),
|
|
33155
33525
|
...scratchRoots
|
|
33156
33526
|
].flatMap((folder) => findLinks(folder));
|
|
33157
|
-
const repositories = readdirSync20(params.workspace, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isMainCheckout(
|
|
33158
|
-
(entry) => planRepository({ repository:
|
|
33527
|
+
const repositories = readdirSync20(params.workspace, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isMainCheckout(join88(params.workspace, entry.name))).map(
|
|
33528
|
+
(entry) => planRepository({ repository: join88(params.workspace, entry.name), handovers, links })
|
|
33159
33529
|
);
|
|
33160
33530
|
const scratch = scratchRoots.flatMap(function rehearsalsIn(scratchRoot) {
|
|
33161
|
-
if (!
|
|
33531
|
+
if (!existsSync83(scratchRoot)) return [];
|
|
33162
33532
|
return readdirSync20(scratchRoot).filter((name) => name.startsWith(REHEARSAL_FOLDER_PREFIX)).sort().map((name) => planRehearsalClone({ scratchRoot, name, links }));
|
|
33163
33533
|
});
|
|
33164
33534
|
return { repositories, scratch };
|
|
@@ -33187,13 +33557,13 @@ function planRepository(params) {
|
|
|
33187
33557
|
}).trim();
|
|
33188
33558
|
const keptBranches = /* @__PURE__ */ new Set([baseBranch, checkedOut]);
|
|
33189
33559
|
const ownedRuns = readRuns({ root: repository }).filter(
|
|
33190
|
-
(run25) => (run25.state === "running" || run25.state === "died") &&
|
|
33560
|
+
(run25) => (run25.state === "running" || run25.state === "died") && existsSync83(run25.worktree)
|
|
33191
33561
|
);
|
|
33192
33562
|
const worktrees = listWorktrees(repository).slice(1).map((worktree) => ({
|
|
33193
33563
|
...worktree,
|
|
33194
|
-
name: spellUnder({ path: worktree.path, folder:
|
|
33564
|
+
name: spellUnder({ path: worktree.path, folder: dirname38(repository) })
|
|
33195
33565
|
}));
|
|
33196
|
-
const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !
|
|
33566
|
+
const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !existsSync83(join88(name, ".git")));
|
|
33197
33567
|
for (const worktree of worktrees) {
|
|
33198
33568
|
const { name } = worktree;
|
|
33199
33569
|
if (isLink2(name)) {
|
|
@@ -33205,7 +33575,7 @@ function planRepository(params) {
|
|
|
33205
33575
|
items.push({ kind: "worktree", name, kept: "detached HEAD" });
|
|
33206
33576
|
continue;
|
|
33207
33577
|
}
|
|
33208
|
-
const kept =
|
|
33578
|
+
const kept = existsSync83(name) ? whyKeepWorktree({
|
|
33209
33579
|
repository,
|
|
33210
33580
|
worktree: name,
|
|
33211
33581
|
branch: worktree.branch,
|
|
@@ -33217,7 +33587,7 @@ function planRepository(params) {
|
|
|
33217
33587
|
if (kept) {
|
|
33218
33588
|
keptBranches.add(worktree.branch);
|
|
33219
33589
|
items.push({ kind: "worktree", name, kept: `${worktree.branch}: ${kept}` });
|
|
33220
|
-
} else if (!
|
|
33590
|
+
} else if (!existsSync83(name) && linkedWorktrees.length > 0) {
|
|
33221
33591
|
keptBranches.add(worktree.branch);
|
|
33222
33592
|
items.push({
|
|
33223
33593
|
kind: "worktree",
|
|
@@ -33228,7 +33598,7 @@ function planRepository(params) {
|
|
|
33228
33598
|
items.push({
|
|
33229
33599
|
kind: "worktree",
|
|
33230
33600
|
name,
|
|
33231
|
-
command:
|
|
33601
|
+
command: existsSync83(name) ? `${cd} git worktree remove ${shellQuote(name)}` : `${cd} git worktree prune`
|
|
33232
33602
|
});
|
|
33233
33603
|
}
|
|
33234
33604
|
for (const branch of readGit({
|
|
@@ -33261,7 +33631,7 @@ function planRepository(params) {
|
|
|
33261
33631
|
for (const handover of mine) {
|
|
33262
33632
|
if (handoverStateOf(handover) !== "committed") continue;
|
|
33263
33633
|
const { folder } = handover;
|
|
33264
|
-
if (isReachedThroughLink({ path: folder, root:
|
|
33634
|
+
if (isReachedThroughLink({ path: folder, root: dirname38(repository) })) {
|
|
33265
33635
|
items.push({ kind: "hand-over", name: folder, kept: PRUNE_LINK_REASON });
|
|
33266
33636
|
continue;
|
|
33267
33637
|
}
|
|
@@ -33271,16 +33641,16 @@ function planRepository(params) {
|
|
|
33271
33641
|
reachedBy ? { kind: "hand-over", name: folder, kept: `the link ${reachedBy} points to it` } : {
|
|
33272
33642
|
kind: "hand-over",
|
|
33273
33643
|
name: folder,
|
|
33274
|
-
command: `cd ${shellQuote(
|
|
33644
|
+
command: `cd ${shellQuote(dirname38(folder))} && rm -rf ${shellQuote(basename12(folder))}`
|
|
33275
33645
|
}
|
|
33276
33646
|
);
|
|
33277
33647
|
}
|
|
33278
33648
|
return { repository, baseBranch, items };
|
|
33279
33649
|
}
|
|
33280
33650
|
function findLinks(folder) {
|
|
33281
|
-
if (!
|
|
33651
|
+
if (!existsSync83(folder)) return [];
|
|
33282
33652
|
return readdirSync20(folder, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink()).flatMap(function reach(entry) {
|
|
33283
|
-
const link =
|
|
33653
|
+
const link = join88(folder, entry.name);
|
|
33284
33654
|
try {
|
|
33285
33655
|
return [{ link, target: realpathSync11(link) }];
|
|
33286
33656
|
} catch {
|
|
@@ -33299,13 +33669,13 @@ function isReachedThroughLink(params) {
|
|
|
33299
33669
|
const fromRoot = relative10(params.root, params.path);
|
|
33300
33670
|
if (fromRoot === "" || fromRoot === ".." || fromRoot.startsWith(`..${sep3}`) || isAbsolute11(fromRoot))
|
|
33301
33671
|
return isLink2(params.path);
|
|
33302
|
-
for (let folder = params.path; folder !== params.root && folder !==
|
|
33672
|
+
for (let folder = params.path; folder !== params.root && folder !== dirname38(folder); folder = dirname38(folder))
|
|
33303
33673
|
if (isLink2(folder)) return true;
|
|
33304
33674
|
return false;
|
|
33305
33675
|
}
|
|
33306
33676
|
function isLink2(path) {
|
|
33307
33677
|
try {
|
|
33308
|
-
return
|
|
33678
|
+
return lstatSync13(path).isSymbolicLink();
|
|
33309
33679
|
} catch {
|
|
33310
33680
|
return false;
|
|
33311
33681
|
}
|
|
@@ -33315,11 +33685,11 @@ function isRemovableHandoverFolder(folder) {
|
|
|
33315
33685
|
return !readdirSync20(folder, { withFileTypes: true }).some((entry) => entry.isDirectory());
|
|
33316
33686
|
}
|
|
33317
33687
|
function isMainCheckout(folder) {
|
|
33318
|
-
const gitFolder =
|
|
33319
|
-
return
|
|
33688
|
+
const gitFolder = join88(folder, ".git");
|
|
33689
|
+
return existsSync83(gitFolder) && statSync13(gitFolder).isDirectory() && existsSync83(join88(gitFolder, "HEAD"));
|
|
33320
33690
|
}
|
|
33321
33691
|
function planRehearsalClone(params) {
|
|
33322
|
-
const clone =
|
|
33692
|
+
const clone = join88(params.scratchRoot, params.name);
|
|
33323
33693
|
if (isLink2(clone)) return { kind: "rehearsal clone", name: clone, kept: PRUNE_LINK_REASON };
|
|
33324
33694
|
const marker = readRehearsalMarker(rehearsalMarkerPath(clone));
|
|
33325
33695
|
if (!marker)
|
|
@@ -33344,22 +33714,22 @@ function planRehearsalClone(params) {
|
|
|
33344
33714
|
};
|
|
33345
33715
|
}
|
|
33346
33716
|
function rehearsalMarkerPath(entry) {
|
|
33347
|
-
const ownMarker =
|
|
33348
|
-
if (
|
|
33349
|
-
const inside = readdirSync20(entry, { withFileTypes: true }).filter((child) => child.isDirectory()).map((child) =>
|
|
33350
|
-
return inside.find((path) =>
|
|
33717
|
+
const ownMarker = join88(entry, ".git", REHEARSAL_MARKER_FILE);
|
|
33718
|
+
if (existsSync83(ownMarker) || !isDirectory(entry)) return ownMarker;
|
|
33719
|
+
const inside = readdirSync20(entry, { withFileTypes: true }).filter((child) => child.isDirectory()).map((child) => join88(entry, child.name, ".git", REHEARSAL_MARKER_FILE));
|
|
33720
|
+
return inside.find((path) => existsSync83(path)) ?? ownMarker;
|
|
33351
33721
|
}
|
|
33352
33722
|
function isDirectory(path) {
|
|
33353
33723
|
try {
|
|
33354
|
-
return
|
|
33724
|
+
return statSync13(path).isDirectory();
|
|
33355
33725
|
} catch {
|
|
33356
33726
|
return false;
|
|
33357
33727
|
}
|
|
33358
33728
|
}
|
|
33359
33729
|
function readRehearsalMarker(path) {
|
|
33360
|
-
if (!
|
|
33730
|
+
if (!existsSync83(path)) return void 0;
|
|
33361
33731
|
try {
|
|
33362
|
-
const marker = JSON.parse(
|
|
33732
|
+
const marker = JSON.parse(readFileSync61(path, "utf8"));
|
|
33363
33733
|
return typeof marker.pid === "number" ? { pid: marker.pid } : void 0;
|
|
33364
33734
|
} catch {
|
|
33365
33735
|
return void 0;
|
|
@@ -33378,7 +33748,7 @@ function whyKeepWorktree(params) {
|
|
|
33378
33748
|
baseBranch: params.baseBranch
|
|
33379
33749
|
});
|
|
33380
33750
|
if (unmerged > 0) return `${unmerged} commit(s) not in ${params.baseBranch}`;
|
|
33381
|
-
if (params.pending ||
|
|
33751
|
+
if (params.pending || existsSync83(handoverLockPath(params.worktree)))
|
|
33382
33752
|
return "a hand-over is pending in it";
|
|
33383
33753
|
if (readGit({
|
|
33384
33754
|
root: params.worktree,
|
|
@@ -33451,11 +33821,11 @@ function listWorktrees(repository) {
|
|
|
33451
33821
|
}
|
|
33452
33822
|
function spellUnder(params) {
|
|
33453
33823
|
const realFolder = realpathSync11(params.folder);
|
|
33454
|
-
return params.path.startsWith(`${realFolder}/`) ?
|
|
33824
|
+
return params.path.startsWith(`${realFolder}/`) ? join88(params.folder, params.path.slice(realFolder.length + 1)) : params.path;
|
|
33455
33825
|
}
|
|
33456
33826
|
function isSameRepository(params) {
|
|
33457
|
-
if (!
|
|
33458
|
-
const common =
|
|
33827
|
+
if (!existsSync83(params.worktree)) return false;
|
|
33828
|
+
const common = spawnSync21("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], {
|
|
33459
33829
|
cwd: params.worktree,
|
|
33460
33830
|
encoding: "utf8"
|
|
33461
33831
|
});
|
|
@@ -33467,10 +33837,10 @@ function isSameRepository(params) {
|
|
|
33467
33837
|
return common.stdout.trim() === mainCommon;
|
|
33468
33838
|
}
|
|
33469
33839
|
function handoverStateOf(handover) {
|
|
33470
|
-
return
|
|
33840
|
+
return existsSync83(handover.lotsFile.repository) ? handoverState(handover) : "repository missing";
|
|
33471
33841
|
}
|
|
33472
33842
|
function refExists(params) {
|
|
33473
|
-
return
|
|
33843
|
+
return spawnSync21("git", ["rev-parse", "--verify", "--quiet", params.ref], { cwd: params.root }).status === 0;
|
|
33474
33844
|
}
|
|
33475
33845
|
|
|
33476
33846
|
// src/commands/worktree.ts
|
|
@@ -33522,7 +33892,7 @@ async function runWorktreePrune(params) {
|
|
|
33522
33892
|
const plan = planPrune({
|
|
33523
33893
|
workspace,
|
|
33524
33894
|
handoverFolders: findHandoverFolders({
|
|
33525
|
-
folder:
|
|
33895
|
+
folder: join89(workspace, COMMIT_PLAN_FOLDER),
|
|
33526
33896
|
depth: LIST_DEPTH
|
|
33527
33897
|
}),
|
|
33528
33898
|
scratchRoot: params.scratchRoot,
|
|
@@ -33548,7 +33918,7 @@ worktree prune --yes asks for a confirmation on a terminal: there is none here,
|
|
|
33548
33918
|
return { exitCode: 0, output: `${report}
|
|
33549
33919
|
Nothing removed.` };
|
|
33550
33920
|
const outcomes = removals.map(function remove(item) {
|
|
33551
|
-
const result =
|
|
33921
|
+
const result = spawnSync22("sh", ["-c", item.command ?? ""], { encoding: "utf8" });
|
|
33552
33922
|
return result.status === 0 ? `\u2713 ${item.command}` : `\u2717 ${item.command}: ${(result.stderr || result.stdout).trim()}`;
|
|
33553
33923
|
});
|
|
33554
33924
|
return {
|
|
@@ -33593,7 +33963,7 @@ function worktreeCard(added) {
|
|
|
33593
33963
|
{ label: "hooks", lines: [added.hooks ? `${added.hooks} copied` : "none to copy"] },
|
|
33594
33964
|
...linksRows({
|
|
33595
33965
|
links: added.siblingLinks,
|
|
33596
|
-
workspace:
|
|
33966
|
+
workspace: dirname39(added.repository),
|
|
33597
33967
|
worktree: added.worktree
|
|
33598
33968
|
}),
|
|
33599
33969
|
{
|
|
@@ -33720,21 +34090,28 @@ Examples:
|
|
|
33720
34090
|
dialecte audit # write benchmarks/types/readability-audit.md
|
|
33721
34091
|
|
|
33722
34092
|
Skills:
|
|
33723
|
-
dialecte skills sync [--agent claude,copilot,agents] [--copy] [--from <workspace>] [--
|
|
33724
|
-
|
|
33725
|
-
#
|
|
33726
|
-
#
|
|
33727
|
-
#
|
|
34093
|
+
dialecte skills sync [--agent claude,copilot,agents] [--copy] [--from <workspace>] [--contributing | --no-contributing]
|
|
34094
|
+
[--vendor <id>] [--no-session-check]
|
|
34095
|
+
# install the consumer skills of your dependencies (or of local checkouts) for your
|
|
34096
|
+
# agents; --contributing adds the contributor skills (metadata.audience: contributor,
|
|
34097
|
+
# to change a dialecte package), remembered until --no-contributing; remembers the
|
|
34098
|
+
# model vendor (detected, asked on a terminal, or --vendor; none: models unset);
|
|
34099
|
+
# with the contributor skills, writes a doctor --brief session-start check in AGENTS.md
|
|
34100
|
+
# for every agent, and for Claude Code the station agents (.claude/agents/dialecte-*.md,
|
|
34101
|
+
# adapters of the dialecte-lot skill's stations) and a SessionStart hook
|
|
34102
|
+
# (--no-session-check leaves the check out)
|
|
33728
34103
|
dialecte skills generate # rewrite the generated blocks (verb map, method index, hook files) from the source
|
|
33729
34104
|
dialecte skills check [--workspace <dir>]
|
|
33730
|
-
# fail on a cited API / path / npm script that does not exist, or a stale block
|
|
34105
|
+
# fail on a cited API / path / npm script that does not exist, or a stale block;
|
|
34106
|
+
# a dialecte-lot skill's references/stations.md must match the cli's stations
|
|
33731
34107
|
|
|
33732
34108
|
Lookups (the same with or without the repositories; --json on each):
|
|
33733
34109
|
dialecte api find "<need>" [--package <name>] [--limit 5]
|
|
33734
34110
|
# methods whose intents, summary or name match the need, best first
|
|
33735
34111
|
dialecte api show <path> # signature, summary, intents, routes, declaration, example (info.of, tx.addChild)
|
|
33736
|
-
dialecte members <expression>
|
|
33737
|
-
# one line per member of doc.query, doc.query.reference, tx.lifecycle.extract
|
|
34112
|
+
dialecte members <expression> [--package <name>] [--version <v>]
|
|
34113
|
+
# one line per member of doc.query, doc.query.reference, tx.lifecycle.extract...;
|
|
34114
|
+
# in an app, of the installed dialecte (--package / --version when several)
|
|
33738
34115
|
dialecte schema <Tag> [--package <name>]
|
|
33739
34116
|
# parents, children with how often, attributes; an unknown tag answers the closest
|
|
33740
34117
|
dialecte models [--vendor <anthropic|openai|google>] [--json]
|