ctx-cc 2.3.0 → 3.1.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.
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: ctx:map-codebase
3
+ description: Comprehensive codebase analysis using 4 parallel mapper agents. Run before starting a new project on existing code.
4
+ ---
5
+
6
+ <objective>
7
+ Analyze an existing codebase comprehensively using 4 specialized parallel agents.
8
+
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
85
+
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
146
+
147
+ Recommendations:
148
+ 1. Address security issues before new features
149
+ 2. Improve test coverage to 80%
150
+ 3. Refactor auth module
151
+
152
+ Saved to: .ctx/codebase/
153
+
154
+ Next: Run /ctx init to start project with this context
155
+ ```
156
+ </output_format>
157
+
158
+ <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
169
+ </when_to_use>
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: ctx:map
3
+ description: Build or rebuild the repository map for intelligent code understanding
4
+ ---
5
+
6
+ <objective>
7
+ Build a token-optimized map of the codebase that enables all CTX agents to understand project structure, symbols, and dependencies.
8
+
9
+ This is the foundation for intelligent code operations.
10
+ </objective>
11
+
12
+ <usage>
13
+ ```
14
+ /ctx map # Build/rebuild repository map
15
+ /ctx map --expand # Generate expanded map (8k tokens)
16
+ /ctx map --stats # Show map statistics only
17
+ /ctx map --refresh # Force full rebuild (ignore cache)
18
+ ```
19
+ </usage>
20
+
21
+ <workflow>
22
+
23
+ ## Step 1: Check Existing Map
24
+
25
+ Read `.ctx/REPO-MAP.json` if exists:
26
+ - If fresh (< 1 hour old) and no git changes: Skip rebuild, show stats
27
+ - If stale or files changed: Incremental update
28
+ - If `--refresh` flag: Full rebuild
29
+
30
+ Check git for changes:
31
+ ```bash
32
+ git diff --name-only HEAD~10 2>/dev/null || echo "no-git"
33
+ ```
34
+
35
+ ## Step 2: Spawn Mapper Agent
36
+
37
+ Spawn `ctx-mapper` agent to build the map:
38
+ - Pass project root
39
+ - Pass token budget (2000 default, 8000 if --expand)
40
+ - Pass list of changed files (for incremental)
41
+
42
+ ## Step 3: Validate Output
43
+
44
+ Ensure mapper produced:
45
+ - `.ctx/REPO-MAP.json` - Valid JSON
46
+ - `.ctx/REPO-MAP.md` - Non-empty markdown
47
+ - `.ctx/repo-map-cache.json` - Cache file
48
+
49
+ ## Step 4: Report Results
50
+
51
+ </workflow>
52
+
53
+ <output_format>
54
+ ```
55
+ [CTX] Repository Map
56
+
57
+ Project: {{name}}
58
+ Stack: {{stack}}
59
+
60
+ Statistics:
61
+ Files: {{file_count}}
62
+ Symbols: {{symbol_count}}
63
+ Lines: {{line_count}}
64
+ Languages: {{language_breakdown}}
65
+
66
+ Entry Points:
67
+ {{entry_points}}
68
+
69
+ Top Referenced:
70
+ 1. {{symbol}} ({{refs}} refs)
71
+ 2. {{symbol}} ({{refs}} refs)
72
+ 3. {{symbol}} ({{refs}} refs)
73
+
74
+ Map Tokens: {{token_count}}/{{budget}}
75
+ Cache: {{cache_status}}
76
+
77
+ Saved to: .ctx/REPO-MAP.md
78
+ ```
79
+ </output_format>
80
+
81
+ <integration>
82
+ The repository map is automatically:
83
+ - Loaded by ctx-researcher before research
84
+ - Loaded by ctx-planner before planning
85
+ - Loaded by ctx-executor before execution
86
+ - Used to identify relevant files for any task
87
+ - Updated incrementally when files change
88
+ </integration>
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: ctx:profile
3
+ description: Switch between model profiles (quality/balanced/budget) for cost optimization
4
+ ---
5
+
6
+ <objective>
7
+ Switch between pre-configured model profiles to optimize for quality or cost.
8
+
9
+ Profiles control which models are used for each phase of the CTX workflow.
10
+ </objective>
11
+
12
+ <usage>
13
+ ```
14
+ /ctx profile # Show current profile
15
+ /ctx profile quality # Use best models (highest cost)
16
+ /ctx profile balanced # Use balanced models (default)
17
+ /ctx profile budget # Use fastest models (lowest cost)
18
+ ```
19
+ </usage>
20
+
21
+ <profiles>
22
+
23
+ ## Quality Profile
24
+ **Use when**: Critical production code, complex architecture, security-sensitive
25
+
26
+ | Phase | Model | Why |
27
+ |-------|-------|-----|
28
+ | Research | Opus | Deep understanding needed |
29
+ | Discussion | Opus | Nuanced question formulation |
30
+ | Planning | Opus | Best architectural decisions |
31
+ | Execution | Opus | Highest quality code |
32
+ | Debugging | Opus | Complex root cause analysis |
33
+ | Verification | Sonnet | Good enough for checks |
34
+ | Mapping | Sonnet | Reliable parsing |
35
+ | Quick | Sonnet | Still good quality |
36
+
37
+ **Estimated cost**: ~3x balanced profile
38
+
39
+ ## Balanced Profile (Default)
40
+ **Use when**: Most development work, good balance of speed and quality
41
+
42
+ | Phase | Model | Why |
43
+ |-------|-------|-----|
44
+ | Research | Opus | Worth investing in understanding |
45
+ | Discussion | Sonnet | Good enough for questions |
46
+ | Planning | Opus | Worth investing in architecture |
47
+ | Execution | Sonnet | Good code quality |
48
+ | Debugging | Sonnet | Reliable debugging |
49
+ | Verification | Haiku | Fast checks sufficient |
50
+ | Mapping | Haiku | Fast parsing |
51
+ | Quick | Haiku | Speed prioritized |
52
+
53
+ **Estimated cost**: Baseline
54
+
55
+ ## Budget Profile
56
+ **Use when**: Prototyping, learning, non-critical code, cost-sensitive
57
+
58
+ | Phase | Model | Why |
59
+ |-------|-------|-----|
60
+ | Research | Sonnet | Acceptable understanding |
61
+ | Discussion | Sonnet | Good enough |
62
+ | Planning | Sonnet | Acceptable plans |
63
+ | Execution | Sonnet | Decent code |
64
+ | Debugging | Sonnet | Usually works |
65
+ | Verification | Haiku | Fast is fine |
66
+ | Mapping | Haiku | Fast parsing |
67
+ | Quick | Haiku | Maximum speed |
68
+
69
+ **Estimated cost**: ~0.4x balanced profile (60% savings)
70
+
71
+ </profiles>
72
+
73
+ <workflow>
74
+
75
+ ## Step 1: Read Current Config
76
+
77
+ Read `.ctx/config.json`:
78
+ - If doesn't exist: Copy from template, set balanced as default
79
+ - Get current `activeProfile`
80
+
81
+ ## Step 2: Handle Command
82
+
83
+ If no argument:
84
+ - Show current profile and routing table
85
+
86
+ If profile name provided:
87
+ - Validate: must be `quality`, `balanced`, or `budget`
88
+ - Update `activeProfile` in config.json
89
+ - Show new routing table
90
+
91
+ ## Step 3: Update Config
92
+
93
+ Write updated config to `.ctx/config.json`
94
+
95
+ </workflow>
96
+
97
+ <output_format>
98
+ ```
99
+ [CTX] Model Profile: {{profile}}
100
+
101
+ Current Routing:
102
+ Research: {{model}} ({{costTier}})
103
+ Discussion: {{model}} ({{costTier}})
104
+ Planning: {{model}} ({{costTier}})
105
+ Execution: {{model}} ({{costTier}})
106
+ Debugging: {{model}} ({{costTier}})
107
+ Verification: {{model}} ({{costTier}})
108
+ Mapping: {{model}} ({{costTier}})
109
+ Quick: {{model}} ({{costTier}})
110
+
111
+ Estimated Cost: {{multiplier}}x baseline
112
+
113
+ Saved to: .ctx/config.json
114
+ ```
115
+ </output_format>
116
+
117
+ <integration>
118
+ All CTX agents check config.json before spawning subagents:
119
+ 1. Determine task type (research, planning, etc.)
120
+ 2. Look up routing table for model
121
+ 3. Use Task tool with `model` parameter
122
+
123
+ Example:
124
+ ```
125
+ Task(
126
+ prompt: "Research authentication patterns",
127
+ subagent_type: "ctx-researcher",
128
+ model: "opus" // from config routing
129
+ )
130
+ ```
131
+ </integration>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ctx-cc",
3
- "version": "2.3.0",
4
- "description": "CTX 2.3 (Continuous Task eXecution) - PRD-driven, design-first workflow orchestration for Claude Code. WCAG 2.2 AA, W3C tokens, story-verified, debug loop until 100% fixed.",
3
+ "version": "3.1.0",
4
+ "description": "CTX 3.1 (Continuous Task eXecution) - Intelligent workflow orchestration for Claude Code. Task parallelization, pre-commit review, criteria auto-generation, smart handoff, issue tracker sync (Linear/Jira/GitHub).",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "claude-code",
@@ -0,0 +1,210 @@
1
+ {
2
+ "$schema": "https://ctx.dev/schemas/config.json",
3
+ "version": "3.1",
4
+
5
+ "models": {
6
+ "architect": {
7
+ "id": "claude-opus-4",
8
+ "description": "Best reasoning, use for critical decisions",
9
+ "costTier": "high"
10
+ },
11
+ "default": {
12
+ "id": "claude-sonnet-4",
13
+ "description": "Balanced performance and cost",
14
+ "costTier": "medium"
15
+ },
16
+ "fast": {
17
+ "id": "claude-haiku-4",
18
+ "description": "Quick tasks, lower cost",
19
+ "costTier": "low"
20
+ }
21
+ },
22
+
23
+ "routing": {
24
+ "research": "architect",
25
+ "discussion": "default",
26
+ "planning": "architect",
27
+ "execution": "default",
28
+ "debugging": "default",
29
+ "verification": "fast",
30
+ "mapping": "fast",
31
+ "quick": "fast",
32
+ "review": "default",
33
+ "parallelizer": "fast",
34
+ "criteria": "default",
35
+ "handoff": "fast"
36
+ },
37
+
38
+ "profiles": {
39
+ "quality": {
40
+ "description": "Best results, higher cost (~3x)",
41
+ "routing": {
42
+ "research": "architect",
43
+ "discussion": "architect",
44
+ "planning": "architect",
45
+ "execution": "architect",
46
+ "debugging": "architect",
47
+ "verification": "default",
48
+ "mapping": "default",
49
+ "quick": "default",
50
+ "review": "architect",
51
+ "parallelizer": "default",
52
+ "criteria": "architect",
53
+ "handoff": "default"
54
+ }
55
+ },
56
+ "balanced": {
57
+ "description": "Good results, moderate cost (default)",
58
+ "routing": {
59
+ "research": "architect",
60
+ "discussion": "default",
61
+ "planning": "architect",
62
+ "execution": "default",
63
+ "debugging": "default",
64
+ "verification": "fast",
65
+ "mapping": "fast",
66
+ "quick": "fast",
67
+ "review": "default",
68
+ "parallelizer": "fast",
69
+ "criteria": "default",
70
+ "handoff": "fast"
71
+ }
72
+ },
73
+ "budget": {
74
+ "description": "Acceptable results, lowest cost (~0.4x)",
75
+ "routing": {
76
+ "research": "default",
77
+ "discussion": "default",
78
+ "planning": "default",
79
+ "execution": "default",
80
+ "debugging": "default",
81
+ "verification": "fast",
82
+ "mapping": "fast",
83
+ "quick": "fast",
84
+ "review": "fast",
85
+ "parallelizer": "fast",
86
+ "criteria": "fast",
87
+ "handoff": "fast"
88
+ }
89
+ }
90
+ },
91
+
92
+ "activeProfile": "balanced",
93
+
94
+ "git": {
95
+ "autoCommit": true,
96
+ "commitPerTask": true,
97
+ "commitMessageFormat": "[CTX] {title}\n\nStory: {storyId} - {storyTitle}\nCriterion: {criterion}\n\nCo-Authored-By: Claude <noreply@anthropic.com>",
98
+ "signOff": false,
99
+ "gpgSign": false,
100
+ "pushOnComplete": false
101
+ },
102
+
103
+ "context": {
104
+ "mapTokenBudget": 2000,
105
+ "mapTokenBudgetExpanded": 8000,
106
+ "prepareHandoffThreshold": 0.4,
107
+ "checkpointThreshold": 0.5,
108
+ "spawnFreshThreshold": 0.6,
109
+ "forceCheckpointThreshold": 0.7
110
+ },
111
+
112
+ "parallelization": {
113
+ "enabled": true,
114
+ "maxParallelTasks": 3,
115
+ "requireDependencyAnalysis": true,
116
+ "fileLocking": true
117
+ },
118
+
119
+ "review": {
120
+ "enabled": true,
121
+ "beforeCommit": true,
122
+ "blockOnCritical": true,
123
+ "blockOnHigh": true,
124
+ "warnOnMedium": true,
125
+ "autoFix": false,
126
+ "checks": {
127
+ "typeErrors": true,
128
+ "importResolution": true,
129
+ "circularDeps": true,
130
+ "security": true,
131
+ "bestPractices": true,
132
+ "consoleLogs": true,
133
+ "emptyBlocks": true
134
+ }
135
+ },
136
+
137
+ "criteria": {
138
+ "autoSuggest": true,
139
+ "minCriteria": 5,
140
+ "maxCriteria": 15,
141
+ "categories": ["happy_path", "validation", "error_states", "security", "performance"]
142
+ },
143
+
144
+ "debug": {
145
+ "maxAttempts": 10,
146
+ "persistSessions": true,
147
+ "screenshotOnFailure": true,
148
+ "autoResume": true
149
+ },
150
+
151
+ "integrations": {
152
+ "linear": {
153
+ "enabled": false,
154
+ "apiKey": "env:LINEAR_API_KEY",
155
+ "teamId": null,
156
+ "projectId": null,
157
+ "syncOnCreate": true,
158
+ "syncOnVerify": true,
159
+ "closeOnComplete": true,
160
+ "statusMapping": {
161
+ "pending": "Todo",
162
+ "executing": "In Progress",
163
+ "verifying": "In Review",
164
+ "complete": "Done"
165
+ }
166
+ },
167
+ "jira": {
168
+ "enabled": false,
169
+ "baseUrl": null,
170
+ "email": "env:JIRA_EMAIL",
171
+ "apiToken": "env:JIRA_API_TOKEN",
172
+ "projectKey": null,
173
+ "issueType": "Story",
174
+ "syncOnCreate": true,
175
+ "syncOnVerify": true,
176
+ "transitionMapping": {
177
+ "executing": "In Progress",
178
+ "verifying": "In Review",
179
+ "complete": "Done"
180
+ }
181
+ },
182
+ "github": {
183
+ "enabled": false,
184
+ "repository": null,
185
+ "token": "env:GITHUB_TOKEN",
186
+ "syncIssues": true,
187
+ "closeOnComplete": true,
188
+ "createPROnComplete": false,
189
+ "labels": {
190
+ "feature": "enhancement",
191
+ "bug": "bug",
192
+ "design": "design"
193
+ }
194
+ },
195
+ "slack": {
196
+ "enabled": false,
197
+ "webhookUrl": "env:SLACK_WEBHOOK_URL",
198
+ "notifyOnPhaseComplete": false,
199
+ "notifyOnVerifyFail": true,
200
+ "notifyOnHandoff": false
201
+ }
202
+ },
203
+
204
+ "ui": {
205
+ "showTokenUsage": true,
206
+ "showModelInfo": true,
207
+ "showWaveProgress": true,
208
+ "verboseOutput": false
209
+ }
210
+ }