Files
openclaw/extensions/policy/src/cli-output-mode.ts
T
2026-07-27 05:44:16 -04:00

15 lines
636 B
TypeScript

import { getRootOptionAwareCommandPath } from "openclaw/plugin-sdk/cli-argv";
/** Policy commands follow Unix convention and switch to JSON when stdout is not a terminal. */
function isPolicyMachineOutput(params: { argv: readonly string[]; stdoutIsTTY: boolean }): boolean {
const [, command] = getRootOptionAwareCommandPath(params.argv, 2);
return ["check", "compare", "watch"].includes(command ?? "") && !params.stdoutIsTTY;
}
export const POLICY_CLI_DESCRIPTOR = {
name: "policy",
description: "Check policy requirements and emit audit evidence",
hasSubcommands: true,
machineOutput: isPolicyMachineOutput,
} as const;