ai-battery 0.1.27 → 0.1.29
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 +9 -5
- package/bin/ai-battery-run +9 -1
- package/docs/RELEASING.md +18 -8
- package/docs/SETUP-REGRESSION.md +63 -0
- package/lib/cli.js +23 -14
- package/lib/core/cli-help.js +5 -4
- package/lib/core/cli-messages.js +8 -0
- package/lib/core/cli-output.js +20 -7
- package/lib/core/diagnostics.js +45 -0
- package/lib/platforms/linux/gnome-control.js +7 -2
- package/lib/platforms/linux/gnome-uuid.js +3 -0
- package/lib/platforms/linux/gnome.js +42 -19
- package/package.json +2 -1
- package/scripts/linux-gnome-menu-check.mjs +1 -0
- package/scripts/linux-gnome-menu-smoke.js +11 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# AI Battery
|
|
2
2
|
|
|
3
|
+
0.1.29: GNOME 확장 UUID를 `ai-battery@hnode`로 변경했습니다. 기존 `ai-battery@hnode.dev` 설치는 HUD 시작 시 자동 이전하며 reset은 두 UUID의 관리 파일을 정리합니다.
|
|
4
|
+
|
|
5
|
+
0.1.28: `setup`만으로 Codex TUI가 연결되던 0.1.24의 기본 동작을 복원했습니다. 신규 설치·업데이트·reset 후 setup을 동일하게 처리합니다. `doctor`는 표시 설정(Visibility), TUI 연동 상태, 현재 세션을 구분하고 누락된 연동·PATH·의존성에 맞는 조치를 안내합니다. [회귀 원인과 검증](docs/SETUP-REGRESSION.md).
|
|
6
|
+
|
|
3
7
|
0.1.27: 한글 오류 메시지가 포함된 하단 사용량 줄이 갱신될 때 Codex 화면에 여러 줄로 누적되던 문제를 수정했습니다. 화면 칸 수를 기준으로 너비를 제한하고 불필요한 공백 채우기를 제거했습니다. 하단 바의 데이터 없음 표시는 `Claude --%`처럼 간결하게 표시합니다.
|
|
4
8
|
|
|
5
9
|
0.1.26: `setup`이 기존 Codex 연동을 해제하던 문제를 수정했습니다. 기존 wrapper·PATH·Codex 상태줄과 tmux 연동을 유지·갱신하며, 실행 중인 셸이 기억하는 경로를 제거하지 않습니다. tmux 미실행 상태를 구분하고 HUD 메뉴의 밝은 테두리를 제거했습니다. 기본 예시는 `ai-battery setup tmux`입니다.
|
|
@@ -108,7 +112,7 @@ npx ai-battery
|
|
|
108
112
|
tmux
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
일반
|
|
115
|
+
`ai-battery setup`은 일반 터미널의 `codex`에도 사용량 행을 연결합니다. 기존 셸에서는 안내된 `source` 명령을 적용하고, 새 터미널에서는 `codex`를 실행하세요. 업데이트 후 setup과 reset 후 setup도 같은 방식으로 연결합니다. 데스크톱 표시는 `ai-battery hud`를 사용합니다.
|
|
112
116
|
|
|
113
117
|
## CLI
|
|
114
118
|
|
|
@@ -172,7 +176,7 @@ CLI는 npm 제거를 자동 실행하지 않습니다. `teardown`과 `uninstall`
|
|
|
172
176
|
|
|
173
177
|
## Setup
|
|
174
178
|
|
|
175
|
-
`setup`은 기존 Codex wrapper·PATH·상태줄과 tmux 연동을 유지·갱신하고 Claude statusLine을 설정합니다. 실행 중인 터미널의 경로와 복구용 백업을 제거하지 않습니다. 새
|
|
179
|
+
`setup`은 기존 Codex wrapper·PATH·상태줄과 tmux 연동을 유지·갱신하고 Claude statusLine을 설정합니다. 실행 중인 터미널의 경로와 복구용 백업을 제거하지 않습니다. 새 설치와 reset 후에도 Codex PATH wrapper를 연결합니다. 원본 Codex 실행 파일·설정·세션 기록은 유지합니다. 연동 해제는 `reset`으로 실행합니다.
|
|
176
180
|
|
|
177
181
|
```bash
|
|
178
182
|
ai-battery setup
|
|
@@ -185,7 +189,7 @@ ai-battery setup tmux
|
|
|
185
189
|
ai-battery setup codex
|
|
186
190
|
```
|
|
187
191
|
|
|
188
|
-
|
|
192
|
+
`setup`과 `setup codex`는 Codex wrapper를 기본으로 연결합니다. `--wrap-codex`는 호환 옵션이며, `--no-wrap-codex`는 wrapper 설정만 생략합니다. 기존 연동을 해제하려면 `reset codex`를 사용합니다. Codex `[tui].status_line` 변경은 별도 옵션인 `--configure-codex-statusline`을 지정한 경우에만 적용합니다. 관리형 변경은 복구 기록을 먼저 저장하고, `reset`에서 해당 변경만 복원합니다.
|
|
189
193
|
|
|
190
194
|
tmux에서는 pane마다 하단 행을 예약하면 같은 전역 배터리가 pane 수만큼 중복 표시됩니다. 대신 tmux의 status bar에 세션당 한 번만 표시할 수 있습니다.
|
|
191
195
|
|
|
@@ -216,7 +220,7 @@ ai-battery on all
|
|
|
216
220
|
|
|
217
221
|
## Codex Terminal Row
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
`ai-battery setup` 이후 새 터미널에서 `codex`를 실행하면 사용량 행이 표시됩니다. `doctor`의 `Visibility`는 표시 허용 설정이고, `TUI`는 다음 실행의 연동 준비 상태, `Session`은 현재 Codex의 연결 여부입니다. `on`만으로 연동을 설치하지는 않습니다. 사용량을 별도로 보려면 `ai-battery --watch 2` 또는 지원 플랫폼에서 `ai-battery hud`를 실행하세요.
|
|
220
224
|
|
|
221
225
|
세션 하나에 하단 행을 추가하려면 명시적으로 실행합니다.
|
|
222
226
|
|
|
@@ -302,7 +306,7 @@ HUD는 백그라운드에서 실행되고 터미널을 바로 돌려줍니다. W
|
|
|
302
306
|
|
|
303
307
|
Ubuntu GNOME에서는 상단 패널과 클릭 메뉴 모두 macOS와 같은 SVG를 사용합니다. 클릭하면 도구명, 그래픽 배터리 바, 퍼센트, 5h 리셋 시각과 7d 잔량을 같은 크기와 정렬로 표시하며, 아래에 새로고침·종료 메뉴가 있습니다. `ai-battery on/off` 설정도 반영합니다. 화면 잠금이나 패널 재시작 후에는 자동으로 다시 연결됩니다.
|
|
304
308
|
|
|
305
|
-
GNOME 45–50에서는 처음 실행할 때 전용 표시 확장을 `~/.local/share/gnome-shell/extensions/ai-battery@hnode
|
|
309
|
+
GNOME 45–50에서는 처음 실행할 때 전용 표시 확장을 `~/.local/share/gnome-shell/extensions/ai-battery@hnode`에 설치하고 활성화합니다. `XDG_DATA_HOME`을 지정한 경우 해당 경로를 사용합니다. 새 확장을 읽으려면 최초 한 번 로그아웃·로그인이 필요합니다. 그 전이나 다른 데스크톱에서는 기본 StatusNotifier 메뉴를 사용합니다. 확장만 비활성화해도 기본 패널 아이콘으로 복귀합니다.
|
|
306
310
|
|
|
307
311
|
GJS, libdbusmenu와 StatusNotifier 호스트가 필요합니다. 현재 Ubuntu 환경에서는 추가 설치 없이 실행됩니다. 구성 요소가 없다면 다음 명령으로 설치하고 Ubuntu AppIndicators 확장을 활성화하세요.
|
|
308
312
|
|
package/bin/ai-battery-run
CHANGED
|
@@ -401,7 +401,7 @@ def main():
|
|
|
401
401
|
|
|
402
402
|
set_winsize(master_fd, child_rows, cols)
|
|
403
403
|
old_term = termios.tcgetattr(sys.stdin.fileno())
|
|
404
|
-
child_exit =
|
|
404
|
+
child_exit = None
|
|
405
405
|
|
|
406
406
|
def on_resize(_signum, _frame):
|
|
407
407
|
status.resize()
|
|
@@ -476,6 +476,14 @@ def main():
|
|
|
476
476
|
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, old_term)
|
|
477
477
|
status.clear()
|
|
478
478
|
|
|
479
|
+
# PTY EOF/EIO may precede the nonblocking wait above. Preserve the
|
|
480
|
+
# command's exit code in that case as well (restored from 0.1.24).
|
|
481
|
+
if child_exit is None:
|
|
482
|
+
_, wait_status = os.waitpid(pid, 0)
|
|
483
|
+
if os.WIFEXITED(wait_status):
|
|
484
|
+
child_exit = os.WEXITSTATUS(wait_status)
|
|
485
|
+
elif os.WIFSIGNALED(wait_status):
|
|
486
|
+
child_exit = 128 + os.WTERMSIG(wait_status)
|
|
479
487
|
raise SystemExit(child_exit)
|
|
480
488
|
|
|
481
489
|
|
package/docs/RELEASING.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# npm release
|
|
2
2
|
|
|
3
|
-
The prepared version is **0.1.
|
|
3
|
+
The prepared version is **0.1.29**, following the published 0.1.28. Preparing or pushing this release does not publish it to npm.
|
|
4
|
+
|
|
5
|
+
## Fixes in 0.1.29
|
|
6
|
+
|
|
7
|
+
- Change the GNOME extension UUID to `ai-battery@hnode`. Migrate the owned legacy `ai-battery@hnode.dev` directory and activation settings during HUD startup. Reset handles both identities and preserves unrelated files. GNOME may require a new login to discover the new UUID.
|
|
8
|
+
|
|
9
|
+
## Fixes in 0.1.28
|
|
10
|
+
|
|
11
|
+
- Restore the 0.1.24 automatic Codex wrapper default, including after reset. Keep the 0.1.26 non-destructive refresh behavior. Explicit opt-out skips setup without removing existing integrations.
|
|
12
|
+
- Diagnose visibility, TUI readiness and current-session attachment separately; report incomplete setup for missing prerequisites. Restore the 0.1.24 PTY EOF exit-status fix.
|
|
13
|
+
- See [the published-package regression audit](SETUP-REGRESSION.md). Test upgrades from the last working 0.1.24 and the current 0.1.27.
|
|
4
14
|
|
|
5
15
|
## Fixes in 0.1.27
|
|
6
16
|
|
|
@@ -22,16 +32,16 @@ The active runner keeps its Python code until the next launch. Updating the CLI
|
|
|
22
32
|
```text
|
|
23
33
|
npm run check
|
|
24
34
|
npm run smoke:linux
|
|
25
|
-
mkdir -p .cache/releases/0.1.
|
|
35
|
+
mkdir -p .cache/releases/0.1.29
|
|
26
36
|
npm pack --dry-run --json
|
|
27
|
-
npm pack --pack-destination .cache/releases/0.1.
|
|
37
|
+
npm pack --pack-destination .cache/releases/0.1.29 --json
|
|
28
38
|
```
|
|
29
39
|
|
|
30
40
|
The regression suite includes real PTYs: an already-running wrapped Codex remains interactive during setup, the same Bash command cache launches it again, a fresh shell displays the usage row, and an attached tmux client displays the bar after live setup. An open wrapper reader retains its old bytes, compatibility command paths and recovery backups survive, and user Codex/shell/tmux settings are compared exactly.
|
|
31
41
|
|
|
32
42
|
POSIX screen regressions replay actual output into a terminal emulator and inspect the rendered rows, cursor and scrollback. They cover repeated Korean error rows, narrow widths, wide/combining characters, control sequences, shorter replacement text, resize and keyboard input through a live PTY.
|
|
33
43
|
|
|
34
|
-
Also install 0.1.
|
|
44
|
+
Also install each of 0.1.24 and 0.1.27 into an isolated npm prefix, open the PTY fixture, upgrade that prefix to the exact 0.1.29 tarball, and run default setup while the original terminal remains open. Save the lifecycle report, package manifest, SHA256 checksum, installed-package smoke report and publish dry-run under `.cache/releases/0.1.29/`.
|
|
35
45
|
|
|
36
46
|
The Linux GUI smoke test opens the actual popup in an isolated GNOME 50.1 Wayland session, verifies zero border width for the content and box pointer, and saves a screenshot. It also checks shared macOS SVG size, provider visibility, extension fallback/reconnect and shutdown. Native Windows/macOS runtime tests require their respective environments; platform-neutral regressions still run here.
|
|
37
47
|
|
|
@@ -41,22 +51,22 @@ Inspect the tarball for runtime modules, stable bin entrypoints and required pla
|
|
|
41
51
|
|
|
42
52
|
```text
|
|
43
53
|
npm whoami
|
|
44
|
-
npm publish .cache/releases/0.1.
|
|
54
|
+
npm publish .cache/releases/0.1.29/ai-battery-0.1.29.tgz --access public --tag latest
|
|
45
55
|
npm view ai-battery version dist-tags --json
|
|
46
56
|
```
|
|
47
57
|
|
|
48
|
-
Authenticate with `npm login` if required, and complete npm 2FA when requested. If 0.1.
|
|
58
|
+
Authenticate with `npm login` if required, and complete npm 2FA when requested. If 0.1.29 is already published, increment the version and repeat verification. Tag the tested commit `v0.1.29` after publication.
|
|
49
59
|
|
|
50
60
|
## Update and enable terminal display
|
|
51
61
|
|
|
52
62
|
```text
|
|
53
|
-
npm install -g ai-battery@0.1.
|
|
63
|
+
npm install -g ai-battery@0.1.29
|
|
54
64
|
ai-battery setup
|
|
55
65
|
ai-battery setup tmux
|
|
56
66
|
tmux
|
|
57
67
|
```
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
Plain setup enables the Codex usage row outside tmux. Run the printed source command in existing shells. New shells load it automatically. Subsequent setup calls preserve that choice. Re-running setup does not require closing running Codex sessions.
|
|
60
70
|
|
|
61
71
|
GNOME caches loaded extension JavaScript. After its display code changes, sign out and back in when convenient, then start the HUD again. The terminal integration does not require a desktop restart.
|
|
62
72
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Codex setup regression: 0.1.24 to 0.1.27
|
|
2
|
+
|
|
3
|
+
The Linux HUD feature did not require a change to Codex terminal setup. The
|
|
4
|
+
0.1.25 release nevertheless lost the default setup behavior shipped in 0.1.24.
|
|
5
|
+
This was a release regression, not a Linux limitation or a user configuration
|
|
6
|
+
requirement.
|
|
7
|
+
|
|
8
|
+
## Evidence
|
|
9
|
+
|
|
10
|
+
The published npm tarballs for all four versions were inspected, including
|
|
11
|
+
`lib/cli.js` and `bin/ai-battery-run`:
|
|
12
|
+
|
|
13
|
+
| Version | Default Codex wrapper | Setup can remove an existing wrapper | PTY EOF preserves child exit status |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| 0.1.24 | enabled | yes, with explicit opt-out | yes |
|
|
16
|
+
| 0.1.25 | disabled | yes, during default setup | no |
|
|
17
|
+
| 0.1.26 | disabled | no | no |
|
|
18
|
+
| 0.1.27 | disabled | no | no |
|
|
19
|
+
| 0.1.28 | enabled | no; removal uses reset | yes |
|
|
20
|
+
|
|
21
|
+
Commit `869683e` restored automatic display, the `--no-wrap-codex` option and
|
|
22
|
+
PTY exit handling for 0.1.24 on `fix/setup-codex-defaults`. That branch was not
|
|
23
|
+
merged into main before the 0.1.25 Linux HUD release. Main continued from
|
|
24
|
+
`98ae375` (0.1.23); the published 0.1.25 package also has `wrapCodex: false`.
|
|
25
|
+
|
|
26
|
+
0.1.26 (`2307c89`) stopped setup from consuming recovery records and deleting
|
|
27
|
+
wrapper paths. It preserved an existing integration but did not restore the
|
|
28
|
+
0.1.24 default. Therefore a reset, which correctly removes the integration,
|
|
29
|
+
followed by plain setup still produced a standalone Codex command. 0.1.27
|
|
30
|
+
fixed Korean row wrapping but retained that setup regression.
|
|
31
|
+
|
|
32
|
+
## Why diagnosis and testing missed it
|
|
33
|
+
|
|
34
|
+
`providerEnabled` is an on/off visibility preference. It defaults to true even
|
|
35
|
+
without an installed integration. The concise doctor formatter displayed it
|
|
36
|
+
as `Codex: on`, while suppressing the missing-wrapper note. That made a display
|
|
37
|
+
preference look like a successful installation.
|
|
38
|
+
|
|
39
|
+
Most live setup tests explicitly passed `--wrap-codex`. Another test asserted
|
|
40
|
+
that default setup should leave Codex standalone. They tested the regressed
|
|
41
|
+
behavior rather than the setup contract of the last working release.
|
|
42
|
+
|
|
43
|
+
## Restored contract
|
|
44
|
+
|
|
45
|
+
- Plain setup and setup codex install or refresh the managed PATH wrapper.
|
|
46
|
+
The original Codex executable, Codex configuration and session history are
|
|
47
|
+
preserved. New tmux integration remains explicit.
|
|
48
|
+
- Setup never detaches an existing integration. `--no-wrap-codex` skips wrapper
|
|
49
|
+
setup and preserves existing files; reset is the removal operation.
|
|
50
|
+
- Reset followed by plain setup restores the terminal row for new sessions.
|
|
51
|
+
An already-running Codex keeps running through both operations.
|
|
52
|
+
- Missing Codex, Python or runner prerequisites produce incomplete setup and a
|
|
53
|
+
failing exit status, with a cause and next step.
|
|
54
|
+
- Doctor reports visibility, integration readiness and current-session
|
|
55
|
+
attachment separately. Missing integration, PATH mismatch, missing runner,
|
|
56
|
+
missing Python and missing original Codex each have their own state and
|
|
57
|
+
action. A missing optional Codex built-in status line is not a wrapper error.
|
|
58
|
+
- Claude diagnosis distinguishes an installed hook waiting for first-use data
|
|
59
|
+
from missing, external, outdated or invalid settings.
|
|
60
|
+
|
|
61
|
+
Release checks now cover default setup without opt-in flags, reset/setup,
|
|
62
|
+
fresh shells, live terminals and upgrades from both 0.1.24 and 0.1.27. Package
|
|
63
|
+
validation uses the exact npm tarball, in addition to source tests.
|
package/lib/cli.js
CHANGED
|
@@ -20,6 +20,7 @@ import { createIntegrationFiles } from "./core/integration-files.js";
|
|
|
20
20
|
import { cliError, cliText, helpText, invalidChoice, requiredValue } from "./core/cli-help.js";
|
|
21
21
|
import { errorText, messageText as cliMessageText } from "./core/cli-messages.js";
|
|
22
22
|
import { formatClaudeResult, formatDoctorResult, formatResetResult, formatSetupResult, formatVisibilityResult } from "./core/cli-output.js";
|
|
23
|
+
import { codexTerminalDisplay, claudeTerminalDisplay } from "./core/diagnostics.js";
|
|
23
24
|
import {
|
|
24
25
|
cacheAgeSeconds,
|
|
25
26
|
clamp,
|
|
@@ -114,7 +115,7 @@ function parseArgs(argv) {
|
|
|
114
115
|
hudState: false,
|
|
115
116
|
silent: false,
|
|
116
117
|
force: false,
|
|
117
|
-
wrapCodex:
|
|
118
|
+
wrapCodex: true,
|
|
118
119
|
configureCodexStatusLine: false,
|
|
119
120
|
attachHud: false,
|
|
120
121
|
header: true,
|
|
@@ -167,6 +168,8 @@ function parseArgs(argv) {
|
|
|
167
168
|
args.force = true;
|
|
168
169
|
} else if (arg === "--wrap-codex") {
|
|
169
170
|
args.wrapCodex = true;
|
|
171
|
+
} else if (arg === "--no-wrap-codex") {
|
|
172
|
+
args.wrapCodex = false;
|
|
170
173
|
} else if (arg === "--configure-codex-statusline") {
|
|
171
174
|
args.configureCodexStatusLine = true;
|
|
172
175
|
} else if (arg === "--attach-hud") {
|
|
@@ -468,7 +471,7 @@ function runningInsideCodex() {
|
|
|
468
471
|
}
|
|
469
472
|
|
|
470
473
|
function runningInsideAiBatteryCodexWrapper() {
|
|
471
|
-
return
|
|
474
|
+
return process.env.AI_BATTERY_WRAPPED_CODEX === "1";
|
|
472
475
|
}
|
|
473
476
|
|
|
474
477
|
function scriptDir() {
|
|
@@ -1904,9 +1907,6 @@ function diagnoseCodex() {
|
|
|
1904
1907
|
if (!wrapperInstalled) {
|
|
1905
1908
|
notes.push("Codex wrapper is not installed. Run: ai-battery setup codex");
|
|
1906
1909
|
}
|
|
1907
|
-
if (!statusLine.configured) {
|
|
1908
|
-
notes.push("Codex status_line is not configured. Run: ai-battery setup codex");
|
|
1909
|
-
}
|
|
1910
1910
|
if (activeIsWrapper && !wrapperInstalled) {
|
|
1911
1911
|
notes.push("Plain \"codex\" still resolves to an AI Battery wrapper outside the configured shim. Run: ai-battery reset codex");
|
|
1912
1912
|
}
|
|
@@ -1964,7 +1964,7 @@ function diagnoseCodex() {
|
|
|
1964
1964
|
const restartNote = codexRestartNote();
|
|
1965
1965
|
if (restartNote) notes.push(restartNote);
|
|
1966
1966
|
|
|
1967
|
-
|
|
1967
|
+
const diagnostic = {
|
|
1968
1968
|
providerEnabled,
|
|
1969
1969
|
runtimeHome,
|
|
1970
1970
|
sessionsPath,
|
|
@@ -1991,6 +1991,8 @@ function diagnoseCodex() {
|
|
|
1991
1991
|
currentCodexWrapped: runningInsideAiBatteryCodexWrapper(),
|
|
1992
1992
|
notes
|
|
1993
1993
|
};
|
|
1994
|
+
diagnostic.terminalDisplay = codexTerminalDisplay(diagnostic, { layout: windowsLayout });
|
|
1995
|
+
return diagnostic;
|
|
1994
1996
|
}
|
|
1995
1997
|
|
|
1996
1998
|
function diagnoseClaudeStatusLine() {
|
|
@@ -2025,9 +2027,10 @@ function diagnoseClaudeStatusLine() {
|
|
|
2025
2027
|
}
|
|
2026
2028
|
|
|
2027
2029
|
async function runDoctor() {
|
|
2030
|
+
const recoveryConfig = readConfig({ strict: true });
|
|
2028
2031
|
const version = await checkPackageVersion();
|
|
2029
2032
|
const claudeStatusLine = diagnoseClaudeStatusLine();
|
|
2030
|
-
const
|
|
2033
|
+
const claudeReading = Boolean(readClaudeStatuslineCache());
|
|
2031
2034
|
return {
|
|
2032
2035
|
generatedAt: new Date().toISOString(),
|
|
2033
2036
|
aiBattery: {
|
|
@@ -2057,8 +2060,9 @@ async function runDoctor() {
|
|
|
2057
2060
|
claude: {
|
|
2058
2061
|
providerEnabled: providerVisible("claude"),
|
|
2059
2062
|
cachePath: claudeCachePath(),
|
|
2060
|
-
statuslineCache:
|
|
2063
|
+
statuslineCache: claudeReading,
|
|
2061
2064
|
statusLine: claudeStatusLine,
|
|
2065
|
+
terminalDisplay: claudeTerminalDisplay(claudeStatusLine, claudeReading),
|
|
2062
2066
|
notes: [
|
|
2063
2067
|
!claudeStatusLine.configured ? "Claude statusLine is not configured. Run: ai-battery setup claude" : null,
|
|
2064
2068
|
claudeStatusLine.configured && !claudeStatusLine.managed
|
|
@@ -2278,19 +2282,22 @@ function runSetup(args) {
|
|
|
2278
2282
|
results.tmux = installTmuxStatus(tmuxRefreshPath ? { confPath: tmuxRefreshPath } : {});
|
|
2279
2283
|
}
|
|
2280
2284
|
if (targets.includes("codex")) {
|
|
2281
|
-
const wrapCodex = args.wrapCodex
|
|
2282
|
-
|| codexWrapperCandidates(previous).some(file => managedCodexWrapper(file));
|
|
2285
|
+
const wrapCodex = args.wrapCodex;
|
|
2283
2286
|
const statusLine = args.configureCodexStatusLine ? installCodexStatusLine(args) : null;
|
|
2284
2287
|
if (wrapCodex) {
|
|
2285
|
-
|
|
2288
|
+
const prerequisite = !codexRunnerExists() ? "AI Battery runner is missing. Reinstall: npm install -g ai-battery@latest"
|
|
2289
|
+
: process.platform !== "win32" && !findCommand("python3") ? "Python 3 is required for the Codex terminal row. Install Python 3, then run ai-battery setup codex." : null;
|
|
2290
|
+
results.codex = prerequisite ? { ok: false, skipped: true, reason: prerequisite, statusLine }
|
|
2291
|
+
: { ...installCodexWrapper(args), statusLine };
|
|
2286
2292
|
} else {
|
|
2287
2293
|
results.codex = {
|
|
2288
2294
|
ok: true,
|
|
2289
|
-
|
|
2290
|
-
reason: "Codex
|
|
2295
|
+
wrapperSetupSkipped: true,
|
|
2296
|
+
reason: "Codex wrapper setup skipped (--no-wrap-codex). Existing integrations are preserved; remove them with ai-battery reset codex.",
|
|
2291
2297
|
statusLine
|
|
2292
2298
|
};
|
|
2293
2299
|
}
|
|
2300
|
+
results.codex.providerEnabled = providerVisible("codex");
|
|
2294
2301
|
if (process.platform === "win32" && wrapCodex) {
|
|
2295
2302
|
results.codex.rowpty = windowsSetupNeedsRowPty()
|
|
2296
2303
|
? (windowsClaudeLauncher || installRowPtyHost())
|
|
@@ -2312,6 +2319,8 @@ function setupResultFailed(result) {
|
|
|
2312
2319
|
|| result.claude?.launcher?.error
|
|
2313
2320
|
|| (result.claude?.launcher && result.claude.launcher.ok === false)
|
|
2314
2321
|
|| (result.codex && result.codex.ok === false)
|
|
2322
|
+
|| result.codex?.path?.ok === false
|
|
2323
|
+
|| result.codex?.path?.error
|
|
2315
2324
|
|| result.codex?.statusLine?.error
|
|
2316
2325
|
|| result.codex?.rowpty?.error
|
|
2317
2326
|
|| (result.codex?.rowpty && result.codex.rowpty.ok === false)
|
|
@@ -5018,7 +5027,7 @@ async function main() {
|
|
|
5018
5027
|
console.log(formatSetupResult(result, {
|
|
5019
5028
|
failed,
|
|
5020
5029
|
reloadCommand: sourcePathCommand(result.codex?.path?.rcPath),
|
|
5021
|
-
restartNote: result.codex && !result.codex.
|
|
5030
|
+
restartNote: result.codex?.ok && !result.codex.wrapperSetupSkipped ? codexRestartNote() : null
|
|
5022
5031
|
}));
|
|
5023
5032
|
}
|
|
5024
5033
|
if (failed) process.exitCode = 1;
|
package/lib/core/cli-help.js
CHANGED
|
@@ -82,17 +82,18 @@ export function helpText(command = "", { env = process.env, platform = process.p
|
|
|
82
82
|
return [
|
|
83
83
|
usage(legacy ? `${command} [--force]` : "setup [codex|claude|tmux|all] [options]"),
|
|
84
84
|
legacy ? t("Configure Claude Code's usage status line.", "Claude Code 상태 표시줄에 사용량을 연결합니다.")
|
|
85
|
-
: t("
|
|
85
|
+
: t("Enable Codex and Claude Code terminal usage display. Specify tmux separately.", "Codex와 Claude Code의 터미널 사용량 표시를 연결합니다. tmux는 별도로 지정합니다."),
|
|
86
86
|
options([
|
|
87
87
|
["--force", "Replace an existing Claude statusLine", "기존 Claude 상태 표시줄 교체"],
|
|
88
88
|
...(!legacy ? [
|
|
89
|
-
["--wrap-codex", "
|
|
89
|
+
["--wrap-codex", "Enable Codex terminal display (default)", "Codex 터미널 표시 연결 (기본)"],
|
|
90
|
+
["--no-wrap-codex", "Skip Codex wrapper setup", "Codex wrapper 설정 생략"],
|
|
90
91
|
["--configure-codex-statusline", "Configure Codex's built-in status line", "Codex 내장 상태 표시줄 설정"]
|
|
91
92
|
] : []),
|
|
92
93
|
json
|
|
93
94
|
]),
|
|
94
95
|
legacy ? t("Restore settings: ai-battery reset claude", "설정 복원: ai-battery reset claude")
|
|
95
|
-
: t("
|
|
96
|
+
: t("The original Codex executable and settings are preserved.\nRestore settings: ai-battery reset", "Codex 원본 실행 파일과 설정은 유지합니다.\n설정 복원: ai-battery reset"),
|
|
96
97
|
examples(legacy ? [`ai-battery ${command}`] : ["ai-battery setup tmux"])
|
|
97
98
|
].join("\n\n");
|
|
98
99
|
}
|
|
@@ -110,7 +111,7 @@ export function helpText(command = "", { env = process.env, platform = process.p
|
|
|
110
111
|
return [usage(`${command} [codex|claude|all]`), command === "on"
|
|
111
112
|
? t("Show the selected tools (default: all).", "선택한 도구의 사용량을 표시합니다. 기본 대상은 all입니다.")
|
|
112
113
|
: t("Hide the selected tools (default: all).", "선택한 도구의 사용량을 숨깁니다. 기본 대상은 all입니다."),
|
|
113
|
-
options([json]), examples([`ai-battery ${command} codex`])].join("\n\n");
|
|
114
|
+
options([json]), t("Changes visibility only. Configure terminal integration with ai-battery setup.", "표시 설정만 변경합니다. 터미널 연결: ai-battery setup"), examples([`ai-battery ${command} codex`])].join("\n\n");
|
|
114
115
|
}
|
|
115
116
|
if (command === "doctor") {
|
|
116
117
|
return [usage("doctor [--json]"), t("Check installation, integrations and available updates.", "설치 상태, 연동 설정, 업데이트를 확인합니다."), options([json])].join("\n\n");
|
package/lib/core/cli-messages.js
CHANGED
|
@@ -72,6 +72,14 @@ const messages = [
|
|
|
72
72
|
["CODEX_HOME contains a comma and the literal path does not exist. Multiple homes are not supported; correct CODEX_HOME before using /resume.", "CODEX_HOME에 존재하는 경로 하나를 지정하세요. 쉼표로 여러 경로를 지정할 수 없습니다.", "Set CODEX_HOME to one existing directory; comma-separated paths are unsupported."],
|
|
73
73
|
["Codex session directory was not found: {path}", "Codex 로그를 찾을 수 없습니다: {path}", "Codex logs not found: {path}"],
|
|
74
74
|
["Codex provider is hidden. Run: ai-battery on codex", "Codex 사용량 표시 켜기: ai-battery on codex", "Show Codex usage: ai-battery on codex"],
|
|
75
|
+
["Open a new terminal to apply PATH changes.", "새 터미널에서 PATH 변경을 적용하세요."],
|
|
76
|
+
["Load the shell configuration or open a new terminal, then run hash -r (zsh: rehash).", "셸 설정을 불러오거나 새 터미널을 연 뒤 hash -r(zsh: rehash)을 실행하세요."],
|
|
77
|
+
["Install Python 3, then run codex again.", "Python 3 설치 후 codex를 다시 실행하세요."],
|
|
78
|
+
["Install Codex or restore its original command on PATH, then run ai-battery setup codex.", "PATH에 원본 Codex 명령을 설치·복구한 뒤 ai-battery setup codex를 실행하세요."],
|
|
79
|
+
["Set AI_BATTERY_WIN_LAYOUT=composite, then run codex again.", "AI_BATTERY_WIN_LAYOUT=composite로 설정한 뒤 codex를 다시 실행하세요."],
|
|
80
|
+
["Start Claude Code to receive usage data.", "Claude Code를 실행하면 사용량이 수집됩니다."],
|
|
81
|
+
["AI Battery runner is missing. Reinstall: npm install -g ai-battery@latest", "AI Battery runner가 없습니다. 재설치: npm install -g ai-battery@latest"],
|
|
82
|
+
["Python 3 is required for the Codex terminal row. Install Python 3, then run ai-battery setup codex.", "Codex 터미널 표시에 Python 3가 필요합니다. 설치 후 ai-battery setup codex를 실행하세요."],
|
|
75
83
|
["Plain \"codex\" still resolves to an AI Battery wrapper outside the configured shim. Run: ai-battery reset codex", "이전 Codex wrapper가 남아 있습니다. 복원: ai-battery reset codex", "Legacy Codex wrapper detected. Restore: ai-battery reset codex"],
|
|
76
84
|
["A Codex backup is available for restore: {path}", "Codex 복구 파일: {path}", "Codex restore backup: {path}"],
|
|
77
85
|
["Plain \"codex\" does not resolve to the AI Battery wrapper in this shell. Ensure {path} is before the original codex on PATH, then {action}.", "PATH에서 원본 codex보다 앞에 배치하세요: {path}\n{action}", "Place before the original codex on PATH: {path}\n{action}"],
|
package/lib/core/cli-output.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cliLanguage } from "./cli-help.js";
|
|
2
2
|
import { errorText, messageText } from "./cli-messages.js";
|
|
3
|
+
import { codexTerminalDisplay, claudeTerminalDisplay } from "./diagnostics.js";
|
|
3
4
|
|
|
4
5
|
function output(env) {
|
|
5
6
|
const lines = [];
|
|
@@ -31,8 +32,9 @@ export function formatSetupResult(result, { failed = false, platform = process.p
|
|
|
31
32
|
else if (claude.launcher?.ok === false) o.note(claude.launcher.reason);
|
|
32
33
|
}
|
|
33
34
|
if (codex) {
|
|
34
|
-
if (codex.
|
|
35
|
-
o.add("Codex:
|
|
35
|
+
if (codex.wrapperSetupSkipped) {
|
|
36
|
+
o.add("Codex wrapper: skipped (--no-wrap-codex)");
|
|
37
|
+
o.add(o.t("Existing integrations are preserved. Remove: ai-battery reset codex", "기존 연동은 유지됩니다. 해제: ai-battery reset codex"));
|
|
36
38
|
} else if (codex.ok) {
|
|
37
39
|
o.add(`Codex wrapper: ready · ${codex.wrapperPath}`);
|
|
38
40
|
o.add(`Original: ${codex.originalCommand}`);
|
|
@@ -43,11 +45,11 @@ export function formatSetupResult(result, { failed = false, platform = process.p
|
|
|
43
45
|
o.error("PATH", codex.path.error || o.t("Could not update PATH.", "PATH를 갱신하지 못했습니다."));
|
|
44
46
|
}
|
|
45
47
|
if (/^(Could not|Skipped)/.test(codex.path?.note || "")) o.note(codex.path.note);
|
|
48
|
+
if (codex.providerEnabled === false) o.add("Visibility: off · ai-battery on codex");
|
|
46
49
|
} else {
|
|
47
50
|
o.add("Codex: skipped");
|
|
48
51
|
o.note(codex.reason);
|
|
49
52
|
}
|
|
50
|
-
if (codex.standalone && platform !== "win32" && !tmux) o.add(o.t("Terminal usage: ai-battery setup tmux", "터미널 사용량 표시: ai-battery setup tmux"));
|
|
51
53
|
if (codex.statusLine) {
|
|
52
54
|
const status = codex.statusLine;
|
|
53
55
|
o.add(`Codex status_line: ${status.error ? "error" : status.alreadyConfigured ? "already configured" : "configured"} · ${status.configPath}`);
|
|
@@ -86,8 +88,15 @@ export function formatDoctorResult(result, { env = process.env } = {}) {
|
|
|
86
88
|
if (battery.updateCheck.error !== "disabled") o.error("npm", battery.updateCheck.error);
|
|
87
89
|
}
|
|
88
90
|
o.lines.push("");
|
|
89
|
-
|
|
90
|
-
o.add(
|
|
91
|
+
const codexDisplay = codex.terminalDisplay || codexTerminalDisplay(codex);
|
|
92
|
+
o.add("Codex:");
|
|
93
|
+
o.add(` Visibility: ${codex.providerEnabled ? "on" : "off"}`);
|
|
94
|
+
if (!codex.providerEnabled) o.add(" Show: ai-battery on codex");
|
|
95
|
+
o.add(` TUI: ${codexDisplay.status}`);
|
|
96
|
+
o.add(` Session: ${codexDisplay.currentSession}`);
|
|
97
|
+
if (codexDisplay.action) o.add(` ${o.t("Fix", "해결")}: ${messageText(codexDisplay.action, env)}`);
|
|
98
|
+
if (codexDisplay.currentSession === "unwrapped") o.add(o.t(" Start a new Codex session after setup to attach the usage row.", " setup 후 새 Codex 세션부터 사용량 줄이 연결됩니다."));
|
|
99
|
+
o.add(` PATH command: ${codex.activeCodex || "not found"}`);
|
|
91
100
|
o.add(` status_line: ${codex.statusLine.error ? "error" : codex.statusLine.configured ? "configured" : "optional"}`);
|
|
92
101
|
o.error(" Error", codex.statusLine.error);
|
|
93
102
|
o.add(` Logs: ${codex.sessionsExists ? "ready" : "not found"}`);
|
|
@@ -96,10 +105,14 @@ export function formatDoctorResult(result, { env = process.env } = {}) {
|
|
|
96
105
|
if (codex.compositor) o.add(` Compositor: ${codex.compositor.available ? "ready" : "dependencies missing"}`);
|
|
97
106
|
if (codex.rowpty?.layoutRequested) o.add(` rowpty: ${codex.rowpty.installed ? "ready" : "not found"} · ConPTY: ${codex.rowpty.bundledConpty ? "bundled" : "OS"}`);
|
|
98
107
|
o.lines.push("");
|
|
99
|
-
|
|
108
|
+
const claudeDisplay = claude.terminalDisplay || claudeTerminalDisplay(claude.statusLine, claude.statuslineCache);
|
|
109
|
+
o.add("Claude:");
|
|
110
|
+
o.add(` Visibility: ${claude.providerEnabled ? "on" : "off"}`);
|
|
111
|
+
if (!claude.providerEnabled) o.add(" Show: ai-battery on claude");
|
|
112
|
+
o.add(` TUI: ${claudeDisplay.status}`);
|
|
113
|
+
if (claudeDisplay.action) o.add(` ${o.t("Next", "다음")}: ${messageText(claudeDisplay.action, env)}`);
|
|
100
114
|
o.add(` statusLine: ${claude.statusLine.error ? "error" : claude.statusLine.managed ? "ready" : claude.statusLine.configured ? "external" : "not configured"}`);
|
|
101
115
|
o.add(` Cache: ${claude.statuslineCache ? "ready" : "waiting"}`);
|
|
102
|
-
if (claude.statusLine.managed && !claude.statuslineCache) o.add(o.t(" Start Claude Code to receive usage data.", " Claude Code를 실행하면 사용량이 수집됩니다."));
|
|
103
116
|
if (result.tmux) {
|
|
104
117
|
o.lines.push("");
|
|
105
118
|
o.add(`tmux: ${result.tmux.error ? "error" : result.tmux.configured ? result.tmux.insideTmux ? "configured · in session" : "configured · outside session" : "not configured"}`);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Installation readiness is independent of the on/off visibility preference.
|
|
2
|
+
// These states describe the next command; an existing session is separate.
|
|
3
|
+
export function codexTerminalDisplay(data, { platform = process.platform, layout = "" } = {}) {
|
|
4
|
+
let status = "ready";
|
|
5
|
+
let action = null;
|
|
6
|
+
if (!data.wrapperInstalled) {
|
|
7
|
+
status = "not configured";
|
|
8
|
+
action = "ai-battery setup codex";
|
|
9
|
+
} else if (!data.activeIsWrapper) {
|
|
10
|
+
status = "PATH mismatch";
|
|
11
|
+
action = platform === "win32" ? "Open a new terminal to apply PATH changes."
|
|
12
|
+
: "Load the shell configuration or open a new terminal, then run hash -r (zsh: rehash).";
|
|
13
|
+
} else if (!data.runnerExists) {
|
|
14
|
+
status = "runner missing";
|
|
15
|
+
action = "npm install -g ai-battery@latest";
|
|
16
|
+
} else if (platform !== "win32" && !data.python3) {
|
|
17
|
+
status = "python3 missing";
|
|
18
|
+
action = "Install Python 3, then run codex again.";
|
|
19
|
+
} else if (!(data.followsPath ? data.resolvedOriginalCommand : data.originalExists)) {
|
|
20
|
+
status = "Codex missing";
|
|
21
|
+
action = "Install Codex or restore its original command on PATH, then run ai-battery setup codex.";
|
|
22
|
+
} else if (platform === "win32" && layout === "plain") {
|
|
23
|
+
status = "disabled by layout";
|
|
24
|
+
action = "Set AI_BATTERY_WIN_LAYOUT=composite, then run codex again.";
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
status,
|
|
28
|
+
ready: status === "ready",
|
|
29
|
+
action,
|
|
30
|
+
currentSession: !data.insideCodex ? "not checked" : data.currentCodexWrapped ? "wrapped" : "unwrapped"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function claudeTerminalDisplay(statusLine, hasReading) {
|
|
35
|
+
const status = statusLine.error ? "settings error" : !statusLine.configured ? "not configured"
|
|
36
|
+
: !statusLine.managed ? "external statusLine" : statusLine.needsRefresh ? "update required"
|
|
37
|
+
: hasReading ? "ready" : "waiting for data";
|
|
38
|
+
return {
|
|
39
|
+
status,
|
|
40
|
+
ready: ["ready", "waiting for data"].includes(status),
|
|
41
|
+
action: status === "not configured" || status === "update required" ? "ai-battery setup claude"
|
|
42
|
+
: status === "external statusLine" ? "ai-battery setup claude --force"
|
|
43
|
+
: status === "waiting for data" ? "Start Claude Code to receive usage data." : null
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Gio from "gi://Gio";
|
|
2
2
|
import GLib from "gi://GLib";
|
|
3
|
+
import { gnomeHudUuid, legacyGnomeHudUuids } from "./gnome-uuid.js";
|
|
3
4
|
|
|
4
|
-
const uuid =
|
|
5
|
+
const uuid = ARGV[1] || gnomeHudUuid;
|
|
6
|
+
if (![gnomeHudUuid, ...legacyGnomeHudUuids].includes(uuid)) throw new Error("Unsupported AI Battery extension UUID");
|
|
5
7
|
const service = "org.gnome.Shell.Extensions";
|
|
6
8
|
const object = "/org/gnome/Shell";
|
|
7
9
|
function call(method, args = null, iface = service) {
|
|
@@ -22,9 +24,12 @@ if (info.available && ["enable", "disable"].includes(ARGV[0])) {
|
|
|
22
24
|
const enable = ARGV[0] === "enable";
|
|
23
25
|
if (!enable) info.accepted = call("DisableExtension", new GLib.Variant("(s)", [uuid]))[0];
|
|
24
26
|
const settings = new Gio.Settings({ schema_id: "org.gnome.shell" });
|
|
27
|
+
// DisableExtension can leave the old UUID in disabled-extensions. Clean
|
|
28
|
+
// both identities when applying the new one, including after a partial move.
|
|
29
|
+
const identities = uuid === gnomeHudUuid ? [uuid, ...legacyGnomeHudUuids] : [uuid];
|
|
25
30
|
for (const key of ["enabled-extensions", "disabled-extensions"]) {
|
|
26
31
|
const previous = settings.get_strv(key);
|
|
27
|
-
let next = previous.filter(value => value
|
|
32
|
+
let next = previous.filter(value => !identities.includes(value));
|
|
28
33
|
if (enable && key === "enabled-extensions") next.push(uuid);
|
|
29
34
|
if (next.join("\0") !== previous.join("\0") && !settings.set_strv(key, next)) throw new Error(`Could not update ${key}`);
|
|
30
35
|
}
|
|
@@ -3,9 +3,11 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { gnomeHudUuid, legacyGnomeHudUuids } from "./gnome-uuid.js";
|
|
7
|
+
|
|
8
|
+
export { gnomeHudUuid } from "./gnome-uuid.js";
|
|
6
9
|
|
|
7
10
|
const directory = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
export const gnomeHudUuid = "ai-battery@hnode.dev";
|
|
9
11
|
export const gnomeHudMetadata = {
|
|
10
12
|
uuid: gnomeHudUuid, name: "AI Battery", description: "Codex and Claude usage with the macOS detail menu",
|
|
11
13
|
"shell-version": ["45", "46", "47", "48", "49", "50"], version: 1,
|
|
@@ -13,52 +15,73 @@ export const gnomeHudMetadata = {
|
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export function createGnomeHudIntegration({ home = os.homedir(), env = process.env, run = spawnSync } = {}) {
|
|
16
|
-
const
|
|
18
|
+
const extensions = path.join(env.XDG_DATA_HOME || path.join(home, ".local/share"), "gnome-shell/extensions");
|
|
19
|
+
const target = path.join(extensions, gnomeHudUuid);
|
|
17
20
|
const source = path.join(directory, "gnome-extension/extension.js");
|
|
18
21
|
const gjs = env.AI_BATTERY_GJS || (fs.existsSync("/usr/bin/gjs") ? "/usr/bin/gjs" : "gjs");
|
|
19
|
-
function control(action) {
|
|
20
|
-
const result = run(gjs, ["-m", path.join(directory, "gnome-control.js"), action], { env, encoding: "utf8", timeout: 8000 });
|
|
22
|
+
function control(action, uuid = gnomeHudUuid) {
|
|
23
|
+
const result = run(gjs, ["-m", path.join(directory, "gnome-control.js"), action, uuid], { env, encoding: "utf8", timeout: 8000 });
|
|
21
24
|
if (result.status !== 0 || result.error) throw new Error(result.error?.message || result.stderr?.trim() || "GNOME HUD integration failed");
|
|
22
25
|
return JSON.parse(result.stdout);
|
|
23
26
|
}
|
|
24
|
-
function owned() {
|
|
25
|
-
const stat = fs.lstatSync(
|
|
27
|
+
function owned(directory = target, uuid = gnomeHudUuid) {
|
|
28
|
+
const stat = fs.lstatSync(directory, { throwIfNoEntry: false });
|
|
26
29
|
if (!stat) return false;
|
|
30
|
+
// Removal may leave unrelated notes in the directory. Their presence is
|
|
31
|
+
// not an installed extension and must not block a later prepare/reset.
|
|
32
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()
|
|
33
|
+
&& !fs.lstatSync(path.join(directory, "metadata.json"), { throwIfNoEntry: false })
|
|
34
|
+
&& !fs.lstatSync(path.join(directory, "extension.js"), { throwIfNoEntry: false })) return false;
|
|
27
35
|
let metadata;
|
|
28
36
|
try {
|
|
29
|
-
const file = path.join(
|
|
37
|
+
const file = path.join(directory, "metadata.json");
|
|
30
38
|
const metaStat = fs.lstatSync(file);
|
|
31
|
-
const codeStat = fs.lstatSync(path.join(
|
|
39
|
+
const codeStat = fs.lstatSync(path.join(directory, "extension.js"));
|
|
32
40
|
if (!stat.isDirectory() || stat.isSymbolicLink() || !metaStat.isFile() || metaStat.isSymbolicLink()
|
|
33
41
|
|| !codeStat.isFile() || codeStat.isSymbolicLink()) throw new Error("Unowned extension");
|
|
34
42
|
metadata = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
35
43
|
} catch { /* Report one ownership error without modifying the directory. */ }
|
|
36
|
-
if (metadata?.uuid !==
|
|
37
|
-
throw new Error(`GNOME HUD extension ownership could not be verified; left untouched: ${
|
|
44
|
+
if (metadata?.uuid !== uuid || metadata["ai-battery-managed"] !== true) {
|
|
45
|
+
throw new Error(`GNOME HUD extension ownership could not be verified; left untouched: ${directory}`);
|
|
38
46
|
}
|
|
39
47
|
return true;
|
|
40
48
|
}
|
|
49
|
+
function legacyInstallations() {
|
|
50
|
+
return legacyGnomeHudUuids.map(uuid => ({ uuid, directory: path.join(extensions, uuid) }))
|
|
51
|
+
.filter(item => owned(item.directory, item.uuid));
|
|
52
|
+
}
|
|
53
|
+
function removeOwned(directory, uuid) {
|
|
54
|
+
control("disable", uuid);
|
|
55
|
+
for (const name of ["extension.js", "metadata.json"]) fs.unlinkSync(path.join(directory, name));
|
|
56
|
+
if (!fs.readdirSync(directory).length) fs.rmdirSync(directory);
|
|
57
|
+
}
|
|
41
58
|
function prepare() {
|
|
42
59
|
const info = control("info");
|
|
43
60
|
if (!info.available || !gnomeHudMetadata["shell-version"].includes(String(info.version).split(".")[0])) return { supported: false };
|
|
44
61
|
const exists = owned();
|
|
62
|
+
// Validate both identities before modifying files or desktop settings.
|
|
63
|
+
const legacy = legacyInstallations();
|
|
45
64
|
const code = fs.readFileSync(source, "utf8");
|
|
46
|
-
const
|
|
65
|
+
const metadata = `${JSON.stringify(gnomeHudMetadata, null, 2)}\n`;
|
|
66
|
+
const changed = !exists || fs.readFileSync(path.join(target, "extension.js"), "utf8") !== code
|
|
67
|
+
|| fs.readFileSync(path.join(target, "metadata.json"), "utf8") !== metadata;
|
|
47
68
|
if (changed) {
|
|
48
69
|
fs.mkdirSync(target, { recursive: true, mode: 0o700 });
|
|
49
70
|
fs.writeFileSync(path.join(target, "extension.js"), code, { mode: 0o600 });
|
|
50
|
-
fs.writeFileSync(path.join(target, "metadata.json"),
|
|
71
|
+
fs.writeFileSync(path.join(target, "metadata.json"), metadata, { mode: 0o600 });
|
|
51
72
|
}
|
|
73
|
+
for (const item of legacy) removeOwned(item.directory, item.uuid);
|
|
52
74
|
const enabled = control("enable");
|
|
53
|
-
return { supported: true, pending: !enabled.accepted || changed, blocked: !info.allowed, path: target
|
|
75
|
+
return { supported: true, pending: !enabled.accepted || changed, blocked: !info.allowed, path: target,
|
|
76
|
+
migrated: legacy.map(item => item.uuid) };
|
|
54
77
|
}
|
|
55
78
|
function remove() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return { changed: true, path: target };
|
|
79
|
+
const exists = owned();
|
|
80
|
+
const legacy = legacyInstallations();
|
|
81
|
+
if (!exists && !legacy.length) return { changed: false };
|
|
82
|
+
if (exists) removeOwned(target, gnomeHudUuid);
|
|
83
|
+
for (const item of legacy) removeOwned(item.directory, item.uuid);
|
|
84
|
+
return { changed: true, path: exists ? target : legacy[0].directory };
|
|
62
85
|
}
|
|
63
86
|
return { prepare, remove, target };
|
|
64
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-battery",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"vendor/rowpty/RowPty.cs",
|
|
44
44
|
"docs/*.svg",
|
|
45
45
|
"docs/RELEASING.md",
|
|
46
|
+
"docs/SETUP-REGRESSION.md",
|
|
46
47
|
"README.md"
|
|
47
48
|
],
|
|
48
49
|
"scripts": {
|
|
@@ -29,6 +29,7 @@ const env = { ...process.env, HOME: home, CODEX_HOME: codex, LANGUAGE: "ko", GIO
|
|
|
29
29
|
AI_BATTERY_STATE_DIR: path.join(root, "state"), AI_BATTERY_DATA_DIR: path.join(root, "data"),
|
|
30
30
|
AI_BATTERY_SHARED_USAGE_STATE_DIR: path.join(root, "shared"), AI_BATTERY_NO_UPDATE_CHECK: "1",
|
|
31
31
|
AI_BATTERY_MENU_ROOT: root, AI_BATTERY_MENU_SOURCE: runtime, AI_BATTERY_MENU_NODE: process.execPath,
|
|
32
|
+
AI_BATTERY_MENU_UUID: gnomeHudMetadata.uuid,
|
|
32
33
|
AI_BATTERY_MENU_BUS: linuxHudBusName(path.join(root, "state")) };
|
|
33
34
|
for (const key of ["DISPLAY", "WAYLAND_DISPLAY", "GNOME_KEYRING_CONTROL", "GNOME_SETUP_DISPLAY", "SESSION_MANAGER", "DBUS_STARTER_ADDRESS", "DBUS_STARTER_BUS_TYPE"]) delete env[key];
|
|
34
35
|
const on = spawnSync(process.execPath, [path.join(runtime, "bin/ai-battery.js"), "on", "all"], { env, encoding: "utf8" });
|
|
@@ -32,7 +32,7 @@ export async function run() {
|
|
|
32
32
|
const source = GLib.getenv("AI_BATTERY_MENU_SOURCE");
|
|
33
33
|
const node = GLib.getenv("AI_BATTERY_MENU_NODE");
|
|
34
34
|
const name = GLib.getenv("AI_BATTERY_MENU_BUS");
|
|
35
|
-
const uuid =
|
|
35
|
+
const uuid = GLib.getenv("AI_BATTERY_MENU_UUID");
|
|
36
36
|
Main.overview.hide();
|
|
37
37
|
const backend = Gio.Subprocess.new(["gjs", "-m", `${source}/lib/platforms/linux/panel.js`, "--bus-name", name,
|
|
38
38
|
"--node", node, "--snapshot", `${source}/lib/platforms/linux/panel-snapshot.js`, "--state-dir", `${root}/state`, "--provider", "all"],
|
|
@@ -42,6 +42,15 @@ export async function run() {
|
|
|
42
42
|
extension = Main.extensionManager.lookup(uuid)?.stateObj;
|
|
43
43
|
return extension?._panels?.size === 1;
|
|
44
44
|
});
|
|
45
|
+
// GNOME can retain the disabled old UUID after its directory was migrated.
|
|
46
|
+
// Exercise the real controller against Shell and dconf, not a command stub.
|
|
47
|
+
const settings = new Gio.Settings({ schema_id: "org.gnome.shell" });
|
|
48
|
+
const disabled = settings.get_strv("disabled-extensions").filter(value => value !== "ai-battery@hnode.dev");
|
|
49
|
+
settings.set_strv("disabled-extensions", [...disabled, "ai-battery@hnode.dev"]);
|
|
50
|
+
Gio.Settings.sync();
|
|
51
|
+
await command(["gjs", "-m", `${source}/lib/platforms/linux/gnome-control.js`, "enable", uuid]);
|
|
52
|
+
await until(() => !settings.get_strv("disabled-extensions").includes("ai-battery@hnode.dev"));
|
|
53
|
+
expect(settings.get_strv("disabled-extensions").join("\0") === disabled.join("\0"), "Migration must preserve unrelated disabled extensions");
|
|
45
54
|
let panel = extension._panels.get(name);
|
|
46
55
|
await until(() => panel.data.presentation === "gnome");
|
|
47
56
|
expect(panel.detail.width === 392, "Detail artwork must retain the macOS width");
|
|
@@ -90,7 +99,7 @@ export async function run() {
|
|
|
90
99
|
await call(name, "Quit");
|
|
91
100
|
await until(() => extension._panels.size === 0);
|
|
92
101
|
const result = { result: "passed", checks: ["Shared macOS detail SVG at full size", "Open GNOME menu renders artwork",
|
|
93
|
-
"Korean menu actions", "Provider visibility and image resizing", "Standard tray fallback on disable", "Enable/reconnect and service shutdown"],
|
|
102
|
+
"Korean menu actions", "Provider visibility and image resizing", "Legacy UUID settings cleanup", "Standard tray fallback on disable", "Enable/reconnect and service shutdown"],
|
|
94
103
|
screenshot: `${root}/detail-menu.png`, fullScreenshot: `${root}/menu.png`, detailImage: detailPath };
|
|
95
104
|
GLib.file_set_contents(`${root}/result.json`, new TextEncoder().encode(JSON.stringify(result, null, 2)));
|
|
96
105
|
print(JSON.stringify(result));
|