hkuds--openharness
5dd8b952ec
A lightweight open-source Python implementation of the Agent Harness architecture. 44x lighter than Claude Code (11K vs 512K lines), 98% core tool coverage. - 43 tools with Pydantic validation and parallel execution - Skills system compatible with anthropics/skills (17+ tested) - Plugin system compatible with claude-code/plugins (12+ tested) - API retry with exponential backoff - Multi-level permissions with path rules - React/Ink TUI with "Oh my Harness!" branding - 114 unit tests + 6 E2E test suites - MIT License
83 行
2.5 KiB
Python
83 行
2.5 KiB
Python
"""Tests for plugin loading."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from openharness.config.settings import Settings
|
|
from openharness.hooks.loader import load_hook_registry
|
|
from openharness.plugins import load_plugins
|
|
from openharness.skills import load_skill_registry
|
|
|
|
|
|
def _write_plugin(root: Path) -> None:
|
|
plugin_dir = root / "example-plugin"
|
|
(plugin_dir / "skills").mkdir(parents=True)
|
|
(plugin_dir / "plugin.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"name": "example",
|
|
"version": "1.0.0",
|
|
"description": "Example plugin",
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
(plugin_dir / "skills" / "deploy.md").write_text(
|
|
"# Deploy\nDeploy with care\n",
|
|
encoding="utf-8",
|
|
)
|
|
(plugin_dir / "hooks.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"session_start": [
|
|
{"type": "command", "command": "printf start"}
|
|
]
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
(plugin_dir / "mcp.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"mcpServers": {
|
|
"demo": {"type": "stdio", "command": "python", "args": ["demo.py"]}
|
|
}
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
|
|
def test_load_plugins_from_project_dir(tmp_path: Path, monkeypatch):
|
|
monkeypatch.setenv("OPENHARNESS_CONFIG_DIR", str(tmp_path / "config"))
|
|
project = tmp_path / "repo"
|
|
plugins_root = project / ".openharness" / "plugins"
|
|
plugins_root.mkdir(parents=True)
|
|
_write_plugin(plugins_root)
|
|
|
|
plugins = load_plugins(Settings(), project)
|
|
|
|
assert len(plugins) == 1
|
|
plugin = plugins[0]
|
|
assert plugin.manifest.name == "example"
|
|
assert plugin.skills[0].name == "Deploy"
|
|
assert "session_start" in plugin.hooks
|
|
assert "demo" in plugin.mcp_servers
|
|
|
|
|
|
def test_plugin_skills_and_hooks_are_merged(tmp_path: Path, monkeypatch):
|
|
monkeypatch.setenv("OPENHARNESS_CONFIG_DIR", str(tmp_path / "config"))
|
|
project = tmp_path / "repo"
|
|
plugins_root = project / ".openharness" / "plugins"
|
|
plugins_root.mkdir(parents=True)
|
|
_write_plugin(plugins_root)
|
|
|
|
skills = load_skill_registry(project).list_skills()
|
|
assert any(skill.name == "Deploy" and skill.source == "plugin" for skill in skills)
|
|
|
|
plugins = load_plugins(Settings(), project)
|
|
hooks = load_hook_registry(Settings(), plugins)
|
|
assert "session_start" in hooks.summary()
|