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:
co-authored by
Claude Opus 4.7
parent
5b71a89574
commit
f6772dac7c
+6
-62
@@ -7,7 +7,6 @@
|
||||
|
||||
import * as path from 'path';
|
||||
import {
|
||||
CodeGraphConfig,
|
||||
Node,
|
||||
Edge,
|
||||
FileRecord,
|
||||
@@ -25,7 +24,6 @@ import {
|
||||
} from './types';
|
||||
import { DatabaseConnection, getDatabasePath } from './db';
|
||||
import { QueryBuilder } from './db/queries';
|
||||
import { loadConfig, saveConfig, createDefaultConfig } from './config';
|
||||
import {
|
||||
isInitialized,
|
||||
createDirectory,
|
||||
@@ -53,7 +51,6 @@ import { FileWatcher, WatchOptions } from './sync';
|
||||
// Re-export types for consumers
|
||||
export * from './types';
|
||||
export { getDatabasePath } from './db';
|
||||
export { getConfigPath } from './config';
|
||||
export {
|
||||
getCodeGraphDir,
|
||||
isInitialized,
|
||||
@@ -85,9 +82,6 @@ export { MCPServer } from './mcp';
|
||||
* Options for initializing a new CodeGraph project
|
||||
*/
|
||||
export interface InitOptions {
|
||||
/** Custom configuration overrides */
|
||||
config?: Partial<CodeGraphConfig>;
|
||||
|
||||
/** Whether to run initial indexing after init */
|
||||
index?: boolean;
|
||||
|
||||
@@ -128,7 +122,6 @@ export interface IndexOptions {
|
||||
export class CodeGraph {
|
||||
private db: DatabaseConnection;
|
||||
private queries: QueryBuilder;
|
||||
private config: CodeGraphConfig;
|
||||
private projectRoot: string;
|
||||
private orchestrator: ExtractionOrchestrator;
|
||||
private resolver: ReferenceResolver;
|
||||
@@ -148,17 +141,15 @@ export class CodeGraph {
|
||||
private constructor(
|
||||
db: DatabaseConnection,
|
||||
queries: QueryBuilder,
|
||||
config: CodeGraphConfig,
|
||||
projectRoot: string
|
||||
) {
|
||||
this.db = db;
|
||||
this.queries = queries;
|
||||
this.config = config;
|
||||
this.projectRoot = projectRoot;
|
||||
this.fileLock = new FileLock(
|
||||
path.join(projectRoot, '.codegraph', 'codegraph.lock')
|
||||
);
|
||||
this.orchestrator = new ExtractionOrchestrator(projectRoot, config, queries);
|
||||
this.orchestrator = new ExtractionOrchestrator(projectRoot, queries);
|
||||
this.resolver = createResolver(projectRoot, queries);
|
||||
this.graphManager = new GraphQueryManager(queries);
|
||||
this.traverser = new GraphTraverser(queries);
|
||||
@@ -194,19 +185,12 @@ export class CodeGraph {
|
||||
// Create directory structure
|
||||
createDirectory(resolvedRoot);
|
||||
|
||||
// Create and save configuration
|
||||
const config = createDefaultConfig(resolvedRoot);
|
||||
if (options.config) {
|
||||
Object.assign(config, options.config);
|
||||
}
|
||||
saveConfig(resolvedRoot, config);
|
||||
|
||||
// Initialize database
|
||||
const dbPath = getDatabasePath(resolvedRoot);
|
||||
const db = DatabaseConnection.initialize(dbPath);
|
||||
const queries = new QueryBuilder(db.getDb());
|
||||
|
||||
const instance = new CodeGraph(db, queries, config, resolvedRoot);
|
||||
const instance = new CodeGraph(db, queries, resolvedRoot);
|
||||
|
||||
// Run initial indexing if requested
|
||||
if (options.index) {
|
||||
@@ -219,7 +203,7 @@ export class CodeGraph {
|
||||
/**
|
||||
* Initialize synchronously (without indexing)
|
||||
*/
|
||||
static initSync(projectRoot: string, options: Omit<InitOptions, 'index' | 'onProgress'> = {}): CodeGraph {
|
||||
static initSync(projectRoot: string): CodeGraph {
|
||||
const resolvedRoot = path.resolve(projectRoot);
|
||||
|
||||
// Check if already initialized
|
||||
@@ -230,19 +214,12 @@ export class CodeGraph {
|
||||
// Create directory structure
|
||||
createDirectory(resolvedRoot);
|
||||
|
||||
// Create and save configuration
|
||||
const config = createDefaultConfig(resolvedRoot);
|
||||
if (options.config) {
|
||||
Object.assign(config, options.config);
|
||||
}
|
||||
saveConfig(resolvedRoot, config);
|
||||
|
||||
// Initialize database
|
||||
const dbPath = getDatabasePath(resolvedRoot);
|
||||
const db = DatabaseConnection.initialize(dbPath);
|
||||
const queries = new QueryBuilder(db.getDb());
|
||||
|
||||
return new CodeGraph(db, queries, config, resolvedRoot);
|
||||
return new CodeGraph(db, queries, resolvedRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,15 +244,12 @@ export class CodeGraph {
|
||||
throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
|
||||
}
|
||||
|
||||
// Load configuration
|
||||
const config = loadConfig(resolvedRoot);
|
||||
|
||||
// Open database
|
||||
const dbPath = getDatabasePath(resolvedRoot);
|
||||
const db = DatabaseConnection.open(dbPath);
|
||||
const queries = new QueryBuilder(db.getDb());
|
||||
|
||||
const instance = new CodeGraph(db, queries, config, resolvedRoot);
|
||||
const instance = new CodeGraph(db, queries, resolvedRoot);
|
||||
|
||||
// Sync if requested
|
||||
if (options.sync) {
|
||||
@@ -302,15 +276,12 @@ export class CodeGraph {
|
||||
throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
|
||||
}
|
||||
|
||||
// Load configuration
|
||||
const config = loadConfig(resolvedRoot);
|
||||
|
||||
// Open database
|
||||
const dbPath = getDatabasePath(resolvedRoot);
|
||||
const db = DatabaseConnection.open(dbPath);
|
||||
const queries = new QueryBuilder(db.getDb());
|
||||
|
||||
return new CodeGraph(db, queries, config, resolvedRoot);
|
||||
return new CodeGraph(db, queries, resolvedRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,32 +301,6 @@ export class CodeGraph {
|
||||
this.db.close();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Configuration
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* Get the current configuration
|
||||
*/
|
||||
getConfig(): CodeGraphConfig {
|
||||
return { ...this.config };
|
||||
}
|
||||
|
||||
/**
|
||||
* Update configuration
|
||||
*/
|
||||
updateConfig(updates: Partial<CodeGraphConfig>): void {
|
||||
Object.assign(this.config, updates);
|
||||
saveConfig(this.projectRoot, this.config);
|
||||
// Recreate orchestrator and resolver with new config
|
||||
this.orchestrator = new ExtractionOrchestrator(
|
||||
this.projectRoot,
|
||||
this.config,
|
||||
this.queries
|
||||
);
|
||||
this.resolver = createResolver(this.projectRoot, this.queries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the project root directory
|
||||
*/
|
||||
@@ -515,7 +460,6 @@ export class CodeGraph {
|
||||
|
||||
this.watcher = new FileWatcher(
|
||||
this.projectRoot,
|
||||
this.config,
|
||||
async () => {
|
||||
const result = await this.sync();
|
||||
const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
|
||||
|
||||
Reference in New Issue
Block a user