affaan-m/ECC · error · Error
Expected at most one agents directory argument
Error message
Expected at most one agents directory argument
What it means
Thrown by parseArgs() in scripts/gemini-adapt-agents.js when more than one positional (non-dash) argument is provided on the command line. The script accepts at most one positional argument: the agents directory path, defaulting to .gemini/agents under the current working directory.
Source
Thrown at scripts/gemini-adapt-agents.js:38
return [
'Adapt ECC agent frontmatter for Gemini CLI.',
'',
'Usage:',
' node scripts/gemini-adapt-agents.js [agents-dir]',
'',
'Defaults to .gemini/agents under the current working directory.',
'Rewrites tools: to Gemini-compatible tool names and removes unsupported color: metadata.'
].join('\n');
}
function parseArgs(argv) {
if (argv.includes('--help') || argv.includes('-h')) {
return { help: true };
}
const positional = argv.filter(arg => !arg.startsWith('-'));
if (positional.length > 1) {
throw new Error('Expected at most one agents directory argument');
}
return {
help: false,
agentsDir: path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents')),
};
}
function ensureDirectory(dirPath) {
if (!fs.existsSync(dirPath)) {
throw new Error(`Agents directory not found: ${dirPath}`);
}
if (!fs.statSync(dirPath).isDirectory()) {
throw new Error(`Expected a directory: ${dirPath}`);
}
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Provide only one directory path: `node scripts/gemini-adapt-agents.js [single-dir]`.
- Quote paths containing spaces: `node scripts/gemini-adapt-agents.js "my agents"`.
- Omit the directory entirely to use the default `.gemini/agents`.
- Run with --help to see expected usage.
Example fix
// before node scripts/gemini-adapt-agents.js ./input ./output // after node scripts/gemini-adapt-agents.js ./input
Defensive patterns
Strategy: validation
Validate before calling
const positional = argv.filter(a => !a.startsWith('-'));
if (positional.length > 1) {
console.error(`Expected at most one directory argument, got ${positional.length}: ${positional.join(', ')}`);
process.exit(1);
} Type guard
function hasAtMostOnePositional(argv) {
return argv.filter(a => !a.startsWith('-')).length <= 1;
} Prevention
- Quote directory paths containing spaces to prevent shell splitting.
- Review the script's --help before passing multiple positionals.
- Validate argument count before calling the script in automation.
When it happens
Trigger: Running `node scripts/gemini-adapt-agents.js ./dir1 ./dir2` or any invocation where two or more arguments do not start with '-'. The filter `argv.filter(arg => !arg.startsWith('-'))` yields more than one entry.
Common situations: Passing both an input and output directory (the script only takes one), or accidentally including an unquoted path with spaces that splits into two tokens, or passing a positional that was meant to be a flag value.
Related errors
- Unknown command: ${firstArg}
- Unknown command: ${resolution.command}
- Unknown argument: ${arg}
- ${flagName} requires a value
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/0074840e052928d3.
Report an issue: GitHub.