Skip to content

Commit 892b04f

Browse files
wishket-pjwJeremyDev87
authored andcommitted
refactor(config): remove unused functions
- Remove getDefaultConfig, mergeWithDefaults (never used) - Remove getFilesByType export (only used internally) - Clean up exports and tests close #32
1 parent 04200d8 commit 892b04f

5 files changed

Lines changed: 3 additions & 149 deletions

File tree

mcp-server/src/config/config.schema.spec.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { describe, it, expect } from 'vitest';
22
import {
33
validateConfig,
44
parseConfig,
5-
getDefaultConfig,
6-
mergeWithDefaults,
75
isCodingBuddyConfig,
86
CodingBuddyConfigSchema,
97
} from './config.schema';
@@ -203,59 +201,6 @@ describe('CodingBuddyConfigSchema', () => {
203201
});
204202
});
205203

206-
describe('getDefaultConfig', () => {
207-
it('should return empty object as default', () => {
208-
const defaults = getDefaultConfig();
209-
expect(defaults).toEqual({});
210-
});
211-
});
212-
213-
describe('mergeWithDefaults', () => {
214-
it('should merge user config with defaults', () => {
215-
const userConfig: CodingBuddyConfig = {
216-
language: 'ko',
217-
projectName: 'my-app',
218-
};
219-
220-
const result = mergeWithDefaults(userConfig);
221-
expect(result.language).toBe('ko');
222-
expect(result.projectName).toBe('my-app');
223-
});
224-
225-
it('should preserve user config values', () => {
226-
const userConfig: CodingBuddyConfig = {
227-
techStack: {
228-
frontend: ['React'],
229-
},
230-
};
231-
232-
const result = mergeWithDefaults(userConfig);
233-
expect(result.techStack?.frontend).toEqual(['React']);
234-
});
235-
236-
it('should deep merge nested objects', () => {
237-
// Since defaults are empty, this mainly tests that nested objects are preserved
238-
const userConfig: CodingBuddyConfig = {
239-
techStack: {
240-
frontend: ['React'],
241-
backend: ['NestJS'],
242-
},
243-
conventions: {
244-
style: 'airbnb',
245-
naming: {
246-
files: 'kebab-case',
247-
},
248-
},
249-
};
250-
251-
const result = mergeWithDefaults(userConfig);
252-
expect(result.techStack?.frontend).toEqual(['React']);
253-
expect(result.techStack?.backend).toEqual(['NestJS']);
254-
expect(result.conventions?.style).toBe('airbnb');
255-
expect(result.conventions?.naming?.files).toBe('kebab-case');
256-
});
257-
});
258-
259204
describe('schema type inference', () => {
260205
it('should correctly infer types from schema', () => {
261206
const config = CodingBuddyConfigSchema.parse({

mcp-server/src/config/config.schema.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -156,47 +156,3 @@ export function isCodingBuddyConfig(value: unknown): value is CodingBuddyConfig
156156
return CodingBuddyConfigSchema.safeParse(value).success;
157157
}
158158

159-
/**
160-
* Get default configuration values
161-
*/
162-
export function getDefaultConfig(): CodingBuddyConfig {
163-
return {};
164-
}
165-
166-
/**
167-
* Deep merge utility for nested objects
168-
*/
169-
function deepMerge<T extends Record<string, unknown>>(target: T, source: T): T {
170-
const result = { ...target };
171-
172-
for (const key of Object.keys(source) as Array<keyof T>) {
173-
const sourceValue = source[key];
174-
const targetValue = target[key];
175-
176-
if (
177-
sourceValue !== undefined &&
178-
typeof sourceValue === 'object' &&
179-
sourceValue !== null &&
180-
!Array.isArray(sourceValue) &&
181-
typeof targetValue === 'object' &&
182-
targetValue !== null &&
183-
!Array.isArray(targetValue)
184-
) {
185-
result[key] = deepMerge(
186-
targetValue as Record<string, unknown>,
187-
sourceValue as Record<string, unknown>,
188-
) as T[keyof T];
189-
} else if (sourceValue !== undefined) {
190-
result[key] = sourceValue;
191-
}
192-
}
193-
194-
return result;
195-
}
196-
197-
/**
198-
* Merge user config with defaults (deep merge)
199-
*/
200-
export function mergeWithDefaults(userConfig: CodingBuddyConfig): CodingBuddyConfig {
201-
return deepMerge(getDefaultConfig(), userConfig);
202-
}

mcp-server/src/config/context.loader.spec.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { describe, it, expect } from 'vitest';
22
import {
33
getContextFileType,
44
isLoadableFile,
5-
getFilesByType,
65
formatContextForAI,
76
type ContextFile,
87
} from './context.loader';
@@ -62,45 +61,6 @@ describe('context.loader', () => {
6261
});
6362
});
6463

65-
describe('getFilesByType', () => {
66-
const mockFiles: ContextFile[] = [
67-
{ path: 'context/arch.md', content: 'arch', type: 'context', extension: '.md' },
68-
{ path: 'context/api.md', content: 'api', type: 'context', extension: '.md' },
69-
{ path: 'prompts/review.md', content: 'review', type: 'prompt', extension: '.md' },
70-
{ path: 'agents/dev.json', content: '{}', type: 'agent', extension: '.json' },
71-
{ path: 'readme.md', content: 'readme', type: 'other', extension: '.md' },
72-
];
73-
74-
it('should filter by context type', () => {
75-
const result = getFilesByType(mockFiles, 'context');
76-
expect(result).toHaveLength(2);
77-
expect(result.map((f) => f.path)).toEqual(['context/arch.md', 'context/api.md']);
78-
});
79-
80-
it('should filter by prompt type', () => {
81-
const result = getFilesByType(mockFiles, 'prompt');
82-
expect(result).toHaveLength(1);
83-
expect(result[0].path).toBe('prompts/review.md');
84-
});
85-
86-
it('should filter by agent type', () => {
87-
const result = getFilesByType(mockFiles, 'agent');
88-
expect(result).toHaveLength(1);
89-
expect(result[0].path).toBe('agents/dev.json');
90-
});
91-
92-
it('should filter by other type', () => {
93-
const result = getFilesByType(mockFiles, 'other');
94-
expect(result).toHaveLength(1);
95-
expect(result[0].path).toBe('readme.md');
96-
});
97-
98-
it('should return empty array for no matches', () => {
99-
const result = getFilesByType([], 'context');
100-
expect(result).toEqual([]);
101-
});
102-
});
103-
10464
describe('formatContextForAI', () => {
10565
it('should format context files correctly', () => {
10666
const files: ContextFile[] = [

mcp-server/src/config/context.loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ export async function loadContextFiles(projectRoot: string): Promise<ContextLoad
170170
}
171171

172172
/**
173-
* Get context files by type
173+
* Get context files by type (internal helper)
174174
*/
175-
export function getFilesByType(files: ContextFile[], type: ContextFileType): ContextFile[] {
175+
function getFilesByType(files: ContextFile[], type: ContextFileType): ContextFile[] {
176176
return files.filter((f) => f.type === type);
177177
}
178178

mcp-server/src/config/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ export {
3434

3535
export type { ValidationResult, ValidationError } from './config.schema';
3636

37-
export {
38-
validateConfig,
39-
parseConfig,
40-
getDefaultConfig,
41-
mergeWithDefaults,
42-
isCodingBuddyConfig,
43-
} from './config.schema';
37+
export { validateConfig, parseConfig, isCodingBuddyConfig } from './config.schema';
4438

4539
// ============================================================================
4640
// Config Loader
@@ -82,7 +76,6 @@ export {
8276
CONTEXT_DIR_NAME,
8377
KNOWN_SUBDIRS,
8478
loadContextFiles,
85-
getFilesByType,
8679
formatContextForAI,
8780
hasContextDir,
8881
} from './context.loader';

0 commit comments

Comments
 (0)