fix(windows): resolve claude.cmd via shutil.which (#124)

Co-authored-by: banteg <4562643+banteg@users.noreply.github.com>
This commit is contained in:
botica
2026-01-15 05:06:13 -06:00
committed by GitHub
parent 495ff261de
commit 81fc88a3cf
2 changed files with 19 additions and 1 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import os import os
import re import re
import shutil
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@@ -449,7 +450,7 @@ class ClaudeRunner(ResumeTokenMixin, JsonlSubprocessRunner):
def build_runner(config: EngineConfig, _config_path: Path) -> Runner: def build_runner(config: EngineConfig, _config_path: Path) -> Runner:
claude_cmd = "claude" claude_cmd = shutil.which("claude") or "claude"
model = config.get("model") model = config.get("model")
if "allowed_tools" in config: if "allowed_tools" in config:
+17
View File
@@ -1,9 +1,11 @@
import json import json
from pathlib import Path from pathlib import Path
from typing import cast
import anyio import anyio
import pytest import pytest
import takopi.runners.claude as claude_runner
from takopi.model import ActionEvent, CompletedEvent, ResumeToken, StartedEvent from takopi.model import ActionEvent, CompletedEvent, ResumeToken, StartedEvent
from takopi.runners.claude import ( from takopi.runners.claude import (
ClaudeRunner, ClaudeRunner,
@@ -62,6 +64,21 @@ def test_claude_resume_format_and_extract() -> None:
assert runner.extract_resume("`codex resume sid`") is None assert runner.extract_resume("`codex resume sid`") is None
def test_build_runner_uses_shutil_which(monkeypatch) -> None:
expected = r"C:\Tools\claude.cmd"
called: dict[str, str] = {}
def fake_which(name: str) -> str | None:
called["name"] = name
return expected
monkeypatch.setattr(claude_runner.shutil, "which", fake_which)
runner = cast(ClaudeRunner, claude_runner.build_runner({}, Path("takopi.toml")))
assert called["name"] == "claude"
assert runner.claude_cmd == expected
def test_translate_success_fixture() -> None: def test_translate_success_fixture() -> None:
state = ClaudeStreamState() state = ClaudeStreamState()
events: list = [] events: list = []