@sejuneoh/aitop 0.37.0 → 0.38.1
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 +59 -0
- package/bin/aitop.mjs +4 -1
- package/package.json +1 -1
- package/src/collect.mjs +2 -1
- package/src/config.mjs +13 -1
- package/src/doctor.mjs +66 -23
- package/src/i18n.mjs +20 -0
- package/src/json.mjs +3 -1
- 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 +620 -0
- package/src/sources/dirs.mjs +48 -2
- package/src/sources/projects.mjs +13 -5
- package/src/summary.mjs +1 -1
- package/src/trace.mjs +6 -4
- package/src/ui/chrome.mjs +2 -0
- package/src/ui/detail.mjs +4 -2
- package/src/ui/table.mjs +4 -2
- package/src/ui/theme.mjs +2 -0
package/src/sources/dirs.mjs
CHANGED
|
@@ -67,13 +67,29 @@ export const defaultCodexHomes = (env = process.env, home = homedir()) => envDir
|
|
|
67
67
|
let chosen = null;
|
|
68
68
|
|
|
69
69
|
// 설정까지 반영한 목록을 정한다. 소스 모듈이 처음 읽기 전에 불러야 한다.
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// agyApp: 설정 파일·환경 변수의 Antigravity 앱 폴더 설정 (false, 경로 배열, true). 정하지 않았으면 undefined (antigravity.mjs findAgyRoots).
|
|
71
|
+
// cowork: Claude Desktop 앱 폴더 설정 (#304, 같은 모양). 정하지 않았으면 undefined (cowork.mjs findCoworkRoots).
|
|
72
|
+
export function setDataDirs({ claude, codex, agyApp, cowork } = {}) {
|
|
73
|
+
chosen = { claude: uniqueDirs(claude ?? defaultClaudeDirs()), codex: uniqueDirs(codex ?? defaultCodexHomes()), agyApp, cowork };
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
const pick = () => (chosen ??= { claude: uniqueDirs(defaultClaudeDirs()), codex: uniqueDirs(defaultCodexHomes()) });
|
|
75
77
|
export const claudeDirs = () => pick().claude;
|
|
76
78
|
export const codexHomes = () => pick().codex;
|
|
79
|
+
export const agyAppSetting = () => chosen?.agyApp;
|
|
80
|
+
export const coworkSetting = () => chosen?.cowork;
|
|
81
|
+
|
|
82
|
+
// AITOP_AGY_APP_HOME 값 (#303): off·0·none·false 면 false(앱 폴더를 읽지 않음), 절대 경로(또는 ~)면 배열.
|
|
83
|
+
// 비었거나 없거나 잘못된 값(on·1·true·상대 경로 등)이면 undefined. 잘못된 값은 config.mjs 가 --doctor·--print-config 에 알린다.
|
|
84
|
+
const OFF = /^(?:0|off|none|false)$/i;
|
|
85
|
+
export const agyAppEnv = (v) => {
|
|
86
|
+
if (typeof v !== 'string' || !v.trim()) return undefined;
|
|
87
|
+
if (OFF.test(v.trim())) return false;
|
|
88
|
+
const list = splitPaths(v);
|
|
89
|
+
return list && list.every(pathLike) ? list : undefined;
|
|
90
|
+
};
|
|
91
|
+
// AITOP_COWORK_HOME 값 (#304). 규칙은 AITOP_AGY_APP_HOME 과 같다: off 면 false, 절대 경로 목록이면 배열, 그 밖은 undefined.
|
|
92
|
+
export const coworkEnv = agyAppEnv;
|
|
77
93
|
export const claudeProjectRoots = () => claudeDirs().map((d) => join(d, 'projects'));
|
|
78
94
|
export const codexSessionRoots = () => codexHomes().map((h) => join(h, 'sessions'));
|
|
79
95
|
|
|
@@ -138,3 +154,33 @@ export function candidateDirs({ home = homedir(), claude = claudeDirs(), codex =
|
|
|
138
154
|
codex: look([...inherited('codex'), join(home, '.codex'), ...near(/^\.codex[-_.]./)], codex, 'sessions'),
|
|
139
155
|
};
|
|
140
156
|
}
|
|
157
|
+
|
|
158
|
+
// Windows 드라이브 경로(C:\…, C:/…, /c:/…)를 WSL 의 /mnt/c/… 로 바꾼다 (#303, #313). 드라이브 경로가 아니면 null.
|
|
159
|
+
export function wslPathOf(p) {
|
|
160
|
+
const m = /^\/?([A-Za-z]):(?:[\\/](.*))?$/.exec(typeof p === 'string' ? p : '');
|
|
161
|
+
return m ? ['/mnt', m[1].toLowerCase(), ...(m[2] ?? '').split(/[\\/]+/).filter(Boolean)].join('/') : null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// WSL 에서 Windows 사용자 홈 폴더 후보 (#303). Windows 앱의 기록은 /mnt/c/Users/<사용자> 아래에 있다.
|
|
165
|
+
// USERPROFILE 이 WSLENV 로 넘어와 있으면(C:\Users\me) 그 폴더만, 없으면 usersDir 아래 사용자 폴더 전부.
|
|
166
|
+
// 공용·기본 프로필 폴더는 건너뛴다. 폴더 이름과 존재만 보고 안은 읽지 않는다.
|
|
167
|
+
const WIN_SKIP = new Set(['all users', 'default', 'default user', 'public', 'defaultapppool', 'wdagutilityaccount']);
|
|
168
|
+
export function wslWindowsHomes({ env = process.env, usersDir = '/mnt/c/Users', has = isDir } = {}) {
|
|
169
|
+
const prof = /^([A-Za-z]):[\\/](.+)$/.exec(String(env.USERPROFILE ?? ''));
|
|
170
|
+
// USERPROFILE 의 폴더가 없으면(다른 드라이브 마운트 등) 사용자 폴더 훑기로 넘어간다.
|
|
171
|
+
if (prof) {
|
|
172
|
+
const p = join('/mnt', prof[1].toLowerCase(), ...prof[2].split(/[\\/]+/).filter(Boolean));
|
|
173
|
+
if (has(p)) return [p];
|
|
174
|
+
}
|
|
175
|
+
let names = [];
|
|
176
|
+
try {
|
|
177
|
+
names = readdirSync(usersDir);
|
|
178
|
+
} catch {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
return names
|
|
182
|
+
.filter((n) => !WIN_SKIP.has(n.toLowerCase()) && !n.startsWith('.') && !/\.ini$/i.test(n))
|
|
183
|
+
.sort()
|
|
184
|
+
.map((n) => join(usersDir, n))
|
|
185
|
+
.filter((p) => has(p));
|
|
186
|
+
}
|
package/src/sources/projects.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// 기간 리포트 --by project 용: 기록 파일 하나가 어느 프로젝트(작업 폴더)의 것인지 찾는다.
|
|
2
|
-
// Claude 는 기록 앞부분 줄의 cwd (없으면 projects/ 아래 폴더
|
|
2
|
+
// Claude 는 기록 앞부분 줄의 cwd (없으면 projects/ 아래 폴더 이름, Cowork 기록은 cowork 또는 고른 폴더), Codex 는 turn_context.cwd (없으면 session_meta.cwd),
|
|
3
3
|
// agy 는 conversation_summaries.db 의 workspace_uris (서브에이전트는 부모 대화의 것) 를 쓴다. 못 찾으면 null.
|
|
4
4
|
// agy 기록은 immutable 로 열어 -wal 에만 있는 막 생긴 대화는 아직 안 보이므로, 그 대화는 (unknown) 으로 나올 수 있다.
|
|
5
5
|
// 장부 캐시 모양은 그대로 두고, 리포트를 낼 때만 파일 앞부분을 조금 읽는다.
|
|
6
6
|
import { openSync, readSync, closeSync, statSync } from 'node:fs';
|
|
7
7
|
import { basename, isAbsolute, join, relative, sep } from 'node:path';
|
|
8
|
-
import {
|
|
8
|
+
import { agyRoots, cwdOf } from './antigravity.mjs';
|
|
9
9
|
import { openReadOnly } from '../sqlite.mjs';
|
|
10
10
|
import { debugIo } from '../log.mjs';
|
|
11
11
|
import { claudeProjectRoots } from './dirs.mjs';
|
|
12
|
+
import { coworkProjectOf } from './cowork.mjs';
|
|
12
13
|
|
|
13
14
|
// 앞부분에서 cwd 를 찾을 때 읽는 최대 크기. Codex 의 첫 줄(session_meta)은 지침 글이 들어 있어 길 수 있다.
|
|
14
15
|
const HEAD_BYTES = 256 * 1024;
|
|
@@ -102,13 +103,19 @@ export function codexProject(path) {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// 대화 id → 작업 폴더. 서브에이전트는 작업 폴더가 비어 있으면 부모를 따라 올라간다. 리포트 한 번에 한 번만 읽는다.
|
|
105
|
-
export function agyWorkspaces(root =
|
|
106
|
+
export function agyWorkspaces(root = agyRoots().map((r) => r.dir)) {
|
|
106
107
|
return new Map([...agyConversations(root)].map(([id, c]) => [id, c.cwd]));
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
// 대화 id → { cwd, title, root }. root: 부모를 끝까지 따라간 맨 위 대화 id (서브에이전트를 그 세션에 묶을 때 쓴다).
|
|
110
111
|
// title 은 agy 가 붙인 대화 제목 (세션 리포트의 '그 밖 이름').
|
|
111
|
-
|
|
112
|
+
// root: 기록 폴더 하나 또는 목록 (CLI 폴더와 앱 폴더, #303). 같은 대화 id 가 여러 폴더에 있으면 앞 폴더 것을 쓴다.
|
|
113
|
+
export function agyConversations(root = agyRoots().map((r) => r.dir)) {
|
|
114
|
+
if (Array.isArray(root)) {
|
|
115
|
+
const all = new Map();
|
|
116
|
+
for (const dir of root) for (const [id, c] of agyConversations(dir)) if (!all.has(id)) all.set(id, c);
|
|
117
|
+
return all;
|
|
118
|
+
}
|
|
112
119
|
const out = new Map();
|
|
113
120
|
let db;
|
|
114
121
|
try {
|
|
@@ -154,7 +161,8 @@ export function attachProjects(books, root) {
|
|
|
154
161
|
let fallback = null;
|
|
155
162
|
if (b.path) {
|
|
156
163
|
if (b.tool === 'claude') {
|
|
157
|
-
|
|
164
|
+
// Claude Desktop Cowork 기록은 기록 안의 cwd(VM·outputs 폴더) 대신 cowork 또는 사용자가 고른 폴더로 묶는다 (#313).
|
|
165
|
+
project = coworkProjectOf(b.path) ?? claudeProject(b.path);
|
|
158
166
|
if (!project) fallback = claudeFolder(b.path, root);
|
|
159
167
|
} else if (b.tool === 'codex') project = codexProject(b.path);
|
|
160
168
|
else if (b.tool === 'agy') project = (agy ??= agyWorkspaces()).get(basename(b.path, '.db')) ?? null;
|
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
|
@@ -50,6 +50,8 @@ const LEGEND_IDS = [
|
|
|
50
50
|
['legend.stalledKey', 'legend.stalled'],
|
|
51
51
|
['member.sdk', 'legend.sdk'],
|
|
52
52
|
['session.auto', 'legend.auto'],
|
|
53
|
+
// TOOL 칸의 cowork (#304).
|
|
54
|
+
['cowork', 'legend.cowork'],
|
|
53
55
|
];
|
|
54
56
|
|
|
55
57
|
// 지금 언어의 상태 기호·열 설명. 제목 줄은 설명이 null 이다. {g} 는 팀원 경과 시간 표시(glyphs().elapsed)로 바꾼다.
|
package/src/ui/detail.mjs
CHANGED
|
@@ -319,7 +319,8 @@ export function summaryLines(s, w, frame, view) {
|
|
|
319
319
|
const cache = cacheState(s);
|
|
320
320
|
const optional = [
|
|
321
321
|
s.branch && [sep, { t: s.branch, fg: PALETTE.info }],
|
|
322
|
-
|
|
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 }],
|
|
323
324
|
s.startedAt && [sep, { t: tr('detail.startedAgo', { at: hhmm(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }), fg: PALETTE.info }],
|
|
324
325
|
// 캐시 남은 시간은 표의 STATUS 칸과 같은 짧은 글로, 가장 먼저 뺀다.
|
|
325
326
|
cache && [sep, { t: cache.text, fg: cache.fg, bold: cache.bold }],
|
|
@@ -487,7 +488,8 @@ export function detail(s, W, H, frame, view) {
|
|
|
487
488
|
kv(tr('detail.folder'), tilde(s.cwd));
|
|
488
489
|
if (s.branch) kv(tr('detail.branch'), s.branch);
|
|
489
490
|
kv(tr('detail.model'), s.model ?? '-');
|
|
490
|
-
|
|
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}` : ''}`);
|
|
491
493
|
if (s.startedAt) kv(tr('detail.started'), tr('detail.ago', { at: clock(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }));
|
|
492
494
|
|
|
493
495
|
// 합계 = 메인 + 서브 = 입력 + 출력 + 캐시 읽기 + 캐시 쓰기 가 화면에서 그대로 맞아떨어지게 보인다.
|
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) {
|
|
@@ -250,7 +250,9 @@ export function toolLastUsed(data, tool, now) {
|
|
|
250
250
|
// 아주 좁으면 실행 중인 도구가 숨김 표시보다 먼저 남고, 숨김 표시는 중간에서 자르지 않고 뺀다.
|
|
251
251
|
export function toolStrip(view, W) {
|
|
252
252
|
const now = view.data.at ?? Date.now();
|
|
253
|
-
|
|
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) => {
|
|
254
256
|
const list = view.data.sessions.filter((s) => s.tool === tool);
|
|
255
257
|
const live = list.filter((s) => s.live).length;
|
|
256
258
|
const last = toolLastUsed(view.data, tool, 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(';');
|