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

Function validateDirectory

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

Source from the content-addressed store, hash-verified

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