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

Function resolveCwd

source code/utils/deepLink/protocolHandler.ts:119–138  ·  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

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

Callers 1

handleDeepLinkUriFunction · 0.85

Calls 3

getKnownPathsForRepoFunction · 0.85
filterExistingPathsFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected