offgrid-ai 0.3.7 → 0.3.9

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/install.sh CHANGED
@@ -123,15 +123,38 @@ if $DRY_RUN; then
123
123
  exit 0
124
124
  fi
125
125
 
126
+ # ── Determine npm global bin directory ──────────────────────────────────────
127
+ # npm bin -g was removed in npm v10+. Fall back to $(npm prefix -g)/bin.
128
+
129
+ NPM_BIN=""
130
+ if command -v npm &>/dev/null; then
131
+ # Try the modern way first, then legacy
132
+ NPM_PREFIX="$(npm prefix -g 2>/dev/null || true)"
133
+ if [[ -n "$NPM_PREFIX" ]]; then
134
+ NPM_BIN="${NPM_PREFIX}/bin"
135
+ fi
136
+ # Validate: the binary should exist there
137
+ if [[ ! -d "$NPM_BIN" ]]; then
138
+ NPM_BIN=""
139
+ fi
140
+ fi
141
+
126
142
  # ── Add npm global bin to PATH if needed ────────────────────────────────────
127
143
 
128
- NPM_BIN="$(npm bin -g 2>/dev/null)"
144
+ INSTALLED_VERSION=""
145
+
146
+ if [[ -n "$NPM_BIN" && -x "$NPM_BIN/offgrid-ai" ]]; then
147
+ # Get version
148
+ INSTALLED_VERSION="$(OFFGRID_NO_UPDATE_CHECK=1 "$NPM_BIN/offgrid-ai" version 2>/dev/null || echo "")"
129
149
 
130
- if ! command -v offgrid-ai &>/dev/null; then
131
- if [[ -n "$NPM_BIN" && -x "$NPM_BIN/offgrid-ai" ]]; then
132
- # Add to current session
150
+ if command -v offgrid-ai &>/dev/null; then
151
+ # Already on PATH nothing to do
152
+ ok "offgrid-ai ${INSTALLED_VERSION:+v${INSTALLED_VERSION} }installed at $(command -v offgrid-ai)"
153
+ else
154
+ # Not on PATH — add it
133
155
  export PATH="$NPM_BIN:$PATH"
134
156
  ok "Added $NPM_BIN to PATH for this session"
157
+ ok "offgrid-ai ${INSTALLED_VERSION:+v${INSTALLED_VERSION} }installed"
135
158
 
136
159
  # Add to shell config for future sessions (pick first existing or .zshrc)
137
160
  ADDED_TO_RC=false
@@ -152,13 +175,20 @@ if ! command -v offgrid-ai &>/dev/null; then
152
175
  if ! $ADDED_TO_RC; then
153
176
  warn "$NPM_BIN is already in a shell config file — restart your terminal to use offgrid-ai"
154
177
  fi
178
+ fi
179
+ else
180
+ # Fallback: try to find it anywhere on PATH after install
181
+ if command -v offgrid-ai &>/dev/null; then
182
+ INSTALLED_VERSION="$(offgrid-ai version 2>/dev/null || echo "")"
183
+ ok "offgrid-ai ${INSTALLED_VERSION:+v${INSTALLED_VERSION} }installed at $(command -v offgrid-ai)"
155
184
  else
156
185
  echo ""
157
- warn "offgrid-ai was installed but the binary wasn't found."
186
+ warn "offgrid-ai was installed but could not be found."
158
187
  echo " Restart your terminal and run: offgrid-ai"
188
+ echo " Or run: npx offgrid-ai"
159
189
  echo ""
160
190
  printf "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}\n"
161
- printf "${BOLD}${GREEN} offgrid-ai is ready!${RESET}\n"
191
+ printf "${BOLD}${GREEN} offgrid-ai is installed!${RESET}\n"
162
192
  printf "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}\n"
163
193
  echo ""
164
194
  echo " Run: offgrid-ai"
@@ -167,13 +197,11 @@ if ! command -v offgrid-ai &>/dev/null; then
167
197
  fi
168
198
  fi
169
199
 
170
- ok "offgrid-ai installed at $(command -v offgrid-ai)"
171
-
172
200
  # ── Done ─────────────────────────────────────────────────────────────────────
173
201
 
174
202
  echo ""
175
203
  printf "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}\n"
176
- printf "${BOLD}${GREEN} offgrid-ai is ready!${RESET}\n"
204
+ printf "${BOLD}${GREEN} offgrid-ai ${INSTALLED_VERSION:+v${INSTALLED_VERSION} }is ready!${RESET}\n"
177
205
  printf "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}\n"
178
206
  echo ""
179
207
  echo " First run will walk you through setting up everything you need"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "offgrid-ai",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
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/logs.mjs CHANGED
@@ -2,6 +2,7 @@ import { existsSync, statSync } from "node:fs";
2
2
  import { appendFile } from "node:fs/promises";
3
3
  import { createReadStream } from "node:fs";
4
4
  import pc from "picocolors";
5
+ import { stripVTControlCharacters } from "node:util";
5
6
 
6
7
  export function tailFriendly(rawLogPath, friendlyLogPath) {
7
8
  let offset = existsSync(rawLogPath) ? statSync(rawLogPath).size : 0;
@@ -21,7 +22,7 @@ export function tailFriendly(rawLogPath, friendlyLogPath) {
21
22
  if (!friendly || seen.has(friendly)) continue;
22
23
  seen.add(friendly);
23
24
  console.log(friendly);
24
- await appendFile(friendlyLogPath, pc.strip(friendly) + "\n", "utf8");
25
+ await appendFile(friendlyLogPath, stripVTControlCharacters(friendly) + "\n", "utf8");
25
26
  }
26
27
  } catch { /* friendly logging must never crash */ }
27
28
  }, 300);
package/src/ui.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { cancel, confirm, intro, isCancel, select, text } from "@clack/prompts";
2
2
  import pc from "picocolors";
3
+ import { stripVTControlCharacters } from "node:util";
3
4
 
4
5
  export { pc };
5
6
  export { pc as colors };
@@ -50,9 +51,9 @@ function handleCancel(value) {
50
51
  }
51
52
 
52
53
  export function renderRows(rows) {
53
- const width = Math.max(...rows.map(([key]) => pc.strip(String(key)).length));
54
+ const width = Math.max(...rows.map(([key]) => stripVTControlCharacters(String(key)).length));
54
55
  return rows.map(([key, value]) => {
55
- const visible = pc.strip(String(key)).length;
56
+ const visible = stripVTControlCharacters(String(key)).length;
56
57
  return `${key}${" ".repeat(Math.max(1, width - visible + 2))}${value}`;
57
58
  }).join("\n");
58
59
  }