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.9.0
tt-a1i62904f3b73dc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f3576e1f..1111e864 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,8 +4,11 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo## [Unreleased]+## [2.9.0] — 2026-07-05+### Added- **Unified CLI entrypoint.** Added `bin/archify.mjs` with `render`, `validate`, `check`, and `examples` commands so renderer-backed workflows have a single product-facing command surface.+- **Architecture examples.** Added self-diagram (`examples/archify-repo.*`) and a third-party sample (`examples/maka-architecture.*`) demonstrating clean main-path layout on real repos.## [2.8.0] — 2026-07-03diff --git a/README.md b/README.mdindex 3e9350a6..efa9a00f 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/)diff --git a/README_EN.md b/README_EN.mdindex 3e9350a6..efa9a00f 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/)diff --git a/README_ZH.md b/README_ZH.mdindex 1c87ffcb..c63463eb 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/)**diff --git a/archify.zip b/archify.zipindex 0926106d..fdce06fc 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/SKILL.md b/archify/SKILL.mdindex 55e4f3d5..96ca872f 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.8"+ version: "2.9"author: tt-a1ibased_on: Cocoon-AI/architecture-diagram-generator (MIT, v1.0)---diff --git a/archify/assets/template.html b/archify/assets/template.htmlindex 7663723f..f1657fba 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.8.0">+ <meta name="generator" content="archify 2.9.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 722b5739..71bed22d 100644--- a/archify/package-lock.json+++ b/archify/package-lock.json@@ -1,12 +1,12 @@{"name": "archify",- "version": "2.8.0",+ "version": "2.9.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "archify",- "version": "2.8.0",+ "version": "2.9.0","license": "MIT","dependencies": {"ajv": "^8.17.1"diff --git a/archify/package.json b/archify/package.jsonindex 5cd88552..6f530524 100644--- a/archify/package.json+++ b/archify/package.json@@ -1,6 +1,6 @@{"name": "archify",- "version": "2.8.0",+ "version": "2.9.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 9974b3b8..3ead1130 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.8.0</span>+ <span data-i18n="hero-badge">Agent Skill · v2.9.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.8.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator</p>+ <p class="footer-meta" data-i18n="footer-meta">v2.9.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.8.0',+ 'hero-badge':'Agent Skill · v2.9.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.8.0 · MIT License<br>Based on Cocoon-AI/architecture-diagram-generator',+ 'footer-meta':'v2.9.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.8.0',+ 'hero-badge':'Agent 技能 · v2.9.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.8.0 · MIT 许可证<br>基于 Cocoon-AI/architecture-diagram-generator',+ 'footer-meta':'v2.9.0 · MIT 许可证<br>基于 Cocoon-AI/architecture-diagram-generator','footer-changelog':'更新日志','footer-license':'许可证'}};diff --git a/examples/archify-repo.architecture.json b/examples/archify-repo.architecture.jsonnew file mode 100644index 00000000..bd9ac1d9--- /dev/null+++ b/examples/archify-repo.architecture.json@@ -0,0 +1,199 @@+{+ "schema_version": 1,+ "diagram_type": "architecture",+ "meta": {+ "title": "Archify",+ "subtitle": "Agent skill → JSON IR → typed renderers → standalone HTML",+ "output": "examples/archify-repo.html"+ },+ "components": [+ {+ "id": "user",+ "type": "external",+ "label": "You",+ "sublabel": "NL or Mermaid",+ "pos": [40, 300],+ "size": [120, 60]+ },+ {+ "id": "agents",+ "type": "frontend",+ "label": "Agent Hosts",+ "sublabel": "Claude · Codex · opencode",+ "pos": [200, 300],+ "size": [150, 60]+ },+ {+ "id": "skill",+ "type": "frontend",+ "label": "SKILL.md",+ "sublabel": "layout judgment",+ "pos": [200, 140],+ "size": [150, 60],+ "tag": "prompt dialect"+ },+ {+ "id": "ir",+ "type": "messagebus",+ "label": "JSON IR",+ "sublabel": "schema_version: 1",+ "pos": [400, 300],+ "size": [140, 60]+ },+ {+ "id": "schemas",+ "type": "security",+ "label": "JSON Schema",+ "sublabel": "ajv strict",+ "pos": [400, 140],+ "size": [140, 60],+ "tag": "fail-closed"+ },+ {+ "id": "renderers",+ "type": "backend",+ "label": "Renderers ×5",+ "sublabel": "layout checks",+ "pos": [590, 300],+ "size": [140, 60],+ "tag": "no auto-layout"+ },+ {+ "id": "template",+ "type": "frontend",+ "label": "template.html",+ "sublabel": "theme + export",+ "pos": [780, 300],+ "size": [140, 60]+ },+ {+ "id": "checker",+ "type": "security",+ "label": "Output Check",+ "sublabel": "SVG gates",+ "pos": [970, 300],+ "size": [140, 60]+ },+ {+ "id": "html",+ "type": "cloud",+ "label": "HTML Artifact",+ "sublabel": "single file",+ "pos": [1160, 300],+ "size": [140, 60]+ },+ {+ "id": "zip",+ "type": "cloud",+ "label": "archify.zip",+ "sublabel": "skill package",+ "pos": [1160, 140],+ "size": [140, 60]+ },+ {+ "id": "ci",+ "type": "backend",+ "label": "CI Gates",+ "sublabel": "golden + zip",+ "pos": [590, 440],+ "size": [140, 60]+ }+ ],+ "boundaries": [+ {+ "kind": "region",+ "label": "archify/ skill package",+ "wraps": ["ir", "schemas", "renderers", "template", "checker"]+ }+ ],+ "connections": [+ {+ "from": "user",+ "to": "agents",+ "variant": "emphasis"+ },+ {+ "from": "agents",+ "to": "skill",+ "fromSide": "top",+ "toSide": "bottom"+ },+ {+ "from": "agents",+ "to": "ir",+ "label": "write IR",+ "variant": "emphasis"+ },+ {+ "from": "ir",+ "to": "schemas",+ "variant": "security",+ "fromSide": "top",+ "toSide": "bottom"+ },+ {+ "from": "ir",+ "to": "renderers",+ "variant": "emphasis"+ },+ {+ "from": "renderers",+ "to": "template",+ "variant": "emphasis"+ },+ {+ "from": "template",+ "to": "checker",+ "variant": "emphasis"+ },+ {+ "from": "checker",+ "to": "html",+ "label": "deliver",+ "variant": "emphasis"+ },+ {+ "from": "renderers",+ "to": "ci",+ "variant": "dashed",+ "fromSide": "bottom",+ "toSide": "top"+ },+ {+ "from": "html",+ "to": "zip",+ "variant": "dashed",+ "fromSide": "top",+ "toSide": "bottom"+ }+ ],+ "cards": [+ {+ "dot": "cyan",+ "title": "Agent loop",+ "items": [+ "Claude / Codex / opencode load the skill",+ "SKILL.md teaches layout judgment, not auto-layout",+ "Mermaid is an input dialect via prompt, not a parser"+ ]+ },+ {+ "dot": "emerald",+ "title": "Render path",+ "items": [+ "JSON IR pins schema_version: 1",+ "Five typed renderers: architecture / workflow / sequence / dataflow / lifecycle",+ "template.html owns theme toggle and 4× export"+ ]+ },+ {+ "dot": "rose",+ "title": "Quality gates",+ "items": [+ "ajv schema validation sits on the IR (fail-closed)",+ "Renderer layout checks, then Output Check on the HTML",+ "CI golden tests and zip freshness stay off the main path"+ ]+ }+ ]+}diff --git a/examples/archify-repo.html b/examples/archify-repo.htmlnew file mode 100644index 00000000..a72d1a80--- /dev/null+++ b/examples/archify-repo.html@@ -0,0 +1,1236 @@+<!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>Archify 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>Archify</h1>+ </div>+ <p class="subtitle">Agent skill → JSON IR → typed renderers → standalone HTML</p>+ </div>++ <!-- Main Diagram -->+ <div class="diagram-container">+ <svg viewBox="0 0 1340 568" role="img" aria-label="Archify — Agent skill → JSON IR → typed renderers → standalone HTML (architecture 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)" />++ <!-- Boundaries (behind everything) -->+ <rect x="370" y="110" width="770" height="270" rx="12" class="c-region" stroke-width="1"/>+ <text x="378" y="128" class="t-cloud" font-size="9" font-weight="600">archify/ skill package</text>++ <!-- Connection paths (before components for correct z-order) -->+ <path d="M 160 330 L 200 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 275 300 L 275 200" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 350 330 L 400 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 470 300 L 470 200" class="a-security" stroke-width="1.5" marker-end="url(#arrowhead-security)"/>+ <path d="M 540 330 L 590 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 730 330 L 780 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 920 330 L 970 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 1110 330 L 1160 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 660 360 L 660 440" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 1230 300 L 1230 200" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>++ <!-- 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">You</text>+ <text x="100" y="344" class="t-muted" font-size="9" text-anchor="middle">NL or Mermaid</text>++ <rect x="200" y="300" width="150" height="60" rx="6" class="c-mask"/>+ <rect x="200" y="300" width="150" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="275" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Agent Hosts</text>+ <text x="275" y="344" class="t-muted" font-size="9" text-anchor="middle">Claude · Codex · opencode</text>++ <rect x="200" y="140" width="150" height="60" rx="6" class="c-mask"/>+ <rect x="200" y="140" width="150" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="275" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">SKILL.md</text>+ <text x="275" y="184" class="t-muted" font-size="9" text-anchor="middle">layout judgment</text>+ <text x="275" y="192" class="t-frontend" font-size="7" text-anchor="middle">prompt dialect</text>++ <rect x="400" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="400" y="300" width="140" height="60" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="470" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">JSON IR</text>+ <text x="470" y="344" class="t-muted" font-size="9" text-anchor="middle">schema_version: 1</text>++ <rect x="400" y="140" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="400" y="140" width="140" height="60" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="470" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">JSON Schema</text>+ <text x="470" y="184" class="t-muted" font-size="9" text-anchor="middle">ajv strict</text>+ <text x="470" y="192" class="t-security" font-size="7" text-anchor="middle">fail-closed</text>++ <rect x="590" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="590" y="300" width="140" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="660" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Renderers ×5</text>+ <text x="660" y="344" class="t-muted" font-size="9" text-anchor="middle">layout checks</text>+ <text x="660" y="352" class="t-backend" font-size="7" text-anchor="middle">no auto-layout</text>++ <rect x="780" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="780" y="300" width="140" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="850" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">template.html</text>+ <text x="850" y="344" class="t-muted" font-size="9" text-anchor="middle">theme + export</text>++ <rect x="970" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="970" y="300" width="140" height="60" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="1040" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Output Check</text>+ <text x="1040" y="344" class="t-muted" font-size="9" text-anchor="middle">SVG gates</text>++ <rect x="1160" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="1160" y="300" width="140" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="1230" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">HTML Artifact</text>+ <text x="1230" y="344" class="t-muted" font-size="9" text-anchor="middle">single file</text>++ <rect x="1160" y="140" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="1160" y="140" width="140" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="1230" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">archify.zip</text>+ <text x="1230" y="184" class="t-muted" font-size="9" text-anchor="middle">skill package</text>++ <rect x="590" y="440" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="590" y="440" width="140" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="660" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">CI Gates</text>+ <text x="660" y="484" class="t-muted" font-size="9" text-anchor="middle">golden + zip</text>++ <!-- Connection labels -->+++ <rect x="350.8" y="310" width="48.4" height="14" rx="3" class="c-mask"/>+ <text x="375" y="320" class="t-backend" font-size="8" text-anchor="middle">write IR</text>+++++ <rect x="1113.2" y="310" width="43.6" height="14" rx="3" class="c-mask"/>+ <text x="1135" y="320" class="t-backend" font-size="8" text-anchor="middle">deliver</text>++++ <!-- Legend -->+ <text x="40" y="539" class="t-primary" font-size="9" font-weight="600">Legend</text>+ <rect x="40" y="544" width="14" height="9" rx="2" class="c-external" stroke-width="1"/>+ <text x="60" y="552" class="t-muted" font-size="8">External</text>+ <rect x="138" y="544" width="14" height="9" rx="2" class="c-frontend" stroke-width="1"/>+ <text x="158" y="552" class="t-muted" font-size="8">Frontend</text>+ <rect x="236" y="544" width="14" height="9" rx="2" class="c-messagebus" stroke-width="1"/>+ <text x="256" y="552" class="t-muted" font-size="8">Message bus</text>+ <rect x="349" y="544" width="14" height="9" rx="2" class="c-security" stroke-width="1"/>+ <text x="369" y="552" class="t-muted" font-size="8">Security</text>+ <rect x="447" y="544" width="14" height="9" rx="2" class="c-backend" stroke-width="1"/>+ <text x="467" y="552" class="t-muted" font-size="8">Backend</text>+ <rect x="540" y="544" width="14" height="9" rx="2" class="c-cloud" stroke-width="1"/>+ <text x="560" y="552" class="t-muted" font-size="8">Cloud</text>+ </svg>+ </div>++ <!-- Info Cards -->+ <div class="cards">+ <div class="card">+ <div class="card-header">+ <div class="card-dot cyan"></div>+ <h3>Agent loop</h3>+ </div>+ <ul>+ <li>• Claude / Codex / opencode load the skill</li>+ <li>• SKILL.md teaches layout judgment, not auto-layout</li>+ <li>• Mermaid is an input dialect via prompt, not a parser</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot emerald"></div>+ <h3>Render path</h3>+ </div>+ <ul>+ <li>• JSON IR pins schema_version: 1</li>+ <li>• Five typed renderers: architecture / workflow / sequence / dataflow / lifecycle</li>+ <li>• template.html owns theme toggle and 4× export</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot rose"></div>+ <h3>Quality gates</h3>+ </div>+ <ul>+ <li>• ajv schema validation sits on the IR (fail-closed)</li>+ <li>• Renderer layout checks, then Output Check on the HTML</li>+ <li>• CI golden tests and zip freshness stay off the main path</li>+ </ul>+ </div>+ </div>++ <!-- Footer -->+ <p class="footer">+ Architecture 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/dataflow-product-analytics.html b/examples/dataflow-product-analytics.htmlindex d1e442f5..1bd90d30 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.8.0">+ <meta name="generator" content="archify 2.9.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 81a08ab1..d44d1558 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.8.0">+ <meta name="generator" content="archify 2.9.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.architecture.json b/examples/maka-architecture.architecture.jsonnew file mode 100644index 00000000..208e0ae2--- /dev/null+++ b/examples/maka-architecture.architecture.json@@ -0,0 +1,226 @@+{+ "schema_version": 1,+ "diagram_type": "architecture",+ "meta": {+ "title": "Maka",+ "subtitle": "Local-first desktop AI workbench — sessions, tools, permissions, recovery",+ "output": "examples/maka-architecture.html"+ },+ "components": [+ {+ "id": "user",+ "type": "external",+ "label": "You",+ "sublabel": "desktop user",+ "pos": [40, 300],+ "size": [120, 60]+ },+ {+ "id": "ui",+ "type": "frontend",+ "label": "Desktop UI",+ "sublabel": "React renderer",+ "pos": [200, 300],+ "size": [140, 60]+ },+ {+ "id": "main",+ "type": "backend",+ "label": "Main Process",+ "sublabel": "Electron IPC",+ "pos": [390, 300],+ "size": [140, 60]+ },+ {+ "id": "session",+ "type": "backend",+ "label": "SessionManager",+ "sublabel": "public runtime API",+ "pos": [580, 300],+ "size": [150, 60]+ },+ {+ "id": "agentrun",+ "type": "backend",+ "label": "AgentRun",+ "sublabel": "turn + recovery",+ "pos": [780, 300],+ "size": [140, 60]+ },+ {+ "id": "model",+ "type": "backend",+ "label": "ModelAdapter",+ "sublabel": "stream + usage",+ "pos": [970, 300],+ "size": [140, 60]+ },+ {+ "id": "providers",+ "type": "cloud",+ "label": "Model Providers",+ "sublabel": "AI SDK / Ollama",+ "pos": [970, 140],+ "size": [140, 60],+ "tag": "API keys local"+ },+ {+ "id": "bots",+ "type": "external",+ "label": "Bots & Gateway",+ "sublabel": "Telegram · Feishu · HTTP",+ "pos": [580, 140],+ "size": [150, 60]+ },+ {+ "id": "permission",+ "type": "security",+ "label": "Permission",+ "sublabel": "policy engine",+ "pos": [780, 140],+ "size": [140, 60],+ "tag": "fail-closed"+ },+ {+ "id": "storage",+ "type": "database",+ "label": "Local Storage",+ "sublabel": "userData JSONL",+ "pos": [580, 440],+ "size": [150, 60]+ },+ {+ "id": "toolrt",+ "type": "messagebus",+ "label": "ToolRuntime",+ "sublabel": "validate · abort",+ "pos": [780, 440],+ "size": [140, 60]+ },+ {+ "id": "tools",+ "type": "frontend",+ "label": "Local Tools",+ "sublabel": "Read · Write · Bash",+ "pos": [970, 440],+ "size": [140, 60]+ }+ ],+ "boundaries": [+ {+ "kind": "region",+ "label": "Electron app + packages/runtime",+ "wraps": ["ui", "main", "session", "agentrun", "model", "toolrt", "storage", "permission"]+ },+ {+ "kind": "security-group",+ "label": "trust boundary",+ "wraps": ["permission", "storage"]+ }+ ],+ "connections": [+ {+ "from": "user",+ "to": "ui",+ "variant": "emphasis"+ },+ {+ "from": "ui",+ "to": "main",+ "label": "IPC",+ "variant": "emphasis"+ },+ {+ "from": "main",+ "to": "session",+ "variant": "emphasis"+ },+ {+ "from": "session",+ "to": "agentrun",+ "label": "turn",+ "variant": "emphasis"+ },+ {+ "from": "agentrun",+ "to": "model",+ "variant": "emphasis"+ },+ {+ "from": "model",+ "to": "providers",+ "label": "stream",+ "variant": "emphasis",+ "fromSide": "top",+ "toSide": "bottom"+ },+ {+ "from": "bots",+ "to": "session",+ "variant": "dashed",+ "fromSide": "bottom",+ "toSide": "top"+ },+ {+ "from": "agentrun",+ "to": "permission",+ "variant": "security",+ "fromSide": "top",+ "toSide": "bottom"+ },+ {+ "from": "session",+ "to": "storage",+ "variant": "dashed",+ "fromSide": "bottom",+ "toSide": "top"+ },+ {+ "from": "agentrun",+ "to": "toolrt",+ "fromSide": "bottom",+ "toSide": "top"+ },+ {+ "from": "toolrt",+ "to": "tools",+ "variant": "emphasis"+ },+ {+ "from": "toolrt",+ "to": "permission",+ "variant": "security",+ "fromSide": "top",+ "toSide": "bottom"+ }+ ],+ "cards": [+ {+ "dot": "cyan",+ "title": "Desktop surfaces",+ "items": [+ "apps/desktop: renderer, preload, main process",+ "Settings for models, bots, search, gateway, permissions",+ "Bots and open gateway share SessionManager as the public API"+ ]+ },+ {+ "dot": "emerald",+ "title": "Runtime kernel",+ "items": [+ "SessionManager → AgentRun → AiSdkBackend",+ "ModelAdapter normalizes provider streams and usage",+ "ToolRuntime owns tool validation, abort, and telemetry"+ ]+ },+ {+ "dot": "rose",+ "title": "Local & privacy",+ "items": [+ "Sessions and credentials live under Electron userData",+ "Write/Bash and risky ops go through the permission engine",+ "Renderer never sees plaintext secrets — only masked status"+ ]+ }+ ]+}diff --git a/examples/maka-architecture.html b/examples/maka-architecture.htmlnew file mode 100644index 00000000..48ecc2e5--- /dev/null+++ b/examples/maka-architecture.html@@ -0,0 +1,1250 @@+<!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>Maka 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>Maka</h1>+ </div>+ <p class="subtitle">Local-first desktop AI workbench — sessions, tools, permissions, recovery</p>+ </div>++ <!-- Main Diagram -->+ <div class="diagram-container">+ <svg viewBox="0 0 1180 588" role="img" aria-label="Maka — Local-first desktop AI workbench — sessions, tools, permissions, recovery (architecture 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)" />++ <!-- Boundaries (behind everything) -->+ <rect x="170" y="110" width="970" height="410" rx="12" class="c-region" stroke-width="1"/>+ <text x="178" y="128" class="t-cloud" font-size="9" font-weight="600">Electron app + packages/runtime</text>++ <rect x="550" y="110" width="400" height="410" rx="8" class="c-security-group" stroke-width="1"/>+ <text x="558" y="128" class="t-security" font-size="9" font-weight="600">trust boundary</text>++ <!-- Connection paths (before components for correct z-order) -->+ <path d="M 160 330 L 200 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 340 330 L 390 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 530 330 L 580 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 730 330 L 780 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 920 330 L 970 330" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 1040 300 L 1040 200" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 655 200 L 655 300" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 850 300 L 850 200" class="a-security" stroke-width="1.5" marker-end="url(#arrowhead-security)"/>+ <path d="M 655 360 L 655 440" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>+ <path d="M 850 360 L 850 440" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>+ <path d="M 920 470 L 970 470" class="a-emphasis" stroke-width="1.8" marker-end="url(#arrowhead-emphasis)"/>+ <path d="M 850 440 L 850 200" class="a-security" stroke-width="1.5" marker-end="url(#arrowhead-security)"/>++ <!-- 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">You</text>+ <text x="100" y="344" class="t-muted" font-size="9" text-anchor="middle">desktop user</text>++ <rect x="200" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="200" y="300" width="140" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="270" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Desktop UI</text>+ <text x="270" y="344" class="t-muted" font-size="9" text-anchor="middle">React renderer</text>++ <rect x="390" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="390" y="300" width="140" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="460" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Main Process</text>+ <text x="460" y="344" class="t-muted" font-size="9" text-anchor="middle">Electron IPC</text>++ <rect x="580" y="300" width="150" height="60" rx="6" class="c-mask"/>+ <rect x="580" y="300" width="150" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="655" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">SessionManager</text>+ <text x="655" y="344" class="t-muted" font-size="9" text-anchor="middle">public runtime API</text>++ <rect x="780" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="780" y="300" width="140" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="850" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">AgentRun</text>+ <text x="850" y="344" class="t-muted" font-size="9" text-anchor="middle">turn + recovery</text>++ <rect x="970" y="300" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="970" y="300" width="140" height="60" rx="6" class="c-backend" stroke-width="1.5"/>+ <text x="1040" y="328" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">ModelAdapter</text>+ <text x="1040" y="344" class="t-muted" font-size="9" text-anchor="middle">stream + usage</text>++ <rect x="970" y="140" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="970" y="140" width="140" height="60" rx="6" class="c-cloud" stroke-width="1.5"/>+ <text x="1040" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Model Providers</text>+ <text x="1040" y="184" class="t-muted" font-size="9" text-anchor="middle">AI SDK / Ollama</text>+ <text x="1040" y="192" class="t-cloud" font-size="7" text-anchor="middle">API keys local</text>++ <rect x="580" y="140" width="150" height="60" rx="6" class="c-mask"/>+ <rect x="580" y="140" width="150" height="60" rx="6" class="c-external" stroke-width="1.5"/>+ <text x="655" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Bots & Gateway</text>+ <text x="655" y="184" class="t-muted" font-size="9" text-anchor="middle">Telegram · Feishu · HTTP</text>++ <rect x="780" y="140" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="780" y="140" width="140" height="60" rx="6" class="c-security" stroke-width="1.5"/>+ <text x="850" y="168" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Permission</text>+ <text x="850" y="184" class="t-muted" font-size="9" text-anchor="middle">policy engine</text>+ <text x="850" y="192" class="t-security" font-size="7" text-anchor="middle">fail-closed</text>++ <rect x="580" y="440" width="150" height="60" rx="6" class="c-mask"/>+ <rect x="580" y="440" width="150" height="60" rx="6" class="c-database" stroke-width="1.5"/>+ <text x="655" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Local Storage</text>+ <text x="655" y="484" class="t-muted" font-size="9" text-anchor="middle">userData JSONL</text>++ <rect x="780" y="440" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="780" y="440" width="140" height="60" rx="6" class="c-messagebus" stroke-width="1.5"/>+ <text x="850" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">ToolRuntime</text>+ <text x="850" y="484" class="t-muted" font-size="9" text-anchor="middle">validate · abort</text>++ <rect x="970" y="440" width="140" height="60" rx="6" class="c-mask"/>+ <rect x="970" y="440" width="140" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>+ <text x="1040" y="468" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">Local Tools</text>+ <text x="1040" y="484" class="t-muted" font-size="9" text-anchor="middle">Read · Write · Bash</text>++ <!-- Connection labels -->++ <rect x="350" y="310" width="30" height="14" rx="3" class="c-mask"/>+ <text x="365" y="320" class="t-backend" font-size="8" text-anchor="middle">IPC</text>++ <rect x="740" y="310" width="30" height="14" rx="3" class="c-mask"/>+ <text x="755" y="320" class="t-backend" font-size="8" text-anchor="middle">turn</text>++ <rect x="1020.6" y="280" width="38.8" height="14" rx="3" class="c-mask"/>+ <text x="1040" y="290" class="t-backend" font-size="8" text-anchor="middle">stream</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-frontend" stroke-width="1"/>+ <text x="158" y="572" class="t-muted" font-size="8">Frontend</text>+ <rect x="236" y="564" width="14" height="9" rx="2" class="c-backend" stroke-width="1"/>+ <text x="256" y="572" class="t-muted" font-size="8">Backend</text>+ <rect x="329" y="564" width="14" height="9" rx="2" class="c-cloud" stroke-width="1"/>+ <text x="349" y="572" class="t-muted" font-size="8">Cloud</text>+ <rect x="412" y="564" width="14" height="9" rx="2" class="c-security" stroke-width="1"/>+ <text x="432" y="572" class="t-muted" font-size="8">Security</text>+ <rect x="510" y="564" width="14" height="9" rx="2" class="c-database" stroke-width="1"/>+ <text x="530" y="572" class="t-muted" font-size="8">Database</text>+ <rect x="608" y="564" width="14" height="9" rx="2" class="c-messagebus" stroke-width="1"/>+ <text x="628" 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 cyan"></div>+ <h3>Desktop surfaces</h3>+ </div>+ <ul>+ <li>• apps/desktop: renderer, preload, main process</li>+ <li>• Settings for models, bots, search, gateway, permissions</li>+ <li>• Bots and open gateway share SessionManager as the public API</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot emerald"></div>+ <h3>Runtime kernel</h3>+ </div>+ <ul>+ <li>• SessionManager → AgentRun → AiSdkBackend</li>+ <li>• ModelAdapter normalizes provider streams and usage</li>+ <li>• ToolRuntime owns tool validation, abort, and telemetry</li>+ </ul>+ </div>++ <div class="card">+ <div class="card-header">+ <div class="card-dot rose"></div>+ <h3>Local & privacy</h3>+ </div>+ <ul>+ <li>• Sessions and credentials live under Electron userData</li>+ <li>• Write/Bash and risky ops go through the permission engine</li>+ <li>• Renderer never sees plaintext secrets — only masked status</li>+ </ul>+ </div>+ </div>++ <!-- Footer -->+ <p class="footer">+ Architecture 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/sequence-cache-miss-request.html b/examples/sequence-cache-miss-request.htmlindex fe2891c1..e8403236 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.8.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'tdiff --git a/examples/web-app-rendered.html b/examples/web-app-rendered.htmlindex f078437e..db467d83 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.8.0">+ <meta name="generator" content="archify 2.9.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 e48d7bd1..da85ed3e 100644--- a/examples/web-app.html+++ b/examples/web-app.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.8.0">+ <meta name="generator" content="archify 2.9.0"><title>Sample Web App Architecture Diagram</title><script>// Resolve the theme before first paint so light-preference users don'tdiff --git a/examples/workflow-agent-tool-call-rendered.html b/examples/workflow-agent-tool-call-rendered.htmlindex 517384f4..7eb5ec26 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.8.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