offgrid-ai 0.15.0 → 0.15.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "offgrid-ai",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
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",
@@ -6,7 +6,7 @@ import { syncPiConfig, removeFromPiConfig } from "../harness-pi.mjs";
6
6
  import { configureLocalProfile } from "../profile-setup.mjs";
7
7
  import { pc, startInteractive, createPrompt, modelSelect } from "../ui.mjs";
8
8
  import { buildCatalogItems, createManagedProfile, itemKey, loadModelCatalog, normalizeCatalog } from "../model-catalog.mjs";
9
- import { modelSelectOption, modelNameWidth, printGgufModelDetails, printMlxModelDetails, printManagedModelDetails, printWorkspaceHeader, printBenchmarkLine, printProfileDetails } from "../model-presenters.mjs";
9
+ import { modelSelectOption, modelNameWidth, inferBackendId, formatSourceLabel, discoverySourceForItem, printGgufModelDetails, printMlxModelDetails, printManagedModelDetails, printWorkspaceHeader, printBenchmarkLine, printProfileDetails } from "../model-presenters.mjs";
10
10
  import { runProfile } from "./run.mjs";
11
11
 
12
12
  const { stripVTControlCharacters } = await import("node:util");
@@ -65,25 +65,40 @@ export async function modelCommandCenter(initialCatalog) {
65
65
  return "setup";
66
66
  };
67
67
 
68
- const groupOrder = ["running", "ready", "setup", "missing"];
69
- const groupLabels = {
70
- running: "Running now",
71
- ready: "Ready",
72
- setup: "Needs setup",
73
- missing: "Missing files",
74
- };
75
- const grouped = new Map(groupOrder.map((key) => [key, []]));
76
- for (const item of allItems) grouped.get(statusFor(item)).push(item);
68
+ // Group ready/running/missing profiles by backend, setup items separate
69
+ const byBackend = new Map();
70
+ const setupItems = [];
71
+ for (const item of allItems) {
72
+ const s = statusFor(item);
73
+ if (s === "setup") {
74
+ setupItems.push(item);
75
+ } else {
76
+ const backendId = inferBackendId(item);
77
+ const sourceId = discoverySourceForItem(item) ?? "unknown";
78
+ const key = `${backendId}:${sourceId}`;
79
+ if (!byBackend.has(key)) byBackend.set(key, { backendId, sourceId, items: [] });
80
+ byBackend.get(key).items.push(item);
81
+ }
82
+ }
77
83
 
78
84
  const groups = [];
79
- for (const group of groupOrder) {
80
- const bucket = grouped.get(group);
81
- if (!bucket || bucket.length === 0) continue;
82
- const items = bucket.map((item) => {
83
- const opt = modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth });
84
- return { value: opt.value, label: opt.label, description: opt.hint };
85
+ for (const { backendId, sourceId, items } of byBackend.values()) {
86
+ const backendLabel = backendFor(backendId)?.label ?? backendId;
87
+ const sourceLabel = formatSourceLabel(sourceId);
88
+ const sep = `Inference: ${backendLabel} via Download Source: ${sourceLabel} (${items.length})`;
89
+ const groupItems = items.map((item) => {
90
+ const opt = modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth, compact: true });
91
+ return { value: opt.value, label: opt.label, description: opt.description };
92
+ });
93
+ groups.push({ separator: ` ${sep}`, items: groupItems });
94
+ }
95
+
96
+ if (setupItems.length > 0) {
97
+ const groupItems = setupItems.map((item) => {
98
+ const opt = modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth, compact: true });
99
+ return { value: opt.value, label: opt.label, description: opt.description };
85
100
  });
86
- groups.push({ separator: ` ${groupLabels[group]} (${bucket.length})`, items });
101
+ groups.push({ separator: ` Needs setup (${setupItems.length})`, items: groupItems });
87
102
  }
88
103
 
89
104
  const prompt = createPrompt();
@@ -62,7 +62,7 @@ function optionBackendTag(backendId) {
62
62
  return optionPad(label, colors[backendId] ?? pc.dim, OPTION_BACKEND_WIDTH);
63
63
  }
64
64
 
