1+ import type { Command } from "commander" ;
2+
3+ import type { CliDeps } from "../../cli/context.js" ;
4+ import { unwrapResponse } from "../../cli/shared.js" ;
5+
6+ function printJson ( data : unknown ) : void {
7+ console . log ( JSON . stringify ( data , null , 2 ) ) ;
8+ }
9+
10+ export function registerRozeniteCliCommands ( program : Command , deps : CliDeps ) : void {
11+ const rozenite = program . command ( "rozenite" ) . description ( "Rozenite React Native devtools bridge" ) ;
12+
13+ rozenite
14+ . command ( "status" )
15+ . description ( "Show Rozenite plugin state and registered tool count" )
16+ . action ( async ( ) => {
17+ const data = unwrapResponse (
18+ await deps . sendCommand ( { type : "plugin-command" , pluginId : "rozenite" , command : "status" } ) ,
19+ "Failed to get Rozenite status"
20+ ) ;
21+ printJson ( data ) ;
22+ } ) ;
23+
24+ rozenite
25+ . command ( "tools" )
26+ . description ( "List registered Rozenite tools" )
27+ . action ( async ( ) => {
28+ const data = unwrapResponse (
29+ await deps . sendCommand ( { type : "plugin-command" , pluginId : "rozenite" , command : "tools" } ) ,
30+ "Failed to list Rozenite tools"
31+ ) ;
32+ printJson ( data ) ;
33+ } ) ;
34+
35+ rozenite
36+ . command ( "tool-schema <name>" )
37+ . description ( "Show input schema for a Rozenite tool" )
38+ . action ( async ( name : string ) => {
39+ const data = unwrapResponse (
40+ await deps . sendCommand ( {
41+ type : "plugin-command" ,
42+ pluginId : "rozenite" ,
43+ command : "tool-schema" ,
44+ input : { name } ,
45+ } ) ,
46+ `Failed to get schema for tool '${ name } '`
47+ ) ;
48+ printJson ( data ) ;
49+ } ) ;
50+
51+ rozenite
52+ . command ( "call <name>" )
53+ . description ( "Call a Rozenite tool" )
54+ . option ( "--input <json>" , "Tool input as JSON string" )
55+ . action ( async ( name : string , options : { input ?: string } ) => {
56+ const args = options . input !== undefined ? ( JSON . parse ( options . input ) as unknown ) : undefined ;
57+ const data = unwrapResponse (
58+ await deps . sendCommand ( {
59+ type : "plugin-command" ,
60+ pluginId : "rozenite" ,
61+ command : "call" ,
62+ input : { name, arguments : args } ,
63+ } ) ,
64+ `Failed to call tool '${ name } '`
65+ ) ;
66+ printJson ( data ) ;
67+ } ) ;
68+ }
0 commit comments