@criogaid/pi-hashline-edit 0.8.0 → 0.10.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.
Files changed (118) hide show
  1. package/README.md +13 -10
  2. package/README.zh-CN.md +12 -9
  3. package/THIRD_PARTY_NOTICES.md +0 -6
  4. package/package.json +1 -1
  5. package/src/core/AGENTS.md +4 -5
  6. package/src/core/apply.test.ts +118 -293
  7. package/src/core/apply.ts +63 -165
  8. package/src/core/case-fold.ts +8 -67
  9. package/src/core/character-set.ts +4 -4
  10. package/src/core/errors.test.ts +23 -7
  11. package/src/core/errors.ts +32 -5
  12. package/src/core/hash.test.ts +8 -16
  13. package/src/core/hash.ts +3 -23
  14. package/src/core/lines.ts +2 -4
  15. package/src/core/ranges.test.ts +16 -8
  16. package/src/core/ranges.ts +10 -6
  17. package/src/core/regex.ts +3 -4
  18. package/src/core/replace.test.ts +47 -1
  19. package/src/core/replace.ts +19 -13
  20. package/src/core/search-analysis.test.ts +24 -27
  21. package/src/core/search-analysis.ts +34 -65
  22. package/src/core/search-matrix.testing.ts +0 -2
  23. package/src/core/search.ts +1 -1
  24. package/src/core/text.test.ts +5 -5
  25. package/src/core/text.ts +5 -12
  26. package/src/core/types.ts +7 -43
  27. package/src/integration/config-registration.test.ts +2 -2
  28. package/src/integration/fusion-dispatch.test.ts +2 -5
  29. package/src/integration/grep-flags.test.ts +0 -14
  30. package/src/integration/grep-js-completeness.test.ts +34 -8
  31. package/src/integration/grep-line-candidates.test.ts +4 -8
  32. package/src/integration/grep-matrix.test.ts +3 -7
  33. package/src/integration/grep-path-matrix.test.ts +5 -5
  34. package/src/integration/grep-prefilter-coverage.test.ts +3 -7
  35. package/src/integration/grep-process-limits.test.ts +78 -0
  36. package/src/integration/grep-rg.test.ts +123 -25
  37. package/src/integration/grep-scan-budget.test.ts +2 -2
  38. package/src/integration/grep-translation.test.ts +12 -27
  39. package/src/integration/large-text.test.ts +1 -47
  40. package/src/integration/model-budget-lifecycle.test.ts +13 -3
  41. package/src/integration/mutation-file-types.testing.ts +1 -1
  42. package/src/integration/npm-package.testing.ts +1 -1
  43. package/src/integration/publication-read-changes.test.ts +125 -47
  44. package/src/integration/replace-worker-boundary.test.ts +21 -11
  45. package/src/integration/report-replay.test.ts +21 -23
  46. package/src/integration/utf8-errors.test.ts +1 -1
  47. package/src/pi/AGENTS.md +16 -16
  48. package/src/pi/action-fusion.test.ts +168 -300
  49. package/src/pi/action-fusion.ts +148 -111
  50. package/src/pi/anchor-format.test.ts +9 -9
  51. package/src/pi/anchor-format.ts +6 -8
  52. package/src/pi/argument-diagnostics.ts +52 -207
  53. package/src/pi/argument-error.ts +2 -1
  54. package/src/pi/argument-format.test.ts +20 -22
  55. package/src/pi/argument-validation.test.ts +382 -418
  56. package/src/pi/argument-validation.ts +5 -8
  57. package/src/pi/budgets.ts +5 -4
  58. package/src/pi/config.test.ts +5 -2
  59. package/src/pi/config.ts +4 -6
  60. package/src/pi/diagnostic-buffer.test.ts +12 -1
  61. package/src/pi/diagnostic-buffer.ts +1 -2
  62. package/src/pi/directory-sync.test.ts +0 -1
  63. package/src/pi/edit-tool.ts +173 -226
  64. package/src/pi/error-text.ts +4 -8
  65. package/src/pi/execute.test.ts +165 -266
  66. package/src/pi/failure-context.test.ts +144 -126
  67. package/src/pi/failure-context.ts +45 -94
  68. package/src/pi/failure-path.test.ts +168 -141
  69. package/src/pi/file-commit.test.ts +110 -53
  70. package/src/pi/file-commit.ts +90 -137
  71. package/src/pi/file-snapshot.test.ts +3 -5
  72. package/src/pi/fusion-card.test.ts +4 -1
  73. package/src/pi/fusion-card.ts +16 -24
  74. package/src/pi/grep-candidates.test.ts +2 -101
  75. package/src/pi/grep-candidates.ts +23 -69
  76. package/src/pi/grep-matrix.test.ts +2 -2
  77. package/src/pi/grep-order.test.ts +4 -4
  78. package/src/pi/grep-output.ts +62 -96
  79. package/src/pi/grep-render.ts +1 -1
  80. package/src/pi/grep-reread.ts +92 -0
  81. package/src/pi/grep-scope.ts +40 -42
  82. package/src/pi/grep-search.ts +22 -31
  83. package/src/pi/grep-tool.ts +55 -82
  84. package/src/pi/grep.test.ts +81 -46
  85. package/src/pi/model-budgets.test.ts +25 -23
  86. package/src/pi/model-budgets.ts +6 -38
  87. package/src/pi/mutation-result.test.ts +44 -35
  88. package/src/pi/mutation-result.ts +51 -20
  89. package/src/pi/mutation-runner.ts +126 -70
  90. package/src/pi/output-budgets.test.ts +38 -16
  91. package/src/pi/path.ts +1 -1
  92. package/src/pi/pi.test.ts +3 -1
  93. package/src/pi/read-tool.ts +5 -5
  94. package/src/pi/regex-worker-contract.ts +3 -13
  95. package/src/pi/regex-worker.ts +1 -10
  96. package/src/pi/registration.test.ts +82 -20
  97. package/src/pi/render.test.ts +79 -42
  98. package/src/pi/render.ts +69 -63
  99. package/src/pi/replace-regex.ts +14 -2
  100. package/src/pi/replace-tool.ts +22 -83
  101. package/src/pi/replace-worker.ts +1 -1
  102. package/src/pi/replace.test.ts +9 -5
  103. package/src/pi/report-cause.ts +3 -8
  104. package/src/pi/report-failure.testing.ts +1 -2
  105. package/src/pi/report-schema.ts +65 -81
  106. package/src/pi/report.test.ts +171 -25
  107. package/src/pi/report.ts +33 -87
  108. package/src/pi/result-safety.test.ts +177 -189
  109. package/src/pi/rg-process.test.ts +77 -63
  110. package/src/pi/rg-process.ts +48 -64
  111. package/src/pi/rg-regex.ts +40 -400
  112. package/src/pi/schema.ts +12 -0
  113. package/src/pi/text-stream.test.ts +0 -21
  114. package/src/pi/text-stream.ts +14 -21
  115. package/src/pi/write-tool.ts +33 -62
  116. package/src/pi/write.test.ts +1 -3
  117. package/src/testing/regex-translation-corpus.ts +12 -12
  118. package/src/pi/replace-worker-contract.ts +0 -10
package/README.md CHANGED
@@ -40,7 +40,7 @@ The model copies an anchor into `edit`:
40
40
  ```json
41
41
  {
42
42
  "path": "greet.ts",
43
- "edits": [{ "op": "replace", "anchor": "2#GFYR", "body": [" return \"hello, hashline\";"] }]
43
+ "edits": [{ "action": "replace", "anchor": "2#GFYR", "body": [" return \"hello, hashline\";"] }]
44
44
  }
45
45
  ```
46
46
 
@@ -53,8 +53,8 @@ The extension replaces Pi's `read`, `grep`, `edit`, and `write`, and adds `repla
53
53
  | Tool | What it does |
54
54
  | --- | --- |
55
55
  | `read` | Shows UTF-8 text with anchors, paginated within the model's output budget. Images and files containing NUL bytes go to Pi's built-in read. |
56
- | `grep` | Searches files and directories with JavaScript regex or literal text; returns anchored matches, file paths, or counts in traversal order; a limit keeps the first matches in that order. Respects ignore rules. |
57
- | `edit` | Replaces, inserts, deletes, copies, or moves whole lines by anchor. All operations in one call apply to the same snapshot, or none apply. |
56
+ | `grep` | Searches files and directories with JavaScript regex or literal text; returns anchored matches, file paths, or counts in traversal order; a limit keeps the first matches in that order. Directory searches respect ignore rules and skip `.git` and linked directories, even beneath a directory named in `path`; naming an ignored file or one of those directories itself searches it. |
57
+ | `edit` | Replaces, inserts, or deletes whole lines by anchor. All operations in one call apply to the same snapshot, or none apply. |
58
58
  | `replace` | Applies literal or regex substitutions across one file. Every rule must match, and overlapping matches reject the batch. |
