feat(rust): add --scene-info-json parameter for LLM extraction results
- Add SceneInfoJson struct with serde rename for camelCase compatibility - Add ApiEndpointJson and BusinessLogicJson support structs - Add scene_info_json field to GenerateSceneRequest (backward compatible) - Rename browser_script to browser_script_skeleton - Add new browser_script that delegates based on scene_info presence - Add browser_script_with_business_logic for enhanced script generation - Update CLI to accept --scene-info-json parameter - Update usage string to document new parameter Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -2,7 +2,7 @@ use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use sgclaw::generated_scene::analyzer::SceneKind;
|
||||
use sgclaw::generated_scene::generator::{generate_scene_package, GenerateSceneRequest};
|
||||
use sgclaw::generated_scene::generator::{generate_scene_package, GenerateSceneRequest, SceneInfoJson};
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = run() {
|
||||
@@ -13,6 +13,10 @@ fn main() {
|
||||
|
||||
fn run() -> Result<(), String> {
|
||||
let args = parse_args(env::args().skip(1))?;
|
||||
let scene_info: Option<SceneInfoJson> = args.scene_info_json
|
||||
.map(|json| serde_json::from_str(&json))
|
||||
.transpose()
|
||||
.map_err(|e| format!("Invalid scene-info-json: {}", e))?;
|
||||
let skill_root = generate_scene_package(GenerateSceneRequest {
|
||||
source_dir: args.source_dir,
|
||||
scene_id: args.scene_id,
|
||||
@@ -21,6 +25,7 @@ fn run() -> Result<(), String> {
|
||||
target_url: args.target_url,
|
||||
output_root: args.output_root,
|
||||
lessons_path: args.lessons_path,
|
||||
scene_info_json: scene_info,
|
||||
})
|
||||
.map_err(|err| err.to_string())?;
|
||||
|
||||
@@ -35,7 +40,8 @@ struct CliArgs {
|
||||
scene_kind: Option<SceneKind>,
|
||||
target_url: Option<String>,
|
||||
output_root: PathBuf,
|
||||
lessons_path: PathBuf,
|
||||
lessons_path: Option<PathBuf>,
|
||||
scene_info_json: Option<String>,
|
||||
}
|
||||
|
||||
fn parse_args(args: impl Iterator<Item = String>) -> Result<CliArgs, String> {
|
||||
@@ -46,6 +52,7 @@ fn parse_args(args: impl Iterator<Item = String>) -> Result<CliArgs, String> {
|
||||
let mut target_url = None;
|
||||
let mut output_root = None;
|
||||
let mut lessons_path = None;
|
||||
let mut scene_info_json = None;
|
||||
let mut pending_flag: Option<String> = None;
|
||||
|
||||
for arg in args {
|
||||
@@ -63,6 +70,7 @@ fn parse_args(args: impl Iterator<Item = String>) -> Result<CliArgs, String> {
|
||||
"--target-url" => target_url = Some(arg),
|
||||
"--output-root" => output_root = Some(PathBuf::from(arg)),
|
||||
"--lessons" => lessons_path = Some(PathBuf::from(arg)),
|
||||
"--scene-info-json" => scene_info_json = Some(arg),
|
||||
_ => return Err(format!("unsupported argument {flag}")),
|
||||
}
|
||||
continue;
|
||||
@@ -70,7 +78,7 @@ fn parse_args(args: impl Iterator<Item = String>) -> Result<CliArgs, String> {
|
||||
|
||||
match arg.as_str() {
|
||||
"--source-dir" | "--scene-id" | "--scene-name" | "--scene-kind" | "--target-url"
|
||||
| "--output-root" | "--lessons" => {
|
||||
| "--output-root" | "--lessons" | "--scene-info-json" => {
|
||||
pending_flag = Some(arg);
|
||||
}
|
||||
"--help" | "-h" => return Err(usage()),
|
||||
@@ -89,10 +97,11 @@ fn parse_args(args: impl Iterator<Item = String>) -> Result<CliArgs, String> {
|
||||
scene_kind,
|
||||
target_url,
|
||||
output_root: output_root.ok_or_else(usage)?,
|
||||
lessons_path: lessons_path.ok_or_else(usage)?,
|
||||
lessons_path,
|
||||
scene_info_json,
|
||||
})
|
||||
}
|
||||
|
||||
fn usage() -> String {
|
||||
"usage: sg_scene_generate --source-dir <scenario-dir> --scene-id <scene-id> --scene-name <display-name> [--scene-kind <report_collection|monitoring>] [--target-url <url>] --output-root <skill-staging-root> --lessons <lessons-toml>".to_string()
|
||||
"usage: sg_scene_generate --source-dir <scenario-dir> --scene-id <scene-id> --scene-name <display-name> [--scene-kind <report_collection|monitoring>] [--target-url <url>] --output-root <skill-staging-root> [--lessons <lessons-toml>] [--scene-info-json '<json>']".to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user