{"record":{"id":"96c6170323d83385","repo":"Yeachan-Heo/oh-my-codex","slug":"conflicting-setup-agents-merge-policy-flags-sou","errorCode":null,"errorMessage":"Conflicting setup AGENTS merge policy flags: ${source} conflicts with another merge policy selector.","messagePattern":"Conflicting setup AGENTS merge policy flags: (.+?) conflicts with another merge policy selector\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":535,"sourceCode":"  \"team\",\n  \"tmux-hook\",\n]);\n\nexport interface ResolvedCliInvocation {\n  command: CliCommand;\n  launchArgs: string[];\n}\n\nexport type SetupMergeAgentsPolicyArg =\n  | { kind: \"set\"; value: boolean }\n  | { kind: \"clear\" }\n  | undefined;\n\nexport function resolveSetupAgentsMergePolicyArg(args: string[]): SetupMergeAgentsPolicyArg {\n  let policy: SetupMergeAgentsPolicyArg;\n  const setPolicy = (next: Exclude<SetupMergeAgentsPolicyArg, undefined>, source: string): void => {\n    if (policy && (policy.kind !== next.kind || (policy.kind === \"set\" && next.kind === \"set\" && policy.value !== next.value))) {\n      throw new Error(`Conflicting setup AGENTS merge policy flags: ${source} conflicts with another merge policy selector.`);\n    }\n    policy = next;\n  };\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n    if (arg === \"--merge-agents\" || arg === \"--no-merge-agents\" || arg === \"--clear-merge-agents-policy\") {\n      const next = args[index + 1];\n      if (next && !next.startsWith(\"--\")) {\n        throw new Error(`Setup AGENTS merge policy flags do not accept values: ${arg} ${next}`);\n      }\n      if (arg === \"--merge-agents\") {\n        setPolicy({ kind: \"set\", value: true }, arg);\n      } else if (arg === \"--no-merge-agents\") {\n        setPolicy({ kind: \"set\", value: false }, arg);\n      } else {\n        setPolicy({ kind: \"clear\" }, arg);\n      }\n    } else if (","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L517-L553","documentation":"The `setup` command's AGENTS merge policy can only be selected once. `resolveSetupAgentsMergePolicyArg` throws when two conflicting policy flags are given — i.e. a second flag of a different kind, or two `set`-kind flags with different values (`--merge-agents` vs `--no-merge-agents`).","triggerScenarios":"Passing more than one of `--merge-agents`, `--no-merge-agents`, `--clear-merge-agents-policy` with differing kinds, e.g. `omx setup --merge-agents --clear-merge-agents-policy` or `omx setup --merge-agents --no-merge-agents`. Repeating the identical flag is fine; conflicting combinations throw.","commonSituations":"Combining flags copy-pasted from different docs or config templates; shell scripts accumulating options from multiple env sources.","solutions":["Use exactly one merge policy flag per invocation","Pick the policy you actually want: --merge-agents, --no-merge-agents, or --clear-merge-agents-policy","Split conflicting policies into separate setup runs if both behaviors are needed over time"],"exampleFix":"# before\nomx setup --merge-agents --clear-merge-agents-policy\n\n# after\nomx setup --merge-agents","handlingStrategy":"validation","validationCode":"const POLICY_FLAGS = ['--merge-agents', '--no-merge-agents', '--clear-merge-agents-policy'];\nconst used = args.filter(a => POLICY_FLAGS.includes(a));\nconst uniqueKinds = new Set(used);\nif (uniqueKinds.size > 1) {\n  console.error('Only one AGENTS merge policy flag is allowed');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await main(args);\n} catch (e) {\n  if ((e as Error).message.startsWith('Conflicting setup AGENTS merge policy flags')) {\n    // strip all but one policy flag and retry\n  } else throw e;\n}","preventionTips":["Build CLI args from a single source of truth config","Never merge flag lists from multiple templates"],"tags":["cli","argument-validation","conflicting-flags","setup"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}