pi-bridge 0.1.8 → 0.1.9

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 +27 -6
  2. package/package.json +1 -1
package/bin/pii.js CHANGED
@@ -1,17 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- const { spawnSync } = require('child_process');
4
+ const { spawnSync, execFileSync } = require('child_process');
5
5
  const path = require('path');
6
+ const fs = require('fs');
7
+ const os = require('os');
6
8
 
7
9
  const preload = path.join(__dirname, '..', 'src', 'local', 'preload.js');
8
10
 
9
- let cli;
10
- try {
11
- cli = require.resolve('@mariozechner/pi-coding-agent');
12
- } catch (_) {
11
+ function findCli() {
12
+ // 1. Standard npm global: pi-bridge and pi share the same node_modules prefix
13
+ const shared = path.resolve(__dirname, '..', '..', '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
14
+ if (fs.existsSync(shared)) return shared;
15
+
16
+ // 2. Windows bundled/custom install: pi.js sits next to pi.ps1 (no node_modules structure)
17
+ if (os.platform() === 'win32') {
18
+ try {
19
+ const wrapper = execFileSync(
20
+ 'powershell',
21
+ ['-NoProfile', '-Command', '(Get-Command pi -ErrorAction Stop).Source'],
22
+ { encoding: 'utf8' }
23
+ ).trim();
24
+ const sibling = wrapper.replace(/\.(ps1|cmd)$/i, '.js');
25
+ if (fs.existsSync(sibling)) return sibling;
26
+ } catch (_) {}
27
+ }
28
+
29
+ return null;
30
+ }
31
+
32
+ const cli = findCli();
33
+ if (!cli) {
13
34
  process.stderr.write(
14
- 'pii: pi not found.\n' +
35
+ 'pii: Could not find pi.\n' +
15
36
  'Install it with: npm install -g @mariozechner/pi-coding-agent\n'
16
37
  );
17
38
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-bridge",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Transparent filesystem bridge that makes pi run natively on a remote machine over SSH",
5
5
  "type": "commonjs",
6
6
  "bin": {