web-probe-cli 0.1.0
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 +162 -0
- package/dist/index.js +1641 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
- package/src/skill/SKILL.md +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# web-probe
|
|
2
|
+
|
|
3
|
+
> AI 浏览器自动化 CLI 工具 — 将 Chrome CDP 管理、页面分析、截图、自动化操作封装为单一命令行入口。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 全局安装(推荐)
|
|
9
|
+
npm install -g web-probe-cli
|
|
10
|
+
|
|
11
|
+
# 或使用 npx 免安装执行
|
|
12
|
+
npx --yes web-probe-cli doctor
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. 检查环境
|
|
19
|
+
web-probe doctor
|
|
20
|
+
|
|
21
|
+
# 2. 注入 Skill 到 AI 工具(自动检测已安装的工具)
|
|
22
|
+
web-probe skill install
|
|
23
|
+
|
|
24
|
+
# 3. 启动 Chrome 调试端口
|
|
25
|
+
web-probe chrome start
|
|
26
|
+
|
|
27
|
+
# 4. 查看标签页
|
|
28
|
+
web-probe tabs
|
|
29
|
+
|
|
30
|
+
# 5. 截图 / 分析页面
|
|
31
|
+
web-probe shot <tabId>
|
|
32
|
+
web-probe inspect <tabId>
|
|
33
|
+
|
|
34
|
+
# 6. 用完关闭
|
|
35
|
+
web-probe chrome stop
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 命令一览
|
|
39
|
+
|
|
40
|
+
### 环境管理
|
|
41
|
+
|
|
42
|
+
| 命令 | 说明 |
|
|
43
|
+
|------|------|
|
|
44
|
+
| `web-probe doctor` | 环境诊断,检查 Node.js / Chrome / Playwright / AI 工具 Skill 状态 |
|
|
45
|
+
| `web-probe setup` | 一键检测环境依赖 |
|
|
46
|
+
| `web-probe skill install` | 自动检测 AI 工具并交互式注入 Skill |
|
|
47
|
+
|
|
48
|
+
### Chrome 调试端口
|
|
49
|
+
|
|
50
|
+
| 命令 | 说明 |
|
|
51
|
+
|------|------|
|
|
52
|
+
| `web-probe chrome start [--port <N>]` | 启动调试端口(默认随机 20000-29999) |
|
|
53
|
+
| `web-probe chrome stop` | 关闭调试端口(Chrome 本体不受影响) |
|
|
54
|
+
| `web-probe chrome status` | 查看调试端口状态 |
|
|
55
|
+
| `web-probe chrome restart` | 重启调试(生成新端口) |
|
|
56
|
+
|
|
57
|
+
### 页面操作
|
|
58
|
+
|
|
59
|
+
| 命令 | 说明 |
|
|
60
|
+
|------|------|
|
|
61
|
+
| `web-probe tabs` | 列出所有标签页 |
|
|
62
|
+
| `web-probe inspect <tabId>` | 提取页面完整结构(JSON) |
|
|
63
|
+
| `web-probe shot <tabId\|url> [-o path]` | 截图 |
|
|
64
|
+
| `web-probe eval <tabId> <js>` | 执行 JavaScript |
|
|
65
|
+
| `web-probe click <tabId> <selector>` | 点击元素 |
|
|
66
|
+
| `web-probe type <tabId> <selector> <text>` | 输入文字 |
|
|
67
|
+
| `web-probe nav <tabId> <url>` | 导航到 URL |
|
|
68
|
+
| `web-probe html <tabId> [selector]` | 提取 HTML |
|
|
69
|
+
|
|
70
|
+
### 通用选项
|
|
71
|
+
|
|
72
|
+
所有命令支持 `--json` 参数输出 JSON 格式,便于 AI 解析。
|
|
73
|
+
|
|
74
|
+
## 支持的 AI 工具
|
|
75
|
+
|
|
76
|
+
`web-probe skill install` 自动检测并注入 Skill 到以下工具:
|
|
77
|
+
|
|
78
|
+
| AI 工具 | Skill 路径 | 格式 |
|
|
79
|
+
|---------|-----------|------|
|
|
80
|
+
| Cursor | `~/.cursor/skills/web-probe/SKILL.md` | SKILL.md |
|
|
81
|
+
| Claude Code | `~/.claude/skills/web-probe/SKILL.md` | SKILL.md |
|
|
82
|
+
| Codex (OpenAI) | `~/.codex/skills/web-probe/SKILL.md` | SKILL.md |
|
|
83
|
+
| Agents (通用标准) | `~/.agents/skills/web-probe/SKILL.md` | SKILL.md |
|
|
84
|
+
| OpenCode | `~/.config/opencode/skills/web-probe/SKILL.md` | SKILL.md |
|
|
85
|
+
| Windsurf | `~/.codeium/windsurf/web-probe-rules.md` | Rules |
|
|
86
|
+
| GitHub Copilot | `~/.github/agents/web-probe.md` | Agents MD |
|
|
87
|
+
| Trae | `~/.trae/rules/web-probe.md` | Rules |
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 自动检测 + 交互式注入
|
|
91
|
+
web-probe skill install
|
|
92
|
+
|
|
93
|
+
# 跳过确认
|
|
94
|
+
web-probe skill install --yes
|
|
95
|
+
|
|
96
|
+
# 指定单个工具
|
|
97
|
+
web-probe skill install --target cursor
|
|
98
|
+
web-probe skill install --target claude-code
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 工作原理
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
AI Agent (Cursor / Claude Code / Codex / OpenCode / ...)
|
|
105
|
+
└→ 读取 SKILL.md(了解可用命令 + 检测 CLI 可用性)
|
|
106
|
+
└→ 通过 Shell 调用 web-probe <command>
|
|
107
|
+
└→ 解析 stdout (JSON) 获取结果
|
|
108
|
+
│
|
|
109
|
+
▼
|
|
110
|
+
web-probe CLI
|
|
111
|
+
├─ Chrome 管理器:端口随机化、自动发现、生命周期管理
|
|
112
|
+
├─ 页面操作引擎:截图、JS 执行、DOM 提取、点击/输入
|
|
113
|
+
├─ AI 工具管理:8 工具检测 + 交互式 Skill 注入
|
|
114
|
+
└─ 底层引擎:chrome-remote-interface (CDP) + Playwright
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 安全特性
|
|
118
|
+
|
|
119
|
+
- **端口随机化**:每次启动生成 20000-29999 范围的随机端口
|
|
120
|
+
- **自动超时**:30 分钟无活动自动关闭调试端口
|
|
121
|
+
- **localhost 限制**:CDP 端口仅绑定 127.0.0.1
|
|
122
|
+
- **Skill 无代码**:Skill 文件只包含命令说明,不含可执行内容
|
|
123
|
+
- **状态文件权限**:`~/.web-probe/state.json` 设为 0600
|
|
124
|
+
|
|
125
|
+
## 开发
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 安装依赖
|
|
129
|
+
npm install
|
|
130
|
+
|
|
131
|
+
# 开发模式(监听变更)
|
|
132
|
+
npm run dev
|
|
133
|
+
|
|
134
|
+
# 构建
|
|
135
|
+
npm run build
|
|
136
|
+
|
|
137
|
+
# 类型检查
|
|
138
|
+
npm run typecheck
|
|
139
|
+
|
|
140
|
+
# 本地全局链接
|
|
141
|
+
npm link
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 技术栈
|
|
145
|
+
|
|
146
|
+
- **CLI 框架**:Commander.js
|
|
147
|
+
- **CDP 客户端**:chrome-remote-interface
|
|
148
|
+
- **截图引擎**:Playwright Core(不下载浏览器,使用系统 Chrome)
|
|
149
|
+
- **构建工具**:tsup(ESM 单文件打包,~49KB)
|
|
150
|
+
- **语言**:TypeScript
|
|
151
|
+
|
|
152
|
+
## 平台支持
|
|
153
|
+
|
|
154
|
+
| 平台 | 状态 |
|
|
155
|
+
|------|------|
|
|
156
|
+
| macOS | ✅ 完整支持 |
|
|
157
|
+
| Linux | ⚠️ 基础支持 |
|
|
158
|
+
| Windows | ⚠️ 实验性 |
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT
|