@@ -6,6 +6,7 @@ fn test_all_prompts_loaded() {
66 assert ! ( !SYSTEM_DEFAULT . is_empty( ) ) ;
77 assert ! ( !CONTINUATION . is_empty( ) ) ;
88 assert ! ( !BOUNDARIES . is_empty( ) ) ;
9+ assert ! ( !REPOSITORY_TOOL_CONTRACT . is_empty( ) ) ;
910 assert ! ( !AGENT_EXPLORE . is_empty( ) ) ;
1011 assert ! ( !AGENT_PLAN . is_empty( ) ) ;
1112 assert ! ( !AGENT_CODE_REVIEW . is_empty( ) ) ;
@@ -100,6 +101,65 @@ fn test_boundaries_not_duplicated_in_general_purpose() {
100101 assert_eq ! ( built. matches( "## Boundaries" ) . count( ) , 1 ) ;
101102}
102103
104+ #[ test]
105+ fn test_repository_tool_contract_is_injected_for_every_style ( ) {
106+ let required_contract = [
107+ "## Repository Tool Contract" ,
108+ "`file_path`" ,
109+ "`files`" ,
110+ "`max_output_bytes`" ,
111+ "`metadata.batch.continuation`" ,
112+ "`output_mode`" ,
113+ "`files_with_matches`" ,
114+ "`metadata.page.next_cursor`" ,
115+ "`sort: \" path\" `" ,
116+ "`dry_run`" ,
117+ "`expected_replacements`" ,
118+ "`max_replacements`" ,
119+ ] ;
120+
121+ for style in [
122+ AgentStyle :: GeneralPurpose ,
123+ AgentStyle :: Plan ,
124+ AgentStyle :: Verification ,
125+ AgentStyle :: Explore ,
126+ AgentStyle :: CodeReview ,
127+ ] {
128+ let built = SystemPromptSlots :: default ( ) . with_style ( style) . build ( ) ;
129+ for expected in required_contract {
130+ assert ! (
131+ built. contains( expected) ,
132+ "style {style:?} missing repository-tool guidance: {expected}"
133+ ) ;
134+ }
135+ }
136+ }
137+
138+ #[ test]
139+ fn test_repository_tool_contract_is_not_duplicated ( ) {
140+ let built = SystemPromptSlots :: default ( ) . build ( ) ;
141+ assert_eq ! ( built. matches( "## Repository Tool Contract" ) . count( ) , 1 ) ;
142+ }
143+
144+ #[ test]
145+ fn test_repository_tool_contract_tracks_registered_schema_parameters ( ) {
146+ for ( tool, schema) in crate :: tools:: builtin:: repository_tool_parameter_schemas ( ) {
147+ assert ! (
148+ REPOSITORY_TOOL_CONTRACT . contains( & format!( "`{tool}`" ) ) ,
149+ "repository-tool contract missing tool: {tool}"
150+ ) ;
151+ let properties = schema[ "properties" ]
152+ . as_object ( )
153+ . unwrap_or_else ( || panic ! ( "{tool} schema has no object properties" ) ) ;
154+ for parameter in properties. keys ( ) {
155+ assert ! (
156+ REPOSITORY_TOOL_CONTRACT . contains( & format!( "`{parameter}`" ) ) ,
157+ "repository-tool contract missing {tool} parameter: {parameter}"
158+ ) ;
159+ }
160+ }
161+ }
162+
103163#[ test]
104164fn test_slots_custom_role_replaces_default ( ) {
105165 let slots = SystemPromptSlots {
@@ -399,6 +459,7 @@ fn test_code_review_guidelines_appended() {
399459fn test_prompts_do_not_reference_removed_surfaces ( ) {
400460 let prompts = [
401461 SYSTEM_DEFAULT ,
462+ REPOSITORY_TOOL_CONTRACT ,
402463 AGENT_VERIFICATION ,
403464 PRE_ANALYSIS_SYSTEM ,
404465 AGENT_EXPLORE ,
0 commit comments