(abs, { maxBytes = MAX_SCAN_BYTES } = {})
| 547 | // no cap: silently treating an oversized-but-valid SKILL.md as "missing" would |
| 548 | // point the reader at the wrong problem. |
| 549 | function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) { |
| 550 | try { |
| 551 | const stat = fs.statSync(abs); |
| 552 | if (!stat.isFile() || stat.size > maxBytes) return null; |
| 553 | const buf = fs.readFileSync(abs); |
| 554 | // A NUL byte means binary; decoding it as text would produce noise. |
| 555 | if (buf.includes(0)) return null; |
| 556 | return buf.toString("utf8"); |
| 557 | } catch (e) { |
| 558 | return null; |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | function readJsonOrNull(repoRoot, file) { |
| 563 | try { |
no outgoing calls