mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 23:00:44 +08:00
重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。 Made-with: Cursor
This commit is contained in:
parent
ba3836f00f
commit
4a23b715a2
498 changed files with 2760 additions and 2200 deletions
58
tests/test_oclaw_skill_manifest.py
Normal file
58
tests/test_oclaw_skill_manifest.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.runtime.skills import build_skill_manifest, discover_workspace_skill_manifests, load_skill_manifest
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def test_load_skill_manifest_with_oclaw_metadata(tmp_path: Path) -> None:
|
||||
d = tmp_path / "skills" / "demo"
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
(d / "SKILL.md").write_text(
|
||||
"""---
|
||||
name: demo
|
||||
description: demo skill
|
||||
user-invocable: true
|
||||
disable-model-invocation: false
|
||||
metadata: {"oclaw":{"install":[{"id":"i1","kind":"node","package":"foo"}]}}
|
||||
---
|
||||
|
||||
# Demo
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
m = load_skill_manifest(d)
|
||||
assert m is not None
|
||||
assert m.name == "demo"
|
||||
assert m.description == "demo skill"
|
||||
assert len(m.install) == 1
|
||||
assert m.install[0].kind == "node"
|
||||
|
||||
|
||||
def test_discover_workspace_skill_manifests(tmp_path: Path) -> None:
|
||||
base = tmp_path / "skills"
|
||||
(base / "a").mkdir(parents=True, exist_ok=True)
|
||||
(base / "a" / "SKILL.md").write_text("name: a\ndescription: A", encoding="utf-8")
|
||||
rows = discover_workspace_skill_manifests(base)
|
||||
assert len(rows) == 1
|
||||
assert rows[0].name == "a"
|
||||
|
||||
|
||||
def test_skill_manifest_is_deterministic_and_sorted() -> None:
|
||||
class Store:
|
||||
def get_setting(self, _k: str) -> str:
|
||||
return ""
|
||||
|
||||
reg = ToolRegistry(
|
||||
[
|
||||
ToolSpec(name="z_tool", description="z", parameters={"type": "object"}, handler=lambda _a: {"ok": True}),
|
||||
ToolSpec(name="a_tool", description="a", parameters={"type": "object"}, handler=lambda _a: {"ok": True}),
|
||||
]
|
||||
)
|
||||
skills1, stats1 = build_skill_manifest(registry=reg, store=Store(), base_url="")
|
||||
skills2, stats2 = build_skill_manifest(registry=reg, store=Store(), base_url="")
|
||||
assert [s.name for s in skills1] == ["a_tool", "z_tool"]
|
||||
assert [s.name for s in skills2] == ["a_tool", "z_tool"]
|
||||
assert stats1.get("visible_names_preview") == stats2.get("visible_names_preview")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue