gsd-ag 1.0.0
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.
- package/.agent/skills/codebase-mapper/SKILL.md +226 -0
- package/.agent/skills/context-compressor/SKILL.md +201 -0
- package/.agent/skills/context-fetch/SKILL.md +184 -0
- package/.agent/skills/context-health-monitor/SKILL.md +105 -0
- package/.agent/skills/debugger/SKILL.md +273 -0
- package/.agent/skills/empirical-validation/SKILL.md +97 -0
- package/.agent/skills/executor/SKILL.md +465 -0
- package/.agent/skills/plan-checker/SKILL.md +283 -0
- package/.agent/skills/planner/SKILL.md +485 -0
- package/.agent/skills/token-budget/SKILL.md +166 -0
- package/.agent/skills/verifier/SKILL.md +421 -0
- package/.agent/workflows/add-phase.md +96 -0
- package/.agent/workflows/add-todo.md +69 -0
- package/.agent/workflows/audit-milestone.md +107 -0
- package/.agent/workflows/check-todos.md +80 -0
- package/.agent/workflows/complete-milestone.md +135 -0
- package/.agent/workflows/debug.md +235 -0
- package/.agent/workflows/discuss-phase.md +103 -0
- package/.agent/workflows/execute.md +325 -0
- package/.agent/workflows/health.md +122 -0
- package/.agent/workflows/help.md +96 -0
- package/.agent/workflows/insert-phase.md +109 -0
- package/.agent/workflows/install.md +152 -0
- package/.agent/workflows/list-phase-assumptions.md +82 -0
- package/.agent/workflows/map.md +394 -0
- package/.agent/workflows/new-milestone.md +126 -0
- package/.agent/workflows/new-project.md +368 -0
- package/.agent/workflows/pause.md +176 -0
- package/.agent/workflows/plan-milestone-gaps.md +116 -0
- package/.agent/workflows/plan.md +380 -0
- package/.agent/workflows/progress.md +90 -0
- package/.agent/workflows/quick.md +128 -0
- package/.agent/workflows/remove-phase.md +139 -0
- package/.agent/workflows/research-phase.md +160 -0
- package/.agent/workflows/resume.md +131 -0
- package/.agent/workflows/update.md +203 -0
- package/.agent/workflows/verify.md +263 -0
- package/.agent/workflows/web-search.md +121 -0
- package/.agent/workflows/whats-new.md +80 -0
- package/.gemini/GEMINI.md +67 -0
- package/.gsd/GSD-STYLE.md +272 -0
- package/.gsd/PROJECT_RULES.md +256 -0
- package/.gsd/adapters/CLAUDE.md +77 -0
- package/.gsd/adapters/GEMINI.md +92 -0
- package/.gsd/adapters/GPT_OSS.md +130 -0
- package/.gsd/docs/model-selection-playbook.md +128 -0
- package/.gsd/docs/runbook.md +296 -0
- package/.gsd/docs/token-optimization-guide.md +207 -0
- package/.gsd/examples/cross-platform.md +99 -0
- package/.gsd/examples/multi-wave-workflow.md +256 -0
- package/.gsd/examples/quick-reference.md +73 -0
- package/.gsd/examples/workflow-example.md +139 -0
- package/.gsd/model_capabilities.yaml +108 -0
- package/.gsd/templates/DEBUG.md +123 -0
- package/.gsd/templates/PLAN.md +90 -0
- package/.gsd/templates/RESEARCH.md +75 -0
- package/.gsd/templates/SUMMARY.md +103 -0
- package/.gsd/templates/UAT.md +168 -0
- package/.gsd/templates/VERIFICATION.md +70 -0
- package/.gsd/templates/architecture.md +67 -0
- package/.gsd/templates/context.md +91 -0
- package/.gsd/templates/decisions.md +37 -0
- package/.gsd/templates/discovery.md +122 -0
- package/.gsd/templates/journal.md +46 -0
- package/.gsd/templates/milestone.md +91 -0
- package/.gsd/templates/phase-summary.md +52 -0
- package/.gsd/templates/project.md +124 -0
- package/.gsd/templates/requirements.md +92 -0
- package/.gsd/templates/roadmap.md +103 -0
- package/.gsd/templates/spec.md +51 -0
- package/.gsd/templates/sprint.md +57 -0
- package/.gsd/templates/stack.md +62 -0
- package/.gsd/templates/state.md +92 -0
- package/.gsd/templates/state_snapshot.md +132 -0
- package/.gsd/templates/todo.md +32 -0
- package/.gsd/templates/token_report.md +79 -0
- package/.gsd/templates/user-setup.md +116 -0
- package/LICENSE +21 -0
- package/README.md +523 -0
- package/bin/init.js +117 -0
- package/package.json +35 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Token Optimization Guide
|
|
2
|
+
|
|
3
|
+
> Practical strategies for reducing token consumption while maintaining quality.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Why Token Optimization Matters
|
|
8
|
+
|
|
9
|
+
| Issue | Impact |
|
|
10
|
+
|-------|--------|
|
|
11
|
+
| Excessive file loading | Higher costs, slower responses |
|
|
12
|
+
| Context accumulation | Quality degradation after 50% |
|
|
13
|
+
| Re-reading files | Wasted tokens on understood content |
|
|
14
|
+
| Full files when snippets suffice | 10x token usage |
|
|
15
|
+
|
|
16
|
+
**Goal:** Maximize output quality per token spent.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## The Token Efficiency Stack
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
┌─────────────────────────────────────┐
|
|
24
|
+
│ 1. Search-First (context-fetch) │ ← Find before loading
|
|
25
|
+
├─────────────────────────────────────┤
|
|
26
|
+
│ 2. Budget Tracking (token-budget) │ ← Know your limits
|
|
27
|
+
├─────────────────────────────────────┤
|
|
28
|
+
│ 3. Compression (context-compressor)│ ← Minimize footprint
|
|
29
|
+
├─────────────────────────────────────┤
|
|
30
|
+
│ 4. Health Monitoring │ ← Prevent degradation
|
|
31
|
+
└─────────────────────────────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Reference: Token Costs
|
|
37
|
+
|
|
38
|
+
### By Content Type
|
|
39
|
+
|
|
40
|
+
| Type | Tokens/Line | 100 Lines = |
|
|
41
|
+
|------|-------------|-------------|
|
|
42
|
+
| Dense code | 6 | ~600 tokens |
|
|
43
|
+
| Standard code | 4 | ~400 tokens |
|
|
44
|
+
| Markdown | 3 | ~300 tokens |
|
|
45
|
+
| Sparse YAML | 2 | ~200 tokens |
|
|
46
|
+
|
|
47
|
+
### By File Size
|
|
48
|
+
|
|
49
|
+
| File Lines | Strategy |
|
|
50
|
+
|------------|----------|
|
|
51
|
+
| <50 | Load freely |
|
|
52
|
+
| 50-200 | Outline first |
|
|
53
|
+
| 200-500 | Search + snippets |
|
|
54
|
+
| 500+ | Never load fully |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Optimization Patterns
|
|
59
|
+
|
|
60
|
+
### Pattern 1: Search → Outline → Target
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Step 1: Search for "handlePayment"
|
|
64
|
+
→ Found in: payment.ts:45, checkout.ts:120
|
|
65
|
+
|
|
66
|
+
Step 2: Get outline of payment.ts
|
|
67
|
+
→ L45-80: handlePayment function
|
|
68
|
+
|
|
69
|
+
Step 3: Load only L45-80
|
|
70
|
+
→ 35 lines (~140 tokens) vs 400 lines (~1600 tokens)
|
|
71
|
+
→ Saved: ~90%
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Pattern 2: Summarize After Understanding
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
After reading auth.ts:
|
|
78
|
+
|
|
79
|
+
## Summary: auth.ts
|
|
80
|
+
- Exports: login, logout, validateToken
|
|
81
|
+
- Pattern: Express middleware
|
|
82
|
+
- DB: queries users table
|
|
83
|
+
- JWT: uses jose library
|
|
84
|
+
|
|
85
|
+
Next time: Reference summary, don't reload
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Pattern 3: Progressive Disclosure
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Need: Understand login flow
|
|
92
|
+
|
|
93
|
+
Level 1: Outline
|
|
94
|
+
→ "login at L45, uses validateCredentials at L67"
|
|
95
|
+
→ Often sufficient
|
|
96
|
+
|
|
97
|
+
Level 2: Key function
|
|
98
|
+
→ Load L45-65 only
|
|
99
|
+
→ Understand core logic
|
|
100
|
+
|
|
101
|
+
Level 3: Dependencies
|
|
102
|
+
→ Load validateCredentials (L67-85)
|
|
103
|
+
→ Only if L2 insufficient
|
|
104
|
+
|
|
105
|
+
Level 4: Full file
|
|
106
|
+
→ Last resort, re-compress after
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Anti-Patterns to Avoid
|
|
112
|
+
|
|
113
|
+
### ❌ The "Context Dump"
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
BAD:
|
|
117
|
+
"Let me read all the files in src/ to understand the project"
|
|
118
|
+
→ 50 files × 200 lines × 4 tokens = 40,000 tokens
|
|
119
|
+
|
|
120
|
+
GOOD:
|
|
121
|
+
"Let me search for 'main entry' and 'router'"
|
|
122
|
+
→ 2 targeted searches, ~500 tokens
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### ❌ The "Just In Case" Load
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
BAD:
|
|
129
|
+
"Loading utils.ts in case I need it later"
|
|
130
|
+
→ Probably won't need it, wasted tokens
|
|
131
|
+
|
|
132
|
+
GOOD:
|
|
133
|
+
"Noting utils.ts exists, will load if needed"
|
|
134
|
+
→ Zero tokens until actually needed
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### ❌ The Re-Read
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
BAD:
|
|
141
|
+
"Reading config.ts again to check the port"
|
|
142
|
+
→ Already read it twice = 1200 tokens
|
|
143
|
+
|
|
144
|
+
GOOD:
|
|
145
|
+
"From my earlier analysis, port is on L15"
|
|
146
|
+
→ Zero additional tokens
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Budget Checkpoints
|
|
152
|
+
|
|
153
|
+
### Before Starting Work
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
□ Do I know my current budget usage?
|
|
157
|
+
□ Have I tried searching before loading?
|
|
158
|
+
□ Am I loading files I've already understood?
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### During Execution
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
□ Am I at >50%? Time to compress.
|
|
165
|
+
□ Am I re-reading files? Use summaries.
|
|
166
|
+
□ Can I use outline instead of full file?
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### After Each Wave
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
□ Have I compressed context for next wave?
|
|
173
|
+
□ Are summaries documented in STATE.md?
|
|
174
|
+
□ Would a fresh session be more efficient?
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Integration with GSD
|
|
180
|
+
|
|
181
|
+
| GSD Workflow | Token Optimization |
|
|
182
|
+
|--------------|-------------------|
|
|
183
|
+
| `/map` | Generate outline, not full read |
|
|
184
|
+
| `/plan` | Budget estimate per task |
|
|
185
|
+
| `/execute` | Load minimal per task |
|
|
186
|
+
| `/verify` | Targeted evidence only |
|
|
187
|
+
| `/pause` | Compress and dump state |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Metrics
|
|
192
|
+
|
|
193
|
+
Track these for improvement:
|
|
194
|
+
|
|
195
|
+
| Metric | Good | Poor |
|
|
196
|
+
|--------|------|------|
|
|
197
|
+
| Files fully loaded | <3 per wave | 10+ |
|
|
198
|
+
| Search:Load ratio | 3:1 | 1:3 |
|
|
199
|
+
| Re-reads | 0 | 3+ |
|
|
200
|
+
| Budget at wave end | <50% | >70% |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
*See also:*
|
|
205
|
+
- *[.agent/skills/token-budget/SKILL.md](.agent/skills/token-budget/SKILL.md)*
|
|
206
|
+
- *[.agent/skills/context-compressor/SKILL.md](.agent/skills/context-compressor/SKILL.md)*
|
|
207
|
+
- *[PROJECT_RULES.md](PROJECT_RULES.md) — Token Efficiency Rules*
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Cross-Platform Commands Reference
|
|
2
|
+
|
|
3
|
+
> PowerShell ↔ Bash equivalents for GSD workflows
|
|
4
|
+
|
|
5
|
+
## Common Operations
|
|
6
|
+
|
|
7
|
+
| Operation | PowerShell | Bash |
|
|
8
|
+
|-----------|------------|------|
|
|
9
|
+
| **Test file exists** | `Test-Path "file.md"` | `test -f "file.md"` |
|
|
10
|
+
| **Test directory exists** | `Test-Path "dir" -PathType Container` | `test -d "dir"` |
|
|
11
|
+
| **Create directory** | `New-Item -ItemType Directory -Path "dir"` | `mkdir -p "dir"` |
|
|
12
|
+
| **List files** | `Get-ChildItem "*.md"` | `ls *.md` |
|
|
13
|
+
| **List recursively** | `Get-ChildItem -Recurse` | `find . -type f` |
|
|
14
|
+
| **Read file** | `Get-Content "file.md"` | `cat "file.md"` |
|
|
15
|
+
| **Search in files** | `Select-String -Path "**/*" -Pattern "TODO"` | `grep -r "TODO" .` |
|
|
16
|
+
| **Count lines** | `(Get-Content file).Count` | `wc -l < file` |
|
|
17
|
+
| **Copy files** | `Copy-Item -Recurse src dest` | `cp -r src dest` |
|
|
18
|
+
| **Delete files** | `Remove-Item -Recurse -Force dir` | `rm -rf dir` |
|
|
19
|
+
|
|
20
|
+
## Git Operations (Same on Both)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git add -A
|
|
24
|
+
git commit -m "message"
|
|
25
|
+
git push
|
|
26
|
+
git status --short
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Workflow-Specific Examples
|
|
30
|
+
|
|
31
|
+
### /map — Analyze Codebase
|
|
32
|
+
|
|
33
|
+
**PowerShell:**
|
|
34
|
+
```powershell
|
|
35
|
+
Get-ChildItem -Recurse -Directory |
|
|
36
|
+
Where-Object { $_.Name -notmatch "node_modules|\.git" }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Bash:**
|
|
40
|
+
```bash
|
|
41
|
+
find . -type d ! -path "*/node_modules/*" ! -path "*/.git/*"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### /plan — Check SPEC Status
|
|
47
|
+
|
|
48
|
+
**PowerShell:**
|
|
49
|
+
```powershell
|
|
50
|
+
$spec = Get-Content ".gsd/SPEC.md" -Raw
|
|
51
|
+
if ($spec -match "FINALIZED") { "Ready" }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Bash:**
|
|
55
|
+
```bash
|
|
56
|
+
if grep -q "FINALIZED" .gsd/SPEC.md; then echo "Ready"; fi
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### /execute — Discover Plans
|
|
62
|
+
|
|
63
|
+
**PowerShell:**
|
|
64
|
+
```powershell
|
|
65
|
+
Get-ChildItem ".gsd/phases/1/*-PLAN.md"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Bash:**
|
|
69
|
+
```bash
|
|
70
|
+
ls .gsd/phases/1/*-PLAN.md 2>/dev/null
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### /verify — Search TODOs
|
|
76
|
+
|
|
77
|
+
**PowerShell:**
|
|
78
|
+
```powershell
|
|
79
|
+
Select-String -Path "src/**/*" -Pattern "TODO|FIXME"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Bash:**
|
|
83
|
+
```bash
|
|
84
|
+
grep -rn "TODO\|FIXME" src/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Environment Detection
|
|
90
|
+
|
|
91
|
+
Add this to workflows for cross-platform commands:
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
**Note:** Commands shown are PowerShell. For Bash equivalents, see `.gsd/examples/cross-platform.md`
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
*Reference for Linux/Mac users*
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Multi-Wave Workflow Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates a complete GSD workflow with:
|
|
4
|
+
- Short spec
|
|
5
|
+
- Plan breakdown
|
|
6
|
+
- 2-wave execution
|
|
7
|
+
- Verification with commands
|
|
8
|
+
- State snapshots
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Example: Add User Authentication
|
|
13
|
+
|
|
14
|
+
### 1. SPEC.md (Finalized)
|
|
15
|
+
|
|
16
|
+
```markdown
|
|
17
|
+
---
|
|
18
|
+
status: FINALIZED
|
|
19
|
+
updated: 2026-02-07
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# User Authentication Feature
|
|
23
|
+
|
|
24
|
+
## Overview
|
|
25
|
+
Add login/logout functionality with JWT tokens.
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
1. POST /api/auth/login endpoint
|
|
29
|
+
2. POST /api/auth/logout endpoint
|
|
30
|
+
3. JWT stored in httpOnly cookie
|
|
31
|
+
4. Protected route middleware
|
|
32
|
+
|
|
33
|
+
## Success Criteria
|
|
34
|
+
- User can login with email/password
|
|
35
|
+
- Invalid credentials return 401
|
|
36
|
+
- Protected routes require valid JWT
|
|
37
|
+
- Logout clears the cookie
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### 2. ROADMAP.md (Phase Entry)
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+
## Phase 1: User Authentication
|
|
46
|
+
|
|
47
|
+
- [ ] Plan 1.1: Auth endpoints (Wave 1)
|
|
48
|
+
- [ ] Plan 1.2: Protected middleware (Wave 2)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
### 3. PLAN 1.1 (Wave 1)
|
|
54
|
+
|
|
55
|
+
```xml
|
|
56
|
+
---
|
|
57
|
+
phase: 1
|
|
58
|
+
plan: 1
|
|
59
|
+
type: implementation
|
|
60
|
+
wave: 1
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
<objective>
|
|
64
|
+
Create login and logout endpoints with JWT handling.
|
|
65
|
+
</objective>
|
|
66
|
+
|
|
67
|
+
<context>
|
|
68
|
+
Files to read: src/app/api/ structure, existing auth if any
|
|
69
|
+
</context>
|
|
70
|
+
|
|
71
|
+
<tasks>
|
|
72
|
+
<task type="auto" effort="medium">
|
|
73
|
+
<name>Create login endpoint</name>
|
|
74
|
+
<files>src/app/api/auth/login/route.ts</files>
|
|
75
|
+
<action>
|
|
76
|
+
Create POST handler accepting {email, password}.
|
|
77
|
+
Query users table, compare password with bcrypt.
|
|
78
|
+
On success: generate JWT, set httpOnly cookie, return 200.
|
|
79
|
+
On failure: return 401 with generic error.
|
|
80
|
+
</action>
|
|
81
|
+
<verify>curl -X POST localhost:3000/api/auth/login -d '{"email":"test@example.com","password":"test123"}'</verify>
|
|
82
|
+
<done>Valid credentials return 200 + Set-Cookie header</done>
|
|
83
|
+
</task>
|
|
84
|
+
|
|
85
|
+
<task type="auto" effort="low">
|
|
86
|
+
<name>Create logout endpoint</name>
|
|
87
|
+
<files>src/app/api/auth/logout/route.ts</files>
|
|
88
|
+
<action>
|
|
89
|
+
Create POST handler that clears the auth cookie.
|
|
90
|
+
Return 200 on success.
|
|
91
|
+
</action>
|
|
92
|
+
<verify>curl -X POST localhost:3000/api/auth/logout --cookie "token=..."</verify>
|
|
93
|
+
<done>Cookie is cleared, response is 200</done>
|
|
94
|
+
</task>
|
|
95
|
+
</tasks>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 4. Wave 1 Execution
|
|
101
|
+
|
|
102
|
+
**Task 1 Commit:**
|
|
103
|
+
```
|
|
104
|
+
git commit -m "feat(phase-1): create login endpoint"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Task 2 Commit:**
|
|
108
|
+
```
|
|
109
|
+
git commit -m "feat(phase-1): create logout endpoint"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### 5. Wave 1 State Snapshot
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+
---
|
|
118
|
+
wave: 1
|
|
119
|
+
phase: 1
|
|
120
|
+
created: 2026-02-07T10:30:00
|
|
121
|
+
status: complete
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
# Wave 1 State Snapshot
|
|
125
|
+
|
|
126
|
+
## Objective
|
|
127
|
+
Create authentication endpoints.
|
|
128
|
+
|
|
129
|
+
## Changes Realized
|
|
130
|
+
- Created login endpoint with JWT generation
|
|
131
|
+
- Created logout endpoint with cookie clearing
|
|
132
|
+
- Added bcrypt password comparison
|
|
133
|
+
|
|
134
|
+
## Files Touched
|
|
135
|
+
| File | Change Type | Description |
|
|
136
|
+
|------|-------------|-------------|
|
|
137
|
+
| src/app/api/auth/login/route.ts | created | Login handler |
|
|
138
|
+
| src/app/api/auth/logout/route.ts | created | Logout handler |
|
|
139
|
+
|
|
140
|
+
## Verification Results
|
|
141
|
+
| Check | Command | Result |
|
|
142
|
+
|-------|---------|--------|
|
|
143
|
+
| Login works | `curl -X POST .../login` | ✅ 200 + cookie |
|
|
144
|
+
| Logout works | `curl -X POST .../logout` | ✅ 200 + cleared |
|
|
145
|
+
|
|
146
|
+
## Commits in This Wave
|
|
147
|
+
| Hash | Message |
|
|
148
|
+
|------|---------|
|
|
149
|
+
| abc123 | feat(phase-1): create login endpoint |
|
|
150
|
+
| def456 | feat(phase-1): create logout endpoint |
|
|
151
|
+
|
|
152
|
+
## TODO for Next Wave
|
|
153
|
+
1. Create auth middleware
|
|
154
|
+
2. Apply to protected routes
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 6. PLAN 1.2 (Wave 2)
|
|
160
|
+
|
|
161
|
+
```xml
|
|
162
|
+
---
|
|
163
|
+
phase: 1
|
|
164
|
+
plan: 2
|
|
165
|
+
type: implementation
|
|
166
|
+
wave: 2
|
|
167
|
+
depends_on: [1]
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
<objective>
|
|
171
|
+
Create middleware to protect routes requiring authentication.
|
|
172
|
+
</objective>
|
|
173
|
+
|
|
174
|
+
<context>
|
|
175
|
+
Wave 1 complete: login/logout endpoints exist.
|
|
176
|
+
JWT is stored in httpOnly cookie named "token".
|
|
177
|
+
</context>
|
|
178
|
+
|
|
179
|
+
<tasks>
|
|
180
|
+
<task type="auto" effort="high">
|
|
181
|
+
<name>Create auth middleware</name>
|
|
182
|
+
<files>src/middleware/auth.ts</files>
|
|
183
|
+
<action>
|
|
184
|
+
Create middleware that:
|
|
185
|
+
1. Reads JWT from cookie
|
|
186
|
+
2. Verifies signature with jose
|
|
187
|
+
3. Attaches user to request
|
|
188
|
+
4. Returns 401 if invalid/missing
|
|
189
|
+
</action>
|
|
190
|
+
<verify>Import and call middleware with mock request</verify>
|
|
191
|
+
<done>Valid JWT passes, invalid/missing returns 401</done>
|
|
192
|
+
</task>
|
|
193
|
+
|
|
194
|
+
<task type="auto" effort="medium">
|
|
195
|
+
<name>Apply middleware to protected route</name>
|
|
196
|
+
<files>src/app/api/user/profile/route.ts</files>
|
|
197
|
+
<action>
|
|
198
|
+
Create example protected route.
|
|
199
|
+
Apply auth middleware.
|
|
200
|
+
Return user data if authenticated.
|
|
201
|
+
</action>
|
|
202
|
+
<verify>curl localhost:3000/api/user/profile with and without cookie</verify>
|
|
203
|
+
<done>With cookie: 200 + data. Without: 401</done>
|
|
204
|
+
</task>
|
|
205
|
+
</tasks>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### 7. Wave 2 Execution & Snapshot
|
|
211
|
+
|
|
212
|
+
**Commits:**
|
|
213
|
+
```
|
|
214
|
+
git commit -m "feat(phase-1): create auth middleware"
|
|
215
|
+
git commit -m "feat(phase-1): apply middleware to profile route"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**State Snapshot:** (similar format to Wave 1)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### 8. Verification
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Full verification sequence
|
|
226
|
+
curl -X POST localhost:3000/api/auth/login \
|
|
227
|
+
-H "Content-Type: application/json" \
|
|
228
|
+
-d '{"email":"user@example.com","password":"secret"}' \
|
|
229
|
+
-c cookies.txt
|
|
230
|
+
|
|
231
|
+
# Expected: 200 + Set-Cookie: token=...
|
|
232
|
+
|
|
233
|
+
curl localhost:3000/api/user/profile -b cookies.txt
|
|
234
|
+
# Expected: 200 + user data
|
|
235
|
+
|
|
236
|
+
curl localhost:3000/api/user/profile
|
|
237
|
+
# Expected: 401
|
|
238
|
+
|
|
239
|
+
curl -X POST localhost:3000/api/auth/logout -b cookies.txt
|
|
240
|
+
# Expected: 200 + cookie cleared
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Key Takeaways
|
|
246
|
+
|
|
247
|
+
1. **Waves group dependent work** — Wave 2 waited for Wave 1
|
|
248
|
+
2. **State snapshots preserve context** — Each wave ends with documented state
|
|
249
|
+
3. **Atomic commits per task** — Easy to trace and revert
|
|
250
|
+
4. **Verification built into plan** — No "trust me, it works"
|
|
251
|
+
5. **Effort hints model selection** — `high` effort = use reasoning model
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
*See PROJECT_RULES.md for wave execution rules.*
|
|
256
|
+
*See templates/state_snapshot.md for snapshot format.*
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# GSD Quick Reference Card
|
|
2
|
+
|
|
3
|
+
## Workflow Lifecycle
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐
|
|
7
|
+
│ /map │ → │ /plan │ → │ /execute │ → │ /verify │
|
|
8
|
+
│ │ │ │ │ │ │ │
|
|
9
|
+
│ Analyze │ │ Create │ │ Run │ │ Check │
|
|
10
|
+
│codebase │ │ phases │ │ tasks │ │ work │
|
|
11
|
+
└─────────┘ └─────────┘ └──────────┘ └─────────┘
|
|
12
|
+
↑ │
|
|
13
|
+
└──────────────┘
|
|
14
|
+
(if gaps found)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## All Commands
|
|
18
|
+
|
|
19
|
+
| Command | Args | Purpose |
|
|
20
|
+
|---------|------|---------|
|
|
21
|
+
| `/map` | - | Analyze codebase → ARCHITECTURE.md |
|
|
22
|
+
| `/plan` | `[phase]` | Create PLAN.md files for phase |
|
|
23
|
+
| `/execute` | `phase [--gaps-only]` | Run plans with wave execution |
|
|
24
|
+
| `/verify` | `phase` | Validate with empirical proof |
|
|
25
|
+
| `/debug` | `description` | Systematic debugging |
|
|
26
|
+
| `/progress` | - | Show current position |
|
|
27
|
+
| `/pause` | - | Save state, end session |
|
|
28
|
+
| `/resume` | - | Load state, start session |
|
|
29
|
+
| `/add-todo` | `item [--priority]` | Quick capture |
|
|
30
|
+
| `/check-todos` | `[--all]` | List pending items |
|
|
31
|
+
|
|
32
|
+
## Core Rules
|
|
33
|
+
|
|
34
|
+
| Rule | Enforcement |
|
|
35
|
+
|------|-------------|
|
|
36
|
+
| 🔒 Planning Lock | No code until SPEC finalized |
|
|
37
|
+
| 💾 State Persistence | Update STATE.md after tasks |
|
|
38
|
+
| 🧹 Context Hygiene | 3 failures → fresh session |
|
|
39
|
+
| ✅ Empirical Validation | Proof required for "done" |
|
|
40
|
+
|
|
41
|
+
## Key Files
|
|
42
|
+
|
|
43
|
+
| File | Purpose | Updated By |
|
|
44
|
+
|------|---------|------------|
|
|
45
|
+
| SPEC.md | Vision (finalize first!) | User |
|
|
46
|
+
| ROADMAP.md | Phase definitions | /plan |
|
|
47
|
+
| STATE.md | Session memory | All |
|
|
48
|
+
| ARCHITECTURE.md | System design | /map |
|
|
49
|
+
| TODO.md | Quick capture | /add-todo |
|
|
50
|
+
|
|
51
|
+
## XML Task Structure
|
|
52
|
+
|
|
53
|
+
```xml
|
|
54
|
+
<task type="auto">
|
|
55
|
+
<name>Clear name</name>
|
|
56
|
+
<files>exact/path.ts</files>
|
|
57
|
+
<action>Specific instructions</action>
|
|
58
|
+
<verify>Executable command</verify>
|
|
59
|
+
<done>Measurable criteria</done>
|
|
60
|
+
</task>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Priority Indicators
|
|
64
|
+
|
|
65
|
+
| Priority | Icon |
|
|
66
|
+
|----------|------|
|
|
67
|
+
| High | 🔴 |
|
|
68
|
+
| Medium | 🟡 |
|
|
69
|
+
| Low | 🟢 |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
*Print this for quick reference!*
|