affaan-m/ECC · error
Unknown argument: ${arg}
Error message
Unknown argument: ${arg} What it means
The CLI argument parser in harness-audit.js only recognizes --help/-h, --format (and --format=), --scope (and --scope=), --root (and --root=), plus a bare scope token. Any other token that begins with '-' is treated as an unsupported flag and rejected outright. The tool will not guess or ignore unknown flags.
Source
Thrown at scripts/harness-audit.js:121
}
if (arg.startsWith('--format=')) {
parsed.format = arg.split('=')[1].toLowerCase();
continue;
}
if (arg.startsWith('--scope=')) {
parsed.scope = normalizeScope(arg.split('=')[1]);
continue;
}
if (arg.startsWith('--root=')) {
parsed.root = path.resolve(arg.slice('--root='.length));
continue;
}
if (arg.startsWith('-')) {
throw new Error(`Unknown argument: ${arg}`);
}
parsed.scope = normalizeScope(arg);
}
if (!['text', 'json'].includes(parsed.format)) {
throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);
}
return parsed;
}
function fileExists(rootDir, relativePath) {
return fs.existsSync(path.join(rootDir, relativePath));
}
function readText(rootDir, relativePath) {
return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');View on GitHub (pinned to 01e15490f0)
Solutions
- Run node scripts/harness-audit.js --help to see the accepted flag set
- Remove the unrecognized flag from the command line
- For machine-readable output use --format=json (there is no --json flag here)
Example fix
// before node scripts/harness-audit.js --json // after node scripts/harness-audit.js --format=json
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN = new Set(['--help','-h','--format','--scope','--root']);
const startsKnown = (a) => a.startsWith('--format=') || a.startsWith('--scope=') || a.startsWith('--root=');
for (const a of argv) {
if (a.startsWith('-') && !KNOWN.has(a) && !startsKnown(a)) {
throw new Error(`Unsupported harness-audit flag: ${a}`);
}
} Type guard
function isKnownHarnessAuditFlag(arg) {
if (!arg.startsWith('-')) return true; // bare scope token
return ['--help','-h','--format','--scope','--root'].includes(arg)
|| arg.startsWith('--format=')
|| arg.startsWith('--scope=')
|| arg.startsWith('--root=');
} Try / catch
try { main(); }
catch (err) {
if (/^Unknown argument:/.test(err.message)) {
console.error(`${err.message}\nRun: node scripts/harness-audit.js --help`);
process.exit(2);
}
throw err;
} Prevention
- Always cross-check flags against --help before scripting them
- Do not assume flags are shared across ECC subcommands
- Pin wrapper scripts to a help-output assertion in CI so flag drift is caught
When it happens
Trigger: Passing --json (which is valid in install-plan.js but NOT here), --verbose, -v, --output report.txt, or a typo such as --scpoe=repo. Also triggered by flags copied from a different ECC subcommand.
Common situations: Copying flags from another ECC script's help text, using an outdated flag renamed in a newer version, or a shell autocomplete inserting the wrong option.
Related errors
- --write requires a path
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
- Unknown argument: ${arg}
- Missing value for ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/b90902cff8ea18d2.
Report an issue: GitHub.