MCPcopy Index your code
hub / github.com/codeaashu/claude-code / resolveCwd

Function resolveCwd

src/utils/deepLink/protocolHandler.ts:117–136  ·  view source on GitHub ↗

* 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
})

Source from the content-addressed store, hash-verified

115 * and its git freshness.
116 */
117async 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

Callers 1

handleDeepLinkUriFunction · 0.85

Calls 3

getKnownPathsForRepoFunction · 0.85
filterExistingPathsFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected