(abs, { maxBytes = MAX_SCAN_BYTES } = {})
| 747 | // no cap: silently treating an oversized-but-valid SKILL.md as "missing" would |
| 748 | // point the reader at the wrong problem. |
| 749 | function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) { |
| 750 | try { |
| 751 | const stat = fs.statSync(abs); |
| 752 | if (!stat.isFile() || stat.size > maxBytes) return null; |
| 753 | const buf = fs.readFileSync(abs); |
| 754 | // A NUL byte means binary; decoding it as text would produce noise. |
| 755 | if (buf.includes(0)) return null; |
| 756 | return buf.toString("utf8"); |
| 757 | } catch (e) { |
| 758 | return null; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | function readJsonOrNull(repoRoot, file) { |
| 763 | try { |
no outgoing calls