From 1fdccd1c3b6c223a30bd8f3a162f8399840b5237 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sat, 18 Jul 2026 14:16:43 +0800 Subject: [PATCH] feat(cli): import:html subcommand mapping to the import_html mcp tool --- crates/op-cli/src/main.rs | 22 ++++++++++++++++++++++ crates/op-cli/src/tests.rs | 24 ++++++++++++++++++++++++ crates/op-cli/src/usage.txt | 1 + 3 files changed, 47 insertions(+) diff --git a/crates/op-cli/src/main.rs b/crates/op-cli/src/main.rs index 8445f09cf..435d10b2c 100644 --- a/crates/op-cli/src/main.rs +++ b/crates/op-cli/src/main.rs @@ -360,6 +360,7 @@ fn command_from_positionals(positionals: &[String], flags: &Flags) -> Result map_layout(flags), "find-space" => map_find_space(flags), "import:svg" => map_import_svg(positionals, flags), + "import:html" => map_import_html(positionals, flags), "import:figma" => figma_cli::map_import_figma(positionals, flags), "codegen:plan" | "codegen:submit" | "codegen:assemble" | "codegen:clean" => { codegen_cli::map_codegen(positionals, flags) @@ -698,6 +699,27 @@ fn map_import_svg(positionals: &[String], flags: &Flags) -> Result Result { + let path = required_pos( + positionals, + 1, + "Usage: op import:html [--x N] [--y N] [--parent P] [--page PAGE]", + )?; + let mut pairs = vec![pair("htmlPath", path)]; + for (flag, key) in [ + ("x", "x"), + ("y", "y"), + ("parent", "parent"), + ("page", "pageId"), + ] { + if let Some(value) = flag_value(flags, flag) { + pairs.push(pair(key, value)); + } + } + push_file_path(&mut pairs, flags); + tool_call("import_html", pairs) +} + fn generic_tool_call(tool: &str, rest: &[String], flags: &Flags) -> Result { let mut pairs = Vec::new(); for kv in rest { diff --git a/crates/op-cli/src/tests.rs b/crates/op-cli/src/tests.rs index 0fbab3447..128508481 100644 --- a/crates/op-cli/src/tests.rs +++ b/crates/op-cli/src/tests.rs @@ -706,6 +706,30 @@ fn parse_args_maps_import_figma_to_direct_converter() { ); } +#[test] +fn import_html_maps_to_tool_call() { + let args = vec![ + "import:html".to_string(), + "page.html".to_string(), + "--x".to_string(), + "10".to_string(), + "--page".to_string(), + "p1".to_string(), + ]; + let parsed = parse_args(&args).expect("parse"); + assert_eq!( + parsed.command, + Command::ToolCall { + tool: "import_html".to_string(), + args: vec![ + ("htmlPath".to_string(), "page.html".to_string()), + ("x".to_string(), "10".to_string()), + ("pageId".to_string(), "p1".to_string()), + ], + } + ); +} + #[test] fn figma_default_out_path_matches_ts_suffix_replacement() { assert_eq!(figma_default_out_path("checkout.fig"), "checkout.op"); diff --git a/crates/op-cli/src/usage.txt b/crates/op-cli/src/usage.txt index ac54e5730..3400f2409 100644 --- a/crates/op-cli/src/usage.txt +++ b/crates/op-cli/src/usage.txt @@ -55,6 +55,7 @@ COMMON COMMANDS: op layout [--parent P] [--depth N] snapshot layout tree op find-space [--direction D] [--width W] [--height H] op import:svg [--x N] [--y N] [--parent P] [--page PAGE] + op import:html [--x N] [--y N] [--parent P] [--page PAGE] op import:figma [--out output.op] op codegen:plan op codegen:submit