MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / resolveCwd

Function resolveCwd

src/utils/deepLink/protocolHandler.ts:118–137  ·  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

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

Callers 1

handleDeepLinkUriFunction · 0.85

Calls 3

getKnownPathsForRepoFunction · 0.85
filterExistingPathsFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected