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 +73 -70
- package/docs/RELEASING.md +9 -9
- package/lib/cli.js +45 -35
- package/lib/core/uninstall.js +0 -60
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AI Battery
|
|
2
2
|
|
|
3
|
-
0.1.
|
|
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
|
|
33
|
-
|
|
|
34
|
-
| Codex
|
|
35
|
-
| Claude Code
|
|
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
|
|
41
|
-
|
|
|
42
|
-
| 공통 사용량 표시
|
|
43
|
-
| 리셋 시각 표시
|
|
44
|
-
| 색상 기준
|
|
45
|
-
| Codex terminal row | Windows에서는 가상 터미널 화면과 배터리 행을 합성하고, WSL/Linux/macOS에서는 PTY wrapper로 별도 사용량 행을 고정합니다.
|
|
46
|
-
| Claude statusLine
|
|
47
|
-
| HUD / menu bar
|
|
48
|
-
| npm 실행
|
|
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
|
|
53
|
-
|
|
|
54
|
-
| `ai-battery`
|
|
55
|
-
| `ai-battery --watch`
|
|
56
|
-
| Claude statusLine
|
|
57
|
-
| Codex fullscreen
|
|
58
|
-
| `ai-battery setup codex` | 지원
|
|
59
|
-
| `ai-battery hud`
|
|
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
|
|
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
|
|
122
|
-
|
|
|
123
|
-
| `--provider all\|codex\|claude` | 표시할 provider를 선택합니다.
|
|
124
|
-
| `--watch [seconds]`
|
|
125
|
-
| `--json`
|
|
126
|
-
| `--bar-width N`
|
|
127
|
-
| `--show-paths`
|
|
128
|
-
| `-v`, `--version`
|
|
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
|
-
|
|
132
|
+
<a id="uninstall"></a>
|
|
133
133
|
|
|
134
|
-
|
|
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
|
|
139
|
+
ai-battery reset settings
|
|
138
140
|
```
|
|
139
141
|
|
|
140
|
-
|
|
142
|
+
`ai-battery reset config`도 같은 동작입니다. 일부 통합만 복원하려면 대상을 지정합니다. 대상 지정 시 다른 통합과 공통 캐시는 유지합니다.
|
|
141
143
|
|
|
142
144
|
```bash
|
|
143
|
-
ai-battery
|
|
144
|
-
ai-battery
|
|
145
|
-
ai-battery
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
복구 기록은 `ai-battery uninstall`이 해당 항목을 성공적으로 복원하거나 안전하게 제거한 뒤에만 지워집니다. Claude는 기존 `statusLine`과 파일 존재 여부·권한만 저장하며 `settings.json` 전체를 복제하지 않으므로 다른 설정이나 비밀값을 백업 파일에 중복 보관하지 않습니다. JSON 결과나 종료 코드를 확인하는 자동화에서는 0일 때만 완전한 정리로 간주하세요.
|
|
151
|
+
관리 중인 status line이나 설정 블록이 사용자에 의해 변경됐다면 덮어쓰지 않고 복구 기록을 보존하며 종료 코드 1로 알립니다. 관련 없는 Codex·Claude 설정, 사용자 추가 파일, 확인할 수 없는 파일은 보존합니다. 셸·tmux의 사용자 수정도 관리 블록 밖의 내용은 유지합니다. 복구 기록은 해당 항목이 복원되거나 안전하게 제거된 뒤에만 지워집니다.
|
|
151
152
|
|
|
152
|
-
|
|
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
|
-
|
|
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`이 필요합니다. 두 옵션은 실행 경로나 사용자 설정을 변경하므로 기본값에서 제외되어 있습니다. 관리형 변경은 복구 기록을 먼저 저장하고,
|
|
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
|
|
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
|
|
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
|
|
295
|
-
|
|
|
296
|
-
| `ai-battery hud` / `ai-battery hud start`
|
|
297
|
-
| `ai-battery hud stop`
|
|
298
|
-
| `ai-battery hud status`
|
|
299
|
-
| `ai-battery hud autostart on`
|
|
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`
|
|
306
|
-
| `ai-battery hud light` / `ai-battery hud dark`
|
|
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
|
|
343
|
-
|
|
|
344
|
-
| CLI
|
|
345
|
-
| PTY row
|
|
346
|
-
| HUD launcher | Node.js / Bash compatibility wrapper
|
|
347
|
-
| HUD UI
|
|
348
|
-
| Data
|
|
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
|
-
-
|
|
9
|
-
- Shell and tmux recovery records preserve exact original content, permissions and file absence. User edits outside managed blocks survive repeated setup and
|
|
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` |
|
|
20
|
-
| Windows native Node 22.23.2 full suite |
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
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("-") &&
|
|
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
|
|
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
|
-
|
|
230
|
-
|
|
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
|
|
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
|
|
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
|
|
2383
|
-
if (
|
|
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
|
|
2387
|
-
return { targets,
|
|
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
|
-
|
|
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"
|
|
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
|
-
|
|
5044
|
-
|
|
5045
|
-
else
|
|
5046
|
-
|
|
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
|
|
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 (
|
|
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));
|
package/lib/core/uninstall.js
CHANGED
|
@@ -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
|
-
}
|