fix(hashline-edit): align autocorrect, BOM/CRLF, and tool description with oh-my-pi

- Rewrite restoreOldWrappedLines to use oh-my-pi's span-scanning algorithm
- Add stripTrailingContinuationTokens and stripMergeOperatorChars helpers
- Fix detectLineEnding to use first-occurrence logic instead of any-match
- Fix applyAppend/applyPrepend to replace empty-line placeholder in empty files
- Enhance tool description with 7 critical rules, tag guidance, and anti-patterns
This commit is contained in:
YeonGyu-Kim
2026-02-22 14:40:18 +09:00
parent 5d1d87cc10
commit e6868e9112
6 changed files with 207 additions and 29 deletions
@@ -5,7 +5,11 @@ export interface FileTextEnvelope {
}
function detectLineEnding(content: string): "\n" | "\r\n" {
return content.includes("\r\n") ? "\r\n" : "\n"
const crlfIndex = content.indexOf("\r\n")
const lfIndex = content.indexOf("\n")
if (lfIndex === -1) return "\n"
if (crlfIndex === -1) return "\n"
return crlfIndex < lfIndex ? "\r\n" : "\n"
}
function stripBom(content: string): { content: string; hadBom: boolean } {