65
- function formatSourceLabel(sourceId) {
65
+ export function formatSourceLabel(sourceId) {
66
66
  if (!sourceId) return "unknown";
67
67
  const map = {
68
68
  huggingface: "HuggingFace",
@@ -95,7 +95,7 @@ function discoverySourceForProfile(profile) {
95
95
  return inferSourceFromPath(profile.modelPath);
96
96
  }
97
97
 
98
- function discoverySourceForItem(item) {
98
+ export function discoverySourceForItem(item) {
99
99
  if (item.type === "profile") return discoverySourceForProfile(item.profile);
100
100
  return item.model?.source ?? null;
101
101
  }
@@ -132,9 +132,10 @@ function optionLabel({ status, backend, source, name, quant, ctx, size, nameWidt
132
132
  return [status, backend, source, pc.bold(optionPad(name, null, nameWidth)), quant, ctx, pc.dim(size)].join(OPTION_SEPARATOR);
133
133
  }
134
134
 
135
- export function modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth }) {
135
+ export function modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth, compact = false }) {
136
136
  const sourceId = discoverySourceForItem(item) ?? "unknown";
137
137
  const backendId = inferBackendId(item);
138
+
138
139
  if (item.type === "profile") {
139
140
  const backend = backendFor(item.profile.backend);
140
141
  const running = runningProfilesNow.some((profile) => profile.id === item.profile.id);
@@ -144,6 +145,16 @@ export function modelSelectOption(item, { runningProfilesNow, modelMissingIds, n
144
145
  const hint = drafterMissing ? "MTP drafter missing — reconfigure"
145
146
  : modelMissing ? `${backend.label} model no longer available`
146
147
  : undefined;
148
+
149
+ if (compact) {
150
+ const indicator = status === "running" ? pc.green("●") : status === "missing" ? pc.red("✗") : pc.dim("○");
151
+ return {
152
+ value: itemKey(item),
153
+ label: [indicator, pc.bold(optionPad(item.label, null, nameWidth)), optionQuantLabel(item), optionCtxLabel(item), pc.dim(optionSizeLabel(item))].join(OPTION_SEPARATOR),
154
+ ...(hint ? { description: pc.red(hint) } : {}),
155
+ };
156
+ }
157
+
147
158
  return {
148
159
  value: itemKey(item),
149
160
  label: optionLabel({
@@ -159,6 +170,17 @@ export function modelSelectOption(item, { runningProfilesNow, modelMissingIds, n
159
170
  ...(hint ? { hint: pc.red(hint) } : {}),
160
171
  };
161
172
  }
173
+
174
+ // Setup item (new model or managed without profile)
175
+ if (compact) {
176
+ const backendLabel = backendFor(backendId)?.label ?? backendId;
177
+ const full = `${item.label} · ${backendLabel}`;
178
+ return {
179
+ value: itemKey(item),
180
+ label: [pc.yellow("○"), pc.yellow(pc.bold(optionPad(full, null, nameWidth))), optionQuantLabel(item), optionCtxLabel(item), pc.dim(optionSizeLabel(item))].join(OPTION_SEPARATOR),
181
+ };
182
+ }
183
+
162
184
  return {
163
185
  value: itemKey(item),
164
186
  label: optionLabel({
@@ -174,7 +196,7 @@ export function modelSelectOption(item, { runningProfilesNow, modelMissingIds, n
174
196
  };
175
197
  }
176
198
 
177
- function inferBackendId(item) {
199
+ export function inferBackendId(item) {
178
200
  if (item.type === "profile") return item.profile.backend;
179
201
  if (item.type === "managed") return item.backendId;
180
202
  // new model: derive from format
package/src/ui.mjs CHANGED
@@ -144,7 +144,10 @@ export function createPrompt() {
144
144
 
145
145
  export async function modelSelect(label, groups, { defaultKey, pageSize = 20 } = {}) {
146
146
  const choices = [];
147
- for (const group of groups) {
147
+ for (let i = 0; i < groups.length; i++) {
148
+ const group = groups[i];
149
+ // Add blank line before each group (except the first)
150
+ if (i > 0) choices.push(new Separator(""));
148
151
  if (group.separator) {
149
152
  choices.push(new Separator(group.separator));
150
153
  }