kimi-code-usage 0.1.0__tar.gz → 0.1.1__tar.gz

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 (27) hide show
  1. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/PKG-INFO +2 -1
  2. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/pyproject.toml +2 -1
  3. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/uv.lock +1 -1
  4. kimi_code_usage-0.1.1/vscode-extension/README.md +96 -0
  5. kimi_code_usage-0.1.1/vscode-extension/assets/icon.png +0 -0
  6. kimi_code_usage-0.1.1/vscode-extension/l10n/bundle.l10n.json +22 -0
  7. kimi_code_usage-0.1.1/vscode-extension/l10n/bundle.l10n.zh-cn.json +22 -0
  8. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/package.json +24 -18
  9. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/src/extension.ts +123 -24
  10. kimi_code_usage-0.1.0/vscode-extension/README.md +0 -89
  11. kimi_code_usage-0.1.0/vscode-extension/assets/icon.png +0 -0
  12. kimi_code_usage-0.1.0/vscode-extension/l10n/bundle.l10n.json +0 -12
  13. kimi_code_usage-0.1.0/vscode-extension/l10n/bundle.l10n.zh-cn.json +0 -12
  14. kimi_code_usage-0.1.0/vscode-extension/package.nls.json +0 -11
  15. kimi_code_usage-0.1.0/vscode-extension/package.nls.zh-cn.json +0 -11
  16. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/.env.example +0 -0
  17. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/.gitignore +0 -0
  18. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/README.md +0 -0
  19. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/requirements.txt +0 -0
  20. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/src/kimi_code_usage/__init__.py +0 -0
  21. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/src/kimi_code_usage/main.py +0 -0
  22. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/src/kimi_code_usage/mcp.py +0 -0
  23. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/.vscodeignore +0 -0
  24. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/LICENSE +0 -0
  25. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/assets/banner.png +0 -0
  26. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/assets/screenshot.png +0 -0
  27. {kimi_code_usage-0.1.0 → kimi_code_usage-0.1.1}/vscode-extension/tsconfig.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kimi-code-usage
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A curated Kimi Coding Plan usage monitor with aesthetic CLI and MCP server.
5
5
  Project-URL: Homepage, https://github.com/Golden0Voyager/kimi-code-usage
6
6
  Project-URL: Repository, https://github.com/Golden0Voyager/kimi-code-usage
@@ -11,6 +11,7 @@ Keywords: curated,kimi,mcp,monitor,moonshot,usage
11
11
  Requires-Python: >=3.10
12
12
  Requires-Dist: aiohttp>=3.8.0
13
13
  Requires-Dist: fastmcp>=0.1.0
14
+ Requires-Dist: httpx[socks]>=0.20.0
14
15
  Requires-Dist: python-dotenv>=1.0.0
15
16
  Requires-Dist: rich>=12.0.0
16
17
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kimi-code-usage"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "A curated Kimi Coding Plan usage monitor with aesthetic CLI and MCP server."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -14,6 +14,7 @@ dependencies = [
14
14
  "rich>=12.0.0",
15
15
  "python-dotenv>=1.0.0",
16
16
  "fastmcp>=0.1.0",
17
+ "httpx[socks]>=0.20.0",
17
18
  ]
18
19
 
19
20
  [project.urls]
@@ -864,7 +864,7 @@ wheels = [
864
864
 
865
865
  [[package]]
866
866
  name = "kimi-code-usage"
867
- version = "0.1.1"
867
+ version = "0.1.0"
868
868
  source = { editable = "." }
869
869
  dependencies = [
870
870
  { name = "aiohttp" },
@@ -0,0 +1,96 @@
1
+ ```text
2
+ ██╗ ██╗ ██╗ ███╗ ███╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗
3
+ ██║ ██╔╝ ██║ ████╗ ████║ ██║ ██╔════╝ ██╔═══██╗ ██╔══██╗ ██╔════╝
4
+ █████╔╝ ██║ ██╔████╔██║ ██║ ██║ ██║ ██║ ██║ ██║ █████╗
5
+ ██╔═██╗ ██║ ██║╚██╔╝██║ ██║ ██║ ██║ ██║ ██║ ██║ ██╔══╝
6
+ ██║ ██╗ ██║ ██║ ╚═╝ ██║ ██║ ╚██████╗ ╚██████╔╝ ██████╔╝ ███████╗
7
+ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
8
+ ```
9
+
10
+ # Kimi Code Usage (Kimi 轨道遥测仪)
11
+
12
+ <p align="center">
13
+ <a href="#"><img src="https://img.shields.io/visual-studio-marketplace/v/HainingYu.kimi-code-usage.svg" alt="Marketplace"></a>
14
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
15
+ <a href="#"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <strong>Navigating your AI trajectory with orbital precision.</strong><br>
20
+ <strong>以环月轨道的精度,感知你的 AI 资源余量。</strong>
21
+ </p>
22
+
23
+ ---
24
+
25
+ ### 🌑 Why Kimi Code Usage? | 为什么选择它?
26
+
27
+ In the vastness of the code universe, your creative flow shouldn't be pulled down by the unexpected gravity well of API quota limits. **Kimi Code Usage** acts as your orbital telemetry system. It brings transparency to your AI consumption, allowing you to focus on exploring the digital cosmos while maintaining full awareness of your life-support resources.
28
+
29
+ 在广袤的代码宇宙中,你的灵感航线不应被突如其来的额度耗尽(引力井)所打断。**Kimi Code Usage** 如同你的专属轨道遥测仪,为你的 AI 消耗提供极简而透明的实时监控,让你在探索深空的专注中,对系统资源状况了然于胸。
30
+
31
+ ---
32
+
33
+ ### 🛰️ Telemetry Showcase | 遥测显示
34
+
35
+ ```text
36
+ [ $(chip) Kimi 周限额:96% 5小时:99% ]
37
+ --------------------------------------------------
38
+ | Kimi API Telemetry Details |
39
+ | Weekly limit: 96,000 / 100,000 (96% left) |
40
+ | 5h limit: 1,980 / 2,000 (99% left) |
41
+ --------------------------------------------------
42
+ ```
43
+
44
+ ---
45
+
46
+ ### ✨ Systems | 核心组件
47
+
48
+ - **Orbital HUD | 轨道级状态栏**
49
+ A sleek indicator showing your remaining API telemetry at a glance.
50
+ 极致简洁的百分比显示,一眼看清飞船的剩余能量。
51
+ - **Atmospheric Alerting | 气流色彩预警**
52
+ Intelligent color shifts to match your trajectory:
53
+ 智能色彩预警,完美融入你的代码轨道:
54
+ - `30%` Remaining: **Stratosphere Caution** (平流层预警 - 保持关注)
55
+ - `10%` Remaining: **Re-entry Alert** (大气层红警 - 严重告警)
56
+ - **Deep Space Insights | 深空数据探针**
57
+ Hover to reveal a precisely curated breakdown of your weekly and short-term orbital limits.
58
+ 悬浮触发详尽的数据面板,掌握长周期与短周期限额的每一处细节。
59
+ - **Thruster Controls | 推进器微调**
60
+ - `Kimi: Refresh Usage` — Instant telemetry sync. (立即同步雷达数据)
61
+ - `Kimi: Show Details` — Deep dive into stats. (查看深空数据面板)
62
+
63
+ ---
64
+
65
+ ### 🚀 Launch Sequence | 发射序列
66
+
67
+ 1. **Dock** the extension from the VS Code Marketplace. (从商店安装扩展)
68
+ 2. **Calibrate** your API Key in Settings > `kimiUsage.apiKey`, or via the `.env` module. (配置你的 API 密钥)
69
+ 3. **Liftoff!** Watch your quota manifest in the status bar. (点火起飞!在状态栏实时感知资源消耗)
70
+
71
+ ---
72
+
73
+ ### ⚙️ Navigation Specs | 导航配置
74
+
75
+ | Setting (配置节点) | Description (说明) | Default |
76
+ | :--- | :--- | :--- |
77
+ | `apiKey` | Your Kimi API secret / 核心密钥 | `KIMI_CODING_API_KEY` |
78
+ | `baseUrl` | API base URL / 接口基站 | `Kimi Coding V1` |
79
+ | `refreshInterval` | Auto-sync minutes / 雷达刷新间隔 | `5` |
80
+ | `warnPercent` | Yellow caution threshold / 黄色平流层预警 | `30%` |
81
+ | `criticalPercent` | Red alert threshold / 红色大气层告警 | `10%` |
82
+
83
+ ---
84
+
85
+ ### 👨‍🚀 About the Commander | 关于指令长
86
+
87
+ Engineered with ❤️ by **Haining Yu**. This extension is a piece of digital architecture designed to bridge the gap between aesthetic curation and intuitive, AI-powered exploration.
88
+
89
+ 由 **Haining Yu** 精心打磨。它不仅是一个开发工具,更是一件融合了美学策展与直觉化 AI 探索的数字航天舱组件。
90
+
91
+ ---
92
+
93
+ <p align="center">
94
+ <strong>See you on the dark side of the moon.</strong>
95
+ </p>
96
+
@@ -0,0 +1,22 @@
1
+ {
2
+ "extension.displayName": "Kimi Code Usage",
3
+ "extension.description": "Monitor your Kimi Coding Plan API quota with aesthetic precision.",
4
+ "config.apiKey.description": "Kimi API key (or set via KIMI_API_KEY environment variable)",
5
+ "config.baseUrl.description": "API base URL",
6
+ "config.refreshIntervalMinutes.description": "Refresh interval in minutes",
7
+ "config.warnPercent.description": "Yellow warning threshold (percentage)",
8
+ "config.criticalPercent.description": "Red alert threshold (percentage)",
9
+ "config.language.description": "Display Language (requires extension restart)",
10
+ "command.refresh.title": "Refresh",
11
+ "command.showDetails.title": "Show Usage Details",
12
+ "Kimi: no key": "Kimi: no key",
13
+ "Set apiKey in VS Code settings or KIMI_API_KEY env var": "Set apiKey in VS Code settings or KIMI_API_KEY env var",
14
+ "No usage data": "No usage data",
15
+ "Kimi: --": "Kimi: --",
16
+ "Kimi: err": "Kimi: err",
17
+ "Kimi API key not configured.": "Kimi API key not configured.",
18
+ "Kimi API Usage Details": "Kimi API Usage Details",
19
+ "Kimi usage fetch failed: {0}": "Kimi usage fetch failed: {0}",
20
+ "left": "left",
21
+ "Weekly limit": "Weekly limit"
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "extension.displayName": "Kimi Code Usage",
3
+ "extension.description": "以优雅的姿态监控你的 Kimi Coding Plan API 配额。",
4
+ "config.apiKey.description": "Kimi API 密钥 (也可通过环境变量 KIMI_API_KEY 设置)",
5
+ "config.baseUrl.description": "API 基础地址",
6
+ "config.refreshIntervalMinutes.description": "自动刷新频率 (分钟)",
7
+ "config.warnPercent.description": "黄色警告阈值 (百分比)",
8
+ "config.criticalPercent.description": "红色警告阈值 (百分比)",
9
+ "config.language.description": "显示语言 (重启插件后生效)",
10
+ "command.refresh.title": "手动刷新",
11
+ "command.showDetails.title": "查看用量详情",
12
+ "Kimi: no key": "Kimi: 缺少 Key",
13
+ "Set apiKey in VS Code settings or KIMI_API_KEY env var": "请在设置中配置 apiKey 或设置 KIMI_API_KEY 环境变量",
14
+ "No usage data": "无用量数据",
15
+ "Kimi: --": "Kimi: --",
16
+ "Kimi: err": "Kimi: 错误",
17
+ "Kimi API key not configured.": "Kimi API Key 未配置。",
18
+ "Kimi API Usage Details": "Kimi API 用量详情",
19
+ "Kimi usage fetch failed: {0}": "Kimi 用量获取失败: {0}",
20
+ "left": "剩余",
21
+ "Weekly limit": "周限额"
22
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "kimi-code-usage",
3
- "displayName": "%extension.displayName%",
4
- "description": "%extension.description%",
3
+ "displayName": "Kimi Code Usage",
4
+ "description": "Monitor your Kimi Coding Plan API quota with aesthetic precision.",
5
5
  "icon": "assets/icon.png",
6
6
  "publisher": "HainingYu",
7
7
  "author": "Haining Yu",
8
8
  "license": "MIT",
9
- "version": "0.1.1",
9
+ "version": "0.1.3",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/Golden0Voyager/kimi-code-usage.git"
@@ -26,44 +26,50 @@
26
26
  "l10n": "./l10n",
27
27
  "contributes": {
28
28
  "configuration": {
29
- "title": "Kimi Usage",
29
+ "title": "Kimi Code Usage",
30
30
  "properties": {
31
- "kimiUsage.apiKey": {
31
+ "kimiCodeUsage.apiKey": {
32
32
  "type": "string",
33
33
  "default": "",
34
- "description": "%config.apiKey.description%"
34
+ "description": "Kimi API Key / 密钥 (Or set via KIMI_API_KEY env var / 或通过 KIMI_API_KEY 环境变量设置)"
35
35
  },
36
- "kimiUsage.baseUrl": {
36
+ "kimiCodeUsage.baseUrl": {
37
37
  "type": "string",
38
38
  "default": "https://api.kimi.com/coding/v1",
39
- "description": "%config.baseUrl.description%"
39
+ "description": "API Base URL / API 基础地址"
40
40
  },
41
- "kimiUsage.refreshIntervalMinutes": {
41
+ "kimiCodeUsage.refreshIntervalMinutes": {
42
42
  "type": "number",
43
43
  "default": 5,
44
- "description": "%config.refreshIntervalMinutes.description%"
44
+ "description": "Refresh interval in minutes / 自动刷新频率 (分钟)"
45
45
  },
46
- "kimiUsage.warnPercent": {
46
+ "kimiCodeUsage.warnPercent": {
47
47
  "type": "number",
48
48
  "default": 30,
49
- "description": "%config.warnPercent.description%"
49
+ "description": "Yellow warning threshold (%) / 黄色警告阈值 (%)"
50
50
  },
51
- "kimiUsage.criticalPercent": {
51
+ "kimiCodeUsage.criticalPercent": {
52
52
  "type": "number",
53
53
  "default": 10,
54
- "description": "%config.criticalPercent.description%"
54
+ "description": "Red alert threshold (%) / 红色警告阈值 (%)"
55
+ },
56
+ "kimiCodeUsage.language": {
57
+ "type": "string",
58
+ "default": "Auto",
59
+ "enum": ["Auto", "English", "Chinese"],
60
+ "description": "Display Language / 显示语言 (Requires restart / 重启插件后生效)"
55
61
  }
56
62
  }
57
63
  },
58
64
  "commands": [
59
65
  {
60
- "command": "kimiUsage.refresh",
61
- "title": "%command.refresh.title%",
66
+ "command": "kimiCodeUsage.refresh",
67
+ "title": "Refresh Usage / 手动刷新",
62
68
  "category": "Kimi"
63
69
  },
64
70
  {
65
- "command": "kimiUsage.showDetails",
66
- "title": "%command.showDetails.title%",
71
+ "command": "kimiCodeUsage.showDetails",
72
+ "title": "Show Usage Details / 查看用量详情",
67
73
  "category": "Kimi"
68
74
  }
69
75
  ]
@@ -1,5 +1,7 @@
1
1
  import * as vscode from 'vscode';
2
2
  import * as https from 'https';
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
3
5
 
4
6
  interface UsageItem {
5
7
  label: string;
@@ -12,18 +14,65 @@ interface UsageItem {
12
14
 
13
15
  let statusBarItem: vscode.StatusBarItem;
14
16
  let intervalId: NodeJS.Timeout | undefined;
17
+ let translator: Translator;
18
+
19
+ class Translator {
20
+ private bundle: Record<string, string> = {};
21
+ private useNative: boolean = true;
22
+
23
+ constructor(context: vscode.ExtensionContext) {
24
+ this.update(context);
25
+ }
26
+
27
+ update(context: vscode.ExtensionContext) {
28
+ const config = vscode.workspace.getConfiguration('kimiCodeUsage');
29
+ const lang = config.get<string>('language', 'Auto');
30
+
31
+ if (lang === 'Auto') {
32
+ this.useNative = true;
33
+ this.bundle = {};
34
+ } else {
35
+ this.useNative = false;
36
+ const fileName = lang === 'Chinese' ? 'bundle.l10n.zh-cn.json' : 'bundle.l10n.json';
37
+ const filePath = path.join(context.extensionPath, 'l10n', fileName);
38
+ try {
39
+ if (fs.existsSync(filePath)) {
40
+ this.bundle = JSON.parse(fs.readFileSync(filePath, 'utf8'));
41
+ }
42
+ } catch (e) {
43
+ console.error('Failed to load l10n bundle', e);
44
+ this.useNative = true;
45
+ }
46
+ }
47
+ }
48
+
49
+ t(message: string, ...args: any[]): string {
50
+ let str = this.useNative ? vscode.l10n.t(message) : (this.bundle[message] || message);
51
+ if (args.length > 0) {
52
+ args.forEach((arg, i) => {
53
+ str = str.replace(`{${i}}`, String(arg));
54
+ });
55
+ }
56
+ return str;
57
+ }
58
+ }
15
59
 
16
60
  export function activate(context: vscode.ExtensionContext) {
61
+ translator = new Translator(context);
62
+
17
63
  statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
18
- statusBarItem.command = 'kimiUsage.showDetails';
64
+ statusBarItem.command = 'kimiCodeUsage.showDetails';
19
65
  statusBarItem.show();
20
66
 
21
- const refreshCmd = vscode.commands.registerCommand('kimiUsage.refresh', refresh);
22
- const detailsCmd = vscode.commands.registerCommand('kimiUsage.showDetails', showDetails);
67
+ const refreshCmd = vscode.commands.registerCommand('kimiCodeUsage.refresh', refresh);
68
+ const detailsCmd = vscode.commands.registerCommand('kimiCodeUsage.showDetails', showDetails);
23
69
 
24
70
  // Listen for configuration changes
25
71
  const configChangeDisposable = vscode.workspace.onDidChangeConfiguration((e) => {
26
- if (e.affectsConfiguration('kimiUsage')) {
72
+ if (e.affectsConfiguration('kimiCodeUsage')) {
73
+ if (e.affectsConfiguration('kimiCodeUsage.language')) {
74
+ translator.update(context);
75
+ }
27
76
  restartInterval();
28
77
  refresh();
29
78
  }
@@ -35,11 +84,15 @@ export function activate(context: vscode.ExtensionContext) {
35
84
  restartInterval();
36
85
  }
37
86
 
87
+ function t(message: string, ...args: any[]): string {
88
+ return translator.t(message, ...args);
89
+ }
90
+
38
91
  function restartInterval() {
39
92
  if (intervalId) {
40
93
  clearInterval(intervalId);
41
94
  }
42
- const cfg = vscode.workspace.getConfiguration('kimiUsage');
95
+ const cfg = vscode.workspace.getConfiguration('kimiCodeUsage');
43
96
  const minutes = cfg.get<number>('refreshIntervalMinutes', 5);
44
97
  intervalId = setInterval(refresh, minutes * 60 * 1000);
45
98
  }
@@ -50,14 +103,52 @@ export function deactivate() {
50
103
  }
51
104
  }
52
105
 
106
+ async function resolveApiKey(): Promise<string> {
107
+ const cfg = vscode.workspace.getConfiguration('kimiCodeUsage');
108
+ const configuredKey = cfg.get<string>('apiKey', '');
109
+ if (configuredKey) return configuredKey;
110
+
111
+ // Search workspace .env files
112
+ if (vscode.workspace.workspaceFolders) {
113
+ for (const folder of vscode.workspace.workspaceFolders) {
114
+ const envPath = vscode.Uri.joinPath(folder.uri, '.env');
115
+ try {
116
+ const envData = await vscode.workspace.fs.readFile(envPath);
117
+ const envText = Buffer.from(envData).toString('utf8');
118
+ const lines = envText.split('\n');
119
+ let fallbackKey = '';
120
+ for (const line of lines) {
121
+ const match = line.match(/^\s*(KIMI_CODING_API_KEY|KIMI_API_KEY)\s*=\s*['"]?([^'"\s]+)['"]?/);
122
+ if (match) {
123
+ if (match[1] === 'KIMI_CODING_API_KEY') {
124
+ return match[2]; // Highest priority in .env
125
+ } else if (!fallbackKey) {
126
+ fallbackKey = match[2];
127
+ }
128
+ }
129
+ }
130
+ if (fallbackKey) return fallbackKey;
131
+ } catch (e) {
132
+ // .env not found or unreadable in this folder, continue
133
+ }
134
+ }
135
+ }
136
+
137
+ // Check process.env (fallback)
138
+ if (process.env.KIMI_CODING_API_KEY) return process.env.KIMI_CODING_API_KEY;
139
+ if (process.env.KIMI_API_KEY) return process.env.KIMI_API_KEY;
140
+
141
+ return '';
142
+ }
143
+
53
144
  async function refresh() {
54
- const cfg = vscode.workspace.getConfiguration('kimiUsage');
55
- const apiKey = cfg.get<string>('apiKey', '') || process.env.KIMI_CODING_API_KEY || '';
145
+ const cfg = vscode.workspace.getConfiguration('kimiCodeUsage');
146
+ const apiKey = await resolveApiKey();
56
147
  const baseUrl = cfg.get<string>('baseUrl', 'https://api.kimi.com/coding/v1');
57
148
 
58
149
  if (!apiKey) {
59
- statusBarItem.text = `$(warning) ${vscode.l10n.t('Kimi: no key')}`;
60
- statusBarItem.tooltip = vscode.l10n.t('Set kimiUsage.apiKey in VS Code settings or KIMI_CODING_API_KEY env var');
150
+ statusBarItem.text = `$(warning) ${t('Kimi: no key')}`;
151
+ statusBarItem.tooltip = t('Set apiKey in VS Code settings or KIMI_CODING_API_KEY env var');
61
152
  statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
62
153
  return;
63
154
  }
@@ -67,8 +158,8 @@ async function refresh() {
67
158
  const items = parsePayload(data);
68
159
 
69
160
  if (items.length === 0) {
70
- statusBarItem.text = `$(chip) ${vscode.l10n.t('Kimi: --')}`;
71
- statusBarItem.tooltip = vscode.l10n.t('No usage data');
161
+ statusBarItem.text = `$(chip) ${t('Kimi: --')}`;
162
+ statusBarItem.tooltip = t('No usage data');
72
163
  statusBarItem.backgroundColor = undefined;
73
164
  return;
74
165
  }
@@ -79,7 +170,7 @@ async function refresh() {
79
170
  statusBarItem.text = `${emoji} Kimi ${parts.join(' ')}`;
80
171
 
81
172
  const lines = items.map(
82
- i => `${i.label}: ${i.used.toLocaleString()}/${i.limit.toLocaleString()} (${i.percent_left.toFixed(0)}% ${vscode.l10n.t('left')})${i.reset_hint ? ' — ' + i.reset_hint : ''}`
173
+ i => `${i.label}: ${i.used.toLocaleString()}/${i.limit.toLocaleString()} (${i.percent_left.toFixed(0)}% ${t('left')})${i.reset_hint ? ' — ' + i.reset_hint : ''}`
83
174
  );
84
175
  statusBarItem.tooltip = lines.join('\n');
85
176
 
@@ -91,7 +182,7 @@ async function refresh() {
91
182
  statusBarItem.backgroundColor = undefined;
92
183
  }
93
184
  } catch (err) {
94
- statusBarItem.text = `$(sync~spin) ${vscode.l10n.t('Kimi: err')}`;
185
+ statusBarItem.text = `$(sync~spin) ${t('Kimi: err')}`;
95
186
  statusBarItem.tooltip = String(err);
96
187
  statusBarItem.backgroundColor = undefined;
97
188
  }
@@ -138,7 +229,7 @@ function parsePayload(payload: any): UsageItem[] {
138
229
 
139
230
  const usage = payload?.usage;
140
231
  if (usage && typeof usage === 'object') {
141
- const row = toRow(usage, vscode.l10n.t('Weekly limit'));
232
+ const row = toRow(usage, t('Weekly limit'));
142
233
  if (row) items.push(row);
143
234
  }
144
235
 
@@ -243,19 +334,27 @@ function toInt(v: any): number | null {
243
334
 
244
335
  function shortLabel(label: string): string {
245
336
  const lower = label.toLowerCase();
246
- if (lower.includes('weekly') || lower.includes('week')) return 'W';
247
- if (lower.includes('5h') || lower.includes('5 hour')) return '5H';
248
- if (lower.includes('month') || lower.includes('monthly')) return 'M';
249
- return label.slice(0, 2).toUpperCase();
337
+ const isZh = translator.t('left') === '剩余'; // 简单的判断是否为中文环境
338
+
339
+ if (lower.includes('weekly') || lower.includes('week') || lower.includes('')) {
340
+ return isZh ? '周限额' : 'W';
341
+ }
342
+ if (lower.includes('5h') || lower.includes('5 hour') || lower.includes('5小时')) {
343
+ return isZh ? '5小时' : '5H';
344
+ }
345
+ if (lower.includes('month') || lower.includes('monthly') || lower.includes('月')) {
346
+ return isZh ? '月限额' : 'M';
347
+ }
348
+ return label.slice(0, 3);
250
349
  }
251
350
 
252
351
  async function showDetails() {
253
- const cfg = vscode.workspace.getConfiguration('kimiUsage');
254
- const apiKey = cfg.get<string>('apiKey', '') || process.env.KIMI_CODING_API_KEY || '';
352
+ const cfg = vscode.workspace.getConfiguration('kimiCodeUsage');
353
+ const apiKey = await resolveApiKey();
255
354
  const baseUrl = cfg.get<string>('baseUrl', 'https://api.kimi.com/coding/v1');
256
355
 
257
356
  if (!apiKey) {
258
- vscode.window.showWarningMessage(vscode.l10n.t('Kimi API key not configured.'));
357
+ vscode.window.showWarningMessage(t('Kimi API key not configured.'));
259
358
  return;
260
359
  }
261
360
 
@@ -263,11 +362,11 @@ async function showDetails() {
263
362
  const data = await fetchUsage(baseUrl, apiKey);
264
363
  const items = parsePayload(data);
265
364
  const picks = items.map((i) => ({
266
- label: `${i.label}: ${i.percent_left.toFixed(0)}% ${vscode.l10n.t('left')}`,
365
+ label: `${i.label}: ${i.percent_left.toFixed(0)}% ${t('left')}`,
267
366
  description: `${i.used.toLocaleString()} / ${i.limit.toLocaleString()}${i.reset_hint ? ' · ' + i.reset_hint : ''}`,
268
367
  }));
269
- vscode.window.showQuickPick(picks, { placeHolder: vscode.l10n.t('Kimi API Usage Details') });
368
+ vscode.window.showQuickPick(picks, { placeHolder: t('Kimi API Usage Details') });
270
369
  } catch (err) {
271
- vscode.window.showErrorMessage(vscode.l10n.t('Kimi usage fetch failed: {0}', String(err)));
370
+ vscode.window.showErrorMessage(t('Kimi usage fetch failed: {0}', String(err)));
272
371
  }
273
372
  }
@@ -1,89 +0,0 @@
1
- <p align="center">
2
- <img src="assets/banner.png" width="100%" alt="Kimi Code Usage Banner">
3
- </p>
4
-
5
- # Kimi Code Usage (Kimi 用量监控)
6
-
7
- <p align="center">
8
- <a href="#"><img src="https://img.shields.io/visual-studio-marketplace/v/HainingYu.kimi-code-usage.svg" alt="Marketplace"></a>
9
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
10
- <a href="#"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"></a>
11
- </p>
12
-
13
- <p align="center">
14
- <strong>Manifesting your AI quota with aesthetic precision.</strong><br>
15
- <strong>以优雅的姿态,感知你的 AI 额度。</strong>
16
- </p>
17
-
18
- ---
19
-
20
- ### 🌟 Why Kimi Code Usage? | 为什么选择它?
21
-
22
- In the era of "Vibecoding," your flow shouldn't be interrupted by unexpected quota limits. **Kimi Code Usage** is a curated extension that brings transparency to your AI consumption, allowing you to focus on creation while staying aware of your resources.
23
-
24
- 在“直觉编程”时代,你的灵感流不应被突如其来的额度超限所打断。**Kimi Code Usage** 为你的 AI 消耗提供透明的实时监控,让你在专注创作的同时,对资源状况了然于胸。
25
-
26
- ---
27
-
28
- ### 🖼️ Showcase | 效果展示
29
-
30
- <p align="center">
31
- <img src="assets/screenshot.png" width="80%" alt="Actual Usage Screenshot">
32
- </p>
33
-
34
- ---
35
-
36
- ### ✨ Features | 功能特性
37
-
38
- - **💎 Minimalist Status Bar | 极简状态栏**
39
- A sleek indicator showing remaining API quota percentage at a glance.
40
- 极致简洁的百分比显示,一眼看清剩余额度。
41
- - **🎨 Sensory Alerting | 色彩感知提醒**
42
- Intelligent color shifts to match your "vibe":
43
- 智能色彩预警,完美融入你的开发氛围:
44
- - `30%` Remaining: **Amber Caution** (保持关注)
45
- - `10%` Remaining: **Scarlet Alert** (紧急预警)
46
- - **🔍 Deep Insights | 详尽数据流**
47
- Hover to reveal a precisely curated breakdown of your weekly and short-term limits.
48
- 悬浮触发详尽的数据面板,掌握周限额与短时限额的每一处细节。
49
- - **⚡ Quick Actions | 瞬时响应**
50
- - `Kimi: Refresh Usage` — Instant sync. (立即同步)
51
- - `Kimi: Show Details` — Deep dive into stats. (深度数据详情)
52
-
53
- ---
54
-
55
- ### 🛠️ Quick Start | 快速上手
56
-
57
- 1. **Install** the extension from the VS Code Marketplace.
58
- 2. **Configure** your API Key (Settings > `kimiUsage.apiKey`).
59
- 3. **Vibe check!** Watch your quota manifest in the status bar.
60
-
61
- 1. 从商店**安装**插件。
62
- 2. **配置** API Key(设置 > `kimiUsage.apiKey`)。
63
- 3. **开启创作!** 在状态栏实时感知你的额度。
64
-
65
- ---
66
-
67
- ### ⚙️ Configuration | 配置详情
68
-
69
- | Setting (设置项) | Description (说明) | Default |
70
- | :--- | :--- | :--- |
71
- | `apiKey` | Your Kimi API secret / API 密钥 | `KIMI_API_KEY` |
72
- | `baseUrl` | API base URL / 接口地址 | `Kimi Coding V1` |
73
- | `refreshInterval` | Auto-sync minutes / 自动刷新间隔 | `5` |
74
- | `warnPercent` | Yellow caution threshold / 警告阈值 | `30%` |
75
- | `criticalPercent` | Red alert threshold / 严重阈值 | `10%` |
76
-
77
- ---
78
-
79
- ### 🎨 About the Curator | 关于策展人
80
-
81
- Crafted with ❤️ by **Haining Yu**, an Art Curator and Vibecoder. This extension is a piece of digital art designed to bridge the gap between aesthetic curation and intuitive, AI-powered coding.
82
-
83
- 由 **Haining Yu** 精心打磨。作为一名艺术策展人与 Vibecoder,我将代码视作展览,力求在审美策展与直觉化 AI 编程之间寻找完美的平衡。
84
-
85
- ---
86
-
87
- <p align="center">
88
- <strong>Enjoy the flow. Stay in the vibe.</strong>
89
- </p>
@@ -1,12 +0,0 @@
1
- {
2
- "Kimi: no key": "Kimi: no key",
3
- "Set kimiUsage.apiKey in VS Code settings or KIMI_CODING_API_KEY env var": "Set kimiUsage.apiKey in VS Code settings or KIMI_CODING_API_KEY env var",
4
- "No usage data": "No usage data",
5
- "Kimi: --": "Kimi: --",
6
- "Kimi: err": "Kimi: err",
7
- "Kimi API key not configured.": "Kimi API key not configured.",
8
- "Kimi API Usage Details": "Kimi API Usage Details",
9
- "Kimi usage fetch failed: {0}": "Kimi usage fetch failed: {0}",
10
- "left": "left",
11
- "Weekly limit": "Weekly limit"
12
- }
@@ -1,12 +0,0 @@
1
- {
2
- "Kimi: no key": "Kimi: 缺少 Key",
3
- "Set kimiUsage.apiKey in VS Code settings or KIMI_CODING_API_KEY env var": "请在设置中配置 kimiUsage.apiKey 或设置 KIMI_CODING_API_KEY 环境变量",
4
- "No usage data": "无用量数据",
5
- "Kimi: --": "Kimi: --",
6
- "Kimi: err": "Kimi: 错误",
7
- "Kimi API key not configured.": "Kimi API Key 未配置。",
8
- "Kimi API Usage Details": "Kimi API 用量详情",
9
- "Kimi usage fetch failed: {0}": "Kimi 用量获取失败: {0}",
10
- "left": "剩余",
11
- "Weekly limit": "周限额"
12
- }
@@ -1,11 +0,0 @@
1
- {
2
- "extension.displayName": "Kimi Code Usage",
3
- "extension.description": "Show Kimi API usage in the status bar",
4
- "config.apiKey.description": "Kimi API key. If empty, reads from KIMI_API_KEY env var.",
5
- "config.baseUrl.description": "Kimi API base URL",
6
- "config.refreshIntervalMinutes.description": "Status bar refresh interval in minutes",
7
- "config.warnPercent.description": "Percentage threshold to show yellow warning",
8
- "config.criticalPercent.description": "Percentage threshold to show red alert",
9
- "command.refresh.title": "Refresh Kimi Usage",
10
- "command.showDetails.title": "Show Kimi Usage Details"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "extension.displayName": "Kimi Code Usage (Kimi 用量监控)",
3
- "extension.description": "在状态栏显示 Kimi API 的用量配额",
4
- "config.apiKey.description": "Kimi API Key。如果为空,则读取 KIMI_API_KEY 环境变量。",
5
- "config.baseUrl.description": "Kimi API Baseurl",
6
- "config.refreshIntervalMinutes.description": "状态栏刷新间隔(分钟)",
7
- "config.warnPercent.description": "显示黄色警告的百分比阈值",
8
- "config.criticalPercent.description": "显示红色警报的百分比阈值",
9
- "command.refresh.title": "刷新 Kimi 用量",
10
- "command.showDetails.title": "查看 Kimi 用量详情"
11
- }