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:
weishu
2026-01-05 18:38:58 +08:00
parent 45822afa49
commit c50621e85a
8 changed files with 214 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
/**
* Codex-specific system prompt for local mode.
*
* This prompt instructs Codex to call the hapi__change_title function
* to set appropriate chat session titles.
*/
import { trimIdent } from '@/utils/trimIdent';
/**
* Title instruction for Codex to call the hapi MCP tool.
* Note: Codex exposes MCP tools under the `functions.` namespace,
* so the tool is called as `functions.hapi__change_title`.
*/
export const TITLE_INSTRUCTION = trimIdent(`
Based on this message, call functions.hapi__change_title to change chat session title that would represent the current task. If chat idea would change dramatically - call this function again to update the title.
`);
/**
* The system prompt to inject via developer_instructions in local mode.
*/
export const codexSystemPrompt = TITLE_INSTRUCTION;