{"record":{"id":"cbcdc6c32781359f","repo":"Yeachan-Heo/oh-my-codex","slug":"agents-init-target-must-be-a-directory-requeste","errorCode":null,"errorMessage":"agents-init target must be a directory: ${requestedTarget}","messagePattern":"agents-init target must be a directory: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/agents-init.ts","lineNumber":300,"sourceCode":"  const dryRun = options.dryRun === true;\n  const force = options.force === true;\n  const verbose = options.verbose === true;\n  const cwd = process.cwd();\n  const requestedTarget = options.targetPath ?? \".\";\n  const targetDir = resolve(cwd, requestedTarget);\n  const relativeTarget = relative(cwd, targetDir);\n\n  if (relativeTarget.startsWith(\"..\")) {\n    throw new Error(\n      `agents-init target must stay inside the current working directory: ${requestedTarget}`,\n    );\n  }\n\n  const targetStat = await stat(targetDir).catch(() => null);\n  if (!targetStat)\n    throw new Error(`agents-init target not found: ${requestedTarget}`);\n  if (!targetStat.isDirectory())\n    throw new Error(\n      `agents-init target must be a directory: ${requestedTarget}`,\n    );\n\n  const summary = createEmptySummary();\n  const plannedDirs = await resolveTargetDirectories(targetDir);\n  const backupRoot = join(\n    cwd,\n    \".omx\",\n    \"backups\",\n    \"agents-init\",\n    new Date().toISOString().replaceAll(\":\", \"-\"),\n  );\n  const activeSession = await readSessionState(cwd);\n  const rootSessionGuardActive = Boolean(\n    activeSession && !isSessionStale(activeSession),\n  );\n\n  console.log(\"oh-my-codex AGENTS bootstrap\");","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/agents-init.ts#L282-L318","documentation":"The agents-init target exists but stat reports it is not a directory (a regular file, symlink to file, etc.). Scaffolding agent config requires a directory to create subdirectories and files into.","triggerScenarios":"Passing --target pointing at a file like README.md or a symlink that resolves to a file.","commonSituations":"Reusing a path that was a directory but is now a file, or pointing at a config filename instead of its parent directory.","solutions":["Point --target at a directory, not a file","If the path should be a directory, remove the conflicting file or rename it"],"exampleFix":"# before\nomx agents-init --target AGENTS.md\n\n# after\nomx agents-init --target .","handlingStrategy":"type-guard","validationCode":"const st = statSync(targetDir, { throwIfNoEntry: false });\nif (st && !st.isDirectory()) {\n  console.error(`target is not a directory: ${targetDir}`);\n  process.exit(2);\n}","typeGuard":"const isDirectory = (p: string): boolean => {\n  const s = statSync(p, { throwIfNoEntry: false });\n  return s?.isDirectory() ?? false;\n};","tryCatchPattern":null,"preventionTips":["Point --target at directories, never at files","Check for name collisions between intended directories and existing files"],"tags":["cli","path-validation","not-a-directory","agents-init"],"backgroundTag":"not-a-directory","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}