(abs, { maxBytes = MAX_SCAN_BYTES } = {})
| 797 | // no cap: silently treating an oversized-but-valid SKILL.md as "missing" would |
| 798 | // point the reader at the wrong problem. |
| 799 | function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) { |
| 800 | try { |
| 801 | const stat = fs.statSync(abs); |
| 802 | if (!stat.isFile() || stat.size > maxBytes) return null; |
| 803 | const buf = fs.readFileSync(abs); |
| 804 | // A NUL byte means binary; decoding it as text would produce noise. |
| 805 | if (buf.includes(0)) return null; |
| 806 | return buf.toString("utf8"); |
| 807 | } catch (e) { |
| 808 | return null; |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | function readJsonOrNull(repoRoot, file) { |
| 813 | try { |
no outgoing calls