mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
完成运行时与启动链路的全面相对路径整改,统一以仓库根为路径基准并移除 oclaw 双层硬编码。
同时补齐路径回归测试与开源自检文档,确保从非仓库 cwd 启动时 workspace 根、配置和 wiki 路径仍稳定可用。 Made-with: Cursor
This commit is contained in:
parent
dbbe3add6a
commit
9d2900db02
40 changed files with 223 additions and 82 deletions
|
|
@ -17,7 +17,12 @@ function Write-Step([string]$msg) {
|
|||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
Set-Location $repoRoot
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
Write-Step "Starting gateway + desktop"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ if (-not (Test-Path $desktopDir)) {
|
|||
|
||||
Set-Location $desktopDir
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
if (-not $KeepExistingGateway) {
|
||||
Write-Host "==> Cleaning previous gateway listener" -ForegroundColor Cyan
|
||||
|
|
|
|||
|
|
@ -19,16 +19,20 @@ function Fail([string]$msg) {
|
|||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
Set-Location $repoRoot
|
||||
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
New-Item -ItemType Directory -Force -Path $runDir | Out-Null
|
||||
$pidFile = Join-Path $runDir "gateway.pid"
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Working directory: $repoRoot"
|
||||
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
|
|
@ -70,7 +74,7 @@ if ($WithWikiWorker) {
|
|||
|
||||
if ($Background) {
|
||||
Write-Step "Starting gateway in background"
|
||||
$p = Start-Process -FilePath $pythonExe -ArgumentList @("-m","oclaw.runtime.operations","gateway","start","--host",$BindHost,"--port",$Port) -WorkingDirectory $repoParent -PassThru -WindowStyle Hidden
|
||||
$p = Start-Process -FilePath $pythonExe -ArgumentList @("-m","oclaw.runtime.operations","gateway","start","--host",$BindHost,"--port",$Port) -WorkingDirectory $repoRoot -PassThru -WindowStyle Hidden
|
||||
Set-Content -Path $pidFile -Value "$($p.Id)" -Encoding ascii
|
||||
Write-Host "gateway.pid = $pidFile" -ForegroundColor DarkGray
|
||||
Write-Host "PID = $($p.Id)" -ForegroundColor Green
|
||||
|
|
|
|||
|
|
@ -17,12 +17,16 @@ function Fail([string]$msg) {
|
|||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
Set-Location $repoRoot
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Working directory: $repoRoot"
|
||||
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ $ErrorActionPreference = "Stop"
|
|||
|
||||
function Resolve-RepoRoot {
|
||||
$here = Split-Path -Parent $PSCommandPath
|
||||
return (Resolve-Path (Join-Path $here "..")).Path
|
||||
return (Resolve-Path (Join-Path $here "..\\..\\..")).Path
|
||||
}
|
||||
|
||||
$repoRoot = Resolve-RepoRoot
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
$null = New-Item -ItemType Directory -Force -Path $runDir -ErrorAction SilentlyContinue
|
||||
$pidFile = Join-Path $runDir "wiki_worker.pid"
|
||||
|
|
@ -25,6 +26,16 @@ function Test-AlivePid([int]$procId) {
|
|||
}
|
||||
}
|
||||
|
||||
function Test-IsWikiWorkerPid([int]$procId) {
|
||||
try {
|
||||
$wmi = Get-CimInstance Win32_Process -Filter "ProcessId = $procId" -ErrorAction Stop
|
||||
$cmd = [string]($wmi.CommandLine)
|
||||
return $cmd -like "*oclaw.runtime.workers.wiki.main*"
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
$pythonExe = $venvPython
|
||||
|
|
@ -35,6 +46,11 @@ if (Test-Path $venvPython) {
|
|||
}
|
||||
$pythonExe = "python"
|
||||
}
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
if (-not $Background) {
|
||||
& $pythonExe -m oclaw.runtime.workers.wiki.main
|
||||
|
|
@ -45,7 +61,7 @@ if (Test-Path $pidFile) {
|
|||
$raw = (Get-Content $pidFile -ErrorAction SilentlyContinue | Select-Object -First 1)
|
||||
$existing = 0
|
||||
[void][int]::TryParse([string]$raw, [ref]$existing)
|
||||
if ($existing -gt 0 -and (Test-AlivePid $existing)) {
|
||||
if ($existing -gt 0 -and (Test-AlivePid $existing) -and (Test-IsWikiWorkerPid $existing)) {
|
||||
Write-Host "[ok] wiki worker already running pid=$existing"
|
||||
exit 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,12 @@ function Write-Step([string]$msg) {
|
|||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
Set-Location $repoRoot
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
|
|
@ -17,7 +21,7 @@ if (Test-Path $venvPython) {
|
|||
}
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Working directory: $repoRoot"
|
||||
Write-Step "Stack status"
|
||||
& $pythonExe -m oclaw.runtime.operations stack status
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@ function Write-Step([string]$msg) {
|
|||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
Set-Location $repoRoot
|
||||
$env:PYTHONPATH = $repoParent
|
||||
$env:PYTHONSAFEPATH = "1"
|
||||
$env:AIA_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OPS_WORKSPACE_ROOT = $repoRoot
|
||||
$env:OCLAW_WORKSPACE = $repoRoot
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
|
|
@ -21,7 +25,7 @@ if (Test-Path $venvPython) {
|
|||
}
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Working directory: $repoRoot"
|
||||
Write-Step "Stopping stack services..."
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ from oclaw.platform.persistence.sqlite_store import SqliteStore
|
|||
|
||||
|
||||
def _load_cfg() -> dict:
|
||||
cfg_file = (Path(PROJECT_ROOT) / "oclaw" / "oclaw.json").resolve()
|
||||
cfg_file = (Path(PROJECT_ROOT) / "oclaw.json").resolve()
|
||||
if not cfg_file.exists():
|
||||
return {}
|
||||
try:
|
||||
|
|
@ -30,7 +30,7 @@ def _wiki_root_from_cfg(cfg: dict) -> Path:
|
|||
plugins = cfg.get("plugins") if isinstance(cfg, dict) else {}
|
||||
entries = plugins.get("entries") if isinstance(plugins, dict) else {}
|
||||
mw = entries.get("memory-wiki") if isinstance(entries, dict) else {}
|
||||
root_cfg = str((mw or {}).get("wiki_root") or "oclaw/docs/memory-system/wiki").strip()
|
||||
root_cfg = str((mw or {}).get("wiki_root") or "docs/memory-system/wiki").strip()
|
||||
root = Path(root_cfg)
|
||||
if not root.is_absolute():
|
||||
root = (Path(PROJECT_ROOT) / root).resolve()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue