31 lines
955 B
Go
31 lines
955 B
Go
package opencode
|
|
|
|
import (
|
|
"log"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/chattools"
|
|
)
|
|
|
|
// withPipelinesTools adds the Pipelines MCP server to a chat service's config
|
|
// overrides. One OpenCode service serves every chat and its MCP requests name
|
|
// no session, so it registers the service's instance endpoint; the server
|
|
// attributes each call to the chat whose stream shows it running. The
|
|
// operator's own overrides win, including a server they named "pipelines".
|
|
// It returns overrides unchanged when the tools are not configured.
|
|
func withPipelinesTools(overrides map[string]any) map[string]any {
|
|
registry := chattools.Current()
|
|
if registry == nil {
|
|
return overrides
|
|
}
|
|
url, err := registry.InstanceURL("opencode")
|
|
if err != nil {
|
|
log.Printf("OpenCode chat: Pipelines tools not registered: %v", err)
|
|
return overrides
|
|
}
|
|
merged := chattools.OpenCodeConfig(url)
|
|
if overrides != nil {
|
|
mergeConfig(merged, overrides)
|
|
}
|
|
return merged
|
|
}
|