Skip to content

Commit bca37cd

Browse files
committed
refactor: simplify code by removing unused features
- Focus LANGUAGE_EXTENSIONS on web dev languages only - Remove MVC pattern detection - Replace spinner with simple logging - Remove unused console utilities close #33
1 parent 892b04f commit bca37cd

6 files changed

Lines changed: 13 additions & 207 deletions

File tree

mcp-server/src/analyzer/code.sampler.ts

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,31 @@ import { pathContainsSegment } from '../shared/path.utils';
55

66
/**
77
* Language detection by file extension
8+
* Focused on web development languages commonly analyzed by this tool
89
*/
910
export const LANGUAGE_EXTENSIONS: Record<string, string> = {
1011
// TypeScript
1112
'.ts': 'typescript',
1213
'.tsx': 'typescript',
13-
'.mts': 'typescript',
14-
'.cts': 'typescript',
1514

1615
// JavaScript
1716
'.js': 'javascript',
1817
'.jsx': 'javascript',
19-
'.mjs': 'javascript',
20-
'.cjs': 'javascript',
2118

2219
// Python
2320
'.py': 'python',
24-
'.pyw': 'python',
2521

26-
// Java/Kotlin
22+
// Java
2723
'.java': 'java',
28-
'.kt': 'kotlin',
29-
'.kts': 'kotlin',
30-
31-
// Go
32-
'.go': 'go',
33-
34-
// Rust
35-
'.rs': 'rust',
36-
37-
// C/C++
38-
'.c': 'c',
39-
'.h': 'c',
40-
'.cpp': 'cpp',
41-
'.hpp': 'cpp',
42-
'.cc': 'cpp',
43-
44-
// C#
45-
'.cs': 'csharp',
46-
47-
// Ruby
48-
'.rb': 'ruby',
49-
50-
// PHP
51-
'.php': 'php',
52-
53-
// Swift
54-
'.swift': 'swift',
5524

5625
// Styles
5726
'.css': 'css',
5827
'.scss': 'scss',
59-
'.sass': 'sass',
60-
'.less': 'less',
6128

6229
// Data/Config
6330
'.json': 'json',
6431
'.yaml': 'yaml',
6532
'.yml': 'yaml',
66-
'.toml': 'toml',
67-
'.xml': 'xml',
68-
69-
// Shell
70-
'.sh': 'shell',
71-
'.bash': 'shell',
72-
'.zsh': 'shell',
73-
74-
// SQL
75-
'.sql': 'sql',
76-
77-
// GraphQL
78-
'.graphql': 'graphql',
79-
'.gql': 'graphql',
8033

8134
// Framework-specific
8235
'.vue': 'vue',
@@ -85,25 +38,15 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
8538

8639
/**
8740
* Extensions considered as code (for sampling)
41+
* Matches LANGUAGE_EXTENSIONS for consistency
8842
*/
8943
const CODE_EXTENSIONS = new Set([
9044
'.ts',
9145
'.tsx',
9246
'.js',
9347
'.jsx',
94-
'.mjs',
95-
'.cjs',
9648
'.py',
9749
'.java',
98-
'.kt',
99-
'.go',
100-
'.rs',
101-
'.c',
102-
'.cpp',
103-
'.cs',
104-
'.rb',
105-
'.php',
106-
'.swift',
10750
'.css',
10851
'.scss',
10952
'.vue',

mcp-server/src/analyzer/directory.analyzer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ export const ARCHITECTURE_PATTERNS: PatternDefinition[] = [
5050
indicators: ['packages', 'apps', 'libs'],
5151
minIndicators: 1,
5252
},
53-
{
54-
name: 'MVC',
55-
indicators: ['src/models', 'src/views', 'src/controllers'],
56-
minIndicators: 2,
57-
},
5853
{
5954
name: 'Clean Architecture',
6055
indicators: ['src/domain', 'src/application', 'src/infrastructure', 'src/presentation'],

mcp-server/src/cli/init/init.command.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export async function runInit(options: InitOptions): Promise<InitResult> {
6262
}
6363

6464
// Step 1: Analyze project
65-
console.spinner.start('Analyzing project...');
65+
console.log.step('🔍', 'Analyzing project...');
6666

6767
const analyzer = new AnalyzerService();
6868
const analysis = await analyzer.analyzeProject(options.projectRoot);
6969

70-
console.spinner.succeed('Project analysis complete');
70+
console.log.success('Project analysis complete');
7171

7272
// Log analysis summary
7373
if (analysis.packageInfo) {
@@ -79,21 +79,21 @@ export async function runInit(options: InitOptions): Promise<InitResult> {
7979
console.log.step('📁', `Files: ${analysis.directoryStructure.totalFiles}`);
8080

8181
// Step 2: Generate config with AI
82-
console.spinner.start('AI is generating configuration...');
82+
console.log.step('🤖', 'AI is generating configuration...');
8383

8484
const generator = new ConfigGenerator({ apiKey });
8585
const config = await generator.generate(analysis);
8686

87-
console.spinner.succeed('Configuration generated');
87+
console.log.success('Configuration generated');
8888

8989
// Step 3: Write config file
90-
console.spinner.start('Writing configuration file...');
90+
console.log.step('💾', 'Writing configuration file...');
9191

9292
const configPath = await writeConfig(options.projectRoot, config, {
9393
format: options.format,
9494
});
9595

96-
console.spinner.succeed(`Configuration saved to ${configPath}`);
96+
console.log.success(`Configuration saved to ${configPath}`);
9797

9898
// Success message
9999
console.log.success('');
@@ -107,7 +107,7 @@ export async function runInit(options: InitOptions): Promise<InitResult> {
107107
};
108108
} catch (error) {
109109
const message = error instanceof Error ? error.message : String(error);
110-
console.spinner.fail(`Error: ${message}`);
110+
console.log.error(message);
111111

112112
return {
113113
success: false,

mcp-server/src/cli/utils/console.spec.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -62,64 +62,4 @@ describe('console utils', () => {
6262
});
6363
});
6464

65-
describe('spinner', () => {
66-
it('should start spinner with message', () => {
67-
consoleUtils.spinner.start('Loading...');
68-
69-
expect(stdoutWrite).toHaveBeenCalled();
70-
const output = stdoutWrite.mock.calls[0][0] as string;
71-
expect(output).toContain('Loading...');
72-
});
73-
74-
it('should stop spinner and show success', () => {
75-
consoleUtils.spinner.start('Loading...');
76-
stdoutWrite.mockClear();
77-
78-
consoleUtils.spinner.succeed('Done!');
79-
80-
expect(stdoutWrite).toHaveBeenCalled();
81-
const output = stdoutWrite.mock.calls.map((c) => c[0]).join('');
82-
expect(output).toContain('Done!');
83-
expect(output).toContain('✓');
84-
});
85-
86-
it('should stop spinner and show failure', () => {
87-
consoleUtils.spinner.start('Loading...');
88-
stderrWrite.mockClear();
89-
90-
consoleUtils.spinner.fail('Failed!');
91-
92-
expect(stderrWrite).toHaveBeenCalled();
93-
const output = stderrWrite.mock.calls.map((c) => c[0]).join('');
94-
expect(output).toContain('Failed!');
95-
expect(output).toContain('✗');
96-
});
97-
98-
it('should stop spinner without message', () => {
99-
consoleUtils.spinner.start('Loading...');
100-
stdoutWrite.mockClear();
101-
102-
consoleUtils.spinner.stop();
103-
104-
// Should clear the spinner line
105-
expect(stdoutWrite).toHaveBeenCalled();
106-
});
107-
});
108-
109-
describe('formatConfig', () => {
110-
it('should format config object as readable output', () => {
111-
const config = {
112-
projectName: 'my-app',
113-
techStack: {
114-
frontend: ['React'],
115-
},
116-
};
117-
118-
const result = consoleUtils.formatConfig(config);
119-
120-
expect(result).toContain('projectName');
121-
expect(result).toContain('my-app');
122-
expect(result).toContain('React');
123-
});
124-
});
12565
});

mcp-server/src/cli/utils/console.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ export interface ConsoleUtils {
1515
error(message: string): void;
1616
step(emoji: string, message: string): void;
1717
};
18-
spinner: {
19-
start(message: string): void;
20-
succeed(message: string): void;
21-
fail(message: string): void;
22-
stop(): void;
23-
};
24-
formatConfig(config: unknown): string;
2518
}
2619

2720
/**
@@ -33,26 +26,12 @@ const colors = {
3326
yellow: '\x1b[33m',
3427
red: '\x1b[31m',
3528
cyan: '\x1b[36m',
36-
dim: '\x1b[2m',
3729
};
3830

39-
/**
40-
* Spinner frames for animation
41-
*/
42-
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
43-
4431
/**
4532
* Create console utilities instance
4633
*/
4734
export function createConsoleUtils(): ConsoleUtils {
48-
let spinnerInterval: ReturnType<typeof setInterval> | null = null;
49-
let spinnerMessage = '';
50-
let frameIndex = 0;
51-
52-
const clearLine = () => {
53-
process.stdout.write('\r\x1b[K');
54-
};
55-
5635
const log = {
5736
info(message: string): void {
5837
process.stdout.write(`${colors.cyan}${colors.reset} ${message}\n`);
@@ -75,58 +54,7 @@ export function createConsoleUtils(): ConsoleUtils {
7554
},
7655
};
7756

78-
const spinner = {
79-
start(message: string): void {
80-
spinnerMessage = message;
81-
frameIndex = 0;
82-
83-
// Initial render
84-
process.stdout.write(`${colors.cyan}${spinnerFrames[frameIndex]}${colors.reset} ${spinnerMessage}`);
85-
86-
// Start animation
87-
spinnerInterval = setInterval(() => {
88-
frameIndex = (frameIndex + 1) % spinnerFrames.length;
89-
clearLine();
90-
process.stdout.write(`${colors.cyan}${spinnerFrames[frameIndex]}${colors.reset} ${spinnerMessage}`);
91-
}, 80);
92-
},
93-
94-
succeed(message: string): void {
95-
if (spinnerInterval) {
96-
clearInterval(spinnerInterval);
97-
spinnerInterval = null;
98-
}
99-
clearLine();
100-
process.stdout.write(`${colors.green}${colors.reset} ${message}\n`);
101-
},
102-
103-
fail(message: string): void {
104-
if (spinnerInterval) {
105-
clearInterval(spinnerInterval);
106-
spinnerInterval = null;
107-
}
108-
clearLine();
109-
process.stderr.write(`${colors.red}${colors.reset} ${message}\n`);
110-
},
111-
112-
stop(): void {
113-
if (spinnerInterval) {
114-
clearInterval(spinnerInterval);
115-
spinnerInterval = null;
116-
}
117-
clearLine();
118-
},
119-
};
120-
121-
const formatConfig = (config: unknown): string => {
122-
return JSON.stringify(config, null, 2);
123-
};
124-
125-
return {
126-
log,
127-
spinner,
128-
formatConfig,
129-
};
57+
return { log };
13058
}
13159

13260
/**

mcp-server/src/mcp/mcp.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
55

66
@Controller()
77
export class McpController {
8-
// Note: This simple implementation assumes a single client connection for simplicity.
9-
// For production with multiple clients, we would need session management.
8+
// Single-client SSE implementation. New connections replace existing ones.
9+
// For multi-client support, implement session-based transport management.
1010
private transport: SSEServerTransport | null = null;
1111

1212
constructor(private mcpService: McpService) {}

0 commit comments

Comments
 (0)