refactor(hashline-edit): redesign hashline format with CID-based hashing
Breaking Changes: - Change hashline format from 'lineNum:hex|content' to 'lineNum#CID:content' - Replace hex-based hashing (00-ff) with CID-based hashing (ZPMQVRWSNKTXJBYH nibbles) - Simplify constants: HASH_DICT → NIBBLE_STR + HASHLINE_DICT - Update patterns: HASHLINE_PATTERN → HASHLINE_REF_PATTERN + HASHLINE_OUTPUT_PATTERN Benefits: - More compact and memorable CID identifiers - Better alignment with LSP line reference format (lineNum#ID) - Improved error messages and diff metadata clarity - Remove unused toHashlineContent from diff-enhancer hook Updates: - Refactor hash-computation for CID generation - Update all diff-utils to use new format - Update hook to use raw content instead of hashline format - Update tests to match new expectations 🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { HASH_DICT } from "./constants"
|
||||
import { HASHLINE_DICT } from "./constants"
|
||||
|
||||
export function computeLineHash(lineNumber: number, content: string): string {
|
||||
void lineNumber
|
||||
const stripped = content.replace(/\s+/g, "")
|
||||
const hashInput = `${lineNumber}:${stripped}`
|
||||
const hash = Bun.hash.xxHash32(hashInput)
|
||||
const hash = Bun.hash.xxHash32(stripped)
|
||||
const index = hash % 256
|
||||
return HASH_DICT[index]
|
||||
return HASHLINE_DICT[index]
|
||||
}
|
||||
|
||||
export function formatHashLine(lineNumber: number, content: string): string {
|
||||
const hash = computeLineHash(lineNumber, content)
|
||||
return `${lineNumber}:${hash}|${content}`
|
||||
return `${lineNumber}#${hash}:${content}`
|
||||
}
|
||||
|
||||
export function formatHashLines(content: string): string {
|
||||
|
||||
Reference in New Issue
Block a user