@fanchao8609/agent_brain_sync 0.2.0 → 0.2.1
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.
- package/package.json +1 -1
- package/src/store.js +13 -0
package/package.json
CHANGED
package/src/store.js
CHANGED
|
@@ -422,6 +422,12 @@ export async function cmdLint({ dir }) {
|
|
|
422
422
|
const pages = await listPages(vault);
|
|
423
423
|
const names = new Set(pages.map((p) => p.slug));
|
|
424
424
|
const linkedNames = new Set(pages.flatMap((p) => p.links));
|
|
425
|
+
// index.md 里列的 [[x]] —— 用于反向查死引用(列了但页不存在)
|
|
426
|
+
let indexLinks = [];
|
|
427
|
+
try {
|
|
428
|
+
const idx = await fs.readFile(join(vault, 'index.md'), 'utf8');
|
|
429
|
+
indexLinks = [...idx.matchAll(/\[\[([^\]|#]+)/g)].map((m) => m[1].trim());
|
|
430
|
+
} catch { /* 无 index 则不查 */ }
|
|
425
431
|
const issues = [];
|
|
426
432
|
|
|
427
433
|
for (const pg of pages) {
|
|
@@ -447,6 +453,13 @@ export async function cmdLint({ dir }) {
|
|
|
447
453
|
}
|
|
448
454
|
}
|
|
449
455
|
|
|
456
|
+
// index.md 反向检查: 列了 [[x]] 但 x 页不存在 —— 删页/归档 source 后忘了清 index 的残留。
|
|
457
|
+
// (page→index 的 INDEX-MISSING 已有, 这里补 index→page, 否则死引用静默留在入口文件里)
|
|
458
|
+
for (const ln of indexLinks) {
|
|
459
|
+
if (/slug|Name|name|Date|页面名$/.test(ln)) continue; // 模板占位行
|
|
460
|
+
if (!names.has(ln)) issues.push(`INDEX-DEAD-LINK: index.md -> [[${ln}]] (该页不存在, 删页后忘清 index?)`);
|
|
461
|
+
}
|
|
462
|
+
|
|
450
463
|
const nsrc = pages.filter((p) => p.dir === 'sources').length;
|
|
451
464
|
if (nsrc > 10) issues.push(`SOURCES-PILED-UP: sources/ has ${nsrc} files > 10; 提炼归档旧 source`);
|
|
452
465
|
|