Skip to content

Commit 80621bf

Browse files
committed
feat(docs): update README and SKILL documentation for clarity and accuracy
1 parent 43540fe commit 80621bf

6 files changed

Lines changed: 244 additions & 145 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ bun.lockb
2828

2929
# Leptos
3030
/site/
31-
code2prompt/
32-
codebank/
31+
.rumdl_cache/

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ exclude = [".github/"]
1010
resolver = "3"
1111

1212
[workspace.dependencies]
13+
# local crates
14+
ast-doc-core = { path = "crates/ast-doc-core", version = "0.1.0" }
15+
16+
# external crates
1317
clap = "4.6.0"
1418
config = "0.15.22"
1519
cucumber = "0.22.1"

README.md

Lines changed: 124 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,128 @@
1-
# Rust Workspace Template
1+
# ast-doc
22

3-
Rust workspace template for `bin/` CLI crates and `crates/` shared libraries with Gherkin + `cucumber-rs` for BDD and `cargo test` for TDD.
3+
AST-powered code documentation tool for generating optimized `llms.txt` files from codebases.
4+
5+
## Overview
6+
7+
`ast-doc` is a Rust CLI tool that combines broad file traversal with deep AST-based semantic parsing to create optimized documentation. It uses a four-stage pipeline:
8+
9+
1. **Ingestion** — File discovery, git metadata capture, directory tree generation
10+
2. **Parser** — tree-sitter AST extraction with pre-computed strategy variants
11+
3. **Scheduler** — Token budget optimization with intelligent degradation
12+
4. **Renderer** — Markdown assembly with anti-bloat rules
13+
14+
## Supported Languages
15+
16+
- Rust (`.rs`)
17+
- Python (`.py`)
18+
- TypeScript/JavaScript (`.ts`, `.tsx`, `.js`, `.jsx`)
19+
- Go (`.go`)
20+
- C (`.c`, `.h`)
21+
22+
## Installation
23+
24+
### As an Agent Skill
25+
26+
Install this skill for use with AI coding agents:
27+
28+
```bash
29+
npx skills add longcipher/ast-doc
30+
```
31+
32+
### From Source
33+
34+
```bash
35+
cargo install --path bin/ast-doc
36+
```
37+
38+
### From crates.io
39+
40+
```bash
41+
cargo install ast-doc
42+
```
443

544
## Features
645

7-
- `bin/` + `crates/` workspace layout
8-
- CLI example (`bin/cli-app`) using `clap`
9-
- Shared library example (`crates/common`)
10-
- BDD acceptance tests with Gherkin + `cucumber-rs`
11-
- TDD inner loop with `cargo test`
12-
- Property tests with `proptest` inside the normal `cargo test` flow
13-
- Optional fuzzing with `cargo-fuzz` for parser-like, protocol, or `unsafe`-heavy crates
14-
- Optional benchmarks with Criterion for performance-sensitive crates
15-
- Strict workspace lint configuration
16-
- `just` commands for format/lint/test/bdd/build
46+
- **Four-stage pipeline**: Ingestion → AST Parser → Token Scheduler → Renderer
47+
- **Output strategies**: Full, NoTests (strip tests), Summary (signatures only)
48+
- **Token budget management**: Configurable `--max-tokens` with automatic degradation
49+
- **Core file protection**: Mark files with `--core` patterns that never get degraded
50+
- **Git context**: Automatic branch, commit, and diff inclusion (disable with `--no-git`)
51+
- **Directory tree**: Visual project structure with language annotations (disable with `--no-tree`)
52+
- **Glob filtering**: Include/exclude patterns for fine-grained file selection
53+
- **Anti-bloat rules**: Compress blank lines, trim trailing whitespace
54+
- **BDD acceptance tests**: Gherkin scenarios with `cucumber-rs`
55+
- **TDD inner loop**: Unit tests with `cargo test`
56+
- **Property tests**: `proptest` in the standard test flow
57+
58+
## Usage
59+
60+
### Basic Usage
61+
62+
```bash
63+
# Generate llms.txt to stdout
64+
ast-doc .
65+
66+
# Write to a file
67+
ast-doc . --output llms.txt
68+
69+
# Set token budget (default: 128,000)
70+
ast-doc . --max-tokens 64000
71+
```
72+
73+
### Output Strategies
74+
75+
```bash
76+
# Full source code (default)
77+
ast-doc . --strategy full
78+
79+
# Strip test modules and functions
80+
ast-doc . --strategy no-tests
81+
82+
# Signatures only, no implementations
83+
ast-doc . --strategy summary
84+
```
85+
86+
### Core Files Protection
87+
88+
```bash
89+
# Core files always use Full strategy, never degraded
90+
ast-doc . --core "src/main.rs" --core "src/lib.rs" --strategy summary
91+
```
92+
93+
### File Filtering
94+
95+
```bash
96+
# Include only Rust files
97+
ast-doc . --include "*.rs"
98+
99+
# Exclude test files
100+
ast-doc . --exclude "*test*"
101+
102+
# Combine include/exclude
103+
ast-doc . --include "*.rs" --exclude "target/**"
104+
```
105+
106+
### Git and Tree Options
107+
108+
```bash
109+
# Skip git context
110+
ast-doc . --no-git
111+
112+
# Skip directory tree
113+
ast-doc . --no-tree
114+
115+
# Copy to clipboard (not yet implemented)
116+
ast-doc . --copy
117+
```
118+
119+
### Verbose Logging
120+
121+
```bash
122+
ast-doc . --verbose
123+
```
17124

