pi-bridge 0.1.8 → 0.2.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.
Files changed (2) hide show
  1. package/bin/pii.js +30 -6
  2. package/package.json +1 -1
package/bin/pii.js CHANGED
@@ -1,17 +1,41 @@
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
 
9
+ const pkg = require('../package.json');
7
10
  const preload = path.join(__dirname, '..', 'src', 'local', 'preload.js');
8
11
 
9
- let cli;
10
- try {
11
- cli = require.resolve('@mariozechner/pi-coding-agent');
12
- } catch (_) {
12
+ if (process.argv.includes('--version') || process.argv.includes('-v') || process.argv.includes('--v')) {
13
+ process.stdout.write('pi-bridge/' + pkg.version + '\n');
14
+ process.exit(0);
15
+ }
16
+
17
+ function findCli() {
18
+ // 1. Standard npm global: pi-bridge and pi share the same node_modules prefix
19
+ const shared = path.resolve(__dirname, '..', '..', '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
20
+ if (fs.existsSync(shared)) return shared;
21
+
22
+ // 2. GitHub clone / bundled install: pi.js sits next to the pi wrapper in PATH
23
+ // Use `where` (Windows built-in) — more reliable than spawning PowerShell
24
+ const whereCmd = os.platform() === 'win32' ? 'where' : 'which';
25
+ try {
26
+ const wrapper = execFileSync(whereCmd, ['pi'], { encoding: 'utf8' })
27
+ .trim().split('\n')[0].trim();
28
+ const sibling = wrapper.replace(/\.(ps1|cmd)$/i, '.js');
29
+ if (fs.existsSync(sibling)) return sibling;
30
+ } catch (_) {}
31
+
32
+ return null;
33
+ }
34
+
35
+ const cli = findCli();
36
+ if (!cli) {
13
37
  process.stderr.write(
14
- 'pii: pi not found.\n' +
38
+ 'pii: Could not find pi.\n' +
15
39
  'Install it with: npm install -g @mariozechner/pi-coding-agent\n'
16
40
  );
17
41
  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.2.0",
4
4
  "description": "Transparent filesystem bridge that makes pi run natively on a remote machine over SSH",
5
5
  "type": "commonjs",
6
6
  "bin": {