@hy-sde-org/dsh-tool-logseq

中文文档
0.2.1-rc.5发布于 2026/11/01MITTypeScriptES Module

Model-facing Logseq CLI tools (logseq_list/upsert/remove/query/show/search/graph/server) that drive a Logseq database graph from the terminal — headless-capable alternative to the desktop MCP bridge

原始使用文档
文档目录11 节
  1. Summary
  2. Table of Contents
  3. Tool surface
  4. Why CLI over MCP
  5. Configuration
  6. Model Experience
  7. Tool schemas
  8. Result values
  9. Prompt section
  10. Known Limitations and Deferred Work
  11. Dev Note

@hy-sde-org/dsh-tool-logseq

English | 中文

Summary

dsh-tool-logseq lets an agent drive a Logseq database graph from the terminal: list, show, search, Datalog-query, upsert, and remove blocks, pages, tags, properties, tasks, and assets, plus graph and server lifecycle actions. Choose it over the desktop-app MCP bridge when you want deterministic JSON output, Datalog querying, structured task upserts, or fully headless operation — the MCP bridge needs the app open and lacks removal, Datalog, and task commands. The tools run the installed logseq CLI on every call, so the CLI must be installed and each call pays one process spawn; the cheapest path is to batch writes into single logseq_upsert calls and start a headless server with logseq_server start.

Table of Contents


Model-facing Logseq CLI tools that drive a Logseq database graph directly from the terminal. The surface is the local alternative to the desktop-app MCP bridge: besides the read/write basics it adds what the MCP bridge cannot do — Datalog query, remove, first-class task upserts, and graph/server lifecycle — all wrapped from the installed logseq CLI (opam exec -- dune build @bundle, or the prebuilt binary).

