Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs: use supported lean Codex commit generation settings (#4261)
Maximilian Roosf732cbda7296
diff --git a/Taskfile.yaml b/Taskfile.yamlindex 87cc61db1..253bf1ddc 100644--- a/Taskfile.yaml+++ b/Taskfile.yaml@@ -365,7 +365,7 @@ tasks:COMMANDS["claude"]='MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='"'"''"'"' --safe-mode --setting-sources='"'"'user'"'"' --system-prompt='"'"''"'"''COMMANDS["llm"]='llm -m claude-haiku-4.5'COMMANDS["aichat"]='aichat -m claude:claude-haiku-4.5'- COMMANDS["codex"]='codex exec -m gpt-5.6-luna -c model_reasoning_effort='"'"'low'"'"' -c system_prompt='"'"''"'"' --sandbox=read-only --json - | jq -sr '"'"'[.[] | select(.item.type? == "agent_message")] | last.item.text'"'"''+ COMMANDS["codex"]='codex exec -m gpt-6-luna -c model_reasoning_effort='"'"'none'"'"' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c '"'"'model_instructions_file="~/.codex/worktrunk-commit-instructions.txt"'"'"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '"'"'[.[] | select(.item.type? == "agent_message")] | last.item.text'"'"''COMMANDS["opencode"]='opencode run -m anthropic/claude-haiku-4.5 --variant fast'# Check which tools are available@@ -381,10 +381,20 @@ tasks:echo " ✗ $tool (not installed)"fidone+ CODEX_READY=trueif command -v jq &>/dev/null; thenecho " ✓ jq (required for codex)"elseecho " ✗ jq (required for codex)"+ CODEX_READY=false+ fi+ if [ -s "$HOME/.codex/worktrunk-commit-instructions.txt" ]; then+ echo " ✓ Codex commit instructions"+ else+ echo " ✗ Codex commit instructions (see llm-commits.md)"+ CODEX_READY=false+ fi+ if [ "$CODEX_READY" = false ]; then# Drop codex from the list. String substitution (${AVAILABLE[@]/codex})# would rewrite the element to "" rather than remove it, leaving an# empty tool name to iterate over later — rebuild the array instead.diff --git a/dev/config.example.toml b/dev/config.example.tomlindex d8a7c0a41..cff232c64 100644--- a/dev/config.example.toml+++ b/dev/config.example.toml@@ -67,8 +67,10 @@## ### Codex#+# Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+## [commit.generation]-# command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+# command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"## ### OpenCode#diff --git a/docs/src/content/docs/config.md b/docs/src/content/docs/config.mdindex b582fc26f..76ff93532 100644--- a/docs/src/content/docs/config.md+++ b/docs/src/content/docs/config.md@@ -150,9 +150,11 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```### OpenCodediff --git a/docs/src/content/docs/faq.md b/docs/src/content/docs/faq.mdindex 6c06d591a..6a8688c7d 100644--- a/docs/src/content/docs/faq.md+++ b/docs/src/content/docs/faq.md@@ -119,11 +119,12 @@ Created by `wt switch <branch>` when switching to a branch that doesn't have a w|------|------------|---------|| `~/.config/worktrunk/config.toml` | `wt config create` | User preferences || `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook and alias commands |+| `~/.codex/worktrunk-commit-instructions.txt` | Accepting first-run Codex commit setup | Minimal Codex instructions used by the saved commit command || `.config/wt.toml` | `wt config create --project` | Project hooks (checked into repo) |User config location: `$XDG_CONFIG_HOME/worktrunk/` (or `~/.config/worktrunk/`) on Linux/macOS, `%APPDATA%\worktrunk\` on Windows.-**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit).+**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit). Codex instructions: `rm ~/.codex/worktrunk-commit-instructions.txt` after changing or removing the saved Codex commit command. That command fails if the file is removed first.### 3. Shell integrationdiff --git a/docs/src/content/docs/llm-commits.md b/docs/src/content/docs/llm-commits.mdindex 6b42b4cd2..b302b937a 100644--- a/docs/src/content/docs/llm-commits.md+++ b/docs/src/content/docs/llm-commits.md@@ -30,13 +30,15 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml# ~/.config/worktrunk/config.toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```-Uses the fast, low-cost variant of the current Codex model family with low reasoning effort and an empty system prompt for faster output. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).+`model_instructions_file` replaces Codex's built-in instructions with that one character. `project_doc_max_bytes=0` limits project instructions, and `skills.max_context_tokens=1` limits the skills catalog. The command disables web search, shell tools, apps, plugins, subagents, and goals. It keeps user provider settings and authentication and skips session persistence. Codex can still load global `AGENTS.md` and other agent context, so a short commit prompt can use thousands of input tokens. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).### Other toolsdiff --git a/plugins/worktrunk/skills/worktrunk/reference/config.md b/plugins/worktrunk/skills/worktrunk/reference/config.mdindex c753e7130..7879d22fa 100644--- a/plugins/worktrunk/skills/worktrunk/reference/config.md+++ b/plugins/worktrunk/skills/worktrunk/reference/config.md@@ -144,9 +144,11 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```### OpenCodediff --git a/plugins/worktrunk/skills/worktrunk/reference/faq.md b/plugins/worktrunk/skills/worktrunk/reference/faq.mdindex d365bf051..69f60e666 100644--- a/plugins/worktrunk/skills/worktrunk/reference/faq.md+++ b/plugins/worktrunk/skills/worktrunk/reference/faq.md@@ -115,11 +115,12 @@ Created by `wt switch <branch>` when switching to a branch that doesn't have a w|------|------------|---------|| `~/.config/worktrunk/config.toml` | `wt config create` | User preferences || `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook and alias commands |+| `~/.codex/worktrunk-commit-instructions.txt` | Accepting first-run Codex commit setup | Minimal Codex instructions used by the saved commit command || `.config/wt.toml` | `wt config create --project` | Project hooks (checked into repo) |User config location: `$XDG_CONFIG_HOME/worktrunk/` (or `~/.config/worktrunk/`) on Linux/macOS, `%APPDATA%\worktrunk\` on Windows.-**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit).+**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit). Codex instructions: `rm ~/.codex/worktrunk-commit-instructions.txt` after changing or removing the saved Codex commit command. That command fails if the file is removed first.### 3. Shell integrationdiff --git a/plugins/worktrunk/skills/worktrunk/reference/llm-commits.md b/plugins/worktrunk/skills/worktrunk/reference/llm-commits.mdindex 2422e5e53..2479aa4c3 100644--- a/plugins/worktrunk/skills/worktrunk/reference/llm-commits.md+++ b/plugins/worktrunk/skills/worktrunk/reference/llm-commits.md@@ -18,13 +18,15 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml# ~/.config/worktrunk/config.toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```-Uses the fast, low-cost variant of the current Codex model family with low reasoning effort and an empty system prompt for faster output. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).+`model_instructions_file` replaces Codex's built-in instructions with that one character. `project_doc_max_bytes=0` limits project instructions, and `skills.max_context_tokens=1` limits the skills catalog. The command disables web search, shell tools, apps, plugins, subagents, and goals. It keeps user provider settings and authentication and skips session persistence. Codex can still load global `AGENTS.md` and other agent context, so a short commit prompt can use thousands of input tokens. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).### Other toolsdiff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.mdindex c753e7130..7879d22fa 100644--- a/skills/worktrunk/reference/config.md+++ b/skills/worktrunk/reference/config.md@@ -144,9 +144,11 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```### OpenCodediff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.mdindex d365bf051..69f60e666 100644--- a/skills/worktrunk/reference/faq.md+++ b/skills/worktrunk/reference/faq.md@@ -115,11 +115,12 @@ Created by `wt switch <branch>` when switching to a branch that doesn't have a w|------|------------|---------|| `~/.config/worktrunk/config.toml` | `wt config create` | User preferences || `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook and alias commands |+| `~/.codex/worktrunk-commit-instructions.txt` | Accepting first-run Codex commit setup | Minimal Codex instructions used by the saved commit command || `.config/wt.toml` | `wt config create --project` | Project hooks (checked into repo) |User config location: `$XDG_CONFIG_HOME/worktrunk/` (or `~/.config/worktrunk/`) on Linux/macOS, `%APPDATA%\worktrunk\` on Windows.-**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit).+**To remove:** Delete directly. User config: `rm ~/.config/worktrunk/config.toml`. Project config: `rm .config/wt.toml` (and commit). Codex instructions: `rm ~/.codex/worktrunk-commit-instructions.txt` after changing or removing the saved Codex commit command. That command fails if the file is removed first.### 3. Shell integrationdiff --git a/skills/worktrunk/reference/llm-commits.md b/skills/worktrunk/reference/llm-commits.mdindex 2422e5e53..2479aa4c3 100644--- a/skills/worktrunk/reference/llm-commits.md+++ b/skills/worktrunk/reference/llm-commits.md@@ -18,13 +18,15 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml# ~/.config/worktrunk/config.toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```-Uses the fast, low-cost variant of the current Codex model family with low reasoning effort and an empty system prompt for faster output. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).+`model_instructions_file` replaces Codex's built-in instructions with that one character. `project_doc_max_bytes=0` limits project instructions, and `skills.max_context_tokens=1` limits the skills catalog. The command disables web search, shell tools, apps, plugins, subagents, and goals. It keeps user provider settings and authentication and skips session persistence. Codex can still load global `AGENTS.md` and other agent context, so a short commit prompt can use thousands of input tokens. Requires `jq` for JSON parsing. See [Codex CLI docs](https://developers.openai.com/codex/cli/).### Other toolsdiff --git a/src/cli/mod.rs b/src/cli/mod.rsindex c2a8c3b95..b5922c74c 100644--- a/src/cli/mod.rs+++ b/src/cli/mod.rs@@ -2090,9 +2090,11 @@ command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haik### Codex+Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+```toml[commit.generation]-command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"+command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"```### OpenCodediff --git a/src/output/commit_generation.rs b/src/output/commit_generation.rsindex cc5d58188..539f9f8a9 100644--- a/src/output/commit_generation.rs+++ b/src/output/commit_generation.rs@@ -7,11 +7,13 @@use std::collections::HashMap;use std::ffi::OsStr;use std::io::{self, IsTerminal};-use std::path::PathBuf;+use std::path::{Path, PathBuf};use std::sync::LazyLock;+use anyhow::Context;use color_print::cformat;use worktrunk::config::{UserConfig, require_config_path};+use worktrunk::path::{format_path_for_display, home_dir};use worktrunk::styling::{eprintln, format_toml, hint_message, info_message, success_message};use super::prompt::{PromptResponse, prompt_yes_no_preview};@@ -25,6 +27,39 @@ const CONFIG_EXAMPLE: &str = include_str!("../../dev/config.example.toml");static RECOMMENDED_COMMANDS: LazyLock<HashMap<String, String>> =LazyLock::new(|| parse_recommended_commands(CONFIG_EXAMPLE));+/// Codex expands `~` in `model_instructions_file`, including when the path is+/// passed through `-c`. Keep the file outside the current repository so every+/// commit uses the same short instructions.+const CODEX_COMMIT_INSTRUCTIONS_FILE: &str = "worktrunk-commit-instructions.txt";++fn codex_instructions_path() -> anyhow::Result<PathBuf> {+ let home = home_dir().ok_or_else(|| anyhow::anyhow!("Cannot determine home directory"))?;+ Ok(home.join(".codex").join(CODEX_COMMIT_INSTRUCTIONS_FILE))+}++fn ensure_codex_instructions_file(path: &Path) -> anyhow::Result<bool> {+ if path.exists() {+ let metadata = path+ .metadata()+ .with_context(|| format!("Failed to inspect {}", path.display()))?;+ anyhow::ensure!(+ metadata.is_file() && metadata.len() > 0,+ "Codex instructions file must be a nonempty file: {}",+ path.display()+ );+ return Ok(false);+ }++ let parent = path+ .parent()+ .context("Codex instructions path has no parent directory")?;+ std::fs::create_dir_all(parent)+ .with_context(|| format!("Failed to create {}", parent.display()))?;+ worktrunk::utils::write_new_atomically(path, ".")+ .with_context(|| format!("Failed to write {}", path.display()))?;+ Ok(true)+}+/// Detected LLM tool available on the system.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum LlmTool {@@ -189,6 +224,9 @@ pub fn prompt_commit_generation(config: &mut UserConfig) -> anyhow::Result<bool>let command = tool.recommended_config();let formatted_command = format_command_for_display(command);let config_preview = format!("[commit.generation]\ncommand = {formatted_command}");+ let codex_instructions = (tool == LlmTool::Codex)+ .then(codex_instructions_path)+ .transpose()?;// Point at the config file wt actually writes to — respecting --config,// WORKTRUNK_CONFIG_PATH, and $XDG_CONFIG_HOME — rather than a hardcoded@@ -204,12 +242,39 @@ pub fn prompt_commit_generation(config: &mut UserConfig) -> anyhow::Result<bool>info_message(cformat!("Would add to <bold>{config_path}</>:")));eprintln!("{}", format_toml(&config_preview));+ if let Some(path) = &codex_instructions {+ eprintln!(+ "{}",+ info_message(format!(+ "Uses {}; creates a one-character file there if absent",+ format_path_for_display(path)+ ))+ );+ }eprintln!();},)?;match response {PromptResponse::Accepted => {+ if let Some(path) = &codex_instructions {+ match ensure_codex_instructions_file(path) {+ Ok(true) => eprintln!(+ "{}",+ success_message(format!(+ "Created Codex instructions: {}",+ format_path_for_display(path)+ ))+ ),+ Ok(false) => {}+ Err(e) => {+ tracing::error!(error = %e, "Failed to prepare Codex instructions");+ eprintln!("{}", hint_message(format!("Codex setup failed: {e:#}")));+ return Ok(false);+ }+ }+ }+// Set the configurationlet command = command.to_string();let save_result = require_config_path()@@ -228,6 +293,15 @@ pub fn prompt_commit_generation(config: &mut UserConfig) -> anyhow::Result<bool>// Show what was addedeprintln!("{}", success_message(cformat!("Added to user config:")));eprintln!("{}", format_toml(&config_preview));+ if let Some(path) = &codex_instructions {+ let display_path = format_path_for_display(path);+ eprintln!(+ "{}",+ hint_message(format!(+ "Keep {display_path}; the saved Codex command requires it"+ ))+ );+ }eprintln!("{}",hint_message(cformat!("View config: <underline>wt config show</>"))@@ -262,10 +336,38 @@ mod tests {#[test]fn test_llm_tool_recommended_config() {assert_snapshot!(LlmTool::Claude.recommended_config(), @"MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --safe-mode --setting-sources='user' --system-prompt=''");- assert_snapshot!(LlmTool::Codex.recommended_config(), @r#"codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == "agent_message")] | last.item.text'"#);+ assert_snapshot!(LlmTool::Codex.recommended_config(), @r#"codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file="~/.codex/worktrunk-commit-instructions.txt"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == "agent_message")] | last.item.text'"#);assert_snapshot!(LlmTool::OpenCode.recommended_config(), @"opencode run -m anthropic/claude-haiku-4.5 --variant fast");}+ #[test]+ fn test_codex_instructions_file_is_minimal_and_preserves_existing_content() {+ let tmp = tempfile::tempdir().unwrap();+ let path = tmp.path().join(".codex/worktrunk-commit-instructions.txt");++ assert!(ensure_codex_instructions_file(&path).unwrap());+ assert_eq!(std::fs::read(&path).unwrap(), b".");++ std::fs::write(&path, "Use my instructions").unwrap();+ assert!(!ensure_codex_instructions_file(&path).unwrap());+ assert_eq!(+ std::fs::read_to_string(&path).unwrap(),+ "Use my instructions"+ );++ std::fs::write(&path, "").unwrap();+ assert!(ensure_codex_instructions_file(&path).is_err());++ let blocked_parent = tmp.path().join("not-a-directory");+ std::fs::write(&blocked_parent, "file").unwrap();+ let err =+ ensure_codex_instructions_file(&blocked_parent.join("instructions.txt")).unwrap_err();+ assert!(+ err.to_string()+ .contains(&blocked_parent.display().to_string())+ );+ }+#[test]fn test_parse_recommended_commands() {let config = "\diff --git a/tests/integration_tests/shell_integration_prompt.rs b/tests/integration_tests/shell_integration_prompt.rsindex 1dcbdf05a..8a94cbfe2 100644--- a/tests/integration_tests/shell_integration_prompt.rs+++ b/tests/integration_tests/shell_integration_prompt.rs@@ -694,19 +694,39 @@ mod commit_generation_prompt_tests {use std::path::{Path, PathBuf};use tempfile::TempDir;- fn setup_fake_claude(temp_home: &Path) -> PathBuf {- // Create a fake claude executable that does nothing+ fn setup_fake_tool(temp_home: &Path, tool: &str) -> PathBuf {+ // Create a fake LLM executable that does nothinglet bin_dir = temp_home.join("bin");fs::create_dir_all(&bin_dir).unwrap();- let claude_path = bin_dir.join("claude");- fs::write(&claude_path, "#!/bin/sh\nexit 0\n").unwrap();+ let tool_path = bin_dir.join(tool);+ fs::write(&tool_path, "#!/bin/sh\nexit 0\n").unwrap();// Make executable- let mut perms = fs::metadata(&claude_path).unwrap().permissions();+ let mut perms = fs::metadata(&tool_path).unwrap().permissions();perms.set_mode(0o755);- fs::set_permissions(&claude_path, perms).unwrap();+ fs::set_permissions(&tool_path, perms).unwrap();bin_dir}+ fn run_codex_prompt(repo: &TestRepo, temp_home: &Path, answers: &[&str]) -> String {+ let bin_dir = setup_fake_tool(temp_home, "codex");+ let test_file = repo.root_path().join("test.txt");+ fs::write(&test_file, "test content\n").unwrap();+ repo.run_git(&["add", "test.txt"]);++ let mut env_vars = repo.test_env_vars();+ let path = crate::common::setup_minimal_path_with_git(&bin_dir);+ env_vars.push(("PATH".to_string(), path));++ let cmd = build_pty_command(+ wt_bin().to_str().unwrap(),+ &["step", "commit"],+ repo.root_path(),+ &env_vars,+ Some(temp_home),+ );+ exec_cmd_in_pty_prompted(cmd, answers, "[y/N").0+ }+/// Test: No LLM tool available, prompt is skipped and skip flag is set#[rstest]fn test_no_llm_tool_sets_skip_flag(repo: TestRepo) {@@ -747,7 +767,7 @@ mod commit_generation_prompt_tests {#[rstest]fn test_user_declines_llm_prompt(repo: TestRepo) {let temp_home = TempDir::new().unwrap();- let bin_dir = setup_fake_claude(temp_home.path());+ let bin_dir = setup_fake_tool(temp_home.path(), "claude");// Stage a changelet test_file = repo.root_path().join("test.txt");@@ -788,7 +808,7 @@ mod commit_generation_prompt_tests {#[rstest]fn test_user_accepts_llm_prompt(repo: TestRepo) {let temp_home = TempDir::new().unwrap();- let bin_dir = setup_fake_claude(temp_home.path());+ let bin_dir = setup_fake_tool(temp_home.path(), "claude");// Stage a changelet test_file = repo.root_path().join("test.txt");@@ -825,11 +845,94 @@ mod commit_generation_prompt_tests {);}+ #[rstest]+ fn test_user_accepts_codex_prompt(repo: TestRepo) {+ let temp_home = TempDir::new().unwrap();+ let output = run_codex_prompt(&repo, temp_home.path(), &["y\n"]);++ assert!(output.contains("Added to user config"), "{output}");+ assert!(output.contains("Created Codex instructions"), "{output}");+ assert!(+ output.contains("the saved Codex command requires it"),+ "{output}"+ );+ let config_content = fs::read_to_string(repo.test_config_path()).unwrap();+ assert!(config_content.contains("model_instructions_file"));+ assert_eq!(+ fs::read(+ temp_home+ .path()+ .join(".codex/worktrunk-commit-instructions.txt")+ )+ .unwrap(),+ b"."+ );+ }++ #[rstest]+ fn test_codex_preview_then_decline_does_not_create_instructions(repo: TestRepo) {+ let temp_home = TempDir::new().unwrap();+ let output = run_codex_prompt(&repo, temp_home.path(), &["?\n", "n\n"]);++ assert!(+ output.contains("creates a one-character file there if absent"),+ "{output}"+ );+ assert!(+ !temp_home+ .path()+ .join(".codex/worktrunk-commit-instructions.txt")+ .exists()+ );+ let config_content = fs::read_to_string(repo.test_config_path()).unwrap_or_default();+ assert!(!config_content.contains("model_instructions_file"));+ }++ #[rstest]+ fn test_codex_prompt_reuses_existing_instructions(repo: TestRepo) {+ let temp_home = TempDir::new().unwrap();+ let instructions = temp_home+ .path()+ .join(".codex/worktrunk-commit-instructions.txt");+ fs::create_dir_all(instructions.parent().unwrap()).unwrap();+ fs::write(&instructions, "Existing instructions").unwrap();++ let output = run_codex_prompt(&repo, temp_home.path(), &["y\n"]);++ assert!(!output.contains("Created Codex instructions"), "{output}");+ assert!(+ output.contains("the saved Codex command requires it"),+ "{output}"+ );+ assert_eq!(+ fs::read_to_string(&instructions).unwrap(),+ "Existing instructions"+ );+ let config_content = fs::read_to_string(repo.test_config_path()).unwrap();+ assert!(config_content.contains("model_instructions_file"));+ }++ #[rstest]+ fn test_codex_prompt_file_creation_failure_does_not_save_command(repo: TestRepo) {+ let temp_home = TempDir::new().unwrap();+ fs::write(temp_home.path().join(".codex"), "not a directory").unwrap();++ let output = run_codex_prompt(&repo, temp_home.path(), &["y\n"]);++ assert!(+ output.contains("Codex setup failed: Failed to create"),+ "{output}"+ );+ assert!(output.contains(".codex"), "{output}");+ let config_content = fs::read_to_string(repo.test_config_path()).unwrap_or_default();+ assert!(!config_content.contains("model_instructions_file"));+ }+/// Test: User requests preview (?)#[rstest]fn test_user_requests_preview(repo: TestRepo) {let temp_home = TempDir::new().unwrap();- let bin_dir = setup_fake_claude(temp_home.path());+ let bin_dir = setup_fake_tool(temp_home.path(), "claude");// Stage a changelet test_file = repo.root_path().join("test.txt");@@ -867,7 +970,7 @@ mod commit_generation_prompt_tests {#[rstest]fn test_user_accepts_but_save_fails_shows_manual_hint(repo: TestRepo) {let temp_home = TempDir::new().unwrap();- let bin_dir = setup_fake_claude(temp_home.path());+ let bin_dir = setup_fake_tool(temp_home.path(), "claude");// Stage a changelet test_file = repo.root_path().join("test.txt");diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snapindex b8d2fd3a6..a58b3bf25 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap@@ -143,8 +143,11 @@ Creates [2m~/.config/worktrunk/config.toml[0m with the following content:[107m [0m [2m#[0m[107m [0m [2m# ### Codex[0m[107m [0m [2m#[0m+[107m [0m [2m# Create `~/.codex/worktrunk-commit-instructions.txt` containing just `.` (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.[0m+[107m [0m [2m#[0m[107m [0m [2m# [commit.generation][0m-[107m [0m [2m# command = "codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"[0m+[107m [0m [2m# command = "codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] |+[107m [0m last.item.text'"[0m[107m [0m [2m#[0m[107m [0m [2m# ### OpenCode[0m[107m [0m [2m#[0mdiff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snapindex aa0789c1e..910c70c49 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap@@ -191,8 +191,10 @@ Generate commit messages automatically during merge. Requires an external CLI to[32mCodex[0m+Create [2m~/.codex/worktrunk-commit-instructions.txt[0m containing just [2m.[0m (no newline). Accepting Worktrunk's first-run Codex setup creates the file for you.+[107m [0m [2m[36m[commit.generation][0m-[107m [0m [2mcommand = [0m[2m[32m"codex exec -m gpt-5.6-luna -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"[0m+[107m [0m [2mcommand = [0m[2m[32m"codex exec -m gpt-6-luna -c model_reasoning_effort='none' -c project_doc_max_bytes=0 -c skills.max_context_tokens=1 -c agents.enabled=false -c features.goals=false -c web_search=disabled -c 'model_instructions_file=\"~/.codex/worktrunk-commit-instructions.txt\"' -c features.shell_tool=false -c features.unified_exec=false -c features.apps=false -c features.plugins=false --ephemeral --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == \"agent_message\")] | last.item.text'"[0m[32mOpenCode[0m