@eskoubar95/spec 0.1.0 → 0.1.3
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/dist/commands/help.d.ts +5 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +23 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +30 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +5 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +88 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/update.d.ts +5 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +72 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/workspace.d.ts +5 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +17 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/index.js +42 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/backup-cursor.d.ts +16 -0
- package/dist/lib/backup-cursor.d.ts.map +1 -0
- package/dist/lib/backup-cursor.js +50 -0
- package/dist/lib/backup-cursor.js.map +1 -0
- package/dist/lib/copy-template.d.ts +9 -1
- package/dist/lib/copy-template.d.ts.map +1 -1
- package/dist/lib/copy-template.js +94 -3
- package/dist/lib/copy-template.js.map +1 -1
- package/dist/lib/cursor-detection.d.ts +6 -0
- package/dist/lib/cursor-detection.d.ts.map +1 -0
- package/dist/lib/cursor-detection.js +31 -0
- package/dist/lib/cursor-detection.js.map +1 -0
- package/dist/lib/detection.d.ts +25 -0
- package/dist/lib/detection.d.ts.map +1 -0
- package/dist/lib/detection.js +186 -0
- package/dist/lib/detection.js.map +1 -0
- package/dist/lib/install-existing.d.ts +6 -0
- package/dist/lib/install-existing.d.ts.map +1 -0
- package/dist/lib/install-existing.js +63 -0
- package/dist/lib/install-existing.js.map +1 -0
- package/dist/lib/project-name.d.ts +7 -0
- package/dist/lib/project-name.d.ts.map +1 -0
- package/dist/lib/project-name.js +13 -0
- package/dist/lib/project-name.js.map +1 -0
- package/dist/lib/prompts.d.ts +6 -5
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +114 -0
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/version-check.d.ts +21 -0
- package/dist/lib/version-check.d.ts.map +1 -0
- package/dist/lib/version-check.js +49 -0
- package/dist/lib/version-check.js.map +1 -0
- package/dist/lib/workspace.d.ts +7 -0
- package/dist/lib/workspace.d.ts.map +1 -0
- package/dist/lib/workspace.js +38 -0
- package/dist/lib/workspace.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
- package/template/.cursor/commands/_shared/activation.md +220 -0
- package/template/.cursor/commands/_shared/coderabbit-integration.md +278 -0
- package/template/.cursor/commands/_shared/command-stacks.md +124 -0
- package/template/.cursor/commands/_shared/deployment-detection.md +294 -0
- package/template/.cursor/commands/_shared/detection.md +277 -0
- package/template/.cursor/commands/_shared/documentation-lookup.md +321 -0
- package/template/.cursor/commands/_shared/git-workflow.md +288 -0
- package/template/.cursor/commands/_shared/github-helpers.md +337 -0
- package/template/.cursor/commands/_shared/github-workflows.md +351 -0
- package/template/.cursor/commands/_shared/helper-metadata.md +481 -0
- package/template/.cursor/commands/_shared/linear-automation.md +388 -0
- package/template/.cursor/commands/_shared/linear-helpers.md +254 -0
- package/template/.cursor/commands/_shared/performance-monitoring.md +369 -0
- package/template/.cursor/commands/_shared/pr-description.md +279 -0
- package/template/.cursor/commands/_shared/retrospective-spec-creation.md +977 -0
- package/template/.cursor/commands/_shared/scaling.md +264 -0
- package/template/.cursor/commands/_shared/state-assertions.md +174 -0
- package/template/.cursor/commands/_shared/test-automation.md +388 -0
- package/template/.cursor/commands/_shared/verification-checkpoints.md +145 -0
- package/template/.cursor/commands/spec/audit.md +240 -0
- package/template/.cursor/commands/spec/evolve.md +163 -0
- package/template/.cursor/commands/spec/sync.md +196 -0
- package/template/.cursor/commands/tools/refactor.md +555 -0
- package/template/.cursor/rules/10-engineering.mdc +149 -0
- package/template/.cursor/rules/11-design.mdc +129 -0
- package/template/.cursor/rules/12-business.mdc +132 -0
- package/template/.cursor/rules/20-nextjs.mdc +146 -0
- package/template/.cursor/rules/21-api-design.mdc +176 -0
- package/template/.cursor/rules/30-database.mdc +183 -0
- package/template/.cursor/rules/31-testing.mdc +191 -0
- package/template/.cursor/scripts/validate-helpers.js +254 -0
- package/template/.sdd/detection-cache.json +1 -0
- package/template/.sdd/install-info.json +1 -0
- package/template/.sdd/version +1 -0
- package/template/spec/00-root-spec.md +8 -1
- package/template/work/backlog/tasks.local.md +92 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
helper_id: coderabbit-integration
|
|
3
|
+
load_when:
|
|
4
|
+
- pr_exists
|
|
5
|
+
- code_review_needed
|
|
6
|
+
- task_validate
|
|
7
|
+
- refactoring_analysis
|
|
8
|
+
dependencies:
|
|
9
|
+
- github-helpers
|
|
10
|
+
sections:
|
|
11
|
+
detection:
|
|
12
|
+
title: "CodeRabbit Detection"
|
|
13
|
+
lines: [14, 60]
|
|
14
|
+
categorization:
|
|
15
|
+
title: "Issue Categorization"
|
|
16
|
+
lines: [61, 120]
|
|
17
|
+
resolution:
|
|
18
|
+
title: "Conversation Resolution"
|
|
19
|
+
lines: [121, 180]
|
|
20
|
+
argumentation:
|
|
21
|
+
title: "Argumentation Logging"
|
|
22
|
+
lines: [181, 234]
|
|
23
|
+
always_load: false
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# CodeRabbit Integration
|
|
27
|
+
|
|
28
|
+
This helper provides logic for detecting, reading, and handling CodeRabbit code review comments from GitHub PRs.
|
|
29
|
+
|
|
30
|
+
## Purpose
|
|
31
|
+
|
|
32
|
+
Automatically handle CodeRabbit comments by:
|
|
33
|
+
- Detecting CodeRabbit comments in PRs
|
|
34
|
+
- Categorizing issues (Minor, Major, Bottleneck, Optimization)
|
|
35
|
+
- Evaluating if issues are already resolved in code
|
|
36
|
+
- Resolving conversations when issues are fixed
|
|
37
|
+
- Providing argumentation when issues shouldn't be resolved
|
|
38
|
+
|
|
39
|
+
## CodeRabbit Detection
|
|
40
|
+
|
|
41
|
+
### Detection Methods
|
|
42
|
+
|
|
43
|
+
**Method 1: Pattern Search**
|
|
44
|
+
- Search for patterns in comment text:
|
|
45
|
+
- "CodeRabbit"
|
|
46
|
+
- "code rabbit"
|
|
47
|
+
- "CodeRabbit AI"
|
|
48
|
+
- "coderabbit"
|
|
49
|
+
- Case-insensitive matching
|
|
50
|
+
|
|
51
|
+
**Method 2: Author Check**
|
|
52
|
+
- Check if comment author is CodeRabbit bot
|
|
53
|
+
- Common bot usernames:
|
|
54
|
+
- "coderabbitai"
|
|
55
|
+
- "coderabbit[bot]"
|
|
56
|
+
- "code-rabbit"
|
|
57
|
+
- "CodeRabbit"
|
|
58
|
+
|
|
59
|
+
**Combined Detection:**
|
|
60
|
+
- Use both methods for reliable detection
|
|
61
|
+
- If either method matches → treat as CodeRabbit comment
|
|
62
|
+
|
|
63
|
+
## Reading PR Comments
|
|
64
|
+
|
|
65
|
+
### GitHub Integration Fallback Strategy
|
|
66
|
+
|
|
67
|
+
**Priority 1: GitHub MCP**
|
|
68
|
+
- Use `mcp_github_get_pull_request_comments` if available
|
|
69
|
+
- Check MCP availability first
|
|
70
|
+
|
|
71
|
+
**Priority 2: GitHub CLI**
|
|
72
|
+
- If MCP not available → use GitHub CLI `gh pr view --comments`
|
|
73
|
+
- Check if `gh` is installed: `gh --version`
|
|
74
|
+
- Parse CLI output for comments
|
|
75
|
+
|
|
76
|
+
**Priority 3: Local Mode**
|
|
77
|
+
- If both fail → log to local mode
|
|
78
|
+
- Store in `work/backlog/tasks.local.md` for manual review
|
|
79
|
+
|
|
80
|
+
### Comment Structure
|
|
81
|
+
|
|
82
|
+
CodeRabbit comments typically include:
|
|
83
|
+
- **Issue type:** Minor, Major, Bottleneck, Optimization
|
|
84
|
+
- **File path:** Which file has the issue
|
|
85
|
+
- **Line numbers:** Specific lines affected
|
|
86
|
+
- **Suggestion:** What should be changed
|
|
87
|
+
- **Reason:** Why the change is suggested
|
|
88
|
+
|
|
89
|
+
## Issue Categorization
|
|
90
|
+
|
|
91
|
+
### Categories
|
|
92
|
+
|
|
93
|
+
**Minor:**
|
|
94
|
+
- Styling issues (formatting, spacing)
|
|
95
|
+
- Naming conventions
|
|
96
|
+
- Code style preferences
|
|
97
|
+
- Minor optimizations
|
|
98
|
+
|
|
99
|
+
**Major:**
|
|
100
|
+
- Performance issues
|
|
101
|
+
- Security vulnerabilities
|
|
102
|
+
- Bugs or potential bugs
|
|
103
|
+
- Architecture concerns
|
|
104
|
+
|
|
105
|
+
**Bottleneck:**
|
|
106
|
+
- Performance bottlenecks
|
|
107
|
+
- Slow operations
|
|
108
|
+
- Resource-intensive code
|
|
109
|
+
- Scalability issues
|
|
110
|
+
|
|
111
|
+
**Optimization:**
|
|
112
|
+
- Code optimization suggestions
|
|
113
|
+
- Efficiency improvements
|
|
114
|
+
- Better algorithms
|
|
115
|
+
- Reduced complexity
|
|
116
|
+
|
|
117
|
+
### Categorization Logic
|
|
118
|
+
|
|
119
|
+
1. **Read comment text:**
|
|
120
|
+
- Look for keywords: "minor", "major", "bottleneck", "optimization"
|
|
121
|
+
- Check CodeRabbit labels/markers
|
|
122
|
+
|
|
123
|
+
2. **Analyze suggestion:**
|
|
124
|
+
- If performance-related → Bottleneck or Optimization
|
|
125
|
+
- If security-related → Major
|
|
126
|
+
- If styling-related → Minor
|
|
127
|
+
- If bug-related → Major
|
|
128
|
+
|
|
129
|
+
3. **Default categorization:**
|
|
130
|
+
- If unclear → treat as Minor (less disruptive)
|
|
131
|
+
|
|
132
|
+
## Evaluating Resolution
|
|
133
|
+
|
|
134
|
+
### Step 1: Check if Issue Already Resolved
|
|
135
|
+
|
|
136
|
+
**For each CodeRabbit comment:**
|
|
137
|
+
1. **Read file mentioned in comment:**
|
|
138
|
+
- Get file path from comment
|
|
139
|
+
- Read current file content
|
|
140
|
+
|
|
141
|
+
2. **Check if issue is fixed:**
|
|
142
|
+
- Compare comment suggestion with current code
|
|
143
|
+
- If suggestion already implemented → mark as resolved
|
|
144
|
+
- If code changed but issue persists → mark as unresolved
|
|
145
|
+
|
|
146
|
+
3. **Verify resolution:**
|
|
147
|
+
- Check if the specific issue mentioned is addressed
|
|
148
|
+
- Don't assume all changes resolve the issue
|
|
149
|
+
|
|
150
|
+
### Step 2: Evaluate if Issue Should Be Resolved
|
|
151
|
+
|
|
152
|
+
**If issue not resolved:**
|
|
153
|
+
1. **Assess importance:**
|
|
154
|
+
- Minor issues: Can be deferred
|
|
155
|
+
- Major issues: Should be addressed
|
|
156
|
+
- Bottlenecks: Should be addressed if performance-critical
|
|
157
|
+
- Optimizations: Can be deferred if not critical
|
|
158
|
+
|
|
159
|
+
2. **Check refactoring rules:**
|
|
160
|
+
- Compare with refactoring rules (see `/tools/refactor`)
|
|
161
|
+
- If aligns with refactoring rules → should be resolved
|
|
162
|
+
- If conflicts with project patterns → may not need resolution
|
|
163
|
+
|
|
164
|
+
3. **Consider project context:**
|
|
165
|
+
- Is this a critical path?
|
|
166
|
+
- Is this blocking other work?
|
|
167
|
+
- Is this a known pattern in the project?
|
|
168
|
+
|
|
169
|
+
## Resolution Actions
|
|
170
|
+
|
|
171
|
+
### When Issue is Resolved
|
|
172
|
+
|
|
173
|
+
1. **Resolve conversation:**
|
|
174
|
+
- Use GitHub helpers (see `github-helpers.md`)
|
|
175
|
+
- Mark conversation as resolved
|
|
176
|
+
- Add comment: "Issue resolved in code"
|
|
177
|
+
|
|
178
|
+
2. **Track resolution:**
|
|
179
|
+
- Log to tracking system (avoid duplicate resolution)
|
|
180
|
+
- Update local tracking if needed
|
|
181
|
+
|
|
182
|
+
### When Issue Should Be Resolved (But Not Yet)
|
|
183
|
+
|
|
184
|
+
1. **Create task:**
|
|
185
|
+
- Add to `work/backlog/tasks.local.md` or Linear
|
|
186
|
+
- Reference CodeRabbit comment
|
|
187
|
+
- Set appropriate priority
|
|
188
|
+
|
|
189
|
+
2. **Add comment to PR:**
|
|
190
|
+
- Acknowledge the issue
|
|
191
|
+
- Explain when it will be addressed
|
|
192
|
+
- Reference created task
|
|
193
|
+
|
|
194
|
+
### When Issue Shouldn't Be Resolved
|
|
195
|
+
|
|
196
|
+
1. **Provide argumentation:**
|
|
197
|
+
- Explain why the issue won't be resolved
|
|
198
|
+
- Reference project patterns or decisions
|
|
199
|
+
- Log to Linear issue or GitHub issue comment
|
|
200
|
+
|
|
201
|
+
2. **Log to local mode:**
|
|
202
|
+
- If Linear/GitHub not available → log to `work/backlog/tasks.local.md`
|
|
203
|
+
- Include argumentation for future reference
|
|
204
|
+
|
|
205
|
+
## Integration Points
|
|
206
|
+
|
|
207
|
+
### In `/task/validate`:
|
|
208
|
+
|
|
209
|
+
**After validation:**
|
|
210
|
+
1. Check if PR exists (from current branch)
|
|
211
|
+
2. If PR exists → read CodeRabbit comments
|
|
212
|
+
3. For each CodeRabbit comment:
|
|
213
|
+
- Check if issue resolved
|
|
214
|
+
- If resolved → resolve conversation
|
|
215
|
+
- If not resolved → evaluate and take action
|
|
216
|
+
|
|
217
|
+
### In `/tools/refactor`:
|
|
218
|
+
|
|
219
|
+
**After refactoring:**
|
|
220
|
+
1. Check if PR exists
|
|
221
|
+
2. If PR exists → read CodeRabbit comments
|
|
222
|
+
3. For each refactoring-related comment:
|
|
223
|
+
- Evaluate against refactoring rules
|
|
224
|
+
- If refactoring needed → apply refactoring
|
|
225
|
+
- If not needed → provide argumentation
|
|
226
|
+
|
|
227
|
+
## Error Handling
|
|
228
|
+
|
|
229
|
+
- **GitHub MCP not available:** Try GitHub CLI, then local mode
|
|
230
|
+
- **GitHub CLI not available:** Use local mode
|
|
231
|
+
- **CodeRabbit not found:** Skip CodeRabbit integration, continue workflow
|
|
232
|
+
- **PR not found:** Skip PR integration, continue workflow
|
|
233
|
+
- **Comment parsing fails:** Log error, continue with next comment
|
|
234
|
+
|
|
235
|
+
## Best Practices
|
|
236
|
+
|
|
237
|
+
1. **Don't block workflow:** If CodeRabbit integration fails, continue without it
|
|
238
|
+
2. **Respect user decisions:** If user explicitly ignores an issue, don't re-raise it
|
|
239
|
+
3. **Track resolutions:** Avoid duplicate resolution attempts
|
|
240
|
+
4. **Provide context:** When arguing against resolution, provide clear reasoning
|
|
241
|
+
5. **Prioritize correctly:** Address Major issues before Minor issues
|
|
242
|
+
|
|
243
|
+
## Examples
|
|
244
|
+
|
|
245
|
+
### Example 1: Minor Issue Resolved
|
|
246
|
+
|
|
247
|
+
**CodeRabbit comment:**
|
|
248
|
+
- "Consider using const instead of let for variable that's never reassigned"
|
|
249
|
+
- File: `src/utils/helpers.ts`, Line 42
|
|
250
|
+
|
|
251
|
+
**Action:**
|
|
252
|
+
- Check if code already uses `const`
|
|
253
|
+
- If yes → resolve conversation
|
|
254
|
+
- If no → check if should be changed (usually yes for Minor)
|
|
255
|
+
|
|
256
|
+
### Example 2: Major Issue Not Resolved
|
|
257
|
+
|
|
258
|
+
**CodeRabbit comment:**
|
|
259
|
+
- "Potential security vulnerability: SQL injection risk"
|
|
260
|
+
- File: `src/api/users.ts`, Line 15
|
|
261
|
+
|
|
262
|
+
**Action:**
|
|
263
|
+
- Check if code uses parameterized queries
|
|
264
|
+
- If no → create task to fix (Major issue)
|
|
265
|
+
- Add comment to PR acknowledging issue
|
|
266
|
+
- Log to Linear or local backlog
|
|
267
|
+
|
|
268
|
+
### Example 3: Optimization Deferred
|
|
269
|
+
|
|
270
|
+
**CodeRabbit comment:**
|
|
271
|
+
- "Consider using Map instead of Object for better performance"
|
|
272
|
+
- File: `src/data/processor.ts`, Line 89
|
|
273
|
+
|
|
274
|
+
**Action:**
|
|
275
|
+
- Evaluate if performance is critical
|
|
276
|
+
- If not critical → add comment explaining deferral
|
|
277
|
+
- Log to backlog for future optimization
|
|
278
|
+
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
helper_id: command-stacks
|
|
3
|
+
load_when:
|
|
4
|
+
- command_invocation
|
|
5
|
+
- workflow_automation
|
|
6
|
+
sections:
|
|
7
|
+
invocation:
|
|
8
|
+
title: "Command Invocation"
|
|
9
|
+
lines: [1, 50]
|
|
10
|
+
stacks:
|
|
11
|
+
title: "Command Stacks"
|
|
12
|
+
lines: [51, 100]
|
|
13
|
+
always_load: false
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Command Stacks
|
|
17
|
+
|
|
18
|
+
Command stacks allow commands to invoke other commands in sequence, enabling automated workflows.
|
|
19
|
+
|
|
20
|
+
## Purpose
|
|
21
|
+
|
|
22
|
+
Command stacks provide:
|
|
23
|
+
- **Automated Workflows**: Execute multiple commands in sequence
|
|
24
|
+
- **Auto-Proceed Logic**: Optionally proceed without user confirmation between steps
|
|
25
|
+
- **Error Handling**: Stop on error, allow resume after fix
|
|
26
|
+
- **Stack Tracking**: Track progress through stack execution
|
|
27
|
+
|
|
28
|
+
## Available Command Stacks
|
|
29
|
+
|
|
30
|
+
### Full Project Initialization
|
|
31
|
+
**Stack:** `/spec/init` → `/spec/refine` → `/spec/plan`
|
|
32
|
+
**Purpose:** Complete project setup from idea to execution plan
|
|
33
|
+
**When to use:** New project initialization
|
|
34
|
+
**Auto-proceed:** Optional (ask user)
|
|
35
|
+
**Error handling:** Stop on error, allow resume
|
|
36
|
+
|
|
37
|
+
### Feature Development
|
|
38
|
+
**Stack:** `/spec/refine` → `/spec/plan` → `/task/start` → `/task/validate`
|
|
39
|
+
**Purpose:** Add new feature to existing project
|
|
40
|
+
**When to use:** Adding features to existing project
|
|
41
|
+
**Auto-proceed:** Optional (ask user)
|
|
42
|
+
**Error handling:** Stop on error, allow resume
|
|
43
|
+
|
|
44
|
+
### Task Execution
|
|
45
|
+
**Stack:** `/task/start` → `/task/validate`
|
|
46
|
+
**Purpose:** Execute and validate single task
|
|
47
|
+
**When to use:** Standard task execution workflow
|
|
48
|
+
**Auto-proceed:** Optional (ask user)
|
|
49
|
+
**Error handling:** Stop on error, allow resume
|
|
50
|
+
|
|
51
|
+
### Spec Evolution
|
|
52
|
+
**Stack:** `/spec/evolve` → `/spec/refine` → `/spec/plan`
|
|
53
|
+
**Purpose:** Update spec as project grows
|
|
54
|
+
**When to use:** Spec needs updating as project evolves
|
|
55
|
+
**Auto-proceed:** Optional (ask user)
|
|
56
|
+
**Error handling:** Stop on error, allow resume
|
|
57
|
+
|
|
58
|
+
### Legacy Project Onboarding
|
|
59
|
+
**Stack:** `/spec/audit` → `/spec/sync` → `/spec/refine`
|
|
60
|
+
**Purpose:** Onboard existing codebase into SDD
|
|
61
|
+
**When to use:** Working with legacy/existing codebase
|
|
62
|
+
**Auto-proceed:** Optional (ask user)
|
|
63
|
+
**Error handling:** Stop on error, allow resume
|
|
64
|
+
|
|
65
|
+
## Stack Execution
|
|
66
|
+
|
|
67
|
+
**Stack Invocation:**
|
|
68
|
+
Commands can invoke stacks using:
|
|
69
|
+
```markdown
|
|
70
|
+
**Command Stack:** /spec/init → /spec/refine → /spec/plan
|
|
71
|
+
**Auto-proceed:** [Yes | No]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Execution Flow:**
|
|
75
|
+
1. Execute first command in stack
|
|
76
|
+
2. Wait for completion (or auto-proceed if enabled)
|
|
77
|
+
3. Execute next command in stack
|
|
78
|
+
4. Continue until all commands complete
|
|
79
|
+
5. Stop on error (report issue, allow resume)
|
|
80
|
+
|
|
81
|
+
**Error Handling:**
|
|
82
|
+
- If command fails → stop stack execution
|
|
83
|
+
- Report error clearly
|
|
84
|
+
- Allow user to fix issue
|
|
85
|
+
- Resume from failed command with same stack
|
|
86
|
+
|
|
87
|
+
**Progress Tracking:**
|
|
88
|
+
- Track which command is executing
|
|
89
|
+
- Show progress (e.g., "Step 2 of 4")
|
|
90
|
+
- Allow user to skip remaining steps
|
|
91
|
+
- Allow user to cancel stack
|
|
92
|
+
|
|
93
|
+
## Auto-Proceed Logic
|
|
94
|
+
|
|
95
|
+
**When Auto-Proceed is Enabled:**
|
|
96
|
+
- Commands execute in sequence
|
|
97
|
+
- No user confirmation between steps
|
|
98
|
+
- Stop only on errors
|
|
99
|
+
- Report completion at end
|
|
100
|
+
|
|
101
|
+
**When Auto-Proceed is Disabled:**
|
|
102
|
+
- Ask user before each step
|
|
103
|
+
- Wait for confirmation
|
|
104
|
+
- Allow user to skip steps
|
|
105
|
+
- Allow user to cancel stack
|
|
106
|
+
|
|
107
|
+
## Stack Definition Format
|
|
108
|
+
|
|
109
|
+
Stacks are defined in this file with:
|
|
110
|
+
- Stack name
|
|
111
|
+
- Command sequence
|
|
112
|
+
- Purpose
|
|
113
|
+
- When to use
|
|
114
|
+
- Auto-proceed default
|
|
115
|
+
- Error handling strategy
|
|
116
|
+
|
|
117
|
+
## Usage in Commands
|
|
118
|
+
|
|
119
|
+
Commands can:
|
|
120
|
+
- Invoke stacks at the end (suggest next steps)
|
|
121
|
+
- Invoke stacks at the beginning (pre-workflow)
|
|
122
|
+
- Invoke stacks conditionally (based on detection results)
|
|
123
|
+
- Allow user to choose stack or single command
|
|
124
|
+
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
---
|
|
2
|
+
helper_id: deployment-detection
|
|
3
|
+
load_when:
|
|
4
|
+
- pr_created
|
|
5
|
+
- pr_updated
|
|
6
|
+
- validation_step
|
|
7
|
+
sections:
|
|
8
|
+
detection:
|
|
9
|
+
title: "Provider Detection"
|
|
10
|
+
lines: [32, 91]
|
|
11
|
+
preview:
|
|
12
|
+
title: "Preview Deployment Logic"
|
|
13
|
+
lines: [111, 194]
|
|
14
|
+
status:
|
|
15
|
+
title: "Deployment Status Checking"
|
|
16
|
+
lines: [214, 217]
|
|
17
|
+
always_load: false
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Deployment Detection & Automation
|
|
21
|
+
|
|
22
|
+
This helper provides logic for detecting deployment providers and automating preview deployments for PRs.
|
|
23
|
+
|
|
24
|
+
## Purpose
|
|
25
|
+
|
|
26
|
+
Automatically detect deployment providers and handle preview deployments:
|
|
27
|
+
- Detect deployment provider (Vercel, Railway, Netlify, etc.)
|
|
28
|
+
- Trigger preview deployments when PRs are created
|
|
29
|
+
- Check deployment status
|
|
30
|
+
- Add preview URLs to PR descriptions
|
|
31
|
+
|
|
32
|
+
## Section: Provider Detection (Lines 13-91)
|
|
33
|
+
|
|
34
|
+
### Detection Methods
|
|
35
|
+
|
|
36
|
+
**Method 1: Config Files**
|
|
37
|
+
- Check for provider-specific config files
|
|
38
|
+
- Vercel: `vercel.json`, `.vercel/` folder
|
|
39
|
+
- Railway: `railway.json`, `railway.toml`
|
|
40
|
+
- Netlify: `netlify.toml`
|
|
41
|
+
- AWS: `amplify.yml`, `serverless.yml`, `sam.yaml`, `appspec.yml`, `buildspec.yml`
|
|
42
|
+
- GCP: `app.yaml`, `cloudbuild.yaml`
|
|
43
|
+
- Azure: `azure-pipelines.yml`, `.github/workflows/azure-*.yml`
|
|
44
|
+
- Docker: `Dockerfile`, `docker-compose.yml`
|
|
45
|
+
- Kubernetes: `kubernetes/`, `k8s/` directories, `*.yaml` manifests
|
|
46
|
+
|
|
47
|
+
**Method 2: Spec Files**
|
|
48
|
+
- Read `spec/08-infrastructure.md`
|
|
49
|
+
- Check "Hosting" section for provider
|
|
50
|
+
- Check "CI/CD" section for deployment config
|
|
51
|
+
|
|
52
|
+
**Method 3: Environment Variables**
|
|
53
|
+
- Check for provider-specific env vars
|
|
54
|
+
- Vercel: `VERCEL`, `VERCEL_URL`
|
|
55
|
+
- Railway: `RAILWAY_ENVIRONMENT`
|
|
56
|
+
- Netlify: `NETLIFY`
|
|
57
|
+
|
|
58
|
+
**Method 4: Git Remote**
|
|
59
|
+
- Check git remote URLs
|
|
60
|
+
- `*.vercel.app` → Vercel
|
|
61
|
+
- `*.railway.app` → Railway
|
|
62
|
+
- `*.netlify.app` → Netlify
|
|
63
|
+
- `*.amplifyapp.com` → AWS Amplify
|
|
64
|
+
- `*.run.app` → GCP Cloud Run
|
|
65
|
+
- `*.appspot.com` → GCP App Engine
|
|
66
|
+
- `*.web.app` → Firebase Hosting
|
|
67
|
+
- `*.azurewebsites.net` → Azure App Service
|
|
68
|
+
- `*.azurestaticapps.net` → Azure Static Web Apps
|
|
69
|
+
|
|
70
|
+
### Provider-Specific Detection
|
|
71
|
+
|
|
72
|
+
#### Vercel
|
|
73
|
+
|
|
74
|
+
**Detection:**
|
|
75
|
+
- Check for `vercel.json` file
|
|
76
|
+
- Check for `.vercel/` directory
|
|
77
|
+
- Check for `VERCEL` environment variable
|
|
78
|
+
- Check git remote for `vercel.app`
|
|
79
|
+
|
|
80
|
+
**Preview Deployment:**
|
|
81
|
+
- Vercel automatically creates preview deployments for PRs
|
|
82
|
+
- Preview URL format: `https://[project-name]-[hash].vercel.app`
|
|
83
|
+
- Get preview URL from Vercel API or git remote
|
|
84
|
+
|
|
85
|
+
#### Railway
|
|
86
|
+
|
|
87
|
+
**Detection:**
|
|
88
|
+
- Check for `railway.json` file
|
|
89
|
+
- Check for `railway.toml` file
|
|
90
|
+
- Check for `RAILWAY_ENVIRONMENT` environment variable
|
|
91
|
+
- Check git remote for `railway.app`
|
|
92
|
+
|
|
93
|
+
**Preview Deployment:**
|
|
94
|
+
- Railway can create preview environments for PRs
|
|
95
|
+
- Requires Railway CLI or API integration
|
|
96
|
+
- Preview URL from Railway dashboard or API
|
|
97
|
+
|
|
98
|
+
#### Netlify
|
|
99
|
+
|
|
100
|
+
**Detection:**
|
|
101
|
+
- Check for `netlify.toml` file
|
|
102
|
+
- Check for `netlify/` directory
|
|
103
|
+
- Check for `NETLIFY` environment variable
|
|
104
|
+
- Check git remote for `netlify.app`
|
|
105
|
+
|
|
106
|
+
**Preview Deployment:**
|
|
107
|
+
- Netlify automatically creates preview deployments for PRs
|
|
108
|
+
- Preview URL format: `https://[branch-name]--[project-name].netlify.app`
|
|
109
|
+
- Get preview URL from Netlify API or build logs
|
|
110
|
+
|
|
111
|
+
## Section: Preview Deployment Logic (Lines 92-194)
|
|
112
|
+
|
|
113
|
+
### When to Deploy
|
|
114
|
+
|
|
115
|
+
**Trigger conditions:**
|
|
116
|
+
1. PR created (after PR creation)
|
|
117
|
+
2. PR updated (new commits pushed)
|
|
118
|
+
3. Manual trigger (if user requests)
|
|
119
|
+
|
|
120
|
+
**Skip conditions:**
|
|
121
|
+
1. Provider not detected
|
|
122
|
+
2. Preview deployment not configured
|
|
123
|
+
3. Deployment already in progress
|
|
124
|
+
4. User explicitly skips deployment
|
|
125
|
+
|
|
126
|
+
### Deployment Process
|
|
127
|
+
|
|
128
|
+
**Step 1: Detect Provider**
|
|
129
|
+
1. Run provider detection
|
|
130
|
+
2. If provider detected → proceed
|
|
131
|
+
3. If no provider → skip deployment
|
|
132
|
+
|
|
133
|
+
**Step 2: Check Deployment Status**
|
|
134
|
+
1. Check if deployment already exists for PR
|
|
135
|
+
2. If exists → get preview URL
|
|
136
|
+
3. If not exists → trigger deployment
|
|
137
|
+
|
|
138
|
+
**Step 3: Trigger Deployment**
|
|
139
|
+
|
|
140
|
+
**Vercel:**
|
|
141
|
+
- Vercel auto-deploys on PR creation (if connected to GitHub)
|
|
142
|
+
- Get preview URL from Vercel API or wait for webhook
|
|
143
|
+
- Alternative: Use Vercel CLI `vercel --prod=false`
|
|
144
|
+
|
|
145
|
+
**Railway:**
|
|
146
|
+
- Use Railway CLI: `railway up`
|
|
147
|
+
- Or trigger via Railway API
|
|
148
|
+
- Get preview URL from Railway dashboard
|
|
149
|
+
|
|
150
|
+
**Netlify:**
|
|
151
|
+
- Netlify auto-deploys on PR creation (if connected to GitHub)
|
|
152
|
+
- Get preview URL from Netlify API
|
|
153
|
+
- Alternative: Use Netlify CLI `netlify deploy --branch=<branch-name>`
|
|
154
|
+
|
|
155
|
+
**AWS Amplify:**
|
|
156
|
+
- Amplify auto-deploys on PR creation (if connected to GitHub)
|
|
157
|
+
- Get preview URL from Amplify API or console
|
|
158
|
+
- Alternative: Use Amplify CLI `amplify publish --branch=<branch-name>`
|
|
159
|
+
|
|
160
|
+
**AWS Lambda (Serverless):**
|
|
161
|
+
- Use Serverless Framework: `serverless deploy --stage=preview`
|
|
162
|
+
- Or use AWS SAM: `sam deploy --stack-name preview-<branch>`
|
|
163
|
+
- Get preview URL from API Gateway or Lambda function URL
|
|
164
|
+
|
|
165
|
+
**GCP Cloud Run:**
|
|
166
|
+
- Deploy to preview service: `gcloud run deploy <service>-preview --source .`
|
|
167
|
+
- Get preview URL from Cloud Run service URL
|
|
168
|
+
- Or use Cloud Build for automated deployment
|
|
169
|
+
|
|
170
|
+
**GCP App Engine:**
|
|
171
|
+
- Deploy preview version: `gcloud app deploy --version=<branch-name>`
|
|
172
|
+
- Get preview URL from App Engine version URL
|
|
173
|
+
|
|
174
|
+
**Firebase Hosting:**
|
|
175
|
+
- Auto-deploys on PR creation (if connected to GitHub)
|
|
176
|
+
- Get preview URL from Firebase Hosting API
|
|
177
|
+
- Alternative: Use Firebase CLI `firebase hosting:channel:deploy <branch-name>`
|
|
178
|
+
|
|
179
|
+
**Azure App Service:**
|
|
180
|
+
- Deploy to staging slot: `az webapp deployment slot swap --slot staging`
|
|
181
|
+
- Get preview URL from staging slot URL
|
|
182
|
+
- Or use Azure CLI for preview deployment
|
|
183
|
+
|
|
184
|
+
**Azure Static Web Apps:**
|
|
185
|
+
- Auto-deploys on PR creation (if connected to GitHub)
|
|
186
|
+
- Get preview URL from Azure Static Web Apps API
|
|
187
|
+
- Preview URL format: `https://[branch-name].[app-name].azurestaticapps.net`
|
|
188
|
+
|
|
189
|
+
**Docker:**
|
|
190
|
+
- Build image: `docker build -t <image>:<branch-name> .`
|
|
191
|
+
- Push to registry: `docker push <image>:<branch-name>`
|
|
192
|
+
- Deploy to preview environment (provider-specific)
|
|
193
|
+
|
|
194
|
+
**Kubernetes:**
|
|
195
|
+
- Apply manifests to preview namespace: `kubectl apply -f k8s/ -n preview-<branch>`
|
|
196
|
+
- Get preview URL from ingress or service
|
|
197
|
+
- Or use Helm for preview deployment: `helm install preview-<branch> ./chart`
|
|
198
|
+
|
|
199
|
+
**Self-Hosted:**
|
|
200
|
+
- Execute custom deployment script
|
|
201
|
+
- Or trigger via CI/CD pipeline
|
|
202
|
+
- Get preview URL from deployment output or config
|
|
203
|
+
|
|
204
|
+
**Step 4: Wait for Deployment**
|
|
205
|
+
1. Poll deployment status
|
|
206
|
+
2. Wait for deployment to complete (or timeout)
|
|
207
|
+
3. Get preview URL when ready
|
|
208
|
+
|
|
209
|
+
**Step 5: Update PR**
|
|
210
|
+
1. Add preview URL to PR description
|
|
211
|
+
2. Format: `### Preview\n[Preview URL](url)`
|
|
212
|
+
3. Update PR via GitHub helpers
|
|
213
|
+
|
|
214
|
+
## Section: Deployment Status Checking (Lines 195-217)
|
|
215
|
+
|
|
216
|
+
### Vercel
|
|
217
|
+
|
|
218
|
+
**Check status:**
|
|
219
|
+
- Use Vercel API: `GET /v1/deployments`
|
|
220
|
+
- Check deployment status: `ready`, `building`, `error`
|
|
221
|
+
- Get preview URL from deployment object
|
|
222
|
+
|
|
223
|
+
### Railway
|
|
224
|
+
|
|
225
|
+
**Check status:**
|
|
226
|
+
- Use Railway API or CLI
|
|
227
|
+
- Check service status
|
|
228
|
+
- Get preview URL from service URL
|
|
229
|
+
|
|
230
|
+
### Netlify
|
|
231
|
+
|
|
232
|
+
**Check status:**
|
|
233
|
+
- Use Netlify API: `GET /api/v1/sites/[site_id]/deploys`
|
|
234
|
+
- Check deploy status: `ready`, `building`, `error`
|
|
235
|
+
- Get preview URL from deploy object
|
|
236
|
+
|
|
237
|
+
## Integration Points
|
|
238
|
+
|
|
239
|
+
### In `/task/validate`:
|
|
240
|
+
|
|
241
|
+
**After PR created:**
|
|
242
|
+
1. Detect deployment provider
|
|
243
|
+
2. If provider detected → trigger preview deployment
|
|
244
|
+
3. Wait for deployment (with timeout)
|
|
245
|
+
4. Get preview URL
|
|
246
|
+
5. Update PR description with preview URL
|
|
247
|
+
6. Update state tracking
|
|
248
|
+
|
|
249
|
+
### In GitHub Workflow:
|
|
250
|
+
|
|
251
|
+
**If GitHub Actions configured:**
|
|
252
|
+
- GitHub Actions can handle deployment
|
|
253
|
+
- This helper can check deployment status
|
|
254
|
+
- Get preview URL from GitHub Actions output or provider API
|
|
255
|
+
|
|
256
|
+
## Error Handling
|
|
257
|
+
|
|
258
|
+
- **Provider not detected:** Skip deployment, continue workflow
|
|
259
|
+
- **Deployment fails:** Report error, continue without preview URL
|
|
260
|
+
- **Deployment timeout:** Report timeout, continue workflow
|
|
261
|
+
- **API unavailable:** Skip deployment, continue workflow
|
|
262
|
+
- **Preview URL not available:** Continue without preview URL
|
|
263
|
+
|
|
264
|
+
## Best Practices
|
|
265
|
+
|
|
266
|
+
1. **Auto-detect provider:** Don't require manual configuration
|
|
267
|
+
2. **Graceful degradation:** Work even if deployment unavailable
|
|
268
|
+
3. **Update PR description:** Always add preview URL when available
|
|
269
|
+
4. **Handle timeouts:** Don't block workflow waiting for deployment
|
|
270
|
+
5. **Cache preview URLs:** Store in state file for quick access
|
|
271
|
+
|
|
272
|
+
## Examples
|
|
273
|
+
|
|
274
|
+
### Example 1: Vercel Auto-Deployment
|
|
275
|
+
|
|
276
|
+
**Detection:** `vercel.json` found
|
|
277
|
+
**Action:** Wait for Vercel auto-deployment
|
|
278
|
+
**Result:** Get preview URL from Vercel API
|
|
279
|
+
**Update PR:** Add preview URL to PR description
|
|
280
|
+
|
|
281
|
+
### Example 2: Railway Manual Deployment
|
|
282
|
+
|
|
283
|
+
**Detection:** `railway.json` found
|
|
284
|
+
**Action:** Trigger deployment via Railway CLI
|
|
285
|
+
**Result:** Get preview URL from Railway
|
|
286
|
+
**Update PR:** Add preview URL to PR description
|
|
287
|
+
|
|
288
|
+
### Example 3: No Provider Detected
|
|
289
|
+
|
|
290
|
+
**Detection:** No provider config found
|
|
291
|
+
**Action:** Skip deployment
|
|
292
|
+
**Result:** Continue workflow without preview URL
|
|
293
|
+
**Update PR:** No preview URL added
|
|
294
|
+
|