Tool surface

  • logseq_list [entityType=page] [limit] [offset] [sort] [order] [fields] [includeBuiltIn] [journalOnly] [includeHidden] [withProperties] [withExtends] [taskStatus] [taskPriority] [content] — list pages, tags, properties, tasks, nodes or assets from the graph with entity-specific toggles.
  • logseq_show [page | id | uuid] [level] [pageHierarchy] [linkedReferences] — render the block/page tree as text.
  • logseq_search [entityType] [content] [limit] — full-text search over blocks/pages/properties/tags.
  • logseq_query [query | name] [inputs] [limit] — Datascript query (structural questions one hop can't answer).
  • logseq_upsert [entityType] [...] — create/update blocks, pages, tags, properties and tasks; tasks get structured status/priority/scheduled/deadline, tags/properties are EDN-mapped, never embedded in content.
  • logseq_remove [entityType] [id|uuid|page|name] — permanent removal (use only when certain).
  • logseq_graph [action] [...] — validate/info/export (edn|sqlite)/import/backup lifecycle.
  • logseq_server [action] — list/start/stop/restart/cleanup the db-worker-node servers; start enables fully headless operation without the desktop app.

Why CLI over MCP

The desktop MCP bridge serves the same graph when the app is open, but requires the app + token header, has no Datalog, no removal, no task commands, and dumps large raw schemas into every request. The CLI wrapper is deterministic JSON (--output json → {"status":"ok","data":…}), headless-capable, full-surface, and compact. Keep the MCP row around disabled if you want a zero-maintenance fallback.

Configuration

import { Context } from '@deepseek-ai/cordis'
import toolLogseqPackage from '@hy-sde-org/dsh-tool-logseq'

const ctx = new Context()
ctx.plugin(toolLogseqPackage, {
  cliPath: 'logseq', // CLI executable (default: on PATH)
  graph: 'llm-wiki', // always pass --graph <name>
  timeoutMs: 60000, // per-call process timeout
  maxItems: 50, // cap on rendered list/search items
})

Setting graph makes every call explicit about its target graph. The plugin activation invariant fails fast with an install hint when the CLI is missing.

Model Experience

Tool schemas

What the model sees

Tool descriptions + schemas encode the CLI contract so the model prefers the CLI path over the MCP bridge, batches writes one logical change per call, and uses structured task status instead of TODO markers in content.

Token effect

Eight hand-authored schemas are added once to the request prefix (~1–2 KB total), far smaller than the MCP upsertNodes schema on every call; results are compact renders (capped by maxItems), so token cost stays bounded regardless of graph size.

KV Cache effect

All schemas are static; per-call args vary but never condition the request prefix. Cached prefixes stay valid across calls.

Result values

What the model sees

Structured enumerations and query rows as plain data, plus the CLI's human tree text for show. Human error envelopes (Error (...) prints) surface as LogseqCliError with argv attached, never as fake success.

Token effect

List/search results are capped (maxItems, default 50) and summarized; query rows are flattened to compact lines; server/graph tables pass through small plain text.

KV Cache effect

Results are per-call snapshots; no read-back that would change the model's rerun prefix.

Prompt section

What the model sees

One logseq:tools card: prefer CLI over MCP, one logical change per call, existence-checks before create, removals are permanent, tasks use structured status, and logseq_server start for headless use.

Token effect

Six short lines added once to the request prefix; negligible per turn.

KV Cache effect

Static section text — no invalidation.

Known Limitations and Deferred Work

  • CLI must be installed — the tools spawn logseq; there is no bundled binary (the CLI is built from the logseq repo). The activation invariant gives an install hint and cliPath supports a non-PATH binary.
  • Per-call process spawn — each tool call starts a fresh CLI process (the CLI's own model). High-frequency shells (many separate edits) cost process startups; batch structured changes in single logseq_upsert calls instead.
  • Graph server required — the graph needs a db-worker-node server; the tools reuse the running one (including the desktop app's) or logseq_server start launches a headless one. A stopped server surfaces as a CLI error, not a clean retry path.
  • JSON shapes are read at runtime — list/search/query item fields follow the CLI's JSON contract; if a future CLI changes shape, the compact renders degrade gracefully rather than crashing.
  • No asset upload — logseq_upsert/logseq_list cover assets only via the generic node/asset listing; binary asset ingestion stays a file/CLI concern for now.

Dev Note

Working context for maintainers — click to expand

None.

版本与发布记录

@hy-sde-org/dsh-tool-logseq 共发布 9 个版本,首次发布于 2026/09/06;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.2.1-rc.5latest2026/11/012 天前
0.2.1-rc.32026/10/259 天前
0.2.1-alpha.42026/10/1618 天前
0.2.1-alpha.22026/10/1321 天前
0.2.0-rc.22026/10/031 个月前
0.1.7-rc.22026/09/291 个月前

关于 @hy-sde-org/dsh-tool-logseq 的常见问题

@hy-sde-org/dsh-tool-logseq 是什么?

面向模型的Logseq命令行工具(logseq_list/upsert/remove/query/show/search/graph/server),用于从终端驱动Logseq数据库图形,可替代桌面MCP桥接

如何安装 @hy-sde-org/dsh-tool-logseq?

在项目目录运行 npm install @hy-sde-org/dsh-tool-logseq,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@deepseek-ai/cordis(~4.0.5)、@deepseek-ai/dsh-tools(^0.2.1-rc.5)、@hy-sde-org/dsh-logseq-graph(^0.2.1-rc.5)、@deepseek-ai/dsh-system-prompt(^0.2.1-rc.5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@hy-sde-org/dsh-tool-logseq 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@hy-sde-org/dsh-tool-logseq 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@hy-sde-org/dsh-tool-logseq 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@hy-sde-org/dsh-tool-logseq 可以商用吗?

@hy-sde-org/dsh-tool-logseq 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@hy-sde-org/dsh-tool-logseq 还在维护吗?

最新版本 0.2.1-rc.5 发布于 2026/11/01(2 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/09/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。