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(diagnostics): ignore non-element markup in node ownership scan
tt-a1i20b74c41a99d
diff --cc archify.zipindex 6cc9c939,a44866db..b19ade57Binary files differdiff --cc archify/scripts/check-render-output.mjsindex b46a60e5,f7149687..43f9a407--- a/archify/scripts/check-render-output.mjs+++ b/archify/scripts/check-render-output.mjs@@@ -626,18 -652,7 +653,20 @@@ function collectDesktopReadability(svgAif (!Number.isFinite(viewBoxWidth) || viewBoxWidth <= 0) return null;const scale = Math.min(1, DESKTOP_READER_DIAGRAM_WIDTH / viewBoxWidth);let worst = null;- for (const match of fragment.matchAll(/<text\b([^>]*)>([\s\S]*?)<\/text>/gi)) {+ const nodeOwners = [];+ // Walk groups alongside text so nested decoration retains the owning node,+ // without leaking that identity into a following boundary or loose label.- for (const match of fragment.matchAll(/<text\b([^>]*)>([\s\S]*?)<\/text>|<g\b[^>]*>|<\/g\s*>/gi)) {++ for (const match of fragment.matchAll(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<text\b([^>]*)>([\s\S]*?)<\/text>|<g\b[^>]*>|<\/g\s*>/gi)) {++ // Comment and CDATA contents cannot open or close a real SVG group.++ if (match[0].startsWith('<!')) continue;+ if (match[1] === undefined) {+ if (/^<\/g/i.test(match[0])) nodeOwners.pop();+ else if (!/\/\s*>$/.test(match[0])) {+ const attrs = parseAttrs(match[0]);+ nodeOwners.push(attrs['data-node-id'] || nodeOwners.at(-1));+ }+ continue;+ }const primary = /\bdata-node-label(?:\s*=|\s|$)/i.test(match[1]);const boundary = /\bdata-boundary-label(?:\s*=|\s|$)/i.test(match[1]);const context = /\bdata-detail\s*=\s*"context"/i.test(match[1]);diff --cc archify/test/render-output-checks.test.mjsindex 34ec248b,7b02ba37..31e3a4ad--- a/archify/test/render-output-checks.test.mjs+++ b/archify/test/render-output-checks.test.mjs@@@ -434,14 -434,155 +434,183 @@@ test('render output check: endpoint stuprocess.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));+test('readability node ownership survives nested groups and does not leak after closing', () => {+ const nested = checkHtml('nested-owner', `+ <g data-node-id="outer"><g/><g><text data-detail="context" font-size="7">Repeated</text></g></g>+ `, 'showcase', '0 0 1200 400');+ assert.equal(nested.result.composition.issues[0].nodeId, 'outer');+ const loose = checkHtml('closed-owner', `+ <g data-node-id="outer"><g><text data-node-label font-size="12">Readable</text></g></g>+ <text data-boundary-label font-size="7">Repeated</text>+ `, 'showcase', '0 0 1200 400');+ assert.equal(loose.result.composition.issues[0].nodeId, undefined);+});+++ for (const position of ['before', 'after']) {+ test(`render output check: finite_svg ignores HTML numeric attributes ${position} SVG`, () => {+ const htmlPath = path.join(tmp, `finite-html-${position}.html`);+ const html = '<div x="NaN" width="Infinity"><input width="NaN"><br></div>';+ const svg = '<svg viewBox="0 0 240 160"><rect x="10" y="10" width="20" height="20"/></svg>';+ fs.writeFileSync(htmlPath, `<!doctype html><html><body>${position === 'before' ? html + svg : svg + html}</body></html>`);+ const result = JSON.parse(execFileSync('node', [checker, htmlPath], { encoding: 'utf8' }));+ const check = result.checks.find(item => item.name === 'finite_svg');+ assert.equal(check.ok, true);+ assert.deepEqual(check.details, []);+ });+ }++ test('render output check: finite_svg ignores comments and CDATA but still checks real elements', () => {+ const { result } = checkHtml('finite-non-elements', `+ <!-- <rect x="NaN"/> -->+ <![CDATA[<path d="Infinity"/>]]>+ <rect x="12" y="20" width="50" height="40"/>+ <circle cx="NaN" cy="20" r="5"/>+ `);+ const check = result.checks.find(item => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, ['circle cx="NaN"']);+ });++ test('render output check: finite_svg decodes numeric references once and reports raw evidence', () => {+ const { result } = checkHtml('finite-encoded-values', `+ <rect x="NaN" y="Infinity"/>+ <circle cx="ӪN" cy="&#78;aN" r="10"/>+ <path d="M 0 0 L NaN 12"/>+ <text x="10" y="10" data-note="NaN">NaN</text>+ `);+ const check = result.checks.find(item => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, [+ 'rect x="NaN"',+ 'rect y="Infinity"',+ 'path d="M 0 0 L NaN 12"',+ ]);+ });++ test('render output check: finite_svg separates foreignObject HTML from SVG geometry', () => {+ const { result } = checkHtml('finite-foreign-object', `+ <foreignObject x="NaN" y="0" width="100" height="100">+ <div xmlns="http://www.w3.org/1999/xhtml" x="NaN" width="Infinity">+ <input width="NaN"><br><div y="Infinity">HTML content</div>+ </div>+ </foreignObject>+ <rect x="Infinity"/>+ `);+ const check = result.checks.find(item => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, ['foreignObject x="NaN"', 'rect x="Infinity"']);+ const nested = checkHtml('finite-foreign-nested-svg', `+ <foreignObject><div x="NaN"><svg><rect x="NaN"/></svg></div></foreignObject>+ `).result.checks.find(item => item.name === 'finite_svg');+ assert.deepEqual(nested.details, ['rect x="NaN"']);+ });++ test('render output check: finite_svg ignores prose that mentions NaN or Infinity', () => {+ const { result } = checkHtml('finite-prose', `+ <g data-node-id="solver" data-node-tag="returns a NaN leaf" aria-label="Focus Solver">+ <title>Solver · returns a NaN leaf · Infinity guard</title>+ <rect x="40" y="40" width="200" height="74" rx="6" class="c-mask"/>+ <text x="140" y="70" class="t-primary" font-size="11" text-anchor="middle">Solver</text>+ <text data-detail="fine" x="140" y="106" class="t-backend" font-size="7">returns a NaN leaf</text>+ </g>+ <!-- Legend -->+ <text x="40" y="140" class="t-primary" font-size="10">Legend</text>+ `);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, true);+ assert.deepEqual(check.details, []);+ });++ test('render output check: finite_svg reports the attribute carrying a non-finite value', () => {+ const { code, result } = checkHtml('finite-attr', `+ <rect x="NaN" y="40" width="200" height="74" rx="6" class="c-mask"/>+ <path d="M 20 20 L undefined 20" class="a-default" stroke-width="1.4"/>+ <text x="140" y="Infinity" class="t-primary" font-size="11">Solver</text>+ <!-- Legend -->+ <text x="40" y="140" class="t-primary" font-size="10">Legend</text>+ `);+ assert.notEqual(code, 0);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, [+ 'rect x="NaN"',+ 'path d="M 20 20 L undefined 20"',+ 'text y="Infinity"',+ ]);+ });++ test('render output check: finite_svg parses quoted angle brackets and HTML attribute quoting', () => {+ const { code, result } = checkHtml('finite-attr-syntax', `+ <rect aria-label="greater > lesser" x="NaN" y="40" width="200" height="74"/>+ <circle cx='Infinity' cy='40' r='6'/>+ <line x1=undefined y1=10 x2=20 y2=10/>+ `);+ assert.notEqual(code, 0);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, [+ 'rect x="NaN"',+ 'circle cx="Infinity"',+ 'line x1="undefined"',+ ]);+ });++ test('render output check: finite_svg covers extended SVG numeric attributes', () => {+ const { code, result } = checkHtml('finite-extended-attrs', `+ <path d="M 0 0 L 10 0" pathLength="NaN"/>+ <radialGradient fr="-Infinity"/>+ <feGaussianBlur stdDeviation="undefined"/>+ `);+ assert.notEqual(code, 0);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, [+ 'path pathLength="NaN"',+ 'radialGradient fr="-Infinity"',+ 'feGaussianBlur stdDeviation="undefined"',+ ]);+ });++ test('render output check: finite_svg covers element-specific filter numeric attributes', () => {+ const { code, result } = checkHtml('finite-element-specific-filter-attrs', `+ <filter id="lighting">+ <feDiffuseLighting><fePointLight x="10" y="10" z="NaN"/></feDiffuseLighting>+ <feSpecularLighting><feSpotLight x="10" y="10" z="-Infinity"/></feSpecularLighting>+ <feColorMatrix type="saturate" values="undefined"/>+ </filter>+ `);+ assert.notEqual(code, 0);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, false);+ assert.deepEqual(check.details, [+ 'fePointLight z="NaN"',+ 'feSpotLight z="-Infinity"',+ 'feColorMatrix values="undefined"',+ ]);+ });++ test('render output check: finite_svg keeps context-sensitive values attributes scoped', () => {+ const { code, result } = checkHtml('finite-context-sensitive-values', `+ <animate attributeName="data-node-tag" values="NaN;Infinity" dur="1s"/>+ `);+ assert.equal(code, 0);+ const check = result.checks.find((item) => item.name === 'finite_svg');+ assert.equal(check.ok, true);+ assert.deepEqual(check.details, []);+ });++++for (const [name, markup] of [++ ['comment-open', '<!-- <g data-node-id="other"> -->'],++ ['comment-close', '<!-- </g> -->'],++ ['cdata', '<![CDATA[<g data-node-id="other"></g></g>]]>'],++]) {++ test(`readability node ownership ignores ${name}`, () => {++ const { result } = checkHtml(`owner-${name}`, `++ <g data-node-id="actual">${markup}<text data-detail="context" font-size="7">Repeated</text></g>++ `, 'showcase', '0 0 1200 400');++ const issue = result.composition.issues.find(item => item.code === 'composition/desktop-readability');++ assert.equal(issue.nodeId, 'actual');++ assert.equal(issue.text, 'Repeated');++ assert.equal(issue.projectedFontPx, 5.425);++ });++}