59
59
  | `write` | Creates a file (`mode: "create"`) or overwrites one (`mode: "overwrite"`), using the content exactly as given. |
60
60
 
@@ -64,16 +64,19 @@ Grep matches the LF view with native JavaScript regexes. Without `multiline`, ea
64
64
 
65
65
  Edit operations:
66
66
 
67
- | `op` | Effect |
67
+ | `action` | Effect |
68
68
  | --- | --- |
69
69
  | `replace` / `delete` | Replace or remove a line, or an inclusive range with `end`. |
70
70
  | `insert_before` / `insert_after` | Insert lines next to an anchor. |
71
71
  | `prepend` / `append` | Insert lines at the start or end of the file. |
72
- | `copy` / `move` | Copy or move a line range to before or after another anchor. |
72
+
73
+ One call takes at most [64 operations](src/pi/edit-tool.ts). Ranges in one call must not overlap, and each gap between lines takes at most one insertion. An insertion at the start of a replaced or deleted range goes before it.
74
+
75
+ Every tool asks for constrained sampling (Pi's `constrainedSampling`, a strict JSON schema) where the provider supports it, so the model cannot emit fields or values the schema does not declare, or exceed edit's operation limit. Optional fields the call does not use are then written as `null`, including each edit operation's fields that its `action` does not take. For the same reason, grep's `pattern`, `path`, and `glob` take arrays only; on other providers Pi wraps a single string into an array.
73
76
 
74
77
  The model sees each tool's full parameter schema; the definitions live in the tool files under [`src/pi/`](src/pi/).
75
78
 
76
- Range operations verify the cited `anchor` and `end`, plus the destination for copy/move. Interior lines have no individual anchor check. Changes elsewhere before the call do not invalidate unchanged anchors; publication rechecks the bytes read while applying the call and rejects a detected change.
79
+ Range operations verify the cited `anchor` and `end`. Interior lines have no individual anchor check. Changes elsewhere before the call do not invalidate unchanged anchors; publication rechecks the bytes read while applying the call and rejects a detected change.
77
80
 
78
81
  ## When an edit is rejected
79
82
 
@@ -81,7 +84,7 @@ Argument and anchor validation failures leave the file untouched. The report nam
81
84
 
82
85
  A failure during or after publication states `NOT_PUBLISHED`, `PUBLISHED`, or `UNKNOWN`. Follow the report's `next` before retrying: an error after publication can leave the requested change on disk.
83
86
 
84
- Argument mistakes are reported per field, with what the field means and how to fix it, before any file is touched.
87
+ Argument mistakes, including a reversed range, are reported per field, with what the field means and how to fix it, before any file is touched.
85
88
 
86
89
  ## Action Fusion
87
90
 
@@ -110,7 +113,7 @@ Add `hashlineEdit` to Pi's global settings (`~/.pi/agent/settings.json`) or a pr
110
113
  "actionFusion": true,
111
114
  "hashLen": 4,
112
115
  "shiftRadius": 15,
113
- "read": { "defaultLimit": 500 },
116
+ "read": { "defaultLimit": 2000 },
114
117
  "grep": { "defaultLimit": 100, "defaultContext": 0, "regexTimeoutMs": 5000 },
115
118
  "replace": { "regexTimeoutMs": 5000 }
116
119
  }
@@ -123,7 +126,7 @@ Add `hashlineEdit` to Pi's global settings (`~/.pi/agent/settings.json`) or a pr
123
126
  | `actionFusion` | `true` | Allow `then_run` on mutation tools. |
124
127
  | `hashLen` | `4` | Anchor hash length, 2–8. |
125
128
  | `shiftRadius` | `15` | Lines searched around a stale anchor before the whole file, 0–100; `0` disables recovery search. |
126
- | `read.defaultLimit` | `500` | Lines returned when the call gives no limit. |
129
+ | `read.defaultLimit` | `2000` | Lines returned when the call gives no limit, matching Pi's built-in read. |
127
130
  | `read.maxKiB` | Model-based | Fixed cap on read output, 1–4096 KiB. |
128
131
  | `grep.defaultLimit` | `100` | Matching lines returned when the call gives no limit. |
129
132
  | `grep.defaultContext` | `0` | Context lines around each match, 0–20. |
@@ -137,7 +140,7 @@ The selected model's declared context capacity sets the output budgets; remainin
137
140
 
138
141
  When model capacity is unknown or invalid, the defaults are 256 KiB for read rows, 50 KiB for grep payloads, 16 KiB per diagnostic block, 4 KiB per free-text field, and 500 UTF-16 code units per grep preview. An explicit `read.maxKiB` overrides only the read cap. Each execution keeps the budget snapshot it started with.
139
142
 
140
- Read reports pagination when the extension cuts a window or its byte budget; a caller-supplied `limit` alone does not add a pagination report. A first row that cannot fit gets a `lineTooLong` fact. Grep reports payload and preview truncation separately, and plain previews for invalid UTF-8 never carry edit anchors.
143
+ Read reports pagination when its default line limit or byte budget cuts a window; a caller-supplied `limit` alone does not add a pagination report. A first row that cannot fit gets a `lineTooLong` fact. Grep reports payload and preview truncation separately, and plain previews for invalid UTF-8 never carry edit anchors.
141
144
 
142
145
  ## Limits
143
146
 
package/README.zh-CN.md CHANGED
@@ -40,7 +40,7 @@ greet.ts · 3 lines
40
40
  ```json
41
41
  {
42
42
  "path": "greet.ts",
43
- "edits": [{ "op": "replace", "anchor": "2#GFYR", "body": [" return \"hello, hashline\";"] }]
43
+ "edits": [{ "action": "replace", "anchor": "2#GFYR", "body": [" return \"hello, hashline\";"] }]
44
44
  }
45
45
  ```
46
46
 
@@ -53,8 +53,8 @@ greet.ts · 3 lines
53
53
  | 工具 | 作用 |
54
54
  | --- | --- |
55
55
  | `read` | 显示带锚点的 UTF-8 文本,按模型的输出预算分页。图片和含 NUL 字节的文件交给 Pi 内置的 read。 |
