@dialecte/cli 0.2.1 → 0.2.2
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 +1035 -699
- 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
|
}
|
|
@@ -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`;
|
|
@@ -7455,7 +7567,7 @@ function lastIndexOf(params) {
|
|
|
7455
7567
|
}
|
|
7456
7568
|
|
|
7457
7569
|
// src/lib/tdd/module-resolver.ts
|
|
7458
|
-
import { existsSync as existsSync28, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as
|
|
7570
|
+
import { existsSync as existsSync28, readdirSync as readdirSync8, readFileSync as readFileSync22, statSync as statSync6 } from "fs";
|
|
7459
7571
|
import { dirname as dirname13, isAbsolute as isAbsolute4, join as join30, normalize, relative as relative5, resolve as resolve12 } from "path";
|
|
7460
7572
|
import ts6 from "typescript";
|
|
7461
7573
|
function createModuleResolver(params) {
|
|
@@ -7572,14 +7684,14 @@ function localOrUnresolved(params) {
|
|
|
7572
7684
|
...MODULE_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
7573
7685
|
...MODULE_EXTENSIONS.map((extension) => join30(base, `index${extension}`))
|
|
7574
7686
|
];
|
|
7575
|
-
const found = candidates.find(
|
|
7687
|
+
const found = candidates.find(isFile3);
|
|
7576
7688
|
if (!found) return { kind: "unresolved" };
|
|
7577
7689
|
const file = relative5(params.root, found);
|
|
7578
7690
|
return file.startsWith("..") || file.startsWith("node_modules/") ? { kind: "package" } : { kind: "local", file };
|
|
7579
7691
|
}
|
|
7580
|
-
function
|
|
7692
|
+
function isFile3(path) {
|
|
7581
7693
|
try {
|
|
7582
|
-
return
|
|
7694
|
+
return statSync6(path).isFile();
|
|
7583
7695
|
} catch {
|
|
7584
7696
|
return false;
|
|
7585
7697
|
}
|
|
@@ -7793,8 +7905,8 @@ function findDeletedCases(params) {
|
|
|
7793
7905
|
findings.push({ verb: "deleted", file, detail: "a new test file deleted after its receipts" });
|
|
7794
7906
|
return findings;
|
|
7795
7907
|
}
|
|
7796
|
-
function findingLine(
|
|
7797
|
-
return `${
|
|
7908
|
+
function findingLine(finding2) {
|
|
7909
|
+
return `${finding2.verb} ${finding2.file} ${finding2.detail}`;
|
|
7798
7910
|
}
|
|
7799
7911
|
|
|
7800
7912
|
// src/lib/tdd/check-tdd-receipts.ts
|
|
@@ -7868,7 +7980,7 @@ async function checkTddReceipts(params) {
|
|
|
7868
7980
|
),
|
|
7869
7981
|
...gone.filter(
|
|
7870
7982
|
(entry) => !state.findings.some(
|
|
7871
|
-
(
|
|
7983
|
+
(finding2) => finding2.verb === "gone" && entryNamesFile({ entry: entry.file, file: finding2.file })
|
|
7872
7984
|
)
|
|
7873
7985
|
).map(
|
|
7874
7986
|
(entry) => `unused gone entry ${entry.file} no test call of the base gone without a title in a file it names (${entry.reason})`
|
|
@@ -8204,9 +8316,9 @@ function renderRerun(rerun) {
|
|
|
8204
8316
|
}
|
|
8205
8317
|
|
|
8206
8318
|
// src/commands/handover.ts
|
|
8207
|
-
import { existsSync as
|
|
8319
|
+
import { existsSync as existsSync51, realpathSync as realpathSync8 } from "fs";
|
|
8208
8320
|
import { tmpdir as tmpdir6 } from "os";
|
|
8209
|
-
import { dirname as dirname24, join as
|
|
8321
|
+
import { dirname as dirname24, join as join58, resolve as resolve18 } from "path";
|
|
8210
8322
|
|
|
8211
8323
|
// src/lib/card/card.constants.ts
|
|
8212
8324
|
var EMPHASIS_CODES = { passed: 32, warning: 33, failed: 31, strong: 1 };
|
|
@@ -8399,10 +8511,10 @@ function resolveCardColumns(params) {
|
|
|
8399
8511
|
}
|
|
8400
8512
|
|
|
8401
8513
|
// src/lib/handover/handover-card.ts
|
|
8402
|
-
import { spawnSync as
|
|
8403
|
-
import { closeSync as closeSync2, mkdtempSync as mkdtempSync4, openSync as openSync2, readFileSync as
|
|
8514
|
+
import { spawnSync as spawnSync10 } from "child_process";
|
|
8515
|
+
import { closeSync as closeSync2, mkdtempSync as mkdtempSync4, openSync as openSync2, readFileSync as readFileSync32, rmSync as rmSync12 } from "fs";
|
|
8404
8516
|
import { tmpdir as tmpdir4 } from "os";
|
|
8405
|
-
import { basename as basename5, join as
|
|
8517
|
+
import { basename as basename5, join as join45 } from "path";
|
|
8406
8518
|
|
|
8407
8519
|
// src/lib/counted.ts
|
|
8408
8520
|
function counted(params) {
|
|
@@ -8592,7 +8704,7 @@ import {
|
|
|
8592
8704
|
readFileSync as readFileSync27,
|
|
8593
8705
|
renameSync as renameSync3,
|
|
8594
8706
|
rmSync as rmSync10,
|
|
8595
|
-
statSync as
|
|
8707
|
+
statSync as statSync7,
|
|
8596
8708
|
writeSync
|
|
8597
8709
|
} from "fs";
|
|
8598
8710
|
import { join as join37 } from "path";
|
|
@@ -9270,7 +9382,7 @@ function isStaleLock(params) {
|
|
|
9270
9382
|
if (holder !== void 0)
|
|
9271
9383
|
return !isOwnerProcessAlive({ pid: holder.pid, startedAt: holder.startedAt });
|
|
9272
9384
|
try {
|
|
9273
|
-
return Date.now() -
|
|
9385
|
+
return Date.now() - statSync7(lock).mtimeMs > LEDGER_LOCK_ORPHAN_MS;
|
|
9274
9386
|
} catch {
|
|
9275
9387
|
return false;
|
|
9276
9388
|
}
|
|
@@ -9741,8 +9853,34 @@ function snapshotRounds(folder) {
|
|
|
9741
9853
|
}
|
|
9742
9854
|
|
|
9743
9855
|
// src/lib/handover/lot-size.ts
|
|
9744
|
-
import {
|
|
9856
|
+
import { join as join42 } from "path";
|
|
9857
|
+
|
|
9858
|
+
// src/lib/handover/committed-bytes.ts
|
|
9859
|
+
import { spawnSync as spawnSync8 } from "child_process";
|
|
9860
|
+
import { lstatSync as lstatSync6, readFileSync as readFileSync30, readlinkSync as readlinkSync2 } from "fs";
|
|
9745
9861
|
import { join as join41 } from "path";
|
|
9862
|
+
function readCommittedBytes(path) {
|
|
9863
|
+
return lstatSync6(path).isSymbolicLink() ? Buffer.from(readlinkSync2(path)) : readFileSync30(path);
|
|
9864
|
+
}
|
|
9865
|
+
function gitBlobIds(params) {
|
|
9866
|
+
return params.files.map(function blobIdOf(file) {
|
|
9867
|
+
const path = join41(params.root, file);
|
|
9868
|
+
const linked = lstatSync6(path).isSymbolicLink();
|
|
9869
|
+
const result = spawnSync8(
|
|
9870
|
+
"git",
|
|
9871
|
+
linked ? ["hash-object", "--stdin"] : ["hash-object", "--", file],
|
|
9872
|
+
{
|
|
9873
|
+
cwd: params.root,
|
|
9874
|
+
encoding: "utf8",
|
|
9875
|
+
input: linked ? readlinkSync2(path) : void 0
|
|
9876
|
+
}
|
|
9877
|
+
);
|
|
9878
|
+
if (result.status !== 0) throw new Error(`git hash-object ${file}: ${result.stderr.trim()}`);
|
|
9879
|
+
return result.stdout.trim();
|
|
9880
|
+
});
|
|
9881
|
+
}
|
|
9882
|
+
|
|
9883
|
+
// src/lib/handover/lot-size.ts
|
|
9746
9884
|
function workingTreeSizeOf(params) {
|
|
9747
9885
|
const tracked = new Set(
|
|
9748
9886
|
readGit({
|
|
@@ -9758,7 +9896,7 @@ function workingTreeSizeOf(params) {
|
|
|
9758
9896
|
})
|
|
9759
9897
|
) : { insertions: 0, deletions: 0 };
|
|
9760
9898
|
for (const file of params.files.filter((path) => !tracked.has(path)))
|
|
9761
|
-
size.insertions += lineCountOf(
|
|
9899
|
+
size.insertions += lineCountOf(readCommittedBytes(join42(params.root, file)).toString("utf8"));
|
|
9762
9900
|
return size;
|
|
9763
9901
|
}
|
|
9764
9902
|
function commitSizeOf(params) {
|
|
@@ -9798,14 +9936,14 @@ function lineCountOf(text) {
|
|
|
9798
9936
|
}
|
|
9799
9937
|
|
|
9800
9938
|
// src/lib/handover/merge-lot.ts
|
|
9801
|
-
import { spawnSync as
|
|
9802
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync39, mkdirSync as mkdirSync11, readFileSync as
|
|
9803
|
-
import { dirname as dirname17, isAbsolute as isAbsolute5, join as
|
|
9939
|
+
import { spawnSync as spawnSync9 } from "child_process";
|
|
9940
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync39, mkdirSync as mkdirSync11, readFileSync as readFileSync31, rmSync as rmSync11, writeFileSync as writeFileSync17 } from "fs";
|
|
9941
|
+
import { dirname as dirname17, isAbsolute as isAbsolute5, join as join44 } from "path";
|
|
9804
9942
|
|
|
9805
9943
|
// src/lib/handover/write-handover.ts
|
|
9806
9944
|
import { createHash as createHash5 } from "crypto";
|
|
9807
|
-
import { chmodSync, existsSync as existsSync38, mkdirSync as mkdirSync10,
|
|
9808
|
-
import { join as
|
|
9945
|
+
import { chmodSync, existsSync as existsSync38, mkdirSync as mkdirSync10, writeFileSync as writeFileSync16 } from "fs";
|
|
9946
|
+
import { join as join43, resolve as resolve13 } from "path";
|
|
9809
9947
|
|
|
9810
9948
|
// src/lib/handover/commit-script.ts
|
|
9811
9949
|
function renderCommitScript(params) {
|
|
@@ -9835,43 +9973,43 @@ function renderCommitScript(params) {
|
|
|
9835
9973
|
function writeHandover(params) {
|
|
9836
9974
|
const { plan, out } = params;
|
|
9837
9975
|
mkdirSync10(out, { recursive: true });
|
|
9838
|
-
const lotsCopy =
|
|
9976
|
+
const lotsCopy = join43(out, HANDOVER_FILES.lots);
|
|
9839
9977
|
if (resolve13(params.lotsPath) !== resolve13(lotsCopy) || !existsSync38(lotsCopy))
|
|
9840
9978
|
writeFileSync16(lotsCopy, `${JSON.stringify(params.lotsFile, null, " ")}
|
|
9841
9979
|
`);
|
|
9842
|
-
writeFileSync16(
|
|
9980
|
+
writeFileSync16(join43(out, HANDOVER_FILES.lotsHash), `${hashFile2(lotsCopy)}
|
|
9843
9981
|
`);
|
|
9844
9982
|
const existing = plan.lots.flatMap((lot) => lot.files).sort();
|
|
9845
9983
|
writeFileSync16(
|
|
9846
|
-
|
|
9984
|
+
join43(out, HANDOVER_FILES.files),
|
|
9847
9985
|
linesOf(plan.lots.flatMap((lot) => [...lot.files, ...lot.deletedFiles]).sort())
|
|
9848
9986
|
);
|
|
9849
9987
|
writeFileSync16(
|
|
9850
|
-
|
|
9851
|
-
linesOf(existing.map((file) => `${hashFile2(
|
|
9988
|
+
join43(out, HANDOVER_FILES.hashes),
|
|
9989
|
+
linesOf(existing.map((file) => `${hashFile2(join43(plan.repository, file))} ${file}`))
|
|
9852
9990
|
);
|
|
9853
9991
|
writeFileSync16(
|
|
9854
|
-
|
|
9992
|
+
join43(out, HANDOVER_FILES.deleted),
|
|
9855
9993
|
linesOf(plan.lots.flatMap((lot) => lot.deletedFiles).sort())
|
|
9856
9994
|
);
|
|
9857
9995
|
const merges = Object.fromEntries(
|
|
9858
9996
|
plan.lots.flatMap((lot, index) => lot.merge ? [[String(index), lot.merge]] : [])
|
|
9859
9997
|
);
|
|
9860
9998
|
if (Object.keys(merges).length) {
|
|
9861
|
-
const mergesPath =
|
|
9999
|
+
const mergesPath = join43(out, HANDOVER_FILES.merges);
|
|
9862
10000
|
writeFileSync16(mergesPath, `${JSON.stringify(merges, null, " ")}
|
|
9863
10001
|
`);
|
|
9864
|
-
writeFileSync16(
|
|
10002
|
+
writeFileSync16(join43(out, HANDOVER_FILES.mergesHash), `${hashFile2(mergesPath)}
|
|
9865
10003
|
`);
|
|
9866
10004
|
}
|
|
9867
|
-
const scriptPath =
|
|
10005
|
+
const scriptPath = join43(out, COMMIT_SCRIPT_FILE);
|
|
9868
10006
|
writeFileSync16(scriptPath, renderCommitScript({ plan, folder: out, cliPath: params.cliPath }));
|
|
9869
10007
|
chmodSync(scriptPath, 493);
|
|
9870
10008
|
writeFileSync16(handoverLockPath(plan.repository), `${scriptPath}
|
|
9871
10009
|
`);
|
|
9872
10010
|
}
|
|
9873
10011
|
function hashFile2(path) {
|
|
9874
|
-
return createHash5("sha256").update(
|
|
10012
|
+
return createHash5("sha256").update(readCommittedBytes(path)).digest("hex");
|
|
9875
10013
|
}
|
|
9876
10014
|
function linesOf(lines) {
|
|
9877
10015
|
return lines.length ? `${lines.join("\n")}
|
|
@@ -9896,12 +10034,12 @@ function planMergeLot(params) {
|
|
|
9896
10034
|
);
|
|
9897
10035
|
const resolutions = Object.entries(lot.resolved).sort(([left], [right]) => left.localeCompare(right)).flatMap(function resolutionOf([path, relative12]) {
|
|
9898
10036
|
if (relative12 === null) return [{ path, removed: true }];
|
|
9899
|
-
const file = isAbsolute5(relative12) ? relative12 :
|
|
10037
|
+
const file = isAbsolute5(relative12) ? relative12 : join44(dirname17(params.lotsPath), relative12);
|
|
9900
10038
|
if (!existsSync39(file)) {
|
|
9901
10039
|
refusals.push(`merge lot ${number}: the resolution ${relative12} of ${path} does not exist`);
|
|
9902
10040
|
return [];
|
|
9903
10041
|
}
|
|
9904
|
-
if (CONFLICT_MARKER_PATTERN.test(
|
|
10042
|
+
if (CONFLICT_MARKER_PATTERN.test(readFileSync31(file, "utf8")))
|
|
9905
10043
|
refusals.push(
|
|
9906
10044
|
`merge lot ${number}: conflict markers in ${relative12}, the resolution of ${path}`
|
|
9907
10045
|
);
|
|
@@ -9943,7 +10081,7 @@ function planMergeLot(params) {
|
|
|
9943
10081
|
};
|
|
9944
10082
|
}
|
|
9945
10083
|
function trialMerge(params) {
|
|
9946
|
-
const trial =
|
|
10084
|
+
const trial = spawnSync9(
|
|
9947
10085
|
"git",
|
|
9948
10086
|
["merge-tree", "--write-tree", "-z", "--no-messages", params.base, params.tip],
|
|
9949
10087
|
{ cwd: params.root, encoding: "utf8" }
|
|
@@ -9968,7 +10106,7 @@ function runMergeLot(params) {
|
|
|
9968
10106
|
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
10107
|
};
|
|
9970
10108
|
writeMergeMarker({ root, tip: merge.tip });
|
|
9971
|
-
const merged =
|
|
10109
|
+
const merged = spawnSync9("git", ["merge", "--no-ff", "--no-commit", merge.tip], {
|
|
9972
10110
|
cwd: root,
|
|
9973
10111
|
encoding: "utf8"
|
|
9974
10112
|
});
|
|
@@ -9995,7 +10133,7 @@ function runMergeLot(params) {
|
|
|
9995
10133
|
return {
|
|
9996
10134
|
refusal: `the resolution of ${resolution.path} changed since the review: ${resolution.file}`
|
|
9997
10135
|
};
|
|
9998
|
-
const target =
|
|
10136
|
+
const target = join44(root, resolution.path);
|
|
9999
10137
|
mkdirSync11(dirname17(target), { recursive: true });
|
|
10000
10138
|
copyFileSync2(resolution.file, target);
|
|
10001
10139
|
readGit({ root, args: ["add", "--", resolution.path] });
|
|
@@ -10018,7 +10156,7 @@ function undoMerge(params) {
|
|
|
10018
10156
|
removeMergeMarker(root);
|
|
10019
10157
|
return ` nothing changed; fix the cause, then ${resume}`;
|
|
10020
10158
|
}
|
|
10021
|
-
const aborted =
|
|
10159
|
+
const aborted = spawnSync9("git", ["merge", "--abort"], { cwd: root, encoding: "utf8" });
|
|
10022
10160
|
if (aborted.status !== 0)
|
|
10023
10161
|
return ` git merge --abort failed (${aborted.stderr.trim()}): look at the repository before running again`;
|
|
10024
10162
|
removeMergeMarker(root);
|
|
@@ -10028,7 +10166,7 @@ function readMergeMarker(root) {
|
|
|
10028
10166
|
const path = mergeMarkerPath(root);
|
|
10029
10167
|
if (!existsSync39(path)) return void 0;
|
|
10030
10168
|
try {
|
|
10031
|
-
return JSON.parse(
|
|
10169
|
+
return JSON.parse(readFileSync31(path, "utf8")).tip;
|
|
10032
10170
|
} catch {
|
|
10033
10171
|
return void 0;
|
|
10034
10172
|
}
|
|
@@ -10041,14 +10179,14 @@ function stagedFilesWithMarkers(root) {
|
|
|
10041
10179
|
root,
|
|
10042
10180
|
args: ["diff", "--cached", "--name-only", "-z", "--diff-filter=d"]
|
|
10043
10181
|
}).filter(function holdsMarkers(file) {
|
|
10044
|
-
const path =
|
|
10182
|
+
const path = join44(root, file);
|
|
10045
10183
|
if (!existsSync39(path)) return false;
|
|
10046
|
-
const text =
|
|
10184
|
+
const text = readCommittedBytes(path);
|
|
10047
10185
|
return !text.subarray(0, BINARY_PROBE_LENGTH).includes(0) && CONFLICT_MARKER_PATTERN.test(text.toString("utf8"));
|
|
10048
10186
|
});
|
|
10049
10187
|
}
|
|
10050
10188
|
function commitOf(params) {
|
|
10051
|
-
const result =
|
|
10189
|
+
const result = spawnSync9(
|
|
10052
10190
|
"git",
|
|
10053
10191
|
["rev-parse", "--verify", "--quiet", `${params.revision}^{commit}`],
|
|
10054
10192
|
{ cwd: params.root, encoding: "utf8" }
|
|
@@ -10191,17 +10329,17 @@ function mergeLine(merge) {
|
|
|
10191
10329
|
}
|
|
10192
10330
|
function runsHandovers(params) {
|
|
10193
10331
|
const [command, ...args] = HANDOVER_PROBE_COMMAND;
|
|
10194
|
-
const folder = mkdtempSync4(
|
|
10195
|
-
const answerPath =
|
|
10332
|
+
const folder = mkdtempSync4(join45(tmpdir4(), HANDOVER_PROBE_FOLDER_PREFIX));
|
|
10333
|
+
const answerPath = join45(folder, "answer.txt");
|
|
10196
10334
|
const answer = openSync2(answerPath, "w");
|
|
10197
10335
|
try {
|
|
10198
|
-
const probe =
|
|
10336
|
+
const probe = spawnSync10(command, args, {
|
|
10199
10337
|
cwd: params.root,
|
|
10200
10338
|
stdio: ["ignore", answer, "ignore"],
|
|
10201
10339
|
timeout: params.timeout,
|
|
10202
10340
|
killSignal: "SIGKILL"
|
|
10203
10341
|
});
|
|
10204
|
-
return probe.status === 0 &&
|
|
10342
|
+
return probe.status === 0 && readFileSync32(answerPath, "utf8").includes(HANDOVER_PROBE_ANSWER);
|
|
10205
10343
|
} finally {
|
|
10206
10344
|
closeSync2(answer);
|
|
10207
10345
|
rmSync12(folder, { recursive: true, force: true });
|
|
@@ -10536,9 +10674,9 @@ function optionalSection(params) {
|
|
|
10536
10674
|
}
|
|
10537
10675
|
|
|
10538
10676
|
// src/lib/handover/list-handovers.ts
|
|
10539
|
-
import { spawnSync as
|
|
10540
|
-
import { existsSync as existsSync41, lstatSync as
|
|
10541
|
-
import { basename as basename6, join as
|
|
10677
|
+
import { spawnSync as spawnSync11 } from "child_process";
|
|
10678
|
+
import { existsSync as existsSync41, lstatSync as lstatSync7, readdirSync as readdirSync11, realpathSync as realpathSync6, statSync as statSync8 } from "fs";
|
|
10679
|
+
import { basename as basename6, join as join47 } from "path";
|
|
10542
10680
|
|
|
10543
10681
|
// src/lib/handover/find-committed-lots.ts
|
|
10544
10682
|
function findCommittedLots(params) {
|
|
@@ -10600,29 +10738,29 @@ function describeMismatch(params) {
|
|
|
10600
10738
|
root,
|
|
10601
10739
|
args: ["rev-parse", ...lot.files.map((file) => `${commit}:${file}`)]
|
|
10602
10740
|
}).split("\n").filter(Boolean);
|
|
10603
|
-
const workingBlobs =
|
|
10741
|
+
const workingBlobs = gitBlobIds({ root, files: lot.files });
|
|
10604
10742
|
return committedBlobs.join("\n") === workingBlobs.join("\n") ? void 0 : "other content than the reviewed files";
|
|
10605
10743
|
}
|
|
10606
10744
|
|
|
10607
10745
|
// src/lib/handover/read-handover-folder.ts
|
|
10608
|
-
import { existsSync as existsSync40, readFileSync as
|
|
10609
|
-
import { join as
|
|
10746
|
+
import { existsSync as existsSync40, readFileSync as readFileSync33 } from "fs";
|
|
10747
|
+
import { join as join46, resolve as resolve14 } from "path";
|
|
10610
10748
|
function readHandoverFolder(folder) {
|
|
10611
10749
|
const absoluteFolder = resolve14(folder);
|
|
10612
|
-
const lotsFile = readLotsFile(
|
|
10750
|
+
const lotsFile = readLotsFile(join46(absoluteFolder, HANDOVER_FILES.lots));
|
|
10613
10751
|
if (typeof lotsFile === "string") return lotsFile;
|
|
10614
10752
|
const missing = [
|
|
10615
10753
|
HANDOVER_FILES.files,
|
|
10616
10754
|
HANDOVER_FILES.hashes,
|
|
10617
10755
|
HANDOVER_FILES.deleted,
|
|
10618
10756
|
HANDOVER_FILES.lotsHash
|
|
10619
|
-
].filter((name) => !existsSync40(
|
|
10757
|
+
].filter((name) => !existsSync40(join46(absoluteFolder, name)));
|
|
10620
10758
|
if (missing.length)
|
|
10621
10759
|
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 = existsSync40(mergesPath) ? JSON.parse(
|
|
10760
|
+
const files = readLines(join46(absoluteFolder, HANDOVER_FILES.files));
|
|
10761
|
+
const deleted = new Set(readLines(join46(absoluteFolder, HANDOVER_FILES.deleted)));
|
|
10762
|
+
const mergesPath = join46(absoluteFolder, HANDOVER_FILES.merges);
|
|
10763
|
+
const merges = existsSync40(mergesPath) ? JSON.parse(readFileSync33(mergesPath, "utf8")) : {};
|
|
10626
10764
|
if (lotsFile.lots.some((lot, index) => isMergeLotPlan(lot) && !merges[index]))
|
|
10627
10765
|
return `${absoluteFolder} misses the merge records (${HANDOVER_FILES.merges}): write it again with \`dialecte handover --rehash <lots.json>\``;
|
|
10628
10766
|
if (Object.values(merges).some((merge) => typeof merge.onTree !== "string"))
|
|
@@ -10642,22 +10780,22 @@ function readHandoverFolder(folder) {
|
|
|
10642
10780
|
deletedFiles: covered.filter((file) => deleted.has(file))
|
|
10643
10781
|
};
|
|
10644
10782
|
}),
|
|
10645
|
-
snapshotLines: readLines(
|
|
10646
|
-
lotsHash:
|
|
10647
|
-
...existsSync40(
|
|
10648
|
-
mergesHash:
|
|
10783
|
+
snapshotLines: readLines(join46(absoluteFolder, HANDOVER_FILES.hashes)),
|
|
10784
|
+
lotsHash: readFileSync33(join46(absoluteFolder, HANDOVER_FILES.lotsHash), "utf8").trim(),
|
|
10785
|
+
...existsSync40(join46(absoluteFolder, HANDOVER_FILES.mergesHash)) && {
|
|
10786
|
+
mergesHash: readFileSync33(join46(absoluteFolder, HANDOVER_FILES.mergesHash), "utf8").trim()
|
|
10649
10787
|
}
|
|
10650
10788
|
};
|
|
10651
10789
|
}
|
|
10652
10790
|
function readLines(path) {
|
|
10653
|
-
return
|
|
10791
|
+
return readFileSync33(path, "utf8").split("\n").filter(Boolean);
|
|
10654
10792
|
}
|
|
10655
10793
|
|
|
10656
10794
|
// src/lib/handover/list-handovers.ts
|
|
10657
10795
|
function listHandovers(params) {
|
|
10658
10796
|
const folders = findHandoverFolders({ folder: params.root, depth: LIST_DEPTH });
|
|
10659
10797
|
return onePerRealPath(folders).flatMap(function listing(folder) {
|
|
10660
|
-
if (!existsSync41(
|
|
10798
|
+
if (!existsSync41(join47(folder, HANDOVER_FILES.lots)))
|
|
10661
10799
|
return [
|
|
10662
10800
|
{
|
|
10663
10801
|
folder,
|
|
@@ -10680,7 +10818,7 @@ function listHandovers(params) {
|
|
|
10680
10818
|
worktree: lotsFile.repository,
|
|
10681
10819
|
branch: lotsFile.branch,
|
|
10682
10820
|
lots: lotsFile.lots.length,
|
|
10683
|
-
age: params.now -
|
|
10821
|
+
age: params.now - statSync8(join47(folder, COMMIT_SCRIPT_FILE)).mtimeMs,
|
|
10684
10822
|
state: repositoryExists ? handoverState(handover) : "repository missing"
|
|
10685
10823
|
}
|
|
10686
10824
|
];
|
|
@@ -10691,7 +10829,7 @@ function onePerRealPath(folders) {
|
|
|
10691
10829
|
for (const folder of folders) {
|
|
10692
10830
|
const real = realpathSync6(folder);
|
|
10693
10831
|
const known = byRealPath.get(real);
|
|
10694
|
-
if (known === void 0 ||
|
|
10832
|
+
if (known === void 0 || lstatSync7(known).isSymbolicLink() && !lstatSync7(folder).isSymbolicLink())
|
|
10695
10833
|
byRealPath.set(real, folder);
|
|
10696
10834
|
}
|
|
10697
10835
|
const kept = new Set(byRealPath.values());
|
|
@@ -10710,7 +10848,7 @@ function handoverState(handover) {
|
|
|
10710
10848
|
return "pending";
|
|
10711
10849
|
}
|
|
10712
10850
|
function revisionOf(params) {
|
|
10713
|
-
const result =
|
|
10851
|
+
const result = spawnSync11("git", ["rev-parse", "--verify", "--quiet", params.revision], {
|
|
10714
10852
|
cwd: params.root,
|
|
10715
10853
|
encoding: "utf8"
|
|
10716
10854
|
});
|
|
@@ -10720,18 +10858,18 @@ function listLegacyScripts(folder) {
|
|
|
10720
10858
|
return readdirSync11(folder).filter((name) => LEGACY_SCRIPT_PATTERN.test(name));
|
|
10721
10859
|
}
|
|
10722
10860
|
function newestScriptTime(folder) {
|
|
10723
|
-
return Math.max(...listLegacyScripts(folder).map((name) =>
|
|
10861
|
+
return Math.max(...listLegacyScripts(folder).map((name) => statSync8(join47(folder, name)).mtimeMs));
|
|
10724
10862
|
}
|
|
10725
10863
|
function findHandoverFolders(params) {
|
|
10726
10864
|
const { folder } = params;
|
|
10727
10865
|
if (!existsSync41(folder)) return [];
|
|
10728
|
-
const hasLots = existsSync41(
|
|
10729
|
-
const found = hasLots && existsSync41(
|
|
10866
|
+
const hasLots = existsSync41(join47(folder, HANDOVER_FILES.lots));
|
|
10867
|
+
const found = hasLots && existsSync41(join47(folder, COMMIT_SCRIPT_FILE)) || !hasLots && listLegacyScripts(folder).length > 0 ? [folder] : [];
|
|
10730
10868
|
if (params.depth === 0) return found;
|
|
10731
10869
|
for (const entry of readdirSync11(folder, { withFileTypes: true }))
|
|
10732
10870
|
if (isFolder({ folder, entry }) && entry.name !== "node_modules" && !entry.name.startsWith("."))
|
|
10733
10871
|
found.push(
|
|
10734
|
-
...findHandoverFolders({ folder:
|
|
10872
|
+
...findHandoverFolders({ folder: join47(folder, entry.name), depth: params.depth - 1 })
|
|
10735
10873
|
);
|
|
10736
10874
|
return found.sort();
|
|
10737
10875
|
}
|
|
@@ -10739,30 +10877,29 @@ function isFolder(params) {
|
|
|
10739
10877
|
if (params.entry.isDirectory()) return true;
|
|
10740
10878
|
if (!params.entry.isSymbolicLink()) return false;
|
|
10741
10879
|
try {
|
|
10742
|
-
return
|
|
10880
|
+
return statSync8(join47(params.folder, params.entry.name)).isDirectory();
|
|
10743
10881
|
} catch {
|
|
10744
10882
|
return false;
|
|
10745
10883
|
}
|
|
10746
10884
|
}
|
|
10747
10885
|
|
|
10748
10886
|
// src/lib/handover/plan-handover.ts
|
|
10749
|
-
import {
|
|
10750
|
-
import { join as join48 } from "path";
|
|
10887
|
+
import { join as join49 } from "path";
|
|
10751
10888
|
|
|
10752
10889
|
// src/lib/handover/find-lot-references.ts
|
|
10753
|
-
import {
|
|
10754
|
-
import { join as join47 } from "path";
|
|
10890
|
+
import { join as join48 } from "path";
|
|
10755
10891
|
|
|
10756
10892
|
// src/lib/rules/committed-text.constants.ts
|
|
10757
10893
|
var GENERIC_REFERENCE_PATTERNS = [
|
|
10758
|
-
{ label: "plan tag", source: "\\blot [A-Z0-9]" },
|
|
10759
|
-
{ label: "acceptance criterion", source: "\\bAC[0-9]" },
|
|
10894
|
+
{ label: "plan tag", source: "\\blot [A-Z0-9]", allowable: true },
|
|
10895
|
+
{ label: "acceptance criterion", source: "\\bAC[0-9]", allowable: true },
|
|
10760
10896
|
// digits up to a word boundary: `#1234ab`, a colour, is not a ticket; nor a hash glued to a word
|
|
10761
10897
|
// (`abc#123`) or ending a character reference (` `)
|
|
10762
10898
|
{
|
|
10763
10899
|
label: "ticket number",
|
|
10764
10900
|
source: "(^|[^&A-Za-z0-9_])#[0-9]{3,}\\b",
|
|
10765
|
-
leadingBoundary: true
|
|
10901
|
+
leadingBoundary: true,
|
|
10902
|
+
allowable: true
|
|
10766
10903
|
},
|
|
10767
10904
|
{ label: "section citation", source: "\xA7 ?[0-9]" },
|
|
10768
10905
|
{ label: "table citation", source: "Tables? [0-9]" },
|
|
@@ -10795,8 +10932,19 @@ function findReferences(params) {
|
|
|
10795
10932
|
function readReferencePatterns(root) {
|
|
10796
10933
|
const packageJson = readPackageJson(root);
|
|
10797
10934
|
const declared = packageJson.dialecte?.referencePatterns ?? [];
|
|
10935
|
+
const allowed = packageJson.dialecte?.allowReferences ?? [];
|
|
10936
|
+
if (!Array.isArray(allowed) || allowed.some((label) => typeof label !== "string"))
|
|
10937
|
+
throw new Error('dialecte.allowReferences: a list of labels, such as ["ticket number"]');
|
|
10938
|
+
const allowable = GENERIC_REFERENCE_PATTERNS.filter((pattern) => pattern.allowable).map(
|
|
10939
|
+
(pattern) => pattern.label
|
|
10940
|
+
);
|
|
10941
|
+
const refused3 = allowed.filter((label) => !allowable.includes(label));
|
|
10942
|
+
if (refused3.length)
|
|
10943
|
+
throw new Error(
|
|
10944
|
+
`dialecte.allowReferences: ${refused3.join(", ")} can never be allowed (only a tag can); allowable: ${allowable.join(", ")}`
|
|
10945
|
+
);
|
|
10798
10946
|
return [
|
|
10799
|
-
...GENERIC_REFERENCE_PATTERNS,
|
|
10947
|
+
...GENERIC_REFERENCE_PATTERNS.filter((pattern) => !allowed.includes(pattern.label)),
|
|
10800
10948
|
...declared.map((source) => ({
|
|
10801
10949
|
label: `reference declared by ${packageJson.name ?? "the package"}`,
|
|
10802
10950
|
source
|
|
@@ -10818,7 +10966,7 @@ function findLotReferences(params) {
|
|
|
10818
10966
|
`lot ${index + 1} message, line ${reference.line}: ${reference.label} \`${reference.text}\``
|
|
10819
10967
|
);
|
|
10820
10968
|
for (const file of lot.files) {
|
|
10821
|
-
const content =
|
|
10969
|
+
const content = readCommittedBytes(join48(root, file));
|
|
10822
10970
|
if (isBinary(content) || !isReferenceChecked(file)) continue;
|
|
10823
10971
|
for (const reference of findReferences({
|
|
10824
10972
|
text: content.toString("utf8"),
|
|
@@ -10887,8 +11035,8 @@ function planHandover(params) {
|
|
|
10887
11035
|
pendingFiles.push(...files);
|
|
10888
11036
|
return {
|
|
10889
11037
|
message: lot.message,
|
|
10890
|
-
files: files.filter((file) =>
|
|
10891
|
-
deletedFiles: files.filter((file) => !
|
|
11038
|
+
files: files.filter((file) => isPresent(join49(root, file))),
|
|
11039
|
+
deletedFiles: files.filter((file) => !isPresent(join49(root, file)))
|
|
10892
11040
|
};
|
|
10893
11041
|
});
|
|
10894
11042
|
for (const file of changedFiles)
|
|
@@ -10904,24 +11052,27 @@ function readGitVersion() {
|
|
|
10904
11052
|
}
|
|
10905
11053
|
|
|
10906
11054
|
// src/lib/handover/rehearse-handover.ts
|
|
10907
|
-
import { spawnSync as
|
|
11055
|
+
import { spawnSync as spawnSync16 } from "child_process";
|
|
10908
11056
|
import {
|
|
10909
11057
|
cpSync as cpSync2,
|
|
10910
|
-
existsSync as
|
|
11058
|
+
existsSync as existsSync49,
|
|
11059
|
+
lstatSync as lstatSync10,
|
|
10911
11060
|
mkdirSync as mkdirSync14,
|
|
10912
11061
|
mkdtempSync as mkdtempSync6,
|
|
10913
11062
|
readdirSync as readdirSync14,
|
|
11063
|
+
readlinkSync as readlinkSync5,
|
|
10914
11064
|
rmdirSync,
|
|
10915
11065
|
rmSync as rmSync18,
|
|
11066
|
+
symlinkSync as symlinkSync5,
|
|
10916
11067
|
writeFileSync as writeFileSync21
|
|
10917
11068
|
} from "fs";
|
|
10918
11069
|
import { constants as constants2 } from "os";
|
|
10919
|
-
import { basename as basename7, dirname as dirname22, isAbsolute as isAbsolute9, join as
|
|
11070
|
+
import { basename as basename7, dirname as dirname22, isAbsolute as isAbsolute9, join as join56 } from "path";
|
|
10920
11071
|
|
|
10921
11072
|
// src/lib/worktree/copy-node-modules.ts
|
|
10922
|
-
import { spawnSync as
|
|
10923
|
-
import { existsSync as
|
|
10924
|
-
import { dirname as dirname18, isAbsolute as isAbsolute6, join as
|
|
11073
|
+
import { spawnSync as spawnSync12 } from "child_process";
|
|
11074
|
+
import { existsSync as existsSync42, lstatSync as lstatSync8, readdirSync as readdirSync12, readlinkSync as readlinkSync3, rmSync as rmSync13, symlinkSync as symlinkSync2 } from "fs";
|
|
11075
|
+
import { dirname as dirname18, isAbsolute as isAbsolute6, join as join50, relative as relative6, resolve as resolve15 } from "path";
|
|
10925
11076
|
function copyNodeModules(params) {
|
|
10926
11077
|
const { from, to } = params;
|
|
10927
11078
|
const runCopy = params.runCopy ?? runCp;
|
|
@@ -10944,19 +11095,19 @@ function copyNodeModules(params) {
|
|
|
10944
11095
|
throw new Error(`cannot copy ${from} to ${to}`);
|
|
10945
11096
|
}
|
|
10946
11097
|
function runCp(args) {
|
|
10947
|
-
const result =
|
|
11098
|
+
const result = spawnSync12("cp", args, { encoding: "utf8" });
|
|
10948
11099
|
return { status: result.status, signal: result.signal };
|
|
10949
11100
|
}
|
|
10950
11101
|
function relinkEscapingLinks(params) {
|
|
10951
11102
|
const relinked = [];
|
|
10952
11103
|
for (const entry of packageEntries(params.from)) {
|
|
10953
|
-
const source =
|
|
10954
|
-
if (!
|
|
10955
|
-
const target =
|
|
11104
|
+
const source = join50(params.from, entry);
|
|
11105
|
+
if (!lstatSync8(source).isSymbolicLink()) continue;
|
|
11106
|
+
const target = readlinkSync3(source);
|
|
10956
11107
|
if (isAbsolute6(target)) continue;
|
|
10957
11108
|
const resolved = resolve15(dirname18(source), target);
|
|
10958
11109
|
if (!relative6(params.from, resolved).startsWith("..")) continue;
|
|
10959
|
-
const copy =
|
|
11110
|
+
const copy = join50(params.to, entry);
|
|
10960
11111
|
rmSync13(copy, { force: true });
|
|
10961
11112
|
symlinkSync2(resolved, copy);
|
|
10962
11113
|
relinked.push(entry);
|
|
@@ -10964,22 +11115,22 @@ function relinkEscapingLinks(params) {
|
|
|
10964
11115
|
return relinked;
|
|
10965
11116
|
}
|
|
10966
11117
|
function packageEntries(folder) {
|
|
10967
|
-
if (!
|
|
11118
|
+
if (!existsSync42(folder)) return [];
|
|
10968
11119
|
return readdirSync12(folder).flatMap(function entriesOf(name) {
|
|
10969
11120
|
if (!name.startsWith("@")) return [name];
|
|
10970
|
-
const scope =
|
|
10971
|
-
if (
|
|
11121
|
+
const scope = join50(folder, name);
|
|
11122
|
+
if (lstatSync8(scope).isSymbolicLink()) return [name];
|
|
10972
11123
|
return readdirSync12(scope).map((inner) => `${name}/${inner}`);
|
|
10973
11124
|
});
|
|
10974
11125
|
}
|
|
10975
11126
|
|
|
10976
11127
|
// src/lib/handover/rehearsal-links.ts
|
|
10977
|
-
import { existsSync as
|
|
11128
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync12, rmSync as rmSync14, symlinkSync as symlinkSync4, unlinkSync as unlinkSync2 } from "fs";
|
|
10978
11129
|
import { dirname as dirname20, isAbsolute as isAbsolute8, resolve as resolve17 } from "path";
|
|
10979
11130
|
|
|
10980
11131
|
// src/lib/worktree/sibling-links.ts
|
|
10981
|
-
import { existsSync as
|
|
10982
|
-
import { dirname as dirname19, isAbsolute as isAbsolute7, join as
|
|
11132
|
+
import { existsSync as existsSync43, lstatSync as lstatSync9, readlinkSync as readlinkSync4, realpathSync as realpathSync7, symlinkSync as symlinkSync3 } from "fs";
|
|
11133
|
+
import { dirname as dirname19, isAbsolute as isAbsolute7, join as join51, relative as relative7, resolve as resolve16, sep } from "path";
|
|
10983
11134
|
|
|
10984
11135
|
// src/lib/workspace.constants.ts
|
|
10985
11136
|
var WORKSPACE_MARKERS = ["_commit-plan", ".worktrees"];
|
|
@@ -10989,7 +11140,7 @@ var WORKTREES_FOLDER = ".worktrees";
|
|
|
10989
11140
|
// src/lib/worktree/sibling-links.ts
|
|
10990
11141
|
function linkSiblings(params) {
|
|
10991
11142
|
const { worktree, repository } = params;
|
|
10992
|
-
const worktreesFolder =
|
|
11143
|
+
const worktreesFolder = join51(dirname19(repository), WORKTREES_FOLDER);
|
|
10993
11144
|
const packageJson = readPackageJson(worktree);
|
|
10994
11145
|
const links = [];
|
|
10995
11146
|
for (const section of DEPENDENCY_SECTIONS)
|
|
@@ -11020,7 +11171,7 @@ function linkSiblings(params) {
|
|
|
11020
11171
|
function linkOutcome(params) {
|
|
11021
11172
|
const { link, target } = params;
|
|
11022
11173
|
if (isPresent(link)) return describeExisting({ link, target });
|
|
11023
|
-
if (!
|
|
11174
|
+
if (!existsSync43(target)) return `skipped: ${target} missing`;
|
|
11024
11175
|
const missingParent = topMissingFolder({ path: dirname19(link), above: params.worktreesFolder });
|
|
11025
11176
|
if (missingParent) return `skipped: ${missingParent} missing`;
|
|
11026
11177
|
params.beforeLink?.(link);
|
|
@@ -11041,11 +11192,11 @@ function topMissingFolder(params) {
|
|
|
11041
11192
|
}
|
|
11042
11193
|
function describeExisting(params) {
|
|
11043
11194
|
const { link, target } = params;
|
|
11044
|
-
const status =
|
|
11195
|
+
const status = lstatSync9(link);
|
|
11045
11196
|
if (!status.isSymbolicLink()) return `kept: a real ${status.isDirectory() ? "folder" : "file"}`;
|
|
11046
|
-
if (
|
|
11197
|
+
if (existsSync43(target) && existsSync43(link) && realpathSync7(link) === realpathSync7(target))
|
|
11047
11198
|
return "present";
|
|
11048
|
-
return `kept: points to ${
|
|
11199
|
+
return `kept: points to ${readlinkSync4(link)}, not ${target}`;
|
|
11049
11200
|
}
|
|
11050
11201
|
function isInside(params) {
|
|
11051
11202
|
const fromFolder = relative7(params.folder, params.path);
|
|
@@ -11071,7 +11222,7 @@ function linkRehearsalSiblings(params) {
|
|
|
11071
11222
|
}
|
|
11072
11223
|
const target = resolve17(repository, path);
|
|
11073
11224
|
if (isPresent(link)) continue;
|
|
11074
|
-
if (!
|
|
11225
|
+
if (!existsSync44(target)) {
|
|
11075
11226
|
lines.push(` not linked: ${path} (${target} missing)`);
|
|
11076
11227
|
continue;
|
|
11077
11228
|
}
|
|
@@ -11089,11 +11240,11 @@ function removeRehearsalFolder(params) {
|
|
|
11089
11240
|
}
|
|
11090
11241
|
|
|
11091
11242
|
// src/lib/handover/rehearsal-plan.ts
|
|
11092
|
-
import { readFileSync as
|
|
11243
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
11093
11244
|
function planRehearsal(params) {
|
|
11094
11245
|
const root = params.handover.lotsFile.repository;
|
|
11095
11246
|
const trees = listLotTrees({ root, lots: params.handover.lots });
|
|
11096
|
-
const hookText = listCommitHookFiles(root).map((file) =>
|
|
11247
|
+
const hookText = listCommitHookFiles(root).map((file) => readFileSync34(file, "utf8")).join("\n");
|
|
11097
11248
|
const context = {
|
|
11098
11249
|
root,
|
|
11099
11250
|
branch: params.handover.lotsFile.branch,
|
|
@@ -11200,38 +11351,38 @@ function fillReason(params) {
|
|
|
11200
11351
|
}
|
|
11201
11352
|
|
|
11202
11353
|
// src/lib/handover/run-handover-folder.ts
|
|
11203
|
-
import { copyFileSync as copyFileSync3, existsSync as
|
|
11204
|
-
import { join as
|
|
11354
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync48, readFileSync as readFileSync36, rmSync as rmSync17, writeFileSync as writeFileSync20 } from "fs";
|
|
11355
|
+
import { join as join55 } from "path";
|
|
11205
11356
|
|
|
11206
11357
|
// src/lib/handover/check-handover-guards.ts
|
|
11207
|
-
import { spawnSync as
|
|
11208
|
-
import { existsSync as
|
|
11209
|
-
import { join as
|
|
11358
|
+
import { spawnSync as spawnSync14 } from "child_process";
|
|
11359
|
+
import { existsSync as existsSync46 } from "fs";
|
|
11360
|
+
import { join as join53 } from "path";
|
|
11210
11361
|
|
|
11211
11362
|
// src/lib/handover/sync-node-modules.ts
|
|
11212
|
-
import { spawnSync as
|
|
11213
|
-
import { existsSync as
|
|
11214
|
-
import { join as
|
|
11363
|
+
import { spawnSync as spawnSync13 } from "child_process";
|
|
11364
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync35, rmSync as rmSync15, writeFileSync as writeFileSync18 } from "fs";
|
|
11365
|
+
import { join as join52 } from "path";
|
|
11215
11366
|
async function syncNodeModules(params) {
|
|
11216
11367
|
const { root, clock } = params;
|
|
11217
|
-
const lockChanged =
|
|
11368
|
+
const lockChanged = spawnSync13("git", ["diff", "--cached", "--quiet", "--", PACKAGE_LOCK_FILE2], { cwd: root }).status === 1;
|
|
11218
11369
|
if (!lockChanged) return {};
|
|
11219
11370
|
const before = nodeModulesAgainstStagedLock(root);
|
|
11220
11371
|
if (before.length === 0) return {};
|
|
11221
11372
|
const startedAt = clock.now();
|
|
11222
11373
|
const files = [PACKAGE_LOCK_FILE2, PACKAGE_MANIFEST_FILE].map((file) => ({
|
|
11223
11374
|
file,
|
|
11224
|
-
path:
|
|
11225
|
-
working:
|
|
11375
|
+
path: join52(root, file),
|
|
11376
|
+
working: existsSync45(join52(root, file)) ? readFileSync35(join52(root, file)) : void 0,
|
|
11226
11377
|
staged: stagedBytes({ root, file })
|
|
11227
11378
|
}));
|
|
11228
11379
|
const overwritten = files.filter((entry) => entry.staged !== void 0);
|
|
11229
11380
|
const backup = installBackupPath(root);
|
|
11230
11381
|
mkdirSync13(backup, { recursive: true });
|
|
11231
11382
|
for (const { file, working, staged } of overwritten) {
|
|
11232
|
-
if (working === void 0) writeFileSync18(
|
|
11233
|
-
else writeFileSync18(
|
|
11234
|
-
writeFileSync18(
|
|
11383
|
+
if (working === void 0) writeFileSync18(join52(backup, `${file}${ABSENT_SUFFIX}`), "");
|
|
11384
|
+
else writeFileSync18(join52(backup, file), working);
|
|
11385
|
+
writeFileSync18(join52(backup, `${file}${STAGED_SUFFIX}`), staged ?? "");
|
|
11235
11386
|
}
|
|
11236
11387
|
function restore() {
|
|
11237
11388
|
for (const { path, working } of overwritten)
|
|
@@ -11250,7 +11401,7 @@ async function syncNodeModules(params) {
|
|
|
11250
11401
|
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
11402
|
};
|
|
11252
11403
|
changed = overwritten.find(
|
|
11253
|
-
({ path, staged }) => !
|
|
11404
|
+
({ path, staged }) => !existsSync45(path) || !readFileSync35(path).equals(staged ?? Buffer.alloc(0))
|
|
11254
11405
|
)?.file;
|
|
11255
11406
|
} finally {
|
|
11256
11407
|
restore();
|
|
@@ -11269,11 +11420,11 @@ async function syncNodeModules(params) {
|
|
|
11269
11420
|
}
|
|
11270
11421
|
function restoreLeftoverBackup(root) {
|
|
11271
11422
|
const backup = installBackupPath(root);
|
|
11272
|
-
if (!
|
|
11423
|
+
if (!existsSync45(backup)) return void 0;
|
|
11273
11424
|
const names = readdirSync13(backup).filter((name) => name.endsWith(STAGED_SUFFIX)).map((name) => name.slice(0, -STAGED_SUFFIX.length));
|
|
11274
11425
|
const stillStaged2 = names.every((name) => {
|
|
11275
|
-
const path =
|
|
11276
|
-
return
|
|
11426
|
+
const path = join52(root, name);
|
|
11427
|
+
return existsSync45(path) && readFileSync35(path).equals(readFileSync35(join52(backup, `${name}${STAGED_SUFFIX}`)));
|
|
11277
11428
|
});
|
|
11278
11429
|
if (!stillStaged2)
|
|
11279
11430
|
return {
|
|
@@ -11281,9 +11432,9 @@ function restoreLeftoverBackup(root) {
|
|
|
11281
11432
|
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
11433
|
};
|
|
11283
11434
|
for (const name of names)
|
|
11284
|
-
if (
|
|
11285
|
-
rmSync15(
|
|
11286
|
-
else writeFileSync18(
|
|
11435
|
+
if (existsSync45(join52(backup, `${name}${ABSENT_SUFFIX}`)))
|
|
11436
|
+
rmSync15(join52(root, name), { force: true });
|
|
11437
|
+
else writeFileSync18(join52(root, name), readFileSync35(join52(backup, name)));
|
|
11287
11438
|
rmSync15(backup, { recursive: true, force: true });
|
|
11288
11439
|
return {
|
|
11289
11440
|
ok: true,
|
|
@@ -11297,11 +11448,11 @@ function installBackupPath(root) {
|
|
|
11297
11448
|
}).trim();
|
|
11298
11449
|
}
|
|
11299
11450
|
function stagedBytes(params) {
|
|
11300
|
-
const staged =
|
|
11451
|
+
const staged = spawnSync13("git", ["show", `:${params.file}`], { cwd: params.root });
|
|
11301
11452
|
return staged.status === 0 ? staged.stdout : void 0;
|
|
11302
11453
|
}
|
|
11303
11454
|
function readStagedLockPackages(root) {
|
|
11304
|
-
const staged =
|
|
11455
|
+
const staged = spawnSync13("git", ["show", `:${PACKAGE_LOCK_FILE2}`], {
|
|
11305
11456
|
cwd: root,
|
|
11306
11457
|
encoding: "utf8"
|
|
11307
11458
|
});
|
|
@@ -11310,8 +11461,8 @@ function readStagedLockPackages(root) {
|
|
|
11310
11461
|
return Object.entries(lock.packages ?? {}).filter(([path]) => path.startsWith("node_modules/"));
|
|
11311
11462
|
}
|
|
11312
11463
|
function installedVersion2(params) {
|
|
11313
|
-
const manifest =
|
|
11314
|
-
return
|
|
11464
|
+
const manifest = join52(params.root, params.path, "package.json");
|
|
11465
|
+
return existsSync45(manifest) ? JSON.parse(readFileSync35(manifest, "utf8")).version : void 0;
|
|
11315
11466
|
}
|
|
11316
11467
|
function nodeModulesAgainstStagedLock(root) {
|
|
11317
11468
|
return readStagedLockPackages(root).flatMap(function differs([path, entry]) {
|
|
@@ -11352,7 +11503,7 @@ function checkHandoverGuards(params) {
|
|
|
11352
11503
|
{
|
|
11353
11504
|
name: "repository",
|
|
11354
11505
|
check: function repositoryExists() {
|
|
11355
|
-
return
|
|
11506
|
+
return existsSync46(root) ? { ok: true, detail: root } : { ok: false, detail: `${root} does not exist` };
|
|
11356
11507
|
}
|
|
11357
11508
|
},
|
|
11358
11509
|
{
|
|
@@ -11363,13 +11514,13 @@ function checkHandoverGuards(params) {
|
|
|
11363
11514
|
ok: false,
|
|
11364
11515
|
detail: `${HANDOVER_FILES.mergesHash} is missing: write it again with --rehash after a review`
|
|
11365
11516
|
};
|
|
11366
|
-
const mergesAsReviewed = handover.mergesHash === void 0 || hashFile2(
|
|
11517
|
+
const mergesAsReviewed = handover.mergesHash === void 0 || hashFile2(join53(handover.folder, HANDOVER_FILES.merges)) === handover.mergesHash;
|
|
11367
11518
|
if (!mergesAsReviewed)
|
|
11368
11519
|
return {
|
|
11369
11520
|
ok: false,
|
|
11370
11521
|
detail: `${HANDOVER_FILES.merges} changed since the hand-over was written: \`dialecte handover --rehash <lots.json>\` after a review`
|
|
11371
11522
|
};
|
|
11372
|
-
return hashFile2(
|
|
11523
|
+
return hashFile2(join53(handover.folder, HANDOVER_FILES.lots)) === handover.lotsHash ? { ok: true, detail: `${lots.length} lot(s) as reviewed` } : {
|
|
11373
11524
|
ok: false,
|
|
11374
11525
|
detail: "lots.json changed since the hand-over was written: `dialecte handover --rehash <lots.json>` after a review"
|
|
11375
11526
|
};
|
|
@@ -11461,8 +11612,8 @@ function checkHandoverGuards(params) {
|
|
|
11461
11612
|
check: function filesAsReviewed() {
|
|
11462
11613
|
const differing = handover.snapshotLines.filter(function differs(line) {
|
|
11463
11614
|
const [hash, ...pathParts] = line.split(" ");
|
|
11464
|
-
const path =
|
|
11465
|
-
return !
|
|
11615
|
+
const path = join53(root, pathParts.join(" "));
|
|
11616
|
+
return !isPresent(path) || hashFile2(path) !== hash;
|
|
11466
11617
|
});
|
|
11467
11618
|
return differing.length ? {
|
|
11468
11619
|
ok: false,
|
|
@@ -11475,7 +11626,7 @@ function checkHandoverGuards(params) {
|
|
|
11475
11626
|
name: "deleted",
|
|
11476
11627
|
check: function deletedStayDeleted() {
|
|
11477
11628
|
const deleted = lots.flatMap((lot) => lot.deletedFiles);
|
|
11478
|
-
const back = deleted.filter((file) =>
|
|
11629
|
+
const back = deleted.filter((file) => isPresent(join53(root, file)));
|
|
11479
11630
|
return back.length ? { ok: false, detail: "deleted in the snapshot and there again", lines: back } : { ok: true, detail: `${deleted.length} file(s) absent` };
|
|
11480
11631
|
}
|
|
11481
11632
|
},
|
|
@@ -11508,7 +11659,7 @@ function checkHandoverGuards(params) {
|
|
|
11508
11659
|
}
|
|
11509
11660
|
}
|
|
11510
11661
|
];
|
|
11511
|
-
const leftover =
|
|
11662
|
+
const leftover = existsSync46(root) ? restoreLeftoverBackup(root) : void 0;
|
|
11512
11663
|
if (leftover) {
|
|
11513
11664
|
write(`${leftover.ok ? "\u2713" : "\u2717"} ${"backup".padEnd(GUARD_NAME_WIDTH)} ${leftover.detail}`);
|
|
11514
11665
|
if (!leftover.ok) return void 0;
|
|
@@ -11551,7 +11702,7 @@ function checkMerges(params) {
|
|
|
11551
11702
|
detail: `lot ${number}: tree not recorded: rehearse first (\`--rehearse\` prints it), add it as "tree" to the lot, then \`dialecte handover --rehash\``
|
|
11552
11703
|
};
|
|
11553
11704
|
const changed = merge.resolutions.filter(
|
|
11554
|
-
(resolution) => !("removed" in resolution) && (!
|
|
11705
|
+
(resolution) => !("removed" in resolution) && (!existsSync46(resolution.file) || hashFile2(resolution.file) !== resolution.sha256)
|
|
11555
11706
|
);
|
|
11556
11707
|
if (changed.length)
|
|
11557
11708
|
return {
|
|
@@ -11598,7 +11749,7 @@ function checkMutation(params) {
|
|
|
11598
11749
|
};
|
|
11599
11750
|
}
|
|
11600
11751
|
function resolveCommit(params) {
|
|
11601
|
-
const result =
|
|
11752
|
+
const result = spawnSync14(
|
|
11602
11753
|
"git",
|
|
11603
11754
|
["rev-parse", "--verify", "--quiet", `${params.revision}^{commit}`],
|
|
11604
11755
|
{ cwd: params.root, encoding: "utf8" }
|
|
@@ -11609,7 +11760,7 @@ function resolveCommit(params) {
|
|
|
11609
11760
|
// src/lib/handover/commit-lots.ts
|
|
11610
11761
|
import { appendFileSync, mkdtempSync as mkdtempSync5, rmSync as rmSync16, writeFileSync as writeFileSync19 } from "fs";
|
|
11611
11762
|
import { tmpdir as tmpdir5 } from "os";
|
|
11612
|
-
import { dirname as dirname21, join as
|
|
11763
|
+
import { dirname as dirname21, join as join54 } from "path";
|
|
11613
11764
|
|
|
11614
11765
|
// src/lib/progress/heartbeat.ts
|
|
11615
11766
|
function startHeartbeat(params) {
|
|
@@ -12040,26 +12191,26 @@ function createHookLiveView(params) {
|
|
|
12040
12191
|
}
|
|
12041
12192
|
|
|
12042
12193
|
// src/lib/handover/unstage-lot.ts
|
|
12043
|
-
import { spawnSync as
|
|
12044
|
-
import { existsSync as
|
|
12194
|
+
import { spawnSync as spawnSync15 } from "child_process";
|
|
12195
|
+
import { existsSync as existsSync47 } from "fs";
|
|
12045
12196
|
function unstageLot(params) {
|
|
12046
12197
|
const { root, clock } = params;
|
|
12047
12198
|
const giveUpAt = clock.now() + INDEX_LOCK_WAIT_MILLISECONDS;
|
|
12048
12199
|
for (; ; ) {
|
|
12049
|
-
const reset =
|
|
12200
|
+
const reset = spawnSync15("git", ["reset", "-q", "--", ...params.paths], {
|
|
12050
12201
|
cwd: root,
|
|
12051
12202
|
encoding: "utf8"
|
|
12052
12203
|
});
|
|
12053
12204
|
if (reset.status === 0) return { unstaged: true };
|
|
12054
12205
|
const lock = indexLockPath(root);
|
|
12055
12206
|
const reason = (reset.stderr || reset.stdout || `git reset exited ${reset.status}`).trim().split("\n")[0];
|
|
12056
|
-
if (!lock || !
|
|
12057
|
-
return { unstaged: false, reason, ...lock &&
|
|
12207
|
+
if (!lock || !existsSync47(lock) || clock.now() >= giveUpAt)
|
|
12208
|
+
return { unstaged: false, reason, ...lock && existsSync47(lock) && { lock } };
|
|
12058
12209
|
clock.sleep(INDEX_LOCK_RETRY_MILLISECONDS);
|
|
12059
12210
|
}
|
|
12060
12211
|
}
|
|
12061
12212
|
function indexLockPath(root) {
|
|
12062
|
-
const result =
|
|
12213
|
+
const result = spawnSync15(
|
|
12063
12214
|
"git",
|
|
12064
12215
|
["rev-parse", "--path-format=absolute", "--git-path", "index.lock"],
|
|
12065
12216
|
{ cwd: root, encoding: "utf8" }
|
|
@@ -12216,7 +12367,7 @@ function recordedHookStep(step) {
|
|
|
12216
12367
|
};
|
|
12217
12368
|
}
|
|
12218
12369
|
function createHookLog(params) {
|
|
12219
|
-
const path =
|
|
12370
|
+
const path = join54(mkdtempSync5(join54(tmpdir5(), HOOK_LOG_FOLDER_PREFIX)), `lot-${params.lot}.log`);
|
|
12220
12371
|
writeFileSync19(path, "");
|
|
12221
12372
|
return path;
|
|
12222
12373
|
}
|
|
@@ -12297,10 +12448,10 @@ async function runHandoverFolder(params) {
|
|
|
12297
12448
|
return committed ? 0 : 1;
|
|
12298
12449
|
}
|
|
12299
12450
|
function archiveLotFile(params) {
|
|
12300
|
-
const source =
|
|
12301
|
-
const target =
|
|
12302
|
-
if (!
|
|
12303
|
-
if (isEmptyDeclaration(
|
|
12451
|
+
const source = join55(params.root, LOT_FILE);
|
|
12452
|
+
const target = join55(params.folder, ARCHIVED_LOT_FILE);
|
|
12453
|
+
if (!existsSync48(source) || existsSync48(target)) return void 0;
|
|
12454
|
+
if (isEmptyDeclaration(readFileSync36(source, "utf8"))) return void 0;
|
|
12304
12455
|
copyFileSync3(source, target);
|
|
12305
12456
|
writeFileSync20(source, EMPTY_LOT_DECLARATION);
|
|
12306
12457
|
return target;
|
|
@@ -12315,7 +12466,7 @@ function isEmptyDeclaration(text) {
|
|
|
12315
12466
|
}
|
|
12316
12467
|
function releaseLock(params) {
|
|
12317
12468
|
const lockPath = handoverLockPath(params.root);
|
|
12318
|
-
if (
|
|
12469
|
+
if (existsSync48(lockPath) && readFileSync36(lockPath, "utf8").trim() === join55(params.folder, COMMIT_SCRIPT_FILE))
|
|
12319
12470
|
rmSync17(lockPath);
|
|
12320
12471
|
}
|
|
12321
12472
|
|
|
@@ -12324,7 +12475,7 @@ async function rehearseHandover(params) {
|
|
|
12324
12475
|
const { handover, write } = params;
|
|
12325
12476
|
const decisions = decideLots({ handover, full: params.full ?? false });
|
|
12326
12477
|
writeFileSync21(
|
|
12327
|
-
|
|
12478
|
+
join56(handover.folder, REHEARSAL_DECISIONS_FILE),
|
|
12328
12479
|
`${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), lots: decisions }, null, 2)}
|
|
12329
12480
|
`
|
|
12330
12481
|
);
|
|
@@ -12355,9 +12506,9 @@ async function rehearseHandover(params) {
|
|
|
12355
12506
|
clock: params.clock
|
|
12356
12507
|
});
|
|
12357
12508
|
const repository = handover.lotsFile.repository;
|
|
12358
|
-
const folder = mkdtempSync6(
|
|
12359
|
-
const clone =
|
|
12360
|
-
const hookTemporary =
|
|
12509
|
+
const folder = mkdtempSync6(join56(params.scratchRoot, REHEARSAL_FOLDER_PREFIX));
|
|
12510
|
+
const clone = join56(folder, basename7(repository));
|
|
12511
|
+
const hookTemporary = join56(folder, REHEARSAL_TEMPORARY_FOLDER);
|
|
12361
12512
|
mkdirSync14(hookTemporary);
|
|
12362
12513
|
write(`rehearsal in ${clone}`);
|
|
12363
12514
|
const links = [];
|
|
@@ -12459,7 +12610,7 @@ function prepareClone(params) {
|
|
|
12459
12610
|
});
|
|
12460
12611
|
readGit({ root: clone, args: ["checkout", "-q", "-B", params.branch, head] });
|
|
12461
12612
|
writeFileSync21(
|
|
12462
|
-
|
|
12613
|
+
join56(clone, ".git", REHEARSAL_MARKER_FILE),
|
|
12463
12614
|
`${JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
12464
12615
|
`
|
|
12465
12616
|
);
|
|
@@ -12469,11 +12620,14 @@ function prepareClone(params) {
|
|
|
12469
12620
|
}
|
|
12470
12621
|
const changed = listChangedFiles({ root: repository, withDeleted: true });
|
|
12471
12622
|
for (const file of changed) {
|
|
12472
|
-
const source =
|
|
12473
|
-
const target =
|
|
12474
|
-
if (
|
|
12623
|
+
const source = join56(repository, file);
|
|
12624
|
+
const target = join56(clone, file);
|
|
12625
|
+
if (isPresent(source)) {
|
|
12475
12626
|
mkdirSync14(dirname22(target), { recursive: true });
|
|
12476
|
-
|
|
12627
|
+
if (lstatSync10(source).isSymbolicLink()) {
|
|
12628
|
+
rmSync18(target, { force: true });
|
|
12629
|
+
symlinkSync5(readlinkSync5(source), target);
|
|
12630
|
+
} else cpSync2(source, target);
|
|
12477
12631
|
} else {
|
|
12478
12632
|
rmSync18(target, { force: true });
|
|
12479
12633
|
removeEmptiedFolders({ clone, folder: dirname22(target) });
|
|
@@ -12484,23 +12638,23 @@ function prepareClone(params) {
|
|
|
12484
12638
|
if (hooks.configured && isAbsolute9(hooks.configured))
|
|
12485
12639
|
readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
|
|
12486
12640
|
else if (hooks.configured) {
|
|
12487
|
-
if (
|
|
12488
|
-
cpSync2(hooks.folder,
|
|
12641
|
+
if (existsSync49(hooks.folder))
|
|
12642
|
+
cpSync2(hooks.folder, join56(clone, hooks.configured), { recursive: true });
|
|
12489
12643
|
readGit({ root: clone, args: ["config", "core.hooksPath", hooks.configured] });
|
|
12490
|
-
} else if (
|
|
12491
|
-
cpSync2(hooks.folder,
|
|
12644
|
+
} else if (existsSync49(hooks.folder))
|
|
12645
|
+
cpSync2(hooks.folder, join56(clone, ".git", "hooks"), { recursive: true });
|
|
12492
12646
|
write(` hooks: ${hooks.configured ?? "git hooks folder"} copied`);
|
|
12493
|
-
const nodeModules =
|
|
12494
|
-
if (
|
|
12495
|
-
const copy = copyNodeModules({ from: nodeModules, to:
|
|
12647
|
+
const nodeModules = join56(repository, "node_modules");
|
|
12648
|
+
if (existsSync49(nodeModules)) {
|
|
12649
|
+
const copy = copyNodeModules({ from: nodeModules, to: join56(clone, "node_modules") });
|
|
12496
12650
|
write(
|
|
12497
12651
|
` node_modules: ${copy.method}${copy.relinked.length ? `, ${copy.relinked.length} link(s) re-pointed` : ""}`
|
|
12498
12652
|
);
|
|
12499
12653
|
}
|
|
12500
|
-
|
|
12654
|
+
spawnSync16("git", ["update-index", "-q", "--refresh"], { cwd: clone });
|
|
12501
12655
|
}
|
|
12502
12656
|
function removeEmptiedFolders(params) {
|
|
12503
|
-
for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) &&
|
|
12657
|
+
for (let folder = params.folder; folder !== params.clone && folder.startsWith(params.clone) && existsSync49(folder); folder = dirname22(folder)) {
|
|
12504
12658
|
if (readdirSync14(folder).length) return;
|
|
12505
12659
|
rmdirSync(folder);
|
|
12506
12660
|
}
|
|
@@ -12731,12 +12885,12 @@ function renderLegend(params) {
|
|
|
12731
12885
|
}
|
|
12732
12886
|
|
|
12733
12887
|
// src/lib/workspace.ts
|
|
12734
|
-
import { existsSync as
|
|
12735
|
-
import { dirname as dirname23, join as
|
|
12888
|
+
import { existsSync as existsSync50 } from "fs";
|
|
12889
|
+
import { dirname as dirname23, join as join57 } from "path";
|
|
12736
12890
|
function findWorkspace(cwd) {
|
|
12737
12891
|
let folder = cwd;
|
|
12738
12892
|
for (; ; ) {
|
|
12739
|
-
if (WORKSPACE_MARKERS.some((marker) =>
|
|
12893
|
+
if (WORKSPACE_MARKERS.some((marker) => existsSync50(join57(folder, marker)))) return folder;
|
|
12740
12894
|
const parent = dirname23(folder);
|
|
12741
12895
|
if (parent === folder) return void 0;
|
|
12742
12896
|
folder = parent;
|
|
@@ -12792,13 +12946,13 @@ function runHandover(params) {
|
|
|
12792
12946
|
const lotsFile = readLotsFile(absoluteLotsPath);
|
|
12793
12947
|
if (typeof lotsFile === "string") return usage(`handover: ${lotsFile}`);
|
|
12794
12948
|
const out = resolve18(getArg(argv, "out") ?? dirname24(absoluteLotsPath));
|
|
12795
|
-
const scriptPath =
|
|
12796
|
-
if (
|
|
12949
|
+
const scriptPath = join58(out, COMMIT_SCRIPT_FILE);
|
|
12950
|
+
if (existsSync51(scriptPath) && !hasFlag(argv, "rehash"))
|
|
12797
12951
|
return usage(
|
|
12798
12952
|
`handover: ${scriptPath} exists: pass --rehash to take the snapshot again after an edit`
|
|
12799
12953
|
);
|
|
12800
12954
|
const heldBy = readHandoverLock(lotsFile.repository);
|
|
12801
|
-
if (heldBy && heldBy !== scriptPath &&
|
|
12955
|
+
if (heldBy && heldBy !== scriptPath && existsSync51(heldBy))
|
|
12802
12956
|
return refused([
|
|
12803
12957
|
handoverHoldRefusal({
|
|
12804
12958
|
script: heldBy,
|
|
@@ -12899,10 +13053,10 @@ async function runHandoverRun(params) {
|
|
|
12899
13053
|
function runHandoverList(params) {
|
|
12900
13054
|
const { argv, cwd } = params;
|
|
12901
13055
|
const workspace = findWorkspace(cwd);
|
|
12902
|
-
const commitPlan = workspace &&
|
|
13056
|
+
const commitPlan = workspace && join58(workspace, COMMIT_PLAN_FOLDER);
|
|
12903
13057
|
const root = resolve18(
|
|
12904
13058
|
cwd,
|
|
12905
|
-
getArg(argv, "root") ?? (commitPlan &&
|
|
13059
|
+
getArg(argv, "root") ?? (commitPlan && existsSync51(commitPlan) ? commitPlan : cwd)
|
|
12906
13060
|
);
|
|
12907
13061
|
const listings = listHandovers({ root, now: params.now });
|
|
12908
13062
|
if (hasFlag(argv, "json")) return { exitCode: 0, output: JSON.stringify(listings, null, 2) };
|
|
@@ -12942,15 +13096,15 @@ function refused(reasons) {
|
|
|
12942
13096
|
}
|
|
12943
13097
|
|
|
12944
13098
|
// src/commands/lot.ts
|
|
12945
|
-
import { existsSync as
|
|
12946
|
-
import { dirname as dirname26, join as
|
|
13099
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync15, readFileSync as readFileSync37, writeFileSync as writeFileSync22 } from "fs";
|
|
13100
|
+
import { dirname as dirname26, join as join60 } from "path";
|
|
12947
13101
|
|
|
12948
13102
|
// src/lib/package-root.ts
|
|
12949
|
-
import { existsSync as
|
|
12950
|
-
import { dirname as dirname25, join as
|
|
13103
|
+
import { existsSync as existsSync52 } from "fs";
|
|
13104
|
+
import { dirname as dirname25, join as join59 } from "path";
|
|
12951
13105
|
function packageRootOf(cwd) {
|
|
12952
13106
|
for (let folder = cwd; ; folder = dirname25(folder)) {
|
|
12953
|
-
if (
|
|
13107
|
+
if (existsSync52(join59(folder, "package.json"))) return folder;
|
|
12954
13108
|
if (dirname25(folder) === folder) return void 0;
|
|
12955
13109
|
}
|
|
12956
13110
|
}
|
|
@@ -12983,11 +13137,11 @@ function runLot(params) {
|
|
|
12983
13137
|
};
|
|
12984
13138
|
const root = packageRootOf(params.cwd);
|
|
12985
13139
|
if (!root) return { exitCode: 1, output: `lot: no package.json at or above ${params.cwd}` };
|
|
12986
|
-
const path =
|
|
13140
|
+
const path = join60(root, LOT_FILE);
|
|
12987
13141
|
let read = {};
|
|
12988
|
-
if (
|
|
13142
|
+
if (existsSync53(path))
|
|
12989
13143
|
try {
|
|
12990
|
-
read = JSON.parse(
|
|
13144
|
+
read = JSON.parse(readFileSync37(path, "utf8"));
|
|
12991
13145
|
} catch (error) {
|
|
12992
13146
|
return {
|
|
12993
13147
|
exitCode: 1,
|
|
@@ -13095,16 +13249,78 @@ function memberLine(member) {
|
|
|
13095
13249
|
return member.summary ? ` ${member.name}() ${shortSummary(member.summary)}` : ` ${member.name}()`;
|
|
13096
13250
|
}
|
|
13097
13251
|
|
|
13252
|
+
// src/lib/namespace-of.ts
|
|
13253
|
+
function namespaceOf(packageName3) {
|
|
13254
|
+
const name = packageName3.split("/").pop() || "dialecte";
|
|
13255
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
13256
|
+
}
|
|
13257
|
+
|
|
13258
|
+
// src/lib/api/installed-bindings.constants.ts
|
|
13259
|
+
var VERSION_SUBPATH_PATTERN = /^\.\/[^/*]+$/;
|
|
13260
|
+
var TEST_ENTRY = "test";
|
|
13261
|
+
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";
|
|
13262
|
+
|
|
13263
|
+
// src/lib/api/installed-bindings.ts
|
|
13264
|
+
function findInstalledBindings(params) {
|
|
13265
|
+
return dependencyNames(params.cwd).flatMap(function bindingsOf(name) {
|
|
13266
|
+
const folder = findInstalledPackage({ cwd: params.cwd, name });
|
|
13267
|
+
const manifest = folder ? readManifest(folder) : void 0;
|
|
13268
|
+
if (!manifest?.name || !isBuiltOnCore(manifest)) return [];
|
|
13269
|
+
const packageName3 = manifest.name;
|
|
13270
|
+
return versionsOf(manifest).map((version) => ({
|
|
13271
|
+
packageName: packageName3,
|
|
13272
|
+
version,
|
|
13273
|
+
binding: {
|
|
13274
|
+
kind: "namespace",
|
|
13275
|
+
name: namespaceOf(packageName3),
|
|
13276
|
+
import: `${packageName3}/${version}`
|
|
13277
|
+
}
|
|
13278
|
+
}));
|
|
13279
|
+
});
|
|
13280
|
+
}
|
|
13281
|
+
function versionsOf(manifest) {
|
|
13282
|
+
const subpaths = typeof manifest.exports === "object" ? Object.keys(manifest.exports) : [];
|
|
13283
|
+
return subpaths.filter((subpath) => VERSION_SUBPATH_PATTERN.test(subpath)).filter((subpath) => subpaths.includes(`${subpath}/${TEST_ENTRY}`)).map((subpath) => subpath.slice(2));
|
|
13284
|
+
}
|
|
13285
|
+
function chooseInstalledBinding(params) {
|
|
13286
|
+
if (params.bindings.length === 0) return { kind: "output", message: NO_DIALECTE_INSTALLED };
|
|
13287
|
+
const matching = params.bindings.filter(
|
|
13288
|
+
(binding) => (params.packageName === void 0 || binding.packageName === params.packageName) && (params.version === void 0 || binding.version === params.version)
|
|
13289
|
+
);
|
|
13290
|
+
if (matching.length === 1) return { kind: "binding", binding: matching[0] };
|
|
13291
|
+
if (matching.length === 0) {
|
|
13292
|
+
const named = [
|
|
13293
|
+
...params.packageName === void 0 ? [] : [`--package ${params.packageName}`],
|
|
13294
|
+
...params.version === void 0 ? [] : [`--version ${params.version}`]
|
|
13295
|
+
].join(" ");
|
|
13296
|
+
return {
|
|
13297
|
+
kind: "output",
|
|
13298
|
+
message: `no installed dialecte matches ${named}; installed:
|
|
13299
|
+
${listLines(params.bindings)}`
|
|
13300
|
+
};
|
|
13301
|
+
}
|
|
13302
|
+
return {
|
|
13303
|
+
kind: "output",
|
|
13304
|
+
message: `several dialectes are installed: pass --package <name> [--version <v>]
|
|
13305
|
+
${listLines(matching)}`
|
|
13306
|
+
};
|
|
13307
|
+
}
|
|
13308
|
+
function listLines(bindings) {
|
|
13309
|
+
return bindings.map((binding) => ` ${binding.packageName} --version ${binding.version}
|
|
13310
|
+
`).join("");
|
|
13311
|
+
}
|
|
13312
|
+
|
|
13098
13313
|
// src/commands/members.constants.ts
|
|
13099
13314
|
var MEMBERS_VALUE_OPTIONS = [
|
|
13100
13315
|
"namespace",
|
|
13101
13316
|
"entry",
|
|
13317
|
+
"package",
|
|
13102
13318
|
"version",
|
|
13103
13319
|
"tsconfig",
|
|
13104
13320
|
"constants-dir",
|
|
13105
13321
|
"out"
|
|
13106
13322
|
];
|
|
13107
|
-
var MEMBERS_USAGE = "usage: dialecte members <expression> [--json] [--version <v>] (in an app
|
|
13323
|
+
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
13324
|
|
|
13109
13325
|
// src/commands/skills.constants.ts
|
|
13110
13326
|
var METHOD_DISCOVERY_DEPTH = 3;
|
|
@@ -13130,12 +13346,16 @@ function readMemberEntries(params) {
|
|
|
13130
13346
|
if (missing) return { kind: "output", output: missing };
|
|
13131
13347
|
const { argv, cwd } = params;
|
|
13132
13348
|
const [expression] = positionalArguments({ argv, valueOptions: MEMBERS_VALUE_OPTIONS });
|
|
13133
|
-
const
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
`, exitCode: 2 }
|
|
13349
|
+
const usage4 = {
|
|
13350
|
+
kind: "output",
|
|
13351
|
+
output: { output: `${MEMBERS_USAGE}
|
|
13352
|
+
`, exitCode: 2 }
|
|
13353
|
+
};
|
|
13354
|
+
if (!expression) return usage4;
|
|
13355
|
+
const binding = readBinding({ argv, cwd });
|
|
13356
|
+
if (binding.kind === "output") return binding;
|
|
13137
13357
|
const entries = discoverMethods({
|
|
13138
|
-
entrySource: discoveryEntry(
|
|
13358
|
+
entrySource: discoveryEntry(binding.binding),
|
|
13139
13359
|
tsconfig: tsconfigOf(argv, cwd),
|
|
13140
13360
|
root: cwd,
|
|
13141
13361
|
// one level below the expression, so each group it holds is counted
|
|
@@ -13143,6 +13363,17 @@ function readMemberEntries(params) {
|
|
|
13143
13363
|
});
|
|
13144
13364
|
return { kind: "entries", entries, expression };
|
|
13145
13365
|
}
|
|
13366
|
+
function readBinding(params) {
|
|
13367
|
+
const [target] = resolveTargets(params.argv, params.cwd);
|
|
13368
|
+
if (target) return { kind: "binding", binding: target.binding };
|
|
13369
|
+
const choice = chooseInstalledBinding({
|
|
13370
|
+
bindings: findInstalledBindings({ cwd: params.cwd }),
|
|
13371
|
+
packageName: getArg(params.argv, "package"),
|
|
13372
|
+
version: getArg(params.argv, "version")
|
|
13373
|
+
});
|
|
13374
|
+
if (choice.kind === "binding") return { kind: "binding", binding: choice.binding.binding };
|
|
13375
|
+
return { kind: "output", output: { output: choice.message, exitCode: 2 } };
|
|
13376
|
+
}
|
|
13146
13377
|
|
|
13147
13378
|
// src/lib/models/answer-models.ts
|
|
13148
13379
|
function answerModels(params) {
|
|
@@ -13212,13 +13443,13 @@ function runModels(params) {
|
|
|
13212
13443
|
}
|
|
13213
13444
|
|
|
13214
13445
|
// src/commands/mutants.ts
|
|
13215
|
-
import { existsSync as
|
|
13446
|
+
import { existsSync as existsSync58, mkdirSync as mkdirSync18, readFileSync as readFileSync40, rmSync as rmSync21, writeFileSync as writeFileSync24 } from "fs";
|
|
13216
13447
|
import { createRequire as createRequire5 } from "module";
|
|
13217
|
-
import { dirname as dirname29, join as
|
|
13448
|
+
import { dirname as dirname29, join as join65, resolve as resolve19 } from "path";
|
|
13218
13449
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL4 } from "url";
|
|
13219
13450
|
|
|
13220
13451
|
// src/lib/mutation/cache-key.ts
|
|
13221
|
-
import { existsSync as
|
|
13452
|
+
import { existsSync as existsSync54 } from "fs";
|
|
13222
13453
|
|
|
13223
13454
|
// src/lib/mutation/incremental-cache.constants.ts
|
|
13224
13455
|
var INCREMENTAL_FILE_NAME = "incremental.json";
|
|
@@ -13244,7 +13475,7 @@ function computeIncrementalKey(params) {
|
|
|
13244
13475
|
...readInstalledKey(root),
|
|
13245
13476
|
options: withoutPerRunFields(options),
|
|
13246
13477
|
cliVersion,
|
|
13247
|
-
ignorer:
|
|
13478
|
+
ignorer: existsSync54(ignorerPlugin) ? hashFile(ignorerPlugin) : MISSING_KEY_INPUT
|
|
13248
13479
|
};
|
|
13249
13480
|
return hashText(JSON.stringify(withSortedKeys(keyed)));
|
|
13250
13481
|
}
|
|
@@ -13271,17 +13502,17 @@ function withSortedKeys(value) {
|
|
|
13271
13502
|
|
|
13272
13503
|
// src/lib/mutation/incremental-cache.ts
|
|
13273
13504
|
import {
|
|
13274
|
-
existsSync as
|
|
13505
|
+
existsSync as existsSync55,
|
|
13275
13506
|
mkdirSync as mkdirSync16,
|
|
13276
13507
|
readdirSync as readdirSync15,
|
|
13277
|
-
readFileSync as
|
|
13508
|
+
readFileSync as readFileSync38,
|
|
13278
13509
|
rmSync as rmSync19,
|
|
13279
|
-
statSync as
|
|
13510
|
+
statSync as statSync9,
|
|
13280
13511
|
writeFileSync as writeFileSync23
|
|
13281
13512
|
} from "fs";
|
|
13282
|
-
import { dirname as dirname27, join as
|
|
13513
|
+
import { dirname as dirname27, join as join61 } from "path";
|
|
13283
13514
|
function incrementalCachePathOf(params) {
|
|
13284
|
-
return
|
|
13515
|
+
return join61(storeFolderOf2(params.root), `${params.packageHash}-${params.key}.json`);
|
|
13285
13516
|
}
|
|
13286
13517
|
function seedIncrementalFile(params) {
|
|
13287
13518
|
const text = readParsableText(incrementalCachePathOf(params));
|
|
@@ -13300,15 +13531,15 @@ function storeIncrementalFile(params) {
|
|
|
13300
13531
|
return true;
|
|
13301
13532
|
}
|
|
13302
13533
|
function storeFolderOf2(root) {
|
|
13303
|
-
return
|
|
13534
|
+
return join61(mutationStoreFolderOf(root), INCREMENTAL_STORE_FOLDER);
|
|
13304
13535
|
}
|
|
13305
13536
|
function evictOldFiles(params) {
|
|
13306
13537
|
const { folder, packageHash, kept } = params;
|
|
13307
13538
|
const prefix2 = `${packageHash}-`;
|
|
13308
13539
|
const files = readdirSync15(folder).filter((name) => name.startsWith(prefix2) && name.endsWith(".json")).map((name) => ({
|
|
13309
13540
|
name,
|
|
13310
|
-
path:
|
|
13311
|
-
modified: modifiedTimeOf(
|
|
13541
|
+
path: join61(folder, name),
|
|
13542
|
+
modified: modifiedTimeOf(join61(folder, name))
|
|
13312
13543
|
})).filter(
|
|
13313
13544
|
(file) => file.modified !== void 0
|
|
13314
13545
|
).filter((file) => file.path !== kept).sort(
|
|
@@ -13319,15 +13550,15 @@ function evictOldFiles(params) {
|
|
|
13319
13550
|
}
|
|
13320
13551
|
function modifiedTimeOf(path) {
|
|
13321
13552
|
try {
|
|
13322
|
-
return
|
|
13553
|
+
return statSync9(path).mtimeMs;
|
|
13323
13554
|
} catch {
|
|
13324
13555
|
return void 0;
|
|
13325
13556
|
}
|
|
13326
13557
|
}
|
|
13327
13558
|
function readParsableText(path) {
|
|
13328
|
-
if (!
|
|
13559
|
+
if (!existsSync55(path)) return void 0;
|
|
13329
13560
|
try {
|
|
13330
|
-
const text =
|
|
13561
|
+
const text = readFileSync38(path, "utf8");
|
|
13331
13562
|
JSON.parse(text);
|
|
13332
13563
|
return text;
|
|
13333
13564
|
} catch {
|
|
@@ -13452,21 +13683,21 @@ function readArguments(params) {
|
|
|
13452
13683
|
}
|
|
13453
13684
|
|
|
13454
13685
|
// src/lib/mutation/drop-run.ts
|
|
13455
|
-
import { existsSync as
|
|
13456
|
-
import { join as
|
|
13686
|
+
import { existsSync as existsSync56, rmSync as rmSync20 } from "fs";
|
|
13687
|
+
import { join as join62 } from "path";
|
|
13457
13688
|
function dropRun(params) {
|
|
13458
13689
|
const { root, runId, isAlive, startTimeOf, afterDecision } = params;
|
|
13459
13690
|
const store = mutationStoreFolderOf(root);
|
|
13460
|
-
const path =
|
|
13691
|
+
const path = join62(store, MUTATION_RUNS_FOLDER, `${runId}.json`);
|
|
13461
13692
|
return withLedgerLock({
|
|
13462
13693
|
root,
|
|
13463
13694
|
work: function dropUnderLock(state) {
|
|
13464
13695
|
const runs = readRuns({ root, isAlive, startTimeOf });
|
|
13465
13696
|
const run25 = isRunId(runId) ? runs.find((entry) => entry.runId === runId) : void 0;
|
|
13466
|
-
if (run25 === void 0 || !
|
|
13697
|
+
if (run25 === void 0 || !existsSync56(path))
|
|
13467
13698
|
return {
|
|
13468
13699
|
ok: false,
|
|
13469
|
-
reason: `no mutation run ${runId} in ${
|
|
13700
|
+
reason: `no mutation run ${runId} in ${join62(store, MUTATION_RUNS_FOLDER)}`
|
|
13470
13701
|
};
|
|
13471
13702
|
if (run25.state === "running")
|
|
13472
13703
|
return {
|
|
@@ -13550,8 +13781,8 @@ function dropVerb(params) {
|
|
|
13550
13781
|
}
|
|
13551
13782
|
|
|
13552
13783
|
// src/lib/mutation/judge-packet.ts
|
|
13553
|
-
import { existsSync as
|
|
13554
|
-
import { join as
|
|
13784
|
+
import { existsSync as existsSync57, readFileSync as readFileSync39 } from "fs";
|
|
13785
|
+
import { join as join63 } from "path";
|
|
13555
13786
|
|
|
13556
13787
|
// node_modules/@babel/parser/lib/index.js
|
|
13557
13788
|
var Position = class {
|
|
@@ -27978,10 +28209,10 @@ function judgePackets(params) {
|
|
|
27978
28209
|
const byFile = /* @__PURE__ */ new Map();
|
|
27979
28210
|
for (const item of pending) byFile.set(item.file, [...byFile.get(item.file) ?? [], item]);
|
|
27980
28211
|
return [...byFile.keys()].sort().map((each) => {
|
|
27981
|
-
const path =
|
|
28212
|
+
const path = join63(root, each);
|
|
27982
28213
|
return packetOf({
|
|
27983
28214
|
file: each,
|
|
27984
|
-
source:
|
|
28215
|
+
source: existsSync57(path) ? readFileSync39(path, "utf8") : void 0,
|
|
27985
28216
|
survivors: (byFile.get(each) ?? []).map(
|
|
27986
28217
|
(item) => inputOf({ item, survivor: reported.get(item.key) })
|
|
27987
28218
|
)
|
|
@@ -28147,7 +28378,7 @@ function judgeVerb(params) {
|
|
|
28147
28378
|
|
|
28148
28379
|
// src/lib/mutation/records-write.ts
|
|
28149
28380
|
import { mkdirSync as mkdirSync17 } from "fs";
|
|
28150
|
-
import { dirname as dirname28, join as
|
|
28381
|
+
import { dirname as dirname28, join as join64 } from "path";
|
|
28151
28382
|
function recordKeys(params) {
|
|
28152
28383
|
const { root, keys, family, removable, afterRecordsWritten } = params;
|
|
28153
28384
|
const reason = params.reason.trim();
|
|
@@ -28211,7 +28442,7 @@ function writeRecords(params) {
|
|
|
28211
28442
|
);
|
|
28212
28443
|
for (const item of items)
|
|
28213
28444
|
(next[item.file] ??= {})[item.key] = recordOf({ item, family, reason, removable });
|
|
28214
|
-
const path =
|
|
28445
|
+
const path = join64(root, MUTATION_RECORDS_PATH);
|
|
28215
28446
|
mkdirSync17(dirname28(path), { recursive: true });
|
|
28216
28447
|
writeAtomically({ path, text: `${JSON.stringify(sortedRecords(next), null, " ")}
|
|
28217
28448
|
` });
|
|
@@ -28384,7 +28615,7 @@ async function runMutants(params) {
|
|
|
28384
28615
|
}
|
|
28385
28616
|
}
|
|
28386
28617
|
function ignorerPluginPath(params) {
|
|
28387
|
-
return
|
|
28618
|
+
return join65(params.distFolder, IGNORER_PLUGIN_FILE);
|
|
28388
28619
|
}
|
|
28389
28620
|
async function runVerb(params) {
|
|
28390
28621
|
const { root, runStryker, startTimeOf } = params;
|
|
@@ -28401,7 +28632,7 @@ async function runVerb(params) {
|
|
|
28401
28632
|
if (declared.kind === "none")
|
|
28402
28633
|
return {
|
|
28403
28634
|
exitCode: 1,
|
|
28404
|
-
output: `mutants run: ${
|
|
28635
|
+
output: `mutants run: ${join65(root, "package.json")} declares no dialecte.mutation: declare its scope and fast tier first`
|
|
28405
28636
|
};
|
|
28406
28637
|
if (declared.kind === "invalid") return { exitCode: 1, output: `mutants run: ${declared.reason}` };
|
|
28407
28638
|
const { declaration } = declared;
|
|
@@ -28453,8 +28684,8 @@ async function runVerb(params) {
|
|
|
28453
28684
|
startTimeOf
|
|
28454
28685
|
});
|
|
28455
28686
|
const workDir = `${MUTANTS_WORK_FOLDER}/${entry.runId}`;
|
|
28456
|
-
mkdirSync18(
|
|
28457
|
-
writeFileSync24(
|
|
28687
|
+
mkdirSync18(join65(root, workDir), { recursive: true });
|
|
28688
|
+
writeFileSync24(join65(root, workDir, EMPTY_STRYKER_CONFIG_FILE), "{}\n");
|
|
28458
28689
|
const records = readRecordsFile({ root });
|
|
28459
28690
|
const tiers = await runTiers({
|
|
28460
28691
|
root,
|
|
@@ -28479,7 +28710,7 @@ run ${entry.runId} stays running until this process ends, then reads as died: re
|
|
|
28479
28710
|
...mutantKeysOf({ report: tiers.report })
|
|
28480
28711
|
});
|
|
28481
28712
|
updateLedger({ root, run: finished, records, targets });
|
|
28482
|
-
rmSync21(
|
|
28713
|
+
rmSync21(join65(root, workDir), { recursive: true, force: true });
|
|
28483
28714
|
return { exitCode: 0, output: renderRun({ root, run: finished }) };
|
|
28484
28715
|
}
|
|
28485
28716
|
async function runTiers(params) {
|
|
@@ -28553,9 +28784,9 @@ async function runTier(params) {
|
|
|
28553
28784
|
}
|
|
28554
28785
|
if (exitCode !== 0) return { failure: `Stryker exited ${exitCode} in the ${tier} tier` };
|
|
28555
28786
|
const reportPath = resolve19(root, options.jsonReporter.fileName);
|
|
28556
|
-
if (!
|
|
28787
|
+
if (!existsSync58(reportPath))
|
|
28557
28788
|
return { failure: `Stryker wrote no report in the ${tier} tier (${reportPath})` };
|
|
28558
|
-
return { report: JSON.parse(
|
|
28789
|
+
return { report: JSON.parse(readFileSync40(reportPath, "utf8")) };
|
|
28559
28790
|
}
|
|
28560
28791
|
function runModeOf(params) {
|
|
28561
28792
|
const { asked, setting, touchesScope } = params;
|
|
@@ -28742,16 +28973,16 @@ function migrateVerb(params) {
|
|
|
28742
28973
|
const read = readArguments({ argv: params.argv, valueOptions: [], flags: ["json"] });
|
|
28743
28974
|
if (typeof read === "string" || read.words.length > 0)
|
|
28744
28975
|
return usageResult({ verb: "migrate", json, read });
|
|
28745
|
-
const legacyPath =
|
|
28746
|
-
if (!
|
|
28976
|
+
const legacyPath = join65(root, LEGACY_RECORDS_PATH);
|
|
28977
|
+
if (!existsSync58(legacyPath))
|
|
28747
28978
|
return refused2({ verb: "migrate", json, reason: `no ${LEGACY_RECORDS_PATH} in ${root}` });
|
|
28748
|
-
if (
|
|
28979
|
+
if (existsSync58(join65(root, MUTATION_RECORDS_PATH)))
|
|
28749
28980
|
return refused2({
|
|
28750
28981
|
verb: "migrate",
|
|
28751
28982
|
json,
|
|
28752
28983
|
reason: `${MUTATION_RECORDS_PATH} already exists in ${root}: nothing overwritten`
|
|
28753
28984
|
});
|
|
28754
|
-
const legacy = JSON.parse(
|
|
28985
|
+
const legacy = JSON.parse(readFileSync40(legacyPath, "utf8"));
|
|
28755
28986
|
const records = migrateRecords({ legacy, readLine: (line) => readLineOf({ root, ...line }) });
|
|
28756
28987
|
writeRecordsFile({ root, records });
|
|
28757
28988
|
const count = Object.values(records).reduce(
|
|
@@ -28766,9 +28997,9 @@ function migrateVerb(params) {
|
|
|
28766
28997
|
});
|
|
28767
28998
|
}
|
|
28768
28999
|
function readLineOf(params) {
|
|
28769
|
-
const path =
|
|
28770
|
-
if (!
|
|
28771
|
-
return
|
|
29000
|
+
const path = join65(params.root, params.file);
|
|
29001
|
+
if (!existsSync58(path)) return "";
|
|
29002
|
+
return readFileSync40(path, "utf8").split("\n")[params.line - 1] ?? "";
|
|
28772
29003
|
}
|
|
28773
29004
|
function usage2(read) {
|
|
28774
29005
|
return usageResult({ read });
|
|
@@ -28778,10 +29009,10 @@ function newDate() {
|
|
|
28778
29009
|
}
|
|
28779
29010
|
function cliDistFolder() {
|
|
28780
29011
|
const start = dirname29(fileURLToPath3(import.meta.url));
|
|
28781
|
-
return
|
|
29012
|
+
return join65(packageRootOf(start) ?? start, CLI_DIST_FOLDER);
|
|
28782
29013
|
}
|
|
28783
29014
|
async function runStrykerOfPackage(params) {
|
|
28784
|
-
const requireFromPackage = createRequire5(
|
|
29015
|
+
const requireFromPackage = createRequire5(join65(process.cwd(), "package.json"));
|
|
28785
29016
|
const entry = requireFromPackage.resolve("@stryker-mutator/core");
|
|
28786
29017
|
const strykerModule = await import(pathToFileURL4(entry).href);
|
|
28787
29018
|
const stryker = new strykerModule.Stryker(params.options);
|
|
@@ -28790,9 +29021,9 @@ async function runStrykerOfPackage(params) {
|
|
|
28790
29021
|
}
|
|
28791
29022
|
|
|
28792
29023
|
// src/commands/narrowing.ts
|
|
28793
|
-
import { spawnSync as
|
|
28794
|
-
import { writeFileSync as writeFileSync25, mkdirSync as mkdirSync19, rmSync as rmSync22, existsSync as
|
|
28795
|
-
import { join as
|
|
29024
|
+
import { spawnSync as spawnSync17 } from "child_process";
|
|
29025
|
+
import { writeFileSync as writeFileSync25, mkdirSync as mkdirSync19, rmSync as rmSync22, existsSync as existsSync59 } from "fs";
|
|
29026
|
+
import { join as join66, resolve as resolve20 } from "path";
|
|
28796
29027
|
async function run13(argv) {
|
|
28797
29028
|
const ROOT = process.cwd();
|
|
28798
29029
|
const tsc = resolveBin("tsc", "typescript", ROOT);
|
|
@@ -28808,12 +29039,12 @@ async function run13(argv) {
|
|
|
28808
29039
|
const schema = await loadSchema(resolve20(ROOT, target.constantsDir));
|
|
28809
29040
|
mkdirSync19(resolve20(ROOT, target.outDir), { recursive: true });
|
|
28810
29041
|
const relFile = `${target.outDir}/narrowing.generated.test-d.ts`;
|
|
28811
|
-
writeFileSync25(
|
|
29042
|
+
writeFileSync25(join66(ROOT, relFile), genNarrowing({ schema, binding: target.binding }));
|
|
28812
29043
|
const apiFile = `${target.outDir}/coverage.api.generated.ts`;
|
|
28813
|
-
const include =
|
|
29044
|
+
const include = existsSync59(join66(ROOT, apiFile)) ? [relFile, apiFile] : [relFile];
|
|
28814
29045
|
const tmp = `.narrow-${target.version}.tsconfig.json`;
|
|
28815
29046
|
writeFileSync25(
|
|
28816
|
-
|
|
29047
|
+
join66(ROOT, tmp),
|
|
28817
29048
|
JSON.stringify({
|
|
28818
29049
|
extends: `./${tsconfig}`,
|
|
28819
29050
|
compilerOptions: {
|
|
@@ -28827,12 +29058,12 @@ async function run13(argv) {
|
|
|
28827
29058
|
include
|
|
28828
29059
|
})
|
|
28829
29060
|
);
|
|
28830
|
-
const res =
|
|
29061
|
+
const res = spawnSync17(tsc.path, ["-p", tmp, "--noEmit"], {
|
|
28831
29062
|
cwd: ROOT,
|
|
28832
29063
|
encoding: "utf8",
|
|
28833
29064
|
maxBuffer: 1e8
|
|
28834
29065
|
});
|
|
28835
|
-
rmSync22(
|
|
29066
|
+
rmSync22(join66(ROOT, tmp), { force: true });
|
|
28836
29067
|
if (res.status === 0) {
|
|
28837
29068
|
console.log(
|
|
28838
29069
|
`\u2705 [${target.version}] narrowing holds \u2014 ${schema.elements.length} elements asserted`
|
|
@@ -28849,7 +29080,7 @@ ${res.stdout || ""}${res.stderr || ""}`
|
|
|
28849
29080
|
}
|
|
28850
29081
|
|
|
28851
29082
|
// src/commands/new-verb.ts
|
|
28852
|
-
import { join as
|
|
29083
|
+
import { join as join68 } from "path";
|
|
28853
29084
|
|
|
28854
29085
|
// src/lib/scaffold/new-verb.constants.ts
|
|
28855
29086
|
var VERB_KINDS = ["query", "transaction"];
|
|
@@ -28867,8 +29098,8 @@ var KIND_SHAPES = {
|
|
|
28867
29098
|
var OPTIONS_WITH_VALUE = ["--version", "--format-config"];
|
|
28868
29099
|
|
|
28869
29100
|
// src/lib/scaffold/new-verb.ts
|
|
28870
|
-
import { existsSync as
|
|
28871
|
-
import { dirname as dirname30, join as
|
|
29101
|
+
import { existsSync as existsSync60, mkdirSync as mkdirSync20, readFileSync as readFileSync41, writeFileSync as writeFileSync26 } from "fs";
|
|
29102
|
+
import { dirname as dirname30, join as join67 } from "path";
|
|
28872
29103
|
|
|
28873
29104
|
// src/lib/scaffold/edit-module.ts
|
|
28874
29105
|
import ts7 from "typescript";
|
|
@@ -29016,20 +29247,20 @@ function scaffoldVerb(params) {
|
|
|
29016
29247
|
[`${kindFolder}/${file}.types.ts`]: renderTypesFile(names),
|
|
29017
29248
|
[`${kindFolder}/${file}.test.ts`]: renderTestFile(names)
|
|
29018
29249
|
};
|
|
29019
|
-
const existing = Object.keys(newFiles).filter((path) =>
|
|
29250
|
+
const existing = Object.keys(newFiles).filter((path) => existsSync60(join67(root, path)));
|
|
29020
29251
|
if (existing.length) return `already there: ${existing.join(", ")}`;
|
|
29021
29252
|
const edits = {};
|
|
29022
29253
|
const barrel = `${kindFolder}/index.ts`;
|
|
29023
29254
|
const exportLine = `export { ${name} } from './${file}'
|
|
29024
29255
|
`;
|
|
29025
|
-
if (
|
|
29256
|
+
if (existsSync60(join67(root, barrel)))
|
|
29026
29257
|
edits[barrel] = withLine({ text: readText({ root, path: barrel }), line: exportLine });
|
|
29027
29258
|
else newFiles[barrel] = exportLine;
|
|
29028
29259
|
const group = `${namespace}${KIND_SHAPES[kind].group}`;
|
|
29029
29260
|
const groupImport = `import * as ${group} from './${kind}'`;
|
|
29030
29261
|
const groupProperty = `${KIND_SHAPES[kind].moduleKey}: ${group}`;
|
|
29031
29262
|
const namespaceModule = `${namespaceFolder}/index.ts`;
|
|
29032
|
-
if (!
|
|
29263
|
+
if (!existsSync60(join67(root, namespaceModule))) {
|
|
29033
29264
|
newFiles[namespaceModule] = `${groupImport}
|
|
29034
29265
|
|
|
29035
29266
|
export const ${namespace} = {
|
|
@@ -29037,7 +29268,7 @@ export const ${namespace} = {
|
|
|
29037
29268
|
}
|
|
29038
29269
|
`;
|
|
29039
29270
|
const registry = `${extensionsFolder}/index.ts`;
|
|
29040
|
-
if (!
|
|
29271
|
+
if (!existsSync60(join67(root, registry))) return `no extension registry at ${registry}`;
|
|
29041
29272
|
const registered = addObjectProperty({
|
|
29042
29273
|
source: addImportLine({
|
|
29043
29274
|
source: readText({ root, path: registry }),
|
|
@@ -29048,7 +29279,7 @@ export const ${namespace} = {
|
|
|
29048
29279
|
});
|
|
29049
29280
|
if (registered === void 0) return `no *_EXTENSION_MODULES object in ${registry}`;
|
|
29050
29281
|
edits[registry] = registered;
|
|
29051
|
-
} else if (!
|
|
29282
|
+
} else if (!existsSync60(join67(root, barrel))) {
|
|
29052
29283
|
const extended = addObjectProperty({
|
|
29053
29284
|
source: addImportLine({
|
|
29054
29285
|
source: readText({ root, path: namespaceModule }),
|
|
@@ -29062,8 +29293,8 @@ export const ${namespace} = {
|
|
|
29062
29293
|
edits[namespaceModule] = extended;
|
|
29063
29294
|
}
|
|
29064
29295
|
for (const [path, text] of Object.entries({ ...newFiles, ...edits })) {
|
|
29065
|
-
mkdirSync20(dirname30(
|
|
29066
|
-
writeFileSync26(
|
|
29296
|
+
mkdirSync20(dirname30(join67(root, path)), { recursive: true });
|
|
29297
|
+
writeFileSync26(join67(root, path), text);
|
|
29067
29298
|
}
|
|
29068
29299
|
return {
|
|
29069
29300
|
written: Object.keys(newFiles).sort(),
|
|
@@ -29083,12 +29314,12 @@ function withLine(params) {
|
|
|
29083
29314
|
${line}`;
|
|
29084
29315
|
}
|
|
29085
29316
|
function readRootElement(params) {
|
|
29086
|
-
const path =
|
|
29087
|
-
if (!
|
|
29088
|
-
return ROOT_ELEMENT_PATTERN.exec(
|
|
29317
|
+
const path = join67(params.root, "src", params.version, "definition", "constants.generated.ts");
|
|
29318
|
+
if (!existsSync60(path)) return "FILL_ROOT_ELEMENT";
|
|
29319
|
+
return ROOT_ELEMENT_PATTERN.exec(readFileSync41(path, "utf8"))?.[1] ?? "FILL_ROOT_ELEMENT";
|
|
29089
29320
|
}
|
|
29090
29321
|
function readText(params) {
|
|
29091
|
-
return
|
|
29322
|
+
return readFileSync41(join67(params.root, params.path), "utf8");
|
|
29092
29323
|
}
|
|
29093
29324
|
function kebabCase(name) {
|
|
29094
29325
|
return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -29129,7 +29360,7 @@ function runNewVerb(params) {
|
|
|
29129
29360
|
return { exitCode: 1, output: `new verb: ${result}, nothing written` };
|
|
29130
29361
|
const formatted = formatFiles({
|
|
29131
29362
|
root: cwd,
|
|
29132
|
-
files: [...result.written, ...result.edited].map((path) =>
|
|
29363
|
+
files: [...result.written, ...result.edited].map((path) => join68(cwd, path)),
|
|
29133
29364
|
options: formatOptsFromArgv(argv)
|
|
29134
29365
|
});
|
|
29135
29366
|
if (!formatted)
|
|
@@ -29158,13 +29389,13 @@ function usage3(message) {
|
|
|
29158
29389
|
import { resolve as resolve21 } from "path";
|
|
29159
29390
|
|
|
29160
29391
|
// src/lib/recap/read-recap-records.ts
|
|
29161
|
-
import { existsSync as
|
|
29162
|
-
import { basename as basename8, dirname as dirname31, join as
|
|
29392
|
+
import { existsSync as existsSync63, realpathSync as realpathSync9 } from "fs";
|
|
29393
|
+
import { basename as basename8, dirname as dirname31, join as join69 } from "path";
|
|
29163
29394
|
|
|
29164
29395
|
// src/lib/review-rounds/decisions-file.ts
|
|
29165
|
-
import { existsSync as
|
|
29396
|
+
import { existsSync as existsSync61, readFileSync as readFileSync42 } from "fs";
|
|
29166
29397
|
function appendDecision(params) {
|
|
29167
|
-
const lines = (
|
|
29398
|
+
const lines = (existsSync61(params.path) ? readFileSync42(params.path, "utf8") : "").split("\n");
|
|
29168
29399
|
appendTableRow({
|
|
29169
29400
|
path: params.path,
|
|
29170
29401
|
lines,
|
|
@@ -29175,8 +29406,8 @@ function appendDecision(params) {
|
|
|
29175
29406
|
});
|
|
29176
29407
|
}
|
|
29177
29408
|
function readDecisions(path) {
|
|
29178
|
-
if (!
|
|
29179
|
-
const lines =
|
|
29409
|
+
if (!existsSync61(path)) return [];
|
|
29410
|
+
const lines = readFileSync42(path, "utf8").split("\n");
|
|
29180
29411
|
const table = findTable({ lines, firstCell: DECISIONS_FIRST_CELL });
|
|
29181
29412
|
return (table?.rowLines ?? []).map(function decisionOf(line) {
|
|
29182
29413
|
const [decision = "", by = "", when = ""] = (tableCells(lines[line]) ?? []).map(unescapeCell);
|
|
@@ -29190,7 +29421,7 @@ function dayOf(date) {
|
|
|
29190
29421
|
}
|
|
29191
29422
|
|
|
29192
29423
|
// src/lib/recap/read-findings.ts
|
|
29193
|
-
import { existsSync as
|
|
29424
|
+
import { existsSync as existsSync62, readFileSync as readFileSync43 } from "fs";
|
|
29194
29425
|
import { relative as relative8 } from "path";
|
|
29195
29426
|
|
|
29196
29427
|
// src/lib/recap/recap.constants.ts
|
|
@@ -29280,8 +29511,8 @@ var RECAP_SCHEDULED_ITEM = "- `{file}:{line}` {mutation}: scheduled for {followU
|
|
|
29280
29511
|
|
|
29281
29512
|
// src/lib/recap/read-findings.ts
|
|
29282
29513
|
function readFindings(params) {
|
|
29283
|
-
if (!
|
|
29284
|
-
const lines =
|
|
29514
|
+
if (!existsSync62(params.path)) return void 0;
|
|
29515
|
+
const lines = readFileSync43(params.path, "utf8").split("\n");
|
|
29285
29516
|
const table = findTable({ lines, firstCell: "id" });
|
|
29286
29517
|
if (!table) return [];
|
|
29287
29518
|
const headerLine = table.lastLine - table.rowLines.length - 1;
|
|
@@ -29290,9 +29521,9 @@ function readFindings(params) {
|
|
|
29290
29521
|
for (const line of lines.slice(headerLine + 2)) {
|
|
29291
29522
|
const cells = tableCells(line)?.map(unescapeCell);
|
|
29292
29523
|
if (!cells || cells.length !== cellCount) continue;
|
|
29293
|
-
const
|
|
29294
|
-
if (typeof
|
|
29295
|
-
findings.push(
|
|
29524
|
+
const finding2 = readFinding({ cells, bases: params.bases });
|
|
29525
|
+
if (typeof finding2 === "string") return finding2;
|
|
29526
|
+
findings.push(finding2);
|
|
29296
29527
|
}
|
|
29297
29528
|
return findings;
|
|
29298
29529
|
}
|
|
@@ -29399,20 +29630,20 @@ function readRecapRecords(params) {
|
|
|
29399
29630
|
const { handover } = params;
|
|
29400
29631
|
const { folder, lotsFile } = handover;
|
|
29401
29632
|
const root = lotsFile.repository;
|
|
29402
|
-
const repositoryExists =
|
|
29633
|
+
const repositoryExists = existsSync63(root);
|
|
29403
29634
|
const user = readGitConfig({ root: repositoryExists ? root : params.cwd, key: "user.name" });
|
|
29404
29635
|
if (!user)
|
|
29405
29636
|
return NO_USER_NAME.replace(
|
|
29406
29637
|
"{where}",
|
|
29407
29638
|
repositoryExists ? "the repository" : "the current folder"
|
|
29408
29639
|
);
|
|
29409
|
-
const declarationPath =
|
|
29640
|
+
const declarationPath = existsSync63(join69(folder, FOLDER_LOT_FILE)) ? join69(folder, FOLDER_LOT_FILE) : join69(root, LOT_FILE);
|
|
29410
29641
|
const accepted = readCases({ path: declarationPath, list: "accept" });
|
|
29411
29642
|
if (typeof accepted === "string") return accepted;
|
|
29412
29643
|
const revised = readCases({ path: declarationPath, list: "revised" });
|
|
29413
29644
|
if (typeof revised === "string") return revised;
|
|
29414
29645
|
const findings = readFindings({
|
|
29415
|
-
path:
|
|
29646
|
+
path: join69(folder, LEDGER_FILE),
|
|
29416
29647
|
bases: pathBasesOf({ root, repositoryExists })
|
|
29417
29648
|
});
|
|
29418
29649
|
if (typeof findings === "string") return findings;
|
|
@@ -29439,7 +29670,7 @@ function readRecapRecords(params) {
|
|
|
29439
29670
|
findings,
|
|
29440
29671
|
accepted,
|
|
29441
29672
|
revised,
|
|
29442
|
-
decisions: readDecisions(
|
|
29673
|
+
decisions: readDecisions(join69(folder, DECISIONS_FILE)),
|
|
29443
29674
|
user
|
|
29444
29675
|
};
|
|
29445
29676
|
}
|
|
@@ -29469,7 +29700,7 @@ function pathBasesOf(params) {
|
|
|
29469
29700
|
};
|
|
29470
29701
|
}
|
|
29471
29702
|
function spellingsOf(folder) {
|
|
29472
|
-
const real =
|
|
29703
|
+
const real = existsSync63(folder) ? realpathSync9(folder) : folder;
|
|
29473
29704
|
return real === folder ? [folder] : [folder, real];
|
|
29474
29705
|
}
|
|
29475
29706
|
function readChecks(params) {
|
|
@@ -29577,24 +29808,24 @@ function itemText(params) {
|
|
|
29577
29808
|
function reviewLines(records) {
|
|
29578
29809
|
const findings = records.findings ?? [];
|
|
29579
29810
|
if (findings.length === 0) return [EMPTY_SECTION.review];
|
|
29580
|
-
const rounds = [...new Set(findings.map((
|
|
29811
|
+
const rounds = [...new Set(findings.map((finding2) => finding2.round))].sort(
|
|
29581
29812
|
(first, second) => first - second
|
|
29582
29813
|
);
|
|
29583
29814
|
const outcomes = FINDING_OUTCOMES.flatMap(function outcomeCount(outcome) {
|
|
29584
|
-
const count = findings.filter((
|
|
29815
|
+
const count = findings.filter((finding2) => finding2.outcome === outcome).length;
|
|
29585
29816
|
return count ? [`${count} ${outcome}`] : [];
|
|
29586
29817
|
});
|
|
29587
29818
|
const highest = rounds.at(-1) ?? 0;
|
|
29588
29819
|
return [
|
|
29589
29820
|
`${counted({ count: highest, noun: "round" })}, ${counted({ count: findings.length, noun: "finding" })}: ${outcomes.join(", ")}.`,
|
|
29590
29821
|
...rounds.flatMap(
|
|
29591
|
-
(round) => roundLines({ round, findings: findings.filter((
|
|
29822
|
+
(round) => roundLines({ round, findings: findings.filter((finding2) => finding2.round === round) })
|
|
29592
29823
|
)
|
|
29593
29824
|
];
|
|
29594
29825
|
}
|
|
29595
29826
|
function roundLines(params) {
|
|
29596
29827
|
const severities = ROUND_SEVERITIES.flatMap(function severityCount(entry) {
|
|
29597
|
-
const count = params.findings.filter((
|
|
29828
|
+
const count = params.findings.filter((finding2) => finding2.severity === entry.severity).length;
|
|
29598
29829
|
if (!count) return [];
|
|
29599
29830
|
return [entry.plural ? counted({ count, noun: entry.severity }) : `${count} ${entry.severity}`];
|
|
29600
29831
|
});
|
|
@@ -29602,7 +29833,7 @@ function roundLines(params) {
|
|
|
29602
29833
|
return [
|
|
29603
29834
|
`- Round ${params.round}: ${counted({ count: params.findings.length, noun: "finding" })}${severitiesText}`,
|
|
29604
29835
|
...params.findings.map(
|
|
29605
|
-
(
|
|
29836
|
+
(finding2) => ` - ${finding2.outcome} ${finding2.id}: ${[finding2.severity, atText(finding2.at), finding2.finding].filter(Boolean).join(" ")}`
|
|
29606
29837
|
)
|
|
29607
29838
|
];
|
|
29608
29839
|
}
|
|
@@ -29612,8 +29843,8 @@ function atText(at) {
|
|
|
29612
29843
|
function decisionLines(records) {
|
|
29613
29844
|
const by = `(by ${ASSISTANT})`;
|
|
29614
29845
|
const lines = [
|
|
29615
|
-
...(records.findings ?? []).filter((
|
|
29616
|
-
(
|
|
29846
|
+
...(records.findings ?? []).filter((finding2) => finding2.outcome === "accepted").map(
|
|
29847
|
+
(finding2) => `- ${DECISION_PREFIXES.kept} ${finding2.id} ${finding2.finding} - ${finding2.reason ?? ""} ${by}`
|
|
29617
29848
|
),
|
|
29618
29849
|
...records.accepted.map(
|
|
29619
29850
|
(entry) => `- ${DECISION_PREFIXES.accepted} ${entry.case} - ${entry.reason} ${by}`
|
|
@@ -29626,8 +29857,8 @@ function decisionLines(records) {
|
|
|
29626
29857
|
return lines.length ? lines : [EMPTY_SECTION.decisions];
|
|
29627
29858
|
}
|
|
29628
29859
|
function followUpLines(records) {
|
|
29629
|
-
const lines = (records.findings ?? []).filter((
|
|
29630
|
-
(
|
|
29860
|
+
const lines = (records.findings ?? []).filter((finding2) => finding2.outcome === "logged").map(
|
|
29861
|
+
(finding2) => `- ${finding2.id}: ${finding2.finding}${finding2.at ? ` (${atText(finding2.at)})` : ""}`
|
|
29631
29862
|
);
|
|
29632
29863
|
return lines.length ? lines : [EMPTY_SECTION.followUps];
|
|
29633
29864
|
}
|
|
@@ -29654,24 +29885,24 @@ function runRecap(params) {
|
|
|
29654
29885
|
}
|
|
29655
29886
|
|
|
29656
29887
|
// src/commands/record.ts
|
|
29657
|
-
import { existsSync as
|
|
29658
|
-
import { basename as basename9, join as
|
|
29888
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync22, readFileSync as readFileSync44, writeFileSync as writeFileSync28 } from "fs";
|
|
29889
|
+
import { basename as basename9, join as join71, resolve as resolve22 } from "path";
|
|
29659
29890
|
|
|
29660
29891
|
// src/lib/review-rounds/snapshot-round.ts
|
|
29661
29892
|
import {
|
|
29662
29893
|
chmodSync as chmodSync2,
|
|
29663
29894
|
copyFileSync as copyFileSync4,
|
|
29664
|
-
existsSync as
|
|
29665
|
-
lstatSync as
|
|
29895
|
+
existsSync as existsSync64,
|
|
29896
|
+
lstatSync as lstatSync11,
|
|
29666
29897
|
mkdirSync as mkdirSync21,
|
|
29667
29898
|
readdirSync as readdirSync16,
|
|
29668
|
-
readlinkSync as
|
|
29899
|
+
readlinkSync as readlinkSync6,
|
|
29669
29900
|
renameSync as renameSync4,
|
|
29670
29901
|
rmSync as rmSync23,
|
|
29671
|
-
symlinkSync as
|
|
29902
|
+
symlinkSync as symlinkSync6,
|
|
29672
29903
|
writeFileSync as writeFileSync27
|
|
29673
29904
|
} from "fs";
|
|
29674
|
-
import { dirname as dirname32, join as
|
|
29905
|
+
import { dirname as dirname32, join as join70 } from "path";
|
|
29675
29906
|
function roundNames(round) {
|
|
29676
29907
|
return {
|
|
29677
29908
|
folder: `round-${round}`,
|
|
@@ -29681,9 +29912,9 @@ function roundNames(round) {
|
|
|
29681
29912
|
}
|
|
29682
29913
|
function copyFileOrLink(params) {
|
|
29683
29914
|
mkdirSync21(dirname32(params.to), { recursive: true });
|
|
29684
|
-
const stats =
|
|
29915
|
+
const stats = lstatSync11(params.from);
|
|
29685
29916
|
if (isFileOrLink(params.to)) rmSync23(params.to);
|
|
29686
|
-
if (stats.isSymbolicLink())
|
|
29917
|
+
if (stats.isSymbolicLink()) symlinkSync6(readlinkSync6(params.from), params.to);
|
|
29687
29918
|
else {
|
|
29688
29919
|
copyFileSync4(params.from, params.to);
|
|
29689
29920
|
chmodSync2(params.to, stats.mode & 4095);
|
|
@@ -29692,10 +29923,10 @@ function copyFileOrLink(params) {
|
|
|
29692
29923
|
function snapshotRefusal(params) {
|
|
29693
29924
|
const names = roundNames(params.round);
|
|
29694
29925
|
const existing = [names.folder, names.deleted, names.base].find(
|
|
29695
|
-
(name) =>
|
|
29926
|
+
(name) => existsSync64(join70(params.folder, name))
|
|
29696
29927
|
);
|
|
29697
29928
|
if (existing)
|
|
29698
|
-
return `${
|
|
29929
|
+
return `${join70(params.folder, existing)} exists already: round ${params.round} was taken`;
|
|
29699
29930
|
return worktreeStateRefusal({ root: params.root, state: params.state });
|
|
29700
29931
|
}
|
|
29701
29932
|
function takeSnapshot(params) {
|
|
@@ -29706,19 +29937,19 @@ function takeSnapshot(params) {
|
|
|
29706
29937
|
const base = readGit({ root, args: ["rev-parse", "HEAD"] }).trim();
|
|
29707
29938
|
const copied = [];
|
|
29708
29939
|
const deleted = [];
|
|
29709
|
-
const partial =
|
|
29940
|
+
const partial = join70(folder, `${names.folder}${PARTIAL_SUFFIX}`);
|
|
29710
29941
|
mkdirSync21(partial);
|
|
29711
29942
|
for (const path of params.state.status.paths) {
|
|
29712
|
-
if (isFileOrLink(
|
|
29713
|
-
copyFileOrLink({ from:
|
|
29943
|
+
if (isFileOrLink(join70(root, path))) {
|
|
29944
|
+
copyFileOrLink({ from: join70(root, path), to: join70(partial, path) });
|
|
29714
29945
|
copied.push(path);
|
|
29715
29946
|
} else if (params.state.head.files.has(path)) deleted.push(path);
|
|
29716
29947
|
}
|
|
29717
29948
|
writeFileSync27(
|
|
29718
|
-
|
|
29949
|
+
join70(folder, `${names.deleted}${PARTIAL_SUFFIX}`),
|
|
29719
29950
|
deleted.sort().map((path) => `${path}\0`).join("")
|
|
29720
29951
|
);
|
|
29721
|
-
writeFileSync27(
|
|
29952
|
+
writeFileSync27(join70(folder, `${names.base}${PARTIAL_SUFFIX}`), `${base}
|
|
29722
29953
|
`);
|
|
29723
29954
|
renameAll({ folder, names: [names.deleted, names.base, names.folder] });
|
|
29724
29955
|
return { copied: copied.length, deleted: deleted.length, base };
|
|
@@ -29727,18 +29958,18 @@ function removeLeftovers(params) {
|
|
|
29727
29958
|
const names = Object.values(roundNames(params.round));
|
|
29728
29959
|
for (const entry of readdirSync16(params.folder))
|
|
29729
29960
|
if (names.some((name) => entry.startsWith(`${name}${PARTIAL_SUFFIX}`)))
|
|
29730
|
-
rmSync23(
|
|
29961
|
+
rmSync23(join70(params.folder, entry), { recursive: true, force: true });
|
|
29731
29962
|
}
|
|
29732
29963
|
function renameAll(params) {
|
|
29733
29964
|
const renamed = [];
|
|
29734
29965
|
try {
|
|
29735
29966
|
for (const name of params.names) {
|
|
29736
|
-
renameSync4(
|
|
29967
|
+
renameSync4(join70(params.folder, `${name}${PARTIAL_SUFFIX}`), join70(params.folder, name));
|
|
29737
29968
|
renamed.push(name);
|
|
29738
29969
|
}
|
|
29739
29970
|
} catch (error) {
|
|
29740
29971
|
for (const name of renamed)
|
|
29741
|
-
renameSync4(
|
|
29972
|
+
renameSync4(join70(params.folder, name), join70(params.folder, `${name}${PARTIAL_SUFFIX}`));
|
|
29742
29973
|
throw error;
|
|
29743
29974
|
}
|
|
29744
29975
|
}
|
|
@@ -29777,7 +30008,7 @@ function recordChoice(params) {
|
|
|
29777
30008
|
const refusal = handoverFolderRefusal(folder);
|
|
29778
30009
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29779
30010
|
mkdirSync22(folder, { recursive: true });
|
|
29780
|
-
const path =
|
|
30011
|
+
const path = join71(folder, DECISIONS_FILE);
|
|
29781
30012
|
appendDecision({
|
|
29782
30013
|
path,
|
|
29783
30014
|
title: basename9(folder),
|
|
@@ -29796,9 +30027,9 @@ function recordReview(params) {
|
|
|
29796
30027
|
const severityWord = values.get("severity") ?? "";
|
|
29797
30028
|
const severity = Object.hasOwn(SEVERITY_SPELLINGS, severityWord) ? SEVERITY_SPELLINGS[severityWord] : void 0;
|
|
29798
30029
|
const at = values.get("at") ?? "";
|
|
29799
|
-
const
|
|
30030
|
+
const finding2 = words[1] ?? "";
|
|
29800
30031
|
if (words.length !== 2 || round === void 0 || severity === void 0) return usage4;
|
|
29801
|
-
if (!
|
|
30032
|
+
if (!finding2 || !at || LINE_BREAK_PATTERN.test(finding2) || LINE_BREAK_PATTERN.test(at))
|
|
29802
30033
|
return {
|
|
29803
30034
|
exitCode: 2,
|
|
29804
30035
|
output: `${RECORD_REVIEW_USAGE} (the finding and --at are one non-empty line each)`
|
|
@@ -29807,8 +30038,8 @@ function recordReview(params) {
|
|
|
29807
30038
|
const refusal = handoverFolderRefusal(folder);
|
|
29808
30039
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29809
30040
|
mkdirSync22(folder, { recursive: true });
|
|
29810
|
-
const ledger =
|
|
29811
|
-
const id = appendFinding({ path: ledger, title: basename9(folder), round, severity, at, finding });
|
|
30041
|
+
const ledger = join71(folder, LEDGER_FILE);
|
|
30042
|
+
const id = appendFinding({ path: ledger, title: basename9(folder), round, severity, at, finding: finding2 });
|
|
29812
30043
|
return { exitCode: 0, output: `record: ${id} open - ${ledger}` };
|
|
29813
30044
|
}
|
|
29814
30045
|
function recordDecision(params) {
|
|
@@ -29822,13 +30053,13 @@ function recordDecision(params) {
|
|
|
29822
30053
|
const folder = resolve22(params.cwd, folderWord);
|
|
29823
30054
|
const refusal = handoverFolderRefusal(folder);
|
|
29824
30055
|
if (refusal) return { exitCode: 1, output: `record: ${refusal}` };
|
|
29825
|
-
const ledger =
|
|
29826
|
-
if (!
|
|
30056
|
+
const ledger = join71(folder, LEDGER_FILE);
|
|
30057
|
+
if (!existsSync65(ledger))
|
|
29827
30058
|
return {
|
|
29828
30059
|
exitCode: 1,
|
|
29829
30060
|
output: `record: no findings ledger ${ledger}: record review writes the first finding`
|
|
29830
30061
|
};
|
|
29831
|
-
const lines =
|
|
30062
|
+
const lines = readFileSync44(ledger, "utf8").split("\n");
|
|
29832
30063
|
const rows = findLedgerTable(lines)?.rows ?? [];
|
|
29833
30064
|
const row = rows.find((candidate) => candidate.id === id);
|
|
29834
30065
|
if (!row)
|
|
@@ -29874,35 +30105,35 @@ function recordSnapshot(params) {
|
|
|
29874
30105
|
import { resolve as resolve24 } from "path";
|
|
29875
30106
|
|
|
29876
30107
|
// src/lib/review-rounds/review-delta.ts
|
|
29877
|
-
import { spawnSync as
|
|
29878
|
-
import { existsSync as
|
|
29879
|
-
import { join as
|
|
30108
|
+
import { spawnSync as spawnSync19 } from "child_process";
|
|
30109
|
+
import { existsSync as existsSync69, readFileSync as readFileSync48, statSync as statSync10 } from "fs";
|
|
30110
|
+
import { join as join75 } from "path";
|
|
29880
30111
|
|
|
29881
30112
|
// src/lib/worktree/add-worktree.ts
|
|
29882
|
-
import { spawnSync as
|
|
29883
|
-
import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as
|
|
29884
|
-
import { basename as basename10, dirname as dirname33, isAbsolute as isAbsolute10, join as
|
|
30113
|
+
import { spawnSync as spawnSync18 } from "child_process";
|
|
30114
|
+
import { appendFileSync as appendFileSync2, cpSync as cpSync3, existsSync as existsSync68, mkdirSync as mkdirSync23, readFileSync as readFileSync47 } from "fs";
|
|
30115
|
+
import { basename as basename10, dirname as dirname33, isAbsolute as isAbsolute10, join as join74 } from "path";
|
|
29885
30116
|
|
|
29886
30117
|
// src/lib/worktree/check-node-modules.ts
|
|
29887
|
-
import { existsSync as
|
|
29888
|
-
import { join as
|
|
30118
|
+
import { existsSync as existsSync67, readFileSync as readFileSync46, realpathSync as realpathSync10 } from "fs";
|
|
30119
|
+
import { join as join73, resolve as resolve23 } from "path";
|
|
29889
30120
|
|
|
29890
30121
|
// src/lib/worktree/locked-packages.ts
|
|
29891
|
-
import { existsSync as
|
|
29892
|
-
import { join as
|
|
30122
|
+
import { existsSync as existsSync66, readFileSync as readFileSync45 } from "fs";
|
|
30123
|
+
import { join as join72 } from "path";
|
|
29893
30124
|
function readLockedPackages(params) {
|
|
29894
|
-
const path =
|
|
29895
|
-
if (!
|
|
30125
|
+
const path = join72(params.worktree, PACKAGE_LOCK_FILE);
|
|
30126
|
+
if (!existsSync66(path)) return { notChecked: "no lockfile" };
|
|
29896
30127
|
let lockfile;
|
|
29897
30128
|
try {
|
|
29898
|
-
lockfile = JSON.parse(
|
|
30129
|
+
lockfile = JSON.parse(readFileSync45(path, "utf8"));
|
|
29899
30130
|
} catch {
|
|
29900
30131
|
return { notChecked: "unreadable" };
|
|
29901
30132
|
}
|
|
29902
30133
|
if (typeof lockfile?.packages !== "object" || lockfile.packages === null)
|
|
29903
30134
|
return { notChecked: "has no packages map" };
|
|
29904
30135
|
return {
|
|
29905
|
-
packages: Object.entries(lockfile.packages).filter(([key, entry]) => key.startsWith(NODE_MODULES_PREFIX) && !entry.inBundle).filter(([key, entry]) => !mayBeLeftOut(entry) || isPresent(
|
|
30136
|
+
packages: Object.entries(lockfile.packages).filter(([key, entry]) => key.startsWith(NODE_MODULES_PREFIX) && !entry.inBundle).filter(([key, entry]) => !mayBeLeftOut(entry) || isPresent(join72(params.worktree, key))).map(([key, entry]) => ({ key, entry }))
|
|
29906
30137
|
};
|
|
29907
30138
|
}
|
|
29908
30139
|
function mayBeLeftOut(entry) {
|
|
@@ -29934,18 +30165,18 @@ function checkNodeModules(params) {
|
|
|
29934
30165
|
}
|
|
29935
30166
|
function problemOf(params) {
|
|
29936
30167
|
const { key, entry } = params.locked;
|
|
29937
|
-
const installed =
|
|
30168
|
+
const installed = join73(params.worktree, key);
|
|
29938
30169
|
if (entry.link) {
|
|
29939
30170
|
const resolved = entry.resolved ?? "";
|
|
29940
30171
|
const target = resolve23(params.worktree, resolved);
|
|
29941
|
-
if (!
|
|
30172
|
+
if (!existsSync67(installed) || !existsSync67(target)) return `link to ${resolved} missing`;
|
|
29942
30173
|
return realpathSync10(installed) === realpathSync10(target) ? void 0 : `link to ${resolved} points elsewhere`;
|
|
29943
30174
|
}
|
|
29944
|
-
const manifest =
|
|
29945
|
-
if (!
|
|
30175
|
+
const manifest = join73(installed, "package.json");
|
|
30176
|
+
if (!existsSync67(manifest)) return "missing";
|
|
29946
30177
|
let version;
|
|
29947
30178
|
try {
|
|
29948
|
-
version = JSON.parse(
|
|
30179
|
+
version = JSON.parse(readFileSync46(manifest, "utf8")).version;
|
|
29949
30180
|
} catch {
|
|
29950
30181
|
return "package.json unreadable";
|
|
29951
30182
|
}
|
|
@@ -29962,13 +30193,13 @@ function packageName2(key) {
|
|
|
29962
30193
|
function addWorktree(params) {
|
|
29963
30194
|
const { branch } = params;
|
|
29964
30195
|
const repository = mainCheckoutOf(params.repository);
|
|
29965
|
-
const worktree =
|
|
30196
|
+
const worktree = join74(
|
|
29966
30197
|
dirname33(repository),
|
|
29967
30198
|
WORKTREES_FOLDER,
|
|
29968
30199
|
`${basename10(repository)}-${branch.split("/").at(-1)}`
|
|
29969
30200
|
);
|
|
29970
|
-
if (
|
|
29971
|
-
const branchExists =
|
|
30201
|
+
if (existsSync68(worktree)) return `${worktree} exists already`;
|
|
30202
|
+
const branchExists = spawnSync18("git", ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
29972
30203
|
cwd: repository
|
|
29973
30204
|
}).status === 0;
|
|
29974
30205
|
if (branchExists && params.from)
|
|
@@ -29980,16 +30211,16 @@ function addWorktree(params) {
|
|
|
29980
30211
|
});
|
|
29981
30212
|
const hooks = readHooksFolder(repository);
|
|
29982
30213
|
let copiedHooks;
|
|
29983
|
-
if (hooks.configured && !isAbsolute10(hooks.configured) &&
|
|
29984
|
-
const target =
|
|
29985
|
-
if (!
|
|
30214
|
+
if (hooks.configured && !isAbsolute10(hooks.configured) && existsSync68(hooks.folder)) {
|
|
30215
|
+
const target = join74(worktree, hooks.configured);
|
|
30216
|
+
if (!existsSync68(target)) cpSync3(hooks.folder, target, { recursive: true });
|
|
29986
30217
|
copiedHooks = hooks.configured;
|
|
29987
30218
|
}
|
|
29988
30219
|
excludeLotFolder(worktree);
|
|
29989
30220
|
const siblingLinks = linkSiblings({ worktree, repository });
|
|
29990
30221
|
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 =
|
|
30222
|
+
const nodeModules = [checkout, repository].filter((folder) => folder !== void 0).map((folder) => join74(folder, "node_modules")).find((folder) => existsSync68(folder)) ?? join74(repository, "node_modules");
|
|
30223
|
+
const copy = existsSync68(nodeModules) ? copyNodeModules({ from: nodeModules, to: join74(worktree, "node_modules") }) : void 0;
|
|
29993
30224
|
const nodeModulesCheck = checkNodeModules({ worktree });
|
|
29994
30225
|
const lockfileRead = readLockedPackages({ worktree });
|
|
29995
30226
|
const lockedPackages = "packages" in lockfileRead ? lockfileRead.packages.length : 0;
|
|
@@ -30024,7 +30255,7 @@ function excludeLotFolder(worktree) {
|
|
|
30024
30255
|
root: worktree,
|
|
30025
30256
|
args: ["rev-parse", "--path-format=absolute", "--git-path", "info/exclude"]
|
|
30026
30257
|
}).trim();
|
|
30027
|
-
const text =
|
|
30258
|
+
const text = existsSync68(exclude) ? readFileSync47(exclude, "utf8") : "";
|
|
30028
30259
|
if (text.split("\n").includes(LOT_FOLDER_EXCLUDE)) return;
|
|
30029
30260
|
mkdirSync23(dirname33(exclude), { recursive: true });
|
|
30030
30261
|
appendFileSync2(exclude, `${text && !text.endsWith("\n") ? "\n" : ""}${LOT_FOLDER_EXCLUDE}
|
|
@@ -30034,23 +30265,23 @@ function excludeLotFolder(worktree) {
|
|
|
30034
30265
|
// src/lib/review-rounds/review-delta.ts
|
|
30035
30266
|
function previousRoundRefusal(params) {
|
|
30036
30267
|
const names = roundNames(params.previous);
|
|
30037
|
-
const snapshot =
|
|
30038
|
-
if (!
|
|
30268
|
+
const snapshot = join75(params.folder, names.folder);
|
|
30269
|
+
if (!existsSync69(snapshot) || !statSync10(snapshot).isDirectory())
|
|
30039
30270
|
return `no snapshot ${snapshot}: record snapshot --round ${params.previous} takes it`;
|
|
30040
|
-
if (!
|
|
30041
|
-
return `no ${
|
|
30042
|
-
const baseFile =
|
|
30043
|
-
if (!
|
|
30044
|
-
const base =
|
|
30271
|
+
if (!existsSync69(join75(params.folder, names.deleted)))
|
|
30272
|
+
return `no ${join75(params.folder, names.deleted)}: record snapshot --round ${params.previous} writes it`;
|
|
30273
|
+
const baseFile = join75(params.folder, names.base);
|
|
30274
|
+
if (!existsSync69(baseFile)) return void 0;
|
|
30275
|
+
const base = readFileSync48(baseFile, "utf8").trim();
|
|
30045
30276
|
const head = readGit({ root: params.root, args: ["rev-parse", "HEAD"] }).trim();
|
|
30046
30277
|
return base === head ? void 0 : `HEAD moved since round-${params.previous} (base ${base}, HEAD ${head})`;
|
|
30047
30278
|
}
|
|
30048
30279
|
function readDeletedPaths(params) {
|
|
30049
|
-
return
|
|
30280
|
+
return readFileSync48(join75(params.folder, roundNames(params.previous).deleted), "utf8").split("\0").filter(Boolean);
|
|
30050
30281
|
}
|
|
30051
30282
|
function computeDelta(params) {
|
|
30052
30283
|
const { root, previous } = params;
|
|
30053
|
-
const snapshot =
|
|
30284
|
+
const snapshot = join75(params.folder, roundNames(previous).folder);
|
|
30054
30285
|
const inPrevious = new Set(listTreeFiles(snapshot));
|
|
30055
30286
|
const inDeleted = new Set(readDeletedPaths(params));
|
|
30056
30287
|
const atHead = params.state.head.files;
|
|
@@ -30060,7 +30291,7 @@ function computeDelta(params) {
|
|
|
30060
30291
|
const sides = {
|
|
30061
30292
|
inPrevious: inPrevious.has(path),
|
|
30062
30293
|
inDeleted: inDeleted.has(path),
|
|
30063
|
-
inWorktree: isFileOrLink(
|
|
30294
|
+
inWorktree: isFileOrLink(join75(root, path)),
|
|
30064
30295
|
atBase: atHead.has(path)
|
|
30065
30296
|
};
|
|
30066
30297
|
const diff = diffOf({ root, snapshot, path, sides, previous });
|
|
@@ -30070,8 +30301,8 @@ function computeDelta(params) {
|
|
|
30070
30301
|
}
|
|
30071
30302
|
function diffOf(params) {
|
|
30072
30303
|
const { sides } = params;
|
|
30073
|
-
const current =
|
|
30074
|
-
const before =
|
|
30304
|
+
const current = join75(params.root, params.path);
|
|
30305
|
+
const before = join75(params.snapshot, params.path);
|
|
30075
30306
|
if (sides.inPrevious)
|
|
30076
30307
|
return sides.inWorktree ? {
|
|
30077
30308
|
form: `round-${params.previous} \u2192 worktree`,
|
|
@@ -30115,7 +30346,7 @@ function diffFiles(params) {
|
|
|
30115
30346
|
});
|
|
30116
30347
|
}
|
|
30117
30348
|
function runDiff(params) {
|
|
30118
|
-
const result =
|
|
30349
|
+
const result = spawnSync19("git", ["-c", "core.quotePath=false", ...params.args], {
|
|
30119
30350
|
cwd: params.cwd,
|
|
30120
30351
|
encoding: "utf8",
|
|
30121
30352
|
maxBuffer: 1e9
|
|
@@ -30127,7 +30358,7 @@ function runDiff(params) {
|
|
|
30127
30358
|
return result.stdout;
|
|
30128
30359
|
}
|
|
30129
30360
|
function currentBranchOf2(root) {
|
|
30130
|
-
const result =
|
|
30361
|
+
const result = spawnSync19("git", ["symbolic-ref", "--short", "-q", "HEAD"], {
|
|
30131
30362
|
cwd: root,
|
|
30132
30363
|
encoding: "utf8"
|
|
30133
30364
|
});
|
|
@@ -30155,10 +30386,10 @@ function addThrowaway(params) {
|
|
|
30155
30386
|
removal: removalCommand({ main: added.repository, path: added.worktree, branch })
|
|
30156
30387
|
};
|
|
30157
30388
|
const names = roundNames(params.previous);
|
|
30158
|
-
const deletedFile =
|
|
30159
|
-
const snapshot =
|
|
30389
|
+
const deletedFile = join75(params.folder, names.deleted);
|
|
30390
|
+
const snapshot = join75(params.folder, names.folder);
|
|
30160
30391
|
try {
|
|
30161
|
-
if (
|
|
30392
|
+
if (statSync10(deletedFile).size > 0)
|
|
30162
30393
|
readGit({
|
|
30163
30394
|
root: added.worktree,
|
|
30164
30395
|
args: [
|
|
@@ -30171,7 +30402,7 @@ function addThrowaway(params) {
|
|
|
30171
30402
|
});
|
|
30172
30403
|
for (const path of listTreeFiles(snapshot))
|
|
30173
30404
|
if (!LOT_FILE_PATTERN.test(path))
|
|
30174
|
-
copyFileOrLink({ from:
|
|
30405
|
+
copyFileOrLink({ from: join75(snapshot, path), to: join75(added.worktree, path) });
|
|
30175
30406
|
} catch (error) {
|
|
30176
30407
|
return `${error.message}; the throwaway worktree is half made, remove it: ${throwaway.removal}`;
|
|
30177
30408
|
}
|
|
@@ -30261,7 +30492,7 @@ function reviewDelta(params) {
|
|
|
30261
30492
|
}
|
|
30262
30493
|
|
|
30263
30494
|
// src/commands/rules.ts
|
|
30264
|
-
import { existsSync as
|
|
30495
|
+
import { existsSync as existsSync70, readFileSync as readFileSync49, statSync as statSync11 } from "fs";
|
|
30265
30496
|
import { resolve as resolve25 } from "path";
|
|
30266
30497
|
|
|
30267
30498
|
// src/lib/rules/check-code-rules.constants.ts
|
|
@@ -30304,8 +30535,8 @@ function checkCodeRules(params) {
|
|
|
30304
30535
|
const kind = fileKindOf(file);
|
|
30305
30536
|
const sourceFile = ts8.createSourceFile(file, text, ts8.ScriptTarget.Latest, true);
|
|
30306
30537
|
const findings = [];
|
|
30307
|
-
function report(
|
|
30308
|
-
const { node, ...rest } =
|
|
30538
|
+
function report(finding2) {
|
|
30539
|
+
const { node, ...rest } = finding2;
|
|
30309
30540
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
30310
30541
|
findings.push({ file, line: position.line + 1, column: position.character + 1, ...rest });
|
|
30311
30542
|
}
|
|
@@ -30528,9 +30759,9 @@ function runRules(params) {
|
|
|
30528
30759
|
}
|
|
30529
30760
|
const referencePatterns = readReferencePatterns(cwd);
|
|
30530
30761
|
const findings = files.flatMap(
|
|
30531
|
-
(file) => checkCodeRules({ file, text:
|
|
30762
|
+
(file) => checkCodeRules({ file, text: readFileSync49(resolve25(cwd, file), "utf8"), referencePatterns })
|
|
30532
30763
|
);
|
|
30533
|
-
const errors = findings.filter((
|
|
30764
|
+
const errors = findings.filter((finding2) => finding2.severity === "error").length;
|
|
30534
30765
|
const warnings = findings.length - errors;
|
|
30535
30766
|
if (givenFiles.length === 0) recordRules({ root: cwd, files, errors, warnings });
|
|
30536
30767
|
const output = json ? JSON.stringify({ files, errors, warnings, findings }, null, 2) : [
|
|
@@ -30541,17 +30772,17 @@ function runRules(params) {
|
|
|
30541
30772
|
}
|
|
30542
30773
|
function expandFolder(params) {
|
|
30543
30774
|
const { cwd, path } = params;
|
|
30544
|
-
if (!
|
|
30775
|
+
if (!statSync11(resolve25(cwd, path)).isDirectory()) return [path];
|
|
30545
30776
|
return listRepositoryFiles({ root: cwd, folder: path }).filter(
|
|
30546
|
-
(file) => TEXT_FILE_PATTERN.test(file) &&
|
|
30777
|
+
(file) => TEXT_FILE_PATTERN.test(file) && existsSync70(resolve25(cwd, file))
|
|
30547
30778
|
);
|
|
30548
30779
|
}
|
|
30549
|
-
function renderFinding(
|
|
30550
|
-
return `${
|
|
30780
|
+
function renderFinding(finding2) {
|
|
30781
|
+
return `${finding2.file}:${finding2.line}:${finding2.column} ${finding2.severity} ${finding2.rule} ${finding2.message}`;
|
|
30551
30782
|
}
|
|
30552
30783
|
|
|
30553
30784
|
// src/commands/run.ts
|
|
30554
|
-
import { readFileSync as
|
|
30785
|
+
import { readFileSync as readFileSync50, writeFileSync as writeFileSync29 } from "fs";
|
|
30555
30786
|
import { resolve as resolve26 } from "path";
|
|
30556
30787
|
import { pathToFileURL as pathToFileURL5 } from "url";
|
|
30557
30788
|
async function run19(argv) {
|
|
@@ -30659,7 +30890,7 @@ async function loadScript(params) {
|
|
|
30659
30890
|
return loaded.default;
|
|
30660
30891
|
}
|
|
30661
30892
|
function readExpectations(params) {
|
|
30662
|
-
const parsed2 = JSON.parse(
|
|
30893
|
+
const parsed2 = JSON.parse(readFileSync50(params.path, "utf8"));
|
|
30663
30894
|
const isExpectationList = Array.isArray(parsed2) && parsed2.every(
|
|
30664
30895
|
(entry) => typeof entry === "object" && entry !== null && typeof entry.tag === "string"
|
|
30665
30896
|
);
|
|
@@ -30671,7 +30902,7 @@ function readExpectations(params) {
|
|
|
30671
30902
|
}
|
|
30672
30903
|
function readInput(params) {
|
|
30673
30904
|
const { path } = params;
|
|
30674
|
-
return new File([
|
|
30905
|
+
return new File([readFileSync50(path)], path.slice(path.lastIndexOf("/") + 1), {
|
|
30675
30906
|
type: "application/xml"
|
|
30676
30907
|
});
|
|
30677
30908
|
}
|
|
@@ -30839,12 +31070,12 @@ async function readSchemaDialectes(params) {
|
|
|
30839
31070
|
}
|
|
30840
31071
|
|
|
30841
31072
|
// src/commands/skills.ts
|
|
30842
|
-
import { existsSync as existsSync80, readdirSync as readdirSync19, readFileSync as
|
|
30843
|
-
import { dirname as dirname36, join as
|
|
31073
|
+
import { existsSync as existsSync80, readdirSync as readdirSync19, readFileSync as readFileSync59, writeFileSync as writeFileSync33 } from "fs";
|
|
31074
|
+
import { dirname as dirname36, join as join85, relative as relative9, sep as sep2 } from "path";
|
|
30844
31075
|
|
|
30845
31076
|
// src/lib/api/api-json.ts
|
|
30846
|
-
import { existsSync as
|
|
30847
|
-
import { join as
|
|
31077
|
+
import { existsSync as existsSync72, readFileSync as readFileSync52 } from "fs";
|
|
31078
|
+
import { join as join77 } from "path";
|
|
30848
31079
|
|
|
30849
31080
|
// src/lib/skills/api-index.ts
|
|
30850
31081
|
function renderApiIndex(entries) {
|
|
@@ -30951,18 +31182,18 @@ function tableCell(text) {
|
|
|
30951
31182
|
}
|
|
30952
31183
|
|
|
30953
31184
|
// src/lib/api/find-example.ts
|
|
30954
|
-
import { existsSync as
|
|
30955
|
-
import { join as
|
|
31185
|
+
import { existsSync as existsSync71, readFileSync as readFileSync51 } from "fs";
|
|
31186
|
+
import { join as join76 } from "path";
|
|
30956
31187
|
import ts9 from "typescript";
|
|
30957
31188
|
function findTestExample(params) {
|
|
30958
31189
|
const { file, position } = splitDeclaredAt(params.declaredAt);
|
|
30959
|
-
const testFile =
|
|
30960
|
-
if (!file.endsWith(".ts") || !
|
|
30961
|
-
const functionName = declaredName({ path:
|
|
31190
|
+
const testFile = join76(params.root, file.replace(/\.ts$/, ".test.ts"));
|
|
31191
|
+
if (!file.endsWith(".ts") || !existsSync71(testFile)) return void 0;
|
|
31192
|
+
const functionName = declaredName({ path: join76(params.root, file), position });
|
|
30962
31193
|
if (!functionName) return void 0;
|
|
30963
31194
|
const source = ts9.createSourceFile(
|
|
30964
31195
|
testFile,
|
|
30965
|
-
|
|
31196
|
+
readFileSync51(testFile, "utf8"),
|
|
30966
31197
|
ts9.ScriptTarget.Latest,
|
|
30967
31198
|
true
|
|
30968
31199
|
);
|
|
@@ -30987,10 +31218,10 @@ function splitDeclaredAt(declaredAt) {
|
|
|
30987
31218
|
};
|
|
30988
31219
|
}
|
|
30989
31220
|
function declaredName(params) {
|
|
30990
|
-
if (!
|
|
31221
|
+
if (!existsSync71(params.path)) return void 0;
|
|
30991
31222
|
const source = ts9.createSourceFile(
|
|
30992
31223
|
params.path,
|
|
30993
|
-
|
|
31224
|
+
readFileSync51(params.path, "utf8"),
|
|
30994
31225
|
ts9.ScriptTarget.Latest,
|
|
30995
31226
|
true
|
|
30996
31227
|
);
|
|
@@ -31072,9 +31303,9 @@ function rootOf(path) {
|
|
|
31072
31303
|
}
|
|
31073
31304
|
function lineOf(params) {
|
|
31074
31305
|
const { file, position } = splitDeclaredAt(params.declaredAt);
|
|
31075
|
-
const path =
|
|
31076
|
-
if (!
|
|
31077
|
-
const line =
|
|
31306
|
+
const path = join77(params.root, file);
|
|
31307
|
+
if (!existsSync72(path)) return file;
|
|
31308
|
+
const line = readFileSync52(path, "utf8").slice(0, position).split("\n").length;
|
|
31078
31309
|
return `${file}:${line}`;
|
|
31079
31310
|
}
|
|
31080
31311
|
function renderApiJson(apiJson) {
|
|
@@ -31108,8 +31339,8 @@ function prompt(params) {
|
|
|
31108
31339
|
}
|
|
31109
31340
|
|
|
31110
31341
|
// src/lib/models/resolve-sync-vendor.ts
|
|
31111
|
-
import { existsSync as existsSync76, readdirSync as readdirSync17, readFileSync as
|
|
31112
|
-
import { basename as basename11, dirname as dirname35, join as
|
|
31342
|
+
import { existsSync as existsSync76, readdirSync as readdirSync17, readFileSync as readFileSync55, statSync as statSync12 } from "fs";
|
|
31343
|
+
import { basename as basename11, dirname as dirname35, join as join81 } from "path";
|
|
31113
31344
|
|
|
31114
31345
|
// src/lib/stations/session-check.constants.ts
|
|
31115
31346
|
var SESSION_CHECK_COMMAND = "npx --no-install @dialecte/cli doctor --brief";
|
|
@@ -31124,16 +31355,92 @@ var SESSION_CHECK_GROUP = {
|
|
|
31124
31355
|
var SESSION_CHECK_COMMAND_PATTERN = /^npx(?: --no-install)? @dialecte\/cli doctor --brief$/;
|
|
31125
31356
|
var MAX_CUTS = 50;
|
|
31126
31357
|
|
|
31358
|
+
// src/lib/stations/agents-file-check.constants.ts
|
|
31359
|
+
var AGENTS_FILE = "AGENTS.md";
|
|
31360
|
+
var AGENTS_CHECK_START = "<!-- dialecte-skills:session-check -->";
|
|
31361
|
+
var AGENTS_CHECK_END = "<!-- /dialecte-skills:session-check -->";
|
|
31362
|
+
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.`;
|
|
31363
|
+
|
|
31364
|
+
// src/lib/stations/agents-file-check.ts
|
|
31365
|
+
import { existsSync as existsSync73, readFileSync as readFileSync53, unlinkSync as unlinkSync3, writeFileSync as writeFileSync30 } from "fs";
|
|
31366
|
+
import { join as join78 } from "path";
|
|
31367
|
+
function syncAgentsFileCheck(params) {
|
|
31368
|
+
const { cwd, enabled } = params;
|
|
31369
|
+
const path = join78(cwd, AGENTS_FILE);
|
|
31370
|
+
const exists = existsSync73(path);
|
|
31371
|
+
const text = exists ? readFileSync53(path, "utf8") : "";
|
|
31372
|
+
const found = findSection(text);
|
|
31373
|
+
if (found === "unclosed") return "unclosed";
|
|
31374
|
+
if (enabled) return addOrUpdate({ path, text, span: found });
|
|
31375
|
+
if (found === void 0) return "unchanged";
|
|
31376
|
+
const without = withoutSection({ text, span: found });
|
|
31377
|
+
if (without.trim() === "") unlinkSync3(path);
|
|
31378
|
+
else writeFileSync30(path, without);
|
|
31379
|
+
return "removed";
|
|
31380
|
+
}
|
|
31381
|
+
function holdsOnlyTheAgentsCheck(text) {
|
|
31382
|
+
const span = findSection(text);
|
|
31383
|
+
if (span === void 0 || span === "unclosed") return false;
|
|
31384
|
+
return `${text.slice(0, span.start)}${text.slice(span.end)}`.trim() === "";
|
|
31385
|
+
}
|
|
31386
|
+
function findSection(text) {
|
|
31387
|
+
const starts = occurrencesOf({ text, marker: AGENTS_CHECK_START });
|
|
31388
|
+
const ends = occurrencesOf({ text, marker: AGENTS_CHECK_END });
|
|
31389
|
+
if (starts.length === 0 && ends.length === 0) return void 0;
|
|
31390
|
+
if (starts.length !== 1 || ends.length !== 1 || starts[0] > ends[0]) return "unclosed";
|
|
31391
|
+
return { start: starts[0], end: ends[0] + AGENTS_CHECK_END.length };
|
|
31392
|
+
}
|
|
31393
|
+
function occurrencesOf(params) {
|
|
31394
|
+
const offsets = [];
|
|
31395
|
+
let from = params.text.indexOf(params.marker);
|
|
31396
|
+
while (from >= 0) {
|
|
31397
|
+
offsets.push(from);
|
|
31398
|
+
from = params.text.indexOf(params.marker, from + params.marker.length);
|
|
31399
|
+
}
|
|
31400
|
+
return offsets;
|
|
31401
|
+
}
|
|
31402
|
+
function eolOf(text) {
|
|
31403
|
+
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
31404
|
+
}
|
|
31405
|
+
function addOrUpdate(params) {
|
|
31406
|
+
const { path, text, span } = params;
|
|
31407
|
+
const eol = eolOf(text);
|
|
31408
|
+
const section = `${AGENTS_CHECK_START}${eol}${AGENTS_CHECK_LINE}${eol}${AGENTS_CHECK_END}`;
|
|
31409
|
+
if (span === void 0) {
|
|
31410
|
+
writeFileSync30(path, `${text}${separatorBefore({ text, eol })}${section}${eol}`);
|
|
31411
|
+
return "added";
|
|
31412
|
+
}
|
|
31413
|
+
if (text.slice(span.start, span.end) === section) return "unchanged";
|
|
31414
|
+
writeFileSync30(path, `${text.slice(0, span.start)}${section}${text.slice(span.end)}`);
|
|
31415
|
+
return "updated";
|
|
31416
|
+
}
|
|
31417
|
+
function separatorBefore(params) {
|
|
31418
|
+
const { text, eol } = params;
|
|
31419
|
+
if (text === "") return "";
|
|
31420
|
+
return text.endsWith("\n") ? eol : `${eol}${eol}`;
|
|
31421
|
+
}
|
|
31422
|
+
function withoutSection(params) {
|
|
31423
|
+
const { text, span } = params;
|
|
31424
|
+
const eol = eolOf(text);
|
|
31425
|
+
let before = text.slice(0, span.start);
|
|
31426
|
+
let after = text.slice(span.end);
|
|
31427
|
+
const startsLine = before === "" || before.endsWith("\n");
|
|
31428
|
+
if (startsLine && after.startsWith(eol)) after = after.slice(eol.length);
|
|
31429
|
+
if (before.endsWith(`${eol}${eol}`)) before = before.slice(0, -eol.length);
|
|
31430
|
+
else if (before === "" && after.startsWith(eol)) after = after.slice(eol.length);
|
|
31431
|
+
return `${before}${after}`;
|
|
31432
|
+
}
|
|
31433
|
+
|
|
31127
31434
|
// src/lib/stations/session-check.ts
|
|
31128
|
-
import { existsSync as existsSync75, mkdirSync as mkdirSync24, readFileSync as
|
|
31129
|
-
import { dirname as dirname34, join as
|
|
31435
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync24, readFileSync as readFileSync54, unlinkSync as unlinkSync4, writeFileSync as writeFileSync31 } from "fs";
|
|
31436
|
+
import { dirname as dirname34, join as join80 } from "path";
|
|
31130
31437
|
|
|
31131
31438
|
// src/lib/stations/station-manifest.ts
|
|
31132
31439
|
import { existsSync as existsSync74 } from "fs";
|
|
31133
|
-
import { join as
|
|
31440
|
+
import { join as join79 } from "path";
|
|
31134
31441
|
function updateStationManifest(params) {
|
|
31135
31442
|
const { folder, patch } = params;
|
|
31136
|
-
if (!existsSync74(
|
|
31443
|
+
if (!existsSync74(join79(folder, MANIFEST_FILE))) return;
|
|
31137
31444
|
const manifest = readSyncManifest(folder);
|
|
31138
31445
|
const { stationAgents, sessionCheck, settingsCreated, sessionCheckInserted, ...rest } = manifest;
|
|
31139
31446
|
writeSyncManifest({
|
|
@@ -31152,9 +31459,9 @@ function updateStationManifest(params) {
|
|
|
31152
31459
|
import { findNodeAtLocation, getNodeValue, parse as parse3, parseTree } from "jsonc-parser";
|
|
31153
31460
|
function syncSessionCheck(params) {
|
|
31154
31461
|
const { cwd, enabled } = params;
|
|
31155
|
-
const manifestFolder =
|
|
31462
|
+
const manifestFolder = join80(cwd, AGENT_SKILL_FOLDERS.claude);
|
|
31156
31463
|
const recorded = readSyncManifest(manifestFolder).sessionCheck === true;
|
|
31157
|
-
const path =
|
|
31464
|
+
const path = join80(cwd, CLAUDE_SETTINGS_FILE);
|
|
31158
31465
|
if (!enabled && !recorded) return "unchanged";
|
|
31159
31466
|
const exists = existsSync75(path);
|
|
31160
31467
|
if (!exists && !enabled) {
|
|
@@ -31164,7 +31471,7 @@ function syncSessionCheck(params) {
|
|
|
31164
31471
|
});
|
|
31165
31472
|
return "unchanged";
|
|
31166
31473
|
}
|
|
31167
|
-
const text = exists ?
|
|
31474
|
+
const text = exists ? readFileSync54(path, "utf8") : NEW_SETTINGS_FILE;
|
|
31168
31475
|
const settings = parseSettings(text);
|
|
31169
31476
|
if (settings === void 0) return "invalid";
|
|
31170
31477
|
if (!hasValidHooks(settings)) return "invalid-hooks";
|
|
@@ -31185,7 +31492,7 @@ function syncSessionCheck(params) {
|
|
|
31185
31492
|
if (present) return recorded ? "unchanged" : "kept";
|
|
31186
31493
|
mkdirSync24(dirname34(path), { recursive: true });
|
|
31187
31494
|
const added = withCheck(text);
|
|
31188
|
-
|
|
31495
|
+
writeFileSync31(path, added.text);
|
|
31189
31496
|
updateStationManifest({
|
|
31190
31497
|
folder: manifestFolder,
|
|
31191
31498
|
patch: {
|
|
@@ -31199,8 +31506,8 @@ function syncSessionCheck(params) {
|
|
|
31199
31506
|
function writeOrDelete(params) {
|
|
31200
31507
|
const left = parseSettings(params.text);
|
|
31201
31508
|
if (params.created && left !== void 0 && Object.keys(left).length === 0)
|
|
31202
|
-
|
|
31203
|
-
else
|
|
31509
|
+
unlinkSync4(params.path);
|
|
31510
|
+
else writeFileSync31(params.path, params.text);
|
|
31204
31511
|
}
|
|
31205
31512
|
function parseSettings(text) {
|
|
31206
31513
|
const errors = [];
|
|
@@ -31395,15 +31702,10 @@ function resolveSyncVendor(params) {
|
|
|
31395
31702
|
candidates: detection.kind === "choose" ? detection.candidates : [...VENDOR_IDS]
|
|
31396
31703
|
};
|
|
31397
31704
|
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
|
-
};
|
|
31705
|
+
const detected = detection.kind === "choose" ? ` Several agents or a multi-vendor host were detected (${detection.candidates.join(", ")}).` : "";
|
|
31404
31706
|
return {
|
|
31405
|
-
kind: "
|
|
31406
|
-
|
|
31707
|
+
kind: "unset",
|
|
31708
|
+
notice: `skills sync: no vendor remembered for the models (\`dialecte models\`).${detected} ${howToSet}
|
|
31407
31709
|
`
|
|
31408
31710
|
};
|
|
31409
31711
|
}
|
|
@@ -31414,30 +31716,33 @@ function presentPaths(cwd) {
|
|
|
31414
31716
|
const candidates = VENDOR_HOSTS.flatMap((host) => host.anyOf.flat());
|
|
31415
31717
|
return new Set(
|
|
31416
31718
|
candidates.filter(
|
|
31417
|
-
(path) => existsSync76(
|
|
31719
|
+
(path) => existsSync76(join81(cwd, path)) && !holdsOnlySyncedSkills({ cwd, path })
|
|
31418
31720
|
)
|
|
31419
31721
|
);
|
|
31420
31722
|
}
|
|
31421
31723
|
function holdsOnlySyncedSkills(params) {
|
|
31422
31724
|
const skillFolders = Object.values(AGENT_SKILL_FOLDERS);
|
|
31423
|
-
if (skillFolders.includes(params.path)) return isSyncedSkillsFolder(
|
|
31424
|
-
|
|
31425
|
-
|
|
31725
|
+
if (skillFolders.includes(params.path)) return isSyncedSkillsFolder(join81(params.cwd, params.path));
|
|
31726
|
+
const stat = statSync12(join81(params.cwd, params.path));
|
|
31727
|
+
if (params.path === AGENTS_FILE)
|
|
31728
|
+
return stat.isFile() && holdsOnlyTheAgentsCheck(readFileSync55(join81(params.cwd, params.path), "utf8"));
|
|
31729
|
+
if (!stat.isDirectory()) return false;
|
|
31730
|
+
const entries = readdirSync17(join81(params.cwd, params.path));
|
|
31426
31731
|
const ownSkillFolders2 = skillFolders.filter((folder) => dirname35(folder) === params.path);
|
|
31427
31732
|
return entries.length > 0 && entries.every(
|
|
31428
31733
|
(entry) => ownSkillFolders2.some(
|
|
31429
|
-
(folder) => basename11(folder) === entry && isSyncedSkillsFolder(
|
|
31734
|
+
(folder) => basename11(folder) === entry && isSyncedSkillsFolder(join81(params.cwd, folder))
|
|
31430
31735
|
) || isSyncedClaudeExtra({ cwd: params.cwd, folder: params.path, entry })
|
|
31431
31736
|
);
|
|
31432
31737
|
}
|
|
31433
31738
|
function isSyncedClaudeExtra(params) {
|
|
31434
31739
|
if (params.folder !== dirname35(AGENT_SKILL_FOLDERS.claude)) return false;
|
|
31435
|
-
const manifest = readManifestOrNothing(
|
|
31436
|
-
const path =
|
|
31437
|
-
if (path ===
|
|
31740
|
+
const manifest = readManifestOrNothing(join81(params.cwd, AGENT_SKILL_FOLDERS.claude));
|
|
31741
|
+
const path = join81(params.cwd, params.folder, params.entry);
|
|
31742
|
+
if (path === join81(params.cwd, CLAUDE_AGENTS_FOLDER))
|
|
31438
31743
|
return readdirSync17(path).every((file) => manifest.stationAgents?.includes(file));
|
|
31439
|
-
if (path ===
|
|
31440
|
-
return manifest.sessionCheck === true && holdsOnlyTheCheck(
|
|
31744
|
+
if (path === join81(params.cwd, CLAUDE_SETTINGS_FILE))
|
|
31745
|
+
return manifest.sessionCheck === true && holdsOnlyTheCheck(readFileSync55(path, "utf8"));
|
|
31441
31746
|
return false;
|
|
31442
31747
|
}
|
|
31443
31748
|
function readManifestOrNothing(folder) {
|
|
@@ -31448,7 +31753,7 @@ function readManifestOrNothing(folder) {
|
|
|
31448
31753
|
}
|
|
31449
31754
|
}
|
|
31450
31755
|
function isSyncedSkillsFolder(folder) {
|
|
31451
|
-
if (!existsSync76(
|
|
31756
|
+
if (!existsSync76(join81(folder, MANIFEST_FILE))) return false;
|
|
31452
31757
|
const { installed } = readSyncManifest(folder);
|
|
31453
31758
|
return readdirSync17(folder).every((entry) => entry === MANIFEST_FILE || installed.includes(entry));
|
|
31454
31759
|
}
|
|
@@ -31463,101 +31768,6 @@ var GENERATED_MARKER_PATTERN = /<!-- (?:dialecte-skills:generated ([\w-]+)|\/dia
|
|
|
31463
31768
|
var STRONG_UNDERSCORE_PATTERN = /__(?=\S)(.+?)(?<=\S)__/g;
|
|
31464
31769
|
var EMPHASIS_UNDERSCORE_PATTERN = /(^|[^\w_])_(?=\S)([^_\n]+?)(?<=\S)_(?![\w_])/g;
|
|
31465
31770
|
|
|
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
31771
|
// src/lib/skills/check-skill-page.ts
|
|
31562
31772
|
function checkSkillPage(params) {
|
|
31563
31773
|
const { file, markdown, folderName, siblingFiles, facts, workspaceFacts } = params;
|
|
@@ -31622,9 +31832,77 @@ function isSkillFileOrFolder(params) {
|
|
|
31622
31832
|
return [...params.siblingFiles].some((siblingFile) => siblingFile.startsWith(`${target}/`));
|
|
31623
31833
|
}
|
|
31624
31834
|
|
|
31835
|
+
// src/lib/skills/check-station-definitions.constants.ts
|
|
31836
|
+
var STATIONS_FILE = "skills/dialecte-lot/references/stations.md";
|
|
31837
|
+
var SECTION_BOUNDARY_PATTERN = /^#{1,3}\s/;
|
|
31838
|
+
var STATION_HEADING_PATTERN = /^###\s+(\S+)\s*$/;
|
|
31839
|
+
var FENCE_PATTERN = /^\s*(```|~~~)/;
|
|
31840
|
+
var DEFINITION_LINE_PATTERN = /^- (Tier|Access): /;
|
|
31841
|
+
|
|
31842
|
+
// src/lib/skills/check-station-definitions.ts
|
|
31843
|
+
function checkStationDefinitions(params) {
|
|
31844
|
+
if (params.markdown === void 0)
|
|
31845
|
+
return [finding(`missing: it defines the stations the cli writes agents for`)];
|
|
31846
|
+
const sections = readSections(params.markdown);
|
|
31847
|
+
const findings = STATIONS.flatMap((station) => checkStation({ station, sections }));
|
|
31848
|
+
const known = new Set(STATIONS.map((station) => station.name));
|
|
31849
|
+
for (const section of sections)
|
|
31850
|
+
if (!known.has(section.name) && holdsDefinitionLine(section))
|
|
31851
|
+
findings.push(finding(`section "${section.name}" is no station of the cli`));
|
|
31852
|
+
return findings;
|
|
31853
|
+
}
|
|
31854
|
+
function finding(message) {
|
|
31855
|
+
return { file: STATIONS_FILE, severity: "error", message };
|
|
31856
|
+
}
|
|
31857
|
+
function holdsDefinitionLine(section) {
|
|
31858
|
+
return section.lines.some((line) => DEFINITION_LINE_PATTERN.test(line));
|
|
31859
|
+
}
|
|
31860
|
+
function readSections(markdown) {
|
|
31861
|
+
const sections = [];
|
|
31862
|
+
let current;
|
|
31863
|
+
let fenced = false;
|
|
31864
|
+
for (const line of markdown.replace(/\r\n/g, "\n").split("\n")) {
|
|
31865
|
+
if (FENCE_PATTERN.test(line)) fenced = !fenced;
|
|
31866
|
+
if (fenced || FENCE_PATTERN.test(line)) continue;
|
|
31867
|
+
const name = STATION_HEADING_PATTERN.exec(line)?.[1];
|
|
31868
|
+
if (name !== void 0) {
|
|
31869
|
+
current = { name, lines: [] };
|
|
31870
|
+
sections.push(current);
|
|
31871
|
+
} else if (SECTION_BOUNDARY_PATTERN.test(line)) current = void 0;
|
|
31872
|
+
else current?.lines.push(line);
|
|
31873
|
+
}
|
|
31874
|
+
return sections;
|
|
31875
|
+
}
|
|
31876
|
+
function checkStation(params) {
|
|
31877
|
+
const { station } = params;
|
|
31878
|
+
const own = params.sections.filter((section) => section.name === station.name);
|
|
31879
|
+
if (own.length === 0) return [finding(`station "${station.name}" has no section`)];
|
|
31880
|
+
if (own.length > 1) return [finding(`station "${station.name}" has more than one section`)];
|
|
31881
|
+
return [
|
|
31882
|
+
...checkLine({ station, section: own[0], label: "Tier", expected: station.tier }),
|
|
31883
|
+
...checkLine({ station, section: own[0], label: "Access", expected: station.access })
|
|
31884
|
+
];
|
|
31885
|
+
}
|
|
31886
|
+
function checkLine(params) {
|
|
31887
|
+
const { station, section, label, expected } = params;
|
|
31888
|
+
const pattern = new RegExp(`^- ${label}: (\\S+)\\s*$`);
|
|
31889
|
+
const found = section.lines.map((line) => pattern.exec(line)?.[1]).find((value) => value);
|
|
31890
|
+
if (found === void 0)
|
|
31891
|
+
return [
|
|
31892
|
+
finding(
|
|
31893
|
+
`station "${station.name}": no \`- ${label}: <value>\` line (the cli has ${expected})`
|
|
31894
|
+
)
|
|
31895
|
+
];
|
|
31896
|
+
if (found !== expected)
|
|
31897
|
+
return [
|
|
31898
|
+
finding(`station "${station.name}": ${label} line says ${found}, the cli has ${expected}`)
|
|
31899
|
+
];
|
|
31900
|
+
return [];
|
|
31901
|
+
}
|
|
31902
|
+
|
|
31625
31903
|
// src/lib/skills/export-entries.ts
|
|
31626
|
-
import { existsSync as existsSync77, readFileSync as
|
|
31627
|
-
import { join as
|
|
31904
|
+
import { existsSync as existsSync77, readFileSync as readFileSync56 } from "fs";
|
|
31905
|
+
import { join as join82 } from "path";
|
|
31628
31906
|
|
|
31629
31907
|
// src/lib/skills/export-entries.constants.ts
|
|
31630
31908
|
var SOURCE_FOLDER = "src";
|
|
@@ -31639,7 +31917,7 @@ var SUBPATH_PATTERN_MARKER = "*";
|
|
|
31639
31917
|
// src/lib/skills/export-entries.ts
|
|
31640
31918
|
function readExportEntries(params) {
|
|
31641
31919
|
const manifest = JSON.parse(
|
|
31642
|
-
|
|
31920
|
+
readFileSync56(join82(params.root, "package.json"), "utf8")
|
|
31643
31921
|
);
|
|
31644
31922
|
const packageName3 = typeof manifest.name === "string" ? manifest.name : "";
|
|
31645
31923
|
return Object.entries(subpathsOf(manifest.exports)).flatMap(
|
|
@@ -31679,7 +31957,7 @@ function sourceOf(params) {
|
|
|
31679
31957
|
`${withoutExtension}${sourceExtension}`,
|
|
31680
31958
|
`${withoutExtension}/index${sourceExtension}`
|
|
31681
31959
|
]);
|
|
31682
|
-
const source = candidates.find((candidate) => existsSync77(
|
|
31960
|
+
const source = candidates.find((candidate) => existsSync77(join82(params.root, candidate)));
|
|
31683
31961
|
if (source === void 0)
|
|
31684
31962
|
throw new Error(
|
|
31685
31963
|
`exports entry "${params.subpath}": no source at ${candidates.join(" nor at ")}`
|
|
@@ -31793,9 +32071,9 @@ function findUnclosedGeneratedBlocks(markdown) {
|
|
|
31793
32071
|
}
|
|
31794
32072
|
|
|
31795
32073
|
// src/lib/skills/package-facts.ts
|
|
31796
|
-
import { spawnSync as
|
|
31797
|
-
import { existsSync as existsSync78, readdirSync as readdirSync18, readFileSync as
|
|
31798
|
-
import { join as
|
|
32074
|
+
import { spawnSync as spawnSync20 } from "child_process";
|
|
32075
|
+
import { existsSync as existsSync78, readdirSync as readdirSync18, readFileSync as readFileSync57 } from "fs";
|
|
32076
|
+
import { join as join83 } from "path";
|
|
31799
32077
|
|
|
31800
32078
|
// src/lib/skills/package-facts.constants.ts
|
|
31801
32079
|
var EXCLUDED_FOLDERS = [
|
|
@@ -31815,14 +32093,14 @@ function listRepositoryPaths(root) {
|
|
|
31815
32093
|
return gitFiles ? withFolders(gitFiles) : walkRepositoryPaths(root);
|
|
31816
32094
|
}
|
|
31817
32095
|
function listGitFiles(root) {
|
|
31818
|
-
if (!existsSync78(
|
|
31819
|
-
const result =
|
|
32096
|
+
if (!existsSync78(join83(root, ".git"))) return void 0;
|
|
32097
|
+
const result = spawnSync20("git", ["ls-files", "--cached", "--others", "--exclude-standard"], {
|
|
31820
32098
|
cwd: root,
|
|
31821
32099
|
encoding: "utf8",
|
|
31822
32100
|
maxBuffer: 1e8
|
|
31823
32101
|
});
|
|
31824
32102
|
if (result.status !== 0) return void 0;
|
|
31825
|
-
return result.stdout.split("\n").filter(Boolean).filter((path) => existsSync78(
|
|
32103
|
+
return result.stdout.split("\n").filter(Boolean).filter((path) => existsSync78(join83(root, path)));
|
|
31826
32104
|
}
|
|
31827
32105
|
function withFolders(files) {
|
|
31828
32106
|
const paths = /* @__PURE__ */ new Set();
|
|
@@ -31836,7 +32114,7 @@ function withFolders(files) {
|
|
|
31836
32114
|
function walkRepositoryPaths(root) {
|
|
31837
32115
|
const paths = [];
|
|
31838
32116
|
function walk(relativeFolder) {
|
|
31839
|
-
for (const entry of readdirSync18(
|
|
32117
|
+
for (const entry of readdirSync18(join83(root, relativeFolder), { withFileTypes: true })) {
|
|
31840
32118
|
const path = relativeFolder ? `${relativeFolder}/${entry.name}` : entry.name;
|
|
31841
32119
|
if (entry.isDirectory()) {
|
|
31842
32120
|
if (EXCLUDED_FOLDERS.includes(entry.name) || EXCLUDED_FOLDERS.includes(path)) continue;
|
|
@@ -31849,31 +32127,31 @@ function walkRepositoryPaths(root) {
|
|
|
31849
32127
|
return paths.sort();
|
|
31850
32128
|
}
|
|
31851
32129
|
function readNpmScripts(root) {
|
|
31852
|
-
const path =
|
|
32130
|
+
const path = join83(root, "package.json");
|
|
31853
32131
|
if (!existsSync78(path)) return /* @__PURE__ */ new Set();
|
|
31854
|
-
return new Set(Object.keys(JSON.parse(
|
|
32132
|
+
return new Set(Object.keys(JSON.parse(readFileSync57(path, "utf8")).scripts ?? {}));
|
|
31855
32133
|
}
|
|
31856
32134
|
function readWorkspaceFacts(workspaceRoot) {
|
|
31857
32135
|
const packageFolders = readdirSync18(workspaceRoot, { withFileTypes: true }).filter(
|
|
31858
|
-
(entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync78(
|
|
32136
|
+
(entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync78(join83(workspaceRoot, entry.name, "package.json"))
|
|
31859
32137
|
).map((entry) => entry.name).sort();
|
|
31860
32138
|
return {
|
|
31861
32139
|
repositoryPaths: packageFolders.flatMap(
|
|
31862
|
-
(folder) => listRepositoryPaths(
|
|
32140
|
+
(folder) => listRepositoryPaths(join83(workspaceRoot, folder)).map((path) => `${folder}/${path}`)
|
|
31863
32141
|
),
|
|
31864
32142
|
npmScripts: new Set(
|
|
31865
|
-
packageFolders.flatMap((folder) => [...readNpmScripts(
|
|
32143
|
+
packageFolders.flatMap((folder) => [...readNpmScripts(join83(workspaceRoot, folder))])
|
|
31866
32144
|
)
|
|
31867
32145
|
};
|
|
31868
32146
|
}
|
|
31869
32147
|
function listHookConcernFiles(root) {
|
|
31870
32148
|
const concernFilesByFolder = {};
|
|
31871
32149
|
for (const version of discoverVersions(root)) {
|
|
31872
|
-
const hooksFolder =
|
|
32150
|
+
const hooksFolder = join83(root, "src", version, "hooks");
|
|
31873
32151
|
if (!existsSync78(hooksFolder)) continue;
|
|
31874
32152
|
for (const folder of readdirSync18(hooksFolder, { withFileTypes: true })) {
|
|
31875
32153
|
if (!folder.isDirectory()) continue;
|
|
31876
|
-
const files = readdirSync18(
|
|
32154
|
+
const files = readdirSync18(join83(hooksFolder, folder.name)).filter(
|
|
31877
32155
|
(file) => file.endsWith(".ts") && !NOT_A_CONCERN_FILE.test(file)
|
|
31878
32156
|
);
|
|
31879
32157
|
concernFilesByFolder[folder.name] = [
|
|
@@ -31887,18 +32165,18 @@ function listHookConcernFiles(root) {
|
|
|
31887
32165
|
// src/lib/stations/sync-station-agents.ts
|
|
31888
32166
|
import {
|
|
31889
32167
|
existsSync as existsSync79,
|
|
31890
|
-
lstatSync as
|
|
32168
|
+
lstatSync as lstatSync12,
|
|
31891
32169
|
mkdirSync as mkdirSync25,
|
|
31892
|
-
readFileSync as
|
|
32170
|
+
readFileSync as readFileSync58,
|
|
31893
32171
|
rmdirSync as rmdirSync2,
|
|
31894
32172
|
rmSync as rmSync24,
|
|
31895
|
-
writeFileSync as
|
|
32173
|
+
writeFileSync as writeFileSync32
|
|
31896
32174
|
} from "fs";
|
|
31897
|
-
import { join as
|
|
32175
|
+
import { join as join84 } from "path";
|
|
31898
32176
|
function syncStationAgents(params) {
|
|
31899
32177
|
const { cwd, plan } = params;
|
|
31900
|
-
const manifestFolder =
|
|
31901
|
-
const agentsFolder =
|
|
32178
|
+
const manifestFolder = join84(cwd, AGENT_SKILL_FOLDERS.claude);
|
|
32179
|
+
const agentsFolder = join84(cwd, CLAUDE_AGENTS_FOLDER);
|
|
31902
32180
|
const previous = (readSyncManifest(manifestFolder).stationAgents ?? []).filter(
|
|
31903
32181
|
(name) => STATION_AGENT_FILE_PATTERN.test(name)
|
|
31904
32182
|
);
|
|
@@ -31912,16 +32190,16 @@ function syncStationAgents(params) {
|
|
|
31912
32190
|
const owned = [];
|
|
31913
32191
|
const produced = new Set(files.map((file) => file.name));
|
|
31914
32192
|
for (const name of previous.filter((candidate) => !produced.has(candidate))) {
|
|
31915
|
-
const path =
|
|
31916
|
-
if (!existsSync79(path) || !
|
|
32193
|
+
const path = join84(agentsFolder, name);
|
|
32194
|
+
if (!existsSync79(path) || !lstatSync12(path).isFile()) continue;
|
|
31917
32195
|
rmSync24(path);
|
|
31918
32196
|
report.removed.push(name);
|
|
31919
32197
|
}
|
|
31920
32198
|
if (report.removed.length > 0) removeFolderIfEmpty(agentsFolder);
|
|
31921
32199
|
for (const file of files) {
|
|
31922
|
-
const path =
|
|
32200
|
+
const path = join84(agentsFolder, file.name);
|
|
31923
32201
|
if (existsSync79(path)) {
|
|
31924
|
-
if (
|
|
32202
|
+
if (readFileSync58(path, "utf8") === file.content) {
|
|
31925
32203
|
owned.push(file.name);
|
|
31926
32204
|
continue;
|
|
31927
32205
|
}
|
|
@@ -31931,7 +32209,7 @@ function syncStationAgents(params) {
|
|
|
31931
32209
|
}
|
|
31932
32210
|
}
|
|
31933
32211
|
mkdirSync25(agentsFolder, { recursive: true });
|
|
31934
|
-
|
|
32212
|
+
writeFileSync32(path, file.content);
|
|
31935
32213
|
owned.push(file.name);
|
|
31936
32214
|
report.written.push(file.name);
|
|
31937
32215
|
}
|
|
@@ -31976,7 +32254,6 @@ function isSubcommand2(value) {
|
|
|
31976
32254
|
}
|
|
31977
32255
|
async function runSyncCommand(params) {
|
|
31978
32256
|
const choice = await chooseVendor(params);
|
|
31979
|
-
if (choice.exitCode === 2) return { output: choice.output, exitCode: 2 };
|
|
31980
32257
|
runSync({ argv: params.argv, cwd: params.cwd, vendor: choice.vendor });
|
|
31981
32258
|
return { output: choice.output, exitCode: 0 };
|
|
31982
32259
|
}
|
|
@@ -31991,17 +32268,15 @@ async function chooseVendor(params) {
|
|
|
31991
32268
|
cwd: params.cwd,
|
|
31992
32269
|
interactive: params.interactive
|
|
31993
32270
|
});
|
|
31994
|
-
if (resolution.kind === "set") return { vendor: resolution.vendor, output: warnings
|
|
32271
|
+
if (resolution.kind === "set") return { vendor: resolution.vendor, output: warnings };
|
|
31995
32272
|
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 };
|
|
32273
|
+
return { vendor: void 0, output: warnings + resolution.notice };
|
|
31999
32274
|
const vendor = await askVendor({
|
|
32000
32275
|
candidates: resolution.candidates,
|
|
32001
32276
|
input: params.input,
|
|
32002
32277
|
output: params.output
|
|
32003
32278
|
});
|
|
32004
|
-
return { vendor, output: warnings
|
|
32279
|
+
return { vendor, output: warnings };
|
|
32005
32280
|
}
|
|
32006
32281
|
function runSync(params) {
|
|
32007
32282
|
const { argv, cwd } = params;
|
|
@@ -32011,24 +32286,51 @@ function runSync(params) {
|
|
|
32011
32286
|
throw new Error(
|
|
32012
32287
|
`skills sync: unknown agent ${unknownAgents.join(", ")} (known: ${Object.keys(AGENT_SKILL_FOLDERS).join(", ")})`
|
|
32013
32288
|
);
|
|
32289
|
+
if (hasFlag(argv, "contributing") && hasFlag(argv, "no-contributing"))
|
|
32290
|
+
throw new Error("skills sync: --contributing and --no-contributing exclude each other");
|
|
32014
32291
|
if (params.vendor !== void 0)
|
|
32015
32292
|
for (const folder of listManifestFolders(cwd))
|
|
32016
|
-
rememberVendor({ folder:
|
|
32017
|
-
const
|
|
32293
|
+
rememberVendor({ folder: join85(cwd, folder), vendor: params.vendor });
|
|
32294
|
+
const targetFolders = agents.map((agent) => join85(cwd, AGENT_SKILL_FOLDERS[agent]));
|
|
32295
|
+
const contributing = isContributingSync({ argv, targetFolders });
|
|
32296
|
+
const discovered = discoverSkillSources({ cwd, from: getArg(argv, "from") });
|
|
32297
|
+
const { missingDependencies } = discovered;
|
|
32298
|
+
const { selected: sources, leftOut } = selectAudience({
|
|
32299
|
+
sources: discovered.sources,
|
|
32300
|
+
contributing
|
|
32301
|
+
});
|
|
32302
|
+
const leftOutNames = leftOut.map((source) => source.name);
|
|
32018
32303
|
const report = syncSkills({
|
|
32019
32304
|
sources,
|
|
32020
|
-
targetFolders
|
|
32305
|
+
targetFolders,
|
|
32021
32306
|
mode: hasFlag(argv, "copy") ? "copy" : "link",
|
|
32022
32307
|
keepUnshipped: missingDependencies.length > 0,
|
|
32023
|
-
vendor: params.vendor
|
|
32308
|
+
vendor: params.vendor,
|
|
32309
|
+
leftOut: leftOutNames,
|
|
32310
|
+
contributing
|
|
32024
32311
|
});
|
|
32025
32312
|
for (const source of sources) console.log(`\u2705 ${source.name} (${source.origin})`);
|
|
32026
|
-
for (const name of report.removed)
|
|
32313
|
+
for (const name of report.removed)
|
|
32314
|
+
console.log(
|
|
32315
|
+
leftOutNames.includes(name) ? `\u{1F5D1} ${name} (contributor skill: --contributing installs it)` : `\u{1F5D1} ${name} (no longer shipped)`
|
|
32316
|
+
);
|
|
32317
|
+
const notInstalled = leftOutNames.filter((name) => !report.removed.includes(name));
|
|
32318
|
+
if (notInstalled.length)
|
|
32319
|
+
console.log(
|
|
32320
|
+
`contributor skills not installed: ${notInstalled.join(", ")} (to change a dialecte package: --contributing)`
|
|
32321
|
+
);
|
|
32027
32322
|
syncClaudeCodeExtras({
|
|
32028
32323
|
argv,
|
|
32029
32324
|
cwd,
|
|
32030
32325
|
claudeIsTarget: agents.includes("claude"),
|
|
32031
|
-
vendor: params.vendor
|
|
32326
|
+
vendor: params.vendor,
|
|
32327
|
+
lotLeftOut: leftOutNames.includes(LOT_SKILL)
|
|
32328
|
+
});
|
|
32329
|
+
syncAgentsCheck({
|
|
32330
|
+
argv,
|
|
32331
|
+
cwd,
|
|
32332
|
+
// the check points at the doctor of the cli: enabled while this sync keeps dialecte-lot in any target
|
|
32333
|
+
enabled: targetFolders.some((folder) => readSyncManifest(folder).installed.includes(LOT_SKILL))
|
|
32032
32334
|
});
|
|
32033
32335
|
for (const path of report.conflicts)
|
|
32034
32336
|
console.warn(`\u26A0\uFE0F ${path} exists and was not installed by sync: left untouched`);
|
|
@@ -32039,9 +32341,14 @@ function runSync(params) {
|
|
|
32039
32341
|
if (sources.length === 0 && missingDependencies.length === 0)
|
|
32040
32342
|
console.log("No dependency ships skills (look for skills/<name>/SKILL.md).");
|
|
32041
32343
|
}
|
|
32344
|
+
function isContributingSync(params) {
|
|
32345
|
+
if (hasFlag(params.argv, "contributing")) return true;
|
|
32346
|
+
if (hasFlag(params.argv, "no-contributing")) return false;
|
|
32347
|
+
return params.targetFolders.some((folder) => readSyncManifest(folder).contributing === true);
|
|
32348
|
+
}
|
|
32042
32349
|
function syncClaudeCodeExtras(params) {
|
|
32043
32350
|
const { argv, cwd, claudeIsTarget } = params;
|
|
32044
|
-
const manifest = readSyncManifest(
|
|
32351
|
+
const manifest = readSyncManifest(join85(cwd, AGENT_SKILL_FOLDERS.claude));
|
|
32045
32352
|
const vendor = params.vendor ?? manifest.vendor;
|
|
32046
32353
|
const hasLot = claudeIsTarget && manifest.installed.includes(LOT_SKILL);
|
|
32047
32354
|
const plan = hasLot ? planStationAgents({ vendor: vendor !== void 0 && isVendorId(vendor) ? vendor : void 0 }) : { kind: "files", files: [] };
|
|
@@ -32052,7 +32359,9 @@ function syncClaudeCodeExtras(params) {
|
|
|
32052
32359
|
for (const path of agents.conflicts)
|
|
32053
32360
|
console.warn(`\u26A0\uFE0F ${path} exists and was not written by sync: left untouched`);
|
|
32054
32361
|
if (claudeIsTarget && !hasLot)
|
|
32055
|
-
console.log(
|
|
32362
|
+
console.log(
|
|
32363
|
+
params.lotLeftOut ? "no station agents: they come with the contributor skills (--contributing)" : `no station agents: no dependency ships the ${LOT_SKILL} skill`
|
|
32364
|
+
);
|
|
32056
32365
|
if (hasLot && agents.skippedReason) console.log(agents.skippedReason);
|
|
32057
32366
|
const session = syncSessionCheck({
|
|
32058
32367
|
cwd,
|
|
@@ -32074,6 +32383,20 @@ function syncClaudeCodeExtras(params) {
|
|
|
32074
32383
|
`\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
32384
|
);
|
|
32076
32385
|
}
|
|
32386
|
+
function syncAgentsCheck(params) {
|
|
32387
|
+
const state = syncAgentsFileCheck({
|
|
32388
|
+
cwd: params.cwd,
|
|
32389
|
+
enabled: params.enabled && !hasFlag(params.argv, "no-session-check")
|
|
32390
|
+
});
|
|
32391
|
+
if (state === "added")
|
|
32392
|
+
console.log(`\u2705 ${AGENTS_FILE}: session-start check (${SESSION_CHECK_COMMAND})`);
|
|
32393
|
+
if (state === "updated") console.log(`\u2705 ${AGENTS_FILE}: session-start check updated`);
|
|
32394
|
+
if (state === "removed") console.log(`\u{1F5D1} ${AGENTS_FILE}: session-start check removed`);
|
|
32395
|
+
if (state === "unclosed")
|
|
32396
|
+
console.warn(
|
|
32397
|
+
`\u26A0\uFE0F ${AGENTS_FILE}: the dialecte session-check section is not closed: left as it is`
|
|
32398
|
+
);
|
|
32399
|
+
}
|
|
32077
32400
|
function generatePages(params) {
|
|
32078
32401
|
const { cwd } = params;
|
|
32079
32402
|
const blocks = renderBlocks({ cwd, methods: params.methods });
|
|
@@ -32094,12 +32417,12 @@ function generatePages(params) {
|
|
|
32094
32417
|
console.error(`\u274C ${page.file}: unknown generated block "${kind}"`);
|
|
32095
32418
|
}
|
|
32096
32419
|
if (findStaleGeneratedKinds({ markdown, blocks }).length === 0) continue;
|
|
32097
|
-
|
|
32420
|
+
writeFileSync33(join85(cwd, page.file), result.markdown);
|
|
32098
32421
|
written.push(page.file);
|
|
32099
32422
|
console.log(`\u270F\uFE0F ${page.file}`);
|
|
32100
32423
|
}
|
|
32101
32424
|
for (const apiJson of staleApiJsonFiles({ cwd, methods: params.methods })) {
|
|
32102
|
-
|
|
32425
|
+
writeFileSync33(join85(cwd, apiJson.file), apiJson.content);
|
|
32103
32426
|
written.push(apiJson.file);
|
|
32104
32427
|
console.log(`\u270F\uFE0F ${apiJson.file}`);
|
|
32105
32428
|
}
|
|
@@ -32153,17 +32476,19 @@ function checkPages(params) {
|
|
|
32153
32476
|
message: `generated block "${kind}" is stale: run \`dialecte skills generate\``
|
|
32154
32477
|
});
|
|
32155
32478
|
}
|
|
32479
|
+
if (pages.some((page) => page.skillName === LOT_SKILL))
|
|
32480
|
+
findings.push(...checkStationDefinitions({ markdown: readStationsPage(cwd) }));
|
|
32156
32481
|
for (const apiJson of staleApiJsonFiles({ cwd, methods }))
|
|
32157
32482
|
findings.push({
|
|
32158
32483
|
file: apiJson.file,
|
|
32159
32484
|
severity: "error",
|
|
32160
32485
|
message: "missing or stale: run `dialecte skills generate`"
|
|
32161
32486
|
});
|
|
32162
|
-
for (const
|
|
32163
|
-
(
|
|
32164
|
-
`${
|
|
32487
|
+
for (const finding2 of findings)
|
|
32488
|
+
(finding2.severity === "error" ? console.error : console.warn)(
|
|
32489
|
+
`${finding2.severity === "error" ? "\u274C" : "\u26A0\uFE0F "} ${finding2.file}: ${finding2.message}`
|
|
32165
32490
|
);
|
|
32166
|
-
const errors = findings.filter((
|
|
32491
|
+
const errors = findings.filter((finding2) => finding2.severity === "error").length;
|
|
32167
32492
|
const methodCount = methods.filter((method) => method.entry === void 0).length;
|
|
32168
32493
|
const exportCount = indexedMethods(methods).filter(
|
|
32169
32494
|
({ entry }) => entry.entry !== void 0
|
|
@@ -32198,7 +32523,7 @@ function staleApiJsonFiles(params) {
|
|
|
32198
32523
|
buildApiJson({ packageName: readPackageName(cwd), methods: params.methods, root: cwd })
|
|
32199
32524
|
);
|
|
32200
32525
|
return pagesWithIndex.map((page) => ({ file: `${dirname36(page.file)}/${API_JSON_FILE}`, content })).filter(
|
|
32201
|
-
(apiJson) => !holdsSameJson({ path:
|
|
32526
|
+
(apiJson) => !holdsSameJson({ path: join85(cwd, apiJson.file), content: apiJson.content })
|
|
32202
32527
|
);
|
|
32203
32528
|
}
|
|
32204
32529
|
function holdsGeneratedBlock(params) {
|
|
@@ -32207,13 +32532,13 @@ function holdsGeneratedBlock(params) {
|
|
|
32207
32532
|
);
|
|
32208
32533
|
}
|
|
32209
32534
|
function readPackageName(cwd) {
|
|
32210
|
-
const manifest = JSON.parse(
|
|
32535
|
+
const manifest = JSON.parse(readFileSync59(join85(cwd, "package.json"), "utf8"));
|
|
32211
32536
|
return typeof manifest.name === "string" ? manifest.name : "";
|
|
32212
32537
|
}
|
|
32213
32538
|
function holdsSameJson(params) {
|
|
32214
32539
|
if (!existsSync80(params.path)) return false;
|
|
32215
32540
|
try {
|
|
32216
|
-
return JSON.stringify(JSON.parse(
|
|
32541
|
+
return JSON.stringify(JSON.parse(readFileSync59(params.path, "utf8"))) === JSON.stringify(JSON.parse(params.content));
|
|
32217
32542
|
} catch {
|
|
32218
32543
|
return false;
|
|
32219
32544
|
}
|
|
@@ -32228,11 +32553,15 @@ function renderBlocks(params) {
|
|
|
32228
32553
|
intents: renderIntentIndex(params.methods)
|
|
32229
32554
|
};
|
|
32230
32555
|
}
|
|
32556
|
+
function readStationsPage(cwd) {
|
|
32557
|
+
const path = join85(cwd, STATIONS_FILE);
|
|
32558
|
+
return existsSync80(path) ? readFileSync59(path, "utf8") : void 0;
|
|
32559
|
+
}
|
|
32231
32560
|
function readPage(params) {
|
|
32232
|
-
return
|
|
32561
|
+
return readFileSync59(join85(params.cwd, params.page.file), "utf8").replace(/\r\n/g, "\n");
|
|
32233
32562
|
}
|
|
32234
32563
|
function listSkillPages(cwd) {
|
|
32235
|
-
const skillsRoot =
|
|
32564
|
+
const skillsRoot = join85(cwd, SKILLS_FOLDER);
|
|
32236
32565
|
let skillNames;
|
|
32237
32566
|
try {
|
|
32238
32567
|
skillNames = readdirSync19(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -32240,7 +32569,7 @@ function listSkillPages(cwd) {
|
|
|
32240
32569
|
return [];
|
|
32241
32570
|
}
|
|
32242
32571
|
return skillNames.flatMap(
|
|
32243
|
-
(skillName) => listRepositoryPaths(
|
|
32572
|
+
(skillName) => listRepositoryPaths(join85(skillsRoot, skillName)).filter((path) => path.endsWith(".md") && !path.startsWith("evals/")).map((path) => ({
|
|
32244
32573
|
file: `${SKILLS_FOLDER}/${skillName}/${path}`,
|
|
32245
32574
|
skillName,
|
|
32246
32575
|
isSkillFile: path === "SKILL.md"
|
|
@@ -32248,22 +32577,22 @@ function listSkillPages(cwd) {
|
|
|
32248
32577
|
);
|
|
32249
32578
|
}
|
|
32250
32579
|
function siblingFilesOf(params) {
|
|
32251
|
-
const skillFolder =
|
|
32252
|
-
const pageFolder = dirname36(
|
|
32580
|
+
const skillFolder = join85(params.cwd, SKILLS_FOLDER, params.skillName);
|
|
32581
|
+
const pageFolder = dirname36(join85(params.cwd, params.page));
|
|
32253
32582
|
return new Set(
|
|
32254
32583
|
listRepositoryPaths(skillFolder).map(
|
|
32255
|
-
(path) => relative9(pageFolder,
|
|
32584
|
+
(path) => relative9(pageFolder, join85(skillFolder, path)).split(sep2).join("/")
|
|
32256
32585
|
)
|
|
32257
32586
|
);
|
|
32258
32587
|
}
|
|
32259
32588
|
|
|
32260
32589
|
// src/lib/tdd/production-states.ts
|
|
32261
|
-
import { join as
|
|
32590
|
+
import { join as join86 } from "path";
|
|
32262
32591
|
function readProductionState(params) {
|
|
32263
32592
|
const { root, base, packageJson } = params;
|
|
32264
32593
|
const files = {};
|
|
32265
32594
|
for (const file of listChangedSince({ root, base }))
|
|
32266
|
-
if (isProductionPath({ file, packageJson })) files[file] = hashFile(
|
|
32595
|
+
if (isProductionPath({ file, packageJson })) files[file] = hashFile(join86(root, file));
|
|
32267
32596
|
const deleted = readGit({
|
|
32268
32597
|
root,
|
|
32269
32598
|
args: ["diff", "--name-only", "--relative", "--no-renames", "--diff-filter=D", base]
|
|
@@ -32850,7 +33179,7 @@ function isSubcommand3(word) {
|
|
|
32850
33179
|
}
|
|
32851
33180
|
|
|
32852
33181
|
// src/commands/text.ts
|
|
32853
|
-
import { existsSync as existsSync81, readFileSync as
|
|
33182
|
+
import { existsSync as existsSync81, readFileSync as readFileSync60 } from "fs";
|
|
32854
33183
|
import { resolve as resolve27 } from "path";
|
|
32855
33184
|
|
|
32856
33185
|
// src/lib/text-check/text-check.constants.ts
|
|
@@ -32871,7 +33200,7 @@ var SUBJECT_MAX_LENGTH = 72;
|
|
|
32871
33200
|
var RECAP_START = "<details";
|
|
32872
33201
|
var HEADING_PATTERN = /^ {0,3}(#{1,6})(?:[ \t]+(.*))?$/;
|
|
32873
33202
|
var CLOSING_HASHES_PATTERN = /(^|[ \t]+)#+[ \t]*$/;
|
|
32874
|
-
var
|
|
33203
|
+
var FENCE_PATTERN2 = /^ {0,3}(`{3,}|~{3,})/;
|
|
32875
33204
|
var WORD_PATTERN = /[\p{L}\p{N}]/u;
|
|
32876
33205
|
var PROBLEM_TEXT = {
|
|
32877
33206
|
beforeFirstHeading: "text before the first heading",
|
|
@@ -32913,7 +33242,7 @@ function readHumanPart(text) {
|
|
|
32913
33242
|
for (const [index, raw] of text.split("\n").entries()) {
|
|
32914
33243
|
const line = raw.replace(/\r$/, "");
|
|
32915
33244
|
if (line.trim().startsWith(RECAP_START)) break;
|
|
32916
|
-
const fenceMark =
|
|
33245
|
+
const fenceMark = FENCE_PATTERN2.exec(line)?.[1];
|
|
32917
33246
|
if (fence !== void 0) {
|
|
32918
33247
|
if (fenceMark && fenceMark[0] === fence[0] && fenceMark.length >= fence.length && !line.trim().slice(fenceMark.length).trim())
|
|
32919
33248
|
fence = void 0;
|
|
@@ -33075,7 +33404,7 @@ function runText2(params) {
|
|
|
33075
33404
|
return renderTextCheck({
|
|
33076
33405
|
file,
|
|
33077
33406
|
kind,
|
|
33078
|
-
check: checkText({ text:
|
|
33407
|
+
check: checkText({ text: readFileSync60(path, "utf8"), kind })
|
|
33079
33408
|
});
|
|
33080
33409
|
}
|
|
33081
33410
|
function isTextKind(kind) {
|
|
@@ -33083,9 +33412,9 @@ function isTextKind(kind) {
|
|
|
33083
33412
|
}
|
|
33084
33413
|
|
|
33085
33414
|
// src/commands/worktree.ts
|
|
33086
|
-
import { spawnSync as
|
|
33415
|
+
import { spawnSync as spawnSync22 } from "child_process";
|
|
33087
33416
|
import { tmpdir as tmpdir7 } from "os";
|
|
33088
|
-
import { dirname as dirname38, join as
|
|
33417
|
+
import { dirname as dirname38, join as join88, relative as relative11, resolve as resolve28 } from "path";
|
|
33089
33418
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
33090
33419
|
|
|
33091
33420
|
// src/lib/card/render-card.ts
|
|
@@ -33137,9 +33466,9 @@ function wrapText2(params) {
|
|
|
33137
33466
|
}
|
|
33138
33467
|
|
|
33139
33468
|
// src/lib/worktree/prune-worktrees.ts
|
|
33140
|
-
import { spawnSync as
|
|
33141
|
-
import { existsSync as existsSync82, lstatSync as
|
|
33142
|
-
import { basename as basename12, dirname as dirname37, isAbsolute as isAbsolute11, join as
|
|
33469
|
+
import { spawnSync as spawnSync21 } from "child_process";
|
|
33470
|
+
import { existsSync as existsSync82, lstatSync as lstatSync13, readdirSync as readdirSync20, readFileSync as readFileSync61, realpathSync as realpathSync11, statSync as statSync13 } from "fs";
|
|
33471
|
+
import { basename as basename12, dirname as dirname37, isAbsolute as isAbsolute11, join as join87, relative as relative10, sep as sep3 } from "path";
|
|
33143
33472
|
function planPrune(params) {
|
|
33144
33473
|
const scratchRoots = [
|
|
33145
33474
|
.../* @__PURE__ */ new Set([params.scratchRoot, params.formerScratchRoot ?? params.scratchRoot])
|
|
@@ -33150,12 +33479,12 @@ function planPrune(params) {
|
|
|
33150
33479
|
});
|
|
33151
33480
|
const links = [
|
|
33152
33481
|
params.workspace,
|
|
33153
|
-
|
|
33154
|
-
|
|
33482
|
+
join87(params.workspace, WORKTREES_FOLDER),
|
|
33483
|
+
join87(params.workspace, COMMIT_PLAN_FOLDER),
|
|
33155
33484
|
...scratchRoots
|
|
33156
33485
|
].flatMap((folder) => findLinks(folder));
|
|
33157
|
-
const repositories = readdirSync20(params.workspace, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isMainCheckout(
|
|
33158
|
-
(entry) => planRepository({ repository:
|
|
33486
|
+
const repositories = readdirSync20(params.workspace, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isMainCheckout(join87(params.workspace, entry.name))).map(
|
|
33487
|
+
(entry) => planRepository({ repository: join87(params.workspace, entry.name), handovers, links })
|
|
33159
33488
|
);
|
|
33160
33489
|
const scratch = scratchRoots.flatMap(function rehearsalsIn(scratchRoot) {
|
|
33161
33490
|
if (!existsSync82(scratchRoot)) return [];
|
|
@@ -33193,7 +33522,7 @@ function planRepository(params) {
|
|
|
33193
33522
|
...worktree,
|
|
33194
33523
|
name: spellUnder({ path: worktree.path, folder: dirname37(repository) })
|
|
33195
33524
|
}));
|
|
33196
|
-
const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !existsSync82(
|
|
33525
|
+
const linkedWorktrees = worktrees.map((worktree) => worktree.name).filter((name) => isLink2(name) && !existsSync82(join87(name, ".git")));
|
|
33197
33526
|
for (const worktree of worktrees) {
|
|
33198
33527
|
const { name } = worktree;
|
|
33199
33528
|
if (isLink2(name)) {
|
|
@@ -33280,7 +33609,7 @@ function planRepository(params) {
|
|
|
33280
33609
|
function findLinks(folder) {
|
|
33281
33610
|
if (!existsSync82(folder)) return [];
|
|
33282
33611
|
return readdirSync20(folder, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink()).flatMap(function reach(entry) {
|
|
33283
|
-
const link =
|
|
33612
|
+
const link = join87(folder, entry.name);
|
|
33284
33613
|
try {
|
|
33285
33614
|
return [{ link, target: realpathSync11(link) }];
|
|
33286
33615
|
} catch {
|
|
@@ -33305,7 +33634,7 @@ function isReachedThroughLink(params) {
|
|
|
33305
33634
|
}
|
|
33306
33635
|
function isLink2(path) {
|
|
33307
33636
|
try {
|
|
33308
|
-
return
|
|
33637
|
+
return lstatSync13(path).isSymbolicLink();
|
|
33309
33638
|
} catch {
|
|
33310
33639
|
return false;
|
|
33311
33640
|
}
|
|
@@ -33315,11 +33644,11 @@ function isRemovableHandoverFolder(folder) {
|
|
|
33315
33644
|
return !readdirSync20(folder, { withFileTypes: true }).some((entry) => entry.isDirectory());
|
|
33316
33645
|
}
|
|
33317
33646
|
function isMainCheckout(folder) {
|
|
33318
|
-
const gitFolder =
|
|
33319
|
-
return existsSync82(gitFolder) &&
|
|
33647
|
+
const gitFolder = join87(folder, ".git");
|
|
33648
|
+
return existsSync82(gitFolder) && statSync13(gitFolder).isDirectory() && existsSync82(join87(gitFolder, "HEAD"));
|
|
33320
33649
|
}
|
|
33321
33650
|
function planRehearsalClone(params) {
|
|
33322
|
-
const clone =
|
|
33651
|
+
const clone = join87(params.scratchRoot, params.name);
|
|
33323
33652
|
if (isLink2(clone)) return { kind: "rehearsal clone", name: clone, kept: PRUNE_LINK_REASON };
|
|
33324
33653
|
const marker = readRehearsalMarker(rehearsalMarkerPath(clone));
|
|
33325
33654
|
if (!marker)
|
|
@@ -33344,14 +33673,14 @@ function planRehearsalClone(params) {
|
|
|
33344
33673
|
};
|
|
33345
33674
|
}
|
|
33346
33675
|
function rehearsalMarkerPath(entry) {
|
|
33347
|
-
const ownMarker =
|
|
33676
|
+
const ownMarker = join87(entry, ".git", REHEARSAL_MARKER_FILE);
|
|
33348
33677
|
if (existsSync82(ownMarker) || !isDirectory(entry)) return ownMarker;
|
|
33349
|
-
const inside = readdirSync20(entry, { withFileTypes: true }).filter((child) => child.isDirectory()).map((child) =>
|
|
33678
|
+
const inside = readdirSync20(entry, { withFileTypes: true }).filter((child) => child.isDirectory()).map((child) => join87(entry, child.name, ".git", REHEARSAL_MARKER_FILE));
|
|
33350
33679
|
return inside.find((path) => existsSync82(path)) ?? ownMarker;
|
|
33351
33680
|
}
|
|
33352
33681
|
function isDirectory(path) {
|
|
33353
33682
|
try {
|
|
33354
|
-
return
|
|
33683
|
+
return statSync13(path).isDirectory();
|
|
33355
33684
|
} catch {
|
|
33356
33685
|
return false;
|
|
33357
33686
|
}
|
|
@@ -33359,7 +33688,7 @@ function isDirectory(path) {
|
|
|
33359
33688
|
function readRehearsalMarker(path) {
|
|
33360
33689
|
if (!existsSync82(path)) return void 0;
|
|
33361
33690
|
try {
|
|
33362
|
-
const marker = JSON.parse(
|
|
33691
|
+
const marker = JSON.parse(readFileSync61(path, "utf8"));
|
|
33363
33692
|
return typeof marker.pid === "number" ? { pid: marker.pid } : void 0;
|
|
33364
33693
|
} catch {
|
|
33365
33694
|
return void 0;
|
|
@@ -33451,11 +33780,11 @@ function listWorktrees(repository) {
|
|
|
33451
33780
|
}
|
|
33452
33781
|
function spellUnder(params) {
|
|
33453
33782
|
const realFolder = realpathSync11(params.folder);
|
|
33454
|
-
return params.path.startsWith(`${realFolder}/`) ?
|
|
33783
|
+
return params.path.startsWith(`${realFolder}/`) ? join87(params.folder, params.path.slice(realFolder.length + 1)) : params.path;
|
|
33455
33784
|
}
|
|
33456
33785
|
function isSameRepository(params) {
|
|
33457
33786
|
if (!existsSync82(params.worktree)) return false;
|
|
33458
|
-
const common =
|
|
33787
|
+
const common = spawnSync21("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], {
|
|
33459
33788
|
cwd: params.worktree,
|
|
33460
33789
|
encoding: "utf8"
|
|
33461
33790
|
});
|
|
@@ -33470,7 +33799,7 @@ function handoverStateOf(handover) {
|
|
|
33470
33799
|
return existsSync82(handover.lotsFile.repository) ? handoverState(handover) : "repository missing";
|
|
33471
33800
|
}
|
|
33472
33801
|
function refExists(params) {
|
|
33473
|
-
return
|
|
33802
|
+
return spawnSync21("git", ["rev-parse", "--verify", "--quiet", params.ref], { cwd: params.root }).status === 0;
|
|
33474
33803
|
}
|
|
33475
33804
|
|
|
33476
33805
|
// src/commands/worktree.ts
|
|
@@ -33522,7 +33851,7 @@ async function runWorktreePrune(params) {
|
|
|
33522
33851
|
const plan = planPrune({
|
|
33523
33852
|
workspace,
|
|
33524
33853
|
handoverFolders: findHandoverFolders({
|
|
33525
|
-
folder:
|
|
33854
|
+
folder: join88(workspace, COMMIT_PLAN_FOLDER),
|
|
33526
33855
|
depth: LIST_DEPTH
|
|
33527
33856
|
}),
|
|
33528
33857
|
scratchRoot: params.scratchRoot,
|
|
@@ -33548,7 +33877,7 @@ worktree prune --yes asks for a confirmation on a terminal: there is none here,
|
|
|
33548
33877
|
return { exitCode: 0, output: `${report}
|
|
33549
33878
|
Nothing removed.` };
|
|
33550
33879
|
const outcomes = removals.map(function remove(item) {
|
|
33551
|
-
const result =
|
|
33880
|
+
const result = spawnSync22("sh", ["-c", item.command ?? ""], { encoding: "utf8" });
|
|
33552
33881
|
return result.status === 0 ? `\u2713 ${item.command}` : `\u2717 ${item.command}: ${(result.stderr || result.stdout).trim()}`;
|
|
33553
33882
|
});
|
|
33554
33883
|
return {
|
|
@@ -33720,21 +34049,28 @@ Examples:
|
|
|
33720
34049
|
dialecte audit # write benchmarks/types/readability-audit.md
|
|
33721
34050
|
|
|
33722
34051
|
Skills:
|
|
33723
|
-
dialecte skills sync [--agent claude,copilot,agents] [--copy] [--from <workspace>] [--
|
|
33724
|
-
|
|
33725
|
-
#
|
|
33726
|
-
#
|
|
33727
|
-
#
|
|
34052
|
+
dialecte skills sync [--agent claude,copilot,agents] [--copy] [--from <workspace>] [--contributing | --no-contributing]
|
|
34053
|
+
[--vendor <id>] [--no-session-check]
|
|
34054
|
+
# install the consumer skills of your dependencies (or of local checkouts) for your
|
|
34055
|
+
# agents; --contributing adds the contributor skills (metadata.audience: contributor,
|
|
34056
|
+
# to change a dialecte package), remembered until --no-contributing; remembers the
|
|
34057
|
+
# model vendor (detected, asked on a terminal, or --vendor; none: models unset);
|
|
34058
|
+
# with the contributor skills, writes a doctor --brief session-start check in AGENTS.md
|
|
34059
|
+
# for every agent, and for Claude Code the station agents (.claude/agents/dialecte-*.md,
|
|
34060
|
+
# adapters of the dialecte-lot skill's stations) and a SessionStart hook
|
|
34061
|
+
# (--no-session-check leaves the check out)
|
|
33728
34062
|
dialecte skills generate # rewrite the generated blocks (verb map, method index, hook files) from the source
|
|
33729
34063
|
dialecte skills check [--workspace <dir>]
|
|
33730
|
-
# fail on a cited API / path / npm script that does not exist, or a stale block
|
|
34064
|
+
# fail on a cited API / path / npm script that does not exist, or a stale block;
|
|
34065
|
+
# a dialecte-lot skill's references/stations.md must match the cli's stations
|
|
33731
34066
|
|
|
33732
34067
|
Lookups (the same with or without the repositories; --json on each):
|
|
33733
34068
|
dialecte api find "<need>" [--package <name>] [--limit 5]
|
|
33734
34069
|
# methods whose intents, summary or name match the need, best first
|
|
33735
34070
|
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
|
|
34071
|
+
dialecte members <expression> [--package <name>] [--version <v>]
|
|
34072
|
+
# one line per member of doc.query, doc.query.reference, tx.lifecycle.extract...;
|
|
34073
|
+
# in an app, of the installed dialecte (--package / --version when several)
|
|
33738
34074
|
dialecte schema <Tag> [--package <name>]
|
|
33739
34075
|
# parents, children with how often, attributes; an unknown tag answers the closest
|
|
33740
34076
|
dialecte models [--vendor <anthropic|openai|google>] [--json]
|