{"record":{"id":"fc59ab198319cb90","repo":"can1357/oh-my-pi","slug":"choose-either-user-or-project-not-both","errorCode":null,"errorMessage":"Choose either --user or --project, not both.","messagePattern":"Choose either --user or --project, not both\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/agents-cli.ts","lineNumber":45,"sourceCode":"\ninterface UnpackResult {\n\ttargetDir: string;\n\ttotal: number;\n\twritten: string[];\n\tskipped: string[];\n}\n\nfunction writeStdout(line: string): void {\n\tprocess.stdout.write(`${line}\\n`);\n}\n\nfunction resolveTargetDir(flags: AgentsCommandArgs[\"flags\"]): string {\n\tif (flags.dir && flags.dir.trim().length > 0) {\n\t\treturn path.resolve(getProjectDir(), flags.dir.trim());\n\t}\n\n\tif (flags.user && flags.project) {\n\t\tthrow new Error(\"Choose either --user or --project, not both.\");\n\t}\n\n\tif (flags.project) {\n\t\treturn path.resolve(getProjectDir(), \".omp\", \"agents\");\n\t}\n\n\treturn path.join(getAgentDir(), \"agents\");\n}\n\nfunction toFrontmatter(agent: AgentDefinition): Record<string, unknown> {\n\tconst frontmatter: Record<string, unknown> = {\n\t\tname: agent.name,\n\t\tdescription: agent.description,\n\t};\n\n\tif (agent.tools && agent.tools.length > 0) frontmatter.tools = agent.tools;\n\tif (agent.spawns !== undefined) frontmatter.spawns = agent.spawns;\n\tif (agent.model && agent.model.length > 0) frontmatter.model = agent.model;","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/agents-cli.ts#L27-L63","documentation":"resolveTargetDir determines which agents directory the `omp agents` subcommand operates on. Passing both --user and --project flags is ambiguous (two conflicting target scopes), so it throws immediately rather than picking one silently.","triggerScenarios":"Running any agents CLI command with both flags together, e.g. `omp agents list --user --project`. Passing neither falls back to the default project dir; passing --dir overrides both.","commonSituations":"Shell aliases or wrapper scripts that append --project on top of a command that already includes --user, or copy-pasted commands where both scopes were meant for two separate invocations.","solutions":["Remove one of the two flags — keep --user for the user-level agents dir or --project for the project-level one.","If a custom location is needed, drop both and use --dir <path> instead.","Fix wrapper scripts/aliases that inject the conflicting flag."],"exampleFix":"// before\nomp agents list --user --project\n// after\nomp agents list --user   # or: omp agents list --project","handlingStrategy":"validation","validationCode":"if (flags.user && flags.project) {\n  throw new Error(\"Choose either --user or --project, not both.\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  await runAgentsCommand(args);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Choose either --user or --project\")) {\n    console.error(\"Pass only one of --user / --project (or --dir <path>).\");\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Build command lines from one scope variable, not by concatenating flags from multiple sources.","Audit shell aliases/wrappers that append scope flags automatically.","Prefer --dir <path> when a specific location matters."],"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"}