ragtime-cli 0.2.2__py3-none-any.whl → 0.2.4__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.2.dist-info → ragtime_cli-0.2.4.dist-info}/METADATA +179 -42
- {ragtime_cli-0.2.2.dist-info → ragtime_cli-0.2.4.dist-info}/RECORD +11 -9
- src/cli.py +657 -7
- src/commands/create-pr.md +389 -0
- src/commands/generate-docs.md +325 -0
- src/commands/pr-graduate.md +7 -2
- src/config.py +19 -0
- {ragtime_cli-0.2.2.dist-info → ragtime_cli-0.2.4.dist-info}/WHEEL +0 -0
- {ragtime_cli-0.2.2.dist-info → ragtime_cli-0.2.4.dist-info}/entry_points.txt +0 -0
- {ragtime_cli-0.2.2.dist-info → ragtime_cli-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {ragtime_cli-0.2.2.dist-info → ragtime_cli-0.2.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a PR with convention checks and graduated knowledge
|
|
3
|
+
allowed-arguments: optional PR title
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, AskUserQuestion, mcp__ragtime__search, mcp__ragtime__memories
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Create PR
|
|
8
|
+
|
|
9
|
+
Create a pull request with branch knowledge graduated and committed alongside the code.
|
|
10
|
+
|
|
11
|
+
**Usage:**
|
|
12
|
+
- `/create-pr` - Interactive PR creation with memory curation
|
|
13
|
+
- `/create-pr "Add authentication flow"` - With suggested title
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
This command ensures code follows team standards and knowledge gets merged with the code:
|
|
18
|
+
|
|
19
|
+
1. Check code against team conventions and app patterns
|
|
20
|
+
2. Review branch memories and decide what graduates to `app/`
|
|
21
|
+
3. Check for conflicts with existing app knowledge
|
|
22
|
+
4. Commit graduated memories as part of the PR
|
|
23
|
+
5. Create the pull request
|
|
24
|
+
|
|
25
|
+
## Step 1: Gather Context
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
BRANCH=$(git branch --show-current)
|
|
29
|
+
BRANCH_SLUG=$(echo "$BRANCH" | tr '/' '-')
|
|
30
|
+
|
|
31
|
+
echo "Branch: $BRANCH"
|
|
32
|
+
|
|
33
|
+
# Check for uncommitted changes
|
|
34
|
+
git status --short
|
|
35
|
+
|
|
36
|
+
# Get commits on this branch
|
|
37
|
+
git log main..HEAD --oneline
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Step 2: Check Code Against Team Conventions
|
|
41
|
+
|
|
42
|
+
Before creating the PR, verify the code follows team standards.
|
|
43
|
+
|
|
44
|
+
### Load conventions config
|
|
45
|
+
|
|
46
|
+
Check `.ragtime/config.yaml` for conventions settings:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
# Default config (if not specified):
|
|
50
|
+
conventions:
|
|
51
|
+
files:
|
|
52
|
+
- ".ragtime/CONVENTIONS.md"
|
|
53
|
+
also_search_memories: true
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Read conventions files
|
|
57
|
+
|
|
58
|
+
For each file in `conventions.files`, read it if it exists:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Check for conventions files
|
|
62
|
+
cat .ragtime/CONVENTIONS.md 2>/dev/null
|
|
63
|
+
# Or other configured files like docs/CODING_STANDARDS.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The conventions doc should contain clear, checkable rules like:
|
|
67
|
+
- "All API endpoints must use auth middleware"
|
|
68
|
+
- "Use async/await, not .then() chains"
|
|
69
|
+
- "Never commit .env files"
|
|
70
|
+
|
|
71
|
+
### Also search memories (if enabled)
|
|
72
|
+
|
|
73
|
+
If `also_search_memories: true` (default), also search for convention memories:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
mcp__ragtime__search:
|
|
77
|
+
query: "convention standard pattern rule always never"
|
|
78
|
+
namespace: "team"
|
|
79
|
+
limit: 20
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
mcp__ragtime__search:
|
|
84
|
+
query: "pattern architecture convention"
|
|
85
|
+
namespace: "app"
|
|
86
|
+
type: "convention,pattern"
|
|
87
|
+
limit: 20
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Get changed files
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Files changed in this branch
|
|
94
|
+
git diff --name-only main...HEAD
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Review code against conventions
|
|
98
|
+
|
|
99
|
+
For each relevant convention/pattern found, check if the changed code follows it:
|
|
100
|
+
|
|
101
|
+
1. Read the convention/pattern memory
|
|
102
|
+
2. Read the relevant changed files
|
|
103
|
+
3. Check for compliance
|
|
104
|
+
|
|
105
|
+
Present findings:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
───────────────────────────────────────────
|
|
109
|
+
🔍 CONVENTION CHECK
|
|
110
|
+
───────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
Checked {file_count} changed files against {convention_count} team conventions.
|
|
113
|
+
|
|
114
|
+
✅ PASSING:
|
|
115
|
+
- "Use async/await, not .then()" - All async code uses await
|
|
116
|
+
- "Error responses use ApiError class" - Verified in api/routes.ts
|
|
117
|
+
|
|
118
|
+
⚠️ POTENTIAL ISSUES:
|
|
119
|
+
- "All API endpoints need auth middleware"
|
|
120
|
+
→ src/api/newEndpoint.ts:15 - No auth middleware detected
|
|
121
|
+
|
|
122
|
+
- "Use logger.error(), not console.error()"
|
|
123
|
+
→ src/services/auth.ts:42 - Found console.error()
|
|
124
|
+
|
|
125
|
+
❌ VIOLATIONS:
|
|
126
|
+
- "Never commit .env files"
|
|
127
|
+
→ .env.local is staged
|
|
128
|
+
───────────────────────────────────────────
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Handle issues
|
|
132
|
+
|
|
133
|
+
If issues found:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
Found {issue_count} potential issues.
|
|
137
|
+
|
|
138
|
+
Options:
|
|
139
|
+
1. **Fix now** - I'll help fix these before creating PR
|
|
140
|
+
2. **Ignore** - Create PR anyway (add justification comment)
|
|
141
|
+
3. **Review each** - Go through issues one by one
|
|
142
|
+
4. **Cancel** - Fix manually and try again
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If "Fix now": Help the user fix each issue before proceeding.
|
|
146
|
+
|
|
147
|
+
If "Ignore": Ask for justification to include in PR description.
|
|
148
|
+
|
|
149
|
+
**Only proceed to memory curation after issues are resolved or acknowledged.**
|
|
150
|
+
|
|
151
|
+
## Step 3: Check for Branch Memories
|
|
152
|
+
|
|
153
|
+
Search for memories in this branch's namespace:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Check .ragtime/branches/{branch-slug}/ for memory files
|
|
157
|
+
ls -la .ragtime/branches/$BRANCH_SLUG/ 2>/dev/null || echo "No branch memories found"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Also search the index:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
mcp__ragtime__search:
|
|
164
|
+
query: "*"
|
|
165
|
+
namespace: "branch-{branch-slug}"
|
|
166
|
+
limit: 50
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**If no branch memories found:** Skip to Step 8 (Create PR).
|
|
170
|
+
|
|
171
|
+
**If memories found:** Continue to Step 4.
|
|
172
|
+
|
|
173
|
+
## Step 4: Present Memories for Curation
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
───────────────────────────────────────────
|
|
177
|
+
📋 BRANCH KNOWLEDGE REVIEW
|
|
178
|
+
───────────────────────────────────────────
|
|
179
|
+
|
|
180
|
+
Before creating the PR, let's review knowledge from this branch.
|
|
181
|
+
|
|
182
|
+
Graduated memories will be:
|
|
183
|
+
- Moved to app/ or team/ namespace
|
|
184
|
+
- Committed as part of this PR
|
|
185
|
+
- Merged with your code changes
|
|
186
|
+
|
|
187
|
+
Found {count} memories in branch-{branch}:
|
|
188
|
+
|
|
189
|
+
───────────────────────────────────────────
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For each memory, show:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
**Memory {n} of {count}:**
|
|
196
|
+
|
|
197
|
+
"{content preview - first 150 chars}..."
|
|
198
|
+
|
|
199
|
+
Type: {type} | Component: {component}
|
|
200
|
+
File: {relative_path}
|
|
201
|
+
|
|
202
|
+
Action?
|
|
203
|
+
1. ✅ Graduate to app/
|
|
204
|
+
2. 🏛️ Graduate to team/ (conventions/standards)
|
|
205
|
+
3. 📚 Keep in branch (don't include in PR)
|
|
206
|
+
4. ❌ Abandon (mark as noise)
|
|
207
|
+
5. 👀 Show full content
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Step 5: Check for Conflicts
|
|
211
|
+
|
|
212
|
+
For each memory being graduated, search for similar content in app/:
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
mcp__ragtime__search:
|
|
216
|
+
query: "{memory content keywords}"
|
|
217
|
+
namespace: "app"
|
|
218
|
+
limit: 5
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
If similar memories exist (similarity > 0.8), present:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
⚠️ POTENTIAL CONFLICT
|
|
225
|
+
|
|
226
|
+
Graduating: "{new memory preview}..."
|
|
227
|
+
|
|
228
|
+
Similar existing memory in app/:
|
|
229
|
+
"{existing memory preview}..."
|
|
230
|
+
File: {existing_file}
|
|
231
|
+
|
|
232
|
+
Options:
|
|
233
|
+
1. **Keep both** - They're different enough
|
|
234
|
+
2. **Replace existing** - New one is better/more current
|
|
235
|
+
3. **Merge** - Combine into one comprehensive memory
|
|
236
|
+
4. **Skip graduation** - Existing one is sufficient
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### If merging:
|
|
240
|
+
|
|
241
|
+
Ask the user to provide the merged content, or offer to draft it:
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
I can draft a merged version combining both. Want me to try?
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
If yes, present the draft for approval before saving.
|
|
248
|
+
|
|
249
|
+
## Step 6: Execute Graduation
|
|
250
|
+
|
|
251
|
+
For each memory to graduate:
|
|
252
|
+
|
|
253
|
+
### Move the file
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# From: .ragtime/branches/{branch-slug}/{id}-{slug}.md
|
|
257
|
+
# To: .ragtime/app/{component}/{id}-{slug}.md (or .ragtime/team/)
|
|
258
|
+
|
|
259
|
+
mkdir -p .ragtime/app/{component}
|
|
260
|
+
mv .ragtime/branches/{branch-slug}/{id}-{slug}.md .ragtime/app/{component}/
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Update the frontmatter
|
|
264
|
+
|
|
265
|
+
Edit the file to update:
|
|
266
|
+
- `namespace: app` (or `team`)
|
|
267
|
+
- `confidence: high`
|
|
268
|
+
- `confidence_reason: pr-graduate`
|
|
269
|
+
- `source: pr-graduate`
|
|
270
|
+
- Add `graduated_from: branch-{branch}`
|
|
271
|
+
|
|
272
|
+
### Stage the changes
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
git add .ragtime/app/
|
|
276
|
+
git add .ragtime/team/
|
|
277
|
+
# Don't stage branch/ folder - it stays local or gets cleaned up later
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Step 7: Commit Knowledge (if any graduated)
|
|
281
|
+
|
|
282
|
+
If memories were graduated:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
git add .ragtime/app/ .ragtime/team/
|
|
286
|
+
|
|
287
|
+
git commit -m "docs: graduate branch knowledge to app
|
|
288
|
+
|
|
289
|
+
Graduated {count} memories from branch-{branch}:
|
|
290
|
+
- {memory1 summary}
|
|
291
|
+
- {memory2 summary}
|
|
292
|
+
..."
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Step 8: Create the PR
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Check if we need to push
|
|
299
|
+
git push -u origin $BRANCH 2>/dev/null || git push
|
|
300
|
+
|
|
301
|
+
# Create PR
|
|
302
|
+
gh pr create --title "{title}" --body "$(cat <<'EOF'
|
|
303
|
+
## Summary
|
|
304
|
+
|
|
305
|
+
{summary from commits and context}
|
|
306
|
+
|
|
307
|
+
## Convention Compliance
|
|
308
|
+
|
|
309
|
+
{if all passed}
|
|
310
|
+
✅ All team conventions verified
|
|
311
|
+
|
|
312
|
+
{if issues were acknowledged}
|
|
313
|
+
⚠️ Known deviations:
|
|
314
|
+
- {issue}: {justification}
|
|
315
|
+
|
|
316
|
+
## Knowledge Added
|
|
317
|
+
|
|
318
|
+
{if memories were graduated}
|
|
319
|
+
This PR includes {count} graduated memories:
|
|
320
|
+
- {list of graduated memories with types}
|
|
321
|
+
|
|
322
|
+
## Test Plan
|
|
323
|
+
|
|
324
|
+
- [ ] {test items}
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
328
|
+
EOF
|
|
329
|
+
)"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Step 9: Summary
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
───────────────────────────────────────────
|
|
336
|
+
✅ PR CREATED
|
|
337
|
+
───────────────────────────────────────────
|
|
338
|
+
|
|
339
|
+
PR: {url}
|
|
340
|
+
Branch: {branch}
|
|
341
|
+
|
|
342
|
+
Knowledge graduated: {count}
|
|
343
|
+
→ app/: {app_count}
|
|
344
|
+
→ team/: {team_count}
|
|
345
|
+
|
|
346
|
+
Remaining in branch/: {kept_count}
|
|
347
|
+
Abandoned: {abandoned_count}
|
|
348
|
+
|
|
349
|
+
The graduated knowledge is now part of your PR.
|
|
350
|
+
Reviewers will see it alongside your code changes.
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Quick Mode
|
|
354
|
+
|
|
355
|
+
For branches with few memories, offer quick mode:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
Found {count} branch memories.
|
|
359
|
+
|
|
360
|
+
1. **Review each** - Curate one by one
|
|
361
|
+
2. **Quick mode** - I'll propose what to graduate
|
|
362
|
+
3. **Graduate all to app/** - Promote everything
|
|
363
|
+
4. **Skip knowledge** - Create PR without graduating
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Quick mode analyzes content and proposes:
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
## Quick Mode Proposal
|
|
370
|
+
|
|
371
|
+
**Graduate to app/:**
|
|
372
|
+
- "Auth uses JWT with 15-min expiry" (architecture)
|
|
373
|
+
- "Redis chosen for session storage" (decision)
|
|
374
|
+
|
|
375
|
+
**Keep in branch:**
|
|
376
|
+
- "Debug notes: token refresh" (task-state)
|
|
377
|
+
|
|
378
|
+
**Abandon:**
|
|
379
|
+
- "TODO: fix later" (noise)
|
|
380
|
+
|
|
381
|
+
Approve this? (yes / review each / edit)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Notes
|
|
385
|
+
|
|
386
|
+
- Graduated memories are committed as part of the PR, so reviewers see them
|
|
387
|
+
- Branch memories that aren't graduated stay in `.ragtime/branches/` for reference
|
|
388
|
+
- After PR merges, run `ragtime prune` to clean up synced branch folders
|
|
389
|
+
- The old `/pr-graduate` command can still be used if you forget to graduate before PR
|
|
@@ -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/commands/pr-graduate.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Graduate branch knowledge to app after PR merge
|
|
2
|
+
description: Graduate branch knowledge to app after PR merge (fallback)
|
|
3
3
|
allowed-tools: Bash, mcp__ragtime__search, mcp__ragtime__graduate, mcp__ragtime__update_status, mcp__ragtime__remember, AskUserQuestion
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# PR Graduate: Curate Branch Knowledge
|
|
6
|
+
# PR Graduate: Curate Branch Knowledge (Post-Merge)
|
|
7
|
+
|
|
8
|
+
> **Preferred workflow:** Use `/create-pr` instead - it graduates memories *before*
|
|
9
|
+
> creating the PR so knowledge is committed alongside code.
|
|
10
|
+
>
|
|
11
|
+
> Use this command only if you already merged without graduating.
|
|
7
12
|
|
|
8
13
|
After a PR is merged, review branch memories and decide what becomes permanent app knowledge.
|
|
9
14
|
|