* 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
})
| 115 | * and its git freshness. |
| 116 | */ |
| 117 | async function resolveCwd(action: { |
| 118 | cwd?: string |
| 119 | repo?: string |
| 120 | }): Promise<{ cwd: string; resolvedRepo?: string }> { |
| 121 | if (action.cwd) { |
| 122 | return { cwd: action.cwd } |
| 123 | } |
| 124 | if (action.repo) { |
| 125 | const known = getKnownPathsForRepo(action.repo) |
| 126 | const existing = await filterExistingPaths(known) |
| 127 | if (existing[0]) { |
| 128 | logForDebugging(`Resolved repo ${action.repo} → ${existing[0]}`) |
| 129 | return { cwd: existing[0], resolvedRepo: action.repo } |
| 130 | } |
| 131 | logForDebugging( |
| 132 | `No local clone found for repo ${action.repo}, falling back to home`, |
| 133 | ) |
| 134 | } |
| 135 | return { cwd: homedir() } |
| 136 | } |
| 137 |
no test coverage detected