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

Unknown agents-init option: ${arg}\n${AGENTS_INIT_USAGE}

Error message

Unknown agents-init option: ${arg}\n${AGENTS_INIT_USAGE}

What it means

agents-init only accepts the flags --dry-run, --force and --verbose; any other dash-prefixed argument triggers this error with the full usage text appended. Positional path arguments are handled separately.

Source

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

  );

  console.log("Summary:");
  console.log(
    `  updated=${summary.updated}, unchanged=${summary.unchanged}, backed_up=${summary.backedUp}, skipped=${summary.skipped}`,
  );
}

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. Use only --dry-run, --force, --verbose
  2. Check for typos such as --dryrun vs --dry-run
  3. Read the usage text embedded in the error message

Example fix

# before
omx agents-init --dryrun

# after
omx agents-init --dry-run
Defensive patterns

Strategy: validation

Validate before calling

const allowed = new Set(['--dry-run', '--force', '--verbose']);
const bad = args.filter(a => a.startsWith('-') && !allowed.has(a));
if (bad.length) { console.error(`unknown options: ${bad.join(', ')}`); process.exit(2); }

Type guard

const isAllowedFlag = (a: string): boolean => !a.startsWith('-') || ['--dry-run','--force','--verbose'].includes(a);

Prevention

When it happens

Trigger: Running `omx agents-init --quiet`, `--yes`, or a typo like `--dryrun`.

Common situations: Habits carried from other CLIs, assuming a global flag applies here, or typo'd flag names (missing hyphen in --dry-run).

Related errors


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