diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index bd81a6f64..70648c82c 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added `AGENT=1` to coding-agent child-process environments so downstream tools can detect agent-driven execution ([#7847](https://github.com/can1357/oh-my-pi/issues/7847)). + ## [17.2.10] - 2026-08-06 ### Breaking Changes diff --git a/packages/coding-agent/src/exec/non-interactive-env.ts b/packages/coding-agent/src/exec/non-interactive-env.ts index 1d25df10e..42f6bab2a 100644 --- a/packages/coding-agent/src/exec/non-interactive-env.ts +++ b/packages/coding-agent/src/exec/non-interactive-env.ts @@ -24,6 +24,7 @@ export const NON_INTERACTIVE_ENV: Readonly> = { GIT_TERMINAL_PROMPT: "0", SSH_ASKPASS: "/usr/bin/false", CI: "1", + AGENT: "1", // Package manager defaults for unattended execution. npm_config_yes: "true", npm_config_update_notifier: "false", diff --git a/packages/coding-agent/test/bash-executor.test.ts b/packages/coding-agent/test/bash-executor.test.ts index ff1d1d6a3..c3e61c4bb 100644 --- a/packages/coding-agent/test/bash-executor.test.ts +++ b/packages/coding-agent/test/bash-executor.test.ts @@ -231,12 +231,12 @@ describe("executeBash", () => { }); it("applies non-interactive environment defaults", async () => { - const result = await executeBash('echo "$GIT_TERMINAL_PROMPT:$PI_TEST_ENV"', { + const result = await executeBash('echo "$AGENT:$GIT_TERMINAL_PROMPT:$PI_TEST_ENV"', { cwd: tempDir, timeout: 5000, env: { PI_TEST_ENV: "hello" }, }); - expect(result.output.trim()).toBe("0:hello"); + expect(result.output.trim()).toBe("1:0:hello"); }); it("runs non-bash shellPath commands through the configured shell", async () => {