Refactor MCP tree server: dispatch table, caching, validation, subprocess cleanup
Break up the 1735-line handle_tool match into 45 individual handler functions with hashtable-based dispatch. Add mtime-based file parse caching (AST + CST), consolidated run_command helper replacing 9 bare open_process_in patterns, require_file/require_dir input validation, and pagination (limit/offset) for sx_find_across, sx_comp_list, sx_comp_usage. Also includes pending VM changes: rest-arity support, hyperscript parser, compiler/transpiler updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -186,6 +186,7 @@ let get_val container key =
|
||||
Hashtbl.replace d "vc-bytecode" (List bc);
|
||||
Hashtbl.replace d "vc-constants" (List consts);
|
||||
Hashtbl.replace d "vc-arity" (Number (float_of_int c.vc_arity));
|
||||
Hashtbl.replace d "vc-rest-arity" (Number (float_of_int c.vc_rest_arity));
|
||||
Hashtbl.replace d "vc-locals" (Number (float_of_int c.vc_locals));
|
||||
Dict d
|
||||
| "vm-upvalues" ->
|
||||
@@ -496,13 +497,28 @@ let _jit_hit = ref 0
|
||||
let _jit_miss = ref 0
|
||||
let _jit_skip = ref 0
|
||||
let jit_reset_counters () = _jit_hit := 0; _jit_miss := 0; _jit_skip := 0
|
||||
(* Sentinel value for "JIT skipped — fall back to CEK".
|
||||
Must be distinguishable from any legitimate return value including Nil.
|
||||
We use a unique tagged dict that is_jit_skip can identify. *)
|
||||
let _jit_skip_sentinel =
|
||||
let d = Hashtbl.create 1 in
|
||||
Hashtbl.replace d "__jit_skip" (Bool true);
|
||||
Dict d
|
||||
|
||||
let is_jit_skip v = match v with
|
||||
| Dict d -> Hashtbl.mem d "__jit_skip"
|
||||
| _ -> false
|
||||
|
||||
(* Platform function for the spec: (jit-skip? v) → transpiles to jit_skip_p *)
|
||||
let jit_skip_p v = Bool (is_jit_skip v)
|
||||
|
||||
let jit_try_call f args =
|
||||
match !_jit_try_call_fn with
|
||||
| None -> incr _jit_skip; Nil
|
||||
| None -> incr _jit_skip; _jit_skip_sentinel
|
||||
| Some hook ->
|
||||
match f with
|
||||
| Lambda l when l.l_name <> None ->
|
||||
let arg_list = match args with List a | ListRef { contents = a } -> a | _ -> [] in
|
||||
(match hook f arg_list with Some result -> incr _jit_hit; result | None -> incr _jit_miss; Nil)
|
||||
| _ -> incr _jit_skip; Nil
|
||||
(match hook f arg_list with Some result -> incr _jit_hit; result | None -> incr _jit_miss; _jit_skip_sentinel)
|
||||
| _ -> incr _jit_skip; _jit_skip_sentinel
|
||||
|
||||
|
||||
Reference in New Issue
Block a user