gsd-opencode 1.3.31
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/bin/install.js +222 -0
- package/command/gsd/add-phase.md +207 -0
- package/command/gsd/complete-milestone.md +105 -0
- package/command/gsd/consider-issues.md +201 -0
- package/command/gsd/create-roadmap.md +115 -0
- package/command/gsd/discuss-milestone.md +47 -0
- package/command/gsd/discuss-phase.md +60 -0
- package/command/gsd/execute-plan.md +128 -0
- package/command/gsd/help.md +315 -0
- package/command/gsd/insert-phase.md +227 -0
- package/command/gsd/list-phase-assumptions.md +50 -0
- package/command/gsd/map-codebase.md +84 -0
- package/command/gsd/new-milestone.md +59 -0
- package/command/gsd/new-project.md +316 -0
- package/command/gsd/pause-work.md +122 -0
- package/command/gsd/plan-fix.md +205 -0
- package/command/gsd/plan-phase.md +67 -0
- package/command/gsd/progress.md +316 -0
- package/command/gsd/remove-phase.md +338 -0
- package/command/gsd/research-phase.md +91 -0
- package/command/gsd/resume-work.md +40 -0
- package/command/gsd/verify-work.md +71 -0
- package/get-shit-done/references/checkpoints.md +287 -0
- package/get-shit-done/references/continuation-format.md +255 -0
- package/get-shit-done/references/git-integration.md +254 -0
- package/get-shit-done/references/plan-format.md +428 -0
- package/get-shit-done/references/principles.md +157 -0
- package/get-shit-done/references/questioning.md +162 -0
- package/get-shit-done/references/research-pitfalls.md +215 -0
- package/get-shit-done/references/scope-estimation.md +172 -0
- package/get-shit-done/references/tdd.md +263 -0
- package/get-shit-done/templates/codebase/architecture.md +255 -0
- package/get-shit-done/templates/codebase/concerns.md +310 -0
- package/get-shit-done/templates/codebase/conventions.md +307 -0
- package/get-shit-done/templates/codebase/integrations.md +280 -0
- package/get-shit-done/templates/codebase/stack.md +186 -0
- package/get-shit-done/templates/codebase/structure.md +285 -0
- package/get-shit-done/templates/codebase/testing.md +480 -0
- package/get-shit-done/templates/config.json +18 -0
- package/get-shit-done/templates/context.md +161 -0
- package/get-shit-done/templates/continue-here.md +78 -0
- package/get-shit-done/templates/discovery.md +146 -0
- package/get-shit-done/templates/issues.md +32 -0
- package/get-shit-done/templates/milestone-archive.md +123 -0
- package/get-shit-done/templates/milestone-context.md +93 -0
- package/get-shit-done/templates/milestone.md +115 -0
- package/get-shit-done/templates/phase-prompt.md +303 -0
- package/get-shit-done/templates/project.md +184 -0
- package/get-shit-done/templates/research.md +529 -0
- package/get-shit-done/templates/roadmap.md +196 -0
- package/get-shit-done/templates/state.md +210 -0
- package/get-shit-done/templates/summary.md +273 -0
- package/get-shit-done/templates/uat-issues.md +143 -0
- package/get-shit-done/workflows/complete-milestone.md +643 -0
- package/get-shit-done/workflows/create-milestone.md +416 -0
- package/get-shit-done/workflows/create-roadmap.md +481 -0
- package/get-shit-done/workflows/discovery-phase.md +293 -0
- package/get-shit-done/workflows/discuss-milestone.md +236 -0
- package/get-shit-done/workflows/discuss-phase.md +247 -0
- package/get-shit-done/workflows/execute-phase.md +1625 -0
- package/get-shit-done/workflows/list-phase-assumptions.md +178 -0
- package/get-shit-done/workflows/map-codebase.md +434 -0
- package/get-shit-done/workflows/plan-phase.md +488 -0
- package/get-shit-done/workflows/research-phase.md +436 -0
- package/get-shit-done/workflows/resume-project.md +287 -0
- package/get-shit-done/workflows/transition.md +580 -0
- package/get-shit-done/workflows/verify-work.md +202 -0
- package/package.json +38 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<overview>
|
|
2
|
+
TDD is about design quality, not coverage metrics. The red-green-refactor cycle forces you to think about behavior before implementation, producing cleaner interfaces and more testable code.
|
|
3
|
+
|
|
4
|
+
**Principle:** If you can describe the behavior as `expect(fn(input)).toBe(output)` before writing `fn`, TDD improves the result.
|
|
5
|
+
|
|
6
|
+
**Key insight:** TDD work is fundamentally heavier than standard tasks—it requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. TDD features get dedicated plans to ensure full context is available throughout the cycle.
|
|
7
|
+
</overview>
|
|
8
|
+
|
|
9
|
+
<when_to_use_tdd>
|
|
10
|
+
## When TDD Improves Quality
|
|
11
|
+
|
|
12
|
+
**TDD candidates (create a TDD plan):**
|
|
13
|
+
- Business logic with defined inputs/outputs
|
|
14
|
+
- API endpoints with request/response contracts
|
|
15
|
+
- Data transformations, parsing, formatting
|
|
16
|
+
- Validation rules and constraints
|
|
17
|
+
- Algorithms with testable behavior
|
|
18
|
+
- State machines and workflows
|
|
19
|
+
- Utility functions with clear specifications
|
|
20
|
+
|
|
21
|
+
**Skip TDD (use standard plan with `type="auto"` tasks):**
|
|
22
|
+
- UI layout, styling, visual components
|
|
23
|
+
- Configuration changes
|
|
24
|
+
- Glue code connecting existing components
|
|
25
|
+
- One-off scripts and migrations
|
|
26
|
+
- Simple CRUD with no business logic
|
|
27
|
+
- Exploratory prototyping
|
|
28
|
+
|
|
29
|
+
**Heuristic:** Can you write `expect(fn(input)).toBe(output)` before writing `fn`?
|
|
30
|
+
→ Yes: Create a TDD plan
|
|
31
|
+
→ No: Use standard plan, add tests after if needed
|
|
32
|
+
</when_to_use_tdd>
|
|
33
|
+
|
|
34
|
+
<tdd_plan_structure>
|
|
35
|
+
## TDD Plan Structure
|
|
36
|
+
|
|
37
|
+
Each TDD plan implements **one feature** through the full RED-GREEN-REFACTOR cycle.
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
---
|
|
41
|
+
phase: XX-name
|
|
42
|
+
plan: NN
|
|
43
|
+
type: tdd
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
<objective>
|
|
47
|
+
[What feature and why]
|
|
48
|
+
Purpose: [Design benefit of TDD for this feature]
|
|
49
|
+
Output: [Working, tested feature]
|
|
50
|
+
</objective>
|
|
51
|
+
|
|
52
|
+
<context>
|
|
53
|
+
@.planning/PROJECT.md
|
|
54
|
+
@.planning/ROADMAP.md
|
|
55
|
+
@relevant/source/files.ts
|
|
56
|
+
</context>
|
|
57
|
+
|
|
58
|
+
<feature>
|
|
59
|
+
<name>[Feature name]</name>
|
|
60
|
+
<files>[source file, test file]</files>
|
|
61
|
+
<behavior>
|
|
62
|
+
[Expected behavior in testable terms]
|
|
63
|
+
Cases: input → expected output
|
|
64
|
+
</behavior>
|
|
65
|
+
<implementation>[How to implement once tests pass]</implementation>
|
|
66
|
+
</feature>
|
|
67
|
+
|
|
68
|
+
<verification>
|
|
69
|
+
[Test command that proves feature works]
|
|
70
|
+
</verification>
|
|
71
|
+
|
|
72
|
+
<success_criteria>
|
|
73
|
+
- Failing test written and committed
|
|
74
|
+
- Implementation passes test
|
|
75
|
+
- Refactor complete (if needed)
|
|
76
|
+
- All 2-3 commits present
|
|
77
|
+
</success_criteria>
|
|
78
|
+
|
|
79
|
+
<output>
|
|
80
|
+
After completion, create SUMMARY.md with:
|
|
81
|
+
- RED: What test was written, why it failed
|
|
82
|
+
- GREEN: What implementation made it pass
|
|
83
|
+
- REFACTOR: What cleanup was done (if any)
|
|
84
|
+
- Commits: List of commits produced
|
|
85
|
+
</output>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**One feature per TDD plan.** If features are trivial enough to batch, they're trivial enough to skip TDD—use a standard plan and add tests after.
|
|
89
|
+
</tdd_plan_structure>
|
|
90
|
+
|
|
91
|
+
<execution_flow>
|
|
92
|
+
## Red-Green-Refactor Cycle
|
|
93
|
+
|
|
94
|
+
**RED - Write failing test:**
|
|
95
|
+
1. Create test file following project conventions
|
|
96
|
+
2. Write test describing expected behavior (from `<behavior>` element)
|
|
97
|
+
3. Run test - it MUST fail
|
|
98
|
+
4. If test passes: feature exists or test is wrong. Investigate.
|
|
99
|
+
5. Commit: `test({phase}-{plan}): add failing test for [feature]`
|
|
100
|
+
|
|
101
|
+
**GREEN - Implement to pass:**
|
|
102
|
+
1. Write minimal code to make test pass
|
|
103
|
+
2. No cleverness, no optimization - just make it work
|
|
104
|
+
3. Run test - it MUST pass
|
|
105
|
+
4. Commit: `feat({phase}-{plan}): implement [feature]`
|
|
106
|
+
|
|
107
|
+
**REFACTOR (if needed):**
|
|
108
|
+
1. Clean up implementation if obvious improvements exist
|
|
109
|
+
2. Run tests - MUST still pass
|
|
110
|
+
3. Only commit if changes made: `refactor({phase}-{plan}): clean up [feature]`
|
|
111
|
+
|
|
112
|
+
**Result:** Each TDD plan produces 2-3 atomic commits.
|
|
113
|
+
</execution_flow>
|
|
114
|
+
|
|
115
|
+
<test_quality>
|
|
116
|
+
## Good Tests vs Bad Tests
|
|
117
|
+
|
|
118
|
+
**Test behavior, not implementation:**
|
|
119
|
+
- Good: "returns formatted date string"
|
|
120
|
+
- Bad: "calls formatDate helper with correct params"
|
|
121
|
+
- Tests should survive refactors
|
|
122
|
+
|
|
123
|
+
**One concept per test:**
|
|
124
|
+
- Good: Separate tests for valid input, empty input, malformed input
|
|
125
|
+
- Bad: Single test checking all edge cases with multiple assertions
|
|
126
|
+
|
|
127
|
+
**Descriptive names:**
|
|
128
|
+
- Good: "should reject empty email", "returns null for invalid ID"
|
|
129
|
+
- Bad: "test1", "handles error", "works correctly"
|
|
130
|
+
|
|
131
|
+
**No implementation details:**
|
|
132
|
+
- Good: Test public API, observable behavior
|
|
133
|
+
- Bad: Mock internals, test private methods, assert on internal state
|
|
134
|
+
</test_quality>
|
|
135
|
+
|
|
136
|
+
<framework_setup>
|
|
137
|
+
## Test Framework Setup (If None Exists)
|
|
138
|
+
|
|
139
|
+
When executing a TDD plan but no test framework is configured, set it up as part of the RED phase:
|
|
140
|
+
|
|
141
|
+
**1. Detect project type:**
|
|
142
|
+
```bash
|
|
143
|
+
# JavaScript/TypeScript
|
|
144
|
+
if [ -f package.json ]; then echo "node"; fi
|
|
145
|
+
|
|
146
|
+
# Python
|
|
147
|
+
if [ -f requirements.txt ] || [ -f pyproject.toml ]; then echo "python"; fi
|
|
148
|
+
|
|
149
|
+
# Go
|
|
150
|
+
if [ -f go.mod ]; then echo "go"; fi
|
|
151
|
+
|
|
152
|
+
# Rust
|
|
153
|
+
if [ -f Cargo.toml ]; then echo "rust"; fi
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**2. Install minimal framework:**
|
|
157
|
+
| Project | Framework | Install |
|
|
158
|
+
|---------|-----------|---------|
|
|
159
|
+
| Node.js | Jest | `npm install -D jest @types/jest ts-jest` |
|
|
160
|
+
| Node.js (Vite) | Vitest | `npm install -D vitest` |
|
|
161
|
+
| Python | pytest | `pip install pytest` |
|
|
162
|
+
| Go | testing | Built-in |
|
|
163
|
+
| Rust | cargo test | Built-in |
|
|
164
|
+
|
|
165
|
+
**3. Create config if needed:**
|
|
166
|
+
- Jest: `jest.config.js` with ts-jest preset
|
|
167
|
+
- Vitest: `vitest.config.ts` with test globals
|
|
168
|
+
- pytest: `pytest.ini` or `pyproject.toml` section
|
|
169
|
+
|
|
170
|
+
**4. Verify setup:**
|
|
171
|
+
```bash
|
|
172
|
+
# Run empty test suite - should pass with 0 tests
|
|
173
|
+
npm test # Node
|
|
174
|
+
pytest # Python
|
|
175
|
+
go test ./... # Go
|
|
176
|
+
cargo test # Rust
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**5. Create first test file:**
|
|
180
|
+
Follow project conventions for test location:
|
|
181
|
+
- `*.test.ts` / `*.spec.ts` next to source
|
|
182
|
+
- `__tests__/` directory
|
|
183
|
+
- `tests/` directory at root
|
|
184
|
+
|
|
185
|
+
Framework setup is a one-time cost included in the first TDD plan's RED phase.
|
|
186
|
+
</framework_setup>
|
|
187
|
+
|
|
188
|
+
<error_handling>
|
|
189
|
+
## Error Handling
|
|
190
|
+
|
|
191
|
+
**Test doesn't fail in RED phase:**
|
|
192
|
+
- Feature may already exist - investigate
|
|
193
|
+
- Test may be wrong (not testing what you think)
|
|
194
|
+
- Fix before proceeding
|
|
195
|
+
|
|
196
|
+
**Test doesn't pass in GREEN phase:**
|
|
197
|
+
- Debug implementation
|
|
198
|
+
- Don't skip to refactor
|
|
199
|
+
- Keep iterating until green
|
|
200
|
+
|
|
201
|
+
**Tests fail in REFACTOR phase:**
|
|
202
|
+
- Undo refactor
|
|
203
|
+
- Commit was premature
|
|
204
|
+
- Refactor in smaller steps
|
|
205
|
+
|
|
206
|
+
**Unrelated tests break:**
|
|
207
|
+
- Stop and investigate
|
|
208
|
+
- May indicate coupling issue
|
|
209
|
+
- Fix before proceeding
|
|
210
|
+
</error_handling>
|
|
211
|
+
|
|
212
|
+
<commit_pattern>
|
|
213
|
+
## Commit Pattern for TDD Plans
|
|
214
|
+
|
|
215
|
+
TDD plans produce 2-3 atomic commits (one per phase):
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
test(08-02): add failing test for email validation
|
|
219
|
+
|
|
220
|
+
- Tests valid email formats accepted
|
|
221
|
+
- Tests invalid formats rejected
|
|
222
|
+
- Tests empty input handling
|
|
223
|
+
|
|
224
|
+
feat(08-02): implement email validation
|
|
225
|
+
|
|
226
|
+
- Regex pattern matches RFC 5322
|
|
227
|
+
- Returns boolean for validity
|
|
228
|
+
- Handles edge cases (empty, null)
|
|
229
|
+
|
|
230
|
+
refactor(08-02): extract regex to constant (optional)
|
|
231
|
+
|
|
232
|
+
- Moved pattern to EMAIL_REGEX constant
|
|
233
|
+
- No behavior changes
|
|
234
|
+
- Tests still pass
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Comparison with standard plans:**
|
|
238
|
+
- Standard plans: 1 commit per task, 2-4 commits per plan
|
|
239
|
+
- TDD plans: 2-3 commits for single feature
|
|
240
|
+
|
|
241
|
+
Both follow same format: `{type}({phase}-{plan}): {description}`
|
|
242
|
+
|
|
243
|
+
**Benefits:**
|
|
244
|
+
- Each commit independently revertable
|
|
245
|
+
- Git bisect works at commit level
|
|
246
|
+
- Clear history showing TDD discipline
|
|
247
|
+
- Consistent with overall commit strategy
|
|
248
|
+
</commit_pattern>
|
|
249
|
+
|
|
250
|
+
<context_budget>
|
|
251
|
+
## Context Budget
|
|
252
|
+
|
|
253
|
+
TDD plans target **~40% context usage** (lower than standard plans' ~50%).
|
|
254
|
+
|
|
255
|
+
Why lower:
|
|
256
|
+
- RED phase: write test, run test, potentially debug why it didn't fail
|
|
257
|
+
- GREEN phase: implement, run test, potentially iterate on failures
|
|
258
|
+
- REFACTOR phase: modify code, run tests, verify no regressions
|
|
259
|
+
|
|
260
|
+
Each phase involves reading files, running commands, analyzing output. The back-and-forth is inherently heavier than linear task execution.
|
|
261
|
+
|
|
262
|
+
Single feature focus ensures full quality throughout the cycle.
|
|
263
|
+
</context_budget>
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Architecture Template
|
|
2
|
+
|
|
3
|
+
Template for `.planning/codebase/ARCHITECTURE.md` - captures conceptual code organization.
|
|
4
|
+
|
|
5
|
+
**Purpose:** Document how the code is organized at a conceptual level. Complements STRUCTURE.md (which shows physical file locations).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## File Template
|
|
10
|
+
|
|
11
|
+
```markdown
|
|
12
|
+
# Architecture
|
|
13
|
+
|
|
14
|
+
**Analysis Date:** [YYYY-MM-DD]
|
|
15
|
+
|
|
16
|
+
## Pattern Overview
|
|
17
|
+
|
|
18
|
+
**Overall:** [Pattern name: e.g., "Monolithic CLI", "Serverless API", "Full-stack MVC"]
|
|
19
|
+
|
|
20
|
+
**Key Characteristics:**
|
|
21
|
+
- [Characteristic 1: e.g., "Single executable"]
|
|
22
|
+
- [Characteristic 2: e.g., "Stateless request handling"]
|
|
23
|
+
- [Characteristic 3: e.g., "Event-driven"]
|
|
24
|
+
|
|
25
|
+
## Layers
|
|
26
|
+
|
|
27
|
+
[Describe the conceptual layers and their responsibilities]
|
|
28
|
+
|
|
29
|
+
**[Layer Name]:**
|
|
30
|
+
- Purpose: [What this layer does]
|
|
31
|
+
- Contains: [Types of code: e.g., "route handlers", "business logic"]
|
|
32
|
+
- Depends on: [What it uses: e.g., "data layer only"]
|
|
33
|
+
- Used by: [What uses it: e.g., "API routes"]
|
|
34
|
+
|
|
35
|
+
**[Layer Name]:**
|
|
36
|
+
- Purpose: [What this layer does]
|
|
37
|
+
- Contains: [Types of code]
|
|
38
|
+
- Depends on: [What it uses]
|
|
39
|
+
- Used by: [What uses it]
|
|
40
|
+
|
|
41
|
+
## Data Flow
|
|
42
|
+
|
|
43
|
+
[Describe the typical request/execution lifecycle]
|
|
44
|
+
|
|
45
|
+
**[Flow Name] (e.g., "HTTP Request", "CLI Command", "Event Processing"):**
|
|
46
|
+
|
|
47
|
+
1. [Entry point: e.g., "User runs command"]
|
|
48
|
+
2. [Processing step: e.g., "Router matches path"]
|
|
49
|
+
3. [Processing step: e.g., "Controller validates input"]
|
|
50
|
+
4. [Processing step: e.g., "Service executes logic"]
|
|
51
|
+
5. [Output: e.g., "Response returned"]
|
|
52
|
+
|
|
53
|
+
**State Management:**
|
|
54
|
+
- [How state is handled: e.g., "Stateless - no persistent state", "Database per request", "In-memory cache"]
|
|
55
|
+
|
|
56
|
+
## Key Abstractions
|
|
57
|
+
|
|
58
|
+
[Core concepts/patterns used throughout the codebase]
|
|
59
|
+
|
|
60
|
+
**[Abstraction Name]:**
|
|
61
|
+
- Purpose: [What it represents]
|
|
62
|
+
- Examples: [e.g., "UserService, ProjectService"]
|
|
63
|
+
- Pattern: [e.g., "Singleton", "Factory", "Repository"]
|
|
64
|
+
|
|
65
|
+
**[Abstraction Name]:**
|
|
66
|
+
- Purpose: [What it represents]
|
|
67
|
+
- Examples: [Concrete examples]
|
|
68
|
+
- Pattern: [Pattern used]
|
|
69
|
+
|
|
70
|
+
## Entry Points
|
|
71
|
+
|
|
72
|
+
[Where execution begins]
|
|
73
|
+
|
|
74
|
+
**[Entry Point]:**
|
|
75
|
+
- Location: [Brief: e.g., "src/index.ts", "API Gateway triggers"]
|
|
76
|
+
- Triggers: [What invokes it: e.g., "CLI invocation", "HTTP request"]
|
|
77
|
+
- Responsibilities: [What it does: e.g., "Parse args, route to command"]
|
|
78
|
+
|
|
79
|
+
## Error Handling
|
|
80
|
+
|
|
81
|
+
**Strategy:** [How errors are handled: e.g., "Exception bubbling to top-level handler", "Per-route error middleware"]
|
|
82
|
+
|
|
83
|
+
**Patterns:**
|
|
84
|
+
- [Pattern: e.g., "try/catch at controller level"]
|
|
85
|
+
- [Pattern: e.g., "Error codes returned to user"]
|
|
86
|
+
|
|
87
|
+
## Cross-Cutting Concerns
|
|
88
|
+
|
|
89
|
+
[Aspects that affect multiple layers]
|
|
90
|
+
|
|
91
|
+
**Logging:**
|
|
92
|
+
- [Approach: e.g., "Winston logger, injected per-request"]
|
|
93
|
+
|
|
94
|
+
**Validation:**
|
|
95
|
+
- [Approach: e.g., "Zod schemas at API boundary"]
|
|
96
|
+
|
|
97
|
+
**Authentication:**
|
|
98
|
+
- [Approach: e.g., "JWT middleware on protected routes"]
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
*Architecture analysis: [date]*
|
|
103
|
+
*Update when major patterns change*
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
<good_examples>
|
|
107
|
+
```markdown
|
|
108
|
+
# Architecture
|
|
109
|
+
|
|
110
|
+
**Analysis Date:** 2025-01-20
|
|
111
|
+
|
|
112
|
+
## Pattern Overview
|
|
113
|
+
|
|
114
|
+
**Overall:** CLI Application with Plugin System
|
|
115
|
+
|
|
116
|
+
**Key Characteristics:**
|
|
117
|
+
- Single executable with subcommands
|
|
118
|
+
- Plugin-based extensibility
|
|
119
|
+
- File-based state (no database)
|
|
120
|
+
- Synchronous execution model
|
|
121
|
+
|
|
122
|
+
## Layers
|
|
123
|
+
|
|
124
|
+
**Command Layer:**
|
|
125
|
+
- Purpose: Parse user input and route to appropriate handler
|
|
126
|
+
- Contains: Command definitions, argument parsing, help text
|
|
127
|
+
- Location: `src/commands/*.ts`
|
|
128
|
+
- Depends on: Service layer for business logic
|
|
129
|
+
- Used by: CLI entry point (`src/index.ts`)
|
|
130
|
+
|
|
131
|
+
**Service Layer:**
|
|
132
|
+
- Purpose: Core business logic
|
|
133
|
+
- Contains: FileService, TemplateService, InstallService
|
|
134
|
+
- Location: `src/services/*.ts`
|
|
135
|
+
- Depends on: File system utilities, external tools
|
|
136
|
+
- Used by: Command handlers
|
|
137
|
+
|
|
138
|
+
**Utility Layer:**
|
|
139
|
+
- Purpose: Shared helpers and abstractions
|
|
140
|
+
- Contains: File I/O wrappers, path resolution, string formatting
|
|
141
|
+
- Location: `src/utils/*.ts`
|
|
142
|
+
- Depends on: Node.js built-ins only
|
|
143
|
+
- Used by: Service layer
|
|
144
|
+
|
|
145
|
+
## Data Flow
|
|
146
|
+
|
|
147
|
+
**CLI Command Execution:**
|
|
148
|
+
|
|
149
|
+
1. User runs: `gsd new-project`
|
|
150
|
+
2. Commander parses args and flags
|
|
151
|
+
3. Command handler invoked (`src/commands/new-project.ts`)
|
|
152
|
+
4. Handler calls service methods (`src/services/project.ts` → `create()`)
|
|
153
|
+
5. Service reads templates, processes files, writes output
|
|
154
|
+
6. Results logged to console
|
|
155
|
+
7. Process exits with status code
|
|
156
|
+
|
|
157
|
+
**State Management:**
|
|
158
|
+
- File-based: All state lives in `.planning/` directory
|
|
159
|
+
- No persistent in-memory state
|
|
160
|
+
- Each command execution is independent
|
|
161
|
+
|
|
162
|
+
## Key Abstractions
|
|
163
|
+
|
|
164
|
+
**Service:**
|
|
165
|
+
- Purpose: Encapsulate business logic for a domain
|
|
166
|
+
- Examples: `src/services/file.ts`, `src/services/template.ts`, `src/services/project.ts`
|
|
167
|
+
- Pattern: Singleton-like (imported as modules, not instantiated)
|
|
168
|
+
|
|
169
|
+
**Command:**
|
|
170
|
+
- Purpose: CLI command definition
|
|
171
|
+
- Examples: `src/commands/new-project.ts`, `src/commands/plan-phase.ts`
|
|
172
|
+
- Pattern: Commander.js command registration
|
|
173
|
+
|
|
174
|
+
**Template:**
|
|
175
|
+
- Purpose: Reusable document structures
|
|
176
|
+
- Examples: PROJECT.md, PLAN.md templates
|
|
177
|
+
- Pattern: Markdown files with substitution variables
|
|
178
|
+
|
|
179
|
+
## Entry Points
|
|
180
|
+
|
|
181
|
+
**CLI Entry:**
|
|
182
|
+
- Location: `src/index.ts`
|
|
183
|
+
- Triggers: User runs `gsd <command>`
|
|
184
|
+
- Responsibilities: Register commands, parse args, display help
|
|
185
|
+
|
|
186
|
+
**Commands:**
|
|
187
|
+
- Location: `src/commands/*.ts`
|
|
188
|
+
- Triggers: Matched command from CLI
|
|
189
|
+
- Responsibilities: Validate input, call services, format output
|
|
190
|
+
|
|
191
|
+
## Error Handling
|
|
192
|
+
|
|
193
|
+
**Strategy:** Throw exceptions, catch at command level, log and exit
|
|
194
|
+
|
|
195
|
+
**Patterns:**
|
|
196
|
+
- Services throw Error with descriptive messages
|
|
197
|
+
- Command handlers catch, log error to stderr, exit(1)
|
|
198
|
+
- Validation errors shown before execution (fail fast)
|
|
199
|
+
|
|
200
|
+
## Cross-Cutting Concerns
|
|
201
|
+
|
|
202
|
+
**Logging:**
|
|
203
|
+
- Console.log for normal output
|
|
204
|
+
- Console.error for errors
|
|
205
|
+
- Chalk for colored output
|
|
206
|
+
|
|
207
|
+
**Validation:**
|
|
208
|
+
- Zod schemas for config file parsing
|
|
209
|
+
- Manual validation in command handlers
|
|
210
|
+
- Fail fast on invalid input
|
|
211
|
+
|
|
212
|
+
**File Operations:**
|
|
213
|
+
- FileService abstraction over fs-extra
|
|
214
|
+
- All paths validated before operations
|
|
215
|
+
- Atomic writes (temp file + rename)
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
*Architecture analysis: 2025-01-20*
|
|
220
|
+
*Update when major patterns change*
|
|
221
|
+
```
|
|
222
|
+
</good_examples>
|
|
223
|
+
|
|
224
|
+
<guidelines>
|
|
225
|
+
**What belongs in ARCHITECTURE.md:**
|
|
226
|
+
- Overall architectural pattern (monolith, microservices, layered, etc.)
|
|
227
|
+
- Conceptual layers and their relationships
|
|
228
|
+
- Data flow / request lifecycle
|
|
229
|
+
- Key abstractions and patterns
|
|
230
|
+
- Entry points
|
|
231
|
+
- Error handling strategy
|
|
232
|
+
- Cross-cutting concerns (logging, auth, validation)
|
|
233
|
+
|
|
234
|
+
**What does NOT belong here:**
|
|
235
|
+
- Exhaustive file listings (that's STRUCTURE.md)
|
|
236
|
+
- Technology choices (that's STACK.md)
|
|
237
|
+
- Line-by-line code walkthrough (defer to code reading)
|
|
238
|
+
- Implementation details of specific features
|
|
239
|
+
|
|
240
|
+
**File paths ARE welcome:**
|
|
241
|
+
Include file paths as concrete examples of abstractions. Use backtick formatting: `src/services/user.ts`. This makes the architecture document actionable for Claude when planning.
|
|
242
|
+
|
|
243
|
+
**When filling this template:**
|
|
244
|
+
- Read main entry points (index, server, main)
|
|
245
|
+
- Identify layers by reading imports/dependencies
|
|
246
|
+
- Trace a typical request/command execution
|
|
247
|
+
- Note recurring patterns (services, controllers, repositories)
|
|
248
|
+
- Keep descriptions conceptual, not mechanical
|
|
249
|
+
|
|
250
|
+
**Useful for phase planning when:**
|
|
251
|
+
- Adding new features (where does it fit in the layers?)
|
|
252
|
+
- Refactoring (understanding current patterns)
|
|
253
|
+
- Identifying where to add code (which layer handles X?)
|
|
254
|
+
- Understanding dependencies between components
|
|
255
|
+
</guidelines>
|