(dir: string)
| 298 | const chunks: string[] = []; |
| 299 | |
| 300 | async function walk(dir: string): Promise<void> { |
| 301 | let entries: import('fs').Dirent[]; |
| 302 | try { entries = await fs.readdir(dir, { withFileTypes: true }); } catch { return; } |
| 303 | for (const e of entries) { |
| 304 | if (total >= MAX_TOTAL) return; |
| 305 | const full = path.join(dir, e.name); |
| 306 | if (e.isDirectory()) { |
| 307 | if (!SKIP_DIR.has(e.name)) await walk(full); |
| 308 | continue; |
| 309 | } |
| 310 | const ext = path.extname(e.name).toLowerCase(); |
| 311 | // SKILL.md has no "code" ext but is always scanned; otherwise gate by ext. |
| 312 | if (e.name !== 'SKILL.md' && !SCAN_EXT.has(ext)) continue; |
| 313 | try { |
| 314 | const stat = await fs.stat(full); |
| 315 | if (stat.size > MAX_FILE) continue; |
| 316 | const text = await fs.readFile(full, 'utf-8'); |
| 317 | chunks.push(`\n# ── ${path.relative(root, full)} ──\n${text}`); |
| 318 | total += text.length; |
| 319 | } catch { /* skip unreadable */ } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | await walk(root); |
| 324 | return chunks.join('\n'); |
no test coverage detected