ctx-cc 3.4.2 → 3.4.4

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/commands/ctx.md CHANGED
@@ -12,67 +12,238 @@ allowed-tools:
12
12
  - AskUserQuestion
13
13
  - mcp__arguseek__research_iteratively
14
14
  - mcp__arguseek__fetch_url
15
+ - mcp__playwright__browser_navigate
16
+ - mcp__playwright__browser_snapshot
17
+ - mcp__playwright__browser_type
18
+ - mcp__playwright__browser_click
15
19
  ---
16
20
 
17
- <objective>
18
- CTX Smart Router - Conversational-first workflow orchestration.
19
-
20
- **Users don't need to know commands.** They describe what they want, CTX routes automatically.
21
-
22
- ```
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
27
- ```
28
- </objective>
29
-
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>
21
+ # CTX Smart Router
22
+
23
+ You MUST follow these instructions exactly. This is not documentation - these are commands to execute.
24
+
25
+ ## Step 1: Check CTX Structure
26
+
27
+ Execute this bash command RIGHT NOW:
28
+
29
+ ```bash
30
+ test -d .ctx && echo "CTX_EXISTS" || echo "CTX_MISSING"
31
+ ```
32
+
33
+ Store the result.
34
+
35
+ ## Step 2: Detect Intent
36
+
37
+ Parse the user's message. Match against these patterns (check in order):
38
+
39
+ | If message contains... | Intent is... |
40
+ |------------------------|--------------|
41
+ | "study", "analyze", "understand", "explore", "deeply" | ANALYZE |
42
+ | "build", "create", "make", "start", "new" | NEW_PROJECT |
43
+ | "fix", "bug", "broken", "error", "crash" | DEBUG |
44
+ | "test", "QA", "check", "accessible" | QA |
45
+ | "status", "progress", "what's next" | STATUS |
46
+
47
+ ## Step 3: Execute Based on Intent
48
+
49
+ ### If Intent = ANALYZE
50
+
51
+ **3a. Show banner:**
52
+
53
+ ```
54
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
55
+ CTX DEEP STUDY
56
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
57
+ ```
58
+
59
+ **3b. Ask scope using AskUserQuestion tool:**
60
+
61
+ You MUST call the AskUserQuestion tool with these exact parameters:
62
+
63
+ ```json
64
+ {
65
+ "questions": [
66
+ {
67
+ "question": "What type of analysis do you need?",
68
+ "header": "Scope",
69
+ "options": [
70
+ { "label": "Code only", "description": "Analyze codebase structure, patterns, and quality" },
71
+ { "label": "Code + Running app", "description": "Also browse the running application in browser" },
72
+ { "label": "Full system", "description": "Code + App + API testing + Database inspection" }
73
+ ],
74
+ "multiSelect": false
75
+ }
76
+ ]
77
+ }
78
+ ```
79
+
80
+ **3c. If user selected "Code + Running app" or "Full system", ask for credentials:**
81
+
82
+ ```json
83
+ {
84
+ "questions": [
85
+ {
86
+ "question": "Do you have login credentials for the app?",
87
+ "header": "Access",
88
+ "options": [
89
+ { "label": "Yes, I'll provide them", "description": "I have username/password" },
90
+ { "label": "No auth needed", "description": "The app doesn't require login" }
91
+ ],
92
+ "multiSelect": false
93
+ }
94
+ ]
95
+ }
96
+ ```
97
+
98
+ If they'll provide credentials, ask:
99
+ ```
100
+ Please provide login credentials:
101
+ • Username/Email:
102
+ • Password:
103
+ ```
104
+
105
+ **3d. Create directory:**
106
+
107
+ ```bash
108
+ mkdir -p .ctx/codebase
109
+ ```
110
+
111
+ **3e. Show spawning indicator:**
112
+
113
+ ```
114
+ ◆ Spawning 4 mappers in parallel...
115
+ → ctx-tech-mapper
116
+ → ctx-arch-mapper
117
+ → ctx-quality-mapper
118
+ → ctx-concerns-mapper
119
+ ```
120
+
121
+ **3f. SPAWN 4 AGENTS NOW using Task tool:**
122
+
123
+ You MUST call the Task tool 4 times with these EXACT parameters. Call all 4 in a SINGLE message:
124
+
125
+ Task 1:
126
+ - prompt: "Analyze this codebase for technology stack. Write comprehensive analysis to: .ctx/codebase/TECH.md. Include languages, frameworks, dependencies, versions, build tools. Return confirmation with line count when complete."
127
+ - subagent_type: "ctx-tech-mapper"
128
+ - model: "haiku"
129
+ - run_in_background: true
130
+ - description: "Map tech stack"
131
+
132
+ Task 2:
133
+ - prompt: "Analyze this codebase architecture. Write comprehensive analysis to: .ctx/codebase/ARCH.md. Include architectural pattern, layer structure, module boundaries, entry points, data flow. Return confirmation with line count when complete."
134
+ - subagent_type: "ctx-arch-mapper"
135
+ - model: "haiku"
136
+ - run_in_background: true
137
+ - description: "Map architecture"
138
+
139
+ Task 3:
140
+ - prompt: "Analyze this codebase for quality patterns. Write comprehensive analysis to: .ctx/codebase/QUALITY.md. Include test coverage, linting, type safety, documentation, code smells. Return confirmation with line count when complete."
141
+ - subagent_type: "ctx-quality-mapper"
142
+ - model: "haiku"
143
+ - run_in_background: true
144
+ - description: "Map quality"
145
+
146
+ Task 4:
147
+ - prompt: "Analyze this codebase for concerns and risks. Write comprehensive analysis to: .ctx/codebase/CONCERNS.md. Include security issues, technical debt, performance problems, operational risks. Return confirmation with line count when complete."
148
+ - subagent_type: "ctx-concerns-mapper"
149
+ - model: "haiku"
150
+ - run_in_background: true
151
+ - description: "Map concerns"
152
+
153
+ **3g. Wait for all agents using TaskOutput:**
154
+
155
+ After spawning, use TaskOutput tool to wait for each agent to complete. Show progress:
156
+
157
+ ```
158
+ ✓ ctx-tech-mapper complete: TECH.md
159
+ ✓ ctx-arch-mapper complete: ARCH.md
160
+ ✓ ctx-quality-mapper complete: QUALITY.md
161
+ ✓ ctx-concerns-mapper complete: CONCERNS.md
162
+ ```
163
+
164
+ **3h. Verify files exist:**
165
+
166
+ ```bash
167
+ ls -la .ctx/codebase/
168
+ wc -l .ctx/codebase/*.md
169
+ ```
170
+
171
+ **3i. Create summary:**
172
+
173
+ Read all 4 files and create .ctx/codebase/SUMMARY.md with key findings.
174
+
175
+ **3j. If browser testing requested, use Playwright:**
176
+
177
+ Detect app URL:
178
+ ```bash
179
+ grep -r "localhost\|PORT" .env* package.json 2>/dev/null | head -3
180
+ ```
181
+
182
+ Then use mcp__playwright__browser_navigate to open the app, login with provided credentials, and explore.
183
+
184
+ **3k. Show completion:**
185
+
186
+ ```
187
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
188
+ CTX ► MAPPING COMPLETE ✓
189
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
190
+
191
+ ┌─────────────────────────────────────────────────────┐
192
+ │ CODEBASE SUMMARY │
193
+ ├─────────────────────────────────────────────────────┤
194
+ │ Tech: [from TECH.md] │
195
+ │ Architecture: [from ARCH.md] │
196
+ │ Quality: [from QUALITY.md] │
197
+ │ Concerns: [count] identified │
198
+ └─────────────────────────────────────────────────────┘
199
+
200
+ Files: .ctx/codebase/
201
+
202
+ ───────────────────────────────────────────────────────
203
+
204
+ ## ▶ Next Up
205
+
206
+ **Initialize project** — set up CTX workflow
207
+
208
+ `/ctx:init`
209
+
210
+ ───────────────────────────────────────────────────────
211
+ ```
212
+
213
+ ### If Intent = NEW_PROJECT
214
+
215
+ Execute /ctx:init inline.
216
+
217
+ ### If Intent = DEBUG
218
+
219
+ Show banner, map codebase first (same as ANALYZE), then spawn ctx-debugger agent.
220
+
221
+ ### If Intent = STATUS
222
+
223
+ Read .ctx/STATE.md and show status with progress bars.
224
+
225
+ ### If Intent = unknown
226
+
227
+ Show help:
228
+ ```
229
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
230
+ CTX ► WELCOME
231
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
232
+
233
+ What would you like to do?
234
+
235
+ • "Study this codebase" → Deep analysis
236
+ • "Build something new" → Project setup
237
+ • "Fix a bug" → Debug mode
238
+ • "Test the app" → QA testing
239
+
240
+ Just describe what you want!
241
+ ```
242
+
243
+ ## CRITICAL RULES
244
+
245
+ 1. You MUST use the Task tool to spawn agents - do not just describe what should happen
246
+ 2. You MUST use AskUserQuestion for interactive prompts - do not just print questions
247
+ 3. You MUST execute bash commands - do not just show them
248
+ 4. You MUST wait for agents with TaskOutput before proceeding
249
+ 5. You MUST show the CLI banners and boxes exactly as specified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-cc",
3
- "version": "3.4.2",
3
+ "version": "3.4.4",
4
4
  "description": "CTX 3.3 (Continuous Task eXecution) - AI that learns your preferences. Learning system, predictive planning, self-healing deployments (Sentry/LogRocket), voice control for hands-free development.",
