Skip to content

Commit a9d21f3

Browse files
authored
fix: project hygiene — docs, lint, daemon restart (#942)
* fix: project hygiene — docs, lint, daemon restart, code fence - Update Node version requirement from >= 20 to >= 21 in 7 doc files (README, README.zh-CN, installation guides, troubleshooting) - Update adapter count from 79+ to 87+ in READMEs - Remove duplicate `lint` script (identical to `typecheck`) - Fix TESTING.md CI matrix: Node ['22'] instead of ['20', '22'] - Fix autofix SKILL.md code fence escaping (\``` → ~~~) - Add daemon restart to postinstall so updated adapters are picked up - Fix preuninstall to respect OPENCLI_DAEMON_PORT env var * fix: align docs and skills with JS-first adapter contract Adapters are now .js files (not .ts). Update all references across: - README.md, README.zh-CN.md, CONTRIBUTING.md - docs/guide/getting-started.md, docs/index.md - skills/opencli-browser/SKILL.md, skills/opencli-explorer/SKILL.md The runtime (discovery.ts) only loads .js from user clis/ directories, and `opencli browser init` generates .js scaffolds. Documentation was still teaching users to create .ts files. * fix: update CI matrix to Node 22 only (drop Node 20) package.json requires Node >= 21 (styleText dependency). The CI matrix was still testing Node 20 which doesn't meet this requirement. * fix: revert incorrect daemon restart from postinstall The daemon (browser bridge) only handles CDP communication — it has no knowledge of adapters. Adapter discovery, loading, and execution all happen in the CLI process, which is fresh each invocation. The _loadedModules cache in execution.ts is process-local and not a real staleness concern. Remove the unnecessary restartDaemon() call.
1 parent 383d28f commit a9d21f3

15 files changed

Lines changed: 37 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
fail-fast: false
4848
matrix:
4949
os: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && fromJSON('["ubuntu-latest","macos-latest","windows-latest"]') || fromJSON('["ubuntu-latest"]') }}
50-
node-version: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && fromJSON('["20","22"]') || fromJSON('["22"]') }}
50+
node-version: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && fromJSON('["22"]') || fromJSON('["22"]') }}
5151
shard: [1, 2]
5252
steps:
5353
- uses: actions/checkout@v6

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ All adapters use TypeScript. Use the pipeline API for data-fetching commands, an
3030

3131
### Pipeline Adapter (Recommended for data-fetching commands)
3232

33-
Create a file like `clis/<site>/<command>.ts`:
33+
Create a file like `clis/<site>/<command>.js`:
3434

3535
```typescript
3636
import { cli, Strategy } from '@jackwener/opencli/registry';
@@ -60,11 +60,11 @@ cli({
6060
});
6161
```
6262

63-
See [`hackernews/top.ts`](clis/hackernews/top.ts) for a real example.
63+
See [`hackernews/top.js`](clis/hackernews/top.js) for a real example.
6464

6565
### func() Adapter (For complex browser interactions)
6666

67-
Create a file like `clis/<site>/<command>.ts`:
67+
Create a file like `clis/<site>/<command>.js`:
6868

6969
```typescript
7070
import { cli, Strategy } from '@jackwener/opencli/registry';

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ It also works as a **CLI hub** for local tools such as `gh`, `docker`, and other
3030
- **AI Agent ready**`explore` discovers APIs, `synthesize` generates adapters, `cascade` finds auth strategies, `browser` controls the browser directly.
3131
- **External CLI Hub** — Discover, auto-install, and passthrough commands to any external CLI (gh, obsidian, docker, etc). Zero setup.
3232
- **Self-healing setup**`opencli doctor` diagnoses and auto-starts the daemon, extension, and live browser connectivity.
33-
- **Dynamic Loader** — Simply drop `.ts` adapters into the `clis/` folder for auto-registration.
33+
- **Dynamic Loader** — Simply drop `.js` adapters into the `clis/` folder for auto-registration.
3434
- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times and pay nothing.
3535
- **Deterministic** — Same command, same output schema, every time. Pipeable, scriptable, CI-friendly.
36-
- **Broad coverage**79+ sites across global and Chinese platforms (Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, and more), plus desktop Electron apps via CDP.
36+
- **Broad coverage**87+ sites across global and Chinese platforms (Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, and more), plus desktop Electron apps via CDP.
3737

3838
---
3939

@@ -136,7 +136,7 @@ OpenCLI is not only for websites. It can also:
136136

137137
## Prerequisites
138138

139-
- **Node.js**: >= 20.0.0 (or **Bun** >= 1.0)
139+
- **Node.js**: >= 21.0.0 (or **Bun** >= 1.0)
140140
- **Chrome or Chromium** running and logged into the target site for browser-backed commands
141141

142142
> **Important**: Browser-backed commands reuse your Chrome/Chromium login session. If you get empty data or permission-like failures, first confirm the site is already open and authenticated in Chrome/Chromium.
@@ -212,7 +212,7 @@ To load the source Browser Bridge extension:
212212
| **xiaoe** | `courses` `detail` `catalog` `play-url` `content` |
213213
| **quark** | `ls` `mkdir` `mv` `rename` `rm` `save` `share-tree` |
214214

215-
79+ adapters in total — **[→ see all supported sites & commands](./docs/adapters/index.md)**
215+
87+ adapters in total — **[→ see all supported sites & commands](./docs/adapters/index.md)**
216216

217217
## CLI Hub
218218

@@ -349,7 +349,7 @@ See **[TESTING.md](./TESTING.md)** for how to run and write tests.
349349
- **"Extension not connected"** — Ensure the Browser Bridge extension is installed and **enabled** in `chrome://extensions` in Chrome or Chromium.
350350
- **"attach failed: Cannot access a chrome-extension:// URL"** — Another extension may be interfering. Try disabling other extensions temporarily.
351351
- **Empty data or 'Unauthorized' error** — Your Chrome/Chromium login session may have expired. Navigate to the target site and log in again.
352-
- **Node API errors** — Ensure Node.js >= 20. Some dependencies require modern Node APIs.
352+
- **Node API errors** — Ensure Node.js >= 21. Some features require `node:util` styleText (stable in Node 21+).
353353
- **Daemon issues** — Check status: `curl localhost:19825/status` · View logs: `curl localhost:19825/logs`
354354

355355
## Star History

README.zh-CN.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
OpenCLI 可以用同一套 CLI 做三类事情:
1212

13-
- **直接使用现成适配器**:B站、知乎、小红书、Twitter/X、Reddit、HackerNews 等 [79+ 站点](#内置命令) 开箱即用。
13+
- **直接使用现成适配器**:B站、知乎、小红书、Twitter/X、Reddit、HackerNews 等 [87+ 站点](#内置命令) 开箱即用。
1414
- **直接驱动浏览器**:用 `opencli browser` 让 AI Agent 实时点击、输入、提取、截图、检查页面状态。
1515
- **把新网站生成成 CLI**:通过 `explore``synthesize``generate``cascade` 从真实页面行为推导出新的适配器。
1616

@@ -23,7 +23,7 @@ OpenCLI 可以用同一套 CLI 做三类事情:
2323
- **输出稳定**:适配器命令返回固定结构,适合 shell、脚本、CI 和 AI Agent 工具调用。
2424
- **面向 AI Agent**`browser` 负责实时操作,`explore` 负责探索接口,`synthesize` 负责生成适配器,`cascade` 负责探测认证路径。
2525
- **运行成本低**:已有命令运行时不消耗模型 token。
26-
- **天然可扩展**:既能用内置能力,也能注册本地 CLI,或直接往 `clis/``.ts` 适配器。
26+
- **天然可扩展**:既能用内置能力,也能注册本地 CLI,或直接往 `clis/``.js` 适配器。
2727

2828
## 快速开始
2929

@@ -124,7 +124,7 @@ OpenCLI 不只是网站 CLI,还可以:
124124

125125
## 前置要求
126126

127-
- **Node.js**: >= 20.0.0
127+
- **Node.js**: >= 21.0.0
128128
- 浏览器型命令需要 Chrome 或 Chromium 处于运行中,并已登录目标网站
129129

130130
> **重要**:浏览器型命令直接复用你的 Chrome/Chromium 登录态。如果拿到空数据或出现权限类失败,先确认目标站点已经在浏览器里打开并完成登录。
@@ -262,7 +262,7 @@ npm link
262262
| **douyin** | `videos` `publish` `drafts` `draft` `delete` `stats` `profile` `update` `hashtag` `location` `activities` `collections` | 浏览器 |
263263
| **yuanbao** | `new` `ask` | 浏览器 |
264264

265-
79+ 适配器 — **[→ 查看完整命令列表](./docs/adapters/index.md)**
265+
87+ 适配器 — **[→ 查看完整命令列表](./docs/adapters/index.md)**
266266

267267
### 外部 CLI 枢纽
268268

@@ -460,7 +460,7 @@ opencli cascade https://api.example.com/data
460460
- **返回空数据,或者报错 "Unauthorized"**
461461
- Chrome/Chromium 里的登录态可能已经过期。请打开当前页面,在新标签页重新手工登录或刷新该页面。
462462
- **Node API 错误 (如 parseArgs, fs 等)**
463-
- 确保 Node.js 版本 `>= 20`
463+
- 确保 Node.js 版本 `>= 21``node:util``styleText` 需要 Node 21+)
464464
- **Daemon 问题**
465465
- 检查 daemon 状态:`curl localhost:19825/status`
466466
- 查看扩展日志:`curl localhost:19825/logs`

TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ E2E 与 smoke 都使用 `./.github/actions/setup-chrome` 准备真实 Chrome,
205205

206206
### Sharding
207207

208-
单元测试使用 vitest 内置 shard,并在 Node `20` / `22` 两个版本上运行
208+
单元测试使用 vitest 内置 shard,并在 Node `22` 上运行(项目要求 Node >= 21)
209209

210210
```yaml
211211
strategy:
212212
matrix:
213-
node-version: ['20', '22']
213+
node-version: ['22']
214214
shard: [1, 2]
215215
steps:
216216
- run: npx vitest run src/ --reporter=verbose --shard=${{ matrix.shard }}/2

docs/guide/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OpenCLI turns **any website** or **Electron app** into a command-line interface
1515
- **Account-safe** — Reuses Chrome's logged-in state; your credentials never leave the browser.
1616
- **AI Agent ready**`explore` discovers APIs, `synthesize` generates adapters, `cascade` finds auth strategies.
1717
- **Self-healing setup**`opencli doctor` auto-starts the daemon and diagnoses extension + live browser connectivity.
18-
- **Dynamic Loader** — Simply drop `.ts` adapters into the `clis/` folder for auto-registration.
18+
- **Dynamic Loader** — Simply drop `.js` adapters into the `clis/` folder for auto-registration.
1919
- **Dual-Engine Architecture** — Supports both declarative pipeline adapters and robust browser runtime TypeScript injections.
2020

2121
## Quick Start

docs/guide/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Requirements
44

5-
- **Node.js**: >= 20.0.0
5+
- **Node.js**: >= 21.0.0
66
- **Chrome** running and logged into the target site (for browser commands)
77

88
## Install via npm (Recommended)

docs/guide/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ OPENCLI_CDP_TARGET=detail.1688.com opencli 1688 item 841141931191 -f json
2525

2626
### Node API errors
2727

28-
- Make sure you are using **Node.js >= 20**. Some dependencies require modern Node APIs.
28+
- Make sure you are using **Node.js >= 21**. Some features require `node:util` styleText (stable in Node 21+).
2929
- Run `node --version` to verify.
3030

3131
### Daemon issues

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ features:
3131
details: "opencli doctor auto-starts the daemon and diagnoses extension + live browser connectivity."
3232
- icon: 📦
3333
title: Dynamic Loader
34-
details: Simply drop .ts adapters into the clis/ folder for auto-registration. Zero boilerplate.
34+
details: Simply drop .js adapters into the clis/ folder for auto-registration. Zero boilerplate.
3535
---

docs/zh/guide/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 系统要求
44

5-
- **Node.js**: >= 20.0.0
5+
- **Node.js**: >= 21.0.0
66
- **Chrome** 已运行并登录目标网站(浏览器命令需要)
77

88
## 通过 npm 安装(推荐)

0 commit comments

Comments
 (0)