Created
May 14, 2025 11:21
-
-
Save SanariSan/e760f868586ee59cf4e4eff51d4d0daa to your computer and use it in GitHub Desktop.
Recursively clip code files with path prepend (for ai to get proj summary)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { appendFileSync, readFileSync } from 'fs'; | |
import { readdir } from 'fs/promises'; | |
import { join } from 'path'; | |
const ROOT = './src'; | |
const OUT = 'samples_clipped.txt'; | |
const init = async () => { | |
const entries = await readdir(ROOT, { | |
recursive: true, | |
withFileTypes: true, | |
}); | |
const files = entries.filter((e) => e.isFile()); | |
for (const entry of files) { | |
const fullPath = join(entry.parentPath, entry.name); | |
const content = readFileSync(fullPath, 'utf-8'); | |
const out = `/*start of file [${fullPath}]*/\n` + content; | |
appendFileSync(OUT, out + `/*end of file [${fullPath}]*/\n\n`); | |
} | |
}; | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment