zxfccmm4/obsidian-opencode-knowledge/opencli-explorer

Claude Code and agent skill by zxfccmm4/obsidian-opencode-knowledge

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when creating a new OpenCLI adapter from scratch, adding support for a new website or platform, exploring a site's API endpoints via browser DevTools, or when a user asks to automatically generate a CLI for a website. Covers automated generation, API discovery workflow, authentication strategy selection, TS adapter writing, and testing.

Install

npx vskill@latest install zxfccmm4/obsidian-opencode-knowledge/opencli-explorer

SKILL.md

CLI-EXPLORER — 适配器探索式开发完全指南

从零到发布:API 发现 → 认证策略 → 写适配器 → 测试验证。

先选路径

情况走这里
只要为一个具体页面生成一个命令opencli-oneshot skill
想先让机器自动试一遍opencli generate <url> [--goal <goal>],失败再回来
新站点 / 多个命令 / oneshot 卡住了继续往下读本文档

核心流程

┌─────────────┐ ┌─────────────┐ ┌──────────────┐ ┌────────┐
│ 1. 发现 API │ ──▶ │ 2. 选择策略 │ ──▶ │ 3. 写适配器 │ ──▶ │ 4. 测试 │
└─────────────┘ └─────────────┘ └──────────────┘ └────────┘
browser explore cascade TS cli() API verify

AI Agent 必读:必须用浏览器探索

必须通过浏览器打开目标网站去探索! 不要只靠静态分析。
很多 API 是懒加载的——字幕、评论、关注列表等深层数据只有点击后才触发。
浏览器探索工作流
步骤命令做什么
0. 打开页面opencli browser open <url>导航到目标页面
1. 观察元素opencli browser state查看可交互元素
2. 首次抓包opencli browser network列出捕获的 JSON API
3. 模拟交互opencli browser click <N>点击按钮触发懒加载
4. 二次抓包opencli browser network找出新触发的 API
5. 查看响应opencli browser network --detail <N>查看完整响应体

Step 1: 发现 API

关注:URL pattern、Method、Request Headers、Response Body 路径

高阶捷径
  1. 后缀爆破法 (`.json`):Reddit、雪球等,URL 加 .json 直接拿 REST 数据
  2. 全局状态法 (`__INITIAL_STATE__`):SSR 站点首页数据挂载在 window 上
  3. 主动交互触发法:懒加载 API 需要点击按钮才触发
  4. 框架 Store 截断:Vue + Pinia 站点,Store Action 绕过签名
  5. XHR/Fetch 拦截:最后手段

Step 2: 选择认证策略

bash
opencli cascade https://api.example.com/hot # 自动探测
Tier策略速度实例
1public⚡ ~1sHacker News, V2EX
2cookie🔄 ~7sBilibili, Zhihu, Reddit
2.5localStorage Bearer🔄 ~7sSlock, Linear, Notion
3header🔄 ~7sTwitter GraphQL
4intercept🔄 ~10s小红书 (Pinia + XHR)
5ui🐌 ~15s+遗留网站

Step 3: 编写适配器

所有适配器统一使用 cli() API,放入 clis/<site>/<name>.js 即自动注册。

typescript
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'mysite',
name: 'mycommand',
description: '一句话描述',
domain: 'www.example.com',
strategy: Strategy.COOKIE,
browser: true,
args: [{ name: 'limit', type: 'int', default: 20 }],
columns: ['rank', 'title', 'value'],
func: async (page, kwargs) => {
await page.goto('https://www.example.com');
const data = await page.evaluate(`(async () => {
const res = await fetch('/api/items', { credentials: 'include' });
const d = await res.json();
return d.data?.items || [];
})()`);
return (data as any[]).slice(0, kwargs.limit).map((item, i) => ({
rank: i + 1,
title: item.title || '',
value: item.value || '',
}));
},
});

Step 4: 测试

bash
# Repo 贡献
npm run build
opencli list | grep mysite
opencli mysite mycommand --limit 3 -v
# 私人 adapter
opencli browser verify <site>/<name>

常见陷阱

陷阱解决方案
缺少 navigate在 evaluate 前加 page.goto()
缺少 strategy: public加 strategy: Strategy.PUBLIC + browser: false
风控被拦截(伪 200)断言数据,throw new AuthRequiredError(domain)
SPA 返回 HTML搜 JS bundle 找 baseURL
TS evaluate 格式必须用 IIFE:(async () => { ... })()

用 AI Agent 自动生成

bash
opencli generate https://www.example.com --goal "hot"
# 或分步:
opencli explore https://www.example.com --site mysite
opencli synthesize mysite
opencli verify mysite/hot --smoke

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/zxfccmm4/obsidian-opencode-knowledge/opencli-explorer/badge)](https://verified-skill.com/skills/zxfccmm4/obsidian-opencode-knowledge/opencli-explorer)

Something wrong with this skill or its page? Tell us.