@tiens.nguyen/gu-cli 1.0.741 → 1.0.742
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/coding-key-prompt.mjs +21 -6
- package/gu-repl.mjs +6 -2
- package/package.json +1 -1
package/coding-key-prompt.mjs
CHANGED
|
@@ -24,6 +24,8 @@ const identity = (s) => s;
|
|
|
24
24
|
* and on Ctrl+K to replace one — and they were two hand-written copies of the same idea. A hint
|
|
25
25
|
* added to one of them would have left the other exactly as confusing.
|
|
26
26
|
*/
|
|
27
|
+
import { keyInUse } from "./server-keys.mjs";
|
|
28
|
+
|
|
27
29
|
export const SECRET_KEY_HINT = "type or paste the key, then press Enter — it stays masked";
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -217,13 +219,26 @@ export function codingKeyFallbackLine(kj, jobId = "") {
|
|
|
217
219
|
* when a choice HAS been made, and when only one key exists — with one there is nothing to
|
|
218
220
|
* choose, and a warning on a correct setup is how warnings stop being read.
|
|
219
221
|
*/
|
|
220
|
-
export function unchosenKeyWarning({ codingKind = "", codingUrl = "", selectedKeyId = "", keys = null } = {}) {
|
|
222
|
+
export function unchosenKeyWarning({ codingKind = "", codingUrl = "", selectedKeyId = "", keys = null, backendId = "" } = {}) {
|
|
221
223
|
const quiet = { warn: false, using: null, why: "" };
|
|
222
224
|
// Local Ollama and MLX need no credential; the Ollama cloud does.
|
|
223
225
|
if (!codingNeedsKey(codingKind, codingUrl)) return quiet;
|
|
224
|
-
if (!Array.isArray(keys)
|
|
226
|
+
if (!Array.isArray(keys)) return quiet;
|
|
225
227
|
if (String(selectedKeyId ?? "").trim()) return quiet;
|
|
226
|
-
|
|
228
|
+
// KEYS BELONG TO A SERVER (#245). Reported: the bar said "key not chosen" beside ollama.com while
|
|
229
|
+
// the key picker showed its one key, hsbc_ollama, "(in use)" — because this counted all seven keys
|
|
230
|
+
// on the ACCOUNT (Anthropic, OpenAI, …) where the API only ever chooses among THIS server's keys.
|
|
231
|
+
// With the server known: its keys, else the keys tied to no server; and a server default IS a
|
|
232
|
+
// choice. Without it (an older caller) the old account-wide count stands.
|
|
233
|
+
if (backendId) {
|
|
234
|
+
const own = keys.filter((k) => k && k.backendId === backendId);
|
|
235
|
+
const pool = own.length ? own : keys.filter((k) => k && !k.backendId);
|
|
236
|
+
if (own.some((k) => k.default)) return quiet;
|
|
237
|
+
if (pool.length < 2) return quiet;
|
|
238
|
+
return { warn: true, using: keyInUse(keys, backendId) ?? pool[0], why: "none-chosen", count: pool.length };
|
|
239
|
+
}
|
|
240
|
+
if (keys.length < 2) return quiet;
|
|
241
|
+
return { warn: true, using: keys[0], why: "none-chosen", count: keys.length };
|
|
227
242
|
}
|
|
228
243
|
|
|
229
244
|
/**
|
|
@@ -245,14 +260,14 @@ export function unchosenKeyWarning({ codingKind = "", codingUrl = "", selectedKe
|
|
|
245
260
|
* qualified ("<kind>::<model>", task #123) stores the bare form and is still a valid pick.
|
|
246
261
|
*/
|
|
247
262
|
/** The folder's coder — its kind AND its URL, which together decide whether it needs a key. */
|
|
248
|
-
export function effectiveCoder({ sessionCodingModel = "", choices = null, defaultKind = "", defaultUrl = "" } = {}) {
|
|
263
|
+
export function effectiveCoder({ sessionCodingModel = "", choices = null, defaultKind = "", defaultUrl = "", defaultBackendId = "" } = {}) {
|
|
249
264
|
const want = String(sessionCodingModel ?? "").trim();
|
|
250
265
|
const list = Array.isArray(choices) ? choices : [];
|
|
251
266
|
if (want) {
|
|
252
267
|
const hit = list.find((c) => c?.id === want || c?.model === want);
|
|
253
|
-
if (hit) return { kind: String(hit.kind ?? ""), url: String(hit.url ?? "") };
|
|
268
|
+
if (hit) return { kind: String(hit.kind ?? ""), url: String(hit.url ?? ""), backendId: String(hit.backendId ?? "") };
|
|
254
269
|
}
|
|
255
|
-
return { kind: String(defaultKind ?? ""), url: String(defaultUrl ?? "") };
|
|
270
|
+
return { kind: String(defaultKind ?? ""), url: String(defaultUrl ?? ""), backendId: String(defaultBackendId ?? "") };
|
|
256
271
|
}
|
|
257
272
|
|
|
258
273
|
export function effectiveCoderKind({
|
package/gu-repl.mjs
CHANGED
|
@@ -6251,6 +6251,8 @@ async function chooseModel() {
|
|
|
6251
6251
|
codingKind: "openai",
|
|
6252
6252
|
selectedKeyId: sessionCodingKeyId,
|
|
6253
6253
|
keys: keysNow,
|
|
6254
|
+
// Only THIS server's keys are a choice to make (#245) — not every key on the account.
|
|
6255
|
+
backendId: ks.backendId,
|
|
6254
6256
|
}).warn;
|
|
6255
6257
|
const line = codingKeyLine({
|
|
6256
6258
|
keys: keysNow,
|
|
@@ -10976,11 +10978,12 @@ async function main() {
|
|
|
10976
10978
|
// machine an Ollama coder, which needs no key — while the folder was on gpt-5. Reading
|
|
10977
10979
|
// it directly made this check answer about a coder nobody was using, and the mark only
|
|
10978
10980
|
// appeared after /model, which re-probes WITH the override.
|
|
10979
|
-
const { kind, url } = effectiveCoder({
|
|
10981
|
+
const { kind, url, backendId } = effectiveCoder({
|
|
10980
10982
|
sessionCodingModel,
|
|
10981
10983
|
choices: probe?.codingChoices,
|
|
10982
10984
|
defaultKind: p?.codingKind,
|
|
10983
10985
|
defaultUrl: probe?.codingChoices?.find?.((c) => c?.isDefault)?.url ?? "",
|
|
10986
|
+
defaultBackendId: probe?.codingChoices?.find?.((c) => c?.isDefault)?.backendId ?? "",
|
|
10984
10987
|
});
|
|
10985
10988
|
const allKeys =
|
|
10986
10989
|
codingNeedsKey(kind, url) && !sessionCodingKeyId ? await fetchCodingKeys() : null;
|
|
@@ -10989,6 +10992,7 @@ async function main() {
|
|
|
10989
10992
|
codingUrl: url,
|
|
10990
10993
|
selectedKeyId: sessionCodingKeyId,
|
|
10991
10994
|
keys: allKeys,
|
|
10995
|
+
backendId,
|
|
10992
10996
|
});
|
|
10993
10997
|
// THE BAR CARRIES IT TOO, from the same decision — a line printed at startup scrolls
|
|
10994
10998
|
// away within a few turns, and the report was precisely that the warning has to be
|
|
@@ -10996,7 +11000,7 @@ async function main() {
|
|
|
10996
11000
|
keyChoicePending = w.warn;
|
|
10997
11001
|
if (w.warn) {
|
|
10998
11002
|
console.log(
|
|
10999
|
-
GUTTER + orange(` ${
|
|
11003
|
+
GUTTER + orange(` ${w.count} API keys for this server and this folder has not chosen one`) +
|
|
11000
11004
|
dim(` — using ${w.using.name} ····${w.using.tail}.`)
|
|
11001
11005
|
);
|
|
11002
11006
|
console.log(GUTTER + dim(" ctrl+k picks the right one; a wrong key fails mid-task.\n"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gu-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.742",
|
|
4
4
|
"description": "Gu CLI — the gu terminal plus the local worker that runs agent / OCR / PDF / embedding jobs on your Mac (Ollama / MLX / OpenAI-compatible).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|