fix(acp): route shell commands through terminal args#1393
fix(acp): route shell commands through terminal args#1393hanhan3344 wants to merge 2 commits intoMoonshotAI:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes ACP terminal-backed Shell execution by correctly splitting shell invocation into an executable (command) plus arguments (args), and updates the ACP terminal adapter to use terminal_id-based follow-up RPCs per the current ACP SDK.
Changes:
- Route Shell commands through
terminal/createascommand=<shell executable>andargs=[shell flags..., user command]. - Update terminal lifecycle calls to use
terminal_id(wait_for_terminal_exit,terminal_output,kill_terminal,release_terminal). - Add a regression test covering bash and PowerShell command/args routing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/acp/test_terminal_tool.py | Adds regression coverage asserting correct command/args routing for bash and PowerShell in ACP terminal mode. |
| src/kimi_cli/acp/tools.py | Updates ACP Terminal tool to construct shell argv properly and use terminal_id-based ACP RPC methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| shell_argv = self._shell_tool._shell_args(params.command) | ||
| term = await self._acp_conn.create_terminal( | ||
| command=params.command, | ||
| command=shell_argv[0], | ||
| session_id=self._acp_session_id, | ||
| args=list(shell_argv[1:]), | ||
| output_byte_limit=builder.max_chars, |
There was a problem hiding this comment.
Terminal calls self._shell_tool._shell_args(...), which is a private helper on Shell (leading underscore) and creates a cross-module dependency on an implementation detail. To make this more stable, consider exposing a public method (e.g., shell_args()/get_shell_invocation()), or moving the argv-building logic to a shared utility that both tools use, and have Terminal call that instead.
|
Addressed Copilot's maintainability suggestion in follow-up commit
Validation: |
Summary
commandand the shell invocation inargsterminal_idProblem
When
kimi acpwas used behind ACP clients with terminal support, Shell commands likeecho testcould fail with errors like:spawn echo test ENOENTspawn ls -la ENOENTThe ACP terminal adapter passed the entire shell command string as
terminal/create.command, which made clients try to spawn the full string as an executable path.The adapter also assumed
create_terminal()returned aTerminalHandle, but the current ACP SDK returns a response containingterminal_id, with follow-up terminal operations happening through separate RPC methods.Fix
_shell_args()to split shell execution into executable + argsterminal/createwith:command=<shell executable>args=[shell flags..., user command]terminal_idwithterminal/wait_for_exit,terminal/output,terminal/kill, andterminal/releaseValidation
uv run pytest tests/acp/test_protocol_v1.py tests/acp/test_terminal_tool.py -q