Repository navigation
Commit c95f234
fix(core): flat module shape, submatch bound, and text-arm offset validation
Fifth review round — Kilo and cubic on the extracted module.
- The new module used `export namespace`, which packages/opencode/AGENTS.md
explicitly prohibits, and its header cited that rule INVERTED: it claimed
AGENTS.md forbids `export * as`, when `export * as` is the prescribed pattern
and `export namespace` is what is forbidden (not standard ESM, blocks
tree-shaking, breaks Node's native TS runner). Flattened to top-level exports
with a self-reexport at the bottom; importers are unchanged. Header corrected.
- Bound the submatch count on the legacy path, matching the core parser. Each
submatch costs a rebase per endpoint and a rebase allocates a string up to the
line length, so an unbounded array turned one in-ceiling record into
O(count x line) work on the shipped `/find` route.
- Validate `{text}`-arm offsets in both parsers. Nothing is rebased there, but
the offset must still be addressable in the line it indexes: core's
`NonNegativeInt` rejects negatives and fractions yet not values past the end,
and legacy's `z.number()` rejects none of them. Raised by two reviewers
independently; my earlier push-back was too narrow — I argued no claim is made
on that arm, but returning a coordinate pair that indexes nothing is a claim.
- Dropped a stale doc comment describing the previous, superseded layout.
Tests: 23 core, 12 legacy. Marker balance verified across all five files.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent e21dc19 commit c95f234
4 files changed
Lines changed: 257 additions & 201 deletions
File tree
- packages
- core
- src
- test
- opencode
- src/file
- test/file
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
151 | 152 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
| |||
171 | 178 | | |
172 | 179 | | |
173 | 180 | | |
174 | | - | |
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
351 | 365 | | |
352 | 366 | | |
353 | 367 | | |
| |||
0 commit comments