mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-12 21:20:49 +08:00
fix(scripts): resolve repo root by searching oclaw.json
Make start/stop scripts robust to directory renames, and improve stop hints when process termination is denied. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f538409c08
commit
38de5a305f
7 changed files with 155 additions and 12 deletions
|
|
@ -8,7 +8,28 @@ function Write-Step([string]$msg) {
|
|||
Write-Host "==> $msg" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoRoot = $null
|
||||
function Resolve-RepoRoot([string]$fromDir) {
|
||||
$cur = (Resolve-Path $fromDir).Path
|
||||
for ($i = 0; $i -lt 12; $i++) {
|
||||
$cfg = Join-Path $cur "oclaw.json"
|
||||
if (Test-Path $cfg) {
|
||||
return $cur
|
||||
}
|
||||
$parent = Split-Path -Parent $cur
|
||||
if (-not $parent -or $parent -eq $cur) {
|
||||
break
|
||||
}
|
||||
$cur = $parent
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
$repoRoot = Resolve-RepoRoot $PSScriptRoot
|
||||
if (-not $repoRoot) {
|
||||
# Fallback: old relative layout assumption
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
}
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoRoot
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue