Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix(architecture): reserve wide arrow ports as a group
tt-a1i1757beb6048a
diff --git a/archify.zip b/archify.zipindex 58e7a675..55110a80 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/renderers/architecture/routing.mjs b/archify/renderers/architecture/routing.mjsindex 7ffdc5bf..77aae0a7 100644--- a/archify/renderers/architecture/routing.mjs+++ b/archify/renderers/architecture/routing.mjs@@ -579,7 +579,14 @@ export function createRouter(components, connections = [], {const pathCache = new Map();const selectedSides = new Map();- const automaticPorts = automaticPortSpread(connections, components);+ const stroke = (relation) => relation.width || (relation.variant === 'emphasis' ? 1.8 : 1.5);+ const markerSpacing = (left, right) => 3.5 * (stroke(left) + stroke(right));+ const portSpacing = (left, right) => Math.max(14, markerSpacing(left, right) + 3.5);+ const automaticPorts = automaticPortSpread(connections, components,+ // Preserve the established initial placement for ordinary markers; only+ // widen groups whose arrowheads cannot fit the legacy 14px slots.+ distinctAutomaticPorts ? { spacingFor: (left, right) =>+ markerSpacing(left, right) > 14 ? portSpacing(left, right) : 14 } : {});const incidentEndpoints = new Map();for (const conn of connections) {if (!components.has(conn.from) || !components.has(conn.to)) continue;@@ -635,8 +642,7 @@ export function createRouter(components, connections = [], {const point = routed? (field === 'from' ? routed.points[0] : routed.points.at(-1)): automaticPorts.get(other)?.[field] || anchor(rect, side);- const stroke = (relation) => relation.width || (relation.variant === 'emphasis' ? 1.8 : 1.5);- occupied.push({ value: point[axis], spacing: Math.max(14, 3.5 * (stroke(conn) + stroke(other)) + 3.5) });+ occupied.push({ value: point[axis], spacing: portSpacing(conn, other) });}if (!occupied.length) return { point: preferred, spread: Boolean(initial) };const candidates = [preferred[axis], ...occupied.flatMap(({ value, spacing }) => [value - spacing, value + spacing])]diff --git a/archify/renderers/shared/geometry.mjs b/archify/renderers/shared/geometry.mjsindex 8718d2a3..db75dd20 100644--- a/archify/renderers/shared/geometry.mjs+++ b/archify/renderers/shared/geometry.mjs@@ -1473,7 +1473,7 @@ export function automaticPortRhythmBridge(// Keep conservative auto-routed fan-out/fan-in relationships visually// distinct without changing authored route controls. The returned map only// contains endpoints that belong to a shared automatic midpoint anchor.-export function automaticPortSpread(relations, boxes, { gutter = 16, maxSpacing = 14, sideFor } = {}) {+export function automaticPortSpread(relations, boxes, { gutter = 16, maxSpacing = 14, sideFor, spacingFor } = {}) {const groups = new Map();const spread = new Map();@@ -1519,8 +1519,22 @@ export function automaticPortSpread(relations, boxes, { gutter = 16, maxSpacingconst spacing = Math.min(maxSpacing, usable / (items.length - 1));if (!(spacing > 0)) continue;+ // Width-aware callers reserve the whole group together. Moving a single+ // port around the legacy 14px slots can wrongly report a full side while+ // its still-unrouted neighbours could have fitted farther apart.+ let offsets;+ if (spacingFor) {+ const gaps = items.slice(1).map((item, index) => Math.max(maxSpacing,+ spacingFor(items[index].relation, item.relation)));+ const span = gaps.reduce((sum, gap) => sum + gap, 0);+ if (span <= usable && gaps.some((gap) => gap > maxSpacing)) {+ let offset = -span / 2;+ offsets = [offset, ...gaps.map((gap) => (offset += gap))];+ }+ }+for (const [index, item] of items.entries()) {- const offset = (index - (items.length - 1) / 2) * spacing;+ const offset = offsets?.[index] ?? (index - (items.length - 1) / 2) * spacing;const point = anchor(item.rect, item.side);if (verticalSide) point[1] += offset;else point[0] += offset;diff --git a/archify/test/architecture-first-draft.test.mjs b/archify/test/architecture-first-draft.test.mjsindex 01981d8d..5363226f 100644--- a/archify/test/architecture-first-draft.test.mjs+++ b/archify/test/architecture-first-draft.test.mjs@@ -48,6 +48,42 @@ test('architecture: automatic side changes keep incoming arrowheads distinct', (}});+test('architecture: wide incoming arrows reserve a whole side before routing', () => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-wide-ports-'));+ try {+ for (const { widths, height } of [+ { widths: [4, 4], height: 68 },+ { widths: [4, 4], height: 72 },+ { widths: [4, 1, 4], height: 80 },+ ]) {+ const components = widths.map((_, index) => ({+ id: `source-${index}`, type: 'backend', label: `Source ${index}`,+ pos: [40, 40 + index * 140], size: [120, 68],+ }));+ components.push({ id: 'hub', type: 'backend', label: 'Hub', pos: [600, 140], size: [180, height] });+ const connections = widths.map((width, index) => ({+ id: `edge-${index}`, from: `source-${index}`, to: 'hub', toSide: 'left', width,+ }));+ for (const ordered of [connections, [...connections].reverse()]) {+ const input = path.join(tmp, 'wide.json');+ fs.writeFileSync(input, JSON.stringify({ schema_version: 1, diagram_type: 'architecture',+ meta: { title: 'Wide incoming arrows', output: 'wide.html', quality_profile: 'showcase' },+ components, connections: ordered,+ }));+ const result = layout(input);+ assert.equal(result.ok, true, JSON.stringify(result.diagnostics));+ const tips = new Map(result.connections.map((conn) => [conn.from, conn.points.at(-1)]));+ for (let index = 1; index < connections.length; index += 1) {+ const distance = Math.abs(tips.get(`source-${index}`)[1] - tips.get(`source-${index - 1}`)[1]);+ assert.ok(distance >= 3.5 * (widths[index] + widths[index - 1]), `colliding arrows: ${distance}px`);+ }+ }+ }+ } finally {+ fs.rmSync(tmp, { recursive: true, force: true });+ }+});+// These candidates are unmodified first drafts from the repair study: authors// declared no route controls, yet the router accepted routes that the// showcase composition gate then rejected (a frame border used as a corridor,