56
- | `grep` | 用 JavaScript 正则或字面文本搜索文件和目录,按遍历顺序返回带锚点的匹配行、文件路径或计数,设了 limit 时保留该顺序下的前若干条匹配;遵守忽略规则。 |
57
- | `edit` | 按锚点替换、插入、删除、复制或移动整行。一次调用中的所有操作基于同一份快照,要么全部生效,要么全部不生效。 |
56
+ | `grep` | 用 JavaScript 正则或字面文本搜索文件和目录,按遍历顺序返回带锚点的匹配行、文件路径或计数,设了 limit 时保留该顺序下的前若干条匹配。搜索目录时遵守忽略规则,并跳过 `.git` 和链接目录,在 `path` 指定的目录之下也是如此;在 `path` 中直接指定被忽略的文件或这些目录本身才会搜索。 |
57
+ | `edit` | 按锚点替换、插入或删除整行。一次调用中的所有操作基于同一份快照,要么全部生效,要么全部不生效。 |
58
58
  | `replace` | 在单个文件内批量执行字面或正则替换。每条规则都必须有匹配,匹配区域重叠时整批拒绝。 |
59
59
  | `write` | 新建文件(`mode: "create"`)或覆盖文件(`mode: "overwrite"`),内容原样写入。 |
60
60
 
@@ -64,16 +64,19 @@ Grep 用原生 JavaScript 正则匹配 LF 视图。不设 `multiline` 时逐物
64
64
 
65
65
  `edit` 的操作:
66
66
 
67
- | `op` | 效果 |
67
+ | `action` | 效果 |
68
68
  | --- | --- |
69
69
  | `replace` / `delete` | 替换或删除一行;配合 `end` 处理闭区间范围。 |
70
70
  | `insert_before` / `insert_after` | 在锚点前或后插入行。 |
71
71
  | `prepend` / `append` | 在文件开头或末尾插入行。 |
72
- | `copy` / `move` | 把一段行复制或移动到另一个锚点之前或之后。 |
72
+
73
+ 一次调用最多 [64 个操作](src/pi/edit-tool.ts)。一次调用中的范围不能重叠,相邻两行之间的每个位置最多一次插入。位于替换或删除区间起点的插入放在该区间之前。
74
+
75
+ 在提供方支持时,所有工具都请求约束采样(Pi 的 `constrainedSampling`,即 strict JSON schema),模型因此无法写出 schema 未声明的字段或取值,也无法超出 edit 的操作数上限。这时调用中没用到的可选字段都写 `null`,edit 每个操作里其 `action` 用不到的字段也一样。出于同一原因,grep 的 `pattern`、`path` 和 `glob` 只接受数组;在其他提供方上,Pi 会把单个字符串包成数组。
73
76
 
74
77
  模型能看到每个工具完整的参数 schema,定义位于 [`src/pi/`](src/pi/) 下的各工具文件。
75
78
 
76
- 范围操作核对给出的 `anchor`、`end`,以及复制或移动的目标锚点,不逐行验证区间内部的内容。调用前其他位置的变化不会使未改变的锚点失效;发布前会复核修改操作实际读取的字节,检测到变化时拒绝发布。
79
+ 范围操作核对给出的 `anchor`、`end`,不逐行验证区间内部的内容。调用前其他位置的变化不会使未改变的锚点失效;发布前会复核修改操作实际读取的字节,检测到变化时拒绝发布。
77
80
 
78
81
  ## 修改被拒绝时
79
82
 
@@ -81,7 +84,7 @@ Grep 用原生 JavaScript 正则匹配 LF 视图。不设 `multiline` 时逐物
81
84
 
82
85
  发布期间或发布后的失败会明确标记 `NOT_PUBLISHED`、`PUBLISHED` 或 `UNKNOWN`。重试前应遵循报告的 `next`:发布后的错误可能意味着所需修改已经写入磁盘。
83
86
 
84
- 参数错误按字段逐条报告,说明字段的含义和修正方法,此时还不会碰任何文件。
87
+ 参数错误(包括反向范围)按字段逐条报告,说明字段的含义和修正方法,此时还不会碰任何文件。
85
88
 
86
89
  ## Action Fusion
87
90
 
@@ -110,7 +113,7 @@ Grep 用原生 JavaScript 正则匹配 LF 视图。不设 `multiline` 时逐物
110
113
  "actionFusion": true,
