The design language that makes your AI harness better at design.
JavaScript
fix(live): wrap shape-of-output bugs from second Bugbot review
Paul Bakaus8660d3aa22dd
diff --git a/.agents/skills/impeccable/scripts/live-wrap.mjs b/.agents/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.agents/skills/impeccable/scripts/live-wrap.mjs+++ b/.agents/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.claude/skills/impeccable/scripts/live-wrap.mjs b/.claude/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.claude/skills/impeccable/scripts/live-wrap.mjs+++ b/.claude/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.cursor/skills/impeccable/scripts/live-wrap.mjs b/.cursor/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.cursor/skills/impeccable/scripts/live-wrap.mjs+++ b/.cursor/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.gemini/skills/impeccable/scripts/live-wrap.mjs b/.gemini/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.gemini/skills/impeccable/scripts/live-wrap.mjs+++ b/.gemini/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.github/skills/impeccable/scripts/live-wrap.mjs b/.github/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.github/skills/impeccable/scripts/live-wrap.mjs+++ b/.github/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.kiro/skills/impeccable/scripts/live-wrap.mjs b/.kiro/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.kiro/skills/impeccable/scripts/live-wrap.mjs+++ b/.kiro/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.opencode/skills/impeccable/scripts/live-wrap.mjs b/.opencode/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.opencode/skills/impeccable/scripts/live-wrap.mjs+++ b/.opencode/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.pi/skills/impeccable/scripts/live-wrap.mjs b/.pi/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.pi/skills/impeccable/scripts/live-wrap.mjs+++ b/.pi/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.rovodev/skills/impeccable/scripts/live-wrap.mjs b/.rovodev/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.rovodev/skills/impeccable/scripts/live-wrap.mjs+++ b/.rovodev/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.trae-cn/skills/impeccable/scripts/live-wrap.mjs b/.trae-cn/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.trae-cn/skills/impeccable/scripts/live-wrap.mjs+++ b/.trae-cn/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/.trae/skills/impeccable/scripts/live-wrap.mjs b/.trae/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/.trae/skills/impeccable/scripts/live-wrap.mjs+++ b/.trae/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/plugin/skills/impeccable/scripts/live-wrap.mjs b/plugin/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/plugin/skills/impeccable/scripts/live-wrap.mjs+++ b/plugin/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/source/skills/impeccable/scripts/live-wrap.mjs b/source/skills/impeccable/scripts/live-wrap.mjsindex 2baca58ea..a5769a50a 100644--- a/source/skills/impeccable/scripts/live-wrap.mjs+++ b/source/skills/impeccable/scripts/live-wrap.mjs@@ -261,7 +261,12 @@ The agent should insert variant HTML at insertLine.`);console.log(JSON.stringify({file: path.relative(process.cwd(), targetFile),startLine: startLine + 1, // 1-indexed for the agent- endLine: startLine + wrapperLines.length, // 1-indexed+ // wrapperLines is an array but one element (the original-content slot)+ // is a `\n`-joined multi-line string, so the actual file-row count is+ // wrapperLines.length + (originalLines.length - 1). Without the offset,+ // endLine pointed inside the wrapper for any picked element that+ // spanned more than one source line.+ endLine: startLine + wrapperLines.length + (originalLines.length - 1), // 1-indexedinsertLine: insertLine + 1, // 1-indexed: where variants gocommentSyntax: commentSyntax,originalLineCount: originalLines.length,@@ -480,7 +485,12 @@ function findAllElements(lines, query, tag = null) {*/function filterByText(candidates, lines, text) {const trimmed = text.replace(/\s+/g, ' ').trim().toLowerCase().slice(0, 80);- if (trimmed.length < 8) return candidates.slice();+ // Too short to disambiguate. Return [] so the caller's `filtered.length+ // === 0` branch fires (fall back to first-match) — the previous+ // `candidates.slice()` return forced `filtered.length > 1` and surfaced+ // a spurious `element_ambiguous` error on every short-text picker event+ // with multiple candidates.+ if (trimmed.length < 8) return [];const targetSpaced = trimmed;const targetCompact = trimmed.replace(/\s+/g, '');diff --git a/tests/live-wrap.test.mjs b/tests/live-wrap.test.mjsindex 11432fc43..70b6eed18 100644--- a/tests/live-wrap.test.mjs+++ b/tests/live-wrap.test.mjs@@ -577,6 +577,71 @@ describe('live-wrap — JSX / TSX correctness', () => {assert.ok(!inside.includes('Hero Three'), 'did not wrap Hero Three');});+ it('short --text falls back to first-match instead of erroneously firing element_ambiguous', () => {+ // Cursor Bugbot regression: filterByText returned `candidates.slice()`+ // (all candidates) when the trimmed snippet was shorter than 8 chars.+ // The caller treats `filtered.length > 1` as ambiguous — so a short+ // textContent on a page with multiple matching siblings produced a+ // spurious `element_ambiguous` error instead of just landing on the+ // first match (the documented short-text fallback).+ const tsx = `export default function Page() {+ return (+ <main>+ <aside className="card"><h1 className="hero-title">Hi</h1></aside>+ <aside className="card"><h1 className="hero-title">Hi</h1></aside>+ </main>+ );+}`;+ writeFileSync(join(tmp, 'Short.tsx'), tsx);++ // Picked element's textContent is 'Hi' — only 2 chars. With multiple+ // matching siblings the prior bug fired element_ambiguous; the fix+ // makes wrap silently land on the first match (existing behavior+ // documented in filterByText's JSDoc).+ execSync(+ `node source/skills/impeccable/scripts/live-wrap.mjs --id short1 --count 3 --classes "card" --tag "aside" --text "Hi" --file "${join(tmp, 'Short.tsx')}"`,+ { cwd: process.cwd(), encoding: 'utf-8' }+ );++ const modified = readFileSync(join(tmp, 'Short.tsx'), 'utf-8');+ assert.ok(modified.includes('data-impeccable-variants="short1"'),+ 'short --text should still wrap (fallback to first-match), not fail with element_ambiguous');+ });++ it('returns endLine that includes the multi-line original content offset', () => {+ // Cursor Bugbot regression: the `endLine` field was computed as+ // `startLine + wrapperLines.length`, but `wrapperLines` is an array+ // where one element (originalIndented) is a `\n`-joined multi-line+ // string. For multi-line picked elements, the actual wrapper region+ // in the file spans (wrapperLines.length + originalLines.length - 1)+ // rows. Reporting too-small endLine misled agents writing variants+ // about the wrapper boundary.+ const html = `<main>+ <section class="multiline-target">+ <h1>Multi</h1>+ <p>Line</p>+ <span>Element</span>+ </section>+</main>`;+ writeFileSync(join(tmp, 'multi.html'), html);++ const result = JSON.parse(execSync(+ `node source/skills/impeccable/scripts/live-wrap.mjs --id ml1 --count 3 --classes "multiline-target" --tag "section" --file "${join(tmp, 'multi.html')}"`,+ { cwd: process.cwd(), encoding: 'utf-8' }+ ));++ const modified = readFileSync(join(tmp, 'multi.html'), 'utf-8');+ const lines = modified.split('\n');+ // endLine is 1-indexed; lines[endLine - 1] should be the wrapper's last+ // line (the impeccable-variants-end marker for HTML).+ assert.match(lines[result.endLine - 1], /impeccable-variants-end ml1/,+ `endLine ${result.endLine} should point at the variants-end marker line. Got: ${JSON.stringify(lines[result.endLine - 1])}`);+ // And the line after the reported endLine should be `</main>` — proving+ // the entire wrapper was accounted for (no rows missing).+ assert.match(lines[result.endLine], /<\/main>/,+ `line after endLine should be </main>; got: ${JSON.stringify(lines[result.endLine])}`);+ });+it('falls back to first-match when --text is not literally present in source (e.g. {title})', () => {// textContent the browser sends is the rendered text, but the source uses// a JSX expression. No candidate's source body contains the literal