@@ -191,6 +191,16 @@ fn tools_list() -> Value {
191191 "name" : "raysense_baseline_diff" ,
192192 "description" : "Diff the current project health against a saved baseline." ,
193193 "inputSchema" : baseline_schema( "Baseline directory. Defaults to <path>/.raysense/baseline." )
194+ } ,
195+ {
196+ "name" : "raysense_baseline_tables" ,
197+ "description" : "List Rayforce splayed tables saved in a Raysense baseline." ,
198+ "inputSchema" : baseline_table_schema( false )
199+ } ,
200+ {
201+ "name" : "raysense_baseline_table_read" ,
202+ "description" : "Read rows from a Rayforce splayed table saved in a Raysense baseline." ,
203+ "inputSchema" : baseline_table_schema( true )
194204 }
195205 ]
196206 } )
@@ -218,6 +228,8 @@ fn call_tool(params: &Value) -> Result<Value> {
218228 "raysense_memory_summary" => memory_summary_tool ( & args) ,
219229 "raysense_baseline_save" => baseline_save_tool ( & args) ,
220230 "raysense_baseline_diff" => baseline_diff_tool ( & args) ,
231+ "raysense_baseline_tables" => baseline_tables_tool ( & args) ,
232+ "raysense_baseline_table_read" => baseline_table_read_tool ( & args) ,
221233 _ => Err ( anyhow ! ( "unknown tool {name}" ) ) ,
222234 }
223235}
@@ -429,6 +441,49 @@ fn baseline_diff_tool(args: &Value) -> Result<Value> {
429441 } ) )
430442}
431443
444+ fn baseline_tables_tool ( args : & Value ) -> Result < Value > {
445+ let root = root_arg ( args) ?;
446+ let baseline_dir = baseline_dir_arg ( args, & root) ?;
447+ let tables_dir = baseline_dir. join ( "tables" ) ;
448+ let tables = raysense_memory:: list_baseline_tables ( & tables_dir)
449+ . with_context ( || format ! ( "failed to list baseline tables {}" , tables_dir. display( ) ) ) ?;
450+
451+ Ok ( json ! ( {
452+ "baseline_path" : baseline_dir,
453+ "tables_path" : tables_dir,
454+ "tables" : tables
455+ } ) )
456+ }
457+
458+ fn baseline_table_read_tool ( args : & Value ) -> Result < Value > {
459+ let root = root_arg ( args) ?;
460+ let baseline_dir = baseline_dir_arg ( args, & root) ?;
461+ let tables_dir = baseline_dir. join ( "tables" ) ;
462+ let table = args
463+ . get ( "table" )
464+ . and_then ( Value :: as_str)
465+ . ok_or_else ( || anyhow ! ( "table must be a string" ) ) ?;
466+ let offset = args
467+ . get ( "offset" )
468+ . map ( |value| {
469+ value
470+ . as_u64 ( )
471+ . map ( |value| value as usize )
472+ . ok_or_else ( || anyhow ! ( "offset must be a non-negative integer" ) )
473+ } )
474+ . transpose ( ) ?
475+ . unwrap_or ( 0 ) ;
476+ let limit = limit_arg ( args, 100 ) ?;
477+ let table_rows = raysense_memory:: read_baseline_table ( & tables_dir, table, offset, limit)
478+ . with_context ( || format ! ( "failed to read baseline table {}" , tables_dir. display( ) ) ) ?;
479+
480+ Ok ( json ! ( {
481+ "baseline_path" : baseline_dir,
482+ "tables_path" : tables_dir,
483+ "table" : table_rows
484+ } ) )
485+ }
486+
432487fn health_from_args ( args : & Value ) -> Result < ( PathBuf , raysense_core:: HealthSummary ) > {
433488 let root = root_arg ( args) ?;
434489 let config = effective_config ( args, & root) ?;
@@ -660,6 +715,23 @@ fn baseline_schema(path_description: &str) -> Value {
660715 } )
661716}
662717
718+ fn baseline_table_schema ( require_table : bool ) -> Value {
719+ let mut schema = json ! ( {
720+ "type" : "object" ,
721+ "properties" : {
722+ "path" : { "type" : "string" , "description" : "Project root. Defaults to the current directory." } ,
723+ "baseline_path" : { "type" : "string" , "description" : "Baseline directory. Defaults to <path>/.raysense/baseline." } ,
724+ "table" : { "type" : "string" , "description" : "Baseline table name, such as files, functions, imports, calls, call_edges, health, hotspots, rules, module_edges, or changed_files." } ,
725+ "offset" : { "type" : "integer" , "minimum" : 0 , "description" : "First row offset. Defaults to 0." } ,
726+ "limit" : { "type" : "integer" , "minimum" : 1 , "description" : "Maximum rows to return. Defaults to 100." }
727+ }
728+ } ) ;
729+ if require_table {
730+ schema[ "required" ] = json ! ( [ "table" ] ) ;
731+ }
732+ schema
733+ }
734+
663735fn limited < T : serde:: Serialize > ( items : & [ T ] , limit : usize ) -> Vec < Value > {
664736 items
665737 . iter ( )
@@ -695,6 +767,8 @@ mod tests {
695767 assert ! ( names. contains( & "raysense_memory_summary" ) ) ;
696768 assert ! ( names. contains( & "raysense_baseline_save" ) ) ;
697769 assert ! ( names. contains( & "raysense_baseline_diff" ) ) ;
770+ assert ! ( names. contains( & "raysense_baseline_tables" ) ) ;
771+ assert ! ( names. contains( & "raysense_baseline_table_read" ) ) ;
698772 }
699773
700774 #[ test]
0 commit comments