@kairyou/agent-tools 0.2.0 → 0.3.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.
Files changed (33) hide show
  1. package/README.md +75 -95
  2. package/README.zh-CN.md +71 -92
  3. package/dist/vision/cli.mjs +13 -13
  4. package/dist/vision/mcp-server.mjs +12 -12
  5. package/{statusline/claude/statusline.mjs → integrations/statusline/claude-statusline.mjs} +3 -1
  6. package/integrations/usage/cli.mjs +27 -0
  7. package/{hooks/codex/usage-hook.mjs → integrations/usage/codex-hook.mjs} +1 -1
  8. package/{lib/usage.mjs → integrations/usage/core.mjs} +4 -0
  9. package/{plugins/opencode/usage-plugin.mjs → integrations/usage/opencode-plugin.mjs} +1 -1
  10. package/integrations/usage/skills/at-usage/SKILL.md +16 -0
  11. package/{plugins → integrations}/vision/mcp-server.mjs +4 -4
  12. package/package.json +5 -9
  13. package/scripts/build-vision.mjs +2 -2
  14. package/scripts/install.mjs +122 -88
  15. package/scripts/release.mjs +75 -5
  16. package/hooks/claude/.gitkeep +0 -1
  17. package/hooks/codex/.gitkeep +0 -1
  18. package/hooks/common/.gitkeep +0 -1
  19. package/hooks/opencode/.gitkeep +0 -1
  20. package/statusline/.gitkeep +0 -1
  21. package/statusline/codex/.gitkeep +0 -1
  22. /package/{plugins/opencode/usage-tui.mjs → integrations/usage/opencode-tui.mjs} +0 -0
  23. /package/{lib/vision → integrations/vision/lib}/cli.mjs +0 -0
  24. /package/{lib/vision → integrations/vision/lib}/config.mjs +0 -0
  25. /package/{lib/vision → integrations/vision/lib}/errors.mjs +0 -0
  26. /package/{lib/vision → integrations/vision/lib}/image-source.mjs +0 -0
  27. /package/{lib/vision → integrations/vision/lib}/inspect.mjs +0 -0
  28. /package/{lib/vision → integrations/vision/lib}/providers/anthropic-compatible.mjs +0 -0
  29. /package/{lib/vision → integrations/vision/lib}/providers/openai-compatible.mjs +0 -0
  30. /package/{lib/vision → integrations/vision/lib}/providers/shared.mjs +0 -0
  31. /package/{lib/vision → integrations/vision/lib}/rate-limit.mjs +0 -0
  32. /package/{lib/vision → integrations/vision/lib}/redact.mjs +0 -0
  33. /package/{plugins → integrations}/vision/skills/at-vision/SKILL.md +0 -0
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Agent Tools
2
2
 
3
- Reusable skills and runtime integrations for Codex, Claude Code, and opencode. This repository keeps each capability in predictable locations so projects can opt into only what they need.
3
+ Reusable Agent Skills, plus runtime integrations for Codex, Claude Code, and opencode.
4
4
 
5
5
  [中文](README.zh-CN.md)
6
6
 
7
- ## Directory Layout
7
+ ## Repository Structure
8
8
 
9
9
  ```text
10
10
  agent-tools/
11
11
  ├── .claude-plugin/ # Claude Code/plugin ecosystem manifest.
12
12
  ├── .codex-plugin/ # Codex plugin manifest.
13
- ├── hooks/ # Shared and agent-specific hook integrations.
14
- ├── plugins/ # Runtime plugins loaded by supported agents.
15
- └── vision/ # Cross-model image understanding (inspect_image MCP server + bundled at-vision skill).
16
- ├── scripts/ # Install, sync, validation, and maintenance scripts.
13
+ ├── integrations/ # Installable capabilities, one directory each; files named by agent + form.
14
+ ├── statusline/ # Claude Code command-backed statusLine script.
15
+ ├── usage/ # Provider usage (query core + codex hook, opencode plugins, CLI, at-usage skill template).
16
+ │ └── vision/ # Cross-model image understanding (inspect_image MCP server + at-vision skill).
17
17
  ├── skills/ # Reusable Agent Skills for CLI discovery and plugin manifests.
18
18
  │ ├── workflow/ # Workflow-oriented skills.
19
19
  │ │ ├── at-commit/ # Conventional Commit message skill.
@@ -21,9 +21,7 @@ agent-tools/
21
21
  │ │ └── at-simplify/ # Reduce complexity and duplication in changes.
22
22
  │ └── integrations/ # Skills that integrate external systems.
23
23
  │ └── at-zentao/ # ZenTao bug/task fixing workflow.
24
- ├── statusline/ # Statusline scripts/templates, grouped by agent.
25
- │ └── claude/ # Claude command-backed statusLine script + example config.
26
- └── lib/ # Shared implementation used by hooks, statuslines, and installers.
24
+ └── scripts/ # Install, sync, validation, and maintenance scripts.
27
25
  ```
