From 276dffdc1dbbc0dd081bd1d46506b1119a43e3f5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 28 Feb 2026 01:05:01 -0700 Subject: [PATCH 1/4] fix(bench): remove unnecessary shell: true from execFileSync execFileSync already receives args as an array, so shell: true is redundant and a minor security anti-pattern. Addresses Greptile review. Impact: 1 functions changed, 0 affected --- scripts/lib/bench-config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/lib/bench-config.js b/scripts/lib/bench-config.js index 804a6b3f..241a6254 100644 --- a/scripts/lib/bench-config.js +++ b/scripts/lib/bench-config.js @@ -70,7 +70,6 @@ export async function resolveBenchmarkSource() { cwd: tmpDir, stdio: 'pipe', timeout: 120_000, - shell: true, }); break; } catch (err) { From e474497e41ea246a366d44c07b9f3c8217be6791 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Sat, 28 Feb 2026 01:28:00 -0700 Subject: [PATCH 2/4] refactor!: merge `fn` into `query`, fold `models` into `embed --models` Reduce CLI surface by consolidating two redundant commands: - `query` now calls fnDeps() with --depth, --file, --kind options (previously just queryName with basic output) - `embed --models` replaces the standalone `models` command - `fn` and `models` commands removed from CLI - MCP tools, programmatic API, and fn-impact unchanged BREAKING CHANGE: `codegraph fn` removed (use `codegraph query`), `codegraph models` removed (use `codegraph embed --models`). --- CLAUDE.md | 2 +- FOUNDATION.md | 2 +- README.md | 14 +++---- src/cli.js | 73 ++++++++++++++--------------------- tests/integration/cli.test.js | 6 +-- 5 files changed, 40 insertions(+), 57 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f76eb2dc..31a3a361 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -119,7 +119,7 @@ Codegraph is **our own tool**. Use it to analyze this repository before making c node src/cli.js build . # Build/update the graph (incremental) node src/cli.js map --limit 20 # Module overview & most-connected nodes node src/cli.js stats # Graph health and quality score -node src/cli.js fn -T # Function call chain (callers + callees) +node src/cli.js query -T # Function call chain (callers + callees) node src/cli.js deps src/.js # File-level imports and importers node src/cli.js diff-impact main # Impact of current branch vs main node src/cli.js complexity -T # Per-function complexity metrics diff --git a/FOUNDATION.md b/FOUNDATION.md index 44458aea..3158f388 100644 --- a/FOUNDATION.md +++ b/FOUNDATION.md @@ -62,7 +62,7 @@ LLM-powered features (richer embeddings, semantic search, AI-enhanced analysis) This dual-mode approach is unique in the competitive landscape. Competitors either require cloud APIs for core functionality (code-graph-rag, autodev-codebase) or offer no AI enhancement at all (CKB, axon, arbor). Nobody else offers both modes in one tool. -*Test: does every core command (`build`, `query`, `fn`, `deps`, `impact`, `diff-impact`, `cycles`, `map`) work with zero API keys? Are LLM features additive, never blocking?* +*Test: does every core command (`build`, `query`, `deps`, `impact`, `diff-impact`, `cycles`, `map`) work with zero API keys? Are LLM features additive, never blocking?* ### 5. Embeddable first, CLI second diff --git a/README.md b/README.md index c0b8866d..656924cc 100644 --- a/README.md +++ b/README.md @@ -217,8 +217,8 @@ codegraph explain # Function summary: signature, calls, callers, te ```bash codegraph impact # Transitive reverse dependency trace -codegraph fn # Function-level: callers, callees, call chain -codegraph fn --no-tests --depth 5 +codegraph query --no-tests # Function-level: callers, callees, call chain +codegraph query --no-tests --depth 5 codegraph fn-impact # What functions break if this one changes codegraph path # Shortest path between two symbols (A calls...calls B) codegraph path --reverse # Follow edges backward @@ -287,7 +287,7 @@ codegraph embed # Build embeddings (default: nomic-v1.5) codegraph embed --model nomic # Use a different model codegraph search "handle authentication" codegraph search "parse config" --min-score 0.4 -n 10 -codegraph models # List available models +codegraph embed --models # List available models ``` #### Multi-query search @@ -336,13 +336,13 @@ codegraph registry remove # Unregister | Flag | Description | |---|---| | `-d, --db ` | Custom path to `graph.db` | -| `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files (available on `fn`, `fn-impact`, `path`, `context`, `explain`, `where`, `diff-impact`, `search`, `map`, `hotspots`, `roles`, `co-change`, `deps`, `impact`, `complexity`, `communities`, `manifesto`) | +| `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files (available on `query`, `fn-impact`, `path`, `context`, `explain`, `where`, `diff-impact`, `search`, `map`, `hotspots`, `roles`, `co-change`, `deps`, `impact`, `complexity`, `communities`, `manifesto`) | | `--depth ` | Transitive trace depth (default varies by command) | | `-j, --json` | Output as JSON | | `-v, --verbose` | Enable debug output | | `--engine ` | Parser engine: `native`, `wasm`, or `auto` (default: `auto`) | -| `-k, --kind ` | Filter by kind: `function`, `method`, `class`, `struct`, `enum`, `trait`, `record`, `module` (`fn`, `context`, `search`) | -| `-f, --file ` | Scope to a specific file (`fn`, `context`, `where`) | +| `-k, --kind ` | Filter by kind: `function`, `method`, `class`, `struct`, `enum`, `trait`, `record`, `module` (`query`, `context`, `search`) | +| `-f, --file ` | Scope to a specific file (`query`, `context`, `where`) | | `--rrf-k ` | RRF smoothing constant for multi-query search (default 60) | ## 🌐 Language Support @@ -485,7 +485,7 @@ This project uses codegraph. The database is at `.codegraph/graph.db`. ### Other useful commands - `codegraph build .` — rebuild the graph (incremental by default) - `codegraph map` — module overview -- `codegraph fn -T` — function call chain +- `codegraph query -T` — function call chain - `codegraph path -T` — shortest call path between two symbols - `codegraph deps ` — file-level dependencies - `codegraph roles --role dead -T` — find dead code (unreferenced symbols) diff --git a/src/cli.js b/src/cli.js index 1c77ab83..ec3e9ce4 100644 --- a/src/cli.js +++ b/src/cli.js @@ -26,7 +26,6 @@ import { fnImpact, impactAnalysis, moduleMap, - queryName, roles, stats, symbolPath, @@ -95,8 +94,11 @@ program program .command('query ') - .description('Find a function/class, show callers and callees') + .description('Find a function/class — callers, callees, and transitive call chain') .option('-d, --db ', 'Path to graph.db') + .option('--depth ', 'Transitive caller depth', '3') + .option('-f, --file ', 'Scope search to functions in this file (partial match)') + .option('-k, --kind ', 'Filter to a specific symbol kind') .option('-T, --no-tests', 'Exclude test/spec files from results') .option('--include-tests', 'Include test/spec files (overrides excludeTests config)') .option('-j, --json', 'Output as JSON') @@ -104,7 +106,14 @@ program .option('--offset ', 'Skip N results (default: 0)') .option('--ndjson', 'Newline-delimited JSON output') .action((name, opts) => { - queryName(name, opts.db, { + if (opts.kind && !ALL_SYMBOL_KINDS.includes(opts.kind)) { + console.error(`Invalid kind "${opts.kind}". Valid: ${ALL_SYMBOL_KINDS.join(', ')}`); + process.exit(1); + } + fnDeps(name, opts.db, { + depth: parseInt(opts.depth, 10), + file: opts.file, + kind: opts.kind, noTests: resolveNoTests(opts), json: opts.json, limit: opts.limit ? parseInt(opts.limit, 10) : undefined, @@ -161,30 +170,6 @@ program fileDeps(file, opts.db, { noTests: resolveNoTests(opts), json: opts.json }); }); -program - .command('fn ') - .description('Function-level dependencies: callers, callees, and transitive call chain') - .option('-d, --db ', 'Path to graph.db') - .option('--depth ', 'Transitive caller depth', '3') - .option('-f, --file ', 'Scope search to functions in this file (partial match)') - .option('-k, --kind ', 'Filter to a specific symbol kind') - .option('-T, --no-tests', 'Exclude test/spec files from results') - .option('--include-tests', 'Include test/spec files (overrides excludeTests config)') - .option('-j, --json', 'Output as JSON') - .action((name, opts) => { - if (opts.kind && !ALL_SYMBOL_KINDS.includes(opts.kind)) { - console.error(`Invalid kind "${opts.kind}". Valid: ${ALL_SYMBOL_KINDS.join(', ')}`); - process.exit(1); - } - fnDeps(name, opts.db, { - depth: parseInt(opts.depth, 10), - file: opts.file, - kind: opts.kind, - noTests: resolveNoTests(opts), - json: opts.json, - }); - }); - program .command('fn-impact ') .description('Function-level impact: what functions break if this one changes') @@ -489,23 +474,6 @@ registry // ─── Embedding commands ───────────────────────────────────────────────── -program - .command('models') - .description('List available embedding models') - .action(() => { - const defaultModel = config.embeddings?.model || DEFAULT_MODEL; - console.log('\nAvailable embedding models:\n'); - for (const [key, cfg] of Object.entries(MODELS)) { - const def = key === defaultModel ? ' (default)' : ''; - const ctx = cfg.contextWindow ? `${cfg.contextWindow} ctx` : ''; - console.log( - ` ${key.padEnd(12)} ${String(cfg.dim).padStart(4)}d ${ctx.padEnd(9)} ${cfg.desc}${def}`, - ); - } - console.log('\nUsage: codegraph embed --model --strategy '); - console.log(' codegraph search "query" --model \n'); - }); - program .command('embed [dir]') .description( @@ -513,15 +481,30 @@ program ) .option( '-m, --model ', - 'Embedding model (default from config or minilm). Run `codegraph models` for details', + 'Embedding model (default from config or minilm). Use `--models` to list available models', ) .option( '-s, --strategy ', `Embedding strategy: ${EMBEDDING_STRATEGIES.join(', ')}. "structured" uses graph context (callers/callees), "source" embeds raw code`, 'structured', ) + .option('--models', 'List available embedding models and exit') .option('-d, --db ', 'Path to graph.db') .action(async (dir, opts) => { + if (opts.models) { + const defaultModel = config.embeddings?.model || DEFAULT_MODEL; + console.log('\nAvailable embedding models:\n'); + for (const [key, cfg] of Object.entries(MODELS)) { + const def = key === defaultModel ? ' (default)' : ''; + const ctx = cfg.contextWindow ? `${cfg.contextWindow} ctx` : ''; + console.log( + ` ${key.padEnd(12)} ${String(cfg.dim).padStart(4)}d ${ctx.padEnd(9)} ${cfg.desc}${def}`, + ); + } + console.log('\nUsage: codegraph embed --model --strategy '); + console.log(' codegraph search "query" --model \n'); + return; + } if (!EMBEDDING_STRATEGIES.includes(opts.strategy)) { console.error( `Unknown strategy: ${opts.strategy}. Available: ${EMBEDDING_STRATEGIES.join(', ')}`, diff --git a/tests/integration/cli.test.js b/tests/integration/cli.test.js index 10eac6d2..45f82c03 100644 --- a/tests/integration/cli.test.js +++ b/tests/integration/cli.test.js @@ -101,9 +101,9 @@ describe('CLI smoke tests', () => { expect(data).toHaveProperty('results'); }); - // ─── Fn ────────────────────────────────────────────────────────────── - test('fn --json returns valid JSON with results', () => { - const out = run('fn', 'add', '--db', dbPath, '--json'); + // ─── Query (fn-level) ─────────────────────────────────────────────── + test('query --json returns fn-level results with depth', () => { + const out = run('query', 'add', '--db', dbPath, '--json'); const data = JSON.parse(out); expect(data).toHaveProperty('results'); }); From 6bf2d8836e1c9cf125b780f895ae20b689edd7eb Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Sat, 28 Feb 2026 01:41:32 -0700 Subject: [PATCH 3/4] docs: add CHANGELOG entry for 2.5.1 patch release --- CHANGELOG.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2d064e..5acc529a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,30 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [2.5.1](https://github.com/optave/codegraph/compare/v2.5.0...v2.5.1) (2026-02-28) + +**Critical fix: recover missing `branch-compare` command and broken programmatic API.** The `branch-compare` command and its implementation file were never committed in v2.5.0, causing `codegraph branch-compare` to crash and `import('@optave/codegraph')` to fail entirely due to a top-level re-export of the missing module. This patch recovers the full implementation (568 lines), adds an export guard test to prevent regressions, and introduces `--dry-run` for `registry prune`. + +### Bug Fixes + +* **cli:** recover `branch-compare` implementation — command was registered in cli.js and index.js but `src/branch-compare.js` was never committed, crashing both the CLI command and the entire programmatic API ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4), [3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) +* **registry:** add `--dry-run` flag to `registry prune` — preview what would be removed without deleting entries ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) +* **bench:** remove unnecessary `shell: true` from `execFileSync` — minor security hardening ([14d03ce](https://github.com/optave/codegraph/commit/14d03ce)) +* **docs:** correct dogfood benchmark data from stale v2.4.0 native binary — native complexity was reported as 2.2x slower than WASM when it's actually 47x faster ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) +* **skill:** add native binary version check to dogfood benchmark phase to prevent stale binary misreports ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) + +### Testing + +* add `index-exports` unit test — validates all re-exports in index.js resolve without `ERR_MODULE_NOT_FOUND` ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) +* add `branch-compare` integration tests (7 tests, 192 lines) ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) +* add `registry prune --dry-run` unit tests ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) + +### Documentation + +* update build performance benchmarks for 2.5.0 ([eb52074](https://github.com/optave/codegraph/commit/eb52074)) +* add dogfood report for v2.5.0 ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) +* reframe Principle 5 from library-first to CLI-first identity ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) + ## [2.5.0](https://github.com/optave/codegraph/compare/v2.4.0...v2.5.0) (2026-02-27) **Complexity analysis, community detection, execution flow tracing, and manifesto rule engine.** This release adds a full code quality suite — cognitive, cyclomatic, Halstead, and Maintainability Index metrics for all 11 supported languages — with native Rust parity for maximum performance. Louvain community detection surfaces module boundaries and drift. A configurable manifesto rule engine enables CI-gated quality thresholds. Execution flow tracing lets you follow call paths through the codebase. Dev builds now publish as GitHub pre-releases instead of npm. From 2528e43e4da6141fcf3528bc84d0f9ce8aa51483 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Sat, 28 Feb 2026 01:45:52 -0700 Subject: [PATCH 4/4] Revert "docs: add CHANGELOG entry for 2.5.1 patch release" This reverts commit 6bf2d8836e1c9cf125b780f895ae20b689edd7eb. --- CHANGELOG.md | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5acc529a..3e2d064e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,30 +2,6 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. -## [2.5.1](https://github.com/optave/codegraph/compare/v2.5.0...v2.5.1) (2026-02-28) - -**Critical fix: recover missing `branch-compare` command and broken programmatic API.** The `branch-compare` command and its implementation file were never committed in v2.5.0, causing `codegraph branch-compare` to crash and `import('@optave/codegraph')` to fail entirely due to a top-level re-export of the missing module. This patch recovers the full implementation (568 lines), adds an export guard test to prevent regressions, and introduces `--dry-run` for `registry prune`. - -### Bug Fixes - -* **cli:** recover `branch-compare` implementation — command was registered in cli.js and index.js but `src/branch-compare.js` was never committed, crashing both the CLI command and the entire programmatic API ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4), [3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) -* **registry:** add `--dry-run` flag to `registry prune` — preview what would be removed without deleting entries ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) -* **bench:** remove unnecessary `shell: true` from `execFileSync` — minor security hardening ([14d03ce](https://github.com/optave/codegraph/commit/14d03ce)) -* **docs:** correct dogfood benchmark data from stale v2.4.0 native binary — native complexity was reported as 2.2x slower than WASM when it's actually 47x faster ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) -* **skill:** add native binary version check to dogfood benchmark phase to prevent stale binary misreports ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) - -### Testing - -* add `index-exports` unit test — validates all re-exports in index.js resolve without `ERR_MODULE_NOT_FOUND` ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) -* add `branch-compare` integration tests (7 tests, 192 lines) ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) -* add `registry prune --dry-run` unit tests ([2ee10d4](https://github.com/optave/codegraph/commit/2ee10d4)) - -### Documentation - -* update build performance benchmarks for 2.5.0 ([eb52074](https://github.com/optave/codegraph/commit/eb52074)) -* add dogfood report for v2.5.0 ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) -* reframe Principle 5 from library-first to CLI-first identity ([3d1224d](https://github.com/optave/codegraph/commit/3d1224d)) - ## [2.5.0](https://github.com/optave/codegraph/compare/v2.4.0...v2.5.0) (2026-02-27) **Complexity analysis, community detection, execution flow tracing, and manifesto rule engine.** This release adds a full code quality suite — cognitive, cyclomatic, Halstead, and Maintainability Index metrics for all 11 supported languages — with native Rust parity for maximum performance. Louvain community detection surfaces module boundaries and drift. A configurable manifesto rule engine enables CI-gated quality thresholds. Execution flow tracing lets you follow call paths through the codebase. Dev builds now publish as GitHub pre-releases instead of npm.