can1357/oh-my-pi · error · Error

Choose either --user or --project, not both.

Error message

Choose either --user or --project, not both.

What it means

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.

Source

Thrown at packages/coding-agent/src/cli/agents-cli.ts:45

interface UnpackResult {
	targetDir: string;
	total: number;
	written: string[];
	skipped: string[];
}

function writeStdout(line: string): void {
	process.stdout.write(`${line}\n`);
}

function resolveTargetDir(flags: AgentsCommandArgs["flags"]): string {
	if (flags.dir && flags.dir.trim().length > 0) {
		return path.resolve(getProjectDir(), flags.dir.trim());
	}

	if (flags.user && flags.project) {
		throw new Error("Choose either --user or --project, not both.");
	}

	if (flags.project) {
		return path.resolve(getProjectDir(), ".omp", "agents");
	}

	return path.join(getAgentDir(), "agents");
}

function toFrontmatter(agent: AgentDefinition): Record<string, unknown> {
	const frontmatter: Record<string, unknown> = {
		name: agent.name,
		description: agent.description,
	};

	if (agent.tools && agent.tools.length > 0) frontmatter.tools = agent.tools;
	if (agent.spawns !== undefined) frontmatter.spawns = agent.spawns;
	if (agent.model && agent.model.length > 0) frontmatter.model = agent.model;

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove one of the two flags — keep --user for the user-level agents dir or --project for the project-level one.
  2. If a custom location is needed, drop both and use --dir <path> instead.
  3. Fix wrapper scripts/aliases that inject the conflicting flag.

Example fix

// before
omp agents list --user --project
// after
omp agents list --user   # or: omp agents list --project
Defensive patterns

Strategy: validation

Validate before calling

if (flags.user && flags.project) {
  throw new Error("Choose either --user or --project, not both.");
}

Type guard

null

Try / catch

try {
  await runAgentsCommand(args);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Choose either --user or --project")) {
    console.error("Pass only one of --user / --project (or --dir <path>).");
    process.exitCode = 2;
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/fc59ab198319cb90. Report an issue: GitHub.