mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-15 01:07:27 +00:00
feat(canonical): introduce core domain types
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
// Package canonical defines the source-of-truth domain types for harness-sync.
|
||||
package canonical
|
||||
|
||||
type Config struct {
|
||||
Paths Paths `yaml:"paths,omitempty"`
|
||||
ActiveProfile string `yaml:"active_profile"`
|
||||
EnabledHarnesses []string `yaml:"enabled_harnesses"`
|
||||
}
|
||||
|
||||
type Paths struct {
|
||||
Skills string `yaml:"skills,omitempty"`
|
||||
Agents string `yaml:"agents,omitempty"`
|
||||
Instructions string `yaml:"instructions,omitempty"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
Name string `yaml:"name"`
|
||||
Gateway Gateway `yaml:"gateway"`
|
||||
Upstreams []Upstream `yaml:"upstreams,omitempty"`
|
||||
Models []Model `yaml:"models"`
|
||||
}
|
||||
|
||||
type Gateway struct {
|
||||
URL string `yaml:"url"`
|
||||
Token string `yaml:"token"`
|
||||
DefaultModel string `yaml:"default_model"`
|
||||
}
|
||||
|
||||
type Upstream struct {
|
||||
Name string `yaml:"name"`
|
||||
APIKey string `yaml:"api_key,omitempty"`
|
||||
BaseURL string `yaml:"base_url,omitempty"`
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
ID string `yaml:"id"`
|
||||
Alias string `yaml:"alias,omitempty"`
|
||||
}
|
||||
|
||||
type MCPRegistry struct {
|
||||
Servers []MCPServer `yaml:"servers"`
|
||||
}
|
||||
|
||||
type MCPServer struct {
|
||||
Env map[string]string `yaml:"env,omitempty"`
|
||||
Name string `yaml:"name"`
|
||||
Command string `yaml:"command,omitempty"`
|
||||
URL string `yaml:"url,omitempty"`
|
||||
Transport string `yaml:"transport,omitempty"`
|
||||
Args []string `yaml:"args,omitempty"`
|
||||
}
|
||||
|
||||
type Skill struct {
|
||||
Name string
|
||||
Description string
|
||||
Body string
|
||||
Path string
|
||||
}
|
||||
|
||||
type Agent struct {
|
||||
Name string
|
||||
Description string
|
||||
Body string
|
||||
Path string
|
||||
}
|
||||
|
||||
type Instructions struct {
|
||||
PerHarness map[string]string
|
||||
Global string
|
||||
}
|
||||
|
||||
type Bundle struct {
|
||||
Config Config
|
||||
Instructions Instructions
|
||||
Root string
|
||||
Profile Profile
|
||||
Skills []Skill
|
||||
Agents []Agent
|
||||
MCP MCPRegistry
|
||||
}
|
||||
|
||||
func (p *Profile) LookupModel(alias string) (Model, bool) {
|
||||
for _, m := range p.Models {
|
||||
if m.Alias == alias || m.ID == alias {
|
||||
return m, true
|
||||
}
|
||||
}
|
||||
return Model{}, false
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package canonical
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestProfileActiveModel(t *testing.T) {
|
||||
p := &Profile{
|
||||
Name: "home",
|
||||
Gateway: Gateway{
|
||||
URL: "https://gw",
|
||||
Token: "dummy",
|
||||
DefaultModel: "sonnet",
|
||||
},
|
||||
Models: []Model{
|
||||
{ID: "claude-sonnet-4-6", Alias: "sonnet"},
|
||||
{ID: "claude-opus-4-7", Alias: "opus"},
|
||||
},
|
||||
}
|
||||
m, ok := p.LookupModel("sonnet")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "claude-sonnet-4-6", m.ID)
|
||||
|
||||
_, ok = p.LookupModel("missing")
|
||||
assert.False(t, ok)
|
||||
}
|
||||
Reference in New Issue
Block a user