Skip to content

Commit 8886166

Browse files
PaulJPhilpclaude
andcommitted
refactor: remove ~80 dead symbols and files across 6 packages
Remove unused code identified post api-server/mcp-transport split: - api-server: legacy cache helpers, unused logger functions - ep-admin: basic-commands, pipeline-commands, TUI adapters, unused error classes, runtime/index re-export - ep-cli: execution service, display service, skill-generator, config/env, runtime/test, unused error classes - ep-shared-services: pattern-presentation, normalize-pattern, render-card/index-markdown, clean-pattern-service, pattern-types - mcp-transport: MCP_2_0_IMPROVEMENTS, oauth-client, unused cache key helpers - toolkit: io module, cache/search/validation services, unused re-exports 69 files changed, ~8,800 lines removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e27c2bb commit 8886166

69 files changed

Lines changed: 186 additions & 8787 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/api-server/src/services/cache/helpers.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,3 @@ export const isExpired = (entry: CacheEntry<unknown>): boolean => {
2222
return Date.now() - entry.timestamp > entry.ttl;
2323
};
2424

25-
/**
26-
* Legacy cache functions (for backward compatibility)
27-
*/
28-
export function getCacheKey(...parts: string[]): string {
29-
return parts.join(":");
30-
}
31-
32-
export function createCacheKey(prefix: string, id: string): string {
33-
return `${prefix}:${id}`;
34-
}

packages/api-server/src/services/logger/__tests__/logger.test.ts

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Effect, Layer } from "effect";
22
import { describe, expect, it } from "vitest";
33
import { MCPConfigService } from "../../config";
4-
import { createLogEntry, logDebug, logError, logInfo, logWarn } from "../helpers";
4+
import { createLogEntry } from "../helpers";
55
import { MCPLoggerService } from "../index";
66

77
const TestLayer = Layer.provideMerge(
@@ -291,113 +291,4 @@ describe("Logger Helpers", () => {
291291
});
292292
});
293293

294-
describe("Legacy logging functions", () => {
295-
// Capture console output without mocks
296-
function captureConsoleOutput(
297-
method: "log" | "warn" | "error"
298-
): { output: string[]; restore: () => void } {
299-
const output: string[] = [];
300-
const original = console[method];
301-
302-
console[method] = ((...args: unknown[]) => {
303-
output.push(args.map(String).join(" "));
304-
}) as any;
305-
306-
return {
307-
output,
308-
restore: () => {
309-
console[method] = original;
310-
},
311-
};
312-
}
313-
314-
it("logDebug should log debug message", () => {
315-
const { output, restore } = captureConsoleOutput("error");
316-
const originalDebug = process.env.MCP_DEBUG;
317-
try {
318-
process.env.MCP_DEBUG = "true";
319-
logDebug("Debug message", { key: "value" });
320-
expect(output.length).toBeGreaterThan(0);
321-
const parsed = JSON.parse(output[0]!);
322-
expect(parsed.level).toBe("debug");
323-
expect(parsed.message).toBe("Debug message");
324-
expect(parsed.data).toEqual({ key: "value" });
325-
} finally {
326-
restore();
327-
if (originalDebug === undefined) {
328-
delete process.env.MCP_DEBUG;
329-
} else {
330-
process.env.MCP_DEBUG = originalDebug;
331-
}
332-
}
333-
});
334-
335-
it("logInfo should log info message", () => {
336-
const { output, restore } = captureConsoleOutput("error");
337-
try {
338-
logInfo("Info message", { key: "value" });
339-
expect(output.length).toBeGreaterThan(0);
340-
const parsed = JSON.parse(output[output.length - 1]!);
341-
expect(parsed.level).toBe("info");
342-
expect(parsed.message).toBe("Info message");
343-
} finally {
344-
restore();
345-
}
346-
});
347-
348-
it("logWarn should log warning message", () => {
349-
const { output, restore } = captureConsoleOutput("warn");
350-
try {
351-
logWarn("Warning message", { key: "value" });
352-
expect(output.length).toBeGreaterThan(0);
353-
const parsed = JSON.parse(output[0]!);
354-
expect(parsed.level).toBe("warn");
355-
expect(parsed.message).toBe("Warning message");
356-
} finally {
357-
restore();
358-
}
359-
});
360-
361-
it("logError should log error message with Error object", () => {
362-
const { output, restore } = captureConsoleOutput("error");
363-
try {
364-
const error = new Error("Test error");
365-
logError("Error message", error, { key: "value" });
366-
expect(output.length).toBeGreaterThan(0);
367-
const parsed = JSON.parse(output[0]!);
368-
expect(parsed.level).toBe("error");
369-
expect(parsed.message).toBe("Error message");
370-
expect(parsed.error.name).toBe("Error");
371-
expect(parsed.error.message).toBe("Test error");
372-
} finally {
373-
restore();
374-
}
375-
});
376-
377-
it("logError should log error message with unknown error", () => {
378-
const { output, restore } = captureConsoleOutput("error");
379-
try {
380-
logError("Error message", "String error", { key: "value" });
381-
expect(output.length).toBeGreaterThan(0);
382-
const parsed = JSON.parse(output[0]!);
383-
expect(parsed.error.name).toBe("UnknownError");
384-
expect(parsed.error.message).toBe("String error");
385-
} finally {
386-
restore();
387-
}
388-
});
389-
390-
it("logError should log error message without error", () => {
391-
const { output, restore } = captureConsoleOutput("error");
392-
try {
393-
logError("Error message", undefined, { key: "value" });
394-
expect(output.length).toBeGreaterThan(0);
395-
const parsed = JSON.parse(output[0]!);
396-
expect(parsed.level).toBe("error");
397-
expect(parsed.error).toBeUndefined();
398-
} finally {
399-
restore();
400-
}
401-
});
402-
});
403294
});

