@sejuneoh/aitop 0.36.1 → 0.38.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 +76 -4
- package/bin/aitop.mjs +56 -16
- package/package.json +1 -1
- package/src/collect.mjs +2 -1
- package/src/config.mjs +13 -1
- package/src/doctor.mjs +73 -27
- package/src/help.mjs +1 -0
- package/src/i18n.mjs +56 -9
- package/src/json.mjs +3 -1
- package/src/keys.mjs +2 -0
- package/src/line.mjs +6 -1
- package/src/notify.mjs +62 -4
- package/src/resume.mjs +2 -1
- package/src/sources/agy-ledger.mjs +48 -20
- package/src/sources/antigravity.mjs +172 -25
- package/src/sources/claude-ledger.mjs +8 -0
- package/src/sources/claude.mjs +16 -12
- package/src/sources/cowork.mjs +562 -0
- package/src/sources/dirs.mjs +42 -2
- package/src/sources/projects.mjs +9 -3
- package/src/suggest.mjs +31 -0
- package/src/summary.mjs +1 -1
- package/src/trace.mjs +6 -4
- package/src/ui/chrome.mjs +20 -3
- package/src/ui/detail.mjs +127 -11
- package/src/ui/draw.mjs +7 -4
- package/src/ui/glyphs.mjs +2 -1
- package/src/ui/table.mjs +40 -16
- package/src/ui/theme.mjs +2 -0
- package/src/ui.mjs +28 -0
package/src/suggest.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// 잘못 친 옵션에 가까운 옵션 하나를 고른다. 의존성 없이 짧은 편집 거리(이웃 글자 자리바꿈 포함)로 잰다.
|
|
2
|
+
|
|
3
|
+
// 삽입·삭제·바꾸기·이웃 두 글자 자리바꿈을 1 로 센 거리 (optimal string alignment).
|
|
4
|
+
export function editDistance(a, b) {
|
|
5
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
|
|
6
|
+
for (let j = 1; j <= b.length; j++) d[0][j] = j;
|
|
7
|
+
for (let i = 1; i <= a.length; i++) {
|
|
8
|
+
for (let j = 1; j <= b.length; j++) {
|
|
9
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
10
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
11
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return d[a.length][b.length];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 앞의 - 와 = 뒤 값을 떼고 비교한다. 거리 상한은 4글자 이하 1, 그보다 길면 2 (엉뚱한 제안을 막는다).
|
|
18
|
+
// 상한 안에서 가장 가까운 후보(같은 거리면 앞의 것)를 돌려주고, 없으면 null. 입력과 똑같은 후보는 제안하지 않는다.
|
|
19
|
+
export function suggest(word, candidates) {
|
|
20
|
+
const core = (s) => s.replace(/^-+/, '').replace(/=.*$/, '').toLowerCase();
|
|
21
|
+
const w = core(word);
|
|
22
|
+
if (!w) return null;
|
|
23
|
+
let best = null;
|
|
24
|
+
let bestD = (w.length <= 4 ? 1 : 2) + 1;
|
|
25
|
+
for (const c of candidates) {
|
|
26
|
+
if (c === word) continue;
|
|
27
|
+
const dist = editDistance(w, core(c));
|
|
28
|
+
if (dist < bestD) [best, bestD] = [c, dist];
|
|
29
|
+
}
|
|
30
|
+
return best;
|
|
31
|
+
}
|
package/src/summary.mjs
CHANGED
|
@@ -51,7 +51,7 @@ export function summarize(sessions, now = Date.now()) {
|
|
|
51
51
|
at: now,
|
|
52
52
|
running: live.filter((s) => s.status === 'busy' || s.status === 'shell').length,
|
|
53
53
|
waiting: waiting.length,
|
|
54
|
-
// Claude 대기 수는 --line 이 세션 파일에서 바로 세므로, 그 밖의 도구 몫(
|
|
54
|
+
// Claude 대기 수는 --line 이 세션 파일에서 바로 세므로, 그 밖의 도구 몫(Antigravity, Claude Desktop Cowork)을 따로 적는다.
|
|
55
55
|
waitingOther: waiting.filter((s) => s.tool !== 'claude').length,
|
|
56
56
|
// 그중 가장 오래 기다린 세션 이름과 대기 시작 시각 (화면 IDLE 칸과 같은 기준). 대기 시간은 읽는 쪽이 지금 시각으로 센다.
|
|
57
57
|
// v 는 그대로 둔다: 예전 aitop 은 이 칸을 모르고 넘기고, 새 aitop 은 이 칸이 없는 예전 요약도 읽는다.
|
package/src/trace.mjs
CHANGED
|
@@ -385,10 +385,12 @@ export async function findTrace(query, { claudeRoots, codexRoots, agyRoot } = {}
|
|
|
385
385
|
if (!q) return { error: 'none', candidates: [] };
|
|
386
386
|
if (claudeRoots == null || codexRoots == null) {
|
|
387
387
|
const d = await import('./sources/dirs.mjs');
|
|
388
|
-
|
|
388
|
+
// Claude Desktop Cowork 세션의 기록 폴더도 함께 본다 (#304).
|
|
389
|
+
claudeRoots ??= [...d.claudeProjectRoots(), ...(await import('./sources/cowork.mjs')).coworkProjectRoots()];
|
|
389
390
|
codexRoots ??= d.codexSessionRoots();
|
|
390
391
|
}
|
|
391
|
-
|
|
392
|
+
// agy 기록 폴더: CLI 폴더와 앱 폴더 (#303). agyRoot 는 폴더 하나 또는 목록.
|
|
393
|
+
const agyDirs = agyRoot == null ? (await import('./sources/antigravity.mjs')).agyRoots().map((r) => r.dir) : [agyRoot].flat();
|
|
392
394
|
// 1) 파일 경로
|
|
393
395
|
if (/\.(jsonl|db)$/i.test(q) && existsSync(q)) {
|
|
394
396
|
const p = resolve(q);
|
|
@@ -429,8 +431,8 @@ export async function findTrace(query, { claudeRoots, codexRoots, agyRoot } = {}
|
|
|
429
431
|
}
|
|
430
432
|
}
|
|
431
433
|
// agy: conversations/<id>.db
|
|
432
|
-
for (const f of list(join(
|
|
433
|
-
if (f.endsWith('.db') && f.toLowerCase().startsWith(low)) found.push({ tool: 'agy', id: f.slice(0, -3), path: join(
|
|
434
|
+
for (const dir of agyDirs) for (const f of list(join(dir, 'conversations'))) {
|
|
435
|
+
if (f.endsWith('.db') && f.toLowerCase().startsWith(low) && !found.some((x) => x.tool === 'agy' && x.id === f.slice(0, -3))) found.push({ tool: 'agy', id: f.slice(0, -3), path: join(dir, 'conversations', f), mtime: mtimeOf(join(dir, 'conversations', f)) });
|
|
434
436
|
}
|
|
435
437
|
// 3) 이름: 최근 Claude 기록의 /rename 이름·제목. 순서: id 가 똑같은 것 > 이름이 똑같은 것 > id 앞부분 > 이름에 들어 있는 것.
|
|
436
438
|
// id 가 똑같거나 id 앞부분으로 하나가 정해지면 이름을 읽지 않는다 (최근 기록 300개를 읽는 비용을 아낀다). 이름은 많아야 한 번 읽는다.
|
package/src/ui/chrome.mjs
CHANGED
|
@@ -33,6 +33,8 @@ const LEGEND_IDS = [
|
|
|
33
33
|
['COST', 'legend.cost'],
|
|
34
34
|
['CONTEXT', 'legend.context'],
|
|
35
35
|
['IDLE', 'legend.idleCol'],
|
|
36
|
+
// 도구 줄 끝의 숨김 표시. 미설치와 7일 미사용을 나눠 적는다 (#290).
|
|
37
|
+
['legend.missingKey', 'legend.missing'],
|
|
36
38
|
['legend.hiddenKey', 'legend.hidden'],
|
|
37
39
|
['+N', 'legend.folded'],
|
|
38
40
|
['legend.periodKey', 'legend.period'],
|
|
@@ -48,6 +50,8 @@ const LEGEND_IDS = [
|
|
|
48
50
|
['legend.stalledKey', 'legend.stalled'],
|
|
49
51
|
['member.sdk', 'legend.sdk'],
|
|
50
52
|
['session.auto', 'legend.auto'],
|
|
53
|
+
// TOOL 칸의 cowork (#304).
|
|
54
|
+
['cowork', 'legend.cowork'],
|
|
51
55
|
];
|
|
52
56
|
|
|
53
57
|
// 지금 언어의 상태 기호·열 설명. 제목 줄은 설명이 null 이다. {g} 는 팀원 경과 시간 표시(glyphs().elapsed)로 바꾼다.
|
|
@@ -132,7 +136,7 @@ export const keyChip = (k) => (NO_COLOR ? { t: `[${k}]` } : { t: ` ${k} `, fg: P
|
|
|
132
136
|
export const keyLabel = (v) => ({ t: ` ${v} `, fg: PALETTE.muted });
|
|
133
137
|
|
|
134
138
|
// items: { k, t, keep, cut } 또는 { segs, keep }. 폭이 모자라면 keep 이 아닌 항목을 오른쪽부터 뺀다.
|
|
135
|
-
// cut: 항목을 하나라도 뺐을 때 바꿔 쓸
|
|
139
|
+
// cut: 항목을 하나라도 뺐을 때 바꿔 쓸 라벨 (#265). ? 칩은 폭마다 이름이 바뀌지 않게 쓰지 않는다 (#290).
|
|
136
140
|
export function hintBar(items, W, right = '') {
|
|
137
141
|
const segsOf = (list) => [{ t: ' ' }, ...list.flatMap((i) => i.segs ?? [keyChip(i.k), keyLabel(i.t)])];
|
|
138
142
|
const wOf = (list) => segsWidth(segsOf(list));
|
|
@@ -168,17 +172,27 @@ function orderHint(view) {
|
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
// y 를 누른 뒤 잠깐 보이는 알림 (view.toast = { key, until }). 시간이 지나면 빠진다.
|
|
175
|
+
// 알림 켜기 힌트(foot.notifyHint)와 a 키 결과도 같은 자리에 보인다 (#294). 켠 결과는 초록, 나머지는 노랑.
|
|
176
|
+
const TOAST_OK = ['foot.copied', 'foot.notifyOn'];
|
|
171
177
|
function toastItem(view, now = Date.now()) {
|
|
172
178
|
const x = view.toast;
|
|
173
179
|
if (!x || now >= x.until) return [];
|
|
174
|
-
return [{ segs: [{ t: t(x.key), fg: x.key
|
|
180
|
+
return [{ segs: [{ t: t(x.key, x.vars), fg: TOAST_OK.includes(x.key) ? PALETTE.busy : PALETTE.waiting, bold: true }, { t: ' ' }], keep: true }];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 알림 상태 칩: a 알림:꺼짐. 키 줄 맨 끝(? q 앞)에 두어 넘칠 때 가장 먼저 빠진다. view.notify 는 bin 이 실시간 화면에서만 둔다 (--once 출력과 스냅숏에는 없다).
|
|
184
|
+
// 색이 없어도 글자로 켜짐·꺼짐을 읽을 수 있다.
|
|
185
|
+
function notifyItem(view) {
|
|
186
|
+
if (typeof view.notify !== 'boolean') return [];
|
|
187
|
+
return [{ k: 'a', t: t('foot.notify', { v: t(view.notify ? 'set.on' : 'set.off') }) }];
|
|
175
188
|
}
|
|
176
189
|
|
|
177
190
|
export function footer(view, W, matched, sel) {
|
|
178
191
|
const RO = t('foot.readOnly');
|
|
179
192
|
const toast = toastItem(view);
|
|
180
193
|
const tail = [
|
|
181
|
-
|
|
194
|
+
// ? 라벨은 폭과 상관없이 하나로 둔다 (#290).
|
|
195
|
+
{ k: '?', t: t('foot.help'), keep: true },
|
|
182
196
|
{ k: 'q', t: t('key.quit'), keep: true },
|
|
183
197
|
];
|
|
184
198
|
const ended = { k: 'e', t: t(view.showEnded ? 'foot.hideEnded' : 'foot.showEnded') };
|
|
@@ -215,6 +229,9 @@ export function footer(view, W, matched, sel) {
|
|
|
215
229
|
...(sel ? [{ k: 'p', t: t(view.pins?.includes(sel.id) ? 'foot.unpin' : 'key.pin') }] : []),
|
|
216
230
|
// 복사(y)는 상세 패널에 이어 여는 명령이 보일 때만 안내하고, 폭이 모자라면 가장 먼저 빠진다.
|
|
217
231
|
...(view.showDetail && resumeCmd(sel) ? [{ k: 'y', t: t('key.copy') }] : []),
|
|
232
|
+
// 알림 상태 칩은 폭이 모자라면 가장 먼저 빠진다. 고정 해제·비용 기준처럼 고른 행에 쓰는 키 안내를 밀어내지 않게 (#294).
|
|
233
|
+
// 빠져도 a 키는 그대로 듣고, 지금 상태는 도움말(?)의 '지금' 줄에서 볼 수 있다.
|
|
234
|
+
...notifyItem(view),
|
|
218
235
|
...tail,
|
|
219
236
|
];
|
|
220
237
|
return hintBar(items, W, RO);
|
package/src/ui/detail.mjs
CHANGED
|
@@ -192,6 +192,35 @@ export function wrapText(text, w) {
|
|
|
192
192
|
return out;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
// 이어 열기 명령 줄바꿈: 공백·/·\ 뒤에서 끊어 경로 조각과 세션 id 가 폭이 허락하면 한 줄에 온전히 남는다 (&& 는 앞 공백에서 끊긴다).
|
|
196
|
+
// 한 조각이 폭보다 길면 지금 줄에 이어 붙이며 그 조각만 글자 단위로 끊는다. 요청 내용은 wrapText 로 글자 단위를 유지한다 (#293).
|
|
197
|
+
export function wrapCommand(text, w) {
|
|
198
|
+
const out = [];
|
|
199
|
+
let cur = '';
|
|
200
|
+
for (const piece of String(text).match(/[^ /\\]*[ /\\]|[^ /\\]+/g) ?? []) {
|
|
201
|
+
if (width((cur + piece).trimEnd()) <= w) {
|
|
202
|
+
cur += piece;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// 새 줄에 온전히 들어가면 줄을 바꾼다.
|
|
206
|
+
if (width(piece.trimEnd()) <= w) {
|
|
207
|
+
if (cur.trimEnd()) out.push(cur.trimEnd());
|
|
208
|
+
cur = piece;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
// 폭보다 긴 조각: 지금 줄 남은 칸부터 글자 단위로 채운다.
|
|
212
|
+
for (const ch of piece) {
|
|
213
|
+
if (cur && width((cur + ch).trimEnd()) > w) {
|
|
214
|
+
out.push(cur.trimEnd());
|
|
215
|
+
cur = '';
|
|
216
|
+
}
|
|
217
|
+
if (cur || ch !== ' ') cur += ch;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (cur.trimEnd() || !out.length) out.push(cur.trimEnd());
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
|
|
195
224
|
// ── 요청 ── 구획: 응답 대기 중이고 요청 내용을 알 때만. 최대 max 줄, 넘치면 마지막 줄 끝을 … 로 바꾼다.
|
|
196
225
|
export function requestBlock(s, w, max = REQUEST_LINES) {
|
|
197
226
|
if (s.status !== 'waiting' || !s.waitDetail || max < 1) return [];
|
|
@@ -290,7 +319,8 @@ export function summaryLines(s, w, frame, view) {
|
|
|
290
319
|
const cache = cacheState(s);
|
|
291
320
|
const optional = [
|
|
292
321
|
s.branch && [sep, { t: s.branch, fg: PALETTE.info }],
|
|
293
|
-
|
|
322
|
+
// Cowork(#304)는 실행 방식(local-agent)을 붙인다.
|
|
323
|
+
s.kind && [sep, { t: s.source === 'app' ? `${s.kind} · ${tr('detail.app')}` : s.tool === 'cowork' && s.entrypoint ? `${s.kind} · ${s.entrypoint}` : s.kind, fg: PALETTE.info }],
|
|
294
324
|
s.startedAt && [sep, { t: tr('detail.startedAgo', { at: hhmm(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }), fg: PALETTE.info }],
|
|
295
325
|
// 캐시 남은 시간은 표의 STATUS 칸과 같은 짧은 글로, 가장 먼저 뺀다.
|
|
296
326
|
cache && [sep, { t: cache.text, fg: cache.fg, bold: cache.bold }],
|
|
@@ -322,18 +352,103 @@ export function summaryLines(s, w, frame, view) {
|
|
|
322
352
|
return [first, [{ t: ' ' }, ...second]];
|
|
323
353
|
}
|
|
324
354
|
|
|
325
|
-
// 이어 열기
|
|
355
|
+
// 이어 열기 명령의 꼬리: 도구별 이어 여는 부분 ('claude --resume <id>', 'codex resume <id>', 'agy --conversation <id>').
|
|
356
|
+
const RESUME_TAIL = /(?:^| )((?:claude|codex|agy) \S+ \S+)$/;
|
|
357
|
+
|
|
358
|
+
// 글 가운데를 … 로 줄이는 함수를 만든다. 돌려준 함수(k)는 폭 k 안에 앞(cd 경로 머리)과 끝(&& 앞)을 남긴다.
|
|
359
|
+
// 글자 폭은 한 번만 재 두고, k 마다 앞과 끝을 번갈아 한 글자씩 채운다 (O(k)).
|
|
360
|
+
function middleCutter(text) {
|
|
361
|
+
const chars = [...text];
|
|
362
|
+
const ws = chars.map((ch) => width(ch));
|
|
363
|
+
const total = ws.reduce((a, b) => a + b, 0);
|
|
364
|
+
return (k) => {
|
|
365
|
+
if (total <= k) return text;
|
|
366
|
+
const mark = ellipsis(k);
|
|
367
|
+
const budget = k - width(mark);
|
|
368
|
+
let used = 0;
|
|
369
|
+
let i = 0;
|
|
370
|
+
let j = chars.length - 1;
|
|
371
|
+
for (let turn = 0; i <= j; turn++) {
|
|
372
|
+
const front = turn % 2 === 0;
|
|
373
|
+
const cw = front ? ws[i] : ws[j];
|
|
374
|
+
if (used + cw > budget) break;
|
|
375
|
+
used += cw;
|
|
376
|
+
if (front) i++;
|
|
377
|
+
else j--;
|
|
378
|
+
}
|
|
379
|
+
return chars.slice(0, i).join('') + mark + chars.slice(j + 1).join('');
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// 폭 k 를 위에서부터 줄여 가며 make(k) 가 room 줄 안에 들어가는 첫 결과. 없으면 null.
|
|
384
|
+
// room 줄에는 폭 room*(w+1) 넘는 글이 들어갈 수 없으므로(줄 끝 공백 하나씩만 빠진다) 거기서부터 센다.
|
|
385
|
+
function fitLines(make, from, w, room) {
|
|
386
|
+
for (let k = Math.min(from, room * (w + 1) + 2); k >= 2; k--) {
|
|
387
|
+
const lines = wrapCommand(make(k), w);
|
|
388
|
+
if (lines.length <= room) return lines;
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 앞부분이 'cd <경로> && 변수=<값>' 이면 경로와 값만 줄여 && 와 변수 이름이 남게 한다 (변수가 없으면 앞부분 전체를 줄인다).
|
|
394
|
+
const CD_HEAD = /^(cd )('(?:[^']|'\\'')*'|\S+)( && [A-Za-z_][A-Za-z0-9_]*=)('(?:[^']|'\\'')*'|\S+)$/;
|
|
395
|
+
|
|
396
|
+
// 경로와 값에 폭 k 를 반씩 나눠 준다. 한쪽이 짧으면 남는 칸은 다른 쪽이 쓴다.
|
|
397
|
+
function envHead(cd) {
|
|
398
|
+
const [, pre, path, mid, value] = cd;
|
|
399
|
+
const cutPath = middleCutter(path);
|
|
400
|
+
const cutValue = middleCutter(value);
|
|
401
|
+
const pw = width(path);
|
|
402
|
+
const vw = width(value);
|
|
403
|
+
const fixed = width(pre) + width(mid);
|
|
404
|
+
return {
|
|
405
|
+
from: fixed + pw + vw,
|
|
406
|
+
make: (k) => {
|
|
407
|
+
const room = k - fixed;
|
|
408
|
+
const p = Math.min(pw, Math.max(2, room - Math.min(vw, Math.ceil(room / 2))));
|
|
409
|
+
const v = room - p;
|
|
410
|
+
return pre + cutPath(Math.max(2, p)) + mid + cutValue(Math.max(2, v));
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 마지막 줄 끝을 … 로 바꾼다.
|
|
416
|
+
function cutLast(lines, w) {
|
|
417
|
+
const mark = ellipsis(w);
|
|
418
|
+
const last = [...lines.at(-1)];
|
|
419
|
+
while (last.length && width(last.join('')) + width(mark) > w) last.pop();
|
|
420
|
+
return [...lines.slice(0, -1), last.join('') + mark];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// 이어 열기 명령을 폭에 맞춰 max 줄로 나눈다. 한 줄에 들어가면 그대로 둔다.
|
|
424
|
+
// 아니면 꼬리(도구 이름·옵션·세션 id)를 마지막 줄(들)에 두고, 앞부분(cd 경로, CLAUDE_CONFIG_DIR=…)은 남은 줄에 넣되 넘치면 가운데를 … 로 줄인다.
|
|
425
|
+
// 세션 id 는 폭이 id 보다 좁을 때만 글자 단위로 끊긴다.
|
|
426
|
+
// 꼬리만으로도 넘치면 마지막 줄 끝을 … 로 바꾼다. 화면만 줄이고 복사(y)에는 명령 전체가 들어간다.
|
|
326
427
|
export function resumeLines(cmd, w, max) {
|
|
327
428
|
if (!cmd || max < 1) return [];
|
|
328
|
-
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
429
|
+
w = Math.max(1, w);
|
|
430
|
+
if (width(cmd) <= w) return [cmd];
|
|
431
|
+
const m = RESUME_TAIL.exec(cmd);
|
|
432
|
+
if (!m) {
|
|
433
|
+
const all = wrapCommand(cmd, w);
|
|
434
|
+
return all.length <= max ? all : cutLast(all.slice(0, max), w);
|
|
435
|
+
}
|
|
436
|
+
const tail = wrapCommand(m[1], w);
|
|
437
|
+
if (tail.length > max) return cutLast(tail.slice(0, max), w);
|
|
438
|
+
const room = max - tail.length;
|
|
439
|
+
const head = cmd.slice(0, m.index + m[0].length - m[1].length).trimEnd();
|
|
440
|
+
// 앞부분을 남은 줄에 들어갈 때까지 가운데부터 줄인다. 남은 줄이 없으면 꼬리만.
|
|
441
|
+
if (room > 0 && head) {
|
|
442
|
+
const cd = CD_HEAD.exec(head);
|
|
443
|
+
if (cd) {
|
|
444
|
+
const { from, make } = envHead(cd);
|
|
445
|
+
const lines = fitLines(make, from, w, room);
|
|
446
|
+
if (lines) return [...lines, ...tail];
|
|
447
|
+
}
|
|
448
|
+
const lines = fitLines(middleCutter(head), width(head), w, room);
|
|
449
|
+
if (lines) return [...lines, ...tail];
|
|
335
450
|
}
|
|
336
|
-
return
|
|
451
|
+
return tail;
|
|
337
452
|
}
|
|
338
453
|
|
|
339
454
|
// 좁은 화면의 셋째 요약 줄: '이어 열기 y …/repo && claude --resume <id>'. 한 줄을 넘으면 앞을 잘라 세션 id 를 남긴다.
|
|
@@ -373,7 +488,8 @@ export function detail(s, W, H, frame, view) {
|
|
|
373
488
|
kv(tr('detail.folder'), tilde(s.cwd));
|
|
374
489
|
if (s.branch) kv(tr('detail.branch'), s.branch);
|
|
375
490
|
kv(tr('detail.model'), s.model ?? '-');
|
|
376
|
-
|
|
491
|
+
// Antigravity 데스크톱 앱의 대화는 종류 뒤에 짧게 '앱' 을 붙인다 (#303, 표에는 열을 만들지 않는다).
|
|
492
|
+
kv(tr('detail.kind'), `${s.kind ?? '-'}${s.source === 'app' ? ` · ${tr('detail.app')}` : ''}${s.tool === 'cowork' && s.entrypoint ? ` · ${s.entrypoint}` : ''}${s.pid ? ` · pid ${s.pid}` : ''}`);
|
|
377
493
|
if (s.startedAt) kv(tr('detail.started'), tr('detail.ago', { at: clock(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }));
|
|
378
494
|
|
|
379
495
|
// 합계 = 메인 + 서브 = 입력 + 출력 + 캐시 읽기 + 캐시 쓰기 가 화면에서 그대로 맞아떨어지게 보인다.
|
package/src/ui/draw.mjs
CHANGED
|
@@ -56,7 +56,7 @@ export function glyph(s, frame) {
|
|
|
56
56
|
export const glyphMoves = (s) => (s.status === 'waiting' ? glyphs().waiting !== glyphs().waitingBlink : !['ended', 'done', 'unseen', 'idle', 'stopped'].includes(s.phase?.kind));
|
|
57
57
|
|
|
58
58
|
// 막대는 같은 높이의 얇은 블록(▃)으로 그리고 채운 칸과 빈칸은 색으로 나눈다. 칸 높이가 모두 같아 끝이 튀어나오지 않는다.
|
|
59
|
-
// 색이 없으면
|
|
59
|
+
// 색이 없으면 █ 와 ░ 로 모양을 가른다. 기호는 glyphs().bar 에 있다.
|
|
60
60
|
|
|
61
61
|
// 0% 보다 크면 최소 1칸, 100% 가 아니면 마지막 칸은 비워 둔다.
|
|
62
62
|
export function filledCells(r, cells) {
|
|
@@ -69,13 +69,16 @@ export function gauge(used, total, cells) {
|
|
|
69
69
|
const BAR = glyphs().bar;
|
|
70
70
|
if (!total) return [{ t: BAR.empty.repeat(cells) + ' ', fg: PALETTE.faint }];
|
|
71
71
|
const r = Math.min(1, Math.max(0, used / total || 0));
|
|
72
|
-
const
|
|
72
|
+
const pct = Math.round(r * 100);
|
|
73
|
+
// 0% 로 보이면 칸도 채우지 않는다.
|
|
74
|
+
const full = cells && pct > 0 ? filledCells(r, cells) : 0;
|
|
73
75
|
const color = r >= 0.85 ? PALETTE.alert : r >= 0.6 ? PALETTE.text : PALETTE.busy;
|
|
76
|
+
// 색이 없어도 보이게 60% 이상은 ~, 85% 이상은 ! 를 붙인다.
|
|
77
|
+
const mark = r >= 0.85 ? '!' : r >= 0.6 ? '~' : '';
|
|
74
78
|
return [
|
|
75
79
|
{ t: BAR.fill.repeat(full), fg: color },
|
|
76
80
|
{ t: BAR.empty.repeat(cells - full), fg: PALETTE.faint },
|
|
77
|
-
|
|
78
|
-
{ t: pad(`${r >= 0.85 ? '!' : ''}${Math.round(r * 100)}%`, 5, 'right'), fg: r >= 0.85 ? PALETTE.alert : PALETTE.muted },
|
|
81
|
+
{ t: pad(`${mark}${pct}%`, 5, 'right'), fg: r >= 0.85 ? PALETTE.alert : PALETTE.muted },
|
|
79
82
|
];
|
|
80
83
|
}
|
|
81
84
|
|
package/src/ui/glyphs.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import { EDGE, NO_COLOR } from './theme.mjs';
|
|
|
8
8
|
const NORMAL = {
|
|
9
9
|
edge: EDGE,
|
|
10
10
|
rule: '─',
|
|
11
|
-
|
|
11
|
+
// 색이 없으면 채운 칸(█)과 빈칸(░)을 모양으로 가른다 (#293).
|
|
12
|
+
bar: NO_COLOR ? { fill: '█', empty: '░' } : { fill: '▃', empty: '▃' },
|
|
12
13
|
week: '▁▂▃▄▅▆▇█',
|
|
13
14
|
// 시작할 때 헤더의 집계 진행 막대. 색이 없으면 채운 칸과 빈칸이 모양으로 갈리도록 ASCII 로 그린다.
|
|
14
15
|
progress: NO_COLOR ? { l: '[', r: ']', fill: '#', empty: '.' } : { l: '▕', r: '▏', fill: '█', empty: '░' },
|
package/src/ui/table.mjs
CHANGED
|
@@ -211,7 +211,7 @@ export function progressSegs(r, bg) {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
// 폭이 모자랄 때 도구 이름 대신 쓰는 짧은 이름.
|
|
214
|
-
export const TOOL_SHORT = { claude: 'cla', codex: 'cdx', gemini: 'gem' };
|
|
214
|
+
export const TOOL_SHORT = { claude: 'cla', cowork: 'cwk', codex: 'cdx', gemini: 'gem' };
|
|
215
215
|
|
|
216
216
|
// 도구 하나의 조각. level 0 은 다 보이고, 2 부터 토큰 수·미설치 글을 빼고, 3 은 이름을 줄인다.
|
|
217
217
|
function toolPart(p, level, showEnded) {
|
|
@@ -221,7 +221,8 @@ function toolPart(p, level, showEnded) {
|
|
|
221
221
|
if (!p.live) {
|
|
222
222
|
// 종료 세션을 함께 볼 때는 그 도구의 누적 토큰을 흐리게 남긴다. 기록 폴더가 없으면 미설치로 보인다.
|
|
223
223
|
const more = !extra ? [] : p.missing ? [{ t: ` ${t('tools.missing')}`, fg: PALETTE.info, italic: true }] : showEnded && p.count ? [{ t: ` · ${fmtTokens(p.tok)}`, fg: PALETTE.info }] : [];
|
|
224
|
-
|
|
224
|
+
// 실행 중 표시(▍) 자리를 비우지 않아 조각 사이가 고르게 2칸이다.
|
|
225
|
+
return [{ t: name, fg: PALETTE.info }, ...more];
|
|
225
226
|
}
|
|
226
227
|
const tc = PALETTE.tools[p.tool];
|
|
227
228
|
return [{ t: glyphs().tool, fg: tc }, { t: name, fg: tc, bold: true }, { t: ` ${p.live}`, fg: PALETTE.text }, ...(extra ? [{ t: ` · ${fmtTokens(p.tok)}`, fg: PALETTE.muted }] : [])];
|
|
@@ -242,14 +243,16 @@ export function toolLastUsed(data, tool, now) {
|
|
|
242
243
|
return times.length ? Math.max(...times) : 0;
|
|
243
244
|
}
|
|
244
245
|
|
|
245
|
-
// 도구 줄: 도구마다 실행 중 세션 수와 누적 토큰. 실행 중 세션도 없고 7일 동안 쓰지 않은 도구는 숨기고 끝에
|
|
246
|
-
//
|
|
246
|
+
// 도구 줄: 도구마다 실행 중 세션 수와 누적 토큰. 실행 중 세션도 없고 7일 동안 쓰지 않은 도구는 숨기고 끝에
|
|
247
|
+
// '미설치: codex 7일 미사용: gemini' 처럼 미설치(기록 폴더 없음)와 미사용을 나눠 적는다 (자리가 모자라면 '미설치: 1 7일 미사용: 1').
|
|
247
248
|
// 숨기면 줄에 남는 도구가 하나도 없을 때는 숨기지 않고 예전처럼 흐리게 (미설치 포함) 다 보인다.
|
|
248
|
-
// 폭이 모자라면
|
|
249
|
+
// 조각 사이 간격은 2칸. 폭이 모자라면 토큰 수 → 이름 순으로 줄이고, 그래도 넘치면 세션이 없는 도구부터 빼고 +N 으로 뺀 수를 적는다.
|
|
249
250
|
// 아주 좁으면 실행 중인 도구가 숨김 표시보다 먼저 남고, 숨김 표시는 중간에서 자르지 않고 뺀다.
|
|
250
251
|
export function toolStrip(view, W) {
|
|
251
252
|
const now = view.data.at ?? Date.now();
|
|
252
|
-
|
|
253
|
+
// Cowork(#304)는 claude 와 따로 센다. 앱 폴더를 찾았거나(--doctor 점검에 있음) 세션이 있을 때만 줄에 넣는다.
|
|
254
|
+
const hasCowork = Boolean(view.data.tools?.tools?.cowork) || view.data.sessions.some((s) => s.tool === 'cowork');
|
|
255
|
+
const all = ['claude', ...(hasCowork ? ['cowork'] : []), 'codex', 'gemini'].map((tool) => {
|
|
253
256
|
const list = view.data.sessions.filter((s) => s.tool === tool);
|
|
254
257
|
const live = list.filter((s) => s.live).length;
|
|
255
258
|
const last = toolLastUsed(view.data, tool, now);
|
|
@@ -266,17 +269,19 @@ export function toolStrip(view, W) {
|
|
|
266
269
|
const visible = all.filter((p) => !p.idle);
|
|
267
270
|
const parts = visible.length ? visible : all;
|
|
268
271
|
const hidden = all.filter((p) => !parts.includes(p));
|
|
269
|
-
// 숨김 표시: 도구 이름을 적고, 자리가 모자라면 개수만 적는다.
|
|
270
|
-
const
|
|
272
|
+
// 숨김 표시: 미설치와 미사용을 나눠 도구 이름을 적고, 자리가 모자라면 개수만 적는다.
|
|
273
|
+
const groups = [['tools.hiddenMissing', hidden.filter((p) => p.missing)], ['tools.hiddenIdle', hidden.filter((p) => !p.missing)]].filter(([, g]) => g.length);
|
|
274
|
+
const note = (named) => groups.map(([key, g]) => ({ t: t(key, { list: named ? g.map((p) => p.tool).join(' ') : g.length }), fg: PALETTE.info }));
|
|
275
|
+
const notes = hidden.length ? [note(true), note(false)] : [[]];
|
|
271
276
|
const plus = (n) => (n ? [{ t: `+${n}`, fg: PALETTE.info }] : []);
|
|
272
277
|
const build = (shown, level, tail = []) => {
|
|
273
|
-
const gap = { t:
|
|
278
|
+
const gap = { t: ' ' };
|
|
274
279
|
const end = tail.flatMap((x, i) => [...(i ? [{ t: ' ' }] : []), x]);
|
|
275
280
|
return [{ t: ' ' }, ...shown.flatMap((p, i) => [...(i ? [gap] : []), ...toolPart(p, level, view.showEnded)]), ...(end.length ? [...(shown.length ? [gap] : []), ...end] : [])];
|
|
276
281
|
};
|
|
277
282
|
const fits = (x) => segsWidth(x) <= W;
|
|
278
283
|
let segs = null;
|
|
279
|
-
for (const level of [0,
|
|
284
|
+
for (const level of [0, 2, 3]) {
|
|
280
285
|
for (const note of notes) {
|
|
281
286
|
const s = build(parts, level, note);
|
|
282
287
|
if (fits(s)) {
|
|
@@ -306,7 +311,7 @@ export function toolStrip(view, W) {
|
|
|
306
311
|
segs = fits(noted.segs) && liveOf(noted) >= liveOf(bare) ? noted.segs : bare.segs;
|
|
307
312
|
}
|
|
308
313
|
// 종료 세션 표시는 다 들어갈 때만 붙인다 (잘린 조각이 남지 않게).
|
|
309
|
-
const ended = [{ t: '
|
|
314
|
+
const ended = [{ t: ' ' }, { t: t('tools.ended'), fg: PALETTE.info, italic: true }];
|
|
310
315
|
if (view.showEnded && segsWidth(segs) + segsWidth(ended) <= W) segs.push(...ended);
|
|
311
316
|
return line(segs, W);
|
|
312
317
|
}
|
|
@@ -357,7 +362,7 @@ export function sessionRow(s, c, W, selected, frame, hot, costMode = 'api', pinn
|
|
|
357
362
|
segs.push(...pin, ...auto, { t: pad(s.name ?? '', c.name - segsWidth(pin) - segsWidth(auto)) + ' ', fg: ended ? PALETTE.ended : PALETTE.text, bold: selected });
|
|
358
363
|
if (c.showProject) segs.push({ t: pad(s.project ?? '', c.project) + ' ', fg: ended ? PALETTE.ended : PALETTE.muted });
|
|
359
364
|
segs.push(
|
|
360
|
-
...statusCell(status, cacheState(s) ?? toolElapsed(s), c.status, { fg: pc, bold: s.status === 'waiting' }, briefStatus(s)),
|
|
365
|
+
...statusCell(status, cacheState(s) ?? toolElapsed(s), c.status, { fg: pc, bold: s.status === 'waiting' }, briefStatus(s), status === statusText(s.phase) ? toolTarget(s.phase) : null),
|
|
361
366
|
{ t: pad(partial ? '…' : blank ? '' : fmtTokens(s.tokens.total), c.tokens, 'right') + ' ', fg: ended ? PALETTE.ended : partial ? PALETTE.info : PALETTE.muted },
|
|
362
367
|
);
|
|
363
368
|
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)) });
|
|
@@ -371,12 +376,15 @@ export function sessionRow(s, c, W, selected, frame, hot, costMode = 'api', pinn
|
|
|
371
376
|
// 덧붙인 글이 먼저 빠지는 정보다: 다 들어가면 그대로, 상태 글을 TAG_STATUS_MIN 칸까지 줄여 들어가면 줄여서 붙이고, 아니면 뺀다.
|
|
372
377
|
// 경고 단계의 덧붙임(tag.warn: 캐시 1분 미만, 도구 10분 이상)은 거꾸로 상태 글보다 오래 남는다 (#264).
|
|
373
378
|
// 그때 상태 글은 짧은 문구(brief, 예: '지시 대기')로 바꾸고, 그래도 넘치면 줄이고, 4칸도 안 남으면 덧붙임만 둔다.
|
|
379
|
+
// target: 도구 실행 중이면 동사('도구 실행')를 뺀 대상('Bash $ npm test'). 칸이 모자라면 동사부터 빼고 대상과 덧붙임을 남긴다 (#293).
|
|
374
380
|
const TAG_STATUS_MIN = 12;
|
|
375
381
|
// 경고 덧붙임 앞에 남길 상태 글의 최소 칸. 이보다 좁으면 '지…' 처럼 줄임표만 남으므로 덧붙임만 둔다.
|
|
376
382
|
const WARN_HEAD_MIN = 4;
|
|
377
|
-
export function statusCell(status, tag, w, look, brief = null) {
|
|
383
|
+
export function statusCell(status, tag, w, look, brief = null, target = null) {
|
|
378
384
|
const plain = [{ t: pad(status, w) + ' ', ...look }];
|
|
379
|
-
|
|
385
|
+
// 대상은 상태 글보다 짧을 때만 쓴다.
|
|
386
|
+
const tgt = target && width(target) < width(status) ? target : null;
|
|
387
|
+
if (!tag) return width(status) > w && tgt ? [{ t: pad(tgt, w) + ' ', ...look }] : plain;
|
|
380
388
|
const tagSeg = { t: tag.text, fg: tag.fg, bold: tag.bold, dim: tag.dim };
|
|
381
389
|
const withHead = (text, sep = ' · ') => {
|
|
382
390
|
const room = w - width(sep) - width(tag.text);
|
|
@@ -387,17 +395,28 @@ export function statusCell(status, tag, w, look, brief = null) {
|
|
|
387
395
|
if (room >= width(status)) return withHead(status);
|
|
388
396
|
if (tag.warn) {
|
|
389
397
|
// 경고 단계: 원문을 자르기보다 짧은 문구를 먼저 쓴다. · 와 함께 들어가지 않으면 사이를 한 칸으로 줄여 본다.
|
|
390
|
-
const head = brief && width(brief) < width(status) ? brief : status;
|
|
398
|
+
const head = tgt ?? (brief && width(brief) < width(status) ? brief : status);
|
|
391
399
|
if (room >= width(head)) return withHead(head);
|
|
392
400
|
if (room + width(' · ') - 1 >= width(head)) return withHead(head, ' ');
|
|
393
401
|
// 줄임표만 남을 만큼 좁으면 상태 글을 빼고 덧붙임만 둔다.
|
|
394
402
|
if (room >= WARN_HEAD_MIN) return withHead(head);
|
|
395
403
|
return [{ ...tagSeg, t: pad(truncate(tag.text, w), w) + ' ' }];
|
|
396
404
|
}
|
|
405
|
+
// 대상이 있으면 동사를 빼고 대상(줄여서라도)과 덧붙임을 남긴다. 4칸도 안 남으면 대상만.
|
|
406
|
+
if (tgt) return room >= WARN_HEAD_MIN ? withHead(tgt) : [{ t: pad(tgt, w) + ' ', ...look }];
|
|
397
407
|
if (room >= Math.min(width(status), TAG_STATUS_MIN)) return withHead(status);
|
|
398
408
|
return plain;
|
|
399
409
|
}
|
|
400
410
|
|
|
411
|
+
// 도구 실행 상태 글에서 동사를 뺀 대상: 'Bash $ npm test' (팀원 수가 있으면 뒤에 붙인다). 도구 실행이 아니면 null.
|
|
412
|
+
export function toolTarget(phase) {
|
|
413
|
+
if (phase?.kind !== 'tool' || phase.msg || !phase.args?.what) return null;
|
|
414
|
+
const full = statusText(phase);
|
|
415
|
+
// '도구 실행 · Bash' 에서 '도구 실행 · ' 를 뗀다. 문구 모양이 다르면 쓰지 않는다.
|
|
416
|
+
const verb = statusText({ kind: 'tool', args: { what: '\0' } }).split('\0')[0];
|
|
417
|
+
return verb && full.startsWith(verb) ? full.slice(verb.length) : null;
|
|
418
|
+
}
|
|
419
|
+
|
|
401
420
|
// 경고 덧붙임 앞에 둘 짧은 상태 글. 다음 지시 대기만 짧은 문구가 따로 있고, 나머지는 상태 글을 줄여 쓴다.
|
|
402
421
|
const briefStatus = (s) => (s.phase?.kind === 'idle' && s.status === 'idle' ? t('status.idleBrief') : null);
|
|
403
422
|
|
|
@@ -464,8 +483,13 @@ export function memberRow(m, last, c, W, frame, parentModel, costMode = 'api', p
|
|
|
464
483
|
export const MARK_COLOR = { ok: PALETTE.busy, missing: PALETTE.alert, limited: PALETTE.muted };
|
|
465
484
|
|
|
466
485
|
export function emptyLines(view, W) {
|
|
467
|
-
const out = [line([{ t: ` ${t(view.showEnded ? 'empty.none24' : 'empty.none')}`, fg: PALETTE.muted, italic: true }], W), line([], W)];
|
|
468
486
|
const tools = Object.values(view.data.tools?.tools ?? {});
|
|
487
|
+
// 프로세스는 실행 중인데 읽을 기록이 없으면 그 사실과 다음 할 일을 첫 줄에 적는다 (실행 1 과 '세션 없음' 이 엇갈리지 않게).
|
|
488
|
+
const running = tools.filter((r) => r.running > 0 && !r.records).map((r) => r.tool);
|
|
489
|
+
const head = running.length
|
|
490
|
+
? [line([{ t: ` ${t('empty.procs', { list: running.join(' ') })}`, fg: PALETTE.muted, italic: true }], W), line([{ t: ` → ${t('empty.procsHint')}`, fg: PALETTE.info }], W)]
|
|
491
|
+
: [line([{ t: ` ${t(view.showEnded ? 'empty.none24' : 'empty.none')}`, fg: PALETTE.muted, italic: true }], W)];
|
|
492
|
+
const out = [...head, line([], W)];
|
|
469
493
|
const pathW = Math.max(0, ...tools.map((r) => width(r.path)));
|
|
470
494
|
for (const r of tools) {
|
|
471
495
|
const d = describe(r, NOW);
|
package/src/ui/theme.mjs
CHANGED
|
@@ -107,6 +107,8 @@ export const paletteName = (theme, colorBlind) => (colorBlind ? `${theme}-cb` :
|
|
|
107
107
|
export const THEME = pickTheme();
|
|
108
108
|
export const COLOR_BLIND = pickColorBlind();
|
|
109
109
|
export const PALETTES = { dark: DARK, light: LIGHT, 'dark-cb': DARK_CB, 'light-cb': LIGHT_CB };
|
|
110
|
+
// Claude Desktop Cowork(#304) 세션은 claude 와 같은 색이다.
|
|
111
|
+
for (const p of Object.values(PALETTES)) p.tools = { ...p.tools, cowork: p.tools.claude };
|
|
110
112
|
export const PALETTE = PALETTES[paletteName(THEME, COLOR_BLIND)];
|
|
111
113
|
|
|
112
114
|
export const hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16)).join(';');
|
package/src/ui.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { width } from './text.mjs';
|
|
|
3
3
|
import { BRAND } from './brand.mjs';
|
|
4
4
|
import { PALETTE } from './ui/theme.mjs';
|
|
5
5
|
import { glyphMoves, line, setNow } from './ui/draw.mjs';
|
|
6
|
+
import { glyphs } from './ui/glyphs.mjs';
|
|
6
7
|
import { TABLE_BOX_H, columns, emptyLines, filterSessions, groupRow, header, memberRow, sessionRow, tableBox, tableHeader, toolStrip, topCost } from './ui/table.mjs';
|
|
7
8
|
import { detail } from './ui/detail.mjs';
|
|
8
9
|
import { detailOpen, footer, help } from './ui/chrome.mjs';
|
|
@@ -22,6 +23,33 @@ export function animating(view) {
|
|
|
22
23
|
return filterSessions(view.data.sessions, view.filter).some((s) => glyphMoves(s) || (s.members ?? []).some((m) => m.status !== 'done'));
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
// 터미널이 아닌 곳(파이프·파일)으로 내는 --once 용 (#292). render 결과에서 맨 아래 키 안내 줄과,
|
|
27
|
+
// 화면 높이를 맞추려고 채운 빈 줄(끝의 빈 줄, 상세 상자 아래쪽의 테두리만 있는 줄)과 줄 끝 공백을 뺀다.
|
|
28
|
+
// 테두리 글자는 지금 기호 세트(AITOP_AMBIGUOUS=wide 면 ASCII)에서 고른다.
|
|
29
|
+
const ANSI = /\x1b\[[0-9;]*m/g;
|
|
30
|
+
const plain = (l) => l.replace(ANSI, '');
|
|
31
|
+
// 줄 끝의 공백과 색 코드를 지운다. 색 코드가 있던 줄은 끝에 초기화(ESC[0m)를 붙여 색이 다음 줄로 번지지 않게 한다.
|
|
32
|
+
const trimEnd = (l) => {
|
|
33
|
+
const cut = l.replace(/(?:\s|\x1b\[[0-9;]*m)+$/, '');
|
|
34
|
+
return cut !== l && /\x1b\[/.test(l) && /\x1b\[/.test(cut) ? cut + '\x1b[0m' : cut;
|
|
35
|
+
};
|
|
36
|
+
export function pipeLines(lines) {
|
|
37
|
+
const E = Object.values(glyphs().edge);
|
|
38
|
+
const vert = new Set(E.map((e) => e.v));
|
|
39
|
+
const filler = (l) => [...plain(l)].every((ch) => /\s/.test(ch) || vert.has(ch));
|
|
40
|
+
const isBottom = (l) => E.some((e) => plain(l).startsWith(e.bl + e.h));
|
|
41
|
+
const out = lines.slice(0, -1);
|
|
42
|
+
while (out.length && !plain(out.at(-1)).trim()) out.pop();
|
|
43
|
+
// 마지막 줄이 상자 아래 테두리면 그 바로 위의 빈 칸 줄들을 지운다.
|
|
44
|
+
const bottom = out.length - 1;
|
|
45
|
+
if (bottom >= 1 && isBottom(out[bottom])) {
|
|
46
|
+
let top = bottom;
|
|
47
|
+
while (top > 1 && filler(out[top - 1])) top--;
|
|
48
|
+
out.splice(top, bottom - top);
|
|
49
|
+
}
|
|
50
|
+
return out.map(trimEnd);
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
// 로딩 중(준비 완료 전이거나 7일 집계 중)에는 경과 시간(IDLE 등)을 데이터를 받은 시각에 맞춰, 스피너 프레임마다 숫자가 따로 바뀌지 않게 한다.
|
|
26
54
|
const settling = (view) => view.data && (view.ready === false || view.data.usage?.loading != null);
|
|
27
55
|
|