@zenalexa/unicli 0.217.3 → 0.218.1
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/AGENTS.md +51 -194
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/bin/unicli-mcp.d.ts +10 -0
- package/dist/bin/unicli-mcp.d.ts.map +1 -0
- package/dist/bin/unicli-mcp.js +10 -0
- package/dist/bin/unicli-mcp.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/auth.d.ts +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +250 -0
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/dev.js +1 -0
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +1 -0
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +15 -6
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/repair.d.ts +1 -0
- package/dist/commands/repair.d.ts.map +1 -1
- package/dist/commands/repair.js +103 -61
- package/dist/commands/repair.js.map +1 -1
- package/dist/engine/chromium-cookies-platform.d.ts +69 -0
- package/dist/engine/chromium-cookies-platform.d.ts.map +1 -0
- package/dist/engine/chromium-cookies-platform.js +315 -0
- package/dist/engine/chromium-cookies-platform.js.map +1 -0
- package/dist/engine/chromium-cookies-types.d.ts +26 -0
- package/dist/engine/chromium-cookies-types.d.ts.map +1 -0
- package/dist/engine/chromium-cookies-types.js +16 -0
- package/dist/engine/chromium-cookies-types.js.map +1 -0
- package/dist/engine/chromium-cookies.d.ts +56 -0
- package/dist/engine/chromium-cookies.d.ts.map +1 -0
- package/dist/engine/chromium-cookies.js +361 -0
- package/dist/engine/chromium-cookies.js.map +1 -0
- package/dist/engine/cookies.d.ts +13 -5
- package/dist/engine/cookies.d.ts.map +1 -1
- package/dist/engine/cookies.js +55 -9
- package/dist/engine/cookies.js.map +1 -1
- package/dist/engine/executor.d.ts +8 -0
- package/dist/engine/executor.d.ts.map +1 -1
- package/dist/engine/executor.js +1 -1
- package/dist/engine/executor.js.map +1 -1
- package/dist/engine/kernel/execute.d.ts.map +1 -1
- package/dist/engine/kernel/execute.js +1 -0
- package/dist/engine/kernel/execute.js.map +1 -1
- package/dist/engine/repair/quarantine-discovery.d.ts +25 -0
- package/dist/engine/repair/quarantine-discovery.d.ts.map +1 -0
- package/dist/engine/repair/quarantine-discovery.js +78 -0
- package/dist/engine/repair/quarantine-discovery.js.map +1 -0
- package/dist/engine/steps/navigate.d.ts +1 -1
- package/dist/engine/steps/navigate.d.ts.map +1 -1
- package/dist/engine/steps/navigate.js +5 -1
- package/dist/engine/steps/navigate.js.map +1 -1
- package/dist/engine/template.d.ts +14 -4
- package/dist/engine/template.d.ts.map +1 -1
- package/dist/engine/template.js +93 -65
- package/dist/engine/template.js.map +1 -1
- package/dist/engine/verify-row-shape.d.ts +17 -0
- package/dist/engine/verify-row-shape.d.ts.map +1 -0
- package/dist/engine/verify-row-shape.js +36 -0
- package/dist/engine/verify-row-shape.js.map +1 -0
- package/dist/fast-path/handlers/adapter.d.ts +15 -0
- package/dist/fast-path/handlers/adapter.d.ts.map +1 -0
- package/dist/fast-path/handlers/adapter.js +169 -0
- package/dist/fast-path/handlers/adapter.js.map +1 -0
- package/dist/fast-path/handlers/discovery.d.ts +14 -0
- package/dist/fast-path/handlers/discovery.d.ts.map +1 -0
- package/dist/fast-path/handlers/discovery.js +280 -0
- package/dist/fast-path/handlers/discovery.js.map +1 -0
- package/dist/fast-path/manifest.d.ts +47 -0
- package/dist/fast-path/manifest.d.ts.map +1 -0
- package/dist/fast-path/manifest.js +32 -0
- package/dist/fast-path/manifest.js.map +1 -0
- package/dist/fast-path/parsed-argv.d.ts +16 -0
- package/dist/fast-path/parsed-argv.d.ts.map +1 -0
- package/dist/fast-path/parsed-argv.js +6 -0
- package/dist/fast-path/parsed-argv.js.map +1 -0
- package/dist/fast-path/policy.d.ts +25 -0
- package/dist/fast-path/policy.d.ts.map +1 -0
- package/dist/fast-path/policy.js +96 -0
- package/dist/fast-path/policy.js.map +1 -0
- package/dist/fast-path/render.d.ts +26 -0
- package/dist/fast-path/render.d.ts.map +1 -0
- package/dist/fast-path/render.js +200 -0
- package/dist/fast-path/render.js.map +1 -0
- package/dist/fast-path.d.ts +8 -10
- package/dist/fast-path.d.ts.map +1 -1
- package/dist/fast-path.js +66 -810
- package/dist/fast-path.js.map +1 -1
- package/dist/manifest.json +7 -6
- package/dist/transport/adapters/cdp-browser.d.ts +6 -6
- package/dist/transport/adapters/cdp-browser.js +7 -7
- package/dist/transport/adapters/cdp-browser.js.map +1 -1
- package/dist/transport/adapters/subprocess.d.ts +4 -4
- package/dist/transport/adapters/subprocess.js +4 -4
- package/package.json +22 -8
- package/server.json +44 -0
- package/skills/README.md +39 -0
- package/skills/talk-normal/SKILL.md +25 -0
- package/skills/talk-normal/prompt.md +35 -0
- package/skills/unicli/SKILL.md +389 -0
- package/skills/unicli/references/auth.md +188 -0
- package/skills/unicli/references/output.md +238 -0
- package/skills/unicli/references/sites.md +259 -0
- package/skills/unicli-browser/SKILL.md +99 -0
- package/skills/unicli-claude-code/SKILL.md +172 -0
- package/skills/unicli-explorer/SKILL.md +90 -0
- package/skills/unicli-hermes/SKILL.md +83 -0
- package/skills/unicli-oneshot/SKILL.md +59 -0
- package/skills/unicli-operate/SKILL.md +113 -0
- package/skills/unicli-repair/SKILL.md +209 -0
- package/skills/unicli-repair/references/error-codes.md +149 -0
- package/skills/unicli-repair/references/yaml-patches.md +321 -0
- package/skills/unicli-smart-search/SKILL.md +80 -0
- package/skills/unicli-usage/SKILL.md +65 -0
- package/src/adapters/adguardhome/rules.yaml +1 -1
- package/src/adapters/adguardhome/stats.yaml +1 -1
- package/src/adapters/adguardhome/status.yaml +1 -1
- package/src/adapters/apple-music/rate-album.yaml +1 -2
- package/src/adapters/arxiv/trending.yaml +1 -1
- package/src/adapters/az/account.yaml +1 -1
- package/src/adapters/coupang/hot.yaml +2 -1
- package/src/adapters/ctrip/hot.yaml +2 -1
- package/src/adapters/ctrip/search.yaml +2 -1
- package/src/adapters/douban/top250.yaml +1 -1
- package/src/adapters/figma/export-selected.yaml +1 -2
- package/src/adapters/gcloud/projects.yaml +1 -1
- package/src/adapters/github-trending/developers.yaml +1 -1
- package/src/adapters/github-trending/weekly.yaml +1 -1
- package/src/adapters/homebrew/search.yaml +1 -1
- package/src/adapters/imdb/top.yaml +1 -1
- package/src/adapters/itch-io/popular.yaml +1 -1
- package/src/adapters/itch-io/top.yaml +1 -1
- package/src/adapters/mastodon/timeline.yaml +1 -1
- package/src/adapters/openrouter/search.yaml +1 -1
- package/src/adapters/pypi/search.yaml +2 -1
- package/src/adapters/sspai/hot.yaml +4 -1
- package/src/adapters/sspai/latest.yaml +3 -3
- package/src/adapters/tieba/hot.yaml +1 -1
- package/src/adapters/wikipedia/today.yaml +1 -1
- package/src/adapters/zoom/toggle-mute.yaml +1 -2
- package/dist/engine/yaml-runner.d.ts +0 -11
- package/dist/engine/yaml-runner.d.ts.map +0 -1
- package/dist/engine/yaml-runner.js +0 -18
- package/dist/engine/yaml-runner.js.map +0 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: unicli
|
|
3
|
+
description: >
|
|
4
|
+
Comprehensive guide to using Uni-CLI — the universal CLI for AI agents.
|
|
5
|
+
Trigger when the user needs to fetch data from websites (Twitter, Bilibili,
|
|
6
|
+
HackerNews, GitHub, Reddit, Bloomberg, Zhihu, WeChat, and 230+ more);
|
|
7
|
+
interact with news, finance, social, academic, shopping, or video platforms;
|
|
8
|
+
control macOS desktop apps (Blender, GIMP, Figma, VS Code, Cursor, Terminal,
|
|
9
|
+
Discord, Slack, etc.) via AppleScript or Accessibility API; automate browser
|
|
10
|
+
actions on login-gated pages; extract trending/hot/search/top lists from any
|
|
11
|
+
major platform; run desktop workflows or system tasks; or when the user says
|
|
12
|
+
"unicli", "scrape", "fetch from", "get trending", "check [site]", "find on
|
|
13
|
+
[platform]", "获取", "查询", "抓取".
|
|
14
|
+
version: 0.218.0
|
|
15
|
+
category: core
|
|
16
|
+
depends-on:
|
|
17
|
+
- talk-normal
|
|
18
|
+
allowed-tools: [Bash, Read]
|
|
19
|
+
protocol: 2.0
|
|
20
|
+
triggers:
|
|
21
|
+
- "unicli"
|
|
22
|
+
- "fetch from"
|
|
23
|
+
- "get from"
|
|
24
|
+
- "check twitter"
|
|
25
|
+
- "bilibili"
|
|
26
|
+
- "hackernews"
|
|
27
|
+
- "scrape"
|
|
28
|
+
- "trending"
|
|
29
|
+
- "hot topics"
|
|
30
|
+
- "desktop app"
|
|
31
|
+
- "macOS app"
|
|
32
|
+
- "browser automation"
|
|
33
|
+
- "search web"
|
|
34
|
+
- "social media"
|
|
35
|
+
- "获取"
|
|
36
|
+
- "查询"
|
|
37
|
+
- "抓取"
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Uni-CLI — Agent Usage Guide
|
|
41
|
+
|
|
42
|
+
unicli converts 237 websites, 2,000+ desktop apps, and macOS system tools into
|
|
43
|
+
deterministic CLI commands. Each command is a ≤20-line YAML pipeline: fetch data,
|
|
44
|
+
transform it, emit a v2 AgentEnvelope. When a command breaks, read the structured
|
|
45
|
+
error, edit the YAML adapter, and it stays fixed for all future calls.
|
|
46
|
+
|
|
47
|
+
**Install** (once): `npm install -g @zenalexa/unicli`
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Five-Command Quick Start
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
unicli list # browse all 3,319 commands
|
|
55
|
+
unicli list --site hackernews # commands for one site
|
|
56
|
+
unicli hackernews top --limit 5 # run a command
|
|
57
|
+
unicli hackernews top --limit 5 -f json # machine-readable JSON envelope
|
|
58
|
+
unicli describe hackernews top # full schema + example payload
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Step 1 — Discover the Right Command
|
|
64
|
+
|
|
65
|
+
### Find by site
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
unicli list --site <site> # all commands for a site
|
|
69
|
+
unicli describe <site> <command> # args, output columns, example
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Search by keyword
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
unicli search "trending" # semantic search across all commands
|
|
76
|
+
unicli search "hot stock" # natural language
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Browse by type
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
unicli list --type web-api # REST API adapters (1,138 commands)
|
|
83
|
+
unicli list --type desktop # desktop app control (2,068 commands)
|
|
84
|
+
unicli list --type browser # browser automation (23 commands)
|
|
85
|
+
unicli list --type service # local/remote services (43 commands)
|
|
86
|
+
unicli list --type bridge # passthrough CLI bridges (47 commands)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Check if a site exists
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
unicli list --site github-trending # returns commands or empty
|
|
93
|
+
unicli health # adapter index summary
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Step 2 — Run Commands
|
|
99
|
+
|
|
100
|
+
### Basic syntax
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
unicli <site> <command> [<positional-arg>] [--flag value] [-f json|md|yaml|csv]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Key flags (universal)
|
|
107
|
+
|
|
108
|
+
| Flag | Effect |
|
|
109
|
+
| -------------------- | ---------------------------------------------------------- |
|
|
110
|
+
| `--limit N` | Cap output rows (default varies, max 100) |
|
|
111
|
+
| `-f json` | Machine-readable v2 AgentEnvelope JSON to stdout |
|
|
112
|
+
| `-f md` | Agent-native Markdown (default, frontmatter + sections) |
|
|
113
|
+
| `-f yaml` | YAML envelope |
|
|
114
|
+
| `-f csv` | Flat CSV (array data only) |
|
|
115
|
+
| `-f compact` | One row per line, `\|` separator |
|
|
116
|
+
| `--args-file <path>` | Read args from a JSON file (avoids shell-quote issues) |
|
|
117
|
+
| `--cursor <token>` | Pagination cursor from previous envelope `meta.pagination` |
|
|
118
|
+
|
|
119
|
+
### Common patterns
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Search
|
|
123
|
+
unicli hackernews search "AI agents" --limit 10
|
|
124
|
+
|
|
125
|
+
# Trending
|
|
126
|
+
unicli weibo hot
|
|
127
|
+
unicli bilibili hot --limit 20
|
|
128
|
+
|
|
129
|
+
# Finance
|
|
130
|
+
unicli xueqiu hot-stock --limit 10 -f json
|
|
131
|
+
|
|
132
|
+
# Desktop control
|
|
133
|
+
unicli blender render scene.blend output.png
|
|
134
|
+
unicli ffmpeg compress video.mp4 -o compressed.mp4
|
|
135
|
+
|
|
136
|
+
# macOS system
|
|
137
|
+
unicli macos volume 60
|
|
138
|
+
unicli macos screenshot ~/Desktop/capture.png
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Pagination
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# First page
|
|
145
|
+
unicli reddit hot --limit 25 -f json | jq '.meta.pagination.next_cursor'
|
|
146
|
+
|
|
147
|
+
# Next page (use cursor from previous response)
|
|
148
|
+
unicli reddit hot --limit 25 --cursor <token> -f json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Step 3 — Read the Output
|
|
154
|
+
|
|
155
|
+
Every command emits a **v2 AgentEnvelope**. Learn the shape once; it applies to
|
|
156
|
+
all 3,319 commands.
|
|
157
|
+
|
|
158
|
+
### JSON structure
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"ok": true,
|
|
163
|
+
"schema_version": "2",
|
|
164
|
+
"command": "hackernews.top",
|
|
165
|
+
"meta": {
|
|
166
|
+
"duration_ms": 2805,
|
|
167
|
+
"count": 5,
|
|
168
|
+
"surface": "web",
|
|
169
|
+
"pagination": { "next_cursor": "...", "has_more": true }
|
|
170
|
+
},
|
|
171
|
+
"data": [{ "rank": 1, "title": "...", "score": 80, "url": "..." }],
|
|
172
|
+
"error": null,
|
|
173
|
+
"next_actions": [
|
|
174
|
+
{ "command": "unicli describe hackernews top", "description": "..." }
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Key fields
|
|
180
|
+
|
|
181
|
+
| Field | Meaning |
|
|
182
|
+
| ----------------- | ------------------------------------------------------------ |
|
|
183
|
+
| `ok` | `true` = success, `false` = failure — **always check first** |
|
|
184
|
+
| `schema_version` | Always `"2"` — confirms v2 envelope |
|
|
185
|
+
| `meta.count` | Rows returned |
|
|
186
|
+
| `meta.pagination` | Non-null when more pages exist; use `.next_cursor` |
|
|
187
|
+
| `data` | Payload array or object |
|
|
188
|
+
| `error` | `null` on success; structured on failure (see Step 5) |
|
|
189
|
+
| `next_actions` | HATEOAS hints — valid commands to run next, trust these |
|
|
190
|
+
|
|
191
|
+
### Markdown format (default)
|
|
192
|
+
|
|
193
|
+
When piped or called by an agent, the default format is `md` — YAML frontmatter
|
|
194
|
+
followed by formatted sections. Use `-f json` for programmatic parsing.
|
|
195
|
+
|
|
196
|
+
### Parse with jq
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
unicli hackernews top -f json | jq '.[].title' # WRONG: data is nested
|
|
200
|
+
unicli hackernews top -f json | jq '.data[].title' # correct
|
|
201
|
+
unicli hackernews top -f json | jq '.data[] | {title, url}'
|
|
202
|
+
unicli xueqiu hot -f json | jq '.data[] | select(.change | tonumber > 5)'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Step 4 — Authentication
|
|
208
|
+
|
|
209
|
+
unicli uses a **strategy cascade** that auto-probes on first run. Most sites need
|
|
210
|
+
no manual setup — the cascade promotes from `public` → `cookie` → `header`
|
|
211
|
+
automatically.
|
|
212
|
+
|
|
213
|
+
### Strategy ladder
|
|
214
|
+
|
|
215
|
+
| Strategy | Auth needed | How to set up |
|
|
216
|
+
| ----------- | --------------------- | ------------------------------------------------------ |
|
|
217
|
+
| `public` | None | Works out of the box |
|
|
218
|
+
| `cookie` | Browser login | `unicli auth setup <site>` → log in once in browser |
|
|
219
|
+
| `header` | Cookie + CSRF | Same as `cookie`; auto-extracted per request |
|
|
220
|
+
| `intercept` | Browser session | `unicli browser start` then `unicli auth setup <site>` |
|
|
221
|
+
| `ui` | Browser + interaction | Same; unicli clicks through login flow |
|
|
222
|
+
|
|
223
|
+
### Auth setup workflow
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# First time — unicli guides you through browser login
|
|
227
|
+
unicli auth setup twitter
|
|
228
|
+
|
|
229
|
+
# Verify credentials are stored
|
|
230
|
+
unicli auth status twitter
|
|
231
|
+
|
|
232
|
+
# List all authenticated sites
|
|
233
|
+
unicli auth list
|
|
234
|
+
|
|
235
|
+
# Re-authenticate when cookies expire (exit code 77)
|
|
236
|
+
unicli auth setup <site>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Cookie files live at `~/.unicli/cookies/<site>.json` — never read or edit these
|
|
240
|
+
directly; use `unicli auth`.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Step 5 — Handle Errors
|
|
245
|
+
|
|
246
|
+
### Exit code → action (primary decision tree)
|
|
247
|
+
|
|
248
|
+
| Code | Meaning | Action |
|
|
249
|
+
| ---- | ---------------------- | -------------------------------------------------- |
|
|
250
|
+
| 0 | Success | Read `data` |
|
|
251
|
+
| 1 | Generic error | Read `error.reason` + `error.suggestion` |
|
|
252
|
+
| 2 | Usage error | Fix arg syntax; run `unicli describe <site> <cmd>` |
|
|
253
|
+
| 66 | Empty result | Try different query terms or `--limit` |
|
|
254
|
+
| 69 | Service unavailable | `unicli browser start` then retry |
|
|
255
|
+
| 75 | Temp failure / timeout | Retry once; if persists → load `unicli-repair` |
|
|
256
|
+
| 77 | Auth required | `unicli auth setup <site>` then retry |
|
|
257
|
+
| 78 | Config error | Read `error.suggestion`; check `~/.unicli/` config |
|
|
258
|
+
|
|
259
|
+
### Failure envelope fields
|
|
260
|
+
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"ok": false,
|
|
264
|
+
"error": {
|
|
265
|
+
"code": "auth_required",
|
|
266
|
+
"exit_code": 77,
|
|
267
|
+
"message": "No cookie file found for twitter",
|
|
268
|
+
"adapter_path": "adapters/twitter/search.yaml",
|
|
269
|
+
"step": 1,
|
|
270
|
+
"retryable": true,
|
|
271
|
+
"suggestion": "Run `unicli auth setup twitter` to authenticate",
|
|
272
|
+
"remedy": {
|
|
273
|
+
"command": "unicli auth setup twitter",
|
|
274
|
+
"message": "Open browser to complete login"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Hard rules
|
|
281
|
+
|
|
282
|
+
- **ALWAYS check `ok` first** before reading `data`.
|
|
283
|
+
- **NEVER retry on exit 2** (usage error — fix the args, not the adapter).
|
|
284
|
+
- **Follow `error.remedy.command`** exactly — it is generated from the adapter schema.
|
|
285
|
+
- **Load `unicli-repair` skill** when the same command fails twice after following
|
|
286
|
+
`remedy` — the adapter likely needs structural repair, not just a retry.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Browser Mode (Escalation Path)
|
|
291
|
+
|
|
292
|
+
Use browser mode when: a site requires JavaScript rendering, login-gated access,
|
|
293
|
+
interaction (click/type/scroll), or the API adapter returns exit 69.
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
unicli browser start # launch Chrome with CDP (required first)
|
|
297
|
+
unicli browser status # confirm CDP is alive + session state
|
|
298
|
+
unicli browser open <url> # navigate to page
|
|
299
|
+
unicli browser state # DOM accessibility tree with [ref] IDs
|
|
300
|
+
unicli browser find --css h2 # query specific elements
|
|
301
|
+
unicli browser click <ref> # interact
|
|
302
|
+
unicli browser type <ref> "text" # fill input
|
|
303
|
+
unicli browser extract # extract full page text
|
|
304
|
+
unicli browser screenshot # capture to file
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
For a guided browser automation workflow, load skill `unicli-browser`.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Composition Patterns
|
|
312
|
+
|
|
313
|
+
### Multi-source research
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Tech trends: query 3 sources
|
|
317
|
+
unicli hackernews top --limit 10 -f json | jq '.data[].title'
|
|
318
|
+
unicli reddit hot --limit 10 -f json | jq '.data[].title'
|
|
319
|
+
unicli github-trending daily --limit 10 -f json | jq '.data[].name'
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Cross-platform topic search
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
for site in hackernews reddit twitter; do
|
|
326
|
+
echo "=== $site ===" && unicli $site search "AI agents" --limit 5
|
|
327
|
+
done
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Data pipeline (pipe to jq)
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
unicli bilibili hot -f json \
|
|
334
|
+
| jq '.data[] | select(.view | tonumber > 1000000) | {title, view, up}'
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Budget rule: 1–2 primary sources + 1 supplementary per user question. Never
|
|
338
|
+
|
|
339
|
+
query the same site twice in one turn.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Skill Routing
|
|
344
|
+
|
|
345
|
+
| Scenario | Load skill |
|
|
346
|
+
| -------------------------------------------- | --------------------- |
|
|
347
|
+
| Adapter fails with structured error envelope | `unicli-repair` |
|
|
348
|
+
| Search queries across platforms | `unicli-smart-search` |
|
|
349
|
+
| Browser automation, CDP sessions | `unicli-browser` |
|
|
350
|
+
| Creating a new adapter from scratch | `unicli-explorer` |
|
|
351
|
+
| One-shot URL → adapter generation | `unicli-oneshot` |
|
|
352
|
+
| Claude / Claude.ai commands | `unicli-claude` |
|
|
353
|
+
| Claude Code commands | `unicli-claude-code` |
|
|
354
|
+
| Hermes integration | `unicli-hermes` |
|
|
355
|
+
| Detailed command reference | `unicli-usage` |
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Efficiency Rules
|
|
360
|
+
|
|
361
|
+
1. Default output is `md` (Markdown). Use `-f json` for programmatic parsing.
|
|
362
|
+
2. Always set `--limit` — default varies per command (5–50); unset = potentially 100+.
|
|
363
|
+
3. MCP server (`unicli mcp serve`) wraps all commands as tools; 4 default tools,
|
|
364
|
+
`--expanded` adds all 3,319 (costs tokens: use only in MCP-only environments).
|
|
365
|
+
4. Adapter user overlay: fixes go to `~/.unicli/adapters/<site>/<cmd>.yaml`
|
|
366
|
+
and survive `npm update`.
|
|
367
|
+
5. `unicli doctor` checks runtime health (Node version, Chrome, auth files,
|
|
368
|
+
adapter index). Run it when unexplained failures occur.
|
|
369
|
+
6. `UNICLI_OUTPUT=json unicli <cmd>` sets JSON globally without `-f json` per call.
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Reference Index
|
|
374
|
+
|
|
375
|
+
| Reference | Load when |
|
|
376
|
+
| ---------------------------------------------- | ---------------------------------------- |
|
|
377
|
+
| [`references/sites.md`](references/sites.md) | Browsing the site catalog by category |
|
|
378
|
+
| [`references/output.md`](references/output.md) | Parsing AgentEnvelope v2 fields in depth |
|
|
379
|
+
| [`references/auth.md`](references/auth.md) | Auth setup per site, cookie management |
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## MCP Server
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
unicli mcp serve # 4 tools: run, list, search, explore
|
|
387
|
+
unicli mcp serve --expanded # all 3,319 commands as individual tools
|
|
388
|
+
unicli mcp serve --profile browser # browser + CDP tools only
|
|
389
|
+
```
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Authentication & Strategy Reference
|
|
2
|
+
|
|
3
|
+
How unicli handles authentication: from public APIs to full browser login flows.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Strategy Cascade (Auto-Probe)
|
|
8
|
+
|
|
9
|
+
On first run, unicli probes strategies in order and caches the result:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
public → cookie → header
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Browser strategies (`intercept`, `ui`) never auto-promote — they require explicit
|
|
16
|
+
opt-in via the YAML adapter's `strategy:` field.
|
|
17
|
+
|
|
18
|
+
| Strategy | Requires | When used |
|
|
19
|
+
| ----------- | ------------------------------- | ------------------------------------------ |
|
|
20
|
+
| `public` | Nothing | Open APIs, no auth |
|
|
21
|
+
| `cookie` | `~/.unicli/cookies/<site>.json` | Login-gated; auto-exported from browser |
|
|
22
|
+
| `header` | Cookie + CSRF token | Cookie + per-request CSRF (auto-extracted) |
|
|
23
|
+
| `intercept` | Browser CDP session | Navigate page, capture XHR; no direct API |
|
|
24
|
+
| `ui` | Browser CDP session | Click through login or interact with page |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## First-Time Setup Workflow
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. Start setup — unicli opens a browser window
|
|
32
|
+
unicli auth setup <site>
|
|
33
|
+
|
|
34
|
+
# 2. Log in to the site in the browser window
|
|
35
|
+
# 3. unicli detects cookies and saves them automatically
|
|
36
|
+
|
|
37
|
+
# 4. Verify
|
|
38
|
+
unicli auth status <site>
|
|
39
|
+
|
|
40
|
+
# 5. Test the command
|
|
41
|
+
unicli <site> <command>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Auth Commands Reference
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
unicli auth setup <site> # guided browser login + cookie export
|
|
50
|
+
unicli auth status <site> # check cookie file exists + expiry
|
|
51
|
+
unicli auth list # all authenticated sites
|
|
52
|
+
unicli auth refresh <site> # re-export cookies (when expired)
|
|
53
|
+
unicli auth remove <site> # delete stored credentials
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Cookie File Location
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
~/.unicli/cookies/<site>.json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Files are JSON arrays of cookie objects (Netscape/WebKit format).
|
|
65
|
+
- **Never read or edit cookie files directly** — use `unicli auth` commands.
|
|
66
|
+
- Cookie files are per-site; one site can have one active cookie file.
|
|
67
|
+
- Expiry: cookies expire per the site's session policy (hours to months).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Exit Code 77 — Auth Required
|
|
72
|
+
|
|
73
|
+
When you see exit 77 (`auth_required` or `not_authenticated`):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Step 1: Check which sites need auth
|
|
77
|
+
unicli auth list
|
|
78
|
+
|
|
79
|
+
# Step 2: Set up auth
|
|
80
|
+
unicli auth setup <site>
|
|
81
|
+
|
|
82
|
+
# Step 3: Retry the failed command
|
|
83
|
+
unicli <site> <command>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Site-Specific Auth Notes
|
|
89
|
+
|
|
90
|
+
### Chinese social platforms (Weibo, Zhihu, Bilibili, Douyin)
|
|
91
|
+
|
|
92
|
+
- Cookie-based; sessions typically last 7–30 days.
|
|
93
|
+
- Re-run `unicli auth setup <site>` after expiry.
|
|
94
|
+
- Bilibili has anti-bot measures — use `unicli auth setup bilibili` in headful mode.
|
|
95
|
+
|
|
96
|
+
### Twitter / X
|
|
97
|
+
|
|
98
|
+
- Cookie-based via browser session.
|
|
99
|
+
- Twitter aggressively rotates session tokens; may need monthly refresh.
|
|
100
|
+
- `unicli auth status twitter` shows last-updated timestamp.
|
|
101
|
+
|
|
102
|
+
### Reddit
|
|
103
|
+
|
|
104
|
+
- Most listing commands work without auth (`public`).
|
|
105
|
+
- Search and user commands may need auth for personalized results.
|
|
106
|
+
|
|
107
|
+
### LinkedIn
|
|
108
|
+
|
|
109
|
+
- Requires auth for most commands.
|
|
110
|
+
- Sessions last weeks; refresh on 77 errors.
|
|
111
|
+
|
|
112
|
+
### Financial platforms (Xueqiu, Eastmoney, Futu)
|
|
113
|
+
|
|
114
|
+
- Xueqiu hot/hot-stock are public.
|
|
115
|
+
- Portfolio/watchlist commands require auth.
|
|
116
|
+
|
|
117
|
+
### E-commerce (Amazon, JD, Taobao)
|
|
118
|
+
|
|
119
|
+
- Hot/search are public.
|
|
120
|
+
- Cart/order/account commands require auth.
|
|
121
|
+
|
|
122
|
+
### GitHub / GitLab
|
|
123
|
+
|
|
124
|
+
- Public repo commands work without auth.
|
|
125
|
+
- `gh` bridge commands use your local `gh auth` token, not unicli cookies.
|
|
126
|
+
- `unicli gh pr list` → delegates to `gh cli` (must have `gh auth login` done).
|
|
127
|
+
|
|
128
|
+
### AI platforms (Claude, ChatGPT, Deepseek)
|
|
129
|
+
|
|
130
|
+
- Require auth for all commands.
|
|
131
|
+
- Browser-based auth; sessions last weeks.
|
|
132
|
+
- Use `unicli claude chat "..."` for quick one-off calls.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Browser Strategy — When Cookie Is Not Enough
|
|
137
|
+
|
|
138
|
+
Some sites require JavaScript rendering or have bot detection that blocks API calls.
|
|
139
|
+
For these, unicli uses `intercept` or `ui` strategy via Chrome CDP.
|
|
140
|
+
|
|
141
|
+
**Pre-requisite**: `unicli browser start` must be running.
|
|
142
|
+
|
|
143
|
+
### Intercept strategy
|
|
144
|
+
|
|
145
|
+
The adapter navigates to the page, captures XHR/fetch responses, and extracts data
|
|
146
|
+
from the network traffic — no DOM scraping, highly reliable.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
unicli browser start
|
|
150
|
+
unicli <site> <command> # adapter auto-uses intercept strategy
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### UI strategy
|
|
154
|
+
|
|
155
|
+
The adapter interacts with the page (click, type, scroll) to trigger data loading,
|
|
156
|
+
then extracts via DOM accessibility snapshot.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
unicli browser start
|
|
160
|
+
unicli browser status # confirm CDP is alive
|
|
161
|
+
unicli <site> <command> # adapter auto-uses ui strategy
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
For building new adapters with these strategies, load skill `unicli-explorer`.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Troubleshooting Auth
|
|
169
|
+
|
|
170
|
+
### Symptoms and fixes
|
|
171
|
+
|
|
172
|
+
| Symptom | Fix |
|
|
173
|
+
| ----------------------------------------- | ----------------------------------------------------------------- |
|
|
174
|
+
| Exit 77, `auth_required` | `unicli auth setup <site>` |
|
|
175
|
+
| Commands work then fail hours later | Cookie expired — `unicli auth refresh <site>` |
|
|
176
|
+
| `unicli auth status <site>` shows no file | Cookie was never set up — run `unicli auth setup <site>` |
|
|
177
|
+
| Browser window opens but login hangs | Try `unicli browser start` first, then `unicli auth setup <site>` |
|
|
178
|
+
| "permission_denied" after login | Account lacks access to that resource |
|
|
179
|
+
| Auth succeeds but command still fails | Check `unicli health` — may be adapter issue, not auth |
|
|
180
|
+
|
|
181
|
+
### Verify the full auth chain
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
unicli doctor # system health: Node, Chrome, auth files, index
|
|
185
|
+
unicli auth list # which sites have cookies
|
|
186
|
+
unicli auth status <site> # cookie file freshness
|
|
187
|
+
unicli browser status # CDP session alive?
|
|
188
|
+
```
|