4.2 KiB
Logseq CLI Default Paths Move Plan
Goal: Move the default --data-dir location to ~/logseq/cli-graphs and the default cli.edn location to ~/logseq/cli.edn, keeping logseq-cli and db-worker-node consistent.
Architecture: logseq-cli resolves defaults in logseq.cli.config and logseq.cli.data-dir, then hands data-dir into logseq.cli.server which spawns and manages db-worker-node. db-worker-node itself also resolves data-dir for logs, locks, and SQLite storage via frontend.worker.platform.node and frontend.worker.db-worker-node-lock.
Tech Stack: ClojureScript, Node.js fs/path, logseq-cli, db-worker-node.
Problem statement
Defaults currently live under ~/.logseq/, but CLI data is not the same as desktop app data and should live under ~/logseq/ for better discoverability and separation. We need to update the defaults in both logseq-cli and db-worker-node, and update docs/help text to match.
Current behavior summary
- logseq-cli uses
~/logseq/cli-graphsas the default data dir. - db-worker-node help text and internal resolution also default to
~/logseq/cli-graphs. - logseq-cli defaults config path to
~/logseq/cli.edn. - Docs reference
~/logseq/cli.ednand~/logseq/cli-graphs.
Requirements
- Default
data-dirbecomes~/logseq/cli-graphseverywhere it is derived. - Default config path becomes
~/logseq/cli.edn. --data-dirand--configflags continue to override defaults.LOGSEQ_CLI_DATA_DIRandLOGSEQ_CLI_CONFIG(if present) continue to override defaults.- Help text and docs must match the new defaults.
Non-goals
- Do not migrate existing data automatically.
- Do not change CLI flags, env var names, or db-worker-node storage layout.
- Do not change runtime behavior beyond the default locations.
Design decisions
- Keep default paths defined in a single place per subsystem (CLI vs db-worker-node), but ensure they resolve to the same new location.
- Do not auto-detect the old location as a fallback to avoid surprises; users can pass
--data-dir/--configexplicitly if needed. - Document the change and provide a brief migration note in CLI docs.
Implementation plan
1) Update default data-dir constants and resolution
src/main/logseq/cli/data_dir.cljs- Change
default-data-dirfrom~/logseq/cli-graphsto~/logseq/cli-graphs.
- Change
src/main/logseq/cli/server.cljs- Update
resolve-data-dirdefault to~/logseq/cli-graphs(keeps server defaults aligned when config is absent).
- Update
src/main/frontend/worker/db_worker_node_lock.cljs- Update
resolve-data-dirdefault to~/logseq/cli-graphs.
- Update
src/main/frontend/worker/platform/node.cljs- Update
node-platformdefault fordata-dirto~/logseq/cli-graphs.
- Update
src/main/frontend/worker/db_worker_node.cljs- Update the
--data-dirhelp text default to~/logseq/cli-graphs.
- Update the
2) Update default config path for CLI
src/main/logseq/cli/config.cljs- Change
config-pathdefault from~/logseq/cli.ednto~/logseq/cli.edn. - Update any inline default map (
resolve-configdefault options) to match if present.
- Change
3) Update docs and internal references
docs/cli/logseq-cli.md- Replace references to
~/logseq/cli.ednand~/logseq/cli-graphswith the new paths. - Add a short migration note: existing data/config can be used by passing
--data-dir/--config.
- Replace references to
docs/agent-guide/*.md- Update any references to the old defaults (notably
docs/agent-guide/002-logseq-cli-subcommands.md,docs/agent-guide/003-db-worker-node-cli-orchestration.md,docs/agent-guide/012-logseq-cli-graph-storage.md,docs/agent-guide/019-logseq-cli-data-dir-permissions.md, anddocs/agent-guide/task--db-worker-nodejs-compatible.md).
- Update any references to the old defaults (notably
4) Tests
- Unit tests likely unaffected, but adjust any tests or snapshots that assert default path strings (search for
~/logseq/cli-graphsor~/logseq/cli.ednin tests). - If tests assert CLI help output or default config path, update expected strings accordingly.
Notes
- Do not add a one-time warning for the old
~/logseq/cli-graphslocation. If a config is needed, prefercli.ednunder the selecteddata-dir. - Do not add any fallback or compatibility for
~/logseq/cli.edn. The old location is ignored.