chore: set up pre-commit framework with general hooks

Add .pre-commit-config.yaml with pre-commit-hooks v5.0.0 (trailing
whitespace, end-of-file fixer, yaml/json checks, large file guard,
merge conflict detection). Add minimal pyproject.toml. Auto-fix
trailing whitespace and missing end-of-file newlines across the
codebase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-03-29 12:58:36 +01:00
parent 41ae1ba82c
commit eee5bfb9ed
26 changed files with 322 additions and 385 deletions

View File

@@ -18,7 +18,7 @@ const DEFAULT_LOG_DIR = join(os.homedir(), '.kicad-mcp', 'logs');
class Logger {
private logLevel: LogLevel = 'info';
private logDir: string = DEFAULT_LOG_DIR;
/**
* Set the log level
* @param level Log level to set
@@ -26,20 +26,20 @@ class Logger {
setLogLevel(level: LogLevel): void {
this.logLevel = level;
}
/**
* Set the log directory
* @param dir Directory to store log files
*/
setLogDir(dir: string): void {
this.logDir = dir;
// Ensure log directory exists
if (!existsSync(this.logDir)) {
mkdirSync(this.logDir, { recursive: true });
}
}
/**
* Log an error message
* @param message Message to log
@@ -47,7 +47,7 @@ class Logger {
error(message: string): void {
this.log('error', message);
}
/**
* Log a warning message
* @param message Message to log
@@ -57,7 +57,7 @@ class Logger {
this.log('warn', message);
}
}
/**
* Log an info message
* @param message Message to log
@@ -67,7 +67,7 @@ class Logger {
this.log('info', message);
}
}
/**
* Log a debug message
* @param message Message to log
@@ -77,7 +77,7 @@ class Logger {
this.log('debug', message);
}
}
/**
* Log a message with the specified level
* @param level Log level
@@ -93,14 +93,14 @@ class Logger {
// Log to console.error (stderr) only - stdout is reserved for MCP protocol
// All log levels go to stderr to avoid corrupting STDIO MCP transport
console.error(formattedMessage);
// Log to file
try {
// Ensure log directory exists
if (!existsSync(this.logDir)) {
mkdirSync(this.logDir, { recursive: true });
}
const logFile = join(this.logDir, `kicad-mcp-${new Date().toISOString().split('T')[0]}.log`);
appendFileSync(logFile, formattedMessage + '\n');
} catch (error) {