
























@@ -35,7 +35,7 @@ export function restoreLineEndings(text: string, ending: "\r\n" | "\n"): string
3535 * - Normalize Unicode dashes/hyphens to ASCII hyphen
3636 * - Normalize special Unicode spaces to regular space
3737 */
38-export function normalizeForFuzzyMatch(text: string): string {
38+function normalizeForFuzzyMatch(text: string): string {
3939return (
4040text
4141.normalize("NFKC")
@@ -58,7 +58,7 @@ export function normalizeForFuzzyMatch(text: string): string {
5858);
5959}
606061-export interface FuzzyMatchResult {
61+interface FuzzyMatchResult {
6262/** Whether a match was found */
6363found: boolean;
6464/** The index where the match starts (in the content that should be used for replacement) */
@@ -86,18 +86,13 @@ interface MatchedEdit {
8686newText: string;
8787}
888889-export interface AppliedEditsResult {
90-baseContent: string;
91-newContent: string;
92-}
93-9489/**
9590 * Find oldText in content, trying exact match first, then fuzzy match.
9691 * When fuzzy matching is used, the returned contentForReplacement is the
9792 * fuzzy-normalized version of the content (trailing whitespace stripped,
9893 * Unicode quotes/dashes normalized to ASCII).
9994 */
100-export function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult {
95+function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult {
10196// Try exact match first
10297const exactIndex = content.indexOf(oldText);
10398if (exactIndex !== -1) {
@@ -205,7 +200,7 @@ export function applyEditsToNormalizedContent(
205200normalizedContent: string,
206201edits: Edit[],
207202path: string,
208-): AppliedEditsResult {
203+): { baseContent: string; newContent: string } {
209204const normalizedEdits = edits.map((edit) => ({
210205oldText: normalizeToLF(edit.oldText),
211206newText: normalizeToLF(edit.newText),
@@ -423,11 +418,6 @@ export interface EditDiffError {
423418error: string;
424419}
425420426-export interface EditDiffOperations {
427-readFile: (absolutePath: string) => Promise<Buffer | string>;
428-access: (absolutePath: string) => Promise<void>;
429-}
430-431421/**
432422 * Compute the diff for one or more edit operations without applying them.
433423 * Used for preview rendering in the TUI before the tool executes.
@@ -436,7 +426,10 @@ export async function computeEditsDiff(
436426path: string,
437427edits: Edit[],
438428cwd: string,
439-operations?: EditDiffOperations,
429+operations?: {
430+readFile: (absolutePath: string) => Promise<Buffer | string>;
431+access: (absolutePath: string) => Promise<void>;
432+},
440433): Promise<EditDiffResult | EditDiffError> {
441434const absolutePath = resolveToCwd(path, cwd);
442435@@ -478,16 +471,3 @@ export async function computeEditsDiff(
478471return { error: err instanceof Error ? err.message : String(err) };
479472}
480473}
481-482-/**
483- * Compute the diff for a single edit operation without applying it.
484- * Kept as a convenience wrapper for single-edit callers.
485- */
486-export async function computeEditDiff(
487-path: string,
488-oldText: string,
489-newText: string,
490-cwd: string,
491-): Promise<EditDiffResult | EditDiffError> {
492-return computeEditsDiff(path, [{ oldText, newText }], cwd);
493-}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。