ReMe/github-pages/scripts/verify-build.mjs
jinliyl 524b1b6908
feat(studio): unify the workbench and proactive runtime (#764)
* fix(proactive): simplify round files and restore failed summaries

* fix(proactive): validate document-relative Markdown links

* feat(proactive_agent): implement v2 daily record workflow with single-file decision

- Add ProactiveAgentStepV2 class to support single daily note decision and reminder
- Introduce RoundOutputs for v2 round file tracking, and keep RoundArtifacts for v1 summary backup
- Refactor AgentOutbox to support both v1 standalone reminder files and v2 daily reminder records
- Add proactive_record utilities to parse and validate v2 daily record frontmatter and metadata
- Enhance proactive_agent to prepare, read, and manage artifacts for both v1 and v2 flows
- Add configuration profile proactive_v2 to enable new workflow with backward compatibility
- Update proactive.yaml and reactive proactive_agent_step configuration comment for easy switching
- Provide extensive schema validation for v2 reminders ensuring priority and message consistency
- Document v2 workflow and usage in English and Chinese runtime docs
- Add unit tests for v2 step verifying single file output and proper decision handling

* refactor(agent/runtime): replace ReminderRef with string keys and simplify reminder handling

- Remove ReminderRef model and switch to using workspace-relative string keys for reminders
- Simplify AgentOutbox to read, write, and manage reminders keyed by strings
- Change file locking and version checking to protect concurrent edits on daily record files
- Replace legacy and v2 reminder file handling with unified ReminderFiles storage
- Adjust ChatNotifications to operate with the new key scheme and update pending/read sets
- Refactor RoundOutputs to RoundRecord for safer round record tracking and rollback
- Remove unused ProactiveRunResult and related references from imports and exports
- Update InboxWakeRequest, AgentReminder, and related models for consistent ID and path validation
- Adjust proactive agent runtime and local runtime to check reminder versions before commit
- Correct language and docs to describe reminders as daily records instead of separate files
- Clean up roles of inbox and outbox for reminder ownership, delivery, and acknowledgments

* fix(proactive): serialize round commits and align desktop reminders

* refactor(proactive): unify task triggers in Proactive Runtime

* fix(proactive): bound reminder payloads and simplify receipts

* refactor(studio): share workbench and simplify proactive delivery

* fix(studio): update and centralize build dependencies

* fix(proactive): guard draft repair and verify Studio deployments

* chore(docs): update source-map-js

* feat(release): support publishing selected artifacts from a tag

* chore(studio): remove the public playground

* refactor: simplify reminders and release workflows

* fix: preserve proactive records and align release provenance

* test(proactive): remove brittle prompt and preset assertions

* fix(proactive): register reminders after input acknowledgement

* feat(notebook): list projects across todos and ideas

* feat(studio): connect mobile apps to configurable ReMe services

* fix(proactive): reserve registered reminder paths

* fix(studio): request Android local network access

* fix(proactive): reserve reminder paths referenced by receipts
2026-11-23 17:19:21 +08:00

163 lines
7.3 KiB
JavaScript

import assert from "node:assert/strict";
import { access, readFile, readdir } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
const siteDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const outputDir = path.join(siteDir, "dist");
async function collectFiles(directory, prefix = "") {
const files = [];
for (const entry of await readdir(directory, { withFileTypes: true })) {
const relativePath = path.posix.join(prefix, entry.name);
if (entry.isDirectory()) files.push(...await collectFiles(path.join(directory, entry.name), relativePath));
else files.push(relativePath);
}
return files;
}
function pageUrl(relativePath) {
if (relativePath === "index.html") return "/";
if (relativePath.endsWith("/index.html")) return `/${relativePath.slice(0, -"index.html".length)}`;
return `/${relativePath.slice(0, -".html".length)}`;
}
function routeExists(pathname, files) {
const relativePath = decodeURIComponent(pathname).replace(/^\/+/, "");
if (!relativePath) return files.has("index.html");
if (relativePath.endsWith("/")) return files.has(`${relativePath}index.html`);
return files.has(relativePath) || files.has(`${relativePath}.html`) || files.has(`${relativePath}/index.html`);
}
const requiredFiles = [
"index.html",
"404.html",
"CNAME",
"reme-icon.svg",
"reme-logo.svg",
"ecosystem/qwenpaw.png",
"ecosystem/deepseek-harness.svg",
"ecosystem/openclaw.svg",
"ecosystem/claude-code.png",
"ecosystem/hermes.svg",
"ecosystem/zvec.ico",
"ecosystem/faiss.png",
"hashmap.json",
"sitemap.xml",
"llms.txt",
"llms-full.txt",
"zh/index.html",
"en/index.html",
"zh/overview.html",
"en/overview.html",
"zh/traffic.html",
"en/traffic.html",
"zh/configuration.html",
"en/configuration.html",
"zh/reme-blog.html",
"en/reme-blog.html",
"zh/blog_20260920.html",
"en/blog_20260920.html",
"zh/blog_20261009.html",
"en/blog_20261009.html",
"zh/benchmarks/memlens.html",
"en/benchmarks/memlens.html",
"zh/benchmarks/mobilemem.html",
"en/benchmarks/mobilemem.html",
"zh/memlens_256k_evaluation.html",
"en/memlens_256k_evaluation.html",
"figures/benchmarks/memlens/memlens-256k-four-models-judge.svg",
"zh/services.html",
"en/services.html",
"zh/reference/jobs.html",
"en/reference/jobs.html",
"zh/configuration/llms.txt",
"en/configuration/llms.txt",
];
for (const relativePath of requiredFiles) await access(path.join(outputDir, relativePath));
assert.equal((await readFile(path.join(outputDir, "CNAME"), "utf8")).trim(), "reme.agentscope.io");
const homepage = await readFile(path.join(outputDir, "index.html"), "utf8");
assert.ok(homepage.includes('href="/en/"'), "root language switch must link to /en/");
assert.ok(!homepage.includes('href="/en/ex"'), "root language switch must not produce /en/ex");
assert.ok(homepage.includes('"en-quick_start":"/en/quick_start"'), "legacy redirects must be embedded");
const ChineseHomepage = await readFile(path.join(outputDir, "zh/index.html"), "utf8");
assert.match(ChineseHomepage, /8cafe9df-d883-4046-b5e9-36dfd21a4884/);
assert.match(ChineseHomepage, /用真实评测/);
assert.match(ChineseHomepage, /89\.4%/);
assert.match(ChineseHomepage, /公开、透明的访问趋势/);
const ChineseTraffic = await readFile(path.join(outputDir, "zh/traffic.html"), "utf8");
assert.match(ChineseTraffic, /S1OZK1PSDLEpyiU5/);
const sitemap = await readFile(path.join(outputDir, "sitemap.xml"), "utf8");
assert.ok(sitemap.includes("<lastmod>"), "sitemap must include canonical-source update times");
assert.ok(!sitemap.includes("<loc>https://reme.agentscope.io/</loc>"), "root redirect must not be indexed");
assert.ok(!sitemap.includes('hreflang="zh-CN" href="https://reme.agentscope.io/"'), "root must not duplicate zh-CN");
const ChineseConfiguration = await readFile(path.join(outputDir, "zh/configuration.html"), "utf8");
assert.match(ChineseConfiguration, /搜索文档/);
assert.match(ChineseConfiguration, /复制 Markdown/);
assert.match(ChineseConfiguration, /在 GitHub 查看源文件/);
const ChineseBlog = await readFile(path.join(outputDir, "zh/blog_20260920.html"), "utf8");
assert.match(ChineseBlog, /<h1[^>]*>给记忆加上“标签”/);
assert.match(ChineseBlog, />记忆标签<\/p>/, "the Chinese sidebar must use the localized article name");
assert.match(
ChineseBlog,
/<a class="VPLink link link" href="\/zh\/reme-blog"[^>]*>.*?<h2 class="text"[^>]*>ReMe 博客<\/h2>/,
"the blog sidebar heading must link to the blog landing page",
);
const EnglishBlog = await readFile(path.join(outputDir, "en/blog_20260920.html"), "utf8");
assert.match(EnglishBlog, /<h1[^>]*>ReMe Memory Tags/);
assert.match(EnglishBlog, /How Does the Tag Index Work\?/);
assert.doesNotMatch(EnglishBlog, /full article is currently available in Chinese/);
for (const language of ["zh", "en"]) {
const multimodalBlog = await readFile(path.join(outputDir, language, "blog_20261009.html"), "utf8");
const overview = await readFile(path.join(outputDir, language, "overview.html"), "utf8");
const configLink = overview.match(/<a\b[^>]*href="([^"]+)"[^>]*>\s*<code>reme\/config\/default\.yaml<\/code>\s*<\/a>/);
assert.equal(
configLink?.[1],
"https://github.com/agentscope-ai/ReMe/blob/main/reme/config/default.yaml",
`${language} overview must link to the default configuration source`,
);
for (const benchmark of ["memlens", "mobilemem"]) {
const route = `/${language}/benchmarks/${benchmark}`;
assert.ok(multimodalBlog.includes(`href="${route}"`), `multimodal blog must link to ${route}`);
assert.ok(overview.includes(`href="${route}"`), `project overview must link to ${route}`);
const evaluation = await readFile(path.join(outputDir, language, "benchmarks", `${benchmark}.html`), "utf8");
assert.ok(evaluation.includes(`href="/${language}/blog_20261009#`), "evaluation must link back to its blog section");
assert.ok(
evaluation.includes(`https://github.com/agentscope-ai/ReMe/blob/main/benchmark/${benchmark}/docs/${language}/evaluation.md`),
"evaluation source link must identify the canonical benchmark document",
);
}
assert.match(multimodalBlog, /src="\/figures\/benchmarks\/memlens\/[^"]+\.svg"/);
assert.doesNotMatch(multimodalBlog, /https:\/\/raw\.githubusercontent\.com\/agentscope-ai\/ReMe\/main\/benchmark\/memlens\/docs\/figure\//);
}
const jobReference = await readFile(path.join(outputDir, "en/reference/jobs.html"), "utf8");
assert.match(jobReference, /Job API Reference/);
assert.match(jobReference, /auto_memory/);
const outputFiles = new Set(await collectFiles(outputDir));
const missingLinks = [];
for (const relativePath of [...outputFiles].filter((file) => file.endsWith(".html"))) {
const html = await readFile(path.join(outputDir, relativePath), "utf8");
const currentUrl = new URL(pageUrl(relativePath), "https://reme-docs.local");
for (const match of html.matchAll(/<a\b[^>]*\bhref="([^"]+)"/g)) {
const href = match[1].replaceAll("&amp;", "&");
if (href.startsWith("#")) continue;
const target = new URL(href, currentUrl);
if (target.origin !== currentUrl.origin) continue;
if (!routeExists(target.pathname, outputFiles)) missingLinks.push(`${relativePath}: ${href}`);
}
}
assert.deepEqual(missingLinks, [], `missing internal links:\n${missingLinks.join("\n")}`);
console.log(`Verified ${requiredFiles.length} documentation build artifacts.`);