easy-claude 0.2.0 → 0.2.1
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/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
```sh
|
|
10
10
|
npm i -g easy-claude
|
|
11
11
|
easy-claude
|
|
12
|
-
easy-claude
|
|
12
|
+
easy-claude show
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
读取 Claude Code 登录账号,桌面端请使用同一账号。登录不存在或过期时,执行 `claude auth login` 后重试。仅安装 Claude 桌面端、没有 Claude Code 登录时不能查询。
|
|
@@ -18,16 +18,16 @@ easy-claude overlay
|
|
|
18
18
|
|
|
19
19
|
- macOS 14+;跟随 Claude 桌面应用窗口,前台显示,后台隐藏。默认左下角账户栏右侧,32×32,透明背景,无底板和阴影。
|
|
20
20
|
- 显示剩余百分比:大于 50% 为绿色、20%–50% 橙色、低于 20% 红色;未知或过期为灰色,不伪装满额。
|
|
21
|
-
-
|
|
21
|
+
- 按返回的真实额度自适应:只有周额度时显示单周环和周剩余数字,不显示5小时项;只有5小时则显示单5小时环,两项都有时双环同时显示:周额度为外侧粗实线环,5 小时额度为内侧细实线环(外环未使用部分为淡色虚线底轨),中心数字默认显示 5 小时剩余百分比(环内省略 %,菜单保留),可在菜单点击“5小时”或“周”切换并记住选择;两环独立配色和判断过期。右键查看“5小时 · 剩余百分比 · 重置时间”和“周 · 剩余百分比 · 重置时间”(重置使用电脑本地时区)、刷新、恢复位置或退出,双击刷新,拖动校准。
|
|
22
22
|
- 可见时每 5 分钟查询,10 分钟前的快照或已到重置时间的数据标为过期;接口错误会立即标记未知。
|
|
23
23
|
- 不显示“7天”等底部文字,详情在悬停提示和菜单。菜单栏标记为 EA。
|
|
24
24
|
- 基于窗口边界定位,不识别头像,不读取桌面聊天或截图;无法自动核对桌面账号与 CLI 账号一致。
|
|
25
25
|
|
|
26
26
|
## 电子时钟
|
|
27
27
|
|
|
28
|
-
运行 `easy-claude
|
|
28
|
+
运行 `easy-claude show` 时同时显示透明电子时钟,跟随 Claude 前台窗口,后台隐藏;可独立拖动位置。默认与额度环并排放在左下角,额度环在左、时钟在右;已有拖动位置继续保留,可从菜单选择“恢复默认位置”应用新布局。
|
|
29
29
|
|
|
30
|
-
默认硅谷 `America/Los_Angeles`,24 小时制,仅显示时分;自动按目标时区处理夏令时,与电脑系统时区无关。右键时钟、圆环或菜单栏 EA
|
|
30
|
+
默认硅谷 `America/Los_Angeles`,24 小时制,仅显示时分;自动按目标时区处理夏令时,与电脑系统时区无关。右键时钟、圆环或菜单栏 EA,使用城市时间子菜单按顺序选择硅谷、洛杉矶、西雅图、华盛顿、哥伦布、新加坡、上海,或输入其他 IANA 时区名称。时区、位置和显示开关自动保留;“恢复默认位置”同时重置圆环与时钟的位置。数字颜色按所选时区切换:09:00–15:00 绿色,15:00–24:00 橙色,00:00–09:00 红色。边界 09:00 起为绿、15:00 起为橙、午夜转红。时钟使用本机系统时间,无需登录或网络校时,不修改系统时区。
|
|
31
31
|
|
|
32
32
|
华盛顿指美国华盛顿特区,哥伦布指俄亥俄州哥伦布,二者使用 `America/New_York`;硅谷、洛杉矶和西雅图使用 `America/Los_Angeles`。城市名称独立保存,相同时区也可分别选择并显示。
|
|
33
33
|
|
|
@@ -55,3 +55,8 @@ npm run build:overlay
|
|
|
55
55
|
升级 package.json 版本,提交后推送同版本 v 标签,由 GitHub Actions 自动测试、构建通用浮窗并发布 npm。稳定版使用 latest,预发布使用 next。发布任务使用 npm Environment,仓库 Deployments 可查看记录。
|
|
56
56
|
|
|
57
57
|
发布使用 Easy 系列共用的 NPM_TOKEN Secret;每次发布前检查有效期和包权限。首次配置后,普通代码推送只运行 CI,版本标签才发布 npm。
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
浮窗使用 `easy-claude show` 启动;原 `overlay` 命令保留兼容。
|
|
61
|
+
|
|
62
|
+
周倒计时只显示最大单位,例如“6天后 25日 06:17 重置”,不足一天按小时、不足一小时按分钟。5小时窗口保留时分组合,例如“3小时2分后 07:59 重置”,没有小时则“22分后 07:59 重置”,省略为零的单位。绝对重置时刻使用电脑本地时区;周含日,5小时不含日期。
|
package/bin/easy-claude.js
CHANGED
|
@@ -5,16 +5,19 @@ import { readUsage, formatUsage } from '../src/usage.js';
|
|
|
5
5
|
|
|
6
6
|
const args = process.argv.slice(2);
|
|
7
7
|
if (args.length === 1 && ['--help', '-h'].includes(args[0])) {
|
|
8
|
-
console.log('用法:easy-claude [usage|overlay]\n显示已登录 Claude 账号的剩余百分比和重置时间。需要 Claude Code 订阅登录。');
|
|
8
|
+
console.log('用法:easy-claude [usage|show|overlay|agent mcp|agent worker 配置路径 [--check|--once]]\n显示已登录 Claude 账号的剩余百分比和重置时间。需要 Claude Code 订阅登录。');
|
|
9
9
|
} else if (args.length === 1 && ['--version', '-v'].includes(args[0])) {
|
|
10
10
|
console.log(version);
|
|
11
|
-
} else if (args.length === 1 &&
|
|
11
|
+
} else if (args.length === 1 && ['show', 'overlay'].includes(args[0])) {
|
|
12
12
|
try { const { launchOverlay } = await import('../src/overlay.js'); await launchOverlay(); }
|
|
13
13
|
catch (error) { console.error(`easy-claude: ${error.message}`); process.exitCode = 1; }
|
|
14
|
+
} else if (args[0] === 'agent') {
|
|
15
|
+
try { const { runAgent } = await import('../src/agent.js'); await runAgent(args.slice(1), 'claude'); }
|
|
16
|
+
catch (error) { console.error(`easy-claude: ${error.message}`); process.exitCode = 1; }
|
|
14
17
|
} else if (args.length === 0 || (args.length === 1 && args[0] === 'usage')) {
|
|
15
18
|
try { console.log(formatUsage(await readUsage())); }
|
|
16
19
|
catch (error) { console.error(`easy-claude: ${error.message}`); process.exitCode = 1; }
|
|
17
20
|
} else {
|
|
18
|
-
console.error('未知参数。用法:easy-claude [usage|overlay],或 easy-claude --help');
|
|
21
|
+
console.error('未知参数。用法:easy-claude [usage|show|overlay|agent mcp|agent worker 配置路径 [--check|--once]],或 easy-claude --help');
|
|
19
22
|
process.exitCode = 1;
|
|
20
23
|
}
|
package/native/Overlay.swift
CHANGED
|
@@ -73,6 +73,9 @@ class RingView: NSView {
|
|
|
73
73
|
var weeklyRemaining: Double?
|
|
74
74
|
var weeklyStale = true
|
|
75
75
|
var showWeeklyPercentage = false
|
|
76
|
+
var showWeeklyRing = true
|
|
77
|
+
var showFiveHourRing = true
|
|
78
|
+
var displaysWeeklyPercentage: Bool { showWeeklyRing && (showWeeklyPercentage || !showFiveHourRing) }
|
|
76
79
|
var stale = true
|
|
77
80
|
var caption = "等待额度"
|
|
78
81
|
var makeMenu: (() -> NSMenu)?
|
|
@@ -83,10 +86,11 @@ class RingView: NSView {
|
|
|
83
86
|
private var originStart = CGPoint.zero
|
|
84
87
|
|
|
85
88
|
override func draw(_ dirtyRect: NSRect) {
|
|
86
|
-
drawRing(radius: 14, remaining: weeklyRemaining, stale: weeklyStale, dashed: true)
|
|
87
|
-
drawRing(radius: 10, remaining: remaining, stale: stale)
|
|
88
|
-
let
|
|
89
|
-
let
|
|
89
|
+
if showWeeklyRing { drawRing(radius: 14, remaining: weeklyRemaining, stale: weeklyStale, dashed: true) }
|
|
90
|
+
if showFiveHourRing { drawRing(radius: showWeeklyRing ? 10 : 14, remaining: remaining, stale: stale) }
|
|
91
|
+
let useWeekly = displaysWeeklyPercentage
|
|
92
|
+
let percentage = useWeekly ? weeklyRemaining : remaining
|
|
93
|
+
let percentageStale = useWeekly ? weeklyStale : stale
|
|
90
94
|
let state = RingState.resolve(percentage, stale: percentageStale)
|
|
91
95
|
let text = percentage.map { "\(Int($0.rounded()))" } ?? "—"
|
|
92
96
|
drawText(text, y: 10, font: .monospacedDigitSystemFont(ofSize: 9, weight: .semibold), color: state.color)
|
|
@@ -149,6 +153,29 @@ struct ClockCity {
|
|
|
149
153
|
]
|
|
150
154
|
}
|
|
151
155
|
|
|
156
|
+
func resetDescription(_ resetsAt: Double?, weekly: Bool, now: Date = Date(), zone: TimeZone = .current) -> String {
|
|
157
|
+
guard let resetsAt, resetsAt.isFinite, abs(resetsAt) < 8.64e12 else { return "重置时间未知" }
|
|
158
|
+
let remaining = resetsAt - now.timeIntervalSince1970
|
|
159
|
+
guard remaining > 0 else { return "已到重置时间,等待更新" }
|
|
160
|
+
let formatter = DateFormatter()
|
|
161
|
+
formatter.locale = Locale(identifier: "zh_CN")
|
|
162
|
+
formatter.timeZone = zone
|
|
163
|
+
formatter.dateFormat = weekly ? "d'日' HH:mm" : "HH:mm"
|
|
164
|
+
let time = formatter.string(from: Date(timeIntervalSince1970: resetsAt))
|
|
165
|
+
let duration: String
|
|
166
|
+
if weekly {
|
|
167
|
+
if remaining >= 86400 { duration = "\(Int(remaining / 86400))天" }
|
|
168
|
+
else if remaining >= 3600 { duration = "\(Int(remaining / 3600))小时" }
|
|
169
|
+
else { duration = "\(Int(ceil(remaining / 60)))分钟" }
|
|
170
|
+
} else {
|
|
171
|
+
let totalMinutes = Int(ceil(remaining / 60))
|
|
172
|
+
let hours = totalMinutes / 60
|
|
173
|
+
let minutes = totalMinutes % 60
|
|
174
|
+
duration = (hours > 0 ? "\(hours)小时" : "") + (minutes > 0 ? "\(minutes)分" : "")
|
|
175
|
+
}
|
|
176
|
+
return "\(duration)后 \(time) 重置"
|
|
177
|
+
}
|
|
178
|
+
|
|
152
179
|
func clockText(at date: Date, zone: TimeZone) -> String {
|
|
153
180
|
let formatter = DateFormatter()
|
|
154
181
|
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
@@ -297,14 +324,19 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|
|
297
324
|
func stale(_ window: UsageWindow?) -> Bool {
|
|
298
325
|
snapshotStale || window?.remaining == nil || (window?.resetsAt.map { $0 <= now } ?? false)
|
|
299
326
|
}
|
|
327
|
+
ring.showWeeklyRing = weekly != nil || fiveHour == nil
|
|
328
|
+
ring.showFiveHourRing = fiveHour != nil
|
|
300
329
|
ring.remaining = fiveHour?.remaining
|
|
301
330
|
ring.stale = stale(fiveHour)
|
|
302
331
|
ring.weeklyRemaining = weekly?.remaining
|
|
303
332
|
ring.weeklyStale = stale(weekly)
|
|
304
333
|
func label(_ value: Double?) -> String { value.map { "\(Int($0.rounded()))%" } ?? "未知" }
|
|
305
|
-
let summary =
|
|
334
|
+
let summary = [
|
|
335
|
+
weekly == nil ? nil : "外侧粗环 · 周额度:\(label(weekly?.remaining))\(ring.weeklyStale ? "(未知或已过期)" : "")",
|
|
336
|
+
fiveHour == nil ? nil : "\(weekly == nil ? "单环" : "内侧细环") · 5 小时:\(label(fiveHour?.remaining))\(ring.stale ? "(未知或已过期)" : "")"
|
|
337
|
+
].compactMap { $0 }.joined(separator: "\n")
|
|
306
338
|
let fetched = snapshot.map { Date(timeIntervalSince1970: $0.fetchedAt).formatted(date: .omitted, time: .standard) } ?? "尚未更新"
|
|
307
|
-
ring.toolTip = "本机 Claude CLI 账号额度\n\(summary)\n\(error ?? snapshot?.detail ?? "正在读取")\n更新时间:\(fetched)\n中心数字为\(ring.
|
|
339
|
+
ring.toolTip = "本机 Claude CLI 账号额度\n\(summary)\n\(error ?? snapshot?.detail ?? "正在读取")\n更新时间:\(fetched)\n中心数字为\(ring.displaysWeeklyPercentage ? "周" : "5小时")剩余;拖动校准位置;双击刷新;右键打开菜单"
|
|
308
340
|
ring.setAccessibilityLabel("Claude \(summary)")
|
|
309
341
|
ring.needsDisplay = true
|
|
310
342
|
}
|
|
@@ -337,7 +369,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|
|
337
369
|
}
|
|
338
370
|
query = process
|
|
339
371
|
do { try process.run() }
|
|
340
|
-
catch { query = nil; self.error = "无法启动额度查询,请重新运行 easy-claude
|
|
372
|
+
catch { query = nil; self.error = "无法启动额度查询,请重新运行 easy-claude show"; updateRing() }
|
|
341
373
|
}
|
|
342
374
|
func item(_ title: String, _ action: Selector?) -> NSMenuItem {
|
|
343
375
|
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
|
|
@@ -352,25 +384,18 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|
|
352
384
|
if snapshot?.restricted == true { menu.addItem(item("服务端提示:当前使用受限", nil)) }
|
|
353
385
|
menu.addItem(.separator())
|
|
354
386
|
for (id, label) in [("five_hour:primary", "5小时"), ("seven_day:primary", "周")] {
|
|
355
|
-
let window = snapshot?.windows.first { $0.id == id }
|
|
356
|
-
let remaining = window
|
|
357
|
-
let reset:
|
|
358
|
-
|
|
359
|
-
let formatter = DateFormatter()
|
|
360
|
-
formatter.locale = Locale(identifier: "zh_CN")
|
|
361
|
-
formatter.timeZone = .current
|
|
362
|
-
formatter.dateFormat = "MM-dd HH:mm"
|
|
363
|
-
reset = formatter.string(from: Date(timeIntervalSince1970: seconds))
|
|
364
|
-
} else { reset = "未知" }
|
|
365
|
-
let option = item("\(label) · \(remaining) · 重置 \(reset)", #selector(selectPercentage(_:)))
|
|
387
|
+
guard let window = snapshot?.windows.first(where: { $0.id == id }) else { continue }
|
|
388
|
+
let remaining = window.remaining.map { "\(Int($0.rounded()))%" } ?? "未知"
|
|
389
|
+
let reset = resetDescription(window.resetsAt, weekly: id == "seven_day:primary")
|
|
390
|
+
let option = item("\(label) · \(remaining) · \(reset)", #selector(selectPercentage(_:)))
|
|
366
391
|
option.representedObject = id
|
|
367
|
-
option.state = (ring.
|
|
392
|
+
option.state = (ring.displaysWeeklyPercentage == (id == "seven_day:primary")) ? .on : .off
|
|
368
393
|
menu.addItem(option)
|
|
369
394
|
}
|
|
370
395
|
menu.addItem(item(query == nil ? "立即刷新" : "正在刷新…", query == nil ? #selector(refresh) : nil))
|
|
371
396
|
menu.addItem(item("恢复默认位置", #selector(resetPosition)))
|
|
372
397
|
menu.addItem(.separator())
|
|
373
|
-
let toggle = item("
|
|
398
|
+
let toggle = item("显示时间", #selector(toggleClock))
|
|
374
399
|
toggle.state = clockEnabled ? .on : .off
|
|
375
400
|
menu.addItem(toggle)
|
|
376
401
|
let zones = NSMenu()
|
|
@@ -381,7 +406,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|
|
381
406
|
zones.addItem(option)
|
|
382
407
|
}
|
|
383
408
|
zones.addItem(item("自定义时区…", #selector(customTimeZone)))
|
|
384
|
-
let zoneItem = item("
|
|
409
|
+
let zoneItem = item("\(clock.cityName)·\(clockText(at: Date(), zone: clock.zone))", nil)
|
|
385
410
|
zoneItem.submenu = zones
|
|
386
411
|
menu.addItem(zoneItem)
|
|
387
412
|
menu.addItem(.separator())
|
|
@@ -457,6 +482,26 @@ struct Main {
|
|
|
457
482
|
if CommandLine.arguments.contains("--self-test") {
|
|
458
483
|
precondition(ClockCity.presets.map(\.name) == ["硅谷", "洛杉矶", "西雅图", "华盛顿", "哥伦布", "新加坡", "上海"])
|
|
459
484
|
precondition(ClockCity.presets.allSatisfy { TimeZone(identifier: $0.identifier) != nil })
|
|
485
|
+
let countdownStart = ISO8601DateFormatter().date(from: "2026-10-15T04:57:00Z")!
|
|
486
|
+
let countdownUTC = TimeZone(secondsFromGMT: 0)!
|
|
487
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 10920, weekly: false, now: countdownStart, zone: countdownUTC) == "3小时2分后 07:59 重置")
|
|
488
|
+
let weekStart = ISO8601DateFormatter().date(from: "2026-10-14T08:03:00Z")!
|
|
489
|
+
precondition(resetDescription(weekStart.timeIntervalSince1970 + 345360, weekly: true, now: weekStart, zone: countdownUTC) == "3天后 18日 07:59 重置")
|
|
490
|
+
precondition(resetDescription(nil, weekly: true) == "重置时间未知")
|
|
491
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970, weekly: false, now: countdownStart) == "已到重置时间,等待更新")
|
|
492
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 1, weekly: false, now: countdownStart, zone: countdownUTC) == "1分后 04:57 重置")
|
|
493
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 86160, weekly: true, now: countdownStart, zone: countdownUTC) == "23小时后 16日 04:53 重置")
|
|
494
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 120, weekly: true, now: countdownStart, zone: countdownUTC) == "2分钟后 15日 04:59 重置")
|
|
495
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 86400, weekly: true, now: countdownStart, zone: countdownUTC) == "1天后 16日 04:57 重置")
|
|
496
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 86399, weekly: true, now: countdownStart, zone: countdownUTC) == "23小时后 16日 04:56 重置")
|
|
497
|
+
precondition(resetDescription(countdownStart.timeIntervalSince1970 + 3599, weekly: false, now: countdownStart, zone: countdownUTC) == "1小时后 05:56 重置")
|
|
498
|
+
let testRing = RingView()
|
|
499
|
+
testRing.showFiveHourRing = false
|
|
500
|
+
precondition(testRing.displaysWeeklyPercentage)
|
|
501
|
+
testRing.showWeeklyPercentage = true
|
|
502
|
+
testRing.showWeeklyRing = false
|
|
503
|
+
testRing.showFiveHourRing = true
|
|
504
|
+
precondition(!testRing.displaysWeeklyPercentage)
|
|
460
505
|
let la = TimeZone(identifier: "America/Los_Angeles")!
|
|
461
506
|
let singapore = TimeZone(identifier: "Asia/Singapore")!
|
|
462
507
|
let winter = ISO8601DateFormatter().date(from: "2026-01-15T12:00:00Z")!
|
|
@@ -503,6 +548,8 @@ struct Main {
|
|
|
503
548
|
let view = RingView(frame: CGRect(x: 0, y: 0, width: 32, height: 32))
|
|
504
549
|
view.remaining = value < 0 ? nil : value; view.stale = value < 0
|
|
505
550
|
view.weeklyRemaining = value < 0 ? nil : 100 - value; view.weeklyStale = value < 0
|
|
551
|
+
if index == 0 { view.showFiveHourRing = false }
|
|
552
|
+
if index == 1 { view.showWeeklyRing = false }
|
|
506
553
|
view.caption = value < 0 ? "额度未知" : "7天"
|
|
507
554
|
view.draw(view.bounds)
|
|
508
555
|
NSGraphicsContext.restoreGraphicsState()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<key>CFBundleIdentifier</key><string>com.unionschool.easy-claude.overlay</string>
|
|
6
6
|
<key>CFBundleName</key><string>Easy Claude Overlay</string>
|
|
7
7
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
8
|
-
<key>CFBundleShortVersionString</key><string>0.2.
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>0.2.1</string>
|
|
9
9
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
10
10
|
<key>LSUIElement</key><true/>
|
|
11
11
|
<key>NSHighResolutionCapable</key><true/>
|
|
Binary file
|