pi-bridge 0.2.0 → 0.2.2
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 +20 -9
- package/package.json +1 -1
package/bin/pii.js
CHANGED
|
@@ -19,15 +19,26 @@ function findCli() {
|
|
|
19
19
|
const shared = path.resolve(__dirname, '..', '..', '@mariozechner', 'pi-coding-agent', 'dist', 'cli.js');
|
|
20
20
|
if (fs.existsSync(shared)) return shared;
|
|
21
21
|
|
|
22
|
-
// 2. GitHub clone
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
// 2. Unix GitHub clone: which pi returns the JS file directly
|
|
23
|
+
if (os.platform() !== 'win32') {
|
|
24
|
+
try {
|
|
25
|
+
const wrapper = execFileSync('which', ['pi'], { encoding: 'utf8' }).trim();
|
|
26
|
+
if (fs.existsSync(wrapper)) return wrapper;
|
|
27
|
+
} catch (_) {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 3. Windows fallback: PowerShell Get-Command finds pi even in custom/non-PATH locations
|
|
31
|
+
if (os.platform() === 'win32') {
|
|
32
|
+
try {
|
|
33
|
+
const wrapper = execFileSync(
|
|
34
|
+
'powershell',
|
|
35
|
+
['-NoProfile', '-Command', '(Get-Command pi -ErrorAction Stop).Source'],
|
|
36
|
+
{ encoding: 'utf8' }
|
|
37
|
+
).trim();
|
|
38
|
+
const sibling = wrapper.replace(/\.(ps1|cmd)$/i, '.js');
|
|
39
|
+
if (fs.existsSync(sibling)) return sibling;
|
|
40
|
+
} catch (_) {}
|
|
41
|
+
}
|
|
31
42
|
|
|
32
43
|
return null;
|
|
33
44
|
}
|