Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix(community): validate catalog inputs and render metadata as text
tt-a1i240acd0cdb56
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 40ce3198..f35363fa 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -301,7 +301,7 @@ jobs:chrome-version: stableinstall-dependencies: true- name: Verify built website navigation and language continuity- run: node --test --test-name-pattern='real Chrome' archify/test/site-language-continuity.test.mjs+ run: node --test --test-name-pattern='real Chrome' archify/test/site-language-continuity.test.mjs website/test/community-browser.test.mjsenv:ARCHIFY_SITE_ROOT: ${{ github.workspace }}/website/distARCHIFY_SITE_INTEGRATION: '1'diff --git a/archify/test/community-packages.test.mjs b/archify/test/community-packages.test.mjsindex 7afd521e..b5d1b0d7 100644--- a/archify/test/community-packages.test.mjs+++ b/archify/test/community-packages.test.mjs@@ -83,3 +83,65 @@ test('community registry: rejects duplicate names and file/name mismatches', ()fs.rmSync(root, { recursive: true, force: true });}});+++test('community package: rejects nested unknown fields and overlong author/evidence text', () => {+ for (const mutate of [+ value => { value.summary.extra = true; },+ value => { value.author.extra = true; },+ value => { value.evidence = [{ label: 'receipt', url: 'https://example.com', extra: true }]; },+ value => { value.author.name = 'x'.repeat(81); },+ value => { value.evidence = [{ label: 'x'.repeat(81), url: 'https://example.com' }]; },+ ]) {+ const value = validPackage();+ mutate(value);+ assert.ok(validatePackage(value).length, JSON.stringify(value));+ }+});++test('community package: rejects malformed HTTPS URLs in every link field', () => {+ for (const url of ['https://', 'https:///example.com', 'https://example.com:bad', 'https://example.com/a b', 'https://user:[email protected]', 'https://example.com/\\path', 'https://example.com/\npath', 'https://example.com/\n', 'https://example.com/\u0000path']) {+ for (const mutate of [+ value => { value.repository = url; },+ value => { value.homepage = url; },+ value => { value.author.url = url; },+ value => { value.evidence = [{ label: 'receipt', url }]; },+ ]) {+ const value = validPackage();+ mutate(value);+ assert.ok(validatePackage(value).length, url);+ }+ }+});++test('community package: text lengths follow Unicode code points at schema boundaries', () => {+ const value = validPackage();+ value.author.name = '😀'.repeat(80);+ value.summary.en = '😀'.repeat(160);+ value.summary.zh = '😀'.repeat(120);+ value.evidence = [{ label: '😀'.repeat(80), url: 'https://example.com/evidence' }];+ assert.deepEqual(validatePackage(value), []);+ value.author.name += '😀';+ assert.ok(validatePackage(value).length);+});+++test('community package: en/zh summaries and evidence labels enforce both length boundaries', () => {+ for (const [field, minimum, maximum] of [['en', 10, 160], ['zh', 6, 120]]) {+ for (const length of [minimum, maximum]) {+ const value = validPackage();+ value.summary[field] = '😀'.repeat(length);+ assert.deepEqual(validatePackage(value), []);+ }+ for (const length of [minimum - 1, maximum + 1]) {+ const value = validPackage();+ value.summary[field] = '😀'.repeat(length);+ assert.ok(validatePackage(value).length);+ }+ }+ for (const length of [1, 80, 81]) {+ const value = validPackage();+ value.evidence = [{ label: '😀'.repeat(length), url: 'https://example.com/receipt' }];+ assert.equal(validatePackage(value).length === 0, length <= 80);+ }+});diff --git a/community/README.md b/community/README.mdindex 622c0671..99744ff7 100644--- a/community/README.md+++ b/community/README.md@@ -32,7 +32,7 @@ Archify has **no in-process plugin API, and none is planned for this registry**.Review follows the tiers in [REVIEWING.md](../REVIEWING.md). Approval criteria:-- Metadata passes `scripts/check-community-packages.mjs`.+- Metadata passes `scripts/check-community-packages.mjs`. Links must be parseable HTTPS URLs with a host, no credentials, whitespace, control characters, or backslashes (the validator checks these URL semantics in addition to the schema). Website builds use the same validator and reject invalid entries.- The declared `archify` compatibility range exists and the supported `schemaVersions` are real.- The package performs what its summary claims, from the evidence you link.- No telemetry, no hosted-service requirement, no code execution inside Archify.diff --git a/community/package.schema.json b/community/package.schema.jsonindex aedcc0cd..0aa1f784 100644--- a/community/package.schema.json+++ b/community/package.schema.json@@ -30,13 +30,13 @@"additionalProperties": false,"required": ["name"],"properties": {- "name": { "type": "string", "minLength": 1, "maxLength": 80 },- "url": { "type": "string", "pattern": "^https://" }+ "name": { "type": "string", "minLength": 1, "maxLength": 80, "pattern": "\\S" },+ "url": { "type": "string", "pattern": "^https://[^\\s\\\\/?#@]+(?:[/?#][^\\s\\\\]*)?$", "format": "uri" }}},"repository": {"type": "string",- "pattern": "^https://",+ "pattern": "^https://[^\\s\\\\/?#@]+(?:[/?#][^\\s\\\\]*)?$", "format": "uri","description": "Public URL of the package source (git repository, npm page, or directory inside one)."},"archify": {@@ -53,7 +53,7 @@},"homepage": {"type": "string",- "pattern": "^https://"+ "pattern": "^https://[^\\s\\\\/?#@]+(?:[/?#][^\\s\\\\]*)?$", "format": "uri"},"tags": {"type": "array",@@ -69,8 +69,8 @@"additionalProperties": false,"required": ["label", "url"],"properties": {- "label": { "type": "string", "minLength": 1, "maxLength": 80 },- "url": { "type": "string", "pattern": "^https://" }+ "label": { "type": "string", "minLength": 1, "maxLength": 80, "pattern": "\\S" },+ "url": { "type": "string", "pattern": "^https://[^\\s\\\\/?#@]+(?:[/?#][^\\s\\\\]*)?$", "format": "uri" }}},"description": "Links to verification evidence: validation receipts, screenshots, rendered example artifacts. Evidence is authored by the submitter; Archify never executes third-party package code."diff --git a/community/packages/archify-dsh.json b/community/packages/archify-dsh.jsonindex dd86c058..8ab55bc2 100644--- a/community/packages/archify-dsh.json+++ b/community/packages/archify-dsh.json@@ -2,22 +2,33 @@"name": "archify-dsh","type": "wrapper","summary": {- "en": "DeepSeek Harness plugin registering the Archify skill as a filesystem skill provider. Published on npm as @tt-a1i/archify-dsh.",- "zh": "DeepSeek Harness 插件,将 Archify skill 注册为文件系统 skill provider。以 npm 包 @tt-a1i/archify-dsh 分发;宿主编写 JSON IR 并调用 Archify CLI。"+ "en": "Published DSH skill bundle @tt-a1i/archify-dsh 0.1.0 includes Archify 2.14.0. Experimental DSH 0.1.0-rc.6 support; the 0.2.0 bundle remains unpublished.",+ "zh": "已发布的 DSH 技能包 @tt-a1i/archify-dsh 0.1.0 内含 Archify 2.14.0,实验支持 DSH 0.1.0-rc.6;0.2.0 包尚未发布。"},"author": {"name": "tt-a1i","url": "https://github.com/tt-a1i"},- "repository": "https://github.com/tt-a1i/archify/tree/main/integrations/deepseek-harness",- "homepage": "https://www.npmjs.com/package/@tt-a1i/archify-dsh",- "archify": ">=3.0.0 <4.0.0",- "schemaVersions": [1, 2],- "tags": ["deepseek-harness", "dsh", "npm", "integration"],+ "repository": "https://github.com/tt-a1i/archify/tree/archify-dsh-v0.1.0/integrations/deepseek-harness",+ "homepage": "https://www.npmjs.com/package/@tt-a1i/archify-dsh/v/0.1.0",+ "archify": "2.14.0",+ "schemaVersions": [+ 1+ ],+ "tags": [+ "deepseek-harness",+ "dsh",+ "npm",+ "integration"+ ],"evidence": [{- "label": "Pinned skill source commit",- "url": "https://github.com/tt-a1i/archify/blob/main/integrations/deepseek-harness/release.json"+ "label": "Published 0.1.0 integration guide",+ "url": "https://github.com/tt-a1i/archify/blob/archify-dsh-v0.1.0/integrations/deepseek-harness/README.md"+ },+ {+ "label": "Bundled Archify 2.14.0 source",+ "url": "https://github.com/tt-a1i/archify/blob/archify-dsh-v0.1.0/archify/package.json"}]}diff --git a/scripts/check-community-packages.mjs b/scripts/check-community-packages.mjsindex 55d0f5fa..e8dcd850 100644--- a/scripts/check-community-packages.mjs+++ b/scripts/check-community-packages.mjs@@ -16,7 +16,7 @@ export const PACKAGE_TYPES = Object.freeze(['skill', 'recipe', 'brand-marks', 'lexport const REQUIRED_FIELDS = Object.freeze(['name', 'type', 'summary', 'author', 'repository', 'archify', 'schemaVersions']);const ALLOWED_FIELDS = new Set([...REQUIRED_FIELDS, 'homepage', 'tags', 'evidence']);const NAME_PATTERN = /^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/;-const HTTPS_PATTERN = /^https:\/\//;+const HTTPS_PATTERN = /^https:\/\/[^\s\\/?#@]+(?:[/?#][^\s\\]*)?$/;const ARCHIFY_RANGE_PATTERN = /^(\^|~)\d+\.\d+\.\d+$|^\d+\.\d+\.\d+$|^>=\d+\.\d+\.\d+ <\d+\.\d+\.\d+$/;const TAG_PATTERN = /^[a-z0-9-]{1,32}$/;@@ -29,7 +29,24 @@ function isString(value) {}function isHttpsUrl(value) {- return isString(value) && HTTPS_PATTERN.test(value);+ if (!isString(value) || /[\s\\\u0000-\u001f\u007f]/.test(value) || !HTTPS_PATTERN.test(value)) return false;+ try {+ const url = new URL(value);+ return url.protocol === 'https:' && !!url.hostname && !url.username && !url.password;+ } catch {+ return false;+ }+}++// JSON Schema measures strings in Unicode code points, not UTF-16 units.+function textLength(value) {+ return [...value].length;+}++function unknownFields(value, allowed, subject, fail) {+ for (const key of Object.keys(value)) {+ if (!allowed.includes(key)) fail(`${subject}: unknown field "${key}".`);+ }}export function validatePackage(value) {@@ -57,15 +74,18 @@ export function validatePackage(value) {if (!isPlainObject(value.summary)) {fail('summary must be an object with "en" and "zh" strings.');} else {+ unknownFields(value.summary, ['en', 'zh'], 'summary', fail);const { en, zh } = value.summary;- if (!isString(en) || en.length < 10 || en.length > 160) fail('summary.en must be 10-160 characters.');- if (!isString(zh) || zh.length < 6 || zh.length > 120) fail('summary.zh must be 6-120 characters.');+ if (!isString(en) || textLength(en) < 10 || textLength(en) > 160) fail('summary.en must be 10-160 characters.');+ if (!isString(zh) || textLength(zh) < 6 || textLength(zh) > 120) fail('summary.zh must be 6-120 characters.');}if (!isPlainObject(value.author) || !isString(value.author.name) || !value.author.name.trim()) {fail('author must be an object with a non-empty "name".');- } else if ('url' in value.author && !isHttpsUrl(value.author.url)) {- fail('author.url must be an https:// URL.');+ } else {+ unknownFields(value.author, ['name', 'url'], 'author', fail);+ if (textLength(value.author.name) > 80) fail('author.name must be at most 80 characters.');+ if ('url' in value.author && !isHttpsUrl(value.author.url)) fail('author.url must be an https:// URL.');}if (!isHttpsUrl(value.repository)) fail('repository must be an https:// URL.');@@ -101,6 +121,9 @@ export function validatePackage(value) {value.evidence.forEach((item, index) => {if (!isPlainObject(item) || !isString(item.label) || !item.label.trim() || !isHttpsUrl(item.url)) {fail(`evidence[${index}] must be {label: string, url: https:// URL}.`);+ } else {+ unknownFields(item, ['label', 'url'], `evidence[${index}]`, fail);+ if (textLength(item.label) > 80) fail(`evidence[${index}].label must be at most 80 characters.`);}});}@@ -109,28 +132,13 @@ export function validatePackage(value) {return failures;}-export function validateRegistry(root = repoRoot) {- const packagesDir = path.join(root, 'community', 'packages');+// Shared by the file-system validator and the website's build-time glob.+export function validatePackageEntries(packageFiles) {const failures = [];const entries = [];- let files = [];- try {- files = fs.readdirSync(packagesDir).filter((entry) => entry.endsWith('.json')).sort();- } catch {- failures.push('community/packages/ is missing or unreadable.');- return { entries, failures };- }- if (files.length === 0) failures.push('community/packages/ contains no package metadata files.');-+ if (packageFiles.length === 0) failures.push('community/packages/ contains no package metadata files.');const seen = new Set();- for (const file of files) {- let value;- try {- value = JSON.parse(fs.readFileSync(path.join(packagesDir, file), 'utf8'));- } catch (error) {- failures.push(`${file}: not valid JSON (${error.message}).`);- continue;- }+ for (const [file, value] of packageFiles) {for (const failure of validatePackage(value)) failures.push(`${file}: ${failure}`);if (isPlainObject(value)) {const expectedFile = `${value.name}.json`;@@ -146,6 +154,27 @@ export function validateRegistry(root = repoRoot) {return { entries, failures };}+export function validateRegistry(root = repoRoot) {+ const packagesDir = path.join(root, 'community', 'packages');+ let files;+ try {+ files = fs.readdirSync(packagesDir).filter((entry) => entry.endsWith('.json')).sort();+ } catch {+ return { entries: [], failures: ['community/packages/ is missing or unreadable.'] };+ }+ const parsed = [];+ const failures = [];+ for (const file of files) {+ try {+ parsed.push([file, JSON.parse(fs.readFileSync(path.join(packagesDir, file), 'utf8'))]);+ } catch (error) {+ failures.push(`${file}: not valid JSON (${error.message}).`);+ }+ }+ const result = validatePackageEntries(parsed);+ return { entries: result.entries, failures: [...failures, ...result.failures] };+}+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {const { entries, failures } = validateRegistry(repoRoot);for (const failure of failures) console.error(`✗ ${failure}`);diff --git a/website/src/data/community.ts b/website/src/data/community.tsindex 9412bc79..3f3f4f26 100644--- a/website/src/data/community.ts+++ b/website/src/data/community.ts@@ -2,6 +2,7 @@// single source of truth; this page never hand-copies package metadata.// import.meta.glob is resolved by Vite at build time relative to this source// file, so the catalog cannot drift from the registry.+import { validatePackageEntries } from '../../../scripts/check-community-packages.mjs';export const PACKAGE_TYPES = ['skill', 'recipe', 'brand-marks', 'locale', 'wrapper'] as const;export type PackageType = (typeof PACKAGE_TYPES)[number];@@ -19,15 +20,13 @@ export interface CommunityPackage {evidence?: { label: string; url: string }[];}-const modules = import.meta.glob<CommunityPackage>('../../../community/packages/*.json', { eager: true, import: 'default' });--export const packages: CommunityPackage[] = Object.entries(modules)- .map(([file, value]) => {- if (!file.endsWith(`/${value.name}.json`)) {- throw new Error(`community registry: ${file} does not match name "${value.name}"`);- }- return value;- })+const modules = import.meta.glob<unknown>('../../../community/packages/*.json', { eager: true, import: 'default' });+const result = validatePackageEntries(Object.entries(modules).map(([file, value]) => [file.split('/').pop(), value]));+if (result.failures.length) {+ throw new Error(`community registry: ${result.failures.join('\n')}`);+}+// The runtime contract is checked before the typed view or PASS label is used.+export const packages: CommunityPackage[] = (result.entries as CommunityPackage[]).sort((a, b) => a.name.localeCompare(b.name));export const typeOrder: PackageType[] = [...PACKAGE_TYPES];diff --git a/website/src/pages/community.astro b/website/src/pages/community.astroindex e4fd143b..24e430c7 100644--- a/website/src/pages/community.astro+++ b/website/src/pages/community.astro@@ -27,13 +27,13 @@ const activeTypes = typeOrder.filter((type) => typeCounts[type] > 0);<div class="shell hero-grid"><div><div class="lead-label" data-en="Community registry / standalone packages" data-zh="社区注册表 / 独立包">Community registry / standalone packages</div>- <h1 data-en="Built on Archify.<br><em>Shared by everyone.</em>" data-zh="基于 Archify 构建,<br><em>由社区共享。</em>">Built on Archify.<br><em>Shared by everyone.</em></h1>+ <h1 data-translation-html data-en="Built on Archify.<br><em>Shared by everyone.</em>" data-zh="基于 Archify 构建,<br><em>由社区共享。</em>">Built on Archify.<br><em>Shared by everyone.</em></h1><p class="hero-copy" data-en="Community packages are standalone works that wrap the Archify CLI — skill packs, recipe libraries, brand kits, locales, and wrappers. Nothing here is a plugin: no third-party code ever runs inside the renderer." data-zh="社区包是围绕 Archify CLI 构建的独立产物——技能包、场景配方、品牌套件、语言包与命令行封装。这里没有插件:任何第三方代码都不会进入渲染器内部运行。">Community packages are standalone works that wrap the Archify CLI — skill packs, recipe libraries, brand kits, locales, and wrappers. Nothing here is a plugin: no third-party code ever runs inside the renderer.</p></div><div class="proof-board" aria-label="Registry summary">- <div class="proof-row"><span class="proof-value">{packages.length}</span><span class="proof-label" data-en="packages listed<br>from the registry" data-zh="个已收录包<br>来自注册表">packages listed<br>from the registry</span></div>- <div class="proof-row"><span class="proof-value">{activeTypes.length}</span><span class="proof-label" data-en="package types<br>in the catalog" data-zh="种包类型<br>收录中">package types<br>in the catalog</span></div>- <div class="proof-row"><span class="proof-value proof-status">PASS</span><span class="proof-label" data-en="metadata validated<br>deterministically" data-zh="元数据通过<br>确定性校验">metadata validated<br>deterministically</span></div>+ <div class="proof-row"><span class="proof-value">{packages.length}</span><span class="proof-label" data-translation-html data-en="packages listed<br>from the registry" data-zh="个已收录包<br>来自注册表">packages listed<br>from the registry</span></div>+ <div class="proof-row"><span class="proof-value">{activeTypes.length}</span><span class="proof-label" data-translation-html data-en="package types<br>in the catalog" data-zh="种包类型<br>收录中">package types<br>in the catalog</span></div>+ <div class="proof-row"><span class="proof-value proof-status">PASS</span><span class="proof-label" data-translation-html data-en="metadata validated<br>deterministically" data-zh="元数据通过<br>确定性校验">metadata validated<br>deterministically</span></div></div></div></section>@@ -87,9 +87,9 @@ const activeTypes = typeOrder.filter((type) => typeCounts[type] > 0);</div><div class="package-actions"><a class="card-link" href={entry.repository} target="_blank" rel="noopener noreferrer" data-en="View source ↗" data-zh="查看源码 ↗">View source ↗</a>- {entry.evidence?.[0] && (- <a class="card-link subtle" href={entry.evidence[0].url} target="_blank" rel="noopener noreferrer" data-en={`${entry.evidence[0].label} ↗`} data-zh={`${entry.evidence[0].label} ↗`}>{entry.evidence[0].label} ↗</a>- )}+ {entry.evidence?.map((evidence) => (+ <a class="card-link subtle evidence-link" href={evidence.url} target="_blank" rel="noopener noreferrer" data-en={`${evidence.label} ↗`} data-zh={`${evidence.label} ↗`}>{evidence.label} ↗</a>+ ))}</div></article>))}diff --git a/website/src/scripts/community.js b/website/src/scripts/community.jsindex ab256c71..b6b82db5 100644--- a/website/src/scripts/community.js+++ b/website/src/scripts/community.js@@ -9,7 +9,10 @@language = ArchifySiteLanguage.write(next);document.documentElement.lang = language === 'zh' ? 'zh-CN' : 'en';document.querySelectorAll('[data-en][data-zh]').forEach(function (node) {- node.innerHTML = node.getAttribute(language === 'zh' ? 'data-zh' : 'data-en');+ var text = node.getAttribute(language === 'zh' ? 'data-zh' : 'data-en');+ // Only fixed page copy opts into markup. Registry strings are text.+ if (node.hasAttribute('data-translation-html')) node.innerHTML = text;+ else node.textContent = text;});var languageButton = document.getElementById('language');languageButton.textContent = language === 'zh' ? 'EN' : '中文';diff --git a/website/src/styles/community.css b/website/src/styles/community.cssindex 56db202e..a12c3d55 100644--- a/website/src/styles/community.css+++ b/website/src/styles/community.css@@ -143,7 +143,7 @@font-family:var(--font-mono); font-size: .5625rem; font-weight:600; letter-spacing: .12em; text-transform: uppercase;}.type-badge::before { content:''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }- .package-summary { flex: 1; padding: .9rem 1.5rem 1.25rem; color: var(--muted); font-size: .8125rem; line-height: 1.7; text-wrap:pretty; }+ .package-summary { flex: 1; padding: .9rem 1.5rem 1.25rem; color: var(--muted); font-size: .8125rem; line-height: 1.7; text-wrap:pretty; overflow-wrap:anywhere; }.package-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; padding: 0 1.5rem 1.125rem; }.meta-chip {display: inline-flex; align-items: center; gap: .4rem;@@ -156,7 +156,7 @@.meta-chip svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }.meta-chip.mono { font-family: var(--font-mono); font-size: .5625rem; letter-spacing: .04em; }.package-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-top: auto; padding: 1.125rem 1.5rem; border-top: 1px solid var(--line); }- .card-link { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: 0 .9rem; border: 1px solid var(--line-hi); border-radius: 8px; color: var(--ink-soft); font-size: .75rem; font-weight: 500; text-decoration: none; transition: all .2s var(--ease-out); }+ .card-link { min-height: 40px; max-width:100%; overflow-wrap:anywhere; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: 0 .9rem; border: 1px solid var(--line-hi); border-radius: 8px; color: var(--ink-soft); font-size: .75rem; font-weight: 500; text-decoration: none; transition: all .2s var(--ease-out); }.card-link:hover { color: var(--ink-site); border-color: var(--ink-site); }.card-link.subtle { border-color: var(--line); color: var(--muted); }.card-link.subtle:hover { color: var(--ink-site); border-color: var(--ink-site); }diff --git a/website/test/community-browser.test.mjs b/website/test/community-browser.test.mjsnew file mode 100644index 00000000..a18b10c5--- /dev/null+++ b/website/test/community-browser.test.mjs@@ -0,0 +1,96 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import http from 'node:http';+import path from 'node:path';+import { ChromeVisualBrowser, findChrome } from '../../archify/bin/visual-check.mjs';+import { createCommunityFixture, payload, websiteRoot } from './helpers/community-fixture.mjs';++const integrationEnabled = process.env.ARCHIFY_SITE_INTEGRATION === '1';+const chrome = integrationEnabled ? findChrome() : null;++test('real Chrome: community metadata remains text through language, filter and navigation changes', {+ skip: integrationEnabled ? false : 'Set ARCHIFY_SITE_INTEGRATION=1 and ARCHIFY_CHROME to run the community browser regression.',+ timeout: 60000,+}, async () => {+ assert.ok(chrome, 'The requested community integration gate requires usable Chrome.');+ const fixture = createCommunityFixture();+ let server;+ let browser;+ try {+ const built = fixture.build();+ assert.equal(built.status, 0, built.stdout + built.stderr);+ server = http.createServer((request, response) => {+ const url = new URL(request.url, 'http://127.0.0.1');+ const root = url.pathname.startsWith('/fixture/') ? fixture.dist : path.join(websiteRoot, 'dist');+ const relative = url.pathname.replace(/^\/(?:fixture|archify)\//, '');+ const file = path.resolve(root, relative);+ if (!file.startsWith(`${root}${path.sep}`)) return response.writeHead(404).end();+ try {+ const types = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml' };+ response.setHeader('Content-Type', types[path.extname(file)] || 'application/octet-stream');+ response.end(fs.readFileSync(file));+ } catch { response.writeHead(404).end(); }+ });+ await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));+ const base = `http://127.0.0.1:${server.address().port}`;+ browser = new ChromeVisualBrowser(chrome);+ const session = await browser.sessionPromise;+ const evaluate = async expression => {+ const result = await browser.cdp.send('Runtime.evaluate', { expression, returnByValue: true, awaitPromise: true }, session);+ assert.ok(!result.exceptionDetails, JSON.stringify(result.exceptionDetails));+ return result.result?.value;+ };+ const navigate = async url => {+ const loaded = browser.cdp.waitFor('Page.loadEventFired', session);+ await browser.cdp.send('Page.navigate', { url }, session);+ await loaded;+ };+ const assertText = async language => {+ const state = await evaluate(`({+ language: document.documentElement.lang,+ executed: document.documentElement.dataset.communityAudit || null,+ summary: document.querySelector('.package-summary').textContent,+ evidence: [...document.querySelectorAll('.evidence-link')].map(node => ({ text: node.textContent, href: node.href })),+ injected: document.querySelectorAll('.package-summary svg, .evidence-link svg').length,+ linksFit: [...document.querySelectorAll('.evidence-link')].every(node => node.scrollWidth <= node.clientWidth + 1),+ heroMarkup: !!document.querySelector('h1 br') && !!document.querySelector('h1 em'),+ width: document.documentElement.scrollWidth, viewport: innerWidth+ })`);+ assert.equal(state.language, language === 'en' ? 'en' : 'zh-CN');+ assert.equal(state.executed, null);+ assert.equal(state.summary, language === 'en' ? payload : `测试 ${payload}`);+ assert.deepEqual(state.evidence, fixture.entry.evidence.map(item => ({ text: `${item.label} ↗`, href: item.url })));+ assert.equal(state.injected, 0);+ assert.ok(state.linksFit, 'long evidence labels must remain readable inside their cards');+ assert.ok(state.heroMarkup, 'fixed title must preserve trusted markup');+ assert.ok(state.width <= state.viewport, 'catalog must fit the viewport');+ };+ for (const width of [1440, 390]) {+ await browser.cdp.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false }, session);+ for (const language of ['en', 'zh']) {+ await navigate(`${base}/fixture/community.html?lang=${language}`);+ await assertText(language);+ await evaluate("document.getElementById('language').click()");+ await assertText(language === 'en' ? 'zh' : 'en');+ await evaluate("document.getElementById('language').click()");+ await assertText(language);+ }+ await evaluate("document.querySelector('[data-filter=recipe]').click()");+ assert.deepEqual(await evaluate(`({ visible: [...document.querySelectorAll('.package-card')].filter(node => !node.hidden).length, empty: getComputedStyle(document.getElementById('empty-state')).display, type: new URL(location.href).searchParams.get('type') })`), { visible: 0, empty: 'block', type: 'recipe' });+ await navigate(`${base}/fixture/community.html?type=skill&lang=en`);+ assert.equal(await evaluate("document.querySelector('[data-filter=skill]').getAttribute('aria-pressed')"), 'true');+ assert.equal(await evaluate("document.querySelector('.package-card').hidden"), false);+ await navigate(`${base}/archify/index.html?lang=zh`);+ const loaded = browser.cdp.waitFor('Page.loadEventFired', session);+ await evaluate("document.querySelector('footer a[href=\"community.html\"]').click()");+ await loaded;+ assert.equal(await evaluate('document.documentElement.lang'), 'zh-CN');+ assert.equal(await evaluate('location.pathname'), '/archify/community.html');+ }+ } finally {+ if (browser) await browser.close();+ if (server) await new Promise(resolve => server.close(resolve));+ fixture.close();+ }+});diff --git a/website/test/community-build.test.mjs b/website/test/community-build.test.mjsnew file mode 100644index 00000000..e66f6fdc--- /dev/null+++ b/website/test/community-build.test.mjs@@ -0,0 +1,32 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import path from 'node:path';+import { createCommunityFixture, payload } from './helpers/community-fixture.mjs';++test('community catalog: real build rejects invalid metadata before displaying PASS', { timeout: 60000 }, () => {+ const fixture = createCommunityFixture();+ try {+ for (const mutate of [+ entry => { entry.summary.extra = true; },+ entry => { entry.repository = 'https://'; },+ ]) {+ const entry = structuredClone(fixture.entry);+ mutate(entry);+ fixture.write(entry);+ const rejected = fixture.build();+ assert.notEqual(rejected.status, 0, rejected.stdout + rejected.stderr);+ assert.match(rejected.stdout + rejected.stderr, /community registry:/);+ assert.ok(!fs.existsSync(path.join(fixture.dist, 'community.html')));+ }+ fixture.write(fixture.entry);+ const accepted = fixture.build();+ assert.equal(accepted.status, 0, accepted.stdout + accepted.stderr);+ const html = fs.readFileSync(path.join(fixture.dist, 'community.html'), 'utf8');+ assert.ok(html.includes('https://example.com/receipt'));+ assert.ok(html.includes('https://example.com/example'));+ assert.ok(!html.includes(payload), 'untrusted markup must be escaped during SSR');+ } finally {+ fixture.close();+ }+});diff --git a/website/test/community.test.mjs b/website/test/community.test.mjsindex f84e62d6..6a8a9bc2 100644--- a/website/test/community.test.mjs+++ b/website/test/community.test.mjs@@ -79,3 +79,15 @@ test('community catalog: navigation, language toggle and disclaimer are present'const submission = elements(dom, 'a').find((node) => (attr(node, 'href') || '').includes('github.com/tt-a1i/archify/tree/main/community'));assert.ok(submission, 'must link to the submission guide');});+++test('community catalog: every evidence link preserves its registry label and URL', () => {+ const cards = elements(communityDom(), 'article').filter(node => hasClass(node, 'package-card'));+ assert.ok(registry.some(entry => entry.evidence?.length > 1), 'exercise a multi-evidence entry');+ for (const entry of registry) {+ const card = cards.find(node => elements(node, 'span').some(span => hasClass(span, 'package-name') && span.childNodes.some(child => child.value === entry.name)));+ const evidence = elements(card, 'a').filter(node => hasClass(node, 'evidence-link'));+ assert.deepEqual(evidence.map(node => ({ label: attr(node, 'data-en'), url: attr(node, 'href') })),+ (entry.evidence || []).map(item => ({ label: `${item.label} ↗`, url: item.url })));+ }+});diff --git a/website/test/helpers/community-fixture.mjs b/website/test/helpers/community-fixture.mjsnew file mode 100644index 00000000..9a3175dc--- /dev/null+++ b/website/test/helpers/community-fixture.mjs@@ -0,0 +1,54 @@+import { spawnSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++export const websiteRoot = fileURLToPath(new URL('../../', import.meta.url));+const repoRoot = path.resolve(websiteRoot, '..');+export const payload = '<svg onload="document.documentElement.dataset.communityAudit=1"></svg>';++export function createCommunityFixture() {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-community-build-'));+ const copy = relative => {+ const target = path.join(root, relative);+ fs.mkdirSync(path.dirname(target), { recursive: true });+ fs.cpSync(path.join(repoRoot, relative), target, { recursive: true });+ };+ // Compile the actual page, loader, validator and language script, without+ // modifying the checked-out registry or running any community package code.+ for (const relative of ['website/src', 'website/astro.config.mjs', 'website/package.json',+ 'archify/package.json', 'archify/recipes', 'scripts/site-copy.mjs',+ 'scripts/check-community-packages.mjs', 'docs/gallery/manifest.json']) copy(relative);+ const pages = path.join(root, 'website/src/pages');+ for (const file of fs.readdirSync(pages)) {+ if (file !== 'community.astro') fs.rmSync(path.join(pages, file), { recursive: true });+ }+ fs.symlinkSync(path.join(websiteRoot, 'node_modules'), path.join(root, 'website/node_modules'), process.platform === 'win32' ? 'junction' : 'dir');+ const assets = path.join(root, 'website/.public/assets');+ fs.mkdirSync(assets, { recursive: true });+ for (const file of ['site-language.js', 'site-navigation.css', 'archify-lockup-light.svg', 'archify-mark.svg']) {+ fs.copyFileSync(path.join(repoRoot, 'docs/assets', file), path.join(assets, file));+ }+ const registry = path.join(root, 'community/packages');+ fs.mkdirSync(registry, { recursive: true });+ const entry = {+ name: 'security-demo', type: 'skill',+ summary: { en: payload, zh: `测试 ${payload}` },+ author: { name: 'demo' }, repository: 'https://example.com/source',+ archify: '3.0.1', schemaVersions: [1],+ evidence: [{ label: payload, url: 'https://example.com/receipt' }, { label: 'Example HTML', url: 'https://example.com/example' }],+ };+ const write = value => fs.writeFileSync(path.join(registry, 'security-demo.json'), JSON.stringify(value));+ write(entry);+ return {+ root, entry, write, dist: path.join(root, 'website/dist'),+ build() {+ fs.rmSync(path.join(root, 'website/dist'), { recursive: true, force: true });+ return spawnSync(process.execPath, [path.join(websiteRoot, 'node_modules/astro/bin/astro.mjs'), 'build'], {+ cwd: path.join(root, 'website'), encoding: 'utf8', timeout: 60000,+ });+ },+ close() { fs.rmSync(root, { recursive: true, force: true }); },+ };+}