mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
feat: add MCP config and system prompt support for Codex local mode
Implements MCP server configuration and developer instructions support in Codex local mode, bringing it to parity with remote mode. Key additions: - buildMcpServerConfigArgs() and buildDeveloperInstructionsArg() utilities to construct -c config arguments for passing MCP servers and instructions to the Codex CLI at runtime - TITLE_INSTRUCTION for Codex to call hapi__change_title to update chat session titles dynamically - Codex local mode now starts hapi MCP bridge server and passes both MCP configuration and developer instructions to Claude, enabling full feature parity with remote mode Files changed: - New: codexMcpConfig.ts (utilities), systemPrompt.ts (prompt definition), codexMcpConfig.test.ts (comprehensive tests) - Updated: codexLocal.ts (accepts mcpServers, builds config args), codexLocalLauncher.ts (starts hapi server, passes config), codexStartConfig.ts (imports TITLE_INSTRUCTION)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { logger } from '@/ui/logger';
|
||||
import { restoreTerminalState } from '@/ui/terminalState';
|
||||
import { spawnWithAbort } from '@/utils/spawnWithAbort';
|
||||
import { buildMcpServerConfigArgs, buildDeveloperInstructionsArg } from './utils/codexMcpConfig';
|
||||
import { codexSystemPrompt } from './utils/systemPrompt';
|
||||
|
||||
/**
|
||||
* Filter out 'resume' subcommand which is managed internally by hapi.
|
||||
@@ -29,6 +31,7 @@ export async function codexLocal(opts: {
|
||||
sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access';
|
||||
onSessionFound: (id: string) => void;
|
||||
codexArgs?: string[];
|
||||
mcpServers?: Record<string, { command: string; args: string[] }>;
|
||||
}): Promise<void> {
|
||||
const args: string[] = [];
|
||||
|
||||
@@ -45,6 +48,14 @@ export async function codexLocal(opts: {
|
||||
args.push('--sandbox', opts.sandbox);
|
||||
}
|
||||
|
||||
// Add MCP server configuration
|
||||
if (opts.mcpServers && Object.keys(opts.mcpServers).length > 0) {
|
||||
args.push(...buildMcpServerConfigArgs(opts.mcpServers));
|
||||
}
|
||||
|
||||
// Add developer instructions (system prompt)
|
||||
args.push(...buildDeveloperInstructionsArg(codexSystemPrompt));
|
||||
|
||||
if (opts.codexArgs) {
|
||||
const safeArgs = filterResumeSubcommand(opts.codexArgs);
|
||||
args.push(...safeArgs);
|
||||
|
||||
Reference in New Issue
Block a user