Skip to content

Commit c9a1536

Browse files
committed
feat: require file locations in all EXPLORATORY tier agent outputs
Enhanced all agentic tool EXPLORATORY prompts (Massive tier) to mandate file location citations for every code element mentioned in analysis. Changes to 6 prompt files: - code_search_prompts.rs: Added FILE LOCATIONS REQUIRED as rule #3 - dependency_analysis_prompts.rs: Added to CRITICAL RULES section - call_chain_prompts.rs: Added MANDATORY FILE LOCATION REQUIREMENT - architecture_analysis_prompts.rs: Added after YOUR TASK section - context_builder_prompts.rs: Added after YOUR MISSION section - semantic_question_prompts.rs: Added after CRITICAL RULE - agentic_api_surface_prompts.rs: Added after ZERO HEURISTICS RULE Required format: `ComponentName in path/to/file.rs:line_number` Example: "ConfigLoader in src/config/loader.rs:42" NOT "ConfigLoader" This ensures agents receive file paths they can use to drill down into specific code when needed, enabling better follow-up analysis and code navigation. Tool results already contain location data (file_path, start_line) - now agents are explicitly required to extract and include it in all outputs.
1 parent 99bfe6d commit c9a1536

File tree

7 files changed

+24
-1
lines changed

7 files changed

+24
-1
lines changed

crates/codegraph-mcp/src/agentic_api_surface_prompts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ YOUR TASK: Conduct exhaustive API ecosystem analysis including maximum-depth dep
234234
235235
ZERO HEURISTICS RULE: Make NO assumptions about what makes a "good" or "bad" API. Only report factual, measurable graph data from tool outputs.
236236
237+
MANDATORY FILE LOCATION REQUIREMENT:
238+
For EVERY API function/method/endpoint mentioned, ALWAYS include file location from tool results in format: `APIName in path/to/file.rs:line`. Example: "POST /api/users in src/api/users.rs:23" NOT just "POST /api/users".
239+
237240
AVAILABLE TOOLS:
238241
1. get_transitive_dependencies(node_id, edge_type, depth) - Follow dependency edges recursively (max depth 10)
239242
2. detect_circular_dependencies(edge_type) - Find bidirectional dependency cycles across entire codebase

crates/codegraph-mcp/src/architecture_analysis_prompts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ pub const ARCHITECTURE_ANALYSIS_EXPLORATORY: &str = r#"You are a principal archi
138138
139139
YOUR TASK: Perform complete, multi-dimensional architecture analysis using ONLY structured graph metrics - ZERO heuristics.
140140
141+
MANDATORY FILE LOCATION REQUIREMENT:
142+
For EVERY component/module/class mentioned in your analysis, ALWAYS include file location from tool results in format: `ComponentName in path/to/file.rs:line`. Example: "ConfigLoader in src/config/loader.rs:42" NOT just "ConfigLoader". Tool results contain location data - extract and use it.
143+
141144
AVAILABLE TOOLS (use extensively):
142145
1. calculate_coupling_metrics(node_id) - Complete coupling analysis for all significant nodes
143146
2. detect_circular_dependencies(edge_type) - ALL edge types (Imports, Calls, Uses, Extends, Implements)

crates/codegraph-mcp/src/call_chain_prompts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ pub const CALL_CHAIN_EXPLORATORY: &str = r#"You are a principal execution flow a
253253
254254
OBJECTIVE: Perform exhaustive call chain analysis to completely map execution paths, trace all invocation sequences, analyze control flow complexity, identify architectural patterns, and provide deep insights into code execution behavior across the entire codebase.
255255
256+
MANDATORY FILE LOCATION REQUIREMENT:
257+
For EVERY function/method/component mentioned in your analysis, ALWAYS include its file location from tool results in format: `FunctionName in path/to/file.rs:line_number`. Example: "process_request in src/handlers/request.rs:145" NOT just "process_request". Tool results contain location data (file_path, start_line) - extract and use it so agents can drill down into specific files.
258+
256259
AVAILABLE TOOLS (use comprehensively):
257260
258261
1. trace_call_chain(from_node, max_depth) - PRIMARY TRACING TOOL

