@sejuneoh/aitop 0.31.0 → 0.31.2
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 +30 -12
- package/package.json +1 -1
- package/src/i18n.mjs +6 -6
- package/src/report.mjs +2 -2
- package/src/sessions-report.mjs +2 -2
- package/src/sources/claude-tracker.mjs +1 -1
- package/src/ui/draw.mjs +3 -2
- package/src/ui/table.mjs +4 -5
package/README.md
CHANGED
|
@@ -3,29 +3,47 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@sejuneoh/aitop)
|
|
4
4
|
[](https://github.com/SejuneOh/aitop/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
**`top` for your AI coding agents.**
|
|
6
|
+
**`top` for your AI coding agents.** One live terminal screen for every Claude Code, Codex CLI and Antigravity CLI session on your machine. Read-only.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
```bash
|
|
9
|
+
npx @sejuneoh/aitop # try it, no install
|
|
10
|
+
npm i -g @sejuneoh/aitop # then just run: aitop
|
|
11
|
+
```
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
- **Waiting alerts**: blocked sessions jump to the top, with optional bell, desktop notification or hook command
|
|
12
|
-
- **Tokens and cost** per session and for today / last 7 days, at public API list prices
|
|
13
|
-
- **Changed files and diffs** per session and per prompt
|
|
14
|
-
- **Read-only**: no network, no ports, no dependencies. It only reads the session logs each CLI already writes
|
|
13
|
+

|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
- **See who needs you.** A waiting session jumps to the top and `n` takes you there. Add `--notify=waiting,done,context` for desktop alerts, or `aitop --line` for a tmux status line.
|
|
16
|
+
- **Know which session is which.** Every row shows the session name (your `/rename` or the tool's title). `y` copies a resume command, and `--report sessions` prints yesterday's sessions with cost for your standup.
|
|
17
|
+
- **All agents, all profiles, nothing sent.** Claude Code, Codex and Antigravity side by side, from [several history folders](#several-claude-or-codex-profiles) (`~/.claude`, `~/.claude-work`, ...). No network, no ports, no dependencies.
|
|
18
|
+
|
|
19
|
+
**How it differs from similar tools**
|
|
20
|
+
|
|
21
|
+
- [ccusage](https://github.com/ryoppippi/ccusage) reports token usage and cost from local logs (daily, monthly, session, 5-hour blocks). aitop is a live session monitor first, with smaller cost reports on the side.
|
|
22
|
+
- [abtop](https://github.com/graykode/abtop) is a Rust live dashboard for Claude Code, Codex CLI and OpenCode, with rate limits, ports and keys to kill sessions. aitop installs with npm, also covers Antigravity, and only watches.
|
|
23
|
+
- [claude-code-monitor](https://github.com/onikan27/claude-code-monitor) watches Claude Code on macOS through hooks it adds to `~/.claude/settings.json`, with a phone web view. aitop adds no hooks and only reads existing logs, on Linux, macOS, WSL and Windows.
|
|
17
24
|
|
|
18
25
|
## Install
|
|
19
26
|
|
|
20
27
|
Requires Node.js 22+ on Linux, macOS, WSL or Windows.
|
|
21
28
|
|
|
22
|
-
Native Windows support is early (Windows Terminal recommended): Claude Code and Codex sessions, `--once`, `--json`, `--report` and `--doctor` work, but process detection, desktop notifications and `--on-waiting` are not there yet ([#195](https://github.com/SejuneOh/aitop/issues/195)-[#197](https://github.com/SejuneOh/aitop/issues/197)). Until then a Codex session counts as running while its log was written in the last 10 minutes, so it drops out during a long step that writes nothing for over 10 minutes, and a crashed session can stay up to 10 minutes. Cache, log and config live in `%LOCALAPPDATA%\aitop\cache`, `%LOCALAPPDATA%\aitop\state` and `%APPDATA%\aitop` unless `XDG_*` is set.
|
|
23
|
-
|
|
24
29
|
```bash
|
|
25
|
-
|
|
30
|
+
npx @sejuneoh/aitop # run the latest version without installing
|
|
31
|
+
npm install -g @sejuneoh/aitop # or install it
|
|
26
32
|
aitop
|
|
27
33
|
```
|
|
28
34
|
|
|
35
|
+
Native Windows support is early (Windows Terminal recommended): Claude Code and Codex sessions, `--once`, `--json`, `--report` and `--doctor` work, but process detection, desktop notifications and `--on-waiting` are not there yet ([#195](https://github.com/SejuneOh/aitop/issues/195)-[#197](https://github.com/SejuneOh/aitop/issues/197)). Until then a Codex session counts as running while its log was written in the last 10 minutes, so it drops out during a long step that writes nothing for over 10 minutes, and a crashed session can stay up to 10 minutes. Cache, log and config live in `%LOCALAPPDATA%\aitop\cache`, `%LOCALAPPDATA%\aitop\state` and `%APPDATA%\aitop` unless `XDG_*` is set.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- **Live status** of every session and its subagents: thinking, running a tool, waiting for you, idle
|
|
40
|
+
- **Waiting alerts**: blocked sessions jump to the top, with optional bell, desktop notification or hook command
|
|
41
|
+
- **Tokens and cost** per session and for today / last 7 days, at public API list prices
|
|
42
|
+
- **Changed files and diffs** per session and per prompt
|
|
43
|
+
- **Read-only**: no network, no ports, no dependencies. It only reads the session logs each CLI already writes
|
|
44
|
+
|
|
45
|
+
> The UI follows your locale: English by default, Korean when the locale starts with `ko`. Set `AITOP_LANG=ko|en` (or `--lang`) to pick one. This covers the live screen, `--once`, `--help`, `--doctor`, error messages and desktop notifications. Keys and options work the same in both.
|
|
46
|
+
|
|
29
47
|
## Usage
|
|
30
48
|
|
|
31
49
|
```
|
|
@@ -64,7 +82,7 @@ aitop --report monthly --by model --months 6
|
|
|
64
82
|
|
|
65
83
|
### Session report
|
|
66
84
|
|
|
67
|
-
`aitop --report sessions [--since yesterday|today|Nd|YYYY-MM-DD] [--plan USD] [--md|--json] [--show-prompts]` lists every session that used tokens in the period (default: since midnight yesterday; at most 30 days back), highest cost first: tool, main model (`+N` more), project (same rule as `--by project`), session name (your `/rename` name, then the tool's title, then the folder), start and end of activity within the period, tokens, cost (API list price,
|
|
85
|
+
`aitop --report sessions [--since yesterday|today|Nd|YYYY-MM-DD] [--plan USD] [--md|--json] [--show-prompts]` lists every session that used tokens in the period (default: since midnight yesterday; at most 30 days back), highest cost first: tool, main model (`+N` more), project (same rule as `--by project`), session name (your `/rename` name, then the tool's title, then the folder), start and end of activity within the period, tokens, cost (API list price; unpriced models are left out, not guessed, and `--json` marks them with `unpriced`) and files changed (`-` when unknown, always for agy). A summary card on top shows the total, the share per tool and the session count; `--plan 200` adds how many times the period's share of a $200/month subscription (period days / 30) you used, still in API list price and not your bill. Claude subagents are counted in their parent session. `--md` prints Markdown you can paste (`|` and line breaks escaped), `--json` the same numbers for scripts. First prompts are hidden unless you pass `--show-prompts`, so they do not end up in shared output (session names still show).
|
|
68
86
|
|
|
69
87
|
```
|
|
70
88
|
aitop --report sessions --md --plan 200
|
package/package.json
CHANGED
package/src/i18n.mjs
CHANGED
|
@@ -259,7 +259,7 @@ export const STRINGS = {
|
|
|
259
259
|
'report.date': '날짜',
|
|
260
260
|
'report.total': '합계',
|
|
261
261
|
'report.empty': '이 기간에 기록된 사용량이 없습니다',
|
|
262
|
-
'report.unpriced': '
|
|
262
|
+
'report.unpriced': '가격표에 없는 모델이 있어 비용이 실제보다 적게 잡혔을 수 있습니다',
|
|
263
263
|
'report.partial': '시간 상한 안에 기록을 다 읽지 못해 일부만 셌습니다. 다시 실행하면 이어 읽습니다',
|
|
264
264
|
'report.progress': '사용량 장부 읽는 중 {pct}% ({s}초)',
|
|
265
265
|
'report.capped': '--days 는 장부가 남기는 {n}일까지만 볼 수 있어 {n}일로 줄입니다',
|
|
@@ -446,7 +446,7 @@ export const STRINGS = {
|
|
|
446
446
|
'legend.pin': '고정한 세션 (p). SESSION 칸 앞에 붙는다',
|
|
447
447
|
'legend.status': '지금 단계. 큰 기록을 처음 읽는 동안은 기록 읽는 중 N%',
|
|
448
448
|
'legend.tokens': '세션 누적 토큰 (서브에이전트 포함, 캐시 읽기 포함)',
|
|
449
|
-
'legend.cost': 'API 정가로 환산한 비용 (Codex 는 OpenAI 정가 추정).
|
|
449
|
+
'legend.cost': 'API 정가로 환산한 비용 (Codex 는 OpenAI 정가 추정). 가격표에 없는 모델은 빼고 센다',
|
|
450
450
|
'legend.context': '마지막 요청의 컨텍스트 사용률 (모델별 창 크기 기준)',
|
|
451
451
|
'legend.idleCol': '마지막 활동 후 지난 시간. 작업 중이면 now',
|
|
452
452
|
'legend.hiddenKey': '숨김 N',
|
|
@@ -562,7 +562,7 @@ export const STRINGS = {
|
|
|
562
562
|
'detail.netLabel': '캐시제외',
|
|
563
563
|
'detail.apiValue': 'API 환산 {v}',
|
|
564
564
|
'detail.netValue': '캐시 제외 {v}',
|
|
565
|
-
'detail.unpriced': '
|
|
565
|
+
'detail.unpriced': ' 가격표에 없는 모델은 빼고 셈',
|
|
566
566
|
|
|
567
567
|
// 데스크톱 알림 (--notify). 화면 언어를 따른다.
|
|
568
568
|
'notify.one': 'aitop: 응답 대기 ({tool})',
|
|
@@ -661,7 +661,7 @@ export const STRINGS = {
|
|
|
661
661
|
'report.date': 'Date',
|
|
662
662
|
'report.total': 'Total',
|
|
663
663
|
'report.empty': 'No usage recorded in this period',
|
|
664
|
-
'report.unpriced': '
|
|
664
|
+
'report.unpriced': 'Includes unpriced models, so the cost may be lower than actual',
|
|
665
665
|
'report.partial': 'Could not read all logs within the time limit, so this is partial. Run again to continue',
|
|
666
666
|
'report.progress': 'Reading usage logs {pct}% ({s}s)',
|
|
667
667
|
'report.capped': '--days is limited to the {n} days the ledger keeps, using {n}',
|
|
@@ -845,7 +845,7 @@ export const STRINGS = {
|
|
|
845
845
|
'legend.pin': 'Pinned session (p), before SESSION',
|
|
846
846
|
'legend.status': 'Current step (Reading log N% on first load)',
|
|
847
847
|
'legend.tokens': 'Tokens incl. subagents and cache reads',
|
|
848
|
-
'legend.cost': 'API cost (Codex estimated).
|
|
848
|
+
'legend.cost': 'API cost (Codex estimated). Unpriced models not counted',
|
|
849
849
|
'legend.context': 'Context used by the last request',
|
|
850
850
|
'legend.idleCol': 'Time since last activity. now while working',
|
|
851
851
|
'legend.hiddenKey': 'hidden N',
|
|
@@ -958,7 +958,7 @@ export const STRINGS = {
|
|
|
958
958
|
'detail.netLabel': 'No cache',
|
|
959
959
|
'detail.apiValue': 'API cost {v}',
|
|
960
960
|
'detail.netValue': 'no cache {v}',
|
|
961
|
-
'detail.unpriced': '
|
|
961
|
+
'detail.unpriced': ' unpriced models not counted',
|
|
962
962
|
|
|
963
963
|
'notify.one': 'aitop: waiting ({tool})',
|
|
964
964
|
'notify.title': 'aitop: waiting',
|
package/src/report.mjs
CHANGED
|
@@ -289,7 +289,7 @@ function foldOthers(columns, keep, lines) {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// --json 모양: 키는 영어, 값은 숫자만 (날짜·이름은 문자열). partial: 시간 상한 때문에 덜 읽었는지.
|
|
292
|
-
// 칸마다 unpriced(가격표에 없는 모델이 끼었는지)를 참·거짓으로 둔다.
|
|
292
|
+
// 칸마다 unpriced(가격표에 없는 모델이 끼었는지)를 참·거짓으로 둔다. 그 몫은 비용에서 빠져 있다.
|
|
293
293
|
export function reportJson(r, version, { partial = false } = {}) {
|
|
294
294
|
const items = (o) => Object.fromEntries(r.columns.map((c) => [c, { tokens: o.items[c]?.tokens ?? 0, cost: o.items[c]?.cost ?? 0, unpriced: Boolean(o.items[c]?.unpriced) }]));
|
|
295
295
|
const monthly = r.report === 'monthly';
|
|
@@ -312,7 +312,7 @@ export function reportJson(r, version, { partial = false } = {}) {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
// 칸 하나: '1.2M $3.40'. 토큰이 없으면 '-'. 가격표에 없는 모델이 끼었으면 화면 헤더처럼 비용 뒤에 ? 를 붙인다 ('$12.30?').
|
|
315
|
-
const cell = (x) => (x && (x.tokens > 0 || x.cost > 0) ? `${fmtTokens(Math.round(x.tokens))} ${
|
|
315
|
+
const cell = (x) => (x && (x.tokens > 0 || x.cost > 0) ? `${fmtTokens(Math.round(x.tokens))} ${x.unpriced && !(x.cost > 0) ? '-' : money(x.cost)}` : '-');
|
|
316
316
|
|
|
317
317
|
// 사람이 읽는 표. 머리글·합계 줄 문구는 화면 언어(t)를 따른다. 도구·모델·프로젝트 이름은 그대로 쓴다.
|
|
318
318
|
const colName = (c) => (c === UNKNOWN ? t('report.unknown') : c === OTHERS ? t('report.others') : truncate(stripControl(c), HEAD_MAX));
|
package/src/sessions-report.mjs
CHANGED
|
@@ -288,7 +288,7 @@ const mdhm = (ms) => {
|
|
|
288
288
|
// 끝 시각: 시작과 같은 날이면 시:분만.
|
|
289
289
|
const endText = (x) => (x.end == null ? '-' : x.start != null && dayKey(x.start) === dayKey(x.end) ? hm(new Date(x.end)) : mdhm(x.end));
|
|
290
290
|
const startText = (x) => (x.start == null ? '-' : mdhm(x.start));
|
|
291
|
-
const costText = (x) => (used(x)
|
|
291
|
+
const costText = (x) => (used(x) && !(x.unpriced && !(x.cost > 0)) ? money(x.cost) : '-');
|
|
292
292
|
const filesText = (x) => (x.files == null ? '-' : `${x.files}${x.filesMore ? '+' : ''}`);
|
|
293
293
|
const modelText = (x) => (x.model ? `${x.model}${x.models.length > 1 ? ` +${x.models.length - 1}` : ''}` : '-');
|
|
294
294
|
const projectText = (x) => (x.project === UNKNOWN ? t('report.unknown') : x.project);
|
|
@@ -304,7 +304,7 @@ const daysText = (n) => (n >= 10 ? String(Math.round(n)) : n.toFixed(1));
|
|
|
304
304
|
function cardLines(r, md = false) {
|
|
305
305
|
const s = r.summary;
|
|
306
306
|
const b = (x) => (md ? `**${x}**` : x);
|
|
307
|
-
const out = [t('sessions.cardTotal', { cost: b(
|
|
307
|
+
const out = [t('sessions.cardTotal', { cost: b(s.unpriced && !(s.cost > 0) ? '-' : money(s.cost)), tokens: fmtTokens(Math.round(s.tokens)), n: s.sessions })];
|
|
308
308
|
const tools = Object.entries(s.tools).map(([tool, o]) => `${tool} ${pct(o.share)}`);
|
|
309
309
|
if (tools.length) out.push(t(s.shareBy === 'cost' ? 'sessions.cardTools' : 'sessions.cardToolsTokens', { tools: tools.join(' · ') }));
|
|
310
310
|
if (s.plan) {
|
|
@@ -74,7 +74,7 @@ export class ClaudeTracker {
|
|
|
74
74
|
this.tokens = emptyTokens();
|
|
75
75
|
this.cost = 0;
|
|
76
76
|
this.costNoCache = 0;
|
|
77
|
-
// 가격표에 없는 모델의 사용량이 섞였는지. 그 몫은 비용에 넣지
|
|
77
|
+
// 가격표에 없는 모델의 사용량이 섞였는지. 그 몫은 비용에 넣지 않는다 (--json 의 costUnknown, 상세 패널 안내 줄).
|
|
78
78
|
this.costUnknown = false;
|
|
79
79
|
this.context = 0;
|
|
80
80
|
this.model = null;
|
package/src/ui/draw.mjs
CHANGED
|
@@ -76,13 +76,14 @@ export function gauge(used, total, cells) {
|
|
|
76
76
|
|
|
77
77
|
export const dollars = (usd) => (usd >= 1000 ? `$${Math.round(usd).toLocaleString('en-US')}` : usd >= 100 ? `$${usd.toFixed(0)}` : `$${usd.toFixed(2)}`);
|
|
78
78
|
|
|
79
|
-
// 비용을 모르는 도구는 '-'. 가격표에 없는 모델이 섞이면 아는
|
|
79
|
+
// 비용을 모르는 도구는 '-'. 가격표에 없는 모델이 섞이면 아는 몫만 보이고(표시는 붙이지 않는다), 아는 몫이 없으면 '-'.
|
|
80
|
+
// 가격표에 없는 모델이 섞였는지는 --json 의 unpriced·costUnknown 과 상세 패널 안내 줄로 알린다.
|
|
80
81
|
// 비용 표시 기준: 'api' 는 API 정가 환산(캐시 포함), 'net' 은 캐시 읽기·쓰기를 뺀 입력·출력만.
|
|
81
82
|
export const costOf = (x, mode = 'api') => (mode === 'net' ? x?.costNoCache ?? null : x?.cost ?? null);
|
|
82
83
|
|
|
83
84
|
export function money(usd, unknown = false) {
|
|
84
85
|
if (usd == null) return '-';
|
|
85
|
-
if (unknown
|
|
86
|
+
if (unknown && !(usd > 0)) return '-';
|
|
86
87
|
return dollars(usd);
|
|
87
88
|
}
|
|
88
89
|
|
package/src/ui/table.mjs
CHANGED
|
@@ -52,10 +52,10 @@ export function columns(W) {
|
|
|
52
52
|
|
|
53
53
|
// 헤더의 7일 비용 막대. days: usage.days7 (오래된 날 → 오늘). 7일 중 가장 큰 날을 █ 로 맞춘다.
|
|
54
54
|
// 비용이 0 인 날은 ▁ 를 장식 색(faint)으로, 쓴 날은 ▂~█ 로 그린다. 색이 없어도 쓴 날(▂ 이상)과 안 쓴 날(▁)이 갈린다.
|
|
55
|
-
// 가격표에 없는 모델만 쓴 날(아는 비용 0)은 쓰지 않은 날과 헷갈리지 않게
|
|
55
|
+
// 가격표에 없는 모델만 쓴 날(아는 비용 0)은 쓰지 않은 날과 헷갈리지 않게 가장 낮은 '쓴 날' 막대(▂)를 흐린 색으로 둔다.
|
|
56
56
|
export function weekBar(days, costMode = 'api') {
|
|
57
57
|
const bar = levelBar(days.map((d) => costOf(d, costMode)));
|
|
58
|
-
return bar.map((x, i) => (x.t === glyphs().week[0] && days[i].unknown ? { t:
|
|
58
|
+
return bar.map((x, i) => (x.t === glyphs().week[0] && days[i].unknown ? { t: glyphs().week[1], fg: PALETTE.muted } : x));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function header(view, W) {
|
|
@@ -109,7 +109,7 @@ export function header(view, W) {
|
|
|
109
109
|
const bud = u ? projectBudget(u, view.budgetDay, { now: view.data.at ?? Date.now() }) : null;
|
|
110
110
|
const ofBudget = bud ? [{ t: `/${Number.isInteger(bud.day) ? `$${bud.day.toLocaleString('en-US')}` : `$${bud.day.toFixed(2)}`}`, fg: PALETTE.muted, bg: B }] : [];
|
|
111
111
|
// 캐시 제외 화면에서 예산 칸 없이 예상만 남으면 캐시 제외 금액으로 읽히지 않게 'API 예상' 이라고 적는다.
|
|
112
|
-
const projOf = (label) => (bud && bud.level !== 'ok' ? { t: `${label} ${usd(bud.projected)}${bud.
|
|
112
|
+
const projOf = (label) => (bud && bud.level !== 'ok' ? { t: `${label} ${usd(bud.projected)}${bud.level === 'warn' ? '!' : ''}`, fg: BUDGET_COLOR[bud.level], bg: B, bold: true } : null);
|
|
113
113
|
const projSeg = projOf(t('hdr.proj'));
|
|
114
114
|
const projApi = net ? projOf(t('hdr.projApi')) : projSeg;
|
|
115
115
|
// budget: 'full' | 'proj' (아래 right 참고). 오늘 칸 뒤에 붙는 예산 칸.
|
|
@@ -126,9 +126,8 @@ export function header(view, W) {
|
|
|
126
126
|
...(tok ? [{ t: ` ${fmtTokens(p.tokens)}`, fg: PALETTE.info, bg: B }] : []),
|
|
127
127
|
];
|
|
128
128
|
// 지출 속도: 최근 1시간 비용(5분 칸 근사)을 시간당으로. 0 이거나 아직 집계 중이면 숨기고, 폭이 모자라면 가장 먼저 뺀다.
|
|
129
|
-
// 아는 몫이 0 인데 가격표에 없는 모델이 섞였으면 금액 없이 (?/h) 만 보인다.
|
|
130
129
|
const hour = u?.lastHour && u.loading == null ? (net ? u.lastHour.costNoCache : u.lastHour.cost) : null;
|
|
131
|
-
const rateText = hour >= 0.005 ?
|
|
130
|
+
const rateText = hour >= 0.005 ? usd(hour) : null;
|
|
132
131
|
const rate = rateText ? [{ t: ` (${rateText}/h)`, fg: PALETTE.muted, bg: B }] : null;
|
|
133
132
|
// bar: 7일 금액 뒤의 날짜별 막대. 집계 중이거나 날짜별 값이 없으면 넣지 않는다.
|
|
134
133
|
const bar = u?.loading == null && u?.days7?.length ? [{ t: ' ', bg: B }, ...weekBar(u.days7, view.costMode).map((x) => ({ ...x, bg: B }))] : null;
|