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
release: archify 2.10.0
tt-a1ifa7fbce7fba8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex abdf19e2..13013f96 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,7 +4,10 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo## [Unreleased]+## [2.10.0] — 2026-07-05+### Added+- **Actionable validator hints (#7).** Architecture layout errors now include concrete `Suggested fix` coordinates (`labelAt`, `labelDy`, nudged `pos`) so agents can patch JSON in one pass.- **Architecture grid placement (#8).** Optional `layout.mode: "grid"` with `row`/`col` per component; explicit `pos` still overrides a cell. Example: `examples/archify-repo-grid.architecture.json`.- **Layout inspect (#9).** `archify inspect architecture <file.json>` (alias: `validate --layout-json`) prints computed component rects, boundaries, connection paths, and label boxes as JSON.diff --git a/README.md b/README.mdindex bbd1b351..5e6df140 100644--- a/README.md+++ b/README.md@@ -17,7 +17,7 @@ Archify is an agent skill for Claude, Codex CLI, and opencode. It turns a plain--+**Project page:** [tt-a1i.github.io/archify](https://tt-a1i.github.io/archify/)@@ -112,26 +112,28 @@ Open the example here: [`examples/lifecycle-agent-run.html`](examples/lifecycle-## What's new-Archify is based on [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0 (dark-only, HTML output). **2.0** rewrote the template around a themeable CSS-variable system and added a client-side export pipeline. **2.1** added copy-to-clipboard + keyboard nav. **2.2** added a print stylesheet + local-font fallback. **2.3** fixed the raster upsampling bug and made exports genuinely sharp at up to 4× source resolution. **2.4** upgraded SVG export to a dual-theme self-contained file. **2.5** added renderer-backed workflow / sequence / data-flow / lifecycle modes, Mermaid input guidance, CJK-aware text measurement, golden tests, and CI. **2.6** brought the architecture renderer to schema + layout validation parity. **2.7** hardens workflow diagrams with phase headers, groups, exception lanes, happy-path linting, same-lane orthogonal routing, and a post-render HTML/SVG checker. **2.8** adds opt-in trace animation and rejects workflow routes that cross unrelated nodes. **2.9** adds a unified CLI (`bin/archify.mjs`) and real-repo architecture examples.--| Feature | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 |-|---|---|---|---|---|---|---|---|---|---|---|---|-| Dark theme | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Same | Same |-| Light theme | — | Toggle | Toggle | Toggle | Toggle + <kbd>T</kbd> shortcut | Same | Same | Same | Same | Same | Same |-| PNG / JPEG / WebP download | manual screenshot | 2× bitmap-upsampled | 1× / 2× / 4× selector (still upsampled) | same | **4× rasterized natively — no blur** | Same | **Light-export lane colors fixed** | Same | Same | Same | Same |-| SVG download | — | Vector, styles inlined (single theme) | Same | Same | Same | **Dual-theme self-contained** (`@media prefers-color-scheme`) | Same (lane colors fixed) | Same | Same | Same | Same |-| Copy PNG to clipboard | — | — | Yes | Same | Yes (up to 4×) | Same | **Safari fix** | Same | Same | Same | Same |-| Keyboard shortcuts | — | — | <kbd>T</kbd> / <kbd>E</kbd> + menu nav | Same | Same | Same | Same | Same | Same | Same | Same |-| Accessibility | — | — | ARIA + focus-visible | Same | Same | Same | Same (+ menu a11y fixes) | Same | Same | Same | Same |-| Print stylesheet | — | — | — | Yes | Yes (+ landscape + 2-col cards) | Same | Same | Same | Same | Same | Same |-| Local-font fallback on export | — | — | — | Yes | Yes | Same | **+ CJK font fallback** | Same | Same | Same | Same |-| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same | Same | Same | Same | Same | Same | Same | Same | Same |-| Typed renderers + schema validation | — | — | — | — | — | — | Workflow / sequence / data-flow / lifecycle | **+ architecture** | Same | Same | Same |-| Workflow structure aids | — | — | — | — | — | — | Lanes + routed edges | Same | **Phases, groups, exception lanes, mainPath lint** | **Route-crossing guard** | Same |-| Post-render artifact checker | — | — | — | — | — | — | — | — | **Yes** | Same | Same |-| Trace animation | — | — | — | — | — | — | — | — | — | **Opt-in** | Same |-| Unified CLI | — | — | — | — | — | — | — | — | — | — | **Yes** |-| Real-repo architecture examples | — | — | — | — | — | — | — | — | — | — | **Yes** |+Archify is based on [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0 (dark-only, HTML output). **2.0** rewrote the template around a themeable CSS-variable system and added a client-side export pipeline. **2.1** added copy-to-clipboard + keyboard nav. **2.2** added a print stylesheet + local-font fallback. **2.3** fixed the raster upsampling bug and made exports genuinely sharp at up to 4× source resolution. **2.4** upgraded SVG export to a dual-theme self-contained file. **2.5** added renderer-backed workflow / sequence / data-flow / lifecycle modes, Mermaid input guidance, CJK-aware text measurement, golden tests, and CI. **2.6** brought the architecture renderer to schema + layout validation parity. **2.7** hardens workflow diagrams with phase headers, groups, exception lanes, happy-path linting, same-lane orthogonal routing, and a post-render HTML/SVG checker. **2.8** adds opt-in trace animation and rejects workflow routes that cross unrelated nodes. **2.9** adds a unified CLI (`bin/archify.mjs`) and real-repo architecture examples. **2.10** adds actionable validator hints, optional architecture grid placement (`row`/`col`), and `archify inspect` for computed layout JSON.++| Feature | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 | 2.10 |+|---|---|---|---|---|---|---|---|---|---|---|---|---|+| Dark theme | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Same | Same | Same |+| Light theme | — | Toggle | Toggle | Toggle | Toggle + <kbd>T</kbd> shortcut | Same | Same | Same | Same | Same | Same | Same |+| PNG / JPEG / WebP download | manual screenshot | 2× bitmap-upsampled | 1× / 2× / 4× selector (still upsampled) | same | **4× rasterized natively — no blur** | Same | **Light-export lane colors fixed** | Same | Same | Same | Same | Same |+| SVG download | — | Vector, styles inlined (single theme) | Same | Same | Same | **Dual-theme self-contained** (`@media prefers-color-scheme`) | Same (lane colors fixed) | Same | Same | Same | Same | Same |+| Copy PNG to clipboard | — | — | Yes | Same | Yes (up to 4×) | Same | **Safari fix** | Same | Same | Same | Same | Same |+| Keyboard shortcuts | — | — | <kbd>T</kbd> / <kbd>E</kbd> + menu nav | Same | Same | Same | Same | Same | Same | Same | Same | Same |+| Accessibility | — | — | ARIA + focus-visible | Same | Same | Same | Same (+ menu a11y fixes) | Same | Same | Same | Same | Same |+| Print stylesheet | — | — | — | Yes | Yes (+ landscape + 2-col cards) | Same | Same | Same | Same | Same | Same | Same |+| Local-font fallback on export | — | — | — | Yes | Yes | Same | **+ CJK font fallback** | Same | Same | Same | Same | Same |+| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same | Same | Same | Same | Same | Same | Same | Same | Same | Same |+| Typed renderers + schema validation | — | — | — | — | — | — | Workflow / sequence / data-flow / lifecycle | **+ architecture** | Same | Same | Same | Same |+| Workflow structure aids | — | — | — | — | — | — | Lanes + routed edges | Same | **Phases, groups, exception lanes, mainPath lint** | **Route-crossing guard** | Same | Same |+| Post-render artifact checker | — | — | — | — | — | — | — | — | **Yes** | Same | Same | Same |+| Trace animation | — | — | — | — | — | — | — | — | — | **Opt-in** | Same | Same |+| Unified CLI | — | — | — | — | — | — | — | — | — | — | **Yes** | Same |+| Real-repo architecture examples | — | — | — | — | — | — | — | — | — | — | **Yes** | Same |+| Architecture grid + layout inspect | — | — | — | — | — | — | — | — | — | — | — | **Yes** |+| Validator actionable hints | — | — | — | — | — | — | — | — | — | — | — | **Yes** |## Quick startdiff --git a/README_EN.md b/README_EN.mdindex 2c8904d6..42eb81ac 100644--- a/README_EN.md+++ b/README_EN.md@@ -17,7 +17,7 @@ Archify is an agent skill for Claude, Codex CLI, and opencode. It turns a plain--+**Project page:** [tt-a1i.github.io/archify](https://tt-a1i.github.io/archify/)@@ -111,26 +111,28 @@ Open the example here: [`examples/lifecycle-agent-run.html`](examples/lifecycle-## What's new-Archify is based on [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0 (dark-only, HTML output). **2.0** rewrote the template around a themeable CSS-variable system and added a client-side export pipeline. **2.1** added copy-to-clipboard + keyboard nav. **2.2** added a print stylesheet + local-font fallback. **2.3** fixed the raster upsampling bug and made exports genuinely sharp at up to 4× source resolution. **2.4** upgraded SVG export to a dual-theme self-contained file. **2.5** added renderer-backed workflow / sequence / data-flow / lifecycle modes, Mermaid input guidance, CJK-aware text measurement, golden tests, and CI. **2.6** brought the architecture renderer to schema + layout validation parity. **2.7** hardens workflow diagrams with phase headers, groups, exception lanes, happy-path linting, same-lane orthogonal routing, and a post-render HTML/SVG checker. **2.8** adds opt-in trace animation and rejects workflow routes that cross unrelated nodes. **2.9** adds a unified CLI (`bin/archify.mjs`) and real-repo architecture examples.--| Feature | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 |-|---|---|---|---|---|---|---|---|---|---|---|---|-| Dark theme | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Same | Same |-| Light theme | — | Toggle | Toggle | Toggle | Toggle + <kbd>T</kbd> shortcut | Same | Same | Same | Same | Same | Same |-| PNG / JPEG / WebP download | manual screenshot | 2× bitmap-upsampled | 1× / 2× / 4× selector (still upsampled) | same | **4× rasterized natively — no blur** | Same | **Light-export lane colors fixed** | Same | Same | Same | Same |-| SVG download | — | Vector, styles inlined (single theme) | Same | Same | Same | **Dual-theme self-contained** (`@media prefers-color-scheme`) | Same (lane colors fixed) | Same | Same | Same | Same |-| Copy PNG to clipboard | — | — | Yes | Same | Yes (up to 4×) | Same | **Safari fix** | Same | Same | Same | Same |-| Keyboard shortcuts | — | — | <kbd>T</kbd> / <kbd>E</kbd> + menu nav | Same | Same | Same | Same | Same | Same | Same | Same |-| Accessibility | — | — | ARIA + focus-visible | Same | Same | Same | Same (+ menu a11y fixes) | Same | Same | Same | Same |-| Print stylesheet | — | — | — | Yes | Yes (+ landscape + 2-col cards) | Same | Same | Same | Same | Same | Same |-| Local-font fallback on export | — | — | — | Yes | Yes | Same | **+ CJK font fallback** | Same | Same | Same | Same |-| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same | Same | Same | Same | Same | Same | Same | Same | Same |-| Typed renderers + schema validation | — | — | — | — | — | — | Workflow / sequence / data-flow / lifecycle | **+ architecture** | Same | Same | Same |-| Workflow structure aids | — | — | — | — | — | — | Lanes + routed edges | Same | **Phases, groups, exception lanes, mainPath lint** | **Route-crossing guard** | Same |-| Post-render artifact checker | — | — | — | — | — | — | — | — | **Yes** | Same | Same |-| Trace animation | — | — | — | — | — | — | — | — | — | **Opt-in** | Same |-| Unified CLI | — | — | — | — | — | — | — | — | — | — | **Yes** |-| Real-repo architecture examples | — | — | — | — | — | — | — | — | — | — | **Yes** |+Archify is based on [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0 (dark-only, HTML output). **2.0** rewrote the template around a themeable CSS-variable system and added a client-side export pipeline. **2.1** added copy-to-clipboard + keyboard nav. **2.2** added a print stylesheet + local-font fallback. **2.3** fixed the raster upsampling bug and made exports genuinely sharp at up to 4× source resolution. **2.4** upgraded SVG export to a dual-theme self-contained file. **2.5** added renderer-backed workflow / sequence / data-flow / lifecycle modes, Mermaid input guidance, CJK-aware text measurement, golden tests, and CI. **2.6** brought the architecture renderer to schema + layout validation parity. **2.7** hardens workflow diagrams with phase headers, groups, exception lanes, happy-path linting, same-lane orthogonal routing, and a post-render HTML/SVG checker. **2.8** adds opt-in trace animation and rejects workflow routes that cross unrelated nodes. **2.9** adds a unified CLI (`bin/archify.mjs`) and real-repo architecture examples. **2.10** adds actionable validator hints, optional architecture grid placement (`row`/`col`), and `archify inspect` for computed layout JSON.++| Feature | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 | 2.10 |+|---|---|---|---|---|---|---|---|---|---|---|---|---|+| Dark theme | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Same | Same | Same |+| Light theme | — | Toggle | Toggle | Toggle | Toggle + <kbd>T</kbd> shortcut | Same | Same | Same | Same | Same | Same | Same |+| PNG / JPEG / WebP download | manual screenshot | 2× bitmap-upsampled | 1× / 2× / 4× selector (still upsampled) | same | **4× rasterized natively — no blur** | Same | **Light-export lane colors fixed** | Same | Same | Same | Same | Same |+| SVG download | — | Vector, styles inlined (single theme) | Same | Same | Same | **Dual-theme self-contained** (`@media prefers-color-scheme`) | Same (lane colors fixed) | Same | Same | Same | Same | Same |+| Copy PNG to clipboard | — | — | Yes | Same | Yes (up to 4×) | Same | **Safari fix** | Same | Same | Same | Same | Same |+| Keyboard shortcuts | — | — | <kbd>T</kbd> / <kbd>E</kbd> + menu nav | Same | Same | Same | Same | Same | Same | Same | Same | Same |+| Accessibility | — | — | ARIA + focus-visible | Same | Same | Same | Same (+ menu a11y fixes) | Same | Same | Same | Same | Same |+| Print stylesheet | — | — | — | Yes | Yes (+ landscape + 2-col cards) | Same | Same | Same | Same | Same | Same | Same |+| Local-font fallback on export | — | — | — | Yes | Yes | Same | **+ CJK font fallback** | Same | Same | Same | Same | Same |+| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same | Same | Same | Same | Same | Same | Same | Same | Same | Same |+| Typed renderers + schema validation | — | — | — | — | — | — | Workflow / sequence / data-flow / lifecycle | **+ architecture** | Same | Same | Same | Same |+| Workflow structure aids | — | — | — | — | — | — | Lanes + routed edges | Same | **Phases, groups, exception lanes, mainPath lint** | **Route-crossing guard** | Same | Same |+| Post-render artifact checker | — | — | — | — | — | — | — | — | **Yes** | Same | Same | Same |+| Trace animation | — | — | — | — | — | — | — | — | — | **Opt-in** | Same | Same |+| Unified CLI | — | — | — | — | — | — | — | — | — | — | **Yes** | Same |+| Real-repo architecture examples | — | — | — | — | — | — | — | — | — | — | **Yes** | Same |+| Architecture grid + layout inspect | — | — | — | — | — | — | — | — | — | — | — | **Yes** |+| Validator actionable hints | — | — | — | — | — | — | — | — | — | — | — | **Yes** |## Quick startdiff --git a/README_ZH.md b/README_ZH.mdindex 47d32496..9a01f346 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -17,7 +17,7 @@ Archify 是一个可用于 Claude、Codex CLI 和 opencode 的 agent skill:你-+**[在线落地页 → tt-a1i.github.io/archify](https://tt-a1i.github.io/archify/)**@@ -113,26 +113,28 @@ Needs Approval,缺少输入时进入 Blocked;工具失败可以 Failed 后## 版本演进-Archify 基于 [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0(只有深色主题的 HTML 输出)fork 重写。**2.0** 把模板重构成 CSS 变量驱动的可主题化系统,加入客户端导出流水线。**2.1** 加入剪贴板复制 + 键盘导航。**2.2** 加入打印样式 + 本地字体回退。**2.3** 修了位图升采样 bug,所有光栅导出改为最高 4× 原生渲染。**2.4** SVG 导出升级成双主题自持版。**2.5** 加入 workflow / sequence / data-flow / lifecycle 四种渲染器、Mermaid 输入指引、CJK-aware 文本测量、golden 测试和 CI。**2.6** 把 architecture 模式也升级到 schema + layout 校验。**2.7** 强化 workflow:phase header、group、exception lane、mainPath 主路径 lint、同泳道正交连线,以及生成后 HTML/SVG 检查器。**2.8** 加入按需 trace 动效,并拒绝 workflow 连线穿过无关节点。**2.9** 加入统一 CLI(`bin/archify.mjs`)和真实仓库 architecture 示例。--| 能力 | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 |-|---|---|---|---|---|---|---|---|---|---|---|---|-| 深色主题 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 同 | 同 |-| 浅色主题 | — | 切换 | 切换 | 切换 | 切换 + <kbd>T</kbd> 快捷键 | 同 | 同 | 同 | 同 | 同 | 同 |-| PNG / JPEG / WebP 下载 | 手动截图 | 2× 位图放大 | 1×/2×/4× 选择器(仍是放大)| 同 | **4× 原生光栅化,不糊** | 同 | **浅色导出泳道配色修复** | 同 | 同 | 同 | 同 |-| SVG 下载 | — | 矢量 + 内联样式(单主题)| 同 | 同 | 同 | **双主题自持**(`@media prefers-color-scheme`)| 同(泳道配色修复)| 同 | 同 | 同 | 同 |-| 复制 PNG 到剪贴板 | — | — | ✓ | 同 | 同(最高 4×)| 同 | **Safari 修复** | 同 | 同 | 同 | 同 |-| 键盘快捷键 | — | — | <kbd>T</kbd>/<kbd>E</kbd> + 菜单导航 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 |-| 可访问性 | — | — | ARIA + focus-visible | 同 | 同 | 同 | 同(+ 菜单 a11y 修复)| 同 | 同 | 同 | 同 |-| 打印样式表 | — | — | — | ✓ | ✓(+ 横向 + 2 列卡片)| 同 | 同 | 同 | 同 | 同 | 同 |-| 导出时本地字体回退 | — | — | — | ✓ | ✓ | 同 | **+ CJK 字体回退** | 同 | 同 | 同 | 同 |-| 样式模型 | 内联 `fill` / `stroke` | CSS 变量 + 语义 class | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 |-| 类型化渲染器 + schema 校验 | — | — | — | — | — | — | workflow / sequence / data-flow / lifecycle | **+ architecture** | 同 | 同 | 同 |-| Workflow 结构辅助 | — | — | — | — | — | — | 泳道 + 路由连线 | 同 | **phase、group、exception lane、mainPath lint** | **连线穿节点 guard** | 同 |-| 生成后 artifact 检查 | — | — | — | — | — | — | — | — | **✓** | 同 | 同 |-| Trace 动效 | — | — | — | — | — | — | — | — | — | **按需开启** | 同 |-| 统一 CLI | — | — | — | — | — | — | — | — | — | — | **✓** |-| 真实仓库 architecture 示例 | — | — | — | — | — | — | — | — | — | — | **✓** |+Archify 基于 [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0(只有深色主题的 HTML 输出)fork 重写。**2.0** 把模板重构成 CSS 变量驱动的可主题化系统,加入客户端导出流水线。**2.1** 加入剪贴板复制 + 键盘导航。**2.2** 加入打印样式 + 本地字体回退。**2.3** 修了位图升采样 bug,所有光栅导出改为最高 4× 原生渲染。**2.4** SVG 导出升级成双主题自持版。**2.5** 加入 workflow / sequence / data-flow / lifecycle 四种渲染器、Mermaid 输入指引、CJK-aware 文本测量、golden 测试和 CI。**2.6** 把 architecture 模式也升级到 schema + layout 校验。**2.7** 强化 workflow:phase header、group、exception lane、mainPath 主路径 lint、同泳道正交连线,以及生成后 HTML/SVG 检查器。**2.8** 加入按需 trace 动效,并拒绝 workflow 连线穿过无关节点。**2.9** 加入统一 CLI(`bin/archify.mjs`)和真实仓库 architecture 示例。**2.10** 加入 validator 修复建议、architecture grid(`row`/`col`)和 `archify inspect` 布局 JSON。++| 能力 | v1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 | 2.10 |+|---|---|---|---|---|---|---|---|---|---|---|---|---|+| 深色主题 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 同 | 同 | 同 |+| 浅色主题 | — | 切换 | 切换 | 切换 | 切换 + <kbd>T</kbd> 快捷键 | 同 | 同 | 同 | 同 | 同 | 同 | 同 |+| PNG / JPEG / WebP 下载 | 手动截图 | 2× 位图放大 | 1×/2×/4× 选择器(仍是放大)| 同 | **4× 原生光栅化,不糊** | 同 | **浅色导出泳道配色修复** | 同 | 同 | 同 | 同 | 同 |+| SVG 下载 | — | 矢量 + 内联样式(单主题)| 同 | 同 | 同 | **双主题自持**(`@media prefers-color-scheme`)| 同(泳道配色修复)| 同 | 同 | 同 | 同 | 同 |+| 复制 PNG 到剪贴板 | — | — | ✓ | 同 | 同(最高 4×)| 同 | **Safari 修复** | 同 | 同 | 同 | 同 | 同 |+| 键盘快捷键 | — | — | <kbd>T</kbd>/<kbd>E</kbd> + 菜单导航 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 |+| 可访问性 | — | — | ARIA + focus-visible | 同 | 同 | 同 | 同(+ 菜单 a11y 修复)| 同 | 同 | 同 | 同 | 同 |+| 打印样式表 | — | — | — | ✓ | ✓(+ 横向 + 2 列卡片)| 同 | 同 | 同 | 同 | 同 | 同 | 同 |+| 导出时本地字体回退 | — | — | — | ✓ | ✓ | 同 | **+ CJK 字体回退** | 同 | 同 | 同 | 同 | 同 |+| 样式模型 | 内联 `fill` / `stroke` | CSS 变量 + 语义 class | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 | 同 |+| 类型化渲染器 + schema 校验 | — | — | — | — | — | — | workflow / sequence / data-flow / lifecycle | **+ architecture** | 同 | 同 | 同 | 同 |+| Workflow 结构辅助 | — | — | — | — | — | — | 泳道 + 路由连线 | 同 | **phase、group、exception lane、mainPath lint** | **连线穿节点 guard** | 同 | 同 |+| 生成后 artifact 检查 | — | — | — | — | — | — | — | — | **✓** | 同 | 同 | 同 |+| Trace 动效 | — | — | — | — | — | — | — | — | — | **按需开启** | 同 | 同 |+| 统一 CLI | — | — | — | — | — | — | — | — | — | — | **✓** | 同 |+| 真实仓库 architecture 示例 | — | — | — | — | — | — | — | — | — | — | **✓** | 同 |+| Architecture grid + layout inspect | — | — | — | — | — | — | — | — | — | — | — | **✓** |+| Validator 修复建议 | — | — | — | — | — | — | — | — | — | — | — | **✓** |## 快速上手diff --git a/ROADMAP.md b/ROADMAP.mdindex c9b6e641..ef3c535c 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -1,6 +1,6 @@# Archify Roadmap-As of v2.9.0, the coordinate-stability work has shipped as JSON IR plus typed renderers for architecture, workflow, sequence, data-flow, and lifecycle diagrams. Workflow diagrams now also have phase/group/exception-lane structure, happy-path linting, trace animation, and route-crossing guards. A unified CLI (`bin/archify.mjs`) wraps render, validate, check, and examples. This file records the design decisions that led there, plus the ideas that were explicitly declined. The original v2.4 / v2.5 backlog (export-scale URL param, color-blind palette, gzip+base64 share links) was considered and dropped — see [Not planned](#not-planned) for the rationale on each.+As of v2.10.0, the coordinate-stability work has shipped as JSON IR plus typed renderers for architecture, workflow, sequence, data-flow, and lifecycle diagrams. Workflow diagrams now also have phase/group/exception-lane structure, happy-path linting, trace animation, and route-crossing guards. A unified CLI (`bin/archify.mjs`) wraps render, validate, check, and examples. This file records the design decisions that led there, plus the ideas that were explicitly declined. The original v2.4 / v2.5 backlog (export-scale URL param, color-blind palette, gzip+base64 share links) was considered and dropped — see [Not planned](#not-planned) for the rationale on each.This roadmap was rewritten on 2026-04-16 after three independent design reviews, and updated the same day after a visual-quality validation experiment conclusively failed (see `experiments/v3-mermaid-validation/RESULT.md`).diff --git a/archify.zip b/archify.zipindex 992b55ff..ad13a024 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/SKILL.md b/archify/SKILL.mdindex 93615e7f..76b3bd50 100644--- a/archify/SKILL.md+++ b/archify/SKILL.md@@ -3,7 +3,7 @@ name: archifydescription: Create professional architecture, workflow, sequence, data-flow, and lifecycle/state diagrams as standalone HTML files with SVG graphics, a built-in dark/light theme toggle, and one-click export to PNG / JPEG / WebP / SVG. Accepts plain-language descriptions or pasted Mermaid code (flowchart, sequenceDiagram, stateDiagram) and lays the diagram out from scratch in archify style. Use when the user asks for system architecture diagrams, infrastructure diagrams, cloud architecture visualizations, security diagrams, network topology, technical workflows, approval flows, runbooks, CI/CD flows, process diagrams, API call sequences, request lifecycles, data pipelines, ETL/ELT maps, PII boundaries, data lineage, state machines, lifecycle diagrams, status transitions, or asks to convert/beautify a Mermaid diagram.license: MITmetadata:- version: "2.9"+ version: "2.10"author: tt-a1ibased_on: Cocoon-AI/architecture-diagram-generator (MIT, v1.0)---diff --git a/archify/assets/template.html b/archify/assets/template.htmlindex f1657fba..c1728c95 100644--- a/archify/assets/template.html+++ b/archify/assets/template.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>[PROJECT NAME] Architecture Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/archify/package-lock.json b/archify/package-lock.jsonindex 71bed22d..8d5e7759 100644--- a/archify/package-lock.json+++ b/archify/package-lock.json@@ -1,12 +1,12 @@{"name": "archify",- "version": "2.9.0",+ "version": "2.10.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "archify",- "version": "2.9.0",+ "version": "2.10.0","license": "MIT","dependencies": {"ajv": "^8.17.1"diff --git a/archify/package.json b/archify/package.jsonindex 6f530524..feccd267 100644--- a/archify/package.json+++ b/archify/package.json@@ -1,6 +1,6 @@{"name": "archify",- "version": "2.9.0",+ "version": "2.10.0","private": true,"type": "module","description": "JSON-IR diagram renderers (architecture / workflow / sequence / dataflow / lifecycle).",diff --git a/docs/index.html b/docs/index.htmlindex 3ead1130..a9ac7588 100644--- a/docs/index.html+++ b/docs/index.html@@ -216,7 +216,7 @@<div class="container"><div class="hero-badge fade-up"><div class="pulse-dot"></div>- <span data-i18n="hero-badge">Agent Skill · v2.9.0</span>+ <span data-i18n="hero-badge">Agent Skill · v2.10.0</span></div><h1 class="fade-up d1" data-i18n="hero-h1">From plain English<br>to architecture <em>in seconds.</em></h1><p class="hero-sub fade-up d2" data-i18n="hero-sub">Describe your system in chat. Archify generates a polished, self-contained HTML diagram — with dark/light themes, clipboard copy, and ultra-crisp 4× export built in.</p>@@ -553,7 +553,7 @@ this description.</span><svg width="22" height="22" viewBox="0 0 28 28" fill="none"><polygon points="14,2 26,8 26,20 14,26 2,20 2,8" fill="rgba(8,51,68,0.7)" stroke="#22d3ee" stroke-width="1.5"/><circle cx="14" cy="15" r="2.5" fill="#22d3ee"/></svg><span style="font-size:.8125rem;font-weight:700;color:var(--muted)">Archify</span></a>- <p class="footer-meta" data-i18n="footer-meta">v2.9.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator</p>+ <p class="footer-meta" data-i18n="footer-meta">v2.10.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator</p></div><div class="footer-links"><a href="https://github.com/tt-a1i/archify" target="_blank" rel="noopener">GitHub</a>@@ -570,7 +570,7 @@ this description.</span>const LANGS = {en: {'nav-docs':'Docs','nav-install':'Install Skill',- 'hero-badge':'Agent Skill · v2.9.0',+ 'hero-badge':'Agent Skill · v2.10.0','hero-h1':'From plain English<br>to architecture <em>in seconds.</em>','hero-sub':'Describe your system in chat. Archify generates a polished, self-contained HTML diagram — with dark/light themes, clipboard copy, and ultra-crisp 4× export built in.','hero-cta':'Get started','hero-gh':'View on GitHub',@@ -621,12 +621,12 @@ this description.</span>'step3-h':'Ask Claude to draw it','step3-p':'Tell Claude to use the Archify skill. It generates a self-contained HTML file you open in any browser. Iterate from there — in plain English.','code-label':'example prompt','kbd-label':'Keyboard shortcuts','kbd-theme':'Toggle theme','kbd-export':'Open export menu','kbd-nav':'Navigate menu','kbd-close':'Close menu',- 'footer-meta':'v2.9.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator',+ 'footer-meta':'v2.10.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator','footer-changelog':'Changelog','footer-license':'License'},zh: {'nav-docs':'文档','nav-install':'安装技能',- 'hero-badge':'Agent 技能 · v2.9.0',+ 'hero-badge':'Agent 技能 · v2.10.0','hero-h1':'用自然语言,<br>秒级生成<em>架构图。</em>','hero-sub':'在对话中描述你的系统,Archify 生成精美、独立的 HTML 架构图——内置深色/浅色主题、一键复制剪贴板、超清 4× 图片导出。','hero-cta':'快速开始','hero-gh':'在 GitHub 查看',@@ -677,7 +677,7 @@ this description.</span>'step3-h':'让 Claude 绘制','step3-p':'告诉 Claude 使用 Archify 技能,它会生成独立的 HTML 文件,用任意浏览器打开即可。然后继续用自然语言迭代。','code-label':'示例提示词','kbd-label':'键盘快捷键','kbd-theme':'切换主题','kbd-export':'打开导出菜单','kbd-nav':'菜单导航','kbd-close':'关闭菜单',- 'footer-meta':'v2.9.0 · MIT 许可证<br>基于 Cocoon-AI/architecture-diagram-generator',+ 'footer-meta':'v2.10.0 · MIT 许可证<br>基于 Cocoon-AI/architecture-diagram-generator','footer-changelog':'更新日志','footer-license':'许可证'}};diff --git a/examples/archify-repo.html b/examples/archify-repo.htmlindex a72d1a80..10fb61c2 100644--- a/examples/archify-repo.html+++ b/examples/archify-repo.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Archify Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/dataflow-product-analytics.html b/examples/dataflow-product-analytics.htmlindex 1bd90d30..0a819236 100644--- a/examples/dataflow-product-analytics.html+++ b/examples/dataflow-product-analytics.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Product Analytics Data Flow Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/lifecycle-agent-run.html b/examples/lifecycle-agent-run.htmlindex d44d1558..a14650ee 100644--- a/examples/lifecycle-agent-run.html+++ b/examples/lifecycle-agent-run.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Agent Run Lifecycle Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/maka-architecture.html b/examples/maka-architecture.htmlindex 48ecc2e5..e7698cb0 100644--- a/examples/maka-architecture.html+++ b/examples/maka-architecture.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Maka Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/sequence-cache-miss-request.html b/examples/sequence-cache-miss-request.htmlindex e8403236..d63145c7 100644--- a/examples/sequence-cache-miss-request.html+++ b/examples/sequence-cache-miss-request.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Cache Miss Request Sequence Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/sequence-cache-miss.html b/examples/sequence-cache-miss.htmlnew file mode 100644index 00000000..e8403236--- /dev/null+++ b/examples/sequence-cache-miss.html@@ -0,0 +1,1261 @@+<!DOCTYPE html>+<html lang="en" data-theme="dark">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="generator" content="archify 2.9.0">+ <title>Cache Miss Request Sequence Diagram</title>+ <script>+ // Resolve the theme before first paint so light-preference users don't+ // see a dark flash. The toolbar script below re-applies with UI state.+ (function () {+ try {+ var theme = null;+ try {+ var param = new URLSearchParams(window.location.search).get('theme');+ if (param === 'light' || param === 'dark') theme = param;+ } catch (_) {}+ if (!theme) {+ try { theme = localStorage.getItem('archify-theme'); } catch (_) {}+ }+ if (theme !== 'light' && theme !== 'dark') {+ theme = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';+ }+ document.documentElement.setAttribute('data-theme', theme);+ } catch (_) {}+ })();+ </script>+ <!-- Async font load: a blackholed network must not block first paint.+ The body font stack falls back to system monospace until it lands. -->+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"+ rel="stylesheet" media="print" onload="this.media='all'">+ <noscript>+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">+ </noscript>+ <style>+ /* ==========================================================+ THEME VARIABLES — switch by toggling [data-theme] on <html>+ ========================================================== */+ :root,+ [data-theme="dark"] {+ --bg: #020617;+ --grid: #1e293b;+ --text: #ffffff;+ --text-muted: #94a3b8;+ --text-dim: #475569;+ /* UI chrome (menu hints, footer) needs more contrast than SVG .t-dim accents */+ --text-faint: #7d8da1;++ --panel: rgba(15, 23, 42, 0.5);+ --panel-border: #1e293b;+ --lane-fill: rgba(15, 23, 42, 0.22);+ --lane-stroke: #334155;++ --arrow: #64748b;+ --arrow-emphasis: #34d399;++ /* Opaque mask color used behind semi-transparent component fills+ so the arrows drawn underneath are properly hidden. */+ --mask: #0f172a;++ --frontend-fill: rgba(8, 51, 68, 0.4);+ --frontend-stroke: #22d3ee;+ --backend-fill: rgba(6, 78, 59, 0.4);+ --backend-stroke: #34d399;+ --database-fill: rgba(76, 29, 149, 0.4);+ --database-stroke: #a78bfa;+ --cloud-fill: rgba(120, 53, 15, 0.3);+ --cloud-stroke: #fbbf24;+ --security-fill: rgba(136, 19, 55, 0.4);+ --security-stroke: #fb7185;+ --messagebus-fill: rgba(251, 146, 60, 0.3);+ --messagebus-stroke:#fb923c;+ --external-fill: rgba(30, 41, 59, 0.5);+ --external-stroke: #94a3b8;++ --toolbar-bg: rgba(15, 23, 42, 0.8);+ --toolbar-border: #334155;+ --toolbar-text: #e2e8f0;+ --toolbar-hover: rgba(15, 23, 42, 0.95);+ --toolbar-menu-bg: #0f172a;+ }++ [data-theme="light"] {+ --bg: #f8fafc;+ --grid: #e2e8f0;+ --text: #0f172a;+ --text-muted: #64748b;+ --text-dim: #94a3b8;+ --text-faint: #64748b;++ --panel: #ffffff;+ --panel-border: #e2e8f0;+ --lane-fill: rgba(248, 250, 252, 0.65);+ --lane-stroke: #cbd5e1;++ --arrow: #94a3b8;+ --arrow-emphasis: #059669;++ --mask: #ffffff;++ --frontend-fill: rgba(34, 211, 238, 0.15);+ --frontend-stroke: #0891b2;+ --backend-fill: rgba(52, 211, 153, 0.18);+ --backend-stroke: #059669;+ --database-fill: rgba(167, 139, 250, 0.2);+ --database-stroke: #7c3aed;+ --cloud-fill: rgba(251, 191, 36, 0.18);+ --cloud-stroke: #d97706;+ --security-fill: rgba(251, 113, 133, 0.15);+ --security-stroke: #e11d48;+ --messagebus-fill: rgba(251, 146, 60, 0.15);+ --messagebus-stroke:#ea580c;+ --external-fill: rgba(148, 163, 184, 0.18);+ --external-stroke: #64748b;++ --toolbar-bg: rgba(255, 255, 255, 0.92);+ --toolbar-border: #cbd5e1;+ --toolbar-text: #334155;+ --toolbar-hover: #ffffff;+ --toolbar-menu-bg: #ffffff;+ }++ * { margin: 0; padding: 0; box-sizing: border-box; }++ body {+ font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace;+ background: var(--bg);+ min-height: 100vh;+ padding: 2rem;+ color: var(--text);+ transition: background 0.2s ease, color 0.2s ease;+ }++ .container { max-width: 1200px; margin: 0 auto; }++ .header { margin-bottom: 2rem; }++ .header-row {+ display: flex;+ align-items: center;+ gap: 1rem;+ margin-bottom: 0.5rem;+ }++ .pulse-dot {+ width: 12px;+ height: 12px;+ background: var(--frontend-stroke);+ border-radius: 50%;+ animation: pulse 2s infinite;+ }++ @keyframes pulse {+ 0%, 100% { opacity: 1; }+ 50% { opacity: 0.5; }+ }++ h1 {+ font-size: 1.5rem;+ font-weight: 700;+ letter-spacing: -0.025em;+ }++ .subtitle {+ color: var(--text-muted);+ font-size: 0.875rem;+ margin-left: 1.75rem;+ }++ .diagram-container {+ background: var(--panel);+ border-radius: 1rem;+ border: 1px solid var(--panel-border);+ padding: 1.5rem;+ overflow-x: auto;+ }++ svg {+ width: 100%;+ min-width: min(900px, 100%);+ display: block;+ }++ .cards {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));+ gap: 1rem;+ margin-top: 2rem;+ }++ .card {+ background: var(--panel);+ border-radius: 0.75rem;+ border: 1px solid var(--panel-border);+ padding: 1.25rem;+ }++ .card-header {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ margin-bottom: 0.75rem;+ }++ .card-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ }++ .card-dot.cyan { background: var(--frontend-stroke); }+ .card-dot.emerald { background: var(--backend-stroke); }+ .card-dot.violet { background: var(--database-stroke); }+ .card-dot.amber { background: var(--cloud-stroke); }+ .card-dot.rose { background: var(--security-stroke); }+ .card-dot.orange { background: var(--messagebus-stroke); }+ .card-dot.slate { background: var(--external-stroke); }++ .card h3 { font-size: 0.875rem; font-weight: 600; color: var(--text); }++ .card ul {+ list-style: none;+ color: var(--text-muted);+ font-size: 0.75rem;+ }++ .card li { margin-bottom: 0.375rem; }++ .footer {+ text-align: center;+ margin-top: 1.5rem;+ color: var(--text-faint);+ font-size: 0.75rem;+ }++ /* ==========================================================+ Print stylesheet — hide interactive controls, force light,+ drop the grid so the diagram doesn't waste ink, use landscape+ so wide diagrams fit, pack summary cards into 2 columns to+ avoid an orphan card on a trailing page.+ ========================================================== */+ @page { size: landscape; margin: 1.5cm; }++ @media print {+ /* Force the FULL light palette — including component fills/strokes and+ lane/arrow colors — so printing from dark theme doesn't put neon+ strokes and translucent dark fills on white paper. */+ :root, [data-theme="dark"], [data-theme="light"] {+ --bg: #ffffff;+ --grid: transparent;+ --panel: #ffffff;+ --panel-border: #e2e8f0;+ --text: #0f172a;+ --text-muted: #475569;+ --text-dim: #94a3b8;+ --text-faint: #64748b;+ --mask: #ffffff;+ --lane-fill: rgba(248, 250, 252, 0.65);+ --lane-stroke: #cbd5e1;+ --arrow: #94a3b8;+ --arrow-emphasis: #059669;+ --frontend-fill: rgba(34, 211, 238, 0.15);+ --frontend-stroke: #0891b2;+ --backend-fill: rgba(52, 211, 153, 0.18);+ --backend-stroke: #059669;+ --database-fill: rgba(167, 139, 250, 0.2);+ --database-stroke: #7c3aed;+ --cloud-fill: rgba(251, 191, 36, 0.18);+ --cloud-stroke: #d97706;+ --security-fill: rgba(251, 113, 133, 0.15);+ --security-stroke: #e11d48;+ --messagebus-fill: rgba(251, 146, 60, 0.15);+ --messagebus-stroke:#ea580c;+ --external-fill: rgba(148, 163, 184, 0.18);+ --external-stroke: #64748b;+ }+ body { background: #ffffff !important; padding: 0; }+ .container { max-width: none; }+ .toolbar, .archify-toast, .no-print { display: none !important; }+ .diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .cards { grid-template-columns: 1fr 1fr; }+ /* Ensure elements break sensibly across pages */+ .card { break-inside: avoid; page-break-inside: avoid; }+ .diagram-container { break-inside: avoid; page-break-inside: avoid; }+ h1, .subtitle { color: #0f172a; }+ }++ /* ==========================================================+ TOOLBAR (theme toggle + export menu)+ ========================================================== */+ .toolbar {+ position: fixed;+ top: 1rem;+ right: 1rem;+ display: flex;+ gap: 0.5rem;+ z-index: 100;+ }+ .toolbar button {+ background: var(--toolbar-bg);+ color: var(--toolbar-text);+ border: 1px solid var(--toolbar-border);+ padding: 0.5rem 0.875rem;+ border-radius: 0.5rem;+ font-family: inherit;+ font-size: 0.75rem;+ font-weight: 500;+ cursor: pointer;+ backdrop-filter: blur(8px);+ transition: background 0.15s, border-color 0.15s;+ display: inline-flex;+ align-items: center;+ gap: 0.375rem;+ }+ .toolbar button:hover {+ background: var(--toolbar-hover);+ border-color: var(--arrow);+ }+ .toolbar button:focus-visible {+ outline: 2px solid var(--frontend-stroke);+ outline-offset: 2px;+ }+ .toolbar .export-wrap { position: relative; }+ .toolbar .export-menu {+ position: absolute;+ top: calc(100% + 0.375rem);+ right: 0;+ background: var(--toolbar-menu-bg);+ border: 1px solid var(--toolbar-border);+ border-radius: 0.5rem;+ padding: 0.375rem;+ min-width: 160px;+ display: none;+ flex-direction: column;+ box-shadow: 0 4px 20px rgba(0,0,0,0.25);+ }+ .toolbar .export-menu.open { display: flex; }+ .toolbar .export-menu button {+ background: transparent;+ border: 0;+ justify-content: space-between;+ width: 100%;+ text-align: left;+ padding: 0.5rem 0.75rem;+ }+ .toolbar .export-menu button:hover {+ background: var(--toolbar-hover);+ }+ .toolbar .export-menu .hint {+ color: var(--text-faint);+ font-size: 0.625rem;+ }+ .toolbar .export-menu hr {+ border: 0;+ border-top: 1px solid var(--toolbar-border);+ margin: 0.25rem 0.375rem;+ opacity: 0.5;+ }++ /* Toast — brief feedback for actions like "copied" */+ .archify-toast {+ position: fixed;+ top: 1rem;+ left: 50%;+ transform: translateX(-50%) translateY(-8px);+ background: var(--toolbar-menu-bg);+ color: var(--text);+ border: 1px solid var(--toolbar-border);+ padding: 0.5rem 1rem;+ border-radius: 0.5rem;+ font-family: inherit;+ font-size: 0.75rem;+ opacity: 0;+ transition: opacity 0.2s, transform 0.2s;+ z-index: 200;+ pointer-events: none;+ box-shadow: 0 4px 20px rgba(0,0,0,0.25);+ }+ .archify-toast.show {+ opacity: 1;+ transform: translateX(-50%) translateY(0);+ }++ @media (max-width: 720px) {+ body { padding: 1rem; }+ .toolbar {+ position: static;+ justify-content: flex-end;+ margin-bottom: 1rem;+ }+ .header { margin-bottom: 1.25rem; }+ .header-row {+ gap: 0.75rem;+ align-items: flex-start;+ }+ h1 {+ font-size: 1.25rem;+ line-height: 1.25;+ }+ .subtitle {+ margin-left: 0;+ font-size: 0.8125rem;+ line-height: 1.55;+ }+ .diagram-container {+ padding: 0.75rem;+ border-radius: 0.75rem;+ }+ .cards {+ grid-template-columns: 1fr;+ margin-top: 1rem;+ }+ }++ /* ==========================================================+ SVG SEMANTIC CLASSES — use these instead of inline fill/stroke+ ========================================================== */+ .c-grid { stroke: var(--grid); fill: none; }+ .c-mask { fill: var(--mask); stroke: none; }++ .c-frontend { fill: var(--frontend-fill); stroke: var(--frontend-stroke); }+ .c-backend { fill: var(--backend-fill); stroke: var(--backend-stroke); }+ .c-database { fill: var(--database-fill); stroke: var(--database-stroke); }+ .c-cloud { fill: var(--cloud-fill); stroke: var(--cloud-stroke); }+ .c-security { fill: var(--security-fill); stroke: var(--security-stroke); }+ .c-messagebus { fill: var(--messagebus-fill); stroke: var(--messagebus-stroke); }+ .c-external { fill: var(--external-fill); stroke: var(--external-stroke); }++ /* Text helpers */+ .t-primary { fill: var(--text); }+ .t-muted { fill: var(--text-muted); }+ .t-dim { fill: var(--text-dim); }+ .t-frontend { fill: var(--frontend-stroke); }+ .t-backend { fill: var(--backend-stroke); }+ .t-database { fill: var(--database-stroke); }+ .t-cloud { fill: var(--cloud-stroke); }+ .t-security { fill: var(--security-stroke); }+ .t-messagebus { fill: var(--messagebus-stroke); }+ .t-external { fill: var(--external-stroke); }++ /* Arrows */+ .a-default { stroke: var(--arrow); fill: none; }+ .a-emphasis { stroke: var(--arrow-emphasis); fill: none; }+ .a-security { stroke: var(--security-stroke); fill: none; stroke-dasharray: 5,5; }+ .a-dashed { stroke: var(--database-stroke); fill: none; stroke-dasharray: 4,4; }++ /* Arrowhead markers reference these */+ .m-default { fill: var(--arrow); }+ .m-emphasis { fill: var(--arrow-emphasis); }+ .m-security { fill: var(--security-stroke); }+ .m-dashed { fill: var(--database-stroke); }++ /* Dashed boundary variants */+ .c-security-group { fill: transparent; stroke: var(--security-stroke); stroke-dasharray: 4,4; }+ .c-region { fill: rgba(251, 191, 36, 0.05); stroke: var(--cloud-stroke); stroke-dasharray: 8,4; }+ .c-lane { fill: var(--lane-fill); stroke: var(--lane-stroke); stroke-dasharray: 6,6; }++ /* Optional trace animation, enabled only by meta.animation = "trace".+ Static diagrams do not carry data-animation and render exactly as before. */+ svg[data-animation="trace"] [data-animate="edge"] {+ stroke-dasharray: 10 8;+ stroke-dashoffset: 54;+ animation: archify-edge-flow 2.4s linear infinite;+ animation-delay: calc(var(--step, 0) * 160ms);+ }+ svg[data-animation="trace"] [data-animate="node"] {+ transform-box: fill-box;+ transform-origin: center;+ animation: archify-node-pulse 3.6s ease-in-out infinite;+ animation-delay: calc(var(--step, 0) * 160ms);+ }+ @keyframes archify-edge-flow {+ to { stroke-dashoffset: 0; }+ }+ @keyframes archify-node-pulse {+ 0%, 72%, 100% { filter: none; stroke-width: 1.5; }+ 18%, 36% {+ filter: drop-shadow(0 0 8px var(--arrow-emphasis));+ stroke-width: 2.4;+ }+ }+ @media (prefers-reduced-motion: reduce) {+ svg[data-animation="trace"] [data-animate] {+ animation: none !important;+ stroke-dashoffset: 0;+ }+ }+ </style>+</head>+<body>+ <!-- Toolbar: theme toggle + export menu (present on every generated diagram)+ Keyboard: T toggles theme, E opens export menu (when no input focused) -->+ <div class="toolbar" role="toolbar" aria-label="Diagram actions">+ <button id="btn-theme" type="button"+ title="Toggle theme (T)"+ aria-label="Toggle color theme"+ aria-pressed="false">+ <span id="theme-icon" aria-hidden="true">☾</span>+ <span id="theme-label">Dark</span>+ </button>+ <div class="export-wrap">+ <button id="btn-export" type="button"+ title="Export diagram (E)"+ aria-label="Export diagram"+ aria-haspopup="menu"+ aria-expanded="false"+ aria-controls="export-menu">+ Export <span aria-hidden="true">▾</span>+ </button>+ <div class="export-menu" id="export-menu" role="menu" aria-label="Export">+ <button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>+ <hr role="separator">+ <button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>+ <button data-format="jpeg" type="button" role="menuitem" tabindex="-1">Download JPEG</button>+ <button data-format="webp" type="button" role="menuitem" tabindex="-1">Download WebP</button>+ <hr role="separator">+ <button data-format="svg" type="button" role="menuitem" tabindex="-1">Download SVG <span class="hint">vector</span></button>+ </div>+ </div>+ </div>++ <div class="container">+ <!-- Header -->+ <div class="header">+ <div class="header-row">+ <div class="pulse-dot"></div>+ <h1>Cache Miss Request Sequence</h1>+ </div>+ <p class="subtitle">Frontend request path with auth, cache fallback, persistence, and async trace</p>+ </div>++ <!-- Main Diagram -->+ <div class="diagram-container">+ <svg viewBox="0 0 820 760" role="img" aria-label="Cache Miss Request Sequence — Frontend request path with auth, cache fallback, persistence, and async trace (sequence diagram)">+ <!-- Definitions -->+ <defs>+ <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-default" />+ </marker>+ <marker id="arrowhead-emphasis" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-emphasis" />+ </marker>+ <marker id="arrowhead-security" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-security" />+ </marker>+ <marker id="arrowhead-dashed" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-dashed" />+ </marker>+ <pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse">+ <path d="M 40 0 L 0 0 0 40" class="c-grid" stroke-width="0.5"/>+ </pattern>+ </defs>++ <!-- Background Grid -->+ <rect width="100%" height="100%" fill="url(#grid)" />++ <!-- Time Segments -->+ <rect x="48" y="150" width="724" height="145" rx="10" class="c-lane" stroke-width="1"/>+ <text x="62" y="168" class="t-dim" font-size="9" font-weight="600">Request</text>++ <rect x="48" y="315" width="724" height="190" rx="10" class="c-lane" stroke-width="1"/>+ <text x="62" y="333" class="t-dim" font-size="9" font-weight="600">Fallback</text>++ <rect x="48" y="525" width="724" height="140" rx="10" class="c-lane" stroke-width="1"/>+ <text x="62" y="543" class="t-dim" font-size="9" font-weight="600">Response + trace</text>++ <!-- Lifelines -->+ <path d="M 62 142 L 62 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 170 142 L 170 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 278 142 L 278 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 386 142 L 386 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 494 142 L 494 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 602 142 L 602 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>+ <path d="M 710 142 L 710 695" class="a-default" stroke-width="0.8" stroke-dasharray="3,7"/>++ <!-- Messages -->+ <path d="M 69 185 L 163 185" class="a-default" stroke-width="1.4" marker-end="url(#arrowhead)"/>+ <rect x="86.6" y="165" width="58.800000000000004" height="16" rx="3" class="c-mask"/>+ <text x="116" y="175" class="t-backend" font-size="9" text-anchor="middle">open page</text>++ <path d="M 177 228 L 271 228" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <rect x="181.6" y="208" width="84.8" height="16" rx="3" class="c-mask"/>+ <text x="224" y="218" class="t-backend" font-size="9" text-anchor="middle">GET /dashboard</text>++ <path d="M 285 270 L 379 270" class="a-security" stroke-width="1.4" marker-end="url(#arrowhead-security)"/>+ <rect x="300" y="250" width="64" height="16" rx="3" class="c-mask"/>+ <text x="332" y="260" class="t-security" font-size="9" text-anchor="middle">verify JWT</text>++ <path d="M 379 305 L 285 305" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <rect x="302.6" y="285" width="58.800000000000004" height="16" rx="3" class="c-mask"/>+ <text x="332" y="295" class="t-muted" font-size="9" text-anchor="middle">claims ok</text>++ <path d="M 285 354 L 487 354" class="a-default" stroke-width="1.4" marker-end="url(#arrowhead)"/>+ <rect x="354" y="334" width="64" height="16" rx="3" class="c-mask"/>+ <text x="386" y="344" class="t-backend" font-size="9" text-anchor="middle">read cache</text>++ <path d="M 487 391 L 285 391" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <rect x="369" y="371" width="34" height="16" rx="3" class="c-mask"/>+ <text x="386" y="381" class="t-muted" font-size="9" text-anchor="middle">miss</text>++ <path d="M 285 443 L 595 443" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <rect x="374.2" y="423" width="131.60000000000002" height="16" rx="3" class="c-mask"/>+ <text x="440" y="433" class="t-backend" font-size="9" text-anchor="middle">query profile + metrics</text>++ <path d="M 595 489 L 285 489" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <rect x="423" y="469" width="34" height="16" rx="3" class="c-mask"/>+ <text x="440" y="479" class="t-muted" font-size="9" text-anchor="middle">rows</text>++ <path d="M 285 536 L 487 536" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>+ <rect x="356.6" y="516" width="58.800000000000004" height="16" rx="3" class="c-mask"/>+ <text x="386" y="526" class="t-messagebus" font-size="9" text-anchor="middle">set cache</text>++ <path d="M 285 580 L 703 580" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>+ <rect x="462" y="560" width="64" height="16" rx="3" class="c-mask"/>+ <text x="494" y="570" class="t-messagebus" font-size="9" text-anchor="middle">emit trace</text>++ <path d="M 271 625 L 177 625" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <rect x="197.2" y="605" width="53.6" height="16" rx="3" class="c-mask"/>+ <text x="224" y="615" class="t-muted" font-size="9" text-anchor="middle">200 JSON</text>++ <path d="M 163 662 L 69 662" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <rect x="94.4" y="642" width="43.2" height="16" rx="3" class="c-mask"/>+ <text x="116" y="652" class="t-muted" font-size="9" text-anchor="middle">render</text>++ <!-- Activations -->+ <rect x="165" y="220" width="10" height="448" rx="3" class="c-mask"/>+ <rect x="165" y="220" width="10" height="448" rx="3" class="c-frontend" stroke-width="1"/>+ <rect x="273" y="228" width="10" height="404" rx="3" class="c-mask"/>+ <rect x="273" y="228" width="10" height="404" rx="3" class="c-backend" stroke-width="1"/>+ <rect x="381" y="265" width="10" height="45" rx="3" class="c-mask"/>+ <rect x="381" y="265" width="10" height="45" rx="3" class="c-security" stroke-width="1"/>+ <rect x="489" y="349" width="10" height="49" rx="3" class="c-mask"/>+ <rect x="489" y="349" width="10" height="49" rx="3" class="c-database" stroke-width="1"/>+ <rect x="597" y="438" width="10" height="58" rx="3" class="c-mask"/>+ <rect x="597" y="438" width="10" height="58" rx="3" class="c-database" stroke-width="1"/>+ <rect x="705" y="575" width="10" height="55" rx="3" class="c-mask"/>+ <rect x="705" y="575" width="10" height="55" rx="3" class="c-messagebus" stroke-width="1"/>++ <!-- Participants -->+ <rect x="19" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="19" y="72" width="86" height="54" rx="6" class="c-external" stroke-width="1.5"/>+ <text x="62" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">User</text>+ <text x="62" y="111" class="t-muted" font-size="7" text-anchor="middle">browser session</text>++ <rect x="127" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="127" y="72" width="86" height="54" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="170" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Web App</text>+ <text x="170" y="111" class="t-muted" font-size="7" text-anchor="middle">React UI</text>++ <rect x="235" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="235" y="72" width="86" height="54" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="278" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">API</text>+ <text x="278" y="111" class="t-muted" font-size="7" text-anchor="middle">request handler</text>++ <rect x="343" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="343" y="72" width="86" height="54" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="386" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Auth</text>+ <text x="386" y="111" class="t-muted" font-size="7" text-anchor="middle">JWT verify</text>++ <rect x="451" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="451" y="72" width="86" height="54" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="494" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Redis</text>+ <text x="494" y="111" class="t-muted" font-size="7" text-anchor="middle">cache</text>++ <rect x="559" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="559" y="72" width="86" height="54" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="602" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Postgres</text>+ <text x="602" y="111" class="t-muted" font-size="7" text-anchor="middle">source of truth</text>++ <rect x="667" y="72" width="86" height="54" rx="6" class="c-mask"/>+ <rect x="667" y="72" width="86" height="54" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="710" y="94" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Trace</text>+ <text x="710" y="111" class="t-muted" font-size="7" text-anchor="middle">async event</text>++ <!-- Legend -->+ <text x="150" y="686" class="t-primary" font-size="10" font-weight="600">Legend</text>+ <path d="M 150 706 L 184 706" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <text x="193" y="709" class="t-muted" font-size="8">request</text>+ <path d="M 270 706 L 304 706" class="a-default" stroke-width="1.4" stroke-dasharray="3,5" marker-end="url(#arrowhead)"/>+ <text x="313" y="709" class="t-muted" font-size="8">return</text>+ <path d="M 385 706 L 419 706" class="a-security" stroke-width="1.4" marker-end="url(#arrowhead-security)"/>+ <text x="428" y="709" class="t-muted" font-size="8">security</text>+ <path d="M 530 706 L 564 706" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>+ <text x="573" y="709" class="t-muted" font-size="8">async trace</text>+ </svg>+ </div>++ <!-- Info Cards -->+ <div class="cards">+ <div class="card">+ <div class="card-header">+ <div class="card-dot emerald"></div>+ <h3>Happy Path</h3>+ </div>+ <ul>+ <li>• The main request is Web App -> API -> data source -> response</li>+ <li>• Return messages are quieter than forward calls</li>+ <li>• Activation bars make ownership duration visible</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot rose"></div>+ <h3>Policy + Fallback</h3>+ </div>+ <ul>+ <li>• JWT verification is colored as a security interaction</li>+ <li>• Cache miss is visible without overpowering the main path</li>+ <li>• Database access only appears after cache fallback</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot orange"></div>+ <h3>Async Trace</h3>+ </div>+ <ul>+ <li>• Trace emission is dashed and secondary</li>+ <li>• It does not block the response path</li>+ <li>• The diagram separates user-facing latency from observability</li>+ </ul>+ </div>+ </div>++ <!-- Footer -->+ <p class="footer">+ Sequence diagram • Built with Archify<span class="no-print"> • Press <kbd>T</kbd> for theme and <kbd>E</kbd> for export</span>+ </p>+ </div>++ <script>+ /* ============================================================+ Theme toggle — persists to localStorage, respects system pref+ ============================================================ */+ var Archify = {};++ Archify.theme = (function () {+ var STORAGE_KEY = 'archify-theme';+ var html = document.documentElement;+ var btn = document.getElementById('btn-theme');+ var icon = document.getElementById('theme-icon');+ var label = document.getElementById('theme-label');++ // localStorage can throw (blocked cookies, sandboxed iframes); the whole+ // script element dies on an uncaught error, so guard every access.+ function readStored() {+ try { return localStorage.getItem(STORAGE_KEY); } catch (_) { return null; }+ }+ function writeStored(value) {+ try { localStorage.setItem(STORAGE_KEY, value); } catch (_) {}+ }+ function urlOverride() {+ // URL param wins (useful for deterministic screenshots / share links)+ try {+ var param = new URLSearchParams(window.location.search).get('theme');+ if (param === 'light' || param === 'dark') return param;+ } catch (_) {}+ return null;+ }++ function resolveInitial() {+ var fromUrl = urlOverride();+ if (fromUrl) return fromUrl;+ var saved = readStored();+ if (saved === 'light' || saved === 'dark') return saved;+ return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';+ }++ function apply(theme) {+ html.setAttribute('data-theme', theme);+ icon.textContent = theme === 'dark' ? '\u263E' : '\u263C';+ label.textContent = theme === 'dark' ? 'Dark' : 'Light';+ btn.setAttribute('aria-pressed', theme === 'light' ? 'true' : 'false');+ }++ function toggle() {+ var next = html.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';+ apply(next);+ writeStored(next);+ }++ apply(resolveInitial());+ btn.addEventListener('click', toggle);++ // Follow live OS theme changes while the user has no explicit preference.+ try {+ var media = window.matchMedia('(prefers-color-scheme: light)');+ var onChange = function (e) {+ var saved = readStored();+ if (urlOverride() || saved === 'light' || saved === 'dark') return;+ apply(e.matches ? 'light' : 'dark');+ };+ if (media.addEventListener) media.addEventListener('change', onChange);+ else if (media.addListener) media.addListener(onChange);+ } catch (_) {}++ return { toggle: toggle };+ })();++ /* ============================================================+ Export — PNG / JPEG / WebP / SVG (download) and Copy PNG (clipboard)++ Raster exports are always rendered at 4x source resolution for+ maximum sharpness. The trick: we set the serialized SVG's+ `width`/`height` to viewBox * 4 so the browser rasterizes the+ vectors at that resolution natively. drawImage then draws at+ the image's natural size (no upscaling = no blur).++ JPEG/WebP paint the current theme's background explicitly since+ those formats have no alpha channel.+ ============================================================ */+ (function () {+ var RASTER_SCALE = 4;++ function diagramFilename() {+ var title = (document.title || 'diagram')+ .replace(/\s+Architecture(\s+Diagram)?$/i, '')+ .replace(/\s+Diagram$/i, '')+ .trim();+ return title.replace(/[^a-z0-9_\-]+/gi, '-')+ .toLowerCase()+ .replace(/^-+|-+$/g, '') || 'diagram';+ }++ function currentBg() {+ return getComputedStyle(document.body).backgroundColor || '#ffffff';+ }++ /**+ * Serialize the main SVG into a standalone document.+ *+ * Two modes:+ * - Default (opts.autoTheme=false) — locks the serialized SVG to the+ * viewer's current theme. Used by the raster pipeline+ * (PNG/JPEG/WebP/clipboard) because canvas rasterization needs+ * deterministic colors; a raster cannot react to+ * prefers-color-scheme after encoding.+ * - autoTheme=true — emits BOTH dark and light variable sets plus a+ * `@media (prefers-color-scheme)` rule so the resulting SVG+ * self-themes when embedded in GitHub READMEs or other hosts that+ * expose a color scheme. Used for "Download SVG".+ */+ function serializeSvg(scale, opts) {+ // scale: integer multiplier for intrinsic SVG pixel dimensions used by+ // the raster path. Defaults to 1 (natural size) for SVG download.+ scale = scale || 1;+ opts = opts || {};+ var autoTheme = opts.autoTheme === true;++ var svg = document.querySelector('.diagram-container svg');+ var clone = svg.cloneNode(true);++ var vb = svg.viewBox.baseVal;+ // Scale width/height so the browser rasterizes the vectors at target+ // resolution directly. viewBox stays unchanged so coordinates don't+ // shift. This is the key to sharp rasters — do NOT scale later via+ // canvas upscaling.+ clone.setAttribute('width', vb.width * scale);+ clone.setAttribute('height', vb.height * scale);+ clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');++ // Only the SVG-relevant rules: semantic classes, markers, and the+ // theme variable blocks. Toolbar/cards/print CSS can never apply+ // inside a standalone SVG and would only bloat the export.+ var hostStyle = (function () {+ var out = [];+ Array.prototype.forEach.call(document.styleSheets, function (sheet) {+ var rules;+ try { rules = sheet.cssRules; } catch (_) { return; } // cross-origin+ if (!rules) return;+ Array.prototype.forEach.call(rules, function (rule) {+ if (rule.type !== 1) return; // plain style rules only+ var sel = rule.selectorText || '';+ if (/(^|,)\s*(svg|:root|\[data-theme|\.c-|\.t-|\.a-|\.m-)/.test(sel)) {+ out.push(rule.cssText);+ }+ });+ });+ return out.join('\n');+ })();++ // Derive the variable list from the stylesheet so newly added theme+ // variables can never be missed by the export pipeline again+ // (--lane-fill/--lane-stroke once were).+ var varNames = (function () {+ var seen = {};+ var names = [];+ (hostStyle.match(/--[a-zA-Z0-9-]+(?=\s*:)/g) || []).forEach(function (n) {+ if (!seen[n]) { seen[n] = true; names.push(n); }+ });+ return names;+ })();++ // Resolve the full variable set for a given data-theme via an+ // off-DOM probe, independent of what the viewer is currently set to.+ function resolveVars(themeAttr) {+ var probe = document.createElement('div');+ probe.setAttribute('data-theme', themeAttr);+ probe.style.cssText = 'position:absolute;width:0;height:0;visibility:hidden;';+ document.body.appendChild(probe);+ try {+ var c = getComputedStyle(probe);+ return varNames.map(function (n) {+ return n + ': ' + c.getPropertyValue(n).trim() + ';';+ }).join(' ');+ } finally {+ document.body.removeChild(probe);+ }+ }++ // Prepend a local()-only @font-face block for each weight so that the+ // sandboxed image-rendering context used during PNG/JPEG/WebP export+ // can find JetBrains Mono if the user has it installed locally, and+ // falls through cleanly to the monospace stack otherwise. The usual+ // Google-Fonts <link> in the host document is unreachable from the+ // serialized SVG, so url()-sourced faces would just hang.+ var fontFallback = [400, 500, 600, 700].map(function (w) {+ return "@font-face { font-family: 'JetBrains Mono'; font-weight: " + w ++ "; src: local('JetBrains Mono'), local('JetBrainsMono-Regular'); }";+ }).join('\n');++ var style = document.createElementNS('http://www.w3.org/2000/svg', 'style');+ var bgRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');+ bgRect.setAttribute('width', '100%');+ bgRect.setAttribute('height', '100%');++ if (autoTheme) {+ // Dual-theme SVG. Dark is the default (so hosts without+ // prefers-color-scheme still render), light swaps in via media+ // query, and svg[data-theme="..."] still lets downstream+ // consumers force a specific theme.+ var darkVars = resolveVars('dark');+ var lightVars = resolveVars('light');++ style.textContent =+ fontFallback + "\n" ++ "svg { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace; }\n" ++ hostStyle + "\n" ++ ":root, svg { " + darkVars + " }\n" ++ "@media (prefers-color-scheme: light) { :root, svg { " + lightVars + " } }\n" ++ "svg[data-theme=\"light\"] { " + lightVars + " }\n" ++ "svg[data-theme=\"dark\"] { " + darkVars + " }\n" ++ "rect.c-bg-rect { fill: var(--bg); }\n";++ // Don't lock the serialized SVG to the viewer's current theme.+ clone.removeAttribute('data-theme');+ // Background follows the CSS variable, not a fixed color, so it+ // swaps with the media query.+ bgRect.setAttribute('class', 'c-bg-rect');+ } else {+ // Raster path: lock to the viewer's current theme.+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';+ var themeHost = document.querySelector('[data-theme="' + theme + '"]') || document.documentElement;+ var computed = getComputedStyle(themeHost);+ var vars = varNames.map(function (n) {+ return n + ': ' + computed.getPropertyValue(n).trim() + ';';+ }).join(' ');++ // IMPORTANT: inject the resolved variables AFTER hostStyle,+ // otherwise hostStyle's ":root, [data-theme=\"dark\"] { ... }" rule+ // overrides our chosen theme via later-in-cascade equal-specificity.+ // Keep this order.+ style.textContent =+ fontFallback + "\n" ++ "svg { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace; }\n" ++ hostStyle + "\n" ++ ":root, svg { " + vars + " }\n";++ bgRect.setAttribute('fill', computed.getPropertyValue('--bg').trim() || '#ffffff');+ }++ clone.insertBefore(style, clone.firstChild);+ clone.insertBefore(bgRect, style.nextSibling);++ return {+ svgString: new XMLSerializer().serializeToString(clone),+ width: vb.width * scale,+ height: vb.height * scale+ };+ }++ function download(blob, filename) {+ var url = URL.createObjectURL(blob);+ var a = document.createElement('a');+ a.href = url;+ a.download = filename;+ document.body.appendChild(a);+ a.click();+ a.remove();+ setTimeout(function () { URL.revokeObjectURL(url); }, 1000);+ }++ // Conservative upper bound on total canvas pixels. Older Safari on iOS+ // silently produces a blank canvas above ~16 Mpx; Chrome / Firefox /+ // desktop Safari are far higher but start failing on memory-constrained+ // devices. We pick the largest integer scale in {4,3,2,1} whose target+ // pixel count fits under this cap.+ var MAX_CANVAS_PIXELS = 16 * 1024 * 1024;++ function pickSafeScale(vbW, vbH) {+ for (var s = RASTER_SCALE; s >= 1; s--) {+ if (vbW * s * vbH * s <= MAX_CANVAS_PIXELS) return s;+ }+ return 1;+ }++ function rasterize(format) {+ // Serialize at a safe scale (RASTER_SCALE=4 by default, reduced if the+ // resulting canvas would exceed MAX_CANVAS_PIXELS). The SVG itself is+ // rasterized at target resolution natively; drawImage draws at natural+ // size — no upsampling blur.+ var svg = document.querySelector('.diagram-container svg');+ var vb = svg.viewBox.baseVal;+ var scale = pickSafeScale(vb.width, vb.height);+ var data = serializeSvg(scale);+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });+ var svgUrl = URL.createObjectURL(svgBlob);++ return new Promise(function (resolve, reject) {+ var img = new Image();+ img.onload = function () {+ var canvas = document.createElement('canvas');+ canvas.width = data.width;+ canvas.height = data.height;+ var ctx = canvas.getContext('2d');+ if (format === 'jpeg') {+ ctx.fillStyle = currentBg();+ ctx.fillRect(0, 0, canvas.width, canvas.height);+ }+ // Draw at natural size — SVG was already rasterized at target res.+ ctx.drawImage(img, 0, 0);+ URL.revokeObjectURL(svgUrl);+ var mime = format === 'jpeg' ? 'image/jpeg' :+ format === 'webp' ? 'image/webp' : 'image/png';+ var quality = format === 'png' ? undefined : 0.95;+ canvas.toBlob(function (blob) {+ if (!blob) reject(new Error('toBlob returned null for ' + format));+ else resolve(blob);+ }, mime, quality);+ };+ img.onerror = function (e) {+ URL.revokeObjectURL(svgUrl);+ reject(e);+ };+ img.src = svgUrl;+ });+ }++ var menu = document.getElementById('export-menu');+ var btn = document.getElementById('btn-export');+ var items = function () {+ return Array.prototype.slice.call(menu.querySelectorAll('button[role="menuitem"]'));+ };++ // ---- Clipboard support ----------------------------------------------+ function canCopyImage() {+ return typeof ClipboardItem !== 'undefined' &&+ navigator.clipboard &&+ typeof navigator.clipboard.write === 'function';+ }++ // ---- Raster format detection ----------------------------------------+ // canvas.toBlob('image/webp') silently returns a PNG on browsers without+ // WebP encoding (older Safari), so detect explicitly.+ function supports(format) {+ if (format === 'svg' || format === 'png') return true;+ var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';+ try {+ var c = document.createElement('canvas');+ c.width = c.height = 2;+ return c.toDataURL(mime).indexOf('data:' + mime) === 0;+ } catch (_) { return false; }+ }++ // Gray out unsupported items.+ items().forEach(function (it) {+ if (it.dataset.format && !supports(it.dataset.format)) {+ it.disabled = true;+ it.title = 'Not supported by this browser';+ it.style.opacity = '0.5';+ }+ if (it.dataset.action === 'copy' && !canCopyImage()) {+ it.disabled = true;+ it.title = 'Clipboard image write not supported by this browser';+ it.style.opacity = '0.5';+ }+ });++ // ---- Toast ----------------------------------------------------------+ // A live region only announces CHANGES to an existing node, so the toast+ // element is created once up front and updated in place.+ var toastEl = document.createElement('div');+ toastEl.className = 'archify-toast';+ toastEl.setAttribute('role', 'status');+ document.body.appendChild(toastEl);+ var toastTimer = null;++ function toast(msg) {+ toastEl.textContent = '';+ requestAnimationFrame(function () {+ toastEl.textContent = msg;+ toastEl.classList.add('show');+ });+ clearTimeout(toastTimer);+ toastTimer = setTimeout(function () { toastEl.classList.remove('show'); }, 1500);+ }++ function open(focusLast) {+ menu.classList.add('open');+ btn.setAttribute('aria-expanded', 'true');+ var available = items().filter(function (i) { return !i.disabled; });+ var target = focusLast ? available[available.length - 1] : available[0];+ if (target) target.focus();+ }+ function close(focusTrigger) {+ menu.classList.remove('open');+ btn.setAttribute('aria-expanded', 'false');+ if (focusTrigger) btn.focus();+ }+ function isOpen() { return menu.classList.contains('open'); }++ btn.addEventListener('click', function (e) {+ e.stopPropagation();+ if (isOpen()) close(false);+ else open();+ });+ // APG menu-button pattern: ArrowDown/ArrowUp on the trigger opens the menu.+ btn.addEventListener('keydown', function (e) {+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {+ e.preventDefault();+ if (!isOpen()) open(e.key === 'ArrowUp');+ }+ });+ document.addEventListener('click', function (e) {+ if (!menu.contains(e.target) && e.target !== btn) close(false);+ });++ // Keyboard navigation inside the menu.+ // Menu items: Up/Down, Home/End.+ // Esc closes + returns focus to trigger; Tab closes.+ menu.addEventListener('keydown', function (e) {+ if (e.key === 'Escape') { e.preventDefault(); close(true); return; }+ if (e.key === 'Tab') { close(false); return; }++ var available = items().filter(function (i) { return !i.disabled; });+ var current = available.indexOf(document.activeElement);+ switch (e.key) {+ case 'ArrowDown':+ e.preventDefault();+ if (available.length) available[(current + 1 + available.length) % available.length].focus();+ break;+ case 'ArrowUp':+ e.preventDefault();+ if (available.length) available[(current - 1 + available.length) % available.length].focus();+ break;+ case 'Home':+ e.preventDefault();+ if (available[0]) available[0].focus();+ break;+ case 'End':+ e.preventDefault();+ if (available.length) available[available.length - 1].focus();+ break;+ }+ });++ function runExport(format) {+ var base = diagramFilename();+ close(true);+ return (format === 'svg'+ ? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {+ download(new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' }), base + '.svg');+ })+ : rasterize(format).then(function (blob) {+ download(blob, base + '.' + format);+ })+ ).catch(function (err) {+ console.error(err);+ alert('Export failed: ' + (err && err.message ? err.message : format));+ });+ }++ function runCopy() {+ close(true);+ if (!canCopyImage()) {+ alert('Clipboard image write not supported in this browser.');+ return;+ }+ // WebKit requires ClipboardItem to be constructed synchronously inside+ // the user gesture — pass the pending Promise<Blob> as the item value.+ // Browsers that reject promise values throw synchronously; fall back+ // to awaiting the blob first (works in Chromium/Firefox).+ var blobPromise = rasterize('png');+ var writePromise;+ try {+ writePromise = navigator.clipboard.write([new ClipboardItem({ 'image/png': blobPromise })]);+ } catch (_) {+ writePromise = blobPromise.then(function (blob) {+ return navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);+ });+ }+ return writePromise.then(function () {+ toast('Copied PNG to clipboard');+ }).catch(function (err) {+ console.error(err);+ alert('Copy failed: ' + (err && err.message ? err.message : 'unknown'));+ });+ }++ menu.addEventListener('click', function (e) {+ var copyBtn = e.target.closest('button[data-action="copy"]');+ if (copyBtn && !copyBtn.disabled) { runCopy(); return; }++ var formatBtn = e.target.closest('button[data-format]');+ if (formatBtn && !formatBtn.disabled) { runExport(formatBtn.dataset.format); }+ });++ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };++ // Auto-open on page load for demo/screenshot purposes: ?openExport=1+ // Wait for fonts (so the menu doesn't flash before typography lands)+ // and paint before opening. Fallback timeout for browsers without the+ // Font Loading API.+ try {+ if (new URLSearchParams(window.location.search).get('openExport') === '1') {+ var openWhenReady = function () {+ requestAnimationFrame(function () { requestAnimationFrame(open); });+ };+ if (document.fonts && document.fonts.ready) {+ document.fonts.ready.then(openWhenReady);+ } else {+ setTimeout(openWhenReady, 200);+ }+ }+ } catch (_) {}+ })();++ /* ============================================================+ Global keyboard shortcuts+ T -> toggle theme+ E -> open export menu+ Ignored when focus is inside an input/textarea/contenteditable.+ ============================================================ */+ document.addEventListener('keydown', function (e) {+ if (e.metaKey || e.ctrlKey || e.altKey) return;+ var t = e.target;+ if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;+ if (e.key === 't' || e.key === 'T') {+ e.preventDefault();+ Archify.theme.toggle();+ } else if (e.key === 'e' || e.key === 'E') {+ e.preventDefault();+ if (!Archify.exportMenu.isOpen()) Archify.exportMenu.open();+ }+ });+ </script>+</body>+</html>diff --git a/examples/web-app-rendered.html b/examples/web-app-rendered.htmlindex db467d83..a13e4cd0 100644--- a/examples/web-app-rendered.html+++ b/examples/web-app-rendered.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Sample Web App Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/web-app.html b/examples/web-app.htmlindex da85ed3e..a13e4cd0 100644--- a/examples/web-app.html+++ b/examples/web-app.html@@ -3,8 +3,8 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">- <title>Sample Web App Architecture Diagram</title>+ <meta name="generator" content="archify 2.10.0">+ <title>Sample Web App Diagram</title><script>// Resolve the theme before first paint so light-preference users don't// see a dark flash. The toolbar script below re-applies with UI state.@@ -525,14 +525,14 @@<div class="header"><div class="header-row"><div class="pulse-dot"></div>- <h1>Sample Web App Architecture</h1>+ <h1>Sample Web App</h1></div>- <p class="subtitle">Classic 3-tier SaaS on AWS — generated by the Archify Claude Skill</p>+ <p class="subtitle">Classic 3-tier SaaS on AWS — rendered by Archify</p></div><!-- Main Diagram --><div class="diagram-container">- <svg viewBox="0 0 1000 680" role="img" aria-label="Sample Web App Architecture diagram">+ <svg viewBox="0 0 1080 588" role="img" aria-label="Sample Web App — Classic 3-tier SaaS on AWS — rendered by Archify (architecture diagram)"><!-- Definitions --><defs><marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">@@ -555,175 +555,151 @@<!-- Background Grid --><rect width="100%" height="100%" fill="url(#grid)" />- <!-- =================================================================- COMPONENT EXAMPLES — use CSS classes, not inline fill/stroke- (so theme toggle works). Each box pattern:- 1. opaque mask rect (.c-mask) to hide arrows underneath- 2. styled rect (.c-<type>) with 1.5px stroke- 3. text (.t-primary / .t-muted)- ================================================================= -->-- <!-- External/Generic Component -->- <rect x="30" y="280" width="100" height="50" rx="6" class="c-mask"/>- <rect x="30" y="280" width="100" height="50" rx="6" class="c-external" stroke-width="1.5"/>- <text x="80" y="300" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Users</text>- <text x="80" y="316" class="t-muted" font-size="9" text-anchor="middle">Browser/Mobile</text>-- <!-- Security Component -->- <rect x="30" y="80" width="100" height="60" rx="6" class="c-mask"/>- <rect x="30" y="80" width="100" height="60" rx="6" class="c-security" stroke-width="1.5"/>- <text x="80" y="105" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Auth Provider</text>- <text x="80" y="121" class="t-muted" font-size="9" text-anchor="middle">OAuth 2.0</text>-- <!-- Region/Cloud Boundary -->- <rect x="160" y="40" width="820" height="620" rx="12" class="c-region" stroke-width="1"/>- <text x="172" y="58" class="t-cloud" font-size="10" font-weight="600">AWS Region: us-west-2</text>-- <!-- AWS/Cloud Service -->- <rect x="200" y="280" width="110" height="50" rx="6" class="c-mask"/>- <rect x="200" y="280" width="110" height="50" rx="6" class="c-cloud" stroke-width="1.5"/>- <text x="255" y="300" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">CloudFront</text>- <text x="255" y="316" class="t-muted" font-size="9" text-anchor="middle">CDN</text>-- <!-- Multi-line AWS Component (S3 Buckets example) -->- <rect x="200" y="380" width="110" height="100" rx="6" class="c-mask"/>- <rect x="200" y="380" width="110" height="100" rx="6" class="c-cloud" stroke-width="1.5"/>- <text x="255" y="400" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">S3 Buckets</text>- <text x="255" y="420" class="t-muted" font-size="8" text-anchor="middle">• bucket-one</text>- <text x="255" y="434" class="t-muted" font-size="8" text-anchor="middle">• bucket-two</text>- <text x="255" y="448" class="t-muted" font-size="8" text-anchor="middle">• bucket-three</text>- <text x="255" y="466" class="t-cloud" font-size="7" text-anchor="middle">OAI Protected</text>-- <!-- Security Group (dashed boundary). NOTE: extra vertical headroom- so the sg-name label has ~12px breathing room above the inner- component. Pattern: boundary y = inner.y - 30, h = inner.h + 50. -->- <rect x="350" y="250" width="120" height="100" rx="8" class="c-security-group" stroke-width="1"/>- <text x="358" y="268" class="t-security" font-size="8">sg-name :port</text>-- <!-- Component inside security group -->- <rect x="360" y="280" width="100" height="50" rx="6" class="c-mask"/>- <rect x="360" y="280" width="100" height="50" rx="6" class="c-cloud" stroke-width="1.5"/>- <text x="410" y="300" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Load Balancer</text>- <text x="410" y="316" class="t-muted" font-size="9" text-anchor="middle">HTTPS :443</text>-- <!-- Backend Component -->- <rect x="510" y="280" width="110" height="50" rx="6" class="c-mask"/>- <rect x="510" y="280" width="110" height="50" rx="6" class="c-backend" stroke-width="1.5"/>- <text x="565" y="300" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">API Server</text>- <text x="565" y="316" class="t-muted" font-size="9" text-anchor="middle">FastAPI :8000</text>-- <!-- Database Component -->- <rect x="700" y="280" width="120" height="50" rx="6" class="c-mask"/>- <rect x="700" y="280" width="120" height="50" rx="6" class="c-database" stroke-width="1.5"/>- <text x="760" y="300" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Database</text>- <text x="760" y="316" class="t-muted" font-size="9" text-anchor="middle">PostgreSQL</text>-- <!-- Frontend Component -->- <rect x="200" y="520" width="200" height="110" rx="8" class="c-mask"/>- <rect x="200" y="520" width="200" height="110" rx="8" class="c-frontend" stroke-width="1.5"/>- <text x="300" y="545" class="t-primary" font-size="12" font-weight="600" text-anchor="middle">Frontend</text>- <text x="300" y="565" class="t-muted" font-size="9" text-anchor="middle">React + TypeScript</text>- <text x="300" y="580" class="t-muted" font-size="9" text-anchor="middle">Additional detail</text>- <text x="300" y="595" class="t-muted" font-size="9" text-anchor="middle">More info</text>- <text x="300" y="615" class="t-frontend" font-size="8" text-anchor="middle">domain.example.com</text>-- <!-- =================================================================- ARROW EXAMPLES (use .a-* classes and stroke-width on the line)- ================================================================= -->-- <!-- Standard arrow with label -->- <line x1="130" y1="305" x2="198" y2="305" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>- <text x="164" y="299" class="t-muted" font-size="9" text-anchor="middle">HTTPS</text>-- <!-- Simple arrow (no label) -->- <line x1="310" y1="305" x2="358" y2="305" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>-- <!-- Vertical arrow -->- <line x1="255" y1="330" x2="255" y2="378" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>- <text x="270" y="358" class="t-muted" font-size="9">OAI</text>-- <!-- Straight arrows between services -->- <line x1="460" y1="305" x2="508" y2="305" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>- <line x1="620" y1="305" x2="698" y2="305" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>- <text x="655" y="299" class="t-muted" font-size="9">TLS</text>-- <!-- Curved dashed path for auth/security flow -->- <path d="M 80 140 L 80 200 Q 80 220 100 220 L 200 220 Q 220 220 220 240 L 220 278"- class="a-security" stroke-width="1.5"/>- <text x="150" y="210" class="t-security" font-size="8">JWT + PKCE</text>-- <!-- =================================================================- LEGEND- ================================================================= -->- <text x="720" y="70" class="t-primary" font-size="10" font-weight="600">Legend</text>-- <rect x="720" y="82" width="16" height="10" rx="2" class="c-frontend" stroke-width="1"/>- <text x="742" y="90" class="t-muted" font-size="8">Frontend</text>-- <rect x="720" y="98" width="16" height="10" rx="2" class="c-backend" stroke-width="1"/>- <text x="742" y="106" class="t-muted" font-size="8">Backend</text>-- <rect x="720" y="114" width="16" height="10" rx="2" class="c-cloud" stroke-width="1"/>- <text x="742" y="122" class="t-muted" font-size="8">Cloud Service</text>-- <rect x="720" y="130" width="16" height="10" rx="2" class="c-database" stroke-width="1"/>- <text x="742" y="138" class="t-muted" font-size="8">Database</text>-- <rect x="720" y="146" width="16" height="10" rx="2" class="c-security" stroke-width="1"/>- <text x="742" y="154" class="t-muted" font-size="8">Security</text>-- <line x1="720" y1="168" x2="736" y2="168" class="a-security" stroke-width="1"/>- <text x="742" y="171" class="t-muted" font-size="8">Auth Flow</text>-- <rect x="720" y="178" width="16" height="10" rx="2" class="c-security-group" stroke-width="1"/>- <text x="742" y="186" class="t-muted" font-size="8">Security Group</text>+ <!-- Boundaries (behind everything) -->+ <rect x="220" y="120" width="820" height="400" rx="12" class="c-region" stroke-width="1"/>+ <text x="228" y="138" class="t-cloud" font-size="9" font-weight="600">AWS Region: us-west-2</text>++ <rect x="430" y="270" width="400" height="110" rx="8" class="c-security-group" stroke-width="1"/>+ <text x="438" y="288" class="t-security" font-size="9" font-weight="600">sg-api :443/:8000</text>++ <!-- Connection paths (before components for correct z-order) -->+ <path d="M 160 330 L 250 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 160 142 L 439.5 142 Q 447.5 142 447.5 150 L 447.5 292 Q 447.5 300 455.5 300 L 735 300" class="a-security" stroke-width="1.5" marker-end="url(#arrowhead-security)"/>+ <path d="M 380 330 L 460 330" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 315 360 L 315 440" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 590 330 L 670 330" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 735 300 L 735 210" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 800 330 L 880 330" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 735 360 L 735 440" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 800 470 L 880 470" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>++ <!-- Components -->+ <rect x="40" y="300" width="120" height="60" rx="6" class="c-mask"/>+ <rect x="40" y="300" width="120" height="60" rx="6" class="c-external" stroke-width="1.5"/>+ <text x="100" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Users</text>+ <text x="100" y="344" class="t-muted" font-size="9" text-anchor="middle">Browser / Mobile</text>++ <rect x="40" y="110" width="120" height="64" rx="6" class="c-mask"/>+ <rect x="40" y="110" width="120" height="64" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="100" y="140" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Auth Provider</text>+ <text x="100" y="156" class="t-muted" font-size="9" text-anchor="middle">OAuth 2.0</text>+ <text x="100" y="166" class="t-security" font-size="7" text-anchor="middle">JWT + PKCE</text>++ <rect x="250" y="300" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="250" y="300" width="130" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="315" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">CloudFront</text>+ <text x="315" y="344" class="t-muted" font-size="9" text-anchor="middle">CDN</text>++ <rect x="460" y="300" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="460" y="300" width="130" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="525" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Load Balancer</text>+ <text x="525" y="344" class="t-muted" font-size="9" text-anchor="middle">HTTPS :443</text>++ <rect x="670" y="300" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="670" y="300" width="130" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="735" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">API Server</text>+ <text x="735" y="344" class="t-muted" font-size="9" text-anchor="middle">FastAPI :8000</text>++ <rect x="670" y="150" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="670" y="150" width="130" height="60" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="735" y="178" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Redis</text>+ <text x="735" y="194" class="t-muted" font-size="9" text-anchor="middle">cache :6379</text>++ <rect x="880" y="300" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="880" y="300" width="130" height="60" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="945" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">PostgreSQL</text>+ <text x="945" y="344" class="t-muted" font-size="9" text-anchor="middle">primary :5432</text>++ <rect x="250" y="440" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="250" y="440" width="130" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="315" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">S3</text>+ <text x="315" y="484" class="t-muted" font-size="9" text-anchor="middle">static assets</text>+ <text x="315" y="492" class="t-cloud" font-size="7" text-anchor="middle">OAI protected</text>++ <rect x="670" y="440" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="670" y="440" width="130" height="60" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="735" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">SQS</text>+ <text x="735" y="484" class="t-muted" font-size="9" text-anchor="middle">job queue</text>++ <rect x="880" y="440" width="130" height="60" rx="6" class="c-mask"/>+ <rect x="880" y="440" width="130" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="945" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Worker</text>+ <text x="945" y="484" class="t-muted" font-size="9" text-anchor="middle">async jobs</text>++ <!-- Connection labels -->+ <rect x="188" y="310" width="34" height="14" rx="3" class="c-mask"/>+ <text x="205" y="320" class="t-backend" font-size="8" text-anchor="middle">HTTPS</text>+ <rect x="418.5" y="201" width="58" height="14" rx="3" class="c-mask"/>+ <text x="447.5" y="211" class="t-security" font-size="8" text-anchor="middle">verify JWT</text>++ <rect x="295.6" y="398" width="38.8" height="14" rx="3" class="c-mask"/>+ <text x="315" y="408" class="t-messagebus" font-size="8" text-anchor="middle">static</text>++ <rect x="701.2" y="212" width="67.6" height="14" rx="3" class="c-mask"/>+ <text x="735" y="222" class="t-muted" font-size="8" text-anchor="middle">read-through</text>+ <rect x="825" y="310" width="30" height="14" rx="3" class="c-mask"/>+ <text x="840" y="320" class="t-muted" font-size="8" text-anchor="middle">SQL</text>+ <rect x="713.2" y="398" width="43.6" height="14" rx="3" class="c-mask"/>+ <text x="735" y="408" class="t-messagebus" font-size="8" text-anchor="middle">enqueue</text>+++ <!-- Legend -->+ <text x="40" y="559" class="t-primary" font-size="9" font-weight="600">Legend</text>+ <rect x="40" y="564" width="14" height="9" rx="2" class="c-external" stroke-width="1"/>+ <text x="60" y="572" class="t-muted" font-size="8">External</text>+ <rect x="138" y="564" width="14" height="9" rx="2" class="c-security" stroke-width="1"/>+ <text x="158" y="572" class="t-muted" font-size="8">Security</text>+ <rect x="236" y="564" width="14" height="9" rx="2" class="c-cloud" stroke-width="1"/>+ <text x="256" y="572" class="t-muted" font-size="8">Cloud</text>+ <rect x="319" y="564" width="14" height="9" rx="2" class="c-backend" stroke-width="1"/>+ <text x="339" y="572" class="t-muted" font-size="8">Backend</text>+ <rect x="412" y="564" width="14" height="9" rx="2" class="c-database" stroke-width="1"/>+ <text x="432" y="572" class="t-muted" font-size="8">Database</text>+ <rect x="510" y="564" width="14" height="9" rx="2" class="c-messagebus" stroke-width="1"/>+ <text x="530" y="572" class="t-muted" font-size="8">Message bus</text></svg></div>+ <!-- Info Cards --><div class="cards"><div class="card"><div class="card-header">- <div class="card-dot rose"></div>- <h3>Security</h3>+ <div class="card-dot cyan"></div>+ <h3>Edge</h3></div><ul>- <li>• OAuth 2.0 via external provider</li>- <li>• JWT + PKCE auth flow</li>- <li>• TLS everywhere</li>- <li>• Security groups scope ingress</li>+ <li>• CloudFront CDN fronts all traffic</li>+ <li>• S3 serves static assets via OAI</li></ul></div><div class="card"><div class="card-header">- <div class="card-dot amber"></div>- <h3>AWS Services</h3>+ <div class="card-dot emerald"></div>+ <h3>Application</h3></div><ul>- <li>• CloudFront CDN + WAF</li>- <li>• S3 buckets (OAI-protected)</li>- <li>• ALB → ECS / Lambda</li>- <li>• RDS PostgreSQL (Multi-AZ)</li>+ <li>• FastAPI behind an HTTPS load balancer</li>+ <li>• Redis read-through cache</li>+ <li>• Async work drained from SQS by a worker</li></ul></div><div class="card"><div class="card-header">- <div class="card-dot violet"></div>- <h3>Data</h3>+ <div class="card-dot rose"></div>+ <h3>Security</h3></div><ul>- <li>• PostgreSQL primary</li>- <li>• Static assets on S3</li>- <li>• CDN-cached GET responses</li>- <li>• Daily snapshots retained 30d</li>+ <li>• OAuth 2.0 with JWT + PKCE</li>+ <li>• API + LB isolated in a security group</li></ul></div></div><!-- Footer --><p class="footer">- <kbd>T</kbd> toggle theme · <kbd>E</kbd> open Export · <kbd>Cmd</kbd>+<kbd>P</kbd> print · raster output natively rendered at 4× source resolution+ Architecture diagram • Built with Archify<span class="no-print"> • Press <kbd>T</kbd> for theme and <kbd>E</kbd> for export</span></p></div>diff --git a/examples/workflow-agent-tool-call-rendered.html b/examples/workflow-agent-tool-call-rendered.htmlindex 7eb5ec26..95673fad 100644--- a/examples/workflow-agent-tool-call-rendered.html+++ b/examples/workflow-agent-tool-call-rendered.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <meta name="generator" content="archify 2.9.0">+ <meta name="generator" content="archify 2.10.0"><title>Agent Tool Call Workflow Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/workflow-agent-tool-call.html b/examples/workflow-agent-tool-call.htmlnew file mode 100644index 00000000..7eb5ec26--- /dev/null+++ b/examples/workflow-agent-tool-call.html@@ -0,0 +1,1282 @@+<!DOCTYPE html>+<html lang="en" data-theme="dark">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="generator" content="archify 2.9.0">+ <title>Agent Tool Call Workflow Diagram</title>+ <script>+ // Resolve the theme before first paint so light-preference users don't+ // see a dark flash. The toolbar script below re-applies with UI state.+ (function () {+ try {+ var theme = null;+ try {+ var param = new URLSearchParams(window.location.search).get('theme');+ if (param === 'light' || param === 'dark') theme = param;+ } catch (_) {}+ if (!theme) {+ try { theme = localStorage.getItem('archify-theme'); } catch (_) {}+ }+ if (theme !== 'light' && theme !== 'dark') {+ theme = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';+ }+ document.documentElement.setAttribute('data-theme', theme);+ } catch (_) {}+ })();+ </script>+ <!-- Async font load: a blackholed network must not block first paint.+ The body font stack falls back to system monospace until it lands. -->+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"+ rel="stylesheet" media="print" onload="this.media='all'">+ <noscript>+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">+ </noscript>+ <style>+ /* ==========================================================+ THEME VARIABLES — switch by toggling [data-theme] on <html>+ ========================================================== */+ :root,+ [data-theme="dark"] {+ --bg: #020617;+ --grid: #1e293b;+ --text: #ffffff;+ --text-muted: #94a3b8;+ --text-dim: #475569;+ /* UI chrome (menu hints, footer) needs more contrast than SVG .t-dim accents */+ --text-faint: #7d8da1;++ --panel: rgba(15, 23, 42, 0.5);+ --panel-border: #1e293b;+ --lane-fill: rgba(15, 23, 42, 0.22);+ --lane-stroke: #334155;++ --arrow: #64748b;+ --arrow-emphasis: #34d399;++ /* Opaque mask color used behind semi-transparent component fills+ so the arrows drawn underneath are properly hidden. */+ --mask: #0f172a;++ --frontend-fill: rgba(8, 51, 68, 0.4);+ --frontend-stroke: #22d3ee;+ --backend-fill: rgba(6, 78, 59, 0.4);+ --backend-stroke: #34d399;+ --database-fill: rgba(76, 29, 149, 0.4);+ --database-stroke: #a78bfa;+ --cloud-fill: rgba(120, 53, 15, 0.3);+ --cloud-stroke: #fbbf24;+ --security-fill: rgba(136, 19, 55, 0.4);+ --security-stroke: #fb7185;+ --messagebus-fill: rgba(251, 146, 60, 0.3);+ --messagebus-stroke:#fb923c;+ --external-fill: rgba(30, 41, 59, 0.5);+ --external-stroke: #94a3b8;++ --toolbar-bg: rgba(15, 23, 42, 0.8);+ --toolbar-border: #334155;+ --toolbar-text: #e2e8f0;+ --toolbar-hover: rgba(15, 23, 42, 0.95);+ --toolbar-menu-bg: #0f172a;+ }++ [data-theme="light"] {+ --bg: #f8fafc;+ --grid: #e2e8f0;+ --text: #0f172a;+ --text-muted: #64748b;+ --text-dim: #94a3b8;+ --text-faint: #64748b;++ --panel: #ffffff;+ --panel-border: #e2e8f0;+ --lane-fill: rgba(248, 250, 252, 0.65);+ --lane-stroke: #cbd5e1;++ --arrow: #94a3b8;+ --arrow-emphasis: #059669;++ --mask: #ffffff;++ --frontend-fill: rgba(34, 211, 238, 0.15);+ --frontend-stroke: #0891b2;+ --backend-fill: rgba(52, 211, 153, 0.18);+ --backend-stroke: #059669;+ --database-fill: rgba(167, 139, 250, 0.2);+ --database-stroke: #7c3aed;+ --cloud-fill: rgba(251, 191, 36, 0.18);+ --cloud-stroke: #d97706;+ --security-fill: rgba(251, 113, 133, 0.15);+ --security-stroke: #e11d48;+ --messagebus-fill: rgba(251, 146, 60, 0.15);+ --messagebus-stroke:#ea580c;+ --external-fill: rgba(148, 163, 184, 0.18);+ --external-stroke: #64748b;++ --toolbar-bg: rgba(255, 255, 255, 0.92);+ --toolbar-border: #cbd5e1;+ --toolbar-text: #334155;+ --toolbar-hover: #ffffff;+ --toolbar-menu-bg: #ffffff;+ }++ * { margin: 0; padding: 0; box-sizing: border-box; }++ body {+ font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace;+ background: var(--bg);+ min-height: 100vh;+ padding: 2rem;+ color: var(--text);+ transition: background 0.2s ease, color 0.2s ease;+ }++ .container { max-width: 1200px; margin: 0 auto; }++ .header { margin-bottom: 2rem; }++ .header-row {+ display: flex;+ align-items: center;+ gap: 1rem;+ margin-bottom: 0.5rem;+ }++ .pulse-dot {+ width: 12px;+ height: 12px;+ background: var(--frontend-stroke);+ border-radius: 50%;+ animation: pulse 2s infinite;+ }++ @keyframes pulse {+ 0%, 100% { opacity: 1; }+ 50% { opacity: 0.5; }+ }++ h1 {+ font-size: 1.5rem;+ font-weight: 700;+ letter-spacing: -0.025em;+ }++ .subtitle {+ color: var(--text-muted);+ font-size: 0.875rem;+ margin-left: 1.75rem;+ }++ .diagram-container {+ background: var(--panel);+ border-radius: 1rem;+ border: 1px solid var(--panel-border);+ padding: 1.5rem;+ overflow-x: auto;+ }++ svg {+ width: 100%;+ min-width: min(900px, 100%);+ display: block;+ }++ .cards {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));+ gap: 1rem;+ margin-top: 2rem;+ }++ .card {+ background: var(--panel);+ border-radius: 0.75rem;+ border: 1px solid var(--panel-border);+ padding: 1.25rem;+ }++ .card-header {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ margin-bottom: 0.75rem;+ }++ .card-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ }++ .card-dot.cyan { background: var(--frontend-stroke); }+ .card-dot.emerald { background: var(--backend-stroke); }+ .card-dot.violet { background: var(--database-stroke); }+ .card-dot.amber { background: var(--cloud-stroke); }+ .card-dot.rose { background: var(--security-stroke); }+ .card-dot.orange { background: var(--messagebus-stroke); }+ .card-dot.slate { background: var(--external-stroke); }++ .card h3 { font-size: 0.875rem; font-weight: 600; color: var(--text); }++ .card ul {+ list-style: none;+ color: var(--text-muted);+ font-size: 0.75rem;+ }++ .card li { margin-bottom: 0.375rem; }++ .footer {+ text-align: center;+ margin-top: 1.5rem;+ color: var(--text-faint);+ font-size: 0.75rem;+ }++ /* ==========================================================+ Print stylesheet — hide interactive controls, force light,+ drop the grid so the diagram doesn't waste ink, use landscape+ so wide diagrams fit, pack summary cards into 2 columns to+ avoid an orphan card on a trailing page.+ ========================================================== */+ @page { size: landscape; margin: 1.5cm; }++ @media print {+ /* Force the FULL light palette — including component fills/strokes and+ lane/arrow colors — so printing from dark theme doesn't put neon+ strokes and translucent dark fills on white paper. */+ :root, [data-theme="dark"], [data-theme="light"] {+ --bg: #ffffff;+ --grid: transparent;+ --panel: #ffffff;+ --panel-border: #e2e8f0;+ --text: #0f172a;+ --text-muted: #475569;+ --text-dim: #94a3b8;+ --text-faint: #64748b;+ --mask: #ffffff;+ --lane-fill: rgba(248, 250, 252, 0.65);+ --lane-stroke: #cbd5e1;+ --arrow: #94a3b8;+ --arrow-emphasis: #059669;+ --frontend-fill: rgba(34, 211, 238, 0.15);+ --frontend-stroke: #0891b2;+ --backend-fill: rgba(52, 211, 153, 0.18);+ --backend-stroke: #059669;+ --database-fill: rgba(167, 139, 250, 0.2);+ --database-stroke: #7c3aed;+ --cloud-fill: rgba(251, 191, 36, 0.18);+ --cloud-stroke: #d97706;+ --security-fill: rgba(251, 113, 133, 0.15);+ --security-stroke: #e11d48;+ --messagebus-fill: rgba(251, 146, 60, 0.15);+ --messagebus-stroke:#ea580c;+ --external-fill: rgba(148, 163, 184, 0.18);+ --external-stroke: #64748b;+ }+ body { background: #ffffff !important; padding: 0; }+ .container { max-width: none; }+ .toolbar, .archify-toast, .no-print { display: none !important; }+ .diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .cards { grid-template-columns: 1fr 1fr; }+ /* Ensure elements break sensibly across pages */+ .card { break-inside: avoid; page-break-inside: avoid; }+ .diagram-container { break-inside: avoid; page-break-inside: avoid; }+ h1, .subtitle { color: #0f172a; }+ }++ /* ==========================================================+ TOOLBAR (theme toggle + export menu)+ ========================================================== */+ .toolbar {+ position: fixed;+ top: 1rem;+ right: 1rem;+ display: flex;+ gap: 0.5rem;+ z-index: 100;+ }+ .toolbar button {+ background: var(--toolbar-bg);+ color: var(--toolbar-text);+ border: 1px solid var(--toolbar-border);+ padding: 0.5rem 0.875rem;+ border-radius: 0.5rem;+ font-family: inherit;+ font-size: 0.75rem;+ font-weight: 500;+ cursor: pointer;+ backdrop-filter: blur(8px);+ transition: background 0.15s, border-color 0.15s;+ display: inline-flex;+ align-items: center;+ gap: 0.375rem;+ }+ .toolbar button:hover {+ background: var(--toolbar-hover);+ border-color: var(--arrow);+ }+ .toolbar button:focus-visible {+ outline: 2px solid var(--frontend-stroke);+ outline-offset: 2px;+ }+ .toolbar .export-wrap { position: relative; }+ .toolbar .export-menu {+ position: absolute;+ top: calc(100% + 0.375rem);+ right: 0;+ background: var(--toolbar-menu-bg);+ border: 1px solid var(--toolbar-border);+ border-radius: 0.5rem;+ padding: 0.375rem;+ min-width: 160px;+ display: none;+ flex-direction: column;+ box-shadow: 0 4px 20px rgba(0,0,0,0.25);+ }+ .toolbar .export-menu.open { display: flex; }+ .toolbar .export-menu button {+ background: transparent;+ border: 0;+ justify-content: space-between;+ width: 100%;+ text-align: left;+ padding: 0.5rem 0.75rem;+ }+ .toolbar .export-menu button:hover {+ background: var(--toolbar-hover);+ }+ .toolbar .export-menu .hint {+ color: var(--text-faint);+ font-size: 0.625rem;+ }+ .toolbar .export-menu hr {+ border: 0;+ border-top: 1px solid var(--toolbar-border);+ margin: 0.25rem 0.375rem;+ opacity: 0.5;+ }++ /* Toast — brief feedback for actions like "copied" */+ .archify-toast {+ position: fixed;+ top: 1rem;+ left: 50%;+ transform: translateX(-50%) translateY(-8px);+ background: var(--toolbar-menu-bg);+ color: var(--text);+ border: 1px solid var(--toolbar-border);+ padding: 0.5rem 1rem;+ border-radius: 0.5rem;+ font-family: inherit;+ font-size: 0.75rem;+ opacity: 0;+ transition: opacity 0.2s, transform 0.2s;+ z-index: 200;+ pointer-events: none;+ box-shadow: 0 4px 20px rgba(0,0,0,0.25);+ }+ .archify-toast.show {+ opacity: 1;+ transform: translateX(-50%) translateY(0);+ }++ @media (max-width: 720px) {+ body { padding: 1rem; }+ .toolbar {+ position: static;+ justify-content: flex-end;+ margin-bottom: 1rem;+ }+ .header { margin-bottom: 1.25rem; }+ .header-row {+ gap: 0.75rem;+ align-items: flex-start;+ }+ h1 {+ font-size: 1.25rem;+ line-height: 1.25;+ }+ .subtitle {+ margin-left: 0;+ font-size: 0.8125rem;+ line-height: 1.55;+ }+ .diagram-container {+ padding: 0.75rem;+ border-radius: 0.75rem;+ }+ .cards {+ grid-template-columns: 1fr;+ margin-top: 1rem;+ }+ }++ /* ==========================================================+ SVG SEMANTIC CLASSES — use these instead of inline fill/stroke+ ========================================================== */+ .c-grid { stroke: var(--grid); fill: none; }+ .c-mask { fill: var(--mask); stroke: none; }++ .c-frontend { fill: var(--frontend-fill); stroke: var(--frontend-stroke); }+ .c-backend { fill: var(--backend-fill); stroke: var(--backend-stroke); }+ .c-database { fill: var(--database-fill); stroke: var(--database-stroke); }+ .c-cloud { fill: var(--cloud-fill); stroke: var(--cloud-stroke); }+ .c-security { fill: var(--security-fill); stroke: var(--security-stroke); }+ .c-messagebus { fill: var(--messagebus-fill); stroke: var(--messagebus-stroke); }+ .c-external { fill: var(--external-fill); stroke: var(--external-stroke); }++ /* Text helpers */+ .t-primary { fill: var(--text); }+ .t-muted { fill: var(--text-muted); }+ .t-dim { fill: var(--text-dim); }+ .t-frontend { fill: var(--frontend-stroke); }+ .t-backend { fill: var(--backend-stroke); }+ .t-database { fill: var(--database-stroke); }+ .t-cloud { fill: var(--cloud-stroke); }+ .t-security { fill: var(--security-stroke); }+ .t-messagebus { fill: var(--messagebus-stroke); }+ .t-external { fill: var(--external-stroke); }++ /* Arrows */+ .a-default { stroke: var(--arrow); fill: none; }+ .a-emphasis { stroke: var(--arrow-emphasis); fill: none; }+ .a-security { stroke: var(--security-stroke); fill: none; stroke-dasharray: 5,5; }+ .a-dashed { stroke: var(--database-stroke); fill: none; stroke-dasharray: 4,4; }++ /* Arrowhead markers reference these */+ .m-default { fill: var(--arrow); }+ .m-emphasis { fill: var(--arrow-emphasis); }+ .m-security { fill: var(--security-stroke); }+ .m-dashed { fill: var(--database-stroke); }++ /* Dashed boundary variants */+ .c-security-group { fill: transparent; stroke: var(--security-stroke); stroke-dasharray: 4,4; }+ .c-region { fill: rgba(251, 191, 36, 0.05); stroke: var(--cloud-stroke); stroke-dasharray: 8,4; }+ .c-lane { fill: var(--lane-fill); stroke: var(--lane-stroke); stroke-dasharray: 6,6; }++ /* Optional trace animation, enabled only by meta.animation = "trace".+ Static diagrams do not carry data-animation and render exactly as before. */+ svg[data-animation="trace"] [data-animate="edge"] {+ stroke-dasharray: 10 8;+ stroke-dashoffset: 54;+ animation: archify-edge-flow 2.4s linear infinite;+ animation-delay: calc(var(--step, 0) * 160ms);+ }+ svg[data-animation="trace"] [data-animate="node"] {+ transform-box: fill-box;+ transform-origin: center;+ animation: archify-node-pulse 3.6s ease-in-out infinite;+ animation-delay: calc(var(--step, 0) * 160ms);+ }+ @keyframes archify-edge-flow {+ to { stroke-dashoffset: 0; }+ }+ @keyframes archify-node-pulse {+ 0%, 72%, 100% { filter: none; stroke-width: 1.5; }+ 18%, 36% {+ filter: drop-shadow(0 0 8px var(--arrow-emphasis));+ stroke-width: 2.4;+ }+ }+ @media (prefers-reduced-motion: reduce) {+ svg[data-animation="trace"] [data-animate] {+ animation: none !important;+ stroke-dashoffset: 0;+ }+ }+ </style>+</head>+<body>+ <!-- Toolbar: theme toggle + export menu (present on every generated diagram)+ Keyboard: T toggles theme, E opens export menu (when no input focused) -->+ <div class="toolbar" role="toolbar" aria-label="Diagram actions">+ <button id="btn-theme" type="button"+ title="Toggle theme (T)"+ aria-label="Toggle color theme"+ aria-pressed="false">+ <span id="theme-icon" aria-hidden="true">☾</span>+ <span id="theme-label">Dark</span>+ </button>+ <div class="export-wrap">+ <button id="btn-export" type="button"+ title="Export diagram (E)"+ aria-label="Export diagram"+ aria-haspopup="menu"+ aria-expanded="false"+ aria-controls="export-menu">+ Export <span aria-hidden="true">▾</span>+ </button>+ <div class="export-menu" id="export-menu" role="menu" aria-label="Export">+ <button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>+ <hr role="separator">+ <button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>+ <button data-format="jpeg" type="button" role="menuitem" tabindex="-1">Download JPEG</button>+ <button data-format="webp" type="button" role="menuitem" tabindex="-1">Download WebP</button>+ <hr role="separator">+ <button data-format="svg" type="button" role="menuitem" tabindex="-1">Download SVG <span class="hint">vector</span></button>+ </div>+ </div>+ </div>++ <div class="container">+ <!-- Header -->+ <div class="header">+ <div class="header-row">+ <div class="pulse-dot"></div>+ <h1>Agent Tool Call Workflow</h1>+ </div>+ <p class="subtitle">Renderer-driven workflow prototype with lanes, anchored nodes, and orthogonal edges</p>+ </div>++ <!-- Main Diagram -->+ <div class="diagram-container">+ <svg viewBox="0 0 720 900" role="img" aria-label="Agent Tool Call Workflow — Renderer-driven workflow prototype with lanes, anchored nodes, and orthogonal edges (workflow diagram)">+ <!-- Definitions -->+ <defs>+ <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-default" />+ </marker>+ <marker id="arrowhead-emphasis" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-emphasis" />+ </marker>+ <marker id="arrowhead-security" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-security" />+ </marker>+ <marker id="arrowhead-dashed" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">+ <polygon points="0 0, 10 3.5, 0 7" class="m-dashed" />+ </marker>+ <pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse">+ <path d="M 40 0 L 0 0 0 40" class="c-grid" stroke-width="0.5"/>+ </pattern>+ </defs>++ <!-- Background Grid -->+ <rect width="100%" height="100%" fill="url(#grid)" />++ <!-- Swimlanes -->+ <rect x="40" y="52" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <text x="54" y="74" class="t-dim" font-size="10" font-weight="600">01 / User Interface</text>++ <rect x="40" y="176" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <text x="54" y="198" class="t-dim" font-size="10" font-weight="600">02 / Agent Runtime</text>++ <rect x="40" y="300" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <text x="54" y="322" class="t-dim" font-size="10" font-weight="600">03 / Policy Boundary</text>++ <rect x="40" y="424" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <rect x="46" y="430" width="628" height="92" rx="8" class="c-security-group" stroke-width="1"/>+ <text x="54" y="446" class="t-security" font-size="10" font-weight="600">EX / Exception Handling</text>++ <rect x="40" y="548" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <text x="54" y="570" class="t-dim" font-size="10" font-weight="600">05 / Tool Execution</text>++ <rect x="40" y="672" width="640" height="104" rx="10" class="c-lane" stroke-width="1"/>+ <text x="54" y="694" class="t-dim" font-size="10" font-weight="600">06 / Observability</text>++ <!-- Phase headers -->+ <line x1="42" y1="35" x2="266" y2="35" class="a-default" stroke-width="1.1"/>+ <rect x="42" y="27" width="224" height="16" rx="4" class="c-mask"/>+ <text x="154" y="39" class="t-muted" font-size="8" font-weight="600" text-anchor="middle">Intake</text>+ <line x1="254" y1="35" x2="476" y2="35" class="a-emphasis" stroke-width="1.1"/>+ <rect x="254" y="27" width="222" height="16" rx="4" class="c-mask"/>+ <text x="365" y="39" class="t-backend" font-size="8" font-weight="600" text-anchor="middle">Plan + route</text>+ <line x1="454" y1="35" x2="671" y2="35" class="a-dashed" stroke-width="1.1"/>+ <rect x="454" y="27" width="217" height="16" rx="4" class="c-mask"/>+ <text x="562.5" y="39" class="t-messagebus" font-size="8" font-weight="600" text-anchor="middle">Execute + report</text>++ <!-- Workflow groups -->+ <rect x="250" y="214" width="230" height="58" rx="9" class="c-lane" stroke-width="1"/>+ <text x="260" y="228" class="t-backend" font-size="7" font-weight="600">Planning loop</text>+ <rect x="450" y="586" width="225" height="58" rx="9" class="c-lane" stroke-width="1"/>+ <text x="460" y="600" class="t-messagebus" font-size="7" font-weight="600">Tool work</text>+ <rect x="380" y="462" width="295" height="58" rx="9" class="c-security-group" stroke-width="1"/>+ <text x="390" y="476" class="t-security" font-size="7" font-weight="600">Human or policy stop</text>++ <!-- Edge paths -->+ <path d="M 134 119 L 174 119" class="a-default" stroke-width="1.4" marker-end="url(#arrowhead)"/>+ <path d="M 220 145 L 220 166 L 300 166 L 300 209" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 346 243 L 384 243" class="a-default" stroke-width="1.4" marker-end="url(#arrowhead)"/>+ <path d="M 430 269 L 430 290 L 430 290 L 430 333" class="a-security" stroke-width="1.4" marker-end="url(#arrowhead-security)"/>+ <path d="M 384 367 L 356 367 L 356 615 L 454 615" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 430 401 L 430 414 L 500 414 L 500 465" class="a-security" stroke-width="1.4" marker-end="url(#arrowhead-security)"/>+ <path d="M 546 491 L 579 491" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 546 615 L 579 615" class="a-default" stroke-width="1.4" marker-end="url(#arrowhead)"/>+ <path d="M 671 615 L 692 615 L 692 119 L 671 119" class="a-emphasis" stroke-width="1.2" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 625 641 L 625 797 L 500 797 L 500 765" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 266 739 L 454 739" class="a-dashed" stroke-width="1.4" marker-end="url(#arrowhead-dashed)"/>++ <!-- Nodes -->+ <rect x="42" y="93" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="42" y="93" width="92" height="52" rx="6" class="c-external" stroke-width="1.5"/>+ <text x="88" y="114" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">User</text>+ <text x="88" y="131" class="t-muted" font-size="8" text-anchor="middle">asks for work</text>++ <rect x="174" y="93" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="174" y="93" width="92" height="52" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="220" y="114" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Chat Surface</text>+ <text x="220" y="131" class="t-muted" font-size="8" text-anchor="middle">thread + files</text>++ <rect x="579" y="93" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="579" y="93" width="92" height="52" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="625" y="114" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Final Reply</text>+ <text x="625" y="131" class="t-muted" font-size="8" text-anchor="middle">answer + changes</text>++ <rect x="254" y="209" width="92" height="68" rx="6" class="c-mask"/>+ <rect x="254" y="209" width="92" height="68" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="300" y="230" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Agent Planner</text>+ <text x="300" y="247" class="t-muted" font-size="8" text-anchor="middle">plan next step</text>+ <text x="300" y="265" class="t-backend" font-size="7" text-anchor="middle">context aware</text>++ <rect x="384" y="217" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="384" y="217" width="92" height="52" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="430" y="238" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Tool Router</text>+ <text x="430" y="255" class="t-muted" font-size="8" text-anchor="middle">choose capability</text>++ <rect x="384" y="333" width="92" height="68" rx="6" class="c-mask"/>+ <rect x="384" y="333" width="92" height="68" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="430" y="354" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Approval Gate</text>+ <text x="430" y="371" class="t-muted" font-size="8" text-anchor="middle">scope + consent</text>+ <text x="430" y="389" class="t-security" font-size="7" text-anchor="middle">block risky ops</text>++ <rect x="454" y="465" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="454" y="465" width="92" height="52" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="500" y="486" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Blocked</text>+ <text x="500" y="503" class="t-muted" font-size="8" text-anchor="middle">wait or reject</text>++ <rect x="579" y="465" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="579" y="465" width="92" height="52" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="625" y="486" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Retry Path</text>+ <text x="625" y="503" class="t-muted" font-size="8" text-anchor="middle">revise request</text>++ <rect x="454" y="581" width="92" height="68" rx="6" class="c-mask"/>+ <rect x="454" y="581" width="92" height="68" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="500" y="602" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Tool Call</text>+ <text x="500" y="619" class="t-muted" font-size="8" text-anchor="middle">shell / browser / MCP</text>+ <text x="500" y="637" class="t-messagebus" font-size="7" text-anchor="middle">structured result</text>++ <rect x="579" y="589" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="579" y="589" width="92" height="52" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="625" y="610" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">External API</text>+ <text x="625" y="627" class="t-muted" font-size="8" text-anchor="middle">network service</text>++ <rect x="174" y="713" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="174" y="713" width="92" height="52" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="220" y="734" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Context Store</text>+ <text x="220" y="751" class="t-muted" font-size="8" text-anchor="middle">repo + memory</text>++ <rect x="454" y="713" width="92" height="52" rx="6" class="c-mask"/>+ <rect x="454" y="713" width="92" height="52" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="500" y="734" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Trace Log</text>+ <text x="500" y="751" class="t-muted" font-size="8" text-anchor="middle">events + output</text>++ <!-- Edge labels -->++ <rect x="245" y="146" width="30" height="14" rx="3" class="c-mask"/>+ <text x="260" y="156" class="t-backend" font-size="8" text-anchor="middle">plan</text>++ <rect x="423" y="277.5" width="82" height="14" rx="3" class="c-mask"/>+ <text x="464" y="287.5" class="t-security" font-size="8" text-anchor="middle">needs approval?</text>++ <rect x="445.6" y="406" width="38.8" height="14" rx="3" class="c-mask"/>+ <text x="465" y="416" class="t-security" font-size="8" text-anchor="middle">denied</text>++++ <rect x="526.3" y="777" width="72.4" height="14" rx="3" class="c-mask"/>+ <text x="562.5" y="787" class="t-database" font-size="8" text-anchor="middle">record result</text>+ <rect x="326.4" y="725" width="77.2" height="14" rx="3" class="c-mask"/>+ <text x="365" y="735" class="t-database" font-size="8" text-anchor="middle">trace + memory</text>++ <!-- Legend -->+ <text x="175" y="800" class="t-primary" font-size="10" font-weight="600">Legend</text>+ <rect x="175" y="812" width="14" height="9" rx="2" class="c-frontend" stroke-width="1"/>+ <text x="195" y="820" class="t-muted" font-size="7">User UI</text>+ <rect x="260" y="812" width="14" height="9" rx="2" class="c-backend" stroke-width="1"/>+ <text x="280" y="820" class="t-muted" font-size="7">Agent logic</text>+ <rect x="370" y="812" width="14" height="9" rx="2" class="c-security" stroke-width="1"/>+ <text x="390" y="820" class="t-muted" font-size="7">Policy</text>+ <rect x="455" y="812" width="14" height="9" rx="2" class="c-messagebus" stroke-width="1"/>+ <text x="475" y="820" class="t-muted" font-size="7">Tool action</text>+ <rect x="565" y="812" width="14" height="9" rx="2" class="c-database" stroke-width="1"/>+ <text x="585" y="820" class="t-muted" font-size="7">Context / trace</text>+ </svg>+ </div>++ <!-- Info Cards -->+ <div class="cards">+ <div class="card">+ <div class="card-header">+ <div class="card-dot cyan"></div>+ <h3>Renderer Rules</h3>+ </div>+ <ul>+ <li>• Lanes and columns determine node placement</li>+ <li>• Edges attach to explicit node anchors</li>+ <li>• Cross-lane paths use orthogonal routing</li>+ <li>• Short adjacent links stay unlabeled</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot rose"></div>+ <h3>Workflow Semantics</h3>+ </div>+ <ul>+ <li>• Approval is a first-class policy step</li>+ <li>• Consent gates are visible in the main path</li>+ <li>• External calls stay inside the tool lane</li>+ <li>• Trace writes are separate from the hot path</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot emerald"></div>+ <h3>Why It Matters</h3>+ </div>+ <ul>+ <li>• This is closer to a diagram_type renderer</li>+ <li>• The graph can be edited without SVG surgery</li>+ <li>• Layout rules can be tested and improved</li>+ <li>• A future IR can reuse this shape directly</li>+ </ul>+ </div>+ </div>++ <!-- Footer -->+ <p class="footer">+ Workflow diagram • Built with Archify<span class="no-print"> • Press <kbd>T</kbd> for theme and <kbd>E</kbd> for export</span>+ </p>+ </div>++ <script>+ /* ============================================================+ Theme toggle — persists to localStorage, respects system pref+ ============================================================ */+ var Archify = {};++ Archify.theme = (function () {+ var STORAGE_KEY = 'archify-theme';+ var html = document.documentElement;+ var btn = document.getElementById('btn-theme');+ var icon = document.getElementById('theme-icon');+ var label = document.getElementById('theme-label');++ // localStorage can throw (blocked cookies, sandboxed iframes); the whole+ // script element dies on an uncaught error, so guard every access.+ function readStored() {+ try { return localStorage.getItem(STORAGE_KEY); } catch (_) { return null; }+ }+ function writeStored(value) {+ try { localStorage.setItem(STORAGE_KEY, value); } catch (_) {}+ }+ function urlOverride() {+ // URL param wins (useful for deterministic screenshots / share links)+ try {+ var param = new URLSearchParams(window.location.search).get('theme');+ if (param === 'light' || param === 'dark') return param;+ } catch (_) {}+ return null;+ }++ function resolveInitial() {+ var fromUrl = urlOverride();+ if (fromUrl) return fromUrl;+ var saved = readStored();+ if (saved === 'light' || saved === 'dark') return saved;+ return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';+ }++ function apply(theme) {+ html.setAttribute('data-theme', theme);+ icon.textContent = theme === 'dark' ? '\u263E' : '\u263C';+ label.textContent = theme === 'dark' ? 'Dark' : 'Light';+ btn.setAttribute('aria-pressed', theme === 'light' ? 'true' : 'false');+ }++ function toggle() {+ var next = html.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';+ apply(next);+ writeStored(next);+ }++ apply(resolveInitial());+ btn.addEventListener('click', toggle);++ // Follow live OS theme changes while the user has no explicit preference.+ try {+ var media = window.matchMedia('(prefers-color-scheme: light)');+ var onChange = function (e) {+ var saved = readStored();+ if (urlOverride() || saved === 'light' || saved === 'dark') return;+ apply(e.matches ? 'light' : 'dark');+ };+ if (media.addEventListener) media.addEventListener('change', onChange);+ else if (media.addListener) media.addListener(onChange);+ } catch (_) {}++ return { toggle: toggle };+ })();++ /* ============================================================+ Export — PNG / JPEG / WebP / SVG (download) and Copy PNG (clipboard)++ Raster exports are always rendered at 4x source resolution for+ maximum sharpness. The trick: we set the serialized SVG's+ `width`/`height` to viewBox * 4 so the browser rasterizes the+ vectors at that resolution natively. drawImage then draws at+ the image's natural size (no upscaling = no blur).++ JPEG/WebP paint the current theme's background explicitly since+ those formats have no alpha channel.+ ============================================================ */+ (function () {+ var RASTER_SCALE = 4;++ function diagramFilename() {+ var title = (document.title || 'diagram')+ .replace(/\s+Architecture(\s+Diagram)?$/i, '')+ .replace(/\s+Diagram$/i, '')+ .trim();+ return title.replace(/[^a-z0-9_\-]+/gi, '-')+ .toLowerCase()+ .replace(/^-+|-+$/g, '') || 'diagram';+ }++ function currentBg() {+ return getComputedStyle(document.body).backgroundColor || '#ffffff';+ }++ /**+ * Serialize the main SVG into a standalone document.+ *+ * Two modes:+ * - Default (opts.autoTheme=false) — locks the serialized SVG to the+ * viewer's current theme. Used by the raster pipeline+ * (PNG/JPEG/WebP/clipboard) because canvas rasterization needs+ * deterministic colors; a raster cannot react to+ * prefers-color-scheme after encoding.+ * - autoTheme=true — emits BOTH dark and light variable sets plus a+ * `@media (prefers-color-scheme)` rule so the resulting SVG+ * self-themes when embedded in GitHub READMEs or other hosts that+ * expose a color scheme. Used for "Download SVG".+ */+ function serializeSvg(scale, opts) {+ // scale: integer multiplier for intrinsic SVG pixel dimensions used by+ // the raster path. Defaults to 1 (natural size) for SVG download.+ scale = scale || 1;+ opts = opts || {};+ var autoTheme = opts.autoTheme === true;++ var svg = document.querySelector('.diagram-container svg');+ var clone = svg.cloneNode(true);++ var vb = svg.viewBox.baseVal;+ // Scale width/height so the browser rasterizes the vectors at target+ // resolution directly. viewBox stays unchanged so coordinates don't+ // shift. This is the key to sharp rasters — do NOT scale later via+ // canvas upscaling.+ clone.setAttribute('width', vb.width * scale);+ clone.setAttribute('height', vb.height * scale);+ clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');++ // Only the SVG-relevant rules: semantic classes, markers, and the+ // theme variable blocks. Toolbar/cards/print CSS can never apply+ // inside a standalone SVG and would only bloat the export.+ var hostStyle = (function () {+ var out = [];+ Array.prototype.forEach.call(document.styleSheets, function (sheet) {+ var rules;+ try { rules = sheet.cssRules; } catch (_) { return; } // cross-origin+ if (!rules) return;+ Array.prototype.forEach.call(rules, function (rule) {+ if (rule.type !== 1) return; // plain style rules only+ var sel = rule.selectorText || '';+ if (/(^|,)\s*(svg|:root|\[data-theme|\.c-|\.t-|\.a-|\.m-)/.test(sel)) {+ out.push(rule.cssText);+ }+ });+ });+ return out.join('\n');+ })();++ // Derive the variable list from the stylesheet so newly added theme+ // variables can never be missed by the export pipeline again+ // (--lane-fill/--lane-stroke once were).+ var varNames = (function () {+ var seen = {};+ var names = [];+ (hostStyle.match(/--[a-zA-Z0-9-]+(?=\s*:)/g) || []).forEach(function (n) {+ if (!seen[n]) { seen[n] = true; names.push(n); }+ });+ return names;+ })();++ // Resolve the full variable set for a given data-theme via an+ // off-DOM probe, independent of what the viewer is currently set to.+ function resolveVars(themeAttr) {+ var probe = document.createElement('div');+ probe.setAttribute('data-theme', themeAttr);+ probe.style.cssText = 'position:absolute;width:0;height:0;visibility:hidden;';+ document.body.appendChild(probe);+ try {+ var c = getComputedStyle(probe);+ return varNames.map(function (n) {+ return n + ': ' + c.getPropertyValue(n).trim() + ';';+ }).join(' ');+ } finally {+ document.body.removeChild(probe);+ }+ }++ // Prepend a local()-only @font-face block for each weight so that the+ // sandboxed image-rendering context used during PNG/JPEG/WebP export+ // can find JetBrains Mono if the user has it installed locally, and+ // falls through cleanly to the monospace stack otherwise. The usual+ // Google-Fonts <link> in the host document is unreachable from the+ // serialized SVG, so url()-sourced faces would just hang.+ var fontFallback = [400, 500, 600, 700].map(function (w) {+ return "@font-face { font-family: 'JetBrains Mono'; font-weight: " + w ++ "; src: local('JetBrains Mono'), local('JetBrainsMono-Regular'); }";+ }).join('\n');++ var style = document.createElementNS('http://www.w3.org/2000/svg', 'style');+ var bgRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');+ bgRect.setAttribute('width', '100%');+ bgRect.setAttribute('height', '100%');++ if (autoTheme) {+ // Dual-theme SVG. Dark is the default (so hosts without+ // prefers-color-scheme still render), light swaps in via media+ // query, and svg[data-theme="..."] still lets downstream+ // consumers force a specific theme.+ var darkVars = resolveVars('dark');+ var lightVars = resolveVars('light');++ style.textContent =+ fontFallback + "\n" ++ "svg { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace; }\n" ++ hostStyle + "\n" ++ ":root, svg { " + darkVars + " }\n" ++ "@media (prefers-color-scheme: light) { :root, svg { " + lightVars + " } }\n" ++ "svg[data-theme=\"light\"] { " + lightVars + " }\n" ++ "svg[data-theme=\"dark\"] { " + darkVars + " }\n" ++ "rect.c-bg-rect { fill: var(--bg); }\n";++ // Don't lock the serialized SVG to the viewer's current theme.+ clone.removeAttribute('data-theme');+ // Background follows the CSS variable, not a fixed color, so it+ // swaps with the media query.+ bgRect.setAttribute('class', 'c-bg-rect');+ } else {+ // Raster path: lock to the viewer's current theme.+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';+ var themeHost = document.querySelector('[data-theme="' + theme + '"]') || document.documentElement;+ var computed = getComputedStyle(themeHost);+ var vars = varNames.map(function (n) {+ return n + ': ' + computed.getPropertyValue(n).trim() + ';';+ }).join(' ');++ // IMPORTANT: inject the resolved variables AFTER hostStyle,+ // otherwise hostStyle's ":root, [data-theme=\"dark\"] { ... }" rule+ // overrides our chosen theme via later-in-cascade equal-specificity.+ // Keep this order.+ style.textContent =+ fontFallback + "\n" ++ "svg { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', monospace; }\n" ++ hostStyle + "\n" ++ ":root, svg { " + vars + " }\n";++ bgRect.setAttribute('fill', computed.getPropertyValue('--bg').trim() || '#ffffff');+ }++ clone.insertBefore(style, clone.firstChild);+ clone.insertBefore(bgRect, style.nextSibling);++ return {+ svgString: new XMLSerializer().serializeToString(clone),+ width: vb.width * scale,+ height: vb.height * scale+ };+ }++ function download(blob, filename) {+ var url = URL.createObjectURL(blob);+ var a = document.createElement('a');+ a.href = url;+ a.download = filename;+ document.body.appendChild(a);+ a.click();+ a.remove();+ setTimeout(function () { URL.revokeObjectURL(url); }, 1000);+ }++ // Conservative upper bound on total canvas pixels. Older Safari on iOS+ // silently produces a blank canvas above ~16 Mpx; Chrome / Firefox /+ // desktop Safari are far higher but start failing on memory-constrained+ // devices. We pick the largest integer scale in {4,3,2,1} whose target+ // pixel count fits under this cap.+ var MAX_CANVAS_PIXELS = 16 * 1024 * 1024;++ function pickSafeScale(vbW, vbH) {+ for (var s = RASTER_SCALE; s >= 1; s--) {+ if (vbW * s * vbH * s <= MAX_CANVAS_PIXELS) return s;+ }+ return 1;+ }++ function rasterize(format) {+ // Serialize at a safe scale (RASTER_SCALE=4 by default, reduced if the+ // resulting canvas would exceed MAX_CANVAS_PIXELS). The SVG itself is+ // rasterized at target resolution natively; drawImage draws at natural+ // size — no upsampling blur.+ var svg = document.querySelector('.diagram-container svg');+ var vb = svg.viewBox.baseVal;+ var scale = pickSafeScale(vb.width, vb.height);+ var data = serializeSvg(scale);+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });+ var svgUrl = URL.createObjectURL(svgBlob);++ return new Promise(function (resolve, reject) {+ var img = new Image();+ img.onload = function () {+ var canvas = document.createElement('canvas');+ canvas.width = data.width;+ canvas.height = data.height;+ var ctx = canvas.getContext('2d');+ if (format === 'jpeg') {+ ctx.fillStyle = currentBg();+ ctx.fillRect(0, 0, canvas.width, canvas.height);+ }+ // Draw at natural size — SVG was already rasterized at target res.+ ctx.drawImage(img, 0, 0);+ URL.revokeObjectURL(svgUrl);+ var mime = format === 'jpeg' ? 'image/jpeg' :+ format === 'webp' ? 'image/webp' : 'image/png';+ var quality = format === 'png' ? undefined : 0.95;+ canvas.toBlob(function (blob) {+ if (!blob) reject(new Error('toBlob returned null for ' + format));+ else resolve(blob);+ }, mime, quality);+ };+ img.onerror = function (e) {+ URL.revokeObjectURL(svgUrl);+ reject(e);+ };+ img.src = svgUrl;+ });+ }++ var menu = document.getElementById('export-menu');+ var btn = document.getElementById('btn-export');+ var items = function () {+ return Array.prototype.slice.call(menu.querySelectorAll('button[role="menuitem"]'));+ };++ // ---- Clipboard support ----------------------------------------------+ function canCopyImage() {+ return typeof ClipboardItem !== 'undefined' &&+ navigator.clipboard &&+ typeof navigator.clipboard.write === 'function';+ }++ // ---- Raster format detection ----------------------------------------+ // canvas.toBlob('image/webp') silently returns a PNG on browsers without+ // WebP encoding (older Safari), so detect explicitly.+ function supports(format) {+ if (format === 'svg' || format === 'png') return true;+ var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';+ try {+ var c = document.createElement('canvas');+ c.width = c.height = 2;+ return c.toDataURL(mime).indexOf('data:' + mime) === 0;+ } catch (_) { return false; }+ }++ // Gray out unsupported items.+ items().forEach(function (it) {+ if (it.dataset.format && !supports(it.dataset.format)) {+ it.disabled = true;+ it.title = 'Not supported by this browser';+ it.style.opacity = '0.5';+ }+ if (it.dataset.action === 'copy' && !canCopyImage()) {+ it.disabled = true;+ it.title = 'Clipboard image write not supported by this browser';+ it.style.opacity = '0.5';+ }+ });++ // ---- Toast ----------------------------------------------------------+ // A live region only announces CHANGES to an existing node, so the toast+ // element is created once up front and updated in place.+ var toastEl = document.createElement('div');+ toastEl.className = 'archify-toast';+ toastEl.setAttribute('role', 'status');+ document.body.appendChild(toastEl);+ var toastTimer = null;++ function toast(msg) {+ toastEl.textContent = '';+ requestAnimationFrame(function () {+ toastEl.textContent = msg;+ toastEl.classList.add('show');+ });+ clearTimeout(toastTimer);+ toastTimer = setTimeout(function () { toastEl.classList.remove('show'); }, 1500);+ }++ function open(focusLast) {+ menu.classList.add('open');+ btn.setAttribute('aria-expanded', 'true');+ var available = items().filter(function (i) { return !i.disabled; });+ var target = focusLast ? available[available.length - 1] : available[0];+ if (target) target.focus();+ }+ function close(focusTrigger) {+ menu.classList.remove('open');+ btn.setAttribute('aria-expanded', 'false');+ if (focusTrigger) btn.focus();+ }+ function isOpen() { return menu.classList.contains('open'); }++ btn.addEventListener('click', function (e) {+ e.stopPropagation();+ if (isOpen()) close(false);+ else open();+ });+ // APG menu-button pattern: ArrowDown/ArrowUp on the trigger opens the menu.+ btn.addEventListener('keydown', function (e) {+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {+ e.preventDefault();+ if (!isOpen()) open(e.key === 'ArrowUp');+ }+ });+ document.addEventListener('click', function (e) {+ if (!menu.contains(e.target) && e.target !== btn) close(false);+ });++ // Keyboard navigation inside the menu.+ // Menu items: Up/Down, Home/End.+ // Esc closes + returns focus to trigger; Tab closes.+ menu.addEventListener('keydown', function (e) {+ if (e.key === 'Escape') { e.preventDefault(); close(true); return; }+ if (e.key === 'Tab') { close(false); return; }++ var available = items().filter(function (i) { return !i.disabled; });+ var current = available.indexOf(document.activeElement);+ switch (e.key) {+ case 'ArrowDown':+ e.preventDefault();+ if (available.length) available[(current + 1 + available.length) % available.length].focus();+ break;+ case 'ArrowUp':+ e.preventDefault();+ if (available.length) available[(current - 1 + available.length) % available.length].focus();+ break;+ case 'Home':+ e.preventDefault();+ if (available[0]) available[0].focus();+ break;+ case 'End':+ e.preventDefault();+ if (available.length) available[available.length - 1].focus();+ break;+ }+ });++ function runExport(format) {+ var base = diagramFilename();+ close(true);+ return (format === 'svg'+ ? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {+ download(new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' }), base + '.svg');+ })+ : rasterize(format).then(function (blob) {+ download(blob, base + '.' + format);+ })+ ).catch(function (err) {+ console.error(err);+ alert('Export failed: ' + (err && err.message ? err.message : format));+ });+ }++ function runCopy() {+ close(true);+ if (!canCopyImage()) {+ alert('Clipboard image write not supported in this browser.');+ return;+ }+ // WebKit requires ClipboardItem to be constructed synchronously inside+ // the user gesture — pass the pending Promise<Blob> as the item value.+ // Browsers that reject promise values throw synchronously; fall back+ // to awaiting the blob first (works in Chromium/Firefox).+ var blobPromise = rasterize('png');+ var writePromise;+ try {+ writePromise = navigator.clipboard.write([new ClipboardItem({ 'image/png': blobPromise })]);+ } catch (_) {+ writePromise = blobPromise.then(function (blob) {+ return navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);+ });+ }+ return writePromise.then(function () {+ toast('Copied PNG to clipboard');+ }).catch(function (err) {+ console.error(err);+ alert('Copy failed: ' + (err && err.message ? err.message : 'unknown'));+ });+ }++ menu.addEventListener('click', function (e) {+ var copyBtn = e.target.closest('button[data-action="copy"]');+ if (copyBtn && !copyBtn.disabled) { runCopy(); return; }++ var formatBtn = e.target.closest('button[data-format]');+ if (formatBtn && !formatBtn.disabled) { runExport(formatBtn.dataset.format); }+ });++ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };++ // Auto-open on page load for demo/screenshot purposes: ?openExport=1+ // Wait for fonts (so the menu doesn't flash before typography lands)+ // and paint before opening. Fallback timeout for browsers without the+ // Font Loading API.+ try {+ if (new URLSearchParams(window.location.search).get('openExport') === '1') {+ var openWhenReady = function () {+ requestAnimationFrame(function () { requestAnimationFrame(open); });+ };+ if (document.fonts && document.fonts.ready) {+ document.fonts.ready.then(openWhenReady);+ } else {+ setTimeout(openWhenReady, 200);+ }+ }+ } catch (_) {}+ })();++ /* ============================================================+ Global keyboard shortcuts+ T -> toggle theme+ E -> open export menu+ Ignored when focus is inside an input/textarea/contenteditable.+ ============================================================ */+ document.addEventListener('keydown', function (e) {+ if (e.metaKey || e.ctrlKey || e.altKey) return;+ var t = e.target;+ if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;+ if (e.key === 't' || e.key === 'T') {+ e.preventDefault();+ Archify.theme.toggle();+ } else if (e.key === 'e' || e.key === 'E') {+ e.preventDefault();+ if (!Archify.exportMenu.isOpen()) Archify.exportMenu.open();+ }+ });+ </script>+</body>+</html>