5
5
  "keywords": [
6
6
  "claude",
@@ -74,17 +74,116 @@ Execute /ctx:init inline (don't tell user to run it separately).
74
74
  Output:
75
75
  ```
76
76
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
77
- CTX ► ANALYZING CODEBASE
77
+ CTX ► DEEP STUDY
78
78
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
79
79
 
80
80
  I understood: "{{user_request}}"
81
81
 
82
- Let me analyze this codebase with 4 specialized mappers.
82
+ Before I analyze, let me understand the scope.
83
+
84
+ ───────────────────────────────────────────────────────
85
+ ```
86
+
87
+ **Step 0: Gather context with AskUserQuestion**
88
+
89
+ Use the AskUserQuestion tool to ask:
90
+
91
+ ```
92
+ AskUserQuestion({
93
+ questions: [
94
+ {
95
+ question: "What type of analysis do you need?",
96
+ header: "Scope",
97
+ options: [
98
+ { label: "Code only", description: "Analyze codebase structure, patterns, and quality" },
99
+ { label: "Code + Running app", description: "Also browse the running application in browser" },
100
+ { label: "Full system", description: "Code + App + API testing + Database inspection" }
101
+ ],
102
+ multiSelect: false
103
+ },
104
+ {
105
+ question: "Is the application running locally?",
106
+ header: "Environment",
107
+ options: [
108
+ { label: "Yes, running", description: "App is running at localhost or local URL" },
109
+ { label: "Not yet", description: "I'll start it or you can help me start it" },
110
+ { label: "Remote/Staging", description: "App is deployed to a remote environment" }
111
+ ],
112
+ multiSelect: false
113
+ }
114
+ ]
115
+ })
116
+ ```
117
+
118
+ **If user selects "Code + Running app" or "Full system":**
119
+
120
+ Ask for credentials:
121
+ ```
122
+ AskUserQuestion({
123
+ questions: [
124
+ {
125
+ question: "Do you have login credentials for the app?",
126
+ header: "Access",
127
+ options: [
128
+ { label: "Yes, I'll provide them", description: "I have username/password or API keys" },
129
+ { label: "No auth needed", description: "The app doesn't require login" },
130
+ { label: "OAuth/SSO only", description: "Login requires external provider" }
131
+ ],
132
+ multiSelect: false
133
+ }
134
+ ]
135
+ })
136
+ ```
137
+
138
+ **If user will provide credentials:**
139
+
140
+ Output:
141
+ ```
142
+ ╔═══════════════════════════════════════════════════════╗
143
+ ║ LOGIN CREDENTIALS ║
144
+ ╚═══════════════════════════════════════════════════════╝
145
+
146
+ I'll detect the app URL from your config files.
147
+ Please provide login credentials for browser testing:
148
+
149
+ • Username/Email: _______________
150
+ • Password: _______________
151
+
152
+ ───────────────────────────────────────────────────────
153
+ → Paste credentials or type "skip" to analyze code only
154
+ ───────────────────────────────────────────────────────
155
+ ```
156
+
157
+ Store credentials in memory for browser testing (never write to files).
158
+
159
+ **Detect app URL from codebase:**
160
+
161
+ ```bash
162
+ # Check common locations for app URL
163
+ grep -r "localhost\|127.0.0.1" .env* package.json 2>/dev/null | head -5
164
+ grep -r "PORT\|port" .env* package.json 2>/dev/null | head -5
165
+ ```
166
+
167
+ Extract URL like `http://localhost:3000` from config.
168
+
169
+ **Step 1: Show analysis plan**
170
+
171
+ Output:
172
+ ```
173
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
174
+ CTX ► ANALYZING CODEBASE
175
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
176
+
177
+ Analysis scope: {{selected_scope}}
178
+ Environment: {{selected_environment}}
179
+ Access: {{access_level}}
180
+
181
+ Starting analysis with 4 specialized mappers...
83
182
 
84
183
  ───────────────────────────────────────────────────────
85
184
  ```
86
185
 
87
- **Step 1: Create structure**
186
+ **Step 2: Create structure**
88
187
 
89
188
  ```bash
90
189
  mkdir -p .ctx/codebase
@@ -150,7 +249,69 @@ cat .ctx/codebase/CONCERNS.md
150
249
 
151
250
  Write `.ctx/codebase/SUMMARY.md` with key findings from each document.
152
251
 
153
- **Step 7: Show completion banner**
252
+ **Step 7: Browser testing (if scope includes running app)**
253
+
254
+ If user selected "Code + Running app" or "Full system":
255
+
256
+ Output:
257
+ ```
258
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
259
+ CTX ► BROWSER TESTING
260
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
261
+
262
+ Now testing the running application...
263
+
264
+ ───────────────────────────────────────────────────────
265
+ ```
266
+
267
+ Use Playwright MCP tools to:
268
+
269
+ 1. Navigate to app URL:
270
+ ```
271
+ mcp__playwright__browser_navigate({ url: "{{app_url}}" })
272
+ ```
273
+
274
+ 2. Take snapshot of initial state:
275
+ ```
276
+ mcp__playwright__browser_snapshot({})
277
+ ```
278
+
279
+ 3. If credentials provided, log in:
280
+ ```
281
+ mcp__playwright__browser_type({ element: "email/username field", ref: "{{ref}}", text: "{{username}}" })
282
+ mcp__playwright__browser_type({ element: "password field", ref: "{{ref}}", text: "{{password}}" })
283
+ mcp__playwright__browser_click({ element: "login button", ref: "{{ref}}" })
284
+ ```
285
+
286
+ 4. Take snapshot after login:
287
+ ```
288
+ mcp__playwright__browser_snapshot({})
289
+ ```
290
+
291
+ 5. Explore key pages based on codebase analysis:
292
+ - Navigate to pages identified in ARCH.md
293
+ - Take screenshots of main flows
294
+ - Check for console errors
295
+
296
+ 6. Write browser findings to `.ctx/codebase/BROWSER.md`:
297
+ - Pages tested
298
+ - UI issues found
299
+ - Console errors
300
+ - Accessibility observations
301
+ - Screenshots taken
302
+
303
+ Output progress:
304
+ ```
305
+ ◆ Testing application...
306
+ → Navigating to {{app_url}}
307
+ → Logging in as {{username}}
308
+ → Exploring dashboard
309
+ → Checking user flows
310
+
311
+ ✓ Browser testing complete: BROWSER.md ({{N}} lines)
312
+ ```
313
+
314
+ **Step 8: Show completion banner**
154
315
 
155
316
  Output:
156
317
  ```