pi-crew 0.3.3 → 0.3.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/package.json
CHANGED
|
@@ -222,9 +222,16 @@ export async function runIterationHook(
|
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
// Write payload to stdin and close it
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
// Write payload to stdin and close it.
|
|
226
|
+
// Handle EPIPE errors gracefully (occurs if the hook script exits before
|
|
227
|
+
// reading all of stdin, which is normal for some hook scripts on certain OS).
|
|
228
|
+
child.stdin.on("error", () => { /* ignore EPIPE — hook exited early */ });
|
|
229
|
+
try {
|
|
230
|
+
child.stdin.write(stdinJson, "utf-8");
|
|
231
|
+
child.stdin.end();
|
|
232
|
+
} catch {
|
|
233
|
+
// ignore
|
|
234
|
+
}
|
|
228
235
|
});
|
|
229
236
|
}
|
|
230
237
|
|
package/src/ui/mascot.ts
CHANGED
|
@@ -122,6 +122,7 @@ export class AnimatedMascot {
|
|
|
122
122
|
private gridVersion = 0;
|
|
123
123
|
private cachedWidth = 0;
|
|
124
124
|
private cachedVersion = -1;
|
|
125
|
+
private cachedFrame = -1;
|
|
125
126
|
private cachedLines: string[] = [];
|
|
126
127
|
|
|
127
128
|
constructor(themeLike: unknown, onDone: () => void, options: AnimatedMascotOptions = {}) {
|
|
@@ -398,7 +399,7 @@ export class AnimatedMascot {
|
|
|
398
399
|
}
|
|
399
400
|
|
|
400
401
|
render(width: number): string[] {
|
|
401
|
-
if (width === this.cachedWidth && this.cachedVersion === this.gridVersion && this.cachedLines.length) {
|
|
402
|
+
if (width === this.cachedWidth && this.cachedVersion === this.gridVersion && this.cachedFrame === this.frame && this.cachedLines.length) {
|
|
402
403
|
return this.cachedLines;
|
|
403
404
|
}
|
|
404
405
|
const safeWidth = Math.max(20, width);
|
|
@@ -424,6 +425,7 @@ export class AnimatedMascot {
|
|
|
424
425
|
result.push(`${this.theme.fg("border", "╰")}${horizontal}${this.theme.fg("border", "╯")}`);
|
|
425
426
|
this.cachedWidth = safeWidth;
|
|
426
427
|
this.cachedVersion = this.gridVersion;
|
|
428
|
+
this.cachedFrame = this.frame;
|
|
427
429
|
this.cachedLines = result;
|
|
428
430
|
return result;
|
|
429
431
|
}
|
|
@@ -77,15 +77,18 @@ function normalizeSyntheticPath(worktreePath: string, rawPath: string): string {
|
|
|
77
77
|
* @param hookPath - The hook script path to validate
|
|
78
78
|
* @returns true if the path is allowed, false otherwise
|
|
79
79
|
*/
|
|
80
|
-
function isAllowedSetupHook(hookPath: string): boolean {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
function isAllowedSetupHook(hookPath: string): boolean {
|
|
81
|
+
if (!hookPath || hookPath.trim().length === 0) return false;
|
|
82
|
+
if (!path.isAbsolute(hookPath)) {
|
|
83
|
+
// Use path.posix.normalize for consistent forward-slash handling on all platforms.
|
|
84
|
+
const normalized = path.posix.normalize(hookPath);
|
|
85
|
+
return normalized === ".hooks" || normalized.startsWith(".hooks/");
|
|
86
|
+
}
|
|
87
|
+
// Normalize to forward slashes for consistent cross-platform comparison.
|
|
88
|
+
const normalizedHookPath = hookPath.replace(/\\/g, "/");
|
|
89
|
+
const homeHooksNormalized = (process.env.HOME ?? "").replace(/\\/g, "/") + "/.pi/hooks";
|
|
90
|
+
return normalizedHookPath === homeHooksNormalized || normalizedHookPath.startsWith(homeHooksNormalized + "/");
|
|
85
91
|
}
|
|
86
|
-
const homeHooks = path.join(process.env.HOME ?? "", "", ".pi", "hooks");
|
|
87
|
-
return hookPath === homeHooks || hookPath.startsWith(homeHooks + path.sep);
|
|
88
|
-
}
|
|
89
92
|
|
|
90
93
|
function runSetupHook(manifest: TeamRunManifest, task: TeamTaskState, repoRoot: string, worktreePath: string, branch: string): string[] {
|
|
91
94
|
const cfg = loadConfig(manifest.cwd).config.worktree;
|
|
@@ -101,15 +104,18 @@ function runSetupHook(manifest: TeamRunManifest, task: TeamTaskState, repoRoot:
|
|
|
101
104
|
return [];
|
|
102
105
|
}
|
|
103
106
|
const nodeHook = hookPath.endsWith(".js") || hookPath.endsWith(".cjs") || hookPath.endsWith(".mjs");
|
|
107
|
+
// On Windows, set shell:true to ensure PATH resolution and .cjs/.bat file associations work.
|
|
108
|
+
const useShell = process.platform === "win32";
|
|
104
109
|
const result = spawnSync(nodeHook ? process.execPath : hookPath, nodeHook ? [hookPath] : [], {
|
|
105
110
|
cwd: worktreePath,
|
|
106
111
|
encoding: "utf-8",
|
|
107
112
|
input: JSON.stringify({ version: 1, repoRoot, worktreePath, agentCwd: worktreePath, branch, runId: manifest.runId, taskId: task.id, agent: task.agent }),
|
|
108
113
|
timeout: cfg.setupHookTimeoutMs ?? 30_000,
|
|
109
|
-
shell:
|
|
114
|
+
shell: useShell,
|
|
110
115
|
env: sanitizeEnvSecrets(process.env, {
|
|
111
116
|
allowList: ["PATH", "HOME", "USERPROFILE", "TEMP", "TMP", "TMPDIR", "LANG", "LC_ALL", "PI_*"],
|
|
112
117
|
}),
|
|
118
|
+
windowsHide: true,
|
|
113
119
|
});
|
|
114
120
|
if (result.error) throw new Error(`worktree setup hook failed: ${result.error.message}`);
|
|
115
121
|
if (result.status !== 0) throw new Error(`worktree setup hook failed with exit code ${result.status}: ${result.stderr || result.stdout || "no output"}`);
|