obsidian-gemini-helper
AGENTS.md117 starsChanged 5 months agoMITView on GitHub
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository. Obsidian plugin for Google Gemini AI with Chat, Workflow Automation, and Semantic Search (RAG). Uses @google/genai SDK. API-only (no CLI backends or local LLM support). After building, reload the plugin in Obsidian to test changes. Use npm's built-in version command which automatically updates all version files: This runs version-bump.mjs which updates package.json, manifest.json, and versions.json together.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,315 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-toolSkill
- add-workflow-nodeSkill
- gemini-best-practicesSkill
- add-toolSkill
- add-workflow-nodeSkill
- gemini-best-practicesSkill
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
After building, reload the plugin in Obsidian to test changes.
- Distinctive: line 21
Use npm's built-in version command which automatically updates all version files:
- Distinctive: line 141
When adding a new workflow node type, ALL of the following files must be updated:
- Very specific: line 143
src/workflow/types.ts: - Add to WorkflowNodeType union type AND WORKFLOW_NODE_TYPES set (single source of truth for isWorkflowNodeType()) - Very specific: line 144
src/workflow/workflowSpec.ts: - Add documentation for AI workflow generation - Very specific: line 145
src/workflow/nodeHandlers.ts: - Add handle*Node() function and import - Very specific: line 146
src/workflow/executor.ts: - Add case in the switch statement to call handler and log - Very specific: line 148
Add to NODE_TYPE_LABELS object
- Very specific: line 149
Add to ADDABLE_NODE_TYPES array
- Very specific: line 150
Add to getDefaultProperties() switch
- Very specific: line 154
Add case in renderPropertyFields() switch for editor UI
≈ “Common” is an estimate: at least 1 in 5 of the 42,283 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
Project Overview
Obsidian plugin for Google Gemini AI with Chat, Workflow Automation, and Semantic Search (RAG). Uses @google/genai SDK. API-only (no CLI backends or local LLM support).
Build Commands
npm run build # Production build (tsc + esbuild) -> outputs main.js
npm run dev # Development build with watch mode
npm run lint # ESLint checkAfter building, reload the plugin in Obsidian to test changes.
Version Bumping
Use npm's built-in version command which automatically updates all version files:
npm version patch # 1.2.3 -> 1.2.4
npm version minor # 1.2.3 -> 1.3.0
npm version major # 1.2.3 -> 2.0.0This runs version-bump.mjs which updates package.json, manifest.json, and versions.json together.
Architecture
Core Layer (src/core/)
- gemini.ts - Gemini API client wrapper
GeminiClientclass with streaming chat, function calling, and RAG integrationchatWithToolsStream()- Main method for chat with tools and optional RAGmessagesToHistory()- Converts Message[] to Gemini Content[] format
- fileSearch.ts - File Search RAG management
FileSearchManager- Handles store creation, file sync, deletionsmartSync()- Checksum-based incremental sync with parallel uploads
- tools.ts - Function calling tool definitions (13 tools for vault operations)
- mcpClient.ts - MCP (Model Context Protocol) client for external tool servers
- Implements Streamable HTTP transport with JSON-RPC
Vault Layer (src/vault/)
- notes.ts - Note CRUD operations + safe editing with
proposeEdit()/applyEdit()/discardEdit() - search.ts - Local vault search (filename and content)
- toolExecutor.ts - Maps tool calls to vault operations
Workflow Layer (src/workflow/)
- types.ts - Workflow node types and execution context definitions
- parser.ts - Parses workflow YAML from markdown code blocks
- executor.ts - Stack-based workflow execution engine with MAX_ITERATIONS (1000) safety
- nodeHandlers.ts - Individual handlers for 21 node types
- history.ts - Execution history tracking
- historyCanvas.ts - Export execution history to Obsidian Canvas
- codeblockSync.ts - Sync workflow changes back to markdown
Dashboard Hub Integration (src/integrations/)
- Dashboard UI,
.dashboardownership, widgets, and storage are provided by the separateobsidian-dashboard-hubplugin. - dashboardHubCapabilities.ts - Exposes Gemini models, Chat handoff, headless Workflow execution, Base generation, text rewriting, and Workflow generation to Dashboard Hub.
- Dashboard Hub contributes its
dashboardagent skill dynamically through the runtime skill registry insrc/core/runtimeSkills.ts. plugin.tsretains a compatibilitycreate-dashboardcommand that delegates creation to Dashboard Hub.
UI Layer (src/ui/)
- ChatView.tsx - Obsidian ItemView wrapper for React
- SettingsTab.tsx - Plugin settings UI
- components/ - React components (Chat, MessageList, MessageBubble, InputArea)
- components/workflow/ - Workflow-specific modals and WorkflowPanel.tsx
Key Data Flow (Chat)
- User sends message →
Chat.tsx→GeminiClient.chatWithToolsStream() - Gemini responds with text/function calls → streamed back to UI
- Function calls →
toolExecutor.ts→notes.ts/search.ts→ results back to Gemini - RAG: If enabled,
fileSearchtool added to Gemini request for semantic search
Key Data Flow (Workflow)
- User selects workflow →
WorkflowPanel.tsxloads from markdown code block parseWorkflowFromMarkdown()converts YAML toWorkflowgraphWorkflowExecutor.execute()traverses nodes using stack-based execution- Each node type handled by specific handler in
nodeHandlers.ts - Results saved to execution history, optionally exported to Canvas
Important Implementation Details
Safe Editing (propose_edit tool)
- Changes applied directly to file, original content backed up in memory
- User clicks Apply (confirm) or Discard (restore from backup)
update_notetool disabled to force safe editing flow
RAG Integration
- Multiple RAG settings stored in workspace state file (
.gemini-workspace.json) - Supports internal stores (auto-synced) and external store IDs
RagSetting.filestracks checksums for incremental sync- Store data persists on Google servers; use "Delete RAG Store" in settings to clean up
Chat History
- Saved as Markdown files in
{workspaceFolder}/chats/{chatId}.md - YAML frontmatter with title, timestamps
- Messages parsed/serialized via
messagesToMarkdown()/parseMarkdownToMessages()
Streaming
- Uses SDK Chat (
this.ai.chats.create()) for automatic thought signature handling - AbortController for stop functionality
groundingMetadatain response indicates RAG usage
Workflow Execution
- Stack-based traversal with iteration counting for loop safety
- Conditional nodes (
if,while) use labeled edges ("true"/"false") - Variables interpolated via
{{varName}}syntax in node properties - Sub-workflows executed recursively with variable passing
- Event triggers support glob patterns for file filtering
MCP Integration
- External MCP servers configured via settings (
mcpServersarray) McpClientimplements Streamable HTTP transport- Session management with
Mcp-Session-Idheader - Available in workflow
mcpnodes
Key Types (src/types/index.ts)
Message- Chat message with optional attachments, toolsUsed, pendingEdit, ragUsedPendingEditInfo- Tracks edit status (pending/applied/discarded)StreamChunk- Streaming response types (text, tool_call, tool_result, rag_used, error, done)GeminiHelperSettings- Plugin configurationWorkspaceState- Per-workspace state (selected model, RAG settings)RagSetting- Individual RAG store configuration
Workflow Types (src/workflow/types.ts)
WorkflowNodeType- 21 node types (command, http, note, dialog, mcp, etc.)WORKFLOW_NODE_TYPES- Set of all valid node type strings (single source of truth)isWorkflowNodeType()- Type guard used by parser.ts and codeblockSync.tsnormalizeValue()- Converts unknown YAML values to string (shared utility)Workflow- Node graph with edges and start nodeExecutionContext- Variables map and execution logsPromptCallbacks- UI callbacks for interactive nodes
Adding New Workflow Node Types
When adding a new workflow node type, ALL of the following files must be updated:
src/workflow/types.ts- Add toWorkflowNodeTypeunion type ANDWORKFLOW_NODE_TYPESset (single source of truth forisWorkflowNodeType())src/workflow/workflowSpec.ts- Add documentation for AI workflow generationsrc/workflow/nodeHandlers.ts- Addhandle*Node()function and importsrc/workflow/executor.ts- Addcasein the switch statement to call handler and logsrc/ui/components/workflow/WorkflowPanel.tsx:- Add to
NODE_TYPE_LABELSobject - Add to
ADDABLE_NODE_TYPESarray - Add to
getDefaultProperties()switch - Add to
getNodeSummary()switch
- Add to
src/ui/components/workflow/NodeEditorModal.ts:- Add to
NODE_TYPE_LABELSobject - Add
caseinrenderPropertyFields()switch for editor UI
- Add to
Common mistakes:
- Forgetting
WORKFLOW_NODE_TYPESset causes nodes to be skipped during parsing and disappear from visual workflow - Forgetting
executor.tscauses node execution to fail silently
Notes
- Obsidian API accessed via
app.vault(files) andapp.workspace(UI) - React components rendered inside Obsidian's ItemView
- File attachments converted to Base64 and sent as
inlineDataparts - Desktop and mobile supported
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

