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

Class RegistryClient

packages/config-yaml/src/registryClient.ts:10–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10export class RegistryClient implements Registry {
11 private readonly rootPath?: string;
12
13 constructor(options: RegistryClientOptions = {}) {
14 this.rootPath = options.rootPath;
15 }
16
17 async getContent(id: PackageIdentifier): Promise<string> {
18 // Return pre-read content if available (for vscode-remote:// URIs in WSL)
19 if (id.uriType === "file" && id.content !== undefined) {
20 return id.content;
21 }
22
23 switch (id.uriType) {
24 case "file":
25 return this.getContentFromFilePath(id.fileUri);
26 case "slug":
27 throw new Error("Slug-based package resolution is not supported");
28 default:
29 throw new Error(
30 `Unknown package identifier type: ${(id as any).uriType}`,
31 );
32 }
33 }
34
35 private getContentFromFilePath(filepath: string): string {
36 if (filepath.startsWith("file://")) {
37 // For Windows file:///C:/path/to/file, we need to handle it properly
38 // On other systems, we might have file:///path/to/file
39 return fs.readFileSync(new URL(filepath), "utf8");
40 } else if (path.isAbsolute(filepath)) {
41 return fs.readFileSync(filepath, "utf8");
42 } else {
43 // Try to resolve relative to current working directory first
44 const resolvedPath = path.resolve(filepath);
45 if (fs.existsSync(resolvedPath)) {
46 return fs.readFileSync(resolvedPath, "utf8");
47 }
48 // Fall back to rootPath if file doesn't exist relative to cwd
49 if (this.rootPath) {
50 return fs.readFileSync(path.join(this.rootPath, filepath), "utf8");
51 }
52 throw new Error("No rootPath provided for relative file path");
53 }
54 }
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected