ai-battery 0.1.15 → 0.1.16
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 +2 -0
- package/bin/ai-battery-hud.js +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/ai-battery-hud.js
CHANGED
|
@@ -661,6 +661,20 @@ function runPowerShell(command) {
|
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
+
function refreshWslHudScriptCopy() {
|
|
665
|
+
if (!useWsl) return null;
|
|
666
|
+
const result = runPowerShell([
|
|
667
|
+
"$dir = Join-Path $env:LOCALAPPDATA 'ai-battery'",
|
|
668
|
+
"New-Item -ItemType Directory -Force -Path $dir | Out-Null",
|
|
669
|
+
"$hud = Join-Path $dir 'ai-battery-hud.ps1'",
|
|
670
|
+
`Copy-Item ${psSingleQuote(hudScript)} $hud -Force -ErrorAction Stop`,
|
|
671
|
+
"Write-Output $hud"
|
|
672
|
+
].join("; "));
|
|
673
|
+
if (result.status !== 0) return null;
|
|
674
|
+
const output = (result.stdout || "").trim().split(/\r?\n/).filter(Boolean).pop();
|
|
675
|
+
return output || null;
|
|
676
|
+
}
|
|
677
|
+
|
|
664
678
|
function hudProcessStatus() {
|
|
665
679
|
const query = "$hud = Get-CimInstance Win32_Process | Where-Object { "
|
|
666
680
|
+ "$_.ProcessId -ne $PID -and "
|
|
@@ -756,6 +770,7 @@ if (subcommand === "autostart") {
|
|
|
756
770
|
process.exit(0);
|
|
757
771
|
}
|
|
758
772
|
|
|
773
|
+
const launchHudScript = stop ? hudScript : (refreshWslHudScriptCopy() || hudScript);
|
|
759
774
|
const wasRunning = (!foreground && !once && !stop)
|
|
760
775
|
? hudProcessStatus().startsWith("running ")
|
|
761
776
|
: false;
|
|
@@ -782,7 +797,7 @@ if (useWsl) {
|
|
|
782
797
|
hudScriptArgs.push("-UseWsl");
|
|
783
798
|
}
|
|
784
799
|
|
|
785
|
-
const psArgs = powerShellCommandArgs(
|
|
800
|
+
const psArgs = powerShellCommandArgs(launchHudScript, hudScriptArgs);
|
|
786
801
|
|
|
787
802
|
if (foreground || once || stop) {
|
|
788
803
|
const result = spawnSync(powershell, psArgs, { stdio: "inherit", windowsHide: true });
|