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
Merge latest dev into Sequence spread capacity branch
tt-a1i4d7e5605ad92
diff --cc archify.zipindex b983678e,47fdb8be..5b65b36dBinary files differdiff --cc docs/gallery.htmlindex 6a7be74e,00ee69af..4174a5e7--- a/docs/gallery.html+++ b/docs/gallery.html@@@ -477,7 -477,7 +477,7 @@@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">7N · 14E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="8bab7c2e51b3b7ded32e86d53a48a42be2542b9d6bf2c73f25f366e68790ff45">8bab7c2e51b3</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="9dafff82eaab1e7f45c8a290c71036275d8ffdbf35ba2df8242a8b324a6d8de7">9dafff82eaab</span></div>++ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="2a034af8c52698684e7f0e1f1f14988ea52043cd5012245c05a02d0b7372f92c">2a034af8c526</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/async-job-roundtrip.sequence.html#focus=queue" target="_blank" rel="noopener" data-en="Explore focus ↗" data-zh="探索聚焦路径 ↗">Explore focus ↗</a>@@@ -1564,8 -1564,8 +1564,8 @@@ receipt 108 checks / 12 artifacts / det"engineeringProfile": null,"nodeCount": 7,"edgeCount": 14,- "artifactBytes": 771167,- "artifactSha256": "8bab7c2e51b3b7ded32e86d53a48a42be2542b9d6bf2c73f25f366e68790ff45",- "artifactBytes": 777193,- "artifactSha256": "9dafff82eaab1e7f45c8a290c71036275d8ffdbf35ba2df8242a8b324a6d8de7",++ "artifactBytes": 778453,++ "artifactSha256": "2a034af8c52698684e7f0e1f1f14988ea52043cd5012245c05a02d0b7372f92c","sourceBytes": 3766,"sourceSha256": "b8c6c52f1763ede2933c77deb8da59b3e06917bc41d27e66df896136456b859a","checks": [diff --cc docs/gallery/manifest.jsonindex 1c7c3b00,5970487e..856b65b9--- a/docs/gallery/manifest.json+++ b/docs/gallery/manifest.json@@@ -882,8 -882,8 +882,8 @@@"engineeringProfile": null,"nodeCount": 7,"edgeCount": 14,- "artifactBytes": 771167,- "artifactSha256": "8bab7c2e51b3b7ded32e86d53a48a42be2542b9d6bf2c73f25f366e68790ff45",- "artifactBytes": 777193,- "artifactSha256": "9dafff82eaab1e7f45c8a290c71036275d8ffdbf35ba2df8242a8b324a6d8de7",++ "artifactBytes": 778453,++ "artifactSha256": "2a034af8c52698684e7f0e1f1f14988ea52043cd5012245c05a02d0b7372f92c","sourceBytes": 3766,"sourceSha256": "b8c6c52f1763ede2933c77deb8da59b3e06917bc41d27e66df896136456b859a","checks": [diff --cc test/sequence-column-fit.test.mjsindex 23531fbf,ef15ad0d..b99a3c93--- a/test/sequence-column-fit.test.mjs+++ b/test/sequence-column-fit.test.mjs@@@ -100,10 -102,10 +100,10 @@@ test('a label the fixed box rejects fitconst estimatedLabelW = textUnits(wideLabel) * 6.8;assert.ok(estimatedLabelW > 86 + 6, 'the fixture label must actually exceed the fixed box');- const fixed = renderOutcome(labelledSequence());+ const fixed = renderOutcome(labelledSequence('fixed'));assert.notEqual(fixed.code, 0, 'the fixed box still rejects a label it cannot hold');assert.ok(fixed.stderr.includes(`Label "${wideLabel}"`), `expected the label in stderr:\n${fixed.stderr}`);- assert.ok(fixed.stderr.includes('86px participant box'), `expected the fixed box width in stderr:\n${fixed.stderr}`);+ assert.ok(fixed.stderr.includes('component "gateway" (86px)'), `expected the fixed box width in stderr:\n${fixed.stderr}`);const spread = renderOutcome(labelledSequence('spread'));assert.equal(spread.code, 0, spread.stderr);@@@ -168,83 -167,15 +168,95 @@@ test('standard retains acceptance for passert.equal(Number(plate[3]), 9);});++test('seven participants fit an authored 820px frame with real card gutters', () => {+ const doc = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples/async-job-roundtrip.sequence.json'), 'utf8'));+ assert.equal(doc.meta.column_fit, undefined);+ const original = structuredClone(doc);+ const html = render(doc);+ const boxes = participantBoxes(html);+ assert.equal(boxes.length, 7);+ assert.equal(boxes[0].x, 62);+ assert.equal(boxes.at(-1).x + boxes.at(-1).width, 780);+ for (let i = 1; i < boxes.length; i++) {+ const gap = boxes[i].x - boxes[i - 1].x;+ assert.ok(gap < 108 && gap >= boxes[i - 1].width + 16);+ }+ assert.match(html, /viewBox="0 0 820 920"/);+ assert.deepEqual(doc, original, 'rendering never rewrites the authored input');+ assert.equal(html, render({ ...doc, meta: { ...doc.meta, column_fit: 'spread' } }));+ const nodes = [...html.matchAll(/<g id="node-([^"]+)"/g)].map(match => match[1]);+ assert.deepEqual(nodes, doc.participants.map(participant => participant.id));+ const paths = [...html.matchAll(/data-composition-edge-from="([^"]+)" data-composition-edge-to="([^"]+)"[^>]* d="M ([\d.]+) ([\d.]+) L ([\d.]+) ([\d.]+)"/g)];+ assert.deepEqual(paths.map(match => [match[1], match[2], Number(match[4]), Number(match[6])]),+ doc.messages.map(message => [message.from, message.to, message.y, message.y]));+ for (const match of paths) assert.ok(Math.abs(Number(match[5]) - Number(match[3])) >= 60);+ for (const message of doc.messages) assert.ok(html.includes(`>${message.label}</text>`));+});++test('spread capacity still rejects an infeasible frame and unrescuable participant label', () => {+ const doc = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples/async-job-roundtrip.sequence.json'), 'utf8'));+ doc.meta.viewBox[0] = 740;+ const narrow = renderOutcome(doc);+ assert.notEqual(narrow.code, 0);+ assert.match(narrow.stderr, /Participants exceed viewBox width/);+ doc.meta.viewBox[0] = 820;+ doc.participants[0].label = 'A participant label far beyond the available frame capacity';+ const long = renderOutcome(doc);+ assert.notEqual(long.code, 0);- assert.match(long.stderr, /wider than the 86px participant box/);++ assert.ok(long.stderr.includes(`wider than component "${doc.participants[0].id}" (86px)`), long.stderr);+});+++test('narrow authored canvases reduce only the spread left margin to retain feasible capacity', () => {+ for (const [width, height, count, expectedLeft] of [[480, 620, 4, 48], [794, 920, 7, 56]]) {+ const doc = wideSequence();+ doc.meta.viewBox = [width, height];+ doc.participants = Array.from({ length: count }, (_, index) => ({ id: `p${index}`, type: 'backend', label: `P${index}` }));+ doc.messages = [{ from: 'p0', to: `p${count - 1}`, y: 200, label: 'request' }];+ const html = render(doc, true);+ const boxes = participantBoxes(html);+ assert.equal(boxes.length, count);+ assert.equal(boxes[0].x, expectedLeft);+ assert.equal(boxes[0].width, 86);+ assert.equal(boxes.at(-1).x + boxes.at(-1).width, width - 40);+ for (let i = 1; i < boxes.length; i++) assert.ok(boxes[i].x - boxes[i - 1].x - boxes[i - 1].width >= 16);+ assert.match(html, new RegExp(`viewBox="0 0 ${width} ${height}"`));+ assert.equal(html, render({ ...doc, meta: { ...doc.meta, column_fit: 'spread' } }, true));+ const fixedBoxes = participantBoxes(render({ ...doc, meta: { ...doc.meta, column_fit: 'fixed' } }, true));+ assert.deepEqual(fixedBoxes, Array.from({ length: count }, (_, index) => ({ x: 19 + index * 108, width: 86 })));+ }+});+++test('eight participants fit the automatic 920px canvas with default and explicit spread', () => {+ const doc = {+ schema_version: 1, diagram_type: 'sequence', meta: { title: 'Eight participants' },+ participants: Array.from({ length: 8 }, (_, index) => ({ id: `p${index}`, type: 'backend', label: `P${index}` })),+ messages: [{ from: 'p0', to: 'p7', y: 200, label: 'request' }],+ };+ const original = structuredClone(doc);+ const html = render(doc, true);+ const boxes = participantBoxes(html);+ assert.equal(boxes.length, 8);+ assert.equal(boxes[0].x, 62);+ assert.equal(boxes.at(-1).x + boxes.at(-1).width, 880);+ for (let i = 1; i < boxes.length; i++) assert.ok(boxes[i].x - boxes[i - 1].x - boxes[i - 1].width >= 16);+ assert.match(html, /viewBox="0 0 920 760"/);+ assert.deepEqual(doc, original);+ assert.equal(html, render({ ...doc, meta: { ...doc.meta, column_fit: 'spread' } }, true));+ const fixedBoxes = participantBoxes(render({ ...doc, meta: { ...doc.meta, column_fit: 'fixed' } }, true));+ assert.deepEqual(fixedBoxes, Array.from({ length: 8 }, (_, index) => ({ x: 19 + index * 108, width: 86 })));+});+ // The Viewer fit declaration is independent of fixed/spread column geometry.+ test('automatic sequence declares width-first fit; authored viewBox does not', () => {+ for (const columnFit of [undefined, 'fixed', 'spread']) {+ const doc = wideSequence(columnFit);+ delete doc.meta.viewBox;+ const root = render(doc).match(/<svg\b[^>]*>/)?.[0];+ assert.match(root, /data-reader-fit="width-first"/);- assert.match(root, new RegExp(`data-sequence-column-fit="${columnFit || 'fixed'}"`));++ assert.match(root, new RegExp(`data-sequence-column-fit="${columnFit || 'spread'}"`));+ const authoredRoot = render(wideSequence(columnFit)).match(/<svg\b[^>]*>/)?.[0];+ assert.doesNotMatch(authoredRoot, /data-reader-fit=/);+ }+ });