mirror of
https://github.com/czm15053/write-notes-like-deepseek
synced 2026-11-26 10:14:07 +08:00
feat: 支持工程决策看板与构建体系
This commit is contained in:
@@ -1,5 +1,50 @@
|
||||
/** Verify tree: lifecycle/class/filename/INDEX. Run: npx tsx scripts/verify-agent-note-tree.ts */
|
||||
import { walkAgentNoteTree } from "./agent-note-tree.ts";
|
||||
/**
|
||||
* Verify tree: lifecycle/class/filename/INDEX and internal relative markdown links.
|
||||
* Run: npx tsx scripts/verify-agent-note-tree.ts
|
||||
*/
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { agentNoteRoot, walkAgentNoteTree } from "./agent-note-tree.ts";
|
||||
|
||||
const { notes, errors } = walkAgentNoteTree();
|
||||
if (errors.length) { for (const e of errors) console.error(e); process.exit(1); }
|
||||
console.log(`ok: ${notes.length} note(s) tree verified`);
|
||||
|
||||
// Check relative markdown links inside active notes
|
||||
const LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
||||
|
||||
for (const note of notes) {
|
||||
const noteFullPath = resolve(agentNoteRoot, note.rel);
|
||||
const content = readFileSync(noteFullPath, "utf8");
|
||||
let match: RegExpExecArray | null;
|
||||
|
||||
while ((match = LINK_REGEX.exec(content)) !== null) {
|
||||
const rawTarget = match[2]?.trim();
|
||||
if (!rawTarget) continue;
|
||||
|
||||
// Ignore web links, intra-page anchors and ellipsis placeholders
|
||||
if (rawTarget.startsWith("http://") || rawTarget.startsWith("https://") || rawTarget.startsWith("#") || rawTarget.startsWith("mailto:") || rawTarget.includes("…")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Strip anchor fragment if present
|
||||
const fileTarget = rawTarget.split("#")[0];
|
||||
if (!fileTarget) continue;
|
||||
|
||||
const resolvedTarget = resolve(dirname(noteFullPath), fileTarget);
|
||||
|
||||
// Only verify internal links within agentNoteRoot
|
||||
if (!resolvedTarget.startsWith(agentNoteRoot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!existsSync(resolvedTarget)) {
|
||||
errors.push(`link: ${note.rel} -> "${rawTarget}" target file does not exist`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
for (const e of errors) console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`ok: ${notes.length} note(s) tree and relative links verified`);
|
||||
|
||||
Reference in New Issue
Block a user