1实现原理 · 为什么它能做到
工具链本质是一台「JSON-IR → 独立 HTML」编译器:作者只写一份小型强类型 JSON 规格,Node CLI 渲染成内联 SVG 的单文件 HTML,不依赖运行时后端。
Create a self-contained, interactive HTML diagram from a small typed JSON specification. Static output is the default; enable motion only when the user asks for a demo or presentation.
强制「有界创作路径」:普通生成只允许读 1 个 type schema + common schema + 1 个示例,禁止提前翻渲染器/校验器/测试源码——用阅读预算换 token 与稳定性。
Use this bounded path for ordinary generation. Do not read the optional Viewer Runtime reference unless the user asks about those features.
「产物先行」纪律:下一个工具动作必须是写出候选 JSON,禁止在 prose 里规划精确坐标;起点约束为一条主路径 + 稀疏标签 + 至多 12 个主节点。
3. Artifact first: the next tool action must write the candidate. Write the candidate before inspecting renderer internals. Do not plan exact coordinates in prose. Start with one clear main path, short side branches, sparse labels, and at most 12 primary nodes. Set `meta.quality_profile` to `"showcase"` unless the user explicitly requests a dense `standard` map. Start with automatic routes and labels. Do not add `via`, `channelX`, `channelY`, or `labelAt` before a diagnostic calls for one; apply at most one diagnosed geometry control per repair.
验收靠机器回执而不是模型自述:validate 回执只有 4 项检查 = 基础通过,showcase 必须报满 9 项 artifact 检查且 0 composition error、0 warning。
A receipt with only 4 artifact checks is basic validation, never showcase acceptance. A showcase pass must report all 9 artifact checks with 0 composition errors and 0 warnings. If the candidate omits or misspells the exact `meta.quality_profile` field, fix it before geometry. For a workflow v2 geometry diagnosis, run `node bin/archify.mjs validate workflow <candidate.json> --layout-json` and use the stable compiler receipt; solver internals are not authoring controls. A passing final validation freezes the candidate: never edit it afterward.
交付是确定性的:deliver 把规格字节冻结成同目录私有快照,渲染并校验该快照,再原子提交 HTML,输出规格与产物两者的 SHA-256 与字节数。
Use `validate` during repair and `deliver` once for final acceptance. Delivery freezes the exact specification bytes into a private same-directory snapshot, renders and checks that snapshot, atomically commits the HTML, and reports SHA-256 plus byte counts for both specification and artifact. This is deterministic artifact evidence; it does not exercise the Viewer in a browser.
更新感知是可运行的本地脚本,只做只读检查、绝不下载/安装:check-update.mjs 抓官方 manifest,展示通知后按 eventKey 回执确认。
After the first candidate exists, run the packaged checker `scripts/check-update.mjs` once with Node and continue the requested workflow. If the command cannot run, continue without mentioning the check.
manifest 地址被代码硬钉:fetchCandidate 先断言 URL 等于常量 DEFAULT_MANIFEST_URL,再以 GET + redirect:'error' + 超时 + 有界 JSON 读取,非 200 或非 application/json 一律失败。
export const DEFAULT_MANIFEST_URL = 'https://tt-a1i.github.io/archify/skill-updates/archify/stable.json';
品牌标志走「摘要钉住」而不是猜测:内置 Simple Icons 目录可离线查询;只有用户给出官方 HTTP(S) URL 时才抓取,并把抓到的图钉成 sha256 写进节点,渲染与校验永不做未钉住的抓取。
- Brand identity is optional and explicit. Put a canonical built-in ID in `brand` when the node names that real product. If no preset matches and the user supplied the official HTTP(S) URL, first run `node bin/archify.mjs brands capture "<url>" --json`, then author the returned digest-pinned `brand` object. Render and validate never perform an unpinned capture. Otherwise omit `brand`. Never infer a brand from a vague role such as "database", and never let a badge replace the semantic `type`, label, or relationship facts.
浏览器证据用本机 Chrome/Chromium 的无头 CDP(--remote-debugging-pipe)采集,不引入 Playwright/Puppeteer 依赖;找不到浏览器则明确 skip 而不是假装通过。
export function findChrome({ env = process.env, platform = process.platform } = {}) { if (Object.prototype.hasOwnProperty.call(env, 'ARCHIFY_CHROME')) { return executable(env.ARCHIFY_CHROME, platform); }
「图必须反映真实代码」时用 git 取证:repository-evidence.mjs 通过 `git -C <repo>` 读取 remote/revision 并校验 repo-relative POSIX 路径,禁止绝对路径与控制字符。
function runGit(repoRoot, args) { const result = spawnSync('git', ['-C', repoRoot, ...args], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, });
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| network | Archify 官方更新 manifest(唯一固定外发端点) |
| network | 用户提供的官方品牌页/图标 URL(仅在显式 brands capture 或节点钉住品牌时抓取;私网地址被拒绝) |
| cli | Node.js >= 18(技能包内无需 npm install,doctor 可直接自检) |
| cli | git(仅在使用 repository evidence 时调用 `git -C <repo>` 取 remote/revision) |
| cli | 本机 Google Chrome / Chromium(visual-check 的无头 CDP 浏览器;缺失则跳过并解释) |
| package | devDependencies(仅仓库开发/测试用,技能包运行时不依赖):ajv 8.17.1 / parse5 7.3.0 / saxes 6.0.0 / simple-icons 16.28.0 |
| network | 本地预览 HTTP 服务(仅绑定 127.0.0.1,URL 必须是 loopback 根路径) |
4风险提醒 风险提醒:黄色 · 留意使用
- 体量与阅读成本高 — 技能目录 214 个文件、8.5MB(含 756KB 模板与大量 test/docs),首次使用的 agent 若违反「禁读清单」会迅速吃掉上下文;作者用 SKILL.md 纪律约束,但这依赖宿主是否遵从。
- 可执行面宽于纯提示词技能 — 会在本机跑 Node、git 与无头 Chrome,并向用户产物目录写 HTML/截图/sidecar;使用前应确认宿主的命令执行与写盘授权范围。
- 更新通知的信任链在远端 — 通知内容来自 tt-a1i.github.io 的 manifest;虽然代码只取固定字段且禁止转述远端文案,若该 Pages 被篡改,展示给用户的版本/严重级别信息仍源自远端(不会自动安装,风险被限制在信息层)。
- 品牌素材许可非单一 — Simple Icons 集合为 CC0 但个别图标另有许可(如 Vue CC-BY-NC-SA-4.0、Jenkins CC-BY-SA-3.0),商用嵌入图检查需自行核对节点所用品牌;THIRD_PARTY_NOTICES.md 已逐项披露但不等同于授权。
- visual-check 通过 ≠ 好看 — 作者本人反复强调机器测量不构成感知评审;若使用者把 ok:true 当作设计质量结论,会得到虚假信心。
5第二遍独立确认
- [ok] SKILL.md 声明的 9 项 showcase 检查真实存在 — 实跑 validate architecture examples/web-app.architecture.json --quality showcase --json:ok:true,checks 恰 9 项且全 ok:true,composition.errors=0 / warnings=0,与 SKILL.md 第 28 行「must report all 9 artifact checks with 0 composition errors and 0 warnings」逐字对应。
- [ok] 更新检查只读、不下载不安装 — check-update.mjs 只有 fetch GET(candidate manifest)、有界读取与本地状态文件写入,无下载/解包/执行路径;SKILL.md 第 44 行明文承诺 'never downloads, installs, or executes an update';fetchCandidate 首行即断言 manifestUrl === DEFAULT_MANIFEST_URL。
- [ok] 固定外发端点只有一个 — http(s) 字面量扫描后,可执行代码里的外发目标仅 DEFAULT_MANIFEST_URL(scripts/update-contract.mjs:3 = https://tt-a1i.github.io/archify/skill-updates/archify/stable.json);其余 http 命中为 docs/许可声明/品牌 source 元数据/data-URI、以及 preview 的 127.0.0.1。
- [ok] 品牌抓取的 SSRF 防护成立 — validateUrlShape 拒绝非 HTTP(S)、带凭证 URL、非标准端口、localhost/.local;resolveRequestTarget 对解析出的每个地址做 isPrivateBrandAddress 检查;requestPinned 在 transport.request 的 lookup 中直接返回已校验地址,注释明说是为 'closes the DNS-rebinding gap';ARCHIFY_BRAND_ALLOW_PRIVATE=1 才放开(默认关)。
- [ok] 无凭证/密钥读取 — 对 bin/ renderers/ scripts/ delta/ 的 api_key|secret|password|token|keychain|.netrc|.ssh|bearer|authorization 扫描:命中仅为 URL 凭证字段的反向拒绝(brand-marks.mjs:126、repository-location.mjs:24-25、open-artifact.mjs:82)与 SVG tokenizer 变量名;process.env 命中全部为行为开关(ARCHIFY_*、LOCALAPPDATA、XDG_CACHE_HOME、PROGRAMFILES)。
- [ok] visual-check 的浏览器依赖与降级行为 — findChrome 支持 ARCHIFY_CHROME 覆盖 + 三平台固定路径 + linux 命令探测;不可用时 receipt.status='skipped'、exit code 2(EXIT.skipped)、诊断 viewer/chrome-unavailable,绝不谎报通过。本环境未装 Chrome,故本报告未做浏览器证据冒烟(已如实标注)。
- [ok] repository evidence 的 git 调用与路径校验 — runGit 用 spawnSync('git', ['-C', repoRoot, ...])(maxBuffer 16MiB);verifiedSourcePath 拒绝绝对路径、反斜杠、控制字符,只接受 repo-relative POSIX 路径。
- [ok] 预览服务器只在 loopback — bin/preview.mjs:13 `const loopbackHost = '127.0.0.1'`,server.listen(0, loopbackHost);bin/open-artifact.mjs 拒绝非 http/非 127.0.0.1/带端口之外形状的 URL。
6结论
6a2bea3e072ab6aa…d673e8300d