agy-bar 0.9.1 → 0.9.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/CHANGELOG.md +27 -0
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/bin/agy-bar.mjs +11 -2
- package/package.json +1 -1
- package/src/installer.mjs +118 -8
- package/src/monitor.mjs +30 -11
- package/src/quota-sync.mjs +291 -0
- package/src/render.mjs +17 -6
- package/src/statusline.mjs +36 -23
- package/src/tab-title.mjs +75 -21
- package/src/telemetry.mjs +51 -15
- package/src/title.mjs +136 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **agy-bar** are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.9.3] - 2026-11-26
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Official Native Antigravity CLI `title` Hook (`src/title.mjs`, `src/installer.mjs`)**:
|
|
9
|
+
- Upgraded terminal tab/window title sync to Antigravity CLI's official `settings.json` `"title"` command interface (`https://antigravity.google/docs/cli/title`) so `agy` itself drives window/tab titles cleanly on **macOS, Linux, and native Windows Terminal** with zero `/dev/tty` escape-sequence interleaving and zero `ps` subprocesses.
|
|
10
|
+
- `agy-bar install` automatically configures `settings.title` (backing up previous settings for clean `uninstall` restoration, refusing to overwrite unrelated custom `title` commands, and supporting `--no-title` opt-out); `agy-bar doctor` now verifies native title health.
|
|
11
|
+
- Uses a lightweight per-session `.title` marker so `statusline.mjs` automatically steps aside once native `title` is active while seamlessly keeping hardened `/dev/tty` fallback for un-restarted sessions.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Hardened Fallback Tab Title Sync (`src/tab-title.mjs`, `src/statusline.mjs`, `src/telemetry.mjs`)**:
|
|
15
|
+
- Ran fallback tab-title sync synchronously before async SQLite scans to prevent out-of-order `working`/`idle` races, cached `lastTabTty` for zero-`ps` direct writes with `O_NOCTTY`, widened `ps` timeout to `500ms`, and stopped persisting `lastTabTitle` on failed writes so retries happen automatically.
|
|
16
|
+
- **Account Isolation Key (`src/quota-sync.mjs`)**:
|
|
17
|
+
- Included AGY's live top-level `payload.email` field when computing the non-PII SHA-1 account key for local cross-terminal quota sync.
|
|
18
|
+
|
|
19
|
+
## [0.9.2] - 2026-11-26
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **Cross-Terminal Local Quota Freshness Sync (`src/quota-sync.mjs`)**:
|
|
23
|
+
- Shares observed account quota snapshots locally across concurrent `agy` terminals via atomic `~/.gemini/config/agy-bar/quota-cache.json` (zero network requests, zero extra disk writes when idle, hashed non-PII account isolation).
|
|
24
|
+
- Whenever **any** `agy` terminal triggers a new 5h/7d reset window (newer `reset_time`) or consumes quota in the same window (strictly lower `remaining_fraction`), all other idle terminals and `agy-bar monitor` automatically display the freshest quota on their very next refresh instead of staying stuck on stale `0% (due)` or outdated percentages.
|
|
25
|
+
- **Clearer Expired-Reset `(ready)` Indicator (`src/render.mjs`, `src/monitor.mjs`)**:
|
|
26
|
+
- When a `5h` bucket's `reset_time` has already passed (`reset_time <= now`) and the sibling `7d` weekly cap still has remaining quota, replaces alarming bold-red `0% (due)` with calm amber `0%` + green `(ready)` so you can tell at a glance that the reset point has passed and sending a message will refresh it.
|
|
27
|
+
- Keeps bold-red `0% (due)` when the sibling `7d` weekly bucket is also exhausted (`0%` and not yet due).
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- **Epoch-Zero Reset Sentinel (`1970-01-01T00:00:00Z`)**: Stopped rendering misleading `(due)` on unused 100% buckets whose protobuf zero timestamp (`1970-01-01T00:00:00Z`) indicates the window has not started yet.
|
|
31
|
+
|
|
5
32
|
## [0.9.1] - 2026-11-26
|
|
6
33
|
|
|
7
34
|
### Added
|
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
41
41
|
| **Line 1 · Left** | `~/code/agy-bar (main* +142 -38) · PX 7897` | Compact `~` path (`dirStyle`), live Git diff lines (tracked + untracked text, 3s cache), active proxy port badge, plus on-demand state badges (`CONFIRM` / `INPUT` when waiting on you, `ERR`, `● 34s · esc`, `SUB N` subagents, `TASK N` background tasks, `PLAN` / `SANDBOX`, Vim `[NORMAL]`) |
|
|
42
42
|
| **Line 1 · Right** | `DAY 136M/$13.2 · WK 810M · MO 875M · ALL 906M │ Model` | Calm neutral cumulative token/spend strip + active model & reasoning effort; sheds gracefully on narrow split panes |
|
|
43
43
|
| **Line 2 · Left** | `CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·158t/s │ ~$0.18` | Unified health context gauge (`→/compact` at danger), 5-min prompt cache TTL countdown, exact first-token latency + streaming decode speed, and live conversation spend (rolls up nested subagent costs automatically, refreshing every 20s while subagents run) |
|
|
44
|
-
| **Line 2 · Right** | `5h ▮▮▮▮▮▯ 85% (2h30m) │ 7d ▮▮▮▮▯▯ 64% (3d)` | Active model pool quotas (**Gemini 4 Neon / Carbon / Hydrogen / Argon** & **Claude 3p**) with reset countdowns |
|
|
44
|
+
| **Line 2 · Right** | `5h ▮▮▮▮▮▯ 85% (2h30m) │ 7d ▮▮▮▮▯▯ 64% (3d)` | Active model pool quotas (**Gemini 4 Neon / Carbon / Hydrogen / Argon** & **Claude 3p**) with live reset countdowns, local cross-terminal freshness sync, and green `(ready)` hint once a 5h reset point has passed |
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
@@ -82,7 +82,7 @@ Running 3–5 `agy` sessions across different repos? Open `agy-bar monitor` in a
|
|
|
82
82
|
|
|
83
83
|
### 5. Automatic Terminal Tab Titles (`●` / `● [N]` / `?` / `✓`) & Agent Summarization (`agy-bar title`)
|
|
84
84
|
|
|
85
|
-
Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTerm2, Kitty, WezTerm, macOS Terminal, and VS Code with live activity state (`●` working, `● [N]` running subagents, `?` waiting for user input/confirmation, `✗` error, `✓` truly idle) + concise topic title
|
|
85
|
+
Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTerm2, Kitty, WezTerm, macOS Terminal, Windows Terminal, and VS Code using **Antigravity CLI's official `title` hook** (`settings.json` → `title`, with automatic OSC 0/2 fallback for older sessions) to show live activity state (`●` working, `● [N]` running subagents, `?` waiting for user input/confirmation, `✗` error, `✓` truly idle) + concise topic title (zero extra tokens, full macOS / Linux / Windows support):
|
|
86
86
|
|
|
87
87
|

