drift-ml 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/bin/drift.js +50 -8
  2. package/package.json +1 -1
package/bin/drift.js CHANGED
@@ -1,17 +1,59 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { spawnSync } = require("child_process");
4
+ const path = require("path");
5
+ const fs = require("fs");
4
6
 
5
- function which(cmd) {
6
- const isWindows = process.platform === "win32";
7
- const whichCmd = isWindows ? "where" : "which";
8
- const { status, stdout } = spawnSync(whichCmd, [cmd], { encoding: "utf8" });
9
- return status === 0 ? (stdout || "").trim().split("\n")[0] : null;
7
+ // Known pipx install locations
8
+ function getPipxBinPaths() {
9
+ const home = process.env.HOME || process.env.USERPROFILE || "";
10
+ return [
11
+ path.join(home, ".local", "bin", "drift"),
12
+ "/usr/local/bin/drift",
13
+ ];
14
+ }
15
+
16
+ // Find Python-based drift (not this Node script)
17
+ function findPythonDrift() {
18
+ // First check pipx standard locations
19
+ for (const p of getPipxBinPaths()) {
20
+ if (fs.existsSync(p)) {
21
+ // Verify it's not a Node script (i.e., not us)
22
+ try {
23
+ const content = fs.readFileSync(p, "utf8").slice(0, 100);
24
+ if (!content.includes("#!/usr/bin/env node")) {
25
+ return p;
26
+ }
27
+ } catch (_) {}
28
+ }
29
+ }
30
+
31
+ // Fallback: search PATH but skip Node scripts
32
+ const pathEnv = process.env.PATH || "";
33
+ const dirs = pathEnv.split(path.delimiter);
34
+
35
+ for (const dir of dirs) {
36
+ const candidate = path.join(dir, "drift");
37
+ if (fs.existsSync(candidate)) {
38
+ try {
39
+ const content = fs.readFileSync(candidate, "utf8").slice(0, 100);
40
+ // Skip if it's a Node script (that's us or another Node launcher)
41
+ if (content.includes("#!/usr/bin/env node")) {
42
+ continue;
43
+ }
44
+ return candidate;
45
+ } catch (_) {
46
+ // Binary file or unreadable - might be the real one
47
+ return candidate;
48
+ }
49
+ }
50
+ }
51
+
52
+ return null;
10
53
  }
11
54
 
12
55
  function main() {
13
- // Check if drift binary exists on PATH
14
- const driftPath = which("drift");
56
+ const driftPath = findPythonDrift();
15
57
 
16
58
  if (!driftPath) {
17
59
  console.error(`
@@ -28,7 +70,7 @@ Then run:
28
70
  process.exit(1);
29
71
  }
30
72
 
31
- // Run drift and forward stdin/stdout
73
+ // Run the Python drift and forward stdin/stdout
32
74
  const result = spawnSync(driftPath, process.argv.slice(2), {
33
75
  stdio: "inherit",
34
76
  env: process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drift-ml",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Drift — terminal-first, chat-based AutoML. Same engine as the web app. On first run: downloads and starts the engine locally (never exposes engine source).",
5
5
  "bin": {
6
6
  "drift": "./bin/drift.js"