ai-battery 0.1.22 → 0.1.23

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
@@ -1,6 +1,6 @@
1
1
  # AI Battery
2
2
 
3
- 0.1.22: 기본 Codex 설치는 실행 명령·PATH·설정을 변경하지 않습니다. 이전 wrapper는 `setup codex`로 해제할 수 있고, 전체 `uninstall`은 통합 복원 후 캐시·전용 런타임·현재 npm 설치도 제거합니다. 기존 Bash 터미널에 삭제된 wrapper 경로가 남았다면 `hash -r`을 실행하세요.
3
+ 0.1.23: 기본 Codex 설치는 실행 명령·PATH·설정을 변경하지 않습니다. `reset settings`는 AI Battery의 설정 변경을 복원하고 생성 파일을 정리하며 npm 패키지는 유지합니다. 패키지 삭제는 `npm uninstall -g ai-battery`로 진행하세요. 기존 Bash 터미널에 삭제된 wrapper 경로가 남았다면 `hash -r`을 실행하세요.
4
4
 
5
5
  [한국어](README.md) · [English](docs/i18n/en/) · [日本語](docs/i18n/ja/) · [中文](docs/i18n/zh/) · [Español](docs/i18n/es/)
6
6
 
@@ -29,34 +29,34 @@ Markdown의 텍스트 fallback은 렌더러별 블록 문자 높이 차이를
29
29
  Codex 86% │ 5h 18:09 │ 7d 82% ┃ Claude 4% │ 5h 18:10 │ 7d 71%
30
30
  ```
31
31
 
32
- | Provider | Source | Shows |
33
- | --- | --- | --- |
34
- | Codex | `~/.codex/sessions/**/*.jsonl` | 5h 잔량, 5h 리셋 시각, 7d 잔량 |
35
- | Claude Code | Claude `statusLine` payload cache + 429 hit logs | 5h 잔량, 5h 리셋 시각, 7d 잔량 |
36
- | Claude fallback | `~/.claude/projects/**/*.jsonl` | 최근 턴 토큰 사용량 |
32
+ | Provider | Source | Shows |
33
+ | --------------- | ------------------------------------------------ | ------------------------------ |
34
+ | Codex | `~/.codex/sessions/**/*.jsonl` | 5h 잔량, 5h 리셋 시각, 7d 잔량 |
35
+ | Claude Code | Claude `statusLine` payload cache + 429 hit logs | 5h 잔량, 5h 리셋 시각, 7d 잔량 |
36
+ | Claude fallback | `~/.claude/projects/**/*.jsonl` | 최근 턴 토큰 사용량 |
37
37
 
38
38
  ## Features
39
39
 
40
- | Feature | Description |
41
- | --- | --- |
42
- | 공통 사용량 표시 | Codex와 Claude Code 사용량을 같은 형식으로 표시합니다. |
43
- | 리셋 시각 표시 | `5h`, `7d` 창 라벨과 값을 표시합니다. |
44
- | 색상 기준 | 40% 초과 초록, 21-40% 주황, 20% 이하 빨강으로 배터리만 강조합니다. |
45
- | Codex terminal row | Windows에서는 가상 터미널 화면과 배터리 행을 합성하고, WSL/Linux/macOS에서는 PTY wrapper로 별도 사용량 행을 고정합니다. |
46
- | Claude statusLine | Claude Code 내장 statusLine hook과 실제 429 hit 로그로 Claude rate limit 상태를 읽습니다. |
47
- | HUD / menu bar | Windows native에서는 terminal-docked/floating HUD, WSL에서는 floating HUD, macOS에서는 menu bar status item을 제공합니다. |
48
- | npm 실행 | `npm install -g` 또는 `npx`로 실행할 수 있습니다. |
40
+ | Feature | Description |
41
+ | ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
42
+ | 공통 사용량 표시 | Codex와 Claude Code 사용량을 같은 형식으로 표시합니다. |
43
+ | 리셋 시각 표시 | `5h`, `7d` 창 라벨과 값을 표시합니다. |
44
+ | 색상 기준 | 40% 초과 초록, 21-40% 주황, 20% 이하 빨강으로 배터리만 강조합니다. |
45
+ | Codex terminal row | Windows에서는 가상 터미널 화면과 배터리 행을 합성하고, WSL/Linux/macOS에서는 PTY wrapper로 별도 사용량 행을 고정합니다. |
46
+ | Claude statusLine | Claude Code 내장 statusLine hook과 실제 429 hit 로그로 Claude rate limit 상태를 읽습니다. |
47
+ | HUD / menu bar | Windows native에서는 terminal-docked/floating HUD, WSL에서는 floating HUD, macOS에서는 menu bar status item을 제공합니다. |
48
+ | npm 실행 | `npm install -g` 또는 `npx`로 실행할 수 있습니다. |
49
49
 
50
50
  ## Platform Support
51
51
 
52
- | Mode | Windows native | WSL | Linux | macOS | Note |
53
- | --- | --- | --- | --- | --- | --- |
54
- | `ai-battery` | 지원 | 지원 | 지원 | 지원 | Node.js 18 이상이 필요합니다. |
55
- | `ai-battery --watch` | 지원 | 지원 | 지원 | 지원 | 터미널 안에서 주기적으로 갱신합니다. |
56
- | Claude statusLine | 지원 | 지원 | 지원 | 지원 | Claude Code `statusLine`에 `node <script>` 명령을 저장합니다. |
57
- | Codex fullscreen | 지원 | 지원 | 지원 | 지원 | Windows 기본값은 Fullscreen PTY 화면과 터미널 배터리 행을 합성합니다. WSL/Linux/macOS는 POSIX PTY와 `python3`를 사용합니다. |
58
- | `ai-battery setup codex` | 지원 | 지원 | 지원 | 지원 | 기존 AI Battery wrapper를 해제합니다. 새 wrapper나 Codex 설정 변경은 명시적 옵션이 필요합니다. |
59
- | `ai-battery hud` | 지원 | 지원 | 미지원 | 지원 | Windows/WSL은 PowerShell/WinForms HUD, macOS는 menu bar status item입니다. |
52
+ | Mode | Windows native | WSL | Linux | macOS | Note |
53
+ | ------------------------ | -------------- | ---- | ------ | ----- | --------------------------------------------------------------------------------------------------------------------------- |
54
+ | `ai-battery` | 지원 | 지원 | 지원 | 지원 | Node.js 18 이상이 필요합니다. |
55
+ | `ai-battery --watch` | 지원 | 지원 | 지원 | 지원 | 터미널 안에서 주기적으로 갱신합니다. |
56
+ | Claude statusLine | 지원 | 지원 | 지원 | 지원 | Claude Code `statusLine`에 `node <script>` 명령을 저장합니다. |
57
+ | Codex fullscreen | 지원 | 지원 | 지원 | 지원 | Windows 기본값은 Fullscreen PTY 화면과 터미널 배터리 행을 합성합니다. WSL/Linux/macOS는 POSIX PTY와 `python3`를 사용합니다. |
58
+ | `ai-battery setup codex` | 지원 | 지원 | 지원 | 지원 | 기존 AI Battery wrapper를 해제합니다. 새 wrapper나 Codex 설정 변경은 명시적 옵션이 필요합니다. |
59
+ | `ai-battery hud` | 지원 | 지원 | 미지원 | 지원 | Windows/WSL은 PowerShell/WinForms HUD, macOS는 menu bar status item입니다. |
60
60
 
61
61
  실행 중 감지는 Linux/WSL은 `/proc`, macOS는 `ps`, Windows는 PowerShell 프로세스 목록을 사용합니다. 텍스트 출력은 흰색/회색으로, macOS HUD는 실행 중인 항목만 색상 배터리바로 강조하고 비실행 항목은 흐린 회색 계열로 표시합니다.
62
62
 
@@ -111,52 +111,55 @@ ai-battery --version
111
111
  ai-battery --provider codex
112
112
  ai-battery --provider claude
113
113
  ai-battery setup
114
- ai-battery uninstall
114
+ ai-battery reset settings
115
115
  ai-battery doctor
116
116
  ai-battery hud
117
117
  ai-battery off codex
118
118
  ai-battery on codex
119
119
  ```
