兼容 memory-wiki 输入路径并强调相对路径

- memory-wiki 的 wiki_root 路径解析兼容:相对路径 / data/wiki 前缀 / wiki_root 下绝对路径
- 系统提示词强调:模型传相对 wiki 根路径(相对 data/wiki),避免直接给 data/wiki/... 或绝对路径
- 修复并回归:memory-wiki 工具动态加载模块 import-time 错误(sys.modules 注入)
- chat.js 增强会话滚动跟随(异步渲染补滚)

Made-with: Cursor
This commit is contained in:
oliver 2026-04-29 08:54:58 +08:00
parent 27b8698f9b
commit 25180921e7
4 changed files with 100 additions and 11 deletions

View file

@ -1,5 +1,8 @@
from __future__ import annotations
from pathlib import Path
from oclaw.platform.config.paths import PROJECT_ROOT
from oclaw.runtime.tools.experts.memory.wiki_tools import (
memory_wiki_apply_tool,
memory_wiki_get_tool,
@ -35,3 +38,22 @@ def test_memory_wiki_tools_handlers_load_without_dataclass_module_error() -> Non
assert "AttributeError" not in str(apply_res.get("error", ""))
assert "__dict__" not in str(apply_res.get("error", ""))
def test_memory_wiki_tools_accept_relative_prefixed_and_absolute_paths() -> None:
wiki_root = (PROJECT_ROOT / "data" / "wiki").resolve()
rel = Path("improvement") / "learnings.md"
abs_path = str((wiki_root / rel).resolve())
prefixed_rel = str(Path("data/wiki") / rel)
# Relative
r1 = memory_wiki_get_tool().handler({"path": str(rel)})
assert r1.get("ok") is True
# Prefixed by "data/wiki/..."
r2 = memory_wiki_get_tool().handler({"path": prefixed_rel})
assert r2.get("ok") is True
# Absolute path under wiki_root
r3 = memory_wiki_get_tool().handler({"path": abs_path})
assert r3.get("ok") is True