{"record":{"id":"8149ff790e1a9dcf","repo":"can1357/oh-my-pi","slug":"trusted-extension-cannot-be-combined-with-exte","errorCode":null,"errorMessage":"--trusted-extension cannot be combined with --extension, -e, or --hook","messagePattern":"--trusted-extension cannot be combined with --extension, -e, or --hook","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/args.ts","lineNumber":321,"sourceCode":"\t\t\t// removes it so it does not leak into messages (issue #2459).\n\t\t\tresult.unrecognizedFlags.push(arg);\n\t\t}\n\t\t// Drop an unconsumed `--flag=value` value (e.g. a boolean flag): when no\n\t\t// branch advanced past the spliced token, remove it so it does not fall\n\t\t// through to a later iteration and become a positional message.\n\t\tif (equalsValueIndex !== -1 && i === flagIndex) {\n\t\t\targs.splice(equalsValueIndex, 1);\n\t\t}\n\t}\n\n\tconst swallowedTrustedFlag = [...(result.extensions ?? []), ...(result.hooks ?? [])].some(\n\t\tvalue => value === \"--trusted-extension\" || value.startsWith(\"--trusted-extension=\"),\n\t);\n\tif ((result.trustedExtensions?.length ?? 0) !== trustedFlagCount || swallowedTrustedFlag) {\n\t\tthrow new CliUsageError(\"--trusted-extension requires a non-empty, non-flag value\");\n\t}\n\tif (trustedFlagCount > 0 && ((result.extensions?.length ?? 0) > 0 || (result.hooks?.length ?? 0) > 0)) {\n\t\tthrow new CliUsageError(\"--trusted-extension cannot be combined with --extension, -e, or --hook\");\n\t}\n\tfor (const trustedPath of result.trustedExtensions ?? []) {\n\t\tif (trustedPath.length === 0) {\n\t\t\tthrow new CliUsageError(\"--trusted-extension requires a non-empty, non-flag value\");\n\t\t}\n\t\tif (!path.isAbsolute(trustedPath)) {\n\t\t\tthrow new CliUsageError(`--trusted-extension requires an absolute path: ${trustedPath}`);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/** Reject requested tool names absent from the fully discovered session registry. */\nexport function validateToolNames(requested: readonly string[] | undefined, known: readonly string[]): void {\n\tif (!requested) return;\n\tconst knownNames = new Set(known);\n\tconst unknown = requested.filter(name => !knownNames.has(name));","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/args.ts#L303-L339","documentation":"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.","triggerScenarios":"A single omp invocation that includes at least one --trusted-extension AND at least one --extension/-e or --hook flag (in any order).","commonSituations":"Extending a previously working command line by appending a trusted extension (or vice versa), or docs/scripts from different workflows merged into one command.","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."],"exampleFix":"// before\nomp --trusted-extension=/a/b --extension ./my-ext\n// after\nomp --trusted-extension=/a/b   # move --extension to a separate invocation or config","handlingStrategy":"validation","validationCode":"const hasTrusted = argv.some(a => a === \"--trusted-extension\" || a.startsWith(\"--trusted-extension=\"));\nconst hasExtOrHook = argv.some(a => a === \"--extension\" || a === \"-e\" || a === \"--hook\");\nif (hasTrusted && hasExtOrHook) {\n  throw new Error(\"Split into two invocations: --trusted-extension cannot combine with --extension/-e/--hook\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  await runRootCommand(argv);\n} catch (err) {\n  if (err instanceof CliUsageError && err.message.includes(\"cannot be combined\")) {\n    console.error(\"Use either trusted extensions or extensions/hooks in one command, not both.\");\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["cli","conflicting-flags","usage-error"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}