@kairyou/agent-tools 0.1.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 (38) hide show
  1. package/README.md +147 -69
  2. package/README.zh-CN.md +143 -67
  3. package/dist/vision/cli.mjs +1972 -0
  4. package/dist/vision/mcp-server.mjs +32858 -0
  5. package/{statusline/claude/statusline.mjs → integrations/statusline/claude-statusline.mjs} +4 -2
  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} +5 -1
  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/integrations/vision/lib/cli.mjs +137 -0
  12. package/integrations/vision/lib/config.mjs +159 -0
  13. package/integrations/vision/lib/errors.mjs +35 -0
  14. package/integrations/vision/lib/image-source.mjs +273 -0
  15. package/integrations/vision/lib/inspect.mjs +108 -0
  16. package/integrations/vision/lib/providers/anthropic-compatible.mjs +59 -0
  17. package/integrations/vision/lib/providers/openai-compatible.mjs +56 -0
  18. package/integrations/vision/lib/providers/shared.mjs +251 -0
  19. package/integrations/vision/lib/rate-limit.mjs +188 -0
  20. package/integrations/vision/lib/redact.mjs +30 -0
  21. package/integrations/vision/mcp-server.mjs +96 -0
  22. package/integrations/vision/skills/at-vision/SKILL.md +66 -0
  23. package/package.json +15 -10
  24. package/scripts/build-vision.mjs +35 -0
  25. package/scripts/capture-codex-tools.mjs +48 -0
  26. package/scripts/install.mjs +511 -29
  27. package/scripts/release.mjs +126 -0
  28. package/skills/integrations/at-zentao/SKILL.md +148 -0
  29. package/skills/workflow/at-commit/SKILL.md +3 -8
  30. package/skills/workflow/at-review/SKILL.md +9 -4
  31. package/skills/workflow/at-simplify/SKILL.md +1 -0
  32. package/hooks/claude/.gitkeep +0 -1
  33. package/hooks/codex/.gitkeep +0 -1
  34. package/hooks/common/.gitkeep +0 -1
  35. package/hooks/opencode/.gitkeep +0 -1
  36. package/statusline/.gitkeep +0 -1
  37. package/statusline/codex/.gitkeep +0 -1
  38. /package/{plugins/opencode/usage-tui.mjs → integrations/usage/opencode-tui.mjs} +0 -0
package/README.md CHANGED
@@ -1,65 +1,109 @@
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
- ├── 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).
16
17
  ├── skills/ # Reusable Agent Skills for CLI discovery and plugin manifests.
17
- └── workflow/ # Workflow-oriented skills.
18
- ├── at-commit/ # Conventional Commit message skill.
19
- ├── at-review/ # Review changes for bugs and regressions.
20
- └── at-simplify/ # Reduce complexity and duplication in changes.
21
- ├── statusline/ # Statusline scripts/templates, grouped by agent.
22
- └── claude/ # Claude command-backed statusLine script + example config.
23
- └── lib/ # Shared implementation used by hooks, statuslines, and installers.
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
+ └── scripts/ # Install, sync, validation, and maintenance scripts.
24
25
  ```
25
26
 
26
- ## Current Skills
27
+ ## Skills
27
28
 
28
- - `at-commit`: Generate a Conventional Commits message from staged changes and wait for user confirmation before committing.
29
- - `at-review`: Review changes for correctness bugs, regressions, convention violations, and high-value cleanup findings.
30
- - `at-simplify`: Refactor changes to reduce duplication, lower complexity, and improve code quality.
31
-
32
- ## Usage
33
-
34
- List available skills:
29
+ ### Install
35
30
 
36
31
  ```bash
32
+ # List available skills
37
33
  npx -y skills@latest add kairyou/agent-tools --list
34
+
35
+ # Install globally (pass one or more names after --skill)
36
+ npx -y skills@latest add kairyou/agent-tools --skill <name...> -g -y
38
37
  ```
39
38
 
40
- Install skills globally:
39
+ ### at-commit
40
+
41
+ Generate a Conventional Commits message from staged changes and wait for user confirmation before committing.
41
42
 
42
43
  ```bash
43
44
  npx -y skills@latest add kairyou/agent-tools --skill at-commit -g -y
45
+ ```
46
+
47
+ - Usage: `/at-commit [<language>]` — language for the commit description (Conventional Commits tokens stay in English)
48
+
49
+ ### at-review
50
+
51
+ Review changes for correctness bugs, regressions, convention violations, and high-value cleanup findings.
52
+
53
+ ```bash
44
54
  npx -y skills@latest add kairyou/agent-tools --skill at-review -g -y
55
+ ```
56
+
57
+ - Usage: `/at-review [--fix] [<pr|branch|path>]` — reports findings; `--fix` also applies them
58
+
59
+ ### at-simplify
60
+
61
+ Refactor changes to reduce duplication, lower complexity, and improve code quality.
62
+
63
+ ```bash
45
64
  npx -y skills@latest add kairyou/agent-tools --skill at-simplify -g -y
46
65
  ```
47
66
 
48
- Pass multiple skills after `--skill`, for example `--skill at-commit at-review at-simplify`.
67
+ - Usage: `/at-simplify [<pr|branch|path>]`
68
+
69
+ ### at-zentao
70
+
71
+ Work ZenTao (禅道) bugs/tasks end to end: fix, verify, stage; asks before committing and before writing status back.
72
+
73
+ ```bash
74
+ npx -y skills@latest add kairyou/agent-tools --skill at-zentao -g -y
75
+ ```
76
+
77
+ Usage:
49
78
 
50
- ## Runtime integrations
79
+ - `/at-zentao bugs` — list bugs assigned to you (the configured account); pick one or several (several = batch mode)
80
+ - `/at-zentao tasks` — same, for tasks
81
+ - `/at-zentao bug <id>` — work a specific bug
82
+ - `/at-zentao task <id>` — work a specific task
51
83
 
52
- ### Claude Code
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.
53
85
 
54
- #### Statusline
86
+ ## Integrations
87
+
88
+ Runtime capabilities, installed per agent:
55
89
 
56
90
  ```bash
57
- # Install or update
58
- npx -y github:kairyou/agent-tools statusline -a claude
91
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
92
+ ```
93
+
94
+ `--dry-run` previews, `--uninstall` removes, and re-running the install command
95
+ updates.
59
96
 
60
- # Preview or uninstall
61
- npx -y github:kairyou/agent-tools statusline -a claude --dry-run
62
- npx -y github:kairyou/agent-tools statusline -a claude --uninstall
97
+ | Capability | Claude Code | Codex | OpenCode |
98
+ | --- | --- | --- | --- |
99
+ | `statusline` | | | – |
100
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` command |
101
+ | `vision` | ✓ | ✓ | ✓ |
102
+
103
+ ### Statusline
104
+
105
+ ```bash
106
+ npx -y @kairyou/agent-tools@latest statusline -a claude
63
107
  ```
64
108
 
65
109
  The installer writes `statusLine` to `~/.claude/settings.json`. The default
@@ -76,81 +120,115 @@ To choose what appears, edit `statusline.fields` in
76
120
  `~/.agent-tools/config.jsonc`. The installer may add new default keys on update;
77
121
  it preserves top-of-file comments and existing values.
78
122
 
79
- ### Codex
123
+ ### Provider usage
80
124
 
81
- #### Provider usage hook
125
+ Shows the active API provider's balance / quota inside each agent.
82
126
 
83
127
  ```bash
84
- # Install or update
85
- npx -y github:kairyou/agent-tools usage -a codex
86
-
87
- # Preview or uninstall
88
- npx -y github:kairyou/agent-tools usage -a codex --dry-run
89
- npx -y github:kairyou/agent-tools usage -a codex --uninstall
128
+ npx -y @kairyou/agent-tools@latest usage -a claude
129
+ npx -y @kairyou/agent-tools@latest usage -a codex
130
+ npx -y @kairyou/agent-tools@latest usage -a opencode
90
131
  ```
91
132
 
92
- The installer adds the hook to `UserPromptSubmit` and `Stop` in
93
- `~/.codex/hooks.json`. After installation, run `/hooks` inside Codex and approve
94
- 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.
95
142
 
96
143
  Output examples:
97
144
 
98
145
  ```text
99
146
  # Subscription / plan quota.
100
- 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
101
148
 
102
149
  # Wallet balance.
103
- warning: API | balance $362 | today $61.7 | 30d $566
150
+ API | balance $362 | today $61.7 | 30d $566
104
151
  ```
105
152
 
106
153
  Fields: `D/W/M` are daily/weekly/monthly spend against plan limits; `Exp` is
107
154
  the plan expiry; `balance` is wallet credit; `today` and `30d` are API spend.
108
155
 
109
- ### OpenCode
156
+ #### Supported gateways
157
+
158
+ Balance, quota, and plan usage queries support compatible Sub2API-like,
159
+ NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
160
+
161
+ ### Vision (cross-model image understanding)
110
162
 
111
- #### Provider usage plugin
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
112
166
 
113
167
  ```bash
114
- # Install or update
115
- npx -y github:kairyou/agent-tools usage -a opencode
168
+ npx -y @kairyou/agent-tools@latest vision -a claude
169
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
170
+ ```
116
171
 
117
- # Preview or uninstall
118
- npx -y github:kairyou/agent-tools usage -a opencode --dry-run
119
- npx -y github:kairyou/agent-tools usage -a opencode --uninstall
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.
176
+
177
+ #### Configure
178
+
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
+ }
120
192
  ```
121
193
 
122
- The installer adds global server and TUI plugins. After the active session
123
- becomes idle, the server plugin refreshes usage and shows it as a toast. The TUI
124
- plugin also registers `/at-usage` for the latest cached value. Restart opencode
125
- after installing or updating the plugins.
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.
126
197
 
127
- Toast example:
198
+ #### Use
128
199
 
129
- ```text
130
- Provider usage
131
- balance $244 | today $45.8 | 30d $604
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?"
132
206
  ```
133
207
 
134
- ### Supported gateways
208
+ ## Run from Git
135
209
 
136
- Balance, quota, and plan usage queries support compatible Sub2API-like,
137
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like, and OpenRouter gateways.
210
+ To run directly from the repository, replace the npm package name with
211
+ `github:kairyou/agent-tools` (Git required):
212
+
213
+ ```bash
214
+ npx -y github:kairyou/agent-tools usage -a codex
215
+ ```
138
216
 
139
217
  ## FAQ
140
218
 
141
- ### Why does a global install report `Failed to install 1`?
219
+ ### Why does global installation fail for PromptScript?
142
220
 
143
221
  `PromptScript does not support global skill installation` means that the
144
222
  PromptScript agent does not support global installation. It does not affect
145
223
  other agents and can be ignored. See [`skills` issue #1352](https://github.com/vercel-labs/skills/issues/1352).
146
224
 
225
+ ## References
226
+
227
+ - [OpenCommit](https://github.com/di-sukharev/opencommit)
228
+ - [GitLens](https://github.com/gitkraken/vscode-gitlens)
229
+ - [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
230
+
147
231
  ## Notes
148
232
 
149
- - `skills/` contains reusable `SKILL.md` capabilities.
150
- - `hooks/` keeps stable ownership directories for shared and agent-specific integrations.
151
- - `plugins/` contains runtime plugin implementations such as opencode usage.
152
- - `statusline/claude/` contains the command-backed Claude statusLine script.
153
- - `lib/` contains shared implementation such as API usage query logic.
154
233
  - The installer marks and removes only the config entries it owns.
155
-
156
- Run local checks with `npm test`.
234
+ - Run local checks with `npm test`.
package/README.zh-CN.md CHANGED
@@ -1,63 +1,106 @@
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.
13
- ├── scripts/ # 安装、同步、校验和仓库维护脚本。
11
+ ├── integrations/ # 可安装的 capability, 一个一目录; 文件按 agent + 形态命名.
12
+ ├── statusline/ # Claude Code command-backed statusLine 脚本.
13
+ ├── usage/ # Provider usage (查询核心 + codex hook, opencode plugins, CLI, at-usage skill 模板).
14
+ │ └── vision/ # 跨模型识图(inspect_image MCP server + 内置 at-vision skill)。
14
15
  ├── skills/ # 可复用 Agent Skills,供 CLI 扫描和 plugin manifest 声明。
15
- └── workflow/ # 工作流类 skills。
16
- ├── at-commit/ # 生成 Conventional Commits message.
17
- ├── at-review/ # 审查改动中的 bug 与回归风险.
18
- └── at-simplify/ # 减少改动中的冗余和复杂度.
19
- ├── statusline/ # Statusline 配置片段/模板,按 agent 分组。
20
- └── claude/ # Claude command-backed statusLine 脚本和示例配置。
21
- └── lib/ # hooks、statusline、installer 复用的共享实现。
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
+ └── scripts/ # 安装、同步、校验和仓库维护脚本。
22
23
  ```
23
24
 
24
- ## 当前 Skills
25
+ ## Skills
25
26
 
26
- - `at-commit`: 根据暂存区改动生成 Conventional Commits message, 并在提交前等待用户确认.
27
- - `at-review`: 审查改动中的正确性 bug, 回归风险, 约定违规和高价值清理项.
28
- - `at-simplify`: 重构改动, 减少冗余, 降低复杂度, 提升代码质量.
29
-
30
- ## 使用方式
31
-
32
- 查看可用 skills:
27
+ ### 安装
33
28
 
34
29
  ```bash
30
+ # 查看可用 skills
35
31
  npx -y skills@latest add kairyou/agent-tools --list
32
+
33
+ # 全局安装(--skill 后面可以跟一个或多个名字)
34
+ npx -y skills@latest add kairyou/agent-tools --skill <name...> -g -y
36
35
  ```
37
36
 
38
- 全局安装 skill:
37
+ ### at-commit
38
+
39
+ 根据暂存区改动生成 Conventional Commits message, 并在提交前等待用户确认.
39
40
 
40
41
  ```bash
41
42
  npx -y skills@latest add kairyou/agent-tools --skill at-commit -g -y
43
+ ```
44
+
45
+ - 用法: `/at-commit [<语言>]` — 指定 commit description 的语言(Conventional Commits 语法部分保持英文)
46
+
47
+ ### at-review
48
+
49
+ 审查改动中的正确性 bug, 回归风险, 约定违规和高价值清理项.
50
+
51
+ ```bash
42
52
  npx -y skills@latest add kairyou/agent-tools --skill at-review -g -y
53
+ ```
54
+
55
+ - 用法: `/at-review [--fix] [<pr|分支|路径>]` — 输出审查结果; 加 `--fix` 则同时应用修复
56
+
57
+ ### at-simplify
58
+
59
+ 重构改动, 减少冗余, 降低复杂度, 提升代码质量.
60
+
61
+ ```bash
43
62
  npx -y skills@latest add kairyou/agent-tools --skill at-simplify -g -y
44
63
  ```
45
64
 
46
- 多个 skill 可以跟在 `--skill` 后面,例如 `--skill at-commit at-review at-simplify`。
65
+ - 用法: `/at-simplify [<pr|分支|路径>]`
66
+
67
+ ### at-zentao
68
+
69
+ 读取禅道 bug/task 并端到端处理: 修复, 验证, 暂存; 提交和回写状态前均需确认.
70
+
71
+ ```bash
72
+ npx -y skills@latest add kairyou/agent-tools --skill at-zentao -g -y
73
+ ```
74
+
75
+ 用法:
47
76
 
48
- ## Runtime integrations
77
+ - `/at-zentao bugs` — 列出指派给你(配置的账号)的 bug, 挑一个或多个(多个 = 批量模式)
78
+ - `/at-zentao tasks` — 同上, 任务清单
79
+ - `/at-zentao bug <id>` — 直接处理指定 bug
80
+ - `/at-zentao task <id>` — 直接处理指定 task
49
81
 
50
- ### Claude Code
82
+ 配置: `~/.agent-tools/config.jsonc` → `"zentao": { "url", "account", "password" }`. 首次使用会引导; `password` 自己填进文件(或设环境变量 `ZENTAO_PASSWORD`), 不要发在对话里.
51
83
 
52
- #### Statusline
84
+ ## Integrations
85
+
86
+ Runtime capability, 按 agent 选装:
53
87
 
54
88
  ```bash
55
- # 安装或更新
56
- npx -y github:kairyou/agent-tools statusline -a claude
89
+ npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
90
+ ```
91
+
92
+ `--dry-run` 预览, `--uninstall` 卸载, 重新执行安装命令即为更新.
57
93
 
58
- # 预览或卸载
59
- npx -y github:kairyou/agent-tools statusline -a claude --dry-run
60
- npx -y github:kairyou/agent-tools statusline -a claude --uninstall
94
+ | Capability | Claude Code | Codex | OpenCode |
95
+ | --- | --- | --- | --- |
96
+ | `statusline` | | | – |
97
+ | `usage` | `/at-usage` skill | hook + `$at-usage` skill | toast + `/at-usage` 命令 |
98
+ | `vision` | ✓ | ✓ | ✓ |
99
+
100
+ ### Statusline
101
+
102
+ ```bash
103
+ npx -y @kairyou/agent-tools@latest statusline -a claude
61
104
  ```
62
105
 
63
106
  安装器会把 `statusLine` 写入 `~/.claude/settings.json`. 默认显示:
@@ -72,78 +115,111 @@ npx -y github:kairyou/agent-tools statusline -a claude --uninstall
72
115
  如需控制显示项, 修改 `~/.agent-tools/config.jsonc` 里的
73
116
  `statusline.fields`. 安装器更新时可能补充新的默认键; 文件顶部注释和已有值会保留.
74
117
 
75
- ### Codex
118
+ ### Provider usage
76
119
 
77
- #### Provider usage hook
120
+ 在各 agent 内显示当前 API provider 的余额/额度.
78
121
 
79
122
  ```bash
80
- # 安装或更新
81
- npx -y github:kairyou/agent-tools usage -a codex
82
-
83
- # 预览或卸载
84
- npx -y github:kairyou/agent-tools usage -a codex --dry-run
85
- npx -y github:kairyou/agent-tools usage -a codex --uninstall
123
+ npx -y @kairyou/agent-tools@latest usage -a claude
124
+ npx -y @kairyou/agent-tools@latest usage -a codex
125
+ npx -y @kairyou/agent-tools@latest usage -a opencode
86
126
  ```
87
127
 
88
- 安装器会把 hook 添加到 `~/.codex/hooks.json` `UserPromptSubmit`
89
- `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.
90
136
 
91
137
  显示效果示例:
92
138
 
93
139
  ```text
94
140
  # 订阅/套餐额度.
95
- 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
96
142
 
97
143
  # 钱包余额.
98
- warning: API | balance $362 | today $61.7 | 30d $566
144
+ API | balance $362 | today $61.7 | 30d $566
99
145
  ```
100
146
 
101
147
  字段含义: `D/W/M` 是日/周/月套餐消耗与上限, `Exp` 是套餐到期日,
102
148
  `balance` 是钱包余额, `today` / `30d` 是今日与近 30 天 API 消耗.
103
149
 
104
- ### OpenCode
150
+ #### 支持的网关
105
151
 
106
- #### Provider usage plugin
152
+ 余额, 额度和套餐用量查询支持兼容 Sub2API-like,
153
+ NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
154
+
155
+ ### Vision(跨模型识图)
156
+
157
+ 让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
158
+
159
+ #### 安装
107
160
 
108
161
  ```bash
109
- # 安装或更新
110
- npx -y github:kairyou/agent-tools usage -a opencode
162
+ npx -y @kairyou/agent-tools@latest vision -a claude
163
+ npx -y @kairyou/agent-tools@latest vision -a codex claude opencode
164
+ ```
111
165
 
112
- # 预览或卸载
113
- npx -y github:kairyou/agent-tools usage -a opencode --dry-run
114
- npx -y github:kairyou/agent-tools usage -a opencode --uninstall
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 目录.
169
+
170
+ #### 配置
171
+
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
+ }
115
185
  ```
116
186
 
117
- 安装器会添加全局 server plugin TUI plugin. 当前 session 进入 idle 后, server
118
- plugin 会刷新 usage 并通过 toast 显示; TUI plugin 还会注册 `/at-usage`, 用于查看最新
119
- 缓存值. 安装或更新 plugin 后需要重启 opencode.
187
+ `apiKey` 可直接填密钥, 或用 `{ "env": "VARIABLE_NAME" }` 引用已有环境变量; 网关不需要密钥时可省略.
188
+ Provider 请求由 runtime 直接发送, API key 不进入 shell 命令; 对外错误会将 key 脱敏为 `***`. `maxConcurrentRequests` 和 `maxRequestsPerMinute` 在本机的 MCP/CLI 进程之间共享.
189
+ 图片字节会无损地流式编码到 Provider base64 JSON 请求中, 不做重压缩; URL 图片使用私有临时文件, 每次请求结束后自动删除.
120
190
 
121
- 显示效果示例:
191
+ #### 使用
122
192
 
123
- ```text
124
- Provider usage
125
- balance $244 | today $45.8 | 30d $604
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 "导航栏的背景色和高度是多少"
126
199
  ```
127
200
 
128
- ### 支持的网关
201
+ ## 从 Git 运行
129
202
 
130
- 余额, 额度和套餐用量查询支持兼容 Sub2API-like,
131
- NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
203
+ 如需直接使用仓库版本,可将 npm 包名替换为 `github:kairyou/agent-tools`(本机需已安装 Git):
204
+
205
+ ```bash
206
+ npx -y github:kairyou/agent-tools usage -a codex
207
+ ```
132
208
 
133
209
  ## FAQ
134
210
 
135
- ### 全局安装为什么显示 `Failed to install 1`?
211
+ ### 为什么全局安装提示 PromptScript 不支持?
136
212
 
137
213
  `PromptScript does not support global skill installation` 表示 PromptScript Agent 不支持全局
138
214
  安装,不影响其他 Agent,可忽略。参见 [`skills` issue #1352](https://github.com/vercel-labs/skills/issues/1352)。
139
215
 
216
+ ## References
217
+
218
+ - [OpenCommit](https://github.com/di-sukharev/opencommit)
219
+ - [GitLens](https://github.com/gitkraken/vscode-gitlens)
220
+ - [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
221
+
140
222
  ## 说明
141
223
 
142
- - `skills/` 放可复用的 `SKILL.md` 能力。项目可以只安装自己需要的 skills。
143
- - `hooks/` 按通用逻辑和各 agent 适配实现划分目录。
144
- - `plugins/` 放 opencode usage 等 runtime plugin 实现.
145
- - `statusline/claude/` 放 Claude command-backed statusLine 脚本。
146
- - `lib/` 放 API usage 查询等共享实现。
147
224
  - 安装器只标记并移除自己写入的配置项。
148
-
149
- 本地检查运行 `npm test`。
225
+ - 本地检查运行 `npm test`。