cli-anything-obsidian

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-anything-obsidian

cli-anything-obsidian

Knowledge management and note-taking via the Obsidian Local REST API. Designed for AI agents and power users who need to manage notes, search the vault, and execute commands without the GUI.
通过Obsidian Local REST API实现知识管理与笔记记录。专为需要在无GUI环境下管理笔记、搜索知识库并执行命令的AI Agent和高级用户设计。

Installation

安装

This CLI is installed as part of the cli-anything-obsidian package:
bash
pip install cli-anything-obsidian
Prerequisites:
此CLI作为cli-anything-obsidian包的一部分进行安装:
bash
pip install cli-anything-obsidian
前提条件:

Usage

使用方法

Basic Commands

基础命令

bash
undefined
bash
undefined

Show help

显示帮助信息

cli-anything-obsidian --help
cli-anything-obsidian --help

Start interactive REPL mode

启动交互式REPL模式

cli-anything-obsidian
cli-anything-obsidian

List vault files

列出知识库文件

cli-anything-obsidian vault list
cli-anything-obsidian vault list

Run with JSON output (for agent consumption)

以JSON格式输出(供Agent使用)

cli-anything-obsidian --json vault list
undefined
cli-anything-obsidian --json vault list
undefined

REPL Mode

REPL模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-obsidian
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-obsidian

Enter commands interactively with tab-completion and history

交互式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令组

Vault

知识库(Vault)

Vault file management commands.
CommandDescription
list
List files in the vault or a subdirectory
read
Read the content of a note
create
Create a new note
update
Overwrite an existing note
delete
Delete a note from the vault
append
Append content to an existing note
知识库文件管理命令。
命令描述
list
列出知识库或子目录中的文件
read
读取笔记内容
create
创建新笔记
update
覆盖现有笔记内容
delete
从知识库中删除笔记
append
向现有笔记追加内容

Search

搜索(Search)

Vault search commands.
CommandDescription
query
Search using Obsidian query syntax
simple
Plain text search across the vault
知识库搜索命令。
命令描述
query
使用Obsidian查询语法进行搜索
simple
在知识库中进行纯文本搜索

Note

笔记(Note)

Active note commands.
CommandDescription
active
Get the currently active note in Obsidian
open
Open a note in the Obsidian editor
当前活跃笔记相关命令。
命令描述
active
获取Obsidian中当前活跃的笔记
open
在Obsidian编辑器中打开笔记

Command

命令(Command)

Obsidian command palette commands.
CommandDescription
list
List all available Obsidian commands
execute
Execute a command by its ID
Obsidian命令面板相关命令。
命令描述
list
列出所有可用的Obsidian命令
execute
通过命令ID执行命令

Server

服务器(Server)

Server status and info commands.
CommandDescription
status
Check if the Obsidian Local REST API is running
服务器状态与信息相关命令。
命令描述
status
检查Obsidian Local REST API是否正在运行

Session

会话(Session)

Session state commands.
CommandDescription
status
Show current session state
会话状态相关命令。
命令描述
status
显示当前会话状态

Examples

示例

List and Read Notes

列出与读取笔记

bash
undefined
bash
undefined

List all vault files

列出所有知识库文件

cli-anything-obsidian vault list
cli-anything-obsidian vault list

List files in a subdirectory

列出子目录中的文件

cli-anything-obsidian vault list "Daily Notes"
cli-anything-obsidian vault list "Daily Notes"

Read a note

读取笔记

cli-anything-obsidian vault read "Projects/my-project.md"
undefined
cli-anything-obsidian vault read "Projects/my-project.md"
undefined

Create and Update Notes

创建与更新笔记

bash
undefined
bash
undefined

Create a new note

创建新笔记

cli-anything-obsidian vault create "Projects/new-project.md" --content "# New Project"
cli-anything-obsidian vault create "Projects/new-project.md" --content "# New Project"

Update (overwrite) a note

更新(覆盖)笔记

cli-anything-obsidian vault update "Projects/new-project.md" --content "# Updated Content"
cli-anything-obsidian vault update "Projects/new-project.md" --content "# Updated Content"