120
120
 
121
- | Option | Description |
122
- | --- | --- |
123
- | `--provider all\|codex\|claude` | 표시할 provider를 선택합니다. |
124
- | `--watch [seconds]` | 같은 줄에서 주기적으로 갱신합니다. |
125
- | `--json` | HUD나 다른 도구에서 쓰기 좋은 JSON을 출력합니다. |
126
- | `--bar-width N` | 터미널 배터리 바 길이를 조정합니다. |
127
- | `--show-paths` | 로그 파일 경로와 데이터 관측 시각을 함께 표시합니다. |
128
- | `-v`, `--version` | 설치된 `ai-battery` 버전을 출력합니다. |
121
+ | Option | Description |
122
+ | ------------------------------- | ---------------------------------------------------- |
123
+ | `--provider all\|codex\|claude` | 표시할 provider를 선택합니다. |
124
+ | `--watch [seconds]` | 같은 줄에서 주기적으로 갱신합니다. |
125
+ | `--json` | HUD나 다른 도구에서 쓰기 좋은 JSON을 출력합니다. |
126
+ | `--bar-width N` | 터미널 배터리 바 길이를 조정합니다. |
127
+ | `--show-paths` | 로그 파일 경로와 데이터 관측 시각을 함께 표시합니다. |
128
+ | `-v`, `--version` | 설치된 `ai-battery` 버전을 출력합니다. |
129
129
 
130
130
  `doctor`는 설치 상태와 함께 npm latest 버전을 확인합니다. 네트워크가 막혀 있으면 버전 확인만 건너뛰고 나머지 진단은 계속 표시합니다.
131
131
 
132
- ## Uninstall
132
+ <a id="uninstall"></a>
133
133
 
134
- `off`는 표시만 숨깁니다. 인자 없는 `uninstall`은 통합을 복원하고, 소유권을 확인한 AI Battery 캐시·전용 런타임·별칭과 현재 실행 중인 npm 설치까지 제거합니다. 개발 checkout이나 임시 npx 실행에서는 npm 프로젝트를 삭제하지 않습니다.
134
+ ## Reset Settings
135
+
136
+ `ai-battery reset settings`는 AI Battery가 추가한 통합 설정을 원래 값으로 복원하고, 소유권을 확인한 AI Battery 캐시·전용 런타임·생성 파일을 정리합니다. Codex·Claude의 관련 없는 설정과 npm 패키지·실행 명령은 유지합니다. Codex나 Claude의 설정 전체를 기본값으로 초기화하는 명령은 아닙니다.
135
137
 
136
138
  ```bash
137
- ai-battery uninstall
139
+ ai-battery reset settings
138
140
  ```
139
141
 
140
- 통합만 해제하고 패키지는 유지하려면 `ai-battery teardown`을 사용합니다. 아래처럼 특정 통합만 제거할 수도 있습니다.
142
+ `ai-battery reset config`도 같은 동작입니다. 일부 통합만 복원하려면 대상을 지정합니다. 대상 지정 시 다른 통합과 공통 캐시는 유지합니다.
141
143
 
142
144
  ```bash
143
- ai-battery uninstall codex
144
- ai-battery uninstall claude
145
- ai-battery uninstall hud
145
+ ai-battery reset settings codex
146
+ ai-battery reset settings claude
147
+ ai-battery reset settings hud
148
+ ai-battery reset settings tmux
146
149
  ```
147
150
 
148
- 이 명령은 AI Battery가 관리 마커를 넣은 Codex wrapper, Codex `[tui].status_line`, Claude `statusLine`, HUD/menu bar autostart와 실행 중인 HUD를 정리합니다. 다른 도구가 만든 `codex` 파일이나 Claude `statusLine`은 건드리지 않습니다. setup 전에 복구 기록을 먼저 저장하며, 이후 사용자가 추가한 관련 없는 Codex/Claude 설정은 보존하고 AI Battery가 관리한 값만 원래 값으로 되돌립니다. 관리 중인 status line 자체나 wrapper 파일이 setup 이후 다른 값으로 바뀌었다면 덮어쓰거나 삭제하지 않고 복구 기록과 PATH를 유지한 채 종료 코드 1로 알립니다. 원본 command backup이 있는 wrapper는 현재 wrapper를 임시 보존한 뒤 원본 교체가 성공한 경우에만 삭제합니다. 현재 이미 AI Battery wrapper 안에서 실행 중인 Codex 세션의 terminal row는 그 세션을 종료해야 사라집니다.
149
-
150
- 복구 기록은 `ai-battery uninstall`이 해당 항목을 성공적으로 복원하거나 안전하게 제거한 뒤에만 지워집니다. Claude는 기존 `statusLine`과 파일 존재 여부·권한만 저장하며 `settings.json` 전체를 복제하지 않으므로 다른 설정이나 비밀값을 백업 파일에 중복 보관하지 않습니다. JSON 결과나 종료 코드를 확인하는 자동화에서는 0일 때만 완전한 정리로 간주하세요.
151
+ 관리 중인 status line이나 설정 블록이 사용자에 의해 변경됐다면 덮어쓰지 않고 복구 기록을 보존하며 종료 코드 1로 알립니다. 관련 없는 Codex·Claude 설정, 사용자 추가 파일, 확인할 수 없는 파일은 보존합니다. 셸·tmux의 사용자 수정도 관리 블록 밖의 내용은 유지합니다. 복구 기록은 해당 항목이 복원되거나 안전하게 제거된 뒤에만 지워집니다.
151
152
 
152
- 전체 삭제는 통합 복원에 성공한 경우에만 npm 제거로 진행합니다. 수정된 관리 블록, 확인할 수 없는 파일과 복구 기록은 보존하고 결과에 경로를 표시합니다. 같은 폴더에 사용자가 추가한 파일이나 다른 npm 패키지는 삭제하지 않습니다. Windows와 WSL에 각각 설치했다면 각 설치에서 실행하세요.
153
+ 패키지까지 삭제하려면 설정 복원이 성공한 다음 npm으로 제거합니다. 로컬 설치는 `npm uninstall ai-battery`, 전역 설치는 아래 명령을 사용합니다. Windows와 WSL, Node 버전별 설치는 각각 진행하세요.
153
154
 
154
155
  ```bash
155
- ai-battery uninstall
156
+ ai-battery reset settings && npm uninstall -g ai-battery
156
157
  hash -r # Bash: 기존 터미널의 삭제된 wrapper 경로 캐시 해제 (zsh: rehash)
157
158
  ```
158
159
 
159
- 자식 프로세스인 CLI는 부모 셸의 명령 캐시를 지울 수 없습니다. 새 터미널을 열어도 캐시는 초기화됩니다. 현대 npm은 외부 통합을 정리하는 uninstall lifecycle을 실행하지 않으므로 `npm uninstall -g ai-battery`만 실행했던 구버전 사용자는 패키지를 다시 설치하고 `ai-battery uninstall`로 통합부터 정리하세요.
160
+ CLI는 npm 제거를 자동 실행하지 않습니다. `teardown`과 `uninstall`은 호환용 별칭으로 남아 있으며, 동일하게 설정과 생성 파일만 정리합니다. `off`는 표시만 숨깁니다. 이미 npm 패키지를 먼저 지웠다면 다시 설치하고 `reset settings`로 통합부터 복원하세요.
161
+
162
+ 자식 프로세스인 CLI는 부모 셸의 명령 캐시를 지울 수 없습니다. 새 터미널을 열어도 캐시는 초기화됩니다. 이미 wrapper로 시작한 Codex 세션의 하단 행은 해당 세션을 종료해야 사라집니다.
160
163
 
161
164
  ## Setup
162
165
 
@@ -175,7 +178,7 @@ ai-battery setup codex
175
178
 
176
179
  Codex 실행 경로를 그대로 유지하려면 `ai-battery --watch 2` 또는 `ai-battery hud`를 사용하세요. 하단 행을 실행 세션 하나에만 추가하려면 POSIX에서는 `ai-battery-run -- codex`, Windows에서는 `ai-battery-run-win -- codex`를 직접 실행합니다.
177
180
 
178
- 기존처럼 `codex` 명령에 wrapper를 연결하려는 경우에만 `ai-battery setup codex --wrap-codex`를 사용합니다. Codex `[tui].status_line` 변경도 별도 옵션인 `--configure-codex-statusline`이 필요합니다. 두 옵션은 실행 경로나 사용자 설정을 변경하므로 기본값에서 제외되어 있습니다. 관리형 변경은 복구 기록을 먼저 저장하고, uninstall 시 해당 변경만 복원합니다.
181
+ 기존처럼 `codex` 명령에 wrapper를 연결하려는 경우에만 `ai-battery setup codex --wrap-codex`를 사용합니다. Codex `[tui].status_line` 변경도 별도 옵션인 `--configure-codex-statusline`이 필요합니다. 두 옵션은 실행 경로나 사용자 설정을 변경하므로 기본값에서 제외되어 있습니다. 관리형 변경은 복구 기록을 먼저 저장하고, `reset settings`에서 해당 변경만 복원합니다.
179
182
 
180
183
  다음 Windows runner 설명은 직접 runner를 실행하거나 wrapper를 명시적으로 선택한 경우에 적용됩니다.
181
184
 
@@ -195,7 +198,7 @@ tmux에서는 pane마다 하단 행을 예약하면 같은 전역 배터리가 p
195
198
  ai-battery setup tmux
196
199
  ```
197
200
 
198
- `~/.tmux.conf`에 관리 블록을 추가해 status-right에 배터리를 표시하고(10초 간격 갱신), 이 tmux 안에서 실행되는 `codex`는 pane별 배터리 행을 생략하고 pane 전체를 사용합니다. Claude statusLine도 같은 환경에서는 배터리 행을 접고 header(모델·디렉터리·브랜치) 1행만 표시합니다 — 배터리는 tmux bar에 이미 있기 때문입니다. 적용하려면 `tmux source-file ~/.tmux.conf` 후 새 pane을 여세요. 이 블록은 기존 `status-right` 설정을 덮어쓰므로 `setup all`에 포함되지 않는 opt-in입니다. 해제는 `ai-battery uninstall tmux`, tmux 안에서도 pane별 행을 유지하려면 `AI_BATTERY_TMUX=row`를 설정합니다.
201
+ `~/.tmux.conf`에 관리 블록을 추가해 status-right에 배터리를 표시하고(10초 간격 갱신), 이 tmux 안에서 실행되는 `codex`는 pane별 배터리 행을 생략하고 pane 전체를 사용합니다. Claude statusLine도 같은 환경에서는 배터리 행을 접고 header(모델·디렉터리·브랜치) 1행만 표시합니다 — 배터리는 tmux bar에 이미 있기 때문입니다. 적용하려면 `tmux source-file ~/.tmux.conf` 후 새 pane을 여세요. 이 블록은 기존 `status-right` 설정을 덮어쓰므로 `setup all`에 포함되지 않는 opt-in입니다. 해제는 `ai-battery reset settings tmux`, tmux 안에서도 pane별 행을 유지하려면 `AI_BATTERY_TMUX=row`를 설정합니다.
199
202
 
200
203
  Codex 하단 행이 보이지 않으면 진단을 실행합니다.
201
204
 
@@ -271,7 +274,7 @@ ai-battery hud -Mode statusline -Position bottomcenter
271
274
  제거:
272
275
 
273
276
  ```bash
274
- ai-battery uninstall-claude-statusline
277
+ ai-battery reset settings claude
275
278
  ```
276
279
 
277
280
  Claude가 한 번 이상 statusLine payload를 전달해야 Claude의 사용량 캐시가 생성됩니다. 그 전에는 Claude 로컬 로그 기반 fallback이 표시됩니다.
@@ -291,21 +294,21 @@ Codex [battery:88] │ 5h 00:47 │ 7d 93%
291
294
  Claude [battery:76] │ 5h 00:47 │ 7d 59%
292
295
  ```
293
296
 
294
- | Command | Role |
295
- | --- | --- |
296
- | `ai-battery hud` / `ai-battery hud start` | Windows floating HUD 또는 macOS menu bar item을 시작합니다. |
297
- | `ai-battery hud stop` | 실행 중인 HUD/menu bar item을 종료합니다. (`--stop`도 동일) |
298
- | `ai-battery hud status` | HUD/menu bar 실행 여부와 autostart 등록 상태를 보여줍니다. |
299
- | `ai-battery hud autostart on` | Windows 로그인 또는 macOS 로그인 시 자동 실행을 등록합니다. |
300
- | `ai-battery hud autostart off` | 자동 실행 등록을 해제합니다. |
301
- | `ai-battery hud autostart status` | 자동 실행 등록 상태만 보여줍니다. |
302
- | `ai-battery hud -Foreground` | 디버깅용으로 터미널에 붙여 실행합니다. |
303
- | `ai-battery hud -Once` | 콘솔에서 한 번만 출력합니다. |
304
- | `ai-battery hud -Interval 2` | 갱신 주기를 바꿉니다. |
305
- | `ai-battery hud -Mode tray` | Windows tray icon 모드로 실행합니다. macOS에서는 menu bar item이 기본입니다. |
306
- | `ai-battery hud light` / `ai-battery hud dark` | Windows floating HUD를 밝은 작업표시줄용 검은 글자 또는 어두운 작업표시줄용 흰 글자로 바꿉니다. |
307
- | `ai-battery hud black` / `ai-battery hud white` | 글자색을 직접 검은색 또는 흰색으로 바꿉니다. |
308
- | `ai-battery hud --backdrop` / `ai-battery hud --no-backdrop` | Windows floating HUD 글자 뒤 어두운 backing을 켜거나 끕니다. |
297
+ | Command | Role |
298
+ | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
299
+ | `ai-battery hud` / `ai-battery hud start` | Windows floating HUD 또는 macOS menu bar item을 시작합니다. |
300
+ | `ai-battery hud stop` | 실행 중인 HUD/menu bar item을 종료합니다. (`--stop`도 동일) |
301
+ | `ai-battery hud status` | HUD/menu bar 실행 여부와 autostart 등록 상태를 보여줍니다. |
302
+ | `ai-battery hud autostart on` | Windows 로그인 또는 macOS 로그인 시 자동 실행을 등록합니다. |
303
+ | `ai-battery hud autostart off` | 자동 실행 등록을 해제합니다. |
304
+ | `ai-battery hud autostart status` | 자동 실행 등록 상태만 보여줍니다. |
305
+ | `ai-battery hud -Foreground` | 디버깅용으로 터미널에 붙여 실행합니다. |
306
+ | `ai-battery hud -Once` | 콘솔에서 한 번만 출력합니다. |
307
+ | `ai-battery hud -Interval 2` | 갱신 주기를 바꿉니다. |
308
+ | `ai-battery hud -Mode tray` | Windows tray icon 모드로 실행합니다. macOS에서는 menu bar item이 기본입니다. |
309
+ | `ai-battery hud light` / `ai-battery hud dark` | Windows floating HUD를 밝은 작업표시줄용 검은 글자 또는 어두운 작업표시줄용 흰 글자로 바꿉니다. |
310
+ | `ai-battery hud black` / `ai-battery hud white` | 글자색을 직접 검은색 또는 흰색으로 바꿉니다. |
311
+ | `ai-battery hud --backdrop` / `ai-battery hud --no-backdrop` | Windows floating HUD 글자 뒤 어두운 backing을 켜거나 끕니다. |
309
312
 
310
313
  Windows floating HUD는 기본적으로 투명 배경에 밝은 글자로 표시합니다. 밝은 작업표시줄에서는 `ai-battery hud light`, 어두운 작업표시줄에서는 `ai-battery hud dark`를 쓰면 됩니다. 글자색으로 직접 고르려면 `ai-battery hud black` 또는 `ai-battery hud white`를 쓰세요. 로그인 자동 실행에도 같은 모드를 저장하려면 `ai-battery hud autostart on light`처럼 붙이면 됩니다.
