Feat: Add a CLI by logseq-cldwalker · Pull Request #12000 · logseq/logseq · GitHub
Skip to content

Feat: Add a CLI - #12000

Merged
logseq-cldwalker merged 30 commits into
masterfrom
feat/add-cli
Aug 11, 2025
Merged

logseq-cldwalker merged 30 commits into
masterfrom
feat/add-cli

Conversation

@logseq-cldwalker

@logseq-cldwalker logseq-cldwalker commented Jul 18, 2025 •

Copy link
Copy Markdown
Collaborator

This PR adds a logseq CLI for DB graphs which can be installed via npm/yarn. See https://github.com/logseq/logseq/blob/feat/add-cli/deps/cli/README.md for an overview of the CLI.

To QA: npm i -g @logseq/cli@alpha

Remaining tasks:

  • Fix local dev install of CLI for yarn
  • Add a pre-release task for preparing CLI's nbb dependencies
  • Fix startup time issue
  • Add a workflow for releasing CLI to npm

@github-actions github-actions Bot added the :type/feature New feature label Jul 18, 2025
@logseq-cldwalker logseq-cldwalker changed the title Feat: Add a CLI Feat: Add a CLI [WIP] Jul 18, 2025
@logseq-cldwalker
logseq-cldwalker force-pushed the feat/add-cli branch 5 times, most recently from cfae41f to 5470828 Compare July 24, 2025 19:27
@logseq-cldwalker
logseq-cldwalker force-pushed the feat/add-cli branch 6 times, most recently from 9ccab71 to 456f853 Compare August 6, 2025 17:19
@logseq-cldwalker
logseq-cldwalker force-pushed the feat/add-cli branch 10 times, most recently from e393fee to 499c4c8 Compare August 7, 2025 22:01
@logseq-cldwalker logseq-cldwalker changed the title Feat: Add a CLI [WIP] Feat: Add a CLI Aug 7, 2025

@tiensonqin tiensonqin left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting to have CLI! 🚢 🚀

I tested all the commands for both docs and lambda graph, and they work exactly as written in README, great work!

It'll be nice to support those cases:

  1. query by block uuid instead of[:block/uuid #uuid "block-uuid"]
  2. query by block title or lowercased name
  3. add an option for "query" to return all properties instead of id
  4. able to search without the api server by using (d/datoms db :avet :block/title)
  5. able to dsl query without the api server, we need to move frontend.db.query-dsl to deps/db first

Also move common db graph list to shared ns and move common prefix
constants to common-config
Was used for removed e2e tests. Test rtc just in case
allows for user specified limit of results.
Also enabled nbb-logseq tests for cli since first
test was introduced
Also update cli install instructions
Lazy load namespaces as start time goes up with more required namespaces
external to nbb-logseq or node. CLI now only loads ~6 namespaces instead
of 55 namespaces at start and then lazy loads a command ns as needed
confirmed with npm pack that CLI works with files config
also fix minor bug silently failing show command for abnormal graphs
Also add user friendly error handling when api server isn't turned on
Can use uuid string as shorthand identifier. Can make properties
readable with option. Also wire up local query to use default catch
handler
@logseq-cldwalker

Copy link
Copy Markdown
Collaborator Author

Also add assertion to guard against previous load time issue
failing w/ confusing stacktraces. Also exit correctly when a nonexistent
graph is given
@logseq-cldwalker
logseq-cldwalker merged commit 35c2952 into master Aug 11, 2025
@logseq-cldwalker
logseq-cldwalker deleted the feat/add-cli branch August 11, 2025 21:05
@tiensonqin

Copy link
Copy Markdown
Contributor

@logseq-cldwalker Nice!
For 2, I mean to query pages/blocks by their names, e.g. logseq query graph-name "page-name".
For 4, to use Datascript's datoms for searching if there's no access token provided for search. Something like:

(->> (d/datoms db :aevt :block/title)
     (filter (fn [datom]
               (string/includes? (:v datom) search-input))))

@tiensonqin

Copy link
Copy Markdown
Contributor

Another idea is to add an append command to write some text to the db with the http api. e.g. logseq append graph-name "some text".

logseq-cldwalker added a commit that referenced this pull request Aug 13, 2025
to address #12000 (comment).
Also bump version for initial release
@logseq-cldwalker

Copy link
Copy Markdown
Collaborator Author

For 2, I mean to query pages/blocks by their names, e.g. logseq query graph-name "page-name".
For 4, to use Datascript's datoms for searching if there's no access token provided for search. Something like:

Addressed these in cc1093a. For 2, I added it as an option e.g. logseq query graph-name "page-name" -t because a string is already used to invoke a datalog query or a uuid string local entity query. Fwiw for predefined queries like this, it'd eventually be worth having a separate command as it allows for more powerful and custom queries by the user as I explored in https://github.com/cldwalker/logseq-query. logseq query is focused on invoking simple or advanced/datalog queries

Going to do an initial release of the CLI soon

@logseq-cldwalker

Copy link
Copy Markdown
Collaborator Author

Another idea is to add an append command to write some text to the db with the http api. e.g. logseq append graph-name "some text"

Good idea. Have questions so made this an issue - https://test.logseq.com/#/page/689ca670-d93f-4fe0-a262-029d95f8450f

@tiensonqin

Copy link
Copy Markdown
Contributor

tiensonqin pushed a commit that referenced this pull request Aug 14, 2025
to address #12000 (comment).
Also bump version for initial release
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
to address #12000 (comment).
Also bump version for initial release
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
to address #12000 (comment).
Also bump version for initial release
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
to address #12000 (comment).
Also bump version for initial release
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
to address #12000 (comment).
Also bump version for initial release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:type/feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants