diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0812663..4782b5578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Only write entries that are worth mentioning to users. ## Unreleased +- Tools: Shell tool headlines now keep the full command string instead of applying the generic 50-character middle truncation, making long paths and arguments visible when reviewing repeated or failed commands + ## 1.47.0 (2026-06-05) - Shell: Guide users to the new standalone Kimi Code — adds a `/upgrade` command that installs it (migrating your config & sessions automatically), a welcome-screen nudge, and a once-per-day tip shown on exit diff --git a/src/kimi_cli/tools/__init__.py b/src/kimi_cli/tools/__init__.py index 371a9d498..714733703 100644 --- a/src/kimi_cli/tools/__init__.py +++ b/src/kimi_cli/tools/__init__.py @@ -94,7 +94,8 @@ def extract_key_argument(json_content: str | streamingjson.Lexer, tool_name: str key_argument = "".join(content) else: key_argument = json_content - key_argument = shorten_middle(key_argument, width=50) + if tool_name != "Shell": + key_argument = shorten_middle(key_argument, width=50) return key_argument diff --git a/tests/tools/test_extract_key_argument.py b/tests/tools/test_extract_key_argument.py index 8f726d5fd..fc74938b1 100644 --- a/tests/tools/test_extract_key_argument.py +++ b/tests/tools/test_extract_key_argument.py @@ -15,11 +15,28 @@ def test_shell(self): result = extract_key_argument('{"command": "ls -la"}', "Shell") assert result == "ls -la" + def test_shell_long_command_keeps_path_and_arguments(self): + command = ( + "python scripts/really/deeply/nested/path/for/reproducing/issue_2142.py " + "--input /tmp/moonshot/kimi-cli/very/long/source/file.txt " + "--output /tmp/moonshot/kimi-cli/very/long/result.json" + ) + result = extract_key_argument(f'{{"command": "{command}"}}', "Shell") + assert result == command + assert "..." not in result + def test_readfile(self): result = extract_key_argument('{"path": "foo/bar.py"}', "ReadFile") assert result is not None assert "foo/bar.py" in result + def test_readfile_long_path_still_shortens(self): + long_path = "/workspace/" + "/".join(f"directory_{i:02d}" for i in range(12)) + "/target.py" + result = extract_key_argument(f'{{"path": "{long_path}"}}', "ReadFile") + assert result is not None + assert "..." in result + assert len(result) <= 53 + def test_grep(self): result = extract_key_argument('{"pattern": "hello"}', "Grep") assert result == "hello"