111
114
  "hashLen": 4,
112
115
  "shiftRadius": 15,
113
- "read": { "defaultLimit": 500 },
116
+ "read": { "defaultLimit": 2000 },
114
117
  "grep": { "defaultLimit": 100, "defaultContext": 0, "regexTimeoutMs": 5000 },
115
118
  "replace": { "regexTimeoutMs": 5000 }
116
119
  }
@@ -123,7 +126,7 @@ Grep 用原生 JavaScript 正则匹配 LF 视图。不设 `multiline` 时逐物
123
126
  | `actionFusion` | `true` | 允许修改类工具使用 `then_run`。 |
124
127
  | `hashLen` | `4` | 锚点哈希长度,2–8。 |
125
128
  | `shiftRadius` | `15` | 锚点过期时先在附近多少行内查找,再查全文件,0–100;`0` 关闭恢复查找。 |
126
- | `read.defaultLimit` | `500` | 调用未指定时返回的行数。 |
129
+ | `read.defaultLimit` | `2000` | 调用未指定时返回的行数,与 Pi 内置 read 一致。 |
127
130
  | `read.maxKiB` | 按模型 | read 输出的固定上限,1–4096 KiB。 |
128
131
  | `grep.defaultLimit` | `100` | 调用未指定时返回的匹配行数。 |
129
132
  | `grep.defaultContext` | `0` | 每个匹配前后的上下文行数,0–20。 |
@@ -6,8 +6,6 @@ The JS-to-ripgrep candidate translator adapts the following analysis techniques
6
6
  | --- | --- | --- |
