Compython
unlistedby Dison Franco
AI chat assistant with vault awareness, semantic search, one-click edits, and native Python execution.
π Compython
AI chat assistant for Obsidian with vault awareness, semantic search, one-click edits, and native Python execution.
Compython is a fork of Smart Composer that adds the ability to write and run Python code directly inside Obsidian β both manually by the user and autonomously by the AI model.
β¨ What's new in Compython
Native Python Execution
Every Python code block in the chat gets a "Run Python" button. Click it and the output appears inline β no terminal, no switching apps, no copy-paste.
- Works with any AI model β local (Gemma, Qwen, LLaMA) or cloud (Claude, GPT, Gemini)
- No tool calling required β based on markdown code block detection, so every model works
- Output appears inline with stdout, stderr, and exit code
- The vault path is automatically available as the
VAULT_PATHenvironment variable inside scripts
π Features (inherited from Smart Composer)
- Contextual Chat β reference vault files with
@filenamesyntax - Apply Edit β AI suggests edits to your notes with one-click apply
- Vault Search (RAG) β semantic search across your entire vault
- MCP Support β connect to external tools via Model Context Protocol
- Local Model Support β Ollama, LM Studio, and any OpenAI-compatible provider
- Custom System Prompts and Prompt Templates
- Multiple AI providers: Anthropic, OpenAI, Gemini, Groq, DeepSeek, OpenRouter, and more
π¦ Installation
Manual installation
- Download the latest release:
main.js,manifest.json,styles.css - Create the folder:
YOUR_VAULT/.obsidian/plugins/compython/ - Copy the 3 files into that folder
- In Obsidian:
Settings β Community plugins β reloadβ enable Compython
β οΈ If you have Smart Composer installed, disable or uninstall it first β they conflict since they register the same view type.
βοΈ Setting up Python execution
- Go to
Settings β Compython β Python Executor - Toggle Enable Python execution ON
- Set the Python path:
- Windows:
pythonorC:\Python311\python.exe - macOS/Linux:
python3
- Windows:
- Configure timeout and confirmation preferences
- Done β every
pythoncode block in chat will now have a Run Python button
Using your vault path in scripts
import os
vault = os.environ.get("VAULT_PATH", ".")
print(f"My vault is at: {vault}")
# List all markdown files in the vault
import pathlib
notes = list(pathlib.Path(vault).rglob("*.md"))
print(f"Found {len(notes)} notes")
π§ Development
git clone https://github.com/disonfranco/compython
cd compython
npm install
npm run dev # watch mode
npm run build # production build
Copy main.js, manifest.json, and styles.css to your vault's plugin folder after building.
πΊοΈ Roadmap
- Auto-run Python after AI response (agentic loop for local models)
- Plot rendering β display matplotlib figures inline in chat
- Session state β persistent Python environment across executions
- Virtual environment support β point to a venv instead of system Python
- Safety sandbox β optional restricted execution mode
π Credits
Compython is built on top of Smart Composer by @glowingjade and contributors. All original features and architecture are theirs β Compython adds the Python execution layer on top.
Authors of the Python execution feature:
- Dison Franco β concept, testing, and direction
- Claude (Anthropic) β implementation
π License
MIT β same as the original Smart Composer.
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.