Conversation
…plication, move outlier free functions
- Absorb internal/dockerutil (single-function package) into internal/mcp
- Moved ExpandEnvArgs to internal/mcp/dockerenv.go
- Updated connection.go and connection_test.go; consolidated test cases
- Deleted internal/dockerutil directory
- Fix auth.TruncateSessionID duplication with strutil.Truncate
- TruncateSessionID delegates to strutil.Truncate(sessionID, 8)
- Move toDIFCTags/tagsToStrings from unified.go to internal/difc
- New internal/difc/tags.go with exported StringsToTags/TagsToStrings
- Added unit tests in internal/difc/tags_test.go
- Move convertToCallToolResult/parseToolArguments from unified.go to internal/mcp
- New internal/mcp/tool_result.go with ConvertToCallToolResult/ParseToolArguments
- Updated unified.go and its test to use mcp.* versions
- Uses logger.New('mcp:tool_result') for debug logging per project conventions
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
lpcox
March 15, 2026 00:08
View session
7 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors and “clusters” semantically related helper functions into the packages where they logically belong, removing a single-function package and reducing duplication across the codebase.
Changes:
- Moved Docker
-e VARenvironment expansion logic intointernal/mcpand removedinternal/dockerutil. - Deduplicated
auth.TruncateSessionIDby delegating tostrutil.Truncate. - Moved DIFC tag conversion helpers out of
UnifiedServerintointernal/difcwith new unit tests. - Moved MCP tool result/argument parsing helpers out of
UnifiedServerintointernal/mcp, updating call sites and tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/server/unified.go | Switched to new mcp/difc helper functions; removed local free functions. |
| internal/server/call_tool_result_test.go | Updated tests to call mcp.ConvertToCallToolResult. |
| internal/mcp/tool_result.go | New home for ConvertToCallToolResult and ParseToolArguments with debug logging. |
| internal/mcp/dockerenv.go | Absorbed Docker env expansion helper into mcp with updated logger namespace. |
| internal/mcp/connection.go | Uses local ExpandEnvArgs instead of dockerutil. |
| internal/mcp/connection_test.go | Consolidated/expanded Docker env arg tests; removed dockerutil import. |
| internal/difc/tags.go | New exported DIFC tag/string conversion helpers. |
| internal/difc/tags_test.go | Unit tests for StringsToTags / TagsToStrings. |
| internal/auth/header.go | TruncateSessionID now delegates to strutil.Truncate. |
| internal/dockerutil/env_test.go | Removed as part of deleting the internal/dockerutil package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This was referenced Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the actionable improvements identified in issue #1827 (semantic function clustering analysis).
Changes
1. Absorb
internal/dockerutilintointernal/mcpThe
internal/dockerutilpackage contained a single function (ExpandEnvArgs) used exclusively byinternal/mcp/connection.go. Moving it eliminates the single-function package:internal/mcp/dockerenv.gowithExpandEnvArgsconnection.goto use the local function (no more import ofdockerutil)TestExpandDockerEnvArgsinconnection_test.gowith the 4 additional test cases from the olddockerutil/env_test.gointernal/dockerutil/2. Reduce duplication in
auth.TruncateSessionIDTruncateSessionIDininternal/auth/header.goduplicated the truncation logic already ininternal/strutil/truncate.go. It now delegates tostrutil.Truncate(sessionID, 8), keeping only the"(none)"special-case for empty strings.3. Move
toDIFCTags/tagsToStringsfromunified.gotointernal/difcThese free functions only deal with
difc.Tagtypes and have no dependency on server logic. Exported asdifc.StringsToTags/difc.TagsToStringsin a newinternal/difc/tags.gofile with unit tests.4. Move
convertToCallToolResult/parseToolArgumentsfromunified.gotointernal/mcpThese MCP SDK utility functions are generic enough to belong in the
mcppackage alongside other protocol helpers. Exported asmcp.ConvertToCallToolResult/mcp.ParseToolArgumentsininternal/mcp/tool_result.go, usinglogger.New("mcp:tool_result")for debug logging per project conventions.Testing
make agent-finished)difc.StringsToTags/difc.TagsToStringsCloses #1827