u1s1-cli 0.19.1 → 0.19.3
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/dist/loop.js +4 -1
- package/dist/usage.js +18 -1
- package/package.json +1 -1
package/dist/loop.js
CHANGED
|
@@ -59,12 +59,15 @@ function parseArgs(ui, raw) {
|
|
|
59
59
|
const tokens = raw.trim().split(/\s+/).filter(Boolean);
|
|
60
60
|
let intervalMs;
|
|
61
61
|
let intervalIdx = -1;
|
|
62
|
+
// 命中的是不是末尾 "every 30m" 这种占两个 token 的形式(删除时要一起删掉 "every")
|
|
63
|
+
let matchedEveryForm = false;
|
|
62
64
|
// 末尾的 "every 30m" 形式占两个 token,先于前置匹配检查
|
|
63
65
|
if (tokens.length >= 2 && tokens[tokens.length - 2].toLowerCase() === "every") {
|
|
64
66
|
const parsed = parseIntervalMs(tokens[tokens.length - 1]);
|
|
65
67
|
if (parsed !== undefined) {
|
|
66
68
|
intervalMs = parsed;
|
|
67
69
|
intervalIdx = tokens.length - 2;
|
|
70
|
+
matchedEveryForm = true;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
if (intervalMs === undefined) {
|
|
@@ -79,7 +82,7 @@ function parseArgs(ui, raw) {
|
|
|
79
82
|
}
|
|
80
83
|
const rest = tokens.slice();
|
|
81
84
|
if (intervalMs !== undefined) {
|
|
82
|
-
rest.splice(intervalIdx,
|
|
85
|
+
rest.splice(intervalIdx, matchedEveryForm ? 2 : 1);
|
|
83
86
|
}
|
|
84
87
|
const prompt = rest.join(" ").trim();
|
|
85
88
|
if (!prompt) {
|
package/dist/usage.js
CHANGED
|
@@ -46,11 +46,28 @@ export async function usage() {
|
|
|
46
46
|
};
|
|
47
47
|
if (me.packages.length === 0)
|
|
48
48
|
console.log(" 用量包 (无生效中的用量包)");
|
|
49
|
+
// 同种类、同范围、同有效期的包合并成一条展示(比如邀请多个好友拿到的多份邀请赠送)
|
|
50
|
+
const groups = new Map();
|
|
49
51
|
for (const p of me.packages) {
|
|
52
|
+
const key = `${p.kind}|${p.scope}|${p.daily_tokens != null}|${p.expires_at || ""}`;
|
|
53
|
+
const g = groups.get(key);
|
|
54
|
+
// 可空字段求和:两边都是 null 就保持 null,别把「一次性包没有日额度」污染成 0
|
|
55
|
+
const sumOpt = (a, b) => (a == null && b == null ? null : (a ?? 0) + (b ?? 0));
|
|
56
|
+
if (g) {
|
|
57
|
+
g.count += 1;
|
|
58
|
+
g.daily_tokens = sumOpt(g.daily_tokens, p.daily_tokens);
|
|
59
|
+
g.total_tokens = sumOpt(g.total_tokens, p.total_tokens);
|
|
60
|
+
g.remaining += p.remaining;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
groups.set(key, { ...p, count: 1 });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const p of groups.values()) {
|
|
50
67
|
const daily = p.daily_tokens != null;
|
|
51
68
|
const total = daily ? (p.daily_tokens ?? 0) : (p.total_tokens ?? 0);
|
|
52
69
|
const ratio = total > 0 ? p.remaining / total : 0;
|
|
53
|
-
const label = (PKG_LABEL[p.kind] ?? p.kind).padEnd(5, " ");
|
|
70
|
+
const label = ((PKG_LABEL[p.kind] ?? p.kind) + (p.count > 1 ? ` ×${p.count}` : "")).padEnd(5, " ");
|
|
54
71
|
const per = daily ? "/天" : "";
|
|
55
72
|
console.log(` ${label} 还剩 ${fmtTokensCn(p.remaining)} / ${fmtTokensCn(total)}${per} ${bar(ratio)}`);
|
|
56
73
|
const scopeNote = p.scope === "free" ? "仅默认模型和搜索 · 0 点恢复" : "全模型可用";
|