fix(windows): resolve claude.cmd via shutil.which (#124)
Co-authored-by: banteg <4562643+banteg@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -449,7 +450,7 @@ class ClaudeRunner(ResumeTokenMixin, JsonlSubprocessRunner):
|
||||
|
||||
|
||||
def build_runner(config: EngineConfig, _config_path: Path) -> Runner:
|
||||
claude_cmd = "claude"
|
||||
claude_cmd = shutil.which("claude") or "claude"
|
||||
|
||||
model = config.get("model")
|
||||
if "allowed_tools" in config:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
|
||||
import anyio
|
||||
import pytest
|
||||
|
||||
import takopi.runners.claude as claude_runner
|
||||
from takopi.model import ActionEvent, CompletedEvent, ResumeToken, StartedEvent
|
||||
from takopi.runners.claude import (
|
||||
ClaudeRunner,
|
||||
@@ -62,6 +64,21 @@ def test_claude_resume_format_and_extract() -> 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:
|
||||
state = ClaudeStreamState()
|
||||
events: list = []
|
||||
|
||||
Reference in New Issue
Block a user