diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 23d7b9394..6e63d2f26 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Fixed package commands such as `pi list`, `pi install`, and `pi update` to terminate after completing even if an extension leaves background handles open ([#5687](https://github.com/earendil-works/pi/issues/5687)). - Fixed `pi update` for pnpm global installs whose configured `global-bin-dir` no longer matches the active pnpm home ([#5689](https://github.com/earendil-works/pi/issues/5689)). - Fixed npm package specs that use ranges or tags (for example `@^1.2.7`) so installed package resources still load instead of being treated as mismatched exact pins ([#5695](https://github.com/earendil-works/pi/issues/5695)). - Fixed inherited OpenCode/OpenCode Go completion model metadata to omit long-retention cache fields for routes that reject `prompt_cache_retention` ([#5702](https://github.com/earendil-works/pi/issues/5702)). diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index 63d6ec1ef..00f3b208d 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -467,6 +467,7 @@ export async function main(args: string[], options?: MainOptions) { } if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) { + process.exit(process.exitCode ?? 0); return; } diff --git a/packages/coding-agent/test/package-command-paths.test.ts b/packages/coding-agent/test/package-command-paths.test.ts index 1cff83f6f..4cc1ce5ec 100644 --- a/packages/coding-agent/test/package-command-paths.test.ts +++ b/packages/coding-agent/test/package-command-paths.test.ts @@ -37,12 +37,21 @@ describe("package commands", () => { originalExitCode = process.exitCode; originalExecPath = process.execPath; process.exitCode = undefined; + vi.spyOn(process, "exit").mockImplementation(((code?: string | number | null) => { + if (code === undefined || code === null || Number(code) === 0) { + process.exitCode = undefined; + } else { + process.exitCode = code; + } + return undefined as never; + }) as typeof process.exit); process.env[ENV_AGENT_DIR] = agentDir; process.chdir(projectDir); }); afterEach(() => { vi.unstubAllGlobals(); + vi.restoreAllMocks(); process.chdir(originalCwd); process.exitCode = originalExitCode; if (originalAgentDir === undefined) {