@sejuneoh/aitop 0.33.1 → 0.34.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/src/ui/draw.mjs CHANGED
@@ -43,16 +43,17 @@ export function glyph(s, frame) {
43
43
  const G = glyphs();
44
44
  if (s.status === 'waiting') return { t: frame % 8 < 5 ? G.waiting : G.waitingBlink, fg: PALETTE.waiting, bold: true };
45
45
  if (k === 'ended') return { t: G.ended, fg: PALETTE.ended };
46
- if (k === 'done') return { t: '✓', fg: PALETTE.info };
46
+ if (k === 'done') return { t: G.done, fg: PALETTE.info };
47
47
  if (k === 'unseen') return { t: G.unseen, fg: PALETTE.busy, bold: true };
48
- // 오류로 멈춤: 돌지 않는 ! 로 작업 중(스피너)과 구분한다.
49
- if (k === 'stopped') return { t: '!', fg: PALETTE.alert, bold: true };
48
+ // 오류로 멈춤: 돌지 않는 기호(G.stopped)로 작업 중(스피너)과 구분한다.
49
+ if (k === 'stopped') return { t: G.stopped, fg: PALETTE.alert, bold: true };
50
50
  if (k === 'idle') return s.status === 'live' ? { t: G.live, fg: PALETTE.tools[s.tool] } : { t: G.idle, fg: PALETTE.idle };
51
51
  return { t: SPIN[frame % SPIN.length], fg: PHASE_COLOR[k] ?? PALETTE.busy, bold: true };
52
52
  }
53
53
 
54
54
  // glyph 가 frame 에 따라 모양을 바꾸는지 (응답 대기 깜빡임, 작업 중 스피너).
55
- export const glyphMoves = (s) => s.status === 'waiting' || !['ended', 'done', 'unseen', 'idle', 'stopped'].includes(s.phase?.kind);
55
+ // SAFE 세트처럼 응답 대기 기호가 깜빡이지 않으면 응답 대기만으로는 다시 그리지 않는다.
56
+ export const glyphMoves = (s) => (s.status === 'waiting' ? glyphs().waiting !== glyphs().waitingBlink : !['ended', 'done', 'unseen', 'idle', 'stopped'].includes(s.phase?.kind));
56
57
 
57
58
  // 막대는 같은 높이의 얇은 블록(▃)으로 그리고 채운 칸과 빈칸은 색으로 나눈다. 칸 높이가 모두 같아 끝이 튀어나오지 않는다.
58
59
  // 색이 없으면 빈칸을 가장 얇은 ▁ 로 그려 모양으로 구분한다. 기호는 glyphs().bar 에 있다.
