docs(design): compact remaining internal records

This commit is contained in:
Rahim
2026-07-15 13:02:54 -07:00
parent f6b5c16366
commit 35a46919d2
55 changed files with 832 additions and 13353 deletions
+45
View File
@@ -700,6 +700,7 @@ function checkAgentContext() {
// ── Check 10: Internal record consistency ──────────────────────────────────
const DESIGN_STATUSES = new Set(['draft', 'decided', 'active', 'partial', 'implemented', 'superseded', 'reference']);
const INTERNAL_RECORD_MAX_LINES = 160;
function recordFrontmatter(path, warnings) {
const relative = relativePath(path);
@@ -714,6 +715,34 @@ function recordFrontmatter(path, warnings) {
);
}
function checkLocalMarkdownLinks(path, warnings) {
const source = readText(path);
for (const match of source.matchAll(/!?\[[^\]]*\]\(([^)]+)\)/g)) {
let target = match[1].trim();
if (target.startsWith('<') && target.endsWith('>')) target = target.slice(1, -1);
if (!target || target.startsWith('#') || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue;
target = target
.split(/\s+["']/)[0]
.split('#')[0]
.split('?')[0];
if (!target) continue;
try {
target = decodeURIComponent(target);
} catch {
warnings.push(`${relativePath(path)}: invalid encoded Markdown link "${match[1]}"`);
continue;
}
const resolved = target.startsWith('/') ? join(ROOT, target.slice(1)) : resolve(dirname(path), target);
if (!existsSync(resolved)) {
warnings.push(`${relativePath(path)}: broken local Markdown link "${match[1]}"`);
}
}
}
function checkInternalRecords() {
const warnings = [];
const designDir = join(ROOT, 'internal/design');
@@ -727,6 +756,8 @@ function checkInternalRecords() {
for (const path of listFiles(designDir, (path) => path.endsWith('.md'))) {
if (path === designReadme) continue;
checkFileBudget(path, INTERNAL_RECORD_MAX_LINES, Number.POSITIVE_INFINITY, warnings);
checkLocalMarkdownLinks(path, warnings);
const frontmatter = recordFrontmatter(path, warnings);
if (!frontmatter) continue;
if (!DESIGN_STATUSES.has(frontmatter.status)) {
@@ -738,7 +769,16 @@ function checkInternalRecords() {
}
const decisionsDir = join(ROOT, 'internal/decisions');
const decisionsReadme = join(decisionsDir, 'README.md');
for (const entry of readdirSync(decisionsDir, { withFileTypes: true })) {
if (entry.isFile() && entry.name.endsWith('.md') && join(decisionsDir, entry.name) !== decisionsReadme) {
warnings.push(`internal/decisions/${entry.name}: place decision records in an area directory`);
}
}
for (const path of listFiles(decisionsDir, (path) => path.endsWith('.md') && !path.endsWith('/README.md'))) {
checkFileBudget(path, INTERNAL_RECORD_MAX_LINES, Number.POSITIVE_INFINITY, warnings);
checkLocalMarkdownLinks(path, warnings);
const frontmatter = recordFrontmatter(path, warnings);
if (!frontmatter) continue;
if (frontmatter.status !== 'decided') {
@@ -749,6 +789,11 @@ function checkInternalRecords() {
}
}
for (const path of listFiles(join(ROOT, 'rfc'), (path) => path.endsWith('.md'))) {
checkFileBudget(path, INTERNAL_RECORD_MAX_LINES, Number.POSITIVE_INFINITY, warnings);
checkLocalMarkdownLinks(path, warnings);
}
return { ok: warnings.length === 0, warnings };
}