@tiens.nguyen/gu-cli 1.0.686
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/README.md +52 -0
- package/agent-model-command.mjs +259 -0
- package/agent-model-label.mjs +159 -0
- package/clear-state.mjs +149 -0
- package/client-expert-api.mjs +736 -0
- package/client-expert-run.mjs +892 -0
- package/client-expert-setup.mjs +616 -0
- package/coding-choice-tags.mjs +69 -0
- package/coding-key-prompt.mjs +229 -0
- package/coding-provider-setup.mjs +808 -0
- package/completed-flush.mjs +105 -0
- package/daemon-control.mjs +462 -0
- package/device-login.mjs +212 -0
- package/doctor-check.mjs +239 -0
- package/embed-model-command.mjs +157 -0
- package/first-run-steps.mjs +171 -0
- package/gonext_agent_chat.py +12299 -0
- package/gonext_mlx_embed.py +155 -0
- package/gonext_probe_agent.py +93 -0
- package/gonext_transcribe.py +130 -0
- package/gu-cli.mjs +4930 -0
- package/gu-repl.mjs +10326 -0
- package/job-pools.mjs +89 -0
- package/model-doctor.mjs +1494 -0
- package/node-version.mjs +40 -0
- package/ollama-setup.mjs +832 -0
- package/package.json +100 -0
- package/platform-tools.mjs +520 -0
- package/poll-errors.mjs +141 -0
- package/proxy-command.mjs +165 -0
- package/proxy-config.mjs +255 -0
- package/proxy-dispatcher.mjs +132 -0
- package/proxy-selftest.mjs +234 -0
- package/proxy-store.mjs +69 -0
- package/rag-job-config.mjs +59 -0
- package/rag-selftest.mjs +215 -0
- package/s3-setup.mjs +85 -0
- package/terminal-copy.mjs +248 -0
- package/terminal-hover.mjs +153 -0
- package/terminal-layout.mjs +2507 -0
- package/terminal-viewport.mjs +602 -0
- package/thinking_words.txt +1003 -0
- package/version-check.mjs +72 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is something newer available, and which installed version should actually be used?
|
|
3
|
+
*
|
|
4
|
+
* TWO THINGS GO STALE INDEPENDENTLY (task #181) and neither was ever checked:
|
|
5
|
+
* · the CLI — @tiens.nguyen/gu-cli on npm
|
|
6
|
+
* · the API — the Client Expert package on S3, per ~/.gonext/api/<version>/
|
|
7
|
+
*
|
|
8
|
+
* They share nothing but the question. The CLI's answer means "restart gu"; the API's means
|
|
9
|
+
* "restart the local API, dropping whatever it was serving". So only the COMPARISON lives here,
|
|
10
|
+
* pure and testable without a network, a bucket or a registry — the fetches belong to the
|
|
11
|
+
* callers, which is also what lets a failed probe degrade to "no update" instead of an error.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compare two dotted versions numerically. → negative if a < b, 0 if equal, positive if a > b.
|
|
16
|
+
*
|
|
17
|
+
* NOT a string compare, which is the bug this exists to avoid: "1.0.9" > "1.0.10" lexically,
|
|
18
|
+
* and the version numbers here are already past that boundary. Non-numeric junk sorts as 0
|
|
19
|
+
* rather than NaN, so a malformed manifest can never make a comparison silently reverse.
|
|
20
|
+
*/
|
|
21
|
+
export function compareVersions(a, b) {
|
|
22
|
+
const parts = (v) => String(v ?? "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
23
|
+
const A = parts(a);
|
|
24
|
+
const B = parts(b);
|
|
25
|
+
for (let i = 0; i < Math.max(A.length, B.length); i++) {
|
|
26
|
+
const d = (A[i] ?? 0) - (B[i] ?? 0);
|
|
27
|
+
if (d) return d;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Is `available` strictly newer than `running`? Missing either side ⇒ no. */
|
|
33
|
+
export function isNewer(available, running) {
|
|
34
|
+
if (!available || !running) return false;
|
|
35
|
+
return compareVersions(available, running) > 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The version to actually START, from what is installed on disk. → the version, or "".
|
|
40
|
+
*
|
|
41
|
+
* NEWEST USABLE, NOT NEWEST. This is the outage fix. `api start` used to sort the directory
|
|
42
|
+
* names and take the last one, with no check that it could run — so an interrupted upgrade
|
|
43
|
+
* (source unpacked, dependencies not yet installed) sorted highest, was chosen, and failed with
|
|
44
|
+
* `Cannot find package 'dotenv'` while a perfectly good older version sat beside it. Observed
|
|
45
|
+
* on a live machine, which was down until the deps were installed by hand.
|
|
46
|
+
*
|
|
47
|
+
* `usable` is injected rather than read here so the rule is testable without a filesystem, and
|
|
48
|
+
* so the caller decides what "usable" means (today: node_modules present).
|
|
49
|
+
*/
|
|
50
|
+
export function pickUsableVersion(versions, usable = () => true) {
|
|
51
|
+
const sorted = [...(versions ?? [])]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.sort((a, b) => compareVersions(a, b));
|
|
54
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
55
|
+
if (usable(sorted[i])) return sorted[i];
|
|
56
|
+
}
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* What the user should be told is available. → { cli, api, any }
|
|
62
|
+
*
|
|
63
|
+
* Each side is either "" (nothing newer, or we could not find out) or the newer version. The
|
|
64
|
+
* two are kept SEPARATE all the way to the UI because acting on them differs: one restarts the
|
|
65
|
+
* API, the other requires restarting gu itself. Collapsing them into a boolean here is what
|
|
66
|
+
* would make a single ambiguous "update available" button, which is the thing to avoid.
|
|
67
|
+
*/
|
|
68
|
+
export function updatesAvailable({ cliRunning, cliLatest, apiRunning, apiLatest } = {}) {
|
|
69
|
+
const cli = isNewer(cliLatest, cliRunning) ? String(cliLatest) : "";
|
|
70
|
+
const api = isNewer(apiLatest, apiRunning) ? String(apiLatest) : "";
|
|
71
|
+
return { cli, api, any: Boolean(cli || api) };
|
|
72
|
+
}
|