agy-bar 0.0.0-stage → 0.9.0
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/AGENTS.md +33 -0
- package/CHANGELOG.md +163 -0
- package/LICENSE +21 -0
- package/README.md +234 -2
- package/README.zh-CN.md +235 -0
- package/bin/agy-bar.mjs +971 -0
- package/package.json +59 -4
- package/skills/agy-bar/SKILL.md +46 -0
- package/src/ansi.mjs +201 -0
- package/src/config.mjs +623 -0
- package/src/fs-atomic.mjs +18 -0
- package/src/git.mjs +213 -0
- package/src/history-scan.mjs +457 -0
- package/src/installer.mjs +438 -0
- package/src/monitor.mjs +173 -0
- package/src/preview.mjs +222 -0
- package/src/pricing-sync.mjs +421 -0
- package/src/pricing.mjs +228 -0
- package/src/proxy.mjs +829 -0
- package/src/render.mjs +860 -0
- package/src/shell-hook.mjs +261 -0
- package/src/skill.mjs +42 -0
- package/src/stats.mjs +693 -0
- package/src/statusline.mjs +136 -0
- package/src/step-timing.mjs +164 -0
- package/src/tab-title.mjs +232 -0
- package/src/telemetry.mjs +526 -0
- package/src/themes.mjs +145 -0
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-bar",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.9.0",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "xy-tuoren",
|
|
8
|
+
"homepage": "https://github.com/xy-tuoren/agy-bar",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/xy-tuoren/agy-bar.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xy-tuoren/agy-bar/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"antigravity",
|
|
18
|
+
"agy",
|
|
19
|
+
"cli",
|
|
20
|
+
"statusline",
|
|
21
|
+
"hud",
|
|
22
|
+
"dashboard",
|
|
23
|
+
"quota",
|
|
24
|
+
"context-window",
|
|
25
|
+
"token-usage",
|
|
26
|
+
"heatmap",
|
|
27
|
+
"pricing",
|
|
28
|
+
"proxy",
|
|
29
|
+
"gemini",
|
|
30
|
+
"claude",
|
|
31
|
+
"terminal"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20.0.0"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"agy-bar": "./bin/agy-bar.mjs"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"AGENTS.md",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"bin/",
|
|
43
|
+
"src/",
|
|
44
|
+
"skills/",
|
|
45
|
+
"README.md",
|
|
46
|
+
"README.zh-CN.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"test": "node --test",
|
|
51
|
+
"install:agy": "node bin/agy-bar.mjs install",
|
|
52
|
+
"uninstall:agy": "node bin/agy-bar.mjs uninstall",
|
|
53
|
+
"preview": "node bin/agy-bar.mjs preview",
|
|
54
|
+
"preview:svg": "node scripts/generate-preview-svg.mjs && node scripts/generate-stats-svg.mjs && node scripts/generate-showcase-svgs.mjs",
|
|
55
|
+
"stats": "node bin/agy-bar.mjs stats",
|
|
56
|
+
"pricing": "node bin/agy-bar.mjs pricing",
|
|
57
|
+
"monitor": "node bin/agy-bar.mjs monitor",
|
|
58
|
+
"debug": "node bin/agy-bar.mjs debug",
|
|
59
|
+
"doctor": "node bin/agy-bar.mjs doctor"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agy-bar
|
|
3
|
+
description: Inspect and customize the agy-bar statusline, launch agy through a local proxy without TUN mode, set concise terminal tab titles, check local CLI usage stats and estimated API costs, monitor concurrent CLI sessions, or debug payloads for Antigravity CLI. Use when the user asks to configure agy-bar, set up or check no-TUN proxy for agy, rename/summarize the terminal tab title, switch themes/presets/colorMode/barStyle, toggle items, or run stats/monitor/debug.
|
|
4
|
+
---
|
|
5
|
+
<!-- agy-bar: managed skill -->
|
|
6
|
+
|
|
7
|
+
# agy-bar Guide
|
|
8
|
+
|
|
9
|
+
Use the installed `agy-bar` CLI helper to manage `~/.gemini/config/agy-bar/config.json`, configure the no-TUN proxy launcher, update terminal tab titles, and inspect local telemetry. Never edit unrelated Antigravity CLI settings.
|
|
10
|
+
|
|
11
|
+
## CLI Entrypoint
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
agy-bar <command> # installed at ~/.local/bin/agy-bar (or: node ~/.gemini/config/agy-bar/app/bin/agy-bar.mjs <command>)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Common Commands
|
|
18
|
+
|
|
19
|
+
| Intent | Command |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Launch `agy` via local proxy (no TUN) | Plain `agy [args...]` (via shell hook) or `agy-bar run [agy args...]` |
|
|
22
|
+
| Auto-detect / set / check no-TUN proxy | `agy-bar proxy auto` / `agy-bar proxy set http://127.0.0.1:7897` / `agy-bar proxy status` |
|
|
23
|
+
| Manage shell hook / toggle / exports | `agy-bar proxy hook\|unhook` / `agy-bar proxy on\|off` / `agy-bar proxy env` |
|
|
24
|
+
| Set concise tab title (~10 tokens) | `agy-bar title "<4-8 char concise topic>"` |
|
|
25
|
+
| Clear custom tab title | `agy-bar title --clear` |
|
|
26
|
+
| Configure tab title sync | `agy-bar config set tabTitle on\|off tabTitleSource auto\|title\|dir\|title+dir` |
|
|
27
|
+
| Show current settings | `agy-bar config show` |
|
|
28
|
+
| Switch preset / theme / bar style | `agy-bar config preset ...` / `agy-bar config theme ...` / `agy-bar config bar-style ...` |
|
|
29
|
+
| Switch gauge color mode / path style | `agy-bar config set colorMode health \| distinct` / `agy-bar config set dirStyle short \| parent \| name` |
|
|
30
|
+
| Show / hide elements | `agy-bar config enable cost session contextDelta` / `agy-bar config disable dir ttft speed` |
|
|
31
|
+
| Tune alerts, timing, or pricing sync | `agy-bar config set ttftWarnSec 8 ttftDangerSec 15 dbTiming on pricingAutoSync on\|off` |
|
|
32
|
+
| Full-history token heatmap & stats | `agy-bar stats [today\|7d\|30d\|all] [--source all\|cli\|desktop\|ledger] [--palette purple\|green\|cyan\|amber]` |
|
|
33
|
+
| Inspect, sync, or override model pricing | `agy-bar pricing show` / `agy-bar pricing sync` / `agy-bar pricing set <model> <in> <out> [cacheRead]` |
|
|
34
|
+
| Multi-CLI live monitor | `agy-bar monitor [--once]` |
|
|
35
|
+
| Redacted payload debug | `agy-bar debug --capture` then `agy-bar debug` |
|
|
36
|
+
| Preview / Diagnostics | `agy-bar preview --scenario all` / `agy-bar doctor` |
|
|
37
|
+
|
|
38
|
+
## Toggleable Items
|
|
39
|
+
|
|
40
|
+
`hint`, `vim`, `mode`, `subagents`, `turnTimer`, `proxy`, `dir`, `model`, `effort`, `git`, `gitDirty`, `gitDiff`, `context`, `contextBar`, `contextDelta`, `compactHint`, `capacity`, `cache`, `cacheTtl`, `ttft`, `speed`, `cost`, `todayCost`, `session`, `todayTokens`, `weekTokens`, `monthTokens`, `totalTokens`, `quota`, `quotaBar`, `quota5h`, `quotaWeekly`, `reset`
|
|
41
|
+
|
|
42
|
+
## Workflow
|
|
43
|
+
|
|
44
|
+
1. Run `agy-bar config show` (or `agy-bar proxy status`) first if current preferences are unclear.
|
|
45
|
+
2. When summarizing a terminal tab title, condense the active topic into 4–8 Chinese chars (or 3–5 English words) directly from current context and run `agy-bar title "<summary>"` without extra LLM calls.
|
|
46
|
+
3. Configuration changes take effect on the next statusline refresh without restarting `agy`.
|
package/src/ansi.mjs
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
|
|
2
|
+
|
|
3
|
+
export function stripAnsi(text) {
|
|
4
|
+
return String(text ?? '').replace(ANSI_REGEX, '');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function sanitizeText(value) {
|
|
8
|
+
return stripAnsi(String(value ?? '')).replace(/[\x00-\x1f\x7f]/g, '').trim();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function rgbToAnsi256(r, g, b) {
|
|
12
|
+
const clamp = (v) => Math.max(0, Math.min(255, Math.round(Number(v) || 0)));
|
|
13
|
+
const cr = clamp(r);
|
|
14
|
+
const cg = clamp(g);
|
|
15
|
+
const cb = clamp(b);
|
|
16
|
+
|
|
17
|
+
// Nearest 6x6x6 xterm color cube index (16..231).
|
|
18
|
+
const levels = [0, 95, 135, 175, 215, 255];
|
|
19
|
+
const nearestCube = (val) => {
|
|
20
|
+
let bestIdx = 0;
|
|
21
|
+
let bestDist = Infinity;
|
|
22
|
+
for (let i = 0; i < levels.length; i++) {
|
|
23
|
+
const d = Math.abs(val - levels[i]);
|
|
24
|
+
if (d < bestDist) {
|
|
25
|
+
bestDist = d;
|
|
26
|
+
bestIdx = i;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return bestIdx;
|
|
30
|
+
};
|
|
31
|
+
const ri = nearestCube(cr);
|
|
32
|
+
const gi = nearestCube(cg);
|
|
33
|
+
const bi = nearestCube(cb);
|
|
34
|
+
const cubeIdx = 16 + 36 * ri + 6 * gi + bi;
|
|
35
|
+
const cubeDist =
|
|
36
|
+
(cr - levels[ri]) ** 2 + (cg - levels[gi]) ** 2 + (cb - levels[bi]) ** 2;
|
|
37
|
+
|
|
38
|
+
// Nearest 24-step xterm grayscale ramp index (232..255).
|
|
39
|
+
const avg = (cr + cg + cb) / 3;
|
|
40
|
+
const grayStep = Math.max(0, Math.min(23, Math.round((avg - 8) / 10)));
|
|
41
|
+
const grayVal = 8 + grayStep * 10;
|
|
42
|
+
const grayIdx = 232 + grayStep;
|
|
43
|
+
const grayDist = (cr - grayVal) ** 2 + (cg - grayVal) ** 2 + (cb - grayVal) ** 2;
|
|
44
|
+
|
|
45
|
+
return grayDist < cubeDist ? grayIdx : cubeIdx;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function detectColorDepth(env = process.env) {
|
|
49
|
+
if (!env || typeof env !== 'object') return 'truecolor';
|
|
50
|
+
if ('NO_COLOR' in env) return 'none';
|
|
51
|
+
const term = String(env.TERM || '').trim().toLowerCase();
|
|
52
|
+
if (term === 'dumb') return 'none';
|
|
53
|
+
|
|
54
|
+
const colorterm = String(env.COLORTERM || '').trim().toLowerCase();
|
|
55
|
+
if (colorterm.includes('truecolor') || colorterm.includes('24bit')) return 'truecolor';
|
|
56
|
+
|
|
57
|
+
const termProgram = String(env.TERM_PROGRAM || '').trim();
|
|
58
|
+
if (termProgram === 'Apple_Terminal') return '256';
|
|
59
|
+
|
|
60
|
+
if (
|
|
61
|
+
env.WT_SESSION ||
|
|
62
|
+
env.KITTY_WINDOW_ID ||
|
|
63
|
+
env.KONSOLE_VERSION ||
|
|
64
|
+
env.VTE_VERSION ||
|
|
65
|
+
env.DOMTERM ||
|
|
66
|
+
/^(?:ghostty|iterm\.app|wezterm|vscode|hyper|tabby|warpterminal|alacritty|rio|contour)$/i.test(termProgram) ||
|
|
67
|
+
/(?:direct|kitty|ghostty|alacritty|wezterm)/.test(term)
|
|
68
|
+
) {
|
|
69
|
+
return 'truecolor';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (/(?:^|-)(?:256color)$/.test(term)) return '256';
|
|
73
|
+
return 'truecolor';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function fg(text, rgb, enabled = true) {
|
|
77
|
+
if (!enabled || enabled === 'none' || !rgb || !text) return String(text ?? '');
|
|
78
|
+
const [r, g, b] = rgb;
|
|
79
|
+
if (enabled === '256') {
|
|
80
|
+
return `\x1b[38;5;${rgbToAnsi256(r, g, b)}m${text}\x1b[0m`;
|
|
81
|
+
}
|
|
82
|
+
return `\x1b[38;2;${r};${g};${b}m${text}\x1b[0m`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function bold(text, enabled = true) {
|
|
86
|
+
if (!enabled || !text) return String(text ?? '');
|
|
87
|
+
return `\x1b[1m${text}\x1b[22m`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function dim(text, enabled = true) {
|
|
91
|
+
if (!enabled || !text) return String(text ?? '');
|
|
92
|
+
return `\x1b[2m${text}\x1b[22m`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function charWidth(ch) {
|
|
96
|
+
const cp = ch.codePointAt(0);
|
|
97
|
+
if (cp === undefined || cp < 0x20 || (cp >= 0x7f && cp < 0xa0)) return 0;
|
|
98
|
+
// Combining marks
|
|
99
|
+
if ((cp >= 0x0300 && cp <= 0x036f) || (cp >= 0xfe00 && cp <= 0xfe0f) || cp === 0x200d) return 0;
|
|
100
|
+
// Wide CJK, astral emoji, & BMP Emoji_Presentation symbols (e.g. ⚡ U+26A1)
|
|
101
|
+
if (
|
|
102
|
+
cp > 0xffff ||
|
|
103
|
+
cp === 0x26a1 ||
|
|
104
|
+
cp === 0x231a ||
|
|
105
|
+
cp === 0x231b ||
|
|
106
|
+
(cp >= 0x23e9 && cp <= 0x23ec) ||
|
|
107
|
+
cp === 0x23f0 ||
|
|
108
|
+
cp === 0x23f3 ||
|
|
109
|
+
(cp >= 0x25fd && cp <= 0x25fe) ||
|
|
110
|
+
(cp >= 0x2614 && cp <= 0x2615) ||
|
|
111
|
+
(cp >= 0x2648 && cp <= 0x2653) ||
|
|
112
|
+
cp === 0x267f ||
|
|
113
|
+
cp === 0x2693 ||
|
|
114
|
+
(cp >= 0x26aa && cp <= 0x26ab) ||
|
|
115
|
+
(cp >= 0x26bd && cp <= 0x26be) ||
|
|
116
|
+
(cp >= 0x26c4 && cp <= 0x26c5) ||
|
|
117
|
+
cp === 0x26ce ||
|
|
118
|
+
cp === 0x26d4 ||
|
|
119
|
+
cp === 0x26ea ||
|
|
120
|
+
(cp >= 0x26f2 && cp <= 0x26f3) ||
|
|
121
|
+
cp === 0x26f5 ||
|
|
122
|
+
cp === 0x26fa ||
|
|
123
|
+
cp === 0x26fd ||
|
|
124
|
+
cp === 0x2705 ||
|
|
125
|
+
(cp >= 0x270a && cp <= 0x270b) ||
|
|
126
|
+
cp === 0x2728 ||
|
|
127
|
+
cp === 0x274c ||
|
|
128
|
+
cp === 0x274e ||
|
|
129
|
+
(cp >= 0x2753 && cp <= 0x2755) ||
|
|
130
|
+
cp === 0x2757 ||
|
|
131
|
+
(cp >= 0x2795 && cp <= 0x2797) ||
|
|
132
|
+
cp === 0x27b0 ||
|
|
133
|
+
cp === 0x27bf ||
|
|
134
|
+
(cp >= 0x2b1b && cp <= 0x2b1c) ||
|
|
135
|
+
cp === 0x2b50 ||
|
|
136
|
+
cp === 0x2b55 ||
|
|
137
|
+
(cp >= 0x1100 && cp <= 0x115f) ||
|
|
138
|
+
(cp >= 0x2e80 && cp <= 0xa4cf && cp !== 0x303f) ||
|
|
139
|
+
(cp >= 0xac00 && cp <= 0xd7a3) ||
|
|
140
|
+
(cp >= 0xf900 && cp <= 0xfaff) ||
|
|
141
|
+
(cp >= 0xfe10 && cp <= 0xfe19) ||
|
|
142
|
+
(cp >= 0xfe30 && cp <= 0xfe6f) ||
|
|
143
|
+
(cp >= 0xff00 && cp <= 0xff60) ||
|
|
144
|
+
(cp >= 0xffe0 && cp <= 0xffe6)
|
|
145
|
+
) {
|
|
146
|
+
return 2;
|
|
147
|
+
}
|
|
148
|
+
return 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function visibleWidth(text) {
|
|
152
|
+
const plain = stripAnsi(text);
|
|
153
|
+
let width = 0;
|
|
154
|
+
for (const ch of plain) {
|
|
155
|
+
width += charWidth(ch);
|
|
156
|
+
}
|
|
157
|
+
return width;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function clipPlain(text, maxWidth) {
|
|
161
|
+
if (maxWidth <= 0) return '';
|
|
162
|
+
let out = '';
|
|
163
|
+
let width = 0;
|
|
164
|
+
for (const ch of stripAnsi(text)) {
|
|
165
|
+
const w = charWidth(ch);
|
|
166
|
+
if (width + w > maxWidth) break;
|
|
167
|
+
out += ch;
|
|
168
|
+
width += w;
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function clipAnsi(text, maxWidth) {
|
|
174
|
+
if (maxWidth <= 0) return '';
|
|
175
|
+
const input = String(text ?? '');
|
|
176
|
+
let out = '';
|
|
177
|
+
let width = 0;
|
|
178
|
+
let hasAnsi = false;
|
|
179
|
+
let i = 0;
|
|
180
|
+
|
|
181
|
+
while (i < input.length) {
|
|
182
|
+
if (input[i] === '\x1b' && input[i + 1] === '[') {
|
|
183
|
+
const end = input.indexOf('m', i + 2);
|
|
184
|
+
if (end !== -1) {
|
|
185
|
+
out += input.slice(i, end + 1);
|
|
186
|
+
hasAnsi = true;
|
|
187
|
+
i = end + 1;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const cp = input.codePointAt(i);
|
|
192
|
+
const ch = String.fromCodePoint(cp);
|
|
193
|
+
const w = charWidth(ch);
|
|
194
|
+
if (width + w > maxWidth) break;
|
|
195
|
+
out += ch;
|
|
196
|
+
width += w;
|
|
197
|
+
i += ch.length;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return hasAnsi && !out.endsWith('\x1b[0m') ? `${out}\x1b[0m` : out;
|
|
201
|
+
}
|