@kairyou/agent-tools 0.2.0 → 0.4.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 (40) hide show
  1. package/README.md +112 -115
  2. package/README.zh-CN.md +108 -115
  3. package/dist/statusline/claude-statusline.mjs +355 -0
  4. package/dist/usage/cli.mjs +25 -0
  5. package/dist/usage/codex-hook.mjs +144 -0
  6. package/dist/usage/core.mjs +1054 -0
  7. package/dist/usage/opencode-plugin.mjs +80 -0
  8. package/dist/usage/opencode-tui.mjs +46 -0
  9. package/dist/vision/cli.mjs +13 -13
  10. package/dist/vision/mcp-server.mjs +12 -12
  11. package/{statusline/claude/statusline.mjs → integrations/statusline/claude-statusline.mjs} +33 -2
  12. package/integrations/usage/cli.mjs +27 -0
  13. package/{hooks/codex/usage-hook.mjs → integrations/usage/codex-hook.mjs} +1 -1
  14. package/{lib/usage.mjs → integrations/usage/core.mjs} +34 -1
  15. package/{plugins/opencode/usage-plugin.mjs → integrations/usage/opencode-plugin.mjs} +1 -1
  16. package/integrations/usage/skills/at-usage/SKILL.md +16 -0
  17. package/{plugins → integrations}/vision/mcp-server.mjs +4 -4
  18. package/package.json +8 -12
  19. package/scripts/build.mjs +65 -0
  20. package/scripts/install.mjs +135 -90
  21. package/scripts/release.mjs +75 -5
  22. package/hooks/claude/.gitkeep +0 -1
  23. package/hooks/codex/.gitkeep +0 -1
  24. package/hooks/common/.gitkeep +0 -1
  25. package/hooks/opencode/.gitkeep +0 -1
  26. package/scripts/build-vision.mjs +0 -35
  27. package/statusline/.gitkeep +0 -1
  28. package/statusline/codex/.gitkeep +0 -1
  29. /package/{plugins/opencode/usage-tui.mjs → integrations/usage/opencode-tui.mjs} +0 -0
  30. /package/{lib/vision → integrations/vision/lib}/cli.mjs +0 -0
  31. /package/{lib/vision → integrations/vision/lib}/config.mjs +0 -0
  32. /package/{lib/vision → integrations/vision/lib}/errors.mjs +0 -0
  33. /package/{lib/vision → integrations/vision/lib}/image-source.mjs +0 -0
  34. /package/{lib/vision → integrations/vision/lib}/inspect.mjs +0 -0
  35. /package/{lib/vision → integrations/vision/lib}/providers/anthropic-compatible.mjs +0 -0
  36. /package/{lib/vision → integrations/vision/lib}/providers/openai-compatible.mjs +0 -0
  37. /package/{lib/vision → integrations/vision/lib}/providers/shared.mjs +0 -0
  38. /package/{lib/vision → integrations/vision/lib}/rate-limit.mjs +0 -0
  39. /package/{lib/vision → integrations/vision/lib}/redact.mjs +0 -0
  40. /package/{plugins → integrations}/vision/skills/at-vision/SKILL.md +0 -0
package/README.md CHANGED
@@ -1,30 +1,10 @@
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 and installable integrations statusline, provider usage, and vision for Codex, Claude Code, and opencode.
4
4
 
5
- [中文](README.zh-CN.md)
6
-
7
- ## Directory Layout
5
+ Requires Node.js >= 22.
8
6
 
9
- ```text
10
- agent-tools/
11
- ├── .claude-plugin/ # Claude Code/plugin ecosystem manifest.
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.
17
- ├── skills/ # Reusable Agent Skills for CLI discovery and plugin manifests.
18
- │ ├── workflow/ # Workflow-oriented skills.
19
- │ │ ├── at-commit/ # Conventional Commit message skill.
20
- │ │ ├── at-review/ # Review changes for bugs and regressions.
21
- │ │ └── at-simplify/ # Reduce complexity and duplication in changes.
22
- │ └── integrations/ # Skills that integrate external systems.
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.
27
- ```
7
+ [中文](README.zh-CN.md)
28
8
 
29
9
  ## Skills
30
10
 
@@ -85,70 +65,29 @@ Usage:
85
65
 
86
66
  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
67
 
88
- ## Plugins
89
-
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
- ```
68
+ ## Integrations
124
69
 
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:
70
+ Runtime capabilities, installed per agent:
134
71
 
135
72
  ```bash
136
- npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "What are the navbar background color and height?"
73
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
137
74
  ```
138
75
 
139
- ## Runtime integrations
76
+ `--dry-run` previews, `--uninstall` unwires the integration from the agent, and
77
+ re-running the install command updates. The installer only touches config
78
+ entries it wrote itself; shared files under `~/.agent-tools` are kept on
79
+ uninstall.
140
80
 
141
- ### Claude Code
81
+ | Capability | Claude Code | Codex | OpenCode |
82
+ | --- | --- | --- | --- |
83
+ | `statusline` | ✓ | – | – |
84
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` command |
85
+ | `vision` | ✓ | ✓ | ✓ |
142
86
 
143
- #### Statusline
87
+ ### Statusline
144
88
 
145
89
  ```bash
146
- # Install or update
147
90
  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
91
  ```
153
92
 
154
93
  The installer writes `statusLine` to `~/.claude/settings.json`. The default
@@ -165,67 +104,110 @@ To choose what appears, edit `statusline.fields` in
165
104
  `~/.agent-tools/config.jsonc`. The installer may add new default keys on update;
166
105
  it preserves top-of-file comments and existing values.
167
106
 
168
- ### Codex
107
+ ### Provider usage
169
108
 
170
- #### Provider usage hook
109
+ For API relay / gateway setups: shows the relay's balance / quota inside the
110
+ agent, so when you pay per use or have plan limits you always know how much you
111
+ have spent and how much is left — without opening the gateway console.
112
+ Works with compatible Sub2API-like,
113
+ NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
171
114
 
172
115
  ```bash
173
- # Install or update
116
+ npx -y @kairyou/agent-tools@latest usage -a claude
174
117
  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
118
+ npx -y @kairyou/agent-tools@latest usage -a opencode
179
119
  ```
180
120
 
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.
121
+ - **Claude Code** installs the `at-usage` skill into `~/.claude/skills`; invoke
122
+ `/at-usage` to show the current usage in the conversation.
123
+ - **Codex** — adds a hook to `UserPromptSubmit` and `Stop` in `~/.codex/hooks.json`
124
+ and the `at-usage` skill to `~/.agents/skills`. Run `/hooks` inside Codex once
125
+ to approve it. The Codex CLI displays hook output; some clients (e.g. Paseo)
126
+ currently do not — invoke `$at-usage` there.
127
+ - **OpenCode** — adds server and TUI plugins: usage refreshes when the session
128
+ goes idle and shows as a toast, and `/at-usage` shows the latest cached value.
129
+ Restart opencode after installing or updating.
130
+
131
+ The relay endpoint is auto-discovered — Codex: the active provider's `base_url`
132
+ and key from `~/.codex/config.toml` / `auth.json`; Claude Code:
133
+ `ANTHROPIC_BASE_URL` plus `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY`.
134
+ Official (non-relay) endpoints are skipped. If it reports
135
+ `Provider usage is unavailable.`, point it at the relay explicitly —
136
+ `PROVIDER_USAGE_BASE_URL` / `PROVIDER_USAGE_API_KEY` env vars override the
137
+ endpoint and key — and tune `providerUsage` in `~/.agent-tools/config.jsonc`:
138
+
139
+ ```jsonc
140
+ {
141
+ "providerUsage": {
142
+ "preset": "auto", // sub2api | new-api | veloera | anyrouter | openrouter | ...
143
+ "userId": "", // some NewAPI/Veloera panels require your panel user id
144
+ "days": 30, // spend window for the "30d" field (max 90)
145
+ "debug": false // true: log probes to ~/.agent-tools/logs/usage-debug.log
146
+ }
147
+ }
148
+ ```
184
149
 
185
150
  Output examples:
186
151
 
187
152
  ```text
188
- # Subscription / plan quota.
189
- warning: API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
153
+ # Relay plan quota.
154
+ API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
190
155
 
191
156
  # Wallet balance.
192
- warning: API | balance $362 | today $61.7 | 30d $566
157
+ API | balance $362 | today $61.7 | 30d $566
193
158
  ```
194
159
 
195
160
  Fields: `D/W/M` are daily/weekly/monthly spend against plan limits; `Exp` is
196
161
  the plan expiry; `balance` is wallet credit; `today` and `30d` are API spend.
197
162
 
198
- ### OpenCode
163
+ ### Vision (cross-model image understanding)
164
+
165
+ 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.
199
166
 
200
- #### Provider usage plugin
167
+ #### Install
201
168
 
202
169
  ```bash
203
- # Install or update
204
- npx -y @kairyou/agent-tools@latest usage -a opencode
205
-
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
170
+ npx -y @kairyou/agent-tools@latest vision -a claude
171
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
209
172
  ```
210
173
 
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.
174
+ Uninstalling keeps your vision provider config. The installer registers the
175
+ `inspect_image` MCP server for each agent (Claude Code: `~/.claude.json`; Codex:
176
+ `~/.codex/config.toml`; OpenCode: `opencode.json`) and installs the `at-vision`
177
+ skill into the agent's skills directory.
215
178
 
216
- Toast example:
179
+ #### Configure
217
180
 
218
- ```text
219
- Provider usage
220
- balance $244 | today $45.8 | 30d $604
181
+ `~/.agent-tools/config.jsonc` is the only config entry point:
182
+
183
+ ```jsonc
184
+ {
185
+ "vision": {
186
+ "provider": "openai-compatible", // or "anthropic-compatible"
187
+ "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible: gateway root, /v1/messages is appended
188
+ "model": "internal-vlm",
189
+ "apiKey": { "env": "OPENAI_API_KEY" } // reuse an existing env var, or the key itself
190
+ // , "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192
191
+ // , "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
192
+ }
193
+ }
221
194
  ```
222
195
 
223
- ### Supported gateways
196
+ `apiKey` takes the key itself, or `{ "env": "VARIABLE_NAME" }` to reuse an existing environment variable; omit it if your gateway needs no key.
197
+ 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.
198
+ 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
199
 
225
- Balance, quota, and plan usage queries support compatible Sub2API-like,
226
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
200
+ #### Use
201
+
202
+ 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.
203
+
204
+ To diagnose the provider setup or test recognition quality manually:
227
205
 
228
- ### Run from Git
206
+ ```bash
207
+ npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "What are the navbar background color and height?"
208
+ ```
209
+
210
+ ## Run from Git
229
211
 
230
212
  To run directly from the repository, replace the npm package name with
231
213
  `github:kairyou/agent-tools` (Git required):
@@ -234,6 +216,26 @@ To run directly from the repository, replace the npm package name with
234
216
  npx -y github:kairyou/agent-tools usage -a codex
235
217
  ```
236
218
 
219
+ ## Repository Structure
220
+
221
+ ```text
222
+ agent-tools/
223
+ ├── .claude-plugin/ # Claude Code/plugin ecosystem manifest.
224
+ ├── .codex-plugin/ # Codex plugin manifest.
225
+ ├── integrations/ # Installable capabilities, one directory each.
226
+ │ ├── statusline/ # Agent status line: branch, model, usage.
227
+ │ ├── usage/ # Provider balance / quota display.
228
+ │ └── vision/ # Cross-model image understanding.
229
+ ├── skills/ # Reusable Agent Skills.
230
+ │ ├── workflow/ # Workflow-oriented skills.
231
+ │ │ ├── at-commit/ # Conventional Commit message skill.
232
+ │ │ ├── at-review/ # Review changes for bugs and regressions.
233
+ │ │ └── at-simplify/ # Reduce complexity and duplication in changes.
234
+ │ └── integrations/ # Skills that integrate external systems.
235
+ │ └── at-zentao/ # ZenTao bug/task fixing workflow.
236
+ └── scripts/ # Install, sync, validation, and maintenance scripts.
237
+ ```
238
+
237
239
  ## FAQ
238
240
 
239
241
  ### Why does global installation fail for PromptScript?
@@ -247,8 +249,3 @@ other agents and can be ignored. See [`skills` issue #1352](https://github.com/v
247
249
  - [OpenCommit](https://github.com/di-sukharev/opencommit)
248
250
  - [GitLens](https://github.com/gitkraken/vscode-gitlens)
249
251
  - [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
250
-
251
- ## Notes
252
-
253
- - The installer marks and removes only the config entries it owns.
254
- - Run local checks with `npm test`.
package/README.zh-CN.md CHANGED
@@ -1,28 +1,8 @@
1
1
  # Agent Tools
2
2
 
3
- 面向 CodexClaude Code 与 opencode 的可复用 skills runtime integrations. 本仓库把各项能力放在可预期的位置; 不同项目可以只安装自己需要的部分.
3
+ 可复用的 Agent Skills, 以及面向 Codex, Claude Code 与 opencode 的可安装 integrations: statusline, provider usage 与跨模型识图.
4
4
 
5
- ## 目录结构
6
-
7
- ```text
8
- agent-tools/
9
- ├── .claude-plugin/ # Claude Code/plugin 生态的 manifest。
10
- ├── .codex-plugin/ # Codex plugin manifest。
11
- ├── hooks/ # 通用 hook 逻辑及各 agent 的适配实现。
12
- ├── plugins/ # 由各 agent 加载的 runtime plugins.
13
- │ └── vision/ # 跨模型识图(inspect_image MCP server + 内置 at-vision skill)。
14
- ├── scripts/ # 安装、同步、校验和仓库维护脚本。
15
- ├── skills/ # 可复用 Agent Skills,供 CLI 扫描和 plugin manifest 声明。
16
- │ ├── workflow/ # 工作流类 skills。
17
- │ │ ├── at-commit/ # 生成 Conventional Commits message.
18
- │ │ ├── at-review/ # 审查改动中的 bug 与回归风险.
19
- │ │ └── at-simplify/ # 减少改动中的冗余和复杂度.
20
- │ └── integrations/ # 对接外部系统的 skills。
21
- │ └── at-zentao/ # 禅道 bug/task 修复工作流.
22
- ├── statusline/ # Statusline 配置片段/模板,按 agent 分组。
23
- │ └── claude/ # Claude command-backed statusLine 脚本和示例配置。
24
- └── lib/ # hooks、statusline、installer 复用的共享实现。
25
- ```
5
+ 需要 Node.js >= 22.
26
6
 
27
7
  ## Skills
28
8
 
@@ -83,70 +63,27 @@ npx -y skills@latest add kairyou/agent-tools --skill at-zentao -g -y
83
63
 
84
64
  配置: `~/.agent-tools/config.jsonc` → `"zentao": { "url", "account", "password" }`. 首次使用会引导; `password` 自己填进文件(或设环境变量 `ZENTAO_PASSWORD`), 不要发在对话里.
85
65
 
86
- ## Plugins
87
-
88
- ### Vision(跨模型识图)
89
-
90
- 让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
66
+ ## Integrations
91
67
 
92
- #### 安装
68
+ Runtime capability, 按 agent 选装:
93
69
 
94
70
  ```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
71
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
102
72
  ```
103
73
 
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 配置.
74
+ `--dry-run` 预览, `--uninstall` 解除对应集成, 重新执行安装命令即为更新.
75
+ 安装器只改动自己写入的配置项; 卸载会保留 `~/.agent-tools` 下的共享文件.
105
76
 
106
- #### 配置
77
+ | Capability | Claude Code | Codex | OpenCode |
78
+ | --- | --- | --- | --- |
79
+ | `statusline` | ✓ | – | – |
80
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` 命令 |
81
+ | `vision` | ✓ | ✓ | ✓ |
107
82
 
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
- 人工排查配置或测试识别质量时可用:
83
+ ### Statusline
132
84
 
133
85
  ```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
86
  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
87
  ```
151
88
 
152
89
  安装器会把 `statusLine` 写入 `~/.claude/settings.json`. 默认显示:
@@ -161,86 +98,142 @@ npx -y @kairyou/agent-tools@latest statusline -a claude --uninstall
161
98
  如需控制显示项, 修改 `~/.agent-tools/config.jsonc` 里的
162
99
  `statusline.fields`. 安装器更新时可能补充新的默认键; 文件顶部注释和已有值会保留.
163
100
 
164
- ### Codex
101
+ ### Provider usage
165
102
 
166
- #### Provider usage hook
103
+ 面向使用 API 中转的场景: 在 agent 内直接显示中转网关的余额/额度, 按量付费或
104
+ 有套餐限额时, 随时知道花了多少, 还剩多少, 不用切出去登录网关后台.
105
+ 支持兼容 Sub2API-like, NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like
106
+ 与 OpenRouter 的网关.
167
107
 
168
108
  ```bash
169
- # 安装或更新
109
+ npx -y @kairyou/agent-tools@latest usage -a claude
170
110
  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
111
+ npx -y @kairyou/agent-tools@latest usage -a opencode
175
112
  ```
176
113
 
177
- 安装器会把 hook 添加到 `~/.codex/hooks.json` `UserPromptSubmit`
178
- `Stop`. 安装后, 在 Codex 里运行 `/hooks` 并批准 agent-tools usage hooks.
114
+ - **Claude Code** `at-usage` skill 装入 `~/.claude/skills`; 调用
115
+ `/at-usage` 即可在对话中显示当前用量.
116
+ - **Codex** — 把 hook 添加到 `~/.codex/hooks.json` 的 `UserPromptSubmit` 和
117
+ `Stop`, 并把 `at-usage` skill 装入 `~/.agents/skills`. 安装后在 Codex 里运行
118
+ `/hooks` 批准一次. Codex CLI 会显示 hook 输出; 部分客户端(如 Paseo)目前不显示,
119
+ 可调用 `$at-usage` 按需查询.
120
+ - **OpenCode** — 添加 server plugin 和 TUI plugin: session 进入 idle 后自动刷新
121
+ usage 并以 toast 显示, `/at-usage` 查看最新缓存值. 安装或更新后需要重启 opencode.
122
+
123
+ 中转端点自动发现 — Codex: 读取 `~/.codex/config.toml` / `auth.json` 里当前
124
+ provider 的 `base_url` 和密钥; Claude Code: 读取 `ANTHROPIC_BASE_URL` 与
125
+ `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY`. 官方(非中转)端点会被跳过.
126
+ 如果结果是 `Provider usage is unavailable.`, 可用环境变量
127
+ `PROVIDER_USAGE_BASE_URL` / `PROVIDER_USAGE_API_KEY` 显式指定端点和密钥,
128
+ 并在 `~/.agent-tools/config.jsonc` 里调整 `providerUsage`:
129
+
130
+ ```jsonc
131
+ {
132
+ "providerUsage": {
133
+ "preset": "auto", // sub2api | new-api | veloera | anyrouter | openrouter | ...
134
+ "userId": "", // 部分 NewAPI/Veloera 面板需要填面板用户 id
135
+ "days": 30, // "30d" 字段的统计窗口(最大 90)
136
+ "debug": false // true: 探测过程写入 ~/.agent-tools/logs/usage-debug.log
137
+ }
138
+ }
139
+ ```
179
140
 
180
141
  显示效果示例:
181
142
 
182
143
  ```text
183
- # 订阅/套餐额度.
184
- warning: API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
144
+ # 中转套餐额度.
145
+ API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
185
146
 
186
147
  # 钱包余额.
187
- warning: API | balance $362 | today $61.7 | 30d $566
148
+ API | balance $362 | today $61.7 | 30d $566
188
149
  ```
189
150
 
190
151
  字段含义: `D/W/M` 是日/周/月套餐消耗与上限, `Exp` 是套餐到期日,
191
152
  `balance` 是钱包余额, `today` / `30d` 是今日与近 30 天 API 消耗.
192
153
 
193
- ### OpenCode
154
+ ### Vision(跨模型识图)
194
155
 
195
- #### Provider usage plugin
156
+ 让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
196
157
 
197
- ```bash
198
- # 安装或更新
199
- npx -y @kairyou/agent-tools@latest usage -a opencode
158
+ #### 安装
200
159
 
201
- # 预览或卸载
202
- npx -y @kairyou/agent-tools@latest usage -a opencode --dry-run
203
- npx -y @kairyou/agent-tools@latest usage -a opencode --uninstall
160
+ ```bash
161
+ npx -y @kairyou/agent-tools@latest vision -a claude
162
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
204
163
  ```
205
164
 
206
- 安装器会添加全局 server plugin TUI plugin. 当前 session 进入 idle 后, server
207
- plugin 会刷新 usage 并通过 toast 显示; TUI plugin 还会注册 `/at-usage`, 用于查看最新
208
- 缓存值. 安装或更新 plugin 后需要重启 opencode.
165
+ 卸载默认保留 vision provider 配置. 安装器会为每个 agent 注册 `inspect_image`
166
+ MCP server (Claude Code: `~/.claude.json`; Codex: `~/.codex/config.toml`;
167
+ OpenCode: `opencode.json`), 并把 `at-vision` skill 装入对应 agent 的 skills 目录.
209
168
 
210
- 显示效果示例:
169
+ #### 配置
211
170
 
212
- ```text
213
- Provider usage
214
- balance $244 | today $45.8 | 30d $604
171
+ `~/.agent-tools/config.jsonc` 是唯一配置入口:
172
+
173
+ ```jsonc
174
+ {
175
+ "vision": {
176
+ "provider": "openai-compatible", // 或 "anthropic-compatible"
177
+ "baseUrl": "https://gateway.example.com/v1", // anthropic-compatible 填网关根地址, 会自动拼 /v1/messages
178
+ "model": "internal-vlm",
179
+ "apiKey": { "env": "OPENAI_API_KEY" } // 引用已有环境变量, 也可以直接填密钥
180
+ // , "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192
181
+ // , "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
182
+ }
183
+ }
215
184
  ```
216
185
 
217
- ### 支持的网关
186
+ `apiKey` 可直接填密钥, 或用 `{ "env": "VARIABLE_NAME" }` 引用已有环境变量; 网关不需要密钥时可省略.
187
+ Provider 请求由 runtime 直接发送, API key 不进入 shell 命令; 对外错误会将 key 脱敏为 `***`. `maxConcurrentRequests` 和 `maxRequestsPerMinute` 在本机的 MCP/CLI 进程之间共享.
188
+ 图片字节会无损地流式编码到 Provider 的 base64 JSON 请求中, 不做重压缩; URL 图片使用私有临时文件, 每次请求结束后自动删除.
218
189
 
219
- 余额, 额度和套餐用量查询支持兼容 Sub2API-like,
220
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
190
+ #### 使用
221
191
 
222
- ### Git 运行
192
+ 在消息里给出图片的文件路径或 URL 即可. Agent 优先调用 MCP 的 `inspect_image`; 模型网关不支持 MCP namespace tools 时, 改用已安装的本地 vision CLI. 不要直接粘贴截图: 主模型不支持图片时, 粘贴会在到达工具前就报 API 400 — 保存成文件再给路径.
223
193
 
224
- 如需直接使用仓库版本,可将 npm 包名替换为 `github:kairyou/agent-tools`(本机需已安装 Git):
194
+ 人工排查配置或测试识别质量时可用:
195
+
196
+ ```bash
197
+ npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "导航栏的背景色和高度是多少"
198
+ ```
199
+
200
+ ## 从 Git 运行
201
+
202
+ 如需直接使用仓库版本, 可将 npm 包名替换为 `github:kairyou/agent-tools` (本机需已安装 Git):
225
203
 
226
204
  ```bash
227
205
  npx -y github:kairyou/agent-tools usage -a codex
228
206
  ```
229
207
 
208
+ ## 仓库结构
209
+
210
+ ```text
211
+ agent-tools/
212
+ ├── .claude-plugin/ # Claude Code/plugin 生态的 manifest.
213
+ ├── .codex-plugin/ # Codex plugin manifest.
214
+ ├── integrations/ # 可安装的 capability, 一个一目录.
215
+ │ ├── statusline/ # Agent 状态栏: 分支, 模型, 用量.
216
+ │ ├── usage/ # Provider 余额/额度显示.
217
+ │ └── vision/ # 跨模型识图.
218
+ ├── skills/ # 可复用的 Agent Skills.
219
+ │ ├── workflow/ # 工作流类 skills.
220
+ │ │ ├── at-commit/ # 生成 Conventional Commits message.
221
+ │ │ ├── at-review/ # 审查改动中的 bug 与回归风险.
222
+ │ │ └── at-simplify/ # 减少改动中的冗余和复杂度.
223
+ │ └── integrations/ # 对接外部系统的 skills.
224
+ │ └── at-zentao/ # 禅道 bug/task 修复工作流.
225
+ └── scripts/ # 安装, 同步, 校验和仓库维护脚本.
226
+ ```
227
+
230
228
  ## FAQ
231
229
 
232
- ### 为什么全局安装提示 PromptScript 不支持?
230
+ ### 为什么全局安装提示 PromptScript 不支持?
233
231
 
234
232
  `PromptScript does not support global skill installation` 表示 PromptScript Agent 不支持全局
235
- 安装,不影响其他 Agent,可忽略。参见 [`skills` issue #1352](https://github.com/vercel-labs/skills/issues/1352)
233
+ 安装, 不影响其他 Agent, 可忽略. 参见 [`skills` issue #1352](https://github.com/vercel-labs/skills/issues/1352).
236
234
 
237
235
  ## References
238
236
 
239
237
  - [OpenCommit](https://github.com/di-sukharev/opencommit)
240
238
  - [GitLens](https://github.com/gitkraken/vscode-gitlens)
241
239
  - [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
242
-
243
- ## 说明
244
-
245
- - 安装器只标记并移除自己写入的配置项。
246
- - 本地检查运行 `npm test`。