@jackwener/opencli 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -49
- package/README.zh-CN.md +73 -60
- package/cli-manifest.json +3261 -1758
- package/clis/antigravity/serve.js +71 -25
- package/clis/baidu-scholar/search.js +87 -0
- package/clis/baidu-scholar/search.test.js +23 -0
- package/clis/deepseek/ask.js +74 -0
- package/clis/deepseek/history.js +25 -0
- package/clis/deepseek/new.js +20 -0
- package/clis/deepseek/read.js +22 -0
- package/clis/deepseek/status.js +24 -0
- package/clis/deepseek/utils.js +208 -0
- package/clis/eastmoney/_secid.js +78 -0
- package/clis/eastmoney/announcement.js +52 -0
- package/clis/eastmoney/convertible.js +73 -0
- package/clis/eastmoney/etf.js +65 -0
- package/clis/eastmoney/holders.js +78 -0
- package/clis/eastmoney/index-board.js +96 -0
- package/clis/eastmoney/kline.js +87 -0
- package/clis/eastmoney/kuaixun.js +54 -0
- package/clis/eastmoney/longhu.js +67 -0
- package/clis/eastmoney/money-flow.js +78 -0
- package/clis/eastmoney/northbound.js +57 -0
- package/clis/eastmoney/quote.js +107 -0
- package/clis/eastmoney/rank.js +94 -0
- package/clis/eastmoney/sectors.js +76 -0
- package/clis/google-scholar/search.js +58 -0
- package/clis/google-scholar/search.test.js +23 -0
- package/clis/gov-law/commands.test.js +39 -0
- package/clis/gov-law/recent.js +22 -0
- package/clis/gov-law/search.js +41 -0
- package/clis/gov-law/shared.js +51 -0
- package/clis/gov-policy/commands.test.js +27 -0
- package/clis/gov-policy/recent.js +47 -0
- package/clis/gov-policy/search.js +48 -0
- package/clis/nowcoder/companies.js +23 -0
- package/clis/nowcoder/creators.js +27 -0
- package/clis/nowcoder/detail.js +61 -0
- package/clis/nowcoder/experience.js +36 -0
- package/clis/nowcoder/hot.js +24 -0
- package/clis/nowcoder/jobs.js +21 -0
- package/clis/nowcoder/notifications.js +29 -0
- package/clis/nowcoder/papers.js +40 -0
- package/clis/nowcoder/practice.js +37 -0
- package/clis/nowcoder/recommend.js +30 -0
- package/clis/nowcoder/referral.js +39 -0
- package/clis/nowcoder/salary.js +40 -0
- package/clis/nowcoder/search.js +49 -0
- package/clis/nowcoder/suggest.js +33 -0
- package/clis/nowcoder/topics.js +27 -0
- package/clis/nowcoder/trending.js +25 -0
- package/clis/twitter/list-add.js +337 -0
- package/clis/twitter/list-add.test.js +15 -0
- package/clis/twitter/list-remove.js +297 -0
- package/clis/twitter/list-remove.test.js +14 -0
- package/clis/twitter/list-tweets.js +185 -0
- package/clis/twitter/list-tweets.test.js +108 -0
- package/clis/twitter/lists.js +134 -47
- package/clis/twitter/lists.test.js +105 -38
- package/clis/wanfang/search.js +66 -0
- package/clis/wanfang/search.test.js +23 -0
- package/clis/web/read.js +1 -1
- package/clis/weixin/download.js +3 -2
- package/clis/xiaohongshu/publish.js +149 -28
- package/clis/xiaohongshu/publish.test.js +319 -6
- package/clis/xiaoyuzhou/download.js +8 -4
- package/clis/xiaoyuzhou/download.test.js +23 -13
- package/clis/xiaoyuzhou/episode.js +9 -4
- package/clis/xiaoyuzhou/podcast-episodes.js +15 -11
- package/clis/xiaoyuzhou/podcast.js +9 -4
- package/clis/xiaoyuzhou/utils.js +0 -40
- package/clis/xiaoyuzhou/utils.test.js +15 -75
- package/clis/zsxq/dynamics.js +1 -1
- package/clis/zsxq/utils.js +6 -3
- package/clis/zsxq/utils.test.js +31 -0
- package/dist/src/browser/base-page.d.ts +1 -1
- package/dist/src/browser/bridge.d.ts +1 -0
- package/dist/src/browser/bridge.js +1 -1
- package/dist/src/browser/cdp.js +1 -1
- package/dist/src/browser/daemon-client.d.ts +6 -4
- package/dist/src/browser/daemon-client.js +6 -1
- package/dist/src/browser/daemon-client.test.js +40 -1
- package/dist/src/browser/dom-snapshot.js +7 -2
- package/dist/src/browser/page.d.ts +14 -4
- package/dist/src/browser/page.js +48 -7
- package/dist/src/browser/page.test.js +97 -0
- package/dist/src/cli.js +227 -150
- package/dist/src/cli.test.js +167 -90
- package/dist/src/commanderAdapter.d.ts +0 -1
- package/dist/src/commanderAdapter.js +2 -16
- package/dist/src/commanderAdapter.test.js +1 -1
- package/dist/src/completion-shared.js +2 -5
- package/dist/src/daemon.js +8 -0
- package/dist/src/download/article-download.d.ts +1 -0
- package/dist/src/download/article-download.js +3 -0
- package/dist/src/download/article-download.test.js +39 -0
- package/dist/src/plugin.d.ts +1 -8
- package/dist/src/plugin.js +1 -27
- package/dist/src/plugin.test.js +1 -59
- package/dist/src/registry.d.ts +1 -0
- package/dist/src/registry.js +3 -2
- package/dist/src/registry.test.js +22 -0
- package/dist/src/types.d.ts +14 -5
- package/package.json +1 -1
- package/clis/twitter/lists-parser.js +0 -77
- package/clis/twitter/lists.d.ts +0 -5
- package/dist/src/cascade.d.ts +0 -46
- package/dist/src/cascade.js +0 -135
- package/dist/src/explore.d.ts +0 -99
- package/dist/src/explore.js +0 -402
- package/dist/src/generate-verified.d.ts +0 -105
- package/dist/src/generate-verified.js +0 -696
- package/dist/src/generate-verified.test.js +0 -925
- package/dist/src/generate.d.ts +0 -46
- package/dist/src/generate.js +0 -117
- package/dist/src/record.d.ts +0 -96
- package/dist/src/record.js +0 -657
- package/dist/src/record.test.d.ts +0 -1
- package/dist/src/record.test.js +0 -293
- package/dist/src/skill-generate.d.ts +0 -30
- package/dist/src/skill-generate.js +0 -75
- package/dist/src/skill-generate.test.d.ts +0 -1
- package/dist/src/skill-generate.test.js +0 -173
- package/dist/src/synthesize.d.ts +0 -97
- package/dist/src/synthesize.js +0 -208
- /package/dist/src/{generate-verified.test.d.ts → download/article-download.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
OpenCLI gives you one surface for three different kinds of automation:
|
|
12
12
|
|
|
13
13
|
- **Use built-in adapters** for sites like Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, Twitter/X, and [many more](#built-in-commands).
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
14
|
+
- **Let AI Agents operate any website** — install the `opencli-adapter-author` skill in your AI agent (Claude Code, Cursor, etc.), and it can navigate, click, type, extract, and inspect any page through your logged-in browser via `opencli browser` primitives.
|
|
15
|
+
- **Write new adapters** end-to-end with `opencli browser` + the `opencli-adapter-author` skill, which guides from first recon through field decoding, code, and `opencli browser verify`.
|
|
16
16
|
|
|
17
17
|
It also works as a **CLI hub** for local tools such as `gh`, `docker`, and other binaries you register yourself, plus **desktop app adapters** for Electron apps like Cursor, Codex, Antigravity, ChatGPT, and Notion.
|
|
18
18
|
|
|
19
19
|
## Highlights
|
|
20
20
|
|
|
21
21
|
- **Desktop App Control** — Drive Electron apps (Cursor, Codex, ChatGPT, Notion, etc.) directly from the terminal via CDP.
|
|
22
|
-
- **Browser Automation** — `
|
|
23
|
-
- **Website → CLI** — Turn any website into a deterministic CLI:
|
|
22
|
+
- **Browser Automation for AI Agents** — Install the `opencli-adapter-author` skill, and your AI agent can operate any website: navigate, click, type, extract, screenshot — all through your logged-in Chrome session.
|
|
23
|
+
- **Website → CLI** — Turn any website into a deterministic CLI: 90+ pre-built adapters, or write your own with the `opencli-adapter-author` skill + `opencli browser verify`.
|
|
24
24
|
- **Account-safe** — Reuses Chrome/Chromium logged-in state; your credentials never leave the browser.
|
|
25
|
-
- **AI Agent ready** —
|
|
25
|
+
- **AI Agent ready** — One skill takes you from site recon through API discovery, field decoding, adapter writing, and verification.
|
|
26
26
|
- **CLI Hub** — Discover, auto-install, and passthrough commands to any external CLI (gh, docker, obsidian, etc).
|
|
27
27
|
- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times and pay nothing.
|
|
28
28
|
- **Deterministic** — Same command, same output schema, every time. Pipeable, scriptable, CI-friendly.
|
|
@@ -70,12 +70,9 @@ Use OpenCLI directly when you want a reliable command instead of a live browser
|
|
|
70
70
|
|
|
71
71
|
## For AI Agents
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
OpenCLI's browser commands are designed to be used by AI Agents — not run manually. Install skills into your AI agent (Claude Code, Cursor, etc.), and the agent operates websites on your behalf using your logged-in Chrome session.
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
- [`skills/opencli-browser/SKILL.md`](./skills/opencli-browser/SKILL.md): the low-level control surface for live browsing, debugging, and manual intervention.
|
|
77
|
-
|
|
78
|
-
Install the packaged skills with:
|
|
75
|
+
### Install skills
|
|
79
76
|
|
|
80
77
|
```bash
|
|
81
78
|
npx skills add jackwener/opencli
|
|
@@ -84,40 +81,62 @@ npx skills add jackwener/opencli
|
|
|
84
81
|
Or install only what you need:
|
|
85
82
|
|
|
86
83
|
```bash
|
|
87
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
88
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
89
|
-
npx skills add jackwener/opencli --skill
|
|
90
|
-
npx skills add jackwener/opencli --skill opencli-oneshot
|
|
84
|
+
npx skills add jackwener/opencli --skill opencli-adapter-author
|
|
85
|
+
npx skills add jackwener/opencli --skill opencli-autofix
|
|
86
|
+
npx skills add jackwener/opencli --skill smart-search
|
|
91
87
|
```
|
|
92
88
|
|
|
93
|
-
|
|
89
|
+
### Which skill to use
|
|
94
90
|
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
| Skill | When to use | Example prompt to your AI agent |
|
|
92
|
+
|-------|------------|-------------------------------|
|
|
93
|
+
| **opencli-adapter-author** | Operate a site in real time, or write a reusable adapter for a new site | "Help me check my Xiaohongshu notifications" / "Write an adapter for douyin trending" / "Make a command that grabs the top posts from this page" |
|
|
94
|
+
| **opencli-autofix** | Repair a broken adapter when a built-in command fails | "`opencli zhihu hot` is returning empty — fix it" |
|
|
95
|
+
| **smart-search** | Search across existing OpenCLI capabilities | "Find me a Bilibili trending adapter" |
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
### How it works
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
Once `opencli-adapter-author` is installed, your AI agent can:
|
|
101
100
|
|
|
102
|
-
|
|
101
|
+
1. **Navigate** to any URL using your logged-in browser
|
|
102
|
+
2. **Read** page content via structured DOM snapshots (not screenshots)
|
|
103
|
+
3. **Interact** — click buttons, fill forms, select options, press keys
|
|
104
|
+
4. **Extract** data from the page or intercept network API responses
|
|
105
|
+
5. **Wait** for elements, text, or page transitions
|
|
103
106
|
|
|
104
|
-
|
|
107
|
+
The agent handles all the `opencli browser` commands internally — you just describe what you want done in natural language.
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
**Skill references:**
|
|
110
|
+
- [`skills/opencli-adapter-author/SKILL.md`](./skills/opencli-adapter-author/SKILL.md) — browser operation + adapter authoring, end-to-end
|
|
111
|
+
- [`skills/opencli-autofix/SKILL.md`](./skills/opencli-autofix/SKILL.md) — repair broken adapters
|
|
112
|
+
- [`skills/smart-search/SKILL.md`](./skills/smart-search/SKILL.md) — capability search
|
|
113
|
+
|
|
114
|
+
Available browser commands include `open`, `state`, `click`, `type`, `select`, `keys`, `wait`, `get`, `screenshot`, `scroll`, `back`, `eval`, `network`, `tab list`, `tab new`, `tab select`, `tab close`, `init`, `verify`, and `close`.
|
|
115
|
+
|
|
116
|
+
`opencli browser open <url>` and `opencli browser tab new [url]` both return a target ID. Use `opencli browser tab list` to inspect the target IDs of tabs that already exist, then pass `--tab <targetId>` to route a command to a specific tab. `tab new` creates a new tab without changing the default browser target; only `tab select <targetId>` promotes that tab to the default target for later untargeted `opencli browser ...` commands.
|
|
117
|
+
|
|
118
|
+
## Core Concepts
|
|
119
|
+
|
|
120
|
+
### `browser`: AI Agent browser control
|
|
121
|
+
|
|
122
|
+
`opencli browser` commands are the low-level primitives that AI Agents use to operate websites. You don't run these manually — instead, install the `opencli-adapter-author` skill into your AI agent, describe what you want in natural language, and the agent handles the browser operations.
|
|
107
123
|
|
|
108
|
-
|
|
124
|
+
For example, tell your agent: *"Help me check my Xiaohongshu notifications"* — the agent will use `opencli browser open`, `state`, `click`, etc. under the hood.
|
|
109
125
|
|
|
110
|
-
###
|
|
126
|
+
### Built-in adapters: stable commands
|
|
111
127
|
|
|
112
|
-
Use
|
|
128
|
+
Use site-specific commands such as `opencli hackernews top` or `opencli reddit hot` when the capability already exists. These are deterministic and work without browser — ideal for both humans and AI agents.
|
|
113
129
|
|
|
114
|
-
|
|
115
|
-
- `synthesize` turns exploration artifacts into evaluate-based JS adapters.
|
|
116
|
-
- `generate` runs the verified generation path and returns either a usable command or a structured explanation of why completion was blocked or needs human review.
|
|
130
|
+
### Writing a new adapter
|
|
117
131
|
|
|
118
|
-
|
|
132
|
+
When the site you need is not yet covered, use the `opencli-adapter-author` skill. It takes the agent end-to-end:
|
|
119
133
|
|
|
120
|
-
|
|
134
|
+
1. Recon the site and classify its pattern (SPA / SSR / JSONP / Token / Streaming).
|
|
135
|
+
2. Discover the right endpoint — network inspection, initial state, bundle search, token trace, or interceptor fallback.
|
|
136
|
+
3. Decide the auth strategy — `PUBLIC` / `COOKIE` / `HEADER` / `INTERCEPT`.
|
|
137
|
+
4. Decode response fields and design output columns.
|
|
138
|
+
5. `opencli browser init <site>/<name>` → write adapter → `opencli browser verify <site>/<name>`.
|
|
139
|
+
6. Persist site knowledge to `~/.opencli/sites/<site>/` so the next adapter for the same site is faster.
|
|
121
140
|
|
|
122
141
|
### CLI Hub and desktop adapters
|
|
123
142
|
|
|
@@ -141,7 +160,6 @@ OpenCLI is not only for websites. It can also:
|
|
|
141
160
|
| `OPENCLI_WINDOW_FOCUSED` | `false` | Set to `1` to open automation windows in the foreground (useful for debugging) |
|
|
142
161
|
| `OPENCLI_BROWSER_CONNECT_TIMEOUT` | `30` | Seconds to wait for browser connection |
|
|
143
162
|
| `OPENCLI_BROWSER_COMMAND_TIMEOUT` | `60` | Seconds to wait for a single browser command |
|
|
144
|
-
| `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | `120` | Seconds to wait for explore/record operations |
|
|
145
163
|
| `OPENCLI_CDP_ENDPOINT` | — | Chrome DevTools Protocol endpoint for remote browser or Electron apps |
|
|
146
164
|
| `OPENCLI_CDP_TARGET` | — | Filter CDP targets by URL substring (e.g. `detail.1688.com`) |
|
|
147
165
|
| `OPENCLI_VERBOSE` | `false` | Enable verbose logging (`-v` flag also works) |
|
|
@@ -160,10 +178,9 @@ npx skills add jackwener/opencli
|
|
|
160
178
|
Or refresh only the skills you actually use:
|
|
161
179
|
|
|
162
180
|
```bash
|
|
163
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
164
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
165
|
-
npx skills add jackwener/opencli --skill
|
|
166
|
-
npx skills add jackwener/opencli --skill opencli-oneshot
|
|
181
|
+
npx skills add jackwener/opencli --skill opencli-adapter-author
|
|
182
|
+
npx skills add jackwener/opencli --skill opencli-autofix
|
|
183
|
+
npx skills add jackwener/opencli --skill smart-search
|
|
167
184
|
```
|
|
168
185
|
|
|
169
186
|
## For Developers
|
|
@@ -191,7 +208,7 @@ To load the source Browser Bridge extension:
|
|
|
191
208
|
| **bilibili** | `hot` `search` `history` `feed` `ranking` `download` `comments` `dynamic` `favorite` `following` `me` `subtitle` `user-videos` |
|
|
192
209
|
| **tieba** | `hot` `posts` `search` `read` |
|
|
193
210
|
| **hupu** | `hot` `search` `detail` `mentions` `reply` `like` `unlike` |
|
|
194
|
-
| **twitter** | `trending` `search` `timeline` `lists` `bookmarks` `post` `download` `profile` `article` `like` `likes` `notifications` `reply` `reply-dm` `thread` `follow` `unfollow` `followers` `following` `block` `unblock` `bookmark` `unbookmark` `delete` `hide-reply` `accept` |
|
|
211
|
+
| **twitter** | `trending` `search` `timeline` `lists` `list-tweets` `list-add` `list-remove` `bookmarks` `post` `download` `profile` `article` `like` `likes` `notifications` `reply` `reply-dm` `thread` `follow` `unfollow` `followers` `following` `block` `unblock` `bookmark` `unbookmark` `delete` `hide-reply` `accept` |
|
|
195
212
|
| **reddit** | `hot` `frontpage` `popular` `search` `subreddit` `read` `user` `user-posts` `user-comments` `upvote` `upvoted` `save` `saved` `comment` `subscribe` |
|
|
196
213
|
| **zhihu** | `hot` `search` `question` `download` `follow` `like` `favorite` `comment` `answer` |
|
|
197
214
|
| **amazon** | `bestsellers` `search` `product` `offer` `discussion` `movers-shakers` `new-releases` |
|
|
@@ -205,11 +222,17 @@ To load the source Browser Bridge extension:
|
|
|
205
222
|
| **xiaoe** | `courses` `detail` `catalog` `play-url` `content` |
|
|
206
223
|
| **quark** | `ls` `mkdir` `mv` `rename` `rm` `save` `share-tree` |
|
|
207
224
|
| **uiverse** | `code` `preview` |
|
|
208
|
-
| **
|
|
225
|
+
| **baidu-scholar** | `search` |
|
|
226
|
+
| **google-scholar** | `search` |
|
|
227
|
+
| **gov-law** | `search` `recent` |
|
|
228
|
+
| **gov-policy** | `search` `recent` |
|
|
229
|
+
| **nowcoder** | `hot` `trending` `topics` `recommend` `creators` `companies` `jobs` `search` `suggest` `experience` `referral` `salary` `papers` `practice` `notifications` `detail` |
|
|
230
|
+
| **wanfang** | `search` |
|
|
231
|
+
| **xiaoyuzhou** | `podcast*` `podcast-episodes*` `episode*` `download*` `transcript*` |
|
|
209
232
|
|
|
210
|
-
|
|
233
|
+
90+ adapters in total — **[→ see all supported sites & commands](./docs/adapters/index.md)**
|
|
211
234
|
|
|
212
|
-
`*` `opencli xiaoyuzhou transcript`
|
|
235
|
+
`*` `opencli xiaoyuzhou podcast`, `podcast-episodes`, `episode`, `download`, and `transcript` require local Xiaoyuzhou credentials in `~/.opencli/xiaoyuzhou.json`.
|
|
213
236
|
|
|
214
237
|
## CLI Hub
|
|
215
238
|
|
|
@@ -260,7 +283,7 @@ OpenCLI supports downloading images, videos, and articles from supported platfor
|
|
|
260
283
|
| **douban** | Images | Poster / still image lists |
|
|
261
284
|
| **pixiv** | Images | Original-quality illustrations, multi-page |
|
|
262
285
|
| **1688** | Images, Videos | Downloads page-visible product media from item pages |
|
|
263
|
-
| **xiaoyuzhou** | Audio, Transcript | Downloads episode audio
|
|
286
|
+
| **xiaoyuzhou** | Audio, Transcript | Downloads episode audio and transcript JSON/text with local credentials |
|
|
264
287
|
| **zhihu** | Articles (Markdown) | Exports with optional image download |
|
|
265
288
|
| **weixin** | Articles (Markdown) | WeChat Official Account articles |
|
|
266
289
|
|
|
@@ -276,7 +299,7 @@ opencli xiaoyuzhou download 69b3b675772ac2295bfc01d0 --output ./xiaoyuzhou
|
|
|
276
299
|
opencli xiaoyuzhou transcript 69dd0c98e2c8be31551f6a33 --output ./xiaoyuzhou-transcripts
|
|
277
300
|
```
|
|
278
301
|
|
|
279
|
-
`opencli xiaoyuzhou transcript`
|
|
302
|
+
`opencli xiaoyuzhou download` and `transcript` require local Xiaoyuzhou credentials in `~/.opencli/xiaoyuzhou.json`.
|
|
280
303
|
|
|
281
304
|
## Output Formats
|
|
282
305
|
|
|
@@ -332,16 +355,15 @@ See [Plugins Guide](./docs/guide/plugins.md) for creating your own plugin.
|
|
|
332
355
|
|
|
333
356
|
## For AI Agents (Developer Guide)
|
|
334
357
|
|
|
335
|
-
|
|
358
|
+
Before writing any adapter code, read the [`opencli-adapter-author` skill](./skills/opencli-adapter-author/SKILL.md). It takes you end-to-end:
|
|
336
359
|
|
|
337
|
-
|
|
360
|
+
- Recon the site and pick a pattern (SPA / SSR / JSONP / Token / Streaming).
|
|
361
|
+
- Discover the right endpoint via `opencli browser network`, `eval`, or the interceptor fallback.
|
|
362
|
+
- Decide auth strategy (`PUBLIC` / `COOKIE` / `HEADER` / `INTERCEPT`).
|
|
363
|
+
- Decode response fields, design columns, scaffold with `opencli browser init`.
|
|
364
|
+
- Verify with `opencli browser verify <site>/<name>` before shipping.
|
|
338
365
|
|
|
339
|
-
|
|
340
|
-
opencli explore https://example.com --site mysite # Discover APIs + capabilities
|
|
341
|
-
opencli synthesize mysite # Generate JS adapters
|
|
342
|
-
opencli generate https://example.com --goal "hot" # One-shot: explore → synthesize → register
|
|
343
|
-
opencli cascade https://api.example.com/data # Auto-probe: PUBLIC → COOKIE → HEADER
|
|
344
|
-
```
|
|
366
|
+
Adapters you write outside the repo live at `~/.opencli/clis/<site>/<name>.js`. Site knowledge (endpoints, field maps, fixtures) accumulates in `~/.opencli/sites/<site>/` so the next adapter for the same site starts from context instead of zero.
|
|
345
367
|
|
|
346
368
|
## Testing
|
|
347
369
|
|
package/README.zh-CN.md
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
OpenCLI 可以用同一套 CLI 做三类事情:
|
|
12
12
|
|
|
13
|
-
- **直接使用现成适配器**:B站、知乎、小红书、Twitter/X、Reddit、HackerNews 等 [
|
|
14
|
-
-
|
|
15
|
-
-
|
|
13
|
+
- **直接使用现成适配器**:B站、知乎、小红书、Twitter/X、Reddit、HackerNews 等 [90+ 站点](#内置命令) 开箱即用。
|
|
14
|
+
- **让 AI Agent 操作任意网站**:在你的 AI Agent(Claude Code、Cursor 等)中安装 `opencli-adapter-author` skill,Agent 就能用你的已登录浏览器导航、点击、输入、提取任意网页内容。
|
|
15
|
+
- **把新网站写成 CLI**:用 `opencli browser` 原语 + `opencli-adapter-author` skill,从站点侦察、API 发现、字段解码到 `opencli browser verify` 一条龙。
|
|
16
16
|
|
|
17
17
|
除了网站能力,OpenCLI 还是一个 **CLI 枢纽**:你可以把 `gh`、`docker` 等本地工具统一注册到 `opencli` 下,也可以通过桌面端适配器控制 Cursor、Codex、Antigravity、ChatGPT、Notion 等 Electron 应用。
|
|
18
18
|
|
|
19
19
|
## 亮点
|
|
20
20
|
|
|
21
21
|
- **桌面应用控制** — 通过 CDP 直接在终端驱动 Electron 应用(Cursor、Codex、ChatGPT、Notion 等)。
|
|
22
|
-
-
|
|
23
|
-
- **网站 → CLI** — 把任何网站变成确定性 CLI:
|
|
22
|
+
- **AI Agent 浏览器自动化** — 安装 `opencli-adapter-author` skill,你的 AI Agent 就能操作任意网站:导航、点击、输入、提取、截图——全部通过你的已登录 Chrome 会话完成。
|
|
23
|
+
- **网站 → CLI** — 把任何网站变成确定性 CLI:90+ 内置适配器,或用 `opencli-adapter-author` skill + `opencli browser verify` 自己写。
|
|
24
24
|
- **账号安全** — 复用 Chrome/Chromium 登录态,凭证永远不会离开浏览器。
|
|
25
|
-
- **面向 AI Agent** —
|
|
25
|
+
- **面向 AI Agent** — 一个 skill 带你走完站点侦察、API 发现、字段解码、适配器编写、验证的全流程。
|
|
26
26
|
- **CLI 枢纽** — 统一发现、自动安装、纯透传任何外部 CLI(gh、docker、obsidian 等)。
|
|
27
27
|
- **零 LLM 成本** — 运行时不消耗模型 token,跑 10,000 次也不花一分钱。
|
|
28
28
|
- **确定性输出** — 相同命令,相同输出结构,每次一致。可管道、可脚本、CI 友好。
|
|
@@ -68,12 +68,9 @@ opencli bilibili hot --limit 5
|
|
|
68
68
|
|
|
69
69
|
## 给 AI Agent
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
OpenCLI 的 browser 命令是给 AI Agent 用的——不是手动执行的。把 skill 安装到你的 AI Agent(Claude Code、Cursor 等)中,Agent 就能用你的已登录 Chrome 会话替你操作网站。
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
- [`skills/opencli-browser/SKILL.md`](./skills/opencli-browser/SKILL.md):底层控制入口,适合实时操作页面、debug 和人工介入。
|
|
75
|
-
|
|
76
|
-
安装全部 OpenCLI skills:
|
|
73
|
+
### 安装 skill
|
|
77
74
|
|
|
78
75
|
```bash
|
|
79
76
|
npx skills add jackwener/opencli
|
|
@@ -82,40 +79,62 @@ npx skills add jackwener/opencli
|
|
|
82
79
|
或只装需要的 skill:
|
|
83
80
|
|
|
84
81
|
```bash
|
|
85
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
86
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
87
|
-
npx skills add jackwener/opencli --skill
|
|
88
|
-
npx skills add jackwener/opencli --skill opencli-oneshot
|
|
82
|
+
npx skills add jackwener/opencli --skill opencli-adapter-author
|
|
83
|
+
npx skills add jackwener/opencli --skill opencli-autofix
|
|
84
|
+
npx skills add jackwener/opencli --skill smart-search
|
|
89
85
|
```
|
|
90
86
|
|
|
91
|
-
|
|
87
|
+
### 选择哪个 skill
|
|
92
88
|
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
| Skill | 适用场景 | 你对 AI Agent 说的话 |
|
|
90
|
+
|-------|---------|-------------------|
|
|
91
|
+
| **opencli-adapter-author** | 实时操作任意网站,或为新站点写可复用适配器 | "帮我看看小红书的通知" / "帮我做一个抖音热门的适配器" / "帮我做一个抓取这个页面热帖的命令" |
|
|
92
|
+
| **opencli-autofix** | 内置命令失败时修复已有适配器 | "`opencli zhihu hot` 返回空了,修一下" |
|
|
93
|
+
| **smart-search** | 在现有 OpenCLI 能力里搜索 | "帮我找个 B 站热门相关的适配器" |
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
### 工作原理
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
安装 `opencli-adapter-author` skill 后,你的 AI Agent 可以:
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
1. **导航**到任意 URL,使用你的已登录浏览器
|
|
100
|
+
2. **读取**页面内容——通过结构化 DOM 快照(不是截图)
|
|
101
|
+
3. **交互**——点击按钮、填写表单、选择选项、按键
|
|
102
|
+
4. **提取**页面数据或拦截网络 API 响应
|
|
103
|
+
5. **等待**元素、文本或页面跳转
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
Agent 在内部自动处理所有 `opencli browser` 命令——你只需用自然语言描述想做的事。
|
|
103
106
|
|
|
104
|
-
|
|
107
|
+
**Skill 参考文档:**
|
|
108
|
+
- [`skills/opencli-adapter-author/SKILL.md`](./skills/opencli-adapter-author/SKILL.md) — 浏览器操作 + 适配器编写,全流程
|
|
109
|
+
- [`skills/opencli-autofix/SKILL.md`](./skills/opencli-autofix/SKILL.md) — 修复已有适配器
|
|
110
|
+
- [`skills/smart-search/SKILL.md`](./skills/smart-search/SKILL.md) — 能力搜索
|
|
111
|
+
|
|
112
|
+
`browser` 可用命令包括:`open`、`state`、`click`、`type`、`select`、`keys`、`wait`、`get`、`screenshot`、`scroll`、`back`、`eval`、`network`、`tab list`、`tab new`、`tab select`、`tab close`、`init`、`verify`、`close`。
|
|
113
|
+
|
|
114
|
+
`opencli browser open <url>` 和 `opencli browser tab new [url]` 都会返回 target ID。`opencli browser tab list` 用来查看当前已存在 tab 的 target ID,再通过 `--tab <targetId>` 把命令明确路由到某个 tab。`tab new` 只会新建 tab,不会改变默认浏览器目标;只有显式执行 `tab select <targetId>`,才会把该 tab 设为后续未指定 target 的 `opencli browser ...` 命令的默认目标。
|
|
115
|
+
|
|
116
|
+
## 核心概念
|
|
117
|
+
|
|
118
|
+
### `browser`:AI Agent 的浏览器控制层
|
|
105
119
|
|
|
106
|
-
|
|
120
|
+
`opencli browser` 命令是 AI Agent 操作网站的底层原语。你不需要手动运行这些命令——把 `opencli-adapter-author` skill 安装到你的 AI Agent 中,用自然语言描述你想做的事,Agent 会自动处理浏览器操作。
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
比如你告诉 Agent:*"帮我看看小红书的通知"*——Agent 会在底层调用 `opencli browser open`、`state`、`click` 等命令。
|
|
109
123
|
|
|
110
|
-
|
|
124
|
+
### 内置适配器:稳定命令
|
|
125
|
+
|
|
126
|
+
当某个站点能力已经存在时,优先使用 `opencli hackernews top`、`opencli reddit hot` 这类稳定命令。这些命令是确定性的,无需浏览器——人类和 AI Agent 都可以直接使用。
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
- `synthesize` 负责把探索结果转成 evaluate-based YAML 适配器
|
|
114
|
-
- `generate` 负责跑通 verified generation 主链路,最后要么给出可直接使用的命令,要么返回结构化的阻塞原因 / 人工介入结果
|
|
128
|
+
### 为新站点写适配器
|
|
115
129
|
|
|
116
|
-
|
|
130
|
+
当你需要的网站还没覆盖时,用 `opencli-adapter-author` skill,它会把 Agent 带到闭环:
|
|
117
131
|
|
|
118
|
-
|
|
132
|
+
1. 侦察站点,分类 pattern(SPA / SSR / JSONP / Token / Streaming)
|
|
133
|
+
2. 发现目标 endpoint——network 精读、initial state、bundle 搜索、token 溯源,或 interceptor 兜底
|
|
134
|
+
3. 定认证策略——`PUBLIC` / `COOKIE` / `HEADER` / `INTERCEPT`
|
|
135
|
+
4. 字段解码 + 设计输出列
|
|
136
|
+
5. `opencli browser init <site>/<name>` → 写适配器 → `opencli browser verify <site>/<name>`
|
|
137
|
+
6. 把站点知识沉到 `~/.opencli/sites/<site>/`,下次写同站点的其他命令直接吃缓存
|
|
119
138
|
|
|
120
139
|
### CLI 枢纽与桌面端适配器
|
|
121
140
|
|
|
@@ -139,7 +158,6 @@ OpenCLI 不只是网站 CLI,还可以:
|
|
|
139
158
|
| `OPENCLI_WINDOW_FOCUSED` | `false` | 设为 `1` 时 automation 窗口在前台打开(适合调试) |
|
|
140
159
|
| `OPENCLI_BROWSER_CONNECT_TIMEOUT` | `30` | 浏览器连接超时(秒) |
|
|
141
160
|
| `OPENCLI_BROWSER_COMMAND_TIMEOUT` | `60` | 单个浏览器命令超时(秒) |
|
|
142
|
-
| `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | `120` | explore/record 操作超时(秒) |
|
|
143
161
|
| `OPENCLI_CDP_ENDPOINT` | — | Chrome DevTools Protocol 端点,用于远程浏览器或 Electron 应用 |
|
|
144
162
|
| `OPENCLI_CDP_TARGET` | — | 按 URL 子串过滤 CDP target(如 `detail.1688.com`) |
|
|
145
163
|
| `OPENCLI_VERBOSE` | `false` | 启用详细日志(`-v` 也可以) |
|
|
@@ -158,10 +176,9 @@ npx skills add jackwener/opencli
|
|
|
158
176
|
如果你只装了部分 skill,也可以只刷新自己在用的:
|
|
159
177
|
|
|
160
178
|
```bash
|
|
161
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
162
|
-
npx skills add jackwener/opencli --skill opencli-
|
|
163
|
-
npx skills add jackwener/opencli --skill
|
|
164
|
-
npx skills add jackwener/opencli --skill opencli-oneshot
|
|
179
|
+
npx skills add jackwener/opencli --skill opencli-adapter-author
|
|
180
|
+
npx skills add jackwener/opencli --skill opencli-autofix
|
|
181
|
+
npx skills add jackwener/opencli --skill smart-search
|
|
165
182
|
```
|
|
166
183
|
|
|
167
184
|
## 面向开发者
|
|
@@ -187,7 +204,7 @@ npm link
|
|
|
187
204
|
|
|
188
205
|
| 站点 | 命令 | 模式 |
|
|
189
206
|
|------|------|------|
|
|
190
|
-
| **twitter** | `trending` `search` `timeline` `lists` `bookmarks` `profile` `thread` `following` `followers` `notifications` `post` `reply` `delete` `like` `likes` `article` `follow` `unfollow` `bookmark` `unbookmark` `download` `accept` `reply-dm` `block` `unblock` `hide-reply` | 浏览器 |
|
|
207
|
+
| **twitter** | `trending` `search` `timeline` `lists` `list-tweets` `list-add` `list-remove` `bookmarks` `profile` `thread` `following` `followers` `notifications` `post` `reply` `delete` `like` `likes` `article` `follow` `unfollow` `bookmark` `unbookmark` `download` `accept` `reply-dm` `block` `unblock` `hide-reply` | 浏览器 |
|
|
191
208
|
| **reddit** | `hot` `frontpage` `popular` `search` `subreddit` `read` `user` `user-posts` `user-comments` `upvote` `save` `comment` `subscribe` `saved` `upvoted` | 浏览器 |
|
|
192
209
|
| **tieba** | `hot` `posts` `search` `read` | 浏览器 |
|
|
193
210
|
| **hupu** | `hot` `search` `detail` `mentions` `reply` `like` `unlike` | 浏览器 |
|
|
@@ -201,14 +218,20 @@ npm link
|
|
|
201
218
|
| **discord-app** | `status` `send` `read` `channels` `servers` `search` `members` | 桌面端 |
|
|
202
219
|
| **v2ex** | `hot` `latest` `topic` `node` `user` `member` `replies` `nodes` `daily` `me` `notifications` | 公开 / 浏览器 |
|
|
203
220
|
| **xueqiu** | `feed` `hot-stock` `hot` `search` `stock` `comments` `watchlist` `earnings-date` `fund-holdings` `fund-snapshot` | 浏览器 |
|
|
204
|
-
| **antigravity** | `status` `send` `read` `new` `dump` `extract-code` `model` `watch` | 桌面端 |
|
|
221
|
+
| **antigravity** | `status` `send` `read` `new` `dump` `extract-code` `model` `watch` `serve` | 桌面端 |
|
|
205
222
|
| **chatgpt-app** | `status` `new` `send` `read` `ask` `model` | 桌面端 |
|
|
206
223
|
| **xiaohongshu** | `search` `notifications` `feed` `user` `download` `publish` `creator-notes` `creator-note-detail` `creator-notes-summary` `creator-profile` `creator-stats` | 浏览器 |
|
|
207
224
|
| **xiaoe** | `courses` `detail` `catalog` `play-url` `content` | 浏览器 |
|
|
208
225
|
| **quark** | `ls` `mkdir` `mv` `rename` `rm` `save` `share-tree` | 浏览器 |
|
|
209
226
|
| **uiverse** | `code` `preview` | 浏览器 |
|
|
210
227
|
| **apple-podcasts** | `search` `episodes` `top` | 公开 |
|
|
211
|
-
| **
|
|
228
|
+
| **baidu-scholar** | `search` | 公开 |
|
|
229
|
+
| **google-scholar** | `search` | 公开 |
|
|
230
|
+
| **gov-law** | `search` `recent` | 公开 |
|
|
231
|
+
| **gov-policy** | `search` `recent` | 公开 |
|
|
232
|
+
| **nowcoder** | `hot` `trending` `topics` `recommend` `creators` `companies` `jobs` `search` `suggest` `experience` `referral` `salary` `papers` `practice` `notifications` `detail` | 公开 / 浏览器 |
|
|
233
|
+
| **wanfang** | `search` | 公开 |
|
|
234
|
+
| **xiaoyuzhou** | `podcast*` `podcast-episodes*` `episode*` `download*` `transcript*` | 本地凭证 |
|
|
212
235
|
| **zhihu** | `hot` `search` `question` `download` `follow` `like` `favorite` `comment` `answer` | 浏览器 |
|
|
213
236
|
| **weixin** | `download` | 浏览器 |
|
|
214
237
|
| **youtube** | `search` `video` `transcript` `comments` `channel` `playlist` `feed` `history` `watch-later` `subscriptions` `like` `unlike` `subscribe` `unsubscribe` | 浏览器 |
|
|
@@ -266,9 +289,9 @@ npm link
|
|
|
266
289
|
| **douyin** | `videos` `publish` `drafts` `draft` `delete` `stats` `profile` `update` `hashtag` `location` `activities` `collections` | 浏览器 |
|
|
267
290
|
| **yuanbao** | `new` `ask` | 浏览器 |
|
|
268
291
|
|
|
269
|
-
|
|
292
|
+
90+ 适配器 — **[→ 查看完整命令列表](./docs/adapters/index.md)**
|
|
270
293
|
|
|
271
|
-
`*` `opencli xiaoyuzhou transcript` 需要本地小宇宙凭证:`~/.opencli/xiaoyuzhou.json`。
|
|
294
|
+
`*` `opencli xiaoyuzhou podcast`、`podcast-episodes`、`episode`、`download`、`transcript` 需要本地小宇宙凭证:`~/.opencli/xiaoyuzhou.json`。
|
|
272
295
|
|
|
273
296
|
### 外部 CLI 枢纽
|
|
274
297
|
|
|
@@ -322,7 +345,7 @@ OpenCLI 支持从各平台下载图片、视频和文章。
|
|
|
322
345
|
| **Twitter/X** | 图片、视频 | 从用户媒体页或单条推文下载 |
|
|
323
346
|
| **Pixiv** | 图片 | 下载原始画质插画,支持多页作品 |
|
|
324
347
|
| **1688** | 图片、视频 | 下载商品页中可见的商品素材 |
|
|
325
|
-
| **小宇宙** | 音频、转录 |
|
|
348
|
+
| **小宇宙** | 音频、转录 | 使用本地凭证下载单集音频和转录 JSON / 文本 |
|
|
326
349
|
| **知乎** | 文章(Markdown) | 导出文章,可选下载图片到本地 |
|
|
327
350
|
| **微信公众号** | 文章(Markdown) | 导出微信公众号文章为 Markdown |
|
|
328
351
|
| **豆瓣** | 图片 | 下载电影条目的海报 / 剧照图片 |
|
|
@@ -377,7 +400,7 @@ opencli zhihu download "https://zhuanlan.zhihu.com/p/xxx" --download-images
|
|
|
377
400
|
opencli weixin download --url "https://mp.weixin.qq.com/s/xxx" --output ./weixin
|
|
378
401
|
```
|
|
379
402
|
|
|
380
|
-
`opencli xiaoyuzhou transcript` 需要本地小宇宙凭证:`~/.opencli/xiaoyuzhou.json`。
|
|
403
|
+
`opencli xiaoyuzhou download` 和 `transcript` 需要本地小宇宙凭证:`~/.opencli/xiaoyuzhou.json`。
|
|
381
404
|
|
|
382
405
|
|
|
383
406
|
|
|
@@ -448,25 +471,15 @@ opencli plugin uninstall my-tool # 卸载
|
|
|
448
471
|
|
|
449
472
|
如果你是一个被要求查阅代码并编写新 `opencli` 适配器的 AI,请遵守以下工作流。
|
|
450
473
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
> **完整模式**:在编写任何新代码前,先阅读 [opencli-explorer skill](./skills/opencli-explorer/SKILL.md)。它包含完整的适配器探索开发指南、API 探测流程、5级认证策略以及常见陷阱。
|
|
454
|
-
|
|
455
|
-
```bash
|
|
456
|
-
# 1. Deep Explore — 网络拦截 → 响应分析 → 能力推理 → 框架检测
|
|
457
|
-
opencli explore https://example.com --site mysite
|
|
458
|
-
|
|
459
|
-
# 2. Synthesize — 从探索成果物生成 evaluate-based TS 适配器
|
|
460
|
-
opencli synthesize mysite
|
|
474
|
+
在动代码前,先读 [`opencli-adapter-author` skill](./skills/opencli-adapter-author/SKILL.md)。它把整个流程串起来:
|
|
461
475
|
|
|
462
|
-
|
|
463
|
-
opencli
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
opencli
|
|
467
|
-
```
|
|
476
|
+
- 侦察站点,选定 pattern(SPA / SSR / JSONP / Token / Streaming)
|
|
477
|
+
- 用 `opencli browser network`、`eval`、interceptor 等找到目标 endpoint
|
|
478
|
+
- 定认证策略(`PUBLIC` / `COOKIE` / `HEADER` / `INTERCEPT`)
|
|
479
|
+
- 字段解码、设计 columns、`opencli browser init` 生成骨架
|
|
480
|
+
- 交付前用 `opencli browser verify <site>/<name>` 验证
|
|
468
481
|
|
|
469
|
-
|
|
482
|
+
在仓库外写的私有适配器放到 `~/.opencli/clis/<site>/<name>.js`;每个站点的 endpoint、字段映射、抓包样本会累积在 `~/.opencli/sites/<site>/`,下次写同站点的其他命令可以直接复用。
|
|
470
483
|
|
|
471
484
|
## 常见问题排查
|
|
472
485
|
|