{"record":{"id":"fcb21c127839f998","repo":"affaan-m/ECC","slug":"agents-directory-not-found-dirpath","errorCode":null,"errorMessage":"Agents directory not found: ${dirPath}","messagePattern":"Agents directory not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/gemini-adapt-agents.js","lineNumber":49,"sourceCode":"function 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\nfunction parseToolList(line) {\n  const match = line.match(/^\\s*tools\\s*:\\s*(.*)$/);\n  if (!match) {\n    return null;\n  }\n\n  return normalizeAgentTools(match[1]);\n}\n\nfunction adaptToolName(toolName) {\n  const mapped = TOOL_NAME_MAP.get(toolName);","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/gemini-adapt-agents.js#L31-L67","documentation":"ensureDirectory throws when the resolved agents directory (default .gemini/agents under cwd, or the positional argument) does not exist on disk. The faulting input is dirPath; the adaptation step needs existing agent files to rewrite.","triggerScenarios":"Passing an --agents-dir/positional path that was never created, running from the wrong working directory so the default `.gemini/agents` doesn't exist there, or a typo'd path.","commonSituations":"Fresh clones that don't include .gemini/agents, running the script in a repo that hasn't been initialized for Gemini, path typos, or case-sensitivity mismatches on Linux.","solutions":["Create the directory or run the step that copies agents into .gemini/agents first.","Verify the path passed as the positional argument is correct and spelled right.","Check cwd — the default is relative to the current working directory."],"exampleFix":"// before\n$ node scripts/gemini-adapt-agents.js ./nonexistent\nError: Agents directory not found: ./nonexistent\n// after\n$ mkdir -p .gemini/agents && node scripts/gemini-adapt-agents.js","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst dir = process.argv[2] || '.gemini/agents';\nif (!fs.existsSync(dir)) {\n  console.error(`Create it first: mkdir -p ${dir}`);\n  process.exit(1);\n}","typeGuard":"const isExistingDirectory = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();","tryCatchPattern":"try {\n  adaptAgents(argv);\n} catch (err) {\n  if (/^Agents directory not found:/.test(err.message)) {\n    console.error(`${err.message}\\nRun: mkdir -p ${dir}`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Run `mkdir -p .gemini/agents` before invoking the script in a fresh repo.","Execute the script from the repository root.","Verify the path with `ls -d <dir>` first, watching for case-sensitivity.","Initialize Gemini config via the ECC installer rather than hand-rolling paths."],"tags":["cli","file-not-found","directory"],"backgroundTag":"directory-not-found","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"}