ctx-cc 1.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/bin/ctx.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { install } from '../src/install.js';
4
+
5
+ const args = process.argv.slice(2);
6
+ const options = {
7
+ global: args.includes('--global') || args.includes('-g'),
8
+ project: args.includes('--project') || args.includes('-p'),
9
+ force: args.includes('--force') || args.includes('-f'),
10
+ help: args.includes('--help') || args.includes('-h'),
11
+ };
12
+
13
+ if (options.help) {
14
+ console.log(`
15
+ \x1b[36m ██████╗████████╗██╗ ██╗
16
+ ██╔════╝╚══██╔══╝╚██╗██╔╝
17
+ ██║ ██║ ╚███╔╝
18
+ ██║ ██║ ██╔██╗
19
+ ╚██████╗ ██║ ██╔╝ ██╗
20
+ ╚═════╝ ╚═╝ ╚═╝ ╚═╝\x1b[0m
21
+
22
+ \x1b[1mCTX - Smart Context Management\x1b[0m
23
+ The GSD Killer. 12 commands, infinite power.
24
+
25
+ \x1b[1mUsage:\x1b[0m
26
+ npx ctx-cc [options]
27
+
28
+ \x1b[1mOptions:\x1b[0m
29
+ --global, -g Install to ~/.claude (default)
30
+ --project, -p Install to .claude in current directory
31
+ --force, -f Overwrite existing installation
32
+ --help, -h Show this help message
33
+
34
+ \x1b[1mExamples:\x1b[0m
35
+ npx ctx-cc --global Install globally
36
+ npx ctx-cc --project Install for current project only
37
+
38
+ \x1b[1mAfter Installation:\x1b[0m
39
+ Launch Claude Code and run /ctx:help
40
+ `);
41
+ process.exit(0);
42
+ }
43
+
44
+ // Default to global if no option specified
45
+ if (!options.global && !options.project) {
46
+ options.global = true;
47
+ }
48
+
49
+ install(options);
package/commands/do.md ADDED
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: ctx:do
3
+ description: Execute current phase or run a quick task
4
+ args: "[task]"
5
+ ---
6
+
7
+ <objective>
8
+ Execute the current phase's plan, OR run a quick task if an argument is provided.
9
+ </objective>
10
+
11
+ <process>
12
+
13
+ <step name="check_mode">
14
+ If argument provided (e.g., `/ctx:do "fix the login bug"`):
15
+ → Quick Task Mode
16
+
17
+ If no argument:
18
+ → Phase Execution Mode
19
+ </step>
20
+
21
+ <!-- QUICK TASK MODE -->
22
+ <step name="quick_task" condition="argument provided">
23
+ Quick task mode - bypass full workflow:
24
+
25
+ 1. Read the task description
26
+ 2. Load relevant context from memory
27
+ 3. Execute the task directly
28
+ 4. Create atomic git commit
29
+ 5. Update memory with what was done
30
+
31
+ ```
32
+ ## Quick Task
33
+
34
+ **Task:** {task description}
35
+ **Status:** In Progress
36
+
37
+ Executing without full planning workflow...
38
+ ```
39
+
40
+ Skip to `complete_task` step.
41
+ </step>
42
+
43
+ <!-- PHASE EXECUTION MODE -->
44
+ <step name="load_phase">
45
+ Load current phase from `.ctx/ROADMAP.md`:
46
+
47
+ 1. Find phase with status "in_progress" or first "pending"
48
+ 2. Load `.ctx/phases/{phase-id}/PLAN.md`
49
+ 3. Load `.ctx/phases/{phase-id}/PROGRESS.md`
50
+
51
+ If no phase found:
52
+ ```
53
+ No phase to execute. Run `/ctx:plan <goal>` first.
54
+ ```
55
+ </step>
56
+
57
+ <step name="load_context">
58
+ JIT context loading:
59
+
60
+ 1. Load relevant facts from memory
61
+ 2. Load file index for files mentioned in plan
62
+ 3. Retrieve only needed files (not entire codebase)
63
+
64
+ Target: Minimal context for current task.
65
+ </step>
66
+
67
+ <step name="execute_tasks">
68
+ For each task in PLAN.md:
69
+
70
+ 1. **Start task**
71
+ - Update PROGRESS.md: task status → "in_progress"
72
+ - Load task-specific files
73
+
74
+ 2. **Execute**
75
+ - Implement the task
76
+ - Follow deviation rules:
77
+ - Bug in existing code → Auto-fix, document
78
+ - Missing validation → Auto-add, document
79
+ - Blocking issue → Auto-fix, document
80
+ - Architectural decision → STOP, ask user
81
+
82
+ 3. **Commit**
83
+ - Atomic git commit for the task
84
+ - Message: "ctx: {task title}"
85
+
86
+ 4. **Update progress**
87
+ - Mark task complete in PROGRESS.md
88
+ - Extract facts to memory
89
+ - Check context budget
90
+
91
+ 5. **Context check**
92
+ - If context > 50%: trigger auto-checkpoint
93
+ - Signal user if split recommended
94
+ </step>
95
+
96
+ <step name="complete_task">
97
+ After task/phase completion:
98
+
99
+ ```
100
+ ## Task Complete
101
+
102
+ **Task:** {description}
103
+ **Files changed:** {list}
104
+ **Commit:** {hash}
105
+
106
+ **Context:** {percentage}%
107
+ {If > 50%: "Consider `/ctx:pause` to checkpoint."}
108
+
109
+ **Next:** {next task or "Run `/ctx:verify` to validate"}
110
+ ```
111
+ </step>
112
+
113
+ </process>
114
+
115
+ <deviation_rules>
116
+ | Rule | Trigger | Action |
117
+ |------|---------|--------|
118
+ | 1 | Bug in existing code | Auto-fix, document in commit |
119
+ | 2 | Missing validation | Auto-add, document |
120
+ | 3 | Blocking issue | Auto-fix, document |
121
+ | 4 | Architectural decision | **STOP** - ask user |
122
+ </deviation_rules>
123
+
124
+ <success_criteria>
125
+ - [ ] Task executed successfully
126
+ - [ ] Atomic git commit created
127
+ - [ ] PROGRESS.md updated
128
+ - [ ] Memory updated with facts
129
+ - [ ] Context budget monitored
130
+ </success_criteria>
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: ctx:forget
3
+ description: Remove a fact from memory
4
+ args: "<id>"
5
+ ---
6
+
7
+ <objective>
8
+ Remove a specific fact from CTX memory by its ID.
9
+ </objective>
10
+
11
+ <process>
12
+
13
+ <step name="find_fact">
14
+ Search all memory tiers for the fact ID.
15
+
16
+ If not found:
17
+ ```
18
+ Fact "{id}" not found in memory.
19
+ Use `/ctx:recall {query}` to find fact IDs.
20
+ ```
21
+ </step>
22
+
23
+ <step name="confirm">
24
+ Show the fact before removal:
25
+
26
+ ```
27
+ ## Forget Fact
28
+
29
+ **ID:** {id}
30
+ **Content:** {fact}
31
+ **Category:** {category}
32
+ **Stored:** {timestamp}
33
+
34
+ Are you sure you want to remove this fact?
35
+ This cannot be undone.
36
+ ```
37
+ </step>
38
+
39
+ <step name="remove">
40
+ Delete the fact from its memory tier.
41
+
42
+ ```
43
+ ## Fact Forgotten
44
+
45
+ **ID:** {id}
46
+ **Content:** {fact}
47
+
48
+ Removed from {tier} memory.
49
+ ```
50
+ </step>
51
+
52
+ </process>
53
+
54
+ <success_criteria>
55
+ - [ ] Fact located by ID
56
+ - [ ] Confirmation shown
57
+ - [ ] Fact removed from correct tier
58
+ </success_criteria>
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: ctx:help
3
+ description: Show CTX commands and usage guide
4
+ ---
5
+
6
+ <objective>
7
+ Display the complete CTX command reference.
8
+
9
+ Output ONLY the reference content below. Do NOT add project-specific analysis or suggestions.
10
+ </objective>
11
+
12
+ <reference>
13
+ # CTX Command Reference
14
+
15
+ **CTX** (Context) is a smart context management system for Claude Code.
16
+ 12 commands. Infinite power.
17
+
18
+ ## Quick Start
19
+
20
+ ```
21
+ 1. /ctx:init Initialize project
22
+ 2. /ctx:plan <goal> Research + Plan automatically
23
+ 3. /ctx:do Execute phase
24
+ 4. (repeat 2-3 for each phase)
25
+ 5. /ctx:ship Final audit
26
+ ```
27
+
28
+ ## Why CTX?
29
+
30
+ | Aspect | GSD | CTX |
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 |
38
+
39
+ ## Core Workflow
40
+
41
+ **`/ctx:init`**
42
+ Initialize project. Detects tech stack, maps codebase, creates PROJECT.md.
43
+
44
+ **`/ctx:plan <goal>`**
45
+ Research + Plan automatically. Uses ArguSeek for web research and ChunkHound for semantic code search.
46
+
47
+ **`/ctx:do [task]`**
48
+ Execute current phase, or run a quick task if argument provided.
49
+ - `/ctx:do` - Execute current phase
50
+ - `/ctx:do "fix the login bug"` - Quick task (bypasses workflow)
51
+
52
+ **`/ctx:verify`**
53
+ Three-level verification:
54
+ 1. Exists - Is file on disk?
55
+ 2. Substantive - Real code, not stub?
56
+ 3. Wired - Imported and used?
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.
67
+
68
+ **`/ctx:phase list`**
69
+ Show all phases with status.
70
+
71
+ **`/ctx:phase next`**
72
+ Move to the next phase.
73
+
74
+ ## Memory
75
+
76
+ **`/ctx:remember <fact>`**
77
+ Force-remember something important.
78
+
79
+ **`/ctx:recall <query>`**
80
+ Query memory for relevant facts.
81
+
82
+ **`/ctx:forget <id>`**
83
+ Remove a fact from memory.
84
+
85
+ ## Session Control
86
+
87
+ **`/ctx:pause`**
88
+ Create checkpoint with handoff notes. Safe to close session.
89
+
90
+ **`/ctx:resume`**
91
+ Resume from last checkpoint. Restores full context in ~2-3k tokens.
92
+
93
+ **`/ctx:status`**
94
+ Full status report: project, phase, progress, context usage, todos.
95
+
96
+ ## Integrations
97
+
98
+ ### ArguSeek (Web Research)
99
+ Auto-generates research queries during `/ctx:plan`:
100
+ - Best practices for the goal
101
+ - Security considerations
102
+ - Performance optimization
103
+ - Error handling patterns
104
+
105
+ ### ChunkHound (Semantic Code Search)
106
+ Auto-runs during `/ctx:plan`:
107
+ - Semantic search for goal-relevant code
108
+ - Pattern detection
109
+ - Entry point mapping
110
+
111
+ Install: `uv tool install chunkhound`
112
+
113
+ ## Directory Structure
114
+
115
+ ```
116
+ .ctx/
117
+ ├── PROJECT.md # Project definition
118
+ ├── ROADMAP.md # Phase roadmap
119
+ ├── config.json # Settings
120
+ ├── phases/{id}/ # Phase data
121
+ │ ├── RESEARCH.md # ArguSeek + ChunkHound results
122
+ │ ├── PLAN.md # Task breakdown
123
+ │ ├── PROGRESS.md # Execution state
124
+ │ └── VERIFY.md # Verification report
125
+ ├── memory/ # Hierarchical memory
126
+ ├── checkpoints/ # Auto-checkpoints
127
+ └── todos/ # Task management
128
+ ```
129
+
130
+ ## Context Budget
131
+
132
+ | Usage | Quality | Action |
133
+ |-------|---------|--------|
134
+ | 0-30% | Peak | Continue |
135
+ | 30-50% | Good | Continue |
136
+ | 50%+ | Degrading | Auto-checkpoint |
137
+
138
+ ## Updating CTX
139
+
140
+ ```
141
+ /ctx:update
142
+ ```
143
+
144
+ ---
145
+ *CTX - 12 commands, infinite power*
146
+ </reference>
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: ctx:init
3
+ description: Initialize CTX project with tech detection and codebase mapping
4
+ ---
5
+
6
+ <objective>
7
+ Initialize a new CTX project. Detect tech stack, map codebase structure, create PROJECT.md and initial ROADMAP.md.
8
+ </objective>
9
+
10
+ <process>
11
+
12
+ <step name="detect_tech_stack">
13
+ Scan the project to detect:
14
+ - Package managers: package.json, Cargo.toml, go.mod, requirements.txt, etc.
15
+ - Frameworks: React, Next.js, FastAPI, Express, etc.
16
+ - Languages: TypeScript, Python, Go, Rust, etc.
17
+ - Build tools: Webpack, Vite, esbuild, etc.
18
+ </step>
19
+
20
+ <step name="create_ctx_directory">
21
+ Create `.ctx/` directory structure:
22
+
23
+ ```
24
+ .ctx/
25
+ ├── PROJECT.md
26
+ ├── ROADMAP.md
27
+ ├── config.json
28
+ ├── phases/
29
+ ├── memory/
30
+ │ ├── working/
31
+ │ ├── episodic/
32
+ │ └── semantic/
33
+ ├── checkpoints/
34
+ └── todos/
35
+ ```
36
+ </step>
37
+
38
+ <step name="map_codebase">
39
+ If this is an existing codebase (not empty), analyze:
40
+ - Entry points (main files, index files)
41
+ - Key directories and their purposes
42
+ - Architectural patterns used
43
+ - Important dependencies
44
+
45
+ Use ChunkHound if available:
46
+ ```bash
47
+ chunkhound index .
48
+ ```
49
+ </step>
50
+
51
+ <step name="create_project_md">
52
+ Write `.ctx/PROJECT.md`:
53
+
54
+ ```markdown
55
+ # Project: {name}
56
+
57
+ ## Tech Stack
58
+ - Language: {detected}
59
+ - Framework: {detected}
60
+ - Build: {detected}
61
+
62
+ ## Architecture
63
+ {brief description from codebase mapping}
64
+
65
+ ## Entry Points
66
+ - {list of main files}
67
+
68
+ ## Key Patterns
69
+ - {patterns identified}
70
+
71
+ ## Initialized
72
+ {timestamp}
73
+ ```
74
+ </step>
75
+
76
+ <step name="create_config">
77
+ Write `.ctx/config.json`:
78
+
79
+ ```json
80
+ {
81
+ "version": "1.0.0",
82
+ "initialized": "{timestamp}",
83
+ "techStack": {
84
+ "language": "{detected}",
85
+ "framework": "{detected}",
86
+ "buildTool": "{detected}"
87
+ },
88
+ "integrations": {
89
+ "arguseek": true,
90
+ "chunkhound": true
91
+ },
92
+ "contextBudget": 50
93
+ }
94
+ ```
95
+ </step>
96
+
97
+ <step name="ask_goal">
98
+ Ask the user:
99
+
100
+ "Project initialized! What's your goal for this project?"
101
+
102
+ Based on their answer, create initial `.ctx/ROADMAP.md` with Phase 1.
103
+ </step>
104
+
105
+ </process>
106
+
107
+ <output>
108
+ ```
109
+ ## CTX Initialized
110
+
111
+ **Project:** {name}
112
+ **Tech Stack:** {language} + {framework}
113
+ **Integrations:**
114
+ - ArguSeek: {available/not available}
115
+ - ChunkHound: {indexed/not available}
116
+
117
+ **Files Created:**
118
+ - .ctx/PROJECT.md
119
+ - .ctx/ROADMAP.md
120
+ - .ctx/config.json
121
+
122
+ **Next:** Run `/ctx:plan <goal>` to start your first phase.
123
+ ```
124
+ </output>
125
+
126
+ <success_criteria>
127
+ - [ ] Tech stack detected correctly
128
+ - [ ] .ctx/ directory created
129
+ - [ ] PROJECT.md written with accurate info
130
+ - [ ] ChunkHound index attempted if available
131
+ - [ ] User asked for project goal
132
+ </success_criteria>
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: ctx:pause
3
+ description: Create checkpoint with handoff notes
4
+ ---
5
+
6
+ <objective>
7
+ Create a checkpoint of current state for seamless session resumption. Captures all context needed to continue later.
8
+ </objective>
9
+
10
+ <process>
11
+
12
+ <step name="capture_state">
13
+ Capture current state:
14
+
15
+ 1. **Active phase** - Which phase, which task
16
+ 2. **Progress** - What's done, what's pending
17
+ 3. **Working memory** - Recent facts and decisions
18
+ 4. **File state** - Files being worked on
19
+ 5. **Context usage** - Current percentage
20
+ </step>
21
+
22
+ <step name="generate_handoff">
23
+ Create handoff notes:
24
+
25
+ ```markdown
26
+ # Checkpoint: {timestamp}
27
+
28
+ ## Context
29
+ **Phase:** {phase name}
30
+ **Task:** {current task or "between tasks"}
31
+ **Progress:** {percentage}%
32
+
33
+ ## What Was Done
34
+ - {completed item 1}
35
+ - {completed item 2}
36
+
37
+ ## What's Next
38
+ - {next task}
39
+ - {considerations}
40
+
41
+ ## Key Decisions Made
42
+ - {decision 1}
43
+ - {decision 2}
44
+
45
+ ## Open Questions
46
+ - {question if any}
47
+
48
+ ## Files in Progress
49
+ - {file 1}: {state}
50
+ - {file 2}: {state}
51
+ ```
52
+ </step>
53
+
54
+ <step name="save_checkpoint">
55
+ Save to `.ctx/checkpoints/{checkpoint-id}/`:
56
+
57
+ ```
58
+ .ctx/checkpoints/{id}/
59
+ ├── HANDOFF.md # Human-readable summary
60
+ ├── state.json # Machine-readable state
61
+ ├── working-memory.json # Current session memory
62
+ └── file-index.json # Relevant files
63
+ ```
64
+ </step>
65
+
66
+ <step name="commit_checkpoint">
67
+ Create git commit for checkpoint:
68
+
69
+ ```bash
70
+ git add .ctx/
71
+ git commit -m "ctx: checkpoint {id} - {phase name}"
72
+ ```
73
+ </step>
74
+
75
+ <step name="output">
76
+ ```
77
+ ## Checkpoint Created
78
+
79
+ **ID:** {checkpoint-id}
80
+ **Phase:** {phase name}
81
+ **Progress:** {percentage}%
82
+ **Context:** {context percentage}%
83
+
84
+ **Handoff Summary:**
85
+ {brief summary}
86
+
87
+ **Resume Command:**
88
+ ```
89
+ /ctx:resume
90
+ ```
91
+
92
+ Safe to close this session. State preserved.
93
+ ```
94
+ </step>
95
+
96
+ </process>
97
+
98
+ <success_criteria>
99
+ - [ ] State fully captured
100
+ - [ ] Handoff notes generated
101
+ - [ ] Checkpoint saved to .ctx/checkpoints/
102
+ - [ ] Git commit created
103
+ - [ ] Resume instructions provided
104
+ </success_criteria>
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: ctx:phase-add
3
+ description: Add a new phase to the roadmap
4
+ args: "<name>"
5
+ ---
6
+
7
+ <objective>
8
+ Add a new phase to the project roadmap.
9
+ </objective>
10
+
11
+ <process>
12
+
13
+ <step name="validate">
14
+ Check `.ctx/ROADMAP.md` exists. If not:
15
+ ```
16
+ CTX not initialized. Run `/ctx:init` first.
17
+ ```
18
+ </step>
19
+
20
+ <step name="get_details">
21
+ Ask user for phase details:
22
+
23
+ 1. **Goal**: What should this phase achieve?
24
+ 2. **Priority**: Where in the roadmap? (next, end, after phase X)
25
+ </step>
26
+
27
+ <step name="create_phase">
28
+ 1. Generate phase ID from name (slugified)
29
+ 2. Create phase directory: `.ctx/phases/{phase-id}/`
30
+ 3. Add to ROADMAP.md in specified position
31
+ 4. Set status to "pending"
32
+ </step>
33
+
34
+ <step name="output">
35
+ ```
36
+ ## Phase Added
37
+
38
+ **Name:** {name}
39
+ **ID:** {phase-id}
40
+ **Position:** #{position} in roadmap
41
+ **Status:** pending
42
+
43
+ **Next:** Run `/ctx:plan {name}` to create the plan.
44
+ ```
45
+ </step>
46
+
47
+ </process>
48
+
49
+ <success_criteria>
50
+ - [ ] Phase added to ROADMAP.md
51
+ - [ ] Phase directory created
52
+ - [ ] Position correct in roadmap
53
+ </success_criteria>
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: ctx:phase-list
3
+ description: Show all phases with status
4
+ ---
5
+
6
+ <objective>
7
+ Display all phases in the roadmap with their current status.
8
+ </objective>
9
+
10
+ <process>
11
+
12
+ <step name="load_roadmap">
13
+ Read `.ctx/ROADMAP.md` and parse phases.
14
+
15
+ If not found:
16
+ ```
17
+ CTX not initialized. Run `/ctx:init` first.
18
+ ```
19
+ </step>
20
+
21
+ <step name="display_phases">
22
+ ```
23
+ ## Project Phases
24
+
25
+ | # | Phase | Status | Progress | Verified |
26
+ |---|-------|--------|----------|----------|
27
+ | 1 | {name} | complete | 100% | ✓ |
28
+ | 2 | {name} | in_progress | 60% | - |
29
+ | 3 | {name} | pending | 0% | - |
30
+
31
+ **Current:** Phase 2 - {name}
32
+ **Remaining:** {count} phases
33
+
34
+ **Next action:**
35
+ - If current incomplete: `/ctx:do`
36
+ - If current done: `/ctx:verify` then `/ctx:phase next`
37
+ ```
38
+ </step>
39
+
40
+ </process>
41
+
42
+ <success_criteria>
43
+ - [ ] All phases listed with accurate status
44
+ - [ ] Current phase highlighted
45
+ - [ ] Next action suggested
46
+ </success_criteria>