ctx-cc 2.2.0 → 3.0.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.
package/README.md CHANGED
@@ -1,6 +1,25 @@
1
- # CTX 2.2 - Continuous Task eXecution
1
+ <div align="center">
2
2
 
3
- > Smart workflow orchestration for Claude Code. PRD-driven. 8 commands. Debug loop until 100% fixed.
3
+ # CTX
4
+
5
+ ### Continuous Task eXecution
6
+
7
+ **Production-grade workflow orchestration for Claude Code.**
8
+
9
+ [![npm version](https://img.shields.io/npm/v/ctx-cc.svg?style=flat-square)](https://www.npmjs.com/package/ctx-cc)
10
+ [![npm downloads](https://img.shields.io/npm/dm/ctx-cc.svg?style=flat-square)](https://www.npmjs.com/package/ctx-cc)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
12
+ [![GitHub stars](https://img.shields.io/github/stars/jufjuf/CTX?style=flat-square)](https://github.com/jufjuf/CTX/stargazers)
13
+
14
+ <img src="./assets/terminal.png" alt="CTX Terminal" width="700">
15
+
16
+ **Repository mapping. Discussion phase. Model profiles. Git-native. Persistent debug. Parallel analysis.**
17
+
18
+ [Installation](#installation) · [Quick Start](#quick-start) · [New in 3.0](#new-in-30) · [Commands](#commands) · [Why CTX](#why-ctx)
19
+
20
+ </div>
21
+
22
+ ---
4
23
 
5
24
  ## Installation
6
25
 
@@ -8,59 +27,157 @@
8
27
  npx ctx-cc
9
28
  ```
10
29
 
11
- Options:
30
+ That's it. CTX installs itself to your Claude Code environment.
31
+
12
32
  ```bash
33
+ # Options
13
34
  npx ctx-cc --global # Install to ~/.claude (default)
14
35
  npx ctx-cc --project # Install to .claude in current directory
15
36
  npx ctx-cc --force # Overwrite existing installation
16
37
  ```
17
38
 
18
- ## Why CTX 2.2?
19
-
20
- | Feature | Before | CTX 2.2 |
21
- |---------|--------|---------|
22
- | Requirements | Ad-hoc goals | **PRD.json with stories** |
23
- | Verification | Task-based | **Acceptance criteria** |
24
- | Commands | 12-27 | **8** (organized) |
25
- | Router | Manual | **Smart (auto-routing)** |
26
- | Debug | Manual | **Loop until 100% fixed** |
27
- | Browser Verify | No | **Playwright/DevTools** |
28
- | Planning | Any size | **Atomic (2-3 tasks max)** |
29
- | Resume cost | ~50k tokens | **~2.5k tokens** |
39
+ ---
30
40
 
31
41
  ## Quick Start
32
42
 
33
43
  ```
34
- 1. /ctx init Gather ALL info upfront (requirements + credentials)
35
- 2. /ctx Autonomous execution with minimal interruption
36
- 3. /ctx pause Checkpoint when needed
44
+ 1. /ctx init Gather requirements + credentials + design context
45
+ 2. /ctx map Build repository map (existing codebases)
46
+ 3. /ctx Autonomous execution with minimal interruption
37
47
  ```
38
48
 
39
49
  **The Flow:**
40
50
  ```
41
- /ctx init → Gather everything → /ctx → Autonomous loop → Delivered!
51
+ /ctx init → /ctx map → /ctx → Autonomous loop → Delivered!
42
52
  ```
43
53
 
44
- ## Front-Loaded Approach
54
+ ---
45
55
 
46
- CTX gathers EVERYTHING at initialization:
47
- - **Requirements** → PRD.json stories
48
- - **Acceptance criteria** → How to verify each story
49
- - **Test credentials** → .ctx/.env (gitignored)
50
- - **Constitution** → Rules for autonomous decisions
56
+ ## New in 3.0
51
57
 
52
- Then executes autonomously:
53
- - Only interrupts for architecture decisions (Rule 4)
54
- - Uses stored credentials for browser testing
55
- - Loops through stories until all pass
58
+ ### Repository Mapping (like Aider)
59
+ ```bash
60
+ /ctx map # Build token-optimized codebase map
61
+ /ctx map --expand # Include call graph (8k tokens)
62
+ /ctx map --refresh # Force full rebuild
63
+ ```
56
64
 
57
- ## The 8 Commands
65
+ Creates `REPO-MAP.md` with symbols, dependencies, and navigation hints.
66
+
67
+ ### Discussion Phase (like GSD)
68
+ ```bash
69
+ /ctx discuss S001 # Capture decisions BEFORE planning
70
+ /ctx discuss --review # Review locked decisions
71
+ ```
72
+
73
+ Prevents mid-implementation questions by locking decisions in `CONTEXT.md`.
74
+
75
+ ### Model Profiles (Cost Optimization)
76
+ ```bash
77
+ /ctx profile # Show current profile
78
+ /ctx profile quality # Best models (Opus everywhere)
79
+ /ctx profile balanced # Smart mix (default)
80
+ /ctx profile budget # Fast models (60% savings)
81
+ ```
82
+
83
+ | Profile | Research | Execute | Verify | Cost |
84
+ |---------|----------|---------|--------|------|
85
+ | quality | Opus | Opus | Sonnet | 3x |
86
+ | balanced | Opus | Sonnet | Haiku | 1x |
87
+ | budget | Sonnet | Sonnet | Haiku | 0.4x |
88
+
89
+ ### Git-Native Workflow
90
+ Every completed task auto-commits:
91
+ ```
92
+ [CTX] Implement user login endpoint
93
+
94
+ Story: S001 - User Authentication
95
+ Criteria: User can log in with credentials
96
+ Files: src/auth/login.ts, src/routes/auth.ts
97
+
98
+ Co-Authored-By: Claude <noreply@anthropic.com>
99
+ ```
100
+
101
+ Configure in `.ctx/config.json`:
102
+ ```json
103
+ {
104
+ "git": {
105
+ "autoCommit": true,
106
+ "commitPerTask": true
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### Persistent Debug State
112
+ Debug sessions survive context resets:
113
+ ```bash
114
+ /ctx debug --resume # Continue previous session
115
+ ```
116
+
117
+ State stored in `.ctx/debug/sessions/`:
118
+ - `STATE.json` - Machine-readable progress
119
+ - `TRACE.md` - Human-readable log
120
+ - `hypotheses.json` - All theories tested
121
+ - `screenshots/` - Visual evidence
122
+
123
+ ### Parallel Codebase Analysis
124
+ ```bash
125
+ /ctx map-codebase # Full analysis with 4 parallel agents
126
+ ```
127
+
128
+ Spawns 4 agents simultaneously:
129
+ | Agent | Output | Analyzes |
130
+ |-------|--------|----------|
131
+ | TECH | TECH.md | Languages, frameworks, dependencies |
132
+ | ARCH | ARCH.md | Patterns, data flow, modules |
133
+ | QUALITY | QUALITY.md | Test coverage, lint, type safety |
134
+ | CONCERNS | CONCERNS.md | Security, tech debt, performance |
135
+
136
+ Results synthesized into `SUMMARY.md`.
137
+
138
+ ---
139
+
140
+ ## Why CTX?
141
+
142
+ | Feature | Aider | GSD | CTX 3.0 |
143
+ |---------|-------|-----|---------|
144
+ | Repository Map | Yes | No | **Yes** |
145
+ | Discussion Phase | No | Yes | **Yes** |
146
+ | Model Profiles | Yes | Partial | **Yes** |
147
+ | Git-Native Commits | Yes | No | **Yes** |
148
+ | Persistent Debug | No | Partial | **Yes** |
149
+ | Parallel Analysis | No | Yes | **Yes** |
150
+ | PRD-Driven | No | Yes | **Yes** |
151
+ | Design System | No | No | **Yes** |
152
+ | Browser Verification | No | No | **Yes** |
153
+
154
+ **CTX 3.0 combines the best of Aider and GSD.**
155
+
156
+ ---
157
+
158
+ ## Commands
58
159
 
59
160
  ### Smart (Auto-routing)
60
161
  | Command | Purpose |
61
162
  |---------|---------|
62
163
  | `/ctx` | **Smart router** - reads STATE.md, does the right thing |
63
- | `/ctx init` | Initialize project with STATE.md |
164
+ | `/ctx init` | Initialize project with STATE.md + PRD.json |
165
+
166
+ ### Mapping
167
+ | Command | Purpose |
168
+ |---------|---------|
169
+ | `/ctx map` | Build repository map (REPO-MAP.md) |
170
+ | `/ctx map-codebase` | Deep analysis (4 parallel agents) |
171
+
172
+ ### Discussion
173
+ | Command | Purpose |
174
+ |---------|---------|
175
+ | `/ctx discuss [story]` | Capture decisions before planning |
176
+
177
+ ### Configuration
178
+ | Command | Purpose |
179
+ |---------|---------|
180
+ | `/ctx profile [name]` | Switch model profile (quality/balanced/budget) |
64
181
 
65
182
  ### Inspect (Read-only)
66
183
  | Command | Purpose |
@@ -85,163 +202,184 @@ Then executes autonomously:
85
202
  | `/ctx phase list` | Show all phases |
86
203
  | `/ctx phase add "goal"` | Add new phase |
87
204
  | `/ctx phase next` | Complete current, move to next |
88
- | `/ctx phase skip` | Skip current phase |
89
-
90
- ### Smart Router States
91
205
 
92
- | State | What `/ctx` does |
93
- |-------|------------------|
94
- | initializing | Research + Plan (ArguSeek + ChunkHound) |
95
- | executing | Execute current task |
96
- | debugging | **Debug loop until 100% fixed** |
97
- | verifying | Three-level verification |
98
- | paused | Resume from checkpoint |
99
-
100
- ## Debug Loop (Key Feature)
206
+ ---
101
207
 
102
- When something breaks, CTX enters debug mode and loops until fixed:
208
+ ## State Machine
103
209
 
104
210
  ```
105
- Loop (max 5 attempts):
106
- 1. Analyze error
107
- 2. Form hypothesis
108
- 3. Apply fix
109
- 4. Verify (build + tests + browser)
110
- 5. If fixed → done
111
- If not → new hypothesis, try again
211
+ initializing discussing → executing → verifying → COMPLETE
212
+ ↑ ↓
213
+ └── debugging ──┘
112
214
  ```
113
215
 
114
- **Browser verification for UI:**
115
- - Navigates to affected page
116
- - Checks elements exist
117
- - Takes screenshot proof
118
- - Saves to `.ctx/debug/`
119
-
120
- ## Key Design Principles
121
-
122
- ### Atomic Planning (2-3 Tasks Max)
123
- Why? Context degradation is real:
124
- | Context | Quality |
125
- |---------|---------|
126
- | 0-30% | Peak |
127
- | 30-50% | Good |
128
- | 50%+ | Degrading |
129
-
130
- Big work = multiple phases, not bigger plans.
131
-
132
- ### 95% Auto-Deviation Handling
133
- | Trigger | Action |
134
- |---------|--------|
135
- | Bug in existing code | Auto-fix |
136
- | Missing validation | Auto-add |
137
- | Blocking issue | Auto-fix |
138
- | Architecture decision | Ask user |
139
-
140
- ### Three-Level Verification
141
- 1. **Exists** - File on disk?
142
- 2. **Substantive** - Real code, not stub?
143
- 3. **Wired** - Imported and used?
216
+ | State | What happens |
217
+ |-------|--------------|
218
+ | initializing | Research + Map + Plan |
219
+ | discussing | Capture decisions in CONTEXT.md |
220
+ | executing | Execute with git-native commits |
221
+ | debugging | Persistent debug loop (max 10 attempts) |
222
+ | verifying | Three-level verification |
223
+ | paused | Resume from checkpoint |
144
224
 
145
- ### STATE.md - Single Source of Truth
146
- ~100 lines. Always accurate. Always read first.
225
+ ---
147
226
 
148
- ## 5 Specialized Agents
227
+ ## Context Management
149
228
 
150
- | Agent | Spawned when |
151
- |-------|--------------|
152
- | ctx-researcher | status = initializing |
153
- | ctx-planner | after research |
154
- | ctx-executor | status = executing |
155
- | ctx-debugger | status = debugging |
156
- | ctx-verifier | status = verifying |
229
+ CTX actively manages context budget:
157
230
 
158
- ## Integrations
231
+ | Usage | Quality | Action |
232
+ |-------|---------|--------|
233
+ | 0-30% | Peak | Continue |
234
+ | 30-40% | Good | Continue |
235
+ | 40-50% | Good | Prepare handoff notes |
236
+ | 50-60% | Degrading | Auto-checkpoint |
237
+ | 60-70% | Degrading | Create HANDOFF.md |
238
+ | 70%+ | Poor | Force checkpoint |
159
239
 
160
- ### ArguSeek (Web Research)
161
- Auto-runs during planning:
162
- - Best practices for the goal
163
- - Security considerations
164
- - Performance patterns
240
+ Smart handoff creates `HANDOFF.md` with:
241
+ - Completed tasks with commit hashes
242
+ - Current task progress
243
+ - Key decisions made
244
+ - Files modified
245
+ - Next steps
165
246
 
166
- ### ChunkHound (Semantic Code Search)
167
- Auto-runs during planning:
168
- - Semantic search for relevant code
169
- - Pattern detection
170
- - Entry point mapping
247
+ ---
171
248
 
172
- Install: `uv tool install chunkhound`
249
+ ## 10 Specialized Agents
250
+
251
+ | Agent | Spawned when | Model (balanced) |
252
+ |-------|--------------|------------------|
253
+ | ctx-mapper | /ctx map | haiku |
254
+ | ctx-tech-mapper | /ctx map-codebase | haiku |
255
+ | ctx-arch-mapper | /ctx map-codebase | haiku |
256
+ | ctx-quality-mapper | /ctx map-codebase | haiku |
257
+ | ctx-concerns-mapper | /ctx map-codebase | haiku |
258
+ | ctx-discusser | status = discussing | sonnet |
259
+ | ctx-researcher | status = initializing | opus |
260
+ | ctx-planner | after research | opus |
261
+ | ctx-executor | status = executing | sonnet |
262
+ | ctx-designer | design stories | sonnet |
263
+ | ctx-debugger | status = debugging | sonnet |
264
+ | ctx-verifier | status = verifying | haiku |
173
265
 
174
- ### Browser Verification (Playwright/Chrome DevTools)
175
- Auto-runs during debugging and verification:
176
- - Navigate to pages
177
- - Check elements exist
178
- - Take screenshot proof
266
+ ---
179
267
 
180
268
  ## Directory Structure
181
269
 
182
270
  ```
183
271
  .ctx/
272
+ ├── config.json # Model profiles, git settings
184
273
  ├── STATE.md # Living digest - execution state
185
- ├── PRD.json # Requirements contract - stories + criteria
186
- ├── phases/{story_id}/ # Per-story data
187
- ├── RESEARCH.md # ArguSeek + ChunkHound results
188
- ├── PLAN.md # Tasks mapped to acceptance criteria
274
+ ├── PRD.json # Requirements contract
275
+ ├── REPO-MAP.md # Token-optimized codebase map
276
+ ├── REPO-MAP.json # Structured map data
277
+ ├── .env # Test credentials (GITIGNORED)
278
+ ├── codebase/ # Deep analysis results
279
+ │ ├── TECH.md
280
+ │ ├── ARCH.md
281
+ │ ├── QUALITY.md
282
+ │ ├── CONCERNS.md
283
+ │ └── SUMMARY.md
284
+ ├── phases/{story_id}/
285
+ │ ├── CONTEXT.md # Locked decisions (discussion phase)
286
+ │ ├── RESEARCH.md # ArguSeek results
287
+ │ ├── PLAN.md # Tasks mapped to criteria
189
288
  │ └── VERIFY.md # Verification report
289
+ ├── debug/
290
+ │ ├── sessions/ # Persistent debug state
291
+ │ └── screenshots/ # Visual proof
190
292
  ├── checkpoints/ # Auto-checkpoints
191
- ├── debug/ # Debug screenshots
192
293
  └── memory/ # Decision memory
193
294
  ```
194
295
 
195
- ## PRD.json - Requirements Contract
296
+ ---
297
+
298
+ ## Configuration
196
299
 
300
+ `.ctx/config.json`:
197
301
  ```json
198
302
  {
199
- "stories": [
200
- {
201
- "id": "S001",
202
- "title": "User login",
203
- "acceptanceCriteria": [
204
- "User can log in with email",
205
- "Invalid password shows error"
206
- ],
207
- "passes": false
303
+ "activeProfile": "balanced",
304
+ "models": {
305
+ "architect": { "id": "claude-opus-4", "costTier": "high" },
306
+ "default": { "id": "claude-sonnet-4", "costTier": "medium" },
307
+ "fast": { "id": "claude-haiku-4", "costTier": "low" }
308
+ },
309
+ "profiles": {
310
+ "quality": {
311
+ "research": "architect",
312
+ "discussion": "architect",
313
+ "planning": "architect",
314
+ "execution": "architect"
315
+ },
316
+ "balanced": {
317
+ "research": "architect",
318
+ "discussion": "default",
319
+ "planning": "architect",
320
+ "execution": "default"
321
+ },
322
+ "budget": {
323
+ "research": "default",
324
+ "planning": "default",
325
+ "execution": "default"
208
326
  }
209
- ],
210
- "metadata": {
211
- "currentStory": "S001",
212
- "passedStories": 0,
213
- "totalStories": 5
327
+ },
328
+ "git": {
329
+ "autoCommit": true,
330
+ "commitPerTask": true
214
331
  }
215
332
  }
216
333
  ```
217
334
 
218
- When a story passes verification, `passes` becomes `true`.
219
- When all stories pass, project is complete.
335
+ ---
220
336
 
221
- ## Secure Credentials (.ctx/.env)
337
+ ## Integrations
222
338
 
223
- During `/ctx init`, you'll be asked for test credentials:
339
+ ### ArguSeek (Web Research)
340
+ Auto-runs during planning for best practices, security, and patterns.
224
341
 
342
+ ### ChunkHound (Semantic Code Search)
343
+ Auto-runs during planning for semantic search and pattern detection.
225
344
  ```bash
226
- # .ctx/.env (automatically gitignored)
227
- APP_URL=http://localhost:3000
228
- TEST_USER_EMAIL=test@example.com
229
- TEST_USER_PASSWORD=testpass123
230
- ADMIN_EMAIL=admin@example.com
231
- ADMIN_PASSWORD=adminpass123
232
- API_KEY=your-api-key
345
+ uv tool install chunkhound
233
346
  ```
234
347
 
235
- **Why?**
236
- - Enables autonomous browser verification
237
- - No interruptions asking "what's the login?"
238
- - Agents use credentials silently for testing
239
- - NEVER echoed in logs or committed
348
+ ### Browser Verification (Playwright/Chrome DevTools)
349
+ Auto-runs during debugging and verification for visual proof.
350
+
351
+ ### Figma MCP (Design Context)
352
+ Auto-runs during design stories for tokens and component metadata.
353
+
354
+ ### Gemini Design MCP (Visual Generation)
355
+ Auto-runs during design stories for mockups and UI code.
356
+
357
+ ---
358
+
359
+ ## Key Principles
360
+
361
+ ### 95% Auto-Deviation Handling
362
+
363
+ | Trigger | Action |
364
+ |---------|--------|
365
+ | Bug in existing code | Auto-fix, document in commit |
366
+ | Missing validation | Auto-add, document |
367
+ | Blocking issue | Auto-fix, document |
368
+ | Architecture decision | **Ask user** |
369
+
370
+ ### Three-Level Verification
371
+
372
+ | Level | Question | Check |
373
+ |-------|----------|-------|
374
+ | Exists | File on disk? | Glob |
375
+ | Substantive | Real code, not stub? | No TODOs, no placeholders |
376
+ | Wired | Imported and used? | Trace imports |
377
+
378
+ ### Atomic Planning
240
379
 
241
- **Security:**
242
- - `.ctx/.gitignore` automatically protects `.env`
243
- - Credentials used ONLY for test automation
244
- - Never hardcoded, always read from .env
380
+ Plans limited to 2-3 tasks to prevent context degradation.
381
+
382
+ ---
245
383
 
246
384
  ## Updating
247
385
 
@@ -249,15 +387,18 @@ API_KEY=your-api-key
249
387
  npx ctx-cc --force
250
388
  ```
251
389
 
390
+ ---
391
+
252
392
  ## License
253
393
 
254
394
  MIT
255
395
 
256
- ## Links
396
+ ---
257
397
 
258
- - [GitHub](https://github.com/jufjuf/CTX)
259
- - [Issues](https://github.com/jufjuf/CTX/issues)
398
+ <div align="center">
260
399
 
261
- ---
400
+ **[GitHub](https://github.com/jufjuf/CTX)** · **[Issues](https://github.com/jufjuf/CTX/issues)** · **[npm](https://www.npmjs.com/package/ctx-cc)**
401
+
402
+ *CTX 3.0 - Repository mapping. Discussion phase. Model profiles. Git-native. Persistent debug.*
262
403
 
263
- *CTX 2.2 - PRD-driven, story-verified, debug loop until 100% fixed*
404
+ </div>