28
26
 
29
27
  ## Skills
@@ -85,70 +83,27 @@ Usage:
85
83
 
86
84
  Config: `~/.agent-tools/config.jsonc` → `"zentao": { "url", "account", "password" }`. First run guides you; fill `password` in the file yourself (or env `ZENTAO_PASSWORD`), never in chat.
87
85
 
88
- ## Plugins
86
+ ## Integrations
89
87
 
90
- ### Vision (cross-model image understanding)
91
-
92
- Lets a main model that cannot see images ask a multimodal model specific questions about an image (local path or http(s) URL) and reason on from the answers. Typical uses: reading error screenshots, implementing UI from design mockups, locating the glitch in a bug-report screenshot. One installer capability bundling three parts: the `inspect_image` MCP stdio server, the `at-vision` policy skill, and a human diagnostic CLI.
93
-
94
- #### Install
95
-
96
- ```bash
97
- # One command per agent (or list several)
98
- npx -y @kairyou/agent-tools@latest vision -a claude
99
- npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
100
-
101
- # Preview or uninstall (uninstall keeps your vision provider config)
102
- npx -y @kairyou/agent-tools@latest vision -a claude --dry-run
103
- npx -y @kairyou/agent-tools@latest vision -a claude --uninstall
104
- ```
105
-
106
- Install atomically writes a prebuilt, self-contained MCP runtime to `~/.agent-tools/vision-runtime`, registers it per agent (Claude Code: `~/.claude.json`; Codex: a marker-delimited block in `~/.codex/config.toml`; OpenCode: `opencode.json`), and installs the `at-vision` skill into the agent's global skills directory (Claude Code: `~/.claude/skills`; Codex: `~/.agents/skills`; OpenCode: its config directory's `skills`). Installation does not download a second dependency tree; re-run the command to update. Uninstalling the last agent that references the shared runtime removes it while preserving the vision provider config.
107
-
108
- #### Configure
109
-
110
- `~/.agent-tools/config.jsonc` is the only config entry point:
111
-
112
- ```jsonc
113
- {
114
- "vision": {
115
- "provider": "openai-compatible", // or "anthropic-compatible"
116
- "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible: gateway root, /v1/messages is appended
117
- "model": "internal-vlm",
118
- "apiKey": { "env": "OPENAI_API_KEY" } // reuse an existing env var, or the key itself
119
- // optional: "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192,
120
- // "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
121
- }
122
- }
123
- ```
124
-
125
- `apiKey` takes the key itself, or `{ "env": "VARIABLE_NAME" }` to reuse an existing environment variable; omit it if your gateway needs no key.
126
- The runtime sends provider requests directly, so the API key never enters a shell command; user-facing errors redact it as `***`. `maxConcurrentRequests` and `maxRequestsPerMinute` are shared across local MCP and CLI processes.
127
- Image bytes are streamed into the provider's base64 JSON request without recompression; URL inputs use a private temporary file that is removed after each request.
128
-
129
- #### Use
130
-
131
- Pass images as file paths or URLs in your message. The agent prefers the `inspect_image` MCP tool and falls back to the installed local vision CLI when its model gateway cannot invoke MCP namespace tools. Do not paste screenshots directly: with a non-vision main model the paste fails with an API 400 before any tool runs — save the image and give its path instead.
132
-
133
- To diagnose the provider setup or test recognition quality manually:
88
+ Runtime capabilities, installed per agent:
134
89
 
135
90
  ```bash
136
- npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "What are the navbar background color and height?"
91
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
137
92
  ```
138
93
 
139
- ## Runtime integrations
94
+ `--dry-run` previews, `--uninstall` removes, and re-running the install command
95
+ updates.
140
96
 
141
- ### Claude Code
97
+ | Capability | Claude Code | Codex | OpenCode |
98
+ | --- | --- | --- | --- |
99
+ | `statusline` | ✓ | – | – |
100
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` command |
101
+ | `vision` | ✓ | ✓ | ✓ |
142
102
 
143
- #### Statusline
103
+ ### Statusline
144
104
 
145
105
  ```bash
146
- # Install or update
147
106
  npx -y @kairyou/agent-tools@latest statusline -a claude
148
-
149
- # Preview or uninstall
150
- npx -y @kairyou/agent-tools@latest statusline -a claude --dry-run
151
- npx -y @kairyou/agent-tools@latest statusline -a claude --uninstall
152
107
  ```
153
108
 
154
109
  The installer writes `statusLine` to `~/.claude/settings.json`. The default
@@ -165,67 +120,92 @@ To choose what appears, edit `statusline.fields` in
165
120
  `~/.agent-tools/config.jsonc`. The installer may add new default keys on update;
166
121
  it preserves top-of-file comments and existing values.
167
122
 
168
- ### Codex
123
+ ### Provider usage
169
124
 
170
- #### Provider usage hook
125
+ Shows the active API provider's balance / quota inside each agent.
171
126
 
172
127
  ```bash
173
- # Install or update
128
+ npx -y @kairyou/agent-tools@latest usage -a claude
174
129
  npx -y @kairyou/agent-tools@latest usage -a codex
175
-
176
- # Preview or uninstall
177
- npx -y @kairyou/agent-tools@latest usage -a codex --dry-run
178
- npx -y @kairyou/agent-tools@latest usage -a codex --uninstall
130
+ npx -y @kairyou/agent-tools@latest usage -a opencode
179
131
  ```
180
132
 
181
- The installer adds the hook to `UserPromptSubmit` and `Stop` in
182
- `~/.codex/hooks.json`. After installation, run `/hooks` inside Codex and approve
183
- the agent-tools usage hooks.
133
+ - **Claude Code** installs the `at-usage` skill into `~/.claude/skills`; invoke
134
+ `/at-usage` to show the current usage in the conversation.
135
+ - **Codex** — adds a hook to `UserPromptSubmit` and `Stop` in `~/.codex/hooks.json`
136
+ and the `at-usage` skill to `~/.agents/skills`. Run `/hooks` inside Codex once
137
+ to approve it. Hook output only appears in the Codex CLI; in clients that do
138
+ not show it (e.g. Paseo), invoke `$at-usage`.
139
+ - **OpenCode** — adds server and TUI plugins: usage refreshes when the session
140
+ goes idle and shows as a toast, and `/at-usage` shows the latest cached value.
141
+ Restart opencode after installing or updating.
184
142
 
185
143
  Output examples:
186
144
 
187
145
  ```text
188
146
  # Subscription / plan quota.
189
- warning: API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
147
+ API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
190
148
 
191
149
  # Wallet balance.
192
- warning: API | balance $362 | today $61.7 | 30d $566
150
+ API | balance $362 | today $61.7 | 30d $566
193
151
  ```
194
152
 
195
153
  Fields: `D/W/M` are daily/weekly/monthly spend against plan limits; `Exp` is
196
154
  the plan expiry; `balance` is wallet credit; `today` and `30d` are API spend.
197
155
 
198
- ### OpenCode
156
+ #### Supported gateways
199
157
 
200
- #### Provider usage plugin
158
+ Balance, quota, and plan usage queries support compatible Sub2API-like,
159
+ NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
201
160
 
202
- ```bash
203
- # Install or update
204
- npx -y @kairyou/agent-tools@latest usage -a opencode
161
+ ### Vision (cross-model image understanding)
205
162
 
206
- # Preview or uninstall
207
- npx -y @kairyou/agent-tools@latest usage -a opencode --dry-run
208
- npx -y @kairyou/agent-tools@latest usage -a opencode --uninstall
163
+ Lets a main model that cannot see images ask a multimodal model specific questions about an image (local path or http(s) URL) and reason on from the answers. Typical uses: reading error screenshots, implementing UI from design mockups, locating the glitch in a bug-report screenshot. One installer capability bundling three parts: the `inspect_image` MCP stdio server, the `at-vision` policy skill, and a human diagnostic CLI.
164
+
165
+ #### Install
166
+
167
+ ```bash
168
+ npx -y @kairyou/agent-tools@latest vision -a claude
169
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
209
170
  ```
210
171
 
211
- The installer adds global server and TUI plugins. After the active session
212
- becomes idle, the server plugin refreshes usage and shows it as a toast. The TUI
213
- plugin also registers `/at-usage` for the latest cached value. Restart opencode
214
- after installing or updating the plugins.
172
+ Uninstalling keeps your vision provider config. The installer registers the
173
+ `inspect_image` MCP server for each agent (Claude Code: `~/.claude.json`; Codex:
174
+ `~/.codex/config.toml`; OpenCode: `opencode.json`) and installs the `at-vision`
175
+ skill into the agent's skills directory.
215
176
 
216
- Toast example:
177
+ #### Configure
217
178
 
218
- ```text
219
- Provider usage
220
- balance $244 | today $45.8 | 30d $604
179
+ `~/.agent-tools/config.jsonc` is the only config entry point:
180
+
181
+ ```jsonc
182
+ {
183
+ "vision": {
184
+ "provider": "openai-compatible", // or "anthropic-compatible"
185
+ "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible: gateway root, /v1/messages is appended
186
+ "model": "internal-vlm",
187
+ "apiKey": { "env": "OPENAI_API_KEY" } // reuse an existing env var, or the key itself
188
+ // optional: "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192,
189
+ // "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
190
+ }
191
+ }
221
192
  ```
222
193
 
223
- ### Supported gateways
194
+ `apiKey` takes the key itself, or `{ "env": "VARIABLE_NAME" }` to reuse an existing environment variable; omit it if your gateway needs no key.
195
+ The runtime sends provider requests directly, so the API key never enters a shell command; user-facing errors redact it as `***`. `maxConcurrentRequests` and `maxRequestsPerMinute` are shared across local MCP and CLI processes.
196
+ Image bytes are streamed into the provider's base64 JSON request without recompression; URL inputs use a private temporary file that is removed after each request.
224
197
 
225
- Balance, quota, and plan usage queries support compatible Sub2API-like,
226
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
198
+ #### Use
199
+
200
+ Pass images as file paths or URLs in your message. The agent prefers the `inspect_image` MCP tool and falls back to the installed local vision CLI when its model gateway cannot invoke MCP namespace tools. Do not paste screenshots directly: with a non-vision main model the paste fails with an API 400 before any tool runs — save the image and give its path instead.
201
+
202
+ To diagnose the provider setup or test recognition quality manually:
203
+
204
+ ```bash
205
+ npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "What are the navbar background color and height?"
206
+ ```
227
207
 
228
- ### Run from Git
208
+ ## Run from Git
229
209
 
230
210
  To run directly from the repository, replace the npm package name with
231
211
  `github:kairyou/agent-tools` (Git required):
package/README.zh-CN.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # Agent Tools
2
2
 
3
- 面向 Codex、Claude Code 与 opencode 的可复用 skills 和 runtime integrations. 本仓库把各项能力放在可预期的位置; 不同项目可以只安装自己需要的部分.
3
+ 可复用的 Agent Skills, 以及面向 Codex、Claude Code 与 opencode runtime integrations.
4
4
 
5
- ## 目录结构
5
+ ## 仓库结构
6
6
 
7
7
  ```text
8
8
  agent-tools/
9
9
  ├── .claude-plugin/ # Claude Code/plugin 生态的 manifest。
10
10
  ├── .codex-plugin/ # Codex plugin manifest。
11
- ├── hooks/ # 通用 hook 逻辑及各 agent 的适配实现。
12
- ├── plugins/ # 由各 agent 加载的 runtime plugins.
11
+ ├── integrations/ # 可安装的 capability, 一个一目录; 文件按 agent + 形态命名.
12
+ ├── statusline/ # Claude Code command-backed statusLine 脚本.
13
+ │ ├── usage/ # Provider usage (查询核心 + codex hook, opencode plugins, CLI, at-usage skill 模板).
13
14
  │ └── vision/ # 跨模型识图(inspect_image MCP server + 内置 at-vision skill)。
14
- ├── scripts/ # 安装、同步、校验和仓库维护脚本。
15
15
  ├── skills/ # 可复用 Agent Skills,供 CLI 扫描和 plugin manifest 声明。
16
16
  │ ├── workflow/ # 工作流类 skills。
17
17
  │ │ ├── at-commit/ # 生成 Conventional Commits message.
@@ -19,9 +19,7 @@ agent-tools/
19
19
  │ │ └── at-simplify/ # 减少改动中的冗余和复杂度.
