@getrift/rift 0.1.0-beta.19 → 0.1.0-beta.20
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/dist/src/cli/commands/status.d.ts.map +1 -1
- package/dist/src/cli/commands/status.js +38 -2
- package/dist/src/cli/commands/status.js.map +1 -1
- package/dist/src/cli/commands/update.d.ts +56 -5
- package/dist/src/cli/commands/update.d.ts.map +1 -1
- package/dist/src/cli/commands/update.js +250 -21
- package/dist/src/cli/commands/update.js.map +1 -1
- package/dist/src/cli/http-client.d.ts +25 -1
- package/dist/src/cli/http-client.d.ts.map +1 -1
- package/dist/src/cli/http-client.js +82 -0
- package/dist/src/cli/http-client.js.map +1 -1
- package/dist/src/cli/status/friend-header.d.ts.map +1 -1
- package/dist/src/cli/status/friend-header.js +3 -0
- package/dist/src/cli/status/friend-header.js.map +1 -1
- package/dist/src/diagnostics/codex-preflight.d.ts +1 -1
- package/dist/src/diagnostics/codex-preflight.d.ts.map +1 -1
- package/dist/src/diagnostics/codex-preflight.js +12 -0
- package/dist/src/diagnostics/codex-preflight.js.map +1 -1
- package/dist/src/diagnostics/doctor.d.ts.map +1 -1
- package/dist/src/diagnostics/doctor.js +2 -0
- package/dist/src/diagnostics/doctor.js.map +1 -1
- package/dist/src/observability/tool-usage-stats.d.ts.map +1 -1
- package/dist/src/observability/tool-usage-stats.js +14 -1
- package/dist/src/observability/tool-usage-stats.js.map +1 -1
- package/dist/src/providers/codex-cli-runner.d.ts.map +1 -1
- package/dist/src/providers/codex-cli-runner.js +43 -4
- package/dist/src/providers/codex-cli-runner.js.map +1 -1
- package/operator/swiftbar/render-menu.py +61 -18
- package/operator/swiftbar/rift.10s.sh +52 -28
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,iBAAiB,IAAI,OAAO,CA6H3C"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* header still prints (with an "unreachable" line) and the map is omitted.
|
|
14
14
|
*/
|
|
15
15
|
import { Command } from "commander";
|
|
16
|
-
import { createHttpClient, probeDefaultDaemonHealth, readToken, resolveBaseUrl, CliError, } from "../http-client.js";
|
|
16
|
+
import { createHttpClient, probeDefaultDaemonHealth, readToken, resolveBaseUrl, resolveBaseUrlLenient, CliError, } from "../http-client.js";
|
|
17
17
|
import { printError, printJson, printText } from "../output.js";
|
|
18
18
|
import { renderFriendHeader } from "../status/friend-header.js";
|
|
19
19
|
import { readLocalSignals } from "../status/local-signals.js";
|
|
@@ -31,6 +31,11 @@ export function makeStatusCommand() {
|
|
|
31
31
|
// resolveBaseUrl can't load a config; render a no-config-yet
|
|
32
32
|
// header instead of erroring out.
|
|
33
33
|
let baseUrl;
|
|
34
|
+
// When set, the config is newer than this CLI (an unknown top-level
|
|
35
|
+
// key like `codex_cli` from a later beta). We still render status —
|
|
36
|
+
// diagnostics must not die on a forward-compatible config — but we
|
|
37
|
+
// surface this line so the friend knows to update their CLI.
|
|
38
|
+
let staleCliNote = null;
|
|
34
39
|
try {
|
|
35
40
|
baseUrl = resolveBaseUrl(globalOpts.config);
|
|
36
41
|
}
|
|
@@ -39,7 +44,33 @@ export function makeStatusCommand() {
|
|
|
39
44
|
await renderNoConfigStatus(globalOpts.json, globalOpts.config);
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
// Per A-2.3a: status is the diagnostic command and must stay useful
|
|
48
|
+
// when an OLDER CLI meets a NEWER config. Strict Zod parsing fails
|
|
49
|
+
// closed on an unrecognized top-level key, but for status we only
|
|
50
|
+
// need the daemon's host/port — read those leniently and keep going.
|
|
51
|
+
// This does NOT weaken validation for daemon startup or write paths.
|
|
52
|
+
//
|
|
53
|
+
// Crucially, only a FORWARD-COMPAT failure (code "config_too_new":
|
|
54
|
+
// the config carries keys this CLI doesn't know) earns this path. A
|
|
55
|
+
// genuinely broken config (code "invalid": a known field with a bad
|
|
56
|
+
// value) must still surface as "config invalid" — otherwise status
|
|
57
|
+
// would tell the friend "your CLI is older than your config" when
|
|
58
|
+
// the real problem is a typo in their config. That diagnostic lie is
|
|
59
|
+
// exactly the failure mode this whole fix exists to kill.
|
|
60
|
+
if (err instanceof CliError && err.code === "config_too_new") {
|
|
61
|
+
const lenient = resolveBaseUrlLenient(globalOpts.config);
|
|
62
|
+
if (lenient) {
|
|
63
|
+
baseUrl = lenient;
|
|
64
|
+
staleCliNote =
|
|
65
|
+
"Your Rift CLI is older than your config. Update with: rift update (or npm install -g @getrift/rift@beta).";
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
43
74
|
}
|
|
44
75
|
const token = await readToken();
|
|
45
76
|
if (!token) {
|
|
@@ -72,6 +103,9 @@ export function makeStatusCommand() {
|
|
|
72
103
|
header: headerLines.join("\n"),
|
|
73
104
|
friend,
|
|
74
105
|
capability_map: capabilityMap,
|
|
106
|
+
// Present only when an older CLI read a newer config; consumers
|
|
107
|
+
// (menu bar) can surface the "update your CLI" nudge.
|
|
108
|
+
stale_cli: staleCliNote,
|
|
75
109
|
// Structured client-connection list for non-human consumers
|
|
76
110
|
// (the menu bar). The human header already folds this in;
|
|
77
111
|
// exposing it here keeps `rift status` the single source of
|
|
@@ -86,6 +120,8 @@ export function makeStatusCommand() {
|
|
|
86
120
|
}
|
|
87
121
|
for (const line of headerLines)
|
|
88
122
|
printText(line);
|
|
123
|
+
if (staleCliNote)
|
|
124
|
+
printText(`Heads up: ${staleCliNote}`);
|
|
89
125
|
if (opts.tools && capabilityMap) {
|
|
90
126
|
printText("");
|
|
91
127
|
printText(capabilityMap);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,SAAS,EACT,cAAc,EACd,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;SACzB,WAAW,CAAC,yDAAyD,CAAC;SACtE,MAAM,CAAC,SAAS,EAAE,iDAAiD,CAAC;SACpE,MAAM,CACL,qBAAqB,EACrB,+GAA+G,CAChH;SACA,MAAM,CAAC,KAAK,EAAE,IAAkD,EAAE,GAAG,EAAE,EAAE;QACxE,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,EAGrC,CAAC;QACF,IAAI,CAAC;YACH,gEAAgE;YAChE,6DAA6D;YAC7D,2DAA2D;YAC3D,6DAA6D;YAC7D,kCAAkC;YAClC,IAAI,OAAe,CAAC;YACpB,IAAI,CAAC;gBACH,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;oBACxD,MAAM,oBAAo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B,CAAC,CAAC,iEAAiE;QACnE,CAAC,CAAC,sFAAsF,CAAC;IAC3F,MAAM,KAAK,GAAG;QACZ,oBAAoB,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,gBAAgB;QACjE,gBAAgB,WAAW,EAAE;QAC7B,6BAA6B,UAAU,EAAE;KAC1C,CAAC;IACF,IAAI,MAAM,EAAE,CAAC;QACX,SAAS,CAAC;YACR,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YACxB,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,UAAU;YAC9B,SAAS,EAAE,KAAK,CAAC,EAAE;SACpB,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,SAAS,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { kickstartDaemon, waitForHealth } from "../../onboarding/daemon-control.js";
|
|
3
3
|
import { installMenuBar } from "./menubar.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where the `rift` the friend's shell actually runs lives, and what version
|
|
6
|
+
* it reports. Resolved by running the binary on PATH — never by trusting the
|
|
7
|
+
* currently-executing process, which is still the OLD build mid-update.
|
|
8
|
+
*/
|
|
9
|
+
export interface ActiveCliLocation {
|
|
10
|
+
/** Absolute path of `rift` resolved on PATH (e.g. /opt/homebrew/bin/rift), or null. */
|
|
11
|
+
binPath: string | null;
|
|
12
|
+
/** Install prefix owning that binary (parent of its bin dir), or null. */
|
|
13
|
+
prefix: string | null;
|
|
14
|
+
}
|
|
4
15
|
export interface UpdateRunner {
|
|
5
16
|
/**
|
|
6
|
-
* Run `npm install -g <spec
|
|
7
|
-
* can decide whether to retry with
|
|
8
|
-
* to the friend's terminal so progress
|
|
17
|
+
* Run `npm install -g <spec>`, optionally pinned to a global `--prefix`.
|
|
18
|
+
* Returns the exit code so the command can decide whether to retry with
|
|
19
|
+
* sudo. stderr/stdout pass through to the friend's terminal so progress
|
|
20
|
+
* is visible. When `prefix` is provided we install into that prefix so
|
|
21
|
+
* the copy on the friend's PATH is the copy that gets upgraded.
|
|
9
22
|
*/
|
|
10
|
-
runNpmInstall: (spec: string, useSudo: boolean) => Promise<number>;
|
|
23
|
+
runNpmInstall: (spec: string, useSudo: boolean, prefix?: string | null) => Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve where the `rift` on PATH lives (before install) so we can target
|
|
26
|
+
* its prefix and later diagnose a prefix mismatch.
|
|
27
|
+
*/
|
|
28
|
+
resolveActiveCli: () => Promise<ActiveCliLocation>;
|
|
29
|
+
/**
|
|
30
|
+
* Version the `rift` on PATH reports right now (`rift --version`). Called
|
|
31
|
+
* AFTER install to confirm the upgrade actually took. null if it can't run.
|
|
32
|
+
*/
|
|
33
|
+
getActiveCliVersion: () => Promise<string | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Expected version: `npm view @getrift/rift@beta version`. null on probe
|
|
36
|
+
* failure (offline / registry hiccup). A null expected version FAILS
|
|
37
|
+
* verification as `unverified` — we cannot prove the install landed, so we
|
|
38
|
+
* never claim success. (This is the invariant that keeps `rift update` from
|
|
39
|
+
* lying; see `evaluateUpgrade`.)
|
|
40
|
+
*/
|
|
41
|
+
getExpectedVersion: () => Promise<string | null>;
|
|
42
|
+
/** npm's own global prefix (`npm prefix -g`) — where a bare `-g` install lands. */
|
|
43
|
+
getNpmGlobalPrefix: () => Promise<string | null>;
|
|
11
44
|
/** Kickstart the daemon. Defaults to the launchctl helper. */
|
|
12
45
|
kickstart: typeof kickstartDaemon;
|
|
13
46
|
/** Poll /health. Defaults to the onboarding helper. */
|
|
@@ -18,7 +51,7 @@ export interface UpdateRunner {
|
|
|
18
51
|
export declare function makeUpdateCommand(): Command;
|
|
19
52
|
export interface UpdateResult {
|
|
20
53
|
ok: boolean;
|
|
21
|
-
step?: "npm" | "kickstart" | "health";
|
|
54
|
+
step?: "npm" | "verify" | "kickstart" | "health";
|
|
22
55
|
transcript: string[];
|
|
23
56
|
}
|
|
24
57
|
/**
|
|
@@ -26,4 +59,22 @@ export interface UpdateResult {
|
|
|
26
59
|
* always returns — exit-code mapping is the caller's job.
|
|
27
60
|
*/
|
|
28
61
|
export declare function runUpdate(runner: UpdateRunner): Promise<UpdateResult>;
|
|
62
|
+
type UpgradeFailure = "no_binary" | "unverified" | "mismatch";
|
|
63
|
+
/**
|
|
64
|
+
* Decide whether the active CLI actually upgraded. The contract is strict and
|
|
65
|
+
* biased toward honesty — "could not confirm" is a FAILURE, never a pass:
|
|
66
|
+
* - no active version at all → the binary is broken (`no_binary`).
|
|
67
|
+
* - no expected version → we couldn't reach the registry to learn the latest
|
|
68
|
+
* beta, so we cannot claim the update landed (`unverified`). This is the
|
|
69
|
+
* deliberate fix for "couldn't verify" silently becoming "updated".
|
|
70
|
+
* - active != expected → still the old (or wrong) build (`mismatch`).
|
|
71
|
+
* Only an active version that equals a freshly-resolved expected version is OK.
|
|
72
|
+
*/
|
|
73
|
+
export declare function evaluateUpgrade(expected: string | null, activeVersion: string | null): {
|
|
74
|
+
ok: true;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
reason: UpgradeFailure;
|
|
78
|
+
};
|
|
79
|
+
export {};
|
|
29
80
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,eAAe,EACf,aAAa,EACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE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;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAKtD"}
|
|
@@ -2,22 +2,44 @@
|
|
|
2
2
|
* `rift update` — friend-readable in-place upgrade for the npm-installed CLI.
|
|
3
3
|
*
|
|
4
4
|
* Steps (in order, each one printed):
|
|
5
|
-
* 1.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* 1. Resolve the target version with FRESH registry metadata
|
|
6
|
+
* (`npm view --prefer-online @getrift/rift@beta version`), then
|
|
7
|
+
* `npm install -g --prefer-online @getrift/rift@<that exact version>`.
|
|
8
|
+
* Pinning the exact version (not the `@beta` tag) plus `--prefer-online`
|
|
9
|
+
* removes the two ways an install can be a silent no-op: a stale local
|
|
10
|
+
* cache resolving the tag to the already-installed version, and the
|
|
11
|
+
* verify step later reading that same stale cache so a no-op "matches"
|
|
12
|
+
* itself. Falls back to `sudo npm install -g …` exactly like
|
|
13
|
+
* scripts/install.sh, so friends who installed via the one-liner without
|
|
14
|
+
* nvm don't hit a permission wall. When we can resolve where the `rift`
|
|
15
|
+
* on the friend's PATH lives, we install into THAT prefix (`--prefix`)
|
|
16
|
+
* so the copy their terminal runs is the copy that gets upgraded.
|
|
17
|
+
* 2. VERIFY: run the `rift` on PATH and confirm its version now equals the
|
|
18
|
+
* freshly-resolved expected version. An exit-0 npm install is NOT proof
|
|
19
|
+
* of an upgrade — npm can install into a different prefix than the binary
|
|
20
|
+
* on PATH. And if we could not reach the registry to learn the expected
|
|
21
|
+
* version at all, we FAIL as "could not verify" rather than passing on
|
|
22
|
+
* "installed something". We refuse to report success until the active
|
|
23
|
+
* version provably equals a freshly-resolved expected version. This is
|
|
24
|
+
* the load-bearing fix for the beta.18→beta.19 silent no-op that shipped
|
|
25
|
+
* a CLI too old to read its own (valid) config.
|
|
26
|
+
* 3. `launchctl kickstart -k gui/$UID/com.getrift.daemon` — restarts the
|
|
10
27
|
* daemon so it picks up the new code on disk.
|
|
11
|
-
*
|
|
28
|
+
* 4. Poll `/health` until 200 (or timeout) — proves the new build can
|
|
12
29
|
* actually start.
|
|
13
|
-
*
|
|
30
|
+
* 5. Refresh the SwiftBar menu plugin — keeps the 10-second menu surface
|
|
14
31
|
* on the same packaged scripts as the just-installed CLI.
|
|
15
32
|
*
|
|
16
33
|
* Failure contract:
|
|
17
34
|
* - npm install failure (step 1): the previous install is left in place.
|
|
18
35
|
* `npm install -g` with the same dist-tag is atomic enough here — npm
|
|
19
36
|
* replaces `bin/rift` only after a successful tarball install.
|
|
20
|
-
* -
|
|
37
|
+
* - Verification failure (step 2): npm reported success but the `rift` on
|
|
38
|
+
* PATH is still the old version. The transcript names both versions and
|
|
39
|
+
* all the paths, leads with a plain-English headline ("Rift updated one
|
|
40
|
+
* copy, but your terminal still points at another copy."), and prints the
|
|
41
|
+
* exact command to install into the right prefix.
|
|
42
|
+
* - Kickstart or /health failure (steps 3–4): the new package is already
|
|
21
43
|
* installed on disk; only daemon recovery is needed. The transcript
|
|
22
44
|
* says so explicitly and points at the manual recovery action.
|
|
23
45
|
* In every branch the output is a friend-readable error pointing at the
|
|
@@ -31,16 +53,23 @@
|
|
|
31
53
|
* loop (see src/observability/version-check.ts); this command does
|
|
32
54
|
* not write to that snapshot.
|
|
33
55
|
*/
|
|
34
|
-
import { spawn } from "node:child_process";
|
|
56
|
+
import { spawn, execFile } from "node:child_process";
|
|
57
|
+
import path from "node:path";
|
|
35
58
|
import { Command } from "commander";
|
|
36
59
|
import { kickstartDaemon, waitForHealth, } from "../../onboarding/daemon-control.js";
|
|
37
60
|
import { installMenuBar } from "./menubar.js";
|
|
38
61
|
import { printJson, printText } from "../output.js";
|
|
62
|
+
const RIFT_PACKAGE_NAME = "@getrift/rift";
|
|
39
63
|
const RIFT_PACKAGE_SPEC = "@getrift/rift@beta";
|
|
64
|
+
const RIFT_BETA_TAG = "@getrift/rift@beta";
|
|
40
65
|
const DAEMON_BASE_URL = "http://127.0.0.1:3577";
|
|
41
66
|
const HEALTH_TIMEOUT_MS = 30_000;
|
|
42
67
|
const defaultRunner = {
|
|
43
68
|
runNpmInstall: defaultNpmInstall,
|
|
69
|
+
resolveActiveCli: defaultResolveActiveCli,
|
|
70
|
+
getActiveCliVersion: defaultGetActiveCliVersion,
|
|
71
|
+
getExpectedVersion: defaultGetExpectedVersion,
|
|
72
|
+
getNpmGlobalPrefix: defaultGetNpmGlobalPrefix,
|
|
44
73
|
kickstart: kickstartDaemon,
|
|
45
74
|
waitForHealth,
|
|
46
75
|
installMenuBar,
|
|
@@ -71,26 +100,67 @@ export async function runUpdate(runner) {
|
|
|
71
100
|
const say = (line) => {
|
|
72
101
|
transcript.push(line);
|
|
73
102
|
};
|
|
74
|
-
// --- Step
|
|
75
|
-
|
|
76
|
-
|
|
103
|
+
// --- Step 1a: resolve the target version with FRESH registry metadata ---
|
|
104
|
+
// Resolve the expected version BEFORE installing, and force a registry
|
|
105
|
+
// round-trip (`npm view --prefer-online`). This is load-bearing: if both
|
|
106
|
+
// `npm install @beta` and the verification's `npm view @beta` read the same
|
|
107
|
+
// stale local cache, the tag can resolve to the version already installed —
|
|
108
|
+
// a no-op that then "verifies" against itself (beta.18 == beta.18) and the
|
|
109
|
+
// command lies. Pinning to the freshly-resolved EXACT version below removes
|
|
110
|
+
// the tag indirection from the install entirely.
|
|
111
|
+
const active = await runner.resolveActiveCli();
|
|
112
|
+
const installPrefix = active.prefix;
|
|
113
|
+
const expected = await runner.getExpectedVersion();
|
|
114
|
+
// --- Step 1b: npm install ---
|
|
115
|
+
// Install the exact pinned version when we know it (so a stale-cached tag
|
|
116
|
+
// can't redirect us), falling back to the @beta tag only when the registry
|
|
117
|
+
// probe failed. Install into the prefix that owns the `rift` on PATH so the
|
|
118
|
+
// copy the friend's shell runs is the copy that gets upgraded; when we can't
|
|
119
|
+
// resolve it, fall back to npm's choice and let verify (Step 2) catch a split.
|
|
120
|
+
const installSpec = expected ? `${RIFT_PACKAGE_NAME}@${expected}` : RIFT_PACKAGE_SPEC;
|
|
121
|
+
say(`==> Installing ${installSpec} via npm` +
|
|
122
|
+
(installPrefix ? ` (into ${installPrefix})` : ""));
|
|
123
|
+
let npmCode = await runner.runNpmInstall(installSpec, false, installPrefix);
|
|
77
124
|
if (npmCode !== 0) {
|
|
78
125
|
// npm exits non-zero on a permission denied error; mirror install.sh
|
|
79
126
|
// and retry under sudo so a non-nvm user on a system Node doesn't get
|
|
80
127
|
// stuck. The sudo prompt itself surfaces inline in the friend's
|
|
81
128
|
// terminal — we don't try to suppress it.
|
|
82
129
|
say(" npm install failed without sudo — retrying with sudo");
|
|
83
|
-
npmCode = await runner.runNpmInstall(
|
|
130
|
+
npmCode = await runner.runNpmInstall(installSpec, true, installPrefix);
|
|
84
131
|
}
|
|
85
132
|
if (npmCode !== 0) {
|
|
86
133
|
say("");
|
|
87
134
|
say("Update failed at step 1 (npm install).");
|
|
88
135
|
say("Your existing Rift install is unchanged.");
|
|
89
|
-
say(`Try manually: npm install -g ${RIFT_PACKAGE_SPEC}`);
|
|
136
|
+
say(`Try manually: npm install -g --prefer-online ${RIFT_PACKAGE_SPEC}`);
|
|
90
137
|
return { ok: false, step: "npm", transcript };
|
|
91
138
|
}
|
|
92
139
|
say(" npm install completed.");
|
|
93
|
-
// --- Step 2:
|
|
140
|
+
// --- Step 2: verify the active CLI actually upgraded ---
|
|
141
|
+
// An exit-0 npm install is NOT proof. npm can install into a different
|
|
142
|
+
// prefix than the binary on PATH, or (when we fell back to the tag) resolve
|
|
143
|
+
// `@beta` to the version already installed. In both cases the friend's shell
|
|
144
|
+
// still runs the old build. Refuse to claim success until the `rift` on PATH
|
|
145
|
+
// reports the expected version — and if we never resolved the expected
|
|
146
|
+
// version, say so honestly rather than passing on "installed something".
|
|
147
|
+
say("==> Verifying the rift on your PATH is up to date");
|
|
148
|
+
const activeVersion = await runner.getActiveCliVersion();
|
|
149
|
+
const verdict = evaluateUpgrade(expected, activeVersion);
|
|
150
|
+
if (!verdict.ok) {
|
|
151
|
+
const npmPrefix = await runner.getNpmGlobalPrefix();
|
|
152
|
+
appendVerifyDiagnosis(say, {
|
|
153
|
+
expected,
|
|
154
|
+
activeVersion,
|
|
155
|
+
active,
|
|
156
|
+
installPrefix,
|
|
157
|
+
npmPrefix,
|
|
158
|
+
reason: verdict.reason,
|
|
159
|
+
});
|
|
160
|
+
return { ok: false, step: "verify", transcript };
|
|
161
|
+
}
|
|
162
|
+
say(` Active rift is ${activeVersion} (matches the published @beta).`);
|
|
163
|
+
// --- Step 3: kickstart daemon ---
|
|
94
164
|
say("==> Restarting the Rift daemon");
|
|
95
165
|
const kick = await runner.kickstart();
|
|
96
166
|
if (kick.status !== "ok") {
|
|
@@ -102,7 +172,7 @@ export async function runUpdate(runner) {
|
|
|
102
172
|
return { ok: false, step: "kickstart", transcript };
|
|
103
173
|
}
|
|
104
174
|
say(" Daemon kickstarted.");
|
|
105
|
-
// --- Step
|
|
175
|
+
// --- Step 4: wait for /health ---
|
|
106
176
|
say("==> Waiting for the daemon to answer /health");
|
|
107
177
|
const health = await runner.waitForHealth({
|
|
108
178
|
baseUrl: DAEMON_BASE_URL,
|
|
@@ -116,7 +186,7 @@ export async function runUpdate(runner) {
|
|
|
116
186
|
return { ok: false, step: "health", transcript };
|
|
117
187
|
}
|
|
118
188
|
say(` Daemon healthy (uptime ${health.uptimeSeconds}s).`);
|
|
119
|
-
// --- Step
|
|
189
|
+
// --- Step 5: refresh menu bar plugin ---
|
|
120
190
|
say("==> Refreshing the Rift menu bar");
|
|
121
191
|
try {
|
|
122
192
|
const menu = runner.installMenuBar();
|
|
@@ -135,15 +205,174 @@ export async function runUpdate(runner) {
|
|
|
135
205
|
say("Rift updated. Run `rift status` to confirm the new version.");
|
|
136
206
|
return { ok: true, transcript };
|
|
137
207
|
}
|
|
138
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Decide whether the active CLI actually upgraded. The contract is strict and
|
|
210
|
+
* biased toward honesty — "could not confirm" is a FAILURE, never a pass:
|
|
211
|
+
* - no active version at all → the binary is broken (`no_binary`).
|
|
212
|
+
* - no expected version → we couldn't reach the registry to learn the latest
|
|
213
|
+
* beta, so we cannot claim the update landed (`unverified`). This is the
|
|
214
|
+
* deliberate fix for "couldn't verify" silently becoming "updated".
|
|
215
|
+
* - active != expected → still the old (or wrong) build (`mismatch`).
|
|
216
|
+
* Only an active version that equals a freshly-resolved expected version is OK.
|
|
217
|
+
*/
|
|
218
|
+
export function evaluateUpgrade(expected, activeVersion) {
|
|
219
|
+
if (!activeVersion)
|
|
220
|
+
return { ok: false, reason: "no_binary" };
|
|
221
|
+
if (!expected)
|
|
222
|
+
return { ok: false, reason: "unverified" };
|
|
223
|
+
if (activeVersion !== expected)
|
|
224
|
+
return { ok: false, reason: "mismatch" };
|
|
225
|
+
return { ok: true };
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Friend-readable verification failure. Leads with a plain-English headline,
|
|
229
|
+
* then prints versions and paths so the detail is actionable. The branch is
|
|
230
|
+
* chosen from the classified `reason`, and — crucially — only calls it a
|
|
231
|
+
* prefix split when the install was NOT targeted at the active CLI's prefix.
|
|
232
|
+
* Since we install with `--prefix <active.prefix>` whenever we can resolve it,
|
|
233
|
+
* a failure there is a stale-cache / no-op, NOT a split; telling the friend to
|
|
234
|
+
* re-run the same targeted command would be misleading.
|
|
235
|
+
*/
|
|
236
|
+
function appendVerifyDiagnosis(say, ctx) {
|
|
237
|
+
const { expected, activeVersion, active, installPrefix, npmPrefix, reason } = ctx;
|
|
238
|
+
// The prefix npm actually wrote to: the one we targeted, else npm's default.
|
|
239
|
+
const actualInstallPrefix = installPrefix ?? npmPrefix;
|
|
240
|
+
// A genuine split is only possible when we did NOT target the active prefix
|
|
241
|
+
// (installPrefix === null) AND the binary on PATH lives outside where npm
|
|
242
|
+
// installed. When we targeted active.prefix, npm wrote exactly there.
|
|
243
|
+
const prefixSplit = reason === "mismatch" &&
|
|
244
|
+
installPrefix === null &&
|
|
245
|
+
active.binPath !== null &&
|
|
246
|
+
npmPrefix !== null &&
|
|
247
|
+
!binaryLivesUnderPrefix(active.binPath, npmPrefix);
|
|
248
|
+
say("");
|
|
249
|
+
if (reason === "no_binary") {
|
|
250
|
+
say("Rift installed, but `rift --version` would not run afterward.");
|
|
251
|
+
}
|
|
252
|
+
else if (reason === "unverified") {
|
|
253
|
+
say("Rift installed something, but I could not confirm it is the latest.");
|
|
254
|
+
}
|
|
255
|
+
else if (prefixSplit) {
|
|
256
|
+
say("Rift updated one copy, but your terminal still points at another copy.");
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
say("Rift installed, but the rift in your PATH is still the old version.");
|
|
260
|
+
}
|
|
261
|
+
// Detail block — keep the headline understandable, put specifics below it.
|
|
262
|
+
say("");
|
|
263
|
+
if (expected)
|
|
264
|
+
say(` Expected (published @beta): ${expected}`);
|
|
265
|
+
else
|
|
266
|
+
say(" Expected (published @beta): unknown — npm registry probe failed");
|
|
267
|
+
say(` Active (your shell's rift): ${activeVersion ?? "unknown"}`);
|
|
268
|
+
if (active.binPath)
|
|
269
|
+
say(` Active rift path: ${active.binPath}`);
|
|
270
|
+
if (actualInstallPrefix) {
|
|
271
|
+
say(` Installed into prefix: ${actualInstallPrefix}`);
|
|
272
|
+
}
|
|
273
|
+
if (prefixSplit && npmPrefix) {
|
|
274
|
+
say(` npm global prefix: ${npmPrefix}`);
|
|
275
|
+
}
|
|
276
|
+
// Recovery.
|
|
277
|
+
say("");
|
|
278
|
+
if (reason === "unverified") {
|
|
279
|
+
say("This usually means npm couldn't reach the registry. Check your");
|
|
280
|
+
say("connection and re-run `rift update`. To verify by hand:");
|
|
281
|
+
say(` npm view ${RIFT_BETA_TAG} version # the target`);
|
|
282
|
+
say(" rift --version # what your shell runs");
|
|
283
|
+
}
|
|
284
|
+
else if (prefixSplit) {
|
|
285
|
+
const targetPrefix = active.prefix ?? deriveBinPrefix(active.binPath);
|
|
286
|
+
say("Fix: install into the copy your terminal actually runs:");
|
|
287
|
+
if (targetPrefix) {
|
|
288
|
+
say(` npm install -g --prefix ${targetPrefix} --prefer-online ${RIFT_BETA_TAG}`);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
say(` npm install -g --prefer-online ${RIFT_BETA_TAG}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
// no_binary or same-prefix no-op: most often a stale npm metadata cache.
|
|
296
|
+
say("Your npm metadata cache may be stale (the install was a no-op).");
|
|
297
|
+
say(`Fix: npm install -g --prefer-online ${RIFT_BETA_TAG}`);
|
|
298
|
+
say(" (if it repeats: npm cache clean --force, then re-run rift update)");
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/** True when `binPath` sits inside `<prefix>/bin` (i.e. npm's `-g` bin dir). */
|
|
302
|
+
function binaryLivesUnderPrefix(binPath, prefix) {
|
|
303
|
+
const binDir = path.join(prefix, "bin") + path.sep;
|
|
304
|
+
return (binPath + path.sep).startsWith(binDir);
|
|
305
|
+
}
|
|
306
|
+
/** prefix that owns a `<prefix>/bin/rift` binary, or null if not that shape. */
|
|
307
|
+
function deriveBinPrefix(binPath) {
|
|
308
|
+
if (!binPath)
|
|
309
|
+
return null;
|
|
310
|
+
const binDir = path.dirname(binPath);
|
|
311
|
+
return path.basename(binDir) === "bin" ? path.dirname(binDir) : null;
|
|
312
|
+
}
|
|
313
|
+
function defaultNpmInstall(spec, useSudo, prefix) {
|
|
139
314
|
return new Promise((resolve) => {
|
|
315
|
+
const prefixArgs = prefix ? ["--prefix", prefix] : [];
|
|
316
|
+
// `--prefer-online` forces npm to revalidate registry metadata instead of
|
|
317
|
+
// trusting a possibly-stale local cache — defense in depth on top of the
|
|
318
|
+
// pinned exact version, so even the tag-fallback path installs fresh.
|
|
319
|
+
const baseArgs = ["install", "-g", "--prefer-online", ...prefixArgs, spec];
|
|
140
320
|
const cmd = useSudo ? "sudo" : "npm";
|
|
141
|
-
const args = useSudo
|
|
142
|
-
? ["npm", "install", "-g", spec]
|
|
143
|
-
: ["install", "-g", spec];
|
|
321
|
+
const args = useSudo ? ["npm", ...baseArgs] : baseArgs;
|
|
144
322
|
const child = spawn(cmd, args, { stdio: "inherit" });
|
|
145
323
|
child.on("error", () => resolve(1));
|
|
146
324
|
child.on("close", (code) => resolve(code ?? 1));
|
|
147
325
|
});
|
|
148
326
|
}
|
|
327
|
+
/** Run a command, capture trimmed stdout, return null on any failure. */
|
|
328
|
+
function capture(cmd, args) {
|
|
329
|
+
return new Promise((resolve) => {
|
|
330
|
+
execFile(cmd, args, { timeout: 20_000, encoding: "utf8" }, (err, stdout) => {
|
|
331
|
+
if (err) {
|
|
332
|
+
resolve(null);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const out = stdout.trim();
|
|
336
|
+
resolve(out.length > 0 ? out : null);
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Resolve the `rift` the friend's shell runs and the prefix that owns it.
|
|
342
|
+
* Uses `command -v rift` (PATH lookup) rather than this process's own path —
|
|
343
|
+
* the running update is the OLD build, and we want the binary a fresh shell
|
|
344
|
+
* would launch. Prefix is the parent of the binary's `bin/` dir, which is
|
|
345
|
+
* exactly what `npm install -g --prefix` expects.
|
|
346
|
+
*/
|
|
347
|
+
async function defaultResolveActiveCli() {
|
|
348
|
+
const binPath = await capture("/bin/sh", ["-c", "command -v rift"]);
|
|
349
|
+
if (!binPath)
|
|
350
|
+
return { binPath: null, prefix: null };
|
|
351
|
+
// /opt/homebrew/bin/rift → bin dir /opt/homebrew/bin → prefix /opt/homebrew
|
|
352
|
+
const binDir = path.dirname(binPath);
|
|
353
|
+
const prefix = path.basename(binDir) === "bin" ? path.dirname(binDir) : null;
|
|
354
|
+
return { binPath, prefix };
|
|
355
|
+
}
|
|
356
|
+
/** Version reported by the `rift` on PATH (`rift --version`). */
|
|
357
|
+
async function defaultGetActiveCliVersion() {
|
|
358
|
+
const out = await capture("/bin/sh", ["-c", "rift --version"]);
|
|
359
|
+
if (!out)
|
|
360
|
+
return null;
|
|
361
|
+
// commander prints a bare version line; tolerate any extra decoration.
|
|
362
|
+
const match = out.match(/\d+\.\d+\.\d+[^\s]*/);
|
|
363
|
+
return match ? match[0] : out;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Expected version from the published `@beta` dist-tag, with FRESH metadata.
|
|
367
|
+
* `--prefer-online` is load-bearing: without it this probe can read the same
|
|
368
|
+
* stale cache the install did, so a no-op install would "verify" against an
|
|
369
|
+
* equally-stale expected version and the command would lie.
|
|
370
|
+
*/
|
|
371
|
+
function defaultGetExpectedVersion() {
|
|
372
|
+
return capture("npm", ["view", "--prefer-online", RIFT_BETA_TAG, "version"]);
|
|
373
|
+
}
|
|
374
|
+
/** npm's own global prefix (`npm prefix -g`). */
|
|
375
|
+
function defaultGetNpmGlobalPrefix() {
|
|
376
|
+
return capture("npm", ["prefix", "-g"]);
|
|
377
|
+
}
|
|
149
378
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,eAAe,E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_refused" | "unauthorized" | "not_found" | "invalid" | "conflict" | "rate_limited" | "validation" | "server_error" | "unknown";
|
|
2
|
+
export type CliErrorCode = "connection_refused" | "unauthorized" | "not_found" | "invalid" | "config_too_new" | "conflict" | "rate_limited" | "validation" | "server_error" | "unknown";
|
|
3
3
|
export declare class CliError extends Error {
|
|
4
4
|
readonly code: CliErrorCode;
|
|
5
5
|
readonly statusCode?: number | undefined;
|
|
@@ -55,6 +55,30 @@ export declare function resolveConfigPath(globalOpts: {
|
|
|
55
55
|
export declare function requireExistingConfigPath(globalOpts: {
|
|
56
56
|
config?: string;
|
|
57
57
|
}): string;
|
|
58
|
+
/**
|
|
59
|
+
* Status-only lenient base-URL resolver. `rift status` is a diagnostic and
|
|
60
|
+
* must stay useful even when the config carries a top-level key this (older)
|
|
61
|
+
* CLI doesn't recognize yet — e.g. a newer beta wrote `codex_cli` and strict
|
|
62
|
+
* Zod parsing rejects the whole file. It reads ONLY `server.port` leniently
|
|
63
|
+
* so status can still probe the daemon and tell the friend to update.
|
|
64
|
+
*
|
|
65
|
+
* SECURITY: the host is hard-pinned to `127.0.0.1` — never read from the
|
|
66
|
+
* config. `rift status` reads the auth token and sends it to this URL, so if
|
|
67
|
+
* lenient mode honoured an arbitrary `server.host`, a malformed config could
|
|
68
|
+
* redirect Rift's secret token to a non-loopback address. The strict schema
|
|
69
|
+
* already constrains host to the `127.0.0.1` literal, so no valid config ever
|
|
70
|
+
* carries another host — there is nothing legitimate to read, and reading it
|
|
71
|
+
* would only open an exfiltration path. We pin the daemon address and vary
|
|
72
|
+
* only the port (the one field a real config legitimately changes).
|
|
73
|
+
*
|
|
74
|
+
* NEVER use this for daemon startup or any write path — strict validation
|
|
75
|
+
* (`resolveBaseUrl` / `requireExistingConfigPath`) stays the only gate there.
|
|
76
|
+
* This is a read-only, loopback-only diagnostic fallback, nothing more.
|
|
77
|
+
*
|
|
78
|
+
* Returns null when the file is missing/unreadable or not valid JSON — those
|
|
79
|
+
* are real errors the caller should surface, not "the config is just newer".
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveBaseUrlLenient(configPath: string): string | null;
|
|
58
82
|
/**
|
|
59
83
|
* No-auth probe of a daemon's /health endpoint at an explicit base URL.
|
|
60
84
|
* `/health` is unauthenticated by design, so this needs neither a token nor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/cli/http-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/cli/http-client.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,cAAc,GACd,WAAW,GACX,SAAS,GAKT,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,YAAY,GACZ,cAAc,GACd,SAAS,CAAC;AAEd,qBAAa,QAAS,SAAQ,KAAK;aAGf,IAAI,EAAE,YAAY;aAClB,UAAU,CAAC,EAAE,MAAM;aACnB,IAAI,CAAC,EAAE,OAAO;gBAH9B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,YAAY,EAClB,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,IAAI,CAAC,EAAE,OAAO,YAAA;CAKjC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAC7C,OAAO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