Skip to main content

Interactive document sessions with AI agents

Project description

agent-doc

Interactive document sessions with AI agents.

Edit a markdown file, press a hotkey, and the tool diffs your changes, sends them to an AI agent, and writes the response back into the document. The document is the UI.

Alpha Software — actively developed; APIs and frontmatter format may change between versions.

Single-user only. agent-doc operates on the local filesystem with no access control. Use a private git repository. See the Security section for details.

Install

curl -fsSL https://raw.githubusercontent.com/btakita/agent-doc/main/install.sh | sh

Alternatives:

# From crates.io
cargo install agent-doc

# From PyPI
pip install agent-doc

# From source
cargo build --release
cargo install --path .

Quick Start

# 1. Initialize project (creates .agent-doc/ and installs SKILL.md)
agent-doc init

# 2. Scaffold a session document
agent-doc init session.md "My Topic"

# 3. Claim the document to the current tmux pane
agent-doc claim session.md

# 4. Route hotkey triggers to the correct tmux pane
agent-doc route session.md

# 5. Run: diff, send to agent, write response back
agent-doc run session.md

The typical edit cycle: write in your editor, trigger agent-doc route <file> via a hotkey, the agent responds in the same document.

Key Features

  • Template mode — named component regions (<!-- agent:name -->) updated independently; inline attrs (patch=, max_lines=) > components.toml > built-in defaults
  • CRDT merge — yrs-based conflict-free merge for concurrent edits between agent writes and user edits
  • IPC-first writes — socket IPC (Unix domain sockets); editor plugin receives JSON patches instead of file overwrites; preserves cursor position, undo history, and avoids "externally modified" dialogs
  • Tmux routing — persistent Claude Code sessions per document; route dispatches to the correct pane or auto-starts one; reconciler always runs (no early exits) handling 0/1/2+ panes uniformly
  • Streaming — real-time CRDT write-back loop (agent-doc stream) with optional chain-of-thought routing
  • Parallel fan-out — independent git worktrees per subtask, each with its own Claude session (agent-doc parallel)
  • Editor plugins — JetBrains and VS Code plugins for hotkey integration and IPC writes
  • Watch daemon — auto-submit on file change with debounce and reactive mode for stream documents
  • Linked resourceslinks frontmatter field for local files and URLs; URL content fetched, converted HTML→markdown via htmd, cached, and diffed on each preflight
  • Session logging — persistent logs at .agent-doc/logs/<session-uuid>.log for debugging session crashes and restarts
  • Git integration — auto-commit each run; squash history with agent-doc clean
  • Bulk resync — validates session state and fixes stale/orphaned panes in 2 subprocess calls instead of ~20-40; --fix --session <name> relocates WrongSession panes via join-pane instead of killing them
  • Column memory.agent-doc/last_layout.json remembers column→agent-doc mapping; preserves 2-pane tmux layout when one editor column switches to a non-agent file
  • Stash + rescue — replaced panes are stashed (alive in background); stash rescue brings them back when the user switches to that document again
  • Startup lock.agent-doc/starting/<hash>.lock with 5s TTL prevents double-spawn when sync fires twice in quick succession
  • Component-aware baseline guard — detects stale baselines by comparing append-mode components only; user edits to replace-mode components (status, pending) don't trigger false positives
  • Hook system — cross-session event coordination via agent-doc hook fire/poll/listen/gc; integrates with Claude Code hooks via PostToolUse bridge
  • Slash command dispatchpreflight extracts slash commands from user-added diff lines (parse_slash_commands); the SKILL executes them before responding; guards exclude code fences, blockquotes, and non-added lines
  • Dedupe stale patch cleanup — after removing duplicate blocks, dedupe also deletes the stale .agent-doc/patches/<hash>.json to prevent the plugin's startup scan from re-applying removed content

Architecture

The binary owns all deterministic behavior: component parsing, patch application, CRDT merge, snapshot management, git operations, tmux routing, and IPC writes. The SKILL.md Claude Code skill is the non-deterministic orchestrator — it reads the diff, generates responses, and decides what to write.

Binary vs. Agent Responsibility:

