Skip to content

feat(cli): add --data-dir flag to store CodeGraph data in a custom directory#568

Open
kkvcrobatz wants to merge 1 commit into
colbymchenry:mainfrom
kkvcrobatz:feat/configurable-data-dir
Open

feat(cli): add --data-dir flag to store CodeGraph data in a custom directory#568
kkvcrobatz wants to merge 1 commit into
colbymchenry:mainfrom
kkvcrobatz:feat/configurable-data-dir

Conversation

@kkvcrobatz
Copy link
Copy Markdown

Summary

  • All CLI commands (init, uninit, index, sync, status, query, files, context, callers,
    callees, impact, affected, serve) now accept --data-dir <path> to store CodeGraph data in a custom
    directory instead of the default <projectRoot>/.codegraph/
  • Useful when integrating CodeGraph as a bundled dependency and needing all artefacts under a single
    directory tree (e.g. knowledge/codegraph/)
  • The path can be absolute or relative to the project root; default behavior is fully unchanged

Closes #304, #452.

Changes

  • src/directory.tsgetCodeGraphDir() and all exported functions accept an optional dataDir?
    parameter
  • src/db/index.tsgetDatabasePath() threads dataDir through getCodeGraphDir()
  • src/mcp/daemon-paths.tsgetDaemonSocketPath() / getDaemonPidPath() accept dataDir?
  • src/index.tsInitOptions and OpenOptions gain dataDir?: string; threaded through init,
    initSync, open, openSync, uninitialize
  • src/bin/codegraph.ts — all subcommands gain --data-dir <path>

Test plan

  • 8 new unit tests in __tests__/configurable-data-dir.test.ts covering getCodeGraphDir and
    isInitialized with custom dataDir
  • All 8 new tests pass; existing test failures are pre-existing Windows EBUSY cleanup issues unrelated
    to this change (reproduce on main)

…rectory

All CLI commands (init, uninit, index, sync, status, query, files,
context, callers, callees, impact, affected, serve) now accept
--data-dir <path> to store the .codegraph/ database and artefacts in
a custom location instead of <projectRoot>/.codegraph/.

The path can be absolute or relative to the project root. Default
behavior (no flag) is unchanged — fully backward-compatible.

Also exposes dataDir via InitOptions and OpenOptions in the library
API, threads it through CodeGraph.init/open/openSync/uninitialize, and
updates getDatabasePath, getDaemonSocketPath, getDaemonPidPath.

Closes colbymchenry#304, colbymchenry#452.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Configurable .codegraph/ data directory location

1 participant