ctx-cc 2.3.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.3 - Continuous Task eXecution
1
+ <div align="center">
2
2
 
3
- > Smart workflow orchestration for Claude Code. PRD-driven. Design-first. 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,97 +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.3?
19
-
20
- | Feature | Before | CTX 2.3 |
21
- |---------|--------|---------|
22
- | Requirements | Ad-hoc goals | **PRD.json with stories** |
23
- | Design | Manual workflow | **Full design system** |
24
- | Accessibility | Manual checks | **WCAG 2.2 AA + EAA 2025** |
25
- | Tokens | Custom formats | **W3C Design Tokens** |
26
- | Verification | Task-based | **Acceptance criteria** |
27
- | Commands | 12-27 | **8** (organized) |
28
- | Router | Manual | **Smart (auto-routing)** |
29
- | Debug | Manual | **Loop until 100% fixed** |
30
- | Browser Verify | No | **Playwright/DevTools** |
31
- | Planning | Any size | **Atomic (2-3 tasks max)** |
32
- | Resume cost | ~50k tokens | **~2.5k tokens** |
39
+ ---
33
40
 
34
41
  ## Quick Start
35
42
 
36
43
  ```
37
- 1. /ctx init Gather ALL info upfront (requirements + credentials)
38
- 2. /ctx Autonomous execution with minimal interruption
39
- 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
40
47
  ```
41
48
 
42
49
  **The Flow:**
43
50
  ```
44
- /ctx init → Gather everything → /ctx → Autonomous loop → Delivered!
51
+ /ctx init → /ctx map → /ctx → Autonomous loop → Delivered!
45
52
  ```
46
53
 
47
- ## Front-Loaded Approach
54
+ ---
48
55
 
49
- CTX gathers EVERYTHING at initialization:
50
- - **Requirements** → PRD.json stories
51
- - **Acceptance criteria** → How to verify each story
52
- - **Test credentials** → .ctx/.env (gitignored)
53
- - **Constitution** → Rules for autonomous decisions
54
- - **Design context** → Brand personality, inspirations, accessibility needs
56
+ ## New in 3.0
55
57
 
56
- Then executes autonomously:
57
- - Only interrupts for architecture decisions (Rule 4)
58
- - Only interrupts for design approvals at gates
59
- - Uses stored credentials for browser testing
60
- - 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
+ ```
61
64
 
62
- ## Design System (New in 2.3)
65
+ Creates `REPO-MAP.md` with symbols, dependencies, and navigation hints.
63
66
 
64
- CTX handles visual work with dedicated agents and approval gates.
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`.
65
74
 
66
- ### Story Types
67
- | Type | Agent | Purpose |
68
- |------|-------|---------|
69
- | feature | ctx-executor | Standard implementation |
70
- | brand | ctx-designer | BRAND_KIT.md + W3C tokens |
71
- | design | ctx-designer | UI components/pages |
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
+ ```
72
82
 
73
- ### 3 Options Pattern
74
- All design decisions present three options:
75
- - **Option A**: Conservative (safe, proven)
76
- - **Option B**: Balanced (recommended)
77
- - **Option C**: Bold (distinctive)
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 |
78
88
 
79
- ### Design Approval Gates
89
+ ### Git-Native Workflow
90
+ Every completed task auto-commits:
80
91
  ```
81
- Mood Board Direction (A/B/C) → Prototype → Final
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>
82
99
  ```
83
- Each gate requires user approval before proceeding.
84
100
 
85
- ### WCAG 2.2 AA + EAA 2025
86
- | Criterion | Requirement |
87
- |-----------|-------------|
88
- | 2.4.11 | Focus not obscured |
89
- | 2.5.7 | Drag alternatives |
90
- | 2.5.8 | 24x24px targets |
91
- | 3.3.8 | Accessible auth |
101
+ Configure in `.ctx/config.json`:
102
+ ```json
103
+ {
104
+ "git": {
105
+ "autoCommit": true,
106
+ "commitPerTask": true
107
+ }
108
+ }
109
+ ```
92
110
 
93
- EU markets require EAA 2025 compliance (enforcement: June 28, 2025).
111
+ ### Persistent Debug State
112
+ Debug sessions survive context resets:
113
+ ```bash
114
+ /ctx debug --resume # Continue previous session
115
+ ```
94
116
 
95
- ## The 8 Commands
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
96
159
 
97
160
  ### Smart (Auto-routing)
98
161
  | Command | Purpose |
99
162
  |---------|---------|
100
163
  | `/ctx` | **Smart router** - reads STATE.md, does the right thing |
101
- | `/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) |
102
181
 
103
182
  ### Inspect (Read-only)
104
183
  | Command | Purpose |
@@ -123,206 +202,184 @@ EU markets require EAA 2025 compliance (enforcement: June 28, 2025).
123
202
  | `/ctx phase list` | Show all phases |
124
203
  | `/ctx phase add "goal"` | Add new phase |
125
204
  | `/ctx phase next` | Complete current, move to next |
126
- | `/ctx phase skip` | Skip current phase |
127
205
 
128
- ### Smart Router States
129
-
130
- | State | What `/ctx` does |
131
- |-------|------------------|
132
- | initializing | Research + Plan (ArguSeek + ChunkHound) |
133
- | executing | Execute current task |
134
- | debugging | **Debug loop until 100% fixed** |
135
- | verifying | Three-level verification |
136
- | paused | Resume from checkpoint |
137
-
138
- ## Debug Loop (Key Feature)
206
+ ---
139
207
 
140
- When something breaks, CTX enters debug mode and loops until fixed:
208
+ ## State Machine
141
209
 
142
210
  ```
143
- Loop (max 5 attempts):
144
- 1. Analyze error
145
- 2. Form hypothesis
146
- 3. Apply fix
147
- 4. Verify (build + tests + browser)
148
- 5. If fixed → done
149
- If not → new hypothesis, try again
211
+ initializing discussing → executing → verifying → COMPLETE
212
+ ↑ ↓
213
+ └── debugging ──┘
150
214
  ```
151
215
 
152
- **Browser verification for UI:**
153
- - Navigates to affected page
154
- - Checks elements exist
155
- - Takes screenshot proof
156
- - Saves to `.ctx/debug/`
157
-
158
- ## Key Design Principles
159
-
160
- ### Atomic Planning (2-3 Tasks Max)
161
- Why? Context degradation is real:
162
- | Context | Quality |
163
- |---------|---------|
164
- | 0-30% | Peak |
165
- | 30-50% | Good |
166
- | 50%+ | Degrading |
167
-
168
- Big work = multiple phases, not bigger plans.
169
-
170
- ### 95% Auto-Deviation Handling
171
- | Trigger | Action |
172
- |---------|--------|
173
- | Bug in existing code | Auto-fix |
174
- | Missing validation | Auto-add |
175
- | Blocking issue | Auto-fix |
176
- | Architecture decision | Ask user |
177
-
178
- ### Three-Level Verification
179
- 1. **Exists** - File on disk?
180
- 2. **Substantive** - Real code, not stub?
181
- 3. **Wired** - Imported and used?
182
-
183
- ### STATE.md - Single Source of Truth
184
- ~100 lines. Always accurate. Always read first.
185
-
186
- ## 6 Specialized Agents
187
-
188
- | Agent | Spawned when |
216
+ | State | What happens |
189
217
  |-------|--------------|
190
- | ctx-researcher | status = initializing |
191
- | ctx-planner | after research |
192
- | ctx-executor | status = executing (feature stories) |
193
- | ctx-designer | status = executing (brand/design stories) |
194
- | ctx-debugger | status = debugging |
195
- | ctx-verifier | status = verifying |
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 |
196
224
 
197
- ## Integrations
225
+ ---
198
226
 
199
- ### ArguSeek (Web Research)
200
- Auto-runs during planning:
201
- - Best practices for the goal
202
- - Security considerations
203
- - Performance patterns
227
+ ## Context Management
204
228
 
205
- ### ChunkHound (Semantic Code Search)
206
- Auto-runs during planning:
207
- - Semantic search for relevant code
208
- - Pattern detection
209
- - Entry point mapping
229
+ CTX actively manages context budget:
210
230
 
211
- Install: `uv tool install chunkhound`
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 |
212
239
 
213
- ### Browser Verification (Playwright/Chrome DevTools)
214
- Auto-runs during debugging and verification:
215
- - Navigate to pages
216
- - Check elements exist
217
- - Take screenshot proof
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
218
246
 
219
- ### Figma MCP (Design Context)
220
- Auto-runs during design stories:
221
- - Extract design tokens
222
- - Get component metadata
223
- - Screenshot references
247
+ ---
224
248
 
225
- ### Gemini Design MCP (Visual Generation)
226
- Auto-runs during design stories:
227
- - Generate UI mockups
228
- - Create UI code
229
- - Analyze designs for accessibility
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 |
265
+
266
+ ---
230
267
 
231
268
  ## Directory Structure
232
269
 
233
270
  ```
234
271
  .ctx/
272
+ ├── config.json # Model profiles, git settings
235
273
  ├── STATE.md # Living digest - execution state
236
- ├── PRD.json # Requirements contract - stories + criteria
237
- ├── phases/{story_id}/ # Per-story data
238
- ├── RESEARCH.md # ArguSeek + ChunkHound results
239
- ├── PLAN.md # Tasks mapped to acceptance criteria
240
- ├── VERIFY.md # Verification report
241
- │ ├── MOOD_BOARD.md # Design references (design stories)
242
- └── DESIGN_BRIEF.md # Design decisions (design stories)
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
288
+ │ └── VERIFY.md # Verification report
289
+ ├── debug/
290
+ │ ├── sessions/ # Persistent debug state
291
+ │ └── screenshots/ # Visual proof
243
292
  ├── checkpoints/ # Auto-checkpoints
244
- ├── debug/ # Debug screenshots
245
293
  └── memory/ # Decision memory
246
-
247
- project/
248
- ├── BRAND_KIT.md # Visual foundation (brand stories)
249
- └── tokens/ # W3C design tokens
250
- ├── primitive.tokens.json
251
- ├── semantic.tokens.json
252
- └── component.tokens.json
253
294
  ```
254
295
 
255
- ## PRD.json - Requirements Contract
296
+ ---
297
+
298
+ ## Configuration
256
299
 
300
+ `.ctx/config.json`:
257
301
  ```json
258
302
  {
259
- "brand": {
260
- "hasBrandKit": false,
261
- "personality": ["professional", "modern"],
262
- "euMarket": true
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" }
263
308
  },
264
- "design": {
265
- "wcagLevel": "AA",
266
- "eaaCompliance": true,
267
- "tokenFormat": "w3c"
268
- },
269
- "stories": [
270
- {
271
- "id": "S001",
272
- "type": "brand",
273
- "title": "Establish brand kit",
274
- "acceptanceCriteria": [
275
- "BRAND_KIT.md exists",
276
- "tokens/ directory populated"
277
- ],
278
- "passes": false
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"
279
321
  },
280
- {
281
- "id": "S002",
282
- "type": "design",
283
- "title": "Login page",
284
- "acceptanceCriteria": [
285
- "WCAG 2.2 AA compliant",
286
- "All states implemented"
287
- ],
288
- "passes": false
322
+ "budget": {
323
+ "research": "default",
324
+ "planning": "default",
325
+ "execution": "default"
289
326
  }
290
- ],
291
- "metadata": {
292
- "currentStory": "S001",
293
- "passedStories": 0,
294
- "totalStories": 2
327
+ },
328
+ "git": {
329
+ "autoCommit": true,
330
+ "commitPerTask": true
295
331
  }
296
332
  }
297
333
  ```
298
334
 
299
- When a story passes verification, `passes` becomes `true`.
300
- When all stories pass, project is complete.
335
+ ---
301
336
 
302
- ## Secure Credentials (.ctx/.env)
337
+ ## Integrations
303
338
 
304
- 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.
305
341
 
342
+ ### ChunkHound (Semantic Code Search)
343
+ Auto-runs during planning for semantic search and pattern detection.
306
344
  ```bash
307
- # .ctx/.env (automatically gitignored)
308
- APP_URL=http://localhost:3000
309
- TEST_USER_EMAIL=test@example.com
310
- TEST_USER_PASSWORD=testpass123
311
- ADMIN_EMAIL=admin@example.com
312
- ADMIN_PASSWORD=adminpass123
313
- API_KEY=your-api-key
345
+ uv tool install chunkhound
314
346
  ```
315
347
 
316
- **Why?**
317
- - Enables autonomous browser verification
318
- - No interruptions asking "what's the login?"
319
- - Agents use credentials silently for testing
320
- - 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
321
379
 
322
- **Security:**
323
- - `.ctx/.gitignore` automatically protects `.env`
324
- - Credentials used ONLY for test automation
325
- - Never hardcoded, always read from .env
380
+ Plans limited to 2-3 tasks to prevent context degradation.
381
+
382
+ ---
326
383
 
327
384
  ## Updating
328
385
 
@@ -330,15 +387,18 @@ API_KEY=your-api-key
330
387
  npx ctx-cc --force
331
388
  ```
332
389
 
390
+ ---
391
+
333
392
  ## License
334
393
 
335
394
  MIT
336
395
 
337
- ## Links
396
+ ---
338
397
 
339
- - [GitHub](https://github.com/jufjuf/CTX)
340
- - [Issues](https://github.com/jufjuf/CTX/issues)
398
+ <div align="center">
341
399
 
342
- ---
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.*
343
403
 
344
- *CTX 2.3 - PRD-driven, design-first, story-verified, debug loop until 100% fixed*
404
+ </div>