pi-bridge 0.1.4 → 0.1.5

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/pii.js +23 -20
  2. package/package.json +1 -1
package/bin/pii.js CHANGED
@@ -19,33 +19,36 @@ const os = require('os');
19
19
  const preload = path.join(__dirname, '..', 'src', 'local', 'preload.js');
20
20
 
21
21
  function findPiCli() {
22
- // npm root -g gives the exact global node_modules dir on all platforms.
23
- // Use shell:true so Windows can resolve npm.cmd without ENOENT.
24
- const npmRoot = execFileSync('npm', ['root', '-g'], { encoding: 'utf8', shell: true }).trim();
25
- const cli = path.join(npmRoot, '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
22
+ if (os.platform() === 'win32') {
23
+ // On Windows: resolve from the pi.ps1 wrapper's basedir.
24
+ // npm puts binaries and node_modules in the same directory on Windows.
25
+ const wrapper = execFileSync(
26
+ 'powershell',
27
+ ['-NoProfile', '-Command', '(Get-Command pi -ErrorAction Stop).Source'],
28
+ { encoding: 'utf8' }
29
+ ).trim();
30
+ const basedir = path.dirname(wrapper);
31
+ const cli = path.join(basedir, 'node_modules', '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
32
+ if (!fs.existsSync(cli)) {
33
+ throw new Error(
34
+ 'Could not find pi CLI at ' + cli + '\n' +
35
+ 'Make sure pi is installed: npm install -g @mariozechner/pi-coding-agent'
36
+ );
37
+ }
38
+ // Prefer the Node binary bundled alongside pi if present
39
+ const localNode = path.join(basedir, 'node.exe');
40
+ return { cli, nodeExe: fs.existsSync(localNode) ? localNode : process.execPath };
41
+ }
26
42
 
43
+ // Unix/macOS: npm puts packages in lib/node_modules, use npm root -g
44
+ const npmRoot = execFileSync('npm', ['root', '-g'], { encoding: 'utf8' }).trim();
45
+ const cli = path.join(npmRoot, '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
27
46
  if (!fs.existsSync(cli)) {
28
47
  throw new Error(
29
48
  'Could not find pi CLI at ' + cli + '\n' +
30
49
  'Make sure pi is installed: npm install -g @mariozechner/pi-coding-agent'
31
50
  );
32
51
  }
33
-
34
- // On Windows, prefer the node.exe bundled alongside the pi wrapper if present
35
- if (os.platform() === 'win32') {
36
- try {
37
- const wrapper = execFileSync(
38
- 'powershell',
39
- ['-NoProfile', '-Command', '(Get-Command pi -ErrorAction Stop).Source'],
40
- { encoding: 'utf8' }
41
- ).trim();
42
- const localNode = path.join(path.dirname(wrapper), 'node.exe');
43
- if (fs.existsSync(localNode)) {
44
- return { cli, nodeExe: localNode };
45
- }
46
- } catch (_) {}
47
- }
48
-
49
52
  return { cli, nodeExe: process.execPath };
50
53
  }
51
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-bridge",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Transparent filesystem bridge that makes pi run natively on a remote machine over SSH",
5
5
  "type": "commonjs",
6
6
  "bin": {