Skip to content

Commit c563c59

Browse files
WitMiaoclaude
andcommitted
feat(cometix): add Cometix integration with comprehensive toolset
- Add complete Cometix utility suite with installer, commands, and menu integration - Implement auto-updater with version checking and download capabilities - Add comprehensive i18n support for Cometix features in both zh-CN and en - Include full test coverage for all Cometix utilities - Update CLI menu to include Cometix options - Add error handling and type definitions for Cometix operations - Update README files with Cometix integration information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 73b7f50 commit c563c59

30 files changed

Lines changed: 1071 additions & 15 deletions
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# CCometixLine Integration Plan
2+
3+
## Context
4+
5+
CCometixLine 是一个基于 Rust 的高性能 Claude Code 状态栏工具,提供 Git 集成和实时使用量跟踪功能。
6+
7+
## Implementation Summary
8+
9+
### 1. TDD Development Approach
10+
11+
- ✅ 编写全面的测试用例 (19 个测试)
12+
- ✅ 实现最小化功能使测试通过
13+
- ✅ 重构和优化代码结构
14+
15+
### 2. Core Components Implemented
16+
17+
#### 安装和检查模块 (`src/utils/cometix/installer.ts`)
18+
19+
- `isCometixLineInstalled()`: 检查 CCometixLine 安装状态
20+
- `installCometixLine()`: 安装 CCometixLine
21+
22+
#### 命令执行模块 (`src/utils/cometix/commands.ts`)
23+
24+
- `runCometixInstallOrUpdate()`: 执行安装或更新命令
25+
- `runCometixPrintConfig()`: 打印默认配置
26+
27+
#### 菜单管理模块 (`src/utils/cometix/menu.ts`)
28+
29+
- `showCometixMenu()`: 显示 CCometixLine 子菜单
30+
- 提供安装/更新和配置打印选项
31+
32+
#### 公共工具模块 (`src/utils/cometix/common.ts`)
33+
34+
- 定义常量和公共配置
35+
- 抽象化 npm 命令
36+
37+
### 3. Integration Points
38+
39+
#### 初始化流程集成 (`src/commands/init.ts`)
40+
41+
- 在第 11 步添加 CCometixLine 安装提示
42+
- 默认同意安装(按回车)
43+
- 如果已安装则跳过提示
44+
45+
#### 主菜单集成 (`src/commands/menu.ts`)
46+
47+
- 在"其他工具"部分添加 "L. CCometixLine" 选项
48+
- 进入 CCometixLine 管理子菜单
49+
- 支持大小写字母输入
50+
51+
### 4. Internationalization Support
52+
53+
#### 中文翻译 (`src/i18n/locales/zh-CN/cometix.ts`)
54+
55+
- 完整的中文界面支持
56+
- 安装提示和错误消息
57+
58+
#### 英文翻译 (`src/i18n/locales/en/cometix.ts`)
59+
60+
- 完整的英文界面支持
61+
- 与中文版本保持同步
62+
63+
### 5. Quality Assurance
64+
65+
#### 测试覆盖
66+
67+
- 单元测试: 19 个测试用例
68+
- 覆盖安装、命令、菜单三个核心模块
69+
- 边界条件和错误处理测试
70+
71+
#### 代码质量
72+
73+
- TypeScript 类型检查通过
74+
- 遵循现有代码风格和模式
75+
- 复用现有基础设施(错误处理、国际化等)
76+
77+
## Usage Flow
78+
79+
### 初始化时安装
80+
81+
```bash
82+
zcf init
83+
# 会询问: 是否安装CCometixLine - 基于 Rust 的高性能 Claude Code 状态栏工具,集成 Git 信息和实时使用量跟踪?
84+
# 默认 [Y/n]: 按回车即可安装
85+
```
86+
87+
### 通过菜单管理
88+
89+
```bash
90+
zcf
91+
# 选择 L. CCometixLine
92+
# 进入子菜单:
93+
# 1. 安装或更新: npm install -g @cometix/ccline; npm update -g @cometix/ccline
94+
# 2. 打印默认配置: ccline --print
95+
# 0. 返回主菜单
96+
```
97+
98+
## Technical Architecture
99+
100+
### File Structure
101+
102+
```
103+
src/utils/cometix/
104+
├── installer.ts # 安装检查和安装逻辑
105+
├── commands.ts # 命令执行逻辑
106+
├── menu.ts # 菜单交互逻辑
107+
├── common.ts # 公共常量和工具
108+
├── types.ts # TypeScript 类型定义
109+
└── errors.ts # 错误处理类
110+
```
111+
112+
### Integration Points
113+
114+
- `src/commands/init.ts`: 初始化流程集成 (Line 407-429)
115+
- `src/commands/menu.ts`: 主菜单集成 (Line 80-82, 105, 147-150, 172)
116+
- `src/utils/tools.ts`: 工具导出 (Line 108-111)
117+
118+
## Dependencies
119+
120+
- 复用现有的 npm 命令执行逻辑
121+
- 集成现有的国际化基础设施
122+
- 遵循现有的错误处理模式
123+
124+
## Benefits
125+
126+
1. **无缝集成**: 与现有 ZCF 工作流程完全集成
127+
2. **用户友好**: 简单的安装和管理流程
128+
3. **国际化**: 完整的中英文支持
129+
4. **高质量**: TDD 开发确保代码质量
130+
5. **可维护**: 清晰的模块结构和类型安全
131+
132+
## Future Enhancements
133+
134+
- 添加版本检查功能
135+
- 支持配置文件自定义
136+
- 集成到工作流模板中

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Menu options include:
2727
- `3-7` Configuration management (API/CCR, MCP, Model settings, AI personality, etc.)
2828
- `R` Claude Code Router management (enhanced in v2.8.1)
2929
- `U` ccusage - Claude Code usage analysis
30-
- `+` Check updates - Check and update Claude Code and CCR versions
30+
- `+` Check updates - Check and update Claude Code, CCR and CCometixLine versions (v2.10.0+ enhanced)
3131
- More features...
3232

3333
### Or, use direct commands:
@@ -75,6 +75,16 @@ After installation, use `/bmad-init` to initialize the BMad workflow in your pro
7575
- **Easy Management**: Interactive menu for CCR configuration and service control
7676
- **Auto Updates**: Automatic version checking and updates for CCR and Claude Code (v2.8.1+)
7777
78+
#### 📊 CCometixLine Support (Status Bar Tool) (v2.10.0+ New)
79+
80+
[CCometixLine](https://github.com/Haleclipse/CCometixLine) is a high-performance Rust-based statusline tool that provides:
81+
82+
- **Real-time Usage Tracking**: Monitor Claude Code API usage in real-time
83+
- **Git Integration**: Display Git status and branch information
84+
- **Status Line Display**: Native integration with your terminal statusline
85+
- **Performance Optimized**: Built with Rust for minimal resource usage
86+
- **Auto Updates**: Included in ZCF's update checking system
87+
7888
To access CCR features:
7989
8090
```bash
@@ -83,10 +93,10 @@ npx zcf ccr # Open CCR management menu
8393
npx zcf → select R
8494
```
8595
86-
Check for updates (v2.8.1+):
96+
Check for updates (v2.8.1+, CCometixLine support v2.10.0+):
8797
8898
```bash
89-
npx zcf check-updates # Check and update Claude Code and CCR to latest versions
99+
npx zcf check-updates # Check and update Claude Code, CCR and CCometixLine to latest versions
90100
# or
91101
npx zcf → select +
92102
```
@@ -197,6 +207,7 @@ Select function:
197207
--------- Other Tools ----------
198208
R. CCR Management - Claude Code Router management
199209
U. CCUsage - Claude Code usage analysis tool
210+
L. CCometixLine - High-performance statusline tool with Git integration and real-time usage tracking (v2.10.0+ new)
200211

201212
------------ ZCF ------------
202213
0. Select display language / 更改显示语言 - Change ZCF interface language
@@ -499,6 +510,7 @@ This project is inspired by and incorporates the following open source projects:
499510
500511
- [LINUX DO - The New Ideal Community](https://linux.do)
501512
- [CCR](https://github.com/musistudio/claude-code-router)
513+
- [CCometixLine](https://github.com/Haleclipse/CCometixLine)
502514
- [ccusage](https://github.com/ryoppippi/ccusage)
503515
- [BMad Method](https://github.com/bmad-code-org/BMAD-METHOD)
504516

README_zh-CN.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ npx zcf # 打开交互式菜单,根据你的需求选择操作
2727
- `3-7` 配置管理(API/CCR、MCP、模型设置、AI 个性等)
2828
- `R` Claude Code Router 管理(v2.8.1 增强)
2929
- `U` ccusage - Claude Code 用量分析
30-
- `+` 检查更新 - 检查并更新 Claude Code 和 CCR 的版本
30+
- `+` 检查更新 - 检查并更新 Claude Code、CCRCCometixLine 的版本(v2.10.0+ 增强)
3131
- 更多功能选项...
3232

3333
### 或者,直接使用命令:
@@ -75,6 +75,16 @@ npx zcf → 选择 2 # 通过菜单执行工作流更新
7575
- **便捷管理**:提供交互式菜单进行 CCR 配置和服务控制
7676
- **自动更新**:CCR 和 Claude Code 的自动版本检查和更新(v2.8.1+)
7777

78+
#### 📊 CCometixLine 支持(状态栏工具)(v2.10.0+ 新增)
79+
80+
[CCometixLine](https://github.com/Haleclipse/CCometixLine) 是一个基于 Rust 的高性能状态栏工具,提供:
81+
82+
- **实时用量追踪**:实时监控 Claude Code API 使用情况
83+
- **Git 集成**:显示 Git 状态和分支信息
84+
- **状态栏显示**:与终端状态栏原生集成
85+
- **性能优化**:使用 Rust 构建,资源消耗极低
86+
- **自动更新**:已集成到 ZCF 的更新检查系统
87+
7888
访问 CCR 功能:
7989

8090
```bash
@@ -83,10 +93,10 @@ npx zcf ccr # 打开 CCR 管理菜单
8393
npx zcf → 选择 R
8494
```
8595

86-
检查更新(v2.8.1+):
96+
检查更新(v2.8.1+,CCometixLine 支持 v2.10.0+):
8797

8898
```bash
89-
npx zcf check-updates # 检查并更新 Claude Code 和 CCR 到最新版本
99+
npx zcf check-updates # 检查并更新 Claude Code、CCRCCometixLine 到最新版本
90100
#
91101
npx zcf → 选择 +
92102
```
@@ -197,6 +207,7 @@ $ npx zcf
197207
--------- 其他工具 ----------
198208
R. CCR 管理 - Claude Code Router 管理
199209
U. CCUsage - Claude Code 用量分析工具
210+
L. CCometixLine - 基于 Rust 的高性能 Claude Code 状态栏工具,集成 Git 信息和实时使用量跟踪(v2.10.0+ 新增)
200211

201212
------------ ZCF ------------
202213
0. 更改显示语言 / Select display language - 更改 ZCF 界面语言
@@ -499,6 +510,7 @@ ZCF 现已支持在 Android Termux 环境中运行:
499510

500511
- [LINUX DO - 新的理想型社区](https://linux.do)
501512
- [CCR](https://github.com/musistudio/claude-code-router)
513+
- [CCometixLine](https://github.com/Haleclipse/CCometixLine)
502514
- [ccusage](https://github.com/ryoppippi/ccusage)
503515
- [BMad Method](https://github.com/bmad-code-org/BMAD-METHOD)
504516

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"allowCompoundWords": true,
66
"words": [
77
"bmad",
8+
"cometix",
89
"miaoda",
910
"musistudio",
1011
"npmjs",

src/commands/init.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { selectMcpServices } from '../utils/mcp-selector';
3939
import { selectAndInstallWorkflows } from '../utils/workflow-installer';
4040
import { isCcrInstalled, installCcr } from '../utils/ccr/installer';
4141
import { setupCcrConfiguration } from '../utils/ccr/config';
42+
import { isCometixLineInstalled, installCometixLine } from '../utils/cometix/installer';
4243

4344
export interface InitOptions {
4445
lang?: SupportedLang;
@@ -403,6 +404,30 @@ export async function init(options: InitOptions = {}) {
403404
}
404405
}
405406

407+
// Step 11: Ask about CCometixLine installation
408+
const cometixInstalled = await isCometixLineInstalled();
409+
if (!cometixInstalled) {
410+
const { shouldInstallCometix } = await inquirer.prompt<{ shouldInstallCometix: boolean }>({
411+
type: 'confirm',
412+
name: 'shouldInstallCometix',
413+
message: i18n.cometix.installCometixPrompt,
414+
default: true,
415+
});
416+
417+
if (shouldInstallCometix === undefined) {
418+
console.log(ansis.yellow(i18n.common.cancelled));
419+
process.exit(0);
420+
}
421+
422+
if (shouldInstallCometix) {
423+
await installCometixLine(scriptLang);
424+
} else {
425+
console.log(ansis.yellow(i18n.cometix.cometixSkipped));
426+
}
427+
} else {
428+
console.log(ansis.green(`✔ ${i18n.cometix.cometixAlreadyInstalled}`));
429+
}
430+
406431
// Step 12: Save zcf config
407432
updateZcfConfig({
408433
version,

src/commands/menu.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
clearZcfCacheFeature,
1212
changeScriptLanguageFeature,
1313
} from '../utils/features';
14-
import { runCcusageFeature, runCcrMenuFeature } from '../utils/tools';
14+
import { runCcusageFeature, runCcrMenuFeature, runCometixMenuFeature } from '../utils/tools';
1515
import { init } from './init';
1616
import { update } from './update';
1717
import { checkUpdates } from './check-updates';
@@ -77,6 +77,9 @@ export async function showMainMenu() {
7777
console.log(
7878
` ${ansis.cyan('U.')} ${i18n.menu.menuOptions.ccusage} ${ansis.gray('- ' + i18n.menu.menuDescriptions.ccusage)}`
7979
);
80+
console.log(
81+
` ${ansis.cyan('L.')} ${i18n.menu.menuOptions.cometixLine} ${ansis.gray('- ' + i18n.menu.menuDescriptions.cometixLine)}`
82+
);
8083
console.log('');
8184
console.log(' ------------ ZCF ------------');
8285
console.log(
@@ -99,7 +102,7 @@ export async function showMainMenu() {
99102
name: 'choice',
100103
message: i18n.common.enterChoice,
101104
validate: (value) => {
102-
const valid = ['1', '2', '3', '4', '5', '6', '7', 'r', 'R', 'u', 'U', '0', '-', '+', 'q', 'Q'];
105+
const valid = ['1', '2', '3', '4', '5', '6', '7', 'r', 'R', 'u', 'U', 'l', 'L', '0', '-', '+', 'q', 'Q'];
103106
return valid.includes(value) || i18n.common.invalidChoice;
104107
},
105108
});
@@ -141,6 +144,10 @@ export async function showMainMenu() {
141144
case 'U':
142145
await runCcusageFeature(scriptLang);
143146
break;
147+
case 'l':
148+
case 'L':
149+
await runCometixMenuFeature(scriptLang);
150+
break;
144151
case '0':
145152
const newLang = await changeScriptLanguageFeature(scriptLang);
146153
if (newLang !== scriptLang) {
@@ -161,8 +168,8 @@ export async function showMainMenu() {
161168

162169
// Add spacing between operations
163170
if (!exitMenu && choice.toLowerCase() !== 'q') {
164-
// Skip confirmation for ZCF configuration options (0, -, +, u, r)
165-
if (choice === '0' || choice === '-' || choice === '+' || choice.toLowerCase() === 'u' || choice.toLowerCase() === 'r') {
171+
// Skip confirmation for ZCF configuration options (0, -, +, u, r, l)
172+
if (choice === '0' || choice === '-' || choice === '+' || choice.toLowerCase() === 'u' || choice.toLowerCase() === 'r' || choice.toLowerCase() === 'l') {
166173
console.log('\n' + ansis.dim('─'.repeat(50)) + '\n');
167174
continue; // Directly return to menu
168175
}

src/i18n/locales/en/cometix.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export const cometixMessages = {
2+
// Installation
3+
installingCometix: 'Installing CCometixLine...',
4+
cometixInstallSuccess: 'CCometixLine installed successfully',
5+
cometixInstallFailed: 'Failed to install CCometixLine',
6+
cometixAlreadyInstalled: 'CCometixLine is already installed',
7+
8+
// Installation prompt in init
9+
installCometixPrompt: 'Install CCometixLine - High-performance Claude Code statusline tool with Git integration and real-time usage tracking?',
10+
cometixSkipped: 'CCometixLine installation skipped',
11+
12+
// Commands
13+
installingOrUpdating: 'Installing/updating CCometixLine...',
14+
installUpdateSuccess: 'CCometixLine install/update completed',
15+
installUpdateFailed: 'Failed to install/update CCometixLine',
16+
printingConfig: 'Printing CCometixLine configuration...',
17+
printConfigSuccess: 'Configuration printed successfully',
18+
printConfigFailed: 'Failed to print configuration',
19+
commandNotFound: 'ccline command not found. Please install CCometixLine first.',
20+
21+
// CCometixLine Menu
22+
cometixMenuTitle: 'CCometixLine - High-performance Claude Code statusline tool with Git integration and real-time usage tracking',
23+
cometixMenuOptions: {
24+
installOrUpdate: 'Install or Update',
25+
printConfig: 'Print Default Configuration',
26+
back: 'Back to Main Menu',
27+
},
28+
cometixMenuDescriptions: {
29+
installOrUpdate: 'Install or update CCometixLine using npm',
30+
printConfig: 'Display current CCometixLine configuration',
31+
},
32+
};

src/i18n/locales/en/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { bmad } from './bmad';
1111
import { errors } from './errors';
1212
import { tools } from './tools';
1313
import { ccrMessages } from './ccr';
14+
import { cometixMessages } from './cometix';
1415
import { updater } from './updater';
1516
import type { TranslationStructure, McpServicesTranslations } from '../../types';
1617

@@ -29,6 +30,7 @@ export const en: TranslationStructure = {
2930
errors,
3031
tools,
3132
ccr: ccrMessages,
33+
cometix: cometixMessages,
3234
updater,
3335
};
3436

0 commit comments

Comments
 (0)