ai-battery 0.1.19 → 0.1.20

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/docs/RELEASING.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # npm release
2
2
 
3
- The current release candidate is **0.1.19**. `latest` on npm was checked as **0.1.18** on 2026-10-09. Publishing the same name/version twice is not allowed.
3
+ The current release candidate is **0.1.20**. `latest` on npm was checked as **0.1.19** on 2026-10-09. Publishing the same name/version twice is not allowed.
4
+
5
+ 0.1.20 configures the bundled node-pty ConPTY input pipe for blocking writes before forwarding terminal replies or keyboard input. Nonblocking pipe writes can otherwise return EAGAIN and destroy an unhandled Socket. If the installed transport cannot be configured, the compositor closes its child and falls back to native execution. The actual Codex fullscreen fixture passed all 13 checks after the change; the user's intermittent crash has not been independently reproduced.
4
6
 
5
7
  Preflight on 2026-10-09 passed 105 Windows tests (24 platform skips) and 117 WSL tests (12 platform skips). The installed tarball passed all 13 actual Codex 0.161.0 fullscreen checks under system Node 22.15.1 with automatic private-runtime selection. A fresh official runtime download, SHA256 verification, extraction and launch also passed. Windows and WSL installed CLI readings were checked against the same shared account usage. npm publication and remote Git changes remain pending.
6
8
 
@@ -29,26 +31,26 @@ Inspect the package file list. Screenshots, logs, credentials, local runtime bin
29
31
  ```powershell
30
32
  npm login
31
33
  npm whoami
32
- npm publish ./ai-battery-0.1.19.tgz --access public --tag latest
34
+ npm publish ./ai-battery-0.1.20.tgz --access public --tag latest
33
35
  npm view ai-battery version dist-tags --json
34
36
  ```
35
37
 
36
- Use the exact tested tarball. Complete npm's authentication/2FA prompt when requested. This repository's preflight does not perform `npm login` or `npm publish` automatically. If 0.1.19 has already been published by the time you release, increment the package version and repeat the preparation.
38
+ Use the exact tested tarball. Complete npm's authentication/2FA prompt when requested. This repository's preflight does not perform `npm login` or `npm publish` automatically. If 0.1.20 has already been published by the time you release, increment the package version and repeat the preparation.
37
39
 
38
40
  For a preview instead of replacing `latest`:
39
41
 
40
42
  ```powershell
41
- npm publish ./ai-battery-0.1.19.tgz --access public --tag next
43
+ npm publish ./ai-battery-0.1.20.tgz --access public --tag next
42
44
  ```
43
45
 
44
- After a successful publication, tag the tested commit (`v0.1.19`), push the release commit/tag, and remove merged remote feature branches. Do not delete the remote test branch before the integrated release commit reaches the remote main branch.
46
+ After a successful publication, tag the tested commit (`v0.1.20`), push the release commit/tag, and remove merged remote feature branches. Do not delete the remote test branch before the integrated release commit reaches the remote main branch.
45
47
 
46
48
  ## Update installed integrations
47
49
 
48
50
  Run this separately in Windows and WSL:
49
51
 
50
52
  ```text
51
- npm install -g ai-battery@0.1.19
53
+ npm install -g ai-battery@0.1.20
52
54
  ai-battery setup codex
53
55
  ai-battery doctor
54
56
  ```
@@ -630,6 +630,16 @@ function compositorWindowsPty(release = os.release()) {
630
630
  };
631
631
  }
632
632
 
633
+ function configureWindowsPtyInput(term) {
634
+ // node-pty 1.1 opens ConPTY's input pipe as a net.Socket. A nonblocking
635
+ // Windows pipe write can return EAGAIN and destroy that socket. Match the
636
+ // blocking pipe descriptor used by the native console input transport.
637
+ const handle = term?._agent?.inSocket?._handle;
638
+ if (typeof handle?.setBlocking !== "function") throw new Error("ConPTY input pipe cannot be configured safely");
639
+ const result = handle.setBlocking(true);
640
+ if (result !== 0) throw new Error(`ConPTY blocking input configuration failed: ${result}`);
641
+ }
642
+
633
643
  async function runFullscreenCompositor(args, activeProvider) {
634
644
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
635
645
  debugLog("fullscreen:unavailable", {
@@ -689,7 +699,9 @@ async function runFullscreenCompositor(args, activeProvider) {
689
699
  useConptyDll: compositorUsesBundledConpty(),
690
700
  conptyInheritCursor: false
691
701
  });
702
+ configureWindowsPtyInput(term);
692
703
  } catch (error) {
704
+ try { term?.kill?.(); } catch {}
693
705
  await compositor?.dispose?.().catch(() => {});
694
706
  debugLog("fullscreen:error", { stage: "spawn", error: error.message, command });
695
707
  return null;
@@ -1349,6 +1361,7 @@ export {
1349
1361
  compositorFrameIntervalMs,
1350
1362
  compositorUsesBundledConpty,
1351
1363
  compositorWindowsPty,
1364
+ configureWindowsPtyInput,
1352
1365
  conPtyBackspaceMode,
1353
1366
  conPtyRepaintIntervalMs,
1354
1367
  isVsCodeTerminal,
@@ -6,7 +6,8 @@ import path from "node:path";
6
6
  export function createWindowsPathIntegration({
7
7
  pathDirPrecedesOriginal,
8
8
  samePath,
9
- uniquePaths
9
+ uniquePaths,
10
+ runPowerShell
10
11
  }) {
11
12
 
12
13
  function psQuote(value) {
@@ -14,6 +15,7 @@ function psQuote(value) {
14
15
  }
15
16
 
16
17
  function runWindowsPowerShell(script) {
18
+ if (runPowerShell) return runPowerShell(script);
17
19
  return spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", script], {
18
20
  encoding: "utf8",
19
21
  windowsHide: true,
@@ -23,7 +25,8 @@ function runWindowsPowerShell(script) {
23
25
 
24
26
  function windowsUserPathParts() {
25
27
  const result = runWindowsPowerShell("[Environment]::GetEnvironmentVariable('Path', 'User')");
26
- const text = result.status === 0 ? result.stdout : "";
28
+ if (result.status !== 0) throw new Error("Could not read Windows user PATH; leaving it unchanged");
29
+ const text = result.stdout;
27
30
  return String(text || "")
28
31
  .trim()
29
32
  .split(";")
@@ -48,32 +51,33 @@ function windowsUserPathWithShim(parts, shimDir) {
48
51
  !sameWindowsPath(entry, shimDir)
49
52
  && !staleWindowsAiBatteryTempPath(entry)
50
53
  ));
54
+ const next = [shimDir, ...filtered];
51
55
  return {
52
- parts: [shimDir, ...filtered],
53
- changed: filtered.length !== parts.length || !sameWindowsPath(parts[0] || "", shimDir)
56
+ parts: next,
57
+ changed: next.length !== parts.length || next.some((entry, index) => !sameWindowsPath(entry, parts[index] || ""))
54
58
  };
55
59
  }
56
60
 
57
61
  function ensureWindowsShimPath(shimDir, originalCommand) {
58
62
  const activeNow = pathDirPrecedesOriginal(shimDir, originalCommand);
59
- if (activeNow) {
63
+ if (process.env.AI_BATTERY_SKIP_WINDOWS_PATH_WRITE === "1") {
60
64
  return {
61
65
  changed: false,
62
66
  rcPath: null,
63
- note: `${shimDir} is already before the original codex on PATH. Plain "codex" can use AI Battery in new command lookups. Open a new cmd/PowerShell if this terminal cached the old command.`
67
+ note: `Skipped Windows user PATH update for ${shimDir}`
64
68
  };
65
69
  }
66
70
 
67
- if (process.env.AI_BATTERY_SKIP_WINDOWS_PATH_WRITE === "1") {
71
+ const parts = windowsUserPathParts();
72
+ const nextPath = windowsUserPathWithShim(parts, shimDir);
73
+ if (activeNow && !nextPath.changed) {
68
74
  return {
69
75
  changed: false,
70
76
  rcPath: null,
71
- note: `Skipped Windows user PATH update for ${shimDir}`
77
+ note: `${shimDir} is already configured in the Windows user PATH. Open a new cmd/PowerShell if this terminal cached the old command.`
72
78
  };
73
79
  }
74
80
 
75
- const parts = windowsUserPathParts();
76
- const nextPath = windowsUserPathWithShim(parts, shimDir);
77
81
  const next = nextPath.parts.join(";");
78
82
  const result = runWindowsPowerShell(`[Environment]::SetEnvironmentVariable('Path', ${psQuote(next)}, 'User')`);
79
83
  if (result.status !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -58,7 +58,8 @@
58
58
  "node": ">=18"
59
59
  },
60
60
  "dependencies": {
61
- "@xterm/headless": "6.0.0"
61
+ "@xterm/headless": "6.0.0",
62
+ "ai-battery": "^0.1.19"
62
63
  },
63
64
  "optionalDependencies": {
64
65
  "node-pty": "1.1.0"