{"record":{"id":"cbc6c41ed96bcfea","repo":"affaan-m/ECC","slug":"expected-a-directory-dirpath","errorCode":null,"errorMessage":"Expected a directory: ${dirPath}","messagePattern":"Expected a directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/gemini-adapt-agents.js","lineNumber":53,"sourceCode":"\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);\n  if (mapped) {\n    return mapped;\n  }\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/gemini-adapt-agents.js#L35-L71","documentation":"Thrown by ensureDirectory() in scripts/gemini-adapt-agents.js when the path exists (passes existsSync) but is not a directory — fs.statSync().isDirectory() returns false. This catches cases where the path points to a file, symlink to a file, or other non-directory filesystem entry.","triggerScenarios":"Passing a path that resolves to a regular file (e.g. `node scripts/gemini-adapt-agents.js .gemini/agents/some-agent.md`) instead of the parent directory, or pointing at a named pipe/socket.","commonSituations":"User passes an individual agent file path instead of the directory, or a stale symlink points to a file. Also common when the default `.gemini/agents` is accidentally a file created by a misconfigured tool.","solutions":["Ensure the path points to a directory, not a file.","If you passed an agent file path, use its parent directory instead.","Check with `ls -la <path>` to confirm it is a directory.","Remove or rename the conflicting file if it was created by mistake."],"exampleFix":"// before\nnode scripts/gemini-adapt-agents.js .gemini/agents/my-agent.md\n// after\nnode scripts/gemini-adapt-agents.js .gemini/agents","handlingStrategy":"validation","validationCode":"const stat = fs.statSync(dirPath);\nif (!stat.isDirectory()) {\n  console.error(`Path is not a directory: ${dirPath}. Use the parent directory, not a file.`);\n  process.exit(1);\n}","typeGuard":"function isDirectory(p) {\n  try { return fs.statSync(p).isDirectory(); } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always pass a directory path, not an individual file path.","Use `ls -ld <path>` to verify the entry is a directory before running.","Avoid passing symlinks unless you have verified they resolve to a directory."],"tags":["filesystem","cli","gemini","type-check"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}