@sejuneoh/aitop 0.38.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 +3 -1
- package/package.json +1 -1
- package/src/sources/antigravity.mjs +2 -2
- package/src/sources/cowork.mjs +69 -11
- package/src/sources/dirs.mjs +6 -0
- package/src/sources/projects.mjs +4 -2
package/README.md
CHANGED
|
@@ -473,6 +473,7 @@ Claude Desktop agent mode (Cowork) sessions show in the table as `cowork` in the
|
|
|
473
473
|
- The name is the app's session title. Tokens, cost, progress and subagents come from the same jsonl log Claude Code writes. The detail panel and `--json` `entrypoint` show `local-agent`.
|
|
474
474
|
- Header today and 7-day totals, the monthly archive and `--report` (daily, sessions, trace) add them to Claude. A log that is also in `~/.claude/projects` is counted once.
|
|
475
475
|
- A pending permission request shows as waiting (◆) and counts for `--notify`, `--on-waiting`, `n`, the header, the window title and `--line`.
|
|
476
|
+
- The PROJECT column and `--report ... --by project` group them as `cowork`, or under the folder picked for the session (the column shows its last name). On WSL a Windows working folder (`C:\…`) shows as `/mnt/c/…`.
|
|
476
477
|
|
|
477
478
|
<details>
|
|
478
479
|
<summary>Details: running and waiting, files read</summary>
|
|
@@ -480,7 +481,8 @@ Claude Desktop agent mode (Cowork) sessions show in the table as `cowork` in the
|
|
|
480
481
|
- Cowork runs in a VM the app starts, so its process is not visible. A session is running when the later of its `lastActivityAt` and its log's modified time is within 2 minutes. Archived sessions (`isArchived`) are ended.
|
|
481
482
|
- Waiting: if no answer (`permission_response`, `permission_denied`, `permission_auto_approved`), turn end (`result`) or restart (`init`) line follows the last `permission_request` at the end of the session's `audit.jsonl`, the session waits for that `tool_name`. There is no id linking requests and answers, so only the order counts, and a session whose log has no open tool call is not waiting.
|
|
482
483
|
- Waiting lasts regardless of the 2-minute rule for up to 1 hour after the request. Older requests count as abandoned and the session as ended.
|
|
483
|
-
-
|
|
484
|
+
- The session's log folder is `local_<id>/`, else the folder named after the first 8 characters of the id (scheduled tasks, meta `hostLoopMode`), else the parent folder name of the meta's working folder, at the same level. Only real folders (not symlinks) are used.
|
|
485
|
+
- Only three kinds of files are opened: the session meta `local_<id>.json` (only title, model, folder, picked folder, times, archived flag and log id are used), logs under `.claude/projects/**/*.jsonl`, and `audit.jsonl`. `.audit-key`, `.claude.json`, `policy-limits.json`, `outputs/`, `uploads/` and the like in the log folder are not opened either. Cookies, Local Storage, settings and subagent meta files in the same app folder are not opened.
|
|
484
486
|
- From `audit.jsonl` only the kind, tool name and time of permission lines are taken. Request contents (`tool_input`), signatures (`_audit_hmac`) and messages never reach the screen, the cache or `--json`. Cost comes from log usage, not `total_cost_usd`.
|
|
485
487
|
- To keep a slow `/mnt/c` cheap, the session list, meta, log list and `audit.jsonl` are checked at most every 10 seconds, so waiting can show up to 10 seconds late. The 2-minute running check still uses the current time.
|
|
486
488
|
- Sessions idle for over 7 days are known from their meta only; their log folders are not listed.
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import { addActivity, emptyTokens, mergeActivity, pushEvent, describeTool, toolD
|
|
|
13
13
|
import { contextWindow, geminiCost } from '../pricing.mjs';
|
|
14
14
|
import { debug, debugIo } from '../log.mjs';
|
|
15
15
|
import { isWsl } from '../notify.mjs';
|
|
16
|
-
import { agyAppEnv, agyAppSetting, expandHome, wslWindowsHomes } from './dirs.mjs';
|
|
16
|
+
import { agyAppEnv, agyAppSetting, expandHome, wslPathOf, wslWindowsHomes } from './dirs.mjs';
|
|
17
17
|
|
|
18
18
|
const isDir = (p) => {
|
|
19
19
|
try {
|
|
@@ -586,7 +586,7 @@ export function cwdOf(workspaceUris, { wsl = null } = {}) {
|
|
|
586
586
|
// Windows 의 file:///c%3A/… 는 c:\… 가 되므로 드라이브 문자를 대문자로 맞춘다 (Claude·Codex 의 C:\ 와 같은 프로젝트로 묶이게).
|
|
587
587
|
if (process.platform === 'win32') return p.replace(/^[a-z](?=:)/, (d) => d.toUpperCase());
|
|
588
588
|
const drive = /^\/?([A-Za-z]):(?:[\\/](.*))?$/.exec(p);
|
|
589
|
-
if (drive && (wsl ?? wslNow())) return
|
|
589
|
+
if (drive && (wsl ?? wslNow())) return wslPathOf(p);
|
|
590
590
|
return p;
|
|
591
591
|
} catch (e) {
|
|
592
592
|
debug('agy', 'workspace_uris parse failed', e);
|
package/src/sources/cowork.mjs
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
// <앱>/local-agent-mode-sessions/<uuid>/<uuid>/local_<id>.json 세션 메타 (제목, 모델, 마지막 활동 시각 등)
|
|
4
4
|
// <앱>/local-agent-mode-sessions/<uuid>/<uuid>/local_<id>/.claude/projects/*/*.jsonl Claude Code 와 같은 대화 기록 (+ <id>/subagents/)
|
|
5
5
|
// <앱>/local-agent-mode-sessions/<uuid>/<uuid>/local_<id>/audit.jsonl 권한 요청·응답이 든 감사 기록
|
|
6
|
+
// 예약 작업(메타 hostLoopMode: true, #313)은 기록 폴더가 local_<id>/ 가 아니라 id 앞 8자리 폴더(<uuid>/<uuid>/2c7ea83c/)이고
|
|
7
|
+
// 대화 기록은 그 아래 .claude/projects/session/<cliSessionId>.jsonl 이다. 메타 cwd 는 Windows 경로(C:\…\2c7ea83c\outputs)다.
|
|
6
8
|
// 앱 폴더에는 쿠키·Local Storage·설정 같은 다른 파일도 있으므로 위 세 가지만 연다 (허용 목록). 폴더는 목록만 읽는다.
|
|
7
9
|
// 프로세스가 VM 안이라 보이지 않으므로 실행 중은 메타의 lastActivityAt 과 기록 수정 시각 중 늦은 쪽이 2분 안이면으로 본다.
|
|
8
10
|
// 세션은 TOOL 칸에 cowork 로 보이고(색은 claude), 기록 파서는 Claude 것(claude-tracker.mjs)을 그대로 쓴다.
|
|
9
|
-
import { readdirSync, readFileSync, statSync, openSync, readSync, closeSync, realpathSync } from 'node:fs';
|
|
10
|
-
import { join, basename, resolve } from 'node:path';
|
|
11
|
+
import { readdirSync, readFileSync, statSync, lstatSync, openSync, readSync, closeSync, realpathSync } from 'node:fs';
|
|
12
|
+
import { join, basename, resolve, sep } from 'node:path';
|
|
11
13
|
import { homedir } from 'node:os';
|
|
12
14
|
import { ClaudeTracker } from './claude-tracker.mjs';
|
|
13
15
|
import { sessionName } from './common.mjs';
|
|
14
16
|
import { emptySub, sessionTotals, readMembers, withRunningMembers, phaseOf, stoppedPhase, cacheOf, toolStartOf } from './claude.mjs';
|
|
15
|
-
import { coworkEnv, coworkSetting, expandHome, wslWindowsHomes } from './dirs.mjs';
|
|
17
|
+
import { coworkEnv, coworkSetting, expandHome, wslPathOf, wslWindowsHomes } from './dirs.mjs';
|
|
16
18
|
import { loadCache } from '../cache.mjs';
|
|
17
19
|
import { isWsl } from '../notify.mjs';
|
|
18
20
|
import { debugIo } from '../log.mjs';
|
|
@@ -118,6 +120,8 @@ export function pickMeta(m) {
|
|
|
118
120
|
title: str(m.title),
|
|
119
121
|
model: str(m.model),
|
|
120
122
|
cwd: str(m.cwd),
|
|
123
|
+
// 사용자가 고른 폴더 중 첫 번째 (PROJECT 칸에 쓴다, #313).
|
|
124
|
+
folder: Array.isArray(m.userSelectedFolders) ? (m.userSelectedFolders.map(str).find(Boolean) ?? null) : null,
|
|
121
125
|
createdAt: num(m.createdAt),
|
|
122
126
|
lastActivityAt: num(m.lastActivityAt),
|
|
123
127
|
isArchived: m.isArchived === true,
|
|
@@ -160,6 +164,45 @@ function readMeta(path) {
|
|
|
160
164
|
return out;
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
// 세션의 기록 폴더 (#313). 후보 순서: local_<id>/ → id 앞 8자리 폴더(예약 작업) → 메타 cwd 의 상위 폴더 이름
|
|
168
|
+
// (cwd 가 local-agent-mode-sessions 아래일 때만). 메타와 같은 층의 폴더 목록(entries)에 있고 실제 폴더(심볼릭 링크 아님)인 것만 쓴다.
|
|
169
|
+
// 하나도 없으면 local_<id>/ (없는 폴더라 기록 목록이 비고, 예전과 같다).
|
|
170
|
+
const NAME_RE = /^[\w.-]{1,128}$/;
|
|
171
|
+
function sessionDir(dir2, localId, meta, entries) {
|
|
172
|
+
const segs = String(meta.cwd ?? '').split(/[\\/]+/).filter(Boolean);
|
|
173
|
+
const cands = [localId, localId.slice(6, 14)];
|
|
174
|
+
if (segs.length >= 2 && segs.includes(SESSIONS_DIR)) cands.push(segs.at(-2));
|
|
175
|
+
for (const name of cands) {
|
|
176
|
+
if (!NAME_RE.test(name) || name === '.' || name === '..') continue;
|
|
177
|
+
const e = entries.get(name);
|
|
178
|
+
if (!e) continue;
|
|
179
|
+
const p = join(dir2, name);
|
|
180
|
+
let ok = e.isDirectory();
|
|
181
|
+
if (!ok && !e.isFile() && !e.isSymbolicLink()) {
|
|
182
|
+
try {
|
|
183
|
+
ok = lstatSync(p).isDirectory();
|
|
184
|
+
} catch {}
|
|
185
|
+
}
|
|
186
|
+
if (ok) return p;
|
|
187
|
+
}
|
|
188
|
+
return join(dir2, localId);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 작업 폴더 경로를 이 컴퓨터에서 보이는 모양으로. WSL 에서 Windows 경로(C:\…)는 /mnt/c/… 로 바꾼다 (#313).
|
|
192
|
+
let wslForce = null;
|
|
193
|
+
let onWsl = null;
|
|
194
|
+
const wslNow = () => wslForce ?? (onWsl ??= process.platform === 'linux' && isWsl());
|
|
195
|
+
const hostPath = (p) => (p && wslNow() ? (wslPathOf(p) ?? p) : p);
|
|
196
|
+
const lastName = (p) => String(p ?? '').split(/[\\/]+/).filter(Boolean).at(-1) ?? null;
|
|
197
|
+
|
|
198
|
+
// PROJECT 칸: 사용자가 고른 폴더가 있으면 그 마지막 이름, 없으면 cowork (#313).
|
|
199
|
+
// path: --by project 장부에 쓰는 값 (고른 폴더의 경로, 없으면 'cowork').
|
|
200
|
+
export function coworkProject(meta) {
|
|
201
|
+
const folder = hostPath(meta?.folder ?? null);
|
|
202
|
+
const name = folder ? lastName(folder) : null;
|
|
203
|
+
return name ? { name, path: folder } : { name: 'cowork', path: 'cowork' };
|
|
204
|
+
}
|
|
205
|
+
|
|
163
206
|
// 세션 폴더의 대화 기록 목록: .claude/projects/<폴더>/*.jsonl 과 <id>/subagents/*.jsonl.
|
|
164
207
|
// key 는 projects/ 아래 상대 경로 (claude-ledger.mjs 와 같은 모양이라 ~/.claude/projects 에 같은 기록이 있으면 한 번만 센다).
|
|
165
208
|
function listTranscripts(dir) {
|
|
@@ -334,21 +377,23 @@ function scanRoot(root, days, now) {
|
|
|
334
377
|
for (const b of ls(join(base, a.name), 'sessions read failed')) {
|
|
335
378
|
if (!dirEnt(b, join(base, a.name, b.name))) continue;
|
|
336
379
|
const dir2 = join(base, a.name, b.name);
|
|
337
|
-
|
|
380
|
+
const ents = ls(dir2, 'sessions read failed');
|
|
381
|
+
const byName = new Map(ents.map((e) => [e.name, e]));
|
|
382
|
+
for (const f of ents) {
|
|
338
383
|
const m = /^(local_[\w-]+)\.json$/.exec(f.name);
|
|
339
384
|
if (!m || !fileEnt(f)) continue;
|
|
340
385
|
const metaPath = join(dir2, f.name);
|
|
341
386
|
const got = readMeta(metaPath);
|
|
342
387
|
if (!got?.meta) continue;
|
|
343
388
|
const meta = got.meta;
|
|
344
|
-
const dir =
|
|
389
|
+
const dir = sessionDir(dir2, m[1], meta, byName);
|
|
345
390
|
const touched = Math.max(meta.lastActivityAt ?? 0, got.mtime);
|
|
346
391
|
const recent = now - touched < days * 86400_000;
|
|
347
392
|
const list = recent ? transcriptsOf(dir, meta, got.mtime) : { files: [], main: null };
|
|
348
393
|
const newest = Math.max(0, ...list.files.map((x) => x.mtime));
|
|
349
394
|
const activity = Math.max(meta.lastActivityAt ?? 0, newest);
|
|
350
395
|
const maybe = !meta.isArchived && now - activity <= COWORK_WAIT_MAX_MS + COWORK_TTL_MS;
|
|
351
|
-
out.push({ localId: m[1], root, dir, meta, metaMtime: got.mtime, files: list.files, main: list.main, wait: maybe ? readAudit(join(dir, 'audit.jsonl')) : null, audited: maybe });
|
|
396
|
+
out.push({ localId: m[1], root, dir, metaPath, meta, metaMtime: got.mtime, files: list.files, main: list.main, wait: maybe ? readAudit(join(dir, 'audit.jsonl')) : null, audited: maybe });
|
|
352
397
|
}
|
|
353
398
|
}
|
|
354
399
|
}
|
|
@@ -368,8 +413,8 @@ export function coworkSnapshot({ roots = coworkRoots(), days = DAYS, now = Date.
|
|
|
368
413
|
// 이번 목록에 없는 세션(지워진 세션, 이제 읽지 않는 앱 폴더)의 캐시는 지운다. 기간이 다른 목록(리포트)은 세션이 같으므로 7일 목록 때만 한다.
|
|
369
414
|
if (days === DAYS) {
|
|
370
415
|
const dirs = new Set(snap.sessions.map((s) => s.dir));
|
|
371
|
-
const
|
|
372
|
-
for (const p of metas.keys()) if (!
|
|
416
|
+
const metaPaths = new Set(snap.sessions.map((s) => s.metaPath));
|
|
417
|
+
for (const p of metas.keys()) if (!metaPaths.has(p)) metas.delete(p);
|
|
373
418
|
for (const d of listings.keys()) if (!dirs.has(d)) listings.delete(d);
|
|
374
419
|
// audit 는 이번에 보지 않은 것(대기 기간이 지났거나 보관한 세션)도 지운다.
|
|
375
420
|
const audited = new Set(snap.sessions.filter((s) => s.audited).map((s) => join(s.dir, 'audit.jsonl')));
|
|
@@ -384,6 +429,14 @@ export function coworkLedgerFiles(days = DAYS, now = Date.now()) {
|
|
|
384
429
|
return coworkSnapshot({ days: Math.max(DAYS, days), now }).sessions.flatMap((s) => s.files.filter((f) => f.mtime >= cutoff).map(({ key, path, mtime }) => ({ key, path, mtime })));
|
|
385
430
|
}
|
|
386
431
|
|
|
432
|
+
// --by project 용: Cowork 기록 파일이면 그 세션의 프로젝트(coworkProject 의 path), 아니면 null (#313).
|
|
433
|
+
// 앱 폴더의 세션 목록 밖이어도 앱 폴더의 local-agent-mode-sessions 아래면 cowork 로 둔다.
|
|
434
|
+
export function coworkProjectOf(path, roots = coworkRoots()) {
|
|
435
|
+
if (!path || !roots.some((r) => path.startsWith(join(r, SESSIONS_DIR) + sep))) return null;
|
|
436
|
+
const s = coworkSnapshot({ roots }).sessions.find((x) => path.startsWith(x.dir + sep));
|
|
437
|
+
return coworkProject(s?.meta).path;
|
|
438
|
+
}
|
|
439
|
+
|
|
387
440
|
// --report trace 가 세션 id 로 기록을 찾을 때 쓰는 projects/ 폴더 목록.
|
|
388
441
|
export function coworkProjectRoots() {
|
|
389
442
|
return coworkSnapshot().sessions.map((s) => join(s.dir, '.claude', 'projects'));
|
|
@@ -458,7 +511,8 @@ function row(s, { budget, now, want, timeLive }) {
|
|
|
458
511
|
const waitingFor = wait ? `approve ${wait.tool}` : null;
|
|
459
512
|
const status = statusOf(live, wait, t, mtime, now);
|
|
460
513
|
const phase = withRunningMembers(phaseOf(status, { waitingFor }, t), status, members);
|
|
461
|
-
const
|
|
514
|
+
const project = coworkProject(m).name;
|
|
515
|
+
const name = sessionName(m.title ?? '') ?? t?.customTitle ?? t?.title ?? `${project} · ${s.localId.slice(6, 14)}`;
|
|
462
516
|
return {
|
|
463
517
|
tool: 'cowork',
|
|
464
518
|
id: m.cliSessionId ?? m.sessionId ?? s.localId,
|
|
@@ -466,8 +520,8 @@ function row(s, { budget, now, want, timeLive }) {
|
|
|
466
520
|
kind: 'interactive',
|
|
467
521
|
name,
|
|
468
522
|
customName: null,
|
|
469
|
-
cwd: m.cwd,
|
|
470
|
-
project
|
|
523
|
+
cwd: hostPath(m.cwd),
|
|
524
|
+
project,
|
|
471
525
|
branch: t?.branch ?? null,
|
|
472
526
|
model: t?.model ?? m.model,
|
|
473
527
|
// Cowork 기록의 실행 방식 ('local-agent').
|
|
@@ -548,6 +602,10 @@ export const _test = {
|
|
|
548
602
|
keys() {
|
|
549
603
|
return { metas: [...metas.keys()], listings: [...listings.keys()], audits: [...audits.keys()] };
|
|
550
604
|
},
|
|
605
|
+
// WSL 인지 정해 둔다 (null 이면 저절로).
|
|
606
|
+
wsl(v) {
|
|
607
|
+
wslForce = v;
|
|
608
|
+
},
|
|
551
609
|
reset() {
|
|
552
610
|
snaps.clear();
|
|
553
611
|
metas.clear();
|
package/src/sources/dirs.mjs
CHANGED
|
@@ -155,6 +155,12 @@ export function candidateDirs({ home = homedir(), claude = claudeDirs(), codex =
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
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
|
+
|
|
158
164
|
// WSL 에서 Windows 사용자 홈 폴더 후보 (#303). Windows 앱의 기록은 /mnt/c/Users/<사용자> 아래에 있다.
|
|
159
165
|
// USERPROFILE 이 WSLENV 로 넘어와 있으면(C:\Users\me) 그 폴더만, 없으면 usersDir 아래 사용자 폴더 전부.
|
|
160
166
|
// 공용·기본 프로필 폴더는 건너뛴다. 폴더 이름과 존재만 보고 안은 읽지 않는다.
|
package/src/sources/projects.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
// 장부 캐시 모양은 그대로 두고, 리포트를 낼 때만 파일 앞부분을 조금 읽는다.
|
|
@@ -9,6 +9,7 @@ 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;
|
|
@@ -160,7 +161,8 @@ export function attachProjects(books, root) {
|
|
|
160
161
|
let fallback = null;
|
|
161
162
|
if (b.path) {
|
|
162
163
|
if (b.tool === 'claude') {
|
|
163
|
-
|
|
164
|
+
// Claude Desktop Cowork 기록은 기록 안의 cwd(VM·outputs 폴더) 대신 cowork 또는 사용자가 고른 폴더로 묶는다 (#313).
|
|
165
|
+
project = coworkProjectOf(b.path) ?? claudeProject(b.path);
|
|
164
166
|
if (!project) fallback = claudeFolder(b.path, root);
|
|
165
167
|
} else if (b.tool === 'codex') project = codexProject(b.path);
|
|
166
168
|
else if (b.tool === 'agy') project = (agy ??= agyWorkspaces()).get(basename(b.path, '.db')) ?? null;
|