| 1 | import fs from "fs"; |
| 2 | |
| 3 | import ignore from "ignore"; |
| 4 | |
| 5 | import { getGlobalContinueIgnorePath } from "../util/paths"; |
| 6 | |
| 7 | export const DEFAULT_IGNORE_FILETYPES = [ |
| 8 | "*.DS_Store", |
| 9 | "*-lock.json", |
| 10 | "*.lock", |
| 11 | "*.log", |
| 12 | "*.ttf", |
| 13 | "*.png", |
| 14 | "*.jpg", |
| 15 | "*.jpeg", |
| 16 | "*.gif", |
| 17 | "*.mp4", |
| 18 | "*.svg", |
| 19 | "*.ico", |
| 20 | "*.pdf", |
| 21 | "*.zip", |
| 22 | "*.gz", |
| 23 | "*.tar", |
| 24 | "*.dmg", |
| 25 | "*.tgz", |
| 26 | "*.rar", |
| 27 | "*.7z", |
| 28 | "*.exe", |
| 29 | "*.dll", |
| 30 | "*.obj", |
| 31 | "*.o", |
| 32 | "*.o.d", |
| 33 | "*.a", |
| 34 | "*.lib", |
| 35 | "*.so", |
| 36 | "*.dylib", |
| 37 | "*.ncb", |
| 38 | "*.sdf", |
| 39 | "*.woff", |
| 40 | "*.woff2", |
| 41 | "*.eot", |
| 42 | "*.cur", |
| 43 | "*.avi", |
| 44 | "*.mpg", |
| 45 | "*.mpeg", |
| 46 | "*.mov", |
| 47 | "*.mp3", |
| 48 | "*.mp4", |
| 49 | "*.mkv", |
| 50 | "*.mkv", |
| 51 | "*.webm", |
| 52 | "*.jar", |
| 53 | "*.onnx", |
| 54 | "*.parquet", |
| 55 | "*.pqt", |
| 56 | "*.wav", |
| 57 | "*.webp", |
| 58 | "*.db", |
| 59 | "*.sqlite", |
| 60 | "*.wasm", |
| 61 | "*.plist", |
| 62 | "*.profraw", |
| 63 | "*.gcda", |
| 64 | "*.gcno", |
| 65 | "go.sum", |
| 66 | "*.env", |
| 67 | "*.gitignore", |
| 68 | "*.gitkeep", |
| 69 | "*.continueignore", |
| 70 | "config.json", |
| 71 | "config.yaml", |
| 72 | "*.csv", |
| 73 | "*.uasset", |
| 74 | "*.pdb", |
| 75 | "*.bin", |
| 76 | "*.pag", |
| 77 | "*.swp", |
| 78 | "*.jsonl", |
| 79 | // "*.prompt", // can be incredibly confusing for the LLM to have another set of instructions injected into the prompt |
| 80 | ]; |
| 81 | |
| 82 | export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES); |
| 83 | export const DEFAULT_IGNORE_DIRS = [ |
| 84 | ".git/", |
| 85 | ".svn/", |
| 86 | ".vscode/", |
| 87 | ".idea/", |
| 88 | ".vs/", |
| 89 | "venv/", |
| 90 | ".venv/", |
| 91 | "env/", |
| 92 | ".env/", |
| 93 | "node_modules/", |
| 94 | "dist/", |
| 95 | "build/", |
| 96 | "Build/", |
| 97 | "target/", |
| 98 | "out/", |
| 99 | "bin/", |
| 100 | ".pytest_cache/", |
| 101 | ".vscode-test/", |
| 102 | ".continue/", |
| 103 | "__pycache__/", |
| 104 | "site-packages/", |
| 105 | ".gradle/", |
| 106 | ".mvn/", |
| 107 | ".cache/", |
| 108 | "gems/", |
| 109 | "vendor/", |
| 110 | ]; |
| 111 | |
| 112 | export const defaultIgnoreDir = ignore().add(DEFAULT_IGNORE_DIRS); |
| 113 | |
| 114 | export const DEFAULT_IGNORE = |
| 115 | DEFAULT_IGNORE_FILETYPES.join("\n") + "\n" + DEFAULT_IGNORE_DIRS.join("\n"); |
| 116 | |
| 117 | export const defaultIgnoreFileAndDir = ignore() |
| 118 | .add(defaultIgnoreFile) |
| 119 | .add(defaultIgnoreDir); |
| 120 | |
| 121 | export function gitIgArrayFromFile(file: string) { |
| 122 | return file |
| 123 | .split(/\r?\n/) // Split on new line |
| 124 | .map((l) => l.trim()) // Remove whitespace |
| 125 | .filter((l) => !/^#|^$/.test(l)); // Remove empty lines |
| 126 | } |
| 127 | |
| 128 | export const getGlobalContinueIgArray = () => { |
| 129 | const contents = fs.readFileSync(getGlobalContinueIgnorePath(), "utf8"); |
| 130 | return gitIgArrayFromFile(contents); |
| 131 | }; |