MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / discoverHubs

Function discoverHubs

src/core/hub.ts:74–98  ·  view source on GitHub ↗
(rootDir: string)

Source from the content-addressed store, hash-verified

72}
73
74export async function discoverHubs(rootDir: string): Promise<string[]> {
75 const hubs: string[] = [];
76 const skip = new Set(["node_modules", ".git", "build", "dist", ".mcp_data"]);
77
78 async function walk(dir: string): Promise<void> {
79 const entries = await readdir(dir, { withFileTypes: true });
80 for (const entry of entries) {
81 if (skip.has(entry.name)) continue;
82 const full = join(dir, entry.name);
83
84 if (entry.isDirectory()) {
85 await walk(full);
86 } else if (entry.name.endsWith(".md")) {
87 const content = await readFile(full, "utf-8");
88 if (WIKILINK_RE.test(content)) {
89 hubs.push(relative(rootDir, full).replace(/\\/g, "/"));
90 WIKILINK_RE.lastIndex = 0;
91 }
92 }
93 }
94 }
95
96 await walk(rootDir);
97 return hubs.sort();
98}
99
100export async function findOrphanedFiles(
101 rootDir: string,

Callers 4

hub.test.mjsFile · 0.85
findHubByNameFunction · 0.85
getFeatureHubFunction · 0.85
findOrphanedFilesFunction · 0.85

Calls 1

walkFunction · 0.85

Tested by

no test coverage detected