bb0508d639
- Updated multiple hooks (context-hook, new-hook, save-hook, summary-hook, user-message-hook) to throw errors using `getWorkerRestartInstructions` for improved user guidance on worker connection issues. - Enhanced `handleWorkerError` function to utilize the new error message generator for consistent error reporting. - Modified `ensureWorkerRunning` function to provide detailed instructions based on the worker's state, including port information. - Introduced `getWorkerRestartInstructions` utility in `error-messages.ts` to generate platform-aware error messages for worker failures.
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
/**
|
|
* Platform-aware error message generator for worker connection failures
|
|
*/
|
|
|
|
export interface WorkerErrorMessageOptions {
|
|
port?: number;
|
|
includeSkillFallback?: boolean;
|
|
customPrefix?: string;
|
|
}
|
|
|
|
/**
|
|
* Generate platform-specific worker restart instructions
|
|
* @param options Configuration for error message generation
|
|
* @returns Formatted error message with platform-specific paths and commands
|
|
*/
|
|
export function getWorkerRestartInstructions(
|
|
options: WorkerErrorMessageOptions = {}
|
|
): string {
|
|
const {
|
|
port,
|
|
includeSkillFallback = false,
|
|
customPrefix
|
|
} = options;
|
|
|
|
const isWindows = process.platform === 'win32';
|
|
|
|
// Platform-specific directory paths
|
|
const pluginDir = isWindows
|
|
? '%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack'
|
|
: '~/.claude/plugins/marketplaces/thedotmack';
|
|
|
|
// Platform-specific terminal name
|
|
const terminal = isWindows
|
|
? 'Command Prompt or PowerShell'
|
|
: 'Terminal';
|
|
|
|
// Build error message
|
|
const prefix = customPrefix || 'Worker service connection failed.';
|
|
const portInfo = port ? ` (port ${port})` : '';
|
|
|
|
let message = `${prefix}${portInfo}\n\n`;
|
|
message += `To restart the worker:\n`;
|
|
message += `1. Exit Claude Code completely\n`;
|
|
message += `2. Open ${terminal}\n`;
|
|
message += `3. Navigate to: ${pluginDir}\n`;
|
|
message += `4. Run: npm run worker:restart`;
|
|
|
|
if (includeSkillFallback) {
|
|
message += `\n\nIf that doesn't work, try: /troubleshoot`;
|
|
}
|
|
|
|
return message;
|
|
}
|