affaan-m/ECC · error · Error

Expected at most one agents directory argument

Error message

Expected at most one agents directory argument

What it means

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.

Source

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

  return [
    'Adapt ECC agent frontmatter for Gemini CLI.',
    '',
    'Usage:',
    '  node scripts/gemini-adapt-agents.js [agents-dir]',
    '',
    'Defaults to .gemini/agents under the current working directory.',
    'Rewrites tools: to Gemini-compatible tool names and removes unsupported color: metadata.'
  ].join('\n');
}

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}`);
  }
}

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Provide only one directory path: `node scripts/gemini-adapt-agents.js [single-dir]`.
  2. Quote paths containing spaces: `node scripts/gemini-adapt-agents.js "my agents"`.
  3. Omit the directory entirely to use the default `.gemini/agents`.
  4. Run with --help to see expected usage.

Example fix

// before
node scripts/gemini-adapt-agents.js ./input ./output
// after
node scripts/gemini-adapt-agents.js ./input
Defensive patterns

Strategy: validation

Validate before calling

const positional = argv.filter(a => !a.startsWith('-'));
if (positional.length > 1) {
  console.error(`Expected at most one directory argument, got ${positional.length}: ${positional.join(', ')}`);
  process.exit(1);
}

Type guard

function hasAtMostOnePositional(argv) {
  return argv.filter(a => !a.startsWith('-')).length <= 1;
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/0074840e052928d3. Report an issue: GitHub.