* Resolve the working directory for the launched Claude instance. * Precedence: explicit cwd > repo lookup (MRU clone) > home. * A repo that isn't cloned locally is not an error — fall through to home * so a web link referencing a repo the user doesn't have still opens Claude. * * Returns the r
(action: {
cwd?: string
repo?: string
})
| 116 | * and its git freshness. |
| 117 | */ |
| 118 | async function resolveCwd(action: { |
| 119 | cwd?: string |
| 120 | repo?: string |
| 121 | }): Promise<{ cwd: string; resolvedRepo?: string }> { |
| 122 | if (action.cwd) { |
| 123 | return { cwd: action.cwd } |
| 124 | } |
| 125 | if (action.repo) { |
| 126 | const known = getKnownPathsForRepo(action.repo) |
| 127 | const existing = await filterExistingPaths(known) |
| 128 | if (existing[0]) { |
| 129 | logForDebugging(`Resolved repo ${action.repo} → ${existing[0]}`) |
| 130 | return { cwd: existing[0], resolvedRepo: action.repo } |
| 131 | } |
| 132 | logForDebugging( |
| 133 | `No local clone found for repo ${action.repo}, falling back to home`, |
| 134 | ) |
| 135 | } |
| 136 | return { cwd: homedir() } |
| 137 | } |
no test coverage detected