@sejuneoh/aitop 0.31.2 → 0.32.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/README.md +15 -4
- package/package.json +1 -1
- package/src/i18n.mjs +2 -0
- package/src/json.mjs +4 -1
- package/src/sources/antigravity.mjs +48 -14
- package/src/sources/claude.mjs +6 -2
- package/src/sources/common.mjs +23 -0
- package/src/text.mjs +9 -0
- package/src/ui/table.mjs +22 -4
- package/src/ui.mjs +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.** One live terminal screen for every Claude Code, Codex CLI and Antigravity CLI session on your machine.
|
|
6
|
+
**`top` for your AI coding agents.** One live terminal screen for every Claude Code, Codex CLI and Antigravity CLI session on your machine. No hooks, read-only.
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
npx @sejuneoh/aitop # try it, no install
|
|
@@ -14,13 +14,14 @@ npm i -g @sejuneoh/aitop # then just run: aitop
|
|
|
14
14
|
|
|
15
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
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
|
-
- **
|
|
17
|
+
- **No hooks, nothing sent.** Claude Code, Codex CLI and Antigravity CLI side by side, from [several history folders](#several-claude-or-codex-profiles) (`~/.claude`, `~/.claude-work`, ...). aitop only reads the logs they already write. It changes no settings and needs no network, ports or dependencies.
|
|
18
18
|
|
|
19
19
|
**How it differs from similar tools**
|
|
20
20
|
|
|
21
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
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
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.
|
|
24
|
+
- [Agents Stack](https://marketplace.visualstudio.com/items?itemName=MykD.agents-stack) is a VS Code extension for Claude Code, Antigravity, Codex and Gemini CLI. It adds hooks to each agent's config, and Antigravity has no hook for approval waits, so those do not show. aitop runs in any terminal, adds no hooks and shows Antigravity sessions waiting for approval.
|
|
24
25
|
|
|
25
26
|
## Install
|
|
26
27
|
|
|
@@ -36,9 +37,9 @@ Native Windows support is early (Windows Terminal recommended): Claude Code and
|
|
|
36
37
|
|
|
37
38
|
## Features
|
|
38
39
|
|
|
39
|
-
- **Live status** of every session and its subagents: thinking, running a tool, waiting for you, idle
|
|
40
|
+
- **Live status** of every session and its subagents: thinking, running a tool, waiting for you, idle. Subagent rows show how long they have run ([details](#subagents))
|
|
40
41
|
- **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
|
+
- **Tokens and cost** per session and for today / last 7 days, estimated at public API list prices. This is not your bill
|
|
42
43
|
- **Changed files and diffs** per session and per prompt
|
|
43
44
|
- **Read-only**: no network, no ports, no dependencies. It only reads the session logs each CLI already writes
|
|
44
45
|
|
|
@@ -65,6 +66,14 @@ To continue a session elsewhere (for example when you cannot jump to its tab, as
|
|
|
65
66
|
|
|
66
67
|
In `--json`, `phase` stays the Korean status text in every language (as does `AITOP_WAITING_FOR` for `--on-waiting`). Session `name` uses the same user-given names as the table: a Codex session's `name` changes from the folder name to its `thread_name` once it has one. For scripts, use `phaseKind`, a stable state name: `think`, `write`, `tool`, `team`, `waiting`, `idle`, `done`, `ended` (or `null`). Other text fields follow their own rules: with English selected, `--doctor --json` has Korean `tools.*.hint` but English `config.problems`.
|
|
67
68
|
|
|
69
|
+
### Subagents
|
|
70
|
+
|
|
71
|
+
Subagents show as `├─` rows under their session. While one works, its row shows how long it has run (`42s`, `3m12s`, `1h05m`).
|
|
72
|
+
|
|
73
|
+
A dim `stalled?` appears when a working subagent's log has not changed for 3 minutes. While it runs a tool that can be slow (Bash, PowerShell, a nested agent, web fetch or search, an MCP tool, agy `run_command`), the limit is 10 minutes. It is only a guess. It never shows while the session waits for you, and it does not change sorting, alerts, the window title or `--line`. `--json` has it per member as `stalled`, with `startedAt` and `lastActivityAt`.
|
|
74
|
+
|
|
75
|
+
When an Antigravity subagent waits for your approval, its parent row waits too, as `<agent>: <tool>`. So the session jumps to the top and counts for `n`, `--notify` and `--line`. If the parent waits itself, its own wait shows first. Other waiting subagents show on their own rows.
|
|
76
|
+
|
|
68
77
|
### Daily report
|
|
69
78
|
|
|
70
79
|
`aitop --report daily` prints tokens and cost (API list price, like the header) per day, newest first, with a total row, then exits. Columns are per tool by default, per model with `--by model`, or per project with `--by project` (the last folder name of the working directory: Claude log `cwd`, Codex `turn_context.cwd`, agy workspace; Claude Code worktrees under `<repo>/.claude/worktrees/` count as the repo; `(unknown)` when missing; extra columns beyond the terminal width are merged into `(others)`, `--json` lists all with a `paths` map); `--days N` goes back up to 30 days, and `--json` gives the same numbers for scripts. The first run reads up to 30 days of logs, so it can take a while (progress shows on stderr); later runs use the cache.
|
|
@@ -129,3 +138,5 @@ aitop reads `~/.claude` and `~/.codex` by default. To read more profiles, list t
|
|
|
129
138
|
## License
|
|
130
139
|
|
|
131
140
|
[MIT](https://github.com/SejuneOh/aitop/blob/main/LICENSE)
|
|
141
|
+
|
|
142
|
+
Not affiliated with or endorsed by Anthropic, OpenAI or Google. Product names are trademarks of their owners.
|
package/package.json
CHANGED
package/src/i18n.mjs
CHANGED
|
@@ -391,6 +391,7 @@ export const STRINGS = {
|
|
|
391
391
|
'tools.hidden': '숨김 {list}',
|
|
392
392
|
'tools.ended': '종료된 세션 포함 (24시간)',
|
|
393
393
|
'table.title': '세션 {n}',
|
|
394
|
+
'member.stalled': '멈춘 듯',
|
|
394
395
|
'group.count': '{n}개',
|
|
395
396
|
'group.waiting': '응답 대기',
|
|
396
397
|
'group.pinned': '고정',
|
|
@@ -790,6 +791,7 @@ export const STRINGS = {
|
|
|
790
791
|
'tools.hidden': 'hidden {list}',
|
|
791
792
|
'tools.ended': 'with ended sessions (24h)',
|
|
792
793
|
'table.title': 'Sessions {n}',
|
|
794
|
+
'member.stalled': 'stalled?',
|
|
793
795
|
'group.count': '{n}',
|
|
794
796
|
'group.waiting': 'Waiting',
|
|
795
797
|
'group.pinned': 'Pinned',
|
package/src/json.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { projectBudget } from './budget.mjs';
|
|
|
2
2
|
import { toolsJson } from './doctor.mjs';
|
|
3
3
|
import { phaseText } from './i18n.mjs';
|
|
4
4
|
import { resumeCmd } from './resume.mjs';
|
|
5
|
+
import { memberStalled } from './sources/common.mjs';
|
|
5
6
|
|
|
6
7
|
// aitop --json 출력. 다른 스크립트나 AI 가 읽기 쉬운 모양으로 세션 목록과 사용량 합계를 담는다.
|
|
7
8
|
// 텍스트는 수집 단계에서 이미 비밀값 가림이 적용돼 있다.
|
|
@@ -60,7 +61,9 @@ export function toJson(data, version = null, opts = {}) {
|
|
|
60
61
|
context: { used: s.context?.used ?? 0, window: s.context?.window ?? null },
|
|
61
62
|
// 변경 내용(diff)은 넣지 않고 파일별 통계만 넣는다. 줄 수는 편집마다 더한 누적값이다 (git diff 아님).
|
|
62
63
|
files: (s.files ?? []).map((f) => ({ path: f.path, created: Boolean(f.created), edits: f.edits, writtenLines: f.add, deletedLines: f.del, updatedAt: iso(f.at), agents: f.agents ?? [] })),
|
|
63
|
-
|
|
64
|
+
// startedAt·lastActivityAt 은 세션의 startedAt·updatedAt 과 같은 ISO 시각이다 (모르면 null).
|
|
65
|
+
// stalled 는 화면의 '멈춘 듯' 과 같은 짐작(common.mjs memberStalled)을 data.at 기준으로 본 값이다.
|
|
66
|
+
members: (s.members ?? []).map((m) => ({ name: m.name, task: m.task ?? null, model: m.model ?? null, status: m.status, phase: koPhase(m.phase), phaseKind: m.phase?.kind ?? null, tokens: m.tokens ?? 0, cost: money(m.cost), startedAt: iso(m.startedAt), lastActivityAt: iso(m.lastActivityAt), stalled: memberStalled(m, data.at ?? Date.now(), s.status) })),
|
|
64
67
|
})),
|
|
65
68
|
};
|
|
66
69
|
}
|
|
@@ -9,7 +9,7 @@ import { homedir } from 'node:os';
|
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import { openReadOnly, loadSqlite } from '../sqlite.mjs';
|
|
11
11
|
import { findProcesses, isAgy, openFiles } from '../procs.mjs';
|
|
12
|
-
import { addActivity, emptyTokens, mergeActivity, pushEvent, describeTool, toolDetail, isNoisePrompt, MEMBER_FADE_MS } from './common.mjs';
|
|
12
|
+
import { addActivity, emptyTokens, mergeActivity, pushEvent, describeTool, toolDetail, isNoisePrompt, isLongTool, MEMBER_FADE_MS } from './common.mjs';
|
|
13
13
|
import { contextWindow, geminiCost } from '../pricing.mjs';
|
|
14
14
|
import { debug, debugIo } from '../log.mjs';
|
|
15
15
|
|
|
@@ -245,6 +245,8 @@ const fresh = () => ({
|
|
|
245
245
|
events: [],
|
|
246
246
|
turns: [],
|
|
247
247
|
turnCount: 0,
|
|
248
|
+
// 읽은 단계 가운데 가장 이른 만든 시각 (서브에이전트 경과 시간의 기준).
|
|
249
|
+
firstAt: null,
|
|
248
250
|
lastTool: null,
|
|
249
251
|
last: null,
|
|
250
252
|
// 아직 바뀌는 중인 단계 가운데 가장 뒤의 것 (지금 무엇을 하는지 보이는 데 쓴다).
|
|
@@ -426,6 +428,7 @@ function addEvent(n, at, kind, text) {
|
|
|
426
428
|
|
|
427
429
|
function applyStep(n, s, idx) {
|
|
428
430
|
if (!s) return;
|
|
431
|
+
if (s.at && (n.firstAt == null || s.at < n.firstAt)) n.firstAt = s.at;
|
|
429
432
|
const at = s.at ? new Date(s.at).toISOString() : null;
|
|
430
433
|
if (s.type === STEP.PROMPT) {
|
|
431
434
|
if (s.text && !isNoisePrompt(s.text)) {
|
|
@@ -599,22 +602,28 @@ export function matchLive(procs, rows, filesOf = openFiles, dir = AGY_ROOT) {
|
|
|
599
602
|
return { live, loose };
|
|
600
603
|
}
|
|
601
604
|
|
|
602
|
-
|
|
605
|
+
// wait: 이 서브에이전트가 허락을 기다리는 도구 (subWait 가 정한다). 기다리면 상태를 'waiting' 으로 두고 무엇을 기다리는지 보인다.
|
|
606
|
+
function member(r, g, wait = null) {
|
|
603
607
|
return {
|
|
604
608
|
id: r.id,
|
|
605
609
|
name: r.agent || 'agent',
|
|
606
610
|
model: g.model,
|
|
607
611
|
task: r.title ?? '',
|
|
608
|
-
status: r.running ? 'busy' : 'done',
|
|
612
|
+
status: wait ? 'waiting' : r.running ? 'busy' : 'done',
|
|
609
613
|
started: g.tokens.total > 0,
|
|
610
|
-
phase: r.running ? { kind: 'think', msg: 'steps', args: { n: r.steps } } : { kind: 'done' },
|
|
614
|
+
phase: wait ? { kind: 'waiting', args: { what: wait } } : r.running ? { kind: 'think', msg: 'steps', args: { n: r.steps } } : { kind: 'done' },
|
|
611
615
|
now: '',
|
|
612
616
|
tokens: g.tokens.total,
|
|
613
617
|
cost: g.cost,
|
|
614
618
|
costNoCache: g.costNoCache,
|
|
615
619
|
costUnknown: g.costUnknown,
|
|
616
|
-
//
|
|
620
|
+
// 대화 목록에는 시작 시각이 없어 마지막으로 바뀐 시각을 둔다 (정렬용).
|
|
617
621
|
updatedAt: r.updatedAt,
|
|
622
|
+
// 경과 시간의 기준은 읽은 단계 가운데 가장 이른 만든 시각, 멈춘 듯 판단은 대화 목록의 마지막 수정 시각이다.
|
|
623
|
+
startedAt: g.firstAt ?? null,
|
|
624
|
+
lastActivityAt: r.updatedAt ?? null,
|
|
625
|
+
// 실행 중인 단계가 run_command 처럼 오래 걸릴 수 있는 도구면 멈춘 듯 기준을 길게 잡는다 (common.mjs).
|
|
626
|
+
longStep: Boolean(r.running && g.open?.type === STEP.TOOL && isLongTool(g.open.tool?.name)),
|
|
618
627
|
};
|
|
619
628
|
}
|
|
620
629
|
|
|
@@ -638,13 +647,22 @@ export function waitingFor(g) {
|
|
|
638
647
|
return w.what;
|
|
639
648
|
}
|
|
640
649
|
|
|
650
|
+
// 서브에이전트가 허락을 기다리는지. 부모와 같은 규칙(waitingFor: steps status 9, 본 뒤 -wal 이 바뀌면 대기 아님)을 쓴다.
|
|
651
|
+
// 부모 세션이 살아 있고 서브에이전트 자신도 아직 실행 중(r.running)일 때만 센다. 끝난 서브에이전트에 남은 9 는
|
|
652
|
+
// 허락 없이 끝난 흔적이라 무시한다.
|
|
653
|
+
export function subWait(parentLive, r, g) {
|
|
654
|
+
if (!parentLive || !r.running) return null;
|
|
655
|
+
return waitingFor(g);
|
|
656
|
+
}
|
|
657
|
+
|
|
641
658
|
// 실행 중일 때는 아직 바뀌는 중인 단계, 없으면 마지막으로 끝난 단계로 지금 할 일을 짐작한다.
|
|
642
659
|
// 끝난 답변이 도구 호출을 냈으면 그 도구를 실행할 차례이고, 끝난 도구 호출 뒤에는 모델이 결과를 읽고 생각한다.
|
|
643
|
-
|
|
660
|
+
// kidWait: 부모가 기다리지 않을 때 대신 보일 서브에이전트의 허락 대기 문구 (collectAgy 가 정한다).
|
|
661
|
+
export function phaseOf(live, r, g, runningMembers = 0, kidWait = null) {
|
|
644
662
|
if (!live) return { kind: 'ended' };
|
|
645
663
|
// 같이 도는 에이전트 수는 args.agents 로 보내고, 화면이 문구 뒤에 붙인다.
|
|
646
664
|
const extra = runningMembers ? { agents: runningMembers } : {};
|
|
647
|
-
const wait = waitingFor(g);
|
|
665
|
+
const wait = waitingFor(g) ?? kidWait;
|
|
648
666
|
if (wait) return { kind: 'waiting', args: { what: wait, ...extra } };
|
|
649
667
|
if (!r.running) return { kind: 'idle' };
|
|
650
668
|
// 바뀌는 중인 단계와 끝난 단계 가운데 더 뒤의 것이 지금 하는 일이다 (앞의 명령이 오래 도는 동안 뒤 단계가 이어질 수 있다).
|
|
@@ -708,10 +726,11 @@ export function collectAgy({ showEnded, budget }) {
|
|
|
708
726
|
const kids = children.get(r.id) ?? [];
|
|
709
727
|
// 서브에이전트 기록은 한 번만 읽어 행과 합계가 같은 값을 쓰게 한다.
|
|
710
728
|
const kidUsage = kids.map((c) => readConversation(c.id, budget));
|
|
729
|
+
const kidWaits = kids.map((c, i) => subWait(isLive, c, kidUsage[i]));
|
|
711
730
|
// 끝난 서브에이전트는 Claude 팀원처럼 잠시 "완료"로 보였다가 행에서 빠진다. 합계에는 그대로 남는다.
|
|
712
731
|
const members = kids
|
|
713
|
-
.map((c, i) => member(c, kidUsage[i]))
|
|
714
|
-
.filter((m) => m.status
|
|
732
|
+
.map((c, i) => member(c, kidUsage[i], kidWaits[i]))
|
|
733
|
+
.filter((m) => m.status !== 'done' || (m.updatedAt != null && Date.now() - m.updatedAt <= MEMBER_FADE_MS))
|
|
715
734
|
.sort((a, b) => (a.updatedAt ?? 0) - (b.updatedAt ?? 0));
|
|
716
735
|
// 메인과 서브에이전트를 항목별로 더한다 (Claude 세션과 같은 방식).
|
|
717
736
|
const tokens = { ...g.tokens, main: g.tokens.total, sub: 0, subCount: kids.length };
|
|
@@ -726,8 +745,23 @@ export function collectAgy({ showEnded, budget }) {
|
|
|
726
745
|
costNoCache += u.costNoCache;
|
|
727
746
|
costUnknown ||= u.costUnknown;
|
|
728
747
|
}
|
|
729
|
-
|
|
730
|
-
const
|
|
748
|
+
// 허락을 기다리는 서브에이전트도 아직 끝나지 않았으니 같이 도는 에이전트로 센다.
|
|
749
|
+
const running = members.filter((m) => m.status !== 'done').length;
|
|
750
|
+
// 부모 행의 대기 규칙:
|
|
751
|
+
// 1. 부모 대화가 허락을 기다리면 그것을 보인다. 부모와 서브가 함께 기다려도 부모 것이 먼저다.
|
|
752
|
+
// 2. 아니면 기다리는 서브에이전트 가운데 가장 오래 기다린 것(마지막으로 바뀐 시각이 가장 이른 것)을 '이름: 도구' 로 보인다.
|
|
753
|
+
// 나머지 서브에이전트의 대기는 각자의 팀원 행에 보인다.
|
|
754
|
+
// 대기 정렬·--notify·--line·summary.json 은 세션의 status·waitingFor·waitSince 를 쓰므로 이것으로 함께 바뀐다.
|
|
755
|
+
const own = isLive ? waitingFor(g) : null;
|
|
756
|
+
let kidIdx = -1;
|
|
757
|
+
if (!own) {
|
|
758
|
+
for (let i = 0; i < kids.length; i++) {
|
|
759
|
+
if (kidWaits[i] && (kidIdx < 0 || (kids[i].updatedAt ?? Infinity) < (kids[kidIdx].updatedAt ?? Infinity))) kidIdx = i;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
const kidWait = kidIdx >= 0 ? `${kids[kidIdx].agent || 'agent'}: ${kidWaits[kidIdx]}` : null;
|
|
763
|
+
const wait = own ?? kidWait;
|
|
764
|
+
const waitDetail = own ? (g.wait.detail ?? own) : kidWait ? (kidUsage[kidIdx].wait?.detail ?? kidWaits[kidIdx]) : null;
|
|
731
765
|
out.push({
|
|
732
766
|
tool: 'gemini',
|
|
733
767
|
id: r.id,
|
|
@@ -740,17 +774,17 @@ export function collectAgy({ showEnded, budget }) {
|
|
|
740
774
|
model: g.model,
|
|
741
775
|
live: isLive,
|
|
742
776
|
status: !isLive ? 'ended' : wait ? 'waiting' : r.running ? 'busy' : 'idle',
|
|
743
|
-
phase: phaseOf(isLive, r, g, running),
|
|
777
|
+
phase: phaseOf(isLive, r, g, running, kidWait),
|
|
744
778
|
cost,
|
|
745
779
|
costNoCache,
|
|
746
780
|
costUnknown,
|
|
747
781
|
waitingFor: wait,
|
|
748
|
-
waitDetail
|
|
782
|
+
waitDetail,
|
|
749
783
|
now: g.lastTool ?? g.events.at(-1)?.text ?? '',
|
|
750
784
|
startedAt: null,
|
|
751
785
|
updatedAt: r.updatedAt ?? Date.now(),
|
|
752
786
|
// 대기 시작 시각 (--line 요약용). 기록에 시각이 없으면 지금 시각으로 메우지 않고 null.
|
|
753
|
-
waitSince:
|
|
787
|
+
waitSince: own ? (r.updatedAt ?? null) : kidWait ? (kids[kidIdx].updatedAt ?? null) : null,
|
|
754
788
|
tokens,
|
|
755
789
|
context: { used: g.prompt, window: contextWindow(g.model, g.prompt) },
|
|
756
790
|
events: g.events,
|
package/src/sources/claude.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { contextWindow } from '../pricing.mjs';
|
|
|
7
7
|
import { join, basename } from 'node:path';
|
|
8
8
|
import { isSessionAlive } from '../procs.mjs';
|
|
9
9
|
import { ClaudeTracker, tailCustomTitle } from './claude-tracker.mjs';
|
|
10
|
-
import { emptyTokens, mergeActivity, MEMBER_FADE_MS, sessionName } from './common.mjs';
|
|
10
|
+
import { emptyTokens, isLongTool, mergeActivity, MEMBER_FADE_MS, sessionName } from './common.mjs';
|
|
11
11
|
import { mergeFiles } from './files.mjs';
|
|
12
12
|
import { debug, debugIo } from '../log.mjs';
|
|
13
13
|
import { claudeDirs, claudeProjectRoots, dedupeBy } from './dirs.mjs';
|
|
@@ -148,7 +148,11 @@ function readMembers(transcript, parent, budget) {
|
|
|
148
148
|
costNoCache: t.costNoCache,
|
|
149
149
|
costUnknown: t.costUnknown,
|
|
150
150
|
loading: t.loading != null,
|
|
151
|
-
|
|
151
|
+
// 경과 시간의 기준은 서브에이전트 기록의 첫 줄 시각, 멈춘 듯 판단은 기록 파일의 마지막 수정 시각이다.
|
|
152
|
+
startedAt: t.firstAt ?? t.events[0]?.at,
|
|
153
|
+
lastActivityAt: t.mtimeMs || null,
|
|
154
|
+
// Bash 처럼 결과가 오기까지 오래 걸릴 수 있는 도구가 도는 중이면 멈춘 듯 기준을 길게 잡는다 (common.mjs).
|
|
155
|
+
longStep: [...t.pending.values()].some((p) => isLongTool(p.name)),
|
|
152
156
|
});
|
|
153
157
|
}
|
|
154
158
|
members.sort((a, b) => (a.startedAt ?? 0) - (b.startedAt ?? 0));
|
package/src/sources/common.mjs
CHANGED
|
@@ -5,6 +5,29 @@ export const MAX_EVENTS = 40;
|
|
|
5
5
|
// 끝난 서브에이전트(팀원)는 이 시간 동안 "완료"로 보였다가 목록에서 사라진다.
|
|
6
6
|
export const MEMBER_FADE_MS = 6000;
|
|
7
7
|
|
|
8
|
+
// 작업 중인 서브에이전트가 '멈춘 듯' 보이기까지 기록이 바뀌지 않은 시간.
|
|
9
|
+
// 서브에이전트는 모델 응답 한 번, 도구 결과 한 번마다 기록에 한 줄을 쓴다. 긴 생각을 하는 응답도 대개 1~2분 안에 끝나므로
|
|
10
|
+
// 3분 동안 한 줄도 없으면 드문 일로 본다. 다만 Bash 같은 도구가 도는 동안에는 결과가 올 때까지 쓰지 않는데,
|
|
11
|
+
// Claude Code 의 Bash 시간 제한이 최대 10분이라 그런 단계에서는 10분을 기다린다.
|
|
12
|
+
// 짐작일 뿐이라 화면에 흐리게만 보이고 정렬·알림·창 제목·--line 에는 쓰지 않는다.
|
|
13
|
+
export const MEMBER_STALL_MS = 3 * 60_000;
|
|
14
|
+
export const MEMBER_STALL_LONG_MS = 10 * 60_000;
|
|
15
|
+
// 결과가 올 때까지 오래 기록이 없을 수 있는 도구 (Claude·agy 이름). 서브에이전트 안의 서브에이전트(Agent·Task)도 그동안 쓰지 않는다.
|
|
16
|
+
// Skill 은 지침 글을 바로 돌려주는 도구라 넣지 않는다.
|
|
17
|
+
export const LONG_TOOLS = new Set(['Bash', 'PowerShell', 'Agent', 'Task', 'WebFetch', 'WebSearch', 'run_command', 'shell', 'call_mcp_tool']);
|
|
18
|
+
// MCP 도구(mcp__서버__도구, agy 는 call_mcp_tool)는 바깥 서버가 응답할 때까지 기다리므로 얼마나 걸릴지 알 수 없어 오래 걸리는 쪽으로 본다.
|
|
19
|
+
export const isLongTool = (name) => LONG_TOOLS.has(name) || String(name ?? '').startsWith('mcp__');
|
|
20
|
+
|
|
21
|
+
// m: 수집기가 만든 팀원. status 'busy' 이고 lastActivityAt 이 기준보다 오래됐으면 true. longStep 이면 긴 기준을 쓴다.
|
|
22
|
+
// 허락을 기다리는 동안은 기록이 멈추는 것이 정상이므로, 팀원이 응답 대기('waiting')이거나 부모 세션(parentStatus)이
|
|
23
|
+
// 응답 대기면 멈춘 듯으로 보지 않는다 (Claude 는 서브에이전트의 허락 요청이 부모 세션의 대기로만 보인다).
|
|
24
|
+
// 팀원 쪽은 'busy' 가 아니면(대기·완료 모두) 따로 보지 않고 false 다. 부모가 기다리면 형제 팀원의 표시도 함께 꺼진다 (덜 알리는 쪽).
|
|
25
|
+
export function memberStalled(m, now = Date.now(), parentStatus = null) {
|
|
26
|
+
if (parentStatus === 'waiting') return false;
|
|
27
|
+
if (m?.status !== 'busy' || !Number.isFinite(m.lastActivityAt)) return false;
|
|
28
|
+
return now - m.lastActivityAt >= (m.longStep ? MEMBER_STALL_LONG_MS : MEMBER_STALL_MS);
|
|
29
|
+
}
|
|
30
|
+
|
|
8
31
|
export function emptyTokens() {
|
|
9
32
|
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 };
|
|
10
33
|
}
|
package/src/text.mjs
CHANGED
|
@@ -254,3 +254,12 @@ export function fmtAgo(ms) {
|
|
|
254
254
|
if (s < 86400) return Math.floor(s / 3600) + 'h';
|
|
255
255
|
return Math.floor(s / 86400) + 'd';
|
|
256
256
|
}
|
|
257
|
+
|
|
258
|
+
// 서브에이전트 경과 시간. 1분 아래는 42s, 1시간 아래는 3m12s, 그 위는 1h05m (초는 버린다).
|
|
259
|
+
export function fmtElapsed(ms) {
|
|
260
|
+
const s = Math.max(0, Math.floor(ms / 1000));
|
|
261
|
+
const two = (n) => String(n).padStart(2, '0');
|
|
262
|
+
if (s < 60) return `${s}s`;
|
|
263
|
+
if (s < 3600) return `${Math.floor(s / 60)}m${two(s % 60)}s`;
|
|
264
|
+
return `${Math.floor(s / 3600)}h${two(Math.floor(s / 60) % 60)}m`;
|
|
265
|
+
}
|
package/src/ui/table.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { describe } from '../doctor.mjs';
|
|
3
3
|
import { BRAND } from '../brand.mjs';
|
|
4
4
|
import { projectBudget } from '../budget.mjs';
|
|
5
|
-
import { fmtAgo, fmtTokens, pad, truncate, width } from '../text.mjs';
|
|
5
|
+
import { fmtAgo, fmtElapsed, fmtTokens, pad, truncate, width } from '../text.mjs';
|
|
6
|
+
import { memberStalled } from '../sources/common.mjs';
|
|
6
7
|
import { BUDGET_COLOR, PALETTE, PHASE_COLOR, RESET, style } from './theme.mjs';
|
|
7
8
|
import { NOW, SPIN, clock, costOf, gauge, glyph, levelBar, line, money, segsWidth, shortModel } from './draw.mjs';
|
|
8
9
|
import { glyphs } from './glyphs.mjs';
|
|
@@ -366,8 +367,10 @@ const pendingGauge = (cells) => [{ t: glyphs().bar.empty.repeat(cells), fg: PALE
|
|
|
366
367
|
export const statusText = (phase) => phaseText(phase, { short: true });
|
|
367
368
|
|
|
368
369
|
// 메인 세션 아래에 붙는 팀원(서브에이전트) 행. 끝나면 잠깐 "완료"로 보였다가 사라진다.
|
|
369
|
-
// parentModel: 부모와 같은 모델이면 모델 칸을 비운다. costMode: 'api' | 'net'.
|
|
370
|
-
|
|
370
|
+
// parentModel: 부모와 같은 모델이면 모델 칸을 비운다. costMode: 'api' | 'net'. parentStatus: 부모 세션 상태 (응답 대기면 멈춘 듯을 붙이지 않는다).
|
|
371
|
+
// 경과 시간은 초 단위로 바뀌지만 타이머를 따로 두지 않는다. 작업 중인 팀원이 있으면 ui.mjs animating() 이 이미 참이라
|
|
372
|
+
// 스피너 틱(120ms)마다 다시 그리고 있고, 그 틱에 실려 바뀐다. 끝난 팀원(done)은 경과 시간을 그리지 않아 틱을 붙잡지 않는다.
|
|
373
|
+
export function memberRow(m, last, c, W, frame, parentModel, costMode = 'api', parentStatus = null) {
|
|
371
374
|
const done = m.status === 'done';
|
|
372
375
|
const g = done ? { t: '✓', fg: PALETTE.info } : { t: SPIN[(frame + 3) % SPIN.length], fg: PALETTE.team, bold: true };
|
|
373
376
|
const branch = last ? glyphs().memberLast : glyphs().member;
|
|
@@ -389,11 +392,26 @@ export function memberRow(m, last, c, W, frame, parentModel, costMode = 'api') {
|
|
|
389
392
|
{ t: label, fg: done ? PALETTE.info : PALETTE.team },
|
|
390
393
|
{ t: pad(showSuffix ? suffix : '', nameW - width(label)) + ' ', fg: PALETTE.info },
|
|
391
394
|
);
|
|
395
|
+
// 팀원 행은 CONTEXT·IDLE 칸이 비므로 그 자리(둘 사이 공백 포함)에 작업 중 경과 시간과 '멈춘 듯' 을 오른쪽 맞춤으로 둔다.
|
|
396
|
+
// 두 칸은 폭과 상관없이 늘 있는 열이라, 좁아지면 이름·STATUS 가 먼저 줄고 경과 시간은 남는다 (세션 행의 IDLE 과 같은 규칙).
|
|
397
|
+
// '멈춘 듯' 은 글자로 적어 색이 없어도 구분되고, 흐린 색으로만 둔다. 놓는 곳은 위에서부터 들어가는 첫 자리다:
|
|
398
|
+
// 끝 칸에 '멈춘 듯 3m12s' → STATUS 칸 앞 (CTX 5칸만 남는 폭) → STATUS 칸도 그보다 좁으면 경과 시간 뒤에 '?' 하나 (3m12s?).
|
|
399
|
+
const tailW = c.ctx + 1 + c.age;
|
|
400
|
+
const elapsed = !done && Number.isFinite(m.startedAt) ? fmtElapsed(NOW - m.startedAt) : '';
|
|
401
|
+
const stalled = !done && memberStalled(m, NOW, parentStatus) ? t('member.stalled') : '';
|
|
402
|
+
const both = stalled && elapsed ? width(stalled) + 1 + width(elapsed) <= tailW : Boolean(stalled);
|
|
403
|
+
const before = stalled && !both && c.status >= width(stalled) + 1;
|
|
404
|
+
const quest = stalled && !both && !before;
|
|
405
|
+
const inStatus = before ? [{ t: `${stalled} `, fg: PALETTE.info, italic: true }] : [];
|
|
392
406
|
segs.push(
|
|
393
|
-
|
|
407
|
+
...inStatus,
|
|
408
|
+
{ t: pad(statusText(m.phase), Math.max(0, c.status - segsWidth(inStatus))) + ' ', fg: done ? PALETTE.info : PHASE_COLOR[m.phase?.kind] ?? PALETTE.muted },
|
|
394
409
|
{ t: pad(m.loading ? '…' : started ? fmtTokens(m.tokens ?? 0) : '', c.tokens, 'right') + ' ', fg: done || m.loading ? PALETTE.info : PALETTE.muted },
|
|
395
410
|
);
|
|
396
411
|
if (c.showCost) segs.push({ t: pad(m.loading ? '…' : started ? money(costOf(m, costMode), m.costUnknown) : '', c.cost, 'right') + ' ', fg: done || m.loading ? PALETTE.info : PALETTE.muted });
|
|
412
|
+
const mark = stalled && both ? [{ t: stalled, fg: PALETTE.info, italic: true }, ...(elapsed ? [{ t: ' ' }] : [])] : [];
|
|
413
|
+
const time = elapsed ? [{ t: elapsed, fg: PALETTE.info }, ...(quest ? [{ t: '?', fg: PALETTE.info, italic: true }] : [])] : [];
|
|
414
|
+
if (mark.length || time.length) segs.push({ t: ' '.repeat(Math.max(0, tailW - segsWidth([...mark, ...time]))) }, ...mark, ...time);
|
|
397
415
|
// 끝난 팀원은 종료 행처럼 기울임꼴로 둔다.
|
|
398
416
|
return line(done ? segs.map((x) => ({ ...x, italic: true })) : segs, W);
|
|
399
417
|
}
|
package/src/ui.mjs
CHANGED
|
@@ -84,7 +84,7 @@ export function render(view, W, H) {
|
|
|
84
84
|
// 준비 완료 전에는 값이 커지는 대로 ▲ 가 옮겨 다니므로 붙이지 않는다.
|
|
85
85
|
const hot = view.ready === false ? null : topCost(visible.filter(isSession).map((r) => r.s), view.costMode);
|
|
86
86
|
if (!sessions.length) table.push(...(view.filter ? [line([{ t: ` ${t('ui.noMatch', { q: view.filter })}`, fg: PALETTE.muted, italic: true }], TW)] : emptyLines(view, TW)));
|
|
87
|
-
for (const r of visible) table.push(r.g ? groupRow(r.g, TW) : r.m ? memberRow(r.m, r.last, c, TW, view.frame, r.s.model, view.costMode) : sessionRow(r.s, c, TW, r.s === sel, view.frame, hot, view.costMode, Boolean(view.pins?.includes(r.s.id))));
|
|
87
|
+
for (const r of visible) table.push(r.g ? groupRow(r.g, TW) : r.m ? memberRow(r.m, r.last, c, TW, view.frame, r.s.model, view.costMode, r.s.status) : sessionRow(r.s, c, TW, r.s === sel, view.frame, hot, view.costMode, Boolean(view.pins?.includes(r.s.id))));
|
|
88
88
|
if (clipped) {
|
|
89
89
|
const onScreen = new Set(visible.filter(isSession).map((r) => r.s));
|
|
90
90
|
const hidden = sessions.filter((s) => !onScreen.has(s));
|