Communitygithub.com

cli-anything-obsidian

通过 Obsidian Local REST API 进行知识管理和记笔记。专为 AI 代理和高级用户设计,无需图形界面即可管理笔记、搜索仓库和执行命令。

cli-anything-obsidian 是什么?

cli-anything-obsidian 是一个为 AI 代理和高级用户设计的命令行工具,通过 Obsidian Local REST API 提供知识管理和笔记功能。它支持笔记 CRUD 操作、仓库搜索、活动笔记管理、Obsidian 命令执行以及服务器状态检查。该工具可在任何支持 Python 的环境中使用,需要 Python 3.10+ 和运行中的 Obsidian 实例以及 Local REST API 插件。它提供对人类友好的格式化输出和对 AI 代理友好的 JSON 输出,并且维护可配置的 API 密钥和主机 URL 等会话状态。对于 AI 代理,建议始终使用 --json 标志以获取可解析的输出,并通过环境变量设置 API 密钥以避免每次调用都传递。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-obsidian

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

cli-anything-obsidian 是做什么的?

通过 Obsidian Local REST API 进行知识管理和记笔记。专为 AI 代理和高级用户设计,无需图形界面即可管理笔记、搜索仓库和执行命令。

安装

此 CLI 作为 cli-anything-obsidian 包的一部分安装:

pip install cli-anything-obsidian

前提条件:

用法

基本命令

# 显示帮助
cli-anything-obsidian --help

# 启动交互式 REPL 模式
cli-anything-obsidian

# 列出仓库文件
cli-anything-obsidian vault list

# 以 JSON 输出运行(供代理使用)
cli-anything-obsidian --json vault list

REPL 模式

当不指定子命令调用时,CLI 会进入交互式 REPL 会话:

cli-anything-obsidian
# 使用 Tab 补全和历史记录交互式输入命令

命令组

Vault(仓库)

仓库文件管理命令。

命令描述
list列出仓库或子目录中的文件
read读取笔记内容
create创建新笔记
update覆盖现有笔记
delete从仓库中删除笔记
append向现有笔记追加内容

Search(搜索)

仓库搜索命令。

命令描述
query使用 Obsidian 查询语法进行搜索
simple在整个仓库中进行纯文本搜索

Note(笔记)

活动笔记命令。

命令描述
active获取 Obsidian 中当前活动的笔记
open在 Obsidian 编辑器中打开笔记

Command(命令)

Obsidian 命令面板命令。

命令描述
list列出所有可用的 Obsidian 命令
execute通过命令 ID 执行命令

Server(服务器)

服务器状态和信息命令。

命令描述
status检查 Obsidian Local REST API 是否正在运行

Session(会话)

会话状态命令。

命令描述
status显示当前会话状态

示例

列出和读取笔记

# 列出所有仓库文件
cli-anything-obsidian vault list

# 列出子目录中的文件
cli-anything-obsidian vault list "Daily Notes"

# 读取笔记
cli-anything-obsidian vault read "Projects/my-project.md"

创建和更新笔记

# 创建新笔记
cli-anything-obsidian vault create "Projects/new-project.md" --content "# New Project"

# 更新(覆盖)笔记
cli-anything-obsidian vault update "Projects/new-project.md" --content "# Updated Content"

# 追加到笔记
cli-anything-obsidian vault append "Projects/new-project.md" --content "\n## New Section"

搜索

# 纯文本搜索(GET /search/simple/)
cli-anything-obsidian search simple "meeting notes"

# Dataview DQL 查询 — 默认 --type dql,发送为
# application/vnd.olrapi.dataview.dql+txt
cli-anything-obsidian search query 'TABLE file.link FROM "Projects"'

# JsonLogic 查询 — application/vnd.olrapi.jsonlogic+json
cli-anything-obsidian search query --type jsonlogic \
  '{"==":[{"var":"frontmatter.status"},"active"]}'

命令

# 列出可用命令
cli-anything-obsidian command list

# 通过命令 ID 执行命令
cli-anything-obsidian command execute "editor:toggle-bold"

交互式 REPL 会话

启动交互式会话以进行探索性使用。

cli-anything-obsidian
# 交互式输入命令
# 使用 'help' 查看可用命令

API 密钥配置

# 通过标志
cli-anything-obsidian --api-key YOUR_KEY vault list

# 通过环境变量(推荐用于代理)
export OBSIDIAN_API_KEY=YOUR_KEY
cli-anything-obsidian vault list

状态管理

CLI 维护轻量级的会话状态:

  • API 密钥:可通过 --api-key 或 OBSIDIAN_API_KEY 环境变量配置
  • 主机 URL:默认为 https://localhost:27124;可通过 --host 配置

输出格式

所有命令支持双输出模式:

  • 人类可读(默认):表格、颜色、格式化文本
  • 机器可读(--json 标志):供代理使用的结构化 JSON
# 人类输出
cli-anything-obsidian vault list

# 供代理使用的 JSON 输出
cli-anything-obsidian --json vault list

针对 AI 代理

以编程方式使用此 CLI 时:

  1. 始终使用 --json 标志 以获取可解析的输出
  2. 检查返回码 - 0 表示成功,非零表示错误
  3. 解析 stderr 以在失败时获取错误消息
  4. 设置 OBSIDIAN_API_KEY 环境变量,避免每次调用都传递 --api-key
  5. 在使用其他命令前,使用 server status 确认 Obsidian 正在运行

更多信息

  • 完整文档:请参阅包中的 README.md
  • 测试覆盖率:请参阅包中的 TEST.md
  • 方法论:请参阅 cli-anything-plugin 中的 HARNESS.md

版本

1.1.0

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相关技能