Skip to content

Conversation

@baxen
Copy link
Collaborator

@baxen baxen commented Dec 25, 2025

Summary

Refactors the add_extension function in extension_manager.rs to reduce its line count from 259 lines to 129 lines (well under the 200 line target).

Changes

Extracted the following helper functions from add_extension:

  • merge_environments: Async function to merge environment variables from direct envs and keychain-stored env_keys
  • substitute_env_vars: Function to substitute environment variables in strings (supports both ${VAR} and $VAR syntax)
  • create_streamable_http_client: Async function to create StreamableHttp MCP clients with header substitution and OAuth support
  • create_stdio_client: Async function to create Stdio MCP clients with malware checking

Also updated the test to use the module-level substitute_env_vars function instead of duplicating it.

Testing

  • All existing tests pass
  • Clippy passes with no warnings
  • Code formatted with cargo fmt

Related

Part of TSK-696: Simplify clippy baseline system

Extract helper functions from the 259-line add_extension function:
- merge_environments: async function to merge env vars from direct envs and keychain
- substitute_env_vars: function to substitute env vars in strings (supports ${VAR} and $VAR)
- create_streamable_http_client: async function to create StreamableHttp MCP clients
- create_stdio_client: async function to create Stdio MCP clients

The add_extension function is now 129 lines (down from 259), well under the 200 line target.

Also updated the test to use the module-level substitute_env_vars function instead of duplicating it.
Copilot AI review requested due to automatic review settings December 25, 2025 03:17
Copy link
Contributor

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 successfully refactors the add_extension function in extension_manager.rs to reduce its line count from 259 to 129 lines by extracting helper functions. The refactoring is purely structural with no behavioral changes.

  • Extracts four helper functions: merge_environments, substitute_env_vars, create_streamable_http_client, and create_stdio_client
  • Updates the test to use the newly module-level substitute_env_vars function instead of duplicating it
  • Maintains all existing functionality and error handling patterns

@baxen baxen marked this pull request as draft December 25, 2025 03:29
@block block deleted a comment from Copilot AI Dec 25, 2025
@baxen baxen marked this pull request as ready for review December 25, 2025 04:07
@baxen baxen changed the title TSK-705: Refactor add_extension to reduce line count chore: refactor add_extension to reduce line count Dec 25, 2025
@baxen baxen mentioned this pull request Dec 26, 2025
11 tasks
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