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
Size shorthand nodes to their labels and steer agents away from ID clashes
tt-a1i5b10823b7f1f
diff --git a/archify/explainer/diagrams.mjs b/archify/explainer/diagrams.mjsindex dad42d33..ca4dc540 100644--- a/archify/explainer/diagrams.mjs+++ b/archify/explainer/diagrams.mjs@@ -5,6 +5,7 @@ import { createHash } from 'node:crypto';import { execFile } from 'node:child_process';import { promisify } from 'node:util';import { validateSchema } from '../renderers/shared/validator.mjs';+import { textUnits } from '../renderers/shared/utils.mjs';import { throwDiagnosticError } from '../renderers/shared/diagnostics.mjs';import { createOwnedTempDirectory } from '../renderers/shared/owned-temp-directory.mjs';@@ -165,6 +166,8 @@ export function compileExplainerDiagram(diagramType, rows, { title, id, line = 1else expect(entry, 2, 3, 'api | API | backend');context.rowMap[`/${diagramType === 'architecture' ? 'components' : 'nodes'}/${nodes.length}`] = entry.context.line;const node = { id: safeId(entry.parts[0], entry.context), label: entry.parts[1], type: entry.parts[2] || 'backend' };+ const labelWidth = Math.ceil(textUnits(node.label) * 6.8 + 12);+ if (diagramType === 'workflow' && labelWidth > 200) node.width = labelWidth;if (entry.parts[3]) nodeLanes.set(node.id, { lane: safeId(entry.parts[3], entry.context), context: entry.context });nodes.push(node);}@@ -174,8 +177,9 @@ export function compileExplainerDiagram(diagramType, rows, { title, id, line = 1if (diagramType === 'architecture') {const cols = Math.max(1, ...placed.map(node => node.col + 1));if (cols > 12) fail(context, 'diagram-shorthand-limit', 'This architecture needs more than twelve native grid columns.', 'Use native JSON with explicit component positions.');- spec.layout = { mode: 'grid', cols, cellW: 176, cellH: 76, gapX: 100, gapY: 110 };- spec.components = placed;+ const fitWidth = node => Math.ceil(textUnits(node.label) * 6.6 + 16);+ spec.layout = { mode: 'grid', cols, cellW: Math.max(176, ...placed.map(fitWidth)), cellH: 76, gapX: 100, gapY: 110 };+ spec.components = placed.map(node => fitWidth(node) > 120 ? { ...node, size: [fitWidth(node), 60] } : node);spec.connections = edges;} else if (lanes.size) {for (const [id, { lane, context: ctx }] of nodeLanes) if (!lanes.has(lane)) fail(ctx, 'diagram-lane', `Node ${id} names an undeclared lane.`, 'lane locate | Locate the cause');diff --git a/archify/references/explainer-authoring.md b/archify/references/explainer-authoring.mdindex 12a9eb54..96bc6252 100644--- a/archify/references/explainer-authoring.md+++ b/archify/references/explainer-authoring.md@@ -50,7 +50,7 @@ Deliver it with the command under [Delivery](#delivery).### Rules that keep a draft valid-- IDs are unique across the whole document: panels, blocks, diagrams and steps share one namespace. Name a diagram after its content (`handshake-flow`), not after its panel (`handshake`).+- IDs are unique across the whole document: panels, blocks, diagrams and steps share one namespace. Give a block an `id` only when a step, link or patch targets it; omit it on callouts, facts and lists. Name a diagram after its content (`handshake-flow`), not after its panel (`handshake`).- Prose is plain text. Wrap file paths, globs, `<placeholders>`, operators and code in backticks: a bare `<`, `>` or `*` in prose fails as HTML or emphasis. Inline code is shown literally.- Directive rows are pipe rows, one per line, each with the documented number of cells: `| first | second |`. Write a literal pipe inside a cell as `\|`. A blank line or the next `##` or `@` line ends the rows.- Directive arguments are `key=value`; quote values with spaces using double quotes and JSON escaping.