Skip to content

Conversation

@c-rick
Copy link
Contributor

@c-rick c-rick commented Jun 19, 2025

fix: issue 支持复杂参数
fix: default tenant name
feat: add .history ignore
feat: support config first complex arg edit

🔍 影响范围
核心模块:pkg/openapi/converter.go 中的 OpenAPI 转换逻辑
数据结构:internal/common/config/mcp.go 中的配置定义
向后兼容:保持了现有 API 的兼容性,不影响已有功能

Summary by Sourcery

Support complex nested object and array arguments by extending the OpenAPI converter, configuration/DTO schema, and rendering logic to handle recursive structures and normalize JSON string values

New Features:

  • Add recursive buildNestedArg function to convert nested object and array schemas in the OpenAPI converter
  • Extend ItemsConfig in config and DTO layers with Properties, Items, and Required fields to model complex types
  • Introduce NormalizeJSONStringValues function to parse string-encoded JSON arguments into native structures at runtime

Enhancements:

  • Switch template rendering to use toJSON for proper JSON serialization of argument values

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 19, 2025

Reviewer's Guide

This PR enriches argument processing to handle nested object and array structures: it extends the OpenAPI converter with a recursive builder, adapts data-transfer and config structs for nested ItemsConfig fields, refines template rendering to normalize JSON strings, and hooks normalization into the tool execution pipeline.

Sequence diagram for argument normalization in tool execution

sequenceDiagram
    participant Server
    participant Template
    participant Args as args (map)

    Server->>Args: fillDefaultArgs(tool, args)
    Server->>Template: NormalizeJSONStringValues(args)
    Template->>Args: Normalize JSON string values (in-place)
    Server->>Server: Log tool execution
Loading

Class diagram for updated ItemsConfig structure

classDiagram
    class ItemsConfig {
        +string Type
        +string[] Enum
        +map<string, any> Properties
        +ItemsConfig* Items
        +string[] Required
    }
Loading

Class diagram for recursive ItemsConfig conversion in DTO

classDiagram
    class config~ItemsConfig~ {
        +string Type
        +string[] Enum
        +map<string, any> Properties
        +ItemsConfig* Items
        +string[] Required
    }
    class dto~ItemsConfig~ {
        +string Type
        +string[] Enum
        +map<string, any> Properties
        +ItemsConfig* Items
        +string[] Required
    }
    config~ItemsConfig~ <.. dto~ItemsConfig~ : FromItemsConfig(cfg)
Loading

File-Level Changes

Change Details Files
Enhanced OpenAPI converter to support nested object and array arguments
  • Detect array types and attach nested items in converter
  • Swap body template formatting to use JSON serialization
  • Implement recursive buildNestedArg function for nested schemas
pkg/openapi/converter.go
Extended ItemsConfig in DTO to include nested properties and items
  • Added Properties, Items, and Required fields to ItemsConfig struct
  • Updated FromItemsConfig to recursively convert nested ItemsConfig objects
internal/common/dto/mcp.go
Refined argument preprocessing and normalization in template renderer
  • Removed JSON marshaling for slice arguments
  • Introduced NormalizeJSONStringValues to parse JSON strings into native types
internal/template/renderer.go
Augmented MCP config definitions and schema serialization for nested items
  • Added Items and Required fields to config ItemsConfig
  • Adjusted ToToolSchema to include nested properties for item definitions
internal/common/config/mcp.go
Integrated JSON string normalization into tool execution pipeline
  • Inserted NormalizeJSONStringValues call before executing HTTP tools
internal/core/tool.go

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @c-rick - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@iFurySt iFurySt left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@iFurySt iFurySt merged commit f8b5150 into AmoyLab:main Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants