@oh-my-pi/hashline 16.5.2 → 17.0.0
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.
- package/CHANGELOG.md +6 -0
- package/dist/types/patcher.d.ts +6 -0
- package/package.json +1 -1
- package/src/patcher.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [17.0.0] - 2026-07-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `enforceSeenLines` option to `PatcherOptions` (defaulting to `true`) to control whether seen-line validation is enforced on anchored edits, allowing tags to validate on content hash alone when disabled.
|
|
10
|
+
|
|
5
11
|
## [16.5.0] - 2026-07-13
|
|
6
12
|
|
|
7
13
|
### Fixed
|
package/dist/types/patcher.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export interface PatcherOptions {
|
|
|
15
15
|
* host did not wire a resolver). Plain line-range ops never need it.
|
|
16
16
|
*/
|
|
17
17
|
blockResolver?: BlockResolver;
|
|
18
|
+
/**
|
|
19
|
+
* Enforce the seen-line guard: reject anchored edits on lines the read/search
|
|
20
|
+
* that minted the tag never displayed. Defaults to `true`. When `false`, tags
|
|
21
|
+
* validate on content hash alone and any anchor into the tagged content applies.
|
|
22
|
+
*/
|
|
23
|
+
enforceSeenLines?: boolean;
|
|
18
24
|
}
|
|
19
25
|
/** Per-section result returned by {@link Patcher.apply} / {@link Patcher.commit}. */
|
|
20
26
|
export interface PatchSectionResult {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/hashline",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "17.0.0",
|
|
5
5
|
"description": "Hashline: a compact, line-anchored patch language and applier. Pluggable FS/IO so it works over disk, in-memory, or any custom backend.",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
package/src/patcher.ts
CHANGED
|
@@ -73,6 +73,12 @@ export interface PatcherOptions {
|
|
|
73
73
|
* host did not wire a resolver). Plain line-range ops never need it.
|
|
74
74
|
*/
|
|
75
75
|
blockResolver?: BlockResolver;
|
|
76
|
+
/**
|
|
77
|
+
* Enforce the seen-line guard: reject anchored edits on lines the read/search
|
|
78
|
+
* that minted the tag never displayed. Defaults to `true`. When `false`, tags
|
|
79
|
+
* validate on content hash alone and any anchor into the tagged content applies.
|
|
80
|
+
*/
|
|
81
|
+
enforceSeenLines?: boolean;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/** Per-section result returned by {@link Patcher.apply} / {@link Patcher.commit}. */
|
|
@@ -197,6 +203,7 @@ export class Patcher {
|
|
|
197
203
|
readonly snapshots: SnapshotStore;
|
|
198
204
|
readonly recovery: Recovery;
|
|
199
205
|
readonly blockResolver: BlockResolver | undefined;
|
|
206
|
+
readonly #enforceSeenLines: boolean;
|
|
200
207
|
|
|
201
208
|
constructor(options: PatcherOptions) {
|
|
202
209
|
if (!options.snapshots) {
|
|
@@ -206,6 +213,7 @@ export class Patcher {
|
|
|
206
213
|
this.snapshots = options.snapshots;
|
|
207
214
|
this.recovery = new Recovery(options.snapshots);
|
|
208
215
|
this.blockResolver = options.blockResolver;
|
|
216
|
+
this.#enforceSeenLines = options.enforceSeenLines ?? true;
|
|
209
217
|
}
|
|
210
218
|
|
|
211
219
|
/**
|
|
@@ -628,7 +636,9 @@ export class Patcher {
|
|
|
628
636
|
// The line numbers in `edits` index the exact content the tag names.
|
|
629
637
|
// Reject any anchor the read never displayed: editing lines the model
|
|
630
638
|
// has not seen is the off-by-memory mistake that mangles files.
|
|
631
|
-
if (expected !== undefined
|
|
639
|
+
if (expected !== undefined && this.#enforceSeenLines) {
|
|
640
|
+
this.#assertSeenLines(section, expected, matchedSnapshot);
|
|
641
|
+
}
|
|
632
642
|
const result = applyEdits(normalized, resolved);
|
|
633
643
|
return withResolveWarnings(blockResolutions.length > 0 ? { ...result, blockResolutions } : result);
|
|
634
644
|
}
|