{"record":{"id":"0074840e052928d3","repo":"affaan-m/ECC","slug":"expected-at-most-one-agents-directory-argument","errorCode":null,"errorMessage":"Expected at most one agents directory argument","messagePattern":"Expected at most one agents directory argument","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/gemini-adapt-agents.js","lineNumber":38,"sourceCode":"  return [\n    'Adapt ECC agent frontmatter for Gemini CLI.',\n    '',\n    'Usage:',\n    '  node scripts/gemini-adapt-agents.js [agents-dir]',\n    '',\n    'Defaults to .gemini/agents under the current working directory.',\n    'Rewrites tools: to Gemini-compatible tool names and removes unsupported color: metadata.'\n  ].join('\\n');\n}\n\nfunction parseArgs(argv) {\n  if (argv.includes('--help') || argv.includes('-h')) {\n    return { help: true };\n  }\n\n  const positional = argv.filter(arg => !arg.startsWith('-'));\n  if (positional.length > 1) {\n    throw new Error('Expected at most one agents directory argument');\n  }\n\n  return {\n    help: false,\n    agentsDir: path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents')),\n  };\n}\n\nfunction ensureDirectory(dirPath) {\n  if (!fs.existsSync(dirPath)) {\n    throw new Error(`Agents directory not found: ${dirPath}`);\n  }\n\n  if (!fs.statSync(dirPath).isDirectory()) {\n    throw new Error(`Expected a directory: ${dirPath}`);\n  }\n}\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/gemini-adapt-agents.js#L20-L56","documentation":"parseArgs throws when more than one positional argument is supplied; the tool accepts at most a single agents directory path. Extra positionals indicate a malformed invocation (unquoted paths with spaces often cause this).","triggerScenarios":"Running `node scripts/gemini-adapt-agents.js dirA dirB`, or accidentally passing extra unquoted paths / stray words that don't start with '-' so they count as positionals.","commonSituations":"Quoting mistakes turning one path into two arguments, copy-pasting a command with multiple source dirs from docs, or forgetting a flag so its would-be value becomes a second positional.","solutions":["Quote the directory path if it contains spaces: node scripts/gemini-adapt-agents.js \"/path with spaces\".","Pass only one agents directory per run.","Omit the argument to use the default .gemini/agents."],"exampleFix":"// before\n$ node scripts/gemini-adapt-agents.js agents1 agents2\nError: Expected at most one agents directory argument\n// after\n$ node scripts/gemini-adapt-agents.js agents1","handlingStrategy":"validation","validationCode":"const positionals = process.argv.slice(2).filter(a => !a.startsWith('-'));\nif (positionals.length > 1) {\n  console.error('Pass at most one agents directory');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  adaptAgents(process.argv.slice(2));\n} catch (err) {\n  if (/at most one agents directory/.test(err.message)) {\n    console.error('Usage: gemini-adapt-agents.js [agentsDir]');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Quote paths with spaces so they stay a single argument.","Pass one directory or nothing (default ./.gemini/agents).","Check that flags come before any positional and all intended flags are recognized."],"tags":["cli","invalid-cli-argument","too-many-arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}