feat: zero-config indexing driven by .gitignore (#283) (#285)

Remove .codegraph/config.json and the entire config surface. CodeGraph now
indexes every file whose extension maps to a supported language and respects
.gitignore everywhere — git repos via git itself, non-git projects via the
`ignore` library (root + nested .gitignore files, the same way git does).

- Remove CodeGraphConfig/DEFAULT_CONFIG, src/config.ts, and the public config
  API (the `config` option on init, getConfig/updateConfig/getConfigPath).
- Derive the source-file allowlist from EXTENSION_MAP (isSourceFile); maxFileSize
  is now a constant. Drop the .codegraphignore marker.
- Behavior change: committed, non-gitignored dirs (vendor/, a committed dist/)
  are now indexed — .gitignore is the single source of truth.

Earlier inert fields (languages, frameworks, extractDocstrings, trackCallSites,
customPatterns) and their dead helpers are removed as part of this.

Resolves #283.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-05-21 18:06:02 -05:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 5b71a89574
commit f6772dac7c
16 changed files with 223 additions and 996 deletions
+1 -67
View File
@@ -9,8 +9,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { CodeGraph } from '../src';
import { DEFAULT_CONFIG, Node, Edge } from '../src/types';
import { loadConfig, saveConfig } from '../src/config';
import { Node, Edge } from '../src/types';
import { isInitialized, getCodeGraphDir, validateDirectory } from '../src/directory';
import { DatabaseConnection, getDatabasePath } from '../src/db';
@@ -60,41 +59,12 @@ describe('CodeGraph Foundation', () => {
cg.close();
});
it('should create config.json with defaults', () => {
const cg = CodeGraph.initSync(tempDir);
const configPath = path.join(getCodeGraphDir(tempDir), 'config.json');
expect(fs.existsSync(configPath)).toBe(true);
const config = cg.getConfig();
expect(config.version).toBe(DEFAULT_CONFIG.version);
expect(config.include).toEqual(DEFAULT_CONFIG.include);
expect(config.exclude).toEqual(DEFAULT_CONFIG.exclude);
cg.close();
});
it('should throw if already initialized', () => {
const cg = CodeGraph.initSync(tempDir);
cg.close();
expect(() => CodeGraph.initSync(tempDir)).toThrow(/already initialized/i);
});
it('should accept custom config options', () => {
const cg = CodeGraph.initSync(tempDir, {
config: {
maxFileSize: 500000,
extractDocstrings: false,
},
});
const config = cg.getConfig();
expect(config.maxFileSize).toBe(500000);
expect(config.extractDocstrings).toBe(false);
cg.close();
});
});
describe('Opening Projects', () => {
@@ -112,17 +82,6 @@ describe('CodeGraph Foundation', () => {
it('should throw if not initialized', () => {
expect(() => CodeGraph.openSync(tempDir)).toThrow(/not initialized/i);
});
it('should preserve configuration across open/close', () => {
const cg1 = CodeGraph.initSync(tempDir, {
config: { maxFileSize: 123456 },
});
cg1.close();
const cg2 = CodeGraph.openSync(tempDir);
expect(cg2.getConfig().maxFileSize).toBe(123456);
cg2.close();
});
});
describe('Static Methods', () => {
@@ -182,31 +141,6 @@ describe('CodeGraph Foundation', () => {
});
});
describe('Configuration', () => {
it('should load and merge config with defaults', () => {
const cg = CodeGraph.initSync(tempDir);
cg.close();
const config = loadConfig(tempDir);
expect(config.version).toBe(DEFAULT_CONFIG.version);
expect(config.rootDir).toBe(path.resolve(tempDir));
});
it('should update configuration', () => {
const cg = CodeGraph.initSync(tempDir);
cg.updateConfig({ maxFileSize: 999999 });
expect(cg.getConfig().maxFileSize).toBe(999999);
cg.close();
// Verify persistence
const config = loadConfig(tempDir);
expect(config.maxFileSize).toBe(999999);
});
});
describe('Directory Management', () => {
it('should validate directory structure', () => {
const cg = CodeGraph.initSync(tempDir);