@probelabs/probe 0.6.0-rc76 → 0.6.0-rc77
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 +109 -6
- package/build/agent/index.js +123 -16
- package/build/mcp/index.js +17 -2
- package/build/mcp/index.ts +21 -6
- package/build/search.js +11 -3
- package/build/tools/vercel.js +26 -7
- package/cjs/agent/ProbeAgent.cjs +115 -14
- package/cjs/index.cjs +115 -14
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +109 -6
- package/src/agent/index.js +7 -2
- package/src/mcp/index.ts +21 -6
- package/src/search.js +11 -3
- package/src/tools/vercel.js +26 -7
|
@@ -54,6 +54,7 @@ export class ProbeAgent {
|
|
|
54
54
|
* @param {string} [options.provider] - Force specific AI provider
|
|
55
55
|
* @param {string} [options.model] - Override model name
|
|
56
56
|
* @param {boolean} [options.debug] - Enable debug mode
|
|
57
|
+
* @param {boolean} [options.outline] - Enable outline-xml format for search results
|
|
57
58
|
*/
|
|
58
59
|
constructor(options = {}) {
|
|
59
60
|
// Basic configuration
|
|
@@ -64,6 +65,7 @@ export class ProbeAgent {
|
|
|
64
65
|
this.debug = options.debug || process.env.DEBUG === '1';
|
|
65
66
|
this.cancelled = false;
|
|
66
67
|
this.tracer = options.tracer || null;
|
|
68
|
+
this.outline = !!options.outline;
|
|
67
69
|
|
|
68
70
|
// Search configuration
|
|
69
71
|
this.allowedFolders = options.path ? [options.path] : [process.cwd()];
|
|
@@ -103,7 +105,8 @@ export class ProbeAgent {
|
|
|
103
105
|
sessionId: this.sessionId,
|
|
104
106
|
debug: this.debug,
|
|
105
107
|
defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
|
|
106
|
-
allowedFolders: this.allowedFolders
|
|
108
|
+
allowedFolders: this.allowedFolders,
|
|
109
|
+
outline: this.outline
|
|
107
110
|
};
|
|
108
111
|
|
|
109
112
|
// Create base tools
|
|
@@ -1010,15 +1013,115 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
1010
1013
|
console.log(`[DEBUG] Mermaid validation: attempt_completion result validation completed (no fixes needed)`);
|
|
1011
1014
|
}
|
|
1012
1015
|
|
|
1013
|
-
// Validate JSON
|
|
1016
|
+
// Validate and potentially correct JSON for attempt_completion results
|
|
1014
1017
|
if (isJsonSchema(options.schema)) {
|
|
1015
1018
|
if (this.debug) {
|
|
1016
|
-
console.log(`[DEBUG] JSON validation:
|
|
1019
|
+
console.log(`[DEBUG] JSON validation: Starting validation process for attempt_completion result`);
|
|
1020
|
+
console.log(`[DEBUG] JSON validation: Response length: ${finalResult.length} chars`);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// Record JSON validation start in telemetry
|
|
1024
|
+
if (this.tracer) {
|
|
1025
|
+
this.tracer.recordJsonValidationEvent('attempt_completion_started', {
|
|
1026
|
+
'json_validation.response_length': finalResult.length,
|
|
1027
|
+
'json_validation.schema_type': 'JSON',
|
|
1028
|
+
'json_validation.context': 'attempt_completion'
|
|
1029
|
+
});
|
|
1017
1030
|
}
|
|
1018
|
-
|
|
1031
|
+
|
|
1032
|
+
let validation = validateJsonResponse(finalResult, { debug: this.debug });
|
|
1033
|
+
let retryCount = 0;
|
|
1034
|
+
const maxRetries = 3;
|
|
1035
|
+
|
|
1036
|
+
// First check if the response is valid JSON but is actually a schema definition
|
|
1037
|
+
if (validation.isValid && isJsonSchemaDefinition(finalResult, { debug: this.debug })) {
|
|
1038
|
+
if (this.debug) {
|
|
1039
|
+
console.log(`[DEBUG] JSON validation: attempt_completion response is a JSON schema definition instead of data, correcting...`);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// Use specialized correction prompt for schema definition confusion
|
|
1043
|
+
const schemaDefinitionPrompt = createSchemaDefinitionCorrectionPrompt(
|
|
1044
|
+
finalResult,
|
|
1045
|
+
options.schema,
|
|
1046
|
+
0
|
|
1047
|
+
);
|
|
1048
|
+
|
|
1049
|
+
finalResult = await this.answer(schemaDefinitionPrompt, [], {
|
|
1050
|
+
...options,
|
|
1051
|
+
_schemaFormatted: true
|
|
1052
|
+
});
|
|
1053
|
+
finalResult = cleanSchemaResponse(finalResult);
|
|
1054
|
+
validation = validateJsonResponse(finalResult);
|
|
1055
|
+
retryCount = 1; // Start at 1 since we already did one correction
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
while (!validation.isValid && retryCount < maxRetries) {
|
|
1059
|
+
if (this.debug) {
|
|
1060
|
+
console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);
|
|
1061
|
+
console.log(`[DEBUG] JSON validation: Invalid response sample: ${finalResult.substring(0, 300)}${finalResult.length > 300 ? '...' : ''}`);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// Check if the invalid response is actually a schema definition
|
|
1065
|
+
let correctionPrompt;
|
|
1066
|
+
try {
|
|
1067
|
+
if (isJsonSchemaDefinition(finalResult, { debug: this.debug })) {
|
|
1068
|
+
if (this.debug) {
|
|
1069
|
+
console.log(`[DEBUG] JSON validation: attempt_completion response is still a schema definition, using specialized correction`);
|
|
1070
|
+
}
|
|
1071
|
+
correctionPrompt = createSchemaDefinitionCorrectionPrompt(
|
|
1072
|
+
finalResult,
|
|
1073
|
+
options.schema,
|
|
1074
|
+
retryCount
|
|
1075
|
+
);
|
|
1076
|
+
} else {
|
|
1077
|
+
correctionPrompt = createJsonCorrectionPrompt(
|
|
1078
|
+
finalResult,
|
|
1079
|
+
options.schema,
|
|
1080
|
+
validation.error,
|
|
1081
|
+
retryCount
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
} catch (error) {
|
|
1085
|
+
// If we can't parse to check if it's a schema definition, use regular correction
|
|
1086
|
+
correctionPrompt = createJsonCorrectionPrompt(
|
|
1087
|
+
finalResult,
|
|
1088
|
+
options.schema,
|
|
1089
|
+
validation.error,
|
|
1090
|
+
retryCount
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
finalResult = await this.answer(correctionPrompt, [], {
|
|
1095
|
+
...options,
|
|
1096
|
+
_schemaFormatted: true
|
|
1097
|
+
});
|
|
1098
|
+
finalResult = cleanSchemaResponse(finalResult);
|
|
1099
|
+
|
|
1100
|
+
// Validate the corrected response
|
|
1101
|
+
validation = validateJsonResponse(finalResult, { debug: this.debug });
|
|
1102
|
+
retryCount++;
|
|
1103
|
+
|
|
1104
|
+
if (this.debug) {
|
|
1105
|
+
if (validation.isValid) {
|
|
1106
|
+
console.log(`[DEBUG] JSON validation: attempt_completion correction successful on attempt ${retryCount}`);
|
|
1107
|
+
} else {
|
|
1108
|
+
console.log(`[DEBUG] JSON validation: attempt_completion correction failed on attempt ${retryCount}: ${validation.error}`);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// Record final validation result
|
|
1114
|
+
if (this.tracer) {
|
|
1115
|
+
this.tracer.recordJsonValidationEvent('attempt_completion_completed', {
|
|
1116
|
+
'json_validation.success': validation.isValid,
|
|
1117
|
+
'json_validation.retry_count': retryCount,
|
|
1118
|
+
'json_validation.final_response_length': finalResult.length
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1019
1122
|
if (!validation.isValid && this.debug) {
|
|
1020
|
-
console.log(`[DEBUG] JSON validation: attempt_completion result validation failed: ${validation.error}`);
|
|
1021
|
-
console.log(`[DEBUG] JSON validation: attempt_completion response: ${finalResult.substring(0, 500)}${finalResult.length > 500 ? '...' : ''}`);
|
|
1123
|
+
console.log(`[DEBUG] JSON validation: attempt_completion result validation failed after ${maxRetries} attempts: ${validation.error}`);
|
|
1124
|
+
console.log(`[DEBUG] JSON validation: Final attempt_completion response: ${finalResult.substring(0, 500)}${finalResult.length > 500 ? '...' : ''}`);
|
|
1022
1125
|
} else if (validation.isValid && this.debug) {
|
|
1023
1126
|
console.log(`[DEBUG] JSON validation: attempt_completion result validation successful`);
|
|
1024
1127
|
}
|
package/build/agent/index.js
CHANGED
|
@@ -1103,8 +1103,12 @@ async function search(options) {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
const binaryPath = await getBinaryPath(options.binaryOptions || {});
|
|
1105
1105
|
const cliArgs = buildCliArgs(options, SEARCH_FLAG_MAP);
|
|
1106
|
-
if (options.json) {
|
|
1106
|
+
if (options.json && !options.format) {
|
|
1107
1107
|
cliArgs.push("--format", "json");
|
|
1108
|
+
} else if (options.format) {
|
|
1109
|
+
if (options.format === "json") {
|
|
1110
|
+
options.json = true;
|
|
1111
|
+
}
|
|
1108
1112
|
}
|
|
1109
1113
|
if (!options.maxTokens) {
|
|
1110
1114
|
options.maxTokens = 1e4;
|
|
@@ -1229,7 +1233,8 @@ var init_search = __esm({
|
|
|
1229
1233
|
mergeThreshold: "--merge-threshold",
|
|
1230
1234
|
session: "--session",
|
|
1231
1235
|
timeout: "--timeout",
|
|
1232
|
-
language: "--language"
|
|
1236
|
+
language: "--language",
|
|
1237
|
+
format: "--format"
|
|
1233
1238
|
};
|
|
1234
1239
|
}
|
|
1235
1240
|
});
|
|
@@ -1876,7 +1881,7 @@ var init_vercel = __esm({
|
|
|
1876
1881
|
init_delegate();
|
|
1877
1882
|
init_common();
|
|
1878
1883
|
searchTool = (options = {}) => {
|
|
1879
|
-
const { sessionId, maxTokens = 1e4, debug = false } = options;
|
|
1884
|
+
const { sessionId, maxTokens = 1e4, debug = false, outline = false } = options;
|
|
1880
1885
|
return tool({
|
|
1881
1886
|
name: "search",
|
|
1882
1887
|
description: searchDescription,
|
|
@@ -1894,10 +1899,10 @@ var init_vercel = __esm({
|
|
|
1894
1899
|
if (debug) {
|
|
1895
1900
|
console.error(`Executing search with query: "${searchQuery}", path: "${searchPath}", exact: ${exact ? "true" : "false"}, language: ${language || "all"}, session: ${sessionId || "none"}`);
|
|
1896
1901
|
}
|
|
1897
|
-
const
|
|
1902
|
+
const searchOptions = {
|
|
1898
1903
|
query: searchQuery,
|
|
1899
1904
|
path: searchPath,
|
|
1900
|
-
allow_tests,
|
|
1905
|
+
allowTests: allow_tests,
|
|
1901
1906
|
exact,
|
|
1902
1907
|
json: false,
|
|
1903
1908
|
maxTokens: effectiveMaxTokens,
|
|
@@ -1905,7 +1910,11 @@ var init_vercel = __esm({
|
|
|
1905
1910
|
// Pass session ID if provided
|
|
1906
1911
|
language
|
|
1907
1912
|
// Pass language parameter if provided
|
|
1908
|
-
}
|
|
1913
|
+
};
|
|
1914
|
+
if (outline) {
|
|
1915
|
+
searchOptions.format = "outline-xml";
|
|
1916
|
+
}
|
|
1917
|
+
const results = await search(searchOptions);
|
|
1909
1918
|
return results;
|
|
1910
1919
|
} catch (error) {
|
|
1911
1920
|
console.error("Error executing search command:", error);
|
|
@@ -1948,7 +1957,7 @@ var init_vercel = __esm({
|
|
|
1948
1957
|
});
|
|
1949
1958
|
};
|
|
1950
1959
|
extractTool = (options = {}) => {
|
|
1951
|
-
const { debug = false } = options;
|
|
1960
|
+
const { debug = false, outline = false } = options;
|
|
1952
1961
|
return tool({
|
|
1953
1962
|
name: "extract",
|
|
1954
1963
|
description: extractDescription,
|
|
@@ -1981,19 +1990,27 @@ var init_vercel = __esm({
|
|
|
1981
1990
|
if (debug) {
|
|
1982
1991
|
console.error(`Created temporary file for input content: ${tempFilePath}`);
|
|
1983
1992
|
}
|
|
1993
|
+
let effectiveFormat = format;
|
|
1994
|
+
if (outline && format === "outline-xml") {
|
|
1995
|
+
effectiveFormat = "xml";
|
|
1996
|
+
}
|
|
1984
1997
|
extractOptions = {
|
|
1985
1998
|
inputFile: tempFilePath,
|
|
1986
1999
|
allowTests: allow_tests,
|
|
1987
2000
|
contextLines: context_lines,
|
|
1988
|
-
format
|
|
2001
|
+
format: effectiveFormat
|
|
1989
2002
|
};
|
|
1990
2003
|
} else if (file_path) {
|
|
1991
2004
|
const files = [file_path];
|
|
2005
|
+
let effectiveFormat = format;
|
|
2006
|
+
if (outline && format === "outline-xml") {
|
|
2007
|
+
effectiveFormat = "xml";
|
|
2008
|
+
}
|
|
1992
2009
|
extractOptions = {
|
|
1993
2010
|
files,
|
|
1994
2011
|
allowTests: allow_tests,
|
|
1995
2012
|
contextLines: context_lines,
|
|
1996
|
-
format
|
|
2013
|
+
format: effectiveFormat
|
|
1997
2014
|
};
|
|
1998
2015
|
} else {
|
|
1999
2016
|
throw new Error("Either file_path or input_content must be provided");
|
|
@@ -3709,6 +3726,7 @@ var init_ProbeAgent = __esm({
|
|
|
3709
3726
|
* @param {string} [options.provider] - Force specific AI provider
|
|
3710
3727
|
* @param {string} [options.model] - Override model name
|
|
3711
3728
|
* @param {boolean} [options.debug] - Enable debug mode
|
|
3729
|
+
* @param {boolean} [options.outline] - Enable outline-xml format for search results
|
|
3712
3730
|
*/
|
|
3713
3731
|
constructor(options = {}) {
|
|
3714
3732
|
this.sessionId = options.sessionId || randomUUID4();
|
|
@@ -3718,6 +3736,7 @@ var init_ProbeAgent = __esm({
|
|
|
3718
3736
|
this.debug = options.debug || process.env.DEBUG === "1";
|
|
3719
3737
|
this.cancelled = false;
|
|
3720
3738
|
this.tracer = options.tracer || null;
|
|
3739
|
+
this.outline = !!options.outline;
|
|
3721
3740
|
this.allowedFolders = options.path ? [options.path] : [process.cwd()];
|
|
3722
3741
|
this.clientApiProvider = options.provider || null;
|
|
3723
3742
|
this.clientApiKey = null;
|
|
@@ -3741,7 +3760,8 @@ var init_ProbeAgent = __esm({
|
|
|
3741
3760
|
sessionId: this.sessionId,
|
|
3742
3761
|
debug: this.debug,
|
|
3743
3762
|
defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
|
|
3744
|
-
allowedFolders: this.allowedFolders
|
|
3763
|
+
allowedFolders: this.allowedFolders,
|
|
3764
|
+
outline: this.outline
|
|
3745
3765
|
};
|
|
3746
3766
|
const baseTools = createTools(configOptions);
|
|
3747
3767
|
const wrappedTools = createWrappedTools(baseTools);
|
|
@@ -4510,12 +4530,93 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
4510
4530
|
}
|
|
4511
4531
|
if (isJsonSchema(options.schema)) {
|
|
4512
4532
|
if (this.debug) {
|
|
4513
|
-
console.log(`[DEBUG] JSON validation:
|
|
4533
|
+
console.log(`[DEBUG] JSON validation: Starting validation process for attempt_completion result`);
|
|
4534
|
+
console.log(`[DEBUG] JSON validation: Response length: ${finalResult.length} chars`);
|
|
4535
|
+
}
|
|
4536
|
+
if (this.tracer) {
|
|
4537
|
+
this.tracer.recordJsonValidationEvent("attempt_completion_started", {
|
|
4538
|
+
"json_validation.response_length": finalResult.length,
|
|
4539
|
+
"json_validation.schema_type": "JSON",
|
|
4540
|
+
"json_validation.context": "attempt_completion"
|
|
4541
|
+
});
|
|
4542
|
+
}
|
|
4543
|
+
let validation = validateJsonResponse(finalResult, { debug: this.debug });
|
|
4544
|
+
let retryCount = 0;
|
|
4545
|
+
const maxRetries = 3;
|
|
4546
|
+
if (validation.isValid && isJsonSchemaDefinition(finalResult, { debug: this.debug })) {
|
|
4547
|
+
if (this.debug) {
|
|
4548
|
+
console.log(`[DEBUG] JSON validation: attempt_completion response is a JSON schema definition instead of data, correcting...`);
|
|
4549
|
+
}
|
|
4550
|
+
const schemaDefinitionPrompt = createSchemaDefinitionCorrectionPrompt(
|
|
4551
|
+
finalResult,
|
|
4552
|
+
options.schema,
|
|
4553
|
+
0
|
|
4554
|
+
);
|
|
4555
|
+
finalResult = await this.answer(schemaDefinitionPrompt, [], {
|
|
4556
|
+
...options,
|
|
4557
|
+
_schemaFormatted: true
|
|
4558
|
+
});
|
|
4559
|
+
finalResult = cleanSchemaResponse(finalResult);
|
|
4560
|
+
validation = validateJsonResponse(finalResult);
|
|
4561
|
+
retryCount = 1;
|
|
4562
|
+
}
|
|
4563
|
+
while (!validation.isValid && retryCount < maxRetries) {
|
|
4564
|
+
if (this.debug) {
|
|
4565
|
+
console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);
|
|
4566
|
+
console.log(`[DEBUG] JSON validation: Invalid response sample: ${finalResult.substring(0, 300)}${finalResult.length > 300 ? "..." : ""}`);
|
|
4567
|
+
}
|
|
4568
|
+
let correctionPrompt;
|
|
4569
|
+
try {
|
|
4570
|
+
if (isJsonSchemaDefinition(finalResult, { debug: this.debug })) {
|
|
4571
|
+
if (this.debug) {
|
|
4572
|
+
console.log(`[DEBUG] JSON validation: attempt_completion response is still a schema definition, using specialized correction`);
|
|
4573
|
+
}
|
|
4574
|
+
correctionPrompt = createSchemaDefinitionCorrectionPrompt(
|
|
4575
|
+
finalResult,
|
|
4576
|
+
options.schema,
|
|
4577
|
+
retryCount
|
|
4578
|
+
);
|
|
4579
|
+
} else {
|
|
4580
|
+
correctionPrompt = createJsonCorrectionPrompt(
|
|
4581
|
+
finalResult,
|
|
4582
|
+
options.schema,
|
|
4583
|
+
validation.error,
|
|
4584
|
+
retryCount
|
|
4585
|
+
);
|
|
4586
|
+
}
|
|
4587
|
+
} catch (error) {
|
|
4588
|
+
correctionPrompt = createJsonCorrectionPrompt(
|
|
4589
|
+
finalResult,
|
|
4590
|
+
options.schema,
|
|
4591
|
+
validation.error,
|
|
4592
|
+
retryCount
|
|
4593
|
+
);
|
|
4594
|
+
}
|
|
4595
|
+
finalResult = await this.answer(correctionPrompt, [], {
|
|
4596
|
+
...options,
|
|
4597
|
+
_schemaFormatted: true
|
|
4598
|
+
});
|
|
4599
|
+
finalResult = cleanSchemaResponse(finalResult);
|
|
4600
|
+
validation = validateJsonResponse(finalResult, { debug: this.debug });
|
|
4601
|
+
retryCount++;
|
|
4602
|
+
if (this.debug) {
|
|
4603
|
+
if (validation.isValid) {
|
|
4604
|
+
console.log(`[DEBUG] JSON validation: attempt_completion correction successful on attempt ${retryCount}`);
|
|
4605
|
+
} else {
|
|
4606
|
+
console.log(`[DEBUG] JSON validation: attempt_completion correction failed on attempt ${retryCount}: ${validation.error}`);
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
if (this.tracer) {
|
|
4611
|
+
this.tracer.recordJsonValidationEvent("attempt_completion_completed", {
|
|
4612
|
+
"json_validation.success": validation.isValid,
|
|
4613
|
+
"json_validation.retry_count": retryCount,
|
|
4614
|
+
"json_validation.final_response_length": finalResult.length
|
|
4615
|
+
});
|
|
4514
4616
|
}
|
|
4515
|
-
const validation = validateJsonResponse(finalResult, { debug: this.debug });
|
|
4516
4617
|
if (!validation.isValid && this.debug) {
|
|
4517
|
-
console.log(`[DEBUG] JSON validation: attempt_completion result validation failed: ${validation.error}`);
|
|
4518
|
-
console.log(`[DEBUG] JSON validation: attempt_completion response: ${finalResult.substring(0, 500)}${finalResult.length > 500 ? "..." : ""}`);
|
|
4618
|
+
console.log(`[DEBUG] JSON validation: attempt_completion result validation failed after ${maxRetries} attempts: ${validation.error}`);
|
|
4619
|
+
console.log(`[DEBUG] JSON validation: Final attempt_completion response: ${finalResult.substring(0, 500)}${finalResult.length > 500 ? "..." : ""}`);
|
|
4519
4620
|
} else if (validation.isValid && this.debug) {
|
|
4520
4621
|
console.log(`[DEBUG] JSON validation: attempt_completion result validation successful`);
|
|
4521
4622
|
}
|
|
@@ -5316,8 +5417,10 @@ function parseArgs() {
|
|
|
5316
5417
|
traceFile: void 0,
|
|
5317
5418
|
traceRemote: void 0,
|
|
5318
5419
|
traceConsole: false,
|
|
5319
|
-
useStdin: false
|
|
5420
|
+
useStdin: false,
|
|
5320
5421
|
// New flag to indicate stdin should be used
|
|
5422
|
+
outline: false
|
|
5423
|
+
// New flag to enable outline format
|
|
5321
5424
|
};
|
|
5322
5425
|
for (let i = 0; i < args.length; i++) {
|
|
5323
5426
|
const arg = args[i];
|
|
@@ -5351,6 +5454,8 @@ function parseArgs() {
|
|
|
5351
5454
|
config.traceRemote = args[++i];
|
|
5352
5455
|
} else if (arg === "--trace-console") {
|
|
5353
5456
|
config.traceConsole = true;
|
|
5457
|
+
} else if (arg === "--outline") {
|
|
5458
|
+
config.outline = true;
|
|
5354
5459
|
} else if (!arg.startsWith("--") && !config.question) {
|
|
5355
5460
|
config.question = arg;
|
|
5356
5461
|
}
|
|
@@ -5380,6 +5485,7 @@ Options:
|
|
|
5380
5485
|
--model <name> Override model name
|
|
5381
5486
|
--allow-edit Enable code modification capabilities
|
|
5382
5487
|
--verbose Enable verbose output
|
|
5488
|
+
--outline Use outline-xml format for code search results
|
|
5383
5489
|
--mcp Run as MCP server
|
|
5384
5490
|
--acp Run as ACP server (Agent Client Protocol)
|
|
5385
5491
|
--max-iterations <number> Max tool iterations (default: 30)
|
|
@@ -5719,7 +5825,8 @@ async function main() {
|
|
|
5719
5825
|
customPrompt: systemPrompt,
|
|
5720
5826
|
allowEdit: config.allowEdit,
|
|
5721
5827
|
debug: config.verbose,
|
|
5722
|
-
tracer: appTracer
|
|
5828
|
+
tracer: appTracer,
|
|
5829
|
+
outline: config.outline
|
|
5723
5830
|
};
|
|
5724
5831
|
const agent = new ProbeAgent(agentConfig);
|
|
5725
5832
|
let result;
|
package/build/mcp/index.js
CHANGED
|
@@ -25,6 +25,11 @@ function parseArgs() {
|
|
|
25
25
|
}
|
|
26
26
|
i++; // Skip the next argument
|
|
27
27
|
}
|
|
28
|
+
else if (args[i] === '--format' && i + 1 < args.length) {
|
|
29
|
+
config.format = args[i + 1];
|
|
30
|
+
console.error(`Format set to ${config.format}`);
|
|
31
|
+
i++; // Skip the next argument
|
|
32
|
+
}
|
|
28
33
|
else if (args[i] === '--help' || args[i] === '-h') {
|
|
29
34
|
console.log(`
|
|
30
35
|
Probe MCP Server
|
|
@@ -34,6 +39,7 @@ Usage:
|
|
|
34
39
|
|
|
35
40
|
Options:
|
|
36
41
|
--timeout, -t <seconds> Set timeout for search operations (default: 30)
|
|
42
|
+
--format <format> Set output format (json, outline-xml, etc.)
|
|
37
43
|
--help, -h Show this help message
|
|
38
44
|
`);
|
|
39
45
|
process.exit(0);
|
|
@@ -87,8 +93,9 @@ if (packageVersion === '0.0.0') {
|
|
|
87
93
|
const binDir = path.resolve(__dirname, '..', 'bin');
|
|
88
94
|
console.log(`Bin directory: ${binDir}`);
|
|
89
95
|
class ProbeServer {
|
|
90
|
-
constructor(timeout = 30) {
|
|
96
|
+
constructor(timeout = 30, format) {
|
|
91
97
|
this.defaultTimeout = timeout;
|
|
98
|
+
this.defaultFormat = format;
|
|
92
99
|
this.server = new Server({
|
|
93
100
|
name: '@probelabs/probe',
|
|
94
101
|
version: packageVersion,
|
|
@@ -358,6 +365,14 @@ class ProbeServer {
|
|
|
358
365
|
else if (this.defaultTimeout !== undefined) {
|
|
359
366
|
options.timeout = this.defaultTimeout;
|
|
360
367
|
}
|
|
368
|
+
// Handle format options
|
|
369
|
+
if (this.defaultFormat === 'outline-xml') {
|
|
370
|
+
// For outline-xml format, we pass it as a format flag to the search command
|
|
371
|
+
options.format = 'outline-xml';
|
|
372
|
+
}
|
|
373
|
+
else if (this.defaultFormat === 'json') {
|
|
374
|
+
options.json = true;
|
|
375
|
+
}
|
|
361
376
|
console.error("Executing search with options:", JSON.stringify(options, null, 2));
|
|
362
377
|
// Double-check that path is still in the options object
|
|
363
378
|
if (!options.path) {
|
|
@@ -495,5 +510,5 @@ class ProbeServer {
|
|
|
495
510
|
console.error('Probe MCP server running on stdio');
|
|
496
511
|
}
|
|
497
512
|
}
|
|
498
|
-
const server = new ProbeServer(cliConfig.timeout);
|
|
513
|
+
const server = new ProbeServer(cliConfig.timeout, cliConfig.format);
|
|
499
514
|
server.run().catch(console.error);
|
package/build/mcp/index.ts
CHANGED
|
@@ -17,10 +17,10 @@ import { fileURLToPath } from 'url';
|
|
|
17
17
|
import { search, query, extract, getBinaryPath, setBinaryPath } from '../index.js';
|
|
18
18
|
|
|
19
19
|
// Parse command-line arguments
|
|
20
|
-
function parseArgs(): { timeout?: number } {
|
|
20
|
+
function parseArgs(): { timeout?: number; format?: string } {
|
|
21
21
|
const args = process.argv.slice(2);
|
|
22
|
-
const config: { timeout?: number } = {};
|
|
23
|
-
|
|
22
|
+
const config: { timeout?: number; format?: string } = {};
|
|
23
|
+
|
|
24
24
|
for (let i = 0; i < args.length; i++) {
|
|
25
25
|
if ((args[i] === '--timeout' || args[i] === '-t') && i + 1 < args.length) {
|
|
26
26
|
const timeout = parseInt(args[i + 1], 10);
|
|
@@ -31,6 +31,10 @@ function parseArgs(): { timeout?: number } {
|
|
|
31
31
|
console.error(`Invalid timeout value: ${args[i + 1]}. Using default.`);
|
|
32
32
|
}
|
|
33
33
|
i++; // Skip the next argument
|
|
34
|
+
} else if (args[i] === '--format' && i + 1 < args.length) {
|
|
35
|
+
config.format = args[i + 1];
|
|
36
|
+
console.error(`Format set to ${config.format}`);
|
|
37
|
+
i++; // Skip the next argument
|
|
34
38
|
} else if (args[i] === '--help' || args[i] === '-h') {
|
|
35
39
|
console.log(`
|
|
36
40
|
Probe MCP Server
|
|
@@ -40,12 +44,13 @@ Usage:
|
|
|
40
44
|
|
|
41
45
|
Options:
|
|
42
46
|
--timeout, -t <seconds> Set timeout for search operations (default: 30)
|
|
47
|
+
--format <format> Set output format (json, outline-xml, etc.)
|
|
43
48
|
--help, -h Show this help message
|
|
44
49
|
`);
|
|
45
50
|
process.exit(0);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
|
-
|
|
53
|
+
|
|
49
54
|
return config;
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -144,9 +149,11 @@ interface ExtractCodeArgs {
|
|
|
144
149
|
class ProbeServer {
|
|
145
150
|
private server: Server;
|
|
146
151
|
private defaultTimeout: number;
|
|
152
|
+
private defaultFormat?: string;
|
|
147
153
|
|
|
148
|
-
constructor(timeout: number = 30) {
|
|
154
|
+
constructor(timeout: number = 30, format?: string) {
|
|
149
155
|
this.defaultTimeout = timeout;
|
|
156
|
+
this.defaultFormat = format;
|
|
150
157
|
this.server = new Server(
|
|
151
158
|
{
|
|
152
159
|
name: '@probelabs/probe',
|
|
@@ -426,6 +433,14 @@ class ProbeServer {
|
|
|
426
433
|
} else if (this.defaultTimeout !== undefined) {
|
|
427
434
|
options.timeout = this.defaultTimeout;
|
|
428
435
|
}
|
|
436
|
+
|
|
437
|
+
// Handle format options
|
|
438
|
+
if (this.defaultFormat === 'outline-xml') {
|
|
439
|
+
// For outline-xml format, we pass it as a format flag to the search command
|
|
440
|
+
options.format = 'outline-xml';
|
|
441
|
+
} else if (this.defaultFormat === 'json') {
|
|
442
|
+
options.json = true;
|
|
443
|
+
}
|
|
429
444
|
|
|
430
445
|
console.error("Executing search with options:", JSON.stringify(options, null, 2));
|
|
431
446
|
|
|
@@ -589,5 +604,5 @@ class ProbeServer {
|
|
|
589
604
|
}
|
|
590
605
|
}
|
|
591
606
|
|
|
592
|
-
const server = new ProbeServer(cliConfig.timeout);
|
|
607
|
+
const server = new ProbeServer(cliConfig.timeout, cliConfig.format);
|
|
593
608
|
server.run().catch(console.error);
|
package/build/search.js
CHANGED
|
@@ -28,7 +28,8 @@ const SEARCH_FLAG_MAP = {
|
|
|
28
28
|
mergeThreshold: '--merge-threshold',
|
|
29
29
|
session: '--session',
|
|
30
30
|
timeout: '--timeout',
|
|
31
|
-
language: '--language'
|
|
31
|
+
language: '--language',
|
|
32
|
+
format: '--format'
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -52,6 +53,7 @@ const SEARCH_FLAG_MAP = {
|
|
|
52
53
|
* @param {string} [options.session] - Session ID for caching results
|
|
53
54
|
* @param {number} [options.timeout] - Timeout in seconds (default: 30)
|
|
54
55
|
* @param {string} [options.language] - Limit search to files of a specific programming language
|
|
56
|
+
* @param {string} [options.format] - Output format ('json', 'outline-xml', etc.)
|
|
55
57
|
* @param {Object} [options.binaryOptions] - Options for getting the binary
|
|
56
58
|
* @param {boolean} [options.binaryOptions.forceDownload] - Force download even if binary exists
|
|
57
59
|
* @param {string} [options.binaryOptions.version] - Specific version to download
|
|
@@ -74,9 +76,15 @@ export async function search(options) {
|
|
|
74
76
|
// Build CLI arguments from options
|
|
75
77
|
const cliArgs = buildCliArgs(options, SEARCH_FLAG_MAP);
|
|
76
78
|
|
|
77
|
-
// Add
|
|
78
|
-
if (options.json) {
|
|
79
|
+
// Add format if specified, with json option taking precedence for backwards compatibility
|
|
80
|
+
if (options.json && !options.format) {
|
|
79
81
|
cliArgs.push('--format', 'json');
|
|
82
|
+
} else if (options.format) {
|
|
83
|
+
// Format is already handled by buildCliArgs through SEARCH_FLAG_MAP
|
|
84
|
+
// but we need to ensure json parsing for json format
|
|
85
|
+
if (options.format === 'json') {
|
|
86
|
+
options.json = true;
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
// Set default maxTokens if not provided
|
package/build/tools/vercel.js
CHANGED
|
@@ -20,7 +20,7 @@ import { searchSchema, querySchema, extractSchema, delegateSchema, searchDescrip
|
|
|
20
20
|
* @returns {Object} Configured search tool
|
|
21
21
|
*/
|
|
22
22
|
export const searchTool = (options = {}) => {
|
|
23
|
-
const { sessionId, maxTokens = 10000, debug = false } = options;
|
|
23
|
+
const { sessionId, maxTokens = 10000, debug = false, outline = false } = options;
|
|
24
24
|
|
|
25
25
|
return tool({
|
|
26
26
|
name: 'search',
|
|
@@ -46,16 +46,23 @@ export const searchTool = (options = {}) => {
|
|
|
46
46
|
console.error(`Executing search with query: "${searchQuery}", path: "${searchPath}", exact: ${exact ? 'true' : 'false'}, language: ${language || 'all'}, session: ${sessionId || 'none'}`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const searchOptions = {
|
|
50
50
|
query: searchQuery,
|
|
51
51
|
path: searchPath,
|
|
52
|
-
allow_tests,
|
|
52
|
+
allowTests: allow_tests,
|
|
53
53
|
exact,
|
|
54
54
|
json: false,
|
|
55
55
|
maxTokens: effectiveMaxTokens,
|
|
56
56
|
session: sessionId, // Pass session ID if provided
|
|
57
57
|
language // Pass language parameter if provided
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Add outline format if enabled
|
|
61
|
+
if (outline) {
|
|
62
|
+
searchOptions.format = 'outline-xml';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const results = await search(searchOptions);
|
|
59
66
|
|
|
60
67
|
return results;
|
|
61
68
|
} catch (error) {
|
|
@@ -122,7 +129,7 @@ export const queryTool = (options = {}) => {
|
|
|
122
129
|
* @returns {Object} Configured extract tool
|
|
123
130
|
*/
|
|
124
131
|
export const extractTool = (options = {}) => {
|
|
125
|
-
const { debug = false } = options;
|
|
132
|
+
const { debug = false, outline = false } = options;
|
|
126
133
|
|
|
127
134
|
return tool({
|
|
128
135
|
name: 'extract',
|
|
@@ -168,23 +175,35 @@ export const extractTool = (options = {}) => {
|
|
|
168
175
|
console.error(`Created temporary file for input content: ${tempFilePath}`);
|
|
169
176
|
}
|
|
170
177
|
|
|
178
|
+
// Apply format mapping for outline-xml to xml
|
|
179
|
+
let effectiveFormat = format;
|
|
180
|
+
if (outline && format === 'outline-xml') {
|
|
181
|
+
effectiveFormat = 'xml';
|
|
182
|
+
}
|
|
183
|
+
|
|
171
184
|
// Set up extract options with input file
|
|
172
185
|
extractOptions = {
|
|
173
186
|
inputFile: tempFilePath,
|
|
174
187
|
allowTests: allow_tests,
|
|
175
188
|
contextLines: context_lines,
|
|
176
|
-
format
|
|
189
|
+
format: effectiveFormat
|
|
177
190
|
};
|
|
178
191
|
} else if (file_path) {
|
|
179
192
|
// Parse file_path to handle line numbers and symbol names
|
|
180
193
|
const files = [file_path];
|
|
181
194
|
|
|
195
|
+
// Apply format mapping for outline-xml to xml
|
|
196
|
+
let effectiveFormat = format;
|
|
197
|
+
if (outline && format === 'outline-xml') {
|
|
198
|
+
effectiveFormat = 'xml';
|
|
199
|
+
}
|
|
200
|
+
|
|
182
201
|
// Set up extract options with files
|
|
183
202
|
extractOptions = {
|
|
184
203
|
files,
|
|
185
204
|
allowTests: allow_tests,
|
|
186
205
|
contextLines: context_lines,
|
|
187
|
-
format
|
|
206
|
+
format: effectiveFormat
|
|
188
207
|
};
|
|
189
208
|
} else {
|
|
190
209
|
throw new Error('Either file_path or input_content must be provided');
|