Give your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Python agent-infrastructureai-agentai-searchautomationbilibiliclaude-codeclicursorfree-apillm-toolsmcppythonreddit-scrapertwitter-scraperweb-scraperxiaohongshuyoutube-transcript
fix(skill): support OpenCode discovery
Pnant8809232af71a
diff --git a/agent_reach/cli.py b/agent_reach/cli.pyindex 22519749..746fc923 100644--- a/agent_reach/cli.py+++ b/agent_reach/cli.py@@ -411,10 +411,10 @@ def _cmd_install(args):def _install_skill(force: bool = True):- """Install Agent Reach as an agent skill (OpenClaw / Claude Code / .agents)."""+ """Install Agent Reach as an agent skill for supported agent clients."""+ import importlib.resourcesimport osimport shutil- import importlib.resourcesdef _is_english_locale(value: str) -> bool:normalized = value.strip().lower()@@ -482,25 +482,28 @@ def _install_skill(force: bool = True):print(f" Warning: Could not install skill: {e}")return None- # Determine skill install path (priority: .agents > openclaw > claude)+ # Install into every known skill root that already exists.skill_dirs = [- os.path.expanduser("~/.agents/skills"), # Generic agents (priority)- os.path.expanduser("~/.openclaw/skills"), # OpenClaw- os.path.expanduser("~/.claude/skills"), # Claude Code (if exists)+ (os.path.expanduser("~/.agents/skills"), "Agent"),+ (os.path.expanduser("~/.config/opencode/skills"), "OpenCode"),+ (os.path.expanduser("~/.openclaw/skills"), "OpenClaw"),+ (os.path.expanduser("~/.claude/skills"), "Claude Code"),]# Insert OPENCLAW_HOME path at the beginning if environment variable is setopenclaw_home = os.environ.get("OPENCLAW_HOME")if openclaw_home:- skill_dirs.insert(0, os.path.join(openclaw_home, ".openclaw", "skills"))+ skill_dirs.insert(+ 0,+ (os.path.join(openclaw_home, ".openclaw", "skills"), "OpenClaw"),+ )installed = False- for skill_dir in skill_dirs:+ for skill_dir, platform_name in skill_dirs:if os.path.isdir(skill_dir):target = os.path.join(skill_dir, "agent-reach")status = _copy_skill_dir(target)if status:- platform_name = "Agent" if ".agents" in skill_dir else "OpenClaw" if "openclaw" in skill_dir else "Claude Code"if status == "preserved":print(f"Skill already installed for {platform_name}, preserving existing files: {target}")else:@@ -518,7 +521,10 @@ def _install_skill(force: bool = True):print(f"Skill installed: {target}")else:print(" -- Could not install agent skill (optional)")- print(" -- Tip: install OpenClaw, Claude Code, or create ~/.agents/skills/ manually")+ print(+ " -- Tip: install OpenCode, OpenClaw, Claude Code, "+ "or create ~/.agents/skills/ manually"+ )def _uninstall_skill():@@ -526,6 +532,7 @@ def _uninstall_skill():import shutilskill_dirs = [+ ("~/.config/opencode/skills/agent-reach", "OpenCode"),("~/.openclaw/skills/agent-reach", "OpenClaw"),("~/.claude/skills/agent-reach", "Claude Code"),("~/.agents/skills/agent-reach", "Agent"),@@ -1649,6 +1656,7 @@ def _cmd_uninstall(args):# ── 2. Skill files ──skill_dirs = [+ ("~/.config/opencode/skills/agent-reach", "OpenCode"),("~/.openclaw/skills/agent-reach", "OpenClaw"),("~/.claude/skills/agent-reach", "Claude Code"),("~/.agents/skills/agent-reach", "Agent"),diff --git a/agent_reach/skill/SKILL.md b/agent_reach/skill/SKILL.mdindex d633a6c5..441cebc3 100644--- a/agent_reach/skill/SKILL.md+++ b/agent_reach/skill/SKILL.md@@ -19,25 +19,8 @@ description: >【路由方式】SKILL.md 包含路由表和常用命令,复杂场景需按需阅读对应分类的 references/*.md。分类:search / social (小红书/推特/B站/V2EX/Reddit/Facebook/Instagram) / career(LinkedIn) / dev(github) / web(网页/文章/RSS) / video(YouTube/B站/播客) / finance(雪球/股票)。-triggers:- - research: 调研/全网调研/帮我调研/研究一下/research/深入了解- - search: 搜/查/找/search/搜索/查一下/帮我搜/看看大家怎么说- - social:- - 小红书: xiaohongshu/xhs/小红书/红书- - Twitter: twitter/推特/x.com/推文- - B站: bilibili/b站/哔哩哔哩- - V2EX: v2ex- - Reddit: reddit- - Facebook: facebook/fb/facebook groups- - Instagram: instagram/ig- - career: 招聘/职位/求职/linkedin/领英/找工作- - dev: github/代码/仓库/gh/issue/pr/分支/commit- - web: 网页/链接/文章/rss/读一下/打开这个- - video: youtube/视频/播客/字幕/小宇宙/转录/yt- - finance: 雪球/股票/stock/xueqiu/行情/基金metadata:- openclaw:- homepage: https://github.com/Panniantong/Agent-Reach+ homepage: https://github.com/Panniantong/Agent-Reach---# Agent Reach — 互联网能力路由器diff --git a/agent_reach/skill/SKILL_en.md b/agent_reach/skill/SKILL_en.mdindex 0d57dd67..1d4e364a 100644--- a/agent_reach/skill/SKILL_en.md+++ b/agent_reach/skill/SKILL_en.md@@ -17,8 +17,7 @@ description: >internet content); posting/commenting/liking (write operations); platformsthat already have a dedicated skill installed (prefer that skill).metadata:- openclaw:- homepage: https://github.com/Panniantong/Agent-Reach+ homepage: https://github.com/Panniantong/Agent-Reach---# Agent Reach — internet capability routerdiff --git a/tests/test_opencode_skill.py b/tests/test_opencode_skill.pynew file mode 100644index 00000000..34326de3--- /dev/null+++ b/tests/test_opencode_skill.py@@ -0,0 +1,101 @@+"""OpenCode discovery and metadata compatibility for the packaged skill."""++from __future__ import annotations++import importlib.resources+import os+import re+from pathlib import Path+from types import SimpleNamespace+from unittest.mock import patch++import pytest+import yaml++from agent_reach.cli import _cmd_uninstall, _install_skill, _uninstall_skill+++def _frontmatter(resource_name: str) -> dict[str, object]:+ text = (+ importlib.resources.files("agent_reach")+ .joinpath("skill", resource_name)+ .read_text(encoding="utf-8")+ )+ match = re.match(r"\A---\n(.*?)\n---\n", text, flags=re.DOTALL)+ assert match is not None, f"{resource_name} must start with YAML frontmatter"+ return yaml.safe_load(match.group(1))+++def test_skill_frontmatter_uses_opencode_supported_fields():+ """Both locale variants must follow OpenCode's documented schema."""+ allowed_fields = {+ "name",+ "description",+ "license",+ "compatibility",+ "metadata",+ }++ for resource_name in ("SKILL.md", "SKILL_en.md"):+ frontmatter = _frontmatter(resource_name)+ assert set(frontmatter) <= allowed_fields, resource_name+ assert frontmatter["name"] == "agent-reach", resource_name++ description = frontmatter["description"]+ assert isinstance(description, str), resource_name+ assert 1 <= len(description) <= 1024, resource_name++ metadata = frontmatter.get("metadata", {})+ assert isinstance(metadata, dict), resource_name+ assert all(+ isinstance(key, str) and isinstance(value, str)+ for key, value in metadata.items()+ ), resource_name+++def test_install_skill_discovers_opencode_global_directory(tmp_path: Path):+ skill_parent = tmp_path / ".config" / "opencode" / "skills"+ skill_parent.mkdir(parents=True)++ with patch(+ "agent_reach.cli.os.path.expanduser",+ side_effect=lambda value: value.replace("~", os.fspath(tmp_path)),+ ), patch.dict(os.environ, {}, clear=True):+ _install_skill()++ installed = skill_parent / "agent-reach" / "SKILL.md"+ assert installed.is_file()+ assert "Agent Reach" in installed.read_text(encoding="utf-8")+++def test_uninstall_skill_removes_opencode_global_directory(tmp_path: Path):+ installed = tmp_path / ".config" / "opencode" / "skills" / "agent-reach"+ installed.mkdir(parents=True)+ (installed / "SKILL.md").write_text("test", encoding="utf-8")++ with patch(+ "agent_reach.cli.os.path.expanduser",+ side_effect=lambda value: value.replace("~", os.fspath(tmp_path)),+ ), patch.dict(os.environ, {}, clear=True):+ _uninstall_skill()++ assert not installed.exists()+++def test_full_uninstall_includes_opencode_directory(+ tmp_path: Path, capsys: pytest.CaptureFixture[str]+):+ installed = tmp_path / ".config" / "opencode" / "skills" / "agent-reach"+ installed.mkdir(parents=True)++ with patch(+ "agent_reach.cli.os.path.expanduser",+ side_effect=lambda value: value.replace("~", os.fspath(tmp_path)),+ ), patch("agent_reach.utils.paths.home_dir", return_value=tmp_path), patch(+ "shutil.which", return_value=None+ ):+ _cmd_uninstall(SimpleNamespace(dry_run=True, keep_config=True))++ output = capsys.readouterr().out+ assert f"Would remove OpenCode skill: {installed}" in output+ assert installed.is_dir()