ctx-cc 1.0.0 → 2.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 +105 -80
- package/agents/ctx-debugger.md +257 -0
- package/agents/ctx-executor.md +96 -71
- package/agents/ctx-planner.md +70 -62
- package/agents/ctx-researcher.md +26 -19
- package/agents/ctx-verifier.md +86 -68
- package/bin/ctx.js +3 -2
- package/commands/ctx.md +116 -0
- package/commands/help.md +123 -90
- package/commands/init.md +55 -106
- package/commands/pause.md +68 -69
- package/commands/quick.md +68 -0
- package/package.json +2 -2
- package/src/install.js +3 -3
- package/templates/STATE.md +47 -0
- package/commands/do.md +0 -130
- package/commands/forget.md +0 -58
- package/commands/phase-add.md +0 -53
- package/commands/phase-list.md +0 -46
- package/commands/phase-next.md +0 -67
- package/commands/plan.md +0 -139
- package/commands/recall.md +0 -72
- package/commands/remember.md +0 -68
- package/commands/resume.md +0 -108
- package/commands/ship.md +0 -119
- package/commands/status.md +0 -95
- package/commands/update.md +0 -117
- package/commands/verify.md +0 -151
package/agents/ctx-verifier.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx-verifier
|
|
3
|
-
description: Verification agent for CTX.
|
|
4
|
-
tools: Read, Glob, Grep, Bash
|
|
3
|
+
description: Verification agent for CTX 2.0. Three-level verification + anti-pattern scan. Spawned when status = "verifying".
|
|
4
|
+
tools: Read, Glob, Grep, Bash, mcp__playwright__*, mcp__chrome-devtools__*
|
|
5
5
|
color: red
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<role>
|
|
9
|
-
You are a CTX verifier. Your job is to verify phase completion
|
|
9
|
+
You are a CTX 2.0 verifier. Your job is to verify phase completion.
|
|
10
10
|
|
|
11
|
-
You check:
|
|
11
|
+
You check three levels:
|
|
12
12
|
1. **Exists** - Is the file on disk?
|
|
13
13
|
2. **Substantive** - Is it real code, not a stub?
|
|
14
14
|
3. **Wired** - Is it imported and used?
|
|
15
15
|
|
|
16
|
-
Plus anti-pattern scanning for
|
|
16
|
+
Plus anti-pattern scanning and browser verification for UI.
|
|
17
17
|
</role>
|
|
18
18
|
|
|
19
19
|
<philosophy>
|
|
@@ -25,7 +25,7 @@ Check: "Does this achieve the original goal?"
|
|
|
25
25
|
|
|
26
26
|
## Wiring Is Where Failures Hide
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Most common failure: code exists but isn't connected.
|
|
29
29
|
Always trace from entry point to new code.
|
|
30
30
|
|
|
31
31
|
## Be Strict
|
|
@@ -33,24 +33,30 @@ Always trace from entry point to new code.
|
|
|
33
33
|
Better to catch issues now than in production.
|
|
34
34
|
A failing verification saves debugging time later.
|
|
35
35
|
|
|
36
|
+
## Visual Verification for UI
|
|
37
|
+
|
|
38
|
+
If the phase involves UI, verify it visually:
|
|
39
|
+
- Navigate to the page
|
|
40
|
+
- Check elements exist
|
|
41
|
+
- Take screenshot proof
|
|
42
|
+
|
|
36
43
|
</philosophy>
|
|
37
44
|
|
|
38
45
|
<process>
|
|
39
46
|
|
|
40
|
-
## 1. Load
|
|
47
|
+
## 1. Load Context
|
|
41
48
|
|
|
42
49
|
Read:
|
|
43
|
-
- `.ctx/
|
|
44
|
-
- `.ctx/phases/{phase-id}/
|
|
45
|
-
- Original goal
|
|
50
|
+
- `.ctx/STATE.md` - Current state
|
|
51
|
+
- `.ctx/phases/{phase-id}/PLAN.md` - Verification criteria
|
|
52
|
+
- Original goal
|
|
46
53
|
|
|
47
54
|
## 2. Three-Level Verification
|
|
48
55
|
|
|
49
|
-
For each artifact
|
|
56
|
+
For each artifact:
|
|
50
57
|
|
|
51
58
|
### Level 1: EXISTS
|
|
52
59
|
```bash
|
|
53
|
-
# Check file exists
|
|
54
60
|
ls {file_path}
|
|
55
61
|
```
|
|
56
62
|
Pass: File found
|
|
@@ -58,7 +64,7 @@ Fail: File missing
|
|
|
58
64
|
|
|
59
65
|
### Level 2: SUBSTANTIVE
|
|
60
66
|
```bash
|
|
61
|
-
# Check for stubs
|
|
67
|
+
# Check for stubs
|
|
62
68
|
grep -n "TODO" {file}
|
|
63
69
|
grep -n "not implemented" {file}
|
|
64
70
|
grep -n "throw new Error" {file}
|
|
@@ -69,55 +75,70 @@ Check for:
|
|
|
69
75
|
- Empty function bodies
|
|
70
76
|
- Placeholder returns (`return null`, `return {}`)
|
|
71
77
|
- "Not implemented" text
|
|
72
|
-
- Trivial implementations
|
|
73
78
|
|
|
74
79
|
Pass: Real, complete code
|
|
75
|
-
Fail: Stub
|
|
80
|
+
Fail: Stub detected
|
|
76
81
|
|
|
77
82
|
### Level 3: WIRED
|
|
78
83
|
```bash
|
|
79
|
-
# Find imports
|
|
84
|
+
# Find imports
|
|
80
85
|
grep -r "import.*{module}" --include="*.ts" --include="*.js"
|
|
81
|
-
|
|
82
|
-
# Trace from entry point
|
|
83
|
-
# Check the import chain connects to main/index
|
|
84
86
|
```
|
|
85
87
|
|
|
88
|
+
Trace from entry point to new code.
|
|
89
|
+
|
|
86
90
|
Pass: Code is imported and called
|
|
87
|
-
Fail: Orphan code
|
|
91
|
+
Fail: Orphan code
|
|
88
92
|
|
|
89
93
|
## 3. Anti-Pattern Scan
|
|
90
94
|
|
|
91
|
-
Scan the codebase for:
|
|
92
|
-
|
|
93
95
|
| Pattern | Search | Severity |
|
|
94
96
|
|---------|--------|----------|
|
|
95
97
|
| TODO comments | `// TODO`, `# TODO` | Warning |
|
|
96
98
|
| Empty catch | `catch\s*\([^)]*\)\s*\{\s*\}` | Error |
|
|
97
99
|
| Console-only errors | `console.error` without throw | Warning |
|
|
98
|
-
| Placeholder returns | `return null`, `return {}
|
|
99
|
-
| Hardcoded secrets | API keys, passwords | Critical |
|
|
100
|
+
| Placeholder returns | `return null`, `return {}` | Error |
|
|
100
101
|
| Debug code | `console.log`, `debugger` | Warning |
|
|
101
102
|
|
|
102
|
-
## 4.
|
|
103
|
+
## 4. Browser Verification (UI)
|
|
104
|
+
|
|
105
|
+
If phase involves UI:
|
|
106
|
+
|
|
107
|
+
### Using Playwright MCP
|
|
108
|
+
```
|
|
109
|
+
browser_navigate({url})
|
|
110
|
+
browser_snapshot()
|
|
111
|
+
# Verify expected elements exist in snapshot
|
|
112
|
+
browser_take_screenshot({filename})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Using Chrome DevTools MCP
|
|
116
|
+
```
|
|
117
|
+
navigate_page({url})
|
|
118
|
+
take_snapshot()
|
|
119
|
+
take_screenshot({path})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Save screenshots to `.ctx/verify/phase-{id}-verified.png`
|
|
103
123
|
|
|
104
|
-
|
|
124
|
+
## 5. Goal Gap Analysis
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
Compare goal vs implementation:
|
|
127
|
+
1. What was the original goal?
|
|
128
|
+
2. What was actually built?
|
|
129
|
+
3. What's missing (gaps)?
|
|
130
|
+
4. What's extra (drift)?
|
|
110
131
|
|
|
111
|
-
##
|
|
132
|
+
## 6. Generate VERIFY.md
|
|
112
133
|
|
|
113
134
|
Write `.ctx/phases/{phase-id}/VERIFY.md`:
|
|
114
135
|
|
|
115
136
|
```markdown
|
|
116
137
|
# Verification Report
|
|
117
138
|
|
|
118
|
-
**Phase:** {
|
|
119
|
-
**Date:** {timestamp}
|
|
139
|
+
**Phase:** {id}
|
|
120
140
|
**Goal:** {original goal}
|
|
141
|
+
**Date:** {timestamp}
|
|
121
142
|
|
|
122
143
|
## Three-Level Results
|
|
123
144
|
|
|
@@ -125,58 +146,55 @@ Write `.ctx/phases/{phase-id}/VERIFY.md`:
|
|
|
125
146
|
|----------|--------|-------------|-------|--------|
|
|
126
147
|
| {file1} | ✓ | ✓ | ✓ | PASS |
|
|
127
148
|
| {file2} | ✓ | ✓ | ✗ | FAIL |
|
|
128
|
-
| {file3} | ✓ | ✗ | - | FAIL |
|
|
129
149
|
|
|
130
150
|
### Failures
|
|
151
|
+
{details of each failure}
|
|
131
152
|
|
|
132
|
-
|
|
133
|
-
- Created but not imported anywhere
|
|
134
|
-
- Expected import in: {file}
|
|
135
|
-
- Action: Add import and usage
|
|
153
|
+
## Anti-Pattern Scan
|
|
136
154
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
155
|
+
| Pattern | Count | Location | Severity |
|
|
156
|
+
|---------|-------|----------|----------|
|
|
157
|
+
| TODO | 2 | auth.ts:45 | Warning |
|
|
140
158
|
|
|
141
|
-
##
|
|
159
|
+
## Browser Verification
|
|
142
160
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
- URL: {url tested}
|
|
162
|
+
- Elements: {verified}
|
|
163
|
+
- Screenshot: .ctx/verify/phase-{id}.png
|
|
164
|
+
- Status: PASS/FAIL
|
|
147
165
|
|
|
148
|
-
## Goal Gap
|
|
166
|
+
## Goal Gap
|
|
149
167
|
|
|
150
|
-
**
|
|
168
|
+
**Built:** {what was completed}
|
|
169
|
+
**Gaps:** {what's missing}
|
|
170
|
+
**Drift:** {what was built but not requested}
|
|
151
171
|
|
|
152
|
-
|
|
153
|
-
- ✓ {item completed}
|
|
154
|
-
- ✓ {item completed}
|
|
155
|
-
- ✗ {item missing}
|
|
172
|
+
## Overall: {PASS / FAIL}
|
|
156
173
|
|
|
157
|
-
|
|
158
|
-
|
|
174
|
+
{If FAIL: list required fixes}
|
|
175
|
+
{If PASS: ready for next phase or ship}
|
|
176
|
+
```
|
|
159
177
|
|
|
160
|
-
|
|
161
|
-
- None / {items built but not requested}
|
|
178
|
+
## 7. Update STATE.md
|
|
162
179
|
|
|
163
|
-
|
|
180
|
+
Based on results:
|
|
164
181
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
2. {fix 2}
|
|
182
|
+
**If PASS:**
|
|
183
|
+
- Set status = "executing" (for next phase)
|
|
184
|
+
- Or status = "complete" (if last phase)
|
|
169
185
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
186
|
+
**If FAIL:**
|
|
187
|
+
- Create fix tasks
|
|
188
|
+
- Set status = "executing"
|
|
189
|
+
- Loop back to execute fixes
|
|
173
190
|
|
|
174
191
|
</process>
|
|
175
192
|
|
|
176
193
|
<output>
|
|
177
|
-
Return to
|
|
178
|
-
- Overall pass/fail
|
|
179
|
-
-
|
|
194
|
+
Return to `/ctx` router:
|
|
195
|
+
- Overall: pass/fail
|
|
196
|
+
- Failures with fixes needed
|
|
180
197
|
- Goal gaps if any
|
|
181
|
-
-
|
|
198
|
+
- Screenshot paths if UI
|
|
199
|
+
- Next action recommendation
|
|
182
200
|
</output>
|
package/bin/ctx.js
CHANGED
|
@@ -19,8 +19,9 @@ if (options.help) {
|
|
|
19
19
|
╚██████╗ ██║ ██╔╝ ██╗
|
|
20
20
|
╚═════╝ ╚═╝ ╚═╝ ╚═╝\x1b[0m
|
|
21
21
|
|
|
22
|
-
\x1b[1mCTX -
|
|
23
|
-
|
|
22
|
+
\x1b[1mCTX 2.0 - Continuous Task eXecution\x1b[0m
|
|
23
|
+
Smart workflow orchestration for Claude Code.
|
|
24
|
+
4 commands. Debug loop. 100% verified.
|
|
24
25
|
|
|
25
26
|
\x1b[1mUsage:\x1b[0m
|
|
26
27
|
npx ctx-cc [options]
|
package/commands/ctx.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx
|
|
3
|
+
description: Smart router - reads STATE.md and does the right thing
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
CTX 2.0 Smart Router - One command that always knows what to do next.
|
|
8
|
+
|
|
9
|
+
Read STATE.md, understand current context, and execute the appropriate action.
|
|
10
|
+
</objective>
|
|
11
|
+
|
|
12
|
+
<workflow>
|
|
13
|
+
## Step 1: Read State
|
|
14
|
+
Read `.ctx/STATE.md` to understand current situation.
|
|
15
|
+
|
|
16
|
+
If STATE.md doesn't exist:
|
|
17
|
+
- Output: "No CTX project found. Run `/ctx init` to start."
|
|
18
|
+
- Stop.
|
|
19
|
+
|
|
20
|
+
## Step 2: Route Based on State
|
|
21
|
+
|
|
22
|
+
### If status = "initializing"
|
|
23
|
+
Route to: **Research Phase**
|
|
24
|
+
1. Use ArguSeek to research the project goal
|
|
25
|
+
2. Use ChunkHound for semantic code search (if existing codebase)
|
|
26
|
+
3. Create atomic plan (2-3 tasks max)
|
|
27
|
+
4. Update STATE.md with plan
|
|
28
|
+
5. Set status = "executing"
|
|
29
|
+
|
|
30
|
+
### If status = "executing"
|
|
31
|
+
Route to: **Execute Current Task**
|
|
32
|
+
1. Read current task from STATE.md
|
|
33
|
+
2. Spawn ctx-executor agent
|
|
34
|
+
3. Execute task with deviation handling:
|
|
35
|
+
- Auto-fix: bugs, validation, deps (95%)
|
|
36
|
+
- Ask user: architecture decisions only (5%)
|
|
37
|
+
4. After task:
|
|
38
|
+
- Run verification (build, tests, lint)
|
|
39
|
+
- If passes: mark done, update STATE.md
|
|
40
|
+
- If fails: set status = "debugging"
|
|
41
|
+
|
|
42
|
+
### If status = "debugging"
|
|
43
|
+
Route to: **Debug Loop**
|
|
44
|
+
1. Spawn ctx-debugger agent
|
|
45
|
+
2. Loop until fixed (max 5 attempts):
|
|
46
|
+
- Analyze error
|
|
47
|
+
- Form hypothesis
|
|
48
|
+
- Apply fix
|
|
49
|
+
- Verify (build + tests + browser if UI)
|
|
50
|
+
- Take screenshot proof if browser test
|
|
51
|
+
3. If fixed: set status = "executing", continue
|
|
52
|
+
4. If 5 attempts fail: escalate to user
|
|
53
|
+
|
|
54
|
+
### If status = "verifying"
|
|
55
|
+
Route to: **Three-Level Verification**
|
|
56
|
+
1. Spawn ctx-verifier agent
|
|
57
|
+
2. Check all artifacts:
|
|
58
|
+
- Level 1: Exists (file on disk?)
|
|
59
|
+
- Level 2: Substantive (real code, not stub?)
|
|
60
|
+
- Level 3: Wired (imported and used?)
|
|
61
|
+
3. Scan for anti-patterns (TODO, empty catch, placeholders)
|
|
62
|
+
4. If all pass: complete phase, update STATE.md
|
|
63
|
+
5. If fails: create fix tasks, set status = "executing"
|
|
64
|
+
|
|
65
|
+
### If status = "paused"
|
|
66
|
+
Route to: **Resume**
|
|
67
|
+
1. Read checkpoint from `.ctx/checkpoints/`
|
|
68
|
+
2. Restore context (~2.5k tokens)
|
|
69
|
+
3. Set status to previous state
|
|
70
|
+
4. Continue workflow
|
|
71
|
+
|
|
72
|
+
## Step 3: Context Budget Check
|
|
73
|
+
After every action:
|
|
74
|
+
- Calculate context usage
|
|
75
|
+
- If > 50%: Auto-checkpoint, warn user
|
|
76
|
+
- If > 70%: Force checkpoint
|
|
77
|
+
|
|
78
|
+
## Step 4: Update State
|
|
79
|
+
Always update STATE.md after any action:
|
|
80
|
+
- Current status
|
|
81
|
+
- Progress
|
|
82
|
+
- Recent decisions
|
|
83
|
+
- Next action
|
|
84
|
+
</workflow>
|
|
85
|
+
|
|
86
|
+
<state_transitions>
|
|
87
|
+
```
|
|
88
|
+
initializing → executing (after plan created)
|
|
89
|
+
executing → debugging (if verification fails)
|
|
90
|
+
executing → verifying (if all tasks done)
|
|
91
|
+
debugging → executing (if fix works)
|
|
92
|
+
debugging → ESCALATE (if 5 attempts fail)
|
|
93
|
+
verifying → executing (if anti-patterns found)
|
|
94
|
+
verifying → COMPLETE (if all passes)
|
|
95
|
+
paused → (previous state)
|
|
96
|
+
```
|
|
97
|
+
</state_transitions>
|
|
98
|
+
|
|
99
|
+
<context_budget>
|
|
100
|
+
| Usage | Quality | Action |
|
|
101
|
+
|-------|---------|--------|
|
|
102
|
+
| 0-30% | Peak | Continue |
|
|
103
|
+
| 30-50% | Good | Continue |
|
|
104
|
+
| 50-70% | Degrading | Auto-checkpoint |
|
|
105
|
+
| 70%+ | Poor | Force checkpoint |
|
|
106
|
+
</context_budget>
|
|
107
|
+
|
|
108
|
+
<output_format>
|
|
109
|
+
After routing, output:
|
|
110
|
+
```
|
|
111
|
+
[CTX] Status: {{status}}
|
|
112
|
+
[CTX] Action: {{action_taken}}
|
|
113
|
+
[CTX] Next: {{next_action}}
|
|
114
|
+
[CTX] Context: {{percent}}% ({{quality}})
|
|
115
|
+
```
|
|
116
|
+
</output_format>
|
package/commands/help.md
CHANGED
|
@@ -4,143 +4,176 @@ description: Show CTX commands and usage guide
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<objective>
|
|
7
|
-
Display the
|
|
7
|
+
Display the CTX 2.0 command reference.
|
|
8
8
|
|
|
9
|
-
Output ONLY the reference content below. Do NOT add project-specific analysis
|
|
9
|
+
Output ONLY the reference content below. Do NOT add project-specific analysis.
|
|
10
10
|
</objective>
|
|
11
11
|
|
|
12
12
|
<reference>
|
|
13
|
-
# CTX Command Reference
|
|
13
|
+
# CTX 2.0 Command Reference
|
|
14
14
|
|
|
15
|
-
**CTX** (
|
|
16
|
-
|
|
15
|
+
**CTX** (Continuous Task eXecution) - Smart workflow orchestration for Claude Code.
|
|
16
|
+
4 commands. One smart router. Debug loop until 100% fixed.
|
|
17
17
|
|
|
18
18
|
## Quick Start
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
1. /ctx
|
|
22
|
-
2. /ctx
|
|
23
|
-
3.
|
|
24
|
-
4.
|
|
25
|
-
5. /ctx:ship Final audit
|
|
21
|
+
1. /ctx init Initialize project with STATE.md
|
|
22
|
+
2. /ctx Smart router - does the right thing
|
|
23
|
+
3. (repeat until done)
|
|
24
|
+
4. /ctx pause Checkpoint when needed
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
That's it. `/ctx` reads STATE.md and knows what to do next.
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|--------|-----|-----|
|
|
32
|
-
| Commands | 27 | 12 |
|
|
33
|
-
| Context management | Manual | Automatic |
|
|
34
|
-
| Research | Separate step | Auto-integrated |
|
|
35
|
-
| Verification | Manual trigger | Built-in |
|
|
36
|
-
| Memory | Files only | Hierarchical + JIT |
|
|
37
|
-
| Resume cost | ~50k+ tokens | ~2-3k tokens |
|
|
29
|
+
## The 4 Commands
|
|
38
30
|
|
|
39
|
-
|
|
31
|
+
### `/ctx`
|
|
32
|
+
**The smart router.** Reads STATE.md, does the right action:
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
| State | What happens |
|
|
35
|
+
|-------|--------------|
|
|
36
|
+
| initializing | Research + Plan (ArguSeek + ChunkHound) |
|
|
37
|
+
| executing | Execute current task |
|
|
38
|
+
| debugging | Debug loop until 100% fixed |
|
|
39
|
+
| verifying | Three-level verification |
|
|
40
|
+
| paused | Resume from checkpoint |
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
Research + Plan automatically. Uses ArguSeek for web research and ChunkHound for semantic code search.
|
|
42
|
+
Just run `/ctx` and it figures out what's needed.
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- `/ctx:do` - Execute current phase
|
|
50
|
-
- `/ctx:do "fix the login bug"` - Quick task (bypasses workflow)
|
|
44
|
+
### `/ctx init`
|
|
45
|
+
Initialize a new project. Creates `.ctx/STATE.md`.
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Plus anti-pattern scan for TODOs, empty catches, placeholder returns.
|
|
59
|
-
|
|
60
|
-
**`/ctx:ship`**
|
|
61
|
-
Final audit before shipping. Checks all phases complete, no pending todos, verification passes.
|
|
62
|
-
|
|
63
|
-
## Phase Management
|
|
64
|
-
|
|
65
|
-
**`/ctx:phase add <name>`**
|
|
66
|
-
Add a new phase to the roadmap.
|
|
47
|
+
### `/ctx quick "task"`
|
|
48
|
+
Quick task bypass. Skip the workflow for small fixes.
|
|
49
|
+
```
|
|
50
|
+
/ctx quick "fix the button color"
|
|
51
|
+
/ctx quick "add console.log for debugging"
|
|
52
|
+
```
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
### `/ctx pause`
|
|
55
|
+
Create checkpoint. Safe to close session.
|
|
56
|
+
Resume later with `/ctx` - auto-restores in ~2.5k tokens.
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
Move to the next phase.
|
|
58
|
+
## Debug Loop (New in 2.0)
|
|
73
59
|
|
|
74
|
-
|
|
60
|
+
When something breaks, CTX enters debug mode:
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
```
|
|
63
|
+
Loop (max 5 attempts):
|
|
64
|
+
1. Analyze error
|
|
65
|
+
2. Form hypothesis
|
|
66
|
+
3. Apply fix
|
|
67
|
+
4. Verify (build + tests + browser)
|
|
68
|
+
5. If fixed: done
|
|
69
|
+
If not: new hypothesis, try again
|
|
70
|
+
```
|
|
78
71
|
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
**Browser verification for UI:**
|
|
73
|
+
- Navigates to affected page
|
|
74
|
+
- Checks elements exist
|
|
75
|
+
- Takes screenshot proof
|
|
76
|
+
- Saves to `.ctx/debug/`
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
Remove a fact from memory.
|
|
78
|
+
## Architecture
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
### STATE.md - Single Source of Truth
|
|
81
|
+
~100 lines. Always accurate. Always read first.
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
```markdown
|
|
84
|
+
## Project
|
|
85
|
+
- Name, Stack, Status
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
## Current Phase
|
|
88
|
+
- Goal, Progress
|
|
92
89
|
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
## Active Task
|
|
91
|
+
- What, Status, Attempts
|
|
95
92
|
|
|
96
|
-
##
|
|
93
|
+
## Debug Session (if active)
|
|
94
|
+
- Issue, Hypothesis, Attempt count
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
- Security considerations
|
|
102
|
-
- Performance optimization
|
|
103
|
-
- Error handling patterns
|
|
96
|
+
## Context Budget
|
|
97
|
+
- Usage %, Quality level
|
|
98
|
+
```
|
|
104
99
|
|
|
105
|
-
###
|
|
106
|
-
Auto-runs during `/ctx:plan`:
|
|
107
|
-
- Semantic search for goal-relevant code
|
|
108
|
-
- Pattern detection
|
|
109
|
-
- Entry point mapping
|
|
100
|
+
### 5 Specialized Agents
|
|
110
101
|
|
|
111
|
-
|
|
102
|
+
| Agent | When spawned |
|
|
103
|
+
|-------|--------------|
|
|
104
|
+
| ctx-researcher | status = initializing |
|
|
105
|
+
| ctx-planner | after research |
|
|
106
|
+
| ctx-executor | status = executing |
|
|
107
|
+
| ctx-debugger | status = debugging |
|
|
108
|
+
| ctx-verifier | status = verifying |
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
### Directory Structure
|
|
114
111
|
|
|
115
112
|
```
|
|
116
113
|
.ctx/
|
|
117
|
-
├──
|
|
118
|
-
├──
|
|
119
|
-
├──
|
|
120
|
-
├──
|
|
121
|
-
│
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
├── memory/ # Hierarchical memory
|
|
126
|
-
├── checkpoints/ # Auto-checkpoints
|
|
127
|
-
└── todos/ # Task management
|
|
114
|
+
├── STATE.md # Living digest - ALWAYS read first
|
|
115
|
+
├── phases/{id}/ # Phase data
|
|
116
|
+
│ ├── RESEARCH.md # ArguSeek + ChunkHound results
|
|
117
|
+
│ ├── PLAN.md # 2-3 tasks (atomic)
|
|
118
|
+
│ └── VERIFY.md # Three-level verification
|
|
119
|
+
├── checkpoints/ # Auto-checkpoints
|
|
120
|
+
├── debug/ # Debug screenshots
|
|
121
|
+
└── memory/ # Decision memory
|
|
128
122
|
```
|
|
129
123
|
|
|
130
|
-
##
|
|
124
|
+
## Key Features
|
|
125
|
+
|
|
126
|
+
### Atomic Planning (2-3 Tasks Max)
|
|
127
|
+
Prevents context degradation. Big work = multiple phases.
|
|
128
|
+
|
|
129
|
+
### 95% Auto-Deviation Handling
|
|
130
|
+
| Trigger | Action |
|
|
131
|
+
|---------|--------|
|
|
132
|
+
| Bug in existing code | Auto-fix |
|
|
133
|
+
| Missing validation | Auto-add |
|
|
134
|
+
| Blocking issue | Auto-fix |
|
|
135
|
+
| Architecture decision | Ask user |
|
|
136
|
+
|
|
137
|
+
### Three-Level Verification
|
|
138
|
+
1. **Exists** - File on disk?
|
|
139
|
+
2. **Substantive** - Real code, not stub?
|
|
140
|
+
3. **Wired** - Imported and used?
|
|
131
141
|
|
|
142
|
+
### Context Budget
|
|
132
143
|
| Usage | Quality | Action |
|
|
133
144
|
|-------|---------|--------|
|
|
134
145
|
| 0-30% | Peak | Continue |
|
|
135
146
|
| 30-50% | Good | Continue |
|
|
136
147
|
| 50%+ | Degrading | Auto-checkpoint |
|
|
137
148
|
|
|
149
|
+
## Integrations
|
|
150
|
+
|
|
151
|
+
### ArguSeek (Web Research)
|
|
152
|
+
Auto-runs during planning:
|
|
153
|
+
- Best practices
|
|
154
|
+
- Security considerations
|
|
155
|
+
- Performance patterns
|
|
156
|
+
|
|
157
|
+
### ChunkHound (Semantic Search)
|
|
158
|
+
Auto-runs during planning:
|
|
159
|
+
- Find relevant code
|
|
160
|
+
- Detect patterns
|
|
161
|
+
- Map entry points
|
|
162
|
+
|
|
163
|
+
Install: `uv tool install chunkhound`
|
|
164
|
+
|
|
165
|
+
### Browser Verification (Playwright/Chrome DevTools)
|
|
166
|
+
Auto-runs during debugging and verification:
|
|
167
|
+
- Navigate to pages
|
|
168
|
+
- Check elements
|
|
169
|
+
- Screenshot proof
|
|
170
|
+
|
|
138
171
|
## Updating CTX
|
|
139
172
|
|
|
140
|
-
```
|
|
141
|
-
|
|
173
|
+
```bash
|
|
174
|
+
npx ctx-cc --force
|
|
142
175
|
```
|
|
143
176
|
|
|
144
177
|
---
|
|
145
|
-
*CTX -
|
|
178
|
+
*CTX 2.0 - 4 commands, debug loop, 100% verified*
|
|
146
179
|
</reference>
|