|
98 | 98 | }); |
99 | 99 | return { |
100 | 100 | command: [command, ...args].join(' '), |
| 101 | + cwd: options.cwd ?? process.cwd(), |
101 | 102 | status: result.status, |
102 | 103 | signal: result.signal, |
103 | 104 | error: result.error?.message ?? null, |
@@ -178,18 +179,27 @@ jobs: |
178 | 179 | mkdirSync(runDir, { recursive: true }); |
179 | 180 | const env = { ...process.env, CBM_CACHE_DIR: join(runDir, 'cbm-cache'), CBM_DIAGNOSTICS: '1' }; |
180 | 181 | const query = makeQuery(task.problem_statement); |
| 182 | + const firstTerm = query.split(/\s+/).find(Boolean) || 'TODO'; |
| 183 | + const toolOptions = { env, cwd: task.repo_checkout_path, timeoutMs: 120_000 }; |
181 | 184 | const setup = run(cbmBin, ['--version'], { env, timeoutMs: 60_000 }); |
182 | | - const indexRun = run(cbmBin, ['cli', 'index_repository', JSON.stringify({ repo_path: task.repo_checkout_path })], { env, timeoutMs: 45 * 60 * 1000 }); |
183 | | - const listProjects = runCandidates('list_projects', [['cli', '--raw', 'list_projects'], ['cli', 'list_projects'], ['cli', 'list_projects', '{}']], { env, timeoutMs: 120_000 }); |
184 | | - const graphSchema = runCandidates('get_graph_schema', [['cli', '--raw', 'get_graph_schema'], ['cli', 'get_graph_schema'], ['cli', 'get_graph_schema', '{}']], { env, timeoutMs: 120_000 }); |
185 | | - const graphSearch = runCandidates('search_graph', [['cli', '--raw', 'search_graph', JSON.stringify({ label: 'Function', limit: 25 })], ['cli', 'search_graph', JSON.stringify({ label: 'Function', limit: 25 })]], { env, timeoutMs: 120_000 }); |
186 | | - const codeSearch = runCandidates('search_code', [['cli', '--raw', 'search_code', JSON.stringify({ query, limit: 25 })], ['cli', 'search_code', JSON.stringify({ query, limit: 25 })]], { env, timeoutMs: 120_000 }); |
| 185 | + const indexRun = run(cbmBin, ['cli', 'index_repository', JSON.stringify({ repo_path: task.repo_checkout_path })], { env, cwd: task.repo_checkout_path, timeoutMs: 45 * 60 * 1000 }); |
| 186 | + const listProjects = runCandidates('list_projects', [['cli', '--raw', 'list_projects'], ['cli', 'list_projects'], ['cli', 'list_projects', '{}']], toolOptions); |
| 187 | + const graphSchema = runCandidates('get_graph_schema', [['cli', '--raw', 'get_graph_schema'], ['cli', 'get_graph_schema'], ['cli', 'get_graph_schema', '{}']], toolOptions); |
| 188 | + const graphSearch = runCandidates('search_graph', [['cli', '--raw', 'search_graph', JSON.stringify({ label: 'Function', limit: 25 })], ['cli', 'search_graph', JSON.stringify({ label: 'Function', limit: 25 })]], toolOptions); |
| 189 | + const codeSearch = runCandidates('search_code', [ |
| 190 | + ['cli', '--raw', 'search_code', JSON.stringify({ pattern: query, limit: 25 })], |
| 191 | + ['cli', 'search_code', JSON.stringify({ pattern: query, limit: 25 })], |
| 192 | + ['cli', 'search_code', JSON.stringify({ pattern: firstTerm, limit: 25 })], |
| 193 | + ['cli', 'search_code', JSON.stringify({ query, limit: 25 })] |
| 194 | + ], toolOptions); |
187 | 195 |
|
188 | 196 | const spans = new Map(); |
189 | | - for (const text of [codeSearch.stdout, graphSearch.stdout, graphSchema.stdout, listProjects.stdout]) { |
190 | | - const parsed = parseJsonish(text); |
191 | | - if (parsed) collectSpans(parsed, spans); |
192 | | - collectTextSpans(text, spans); |
| 197 | + for (const result of [codeSearch, graphSearch, graphSchema, listProjects]) { |
| 198 | + for (const text of [result.stdout, result.stderr]) { |
| 199 | + const parsed = parseJsonish(text); |
| 200 | + if (parsed) collectSpans(parsed, spans); |
| 201 | + collectTextSpans(text, spans); |
| 202 | + } |
193 | 203 | } |
194 | 204 | const predFiles = [...spans.keys()].slice(0, 20); |
195 | 205 | const predSpans = Object.fromEntries([...spans.entries()].slice(0, 20)); |
@@ -227,6 +237,7 @@ jobs: |
227 | 237 | laneIsolation: { |
228 | 238 | allowedTool: 'codebase-memory-mcp', |
229 | 239 | observedCommands: [setup.command, indexRun.command, listProjects.command, graphSchema.command, graphSearch.command, codeSearch.command], |
| 240 | + observedCwds: [setup.cwd, indexRun.cwd, listProjects.cwd, graphSchema.cwd, graphSearch.cwd, codeSearch.cwd], |
230 | 241 | disallowedNativeReadSearchUsedForPrediction: false, |
231 | 242 | note: 'Prediction spans are derived only from codebase-memory-mcp CLI outputs.' |
232 | 243 | }, |
|
0 commit comments