@juicesharp/rpiv-pi 0.4.0 → 0.4.1
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.
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
takeGitContextIfChanged,
|
|
26
26
|
} from "./git-context.js";
|
|
27
27
|
import { syncBundledAgents } from "./agents.js";
|
|
28
|
+
import { spawnPiInstall } from "./pi-installer.js";
|
|
28
29
|
import {
|
|
29
30
|
hasPiSubagentsInstalled,
|
|
30
31
|
hasRpivAskUserQuestionInstalled,
|
|
@@ -238,7 +239,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
238
239
|
for (const { pkg } of missing) {
|
|
239
240
|
ctx.ui.notify(`Installing ${pkg}…`, "info");
|
|
240
241
|
try {
|
|
241
|
-
const result = await
|
|
242
|
+
const result = await spawnPiInstall(pkg, 120_000);
|
|
242
243
|
if (result.code === 0) {
|
|
243
244
|
succeeded.push(pkg);
|
|
244
245
|
} else {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows-safe wrapper around `pi install <pkg>`.
|
|
3
|
+
*
|
|
4
|
+
* Pi's own `pi.exec` calls `child_process.spawn(cmd, args, { shell: false })`,
|
|
5
|
+
* which cannot launch `.cmd`/`.bat` shims on Windows — npm installs `pi` as
|
|
6
|
+
* `pi.cmd`, so on Windows the spawn ENOENTs silently and the caller sees only
|
|
7
|
+
* `exit 1`. We side-step it here by invoking via `cmd.exe /c` on Windows.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
|
|
12
|
+
export interface PiInstallResult {
|
|
13
|
+
code: number;
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function spawnPiInstall(pkg: string, timeoutMs: number): Promise<PiInstallResult> {
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const isWindows = process.platform === "win32";
|
|
21
|
+
const [cmd, args, spawnOpts] = isWindows
|
|
22
|
+
? (["cmd.exe", ["/c", "pi", "install", pkg], { windowsHide: true }] as const)
|
|
23
|
+
: (["pi", ["install", pkg], {}] as const);
|
|
24
|
+
|
|
25
|
+
let settled = false;
|
|
26
|
+
let stdout = "";
|
|
27
|
+
let stderr = "";
|
|
28
|
+
|
|
29
|
+
const proc = spawn(cmd, args, { ...spawnOpts, stdio: ["ignore", "pipe", "pipe"] });
|
|
30
|
+
proc.stdout?.on("data", (d) => (stdout += d.toString()));
|
|
31
|
+
proc.stderr?.on("data", (d) => (stderr += d.toString()));
|
|
32
|
+
|
|
33
|
+
const settle = (result: PiInstallResult) => {
|
|
34
|
+
if (settled) return;
|
|
35
|
+
settled = true;
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
resolve(result);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const timer = setTimeout(() => {
|
|
41
|
+
proc.kill("SIGTERM");
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
if (!proc.killed) proc.kill("SIGKILL");
|
|
44
|
+
}, 5000);
|
|
45
|
+
settle({ code: 124, stdout, stderr: stderr + `\n[timed out after ${timeoutMs}ms]` });
|
|
46
|
+
}, timeoutMs);
|
|
47
|
+
|
|
48
|
+
proc.on("error", (err) => {
|
|
49
|
+
settle({ code: 1, stdout, stderr: stderr + (stderr ? "\n" : "") + err.message });
|
|
50
|
+
});
|
|
51
|
+
proc.on("close", (code) => {
|
|
52
|
+
settle({ code: code ?? 1, stdout, stderr });
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-pi",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Skill-based development workflow for Pi — research, design, plan, implement, review",
|
|
5
5
|
"keywords": ["pi-package", "pi-extension", "rpiv", "skills", "workflow"],
|
|
6
6
|
"license": "MIT",
|