codebase-context 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +358 -282
- package/dist/analyzers/angular/index.d.ts.map +1 -1
- package/dist/analyzers/angular/index.js +7 -2
- package/dist/analyzers/angular/index.js.map +1 -1
- package/dist/analyzers/generic/index.d.ts +1 -0
- package/dist/analyzers/generic/index.d.ts.map +1 -1
- package/dist/analyzers/generic/index.js +89 -10
- package/dist/analyzers/generic/index.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +240 -1
- package/dist/cli.js.map +1 -1
- package/dist/constants/codebase-context.d.ts +13 -0
- package/dist/constants/codebase-context.d.ts.map +1 -1
- package/dist/constants/codebase-context.js +13 -0
- package/dist/constants/codebase-context.js.map +1 -1
- package/dist/core/index-meta.d.ts +24 -0
- package/dist/core/index-meta.d.ts.map +1 -0
- package/dist/core/index-meta.js +204 -0
- package/dist/core/index-meta.js.map +1 -0
- package/dist/core/indexer.d.ts.map +1 -1
- package/dist/core/indexer.js +253 -14
- package/dist/core/indexer.js.map +1 -1
- package/dist/core/search.d.ts +1 -0
- package/dist/core/search.d.ts.map +1 -1
- package/dist/core/search.js +60 -5
- package/dist/core/search.js.map +1 -1
- package/dist/core/symbol-references.d.ts +21 -0
- package/dist/core/symbol-references.d.ts.map +1 -0
- package/dist/core/symbol-references.js +91 -0
- package/dist/core/symbol-references.js.map +1 -0
- package/dist/eval/harness.d.ts +5 -0
- package/dist/eval/harness.d.ts.map +1 -0
- package/dist/eval/harness.js +153 -0
- package/dist/eval/harness.js.map +1 -0
- package/dist/eval/types.d.ts +59 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/grammars/manifest.d.ts +26 -0
- package/dist/grammars/manifest.d.ts.map +1 -0
- package/dist/grammars/manifest.js +63 -0
- package/dist/grammars/manifest.js.map +1 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +136 -1298
- package/dist/index.js.map +1 -1
- package/dist/preflight/evidence-lock.d.ts +6 -0
- package/dist/preflight/evidence-lock.d.ts.map +1 -1
- package/dist/preflight/evidence-lock.js +33 -1
- package/dist/preflight/evidence-lock.js.map +1 -1
- package/dist/storage/lancedb.d.ts +9 -1
- package/dist/storage/lancedb.d.ts.map +1 -1
- package/dist/storage/lancedb.js +26 -8
- package/dist/storage/lancedb.js.map +1 -1
- package/dist/tools/detect-circular-dependencies.d.ts +5 -0
- package/dist/tools/detect-circular-dependencies.d.ts.map +1 -0
- package/dist/tools/detect-circular-dependencies.js +117 -0
- package/dist/tools/detect-circular-dependencies.js.map +1 -0
- package/dist/tools/get-codebase-metadata.d.ts +5 -0
- package/dist/tools/get-codebase-metadata.d.ts.map +1 -0
- package/dist/tools/get-codebase-metadata.js +53 -0
- package/dist/tools/get-codebase-metadata.js.map +1 -0
- package/dist/tools/get-component-usage.d.ts +5 -0
- package/dist/tools/get-component-usage.d.ts.map +1 -0
- package/dist/tools/get-component-usage.js +83 -0
- package/dist/tools/get-component-usage.js.map +1 -0
- package/dist/tools/get-indexing-status.d.ts +5 -0
- package/dist/tools/get-indexing-status.d.ts.map +1 -0
- package/dist/tools/get-indexing-status.js +44 -0
- package/dist/tools/get-indexing-status.js.map +1 -0
- package/dist/tools/get-memory.d.ts +5 -0
- package/dist/tools/get-memory.d.ts.map +1 -0
- package/dist/tools/get-memory.js +89 -0
- package/dist/tools/get-memory.js.map +1 -0
- package/dist/tools/get-style-guide.d.ts +5 -0
- package/dist/tools/get-style-guide.d.ts.map +1 -0
- package/dist/tools/get-style-guide.js +151 -0
- package/dist/tools/get-style-guide.js.map +1 -0
- package/dist/tools/get-symbol-references.d.ts +5 -0
- package/dist/tools/get-symbol-references.d.ts.map +1 -0
- package/dist/tools/get-symbol-references.js +70 -0
- package/dist/tools/get-symbol-references.js.map +1 -0
- package/dist/tools/get-team-patterns.d.ts +5 -0
- package/dist/tools/get-team-patterns.d.ts.map +1 -0
- package/dist/tools/get-team-patterns.js +131 -0
- package/dist/tools/get-team-patterns.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +41 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/refresh-index.d.ts +5 -0
- package/dist/tools/refresh-index.d.ts.map +1 -0
- package/dist/tools/refresh-index.js +40 -0
- package/dist/tools/refresh-index.js.map +1 -0
- package/dist/tools/remember.d.ts +5 -0
- package/dist/tools/remember.d.ts.map +1 -0
- package/dist/tools/remember.js +101 -0
- package/dist/tools/remember.js.map +1 -0
- package/dist/tools/search-codebase.d.ts +5 -0
- package/dist/tools/search-codebase.d.ts.map +1 -0
- package/dist/tools/search-codebase.js +638 -0
- package/dist/tools/search-codebase.js.map +1 -0
- package/dist/tools/types.d.ts +31 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/ast-chunker.d.ts +71 -0
- package/dist/utils/ast-chunker.d.ts.map +1 -0
- package/dist/utils/ast-chunker.js +453 -0
- package/dist/utils/ast-chunker.js.map +1 -0
- package/dist/utils/chunking.d.ts.map +1 -1
- package/dist/utils/chunking.js +10 -3
- package/dist/utils/chunking.js.map +1 -1
- package/dist/utils/language-detection.d.ts.map +1 -1
- package/dist/utils/language-detection.js +20 -0
- package/dist/utils/language-detection.js.map +1 -1
- package/dist/utils/tree-sitter.d.ts +17 -0
- package/dist/utils/tree-sitter.d.ts.map +1 -0
- package/dist/utils/tree-sitter.js +311 -0
- package/dist/utils/tree-sitter.js.map +1 -0
- package/docs/capabilities.md +169 -92
- package/grammars/.gitkeep +0 -0
- package/grammars/tree-sitter-c.wasm +0 -0
- package/grammars/tree-sitter-c_sharp.wasm +0 -0
- package/grammars/tree-sitter-cpp.wasm +0 -0
- package/grammars/tree-sitter-go.wasm +0 -0
- package/grammars/tree-sitter-java.wasm +0 -0
- package/grammars/tree-sitter-javascript.wasm +0 -0
- package/grammars/tree-sitter-python.wasm +0 -0
- package/grammars/tree-sitter-rust.wasm +0 -0
- package/grammars/tree-sitter-tsx.wasm +0 -0
- package/grammars/tree-sitter-typescript.wasm +0 -0
- package/package.json +151 -157
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { CodebaseIndexer } from '../core/indexer.js';
|
|
3
|
+
export const definition = {
|
|
4
|
+
name: 'get_codebase_metadata',
|
|
5
|
+
description: 'Get codebase metadata including framework information, dependencies, architecture patterns, ' +
|
|
6
|
+
'and project statistics.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export async function handle(_args, ctx) {
|
|
13
|
+
const indexer = new CodebaseIndexer({ rootPath: ctx.rootPath });
|
|
14
|
+
const metadata = await indexer.detectMetadata();
|
|
15
|
+
// Load team patterns from intelligence file
|
|
16
|
+
let teamPatterns = {};
|
|
17
|
+
try {
|
|
18
|
+
const intelligencePath = ctx.paths.intelligence;
|
|
19
|
+
const intelligenceContent = await fs.readFile(intelligencePath, 'utf-8');
|
|
20
|
+
const intelligence = JSON.parse(intelligenceContent);
|
|
21
|
+
if (intelligence.patterns) {
|
|
22
|
+
teamPatterns = {
|
|
23
|
+
dependencyInjection: intelligence.patterns.dependencyInjection,
|
|
24
|
+
stateManagement: intelligence.patterns.stateManagement,
|
|
25
|
+
componentInputs: intelligence.patterns.componentInputs
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (_error) {
|
|
30
|
+
// No intelligence file or parsing error
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'text',
|
|
36
|
+
text: JSON.stringify({
|
|
37
|
+
status: 'success',
|
|
38
|
+
metadata: {
|
|
39
|
+
name: metadata.name,
|
|
40
|
+
framework: metadata.framework,
|
|
41
|
+
languages: metadata.languages,
|
|
42
|
+
dependencies: metadata.dependencies.slice(0, 20),
|
|
43
|
+
architecture: metadata.architecture,
|
|
44
|
+
projectStructure: metadata.projectStructure,
|
|
45
|
+
statistics: metadata.statistics,
|
|
46
|
+
teamPatterns
|
|
47
|
+
}
|
|
48
|
+
}, null, 2)
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=get-codebase-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-codebase-metadata.js","sourceRoot":"","sources":["../../src/tools/get-codebase-metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,8FAA8F;QAC9F,yBAAyB;IAC3B,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAA8B,EAC9B,GAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;IAEhD,4CAA4C;IAC5C,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAErD,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC1B,YAAY,GAAG;gBACb,mBAAmB,EAAE,YAAY,CAAC,QAAQ,CAAC,mBAAmB;gBAC9D,eAAe,EAAE,YAAY,CAAC,QAAQ,CAAC,eAAe;gBACtD,eAAe,EAAE,YAAY,CAAC,QAAQ,CAAC,eAAe;aACvD,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,wCAAwC;IAC1C,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,MAAM,EAAE,SAAS;oBACjB,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAQ,CAAC,IAAI;wBACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;wBAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;wBAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;wBAChD,YAAY,EAAE,QAAQ,CAAC,YAAY;wBACnC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;wBAC3C,UAAU,EAAE,QAAQ,CAAC,UAAU;wBAC/B,YAAY;qBACb;iBACF,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-component-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-usage.d.ts","sourceRoot":"","sources":["../../src/tools/get-component-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,UAAU,EAAE,IAiBxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAiFvB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
export const definition = {
|
|
3
|
+
name: 'get_component_usage',
|
|
4
|
+
description: 'Find WHERE a library or component is used in the codebase. ' +
|
|
5
|
+
"This is 'Find Usages' - returns all files that import a given package/module. " +
|
|
6
|
+
"Example: get_component_usage('@mycompany/utils') -> shows all files using it.",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
name: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: "Import source to find usages for (e.g., 'primeng/table', '@mycompany/ui/button', 'lodash')"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
required: ['name']
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export async function handle(args, ctx) {
|
|
19
|
+
const { name: componentName } = args;
|
|
20
|
+
try {
|
|
21
|
+
const intelligencePath = ctx.paths.intelligence;
|
|
22
|
+
const content = await fs.readFile(intelligencePath, 'utf-8');
|
|
23
|
+
const intelligence = JSON.parse(content);
|
|
24
|
+
const importGraph = intelligence.importGraph || {};
|
|
25
|
+
const usages = importGraph.usages || {};
|
|
26
|
+
// Find matching usages (exact match or partial match)
|
|
27
|
+
let matchedUsage = usages[componentName];
|
|
28
|
+
// Try partial match if exact match not found
|
|
29
|
+
if (!matchedUsage) {
|
|
30
|
+
const matchingKeys = Object.keys(usages).filter((key) => key.includes(componentName) || componentName.includes(key));
|
|
31
|
+
if (matchingKeys.length > 0) {
|
|
32
|
+
matchedUsage = usages[matchingKeys[0]];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (matchedUsage) {
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: JSON.stringify({
|
|
41
|
+
status: 'success',
|
|
42
|
+
component: componentName,
|
|
43
|
+
usageCount: matchedUsage.usageCount,
|
|
44
|
+
usedIn: matchedUsage.usedIn
|
|
45
|
+
}, null, 2)
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// Show top used as alternatives
|
|
52
|
+
const topUsed = importGraph.topUsed || [];
|
|
53
|
+
return {
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: JSON.stringify({
|
|
58
|
+
status: 'not_found',
|
|
59
|
+
component: componentName,
|
|
60
|
+
message: `No usages found for '${componentName}'.`,
|
|
61
|
+
suggestions: topUsed.slice(0, 10)
|
|
62
|
+
}, null, 2)
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
73
|
+
text: JSON.stringify({
|
|
74
|
+
status: 'error',
|
|
75
|
+
message: 'Failed to get component usage. Run indexing first.',
|
|
76
|
+
error: error instanceof Error ? error.message : String(error)
|
|
77
|
+
}, null, 2)
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=get-component-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-usage.js","sourceRoot":"","sources":["../../src/tools/get-component-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAGpC,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,6DAA6D;QAC7D,gFAAgF;QAChF,+EAA+E;IACjF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,4FAA4F;aAC/F;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA6B,EAC7B,GAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAwB,CAAC;IAEzD,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC;QAExC,sDAAsD;QACtD,IAAI,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;QAEzC,6CAA6C;QAC7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CA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CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC9D,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(_args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-indexing-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-indexing-status.d.ts","sourceRoot":"","sources":["../../src/tools/get-indexing-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,UAAU,EAAE,IASxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const definition = {
|
|
2
|
+
name: 'get_indexing_status',
|
|
3
|
+
description: 'Get current indexing status: state, statistics, and progress. ' +
|
|
4
|
+
'Use refresh_index to manually trigger re-indexing when needed.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export async function handle(_args, ctx) {
|
|
11
|
+
const progress = ctx.indexState.indexer?.getProgress();
|
|
12
|
+
return {
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
type: 'text',
|
|
16
|
+
text: JSON.stringify({
|
|
17
|
+
status: ctx.indexState.status,
|
|
18
|
+
rootPath: ctx.rootPath,
|
|
19
|
+
lastIndexed: ctx.indexState.lastIndexed?.toISOString(),
|
|
20
|
+
stats: ctx.indexState.stats
|
|
21
|
+
? {
|
|
22
|
+
totalFiles: ctx.indexState.stats.totalFiles,
|
|
23
|
+
indexedFiles: ctx.indexState.stats.indexedFiles,
|
|
24
|
+
totalChunks: ctx.indexState.stats.totalChunks,
|
|
25
|
+
duration: `${(ctx.indexState.stats.duration / 1000).toFixed(2)}s`,
|
|
26
|
+
incremental: ctx.indexState.stats.incremental
|
|
27
|
+
}
|
|
28
|
+
: undefined,
|
|
29
|
+
progress: progress
|
|
30
|
+
? {
|
|
31
|
+
phase: progress.phase,
|
|
32
|
+
percentage: progress.percentage,
|
|
33
|
+
filesProcessed: progress.filesProcessed,
|
|
34
|
+
totalFiles: progress.totalFiles
|
|
35
|
+
}
|
|
36
|
+
: undefined,
|
|
37
|
+
error: ctx.indexState.error,
|
|
38
|
+
hint: 'Use refresh_index to manually trigger re-indexing when needed.'
|
|
39
|
+
}, null, 2)
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=get-indexing-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-indexing-status.js","sourceRoot":"","sources":["../../src/tools/get-indexing-status.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,gEAAgE;QAChE,gEAAgE;IAClE,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAA8B,EAC9B,GAAgB;IAEhB,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;IAEvD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,MAAM;oBAC7B,QAAQ,EAAE,GAAG,CAAC,QAAQ;oBACtB,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE;oBACtD,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK;wBACzB,CAAC,CAAC;4BACE,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU;4BAC3C,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY;4BAC/C,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW;4BAC7C,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;4BACjE,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW;yBAC9C;wBACH,CAAC,CAAC,SAAS;oBACb,QAAQ,EAAE,QAAQ;wBAChB,CAAC,CAAC;4BACE,KAAK,EAAE,QAAQ,CAAC,KAAK;4BACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;4BAC/B,cAAc,EAAE,QAAQ,CAAC,cAAc;4BACvC,UAAU,EAAE,QAAQ,CAAC,UAAU;yBAChC;wBACH,CAAC,CAAC,SAAS;oBACb,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK;oBAC3B,IAAI,EAAE,gEAAgE;iBACvE,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-memory.d.ts","sourceRoot":"","sources":["../../src/tools/get-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS5D,eAAO,MAAM,UAAU,EAAE,IAyBxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAkFvB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { readMemoriesFile, filterMemories, applyUnfilteredLimit, withConfidence } from '../memory/store.js';
|
|
2
|
+
export const definition = {
|
|
3
|
+
name: 'get_memory',
|
|
4
|
+
description: 'Retrieves team conventions, architectural decisions, and known gotchas.\n' +
|
|
5
|
+
'CALL BEFORE suggesting patterns, libraries, or architecture.\n\n' +
|
|
6
|
+
'Filters: category (tooling/architecture/testing/dependencies/conventions), type (convention/decision/gotcha), query (keyword search).',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
category: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'Filter by category',
|
|
13
|
+
enum: ['tooling', 'architecture', 'testing', 'dependencies', 'conventions']
|
|
14
|
+
},
|
|
15
|
+
type: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Filter by memory type',
|
|
18
|
+
enum: ['convention', 'decision', 'gotcha', 'failure']
|
|
19
|
+
},
|
|
20
|
+
query: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'Keyword search across memory and reason'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export async function handle(args, ctx) {
|
|
28
|
+
const { category, type, query } = args;
|
|
29
|
+
try {
|
|
30
|
+
const memoryPath = ctx.paths.memory;
|
|
31
|
+
const allMemories = await readMemoriesFile(memoryPath);
|
|
32
|
+
if (allMemories.length === 0) {
|
|
33
|
+
return {
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'text',
|
|
37
|
+
text: JSON.stringify({
|
|
38
|
+
status: 'success',
|
|
39
|
+
message: "No team conventions recorded yet. Use 'remember' to build tribal knowledge or memory when the user corrects you over a repeatable pattern.",
|
|
40
|
+
memories: [],
|
|
41
|
+
count: 0
|
|
42
|
+
}, null, 2)
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const filtered = filterMemories(allMemories, { category, type, query });
|
|
48
|
+
const limited = applyUnfilteredLimit(filtered, { category, type, query }, 20);
|
|
49
|
+
// Enrich with confidence decay
|
|
50
|
+
const enriched = withConfidence(limited.memories);
|
|
51
|
+
const staleCount = enriched.filter((m) => m.stale).length;
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
text: JSON.stringify({
|
|
57
|
+
status: 'success',
|
|
58
|
+
count: enriched.length,
|
|
59
|
+
totalCount: limited.totalCount,
|
|
60
|
+
truncated: limited.truncated,
|
|
61
|
+
...(staleCount > 0 && {
|
|
62
|
+
staleCount,
|
|
63
|
+
staleNote: `${staleCount} memor${staleCount === 1 ? 'y' : 'ies'} below 30% confidence. Consider reviewing or removing.`
|
|
64
|
+
}),
|
|
65
|
+
message: limited.truncated
|
|
66
|
+
? 'Showing 20 most recent. Use filters (category/type/query) for targeted results.'
|
|
67
|
+
: undefined,
|
|
68
|
+
memories: enriched
|
|
69
|
+
}, null, 2)
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: JSON.stringify({
|
|
80
|
+
status: 'error',
|
|
81
|
+
message: 'Failed to retrieve memories.',
|
|
82
|
+
error: error instanceof Error ? error.message : String(error)
|
|
83
|
+
}, null, 2)
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=get-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-memory.js","sourceRoot":"","sources":["../../src/tools/get-memory.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,2EAA2E;QAC3E,kEAAkE;QAClE,uIAAuI;IACzI,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,CAAC;aAC5E;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uBAAuB;gBACpC,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC;aACtD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;aACvD;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA6B,EAC7B,GAAgB;IAEhB,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAIjC,C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AU,SAAS,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,wDAAwD;yBACxH,CAAC;wBACF,OAAO,EAAE,OAAO,CAAC,SAAS;4BACxB,CAAC,CAAC,iFAAiF;4BACnF,CAAC,CAAC,SAAS;wBACb,QAAQ,EAAE,QAAQ;qBACnB,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,MAAM,EAAE,OAAO;wBACf,OAAO,EAAE,8BAA8B;wBACvC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC9D,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-style-guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-style-guide.d.ts","sourceRoot":"","sources":["../../src/tools/get-style-guide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,UAAU,EAAE,IAiBxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CA4JvB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { glob } from 'glob';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
export const definition = {
|
|
5
|
+
name: 'get_style_guide',
|
|
6
|
+
description: 'Query style guide rules and architectural patterns from project documentation.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
query: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'Query for specific style guide rules (e.g., "component naming", "service patterns")'
|
|
13
|
+
},
|
|
14
|
+
category: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'Filter by category (naming, structure, patterns, testing)'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export async function handle(args, ctx) {
|
|
22
|
+
const { query, category } = args;
|
|
23
|
+
const queryStr = typeof query === 'string' ? query.trim() : '';
|
|
24
|
+
const queryLower = queryStr.toLowerCase();
|
|
25
|
+
const queryTerms = queryLower.split(/\s+/).filter(Boolean);
|
|
26
|
+
const categoryLower = typeof category === 'string' ? category.trim().toLowerCase() : '';
|
|
27
|
+
const limitedMode = queryTerms.length === 0;
|
|
28
|
+
const LIMITED_MAX_FILES = 3;
|
|
29
|
+
const LIMITED_MAX_SECTIONS_PER_FILE = 2;
|
|
30
|
+
const styleGuidePatterns = [
|
|
31
|
+
'STYLE_GUIDE.md',
|
|
32
|
+
'CODING_STYLE.md',
|
|
33
|
+
'ARCHITECTURE.md',
|
|
34
|
+
'CONTRIBUTING.md',
|
|
35
|
+
'docs/style-guide.md',
|
|
36
|
+
'docs/coding-style.md',
|
|
37
|
+
'docs/ARCHITECTURE.md'
|
|
38
|
+
];
|
|
39
|
+
const foundGuides = [];
|
|
40
|
+
for (const pattern of styleGuidePatterns) {
|
|
41
|
+
try {
|
|
42
|
+
const files = await glob(pattern, {
|
|
43
|
+
cwd: ctx.rootPath,
|
|
44
|
+
absolute: true
|
|
45
|
+
});
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
// Normalize line endings to \n for consistent output
|
|
49
|
+
const rawContent = await fs.readFile(file, 'utf-8');
|
|
50
|
+
const content = rawContent.replace(/\r\n/g, '\n');
|
|
51
|
+
const relativePath = path.relative(ctx.rootPath, file);
|
|
52
|
+
// Find relevant sections based on query
|
|
53
|
+
const sections = content.split(/^##\s+/m);
|
|
54
|
+
const relevantSections = [];
|
|
55
|
+
if (limitedMode) {
|
|
56
|
+
const headings = (content.match(/^##\s+.+$/gm) || [])
|
|
57
|
+
.map((h) => h.trim())
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.slice(0, LIMITED_MAX_SECTIONS_PER_FILE);
|
|
60
|
+
if (headings.length > 0) {
|
|
61
|
+
relevantSections.push(...headings);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const words = content.split(/\s+/).filter(Boolean);
|
|
65
|
+
if (words.length > 0) {
|
|
66
|
+
relevantSections.push(`Overview: ${words.slice(0, 80).join(' ')}...`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
for (const section of sections) {
|
|
72
|
+
const sectionLower = section.toLowerCase();
|
|
73
|
+
const isRelevant = queryTerms.some((term) => sectionLower.includes(term));
|
|
74
|
+
if (isRelevant) {
|
|
75
|
+
// Limit section size to ~500 words
|
|
76
|
+
const words = section.split(/\s+/);
|
|
77
|
+
const truncated = words.slice(0, 500).join(' ');
|
|
78
|
+
relevantSections.push('## ' + (words.length > 500 ? truncated + '...' : section.trim()));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const categoryMatch = !categoryLower ||
|
|
83
|
+
relativePath.toLowerCase().includes(categoryLower) ||
|
|
84
|
+
relevantSections.some((section) => section.toLowerCase().includes(categoryLower));
|
|
85
|
+
if (!categoryMatch) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (relevantSections.length > 0) {
|
|
89
|
+
foundGuides.push({
|
|
90
|
+
file: relativePath,
|
|
91
|
+
content: content.slice(0, 200) + '...',
|
|
92
|
+
relevantSections: relevantSections.slice(0, limitedMode ? LIMITED_MAX_SECTIONS_PER_FILE : 3)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (_e) {
|
|
97
|
+
// Skip unreadable files
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (_e) {
|
|
102
|
+
// Pattern didn't match, continue
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const results = limitedMode ? foundGuides.slice(0, LIMITED_MAX_FILES) : foundGuides;
|
|
106
|
+
if (results.length === 0) {
|
|
107
|
+
return {
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: 'text',
|
|
111
|
+
text: JSON.stringify({
|
|
112
|
+
status: 'no_results',
|
|
113
|
+
message: limitedMode
|
|
114
|
+
? 'No style guide files found in the default locations.'
|
|
115
|
+
: `No style guide content found matching: ${queryStr}`,
|
|
116
|
+
searchedPatterns: styleGuidePatterns,
|
|
117
|
+
hint: limitedMode
|
|
118
|
+
? "Run get_style_guide with a query or category (e.g. category: 'testing') for targeted results."
|
|
119
|
+
: "Try broader terms like 'naming', 'patterns', 'testing', 'components'"
|
|
120
|
+
}, null, 2)
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
type: 'text',
|
|
129
|
+
text: JSON.stringify({
|
|
130
|
+
status: 'success',
|
|
131
|
+
query: queryStr || undefined,
|
|
132
|
+
category,
|
|
133
|
+
limited: limitedMode,
|
|
134
|
+
notice: limitedMode
|
|
135
|
+
? 'No query provided. Results are capped. Provide query and/or category for targeted guidance.'
|
|
136
|
+
: undefined,
|
|
137
|
+
resultLimits: limitedMode
|
|
138
|
+
? {
|
|
139
|
+
maxFiles: LIMITED_MAX_FILES,
|
|
140
|
+
maxSectionsPerFile: LIMITED_MAX_SECTIONS_PER_FILE
|
|
141
|
+
}
|
|
142
|
+
: undefined,
|
|
143
|
+
results,
|
|
144
|
+
totalFiles: results.length,
|
|
145
|
+
totalMatches: foundGuides.length
|
|
146
|
+
}, null, 2)
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=get-style-guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-style-guide.js","sourceRoot":"","sources":["../../src/tools/get-style-guide.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,gFAAgF;IAC7F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,qFAAqF;aACxF;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2DAA2D;aACzE;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA6B,EAC7B,GAAgB;IAEhB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAG3B,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE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E,CAAC;QACzB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,MAAM,EAAE,YAAY;wBACpB,OAAO,EAAE,WAAW;4BAClB,CAAC,CAAC,sDAAsD;4BACxD,CAAC,CAAC,0CAA0C,QAAQ,EAAE;wBACxD,gBAAgB,EAAE,kBAAkB;wBACpC,IAAI,EAAE,WAAW;4BACf,CAAC,CAAC,+FAA+F;4BACjG,CAAC,CAAC,sEAAsE;qBAC3E,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,QAAQ,IAAI,SAAS;oBAC5B,QAAQ;oBACR,OAAO,EAAE,WAAW;oBACpB,MAAM,EAAE,WAAW;wBACjB,CAAC,CAAC,6FAA6F;wBAC/F,CAAC,CAAC,SAAS;oBACb,YAAY,EAAE,WAAW;wBACvB,CAAC,CAAC;4BACE,QAAQ,EAAE,iBAAiB;4BAC3B,kBAAkB,EAAE,6BAA6B;yBAClD;wBACH,CAAC,CAAC,SAAS;oBACb,OAAO;oBACP,UAAU,EAAE,OAAO,CAAC,MAAM;oBAC1B,YAAY,EAAE,WAAW,CAAC,MAAM;iBACjC,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-symbol-references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-symbol-references.d.ts","sourceRoot":"","sources":["../../src/tools/get-symbol-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,eAAO,MAAM,UAAU,EAAE,IAmBxB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAiEvB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { findSymbolReferences } from '../core/symbol-references.js';
|
|
2
|
+
export const definition = {
|
|
3
|
+
name: 'get_symbol_references',
|
|
4
|
+
description: 'Find concrete references to a symbol in indexed chunks. Returns total usageCount and top usage snippets.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
symbol: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Symbol name to find references for (for example: parseConfig or UserService)'
|
|
11
|
+
},
|
|
12
|
+
limit: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
description: 'Maximum number of usage snippets to return (default: 10)',
|
|
15
|
+
default: 10
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
required: ['symbol']
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export async function handle(args, ctx) {
|
|
22
|
+
const { symbol, limit } = args;
|
|
23
|
+
const normalizedSymbol = typeof symbol === 'string' ? symbol.trim() : '';
|
|
24
|
+
const normalizedLimit = typeof limit === 'number' && Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : 10;
|
|
25
|
+
if (!normalizedSymbol) {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: JSON.stringify({
|
|
31
|
+
status: 'error',
|
|
32
|
+
message: "Invalid params: 'symbol' is required and must be a non-empty string."
|
|
33
|
+
}, null, 2)
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
isError: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const result = await findSymbolReferences(ctx.rootPath, normalizedSymbol, normalizedLimit);
|
|
40
|
+
if (result.status === 'error') {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: JSON.stringify({
|
|
46
|
+
status: 'error',
|
|
47
|
+
symbol: normalizedSymbol,
|
|
48
|
+
message: result.message
|
|
49
|
+
}, null, 2)
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: JSON.stringify({
|
|
59
|
+
status: 'success',
|
|
60
|
+
symbol: result.symbol,
|
|
61
|
+
usageCount: result.usageCount,
|
|
62
|
+
usages: result.usages,
|
|
63
|
+
confidence: result.confidence,
|
|
64
|
+
isComplete: result.isComplete
|
|
65
|
+
}, null, 2)
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=get-symbol-references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-symbol-references.js","sourceRoot":"","sources":["../../src/tools/get-symbol-references.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,0GAA0G;IAC5G,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAA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ACxB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,MAAM,EAAE,SAAS;oBACjB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;iBAC9B,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ToolContext, ToolResponse } from './types.js';
|
|
3
|
+
export declare const definition: Tool;
|
|
4
|
+
export declare function handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResponse>;
|
|
5
|
+
//# sourceMappingURL=get-team-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-team-patterns.d.ts","sourceRoot":"","sources":["../../src/tools/get-team-patterns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO5D,eAAO,MAAM,UAAU,EAAE,IAexB,CAAC;AAEF,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,CAkHvB"}
|