@sejuneoh/aitop 0.35.0 → 0.36.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
@@ -124,6 +124,8 @@ Subagents show as `├─` rows under their session, on the live screen.
124
124
  - A dim `stalled?` appears when a working subagent's log has not changed for 3 minutes. It is only a guess.
125
125
  - While it runs a tool that can be slow, the limit is 10 minutes.
126
126
  - When an Antigravity subagent waits for your approval, its parent row waits too, as `<agent>: <tool>`.
127
+ - A `claude -p` run started from a Claude session (by its process, or from `~/.claude/jobs/<id>/` once ended) shows as a `-p` row under that session, with its cost added; one with no parent (cron) stays on top marked `auto` and never counts as waiting for you.
128
+ - If the parent session stays open for more than 24 hours, `claude -p` runs that ended before that are left out of its total.
127
129
 
128
130
  <details>
129
131
  <summary>Details: <code>stalled?</code> and Antigravity waits</summary>
@@ -285,9 +287,9 @@ Alerts when a session starts waiting, finishes a long turn or fills its context.
285
287
  >
286
288
  > `aitop --on-waiting 'my-hook.sh'`
287
289
 
288
- - `--notify`: desktop notification when a session starts waiting (notify-send on Linux, Windows notification on WSL, osascript on macOS).
290
+ - `--notify`: desktop notification when a session starts waiting (notify-send on Linux, osascript on macOS, a Windows notification through PowerShell on WSL and Windows).
289
291
  - `--notify=waiting,done,context`: pick the kinds. Plain `--notify` uses the config file kinds, or waiting only when none are set.
290
- - `--on-waiting`: run a command with `/bin/sh -c` for the same events (10 second limit, runs as you).
292
+ - `--on-waiting`: run a command with `/bin/sh -c` (`cmd.exe /d /v:on /s /c` on Windows) for the same events (10 second limit, runs as you).
291
293
  - Sessions already waiting (or already over 90% context) when aitop starts are not reported.
292
294
 
293
295
  **Kinds**
@@ -313,7 +315,7 @@ Alerts when a session starts waiting, finishes a long turn or fills its context.
313
315
  **Config file and switches**
314
316
 
315
317
  - `"notify": true` or `"notify": ["waiting", "done", "context"]`.
