docs: 共有技能收归 meta 单一份并加工作区级笔记校验入口
- write-notes-like-deepseek 从三个子仓库的重复副本改为 meta 唯一副本 - 新增 .agents/scripts/verify-notes.ts,从 meta 视角一次校验四个笔记根 - workspace-layout 补「共有技能单一来源」的落位与理由 - .rgignore 排除 archived 历史快照
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Verify tree: lifecycle/class/filename/INDEX and internal relative markdown links.
|
||||
* Run: node <skill-dir>/scripts/verify-agent-note-tree.ts
|
||||
*/
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { dirname, resolve, sep } from "node:path";
|
||||
import { agentNoteRoot, walkAgentNoteTree } from "./agent-note-tree.ts";
|
||||
|
||||
const { notes, errors } = walkAgentNoteTree();
|
||||
|
||||
// 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) {
|
||||
let rawTarget = match[2]?.trim();
|
||||
if (!rawTarget) continue;
|
||||
|
||||
// Support CommonMark angle bracket destinations: [text](<path>)
|
||||
if (rawTarget.startsWith("<") && rawTarget.endsWith(">")) {
|
||||
rawTarget = rawTarget.slice(1, -1).trim();
|
||||
}
|
||||
|
||||
// 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 (boundary-aware: a
|
||||
// sibling like .agents/notes-backup/ must not prefix-match)
|
||||
if (!resolvedTarget.startsWith(agentNoteRoot + sep)) {
|
||||
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