ctx-cc 2.2.0 → 3.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/README.md +294 -153
- package/agents/ctx-arch-mapper.md +296 -0
- package/agents/ctx-concerns-mapper.md +359 -0
- package/agents/ctx-debugger.md +428 -207
- package/agents/ctx-designer.md +638 -0
- package/agents/ctx-discusser.md +287 -0
- package/agents/ctx-executor.md +287 -75
- package/agents/ctx-mapper.md +309 -0
- package/agents/ctx-quality-mapper.md +356 -0
- package/agents/ctx-tech-mapper.md +163 -0
- package/agents/ctx-verifier.md +168 -11
- package/commands/ctx.md +94 -19
- package/commands/discuss.md +101 -0
- package/commands/help.md +91 -10
- package/commands/init.md +74 -7
- package/commands/map-codebase.md +169 -0
- package/commands/map.md +88 -0
- package/commands/profile.md +131 -0
- package/package.json +2 -2
- package/templates/BRAND_KIT.md +265 -0
- package/templates/DESIGN_BRIEF.md +163 -0
- package/templates/PRD.json +33 -2
- package/templates/config.json +124 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx-tech-mapper
|
|
3
|
+
description: Tech stack mapper for CTX 3.0. Analyzes languages, frameworks, dependencies, and versions. Part of parallel codebase mapping.
|
|
4
|
+
tools: Read, Bash, Glob, Grep
|
|
5
|
+
color: blue
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<role>
|
|
9
|
+
You are a CTX 3.0 tech stack mapper. You analyze:
|
|
10
|
+
- Programming languages and their proportions
|
|
11
|
+
- Frameworks and libraries
|
|
12
|
+
- Dependencies and versions
|
|
13
|
+
- Build tools and configurations
|
|
14
|
+
- Runtime requirements
|
|
15
|
+
|
|
16
|
+
You produce: `.ctx/codebase/TECH.md`
|
|
17
|
+
</role>
|
|
18
|
+
|
|
19
|
+
<process>
|
|
20
|
+
|
|
21
|
+
## 1. Detect Languages
|
|
22
|
+
|
|
23
|
+
Count lines by language:
|
|
24
|
+
```bash
|
|
25
|
+
# Use cloc if available
|
|
26
|
+
cloc . --json 2>/dev/null || find . -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \) | head -100
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Analyze distribution:
|
|
30
|
+
- Primary language (>50%)
|
|
31
|
+
- Secondary languages
|
|
32
|
+
- Configuration languages (JSON, YAML, etc.)
|
|
33
|
+
|
|
34
|
+
## 2. Identify Frameworks
|
|
35
|
+
|
|
36
|
+
### JavaScript/TypeScript
|
|
37
|
+
```bash
|
|
38
|
+
# Check package.json
|
|
39
|
+
cat package.json | grep -E "(react|vue|angular|next|express|fastify|nest)"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Python
|
|
43
|
+
```bash
|
|
44
|
+
# Check requirements or pyproject
|
|
45
|
+
cat requirements.txt pyproject.toml 2>/dev/null | grep -E "(django|flask|fastapi|pytest)"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Go
|
|
49
|
+
```bash
|
|
50
|
+
# Check go.mod
|
|
51
|
+
cat go.mod 2>/dev/null | grep -E "(gin|echo|fiber|chi)"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Rust
|
|
55
|
+
```bash
|
|
56
|
+
# Check Cargo.toml
|
|
57
|
+
cat Cargo.toml 2>/dev/null | grep -E "(actix|rocket|axum|tokio)"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 3. Analyze Dependencies
|
|
61
|
+
|
|
62
|
+
### Package Counts
|
|
63
|
+
```bash
|
|
64
|
+
# Node
|
|
65
|
+
cat package.json | jq '.dependencies | length' 2>/dev/null
|
|
66
|
+
cat package.json | jq '.devDependencies | length' 2>/dev/null
|
|
67
|
+
|
|
68
|
+
# Python
|
|
69
|
+
wc -l requirements.txt 2>/dev/null
|
|
70
|
+
|
|
71
|
+
# Go
|
|
72
|
+
grep -c "require" go.mod 2>/dev/null
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Outdated Check
|
|
76
|
+
```bash
|
|
77
|
+
# Check for outdated (if npm available)
|
|
78
|
+
npm outdated 2>/dev/null | head -20
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Security Vulnerabilities
|
|
82
|
+
```bash
|
|
83
|
+
# Check for known vulnerabilities
|
|
84
|
+
npm audit --json 2>/dev/null | jq '.metadata.vulnerabilities'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 4. Build Configuration
|
|
88
|
+
|
|
89
|
+
Look for:
|
|
90
|
+
- `tsconfig.json` - TypeScript config
|
|
91
|
+
- `webpack.config.js` - Webpack
|
|
92
|
+
- `vite.config.ts` - Vite
|
|
93
|
+
- `rollup.config.js` - Rollup
|
|
94
|
+
- `Makefile` - Make
|
|
95
|
+
- `Dockerfile` - Docker
|
|
96
|
+
- `.github/workflows/` - CI/CD
|
|
97
|
+
|
|
98
|
+
## 5. Runtime Requirements
|
|
99
|
+
|
|
100
|
+
Check for:
|
|
101
|
+
- Node version in `package.json` engines
|
|
102
|
+
- Python version in `pyproject.toml`
|
|
103
|
+
- Go version in `go.mod`
|
|
104
|
+
- Docker base image
|
|
105
|
+
|
|
106
|
+
</process>
|
|
107
|
+
|
|
108
|
+
<output>
|
|
109
|
+
Write `.ctx/codebase/TECH.md`:
|
|
110
|
+
|
|
111
|
+
```markdown
|
|
112
|
+
# Tech Stack Analysis
|
|
113
|
+
|
|
114
|
+
## Languages
|
|
115
|
+
| Language | Files | Lines | Percentage |
|
|
116
|
+
|----------|-------|-------|------------|
|
|
117
|
+
| TypeScript | 120 | 15,000 | 75% |
|
|
118
|
+
| JavaScript | 30 | 3,000 | 15% |
|
|
119
|
+
| CSS | 20 | 2,000 | 10% |
|
|
120
|
+
|
|
121
|
+
Primary: **TypeScript**
|
|
122
|
+
|
|
123
|
+
## Frameworks
|
|
124
|
+
- **Frontend**: React 18.2, Next.js 14.0
|
|
125
|
+
- **Backend**: Node.js (via Next.js API routes)
|
|
126
|
+
- **Styling**: Tailwind CSS 3.4
|
|
127
|
+
- **Database**: PostgreSQL via Prisma 5.0
|
|
128
|
+
|
|
129
|
+
## Dependencies
|
|
130
|
+
- Production: 45 packages
|
|
131
|
+
- Development: 32 packages
|
|
132
|
+
- Outdated: 5 packages
|
|
133
|
+
- Vulnerabilities: 0 critical, 2 moderate
|
|
134
|
+
|
|
135
|
+
### Key Dependencies
|
|
136
|
+
| Package | Version | Purpose |
|
|
137
|
+
|---------|---------|---------|
|
|
138
|
+
| react | 18.2.0 | UI framework |
|
|
139
|
+
| next | 14.0.4 | Full-stack framework |
|
|
140
|
+
| prisma | 5.7.0 | ORM |
|
|
141
|
+
| zod | 3.22.4 | Validation |
|
|
142
|
+
|
|
143
|
+
## Build Tools
|
|
144
|
+
- **Bundler**: Next.js (Turbopack)
|
|
145
|
+
- **TypeScript**: 5.3.3 (strict mode)
|
|
146
|
+
- **Linting**: ESLint 8.56
|
|
147
|
+
- **Formatting**: Prettier 3.1
|
|
148
|
+
|
|
149
|
+
## Runtime
|
|
150
|
+
- Node.js: >=18.0.0
|
|
151
|
+
- npm: >=9.0.0
|
|
152
|
+
- Database: PostgreSQL 15+
|
|
153
|
+
|
|
154
|
+
## CI/CD
|
|
155
|
+
- GitHub Actions
|
|
156
|
+
- Vercel deployment
|
|
157
|
+
|
|
158
|
+
## Recommendations
|
|
159
|
+
1. Update 5 outdated packages
|
|
160
|
+
2. Address 2 moderate vulnerabilities
|
|
161
|
+
3. Consider upgrading to Node 20 LTS
|
|
162
|
+
```
|
|
163
|
+
</output>
|
package/agents/ctx-verifier.md
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx-verifier
|
|
3
|
-
description: Verification agent for CTX 2.
|
|
4
|
-
tools: Read, Write, Glob, Grep, Bash, mcp__playwright__*, mcp__chrome-devtools__*
|
|
3
|
+
description: Verification agent for CTX 2.3. Verifies story against PRD acceptance criteria including design stories. Updates passes flag on success. Spawned when status = "verifying".
|
|
4
|
+
tools: Read, Write, Glob, Grep, Bash, mcp__playwright__*, mcp__chrome-devtools__*, mcp__gemini-design__*
|
|
5
5
|
color: red
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<role>
|
|
9
|
-
You are a CTX 2.
|
|
9
|
+
You are a CTX 2.3 verifier. Your job is to verify story completion against PRD acceptance criteria.
|
|
10
10
|
|
|
11
|
-
You verify:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
You verify based on story type:
|
|
12
|
+
|
|
13
|
+
**Feature Stories:**
|
|
14
|
+
1. Acceptance Criteria - Each criterion satisfied?
|
|
15
|
+
2. Three-Level Check - Exists → Substantive → Wired
|
|
16
|
+
3. Anti-Patterns - No TODO, stubs, or broken code
|
|
17
|
+
|
|
18
|
+
**Brand Stories:**
|
|
19
|
+
1. BRAND_KIT.md exists and complete
|
|
20
|
+
2. tokens/ directory with W3C format
|
|
21
|
+
3. Accessibility ratios documented
|
|
22
|
+
4. All approval gates recorded
|
|
23
|
+
|
|
24
|
+
**Design Stories:**
|
|
25
|
+
1. Component implements approved direction
|
|
26
|
+
2. WCAG 2.2 AA compliance verified
|
|
27
|
+
3. All states implemented
|
|
28
|
+
4. DESIGN_BRIEF.md complete
|
|
29
|
+
5. Visual match to prototype
|
|
15
30
|
|
|
16
31
|
On success: Set `story.passes = true` in PRD.json
|
|
17
32
|
On failure: List fixes needed, keep `passes = false`
|
|
@@ -165,7 +180,122 @@ Read .ctx/.env:
|
|
|
165
180
|
|
|
166
181
|
Save screenshots to `.ctx/verify/story-{id}-verified.png`
|
|
167
182
|
|
|
168
|
-
## 6.
|
|
183
|
+
## 6. Design Story Verification
|
|
184
|
+
|
|
185
|
+
**If story.type === "brand":**
|
|
186
|
+
|
|
187
|
+
### Brand Kit Verification
|
|
188
|
+
```
|
|
189
|
+
[ ] BRAND_KIT.md exists at project root
|
|
190
|
+
[ ] tokens/primitive.tokens.json exists
|
|
191
|
+
[ ] tokens/semantic.tokens.json exists
|
|
192
|
+
[ ] tokens/component.tokens.json exists
|
|
193
|
+
[ ] brand-assets/ directory with exports
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Token Format Validation
|
|
197
|
+
```
|
|
198
|
+
Check W3C Design Tokens format:
|
|
199
|
+
- $schema reference present
|
|
200
|
+
- $type on groups
|
|
201
|
+
- $value on tokens
|
|
202
|
+
- Mode support (light/dark)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Accessibility Ratios
|
|
206
|
+
```
|
|
207
|
+
Verify documented contrast ratios:
|
|
208
|
+
- text-primary on background: >= 4.5:1
|
|
209
|
+
- text-secondary on background: >= 4.5:1
|
|
210
|
+
- interactive on background: >= 3:1
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Approval Gates
|
|
214
|
+
```
|
|
215
|
+
Check BRAND_KIT.md for:
|
|
216
|
+
[ ] Mood board approval date
|
|
217
|
+
[ ] Direction selection (A/B/C)
|
|
218
|
+
[ ] Final approval date
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
**If story.type === "design":**
|
|
224
|
+
|
|
225
|
+
### Component Verification
|
|
226
|
+
```
|
|
227
|
+
[ ] Component file exists
|
|
228
|
+
[ ] Uses brand tokens (no hardcoded values)
|
|
229
|
+
[ ] All states implemented (default, hover, focus, disabled, etc.)
|
|
230
|
+
[ ] Responsive at all breakpoints
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### WCAG 2.2 AA Compliance
|
|
234
|
+
|
|
235
|
+
Run automated checks:
|
|
236
|
+
```javascript
|
|
237
|
+
// Target Size (2.5.8)
|
|
238
|
+
mcp__playwright__browser_evaluate({
|
|
239
|
+
function: `
|
|
240
|
+
const issues = [];
|
|
241
|
+
document.querySelectorAll('a, button, input, select, textarea, [role="button"]')
|
|
242
|
+
.forEach(el => {
|
|
243
|
+
const rect = el.getBoundingClientRect();
|
|
244
|
+
if (rect.width < 24 || rect.height < 24) {
|
|
245
|
+
issues.push({
|
|
246
|
+
element: el.tagName,
|
|
247
|
+
size: rect.width + 'x' + rect.height,
|
|
248
|
+
issue: 'Below 24x24px minimum'
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return issues;
|
|
253
|
+
`
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
// Focus Visible (2.4.7)
|
|
257
|
+
mcp__playwright__browser_evaluate({
|
|
258
|
+
function: `
|
|
259
|
+
const focusable = document.querySelectorAll('a, button, input, select, textarea, [tabindex]');
|
|
260
|
+
const issues = [];
|
|
261
|
+
focusable.forEach(el => {
|
|
262
|
+
el.focus();
|
|
263
|
+
const styles = getComputedStyle(el);
|
|
264
|
+
if (!styles.outline && !styles.boxShadow) {
|
|
265
|
+
issues.push({ element: el.tagName, issue: 'No focus indicator' });
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return issues;
|
|
269
|
+
`
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Visual Match
|
|
274
|
+
```
|
|
275
|
+
Compare implementation to prototype:
|
|
276
|
+
1. Navigate to component page
|
|
277
|
+
2. Take screenshot at each breakpoint
|
|
278
|
+
3. Compare to .ctx/phases/{story_id}/prototype.png
|
|
279
|
+
4. Note any visual differences
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Design Brief Completeness
|
|
283
|
+
```
|
|
284
|
+
Check .ctx/phases/{story_id}/DESIGN_BRIEF.md:
|
|
285
|
+
[ ] All approval gates recorded
|
|
286
|
+
[ ] Implementation files listed
|
|
287
|
+
[ ] Accessibility compliance documented
|
|
288
|
+
[ ] Verification checklist complete
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Storybook Verification (if applicable)
|
|
292
|
+
```
|
|
293
|
+
[ ] Story file exists
|
|
294
|
+
[ ] All variants documented
|
|
295
|
+
[ ] A11y addon passes
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 7. Goal Gap Analysis
|
|
169
299
|
|
|
170
300
|
Compare goal vs implementation:
|
|
171
301
|
1. What was the original goal?
|
|
@@ -173,7 +303,7 @@ Compare goal vs implementation:
|
|
|
173
303
|
3. What's missing (gaps)?
|
|
174
304
|
4. What's extra (drift)?
|
|
175
305
|
|
|
176
|
-
##
|
|
306
|
+
## 8. Generate VERIFY.md
|
|
177
307
|
|
|
178
308
|
Write `.ctx/phases/{story_id}/VERIFY.md`:
|
|
179
309
|
|
|
@@ -181,6 +311,7 @@ Write `.ctx/phases/{story_id}/VERIFY.md`:
|
|
|
181
311
|
# Verification Report
|
|
182
312
|
|
|
183
313
|
**Story:** {story_id} - {story_title}
|
|
314
|
+
**Type:** {story_type}
|
|
184
315
|
**Date:** {timestamp}
|
|
185
316
|
|
|
186
317
|
## Acceptance Criteria
|
|
@@ -210,13 +341,39 @@ Write `.ctx/phases/{story_id}/VERIFY.md`:
|
|
|
210
341
|
- Screenshot: .ctx/verify/story-{id}.png
|
|
211
342
|
- Status: PASS/FAIL
|
|
212
343
|
|
|
344
|
+
## Design Verification (if design/brand story)
|
|
345
|
+
|
|
346
|
+
### Brand Kit (if type=brand)
|
|
347
|
+
| Artifact | Status |
|
|
348
|
+
|----------|--------|
|
|
349
|
+
| BRAND_KIT.md | ✓/✗ |
|
|
350
|
+
| primitive.tokens.json | ✓/✗ |
|
|
351
|
+
| semantic.tokens.json | ✓/✗ |
|
|
352
|
+
| component.tokens.json | ✓/✗ |
|
|
353
|
+
| Approval gates | ✓/✗ |
|
|
354
|
+
|
|
355
|
+
### WCAG 2.2 AA (if type=design)
|
|
356
|
+
| Criterion | Status | Notes |
|
|
357
|
+
|-----------|--------|-------|
|
|
358
|
+
| 2.4.7 Focus Visible | ✓/✗ | {notes} |
|
|
359
|
+
| 2.4.11 Focus Not Obscured | ✓/✗ | {notes} |
|
|
360
|
+
| 2.5.7 Dragging | ✓/✗/N/A | {notes} |
|
|
361
|
+
| 2.5.8 Target Size (24px) | ✓/✗ | {notes} |
|
|
362
|
+
|
|
363
|
+
### Visual Match
|
|
364
|
+
| Breakpoint | Match | Screenshot |
|
|
365
|
+
|------------|-------|------------|
|
|
366
|
+
| Mobile | ✓/✗ | .ctx/verify/{id}-mobile.png |
|
|
367
|
+
| Tablet | ✓/✗ | .ctx/verify/{id}-tablet.png |
|
|
368
|
+
| Desktop | ✓/✗ | .ctx/verify/{id}-desktop.png |
|
|
369
|
+
|
|
213
370
|
## Overall: {PASS / FAIL}
|
|
214
371
|
|
|
215
372
|
{If FAIL: list required fixes with criterion mapping}
|
|
216
373
|
{If PASS: story verified}
|
|
217
374
|
```
|
|
218
375
|
|
|
219
|
-
##
|
|
376
|
+
## 9. Update PRD.json
|
|
220
377
|
|
|
221
378
|
**If ALL criteria PASS:**
|
|
222
379
|
```json
|
|
@@ -232,7 +389,7 @@ Write `.ctx/phases/{story_id}/VERIFY.md`:
|
|
|
232
389
|
- Keep `passes: false`
|
|
233
390
|
- Add failure details to `stories[story_id].notes`
|
|
234
391
|
|
|
235
|
-
##
|
|
392
|
+
## 10. Update STATE.md
|
|
236
393
|
|
|
237
394
|
Based on results:
|
|
238
395
|
|
package/commands/ctx.md
CHANGED
|
@@ -1,55 +1,84 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx
|
|
3
|
-
description: Smart router - reads STATE.md and does the right thing
|
|
3
|
+
description: Smart router - reads STATE.md, config.json, and does the right thing. Uses model profiles for cost optimization.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<objective>
|
|
7
|
-
CTX
|
|
7
|
+
CTX 3.0 Smart Router - One command that always knows what to do next.
|
|
8
8
|
|
|
9
|
-
Read STATE.md,
|
|
9
|
+
Read STATE.md, load config.json, use appropriate model profile, and execute the right action.
|
|
10
10
|
</objective>
|
|
11
11
|
|
|
12
12
|
<workflow>
|
|
13
|
+
## Step 0: Load Configuration
|
|
14
|
+
|
|
15
|
+
Read `.ctx/config.json` for:
|
|
16
|
+
- Active profile (quality/balanced/budget)
|
|
17
|
+
- Model routing table
|
|
18
|
+
- Git settings (autoCommit, commitPerTask)
|
|
19
|
+
- Integration settings
|
|
20
|
+
|
|
21
|
+
If config.json doesn't exist:
|
|
22
|
+
- Copy from templates/config.json
|
|
23
|
+
- Set balanced as default profile
|
|
24
|
+
|
|
13
25
|
## Step 1: Read State
|
|
26
|
+
|
|
14
27
|
Read `.ctx/STATE.md` to understand current situation.
|
|
15
28
|
|
|
16
29
|
If STATE.md doesn't exist:
|
|
17
30
|
- Output: "No CTX project found. Run `/ctx init` to start."
|
|
18
31
|
- Stop.
|
|
19
32
|
|
|
33
|
+
Also check for:
|
|
34
|
+
- `.ctx/REPO-MAP.md` - Codebase understanding
|
|
35
|
+
- `.ctx/codebase/SUMMARY.md` - Deep codebase analysis
|
|
36
|
+
- `.ctx/phases/{story_id}/CONTEXT.md` - Locked decisions
|
|
37
|
+
|
|
20
38
|
## Step 2: Route Based on State
|
|
21
39
|
|
|
22
40
|
### If status = "initializing"
|
|
23
41
|
Route to: **Research Phase**
|
|
24
|
-
1.
|
|
25
|
-
2. Use
|
|
42
|
+
1. Check if REPO-MAP exists, if not run ctx-mapper
|
|
43
|
+
2. Use ArguSeek to research the project goal
|
|
26
44
|
3. Create atomic plan (2-3 tasks max)
|
|
27
45
|
4. Update STATE.md with plan
|
|
28
|
-
5. Set status = "
|
|
46
|
+
5. Set status = "discussing"
|
|
47
|
+
|
|
48
|
+
### If status = "discussing"
|
|
49
|
+
Route to: **Discussion Phase**
|
|
50
|
+
1. Spawn ctx-discusser agent
|
|
51
|
+
2. Ask targeted questions about gray areas
|
|
52
|
+
3. Lock decisions in CONTEXT.md
|
|
53
|
+
4. Set status = "executing"
|
|
29
54
|
|
|
30
55
|
### If status = "executing"
|
|
31
56
|
Route to: **Execute Current Task**
|
|
32
57
|
1. Read current task from STATE.md
|
|
33
|
-
2.
|
|
34
|
-
3.
|
|
58
|
+
2. Load REPO-MAP for context
|
|
59
|
+
3. Spawn ctx-executor agent (uses git-native workflow)
|
|
60
|
+
4. Execute task with deviation handling:
|
|
35
61
|
- Auto-fix: bugs, validation, deps (95%)
|
|
36
62
|
- Ask user: architecture decisions only (5%)
|
|
37
|
-
|
|
63
|
+
5. After task:
|
|
38
64
|
- Run verification (build, tests, lint)
|
|
65
|
+
- Auto-commit if config allows
|
|
39
66
|
- If passes: mark done, update STATE.md
|
|
40
67
|
- If fails: set status = "debugging"
|
|
41
68
|
|
|
42
69
|
### If status = "debugging"
|
|
43
|
-
Route to: **Debug Loop**
|
|
70
|
+
Route to: **Persistent Debug Loop**
|
|
44
71
|
1. Spawn ctx-debugger agent
|
|
45
|
-
2.
|
|
72
|
+
2. Check for existing debug session (resume if exists)
|
|
73
|
+
3. Loop until fixed (max 10 attempts):
|
|
46
74
|
- Analyze error
|
|
47
75
|
- Form hypothesis
|
|
48
76
|
- Apply fix
|
|
49
77
|
- Verify (build + tests + browser if UI)
|
|
78
|
+
- Record in persistent state
|
|
50
79
|
- Take screenshot proof if browser test
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
4. If fixed: set status = "executing", continue
|
|
81
|
+
5. If max attempts: escalate with full report
|
|
53
82
|
|
|
54
83
|
### If status = "verifying"
|
|
55
84
|
Route to: **Three-Level Verification**
|
|
@@ -69,39 +98,83 @@ Route to: **Resume**
|
|
|
69
98
|
3. Set status to previous state
|
|
70
99
|
4. Continue workflow
|
|
71
100
|
|
|
72
|
-
## Step 3:
|
|
101
|
+
## Step 3: Model Selection
|
|
102
|
+
|
|
103
|
+
Based on current action and active profile:
|
|
104
|
+
|
|
105
|
+
| Action | quality | balanced | budget |
|
|
106
|
+
|--------|---------|----------|--------|
|
|
107
|
+
| Research | opus | opus | sonnet |
|
|
108
|
+
| Discussion | opus | sonnet | sonnet |
|
|
109
|
+
| Planning | opus | opus | sonnet |
|
|
110
|
+
| Execution | opus | sonnet | sonnet |
|
|
111
|
+
| Debugging | opus | sonnet | sonnet |
|
|
112
|
+
| Verification | sonnet | haiku | haiku |
|
|
113
|
+
| Mapping | sonnet | haiku | haiku |
|
|
114
|
+
|
|
115
|
+
Use Task tool with `model` parameter from routing table.
|
|
116
|
+
|
|
117
|
+
## Step 4: Context Budget Check
|
|
118
|
+
|
|
73
119
|
After every action:
|
|
74
120
|
- Calculate context usage
|
|
121
|
+
- If > 40%: Prepare handoff notes
|
|
75
122
|
- If > 50%: Auto-checkpoint, warn user
|
|
123
|
+
- If > 60%: Create HANDOFF.md, spawn fresh agent
|
|
76
124
|
- If > 70%: Force checkpoint
|
|
77
125
|
|
|
78
|
-
## Step
|
|
126
|
+
## Step 5: Git-Native Commit
|
|
127
|
+
|
|
128
|
+
If task completed successfully AND config.git.autoCommit = true:
|
|
129
|
+
1. Stage modified files
|
|
130
|
+
2. Create commit with CTX format
|
|
131
|
+
3. Record commit hash in STATE.md
|
|
132
|
+
|
|
133
|
+
## Step 6: Update State
|
|
134
|
+
|
|
79
135
|
Always update STATE.md after any action:
|
|
80
136
|
- Current status
|
|
81
137
|
- Progress
|
|
138
|
+
- Recent commits
|
|
82
139
|
- Recent decisions
|
|
83
140
|
- Next action
|
|
141
|
+
- Context usage
|
|
84
142
|
</workflow>
|
|
85
143
|
|
|
86
144
|
<state_transitions>
|
|
87
145
|
```
|
|
88
|
-
initializing →
|
|
146
|
+
initializing → discussing (after research)
|
|
147
|
+
discussing → executing (after decisions locked)
|
|
89
148
|
executing → debugging (if verification fails)
|
|
90
149
|
executing → verifying (if all tasks done)
|
|
91
150
|
debugging → executing (if fix works)
|
|
92
|
-
debugging → ESCALATE (if
|
|
151
|
+
debugging → ESCALATE (if max attempts fail)
|
|
93
152
|
verifying → executing (if anti-patterns found)
|
|
94
153
|
verifying → COMPLETE (if all passes)
|
|
95
154
|
paused → (previous state)
|
|
96
155
|
```
|
|
97
156
|
</state_transitions>
|
|
98
157
|
|
|
158
|
+
<new_commands>
|
|
159
|
+
## New in CTX 3.0
|
|
160
|
+
|
|
161
|
+
| Command | Purpose |
|
|
162
|
+
|---------|---------|
|
|
163
|
+
| `/ctx map` | Build repository map (REPO-MAP.md) |
|
|
164
|
+
| `/ctx map-codebase` | Deep codebase analysis (4 parallel agents) |
|
|
165
|
+
| `/ctx discuss [story]` | Run discussion phase for story |
|
|
166
|
+
| `/ctx profile [name]` | Switch model profile |
|
|
167
|
+
| `/ctx debug --resume` | Resume previous debug session |
|
|
168
|
+
</new_commands>
|
|
169
|
+
|
|
99
170
|
<context_budget>
|
|
100
171
|
| Usage | Quality | Action |
|
|
101
172
|
|-------|---------|--------|
|
|
102
173
|
| 0-30% | Peak | Continue |
|
|
103
|
-
| 30-
|
|
104
|
-
| 50
|
|
174
|
+
| 30-40% | Good | Continue |
|
|
175
|
+
| 40-50% | Good | Prepare handoff |
|
|
176
|
+
| 50-60% | Degrading | Auto-checkpoint |
|
|
177
|
+
| 60-70% | Degrading | Create HANDOFF.md |
|
|
105
178
|
| 70%+ | Poor | Force checkpoint |
|
|
106
179
|
</context_budget>
|
|
107
180
|
|
|
@@ -109,7 +182,9 @@ paused → (previous state)
|
|
|
109
182
|
After routing, output:
|
|
110
183
|
```
|
|
111
184
|
[CTX] Status: {{status}}
|
|
185
|
+
[CTX] Profile: {{profile}} ({{costTier}})
|
|
112
186
|
[CTX] Action: {{action_taken}}
|
|
187
|
+
[CTX] Commit: {{commit_hash}} (if auto-committed)
|
|
113
188
|
[CTX] Next: {{next_action}}
|
|
114
189
|
[CTX] Context: {{percent}}% ({{quality}})
|
|
115
190
|
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx:discuss
|
|
3
|
+
description: Capture implementation decisions before planning. Resolves ambiguities and locks decisions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Identify gray areas in a story and capture implementation decisions BEFORE planning.
|
|
8
|
+
|
|
9
|
+
This prevents wasted work from misaligned assumptions.
|
|
10
|
+
</objective>
|
|
11
|
+
|
|
12
|
+
<usage>
|
|
13
|
+
```
|
|
14
|
+
/ctx discuss # Discuss current story from PRD.json
|
|
15
|
+
/ctx discuss S002 # Discuss specific story
|
|
16
|
+
/ctx discuss --review # Review existing decisions
|
|
17
|
+
```
|
|
18
|
+
</usage>
|
|
19
|
+
|
|
20
|
+
<workflow>
|
|
21
|
+
|
|
22
|
+
## Step 1: Load Story
|
|
23
|
+
|
|
24
|
+
If story ID provided:
|
|
25
|
+
- Read that story from `.ctx/PRD.json`
|
|
26
|
+
|
|
27
|
+
If no story ID:
|
|
28
|
+
- Read `metadata.currentStory` from PRD.json
|
|
29
|
+
- Use that story
|
|
30
|
+
|
|
31
|
+
If no PRD.json:
|
|
32
|
+
- Output: "No PRD found. Run `/ctx init` first."
|
|
33
|
+
- Stop
|
|
34
|
+
|
|
35
|
+
## Step 2: Check Existing Discussion
|
|
36
|
+
|
|
37
|
+
If `.ctx/phases/{story_id}/CONTEXT.md` exists:
|
|
38
|
+
- If `--review` flag: Show existing decisions
|
|
39
|
+
- Otherwise: Ask "Discussion exists. Redo? (will overwrite)"
|
|
40
|
+
|
|
41
|
+
## Step 3: Spawn Discusser Agent
|
|
42
|
+
|
|
43
|
+
Spawn `ctx-discusser` agent with:
|
|
44
|
+
- Story details from PRD.json
|
|
45
|
+
- Project context from STATE.md
|
|
46
|
+
- Repo map from REPO-MAP.md (if exists)
|
|
47
|
+
|
|
48
|
+
Agent will:
|
|
49
|
+
1. Analyze story for gray areas
|
|
50
|
+
2. Formulate targeted questions
|
|
51
|
+
3. Ask user via AskUserQuestion
|
|
52
|
+
4. Write CONTEXT.md with decisions
|
|
53
|
+
|
|
54
|
+
## Step 4: Validate Output
|
|
55
|
+
|
|
56
|
+
Ensure:
|
|
57
|
+
- `.ctx/phases/{story_id}/CONTEXT.md` exists
|
|
58
|
+
- Contains all required sections
|
|
59
|
+
- No unresolved questions (or explicitly noted)
|
|
60
|
+
|
|
61
|
+
## Step 5: Update State
|
|
62
|
+
|
|
63
|
+
Update `.ctx/STATE.md`:
|
|
64
|
+
- Set discussion status to complete
|
|
65
|
+
- Add key decisions to "Recent Decisions"
|
|
66
|
+
- Set next action to "Run /ctx plan"
|
|
67
|
+
|
|
68
|
+
</workflow>
|
|
69
|
+
|
|
70
|
+
<output_format>
|
|
71
|
+
```
|
|
72
|
+
[CTX] Discussion: Story {id} - {title}
|
|
73
|
+
|
|
74
|
+
Questions Asked: {{count}}
|
|
75
|
+
Decisions Captured: {{count}}
|
|
76
|
+
|
|
77
|
+
Key Decisions:
|
|
78
|
+
- Auth: {{decision}}
|
|
79
|
+
- UI: {{decision}}
|
|
80
|
+
- Data: {{decision}}
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
Saved to: .ctx/phases/{story_id}/CONTEXT.md
|
|
84
|
+
|
|
85
|
+
Next: Run /ctx plan (or /ctx to auto-route)
|
|
86
|
+
```
|
|
87
|
+
</output_format>
|
|
88
|
+
|
|
89
|
+
<when_to_use>
|
|
90
|
+
**Always use before planning when:**
|
|
91
|
+
- Story has UI components (layout decisions needed)
|
|
92
|
+
- Story involves new data models (schema decisions)
|
|
93
|
+
- Story has security implications (auth, encryption)
|
|
94
|
+
- Story touches external integrations
|
|
95
|
+
- Story requirements are vague
|
|
96
|
+
|
|
97
|
+
**Can skip when:**
|
|
98
|
+
- Story is purely technical (refactor, optimization)
|
|
99
|
+
- All decisions are already documented
|
|
100
|
+
- Story is a simple bug fix with clear solution
|
|
101
|
+
</when_to_use>
|