@@ -162,6 +163,7 @@ export function levelBar(values) {
162
163
  // 초 단위로 바뀌지만 타이머를 따로 두지 않는다: 실시간 화면은 데이터 갱신(1초마다)에 맞춰 다시 그리므로 그때 바뀐다.
163
164
  // 그래서 animating() 에 넣지 않고, 스피너가 없는 화면에서 120ms 프레임 타이머를 깨우지 않는다.
164
165
  export const CACHE_WARN_MS = 60_000;
166
+ // warn: 1분 미만 남은 경고 단계. STATUS 칸이 좁아도 상태 글보다 먼저 남는다 (table.mjs statusCell).
165
167
  export function cacheState(s, now = NOW) {
166
168
  if (s?.cacheExpiresAt == null || !s.live || (s.status !== 'waiting' && s.status !== 'idle')) return null;
167
169
  const left = s.cacheExpiresAt - now;
@@ -169,12 +171,12 @@ export function cacheState(s, now = NOW) {
169
171
  if (left <= 0) return { expired: true, ttl, text: tr('cache.expired'), fg: PALETTE.faint };
170
172
  const sec = Math.ceil(left / 1000);
171
173
  const t = `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, '0')}`;
172
- return { expired: false, ttl, left: t, text: tr('cache.left', { t }), fg: left < CACHE_WARN_MS ? PALETTE.alert : PALETTE.info, bold: left < CACHE_WARN_MS };
174
+ return { expired: false, ttl, left: t, text: tr('cache.left', { t }), fg: left < CACHE_WARN_MS ? PALETTE.alert : PALETTE.info, bold: left < CACHE_WARN_MS, warn: left < CACHE_WARN_MS };
173
175
  }
174
176
 
175
177
  // 지금 도는 도구의 경과 시간 (수집기의 toolStartedAt). 작업 중이고 진행 단계가 도구 실행인 세션만 본다.
176
178
  // 1분 미만은 대부분의 도구 호출이 끝나는 시간이라 보이지 않는다 (짧은 도구마다 숫자가 깜빡이지 않게).
177
- // TOOL_LONG_MS(10분) 이상이면 흐린 경고색: Claude Code 의 Bash 시간 제한이 최대 10분이라 #233 의 '멈춘 듯' 긴 기준과 같은 값을 쓴다.
179
+ // TOOL_LONG_MS(10분) 이상이면 흐린 경고색이고 warn 으로 표시해 STATUS 칸에서 상태 글보다 오래 남는다: Claude Code 의 Bash 시간 제한이 최대 10분이라 #233 의 '멈춘 듯' 긴 기준과 같은 값을 쓴다.
178
180
  // 형식은 팀원 행 경과 시간과 같은 fmtElapsed 다. 이 세션은 작업 중이라 스피너가 돌고(animating) 그 틱에 실려 바뀌므로 타이머를 따로 두지 않는다.
179
181
  export const TOOL_SHOW_MS = 60_000;
180
182
  export const TOOL_LONG_MS = MEMBER_STALL_LONG_MS;
@@ -183,5 +185,5 @@ export function toolElapsed(s, now = NOW) {
183
185
  const ms = now - s.toolStartedAt;
184
186
  if (ms < TOOL_SHOW_MS) return null;
185
187
  const long = ms >= TOOL_LONG_MS;
186
- return { text: fmtElapsed(ms), fg: long ? PALETTE.alert : PALETTE.info, dim: long, long };
188
+ return { text: fmtElapsed(ms), fg: long ? PALETTE.alert : PALETTE.info, dim: long, long, warn: long };
187
189
  }
package/src/ui/glyphs.mjs CHANGED
@@ -12,17 +12,28 @@ const NORMAL = {
12
12
  week: '▁▂▃▄▅▆▇█',
13
13
  // 시작할 때 헤더의 집계 진행 막대. 색이 없으면 채운 칸과 빈칸이 모양으로 갈리도록 ASCII 로 그린다.
14
14
  progress: NO_COLOR ? { l: '[', r: ']', fill: '#', empty: '.' } : { l: '▕', r: '▏', fill: '█', empty: '░' },
15
+ // 상태 기호. 색이 없거나(NO_COLOR) 색약 팔레트여도 모양만으로 갈리도록 서로 겹치지 않게 둔다 (test/glyphs.test.mjs).
15
16
  waiting: '◆',
16
17
  waitingBlink: '◇',
17
18
  unseen: '●',
18
- live: '●',
19
+ // 상태를 모르는 실행 중 세션(Gemini 프로세스만 보임). 확인 전 ● 와 겹치지 않게 반쯤 찬 원.
20
+ live: '◐',
19
21
  idle: '○',
20
22
  ended: '·',
23
+ // 오류로 멈춤: 돌지 않는 ! 로 작업 중(스피너)과 구분한다.
24
+ stopped: '!',
25
+ done: '✓',
21
26
  select: '▌',
22
27
  tool: '▍',
23
28
  hot: '▲',
24
29
  member: '├─ ',
25
30
  memberLast: '└─ ',
31
+ // 호출 트리(--report trace)의 이어지는 가지, 묶음 수, 완료·실패 표시.
32
+ memberPipe: '│ ',
33
+ times: '×',
34
+ traceDone: '✓',
35
+ traceFail: '✗',
36
+ traceRun: '●',
26
37
  event: '•',
27
38
  cursor: '▏',
28
39
  pin: '★',
@@ -38,24 +49,40 @@ const SAFE = {
38
49
  bar: { fill: '#', empty: NO_COLOR ? '.' : '#' },
39
50
  week: '_.:-=+*#',
40
51
  progress: { l: '[', r: ']', fill: '#', empty: '.' },
41
- waiting: '!',
42
- waitingBlink: '.',
52
+ // 상태 기호는 서로, 그리고 선택 > · 접힘 + - 와도 겹치지 않게 둔다.
53
+ // 응답 대기는 묻는 ? 로, 멈춤은 기본 세트와 같은 ! 로 둔다. 색약 팔레트에서 둘 다 노랑 계열이라 기호로만 갈린다.
54
+ // 응답 대기는 깜빡이지 않는다: 빈 모양으로 바뀌면 그 순간 다른 상태(. 종료)와 헷갈린다.
55
+ waiting: '?',
56
+ waitingBlink: '?',
43
57
  unseen: '*',
44
- live: '*',
58
+ live: '@',
45
59
  idle: 'o',
46
60
  ended: '.',
61
+ stopped: '!',
62
+ // 폭이 모호하지 않아(N) 그대로 둔다.
63
+ done: '✓',
47
64
  select: '>',
48
65
  tool: '|',
49
66
  hot: '^',
50
67
  member: '|- ',
51
68
  memberLast: '`- ',
69
+ memberPipe: '| ',
70
+ times: 'x',
71
+ traceDone: '+',
72
+ traceFail: 'x',
73
+ traceRun: '*',
52
74
  event: '*',
53
75
  cursor: '|',
54
- pin: '*',
76
+ // 확인 전 * 와 겹치지 않게.
77
+ pin: '#',
55
78
  };
56
79
 
57
80
  export const glyphs = () => (ambiguousWide() ? SAFE : NORMAL);
58
81
 
59
82
  // 도움말 범례처럼 기본 기호로 적어 둔 글을 지금 기호로 바꾼다.
60
- const SWAP = { '◆': 'waiting', '●': 'unseen', '○': 'idle', '·': 'ended', '★': 'pin' };
83
+ const SWAP = { '◆': 'waiting', '●': 'unseen', '◐': 'live', '○': 'idle', '!': 'stopped', '✓': 'done', '·': 'ended', '★': 'pin', '▲': 'hot' };
84
+
85
+ // 표의 상태 칸과 그 앞뒤에 서는 기호. 세트마다 서로 달라야 한다 (응답 대기 깜빡임은 응답 대기와 같아도 된다).
86
+ export const STATUS_KEYS = ['waiting', 'unseen', 'live', 'idle', 'stopped', 'done', 'ended', 'select', 'pin'];
87
+ export const glyphSets = () => ({ NORMAL, SAFE });
61
88
  export const legendMark = (t) => (SWAP[t] ? glyphs()[SWAP[t]] : t);
package/src/ui/table.mjs CHANGED
@@ -9,6 +9,7 @@ import { NOW, SPIN, cacheState, clock, toolElapsed, costOf, gauge, glyph, levelB
9
9
  import { glyphs } from './glyphs.mjs';
10
10
  import { phaseText, t } from '../i18n.mjs';
11
11
  import { NO_FOLDER } from '../order.mjs';
12
+ import { isStopped } from '../attention.mjs';
12
13
 
13
14
  // 검색어가 세션 이름·폴더·모델 중 하나에 들어 있으면 남긴다 (대소문자 무시).
14
15
  export function filterSessions(sessions, query) {
@@ -66,7 +67,9 @@ export function header(view, W) {
66
67
  const working = count((s) => ['busy', 'shell'].includes(s.status));
67
68
  const waiting = count((s) => s.status === 'waiting');
68
69
  const unseen = count((s) => s.unseen);
69
- const idle = count((s) => (s.status === 'idle' || s.status === 'live') && !s.unseen);
70
+ // 오류로 멈춘 세션은 status 가 idle 이라도 대기에서 빼고 따로 센다 (#262).
71
+ const stopped = count(isStopped);
72
+ const idle = count((s) => (s.status === 'idle' || s.status === 'live') && !s.unseen && !isStopped(s));
70
73
  const B = PALETTE.bar;
71
74
  const G = glyphs();
72
75
  // 0 인 상태는 빼서 오른쪽 사용량 자리를 남긴다. 좁으면 이름을 줄인다.
@@ -77,7 +80,7 @@ export function header(view, W) {
77
80
  { t: `${n} ${t(key, null, { short: narrow })}`, fg: bold ? color : PALETTE.text, bg: B, bold },
78
81
  ]
79
82
  : [];
80
- // drop: 0 은 모두 보이고, 1 은 live 수(다른 수의 합)를 빼고, 2 는 ○ 대기까지 뺀다.
83
+ // drop: 0 은 모두 보이고, 1 은 세션(live) 수(다른 수의 합)를 빼고, 2 는 ○ 지시 대기까지 뺀다.
81
84
  // 빼고 나서 남는 상태 수가 없으면 live 수는 남긴다.
82
85
  const leftOf = (narrow, drop = 0) => {
83
86
  const others = [
@@ -85,15 +88,16 @@ export function header(view, W) {
85
88
  ...stat(G.unseen, unseen, 'hdr.unseen', PALETTE.busy, true, narrow),
86
89
  ...(drop < 2 ? stat(G.idle, idle, 'hdr.idle', PALETTE.idle, false, narrow) : []),
87
90
  ];
91
+ const urgent = [...stat(G.waiting, waiting, 'hdr.waiting', PALETTE.waiting, true, narrow), ...stat(G.stopped, stopped, 'hdr.stopped', PALETTE.alert, true, narrow)].map((x, i) => (i === 0 ? { ...x, t: x.t.trimStart() } : x));
88
92
  const counts = [
89
- ...(drop < 1 || !others.length ? [{ t: `${live.length} live`, fg: PALETTE.text, bg: B, bold: true }] : []),
93
+ ...(drop < 1 || !others.length ? [{ t: t('hdr.live', { n: live.length }), fg: PALETTE.text, bg: B, bold: true }] : []),
90
94
  ...others,
91
95
  ].map((x, i) => (i === 0 ? { ...x, t: x.t.trimStart() } : x));
92
96
  return [
93
97
  { t: ` ${BRAND.logo} `, fg: PALETTE.chipText, bg: PALETTE.brand, bold: true },
94
98
  { t: ' ', bg: B },
95
- // 응답 대기가 있으면 사람이 할 일이므로 맨 앞에 둔다.
96
- ...(waiting ? [...stat(G.waiting, waiting, 'hdr.waiting', PALETTE.waiting, true, narrow).map((x, i) => (i === 0 ? { ...x, t: x.t.trimStart() } : x)), ...(counts.length ? [{ t: ' ', bg: B }] : [])] : []),
99
+ // 응답 대기·멈춤은 사람이 할 일이므로 맨 앞에 둔다. 멈춤은 기호(!)와 글자를 함께 써 색이 없어도 갈린다.
100
+ ...(urgent.length ? [...urgent, ...(counts.length ? [{ t: ' ', bg: B }] : [])] : []),
97
101
  ...counts,
98
102
  ];
99
103
  };
@@ -350,7 +354,7 @@ export function sessionRow(s, c, W, selected, frame, hot, costMode = 'api', pinn
350
354
  segs.push(...pin, { t: pad(s.name ?? '', c.name - segsWidth(pin)) + ' ', fg: ended ? PALETTE.ended : PALETTE.text, bold: selected });
351
355
  if (c.showProject) segs.push({ t: pad(s.project ?? '', c.project) + ' ', fg: ended ? PALETTE.ended : PALETTE.muted });
352
356
  segs.push(
353
- ...statusCell(status, cacheState(s) ?? toolElapsed(s), c.status, { fg: pc, bold: s.status === 'waiting' }),
357
+ ...statusCell(status, cacheState(s) ?? toolElapsed(s), c.status, { fg: pc, bold: s.status === 'waiting' }, briefStatus(s)),
354
358
  { t: pad(partial ? '…' : blank ? '' : fmtTokens(s.tokens.total), c.tokens, 'right') + ' ', fg: ended ? PALETTE.ended : partial ? PALETTE.info : PALETTE.muted },
355
359
  );
356
360
  if (c.showCost) segs.push(partial ? { t: pad('…', c.cost, 'right') + ' ', fg: PALETTE.info } : { t: pad(blank ? '' : (hot?.has(s.id) ? glyphs().hot : '') + money(costOf(s, costMode), s.costUnknown), c.cost, 'right') + ' ', fg: s.cost == null || ended ? PALETTE.info : hot?.has(s.id) ? PALETTE.money : PALETTE.muted, bold: Boolean(hot?.has(s.id)) });
@@ -362,17 +366,38 @@ export function sessionRow(s, c, W, selected, frame, hot, costMode = 'api', pinn
362
366
  // 세션 행의 STATUS 칸 (뒤 공백 포함). 덧붙일 짧은 글(tag)이 있으면 상태 글 뒤에 ' · 캐시 3:12' 처럼 붙인다.
363
367
  // tag 는 기다리는 세션의 캐시 남은 시간(cacheState) 또는 작업 중 세션의 도구 경과 시간(toolElapsed)이다. 두 상태가 달라 함께 붙지 않는다.
364
368
  // 덧붙인 글이 먼저 빠지는 정보다: 다 들어가면 그대로, 상태 글을 TAG_STATUS_MIN 칸까지 줄여 들어가면 줄여서 붙이고, 아니면 뺀다.
369
+ // 경고 단계의 덧붙임(tag.warn: 캐시 1분 미만, 도구 10분 이상)은 거꾸로 상태 글보다 오래 남는다 (#264).
370
+ // 그때 상태 글은 짧은 문구(brief, 예: '지시 대기')로 바꾸고, 그래도 넘치면 줄이고, 4칸도 안 남으면 덧붙임만 둔다.
365
371
  const TAG_STATUS_MIN = 12;
366
- export function statusCell(status, tag, w, look) {
372
+ // 경고 덧붙임 앞에 남길 상태 글의 최소 칸. 이보다 좁으면 '지…' 처럼 줄임표만 남으므로 덧붙임만 둔다.
373
+ const WARN_HEAD_MIN = 4;
374
+ export function statusCell(status, tag, w, look, brief = null) {
367
375
  const plain = [{ t: pad(status, w) + ' ', ...look }];
368
376
  if (!tag) return plain;
369
- const segs = [{ t: ' · ', fg: PALETTE.info }, { t: tag.text, fg: tag.fg, bold: tag.bold, dim: tag.dim }];
370
- const room = w - segsWidth(segs);
371
- if (room < Math.min(width(status), TAG_STATUS_MIN)) return plain;
372
- const head = truncate(status, room);
373
- return [{ t: head, ...look }, ...segs, { t: ' '.repeat(Math.max(0, room - width(head))) + ' ' }];
377
+ const tagSeg = { t: tag.text, fg: tag.fg, bold: tag.bold, dim: tag.dim };
378
+ const withHead = (text, sep = ' · ') => {
379
+ const room = w - width(sep) - width(tag.text);
380
+ const head = truncate(text, room);
381
+ return [{ t: head, ...look }, { t: sep, fg: PALETTE.info }, tagSeg, { t: ' '.repeat(Math.max(0, room - width(head))) + ' ' }];
382
+ };
383
+ const room = w - width(' · ') - width(tag.text);
384
+ if (room >= width(status)) return withHead(status);
385
+ if (tag.warn) {
386
+ // 경고 단계: 원문을 자르기보다 짧은 문구를 먼저 쓴다. · 와 함께 들어가지 않으면 사이를 한 칸으로 줄여 본다.
387
+ const head = brief && width(brief) < width(status) ? brief : status;
388
+ if (room >= width(head)) return withHead(head);
389
+ if (room + width(' · ') - 1 >= width(head)) return withHead(head, ' ');
390
+ // 줄임표만 남을 만큼 좁으면 상태 글을 빼고 덧붙임만 둔다.
391
+ if (room >= WARN_HEAD_MIN) return withHead(head);
392
+ return [{ ...tagSeg, t: pad(truncate(tag.text, w), w) + ' ' }];
393
+ }
394
+ if (room >= Math.min(width(status), TAG_STATUS_MIN)) return withHead(status);
395
+ return plain;
374
396
  }
375
397
 
398
+ // 경고 덧붙임 앞에 둘 짧은 상태 글. 다음 지시 대기만 짧은 문구가 따로 있고, 나머지는 상태 글을 줄여 쓴다.
399
+ const briefStatus = (s) => (s.phase?.kind === 'idle' && s.status === 'idle' ? t('status.idleBrief') : null);
400
+
376
401
  // 기록을 읽는 중인 세션의 CONTEXT 칸: 빈 막대와 … (gauge 와 같은 폭).
377
402
  const pendingGauge = (cells) => [{ t: glyphs().bar.empty.repeat(cells), fg: PALETTE.faint }, { t: pad('…', 5, 'right'), fg: PALETTE.info }];
378
403
 
@@ -386,7 +411,7 @@ export const statusText = (phase) => phaseText(phase, { short: true });
386
411
  // 스피너 틱(120ms)마다 다시 그리고 있고, 그 틱에 실려 바뀐다. 끝난 팀원(done)은 경과 시간을 그리지 않아 틱을 붙잡지 않는다.
387
412
  export function memberRow(m, last, c, W, frame, parentModel, costMode = 'api', parentStatus = null) {
388
413
  const done = m.status === 'done';
389
- const g = done ? { t: '✓', fg: PALETTE.info } : { t: SPIN[(frame + 3) % SPIN.length], fg: PALETTE.team, bold: true };
414
+ const g = done ? { t: glyphs().done, fg: PALETTE.info } : { t: SPIN[(frame + 3) % SPIN.length], fg: PALETTE.team, bold: true };
390
415
  const branch = last ? glyphs().memberLast : glyphs().member;
391
416
  const segs = [
392
417
  { t: ' '.repeat(c.mark + c.glyph) },
package/src/ui/theme.mjs CHANGED
@@ -70,7 +70,7 @@ const LIGHT = {
70
70
  // 색약(적록 색약: 1형·2형) 팔레트. Okabe-Ito 색 계열을 터미널 배경에 맞게 밝기만 조정했다.
71
71
  // 적록 색약은 빨강·초록·노랑을 노랑 계열 한 가지로, 파랑·보라를 파랑 계열로 본다. 그래서 꼭 갈라야 하는 쌍을 노랑 계열과 파랑 계열로 나눈다.
72
72
  // 응답 대기(노랑) ↔ 돈(파랑), 작업 중·diff 더한 줄(청록) ↔ 경고·diff 지운 줄(주홍), 예산 주의(자주) ↔ 경고(주홍).
73
- // 대기와 경고는 둘 다 노랑 계열로 보이지만 ◆ 와 ! 기호로 갈린다.
73
+ // 대기와 경고(멈춤)는 둘 다 노랑 계열로 보이지만 기호로 갈린다: 기본 ◆ 와 !, AITOP_AMBIGUOUS=wide 는 ? 와 ! (glyphs.mjs).
74
74
  // 어두운 배경의 돈은 도구 실행(하늘색)과 같은 행에 서므로 같은 파랑 계열 안에서 훨씬 밝게 둔다.
75
75
  // 글자·배경·도구 색은 기본 팔레트와 같고, 상태색과 diff 배경만 바꾼다. 대비 규칙은 기본 팔레트와 같다.
76
76
  const DARK_CB = {