|
30 | 30 | TESTS = [ |
31 | 31 | ("1. pattern_detection", { |
32 | 32 | "jsonrpc": "2.0", "method": "tools/call", |
33 | | - "params": {"name": "pattern_detection","arguments": {"_unused": None}}, "id": 101 |
| 33 | + "params": {"name": "pattern_detection", "arguments": {"_unused": None}}, "id": 101 |
34 | 34 | }), |
35 | 35 | ("2. vector_search", { |
36 | 36 | "jsonrpc": "2.0", "method": "tools/call", |
37 | | - "params": {"name": "vector_search","arguments": {"query": "async function implementation","limit": 3}}, "id": 102 |
| 37 | + "params": {"name": "vector_search", "arguments": {"query": "async function implementation", "limit": 3}}, "id": 102 |
38 | 38 | }), |
39 | 39 | ("3. enhanced_search", { |
40 | 40 | "jsonrpc": "2.0", "method": "tools/call", |
41 | | - "params": {"name": "enhanced_search","arguments": {"query": "RAG engine streaming implementation","limit": 3}}, "id": 103 |
| 41 | + "params": {"name": "enhanced_search", "arguments": {"query": "RAG engine streaming implementation", "limit": 3}}, "id": 103 |
42 | 42 | }), |
43 | 43 | ("4. codebase_qa", { |
44 | 44 | "jsonrpc": "2.0", "method": "tools/call", |
45 | | - "params": {"name": "codebase_qa","arguments": {"question": "How does the RAG engine handle streaming responses?","max_results": 3,"streaming": False}}, "id": 104 |
| 45 | + "params": {"name": "codebase_qa", "arguments": {"question": "How does the RAG engine handle streaming responses?", "max_results": 3, "streaming": False}}, "id": 104 |
46 | 46 | }), |
47 | 47 | ("5. graph_neighbors (auto-fill node UUID)", { |
48 | 48 | "jsonrpc": "2.0", "method": "tools/call", |
49 | | - "params": {"name": "graph_neighbors","arguments": {"node": "REPLACE_WITH_NODE_UUID","limit": 5}}, "id": 105 |
| 49 | + "params": {"name": "graph_neighbors", "arguments": {"node": "REPLACE_WITH_NODE_UUID", "limit": 5}}, "id": 105 |
50 | 50 | }), |
51 | 51 | ("6. impact_analysis", { |
52 | 52 | "jsonrpc": "2.0", "method": "tools/call", |
53 | | - "params": {"name": "impact_analysis","arguments": {"target_function": "analyze_codebase","file_path": "crates/codegraph-mcp/src/qwen.rs","change_type": "modify"}}, "id": 106 |
| 53 | + "params": {"name": "impact_analysis", "arguments": {"target_function": "analyze_codebase", "file_path": "crates/codegraph-mcp/src/qwen.rs", "change_type": "modify"}}, "id": 106 |
54 | 54 | }), |
55 | 55 | ("7. code_documentation", { |
56 | 56 | "jsonrpc": "2.0", "method": "tools/call", |
57 | | - "params": {"name": "code_documentation","arguments": {"target_name": "QwenClient","file_path": "crates/codegraph-mcp/src/qwen.rs","style": "concise"}}, "id": 107 |
| 57 | + "params": {"name": "code_documentation", "arguments": {"target_name": "QwenClient", "file_path": "crates/codegraph-mcp/src/qwen.rs", "style": "concise"}}, "id": 107 |
58 | 58 | }), |
59 | 59 | ] |
60 | 60 |
|
| 61 | +WAIT_OVERRIDE = { |
| 62 | + 101: 4.0, |
| 63 | + 102: 4.0, |
| 64 | + 103: 12.0, |
| 65 | + 104: 15.0, |
| 66 | + 105: 6.0, |
| 67 | + 106: 12.0, |
| 68 | + 107: 12.0, |
| 69 | +} |
| 70 | + |
61 | 71 | def drain(proc, seconds=2.0): |
62 | 72 | """Read stdout for up to `seconds`, print as it arrives, and return captured text.""" |
63 | 73 | out = [] |
@@ -191,29 +201,37 @@ def run(): |
191 | 201 | vec2_output = "" |
192 | 202 | for title, payload in TESTS: |
193 | 203 | print(f"\n### {title} ###") |
194 | | - out = send(proc, payload, wait=3.0) |
| 204 | + if payload["id"] == 105: |
| 205 | + node = extract_uuid(vec2_output) |
| 206 | + if not node: |
| 207 | + print("⚠️ No UUID found in vector_search output. Skipping graph_neighbors call.") |
| 208 | + continue |
| 209 | + print(f"Auto-detected node UUID from vector_search: {node}") |
| 210 | + payload = { |
| 211 | + **payload, |
| 212 | + "params": { |
| 213 | + **payload["params"], |
| 214 | + "arguments": { |
| 215 | + **payload["params"]["arguments"], |
| 216 | + "node": node |
| 217 | + } |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + wait_time = WAIT_OVERRIDE.get(payload["id"], 3.0) |
| 222 | + out = send(proc, payload, wait=wait_time) |
| 223 | + |
| 224 | + if not out.strip(): |
| 225 | + # Some tools (especially ones calling local LLMs) can take longer than |
| 226 | + # our initial wait window. Give them more time and capture any output. |
| 227 | + extra_wait = max(5.0, wait_time) |
| 228 | + extra = drain(proc, extra_wait) |
| 229 | + if extra: |
| 230 | + out += extra |
| 231 | + |
195 | 232 | if payload["id"] == 102: |
196 | 233 | vec2_output = out |
197 | 234 |
|
198 | | - if payload["id"] == 105: # graph_neighbors placeholder |
199 | | - if "REPLACE_WITH_NODE_UUID" in json.dumps(payload): |
200 | | - node = extract_uuid(vec2_output) |
201 | | - if node: |
202 | | - print(f"Auto-detected node UUID from vector_search: {node}") |
203 | | - payload = { |
204 | | - **payload, |
205 | | - "params": { |
206 | | - **payload["params"], |
207 | | - "arguments": { |
208 | | - **payload["params"]["arguments"], |
209 | | - "node": node |
210 | | - } |
211 | | - } |
212 | | - } |
213 | | - send(proc, payload, wait=3.0) |
214 | | - else: |
215 | | - print("⚠️ No UUID found in vector_search output. Skipping graph_neighbors actual call.") |
216 | | - |
217 | 235 | # Graceful shutdown |
218 | 236 | try: |
219 | 237 | proc.send_signal(signal.SIGINT) |
|
0 commit comments