From 2fe1d1991a5afc4bb9af8d268dbdcf96209cc830 Mon Sep 17 00:00:00 2001 From: roboomp Date: Thu, 6 Aug 2026 18:45:58 +0000 Subject: [PATCH] feat(coding-agent): marked child processes as agent-driven - Set AGENT=1 through the shared non-interactive child environment. - Covered the marker through the bash executor integration path. Fixes #7847 --- packages/coding-agent/CHANGELOG.md | 4 ++++ packages/coding-agent/src/exec/non-interactive-env.ts | 1 + packages/coding-agent/test/bash-executor.test.ts | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) 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 () => {