📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
/** Canonical list of valid mode names — import from here to avoid drift. */
|
||||
export const VALID_MODES = ["review", "audit", "debt", "test", "health"];
|
||||
export const VALID_MODES = ["review", "audit", "debt", "test", "health", "sweep"];
|
||||
|
||||
/**
|
||||
* Assemble the system prompt for a given brooks-lint mode.
|
||||
@@ -25,7 +25,7 @@ export function assembleSystemPrompt(mode, skillsDir) {
|
||||
// Add risk definitions based on mode
|
||||
if (mode === "test") {
|
||||
sections.push(read(path.join(sharedDir, "test-decay-risks.md")));
|
||||
} else if (mode === "health") {
|
||||
} else if (mode === "health" || mode === "sweep") {
|
||||
sections.push(read(path.join(sharedDir, "decay-risks.md")));
|
||||
sections.push(read(path.join(sharedDir, "test-decay-risks.md")));
|
||||
} else {
|
||||
@@ -39,6 +39,7 @@ export function assembleSystemPrompt(mode, skillsDir) {
|
||||
debt: ["brooks-debt", "debt-guide.md"],
|
||||
test: ["brooks-test", "test-guide.md"],
|
||||
health: ["brooks-health", "health-guide.md"],
|
||||
sweep: ["brooks-sweep", "sweep-guide.md"],
|
||||
};
|
||||
|
||||
const [modeDir, guideFile] = guideMap[mode] ?? (() => { throw new Error(`Unknown mode: ${mode}`); })();
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
* validation run on import.
|
||||
*/
|
||||
|
||||
function normalizeNewlines(text) {
|
||||
return text.replace(/\r\n/g, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the `books:` list from a YAML frontmatter block at the top of a
|
||||
* markdown file. Returns an array of book title strings, or null if the
|
||||
@@ -23,7 +27,8 @@
|
||||
* other special characters — the only delimiter is the line break.
|
||||
*/
|
||||
export function parseFrontmatterBooks(text) {
|
||||
const match = text.match(/^---\n([\s\S]*?)\n---/);
|
||||
const normalized = normalizeNewlines(text);
|
||||
const match = normalized.match(/^---\n([\s\S]*?)\n---/);
|
||||
if (!match) return null;
|
||||
const booksSection = match[1].match(/^books:\n((?:[ \t]+-[^\n]+\n?)+)/m);
|
||||
if (!booksSection) return null;
|
||||
@@ -38,7 +43,7 @@ export function parseFrontmatterBooks(text) {
|
||||
* Each book section uses the pattern: ## Author Name — *Book Title*
|
||||
*/
|
||||
export function countBookSections(text) {
|
||||
return (text.match(/^## .+ — \*/gm) ?? []).length;
|
||||
return (normalizeNewlines(text).match(/^## .+ — \*/gm) ?? []).length;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +51,7 @@ export function countBookSections(text) {
|
||||
* Each risk section uses the pattern: ## Risk N: Title
|
||||
*/
|
||||
export function countProductionRisks(text) {
|
||||
return (text.match(/^## Risk \d+:/gm) ?? []).length;
|
||||
return (normalizeNewlines(text).match(/^## Risk \d+:/gm) ?? []).length;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +59,7 @@ export function countProductionRisks(text) {
|
||||
* Each risk section uses the pattern: ## Risk TN: Title
|
||||
*/
|
||||
export function countTestRisks(text) {
|
||||
return (text.match(/^## Risk T\d+:/gm) ?? []).length;
|
||||
return (normalizeNewlines(text).match(/^## Risk T\d+:/gm) ?? []).length;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +67,7 @@ export function countTestRisks(text) {
|
||||
* Returns null if no version header is found.
|
||||
*/
|
||||
export function extractChangelogVersion(text) {
|
||||
return text.match(/^## \[(.+?)\] - /m)?.[1] ?? null;
|
||||
return normalizeNewlines(text).match(/^## \[(.+?)\] - /m)?.[1] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +76,7 @@ export function extractChangelogVersion(text) {
|
||||
* Returns: ["1", "2a", "6b", ...] — the label portion only.
|
||||
*/
|
||||
export function extractGuideStepLabels(text) {
|
||||
return (text.match(/^### Step (\d+[a-z]?)/gm) ?? [])
|
||||
return (normalizeNewlines(text).match(/^### Step (\d+[a-z]?)/gm) ?? [])
|
||||
.map(m => m.replace(/^### Step /, ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.resolve(__dirname, "..");
|
||||
|
||||
function readText(relPath) {
|
||||
return readFileSync(path.join(root, relPath), "utf8");
|
||||
return readFileSync(path.join(root, relPath), "utf8").replace(/\r\n/g, "\n");
|
||||
}
|
||||
|
||||
function readJson(relPath) {
|
||||
@@ -302,7 +302,7 @@ function checkSecurity() {
|
||||
function checkHookOutput() {
|
||||
function runHook(env = {}) {
|
||||
const tempHome = mkdtempSync(path.join(os.tmpdir(), "brooks-lint-hook-home-"));
|
||||
const stdout = execFileSync("bash", ["hooks/session-start"], {
|
||||
const stdout = execFileSync(process.execPath, [path.join(root, "hooks", "session-start.mjs")], {
|
||||
cwd: root,
|
||||
env: { ...process.env, HOME: tempHome, ...env },
|
||||
encoding: "utf8",
|
||||
|
||||
@@ -12,6 +12,7 @@ import { writeFileSync, mkdtempSync, rmSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
import os from "node:os";
|
||||
import { assembleSystemPrompt, VALID_MODES } from "./assemble-prompt.mjs";
|
||||
import { readHistory, appendHistory, getTrend } from "./history.mjs";
|
||||
import {
|
||||
parseFrontmatterBooks,
|
||||
@@ -77,6 +78,11 @@ test("handles 4-space indentation", () => {
|
||||
assert.deepEqual(parseFrontmatterBooks(text), ["The Mythical Man-Month", "Code Complete"]);
|
||||
});
|
||||
|
||||
test("handles CRLF line endings", () => {
|
||||
const text = "---\r\nbooks:\r\n - The Mythical Man-Month\r\n - Code Complete\r\n---\r\n";
|
||||
assert.deepEqual(parseFrontmatterBooks(text), ["The Mythical Man-Month", "Code Complete"]);
|
||||
});
|
||||
|
||||
test("handles titles containing colons", () => {
|
||||
const text = "---\nbooks:\n - Domain-Driven Design: Tackling Complexity\n---\n";
|
||||
assert.deepEqual(parseFrontmatterBooks(text), ["Domain-Driven Design: Tackling Complexity"]);
|
||||
@@ -234,6 +240,21 @@ test("handles full pr-review-guide pattern", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// —— assembleSystemPrompt / VALID_MODES ————————————————————————————————
|
||||
|
||||
console.log("\nassembleSystemPrompt");
|
||||
|
||||
test("includes sweep in VALID_MODES", () => {
|
||||
assert.ok(VALID_MODES.includes("sweep"));
|
||||
});
|
||||
|
||||
test("assembles sweep prompt with both risk catalogs and sweep guide", () => {
|
||||
const prompt = assembleSystemPrompt("sweep", path.join(__dirname, "..", "skills"));
|
||||
assert.match(prompt, /## Risk 1: Cognitive Overload/);
|
||||
assert.match(prompt, /## Risk T1: Test Obscurity/);
|
||||
assert.match(prompt, /# Brooks-Lint .* Full Sweep Guide/);
|
||||
});
|
||||
|
||||
// ── readHistory ────────────────────────────────────────────────────────────
|
||||
|
||||
console.log("\nreadHistory");
|
||||
|
||||
Reference in New Issue
Block a user