@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 CHANGED
@@ -431,6 +431,65 @@ aitop reads `~/.claude` and `~/.codex` by default. List more profiles to read th
431
431
 
432
432
  </details>
433
433
 
434
+ ## Antigravity desktop app
435
+
436
+ Conversations from the Antigravity desktop app show in the Gemini tab next to agy CLI ones. aitop reads the app folder when it exists.
437
+
438
+ > `aitop --doctor`
439
+ >
440
+ > `AITOP_AGY_APP_HOME=off aitop`
441
+
442
+ - Folder: `~/.gemini/antigravity`. On WSL, also `.gemini/antigravity` in your Windows home.
443
+ - The Windows home is `USERPROFILE` when it is passed in, otherwise each user folder in `/mnt/c/Users` except shared ones (Public, Default, ...).
444
+ - Only folders with `conversations/` are read. `aitop --doctor` shows them as `+ … Antigravity app` under agy.
445
+ - Turn it off with `"agyApp": false` in the config file or `AITOP_AGY_APP_HOME=off`. Give absolute paths (joined by `:` on Linux and macOS, `;` on Windows) to read only those. Other values (`on`, `1`, relative paths) are ignored with a warning in `--doctor` and `--print-config`.
446
+ - The detail panel shows `interactive · app` and `--json` has `source: "app"` (`"cli"` for agy CLI). No new table column.
447
+ - The 7-day usage and monthly reports add both.
448
+
449
+ <details>
450
+ <summary>Details: running state, files read</summary>
451
+
452
+ - The app process is not visible from WSL, so an app conversation counts as running when its log (`conversations/<id>.db-wal`) or the conversation list changed in the last 2 minutes.
453
+ - So an app conversation quiet for over 2 minutes shows as ended, and a closed app stays running for up to 2 minutes.
454
+ - App conversations cannot be resumed with the agy CLI, so no resume command is made.
455
+ - The app folder also holds sign-in tokens and other files. aitop opens only `conversations/` and `conversation_summaries.db`, read-only (immutable).
456
+ - With `AITOP_AGY_HOME` set, the app folder is read only if `AITOP_AGY_APP_HOME` is set too (keeps tests away from real logs). `--print-config` then shows `agyApp false env (AITOP_AGY_HOME)`.
457
+ - To keep a slow `/mnt/c` cheap, the app folder's file list and log signatures are checked at most every 10 seconds. The 2-minute running check still uses the current time.
458
+ - If the same conversation id is in both folders, the agy CLI one wins.
459
+
460
+ </details>
461
+
462
+ ## Claude Desktop Cowork
463
+
464
+ Claude Desktop agent mode (Cowork) sessions show in the table as `cowork` in the TOOL column (Claude color), counted apart from claude in the tool row. aitop reads the app folder when it exists.
465
+
466
+ > `aitop --doctor`
467
+ >
468
+ > `AITOP_COWORK_HOME=off aitop`
469
+
470
+ - Folders: macOS `~/Library/Application Support/Claude`, Windows `%LOCALAPPDATA%\Packages\Claude_*\LocalCache\Roaming\Claude` (Store install) and `%APPDATA%\Claude`. On WSL, `AppData/Local/Packages/Claude_*/LocalCache/Roaming/Claude` and `AppData/Roaming/Claude` in your Windows home (same rule as the Antigravity app).
471
+ - Only folders with `local-agent-mode-sessions/` are read. `aitop --doctor` shows a `cowork` line (`Claude app · N sessions`), or no line when there is no app folder.
472
+ - Turn it off with `"cowork": false` in the config file or `AITOP_COWORK_HOME=off`. Give absolute app folder paths (joined by `:` on Linux and macOS, `;` on Windows) to read only those. Other values are ignored with a warning in `--doctor` and `--print-config`.
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
+ - 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
+ - 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/…`.
477
+
478
+ <details>
479
+ <summary>Details: running and waiting, files read</summary>
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.
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.
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.
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.
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`.
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.
488
+ - Sessions idle for over 7 days are known from their meta only; their log folders are not listed.
489
+ - No resume command is made. The format is private and may change with app updates; unreadable parts are skipped quietly.
490
+
491
+ </details>
492
+
434
493
  ## Resume a session elsewhere
435
494
 
436
495
  Continue a session elsewhere, for example when you cannot jump to its tab, as in Windows Terminal with WSL. The detail panel shows a `Resume` command and `y` copies it. The panel wraps it at spaces, `/` and `\`, keeps the resume part (`claude --resume <id>`) on the last line(s), and keeps the session id on one line when the width allows. A long `cd` part is shortened in the middle with `…`; `y` still copies the whole command.
package/bin/aitop.mjs CHANGED
@@ -88,7 +88,10 @@ if (config.values.icons.source === 'file') process.env.AITOP_ICONS = opt.icons;
88
88
  setAmbiguous(opt.ambiguous);
89
89
  // 읽을 Claude·Codex 기록 폴더 목록. 기록을 읽는 모듈을 불러오기 전에 정한다 (#212).
90
90
  const { setDataDirs } = await import('../src/sources/dirs.mjs');
91
- setDataDirs({ claude: opt.claudeDirs, codex: opt.codexHomes });
91
+ // agyApp 은 정하지 않았으면(기본값) 넘기지 않아 AITOP_AGY_HOME 격리 규칙(antigravity.mjs findAgyRoots)을 그대로 따른다.
92
+ // cowork(#304)도 같다: 기본값이면 넘기지 않고 findCoworkRoots 가 AITOP_COWORK_HOME 과 저절로 찾기를 따른다.
93
+ const chosen = (k) => (config.values[k].source === 'default' ? undefined : opt[k]);
94
+ setDataDirs({ claude: opt.claudeDirs, codex: opt.codexHomes, agyApp: chosen('agyApp'), cowork: chosen('cowork') });
92
95
  const { BRAND, userVarsSeq } = await import('../src/brand.mjs');
93
96
  const { keysText } = await import('../src/help.mjs');
94
97
  const { debug, initLog, logPath } = await import('../src/log.mjs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sejuneoh/aitop",
3
- "version": "0.37.0",
3
+ "version": "0.38.1",
4
4
  "description": "터미널에서 Claude Code · Codex · Antigravity · Gemini 세션과 토큰을 실시간으로 보는 읽기 전용 모니터",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/collect.mjs CHANGED
@@ -2,6 +2,7 @@ import { collectClaude } from './sources/claude.mjs';
2
2
  import { collectCodex } from './sources/codex.mjs';
3
3
  import { collectGemini } from './sources/gemini.mjs';
4
4
  import { collectAgy } from './sources/antigravity.mjs';
5
+ import { collectCowork } from './sources/cowork.mjs';
5
6
  import { collectLedger } from './sources/claude-ledger.mjs';
6
7
  import { createBudget } from './tail.mjs';
7
8
 
@@ -29,7 +30,7 @@ export function collect({ budgetBytes = Infinity, budgetMs = Infinity, ...opts }
29
30
  const budgetOf = (name, bytes, ms) => (budgets[name] = createBudget(bytes, ms));
30
31
  const sessions = [];
31
32
  const errors = [];
32
- for (const [tool, fn] of [['claude', collectClaude], ['codex', collectCodex], ['gemini', collectGemini], ['agy', collectAgy]]) {
33
+ for (const [tool, fn] of [['claude', collectClaude], ['cowork', collectCowork], ['codex', collectCodex], ['gemini', collectGemini], ['agy', collectAgy]]) {
33
34
  try {
34
35
  sessions.push(...fn({ ...opts, budget: budgetOf(tool, budgetBytes, budgetMs) }));
35
36
  } catch (err) {
package/src/config.mjs CHANGED
@@ -9,7 +9,7 @@ import { appDir } from './paths.mjs';
9
9
  import { stripControl } from './text.mjs';
10
10
  import { langValue, localeLang, t } from './i18n.mjs';
11
11
  import { EVENT_KINDS } from './notify.mjs';
12
- import { DIR_ENV, pathLike, splitPaths } from './sources/dirs.mjs';
12
+ import { DIR_ENV, agyAppEnv, coworkEnv, pathLike, splitPaths } from './sources/dirs.mjs';
13
13
 
14
14
  const bool = (v) => typeof v === 'boolean';
15
15
  const oneOf = (...xs) => (v) => xs.includes(v);
@@ -81,6 +81,13 @@ export const KEYS = {
81
81
  // AITOP_CLAUDE_DIRS > 설정 파일 > 물려받은 CLAUDE_CONFIG_DIR (inherit, Claude Code 용 변수라 설정 파일보다 낮다) > ~/.claude.
82
82
  claudeDirs: { ok: pathList, expect: 'cfg.paths', def: () => [join(homedir(), DIR_ENV.claude.home)], env: [DIR_ENV.claude.own, (v) => splitPaths(v)], inherit: [DIR_ENV.claude.inherited, (v) => splitPaths(v)] },
83
83
  codexHomes: { ok: pathList, expect: 'cfg.paths', def: () => [join(homedir(), DIR_ENV.codex.home)], env: [DIR_ENV.codex.own, (v) => splitPaths(v)], inherit: [DIR_ENV.codex.inherited, (v) => splitPaths(v)] },
84
+ // Antigravity 데스크톱 앱 폴더 (#303, antigravity.mjs findAgyRoots). true 면 저절로 찾고, false 면 읽지 않고, 경로 배열이면 그 폴더만.
85
+ // AITOP_AGY_APP_HOME(경로 또는 off) > 설정 파일 > 기본(true). AITOP_AGY_HOME 을 주고 AITOP_AGY_APP_HOME 을 주지 않으면 이 값과 상관없이 읽지 않는다.
86
+ // masked: 이 환경 변수가 있으면(그리고 자기 환경 변수가 없으면) 값을 false 로 두고 출처를 그 변수로 보인다. 설정 파일 값은 무시됨으로 알린다.
87
+ agyApp: { ok: (v) => bool(v) || pathList(v), expect: 'cfg.agyApp', def: true, env: ['AITOP_AGY_APP_HOME', agyAppEnv], envProblem: true, envExpect: 'cfg.agyAppEnv', masked: 'AITOP_AGY_HOME' },
88
+ // Claude Desktop Cowork(에이전트 모드) 세션을 담은 앱 폴더 (#304, cowork.mjs findCoworkRoots). 모양은 agyApp 과 같다.
89
+ // AITOP_COWORK_HOME(경로 또는 off) > 설정 파일 > 기본(true, 저절로 찾음).
90
+ cowork: { ok: (v) => bool(v) || pathList(v), expect: 'cfg.cowork', def: true, env: ['AITOP_COWORK_HOME', coworkEnv], envProblem: true, envExpect: 'cfg.agyAppEnv' },
84
91
  };
85
92
 
86
93
  // Windows 는 XDG_CONFIG_HOME 이 없으면 %APPDATA%\aitop\config.json.
@@ -196,6 +203,11 @@ export function resolveConfig({ flags = {}, env = process.env, file } = {}) {
196
203
  else if (spec.inherit && spec.inherit[1](env[spec.inherit[0]]) !== undefined) values[key] = { value: spec.inherit[1](env[spec.inherit[0]]), source: 'env', env: spec.inherit[0] };
197
204
  // 기본값이 함수면 환경에서 고른다 (lang 은 로캘).
198
205
  else values[key] = { value: typeof spec.def === 'function' ? spec.def(env) : spec.def, source: 'default' };
206
+ // 다른 환경 변수가 이 값을 덮는 경우 (agyApp 과 AITOP_AGY_HOME, antigravity.mjs findAgyRoots).
207
+ if (spec.masked && env[spec.masked] != null && (values[key].source === 'file' || values[key].source === 'default')) {
208
+ if (values[key].source === 'file') problems.push(t('cfg.masked', { key, name: spec.masked }));
209
+ values[key] = { value: false, source: 'env', env: spec.masked };
210
+ }
199
211
  }
200
212
  return { path: file.path, exists: file.exists, values, problems };
201
213
  }
package/src/doctor.mjs CHANGED
@@ -5,7 +5,8 @@ import { readdirSync, readFileSync, statSync, existsSync, openSync, readSync, cl
5
5
  import { basename, join } from 'node:path';
6
6
  import { homedir, platform } from 'node:os';
7
7
  import { findProcesses, isCodex, isGemini, isAgy, canListProcesses, isAlive, isSessionAlive, processMethod } from './procs.mjs';
8
- import { AGY_ROOT } from './sources/antigravity.mjs';
8
+ import { agyRoots } from './sources/antigravity.mjs';
9
+ import { coworkCheck } from './sources/cowork.mjs';
9
10
  import { loadSqlite, openReadOnly } from './sqlite.mjs';
10
11
  import { fmtAgo, pad, stripControl, width } from './text.mjs';
11
12
  import { BRAND } from './brand.mjs';
@@ -174,42 +175,70 @@ function gemini() {
174
175
  };
175
176
  }
176
177
 
177
- // Antigravity CLI: 요약 DB 를 열어 대화 목록을 읽을 수 있는지 본다. node:sqlite 가 없으면 프로세스만 센다.
178
- function agy() {
179
- const dir = join(AGY_ROOT, 'conversations');
178
+ // Antigravity CLI 와 데스크톱 앱(#303): 요약 DB 를 열어 대화 목록을 읽을 수 있는지 본다. node:sqlite 가 없으면 프로세스만 센다.
179
+ // path 는 CLI 폴더(예전 모양). 앱 폴더가 있으면 dirs 에 폴더마다 { path, found, records, source } 를 두고 둘째 줄부터 보인다.
180
+ // 앱 폴더는 있는 것만 목록에 들어오므로(findAgyRoots) 없으면 줄이 생기지 않는다. 앱 폴더에서도 conversations/ 와 요약 DB 만 본다.
181
+ function agy(roots = agyRoots()) {
180
182
  const running = canListProcesses() ? findProcesses(isAgy).length : null;
181
- const files = existsSync(dir) ? walk(dir, 0, (n) => n.endsWith('.db')) : null;
182
- if (!files) return { tool: 'agy', state: 'missing', path: tilde(AGY_ROOT), records: 0, lastAt: null, running, readable: null, hint: null };
183
+ const dirs = [];
184
+ const files = [];
185
+ for (const r of roots) {
186
+ const dir = join(r.dir, 'conversations');
187
+ const got = existsSync(dir) ? walk(dir, 0, (n) => n.endsWith('.db')) : null;
188
+ dirs.push({ path: tilde(r.dir), found: Boolean(got), records: got?.length ?? 0, source: r.source, root: r.dir });
189
+ files.push(...(got ?? []));
190
+ }
191
+ const path = dirs[0].path;
192
+ // 앱 폴더가 없으면 예전과 같은 모양 (dirs 없음).
193
+ const more = dirs.length > 1 ? { dirs: dirs.map(({ root, ...d }) => d) } : {};
194
+ if (!dirs.some((d) => d.found)) return { tool: 'agy', state: 'missing', path, ...more, records: 0, lastAt: null, running, readable: null, hint: null };
183
195
  const last = newest(files.flatMap((f) => [f, `${f}-wal`]).filter((f) => existsSync(f)));
184
- if (!loadSqlite()) return { tool: 'agy', state: 'limited', path: tilde(AGY_ROOT), records: files.length, lastAt: last?.mtime ?? null, running, readable: null, hint: null };
185
- let readable = false;
186
- let db;
187
- try {
188
- db = openReadOnly(join(AGY_ROOT, 'conversation_summaries.db'));
189
- db.prepare('select count(*) n from conversation_summaries').get();
190
- readable = true;
191
- } catch {
192
- } finally {
193
- db?.close();
196
+ if (!loadSqlite()) return { tool: 'agy', state: 'limited', path, ...more, records: files.length, lastAt: last?.mtime ?? null, running, readable: null, hint: null };
197
+ // 기록이 있는 폴더의 요약 DB 를 모두 읽을 수 있어야 읽을 수 있다고 본다.
198
+ let readable = true;
199
+ for (const d of dirs.filter((x) => x.found)) {
200
+ let db;
201
+ try {
202
+ db = openReadOnly(join(d.root, 'conversation_summaries.db'));
203
+ db.prepare('select count(*) n from conversation_summaries').get();
204
+ } catch {
205
+ readable = false;
206
+ } finally {
207
+ db?.close();
208
+ }
194
209
  }
195
- return { tool: 'agy', state: 'ok', path: tilde(AGY_ROOT), records: files.length, lastAt: last?.mtime ?? null, running, readable, hint: null };
210
+ return { tool: 'agy', state: 'ok', path, ...more, records: files.length, lastAt: last?.mtime ?? null, running, readable, hint: null };
211
+ }
212
+
213
+ // Claude Desktop Cowork(#304): 앱 폴더마다 세션 목록(메타)만 본다. 기록 내용·audit.jsonl 은 읽지 않는다.
214
+ // 앱 폴더를 하나도 찾지 못했으면(앱을 쓰지 않거나 끔) null 이고, --doctor 와 도구 줄에 cowork 가 보이지 않는다.
215
+ // path 는 첫 앱 폴더, 둘째부터는 dirs 로 한 줄씩. 세션 목록을 읽지 못한 폴더가 있으면 readable 이 false 다.
216
+ function cowork(roots) {
217
+ const list = roots ? coworkCheck(roots) : coworkCheck();
218
+ if (!list.length) return null;
219
+ const dirs = list.map((r) => ({ path: tilde(r.dir), found: r.ok, records: r.sessions, source: 'cowork' }));
220
+ const lastAt = Math.max(0, ...list.map((r) => r.lastAt ?? 0)) || null;
221
+ const records = list.reduce((a, r) => a + r.sessions, 0);
222
+ return { tool: 'cowork', state: 'ok', path: dirs[0].path, ...(dirs.length > 1 ? { dirs } : {}), records, lastAt, running: null, readable: list.every((r) => r.ok), hint: null };
196
223
  }
197
224
 
198
225
  // 도구별 안내 한 줄. 없으면 null. 점검 결과(--json 의 tools.*.hint)에는 예전처럼 한국어로 넣고, --doctor 글은 지금 언어로 다시 만든다.
199
226
  export function hintOf(r, lang = 'ko') {
200
227
  const o = { lang };
201
228
  if (r.tool === 'gemini') return tr('doctor.hint.gemini', null, o);
229
+ if (r.tool === 'cowork') return r.readable === false ? tr('doctor.hint.coworkUnread', null, o) : null;
202
230
  if (r.state === 'missing') return r.tool === 'agy' ? tr('doctor.hint.agyMissing', null, o) : tr('doctor.hint.missing', { tool: r.tool }, o);
203
231
  if (r.tool === 'agy' && r.state === 'limited') return tr('doctor.hint.agyNode', { node: process.versions.node }, o);
204
232
  return null;
205
233
  }
206
234
 
207
- // home: 후보 폴더를 찾을 홈 폴더 (테스트에서 바꿔 끼운다).
208
- export function checkTools({ home = HOME } = {}) {
235
+ // home: 후보 폴더를 찾을 홈 폴더 (테스트에서 바꿔 끼운다). coworkRoots: Cowork 앱 폴더 목록 (테스트용, 주지 않으면 찾은 것).
236
+ export function checkTools({ home = HOME, coworkRoots } = {}) {
209
237
  const cand = candidateDirs({ home });
210
238
  const tools = {};
211
- for (const fn of [claude, codex, gemini, agy]) {
212
- const r = fn === claude ? claude(cand.claude) : fn === codex ? codex(cand.codex) : fn();
239
+ for (const fn of [claude, cowork, codex, gemini, agy]) {
240
+ const r = fn === claude ? claude(cand.claude) : fn === codex ? codex(cand.codex) : fn === cowork ? cowork(coworkRoots) : fn();
241
+ if (!r) continue;
213
242
  r.hint = hintOf(r, 'ko');
214
243
  tools[r.tool] = r;
215
244
  }
@@ -275,7 +304,18 @@ export function describe(t, now = Date.now(), lang = getLang()) {
275
304
  if (t.keys?.length) parts.push(tr('doctor.keys', { keys: t.keys.join(', ') }, o));
276
305
  // 한국어 안내는 점검 결과에 든 그대로, 다른 언어는 같은 조건으로 다시 만든다.
277
306
  const hint = lang === 'ko' || !t.hint ? t.hint : (hintOf(t, lang) ?? t.hint);
278
- return { mark: MARK[t.state], state: lang === 'ko' ? STATE_TEXT[t.state] : tr(`doctor.state.${t.state}`, null, { lang, short: true }), path: t.path, detail: parts.join(' · '), hint };
307
+ // Cowork 는 기록 수 대신 세션 수를 보이고, 실행 중 수는 뺀다 (프로세스가 VM 안이라 보이지 않는다).
308
+ const detail = t.tool === 'cowork' ? coworkDetail(t, now, lang) : parts.join(' · ');
309
+ return { mark: MARK[t.state], state: lang === 'ko' ? STATE_TEXT[t.state] : tr(`doctor.state.${t.state}`, null, { lang, short: true }), path: t.path, detail, hint };
310
+ }
311
+
312
+ // Cowork 줄의 설명: 'Claude 앱 · 세션 N개 · 마지막 …'.
313
+ function coworkDetail(t, now, lang) {
314
+ const o = { lang };
315
+ const parts = [tr('doctor.coworkApp', null, o), tr('doctor.coworkSessions', { n: t.records.toLocaleString('en-US') }, o)];
316
+ if (t.lastAt) parts.push(tr('doctor.last', { ago: lang === 'ko' ? ago(now - t.lastAt) : fmtAgo(now - t.lastAt) }, o));
317
+ if (t.readable === false) parts.push(tr('doctor.unreadable', null, o));
318
+ return parts.join(' · ');
279
319
  }
280
320
 
281
321
  // aitop --doctor 의 사람용 출력.
@@ -290,7 +330,10 @@ export function doctorText(result, version, now = Date.now(), lang = getLang())
290
330
  const d = describe(t, now, lang);
291
331
  out.push(`${d.mark} ${pad(t.tool, 7)}${pad(d.state, 10)}${d.path}`);
292
332
  // 기록 폴더가 여럿이면 둘째부터 한 줄씩, 읽지 않는 후보 폴더는 넣는 방법과 함께 (#212).
293
- for (const x of t.dirs?.slice(1) ?? []) out.push(` + ${pad('', 15)}${x.path} ${x.found ? tr('doctor.records', { n: x.records.toLocaleString('en-US') }, o) : tr('doctor.dirMissing', null, o)}`);
333
+ // Antigravity 앱 폴더(source 'app', #303)는 기록 수 앞에 '앱' 을 붙인다.
334
+ const count = (x) => tr(x.source === 'cowork' ? 'doctor.coworkSessions' : 'doctor.records', { n: x.records.toLocaleString('en-US') }, o);
335
+ const tag = (x) => (x.source === 'app' ? `${tr('doctor.agyApp', null, o)} · ` : x.source === 'cowork' ? `${tr('doctor.coworkApp', null, o)} · ` : '');
336
+ for (const x of t.dirs?.slice(1) ?? []) out.push(` + ${pad('', 15)}${x.path} ${tag(x)}${x.found ? count(x) : tr('doctor.dirMissing', null, o)}`);
294
337
  out.push(` ${d.detail}`);
295
338
  if (d.hint) out.push(` → ${d.hint}`);
296
339
  if (t.candidates?.length) {
package/src/i18n.mjs CHANGED
@@ -340,6 +340,10 @@ export const STRINGS = {
340
340
  'cfg.notify': 'true, false 또는 waiting·done·context 배열',
341
341
  'cfg.positive': '0 보다 큰 수',
342
342
  'cfg.paths': '절대 경로(또는 ~/...) 문자열 배열, 1~16개',
343
+ 'cfg.agyApp': 'true, false 또는 절대 경로(또는 ~/...) 배열',
344
+ 'cfg.cowork': 'true, false 또는 Claude 앱 폴더 절대 경로(또는 ~/...) 배열',
345
+ 'cfg.agyAppEnv': 'off 또는 절대 경로(또는 ~/...) 목록',
346
+ 'cfg.masked': '설정 파일의 {key} 는 {name} 이 있어 무시합니다',
343
347
  'cfg.file': '설정 파일: {path} ({state})',
344
348
  'cfg.exists': '있음',
345
349
  'cfg.missing': '없음',
@@ -357,6 +361,10 @@ export const STRINGS = {
357
361
  'doctor.noFolder': '기록 폴더 없음',
358
362
  'doctor.records': '기록 {n}개',
359
363
  'doctor.dirMissing': '폴더 없음',
364
+ 'doctor.agyApp': 'Antigravity 앱',
365
+ 'doctor.coworkApp': 'Claude 앱',
366
+ 'doctor.coworkSessions': '세션 {n}개',
367
+ 'doctor.hint.coworkUnread': '세션 목록을 읽지 못했습니다. 앱 업데이트로 형식이 바뀌었을 수 있습니다',
360
368
  'doctor.candidate': '읽지 않는 기록 폴더 {path} (기록 {n}개)',
361
369
  'doctor.candidateHintClaude': '읽으려면 설정 파일 claudeDirs 배열에 넣거나 AITOP_CLAUDE_DIRS 로 주세요 (예: ["~/.claude", "~/.claude-work"])',
362
370
  'doctor.candidateHintCodex': '읽으려면 설정 파일 codexHomes 배열에 넣거나 AITOP_CODEX_HOMES 로 주세요 (예: ["~/.codex", "~/.codex-alt"])',
@@ -531,6 +539,7 @@ export const STRINGS = {
531
539
  'legend.stalled': '팀원 기록이 3분(느린 도구 10분) 그대로. 짐작',
532
540
  'legend.sdk': '팀원 행: 이 세션이 띄운 claude -p 실행',
533
541
  'legend.auto': '부모 없는 claude -p 실행. 대기 알림 없음',
542
+ 'legend.cowork': 'TOOL 칸: Claude Desktop 에이전트 모드 세션',
534
543
  'legend.status': '지금 단계. 큰 기록을 처음 읽는 동안은 기록 읽는 중 N%',
535
544
  'legend.tokens': '세션 누적 토큰 (서브에이전트 포함, 캐시 읽기 포함)',
536
545
  'legend.cost': 'API 정가로 환산한 비용 (Codex 는 OpenAI 정가 추정). 가격표에 없는 모델은 빼고 센다',
@@ -638,6 +647,7 @@ export const STRINGS = {
638
647
  'detail.folder': '폴더',
639
648
  'detail.branch': '브랜치',
640
649
  'detail.model': '모델',
650
+ 'detail.app': '앱',
641
651
  'detail.kind': '종류',
642
652
  'detail.started': '시작',
643
653
  'detail.ago': '{at} ({ago} 전)',
@@ -825,6 +835,10 @@ export const STRINGS = {
825
835
  'cfg.notify': 'true, false or a list of waiting, done, context',
826
836
  'cfg.positive': 'a number above 0',
827
837
  'cfg.paths': 'a list of 1 to 16 absolute paths (or ~/...)',
838
+ 'cfg.agyApp': 'true, false, or a list of absolute paths (or ~/...)',
839
+ 'cfg.cowork': 'true, false, or a list of absolute Claude app folder paths (or ~/...)',
840
+ 'cfg.agyAppEnv': 'off or a list of absolute paths (or ~/...)',
841
+ 'cfg.masked': 'ignoring {key} in the config file because {name} is set',
828
842
  'cfg.file': 'Config file: {path} ({state})',
829
843
  'cfg.exists': 'found',
830
844
  'cfg.missing': 'not found',
@@ -842,6 +856,10 @@ export const STRINGS = {
842
856
  'doctor.noFolder': 'no log folder',
843
857
  'doctor.records': { one: '{n} log', other: '{n} logs' },
844
858
  'doctor.dirMissing': 'folder not found',
859
+ 'doctor.agyApp': 'Antigravity app',
860
+ 'doctor.coworkApp': 'Claude app',
861
+ 'doctor.coworkSessions': { one: '{n} session', other: '{n} sessions' },
862
+ 'doctor.hint.coworkUnread': 'could not read the session list. An app update may have changed the format',
845
863
  'doctor.candidate': { one: 'not read: {path} ({n} log)', other: 'not read: {path} ({n} logs)' },
846
864
  'doctor.candidateHintClaude': 'to read it, add it to claudeDirs in the config file or AITOP_CLAUDE_DIRS (e.g. ["~/.claude", "~/.claude-work"])',
847
865
  'doctor.candidateHintCodex': 'to read it, add it to codexHomes in the config file or AITOP_CODEX_HOMES (e.g. ["~/.codex", "~/.codex-alt"])',
@@ -1009,6 +1027,7 @@ export const STRINGS = {
1009
1027
  'legend.stalled': 'No log change 3 min (slow tools 10). A guess',
1010
1028
  'legend.sdk': 'Member row: claude -p run of this session',
1011
1029
  'legend.auto': 'claude -p run with no parent. No wait alerts',
1030
+ 'legend.cowork': 'TOOL column: Claude Desktop agent mode session',
1012
1031
  'legend.status': 'Current step (Reading log N% on first load)',
1013
1032
  'legend.tokens': 'Tokens incl. subagents and cache reads',
1014
1033
  'legend.cost': 'API cost (Codex estimated). Unpriced models not counted',
@@ -1113,6 +1132,7 @@ export const STRINGS = {
1113
1132
  'detail.folder': 'Folder',
1114
1133
  'detail.branch': 'Branch',
1115
1134
  'detail.model': 'Model',
1135
+ 'detail.app': 'app',
1116
1136
  'detail.kind': 'Kind',
1117
1137
  'detail.started': 'Started',
1118
1138
  'detail.ago': '{at} ({ago} ago)',
package/src/json.mjs CHANGED
@@ -40,9 +40,11 @@ export function toJson(data, version = null, opts = {}) {
40
40
  branch: s.branch ?? null,
41
41
  model: s.model ?? null,
42
42
  kind: s.kind ?? null,
43
- // 실행 방식 (Claude 기록의 entrypoint: 'cli', 'sdk-cli' 등, 모르면 null). auto 는 부모 세션을 못 찾은 claude -p 실행 (#286).
43
+ // 실행 방식 (Claude 기록의 entrypoint: 'cli', 'sdk-cli', Cowork 는 'local-agent' 등, 모르면 null). auto 는 부모 세션을 못 찾은 claude -p 실행 (#286).
44
44
  // 부모를 찾은 claude -p 실행은 여기 없고 부모의 members 에 entrypoint·parentId 와 함께 들어간다 (합계도 부모에 더해져 있다).
45
45
  entrypoint: s.entrypoint ?? null,
46
+ // 기록이 온 곳. Antigravity(tool 'gemini' 이고 기록이 있는 세션)만 'cli'(agy CLI) 또는 'app'(데스크톱 앱), 나머지는 null (#303).
47
+ source: s.source ?? null,
46
48
  auto: Boolean(s.auto),
47
49
  pid: s.pid ?? null,
48
50
  live: Boolean(s.live),
package/src/resume.mjs CHANGED
@@ -36,7 +36,8 @@ function resumeArgs(s) {
36
36
  const u = codexId(id);
37
37
  return u ? ['codex', 'resume', u] : null;
38
38
  }
39
- if (s.tool === 'gemini') return isUuid(id) ? ['agy', '--conversation', id] : null;
39
+ // Antigravity 데스크톱 앱의 대화(source 'app')는 agy CLI 로 이어 열 수 없어 만들지 않는다 (#303).
40
+ if (s.tool === 'gemini') return isUuid(id) && s.source !== 'app' ? ['agy', '--conversation', id] : null;
40
41
  return null;
41
42
  }
42
43
 
@@ -3,8 +3,8 @@
3
3
  // 세션 화면과 상관없이 끝난 대화까지 세야 해서 토큰만 가볍게 따로 읽고(진행 기록은 읽지 않는다), 어디까지 읽었는지는 캐시에 둔다.
4
4
  // 기록은 늘 immutable 로 열어 agy 폴더에 아무것도 만들거나 고치지 않는다.
5
5
  import { readdirSync, statSync, existsSync } from 'node:fs';
6
- import { join } from 'node:path';
7
- import { AGY_ROOT, readCalls, sigOf, maxIdx } from './antigravity.mjs';
6
+ import { dirname, join } from 'node:path';
7
+ import { agyRoots, readCalls, sigOf, maxIdx, APP_TTL_MS } from './antigravity.mjs';
8
8
  import { openReadOnly, loadSqlite } from '../sqlite.mjs';
9
9
  import { loadCache, markDirty } from '../cache.mjs';
10
10
  import { dayKey, addSlot, addModel, recentDays } from './common.mjs';
@@ -73,6 +73,8 @@ export class AgyBook {
73
73
 
74
74
  update(budget) {
75
75
  const sig = sigOf(this.path);
76
+ // 이번에 본 서명. 끝까지 읽었는지(sig) 또는 실패로 멈춰 둔 것인지(failSig) 판단에 쓴다 (앱 폴더 TTL, #303).
77
+ this.seenSig = sig;
76
78
  if (sig === null || sig === this.sig || sig === this.failSig) return;
77
79
  if (outOf(budget)) {
78
80
  budget.exhausted = true;
@@ -147,25 +149,35 @@ export class AgyBook {
147
149
  }
148
150
 
149
151
  let listed = { at: 0, files: [], days: 0 };
152
+ // 앱 폴더의 conversations/ 경로들 (#303). 이 아래 기록은 APP_TTL_MS 마다 한 번만 서명을 본다.
153
+ let apps = new Set();
154
+ const inApp = (p) => apps.has(dirname(p));
150
155
 
151
- // 최근 days 일(평소 7일, 리포트는 더 길게) 안에 바뀐 대화 기록.
152
- function recentFiles(days = DAYS) {
156
+ // 최근 days 일(평소 7일, 리포트는 더 길게) 안에 바뀐 대화 기록. CLI 폴더와 앱 폴더를 모두 본다 (#303).
157
+ // 장부·캐시는 파일 경로로 나뉘어 폴더끼리 섞이지 않는다. 같은 대화 id 가 두 폴더에 있으면 앞 폴더 것만 센다.
158
+ function recentFiles(days = DAYS, roots = agyRoots()) {
153
159
  if (listed.days === days && Date.now() - listed.at < LIST_TTL_MS) return listed.files;
154
- const dir = join(AGY_ROOT, 'conversations');
160
+ apps = new Set(roots.filter((r) => r.source === 'app').map((r) => join(r.dir, 'conversations')));
155
161
  const cutoff = Date.now() - days * 86400_000;
156
162
  const files = [];
157
- let names = [];
158
- try {
159
- names = readdirSync(dir);
160
- } catch (e) {
161
- debugIo('ledger', 'agy conversations read failed', e);
162
- }
163
- for (const f of names) {
164
- if (!f.endsWith('.db')) continue;
165
- const p = join(dir, f);
163
+ const seen = new Set();
164
+ for (const r of roots) {
165
+ const dir = join(r.dir, 'conversations');
166
+ if (!existsSync(dir)) continue;
167
+ let names = [];
166
168
  try {
167
- if (statSync(p).mtimeMs >= cutoff) files.push(p);
168
- } catch {}
169
+ names = readdirSync(dir);
170
+ } catch (e) {
171
+ debugIo('ledger', 'agy conversations read failed', e);
172
+ }
173
+ for (const f of names) {
174
+ if (!f.endsWith('.db') || seen.has(f)) continue;
175
+ seen.add(f);
176
+ const p = join(dir, f);
177
+ try {
178
+ if (statSync(p).mtimeMs >= cutoff) files.push(p);
179
+ } catch {}
180
+ }
169
181
  }
170
182
  listed = { at: Date.now(), files, days };
171
183
  return files;
@@ -178,15 +190,23 @@ const books = new Map();
178
190
  // node:sqlite 를 못 쓰는 Node 에서는 비어 있다 (agy 는 프로세스만 보인다).
179
191
  export function collectAgyLedger({ budget, days = DAYS } = {}) {
180
192
  const out = { days: [], slots: [], paths: [], stale: [], pending: 0, size: 0 };
181
- if (!loadSqlite() || !existsSync(join(AGY_ROOT, 'conversations'))) return out;
193
+ if (!loadSqlite() || !agyRoots().some((r) => existsSync(join(r.dir, 'conversations')))) return out;
182
194
  const files = recentFiles(days);
183
195
  const keep = new Set(files);
184
196
  for (const p of books.keys()) if (!keep.has(p)) books.delete(p);
185
197
  for (const p of files) {
186
198
  let b = books.get(p);
187
199
  if (!b) books.set(p, (b = new AgyBook(p)));
188
- b.update(budget);
189
- const size = b.size;
200
+ // 앱 폴더(/mnt/c 일 수 있음)의 기록은 지금 서명까지 다 읽었거나(sig), 실패로 멈춰 둔 서명(failSig)이면
201
+ // TTL 안에서는 다시 stat·열기를 하지 않고 지난 값을 쓴다. 읽기 한도에 걸려 덜 읽었으면 다음 갱신에 바로 이어 읽는다.
202
+ const app = inApp(p);
203
+ const fresh = app && b.checkedAt != null && Date.now() - b.checkedAt < APP_TTL_MS;
204
+ if (!fresh) {
205
+ b.update(budget);
206
+ if (app) b.checkedAt = b.seenSig != null && (b.seenSig === b.sig || b.seenSig === b.failSig) ? Date.now() : null;
207
+ }
208
+ const size = fresh ? b.lastSize : b.size;
209
+ b.lastSize = size;
190
210
  out.size += size;
191
211
  if (!b.complete) out.pending += size;
192
212
  // 실패한 기록은 빠졌을 수 있는 첫날, 아니면 null.
@@ -200,4 +220,12 @@ export function collectAgyLedger({ budget, days = DAYS } = {}) {
200
220
 
201
221
  // 테스트용: 기록을 연 횟수.
202
222
  let opens = 0;
203
- export const _test = { reset: () => ((listed = { at: 0, files: [], days: 0 }), books.clear()), opens: () => opens };
223
+ export const _test = {
224
+ reset: () => ((listed = { at: 0, files: [], days: 0 }), books.clear()),
225
+ opens: () => opens,
226
+ // 앱 폴더 기록의 TTL 이 지난 것을 흉내 낸다.
227
+ age: (ms) => {
228
+ listed.at -= ms;
229
+ for (const b of books.values()) if (b.checkedAt != null) b.checkedAt -= ms;
230
+ },
231
+ };