feat(vscode): codex 命令统一组装,模型/思考级别可在设置面板配置

新增 cc/codexCommand.ts 作为 codex 调用的唯一出口(buildCodexArgs /
buildCodexCommandString),把 exec-review / resume / interactive 三种形态
的 flag 拼装收敛到一处;模型与思考级别作为自由文本项写入全局设置并贯穿
webview 消息通道,空值则不传 -c,沿用 codex config.toml 默认。
This commit is contained in:
2026-07-13 06:43:58 +08:00
parent aff99c57f3
commit 5188c23765
11 changed files with 225 additions and 12 deletions
+4
View File
@@ -855,6 +855,8 @@ export class KanbanWebviewPanel {
implTabPreCreateScript: s.implTabPreCreateScript,
implTabPostCloseScript: s.implTabPostCloseScript,
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
codexModel: s.codexModel,
codexReasoningEffort: s.codexReasoningEffort,
})
return
}
@@ -918,6 +920,8 @@ export class KanbanWebviewPanel {
implTabPreCreateScript: s.implTabPreCreateScript,
implTabPostCloseScript: s.implTabPostCloseScript,
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
codexModel: s.codexModel,
codexReasoningEffort: s.codexReasoningEffort,
})
return
}
+22 -3
View File
@@ -9,6 +9,7 @@ import * as path from 'node:path'
import { window, workspace } from 'vscode'
import { getToken } from '../../auth/secrets'
import { buildCcCommand } from '../../cc/ccCommand'
import { buildCodexCommandString } from '../../cc/codexCommand'
import { watchForNewCodexSession } from '../../cc/codexSessionWatcher'
import { getBrainstormContinuePrompt, getImplementPlanPrompt } from '../../cc/prompts'
import { projectsDirFor, watchForNewSession } from '../../cc/sessionWatcher'
@@ -287,7 +288,13 @@ export async function handleResumeReviewSession(panel: KanbanWebviewPanel, sessi
panel.reviewTerminals.set(sessionId, terminal)
panel.trackSessionTerminal(terminal, issueNumber, 'review')
terminal.show(false)
terminal.sendText(`codex resume -c model_reasoning_effort=xhigh --dangerously-bypass-approvals-and-sandbox ${sessionId}`)
const settings = getSettings(panel.context)
terminal.sendText(buildCodexCommandString({
mode: 'resume',
sessionId,
model: settings.codexModel,
reasoningEffort: settings.codexReasoningEffort,
}))
logger.add({
level: 'info',
source: 'terminal',
@@ -418,7 +425,13 @@ export async function triggerAutoReviewTab(panel: KanbanWebviewPanel, opts: {
panel.reviewTerminals.set(existingSessionId, terminal)
panel.trackSessionTerminal(terminal, opts.issueNumber, 'review')
terminal.show(false)
terminal.sendText(`codex resume -c model_reasoning_effort=xhigh --dangerously-bypass-approvals-and-sandbox ${existingSessionId}`)
const settings = getSettings(panel.context)
terminal.sendText(buildCodexCommandString({
mode: 'resume',
sessionId: existingSessionId,
model: settings.codexModel,
reasoningEffort: settings.codexReasoningEffort,
}))
// codex resume rebuilds the conversation from the jsonl rollout
// before the TUI accepts input — empirically much slower than the
// 250ms gap the reuse path uses. 8s is a conservative guess that
@@ -494,7 +507,13 @@ export async function triggerAutoReviewTab(panel: KanbanWebviewPanel, opts: {
// the terminal alive after the run so users can follow up with codex,
// mirroring how claude implementation/brainstorm sessions stay open.
// 提示词模板自带 /review 前缀,不在这里再拼。
const cmd = `codex -c model_reasoning_effort=xhigh --dangerously-bypass-approvals-and-sandbox '${opts.prompt}'`
const settings = getSettings(panel.context)
const cmd = buildCodexCommandString({
mode: 'interactive',
prompt: opts.prompt,
model: settings.codexModel,
reasoningEffort: settings.codexReasoningEffort,
})
terminal.sendText(cmd)
logger.add({
level: 'info',
+11
View File
@@ -33,6 +33,8 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
implTabPreCreateScript: string
implTabPostCloseScript: string
conflictResolutionProfilePath: string
codexModel: string
codexReasoningEffort: string
youtrackBaseUrl: string
youtrackProjectShortName: string
youtrackCloseCommand: string
@@ -61,6 +63,9 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
const trimmedImplPost = payload.implTabPostCloseScript.trim()
// conflict-resolution profile: '' is meaningful (= DEFAULT_PROFILE_PATH).
const trimmedConflictProfile = payload.conflictResolutionProfilePath.trim()
// codex 模型 / 思考级别:空串有意义(= 用 codex 默认),只 trim。
const trimmedCodexModel = payload.codexModel.trim()
const trimmedCodexReasoningEffort = payload.codexReasoningEffort.trim()
const prev = getSettings(panel.context)
// Capture the previous token *for this host* before overwriting it, so
// we can decide below whether the kanban needs a re-fetch. (Only host
@@ -91,6 +96,8 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
implTabPreCreateScript: trimmedImplPre,
implTabPostCloseScript: trimmedImplPost,
conflictResolutionProfilePath: trimmedConflictProfile,
codexModel: trimmedCodexModel,
codexReasoningEffort: trimmedCodexReasoningEffort,
})
return
}
@@ -113,6 +120,8 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
implTabPreCreateScript: trimmedImplPre,
implTabPostCloseScript: trimmedImplPost,
conflictResolutionProfilePath: trimmedConflictProfile,
codexModel: trimmedCodexModel,
codexReasoningEffort: trimmedCodexReasoningEffort,
youtrackBaseUrl: trimmedYtBase,
youtrackProjectShortName: trimmedYtProject,
youtrackCloseCommand: trimmedYtClose,
@@ -196,6 +205,8 @@ export async function handleEditSettingsRequest(panel: KanbanWebviewPanel): Prom
implTabPreCreateScript: s.implTabPreCreateScript,
implTabPostCloseScript: s.implTabPostCloseScript,
conflictResolutionProfilePath: s.conflictResolutionProfilePath,
codexModel: s.codexModel,
codexReasoningEffort: s.codexReasoningEffort,
youtrackBaseUrl: s.youtrackBaseUrl,
youtrackProjectShortName: s.youtrackProjectShortName,
youtrackCloseCommand: s.youtrackCloseCommand,
+4
View File
@@ -67,6 +67,8 @@ export type ExtensionToWebview
implTabPreCreateScript: string
implTabPostCloseScript: string
conflictResolutionProfilePath: string
codexModel: string
codexReasoningEffort: string
youtrackBaseUrl?: string
youtrackProjectShortName?: string
youtrackCloseCommand?: string
@@ -129,6 +131,8 @@ export type WebviewToExtension
implTabPreCreateScript: string
implTabPostCloseScript: string
conflictResolutionProfilePath: string
codexModel: string
codexReasoningEffort: string
youtrackBaseUrl: string
youtrackProjectShortName: string
youtrackCloseCommand: string