{"record":{"id":"8af5f4996fc59b7d","repo":"Yeachan-Heo/oh-my-codex","slug":"expected-scope-user-project","errorCode":null,"errorMessage":"Expected --scope user|project","messagePattern":"Expected --scope user\\|project","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/agents.ts","lineNumber":66,"sourceCode":"    throw new Error(`invalid agent name: ${name}`);\n  }\n  if (isReservedNativeAgentName(trimmed)) {\n    throw new Error(`\"${trimmed}\" is reserved by Codex built-in agents`);\n  }\n  return trimmed;\n}\n\nfunction resolveAgentsDir(scope: AgentScope, cwd = process.cwd()): string {\n  return scope === 'project' ? projectCodexAgentsDir(cwd) : codexAgentsDir();\n}\n\nfunction parseScopeArg(args: string[]): AgentScope | undefined {\n  for (let i = 0; i < args.length; i += 1) {\n    const arg = args[i];\n    if (arg === '--scope') {\n      const value = args[i + 1];\n      if (value === 'user' || value === 'project') return value;\n      throw new Error('Expected --scope user|project');\n    }\n    if (arg === '--scope=user') return 'user';\n    if (arg === '--scope=project') return 'project';\n  }\n  return undefined;\n}\n\nfunction inferMutationScope(cwd = process.cwd()): AgentScope {\n  const persistedScopePath = join(cwd, '.omx', 'setup-scope.json');\n  if (existsSync(persistedScopePath)) {\n    try {\n      const parsed = JSON.parse(readFileSync(persistedScopePath, 'utf8')) as { scope?: string };\n      if (parsed.scope === 'project' || parsed.scope === 'project-local') return 'project';\n      if (parsed.scope === 'user') return 'user';\n    } catch {\n      // fall through\n    }\n  }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/agents.ts#L48-L84","documentation":"The --scope flag was given as two arguments (`--scope <value>`) but the following value is neither 'user' nor 'project'. The one-argument forms --scope=user/--scope=project are validated by exact match, so this error specifically indicates `--scope foo`, `--scope` at end of args, or `--scope` followed by another flag.","triggerScenarios":"`omx agent add x --scope team`, `omx agent add x --scope` (missing value), or `--scope --force` where the next token is consumed as the value.","commonSituations":"Missing value after --scope, expecting other scopes (org/team), or flag ordering that lets another flag be eaten as the scope value.","solutions":["Use `--scope user` or `--scope project` (or `--scope=user`)","Ensure a value follows --scope and is not another flag","Omit --scope entirely to use the inferred default"],"exampleFix":"# before\nomx agent add x --scope --force\n\n# after\nomx agent add x --scope project --force","handlingStrategy":"validation","validationCode":"const i = args.indexOf('--scope');\nif (i !== -1 && !['user', 'project', '--scope=user', '--scope=project'].some(v => args.includes(v))) {\n  const v = args[i + 1];\n  if (v !== 'user' && v !== 'project') { console.error('scope must be user|project'); process.exit(2); }\n}","typeGuard":"const isScopeValue = (v: unknown): v is 'user' | 'project' => v === 'user' || v === 'project';","tryCatchPattern":null,"preventionTips":["Prefer the --scope=value form to avoid value-consumption ambiguity","Always pair --scope with an explicit value"],"tags":["cli","agents","flag-validation","scope"],"backgroundTag":"invalid-flag-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}