{"record":{"id":"f254cd2789bafef4","repo":"Yeachan-Heo/oh-my-codex","slug":"agent-not-found-normalized","errorCode":null,"errorMessage":"agent not found: ${normalized}","messagePattern":"agent not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/agents.ts","lineNumber":192,"sourceCode":"    throw new Error(`agent already exists: ${path}`);\n  }\n  await mkdir(resolveAgentsDir(scope, cwd), { recursive: true });\n  await writeFile(path, scaffoldAgentToml(normalized));\n  return path;\n}\n\nfunction resolveExistingAgentPath(\n  name: string,\n  options: { cwd?: string; scope?: AgentScope } = {},\n): string {\n  const cwd = options.cwd ?? process.cwd();\n  const normalized = normalizeAgentName(name);\n  const candidateScopes: AgentScope[] = options.scope ? [options.scope] : ['project', 'user'];\n  for (const scope of candidateScopes) {\n    const path = getAgentFilePath(normalized, scope, cwd);\n    if (existsSync(path)) return path;\n  }\n  throw new Error(`agent not found: ${normalized}`);\n}\n\nasync function confirmRemove(path: string): Promise<boolean> {\n  const rl = createInterface({ input: process.stdin, output: process.stdout });\n  try {\n    const answer = (await rl.question(`Delete native agent ${path}? [y/N]: `)).trim().toLowerCase();\n    return answer === 'y' || answer === 'yes';\n  } finally {\n    rl.close();\n  }\n}\n\nfunction ensureInteractiveRemove(force: boolean): void {\n  if (force) return;\n  if (process.stdin.isTTY && process.stdout.isTTY) return;\n  throw new Error('remove requires an interactive terminal; rerun with --force in non-interactive environments');\n}\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/agents.ts#L174-L210","documentation":"remove/edit path resolution: resolveExistingAgentPath checks the candidate scope(s) (project then user, unless --scope narrows it) and throws when no agent file exists for the normalized name. It is the not-found guard before deletion or editing.","triggerScenarios":"`omx agent remove ghost`, editing a typo'd name, or removing with --scope project when the agent only exists in user scope.","commonSituations":"Typos, agent was already removed, wrong --scope narrowing the search, or running from a different directory so project scope resolves elsewhere.","solutions":["List agents to confirm the exact name (e.g. `omx agent list`)","Omit --scope so both scopes are searched","Check you are in the right working directory for project-scoped agents"],"exampleFix":"# before\nomx agent remove reviwer --scope project\n\n# after\nomx agent remove reviewer","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nconst path = getAgentFilePath(name, 'project', cwd);\nif (!existsSync(path) && !existsSync(getAgentFilePath(name, 'user', cwd))) {\n  console.error(`no such agent: ${name}`);\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await removeNativeAgent(name);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('agent not found:')) return; // already gone: treat as success\n  throw e;\n}","preventionTips":["List agents before remove/edit to confirm names","Run from the repo root so project scope resolves correctly","Treat not-found as success in cleanup scripts (idempotent teardown)"],"tags":["cli","agents","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}