can1357/oh-my-pi · error · CliUsageError
--trusted-extension cannot be combined with --extension, -e,
Error message
--trusted-extension cannot be combined with --extension, -e, or --hook
What it means
parseArgs rejects combining --trusted-extension with --extension (-e) or --hook because the two loading mechanisms are mutually exclusive in a single invocation; both flags present means the CLI cannot decide a single extension strategy.
Source
Thrown at packages/coding-agent/src/cli/args.ts:321
// removes it so it does not leak into messages (issue #2459).
result.unrecognizedFlags.push(arg);
}
// Drop an unconsumed `--flag=value` value (e.g. a boolean flag): when no
// branch advanced past the spliced token, remove it so it does not fall
// through to a later iteration and become a positional message.
if (equalsValueIndex !== -1 && i === flagIndex) {
args.splice(equalsValueIndex, 1);
}
}
const swallowedTrustedFlag = [...(result.extensions ?? []), ...(result.hooks ?? [])].some(
value => value === "--trusted-extension" || value.startsWith("--trusted-extension="),
);
if ((result.trustedExtensions?.length ?? 0) !== trustedFlagCount || swallowedTrustedFlag) {
throw new CliUsageError("--trusted-extension requires a non-empty, non-flag value");
}
if (trustedFlagCount > 0 && ((result.extensions?.length ?? 0) > 0 || (result.hooks?.length ?? 0) > 0)) {
throw new CliUsageError("--trusted-extension cannot be combined with --extension, -e, or --hook");
}
for (const trustedPath of result.trustedExtensions ?? []) {
if (trustedPath.length === 0) {
throw new CliUsageError("--trusted-extension requires a non-empty, non-flag value");
}
if (!path.isAbsolute(trustedPath)) {
throw new CliUsageError(`--trusted-extension requires an absolute path: ${trustedPath}`);
}
}
return result;
}
/** Reject requested tool names absent from the fully discovered session registry. */
export function validateToolNames(requested: readonly string[] | undefined, known: readonly string[]): void {
if (!requested) return;
const knownNames = new Set(known);
const unknown = requested.filter(name => !knownNames.has(name));View on GitHub (pinned to 9690622007)
Solutions
- Remove one group of flags: keep either trusted extensions or extensions/hooks for this run.
- If both are genuinely needed, run two invocations or use a config file that declares them appropriately.
- Check scripts/CI configs for accumulated flags from multiple sources.
Example fix
// before omp --trusted-extension=/a/b --extension ./my-ext // after omp --trusted-extension=/a/b # move --extension to a separate invocation or config
Defensive patterns
Strategy: validation
Validate before calling
const hasTrusted = argv.some(a => a === "--trusted-extension" || a.startsWith("--trusted-extension="));
const hasExtOrHook = argv.some(a => a === "--extension" || a === "-e" || a === "--hook");
if (hasTrusted && hasExtOrHook) {
throw new Error("Split into two invocations: --trusted-extension cannot combine with --extension/-e/--hook");
} Type guard
null
Try / catch
try {
await runRootCommand(argv);
} catch (err) {
if (err instanceof CliUsageError && err.message.includes("cannot be combined")) {
console.error("Use either trusted extensions or extensions/hooks in one command, not both.");
process.exitCode = 2;
return;
}
throw err;
} Prevention
- Keep one extension-loading strategy per script; document which one your CI uses.
- Grep accumulated command-line builders for both flag groups before shipping.
- Migrate legacy --extension usage to --trusted-extension deliberately, not incrementally.
When it happens
Trigger: A single omp invocation that includes at least one --trusted-extension AND at least one --extension/-e or --hook flag (in any order).
Common situations: Extending a previously working command line by appending a trusted extension (or vice versa), or docs/scripts from different workflows merged into one command.
Related errors
- Choose either --user or --project, not both.
- too many templates
- extra operand {} file operands cannot be combined with --fil
- multiple output files specified
- when reading file names from standard input, no file name of
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8149ff790e1a9dcf.
Report an issue: GitHub.