20
20
  │ └── integrations/ # 对接外部系统的 skills。
21
21
  │ └── at-zentao/ # 禅道 bug/task 修复工作流.
22
- ├── statusline/ # Statusline 配置片段/模板,按 agent 分组。
23
- │ └── claude/ # Claude command-backed statusLine 脚本和示例配置。
24
- └── lib/ # hooks、statusline、installer 复用的共享实现。
22
+ └── scripts/ # 安装、同步、校验和仓库维护脚本。
25
23
  ```
26
24
 
27
25
  ## Skills
@@ -83,70 +81,26 @@ npx -y skills@latest add kairyou/agent-tools --skill at-zentao -g -y
83
81
 
84
82
  配置: `~/.agent-tools/config.jsonc` → `"zentao": { "url", "account", "password" }`. 首次使用会引导; `password` 自己填进文件(或设环境变量 `ZENTAO_PASSWORD`), 不要发在对话里.
85
83
 
86
- ## Plugins
84
+ ## Integrations
87
85
 
88
- ### Vision(跨模型识图)
89
-
90
- 让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
91
-
92
- #### 安装
86
+ Runtime capability, 按 agent 选装:
93
87
 
94
88
  ```bash
95
- # 每个 agent 一条命令(也可以一次列多个)
96
- npx -y @kairyou/agent-tools@latest vision -a claude
97
- npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
98
-
99
- # 预览或卸载(卸载默认保留 vision provider 配置)
100
- npx -y @kairyou/agent-tools@latest vision -a claude --dry-run
101
- npx -y @kairyou/agent-tools@latest vision -a claude --uninstall
89
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
102
90
  ```
103
91
 
104
- 安装会把预构建的自包含 MCP runtime 原子写入 `~/.agent-tools/vision-runtime`, 为每个 agent 注册(Claude Code: `~/.claude.json`; Codex: `~/.codex/config.toml` 中带标记的独立块; OpenCode: `opencode.json`), 并把 `at-vision` skill 装入对应 agent 的全局 skills 目录(Claude Code: `~/.claude/skills`; Codex: `~/.agents/skills`; OpenCode: 配置目录下的 `skills`). 安装过程不再二次下载依赖; 更新 = 重新执行安装命令. 卸载最后一个引用该 runtime 的 agent 时会一并清理 runtime, 但保留 vision provider 配置.
92
+ `--dry-run` 预览, `--uninstall` 卸载, 重新执行安装命令即为更新.
105
93
 
106
- #### 配置
94
+ | Capability | Claude Code | Codex | OpenCode |
95
+ | --- | --- | --- | --- |
96
+ | `statusline` | ✓ | – | – |
97
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` 命令 |
98
+ | `vision` | ✓ | ✓ | ✓ |
107
99
 
108
- `~/.agent-tools/config.jsonc` 是唯一配置入口:
109
-
110
- ```jsonc
111
- {
112
- "vision": {
113
- "provider": "openai-compatible", // 或 "anthropic-compatible"
114
- "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible 填网关根地址, 会自动拼 /v1/messages
115
- "model": "internal-vlm",
116
- "apiKey": { "env": "OPENAI_API_KEY" } // 引用已有环境变量, 也可以直接填密钥
117
- // 可选: "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192,
118
- // "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
119
- }
120
- }
121
- ```
122
-
123
- `apiKey` 可直接填密钥, 或用 `{ "env": "VARIABLE_NAME" }` 引用已有环境变量; 网关不需要密钥时可省略.
124
- Provider 请求由 runtime 直接发送, API key 不进入 shell 命令; 对外错误会将 key 脱敏为 `***`. `maxConcurrentRequests` 和 `maxRequestsPerMinute` 在本机的 MCP/CLI 进程之间共享.
125
- 图片字节会无损地流式编码到 Provider 的 base64 JSON 请求中, 不做重压缩; URL 图片使用私有临时文件, 每次请求结束后自动删除.
126
-
127
- #### 使用
128
-
129
- 在消息里给出图片的文件路径或 URL 即可. Agent 优先调用 MCP 的 `inspect_image`; 模型网关不支持 MCP namespace tools 时, 改用已安装的本地 vision CLI. 不要直接粘贴截图: 主模型不支持图片时, 粘贴会在到达工具前就报 API 400 — 保存成文件再给路径.
130
-
131
- 人工排查配置或测试识别质量时可用:
100
+ ### Statusline
132
101
 