316
- - `"onWaiting": "..."` (the file must be `chmod 600`).
318
+ - `"onWaiting": "..."` (the file must be `chmod 600`; on Windows it must be under your profile instead, see [Install](#install)).
317
319
  - `"doneMinutes": 5`.
318
320
  - Plain `--notify` keeps the kinds from the config `notify` list (waiting only when there is none).
319
321
  - `--no-notify` turns off only the desktop notification: the hook still follows those kinds.
@@ -324,7 +326,7 @@ Alerts when a session starts waiting, finishes a long turn or fills its context.
324
326
  <details>
325
327
  <summary>Details: WSL, D-Bus, notification text</summary>
326
328
 
327
- - On WSL, aitop shows a Windows notification through `powershell.exe` (as Windows PowerShell, no setup needed).
329
+ - On WSL and Windows, aitop shows a Windows notification through `powershell.exe` (as Windows PowerShell, no setup needed). On Windows it uses the one under `%SystemRoot%` first, then the PATH.
328
330
  - It falls back to notify-send when `powershell.exe` is not on the PATH.
329
331
  - notify-send needs a D-Bus session bus. When `DBUS_SESSION_BUS_ADDRESS` is unset or its socket file is missing, notifications cannot show and `--doctor` marks the line with `!`.
330
332
  - A missing tool or a failed notification is skipped quietly.
@@ -476,7 +478,7 @@ Continue a session elsewhere, for example when you cannot jump to its tab, as in
476
478
  **Other fields**
477
479
 
478
480
  - `cacheExpiresAt`, `toolStartedAt`: [Features](#features).
479
- - `stalled`, `startedAt`, `lastActivityAt`: [Subagents](#subagents).
481
+ - `stalled`, `startedAt`, `lastActivityAt`, `entrypoint`, `auto`, `parentId`: [Subagents](#subagents).
480
482
  - `resumeCmd`: [Resume a session elsewhere](#resume-a-session-elsewhere).
481
483
  - Report output (`month`, `current`, `status`, `paths`, `unpriced`, `waitedMs`): [Daily and monthly reports](#daily-and-monthly-reports), [Session report](#session-report).
482
484
 
@@ -535,13 +537,22 @@ Requires Node.js 22+ on Linux, macOS, WSL or Windows.
535
537
  - `npm install -g` installs it. Then run `aitop`.
536
538
 
537
539
  <details>
538
- <summary>Windows: what works and what does not yet</summary>
539
-
540
- - Native Windows support is early (Windows Terminal recommended).
541
- - Works: Claude Code and Codex sessions, `--once`, `--json`, `--report` and `--doctor`.
542
- - Not there yet: process detection, desktop notifications and `--on-waiting` ([#195](https://github.com/SejuneOh/aitop/issues/195)-[#197](https://github.com/SejuneOh/aitop/issues/197)).
543
- - Until then a Codex session counts as running while its log was written in the last 10 minutes.
544
- - So it drops out during a long step that writes nothing for over 10 minutes, and a crashed session can stay up to 10 minutes.
540
+ <summary>Windows: what works and how</summary>
541
+
542
+ - Windows Terminal is recommended.
543
+ - In the old console (conhost) the `▕█░` bars and braille (`⠋`, the logo) may show as boxes, and `--doctor` says so. Run with `AITOP_AMBIGUOUS=wide` (ASCII tables and bars) or `NO_COLOR` (progress bar as `[#.]`) there.
544
+ - When antivirus or another aitop briefly holds a cache or summary file, replacing it is retried 3 times, 50ms apart.
545
+ - Works: Claude Code and Codex sessions, `--once`, `--json`, `--report`, `--doctor`, `--notify` and `--on-waiting`.
546
+ - `--on-waiting` runs through `%COMSPEC%` (usually `cmd.exe`) `/d /v:on /s /c` with no window, and `taskkill /T /F` ends it and its children.
547
+ - Inside the command, read values as `!AITOP_PROJECT!`, not `%AITOP_PROJECT%`: cmd reads `&`, `|` and `>` in a `%...%` value as part of the command, but not in a `!...!` value. A `!` in the command itself is read as a variable mark.
548
+ - The same goes for a `.bat` or `.cmd` file the hook calls: `%AITOP_PROJECT%` inside it is read as part of the script. Start it with `setlocal enabledelayedexpansion` and use `!AITOP_PROJECT!`, or write the hook in PowerShell and read `$env:AITOP_PROJECT`.
549
+ - Windows uses ACLs, not modes, so instead of the `chmod 600` check `onWaiting` in the config file is accepted only when the file (after following links) is under your profile (`%USERPROFILE%`, for example `%APPDATA%\aitop`), which other users cannot write by default. A config file elsewhere (say `XDG_CONFIG_HOME=C:\cfg`) has its `onWaiting` ignored, with a warning at start and in `--doctor`.
550
+ - Desktop notifications (`--notify`) show through Windows PowerShell, as on WSL.
551
+ - Running processes come from one PowerShell call (`Get-CimInstance Win32_Process`): ids, parents, command lines and start times. It takes about a second, so aitop waits for the first one and then refreshes it in the background every 5 seconds (8 second limit). `--doctor` shows the method and the time it took.
552
+ - Windows does not give other processes' working folders, so each Codex process (latest first) gets the most recently written session among those started after it, which follows `/new`. A process with none gets the latest log written after it started (a resumed session).
553
+ - Known limit: by times alone this cannot tell a session that just ended in another terminal from `/new`, so such a session may show as running for a while instead of a long-idle one. It corrects itself once the idle session writes again.
554
+ - A Claude Code session is ended when the process now holding its pid started after the session file was last written (pid reuse).
555
+ - If the PowerShell call fails 3 times in a row (or the first call fails), a Codex session counts as running while its log was written in the last 10 minutes, as before. It is retried after a minute.
545
556
  - Cache, log and config live in `%LOCALAPPDATA%\aitop\cache`, `%LOCALAPPDATA%\aitop\state` and `%APPDATA%\aitop` unless `XDG_*` is set.
546
557
 
547
558
  </details>
package/bin/aitop.mjs CHANGED
@@ -254,10 +254,16 @@ if ((cli.notify || cli.onWaiting) && (args.has('--once') || args.has('--json') |
254
254
 
255
255
  const { checkTools, doctorText, toolsJson } = await import('../src/doctor.mjs');
256
256
  if (args.has('--doctor')) {
257
+ // 진단은 한 번 돌고 끝나므로 Windows 의 첫 PowerShell CIM 호출을 더 오래 기다린다 (procs.mjs WIN_DOCTOR_TIMEOUT_MS).
258
+ const { setFirstScanTimeout, WIN_DOCTOR_TIMEOUT_MS } = await import('../src/procs.mjs');
259
+ setFirstScanTimeout(WIN_DOCTOR_TIMEOUT_MS);
257
260
  const result = { ...checkTools(), config: configJson(config), log: { on: log.on, path: log.path } };
258
261
  await printAndExit(args.has('--json') ? JSON.stringify({ version: VERSION, ...result, tools: toolsJson(result.tools) }, null, 2) : doctorText(result, VERSION));
259
262
  }
260
263
 
264
+ // 설정 파일의 onWaiting 을 받지 않았으면 실행할 때도 알린다 (--doctor·--print-config 에는 problems 로 보인다).
265
+ if (cfgFile.onWaitingIgnored && !cli.onWaiting) process.stderr.write(`aitop: ${cfgFile.onWaitingIgnored}\n`);
266
+
261
267
  const { collect } = await import('../src/collect.mjs');
262
268
  const { render, filterSessions, animating } = await import('../src/ui.mjs');
263
269
  const { arrange } = await import('../src/order.mjs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sejuneoh/aitop",
3
- "version": "0.35.0",
3
+ "version": "0.36.1",
4
4
  "description": "터미널에서 Claude Code · Codex · Antigravity · Gemini 세션과 토큰을 실시간으로 보는 읽기 전용 모니터",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,6 +34,7 @@
34
34
  "scripts": {
35
35
  "start": "node bin/aitop.mjs",
36
36
  "test": "node --import ./test/lang-ko.mjs --test test/*.test.mjs",
37
- "test:e2e": "node --import ./test/lang-ko.mjs --test test/e2e/*.e2e.mjs"
37
+ "test:e2e": "node --import ./test/lang-ko.mjs --test test/e2e/*.e2e.mjs",
38
+ "test:perf": "node --test test/perf/*.perf.mjs"
38
39
  }
39
40
  }
package/src/attention.mjs CHANGED
@@ -24,6 +24,10 @@ export function markSeen(state, id) {
24
24
  state.unseen.delete(id);
25
25
  }
26
26
 
27
+ // 사람을 부르는 응답 대기인지. 부모 세션을 못 찾은 claude -p 실행(auto, cron 등)은 사람이 답할 수 없으므로
28
+ // 응답 대기여도 알림·n 이동·창 제목·헤더 수·맨 위 올림에서 뺀다 (#286). 행 자체의 ◆ 와 상태 글은 그대로 보인다.
29
+ export const callsYou = (s) => s.status === 'waiting' && !s.auto;
30
+
27
31
  // 오류로 멈춘 세션 (로그인 필요·연결 끊김 등, phase stopped). status 는 idle 이지만 사람이 손대야 하므로 대기와 따로 센다 (#262).
28
32
  export const isStopped = (s) => Boolean(s.live) && s.phase?.kind === 'stopped';
29
33
 
@@ -32,12 +36,12 @@ export const isStopped = (s) => Boolean(s.live) && s.phase?.kind === 'stopped';
32
36
  export function nextAttention(state, sessions, selectedId) {
33
37
  const at = sessions.findIndex((s) => s.id === selectedId);
34
38
  const ordered = at < 0 ? sessions : [...sessions.slice(at + 1), ...sessions.slice(0, at)];
35
- return ordered.find((s) => s.status === 'waiting') ?? ordered.find(isStopped) ?? ordered.find((s) => state.unseen.has(s.id)) ?? null;
39
+ return ordered.find(callsYou) ?? ordered.find(isStopped) ?? ordered.find((s) => state.unseen.has(s.id)) ?? null;
36
40
  }
37
41
 
38
42
  // 응답 대기(◆), 멈춤(!), 확인 전(●) 수.
39
43
  export function attentionCounts(sessions) {
40
- return { waiting: sessions.filter((s) => s.live && s.status === 'waiting').length, stopped: sessions.filter(isStopped).length, unseen: sessions.filter((s) => s.unseen).length };
44
+ return { waiting: sessions.filter((s) => s.live && callsYou(s)).length, stopped: sessions.filter(isStopped).length, unseen: sessions.filter((s) => s.unseen).length };
41
45
  }
42
46
 
43
47
  // 창 제목: 맨 앞 아이콘(탭 사이에서 aitop 을 찾게) + 응답 대기·멈춤·확인 전 수. 예: 󰚩 (2◆ 1! 1●) aitop
@@ -49,7 +53,7 @@ export function windowTitle(sessions, icon = '') {
49
53
 
50
54
  // 새로 응답 대기가 된 세션 목록. seen 은 지난번 응답 대기 세션 id 집합이며 여기서 갱신한다.
51
55
  export function freshWaiting(seen, sessions) {
52
- const now = sessions.filter((s) => s.live && s.status === 'waiting');
56
+ const now = sessions.filter((s) => s.live && callsYou(s));
53
57
  const fresh = now.filter((s) => !seen.has(s.id));
54
58
  seen.clear();
55
59
  for (const s of now) seen.add(s.id);
@@ -99,7 +103,8 @@ export function takeEvents(watch, sessions, { now = Date.now(), ready = true } =
99
103
  const out = [];
100
104
  const ids = new Set();
101
105
  for (const s of sessions) {
102
- if (!s.live || s.status === 'ended' || isSub(s)) continue;
106
+ // 부모를 못 찾은 claude -p 실행(auto)은 사람이 지켜보는 작업이 아니므로 완료·컨텍스트도 알리지 않는다 (#286).
107
+ if (!s.live || s.status === 'ended' || isSub(s) || s.auto) continue;
103
108
  ids.add(s.id);
104
109
  let st = watch.per.get(s.id);
105
110
  if (!st) watch.per.set(s.id, (st = { run: false, busyMs: 0, busyAt: null, idleSince: null, ctxArmed: true, first: true }));
package/src/cache.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // 큰 세션 기록을 매번 처음부터 다시 읽지 않도록, 파일별로 "어디까지 읽었고 그때 합계가 얼마였는지"를
2
2
  // ~/.cache/aitop 에 저장한다. 이 프로그램이 디스크에 쓰는 곳은 여기와 --debug 때의 디버그 로그(log.mjs)뿐이다.
3
- import { readFileSync, writeFileSync, mkdirSync, renameSync, statSync, readdirSync, rmSync } from 'node:fs';
3
+ import { readFileSync, writeFileSync, mkdirSync, statSync, readdirSync, rmSync } from 'node:fs';
4
+ import { renameSync, RENAME_RETRIES } from './rename.mjs';
4
5
  import { join } from 'node:path';
5
6
  import { homedir } from 'node:os';
6
7
  import { appDir } from './paths.mjs';
@@ -15,6 +16,8 @@ const VERSION = 14;
15
16
  // Windows 는 XDG_CACHE_HOME 이 없으면 %LOCALAPPDATA%\aitop\cache (paths.mjs).
16
17
  const ROOT = appDir('cache', { home: homedir() });
17
18
  export const CACHE_ROOT = ROOT;
19
+ // claude -p 실행의 기억된 부모 (sources/claude.mjs knownParents). 버전 폴더 밖에 두고 removeOldDirs 가 지우지 않는다.
20
+ export const PARENTS_FILE = 'sdk-parents.json';
18
21
  const NAME = `v${VERSION}-${PRICE_TAG}`;
19
22
  const DIR = join(ROOT, NAME);
20
23
  export const CACHE_DIR = DIR;
@@ -30,7 +33,8 @@ function removeOldDirs() {
30
33
  for (const d of readdirSync(ROOT)) {
31
34
  // summary.json(--line 용 요약, summary.mjs)은 버전 폴더 밖에 두고 여기서 지우지 않는다. 남은 임시 파일은 일주일 뒤 지운다.
32
35
  // monthly.json(월별 보관함, monthly.mjs)과 깨져서 옆으로 옮긴 monthly.json.bad-* 도 사용자 기록이라 지우지 않는다.
33
- if (d === NAME || d === 'summary.json' || d === 'monthly.json' || d.startsWith('monthly.json.bad-')) continue;
36
+ // sdk-parents.json(claude -p 실행의 기억된 부모)도 형식 버전과 상관없이 남긴다.
37
+ if (d === NAME || d === 'summary.json' || d === 'monthly.json' || d === PARENTS_FILE || d.startsWith('monthly.json.bad-')) continue;
34
38
  const p = join(ROOT, d);
35
39
  // 이 버전보다 낮은 형식(v2, v6-… 등)은 더 이상 어떤 버전도 쓰지 않으므로 바로 지운다.
36
40
  const ver = Number(/^v(\d+)(?:-|$)/.exec(d)?.[1]);
@@ -70,13 +74,21 @@ export function flushCache() {
70
74
  return;
71
75
  }
72
76
  if (!cleaned) removeOldDirs();
77
+ // 교체가 재시도 뒤에도 실패하면(권한 등 계속되는 오류) 이번 저장의 남은 파일은 재시도 없이 한 번만 해 본다.
78
+ // 파일마다 재시도로 멈추는 시간이 쌓이지 않게 한다 (Windows, #198).
79
+ let retries = RENAME_RETRIES;
73
80
  for (const [key, { path, build }] of dirty) {
74
81
  try {
75
82
  const data = build();
76
83
  if (!data) continue;
77
84
  const file = join(DIR, key + '.json');
78
85
  writeFileSync(file + '.tmp', JSON.stringify({ ...data, path, ino: statSync(path).ino }), { mode: 0o600 });
79
- renameSync(file + '.tmp', file);
86
+ try {
87
+ renameSync(file + '.tmp', file, { retries });
88
+ } catch (e) {
89
+ retries = 0;
90
+ throw e;
91
+ }
80
92
  } catch (e) {
81
93
  debugIo('cache', 'cache write failed', e);
82
94
  }
package/src/config.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  // 설정 파일은 $XDG_CONFIG_HOME/aitop/config.json (없으면 ~/.config/aitop/config.json). aitop 은 이 파일을 읽기만 한다.
3
3
  // 잘못된 JSON, 모르는 키, 잘못된 값은 그 키만 무시하고 problems 에 남긴다 (--doctor 와 --print-config 가 보인다).
4
4
  // 화면 모듈은 불러올 때 테마·아이콘을 고르므로, 이 모듈은 화면 모듈을 불러오지 않는다 (notify.mjs 는 text·i18n 만 쓴다).
5
- import { closeSync, constants, fstatSync, openSync, readSync, statSync } from 'node:fs';
5
+ import { closeSync, constants, fstatSync, openSync, readSync, realpathSync, statSync } from 'node:fs';
6
6
  import { homedir } from 'node:os';
7
7
  import { join, posix, win32 } from 'node:path';
8
8
  import { appDir } from './paths.mjs';
@@ -93,8 +93,24 @@ export const MAX_BYTES = 64 * 1024;
93
93
 
94
94
  const show = (v) => JSON.stringify(v)?.slice(0, 60) ?? String(v);
95
95
 
96
- // 파일을 읽어 올바른 키만 values 에 담는다. uid: 현재 사용자 (테스트에서 바꿔 끼운다).
97
- export function readConfigFile(path, { uid = process.getuid?.() } = {}) {
96
+ // Windows: 설정 파일의 실제 경로(링크를 따라간 뒤)가 사용자 프로필(%USERPROFILE%) 아래인지. 대소문자와 \ / 를 무시한다.
97
+ // 프로필 폴더는 기본 ACL 로 다른 일반 사용자가 쓸 수 없지만, 그 밖(예: C:\cfg)은 Authenticated Users 가 고칠 수 있는 일이 흔하다 (#196).
98
+ export function underProfile(file, profile, realpath = realpathSync.native) {
99
+ if (!profile) return false;
100
+ const norm = (p) => {
101
+ let r;
102
+ try {
103
+ r = realpath(p);
104
+ } catch {
105
+ r = p;
106
+ }
107
+ return win32.normalize(String(r)).replace(/\\+$/, '').toLowerCase();
108
+ };
109
+ return norm(file).startsWith(norm(profile) + '\\');
110
+ }
111
+
112
+ // 파일을 읽어 올바른 키만 values 에 담는다. uid: 현재 사용자, platform: OS, profile·realpath: Windows 프로필 확인용 (테스트에서 바꿔 끼운다).
113
+ export function readConfigFile(path, { uid = process.getuid?.(), platform = process.platform, profile = process.env.USERPROFILE || homedir(), realpath } = {}) {
98
114
  const res = { path, exists: false, values: {}, problems: [] };
99
115
  let fd;
100
116
  let text;
@@ -145,13 +161,21 @@ export function readConfigFile(path, { uid = process.getuid?.() } = {}) {
145
161
  else res.values[key] = value;
146
162
  }
147
163
  // 응답 대기 때 실행할 명령은 다른 사용자가 바꿀 수 없는 파일에서만 받는다.
148
- if ('onWaiting' in res.values) {
164
+ // Windows 는 uid 가 없고 mode 가 보통 0o666 이라(권한은 ACL) mode 대신, 파일이 사용자 프로필 아래에 있을 때만 받는다 (#196).
165
+ if ('onWaiting' in res.values && platform === 'win32') {
166
+ if (!underProfile(path, profile, realpath)) {
167
+ delete res.values.onWaiting;
168
+ res.onWaitingIgnored = t('cfg.onWaitingIgnoredWin');
169
+ res.problems.push(res.onWaitingIgnored);
170
+ }
171
+ } else if ('onWaiting' in res.values) {
149
172
  const mine = uid == null || st.uid === uid;
150
173
  const shared = (st.mode & 0o022) !== 0;
151
174
  if (!mine || shared) {
152
175
  delete res.values.onWaiting;
153
176
  const why = [!mine && t('cfg.notMine'), shared && t('cfg.shared', { mode: (st.mode & 0o777).toString(8).padStart(3, '0') })].filter(Boolean).join(', ');
154
- res.problems.push(t('cfg.onWaitingIgnored', { why }));
177
+ res.onWaitingIgnored = t('cfg.onWaitingIgnored', { why });
178
+ res.problems.push(res.onWaitingIgnored);
155
179
  }
156
180
  }
157
181
  return res;
package/src/doctor.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  import { readdirSync, readFileSync, statSync, existsSync, openSync, readSync, closeSync } from 'node:fs';
5
5
  import { basename, join } from 'node:path';
6
6
  import { homedir, platform } from 'node:os';
7
- import { findProcesses, isCodex, isGemini, isAgy, canListProcesses, isAlive, isSessionAlive } from './procs.mjs';
7
+ import { findProcesses, isCodex, isGemini, isAgy, canListProcesses, isAlive, isSessionAlive, processMethod } from './procs.mjs';
8
8
  import { AGY_ROOT } from './sources/antigravity.mjs';
9
9
  import { loadSqlite, openReadOnly } from './sqlite.mjs';
10
10
  import { fmtAgo, pad, stripControl } from './text.mjs';
@@ -105,7 +105,7 @@ function topKeys(path) {
105
105
  function liveSessionFile(path) {
106
106
  try {
107
107
  const e = JSON.parse(readFileSync(path, 'utf8'));
108
- return !e.spare && isSessionAlive(e.pid, e.procStart);
108
+ return !e.spare && isSessionAlive(e.pid, e.procStart, e.updatedAt ?? e.startedAt);
109
109
  } catch {
110
110
  return false;
111
111
  }
@@ -213,7 +213,19 @@ export function checkTools({ home = HOME } = {}) {
213
213
  r.hint = hintOf(r, 'ko');
214
214
  tools[r.tool] = r;
215
215
  }
216
- return { platform: platform(), processes: canListProcesses(), tools, notifier: notifierCheck() };
216
+ const con = consoleCheck();
217
+ // Windows 는 프로세스 목록 방식(PowerShell CIM)과 걸린 시간을 함께 보인다 (#195). 그 밖의 OS 는 예전 모양 그대로.
218
+ const how = processMethod();
219
+ return { platform: platform(), processes: canListProcesses(), ...(how ? { processMethod: how } : {}), tools, notifier: notifierCheck(), ...(con ? { console: con } : {}) };
220
+ }
221
+
222
+ // Windows 의 터미널이 구형 콘솔(conhost)로 보이는지. Windows Terminal(WT_SESSION), VS Code·WezTerm(TERM_PROGRAM),
223
+ // ConEmu(ConEmuANSI), mintty 같은 TERM 을 넣는 터미널이면 아니라고 본다. win32 가 아니면 null.
224
+ // 구형 콘솔의 기본 글꼴에는 ▕█░ 막대와 점자(⠋, 로고 ⣠⣴⣾)가 없어 네모로 보일 수 있다 (#198).
225
+ export function consoleCheck({ platform: plat = platform(), env = process.env } = {}) {
226
+ if (plat !== 'win32') return null;
227
+ const modern = Boolean(env.WT_SESSION || env.TERM_PROGRAM || env.ConEmuANSI || env.TERM);
228
+ return { legacy: !modern };
217
229
  }
218
230
 
219
231
  // 알림 도구와, notify-send 면 D-Bus 세션 버스를 찾을 수 있는지 (#250). 알림을 실제로 보내 보지는 않는다.
@@ -237,7 +249,7 @@ export function notifierText(n, plat = platform(), lang = getLang(), wsl = plat
237
249
  }
238
250
  if (n) return tr('doctor.notifier', { kind: n.kind, path: n.path }, o);
239
251
  if (wsl) return [tr('doctor.noNotifierWsl', null, o), hint('doctor.wslHint')].join('\n');
240
- const want = plat === 'darwin' ? 'osascript' : 'notify-send';
252
+ const want = plat === 'darwin' ? 'osascript' : plat === 'win32' ? 'powershell.exe' : 'notify-send';
241
253
  return tr('doctor.noNotifier', { want }, o);
242
254
  }
243
255
 
@@ -269,7 +281,10 @@ export function describe(t, now = Date.now(), lang = getLang()) {
269
281
  // aitop --doctor 의 사람용 출력.
270
282
  export function doctorText(result, version, now = Date.now(), lang = getLang()) {
271
283
  const o = { lang };
272
- const os = tr('doctor.os', { platform: result.platform, state: tr(result.processes ? 'doctor.procsOk' : 'doctor.procsNo', null, o) }, o);
284
+ const pm = result.processMethod;
285
+ const why = pm?.error ? tr(pm.error === 'timeout' ? 'doctor.procsTimeout' : 'doctor.procsFailed', null, o) : '';
286
+ const how = pm?.kind === 'cim' ? tr('doctor.procsCim', { s: pm.ms == null ? '?' : (pm.ms / 1000).toFixed(1) }, o) + why : '';
287
+ const os = tr('doctor.os', { platform: result.platform, state: tr(result.processes ? 'doctor.procsOk' : 'doctor.procsNo', null, o) + how }, o);
273
288
  const out = [tr('doctor.title', { logo: BRAND.logo, version, os }, o), ''];
274
289
  for (const t of Object.values(result.tools)) {
275
290
  const d = describe(t, now, lang);
@@ -284,6 +299,7 @@ export function doctorText(result, version, now = Date.now(), lang = getLang())
284
299
  }
285
300
  }
286
301
  if ('notifier' in result) out.push('', notifierText(result.notifier, result.platform, lang));
302
+ if (result.console?.legacy) out.push('', tr('doctor.legacyConsole', null, o), ` → ${tr('doctor.legacyConsoleHint', null, o)}`);
287
303
  // 설정 파일: 무시한 키와 값, 받지 않은 onWaiting 을 알린다.
288
304
  const cfg = result.config;
289
305
  if (cfg) {
package/src/i18n.mjs CHANGED
@@ -82,10 +82,10 @@ const HELP_KO = `{logo} aitop - 터미널에서 Claude Code · Codex · Antigrav
82
82
  같은 도구 연속 호출은 Grep ×38 처럼 묶고, 깊은 가지는 접는다. 명령·경로 같은 인자와 지시 글은 --show-prompts 일 때만
83
83
  aitop --doctor Claude · Codex · Antigravity · Gemini 기록과 실행 중인 프로세스, 설정 파일을 점검한다 (--json 과 함께 쓸 수 있다)
84
84
  aitop --bell 응답 대기 세션이 새로 생기면 터미널 벨을 울린다
85
- aitop --notify 응답 대기 세션이 새로 생기면 데스크톱 알림을 띄운다 (Linux notify-send · macOS osascript · WSL 은 powershell.exe 로 Windows 알림, 없으면 건너뜀)
85
+ aitop --notify 응답 대기 세션이 새로 생기면 데스크톱 알림을 띄운다 (Linux notify-send · macOS osascript · WSL·Windows 는 powershell.exe 로 Windows 알림, 없으면 건너뜀)
86
86
  aitop --notify=waiting,done,context 알릴 종류를 고른다 (--notify 만 주면 설정 파일 notify 배열, 없으면 waiting). done: 3분(설정 파일 doneMinutes, 응답 대기 시간 빼고) 넘게 작업하던 세션이 다음 지시를
87
87
  기다리면 한 번. context: 컨텍스트가 90% 를 넘으면 한 번 (85% 아래로 내려가면 다시)
88
- aitop --on-waiting <명령> 알릴 일이 생기면 /bin/sh -c 로 명령을 실행한다 (내 권한으로 실행, 10초 제한). 종류는 --notify 를 따른다 (--no-notify 여도)
88
+ aitop --on-waiting <명령> 알릴 일이 생기면 /bin/sh -c (Windows 는 cmd.exe /c) 로 명령을 실행한다 (내 권한으로 실행, 10초 제한). 종류는 --notify 를 따른다 (--no-notify 여도)
89
89
  세션 정보는 환경변수로만: AITOP_EVENT(waiting|done|context) AITOP_TOOL AITOP_PROJECT AITOP_SESSION_ID AITOP_CWD AITOP_WAITING_FOR
90
90
  aitop --show-requests 응답 대기 요청 전체를 상세 패널·--json 에 보인다 (AITOP_SHOW_REQUESTS=1). 비밀값 가림은 최선일 뿐이라 명령 속 비밀값이 보일 수 있다
91
91
  aitop --budget-day <달러> 하루 예산. 헤더에 오늘 $12.30/$50 처럼 보이고, 오늘 끝 예상 비용(오늘 + 최근 속도 × 자정까지, 늘 API 환산)이
@@ -144,10 +144,10 @@ const HELP_EN = `{logo} aitop - watch Claude Code, Codex, Antigravity and Gemini
144
144
  Repeated calls of one tool are grouped like Grep ×38 and deep branches are folded. Arguments and prompt text only with --show-prompts
145
145
  aitop --doctor check Claude, Codex, Antigravity and Gemini logs, running processes and the config file (works with --json)
146
146
  aitop --bell ring the terminal bell when a session starts waiting for you
147
- aitop --notify show a desktop notification when a session starts waiting (notify-send on Linux, osascript on macOS, a Windows toast via powershell.exe on WSL; skipped if missing)
147
+ aitop --notify show a desktop notification when a session starts waiting (notify-send on Linux, osascript on macOS, a Windows toast via powershell.exe on WSL and Windows; skipped if missing)
148
148
  aitop --notify=waiting,done,context pick what to notify about (plain --notify: the config notify list, else waiting). done: once when a session that worked for
149
149
  over 3 minutes (config doneMinutes, approval waits not counted) waits for its next instruction. context: once when context passes 90% (again after it drops below 85%)
150
- aitop --on-waiting <cmd> run a command with /bin/sh -c when there is something to notify (runs as you, 10 second limit). Follows the --notify kinds (even with --no-notify)
150
+ aitop --on-waiting <cmd> run a command with /bin/sh -c (cmd.exe /c on Windows) when there is something to notify (runs as you, 10 second limit). Follows the --notify kinds (even with --no-notify)
151
151
  Session info is passed only in env vars: AITOP_EVENT(waiting|done|context) AITOP_TOOL AITOP_PROJECT AITOP_SESSION_ID AITOP_CWD AITOP_WAITING_FOR
152
152
  aitop --show-requests show full waiting requests in the detail panel and --json (AITOP_SHOW_REQUESTS=1). Secret masking is best effort, so secrets in commands may show
153
153
  aitop --budget-day <usd> daily budget. The header shows today $12.30/$50, and it warns when the projected end-of-day cost (today + recent rate until midnight, always API cost)
@@ -328,6 +328,7 @@ export const STRINGS = {
328
328
  'cfg.badValue': '{key} 값 {value} 이 잘못되어 무시합니다 ({expect})',
329
329
  'cfg.badEnv': '환경 변수 {name} 값 {value} 이 잘못되어 무시합니다 ({expect})',
330
330
  'cfg.onWaitingIgnored': 'onWaiting 은 무시합니다: {why}. chmod 600 으로 고치세요',
331
+ 'cfg.onWaitingIgnoredWin': 'onWaiting 은 무시합니다: 설정 파일이 사용자 프로필(%USERPROFILE%) 밖에 있어 다른 사용자가 고칠 수 있음. 프로필 아래(%APPDATA%\\aitop)로 옮기세요',
331
332
  'cfg.notMine': '파일 소유자가 현재 사용자가 아님',
332
333
  'cfg.shared': '그룹·다른 사용자가 쓸 수 있음 (mode {mode})',
333
334
  'cfg.either': '{a} 또는 {b}',
@@ -343,6 +344,9 @@ export const STRINGS = {
343
344
  'doctor.os': '{platform}, 프로세스 {state}',
344
345
  'doctor.procsOk': '확인 가능',
345
346
  'doctor.procsNo': '확인 불가',
347
+ 'doctor.procsCim': ' · PowerShell CIM {s}초',
348
+ 'doctor.procsTimeout': ', 시간 초과',
349
+ 'doctor.procsFailed': ', 실패',
346
350
  'doctor.state.ok': '찾음',
347
351
  'doctor.state.missing': '없음',
348
352
  'doctor.state.limited': '일부 지원',
@@ -353,7 +357,7 @@ export const STRINGS = {
353
357
  'doctor.candidateHintClaude': '읽으려면 설정 파일 claudeDirs 배열에 넣거나 AITOP_CLAUDE_DIRS 로 주세요 (예: ["~/.claude", "~/.claude-work"])',
354
358
  'doctor.candidateHintCodex': '읽으려면 설정 파일 codexHomes 배열에 넣거나 AITOP_CODEX_HOMES 로 주세요 (예: ["~/.codex", "~/.codex-alt"])',
355
359
  'doctor.last': '마지막 {ago} 전',
356
- 'doctor.runningUnknown': '실행 수 확인 불가 (Linux·WSL·macOS 만 지원)',
360
+ 'doctor.runningUnknown': '실행 수 확인 불가 (프로세스 목록을 얻지 못함)',
357
361
  'doctor.running': '실행 {n}',
358
362
  'doctor.unreadable': '최근 기록 읽기 실패',
359
363
  'doctor.keys': '키: {keys}',
@@ -369,6 +373,8 @@ export const STRINGS = {
369
373
  'doctor.busMissing': 'DBUS_SESSION_BUS_ADDRESS 없음',
370
374
  'doctor.busSocket': '{path} 소켓 없음',
371
375
  'doctor.busHint': '데스크톱 세션 안에서 실행하거나 사용자 D-Bus(systemctl --user, dbus-launch)를 켠다. 대신 --on-waiting 으로 다른 알림 명령을 부를 수 있다',
376
+ 'doctor.legacyConsole': '! 터미널 구형 콘솔(conhost)로 보임 · ▕█░ 막대와 점자 글자(⠋, 로고)가 네모로 보일 수 있음',
377
+ 'doctor.legacyConsoleHint': 'Windows Terminal 을 권장한다. 이 콘솔을 쓴다면 AITOP_AMBIGUOUS=wide(표·막대를 ASCII 로)나 NO_COLOR(진행 막대를 [#.] 로)로 실행한다',
372
378
  'doctor.config': '{mark} 설정 {state}{path}',
373
379
  'doctor.configExists': '있음',
374
380
  'doctor.configMissing': '없음 (기본값)',
@@ -443,6 +449,8 @@ export const STRINGS = {
443
449
  'tools.ended': '종료된 세션 포함 (24시간)',
444
450
  'table.title': '세션 {n}',
445
451
  'member.stalled': '멈춘 듯',
452
+ 'member.sdk': '-p',
453
+ 'session.auto': '자동',
446
454
  'group.count': '{n}개',
447
455
  'group.waiting': '응답 대기',
448
456
  'group.pinned': '고정',
@@ -511,6 +519,8 @@ export const STRINGS = {
511
519
  'legend.elapsed': '팀원 행 끝: 팀원이 일을 시작한 뒤 지난 시간',
512
520
  'legend.stalledKey': '멈춘 듯',
513
521
  'legend.stalled': '팀원 기록이 3분(느린 도구 10분) 그대로. 짐작',
522
+ 'legend.sdk': '팀원 행: 이 세션이 띄운 claude -p 실행',
523
+ 'legend.auto': '부모 없는 claude -p 실행. 대기 알림 없음',
514
524
  'legend.status': '지금 단계. 큰 기록을 처음 읽는 동안은 기록 읽는 중 N%',
515
525
  'legend.tokens': '세션 누적 토큰 (서브에이전트 포함, 캐시 읽기 포함)',
516
526
  'legend.cost': 'API 정가로 환산한 비용 (Codex 는 OpenAI 정가 추정). 가격표에 없는 모델은 빼고 센다',
@@ -790,6 +800,7 @@ export const STRINGS = {
790
800
  'cfg.badValue': 'ignoring bad {key} value {value} ({expect})',
791
801
  'cfg.badEnv': 'ignoring bad env var {name} value {value} ({expect})',
792
802
  'cfg.onWaitingIgnored': 'ignoring onWaiting: {why}. Fix with chmod 600',
803
+ 'cfg.onWaitingIgnoredWin': 'ignoring onWaiting: the config file is outside your profile (%USERPROFILE%), so other users may be able to change it. Move it under your profile (%APPDATA%\\aitop)',
793
804
  'cfg.notMine': 'file is not owned by the current user',
794
805
  'cfg.shared': 'group or other users can write it (mode {mode})',
795
806
  'cfg.either': '{a} or {b}',
@@ -805,6 +816,9 @@ export const STRINGS = {
805
816
  'doctor.os': '{platform}, processes {state}',
806
817
  'doctor.procsOk': 'visible',
807
818
  'doctor.procsNo': 'not visible',
819
+ 'doctor.procsCim': ' · PowerShell CIM {s}s',
820
+ 'doctor.procsTimeout': ', timed out',
821
+ 'doctor.procsFailed': ', failed',
808
822
  'doctor.state.ok': 'found',
809
823
  'doctor.state.missing': 'missing',
810
824
  'doctor.state.limited': { long: 'partial support', short: 'partial' },
@@ -815,7 +829,7 @@ export const STRINGS = {
815
829
  'doctor.candidateHintClaude': 'to read it, add it to claudeDirs in the config file or AITOP_CLAUDE_DIRS (e.g. ["~/.claude", "~/.claude-work"])',
816
830
  'doctor.candidateHintCodex': 'to read it, add it to codexHomes in the config file or AITOP_CODEX_HOMES (e.g. ["~/.codex", "~/.codex-alt"])',
817
831
  'doctor.last': 'last {ago} ago',
818
- 'doctor.runningUnknown': 'cannot count running (Linux, WSL and macOS only)',
832
+ 'doctor.runningUnknown': 'cannot count running (no process list)',
819
833
  'doctor.running': 'running {n}',
820
834
  'doctor.unreadable': 'cannot read the latest log',
821
835
  'doctor.keys': 'keys: {keys}',
@@ -831,6 +845,8 @@ export const STRINGS = {
831
845
  'doctor.busMissing': 'DBUS_SESSION_BUS_ADDRESS not set',
832
846
  'doctor.busSocket': 'no socket at {path}',
833
847
  'doctor.busHint': 'run inside a desktop session or start a user D-Bus (systemctl --user, dbus-launch). Or call another notifier with --on-waiting',
848
+ 'doctor.legacyConsole': '! console legacy console (conhost) · ▕█░ bars and braille (⠋, logo) may show as boxes',
849
+ 'doctor.legacyConsoleHint': 'Windows Terminal is recommended. In this console, run with AITOP_AMBIGUOUS=wide (ASCII tables and bars) or NO_COLOR (progress bar as [#.])',
834
850
  'doctor.config': '{mark} config {state}{path}',
835
851
  'doctor.configExists': 'found',
836
852
  'doctor.configMissing': 'not found',
@@ -898,6 +914,8 @@ export const STRINGS = {
898
914
  'tools.ended': 'with ended sessions (24h)',
899
915
  'table.title': 'Sessions {n}',
900
916
  'member.stalled': 'stalled?',
917
+ 'member.sdk': '-p',
918
+ 'session.auto': 'auto',
901
919
  'group.count': '{n}',
902
920
  'group.waiting': 'Waiting',
903
921
  'group.pinned': 'Pinned',
@@ -965,6 +983,8 @@ export const STRINGS = {
965
983
  'legend.elapsed': 'Subagent row end: time since it started',
966
984
  'legend.stalledKey': 'stalled?',
967
985
  'legend.stalled': 'No log change 3 min (slow tools 10). A guess',
986
+ 'legend.sdk': 'Member row: claude -p run of this session',
987
+ 'legend.auto': 'claude -p run with no parent. No wait alerts',
968
988
  'legend.status': 'Current step (Reading log N% on first load)',
969
989
  'legend.tokens': 'Tokens incl. subagents and cache reads',
970
990
  'legend.cost': 'API cost (Codex estimated). Unpriced models not counted',
package/src/json.mjs CHANGED
@@ -40,6 +40,10 @@ 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).
44
+ // 부모를 찾은 claude -p 실행은 여기 없고 부모의 members 에 entrypoint·parentId 와 함께 들어간다 (합계도 부모에 더해져 있다).
45
+ entrypoint: s.entrypoint ?? null,
46
+ auto: Boolean(s.auto),
43
47
  pid: s.pid ?? null,
44
48
  live: Boolean(s.live),
45
49
  status: s.status,
@@ -69,7 +73,7 @@ export function toJson(data, version = null, opts = {}) {
69
73
  files: (s.files ?? []).map((f) => ({ path: f.path, created: Boolean(f.created), edits: f.edits, writtenLines: f.add, deletedLines: f.del, updatedAt: iso(f.at), agents: f.agents ?? [] })),
70
74
  // startedAt·lastActivityAt 은 세션의 startedAt·updatedAt 과 같은 ISO 시각이다 (모르면 null).
71
75
  // stalled 는 화면의 '멈춘 듯' 과 같은 짐작(common.mjs memberStalled)을 data.at 기준으로 본 값이다.
72
- members: (s.members ?? []).map((m) => ({ name: m.name, task: m.task ?? null, model: m.model ?? null, status: m.status, phase: koPhase(m.phase), phaseKind: m.phase?.kind ?? null, tokens: m.tokens ?? 0, cost: money(m.cost), startedAt: iso(m.startedAt), lastActivityAt: iso(m.lastActivityAt), stalled: memberStalled(m, data.at ?? Date.now(), s.status) })),
76
+ members: (s.members ?? []).map((m) => ({ ...(m.sdk ? { id: m.id, entrypoint: m.entrypoint ?? null, parentId: m.parentId ?? s.id } : {}), name: m.name, task: m.task ?? null, model: m.model ?? null, status: m.status, phase: koPhase(m.phase), phaseKind: m.phase?.kind ?? null, tokens: m.tokens ?? 0, cost: money(m.cost), startedAt: iso(m.startedAt), lastActivityAt: iso(m.lastActivityAt), stalled: memberStalled(m, data.at ?? Date.now(), s.status) })),
73
77
  })),
74
78
  };
75
79
  }
package/src/log.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  // 기록 형식이 바뀌어 값이 비는 원인을 찾기 위한 것이라, 오류 이름·코드와 짧은 맥락(출처, 파일 이름)만 쓴다.
3
3
  // 기록 내용·도구 입력은 쓰지 않고, 쓰는 글은 모두 mask() 와 stripControl() 을 거친다.
4
4
  // 꺼져 있으면 파일을 만들지 않고 debug() 는 바로 돌아간다.
5
- import { closeSync, constants, fchmodSync, fstatSync, mkdirSync, openSync, renameSync, statSync, writeSync } from 'node:fs';
5
+ import { closeSync, constants, fchmodSync, fstatSync, mkdirSync, openSync, statSync, writeSync } from 'node:fs';
6
+ import { renameSync } from './rename.mjs';
6
7
  import { homedir } from 'node:os';
7
8
  import { basename, dirname, posix, win32 } from 'node:path';
8
9
  import { appDir } from './paths.mjs';
package/src/monthly.mjs CHANGED
@@ -11,7 +11,8 @@
11
11
  // (다음 기회에 다시 접는다), pid 별 임시 파일에 쓴 뒤 rename 한다.
12
12
  //
13
13
  // 값마다 사용량 벡터(입력·출력·캐시 읽기·캐시 쓰기 5분·1시간, fast 모드는 따로)를 남겨, 가격표가 바뀌면 지금 가격으로 다시 계산한다.
14
- import { readFileSync, writeFileSync, mkdirSync, renameSync, rmSync } from 'node:fs';
14
+ import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'node:fs';
15
+ import { renameSync } from './rename.mjs';
15
16
  import { dirname, join } from 'node:path';
16
17
  import { CACHE_ROOT } from './cache.mjs';
17
18
  import { PRICE_TAG, vecCost } from './pricing.mjs';