affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

`parseArgs` in generate-command-registry.js accepts only three flags: `--json`, `--write`, `--check`. Any other CLI token throws `Unknown argument: <arg>`. The check runs before any work, so it fails fast on typos or unsupported options.

Source

Thrown at scripts/ci/generate-command-registry.js:263

  for (const { agent, count } of registry.statistics.topAgents) {
    lines.push(`  ${agent}: ${count}`);
  }

  lines.push('', 'Top skills:');
  for (const { skill, count } of registry.statistics.topSkills) {
    lines.push(`  ${skill}: ${count}`);
  }

  return `${lines.join('\n')}\n`;
}

function parseArgs(argv) {
  const allowed = new Set(['--json', '--write', '--check']);
  const flags = new Set();

  for (const arg of argv) {
    if (!allowed.has(arg)) {
      throw new Error(`Unknown argument: ${arg}`);
    }
    flags.add(arg);
  }

  return {
    json: flags.has('--json'),
    write: flags.has('--write'),
    check: flags.has('--check'),
  };
}

function run(argv = process.argv.slice(2), options = {}) {
  const stdout = options.stdout || process.stdout;
  const stderr = options.stderr || process.stderr;
  const outputPath = options.outputPath || DEFAULT_OUTPUT_PATH;

  try {
    const args = parseArgs(argv);

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Use only `--json`, `--write`, or `--check`. To emit JSON: `--json`. To write the artifact: `--write`. To verify staleness: `--check`.
  2. There is no `--help` in this script — read the file header comment (lines 1-10) for usage.
  3. Remove any positional or value-bearing arguments; the script hardcodes DEFAULT_OUTPUT_PATH.
  4. If you need a custom output path, call the exported `writeRegistry(registry, outputPath)` / `checkRegistry(registry, outputPath)` from Node instead of the CLI.

Example fix

// before — passing an unsupported --output flag
node scripts/ci/generate-command-registry.js --output docs/other.json
// -> Unknown argument: --output

// after
node scripts/ci/generate-command-registry.js --write
// or, for a custom path, call from Node:
// node -e "const {generateRegistry,writeRegistry}=require('./scripts/ci/generate-command-registry.js'); writeRegistry(generateRegistry(), 'docs/other.json')"
Defensive patterns

Strategy: validation

Validate before calling

const allowed = new Set(['--json', '--write', '--check']);
const argv = process.argv.slice(2);
for (const arg of argv) {
  if (!allowed.has(arg)) {
    console.error(`Unknown argument: ${arg}. Allowed: --json, --write, --check`);
    process.exit(2);
  }
}

Type guard

function isAllowedArg(arg) {
  return new Set(['--json', '--write', '--check']).has(arg);
}

Try / catch

try {
  run(argv);
} catch (error) {
  if (/Unknown argument/i.test(error.message)) {
    console.error('Allowed flags: --json, --write, --check. No --help, no value-bearing flags.');
  }
  throw error;
}

Prevention

When it happens

Trigger: Triggered by passing any flag outside the allowed set: `--help`, `-h`, `--output`, `--check-only`, positional args, `--format`, misspelled flags like `--wite`, or a value-bearing flag like `--out path.json`.

Common situations: A user assumes `--help` exists (it doesn't in this script). Someone passes an output path. A CI script forwards unknown args. A typo on the command line. Confusing this script's flag set with another CI script's (e.g. catalog.js supports `--md`/`--text` but this one doesn't).

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/d6fdb0605273eb53. Report an issue: GitHub.