doc-fetch 1.0.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.
- doc_fetch-1.0.0/PKG-INFO +219 -0
- doc_fetch-1.0.0/README.md +188 -0
- doc_fetch-1.0.0/cmd/docfetch/main.go +54 -0
- doc_fetch-1.0.0/doc_fetch/__init__.py +6 -0
- doc_fetch-1.0.0/doc_fetch/__main__.py +7 -0
- doc_fetch-1.0.0/doc_fetch/cli.py +113 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/PKG-INFO +219 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/SOURCES.txt +19 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/dependency_links.txt +1 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/entry_points.txt +2 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/not-zip-safe +1 -0
- doc_fetch-1.0.0/doc_fetch.egg-info/top_level.txt +1 -0
- doc_fetch-1.0.0/docs/usage.md +67 -0
- doc_fetch-1.0.0/examples/golang-example.sh +12 -0
- doc_fetch-1.0.0/go.mod +11 -0
- doc_fetch-1.0.0/pkg/fetcher/fetcher.go +332 -0
- doc_fetch-1.0.0/pkg/fetcher/html2md.go +71 -0
- doc_fetch-1.0.0/pkg/fetcher/writer.go +32 -0
- doc_fetch-1.0.0/pyproject.toml +37 -0
- doc_fetch-1.0.0/setup.cfg +4 -0
- doc_fetch-1.0.0/setup.py +158 -0
doc_fetch-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: doc-fetch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Dynamic documentation fetching CLI that converts entire documentation sites to single markdown files for AI/LLM consumption
|
|
5
|
+
Home-page: https://github.com/AlphaTechini/doc-fetch
|
|
6
|
+
Author: AlphaTechini
|
|
7
|
+
Author-email: AlphaTechini <rehobothokoibu@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/AlphaTechini/doc-fetch
|
|
10
|
+
Project-URL: Repository, https://github.com/AlphaTechini/doc-fetch
|
|
11
|
+
Project-URL: Documentation, https://github.com/AlphaTechini/doc-fetch#readme
|
|
12
|
+
Keywords: documentation,ai,llm,markdown,crawler,security
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Documentation
|
|
24
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.7
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
Dynamic: author
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
|
|
32
|
+
# DocFetch - Dynamic Documentation Fetcher š
|
|
33
|
+
|
|
34
|
+
**Transform entire documentation sites into AI-ready, single-file markdown with intelligent LLM.txt indexing**
|
|
35
|
+
|
|
36
|
+
Most AIs can't navigate documentation like humans do. They can't scroll through sections, click sidebar links, or explore related pages. **DocFetch solves this fundamental problem** by converting entire documentation sites into comprehensive, clean markdown files that contain every section and piece of information in a format that LLMs love.
|
|
37
|
+
|
|
38
|
+
## š Why DocFetch is Essential for AI Development
|
|
39
|
+
|
|
40
|
+
### š¤ **AI/LLM Optimization**
|
|
41
|
+
- **Single-file consumption**: No more fragmented context across multiple pages
|
|
42
|
+
- **Clean, structured markdown**: Perfect token efficiency for LLM context windows
|
|
43
|
+
- **Intelligent LLM.txt generation**: AI-friendly index with semantic categorization
|
|
44
|
+
- **Noise removal**: Automatically strips navigation, headers, footers, ads, and buttons
|
|
45
|
+
|
|
46
|
+
### ā” **Developer Productivity**
|
|
47
|
+
- **One command automation**: Replace hours of manual copy-pasting with a single CLI command
|
|
48
|
+
- **Complete documentation access**: Give your AI agents full access to official documentation
|
|
49
|
+
- **Consistent formatting**: Uniform structure across different documentation sites
|
|
50
|
+
- **Version control friendly**: Markdown files work perfectly with Git
|
|
51
|
+
|
|
52
|
+
### šÆ **Smart Content Intelligence**
|
|
53
|
+
- **Automatic page classification**: Identifies APIs, guides, references, and examples
|
|
54
|
+
- **Semantic descriptions**: Generates concise, relevant descriptions for each section
|
|
55
|
+
- **URL preservation**: Maintains original source links for verification
|
|
56
|
+
- **Adaptive content extraction**: Works with diverse documentation site structures
|
|
57
|
+
|
|
58
|
+
### š§ **Production Ready**
|
|
59
|
+
- **Concurrent fetching**: Fast downloads with configurable concurrency
|
|
60
|
+
- **Respectful crawling**: Honors robots.txt and includes rate limiting
|
|
61
|
+
- **Cross-platform**: Works on Windows, macOS, and Linux
|
|
62
|
+
- **Multiple installation options**: NPM, Go install, or direct binary download
|
|
63
|
+
|
|
64
|
+
## š¦ Installation
|
|
65
|
+
|
|
66
|
+
### NPM (Recommended for JavaScript/Node.js developers)
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g doc-fetch
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Go (For Go developers)
|
|
72
|
+
```bash
|
|
73
|
+
go install github.com/AlphaTechini/doc-fetch/cmd/docfetch@latest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Direct Binary Download
|
|
77
|
+
Visit [Releases](https://github.com/AlphaTechini/doc-fetch/releases) and download your platform's binary.
|
|
78
|
+
|
|
79
|
+
## šÆ Usage
|
|
80
|
+
|
|
81
|
+
### Basic Usage
|
|
82
|
+
```bash
|
|
83
|
+
# Fetch entire documentation site to single markdown file
|
|
84
|
+
doc-fetch --url https://golang.org/doc/ --output ./docs/golang-full.md
|
|
85
|
+
|
|
86
|
+
# With LLM.txt generation for AI optimization
|
|
87
|
+
doc-fetch --url https://react.dev/learn --output docs.md --llm-txt
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Advanced Usage
|
|
91
|
+
```bash
|
|
92
|
+
# Comprehensive documentation fetch with all features
|
|
93
|
+
doc-fetch \
|
|
94
|
+
--url https://docs.example.com \
|
|
95
|
+
--output ./internal/docs.md \
|
|
96
|
+
--depth 4 \
|
|
97
|
+
--concurrent 10 \
|
|
98
|
+
--llm-txt \
|
|
99
|
+
--user-agent "MyBot/1.0"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Command Options
|
|
103
|
+
| Flag | Short | Description | Default |
|
|
104
|
+
|------|-------|-------------|---------|
|
|
105
|
+
| `--url` | `-u` | Base URL to fetch documentation from | **Required** |
|
|
106
|
+
| `--output` | `-o` | Output file path | `docs.md` |
|
|
107
|
+
| `--depth` | `-d` | Maximum crawl depth | `2` |
|
|
108
|
+
| `--concurrent` | `-c` | Number of concurrent fetchers | `3` |
|
|
109
|
+
| `--llm-txt` | | Generate AI-friendly llm.txt index | `false` |
|
|
110
|
+
| `--user-agent` | | Custom user agent string | `DocFetch/1.0` |
|
|
111
|
+
|
|
112
|
+
## š Output Files
|
|
113
|
+
|
|
114
|
+
When using `--llm-txt`, DocFetch generates two files:
|
|
115
|
+
|
|
116
|
+
### `docs.md` - Complete Documentation
|
|
117
|
+
```markdown
|
|
118
|
+
# Documentation
|
|
119
|
+
|
|
120
|
+
This file contains documentation fetched by DocFetch.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Getting Started
|
|
125
|
+
|
|
126
|
+
This guide covers installation, setup, and first program...
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Language Specification
|
|
131
|
+
|
|
132
|
+
Complete Go language specification and syntax...
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `docs.llm.txt` - AI-Friendly Index
|
|
136
|
+
```txt
|
|
137
|
+
# llm.txt - AI-friendly documentation index
|
|
138
|
+
|
|
139
|
+
[GUIDE] Getting Started
|
|
140
|
+
https://golang.org/doc/install
|
|
141
|
+
Covers installation, setup, and first program.
|
|
142
|
+
|
|
143
|
+
[REFERENCE] Language Specification
|
|
144
|
+
https://golang.org/ref/spec
|
|
145
|
+
Complete Go language specification and syntax.
|
|
146
|
+
|
|
147
|
+
[API] net/http
|
|
148
|
+
https://pkg.go.dev/net/http
|
|
149
|
+
HTTP client/server implementation.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## š Real-World Examples
|
|
153
|
+
|
|
154
|
+
### Fetch Go Documentation
|
|
155
|
+
```bash
|
|
156
|
+
doc-fetch --url https://golang.org/doc/ --output ./docs/go-documentation.md --depth 4 --llm-txt
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Fetch React Documentation
|
|
160
|
+
```bash
|
|
161
|
+
doc-fetch --url https://react.dev/learn --output ./docs/react-learn.md --concurrent 10 --llm-txt
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Fetch Your Own Project Docs
|
|
165
|
+
```bash
|
|
166
|
+
doc-fetch --url https://your-project.com/docs/ --output ./internal/docs.md --llm-txt
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## š¤ How LLM.txt Supercharges Your AI
|
|
170
|
+
|
|
171
|
+
The generated `llm.txt` file acts as a **semantic roadmap** for your AI agents:
|
|
172
|
+
|
|
173
|
+
1. **Precise Navigation**: Agents can query specific sections without scanning entire documents
|
|
174
|
+
2. **Context Awareness**: Know whether they're looking at an API reference vs. a tutorial
|
|
175
|
+
3. **Efficient Retrieval**: Jump directly to relevant content based on query intent
|
|
176
|
+
4. **Source Verification**: Always maintain links back to original documentation
|
|
177
|
+
|
|
178
|
+
**Example AI Prompt Enhancement:**
|
|
179
|
+
```
|
|
180
|
+
Instead of: "What does the net/http package do?"
|
|
181
|
+
Your AI can now: "Check the [API] net/http section in llm.txt for HTTP client/server implementation details"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## šļø How It Works
|
|
185
|
+
|
|
186
|
+
1. **Link Discovery**: Parses the base URL to find all internal documentation links
|
|
187
|
+
2. **Content Fetching**: Downloads all pages concurrently with respect for robots.txt
|
|
188
|
+
3. **HTML Cleaning**: Removes non-content elements (navigation, headers, footers, etc.)
|
|
189
|
+
4. **Markdown Conversion**: Converts cleaned HTML to structured markdown
|
|
190
|
+
5. **Intelligent Classification**: Categorizes pages as API, GUIDE, REFERENCE, or EXAMPLE
|
|
191
|
+
6. **Description Generation**: Creates concise, relevant descriptions for each section
|
|
192
|
+
7. **Single File Output**: Combines all documentation into one comprehensive file
|
|
193
|
+
8. **LLM.txt Generation**: Creates AI-friendly index with semantic categorization
|
|
194
|
+
|
|
195
|
+
## š Future Features
|
|
196
|
+
|
|
197
|
+
- **Incremental updates**: Only fetch changed pages on subsequent runs
|
|
198
|
+
- **Custom selectors**: Allow users to specify content areas for different sites
|
|
199
|
+
- **Multiple formats**: Support PDF, JSON, and other output formats
|
|
200
|
+
- **Token counting**: Estimate token usage for LLM context planning
|
|
201
|
+
- **Advanced classification**: Machine learning-based page type detection
|
|
202
|
+
|
|
203
|
+
## š” Why This Exists
|
|
204
|
+
|
|
205
|
+
Traditional documentation sites are designed for **human navigation**, not **AI consumption**. When working with LLMs, you often need to manually copy-paste multiple sections or provide incomplete context. DocFetch automates this process, giving your AI agents complete access to documentation without the manual overhead.
|
|
206
|
+
|
|
207
|
+
**Stop wasting time copying documentation. Start building AI agents with complete knowledge.**
|
|
208
|
+
|
|
209
|
+
## š¤ Contributing
|
|
210
|
+
|
|
211
|
+
Contributions are welcome! Please open an issue or pull request on GitHub.
|
|
212
|
+
|
|
213
|
+
## š License
|
|
214
|
+
|
|
215
|
+
MIT License
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
**Built with ā¤ļø for AI developers who deserve better documentation access**
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# DocFetch - Dynamic Documentation Fetcher š
|
|
2
|
+
|
|
3
|
+
**Transform entire documentation sites into AI-ready, single-file markdown with intelligent LLM.txt indexing**
|
|
4
|
+
|
|
5
|
+
Most AIs can't navigate documentation like humans do. They can't scroll through sections, click sidebar links, or explore related pages. **DocFetch solves this fundamental problem** by converting entire documentation sites into comprehensive, clean markdown files that contain every section and piece of information in a format that LLMs love.
|
|
6
|
+
|
|
7
|
+
## š Why DocFetch is Essential for AI Development
|
|
8
|
+
|
|
9
|
+
### š¤ **AI/LLM Optimization**
|
|
10
|
+
- **Single-file consumption**: No more fragmented context across multiple pages
|
|
11
|
+
- **Clean, structured markdown**: Perfect token efficiency for LLM context windows
|
|
12
|
+
- **Intelligent LLM.txt generation**: AI-friendly index with semantic categorization
|
|
13
|
+
- **Noise removal**: Automatically strips navigation, headers, footers, ads, and buttons
|
|
14
|
+
|
|
15
|
+
### ā” **Developer Productivity**
|
|
16
|
+
- **One command automation**: Replace hours of manual copy-pasting with a single CLI command
|
|
17
|
+
- **Complete documentation access**: Give your AI agents full access to official documentation
|
|
18
|
+
- **Consistent formatting**: Uniform structure across different documentation sites
|
|
19
|
+
- **Version control friendly**: Markdown files work perfectly with Git
|
|
20
|
+
|
|
21
|
+
### šÆ **Smart Content Intelligence**
|
|
22
|
+
- **Automatic page classification**: Identifies APIs, guides, references, and examples
|
|
23
|
+
- **Semantic descriptions**: Generates concise, relevant descriptions for each section
|
|
24
|
+
- **URL preservation**: Maintains original source links for verification
|
|
25
|
+
- **Adaptive content extraction**: Works with diverse documentation site structures
|
|
26
|
+
|
|
27
|
+
### š§ **Production Ready**
|
|
28
|
+
- **Concurrent fetching**: Fast downloads with configurable concurrency
|
|
29
|
+
- **Respectful crawling**: Honors robots.txt and includes rate limiting
|
|
30
|
+
- **Cross-platform**: Works on Windows, macOS, and Linux
|
|
31
|
+
- **Multiple installation options**: NPM, Go install, or direct binary download
|
|
32
|
+
|
|
33
|
+
## š¦ Installation
|
|
34
|
+
|
|
35
|
+
### NPM (Recommended for JavaScript/Node.js developers)
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g doc-fetch
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Go (For Go developers)
|
|
41
|
+
```bash
|
|
42
|
+
go install github.com/AlphaTechini/doc-fetch/cmd/docfetch@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Direct Binary Download
|
|
46
|
+
Visit [Releases](https://github.com/AlphaTechini/doc-fetch/releases) and download your platform's binary.
|
|
47
|
+
|
|
48
|
+
## šÆ Usage
|
|
49
|
+
|
|
50
|
+
### Basic Usage
|
|
51
|
+
```bash
|
|
52
|
+
# Fetch entire documentation site to single markdown file
|
|
53
|
+
doc-fetch --url https://golang.org/doc/ --output ./docs/golang-full.md
|
|
54
|
+
|
|
55
|
+
# With LLM.txt generation for AI optimization
|
|
56
|
+
doc-fetch --url https://react.dev/learn --output docs.md --llm-txt
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Advanced Usage
|
|
60
|
+
```bash
|
|
61
|
+
# Comprehensive documentation fetch with all features
|
|
62
|
+
doc-fetch \
|
|
63
|
+
--url https://docs.example.com \
|
|
64
|
+
--output ./internal/docs.md \
|
|
65
|
+
--depth 4 \
|
|
66
|
+
--concurrent 10 \
|
|
67
|
+
--llm-txt \
|
|
68
|
+
--user-agent "MyBot/1.0"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Command Options
|
|
72
|
+
| Flag | Short | Description | Default |
|
|
73
|
+
|------|-------|-------------|---------|
|
|
74
|
+
| `--url` | `-u` | Base URL to fetch documentation from | **Required** |
|
|
75
|
+
| `--output` | `-o` | Output file path | `docs.md` |
|
|
76
|
+
| `--depth` | `-d` | Maximum crawl depth | `2` |
|
|
77
|
+
| `--concurrent` | `-c` | Number of concurrent fetchers | `3` |
|
|
78
|
+
| `--llm-txt` | | Generate AI-friendly llm.txt index | `false` |
|
|
79
|
+
| `--user-agent` | | Custom user agent string | `DocFetch/1.0` |
|
|
80
|
+
|
|
81
|
+
## š Output Files
|
|
82
|
+
|
|
83
|
+
When using `--llm-txt`, DocFetch generates two files:
|
|
84
|
+
|
|
85
|
+
### `docs.md` - Complete Documentation
|
|
86
|
+
```markdown
|
|
87
|
+
# Documentation
|
|
88
|
+
|
|
89
|
+
This file contains documentation fetched by DocFetch.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Getting Started
|
|
94
|
+
|
|
95
|
+
This guide covers installation, setup, and first program...
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Language Specification
|
|
100
|
+
|
|
101
|
+
Complete Go language specification and syntax...
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `docs.llm.txt` - AI-Friendly Index
|
|
105
|
+
```txt
|
|
106
|
+
# llm.txt - AI-friendly documentation index
|
|
107
|
+
|
|
108
|
+
[GUIDE] Getting Started
|
|
109
|
+
https://golang.org/doc/install
|
|
110
|
+
Covers installation, setup, and first program.
|
|
111
|
+
|
|
112
|
+
[REFERENCE] Language Specification
|
|
113
|
+
https://golang.org/ref/spec
|
|
114
|
+
Complete Go language specification and syntax.
|
|
115
|
+
|
|
116
|
+
[API] net/http
|
|
117
|
+
https://pkg.go.dev/net/http
|
|
118
|
+
HTTP client/server implementation.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## š Real-World Examples
|
|
122
|
+
|
|
123
|
+
### Fetch Go Documentation
|
|
124
|
+
```bash
|
|
125
|
+
doc-fetch --url https://golang.org/doc/ --output ./docs/go-documentation.md --depth 4 --llm-txt
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Fetch React Documentation
|
|
129
|
+
```bash
|
|
130
|
+
doc-fetch --url https://react.dev/learn --output ./docs/react-learn.md --concurrent 10 --llm-txt
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Fetch Your Own Project Docs
|
|
134
|
+
```bash
|
|
135
|
+
doc-fetch --url https://your-project.com/docs/ --output ./internal/docs.md --llm-txt
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## š¤ How LLM.txt Supercharges Your AI
|
|
139
|
+
|
|
140
|
+
The generated `llm.txt` file acts as a **semantic roadmap** for your AI agents:
|
|
141
|
+
|
|
142
|
+
1. **Precise Navigation**: Agents can query specific sections without scanning entire documents
|
|
143
|
+
2. **Context Awareness**: Know whether they're looking at an API reference vs. a tutorial
|
|
144
|
+
3. **Efficient Retrieval**: Jump directly to relevant content based on query intent
|
|
145
|
+
4. **Source Verification**: Always maintain links back to original documentation
|
|
146
|
+
|
|
147
|
+
**Example AI Prompt Enhancement:**
|
|
148
|
+
```
|
|
149
|
+
Instead of: "What does the net/http package do?"
|
|
150
|
+
Your AI can now: "Check the [API] net/http section in llm.txt for HTTP client/server implementation details"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## šļø How It Works
|
|
154
|
+
|
|
155
|
+
1. **Link Discovery**: Parses the base URL to find all internal documentation links
|
|
156
|
+
2. **Content Fetching**: Downloads all pages concurrently with respect for robots.txt
|
|
157
|
+
3. **HTML Cleaning**: Removes non-content elements (navigation, headers, footers, etc.)
|
|
158
|
+
4. **Markdown Conversion**: Converts cleaned HTML to structured markdown
|
|
159
|
+
5. **Intelligent Classification**: Categorizes pages as API, GUIDE, REFERENCE, or EXAMPLE
|
|
160
|
+
6. **Description Generation**: Creates concise, relevant descriptions for each section
|
|
161
|
+
7. **Single File Output**: Combines all documentation into one comprehensive file
|
|
162
|
+
8. **LLM.txt Generation**: Creates AI-friendly index with semantic categorization
|
|
163
|
+
|
|
164
|
+
## š Future Features
|
|
165
|
+
|
|
166
|
+
- **Incremental updates**: Only fetch changed pages on subsequent runs
|
|
167
|
+
- **Custom selectors**: Allow users to specify content areas for different sites
|
|
168
|
+
- **Multiple formats**: Support PDF, JSON, and other output formats
|
|
169
|
+
- **Token counting**: Estimate token usage for LLM context planning
|
|
170
|
+
- **Advanced classification**: Machine learning-based page type detection
|
|
171
|
+
|
|
172
|
+
## š” Why This Exists
|
|
173
|
+
|
|
174
|
+
Traditional documentation sites are designed for **human navigation**, not **AI consumption**. When working with LLMs, you often need to manually copy-paste multiple sections or provide incomplete context. DocFetch automates this process, giving your AI agents complete access to documentation without the manual overhead.
|
|
175
|
+
|
|
176
|
+
**Stop wasting time copying documentation. Start building AI agents with complete knowledge.**
|
|
177
|
+
|
|
178
|
+
## š¤ Contributing
|
|
179
|
+
|
|
180
|
+
Contributions are welcome! Please open an issue or pull request on GitHub.
|
|
181
|
+
|
|
182
|
+
## š License
|
|
183
|
+
|
|
184
|
+
MIT License
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
**Built with ā¤ļø for AI developers who deserve better documentation access**
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"flag"
|
|
5
|
+
"log"
|
|
6
|
+
"strings"
|
|
7
|
+
|
|
8
|
+
"github.com/AlphaTechini/doc-fetch/pkg/fetcher"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func main() {
|
|
12
|
+
url := flag.String("url", "", "Base URL to fetch documentation from")
|
|
13
|
+
output := flag.String("output", "docs.md", "Output file path")
|
|
14
|
+
depth := flag.Int("depth", 2, "Maximum crawl depth")
|
|
15
|
+
concurrent := flag.Int("concurrent", 3, "Concurrent fetchers")
|
|
16
|
+
userAgent := flag.String("user-agent", "DocFetch/1.0", "Custom user agent")
|
|
17
|
+
llmTxt := flag.Bool("llm-txt", false, "Generate llm.txt index file")
|
|
18
|
+
|
|
19
|
+
flag.Parse()
|
|
20
|
+
|
|
21
|
+
if *url == "" {
|
|
22
|
+
log.Fatal("Error: URL is required\nUsage: doc-fetch --url <base-url> --output <file-path>")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Validate configuration for security
|
|
26
|
+
config := fetcher.Config{
|
|
27
|
+
BaseURL: *url,
|
|
28
|
+
OutputPath: *output,
|
|
29
|
+
MaxDepth: *depth,
|
|
30
|
+
Workers: *concurrent,
|
|
31
|
+
UserAgent: *userAgent,
|
|
32
|
+
GenerateLLMTxt: *llmTxt,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if err := fetcher.ValidateConfig(&config); err != nil {
|
|
36
|
+
log.Fatalf("Configuration error: %v", err)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
err := fetcher.Run(config)
|
|
40
|
+
if err != nil {
|
|
41
|
+
log.Fatalf("Failed to fetch documentation: %v", err)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
log.Printf("Documentation successfully saved to %s", *output)
|
|
45
|
+
if *llmTxt {
|
|
46
|
+
llmTxtPath := *output
|
|
47
|
+
if strings.HasSuffix(*output, ".md") {
|
|
48
|
+
llmTxtPath = strings.TrimSuffix(*output, ".md") + ".llm.txt"
|
|
49
|
+
} else {
|
|
50
|
+
llmTxtPath = *output + ".llm.txt"
|
|
51
|
+
}
|
|
52
|
+
log.Printf("LLM.txt index generated: %s", llmTxtPath)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
DocFetch CLI wrapper for Python.
|
|
4
|
+
|
|
5
|
+
This module provides a Python interface to the Go-based DocFetch binary.
|
|
6
|
+
It handles downloading the appropriate binary for your platform and
|
|
7
|
+
executing it with the provided arguments.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import subprocess
|
|
13
|
+
import platform
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
# Get the directory where this script is located
|
|
17
|
+
SCRIPT_DIR = Path(__file__).parent
|
|
18
|
+
BIN_DIR = SCRIPT_DIR / "bin"
|
|
19
|
+
BINARY_NAME = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_binary_name():
|
|
23
|
+
"""Get the appropriate binary name for the current platform."""
|
|
24
|
+
system = platform.system().lower()
|
|
25
|
+
machine = platform.machine().lower()
|
|
26
|
+
|
|
27
|
+
# Map machine architectures
|
|
28
|
+
arch_map = {
|
|
29
|
+
'x86_64': 'amd64',
|
|
30
|
+
'amd64': 'amd64',
|
|
31
|
+
'arm64': 'arm64',
|
|
32
|
+
'aarch64': 'arm64'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
arch = arch_map.get(machine, 'amd64')
|
|
36
|
+
|
|
37
|
+
if system == 'windows':
|
|
38
|
+
return f'doc-fetch_windows_{arch}.exe'
|
|
39
|
+
elif system == 'darwin':
|
|
40
|
+
return f'doc-fetch_darwin_{arch}'
|
|
41
|
+
else: # linux and others
|
|
42
|
+
return f'doc-fetch_linux_{arch}'
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def download_binary():
|
|
46
|
+
"""Download the appropriate binary from GitHub releases."""
|
|
47
|
+
import urllib.request
|
|
48
|
+
import ssl
|
|
49
|
+
|
|
50
|
+
binary_name = get_binary_name()
|
|
51
|
+
binary_path = BIN_DIR / binary_name
|
|
52
|
+
|
|
53
|
+
# Create bin directory if it doesn't exist
|
|
54
|
+
BIN_DIR.mkdir(exist_ok=True)
|
|
55
|
+
|
|
56
|
+
# URL for the binary
|
|
57
|
+
url = f"https://github.com/AlphaTechini/doc-fetch/releases/download/v1.0.0/{binary_name}"
|
|
58
|
+
|
|
59
|
+
print(f"š„ Downloading doc-fetch binary for {platform.system()} {platform.machine()}...")
|
|
60
|
+
print(f" URL: {url}")
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
# Create SSL context to handle certificates
|
|
64
|
+
ssl_context = ssl.create_default_context()
|
|
65
|
+
|
|
66
|
+
# Download the binary
|
|
67
|
+
with urllib.request.urlopen(url, context=ssl_context) as response:
|
|
68
|
+
with open(binary_path, 'wb') as f:
|
|
69
|
+
f.write(response.read())
|
|
70
|
+
|
|
71
|
+
# Make executable on Unix-like systems
|
|
72
|
+
if platform.system() != 'Windows':
|
|
73
|
+
os.chmod(binary_path, 0o755)
|
|
74
|
+
|
|
75
|
+
print("ā
Binary downloaded successfully!")
|
|
76
|
+
return binary_path
|
|
77
|
+
|
|
78
|
+
except Exception as e:
|
|
79
|
+
print(f"ā Failed to download binary: {e}")
|
|
80
|
+
print("š” Please ensure you have internet access and can reach GitHub.")
|
|
81
|
+
sys.exit(1)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def main():
|
|
85
|
+
"""Main entry point for the doc-fetch CLI."""
|
|
86
|
+
global BINARY_NAME
|
|
87
|
+
|
|
88
|
+
# Get binary path
|
|
89
|
+
binary_name = get_binary_name()
|
|
90
|
+
binary_path = BIN_DIR / binary_name
|
|
91
|
+
|
|
92
|
+
# Download binary if it doesn't exist
|
|
93
|
+
if not binary_path.exists():
|
|
94
|
+
binary_path = download_binary()
|
|
95
|
+
|
|
96
|
+
# Execute the binary with all arguments
|
|
97
|
+
try:
|
|
98
|
+
result = subprocess.run([str(binary_path)] + sys.argv[1:], check=False)
|
|
99
|
+
sys.exit(result.returncode)
|
|
100
|
+
except FileNotFoundError:
|
|
101
|
+
print("ā doc-fetch binary not found!")
|
|
102
|
+
print("š” This shouldn't happen. Please reinstall the package.")
|
|
103
|
+
sys.exit(1)
|
|
104
|
+
except KeyboardInterrupt:
|
|
105
|
+
print("\nā ļø Interrupted by user")
|
|
106
|
+
sys.exit(130)
|
|
107
|
+
except Exception as e:
|
|
108
|
+
print(f"ā Failed to execute doc-fetch: {e}")
|
|
109
|
+
sys.exit(1)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
main()
|