Skip to content

Commit afa5e60

Browse files
authored
refactor: consolidate 6 skills into 3, remove mechanical commands (#1094)
* refactor: consolidate 6 skills into 3, remove mechanical commands Replaces opencli-oneshot / opencli-explorer / opencli-browser / opencli-usage with a single opencli-adapter-author skill that takes the AI agent end-to-end: site recon, API discovery, field decoding, adapter coding, and `opencli browser verify`. Removes the mechanical commands (`explore`, `synthesize`, `generate`, `cascade`, `record`) and their src/tests — they were codegen scaffolding meant for agents, which the new skill handles more flexibly via `opencli browser` primitives. Skill highlights: - Top-level decision tree + 12-step runbook - 5 site patterns (SPA / SSR / JSONP / Token / Streaming) - 5-layer API discovery (network → initial state → bundle → token → interceptor) - Field decode playbook (self-explanatory → codes → sort-key comparison) - Output design guide (columns, types, order, ≤15 per adapter) - Two-layer site memory: in-repo seeds for eastmoney/xueqiu/bilibili/tonghuashun plus local `~/.opencli/sites/<site>/` runtime workspace Kept skills: opencli-autofix (now points to adapter-author for rewrites), smart-search. Kept primitives: `browser *`, `doctor`, `list`, `validate`, `verify`, `<site> <cmd>`, `plugin *`, `completion`. No backward compatibility shims. Full test suite (1605 tests) passes. * review fixes: honest coverage, hard memory-hit path, typo, stale docs - site-memory hit path no longer jumps to writing adapter; forces Step 5 endpoint re-verification + Step 7 field check, and 30-day expiry - site-memory.md now specifies exact schemas for endpoints.json / field-map.json / notes.md / fixtures + write-back timing rules - coverage-matrix.md marks unverified patterns as 🟡 with an evidence section citing coingecko dry run + PR #1091 eastmoney + bilibili - eastmoney seed typo: resolveSecids -> resolveSecid (and splitSymbols) - docs/developer/ai-workflow.md rewritten to teach the adapter-author skill + opencli browser * primitives (dropped generate/synthesize/ cascade/explore references) - ts-adapter.md, getting-started.md, CHANGELOG.md:87 updated to point at opencli-adapter-author * fix(ci): resync package-lock + drop stale built-in list reference - Regenerate package-lock.json to restore @emnapi/core + @emnapi/runtime entries that got dropped during the rebase — `npm ci` was failing on all CI jobs (build / audit / docs-build / bun-test / unit-test) - docs/guide/getting-started.md: built-in list dropped `explore`, now reads (list, validate, verify, browser, doctor, plugin...) * fix(ci): restore package-lock.json from main (unrelated lockfile churn)
1 parent 0f903f5 commit afa5e60

48 files changed

Lines changed: 2380 additions & 8077 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Adapter code, validation, and error handling have been modernized.
8484
1. **Update Node.js** to v21 or later (v22 LTS recommended).
8585
2. **Run `npm install -g @jackwener/opencli@latest`** — the preuninstall hook gracefully stops the old daemon; the first browser command after upgrade auto-restarts it.
8686
3. **If you have custom `.ts` adapters** in `~/.opencli/clis/`, rename or compile them to `.js`. A warning will be printed on startup if stale `.ts` files are detected.
87-
4. **If you have custom `.yaml` adapters**, convert them to JS using the `cli()` API (see `skills/opencli-explorer/references/adapter-templates.md`).
87+
4. **If you have custom `.yaml` adapters**, convert them to JS using the `cli()` API (see `skills/opencli-adapter-author/references/adapter-template.md`).
8888
5. **If you parse error output from stdout**, switch to stderr. Errors are now structured YAML envelopes with typed exit codes.
8989

9090

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cli({
102102
});
103103
```
104104

105-
Use `opencli explore <url>` to discover APIs and see [opencli-explorer skill](./skills/opencli-explorer/SKILL.md) if you need the full adapter workflow.
105+
Install the [`opencli-adapter-author` skill](./skills/opencli-adapter-author/SKILL.md) if you need the full adapter workflow — recon → API discovery → field decoding → `opencli browser verify`.
106106

107107
### Validate Your Adapter
108108

README.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
OpenCLI gives you one surface for three different kinds of automation:
1212

1313
- **Use built-in adapters** for sites like Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, Twitter/X, and [many more](#built-in-commands).
14-
- **Let AI Agents operate any website** — install the `opencli-browser` skill in your AI agent (Claude Code, Cursor, etc.), and it can navigate, click, type, extract, and inspect any page using your logged-in browser.
15-
- **Generate new adapters** from real browser behavior with `explore`, `synthesize`, `generate`, and `cascade`.
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`.
1616

1717
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.
1818

1919
## Highlights
2020

2121
- **Desktop App Control** — Drive Electron apps (Cursor, Codex, ChatGPT, Notion, etc.) directly from the terminal via CDP.
22-
- **Browser Automation for AI Agents** — Install the `opencli-browser` 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 generate your own with `opencli generate`.
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`.
2424
- **Account-safe** — Reuses Chrome/Chromium logged-in state; your credentials never leave the browser.
25-
- **AI Agent ready**`explore` discovers APIs, `synthesize` generates adapters, `cascade` finds auth strategies. The `opencli-browser` skill gives any AI agent full browser control.
25+
- **AI Agent ready**One skill takes you from site recon through API discovery, field decoding, adapter writing, and verification.
2626
- **CLI Hub** — Discover, auto-install, and passthrough commands to any external CLI (gh, docker, obsidian, etc).
2727
- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times and pay nothing.
2828
- **Deterministic** — Same command, same output schema, every time. Pipeable, scriptable, CI-friendly.
@@ -81,24 +81,22 @@ npx skills add jackwener/opencli
8181
Or install only what you need:
8282

8383
```bash
84-
npx skills add jackwener/opencli --skill opencli-usage
85-
npx skills add jackwener/opencli --skill opencli-browser
86-
npx skills add jackwener/opencli --skill opencli-explorer
87-
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
8887
```
8988

9089
### Which skill to use
9190

9291
| Skill | When to use | Example prompt to your AI agent |
9392
|-------|------------|-------------------------------|
94-
| **opencli-browser** | Operate any website in real time | "Help me post this content on Xiaohongshu" / "Check my Twitter notifications and summarize them" |
95-
| **opencli-explorer** | Create a reusable CLI for a site | "Generate an adapter for douyin trending" |
96-
| **opencli-oneshot** | Quick one-off: URL + goal → adapter | "Make a command that grabs the top posts from this page" |
97-
| **opencli-usage** | Use existing built-in adapters | "Get the top 5 Bilibili trending videos" |
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" |
9896

9997
### How it works
10098

101-
Once the `opencli-browser` skill is installed, your AI agent can:
99+
Once `opencli-adapter-author` is installed, your AI agent can:
102100

103101
1. **Navigate** to any URL using your logged-in browser
104102
2. **Read** page content via structured DOM snapshots (not screenshots)
@@ -109,8 +107,9 @@ Once the `opencli-browser` skill is installed, your AI agent can:
109107
The agent handles all the `opencli browser` commands internally — you just describe what you want done in natural language.
110108

111109
**Skill references:**
112-
- [`skills/opencli-browser/SKILL.md`](./skills/opencli-browser/SKILL.md) — real-time browser operation
113-
- [`skills/opencli-explorer/SKILL.md`](./skills/opencli-explorer/SKILL.md) — adapter creation workflow
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
114113

115114
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`.
116115

@@ -120,25 +119,24 @@ Available browser commands include `open`, `state`, `click`, `type`, `select`, `
120119

121120
### `browser`: AI Agent browser control
122121

123-
`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-browser` skill into your AI agent, describe what you want in natural language, and the agent handles the browser operations.
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.
124123

125124
For example, tell your agent: *"Help me check my Xiaohongshu notifications"* — the agent will use `opencli browser open`, `state`, `click`, etc. under the hood.
126125

127126
### Built-in adapters: stable commands
128127

129128
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.
130129

131-
### `explore` / `synthesize` / `generate`: create new CLIs
130+
### Writing a new adapter
132131

133-
Use these commands when the site you need is not covered yet:
132+
When the site you need is not yet covered, use the `opencli-adapter-author` skill. It takes the agent end-to-end:
134133

135-
- `explore` inspects the page, network activity, and capability surface.
136-
- `synthesize` turns exploration artifacts into evaluate-based JS adapters.
137-
- `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.
138-
139-
### `cascade`: auth strategy discovery
140-
141-
Use `cascade` to probe fallback auth paths such as public endpoints, cookies, and custom headers before you commit to an adapter design.
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.
142140

143141
### CLI Hub and desktop adapters
144142

@@ -162,7 +160,6 @@ OpenCLI is not only for websites. It can also:
162160
| `OPENCLI_WINDOW_FOCUSED` | `false` | Set to `1` to open automation windows in the foreground (useful for debugging) |
163161
| `OPENCLI_BROWSER_CONNECT_TIMEOUT` | `30` | Seconds to wait for browser connection |
164162
| `OPENCLI_BROWSER_COMMAND_TIMEOUT` | `60` | Seconds to wait for a single browser command |
165-
| `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | `120` | Seconds to wait for explore/record operations |
166163
| `OPENCLI_CDP_ENDPOINT` || Chrome DevTools Protocol endpoint for remote browser or Electron apps |
167164
| `OPENCLI_CDP_TARGET` || Filter CDP targets by URL substring (e.g. `detail.1688.com`) |
168165
| `OPENCLI_VERBOSE` | `false` | Enable verbose logging (`-v` flag also works) |
@@ -181,10 +178,9 @@ npx skills add jackwener/opencli
181178
Or refresh only the skills you actually use:
182179

183180
```bash
184-
npx skills add jackwener/opencli --skill opencli-usage
185-
npx skills add jackwener/opencli --skill opencli-browser
186-
npx skills add jackwener/opencli --skill opencli-explorer
187-
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
188184
```
189185

190186
## For Developers
@@ -359,16 +355,15 @@ See [Plugins Guide](./docs/guide/plugins.md) for creating your own plugin.
359355

360356
## For AI Agents (Developer Guide)
361357

362-
> **Quick mode**: To generate a single command for a specific page URL, see [opencli-oneshot skill](./skills/opencli-oneshot/SKILL.md) — just a URL + one-line goal, 4 steps done.
358+
Before writing any adapter code, read the [`opencli-adapter-author` skill](./skills/opencli-adapter-author/SKILL.md). It takes you end-to-end:
363359

364-
> **Full mode**: Before writing any adapter code, read [opencli-explorer skill](./skills/opencli-explorer/SKILL.md). It contains the complete browser exploration workflow, the 5-tier authentication strategy decision tree, and debugging guide.
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.
365365

366-
```bash
367-
opencli explore https://example.com --site mysite # Discover APIs + capabilities
368-
opencli synthesize mysite # Generate JS adapters
369-
opencli generate https://example.com --goal "hot" # One-shot: explore → synthesize → register
370-
opencli cascade https://api.example.com/data # Auto-probe: PUBLIC → COOKIE → HEADER
371-
```
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.
372367

373368
## Testing
374369

0 commit comments

Comments
 (0)