minimax-status 1.1.3 → 1.1.4
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/cli/index.js +31 -3
- package/cli/renderer.js +3 -10
- package/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -282,9 +282,18 @@ program
|
|
|
282
282
|
const displayDir = currentDir || cliCurrentDir || "";
|
|
283
283
|
|
|
284
284
|
let configCounts = { claudeMdCount: 0, rulesCount: 0, mcpCount: 0, hooksCount: 0 };
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
// 优先使用 stdin 传入的 workspacePath,否则 fallback 到 process.cwd()
|
|
286
|
+
const workspacePath = stdinData?.workspace?.current_directory || process.cwd();
|
|
287
|
+
if (workspacePath) {
|
|
288
|
+
try {
|
|
289
|
+
// 添加超时防止挂起
|
|
290
|
+
configCounts = await Promise.race([
|
|
291
|
+
configCounter.count(workspacePath),
|
|
292
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('config timeout')), 2000))
|
|
293
|
+
]);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
// 超时或失败,保持默认值
|
|
296
|
+
}
|
|
288
297
|
}
|
|
289
298
|
|
|
290
299
|
// 获取 git 分支信息
|
|
@@ -301,12 +310,14 @@ program
|
|
|
301
310
|
gitBranch = { name: branch };
|
|
302
311
|
|
|
303
312
|
// 获取 ahead/behind
|
|
313
|
+
let hasUpstream = false;
|
|
304
314
|
try {
|
|
305
315
|
const revList = require('child_process').execSync(
|
|
306
316
|
'git rev-list --left-right --count HEAD...@{upstream}',
|
|
307
317
|
{ cwd: gitSearchPath, encoding: 'utf8', timeout: 3000 }
|
|
308
318
|
).trim();
|
|
309
319
|
if (revList) {
|
|
320
|
+
hasUpstream = true;
|
|
310
321
|
const [behind, ahead] = revList.split(/\s+/).map(n => parseInt(n) || 0);
|
|
311
322
|
if (ahead > 0 || behind > 0) {
|
|
312
323
|
gitBranch.ahead = ahead;
|
|
@@ -317,6 +328,23 @@ program
|
|
|
317
328
|
// 无 upstream 或获取失败,静默跳过
|
|
318
329
|
}
|
|
319
330
|
|
|
331
|
+
// 如果没有 upstream,尝试获取本地 commit 数作为提示
|
|
332
|
+
if (!hasUpstream) {
|
|
333
|
+
try {
|
|
334
|
+
const localCommits = require('child_process').execSync(
|
|
335
|
+
'git rev-list --count HEAD',
|
|
336
|
+
{ cwd: gitSearchPath, encoding: 'utf8', timeout: 3000 }
|
|
337
|
+
).trim();
|
|
338
|
+
const commitCount = parseInt(localCommits) || 0;
|
|
339
|
+
// 如果有本地 commits(大于1,因为初始commit算1个),标记有待推送
|
|
340
|
+
if (commitCount > 1) {
|
|
341
|
+
gitBranch.ahead = -1; // -1 表示有未知数量的待推送
|
|
342
|
+
}
|
|
343
|
+
} catch (e) {
|
|
344
|
+
// 获取失败,静默跳过
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
320
348
|
// 检查未提交的更改
|
|
321
349
|
try {
|
|
322
350
|
const status = require('child_process').execSync(
|
package/cli/renderer.js
CHANGED
|
@@ -94,6 +94,9 @@ class Renderer {
|
|
|
94
94
|
branchStr += chalk.cyan(' ⬇' + behind);
|
|
95
95
|
} else if (ahead > 0) {
|
|
96
96
|
branchStr += chalk.yellow(' ⬆' + ahead);
|
|
97
|
+
} else if (ahead === -1) {
|
|
98
|
+
// 没有 upstream 但有本地 commits
|
|
99
|
+
branchStr += chalk.yellow(' ⬆');
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
// 未提交更改用红色点
|
|
@@ -126,16 +129,6 @@ class Renderer {
|
|
|
126
129
|
: `${remaining.minutes}m`;
|
|
127
130
|
parts.push(`${chalk.yellow('⌛')} ${chalk.white(remainingText)}`);
|
|
128
131
|
|
|
129
|
-
if (configCounts.claudeMdCount > 0) {
|
|
130
|
-
parts.push(`${chalk.white(configCounts.claudeMdCount + ' CLAUDE.md')}`);
|
|
131
|
-
}
|
|
132
|
-
if (configCounts.rulesCount > 0) {
|
|
133
|
-
parts.push(`${chalk.cyan(configCounts.rulesCount + ' rules')}`);
|
|
134
|
-
}
|
|
135
|
-
if (configCounts.mcpCount > 0) {
|
|
136
|
-
parts.push(`${chalk.yellow(configCounts.mcpCount + ' MCPs')}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
132
|
if (expiry) {
|
|
140
133
|
const expiryColor = expiry.daysRemaining <= 3 ? chalk.red : expiry.daysRemaining <= 7 ? chalk.yellow : chalk.green;
|
|
141
134
|
parts.push(`${expiryColor('到期: ' + expiry.daysRemaining + '天')}`);
|