Responsibility Owner Why
Component parsing, patch application, mode resolution Binary (Rust) Deterministic, testable, consistent across agents
CRDT merge, snapshot management, atomic writes Binary (Rust) Concurrency safety requires flock + atomic rename
Diff computation, comment stripping, truncation detection Binary (Rust) Reproducible baseline comparison
Git operations (commit, history, clean) Binary (Rust) Direct std::process::Command calls
Tmux routing, session registry, pane management Binary (Rust) Process-level coordination
Pre-response snapshots, undo, extract, transfer Binary (Rust) File-level atomicity
Boundary marker lifecycle (insert, reposition, cleanup) Binary (Rust) Deterministic, all write paths need it
Reading diff, interpreting user intent Skill (SKILL.md) Requires LLM reasoning
Generating response content Skill (SKILL.md) Non-deterministic
Deciding what to write to which component Skill (SKILL.md) Context-dependent
Streaming checkpoints, progress tracking Skill (SKILL.md) Response-generation timing
Pending item management (parse, populate, process) Skill (SKILL.md) Semantic understanding of prompts

See CLAUDE.md for the full module layout, stream mode details, and release process.

Supported Editors

JetBrains (IntelliJ, PyCharm, etc.)

agent-doc plugin install jetbrains

Or install from JetBrains Marketplace. Configure an External Tool: Program=agent-doc, Args=run $FilePath$, Working dir=$ProjectFileDir$. Assign a keyboard shortcut.

VS Code

agent-doc plugin install vscode

Or install from the VS Code Marketplace. Add a task with "command": "agent-doc run ${file}" and bind it to a keybinding.

Vim/Neovim

nnoremap <leader>as :!agent-doc run %<CR>:e<CR>

Domain Ontology

agent-doc extends the existence kernel vocabulary with domain-specific terms.

Document Lifecycle

Term Definition
Session A persistent conversation between a user and an agent, identified by UUID. Stored in frontmatter as agent_doc_session.
Document A markdown file that serves as the UI for a session. Contains frontmatter, components, and user/agent content.
Snapshot A baseline copy of the document at a known state. Used for diff computation and CRDT merge.
Component A named region in a template document (<!-- agent:name -->...<!-- /agent:name -->). Targeted by patch blocks.
Boundary A marker (<!-- agent:boundary:hash -->) that separates committed content from uncommitted user edits.
Exchange The shared conversation surface where user and agent write inline. A component with patch=append.

Pane Lifecycle

Term Definition
Binding The document→pane association stored in sessions.json. Created by claim (explicit) or auto_start (automatic). One document per pane.
Reconciliation The process of matching editor layout to tmux layout. Performed by sync. Stashes unwanted panes, provisions missing ones.
Provisioning Creating a new tmux pane and starting a Claude session for a document. Performed by route::auto_start. The normal path for new documents — sync triggers provisioning when it finds a session UUID with no registered pane.
Initialization Assigning a session UUID, creating a snapshot, and committing to git. Performed by ensure_initialized(). Called from claim, preflight, and sync's resolve_file.

Integration Layer

Term Definition
Route Resolve which tmux pane handles a file. Creates panes if needed (provisioning).
Sync Reconcile editor layout with tmux layout. The primary entrypoint from the JB plugin on every tab switch.
Claim Bind a document to a specific existing pane. Used for manual pane assignment; not needed in normal editor workflow (sync + auto_start handles it).

Interaction Model

Term Definition
Directive A signal that authorizes and requests action. User inputs like "do", "go", "yes" are directives. Classified as DiffType::Approval in preflight. The directive's brevity is independent of the expected execution thoroughness — quality processes always apply in full.
Cycle One round-trip: user edits -> preflight -> agent response -> write-back -> commit. Logged in .agent-doc/logs/cycles.jsonl with git state references for reproducibility.
Layout check Pre-agent tmux health inspection (check_layout()). Detects: missing window 0, non-idle stash panes, and session drift (registered panes spanning multiple tmux sessions). Reported as layout_issues[] in preflight JSON.
Session drift Condition where registered document panes span more than one tmux session. Detected by preflight's check_layout(). Fixed by agent-doc session set <N> to consolidate panes into the target session.
Diff The user's changes since the last snapshot. Classified by classify_diff() into a DiffType for skill routing. Comment-stripped before comparison.
Annotation A user edit to agent-written content (inline modification, colon-append). Classified as DiffType::Annotation.

Security

