Skip to content
Merged
2 changes: 1 addition & 1 deletion agent_cli/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def execute_code(code: str) -> str:
except subprocess.CalledProcessError as e:
return f"Error executing code: {e.stderr}"
except FileNotFoundError:
return f"Error: Command not found: {code.split()[0]}"
return f"Error: Command not found: {code.split(maxsplit=1)[0]}"


def add_memory(content: str, category: str = "general", tags: str = "") -> str:
Expand Down
2 changes: 1 addition & 1 deletion agent_cli/agents/transcribe_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def _process_segment( # noqa: PLR0912
if cfg.clipboard:
import pyperclip # noqa: PLC0415

text_to_copy = processed if processed else transcript
text_to_copy = processed or transcript
pyperclip.copy(text_to_copy)

# Log
Expand Down
23 changes: 19 additions & 4 deletions agent_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ class Dev(BaseModel):

default_agent: str | None = None
default_editor: str | None = None
branch_name_mode: Literal["random", "auto", "ai"] = "random"
branch_name_agent: Literal["claude", "codex", "gemini"] | None = None
branch_name_timeout: float = 20.0 # seconds
agent_args: dict[str, list[str]] | None = (
None # Per-agent args, e.g. {"claude": ["--dangerously-skip-permissions"]}
)
Expand Down Expand Up @@ -319,16 +322,28 @@ def normalize_provider_defaults(cfg: dict[str, Any]) -> dict[str, Any]:
return normalized


def _replace_dashed_keys(cfg: dict[str, Any]) -> dict[str, Any]:
return {k.replace("-", "_"): v for k, v in cfg.items()}
def _replace_dashed_keys(cfg: Any) -> Any:
"""Recursively replace dashed keys in dictionaries."""
if isinstance(cfg, dict):
return {k.replace("-", "_"): _replace_dashed_keys(v) for k, v in cfg.items()}
return cfg


def _flatten_nested_sections(cfg: dict[str, Any], prefix: str = "") -> dict[str, Any]:
"""Flatten nested TOML sections: {"a": {"b": {"x": 1}}} -> {"a.b": {"x": 1}}."""
result = {}
"""Flatten nested TOML sections while preserving scalar parent options.

Example:
{"a": {"x": 1, "b": {"y": 2}}} -> {"a": {"x": 1}, "a.b": {"y": 2}}
{"a": {"b": {"x": 1}}} -> {"a.b": {"x": 1}}

"""
result: dict[str, Any] = {}
for key, value in cfg.items():
full_key = f"{prefix}.{key}" if prefix else key
if isinstance(value, dict) and any(isinstance(v, dict) for v in value.values()):
scalar_items = {k: v for k, v in value.items() if not isinstance(v, dict)}
if scalar_items:
result[full_key] = scalar_items
result.update(_flatten_nested_sections(value, full_key))
else:
result[full_key] = value
Expand Down
2 changes: 1 addition & 1 deletion agent_cli/core/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _is_uvx_cache() -> bool:

def _check_package_installed(pkg: str) -> bool:
"""Check if a single package is installed."""
top_module = pkg.split(".")[0]
top_module = pkg.split(".", maxsplit=1)[0]
try:
return find_spec(top_module) is not None
except (ValueError, ModuleNotFoundError):
Expand Down
Loading