@kirill.konshin/lint 0.6.0 → 0.6.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.
Files changed (51) hide show
  1. package/README.md +8 -8
  2. package/dist/lib.js +2 -1
  3. package/package.json +4 -6
  4. package/skills/spec-steward/SKILL.md +2 -2
  5. package/skills/spec-steward/references/contract.md +7 -7
  6. package/skills/spec-tools/SKILL.md +3 -1
  7. package/skills/spec-tools/references/contract.md +5 -5
  8. package/skills/spec-tools/references/gitlab.md +26 -35
  9. package/skills/spec-tools/scripts/cli.js +8155 -0
  10. package/skills/spec-verify/SKILL.md +6 -6
  11. package/skills/spec-steward/scripts/lib/align.mjs +0 -127
  12. package/skills/spec-steward/scripts/lib/checks.mjs +0 -589
  13. package/skills/spec-steward/scripts/lib/citations.mjs +0 -156
  14. package/skills/spec-steward/scripts/lib/corpus.mjs +0 -256
  15. package/skills/spec-steward/scripts/lib/coverage.mjs +0 -123
  16. package/skills/spec-steward/scripts/lib/evidence.mjs +0 -189
  17. package/skills/spec-steward/scripts/lib/git.mjs +0 -138
  18. package/skills/spec-steward/scripts/lib/review.mjs +0 -347
  19. package/skills/spec-steward/scripts/lib/scan.mjs +0 -364
  20. package/skills/spec-steward/scripts/lib/util.mjs +0 -161
  21. package/skills/spec-steward/scripts/lib/wire.mjs +0 -333
  22. package/skills/spec-steward/scripts/steward.mjs +0 -289
  23. package/spec-tools/dist/audit-DkZZulq6.mjs +0 -130
  24. package/spec-tools/dist/auditChanged-CNGjlake.mjs +0 -1
  25. package/spec-tools/dist/auditChanged-CZCvMgyZ.mjs +0 -618
  26. package/spec-tools/dist/auditReport-xgq4wK2i.mjs +0 -458
  27. package/spec-tools/dist/auditScope-CBuBtfPG.mjs +0 -104
  28. package/spec-tools/dist/changeGates-DdeQKfle.mjs +0 -333
  29. package/spec-tools/dist/changeGates-uy4Ti8rK.mjs +0 -1
  30. package/spec-tools/dist/ci-BUewHJS3.mjs +0 -143
  31. package/spec-tools/dist/ci-CFBzn8Of.mjs +0 -1
  32. package/spec-tools/dist/cli.mjs +0 -93
  33. package/spec-tools/dist/comment-szasMMg2.mjs +0 -57
  34. package/spec-tools/dist/files-Bppsb34B.mjs +0 -1
  35. package/spec-tools/dist/files-QlzY687_.mjs +0 -38
  36. package/spec-tools/dist/html-BMTkpbUN.mjs +0 -1766
  37. package/spec-tools/dist/jsonrepair-Dlm5dEen.mjs +0 -742
  38. package/spec-tools/dist/repo-CjIoUPYl.mjs +0 -16
  39. package/spec-tools/dist/repo-DUcnJw3c.mjs +0 -1
  40. package/spec-tools/dist/run-BElA9du3.mjs +0 -67
  41. package/spec-tools/dist/specDiff-8G56jMYn.mjs +0 -123
  42. package/spec-tools/dist/steward-DeieyOcj.mjs +0 -34
  43. package/spec-tools/dist/stewardAudit-BRMM0lrD.mjs +0 -1
  44. package/spec-tools/dist/stewardAudit-v0vOMfLN.mjs +0 -271
  45. package/spec-tools/dist/tier-Cn0P7juM.mjs +0 -1
  46. package/spec-tools/dist/tier-c3s_mA_I.mjs +0 -65
  47. package/spec-tools/dist/util-wnxhsnWO.mjs +0 -49
  48. package/spec-tools/dist/verdict-BFfN9PO8.mjs +0 -58
  49. package/spec-tools/dist/workers-BcIgckeq.mjs +0 -417
  50. package/spec-tools/dist/workflowEvidence-DyBj8EdG.mjs +0 -1
  51. package/spec-tools/dist/workflowEvidence-oui6ghPI.mjs +0 -78