packages/api-server/src/services/logger/helpers.ts

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -51,100 +51,3 @@ export const createLogEntry = (
5151
return baseEntry;
5252
};
5353

54-
/**
55-
* Log levels and their priorities
56-
*/
57-
const LOG_LEVELS: Record<string, number> = {
58-
debug: 0,
59-
info: 1,
60-
warn: 2,
61-
error: 3,
62-
};
63-
64-
/**
65-
* Get current log level priority
66-
*/
67-
function getLogLevelPriority(): number {
68-
const defaultLevel = process.env.NODE_ENV === "production" ? "warn" : "info";
69-
const level = process.env.LOG_LEVEL || defaultLevel;
70-
// MCP_DEBUG=true forces debug level
71-
if (process.env.MCP_DEBUG === "true") return LOG_LEVELS.debug;
72-
return LOG_LEVELS[level.toLowerCase()] ?? LOG_LEVELS[defaultLevel];
73-
}
74-
75-
/**
76-
* Legacy logging functions (for backward compatibility)
77-
*/
78-
export function logDebug(
79-
message: string,
80-
data?: Record<string, unknown>
81-
): void {
82-
if (getLogLevelPriority() <= LOG_LEVELS.debug) {
83-
console.error(
84-
JSON.stringify({
85-
timestamp: new Date().toISOString(),
86-
level: "debug",
87-
message,
88-
data,
89-
})
90-
);
91-
}
92-
}
93-
94-
export function logInfo(message: string, data?: Record<string, unknown>): void {
95-
if (getLogLevelPriority() <= LOG_LEVELS.info) {
96-
console.error(
97-
JSON.stringify({
98-
timestamp: new Date().toISOString(),
99-
level: "info",
100-
message,
101-
data,
102-
})
103-
);
104-
}
105-
}
106-
107-
export function logWarn(message: string, data?: Record<string, unknown>): void {
108-
if (getLogLevelPriority() <= LOG_LEVELS.warn) {
109-
console.warn(
110-
JSON.stringify({
111-
timestamp: new Date().toISOString(),
112-
level: "warn",
113-
message,
114-
data,
115-
})
116-
);
117-
}
118-
}
119-
120-
export function logError(
121-
message: string,
122-
error?: unknown,
123-
data?: Record<string, unknown>
124-
): void {
125-
if (getLogLevelPriority() <= LOG_LEVELS.error) {
126-
const logEntry: any = {
127-
timestamp: new Date().toISOString(),
128-
level: "error",
129-
message,
130-
data,
131-
};
132-
133-
if (error) {
134-
if (error instanceof Error) {
135-
logEntry.error = {
136-
name: error.name,
137-
message: error.message,
138-
stack: error.stack,
139-
};
140-
} else {
141-
logEntry.error = {
142-
name: "UnknownError",
143-
message: String(error),
144-
};
145-
}
146-
}
147-
148-
console.error(JSON.stringify(logEntry));
149-
}
150-
}

packages/api-server/src/tracing/otlpLayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Effect } from "effect";
1616
/**
1717
* Tracing configuration from environment variables
1818
*/
19-
export interface TracingConfig {
19+
interface TracingConfig {
2020
readonly otlpEndpoint: string;
2121
readonly otlpHeaders: Record<string, string>;
2222
readonly serviceName: string;

0 commit comments

Comments
 (0)