Skip to content

fix(cli): protect built-in TUI agent modes#36

Open
BunsDev wants to merge 1 commit into
mainfrom
codex/propose-fix-for-tab-plan-mode-vulnerability
Open

fix(cli): protect built-in TUI agent modes#36
BunsDev wants to merge 1 commit into
mainfrom
codex/propose-fix-for-tab-plan-mode-vulnerability

Conversation

@BunsDev
Copy link
Copy Markdown
Member

@BunsDev BunsDev commented Jun 3, 2026

Motivation

  • Prevent a repository-controlled agent named plan from replacing the built-in read-only Plan mode and misleading the user into granting write/exec tool access.

Description

  • Add resolve_tui_agent_mode which resolves TUI-selected reserved modes (build, plan, explore) to the built-in definitions before consulting familiars/project agents.
  • Update the TUI Tab-mode path to call resolve_tui_agent_mode when app.agent_mode_changed so the visual mode and tool-filtering remain consistent and secure.
  • Add regression tests (tui_reserved_modes_ignore_project_agent_overrides, tui_non_reserved_modes_can_use_project_agents) and a small test_agent helper to cover reserved vs non-reserved resolution behavior in src-rust/crates/cli/src/main.rs.

Testing

  • Ran git diff --check which passed with no whitespace/errors reported.
  • Ran cargo fmt --all --check (formatting verified) in the workspace.
  • Attempted cargo test / cargo check --workspace and targeted tests, but execution was blocked by missing system development dependency (alsa.pc / ALSA dev package), causing the build to fail before tests could run; the new unit tests are present but could not be executed in this environment.

Codex Task

Copilot AI review requested due to automatic review settings June 3, 2026 12:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the CLI TUI mode-switcher so that selecting reserved modes (build, plan, explore) always resolves to the built-in agent definitions, preventing repository-configured agents with the same names from replacing security-significant built-in modes.

Changes:

  • Added resolve_tui_agent_mode to force reserved TUI modes to use built-in agent definitions before consulting familiars/project agents.
  • Updated the interactive TUI mode-change handling to use resolve_tui_agent_mode, keeping displayed mode and tool filtering consistent.
  • Added regression tests to verify reserved modes ignore project overrides while non-reserved modes can still resolve to project agents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1282 to +1284
let mut all_agents = claurst_core::coven_shared::default_agents_with_familiars();
all_agents.extend(config_agents.clone());
all_agents.get(mode).cloned()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants