Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

The 837-line safe_inputs.go mixed parsing, generation, and rendering concerns, making it harder to navigate and violating single responsibility principle.

Changes

Split into three focused files:

  • safe_inputs_parser.go (413 lines)

    • Configuration parsing: parseSafeInputsMap, ParseSafeInputs, extractSafeInputsConfig
    • Validation: HasSafeInputs, IsSafeInputsEnabled, IsSafeInputsHTTPMode
    • Name sanitization: sanitizeParameterName, sanitizePythonVariableName
    • Type definitions: SafeInputsConfig, SafeInputToolConfig, SafeInputParam
  • safe_inputs_generator.go (311 lines)

    • Tools config generation: generateSafeInputsToolsConfig
    • Script generation: MCP server entry point, JavaScript/Shell/Python tool handlers
    • Public wrappers for CLI inspector
  • safe_inputs_renderer.go (129 lines)

    • MCP config rendering: renderSafeInputsMCPConfigWithOptions
    • Environment variable and secret collection

All functions remain in workflow package. Tests split correspondingly into three files mirroring the production structure.

Follows existing patterns like create_*.go files (e.g., create_issue.go, create_pull_request.go).

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Split safe_inputs.go into focused modules</issue_title>
<issue_description>## Objective

Split pkg/workflow/safe_inputs.go (837 lines) into three focused files organized by responsibility: parsing, generation, and rendering.

Context

The current safe_inputs.go file mixes multiple concerns:

  • Parsing: parseSafeInputsMap, ParseSafeInputs
  • Configuration: HasSafeInputs, IsSafeInputsHTTPMode, IsSafeInputsEnabled
  • Generation: 10+ functions generating MCP server scripts and tool scripts
  • Rendering: MCP config rendering and environment variable collection
  • Utilities: Parameter name sanitization

This makes the file harder to navigate and violates single responsibility principle.

Implementation Steps

  1. Create pkg/workflow/safe_inputs_parser.go (~200 lines):

    • Move: parseSafeInputsMap
    • Move: ParseSafeInputs
    • Move: HasSafeInputs
    • Move: IsSafeInputsHTTPMode
    • Move: IsSafeInputsEnabled
    • Move: sanitizeParameterName
    • Move: sanitizePythonVariableName
  2. Create pkg/workflow/safe_inputs_generator.go (~400 lines):

    • Move: generateSafeInputsToolsConfig
    • Move: generateSafeInputsMCPServerScript
    • Move: generateSafeInputJavaScriptToolScript
    • Move: All related script generation functions
  3. Create pkg/workflow/safe_inputs_renderer.go (~200 lines):

    • Move: renderSafeInputsMCPConfigWithOptions
    • Move: getSafeInputsEnvVars
    • Move: collectSafeInputsSecrets
  4. Delete original pkg/workflow/safe_inputs.go after migration

  5. Update imports in any files that import safe_inputs functions

Files to Modify

Create:

  • pkg/workflow/safe_inputs_parser.go
  • pkg/workflow/safe_inputs_parser_test.go
  • pkg/workflow/safe_inputs_generator.go
  • pkg/workflow/safe_inputs_generator_test.go
  • pkg/workflow/safe_inputs_renderer.go
  • pkg/workflow/safe_inputs_renderer_test.go

Delete:

  • pkg/workflow/safe_inputs.go

Update:

  • Any files importing from safe_inputs.go (verify with grep)

Acceptance Criteria

  • All parsing functions in safe_inputs_parser.go
  • All generation functions in safe_inputs_generator.go
  • All rendering functions in safe_inputs_renderer.go
  • Original safe_inputs.go removed
  • All tests migrated and passing
  • No import errors in dependent files
  • make test passes
  • make lint passes

Testing

# Find all files importing safe_inputs
grep -r "safe_inputs" pkg/

# Verify tests pass
make fmt
make lint  
make test

Estimated Effort

4-6 hours
Related to #7778

AI generated by Plan Command for #7778

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 26, 2025
- Created safe_inputs_parser.go: parsing and configuration functions
- Created safe_inputs_generator.go: tool script generation functions
- Created safe_inputs_renderer.go: MCP config rendering functions
- Moved tests to corresponding test files
- Deleted original safe_inputs.go and safe_inputs_test.go
- All tests passing, code compiles successfully

Co-authored-by: mnkiefer <[email protected]>
Copilot AI changed the title [WIP] Split safe_inputs.go into focused modules Split safe_inputs.go into focused modules by responsibility Dec 26, 2025
Copilot AI requested a review from mnkiefer December 26, 2025 22:06
@pelikhan pelikhan marked this pull request as ready for review December 26, 2025 22:42
@pelikhan pelikhan merged commit 35dd166 into main Dec 26, 2025
163 checks passed
@pelikhan pelikhan deleted the copilot/split-safe-inputs-into-modules branch December 26, 2025 22:49
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.

[plan] Split safe_inputs.go into focused modules

3 participants