|
| 1 | +#!/usr/bin/env node |
| 2 | +/** |
| 3 | + * Create cleanup issues in Linear |
| 4 | + */ |
| 5 | + |
| 6 | +import dotenv from 'dotenv'; |
| 7 | +import path from 'path'; |
| 8 | +import { fileURLToPath } from 'url'; |
| 9 | + |
| 10 | +const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 11 | +dotenv.config({ path: path.join(__dirname, '..', '.env') }); |
| 12 | + |
| 13 | +const TEAM_ID = 'STA'; // Stackmemoryai team |
| 14 | + |
| 15 | +const cleanupTasks = [ |
| 16 | + { |
| 17 | + title: 'Add tests for monitoring module (0% coverage)', |
| 18 | + description: `## Problem |
| 19 | +The \`/src/core/monitoring/\` module has 0% test coverage. |
| 20 | +
|
| 21 | +## Files affected |
| 22 | +- src/core/monitoring/logger.ts |
| 23 | +- src/core/monitoring/health-check.ts |
| 24 | +- src/core/monitoring/metrics-collector.ts |
| 25 | +- src/core/monitoring/performance-tracker.ts |
| 26 | +- src/core/monitoring/index.ts |
| 27 | +
|
| 28 | +## Acceptance criteria |
| 29 | +- [ ] Add unit tests for all public functions |
| 30 | +- [ ] Test error handling paths |
| 31 | +- [ ] Achieve >80% coverage`, |
| 32 | + priority: 2, // High |
| 33 | + labels: ['tech-debt', 'testing'], |
| 34 | + }, |
| 35 | + { |
| 36 | + title: 'Add tests for performance module (0% coverage)', |
| 37 | + description: `## Problem |
| 38 | +The \`/src/core/performance/\` module has 0% test coverage. |
| 39 | +
|
| 40 | +## Files affected |
| 41 | +- src/core/performance/profiler.ts |
| 42 | +- src/core/performance/metrics.ts |
| 43 | +- src/core/performance/index.ts |
| 44 | +
|
| 45 | +## Acceptance criteria |
| 46 | +- [ ] Add unit tests for profiler |
| 47 | +- [ ] Add unit tests for metrics collection |
| 48 | +- [ ] Achieve >80% coverage`, |
| 49 | + priority: 2, // High |
| 50 | + labels: ['tech-debt', 'testing'], |
| 51 | + }, |
| 52 | + { |
| 53 | + title: 'Add tests for session module (0% coverage)', |
| 54 | + description: `## Problem |
| 55 | +The \`/src/core/session/\` module has 0% test coverage. |
| 56 | +
|
| 57 | +## Files affected |
| 58 | +- src/core/session/session-manager.ts |
| 59 | +- src/core/session/enhanced-handoff.ts |
| 60 | +- src/core/session/index.ts |
| 61 | +
|
| 62 | +## Acceptance criteria |
| 63 | +- [ ] Add unit tests for session lifecycle |
| 64 | +- [ ] Add unit tests for handoff |
| 65 | +- [ ] Achieve >80% coverage`, |
| 66 | + priority: 2, // High |
| 67 | + labels: ['tech-debt', 'testing'], |
| 68 | + }, |
| 69 | + { |
| 70 | + title: 'Add tests for claude-code integration (7 files, 0% coverage)', |
| 71 | + description: `## Problem |
| 72 | +The \`/src/integrations/claude-code/\` module has no tests. |
| 73 | +
|
| 74 | +## Files affected |
| 75 | +- src/integrations/claude-code/agent-bridge.ts |
| 76 | +- src/integrations/claude-code/context-injector.ts |
| 77 | +- src/integrations/claude-code/hook-manager.ts |
| 78 | +- src/integrations/claude-code/index.ts |
| 79 | +- src/integrations/claude-code/mcp-client.ts |
| 80 | +- src/integrations/claude-code/session-detector.ts |
| 81 | +- src/integrations/claude-code/types.ts |
| 82 | +
|
| 83 | +## Acceptance criteria |
| 84 | +- [ ] Add unit tests for all modules |
| 85 | +- [ ] Mock external dependencies |
| 86 | +- [ ] Achieve >80% coverage`, |
| 87 | + priority: 2, // High |
| 88 | + labels: ['tech-debt', 'testing'], |
| 89 | + }, |
| 90 | + { |
| 91 | + title: 'Improve trace module test coverage (9%)', |
| 92 | + description: `## Problem |
| 93 | +The \`/src/core/trace/\` module has only ~9% test coverage. |
| 94 | +
|
| 95 | +## Files affected (11 files) |
| 96 | +- src/core/trace/trace-detector.ts |
| 97 | +- src/core/trace/trace-bundler.ts |
| 98 | +- src/core/trace/pattern-matcher.ts |
| 99 | +- And 8 more... |
| 100 | +
|
| 101 | +## Acceptance criteria |
| 102 | +- [ ] Add tests for trace detection |
| 103 | +- [ ] Add tests for pattern matching |
| 104 | +- [ ] Add tests for trace bundling |
| 105 | +- [ ] Achieve >80% coverage`, |
| 106 | + priority: 3, // Medium |
| 107 | + labels: ['tech-debt', 'testing'], |
| 108 | + }, |
| 109 | + { |
| 110 | + title: 'Reorganize scripts directory (112 files)', |
| 111 | + description: `## Problem |
| 112 | +The \`/scripts/\` directory has 112 files with no clear organization. |
| 113 | +
|
| 114 | +## Proposed structure |
| 115 | +\`\`\` |
| 116 | +scripts/ |
| 117 | + setup/ # Installation & configuration |
| 118 | + test/ # Test runners |
| 119 | + cli/ # CLI wrappers |
| 120 | + maintenance/ # Cleanup & sync tasks |
| 121 | + demos/ # Demo & example scripts (DONE) |
| 122 | + archive/ # Archived scripts |
| 123 | +\`\`\` |
| 124 | +
|
| 125 | +## Acceptance criteria |
| 126 | +- [ ] Create subdirectories |
| 127 | +- [ ] Move scripts to appropriate directories |
| 128 | +- [ ] Update any references in package.json |
| 129 | +- [ ] Update documentation`, |
| 130 | + priority: 4, // Low |
| 131 | + labels: ['tech-debt', 'organization'], |
| 132 | + }, |
| 133 | + { |
| 134 | + title: 'Remove ESLint blanket exclusion of /src/integrations/', |
| 135 | + description: `## Problem |
| 136 | +ESLint config (line 55) excludes entire \`/src/integrations/\` directory from linting. |
| 137 | +
|
| 138 | +## Impact |
| 139 | +- Potential code quality issues not caught |
| 140 | +- Inconsistent code style |
| 141 | +- 33 warnings not shown |
| 142 | +
|
| 143 | +## Acceptance criteria |
| 144 | +- [ ] Remove blanket exclusion from eslint.config.js |
| 145 | +- [ ] Fix any lint errors that appear |
| 146 | +- [ ] Keep specific exclusions only if truly needed`, |
| 147 | + priority: 3, // Medium |
| 148 | + labels: ['tech-debt', 'code-quality'], |
| 149 | + }, |
| 150 | + { |
| 151 | + title: 'Resolve service duplication (context-service.ts)', |
| 152 | + description: `## Problem |
| 153 | +\`context-service.ts\` exists in two locations with different implementations: |
| 154 | +- /src/services/context-service.ts |
| 155 | +- /src/daemon/services/context-service.ts |
| 156 | +
|
| 157 | +## Acceptance criteria |
| 158 | +- [ ] Analyze both implementations |
| 159 | +- [ ] Rename daemon version to DaemonContextService or consolidate |
| 160 | +- [ ] Update all imports |
| 161 | +- [ ] Document the difference if both needed`, |
| 162 | + priority: 3, // Medium |
| 163 | + labels: ['tech-debt', 'organization'], |
| 164 | + }, |
| 165 | + { |
| 166 | + title: 'Rename temporary-named files (refactored-*, enhanced-*)', |
| 167 | + description: `## Problem |
| 168 | +Several files have temporary-sounding names: |
| 169 | +- refactored-frame-manager.ts |
| 170 | +- enhanced-hybrid-digest.ts |
| 171 | +- enhanced-rehydration.ts |
| 172 | +- enhanced-handoff.ts |
| 173 | +
|
| 174 | +## Acceptance criteria |
| 175 | +- [ ] Rename to final names (remove prefix) |
| 176 | +- [ ] Update all imports |
| 177 | +- [ ] Verify tests pass`, |
| 178 | + priority: 4, // Low |
| 179 | + labels: ['tech-debt', 'naming'], |
| 180 | + }, |
| 181 | + { |
| 182 | + title: 'Add documentation for monitoring, trace, and performance modules', |
| 183 | + description: `## Problem |
| 184 | +Critical modules lack documentation: |
| 185 | +- /src/core/monitoring/ - no docs |
| 186 | +- /src/core/trace/ - demos but no guide |
| 187 | +- /src/core/performance/ - no docs |
| 188 | +
|
| 189 | +## Acceptance criteria |
| 190 | +- [ ] Add README.md or docs for each module |
| 191 | +- [ ] Document public APIs |
| 192 | +- [ ] Add usage examples`, |
| 193 | + priority: 4, // Low |
| 194 | + labels: ['documentation'], |
| 195 | + }, |
| 196 | +]; |
| 197 | + |
| 198 | +async function queryLinear(query, variables = {}) { |
| 199 | + const apiKey = |
| 200 | + process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY; |
| 201 | + const response = await fetch('https://api.linear.app/graphql', { |
| 202 | + method: 'POST', |
| 203 | + headers: { |
| 204 | + 'Content-Type': 'application/json', |
| 205 | + Authorization: apiKey, |
| 206 | + }, |
| 207 | + body: JSON.stringify({ query, variables }), |
| 208 | + }); |
| 209 | + |
| 210 | + const data = await response.json(); |
| 211 | + if (data.errors) { |
| 212 | + throw new Error(data.errors[0].message); |
| 213 | + } |
| 214 | + return data.data; |
| 215 | +} |
| 216 | + |
| 217 | +async function getTeamId() { |
| 218 | + const teams = await queryLinear(` |
| 219 | + query { |
| 220 | + teams { |
| 221 | + nodes { |
| 222 | + id |
| 223 | + key |
| 224 | + name |
| 225 | + } |
| 226 | + } |
| 227 | + } |
| 228 | + `); |
| 229 | + |
| 230 | + const team = teams.teams.nodes.find((t) => t.key === TEAM_ID); |
| 231 | + if (!team) { |
| 232 | + throw new Error(`Team ${TEAM_ID} not found`); |
| 233 | + } |
| 234 | + return team.id; |
| 235 | +} |
| 236 | + |
| 237 | +async function createIssue(teamId, task) { |
| 238 | + const mutation = ` |
| 239 | + mutation CreateIssue($input: IssueCreateInput!) { |
| 240 | + issueCreate(input: $input) { |
| 241 | + success |
| 242 | + issue { |
| 243 | + id |
| 244 | + identifier |
| 245 | + title |
| 246 | + url |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + `; |
| 251 | + |
| 252 | + const result = await queryLinear(mutation, { |
| 253 | + input: { |
| 254 | + teamId, |
| 255 | + title: task.title, |
| 256 | + description: task.description, |
| 257 | + priority: task.priority, |
| 258 | + }, |
| 259 | + }); |
| 260 | + |
| 261 | + return result.issueCreate; |
| 262 | +} |
| 263 | + |
| 264 | +async function main() { |
| 265 | + const apiKey = |
| 266 | + process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY; |
| 267 | + if (!apiKey) { |
| 268 | + console.error('❌ LINEAR_API_KEY not set'); |
| 269 | + process.exit(1); |
| 270 | + } |
| 271 | + |
| 272 | + console.log('🔄 Connecting to Linear...'); |
| 273 | + |
| 274 | + // Verify connection |
| 275 | + const viewer = await queryLinear('{ viewer { name email } }'); |
| 276 | + console.log(`✅ Connected as: ${viewer.viewer.name}`); |
| 277 | + |
| 278 | + // Get team ID |
| 279 | + const teamId = await getTeamId(); |
| 280 | + console.log(`📋 Team: ${TEAM_ID} (${teamId})\n`); |
| 281 | + |
| 282 | + // Create issues |
| 283 | + console.log(`Creating ${cleanupTasks.length} cleanup issues...\n`); |
| 284 | + |
| 285 | + for (const task of cleanupTasks) { |
| 286 | + try { |
| 287 | + const result = await createIssue(teamId, task); |
| 288 | + if (result.success) { |
| 289 | + console.log(`✅ ${result.issue.identifier}: ${task.title}`); |
| 290 | + console.log(` ${result.issue.url}\n`); |
| 291 | + } else { |
| 292 | + console.log(`❌ Failed: ${task.title}`); |
| 293 | + } |
| 294 | + } catch (error) { |
| 295 | + console.log(`❌ Error creating "${task.title}": ${error.message}`); |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + console.log('✅ Done!'); |
| 300 | +} |
| 301 | + |
| 302 | +main().catch(console.error); |
0 commit comments