修复 memory wiki 工具加载异常并在系统提示词声明默认 wiki 路径。

为动态加载的 memory-wiki 模块补充 sys.modules 注册以避免 dataclass 导入期崩溃,同时在统一技能策略中明确默认根路径为 data/wiki,并新增工具加载回归测试。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-29 08:34:38 +08:00
parent c6a1da1980
commit 27b8698f9b
3 changed files with 42 additions and 0 deletions

View file

@ -1,6 +1,7 @@
from __future__ import annotations
import importlib.util
import sys
from types import SimpleNamespace
from typing import Any, Callable
@ -30,6 +31,9 @@ def _wiki_handlers() -> dict[str, Callable[[dict[str, Any]], dict[str, Any]]]:
if spec is None or spec.loader is None:
return {}
mod = importlib.util.module_from_spec(spec)
# Register module before exec so decorators (e.g., @dataclass) can resolve
# cls.__module__ via sys.modules during import-time processing.
sys.modules[spec.name] = mod
spec.loader.exec_module(mod) # type: ignore[assignment]
fn = getattr(mod, "build_wiki_tool_specs", None)
if not callable(fn):