Skip to content

Commit f634140

Browse files
committed
update readme
1 parent 5184c61 commit f634140

File tree

1 file changed

+141
-12
lines changed

1 file changed

+141
-12
lines changed

README.md

Lines changed: 141 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,84 @@
33

44
# llmstxt
55

6-
A Python tool to compress code files into a single, LLM-friendly text file.
6+
A Python tool for compressing and organizing code files into a single, LLM-friendly text file. This tool is designed to help prepare codebases for analysis by Large Language Models by removing unnecessary content while preserving important semantic information.
77

88
## Features
99

10-
- Preserves important comments and docstrings
11-
- Removes unnecessary content
12-
- Structured, LLM-friendly output
13-
- GitHub Actions integration for automatic updates
10+
### Smart Code Compression
11+
12+
- Preserves docstrings and important comments
13+
- Removes redundant whitespace and formatting
14+
- Maintains code structure and readability
15+
- Handles multiple programming languages
16+
17+
### Language Support
18+
19+
- Python (with AST-based compression)
20+
- JavaScript
21+
- Java
22+
- C/C++
23+
- Shell scripts
24+
- HTML/CSS
25+
- Configuration files (JSON, YAML, TOML, INI)
26+
- Markdown
27+
28+
### LLM-Friendly Output
29+
30+
- XML-style semantic markers
31+
- File metadata and type information
32+
- Organized imports section
33+
- Clear file boundaries
34+
- Consistent formatting
35+
36+
### Automation
37+
38+
- GitHub Actions integration
39+
- Automatic updates on code changes
40+
- CI/CD friendly
1441

1542
## Installation
1643

44+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management, but can also be installed directly with pip.
45+
1746
```bash
47+
# Using pip
1848
pip install git+https://github.com/ngmisl/llmstxt.git
49+
50+
# Using uv (recommended for development)
51+
curl -LsSf https://astral.sh/uv/install.sh | sh
52+
uv pip install .
53+
54+
# For development
55+
uv pip install -e ".[dev]"
1956
```
2057

2158
## Usage
2259

23-
### Command Line
60+
### Local Usage
2461

2562
```bash
26-
# Generate llms.txt in current directory
63+
# Generate llms.txt from current directory
2764
python -m llmstxt
2865

2966
# Or import and use in your code
3067
from llmstxt import generate_llms_txt
3168
generate_llms_txt()
3269
```
3370

71+
The script will:
72+
73+
1. Scan the current directory recursively
74+
2. Process files according to .gitignore rules
75+
3. Generate `llms.txt` with compressed content
76+
3477
### GitHub Actions Integration
3578

36-
To automatically update `llms.txt` in your repository:
79+
There are two ways to use this tool with GitHub Actions:
3780

38-
1. Create `.github/workflows/update-llms.yml` with:
81+
1. **For Your Own Repository**
82+
83+
Create `.github/workflows/update-llms.yml` with:
3984

4085
```yaml
4186
name: Update llms.txt
@@ -93,28 +138,112 @@ jobs:
93138
```
94139
95140
The workflow will:
141+
96142
- Run on push to main/master
97143
- Run on pull requests
98144
- Can be triggered manually
99145
- Generate and commit `llms.txt` automatically
100146

147+
2. **For Remote Repositories**
148+
You can trigger the action for any repository using the GitHub API:
149+
150+
```bash
151+
curl -X POST \
152+
-H "Authorization: token $GITHUB_TOKEN" \
153+
-H "Accept: application/vnd.github.v3+json" \
154+
https://api.github.com/repos/ngmisl/llmstxt/dispatches \
155+
-d '{"event_type": "update-llms", "client_payload": {"repository": "https://github.com/user/repo.git"}}'
156+
```
157+
158+
## Output Format
159+
160+
The generated `llms.txt` file follows this structure:
161+
162+
```python
163+
# Project: llmstxt
164+
165+
## Project Structure
166+
This file contains the compressed and processed contents of the project.
167+
168+
### File Types
169+
- .py
170+
- .js
171+
- .java
172+
...
173+
174+
<file>src/main.py</file>
175+
<metadata>
176+
path: src/main.py
177+
type: py
178+
size: 1234 bytes
179+
</metadata>
180+
181+
<imports>
182+
import ast
183+
from typing import Optional
184+
</imports>
185+
186+
<code lang='python'>
187+
def example():
188+
"""Docstring preserved."""
189+
return True
190+
</code>
191+
192+
<file>src/utils.js</file>
193+
<metadata>
194+
path: src/utils.js
195+
type: js
196+
size: 567 bytes
197+
</metadata>
198+
199+
<code lang='javascript'>
200+
function helper() {
201+
return true;
202+
}
203+
</code>
204+
```
205+
206+
## Configuration
207+
208+
The tool can be configured through function parameters:
209+
210+
```python
211+
generate_llms_txt(
212+
output_file="llms.txt", # Output filename
213+
max_file_size=100 * 1024, # Max file size (100KB)
214+
allowed_extensions=( # Supported file types
215+
".py", ".js", ".java",
216+
".c", ".cpp", ".h", ".hpp",
217+
".sh", ".txt", ".md",
218+
".json", ".xml", ".yaml",
219+
".yml", ".toml", ".ini"
220+
)
221+
)
222+
```
223+
101224
## Development
102225

226+
Requirements:
227+
228+
- Python 3.8+
229+
- [uv](https://github.com/astral-sh/uv) for dependency management (recommended)
230+
103231
```bash
104232
# Clone the repository
105233
git clone https://github.com/ngmisl/llmstxt.git
106234
cd llmstxt
107235
108236
# Install development dependencies
109-
pip install -e ".[dev]"
237+
uv pip install -e ".[dev]"
110238
111239
# Run type checking
112240
mypy llmstxt
113241
114-
# Run linting
242+
# Run linting and formatting
115243
ruff check llmstxt
244+
ruff format llmstxt
116245
```
117246

118247
## License
119248

120-
MIT
249+
MIT License - See LICENSE file for details

0 commit comments

Comments
 (0)