pi-bridge 0.1.3 → 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.
- package/bin/pii.js +23 -21
- package/package.json +1 -1
package/bin/pii.js
CHANGED
|
@@ -19,34 +19,36 @@ const os = require('os');
|
|
|
19
19
|
const preload = path.join(__dirname, '..', 'src', 'local', 'preload.js');
|
|
20
20
|
|
|
21
21
|
function findPiCli() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
}
|
|
27
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');
|
|
28
46
|
if (!fs.existsSync(cli)) {
|
|
29
47
|
throw new Error(
|
|
30
48
|
'Could not find pi CLI at ' + cli + '\n' +
|
|
31
49
|
'Make sure pi is installed: npm install -g @mariozechner/pi-coding-agent'
|
|
32
50
|
);
|
|
33
51
|
}
|
|
34
|
-
|
|
35
|
-
// On Windows, prefer the node.exe bundled alongside the pi wrapper if present
|
|
36
|
-
if (os.platform() === 'win32') {
|
|
37
|
-
try {
|
|
38
|
-
const wrapper = execFileSync(
|
|
39
|
-
'powershell',
|
|
40
|
-
['-NoProfile', '-Command', '(Get-Command pi -ErrorAction Stop).Source'],
|
|
41
|
-
{ encoding: 'utf8' }
|
|
42
|
-
).trim();
|
|
43
|
-
const localNode = path.join(path.dirname(wrapper), 'node.exe');
|
|
44
|
-
if (fs.existsSync(localNode)) {
|
|
45
|
-
return { cli, nodeExe: localNode };
|
|
46
|
-
}
|
|
47
|
-
} catch (_) {}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
52
|
return { cli, nodeExe: process.execPath };
|
|
51
53
|
}
|
|
52
54
|
|