affaan-m/ECC · error

Unknown argument

Error message

Unknown argument: ${a}

What it means

parseArgs in scripts/proximity-tick.js throws this error when a command-line token does not match any of its recognized flags (--help, --dry-run, --json, --watch, --db, --state-db, etc.). The allowlist parser rejects unknown flags instead of ignoring them, catching typos and cross-script flag mistakes.

Solutions

  1. Run with --help/-h to see supported flags
  2. Fix the flag spelling to one of the recognized options
  3. Remove unsupported positional arguments
  4. Use space-separated flag values (e.g. --db path) if equals form isn't supported

Example fix

// before
node scripts/proximity-tick.js --interval 10
// after
node scripts/proximity-tick.js --watch 10
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = new Set(['--help','-h','--dry-run','--json','--watch','--db','--state-db']);
function findUnknownFlags(argv) {
  return argv.slice(2).filter(a => a.startsWith('--') && !KNOWN.has(a));
}

Try / catch

try {
  await main(process.argv);
} catch (e) {
  if (e.message.startsWith('Unknown argument:')) {
    console.error(`${e.message} — see --help for supported flags`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Passing an unsupported or misspelled flag such as `--interval`, `--verbose`, `--db=` (equals form if unsupported), or a stray positional argument.

Common situations: Reusing flags from other tick/audit scripts; typos like `--state_db`; passing positional file paths the script doesn't accept; assuming equals-style syntax is supported.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/67a7fe1aba813f81. Report an issue: GitHub.

Appendix: source

Thrown at scripts/proximity-tick.js:41

  const parsed = { watchSec: 0, dryRun: false, json: false, help: false, dbPath: null, stateDbPath: null };
  for (let i = 0; i < args.length; i += 1) {
    const a = args[i];
    if (a === '--help' || a === '-h') parsed.help = true;
    else if (a === '--dry-run') parsed.dryRun = true;
    else if (a === '--json') parsed.json = true;
    else if (a === '--watch') {
      const v = Number.parseInt(args[i + 1], 10);
      if (!Number.isInteger(v) || v <= 0) throw new Error('--watch needs a positive seconds value');
      parsed.watchSec = v;
      i += 1;
    } else if (a === '--db') {
      parsed.dbPath = args[i + 1];
      i += 1;
    } else if (a === '--state-db') {
      parsed.stateDbPath = args[i + 1];
      i += 1;
    } else {
      throw new Error(`Unknown argument: ${a}`);
    }
  }
  return parsed;
}

function showHelp() {
  console.log(
    [
      'Usage: node scripts/proximity-tick.js [--watch <seconds>] [--dry-run] [--json] [--db <path>] [--state-db <path>]',
      '',
      'Scan agent proximity from the control-pane state and steer/transmit by sending',
      'internal session-to-session messages. --dry-run sends nothing; --watch loops.'
    ].join('\n')
  );
}

function report(tick, json) {
  if (json) {

View on GitHub (pinned to 8321021c54)