diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index b33d5cf0b..645a941b0 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -38,6 +38,7 @@ ### Changed +- Enabled Node's persistent compile cache before loading the bundled CLI runtime, reducing repeat launch time. - Made `--resume` session results appear progressively, using file modification times to prioritize all-folder loading and cancelling outstanding transcript reads after selection. - Reduced `--continue` startup time by checking candidate session headers in modification-time order and stopping after the newest matching session. - Replaced the external native clipboard dependency with bundled asynchronous macOS, Windows, and X11 helpers while preserving platform command and OSC 52 fallbacks ([#9163](https://github.com/earendil-works/pi/pull/9163)). diff --git a/scripts/build-coding-agent-bundle.mjs b/scripts/build-coding-agent-bundle.mjs index aac3dd6e5..028b0b6a6 100644 --- a/scripts/build-coding-agent-bundle.mjs +++ b/scripts/build-coding-agent-bundle.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { chmodSync, existsSync, mkdirSync, rmSync } from "node:fs"; +import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; import { isBuiltin } from "node:module"; import { dirname, join, relative, resolve } from "node:path"; import { fileURLToPath } from "node:url"; @@ -162,7 +162,7 @@ const mainResult = await build({ ...commonBuildOptions(), entryNames: "[name]", entryPoints: { - cli: join(codingAgentDistDir, "cli.js"), + "cli-runtime": join(codingAgentDistDir, "cli.js"), index: join(codingAgentDistDir, "index.js"), "rpc-entry": join(codingAgentDistDir, "rpc-entry.js"), }, @@ -206,9 +206,17 @@ if (dirname(imageResizeOutput) !== dirname(imageResizeWorkerOutput)) { } validateExternalImports([mainResult.metafile, lazyResult.metafile]); +const cliLauncher = `#!/usr/bin/env node +import { createRequire, enableCompileCache } from "node:module"; + +enableCompileCache(); +createRequire(import.meta.url)("./cli-runtime.js"); +`; +writeFileSync(join(bundleDir, "cli.js"), cliLauncher); chmodSync(join(bundleDir, "cli.js"), 0o755); chmodSync(join(bundleDir, "rpc-entry.js"), 0o755); -const files = new Set([...Object.keys(mainResult.metafile.outputs), ...Object.keys(lazyResult.metafile.outputs)]).size; -const mib = outputBytes([mainResult.metafile, lazyResult.metafile]) / (1024 * 1024); +const files = + new Set([...Object.keys(mainResult.metafile.outputs), ...Object.keys(lazyResult.metafile.outputs)]).size + 1; +const mib = (outputBytes([mainResult.metafile, lazyResult.metafile]) + cliLauncher.length) / (1024 * 1024); console.log(`Built ${relative(repoRoot, bundleDir)} (${files} files, ${mib.toFixed(1)} MiB)`);