probe-research 0.15.0 → 0.16.0
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/bin/probe-research.js +51 -46
- package/package.json +1 -1
package/bin/probe-research.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* there is nothing here that can drift from the CLI's behaviour.
|
|
12
12
|
*
|
|
13
13
|
* Resolution order, best first:
|
|
14
|
-
* 1. `probe` on PATH
|
|
14
|
+
* 1. `probe` on PATH at or above FIX_MIN -> exec it at once (the common re-run case)
|
|
15
15
|
* 2. `uv` -> uvx, no install, no state left behind
|
|
16
16
|
* 3. bootstrap uv, then uvx -> the from-zero path: uv at the Mac app's pin,
|
|
17
17
|
* its installer checked by sha256 before it runs
|
|
@@ -32,6 +32,8 @@ const os = require("node:os");
|
|
|
32
32
|
const path = require("node:path");
|
|
33
33
|
|
|
34
34
|
const DIST = "probe-research";
|
|
35
|
+
/** The compiled CLI `probe-research[all]` pins to its own version since the split (the CLI's `_entry.CLI_DIST`). */
|
|
36
|
+
const CLI_DIST = "probe-research-cli";
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* Where the published-version manifest lives. The SessionStart hook already
|
|
@@ -103,6 +105,14 @@ const MANIFEST_TIMEOUT_MS = 1500;
|
|
|
103
105
|
* entry point, so the floor only ever names a release already on PyPI.
|
|
104
106
|
*/
|
|
105
107
|
const MIN_CLI = "0.374.0";
|
|
108
|
+
/**
|
|
109
|
+
* The first CLI whose wizard opens the browser at once (instant sign-in, plan S8): its sign-in asks for
|
|
110
|
+
* the code before sending queued writes, and its setup runs behind the screens. An installed `probe` at
|
|
111
|
+
* or above it runs at once, with no manifest read: its own updater moves it forward. Below it (0.374.0
|
|
112
|
+
* to the release before this one still carry the slow wizard), the launcher runs that release's newest
|
|
113
|
+
* instead, downloaded once. Same rule as MIN_CLI: only ever a release already on PyPI.
|
|
114
|
+
*/
|
|
115
|
+
const FIX_MIN = "0.385.0";
|
|
106
116
|
/**
|
|
107
117
|
* The floor where Probe's compiled CLI has no build (`getMissingBuild`): no release past
|
|
108
118
|
* the split installs there, so the newest that does is run as it is (plan R15, T22).
|
|
@@ -451,15 +461,10 @@ async function main() {
|
|
|
451
461
|
}
|
|
452
462
|
if (signInCodeAt(args) >= 0) console.error(SIGN_IN_CODE_NOTE);
|
|
453
463
|
|
|
454
|
-
// Hand off to an
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
// another update.
|
|
459
|
-
//
|
|
460
|
-
// That is the same failure the `--refresh` flag below exists to fix -- uv
|
|
461
|
-
// serving whatever it resolved on day one -- in the other branch. It was
|
|
462
|
-
// fixed there and left standing here.
|
|
464
|
+
// Hand off to an installed CLI at or above FIX_MIN at once, with no manifest
|
|
465
|
+
// read before the wizard: such a CLI keeps itself current (its updater), so a
|
|
466
|
+
// floor no longer freezes anyone on an old release the way it did before the
|
|
467
|
+
// CLI updated itself. Below FIX_MIN, the published latest is fetched instead.
|
|
463
468
|
// No compiled CLI build for this computer: no release after the split installs here, so an
|
|
464
469
|
// installed probe is never "behind" one; run it as long as it is above the floor.
|
|
465
470
|
const missingBuild = getMissingBuild(process.platform, process.arch,
|
|
@@ -480,29 +485,23 @@ async function main() {
|
|
|
480
485
|
}
|
|
481
486
|
} else if (has("probe")) {
|
|
482
487
|
const found = installedVersion();
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
);
|
|
495
|
-
}
|
|
488
|
+
// A fixed CLI runs at once (plan S8): no manifest read on the way to the browser.
|
|
489
|
+
if (found && atLeast(found, FIX_MIN)) return run("probe", forwarded);
|
|
490
|
+
latest = await latestVersion();
|
|
491
|
+
// Unknown latest (offline, no route) means run what we have: see latestVersion's contract.
|
|
492
|
+
if (!latest && found && atLeast(found, wanted)) return run("probe", forwarded);
|
|
493
|
+
console.error(
|
|
494
|
+
`probe-research: installed probe ${found || "(unknown version)"} is older than ` +
|
|
495
|
+
`${FIX_MIN}; fetching ${latest || "the latest"}…`,
|
|
496
|
+
);
|
|
497
|
+
} else {
|
|
498
|
+
latest = await latestVersion();
|
|
496
499
|
}
|
|
497
|
-
//
|
|
498
|
-
// reuses
|
|
499
|
-
//
|
|
500
|
-
//
|
|
501
|
-
|
|
502
|
-
// stale 0.46.0 satisfies `>=0.36.0` and uv hands back the very version we
|
|
503
|
-
// just decided was out of date -- the currency check above would print
|
|
504
|
-
// "fetching the latest" and then change nothing. Measured exactly that before
|
|
505
|
-
// this line existed.
|
|
500
|
+
// The published latest, pinned exactly (plan S8): the manifest names it only once it is on PyPI, and
|
|
501
|
+
// uv reuses the env it built for that version, so it is downloaded once, ever. A range let uv hand back
|
|
502
|
+
// the stale tool it already had (a 0.46.0 satisfied `>=0.36.0`: measured). Unknown latest (offline, no
|
|
503
|
+
// route): any fixed CLI uv already has, `>=FIX_MIN`. A repair still asks for the newest, `>=`.
|
|
504
|
+
const pinned = !missingBuild && latest && atLeast(latest, FIX_MIN) ? latest : null;
|
|
506
505
|
const target = latest && atLeast(latest, wanted) ? latest : wanted;
|
|
507
506
|
// `[all]`: the CLI's dependencies are an extra from the release after
|
|
508
507
|
// 0.188 (plan 2.11); asking for it is harmless while core still has them.
|
|
@@ -514,24 +513,17 @@ async function main() {
|
|
|
514
513
|
"(the probe-research package without [all]) installs at every version.",
|
|
515
514
|
);
|
|
516
515
|
}
|
|
517
|
-
const spec = missingBuild ? `${DIST}[all]`
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
// user frozen on the version they happened to run on day one, with the
|
|
521
|
-
// launcher silently never delivering another update.
|
|
522
|
-
//
|
|
523
|
-
// It has to be the full `--refresh`: `--refresh-package` only refreshes
|
|
524
|
-
// package METADATA and still reuses the built environment (measured — it
|
|
525
|
-
// kept returning 0.10.0 after 0.10.1 was published). The full refresh costs
|
|
526
|
-
// ~100ms, which is nothing for a command that only runs when there is no
|
|
527
|
-
// usable local install.
|
|
516
|
+
const spec = missingBuild ? `${DIST}[all]`
|
|
517
|
+
: !mayUseInstalled(forwarded) ? `${DIST}[all]>=${target}`
|
|
518
|
+
: pinned ? `${DIST}[all]==${pinned}` : `${DIST}[all]>=${FIX_MIN}`;
|
|
528
519
|
// No pipx: the CLI installs itself for good with uv only, so a pipx run ended
|
|
529
|
-
// in that refusal anyway (install redesign R11).
|
|
520
|
+
// in that refusal anyway (install redesign R11). Cache flags: getRefreshFlags.
|
|
530
521
|
const isolated = uvRunFlags(forwarded);
|
|
522
|
+
const refresh = getRefreshFlags({ repair: !mayUseInstalled(forwarded), missingBuild, pinned });
|
|
531
523
|
const uvOnPath = has("uv");
|
|
532
524
|
const uvVersion = uvOnPath ? getUvVersion() : null;
|
|
533
525
|
if (uvVersion && atLeast(uvVersion, UV_MIN)) {
|
|
534
|
-
return run("uv", ["tool", "run", ...isolated, "--python", PYTHON_REQUEST,
|
|
526
|
+
return run("uv", ["tool", "run", ...isolated, "--python", PYTHON_REQUEST, ...refresh, "--from", spec, "probe",
|
|
535
527
|
...forwarded]);
|
|
536
528
|
}
|
|
537
529
|
|
|
@@ -548,10 +540,23 @@ async function main() {
|
|
|
548
540
|
}
|
|
549
541
|
const uv = installUv(process.env, forwarded);
|
|
550
542
|
return run(uv, [
|
|
551
|
-
"tool", "run", ...isolated, "--python", PYTHON_REQUEST,
|
|
543
|
+
"tool", "run", ...isolated, "--python", PYTHON_REQUEST, ...refresh, "--from", spec, "probe", ...forwarded,
|
|
552
544
|
]);
|
|
553
545
|
}
|
|
554
546
|
|
|
547
|
+
/**
|
|
548
|
+
* uv's cache flags for a throwaway run. A pinned release builds once and is reused from uv's cache:
|
|
549
|
+
* `--refresh-package` reads only probe-research's index again (and the compiled CLI's, which `[all]` pins
|
|
550
|
+
* to the same version), so a release newer than uv's 10-minute copy still resolves, and no cached wheel
|
|
551
|
+
* or env is fetched again. A range (a repair's newest,
|
|
552
|
+
* a computer with no compiled build) needs the full `--refresh`: uv reuses the env it built for a range,
|
|
553
|
+
* so `--refresh-package` alone kept serving 0.10.0 after 0.10.1 shipped (measured).
|
|
554
|
+
*/
|
|
555
|
+
function getRefreshFlags({ repair, missingBuild, pinned }) {
|
|
556
|
+
if (repair || missingBuild) return ["--refresh"];
|
|
557
|
+
return pinned ? ["--refresh-package", DIST, "--refresh-package", CLI_DIST] : [];
|
|
558
|
+
}
|
|
559
|
+
|
|
555
560
|
/** The hex sha256 of a file's bytes. */
|
|
556
561
|
function hashFile(file) {
|
|
557
562
|
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|