推进本地索引与 AI changed-files 审计

- 为本地工作区补充 search/backlinks/tags/resource 引用索引与 watcher 单文件刷新
- 在页面设置中增加索引页签,并展示本地反链、标签和 AI changed-files 审计
- 补充本地搜索与本地 AI changed-files 浏览器 smoke,并回填当前优先级 checklist
This commit is contained in:
lix-2026
2026-05-19 10:22:01 +08:00
parent 1b5d6a2a2d
commit fc4a47e597
8 changed files with 968 additions and 42 deletions
@@ -72,7 +72,14 @@ async function run() {
const debug = { root, baseUrl: BASE_URL };
writeWorkspaceManifest(root, "user_real");
fs.mkdirSync(path.join(root, "docs"), { recursive: true });
fs.writeFileSync(path.join(root, "README.md"), "# Search Smoke\n打开搜索 smoke。\n", "utf8");
const token = `LOCAL-SEARCH-${Date.now()}`;
const firstRelativePath = "docs/search-target.md";
const renamedRelativePath = "docs/search-renamed.md";
fs.writeFileSync(
path.join(root, "README.md"),
`---\ntitle: Search Smoke\ntags: [alpha]\n---\n# Search Smoke\n打开搜索 smoke。\n[Target](docs/search-target.md)\n`,
"utf8",
);
const browser = await chromium.launch({
headless: true,
@@ -97,12 +104,9 @@ async function run() {
timeout: UI_TIMEOUT_MS,
});
const token = `LOCAL-SEARCH-${Date.now()}`;
const firstRelativePath = "docs/search-target.md";
const renamedRelativePath = "docs/search-renamed.md";
fs.writeFileSync(
path.join(root, firstRelativePath),
`---\ntitle: Search Target\n---\n# Search Target\n${token}\n`,
`---\ntitle: Search Target\ntags: [alpha, beta]\n---\n# Search Target\n${token}\n`,
"utf8",
);
@@ -115,6 +119,30 @@ async function run() {
`新建页面应立即可搜索: ${JSON.stringify(firstResults)}`,
);
await page.goto(documentUrl(root, firstRelativePath), {
waitUntil: "domcontentloaded",
timeout: UI_TIMEOUT_MS,
});
await page.locator('[data-testid="mnote-leptos-tiptap-island-editor-root"]').first().waitFor({
state: "visible",
timeout: UI_TIMEOUT_MS,
});
await page.locator('[data-testid="wolai-page-settings-trigger"]').click({ timeout: UI_TIMEOUT_MS });
await page.locator('[data-page-settings-tab="index"]').click({ timeout: UI_TIMEOUT_MS });
await page.waitForFunction(() => {
const backlinks = document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]');
const tags = document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]');
return Boolean(
backlinks && backlinks.textContent && backlinks.textContent.includes("Search Smoke")
&& tags && tags.textContent && tags.textContent.includes("#alpha"),
);
}, null, { timeout: UI_TIMEOUT_MS });
debug.localIndexPanel = await page.evaluate(() => ({
backlinks: document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]')?.textContent || "",
tags: document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]')?.textContent || "",
status: document.querySelector('[data-testid="wolai-page-settings-local-index-status"]')?.textContent || "",
}));
fs.renameSync(path.join(root, firstRelativePath), path.join(root, renamedRelativePath));
const second = await browserSearch(page, root, token);
assert.equal(second.status, 200, `重命名后搜索应成功: ${JSON.stringify(second)}`);
@@ -135,6 +163,7 @@ async function run() {
token,
firstPath: firstRelativePath,
renamedPath: renamedRelativePath,
localIndexPanel: debug.localIndexPanel,
indexExists: fs.existsSync(path.join(root, ".mnote", "index", "search-index.json")),
};
fs.writeFileSync(RESULT_PATH, `${JSON.stringify(result, null, 2)}\n`, "utf8");