offgrid-ai 0.8.13 → 0.8.14

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/updates.mjs +3 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "offgrid-ai",
3
- "version": "0.8.13",
3
+ "version": "0.8.14",
4
4
  "description": "Privacy-first CLI for running local LLMs — discover, configure, run, benchmark",
5
5
  "author": "Eeshan Srivastava (https://eeshans.com)",
6
6
  "type": "module",
package/src/updates.mjs CHANGED
@@ -1,27 +1,13 @@
1
1
  import { spawn } from "node:child_process";
2
- import { readFile, writeFile, mkdir } from "node:fs/promises";
3
2
  import { readFileSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
3
  import { fileURLToPath } from "node:url";
6
- import { DATA_DIR } from "./config.mjs";
7
4
 
8
5
  const PACKAGE_NAME = "offgrid-ai";
9
- const UPDATE_CHECK_INTERVAL = 24 * 60 * 60 * 1000;
10
6
 
11
- export async function checkForUpdate({ now = Date.now(), fetchImpl = globalThis.fetch, force = false } = {}) {
7
+ export async function checkForUpdate({ fetchImpl = globalThis.fetch } = {}) {
12
8
  if (process.env.OFFGRID_NO_UPDATE_CHECK) return null;
13
9
 
14
10
  const currentVersion = currentPackageVersion();
15
- const cacheFile = join(DATA_DIR, "update-cache.json");
16
- const cached = await readUpdateCache(cacheFile);
17
-
18
- // Use cache if fresh (within 24h) and still applies to current version
19
- if (!force && cached?.lastChecked && now - cached.lastChecked < UPDATE_CHECK_INTERVAL) {
20
- if (cached.currentVersion === currentVersion) {
21
- return updateResult(currentVersion, cached.latestVersion);
22
- }
23
- // Cache is from a different installed version — invalidate and refetch
24
- }
25
11
 
26
12
  try {
27
13
  const response = await fetchImpl(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
@@ -32,9 +18,6 @@ export async function checkForUpdate({ now = Date.now(), fetchImpl = globalThis.
32
18
  const latestVersion = typeof body?.version === "string" ? body.version : null;
33
19
  if (!latestVersion) return null;
34
20
 
35
- await mkdir(DATA_DIR, { recursive: true });
36
- await writeFile(cacheFile, JSON.stringify({ lastChecked: now, currentVersion, latestVersion }, null, 2) + "\n", "utf8");
37
-
38
21
  return updateResult(currentVersion, latestVersion);
39
22
  } catch {
40
23
  return null;
@@ -42,8 +25,8 @@ export async function checkForUpdate({ now = Date.now(), fetchImpl = globalThis.
42
25
  }
43
26
 
44
27
  export function currentPackageVersion() {
45
- const __dirname = dirname(fileURLToPath(import.meta.url));
46
- const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
28
+ const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
29
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
47
30
  return pkg.version;
48
31
  }
49
32
 
@@ -97,14 +80,6 @@ export function runUpdateCommand(plan) {
97
80
  });
98
81
  }
99
82
 
100
- async function readUpdateCache(cacheFile) {
101
- try {
102
- return JSON.parse(await readFile(cacheFile, "utf8"));
103
- } catch {
104
- return null;
105
- }
106
- }
107
-
108
83
  function updateResult(currentVersion, latestVersion) {
109
84
  return isNewerVersion(latestVersion, currentVersion)
110
85
  ? { current: currentVersion, latest: latestVersion }