agent-doc is designed for single-user, local operation. All session data (documents, snapshots, exchange history) is stored on the local filesystem and committed to a git repository.

Current security model:

  • Single user only. There is no multi-user access control, authentication, or session isolation.
  • Private repo recommended. Session documents may contain sensitive content (correspondence, research, credentials in context). Use a private git repository.
  • Prompt injection risk. Content pasted into documents from external sources (emails, web pages, chat logs) could contain prompt injection attempts. The agent processes all document content as user input with no injection scanning.
  • --dangerously-skip-permissions exposure. When running with this flag (common in agent-doc sessions), the agent has full filesystem access. Injected prompts could read files or execute commands if not sandboxed.

Planned: Collaborative security for web/networked deployments (multi-user access control, session isolation, content scanning, compartmented access patterns).

License

Licensed under either of MIT or Apache-2.0 at your option.

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

agent_doc-0.33.1.tar.gz (817.0 kB view details)

Uploaded Source

Built Distributions

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

agent_doc-0.33.1-py3-none-win_amd64.whl (4.0 MB view details)

Uploaded Python 3Windows x86-64

agent_doc-0.33.1-py3-none-manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

agent_doc-0.33.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

agent_doc-0.33.1-py3-none-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

agent_doc-0.33.1-py3-none-macosx_10_12_x86_64.whl (4.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file agent_doc-0.33.1.tar.gz.

File metadata

  • Download URL: agent_doc-0.33.1.tar.gz
  • Upload date:
  • Size: 817.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_doc-0.33.1.tar.gz
Algorithm Hash digest
SHA256 63d92f8e863cd201da39e695924386cfc748bc8d7aae3dc7e58abb5af220e04c
MD5 97bb5fdfef718d47f2dc357f2a3e4c7f
BLAKE2b-256 56b1ccc51c6143f8e5e167a475c0a9f01c0bc8deab8251ad8f8dc4934779ce61

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_doc-0.33.1.tar.gz:

Publisher: pypi.yml on btakita/agent-doc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_doc-0.33.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: agent_doc-0.33.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_doc-0.33.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 89e17775bb37f677dc080a7367cf3a33b548ab600209b06394f25b57967240a9
MD5 4d28b1e335f4600fc08d5908b935cd9e
BLAKE2b-256 5ea3c4f60bfdea787e6080109a28b48b2140fd5ce7c8183abc8c5954fafbc0e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_doc-0.33.1-py3-none-win_amd64.whl:

Publisher: pypi.yml on btakita/agent-doc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_doc-0.33.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for agent_doc-0.33.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b71182c16c69f01bb6abbfd3037579247f0e7b37ab98ae406000ddcb267dd9c
MD5 5df479a39575087416b91928989621e2
BLAKE2b-256 83855cf0b686a090ffac4164eacf1ad0c41e416738c7101e3e29b0348f3cc915

See more details on using hashes here.

File details

Details for the file agent_doc-0.33.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for agent_doc-0.33.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba1f5301be0d52c71eeb1c2f6a3089068e804259d49a5682371a2d12275f0998
MD5 5ce971ef7ac2895e471f2ffc22479484
BLAKE2b-256 a1b2734da3f69ed5714339483f1fd084021912aae75d84050b716e54f0f1f7ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_doc-0.33.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on btakita/agent-doc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_doc-0.33.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for agent_doc-0.33.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af5c7ac0833f75b152ce876633ba5ca1fa83bf31f344fe376cfcba03186ef2e8
MD5 83221ba6c9b881e6538a8bef0ebf7c95
BLAKE2b-256 507492218bd15f870f7b5722668f618719303cd9b5f32bf04e31178e68f9fb4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_doc-0.33.1-py3-none-macosx_11_0_arm64.whl:

Publisher: pypi.yml on btakita/agent-doc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_doc-0.33.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for agent_doc-0.33.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0ba67eeb776126d67866fe47c66cb8bb7bb3e49dd6bed92928c3b060b4ba0caa
MD5 5c9705607f9532fbd9da7ee1a6df0b46
BLAKE2b-256 9174e3ed12c4689ceaed8e386edf4353eae8d9bd2e25caf93c07575cfec3feb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_doc-0.33.1-py3-none-macosx_10_12_x86_64.whl:

Publisher: pypi.yml on btakita/agent-doc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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