(dir: string, prefix: string)
| 15 | } |
| 16 | |
| 17 | async function collectFilesFromDirectory(dir: string, prefix: string): Promise<FileEntry[]> { |
| 18 | const files: FileEntry[] = [] |
| 19 | |
| 20 | const patterns = [ |
| 21 | "arctic.json", |
| 22 | "arctic.jsonc", |
| 23 | "config.json", |
| 24 | "agent/**/*.md", |
| 25 | "agents/**/*.md", |
| 26 | "command/**/*.md", |
| 27 | "commands/**/*.md", |
| 28 | "mode/*.md", |
| 29 | "plugin/*.ts", |
| 30 | "plugin/*.js", |
| 31 | "plugins/*.ts", |
| 32 | "plugins/*.js", |
| 33 | "package.json", |
| 34 | "bun.lock", |
| 35 | ] |
| 36 | |
| 37 | for (const pattern of patterns) { |
| 38 | const glob = new Bun.Glob(pattern) |
| 39 | for await (const item of glob.scan({ |
| 40 | absolute: true, |
| 41 | cwd: dir, |
| 42 | dot: true, |
| 43 | followSymlinks: true, |
| 44 | })) { |
| 45 | const file = Bun.file(item) |
| 46 | const exists = await file.exists() |
| 47 | if (!exists) continue |
| 48 | |
| 49 | const content = await file.arrayBuffer().catch(() => null) |
| 50 | if (!content) continue |
| 51 | |
| 52 | const relativePath = path.relative(dir, item) |
| 53 | files.push({ |
| 54 | path: item, |
| 55 | content: Buffer.from(content), |
| 56 | relativePath: path.join(prefix, relativePath), |
| 57 | }) |
| 58 | |
| 59 | log.debug("collected file", { path: item, relativePath: path.join(prefix, relativePath) }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return files |
| 64 | } |
| 65 | |
| 66 | async function collectFiles(): Promise<FileEntry[]> { |
| 67 | const files: FileEntry[] = [] |
no test coverage detected