ctx-cc 2.3.0 → 3.1.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 +369 -223
- package/agents/ctx-arch-mapper.md +296 -0
- package/agents/ctx-concerns-mapper.md +359 -0
- package/agents/ctx-criteria-suggester.md +358 -0
- package/agents/ctx-debugger.md +428 -207
- package/agents/ctx-discusser.md +287 -0
- package/agents/ctx-executor.md +287 -75
- package/agents/ctx-handoff.md +379 -0
- package/agents/ctx-mapper.md +309 -0
- package/agents/ctx-parallelizer.md +351 -0
- package/agents/ctx-quality-mapper.md +356 -0
- package/agents/ctx-reviewer.md +366 -0
- package/agents/ctx-tech-mapper.md +163 -0
- package/commands/ctx.md +94 -19
- package/commands/discuss.md +101 -0
- package/commands/integrate.md +422 -0
- package/commands/map-codebase.md +169 -0
- package/commands/map.md +88 -0
- package/commands/profile.md +131 -0
- package/package.json +2 -2
- package/templates/config.json +210 -0
package/commands/ctx.md
CHANGED
|
@@ -1,55 +1,84 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ctx
|
|
3
|
-
description: Smart router - reads STATE.md and does the right thing
|
|
3
|
+
description: Smart router - reads STATE.md, config.json, and does the right thing. Uses model profiles for cost optimization.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<objective>
|
|
7
|
-
CTX
|
|
7
|
+
CTX 3.0 Smart Router - One command that always knows what to do next.
|
|
8
8
|
|
|
9
|
-
Read STATE.md,
|
|
9
|
+
Read STATE.md, load config.json, use appropriate model profile, and execute the right action.
|
|
10
10
|
</objective>
|
|
11
11
|
|
|
12
12
|
<workflow>
|
|
13
|
+
## Step 0: Load Configuration
|
|
14
|
+
|
|
15
|
+
Read `.ctx/config.json` for:
|
|
16
|
+
- Active profile (quality/balanced/budget)
|
|
17
|
+
- Model routing table
|
|
18
|
+
- Git settings (autoCommit, commitPerTask)
|
|
19
|
+
- Integration settings
|
|
20
|
+
|
|
21
|
+
If config.json doesn't exist:
|
|
22
|
+
- Copy from templates/config.json
|
|
23
|
+
- Set balanced as default profile
|
|
24
|
+
|
|
13
25
|
## Step 1: Read State
|
|
26
|
+
|
|
14
27
|
Read `.ctx/STATE.md` to understand current situation.
|
|
15
28
|
|
|
16
29
|
If STATE.md doesn't exist:
|
|
17
30
|
- Output: "No CTX project found. Run `/ctx init` to start."
|
|
18
31
|
- Stop.
|
|
19
32
|
|
|
33
|
+
Also check for:
|
|
34
|
+
- `.ctx/REPO-MAP.md` - Codebase understanding
|
|
35
|
+
- `.ctx/codebase/SUMMARY.md` - Deep codebase analysis
|
|
36
|
+
- `.ctx/phases/{story_id}/CONTEXT.md` - Locked decisions
|
|
37
|
+
|
|
20
38
|
## Step 2: Route Based on State
|
|
21
39
|
|
|
22
40
|
### If status = "initializing"
|
|
23
41
|
Route to: **Research Phase**
|
|
24
|
-
1.
|
|
25
|
-
2. Use
|
|
42
|
+
1. Check if REPO-MAP exists, if not run ctx-mapper
|
|
43
|
+
2. Use ArguSeek to research the project goal
|
|
26
44
|
3. Create atomic plan (2-3 tasks max)
|
|
27
45
|
4. Update STATE.md with plan
|
|
28
|
-
5. Set status = "
|
|
46
|
+
5. Set status = "discussing"
|
|
47
|
+
|
|
48
|
+
### If status = "discussing"
|
|
49
|
+
Route to: **Discussion Phase**
|
|
50
|
+
1. Spawn ctx-discusser agent
|
|
51
|
+
2. Ask targeted questions about gray areas
|
|
52
|
+
3. Lock decisions in CONTEXT.md
|
|
53
|
+
4. Set status = "executing"
|
|
29
54
|
|
|
30
55
|
### If status = "executing"
|
|
31
56
|
Route to: **Execute Current Task**
|
|
32
57
|
1. Read current task from STATE.md
|
|
33
|
-
2.
|
|
34
|
-
3.
|
|
58
|
+
2. Load REPO-MAP for context
|
|
59
|
+
3. Spawn ctx-executor agent (uses git-native workflow)
|
|
60
|
+
4. Execute task with deviation handling:
|
|
35
61
|
- Auto-fix: bugs, validation, deps (95%)
|
|
36
62
|
- Ask user: architecture decisions only (5%)
|
|
37
|
-
|
|
63
|
+
5. After task:
|
|
38
64
|
- Run verification (build, tests, lint)
|
|
65
|
+
- Auto-commit if config allows
|
|
39
66
|
- If passes: mark done, update STATE.md
|
|
40
67
|
- If fails: set status = "debugging"
|
|
41
68
|
|
|
42
69
|
### If status = "debugging"
|
|
43
|
-
Route to: **Debug Loop**
|
|
70
|
+
Route to: **Persistent Debug Loop**
|
|
44
71
|
1. Spawn ctx-debugger agent
|
|
45
|
-
2.
|
|
72
|
+
2. Check for existing debug session (resume if exists)
|
|
73
|
+
3. Loop until fixed (max 10 attempts):
|
|
46
74
|
- Analyze error
|
|
47
75
|
- Form hypothesis
|
|
48
76
|
- Apply fix
|
|
49
77
|
- Verify (build + tests + browser if UI)
|
|
78
|
+
- Record in persistent state
|
|
50
79
|
- Take screenshot proof if browser test
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
4. If fixed: set status = "executing", continue
|
|
81
|
+
5. If max attempts: escalate with full report
|
|
53
82
|
|
|
54
83
|
### If status = "verifying"
|
|
55
84
|
Route to: **Three-Level Verification**
|
|
@@ -69,39 +98,83 @@ Route to: **Resume**
|
|
|
69
98
|
3. Set status to previous state
|
|
70
99
|
4. Continue workflow
|
|
71
100
|
|
|
72
|
-
## Step 3:
|
|
101
|
+
## Step 3: Model Selection
|
|
102
|
+
|
|
103
|
+
Based on current action and active profile:
|
|
104
|
+
|
|
105
|
+
| Action | quality | balanced | budget |
|
|
106
|
+
|--------|---------|----------|--------|
|
|
107
|
+
| Research | opus | opus | sonnet |
|
|
108
|
+
| Discussion | opus | sonnet | sonnet |
|
|
109
|
+
| Planning | opus | opus | sonnet |
|
|
110
|
+
| Execution | opus | sonnet | sonnet |
|
|
111
|
+
| Debugging | opus | sonnet | sonnet |
|
|
112
|
+
| Verification | sonnet | haiku | haiku |
|
|
113
|
+
| Mapping | sonnet | haiku | haiku |
|
|
114
|
+
|
|
115
|
+
Use Task tool with `model` parameter from routing table.
|
|
116
|
+
|
|
117
|
+
## Step 4: Context Budget Check
|
|
118
|
+
|
|
73
119
|
After every action:
|
|
74
120
|
- Calculate context usage
|
|
121
|
+
- If > 40%: Prepare handoff notes
|
|
75
122
|
- If > 50%: Auto-checkpoint, warn user
|
|
123
|
+
- If > 60%: Create HANDOFF.md, spawn fresh agent
|
|
76
124
|
- If > 70%: Force checkpoint
|
|
77
125
|
|
|
78
|
-
## Step
|
|
126
|
+
## Step 5: Git-Native Commit
|
|
127
|
+
|
|
128
|
+
If task completed successfully AND config.git.autoCommit = true:
|
|
129
|
+
1. Stage modified files
|
|
130
|
+
2. Create commit with CTX format
|
|
131
|
+
3. Record commit hash in STATE.md
|
|
132
|
+
|
|
133
|
+
## Step 6: Update State
|
|
134
|
+
|
|
79
135
|
Always update STATE.md after any action:
|
|
80
136
|
- Current status
|
|
81
137
|
- Progress
|
|
138
|
+
- Recent commits
|
|
82
139
|
- Recent decisions
|
|
83
140
|
- Next action
|
|
141
|
+
- Context usage
|
|
84
142
|
</workflow>
|
|
85
143
|
|
|
86
144
|
<state_transitions>
|
|
87
145
|
```
|
|
88
|
-
initializing →
|
|
146
|
+
initializing → discussing (after research)
|
|
147
|
+
discussing → executing (after decisions locked)
|
|
89
148
|
executing → debugging (if verification fails)
|
|
90
149
|
executing → verifying (if all tasks done)
|
|
91
150
|
debugging → executing (if fix works)
|
|
92
|
-
debugging → ESCALATE (if
|
|
151
|
+
debugging → ESCALATE (if max attempts fail)
|
|
93
152
|
verifying → executing (if anti-patterns found)
|
|
94
153
|
verifying → COMPLETE (if all passes)
|
|
95
154
|
paused → (previous state)
|
|
96
155
|
```
|
|
97
156
|
</state_transitions>
|
|
98
157
|
|
|
158
|
+
<new_commands>
|
|
159
|
+
## New in CTX 3.0
|
|
160
|
+
|
|
161
|
+
| Command | Purpose |
|
|
162
|
+
|---------|---------|
|
|
163
|
+
| `/ctx map` | Build repository map (REPO-MAP.md) |
|
|
164
|
+
| `/ctx map-codebase` | Deep codebase analysis (4 parallel agents) |
|
|
165
|
+
| `/ctx discuss [story]` | Run discussion phase for story |
|
|
166
|
+
| `/ctx profile [name]` | Switch model profile |
|
|
167
|
+
| `/ctx debug --resume` | Resume previous debug session |
|
|
168
|
+
</new_commands>
|
|
169
|
+
|
|
99
170
|
<context_budget>
|
|
100
171
|
| Usage | Quality | Action |
|
|
101
172
|
|-------|---------|--------|
|
|
102
173
|
| 0-30% | Peak | Continue |
|
|
103
|
-
| 30-
|
|
104
|
-
| 50
|
|
174
|
+
| 30-40% | Good | Continue |
|
|
175
|
+
| 40-50% | Good | Prepare handoff |
|
|
176
|
+
| 50-60% | Degrading | Auto-checkpoint |
|
|
177
|
+
| 60-70% | Degrading | Create HANDOFF.md |
|
|
105
178
|
| 70%+ | Poor | Force checkpoint |
|
|
106
179
|
</context_budget>
|
|
107
180
|
|
|
@@ -109,7 +182,9 @@ paused → (previous state)
|
|
|
109
182
|
After routing, output:
|
|
110
183
|
```
|
|
111
184
|
[CTX] Status: {{status}}
|
|
185
|
+
[CTX] Profile: {{profile}} ({{costTier}})
|
|
112
186
|
[CTX] Action: {{action_taken}}
|
|
187
|
+
[CTX] Commit: {{commit_hash}} (if auto-committed)
|
|
113
188
|
[CTX] Next: {{next_action}}
|
|
114
189
|
[CTX] Context: {{percent}}% ({{quality}})
|
|
115
190
|
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx:discuss
|
|
3
|
+
description: Capture implementation decisions before planning. Resolves ambiguities and locks decisions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Identify gray areas in a story and capture implementation decisions BEFORE planning.
|
|
8
|
+
|
|
9
|
+
This prevents wasted work from misaligned assumptions.
|
|
10
|
+
</objective>
|
|
11
|
+
|
|
12
|
+
<usage>
|
|
13
|
+
```
|
|
14
|
+
/ctx discuss # Discuss current story from PRD.json
|
|
15
|
+
/ctx discuss S002 # Discuss specific story
|
|
16
|
+
/ctx discuss --review # Review existing decisions
|
|
17
|
+
```
|
|
18
|
+
</usage>
|
|
19
|
+
|
|
20
|
+
<workflow>
|
|
21
|
+
|
|
22
|
+
## Step 1: Load Story
|
|
23
|
+
|
|
24
|
+
If story ID provided:
|
|
25
|
+
- Read that story from `.ctx/PRD.json`
|
|
26
|
+
|
|
27
|
+
If no story ID:
|
|
28
|
+
- Read `metadata.currentStory` from PRD.json
|
|
29
|
+
- Use that story
|
|
30
|
+
|
|
31
|
+
If no PRD.json:
|
|
32
|
+
- Output: "No PRD found. Run `/ctx init` first."
|
|
33
|
+
- Stop
|
|
34
|
+
|
|
35
|
+
## Step 2: Check Existing Discussion
|
|
36
|
+
|
|
37
|
+
If `.ctx/phases/{story_id}/CONTEXT.md` exists:
|
|
38
|
+
- If `--review` flag: Show existing decisions
|
|
39
|
+
- Otherwise: Ask "Discussion exists. Redo? (will overwrite)"
|
|
40
|
+
|
|
41
|
+
## Step 3: Spawn Discusser Agent
|
|
42
|
+
|
|
43
|
+
Spawn `ctx-discusser` agent with:
|
|
44
|
+
- Story details from PRD.json
|
|
45
|
+
- Project context from STATE.md
|
|
46
|
+
- Repo map from REPO-MAP.md (if exists)
|
|
47
|
+
|
|
48
|
+
Agent will:
|
|
49
|
+
1. Analyze story for gray areas
|
|
50
|
+
2. Formulate targeted questions
|
|
51
|
+
3. Ask user via AskUserQuestion
|
|
52
|
+
4. Write CONTEXT.md with decisions
|
|
53
|
+
|
|
54
|
+
## Step 4: Validate Output
|
|
55
|
+
|
|
56
|
+
Ensure:
|
|
57
|
+
- `.ctx/phases/{story_id}/CONTEXT.md` exists
|
|
58
|
+
- Contains all required sections
|
|
59
|
+
- No unresolved questions (or explicitly noted)
|
|
60
|
+
|
|
61
|
+
## Step 5: Update State
|
|
62
|
+
|
|
63
|
+
Update `.ctx/STATE.md`:
|
|
64
|
+
- Set discussion status to complete
|
|
65
|
+
- Add key decisions to "Recent Decisions"
|
|
66
|
+
- Set next action to "Run /ctx plan"
|
|
67
|
+
|
|
68
|
+
</workflow>
|
|
69
|
+
|
|
70
|
+
<output_format>
|
|
71
|
+
```
|
|
72
|
+
[CTX] Discussion: Story {id} - {title}
|
|
73
|
+
|
|
74
|
+
Questions Asked: {{count}}
|
|
75
|
+
Decisions Captured: {{count}}
|
|
76
|
+
|
|
77
|
+
Key Decisions:
|
|
78
|
+
- Auth: {{decision}}
|
|
79
|
+
- UI: {{decision}}
|
|
80
|
+
- Data: {{decision}}
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
Saved to: .ctx/phases/{story_id}/CONTEXT.md
|
|
84
|
+
|
|
85
|
+
Next: Run /ctx plan (or /ctx to auto-route)
|
|
86
|
+
```
|
|
87
|
+
</output_format>
|
|
88
|
+
|
|
89
|
+
<when_to_use>
|
|
90
|
+
**Always use before planning when:**
|
|
91
|
+
- Story has UI components (layout decisions needed)
|
|
92
|
+
- Story involves new data models (schema decisions)
|
|
93
|
+
- Story has security implications (auth, encryption)
|
|
94
|
+
- Story touches external integrations
|
|
95
|
+
- Story requirements are vague
|
|
96
|
+
|
|
97
|
+
**Can skip when:**
|
|
98
|
+
- Story is purely technical (refactor, optimization)
|
|
99
|
+
- All decisions are already documented
|
|
100
|
+
- Story is a simple bug fix with clear solution
|
|
101
|
+
</when_to_use>
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctx:integrate
|
|
3
|
+
description: Setup and manage issue tracker integrations (Linear, Jira, GitHub Issues). Sync stories between PRD.json and external tools.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
Connect CTX to external issue trackers for bidirectional story sync.
|
|
8
|
+
|
|
9
|
+
When integrated:
|
|
10
|
+
- Stories in PRD.json sync to issue tracker
|
|
11
|
+
- Status updates reflect in both systems
|
|
12
|
+
- Verification pass → close issue
|
|
13
|
+
- Verification fail → add comment with details
|
|
14
|
+
</objective>
|
|
15
|
+
|
|
16
|
+
<usage>
|
|
17
|
+
```
|
|
18
|
+
/ctx integrate # Show current integrations
|
|
19
|
+
/ctx integrate linear # Setup Linear integration
|
|
20
|
+
/ctx integrate jira # Setup Jira integration
|
|
21
|
+
/ctx integrate github # Setup GitHub Issues integration
|
|
22
|
+
/ctx integrate --sync # Force sync all stories
|
|
23
|
+
/ctx integrate --disconnect # Remove integration
|
|
24
|
+
```
|
|
25
|
+
</usage>
|
|
26
|
+
|
|
27
|
+
<supported_integrations>
|
|
28
|
+
|
|
29
|
+
## Linear
|
|
30
|
+
|
|
31
|
+
**Best for**: Startups, modern teams, API-first workflows
|
|
32
|
+
|
|
33
|
+
**Features**:
|
|
34
|
+
- Automatic story → issue sync
|
|
35
|
+
- Status mapping (CTX status → Linear status)
|
|
36
|
+
- Label sync (story type → Linear labels)
|
|
37
|
+
- Cycle/sprint assignment
|
|
38
|
+
- Comment sync on verify fail
|
|
39
|
+
|
|
40
|
+
**Setup**:
|
|
41
|
+
```bash
|
|
42
|
+
/ctx integrate linear
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Prompts for:
|
|
46
|
+
1. API Key (from Linear settings)
|
|
47
|
+
2. Team ID (workspace identifier)
|
|
48
|
+
3. Default project (optional)
|
|
49
|
+
4. Status mapping preferences
|
|
50
|
+
|
|
51
|
+
**Config** (`.ctx/config.json`):
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"integrations": {
|
|
55
|
+
"linear": {
|
|
56
|
+
"enabled": true,
|
|
57
|
+
"apiKey": "env:LINEAR_API_KEY",
|
|
58
|
+
"teamId": "TEAM-123",
|
|
59
|
+
"projectId": "PROJECT-456",
|
|
60
|
+
"syncOnCreate": true,
|
|
61
|
+
"syncOnVerify": true,
|
|
62
|
+
"statusMapping": {
|
|
63
|
+
"pending": "Todo",
|
|
64
|
+
"executing": "In Progress",
|
|
65
|
+
"verifying": "In Review",
|
|
66
|
+
"complete": "Done"
|
|
67
|
+
},
|
|
68
|
+
"typeLabels": {
|
|
69
|
+
"feature": "feature",
|
|
70
|
+
"bug": "bug",
|
|
71
|
+
"design": "design"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Jira
|
|
79
|
+
|
|
80
|
+
**Best for**: Enterprise, existing Jira workflows
|
|
81
|
+
|
|
82
|
+
**Features**:
|
|
83
|
+
- Story → Issue sync
|
|
84
|
+
- Custom field mapping
|
|
85
|
+
- Sprint assignment
|
|
86
|
+
- Transition on status change
|
|
87
|
+
- Attachment support (screenshots)
|
|
88
|
+
|
|
89
|
+
**Setup**:
|
|
90
|
+
```bash
|
|
91
|
+
/ctx integrate jira
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Prompts for:
|
|
95
|
+
1. Jira URL (https://your-domain.atlassian.net)
|
|
96
|
+
2. API Token (from Atlassian account)
|
|
97
|
+
3. Project Key (e.g., "PROJ")
|
|
98
|
+
4. Issue type (Story, Task, etc.)
|
|
99
|
+
|
|
100
|
+
**Config**:
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"integrations": {
|
|
104
|
+
"jira": {
|
|
105
|
+
"enabled": true,
|
|
106
|
+
"baseUrl": "https://your-domain.atlassian.net",
|
|
107
|
+
"email": "env:JIRA_EMAIL",
|
|
108
|
+
"apiToken": "env:JIRA_API_TOKEN",
|
|
109
|
+
"projectKey": "PROJ",
|
|
110
|
+
"issueType": "Story",
|
|
111
|
+
"syncOnCreate": true,
|
|
112
|
+
"syncOnVerify": true,
|
|
113
|
+
"customFields": {
|
|
114
|
+
"acceptanceCriteria": "customfield_10001"
|
|
115
|
+
},
|
|
116
|
+
"transitionMapping": {
|
|
117
|
+
"executing": "In Progress",
|
|
118
|
+
"verifying": "In Review",
|
|
119
|
+
"complete": "Done"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## GitHub Issues
|
|
127
|
+
|
|
128
|
+
**Best for**: Open source, GitHub-centric workflows
|
|
129
|
+
|
|
130
|
+
**Features**:
|
|
131
|
+
- Story → Issue sync
|
|
132
|
+
- Label management
|
|
133
|
+
- Milestone assignment
|
|
134
|
+
- Link to commits/PRs
|
|
135
|
+
- Close on verify pass
|
|
136
|
+
|
|
137
|
+
**Setup**:
|
|
138
|
+
```bash
|
|
139
|
+
/ctx integrate github
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Prompts for:
|
|
143
|
+
1. Repository (owner/repo format)
|
|
144
|
+
2. GitHub token (uses existing gh auth if available)
|
|
145
|
+
3. Label preferences
|
|
146
|
+
|
|
147
|
+
**Config**:
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"integrations": {
|
|
151
|
+
"github": {
|
|
152
|
+
"enabled": true,
|
|
153
|
+
"repository": "owner/repo",
|
|
154
|
+
"token": "env:GITHUB_TOKEN",
|
|
155
|
+
"syncOnCreate": true,
|
|
156
|
+
"syncOnVerify": true,
|
|
157
|
+
"closeOnComplete": true,
|
|
158
|
+
"labels": {
|
|
159
|
+
"feature": "enhancement",
|
|
160
|
+
"bug": "bug",
|
|
161
|
+
"design": "design"
|
|
162
|
+
},
|
|
163
|
+
"milestoneFromPhase": true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
</supported_integrations>
|
|
170
|
+
|
|
171
|
+
<workflow>
|
|
172
|
+
|
|
173
|
+
## Step 1: Check Existing Integration
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
cat .ctx/config.json | jq '.integrations'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
If integration exists, show status:
|
|
180
|
+
```
|
|
181
|
+
[CTX] Integration Status
|
|
182
|
+
|
|
183
|
+
Linear: ✅ Connected
|
|
184
|
+
Team: Engineering
|
|
185
|
+
Stories synced: 12
|
|
186
|
+
Last sync: 2 minutes ago
|
|
187
|
+
|
|
188
|
+
GitHub: ❌ Not configured
|
|
189
|
+
Jira: ❌ Not configured
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Step 2: Setup New Integration
|
|
193
|
+
|
|
194
|
+
### For Linear:
|
|
195
|
+
```
|
|
196
|
+
[CTX] Linear Integration Setup
|
|
197
|
+
|
|
198
|
+
1. Get your API key from: https://linear.app/settings/api
|
|
199
|
+
|
|
200
|
+
2. Enter API Key: **********************
|
|
201
|
+
|
|
202
|
+
3. Fetching teams...
|
|
203
|
+
Found teams:
|
|
204
|
+
[1] Engineering (ENG)
|
|
205
|
+
[2] Product (PRD)
|
|
206
|
+
|
|
207
|
+
Select team: 1
|
|
208
|
+
|
|
209
|
+
4. Fetching projects...
|
|
210
|
+
Found projects:
|
|
211
|
+
[1] CTX Development
|
|
212
|
+
[2] Website Redesign
|
|
213
|
+
[3] No project (team inbox)
|
|
214
|
+
|
|
215
|
+
Select default project: 1
|
|
216
|
+
|
|
217
|
+
5. Status mapping:
|
|
218
|
+
CTX "executing" → Linear "In Progress" ✓
|
|
219
|
+
CTX "verifying" → Linear "In Review" ✓
|
|
220
|
+
CTX "complete" → Linear "Done" ✓
|
|
221
|
+
|
|
222
|
+
Use these mappings? [Y/n]: y
|
|
223
|
+
|
|
224
|
+
✅ Linear integration configured!
|
|
225
|
+
|
|
226
|
+
Saved to: .ctx/config.json
|
|
227
|
+
API key stored in: .ctx/.env (gitignored)
|
|
228
|
+
|
|
229
|
+
Run `/ctx integrate --sync` to sync existing stories.
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### For Jira:
|
|
233
|
+
```
|
|
234
|
+
[CTX] Jira Integration Setup
|
|
235
|
+
|
|
236
|
+
1. Enter your Jira URL: https://mycompany.atlassian.net
|
|
237
|
+
|
|
238
|
+
2. Enter email for API access: user@company.com
|
|
239
|
+
|
|
240
|
+
3. Get API token from: https://id.atlassian.com/manage-profile/security/api-tokens
|
|
241
|
+
Enter API Token: **********************
|
|
242
|
+
|
|
243
|
+
4. Fetching projects...
|
|
244
|
+
Found projects:
|
|
245
|
+
[1] PROJ - Main Project
|
|
246
|
+
[2] OPS - Operations
|
|
247
|
+
|
|
248
|
+
Select project: 1
|
|
249
|
+
|
|
250
|
+
5. Issue type for stories:
|
|
251
|
+
[1] Story
|
|
252
|
+
[2] Task
|
|
253
|
+
[3] Bug
|
|
254
|
+
|
|
255
|
+
Select: 1
|
|
256
|
+
|
|
257
|
+
✅ Jira integration configured!
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### For GitHub:
|
|
261
|
+
```
|
|
262
|
+
[CTX] GitHub Issues Integration Setup
|
|
263
|
+
|
|
264
|
+
1. Enter repository (owner/repo): myorg/myrepo
|
|
265
|
+
|
|
266
|
+
2. Checking GitHub authentication...
|
|
267
|
+
✅ Found existing gh auth
|
|
268
|
+
|
|
269
|
+
3. Fetching repository info...
|
|
270
|
+
✅ Repository found: My Repo
|
|
271
|
+
✅ Issues enabled
|
|
272
|
+
|
|
273
|
+
4. Labels to create/use:
|
|
274
|
+
- "ctx:feature" for feature stories
|
|
275
|
+
- "ctx:bug" for bug stories
|
|
276
|
+
- "ctx:design" for design stories
|
|
277
|
+
|
|
278
|
+
Create missing labels? [Y/n]: y
|
|
279
|
+
|
|
280
|
+
✅ GitHub integration configured!
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Step 3: Sync Stories
|
|
284
|
+
|
|
285
|
+
When `/ctx integrate --sync` runs:
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
[CTX] Syncing stories to Linear...
|
|
289
|
+
|
|
290
|
+
Story S001 - User Authentication
|
|
291
|
+
→ Creating issue in Linear...
|
|
292
|
+
→ Issue created: ENG-123
|
|
293
|
+
→ Syncing acceptance criteria...
|
|
294
|
+
✅ Synced
|
|
295
|
+
|
|
296
|
+
Story S002 - Dashboard UI
|
|
297
|
+
→ Creating issue in Linear...
|
|
298
|
+
→ Issue created: ENG-124
|
|
299
|
+
✅ Synced
|
|
300
|
+
|
|
301
|
+
Story S003 - API Refactor
|
|
302
|
+
→ Issue already exists: ENG-100
|
|
303
|
+
→ Updating status...
|
|
304
|
+
✅ Updated
|
|
305
|
+
|
|
306
|
+
Summary:
|
|
307
|
+
Created: 2 issues
|
|
308
|
+
Updated: 1 issue
|
|
309
|
+
Errors: 0
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Step 4: Ongoing Sync
|
|
313
|
+
|
|
314
|
+
### On Story Create (via /ctx init or edit PRD.json)
|
|
315
|
+
```
|
|
316
|
+
if config.integrations.linear.syncOnCreate:
|
|
317
|
+
create_linear_issue(story)
|
|
318
|
+
store_issue_id_in_prd(story.id, issue.id)
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### On Status Change
|
|
322
|
+
```
|
|
323
|
+
if status changed to "executing":
|
|
324
|
+
update_issue_status("In Progress")
|
|
325
|
+
|
|
326
|
+
if status changed to "complete":
|
|
327
|
+
update_issue_status("Done")
|
|
328
|
+
if config.closeOnComplete:
|
|
329
|
+
close_issue()
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### On Verify Fail
|
|
333
|
+
```
|
|
334
|
+
if verification fails:
|
|
335
|
+
add_comment(issue, {
|
|
336
|
+
title: "Verification Failed",
|
|
337
|
+
body: verification_report,
|
|
338
|
+
attachments: screenshots
|
|
339
|
+
})
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### On Verify Pass
|
|
343
|
+
```
|
|
344
|
+
if verification passes:
|
|
345
|
+
add_comment(issue, {
|
|
346
|
+
title: "✅ Verification Passed",
|
|
347
|
+
body: summary,
|
|
348
|
+
commits: related_commits
|
|
349
|
+
})
|
|
350
|
+
close_issue()
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
</workflow>
|
|
354
|
+
|
|
355
|
+
<prd_integration>
|
|
356
|
+
|
|
357
|
+
## PRD.json with Issue Tracking
|
|
358
|
+
|
|
359
|
+
```json
|
|
360
|
+
{
|
|
361
|
+
"stories": [
|
|
362
|
+
{
|
|
363
|
+
"id": "S001",
|
|
364
|
+
"title": "User Authentication",
|
|
365
|
+
"type": "feature",
|
|
366
|
+
"acceptanceCriteria": [...],
|
|
367
|
+
"passes": false,
|
|
368
|
+
"external": {
|
|
369
|
+
"linear": {
|
|
370
|
+
"issueId": "ENG-123",
|
|
371
|
+
"url": "https://linear.app/team/issue/ENG-123"
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
The `external` field tracks linked issues across integrations.
|
|
380
|
+
|
|
381
|
+
</prd_integration>
|
|
382
|
+
|
|
383
|
+
<commands>
|
|
384
|
+
|
|
385
|
+
## Integration Commands
|
|
386
|
+
|
|
387
|
+
| Command | Action |
|
|
388
|
+
|---------|--------|
|
|
389
|
+
| `/ctx integrate` | Show all integrations status |
|
|
390
|
+
| `/ctx integrate linear` | Setup Linear |
|
|
391
|
+
| `/ctx integrate jira` | Setup Jira |
|
|
392
|
+
| `/ctx integrate github` | Setup GitHub Issues |
|
|
393
|
+
| `/ctx integrate --sync` | Force sync all stories |
|
|
394
|
+
| `/ctx integrate --sync S001` | Sync specific story |
|
|
395
|
+
| `/ctx integrate --disconnect linear` | Remove Linear integration |
|
|
396
|
+
| `/ctx integrate --test` | Test connection |
|
|
397
|
+
|
|
398
|
+
</commands>
|
|
399
|
+
|
|
400
|
+
<output_format>
|
|
401
|
+
```
|
|
402
|
+
[CTX] Integration: {{provider}}
|
|
403
|
+
|
|
404
|
+
Status: {{connected|disconnected|error}}
|
|
405
|
+
{{details}}
|
|
406
|
+
|
|
407
|
+
Last sync: {{timestamp}}
|
|
408
|
+
Stories synced: {{count}}
|
|
409
|
+
|
|
410
|
+
{{action_result}}
|
|
411
|
+
```
|
|
412
|
+
</output_format>
|
|
413
|
+
|
|
414
|
+
<security>
|
|
415
|
+
## Credential Security
|
|
416
|
+
|
|
417
|
+
- API keys stored in `.ctx/.env` (gitignored)
|
|
418
|
+
- Config references via `env:VARIABLE_NAME`
|
|
419
|
+
- Never log or display full tokens
|
|
420
|
+
- Support for environment variables
|
|
421
|
+
- Prompt for re-auth if token expired
|
|
422
|
+
</security>
|