Split run commands into a gh-style options/run seam (stream, transcribe, agent, speak, llm)#100
Merged
Merged
Conversation
The Typer function now only parses argv into a frozen StreamOptions dataclass and hands it to the module-level run_stream(opts, state, json_mode) in the new aai_cli/stream_exec.py (mirroring the transcribe_exec precedent), instead of closing over ~37 flag locals in a nested body(). Because the run path is a plain function of data, tests can drive validation, flag mapping, and session wiring by constructing options directly (tests/test_stream_exec.py) with no CliRunner argv round-trip. No behavior change: flag definitions, help text, validation ordering (sources before credentials), and --show-code output are untouched. Test monkeypatch targets move with the code (aai_cli.commands.stream.* -> aai_cli.stream_exec.*), StreamSession / llm.run_chain patches now point at their home modules, and the convention is documented in AGENTS.md for future flag-heavy commands. https://claude.ai/code/session_01TevyxEQHkkjBv4wrQKkAQV
Apply the seam piloted on stream (frozen <Cmd>Options dataclass parsed by the Typer function, module-level run_<cmd>(opts, state, json_mode) holding the body) to the remaining flag-heavy commands: - transcribe -> TranscribeOptions + run_transcribe in transcribe_exec.py (the existing home of the command's run helpers; transcribe_batch is imported lazily there since it imports this module at load time) - agent -> agent_exec.py (also absorbs _resolve_system_prompt and _open_audio; --list-voices keeps its own auth-free body in the command) - speak -> speak_exec.py (with the emit/synthesize helpers and the DEFAULT_VOICE/DEFAULT_LANGUAGE constants) - llm -> llm_exec.py (one-shot + --follow; --list-models stays in the command; the gateway client aai_cli/llm.py stays rich-free per the architecture contract) The command modules are now pure flag surface (transcribe 490->404 lines, agent 213->113, speak 267->82, llm 210->113). New exec modules are registered in the import-linter "core must not import commands" contract. Test monkeypatch targets move with the code; the helpers that commands still import (commands.llm.gateway, commands.transcribe.llm) keep their existing targets. tests/test_command_options_seam.py drives each run function directly off a defaults Options instance, including the agent Ctrl-C/BrokenPipe paths that previously had no coverage. No behavior change: flag definitions, help text, validation ordering, messages, and exit codes are untouched. https://claude.ai/code/session_01TevyxEQHkkjBv4wrQKkAQV
Resolves the import-block conflict in transcribe_exec.py (union of the options/run-split imports and main's mutually_exclusive import) and repoints the patch targets of tests added on main at the exec modules the run logic moved to (aai_cli.commands.stream.* -> aai_cli.stream_exec.*), fixing the CI failure on the PR merge ref. https://claude.ai/code/session_01TevyxEQHkkjBv4wrQKkAQV
…o claude/hopeful-allen-phne89
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Separate CLI parsing from execution for all five flag-heavy run commands, following gh CLI's
Options+ run-function pattern. Each Typer command function now only parses argv into a frozen<Cmd>Optionsdataclass and hands it to a module-levelrun_<cmd>(opts, state, *, json_mode)— so tests drive validation, flag mapping, and session wiring by constructing options directly instead of round-tripping argv throughCliRunner.Changes
aai_cli/stream_exec.py(new) —StreamOptions+run_stream, plus the--show-codeand audio-source dispatch logic (the pilot / reference implementation)aai_cli/transcribe_exec.py— gainsTranscribeOptions+run_transcribealongside the existing run helpers (transcribe_batchis imported lazily there; it imports this module at load time)aai_cli/agent_exec.py(new) —AgentOptions+run_agent, absorbing_resolve_system_prompt/_open_audio;--list-voiceskeeps its own auth-free body in the commandaai_cli/speak_exec.py(new) —SpeakOptions+run_speakwith the synthesize/emit helpers and the voice/language defaultsaai_cli/llm_exec.py(new) —LlmOptions+run_llmcovering one-shot and--follow;--list-modelsstays in the command (aai_cli/llm.pyremains the rich-free gateway client per the import-linter contract)transcribe490→404 lines,stream449→340,speak267→82,agent213→113,llm210→113aai_cli.commands.<cmd>.*→aai_cli.<cmd>_exec.*); newtests/test_stream_exec.pyandtests/test_command_options_seam.pydrive each run function directly off a defaultsOptionsinstance (including agent Ctrl-C/BrokenPipe paths that previously had no coverage)Behavior
None changed: flag definitions, help text (snapshots untouched), validation ordering, error messages, and exit codes are byte-identical.
Gate
Full
scripts/check.shgreen locally on the merged tree, including 100% patch coverage and 70/70 diff-scoped mutants killed. The branch includes a merge of currentmain(themutually_exclusivevalidator consolidation and tightened test fakes), with the new tests from #98 repointed at the exec modules — which fixes the earlier CI failure on the merge ref.https://claude.ai/code/session_01TevyxEQHkkjBv4wrQKkAQV