{"record":{"id":"82ffcc302893b22f","repo":"Yeachan-Heo/oh-my-codex","slug":"agents-init-target-not-found-requestedtarget","errorCode":null,"errorMessage":"agents-init target not found: ${requestedTarget}","messagePattern":"agents-init target not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/agents-init.ts","lineNumber":298,"sourceCode":"  options: AgentsInitOptions = {},\n): Promise<void> {\n  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  );","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/agents-init.ts#L280-L316","documentation":"After confirming the agents-init target stays inside cwd, the code stats the resolved directory; if stat fails (ENOENT etc.) the target does not exist and this error is thrown. The target must exist beforehand — agents-init does not create the target directory.","triggerScenarios":"Passing --target subdir where subdir does not exist, or a typo'd path.","commonSituations":"Assuming agents-init mkdirs the target, stale scripts referencing deleted directories, or relative paths resolved against an unexpected cwd.","solutions":["Create the directory first: mkdir -p <target>","Check for typos in the path argument","Verify you are running from the expected working directory"],"exampleFix":"# before\nomx agents-init --target packages/new\n\n# after\nmkdir -p packages/new && omx agents-init --target packages/new","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs';\nif (!statSync(targetDir, { throwIfNoEntry: false })) {\n  console.error(`target does not exist: ${targetDir}`);\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["mkdir -p the target directory before scaffolding","Verify cwd before running so relative targets resolve as expected"],"tags":["cli","path-validation","not-found","agents-init"],"backgroundTag":"path-not-found","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}