Something went wrong. Try again.
Pi extension for async subagent delegation with truncation, artifacts, and session sharing
Something went wrong. Try again.
666 B · 15 lines
TypeScript
12345678910111213141516import * as fs from "node:fs";import * as path from "node:path";
export function writeNodeCommand(directory: string, name: string, source: string): string { if (process.platform === "win32") { const scriptPath = path.join(directory, `${name}.cjs`); const commandPath = path.join(directory, `${name}.cmd`); fs.writeFileSync(scriptPath, source, "utf-8"); fs.writeFileSync(commandPath, `@echo off\r\n"${process.execPath}" "${scriptPath}" %*\r\n`, "utf-8"); return commandPath; } const commandPath = path.join(directory, name); fs.writeFileSync(commandPath, `#!/usr/bin/env node\n${source}\n`, { encoding: "utf-8", mode: 0o755 }); return commandPath;}