SuperAPI AI Directory

opencli

Frontend & websites

View repository

Updated 10-15 22:15

About this skill

opencli

CLI tool that turns websites into CLI interfaces, reusing Chrome's login state. Zero credentials needed.

Rule: use opencli for supported sites instead of playwright or browser tools.

Runtime Rules

  • Prefer opencli for supported sites before Playwright/browser automation.
  • Prefer -f json when the result needs to be parsed or summarized.
  • Prefer positional args when the command supports them; do not invent --query / --id / --url flags unless opencli --help shows them.
  • For write operations, show the content to the user first and wait for confirmation.
  • If a command fails, inspect opencli <site> --help or opencli doctor before assuming the site is unsupported.

Preconditions

Browser commands require all of the following:

  • Chrome is running
  • The user is already logged into the target site in Chrome
  • The OpenCLI Browser Bridge extension is installed
  • opencli doctor passes, or at least reports a live browser bridge

Useful checks:

opencli --version
opencli doctor
opencli list -f yaml

Syntax

opencli <site> <command> [--option value] [-f json]

Common flags (all commands):

  • -f json — machine-readable output (preferred for parsing)
  • --limit N — number of results (default varies, usually 20)
  • -f table|json|yaml|md|csv

Quick Examples

# 读取/浏览
opencli bilibili hot --limit 10 -f json
opencli zhihu hot -f json
opencli weibo hot -f json
opencli twitter timeline -f json
opencli hackernews top --limit 20 -f json
opencli v2ex hot -f json
opencli reddit hot -f json
opencli xiaohongshu feed -f json

# 搜索
opencli bilibili search --keyword "AI" -f json
opencli zhihu search --keyword "大模型" -f json
opencli twitter search --query "claude AI" -f json
opencli youtube search --query "LLM tutorial" -f json
opencli boss search --query "AI工程师" --city "上海" -f json

# 互动(写操作)
opencli twitter post --text "Hello from CLI!"
opencli twitter reply --url "https://x.com/.../status/123" --text "Great post!"
opencli twitter like --url "https://x.com/.../status/123"

# 个人数据
opencli bilibili history -f json
opencli twitter bookmarks -f json
opencli xueqiu watchlist -f json

Output Formatting Rules

When displaying results to the user:

  1. Always show original title + Chinese translation + clickable link as separate columns
  2. Table format: # | 原标题 | 中文翻译 | 链接 | 关键指标...
  3. Original Title: plain text, no markdown link — do NOT use [title](url) format
  4. Chinese Translation: plain Chinese translation text
  5. Link: [🔗](url) — compact clickable icon
  6. Translate all English titles to Chinese — never show English-only output to the user

Example:

| # | 原标题 | 中文翻译 | 链接 | 分 | 评论 |
|---|--------|---------|------|-----|------|
| 1 | The 49MB web page | 那个 49MB 的网页 | [🔗](https://...) | 388 | 196 |

Fallback strategy: use Playwright when opencli does not support it

Core principle: never say "not supported"; try opencli first, and automatically switch to Playwright when it fails or there is no command.

Decision Flow

用户请求
  ↓
opencli 有对应命令?
  ├─ 是 → 执行 opencli
  └─ 否 → 直接用 Playwright MCP 打开对应页面完成任务
              ↓
           Playwright 报错 / 无法连接?
              └─ 引导用户安装桥接插件(见下方)

Common scenarios opencli does not support → Playwright alternatives

Scenario URL Playwright Operation
Zhihu Direct Messages https://www.zhihu.com/messages navigate → snapshot to read the list
Zhihu Notifications https://www.zhihu.com/notifications navigate → snapshot
Weibo Posting https://weibo.com navigate → click the input box → type → send
Xiaohongshu Direct Messages https://www.xiaohongshu.com/im navigate → snapshot
Bilibili Direct Messages https://message.bilibili.com navigate → snapshot
Twitter DM https://x.com/messages navigate → snapshot

Playwright Standard Operating Procedure

1. mcp__playwright__browser_navigate → 目标 URL
2. mcp__playwright__browser_snapshot → 读取页面结构
3. 根据需要:browser_click / browser_type / browser_scroll
4. 将结果整理后呈现给用户

⚠️ Write operation risk warning (must be communicated before posting/replying/liking)

  1. Account Security: automated behavior may trigger platform risk controls
  2. Irreversible: made public immediately after publishing
  3. Best Practice: show the user the content to be published before executing, and wait for confirmation

Guidance script when the plugin is not installed

If Playwright reports an error (connection failed / cannot control the browser), tell the user:

"You need to install the Playwright MCP Bridge plugin in Chrome to control the browser. Installation steps:

  1. Open Chrome and visit the Chrome Web Store
  2. Search for "Playwright MCP" or "MCP Bridge"
  3. Click "Add to Chrome"
  4. After installation, make sure Chrome is logged in to the target website
  5. Tell me your needs again, and I will help you complete them"

Requirements

  • Chrome browser open with target site logged in
  • OpenCLI Browser Bridge extension installed in Chrome
  • opencli doctor should be healthy before debugging adapter issues
  • Playwright MCP Bridge is only for fallback browser automation, not for normal opencli execution

Self-iteration capability: create a CLI for a new website

When opencli does not support a website, do not give up—create it yourself!

Before modifying or creating an adapter, first read:

  • /Users/huangzongning/development/opencli/CLI-EXPLORER.md
  • /Users/huangzongning/development/opencli/CLI-ONESHOT.md

Adapter Development Rules

  1. Prefer using a positional arg for the main parameter; do not make it --query / --id / --url
  2. For expected adapter failures, prefer throwing a structured error; do not directly expose the raw exception to the user
  3. When adding an adapter or adding a user-discoverable command, update the documentation and command reference at the same time
  4. After automatic generation fails, then proceed to the manual YAML/TS adapter process
  5. When debugging, first verify opencli doctor, then troubleshoot the selectors and request logic

Process

1. opencli <site> --help  →  报错?说明不支持
2. opencli generate <url>  →  尝试自动生成(成功则结束)
3. 自动生成失败 → 手动创建 YAML:
   a. 用 Playwright 打开目标页面
   b. browser_evaluate 探索 DOM 结构(找 data-test 属性、class 规律)
   c. 确认选择器后写入 ~/.opencli/clis/<site>/top.yaml
   d. opencli <site> top -f json  →  验证输出

YAML format (DOM scraping template)

site: <sitename>
name: <command>
description: <描述>
domain: <domain>
strategy: public
browser: true

args:
  limit:
    type: int
    default: 10

pipeline:
  - navigate: https://<url>
  - evaluate: |
      (async () => {
        const limit = ${{ args.limit }};
        // DOM 抓取逻辑
        return results;
      })()

columns: [rank, name, ...]

Created custom CLIs

Site Command File Key Selectors
producthunt top ~/.opencli/clis/producthunt/top.yaml button[data-test="vote-button"] → parent container → [data-test^="post-name-"],tagline: nameEl.parentElement.querySelector('span.mt-0\\.5')

Debugging Tips

  • browser_evaluate Explore the structure first:document.querySelector('...').innerHTML
  • Find data-test attributes are the most stable, followed by semantic words in the class
  • tagline is usually a sibling element of name (nameEl.parentElement.querySelector('span...'))
  • Use seen = new Set()for deduplication to prevent duplicate products
  • If you suspect it is a bridging issue on the opencli side, first run opencli doctor

Full Command Reference

See references/commands.md for all 55 commands with complete argument details.