Skip to content

Commit f083a57

Browse files
darion-yaphetthedotmack
authored andcommitted
Merge PR #2981: route settings diagnostics through emitDiagnostic
Preserves PR #2981 by darion-yaphet.
2 parents 8085ba4 + 2715ef8 commit f083a57

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/shared/SettingsDefaultsManager.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { chmodSync, readFileSync, writeFileSync, existsSync, mkdirSync } from 'f
33
import { join, dirname } from 'path';
44
import { homedir } from 'os';
55
import { HOOK_TIMEOUTS, getTimeout } from './hook-constants.js';
6+
import { emitDiagnostic } from './hook-io.js';
67

78
export const SETTINGS_FILE_MODE = 0o600;
89

@@ -243,10 +244,12 @@ export class SettingsDefaultsManager {
243244
writeSettingsFileSecure(settingsPath, defaults);
244245
// stderr, never stdout: this fires on the first boot in a fresh data
245246
// dir, and CLI commands like `start` promise machine-readable JSON
246-
// on stdout to the hook framework.
247-
console.warn('[SETTINGS] Created settings file with defaults:', settingsPath);
247+
// on stdout to the hook framework. emitDiagnostic routes through the
248+
// same channel logger uses so the line survives the Phase 2 hook
249+
// stderr buffer (#2292) instead of being swallowed by raw console.
250+
emitDiagnostic(`[SETTINGS] Created settings file with defaults: ${settingsPath}\n`);
248251
} catch (error: unknown) {
249-
console.warn('[SETTINGS] Failed to create settings file, using in-memory defaults:', settingsPath, error instanceof Error ? error.message : String(error));
252+
emitDiagnostic(`[SETTINGS] Failed to create settings file, using in-memory defaults: ${settingsPath} ${error instanceof Error ? error.message : String(error)}\n`);
250253
}
251254
return applyEnvOverrides ? this.applyEnvOverrides(defaults) : defaults;
252255
}
@@ -270,9 +273,9 @@ export class SettingsDefaultsManager {
270273
try {
271274
writeSettingsFileSecure(settingsPath, flatSettings);
272275
// stderr, never stdout — same JSON-on-stdout contract as above.
273-
console.warn('[SETTINGS] Migrated settings file from nested to flat schema:', settingsPath);
276+
emitDiagnostic(`[SETTINGS] Migrated settings file from nested to flat schema: ${settingsPath}\n`);
274277
} catch (error: unknown) {
275-
console.warn('[SETTINGS] Failed to auto-migrate settings file:', settingsPath, error instanceof Error ? error.message : String(error));
278+
emitDiagnostic(`[SETTINGS] Failed to auto-migrate settings file: ${settingsPath} ${error instanceof Error ? error.message : String(error)}\n`);
276279
// Continue with in-memory migration even if write fails
277280
}
278281
}
@@ -286,7 +289,7 @@ export class SettingsDefaultsManager {
286289

287290
return applyEnvOverrides ? this.applyEnvOverrides(result) : result;
288291
} catch (error: unknown) {
289-
console.warn('[SETTINGS] Failed to load settings, using defaults:', settingsPath, error instanceof Error ? error.message : String(error));
292+
emitDiagnostic(`[SETTINGS] Failed to load settings, using defaults: ${settingsPath} ${error instanceof Error ? error.message : String(error)}\n`);
290293
const defaults = this.getAllDefaults();
291294
return applyEnvOverrides ? this.applyEnvOverrides(defaults) : defaults;
292295
}

0 commit comments

Comments
 (0)