pi-provider-codebuddy 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-10-31
4
+
5
+ 首个公开发布。
6
+
7
+ ### 新增
8
+
9
+ - **多站点登录**:`/login` 选择 CodeBuddy(CN)、CodeBuddy(International)、CodeBuddy iOA、CodeBuddy Enterprise 四个入口之一,浏览器完成 OAuth 登录;每个站点独立账号槽位,互不影响,可同时登录多个站点。企业入口登录时手动输入站点地址。
10
+ - **模型目录自动同步**:登录后自动拉取账号可用的模型目录并缓存(本地缓存 24h TTL),启动与每次会话开始时刷新;含企业自定义模型,支持 pi 的 `--model`、`--list-models` 与 omp 的模型选择。
11
+ - **思考档位**:模型名后缀 `:low` / `:medium` / `:high` / `:xhigh` / `:max`(omp 用 `--thinking`),支持范围自动跟随模型声明收敛。
12
+ - **额度显示**:状态栏实时显示会话消耗与账号周期额度,`/codebuddy-usage` 查看明细(会话明细、周期起止与重置时间、其他已登录站点额度快照)。
13
+ - **兼容旧版凭据**:读取多站点改造前的单 `codebuddy` 凭据槽位,旧登录无需重新认证。
14
+
15
+ ### 限制
16
+
17
+ - 每个站点一个账号槽位;企业入口仅支持一个域名,重复输入会覆盖。
18
+ - omp 的同站点多账号轮换尚未支持。
19
+ - 国际站与 iOA 入口尚缺真实环境验证。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fred Tan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # Pi Provider CodeBuddy
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/pi-provider-codebuddy)](https://www.npmjs.com/package/pi-provider-codebuddy)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+
6
+ 在 [pi](https://github.com/earendil-works/pi) 和 [oh-my-pi](https://github.com/can1357/oh-my-pi) 里使用你的 CodeBuddy 订阅:登录 CodeBuddy 账号后,pi / omp 会自动列出账号可用的模型,对话消耗和剩余额度直接显示在状态栏里。
7
+
8
+ - **多站点登录**:国内站、国际站、iOA、企业自建站点分别登录、互不影响,可同时使用
9
+ - **模型目录自动同步**:登录后自动拉取账号可用的模型,含企业自定义模型
10
+ - **思考档位**:`low` / `medium` / `high` / `xhigh` / `max`,自动跟随模型声明收敛
11
+ - **额度显示**:状态栏实时显示会话消耗与账号周期额度,`/codebuddy-usage` 查看明细
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ pi install npm:pi-provider-codebuddy # pi
17
+ omp plugin install pi-provider-codebuddy # omp
18
+ ```
19
+
20
+ 或从源码安装:
21
+
22
+ ```bash
23
+ git clone https://github.com/fredtanxo/pi-provider-codebuddy
24
+ cd pi-provider-codebuddy
25
+ npm install # 会自动构建 dist/
26
+
27
+ pi install "$PWD" # pi
28
+ omp plugin install "$PWD" # omp
29
+ ```
30
+
31
+ 更新用 `pi update --extensions`(pi)或 `omp plugin upgrade`(omp)。
32
+
33
+ ## 登录
34
+
35
+ 在 pi 或 omp 里执行 `/login`,选择要登录的入口:
36
+
37
+ | Provider | 显示名 | 地址 |
38
+ | ---------------------- | ------------------------- | ---------------------------------------------------------- |
39
+ | `codebuddy-cn` | CodeBuddy (CN) | `https://copilot.tencent.com` |
40
+ | `codebuddy-intl` | CodeBuddy (International) | `https://www.codebuddy.ai` |
41
+ | `codebuddy-ioa` | CodeBuddy iOA | `https://copilot.tencent.com`(与 CN 同地址,走企业 SSO) |
42
+ | `codebuddy-enterprise` | CodeBuddy Enterprise | 登录时手动输入,例如 `https://<enterprise>.copilot.qq.com` |
43
+
44
+ - 选好入口后会给出登录链接,在浏览器里完成登录即可。
45
+ - 同一入口重复 `/login` 会替换该站点的账号;不同站点互不影响,可以同时登录多个。
46
+
47
+ ## 选择模型
48
+
49
+ 模型按入口寻址,不同站点的同名模型不会混淆:
50
+
51
+ ```bash
52
+ pi --list-models codebuddy-cn
53
+ pi --model codebuddy-cn/glm-5.3:high
54
+
55
+ omp models codebuddy-intl
56
+ omp --model codebuddy-intl/glm-5.3 --thinking high
57
+ ```
58
+
59
+ 模型名末尾的 `(x0.79 credits)` 是 CodeBuddy 标注的计费倍率;`:high` / `--thinking high` 是思考档位,支持 `low` 到 `max`,不指定则由模型声明决定。
60
+
61
+ ## 额度
62
+
63
+ 状态栏显示两项:
64
+
65
+ ```
66
+ CodeBuddy session: 0.14 credits · CodeBuddy cycle: 21.14 / 10000 credits
67
+ ```
68
+
69
+ - **session**:本次会话所有计费请求的消耗
70
+ - **cycle**:账号当前计费周期的额度,与 CodeBuddy 网页控制台的用量页一致;包含其他客户端的消耗,刷新失败时显示 `[stale]`
71
+
72
+ 会话消耗按每次回复持久化在 `usage.codebuddyCredit` 字段上(CodeBuddy 返回的计费数值,非标准 `usage` 字段),因此跨会话累计依赖宿主原样保存 `usage` 的行为。若宿主将来裁剪未知字段,历史会话的消耗会归入「无计费信息」计数。
73
+
74
+ `/codebuddy-usage` 可查看会话明细、周期起止与重置时间,以及其他已登录站点的额度快照。
75
+
76
+ ## 常见问题
77
+
78
+ - **提示登录过期**:长期闲置(约 24 天以上)后登录会失效,重新 `/login` 对应入口即可,不影响其他站点。
79
+ - **omp 下切换模型后状态栏没更新**:这是 omp 的已知差异,发送下一条消息后就会刷新。
80
+
81
+ ## 已知限制
82
+
83
+ - 每个站点一个账号槽位;企业入口只支持一个域名,再次输入会覆盖前一个。
84
+ - omp 的同站点多账号轮换尚未支持;多站点请分别登录对应入口。
85
+ - 国际站与 iOA 入口尚缺真实环境验证,遇到问题欢迎提 issue。
86
+
87
+ ## 开发
88
+
89
+ ```bash
90
+ npm run check # 类型检查
91
+ npm test # 单元测试
92
+ npm run build # 构建到 dist/
93
+ ```
94
+
95
+ 欢迎 issue 和 PR,改动请配套单测。
96
+
97
+ ## License
98
+
99
+ [MIT](LICENSE)