ctx-cc 3.1.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,465 @@
1
+ ---
2
+ name: metrics
3
+ description: Metrics dashboard - understand AI productivity impact with stories completed, time per story, token usage, and cost analysis.
4
+ ---
5
+
6
+ <objective>
7
+ CTX 3.2 Metrics Dashboard - Comprehensive productivity analytics for understanding AI development impact.
8
+ </objective>
9
+
10
+ <usage>
11
+ ```
12
+ /ctx metrics # Show overview dashboard
13
+ /ctx metrics today # Today's metrics
14
+ /ctx metrics week # This week's metrics
15
+ /ctx metrics month # This month's metrics
16
+ /ctx metrics story [id] # Specific story metrics
17
+ /ctx metrics cost # Cost analysis
18
+ /ctx metrics export # Export dashboard HTML
19
+ ```
20
+ </usage>
21
+
22
+ <metrics_structure>
23
+
24
+ ## Data Sources
25
+
26
+ Metrics are derived from:
27
+ - `.ctx/audit/` - Action logs
28
+ - `.ctx/STATE.md` - Current progress
29
+ - `git log` - Commit history
30
+ - `.ctx/phases/` - Story/task data
31
+
32
+ ## Metrics Directory
33
+
34
+ ```
35
+ .ctx/metrics/
36
+ ├── daily/
37
+ │ ├── 2024-01-20.json
38
+ │ └── ...
39
+ ├── aggregates/
40
+ │ ├── weekly.json
41
+ │ └── monthly.json
42
+ ├── dashboard.html # Local web view
43
+ └── metrics-config.json
44
+ ```
45
+
46
+ </metrics_structure>
47
+
48
+ <core_metrics>
49
+
50
+ ## Productivity Metrics
51
+
52
+ ### Stories Per Day/Week
53
+ ```json
54
+ {
55
+ "metric": "stories_completed",
56
+ "period": "week",
57
+ "value": 8,
58
+ "trend": "+2 vs last week",
59
+ "breakdown": {
60
+ "Mon": 2,
61
+ "Tue": 1,
62
+ "Wed": 2,
63
+ "Thu": 1,
64
+ "Fri": 2
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### Average Time Per Story
70
+ ```json
71
+ {
72
+ "metric": "time_per_story",
73
+ "period": "week",
74
+ "average": "1h 45m",
75
+ "median": "1h 30m",
76
+ "range": {
77
+ "min": "30m",
78
+ "max": "4h 15m"
79
+ },
80
+ "trend": "-15m vs last week"
81
+ }
82
+ ```
83
+
84
+ ### Debug Loop Frequency
85
+ ```json
86
+ {
87
+ "metric": "debug_frequency",
88
+ "period": "week",
89
+ "total": 12,
90
+ "avgAttemptsPerLoop": 2.3,
91
+ "successRate": "92%",
92
+ "avgResolutionTime": "8m",
93
+ "topCauses": [
94
+ {"cause": "Type errors", "count": 5},
95
+ {"cause": "Import issues", "count": 3},
96
+ {"cause": "Logic bugs", "count": 4}
97
+ ]
98
+ }
99
+ ```
100
+
101
+ ### Verification Success Rate
102
+ ```json
103
+ {
104
+ "metric": "verification_success",
105
+ "period": "week",
106
+ "firstPassSuccess": "78%",
107
+ "overallSuccess": "96%",
108
+ "avgAttempts": 1.3,
109
+ "commonFailures": [
110
+ {"type": "Missing error handling", "count": 4},
111
+ {"type": "Empty catch blocks", "count": 2},
112
+ {"type": "TODO comments", "count": 3}
113
+ ]
114
+ }
115
+ ```
116
+
117
+ </core_metrics>
118
+
119
+ <cost_metrics>
120
+
121
+ ## Token Usage
122
+
123
+ ```json
124
+ {
125
+ "metric": "token_usage",
126
+ "period": "week",
127
+ "total": {
128
+ "input": 750000,
129
+ "output": 225000,
130
+ "combined": 975000
131
+ },
132
+ "byPhase": {
133
+ "research": {"input": 150000, "output": 45000},
134
+ "planning": {"input": 100000, "output": 30000},
135
+ "execution": {"input": 350000, "output": 105000},
136
+ "verification": {"input": 100000, "output": 30000},
137
+ "debugging": {"input": 50000, "output": 15000}
138
+ },
139
+ "byModel": {
140
+ "opus": {"tokens": 250000, "percentage": "26%"},
141
+ "sonnet": {"tokens": 600000, "percentage": "62%"},
142
+ "haiku": {"tokens": 125000, "percentage": "12%"}
143
+ }
144
+ }
145
+ ```
146
+
147
+ ## Cost Analysis
148
+
149
+ ```json
150
+ {
151
+ "metric": "cost",
152
+ "period": "week",
153
+ "total": 4.87,
154
+ "currency": "USD",
155
+ "byDay": {
156
+ "Mon": 1.20,
157
+ "Tue": 0.85,
158
+ "Wed": 1.10,
159
+ "Thu": 0.92,
160
+ "Fri": 0.80
161
+ },
162
+ "byPhase": {
163
+ "research": 1.20,
164
+ "planning": 0.80,
165
+ "execution": 2.10,
166
+ "verification": 0.50,
167
+ "debugging": 0.27
168
+ },
169
+ "perStory": {
170
+ "average": 0.61,
171
+ "min": 0.15,
172
+ "max": 1.85
173
+ },
174
+ "trend": "-12% vs last week",
175
+ "savings": {
176
+ "vsQualityProfile": "2.45 (saved 50%)",
177
+ "vsBudgetProfile": "-1.20 (spent 25% more)"
178
+ }
179
+ }
180
+ ```
181
+
182
+ ## ROI Analysis
183
+
184
+ ```json
185
+ {
186
+ "metric": "roi",
187
+ "period": "week",
188
+ "storiesCompleted": 8,
189
+ "estimatedManualHours": 32,
190
+ "actualAIHours": 8,
191
+ "timeSaved": "24h",
192
+ "costSaved": {
193
+ "atDevRate": 150,
194
+ "aiCost": 4.87,
195
+ "netSavings": 145.13,
196
+ "roiMultiple": "30x"
197
+ }
198
+ }
199
+ ```
200
+
201
+ </cost_metrics>
202
+
203
+ <quality_metrics>
204
+
205
+ ## Code Quality
206
+
207
+ ```json
208
+ {
209
+ "metric": "code_quality",
210
+ "period": "week",
211
+ "linesOfCode": {
212
+ "added": 1250,
213
+ "removed": 340,
214
+ "net": 910
215
+ },
216
+ "commits": 45,
217
+ "avgCommitSize": 28,
218
+ "reviewerBlocks": {
219
+ "critical": 0,
220
+ "high": 2,
221
+ "medium": 8,
222
+ "resolved": "100%"
223
+ },
224
+ "testCoverage": {
225
+ "before": "72%",
226
+ "after": "78%",
227
+ "change": "+6%"
228
+ }
229
+ }
230
+ ```
231
+
232
+ ## Human Intervention Rate
233
+
234
+ ```json
235
+ {
236
+ "metric": "human_intervention",
237
+ "period": "week",
238
+ "autoHandled": 95,
239
+ "userDecisions": 5,
240
+ "total": 100,
241
+ "autoRate": "95%",
242
+ "interventionTypes": [
243
+ {"type": "Architectural decision", "count": 3},
244
+ {"type": "Scope clarification", "count": 2}
245
+ ]
246
+ }
247
+ ```
248
+
249
+ </quality_metrics>
250
+
251
+ <dashboard_output>
252
+
253
+ ## Terminal Dashboard
254
+
255
+ ```
256
+ ╔══════════════════════════════════════════════════════════════════╗
257
+ ║ CTX METRICS DASHBOARD ║
258
+ ║ Week 3, 2024 ║
259
+ ╠══════════════════════════════════════════════════════════════════╣
260
+ ║ ║
261
+ ║ PRODUCTIVITY COST ║
262
+ ║ ───────────── ──── ║
263
+ ║ Stories/Week: 8 (+2) Total: $4.87 (-12%) ║
264
+ ║ Time/Story: 1h 45m (-15m) Per Story: $0.61 ║
265
+ ║ Debug Loops: 12 (92% resolved) Tokens: 975K ║
266
+ ║ Verify Success: 78% first pass ║
267
+ ║ ║
268
+ ║ ┌──────────────────────────────────────────────────────────┐ ║
269
+ ║ │ Stories Completed by Day │ ║
270
+ ║ │ │ ║
271
+ ║ │ ██ │ ║
272
+ ║ │ ██ ██ ██ │ ║
273
+ ║ │ ██ ██ █ ██ ██ │ ║
274
+ ║ │ ────────────────────── │ ║
275
+ ║ │ Mon Tue Wed Thu Fri │ ║
276
+ ║ └──────────────────────────────────────────────────────────┘ ║
277
+ ║ ║
278
+ ║ TOKEN USAGE BY MODEL COST BY PHASE ║
279
+ ║ ──────────────────── ────────────── ║
280
+ ║ Opus: 250K (26%) ████ Research: $1.20 ████ ║
281
+ ║ Sonnet: 600K (62%) █████████ Planning: $0.80 ███ ║
282
+ ║ Haiku: 125K (12%) ██ Execution: $2.10 ███████ ║
283
+ ║ Verify: $0.50 ██ ║
284
+ ║ Debug: $0.27 █ ║
285
+ ║ ║
286
+ ║ ROI SUMMARY ║
287
+ ║ ─────────── ║
288
+ ║ Time Saved: 24 hours ║
289
+ ║ Cost Saved: $145.13 ║
290
+ ║ ROI Multiple: 30x ║
291
+ ║ ║
292
+ ╚══════════════════════════════════════════════════════════════════╝
293
+ ```
294
+
295
+ ## Story Metrics
296
+
297
+ ```
298
+ [METRICS] Story S001: User Authentication
299
+
300
+ Duration: 2h 15m
301
+ Tasks: 5
302
+ Commits: 8
303
+ Cost: $0.85
304
+
305
+ Phases:
306
+ Research: 15m ($0.15) ████
307
+ Discussion: 20m ($0.10) █████
308
+ Planning: 10m ($0.08) ███
309
+ Execution: 1h 15m ($0.45) ████████████████
310
+ Verification: 15m ($0.07) ████
311
+
312
+ Debug Loops: 2
313
+ - Type error in auth.ts (resolved in 3m)
314
+ - Missing import (resolved in 2m)
315
+
316
+ Verification: Passed on 2nd attempt
317
+ - First: Missing error handling
318
+ - Fixed: Added try/catch
319
+
320
+ Files Modified: 8
321
+ Lines Added: 245
322
+ Lines Removed: 12
323
+ ```
324
+
325
+ ## Cost Dashboard
326
+
327
+ ```
328
+ [METRICS] Cost Analysis - January 2024
329
+
330
+ Total Spend: $42.50
331
+
332
+ By Week:
333
+ W1: $12.30 ████████████
334
+ W2: $10.85 ██████████
335
+ W3: $9.75 █████████
336
+ W4: $9.60 █████████
337
+ └── Trend: -22% (improving efficiency)
338
+
339
+ By Phase:
340
+ Research: $8.50 (20%)
341
+ Planning: $5.10 (12%)
342
+ Execution: $21.25 (50%)
343
+ Verification: $4.25 (10%)
344
+ Debugging: $3.40 (8%)
345
+
346
+ By Model:
347
+ Opus: $18.70 (44%) - Critical decisions
348
+ Sonnet: $19.55 (46%) - Most work
349
+ Haiku: $4.25 (10%) - Quick tasks
350
+
351
+ Efficiency:
352
+ Stories: 32
353
+ Cost/Story: $1.33
354
+ Time Saved: ~96 hours
355
+ ROI: 115x
356
+ ```
357
+
358
+ </dashboard_output>
359
+
360
+ <html_dashboard>
361
+
362
+ ## Export to HTML
363
+
364
+ `/ctx metrics export` generates `.ctx/metrics/dashboard.html`:
365
+
366
+ ```html
367
+ <!DOCTYPE html>
368
+ <html>
369
+ <head>
370
+ <title>CTX Metrics Dashboard</title>
371
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
372
+ <style>
373
+ /* Clean, modern dashboard styling */
374
+ </style>
375
+ </head>
376
+ <body>
377
+ <div class="dashboard">
378
+ <header>
379
+ <h1>CTX Metrics Dashboard</h1>
380
+ <span class="period">January 2024</span>
381
+ </header>
382
+
383
+ <div class="metrics-grid">
384
+ <div class="metric-card">
385
+ <h3>Stories Completed</h3>
386
+ <div class="value">32</div>
387
+ <div class="trend positive">+8 vs last month</div>
388
+ </div>
389
+ <!-- More metric cards -->
390
+ </div>
391
+
392
+ <div class="charts">
393
+ <canvas id="storiesChart"></canvas>
394
+ <canvas id="costChart"></canvas>
395
+ <canvas id="tokenChart"></canvas>
396
+ </div>
397
+ </div>
398
+
399
+ <script>
400
+ // Chart.js configurations
401
+ </script>
402
+ </body>
403
+ </html>
404
+ ```
405
+
406
+ Open with: `open .ctx/metrics/dashboard.html`
407
+
408
+ </html_dashboard>
409
+
410
+ <configuration>
411
+
412
+ ## Metrics Settings
413
+
414
+ `.ctx/metrics/metrics-config.json`:
415
+ ```json
416
+ {
417
+ "enabled": true,
418
+ "collection": {
419
+ "tokens": true,
420
+ "costs": true,
421
+ "timing": true,
422
+ "quality": true
423
+ },
424
+ "aggregation": {
425
+ "daily": true,
426
+ "weekly": true,
427
+ "monthly": true
428
+ },
429
+ "costRates": {
430
+ "opus": {"input": 0.015, "output": 0.075},
431
+ "sonnet": {"input": 0.003, "output": 0.015},
432
+ "haiku": {"input": 0.00025, "output": 0.00125}
433
+ },
434
+ "roi": {
435
+ "developerHourlyRate": 150,
436
+ "hoursPerStoryManual": 4
437
+ },
438
+ "alerts": {
439
+ "dailyCostThreshold": 10,
440
+ "weeklyStoriesTarget": 10,
441
+ "verificationSuccessTarget": 80
442
+ },
443
+ "export": {
444
+ "format": "html",
445
+ "includeCharts": true,
446
+ "autoExport": false
447
+ }
448
+ }
449
+ ```
450
+
451
+ </configuration>
452
+
453
+ <output_format>
454
+ ```
455
+ [METRICS] {period}
456
+
457
+ {summary_stats}
458
+
459
+ {visualizations}
460
+
461
+ {insights}
462
+
463
+ Export: /ctx metrics export
464
+ ```
465
+ </output_format>
@@ -0,0 +1,264 @@
1
+ ---
2
+ name: milestone
3
+ description: Milestone workflow - list, audit, complete, and start new milestones for release management.
4
+ ---
5
+
6
+ <objective>
7
+ CTX 3.2 Milestone Workflow - Full release management with audit, archive, and git tagging.
8
+ </objective>
9
+
10
+ <usage>
11
+ ```
12
+ /ctx milestone # Show current milestone status
13
+ /ctx milestone list # List all milestones
14
+ /ctx milestone audit # Verify current milestone complete
15
+ /ctx milestone complete # Archive and tag release
16
+ /ctx milestone new [name] # Start next version
17
+ ```
18
+ </usage>
19
+
20
+ <workflow>
21
+
22
+ ## Step 0: Parse Subcommand
23
+
24
+ Extract subcommand from args:
25
+ - No args or "status" → Show Status
26
+ - "list" → List All
27
+ - "audit" → Audit Current
28
+ - "complete" → Complete & Archive
29
+ - "new [name]" → Start New
30
+
31
+ ## Step 1: Show Status (default)
32
+
33
+ Read STATE.md and show:
34
+ ```
35
+ [MILESTONE] v1.0.0 - "Initial Release"
36
+
37
+ Phases:
38
+ ✓ Phase 1: Authentication (3/3 stories)
39
+ ✓ Phase 2: Dashboard (5/5 stories)
40
+ → Phase 3: API Integration (2/4 stories)
41
+ ○ Phase 4: Polish (0/2 stories)
42
+
43
+ Progress: 10/14 stories (71%)
44
+ Started: 2024-01-01
45
+ Estimated: 2024-01-20
46
+ ```
47
+
48
+ ## Step 2: List All Milestones
49
+
50
+ Read `.ctx/milestones/` directory:
51
+ ```
52
+ [MILESTONES]
53
+
54
+ Active:
55
+ → v1.0.0 "Initial Release" (71% complete)
56
+
57
+ Archived:
58
+ ✓ v0.5.0 "Beta" (2024-01-01) - git tag: v0.5.0
59
+ ✓ v0.4.0 "Alpha" (2023-12-15) - git tag: v0.4.0
60
+ ```
61
+
62
+ ## Step 3: Audit Current Milestone
63
+
64
+ Spawn ctx-verifier to check all stories:
65
+
66
+ ```
67
+ [AUDIT] v1.0.0
68
+
69
+ Phase 1: Authentication
70
+ ✓ S001: User registration
71
+ ✓ S002: User login
72
+ ✓ S003: Password reset
73
+
74
+ Phase 2: Dashboard
75
+ ✓ S004: Dashboard layout
76
+ ✓ S005: Charts component
77
+ ⚠ S006: Data export (missing error handling)
78
+ ✓ S007: Filters
79
+ ✓ S008: Pagination
80
+
81
+ Phase 3: API Integration
82
+ ✓ S009: REST endpoints
83
+ ✗ S010: Webhooks (not implemented)
84
+ → S011: Rate limiting (in progress)
85
+ ○ S012: Documentation
86
+
87
+ Phase 4: Polish
88
+ ○ S013: Performance
89
+ ○ S014: Accessibility
90
+
91
+ [RESULT] NOT READY
92
+ - 2 stories incomplete
93
+ - 1 story has issues
94
+
95
+ Run `/ctx milestone gaps` to create fix phases.
96
+ ```
97
+
98
+ ## Step 4: Complete Milestone
99
+
100
+ Only if audit passes:
101
+
102
+ 1. **Archive State**
103
+ ```bash
104
+ mkdir -p .ctx/archive/v1.0.0
105
+ cp -r .ctx/phases .ctx/archive/v1.0.0/
106
+ cp .ctx/STATE.md .ctx/archive/v1.0.0/
107
+ cp .ctx/PRD.json .ctx/archive/v1.0.0/
108
+ ```
109
+
110
+ 2. **Create Git Tag**
111
+ ```bash
112
+ git tag -a v1.0.0 -m "CTX Milestone: v1.0.0 - Initial Release
113
+
114
+ Stories completed: 14
115
+ Phases: 4
116
+ Duration: 20 days
117
+
118
+ Co-Authored-By: Claude <noreply@anthropic.com>"
119
+
120
+ git push origin v1.0.0
121
+ ```
122
+
123
+ 3. **Update Milestone Record**
124
+ ```json
125
+ {
126
+ "version": "1.0.0",
127
+ "name": "Initial Release",
128
+ "completedAt": "2024-01-20T15:30:00Z",
129
+ "gitTag": "v1.0.0",
130
+ "stats": {
131
+ "phases": 4,
132
+ "stories": 14,
133
+ "commits": 47,
134
+ "duration": "20d"
135
+ }
136
+ }
137
+ ```
138
+
139
+ 4. **Output**
140
+ ```
141
+ [COMPLETE] v1.0.0 archived successfully
142
+
143
+ Archive: .ctx/archive/v1.0.0/
144
+ Git tag: v1.0.0
145
+ Duration: 20 days
146
+ Stories: 14
147
+
148
+ Ready to start next milestone with `/ctx milestone new`
149
+ ```
150
+
151
+ ## Step 5: Start New Milestone
152
+
153
+ ```
154
+ /ctx milestone new v1.1.0 "Feature Expansion"
155
+ ```
156
+
157
+ 1. **Create Milestone Directory**
158
+ ```
159
+ .ctx/milestones/v1.1.0/
160
+ ├── MILESTONE.json
161
+ └── phases/
162
+ ```
163
+
164
+ 2. **Initialize MILESTONE.json**
165
+ ```json
166
+ {
167
+ "version": "1.1.0",
168
+ "name": "Feature Expansion",
169
+ "createdAt": "2024-01-21T09:00:00Z",
170
+ "status": "active",
171
+ "phases": [],
172
+ "previousMilestone": "v1.0.0"
173
+ }
174
+ ```
175
+
176
+ 3. **Reset STATE.md**
177
+ ```markdown
178
+ # CTX State
179
+
180
+ ## Current
181
+ - **Milestone**: v1.1.0 - Feature Expansion
182
+ - **Status**: initializing
183
+ - **Phase**: None
184
+
185
+ ## Context
186
+ - Started: 2024-01-21
187
+ - Previous: v1.0.0 (archived)
188
+ ```
189
+
190
+ 4. **Output**
191
+ ```
192
+ [NEW] Milestone v1.1.0 "Feature Expansion" created
193
+
194
+ Previous: v1.0.0 (archived at .ctx/archive/v1.0.0/)
195
+ Status: initializing
196
+
197
+ Next steps:
198
+ 1. Define phases with `/ctx phase add "goal"`
199
+ 2. Or use `/ctx` to start with research
200
+ ```
201
+
202
+ ## Step 6: Generate Gap Phases
203
+
204
+ If audit fails, offer to create fix phases:
205
+
206
+ ```
207
+ /ctx milestone gaps
208
+ ```
209
+
210
+ Analyzes audit failures and creates:
211
+ ```
212
+ [GAPS] Creating fix phases for v1.0.0
213
+
214
+ Phase 4.1: Fix S006 error handling
215
+ - Add try/catch to export function
216
+ - Add user feedback on failure
217
+
218
+ Phase 4.2: Implement S010 webhooks
219
+ - Create webhook endpoints
220
+ - Add signature validation
221
+ - Test with external service
222
+
223
+ Phase 4.3: Complete S011 rate limiting
224
+ - Finish middleware implementation
225
+ - Add Redis backend
226
+
227
+ Add these phases? [Y/n]
228
+ ```
229
+
230
+ </workflow>
231
+
232
+ <state_updates>
233
+ After any milestone action, update STATE.md:
234
+
235
+ ```markdown
236
+ ## Milestone
237
+ - **Current**: v1.0.0
238
+ - **Status**: active | auditing | completing | archived
239
+ - **Progress**: 10/14 (71%)
240
+ - **Last Audit**: 2024-01-20 (FAILED: 2 incomplete)
241
+ ```
242
+ </state_updates>
243
+
244
+ <integration>
245
+ If issue tracker integration enabled:
246
+
247
+ **On Complete**:
248
+ - Close all stories in Linear/Jira
249
+ - Create release in GitHub
250
+ - Post to Slack channel
251
+
252
+ **On Gaps**:
253
+ - Create issues for gap phases
254
+ - Link to milestone epic
255
+ </integration>
256
+
257
+ <output_format>
258
+ ```
259
+ [MILESTONE] {action}
260
+ {details}
261
+
262
+ {next_steps}
263
+ ```
264
+ </output_format>