133
102
  ```bash
134
- npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "导航栏的背景色和高度是多少"
135
- ```
136
-
137
- ## Runtime integrations
138
-
139
- ### Claude Code
140
-
141
- #### Statusline
142
-
143
- ```bash
144
- # 安装或更新
145
103
  npx -y @kairyou/agent-tools@latest statusline -a claude
146
-
147
- # 预览或卸载
148
- npx -y @kairyou/agent-tools@latest statusline -a claude --dry-run
149
- npx -y @kairyou/agent-tools@latest statusline -a claude --uninstall
150
104
  ```
151
105
 
152
106
  安装器会把 `statusLine` 写入 `~/.claude/settings.json`. 默认显示:
@@ -161,65 +115,90 @@ npx -y @kairyou/agent-tools@latest statusline -a claude --uninstall
161
115
  如需控制显示项, 修改 `~/.agent-tools/config.jsonc` 里的
162
116
  `statusline.fields`. 安装器更新时可能补充新的默认键; 文件顶部注释和已有值会保留.
163
117
 
164
- ### Codex
118
+ ### Provider usage
165
119
 
166
- #### Provider usage hook
120
+ 在各 agent 内显示当前 API provider 的余额/额度.
167
121
 
168
122
  ```bash
169
- # 安装或更新
123
+ npx -y @kairyou/agent-tools@latest usage -a claude
170
124
  npx -y @kairyou/agent-tools@latest usage -a codex
171
-
172
- # 预览或卸载
173
- npx -y @kairyou/agent-tools@latest usage -a codex --dry-run
174
- npx -y @kairyou/agent-tools@latest usage -a codex --uninstall
125
+ npx -y @kairyou/agent-tools@latest usage -a opencode
175
126
  ```
176
127
 
177
- 安装器会把 hook 添加到 `~/.codex/hooks.json` `UserPromptSubmit`
178
- `Stop`. 安装后, 在 Codex 里运行 `/hooks` 并批准 agent-tools usage hooks.
128
+ - **Claude Code** `at-usage` skill 装入 `~/.claude/skills`; 调用
129
+ `/at-usage` 即可在对话中显示当前用量.
130
+ - **Codex** — 把 hook 添加到 `~/.codex/hooks.json` 的 `UserPromptSubmit` 和
131
+ `Stop`, 并把 `at-usage` skill 装入 `~/.agents/skills`. 安装后在 Codex 里运行
132
+ `/hooks` 批准一次. Hook 输出只在 Codex CLI 里显示; Paseo 等不显示 hook 输出的
133
+ 前端, 可调用 `$at-usage` 按需查询.
134
+ - **OpenCode** — 添加 server plugin 和 TUI plugin: session 进入 idle 后自动刷新
135
+ usage 并以 toast 显示, `/at-usage` 查看最新缓存值. 安装或更新后需要重启 opencode.
179
136
 
180
137
  显示效果示例:
181
138
 
182
139
  ```text
183
140
  # 订阅/套餐额度.
184
- warning: API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
141
+ API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
185
142
 
186
143
  # 钱包余额.
187
- warning: API | balance $362 | today $61.7 | 30d $566
144
+ API | balance $362 | today $61.7 | 30d $566
188
145
  ```
189
146
 
190
147
  字段含义: `D/W/M` 是日/周/月套餐消耗与上限, `Exp` 是套餐到期日,
191
148
  `balance` 是钱包余额, `today` / `30d` 是今日与近 30 天 API 消耗.
192
149
 
193
- ### OpenCode
150
+ #### 支持的网关
194
151
 
195
- #### Provider usage plugin
152
+ 余额, 额度和套餐用量查询支持兼容 Sub2API-like,
153
+ NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
196
154
 
