pi-bridge 0.1.9 → 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.
- package/bin/pii.js +15 -12
- package/package.json +1 -1
package/bin/pii.js
CHANGED
|
@@ -6,25 +6,28 @@ const path = require('path');
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
|
|
9
|
+
const pkg = require('../package.json');
|
|
9
10
|
const preload = path.join(__dirname, '..', 'src', 'local', 'preload.js');
|
|
10
11
|
|
|
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
|
+
|
|
11
17
|
function findCli() {
|
|
12
18
|
// 1. Standard npm global: pi-bridge and pi share the same node_modules prefix
|
|
13
19
|
const shared = path.resolve(__dirname, '..', '..', '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
|
|
14
20
|
if (fs.existsSync(shared)) return shared;
|
|
15
21
|
|
|
16
|
-
// 2.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (fs.existsSync(sibling)) return sibling;
|
|
26
|
-
} catch (_) {}
|
|
27
|
-
}
|
|
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 (_) {}
|
|
28
31
|
|
|
29
32
|
return null;
|
|
30
33
|
}
|