Files
superwork/vscode/src/cc/codexCommand.ts
T
cruldra b585016cd7 feat(vscode): 头脑风暴 profile 独立 + codex 命令统一组装收尾
- 头脑风暴/实施/测试会话 profile 彻底独立,互不回退,各自空值回落默认
- 新建工单弹窗的 profile 选择改为头脑风暴专用 brainstormProfilePath
- 详情面板新增「头脑风暴配置文件」下拉
- 删除从未接线的死代码 reviewFlow.ts(runReview 全仓库无调用方)
- codexCommand 精简为仅 resume/interactive 两种终端命令形态
- 版本号 0.2.55 → 0.2.60
2026-07-13 07:50:39 +08:00

51 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Single source of truth for assembling `codex` invocations.
*
* The review flow shells codex two ways — `codex resume <id>` and the
* interactive `codex '<prompt>'` TUI — both sent to a terminal. Building the
* flags in one place keeps `--dangerously-bypass-approvals-and-sandbox` and the
* optional model / reasoning-effort `-c` overrides from drifting apart.
*
* Model and reasoning effort are free-form: an empty value omits the override
* so codex falls back to its own `config.toml` default.
*/
export interface CodexCommandOpts {
/** 'resume' = `codex resume <id>`'interactive' = `codex '<prompt>'` */
mode: 'resume' | 'interactive'
/** resume 模式必填:codex thread id */
sessionId?: string
/** interactive 模式的 promptpositional)。调用方保证不含单引号。 */
prompt?: string
/** 空 = 不传 `-c model=`,用 codex 默认 */
model?: string
/** 空 = 不传 `-c model_reasoning_effort=`,用 codex 默认。合法值 minimal/low/medium/high/xhigh */
reasoningEffort?: string
}
const BYPASS_FLAG = '--dangerously-bypass-approvals-and-sandbox'
/**
* `-c key=value` overrides for model / reasoning effort. Blank values are
* dropped so codex keeps its config.toml default.
*/
function configOverrides(opts: CodexCommandOpts): string[] {
const parts: string[] = []
const model = opts.model?.trim()
if (model)
parts.push('-c', `model=${model}`)
const effort = opts.reasoningEffort?.trim()
if (effort)
parts.push('-c', `model_reasoning_effort=${effort}`)
return parts
}
/** Full shell command string (with `codex` prefix) for `terminal.sendText`. */
export function buildCodexCommandString(opts: CodexCommandOpts): string {
const overrides = configOverrides(opts)
const parts = opts.mode === 'resume'
? ['resume', ...overrides, BYPASS_FLAG, ...(opts.sessionId ? [opts.sessionId] : [])]
: [...overrides, BYPASS_FLAG, ...(opts.prompt ? [`'${opts.prompt}'`] : [])]
return ['codex', ...parts].join(' ')
}