Skip to content

Commit 8e8417c

Browse files
chore: cleanup unused code and organize demos
- Delete unused directories: pg-aiguide, validation, core/analytics - Move demo files from src/ to scripts/demos/ - Add create-cleanup-issues.js for Linear task creation - Created 10 Linear issues for remaining tech debt (STA-438 to STA-447) Cleanup items tracked in Linear: - Test coverage for monitoring, performance, session, claude-code, trace - Scripts directory reorganization - ESLint config improvements - Service duplication resolution - Temporary file naming cleanup - Documentation gaps Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 82b226c commit 8e8417c

10 files changed

Lines changed: 317 additions & 1233 deletions

File tree

scripts/create-cleanup-issues.js

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
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);

src/integrations/ralph/ralph-integration-demo.ts renamed to scripts/demos/ralph-integration-demo.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ class RalphIntegrationDemo {
113113
console.log('🔧 Running worker iteration...');
114114
const iteration = await this.bridge.runWorkerIteration();
115115

116-
console.log(`✓ Analysis: ${iteration.analysis.filesCount} files, tests ${iteration.analysis.testsPass ? 'pass' : 'fail'}`);
116+
console.log(
117+
`✓ Analysis: ${iteration.analysis.filesCount} files, tests ${iteration.analysis.testsPass ? 'pass' : 'fail'}`
118+
);
117119
console.log(`✓ Plan: ${iteration.plan.summary}`);
118120
console.log(`✓ Changes: ${iteration.changes.length} modifications`);
119-
console.log(`✓ Validation: ${iteration.validation.testsPass ? 'pass' : 'fail'}`);
121+
console.log(
122+
`✓ Validation: ${iteration.validation.testsPass ? 'pass' : 'fail'}`
123+
);
120124

121125
// Run reviewer iteration
122126
console.log('👀 Running reviewer iteration...');
@@ -131,7 +135,9 @@ class RalphIntegrationDemo {
131135

132136
// Show context budget usage
133137
const usage = this.bridge.getPerformanceMetrics();
134-
console.log(`📊 Token usage: ${usage.tokenCount} / Context load: ${usage.contextLoadTime}ms`);
138+
console.log(
139+
`📊 Token usage: ${usage.tokenCount} / Context load: ${usage.contextLoadTime}ms`
140+
);
135141

136142
// Create checkpoint every few iterations
137143
if ((i + 1) % 3 === 0) {
@@ -141,7 +147,7 @@ class RalphIntegrationDemo {
141147
}
142148

143149
// Small delay for demo
144-
await new Promise(resolve => setTimeout(resolve, 1000));
150+
await new Promise((resolve) => setTimeout(resolve, 1000));
145151
}
146152
}
147153

@@ -157,7 +163,7 @@ class RalphIntegrationDemo {
157163

158164
try {
159165
console.log('🔄 Simulating session rehydration...');
160-
166+
161167
// This would normally rehydrate from a real StackMemory session
162168
// For demo, we'll show the concept
163169
console.log('✓ Loading context from StackMemory...');
@@ -171,7 +177,6 @@ class RalphIntegrationDemo {
171177
console.log(' - State reconciled: 0.3s');
172178
console.log(' - Memory usage: 45MB');
173179
console.log(' - Cache hit rate: 78%');
174-
175180
} catch (error: any) {
176181
console.log(`⚠️ Recovery simulation: ${error.message}`);
177182
}
@@ -190,7 +195,9 @@ class RalphIntegrationDemo {
190195
console.log(` Iteration Time: ${metrics.iterationTime}ms avg`);
191196
console.log(` Context Load Time: ${metrics.contextLoadTime}ms avg`);
192197
console.log(` State Save Time: ${metrics.stateSaveTime}ms avg`);
193-
console.log(` Memory Usage: ${Math.round(metrics.memoryUsage / 1024 / 1024)}MB`);
198+
console.log(
199+
` Memory Usage: ${Math.round(metrics.memoryUsage / 1024 / 1024)}MB`
200+
);
194201
console.log(` Token Count: ${metrics.tokenCount}`);
195202
console.log(` Cache Hit Rate: ${Math.round(metrics.cacheHitRate * 100)}%`);
196203

@@ -234,4 +241,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
234241
main().catch(console.error);
235242
}
236243

237-
export { RalphIntegrationDemo };
244+
export { RalphIntegrationDemo };

0 commit comments

Comments
 (0)