agent-doc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_doc-0.1.0/.claude/skills/agent-doc/SKILL.md +92 -0
- agent_doc-0.1.0/.github/workflows/book.yml +22 -0
- agent_doc-0.1.0/.github/workflows/ci.yml +21 -0
- agent_doc-0.1.0/.github/workflows/mdbook.yml +60 -0
- agent_doc-0.1.0/.github/workflows/pypi.yml +78 -0
- agent_doc-0.1.0/.github/workflows/release.yml +96 -0
- agent_doc-0.1.0/.gitignore +13 -0
- agent_doc-0.1.0/CLAUDE.md +43 -0
- agent_doc-0.1.0/Cargo.lock +895 -0
- agent_doc-0.1.0/Cargo.toml +34 -0
- agent_doc-0.1.0/Makefile +70 -0
- agent_doc-0.1.0/PKG-INFO +183 -0
- agent_doc-0.1.0/README.md +170 -0
- agent_doc-0.1.0/SKILL.md +98 -0
- agent_doc-0.1.0/SPECS.md +107 -0
- agent_doc-0.1.0/VERSIONS.md +24 -0
- agent_doc-0.1.0/book.toml +9 -0
- agent_doc-0.1.0/docs/SUMMARY.md +27 -0
- agent_doc-0.1.0/docs/development/building.md +49 -0
- agent_doc-0.1.0/docs/development/conventions.md +36 -0
- agent_doc-0.1.0/docs/getting-started/configuration.md +55 -0
- agent_doc-0.1.0/docs/getting-started/installation.md +29 -0
- agent_doc-0.1.0/docs/getting-started/quick-start.md +62 -0
- agent_doc-0.1.0/docs/guide/agent-backends.md +59 -0
- agent_doc-0.1.0/docs/guide/commands.md +79 -0
- agent_doc-0.1.0/docs/guide/document-format.md +66 -0
- agent_doc-0.1.0/docs/guide/editor-integration.md +56 -0
- agent_doc-0.1.0/docs/guide/submit-flow.md +51 -0
- agent_doc-0.1.0/docs/introduction.md +34 -0
- agent_doc-0.1.0/docs/reference/changelog.md +1 -0
- agent_doc-0.1.0/docs/reference/specs.md +1 -0
- agent_doc-0.1.0/install.sh +126 -0
- agent_doc-0.1.0/pyproject.toml +24 -0
- agent_doc-0.1.0/src/agent/claude.rs +110 -0
- agent_doc-0.1.0/src/agent/mod.rs +40 -0
- agent_doc-0.1.0/src/audit_docs.rs +1153 -0
- agent_doc-0.1.0/src/clean.rs +11 -0
- agent_doc-0.1.0/src/config.rs +49 -0
- agent_doc-0.1.0/src/diff.rs +108 -0
- agent_doc-0.1.0/src/frontmatter.rs +186 -0
- agent_doc-0.1.0/src/git.rs +107 -0
- agent_doc-0.1.0/src/init.rs +29 -0
- agent_doc-0.1.0/src/main.rs +99 -0
- agent_doc-0.1.0/src/reset.rs +23 -0
- agent_doc-0.1.0/src/snapshot.rs +151 -0
- agent_doc-0.1.0/src/submit.rs +167 -0
- agent_doc-0.1.0/tests/test_cli.rs +127 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# agent-doc run
|
|
2
|
+
|
|
3
|
+
Interactive document session — respond to user edits in a markdown document.
|
|
4
|
+
|
|
5
|
+
## Invocation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/agent-doc <FILE>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Arguments: `FILE` — path to the session document (e.g., `plan.md`)
|
|
12
|
+
|
|
13
|
+
## Core Principles
|
|
14
|
+
|
|
15
|
+
- **Document is the UI** — the user's edits ARE the prompt; respond in the document AND the console
|
|
16
|
+
- **Preserve user edits** — never overwrite; read the file fresh before writing
|
|
17
|
+
- **Show progress** — stream your response in the console so the user sees real-time feedback
|
|
18
|
+
- **Maintain session** — the document is a living conversation, not a one-shot
|
|
19
|
+
|
|
20
|
+
## Workflow
|
|
21
|
+
|
|
22
|
+
### 1. Read the document and snapshot
|
|
23
|
+
|
|
24
|
+
- Read `<FILE>` to get current content
|
|
25
|
+
- Read the snapshot at `.agent-doc/snapshots/<hash>.md` where `<hash>` is SHA256 of the canonical file path
|
|
26
|
+
- If no snapshot exists, treat this as the first run (entire document is new)
|
|
27
|
+
|
|
28
|
+
### 2. Compute the diff
|
|
29
|
+
|
|
30
|
+
- Compare snapshot (previous state) against current content
|
|
31
|
+
- The diff represents what the user changed since the last run
|
|
32
|
+
- If no diff (content unchanged), tell the user nothing changed and stop
|
|
33
|
+
|
|
34
|
+
### 3. Respond
|
|
35
|
+
|
|
36
|
+
- Address the user's changes naturally in the console (this gives real-time streaming feedback)
|
|
37
|
+
- Respond to:
|
|
38
|
+
- New `## User` blocks
|
|
39
|
+
- Inline annotations (blockquotes, comments, edits to previous responses)
|
|
40
|
+
- Structural changes (deletions, reorganization)
|
|
41
|
+
- Your console response IS the document response — they should be the same content
|
|
42
|
+
|
|
43
|
+
### 4. Write back to the document
|
|
44
|
+
|
|
45
|
+
After responding, update the document file:
|
|
46
|
+
|
|
47
|
+
1. **Re-read the file** (user may have edited during your response)
|
|
48
|
+
2. Append your response as:
|
|
49
|
+
```
|
|
50
|
+
## Assistant
|
|
51
|
+
|
|
52
|
+
<your response>
|
|
53
|
+
|
|
54
|
+
## User
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
3. Use the Edit tool to append (not Write — preserves user edits made during response)
|
|
58
|
+
4. Update the snapshot to match the new document state
|
|
59
|
+
|
|
60
|
+
### 5. Git integration (optional)
|
|
61
|
+
|
|
62
|
+
If the document is in a git repo:
|
|
63
|
+
- Before responding: `git add -f <FILE> && git commit -m "agent-doc: <timestamp>" --no-verify`
|
|
64
|
+
- After writing response: do NOT commit (leave as uncommitted for diff gutters)
|
|
65
|
+
|
|
66
|
+
## Document Format
|
|
67
|
+
|
|
68
|
+
Session documents use YAML frontmatter:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
---
|
|
72
|
+
session: <uuid or null>
|
|
73
|
+
agent: <name or null>
|
|
74
|
+
model: <model or null>
|
|
75
|
+
branch: <branch or null>
|
|
76
|
+
---
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The body alternates `## User` and `## Assistant` blocks. Inline annotations (blockquotes, comments) within any block are valid prompts.
|
|
80
|
+
|
|
81
|
+
## Snapshot Storage
|
|
82
|
+
|
|
83
|
+
- Location: `.agent-doc/snapshots/` relative to CWD
|
|
84
|
+
- Filename: `sha256(canonical_path) + ".md"`
|
|
85
|
+
- Contains the full document content after the last run
|
|
86
|
+
|
|
87
|
+
## Success Criteria
|
|
88
|
+
|
|
89
|
+
- User sees streaming response in the Claude console
|
|
90
|
+
- Document is updated with the response (user can see it in their editor)
|
|
91
|
+
- User edits made during response are preserved (not overwritten)
|
|
92
|
+
- Snapshot is updated for the next run's diff computation
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Book
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
permissions:
|
|
6
|
+
pages: write
|
|
7
|
+
id-token: write
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment:
|
|
12
|
+
name: github-pages
|
|
13
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: taiki-e/install-action@mdbook
|
|
17
|
+
- run: mdbook build
|
|
18
|
+
- uses: actions/upload-pages-artifact@v3
|
|
19
|
+
with:
|
|
20
|
+
path: book
|
|
21
|
+
- id: deployment
|
|
22
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
16
|
+
with:
|
|
17
|
+
components: clippy
|
|
18
|
+
|
|
19
|
+
- run: cargo clippy -- -D warnings
|
|
20
|
+
|
|
21
|
+
- run: cargo test
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Sample workflow for building and deploying a mdBook site to GitHub Pages
|
|
2
|
+
#
|
|
3
|
+
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
|
|
4
|
+
#
|
|
5
|
+
name: Deploy mdBook site to Pages
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
# Runs on pushes targeting the default branch
|
|
9
|
+
push:
|
|
10
|
+
branches: ["main"]
|
|
11
|
+
|
|
12
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
pages: write
|
|
19
|
+
id-token: write
|
|
20
|
+
|
|
21
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
22
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
23
|
+
concurrency:
|
|
24
|
+
group: "pages"
|
|
25
|
+
cancel-in-progress: false
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
# Build job
|
|
29
|
+
build:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
env:
|
|
32
|
+
MDBOOK_VERSION: 0.4.36
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- name: Install mdBook
|
|
36
|
+
run: |
|
|
37
|
+
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
|
|
38
|
+
rustup update
|
|
39
|
+
cargo install --version ${MDBOOK_VERSION} mdbook
|
|
40
|
+
- name: Setup Pages
|
|
41
|
+
id: pages
|
|
42
|
+
uses: actions/configure-pages@v5
|
|
43
|
+
- name: Build with mdBook
|
|
44
|
+
run: mdbook build
|
|
45
|
+
- name: Upload artifact
|
|
46
|
+
uses: actions/upload-pages-artifact@v3
|
|
47
|
+
with:
|
|
48
|
+
path: ./book
|
|
49
|
+
|
|
50
|
+
# Deployment job
|
|
51
|
+
deploy:
|
|
52
|
+
environment:
|
|
53
|
+
name: github-pages
|
|
54
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
needs: build
|
|
57
|
+
steps:
|
|
58
|
+
- name: Deploy to GitHub Pages
|
|
59
|
+
id: deployment
|
|
60
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
include:
|
|
16
|
+
- target: x86_64-unknown-linux-gnu
|
|
17
|
+
os: ubuntu-latest
|
|
18
|
+
- target: aarch64-unknown-linux-gnu
|
|
19
|
+
os: ubuntu-latest
|
|
20
|
+
- target: x86_64-apple-darwin
|
|
21
|
+
os: macos-13
|
|
22
|
+
- target: aarch64-apple-darwin
|
|
23
|
+
os: macos-latest
|
|
24
|
+
- target: x86_64-pc-windows-msvc
|
|
25
|
+
os: windows-latest
|
|
26
|
+
|
|
27
|
+
runs-on: ${{ matrix.os }}
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
|
|
36
|
+
- name: Build wheel
|
|
37
|
+
uses: PyO3/maturin-action@v1
|
|
38
|
+
with:
|
|
39
|
+
target: ${{ matrix.target }}
|
|
40
|
+
args: --release --out dist
|
|
41
|
+
manylinux: auto
|
|
42
|
+
|
|
43
|
+
- uses: actions/upload-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: wheel-${{ matrix.target }}
|
|
46
|
+
path: dist
|
|
47
|
+
|
|
48
|
+
sdist:
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Build sdist
|
|
54
|
+
uses: PyO3/maturin-action@v1
|
|
55
|
+
with:
|
|
56
|
+
command: sdist
|
|
57
|
+
args: --out dist
|
|
58
|
+
|
|
59
|
+
- uses: actions/upload-artifact@v4
|
|
60
|
+
with:
|
|
61
|
+
name: sdist
|
|
62
|
+
path: dist
|
|
63
|
+
|
|
64
|
+
publish:
|
|
65
|
+
needs: [build, sdist]
|
|
66
|
+
runs-on: ubuntu-latest
|
|
67
|
+
environment: pypi
|
|
68
|
+
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/download-artifact@v4
|
|
71
|
+
with:
|
|
72
|
+
path: dist
|
|
73
|
+
merge-multiple: true
|
|
74
|
+
|
|
75
|
+
- name: Publish to PyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
77
|
+
with:
|
|
78
|
+
packages-dir: dist
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
include:
|
|
16
|
+
- target: x86_64-unknown-linux-gnu
|
|
17
|
+
os: ubuntu-latest
|
|
18
|
+
use_cross: false
|
|
19
|
+
- target: aarch64-unknown-linux-gnu
|
|
20
|
+
os: ubuntu-latest
|
|
21
|
+
use_cross: true
|
|
22
|
+
- target: x86_64-apple-darwin
|
|
23
|
+
os: macos-14
|
|
24
|
+
use_cross: false
|
|
25
|
+
- target: aarch64-apple-darwin
|
|
26
|
+
os: macos-latest
|
|
27
|
+
use_cross: false
|
|
28
|
+
- target: x86_64-pc-windows-msvc
|
|
29
|
+
os: windows-latest
|
|
30
|
+
use_cross: false
|
|
31
|
+
|
|
32
|
+
runs-on: ${{ matrix.os }}
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
|
|
37
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
38
|
+
with:
|
|
39
|
+
targets: ${{ matrix.target }}
|
|
40
|
+
|
|
41
|
+
- name: Install cross
|
|
42
|
+
if: matrix.use_cross
|
|
43
|
+
run: cargo install cross --version 0.2.5
|
|
44
|
+
|
|
45
|
+
- name: Build (cross)
|
|
46
|
+
if: matrix.use_cross
|
|
47
|
+
run: cross build --release --target ${{ matrix.target }}
|
|
48
|
+
env:
|
|
49
|
+
CROSS_CONTAINER_ENGINE: docker
|
|
50
|
+
|
|
51
|
+
- name: Build (cargo)
|
|
52
|
+
if: "!matrix.use_cross"
|
|
53
|
+
run: cargo build --release --target ${{ matrix.target }}
|
|
54
|
+
|
|
55
|
+
- name: Package (Unix)
|
|
56
|
+
if: runner.os != 'Windows'
|
|
57
|
+
run: tar czf agent-doc-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release agent-doc
|
|
58
|
+
|
|
59
|
+
- name: Package (Windows)
|
|
60
|
+
if: runner.os == 'Windows'
|
|
61
|
+
shell: pwsh
|
|
62
|
+
run: Compress-Archive -Path target/${{ matrix.target }}/release/agent-doc.exe -DestinationPath agent-doc-${{ matrix.target }}.zip
|
|
63
|
+
|
|
64
|
+
- name: Upload artifact (Unix)
|
|
65
|
+
if: runner.os != 'Windows'
|
|
66
|
+
uses: actions/upload-artifact@v4
|
|
67
|
+
with:
|
|
68
|
+
name: agent-doc-${{ matrix.target }}
|
|
69
|
+
path: agent-doc-${{ matrix.target }}.tar.gz
|
|
70
|
+
|
|
71
|
+
- name: Upload artifact (Windows)
|
|
72
|
+
if: runner.os == 'Windows'
|
|
73
|
+
uses: actions/upload-artifact@v4
|
|
74
|
+
with:
|
|
75
|
+
name: agent-doc-${{ matrix.target }}
|
|
76
|
+
path: agent-doc-${{ matrix.target }}.zip
|
|
77
|
+
|
|
78
|
+
release:
|
|
79
|
+
needs: build
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/download-artifact@v4
|
|
83
|
+
with:
|
|
84
|
+
path: artifacts
|
|
85
|
+
merge-multiple: true
|
|
86
|
+
|
|
87
|
+
- name: Create release
|
|
88
|
+
env:
|
|
89
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
90
|
+
GH_REPO: ${{ github.repository }}
|
|
91
|
+
run: |
|
|
92
|
+
tag="${GITHUB_REF#refs/tags/}"
|
|
93
|
+
gh release create "$tag" \
|
|
94
|
+
--title "agent-doc $tag" \
|
|
95
|
+
--generate-notes \
|
|
96
|
+
artifacts/*
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# agent-doc
|
|
2
|
+
|
|
3
|
+
Interactive document sessions with AI agents.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- Use `clap` derive for CLI argument parsing
|
|
8
|
+
- Use `serde` derive for all data types
|
|
9
|
+
- Use `serde_yaml` for frontmatter parsing
|
|
10
|
+
- Use `similar` crate for diffing (pure Rust, no shell `diff` dependency)
|
|
11
|
+
- Use `serde_json` for agent response parsing
|
|
12
|
+
- Use `std::process::Command` for git operations (not `git2`)
|
|
13
|
+
- Use `toml + serde` for config file parsing
|
|
14
|
+
- No async — sequential per-run
|
|
15
|
+
- Use `anyhow` for application errors
|
|
16
|
+
|
|
17
|
+
## Module Layout
|
|
18
|
+
|
|
19
|
+
Use this layout when adding modules. Add new subcommands in their own file, wired through `main.rs`.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/
|
|
23
|
+
main.rs # CLI entry point (clap derive)
|
|
24
|
+
submit.rs # Core loop: diff, send, merge-safe write, snapshot, git
|
|
25
|
+
init.rs # Scaffold session document
|
|
26
|
+
reset.rs # Clear session + snapshot
|
|
27
|
+
diff.rs # Preview diff (dry run)
|
|
28
|
+
clean.rs # Squash git history
|
|
29
|
+
frontmatter.rs # YAML frontmatter parse/write
|
|
30
|
+
snapshot.rs # Snapshot path/read/write
|
|
31
|
+
git.rs # Commit, branch, squash
|
|
32
|
+
config.rs # Global config (~/.config/agent-doc/config.toml)
|
|
33
|
+
agent/
|
|
34
|
+
mod.rs # Agent trait
|
|
35
|
+
claude.rs # Claude backend
|
|
36
|
+
audit_docs.rs # Audit instruction files (CLAUDE.md, AGENTS.md, SKILL.md)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Agent Backend Contract
|
|
40
|
+
|
|
41
|
+
Each agent backend implements: take a prompt string, return (response_text, session_id).
|
|
42
|
+
The prompt includes the diff and full document. The agent backend handles CLI
|
|
43
|
+
invocation, JSON parsing, and session flags.
|