-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathget-codebase-metadata.ts
More file actions
66 lines (61 loc) · 1.9 KB
/
get-codebase-metadata.ts
File metadata and controls
66 lines (61 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
import { promises as fs } from 'fs';
import type { ToolContext, ToolResponse } from './types.js';
import { CodebaseIndexer } from '../core/indexer.js';
export const definition: Tool = {
name: 'get_codebase_metadata',
description:
'Get codebase metadata including framework information, dependencies, architecture patterns, ' +
'and project statistics.',
inputSchema: {
type: 'object',
properties: {}
}
};
export async function handle(
_args: Record<string, unknown>,
ctx: ToolContext
): Promise<ToolResponse> {
const indexer = new CodebaseIndexer({ rootPath: ctx.rootPath });
const metadata = await indexer.detectMetadata();
// Load team patterns from intelligence file
let teamPatterns = {};
try {
const intelligencePath = ctx.paths.intelligence;
const intelligenceContent = await fs.readFile(intelligencePath, 'utf-8');
const intelligence = JSON.parse(intelligenceContent);
if (intelligence.patterns) {
teamPatterns = {
dependencyInjection: intelligence.patterns.dependencyInjection,
stateManagement: intelligence.patterns.stateManagement,
componentInputs: intelligence.patterns.componentInputs
};
}
} catch (_error) {
// No intelligence file or parsing error
}
return {
content: [
{
type: 'text',
text: JSON.stringify(
{
status: 'success',
metadata: {
name: metadata.name,
framework: metadata.framework,
languages: metadata.languages,
dependencies: metadata.dependencies.slice(0, 20),
architecture: metadata.architecture,
projectStructure: metadata.projectStructure,
statistics: metadata.statistics,
teamPatterns
}
},
null,
2
)
}
]
};
}