Goal: Add logseq-cli support for import/export with EDN and SQLite formats using the existing db-worker-node server.
Architecture: Extend logseq-cli command parsing and execution to invoke db-worker-node thread APIs for export and import, with minimal new APIs to handle EDN import and SQLite binary payloads over HTTP.
Tech Stack: ClojureScript, babashka/cli, db-worker-node HTTP /v1/invoke, datascript, sqlite-export helpers, Node fs/path.
Related: Builds on docs/agent-guide/004-logseq-cli-verb-subcommands.md and docs/agent-guide/003-db-worker-node-cli-orchestration.md.
Prefer graph-scoped subcommands to keep import/export with graph management:
logseq graph export --type edn --output <path> [--repo <graph>]logseq graph export --type sqlite --output <path> [--repo <graph>]logseq graph import --type edn --input <path> --repo <graph>logseq graph import --type sqlite --input <path> --repo <graph>Notes:
graph import only supports importing into a new graph name; it must not overwrite an existing graph.--repo is required for import, and required unless the current graph is set in config for export.:thread-api/export-edn, :thread-api/export-db, and :thread-api/import-db.src/main/logseq/cli/transport.cljs and write files with transport/write-output.frontend.handler.db-based.import) but not in db-worker-node.src/main/logseq/cli/commands.cljs and src/main/logseq/cli/main.cljs to locate insertion points for new graph import/export actions.src/main/logseq/cli/commands.cljs.graph import and graph export entries and ensure help output includes them.src/main/logseq/cli/transport.cljs (or a new helper namespace), keeping the existing write-output behavior for EDN and DB files.thread-api/export-edn (graph-only) and write EDN file..sqlite file.thread-api/import-edn (see below), and return a summary message.thread-api/import-sqlite (or reuse import-db with a wrapper that closes/reopens the repo).src/main/frontend/worker/db_core.cljs:
:thread-api/import-edn to convert export EDN into tx data via logseq.db.sqlite.export/build-import and transact with :tx-meta including ::sqlite-export/imported-data? true so the pipeline rebuilds refs.:thread-api/export-db-base64 (or similar) to return a base64 string for SQLite export over HTTP.:thread-api/import-db-base64 (or similar) to accept base64 input, close existing sqlite connections, import db data, and reopen the repo (or invoke :thread-api/create-or-open-db with :import-type :sqlite-db).src/main/logseq/cli/format.cljs to print concise success lines like Exported <type> to <path> and Imported <type> from <path>.docs/cli/logseq-cli.md with new commands, examples, and file format notes.graph import and graph export options in src/test/logseq/cli/commands_test.cljs (or a new namespace).src/test/logseq/cli/integration_test.cljs to:
show or list.src/test/frontend/worker/db_worker_node_test.cljs for the new import/export thread APIs (EDN build-import path and base64 DB export/import).--repo is not provided, or if input file does not exist.graph import only imports into a new graph; it must not overwrite an existing graph.--mode flag; both EDN and SQLite imports are replace-style imports.graph export --type edn is graph-only for now (no page/view/blocks).