@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.
- package/bin/binaries/probe-v0.6.0-rc280-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc280-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc280-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc280-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc280-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +51 -26
- package/build/agent/dsl/environment.js +1 -0
- package/build/agent/index.js +150 -74
- package/build/delegate.js +22 -12
- package/build/downloader.js +28 -25
- package/build/tools/analyzeAll.js +2 -6
- package/build/tools/common.js +4 -3
- package/build/tools/vercel.js +65 -6
- package/cjs/agent/ProbeAgent.cjs +150 -74
- package/cjs/index.cjs +150 -74
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +51 -26
- package/src/agent/dsl/environment.js +1 -0
- package/src/delegate.js +22 -12
- package/src/downloader.js +28 -25
- package/src/tools/analyzeAll.js +2 -6
- package/src/tools/common.js +4 -3
- package/src/tools/vercel.js +65 -6
- package/bin/binaries/probe-v0.6.0-rc279-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc279-x86_64-unknown-linux-musl.tar.gz +0 -0
package/build/downloader.js
CHANGED
|
@@ -95,9 +95,7 @@ async function acquireFileLock(lockPath, version) {
|
|
|
95
95
|
try {
|
|
96
96
|
// Try to create lock file atomically (fails if already exists)
|
|
97
97
|
await fs.writeFile(lockPath, JSON.stringify(lockData), { flag: 'wx' });
|
|
98
|
-
|
|
99
|
-
console.log(`Acquired file lock: ${lockPath}`);
|
|
100
|
-
}
|
|
98
|
+
console.log(`Acquired file lock: ${lockPath}`);
|
|
101
99
|
return true;
|
|
102
100
|
} catch (error) {
|
|
103
101
|
if (error.code === 'EEXIST') {
|
|
@@ -108,17 +106,13 @@ async function acquireFileLock(lockPath, version) {
|
|
|
108
106
|
|
|
109
107
|
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
110
108
|
// Lock is stale, remove it
|
|
111
|
-
|
|
112
|
-
console.log(`Removing stale lock file (age: ${Math.round(lockAge / 1000)}s, pid: ${existingLock.pid})`);
|
|
113
|
-
}
|
|
109
|
+
console.log(`Removing stale lock file (age: ${Math.round(lockAge / 1000)}s, pid: ${existingLock.pid})`);
|
|
114
110
|
await fs.remove(lockPath);
|
|
115
111
|
return false; // Caller should retry
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
// Lock is fresh, another process is downloading
|
|
119
|
-
|
|
120
|
-
console.log(`Download in progress by process ${existingLock.pid}, waiting...`);
|
|
121
|
-
}
|
|
115
|
+
console.log(`Download in progress by process ${existingLock.pid}, waiting...`);
|
|
122
116
|
return false;
|
|
123
117
|
} catch (readError) {
|
|
124
118
|
// Can't read lock file, might be corrupted - remove it
|
|
@@ -180,23 +174,23 @@ async function releaseFileLock(lockPath) {
|
|
|
180
174
|
*/
|
|
181
175
|
async function waitForFileLock(lockPath, binaryPath) {
|
|
182
176
|
const startTime = Date.now();
|
|
177
|
+
let lastStatusTime = startTime;
|
|
178
|
+
|
|
179
|
+
console.log(`Waiting for file lock to clear: ${lockPath}`);
|
|
183
180
|
|
|
184
181
|
// Poll in a loop until binary appears, lock expires, or we timeout
|
|
185
182
|
while (Date.now() - startTime < MAX_LOCK_WAIT_MS) {
|
|
186
183
|
// Check #1: Is the binary now available?
|
|
187
184
|
if (await fs.pathExists(binaryPath)) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
185
|
+
const waitedSeconds = Math.round((Date.now() - startTime) / 1000);
|
|
186
|
+
console.log(`Binary now available at ${binaryPath}, download completed by another process (waited ${waitedSeconds}s)`);
|
|
191
187
|
return true;
|
|
192
188
|
}
|
|
193
189
|
|
|
194
190
|
// Check #2: Is the lock file gone? (download finished or failed)
|
|
195
191
|
const lockExists = await fs.pathExists(lockPath);
|
|
196
192
|
if (!lockExists) {
|
|
197
|
-
|
|
198
|
-
console.log(`Lock file removed but binary not found - download may have failed`);
|
|
199
|
-
}
|
|
193
|
+
console.log(`Lock file removed but binary not found - download may have failed`);
|
|
200
194
|
return false;
|
|
201
195
|
}
|
|
202
196
|
|
|
@@ -205,22 +199,24 @@ async function waitForFileLock(lockPath, binaryPath) {
|
|
|
205
199
|
const lockData = JSON.parse(await fs.readFile(lockPath, 'utf-8'));
|
|
206
200
|
const lockAge = Date.now() - lockData.timestamp;
|
|
207
201
|
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
208
|
-
|
|
209
|
-
console.log(`Lock expired (age: ${Math.round(lockAge / 1000)}s), will retry download`);
|
|
210
|
-
}
|
|
202
|
+
console.log(`Lock expired (age: ${Math.round(lockAge / 1000)}s), will retry download`);
|
|
211
203
|
return false;
|
|
212
204
|
}
|
|
213
205
|
} catch {
|
|
214
206
|
// Ignore errors reading lock file - will retry on next poll
|
|
215
207
|
}
|
|
216
208
|
|
|
209
|
+
if (Date.now() - lastStatusTime >= 15000) {
|
|
210
|
+
const elapsedSeconds = Math.round((Date.now() - startTime) / 1000);
|
|
211
|
+
console.log(`Still waiting for file lock (${elapsedSeconds}s/${MAX_LOCK_WAIT_MS / 1000}s max)`);
|
|
212
|
+
lastStatusTime = Date.now();
|
|
213
|
+
}
|
|
214
|
+
|
|
217
215
|
// Wait 1 second before checking again
|
|
218
216
|
await new Promise(resolve => setTimeout(resolve, LOCK_POLL_INTERVAL_MS));
|
|
219
217
|
}
|
|
220
218
|
|
|
221
|
-
|
|
222
|
-
console.log(`Timeout waiting for file lock`);
|
|
223
|
-
}
|
|
219
|
+
console.log(`Timeout waiting for file lock after ${MAX_LOCK_WAIT_MS / 1000}s`);
|
|
224
220
|
return false;
|
|
225
221
|
}
|
|
226
222
|
|
|
@@ -247,9 +243,7 @@ async function withDownloadLock(version, downloadFn) {
|
|
|
247
243
|
}
|
|
248
244
|
downloadLocks.delete(lockKey);
|
|
249
245
|
} else {
|
|
250
|
-
|
|
251
|
-
console.log(`Download already in progress in this process for version ${lockKey}, waiting...`);
|
|
252
|
-
}
|
|
246
|
+
console.log(`Download already in progress in this process for version ${lockKey}, waiting...`);
|
|
253
247
|
try {
|
|
254
248
|
return await lock.promise;
|
|
255
249
|
} catch (error) {
|
|
@@ -262,10 +256,16 @@ async function withDownloadLock(version, downloadFn) {
|
|
|
262
256
|
}
|
|
263
257
|
|
|
264
258
|
// Create new download promise with timeout protection
|
|
259
|
+
let timeoutId = null;
|
|
265
260
|
const downloadPromise = Promise.race([
|
|
266
261
|
downloadFn(),
|
|
267
262
|
new Promise((_, reject) =>
|
|
268
|
-
|
|
263
|
+
{
|
|
264
|
+
timeoutId = setTimeout(() => reject(new Error(`Download timeout after ${LOCK_TIMEOUT_MS / 1000}s`)), LOCK_TIMEOUT_MS);
|
|
265
|
+
if (timeoutId.unref) {
|
|
266
|
+
timeoutId.unref();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
269
|
)
|
|
270
270
|
]);
|
|
271
271
|
|
|
@@ -278,6 +278,9 @@ async function withDownloadLock(version, downloadFn) {
|
|
|
278
278
|
const result = await downloadPromise;
|
|
279
279
|
return result;
|
|
280
280
|
} finally {
|
|
281
|
+
if (timeoutId) {
|
|
282
|
+
clearTimeout(timeoutId);
|
|
283
|
+
}
|
|
281
284
|
// Clean up lock after download completes (success or failure)
|
|
282
285
|
downloadLocks.delete(lockKey);
|
|
283
286
|
}
|
|
@@ -227,18 +227,14 @@ async function processChunksParallel(chunks, extractionPrompt, maxWorkers, optio
|
|
|
227
227
|
|
|
228
228
|
active.add(promise);
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
console.error(`[analyze_all] Started processing chunk ${chunk.id}/${chunk.total}`);
|
|
232
|
-
}
|
|
230
|
+
console.error(`[analyze_all] Started processing chunk ${chunk.id}/${chunk.total}`);
|
|
233
231
|
}
|
|
234
232
|
|
|
235
233
|
if (active.size > 0) {
|
|
236
234
|
const result = await Promise.race(active);
|
|
237
235
|
results.push(result);
|
|
238
236
|
|
|
239
|
-
|
|
240
|
-
console.error(`[analyze_all] Completed chunk ${result.chunk.id}/${result.chunk.total}`);
|
|
241
|
-
}
|
|
237
|
+
console.error(`[analyze_all] Completed chunk ${result.chunk.id}/${result.chunk.total}`);
|
|
242
238
|
}
|
|
243
239
|
}
|
|
244
240
|
|
package/build/tools/common.js
CHANGED
|
@@ -8,7 +8,7 @@ import { resolve, isAbsolute } from 'path';
|
|
|
8
8
|
|
|
9
9
|
// Common schemas for tool parameters (used for internal execution after XML parsing)
|
|
10
10
|
export const searchSchema = z.object({
|
|
11
|
-
query: z.string().describe('Search query
|
|
11
|
+
query: z.string().describe('Search query — natural language questions or Elasticsearch-style keywords both work. For keywords: use quotes for exact phrases, AND/OR for boolean logic, - for negation. Probe handles stemming and camelCase/snake_case splitting automatically, so do NOT try case or style variations of the same keyword.'),
|
|
12
12
|
path: z.string().optional().default('.').describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.'),
|
|
13
13
|
exact: z.boolean().optional().default(false).describe('Default (false) enables stemming and keyword splitting for exploratory search - "getUserData" matches "get", "user", "data", etc. Set true for precise symbol lookup where "getUserData" matches only "getUserData". Use true when you know the exact symbol name.'),
|
|
14
14
|
maxTokens: z.number().nullable().optional().describe('Maximum tokens to return. Default is 20000. Set to null for unlimited results.'),
|
|
@@ -17,7 +17,7 @@ export const searchSchema = z.object({
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
export const searchAllSchema = z.object({
|
|
20
|
-
query: z.string().describe('Search query
|
|
20
|
+
query: z.string().describe('Search query — natural language questions or Elasticsearch-style keywords both work. For keywords: use quotes for exact phrases, AND/OR for boolean logic, - for negation. Probe handles stemming and camelCase/snake_case splitting automatically, so do NOT try case or style variations of the same keyword.'),
|
|
21
21
|
path: z.string().optional().default('.').describe('Path to search in.'),
|
|
22
22
|
exact: z.boolean().optional().default(false).describe('Use exact matching instead of stemming.'),
|
|
23
23
|
maxTokensPerPage: z.number().optional().default(20000).describe('Tokens per page when paginating. Default 20000.'),
|
|
@@ -149,7 +149,8 @@ export const attemptCompletionSchema = {
|
|
|
149
149
|
|
|
150
150
|
// Tool descriptions (used by Vercel tool() definitions)
|
|
151
151
|
|
|
152
|
-
export const searchDescription = 'Search code in the repository. Free-form questions are accepted, but Elasticsearch-style keyword queries work best. Use this tool first for any code-related questions.';
|
|
152
|
+
export const searchDescription = 'Search code in the repository. Free-form questions are accepted, but Elasticsearch-style keyword queries work best. Use this tool first for any code-related questions. NOTE: By default, search handles stemming, case-insensitive matching, and camelCase/snake_case splitting automatically — do NOT manually try keyword variations like "getAllUsers" then "get_all_users" then "GetAllUsers". One search covers all variations.';
|
|
153
|
+
export const searchDelegateDescription = 'Search code in the repository by asking a question. Accepts natural language questions (e.g., "How does authentication work?", "Where is the user validation logic?"). A specialized subagent breaks down your question into targeted keyword searches and returns extracted code blocks. Do NOT formulate keyword queries yourself — just ask the question naturally.';
|
|
153
154
|
export const queryDescription = 'Search code using ast-grep structural pattern matching. Use this tool to find specific code structures like functions, classes, or methods.';
|
|
154
155
|
export const extractDescription = 'Extract code blocks from files based on file paths and optional line numbers. Use this tool to see complete context after finding relevant files. Line numbers from output can be used with edit start_line/end_line for precise editing.';
|
|
155
156
|
export const delegateDescription = 'Automatically delegate big distinct tasks to specialized probe subagents within the agentic loop. Used by AI agents to break down complex requests into focused, parallel tasks.';
|
package/build/tools/vercel.js
CHANGED
|
@@ -9,7 +9,7 @@ import { query } from '../query.js';
|
|
|
9
9
|
import { extract } from '../extract.js';
|
|
10
10
|
import { delegate } from '../delegate.js';
|
|
11
11
|
import { analyzeAll } from './analyzeAll.js';
|
|
12
|
-
import { searchSchema, querySchema, extractSchema, delegateSchema, analyzeAllSchema, searchDescription, queryDescription, extractDescription, delegateDescription, analyzeAllDescription, parseTargets, parseAndResolvePaths, resolveTargetPath } from './common.js';
|
|
12
|
+
import { searchSchema, querySchema, extractSchema, delegateSchema, analyzeAllSchema, searchDescription, searchDelegateDescription, queryDescription, extractDescription, delegateDescription, analyzeAllDescription, parseTargets, parseAndResolvePaths, resolveTargetPath } from './common.js';
|
|
13
13
|
import { existsSync } from 'fs';
|
|
14
14
|
import { formatErrorForAI } from '../utils/error-types.js';
|
|
15
15
|
import { annotateOutputWithHashes } from './hashline.js';
|
|
@@ -143,11 +143,41 @@ function buildSearchDelegateTask({ searchQuery, searchPath, exact, language, all
|
|
|
143
143
|
'- extract: Verify code snippets to ensure targets are actually relevant before including them.',
|
|
144
144
|
'- listFiles: Understand directory structure to find where relevant code might live.',
|
|
145
145
|
'',
|
|
146
|
-
'
|
|
146
|
+
'CRITICAL - How probe search works (do NOT ignore):',
|
|
147
|
+
'- By default (exact=false), probe ALREADY handles stemming, case-insensitive matching, and camelCase/snake_case splitting.',
|
|
148
|
+
'- Searching "allowed_ips" ALREADY matches "AllowedIPs", "allowedIps", "allowed_ips", etc. Do NOT manually try case/style variations.',
|
|
149
|
+
'- Searching "getUserData" ALREADY matches "get", "user", "data" and their variations.',
|
|
150
|
+
'- NEVER repeat the same search query — you will get the same results.',
|
|
151
|
+
'- NEVER search trivial variations of the same keyword (e.g., AllowedIPs then allowedIps then allowed_ips). This is wasteful — probe handles it.',
|
|
152
|
+
'- If a search returns no results, the term likely does not exist in that path. Try a genuinely DIFFERENT keyword or concept, not a variation.',
|
|
153
|
+
'- If 2-3 consecutive searches return no results for a concept, STOP searching for it and move on.',
|
|
154
|
+
'',
|
|
155
|
+
'GOOD search strategy (do this):',
|
|
156
|
+
' Query: "How does authentication work and how are sessions managed?"',
|
|
157
|
+
' → search "authentication" → search "session management" (two different concepts)',
|
|
158
|
+
' Query: "Find the IP allowlist middleware"',
|
|
159
|
+
' → search "allowlist middleware" (one search, probe handles IP/ip/Ip variations)',
|
|
160
|
+
' Query: "How does BM25 scoring work with SIMD optimization?"',
|
|
161
|
+
' → search "BM25 scoring" → search "SIMD optimization" (two different concepts)',
|
|
162
|
+
'',
|
|
163
|
+
'BAD search strategy (never do this):',
|
|
164
|
+
' → search "AllowedIPs" → search "allowedIps" → search "allowed_ips" (WRONG: these are trivial case variations, probe handles them)',
|
|
165
|
+
' → search "CIDR" → search "cidr" → search "Cidr" → search "*cidr*" (WRONG: same keyword repeated with variations)',
|
|
166
|
+
' → search "error handling" → search "error handling" → search "error handling" (WRONG: repeating exact same query)',
|
|
167
|
+
'',
|
|
168
|
+
'Keyword tips:',
|
|
169
|
+
'- Common programming keywords are filtered as stopwords when unquoted: function, class, return, new, struct, impl, var, let, const, etc.',
|
|
170
|
+
'- Avoid searching for these alone — combine with a specific term (e.g., "middleware function" is fine, "function" alone is too generic).',
|
|
171
|
+
'- To bypass stopword filtering: wrap terms in quotes ("return", "struct") or set exact=true. Both disable stemming and splitting too.',
|
|
172
|
+
'- Multiple words without operators use OR logic: foo bar = foo OR bar. Use AND explicitly if you need both: foo AND bar.',
|
|
173
|
+
'- camelCase terms are split: getUserData becomes "get", "user", "data" — so one search covers all naming styles.',
|
|
174
|
+
'',
|
|
175
|
+
'Strategy:',
|
|
147
176
|
'1. Analyze the query - identify key concepts, entities, and relationships',
|
|
148
|
-
'2. Run focused
|
|
149
|
-
'3.
|
|
150
|
-
'4.
|
|
177
|
+
'2. Run ONE focused search per concept with the most natural keyword. Trust probe to handle variations.',
|
|
178
|
+
'3. If a search returns results, use extract to verify relevance',
|
|
179
|
+
'4. Only try a different keyword if the first one returned irrelevant results (not if it returned no results — that means the concept is absent)',
|
|
180
|
+
'5. Combine all relevant targets in your final response',
|
|
151
181
|
'',
|
|
152
182
|
`Query: ${searchQuery}`,
|
|
153
183
|
`Search path(s): ${searchPath}`,
|
|
@@ -186,10 +216,16 @@ export const searchTool = (options = {}) => {
|
|
|
186
216
|
return result;
|
|
187
217
|
};
|
|
188
218
|
|
|
219
|
+
// Track previous non-paginated searches to detect and block duplicates
|
|
220
|
+
const previousSearches = new Set();
|
|
221
|
+
// Track pagination counts per query to cap runaway pagination
|
|
222
|
+
const paginationCounts = new Map();
|
|
223
|
+
const MAX_PAGES_PER_QUERY = 3;
|
|
224
|
+
|
|
189
225
|
return tool({
|
|
190
226
|
name: 'search',
|
|
191
227
|
description: searchDelegate
|
|
192
|
-
?
|
|
228
|
+
? searchDelegateDescription
|
|
193
229
|
: searchDescription,
|
|
194
230
|
inputSchema: searchSchema,
|
|
195
231
|
execute: async ({ query: searchQuery, path, allow_tests, exact, maxTokens: paramMaxTokens, language, session, nextPage }) => {
|
|
@@ -236,6 +272,29 @@ export const searchTool = (options = {}) => {
|
|
|
236
272
|
};
|
|
237
273
|
|
|
238
274
|
if (!searchDelegate) {
|
|
275
|
+
// Block duplicate non-paginated searches (models sometimes repeat the exact same call)
|
|
276
|
+
// Allow pagination: only nextPage=true is a legitimate repeat of the same query
|
|
277
|
+
const searchKey = `${searchQuery}::${searchPath}::${exact || false}`;
|
|
278
|
+
if (!nextPage) {
|
|
279
|
+
if (previousSearches.has(searchKey)) {
|
|
280
|
+
if (debug) {
|
|
281
|
+
console.error(`[DEDUP] Blocked duplicate search: "${searchQuery}" in "${searchPath}"`);
|
|
282
|
+
}
|
|
283
|
+
return 'DUPLICATE SEARCH BLOCKED: You already searched for this exact query in this path. Do NOT repeat the same search. If you need more results, set nextPage=true with the session ID from the previous search. Otherwise, try a genuinely different keyword, use extract to examine results you already found, or use attempt_completion if you have enough information.';
|
|
284
|
+
}
|
|
285
|
+
previousSearches.add(searchKey);
|
|
286
|
+
paginationCounts.set(searchKey, 0);
|
|
287
|
+
} else {
|
|
288
|
+
// Cap pagination to prevent runaway page-through of broad queries
|
|
289
|
+
const pageCount = (paginationCounts.get(searchKey) || 0) + 1;
|
|
290
|
+
paginationCounts.set(searchKey, pageCount);
|
|
291
|
+
if (pageCount > MAX_PAGES_PER_QUERY) {
|
|
292
|
+
if (debug) {
|
|
293
|
+
console.error(`[DEDUP] Blocked excessive pagination (page ${pageCount}/${MAX_PAGES_PER_QUERY}): "${searchQuery}" in "${searchPath}"`);
|
|
294
|
+
}
|
|
295
|
+
return `PAGINATION LIMIT REACHED: You have already retrieved ${MAX_PAGES_PER_QUERY} pages of results for this query. You have enough results — use extract to examine specific files, or use attempt_completion to return your findings.`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
239
298
|
try {
|
|
240
299
|
const result = maybeAnnotate(await runRawSearch());
|
|
241
300
|
// Track files found in search results for staleness detection
|