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

Function codeGraphDirName

src/directory.ts:43–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 * project root itself; we warn once to stderr so the misconfiguration is seen.
42 */
43export function codeGraphDirName(): string {
44 const raw = process.env.CODEGRAPH_DIR?.trim();
45 if (!raw) return DEFAULT_CODEGRAPH_DIR;
46 const invalid =
47 raw === '.' ||
48 raw.includes('..') ||
49 raw.includes('/') ||
50 raw.includes('\\') ||
51 path.isAbsolute(raw);
52 if (invalid) {
53 if (!warnedBadDirName) {
54 warnedBadDirName = true;
55 // stderr only — stdout is the MCP protocol channel.
56 console.warn(
57 `[codegraph] Ignoring invalid CODEGRAPH_DIR="${raw}" — it must be a plain ` +
58 `directory name (no path separators, no "..", not absolute). Using "${DEFAULT_CODEGRAPH_DIR}".`
59 );
60 }
61 return DEFAULT_CODEGRAPH_DIR;
62 }
63 return raw;
64}
65
66/**
67 * CodeGraph directory name — a load-time snapshot of {@link codeGraphDirName}.

Callers 5

runInitFunction · 0.90
foundation.test.tsFile · 0.90
directory.tsFile · 0.85
isCodeGraphDataDirFunction · 0.85
codeGraphDirNameForFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected