mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-14 00:57:49 +00:00
feat: URL-derived provider keys (hs-<hostname>) + dedup providers sharing same gateway URL
- GatewayProviderKey() derives stable key from gateway URL hostname e.g. https://llmgw.h.raczylo.com/v1 → hs-llmgw-h-raczylo-com - AbsorbDuplicateProviders() merges providers sharing the same baseURL into our canonical entry; user-crafted model metadata wins for overlaps - kilo: renders to opencode.jsonc (primary config), deep-merges providers, deletes enabled_providers filter that was hiding our gateway - opencode: absorbs duplicate providers from existing config - All adapters use GatewayProviderKey() instead of hardcoded string - Fix goose URL doubling (was /v1/v1/chat/completions → /chat/completions) - Fix token propagation: api_key written directly (not env var ref) - Zed: adds prompt_cache_key capability, deletes context_servers key to avoid ContextServerSettingsContent serde untagged-enum parse error
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package opencode
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -76,8 +77,27 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
|
||||
cfgPath := filepath.Join(base, "opencode.jsonc")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
|
||||
// Build the provider map, then absorb any existing providers at the same
|
||||
// gateway URL so duplicates don't accumulate across apply runs.
|
||||
provMap := common.ProvidersAsMap(&b.Profile)
|
||||
if len(existing) > 0 {
|
||||
var base map[string]any
|
||||
clean := common.StripJSONComments(string(existing))
|
||||
if json.Unmarshal([]byte(clean), &base) == nil {
|
||||
if existingProv, ok := base["provider"].(map[string]any); ok {
|
||||
for k, v := range existingProv {
|
||||
if _, ours := provMap[k]; !ours {
|
||||
provMap[k] = v
|
||||
}
|
||||
}
|
||||
provMap = common.AbsorbDuplicateProviders(provMap, common.GatewayProviderKey(b.Profile.Gateway.URL), b.Profile.Gateway.URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
overlay := map[string]any{
|
||||
"provider": common.ProvidersAsMap(&b.Profile),
|
||||
"provider": provMap,
|
||||
"model": common.KiloModelString(&b.Profile),
|
||||
}
|
||||
if mcp := common.BuildMCPMapStyled(&b.MCP, common.MCPOpencodeStyle); len(mcp) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user