@probelabs/probe 0.6.0-rc101 → 0.6.0-rc103
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/build/agent/ProbeAgent.js +254 -4
- package/build/agent/index.js +257 -41
- package/build/mcp/index.js +24 -145
- package/build/mcp/index.ts +23 -162
- package/build/tools/system-message.js +7 -1
- package/cjs/agent/ProbeAgent.cjs +202 -11
- package/cjs/index.cjs +214 -23
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +254 -4
- package/src/agent/index.js +50 -18
- package/src/mcp/index.ts +23 -162
- package/src/tools/system-message.js +7 -1
package/src/mcp/index.ts
CHANGED
|
@@ -112,37 +112,19 @@ console.log(`Bin directory: ${binDir}`);
|
|
|
112
112
|
interface SearchCodeArgs {
|
|
113
113
|
path: string;
|
|
114
114
|
query: string | string[];
|
|
115
|
-
filesOnly?: boolean;
|
|
116
|
-
ignore?: string[];
|
|
117
|
-
excludeFilenames?: boolean;
|
|
118
115
|
exact?: boolean;
|
|
119
116
|
maxResults?: number;
|
|
120
117
|
maxTokens?: number;
|
|
121
118
|
allowTests?: boolean;
|
|
122
119
|
session?: string;
|
|
123
|
-
timeout?: number;
|
|
124
120
|
noGitignore?: boolean;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
interface QueryCodeArgs {
|
|
128
|
-
path: string;
|
|
129
|
-
pattern: string;
|
|
130
|
-
language?: string;
|
|
131
|
-
ignore?: string[];
|
|
132
|
-
allowTests?: boolean;
|
|
133
|
-
maxResults?: number;
|
|
134
|
-
format?: 'markdown' | 'plain' | 'json' | 'color';
|
|
135
|
-
timeout?: number;
|
|
136
|
-
noGitignore?: boolean;
|
|
137
|
-
}
|
|
138
123
|
|
|
139
124
|
interface ExtractCodeArgs {
|
|
140
125
|
path: string;
|
|
141
126
|
files: string[];
|
|
142
127
|
allowTests?: boolean;
|
|
143
|
-
contextLines?: number;
|
|
144
|
-
format?: 'markdown' | 'plain' | 'json';
|
|
145
|
-
timeout?: number;
|
|
146
128
|
noGitignore?: boolean;
|
|
147
129
|
}
|
|
148
130
|
|
|
@@ -193,38 +175,22 @@ class ProbeServer {
|
|
|
193
175
|
},
|
|
194
176
|
query: {
|
|
195
177
|
type: 'string',
|
|
196
|
-
description: 'Elastic search query. Supports logical operators (AND, OR, NOT), and grouping with parentheses. Examples: "config", "(term1 OR term2) AND term3"
|
|
197
|
-
},
|
|
198
|
-
filesOnly: {
|
|
199
|
-
type: 'boolean',
|
|
200
|
-
description: 'Skip AST parsing and just output unique files',
|
|
201
|
-
},
|
|
202
|
-
ignore: {
|
|
203
|
-
type: 'array',
|
|
204
|
-
items: { type: 'string' },
|
|
205
|
-
description: 'Custom patterns to ignore (in addition to .gitignore and common patterns)'
|
|
206
|
-
},
|
|
207
|
-
excludeFilenames: {
|
|
208
|
-
type: 'boolean',
|
|
209
|
-
description: 'Exclude filenames from being used for matching'
|
|
178
|
+
description: 'Elastic search query. Supports logical operators (AND, OR, NOT), and grouping with parentheses. For exact matches of specific identifiers, use quotes: "MyFunction", "SpecificStruct", "exact_variable_name". Examples: "config", "(term1 OR term2) AND term3", "getUserData", "struct Config".',
|
|
210
179
|
},
|
|
211
180
|
exact: {
|
|
212
181
|
type: 'boolean',
|
|
213
|
-
description: '
|
|
182
|
+
description: 'When you exactly know what you are looking for, like known function name, struct name, or variable name, set this flag for precise matching'
|
|
214
183
|
},
|
|
215
184
|
allowTests: {
|
|
216
185
|
type: 'boolean',
|
|
217
|
-
description: 'Allow test files and test code blocks in results (
|
|
186
|
+
description: 'Allow test files and test code blocks in results (enabled by default)',
|
|
187
|
+
default: true
|
|
218
188
|
},
|
|
219
189
|
session: {
|
|
220
190
|
type: 'string',
|
|
221
191
|
description: 'Session identifier for caching. Set to "new" if unknown, or want to reset cache. Re-use session ID returned from previous searches',
|
|
222
192
|
default: "new",
|
|
223
193
|
},
|
|
224
|
-
timeout: {
|
|
225
|
-
type: 'number',
|
|
226
|
-
description: 'Timeout for the search operation in seconds (default: 30)',
|
|
227
|
-
},
|
|
228
194
|
noGitignore: {
|
|
229
195
|
type: 'boolean',
|
|
230
196
|
description: 'Skip .gitignore files (will use PROBE_NO_GITIGNORE environment variable if not set)',
|
|
@@ -233,50 +199,6 @@ class ProbeServer {
|
|
|
233
199
|
required: ['path', 'query']
|
|
234
200
|
},
|
|
235
201
|
},
|
|
236
|
-
{
|
|
237
|
-
name: 'query_code',
|
|
238
|
-
description: "Search code using ast-grep structural pattern matching. Use this tool to find specific code structures like functions, classes, or methods.",
|
|
239
|
-
inputSchema: {
|
|
240
|
-
type: 'object',
|
|
241
|
-
properties: {
|
|
242
|
-
path: {
|
|
243
|
-
type: 'string',
|
|
244
|
-
description: 'Absolute path to the directory to search in (e.g., "/Users/username/projects/myproject").',
|
|
245
|
-
},
|
|
246
|
-
pattern: {
|
|
247
|
-
type: 'string',
|
|
248
|
-
description: 'The ast-grep pattern to search for. Examples: "fn $NAME($$$PARAMS) $$$BODY" for Rust functions, "def $NAME($$$PARAMS): $$$BODY" for Python functions.',
|
|
249
|
-
},
|
|
250
|
-
language: {
|
|
251
|
-
type: 'string',
|
|
252
|
-
description: 'The programming language to search in. If not specified, the tool will try to infer the language from file extensions. Supported languages: rust, javascript, typescript, python, go, c, cpp, java, ruby, php, swift, csharp, yaml.',
|
|
253
|
-
},
|
|
254
|
-
ignore: {
|
|
255
|
-
type: 'array',
|
|
256
|
-
items: { type: 'string' },
|
|
257
|
-
description: 'Custom patterns to ignore (in addition to common patterns)',
|
|
258
|
-
},
|
|
259
|
-
maxResults: {
|
|
260
|
-
type: 'number',
|
|
261
|
-
description: 'Maximum number of results to return'
|
|
262
|
-
},
|
|
263
|
-
format: {
|
|
264
|
-
type: 'string',
|
|
265
|
-
enum: ['markdown', 'plain', 'json', 'color'],
|
|
266
|
-
description: 'Output format for the query results'
|
|
267
|
-
},
|
|
268
|
-
timeout: {
|
|
269
|
-
type: 'number',
|
|
270
|
-
description: 'Timeout for the query operation in seconds (default: 30)',
|
|
271
|
-
},
|
|
272
|
-
noGitignore: {
|
|
273
|
-
type: 'boolean',
|
|
274
|
-
description: 'Skip .gitignore files (will use PROBE_NO_GITIGNORE environment variable if not set)',
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
required: ['path', 'pattern']
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
202
|
{
|
|
281
203
|
name: 'extract_code',
|
|
282
204
|
description: "Extract code blocks from files based on line number, or symbol name. Fetch full file when line number is not provided.",
|
|
@@ -294,22 +216,8 @@ class ProbeServer {
|
|
|
294
216
|
},
|
|
295
217
|
allowTests: {
|
|
296
218
|
type: 'boolean',
|
|
297
|
-
description: 'Allow test files and test code blocks in results (
|
|
298
|
-
|
|
299
|
-
contextLines: {
|
|
300
|
-
type: 'number',
|
|
301
|
-
description: 'Number of context lines to include before and after the extracted block when AST parsing fails to find a suitable node',
|
|
302
|
-
default: 0
|
|
303
|
-
},
|
|
304
|
-
format: {
|
|
305
|
-
type: 'string',
|
|
306
|
-
enum: ['markdown', 'plain', 'json'],
|
|
307
|
-
description: 'Output format for the extracted code',
|
|
308
|
-
default: 'markdown'
|
|
309
|
-
},
|
|
310
|
-
timeout: {
|
|
311
|
-
type: 'number',
|
|
312
|
-
description: 'Timeout for the extract operation in seconds (default: 30)',
|
|
219
|
+
description: 'Allow test files and test code blocks in results (enabled by default)',
|
|
220
|
+
default: true
|
|
313
221
|
},
|
|
314
222
|
noGitignore: {
|
|
315
223
|
type: 'boolean',
|
|
@@ -323,8 +231,8 @@ class ProbeServer {
|
|
|
323
231
|
}));
|
|
324
232
|
|
|
325
233
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
326
|
-
if (request.params.name !== 'search_code' && request.params.name !== '
|
|
327
|
-
request.params.name !== 'probe' && request.params.name !== '
|
|
234
|
+
if (request.params.name !== 'search_code' && request.params.name !== 'extract_code' &&
|
|
235
|
+
request.params.name !== 'probe' && request.params.name !== 'extract') {
|
|
328
236
|
throw new McpError(
|
|
329
237
|
ErrorCode.MethodNotFound,
|
|
330
238
|
`Unknown tool: ${request.params.name}`
|
|
@@ -356,9 +264,6 @@ class ProbeServer {
|
|
|
356
264
|
}
|
|
357
265
|
|
|
358
266
|
result = await this.executeCodeSearch(args);
|
|
359
|
-
} else if (request.params.name === 'query_code' || request.params.name === 'query') {
|
|
360
|
-
const args = request.params.arguments as unknown as QueryCodeArgs;
|
|
361
|
-
result = await this.executeCodeQuery(args);
|
|
362
267
|
} else { // extract_code or extract
|
|
363
268
|
const args = request.params.arguments as unknown as ExtractCodeArgs;
|
|
364
269
|
result = await this.executeCodeExtract(args);
|
|
@@ -409,13 +314,15 @@ class ProbeServer {
|
|
|
409
314
|
};
|
|
410
315
|
|
|
411
316
|
// Add optional parameters only if they exist
|
|
412
|
-
if (args.filesOnly !== undefined) options.filesOnly = args.filesOnly;
|
|
413
|
-
if (args.ignore !== undefined) options.ignore = args.ignore;
|
|
414
|
-
if (args.excludeFilenames !== undefined) options.excludeFilenames = args.excludeFilenames;
|
|
415
317
|
if (args.exact !== undefined) options.exact = args.exact;
|
|
416
318
|
if (args.maxResults !== undefined) options.maxResults = args.maxResults;
|
|
417
319
|
if (args.maxTokens !== undefined) options.maxTokens = args.maxTokens;
|
|
418
|
-
|
|
320
|
+
// Set allowTests to true by default if not specified
|
|
321
|
+
if (args.allowTests !== undefined) {
|
|
322
|
+
options.allowTests = args.allowTests;
|
|
323
|
+
} else {
|
|
324
|
+
options.allowTests = true;
|
|
325
|
+
}
|
|
419
326
|
// Use noGitignore from args, or fall back to PROBE_NO_GITIGNORE environment variable
|
|
420
327
|
if (args.noGitignore !== undefined) {
|
|
421
328
|
options.noGitignore = args.noGitignore;
|
|
@@ -427,12 +334,6 @@ class ProbeServer {
|
|
|
427
334
|
} else {
|
|
428
335
|
options.session = "new";
|
|
429
336
|
}
|
|
430
|
-
// Use timeout from args, or fall back to instance default
|
|
431
|
-
if (args.timeout !== undefined) {
|
|
432
|
-
options.timeout = args.timeout;
|
|
433
|
-
} else if (this.defaultTimeout !== undefined) {
|
|
434
|
-
options.timeout = this.defaultTimeout;
|
|
435
|
-
}
|
|
436
337
|
|
|
437
338
|
// Handle format options
|
|
438
339
|
if (this.defaultFormat === 'outline-xml') {
|
|
@@ -467,50 +368,6 @@ class ProbeServer {
|
|
|
467
368
|
}
|
|
468
369
|
}
|
|
469
370
|
|
|
470
|
-
private async executeCodeQuery(args: QueryCodeArgs): Promise<string> {
|
|
471
|
-
try {
|
|
472
|
-
// Validate required parameters
|
|
473
|
-
if (!args.path) {
|
|
474
|
-
throw new Error("Path is required");
|
|
475
|
-
}
|
|
476
|
-
if (!args.pattern) {
|
|
477
|
-
throw new Error("Pattern is required");
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// Create a single options object with both pattern and path
|
|
481
|
-
const options: any = {
|
|
482
|
-
path: args.path,
|
|
483
|
-
pattern: args.pattern,
|
|
484
|
-
language: args.language,
|
|
485
|
-
ignore: args.ignore,
|
|
486
|
-
allowTests: args.allowTests,
|
|
487
|
-
maxResults: args.maxResults,
|
|
488
|
-
format: args.format,
|
|
489
|
-
timeout: args.timeout || this.defaultTimeout
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
// Use noGitignore from args, or fall back to PROBE_NO_GITIGNORE environment variable
|
|
493
|
-
if (args.noGitignore !== undefined) {
|
|
494
|
-
options.noGitignore = args.noGitignore;
|
|
495
|
-
} else if (process.env.PROBE_NO_GITIGNORE) {
|
|
496
|
-
options.noGitignore = process.env.PROBE_NO_GITIGNORE === 'true';
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
console.log("Executing query with options:", JSON.stringify({
|
|
500
|
-
path: options.path,
|
|
501
|
-
pattern: options.pattern
|
|
502
|
-
}));
|
|
503
|
-
|
|
504
|
-
const result = await query(options);
|
|
505
|
-
return result;
|
|
506
|
-
} catch (error: any) {
|
|
507
|
-
console.error('Error executing code query:', error);
|
|
508
|
-
throw new McpError(
|
|
509
|
-
'MethodNotFound' as unknown as ErrorCode,
|
|
510
|
-
`Error executing code query: ${error.message || String(error)}`
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
371
|
|
|
515
372
|
private async executeCodeExtract(args: ExtractCodeArgs): Promise<string> {
|
|
516
373
|
try {
|
|
@@ -526,12 +383,16 @@ class ProbeServer {
|
|
|
526
383
|
const options: any = {
|
|
527
384
|
files: args.files,
|
|
528
385
|
path: args.path,
|
|
529
|
-
|
|
530
|
-
contextLines: args.contextLines,
|
|
531
|
-
format: args.format,
|
|
532
|
-
timeout: args.timeout || this.defaultTimeout
|
|
386
|
+
format: 'xml'
|
|
533
387
|
};
|
|
534
388
|
|
|
389
|
+
// Set allowTests to true by default if not specified
|
|
390
|
+
if (args.allowTests !== undefined) {
|
|
391
|
+
options.allowTests = args.allowTests;
|
|
392
|
+
} else {
|
|
393
|
+
options.allowTests = true;
|
|
394
|
+
}
|
|
395
|
+
|
|
535
396
|
// Use noGitignore from args, or fall back to PROBE_NO_GITIGNORE environment variable
|
|
536
397
|
if (args.noGitignore !== undefined) {
|
|
537
398
|
options.noGitignore = args.noGitignore;
|
|
@@ -604,5 +465,5 @@ class ProbeServer {
|
|
|
604
465
|
}
|
|
605
466
|
}
|
|
606
467
|
|
|
607
|
-
const server = new ProbeServer(cliConfig.timeout, cliConfig.format);
|
|
468
|
+
const server = new ProbeServer(cliConfig.timeout, cliConfig.format || 'outline-xml');
|
|
608
469
|
server.run().catch(console.error);
|
|
@@ -73,13 +73,19 @@ For GitHub-compatible mermaid diagrams, avoid single quotes and parentheses in n
|
|
|
73
73
|
|
|
74
74
|
**Rules:**
|
|
75
75
|
- NO single quotes in any node labels: 'text' → "text" or text
|
|
76
|
-
- NO parentheses in square brackets: [Text (detail)] → [Text - detail]
|
|
76
|
+
- NO parentheses in square brackets: [Text (detail)] → [Text - detail]
|
|
77
77
|
- NO complex expressions in diamonds: {a && b} → {condition}
|
|
78
|
+
- NO HTML tags in node labels: [<pre>code</pre>] → ["code block"] or [Code Block]
|
|
78
79
|
- USE single quotes for styles and classes: classDef highlight fill:'#ff9999'
|
|
80
|
+
- CRITICAL: When using quotes in node labels, place them INSIDE the brackets: ["quoted text"], NOT [quoted text"]
|
|
79
81
|
|
|
80
82
|
**Examples:**
|
|
81
83
|
- ✅ [Load Config] ["Run command"] {Valid?}
|
|
84
|
+
- ✅ ["depends_on: [generate-items]"] (correct quote placement)
|
|
85
|
+
- ✅ ["Code Block"] (clean text instead of HTML)
|
|
82
86
|
- ❌ [Load (config)] [Run 'command'] {isValid('x')}
|
|
87
|
+
- ❌ [depends_on: [generate-items"] (incorrect quote placement - quote ends inside bracket)
|
|
88
|
+
- ❌ [<pre>depends_on: [generate-items]</pre>] (HTML tags in node labels)
|
|
83
89
|
|
|
84
90
|
**Diagram Type Selection:**
|
|
85
91
|
|