MCPcopy
hub / github.com/continuedev/continue / resolveInputPath

Function resolveInputPath

core/util/pathResolver.ts:31–84  ·  view source on GitHub ↗
(
  ide: IDE,
  inputPath: string,
)

Source from the content-addressed store, hash-verified

29}
30
31export async function resolveInputPath(
32 ide: IDE,
33 inputPath: string,
34): Promise<ResolvedPath | null> {
35 const trimmedPath = inputPath.trim();
36
37 // Handle file:// URIs
38 if (trimmedPath.startsWith("file://")) {
39 const displayPath = fileURLToPath(trimmedPath);
40 const isWithinWorkspace = await isUriWithinWorkspace(ide, trimmedPath);
41 return {
42 uri: trimmedPath,
43 displayPath,
44 isAbsolute: true,
45 isWithinWorkspace,
46 };
47 }
48
49 // Expand tilde paths (handles ~/ and ~username/)
50 const expandedPath = untildify(trimmedPath);
51
52 // Check if it's an absolute path (including Windows paths)
53 const isAbsolute =
54 path.isAbsolute(expandedPath) ||
55 // Windows network paths
56 expandedPath.startsWith("\\\\") ||
57 // Windows drive letters
58 /^[a-zA-Z]:/.test(expandedPath);
59
60 if (isAbsolute) {
61 // Convert to file:// URI format
62 const uri = pathToFileURL(expandedPath).href;
63 const isWithinWorkspace = await isUriWithinWorkspace(ide, uri);
64 return {
65 uri,
66 displayPath: expandedPath,
67 isAbsolute: true,
68 isWithinWorkspace,
69 };
70 }
71
72 // Handle relative paths...
73 const workspaceUri = await resolveRelativePathInDir(expandedPath, ide);
74 if (workspaceUri) {
75 return {
76 uri: workspaceUri,
77 displayPath: expandedPath,
78 isAbsolute: false,
79 isWithinWorkspace: true,
80 };
81 }
82
83 return null;
84}

Callers 9

lsToolImplFunction · 0.90
viewSubdirectoryImplFunction · 0.90
readFileRangeImplFunction · 0.90
readFileImplFunction · 0.90
ls.tsFile · 0.90
createNewFile.tsFile · 0.90
readFileRange.tsFile · 0.90
readFile.tsFile · 0.90

Calls 3

resolveRelativePathInDirFunction · 0.90
isUriWithinWorkspaceFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected