@probelabs/probe 0.6.0-rc314 → 0.6.0-rc316

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/query.js CHANGED
@@ -18,6 +18,7 @@ const QUERY_FLAG_MAP = {
18
18
  language: '--language',
19
19
  ignore: '--ignore',
20
20
  allowTests: '--allow-tests',
21
+ withContext: '--with-context',
21
22
  maxResults: '--max-results',
22
23
  format: '--format'
23
24
  };
@@ -32,6 +33,7 @@ const QUERY_FLAG_MAP = {
32
33
  * @param {string} [options.language] - Programming language to search in
33
34
  * @param {string[]} [options.ignore] - Patterns to ignore
34
35
  * @param {boolean} [options.allowTests] - Include test files
36
+ * @param {boolean} [options.withContext] - Include owning source-block context in JSON output
35
37
  * @param {number} [options.maxResults] - Maximum number of results
36
38
  * @param {string} [options.format] - Output format ('markdown', 'plain', 'json', 'color')
37
39
  * @param {Object} [options.binaryOptions] - Options for getting the binary
@@ -120,4 +122,4 @@ export async function query(options) {
120
122
  const errorMessage = `Error executing query command: ${error.message}\nCommand: ${command}\nCwd: ${cwd}`;
121
123
  throw new Error(errorMessage);
122
124
  }
123
- }
125
+ }
@@ -33,7 +33,8 @@ export const querySchema = z.object({
33
33
  pattern: z.string().describe('AST pattern to search for. Use $NAME for variable names, $$$PARAMS for parameter lists, etc.'),
34
34
  path: z.string().optional().default('.').describe('Path to search in'),
35
35
  language: z.string().optional().default('rust').describe('Programming language to use for parsing'),
36
- allow_tests: z.boolean().optional().default(true).describe('Allow test files in search results')
36
+ allow_tests: z.boolean().optional().default(true).describe('Allow test files in search results'),
37
+ with_context: z.boolean().optional().default(false).describe('Include owning source-block context in JSON output')
37
38
  });
38
39
 
39
40
  export const extractSchema = z.object({
@@ -141,9 +141,16 @@ const CODE_SEARCH_SCHEMA = {
141
141
  * Returns: { action: 'allow'|'block'|'rewrite', rewritten?: string, reason: string }
142
142
  */
143
143
  async function checkDelegateDedup(newQuery, previousQueries, model, debug) {
144
- if (!model || previousQueries.length === 0) {
144
+ if (previousQueries.length === 0) {
145
145
  return { action: 'allow', reason: 'no previous queries' };
146
146
  }
147
+ if (!model) {
148
+ return {
149
+ action: 'allow',
150
+ reason: 'dedup model unavailable',
151
+ error: 'dedup_model_unavailable'
152
+ };
153
+ }
147
154
 
148
155
  const previousList = previousQueries
149
156
  .map((q, i) => {
@@ -203,11 +210,18 @@ Examples:
203
210
  return { action: 'block', reason: parts[1]?.trim() || 'duplicate query' };
204
211
  } else if (action === 'rewrite' && parts[2]) {
205
212
  return { action: 'rewrite', reason: parts[1]?.trim() || 'refined query', rewritten: parts[2].trim() };
213
+ } else if (action === 'allow') {
214
+ return { action: 'allow', reason: parts[1]?.trim() || 'new concept' };
206
215
  }
207
- return { action: 'allow', reason: parts[1]?.trim() || 'new concept' };
216
+ return {
217
+ action: 'allow',
218
+ reason: 'dedup returned unparseable response',
219
+ error: `unexpected_response:${line.slice(0, 200)}`
220
+ };
208
221
  } catch (err) {
209
- if (debug) console.error('[DEDUP-LLM] Error:', err.message);
210
- return { action: 'allow', reason: 'dedup check failed, allowing' };
222
+ const errorMessage = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
223
+ if (debug) console.error('[DEDUP-LLM] Error:', errorMessage);
224
+ return { action: 'allow', reason: 'dedup check failed', error: errorMessage };
211
225
  }
212
226
  }
213
227
 
@@ -702,7 +716,7 @@ export const searchTool = (options = {}) => {
702
716
  }
703
717
  }
704
718
 
705
- // ── Delegate-level semantic dedup ────────────────────────────
719
+ // ── Delegate-level semantic dedup ────────────────────────────
706
720
  // Each delegate is a full flash agent session (minutes, not seconds).
707
721
  // Use LLM to detect semantic duplicates and suggest rewrites.
708
722
  // Compare against ALL previous delegations (not filtered by path) because
@@ -713,10 +727,10 @@ export const searchTool = (options = {}) => {
713
727
  let effectiveQuery = searchQuery;
714
728
 
715
729
  if (previousDelegations.length > 0) {
730
+ const dedupProvider = options.searchDelegateProvider || process.env.PROBE_SEARCH_DELEGATE_PROVIDER || options.provider || process.env.FORCE_PROVIDER || null;
731
+ const dedupModelName = options.searchDelegateModel || process.env.PROBE_SEARCH_DELEGATE_MODEL || options.model || process.env.MODEL_NAME || null;
716
732
  // Lazily create the dedup model (same provider/model as delegate)
717
733
  if (cachedDedupModel === undefined) {
718
- const dedupProvider = options.searchDelegateProvider || process.env.PROBE_SEARCH_DELEGATE_PROVIDER || options.provider || process.env.FORCE_PROVIDER || null;
719
- const dedupModelName = options.searchDelegateModel || process.env.PROBE_SEARCH_DELEGATE_MODEL || options.model || process.env.MODEL_NAME || null;
720
734
  if (debug) {
721
735
  console.error(`[DEDUP-LLM] Creating model: provider=${dedupProvider}, model=${dedupModelName}`);
722
736
  }
@@ -730,6 +744,9 @@ export const searchTool = (options = {}) => {
730
744
  'dedup.query': searchQuery,
731
745
  'dedup.previous_count': String(previousDelegations.length),
732
746
  'dedup.previous_queries': previousDelegations.map(d => d.query).join(' | '),
747
+ 'dedup.provider': dedupProvider || '',
748
+ 'dedup.model': dedupModelName || '',
749
+ 'dedup.model_available': cachedDedupModel ? 'true' : 'false',
733
750
  };
734
751
 
735
752
  const dedup = options.tracer?.withSpan
@@ -740,6 +757,7 @@ export const searchTool = (options = {}) => {
740
757
  'dedup.action': result.action,
741
758
  'dedup.reason': result.reason || '',
742
759
  'dedup.rewritten': result.rewritten || '',
760
+ 'dedup.error': result.error || '',
743
761
  });
744
762
  })
745
763
  : await checkDelegateDedup(searchQuery, previousDelegations, cachedDedupModel, debug);
@@ -918,7 +936,7 @@ export const queryTool = (options = {}) => {
918
936
  name: 'query',
919
937
  description: queryDescription,
920
938
  inputSchema: querySchema,
921
- execute: async ({ pattern, path, language, allow_tests }) => {
939
+ execute: async ({ pattern, path, language, allow_tests, with_context }) => {
922
940
  try {
923
941
  // Parse and resolve paths (supports comma-separated and relative paths)
924
942
  let queryPaths;
@@ -944,6 +962,7 @@ export const queryTool = (options = {}) => {
944
962
  cwd: options.cwd, // Working directory for resolving relative paths
945
963
  language,
946
964
  allowTests: allow_tests ?? true,
965
+ withContext: with_context ?? false,
947
966
  json: false
948
967
  });
949
968