@kairyou/agent-tools 0.3.0 → 0.5.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 +57 -39
- package/README.zh-CN.md +54 -40
- package/dist/statusline/claude-statusline.mjs +1160 -0
- package/dist/usage/cli.mjs +25 -0
- package/dist/usage/codex-hook.mjs +144 -0
- package/dist/usage/core.mjs +1876 -0
- package/dist/usage/opencode-plugin.mjs +80 -0
- package/dist/usage/opencode-tui.mjs +46 -0
- package/integrations/statusline/claude-statusline.mjs +8 -38
- package/integrations/usage/core.mjs +13 -1074
- package/integrations/usage/lib/cache.mjs +110 -0
- package/integrations/usage/lib/config.mjs +99 -0
- package/integrations/usage/lib/context.mjs +138 -0
- package/integrations/usage/lib/format.mjs +265 -0
- package/integrations/usage/lib/http.mjs +186 -0
- package/integrations/usage/lib/routes.mjs +265 -0
- package/integrations/usage/lib/urls.mjs +48 -0
- package/package.json +5 -5
- package/scripts/build.mjs +65 -0
- package/scripts/install.mjs +26 -15
- package/scripts/build-vision.mjs +0 -35
package/README.md
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
# Agent Tools
|
|
2
2
|
|
|
3
|
-
Reusable Agent Skills
|
|
3
|
+
Reusable Agent Skills and installable integrations — statusline, provider usage, and vision — for Codex, Claude Code, and opencode.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Repository Structure
|
|
5
|
+
Requires Node.js >= 22.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
agent-tools/
|
|
11
|
-
├── .claude-plugin/ # Claude Code/plugin ecosystem manifest.
|
|
12
|
-
├── .codex-plugin/ # Codex plugin manifest.
|
|
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
|
-
├── 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
|
-
└── scripts/ # Install, sync, validation, and maintenance scripts.
|
|
25
|
-
```
|
|
7
|
+
[中文](README.zh-CN.md)
|
|
26
8
|
|
|
27
9
|
## Skills
|
|
28
10
|
|
|
@@ -91,8 +73,10 @@ Runtime capabilities, installed per agent:
|
|
|
91
73
|
npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
|
|
92
74
|
```
|
|
93
75
|
|
|
94
|
-
`--dry-run` previews, `--uninstall`
|
|
95
|
-
updates.
|
|
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.
|
|
96
80
|
|
|
97
81
|
| Capability | Claude Code | Codex | OpenCode |
|
|
98
82
|
| --- | --- | --- | --- |
|
|
@@ -122,7 +106,12 @@ it preserves top-of-file comments and existing values.
|
|
|
122
106
|
|
|
123
107
|
### Provider usage
|
|
124
108
|
|
|
125
|
-
|
|
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 the usage APIs of Sub2API, NewAPI/OneAPI-family panels (OneHub,
|
|
113
|
+
DoneHub, Veloera, ...), and OpenRouter; compatibility can vary with a
|
|
114
|
+
deployment's version and auth scheme.
|
|
126
115
|
|
|
127
116
|
```bash
|
|
128
117
|
npx -y @kairyou/agent-tools@latest usage -a claude
|
|
@@ -134,16 +123,35 @@ npx -y @kairyou/agent-tools@latest usage -a opencode
|
|
|
134
123
|
`/at-usage` to show the current usage in the conversation.
|
|
135
124
|
- **Codex** — adds a hook to `UserPromptSubmit` and `Stop` in `~/.codex/hooks.json`
|
|
136
125
|
and the `at-usage` skill to `~/.agents/skills`. Run `/hooks` inside Codex once
|
|
137
|
-
to approve it.
|
|
138
|
-
|
|
126
|
+
to approve it. The Codex CLI displays hook output; some clients (e.g. Paseo)
|
|
127
|
+
currently do not — invoke `$at-usage` there.
|
|
139
128
|
- **OpenCode** — adds server and TUI plugins: usage refreshes when the session
|
|
140
129
|
goes idle and shows as a toast, and `/at-usage` shows the latest cached value.
|
|
141
130
|
Restart opencode after installing or updating.
|
|
142
131
|
|
|
132
|
+
The relay endpoint is auto-discovered — Codex: the active provider's `base_url`
|
|
133
|
+
and key from `~/.codex/config.toml` / `auth.json`; Claude Code:
|
|
134
|
+
`ANTHROPIC_BASE_URL` plus `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY`.
|
|
135
|
+
Official (non-relay) endpoints are skipped. If it reports
|
|
136
|
+
`Provider usage is unavailable.`, point it at the relay explicitly —
|
|
137
|
+
`PROVIDER_USAGE_BASE_URL` / `PROVIDER_USAGE_API_KEY` env vars override the
|
|
138
|
+
endpoint and key — and tune `providerUsage` in `~/.agent-tools/config.jsonc`:
|
|
139
|
+
|
|
140
|
+
```jsonc
|
|
141
|
+
{
|
|
142
|
+
"providerUsage": {
|
|
143
|
+
"preset": "auto", // sub2api | new-api | veloera | openrouter | ...
|
|
144
|
+
"userId": "", // some NewAPI/Veloera panels require your panel user id
|
|
145
|
+
"days": 30, // spend window for the "30d" field (max 90)
|
|
146
|
+
"debug": false // true: log probes to ~/.agent-tools/logs/usage-debug.log
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
143
151
|
Output examples:
|
|
144
152
|
|
|
145
153
|
```text
|
|
146
|
-
#
|
|
154
|
+
# Relay plan quota.
|
|
147
155
|
API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
|
|
148
156
|
|
|
149
157
|
# Wallet balance.
|
|
@@ -153,11 +161,6 @@ API | balance $362 | today $61.7 | 30d $566
|
|
|
153
161
|
Fields: `D/W/M` are daily/weekly/monthly spend against plan limits; `Exp` is
|
|
154
162
|
the plan expiry; `balance` is wallet credit; `today` and `30d` are API spend.
|
|
155
163
|
|
|
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
164
|
### Vision (cross-model image understanding)
|
|
162
165
|
|
|
163
166
|
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.
|
|
@@ -185,8 +188,8 @@ skill into the agent's skills directory.
|
|
|
185
188
|
"baseUrl": "https://gateway.example.com/v1", // anthropic-compatible: gateway root, /v1/messages is appended
|
|
186
189
|
"model": "internal-vlm",
|
|
187
190
|
"apiKey": { "env": "OPENAI_API_KEY" } // reuse an existing env var, or the key itself
|
|
188
|
-
//
|
|
189
|
-
//
|
|
191
|
+
// , "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192
|
|
192
|
+
// , "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
```
|
|
@@ -214,6 +217,26 @@ To run directly from the repository, replace the npm package name with
|
|
|
214
217
|
npx -y github:kairyou/agent-tools usage -a codex
|
|
215
218
|
```
|
|
216
219
|
|
|
220
|
+
## Repository Structure
|
|
221
|
+
|
|
222
|
+
```text
|
|
223
|
+
agent-tools/
|
|
224
|
+
├── .claude-plugin/ # Claude Code/plugin ecosystem manifest.
|
|
225
|
+
├── .codex-plugin/ # Codex plugin manifest.
|
|
226
|
+
├── integrations/ # Installable capabilities, one directory each.
|
|
227
|
+
│ ├── statusline/ # Agent status line: branch, model, usage.
|
|
228
|
+
│ ├── usage/ # Provider balance / quota display.
|
|
229
|
+
│ └── vision/ # Cross-model image understanding.
|
|
230
|
+
├── skills/ # Reusable Agent Skills.
|
|
231
|
+
│ ├── workflow/ # Workflow-oriented skills.
|
|
232
|
+
│ │ ├── at-commit/ # Conventional Commit message skill.
|
|
233
|
+
│ │ ├── at-review/ # Review changes for bugs and regressions.
|
|
234
|
+
│ │ └── at-simplify/ # Reduce complexity and duplication in changes.
|
|
235
|
+
│ └── integrations/ # Skills that integrate external systems.
|
|
236
|
+
│ └── at-zentao/ # ZenTao bug/task fixing workflow.
|
|
237
|
+
└── scripts/ # Install, sync, validation, and maintenance scripts.
|
|
238
|
+
```
|
|
239
|
+
|
|
217
240
|
## FAQ
|
|
218
241
|
|
|
219
242
|
### Why does global installation fail for PromptScript?
|
|
@@ -227,8 +250,3 @@ other agents and can be ignored. See [`skills` issue #1352](https://github.com/v
|
|
|
227
250
|
- [OpenCommit](https://github.com/di-sukharev/opencommit)
|
|
228
251
|
- [GitLens](https://github.com/gitkraken/vscode-gitlens)
|
|
229
252
|
- [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
|
|
230
|
-
|
|
231
|
-
## Notes
|
|
232
|
-
|
|
233
|
-
- The installer marks and removes only the config entries it owns.
|
|
234
|
-
- Run local checks with `npm test`.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
# Agent Tools
|
|
2
2
|
|
|
3
|
-
可复用的 Agent Skills, 以及面向 Codex
|
|
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
|
-
├── 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)。
|
|
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
|
-
└── scripts/ # 安装、同步、校验和仓库维护脚本。
|
|
23
|
-
```
|
|
5
|
+
需要 Node.js >= 22.
|
|
24
6
|
|
|
25
7
|
## Skills
|
|
26
8
|
|
|
@@ -89,7 +71,8 @@ Runtime capability, 按 agent 选装:
|
|
|
89
71
|
npx -y @kairyou/agent-tools@latest <capability> -a <agent...>
|
|
90
72
|
```
|
|
91
73
|
|
|
92
|
-
`--dry-run` 预览, `--uninstall`
|
|
74
|
+
`--dry-run` 预览, `--uninstall` 解除对应集成, 重新执行安装命令即为更新.
|
|
75
|
+
安装器只改动自己写入的配置项; 卸载会保留 `~/.agent-tools` 下的共享文件.
|
|
93
76
|
|
|
94
77
|
| Capability | Claude Code | Codex | OpenCode |
|
|
95
78
|
| --- | --- | --- | --- |
|
|
@@ -117,7 +100,10 @@ npx -y @kairyou/agent-tools@latest statusline -a claude
|
|
|
117
100
|
|
|
118
101
|
### Provider usage
|
|
119
102
|
|
|
120
|
-
|
|
103
|
+
面向使用 API 中转的场景: 在 agent 内直接显示中转网关的余额/额度, 按量付费或
|
|
104
|
+
有套餐限额时, 随时知道花了多少, 还剩多少, 不用切出去登录网关后台.
|
|
105
|
+
支持 Sub2API, NewAPI/OneAPI 系面板 (OneHub, DoneHub, Veloera 等)
|
|
106
|
+
与 OpenRouter 的用量接口; 同类网关的部署版本和鉴权方式不同, 兼容性可能有差异.
|
|
121
107
|
|
|
122
108
|
```bash
|
|
123
109
|
npx -y @kairyou/agent-tools@latest usage -a claude
|
|
@@ -129,15 +115,33 @@ npx -y @kairyou/agent-tools@latest usage -a opencode
|
|
|
129
115
|
`/at-usage` 即可在对话中显示当前用量.
|
|
130
116
|
- **Codex** — 把 hook 添加到 `~/.codex/hooks.json` 的 `UserPromptSubmit` 和
|
|
131
117
|
`Stop`, 并把 `at-usage` skill 装入 `~/.agents/skills`. 安装后在 Codex 里运行
|
|
132
|
-
`/hooks` 批准一次.
|
|
133
|
-
|
|
118
|
+
`/hooks` 批准一次. Codex CLI 会显示 hook 输出; 部分客户端(如 Paseo)目前不显示,
|
|
119
|
+
可调用 `$at-usage` 按需查询.
|
|
134
120
|
- **OpenCode** — 添加 server plugin 和 TUI plugin: session 进入 idle 后自动刷新
|
|
135
121
|
usage 并以 toast 显示, `/at-usage` 查看最新缓存值. 安装或更新后需要重启 opencode.
|
|
136
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 | openrouter | ...
|
|
134
|
+
"userId": "", // 部分 NewAPI/Veloera 面板需要填面板用户 id
|
|
135
|
+
"days": 30, // "30d" 字段的统计窗口(最大 90)
|
|
136
|
+
"debug": false // true: 探测过程写入 ~/.agent-tools/logs/usage-debug.log
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
137
141
|
显示效果示例:
|
|
138
142
|
|
|
139
143
|
```text
|
|
140
|
-
#
|
|
144
|
+
# 中转套餐额度.
|
|
141
145
|
API | D $0.0/$100 | W $0.0/$300 | Exp 07-08
|
|
142
146
|
|
|
143
147
|
# 钱包余额.
|
|
@@ -147,11 +151,6 @@ API | balance $362 | today $61.7 | 30d $566
|
|
|
147
151
|
字段含义: `D/W/M` 是日/周/月套餐消耗与上限, `Exp` 是套餐到期日,
|
|
148
152
|
`balance` 是钱包余额, `today` / `30d` 是今日与近 30 天 API 消耗.
|
|
149
153
|
|
|
150
|
-
#### 支持的网关
|
|
151
|
-
|
|
152
|
-
余额, 额度和套餐用量查询支持兼容 Sub2API-like,
|
|
153
|
-
NewAPI/OneAPI/OneHub/DoneHub/Veloera/AnyRouter-like 与 OpenRouter 的网关.
|
|
154
|
-
|
|
155
154
|
### Vision(跨模型识图)
|
|
156
155
|
|
|
157
156
|
让不支持图片的主模型借助多模态模型识图: 针对图片(本地路径或 http(s) URL)提出具体问题, 拿到答案后继续自己的推理. 常见场景: 读取报错截图, 按设计稿还原 UI, 定位测试反馈截图里的界面问题. 一个安装器 capability 包含三部分: `inspect_image` MCP stdio server, `at-vision` 策略 skill, 以及人工诊断 CLI.
|
|
@@ -178,8 +177,8 @@ OpenCode: `opencode.json`), 并把 `at-vision` skill 装入对应 agent 的 skil
|
|
|
178
177
|
"baseUrl": "https://gateway.example.com/v1", // anthropic-compatible 填网关根地址, 会自动拼 /v1/messages
|
|
179
178
|
"model": "internal-vlm",
|
|
180
179
|
"apiKey": { "env": "OPENAI_API_KEY" } // 引用已有环境变量, 也可以直接填密钥
|
|
181
|
-
//
|
|
182
|
-
//
|
|
180
|
+
// , "timeoutMs": 30000, "maxImageBytes": 20971520, "maxOutputTokens": 8192
|
|
181
|
+
// , "maxConcurrentRequests": 2, "maxRequestsPerMinute": 30
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
184
|
```
|
|
@@ -200,26 +199,41 @@ npx -y @kairyou/agent-tools@latest inspect-image <path|url> -q "导航栏的背
|
|
|
200
199
|
|
|
201
200
|
## 从 Git 运行
|
|
202
201
|
|
|
203
|
-
|
|
202
|
+
如需直接使用仓库版本, 可将 npm 包名替换为 `github:kairyou/agent-tools` (本机需已安装 Git):
|
|
204
203
|
|
|
205
204
|
```bash
|
|
206
205
|
npx -y github:kairyou/agent-tools usage -a codex
|
|
207
206
|
```
|
|
208
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
|
+
|
|
209
228
|
## FAQ
|
|
210
229
|
|
|
211
|
-
### 为什么全局安装提示 PromptScript
|
|
230
|
+
### 为什么全局安装提示 PromptScript 不支持?
|
|
212
231
|
|
|
213
232
|
`PromptScript does not support global skill installation` 表示 PromptScript Agent 不支持全局
|
|
214
|
-
|
|
233
|
+
安装, 不影响其他 Agent, 可忽略. 参见 [`skills` issue #1352](https://github.com/vercel-labs/skills/issues/1352).
|
|
215
234
|
|
|
216
235
|
## References
|
|
217
236
|
|
|
218
237
|
- [OpenCommit](https://github.com/di-sukharev/opencommit)
|
|
219
238
|
- [GitLens](https://github.com/gitkraken/vscode-gitlens)
|
|
220
239
|
- [claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts)
|
|
221
|
-
|
|
222
|
-
## 说明
|
|
223
|
-
|
|
224
|
-
- 安装器只标记并移除自己写入的配置项。
|
|
225
|
-
- 本地检查运行 `npm test`。
|