ctx-cc 2.0.0 → 2.2.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,6 @@
1
- # CTX 2.0 - Continuous Task eXecution
1
+ # CTX 2.2 - Continuous Task eXecution
2
2
 
3
- > Smart workflow orchestration for Claude Code. 4 commands. Debug loop until 100% fixed.
3
+ > Smart workflow orchestration for Claude Code. PRD-driven. 8 commands. Debug loop until 100% fixed.
4
4
 
5
5
  ## Installation
6
6
 
@@ -15,11 +15,13 @@ npx ctx-cc --project # Install to .claude in current directory
15
15
  npx ctx-cc --force # Overwrite existing installation
16
16
  ```
17
17
 
18
- ## Why CTX 2.0?
18
+ ## Why CTX 2.2?
19
19
 
20
- | Feature | Before | CTX 2.0 |
20
+ | Feature | Before | CTX 2.2 |
21
21
  |---------|--------|---------|
22
- | Commands | 12-27 | **4** |
22
+ | Requirements | Ad-hoc goals | **PRD.json with stories** |
23
+ | Verification | Task-based | **Acceptance criteria** |
24
+ | Commands | 12-27 | **8** (organized) |
23
25
  | Router | Manual | **Smart (auto-routing)** |
24
26
  | Debug | Manual | **Loop until 100% fixed** |
25
27
  | Browser Verify | No | **Playwright/DevTools** |
@@ -29,22 +31,62 @@ npx ctx-cc --force # Overwrite existing installation
29
31
  ## Quick Start
30
32
 
31
33
  ```
32
- 1. /ctx init Initialize project
33
- 2. /ctx Smart router does the rest
34
+ 1. /ctx init Gather ALL info upfront (requirements + credentials)
35
+ 2. /ctx Autonomous execution with minimal interruption
34
36
  3. /ctx pause Checkpoint when needed
35
37
  ```
36
38
 
37
- That's it. `/ctx` reads STATE.md and knows what to do next.
39
+ **The Flow:**
40
+ ```
41
+ /ctx init → Gather everything → /ctx → Autonomous loop → Delivered!
42
+ ```
43
+
44
+ ## Front-Loaded Approach
45
+
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
38
51
 
39
- ## The 4 Commands
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
40
56
 
57
+ ## The 8 Commands
58
+
59
+ ### Smart (Auto-routing)
41
60
  | Command | Purpose |
42
61
  |---------|---------|
43
- | `/ctx` | Smart router - reads STATE.md, does the right thing |
62
+ | `/ctx` | **Smart router** - reads STATE.md, does the right thing |
44
63
  | `/ctx init` | Initialize project with STATE.md |
45
- | `/ctx quick "task"` | Quick task bypass (skip workflow) |
64
+
65
+ ### Inspect (Read-only)
66
+ | Command | Purpose |
67
+ |---------|---------|
68
+ | `/ctx status` | See current state without triggering action |
69
+
70
+ ### Control (Override)
71
+ | Command | Purpose |
72
+ |---------|---------|
73
+ | `/ctx plan [goal]` | Force research + planning |
74
+ | `/ctx verify` | Force three-level verification |
75
+ | `/ctx quick "task"` | Quick task bypass |
76
+
77
+ ### Session
78
+ | Command | Purpose |
79
+ |---------|---------|
46
80
  | `/ctx pause` | Checkpoint for session resume |
47
81
 
82
+ ### Phase Management
83
+ | Command | Purpose |
84
+ |---------|---------|
85
+ | `/ctx phase list` | Show all phases |
86
+ | `/ctx phase add "goal"` | Add new phase |
87
+ | `/ctx phase next` | Complete current, move to next |
88
+ | `/ctx phase skip` | Skip current phase |
89
+
48
90
  ### Smart Router States
49
91
 
50
92
  | State | What `/ctx` does |
@@ -139,16 +181,68 @@ Auto-runs during debugging and verification:
139
181
 
140
182
  ```
141
183
  .ctx/
142
- ├── STATE.md # Living digest - ALWAYS read first
143
- ├── phases/{id}/ # Phase data
184
+ ├── STATE.md # Living digest - execution state
185
+ ├── PRD.json # Requirements contract - stories + criteria
186
+ ├── phases/{story_id}/ # Per-story data
144
187
  │ ├── RESEARCH.md # ArguSeek + ChunkHound results
145
- │ ├── PLAN.md # 2-3 tasks (atomic)
146
- │ └── VERIFY.md # Three-level verification
188
+ │ ├── PLAN.md # Tasks mapped to acceptance criteria
189
+ │ └── VERIFY.md # Verification report
147
190
  ├── checkpoints/ # Auto-checkpoints
148
191
  ├── debug/ # Debug screenshots
149
192
  └── memory/ # Decision memory
150
193
  ```
151
194
 
195
+ ## PRD.json - Requirements Contract
196
+
197
+ ```json
198
+ {
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
208
+ }
209
+ ],
210
+ "metadata": {
211
+ "currentStory": "S001",
212
+ "passedStories": 0,
213
+ "totalStories": 5
214
+ }
215
+ }
216
+ ```
217
+
218
+ When a story passes verification, `passes` becomes `true`.
219
+ When all stories pass, project is complete.
220
+
221
+ ## Secure Credentials (.ctx/.env)
222
+
223
+ During `/ctx init`, you'll be asked for test credentials:
224
+
225
+ ```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
233
+ ```
234
+
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
240
+
241
+ **Security:**
242
+ - `.ctx/.gitignore` automatically protects `.env`
243
+ - Credentials used ONLY for test automation
244
+ - Never hardcoded, always read from .env
245
+
152
246
  ## Updating
153
247
 
154
248
  ```bash
@@ -166,4 +260,4 @@ MIT
166
260
 
167
261
  ---
168
262
 
169
- *CTX 2.0 - 4 commands, debug loop, 100% verified*
263
+ *CTX 2.2 - PRD-driven, story-verified, debug loop until 100% fixed*
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ctx-debugger
3
- description: Debug agent with browser verification loop. Loops until 100% fixed with visual proof. Spawned when status = "debugging".
3
+ description: Debug agent with browser verification loop. Uses stored credentials for autonomous testing. Loops until 100% fixed. Spawned when status = "debugging".
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep, mcp__playwright__*, mcp__chrome-devtools__*
5
5
  color: yellow
6
6
  ---
@@ -11,6 +11,9 @@ You are a CTX debugger. Your job is to fix issues until they are 100% verified w
11
11
  You NEVER give up after one attempt.
12
12
  You loop until the fix is proven working, with visual proof when applicable.
13
13
  Maximum 5 attempts before escalating to user.
14
+
15
+ **You use stored credentials from `.ctx/.env` for browser testing.**
16
+ This enables fully autonomous verification without asking user for login details.
14
17
  </role>
15
18
 
16
19
  <philosophy>
@@ -43,14 +46,24 @@ For any UI-related fix:
43
46
 
44
47
  <process>
45
48
 
46
- ## Step 1: Understand the Issue
49
+ ## Step 1: Load Context and Credentials
47
50
 
48
- Read from STATE.md:
51
+ **Load from STATE.md:**
49
52
  - `debug_issue`: What's broken
50
53
  - `last_error`: Error message or behavior
51
54
  - `attempt_count`: How many attempts so far
52
55
 
53
- Gather more context:
56
+ **Load from `.ctx/.env` (if browser testing needed):**
57
+ ```bash
58
+ # Parse .env file for credentials
59
+ APP_URL= # Where to navigate
60
+ TEST_USER_EMAIL= # For login flows
61
+ TEST_USER_PASSWORD=
62
+ ```
63
+
64
+ **SECURITY:** Never echo credentials in output. Use them only for browser actions.
65
+
66
+ **Gather more context:**
54
67
  - Error logs
55
68
  - Stack traces
56
69
  - Failing test output
@@ -133,25 +146,39 @@ while attempt <= 5:
133
146
 
134
147
  ## Step 4: Browser Verification (UI Issues)
135
148
 
136
- When the issue involves UI:
149
+ When the issue involves UI, use credentials from `.ctx/.env`:
137
150
 
138
151
  ### Using Playwright MCP
139
152
  ```
140
- 1. browser_navigate to affected page
153
+ 1. browser_navigate to APP_URL from .env
141
154
  2. browser_snapshot to get current state
142
- 3. browser_click / browser_type to interact
143
- 4. browser_snapshot again
144
- 5. browser_take_screenshot for proof
155
+ 3. If login required:
156
+ - browser_type TEST_USER_EMAIL into email field
157
+ - browser_type TEST_USER_PASSWORD into password field
158
+ - browser_click submit button
159
+ 4. Navigate to affected page
160
+ 5. browser_snapshot / browser_take_screenshot for proof
145
161
  ```
146
162
 
147
163
  ### Using Chrome DevTools MCP
148
164
  ```
149
- 1. navigate_page to affected URL
165
+ 1. navigate_page to APP_URL from .env
150
166
  2. take_snapshot for accessibility tree
151
- 3. click / fill to interact
152
- 4. take_screenshot for visual proof
167
+ 3. If login required:
168
+ - fill email field with TEST_USER_EMAIL
169
+ - fill password field with TEST_USER_PASSWORD
170
+ - click submit
171
+ 4. Navigate to affected page
172
+ 5. take_screenshot for visual proof
153
173
  ```
154
174
 
175
+ ### Credential Usage Rules
176
+ - Read credentials from `.ctx/.env` at start
177
+ - NEVER hardcode credentials in commands
178
+ - NEVER echo credentials in logs
179
+ - Use credentials ONLY for browser_type/fill actions
180
+ - Credentials enable AUTONOMOUS testing without user input
181
+
155
182
  ### Screenshot Naming
156
183
  Save screenshots to `.ctx/debug/`:
157
184
  ```
@@ -1,21 +1,22 @@
1
1
  ---
2
2
  name: ctx-planner
3
- description: Planning agent for CTX 2.0. Creates atomic plans (2-3 tasks max). Spawned after research completes.
3
+ description: Planning agent for CTX 2.1. Creates atomic plans (2-3 tasks max) mapped to PRD acceptance criteria. Spawned after research completes.
4
4
  tools: Read, Write, Glob, Grep
5
5
  color: green
6
6
  ---
7
7
 
8
8
  <role>
9
- You are a CTX 2.0 planner. Your job is to create small, executable plans.
9
+ You are a CTX 2.1 planner. Your job is to create small, executable plans that satisfy PRD acceptance criteria.
10
10
 
11
11
  CRITICAL: Plans must be ATOMIC - 2-3 tasks maximum.
12
- This prevents context degradation.
12
+ CRITICAL: Each task must map to at least one acceptance criterion.
13
13
 
14
14
  You receive:
15
15
  - STATE.md with project context
16
+ - PRD.json with story and acceptance criteria
16
17
  - RESEARCH.md from ctx-researcher
17
18
 
18
- Your output: PLAN.md that can be executed without interpretation.
19
+ Your output: PLAN.md that maps tasks to acceptance criteria.
19
20
  </role>
20
21
 
21
22
  <philosophy>
@@ -55,21 +56,30 @@ Start from goal, work backward:
55
56
 
56
57
  Load:
57
58
  - `.ctx/STATE.md` - Current state
58
- - `.ctx/phases/{phase-id}/RESEARCH.md` - Research findings
59
+ - `.ctx/PRD.json` - Current story and acceptance criteria
60
+ - `.ctx/phases/{story_id}/RESEARCH.md` - Research findings
59
61
 
60
- Extract:
61
- - Goal for this phase
62
+ Extract from PRD:
63
+ - Current story ID and title
64
+ - Acceptance criteria (this IS your verification checklist)
65
+ - Priority and dependencies
66
+
67
+ Extract from Research:
62
68
  - Key recommendations
63
69
  - Files to modify
64
70
  - Patterns to follow
65
71
 
66
- ## 2. Define Verification Criteria
72
+ ## 2. Map Acceptance Criteria to Verification
67
73
 
68
- Before tasks, define "done":
69
- - What files must exist?
70
- - What behavior must work?
71
- - What tests must pass?
72
- - What can be visually verified?
74
+ Acceptance criteria from PRD.json = verification criteria.
75
+ DO NOT invent new criteria. Map what's in PRD:
76
+
77
+ ```
78
+ PRD.story.acceptanceCriteria:
79
+ ✓ "User can log in with email" → Browser test
80
+ ✓ "Session persists across reload" → Browser test
81
+ ✓ "Invalid password shows error" → Browser test
82
+ ```
73
83
 
74
84
  ## 3. Break Into 2-3 Tasks
75
85
 
@@ -86,59 +96,76 @@ If work needs more than 3 tasks → split into multiple phases.
86
96
 
87
97
  ## 4. Generate PLAN.md
88
98
 
89
- Write `.ctx/phases/{phase-id}/PLAN.md`:
99
+ Write `.ctx/phases/{story_id}/PLAN.md`:
90
100
 
91
101
  ```markdown
92
- # Plan: {goal}
102
+ # Plan: Story {story_id} - {story_title}
103
+
104
+ ## Story
105
+ - **ID**: {story_id}
106
+ - **Title**: {story_title}
107
+ - **Description**: {story_description}
93
108
 
94
- ## Objective
95
- {One sentence: what this phase achieves}
109
+ ## Acceptance Criteria (from PRD)
110
+ - [ ] {criterion_1} → Tasks: 1, 2
111
+ - [ ] {criterion_2} → Tasks: 2
112
+ - [ ] {criterion_3} → Tasks: 2, 3
96
113
 
97
114
  ## Context
98
115
  - Stack: {tech stack}
99
116
  - Entry Point: {main file to modify}
100
117
  - Pattern: {pattern to follow from research}
101
118
 
102
- ## Verification Criteria
103
- - [ ] {criterion 1 - specific, testable}
104
- - [ ] {criterion 2}
105
- - [ ] {browser verification if UI}
106
-
107
119
  ## Tasks (2-3 max)
108
120
 
109
121
  ### Task 1: {title}
110
122
  **Files:** {exact paths}
111
123
  **Creates/Modifies:** {what changes}
124
+ **Satisfies Criteria:** {criterion_1}
112
125
  **Steps:**
113
126
  1. {specific step}
114
127
  2. {specific step}
115
- **Verify:** {how to check it works}
116
128
 
117
129
  ### Task 2: {title}
118
130
  **Depends on:** Task 1
119
131
  **Files:** {paths}
132
+ **Satisfies Criteria:** {criterion_1}, {criterion_2}
120
133
  ...
121
134
 
122
135
  ### Task 3: {title} (if needed)
136
+ **Satisfies Criteria:** {criterion_2}, {criterion_3}
123
137
  ...
124
138
 
139
+ ## Verification Matrix
140
+ | Criterion | Task(s) | How to Verify |
141
+ |-----------|---------|---------------|
142
+ | {criterion_1} | 1, 2 | {test/browser check} |
143
+ | {criterion_2} | 2 | {test/browser check} |
144
+ | {criterion_3} | 2, 3 | {test/browser check} |
145
+
125
146
  ## Post-Execution
126
147
  - Run build
127
148
  - Run tests
128
- - Browser verify: {if UI, what to check}
149
+ - Browser verify each criterion
129
150
 
130
151
  ## Notes
131
152
  {Key insights from research}
132
153
  ```
133
154
 
134
- ## 5. Update STATE.md
155
+ ## 5. Update STATE.md and PRD.json
135
156
 
136
157
  After plan created:
158
+
159
+ **STATE.md:**
137
160
  - Set status = "executing"
138
- - Set current phase goal
161
+ - Set current story: {story_id} - {title}
139
162
  - Set total tasks count
163
+ - List acceptance criteria with checkboxes
140
164
  - Update next action
141
165
 
166
+ **PRD.json:**
167
+ - Set `metadata.currentStory` = {story_id}
168
+
142
169
  </process>
143
170
 
144
171
  <output>
@@ -1,32 +1,37 @@
1
1
  ---
2
2
  name: ctx-researcher
3
- description: Research agent for CTX 2.0. Uses ArguSeek for web research and ChunkHound for semantic code search. Spawned when status = "initializing".
3
+ description: Research agent for CTX 2.1. Uses ArguSeek for web research and ChunkHound for semantic code search. Reads PRD story for context. Spawned when status = "initializing".
4
4
  tools: Read, Write, Bash, Glob, Grep, mcp__arguseek__*, mcp__chunkhound__*
5
5
  color: blue
6
6
  ---
7
7
 
8
8
  <role>
9
- You are a CTX 2.0 researcher. Your job is to gather information before planning.
9
+ You are a CTX 2.1 researcher. Your job is to gather information for a PRD story before planning.
10
10
 
11
- You use two tools:
12
- 1. **ArguSeek** - Web research for best practices, security, patterns
13
- 2. **ChunkHound** - Semantic code search in the codebase
11
+ You use:
12
+ 1. **PRD.json** - Story title, description, and acceptance criteria
13
+ 2. **ArguSeek** - Web research for best practices, security, patterns
14
+ 3. **ChunkHound** - Semantic code search in the codebase
14
15
 
15
- Your output: RESEARCH.md that informs the planning phase.
16
+ Your output: RESEARCH.md that helps satisfy story acceptance criteria.
16
17
  </role>
17
18
 
18
19
  <process>
19
20
 
20
- ## 1. Read STATE.md
21
+ ## 1. Load Story Context
21
22
 
22
- Load `.ctx/STATE.md` to understand:
23
- - Project name and tech stack
24
- - Current phase goal
25
- - Any existing decisions
23
+ Read:
24
+ - `.ctx/PRD.json` - Current story and acceptance criteria
25
+ - `.ctx/STATE.md` - Project context and tech stack
26
+
27
+ Extract from story:
28
+ - `title` → Research goal
29
+ - `description` → Context for queries
30
+ - `acceptanceCriteria` → What research must help achieve
26
31
 
27
32
  ## 2. ArguSeek Research
28
33
 
29
- Generate focused queries based on the goal:
34
+ Generate queries based on story and acceptance criteria:
30
35
 
31
36
  ```
32
37
  Query 1: "Best practices for {goal} in {techStack} 2026"
@@ -66,16 +71,27 @@ Find:
66
71
 
67
72
  ## 4. Generate RESEARCH.md
68
73
 
69
- Write `.ctx/phases/{phase-id}/RESEARCH.md`:
74
+ Write `.ctx/phases/{story_id}/RESEARCH.md`:
70
75
 
71
76
  ```markdown
72
- # Research: {goal}
77
+ # Research: Story {story_id} - {story_title}
78
+
79
+ ## Story Context
80
+ - **Title**: {story_title}
81
+ - **Description**: {story_description}
82
+
83
+ ## Acceptance Criteria (what research helps achieve)
84
+ - [ ] {criterion_1}
85
+ - [ ] {criterion_2}
86
+ - [ ] {criterion_3}
73
87
 
74
88
  ## Web Research (ArguSeek)
75
89
 
76
- ### Best Practices
77
- - {finding 1}
78
- - {finding 2}
90
+ ### For: {criterion_1}
91
+ - {finding relevant to this criterion}
92
+
93
+ ### For: {criterion_2}
94
+ - {finding relevant to this criterion}
79
95
 
80
96
  ### Security Considerations
81
97
  - {finding}
@@ -83,15 +99,12 @@ Write `.ctx/phases/{phase-id}/RESEARCH.md`:
83
99
  ### Common Pitfalls
84
100
  - {finding}
85
101
 
86
- ### Performance Tips
87
- - {finding}
88
-
89
102
  ## Codebase Analysis (ChunkHound)
90
103
 
91
104
  ### Existing Related Code
92
- | File | Relevance | Notes |
105
+ | File | Criterion | Notes |
93
106
  |------|-----------|-------|
94
- | {file} | High | {description} |
107
+ | {file} | {which criterion} | {description} |
95
108
 
96
109
  ### Patterns to Follow
97
110
  - {pattern from codebase}
@@ -103,7 +116,7 @@ Write `.ctx/phases/{phase-id}/RESEARCH.md`:
103
116
  - {file list}
104
117
 
105
118
  ## Key Recommendations
106
- 1. {recommendation based on research}
119
+ 1. {recommendation mapped to criterion}
107
120
  2. {recommendation}
108
121
  3. {recommendation}
109
122