probe-research 0.10.0 → 0.10.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.
@@ -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` already on PATH -> exec it (the common re-run case)
14
+ * 1. `probe` on PATH AND new enough -> exec it (the common re-run case)
15
15
  * 2. `uv` -> uvx, no install, no state left behind
16
16
  * 3. `pipx` -> isolated install
17
17
  * 4. bootstrap uv, then uvx -> the from-zero path
@@ -28,6 +28,33 @@ const os = require("node:os");
28
28
  const DIST = "probe-research";
29
29
  const UV_INSTALL = "curl -LsSf https://astral.sh/uv/install.sh | sh";
30
30
 
31
+ /** Compare dotted numeric versions. Returns true when `a` >= `b`. */
32
+ function atLeast(a, b) {
33
+ const pa = String(a).split(".").map((n) => parseInt(n, 10) || 0);
34
+ const pb = String(b).split(".").map((n) => parseInt(n, 10) || 0);
35
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
36
+ const x = pa[i] || 0;
37
+ const y = pb[i] || 0;
38
+ if (x !== y) return x > y;
39
+ }
40
+ return true;
41
+ }
42
+
43
+ /**
44
+ * The version of an existing `probe`, or null if it cannot be determined.
45
+ *
46
+ * Existence is NOT enough. Every current user already has some `probe`, and
47
+ * they are exactly the people most likely to run this command — handing off to
48
+ * whatever ancient build happens to be on PATH gives them a CLI with none of
49
+ * the wizard in it, which is precisely the bug this check exists to stop.
50
+ */
51
+ function installedVersion() {
52
+ const r = spawnSync("probe", ["--version"], { encoding: "utf8", shell: false });
53
+ if (r.status !== 0 || !r.stdout) return null;
54
+ const m = r.stdout.match(/(\d+\.\d+\.\d+(?:\.\d+)?)/);
55
+ return m ? m[1] : null;
56
+ }
57
+
31
58
  function has(cmd) {
32
59
  const probe = process.platform === "win32" ? "where" : "command";
33
60
  const args = process.platform === "win32" ? [cmd] : ["-v", cmd];
@@ -51,10 +78,23 @@ function main() {
51
78
  // `npx probe-research` with no arguments runs the wizard — that is the entire
52
79
  // reason this package exists, so it should not require remembering a verb.
53
80
  const forwarded = args.length ? args : ["wizard"];
81
+ const wanted = require("../package.json").version;
54
82
 
55
- if (has("probe")) return run("probe", forwarded);
56
- if (has("uv")) return run("uv", ["tool", "run", "--from", DIST, "probe", ...forwarded]);
57
- if (has("pipx")) return run("pipx", ["run", "--spec", DIST, "probe", ...forwarded]);
83
+ // Only hand off to an existing install if it is at least as new as this
84
+ // launcher. Otherwise fall through and let uv/pipx fetch a matching CLI.
85
+ if (has("probe")) {
86
+ const found = installedVersion();
87
+ if (found && atLeast(found, wanted)) return run("probe", forwarded);
88
+ console.error(
89
+ `probe-research: installed probe ${found || "(unknown version)"} is older than ` +
90
+ `${wanted}; fetching ${wanted}…`,
91
+ );
92
+ }
93
+ // PIN the version. Unpinned, `uv tool run --from probe-research` happily
94
+ // reuses an already-installed 0.8.2 tool and we are back where we started.
95
+ const spec = `${DIST}==${wanted}`;
96
+ if (has("uv")) return run("uv", ["tool", "run", "--from", spec, "probe", ...forwarded]);
97
+ if (has("pipx")) return run("pipx", ["run", "--spec", spec, "probe", ...forwarded]);
58
98
 
59
99
  if (process.platform === "win32") {
60
100
  console.error(
@@ -75,7 +115,7 @@ function main() {
75
115
  // The installer drops uv in ~/.local/bin, which is not on THIS process's PATH
76
116
  // because it was resolved before the install ran.
77
117
  const uv = `${os.homedir()}/.local/bin/uv`;
78
- return run(uv, ["tool", "run", "--from", DIST, "probe", ...forwarded]);
118
+ return run(uv, ["tool", "run", "--from", `${DIST}==${wanted}`, "probe", ...forwarded]);
79
119
  }
80
120
 
81
121
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "probe-research",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Setup wizard for Probe Research in Claude Code. Runs from zero with npx.",
5
5
  "bin": {
6
6
  "probe-research": "bin/probe-research.js"
@@ -22,5 +22,8 @@
22
22
  "mlops",
23
23
  "experiment-tracking",
24
24
  "probe-research"
25
- ]
25
+ ],
26
+ "scripts": {
27
+ "test": "node --test test/resolve.test.js"
28
+ }
26
29
  }