Fix opencode discovery for Spark and Windows
This commit is contained in:
parent
2bbcc9e272
commit
5f58354772
1 changed files with 7 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
|
@ -15,7 +16,12 @@ class Command(BaseCommand):
|
|||
env_name = f"ARTIFEX_{model_key.upper()}_OPENCODE_COMMAND"
|
||||
if os.environ.get(env_name):
|
||||
return os.environ[env_name]
|
||||
executable = shutil.which("opencode") or "opencode"
|
||||
if os.environ.get("ARTIFEX_OPENCODE_COMMAND"):
|
||||
return os.environ["ARTIFEX_OPENCODE_COMMAND"]
|
||||
executable = shutil.which("opencode")
|
||||
if executable is None:
|
||||
default_user_install = Path.home() / ".opencode" / "bin" / "opencode"
|
||||
executable = str(default_user_install) if default_user_install.exists() else "opencode"
|
||||
return f"{executable} run"
|
||||
|
||||
def opencode_config(self, model_key: str) -> dict[str, object]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue