Skip to content
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b6a00d
fix: scope codegraph batch complexity targets to file paths
carlos-alm Jul 5, 2026
b28051a
fix: exclude parameters and interface/type members from dead-role cla…
carlos-alm Jul 5, 2026
17fbcba
fix: credit import-type usages as exports consumers
carlos-alm Jul 5, 2026
26918bb
fix: prevent fn-impact/query crash when -f/--file is passed
carlos-alm Jul 5, 2026
be6432c
fix: correct exported-symbol detection for literal and object-literal…
carlos-alm Jul 5, 2026
4ead840
fix: exclude primitive type keywords from ast --kind string matching
carlos-alm Jul 5, 2026
f6326bf
fix: resolve call edges through renamed import specifiers
carlos-alm Jul 5, 2026
590f560
fix: couple file_hashes updates with edge regeneration in incremental…
carlos-alm Jul 5, 2026
d3ea4a4
fix: compare signature-change diffs using new-file line ranges
carlos-alm Jul 5, 2026
c306812
feat: add environment doctor check for stale native binary and missin…
carlos-alm Jul 5, 2026
8bb5893
fix: eliminate non-deterministic ordering in community detection
carlos-alm Jul 6, 2026
46037b1
fix: sync update-graph.sh hook extension allowlist with EXTENSIONS
carlos-alm Jul 6, 2026
6a84cf9
fix: recompute directory structure metrics for affected directories o…
carlos-alm Jul 6, 2026
8d936d1
refactor: register hardcoded execFileSync/execSync maxBuffer values i…
carlos-alm Jul 6, 2026
11c84be
fix: gate blast-radius check on newly introduced risk, not pre-existi…
carlos-alm Jul 6, 2026
963301a
fix: gate identifier-argument dynamic call edges on callback-acceptin…
carlos-alm Jul 6, 2026
3e8035d
fix: gate Array.from's callback arg by position, not just callee name
carlos-alm Jul 6, 2026
879635e
fix: scope reexportedSymbols to actually-named re-export specifiers
carlos-alm Jul 6, 2026
0fe9fc3
fix: stop CFG block/edge count from overriding AST-derived cyclomatic…
carlos-alm Jul 6, 2026
ccf3c19
fix: backfill edges.technique for incrementally-inserted calls edges
carlos-alm Jul 6, 2026
d5b1162
fix: wrap remote embedding JSON parse failure in EngineError
carlos-alm Jul 6, 2026
8971017
refactor: extract shared platform-default-path helper in config.ts
carlos-alm Jul 6, 2026
2180d2e
fix: resolve merge conflicts with main (docs check acknowledged)
carlos-alm Jul 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions src/infrastructure/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,34 @@ const _globalConfigCache = new Map<string, Record<string, unknown> | null>();

// ── Global config file location ─────────────────────────────────────────

/**
* Compute the platform-specific default global-config path, ignoring
* CODEGRAPH_USER_CONFIG and file existence — callers handle those separately.
* Shared by getDefaultUserConfigPath() and resolveUserConfigPath() (previously
* duplicated verbatim between the two — issue #1746).
*
* Priority:
* 1. $XDG_CONFIG_HOME/codegraph/config.json
* 2. %APPDATA%\codegraph\config.json (Windows)
* 3. ~/.config/codegraph/config.json (fallback; also the Windows fallback
* when %APPDATA% is unset)
*
* @param home Home directory to use for the fallback branches. Defaults to
* os.homedir(); accepted as a parameter so a caller that already computed
* it (e.g. to reuse for a legacy-path check) doesn't pay for a second call.
*/
function computePlatformDefaultConfigPath(home: string = os.homedir()): string {
const xdgConfig = process.env.XDG_CONFIG_HOME;
if (xdgConfig) return path.join(xdgConfig, 'codegraph', 'config.json');
if (process.platform === 'win32') {
const appdata = process.env.APPDATA;
return appdata
? path.join(appdata, 'codegraph', 'config.json')
: path.join(home, '.config', 'codegraph', 'config.json');
}
return path.join(home, '.config', 'codegraph', 'config.json');
}

/**
* Return the canonical path where a new global config file should be written.
*
Expand All @@ -294,17 +322,7 @@ const _globalConfigCache = new Map<string, Record<string, unknown> | null>();
export function getDefaultUserConfigPath(): string {
const envPath = process.env.CODEGRAPH_USER_CONFIG;
if (envPath) return envPath;

const home = os.homedir();
const xdgConfig = process.env.XDG_CONFIG_HOME;
if (xdgConfig) return path.join(xdgConfig, 'codegraph', 'config.json');
if (process.platform === 'win32') {
const appdata = process.env.APPDATA;
return appdata
? path.join(appdata, 'codegraph', 'config.json')
: path.join(home, '.config', 'codegraph', 'config.json');
}
return path.join(home, '.config', 'codegraph', 'config.json');
return computePlatformDefaultConfigPath();
}

/**
Expand All @@ -328,22 +346,7 @@ export function resolveUserConfigPath(): string | null {
}

const home = os.homedir();

// XDG_CONFIG_HOME takes priority on all platforms when explicitly set.
// Falls back to %APPDATA% on Windows, or ~/.config on Unix/macOS.
let platformDefault: string;
const xdgConfig = process.env.XDG_CONFIG_HOME;
if (xdgConfig) {
platformDefault = path.join(xdgConfig, 'codegraph', 'config.json');
} else if (process.platform === 'win32') {
const appdata = process.env.APPDATA;
platformDefault = appdata
? path.join(appdata, 'codegraph', 'config.json')
: path.join(home, '.config', 'codegraph', 'config.json');
} else {
platformDefault = path.join(home, '.config', 'codegraph', 'config.json');
}

const platformDefault = computePlatformDefaultConfigPath(home);
if (fs.existsSync(platformDefault)) return platformDefault;

const legacyPath = path.join(home, '.codegraph', 'config.json');
Expand Down
Loading