Compython

unlisted

by Dison Franco

AI chat assistant with vault awareness, semantic search, one-click edits, and native Python execution.

Updated 1mo agoMIT
View on GitHub

🐍 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_PATH environment variable inside scripts

πŸš€ Features (inherited from Smart Composer)

  • Contextual Chat β€” reference vault files with @filename syntax
  • 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

  1. Download the latest release: main.js, manifest.json, styles.css
  2. Create the folder: YOUR_VAULT/.obsidian/plugins/compython/
  3. Copy the 3 files into that folder
  4. 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

  1. Go to Settings β†’ Compython β†’ Python Executor
  2. Toggle Enable Python execution ON
  3. Set the Python path:
    • Windows: python or C:\Python311\python.exe
    • macOS/Linux: python3
  4. Configure timeout and confirmation preferences
  5. Done β€” every python code 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.