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.
@@ -1,169 +1,68 @@
1
1
  ---
2
2
  name: ctx:map-codebase
3
- description: Comprehensive codebase analysis using 4 parallel mapper agents. Run before starting a new project on existing code.
3
+ description: Analyze codebase with parallel mapper agents to produce .ctx/codebase/ documents
4
+ argument-hint: "[--refresh]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - Write
11
+ - Task
12
+ - TaskOutput
4
13
  ---
5
14
 
6
15
  <objective>
7
- Analyze an existing codebase comprehensively using 4 specialized parallel agents.
16
+ Analyze existing codebase using parallel ctx-*-mapper agents to produce structured codebase documents.
8
17
 
9
- This command is essential for "brownfield" projects where CTX is being added to existing code.
10
- It produces documentation that informs all future planning and execution.
11
- </objective>
12
-
13
- <usage>
14
- ```
15
- /ctx map-codebase # Full analysis with all 4 mappers
16
- /ctx map-codebase --tech # Only tech stack analysis
17
- /ctx map-codebase --arch # Only architecture analysis
18
- /ctx map-codebase --quality # Only quality analysis
19
- /ctx map-codebase --concerns # Only concerns analysis
20
- /ctx map-codebase --refresh # Force re-analysis (ignore cache)
21
- ```
22
- </usage>
23
-
24
- <parallel_agents>
25
-
26
- ## The 4 Mapper Agents
27
-
28
- ```
29
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
30
- │ TECH │ │ ARCH │ │ QUALITY │ │ CONCERNS │
31
- │ MAPPER │ │ MAPPER │ │ MAPPER │ │ MAPPER │
32
- │ │ │ │ │ │ │ │
33
- │ Stack │ │ Patterns │ │ Test cov │ │ Security │
34
- │ Frameworks │ │ Data flow │ │ Lint status │ │ Tech debt │
35
- │ Dependencies│ │ Modules │ │ Type safety │ │ Performance │
36
- │ Versions │ │ Entry pts │ │ Code smells │ │ Risks │
37
- └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
38
- │ │ │ │
39
- ▼ ▼ ▼ ▼
40
- TECH.md ARCH.md QUALITY.md CONCERNS.md
41
- │ │ │ │
42
- └────────────────┴────────────────┴────────────────┘
43
-
44
-
45
- SUMMARY.md
46
- ```
47
-
48
- All 4 agents run in PARALLEL for speed, then results are synthesized.
49
-
50
- </parallel_agents>
51
-
52
- <workflow>
53
-
54
- ## Step 1: Check Prerequisites
55
-
56
- - Ensure we're in a git repository (or at least a code directory)
57
- - Check for existing analysis in `.ctx/codebase/`
58
- - If exists and not `--refresh`: Show cached results
59
-
60
- ## Step 2: Spawn Parallel Mappers
61
-
62
- Spawn all 4 agents simultaneously using Task tool:
63
-
64
- ```
65
- Task(subagent_type="ctx-tech-mapper", prompt="Analyze tech stack...", run_in_background=true)
66
- Task(subagent_type="ctx-arch-mapper", prompt="Analyze architecture...", run_in_background=true)
67
- Task(subagent_type="ctx-quality-mapper", prompt="Analyze quality...", run_in_background=true)
68
- Task(subagent_type="ctx-concerns-mapper", prompt="Analyze concerns...", run_in_background=true)
69
- ```
70
-
71
- ## Step 3: Wait for Completion
72
-
73
- Use TaskOutput to wait for all 4 mappers:
74
- - Each mapper writes its output to `.ctx/codebase/{TYPE}.md`
75
- - Collect results as they complete
76
- - Show progress to user
77
-
78
- ## Step 4: Synthesize Results
79
-
80
- After all mappers complete, create SUMMARY.md:
81
- - Executive summary of findings
82
- - Key metrics
83
- - Recommendations for CTX workflow
84
- - Suggested first phase
18
+ Each mapper agent explores a focus area and **writes documents directly** to `.ctx/codebase/`. The orchestrator only receives confirmations, keeping context usage minimal.
85
19
 
86
- ## Step 5: Update State
87
-
88
- - Create/update `.ctx/codebase/` directory
89
- - Store analysis timestamp
90
- - Link from STATE.md
91
-
92
- </workflow>
93
-
94
- <output_structure>
95
-
96
- ```
97
- .ctx/codebase/
98
- ├── TECH.md # Tech stack analysis
99
- ├── ARCH.md # Architecture analysis
100
- ├── QUALITY.md # Quality metrics
101
- ├── CONCERNS.md # Security, performance, tech debt
102
- ├── SUMMARY.md # Executive summary
103
- └── metadata.json # Analysis timestamp, versions
104
- ```
105
-
106
- </output_structure>
107
-
108
- <output_format>
109
- ```
110
- [CTX] Codebase Analysis
111
-
112
- Spawning 4 parallel mappers...
113
- [■■■■■■■■■■] TECH ✓ 12s
114
- [■■■■■■■■■■] ARCH ✓ 15s
115
- [■■■■■■■■■■] QUALITY ✓ 18s
116
- [■■■■■■■■■■] CONCERNS ✓ 14s
117
-
118
- Synthesizing results...
119
-
120
- ═══════════════════════════════════════════════════════
121
- CODEBASE SUMMARY
122
- ═══════════════════════════════════════════════════════
123
-
124
- Tech Stack:
125
- Language: TypeScript (92%), JavaScript (8%)
126
- Framework: Next.js 14, React 18
127
- Database: PostgreSQL + Prisma
128
- Testing: Jest, Playwright
129
-
130
- Architecture:
131
- Pattern: Monolith with modular structure
132
- Entry: src/app/page.tsx, src/server/index.ts
133
- Modules: 12 feature modules
134
- API Style: REST + Server Actions
135
-
136
- Quality:
137
- Test Coverage: 67%
138
- Type Safety: Strong (strict mode)
139
- Lint Status: 12 warnings, 0 errors
140
- Code Smells: 3 files need attention
141
-
142
- Concerns:
143
- Security: 2 medium issues (see CONCERNS.md)
144
- Performance: N+1 query in users module
145
- Tech Debt: Auth module needs refactor
20
+ Output: .ctx/codebase/ folder with 5 structured documents about the codebase state.
21
+ </objective>
146
22
 
147
- Recommendations:
148
- 1. Address security issues before new features
149
- 2. Improve test coverage to 80%
150
- 3. Refactor auth module
23
+ <execution_context>
24
+ @~/.claude/ctx/workflows/map-codebase.md
25
+ </execution_context>
151
26
 
152
- Saved to: .ctx/codebase/
27
+ <context>
28
+ Flags: $ARGUMENTS (--refresh to force re-analysis)
153
29
 
154
- Next: Run /ctx init to start project with this context
155
- ```
156
- </output_format>
30
+ **This command can run:**
31
+ - Before /ctx:init (brownfield codebases) - creates codebase map first
32
+ - After /ctx:init (greenfield codebases) - updates codebase map as code evolves
33
+ - Anytime to refresh codebase understanding
34
+ </context>
157
35
 
158
36
  <when_to_use>
159
- **Always run before:**
160
- - Adding CTX to an existing codebase
161
- - Starting major refactoring work
162
- - Onboarding to unfamiliar codebase
163
- - Security or quality audit
164
-
165
- **Can skip when:**
166
- - Greenfield project (no existing code)
167
- - Small utility or script
168
- - Analysis already done and code unchanged
37
+ **Use map-codebase for:**
38
+ - Brownfield projects before initialization (understand existing code first)
39
+ - Refreshing codebase map after significant changes
40
+ - Onboarding to an unfamiliar codebase
41
+ - Before major refactoring (understand current state)
42
+
43
+ **Skip map-codebase for:**
44
+ - Greenfield projects with no code yet (nothing to map)
45
+ - Trivial codebases (<5 files)
169
46
  </when_to_use>
47
+
48
+ <process>
49
+ 1. Check if .ctx/codebase/ already exists (offer to refresh or skip)
50
+ 2. Create .ctx/codebase/ directory structure
51
+ 3. Spawn 4 parallel mapper agents:
52
+ - ctx-tech-mapper → writes TECH.md
53
+ - ctx-arch-mapper → writes ARCH.md
54
+ - ctx-quality-mapper → writes QUALITY.md
55
+ - ctx-concerns-mapper → writes CONCERNS.md
56
+ 4. Wait for agents to complete, collect confirmations (NOT document contents)
57
+ 5. Verify all 4 documents exist with line counts
58
+ 6. Create SUMMARY.md with synthesis
59
+ 7. Offer next steps (typically: /ctx:init)
60
+ </process>
61
+
62
+ <success_criteria>
63
+ - [ ] .ctx/codebase/ directory created
64
+ - [ ] All 4 codebase documents written by mapper agents
65
+ - [ ] SUMMARY.md created with key findings
66
+ - [ ] Parallel agents completed without errors
67
+ - [ ] User knows next steps
68
+ </success_criteria>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-cc",
3
- "version": "3.3.8",
3
+ "version": "3.4.1",
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",
@@ -30,7 +30,8 @@
30
30
  "commands/",
31
31
  "agents/",
32
32
  "references/",
33
- "templates/"
33
+ "templates/",
34
+ "workflows/"
34
35
  ],