7
7
  | [regexpu-core](https://github.com/mathiasbynens/regexpu-core) | Separate scalar sets from class strings; apply scoped flags before lowering a set | MIT |
8
8
  | [refa](https://github.com/RunDevelopment/refa/tree/8d20d94232b1adb043c29810046c060ca1664bf1) | Normalized character intervals and bounded finite languages | MIT |
9
- | [regexp-ast-analysis](https://github.com/RunDevelopment/regexp-ast-analysis/tree/6f0dbfc42ccc4a3fd22da6e3917f4e8cef07bee8) | Track exactness and fixed-width neighbouring characters across assertions | MIT |
10
- | [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp/tree/4700804dba99bed531e727f09c72a69a1dc939a4) | Character constraints for lookarounds and word boundaries | MIT |
11
9
  | [regex-syntax](https://github.com/rust-lang/regex/blob/master/regex-syntax/src/hir/literal.rs) | Budget literal expansion; retain necessary prefixes and suffixes without dropping alternatives | MIT OR Apache-2.0 |
12
10
  | [RE2](https://github.com/google/re2/blob/main/re2/prefilter.cc) | Necessary AND/OR literal conditions for file prefiltering | BSD-3-Clause |
13
11
  | [Vectorscan](https://github.com/VectorCamp/vectorscan/blob/develop/src/parser/prefilter.cpp) | Widen unsupported assertions and backreferences while retaining regular constraints | BSD-3-Clause |
@@ -20,10 +18,6 @@ regexpu-core: Copyright Mathias Bynens <https://mathiasbynens.be/>
20
18
 
21
19
  refa: Copyright (c) 2020 Michael Schmidt
22
20
 
23
- regexp-ast-analysis: Copyright (c) 2021 Michael Schmidt
24
-
25
- eslint-plugin-regexp: Copyright (c) 2020 Yosuke Ota
26
-
27
21
  Permission is hereby granted, free of charge, to any person obtaining a copy
28
22
  of this software and associated documentation files (the "Software"), to deal
29
23
  in the Software without restriction, including without limitation the rights
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@criogaid/pi-hashline-edit",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Hashline-style file editing for pi — line-anchored edits verified by content hash, replacing oldText/newText matching",
6
6
  "homepage": "https://github.com/Criogaid/pi-hashline-edit#readme",
@@ -4,17 +4,16 @@ Internal pure engine: no Pi imports and no public API. It trusts input already f
4
4
 
5
5
  ## Modules
6
6
 
7
- - `hash.ts` computes position-dependent line checksums (line number + content → `LINE#HASH`). `lines.ts` handles splitting, line-ending detection, and physical line counts. `text.ts` does strict UTF-8 decoding.
8
- - `apply.ts` `applyEdits` validates a whole batch of `Edit` ops (see `types.ts`) against a single snapshot: anchor checks, overlap and conflict detection, and shifted-anchor recovery (`AnchorRecovery`: local `shiftRadius` search, then full file). It returns new text or structured failures and never touches the filesystem.
7
+ - `hash.ts` computes position-dependent line checksums (line number + content → `LINE#HASH`). `lines.ts` handles splitting, line-ending detection, and physical line counts. `text.ts` does strict and lossy UTF-8 decoding and decides which text cannot be written.
8
+ - `apply.ts` `applyEdits` validates a whole batch of `Edit` ops (see `types.ts`) against a single snapshot: anchor checks, overlap and conflict detection, and shifted-anchor recovery (`AnchorRecovery`: local `shiftRadius` search, then full file). It returns new text or structured anchor failures, throws `OVERLAPPING_EDITS` for an overlap, and never touches the filesystem.
9
9
  - `regex.ts` builds JavaScript regexes on the LF view (`regexSource`, `buildRegex`) for both grep and replace; neither engine imports the other.
10
10
  - `replace.ts` is replace's engine: literal and JavaScript-regex matching on the LF view, separator restoration, and overlap rejection. `replace-schema.ts` defines the tool's replacement schema and the engine's result schema, with their derived types.
11
11
  - `search.ts` evaluates native JavaScript queries on the LF view and returns bounded physical rows; `search-schema.ts` defines its result.
12
12
  - `search-analysis.ts` parses patterns with regexpp (V8 has already accepted them at tool entry), decides smart case, and derives the literals every match must contain; `case-fold.ts` supplies JavaScript's case equivalence; `character-set.ts` owns character-class sets and shared AST surrogate-pair decoding for both candidate strategies.
13
13
  - `errors.ts` holds the classified `HashlineError`, typed by code so its facts and `next` alternative must match the code's schema, and errno classification.
14
- - `ranges.ts` provides overlap detection for both engines and range merging for grep and failure neighborhoods.
14
+ - `ranges.ts` provides overlap detection for both engines and range merging for failure neighborhoods.
15
15
 
16
16
  ## Constraints
17
17
 
18
- - Plan `copy/move` in `apply.ts` against original line ranges; capture text and separators without moving or duplicating the file-header BOM. Treat source reads separately from mutation conflicts, keep destinations in original coordinates, reject interior move destinations, and make adjacent moves no-ops. Reuse the shared commit and Fusion pipeline.
19
18
  - Own interval algebra, bounded membership caching, and explicit class-string enumeration in `character-set.ts`; derive Unicode properties, `v` sets, and case closure from the running V8 rather than separate Unicode tables. Intersections may enumerate either string operand, subtractions only the left, and unions require every operand. Keep original scoped case flags for membership even when translating a backreference; apply repetition case widening afterward through the existing byte translator. Unknown string properties remain widened.
20
- - Derive necessary file conditions in `search-analysis.ts` as bounded AND/OR literal clauses. Preserve every OR alternative, retain necessary prefixes or suffixes when expansion is too large, and cut literals where bytes can differ from the LF view. Unknown constructs widen candidates, never narrow them.
19
+ - Derive one necessary file condition in `search-analysis.ts`: an AND keeps its most selective side, because extra rg passes cost more than they save. Preserve every OR alternative, retain necessary prefixes or suffixes when expansion is too large, and cut literals where bytes can differ from the LF view. Unknown constructs widen candidates, never narrow them.