Yeachan-Heo/oh-my-codex · error · Error

mission-dir does not exist

Error message

mission-dir does not exist: ${missionDir}

What it means

loadAutoresearchMissionContract resolves the mission-dir argument and immediately throws if existsSync fails — the directory must already exist on disk before the contract can be loaded. The resolved absolute path is included in the message.

Solutions

  1. Check the path for typos and pass the correct absolute path.
  2. If using a relative path, confirm the process cwd or resolve it yourself before calling.
  3. Create/clone the mission directory (and commit it) if it should exist; verify in CI checkout steps.

Example fix

// before
const contract = await loadAutoresearchMissionContract('missions/m1-typo');

// after
const missionDir = resolve('missions/m1');
if (!existsSync(missionDir)) throw new Error(`setup missing: ${missionDir}`);
const contract = await loadAutoresearchMissionContract(missionDir);
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
import { resolve } from 'node:path';

const missionDir = resolve(missionDirArg);
if (!existsSync(missionDir)) {
  throw new Error(`Mission dir missing: ${missionDir} — create or fix the path`);
}
const contract = await loadAutoresearchMissionContract(missionDir);

Try / catch

try {
  await loadAutoresearchMissionContract(dir);
} catch (err) {
  if ((err as Error).message.includes('mission-dir does not exist')) {
    // prompt the user for the correct path or create/clone the mission
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing a relative or absolute mission-dir path that does not exist: typos, wrong working directory for relative paths, or the directory not yet created/synced.

Common situations: CLI --mission-dir typos; running from a different cwd so a relative path resolves elsewhere; directories not yet mounted in containers or not checked out in CI.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/f6054e1bf091ceaf. Report an issue: GitHub.

Appendix: source

Thrown at src/autoresearch/contracts.ts:215

  const result = parsed as Record<string, unknown>;
  if (typeof result.pass !== 'boolean') {
    throw contractError('Evaluator output must include boolean pass.');
  }
  if (result.score !== undefined && typeof result.score !== 'number') {
    throw contractError('Evaluator output score must be numeric when provided.');
  }

  return {
    pass: result.pass,
    ...(result.score === undefined ? {} : { score: result.score }),
  };
}

export async function loadAutoresearchMissionContract(missionDirArg: string): Promise<AutoresearchMissionContract> {
  const missionDir = resolve(missionDirArg);
  if (!existsSync(missionDir)) {
    throw contractError(`mission-dir does not exist: ${missionDir}`);
  }

  const repoRoot = readGit(missionDir, ['rev-parse', '--show-toplevel']);
  ensurePathInside(repoRoot, missionDir);

  const missionFile = join(missionDir, 'mission.md');
  const sandboxFile = join(missionDir, 'sandbox.md');
  if (!existsSync(missionFile)) {
    throw contractError(`mission.md is required inside mission-dir: ${missionFile}`);
  }
  if (!existsSync(sandboxFile)) {
    throw contractError(`sandbox.md is required inside mission-dir: ${sandboxFile}`);
  }

  const missionContent = await readFile(missionFile, 'utf-8');
  const sandboxContent = await readFile(sandboxFile, 'utf-8');
  const sandbox = parseSandboxContract(sandboxContent);
  const missionRelativeDir = relative(repoRoot, missionDir) || basename(missionDir);

View on GitHub (pinned to 3ad79a8a6f)