ctx-cc 3.4.0 → 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/commands/ctx.md +33 -622
- 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
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Orchestrate parallel codebase mapper agents to analyze codebase and produce structured documents in .ctx/codebase/
|
|
3
|
+
|
|
4
|
+
Each agent has fresh context, explores a specific focus area, and **writes documents directly**. The orchestrator only receives confirmation + line counts, then writes a summary.
|
|
5
|
+
|
|
6
|
+
Output: .ctx/codebase/ folder with 4 structured documents about the codebase state.
|
|
7
|
+
</purpose>
|
|
8
|
+
|
|
9
|
+
<philosophy>
|
|
10
|
+
**Why dedicated mapper agents:**
|
|
11
|
+
- Fresh context per domain (no token contamination)
|
|
12
|
+
- Agents write documents directly (no context transfer back to orchestrator)
|
|
13
|
+
- Orchestrator only summarizes what was created (minimal context usage)
|
|
14
|
+
- Faster execution (agents run simultaneously)
|
|
15
|
+
|
|
16
|
+
**Document quality over length:**
|
|
17
|
+
Include enough detail to be useful as reference. Prioritize practical examples (especially code patterns) over arbitrary brevity.
|
|
18
|
+
|
|
19
|
+
**Always include file paths:**
|
|
20
|
+
Documents are reference material for Claude when planning/executing. Always include actual file paths formatted with backticks: `src/services/user.ts`.
|
|
21
|
+
</philosophy>
|
|
22
|
+
|
|
23
|
+
<process>
|
|
24
|
+
|
|
25
|
+
<step name="resolve_model_profile" priority="first">
|
|
26
|
+
Read model profile for agent spawning:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
MODEL_PROFILE=$(cat .ctx/config.json 2>/dev/null | grep -o '"profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Default to "balanced" if not set.
|
|
33
|
+
|
|
34
|
+
**Model lookup table:**
|
|
35
|
+
|
|
36
|
+
| Agent | quality | balanced | budget |
|
|
37
|
+
|-------|---------|----------|--------|
|
|
38
|
+
| ctx-*-mapper | sonnet | haiku | haiku |
|
|
39
|
+
|
|
40
|
+
Store resolved model for use in Task calls below.
|
|
41
|
+
</step>
|
|
42
|
+
|
|
43
|
+
<step name="check_existing">
|
|
44
|
+
Check if .ctx/codebase/ already exists:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ls -la .ctx/codebase/ 2>/dev/null
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**If exists:**
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
.ctx/codebase/ already exists with these documents:
|
|
54
|
+
[List files found]
|
|
55
|
+
|
|
56
|
+
What's next?
|
|
57
|
+
1. Refresh - Delete existing and remap codebase
|
|
58
|
+
2. Skip - Use existing codebase map as-is
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Wait for user response.
|
|
62
|
+
|
|
63
|
+
If "Refresh": Delete .ctx/codebase/, continue to create_structure
|
|
64
|
+
If "Skip": Exit workflow
|
|
65
|
+
|
|
66
|
+
**If doesn't exist:**
|
|
67
|
+
Continue to create_structure.
|
|
68
|
+
</step>
|
|
69
|
+
|
|
70
|
+
<step name="create_structure">
|
|
71
|
+
Create .ctx/codebase/ directory:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mkdir -p .ctx/codebase
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Expected output files:**
|
|
78
|
+
- TECH.md (from ctx-tech-mapper)
|
|
79
|
+
- ARCH.md (from ctx-arch-mapper)
|
|
80
|
+
- QUALITY.md (from ctx-quality-mapper)
|
|
81
|
+
- CONCERNS.md (from ctx-concerns-mapper)
|
|
82
|
+
|
|
83
|
+
Continue to spawn_agents.
|
|
84
|
+
</step>
|
|
85
|
+
|
|
86
|
+
<step name="spawn_agents">
|
|
87
|
+
Spawn 4 parallel ctx-*-mapper agents.
|
|
88
|
+
|
|
89
|
+
Use Task tool with the appropriate `subagent_type`, `model="{mapper_model}"`, and `run_in_background=true` for parallel execution.
|
|
90
|
+
|
|
91
|
+
**CRITICAL:** Use the dedicated mapper agents. The mapper agent writes documents directly.
|
|
92
|
+
|
|
93
|
+
**Agent 1: Tech Focus**
|
|
94
|
+
|
|
95
|
+
Task tool parameters:
|
|
96
|
+
```
|
|
97
|
+
subagent_type: "ctx-tech-mapper"
|
|
98
|
+
model: "{mapper_model}"
|
|
99
|
+
run_in_background: true
|
|
100
|
+
description: "Map codebase tech stack"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Prompt:
|
|
104
|
+
```
|
|
105
|
+
Analyze this codebase for technology stack.
|
|
106
|
+
|
|
107
|
+
Write comprehensive analysis to: .ctx/codebase/TECH.md
|
|
108
|
+
|
|
109
|
+
Include:
|
|
110
|
+
- Languages and their proportions
|
|
111
|
+
- Frameworks and libraries
|
|
112
|
+
- Dependencies and versions
|
|
113
|
+
- Build tools and scripts
|
|
114
|
+
- Runtime requirements
|
|
115
|
+
|
|
116
|
+
Return confirmation with line count when complete.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Agent 2: Architecture Focus**
|
|
120
|
+
|
|
121
|
+
Task tool parameters:
|
|
122
|
+
```
|
|
123
|
+
subagent_type: "ctx-arch-mapper"
|
|
124
|
+
model: "{mapper_model}"
|
|
125
|
+
run_in_background: true
|
|
126
|
+
description: "Map codebase architecture"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Prompt:
|
|
130
|
+
```
|
|
131
|
+
Analyze this codebase architecture.
|
|
132
|
+
|
|
133
|
+
Write comprehensive analysis to: .ctx/codebase/ARCH.md
|
|
134
|
+
|
|
135
|
+
Include:
|
|
136
|
+
- Architectural pattern (MVC, hexagonal, etc.)
|
|
137
|
+
- Layer structure
|
|
138
|
+
- Module boundaries
|
|
139
|
+
- Entry points
|
|
140
|
+
- Data flow patterns
|
|
141
|
+
|
|
142
|
+
Return confirmation with line count when complete.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Agent 3: Quality Focus**
|
|
146
|
+
|
|
147
|
+
Task tool parameters:
|
|
148
|
+
```
|
|
149
|
+
subagent_type: "ctx-quality-mapper"
|
|
150
|
+
model: "{mapper_model}"
|
|
151
|
+
run_in_background: true
|
|
152
|
+
description: "Map codebase quality"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Prompt:
|
|
156
|
+
```
|
|
157
|
+
Analyze this codebase for quality patterns.
|
|
158
|
+
|
|
159
|
+
Write comprehensive analysis to: .ctx/codebase/QUALITY.md
|
|
160
|
+
|
|
161
|
+
Include:
|
|
162
|
+
- Test coverage and patterns
|
|
163
|
+
- Linting and formatting status
|
|
164
|
+
- Type safety
|
|
165
|
+
- Documentation coverage
|
|
166
|
+
- Code smells
|
|
167
|
+
|
|
168
|
+
Return confirmation with line count when complete.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Agent 4: Concerns Focus**
|
|
172
|
+
|
|
173
|
+
Task tool parameters:
|
|
174
|
+
```
|
|
175
|
+
subagent_type: "ctx-concerns-mapper"
|
|
176
|
+
model: "{mapper_model}"
|
|
177
|
+
run_in_background: true
|
|
178
|
+
description: "Map codebase concerns"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Prompt:
|
|
182
|
+
```
|
|
183
|
+
Analyze this codebase for concerns and risks.
|
|
184
|
+
|
|
185
|
+
Write comprehensive analysis to: .ctx/codebase/CONCERNS.md
|
|
186
|
+
|
|
187
|
+
Include:
|
|
188
|
+
- Security vulnerabilities
|
|
189
|
+
- Technical debt
|
|
190
|
+
- Performance issues
|
|
191
|
+
- Operational risks
|
|
192
|
+
- Compliance gaps
|
|
193
|
+
|
|
194
|
+
Return confirmation with line count when complete.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Continue to collect_confirmations.
|
|
198
|
+
</step>
|
|
199
|
+
|
|
200
|
+
<step name="collect_confirmations">
|
|
201
|
+
Wait for all 4 agents to complete using TaskOutput.
|
|
202
|
+
|
|
203
|
+
Read each agent's output to collect confirmations.
|
|
204
|
+
|
|
205
|
+
**Expected confirmation format from each agent:**
|
|
206
|
+
```
|
|
207
|
+
## Mapping Complete
|
|
208
|
+
|
|
209
|
+
**Focus:** {focus}
|
|
210
|
+
**Document written:**
|
|
211
|
+
- `.ctx/codebase/{DOC}.md` ({N} lines)
|
|
212
|
+
|
|
213
|
+
Ready for orchestrator summary.
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**What you receive:** Just file paths and line counts. NOT document contents.
|
|
217
|
+
|
|
218
|
+
If any agent failed, note the failure and continue with successful documents.
|
|
219
|
+
|
|
220
|
+
Continue to verify_output.
|
|
221
|
+
</step>
|
|
222
|
+
|
|
223
|
+
<step name="verify_output">
|
|
224
|
+
Verify all documents created successfully:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
ls -la .ctx/codebase/
|
|
228
|
+
wc -l .ctx/codebase/*.md
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Verification checklist:**
|
|
232
|
+
- All 4 documents exist
|
|
233
|
+
- No empty documents (each should have >20 lines)
|
|
234
|
+
|
|
235
|
+
If any documents missing or empty, note which agents may have failed.
|
|
236
|
+
|
|
237
|
+
Continue to create_summary.
|
|
238
|
+
</step>
|
|
239
|
+
|
|
240
|
+
<step name="create_summary">
|
|
241
|
+
Create SUMMARY.md by reading and synthesizing the 4 documents:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Read each document for synthesis
|
|
245
|
+
cat .ctx/codebase/TECH.md
|
|
246
|
+
cat .ctx/codebase/ARCH.md
|
|
247
|
+
cat .ctx/codebase/QUALITY.md
|
|
248
|
+
cat .ctx/codebase/CONCERNS.md
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Write `.ctx/codebase/SUMMARY.md`:
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
# Codebase Summary
|
|
255
|
+
|
|
256
|
+
## Tech Stack
|
|
257
|
+
{Key findings from TECH.md}
|
|
258
|
+
|
|
259
|
+
## Architecture
|
|
260
|
+
{Key findings from ARCH.md}
|
|
261
|
+
|
|
262
|
+
## Quality
|
|
263
|
+
{Key findings from QUALITY.md}
|
|
264
|
+
|
|
265
|
+
## Concerns
|
|
266
|
+
{Top 3-5 concerns from CONCERNS.md}
|
|
267
|
+
|
|
268
|
+
## Recommendations
|
|
269
|
+
1. {Most important action}
|
|
270
|
+
2. {Second priority}
|
|
271
|
+
3. {Third priority}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Continue to offer_next.
|
|
275
|
+
</step>
|
|
276
|
+
|
|
277
|
+
<step name="offer_next">
|
|
278
|
+
Present completion summary and next steps.
|
|
279
|
+
|
|
280
|
+
**Get line counts:**
|
|
281
|
+
```bash
|
|
282
|
+
wc -l .ctx/codebase/*.md
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Output format:**
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
Codebase mapping complete.
|
|
289
|
+
|
|
290
|
+
Created .ctx/codebase/:
|
|
291
|
+
- TECH.md ([N] lines) - Technologies and dependencies
|
|
292
|
+
- ARCH.md ([N] lines) - System design and patterns
|
|
293
|
+
- QUALITY.md ([N] lines) - Code quality assessment
|
|
294
|
+
- CONCERNS.md ([N] lines) - Technical debt and issues
|
|
295
|
+
- SUMMARY.md ([N] lines) - Executive summary
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Next Up
|
|
301
|
+
|
|
302
|
+
**Initialize project** - use codebase context for planning
|
|
303
|
+
|
|
304
|
+
/ctx:init
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
**Also available:**
|
|
309
|
+
- Re-run mapping: /ctx:map-codebase --refresh
|
|
310
|
+
- Review specific file: cat .ctx/codebase/TECH.md
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
End workflow.
|
|
316
|
+
</step>
|
|
317
|
+
|
|
318
|
+
</process>
|
|
319
|
+
|
|
320
|
+
<success_criteria>
|
|
321
|
+
- .ctx/codebase/ directory created
|
|
322
|
+
- 4 parallel mapper agents spawned with run_in_background=true
|
|
323
|
+
- Agents write documents directly (orchestrator doesn't receive document contents)
|
|
324
|
+
- Use TaskOutput to wait for agent completion
|
|
325
|
+
- All 4 codebase documents exist
|
|
326
|
+
- SUMMARY.md created with synthesis
|
|
327
|
+
- Clear completion summary with line counts
|
|
328
|
+
- User offered clear next steps
|
|
329
|
+
</success_criteria>
|