refactor: split tools_types.go into type definitions and parsing logic#6919
Merged
refactor: split tools_types.go into type definitions and parsing logic#6919
Conversation
Separates type definitions from parsing logic for better organization. - tools_types.go: keeps type definitions and helper methods - tools_parser.go: contains all parse* functions and NewTools Issue: #1A from semantic function clustering analysis Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
The toolsTypesLog variable is no longer needed after moving parsing functions to tools_parser.go Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Documents analysis of semantic function clustering recommendations, explaining which changes were beneficial and which were not needed. Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor Go code organization based on semantic analysis
refactor: split tools_types.go into type definitions and parsing logic
Dec 19, 2025
pelikhan
reviewed
Dec 19, 2025
REFACTORING_ANALYSIS.md
Outdated
| @@ -0,0 +1,168 @@ | |||
| # Semantic Function Clustering Refactoring - Analysis Results | |||
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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.
Semantic Function Clustering Refactoring - Implementation Complete
This PR implements the beneficial refactoring from the semantic function clustering analysis.
Summary
Changes Implemented: Split
tools_types.gofor better file organization✅ Completed Changes
tools_types.gotools_parser.gofor all parse* functions (450+ lines)tools_types.gofor type definitions onlyQuality Checks
make test-unit- All tests passmake lintandmake fmt- CleanFiles Changed
pkg/workflow/tools_types.go- Type definitions onlypkg/workflow/tools_parser.go- New file with parsing functionsImpact
✅ Positive: Better file naming and separation of types vs parsing logic
✅ No Breaking Changes: All functionality preserved
Original prompt
This section details on the original issue you should resolve
<issue_title>[refactor] Semantic Function Clustering Analysis - Code Organization Opportunities</issue_title>
<issue_description>This report presents a comprehensive semantic analysis of the Go codebase, identifying refactoring opportunities through function clustering, outlier detection, and duplicate analysis.
Executive Summary
Analysis Scope: 1,821 functions across 299 non-test Go files in 12 packages
Key Findings:
Estimated Impact:
Package Distribution
Function Count by Package
Naming Pattern Analysis
Common Function Prefixes (pkg/workflow/)
get*build*parse*generate*validate*extract*format*create*Insight: Functions with
create*prefix follow the "one feature per file" pattern well, but most other patterns are scattered.Critical Issues Identified
1. Outlier Functions (Functions in Wrong Files)
Issue #1A:
tools_types.goContains Parsers, Not TypesFile:
/home/runner/work/gh-aw/gh-aw/pkg/workflow/tools_types.goProblem: 15 out of 19 functions (78%) are
parse*functions, despite file name suggesting type definitionsFunctions misplaced:
parseToolsFromFrontmatter()parseMCPServersFromFrontmatter()parseRuntimesFromFrontmatter()parseSerenaConfig()parseGitHubToolConfig()parseGitHubToolset()parseRemoteToolsConfig()parseWebSearchConfig()Recommendation:
Impact: High - Misleading file name causes confusion for developers
Issue #1B: Generic Helper Functions in
close_entity_helpers.goandupdate_entity_helpers.goFiles:
/home/runner/work/gh-aw/gh-aw/pkg/workflow/close_entity_helpers.go:42-parseCloseEntityConfig()/home/runner/work/gh-aw/gh-aw/pkg/workflow/close_entity_helpers.go:91-buildCloseEntityJob()/home/runner/work/gh-aw/gh-aw/pkg/workflow/update_entity_helpers.go:52-parseUpdateEntityConfig()/home/runner/work/gh-aw/gh-aw/pkg/workflow/update_entity_helpers.go:85-buildUpdateEntityJob()Problem: These are generic template functions used by multiple entity-specific files, but named as if they're specific helpers
Detected Duplication Pattern: Both files implement nearly identical patterns:
parseXXXEntityConfig()with entity type parameterbuildXXXEntityJob()with entity type parameterParseTargetConfig()fromsafe_output_builder.gobuildSafeOutputJob()fromsafe_outputs_jobs.goCode Similarity: ~85% similar structure between close and update helpers
Recommendation:
Impact: Medium-High - Reduces code duplication and clarifies these are generic patterns
2. Large Files Requiring Decomposition
Issue #2A:
js.go- Mixed ResponsibilitiesFile:
/home/runner/work/gh-aw/gh-aw/pkg/workflow/js.go(41 functions)Problem: File handles 3 distinct responsibilities:
Comment Removal (10 functions)
removeBlockComments(),removeLineComments(),stripJSComments()YAML Formatting (15 functions)
formatForYAML(),needsYAMLQuoting(), `escapeBacks...💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.