311
314
 
@@ -339,13 +342,13 @@ Codex는 최근 세션 로그에서 `rate_limits` 이벤트를 찾습니다. Cla
339
342
 
340
343
  ## Tech Stack
341
344
 
342
- | Layer | Technology | Role |
343
- | --- | --- | --- |
344
- | CLI | Node.js | 로그 파싱, Claude cache, ANSI/statusLine 출력 |
345
- | PTY row | Python 3 | Codex 실행용 reserved terminal row |
346
- | HUD launcher | Node.js / Bash compatibility wrapper | Windows native/WSL PowerShell HUD와 macOS menu bar 실행 |
347
- | HUD UI | PowerShell WinForms / AppleScriptObjC | Windows floating overlay, tray icon, macOS menu bar item |
348
- | Data | JSONL logs, statusLine JSON | Codex/Claude 사용량 소스 |
345
+ | Layer | Technology | Role |
346
+ | ------------ | ------------------------------------- | -------------------------------------------------------- |
347
+ | CLI | Node.js | 로그 파싱, Claude cache, ANSI/statusLine 출력 |
348
+ | PTY row | Python 3 | Codex 실행용 reserved terminal row |
349
+ | HUD launcher | Node.js / Bash compatibility wrapper | Windows native/WSL PowerShell HUD와 macOS menu bar 실행 |
350
+ | HUD UI | PowerShell WinForms / AppleScriptObjC | Windows floating overlay, tray icon, macOS menu bar item |
351
+ | Data | JSONL logs, statusLine JSON | Codex/Claude 사용량 소스 |
349
352
 
350
353
  ## Source Environment
351
354
 
package/docs/RELEASING.md CHANGED
@@ -5,8 +5,8 @@ The current release candidate is **0.1.22**. It includes the 0.1.21 usage-refres
5
5
  ## Changes in 0.1.22
6
6
 
7
7
  - Default `setup codex` restores legacy AI Battery integrations without creating a Codex wrapper, adding PATH entries or configuring Codex's status line. Use an independent watcher/HUD, or explicitly launch a runner for one session. `--wrap-codex` and `--configure-codex-statusline` are separate opt-ins.
8
- - Full `ai-battery uninstall` restores integrations, selectively removes verified caches and private runtimes, removes aliases belonging to this installation, and runs npm uninstall against the owning prefix. Other npm packages are preserved. `teardown` and targeted uninstall retain the package; development checkouts and npx do not remove an npm project.
9
- - Shell and tmux recovery records preserve exact original content, permissions and file absence. User edits outside managed blocks survive repeated setup and uninstall. Edited blocks, retargeted symlinks and unresolved recovery records prevent unsafe removal.
8
+ - `ai-battery reset settings` restores integrations and selectively removes verified caches, private runtimes and generated files. `reset config` is an alias. The CLI never invokes npm uninstall; all npm packages, package commands and local project manifests/lockfiles are preserved. `teardown` and `uninstall` remain compatibility aliases. Targeted reset restores only the selected integration.
9
+ - Shell and tmux recovery records preserve exact original content, permissions and file absence. User edits outside managed blocks survive repeated setup and reset. Edited blocks, retargeted symlinks and unresolved recovery records prevent unsafe removal.
10
10
  - Windows PATH cleanup preserves unrelated whitespace and separators and reports failed writes. HUD cleanup verifies its Run value and launcher ownership and preserves unknown files. macOS LaunchAgent cleanup refuses foreign files and symlinks.
11
11
  - Existing Bash terminals can cache a deleted legacy Codex wrapper. Run `hash -r` (zsh: `rehash`) or open a new terminal. A child CLI cannot clear its parent shell's command cache. A POSIX wrapper whose Python runner cannot start because Python is absent now runs the original Codex directly.
12
12
 
@@ -16,12 +16,12 @@ Checked on 2026-10-15:
16
16
 
17
17
  | Environment | Result |
18
18
  | --- | --- |
19
- | WSL `npm run check` | 155 passed, 16 platform skips, 0 failures |
20
- | Windows native Node 22.23.2 full suite | 132 passed, 39 platform skips, 0 failures |
19
+ | WSL `npm run check` | 156 passed, 16 platform skips, 0 failures |
20
+ | Windows native Node 22.23.2 full suite | 135 passed, 37 platform skips, 0 failures |
21
21
 
22
- Validation results and tarball manifests are stored in `.cache/releases/0.1.22/`. The regression suite covers default command/config preservation, exact shell restoration, user edits, symlinks, custom integration paths, incomplete recovery, npm failure, global/local prefix selection, actual self-uninstall in isolated installations, and Windows registry ownership. Desktop operations in the npm self-uninstall fixture are stubbed; Windows autostart cleanup is separately exercised against a temporary registry key and profile.
22
+ Validation results and tarball manifests are stored in `.cache/releases/0.1.22/`. The regression suite covers default command/config preservation, exact shell restoration, user edits, symlinks, custom integration paths, incomplete recovery, global/local package preservation, settings/config and compatibility aliases, HUD target parsing, invalid reset scopes, and Windows registry ownership. Desktop operations in the installed CLI fixture are stubbed; Windows autostart cleanup is separately exercised against a temporary registry key and profile.
23
23
 
24
- The current WSL installation was removed with the new cleanup helpers after successful teardown. Original shell, Codex and Claude settings and the original Codex launcher were byte-identical afterward. Codex and Claude still ran successfully. Previous manual test backups were preserved under `.cache/uninstall-audit/preserved-local-test-backups/`.
24
+ Reset behavior is tested in isolated global and local installations, with provider settings and original launchers compared byte for byte. npm removal is a separate explicit operation in the installed-tarball checks.
25
25
 
26
26
  Native Windows validation uses x64 Node 22.23.2. macOS LaunchAgent ownership and file handling are tested through an isolated fixture; native macOS and Windows ARM64 are not verified here.
27
27
 
@@ -57,10 +57,10 @@ ai-battery setup codex
57
57
 
58
58
  Default setup detaches a legacy wrapper. In an existing Bash terminal run `hash -r`; zsh uses `rehash`. Plain `codex` then runs independently. Display usage with `ai-battery --watch 2` or a supported desktop HUD. There is no built-in `ai-battery update` command.
59
59
 
60
- To remove the installation including npm:
60
+ Restore AI Battery settings first, then remove the package with npm only if restoration succeeded:
61
61
 
62
62
  ```text
63
- ai-battery uninstall
63
+ ai-battery reset settings && npm uninstall -g ai-battery
64
64
  ```
65
65
 
66
- Modified or unrecognized files are preserved and listed. A running wrapped session retains its loaded code until it exits. Cleanup of one npm prefix does not uninstall another Windows/WSL or Node-version installation.
66
+ Modified or unrecognized files are preserved and listed. A running wrapped session retains its loaded code until it exits. `reset config` is an alias for `reset settings`. The CLI never removes any npm installation. Use `npm uninstall ai-battery` for local installs; Windows/WSL and Node-version installations are managed separately.
package/lib/cli.js CHANGED
@@ -15,7 +15,7 @@ import { quoteWindowsCommandLineArg, rowptyExePath } from "./platforms/windows/c
15
15
  import { isWsl } from "./platforms/runtime.js";
16
16
  import { createProcessScanner } from "./platforms/process-scanner.js";
17
17
  import { createWindowsPathIntegration } from "./platforms/windows/path-integration.js";
18
- import { cleanupBatteryArtifacts, isBatteryConfig, planPackageRemoval, removeInstalledPackage } from "./core/uninstall.js";
18
+ import { cleanupBatteryArtifacts, isBatteryConfig } from "./core/uninstall.js";
19
19
  import { createIntegrationFiles } from "./core/integration-files.js";