18-
## Quick Start
125+
## Quick Start (Development)
19126

20127
```bash
21128
just setup
@@ -24,8 +131,9 @@ just test
24131
just bdd
25132
just test-all
26133

27-
# Run the example CLI
28-
cargo run -p cli-app -- --name Rust
134+
# Run the CLI
135+
cargo run -p ast-doc -- --help
136+
cargo run -p ast-doc -- .
29137
```
30138

31139
## Testing Matrix
@@ -93,4 +201,4 @@ That keeps the default template lean while still pointing parser-like, protocol,
93201

94202
## License
95203

96-
MIT
204+
Apache-2.0

SKILL.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
name: ast-doc
3+
description: AST-powered code documentation tool for generating optimized llms.txt files from codebases. Use this skill when users need to generate LLM-optimized documentation, reduce token usage when feeding code to AI models, create structured Markdown summaries of code repositories, extract code architecture and public interfaces, or prepare code context for AI-assisted development.
4+
metadata:
5+
author: longcipher
6+
version: "0.1.0"
7+
---
8+
9+
# AST Documentation Generator
10+
11+
Generate optimized `llms.txt` files from codebases using AST-based semantic parsing.
12+
13+
## Triggers
14+
15+
Use this skill when users ask to:
16+
17+
- Generate llms.txt or LLM-optimized documentation
18+
- Document a codebase for AI consumption
19+
- Create code summaries or architecture overviews
20+
- Optimize code context for AI models
21+
- Use code2prompt or similar tools
22+
23+
## Installation
24+
25+
Install the skill:
26+
27+
```bash
28+
npx skills add longcipher/ast-doc
29+
```
30+
31+
Install the CLI tool:
32+
33+
```bash
34+
cargo install ast-doc
35+
```
36+
37+
## Basic Usage
38+
39+
```bash
40+
# Generate documentation from current directory
41+
ast-doc .
42+
43+
# With token limit and output file
44+
ast-doc . --max-tokens 30000 --output llms.txt
45+
46+
# Summary mode for quick overview
47+
ast-doc . --strategy summary --output summary.md
48+
49+
# Protect core files from degradation
50+
ast-doc . --max-tokens 50000 --core "src/core/**" --output docs.txt
51+
52+
# Copy to clipboard
53+
ast-doc . --copy
54+
```
55+
56+
## Options
57+
58+
| Option | Description |
59+
|--------|-------------|
60+
| `-o, --output <FILE>` | Output file path (default: stdout) |
61+
| `-m, --max-tokens <NUM>` | Maximum token budget (default: 100000) |
62+
| `-c, --core <PATTERN>` | Glob pattern for core files (never degrade) |
63+
| `-s, --strategy <STRATEGY>` | Default strategy: `full`, `no-tests`, or `summary` |
64+
| `--include <PATTERN>` | Include file patterns |
65+
| `--exclude <PATTERN>` | Exclude file patterns |
66+
| `--no-git` | Skip git context |
67+
| `--no-tree` | Skip directory tree |
68+
| `--copy` | Copy output to clipboard |
69+
| `-v, --verbose` | Verbose output |
70+
71+
## Output Strategies
72+
73+
1. **Full Mode**: Complete source code preservation
74+
2. **NoTests Mode**: Removes test modules and test functions
75+
3. **Summary Mode**: Extracts only public interfaces, signatures, and docstrings
76+
77+
## Workflow
78+
79+
1. Check if ast-doc is installed:
80+
81+
```bash
82+
which ast-doc
83+
```
84+
85+
2. If not installed, install via cargo:
86+
87+
```bash
88+
cargo install ast-doc
89+
```
90+
91+
3. Run ast-doc with appropriate options:
92+
93+
```bash
94+
ast-doc /path/to/project --max-tokens 50000 --output llms.txt
95+
```
96+
97+
4. Review the generated report showing optimization statistics
98+
99+
## Output Format
100+
101+
The tool generates a standard `llms.txt` Markdown file containing:
102+
103+
- Repository name and description
104+
- Directory tree with strategy annotations
105+
- Git context (branch, commits, changes)
106+
- Source files with their processing strategy and token counts
107+
108+
## Tips
109+
110+
- Use `--core` to protect critical files from being summarized
111+
- Start with higher `--max-tokens` values and decrease as needed
112+
- Use `--strategy summary` for quick architectural overviews
113+
- Combine with `--no-git` and `--no-tree` for pure code output
114+
- Check the optimization report to understand token savings

bin/ast-doc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition.workspace = true
55
description = "CLI for generating optimized llms.txt documentation from codebases"
66

77
[dependencies]
8-
ast-doc-core = { path = "../../crates/ast-doc-core" }
8+
ast-doc-core = { workspace = true }
99
clap = { workspace = true, features = ["derive"] }
1010
eyre = { workspace = true }
1111
tracing = { workspace = true }

0 commit comments

Comments
 (0)