Skip to content

Conversation

@quanru
Copy link
Collaborator

@quanru quanru commented Dec 1, 2025

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

@netlify
Copy link

netlify bot commented Dec 1, 2025

Deploy Preview for midscene ready!

Name Link
🔨 Latest commit f0f0882
🔍 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.

@quanru quanru closed this Dec 2, 2025
@quanru quanru reopened this Dec 2, 2025
@quanru quanru requested a review from Copilot December 2, 2025 07:36
Copilot finished reviewing on behalf of quanru December 2, 2025 07:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends YAML agent configuration to support all serializable fields from AgentOpt, adding 7 new configuration options (testId, groupName, groupDescription, generateReport, autoPrintReportMsg, reportFileName, replanningCycleLimit) to achieve feature parity with programmatic API usage.

Key changes:

  • Extended MidsceneYamlScriptAgentOpt type to include 7 new agent configuration fields with comprehensive JSDoc documentation
  • Updated all 5 agent creation paths (Puppeteer, Bridge, Android, iOS, Generic Interface) to propagate extended options
  • Implemented buildAgentOptions() and resolveTestId() helper functions with proper priority handling (CLI > YAML > filename)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/yaml.ts Extended MidsceneYamlScriptAgentOpt type with 7 new fields and added JSDoc documentation
packages/web-integration/src/puppeteer/agent-launcher.ts Updated puppeteerAgentForTarget signature to accept extended agent options via intersection type
packages/cli/src/create-yaml-player.ts Added helper functions buildAgentOptions() and resolveTestId(), updated all 5 agent creation paths to use these helpers
packages/cli/tests/unit-test/create-yaml-player.test.ts Added 7 new tests covering extended options propagation, testId priority, and helper function getMockCallArg()
packages/cli/tests/midscene_scripts/agent-opts/extended-options.yml Integration test file demonstrating all new agent configuration fields
apps/site/docs/en/automate-with-scripts-in-yaml.mdx Updated English documentation with complete agent field descriptions and examples
apps/site/docs/zh/automate-with-scripts-in-yaml.mdx Updated Chinese documentation with complete agent field descriptions and examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@quanru quanru requested a review from Copilot December 2, 2025 08:16
Copilot finished reviewing on behalf of quanru December 2, 2025 08:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

### `agent` 部分

如需使用 `aiActionContext` 参数,可以通过 `agent` 部分来设置:
`agent` 部分用于配置 AI 代理的行为和测试报告相关选项。所有字段都是可选的。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"代理" --> Agent

quanru and others added 2 commits December 2, 2025 20:23
Extended YAML agent configuration to support 7 additional AgentOpt fields:
- testId, groupName, groupDescription
- generateReport, autoPrintReportMsg, reportFileName
- replanningCycleLimit

Key changes:
- Updated MidsceneYamlScriptAgentOpt type with comprehensive JSDoc
- Modified all 5 agent creation paths (Web/Puppeteer, Bridge, Android, iOS, Interface)
- Updated puppeteerAgentForTarget signature to accept new options
- Added helper functions (buildAgentOptions, resolveTestId, getMockCallArg)
- Unified autoPrintReportMsg handling across platforms
- Updated English and Chinese documentation with complete agent config examples

All 77 tests passing. Maintains backward compatibility - all fields optional.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add 'aiActionContext' to the Pick type in puppeteerAgentForTarget function
signature to reflect the actual API usage. The buildAgentOptions() in
create-yaml-player.ts spreads the entire yamlAgent object (including
aiActionContext) which gets passed through the preference parameter.
This makes the API contract explicit and prevents type confusion.

Resolves Copilot PR review comment.
@quanru quanru force-pushed the feat/yaml-agent-options-support branch from 7bb3bfa to 690f55b Compare December 2, 2025 12:24
Replace '代理' with 'Agent' in Chinese documentation to maintain
consistency with technical terminology.

Resolves yuyutaotao's review comment.
@yuyutaotao yuyutaotao merged commit a94dd07 into v1 Dec 2, 2025
8 checks passed
@yuyutaotao yuyutaotao deleted the feat/yaml-agent-options-support branch December 2, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants