aidex-mcp 1.4.1
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/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/MCP-API-REFERENCE.md +690 -0
- package/README.md +314 -0
- package/build/commands/files.d.ts +28 -0
- package/build/commands/files.js +124 -0
- package/build/commands/index.d.ts +14 -0
- package/build/commands/index.js +14 -0
- package/build/commands/init.d.ts +24 -0
- package/build/commands/init.js +396 -0
- package/build/commands/link.d.ts +45 -0
- package/build/commands/link.js +167 -0
- package/build/commands/note.d.ts +29 -0
- package/build/commands/note.js +105 -0
- package/build/commands/query.d.ts +36 -0
- package/build/commands/query.js +176 -0
- package/build/commands/scan.d.ts +25 -0
- package/build/commands/scan.js +104 -0
- package/build/commands/session.d.ts +52 -0
- package/build/commands/session.js +216 -0
- package/build/commands/signature.d.ts +52 -0
- package/build/commands/signature.js +171 -0
- package/build/commands/summary.d.ts +56 -0
- package/build/commands/summary.js +324 -0
- package/build/commands/update.d.ts +36 -0
- package/build/commands/update.js +273 -0
- package/build/constants.d.ts +10 -0
- package/build/constants.js +10 -0
- package/build/db/database.d.ts +69 -0
- package/build/db/database.js +126 -0
- package/build/db/index.d.ts +7 -0
- package/build/db/index.js +6 -0
- package/build/db/queries.d.ts +163 -0
- package/build/db/queries.js +273 -0
- package/build/db/schema.sql +136 -0
- package/build/index.d.ts +13 -0
- package/build/index.js +74 -0
- package/build/parser/extractor.d.ts +41 -0
- package/build/parser/extractor.js +249 -0
- package/build/parser/index.d.ts +7 -0
- package/build/parser/index.js +7 -0
- package/build/parser/languages/c.d.ts +28 -0
- package/build/parser/languages/c.js +70 -0
- package/build/parser/languages/cpp.d.ts +28 -0
- package/build/parser/languages/cpp.js +91 -0
- package/build/parser/languages/csharp.d.ts +32 -0
- package/build/parser/languages/csharp.js +97 -0
- package/build/parser/languages/go.d.ts +28 -0
- package/build/parser/languages/go.js +83 -0
- package/build/parser/languages/index.d.ts +21 -0
- package/build/parser/languages/index.js +107 -0
- package/build/parser/languages/java.d.ts +28 -0
- package/build/parser/languages/java.js +58 -0
- package/build/parser/languages/php.d.ts +28 -0
- package/build/parser/languages/php.js +75 -0
- package/build/parser/languages/python.d.ts +28 -0
- package/build/parser/languages/python.js +67 -0
- package/build/parser/languages/ruby.d.ts +28 -0
- package/build/parser/languages/ruby.js +68 -0
- package/build/parser/languages/rust.d.ts +28 -0
- package/build/parser/languages/rust.js +73 -0
- package/build/parser/languages/typescript.d.ts +28 -0
- package/build/parser/languages/typescript.js +82 -0
- package/build/parser/tree-sitter.d.ts +30 -0
- package/build/parser/tree-sitter.js +132 -0
- package/build/server/mcp-server.d.ts +7 -0
- package/build/server/mcp-server.js +36 -0
- package/build/server/tools.d.ts +18 -0
- package/build/server/tools.js +1245 -0
- package/build/viewer/git-status.d.ts +25 -0
- package/build/viewer/git-status.js +163 -0
- package/build/viewer/index.d.ts +5 -0
- package/build/viewer/index.js +5 -0
- package/build/viewer/server.d.ts +12 -0
- package/build/viewer/server.js +1122 -0
- package/package.json +66 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Python keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export const PYTHON_KEYWORDS = new Set([
|
|
8
|
+
// Keywords
|
|
9
|
+
'False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await',
|
|
10
|
+
'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
|
|
11
|
+
'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
|
|
12
|
+
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return',
|
|
13
|
+
'try', 'while', 'with', 'yield',
|
|
14
|
+
// Soft keywords (Python 3.10+)
|
|
15
|
+
'match', 'case', 'type',
|
|
16
|
+
// Built-in types
|
|
17
|
+
'int', 'float', 'str', 'bool', 'bytes', 'list', 'dict', 'set',
|
|
18
|
+
'tuple', 'frozenset', 'object', 'type',
|
|
19
|
+
// Built-in functions (common ones)
|
|
20
|
+
'print', 'len', 'range', 'enumerate', 'zip', 'map', 'filter',
|
|
21
|
+
'sorted', 'reversed', 'sum', 'min', 'max', 'abs', 'round',
|
|
22
|
+
'open', 'input', 'isinstance', 'issubclass', 'hasattr', 'getattr',
|
|
23
|
+
'setattr', 'delattr', 'callable', 'iter', 'next', 'super',
|
|
24
|
+
'staticmethod', 'classmethod', 'property',
|
|
25
|
+
// Common exceptions
|
|
26
|
+
'Exception', 'ValueError', 'TypeError', 'KeyError', 'IndexError',
|
|
27
|
+
'AttributeError', 'RuntimeError', 'StopIteration',
|
|
28
|
+
// Common decorators
|
|
29
|
+
'abstractmethod', 'dataclass', 'overload',
|
|
30
|
+
// Type hints
|
|
31
|
+
'Optional', 'List', 'Dict', 'Set', 'Tuple', 'Union', 'Any',
|
|
32
|
+
'Callable', 'Iterable', 'Iterator', 'Generator',
|
|
33
|
+
'TypeVar', 'Generic', 'Protocol',
|
|
34
|
+
// Magic names (dunder)
|
|
35
|
+
'self', 'cls',
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Tree-sitter node types that represent identifiers in Python
|
|
39
|
+
*/
|
|
40
|
+
export const PYTHON_IDENTIFIER_NODES = new Set([
|
|
41
|
+
'identifier',
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
* Tree-sitter node types for comments
|
|
45
|
+
*/
|
|
46
|
+
export const PYTHON_COMMENT_NODES = new Set([
|
|
47
|
+
'comment',
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* Tree-sitter node types for function declarations
|
|
51
|
+
*/
|
|
52
|
+
export const PYTHON_METHOD_NODES = new Set([
|
|
53
|
+
'function_definition',
|
|
54
|
+
]);
|
|
55
|
+
/**
|
|
56
|
+
* Tree-sitter node types for type declarations
|
|
57
|
+
*/
|
|
58
|
+
export const PYTHON_TYPE_NODES = new Set([
|
|
59
|
+
'class_definition',
|
|
60
|
+
]);
|
|
61
|
+
/**
|
|
62
|
+
* Check if a term is a Python keyword
|
|
63
|
+
*/
|
|
64
|
+
export function isKeyword(term) {
|
|
65
|
+
return PYTHON_KEYWORDS.has(term);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Ruby keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export declare const RUBY_KEYWORDS: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Tree-sitter node types that represent identifiers in Ruby
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUBY_IDENTIFIER_NODES: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Tree-sitter node types for comments
|
|
14
|
+
*/
|
|
15
|
+
export declare const RUBY_COMMENT_NODES: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Tree-sitter node types for function declarations
|
|
18
|
+
*/
|
|
19
|
+
export declare const RUBY_METHOD_NODES: Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Tree-sitter node types for type declarations
|
|
22
|
+
*/
|
|
23
|
+
export declare const RUBY_TYPE_NODES: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a term is a Ruby keyword
|
|
26
|
+
*/
|
|
27
|
+
export declare function isKeyword(term: string): boolean;
|
|
28
|
+
//# sourceMappingURL=ruby.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Ruby keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export const RUBY_KEYWORDS = new Set([
|
|
8
|
+
// Control flow
|
|
9
|
+
'if', 'elsif', 'else', 'unless', 'then',
|
|
10
|
+
'while', 'until', 'do', 'end',
|
|
11
|
+
'for', 'in', 'case', 'when',
|
|
12
|
+
// Definition
|
|
13
|
+
'def', 'class', 'module', 'super', 'alias', 'undef',
|
|
14
|
+
// Exception handling
|
|
15
|
+
'begin', 'rescue', 'ensure', 'retry', 'raise',
|
|
16
|
+
// Return & Flow control
|
|
17
|
+
'return', 'yield', 'break', 'next', 'redo',
|
|
18
|
+
// Literals & Values
|
|
19
|
+
'true', 'false', 'nil', 'self',
|
|
20
|
+
// Logical operators
|
|
21
|
+
'and', 'or', 'not',
|
|
22
|
+
// Special
|
|
23
|
+
'defined?', 'BEGIN', 'END',
|
|
24
|
+
// Magic constants
|
|
25
|
+
'__LINE__', '__FILE__', '__ENCODING__',
|
|
26
|
+
// Common built-ins (often noise)
|
|
27
|
+
'attr_reader', 'attr_writer', 'attr_accessor',
|
|
28
|
+
'private', 'protected', 'public',
|
|
29
|
+
'require', 'require_relative', 'include', 'extend', 'prepend',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Tree-sitter node types that represent identifiers in Ruby
|
|
33
|
+
*/
|
|
34
|
+
export const RUBY_IDENTIFIER_NODES = new Set([
|
|
35
|
+
'identifier',
|
|
36
|
+
'constant',
|
|
37
|
+
'instance_variable',
|
|
38
|
+
'class_variable',
|
|
39
|
+
'global_variable',
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* Tree-sitter node types for comments
|
|
43
|
+
*/
|
|
44
|
+
export const RUBY_COMMENT_NODES = new Set([
|
|
45
|
+
'comment',
|
|
46
|
+
]);
|
|
47
|
+
/**
|
|
48
|
+
* Tree-sitter node types for function declarations
|
|
49
|
+
*/
|
|
50
|
+
export const RUBY_METHOD_NODES = new Set([
|
|
51
|
+
'method',
|
|
52
|
+
'singleton_method',
|
|
53
|
+
]);
|
|
54
|
+
/**
|
|
55
|
+
* Tree-sitter node types for type declarations
|
|
56
|
+
*/
|
|
57
|
+
export const RUBY_TYPE_NODES = new Set([
|
|
58
|
+
'class',
|
|
59
|
+
'module',
|
|
60
|
+
'singleton_class',
|
|
61
|
+
]);
|
|
62
|
+
/**
|
|
63
|
+
* Check if a term is a Ruby keyword
|
|
64
|
+
*/
|
|
65
|
+
export function isKeyword(term) {
|
|
66
|
+
return RUBY_KEYWORDS.has(term);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=ruby.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Rust keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export declare const RUST_KEYWORDS: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Tree-sitter node types that represent identifiers in Rust
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUST_IDENTIFIER_NODES: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Tree-sitter node types for comments
|
|
14
|
+
*/
|
|
15
|
+
export declare const RUST_COMMENT_NODES: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Tree-sitter node types for function declarations
|
|
18
|
+
*/
|
|
19
|
+
export declare const RUST_METHOD_NODES: Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Tree-sitter node types for type declarations
|
|
22
|
+
*/
|
|
23
|
+
export declare const RUST_TYPE_NODES: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a term is a Rust keyword
|
|
26
|
+
*/
|
|
27
|
+
export declare function isKeyword(term: string): boolean;
|
|
28
|
+
//# sourceMappingURL=rust.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Rust keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export const RUST_KEYWORDS = new Set([
|
|
8
|
+
// Strict keywords
|
|
9
|
+
'as', 'async', 'await', 'break', 'const', 'continue', 'crate',
|
|
10
|
+
'dyn', 'else', 'enum', 'extern', 'false', 'fn', 'for', 'if',
|
|
11
|
+
'impl', 'in', 'let', 'loop', 'match', 'mod', 'move', 'mut',
|
|
12
|
+
'pub', 'ref', 'return', 'self', 'Self', 'static', 'struct',
|
|
13
|
+
'super', 'trait', 'true', 'type', 'unsafe', 'use', 'where', 'while',
|
|
14
|
+
// Reserved keywords
|
|
15
|
+
'abstract', 'become', 'box', 'do', 'final', 'macro', 'override',
|
|
16
|
+
'priv', 'try', 'typeof', 'unsized', 'virtual', 'yield',
|
|
17
|
+
// Weak keywords
|
|
18
|
+
'union', 'dyn',
|
|
19
|
+
// Primitive types
|
|
20
|
+
'bool', 'char', 'str',
|
|
21
|
+
'i8', 'i16', 'i32', 'i64', 'i128', 'isize',
|
|
22
|
+
'u8', 'u16', 'u32', 'u64', 'u128', 'usize',
|
|
23
|
+
'f32', 'f64',
|
|
24
|
+
// Common types (often noise)
|
|
25
|
+
'Option', 'Some', 'None', 'Result', 'Ok', 'Err',
|
|
26
|
+
'Vec', 'String', 'Box', 'Rc', 'Arc', 'Cell', 'RefCell',
|
|
27
|
+
'HashMap', 'HashSet', 'BTreeMap', 'BTreeSet',
|
|
28
|
+
'Fn', 'FnMut', 'FnOnce',
|
|
29
|
+
'Send', 'Sync', 'Copy', 'Clone', 'Debug', 'Default',
|
|
30
|
+
'Iterator', 'IntoIterator',
|
|
31
|
+
// Common macros
|
|
32
|
+
'println', 'print', 'format', 'panic', 'assert', 'assert_eq',
|
|
33
|
+
'vec', 'todo', 'unimplemented', 'unreachable',
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Tree-sitter node types that represent identifiers in Rust
|
|
37
|
+
*/
|
|
38
|
+
export const RUST_IDENTIFIER_NODES = new Set([
|
|
39
|
+
'identifier',
|
|
40
|
+
'type_identifier',
|
|
41
|
+
'field_identifier',
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
* Tree-sitter node types for comments
|
|
45
|
+
*/
|
|
46
|
+
export const RUST_COMMENT_NODES = new Set([
|
|
47
|
+
'line_comment',
|
|
48
|
+
'block_comment',
|
|
49
|
+
]);
|
|
50
|
+
/**
|
|
51
|
+
* Tree-sitter node types for function declarations
|
|
52
|
+
*/
|
|
53
|
+
export const RUST_METHOD_NODES = new Set([
|
|
54
|
+
'function_item',
|
|
55
|
+
'function_signature_item',
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* Tree-sitter node types for type declarations
|
|
59
|
+
*/
|
|
60
|
+
export const RUST_TYPE_NODES = new Set([
|
|
61
|
+
'struct_item',
|
|
62
|
+
'enum_item',
|
|
63
|
+
'trait_item',
|
|
64
|
+
'type_item',
|
|
65
|
+
'impl_item',
|
|
66
|
+
]);
|
|
67
|
+
/**
|
|
68
|
+
* Check if a term is a Rust keyword
|
|
69
|
+
*/
|
|
70
|
+
export function isKeyword(term) {
|
|
71
|
+
return RUST_KEYWORDS.has(term);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=rust.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript/JavaScript keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export declare const TYPESCRIPT_KEYWORDS: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Tree-sitter node types that represent identifiers in TypeScript
|
|
10
|
+
*/
|
|
11
|
+
export declare const TYPESCRIPT_IDENTIFIER_NODES: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Tree-sitter node types for comments
|
|
14
|
+
*/
|
|
15
|
+
export declare const TYPESCRIPT_COMMENT_NODES: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Tree-sitter node types for function declarations
|
|
18
|
+
*/
|
|
19
|
+
export declare const TYPESCRIPT_METHOD_NODES: Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Tree-sitter node types for type declarations
|
|
22
|
+
*/
|
|
23
|
+
export declare const TYPESCRIPT_TYPE_NODES: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a term is a TypeScript keyword
|
|
26
|
+
*/
|
|
27
|
+
export declare function isKeyword(term: string): boolean;
|
|
28
|
+
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript language configuration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript/JavaScript keywords that should be filtered out during indexing
|
|
6
|
+
*/
|
|
7
|
+
export const TYPESCRIPT_KEYWORDS = new Set([
|
|
8
|
+
// Declarations
|
|
9
|
+
'function', 'class', 'interface', 'type', 'enum',
|
|
10
|
+
'const', 'let', 'var',
|
|
11
|
+
'namespace', 'module', 'declare',
|
|
12
|
+
// Modifiers
|
|
13
|
+
'export', 'import', 'from', 'as',
|
|
14
|
+
'public', 'private', 'protected',
|
|
15
|
+
'static', 'readonly', 'abstract',
|
|
16
|
+
'async', 'await',
|
|
17
|
+
'override',
|
|
18
|
+
// Primitive types
|
|
19
|
+
'void', 'number', 'string', 'boolean', 'symbol', 'bigint',
|
|
20
|
+
'any', 'unknown', 'never', 'object',
|
|
21
|
+
// Control flow
|
|
22
|
+
'if', 'else', 'switch', 'case', 'default',
|
|
23
|
+
'for', 'while', 'do',
|
|
24
|
+
'break', 'continue', 'return',
|
|
25
|
+
'try', 'catch', 'finally', 'throw',
|
|
26
|
+
'in', 'of',
|
|
27
|
+
// Operators and literals
|
|
28
|
+
'new', 'typeof', 'instanceof', 'delete', 'keyof',
|
|
29
|
+
'true', 'false', 'null', 'undefined',
|
|
30
|
+
'this', 'super',
|
|
31
|
+
'is', 'infer', 'extends', 'implements',
|
|
32
|
+
// Property accessors
|
|
33
|
+
'get', 'set',
|
|
34
|
+
// Other
|
|
35
|
+
'constructor', 'with', 'debugger',
|
|
36
|
+
'yield', 'satisfies',
|
|
37
|
+
// Common framework types (often noise)
|
|
38
|
+
'Promise', 'Array', 'Map', 'Set', 'Object', 'Function',
|
|
39
|
+
'Record', 'Partial', 'Required', 'Readonly', 'Pick', 'Omit',
|
|
40
|
+
'Exclude', 'Extract', 'ReturnType', 'Parameters',
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* Tree-sitter node types that represent identifiers in TypeScript
|
|
44
|
+
*/
|
|
45
|
+
export const TYPESCRIPT_IDENTIFIER_NODES = new Set([
|
|
46
|
+
'identifier',
|
|
47
|
+
'type_identifier',
|
|
48
|
+
'property_identifier',
|
|
49
|
+
'shorthand_property_identifier',
|
|
50
|
+
]);
|
|
51
|
+
/**
|
|
52
|
+
* Tree-sitter node types for comments
|
|
53
|
+
*/
|
|
54
|
+
export const TYPESCRIPT_COMMENT_NODES = new Set([
|
|
55
|
+
'comment',
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* Tree-sitter node types for function declarations
|
|
59
|
+
*/
|
|
60
|
+
export const TYPESCRIPT_METHOD_NODES = new Set([
|
|
61
|
+
'function_declaration',
|
|
62
|
+
'method_definition',
|
|
63
|
+
'arrow_function',
|
|
64
|
+
'function_expression',
|
|
65
|
+
'generator_function_declaration',
|
|
66
|
+
]);
|
|
67
|
+
/**
|
|
68
|
+
* Tree-sitter node types for type declarations
|
|
69
|
+
*/
|
|
70
|
+
export const TYPESCRIPT_TYPE_NODES = new Set([
|
|
71
|
+
'class_declaration',
|
|
72
|
+
'interface_declaration',
|
|
73
|
+
'type_alias_declaration',
|
|
74
|
+
'enum_declaration',
|
|
75
|
+
]);
|
|
76
|
+
/**
|
|
77
|
+
* Check if a term is a TypeScript keyword
|
|
78
|
+
*/
|
|
79
|
+
export function isKeyword(term) {
|
|
80
|
+
return TYPESCRIPT_KEYWORDS.has(term.toLowerCase());
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter parser integration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
import Parser from 'tree-sitter';
|
|
5
|
+
export type SupportedLanguage = 'csharp' | 'typescript' | 'javascript' | 'rust' | 'python' | 'c' | 'cpp' | 'java' | 'go' | 'php' | 'ruby';
|
|
6
|
+
/**
|
|
7
|
+
* Get or create a parser for the given language
|
|
8
|
+
*/
|
|
9
|
+
export declare function getParser(language: SupportedLanguage): Parser;
|
|
10
|
+
/**
|
|
11
|
+
* Detect language from file extension
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectLanguage(filePath: string): SupportedLanguage | null;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a file extension is supported
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSupported(filePath: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get all supported file extensions
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSupportedExtensions(): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Parse source code and return the syntax tree
|
|
24
|
+
*/
|
|
25
|
+
export declare function parse(sourceCode: string, language: SupportedLanguage): Parser.Tree;
|
|
26
|
+
/**
|
|
27
|
+
* Parse a file's content with auto-detected language
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseFile(sourceCode: string, filePath: string): Parser.Tree | null;
|
|
30
|
+
//# sourceMappingURL=tree-sitter.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter parser integration for AiDex
|
|
3
|
+
*/
|
|
4
|
+
import Parser from 'tree-sitter';
|
|
5
|
+
// Language grammars
|
|
6
|
+
import CSharp from 'tree-sitter-c-sharp';
|
|
7
|
+
import TypeScript from 'tree-sitter-typescript';
|
|
8
|
+
import Rust from 'tree-sitter-rust';
|
|
9
|
+
import Python from 'tree-sitter-python';
|
|
10
|
+
import C from 'tree-sitter-c';
|
|
11
|
+
import Cpp from 'tree-sitter-cpp';
|
|
12
|
+
import Java from 'tree-sitter-java';
|
|
13
|
+
import Go from 'tree-sitter-go';
|
|
14
|
+
import Php from 'tree-sitter-php';
|
|
15
|
+
import Ruby from 'tree-sitter-ruby';
|
|
16
|
+
// File extension to language mapping
|
|
17
|
+
const EXTENSION_MAP = {
|
|
18
|
+
'.cs': 'csharp',
|
|
19
|
+
'.ts': 'typescript',
|
|
20
|
+
'.tsx': 'typescript',
|
|
21
|
+
'.js': 'javascript',
|
|
22
|
+
'.jsx': 'javascript',
|
|
23
|
+
'.mjs': 'javascript',
|
|
24
|
+
'.cjs': 'javascript',
|
|
25
|
+
'.rs': 'rust',
|
|
26
|
+
'.py': 'python',
|
|
27
|
+
'.pyw': 'python',
|
|
28
|
+
'.c': 'c',
|
|
29
|
+
'.h': 'c',
|
|
30
|
+
'.cpp': 'cpp',
|
|
31
|
+
'.cc': 'cpp',
|
|
32
|
+
'.cxx': 'cpp',
|
|
33
|
+
'.hpp': 'cpp',
|
|
34
|
+
'.hxx': 'cpp',
|
|
35
|
+
'.java': 'java',
|
|
36
|
+
'.go': 'go',
|
|
37
|
+
'.php': 'php',
|
|
38
|
+
'.rb': 'ruby',
|
|
39
|
+
'.rake': 'ruby',
|
|
40
|
+
};
|
|
41
|
+
// Cached parsers per language
|
|
42
|
+
const parsers = new Map();
|
|
43
|
+
/**
|
|
44
|
+
* Get or create a parser for the given language
|
|
45
|
+
*/
|
|
46
|
+
export function getParser(language) {
|
|
47
|
+
let parser = parsers.get(language);
|
|
48
|
+
if (parser) {
|
|
49
|
+
return parser;
|
|
50
|
+
}
|
|
51
|
+
parser = new Parser();
|
|
52
|
+
switch (language) {
|
|
53
|
+
case 'csharp':
|
|
54
|
+
parser.setLanguage(CSharp);
|
|
55
|
+
break;
|
|
56
|
+
case 'typescript':
|
|
57
|
+
parser.setLanguage(TypeScript.typescript);
|
|
58
|
+
break;
|
|
59
|
+
case 'javascript':
|
|
60
|
+
parser.setLanguage(TypeScript.typescript); // TS parser handles JS too
|
|
61
|
+
break;
|
|
62
|
+
case 'rust':
|
|
63
|
+
parser.setLanguage(Rust);
|
|
64
|
+
break;
|
|
65
|
+
case 'python':
|
|
66
|
+
parser.setLanguage(Python);
|
|
67
|
+
break;
|
|
68
|
+
case 'c':
|
|
69
|
+
parser.setLanguage(C);
|
|
70
|
+
break;
|
|
71
|
+
case 'cpp':
|
|
72
|
+
parser.setLanguage(Cpp);
|
|
73
|
+
break;
|
|
74
|
+
case 'java':
|
|
75
|
+
parser.setLanguage(Java);
|
|
76
|
+
break;
|
|
77
|
+
case 'go':
|
|
78
|
+
parser.setLanguage(Go);
|
|
79
|
+
break;
|
|
80
|
+
case 'php':
|
|
81
|
+
parser.setLanguage(Php.php);
|
|
82
|
+
break;
|
|
83
|
+
case 'ruby':
|
|
84
|
+
parser.setLanguage(Ruby);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`Unsupported language: ${language}`);
|
|
88
|
+
}
|
|
89
|
+
parsers.set(language, parser);
|
|
90
|
+
return parser;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Detect language from file extension
|
|
94
|
+
*/
|
|
95
|
+
export function detectLanguage(filePath) {
|
|
96
|
+
const ext = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
|
|
97
|
+
return EXTENSION_MAP[ext] ?? null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Check if a file extension is supported
|
|
101
|
+
*/
|
|
102
|
+
export function isSupported(filePath) {
|
|
103
|
+
return detectLanguage(filePath) !== null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get all supported file extensions
|
|
107
|
+
*/
|
|
108
|
+
export function getSupportedExtensions() {
|
|
109
|
+
return Object.keys(EXTENSION_MAP);
|
|
110
|
+
}
|
|
111
|
+
// Default buffer size for tree-sitter parser (1 MB)
|
|
112
|
+
// Fixes "Invalid argument" error for files > 32KB
|
|
113
|
+
// See: https://github.com/tree-sitter/tree-sitter/issues/3473
|
|
114
|
+
const PARSE_BUFFER_SIZE = 1024 * 1024;
|
|
115
|
+
/**
|
|
116
|
+
* Parse source code and return the syntax tree
|
|
117
|
+
*/
|
|
118
|
+
export function parse(sourceCode, language) {
|
|
119
|
+
const parser = getParser(language);
|
|
120
|
+
return parser.parse(sourceCode, undefined, { bufferSize: PARSE_BUFFER_SIZE });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse a file's content with auto-detected language
|
|
124
|
+
*/
|
|
125
|
+
export function parseFile(sourceCode, filePath) {
|
|
126
|
+
const language = detectLanguage(filePath);
|
|
127
|
+
if (!language) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return parse(sourceCode, language);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=tree-sitter.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server implementation for AiDex
|
|
3
|
+
*/
|
|
4
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { registerTools, handleToolCall } from './tools.js';
|
|
8
|
+
import { PRODUCT_NAME, PRODUCT_NAME_LOWER } from '../constants.js';
|
|
9
|
+
export function createServer() {
|
|
10
|
+
const server = new Server({
|
|
11
|
+
name: PRODUCT_NAME_LOWER,
|
|
12
|
+
version: '1.3.0',
|
|
13
|
+
}, {
|
|
14
|
+
capabilities: {
|
|
15
|
+
tools: {},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
// Register tool list handler
|
|
19
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
20
|
+
return {
|
|
21
|
+
tools: registerTools(),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
// Register tool call handler
|
|
25
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
26
|
+
return handleToolCall(request.params.name, request.params.arguments ?? {});
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
async start() {
|
|
30
|
+
const transport = new StdioServerTransport();
|
|
31
|
+
await server.connect(transport);
|
|
32
|
+
console.error(`${PRODUCT_NAME} MCP server started`);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool definitions and handlers for AiDex
|
|
3
|
+
*/
|
|
4
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Register all available tools
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerTools(): Tool[];
|
|
9
|
+
/**
|
|
10
|
+
* Handle tool calls
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleToolCall(name: string, args: Record<string, unknown>): Promise<{
|
|
13
|
+
content: Array<{
|
|
14
|
+
type: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=tools.d.ts.map
|