Append to a note

向笔记追加内容

cli-anything-obsidian vault append "Projects/new-project.md" --content "\n## New Section"
undefined
cli-anything-obsidian vault append "Projects/new-project.md" --content "\n## New Section"
undefined

Search

搜索

bash
undefined
bash
undefined

Plain text search

纯文本搜索

cli-anything-obsidian search simple "meeting notes"
cli-anything-obsidian search simple "meeting notes"

Obsidian query syntax search (tags, links, etc.)

使用Obsidian查询语法搜索(标签、链接等)

cli-anything-obsidian search query "tag:#project"
undefined
cli-anything-obsidian search query "tag:#project"
undefined

Commands

命令操作

bash
undefined
bash
undefined

List available commands

列出所有可用命令

cli-anything-obsidian command list
cli-anything-obsidian command list

Execute a command by ID

通过命令ID执行命令

cli-anything-obsidian command execute "editor:toggle-bold"
undefined
cli-anything-obsidian command execute "editor:toggle-bold"
undefined

Interactive REPL Session

交互式REPL会话

Start an interactive session for exploratory use.
bash
cli-anything-obsidian
启动交互式会话以进行探索性操作。
bash
cli-anything-obsidian

Enter commands interactively

交互式输入命令

Use 'help' to see available commands

输入'help'查看可用命令

undefined
undefined

API Key Configuration

API密钥配置

bash
undefined
bash
undefined

Via flag

通过命令行参数

cli-anything-obsidian --api-key YOUR_KEY vault list
cli-anything-obsidian --api-key YOUR_KEY vault list

Via environment variable (recommended for agents)

通过环境变量(推荐Agent使用)

export OBSIDIAN_API_KEY=YOUR_KEY cli-anything-obsidian vault list
undefined
export OBSIDIAN_API_KEY=YOUR_KEY cli-anything-obsidian vault list
undefined

State Management

状态管理

The CLI maintains lightweight session state:
  • API key: Configurable via
    --api-key
    or
    OBSIDIAN_API_KEY
    environment variable
  • Host URL: Defaults to
    https://localhost:27124
    ; configurable via
    --host
CLI会维护轻量级的会话状态:
  • API密钥:可通过
    --api-key
    参数或
    OBSIDIAN_API_KEY
    环境变量配置
  • 主机URL:默认值为
    https://localhost:27124
    ;可通过
    --host
    参数配置

Output Formats

输出格式

All commands support dual output modes:
  • Human-readable (default): Tables, colors, formatted text
  • Machine-readable (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、彩色文本、格式化内容
  • 机器可读格式
    --json
    参数):结构化JSON,供Agent使用
bash
undefined

Human output

人类可读输出

cli-anything-obsidian vault list
cli-anything-obsidian vault list

JSON output for agents

供Agent使用的JSON输出

cli-anything-obsidian --json vault list
undefined
cli-anything-obsidian --json vault list
undefined

For AI Agents

针对AI Agent的使用建议

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Set
    OBSIDIAN_API_KEY
    environment variable to avoid passing
    --api-key
    on every call
  5. Verify Obsidian is running with
    server status
    before other commands
以编程方式使用此CLI时:
  1. 始终使用
    --json
    参数
    以获得可解析的输出
  2. 检查返回码 - 0表示成功,非零表示错误
  3. 解析stderr以获取失败时的错误信息
  4. **设置
    OBSIDIAN_API_KEY
    **环境变量,避免每次调用都传递
    --api-key
    参数
  5. 在执行其他命令前,使用
    server status
    验证Obsidian是否正在运行

More Information

更多信息

  • Full documentation: See README.md in the package
  • Test coverage: See TEST.md in the package
  • Methodology: See HARNESS.md in the cli-anything-plugin
  • 完整文档:查看包中的README.md
  • 测试覆盖率:查看包中的TEST.md
  • 实现方法:查看cli-anything-plugin中的HARNESS.md

Version

版本

1.0.0
1.0.0