offgrid-ai 0.15.0 → 0.15.1
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 +1 -1
- package/src/commands/models.mjs +34 -17
- package/src/model-presenters.mjs +26 -4
package/package.json
CHANGED
package/src/commands/models.mjs
CHANGED
|
@@ -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,42 @@ export async function modelCommandCenter(initialCatalog) {
|
|
|
65
65
|
return "setup";
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
for (const { backendId, sourceId, items } of byBackend.values()) {
|
|
86
|
+
const backendLabel = backendFor(backendId)?.label ?? backendId;
|
|
87
|
+
const sourceLabel = formatSourceLabel(sourceId);
|
|
88
|
+
const sep = sourceLabel && sourceLabel !== backendLabel
|
|
89
|
+
? `${backendLabel} · ${sourceLabel} (${items.length})`
|
|
90
|
+
: `${backendLabel} (${items.length})`;
|
|
91
|
+
const groupItems = items.map((item) => {
|
|
92
|
+
const opt = modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth, compact: true });
|
|
93
|
+
return { value: opt.value, label: opt.label, description: opt.description };
|
|
94
|
+
});
|
|
95
|
+
groups.push({ separator: ` ${sep}`, items: groupItems });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (setupItems.length > 0) {
|
|
99
|
+
const groupItems = setupItems.map((item) => {
|
|
100
|
+
const opt = modelSelectOption(item, { runningProfilesNow, modelMissingIds, nameWidth, compact: true });
|
|
101
|
+
return { value: opt.value, label: opt.label, description: opt.description };
|
|
85
102
|
});
|
|
86
|
-
groups.push({ separator: `
|
|
103
|
+
groups.push({ separator: ` Needs setup (${setupItems.length})`, items: groupItems });
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
const prompt = createPrompt();
|
package/src/model-presenters.mjs
CHANGED
|
@@ -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.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
|