[codex] コマンド層の重複を削減し adapter と validation を共通化#45
Merged
Conversation
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.
概要
コマンド層で繰り返されていた「引数検証」「
get_client(ctx)呼び出し」「execute_command(...)包装」を adapter 化し、track/scenes/synth/effectの実装を共通パターンに整理しました。併せて検証関数をcommands/_validation.pyへ集約し、コマンド追加時の実装漏れリスクを下げています。背景とユーザー影響
これまで各コマンドに同型の処理が分散していたため、仕様変更時に横断修正が必要になり、修正漏れで CLI の挙動やエラーメッセージの一貫性が崩れるリスクがありました。
利用者目線では、新規コマンド追加や既存コマンド修正時の品質ぶれにつながる可能性がありました。
根本原因
対応内容
trackにrun_track_command/run_track_value_commandを導入scenesにrun_scene_command/run_scene_value_command/run_scene_move_commandを導入synthとeffectにrun_track_device_commandを導入commands/_validation.pyに以下を追加して検証を集約require_track_and_valuerequire_track_and_namerequire_track_and_volumerequire_track_and_panrequire_scene_indexrequire_scene_and_valuerequire_scene_and_namerequire_scene_moverequire_scene_insert_indexrequire_optional_track_indexrequire_track_and_devicetests/commands/test_track_command_adapter.pytests/commands/test_scenes_command_adapter.pytests/commands/test_synth_command_adapter.pytests/commands/test_effect_command_adapter.pytests/commands/test_validation.pyのケース拡張変更による効果
検証
以下を実行し、すべて成功を確認しました。
uv run python -m ableton_cli.dev_checksuv run ruff check .uv run ruff format --check .uv run pytest(389 passed)