|
|
88
88
|
|
|
@@ -100,7 +100,7 @@ Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTe
|
|
|
100
100
|
|
|
101
101
|
| Guarantee | How It Works |
|
|
102
102
|
| --- | --- |
|
|
103
|
-
| **100% Official `statusLine`
|
|
103
|
+
| **100% Official `statusLine` + `title` Hooks** | Zero binary patching, zero Electron injection, zero Google/AGY private API calls, zero account credential access. Survives every AGY update cleanly. |
|
|
104
104
|
| **Read-Only Local Telemetry** | SQLite conversation scans (`Node >= 22.13`) open DBs in `readOnly: true` mode and extract **only numeric timestamps & token counts** — never prompts or replies. |
|
|
105
105
|
| **Transparent Network Policy** | Statusline rendering itself **never touches the network**. Only an optional 24-hour background sync fetches public unauthenticated pricing JSON (`models.dev` / `LiteLLM`); run `agy-bar config set pricingAutoSync off` for strict offline mode. |
|
|
106
106
|
| **Zero-Dep Fast Hot Path** | `0` runtime dependencies, zero-subprocess idle refreshes (PID fast-path + 3s Git cache + SQLite `mtime` skip + 5-min Windows theme cache), and atomic file writes across concurrent terminals. |
|
package/README.zh-CN.md
CHANGED
|
@@ -41,7 +41,7 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
41
41
|
| **第一行 · 左侧** | `~/code/agy-bar (main* +142 -38) · PX 7897` | 精简 `~` 路径(`dirStyle`)、当前改动实时增删行数(含已追踪修改与新建文本文件,3s 缓存)、本地代理端口徽章;按需亮起状态徽章(等待确认/输入 `CONFIRM`/`INPUT`、报错 `ERR`、工作态 `● 34s · esc`、并行子代理 `SUB N`、后台任务 `TASK N`、`PLAN`/`SANDBOX`、Vim `[NORMAL]`) |
|
|
42
42
|
| **第一行 · 右侧** | `DAY 136M/$13.2 · WK 810M · MO 875M · ALL 906M │ 模型` | 低饱和中性配色汇总今日/本周/本月/累计用量与今日费用 + 当前模型与思考强度;窄分屏自动分级退让 |
|
|
43
43
|
| **第二行 · 左侧** | `CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·158t/s │ ~$0.18` | 统一健康色上下文条(危急提示 `→/compact`)、5 分钟缓存保活倒计时、首字时间 + 纯解码速率、本对话预估费用(自动归集所有子代理与嵌套孙代理开销,子代理运行中每 20 秒准实时刷新) |
|
|
44
|
-
| **第二行 · 右侧** | `5h ▮▮▮▮▮▯ 85% (2h30m) │ 7d ▮▮▮▮▯▯ 64% (3d)` | 自动匹配当前模型额度池(**Gemini 4 Neon / Carbon / Hydrogen / Argon** 与 **Claude 3p
|
|
44
|
+
| **第二行 · 右侧** | `5h ▮▮▮▮▮▯ 85% (2h30m) │ 7d ▮▮▮▮▯▯ 64% (3d)` | 自动匹配当前模型额度池(**Gemini 4 Neon / Carbon / Hydrogen / Argon** 与 **Claude 3p**),支持多终端本地自动同步最新额度快照,5h 到点未刷新时直观提示绿色 `(ready)` |
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
@@ -82,7 +82,7 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
82
82
|
|
|
83
83
|
### 5. 终端标签页标题自动同步 (`●` / `● [N]` / `?` / `✓`) 与 Agent 摘要 (`agy-bar title`)
|
|
84
84
|
|
|
85
|
-
彻底告别多开时所有标签页都叫 `agy --dangerously-skip-permissions`
|
|
85
|
+
彻底告别多开时所有标签页都叫 `agy --dangerously-skip-permissions` 的烦恼:接入 **Antigravity CLI 官方原生 `title` 接口**(`settings.json` → `title`,旧会话自动回退 OSC 0/2),在 macOS / Linux / 原生 Windows Terminal 下的 Ghostty、iTerm2、Kitty、WezTerm、Terminal.app、VS Code 中稳定同步精确状态(`●` 工作中、`● [N]` 子代理运行中、`?` 等待你确认/输入、`✗` 报错、`✓` 全部完成)与精简主题(零额外 Token、无字节交错):
|
|
86
86
|
|
|
87
87
|

|
|
88
88
|
|
|
@@ -100,7 +100,7 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
100
100
|
|
|
101
101
|
| 承诺 | 实现机制 |
|
|
102
102
|
| --- | --- |
|
|
103
|
-
| **100% 官方原生 `statusLine` 接口** | 不修改/不注入任何客户端二进制,不调用任何 Google/AGY 私有接口,不接触账号凭据;官方任意升级不失效、零封号风险。 |
|
|
103
|
+
| **100% 官方原生 `statusLine` + `title` 接口** | 不修改/不注入任何客户端二进制,不调用任何 Google/AGY 私有接口,不接触账号凭据;官方任意升级不失效、零封号风险。 |
|
|
104
104
|
| **只读本地数值遥测** | SQLite 历史扫描(`Node >= 22.13`)全程 `readOnly: true`,**仅提取数值时间戳与 Token 计数**,绝不读取聊天正文。 |
|
|
105
105
|
| **透明联网策略** | 底栏渲染热路径**完全不联网**;仅默认每 24 小时后台异步拉取一次公开免鉴权的 `models.dev` / `LiteLLM` 参考单价,随时可 `agy-bar config set pricingAutoSync off` 严格离线。 |
|
|
106
106
|
| **零依赖极致流畅** | `0` 第三方依赖,空闲刷新零子进程(PID 快速路径 + 3s Git 缓存 + SQLite `mtime` 跳过 + 5 分钟 Windows 主题缓存),多终端并发采用原子写防文件损坏。 |
|
package/bin/agy-bar.mjs
CHANGED
|
@@ -76,9 +76,10 @@ export const HELP_TEXT = [
|
|
|
76
76
|
'Usage: agy-bar <command> [options]',
|
|
77
77
|
'',
|
|
78
78
|
'Commands:',
|
|
79
|
-
' install [options] Install statusline + global
|
|
79
|
+
' install [options] Install statusline + native AGY title hook + global agy-bar CLI',
|
|
80
80
|
' --proxy-hook Also install managed agy() shell hook without prompting',
|
|
81
81
|
' --no-proxy-hook Skip shell hook without prompting (leaves ~/.zshrc untouched)',
|
|
82
|
+
' --no-title Skip configuring AGY native settings.json title hook',
|
|
82
83
|
' --no-skill Skip installing the companion /agy-bar skill',
|
|
83
84
|
' --no-shim Skip installing the ~/.local/bin/agy-bar shortcut command',
|
|
84
85
|
' -y, --yes Non-interactive install (keeps ~/.zshrc untouched unless --proxy-hook)',
|
|
@@ -174,6 +175,8 @@ function parseFlags(args) {
|
|
|
174
175
|
else if (arg === '--with-skill') flags.withSkill = true;
|
|
175
176
|
else if (arg === '--no-shim') flags.withShim = false;
|
|
176
177
|
else if (arg === '--with-shim') flags.withShim = true;
|
|
178
|
+
else if (arg === '--no-title') flags.withTitle = false;
|
|
179
|
+
else if (arg === '--with-title') flags.withTitle = true;
|
|
177
180
|
else if (arg === '--no-shell-hook' || arg === '--no-proxy-hook') flags.withShellHook = false;
|
|
178
181
|
else if (arg === '--with-shell-hook' || arg === '--proxy-hook') flags.withShellHook = true;
|
|
179
182
|
else if (arg === '--yes' || arg === '-y') flags.yes = true;
|
|
@@ -267,6 +270,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
267
270
|
const result = installAgyBar({
|
|
268
271
|
withSkill: flags.withSkill ?? true,
|
|
269
272
|
withShim,
|
|
273
|
+
withTitle: flags.withTitle ?? true,
|
|
270
274
|
withShellHook: hookDecision.enable,
|
|
271
275
|
shell: flags.shell ?? null,
|
|
272
276
|
preset: flags.preset ?? null,
|
|
@@ -274,6 +278,11 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
274
278
|
barStyle: flags.barStyle ?? null,
|
|
275
279
|
});
|
|
276
280
|
console.log(`Installed agy-bar statusline at ${result.scriptPath}`);
|
|
281
|
+
if (result.titleScriptPath) {
|
|
282
|
+
console.log(`Installed native AGY title hook at ${result.titleScriptPath}`);
|
|
283
|
+
} else if (result.titleWarning) {
|
|
284
|
+
console.log(`Note: ${result.titleWarning}`);
|
|
285
|
+
}
|
|
277
286
|
console.log(`Updated AGY settings: ${result.settingsPath}`);
|
|
278
287
|
if (result.shimPath) {
|
|
279
288
|
console.log(`Installed global CLI command: ${result.shimPath}`);
|
|
@@ -469,7 +478,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
469
478
|
);
|
|
470
479
|
const writeRes = renderedTitle && cfg.tabTitle ? writeOscTitle(renderedTitle) : { written: false, tty: null };
|
|
471
480
|
if (writeRes.written) {
|
|
472
|
-
updateSessionTabTitle(updated.sessionId, renderedTitle, { hostPid: writeRes.hostPid });
|
|
481
|
+
updateSessionTabTitle(updated.sessionId, renderedTitle, { hostPid: writeRes.hostPid, tty: writeRes.tty });
|
|
473
482
|
}
|
|
474
483
|
console.log(
|
|
475
484
|
flags.clear
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-bar",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Zero-dependency terminal statusline, no-TUN proxy launcher, exact TTFT & tok/s speed, 5-min cache TTL countdown, live pricing cache, automatic tab titles, 52-week token heatmap, and multi-CLI monitor for Antigravity CLI (agy).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/installer.mjs
CHANGED
|
@@ -33,6 +33,10 @@ export function installedScriptPath(home = homedir()) {
|
|
|
33
33
|
return join(installedAppDir(home), 'src', 'statusline.mjs');
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function installedTitleScriptPath(home = homedir()) {
|
|
37
|
+
return join(installedAppDir(home), 'src', 'title.mjs');
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
export function installedCliPath(home = homedir()) {
|
|
37
41
|
return join(installedAppDir(home), 'bin', 'agy-bar.mjs');
|
|
38
42
|
}
|
|
@@ -49,11 +53,11 @@ function shQuote(value) {
|
|
|
49
53
|
return `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
export function buildCommand(executable, scriptPath, platform = process.platform) {
|
|
56
|
+
export function buildCommand(executable, scriptPath, platform = process.platform, exportName = 'runStatusline') {
|
|
53
57
|
if (platform === 'win32') {
|
|
54
58
|
// Avoid spaces, quotes, and '>' redirection operators for Windows cmd /c safety.
|
|
55
59
|
const encodedUrl = Buffer.from(pathToFileURL(scriptPath).href).toString('base64');
|
|
56
|
-
return `node -e import(Buffer.from('${encodedUrl}','base64').toString()).then(function(m){m
|
|
60
|
+
return `node -e import(Buffer.from('${encodedUrl}','base64').toString()).then(function(m){m.${exportName}()})`;
|
|
57
61
|
}
|
|
58
62
|
return `${shQuote(executable)} ${shQuote(scriptPath)}`;
|
|
59
63
|
}
|
|
@@ -112,6 +116,7 @@ export function isAgyBarCommand(command, backup = null) {
|
|
|
112
116
|
if (typeof command !== 'string' || !command.trim()) return false;
|
|
113
117
|
if (command.includes('agy-bar')) return true;
|
|
114
118
|
if (backup?.installedCommand && command === backup.installedCommand) return true;
|
|
119
|
+
if (backup?.installedTitleCommand && command === backup.installedTitleCommand) return true;
|
|
115
120
|
|
|
116
121
|
// Windows buildCommand() base64-encodes the file:// URL for cmd /c safety.
|
|
117
122
|
const b64Match = /Buffer\.from\('([A-Za-z0-9+/=]+)','base64'\)/.exec(command);
|
|
@@ -159,6 +164,7 @@ export function installAgyBar({
|
|
|
159
164
|
env = process.env,
|
|
160
165
|
withSkill = true,
|
|
161
166
|
withShim = true,
|
|
167
|
+
withTitle = true,
|
|
162
168
|
withShellHook = false,
|
|
163
169
|
shell = null,
|
|
164
170
|
preset = null,
|
|
@@ -176,6 +182,7 @@ export function installAgyBar({
|
|
|
176
182
|
|
|
177
183
|
const appDir = installedAppDir(home);
|
|
178
184
|
const scriptPath = installedScriptPath(home);
|
|
185
|
+
const titleScriptPath = installedTitleScriptPath(home);
|
|
179
186
|
const cliPath = installedCliPath(home);
|
|
180
187
|
const settingsPath = agySettingsPath(home);
|
|
181
188
|
const backupPath = backupFilePath(home);
|
|
@@ -208,19 +215,56 @@ export function installAgyBar({
|
|
|
208
215
|
|
|
209
216
|
const settings = existsSync(settingsPath) ? readJson(settingsPath) : {};
|
|
210
217
|
const existingBackup = existsSync(backupPath) ? readJson(backupPath) : null;
|
|
211
|
-
const command = buildCommand(executable, scriptPath, platform);
|
|
218
|
+
const command = buildCommand(executable, scriptPath, platform, 'runStatusline');
|
|
219
|
+
const titleCommand = buildCommand(executable, titleScriptPath, platform, 'runTitleCommand');
|
|
220
|
+
|
|
221
|
+
const existingTitleOurs = Boolean(
|
|
222
|
+
settings.title &&
|
|
223
|
+
(settings.title?.command === existingBackup?.installedTitleCommand ||
|
|
224
|
+
isAgyBarCommand(settings.title?.command, existingBackup)),
|
|
225
|
+
);
|
|
226
|
+
const hasUnrelatedTitle = Boolean(settings.title && !existingTitleOurs);
|
|
227
|
+
let titleInstalled = false;
|
|
228
|
+
let titleWarning = null;
|
|
212
229
|
|
|
213
230
|
// Keep the original backup across upgrades unless the user switched away to another renderer.
|
|
214
|
-
const
|
|
231
|
+
const statusLineBackup =
|
|
215
232
|
existingBackup && settings.statusLine?.command === existingBackup.installedCommand
|
|
216
|
-
? {
|
|
233
|
+
? {
|
|
234
|
+
hadStatusLine: existingBackup.hadStatusLine,
|
|
235
|
+
statusLine: existingBackup.statusLine,
|
|
236
|
+
installedCommand: command,
|
|
237
|
+
}
|
|
217
238
|
: {
|
|
218
239
|
hadStatusLine: Object.hasOwn(settings, 'statusLine'),
|
|
219
240
|
statusLine: settings.statusLine ?? null,
|
|
220
241
|
installedCommand: command,
|
|
221
242
|
};
|
|
222
243
|
|
|
223
|
-
|
|
244
|
+
let titleBackup;
|
|
245
|
+
if (existingBackup && Object.hasOwn(existingBackup, 'hadTitle') && existingTitleOurs) {
|
|
246
|
+
titleBackup = {
|
|
247
|
+
hadTitle: existingBackup.hadTitle,
|
|
248
|
+
title: existingBackup.title,
|
|
249
|
+
installedTitleCommand: withTitle ? titleCommand : existingBackup.installedTitleCommand ?? null,
|
|
250
|
+
};
|
|
251
|
+
} else if (withTitle && !hasUnrelatedTitle) {
|
|
252
|
+
titleBackup = {
|
|
253
|
+
hadTitle: Object.hasOwn(settings, 'title'),
|
|
254
|
+
title: settings.title ?? null,
|
|
255
|
+
installedTitleCommand: titleCommand,
|
|
256
|
+
};
|
|
257
|
+
} else if (existingBackup && Object.hasOwn(existingBackup, 'hadTitle')) {
|
|
258
|
+
titleBackup = {
|
|
259
|
+
hadTitle: existingBackup.hadTitle,
|
|
260
|
+
title: existingBackup.title,
|
|
261
|
+
installedTitleCommand: existingBackup.installedTitleCommand ?? null,
|
|
262
|
+
};
|
|
263
|
+
} else {
|
|
264
|
+
titleBackup = {};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
writeJson(backupPath, { ...statusLineBackup, ...titleBackup });
|
|
224
268
|
|
|
225
269
|
settings.statusLine = {
|
|
226
270
|
type: 'command',
|
|
@@ -228,11 +272,28 @@ export function installAgyBar({
|
|
|
228
272
|
enabled: true,
|
|
229
273
|
stack_with_default: false,
|
|
230
274
|
};
|
|
275
|
+
|
|
276
|
+
if (withTitle) {
|
|
277
|
+
if (hasUnrelatedTitle) {
|
|
278
|
+
titleWarning = 'Kept existing custom AGY title command in settings.json (pass --no-title to silence this note).';
|
|
279
|
+
} else {
|
|
280
|
+
settings.title = {
|
|
281
|
+
type: 'command',
|
|
282
|
+
command: titleCommand,
|
|
283
|
+
enabled: savedConfig.tabTitle !== false,
|
|
284
|
+
};
|
|
285
|
+
titleInstalled = true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
231
289
|
writeJson(settingsPath, settings);
|
|
232
290
|
|
|
233
291
|
return {
|
|
234
292
|
installed: true,
|
|
235
293
|
scriptPath,
|
|
294
|
+
titleScriptPath: titleInstalled ? titleScriptPath : null,
|
|
295
|
+
titleCommand: titleInstalled ? titleCommand : null,
|
|
296
|
+
titleWarning,
|
|
236
297
|
cliPath,
|
|
237
298
|
shimPath,
|
|
238
299
|
shimWarning,
|
|
@@ -261,22 +322,50 @@ export function uninstallAgyBar({
|
|
|
261
322
|
const hadApp = existsSync(appDir);
|
|
262
323
|
const hadCfgDir = existsSync(cfgDir);
|
|
263
324
|
let restored = false;
|
|
325
|
+
let titleRestored = false;
|
|
264
326
|
|
|
265
327
|
if (hadBackup) {
|
|
266
328
|
const backup = readJson(backupPath);
|
|
267
329
|
if (existsSync(settingsPath)) {
|
|
268
330
|
const settings = readJson(settingsPath);
|
|
331
|
+
let settingsChanged = false;
|
|
269
332
|
if (settings.statusLine?.command === backup.installedCommand) {
|
|
270
333
|
if (backup.hadStatusLine) {
|
|
271
334
|
settings.statusLine = backup.statusLine;
|
|
272
335
|
} else {
|
|
273
336
|
delete settings.statusLine;
|
|
274
337
|
}
|
|
275
|
-
writeJson(settingsPath, settings);
|
|
276
338
|
restored = true;
|
|
339
|
+
settingsChanged = true;
|
|
340
|
+
}
|
|
341
|
+
if (
|
|
342
|
+
backup.installedTitleCommand &&
|
|
343
|
+
(settings.title?.command === backup.installedTitleCommand || isAgyBarCommand(settings.title?.command, backup))
|
|
344
|
+
) {
|
|
345
|
+
if (backup.hadTitle) {
|
|
346
|
+
settings.title = backup.title;
|
|
347
|
+
} else {
|
|
348
|
+
delete settings.title;
|
|
349
|
+
}
|
|
350
|
+
titleRestored = true;
|
|
351
|
+
settingsChanged = true;
|
|
352
|
+
}
|
|
353
|
+
if (settingsChanged) {
|
|
354
|
+
writeJson(settingsPath, settings);
|
|
277
355
|
}
|
|
278
356
|
}
|
|
279
357
|
rmSync(backupPath, { force: true, maxRetries: 3, retryDelay: 50 });
|
|
358
|
+
} else if (existsSync(settingsPath)) {
|
|
359
|
+
try {
|
|
360
|
+
const settings = readJson(settingsPath);
|
|
361
|
+
if (isAgyBarCommand(settings.title?.command)) {
|
|
362
|
+
delete settings.title;
|
|
363
|
+
writeJson(settingsPath, settings);
|
|
364
|
+
titleRestored = true;
|
|
365
|
+
}
|
|
366
|
+
} catch {
|
|
367
|
+
// Ignore malformed settings.json during orphan cleanup.
|
|
368
|
+
}
|
|
280
369
|
}
|
|
281
370
|
|
|
282
371
|
const shimRemoved = uninstallCliShim({ home, platform });
|
|
@@ -295,12 +384,13 @@ export function uninstallAgyBar({
|
|
|
295
384
|
}
|
|
296
385
|
|
|
297
386
|
const removedAnything = Boolean(
|
|
298
|
-
hadBackup || hadApp || shimRemoved || hookResult.removed || skillResult?.removed || (purge && hadCfgDir),
|
|
387
|
+
hadBackup || hadApp || shimRemoved || hookResult.removed || skillResult?.removed || titleRestored || (purge && hadCfgDir),
|
|
299
388
|
);
|
|
300
389
|
if (!removedAnything) {
|
|
301
390
|
return {
|
|
302
391
|
uninstalled: false,
|
|
303
392
|
restored: false,
|
|
393
|
+
titleRestored: false,
|
|
304
394
|
shimRemoved: false,
|
|
305
395
|
shellHookRemoved: false,
|
|
306
396
|
shellHookPaths: [],
|
|
@@ -313,6 +403,7 @@ export function uninstallAgyBar({
|
|
|
313
403
|
return {
|
|
314
404
|
uninstalled: true,
|
|
315
405
|
restored,
|
|
406
|
+
titleRestored,
|
|
316
407
|
shimRemoved,
|
|
317
408
|
shellHookRemoved: hookResult.removed,
|
|
318
409
|
shellHookPaths: hookResult.rcPaths,
|
|
@@ -329,6 +420,7 @@ export function uninstallAgyBar({
|
|
|
329
420
|
export function runDoctor({ home = homedir(), platform = process.platform, env = process.env } = {}) {
|
|
330
421
|
const settingsPath = agySettingsPath(home);
|
|
331
422
|
const scriptPath = installedScriptPath(home);
|
|
423
|
+
const titleScriptPath = installedTitleScriptPath(home);
|
|
332
424
|
const shimDest = cliShimPath(home, platform);
|
|
333
425
|
const cfgPath = configPath(home);
|
|
334
426
|
const skillPath = targetSkillPath(home);
|
|
@@ -368,6 +460,8 @@ export function runDoctor({ home = homedir(), platform = process.platform, env =
|
|
|
368
460
|
|
|
369
461
|
let statusLineEnabled = false;
|
|
370
462
|
let settingsDetail = 'settings.json not found';
|
|
463
|
+
let nativeTitleActive = false;
|
|
464
|
+
let nativeTitleDetail = 'not configured (run "agy-bar install" to enable native cross-platform tab titles)';
|
|
371
465
|
let backup = null;
|
|
372
466
|
const backupPath = backupFilePath(home);
|
|
373
467
|
if (existsSync(backupPath)) {
|
|
@@ -388,6 +482,16 @@ export function runDoctor({ home = homedir(), platform = process.platform, env =
|
|
|
388
482
|
: settings.statusLine
|
|
389
483
|
? `statusLine points to another command (${settings.statusLine.command || 'unknown'})`
|
|
390
484
|
: 'statusLine not configured';
|
|
485
|
+
|
|
486
|
+
const titleIsOurs = isAgyBarCommand(settings.title?.command, backup);
|
|
487
|
+
nativeTitleActive = settings.title?.enabled === true && titleIsOurs && existsSync(titleScriptPath);
|
|
488
|
+
nativeTitleDetail = nativeTitleActive
|
|
489
|
+
? 'title.enabled = true (agy-bar native title active — macOS/Linux/Windows)'
|
|
490
|
+
: titleIsOurs && settings.title?.enabled === false
|
|
491
|
+
? 'title.enabled = false (disabled in settings.json; run "/title on" in agy)'
|
|
492
|
+
: settings.title
|
|
493
|
+
? `title points to another command (${settings.title.command || 'unknown'})`
|
|
494
|
+
: nativeTitleDetail;
|
|
391
495
|
} catch (err) {
|
|
392
496
|
settingsDetail = `Failed to parse settings.json: ${err.message}`;
|
|
393
497
|
}
|
|
@@ -397,6 +501,12 @@ export function runDoctor({ home = homedir(), platform = process.platform, env =
|
|
|
397
501
|
ok: statusLineEnabled,
|
|
398
502
|
detail: settingsDetail,
|
|
399
503
|
});
|
|
504
|
+
checks.push({
|
|
505
|
+
name: 'AGY native title',
|
|
506
|
+
ok: nativeTitleActive,
|
|
507
|
+
optional: true,
|
|
508
|
+
detail: nativeTitleDetail,
|
|
509
|
+
});
|
|
400
510
|
|
|
401
511
|
const skillInstalled = existsSync(skillPath);
|
|
402
512
|
checks.push({
|
package/src/monitor.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { bold, clipPlain, detectColorDepth, fg, visibleWidth } from './ansi.mjs';
|
|
2
2
|
import { loadConfig } from './config.mjs';
|
|
3
3
|
import { formatUsd } from './pricing.mjs';
|
|
4
|
+
import { isBucketResetDue, isWeeklyBucketBlocking, mergeQuotaSnapshots, readSharedQuota } from './quota-sync.mjs';
|
|
4
5
|
import { formatReset, formatTtft, renderBar } from './render.mjs';
|
|
5
6
|
import { listSessions } from './telemetry.mjs';
|
|
6
7
|
import { resolvePalette } from './themes.mjs';
|
|
@@ -108,7 +109,7 @@ function describeMonitorState(session, p, useColor) {
|
|
|
108
109
|
|
|
109
110
|
export function renderMonitorFrame(
|
|
110
111
|
sessions,
|
|
111
|
-
{ now = Date.now(), config = loadConfig(), color = true, env = process.env, columns = process.stdout.columns || 98 } = {},
|
|
112
|
+
{ now = Date.now(), config = loadConfig(), color = true, env = process.env, columns = process.stdout.columns || 98, sharedQuota = null } = {},
|
|
112
113
|
) {
|
|
113
114
|
const resolved = resolvePalette(config.theme, { env });
|
|
114
115
|
const colorDepth = detectColorDepth(env);
|
|
@@ -126,17 +127,33 @@ export function renderMonitorFrame(
|
|
|
126
127
|
);
|
|
127
128
|
lines.push(fg('─'.repeat(ruleWidth), p.sep, useColor));
|
|
128
129
|
|
|
129
|
-
//
|
|
130
|
-
const latestQuota =
|
|
130
|
+
// Merge quota across shared cache + all sessions so the freshest reset window and usage always win.
|
|
131
|
+
const latestQuota = mergeQuotaSnapshots(
|
|
132
|
+
[sharedQuota, ...sessions.map((s) => ({ quota: s.quota, observedAt: s.updatedAt }))],
|
|
133
|
+
now,
|
|
134
|
+
);
|
|
131
135
|
if (latestQuota) {
|
|
136
|
+
const labelOrder = Object.keys(QUOTA_LABELS);
|
|
137
|
+
const sortedEntries = Object.entries(latestQuota).sort(([a], [b]) => {
|
|
138
|
+
const ia = labelOrder.indexOf(a);
|
|
139
|
+
const ib = labelOrder.indexOf(b);
|
|
140
|
+
return (ia < 0 ? 999 : ia) - (ib < 0 ? 999 : ib) || a.localeCompare(b);
|
|
141
|
+
});
|
|
132
142
|
const qItems = [];
|
|
133
|
-
for (const [id, q] of
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const
|
|
143
|
+
for (const [id, q] of sortedEntries) {
|
|
144
|
+
const frac = typeof q.remaining_fraction === 'number' ? q.remaining_fraction : q.remaining;
|
|
145
|
+
if (typeof frac !== 'number') continue;
|
|
146
|
+
const pct = Math.round(frac * 100);
|
|
147
|
+
const due = isBucketResetDue(q, now);
|
|
148
|
+
const blockedByWeekly = due && isWeeklyBucketBlocking(id, latestQuota, now);
|
|
149
|
+
const resetReady = due && !blockedByWeekly;
|
|
150
|
+
const rawTone = pct <= config.quotaDanger ? p.danger : pct <= config.quotaWarn ? p.warn : p.good;
|
|
151
|
+
const tone = resetReady && pct <= config.quotaDanger ? p.warn : rawTone;
|
|
152
|
+
const bar = renderBar(frac, { width: 6, style: config.barStyle, fillColor: tone, trackColor: p.track, color: useColor });
|
|
153
|
+
const resetText = resetReady ? 'ready' : formatReset(q, now);
|
|
154
|
+
const resetPart = resetText ? fg(` (${resetText})`, resetReady ? p.good : p.muted, useColor) : '';
|
|
138
155
|
const label = QUOTA_LABELS[id] || id;
|
|
139
|
-
qItems.push(`${fg(label, p.muted, useColor)} ${bar} ${fg(`${pct}%`, tone, useColor)}${
|
|
156
|
+
qItems.push(`${fg(label, p.muted, useColor)} ${bar} ${fg(`${pct}%`, tone, useColor)}${resetPart}`);
|
|
140
157
|
}
|
|
141
158
|
if (qItems.length > 0) {
|
|
142
159
|
lines.push(`${fg('Quota: ', p.muted, useColor)}${qItems.join(fg(' │ ', p.sep, useColor))}`);
|
|
@@ -205,9 +222,11 @@ export function renderMonitorFrame(
|
|
|
205
222
|
|
|
206
223
|
export async function startMonitor({ intervalMs = 1000, once = false, color = true, baseDir } = {}) {
|
|
207
224
|
const renderOnce = () => {
|
|
225
|
+
const now = Date.now();
|
|
208
226
|
const config = loadConfig();
|
|
209
|
-
const sessions = listSessions({ baseDir, prune: true });
|
|
210
|
-
|
|
227
|
+
const sessions = listSessions({ baseDir, now, prune: true });
|
|
228
|
+
const sharedQuota = readSharedQuota({ baseDir, now })?.buckets || null;
|
|
229
|
+
return renderMonitorFrame(sessions, { now, config, color, sharedQuota });
|
|
211
230
|
};
|
|
212
231
|
|
|
213
232
|
if (once || !process.stdout.isTTY) {
|