Yeachan-Heo/oh-my-codex · error · Error

agents-init accepts at most one path argument.\n${AGENTS_INI

Error message

agents-init accepts at most one path argument.\n${AGENTS_INIT_USAGE}

What it means

agents-init accepts at most one positional argument (the target path). Passing two or more non-flag arguments is ambiguous and rejected with the usage string.

Source

Thrown at src/cli/agents-init.ts:415

export async function agentsInitCommand(args: string[]): Promise<void> {
  if (args.includes("--help") || args.includes("-h")) {
    console.log(AGENTS_INIT_USAGE);
    return;
  }

  const allowedFlags = new Set(["--dry-run", "--force", "--verbose"]);
  for (const arg of args) {
    if (!arg.startsWith("-")) continue;
    if (!allowedFlags.has(arg)) {
      throw new Error(
        `Unknown agents-init option: ${arg}\n${AGENTS_INIT_USAGE}`,
      );
    }
  }

  const positionals = args.filter((arg) => !arg.startsWith("-"));
  if (positionals.length > 1) {
    throw new Error(
      `agents-init accepts at most one path argument.\n${AGENTS_INIT_USAGE}`,
    );
  }

  await agentsInit({
    targetPath: positionals[0],
    dryRun: args.includes("--dry-run"),
    force: args.includes("--force"),
    verbose: args.includes("--verbose"),
  });
}

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Run the command once per target
  2. Quote arguments that may expand to multiple words
  3. Remove stray positionals

Example fix

# before
omx agents-init packages/a packages/b

# after
omx agents-init packages/a && omx agents-init packages/b
Defensive patterns

Strategy: validation

Validate before calling

const positionals = args.filter(a => !a.startsWith('-'));
if (positionals.length > 1) {
  console.error('agents-init takes at most one path');
  process.exit(2);
}

Prevention

When it happens

Trigger: Running `omx agents-init . extra` or passing multiple target paths expecting batch scaffolding.

Common situations: Assuming multi-target support, unquoted shell expansion producing multiple words, or leftover arguments in a script.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/7d92fa54291b54ee. Report an issue: GitHub.