20
20
  import {
21
21
  cacheAgeSeconds,
@@ -60,6 +60,7 @@ const DEFAULT_STATUSLINE_COLUMN_GUARD = 4;
60
60
  const COMMANDS = new Set([
61
61
  "show",
62
62
  "setup",
63
+ "reset",
63
64
  "teardown",
64
65
  "uninstall",
65
66
  "doctor",
@@ -117,19 +118,25 @@ function parseArgs(argv) {
117
118
  usageRow: "auto",
118
119
  help: false,
119
120
  version: false,
121
+ resetScope: null,
120
122
  targets: [],
121
123
  rest: []
122
124
  };
123
125
 
126
+ let commandSeen = false;
124
127
  for (let i = 0; i < argv.length; i += 1) {
125
128
  const arg = argv[i];
126
- if (!arg.startsWith("-") && COMMANDS.has(arg)) {
129
+ if (!commandSeen && !arg.startsWith("-") && COMMANDS.has(arg)) {
127
130
  args.command = arg;
131
+ commandSeen = true;
128
132
  if (arg === "hud") {
129
133
  args.rest = argv.slice(i + 1);
130
134
  break;
131
135
  }
132
- } else if (!arg.startsWith("-") && ["setup", "teardown", "uninstall", "on", "off"].includes(args.command)) {
136
+ } else if (!arg.startsWith("-") && args.command === "reset" && !args.resetScope) {
137
+ if (!["settings", "config"].includes(arg)) throw new Error("Usage: ai-battery reset settings|config [codex|claude|hud|tmux|all]");
138
+ args.resetScope = "settings";
139
+ } else if (!arg.startsWith("-") && ["setup", "reset", "teardown", "uninstall", "on", "off"].includes(args.command)) {
133
140
  args.targets.push(arg);
134
141
  } else if (arg === "--provider" || arg === "-p") {
135
142
  args.provider = argv[++i] || "all";
@@ -198,6 +205,9 @@ function parseArgs(argv) {
198
205
  }
199
206
  }
200
207
 
208
+ if (args.command === "reset" && !args.resetScope && !args.help && !args.version) {
209
+ throw new Error("Usage: ai-battery reset settings|config [codex|claude|hud|tmux|all]");
210
+ }
201
211
  if (!["all", "codex", "claude"].includes(args.provider)) {
202
212
  throw new Error("--provider must be one of: all, codex, claude");
203
213
  }
@@ -214,8 +224,7 @@ function printHelp() {
214
224
  Usage:
215
225
  ai-battery [options]
216
226
  ai-battery setup [codex|claude] [--force] [--wrap-codex]
217
- ai-battery uninstall [codex|claude|hud|tmux|all]
218
- ai-battery teardown [codex|claude|hud|tmux|all]
227
+ ai-battery reset settings [codex|claude|hud|tmux|all]
219
228
  ai-battery doctor
220
229
  ai-battery hud [start|stop|status] [hud options]
221
230
  ai-battery hud autostart on|off|status
@@ -224,10 +233,11 @@ Usage:
224
233
 
225
234
  Aliases:
226
235
  claudex-battery
236
+ ai-battery reset config [codex|claude|hud|tmux|all]
227
237
 
228
238
  Setup leaves Codex's command, PATH and configuration unchanged by default.
229
- Uninstall without targets restores integrations and removes its npm package.
230
- Teardown and targeted uninstall retain the package.
239
+ Reset settings restores AI Battery's integrations and cleans its generated files.
240
+ The npm package stays installed. Remove it separately: npm uninstall -g ai-battery
231
241
 
232
242
  Options:
233
243
  -p, --provider all|codex|claude Provider to show (default: all)
@@ -254,7 +264,8 @@ Options:
254
264
  Compatibility:
255
265
  ai-battery install-claude-statusline [--force]
256
266
  ai-battery uninstall-claude-statusline
257
- ai-battery teardown [codex|claude|hud|all]
267
+ ai-battery teardown [codex|claude|hud|tmux|all]
268
+ ai-battery uninstall [codex|claude|hud|tmux|all]
258
269
  `);
259
270
  }
260
271
 
@@ -1909,7 +1920,7 @@ function diagnoseCodex() {
1909
1920
  notes.push("Codex status_line is not configured. Run: ai-battery setup codex");
1910
1921
  }
1911
1922
  if (activeIsWrapper && !wrapperInstalled) {
1912
- notes.push("Plain \"codex\" still resolves to an AI Battery wrapper outside the configured shim. Run: ai-battery uninstall codex");
1923
+ notes.push("Plain \"codex\" still resolves to an AI Battery wrapper outside the configured shim. Run: ai-battery reset settings codex");
1913
1924
  }
1914
1925
  if (activeWrapperBackup) {
1915
1926
  notes.push(`A Codex backup is available for restore: ${activeWrapperBackup}`);
@@ -2267,7 +2278,7 @@ function runSetup(args) {
2267
2278
  standalone: !failed,
2268
2279
  skipped: failed,
2269
2280
  legacyCleanup,
2270
- reason: failed ? "Could not safely detach the legacy Codex integration; kept recovery metadata. Run ai-battery teardown codex for details."
2281
+ reason: failed ? "Could not safely detach the legacy Codex integration; kept recovery metadata. Run ai-battery reset settings codex for details."
2271
2282
  : "Codex command and configuration are left under Codex's control. Use ai-battery hud or ai-battery-run -- codex for usage display."
2272
2283
  };
2273
2284
  // An explicit status-line request is applied after legacy restoration.
@@ -2379,30 +2390,24 @@ function runTeardown(args) {
2379
2390
  runStep("hud", uninstallHud);
2380
2391
  }
2381
2392
  if (targets.includes("codex")) runStep("rowpty", uninstallRowPtyHost);
2382
- const fullUninstall = args.command === "uninstall" && (!args.targets.length || args.targets.includes("all"));
2383
- if (fullUninstall && !teardownResultFailed({ results })) {
2393
+ const fullReset = !args.targets.length || args.targets.includes("all");
2394
+ if (fullReset && !teardownResultFailed({ results })) {
2384
2395
  const pending = Object.keys(readConfig({ strict: true }).integrationFiles || {});
2385
2396
  if (pending.length) {
2386
- results.recovery = { error: "Unrestored integration files remain; kept recovery metadata and npm package", paths: pending };
2387
- return { targets, fullUninstall, results };
2388
- }
2389
- const plan = planPackageRemoval(path.resolve(scriptDir(), ".."));
2390
- if (plan.error) {
2391
- results.package = plan;
2392
- } else {
2393
- const roots = [stateDir(), dataDir(), path.join(os.tmpdir(), "ai-battery")];
2394
- if (process.platform === "win32" && process.env.LOCALAPPDATA) roots.push(path.join(process.env.LOCALAPPDATA, "ai-battery"));
2395
- results.artifacts = cleanupBatteryArtifacts({
2396
- roots,
2397
- home: userHome(),
2398
- protectedRoots: [codexRuntimeHome(), homePath(".claude"), path.resolve(scriptDir(), "..")]
2399
- });
2400
- if (!results.artifacts.errors.length) results.package = removeInstalledPackage(plan, { home: userHome() });
2397
+ results.recovery = { error: "Unrestored integration files remain; kept recovery metadata", paths: pending };
2398
+ return { targets, fullReset, results };
2401
2399
  }
2400
+ const roots = [stateDir(), dataDir(), path.join(os.tmpdir(), "ai-battery")];
2401
+ if (process.platform === "win32" && process.env.LOCALAPPDATA) roots.push(path.join(process.env.LOCALAPPDATA, "ai-battery"));
2402
+ results.artifacts = cleanupBatteryArtifacts({
2403
+ roots,
2404
+ home: userHome(),
2405
+ protectedRoots: [codexRuntimeHome(), homePath(".claude"), path.resolve(scriptDir(), "..")]
2406
+ });
2402
2407
  }
2403
2408
  return {
2404
2409
  targets,
2405
- fullUninstall,
2410
+ fullReset,
2406
2411
  results
2407
2412
  };
2408
2413
  }
@@ -5030,7 +5035,7 @@ function printTeardownResult(result) {
5030
5035
  }
5031
5036
  const artifacts = result.results.artifacts;
5032
5037
  for (const [name, item] of Object.entries(result.results)) {
5033
- if (["codex", "claude", "hud", "artifacts", "package"].includes(name)) continue;
5038
+ if (["codex", "claude", "hud", "artifacts"].includes(name)) continue;
5034
5039
  if (item.error) console.log(`${name} cleanup error: ${item.error}`);
5035
5040
  for (const error of item.errors || []) console.log(`${name} cleanup error: ${error.path}: ${error.error}`);
5036
5041
  for (const file of item.paths || []) console.log(`Recovery pending: ${file}`);
@@ -5040,10 +5045,12 @@ function printTeardownResult(result) {
5040
5045
  for (const file of artifacts.retained) console.log(`Preserved unrecognized or user-owned file: ${file}`);
5041
5046
  for (const item of artifacts.errors) console.log(`Cleanup error: ${item.path}: ${item.error}`);
5042
5047
  }
5043
- const pkg = result.results.package;
5044
- if (pkg?.removed) console.log(`Removed ai-battery npm package from ${pkg.prefix}`);
5045
- else if (pkg?.error) console.log(`Package uninstall failed: ${pkg.error}`);
5046
- else if (pkg?.skipped) console.log(`Package: ${pkg.reason}`);
5048
+ if (teardownResultFailed(result)) {
5049
+ console.log("Settings reset incomplete; recovery metadata and npm package were preserved.");
5050
+ } else {
5051
+ console.log("AI Battery settings reset; npm package was left unchanged.");
5052
+ console.log("To remove the package: npm uninstall -g ai-battery");
5053
+ }
5047
5054
  if (result.targets.includes("codex") && process.platform !== "win32") {
5048
5055
  console.log("In this existing Bash terminal, run: hash -r (zsh: rehash). A child process cannot clear its parent shell's cached command paths.");
5049
5056
  }
@@ -5125,7 +5132,7 @@ async function main() {
5125
5132
  if (process.platform === "win32" && result.codex && !result.codex.standalone) {
5126
5133
  console.log("Windows terminal note: Codex uses fullscreen PTY composition by default, with a private VT-capable Node runtime when needed and a native HUD fallback. Open a new cmd/PowerShell after setup.");
5127
5134
  }
5128
- console.log("To remove AI Battery cleanly later, run: ai-battery uninstall");
5135
+ console.log("To restore settings later, run: ai-battery reset settings");
5129
5136
  const note = codexRestartNote();
5130
5137
  if (result.codex && note) console.log(note);
5131
5138
  }
@@ -5133,7 +5140,10 @@ async function main() {
5133
5140
  return;
5134
5141
  }
5135
5142
 
5136
- if (args.command === "teardown" || args.command === "uninstall") {
5143
+ if (["reset", "teardown", "uninstall"].includes(args.command)) {
5144
+ if (!args.silent && !args.json && args.command !== "reset") {
5145
+ console.log(`\"${args.command}\" is a compatibility alias for \"reset settings\"; npm package removal is separate.`);
5146
+ }
5137
5147
  const result = runTeardown(args);
5138
5148
  if (args.json) {
5139
5149
  console.log(JSON.stringify(result, null, 2));
@@ -1,9 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import { spawnSync } from "node:child_process";
5
4
 
6
- const ALIASES = ["ai-battery", "ai-battery-hud", "ai-battery-run", "ai-battery-run-win", "claudex-battery", "claudex-battery-hud", "claudex-battery-run"];
7
5
  const STATE_FILES = /^(?:(?:codex-status|windows-processes|wsl-windows-processes|claude-rate-limit-hit)-scan-cache\.json|claude-statusline\.json|codex-account-usage\.json|windows-state-dir|hud-position\.json|hud-snapshot-[\w-]+\.json|(?:tui|hud)-dock-(?:request|host)(?:-\d+)?\.json|macos-menu-(?:bar|detail)\.svg|codex-menu-bar-transparent\.png)(?:\.\d+(?:\.\d+)?(?:\.[a-z0-9]+)?\.tmp)?$/;
8
6
  const HUD_FILES = new Set(["main.ps1", "controls.ps1", "dock.ps1", "native.ps1", "rendering.ps1", "snapshot.ps1", "windowing.ps1", "ai-battery-hud.ps1"]);
9
7
 
@@ -85,61 +83,3 @@ export function cleanupBatteryArtifacts({ roots, home = os.homedir(), protectedR
85
83
  }
86
84
  return result;
87
85
  }
88
-
89
- export function removeBatteryAliases({ packageRoot, packageJson, home = os.homedir() }) {
90
- const removed = [];
91
- for (const name of ALIASES) {
92
- const target = packageJson.bin?.[name];
93
- if (!target) continue;
94
- const alias = path.join(home, ".local", "bin", name);
95
- if (!lstat(alias)?.isSymbolicLink()) continue;
96
- const resolved = path.resolve(path.dirname(alias), fs.readlinkSync(alias));
97
- if (resolved !== path.resolve(packageRoot, target)) continue;
98
- fs.unlinkSync(alias);
99
- removed.push(alias);
100
- }
101
- return removed;
102
- }
103
-
104
- export function planPackageRemoval(packageRoot, { node = process.execPath } = {}) {
105
- const root = path.resolve(packageRoot);
106
- const packageJson = readJson(path.join(root, "package.json"));
107
- if (packageJson?.name !== "ai-battery" || !packageJson.bin || typeof packageJson.bin !== "object"
108
- || Object.entries(packageJson.bin).some(([name, target]) => !ALIASES.includes(name)
109
- || typeof target !== "string" || path.isAbsolute(target) || !inside(path.resolve(root, target), root))) {
110
- return { error: "Package identity or command ownership could not be verified" };
111
- }
112
- if (path.basename(path.dirname(root)) !== "node_modules" || /[\\/]_npx[\\/]/.test(root)) {
113
- return { skipped: true, reason: "Development checkout or temporary npx installation; no npm project was changed" };
114
- }
115
- const modules = path.dirname(root);
116
- const parent = path.dirname(modules);
117
- const localProject = readJson(path.join(parent, "package.json"));
118
- const declaredLocal = [localProject?.dependencies, localProject?.devDependencies, localProject?.optionalDependencies]
119
- .some(deps => Object.hasOwn(deps || {}, "ai-battery"));
120
- const global = !declaredLocal && !fs.existsSync(path.join(parent, "package.json"));
121
- const prefix = global && process.platform !== "win32" && path.basename(parent) === "lib" ? path.dirname(parent) : parent;
122
- const candidates = [
123
- path.join(modules, "npm", "bin", "npm-cli.js"),
124
- path.join(path.dirname(node), "node_modules", "npm", "bin", "npm-cli.js"),
125
- path.resolve(path.dirname(node), "../lib/node_modules/npm/bin/npm-cli.js")
126
- ];
127
- const npm = candidates.find(file => lstat(file)?.isFile());
128
- if (!npm) return { error: "Could not locate npm for the installed package; package was left intact" };
129
- if (!global) {
130
- const project = readJson(path.join(prefix, "package.json"));
131
- if (![project?.dependencies, project?.devDependencies, project?.optionalDependencies].some(deps => Object.hasOwn(deps || {}, "ai-battery"))) {
132
- return { error: "The parent npm project does not declare ai-battery; refusing to change it" };
133
- }
134
- }
135
- return { node, npm, prefix, packageRoot: root, packageJson, global, args: ["uninstall", ...(global ? ["--global"] : []), "--prefix", prefix, "ai-battery", "--ignore-scripts", "--no-audit", "--no-fund"] };
136
- }
137
-
138
- export function removeInstalledPackage(plan, { home = os.homedir(), run = spawnSync } = {}) {
139
- if (plan.error || plan.skipped) return plan;
140
- const result = run(plan.node, [plan.npm, ...plan.args], { encoding: "utf8", windowsHide: true, stdio: ["ignore", "pipe", "pipe"], timeout: 120000 });
141
- if (result.status !== 0 || result.error || lstat(plan.packageRoot)) {
142
- return { error: result.error?.message || result.stderr?.trim() || "npm did not remove the installed package", prefix: plan.prefix };
143
- }
144
- return { removed: true, prefix: plan.prefix, global: plan.global, aliases: removeBatteryAliases({ ...plan, home }) };
145
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
5
5
  "type": "module",
6
6
  "keywords": [