MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / handle

Function handle

src/tools/get-team-patterns.ts:45–196  ·  view source on GitHub ↗
(
  args: Record<string, unknown>,
  ctx: ToolContext
)

Source from the content-addressed store, hash-verified

43};
44
45export async function handle(
46 args: Record<string, unknown>,
47 ctx: ToolContext
48): Promise<ToolResponse> {
49 const { category } = args as { category?: string };
50
51 try {
52 const intelligencePath = ctx.paths.intelligence;
53 const content = await fs.readFile(intelligencePath, 'utf-8');
54 const intelligence = JSON.parse(content) as unknown;
55 if (typeof intelligence !== 'object' || intelligence === null) {
56 throw new Error('Invalid intelligence.json: expected an object');
57 }
58 const intel = intelligence as IntelligenceData;
59
60 const result: Record<string, unknown> = { status: 'success' };
61
62 if (category === 'all' || !category) {
63 const rawPatterns = intel.patterns || {};
64 const filtered: Record<string, unknown> = {};
65 for (const [k, v] of Object.entries(rawPatterns)) {
66 if (shouldSkipLegacyTestingFrameworkCategory(k, rawPatterns)) continue;
67 filtered[k] = v;
68 }
69 result.patterns = filtered;
70 result.goldenFiles = intel.goldenFiles || [];
71 if (intel.tsconfigPaths) {
72 result.tsconfigPaths = intel.tsconfigPaths;
73 }
74 } else if (category === 'di') {
75 result.patterns = {};
76 if (intel.patterns?.dependencyInjection)
77 (result.patterns as Record<string, unknown>).dependencyInjection =
78 intel.patterns.dependencyInjection;
79 result.goldenFiles = filterGoldenFilesByCategory(intel.goldenFiles, ['dependencyInjection:']);
80 } else if (category === 'state') {
81 result.patterns = {};
82 if (intel.patterns?.stateManagement)
83 (result.patterns as Record<string, unknown>).stateManagement =
84 intel.patterns.stateManagement;
85 result.goldenFiles = filterGoldenFilesByCategory(intel.goldenFiles, ['stateManagement:']);
86 } else if (category === 'testing') {
87 result.patterns = {};
88 for (const k of [
89 'unitTestFramework',
90 'e2eFramework',
91 'testingFramework',
92 'testMocking'
93 ] as const) {
94 if (intel.patterns?.[k])
95 (result.patterns as Record<string, unknown>)[k] = intel.patterns[k];
96 }
97 result.goldenFiles = filterGoldenFilesByCategory(intel.goldenFiles, [
98 'unitTestFramework:',
99 'e2eFramework:',
100 'testingFramework:'
101 ]);
102 } else if (category === 'libraries') {

Callers

nothing calls this directly

Tested by

no test coverage detected