affaan-m/ECC · error · Error

Agents directory not found

Error message

Agents directory not found: ${dirPath}

What it means

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.

Solutions

  1. Create the directory or run the step that copies agents into .gemini/agents first.
  2. Verify the path passed as the positional argument is correct and spelled right.
  3. Check cwd — the default is relative to the current working directory.

Example fix

// before
$ node scripts/gemini-adapt-agents.js ./nonexistent
Error: Agents directory not found: ./nonexistent
// after
$ mkdir -p .gemini/agents && node scripts/gemini-adapt-agents.js
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const dir = process.argv[2] || '.gemini/agents';
if (!fs.existsSync(dir)) {
  console.error(`Create it first: mkdir -p ${dir}`);
  process.exit(1);
}

Type guard

const isExistingDirectory = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();

Try / catch

try {
  adaptAgents(argv);
} catch (err) {
  if (/^Agents directory not found:/.test(err.message)) {
    console.error(`${err.message}\nRun: mkdir -p ${dir}`);
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/fcb21c127839f998. Report an issue: GitHub.

Appendix: source

Thrown at scripts/gemini-adapt-agents.js:49

function parseArgs(argv) {
  if (argv.includes('--help') || argv.includes('-h')) {
    return { help: true };
  }

  const positional = argv.filter(arg => !arg.startsWith('-'));
  if (positional.length > 1) {
    throw new Error('Expected at most one agents directory argument');
  }

  return {
    help: false,
    agentsDir: path.resolve(positional[0] || path.join(process.cwd(), '.gemini', 'agents')),
  };
}

function ensureDirectory(dirPath) {
  if (!fs.existsSync(dirPath)) {
    throw new Error(`Agents directory not found: ${dirPath}`);
  }

  if (!fs.statSync(dirPath).isDirectory()) {
    throw new Error(`Expected a directory: ${dirPath}`);
  }
}

function parseToolList(line) {
  const match = line.match(/^\s*tools\s*:\s*(.*)$/);
  if (!match) {
    return null;
  }

  return normalizeAgentTools(match[1]);
}

function adaptToolName(toolName) {
  const mapped = TOOL_NAME_MAP.get(toolName);

View on GitHub (pinned to 8321021c54)