7cab32151e
- Added silent debugging for settings file loading failures in early-settings.ts. - Improved error logging in worker-utils.ts for health check and worker startup failures, including detailed error information and context.
33 lines
1020 B
TypeScript
33 lines
1020 B
TypeScript
import { join } from 'path';
|
|
import { homedir } from 'os';
|
|
import { existsSync, readFileSync } from 'fs';
|
|
import { silentDebug } from '../utils/silent-debug.js';
|
|
|
|
const SETTINGS_PATH = join(homedir(), '.claude-mem', 'settings.json');
|
|
|
|
interface EarlySettings {
|
|
CLAUDE_MEM_DATA_DIR?: string;
|
|
CLAUDE_MEM_LOG_LEVEL?: string;
|
|
CLAUDE_MEM_PYTHON_VERSION?: string;
|
|
CLAUDE_CODE_PATH?: string;
|
|
}
|
|
|
|
/**
|
|
* Load settings for early-stage modules (paths, logger)
|
|
* Falls back to env vars, then defaults
|
|
*/
|
|
export function loadEarlySetting(key: keyof EarlySettings, defaultValue: string): string {
|
|
// Priority: settings.json > env var > default
|
|
try {
|
|
if (existsSync(SETTINGS_PATH)) {
|
|
const data = JSON.parse(readFileSync(SETTINGS_PATH, 'utf-8'));
|
|
const fileValue = data.env?.[key];
|
|
if (fileValue !== undefined) return fileValue;
|
|
}
|
|
} catch (error) {
|
|
silentDebug('Failed to load settings file', { error, settingsPath: SETTINGS_PATH, key });
|
|
}
|
|
|
|
return process.env[key] || defaultValue;
|
|
}
|