midscene icon indicating copy to clipboard operation
midscene copied to clipboard

feat(cli): add full agent options support to YAML scripts

Open quanru opened this issue 3 weeks ago • 1 comments

Summary

Extended YAML agent configuration to support all serializable fields from AgentOpt, adding 7 new configuration options:

  • testId, groupName, groupDescription
  • generateReport, autoPrintReportMsg, reportFileName
  • replanningCycleLimit

Previously, YAML scripts only supported aiActionContext and cache in the agent section. This PR brings YAML configuration to feature parity with programmatic API usage.

Key Changes

Type System

  • Extended MidsceneYamlScriptAgentOpt type using TypeScript's Pick utility
  • Added comprehensive JSDoc documentation with examples and priority rules
  • Excludes non-serializable fields (functions, modelConfig)

Implementation

  • Modified all 5 agent creation paths:
    • Web/Puppeteer (puppeteerAgentForTarget)
    • Bridge Mode (AgentOverChromeBridge)
    • Android (agentFromAdbDevice)
    • iOS (agentFromWebDriverAgent)
    • Generic Interface (createAgent)
  • Updated puppeteerAgentForTarget function signature to accept new agent options
  • Introduced helper functions to reduce code duplication:
    • buildAgentOptions(): Merges YAML agent config with cache and testId
    • resolveTestId(): Implements priority resolution (CLI > YAML > filename)
    • getMockCallArg<T>(): Test helper for cleaner mock assertions

Configuration Priority

  • testId priority: CLI parameter > YAML agent.testId > filename
  • modelConfig: Configured via environment variables (not in YAML)

Code Quality Improvements

  • Unified autoPrintReportMsg handling across platforms
  • Eliminated code duplication through helper functions
  • Added JSDoc documentation for better developer experience
  • All 77 tests passing with 100% backward compatibility

Documentation Updates

Updated both English and Chinese documentation:

  • Complete agent configuration section with all fields
  • Field descriptions and usage examples
  • Priority rules and best practices
  • Example YAML configurations

Testing

  • Added 7 new unit tests covering extended agent options
  • Created integration test YAML file (extended-options.yml)
  • All 29 create-yaml-player tests passing
  • Total: 77 tests passing across all test suites

Backward Compatibility

✅ Fully backward compatible - all new fields are optional. Existing YAML scripts continue to work without modification.

🤖 Generated with Claude Code

quanru avatar Dec 01 '25 11:12 quanru

Deploy Preview for midscene ready!

Name Link
Latest commit f0f088254425185237462132ff6a1ebe1ece2088
Latest deploy log https://app.netlify.com/projects/midscene/deploys/692edb3d9961c50008f36cb4
Deploy Preview https://deploy-preview-1526--midscene.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Dec 01 '25 11:12 netlify[bot]