embark-cli 1.1.7
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/.claude/CLAUDE.md +33 -0
- package/.claude/settings.local.json +32 -0
- package/.github/WORKFLOWS.md +147 -0
- package/.github/workflows/ci.yml +49 -0
- package/.github/workflows/publish.yml +109 -0
- package/.idea/embark-remote-mcp.iml +9 -0
- package/.idea/encodings.xml +4 -0
- package/.idea/indexLayout.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.mcp.json +14 -0
- package/GIT_DISCOVERY.md +231 -0
- package/INTEGRATION_TESTING.md +243 -0
- package/MULTI_REPOSITORY_SEARCH.md +242 -0
- package/README.md +434 -0
- package/dist/auth/auth-helper.d.ts +3 -0
- package/dist/auth/auth-helper.d.ts.map +1 -0
- package/dist/auth/auth-helper.js +171 -0
- package/dist/auth/auth-helper.js.map +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +24 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/jba-login.d.ts +17 -0
- package/dist/auth/jba-login.d.ts.map +1 -0
- package/dist/auth/jba-login.js +345 -0
- package/dist/auth/jba-login.js.map +1 -0
- package/dist/auth/types.d.ts +16 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +3 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/embark-client.d.ts +56 -0
- package/dist/embark-client.d.ts.map +1 -0
- package/dist/embark-client.js +543 -0
- package/dist/embark-client.js.map +1 -0
- package/dist/git-utils.d.ts +47 -0
- package/dist/git-utils.d.ts.map +1 -0
- package/dist/git-utils.js +232 -0
- package/dist/git-utils.js.map +1 -0
- package/dist/handlers.d.ts +80 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +301 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +92 -0
- package/dist/logger.js.map +1 -0
- package/dist/stats-server.d.ts +3 -0
- package/dist/stats-server.d.ts.map +1 -0
- package/dist/stats-server.js +623 -0
- package/dist/stats-server.js.map +1 -0
- package/dist/stats.d.ts +118 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +206 -0
- package/dist/stats.js.map +1 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +62 -0
- package/dist/tools.js.map +1 -0
- package/package.json +47 -0
- package/test-git-discovery.mjs +322 -0
- package/test-multi-repo-filters.mjs +151 -0
- package/test-multiple-roots.mjs +436 -0
- package/test-roots.mjs +306 -0
- package/test-snippet-extraction.mjs +136 -0
- package/watch-logs.sh +78 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Embark API client module
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.makeEmbarkRequest = makeEmbarkRequest;
|
|
10
|
+
exports.semanticCodeSearch = semanticCodeSearch;
|
|
11
|
+
exports.semanticCodeSearchMultiRepo = semanticCodeSearchMultiRepo;
|
|
12
|
+
exports.searchInDependencies = searchInDependencies;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const index_js_1 = require("./auth/index.js");
|
|
15
|
+
const logger_js_1 = require("./logger.js");
|
|
16
|
+
const config_js_1 = require("./config.js");
|
|
17
|
+
const git_utils_js_1 = require("./git-utils.js");
|
|
18
|
+
const stats_js_1 = require("./stats.js");
|
|
19
|
+
function getAxiosStatus(error) {
|
|
20
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
21
|
+
return error.response?.status;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function toErrorMessage(error) {
|
|
26
|
+
if (error instanceof Error) {
|
|
27
|
+
return error.message;
|
|
28
|
+
}
|
|
29
|
+
return String(error);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Helper function to make Embark API requests with automatic token refresh on 401
|
|
33
|
+
*/
|
|
34
|
+
async function makeEmbarkRequest(requestFn, responseHandler, context, revision = null) {
|
|
35
|
+
let authToken = await (0, index_js_1.getAuthToken)();
|
|
36
|
+
const statsContext = context?.statsContext;
|
|
37
|
+
let requestStart = Date.now();
|
|
38
|
+
try {
|
|
39
|
+
(0, logger_js_1.logToFile)('info', 'Making Embark API request', context);
|
|
40
|
+
const response = await requestFn(authToken, revision);
|
|
41
|
+
if (statsContext) {
|
|
42
|
+
(0, stats_js_1.recordApiCallEvent)({
|
|
43
|
+
operation: statsContext.operation,
|
|
44
|
+
endpoint: statsContext.endpoint,
|
|
45
|
+
durationMs: Date.now() - requestStart,
|
|
46
|
+
statusCode: response.status,
|
|
47
|
+
success: true,
|
|
48
|
+
attempt: 1,
|
|
49
|
+
metadata: statsContext.metadata,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
(0, logger_js_1.logToFile)('info', 'Embark API request succeeded', { ...context, status: response.status });
|
|
53
|
+
return responseHandler(response);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
(0, logger_js_1.logToFile)('error', 'Embark API request failed', { ...context, error });
|
|
57
|
+
if (statsContext) {
|
|
58
|
+
(0, stats_js_1.recordApiCallEvent)({
|
|
59
|
+
operation: statsContext.operation,
|
|
60
|
+
endpoint: statsContext.endpoint,
|
|
61
|
+
durationMs: Date.now() - requestStart,
|
|
62
|
+
statusCode: getAxiosStatus(error),
|
|
63
|
+
success: false,
|
|
64
|
+
errorMessage: toErrorMessage(error),
|
|
65
|
+
attempt: 1,
|
|
66
|
+
metadata: statsContext.metadata,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// Check if it's a 401 error and retry with a fresh token
|
|
70
|
+
if (axios_1.default.isAxiosError(error) && error.response?.status === 401) {
|
|
71
|
+
(0, logger_js_1.logToFile)('warn', 'Received 401 error, refreshing token and retrying', context);
|
|
72
|
+
try {
|
|
73
|
+
// Get a fresh token and retry the request
|
|
74
|
+
authToken = await (0, index_js_1.getAuthToken)(true); // Force refresh on retry
|
|
75
|
+
(0, logger_js_1.logToFile)('info', 'Retrieved fresh token, retrying request', context);
|
|
76
|
+
requestStart = Date.now();
|
|
77
|
+
const response = await requestFn(authToken, revision);
|
|
78
|
+
if (statsContext) {
|
|
79
|
+
(0, stats_js_1.recordApiCallEvent)({
|
|
80
|
+
operation: statsContext.operation,
|
|
81
|
+
endpoint: statsContext.endpoint,
|
|
82
|
+
durationMs: Date.now() - requestStart,
|
|
83
|
+
statusCode: response.status,
|
|
84
|
+
success: true,
|
|
85
|
+
attempt: 2,
|
|
86
|
+
metadata: statsContext.metadata,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
(0, logger_js_1.logToFile)('info', 'Request succeeded after token refresh', { ...context, status: response.status });
|
|
90
|
+
return responseHandler(response);
|
|
91
|
+
}
|
|
92
|
+
catch (retryError) {
|
|
93
|
+
(0, logger_js_1.logToFile)('error', 'Request failed even after token refresh', { ...context, retryError });
|
|
94
|
+
if (statsContext) {
|
|
95
|
+
(0, stats_js_1.recordApiCallEvent)({
|
|
96
|
+
operation: statsContext.operation,
|
|
97
|
+
endpoint: statsContext.endpoint,
|
|
98
|
+
durationMs: Date.now() - requestStart,
|
|
99
|
+
statusCode: getAxiosStatus(retryError),
|
|
100
|
+
success: false,
|
|
101
|
+
errorMessage: toErrorMessage(retryError),
|
|
102
|
+
attempt: 2,
|
|
103
|
+
metadata: statsContext.metadata,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (axios_1.default.isAxiosError(retryError)) {
|
|
107
|
+
const status = retryError.response?.status;
|
|
108
|
+
const statusText = retryError.response?.statusText;
|
|
109
|
+
const responseData = retryError.response?.data;
|
|
110
|
+
(0, logger_js_1.logToFile)('error', 'Embark API error details (after retry)', { status, statusText, responseData });
|
|
111
|
+
throw new Error(`Embark API error (${status}): ${statusText} - ${JSON.stringify(responseData)}`);
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Failed Embark request after retry: ${retryError instanceof Error ? retryError.message : String(retryError)}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// For non-401 errors, log and rethrow
|
|
117
|
+
(0, logger_js_1.logToFile)('error', 'Embark request failed (non-401)', { ...context, error });
|
|
118
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
119
|
+
const status = error.response?.status;
|
|
120
|
+
const statusText = error.response?.statusText;
|
|
121
|
+
const responseData = error.response?.data;
|
|
122
|
+
(0, logger_js_1.logToFile)('error', 'Embark API error details', { status, statusText, responseData });
|
|
123
|
+
throw new Error(`Embark API error (${status}): ${statusText} - ${JSON.stringify(responseData)}`);
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`Failed Embark request: ${error instanceof Error ? error.message : String(error)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Perform semantic code search in a single repository
|
|
130
|
+
*/
|
|
131
|
+
async function semanticCodeSearch(text, repositoryGitRemoteUrl, revision, pathFilter, config, pkg, repositoryPath = null) {
|
|
132
|
+
(0, logger_js_1.logToFile)('info', 'Embark search initiated', {
|
|
133
|
+
text,
|
|
134
|
+
repositoryGitRemoteUrl,
|
|
135
|
+
revision,
|
|
136
|
+
pathFilter,
|
|
137
|
+
repositoryPath,
|
|
138
|
+
logAllowed: config.enableRemoteLogs
|
|
139
|
+
});
|
|
140
|
+
const endpointPrefix = (0, config_js_1.getEndpointPrefix)(config.typeToken);
|
|
141
|
+
const endpointUrl = `${config.jetbrainsAiUrl}/${endpointPrefix}/v5/indexing/search`;
|
|
142
|
+
const searchStart = Date.now();
|
|
143
|
+
const canResolveSnippets = repositoryPath !== null;
|
|
144
|
+
let responseStatus;
|
|
145
|
+
let responseResultCount = 0;
|
|
146
|
+
let topFiles = [];
|
|
147
|
+
try {
|
|
148
|
+
const result = await makeEmbarkRequest(async (authToken, rev) => {
|
|
149
|
+
const requestBody = {
|
|
150
|
+
text,
|
|
151
|
+
repository: repositoryGitRemoteUrl,
|
|
152
|
+
};
|
|
153
|
+
if (rev) {
|
|
154
|
+
requestBody.revision = rev;
|
|
155
|
+
}
|
|
156
|
+
if (pathFilter) {
|
|
157
|
+
requestBody.pathFilter = pathFilter;
|
|
158
|
+
}
|
|
159
|
+
if (config.enableRemoteLogs) {
|
|
160
|
+
requestBody.logAllowed = true;
|
|
161
|
+
}
|
|
162
|
+
return await axios_1.default.post(endpointUrl, requestBody, {
|
|
163
|
+
headers: {
|
|
164
|
+
'accept': 'application/json, text/plain',
|
|
165
|
+
'content-type': 'application/json',
|
|
166
|
+
'grazie-agent': JSON.stringify({ name: pkg.name, version: pkg.version }),
|
|
167
|
+
'Grazie-Authenticate-JWT': authToken,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}, (response) => {
|
|
171
|
+
const searchResponse = response.data.searchResponse;
|
|
172
|
+
const results = searchResponse?.results || [];
|
|
173
|
+
responseStatus = response.status;
|
|
174
|
+
responseResultCount = results.length;
|
|
175
|
+
topFiles = results
|
|
176
|
+
.slice(0, 5)
|
|
177
|
+
.map((item) => item?.sourcePosition?.relativePath)
|
|
178
|
+
.filter((filePath) => Boolean(filePath));
|
|
179
|
+
(0, logger_js_1.logToFile)('info', 'Embark search API response received', {
|
|
180
|
+
status: response.status,
|
|
181
|
+
resultCount: results.length
|
|
182
|
+
});
|
|
183
|
+
const qualifiers = [];
|
|
184
|
+
if (revision)
|
|
185
|
+
qualifiers.push(`revision: "${revision}"`);
|
|
186
|
+
if (pathFilter)
|
|
187
|
+
qualifiers.push(`pathFilter: "${pathFilter}"`);
|
|
188
|
+
const qualifiersInfo = qualifiers.length ? ` (${qualifiers.join(', ')})` : '';
|
|
189
|
+
if (results.length === 0) {
|
|
190
|
+
(0, logger_js_1.logToFile)('info', 'Embark search completed with no results', { text, repositoryGitRemoteUrl, revision });
|
|
191
|
+
return {
|
|
192
|
+
content: [
|
|
193
|
+
{
|
|
194
|
+
type: 'text',
|
|
195
|
+
text: `No results found for "${text}" in repository "${repositoryGitRemoteUrl}"${qualifiersInfo}`,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// Resolve snippets if we have a repository path with git available
|
|
201
|
+
const resultText = results.map((result, index) => {
|
|
202
|
+
const snippetInResult = result.content; // returned only if it's OSS and we have an access to it on the server
|
|
203
|
+
const res = result.result;
|
|
204
|
+
const { scoredText, sourcePosition, indexItemType } = res;
|
|
205
|
+
const baseInfo = `${index + 1}. File=${sourcePosition.relativePath}, offset=${sourcePosition.startOffset}:${sourcePosition.endOffset}, similarity=${scoredText.similarity.toFixed(3)}, type=${indexItemType}`;
|
|
206
|
+
// Use server-provided snippet if available
|
|
207
|
+
if (snippetInResult) {
|
|
208
|
+
(0, logger_js_1.logToFile)('debug', 'Using server-provided snippet', {
|
|
209
|
+
relativePath: sourcePosition.relativePath,
|
|
210
|
+
snippetLength: snippetInResult.length
|
|
211
|
+
});
|
|
212
|
+
return `${baseInfo}\n Snippet:\n \`\`\`\n ${snippetInResult.split('\n').join('\n ')}\n \`\`\``;
|
|
213
|
+
}
|
|
214
|
+
// Try to resolve snippet locally if we have a repository path
|
|
215
|
+
if (canResolveSnippets) {
|
|
216
|
+
const snippet = (0, git_utils_js_1.extractSnippetFromGit)(repositoryPath, sourcePosition.relativePath, revision, sourcePosition.startOffset, sourcePosition.endOffset);
|
|
217
|
+
if (snippet) {
|
|
218
|
+
// Include the snippet in the output, properly formatted
|
|
219
|
+
return `${baseInfo}\n Snippet:\n \`\`\`\n ${snippet.split('\n').join('\n ')}\n \`\`\``;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Fallback to coordinates only
|
|
223
|
+
return baseInfo;
|
|
224
|
+
}).join('\n\n');
|
|
225
|
+
(0, logger_js_1.logToFile)('info', 'Embark search completed successfully', {
|
|
226
|
+
text,
|
|
227
|
+
repositoryGitRemoteUrl,
|
|
228
|
+
revision,
|
|
229
|
+
pathFilter,
|
|
230
|
+
resultCount: results.length
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
content: [
|
|
234
|
+
{
|
|
235
|
+
type: 'text',
|
|
236
|
+
text: `Found ${results.length} results for "${text}" in repository "${repositoryGitRemoteUrl}"${qualifiersInfo}:\n\n${resultText}`,
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
};
|
|
240
|
+
}, {
|
|
241
|
+
text,
|
|
242
|
+
repositoryGitRemoteUrl,
|
|
243
|
+
revision,
|
|
244
|
+
statsContext: {
|
|
245
|
+
operation: 'semantic_code_search',
|
|
246
|
+
endpoint: endpointUrl,
|
|
247
|
+
metadata: {
|
|
248
|
+
repository: repositoryGitRemoteUrl,
|
|
249
|
+
pathFilter,
|
|
250
|
+
revision,
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}, revision);
|
|
254
|
+
(0, stats_js_1.recordSearchEvent)({
|
|
255
|
+
searchKind: 'semantic',
|
|
256
|
+
toolName: 'semantic_code_search',
|
|
257
|
+
query: text,
|
|
258
|
+
repositoryUrls: [repositoryGitRemoteUrl],
|
|
259
|
+
revision,
|
|
260
|
+
pathFilter,
|
|
261
|
+
resultCount: responseResultCount,
|
|
262
|
+
durationMs: Date.now() - searchStart,
|
|
263
|
+
statusCode: responseStatus,
|
|
264
|
+
success: true,
|
|
265
|
+
metadata: {
|
|
266
|
+
repositoryPath,
|
|
267
|
+
topFiles,
|
|
268
|
+
canResolveSnippets,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
(0, stats_js_1.recordSearchEvent)({
|
|
275
|
+
searchKind: 'semantic',
|
|
276
|
+
toolName: 'semantic_code_search',
|
|
277
|
+
query: text,
|
|
278
|
+
repositoryUrls: [repositoryGitRemoteUrl],
|
|
279
|
+
revision,
|
|
280
|
+
pathFilter,
|
|
281
|
+
resultCount: responseResultCount,
|
|
282
|
+
durationMs: Date.now() - searchStart,
|
|
283
|
+
statusCode: responseStatus,
|
|
284
|
+
success: false,
|
|
285
|
+
errorMessage: toErrorMessage(error),
|
|
286
|
+
metadata: {
|
|
287
|
+
repositoryPath,
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Perform semantic code search across multiple repositories
|
|
295
|
+
*/
|
|
296
|
+
async function semanticCodeSearchMultiRepo(text, repositories, revision, pathFilter, config, pkg) {
|
|
297
|
+
(0, logger_js_1.logToFile)('info', 'Multi-repository search initiated', {
|
|
298
|
+
text,
|
|
299
|
+
repositoryCount: repositories.length,
|
|
300
|
+
repositories: repositories.map(r => ({ url: r.url, name: r.name })),
|
|
301
|
+
revision,
|
|
302
|
+
pathFilter,
|
|
303
|
+
});
|
|
304
|
+
// Search all repositories in parallel
|
|
305
|
+
const searchPromises = repositories.map(async (repo) => {
|
|
306
|
+
try {
|
|
307
|
+
const result = await semanticCodeSearch(text, repo.url, revision, pathFilter, config, pkg, repo.path);
|
|
308
|
+
// Extract results from the response
|
|
309
|
+
return {
|
|
310
|
+
repositoryUrl: repo.url,
|
|
311
|
+
repositoryName: repo.name,
|
|
312
|
+
results: result,
|
|
313
|
+
error: undefined,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
(0, logger_js_1.logToFile)('warn', 'Search failed for repository', {
|
|
318
|
+
repositoryUrl: repo.url,
|
|
319
|
+
error: error instanceof Error ? error.message : String(error),
|
|
320
|
+
});
|
|
321
|
+
return {
|
|
322
|
+
repositoryUrl: repo.url,
|
|
323
|
+
repositoryName: repo.name,
|
|
324
|
+
results: [],
|
|
325
|
+
error: error instanceof Error ? error.message : String(error),
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
const allResults = await Promise.all(searchPromises);
|
|
330
|
+
// Aggregate results
|
|
331
|
+
const qualifiers = [];
|
|
332
|
+
if (revision)
|
|
333
|
+
qualifiers.push(`revision: "${revision}"`);
|
|
334
|
+
if (pathFilter)
|
|
335
|
+
qualifiers.push(`pathFilter: "${pathFilter}"`);
|
|
336
|
+
const qualifiersInfo = qualifiers.length ? ` (${qualifiers.join(', ')})` : '';
|
|
337
|
+
const successfulSearches = allResults.filter(r => !r.error);
|
|
338
|
+
const failedSearches = allResults.filter(r => r.error);
|
|
339
|
+
if (successfulSearches.length === 0) {
|
|
340
|
+
(0, logger_js_1.logToFile)('warn', 'All repository searches failed', {
|
|
341
|
+
text,
|
|
342
|
+
repositoryCount: repositories.length,
|
|
343
|
+
failedCount: failedSearches.length,
|
|
344
|
+
});
|
|
345
|
+
const errorDetails = failedSearches.map(r => `- ${r.repositoryName || r.repositoryUrl}: ${r.error}`).join('\n');
|
|
346
|
+
return {
|
|
347
|
+
content: [
|
|
348
|
+
{
|
|
349
|
+
type: 'text',
|
|
350
|
+
text: `Search failed in all ${repositories.length} repositories${qualifiersInfo}:\n\n${errorDetails}`,
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
// Combine all results with repository context
|
|
356
|
+
const combinedText = successfulSearches.map((repoResult) => {
|
|
357
|
+
const repoHeader = `## Repository: ${repoResult.repositoryName || repoResult.repositoryUrl}`;
|
|
358
|
+
// Extract the text content from the result
|
|
359
|
+
const content = repoResult.results.content?.[0]?.text || '';
|
|
360
|
+
return `${repoHeader}\n\n${content}`;
|
|
361
|
+
}).join('\n\n---\n\n');
|
|
362
|
+
const totalResults = successfulSearches.reduce((sum, r) => {
|
|
363
|
+
const text = r.results.content?.[0]?.text || '';
|
|
364
|
+
// Count results by parsing "Found N results" from the text
|
|
365
|
+
const match = text.match(/Found (\d+) results/);
|
|
366
|
+
return sum + (match ? parseInt(match[1], 10) : 0);
|
|
367
|
+
}, 0);
|
|
368
|
+
const summary = failedSearches.length > 0
|
|
369
|
+
? `\n\n**Note:** ${failedSearches.length} repository search(es) failed:\n${failedSearches.map(r => `- ${r.repositoryName || r.repositoryUrl}: ${r.error}`).join('\n')}`
|
|
370
|
+
: '';
|
|
371
|
+
(0, logger_js_1.logToFile)('info', 'Multi-repository search completed', {
|
|
372
|
+
text,
|
|
373
|
+
totalResults,
|
|
374
|
+
successfulSearches: successfulSearches.length,
|
|
375
|
+
failedSearches: failedSearches.length,
|
|
376
|
+
});
|
|
377
|
+
(0, stats_js_1.recordMultiRepoSummaryEvent)({
|
|
378
|
+
query: text,
|
|
379
|
+
repositoryCount: repositories.length,
|
|
380
|
+
successfulRepositories: successfulSearches.length,
|
|
381
|
+
failedRepositories: failedSearches.length,
|
|
382
|
+
totalResults,
|
|
383
|
+
metadata: {
|
|
384
|
+
revision,
|
|
385
|
+
pathFilter,
|
|
386
|
+
repositories: repositories.map(r => ({ url: r.url, name: r.name })),
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
return {
|
|
390
|
+
content: [
|
|
391
|
+
{
|
|
392
|
+
type: 'text',
|
|
393
|
+
text: `Searched ${successfulSearches.length} of ${repositories.length} repositories for "${text}"${qualifiersInfo}. Found ${totalResults} total results.\n\n${combinedText}${summary}`,
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Search for code in dependencies
|
|
400
|
+
*/
|
|
401
|
+
async function searchInDependencies(text, dependencies, repositoryGitRemoteUrl, revision, maxResults, minScore, logAllowed, config, pkg) {
|
|
402
|
+
const dependencyStrings = dependencies.map((dep) => `${dep.dependency}:${dep.version}`);
|
|
403
|
+
(0, logger_js_1.logToFile)('info', 'Embark search dependencies initiated', {
|
|
404
|
+
text,
|
|
405
|
+
dependencies: dependencyStrings,
|
|
406
|
+
repositoryGitRemoteUrl,
|
|
407
|
+
revision,
|
|
408
|
+
maxResults
|
|
409
|
+
});
|
|
410
|
+
const endpointUrl = `${config.jetbrainsAiUrl}/search-dependencies`;
|
|
411
|
+
const searchStart = Date.now();
|
|
412
|
+
let responseStatus;
|
|
413
|
+
let responseResultCount = 0;
|
|
414
|
+
try {
|
|
415
|
+
const result = await makeEmbarkRequest(async (authToken, rev) => {
|
|
416
|
+
const requestBody = {
|
|
417
|
+
index: "ProductionIndices.CodeBlocks",
|
|
418
|
+
text,
|
|
419
|
+
dependencies,
|
|
420
|
+
maxResults,
|
|
421
|
+
minScore,
|
|
422
|
+
logAllowed,
|
|
423
|
+
searchPipelineConfig: "SearchPipelineConfig.SearchOnly"
|
|
424
|
+
};
|
|
425
|
+
if (rev) {
|
|
426
|
+
requestBody.revision = rev;
|
|
427
|
+
}
|
|
428
|
+
return await axios_1.default.post(endpointUrl, requestBody, {
|
|
429
|
+
headers: {
|
|
430
|
+
'accept': 'application/json, text/plain',
|
|
431
|
+
'content-type': 'application/json',
|
|
432
|
+
'grazie-agent': JSON.stringify({ name: pkg.name, version: pkg.version }),
|
|
433
|
+
'Grazie-Authenticate-JWT': authToken,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}, (response) => {
|
|
437
|
+
const { results, timings } = response.data;
|
|
438
|
+
responseStatus = response.status;
|
|
439
|
+
responseResultCount = results?.length || 0;
|
|
440
|
+
(0, logger_js_1.logToFile)('info', 'Embark search dependencies API response received', {
|
|
441
|
+
status: response.status,
|
|
442
|
+
resultCount: results?.length || 0,
|
|
443
|
+
timings
|
|
444
|
+
});
|
|
445
|
+
const revisionInfo = revision ? ` (revision: "${revision}")` : '';
|
|
446
|
+
if (!results || results.length === 0) {
|
|
447
|
+
(0, logger_js_1.logToFile)('info', 'Embark search dependencies completed with no results', {
|
|
448
|
+
text,
|
|
449
|
+
dependencies: dependencyStrings,
|
|
450
|
+
repositoryGitRemoteUrl,
|
|
451
|
+
revision
|
|
452
|
+
});
|
|
453
|
+
return {
|
|
454
|
+
content: [
|
|
455
|
+
{
|
|
456
|
+
type: 'text',
|
|
457
|
+
text: `No results found for "${text}" with dependencies [${dependencyStrings.join(', ')}] in repository "${repositoryGitRemoteUrl}"${revisionInfo}`,
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
const resultText = results.map((result, index) => {
|
|
463
|
+
const { searchResult, content } = result;
|
|
464
|
+
const { sourcePosition, indexItemType, similarity } = searchResult;
|
|
465
|
+
return `${index + 1}. File=${sourcePosition.relativePath}, offset=${sourcePosition.startOffset}:${sourcePosition.endOffset}, similarity=${similarity?.toFixed(3) || 'N/A'}, type=${indexItemType}`;
|
|
466
|
+
}).join('\n');
|
|
467
|
+
const timingText = Object.entries(timings).map(([key, value]) => `${key}: ${value}ms`).join(', ');
|
|
468
|
+
(0, logger_js_1.logToFile)('info', 'Embark search dependencies completed successfully', {
|
|
469
|
+
text,
|
|
470
|
+
dependencies: dependencyStrings,
|
|
471
|
+
repositoryGitRemoteUrl,
|
|
472
|
+
revision,
|
|
473
|
+
resultCount: results.length,
|
|
474
|
+
timings
|
|
475
|
+
});
|
|
476
|
+
return {
|
|
477
|
+
content: [
|
|
478
|
+
{
|
|
479
|
+
type: 'text',
|
|
480
|
+
text: `Found ${results.length} results for "${text}" with dependencies [${dependencyStrings.join(', ')}] in repository "${repositoryGitRemoteUrl}"${revisionInfo}:\n\n${resultText}\n\nTimings: ${timingText}`,
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
};
|
|
484
|
+
}, {
|
|
485
|
+
text,
|
|
486
|
+
dependencies: dependencyStrings,
|
|
487
|
+
repositoryGitRemoteUrl,
|
|
488
|
+
revision,
|
|
489
|
+
maxResults,
|
|
490
|
+
statsContext: {
|
|
491
|
+
operation: 'search_in_dependencies',
|
|
492
|
+
endpoint: endpointUrl,
|
|
493
|
+
metadata: {
|
|
494
|
+
repository: repositoryGitRemoteUrl,
|
|
495
|
+
dependencyCount: dependencies.length,
|
|
496
|
+
revision,
|
|
497
|
+
},
|
|
498
|
+
}
|
|
499
|
+
}, revision);
|
|
500
|
+
(0, stats_js_1.recordSearchEvent)({
|
|
501
|
+
searchKind: 'dependencies',
|
|
502
|
+
toolName: 'search_in_dependencies',
|
|
503
|
+
query: text,
|
|
504
|
+
repositoryUrls: [repositoryGitRemoteUrl],
|
|
505
|
+
revision,
|
|
506
|
+
pathFilter: null,
|
|
507
|
+
resultCount: responseResultCount,
|
|
508
|
+
durationMs: Date.now() - searchStart,
|
|
509
|
+
statusCode: responseStatus,
|
|
510
|
+
success: true,
|
|
511
|
+
metadata: {
|
|
512
|
+
dependencies: dependencyStrings,
|
|
513
|
+
maxResults,
|
|
514
|
+
minScore,
|
|
515
|
+
logAllowed,
|
|
516
|
+
timingsCaptured: true,
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
(0, stats_js_1.recordSearchEvent)({
|
|
523
|
+
searchKind: 'dependencies',
|
|
524
|
+
toolName: 'search_in_dependencies',
|
|
525
|
+
query: text,
|
|
526
|
+
repositoryUrls: [repositoryGitRemoteUrl],
|
|
527
|
+
revision,
|
|
528
|
+
pathFilter: null,
|
|
529
|
+
resultCount: responseResultCount,
|
|
530
|
+
durationMs: Date.now() - searchStart,
|
|
531
|
+
statusCode: responseStatus,
|
|
532
|
+
success: false,
|
|
533
|
+
errorMessage: toErrorMessage(error),
|
|
534
|
+
metadata: {
|
|
535
|
+
dependencies: dependencyStrings,
|
|
536
|
+
maxResults,
|
|
537
|
+
minScore,
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
throw error;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
//# sourceMappingURL=embark-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embark-client.js","sourceRoot":"","sources":["../src/embark-client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AA2CH,8CAsGC;AAKD,gDA6LC;AAYD,kEAmIC;AAKD,oDAsKC;AA3oBD,kDAA0B;AAC1B,8CAA+C;AAC/C,2CAAwC;AACxC,2CAA8D;AAC9D,iDAAuD;AACvD,yCAIoB;AAepB,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;IAChC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,SAAuE,EACvE,eAAqC,EACrC,OAAuB,EACvB,WAA0B,IAAI;IAE9B,IAAI,SAAS,GAAG,MAAM,IAAA,uBAAY,GAAE,CAAC;IACrC,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;IAC3C,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE9B,IAAI,CAAC;QACH,IAAA,qBAAS,EAAC,MAAM,EAAE,2BAA2B,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,YAAY,EAAE,CAAC;YACjB,IAAA,6BAAkB,EAAC;gBACjB,SAAS,EAAE,YAAY,CAAC,SAAS;gBACjC,QAAQ,EAAE,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AAE,cAAc,CAAC,KAAK,CAAC;YACnC,QAAQ,EAAE;gBACR,YAAY,EAAE,iBAAiB;gBAC/B,UAAU;gBACV,QAAQ;aACT;SACF,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git utilities for discovering repository information
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract repository URL from Git remote
|
|
6
|
+
*/
|
|
7
|
+
export declare function getGitRemoteUrl(directory: string): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Convert file:// URI to filesystem path
|
|
10
|
+
*/
|
|
11
|
+
export declare function uriToPath(uri: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a directory is a Git repository
|
|
14
|
+
*/
|
|
15
|
+
export declare function isGitRepository(directory: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Discover Git repositories from a list of roots
|
|
18
|
+
*/
|
|
19
|
+
export declare function discoverRepositories(roots: Array<{
|
|
20
|
+
uri: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}>): Array<{
|
|
23
|
+
path: string;
|
|
24
|
+
url: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Truncate a code snippet at word/separator boundaries to avoid breaking tokens.
|
|
29
|
+
*
|
|
30
|
+
* @param snippet - The code snippet to truncate
|
|
31
|
+
* @param maxLen - Maximum total length including suffix (default: 1500)
|
|
32
|
+
* @param suffix - Suffix to append when truncated (default: "\n … (content truncated)")
|
|
33
|
+
* @returns Truncated snippet with suffix, or original if under maxLen
|
|
34
|
+
*/
|
|
35
|
+
export declare function truncateAtBoundary(snippet: string, maxLen?: number, suffix?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Extract code snippet from a file at a specific revision using git show
|
|
38
|
+
*
|
|
39
|
+
* @param repoPath - Absolute path to the git repository
|
|
40
|
+
* @param relativePath - Path to the file relative to the repository root
|
|
41
|
+
* @param revision - Git revision (commit hash, branch name, etc.)
|
|
42
|
+
* @param startOffset - Start byte offset in the file
|
|
43
|
+
* @param endOffset - End byte offset in the file
|
|
44
|
+
* @returns The code snippet, or null if extraction failed
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractSnippetFromGit(repoPath: string, relativePath: string, revision: string | null, startOffset: number, endOffset: number): string | null;
|
|
47
|
+
//# sourceMappingURL=git-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqBhE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAW1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAwEtI;AAMD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,SAAqB,EAC3B,MAAM,SAAe,GACtB,MAAM,CAoCR;AAGD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CA0Cf"}
|