fix(cli): accept -d/--db on build to match every other DB-scoped command#1183
Conversation
Build silently wrote to `<dir>/.codegraph/graph.db` with no way to override while stats/query/where/watch all honor --db. The asymmetry blocked dogfooding workflows that need an isolated DB and surprised users who expected the flag to work everywhere. Wire opts.db through BuildGraphOpts.dbPath; setupPipeline resolves it absolute and falls back to the previous default. Mirrors watch's pattern (#987). Closes #1177.
|
Claude finished @carlos-alm's task —— View job PR Review Complete ✅Root Cause AnalysisProblem Being Solved: Legitimate UX inconsistency where Why This Approach: Mirrors the exact pattern used by the Risk Assessment: Very low risk - purely additive change with comprehensive tests and no modification of existing behavior. Backlog Compliance
Code Quality Assessment✅ Strengths:
✅ Architecture alignment:
✅ Testing quality:
Critical ConcernsNone. This is a well-executed, low-risk consistency fix. Final Recommendation
This PR should be merged. It resolves issue #1177 cleanly without introducing any technical debt or architectural concerns. |
Greptile SummaryCloses a UX gap where
Confidence Score: 5/5Safe to merge — the change is minimal and confined to option plumbing with no side-effects on existing defaults. The diff touches four files, all in straightforward ways: a new CLI flag, a one-field type extension, a two-line conditional in setupPipeline, and two integration tests. The default path is preserved exactly when --db is absent, so no existing workflow is affected. The native Rust orchestrator already consumed ctx.dbPath, so the override flows through both engines without any additional changes. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(cli): accept -d/--db on build to mat..." | Re-trigger Greptile |
Codegraph Impact Analysis3 functions changed → 6 callers affected across 5 files
|
Summary
codegraph build [dir] --db <path>was rejected witherror: unknown option '--db', even though every other DB-scoped command (stats,query,where,watch,snapshot, …) honors it. The asymmetry blocked dogfooding workflows that need an isolated DB and surprised users who reasonably expected the flag to work on the most DB-scoped command.-d, --db <path>tobuild, plumbs it throughBuildGraphOpts.dbPath, and letssetupPipelineresolve it absolute (falling back to<rootDir>/.codegraph/graph.db). Mirrorswatch's pattern from fix(watch): accept -d/--db to point at a graph.db outside cwd #987 verbatim.NativeDatabase.openReadWrite(ctx.dbPath)already drives the Rust side off the samectx.dbPath, so the override flows through both engines.Closes #1177.
Test plan
npx vitest run tests/integration/build.test.ts— 21/21 pass, including 2 new tests in thebuildGraph with custom dbPath (issue #1177)block (verifies DB lands at the custom path AND that<rootDir>/.codegraph/graph.dbis NOT created).npx vitest run tests/integration/cli.test.ts— 29/29 pass.tsc --noEmitclean.codegraph build <dir> --db /tmp/custom.dbwrites there;--helpshows the new flag with default annotation.Notes
The change journal still writes to
<rootDir>/.codegraph/journal.ndjsonregardless of--db, matchingwatch's existing precedent —--dboverrides the DB location only, not the project's.codegraph/directory. If full isolation is needed for dogfooding workflows, that's a small follow-up (the journal path is computed independently injournal.rsandjournal.ts).