@@ -1,16 +0,0 @@
1
- import { execFileSync } from "node:child_process";
2
- //#region spec-tools/src/repo.ts
3
- let top;
4
- /**
5
- * The repository the tools run in: the working tree the current directory belongs to, a detached audit tree included.
6
- * Resolved on first use, so importing a module never needs a repository.
7
- */
8
- const root = () => top ??= execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf8" }).trim();
9
- /** A git command in a repository, the current one by default; its stdout. */
10
- const git = (args, cwd = root()) => execFileSync("git", args, {
11
- cwd,
12
- encoding: "utf8",
13
- maxBuffer: 67108864
14
- });
15
- //#endregion
16
- export { root as n, git as t };
@@ -1 +0,0 @@
1
- export { n as root } from "./repo-CjIoUPYl.mjs";
@@ -1,67 +0,0 @@
1
- import "./tier-c3s_mA_I.mjs";
2
- import { spawn } from "node:child_process";
3
- import * as fs from "node:fs";
4
- //#region spec-tools/src/run.ts
5
- /**
6
- * `spec-tools run <skill>`: one skill-driven AI review, headless — `claude --print "/<skill>"` on the run class's model
7
- * (`AUDIT_MODEL` / `AUDIT_EFFORT`, from `spec-tools tier`). The job log shows the orchestrator's text and one
8
- * timestamped line per tool call, sub-agents included (`↳`), so a long review is legible while it runs; the whole
9
- * stream is kept as `claude.jsonl`, and the final result as the job log the verdict gate recovers from. Exits with
10
- * Claude's own status, the result echoed on a failure — e.g. an API usage-limit error.
11
- */
12
- /** What a review may do: read, delegate to sub-agents, load skills, write its report — and the read-only git commands. */
13
- const REVIEW_TOOLS = "Agent,Skill,Bash(git:git diff*|git log*|git show*),Read,Glob,Grep,Write";
14
- const STREAM_FILE = "claude.jsonl";
15
- /** What one streamed event shows in the job log, or nothing. */
16
- function progress(event, now = /* @__PURE__ */ new Date()) {
17
- if (event.type === "stream_event" && event.event?.type === "content_block_delta") return event.event.delta?.text ?? "";
18
- if (event.type !== "assistant") return "";
19
- const clock = now.toTimeString().slice(0, 8);
20
- return (event.message?.content ?? []).filter((c) => c.type === "tool_use").map((c) => {
21
- const i = c.input ?? {};
22
- const what = String(i.description ?? i.file_path ?? i.pattern ?? i.command ?? "").slice(0, 120);
23
- return `[${clock}]${event.parent_tool_use_id ? " ↳" : ""} ${c.name} ${what}\n`;
24
- }).join("");
25
- }
26
- async function run(skill, log, env = process.env) {
27
- const args = [
28
- "--print",
29
- `/${skill}`,
30
- "--model",
31
- env.AUDIT_MODEL || "claude-haiku-4-5-20251001",
32
- "--effort",
33
- env.AUDIT_EFFORT || "high"
34
- ];
35
- args.push("--output-format", "stream-json", "--verbose", "--include-partial-messages", "--allowedTools", REVIEW_TOOLS);
36
- const stream = fs.createWriteStream(STREAM_FILE);
37
- const child = spawn("claude", args, {
38
- env,
39
- stdio: [
40
- "ignore",
41
- "pipe",
42
- "inherit"
43
- ]
44
- });
45
- let result = "";
46
- let pending = "";
47
- child.stdout.on("data", (chunk) => {
48
- stream.write(chunk);
49
- const lines = (pending + chunk.toString("utf8")).split("\n");
50
- pending = lines.pop() ?? "";
51
- for (const line of lines) try {
52
- const event = JSON.parse(line);
53
- if (event.type === "result") result = event.result ?? "";
54
- process.stdout.write(progress(event));
55
- } catch {}
56
- });
57
- const code = await new Promise((resolve) => {
58
- child.on("error", () => resolve(127));
59
- child.on("close", (c) => resolve(c ?? 1));
60
- });
61
- await new Promise((resolve) => stream.end(resolve));
62
- fs.writeFileSync(log, result ? `${result}\n` : "");
63
- if (code !== 0) console.error(`ERROR: claude exited ${code}:\n${result}`);
64
- return code;
65
- }
66
- //#endregion
67
- export { run };
@@ -1,123 +0,0 @@
1
- import { n as root } from "./repo-CjIoUPYl.mjs";
2
- import { t as diffBase } from "./ci-BUewHJS3.mjs";
3
- import { a as normalizeBlock, c as requirementsAt, s as requirementBlocks, t as capabilitySpecs, u as specMovesSince } from "./changeGates-DdeQKfle.mjs";
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
- //#region spec-tools/src/specDiff.ts
7
- /**
8
- * The reviewer's view of a specification change: the standing requirements ADDED, MODIFIED, REMOVED
9
- * or RENAMED between a base ref and the working tree, by `### Requirement:` heading, each with its
10
- * full block, and the capabilities MOVED to a new path — what a delta used to spell out by hand,
11
- * computed from git instead. A report, never a
12
- * gate: it always exits 0, writes `spec-diff.md` at the repository root and prints it, and CI
13
- * publishes it beside the merge request. The base is the merge request's (`diffBase`) — or `HEAD`,
14
- * the working tree's own edits, for an author's preview — unless a ref is given as the first argument.
15
- *
16
- * Usage: spec-tools diff [<base ref>]
17
- */
18
- const DIFF_FILE = "spec-diff.md";
19
- const id = (r) => `${r.file}#${r.slug}`;
20
- /** The block without its heading line, normalized — what a rename keeps and an edit changes. */
21
- const body = (r) => normalizeBlock(r.block.split("\n").slice(1).join("\n"));
22
- /**
23
- * ADDED is a heading only the head has, REMOVED one only the base has, MODIFIED one on both sides
24
- * whose block differs beyond whitespace. A REMOVED and an ADDED in the same file with the same body
25
- * are one RENAMED, paired once each; a rename that also edits the body stays a REMOVED and an ADDED.
26
- */
27
- function classify(base, head) {
28
- const baseById = new Map(base.map((r) => [id(r), r]));
29
- const headById = new Map(head.map((r) => [id(r), r]));
30
- let added = head.filter((r) => !baseById.has(id(r)));
31
- let removed = base.filter((r) => !headById.has(id(r)));
32
- const modified = head.flatMap((after) => {
33
- const before = baseById.get(id(after));
34
- return before && normalizeBlock(before.block) !== normalizeBlock(after.block) ? [{
35
- before,
36
- after
37
- }] : [];
38
- });
39
- const renamed = [];
40
- for (const from of [...removed]) {
41
- const to = added.find((a) => a.file === from.file && body(a) === body(from));
42
- if (!to) continue;
43
- renamed.push({
44
- from,
45
- to
46
- });
47
- added = added.filter((a) => a !== to);
48
- removed = removed.filter((r) => r !== from);
49
- }
50
- return {
51
- added,
52
- modified,
53
- removed,
54
- renamed
55
- };
56
- }
57
- const capabilityOf = (file) => path.dirname(file).replace(/^openspec\/specs\//, "");
58
- /** The spec files git sees renamed, as capability paths — a moved requirement is compared under its new path. */
59
- const capabilityMoves = (moves) => [...moves].map(([from, to]) => ({
60
- from: capabilityOf(from),
61
- to: capabilityOf(to)
62
- }));
63
- const fence = (block) => [
64
- "```markdown",
65
- block,
66
- "```"
67
- ].join("\n");
68
- const where = (r) => `\`${r.file}:${r.line}\``;
69
- /** The report: a fixed first line CI can read, then one section per operation with every block in full. */
70
- function render(diff, base, moved = []) {
71
- const total = diff.added.length + diff.modified.length + diff.removed.length + diff.renamed.length;
72
- const out = [
73
- `SPEC DIFF ${total} changed (${diff.added.length} added, ${diff.modified.length} modified, ${diff.removed.length} removed, ${diff.renamed.length} renamed)`,
74
- "",
75
- `Standing requirements of \`openspec/specs/\` against \`${base}\`, by heading. A report, not a gate: the reviewer's view of a specification change.`,
76
- ""
77
- ];
78
- if (moved.length) {
79
- out.push("## MOVED", "");
80
- for (const { from, to } of moved) out.push(`- ${from} → ${to}`);
81
- out.push("", "A moved requirement is compared under its new path; one not listed below moved unchanged.", "");
82
- }
83
- if (total === 0) return [
84
- ...out,
85
- "No requirement changed.",
86
- ""
87
- ].join("\n");
88
- if (diff.added.length) {
89
- out.push("## ADDED", "");
90
- for (const r of diff.added) out.push(`### ${r.capability}#${r.slug}`, "", where(r), "", fence(r.block), "");
91
- }
92
- if (diff.modified.length) {
93
- out.push("## MODIFIED", "");
94
- for (const { before, after } of diff.modified) {
95
- out.push(`### ${after.capability}#${after.slug}`, "", where(after), "", fence(after.block), "");
96
- out.push("<details>", "<summary>before</summary>", "", fence(before.block), "", "</details>", "");
97
- }
98
- }
99
- if (diff.removed.length) {
100
- out.push("## REMOVED", "");
101
- for (const r of diff.removed) out.push(`### ${r.capability}#${r.slug}`, "", `was ${where(r)}`, "", fence(r.block), "");
102
- }
103
- if (diff.renamed.length) {
104
- out.push("## RENAMED", "");
105
- for (const { from, to } of diff.renamed) out.push(`- ${from.capability}#${from.slug} → ${to.capability}#${to.slug} (${where(to)}, body unchanged)`);
106
- out.push("");
107
- }
108
- out.push("A removed or renamed heading takes its anchor with it; `spec-steward check` fails every citation that no longer resolves.", "");
109
- return out.join("\n");
110
- }
111
- /** The working tree's requirement blocks, cut by the same rule as the base's. */
112
- function requirementsInTree() {
113
- return capabilitySpecs().flatMap((spec) => requirementBlocks(spec.file, fs.readFileSync(path.join(root(), spec.file), "utf8")));
114
- }
115
- /** `argv` is what follows the command — `[base]` — never the process's own arguments, which start with it. */
116
- function main(argv = [], env = process.env) {
117
- const base = argv[0] ?? diffBase(env);
118
- const text = render(classify(requirementsAt(base), requirementsInTree()), base, capabilityMoves(specMovesSince(base)));
119
- fs.writeFileSync(path.join(root(), DIFF_FILE), text);
120
- return text;
121
- }
122
- //#endregion
123
- export { main };
@@ -1,34 +0,0 @@
1
- import { r as EVIDENCE_FILE } from "./files-QlzY687_.mjs";
2
- import { spawnSync } from "node:child_process";
3
- import * as fs from "node:fs";
4
- import * as path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- //#region spec-tools/src/steward.ts
7
- /** spec-steward's CLI in this package — beside the source and beside the build alike, two levels below the package. */
8
- const STEWARD = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../skills/spec-steward/scripts/steward.mjs");
9
- /** spec-steward with its output on this terminal; its exit code. Binds come from the repository's own configuration. */
10
- const steward = (args, cwd) => spawnSync(process.execPath, [STEWARD, ...args], {
11
- cwd,
12
- stdio: "inherit"
13
- }).status ?? 1;
14
- /** spec-steward's evidence model, written to the repository root for the scope and the focused check to read. */
15
- function writeEvidence(cwd) {
16
- const run = spawnSync(process.execPath, [
17
- STEWARD,
18
- "evidence",
19
- "--json"
20
- ], {
21
- cwd,
22
- encoding: "utf8",
23
- maxBuffer: 536870912,
24
- stdio: [
25
- "ignore",
26
- "pipe",
27
- "inherit"
28
- ]
29
- });
30
- if (run.status !== 0) throw new Error(`spec-steward evidence exited ${run.status}`);
31
- fs.writeFileSync(path.join(cwd, EVIDENCE_FILE), run.stdout);
32
- }
33
- //#endregion
34
- export { steward, writeEvidence };
@@ -1 +0,0 @@
1
- export { i as merge } from "./stewardAudit-v0vOMfLN.mjs";
@@ -1,271 +0,0 @@
1
- import { d as findingsFile, t as AUDIT_FILES } from "./files-QlzY687_.mjs";
2
- import { n as root, t as git } from "./repo-CjIoUPYl.mjs";
3
- import { t as globToRegExp } from "./util-wnxhsnWO.mjs";
4
- import { t as jsonrepair } from "./jsonrepair-Dlm5dEen.mjs";
5
- import { spawnSync } from "node:child_process";
6
- import * as fs from "node:fs";
7
- import * as path from "node:path";
8
- import { fileURLToPath } from "node:url";
9
- //#region spec-tools/src/stewardAudit.ts
10
- /**
11
- * spec-steward's corpus-quality audit on the shared engine: the same evidence, partition, workers, completion and
12
- * verification passes as spec-verify, with spec-steward's worker contract (`skills/spec-steward/references/worker.md`),
13
- * its sweeps (`skills/spec-steward/sweeps.json`) as units beside the capability parts, a skeptic verifier for every
14
- * finding, and a mechanical merge into the review file `spec-steward review render` writes — the owner's to answer.
15
- * What `workflows/audit.js` once did with model passes is mechanical here: a quote not at its line drops the finding,
16
- * the judged lists stand for the critic, and findings sharing a theme key are offered as a theme for the operator to
17
- * sharpen.
18
- */
19
- const FILES = AUDIT_FILES["spec-steward"];
20
- const SKILLS = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../skills");
21
- const STEWARD_CLI = path.join(SKILLS, "spec-steward/scripts/steward.mjs");
22
- /** The skill's sweeps, each a unit numbered after the last capability part, its files resolved in this repository. */
23
- function sweepUnits(model, after, cwd = root()) {
24
- const sweeps = JSON.parse(fs.readFileSync(path.join(SKILLS, "spec-steward/sweeps.json"), "utf8"));
25
- const tracked = git([
26
- "ls-files",
27
- "-co",
28
- "--exclude-standard"
29
- ], cwd).split("\n").filter(Boolean);
30
- const fromEvidence = (kind) => [...new Set(model.requirements.flatMap((r) => r[kind].map((b) => b.file)))];
31
- return sweeps.map((sweep, i) => {
32
- const patterns = (sweep.files ?? []).map((glob) => new RegExp(`^${globToRegExp(glob).source.replace(/^\^/, "")}`));
33
- const files = sweep.from ? fromEvidence(sweep.from) : tracked.filter((file) => patterns.some((re) => re.test(file)));
34
- const part = after + i + 1;
35
- return {
36
- part,
37
- capabilities: [],
38
- files: files.sort(),
39
- findings: [findingsFile(part, 1, "spec-steward")],
40
- requirementIds: [],
41
- bytes: 0,
42
- requirements: 0,
43
- sweep: {
44
- key: sweep.key,
45
- title: sweep.title,
46
- focus: sweep.focus
47
- }
48
- };
49
- });
50
- }
51
- const LOAD_SKILL = (repo) => `First, load the skill: use the Skill tool with skill "spec-steward" (or Read ${path.relative(repo, path.join(SKILLS, "spec-steward/SKILL.md"))} if that fails), then Read its references/worker.md, references/model.md and references/criteria.md, and the placement guide ${path.relative(repo, path.join(SKILLS, "../rules/agent.md"))}, in full. worker.md is your contract: follow it exactly.`;
52
- const TOOL_RULE = "Tool rule: only Skill, Read, Glob, Grep, Write and the read-only git commands — no ls/cat/find, no shell validation of your JSON; other commands are denied here and only cost a turn.";
53
- const unitLine = (p) => p.sweep ? `- sweep: ${p.sweep.title} — ${p.sweep.focus}\n- files to read (Grep within a large one): ${p.files.join(", ") || "(none found — say so in notes)"}` : `- capabilities: ${p.capabilities.join(", ")}\n- evidence files to read in full, then the specifications they name: ${p.files.join(", ")}\n- requirementIds (judged must cover exactly these):\n${p.requirementIds.join("\n")}`;
54
- /** The reading brief: one unit, judged against every criterion. */
55
- const brief = (p, repo) => `You are a worker for spec-steward's corpus-quality audit in repo ${repo}.
56
-
57
- ${LOAD_SKILL(repo)}
58
-
59
- Your assignment:
60
- - part: ${p.part}
61
- - reader: 1
62
- - findings file to write (Write tool, overwrite, nothing else): ${p.findings[0]}
63
- ${unitLine(p)}
64
-
65
- ${TOOL_RULE} Write the findings file exactly at the path above, then return one line: the path and your count of findings.
66
- `;
67
- /** The completion brief: what the first pass left — requirements no judged list names, or a unit that wrote nothing. */
68
- const briefComplete = (p, short, reader, file, repo) => {
69
- const ids = short.requirementIds.length ? short.requirementIds.join("\n") : "(the whole unit)";
70
- return `You are a completion worker for spec-steward's corpus-quality audit in repo ${repo}. The first pass over part ${p.part} was left short; judge exactly what it left, and nothing else.
71
-
72
- ${LOAD_SKILL(repo)}
73
-
74
- Your assignment:
75
- - part: ${p.part}
76
- - reader: ${reader}
77
- - findings file to write (Write tool, overwrite, nothing else): ${file}
78
- ${unitLine(p)}
79
- - left unjudged — judge each against every criterion:
80
- ${ids}
81
-
82
- Your judged list names exactly what you judged here. ${TOOL_RULE} Write the findings file exactly at the path above, then return one line: the path and your count of findings.
83
- `;
84
- };
85
- /** The verifier's brief: one finding, the skeptic's questions, the verdict file. */
86
- const briefVerify = (f, file, repo) => {
87
- const { quote, ruleName, criteria, layer, whatsWrong, proposed, evidence, themeKey, needsHumanIntent } = f;
88
- const finding = {
89
- file: f.file,
90
- line: f.line,
91
- quote,
92
- ruleName,
93
- criteria,
94
- layer,
95
- whatsWrong,
96
- proposed,
97
- evidence,
98
- themeKey,
99
- needsHumanIntent
100
- };
101
- return `You are the skeptic verifying ONE finding of spec-steward's corpus-quality audit in repo ${repo}. Its quote was found at its line mechanically. Judge it by spec-steward's references/model.md and references/criteria.md and the placement guide ${path.relative(repo, path.join(SKILLS, "../rules/agent.md"))}, reading with Read and Grep only.
102
-
103
- The finding:
104
- ${JSON.stringify(finding, null, 2)}
105
-
106
- - It silently decides an intent that is genuinely ambiguous → revise: needsHumanIntent true, the options in proposed.
107
- - It is a style preference, an ordinary implementation bug, or speculation → drop.
108
- - Its proposed verification would catch no real failure (compliance theatre) → revise or drop.
109
- - It moves an internal contract out of the specification only because it is not user-facing → revise.
110
- - Its target layer contradicts the placement guide → revise.
111
- - It reverses a past owner decision without saying so → revise reversesPastDecision.
112
- - A claim about code, tests, tooling or CI is false → revise it, or drop when the finding rests on it.
113
- Default to keep when the finding is concrete, grounded and its proposal sound; sharpen wording where it helps the owner decide.
114
-
115
- Write exactly this JSON with the Write tool to ${file} and nothing else:
116
- {"verdict": "keep" | "revise" | "drop", "reason": "<one sentence>", "revised": {<only the fields you change>}}
117
- Then return one line: the path and the verdict.
118
- `;
119
- };
120
- const normalize = (text) => text.replace(/\s+/g, " ").trim();
121
- /** Whether a quote is in the block that starts at its line: each piece between `…` elisions, in order. */
122
- function quoteAt(quote, lines, line) {
123
- if (!lines || line < 1) return false;
124
- const block = normalize(lines.slice(line - 1, line + 39).join(" "));
125
- let from = 0;
126
- for (const piece of quote.split("…").map(normalize).filter(Boolean)) {
127
- const at = block.indexOf(piece, from);
128
- if (at < 0) return false;
129
- from = at + piece.length;
130
- }
131
- return from > 0;
132
- }
133
- /** The capability a specification file belongs to, else the unit that found it. */
134
- const areaOf = (file, unit) => /^openspec\/specs\/(.+)\/spec\.md$/.exec(file)?.[1] ?? unit?.sweep?.key ?? `part-${unit?.part ?? "?"}`;
135
- const readJson = (file) => {
136
- try {
137
- return JSON.parse(jsonrepair(fs.readFileSync(file, "utf8")));
138
- } catch {
139
- return;
140
- }
141
- };
142
- const words = (key) => key.replace(/-/g, " ").replace(/^./, (c) => c.toUpperCase());
143
- /**
144
- * The merge: every reader's findings, their quotes re-proved at their lines, the verifiers' verdicts applied, duplicates
145
- * folded, theme candidates grouped, coverage checked against the judged lists. Writes the data and renders the review
146
- * file; returns the one-line summary.
147
- */
148
- function merge(read, cwd = root()) {
149
- const scope = readJson(path.join(cwd, FILES.scope));
150
- if (!scope) throw new Error(`${FILES.scope} is missing — run spec-tools scope --audit spec-steward first`);
151
- const repo = path.basename(cwd);
152
- const dir = path.join(cwd, FILES.findings);
153
- const present = fs.existsSync(dir) ? fs.readdirSync(dir) : [];
154
- const candidates = [];
155
- const sound = /* @__PURE__ */ new Set();
156
- const notes = [];
157
- const short = [];
158
- const dropped = [];
159
- for (const unit of scope.parts) {
160
- const files = present.filter((f) => new RegExp(`^part-${unit.part}-\\d+\\.json$`).test(f)).sort();
161
- const judged = /* @__PURE__ */ new Set();
162
- for (const name of files) {
163
- const data = readJson(path.join(dir, name));
164
- if (!data) {
165
- notes.push(`\`${FILES.findings}/${name}\` is not valid JSON — its part is judged again by the completion pass.`);
166
- continue;
167
- }
168
- for (const id of data.judged ?? []) judged.add(id);
169
- for (const id of data.sound ?? []) sound.add(id);
170
- for (const n of data.notes ?? []) notes.push(`part ${unit.part}: ${n}`);
171
- for (const f of data.findings ?? []) {
172
- const candidate = {
173
- ...f,
174
- part: unit.part,
175
- repo,
176
- area: areaOf(f.file, unit)
177
- };
178
- if (quoteAt(f.quote, read(f.file), f.line)) candidates.push(candidate);
179
- else dropped.push({
180
- ...candidate,
181
- droppedBy: "facts",
182
- reason: `the quote is not at ${f.file}:${f.line}`
183
- });
184
- }
185
- }
186
- const missing = unit.requirementIds.filter((id) => !judged.has(id));
187
- if (!files.length) short.push({
188
- part: unit.part,
189
- requirementIds: [],
190
- checks: {}
191
- });
192
- else if (missing.length) short.push({
193
- part: unit.part,
194
- requirementIds: missing,
195
- checks: {}
196
- });
197
- }
198
- const kept = [];
199
- candidates.forEach((c, i) => {
200
- const verdict = readJson(path.join(dir, `verdict-${i + 1}.json`));
201
- if (verdict?.verdict === "drop") dropped.push({
202
- ...c,
203
- droppedBy: "verifier",
204
- reason: verdict.reason
205
- });
206
- else kept.push(verdict?.verdict === "revise" ? {
207
- ...c,
208
- ...verdict.revised,
209
- part: c.part,
210
- repo,
211
- area: c.area
212
- } : c);
213
- });
214
- const unique = /* @__PURE__ */ new Map();
215
- for (const c of kept) {
216
- const key = `${c.file}:${c.line}:${c.themeKey ?? ""}`;
217
- const seen = unique.get(key);
218
- if (!seen) unique.set(key, c);
219
- else unique.set(key, {
220
- ...seen,
221
- criteria: [.../* @__PURE__ */ new Set([...seen.criteria ?? [], ...c.criteria ?? []])],
222
- evidence: [.../* @__PURE__ */ new Set([...seen.evidence ?? [], ...c.evidence ?? []])]
223
- });
224
- }
225
- const byTheme = /* @__PURE__ */ new Map();
226
- for (const c of unique.values()) if (c.themeKey) byTheme.set(c.themeKey, [...byTheme.get(c.themeKey) ?? [], c]);
227
- const themes = [...byTheme.entries()].filter(([, members]) => members.length >= 3).map(([key, members]) => {
228
- const layers = members.map((m) => m.layer);
229
- const layer = layers.sort((a, b) => layers.filter((l) => l === b).length - layers.filter((l) => l === a).length)[0];
230
- return {
231
- key,
232
- title: words(key),
233
- whatsWrong: members[0].whatsWrong,
234
- proposed: members[0].proposed,
235
- layer,
236
- criteria: [...new Set(members.flatMap((m) => m.criteria ?? []))].sort((a, b) => a - b),
237
- needsHumanIntent: members.some((m) => m.needsHumanIntent),
238
- members
239
- };
240
- });
241
- const themed = new Set(themes.flatMap((t) => t.members));
242
- const findings = [...unique.values()].filter((c) => !themed.has(c));
243
- const summary = `REVIEW ${findings.length + themes.length} item(s) (${themes.length} theme(s)), ${dropped.length} dropped${short.length ? `, ${short.length} part(s) short` : ""}`;
244
- const data = {
245
- summary,
246
- candidates,
247
- themes,
248
- findings,
249
- sound: [...sound].sort(),
250
- dropped,
251
- short,
252
- notes
253
- };
254
- fs.mkdirSync(path.dirname(path.join(cwd, FILES.data)), { recursive: true });
255
- fs.writeFileSync(path.join(cwd, FILES.data), JSON.stringify(data, null, 2) + "\n");
256
- const render = spawnSync(process.execPath, [
257
- STEWARD_CLI,
258
- "review",
259
- "render",
260
- FILES.data,
261
- "--out",
262
- FILES.report
263
- ], {
264
- cwd,
265
- encoding: "utf8"
266
- });
267
- if (render.status !== 0) throw new Error(`spec-steward review render failed: ${render.stderr}`);
268
- return `${summary} → ${FILES.report}`;
269
- }
270
- //#endregion
271
- export { quoteAt as a, merge as i, briefComplete as n, sweepUnits as o, briefVerify as r, brief as t };
@@ -1 +0,0 @@
1
- export { a as dotenv, s as tier } from "./tier-c3s_mA_I.mjs";
@@ -1,65 +0,0 @@
1
- import { a as mergeRequest, n as gateBase, r as isNightly } from "./ci-BUewHJS3.mjs";
2
- import { f as syncedUnarchivedChanges, n as deltaFilesInOpenChanges, p as touchedOpenChanges } from "./changeGates-DdeQKfle.mjs";
3
- import { t as classify } from "./workflowEvidence-oui6ghPI.mjs";
4
- //#region spec-tools/src/tier.ts
5
- /**
6
- * The one place a run's audit class is decided, and the only description of the run classes — documents and skills
7
- * point here. Every job reads the answer and none carries model or tier logic of its own: `spec-tools tier` prints it
8
- * as dotenv lines (KEY=value) that the first audit job sources and hands on as a dotenv artifact, so the audit jobs
9
- * after it and the review renderer act on the same decision.
10
- *
11
- * run decided by scope judge gating
12
- * nightly the pipeline's SPEC_AUDIT_NIGHTLY=true corpus expensive advisory
13
- * draft a draft merge request affected cheap advisory
14
- * open-change a merge request touching an open change, with affected cheap advisory
15
- * deltas (workflow-evidence blocks its merge) or
16
- * without (a `skip_specs` folder not yet archived)
17
- * merge-request a merge request touching no open change affected cheap gating
18
- * default-branch anything else: a default-branch push affected expensive gating
19
- *
20
- * Only the nightly audits the corpus. Every other run audits its affected set (`auditChanged.ts`) against the diff
21
- * base `ci.ts` names. Every run reads on the cheap model (AUDIT_MODEL / AUDIT_EFFORT) — the reading and the completion
22
- * pass alike; the judge — the verifier of every ERROR the reading left standing — runs on AUDIT_MODEL_VERIFY /
23
- * AUDIT_EFFORT_VERIFY: the expensive model where the run is the default branch's (a push, the nightly), the cheap one
24
- * on a merge request. Each run stands alone. The nightly reports and never gates: two nightlies over the same commit
25
- * can find different ERRORs.
26
- *
27
- * The rows are decided in that order. Which open changes a merge request touches, and whether they carry deltas, is
28
- * workflow-evidence's classification against the gate base; a classification that fails fails the run class, rather
29
- * than reading as a request that touches nothing. The model and effort here reach every worker of the audit; a
30
- * skill's frontmatter applies to an in-chat run only.
31
- */
32
- const CHEAP_MODEL = "claude-haiku-4-5-20251001";
33
- const CHEAP_EFFORT = "high";
34
- const EXPENSIVE_MODEL = "claude-sonnet-5";
35
- const EXPENSIVE_EFFORT = "medium";
36
- /** The open changes this merge request touches, by workflow-evidence's classification against the gate base. */
37
- function openChangeClass(env = process.env) {
38
- const base = gateBase(env);
39
- const touched = base === null ? [] : touchedOpenChanges(base);
40
- return classify(touched, {
41
- openDeltas: deltaFilesInOpenChanges(),
42
- syncedUnarchived: syncedUnarchivedChanges()
43
- });
44
- }
45
- /** The run class and what follows from it; `openChange` answers only for a non-draft merge request. */
46
- function tier(env = process.env, openChange = () => openChangeClass(env)) {
47
- const mr = mergeRequest(env);
48
- const run = isNightly(env) ? "nightly" : !mr ? "default-branch" : mr.draft ? "draft" : openChange() === "none" ? "merge-request" : "open-change";
49
- const cheap = [env.AUDIT_MODEL_CHEAP || "claude-haiku-4-5-20251001", env.AUDIT_EFFORT_CHEAP || "high"];
50
- const expensive = [env.AUDIT_MODEL_EXPENSIVE || "claude-sonnet-5", env.AUDIT_EFFORT_EXPENSIVE || "medium"];
51
- const judge = run === "nightly" || run === "default-branch" ? expensive : cheap;
52
- return {
53
- AUDIT_RUN: run,
54
- AUDIT_SCOPE: run === "nightly" ? "corpus" : "affected",
55
- AUDIT_GATING: run === "merge-request" || run === "default-branch" ? "gating" : "advisory",
56
- AUDIT_MODEL: cheap[0],
57
- AUDIT_EFFORT: cheap[1],
58
- AUDIT_MODEL_VERIFY: judge[0],
59
- AUDIT_EFFORT_VERIFY: judge[1]
60
- };
61
- }
62
- /** `spec-tools tier`: the run class as dotenv lines. */
63
- const dotenv = (t) => Object.entries(t).map(([key, value]) => `${key}=${value}`).join("\n") + "\n";
64
- //#endregion
65
- export { dotenv as a, EXPENSIVE_MODEL as i, CHEAP_MODEL as n, openChangeClass as o, EXPENSIVE_EFFORT as r, tier as s, CHEAP_EFFORT as t };
@@ -1,49 +0,0 @@
1
- //#region skills/spec-steward/scripts/lib/util.mjs
2
- /** Text helpers shared by every steward command: slugs, tokens, RFC 2119 keywords, absolutes. */
3
- /**
4
- * GitHub/Docusaurus heading slug (github-slugger semantics): lowercase, drop punctuation and symbols, every space
5
- * becomes a hyphen (runs are NOT collapsed, so `a — b` is `a--b`). `seen` makes repeats unique the way a rendered
6
- * page does (`x`, `x-1`, `x-2`).
7
- *
8
- * @param {string} heading
9
- * @param {Map<string, number>} [seen]
10
- */
11
- function slugify(heading, seen) {
12
- const base = heading.toLowerCase().trim().replace(/[^\p{L}\p{N}\p{M}\p{Pc} -]/gu, "").replace(/ /g, "-");
13
- if (!seen) return base;
14
- let slug = base;
15
- while (seen.has(slug)) {
16
- const next = (seen.get(base) ?? 0) + 1;
17
- seen.set(base, next);
18
- slug = `${base}-${next}`;
19
- }
20
- seen.set(slug, 0);
21
- return slug;
22
- }
23
- new Set("the a an and or of to in on for with by from at as is are be been was were it its this that these those when then which who what where while if else not no any all each every one two than into onto via per their there them they his her our your can may must shall should will would could does do did has have had only also more most less such same other another so but nor yet very just over under between within without about after before during because both either neither".split(" "));
24
- /** @param {string} s */
25
- const escapeRe = (s) => s.replace(/[.+^$()|[\]\\]/g, "\\$&");
26
- /**
27
- * A repository-relative glob as a RegExp: `**` spans directories, `*` and `?` stay inside one, `{a,b}` alternates.
28
- * @param {string} glob
29
- */
30
- function globToRegExp(glob) {
31
- let re = "";
32
- for (let i = 0; i < glob.length; i++) {
33
- const c = glob[i];
34
- const end = c === "{" ? glob.indexOf("}", i) : -1;
35
- if (c === "*" && glob[i + 1] === "*") {
36
- const slash = glob[i + 2] === "/";
37
- re += slash ? "(?:.*/)?" : ".*";
38
- i += slash ? 2 : 1;
39
- } else if (c === "*") re += "[^/]*";
40
- else if (c === "?") re += "[^/]";
41
- else if (end > i) {
42
- re += `(?:${glob.slice(i + 1, end).split(",").map(escapeRe).join("|")})`;
43
- i = end;
44
- } else re += escapeRe(c);
45
- }
46
- return new RegExp(`^${re}$`);
47
- }
48
- //#endregion
49
- export { slugify as n, globToRegExp as t };