@probelabs/probe 0.6.0-rc279 → 0.6.0-rc280

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.
@@ -254,6 +254,7 @@ export class ProbeAgent {
254
254
  // Supports exclusion with '!' prefix: ['*', '!bash'] = all tools except bash
255
255
  // disableTools is a convenience flag that overrides allowedTools to []
256
256
  const effectiveAllowedTools = options.disableTools ? [] : options.allowedTools;
257
+ this._rawAllowedTools = options.allowedTools; // Keep raw value for explicit tool checks
257
258
  this.allowedTools = this._parseAllowedTools(effectiveAllowedTools);
258
259
 
259
260
  // Storage adapter (defaults to in-memory)
@@ -481,6 +482,17 @@ export class ProbeAgent {
481
482
  return mcpToolNames.filter(toolName => this._isMcpToolAllowed(toolName));
482
483
  }
483
484
 
485
+ /**
486
+ * Check if query tool was explicitly listed in allowedTools (not via wildcard).
487
+ * Query (ast-grep) is excluded by default because models struggle with AST pattern syntax.
488
+ * @returns {boolean}
489
+ * @private
490
+ */
491
+ _isQueryExplicitlyAllowed() {
492
+ if (!this._rawAllowedTools) return false;
493
+ return Array.isArray(this._rawAllowedTools) && this._rawAllowedTools.includes('query');
494
+ }
495
+
484
496
  /**
485
497
  * Check if tracer is AppTracer (expects sessionId as first param) vs SimpleAppTracer
486
498
  * @returns {boolean} - True if tracer is AppTracer style (requires sessionId)
@@ -837,7 +849,9 @@ export class ProbeAgent {
837
849
  if (wrappedTools.searchToolInstance && isToolAllowed('search')) {
838
850
  this.toolImplementations.search = wrappedTools.searchToolInstance;
839
851
  }
840
- if (wrappedTools.queryToolInstance && isToolAllowed('query')) {
852
+ // query tool (ast-grep) is not exposed to AI by default — models struggle with AST pattern syntax.
853
+ // Only register it when explicitly listed in allowedTools (not via wildcard '*').
854
+ if (wrappedTools.queryToolInstance && isToolAllowed('query') && this._isQueryExplicitlyAllowed()) {
841
855
  this.toolImplementations.query = wrappedTools.queryToolInstance;
842
856
  }
843
857
  if (wrappedTools.extractToolInstance && isToolAllowed('extract')) {
@@ -2008,12 +2022,15 @@ export class ProbeAgent {
2008
2022
  const toolMap = {
2009
2023
  search: {
2010
2024
  schema: searchSchema,
2011
- description: 'Search code in the repository using keyword queries with Elasticsearch syntax.'
2012
- },
2013
- query: {
2014
- schema: querySchema,
2015
- description: 'Search code using ast-grep structural pattern matching.'
2025
+ description: this.searchDelegate
2026
+ ? 'Search code in the repository by asking a question. Accepts natural language questions — a subagent breaks them into targeted keyword searches and returns extracted code blocks. Do NOT formulate keyword queries yourself.'
2027
+ : 'Search code in the repository using keyword queries with Elasticsearch syntax. Handles stemming, case-insensitive matching, and camelCase/snake_case splitting automatically — do NOT try keyword variations manually.'
2016
2028
  },
2029
+ // query tool (ast-grep) removed from AI-facing tools — models struggle with pattern syntax
2030
+ // query: {
2031
+ // schema: querySchema,
2032
+ // description: 'Search code using ast-grep structural pattern matching.'
2033
+ // },
2017
2034
  extract: {
2018
2035
  schema: extractSchema,
2019
2036
  description: 'Extract code blocks from files based on file paths and optional line numbers.'
@@ -2849,10 +2866,12 @@ export class ProbeAgent {
2849
2866
  }
2850
2867
 
2851
2868
  // Add high-level instructions about when to use tools
2869
+ const searchToolDesc1 = this.searchDelegate
2870
+ ? '- search: Ask natural language questions to find code (e.g., "How does authentication work?"). A subagent handles keyword searches and returns extracted code blocks. Do NOT formulate keyword queries — just ask questions.'
2871
+ : '- search: Find code patterns using keyword queries with Elasticsearch syntax. Handles stemming and case variations automatically — do NOT try manual keyword variations.';
2852
2872
  systemPrompt += `You have access to powerful code search and analysis tools through MCP:
2853
- - search: Find code patterns using semantic search
2873
+ ${searchToolDesc1}
2854
2874
  - extract: Extract specific code sections with context
2855
- - query: Use AST patterns for structural code matching
2856
2875
  - listFiles: Browse directory contents
2857
2876
  - searchFiles: Find files by name patterns`;
2858
2877
 
@@ -2860,19 +2879,21 @@ export class ProbeAgent {
2860
2879
  systemPrompt += `\n- bash: Execute bash commands for system operations`;
2861
2880
  }
2862
2881
 
2863
- const searchGuidance = this.searchDelegate
2864
- ? '1. Start with search to retrieve extracted code blocks'
2865
- : '1. Start with search to find relevant code patterns';
2866
- const extractGuidance = this.searchDelegate
2882
+ const searchGuidance1 = this.searchDelegate
2883
+ ? '1. Start with search — ask a question about what you want to understand. It returns extracted code blocks directly.'
2884
+ : '1. Start with search to find relevant code patterns. One search per concept is usually enough — probe handles stemming and case variations.';
2885
+ const extractGuidance1 = this.searchDelegate
2867
2886
  ? '2. Use extract only if you need more context or a full file'
2868
2887
  : '2. Use extract to get detailed context when needed';
2869
2888
 
2870
2889
  systemPrompt += `\n
2871
2890
  When exploring code:
2872
- ${searchGuidance}
2873
- ${extractGuidance}
2891
+ ${searchGuidance1}
2892
+ ${extractGuidance1}
2874
2893
  3. Prefer focused, specific searches over broad queries
2875
- 4. Combine multiple tools to build complete understanding`;
2894
+ 4. Do NOT repeat the same search or try trivial keyword variations — probe handles stemming and case variations automatically
2895
+ 5. If 2-3 consecutive searches return no results for a concept, stop searching for it — the term likely does not exist in that codebase
2896
+ 6. Combine multiple tools to build complete understanding`;
2876
2897
 
2877
2898
  // Add workspace context
2878
2899
  if (this.allowedFolders && this.allowedFolders.length > 0) {
@@ -2911,10 +2932,12 @@ ${extractGuidance}
2911
2932
  }
2912
2933
 
2913
2934
  // Add high-level instructions about when to use tools
2935
+ const searchToolDesc2 = this.searchDelegate
2936
+ ? '- search: Ask natural language questions to find code (e.g., "How does authentication work?"). A subagent handles keyword searches and returns extracted code blocks. Do NOT formulate keyword queries — just ask questions.'
2937
+ : '- search: Find code patterns using keyword queries with Elasticsearch syntax. Handles stemming and case variations automatically — do NOT try manual keyword variations.';
2914
2938
  systemPrompt += `You have access to powerful code search and analysis tools through MCP:
2915
- - search: Find code patterns using semantic search
2939
+ ${searchToolDesc2}
2916
2940
  - extract: Extract specific code sections with context
2917
- - query: Use AST patterns for structural code matching
2918
2941
  - listFiles: Browse directory contents
2919
2942
  - searchFiles: Find files by name patterns`;
2920
2943
 
@@ -2922,19 +2945,21 @@ ${extractGuidance}
2922
2945
  systemPrompt += `\n- bash: Execute bash commands for system operations`;
2923
2946
  }
2924
2947
 
2925
- const searchGuidance = this.searchDelegate
2926
- ? '1. Start with search to retrieve extracted code blocks'
2927
- : '1. Start with search to find relevant code patterns';
2928
- const extractGuidance = this.searchDelegate
2948
+ const searchGuidance2 = this.searchDelegate
2949
+ ? '1. Start with search — ask a question about what you want to understand. It returns extracted code blocks directly.'
2950
+ : '1. Start with search to find relevant code patterns. One search per concept is usually enough — probe handles stemming and case variations.';
2951
+ const extractGuidance2 = this.searchDelegate
2929
2952
  ? '2. Use extract only if you need more context or a full file'
2930
2953
  : '2. Use extract to get detailed context when needed';
2931
2954
 
2932
2955
  systemPrompt += `\n
2933
2956
  When exploring code:
2934
- ${searchGuidance}
2935
- ${extractGuidance}
2957
+ ${searchGuidance2}
2958
+ ${extractGuidance2}
2936
2959
  3. Prefer focused, specific searches over broad queries
2937
- 4. Combine multiple tools to build complete understanding`;
2960
+ 4. Do NOT repeat the same search or try trivial keyword variations — probe handles stemming and case variations automatically
2961
+ 5. If 2-3 consecutive searches return no results for a concept, stop searching for it — the term likely does not exist in that codebase
2962
+ 6. Combine multiple tools to build complete understanding`;
2938
2963
 
2939
2964
  // Add workspace context
2940
2965
  if (this.allowedFolders && this.allowedFolders.length > 0) {
@@ -2990,10 +3015,10 @@ ${extractGuidance}
2990
3015
  Follow these instructions carefully:
2991
3016
  1. Analyze the user's request.
2992
3017
  2. Use the available tools step-by-step to fulfill the request.
2993
- 3. You should always prefer the search tool for code-related questions.${this.searchDelegate ? ' It already returns extracted code blocks; use extract only to expand context or read full files.' : ' Read full files only if really necessary.'}
3018
+ 3. You should always prefer the search tool for code-related questions.${this.searchDelegate ? ' Ask natural language questions — the search subagent handles keyword formulation and returns extracted code blocks. Use extract only to expand context or read full files.' : ' Search handles stemming and case variations automatically — do NOT try keyword variations manually. Read full files only if really necessary.'}
2994
3019
  4. Ensure to get really deep and understand the full picture before answering.
2995
3020
  5. Once the task is fully completed, use the attempt_completion tool to provide the final result.
2996
- 6. Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.${this.allowEdit ? `
3021
+ 6. ${this.searchDelegate ? 'Ask clear, specific questions when searching. Each search should target a distinct concept or question.' : 'Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.'}${this.allowEdit ? `
2997
3022
  7. When modifying files, choose the appropriate tool:
2998
3023
  - Use 'edit' for all code modifications:
2999
3024
  * PREFERRED: Use start_line (and optionally end_line) for line-targeted editing — this is the safest and most precise approach.${this.hashLines ? ' Use the line:hash references from extract/search output (e.g. "42:ab") for integrity verification.' : ''} Always use extract first to see line numbers${this.hashLines ? ' and hashes' : ''}, then edit by line reference.
@@ -284,6 +284,7 @@ export function generateSandboxGlobals(options) {
284
284
  results.push(p);
285
285
 
286
286
  if (executing.size >= mapConcurrency) {
287
+ console.error(`[map] Concurrency limit reached (${executing.size}/${mapConcurrency}), waiting for a slot...`);
287
288
  await Promise.race(executing);
288
289
  }
289
290
  }