ai-battery 0.1.6 → 0.1.7

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.
@@ -169,7 +169,24 @@ function quoteCmdArg(value) {
169
169
  return `"${String(value).replace(/"/g, '""')}"`;
170
170
  }
171
171
 
172
+ function normalizeWindowsCommandPath(value) {
173
+ let text = String(value || "").trim();
174
+ for (let i = 0; i < 6; i += 1) {
175
+ const before = text;
176
+ text = text.replace(/\\"/g, "\"").trim();
177
+ if (
178
+ (text.startsWith("\"") && text.endsWith("\""))
179
+ || (text.startsWith("'") && text.endsWith("'"))
180
+ ) {
181
+ text = text.slice(1, -1).trim();
182
+ }
183
+ if (text === before) break;
184
+ }
185
+ return text;
186
+ }
187
+
172
188
  function resolveWindowsCommandFile(commandPath) {
189
+ commandPath = normalizeWindowsCommandPath(commandPath);
173
190
  if (path.extname(commandPath)) return commandPath;
174
191
  for (const suffix of [".cmd", ".exe", ".bat", ".ps1"]) {
175
192
  const candidate = `${commandPath}${suffix}`;
package/bin/ai-battery.js CHANGED
@@ -537,7 +537,24 @@ function cmdQuote(value) {
537
537
  return `"${String(value).replace(/"/g, '""')}"`;
538
538
  }
539
539
 
540
+ function normalizeWindowsCommandPath(value) {
541
+ let text = String(value || "").trim();
542
+ for (let i = 0; i < 6; i += 1) {
543
+ const before = text;
544
+ text = text.replace(/\\"/g, "\"").trim();
545
+ if (
546
+ (text.startsWith("\"") && text.endsWith("\""))
547
+ || (text.startsWith("'") && text.endsWith("'"))
548
+ ) {
549
+ text = text.slice(1, -1).trim();
550
+ }
551
+ if (text === before) break;
552
+ }
553
+ return text;
554
+ }
555
+
540
556
  function windowsCommandSibling(commandPath) {
557
+ commandPath = normalizeWindowsCommandPath(commandPath);
541
558
  if (path.extname(commandPath)) return commandPath;
542
559
  for (const suffix of [".cmd", ".exe", ".bat", ".ps1"]) {
543
560
  const candidate = `${commandPath}${suffix}`;
@@ -1100,7 +1117,11 @@ function diagnoseCodex() {
1100
1117
  notes.push(`A Codex backup is available for restore: ${activeWrapperBackup}`);
1101
1118
  }
1102
1119
  if (wrapperInstalled && !activeIsWrapper) {
1103
- notes.push(`Plain "codex" does not resolve to the AI Battery wrapper in this shell. Ensure ${path.dirname(configuredWrapper)} is before the original codex on PATH, then open a new terminal or run "hash -r" in the parent shell.`);
1120
+ const wrapperDir = path.dirname(configuredWrapper);
1121
+ const refreshNote = process.platform === "win32"
1122
+ ? `open a new cmd/PowerShell, or run: $env:Path="${wrapperDir};$env:Path"`
1123
+ : "open a new terminal or run \"hash -r\" in the parent shell";
1124
+ notes.push(`Plain "codex" does not resolve to the AI Battery wrapper in this shell. Ensure ${wrapperDir} is before the original codex on PATH, then ${refreshNote}.`);
1104
1125
  }
1105
1126
  if (!runnerExists) {
1106
1127
  notes.push(`AI Battery runner is missing or not executable: ${runnerPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
5
5
  "type": "module",
6
6
  "keywords": [