mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-15 01:07:27 +00:00
refactor: remove dead code, deduplicate defaultHome, simplify mcpEntry + kilo render
Dead code removed: - BuildProviders, buildModels, ProviderEntry (no production callers) - ZedLanguageModels (shadowed by adapter-local version, wrong schema) - GatewayProviderID deprecated constant (zero references) - Corresponding dead tests for BuildProviders Deduplication: - Extract common.DefaultHome() to internal/adapter/common/home.go - All 7 adapters call common.DefaultHome() instead of local copies (-49 lines) Simplification: - mcp.go: merge MCPClaudeStyle/MCPCrushStyle branches (identical URL path, one-line difference in stdio path) — clearer intent, fewer lines - kilo.go: extract opencode.jsonc merge to mergeOpenCodeJSONC() helper, Render() drops from 92 to ~55 lines - goose.go: strings.IndexByte → strings.Cut in splitProviderModel
This commit is contained in:
@@ -32,21 +32,13 @@ func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
a := &Adapter{home: common.DefaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// Name returns the harness identifier.
|
||||
func (a *Adapter) Name() string { return name }
|
||||
|
||||
@@ -152,8 +144,8 @@ func buildExtensions(servers []canonical.MCPServer) map[string]any {
|
||||
// splitProviderModel splits "provider/model" into its parts.
|
||||
// If no slash, provider is "anthropic" and the whole string is the model.
|
||||
func splitProviderModel(s string) (string, string) {
|
||||
if idx := strings.IndexByte(s, '/'); idx >= 0 {
|
||||
return s[:idx], s[idx+1:]
|
||||
if p, m, ok := strings.Cut(s, "/"); ok {
|
||||
return p, m
|
||||
}
|
||||
return "anthropic", s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user