{"record":{"id":"b517d63be0d8cf9b","repo":"coleam00/Archon","slug":"cannot-resolve-run-id-prefix-runid-without-a","errorCode":null,"errorMessage":"Cannot resolve run id prefix '${runId}' without a project directory.","messagePattern":"Cannot resolve run id prefix '(.+?)' without a project directory\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":4069,"sourceCode":" *\n * Full UUIDs skip resolution entirely — exact lookup is global, so full ids\n * keep working from any directory. A caller that already resolved a project can\n * provide its id; otherwise project lookup preserves an exact checkout\n * registration, then falls back to a linked worktree's canonical checkout. By\n * default, an omitted or unregistered cwd and an unmatched prefix pass through\n * unchanged so the downstream exact lookup keeps its existing error surface.\n * Callers without a downstream lookup can require a match instead.\n */\nasync function resolveRunIdArg(\n  runId: string,\n  cwd?: string,\n  requirePrefixMatch = false,\n  codebaseId?: string\n): Promise<string> {\n  if (FULL_RUN_ID_RE.test(runId)) return runId;\n  if (cwd === undefined && codebaseId === undefined) {\n    if (requirePrefixMatch) {\n      throw new Error(`Cannot resolve run id prefix '${runId}' without a project directory.`);\n    }\n    return runId;\n  }\n  const resolvedCodebaseId =\n    codebaseId ?? (cwd === undefined ? undefined : (await findCodebaseForCheckoutPath(cwd))?.id);\n  if (!resolvedCodebaseId) {\n    if (requirePrefixMatch) {\n      throw new Error(`Cannot resolve run id prefix '${runId}' outside a registered project.`);\n    }\n    return runId;\n  }\n  const matches = await workflowDb.findWorkflowRunsByIdPrefix(runId, resolvedCodebaseId);\n  if (matches.length > 1) {\n    const candidates = matches.map(match => `  ${match.id}`).join('\\n');\n    throw new Error(\n      `Run id '${runId}' matches more than one run in this project:\\n${candidates}\\nUse more characters or the full id.`\n    );\n  }","sourceCodeStart":4051,"sourceCodeEnd":4087,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L4051-L4087","documentation":"Run-id prefix resolution needs a project scope to disambiguate short ids. When the caller passed neither a cwd nor a codebaseId, and requirePrefixMatch is set, a non-full run id cannot be resolved and this error is thrown; a full UUID-shaped id is accepted as-is.","triggerScenarios":"Calling a command (e.g. `workflow get <prefix>`, resume/approve) with a short run-id prefix while running outside any project directory and without an explicit codebase context.","commonSituations":"Running the CLI from $HOME or a non-registered checkout; CI jobs that lost the working directory; piping ids from another machine's workspace.","solutions":["cd into the registered project checkout before running the command.","Use the full run id (matching FULL_RUN_ID_RE) so no project scope is needed.","Register the current directory with `archon project register` so cwd resolves to a codebase."],"exampleFix":"// before\narchon workflow get ab12   # run from ~/\n// after\ncd ~/projects/my-app && archon workflow get ab12","handlingStrategy":"validation","validationCode":"const isFullId = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id); if (!isFullId && !process.cwd().startsWith(registeredRoot)) throw new Error('cd into the project or pass the full run id');","typeGuard":"function isFullRunId(s: string): boolean { return /^[0-9a-f-]{36}$/i.test(s); }","tryCatchPattern":"try { await getRun(prefix); } catch (e) { if (String(e.message).includes('without a project directory')) await getRun(await expandToFullId(prefix)); }","preventionTips":["Always run Archon commands from the registered project checkout.","Prefer full run ids in scripts and CI; reserve prefixes for interactive use.","Resolve the codebase explicitly (codebaseId) when invoking helpers programmatically."],"tags":["cli","workflow","id-resolution"],"backgroundTag":"missing-project-context","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}