{"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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/gemini-adapt-agents.js#L31-L67","documentation":"Thrown by ensureDirectory() in scripts/gemini-adapt-agents.js when the resolved agents directory path does not exist on the filesystem (fs.existsSync returns false). This is a preflight check before the script attempts to read and rewrite agent files in that directory.","triggerScenarios":"Running the script with a directory path that does not exist, or running without arguments in a project that has not yet created the `.gemini/agents` directory.","commonSituations":"First-time use of the Gemini adapter before the `.gemini/agents` directory has been scaffolded, passing a typo'd path, or running from the wrong working directory so the default relative path resolves to a non-existent location.","solutions":["Create the directory first: `mkdir -p .gemini/agents` and populate it with agent files.","Verify the path you passed exists: `ls <path>`.","Run the script from the project root where `.gemini/agents` is expected.","If migrating from another harness, copy agent files into the directory first."],"exampleFix":"// before\nnode scripts/gemini-adapt-agents.js ./wrong-path\n// after\nmkdir -p .gemini/agents && node scripts/gemini-adapt-agents.js .gemini/agents","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst target = path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents'));\nif (!fs.existsSync(target)) {\n  console.error(`Creating agents directory: ${target}`);\n  fs.mkdirSync(target, { recursive: true });\n}","typeGuard":"function directoryExists(p) {\n  try { return fs.statSync(p).isDirectory(); } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Run `mkdir -p .gemini/agents` before invoking the script.","Verify the working directory is correct before relying on defaults.","In CI, add a pre-step that scaffolds the expected directory."],"tags":["filesystem","cli","gemini","preflight-check"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}