ragtime-cli 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl
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.
Potentially problematic release.
This version of ragtime-cli might be problematic. Click here for more details.
- ragtime_cli-0.2.5.dist-info/METADATA +402 -0
- {ragtime_cli-0.2.3.dist-info → ragtime_cli-0.2.5.dist-info}/RECORD +13 -11
- src/cli.py +625 -4
- src/commands/generate-docs.md +325 -0
- src/config.py +1 -1
- src/indexers/__init__.py +6 -0
- src/indexers/code.py +473 -0
- src/mcp_server.py +1 -1
- src/memory.py +6 -1
- ragtime_cli-0.2.3.dist-info/METADATA +0 -220
- {ragtime_cli-0.2.3.dist-info → ragtime_cli-0.2.5.dist-info}/WHEEL +0 -0
- {ragtime_cli-0.2.3.dist-info → ragtime_cli-0.2.5.dist-info}/entry_points.txt +0 -0
- {ragtime_cli-0.2.3.dist-info → ragtime_cli-0.2.5.dist-info}/licenses/LICENSE +0 -0
- {ragtime_cli-0.2.3.dist-info → ragtime_cli-0.2.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate documentation from code with AI analysis
|
|
3
|
+
allowed-arguments: path to code (e.g., /generate-docs src/)
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, AskUserQuestion, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Generate Docs
|
|
8
|
+
|
|
9
|
+
Analyze code and generate comprehensive documentation.
|
|
10
|
+
|
|
11
|
+
**Usage:**
|
|
12
|
+
- `/generate-docs src/` - Generate docs for src folder
|
|
13
|
+
- `/generate-docs src/auth/` - Document specific module
|
|
14
|
+
- `/generate-docs` - Interactive mode
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
You (Claude) will:
|
|
19
|
+
1. Read and understand the code
|
|
20
|
+
2. Write clear, helpful documentation
|
|
21
|
+
3. Include examples and usage notes
|
|
22
|
+
4. Output as markdown files
|
|
23
|
+
|
|
24
|
+
This is the AI-powered version. For quick stubs without AI, use `ragtime generate --stubs`.
|
|
25
|
+
|
|
26
|
+
## Step 1: Get the Code Path
|
|
27
|
+
|
|
28
|
+
**If `$ARGUMENTS` provided:**
|
|
29
|
+
- Use it as the code path
|
|
30
|
+
|
|
31
|
+
**If no arguments:**
|
|
32
|
+
- Ask: "What code should I document? (e.g., src/, src/auth/, specific file)"
|
|
33
|
+
|
|
34
|
+
## Step 2: Discover Code Files
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Find code files
|
|
38
|
+
find {path} -type f \( -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" \) \
|
|
39
|
+
-not -path "*/__pycache__/*" \
|
|
40
|
+
-not -path "*/node_modules/*" \
|
|
41
|
+
-not -path "*/.venv/*"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If many files found, ask:
|
|
45
|
+
```
|
|
46
|
+
Found {count} files. Options:
|
|
47
|
+
|
|
48
|
+
1. Document all
|
|
49
|
+
2. Document specific folder
|
|
50
|
+
3. Document specific files (I'll list them)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Step 3: Choose Output Location
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Where should I save the documentation?
|
|
57
|
+
|
|
58
|
+
1. **docs/api/** - API reference docs
|
|
59
|
+
2. **docs/code/** - Code documentation
|
|
60
|
+
3. **.ragtime/app/** - As searchable memories
|
|
61
|
+
4. **Custom path**
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Step 4: Analyze and Document Each File
|
|
65
|
+
|
|
66
|
+
For each code file:
|
|
67
|
+
|
|
68
|
+
1. **Read the full file**
|
|
69
|
+
2. **Understand what it does** - purpose, patterns, relationships
|
|
70
|
+
3. **Write documentation** that explains:
|
|
71
|
+
- What the module/class/function does
|
|
72
|
+
- Why it exists (context)
|
|
73
|
+
- How to use it (examples)
|
|
74
|
+
- Important details (edge cases, requirements)
|
|
75
|
+
|
|
76
|
+
### Documentation Quality Guidelines
|
|
77
|
+
|
|
78
|
+
**Good documentation answers:**
|
|
79
|
+
- What does this do?
|
|
80
|
+
- Why would I use it?
|
|
81
|
+
- How do I use it?
|
|
82
|
+
- What should I watch out for?
|
|
83
|
+
|
|
84
|
+
**Avoid:**
|
|
85
|
+
- Just restating the function name ("getUserById gets a user by ID")
|
|
86
|
+
- Obvious descriptions
|
|
87
|
+
- Missing the "why"
|
|
88
|
+
|
|
89
|
+
### Documentation Template
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
# {Module Name}
|
|
93
|
+
|
|
94
|
+
> **File:** `{path}`
|
|
95
|
+
|
|
96
|
+
## Overview
|
|
97
|
+
|
|
98
|
+
{2-3 sentences explaining what this module does and why it exists}
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
\`\`\`{language}
|
|
103
|
+
{Simple usage example}
|
|
104
|
+
\`\`\`
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## API Reference
|
|
109
|
+
|
|
110
|
+
### `ClassName`
|
|
111
|
+
|
|
112
|
+
{Description of the class - what it represents, when to use it}
|
|
113
|
+
|
|
114
|
+
#### Constructor
|
|
115
|
+
|
|
116
|
+
\`\`\`{language}
|
|
117
|
+
{constructor signature}
|
|
118
|
+
\`\`\`
|
|
119
|
+
|
|
120
|
+
| Parameter | Type | Description |
|
|
121
|
+
|-----------|------|-------------|
|
|
122
|
+
| `param` | `Type` | {Actual description} |
|
|
123
|
+
|
|
124
|
+
#### Methods
|
|
125
|
+
|
|
126
|
+
##### `methodName(params) -> ReturnType`
|
|
127
|
+
|
|
128
|
+
{What this method does, not just restating the name}
|
|
129
|
+
|
|
130
|
+
**Parameters:**
|
|
131
|
+
- `param` (`Type`): {Description}
|
|
132
|
+
|
|
133
|
+
**Returns:** {What it returns and when}
|
|
134
|
+
|
|
135
|
+
**Example:**
|
|
136
|
+
\`\`\`{language}
|
|
137
|
+
{Practical example}
|
|
138
|
+
\`\`\`
|
|
139
|
+
|
|
140
|
+
**Notes:**
|
|
141
|
+
- {Important edge cases}
|
|
142
|
+
- {Performance considerations}
|
|
143
|
+
- {Related methods}
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Functions
|
|
148
|
+
|
|
149
|
+
### `functionName(params) -> ReturnType`
|
|
150
|
+
|
|
151
|
+
{Description}
|
|
152
|
+
|
|
153
|
+
{Parameters, returns, example - same format as methods}
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Constants / Configuration
|
|
158
|
+
|
|
159
|
+
| Name | Value | Description |
|
|
160
|
+
|------|-------|-------------|
|
|
161
|
+
| `CONSTANT` | `value` | {What it's for} |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## See Also
|
|
166
|
+
|
|
167
|
+
- [{Related Module}]({link})
|
|
168
|
+
- [{External Docs}]({link})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Step 5: Add Frontmatter (if .ragtime/ output)
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
---
|
|
175
|
+
namespace: app
|
|
176
|
+
type: architecture
|
|
177
|
+
component: {from path}
|
|
178
|
+
source: generate-docs
|
|
179
|
+
confidence: medium
|
|
180
|
+
confidence_reason: ai-generated
|
|
181
|
+
---
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Step 6: Write and Report
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Generating documentation...
|
|
188
|
+
|
|
189
|
+
✓ src/auth/jwt.py → docs/api/auth/jwt.md
|
|
190
|
+
- JWTManager class
|
|
191
|
+
- create_token, validate_token functions
|
|
192
|
+
|
|
193
|
+
✓ src/auth/sessions.py → docs/api/auth/sessions.md
|
|
194
|
+
- SessionStore class
|
|
195
|
+
- Redis integration details
|
|
196
|
+
|
|
197
|
+
✓ src/db/models.py → docs/api/db/models.md
|
|
198
|
+
- User, Claim, Shift models
|
|
199
|
+
- Relationships documented
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Step 7: Summary
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
───────────────────────────────────────────
|
|
206
|
+
✅ DOCUMENTATION COMPLETE
|
|
207
|
+
───────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
Generated {count} documentation files
|
|
210
|
+
|
|
211
|
+
Coverage:
|
|
212
|
+
- {n} classes documented
|
|
213
|
+
- {n} functions documented
|
|
214
|
+
- {n} with examples
|
|
215
|
+
|
|
216
|
+
Output: {output_path}/
|
|
217
|
+
|
|
218
|
+
Next steps:
|
|
219
|
+
- Review the generated docs
|
|
220
|
+
- Add any missing context
|
|
221
|
+
- Run 'ragtime index' to make searchable
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Best Practices
|
|
225
|
+
|
|
226
|
+
When writing docs:
|
|
227
|
+
|
|
228
|
+
1. **Start with the "why"** - Don't just describe what, explain purpose
|
|
229
|
+
2. **Include real examples** - Show actual usage, not abstract patterns
|
|
230
|
+
3. **Document edge cases** - What happens with null? Empty arrays?
|
|
231
|
+
4. **Link related concepts** - Help readers navigate
|
|
232
|
+
5. **Keep it scannable** - Use headers, tables, code blocks
|
|
233
|
+
|
|
234
|
+
## Example
|
|
235
|
+
|
|
236
|
+
For this code:
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
class RateLimiter:
|
|
240
|
+
"""Rate limiting using token bucket algorithm."""
|
|
241
|
+
|
|
242
|
+
def __init__(self, requests_per_minute: int = 60):
|
|
243
|
+
self.rpm = requests_per_minute
|
|
244
|
+
self.tokens = requests_per_minute
|
|
245
|
+
self.last_update = time.time()
|
|
246
|
+
|
|
247
|
+
def allow(self, cost: int = 1) -> bool:
|
|
248
|
+
"""Check if request is allowed, consuming tokens if so."""
|
|
249
|
+
self._refill()
|
|
250
|
+
if self.tokens >= cost:
|
|
251
|
+
self.tokens -= cost
|
|
252
|
+
return True
|
|
253
|
+
return False
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Generate:
|
|
257
|
+
|
|
258
|
+
```markdown
|
|
259
|
+
# RateLimiter
|
|
260
|
+
|
|
261
|
+
> **File:** `src/middleware/rate_limit.py`
|
|
262
|
+
|
|
263
|
+
## Overview
|
|
264
|
+
|
|
265
|
+
Implements rate limiting using the token bucket algorithm. Use this to protect
|
|
266
|
+
APIs from abuse by limiting how many requests a client can make per minute.
|
|
267
|
+
|
|
268
|
+
## Quick Start
|
|
269
|
+
|
|
270
|
+
\`\`\`python
|
|
271
|
+
limiter = RateLimiter(requests_per_minute=100)
|
|
272
|
+
|
|
273
|
+
@app.before_request
|
|
274
|
+
def check_rate_limit():
|
|
275
|
+
if not limiter.allow():
|
|
276
|
+
return {"error": "Rate limit exceeded"}, 429
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## API Reference
|
|
282
|
+
|
|
283
|
+
### `RateLimiter`
|
|
284
|
+
|
|
285
|
+
A token bucket rate limiter. Tokens refill continuously over time, allowing
|
|
286
|
+
for burst traffic while maintaining an average rate limit.
|
|
287
|
+
|
|
288
|
+
#### Constructor
|
|
289
|
+
|
|
290
|
+
\`\`\`python
|
|
291
|
+
RateLimiter(requests_per_minute: int = 60)
|
|
292
|
+
\`\`\`
|
|
293
|
+
|
|
294
|
+
| Parameter | Type | Default | Description |
|
|
295
|
+
|-----------|------|---------|-------------|
|
|
296
|
+
| `requests_per_minute` | `int` | `60` | Maximum requests allowed per minute |
|
|
297
|
+
|
|
298
|
+
#### Methods
|
|
299
|
+
|
|
300
|
+
##### `allow(cost: int = 1) -> bool`
|
|
301
|
+
|
|
302
|
+
Check if a request should be allowed. If allowed, consumes tokens from the bucket.
|
|
303
|
+
|
|
304
|
+
**Parameters:**
|
|
305
|
+
- `cost` (`int`): Number of tokens this request costs. Use higher values for
|
|
306
|
+
expensive operations.
|
|
307
|
+
|
|
308
|
+
**Returns:** `True` if the request is allowed, `False` if rate limited.
|
|
309
|
+
|
|
310
|
+
**Example:**
|
|
311
|
+
\`\`\`python
|
|
312
|
+
# Normal request
|
|
313
|
+
if limiter.allow():
|
|
314
|
+
process_request()
|
|
315
|
+
|
|
316
|
+
# Expensive operation (costs 5 tokens)
|
|
317
|
+
if limiter.allow(cost=5):
|
|
318
|
+
run_expensive_query()
|
|
319
|
+
\`\`\`
|
|
320
|
+
|
|
321
|
+
**Notes:**
|
|
322
|
+
- Tokens refill continuously, not all at once
|
|
323
|
+
- Thread-safe for single-process use
|
|
324
|
+
- For distributed systems, use Redis-backed rate limiting instead
|
|
325
|
+
```
|
src/config.py
CHANGED
|
@@ -26,7 +26,7 @@ class DocsConfig:
|
|
|
26
26
|
class CodeConfig:
|
|
27
27
|
"""Configuration for code indexing."""
|
|
28
28
|
paths: list[str] = field(default_factory=lambda: ["."])
|
|
29
|
-
languages: list[str] = field(default_factory=lambda: ["
|
|
29
|
+
languages: list[str] = field(default_factory=lambda: ["python", "typescript", "javascript", "vue", "dart"])
|
|
30
30
|
exclude: list[str] = field(default_factory=lambda: [
|
|
31
31
|
"**/node_modules/**",
|
|
32
32
|
"**/.git/**",
|
src/indexers/__init__.py
CHANGED