mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-07 01:21:37 +00:00
Restructure CLI entry point and RPC handler registration to improve maintainability: - Introduce command registry pattern with CommandDefinition interface for consistent command structure - Extract individual command modules (claude, codex, daemon, doctor, gemini, auth, connect, etc.) - Move RPC handlers into separate feature modules (bash, files, git, directories, ripgrep, difftastic, slashCommands) - Create shared RPC types and response helpers (rpcTypes.ts, rpcResponses.ts) - Move SpawnSessionOptions and SpawnSessionResult to rpcTypes for proper type organization - Simplify index.ts to minimal entrypoint using command registry - Update imports in apiMachine.ts and daemon/run.ts to use rpcTypes module This enables: - Better code organization by feature/command - Easier testing of individual commands - Safer RPC handler registration without side effects - Clearer separation of concerns between routing and business logic
25 lines
840 B
TypeScript
25 lines
840 B
TypeScript
import chalk from 'chalk'
|
|
import type { CommandDefinition } from './types'
|
|
|
|
export async function handleConnectCommand(_args: string[]): Promise<void> {
|
|
console.error(chalk.red('The `hapi connect` command is not available in direct-connect mode.'))
|
|
console.error(chalk.gray('Vendor token storage was part of the hosted server flow.'))
|
|
process.exit(1)
|
|
}
|
|
|
|
export const connectCommand: CommandDefinition = {
|
|
name: 'connect',
|
|
requiresRuntimeAssets: true,
|
|
run: async ({ commandArgs }) => {
|
|
try {
|
|
await handleConnectCommand(commandArgs)
|
|
} catch (error) {
|
|
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error')
|
|
if (process.env.DEBUG) {
|
|
console.error(error)
|
|
}
|
|
process.exit(1)
|
|
}
|
|
}
|
|
}
|