Skip to content

Commit 9e5acc7

Browse files
authored
docs: update CLAUDE.md paths from .js to .ts after TypeScript migration (#601)
Fixes #585
1 parent a21a746 commit 9e5acc7

1 file changed

Lines changed: 49 additions & 49 deletions

File tree

CLAUDE.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ npm install # Install dependencies
5858
npm test # Run all tests (vitest)
5959
npm run test:watch # Watch mode
6060
npm run test:coverage # Coverage report
61-
npx vitest run tests/parsers/javascript.test.js # Single test file
61+
npx vitest run tests/parsers/javascript.test.ts # Single test file
6262
npx vitest run -t "finds cycles" # Single test by name
6363
npm run build:wasm # Rebuild WASM grammars from devDeps (built automatically on npm install)
6464
```
@@ -77,80 +77,80 @@ npm run release:dry-run # Preview what release would do without writing
7777

7878
**Pipeline:** Source files → tree-sitter parse → extract symbols → resolve imports → SQLite DB → query/search
7979

80-
JS source is plain JavaScript (ES modules) in `src/`. No transpilation step. The Rust native engine lives in `crates/codegraph-core/`.
80+
Source is TypeScript in `src/`, compiled via `tsup`. The Rust native engine lives in `crates/codegraph-core/`.
8181

8282
| Path | Role |
8383
|------|------|
84-
| `cli.js` | Commander CLI entry point (`bin.codegraph`) |
85-
| `index.js` | Programmatic API exports |
84+
| `cli.ts` | Commander CLI entry point (`bin.codegraph`) |
85+
| `index.ts` | Programmatic API exports |
8686
| **`shared/`** | **Cross-cutting constants and utilities** |
87-
| `shared/constants.js` | `EXTENSIONS` (derived from parser registry) and `IGNORE_DIRS` constants |
88-
| `shared/errors.js` | Domain error hierarchy (`CodegraphError`, `ConfigError`, `ParseError`, etc.) |
89-
| `shared/kinds.js` | Symbol and edge kind constants (`CORE_SYMBOL_KINDS`, `EVERY_SYMBOL_KIND`, `VALID_ROLES`) |
90-
| `shared/paginate.js` | Pagination helpers for bounded query results |
87+
| `shared/constants.ts` | `EXTENSIONS` (derived from parser registry) and `IGNORE_DIRS` constants |
88+
| `shared/errors.ts` | Domain error hierarchy (`CodegraphError`, `ConfigError`, `ParseError`, etc.) |
89+
| `shared/kinds.ts` | Symbol and edge kind constants (`CORE_SYMBOL_KINDS`, `EVERY_SYMBOL_KIND`, `VALID_ROLES`) |
90+
| `shared/paginate.ts` | Pagination helpers for bounded query results |
9191
| **`infrastructure/`** | **Platform and I/O plumbing** |
92-
| `infrastructure/config.js` | `.codegraphrc.json` loading, env overrides, `apiKeyCommand` secret resolution |
93-
| `infrastructure/logger.js` | Structured logging (`warn`, `debug`, `info`, `error`) |
94-
| `infrastructure/native.js` | Native napi-rs addon loader with WASM fallback |
95-
| `infrastructure/registry.js` | Global repo registry (`~/.codegraph/registry.json`) for multi-repo MCP |
96-
| `infrastructure/update-check.js` | npm update availability check |
92+
| `infrastructure/config.ts` | `.codegraphrc.json` loading, env overrides, `apiKeyCommand` secret resolution |
93+
| `infrastructure/logger.ts` | Structured logging (`warn`, `debug`, `info`, `error`) |
94+
| `infrastructure/native.ts` | Native napi-rs addon loader with WASM fallback |
95+
| `infrastructure/registry.ts` | Global repo registry (`~/.codegraph/registry.json`) for multi-repo MCP |
96+
| `infrastructure/update-check.ts` | npm update availability check |
9797
| **`db/`** | **Database layer** |
98-
| `db/index.js` | SQLite schema and operations (`better-sqlite3`) |
98+
| `db/index.ts` | SQLite schema and operations (`better-sqlite3`) |
9999
| **`domain/`** | **Core domain logic** |
100-
| `domain/parser.js` | tree-sitter WASM wrapper; `LANGUAGE_REGISTRY` + per-language extractors for functions, classes, methods, imports, exports, call sites |
101-
| `domain/queries.js` | Query functions: symbol search, file deps, impact analysis, diff-impact |
102-
| `domain/graph/builder.js` | Graph building: file collection, parsing, import resolution, incremental hashing |
103-
| `domain/graph/cycles.js` | Circular dependency detection (delegates to `graph/` subsystem) |
104-
| `domain/graph/resolve.js` | Import resolution (supports native batch mode) |
105-
| `domain/graph/watcher.js` | Watch mode for incremental rebuilds |
106-
| `domain/graph/journal.js` | Change journal for incremental builds |
107-
| `domain/graph/change-journal.js` | Change event tracking (NDJSON) |
100+
| `domain/parser.ts` | tree-sitter WASM wrapper; `LANGUAGE_REGISTRY` + per-language extractors for functions, classes, methods, imports, exports, call sites |
101+
| `domain/queries.ts` | Query functions: symbol search, file deps, impact analysis, diff-impact |
102+
| `domain/graph/builder.ts` | Graph building: file collection, parsing, import resolution, incremental hashing |
103+
| `domain/graph/cycles.ts` | Circular dependency detection (delegates to `graph/` subsystem) |
104+
| `domain/graph/resolve.ts` | Import resolution (supports native batch mode) |
105+
| `domain/graph/watcher.ts` | Watch mode for incremental rebuilds |
106+
| `domain/graph/journal.ts` | Change journal for incremental builds |
107+
| `domain/graph/change-journal.ts` | Change event tracking (NDJSON) |
108108
| `domain/analysis/` | Query-layer analysis: context, dependencies, exports, impact, module-map, roles, symbol-lookup |
109109
| `domain/search/` | Embedding subsystem: model management, vector generation, semantic/keyword/hybrid search, CLI formatting |
110110
| **`features/`** | **Composable feature modules** |
111-
| `features/audit.js` | Composite audit command: explain + impact + health in one call |
112-
| `features/batch.js` | Batch querying for multi-agent dispatch |
113-
| `features/boundaries.js` | Architecture boundary rules with onion architecture preset |
114-
| `features/cfg.js` | Control-flow graph generation |
115-
| `features/check.js` | CI validation predicates (cycles, complexity, blast radius, boundaries) |
116-
| `features/communities.js` | Louvain community detection, drift analysis (delegates to `graph/` subsystem) |
117-
| `features/complexity.js` | Cognitive, cyclomatic, Halstead, MI computation from AST |
118-
| `features/dataflow.js` | Dataflow analysis |
119-
| `features/export.js` | Graph export orchestration: loads data from DB, delegates to `presentation/` serializers |
120-
| `features/manifesto.js` | Configurable rule engine with warn/fail thresholds; CI gate |
121-
| `features/owners.js` | CODEOWNERS integration for ownership queries |
122-
| `features/sequence.js` | Sequence diagram data generation (BFS traversal) |
123-
| `features/snapshot.js` | SQLite DB backup and restore |
124-
| `features/structure.js` | Codebase structure analysis |
125-
| `features/triage.js` | Risk-ranked audit priority queue (delegates scoring to `graph/classifiers/`) |
126-
| `features/graph-enrichment.js` | Data enrichment for HTML viewer (complexity, communities, fan-in/out) |
111+
| `features/audit.ts` | Composite audit command: explain + impact + health in one call |
112+
| `features/batch.ts` | Batch querying for multi-agent dispatch |
113+
| `features/boundaries.ts` | Architecture boundary rules with onion architecture preset |
114+
| `features/cfg.ts` | Control-flow graph generation |
115+
| `features/check.ts` | CI validation predicates (cycles, complexity, blast radius, boundaries) |
116+
| `features/communities.ts` | Louvain community detection, drift analysis (delegates to `graph/` subsystem) |
117+
| `features/complexity.ts` | Cognitive, cyclomatic, Halstead, MI computation from AST |
118+
| `features/dataflow.ts` | Dataflow analysis |
119+
| `features/export.ts` | Graph export orchestration: loads data from DB, delegates to `presentation/` serializers |
120+
| `features/manifesto.ts` | Configurable rule engine with warn/fail thresholds; CI gate |
121+
| `features/owners.ts` | CODEOWNERS integration for ownership queries |
122+
| `features/sequence.ts` | Sequence diagram data generation (BFS traversal) |
123+
| `features/snapshot.ts` | SQLite DB backup and restore |
124+
| `features/structure.ts` | Codebase structure analysis |
125+
| `features/triage.ts` | Risk-ranked audit priority queue (delegates scoring to `graph/classifiers/`) |
126+
| `features/graph-enrichment.ts` | Data enrichment for HTML viewer (complexity, communities, fan-in/out) |
127127
| **`presentation/`** | **Pure output formatting + CLI command wrappers** |
128-
| `presentation/viewer.js` | Interactive HTML renderer with vis-network |
129-
| `presentation/queries-cli/` | CLI display wrappers for query functions, split by concern: `path.js`, `overview.js`, `inspect.js`, `impact.js`, `exports.js` |
130-
| `presentation/*.js` | Command formatters (audit, batch, check, communities, complexity, etc.) — call `features/*.js`, format output, set exit codes |
131-
| `presentation/export.js` | DOT/Mermaid/GraphML/Neo4j serializers |
132-
| `presentation/sequence-renderer.js` | Mermaid sequence diagram rendering |
133-
| `presentation/table.js`, `result-formatter.js`, `colors.js` | CLI table formatting, JSON/NDJSON output, color constants |
128+
| `presentation/viewer.ts` | Interactive HTML renderer with vis-network |
129+
| `presentation/queries-cli/` | CLI display wrappers for query functions, split by concern: `path.ts`, `overview.ts`, `inspect.ts`, `impact.ts`, `exports.ts` |
130+
| `presentation/*.ts` | Command formatters (audit, batch, check, communities, complexity, etc.) — call `features/*.ts`, format output, set exit codes |
131+
| `presentation/export.ts` | DOT/Mermaid/GraphML/Neo4j serializers |
132+
| `presentation/sequence-renderer.ts` | Mermaid sequence diagram rendering |
133+
| `presentation/table.ts`, `result-formatter.ts`, `colors.ts` | CLI table formatting, JSON/NDJSON output, color constants |
134134
| **`graph/`** | **Unified graph model** |
135-
| `graph/` | `CodeGraph` class (`model.js`), algorithms (Tarjan SCC, Louvain, BFS, shortest path, centrality), classifiers (role, risk), builders (dependency, structure, temporal) |
135+
| `graph/` | `CodeGraph` class (`model.ts`), algorithms (Tarjan SCC, Louvain, BFS, shortest path, centrality), classifiers (role, risk), builders (dependency, structure, temporal) |
136136
| **`mcp/`** | **MCP server** |
137137
| `mcp/` | MCP server exposing graph queries to AI agents; single-repo by default, `--multi-repo` to enable cross-repo access |
138-
| `ast-analysis/` | Unified AST analysis framework: shared DFS walker (`visitor.js`), engine orchestrator (`engine.js`), extracted metrics (`metrics.js`), and pluggable visitors for complexity, dataflow, and AST-store |
138+
| `ast-analysis/` | Unified AST analysis framework: shared DFS walker (`visitor.ts`), engine orchestrator (`engine.ts`), extracted metrics (`metrics.ts`), and pluggable visitors for complexity, dataflow, and AST-store |
139139

140140
**Key design decisions:**
141141
- **Dual-engine architecture:** Native Rust parsing via napi-rs (`crates/codegraph-core/`) with automatic fallback to WASM. Controlled by `--engine native|wasm|auto` (default: `auto`)
142142
- Platform-specific prebuilt binaries published as optional npm packages (`@optave/codegraph-{platform}-{arch}`)
143143
- WASM grammars are built from devDeps on `npm install` (via `prepare` script) and not committed to git — used as fallback when native addon is unavailable
144-
- **Language parser registry:** `LANGUAGE_REGISTRY` in `domain/parser.js` is the single source of truth for all supported languages — maps each language to `{ id, extensions, grammarFile, extractor, required }`. `EXTENSIONS` in `shared/constants.js` is derived from the registry. Adding a new language requires one registry entry + extractor function
145-
- **Node kinds:** `SYMBOL_KINDS` in `domain/queries.js` lists all valid kinds: `function`, `method`, `class`, `interface`, `type`, `struct`, `enum`, `trait`, `record`, `module`. Language-specific types use their native kind (e.g. Go structs → `struct`, Rust traits → `trait`, Ruby modules → `module`) rather than mapping everything to `class`/`interface`
144+
- **Language parser registry:** `LANGUAGE_REGISTRY` in `domain/parser.ts` is the single source of truth for all supported languages — maps each language to `{ id, extensions, grammarFile, extractor, required }`. `EXTENSIONS` in `shared/constants.ts` is derived from the registry. Adding a new language requires one registry entry + extractor function
145+
- **Node kinds:** `SYMBOL_KINDS` in `domain/queries.ts` lists all valid kinds: `function`, `method`, `class`, `interface`, `type`, `struct`, `enum`, `trait`, `record`, `module`. Language-specific types use their native kind (e.g. Go structs → `struct`, Rust traits → `trait`, Ruby modules → `module`) rather than mapping everything to `class`/`interface`
146146
- `@huggingface/transformers` and `@modelcontextprotocol/sdk` are optional dependencies, lazy-loaded
147147
- Non-required parsers (all except JS/TS/TSX) fail gracefully if their WASM grammar is unavailable
148148
- Import resolution uses a 6-level priority system with confidence scoring (import-aware → same-file → directory → parent → global → method hierarchy)
149149
- Incremental builds track file hashes in the DB to skip unchanged files
150150
- **MCP single-repo isolation:** `startMCPServer` defaults to single-repo mode — tools have no `repo` property and `list_repos` is not exposed. Passing `--multi-repo` or `--repos` to the CLI (or `options.multiRepo` / `options.allowedRepos` programmatically) enables multi-repo access. `buildToolList(multiRepo)` builds the tool list dynamically; the backward-compatible `TOOLS` export equals `buildToolList(true)`
151151
- **Credential resolution:** `loadConfig` pipeline is `mergeConfig → applyEnvOverrides → resolveSecrets`. The `apiKeyCommand` config field shells out to an external secret manager via `execFileSync` (no shell). Priority: command output > env var > file config > defaults. On failure, warns and falls back gracefully
152152

153-
**Configuration:** All tunable behavioral constants live in `DEFAULTS` in `src/infrastructure/config.js`, grouped by concern (`analysis`, `risk`, `search`, `display`, `community`, `structure`, `mcp`, `check`, `coChange`, `manifesto`). Users override via `.codegraphrc.json``mergeConfig` deep-merges recursively so partial overrides preserve sibling keys. Env vars override LLM settings (`CODEGRAPH_LLM_*`). When adding new behavioral constants, **always add them to `DEFAULTS`** and wire them through config — never introduce new hardcoded magic numbers in individual modules. Category F values (safety boundaries, standard formulas, platform concerns) are the only exception.
153+
**Configuration:** All tunable behavioral constants live in `DEFAULTS` in `src/infrastructure/config.ts`, grouped by concern (`analysis`, `risk`, `search`, `display`, `community`, `structure`, `mcp`, `check`, `coChange`, `manifesto`). Users override via `.codegraphrc.json``mergeConfig` deep-merges recursively so partial overrides preserve sibling keys. Env vars override LLM settings (`CODEGRAPH_LLM_*`). When adding new behavioral constants, **always add them to `DEFAULTS`** and wire them through config — never introduce new hardcoded magic numbers in individual modules. Category F values (safety boundaries, standard formulas, platform concerns) are the only exception.
154154

155155
**Database:** SQLite at `.codegraph/graph.db` with tables: `nodes`, `edges`, `metadata`, `embeddings`, `function_complexity`
156156

0 commit comments

Comments
 (0)