197
- ```bash
198
- # 安装或更新
199
- npx -y @kairyou/agent-tools@latest usage -a opencode
155
+ ### Vision(跨模型识图)
200
156
 
201
- # 预览或卸载
202
- npx -y @kairyou/agent-tools@latest usage -a opencode --dry-run
203
- npx -y @kairyou/agent-tools@latest usage -a opencode --uninstall
157
+ 让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
158
+
159
+ #### 安装
160
+
161
+ ```bash
162
+ npx -y @kairyou/agent-tools@latest vision -a claude
163
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
204
164
  ```
205
165
 
206
- 安装器会添加全局 server plugin TUI plugin. 当前 session 进入 idle 后, server
207
- plugin 会刷新 usage 并通过 toast 显示; TUI plugin 还会注册 `/at-usage`, 用于查看最新
208
- 缓存值. 安装或更新 plugin 后需要重启 opencode.
166
+ 卸载默认保留 vision provider 配置. 安装器会为每个 agent 注册 `inspect_image`
167
+ MCP server (Claude Code: `~/.claude.json`; Codex: `~/.codex/config.toml`;
168
+ OpenCode: `opencode.json`), 并把 `at-vision` skill 装入对应 agent 的 skills 目录.
209
169
 
210
- 显示效果示例:
170
+ #### 配置
211
171
 
212
- ```text
213
- Provider usage
214
- balance $244 | today $45.8 | 30d $604
172
+ `~/.agent-tools/config.jsonc` 是唯一配置入口:
173
+
174
+ ```jsonc
175
+ {
176
+ "vision": {
177
+ "provider": "openai-compatible", // 或 "anthropic-compatible"
178
+ "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible 填网关根地址, 会自动拼 /v1/messages
179
+ "model": "internal-vlm",
180
+ "apiKey": { "env": "OPENAI_API_KEY" } // 引用已有环境变量, 也可以直接填密钥
181
+ // 可选: "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192,
182
+ // "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
183
+ }
184
+ }
215
185
  ```
216
186
 
217
- ### 支持的网关
187
+ `apiKey` 可直接填密钥, 或用 `{ "env": "VARIABLE_NAME" }` 引用已有环境变量; 网关不需要密钥时可省略.
188
+ Provider 请求由 runtime 直接发送, API key 不进入 shell 命令; 对外错误会将 key 脱敏为 `***`. `maxConcurrentRequests` 和 `maxRequestsPerMinute` 在本机的 MCP/CLI 进程之间共享.
189
+ 图片字节会无损地流式编码到 Provider 的 base64 JSON 请求中, 不做重压缩; URL 图片使用私有临时文件, 每次请求结束后自动删除.
218
190
 
219
- 余额, 额度和套餐用量查询支持兼容 Sub2API-like,
220
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
191
+ #### 使用
192
+
193
+ 在消息里给出图片的文件路径或 URL 即可. Agent 优先调用 MCP 的 `inspect_image`; 模型网关不支持 MCP namespace tools 时, 改用已安装的本地 vision CLI. 不要直接粘贴截图: 主模型不支持图片时, 粘贴会在到达工具前就报 API 400 — 保存成文件再给路径.
194
+
195
+ 人工排查配置或测试识别质量时可用:
196
+
197
+ ```bash
198
+ npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "导航栏的背景色和高度是多少"
199
+ ```
221
200
 
222
- ### 从 Git 运行
201
+ ## 从 Git 运行
223
202
 
224
203
  如需直接使用仓库版本,可将 npm 包名替换为 `github:kairyou/agent-tools`(本机需已安装 Git):
225
204
 
@@ -1,13 +1,13 @@
1
- // lib/vision/cli.mjs
1
+ // integrations/vision/lib/cli.mjs
2
2
  import fs4 from "node:fs";
3
3
  import path5 from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
- // lib/vision/inspect.mjs
6
+ // integrations/vision/lib/inspect.mjs
7
7
  import crypto3 from "node:crypto";
8
8
  import path4 from "node:path";
9
9
 
10
- // lib/vision/config.mjs
10
+ // integrations/vision/lib/config.mjs
11
11
  import fs from "node:fs";
12
12
  import os from "node:os";
13
13
  import path from "node:path";
@@ -871,7 +871,7 @@ var ParseErrorCode;
871
871
  ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
872
872
  })(ParseErrorCode || (ParseErrorCode = {}));
873
873
 
874
- // lib/vision/errors.mjs
874
+ // integrations/vision/lib/errors.mjs
875
875
  var ERROR_CODES = Object.freeze({
876
876
  CONFIG: "config_error",
877
877
  INPUT: "input_error",
@@ -899,7 +899,7 @@ function toVisionError(err, fallbackCode = ERROR_CODES.PROVIDER_HTTP) {
899
899
  return new VisionError(fallbackCode, message, { cause: err });
900
900
  }
901
901
 
902
- // lib/vision/config.mjs
902
+ // integrations/vision/lib/config.mjs
903
903
  var PROVIDERS = Object.freeze(["openai-compatible", "anthropic-compatible"]);
904
904
  var CONFIG_DEFAULTS = Object.freeze({
905
905
  timeoutMs: 3e4,
@@ -1037,7 +1037,7 @@ function loadVisionConfig({ file, env = process.env } = {}) {
1037
1037
  };
1038
1038
  }
1039
1039
 
1040
- // lib/vision/image-source.mjs
1040
+ // integrations/vision/lib/image-source.mjs
1041
1041
  import fs2 from "node:fs";
1042
1042
  import os2 from "node:os";
1043
1043
  import path2 from "node:path";
@@ -1285,7 +1285,7 @@ async function loadImageSource(source, { maxImageBytes, timeoutMs, fetchImpl } =
1285
1285
  throw new VisionError(ERROR_CODES.INPUT, `Unsupported image_source.type: ${JSON.stringify(source.type)}`);
1286
1286
  }
1287
1287
 
1288
- // lib/vision/rate-limit.mjs
1288
+ // integrations/vision/lib/rate-limit.mjs
1289
1289
  import crypto from "node:crypto";
1290
1290
  import fs3 from "node:fs";
1291
1291
  import path3 from "node:path";
@@ -1442,7 +1442,7 @@ function createLimiter(config, now = Date.now, { stateFile = null } = {}) {
1442
1442
  return stateFile ? createSharedLimiter(config, now, stateFile) : createProcessLimiter(config, now);
1443
1443
  }
1444
1444
 
1445
- // lib/vision/redact.mjs
1445
+ // integrations/vision/lib/redact.mjs
1446
1446
  var MASK = "***";
1447
1447
  function redactSecrets(text, secrets) {
1448
1448
  if (typeof text !== "string" || text.length === 0) return text;
@@ -1454,7 +1454,7 @@ function redactSecrets(text, secrets) {
1454
1454
  return out;
1455
1455
  }
1456
1456
 
1457
- // lib/vision/providers/shared.mjs
1457
+ // integrations/vision/lib/providers/shared.mjs
1458
1458
  import crypto2 from "node:crypto";
1459
1459
  async function* encodeBase64(readable) {
1460
1460
  let carry = Buffer.alloc(0);
@@ -1667,7 +1667,7 @@ async function postJson({ url, headers, body, timeoutMs, fetchImpl, providerLabe
1667
1667
  }
1668
1668
  }
1669
1669
 
1670
- // lib/vision/providers/anthropic-compatible.mjs
1670
+ // integrations/vision/lib/providers/anthropic-compatible.mjs
1671
1671
  function messagesUrl(baseUrl) {
1672
1672
  return baseUrl.endsWith("/v1") ? `${baseUrl}/messages` : `${baseUrl}/v1/messages`;
1673
1673
  }
@@ -1718,7 +1718,7 @@ async function inspectWithAnthropicCompatible({ config, image, questions, fetchI
1718
1718
  return normalizeAnswers(text, questions);
1719
1719
  }
1720
1720
 
1721
- // lib/vision/providers/openai-compatible.mjs
1721
+ // integrations/vision/lib/providers/openai-compatible.mjs
1722
1722
  function replyText2(json) {
1723
1723
  const message = json?.choices?.[0]?.message;
1724
1724
  if (typeof message?.content === "string") return message.content;
@@ -1765,7 +1765,7 @@ async function inspectWithOpenAICompatible({ config, image, questions, fetchImpl
1765
1765
  return normalizeAnswers(text, questions);
1766
1766
  }
1767
1767
 
1768
- // lib/vision/inspect.mjs
1768
+ // integrations/vision/lib/inspect.mjs
1769
1769
  var PROVIDER_IMPL = {
1770
1770
  "openai-compatible": inspectWithOpenAICompatible,
1771
1771
  "anthropic-compatible": inspectWithAnthropicCompatible
@@ -1849,7 +1849,7 @@ function createVisionService({ config, fetchImpl, now, limiterStateFile } = {})
1849
1849
  return { config: resolved, inspect };
1850
1850
  }
1851
1851
 
1852
- // lib/vision/cli.mjs
1852
+ // integrations/vision/lib/cli.mjs
1853
1853
  function printHelp() {
1854
1854
  const lines = [];
1855
1855
  for (const line of fs4.readFileSync(fileURLToPath(import.meta.url), "utf8").split("\n")) {