@heyhuynhgiabuu/pi-diff 0.5.5 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Cascading text replacement engine for LLM edit tools.
3
+ *
4
+ * When an LLM calls the edit tool with oldString + newString, the oldString
5
+ * often doesn't match exactly due to:
6
+ * - Whitespace differences (indentation, trailing spaces)
7
+ * - Escape sequences (LLMs escaping \n, \t, quotes in tool call params)
8
+ * - Minor formatting drift (tabs vs spaces, trimmed lines)
9
+ *
10
+ * This module provides a cascade of replacer strategies, each progressively
11
+ * more lenient. The first strategy that finds exactly one match wins.
12
+ * If multiple candidates exist for a fuzzy strategy, we reject (safety first).
13
+ *
14
+ * Design inspired by OpenCode's edit tool (anomalyco/opencode) and
15
+ * Cline's diff-apply evals, but restructured for independent use.
16
+ */
17
+ export interface ReplaceResult {
18
+ /** The resulting content after replacement (unchanged if no match). */
19
+ content: string;
20
+ /** Whether a replacement was made. */
21
+ changed: boolean;
22
+ /** Name of the replacer strategy that matched, or "none". */
23
+ strategy: string;
24
+ /** Number of occurrences replaced (only when changed=true). */
25
+ count: number;
26
+ }
27
+ /**
28
+ * Replace oldString with newString in content using a cascade of matching
29
+ * strategies. Tries exact match first, then progressively relaxes matching
30
+ * rules. If no strategy finds a match, returns unchanged content.
31
+ *
32
+ * Safety: if a fuzzy strategy finds multiple candidates, it is skipped
33
+ * (we never auto-pick among ambiguous matches). Only exact matches
34
+ * (SimpleReplacer) are allowed to match multiple occurrences, and only
35
+ * when replaceAll=true.
36
+ *
37
+ * @param content - The full file content to edit.
38
+ * @param oldString - The text to find and replace.
39
+ * @param newString - The replacement text.
40
+ * @param options.replaceAll - When true, replace ALL non-overlapping
41
+ * occurrences. Only safe for exact matches (simple replacer).
42
+ * @returns ReplaceResult with the new content and match strategy info.
43
+ */
44
+ export declare function replace(content: string, oldString: string, newString: string, options?: {
45
+ replaceAll?: boolean;
46
+ }): ReplaceResult;
47
+ //# sourceMappingURL=replace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/core/replace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,WAAW,aAAa;IAC7B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;CACd;AAwZD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,aAAa,CAqFf"}
@@ -0,0 +1,496 @@
1
+ /**
2
+ * Cascading text replacement engine for LLM edit tools.
3
+ *
4
+ * When an LLM calls the edit tool with oldString + newString, the oldString
5
+ * often doesn't match exactly due to:
6
+ * - Whitespace differences (indentation, trailing spaces)
7
+ * - Escape sequences (LLMs escaping \n, \t, quotes in tool call params)
8
+ * - Minor formatting drift (tabs vs spaces, trimmed lines)
9
+ *
10
+ * This module provides a cascade of replacer strategies, each progressively
11
+ * more lenient. The first strategy that finds exactly one match wins.
12
+ * If multiple candidates exist for a fuzzy strategy, we reject (safety first).
13
+ *
14
+ * Design inspired by OpenCode's edit tool (anomalyco/opencode) and
15
+ * Cline's diff-apply evals, but restructured for independent use.
16
+ */
17
+ // ---------------------------------------------------------------------------
18
+ // Helpers
19
+ // ---------------------------------------------------------------------------
20
+ function countOccurrences(content, substring) {
21
+ if (substring.length === 0)
22
+ return 0;
23
+ let count = 0;
24
+ let pos = 0;
25
+ while (true) {
26
+ pos = content.indexOf(substring, pos);
27
+ if (pos === -1)
28
+ break;
29
+ count++;
30
+ pos += substring.length;
31
+ }
32
+ return count;
33
+ }
34
+ /** Levenshtein distance for block anchor similarity comparison. */
35
+ function levenshtein(a, b) {
36
+ if (a === "" || b === "")
37
+ return Math.max(a.length, b.length);
38
+ const matrix = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)));
39
+ for (let i = 1; i <= a.length; i++) {
40
+ for (let j = 1; j <= b.length; j++) {
41
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
42
+ matrix[i][j] = Math.min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j - 1] + cost);
43
+ }
44
+ }
45
+ return matrix[a.length][b.length];
46
+ }
47
+ // ---------------------------------------------------------------------------
48
+ // Replacers (in priority order)
49
+ // ---------------------------------------------------------------------------
50
+ /**
51
+ * 1. Simple exact match.
52
+ */
53
+ const SimpleReplacer = function* (content, find) {
54
+ if (content.includes(find))
55
+ yield find;
56
+ };
57
+ /**
58
+ * 2. Escape-normalized match — unescapes common escape sequences
59
+ * in the find string before matching. Handles LLMs that escape
60
+ * tool call parameters (\\n, \\t, \\", etc.).
61
+ *
62
+ * Runs early (after Simple) so unescaped content flows through
63
+ * line-level strategies (LineTrimmed, BlockAnchor) correctly.
64
+ * Inspired by OpenCode's EscapeNormalizedReplacer.
65
+ */
66
+ const EscapeNormalizedReplacer = function* (content, find) {
67
+ const unescapeStr = (str) => {
68
+ return str.replace(/\\([nrt'"`\\$])/g, (_match, char) => {
69
+ switch (char) {
70
+ case "n":
71
+ return "\n";
72
+ case "t":
73
+ return "\t";
74
+ case "r":
75
+ return "\r";
76
+ case "'":
77
+ return "'";
78
+ case '"':
79
+ return '"';
80
+ case "`":
81
+ return "`";
82
+ case "\\":
83
+ return "\\";
84
+ case "$":
85
+ return "$";
86
+ default:
87
+ return char;
88
+ }
89
+ });
90
+ };
91
+ const unescaped = unescapeStr(find);
92
+ if (unescaped === find)
93
+ return; // nothing was escaped, skip
94
+ if (unescaped.length === 0)
95
+ return;
96
+ // Yield the unescaped string if found directly in content
97
+ if (content.includes(unescaped)) {
98
+ yield unescaped;
99
+ return;
100
+ }
101
+ // Fallback: find matching blocks in content
102
+ const contentLines = content.split("\n");
103
+ const findLines = unescaped.split("\n");
104
+ for (let i = 0; i <= contentLines.length - findLines.length; i++) {
105
+ const block = contentLines.slice(i, i + findLines.length).join("\n");
106
+ if (block === unescaped || block.trim() === unescaped.trim()) {
107
+ yield block;
108
+ return;
109
+ }
110
+ }
111
+ };
112
+ /**
113
+ * 3. Line-trimmed match — compares lines after trimming whitespace.
114
+ * Handles cases where indentation or trailing whitespace differs.
115
+ */
116
+ const LineTrimmedReplacer = function* (content, find) {
117
+ const contentLines = content.split("\n");
118
+ const findLines = find.split("\n");
119
+ // Remove trailing empty line from find if present
120
+ if (findLines.length > 1 && findLines[findLines.length - 1] === "") {
121
+ findLines.pop();
122
+ }
123
+ if (findLines.length > contentLines.length)
124
+ return;
125
+ for (let i = 0; i <= contentLines.length - findLines.length; i++) {
126
+ let matches = true;
127
+ for (let j = 0; j < findLines.length; j++) {
128
+ if (contentLines[i + j].trim() !== findLines[j].trim()) {
129
+ matches = false;
130
+ break;
131
+ }
132
+ }
133
+ if (matches) {
134
+ // Compute the actual substring in the original content
135
+ let startPos = 0;
136
+ for (let k = 0; k < i; k++) {
137
+ startPos += contentLines[k].length + 1;
138
+ }
139
+ let endPos = startPos;
140
+ for (let k = 0; k < findLines.length; k++) {
141
+ endPos += contentLines[i + k].length;
142
+ if (k < findLines.length - 1)
143
+ endPos += 1;
144
+ }
145
+ yield content.slice(startPos, endPos);
146
+ }
147
+ }
148
+ };
149
+ /**
150
+ * 4. Block anchor match — uses first and last lines as anchors,
151
+ * then compares middle lines with Levenshtein similarity.
152
+ * Requires at least 3 lines in the find string.
153
+ *
154
+ * Dual threshold: single candidates get a lower bar (anchors alone
155
+ * are strong evidence), multiple candidates need higher similarity
156
+ * to disambiguate. Inspired by OpenCode's BlockAnchorReplacer.
157
+ */
158
+ const BlockAnchorReplacer = function* (content, find) {
159
+ const contentLines = content.split("\n");
160
+ const findLines = find.split("\n");
161
+ // Need at least 3 lines for meaningful anchor matching
162
+ if (findLines.length < 3)
163
+ return;
164
+ if (findLines[findLines.length - 1] === "")
165
+ findLines.pop();
166
+ if (findLines.length < 3)
167
+ return;
168
+ const firstAnchor = findLines[0].trim();
169
+ const lastAnchor = findLines[findLines.length - 1].trim();
170
+ const searchBlockSize = findLines.length;
171
+ const SINGLE_CANDIDATE_THRESHOLD = 0.25;
172
+ const MULTIPLE_CANDIDATES_THRESHOLD = 0.4;
173
+ // Collect candidate positions where both anchors match
174
+ const candidates = [];
175
+ for (let i = 0; i < contentLines.length; i++) {
176
+ if (contentLines[i].trim() !== firstAnchor)
177
+ continue;
178
+ // Look for matching last line after this first line
179
+ for (let j = i + 2; j < contentLines.length; j++) {
180
+ if (contentLines[j].trim() === lastAnchor) {
181
+ candidates.push({ startLine: i, endLine: j });
182
+ break;
183
+ }
184
+ }
185
+ }
186
+ if (candidates.length === 0)
187
+ return;
188
+ // Score each candidate by Levenshtein similarity
189
+ // Single candidate: relaxed threshold (anchors provide strong signal)
190
+ // Multiple candidates: require higher similarity to disambiguate
191
+ const isSingleCandidate = candidates.length === 1;
192
+ const threshold = isSingleCandidate ? SINGLE_CANDIDATE_THRESHOLD : MULTIPLE_CANDIDATES_THRESHOLD;
193
+ if (isSingleCandidate) {
194
+ const { startLine, endLine } = candidates[0];
195
+ const actualBlockSize = endLine - startLine + 1;
196
+ const middleCount = Math.min(searchBlockSize - 2, actualBlockSize - 2);
197
+ let similarity = 0;
198
+ if (middleCount > 0) {
199
+ for (let j = 1; j <= middleCount; j++) {
200
+ const originalLine = contentLines[startLine + j].trim();
201
+ const searchLine = findLines[j].trim();
202
+ const maxLen = Math.max(originalLine.length, searchLine.length);
203
+ if (maxLen === 0)
204
+ continue;
205
+ const distance = levenshtein(originalLine, searchLine);
206
+ similarity += 1 - distance / maxLen;
207
+ }
208
+ similarity /= middleCount;
209
+ }
210
+ else {
211
+ // No middle lines — anchors alone suffice
212
+ similarity = 1;
213
+ }
214
+ if (similarity >= threshold) {
215
+ let startPos = 0;
216
+ for (let k = 0; k < startLine; k++)
217
+ startPos += contentLines[k].length + 1;
218
+ let endPos = startPos;
219
+ for (let k = startLine; k <= endLine; k++) {
220
+ endPos += contentLines[k].length;
221
+ if (k < endLine)
222
+ endPos += 1;
223
+ }
224
+ yield content.slice(startPos, endPos);
225
+ }
226
+ return;
227
+ }
228
+ // Multiple candidates: pick best match above higher threshold
229
+ let bestMatch = null;
230
+ let bestSimilarity = -1;
231
+ for (const candidate of candidates) {
232
+ const { startLine, endLine } = candidate;
233
+ const actualBlockSize = endLine - startLine + 1;
234
+ const middleCount = Math.min(searchBlockSize - 2, actualBlockSize - 2);
235
+ let similarity = 0;
236
+ if (middleCount > 0) {
237
+ for (let j = 1; j <= middleCount; j++) {
238
+ const originalLine = contentLines[startLine + j].trim();
239
+ const searchLine = findLines[j].trim();
240
+ const maxLen = Math.max(originalLine.length, searchLine.length);
241
+ if (maxLen === 0)
242
+ continue;
243
+ const distance = levenshtein(originalLine, searchLine);
244
+ similarity += 1 - distance / maxLen;
245
+ }
246
+ similarity /= middleCount;
247
+ }
248
+ else {
249
+ similarity = 1;
250
+ }
251
+ if (similarity > bestSimilarity) {
252
+ bestSimilarity = similarity;
253
+ bestMatch = candidate;
254
+ }
255
+ }
256
+ if (!bestMatch || bestSimilarity < threshold)
257
+ return;
258
+ // Yield the actual content substring
259
+ const { startLine, endLine } = bestMatch;
260
+ let startPos = 0;
261
+ for (let k = 0; k < startLine; k++) {
262
+ startPos += contentLines[k].length + 1;
263
+ }
264
+ let endPos = startPos;
265
+ for (let k = startLine; k <= endLine; k++) {
266
+ endPos += contentLines[k].length;
267
+ if (k < endLine)
268
+ endPos += 1;
269
+ }
270
+ yield content.slice(startPos, endPos);
271
+ };
272
+ /**
273
+ * 5. Whitespace-normalized match — collapses all whitespace runs
274
+ * to single spaces and trims. Handles any whitespace differences.
275
+ */
276
+ const WhitespaceNormalizedReplacer = function* (content, find) {
277
+ const normalize = (text) => text.replace(/\s+/g, " ").trim();
278
+ const normalizedFind = normalize(find);
279
+ if (normalizedFind.length === 0)
280
+ return;
281
+ const contentLines = content.split("\n");
282
+ const findLines = find.split("\n");
283
+ // Single-line: find by normalized line content
284
+ if (findLines.length <= 1 || (findLines.length === 2 && findLines[1] === "")) {
285
+ for (let i = 0; i < contentLines.length; i++) {
286
+ if (normalize(contentLines[i]) === normalizedFind) {
287
+ yield contentLines[i];
288
+ }
289
+ }
290
+ return;
291
+ }
292
+ // Multi-line: find blocks where normalized content matches
293
+ const effectiveFindLines = findLines[findLines.length - 1] === "" ? findLines.slice(0, -1) : findLines;
294
+ for (let i = 0; i <= contentLines.length - effectiveFindLines.length; i++) {
295
+ const block = contentLines.slice(i, i + effectiveFindLines.length);
296
+ if (normalize(block.join("\n")) === normalizedFind) {
297
+ yield block.join("\n");
298
+ }
299
+ }
300
+ };
301
+ /**
302
+ * 6. Indentation-flexible match — strips common leading indentation
303
+ * before comparing. Handles blocks that shifted indent level.
304
+ * NOTE: Excluded from the REPLACERS cascade — LineTrimmedReplacer's
305
+ * per-line trim() is a superset. Kept here as documentation artifact.
306
+ */
307
+ const IndentationFlexibleReplacer = function* (content, find) {
308
+ const removeIndent = (text) => {
309
+ const lines = text.split("\n");
310
+ const nonEmpty = lines.filter((l) => l.trim().length > 0);
311
+ if (nonEmpty.length === 0)
312
+ return text;
313
+ const minIndent = Math.min(...nonEmpty.map((l) => {
314
+ const m = l.match(/^(\s*)/);
315
+ return m ? m[1].length : 0;
316
+ }));
317
+ return lines.map((l) => (l.trim().length === 0 ? l : l.slice(minIndent))).join("\n");
318
+ };
319
+ const normalizedFind = removeIndent(find);
320
+ if (normalizedFind.length === 0)
321
+ return;
322
+ const contentLines = content.split("\n");
323
+ const findLines = find.split("\n");
324
+ const effectiveFindLines = findLines[findLines.length - 1] === "" ? findLines.slice(0, -1) : findLines;
325
+ for (let i = 0; i <= contentLines.length - effectiveFindLines.length; i++) {
326
+ const block = contentLines.slice(i, i + effectiveFindLines.length).join("\n");
327
+ if (removeIndent(block) === normalizedFind) {
328
+ yield block;
329
+ }
330
+ }
331
+ };
332
+ /**
333
+ * 7. Trimmed-boundary match — trims leading/trailing whitespace
334
+ * from the find string before matching. Handles accidental
335
+ * whitespace at boundaries.
336
+ */
337
+ const TrimmedBoundaryReplacer = function* (content, find) {
338
+ const trimmed = find.trim();
339
+ if (trimmed === find || trimmed.length === 0)
340
+ return;
341
+ if (content.includes(trimmed)) {
342
+ yield trimmed;
343
+ return;
344
+ }
345
+ // Fallback: find blocks where the trimmed version matches
346
+ const contentLines = content.split("\n");
347
+ const findLines = find.split("\n");
348
+ for (let i = 0; i <= contentLines.length - findLines.length; i++) {
349
+ const block = contentLines.slice(i, i + findLines.length).join("\n");
350
+ if (block.trim() === trimmed) {
351
+ yield block;
352
+ return;
353
+ }
354
+ }
355
+ };
356
+ /**
357
+ * 8. Multi-occurrence replacer — yields ALL exact matches.
358
+ * NOTE: Excluded from the REPLACERS cascade because replaceAll is
359
+ * handled directly in the public `replace()` fast path for exact
360
+ * matches. Fuzzy-strategy replaceAll would be unsafe (ambiguous).
361
+ * Kept here as documentation artifact.
362
+ */
363
+ const MultiOccurrenceReplacer = function* (content, find) {
364
+ if (find.length === 0)
365
+ return;
366
+ let pos = 0;
367
+ while (true) {
368
+ const idx = content.indexOf(find, pos);
369
+ if (idx === -1)
370
+ break;
371
+ yield find;
372
+ pos = idx + find.length;
373
+ }
374
+ };
375
+ /**
376
+ * 9. Context-aware match — uses first and last lines as context
377
+ * anchors, then checks trimmed-line similarity (50%) for middle
378
+ * lines. Simpler than BlockAnchor (no Levenshtein).
379
+ * NOTE: Excluded from the REPLACERS cascade — BlockAnchorReplacer's
380
+ * Levenshtein-based scoring subsumes this. Kept as documentation.
381
+ */
382
+ const ContextAwareReplacer = function* (_content, _find) {
383
+ // Reference implementation in OpenCode:
384
+ // https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/tool/edit.ts
385
+ };
386
+ // ---------------------------------------------------------------------------
387
+ // All replacers in priority order (active members)
388
+ // ---------------------------------------------------------------------------
389
+ const REPLACERS = [
390
+ SimpleReplacer,
391
+ EscapeNormalizedReplacer,
392
+ LineTrimmedReplacer,
393
+ BlockAnchorReplacer,
394
+ WhitespaceNormalizedReplacer,
395
+ TrimmedBoundaryReplacer,
396
+ ];
397
+ // ---------------------------------------------------------------------------
398
+ // Public API
399
+ // ---------------------------------------------------------------------------
400
+ /**
401
+ * Replace oldString with newString in content using a cascade of matching
402
+ * strategies. Tries exact match first, then progressively relaxes matching
403
+ * rules. If no strategy finds a match, returns unchanged content.
404
+ *
405
+ * Safety: if a fuzzy strategy finds multiple candidates, it is skipped
406
+ * (we never auto-pick among ambiguous matches). Only exact matches
407
+ * (SimpleReplacer) are allowed to match multiple occurrences, and only
408
+ * when replaceAll=true.
409
+ *
410
+ * @param content - The full file content to edit.
411
+ * @param oldString - The text to find and replace.
412
+ * @param newString - The replacement text.
413
+ * @param options.replaceAll - When true, replace ALL non-overlapping
414
+ * occurrences. Only safe for exact matches (simple replacer).
415
+ * @returns ReplaceResult with the new content and match strategy info.
416
+ */
417
+ export function replace(content, oldString, newString, options) {
418
+ if (oldString.length === 0) {
419
+ return { content, changed: false, strategy: "none", count: 0 };
420
+ }
421
+ if (oldString === newString) {
422
+ return { content, changed: false, strategy: "none", count: 0 };
423
+ }
424
+ const replaceAll = options?.replaceAll ?? false;
425
+ // Fast path: simple exact match with replaceAll
426
+ if (replaceAll && content.includes(oldString)) {
427
+ const result = content.replaceAll(oldString, newString);
428
+ if (result !== content) {
429
+ const count = countOccurrences(content, oldString);
430
+ return { content: result, changed: true, strategy: "simple-replaceAll", count };
431
+ }
432
+ }
433
+ // Fast path: single exact match
434
+ if (!replaceAll) {
435
+ const idx = content.indexOf(oldString);
436
+ if (idx !== -1) {
437
+ const lastIdx = content.lastIndexOf(oldString);
438
+ if (idx === lastIdx) {
439
+ // Exactly one occurrence
440
+ const result = content.slice(0, idx) + newString + content.slice(idx + oldString.length);
441
+ return { content: result, changed: true, strategy: "simple", count: 1 };
442
+ }
443
+ // Multiple occurrences — fall through to fuzzy strategies
444
+ // (we never auto-pick among duplicates)
445
+ }
446
+ }
447
+ // Run through each replacer strategy in priority order
448
+ for (const replacer of REPLACERS) {
449
+ // Skip SimpleReplacer — already handled above
450
+ if (replacer === SimpleReplacer)
451
+ continue;
452
+ const candidates = [];
453
+ for (const candidate of replacer(content, oldString)) {
454
+ candidates.push(candidate);
455
+ }
456
+ if (candidates.length === 0)
457
+ continue;
458
+ if (replaceAll) {
459
+ // For replaceAll, use all candidates
460
+ let result = content;
461
+ let totalCount = 0;
462
+ for (const candidate of candidates) {
463
+ const count = countOccurrences(result, candidate);
464
+ if (count > 0) {
465
+ result = result.replaceAll(candidate, newString);
466
+ totalCount += count;
467
+ }
468
+ }
469
+ if (totalCount > 0) {
470
+ const strategyName = replacer.name
471
+ .replace("Replacer", "")
472
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
473
+ .toLowerCase();
474
+ return { content: result, changed: true, strategy: `${strategyName}-replaceAll`, count: totalCount };
475
+ }
476
+ continue;
477
+ }
478
+ // Single replacement: must have exactly one candidate
479
+ if (candidates.length === 1) {
480
+ const candidate = candidates[0];
481
+ const idx = content.indexOf(candidate);
482
+ if (idx !== -1) {
483
+ const result = content.slice(0, idx) + newString + content.slice(idx + candidate.length);
484
+ const strategyName = replacer.name
485
+ .replace("Replacer", "")
486
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
487
+ .toLowerCase();
488
+ return { content: result, changed: true, strategy: strategyName, count: 1 };
489
+ }
490
+ }
491
+ // Multiple candidates — skip this strategy (safety first)
492
+ }
493
+ // No match found
494
+ return { content, changed: false, strategy: "none", count: 0 };
495
+ }
496
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repl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AAC,UAAU,EAAE,EAAE,CAAC;qBACvB,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;qBACnC,WAAW,EAAE,CAAC;gBAChB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC7E,CAAC;QACF,CAAC;QACD,0DAA0D;IAC3D,CAAC;IAED,iBAAiB;IACjB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -20,9 +20,10 @@
20
20
  * • Large-diff fallback (skip highlighting, still show diff)
21
21
  * • Async rendering with invalidate() for non-blocking preview
22
22
  */
23
- import type { BundledLanguage } from "shiki";
24
- import { computeHunkBlocks, type ParsedDiff, getSepStyle, parseDiff, parsePatchFiles, resolveSepStyle } from "./core/diff.js";
25
23
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
24
+ import { codeToANSI } from "@shikijs/cli";
25
+ import { computeHunkBlocks, getSepStyle, type ParsedDiff, parseDiff, parsePatchFiles, resolveSepStyle } from "./core/diff.js";
26
+ type BundledLanguage = Parameters<typeof codeToANSI>[1];
26
27
  /** Resolved ANSI colors for diff rendering — theme overrides hardcoded defaults. */
27
28
  interface DiffColors {
28
29
  fgAdd: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAiB,KAAK,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAkC,MAAM,gBAAgB,CAAC;AAE7K,OAAO,KAAK,EAAE,YAAY,EA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