{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/gemini-adapt-agents.js#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnode scripts/gemini-adapt-agents.js ./input ./output\n// after\nnode scripts/gemini-adapt-agents.js ./input","handlingStrategy":"validation","validationCode":"const positional = argv.filter(a => !a.startsWith('-'));\nif (positional.length > 1) {\n  console.error(`Expected at most one directory argument, got ${positional.length}: ${positional.join(', ')}`);\n  process.exit(1);\n}","typeGuard":"function hasAtMostOnePositional(argv) {\n  return argv.filter(a => !a.startsWith('-')).length <= 1;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","argument-parsing","gemini","user-input"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}