ctx-cc 3.3.8 → 3.4.1
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/agents/ctx-arch-mapper.md +1 -1
- package/agents/ctx-concerns-mapper.md +1 -1
- package/agents/ctx-quality-mapper.md +1 -1
- package/agents/ctx-tech-mapper.md +1 -1
- package/commands/ctx.md +66 -513
- package/commands/init.md +505 -233
- package/commands/map-codebase.md +55 -156
- package/package.json +3 -2
- package/src/install.js +8 -0
- package/workflows/ctx-router.md +241 -0
- package/workflows/map-codebase.md +329 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx-concerns-mapper
|
|
3
3
|
description: Concerns mapper for CTX 3.0. Analyzes security vulnerabilities, tech debt, performance issues, and risks. Part of parallel codebase mapping.
|
|
4
|
-
tools: Read, Bash, Glob, Grep
|
|
4
|
+
tools: Read, Write, Bash, Glob, Grep
|
|
5
5
|
color: red
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx-quality-mapper
|
|
3
3
|
description: Quality mapper for CTX 3.0. Analyzes test coverage, lint status, type safety, and code smells. Part of parallel codebase mapping.
|
|
4
|
-
tools: Read, Bash, Glob, Grep
|
|
4
|
+
tools: Read, Write, Bash, Glob, Grep
|
|
5
5
|
color: green
|
|
6
6
|
---
|
|
7
7
|
|
package/commands/ctx.md
CHANGED
|
@@ -1,525 +1,78 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx
|
|
3
|
-
description: Smart router - understands natural language, detects intent, and
|
|
3
|
+
description: Smart router - understands natural language, detects intent, and routes to the right workflow.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Bash
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
10
|
+
- Task
|
|
11
|
+
- TaskOutput
|
|
12
|
+
- AskUserQuestion
|
|
13
|
+
- mcp__arguseek__research_iteratively
|
|
14
|
+
- mcp__arguseek__fetch_url
|
|
4
15
|
---
|
|
5
16
|
|
|
6
17
|
<objective>
|
|
7
18
|
CTX Smart Router - Conversational-first workflow orchestration.
|
|
8
19
|
|
|
9
|
-
**Users don't need to know commands.** They
|
|
20
|
+
**Users don't need to know commands.** They describe what they want, CTX routes automatically.
|
|
10
21
|
|
|
11
22
|
```
|
|
12
|
-
User: "I want to build a todo app"
|
|
13
|
-
User: "Fix the login bug"
|
|
14
|
-
User: "
|
|
15
|
-
User: "What should I do next?"
|
|
23
|
+
User: "I want to build a todo app" -> Routes to init
|
|
24
|
+
User: "Fix the login bug" -> Routes to debug
|
|
25
|
+
User: "Study the codebase" -> Routes to map-codebase
|
|
26
|
+
User: "What should I do next?" -> Shows status + routes
|
|
16
27
|
```
|
|
17
28
|
</objective>
|
|
18
29
|
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
| "
|
|
40
|
-
| "
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// Analyze/study signals
|
|
69
|
-
if (msg.match(/\b(study|analyze|understand|learn|explore|what is this)\b/)) {
|
|
70
|
-
return 'analyze';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Improve signals
|
|
74
|
-
if (msg.match(/\b(improve|optimize|better|enhance|upgrade|refactor)\b/)) {
|
|
75
|
-
return 'improve';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Review signals
|
|
79
|
-
if (msg.match(/\b(review|audit|security|ready|before deploy)\b/)) {
|
|
80
|
-
return 'review';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Ship signals
|
|
84
|
-
if (msg.match(/\b(deploy|ship|publish|release|push|launch)\b/)) {
|
|
85
|
-
return 'ship';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Status signals
|
|
89
|
-
if (msg.match(/\b(status|progress|where|what.?s next|current)\b/)) {
|
|
90
|
-
return 'status';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Help signals
|
|
94
|
-
if (msg.match(/\b(help|how|what can|commands|guide)\b/)) {
|
|
95
|
-
return 'help';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Continue signals (or no clear intent)
|
|
99
|
-
return 'continue';
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Step 1: Check Project State
|
|
104
|
-
|
|
105
|
-
Check if `.ctx/` folder exists:
|
|
106
|
-
|
|
107
|
-
### If NO `.ctx/` folder (New User)
|
|
108
|
-
|
|
109
|
-
Based on detected intent:
|
|
110
|
-
|
|
111
|
-
| Intent | Action |
|
|
112
|
-
|--------|--------|
|
|
113
|
-
| `new-project` | "Let's set up your project!" → Run /ctx:init flow |
|
|
114
|
-
| `debug` | "Let me understand the codebase first." → Run /ctx:map → /ctx:debug |
|
|
115
|
-
| `qa` | "I'll analyze the project first." → Run /ctx:map → /ctx:qa |
|
|
116
|
-
| `production-ready` | "I'll audit everything and make it production ready." → Full pipeline below |
|
|
117
|
-
| `analyze` | "Let me study this codebase." → Run /ctx:map-codebase |
|
|
118
|
-
| `improve` | "I'll analyze and suggest improvements." → Run /ctx:map → analyze → suggest |
|
|
119
|
-
| `continue` | Guide user: "What would you like to do with this project?" |
|
|
120
|
-
| `help` | Show quick start guide |
|
|
121
|
-
|
|
122
|
-
### Production-Ready Pipeline
|
|
123
|
-
|
|
124
|
-
When user says "make it production ready":
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
1. /ctx:map-codebase → Deep analysis (4 parallel agents)
|
|
128
|
-
2. /ctx:qa → Full system QA (WCAG 2.1 AA)
|
|
129
|
-
3. Security audit → Check for vulnerabilities
|
|
130
|
-
4. Performance check → Find slow requests, large assets
|
|
131
|
-
5. Create fix tasks → Prioritized by severity
|
|
132
|
-
6. Execute fixes → With verification loop
|
|
133
|
-
7. Final verification → Three-level check
|
|
134
|
-
8. Report → Production readiness score
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Output:
|
|
138
|
-
```
|
|
139
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
140
|
-
PRODUCTION READINESS AUDIT
|
|
141
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
142
|
-
|
|
143
|
-
Codebase Analysis: ✓ Complete
|
|
144
|
-
├── Tech: React 18, Node.js, PostgreSQL
|
|
145
|
-
├── Architecture: Clean, well-structured
|
|
146
|
-
├── Quality: 78% test coverage
|
|
147
|
-
└── Concerns: 3 security issues, 5 performance issues
|
|
148
|
-
|
|
149
|
-
Full QA: ✓ Complete
|
|
150
|
-
├── Pages tested: 24
|
|
151
|
-
├── WCAG 2.1 AA: 92% compliant
|
|
152
|
-
├── Issues found: 12
|
|
153
|
-
└── Critical: 2
|
|
154
|
-
|
|
155
|
-
Security Audit: ⚠ Issues Found
|
|
156
|
-
├── SQL injection risk: 1
|
|
157
|
-
├── XSS vulnerability: 1
|
|
158
|
-
└── Exposed secrets: 1
|
|
159
|
-
|
|
160
|
-
Performance: ⚠ Issues Found
|
|
161
|
-
├── Slow API calls: 3
|
|
162
|
-
├── Large assets: 2
|
|
163
|
-
└── Missing caching: Yes
|
|
164
|
-
|
|
165
|
-
Fix Tasks Created: 8
|
|
166
|
-
├── Critical: 3 (security)
|
|
167
|
-
├── High: 5 (performance, a11y)
|
|
168
|
-
└── Medium: 4
|
|
169
|
-
|
|
170
|
-
Ready to fix? [Y] Fix all [C] Critical only [R] Review first
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**Output for new users:**
|
|
174
|
-
```
|
|
175
|
-
[CTX] Welcome! I see this is a new project.
|
|
176
|
-
|
|
177
|
-
Based on your request, I'll help you {{detected_action}}.
|
|
178
|
-
|
|
179
|
-
{{guided_next_step}}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### If `.ctx/` folder EXISTS
|
|
183
|
-
|
|
184
|
-
Load configuration and state:
|
|
185
|
-
- Read `.ctx/config.json` for profile settings
|
|
186
|
-
- Read `.ctx/STATE.md` for current status
|
|
187
|
-
- Check `.ctx/REPO-MAP.md` for codebase understanding
|
|
188
|
-
|
|
189
|
-
## Step 2: Route Based on Intent + State
|
|
190
|
-
|
|
191
|
-
Combine detected intent with current state:
|
|
192
|
-
|
|
193
|
-
| Intent | State | Action |
|
|
194
|
-
|--------|-------|--------|
|
|
195
|
-
| `new-project` | any | Warn if project exists, offer to add story |
|
|
196
|
-
| `debug` | any | Route to /ctx:debug |
|
|
197
|
-
| `qa` | any | Route to /ctx:qa |
|
|
198
|
-
| `production-ready` | any | Run full production-ready pipeline |
|
|
199
|
-
| `analyze` | any | Route to /ctx:map-codebase |
|
|
200
|
-
| `improve` | any | Analyze → suggest improvements → create stories |
|
|
201
|
-
| `status` | any | Show STATE.md summary |
|
|
202
|
-
| `continue` | initializing | Run research phase |
|
|
203
|
-
| `continue` | discussing | Run discussion phase |
|
|
204
|
-
| `continue` | executing | Execute current task |
|
|
205
|
-
| `continue` | debugging | Resume debug session |
|
|
206
|
-
| `continue` | verifying | Run verification |
|
|
207
|
-
| `continue` | paused | Resume from checkpoint |
|
|
208
|
-
|
|
209
|
-
## Step 3: Load Configuration
|
|
210
|
-
|
|
211
|
-
Read `.ctx/config.json` for:
|
|
212
|
-
- Active profile (quality/balanced/budget)
|
|
213
|
-
- Model routing table
|
|
214
|
-
- Git settings (autoCommit, commitPerTask)
|
|
215
|
-
- Integration settings
|
|
216
|
-
|
|
217
|
-
If config.json doesn't exist:
|
|
218
|
-
- Copy from templates/config.json
|
|
219
|
-
- Set balanced as default profile
|
|
220
|
-
|
|
221
|
-
## Step 4: Execute Routed Action
|
|
222
|
-
|
|
223
|
-
Based on routing decision from Step 2:
|
|
224
|
-
|
|
225
|
-
### If status = "initializing"
|
|
226
|
-
Route to: **Research Phase**
|
|
227
|
-
1. Check if REPO-MAP exists, if not run ctx-mapper
|
|
228
|
-
2. Use ArguSeek to research the project goal
|
|
229
|
-
3. Create atomic plan (2-3 tasks max)
|
|
230
|
-
4. Update STATE.md with plan
|
|
231
|
-
5. Set status = "discussing"
|
|
232
|
-
|
|
233
|
-
### If status = "discussing"
|
|
234
|
-
Route to: **Discussion Phase**
|
|
235
|
-
1. Spawn ctx-discusser agent
|
|
236
|
-
2. Ask targeted questions about gray areas
|
|
237
|
-
3. Lock decisions in CONTEXT.md
|
|
238
|
-
4. Set status = "executing"
|
|
239
|
-
|
|
240
|
-
### If status = "executing"
|
|
241
|
-
Route to: **Execute Current Task**
|
|
242
|
-
1. Read current task from STATE.md
|
|
243
|
-
2. Load REPO-MAP for context
|
|
244
|
-
3. Spawn ctx-executor agent (uses git-native workflow)
|
|
245
|
-
4. Execute task with deviation handling:
|
|
246
|
-
- Auto-fix: bugs, validation, deps (95%)
|
|
247
|
-
- Ask user: architecture decisions only (5%)
|
|
248
|
-
5. After task:
|
|
249
|
-
- Run verification (build, tests, lint)
|
|
250
|
-
- Auto-commit if config allows
|
|
251
|
-
- If passes: mark done, update STATE.md
|
|
252
|
-
- If fails: set status = "debugging"
|
|
253
|
-
|
|
254
|
-
### If status = "debugging"
|
|
255
|
-
Route to: **Persistent Debug Loop**
|
|
256
|
-
1. Spawn ctx-debugger agent
|
|
257
|
-
2. Check for existing debug session (resume if exists)
|
|
258
|
-
3. Loop until fixed (max 10 attempts):
|
|
259
|
-
- Analyze error
|
|
260
|
-
- Form hypothesis
|
|
261
|
-
- Apply fix
|
|
262
|
-
- Verify (build + tests + browser if UI)
|
|
263
|
-
- Record in persistent state
|
|
264
|
-
- Take screenshot proof if browser test
|
|
265
|
-
4. If fixed: set status = "executing", continue
|
|
266
|
-
5. If max attempts: escalate with full report
|
|
267
|
-
|
|
268
|
-
### If status = "verifying"
|
|
269
|
-
Route to: **Three-Level Verification**
|
|
270
|
-
1. Spawn ctx-verifier agent
|
|
271
|
-
2. Check all artifacts:
|
|
272
|
-
- Level 1: Exists (file on disk?)
|
|
273
|
-
- Level 2: Substantive (real code, not stub?)
|
|
274
|
-
- Level 3: Wired (imported and used?)
|
|
275
|
-
3. Scan for anti-patterns (TODO, empty catch, placeholders)
|
|
276
|
-
4. Browser verification (if UI)
|
|
277
|
-
5. **DELIVERY GUARANTEE:**
|
|
278
|
-
- If ALL pass: complete phase → COMPLETE
|
|
279
|
-
- If ANY fail: set status = "debugging" → fix → verify again
|
|
280
|
-
- Loop until 100% working or max attempts
|
|
281
|
-
- NEVER mark complete with failures
|
|
282
|
-
|
|
283
|
-
### If status = "paused"
|
|
284
|
-
Route to: **Resume**
|
|
285
|
-
1. Read checkpoint from `.ctx/checkpoints/`
|
|
286
|
-
2. Restore context (~2.5k tokens)
|
|
287
|
-
3. Set status to previous state
|
|
288
|
-
4. Continue workflow
|
|
289
|
-
|
|
290
|
-
## Step 5: Model Selection
|
|
291
|
-
|
|
292
|
-
Based on current action and active profile:
|
|
293
|
-
|
|
294
|
-
| Action | quality | balanced | budget |
|
|
295
|
-
|--------|---------|----------|--------|
|
|
296
|
-
| Research | opus | opus | sonnet |
|
|
297
|
-
| Discussion | opus | sonnet | sonnet |
|
|
298
|
-
| Planning | opus | opus | sonnet |
|
|
299
|
-
| Execution | opus | sonnet | sonnet |
|
|
300
|
-
| Debugging | opus | sonnet | sonnet |
|
|
301
|
-
| Verification | sonnet | haiku | haiku |
|
|
302
|
-
| Mapping | sonnet | haiku | haiku |
|
|
303
|
-
|
|
304
|
-
Use Task tool with `model` parameter from routing table.
|
|
305
|
-
|
|
306
|
-
## Step 6: Context Budget Check
|
|
307
|
-
|
|
308
|
-
After every action:
|
|
309
|
-
- Calculate context usage
|
|
310
|
-
- If > 40%: Prepare handoff notes
|
|
311
|
-
- If > 50%: Auto-checkpoint, warn user
|
|
312
|
-
- If > 60%: Create HANDOFF.md, spawn fresh agent
|
|
313
|
-
- If > 70%: Force checkpoint
|
|
314
|
-
|
|
315
|
-
## Step 7: Git-Native Commit
|
|
316
|
-
|
|
317
|
-
If task completed successfully AND config.git.autoCommit = true:
|
|
318
|
-
1. Stage modified files
|
|
319
|
-
2. Create commit with CTX format
|
|
320
|
-
3. Record commit hash in STATE.md
|
|
321
|
-
|
|
322
|
-
## Step 8: Update State
|
|
323
|
-
|
|
324
|
-
Always update STATE.md after any action:
|
|
325
|
-
- Current status
|
|
326
|
-
- Progress
|
|
327
|
-
- Recent commits
|
|
328
|
-
- Recent decisions
|
|
329
|
-
- Next action
|
|
330
|
-
- Context usage
|
|
331
|
-
</workflow>
|
|
332
|
-
|
|
333
|
-
<state_transitions>
|
|
334
|
-
```
|
|
335
|
-
initializing → discussing (after research)
|
|
336
|
-
discussing → executing (after decisions locked)
|
|
337
|
-
executing → debugging (if verification fails)
|
|
338
|
-
executing → verifying (if all tasks done)
|
|
339
|
-
debugging → executing (if fix works)
|
|
340
|
-
debugging → ESCALATE (if max attempts fail)
|
|
341
|
-
verifying → debugging (if any check fails) ← LOOP BACK
|
|
342
|
-
verifying → COMPLETE (if ALL pass 100%) ← ONLY EXIT
|
|
343
|
-
paused → (previous state)
|
|
344
|
-
|
|
345
|
-
DELIVERY GUARANTEE LOOP:
|
|
346
|
-
verifying ←→ debugging ←→ executing
|
|
347
|
-
↓
|
|
348
|
-
COMPLETE (only when 100% verified)
|
|
349
|
-
```
|
|
350
|
-
</state_transitions>
|
|
351
|
-
|
|
352
|
-
<new_commands>
|
|
353
|
-
## New in CTX 3.0
|
|
354
|
-
|
|
355
|
-
| Command | Purpose |
|
|
356
|
-
|---------|---------|
|
|
357
|
-
| `/ctx map` | Build repository map (REPO-MAP.md) |
|
|
358
|
-
| `/ctx map-codebase` | Deep codebase analysis (4 parallel agents) |
|
|
359
|
-
| `/ctx discuss [story]` | Run discussion phase for story |
|
|
360
|
-
| `/ctx profile [name]` | Switch model profile |
|
|
361
|
-
| `/ctx debug --resume` | Resume previous debug session |
|
|
362
|
-
</new_commands>
|
|
363
|
-
|
|
364
|
-
<context_budget>
|
|
365
|
-
| Usage | Quality | Action |
|
|
366
|
-
|-------|---------|--------|
|
|
367
|
-
| 0-30% | Peak | Continue |
|
|
368
|
-
| 30-40% | Good | Continue |
|
|
369
|
-
| 40-50% | Good | Prepare handoff |
|
|
370
|
-
| 50-60% | Degrading | Auto-checkpoint |
|
|
371
|
-
| 60-70% | Degrading | Create HANDOFF.md |
|
|
372
|
-
| 70%+ | Poor | Force checkpoint |
|
|
373
|
-
</context_budget>
|
|
374
|
-
|
|
375
|
-
<output_format>
|
|
376
|
-
|
|
377
|
-
## For New Users (no .ctx/ folder)
|
|
378
|
-
|
|
379
|
-
```
|
|
380
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
381
|
-
Welcome to CTX!
|
|
382
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
383
|
-
|
|
384
|
-
I understood: "{{user_request}}"
|
|
385
|
-
|
|
386
|
-
{{intent_response}}
|
|
387
|
-
|
|
388
|
-
{{guided_action}}
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
**Intent Responses:**
|
|
392
|
-
|
|
393
|
-
| Intent | Response |
|
|
394
|
-
|--------|----------|
|
|
395
|
-
| new-project | "You want to build something new. Let's set it up!" |
|
|
396
|
-
| debug | "You need to fix something. Let me understand the codebase first." |
|
|
397
|
-
| qa | "You want to test the system. I'll analyze the project first." |
|
|
398
|
-
| status | "This is a new project. Would you like to start building?" |
|
|
399
|
-
| help | (Show quick start guide) |
|
|
400
|
-
|
|
401
|
-
## For Existing Projects
|
|
402
|
-
|
|
403
|
-
```
|
|
404
|
-
[CTX] Status: {{status}}
|
|
405
|
-
[CTX] Profile: {{profile}} ({{costTier}})
|
|
406
|
-
[CTX] Action: {{action_taken}}
|
|
407
|
-
[CTX] Commit: {{commit_hash}} (if auto-committed)
|
|
408
|
-
[CTX] Next: {{next_action}}
|
|
409
|
-
[CTX] Context: {{percent}}% ({{quality}})
|
|
410
|
-
|
|
411
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
412
|
-
To continue with CTX, run: /ctx
|
|
413
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
## CRITICAL: Continuation Reminder
|
|
417
|
-
|
|
418
|
-
**ALWAYS end every CTX response with this footer:**
|
|
419
|
-
|
|
420
|
-
```
|
|
421
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
422
|
-
To continue with CTX, run: /ctx
|
|
423
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
This is essential because CTX commands only run for one turn. Without this reminder, users will continue chatting without CTX tracking their work.
|
|
427
|
-
|
|
428
|
-
## Guided Prompts (When Intent Unclear)
|
|
429
|
-
|
|
430
|
-
If user's intent is ambiguous, ask:
|
|
431
|
-
|
|
432
|
-
```
|
|
433
|
-
I'm not sure what you'd like to do. Here are your options:
|
|
434
|
-
|
|
435
|
-
"Build something new" → I'll help you start a project
|
|
436
|
-
"Fix a bug" → I'll debug the issue
|
|
437
|
-
"Test the app" → I'll run full QA
|
|
438
|
-
"Show status" → I'll show current progress
|
|
439
|
-
|
|
440
|
-
What would you like to do?
|
|
441
|
-
```
|
|
442
|
-
</output_format>
|
|
443
|
-
|
|
444
|
-
<examples>
|
|
445
|
-
|
|
446
|
-
## Example Conversations
|
|
447
|
-
|
|
448
|
-
### New User - Build Intent
|
|
449
|
-
```
|
|
450
|
-
User: "I want to build a todo app with React"
|
|
451
|
-
|
|
452
|
-
CTX: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
453
|
-
Welcome to CTX!
|
|
454
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
455
|
-
|
|
456
|
-
I understood: "build a todo app with React"
|
|
457
|
-
|
|
458
|
-
You want to build something new. Let's set it up!
|
|
459
|
-
|
|
460
|
-
I'll now:
|
|
461
|
-
1. Create your project structure
|
|
462
|
-
2. Research best practices for React todo apps
|
|
463
|
-
3. Create a plan with clear milestones
|
|
464
|
-
|
|
465
|
-
[Starting project setup...]
|
|
466
|
-
|
|
467
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
468
|
-
To continue with CTX, run: /ctx
|
|
469
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
### New User - Fix Intent
|
|
473
|
-
```
|
|
474
|
-
User: "The login is broken"
|
|
475
|
-
|
|
476
|
-
CTX: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
477
|
-
Welcome to CTX!
|
|
478
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
479
|
-
|
|
480
|
-
I understood: "login is broken"
|
|
481
|
-
|
|
482
|
-
You need to fix something. Let me understand the codebase first.
|
|
483
|
-
|
|
484
|
-
I'll now:
|
|
485
|
-
1. Map your codebase structure
|
|
486
|
-
2. Find the login-related code
|
|
487
|
-
3. Start debugging
|
|
488
|
-
|
|
489
|
-
[Analyzing codebase...]
|
|
490
|
-
|
|
491
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
492
|
-
To continue with CTX, run: /ctx
|
|
493
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
### Existing Project - Continue
|
|
497
|
-
```
|
|
498
|
-
User: "continue"
|
|
499
|
-
|
|
500
|
-
CTX: [CTX] Status: executing
|
|
501
|
-
[CTX] Profile: balanced (1x cost)
|
|
502
|
-
[CTX] Story: S002 - User Authentication
|
|
503
|
-
[CTX] Task: 2/3 - Implement login form validation
|
|
504
|
-
[CTX] Action: Executing task...
|
|
505
|
-
|
|
506
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
507
|
-
To continue with CTX, run: /ctx
|
|
508
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
### Existing Project - QA Intent
|
|
512
|
-
```
|
|
513
|
-
User: "is the app accessible?"
|
|
514
|
-
|
|
515
|
-
CTX: [CTX] Detected: QA request (accessibility)
|
|
516
|
-
[CTX] Routing to: /ctx:qa --a11y-only
|
|
517
|
-
|
|
518
|
-
Running WCAG 2.1 AA accessibility audit...
|
|
519
|
-
|
|
520
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
521
|
-
To continue with CTX, run: /ctx
|
|
522
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
</examples>
|
|
30
|
+
<execution_context>
|
|
31
|
+
@~/.claude/ctx/workflows/ctx-router.md
|
|
32
|
+
</execution_context>
|
|
33
|
+
|
|
34
|
+
<process>
|
|
35
|
+
1. Check if .ctx/ exists (bash: test -d .ctx)
|
|
36
|
+
2. Detect intent from user message
|
|
37
|
+
3. Route based on intent + ctx state:
|
|
38
|
+
- No .ctx/ + "build/create" -> /ctx:init
|
|
39
|
+
- No .ctx/ + "study/analyze" -> spawn 4 mapper agents in parallel
|
|
40
|
+
- No .ctx/ + "debug/fix" -> map codebase first, then debug
|
|
41
|
+
- Has .ctx/ + any intent -> load state, route accordingly
|
|
42
|
+
4. Spawn appropriate agents with Task()
|
|
43
|
+
5. Update STATE.md
|
|
44
|
+
6. Show "Next Up" with clear next action
|
|
45
|
+
</process>
|
|
46
|
+
|
|
47
|
+
<intent_patterns>
|
|
48
|
+
| Pattern | Intent | Route |
|
|
49
|
+
|---------|--------|-------|
|
|
50
|
+
| "build", "create", "make", "start new" | new-project | /ctx:init |
|
|
51
|
+
| "fix", "bug", "broken", "error", "crash" | debug | Debug flow |
|
|
52
|
+
| "test", "QA", "check", "accessible" | qa | QA flow |
|
|
53
|
+
| "study", "analyze", "understand", "explore" | analyze | Map codebase |
|
|
54
|
+
| "improve", "optimize", "refactor" | improve | Analyze + suggest |
|
|
55
|
+
| "status", "progress", "what's next" | status | Show status |
|
|
56
|
+
| "help", "how", "commands" | help | Show help |
|
|
57
|
+
| "continue", "next", "go" | continue | Read STATE.md |
|
|
58
|
+
</intent_patterns>
|
|
59
|
+
|
|
60
|
+
<model_routing>
|
|
61
|
+
Based on config.json profile, use these models for Task() calls:
|
|
62
|
+
|
|
63
|
+
| Agent | quality | balanced | budget |
|
|
64
|
+
|-------|---------|----------|--------|
|
|
65
|
+
| Mappers | sonnet | haiku | haiku |
|
|
66
|
+
| Debugger | opus | sonnet | sonnet |
|
|
67
|
+
| QA | sonnet | sonnet | haiku |
|
|
68
|
+
| Executor | opus | sonnet | sonnet |
|
|
69
|
+
</model_routing>
|
|
70
|
+
|
|
71
|
+
<success_criteria>
|
|
72
|
+
- [ ] Intent detected from user message
|
|
73
|
+
- [ ] Correct flow routed
|
|
74
|
+
- [ ] ArguSeek called for research (when applicable)
|
|
75
|
+
- [ ] Task() agents spawned with full context
|
|
76
|
+
- [ ] STATE.md updated after each action
|
|
77
|
+
- [ ] Clear "Next Up" shown
|
|
78
|
+
</success_criteria>
|