@ia-ccun/code-agent-cli 0.0.25 → 0.0.26

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/bin/cli.js CHANGED
@@ -170,9 +170,26 @@ async function checkForUpdates() {
170
170
  (latestParts[0] === localParts[0] && latestParts[1] === localParts[1] && latestParts[2] > localParts[2]);
171
171
 
172
172
  if (needsUpdate) {
173
- console.log('\n⚠️ 发现新版本 v%s → v%s', localVersion, latestVersion);
174
- console.log('\n 运行以下命令更新:');
175
- console.log(' npm install -g @nucc/code-agent-cli\n');
173
+ console.log('\n\x1b[38;2;243;139;168m⚠️ 发现新版本 v%s → v%s\x1b[0m', localVersion, latestVersion);
174
+ console.log('\n \x1b[38;2;166;227;161m运行以下命令更新:\x1b[0m');
175
+ console.log(' \x1b[36mnpm install -g @ia-ccun/code-agent-cli\x1b[0m\n');
176
+ }
177
+
178
+ // 写入版本缓存
179
+ try {
180
+ const cacheDir = join(process.env.HOME || process.env.USERPROFILE, '.aicode-cli');
181
+ if (!existsSync(cacheDir)) {
182
+ execSync(`mkdir -p "${cacheDir}"`, { stdio: 'pipe' });
183
+ }
184
+ const cacheData = {
185
+ localVersion,
186
+ latestVersion,
187
+ needsUpdate,
188
+ timestamp: Date.now()
189
+ };
190
+ writeFileSync(versionCachePath, JSON.stringify(cacheData, null, 2));
191
+ } catch (e) {
192
+ // 忽略缓存写入失败
176
193
  }
177
194
  } catch (e) {
178
195
  // 忽略检查失败
@@ -8,7 +8,6 @@
8
8
  import type { AssistantMessage } from "@mariozechner/pi-ai";
9
9
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
10
10
  import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
11
- import { existsSync, readFileSync } from "fs";
12
11
 
13
12
  function fmtTokens(n: number): string {
14
13
  if (n < 1000) return n.toString();
@@ -20,30 +19,9 @@ function fmtTokens(n: number): string {
20
19
  // #49bccf
21
20
  const gold = (s: string) => `\x1b[38;2;73;188;207m${s}\x1b[0m`;
22
21
 
23
- // 获取版本信息(从环境变量和缓存文件)
24
- function getVersionInfo() {
25
- const localVersion = process.env.AICODE_CLI_VERSION;
26
- const cachePath = process.env.AICODE_CLI_VERSION_CACHE;
27
-
28
- if (!localVersion) return null;
29
-
30
- let needsUpdate = false;
31
- let latestVersion = localVersion;
32
-
33
- if (cachePath && existsSync(cachePath)) {
34
- try {
35
- const cache = JSON.parse(readFileSync(cachePath, 'utf-8'));
36
- // 缓存有效期 1 小时
37
- if (Date.now() - cache.timestamp < 3600000) {
38
- latestVersion = cache.latestVersion;
39
- needsUpdate = cache.needsUpdate;
40
- }
41
- } catch (e) {
42
- // 忽略读取失败
43
- }
44
- }
45
-
46
- return { localVersion, latestVersion, needsUpdate };
22
+ // 获取本地版本号
23
+ function getVersion() {
24
+ return process.env.AICODE_CLI_VERSION || null;
47
25
  }
48
26
 
49
27
  export default function (pi: ExtensionAPI) {
@@ -189,15 +167,9 @@ export default function (pi: ExtensionAPI) {
189
167
  segments.push(theme.fg("muted", quote));
190
168
 
191
169
  // ── Version segment (rightmost) ─────────────────────────
192
- const versionInfo = getVersionInfo();
193
- if (versionInfo) {
194
- if (versionInfo.needsUpdate) {
195
- // 红色警告色
196
- segments.push(`\x1b[38;2;243;139;168mv${versionInfo.localVersion} ⚠️\x1b[0m`);
197
- } else {
198
- // 浅灰色
199
- segments.push(theme.fg("muted", `v${versionInfo.localVersion}`));
200
- }
170
+ const version = getVersion();
171
+ if (version) {
172
+ segments.push(theme.fg("muted", `v${version}`));
201
173
  }
202
174
 
203
175
  const joined = segments.join(sep);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ia-ccun/code-agent-cli",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "AI Coding Agent CLI - 基于OpenClaw🦞底层Agent原理实现的的编码智能体(供学习使用)。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",