affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

Thrown by the argument parser in scripts/harness-adapter-compliance.js when a dash-prefixed argument is not one of the recognized flags (--format, --json, --markdown, --text, --root, --help, -h) or their --flag=value variants. Any unrecognized token starting with '--' reaches the final throw.

Source

Thrown at scripts/harness-adapter-compliance.js:56

    }

    if (arg.startsWith('--format=')) {
      parsed.format = arg.slice('--format='.length).toLowerCase();
      continue;
    }

    if (arg === '--root') {
      parsed.root = path.resolve(args[index + 1] || process.cwd());
      index += 1;
      continue;
    }

    if (arg.startsWith('--root=')) {
      parsed.root = path.resolve(arg.slice('--root='.length));
      continue;
    }

    throw new Error(`Unknown argument: ${arg}`);
  }

  if (!['text', 'json', 'markdown'].includes(parsed.format)) {
    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
  }

  parsed.root = path.resolve(parsed.root);
  return parsed;
}

function printHelp() {
  console.log([
    'Usage: node scripts/harness-adapter-compliance.js [options]',
    '',
    'Validate or render the ECC harness adapter compliance scorecard.',
    '',
    'Options:',
    '  --check                 Fail if adapter records or docs are out of sync',

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/harness-adapter-compliance.js --help` to see accepted flags.
  2. Check for typos in flag names.
  3. Remove the unrecognized flag.
  4. Use --format=value or --root=value syntax if applicable.

Example fix

// before
node scripts/harness-adapter-compliance.js --outformat json
// after
node scripts/harness-adapter-compliance.js --format json
Defensive patterns

Strategy: validation

Validate before calling

const VALID_FLAGS = new Set(['--format', '--json', '--markdown', '--text', '--root', '--help', '-h']);
const unknown = args.filter(a => a.startsWith('--') && !VALID_FLAGS.has(a.split('=')[0]));
if (unknown.length > 0) {
  console.error(`Unknown flag(s): ${unknown.join(', ')}`);
  process.exit(1);
}

Type guard

function isKnownHarnessFlag(arg) {
  const base = arg.split('=')[0];
  return ['--format', '--json', '--markdown', '--text', '--root', '--help', '-h'].includes(base);
}

Prevention

When it happens

Trigger: Passing an unsupported flag like `--verbose`, `--output report.txt`, or a typo'd flag name such as `--forma` instead of `--format`.

Common situations: Typo in flag name, using flags from a different script, or passing a flag that was renamed in a version update.

Related errors


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