{"record":{"id":"72076b8eaf416080","repo":"can1357/oh-my-pi","slug":"in-place-and-out-are-mutually-exclusive-72076b","errorCode":null,"errorMessage":"--in-place and --out are mutually exclusive","messagePattern":"--in-place and --out are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/compress/index.ts","lineNumber":82,"sourceCode":"\t\t\t}\n\t\t\tif (matched === 0) throw new Error(`No files matched \"${pattern}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = path.resolve(cwd, pattern);\n\t\tconst stat = await fs.stat(resolved).catch(() => undefined);\n\t\tif (!stat?.isFile()) throw new Error(`Not a file: ${shortenPath(resolved)}`);\n\t\tfound.add(resolved);\n\t}\n\treturn [...found].sort();\n}\n\n/** Compress every requested file through the rewrite/approve loop. */\nexport async function runCompressCommand(options: CompressCommandOptions): Promise<CompressResult> {\n\tconst maxRounds = options.maxRounds ?? DEFAULT_MAX_ROUNDS;\n\tconst concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;\n\tif (!Number.isInteger(maxRounds) || maxRounds <= 0) throw new Error(\"--rounds must be a positive integer\");\n\tif (!Number.isInteger(concurrency) || concurrency <= 0) throw new Error(\"--agents must be a positive integer\");\n\tif (options.inPlace && options.output) throw new Error(\"--in-place and --out are mutually exclusive\");\n\t// Paths and patterns follow the shell's cwd, as a file-taking CLI must; the project\n\t// dir only scopes settings discovery for the sessions.\n\tconst invocationDir = process.cwd();\n\tconst cwd = getProjectDir();\n\tconst targets = await resolveCompressTargets(options.files, invocationDir);\n\tif (targets.length === 0) throw new Error(\"No files to compress\");\n\tif (targets.length > 1 && !options.inPlace) {\n\t\tthrow new Error(`${targets.length} files matched; pass --in-place to rewrite them (--out takes a single file)`);\n\t}\n\n\tconst abortController = new AbortController();\n\tconst abort = (): void => abortController.abort(new Error(\"Compress interrupted\"));\n\tprocess.once(\"SIGINT\", abort);\n\tprocess.once(\"SIGTERM\", abort);\n\tconst progress = createProgressReporter(\"Compressing\");\n\tconst emitToStdout = targets.length === 1 && !options.inPlace && options.output === undefined;\n\n\ttry {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/compress/index.ts#L64-L100","documentation":"runCompressCommand supports either in-place rewriting of the input files or writing a single compressed file via --out. Supplying both flags is ambiguous (where should results go for each target?), so it throws immediately. This is a pure option-conflict guard, checked before any file resolution.","triggerScenarios":"Invoking compress with both `--in-place` and `--out <path>` (or setting both options.inPlace and options.output programmatically).","commonSituations":"Aliases or wrapper scripts that always append --in-place while the user also passes --out; copy-pasted command lines combining examples; config-driven invocations where both flags were enabled.","solutions":["Pick one mode: use `--in-place` alone to rewrite input files, or `--out <file>` alone to write a single result.","Remove the conflicting flag from your wrapper script/alias.","Run two separate invocations if you need both a rewritten file and an output copy."],"exampleFix":"// before\nomp compress file.ts --in-place --out result.ts\n// after\nomp compress file.ts --out result.ts","handlingStrategy":"validation","validationCode":"if (options.inPlace && options.output) {\n  throw new Error(\"--in-place and --out are mutually exclusive\");\n}\n// check before invoking runCompressCommand","typeGuard":null,"tryCatchPattern":"try {\n  await runCompressCommand(options);\n} catch (err) {\n  if (err instanceof Error && err.message === \"--in-place and --out are mutually exclusive\") {\n    process.stderr.write(`${err.message} — choose one output mode\\n`);\n  } else throw err;\n}","preventionTips":["Decide output mode up front: rewrite source (--in-place) or write one result file (--out).","Audit aliases/wrapper scripts that hard-code one of the flags.","In config-driven setups, enforce the XOR constraint when building the options object."],"tags":["cli","argument-validation","mutually-exclusive-options"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}