Interactive document sessions with AI agents
Project description
agent-doc
Interactive document sessions with AI agents.
Edit a markdown document. Press a hotkey. The tool diffs your changes, sends them to an AI agent, and writes the response back into the document. The document is the UI.
Why
Terminal prompts are ephemeral. You type, the agent responds, the context scrolls away. Documents are persistent — you can reorganize, delete noise, annotate inline, and curate the conversation as a living artifact. The agent sees your edits as diffs, so every change carries intent.
Install
cargo install --path .
Quick Start
agent-doc init session.md "Topic Name" # scaffold a session doc
agent-doc run session.md # diff, send, append response
agent-doc diff session.md # preview what would be sent
agent-doc reset session.md # clear session + snapshot
agent-doc clean session.md # squash session git history
Document Format
---
session: 05304d74-90f1-46a1-8a79-55736341b193
agent: claude
---
# Session: Topic Name
## User
Your question or instruction here.
## Assistant
(agent writes here)
## User
Follow-up. You can also annotate inline:
> What about edge cases?
Frontmatter fields
| Field | Required | Default | Description |
|---|---|---|---|
session |
no | (generated on first run) | Session ID for continuity |
agent |
no | claude |
Agent backend to use |
model |
no | (agent default) | Model override |
branch |
no | (none) | Git branch for session commits |
Two interaction modes
Append mode: Structured ## User / ## Assistant blocks.
Inline mode: Annotations anywhere — blockquotes, edits to previous
responses. The diff captures what changed; the agent addresses inline edits
alongside new ## User content.
Both work simultaneously because the run sends a diff, not a parsed structure.
Run Flow
┌──────────┐ hotkey ┌────────────┐ diff + prompt ┌───────┐
│ Editor │ ──────> │ agent-doc │ ──────────────> │ Agent │
│ │ │ │ <────────────── │ API │
│ reload │ <────── │ write+snap │ └───────┘
└──────────┘ │ git commit │
└────────────┘
- Read document, load snapshot (last-known state)
- Compute diff — if empty, exit (double-run guard)
- Send diff + full document to agent, resuming session
- Append response as
## Assistantblock - Save snapshot, git commit
Session continuity
- Empty
session:— forks from the most recent agent session in the directory (inherits context) session: <uuid>— resumes that specific session- Delete
session:value — next run starts fresh
History rewriting
Delete anything from the document. On next run, the diff shows deletions and the agent sees the cleaned-up doc as ground truth.
Git Integration
Each run auto-commits the document for inline diff highlighting in your editor.
| Flag | Behavior |
|---|---|
-b |
Auto-create branch agent-doc/<filename> on first run |
| (none) | Commit to current branch |
--no-git |
Skip git entirely |
Cleanup: agent-doc clean <file> squashes all session commits into one.
Agent Backends
Agent-agnostic core. Only the "send prompt, get response" step varies.
# ~/.config/agent-doc/config.toml
[agents.claude]
command = "claude"
args = ["-p", "--output-format", "json"]
result_path = ".result"
session_path = ".session_id"
[agents.codex]
command = "codex"
args = ["--prompt"]
result_path = ".output"
session_path = ".id"
default_agent = "claude"
Override per-document via agent: in frontmatter, or per-invocation via --agent.
Editor Integration
JetBrains
External Tool: Program=agent-doc, Args=run $FilePath$,
Working dir=$ProjectFileDir$, Output paths=$FilePath$. Assign keyboard shortcut.
VS Code
Task: "command": "agent-doc run ${file}". Bind to keybinding.
Vim/Neovim
nnoremap <leader>as :!agent-doc run %<CR>:e<CR>
CLI Reference
agent-doc run <file> [-b] [--agent <name>] [--model <model>] [--dry-run] [--no-git]
agent-doc init <file> [title] [--agent <name>]
agent-doc diff <file>
agent-doc reset <file>
agent-doc clean <file>
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_doc-0.1.2.tar.gz.
File metadata
- Download URL: agent_doc-0.1.2.tar.gz
- Upload date:
- Size: 41.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b650f6b3c175edcbdadb6ab0f364ea0f3d8d04942156a8264d7253dcabf48da
|
|
| MD5 |
863c21ea9edec561191f84a2d6c87606
|
|
| BLAKE2b-256 |
60ba077d3a9832246b0e185751114c1edf35872d62909a562310a44de8d2a82d
|
File details
Details for the file agent_doc-0.1.2-py3-none-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: agent_doc-0.1.2-py3-none-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd8f6f0dda02bbf4c7b9e16f1cc134b0ead0651431f0b679bd57e89bd55f764
|
|
| MD5 |
f351fbb140b705e0271217ecf284e073
|
|
| BLAKE2b-256 |
0cdc4b0684592949aed3c67313deb3d1ff801b8ba783e059cbfad148a21bb606
|