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

Function getFileSkeleton

src/tools/file-skeleton.ts:36–59  ·  view source on GitHub ↗
(options: SkeletonOptions)

Source from the content-addressed store, hash-verified

34}
35
36export async function getFileSkeleton(options: SkeletonOptions): Promise<string> {
37 const fullPath = resolve(options.rootDir, options.filePath);
38
39 if (!isSupportedFile(fullPath)) {
40 const content = await readFile(fullPath, "utf-8");
41 const preview = content.split("\n").slice(0, 20).join("\n");
42 return `[Unsupported language, showing first 20 lines]\n\n${preview}`;
43 }
44
45 const analysis = await analyzeFile(fullPath);
46
47 if (analysis.symbols.length === 0) {
48 const content = await readFile(fullPath, "utf-8");
49 const preview = content.split("\n").slice(0, 30).join("\n");
50 return `[No symbols detected, showing first 30 lines]\n\n${preview}`;
51 }
52
53 return [
54 `File: ${options.filePath} (${analysis.lineCount} lines)`,
55 `Symbols: ${analysis.symbols.length} top-level definitions`,
56 "",
57 formatSignatureBlock(analysis),
58 ].join("\n");
59}

Callers 3

index.tsFile · 0.85
getFeatureHubFunction · 0.85

Calls 3

isSupportedFileFunction · 0.85
analyzeFileFunction · 0.85
formatSignatureBlockFunction · 0.85

Tested by

no test coverage detected