aios-core 4.2.5 → 4.2.6
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/.aios-core/core/code-intel/code-intel-client.js +280 -0
- package/.aios-core/core/code-intel/code-intel-enricher.js +159 -0
- package/.aios-core/core/code-intel/index.js +137 -0
- package/.aios-core/core/code-intel/providers/code-graph-provider.js +201 -0
- package/.aios-core/core/code-intel/providers/provider-interface.js +108 -0
- package/.aios-core/data/entity-registry.yaml +1330 -1086
- package/.aios-core/install-manifest.yaml +25 -5
- package/package.json +1 -1
- package/packages/installer/src/wizard/pro-setup.js +8 -7
- package/pro/license/license-api.js +9 -9
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { CodeIntelProvider } = require('./provider-interface');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Code Graph MCP tool name mapping.
|
|
7
|
+
* Maps abstract capabilities to Code Graph MCP tool names.
|
|
8
|
+
*/
|
|
9
|
+
const TOOL_MAP = {
|
|
10
|
+
findDefinition: 'find_definition',
|
|
11
|
+
findReferences: 'find_references',
|
|
12
|
+
findCallers: 'find_callers',
|
|
13
|
+
findCallees: 'find_callees',
|
|
14
|
+
analyzeDependencies: 'dependency_analysis',
|
|
15
|
+
analyzeComplexity: 'complexity_analysis',
|
|
16
|
+
analyzeCodebase: 'analyze_codebase',
|
|
17
|
+
getProjectStats: 'project_statistics',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* CodeGraphProvider — Adapter for Code Graph MCP server.
|
|
22
|
+
*
|
|
23
|
+
* Translates the 8 abstract capabilities into Code Graph MCP tool calls.
|
|
24
|
+
* Normalizes responses to match the provider-interface contract.
|
|
25
|
+
*/
|
|
26
|
+
class CodeGraphProvider extends CodeIntelProvider {
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
super('code-graph', options);
|
|
29
|
+
this._mcpServerName = options.mcpServerName || 'code-graph';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Execute an MCP tool call via the configured server.
|
|
34
|
+
* This method is the single point of MCP communication — all capabilities route through here.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} toolName - MCP tool name (e.g. 'find_definition')
|
|
37
|
+
* @param {Object} params - Tool parameters
|
|
38
|
+
* @returns {Promise<Object|null>} Tool result or null on failure
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
async _callMcpTool(toolName, params = {}) {
|
|
42
|
+
// MCP tool calls are executed via the Claude Code MCP protocol.
|
|
43
|
+
// In production, this is invoked by the Claude Code runtime.
|
|
44
|
+
// For testing, this method is mocked.
|
|
45
|
+
//
|
|
46
|
+
// The actual MCP call signature:
|
|
47
|
+
// mcp__<server>__<tool>(params)
|
|
48
|
+
//
|
|
49
|
+
// Since we run inside Claude Code agent context, the MCP call
|
|
50
|
+
// is abstracted. Consumers of this module use the client layer
|
|
51
|
+
// which handles the actual invocation.
|
|
52
|
+
|
|
53
|
+
if (typeof this.options.mcpCallFn === 'function') {
|
|
54
|
+
return await this.options.mcpCallFn(this._mcpServerName, toolName, params);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// No MCP call function configured — provider cannot operate
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async findDefinition(symbol, options = {}) {
|
|
62
|
+
const result = await this._callMcpTool(TOOL_MAP.findDefinition, {
|
|
63
|
+
symbol,
|
|
64
|
+
...options,
|
|
65
|
+
});
|
|
66
|
+
return this._normalizeDefinitionResult(result);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async findReferences(symbol, options = {}) {
|
|
70
|
+
const result = await this._callMcpTool(TOOL_MAP.findReferences, {
|
|
71
|
+
symbol,
|
|
72
|
+
...options,
|
|
73
|
+
});
|
|
74
|
+
return this._normalizeReferencesResult(result);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async findCallers(symbol, options = {}) {
|
|
78
|
+
const result = await this._callMcpTool(TOOL_MAP.findCallers, {
|
|
79
|
+
symbol,
|
|
80
|
+
...options,
|
|
81
|
+
});
|
|
82
|
+
return this._normalizeCallersResult(result);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async findCallees(symbol, options = {}) {
|
|
86
|
+
const result = await this._callMcpTool(TOOL_MAP.findCallees, {
|
|
87
|
+
symbol,
|
|
88
|
+
...options,
|
|
89
|
+
});
|
|
90
|
+
return this._normalizeCalleesResult(result);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async analyzeDependencies(path, options = {}) {
|
|
94
|
+
const result = await this._callMcpTool(TOOL_MAP.analyzeDependencies, {
|
|
95
|
+
path,
|
|
96
|
+
...options,
|
|
97
|
+
});
|
|
98
|
+
return this._normalizeDependenciesResult(result);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async analyzeComplexity(path, options = {}) {
|
|
102
|
+
const result = await this._callMcpTool(TOOL_MAP.analyzeComplexity, {
|
|
103
|
+
path,
|
|
104
|
+
...options,
|
|
105
|
+
});
|
|
106
|
+
return this._normalizeComplexityResult(result);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async analyzeCodebase(path, options = {}) {
|
|
110
|
+
const result = await this._callMcpTool(TOOL_MAP.analyzeCodebase, {
|
|
111
|
+
path,
|
|
112
|
+
...options,
|
|
113
|
+
});
|
|
114
|
+
return this._normalizeCodebaseResult(result);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async getProjectStats(options = {}) {
|
|
118
|
+
const result = await this._callMcpTool(TOOL_MAP.getProjectStats, options);
|
|
119
|
+
return this._normalizeStatsResult(result);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// --- Normalization helpers ---
|
|
123
|
+
// Normalize MCP responses to provider-interface contract format.
|
|
124
|
+
// If result is null/undefined, return null (fallback).
|
|
125
|
+
|
|
126
|
+
_normalizeDefinitionResult(result) {
|
|
127
|
+
if (!result) return null;
|
|
128
|
+
return {
|
|
129
|
+
file: result.file ?? result.path ?? null,
|
|
130
|
+
line: result.line != null ? result.line : (result.row != null ? result.row : null),
|
|
131
|
+
column: result.column != null ? result.column : (result.col != null ? result.col : null),
|
|
132
|
+
context: result.context || result.snippet || null,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
_normalizeReferencesResult(result) {
|
|
137
|
+
if (!result) return null;
|
|
138
|
+
const items = Array.isArray(result) ? result : result.references || result.results || [];
|
|
139
|
+
return items.map((r) => ({
|
|
140
|
+
file: r.file ?? r.path ?? null,
|
|
141
|
+
line: r.line != null ? r.line : (r.row != null ? r.row : null),
|
|
142
|
+
context: r.context || r.snippet || null,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_normalizeCallersResult(result) {
|
|
147
|
+
if (!result) return null;
|
|
148
|
+
const items = Array.isArray(result) ? result : result.callers || result.results || [];
|
|
149
|
+
return items.map((r) => ({
|
|
150
|
+
caller: r.caller || r.name || null,
|
|
151
|
+
file: r.file ?? r.path ?? null,
|
|
152
|
+
line: r.line != null ? r.line : (r.row != null ? r.row : null),
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
_normalizeCalleesResult(result) {
|
|
157
|
+
if (!result) return null;
|
|
158
|
+
const items = Array.isArray(result) ? result : result.callees || result.results || [];
|
|
159
|
+
return items.map((r) => ({
|
|
160
|
+
callee: r.callee || r.name || null,
|
|
161
|
+
file: r.file ?? r.path ?? null,
|
|
162
|
+
line: r.line != null ? r.line : (r.row != null ? r.row : null),
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_normalizeDependenciesResult(result) {
|
|
167
|
+
if (!result) return null;
|
|
168
|
+
return {
|
|
169
|
+
nodes: result.nodes || result.files || [],
|
|
170
|
+
edges: result.edges || result.dependencies || [],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
_normalizeComplexityResult(result) {
|
|
175
|
+
if (!result) return null;
|
|
176
|
+
return {
|
|
177
|
+
score: result.score != null ? result.score : (result.complexity != null ? result.complexity : 0),
|
|
178
|
+
details: result.details || result.metrics || {},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_normalizeCodebaseResult(result) {
|
|
183
|
+
if (!result) return null;
|
|
184
|
+
return {
|
|
185
|
+
files: result.files || [],
|
|
186
|
+
structure: result.structure || {},
|
|
187
|
+
patterns: result.patterns || [],
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_normalizeStatsResult(result) {
|
|
192
|
+
if (!result) return null;
|
|
193
|
+
return {
|
|
194
|
+
files: result.files != null ? result.files : (result.total_files != null ? result.total_files : 0),
|
|
195
|
+
lines: result.lines != null ? result.lines : (result.total_lines != null ? result.total_lines : 0),
|
|
196
|
+
languages: result.languages || {},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = { CodeGraphProvider, TOOL_MAP };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CodeIntelProvider — Abstract base class for all code intelligence providers.
|
|
5
|
+
*
|
|
6
|
+
* Every provider MUST extend this class and implement all 8 primitive capabilities.
|
|
7
|
+
* Default implementations return null (graceful fallback built-in).
|
|
8
|
+
*
|
|
9
|
+
* @abstract
|
|
10
|
+
*/
|
|
11
|
+
class CodeIntelProvider {
|
|
12
|
+
constructor(name, options = {}) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Locate the definition of a symbol.
|
|
19
|
+
* @param {string} symbol - Symbol name to find
|
|
20
|
+
* @param {Object} [options] - Provider-specific options
|
|
21
|
+
* @returns {Promise<{file: string, line: number, column: number, context: string}|null>}
|
|
22
|
+
*/
|
|
23
|
+
async findDefinition(_symbol, _options) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Find all references (usages) of a symbol.
|
|
29
|
+
* @param {string} symbol - Symbol name to search
|
|
30
|
+
* @param {Object} [options] - Provider-specific options
|
|
31
|
+
* @returns {Promise<Array<{file: string, line: number, context: string}>|null>}
|
|
32
|
+
*/
|
|
33
|
+
async findReferences(_symbol, _options) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Find all callers of a function/method.
|
|
39
|
+
* @param {string} symbol - Function/method name
|
|
40
|
+
* @param {Object} [options] - Provider-specific options
|
|
41
|
+
* @returns {Promise<Array<{caller: string, file: string, line: number}>|null>}
|
|
42
|
+
*/
|
|
43
|
+
async findCallers(_symbol, _options) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Find all callees (functions called by) a function/method.
|
|
49
|
+
* @param {string} symbol - Function/method name
|
|
50
|
+
* @param {Object} [options] - Provider-specific options
|
|
51
|
+
* @returns {Promise<Array<{callee: string, file: string, line: number}>|null>}
|
|
52
|
+
*/
|
|
53
|
+
async findCallees(_symbol, _options) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Analyze dependency graph for a file or directory.
|
|
59
|
+
* @param {string} path - File or directory path
|
|
60
|
+
* @param {Object} [options] - Provider-specific options
|
|
61
|
+
* @returns {Promise<{nodes: Array, edges: Array}|null>}
|
|
62
|
+
*/
|
|
63
|
+
async analyzeDependencies(_path, _options) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Analyze code complexity metrics.
|
|
69
|
+
* @param {string} path - File or directory path
|
|
70
|
+
* @param {Object} [options] - Provider-specific options
|
|
71
|
+
* @returns {Promise<{score: number, details: Object}|null>}
|
|
72
|
+
*/
|
|
73
|
+
async analyzeComplexity(_path, _options) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Analyze codebase structure, files and patterns.
|
|
79
|
+
* @param {string} path - Root path to analyze
|
|
80
|
+
* @param {Object} [options] - Provider-specific options
|
|
81
|
+
* @returns {Promise<{files: Array, structure: Object, patterns: Array}|null>}
|
|
82
|
+
*/
|
|
83
|
+
async analyzeCodebase(_path, _options) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get project-level statistics.
|
|
89
|
+
* @param {Object} [options] - Provider-specific options
|
|
90
|
+
* @returns {Promise<{files: number, lines: number, languages: Object}|null>}
|
|
91
|
+
*/
|
|
92
|
+
async getProjectStats(_options) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const CAPABILITIES = [
|
|
98
|
+
'findDefinition',
|
|
99
|
+
'findReferences',
|
|
100
|
+
'findCallers',
|
|
101
|
+
'findCallees',
|
|
102
|
+
'analyzeDependencies',
|
|
103
|
+
'analyzeComplexity',
|
|
104
|
+
'analyzeCodebase',
|
|
105
|
+
'getProjectStats',
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
module.exports = { CodeIntelProvider, CAPABILITIES };
|