diff --git a/README.md b/README.md index 6124375..a222e0a 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ override URLs. Default output is adaptive: -- coding-agent, CI, non-TTY, and automation signals use compact structured - agent output; +- `AGENT` names/flags, coding-agent, CI, non-TTY, and automation signals use + compact structured agent output; - interactive TTY sessions use human output; - `--json`, `--quiet`, `-q`, `--output `, `-o `, and `AKUA_OUTPUT` override detection. diff --git a/docs/architecture.md b/docs/architecture.md index 2a6ef32..98d71d4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -119,7 +119,8 @@ stored with user-only file permissions. The default output mode is adaptive: - `human`: interactive TTY without automation or coding-agent signals; -- `agent`: known coding-agent env vars, CI env vars, or non-TTY stdout; +- `agent`: `AGENT` names/flags, known coding-agent env vars, CI env vars, or + non-TTY stdout; - `json`: explicit `--json`, `--output json`, `-o json`, or `AKUA_OUTPUT=json`; - `quiet`: explicit `--quiet`, `-q`, `--output quiet`, `-o quiet`, or diff --git a/src/runtime/mode.ts b/src/runtime/mode.ts index 0c55e39..be64809 100644 --- a/src/runtime/mode.ts +++ b/src/runtime/mode.ts @@ -9,6 +9,7 @@ export interface OutputModeInput { } const AGENT_ENV_VARS = [ + "AGENT", "CODEX_SANDBOX", "CODEX_CLI", "OPENAI_CODEX", diff --git a/test/mode.test.ts b/test/mode.test.ts index 0315e90..95d0050 100644 --- a/test/mode.test.ts +++ b/test/mode.test.ts @@ -11,6 +11,14 @@ describe("detectOutputMode", () => { expect(detectOutputMode({ argv: [], env: { CODEX_SANDBOX: "1" }, stdoutIsTTY: true })).toBe("agent"); }); + test("detects universal agent environment flag", () => { + expect(detectOutputMode({ argv: [], env: { AGENT: "true" }, stdoutIsTTY: true })).toBe("agent"); + }); + + test("detects universal agent environment name", () => { + expect(detectOutputMode({ argv: [], env: { AGENT: "codex" }, stdoutIsTTY: true })).toBe("agent"); + }); + test("detects CI and non-tty automation", () => { expect(detectOutputMode({ argv: [], env: { CI: "true" }, stdoutIsTTY: true })).toBe("agent"); expect(detectOutputMode({ argv: [], env: {}, stdoutIsTTY: false })).toBe("agent");