Skip to content

maratsalihov/opencode-obsidian-vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCode Obsidian Vault Plugin

Integrate your Obsidian vault with OpenCode AI agent

Search for "opencode" in the Obsidian Community Plugins or install as an OpenCode plugin to give your AI agent full access to your Obsidian vault.

Features

6 Custom Tools for OpenCode

Tool Description
obsidian_read Read any note with line numbers
obsidian_write Create or replace notes
obsidian_edit SEARCH/REPLACE targeted edits
obsidian_search Find notes by name or content
obsidian_list List notes in vault or folder
obsidian_append Append content to existing note
obsidian_move Rename or move notes

Auto-Detection

  • Automatically finds your Obsidian vault
  • Falls back to OBSIDIAN_VAULT_PATH env variable
  • Excludes .obsidian, .trash, .git by default

Installation

As OpenCode Plugin (Recommended)

# Global installation
mkdir -p ~/.config/opencode/plugins
cp dist/index.js ~/.config/opencode/plugins/obsidian-vault.js

# Or project-level
mkdir -p .opencode/plugins
cp dist/index.js .opencode/plugins/obsidian-vault.js

Via npm

npm install -g opencode-obsidian-vault

Then add to your opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-obsidian-vault"]
}

Manual

  1. Build the plugin:
bun install
bun run build
  1. Copy dist/index.js to .opencode/plugins/ in your project

Configuration

Environment Variables

# Tell the plugin where your vault is
export OBSIDIAN_VAULT_PATH="/path/to/your/vault"

In opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": { "api_key": "sk-ant-..." },
    "openai": { "api_key": "sk-..." }
  },
  "model": "anthropic/claude-sonnet-4-20250514",
  "plugin": ["opencode-obsidian-vault"]
}

Usage Examples

Read a note

Read my daily note from yesterday

→ AI uses obsidian_read to fetch the note

Create a new note

Create a new note called "Meeting Notes" in the Meetings folder with today's agenda

→ AI uses obsidian_write to create the note

Search and summarize

Find all notes about project planning and summarize the key points

→ AI uses obsidian_search then obsidian_read

Edit existing note

Add a TODO section to the bottom of "Roadmap.md"

→ AI uses obsidian_append or obsidian_edit

Organize vault

Move all notes from "Inbox" to "Processed/2024" folder

→ AI uses obsidian_move to reorganize

Available Hooks

The plugin also hooks into OpenCode's event system:

  • file.edited - Logs when vault files are modified
  • session.created - Injects vault context into new sessions
  • experimental.session.compacting - Adds vault info to compaction prompts

Development

git clone https://github.com/maratsalihov/opencode-obsidian-vault.git
cd opencode-obsidian-vault
bun install
bun run dev  # Watch mode

License

MIT

Author

Marat SalikhovGitHub

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors