Skip to main content

%%hermes cell magic — talk to Hermes Agent directly inside Jupyter notebooks

Project description

jupyter-ai-hermes-magics

%%hermes cell magic — talk to Hermes Agent directly inside Jupyter notebooks.

Features

  • Two-phase button: Shift+Enter shows a ▶ button; click to send. No auto-send on run.
  • Stop mid-stream: Click ⏹ to stop Hermes. No transcript cell created if stopped.
  • Dynamic cell type: Code responses → code cell. Explanations → markdown cell.
  • No ipywidgets: Uses IPython comms — no widget-state-saving issues.
  • Notebook context: Hermes sees cells above the %%hermes cell (not below).
  • Session tree: Dot-notation labels (main.debug.fix) for branching conversations.
  • Always new transcript: Each response creates a fresh cell below — no fragile update logic.
  • Full agent: Hermes has tools, memory, skills, and can edit notebook cells via MCP.

Installation

pip install jupyter-ai-hermes-magics

Then load in a notebook:

%load_ext jupyter_ai_hermes_magics

Or add to ipython_config.py for auto-load:

c.InteractiveShellApp.extensions = ["jupyter_ai_hermes_magics"]

Usage

Basic chat

%%hermes
Explain what the code in the cell above does

→ A ▶ button appears. Click it to send to Hermes. Response goes to a new cell below.

Branching sessions

%%hermes --label main
Write a function to sort a list

%%hermes --label main.debug
Why does this throw an error?

%%hermes --label main.debug.fix
Fix the error and show the corrected code

Skip context

%%hermes --no-context
What is the capital of France?

Subcommands

%hermes list     # Show session tree
%hermes reset    # Clear all sessions
%hermes version  # Show version

How it works

Two-phase flow

Phase 1 (Shift+Enter): The cell output displays a ▶ button and a tip. No request is sent. The cell's execution_count is captured to identify the magic cell later.

Phase 2 (Click ▶): Hermes starts via hermes chat -q "..." -Q. The button toggles to ⏹ with a live timer. The user can:

  • Wait for completion → response goes to a new transcript cell below.
  • Click ⏹ → process killed, no transcript cell created.

Cell type detection

After Hermes completes, the response is analyzed:

  • Single fenced code block (no prose) → code cell (fences stripped)
  • Raw code (starts with def/class/import) → code cell
  • Prose or mixedmarkdown cell (code blocks render inline)

State consistency

  • ▶ only when idle/done/stopped — never during streaming
  • ⏹ only during streaming — never when idle
  • Transcript always targets the cell below the magic cell (identified by execution_count)
  • On kernel restart, button becomes a static snapshot (no comm target registered)

Requirements

  • Hermes Agent installed and configured (hermes on PATH)
  • IPython ≥ 8.0
  • Jupyter MCP server (auto-started by jupyter-ai in JupyterLab)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_ai_hermes_magics-0.4.0.tar.gz (97.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_ai_hermes_magics-0.4.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_ai_hermes_magics-0.4.0.tar.gz.

File metadata

  • Download URL: jupyter_ai_hermes_magics-0.4.0.tar.gz
  • Upload date:
  • Size: 97.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for jupyter_ai_hermes_magics-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6e58ad40a9f9bf90f09b02a276b29cf4da5eb459dfecc257dbbe32e2ebe9fc0d
MD5 f9db883baff5933cca422597b1db07a2
BLAKE2b-256 0d143529d8bcd6d1d3a106e390b0a679c6dd33014781afb5a8f479cc24d36c9e

See more details on using hashes here.

File details

Details for the file jupyter_ai_hermes_magics-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_ai_hermes_magics-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d754d51f4ff321d38e58310479581e3cde51ad106cafe678753b217d5c8087b
MD5 5c68ab45eed89a887d90906596297380
BLAKE2b-256 7842c7052fc4f97cd9f2ef7350e7657fd0bf45dfc6608d19f2ed397ead9dd21f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page