MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / validateDirectory

Function validateDirectory

src/directory.ts:1156–1188  ·  view source on GitHub ↗
(projectRoot: string)

Source from the content-addressed store, hash-verified

1154 * Check if the .codegraph directory has valid structure
1155 */
1156export function validateDirectory(projectRoot: string): {
1157 valid: boolean;
1158 errors: string[];
1159} {
1160 const errors: string[] = [];
1161 const codegraphDir = getCodeGraphDir(projectRoot);
1162
1163 if (!fs.existsSync(codegraphDir)) {
1164 errors.push('CodeGraph directory does not exist');
1165 return { valid: false, errors };
1166 }
1167
1168 if (!fs.statSync(codegraphDir).isDirectory()) {
1169 errors.push('.codegraph exists but is not a directory');
1170 return { valid: false, errors };
1171 }
1172
1173 // Auto-repair / upgrade .gitignore (non-critical file). A missing one is
1174 // recreated; a stale pre-wildcard default that never ignored daemon.pid is
1175 // regenerated in place (issue #788); a user-authored file is left alone.
1176 const gitignorePath = path.join(codegraphDir, '.gitignore');
1177 const existedBefore = fs.existsSync(gitignorePath);
1178 if (!ensureGitignore(gitignorePath) && !existedBefore) {
1179 // Only a missing-and-uncreatable file is surfaced; a failed in-place
1180 // upgrade of an existing file is non-fatal — the index still works.
1181 errors.push('.gitignore missing in .codegraph directory and could not be created');
1182 }
1183
1184 return {
1185 valid: errors.length === 0,
1186 errors,
1187 };
1188}
1189
1190/**
1191 * Claude Code injects `<task-notification>…</task-notification>` blocks as

Callers 3

openMethod · 0.90
openSyncMethod · 0.90
foundation.test.tsFile · 0.90

Calls 4

getCodeGraphDirFunction · 0.85
ensureGitignoreFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected