mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +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
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue