mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 12:30:44 +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
|
|
@ -30,7 +30,7 @@ def _workspace_for_role(role: str) -> str:
|
|||
|
||||
|
||||
def _role_workspace_signature(role_id: str) -> tuple[Any, ...]:
|
||||
base = (PROJECT_ROOT / "oclaw" / "runtime" / "workspaces").resolve()
|
||||
base = (PROJECT_ROOT / "runtime" / "workspaces").resolve()
|
||||
role_root = (base / role_id).resolve()
|
||||
if not role_root.exists() or not role_root.is_dir():
|
||||
return ("missing", role_id, str(base))
|
||||
|
|
@ -85,7 +85,7 @@ def build_role_system_context(role: str, template_vars: dict[str, Any] | None =
|
|||
cached = _ROLE_CONTEXT_CACHE.get(cache_key)
|
||||
if isinstance(cached, str) and cached.strip():
|
||||
return cached
|
||||
base = (PROJECT_ROOT / "oclaw" / "runtime" / "workspaces").resolve()
|
||||
base = (PROJECT_ROOT / "runtime" / "workspaces").resolve()
|
||||
roots: list[Path] = []
|
||||
role_root = (base / role_id).resolve()
|
||||
if role_root.exists() and role_root.is_dir():
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def build_plugin_config_schema(*_args, **_kwargs) -> dict[str, Any]:
|
|||
"wiki_root": {
|
||||
"type": "string",
|
||||
"description": "Wiki root directory relative to workspace root.",
|
||||
"default": "oclaw/docs/memory-system/wiki",
|
||||
"default": "docs/memory-system/wiki",
|
||||
},
|
||||
"max_search_results": {
|
||||
"type": "integer",
|
||||
|
|
@ -45,9 +45,9 @@ class WikiRuntime:
|
|||
|
||||
def _resolve_runtime(api: Any) -> WikiRuntime:
|
||||
cfg = dict(getattr(api, "plugin_config", {}) or {})
|
||||
root_cfg = str(cfg.get("wiki_root") or "oclaw/docs/memory-system/wiki").strip()
|
||||
root_cfg = str(cfg.get("wiki_root") or "docs/memory-system/wiki").strip()
|
||||
if not root_cfg:
|
||||
root_cfg = "oclaw/docs/memory-system/wiki"
|
||||
root_cfg = "docs/memory-system/wiki"
|
||||
root = Path(root_cfg)
|
||||
if not root.is_absolute():
|
||||
root = (_project_root() / root).resolve()
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ class OclawGateway:
|
|||
@staticmethod
|
||||
def _tabular_limits_from_config() -> dict[str, int]:
|
||||
cfg_path_raw = str(os.getenv("AIA_OCLAW_CONFIG_PATH") or "").strip()
|
||||
cfg_path = Path(cfg_path_raw).expanduser() if cfg_path_raw else (Path(PROJECT_ROOT) / "oclaw" / "oclaw.json")
|
||||
cfg_path = Path(cfg_path_raw).expanduser() if cfg_path_raw else (Path(PROJECT_ROOT) / "oclaw.json")
|
||||
if not cfg_path.is_absolute():
|
||||
cfg_path = (Path(PROJECT_ROOT) / cfg_path).resolve()
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ def _project_root() -> Path:
|
|||
|
||||
|
||||
def _load_config() -> dict[str, Any]:
|
||||
cfg_path = _project_root() / "oclaw" / "oclaw.json"
|
||||
cfg_path = _project_root() / "oclaw.json"
|
||||
if not cfg_path.exists():
|
||||
return {}
|
||||
try:
|
||||
|
|
@ -29,7 +29,7 @@ def _resolve_wiki_entry(cfg: dict[str, Any]) -> dict[str, Any]:
|
|||
|
||||
|
||||
def _resolve_runtime(entry: dict[str, Any]) -> tuple[Path, int, int, bool, int, bool]:
|
||||
root_cfg = str(entry.get("wiki_root") or "oclaw/docs/memory-system/wiki").strip()
|
||||
root_cfg = str(entry.get("wiki_root") or "docs/memory-system/wiki").strip()
|
||||
root = Path(root_cfg)
|
||||
if not root.is_absolute():
|
||||
root = (_project_root() / root).resolve()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def resolve_hooks_config_storage_path() -> Path:
|
|||
Path used for persistent ``hooks.internal.entries`` edits.
|
||||
|
||||
Matches ``resolve_runtime_config`` file resolution: ``OCLAW_CONFIG_PATH`` (optional
|
||||
relative to ``PROJECT_ROOT``), else ``<PROJECT_ROOT>/oclaw/oclaw.json``.
|
||||
relative to ``PROJECT_ROOT``), else ``<PROJECT_ROOT>/oclaw.json``.
|
||||
"""
|
||||
raw = str(os.getenv("OCLAW_CONFIG_PATH") or "").strip()
|
||||
if raw:
|
||||
|
|
@ -21,7 +21,7 @@ def resolve_hooks_config_storage_path() -> Path:
|
|||
if not p.is_absolute():
|
||||
p = (Path(PROJECT_ROOT) / p).resolve()
|
||||
return p
|
||||
return (Path(PROJECT_ROOT) / "oclaw" / "oclaw.json").resolve()
|
||||
return (Path(PROJECT_ROOT) / "oclaw.json").resolve()
|
||||
|
||||
|
||||
def load_storage_config_document() -> dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ def _reset_hooks_runtime_state_for_test() -> None:
|
|||
|
||||
|
||||
def _ensure_oclaw_path() -> Path:
|
||||
oclaw_dir = (Path(PROJECT_ROOT) / "oclaw").resolve()
|
||||
oclaw_dir = Path(PROJECT_ROOT).resolve()
|
||||
if str(oclaw_dir) not in sys.path:
|
||||
sys.path.insert(0, str(oclaw_dir))
|
||||
return oclaw_dir
|
||||
|
|
@ -111,7 +111,7 @@ def resolve_runtime_config() -> dict[str, Any]:
|
|||
cfg = _deep_merge_dict(cfg, file_cfg)
|
||||
return cfg
|
||||
|
||||
default_cfg_path = (Path(PROJECT_ROOT) / "oclaw" / "oclaw.json").resolve()
|
||||
default_cfg_path = (Path(PROJECT_ROOT) / "oclaw.json").resolve()
|
||||
file_cfg = _read_json_file(default_cfg_path)
|
||||
if isinstance(file_cfg, dict):
|
||||
cfg = _deep_merge_dict(cfg, file_cfg)
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ def after_turn_memory(
|
|||
except Exception:
|
||||
pass
|
||||
try:
|
||||
cfg_path = Path(__file__).resolve().parents[2] / "oclaw" / "oclaw.json"
|
||||
cfg_path = Path(__file__).resolve().parents[1] / "oclaw.json"
|
||||
cfg = json.loads(cfg_path.read_text(encoding="utf-8")) if cfg_path.exists() else {}
|
||||
plugins = cfg.get("plugins") if isinstance(cfg, dict) else {}
|
||||
entries = plugins.get("entries") if isinstance(plugins, dict) else {}
|
||||
|
|
|
|||
|
|
@ -33,13 +33,17 @@ from oclaw.runtime.hooks.user_config_hooks import (
|
|||
)
|
||||
from oclaw.runtime.hooks.workspace import load_workspace_hook_entries
|
||||
from oclaw.runtime.hooks_runtime import resolve_runtime_config
|
||||
from oclaw.runtime.tools.experts.workspace.workspace_base import workspace_root
|
||||
|
||||
|
||||
def _resolve_cli_workspace(ns: argparse.Namespace) -> str:
|
||||
w = getattr(ns, "workspace", None)
|
||||
if isinstance(w, str) and w.strip():
|
||||
return w.strip()
|
||||
return str(os.getenv("OCLAW_WORKSPACE") or os.getcwd()).strip() or "."
|
||||
env_ws = str(os.getenv("OCLAW_WORKSPACE") or "").strip()
|
||||
if env_ws:
|
||||
return env_ws
|
||||
return str(workspace_root())
|
||||
|
||||
|
||||
def prepare_hooks_cli_config(cfg: dict[str, Any] | None) -> dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ def _expand_env_value(v: str) -> str:
|
|||
def _mcp_local_env_paths_in_load_order() -> list[Path]:
|
||||
return [
|
||||
Path(db_path()).resolve().parent / "mcp_local.env",
|
||||
(PROJECT_ROOT / "oclaw" / "_local" / "mcp_local.env").resolve(),
|
||||
(PROJECT_ROOT / "_local" / "mcp_local.env").resolve(),
|
||||
(PROJECT_ROOT.parent / "_local" / "mcp_local.env").resolve(),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ def mcp_local_env_merged() -> dict[str, str]:
|
|||
|
||||
|
||||
def mcp_local_env_file_path() -> Path:
|
||||
return (PROJECT_ROOT / "oclaw" / "_local" / "mcp_local.env").resolve()
|
||||
return (PROJECT_ROOT / "_local" / "mcp_local.env").resolve()
|
||||
|
||||
|
||||
def gateway_mcp_env_extras() -> dict[str, str]:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from oclaw.platform.persistence.sqlite_store import SqliteStore
|
|||
from oclaw.runtime.tools.mcp.registry import McpRegistry
|
||||
|
||||
_EXPORT_FILENAME = "mcp_registry_migrated.json"
|
||||
_LOCAL_DIR = (PROJECT_ROOT / "oclaw" / "_local").resolve()
|
||||
_LOCAL_DIR = (PROJECT_ROOT / "_local").resolve()
|
||||
_EXPORT_PATH = (_LOCAL_DIR / _EXPORT_FILENAME).resolve()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -144,19 +144,19 @@ def register_memory_parser(root_sub: argparse._SubParsersAction[argparse.Argumen
|
|||
memory_sub = memory.add_subparsers(dest="memory_cmd", required=True)
|
||||
|
||||
status = memory_sub.add_parser("status", help="Show memory workload status")
|
||||
status.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
status.add_argument("--base-dir", default="docs/memory-system", help="Memory system base directory")
|
||||
status.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
status.set_defaults(func=_cmd_memory_status)
|
||||
|
||||
daily = memory_sub.add_parser("daily", help="Generate today's automated memory run")
|
||||
daily.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
daily.add_argument("--base-dir", default="docs/memory-system", help="Memory system base directory")
|
||||
daily.add_argument("--date", default=None, help="Run date in YYYY-MM-DD")
|
||||
daily.add_argument("--focus", default=None, help="Override focus topic")
|
||||
daily.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
daily.set_defaults(func=_cmd_memory_daily)
|
||||
|
||||
weekly = memory_sub.add_parser("weekly", help="Generate weekly review run sheet")
|
||||
weekly.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
weekly.add_argument("--base-dir", default="docs/memory-system", help="Memory system base directory")
|
||||
weekly.add_argument("--date", default=None, help="Run date in YYYY-MM-DD")
|
||||
weekly.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
weekly.set_defaults(func=_cmd_memory_weekly)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def _project_context_roots() -> tuple[Path, ...]:
|
|||
raw_ws = str(os.getenv("OCLAW_WORKSPACE") or "").strip()
|
||||
if raw_ws:
|
||||
roots.append(Path(raw_ws).expanduser())
|
||||
roots.append(Path(PROJECT_ROOT) / "oclaw" / "runtime" / "workspaces" / "main")
|
||||
roots.append(Path(PROJECT_ROOT) / "runtime" / "workspaces" / "main")
|
||||
roots.append(Path(PROJECT_ROOT))
|
||||
out: list[Path] = []
|
||||
seen: set[str] = set()
|
||||
|
|
|
|||
|
|
@ -87,12 +87,15 @@ def default_skills_root() -> Path:
|
|||
# Optional hard-disable for legacy fallback lookups.
|
||||
if str(os.getenv("AIA_DISABLE_LEGACY_SKILLS_FALLBACK") or "").strip().lower() in {"1", "true", "yes", "on"}:
|
||||
return preferred
|
||||
typo_legacy = (PROJECT_ROOT / "oclaw" / "sills").resolve()
|
||||
typo_legacy = (PROJECT_ROOT / "sills").resolve()
|
||||
if typo_legacy.exists() and typo_legacy.is_dir():
|
||||
return typo_legacy
|
||||
legacy = (PROJECT_ROOT / "oclaw" / "skills").resolve()
|
||||
legacy = (PROJECT_ROOT / "skills").resolve()
|
||||
if legacy.exists() and legacy.is_dir():
|
||||
return legacy
|
||||
legacy_parent = (PROJECT_ROOT.parent / "skills").resolve()
|
||||
if legacy_parent.exists() and legacy_parent.is_dir():
|
||||
return legacy_parent
|
||||
return preferred
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from oclaw.runtime.tools.base import ToolSpec
|
|||
|
||||
|
||||
def _plugin_cfg() -> dict[str, Any]:
|
||||
cfg_path = (PROJECT_ROOT / "oclaw" / "oclaw.json").resolve()
|
||||
cfg_path = (PROJECT_ROOT / "oclaw.json").resolve()
|
||||
if not cfg_path.exists():
|
||||
return {}
|
||||
try:
|
||||
|
|
@ -25,7 +25,7 @@ def _plugin_cfg() -> dict[str, Any]:
|
|||
|
||||
|
||||
def _wiki_handlers() -> dict[str, Callable[[dict[str, Any]], dict[str, Any]]]:
|
||||
api_path = (PROJECT_ROOT / "oclaw" / "runtime" / "extensions" / "memory-wiki" / "api.py").resolve()
|
||||
api_path = (PROJECT_ROOT / "runtime" / "extensions" / "memory-wiki" / "api.py").resolve()
|
||||
spec = importlib.util.spec_from_file_location("memory_wiki_api", str(api_path))
|
||||
if spec is None or spec.loader is None:
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from oclaw.runtime.tools.base import ToolSpec
|
||||
|
|
@ -59,11 +60,30 @@ def read_file_tool() -> ToolSpec:
|
|||
|
||||
|
||||
def write_file_tool() -> ToolSpec:
|
||||
def _normalize_write_path(path: str) -> str:
|
||||
raw = str(path or "").strip().strip('"').strip("'")
|
||||
if not raw:
|
||||
raise ValueError("path_required")
|
||||
p = Path(raw)
|
||||
if p.is_absolute():
|
||||
return str(p)
|
||||
# Keep generated files out of repo root: default relative writes go under data/<workspace_name>/...
|
||||
ws = resolve_workspace_path(".")
|
||||
ws_name = ws.name or "workspace"
|
||||
rel = raw.lstrip("./\\")
|
||||
if not rel:
|
||||
raise ValueError("path_required")
|
||||
return str(Path("data") / ws_name / rel)
|
||||
|
||||
def handler(args: dict[str, Any]) -> dict[str, Any]:
|
||||
path = str(args.get("path") or "").strip()
|
||||
content = str(args.get("content") or "")
|
||||
mode = str(args.get("mode") or "overwrite").strip().lower()
|
||||
p = resolve_workspace_path(path)
|
||||
try:
|
||||
normalized = _normalize_write_path(path)
|
||||
except ValueError as exc:
|
||||
return {"ok": False, "error": str(exc)}
|
||||
p = resolve_workspace_path(normalized)
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
if mode not in ("overwrite", "append"):
|
||||
return {"ok": False, "error": "invalid_mode", "allowed": ["overwrite", "append"]}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ def index_workspace(
|
|||
max_chars_per_chunk: int = 1600,
|
||||
) -> IndexStats:
|
||||
r = Path(root).resolve() if root else _default_workspace_root()
|
||||
pats = patterns or ["oclaw/**/*.py", "README*.md", "**/*.md"]
|
||||
pats = patterns or ["**/*.py", "README*.md", "**/*.md"]
|
||||
files = _iter_files(r, pats, max_files=max(1, int(max_files)))
|
||||
client = build_default_embedding_client()
|
||||
chunks_upserted = 0
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import time
|
|||
import importlib.util
|
||||
import hashlib
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
|
@ -15,7 +16,7 @@ from oclaw.platform.persistence.sqlite_store import OclawTask, SqliteStore
|
|||
|
||||
|
||||
def _load_oclaw_config() -> dict[str, Any]:
|
||||
cfg_path = (Path(PROJECT_ROOT) / "oclaw" / "oclaw.json").resolve()
|
||||
cfg_path = (Path(PROJECT_ROOT) / "oclaw.json").resolve()
|
||||
if not cfg_path.exists():
|
||||
return {}
|
||||
try:
|
||||
|
|
@ -39,7 +40,7 @@ def _is_worker_enabled(entry: dict[str, Any]) -> bool:
|
|||
|
||||
|
||||
def _resolve_wiki_root(plugin_cfg: dict[str, Any]) -> Path:
|
||||
root_cfg = str(plugin_cfg.get("wiki_root") or "oclaw/docs/memory-system/wiki").strip()
|
||||
root_cfg = str(plugin_cfg.get("wiki_root") or "docs/memory-system/wiki").strip()
|
||||
root = Path(root_cfg)
|
||||
if not root.is_absolute():
|
||||
root = (Path(PROJECT_ROOT) / root).resolve()
|
||||
|
|
@ -76,11 +77,16 @@ def _resolve_topic_rules(plugin_cfg: dict[str, Any]) -> list[dict[str, Any]]:
|
|||
|
||||
|
||||
def _tool_handlers(plugin_cfg: dict[str, Any]) -> dict[str, Any]:
|
||||
api_path = (Path(PROJECT_ROOT) / "oclaw" / "extensions" / "memory-wiki" / "api.py").resolve()
|
||||
candidates = [
|
||||
(Path(PROJECT_ROOT) / "runtime" / "extensions" / "memory-wiki" / "api.py").resolve(),
|
||||
(Path(PROJECT_ROOT) / "extensions" / "memory-wiki" / "api.py").resolve(),
|
||||
]
|
||||
api_path = next((p for p in candidates if p.exists()), candidates[0])
|
||||
spec = importlib.util.spec_from_file_location("oclaw_memory_wiki_api_worker", str(api_path))
|
||||
if spec is None or spec.loader is None:
|
||||
return {}
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = mod
|
||||
spec.loader.exec_module(mod) # type: ignore[assignment]
|
||||
build_wiki_tool_specs = getattr(mod, "build_wiki_tool_specs", None)
|
||||
if not callable(build_wiki_tool_specs):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ _SPECIALIST_IDS_CACHE: dict[tuple[Any, ...], tuple[str, ...]] = {}
|
|||
|
||||
|
||||
def workspaces_root() -> Path:
|
||||
return (PROJECT_ROOT / "oclaw" / "runtime" / "workspaces").resolve()
|
||||
return (PROJECT_ROOT / "runtime" / "workspaces").resolve()
|
||||
|
||||
|
||||
def normalize_expert_id(raw: Any) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue