codebuddy-stats 1.1.4 → 1.1.6
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 +3 -1
- package/dist/index.js +7 -7
- package/dist/lib/workspace-resolver.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
一个用于分析 CodeBuddy 系列产品使用成本的命令行工具,支持交互式 TUI 界面和纯文本输出。
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
5
7
|
## 功能特性
|
|
6
8
|
|
|
7
9
|
- **双数据源支持** - 同时支持 CodeBuddy Code 和 CodeBuddy IDE(VS Code 扩展)
|
|
@@ -68,7 +70,7 @@ cbs --help
|
|
|
68
70
|
按项目分类的费用统计,方便了解不同项目的 AI 使用成本。
|
|
69
71
|
|
|
70
72
|
工具会自动将项目标识解析为可读路径:
|
|
71
|
-
- **Code 模式**: 将 `Users-
|
|
73
|
+
- **Code 模式**: 将 `Users-foo-Documents-project-xxx` 还原为 `~/Documents/project/xxx`
|
|
72
74
|
- **IDE 模式**: 将 MD5 hash 映射为实际工作区路径
|
|
73
75
|
|
|
74
76
|
### Daily
|
package/dist/index.js
CHANGED
|
@@ -26,9 +26,9 @@ function parseArgs() {
|
|
|
26
26
|
}
|
|
27
27
|
else if (args[i] === '--help' || args[i] === '-h') {
|
|
28
28
|
console.log(`
|
|
29
|
-
CodeBuddy
|
|
29
|
+
CodeBuddy Stats
|
|
30
30
|
|
|
31
|
-
Usage:
|
|
31
|
+
Usage: codebuddy-stats [options]
|
|
32
32
|
|
|
33
33
|
Options:
|
|
34
34
|
--days <n> 只显示最近 n 天的数据
|
|
@@ -146,7 +146,7 @@ function renderOverview(box, data, width, note) {
|
|
|
146
146
|
content += '─'.repeat(summaryWidth) + '\n';
|
|
147
147
|
if (width >= 80) {
|
|
148
148
|
// 双列布局
|
|
149
|
-
content += `{green-fg}Total cost:{/green-fg}
|
|
149
|
+
content += `{green-fg}~Total cost:{/green-fg} ${formatCost(grandTotal.cost).padStart(12)} `;
|
|
150
150
|
content += `{green-fg}Active days:{/green-fg} ${String(activeDays).padStart(8)}\n`;
|
|
151
151
|
content += `{green-fg}Total tokens:{/green-fg} ${formatTokens(grandTotal.tokens).padStart(12)} `;
|
|
152
152
|
content += `{green-fg}Total requests:{/green-fg} ${formatNumber(grandTotal.requests).padStart(8)}\n`;
|
|
@@ -155,7 +155,7 @@ function renderOverview(box, data, width, note) {
|
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
157
|
// 单列布局
|
|
158
|
-
content += `{green-fg}Total cost:{/green-fg}
|
|
158
|
+
content += `{green-fg}~Total cost:{/green-fg} ${formatCost(grandTotal.cost)}\n`;
|
|
159
159
|
content += `{green-fg}Total tokens:{/green-fg} ${formatTokens(grandTotal.tokens)}\n`;
|
|
160
160
|
content += `{green-fg}Total requests:{/green-fg} ${formatNumber(grandTotal.requests)}\n`;
|
|
161
161
|
content += `{green-fg}Active days:{/green-fg} ${activeDays}\n`;
|
|
@@ -323,7 +323,7 @@ function renderDaily(box, data, scrollOffset = 0, width, note) {
|
|
|
323
323
|
// 纯文本输出模式
|
|
324
324
|
function printTextReport(data) {
|
|
325
325
|
const { modelTotals, projectTotals, grandTotal, topModel, topProject, cacheHitRate, activeDays } = data;
|
|
326
|
-
console.log('\n🤖 CodeBuddy
|
|
326
|
+
console.log('\n🤖 CodeBuddy Stats Report');
|
|
327
327
|
console.log('='.repeat(50));
|
|
328
328
|
console.log(`\nTotal cost: ${formatCost(grandTotal.cost)}`);
|
|
329
329
|
console.log(`Total tokens: ${formatTokens(grandTotal.tokens)}`);
|
|
@@ -366,7 +366,7 @@ async function main() {
|
|
|
366
366
|
// 创建 TUI
|
|
367
367
|
const screen = blessed.screen({
|
|
368
368
|
smartCSR: true,
|
|
369
|
-
title: 'CodeBuddy
|
|
369
|
+
title: 'CodeBuddy Stats',
|
|
370
370
|
forceUnicode: true,
|
|
371
371
|
fullUnicode: true,
|
|
372
372
|
});
|
|
@@ -424,7 +424,7 @@ async function main() {
|
|
|
424
424
|
screen.append(statusBar);
|
|
425
425
|
// 更新 Tab 栏
|
|
426
426
|
function updateTabBar() {
|
|
427
|
-
let content = '
|
|
427
|
+
let content = ' CodeBuddy Stats ';
|
|
428
428
|
content += '{gray-fg}Source:{/gray-fg} ';
|
|
429
429
|
if (currentSource === 'code') {
|
|
430
430
|
content += '{black-fg}{green-bg} Code {/green-bg}{/black-fg} ';
|
|
@@ -480,8 +480,8 @@ function pathExistsSync(p) {
|
|
|
480
480
|
* 尝试将 CodeBuddy Code 的项目名(路径中 / 替换为 -)还原为真实路径
|
|
481
481
|
* 使用回溯搜索,因为目录名本身可能包含 -
|
|
482
482
|
*
|
|
483
|
-
* 例如: "Users-
|
|
484
|
-
* -> "/Users/
|
|
483
|
+
* 例如: "Users-foo-Documents-project-codebuddy-stats"
|
|
484
|
+
* -> "/Users/foo/Documents/project/codebuddy-stats"
|
|
485
485
|
*/
|
|
486
486
|
function tryResolveCodePath(name) {
|
|
487
487
|
// 检查缓存
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebuddy-stats",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"author": "AnotiaWang",
|
|
38
38
|
"license": "ISC",
|
|
39
39
|
"packageManager": "pnpm@9.15.1",
|
|
40
|
-
"description": "CodeBuddy AI
|
|
40
|
+
"description": "CodeBuddy AI usage statistics with terminal UI",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"blessed": "^0.1.81"
|
|
43
43
|
},
|