crates/codegraph-mcp/src/code_search_prompts.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,14 @@ CRITICAL RULES (ABSOLUTELY MANDATORY):
300300
- Format: \"From [tool_name] result, node '[exact_node_id]' showed [specific_metric]\"
301301
- Cross-reference node IDs across multiple tool calls for validation
302302
303-
3. STRUCTURED REASONING CHAIN:
303+
3. FILE LOCATIONS REQUIRED:
304+
- For EVERY node/function/class/component mentioned, ALWAYS include its file location from tool results
305+
- Format: `ComponentName in path/to/file.rs:line_number` or `ComponentName (path/to/file.rs:line_number)`
306+
- Example: "ConfigLoader in src/config/loader.rs:42" NOT just "ConfigLoader"
307+
- Tool results contain location data (file_path, start_line) - extract and use it
308+
- This allows agents to drill down into specific files when needed
309+
310+
4. STRUCTURED REASONING CHAIN:
304311
- Build comprehensive reasoning chains across all tool calls
305312
- Explicitly connect each tool call to findings from previous calls
306313
- Cross-validate findings by approaching from multiple angles

crates/codegraph-mcp/src/context_builder_prompts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ pub const CONTEXT_BUILDER_EXPLORATORY: &str = r#"You are a code context builder
174174
YOUR MISSION:
175175
Build EXHAUSTIVE, ARCHITECTURALLY COMPLETE context for code understanding or generation. Leave no stone unturned - explore every facet of the codebase relevant to the query.
176176
177+
MANDATORY FILE LOCATION REQUIREMENT:
178+
For EVERY code element mentioned, ALWAYS include file location from tool results in format: `Name in path/to/file.rs:line`. Example: "parse_config in src/config/parser.rs:89" NOT just "parse_config".
179+
177180
AVAILABLE TOOLS:
178181
1. get_transitive_dependencies(node_id, edge_type, depth) - Map what this code needs
179182
2. detect_circular_dependencies(edge_type) - Find dependency cycles

crates/codegraph-mcp/src/dependency_analysis_prompts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ PHASE 7: COMPREHENSIVE SYNTHESIS & RECOMMENDATIONS
399399
CRITICAL RULES (Strict Adherence):
400400
- ABSOLUTE ZERO HEURISTICS: Every single claim must be backed by tool data
401401
- EXTRACT ALL NODE IDS: Use exact IDs from ALL tool results
402+
- FILE LOCATIONS REQUIRED: For EVERY node/component/function mentioned in your analysis, ALWAYS include its file location using data from tool results. Format: `ComponentName in src/path/file.rs:line_number`. Example: "WorkflowEngine in src/workflow/engine.rs:42" not just "WorkflowEngine"
402403
- MULTI-DIMENSIONAL COMPLETENESS: Cover all edge types, all depths, all hubs
403404
- STATISTICAL RIGOR: Calculate distributions, correlations, clustering
404405
- EXHAUSTIVE ENUMERATION: List ALL circular dependencies, ALL hubs, ALL outliers

crates/codegraph-mcp/src/semantic_question_prompts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ pub const SEMANTIC_QUESTION_EXPLORATORY: &str = r#"You are a principal code anal
323323
CRITICAL RULE - ZERO HEURISTICS:
324324
You MUST answer questions using EXCLUSIVELY the graph tools and their empirical results.
325325
326+
MANDATORY FILE LOCATION REQUIREMENT:
327+
For EVERY code element mentioned in your answer, ALWAYS include file location from tool results in format: `Name in path/to/file.rs:line`. Example: "authenticate in src/auth/handler.rs:156" NOT just "authenticate".
328+
326329
FORBIDDEN REASONING:
327330
1. General programming knowledge or idioms
328331
2. Naming conventions, prefixes, or suffixes

0 commit comments

Comments
 (0)