@sejuneoh/aitop 0.38.1 → 0.40.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 +11 -2
- package/bin/aitop.mjs +2 -0
- package/package.json +1 -1
- package/src/cache.mjs +3 -1
- package/src/help.mjs +24 -3
- package/src/i18n.mjs +68 -0
- package/src/json.mjs +4 -0
- package/src/keys.mjs +94 -1
- package/src/sources/artifact-source.mjs +278 -0
- package/src/sources/artifacts.mjs +94 -0
- package/src/sources/claude-tracker.mjs +108 -3
- package/src/sources/claude.mjs +11 -1
- package/src/tail.mjs +18 -10
- package/src/ui/artifact-view.mjs +634 -0
- package/src/ui/chrome.mjs +4 -0
- package/src/ui/detail.mjs +66 -1
- package/src/ui/draw.mjs +5 -2
- package/src/ui/theme.mjs +26 -0
- package/src/ui.mjs +12 -1
package/src/ui/detail.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 선택한 세션 상세 패널: 왼쪽 요약, 오른쪽 변경 파일·지시 탭·diff·최근 활동. 100칸 미만에서는 요약을 위쪽 두 줄로 접는다.
|
|
2
|
-
import { ellipsis, fmtAgo, fmtTokens, pad, truncateLeft, width } from '../text.mjs';
|
|
2
|
+
import { ellipsis, fmtAgo, fmtTokens, pad, truncate, truncateLeft, width } from '../text.mjs';
|
|
3
3
|
import { currentTab, filesForTab, turnTabs } from '../turns.mjs';
|
|
4
4
|
import { isAbsolute, relative } from 'node:path';
|
|
5
5
|
import { PALETTE, PHASE_COLOR } from './theme.mjs';
|
|
@@ -8,6 +8,7 @@ import { activitySeries } from '../sources/common.mjs';
|
|
|
8
8
|
import { glyphs } from './glyphs.mjs';
|
|
9
9
|
import { STRINGS, phaseText, t as tr } from '../i18n.mjs';
|
|
10
10
|
import { resumeCmd } from '../resume.mjs';
|
|
11
|
+
import { artifactLink, audienceKind } from '../sources/artifacts.mjs';
|
|
11
12
|
|
|
12
13
|
// 탭 이름: 이번 지시·전체 탭은 turns.mjs 가 ko 이름을 붙이므로 지금 언어로 바꾼다. 지시 탭(T5)은 그대로.
|
|
13
14
|
const tabLabel = (tab, short = false) => (tab.key === 'now' ? tr('detail.tabNow', null, { short }) : tab.key === 'all' ? tr('detail.tabAll') : tab.label);
|
|
@@ -236,12 +237,76 @@ export function requestBlock(s, w, max = REQUEST_LINES) {
|
|
|
236
237
|
return [rule([{ t: tr('detail.request'), fg: PALETTE.waiting, bold: true }], '', w), ...lines.map((l) => [INDENT, { t: l, fg: PALETTE.text }])];
|
|
237
238
|
}
|
|
238
239
|
|
|
240
|
+
// ── 아티팩트 N ── 구획 (#305): Artifact 도구로 게시한 것이 있을 때만. 한 줄에 제목 · v1→v3 · 시각 · 링크 · 바로 수정 · 공개(조직 공유).
|
|
241
|
+
// 버전(seq)을 모르면 버전 칸을 뺀다.
|
|
242
|
+
// 최근 순으로 max-1 줄까지 보이고, 넘치면 가로줄 끝에 +N 을 붙인다.
|
|
243
|
+
export const ARTIFACT_LINES = 4;
|
|
244
|
+
const TITLE_MIN = 12;
|
|
245
|
+
|
|
246
|
+
// 링크 글: 주소 전체(https:// 뺌)가 들어가면 그대로, 아니면 claude.ai/… 뒤에 마지막 조각 끝 8자.
|
|
247
|
+
function linkLabel(url, full) {
|
|
248
|
+
const bare = url.replace(/^https:\/\//, '');
|
|
249
|
+
if (full) return bare;
|
|
250
|
+
const last = bare.split(/[/?#]/).filter(Boolean).at(-1) ?? '';
|
|
251
|
+
return `claude.ai/…${last.slice(-8)}`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// selected: 목록에 들어가(v) 고른 줄. 들여 쓰기 자리에 ▸ 를 두고 배경을 칠해 폭은 그대로다.
|
|
255
|
+
export function artifactRow(a, w, selected = false) {
|
|
256
|
+
const textW = Math.max(1, w - width(INDENT.t));
|
|
257
|
+
const sep = { t: ' · ', fg: PALETTE.info };
|
|
258
|
+
const url = artifactLink(a.url);
|
|
259
|
+
const ver = a.to == null ? null : a.from != null && a.from !== a.to ? `v${a.from}→v${a.to}` : `v${a.to}`;
|
|
260
|
+
const tags = [a.edits && { t: tr('detail.artEdits'), fg: PALETTE.muted }, audienceKind(a.audience) && { t: tr(audienceKind(a.audience) === 'org' ? 'detail.artOrg' : 'detail.artPublic'), fg: PALETTE.waiting, bold: true }].filter(Boolean);
|
|
261
|
+
const link = (full) => (url ? [sep, { t: linkLabel(url, full), fg: PALETTE.info, link: url }] : []);
|
|
262
|
+
const title = a.title || (url ? linkLabel(url, false) : '-');
|
|
263
|
+
const head = [...(ver ? [sep, { t: ver, fg: PALETTE.muted }] : [])];
|
|
264
|
+
const time = Number.isFinite(a.at) ? [sep, { t: hhmm(a.at), fg: PALETTE.info }] : [];
|
|
265
|
+
const tagSegs = tags.flatMap((x) => [sep, x]);
|
|
266
|
+
// 자리가 모자라면 주소 전체 → 표시(바로 수정·공개) → 시각 → 버전 순으로 줄이고, 짧은 링크는 끝까지 남긴다.
|
|
267
|
+
const options = [
|
|
268
|
+
[...head, ...time, ...link(true), ...tagSegs],
|
|
269
|
+
[...head, ...time, ...link(false), ...tagSegs],
|
|
270
|
+
[...head, ...time, ...link(false)],
|
|
271
|
+
[...head, ...link(false)],
|
|
272
|
+
[...link(false)],
|
|
273
|
+
[],
|
|
274
|
+
];
|
|
275
|
+
// 주소 전체는 제목이 잘리지 않을 때만 쓴다. 나머지는 제목이 TITLE_MIN 칸(짧으면 제 길이)을 얻는 첫 모양.
|
|
276
|
+
const want = (k) => (k === 0 ? width(title) : Math.min(width(title), TITLE_MIN));
|
|
277
|
+
const rest = options.find((o, k) => textW - segsWidth(o) >= want(k)) ?? [];
|
|
278
|
+
const titleW = Math.max(1, textW - segsWidth(rest));
|
|
279
|
+
const row = [selected ? { t: '▸', fg: PALETTE.brand, bold: true } : INDENT, { t: truncate(title, titleW), fg: PALETTE.text, bold: true }, ...rest];
|
|
280
|
+
return selected ? fill(row, w, PALETTE.rowFocus) : row;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// view.focus 가 'artifacts' 면 고른 줄(view.artifactId)이 보이게 창을 옮기고, 구획 왼쪽에 ▌ 막대를 세운다 (변경 파일 목록과 같은 모양).
|
|
284
|
+
// 목록에 들어가 있지 않으면 가로줄 끝에 들어가는 키(v)를 알린다.
|
|
285
|
+
export function artifactBlock(s, w, max = ARTIFACT_LINES + 1, view = null) {
|
|
286
|
+
const list = s.artifacts ?? [];
|
|
287
|
+
if (!list.length || max < 2) return [];
|
|
288
|
+
const focused = view?.focus === 'artifacts';
|
|
289
|
+
const gutter = focused ? [{ t: glyphs().select, fg: PALETTE.brand }] : [];
|
|
290
|
+
const inner = w - segsWidth(gutter);
|
|
291
|
+
const slots = max - 1;
|
|
292
|
+
const sel = focused ? list.findIndex((a) => a.id === view.artifactId) : -1;
|
|
293
|
+
const start = sel >= slots ? sel - slots + 1 : 0;
|
|
294
|
+
const shown = list.slice(start, start + slots);
|
|
295
|
+
const more = list.length - shown.length;
|
|
296
|
+
const meta = [more ? `+${more}` : '', focused ? '' : 'v'].filter(Boolean).join(' · ');
|
|
297
|
+
const head = rule([{ t: tr('detail.artifacts', { n: list.length }), fg: focused ? PALETTE.brand : PALETTE.text, bold: true }], meta, inner, focused ? PALETTE.brand : PALETTE.line);
|
|
298
|
+
return [head, ...shown.map((a, k) => artifactRow(a, inner, start + k === sel))].map((r) => [...gutter, ...r]);
|
|
299
|
+
}
|
|
300
|
+
|
|
239
301
|
// 오른쪽 칸: 고친 파일이 없으면 최근 활동만, 있으면 위쪽 절반까지 변경 파일 구획(배경 띠), 파일을 열면 diff.
|
|
240
302
|
// 머리는 안쪽 줄 수에 따라: 16 이상 가로줄+탭+지시, 11~15 가로줄+탭(지시는 탭 줄 오른쪽), 10 이하 가로줄만.
|
|
241
303
|
export function rightColumn(s, w, rows, view) {
|
|
242
304
|
// --show-requests 를 켰고 응답 대기 중이면 요청 내용을 맨 위에 두고, 아래 구획에는 적어도 4줄을 남긴다.
|
|
243
305
|
const req = view?.showRequests ? requestBlock(s, w, Math.min(REQUEST_LINES, rows - 5)) : [];
|
|
244
306
|
if (req.length) return [...req, ...rightColumn({ ...s, waitDetail: null }, w, rows - req.length, view)];
|
|
307
|
+
// 아티팩트 구획은 diff 를 열지 않았을 때 그 아래에 둔다. 아래 구획(변경 파일·최근 활동)에 적어도 6줄을 남긴다.
|
|
308
|
+
const art = view?.focus === 'diff' ? [] : artifactBlock(s, w, Math.min(ARTIFACT_LINES + 1, rows - 6), view);
|
|
309
|
+
if (art.length) return [...art, ...rightColumn({ ...s, waitDetail: null, artifacts: [] }, w, rows - art.length, view)];
|
|
245
310
|
const all = s.files ?? [];
|
|
246
311
|
const focused = view?.focus === 'files';
|
|
247
312
|
// 가로줄 끝에 '─' 두 칸은 남긴다 (── 3칸 + 최근 활동 이름(한국어 9칸) + 막대 + ' ─' 2칸).
|
package/src/ui/draw.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { fmtElapsed, pad, stripControl, truncate, width } from '../text.mjs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { tildeIn } from '../paths.mjs';
|
|
5
|
-
import { NO_COLOR, PALETTE, PHASE_COLOR, RESET, style } from './theme.mjs';
|
|
5
|
+
import { NO_COLOR, PALETTE, PHASE_COLOR, RESET, linksOn, osc8, style } from './theme.mjs';
|
|
6
|
+
import { artifactLink } from '../sources/artifacts.mjs';
|
|
6
7
|
import { glyphs } from './glyphs.mjs';
|
|
7
8
|
import { t as tr } from '../i18n.mjs';
|
|
8
9
|
import { MEMBER_STALL_LONG_MS } from '../sources/common.mjs';
|
|
@@ -15,7 +16,9 @@ export function line(segs, W, bg) {
|
|
|
15
16
|
for (const seg of segs) {
|
|
16
17
|
if (used >= W) break;
|
|
17
18
|
const t = truncate(stripControl(seg.t ?? ''), W - used);
|
|
18
|
-
|
|
19
|
+
// link: 아티팩트 주소 (#305). 허용 목록을 다시 지난 주소만, 링크를 켠 터미널에서만 OSC 8 로 감싼다. 폭은 t 로만 센다.
|
|
20
|
+
const url = seg.link && linksOn() ? artifactLink(seg.link) : null;
|
|
21
|
+
out += style({ bg, ...seg }) + (url && t ? osc8(url, t) : t);
|
|
19
22
|
used += width(t);
|
|
20
23
|
}
|
|
21
24
|
return out + style({ bg }) + ' '.repeat(Math.max(0, W - used)) + RESET;
|
package/src/ui/theme.mjs
CHANGED
|
@@ -126,6 +126,32 @@ export function style({ fg, bg, bold, dim, italic } = {}) {
|
|
|
126
126
|
|
|
127
127
|
export const RESET = NO_COLOR ? '' : '\x1b[0m';
|
|
128
128
|
|
|
129
|
+
// OSC 8 클릭 링크 (#305). 색을 끈 화면(NO_COLOR, 파이프·파일 출력은 bin 이 NO_COLOR 를 켠다)과 터미널이 아닌 출력에서는 늘 평문이다.
|
|
130
|
+
// 그 밖에는 FORCE_HYPERLINK(1/0, supports-hyperlinks 관례)가 있으면 따르고, 없으면 OSC 8 을 그린다고 알려진 터미널만 켠다.
|
|
131
|
+
// tmux 는 3.4 부터 링크를 넘기고 그 전 판은 모르는 OSC 를 삼키므로 켠다. GNU screen 과 리눅스 콘솔은 끈다.
|
|
132
|
+
export function hyperlinks(env = process.env, tty = Boolean(process.stdout?.isTTY)) {
|
|
133
|
+
if (env.NO_COLOR || !tty) return false;
|
|
134
|
+
const force = env.FORCE_HYPERLINK;
|
|
135
|
+
if (force != null && force !== '') return !['0', 'false'].includes(force);
|
|
136
|
+
const term = env.TERM ?? '';
|
|
137
|
+
if (term === 'dumb' || term === 'linux' || env.STY) return false;
|
|
138
|
+
if (env.TMUX || env.WT_SESSION || env.KITTY_WINDOW_ID || env.WEZTERM_PANE || env.KONSOLE_VERSION || env.DOMTERM) return true;
|
|
139
|
+
if (Number(env.VTE_VERSION) >= 5000) return true;
|
|
140
|
+
if (/^(iTerm\.app|WezTerm|vscode|ghostty|Hyper|Tabby|rio|WarpTerminal)$/.test(env.TERM_PROGRAM ?? '')) return true;
|
|
141
|
+
return /kitty|alacritty|foot|ghostty|wezterm/.test(term);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let LINKS = hyperlinks();
|
|
145
|
+
export const linksOn = () => LINKS;
|
|
146
|
+
// 테스트용: 링크 그리기를 켜고 끈다. 이전 값을 돌려준다.
|
|
147
|
+
export function _setLinks(on) {
|
|
148
|
+
const prev = LINKS;
|
|
149
|
+
LINKS = Boolean(on);
|
|
150
|
+
return prev;
|
|
151
|
+
}
|
|
152
|
+
// 글자 t 를 url 로 가는 링크로 감싼다. 폭 계산은 감싸기 전의 t 로 한다 (draw.mjs line).
|
|
153
|
+
export const osc8 = (url, t) => `\x1b]8;;${url}\x1b\\${t}\x1b]8;;\x1b\\`;
|
|
154
|
+
|
|
129
155
|
// 하루 예산 경고. 주의(예상이 예산의 80% 이상)는 대기 색과 헷갈리지 않게 팀원 색을, 초과 예상은 경고 색을 쓴다.
|
|
130
156
|
export const BUDGET_TOKEN = { caution: 'team', warn: 'alert' };
|
|
131
157
|
export const BUDGET_COLOR = { caution: PALETTE[BUDGET_TOKEN.caution], warn: PALETTE[BUDGET_TOKEN.warn] };
|
package/src/ui.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { glyphMoves, line, setNow } from './ui/draw.mjs';
|
|
|
6
6
|
import { glyphs } from './ui/glyphs.mjs';
|
|
7
7
|
import { TABLE_BOX_H, columns, emptyLines, filterSessions, groupRow, header, memberRow, sessionRow, tableBox, tableHeader, toolStrip, topCost } from './ui/table.mjs';
|
|
8
8
|
import { detail } from './ui/detail.mjs';
|
|
9
|
+
import { artifactScreen } from './ui/artifact-view.mjs';
|
|
9
10
|
import { detailOpen, footer, help } from './ui/chrome.mjs';
|
|
10
11
|
import { arrange } from './order.mjs';
|
|
11
12
|
import { callsYou } from './attention.mjs';
|
|
@@ -26,7 +27,8 @@ export function animating(view) {
|
|
|
26
27
|
// 터미널이 아닌 곳(파이프·파일)으로 내는 --once 용 (#292). render 결과에서 맨 아래 키 안내 줄과,
|
|
27
28
|
// 화면 높이를 맞추려고 채운 빈 줄(끝의 빈 줄, 상세 상자 아래쪽의 테두리만 있는 줄)과 줄 끝 공백을 뺀다.
|
|
28
29
|
// 테두리 글자는 지금 기호 세트(AITOP_AMBIGUOUS=wide 면 ASCII)에서 고른다.
|
|
29
|
-
|
|
30
|
+
// 색 코드와 OSC 8 링크 머리·꼬리 (#305).
|
|
31
|
+
const ANSI = /\x1b\[[0-9;]*m|\x1b\]8;[^\x07\x1b]*(?:\x07|\x1b\\)/g;
|
|
30
32
|
const plain = (l) => l.replace(ANSI, '');
|
|
31
33
|
// 줄 끝의 공백과 색 코드를 지운다. 색 코드가 있던 줄은 끝에 초기화(ESC[0m)를 붙여 색이 다음 줄로 번지지 않게 한다.
|
|
32
34
|
const trimEnd = (l) => {
|
|
@@ -73,6 +75,15 @@ export function render(view, W, H) {
|
|
|
73
75
|
lines.push(footer({ ...view, showDetail: detailOpen(view, H) }, W, sessions.length));
|
|
74
76
|
return lines;
|
|
75
77
|
}
|
|
78
|
+
// 아티팩트 원본(#307)은 머리 줄과 키 줄 사이 전체를 쓴다.
|
|
79
|
+
if (view.focus === 'artifact' && view.artDoc) {
|
|
80
|
+
const s = view.data.sessions.find((x) => x.id === view.selectedId);
|
|
81
|
+
const a = s?.artifacts?.find((x) => x.id === view.artifactId) ?? null;
|
|
82
|
+
lines.push(header(view, W), ...artifactScreen(view.artDoc, a, W, Math.max(3, H - 2), view));
|
|
83
|
+
lines.length = H - 1;
|
|
84
|
+
lines.push(footer(view, W, sessions.length));
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
76
87
|
lines.push(header(view, W), toolStrip(view, W));
|
|
77
88
|
if (!boxed) lines.push(line([], W));
|
|
78
89
|
const table = [tableHeader(c, TW)];
|