56 lines
1.4 KiB
PowerShell
56 lines
1.4 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
function Get-StockBotProjectRoot {
|
|
return (Split-Path -Parent $PSScriptRoot)
|
|
}
|
|
|
|
function Resolve-StockBotPython {
|
|
param([string]$Project)
|
|
|
|
$VenvPython = Join-Path $Project ".venv\Scripts\python.exe"
|
|
if (Test-Path $VenvPython) {
|
|
return $VenvPython
|
|
}
|
|
|
|
$PyenvPython = Join-Path $env:USERPROFILE ".pyenv\pyenv-win\versions\3.11.9\python.exe"
|
|
if (Test-Path $PyenvPython) {
|
|
return $PyenvPython
|
|
}
|
|
|
|
$Command = Get-Command python -ErrorAction SilentlyContinue
|
|
if ($Command) {
|
|
return $Command.Source
|
|
}
|
|
|
|
throw "Python not found. Run Restore_StockBot.bat first."
|
|
}
|
|
|
|
function Resolve-StockBotClaude {
|
|
$Candidates = @()
|
|
if ($env:STOCKBOT_CLAUDE) {
|
|
$Candidates += $env:STOCKBOT_CLAUDE
|
|
}
|
|
if ($env:APPDATA) {
|
|
$Candidates += (Join-Path $env:APPDATA "npm\claude.cmd")
|
|
$Candidates += (Join-Path $env:APPDATA "npm\codex.cmd")
|
|
}
|
|
|
|
foreach ($Candidate in $Candidates) {
|
|
if ($Candidate -and (Test-Path $Candidate)) {
|
|
return $Candidate
|
|
}
|
|
}
|
|
|
|
$Claude = Get-Command claude.cmd -ErrorAction SilentlyContinue
|
|
if ($Claude) {
|
|
return $Claude.Source
|
|
}
|
|
|
|
$Codex = Get-Command codex.cmd -ErrorAction SilentlyContinue
|
|
if ($Codex) {
|
|
return $Codex.Source
|
|
}
|
|
|
|
throw "Claude/Codex CLI not found. Run Restore_StockBot.bat or install the CLI, then retry."
|
|
}
|