@oh-my-pi/hashline 16.2.4 → 16.2.6

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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [16.2.6] - 2026-06-29
6
+
7
+ ### Fixed
8
+
9
+ - Fixed a parser error ("payload line has no preceding hunk header") caused by stray dots before the trailing colon in hunk headers, improving compatibility with GLM 5.2 outputs.
10
+
5
11
  ## [16.2.0] - 2026-06-27
6
12
 
7
13
  ### Added
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/hashline",
4
- "version": "16.2.4",
4
+ "version": "16.2.6",
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/tokenizer.ts CHANGED
@@ -234,8 +234,22 @@ function scanKeyword(line: string, index: number, end: number, keyword: string):
234
234
  return next;
235
235
  }
236
236
 
237
+ /**
238
+ * GLM 5.2 inserts a stray `.` between the line number/range and the trailing
239
+ * `:` (e.g. `SWAP 2.=3.:`, `INS.POST 2.:`). A `.` is never valid syntax at
240
+ * this position, so skip it when it precedes an optional `:` or end-of-line.
241
+ */
242
+ function skipStrayDot(line: string, index: number, end: number): number {
243
+ if (index < end && line.charCodeAt(index) === CHAR_DOT) {
244
+ const after = skipWhitespace(line, index + 1, end);
245
+ if (after === end || line.charCodeAt(after) === CHAR_COLON) return after;
246
+ }
247
+ return index;
248
+ }
249
+
237
250
  function consumeOptionalColon(line: string, index: number, end: number): number {
238
- const cursor = skipWhitespace(line, index, end);
251
+ let cursor = skipWhitespace(line, index, end);
252
+ cursor = skipStrayDot(line, cursor, end);
239
253
  return cursor < end && line.charCodeAt(cursor) === CHAR_COLON ? skipWhitespace(line, cursor + 1, end) : cursor;
240
254
  }
241
255
 
@@ -337,7 +351,8 @@ function scanHunkAnchor(line: string, start: number, end: number): TargetScan |
337
351
  if (deleteBlockEnd !== null) {
338
352
  const anchor = scanLineNumber(line, skipWhitespace(line, deleteBlockEnd, end), end);
339
353
  if (anchor === null) return null;
340
- const next = skipWhitespace(line, anchor.nextIndex, end);
354
+ let next = skipWhitespace(line, anchor.nextIndex, end);
355
+ next = skipStrayDot(line, next, end);
341
356
  if (next < end && line.charCodeAt(next) === CHAR_COLON) return null;
342
357
  return { target: { kind: "delete_block", anchor: { line: anchor.line } }, nextIndex: next };
343
358
  }
@@ -345,7 +360,8 @@ function scanHunkAnchor(line: string, start: number, end: number): TargetScan |
345
360
  if (deleteEnd !== null) {
346
361
  const range = scanHeaderRange(line, deleteEnd, end, true);
347
362
  if (range === null) return null;
348
- const next = skipWhitespace(line, range.nextIndex, end);
363
+ let next = skipWhitespace(line, range.nextIndex, end);
364
+ next = skipStrayDot(line, next, end);
349
365
  if (next < end && line.charCodeAt(next) === CHAR_COLON) return null;
350
366
  return { target: { kind: "delete", range: range.range }, nextIndex: next };
351
367
  }