4ea76365cd
Move the hash-anchored edit core (hash computation, validation, edit operations, text normalization, chunk formatter, diff utilities, and a runtime-aware xxHash32 binding) into a new @oh-my-opencode/hashline-core workspace package. The src/tools/hashline-edit/ surface becomes a set of thin re-export shims, so existing import paths in the plugin keep working while the pure logic lives behind a stable package boundary that has no opencode runtime dependencies. Tests: bun test packages/hashline-core src/tools/hashline-edit
60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
/**
|
|
* Hashline core public API.
|
|
*
|
|
* Hash dependency choice: Option 2.
|
|
* This package embeds a runtime-aware xxHash32 implementation (`xxhash32.ts`)
|
|
* that prefers the host runtime's native xxHash32 binding when available and
|
|
* falls back to a pure-JS implementation otherwise. No package-level dependency
|
|
* on any specific runtime; the binding is detected via globalThis at call time.
|
|
*/
|
|
export { NIBBLE_STR, HASHLINE_DICT, HASHLINE_REF_PATTERN, HASHLINE_OUTPUT_PATTERN } from "./constants"
|
|
export type { ReplaceEdit, AppendEdit, PrependEdit, HashlineEdit } from "./types"
|
|
export {
|
|
computeLineHash,
|
|
computeLegacyLineHash,
|
|
formatHashLine,
|
|
formatHashLines,
|
|
streamHashLinesFromUtf8,
|
|
streamHashLinesFromLines,
|
|
} from "./hash-computation"
|
|
export { parseLineRef, validateLineRef, validateLineRefs, HashlineMismatchError, normalizeLineRef } from "./validation"
|
|
export type { LineRef } from "./validation"
|
|
export { applyHashlineEdits, applyHashlineEditsWithReport } from "./edit-operations"
|
|
export type { HashlineApplyReport } from "./edit-operations"
|
|
export {
|
|
applySetLine,
|
|
applyReplaceLines,
|
|
applyInsertAfter,
|
|
applyInsertBefore,
|
|
applyAppend,
|
|
applyPrepend,
|
|
} from "./edit-operation-primitives"
|
|
export { getEditLineNumber, collectLineRefs, detectOverlappingRanges } from "./edit-ordering"
|
|
export { dedupeEdits } from "./edit-deduplication"
|
|
export {
|
|
stripLinePrefixes,
|
|
toNewLines,
|
|
restoreLeadingIndent,
|
|
stripInsertAnchorEcho,
|
|
stripInsertBeforeEcho,
|
|
stripInsertBoundaryEcho,
|
|
stripRangeBoundaryEcho,
|
|
} from "./edit-text-normalization"
|
|
export { canonicalizeFileText, restoreFileText } from "./file-text-canonicalization"
|
|
export type { FileTextEnvelope } from "./file-text-canonicalization"
|
|
export {
|
|
stripTrailingContinuationTokens,
|
|
stripMergeOperatorChars,
|
|
restoreOldWrappedLines,
|
|
maybeExpandSingleLineMerge,
|
|
restoreIndentForPairedReplacement,
|
|
autocorrectReplacementLines,
|
|
} from "./autocorrect-replacement-lines"
|
|
export { normalizeHashlineEdits } from "./normalize-edits"
|
|
export type { RawHashlineEdit } from "./normalize-edits"
|
|
export { createHashlineChunkFormatter } from "./hashline-chunk-formatter"
|
|
export type { HashlineChunkFormatter } from "./hashline-chunk-formatter"
|
|
export type { HashlineStreamOptions } from "./hash-computation"
|
|
export { toHashlineContent, generateUnifiedDiff, countLineDiffs } from "./diff-utils"
|
|
export { generateHashlineDiff } from "./hashline-edit-diff"
|