getaimeter 0.7.5 → 0.7.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.
Files changed (3) hide show
  1. package/cli.js +20 -0
  2. package/package.json +1 -1
  3. package/tray.ps1 +12 -1
package/cli.js CHANGED
@@ -257,6 +257,26 @@ function runStart() {
257
257
  process.exitCode = 1;
258
258
  return;
259
259
  }
260
+
261
+ // Clean up stale lock file if the previous process died
262
+ const fs = require('fs');
263
+ const pathMod = require('path');
264
+ const lockFile = pathMod.join(AIMETER_DIR, 'watcher.lock');
265
+ try {
266
+ if (fs.existsSync(lockFile)) {
267
+ const lockData = JSON.parse(fs.readFileSync(lockFile, 'utf8'));
268
+ try {
269
+ process.kill(lockData.pid, 0);
270
+ // PID is alive — watcher is already running
271
+ console.log(`AIMeter watcher is already running (PID ${lockData.pid}).`);
272
+ return;
273
+ } catch {
274
+ // PID is dead — stale lock, remove it
275
+ fs.unlinkSync(lockFile);
276
+ }
277
+ }
278
+ } catch {}
279
+
260
280
  startNow();
261
281
  console.log('AIMeter watcher started.');
262
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getaimeter",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "Track AI coding costs across Claude, Cursor, Codex, and Gemini. Optimization recommendations that cut costs by 30%.",
5
5
  "bin": {
6
6
  "aimeter": "cli.js"
package/tray.ps1 CHANGED
@@ -122,7 +122,18 @@ $checkUpdateItem.Add_Click({
122
122
  [System.Windows.Forms.MessageBoxIcon]::Information
123
123
  )
124
124
  if ($result -eq [System.Windows.Forms.DialogResult]::Yes) {
125
- Start-Process "cmd.exe" -ArgumentList "/k echo Updating AIMeter... && npm install -g getaimeter@latest && echo. && echo Done! Now restart: aimeter stop ^&^& aimeter start"
125
+ # Update and auto-restart: stop watcher, update npm, restart watcher
126
+ $nodePath = (Get-Command node -ErrorAction SilentlyContinue).Source
127
+ $aimeter = (Get-Command aimeter -ErrorAction SilentlyContinue).Source
128
+ Start-Process "cmd.exe" -ArgumentList "/k echo Updating AIMeter... && npm install -g getaimeter@latest && echo. && echo Restarting watcher... && aimeter stop && timeout /t 2 /nobreak >nul && aimeter start && echo. && echo Updated to latest version! This window can be closed. && echo."
129
+
130
+ # Give the cmd window time to stop us, then exit this tray
131
+ Start-Sleep -Seconds 3
132
+ $tray.Visible = $false
133
+ $tray.Dispose()
134
+ $mutex.ReleaseMutex()
135
+ $mutex.Dispose()
136
+ [System.Windows.Forms.Application]::Exit()
126
137
  }
127
138
  } else {
128
139
  [System.Windows.Forms.MessageBox]::Show(