ctx-cc 3.0.0 → 3.3.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.
@@ -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>