35
36
  "engines": {
36
37
  "node": ">=18.0.0"
package/src/install.js CHANGED
@@ -162,6 +162,14 @@ export async function install(options) {
162
162
  console.log(green(` ✓`) + ` Installed templates (${count} files)`);
163
163
  }
164
164
 
165
+ // Copy workflows
166
+ const srcWorkflows = path.join(packageRoot, 'workflows');
167
+ const destWorkflows = path.join(ctxDir, 'workflows');
168
+ if (fs.existsSync(srcWorkflows)) {
169
+ const count = copyDir(srcWorkflows, destWorkflows);
170
+ console.log(green(` ✓`) + ` Installed workflows (${count} files)`);
171
+ }
172
+
165
173
  // Write VERSION file
166
174
  fs.writeFileSync(path.join(ctxDir, 'VERSION'), VERSION);
167
175
  console.log(green(` ✓`) + ` Wrote VERSION (${VERSION})`);
@@ -0,0 +1,241 @@
1
+ <purpose>
2
+ Smart router for CTX - understands natural language, detects intent, and routes to the right workflow.
3
+
4
+ Users don't need to memorize commands. They describe what they want, CTX routes automatically.
5
+ </purpose>
6
+
7
+ <intent_detection>
8
+ Parse the user's message to detect intent. Check patterns in order:
9
+
10
+ | Pattern | Intent | Action |
11
+ |---------|--------|--------|
12
+ | "build", "create", "make", "start new", "I want to..." + "app/project/feature" | new-project | Route to init flow |
13
+ | "fix", "bug", "broken", "not working", "error", "crash", "fails" | debug | Route to debug flow |
14
+ | "test", "QA", "check", "accessible", "works?", "validate" | qa | Route to QA flow |
15
+ | "study", "analyze", "understand", "learn", "explore", "what is this", "deeply study" | analyze | Route to map-codebase flow |
16
+ | "improve", "optimize", "better", "enhance", "upgrade", "refactor" | improve | Analyze + suggest improvements |
17
+ | "review", "audit", "security", "ready", "before deploy" | review | Verify flow |
18
+ | "deploy", "ship", "publish", "release", "push", "launch" | ship | Ship flow |
19
+ | "status", "progress", "where", "what's next", "current" | status | Status report |
20
+ | "help", "how", "what can", "commands", "guide" | help | Show help |
21
+ | "continue", "next", "go", "do it" | continue | Read STATE.md and continue |
22
+
23
+ Store detected intent for routing.
24
+ </intent_detection>
25
+
26
+ <process>
27
+
28
+ <step name="verify_ctx_structure" priority="first">
29
+ **MANDATORY FIRST STEP - Execute before anything else:**
30
+
31
+ ```bash
32
+ test -d .ctx && echo "exists" || echo "missing"
33
+ ```
34
+
35
+ Store result:
36
+ - If "exists": CTX is initialized, load state
37
+ - If "missing": CTX not initialized, may need setup
38
+ </step>
39
+
40
+ <step name="detect_intent">
41
+ Parse user message and detect intent using patterns above.
42
+
43
+ Output detected intent for routing decision.
44
+ </step>
45
+
46
+ <step name="route_no_ctx">
47
+ **If NO .ctx/ folder (new user):**
48
+
49
+ Route by detected intent:
50
+
51
+ ### Intent: new-project
52
+
53
+ ```
54
+ Welcome to CTX!
55
+
56
+ I understood: "{{user_request}}"
57
+
58
+ You want to build something new. Let's set it up!
59
+ ```
60
+
61
+ Execute /ctx:init inline (don't tell user to run it separately).
62
+
63
+ ### Intent: analyze (study/explore)
64
+
65
+ ```
66
+ Welcome to CTX!
67
+
68
+ I understood: "{{user_request}}"
69
+
70
+ Let me analyze this codebase first.
71
+ ```
72
+
73
+ **Step 1: Create structure**
74
+
75
+ ```bash
76
+ mkdir -p .ctx/codebase
77
+ ```
78
+
79
+ **Step 2: Spawn 4 mapper agents in parallel**
80
+
81
+ Read model profile (default to "balanced"):
82
+ ```bash
83
+ MODEL_PROFILE="haiku"
84
+ ```
85
+
86
+ Spawn all 4 agents with a SINGLE message containing multiple Task calls:
87
+
88
+ ```
89
+ Task(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.", subagent_type="ctx-tech-mapper", model="haiku", run_in_background=true, description="Map tech stack")
90
+
91
+ Task(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.", subagent_type="ctx-arch-mapper", model="haiku", run_in_background=true, description="Map architecture")
92
+
93
+ Task(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.", subagent_type="ctx-quality-mapper", model="haiku", run_in_background=true, description="Map quality")
94
+
95
+ Task(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.", subagent_type="ctx-concerns-mapper", model="haiku", run_in_background=true, description="Map concerns")
96
+ ```
97
+
98
+ **Step 3: Wait for completion**
99
+
100
+ Use TaskOutput to wait for all 4 agents to complete.
101
+
102
+ **Step 4: Verify output**
103
+
104
+ ```bash
105
+ ls -la .ctx/codebase/
106
+ wc -l .ctx/codebase/*.md
107
+ ```
108
+
109
+ **Step 5: Create summary**
110
+
111
+ Read all 4 documents and create SUMMARY.md:
112
+
113
+ ```bash
114
+ cat .ctx/codebase/TECH.md .ctx/codebase/ARCH.md .ctx/codebase/QUALITY.md .ctx/codebase/CONCERNS.md
115
+ ```
116
+
117
+ Write `.ctx/codebase/SUMMARY.md` with key findings from each document.
118
+
119
+ **Step 6: Report**
120
+
121
+ ```
122
+ [CTX] Codebase Mapped
123
+
124
+ Tech: {{stack}}
125
+ Architecture: {{pattern}}
126
+ Quality: {{assessment}}
127
+ Concerns: {{count}} identified
128
+
129
+ Files: .ctx/codebase/
130
+
131
+ ---
132
+
133
+ Next Up:
134
+
135
+ /ctx:init - Initialize project with this context
136
+
137
+ ---
138
+ ```
139
+
140
+ ### Intent: debug
141
+
142
+ ```
143
+ Welcome to CTX!
144
+
145
+ I understood: "{{problem_description}}"
146
+
147
+ Let me analyze the codebase and investigate.
148
+ ```
149
+
150
+ First map codebase (same as analyze), then spawn debugger agent.
151
+
152
+ ### Intent: help or unknown
153
+
154
+ ```
155
+ Welcome to CTX!
156
+
157
+ What would you like to do?
158
+
159
+ "Build something new" -> I'll set up your project
160
+ "Fix a bug" -> I'll debug the issue
161
+ "Study the codebase" -> I'll analyze everything
162
+ "Test the app" -> I'll run full QA
163
+
164
+ Just describe what you want!
165
+ ```
166
+ </step>
167
+
168
+ <step name="route_with_ctx">
169
+ **If .ctx/ folder EXISTS:**
170
+
171
+ ### Load state first
172
+
173
+ ```bash
174
+ cat .ctx/STATE.md
175
+ cat .ctx/config.json 2>/dev/null || echo "{}"
176
+ ```
177
+
178
+ Extract:
179
+ - `status`: Current workflow status
180
+ - `currentPhase`: Active phase
181
+ - `profile`: Model profile (quality/balanced/budget)
182
+
183
+ ### Route by Intent + State
184
+
185
+ | Intent | Action |
186
+ |--------|--------|
187
+ | new-project | Warn project exists, offer to add phase |
188
+ | analyze | Run map-codebase (refresh) |
189
+ | debug | Spawn debugger with context |
190
+ | qa | Spawn QA agent |
191
+ | status | Show status from STATE.md |
192
+ | continue | Resume from STATE.md status |
193
+
194
+ ### Status Report Format
195
+
196
+ ```
197
+ [CTX] Status
198
+
199
+ Project: {{name}}
200
+ Status: {{status}}
201
+ Profile: {{profile}}
202
+
203
+ Progress: [{{progress_bar}}] {{completed}}/{{total}} phases
204
+
205
+ Current: {{current_phase}}
206
+ Next: {{next_action}}
207
+
208
+ ---
209
+
210
+ To continue: /ctx or describe what you want to do
211
+
212
+ ---
213
+ ```
214
+ </step>
215
+
216
+ </process>
217
+
218
+ <research_integration>
219
+ **When to use ArguSeek:**
220
+
221
+ For debug, improve, and review intents, research BEFORE spawning agents:
222
+
223
+ ```
224
+ mcp__arguseek__research_iteratively({
225
+ query: "{{tech_stack}} {{problem_or_goal}} best practices solutions 2025"
226
+ })
227
+ ```
228
+
229
+ Include research findings in agent prompts.
230
+ </research_integration>
231
+
232
+ <success_criteria>
233
+ - [ ] .ctx structure checked first
234
+ - [ ] Intent detected from user message
235
+ - [ ] Correct flow routed
236
+ - [ ] ArguSeek called for research-worthy intents
237
+ - [ ] Task() agents spawned with full context
238
+ - [ ] STATE.md created/updated
239
+ - [ ] Clear "Next Up" shown
240
+ - [ ] User knows to run /ctx to continue
241
+ </success_criteria>