mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-27 22:34:04 +08:00
fix(agent): load split skill docs through read_skill
This commit is contained in:
@@ -93,11 +93,13 @@ def test_moviepilot_api_skill_routes_contracts_to_category_files() -> None:
|
||||
|
||||
assert len(entrypoint.splitlines()) < 300
|
||||
assert "### `" not in entrypoint
|
||||
assert len(category_files) == 22
|
||||
assert len(category_files) == 21
|
||||
assert "models" not in category_files
|
||||
assert all(
|
||||
f"### `{operation_id}`" in category_files[operation_id.split(".", 1)[0]]
|
||||
for operation_id in API_OPERATION_ROUTES
|
||||
)
|
||||
assert all("## Body Models" in content for content in category_files.values())
|
||||
|
||||
|
||||
def test_every_gateway_operation_has_one_exact_english_skill_and_mcp_contract() -> None:
|
||||
|
||||
@@ -129,6 +129,29 @@ async def test_skill_pagination_reconstructs_unmodified_repository_skill() -> No
|
||||
assert server.stats["world_calls"] == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_skill_supporting_document_uses_read_skill_without_file_tool() -> None:
|
||||
"""评测服务应通过 read_skill 加载已列出的分类合同,而不是开放任意文件读取。"""
|
||||
async with EvaluationMcpServer(EvaluationWorld("dedup_existing")) as server:
|
||||
async with _client(server) as client:
|
||||
result, payload = await _tool(
|
||||
client,
|
||||
"read_skill",
|
||||
{"name": "moviepilot-api", "file": "api/config.md"},
|
||||
)
|
||||
assert result["isError"] is False
|
||||
assert payload["tool_result_truncated"] is True
|
||||
assert "# Configuration APIs" in payload["content_preview"]
|
||||
|
||||
invalid_result, invalid = await _tool(
|
||||
client,
|
||||
"read_skill",
|
||||
{"name": "moviepilot-api", "file": "../SKILL.md"},
|
||||
)
|
||||
assert invalid_result["isError"] is True
|
||||
assert invalid["error"] == "skill_file_not_found"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_world_call_limit_is_global_across_sessions_and_parallel_requests() -> None:
|
||||
"""并行连接也共享硬调用上限,超限不会继续读取或改变独立世界。"""
|
||||
|
||||
@@ -77,7 +77,7 @@ def test_skills_middleware_exposes_read_skill_tool(tmp_path):
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_read_skill_loads_body_and_supporting_files_by_id_and_name(tmp_path):
|
||||
"""read_skill 应按 id 或 name 返回完整主体及稳定的辅助文件清单。"""
|
||||
"""read_skill 应按 id 或 name 返回主体,并在同一权限边界内读取辅助文档。"""
|
||||
_write_skill(tmp_path, "moviepilot-api", name="MoviePilot API")
|
||||
skill_dir = tmp_path / "moviepilot-api"
|
||||
(skill_dir / "references").mkdir()
|
||||
@@ -102,6 +102,23 @@ async def test_read_skill_loads_body_and_supporting_files_by_id_and_name(tmp_pat
|
||||
assert by_name["success"] is True
|
||||
assert by_name["skill"]["name"] == "MoviePilot API"
|
||||
|
||||
supporting = json.loads(
|
||||
await skill_tool.ainvoke(
|
||||
{"name": "moviepilot-api", "file": "references/usage.md"}
|
||||
)
|
||||
)
|
||||
assert supporting["success"] is True
|
||||
assert supporting["content"] == "usage"
|
||||
assert supporting["loaded_file"] == "references/usage.md"
|
||||
assert supporting["skill"]["id"] == "moviepilot-api"
|
||||
|
||||
invalid = json.loads(
|
||||
await skill_tool.ainvoke(
|
||||
{"name": "moviepilot-api", "file": "../SKILL.md"}
|
||||
)
|
||||
)
|
||||
assert invalid["success"] is False
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_read_skill_caps_body_at_512_kib_without_global_64_kib_truncation(tmp_path):
|
||||
@@ -142,7 +159,18 @@ async def test_bundled_moviepilot_api_skill_loads_complete_contract() -> None:
|
||||
assert "## API Category Index" in payload["content"]
|
||||
assert "### `workflow.update`" not in payload["content"]
|
||||
assert "api/workflow.md" in payload["supporting_files"]
|
||||
assert "api/models.md" in payload["supporting_files"]
|
||||
assert "api/models.md" not in payload["supporting_files"]
|
||||
|
||||
category = json.loads(
|
||||
await middleware.tools[0].ainvoke(
|
||||
{"name": "moviepilot-api", "file": "api/workflow.md"}
|
||||
)
|
||||
)
|
||||
assert category["success"] is True
|
||||
assert category["loaded_file"] == "api/workflow.md"
|
||||
assert "### `workflow.update`" in category["content"]
|
||||
assert "## Body Models" in category["content"]
|
||||
assert "### `WorkflowExecutionConfig`" in category["content"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -273,6 +301,8 @@ def test_modify_request_instructs_model_to_use_read_skill_without_paths(tmp_path
|
||||
|
||||
assert "`read_skill` tool" in system_content
|
||||
assert "never `read_file`" in system_content
|
||||
assert "supporting Skill document" in system_content
|
||||
assert "relative `file` path" in system_content
|
||||
assert "up to 512 KiB" in system_content
|
||||
assert "moviepilot-api" in system_content
|
||||
assert "Read `" not in system_content
|
||||
|
||||
@@ -117,7 +117,7 @@ def test_modified_builtin_skills_have_incremented_versions() -> None:
|
||||
"command-dispatch": "2",
|
||||
"database-operation": "7",
|
||||
"feedback-issue": "9",
|
||||
"moviepilot-api": "30",
|
||||
"moviepilot-api": "31",
|
||||
"moviepilot-update": "5",
|
||||
"organize-files": "5",
|
||||
"transfer-failed-retry": "5",
|
||||
@@ -147,6 +147,8 @@ def test_core_prompt_requires_read_skill_for_skill_documents() -> None:
|
||||
core_prompt = CORE_PROMPT_PATH.read_text(encoding="utf-8")
|
||||
|
||||
assert "Always use `read_skill`, never `read_file`, to load a skill's SKILL.md" in core_prompt
|
||||
assert "listed supporting Skill document" in core_prompt
|
||||
assert "file=<relative path>" in core_prompt
|
||||
assert "returns up to 512 KiB of the skill body" in core_prompt
|
||||
assert "do not use `read_file` to bypass the limit" in core_prompt
|
||||
|
||||
@@ -206,6 +208,7 @@ def test_api_and_database_skills_declare_final_boundaries() -> None:
|
||||
assert "Never provide a URL, method, authentication header, API key" in api_content
|
||||
assert "retired tool name" in api_content
|
||||
assert "moviepilot tool" in api_content
|
||||
assert "second Models document" in api_content
|
||||
|
||||
update_content = _read_skill("moviepilot-update")
|
||||
assert "allowed-tools: moviepilot_api" in update_content
|
||||
|
||||
Reference in New Issue
Block a user