data

package
v0.260224.1130 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SkillLocationsFile is the filename for skill locations storage
	SkillLocationsFile = "skill_locations.json"
	// SkillClientConfigFile is the filename for IDE client scanning configuration
	SkillClientConfigFile = "skill_client.json"
)
View Source
const DefaultTemplateCacheTTL = 12 * time.Hour // Default TTL for template cache
View Source
const DefaultTemplateHTTPTimeout = 30 * time.Second // Default HTTP timeout for fetching templates
View Source
const TemplateCacheFileName = "provider_template.json"
View Source
const TemplateGitHubURL = "https://raw.githubusercontent.com/tingly-dev/tingly-box/main/internal/data/provider_templates.json"

Variables

This section is empty.

Functions

func DefaultIDEAdapters

func DefaultIDEAdapters() ([]typ.IDEAdapter, error)

DefaultIDEAdapters returns the list of supported IDE adapters from embedded config

func ValidateTemplate

func ValidateTemplate(tmpl *ProviderTemplate) error

ValidateTemplate validates a provider template

Types

type CapabilitySchema added in v0.260224.0

type CapabilitySchema struct {
	BuiltIn      bool         `json:"built_in"`
	ToolType     string       `json:"tool_type,omitempty"`
	ToolName     string       `json:"tool_name,omitempty"`
	DocURL       string       `json:"doc_url,omitempty"`
	ResultFormat ResultFormat `json:"result_format,omitempty"`
}

CapabilitySchema defines the structure for capability schemas like web_search

type ModelList

type ModelList struct {
	Provider    string   `yaml:"provider"`
	UUID        string   `yaml:"uuid"`
	APIBase     string   `yaml:"api_base"`
	Models      []string `yaml:"models"`
	LastUpdated string   `yaml:"last_updated"`
}

ModelList represents the models available for a specific provider (kept for backward compatibility)

type ModelListManager

type ModelListManager struct {
	// contains filtered or unexported fields
}

ModelListManager manages models for different providers using SQLite database

func NewProviderModelManager

func NewProviderModelManager(configDir string) (*ModelListManager, error)

NewProviderModelManager creates a new provider model manager with database backing

func (*ModelListManager) GetAllProviders

func (mm *ModelListManager) GetAllProviders() []string

GetAllProviders returns all provider UUIDs that have models

func (*ModelListManager) GetModels

func (mm *ModelListManager) GetModels(uid string) []string

GetModels returns models for a provider by reading from database

func (*ModelListManager) GetProviderInfo

func (mm *ModelListManager) GetProviderInfo(uid string) (apiBase string, lastUpdated string, exists bool)

GetProviderInfo returns basic info about a provider by reading from database

func (*ModelListManager) HasModels

func (mm *ModelListManager) HasModels(providerUUID string) bool

HasModels checks if a provider has models in the database

func (*ModelListManager) RemoveProvider

func (mm *ModelListManager) RemoveProvider(providerUUID string) error

RemoveProvider removes a provider's models from the database

func (*ModelListManager) SaveModels

func (mm *ModelListManager) SaveModels(provider *typ.Provider, apiBase string, models []string) error

SaveModels saves models for a provider by UUID to the database

type ProviderTemplate

type ProviderTemplate struct {
	ID                     string            `json:"id"`
	Name                   string            `json:"name"`
	Alias                  string            `json:"alias,omitempty"` // Display name with locale information
	Status                 string            `json:"status"`          // "active", "deprecated", etc.
	Valid                  bool              `json:"valid"`
	Website                string            `json:"website"`
	Description            string            `json:"description"`
	Type                   string            `json:"type"` // "official", "reseller", etc.
	APIDoc                 string            `json:"api_doc"`
	ModelDoc               string            `json:"model_doc"`
	PricingDoc             string            `json:"pricing_doc"`
	BaseURLOpenAI          string            `json:"base_url_openai,omitempty"`
	BaseURLAnthropic       string            `json:"base_url_anthropic,omitempty"`
	Models                 []string          `json:"models"`                 // List of model IDs
	ModelLimits            map[string]int    `json:"model_limits,omitempty"` // Model name -> max_tokens mapping
	SupportsModelsEndpoint bool              `json:"supports_models_endpoint"`
	Tags                   []string          `json:"tags,omitempty"`
	Metadata               map[string]string `json:"metadata,omitempty"`
	OAuthProvider          string            `json:"oauth_provider,omitempty"`    // OAuth provider type for oauth type providers
	AuthType               string            `json:"auth_type,omitempty"`         // "oauth", "key"
	WebSearchSchema        string            `json:"web_search_schema,omitempty"` // Reference to capability schema for web_search
}

ProviderTemplate represents a predefined provider configuration template

type ProviderTemplateRegistry

type ProviderTemplateRegistry struct {
	Providers         map[string]*ProviderTemplate `json:"providers"`
	CapabilitySchemas map[string]*CapabilitySchema `json:"capability_schemas,omitempty"`
	Version           string                       `json:"version"`
	LastUpdated       string                       `json:"last_updated"`
}

ProviderTemplateRegistry represents the provider template registry structure from GitHub

type ResultFormat added in v0.260224.0

type ResultFormat struct {
	Type        string                 `json:"type"`
	Description string                 `json:"description,omitempty"`
	Structure   map[string]interface{} `json:"structure,omitempty"`
}

ResultFormat describes how to format tool results

type SkillManager

type SkillManager struct {
	// contains filtered or unexported fields
}

SkillManager manages skill locations

func NewSkillManager

func NewSkillManager(configDir string) (*SkillManager, error)

NewSkillManager creates a new skill manager

func (*SkillManager) AddLocation

func (sm *SkillManager) AddLocation(name, path string, ideSource typ.IDESource) (*typ.SkillLocation, error)

AddLocation adds a new skill location

func (*SkillManager) DiscoverIdes

func (sm *SkillManager) DiscoverIdes() (*typ.DiscoveryResult, error)

DiscoverIdes scans the home directory for installed IDEs with skills

func (*SkillManager) GetLocation

func (sm *SkillManager) GetLocation(id string) (*typ.SkillLocation, error)

GetLocation retrieves a skill location by ID

func (*SkillManager) GetSkillContent

func (sm *SkillManager) GetSkillContent(locationID, skillID, skillPath string) (*typ.Skill, error)

GetSkillContent reads and returns the content of a skill file

func (*SkillManager) ListLocations

func (sm *SkillManager) ListLocations() []typ.SkillLocation

ListLocations returns all skill locations

func (*SkillManager) RemoveLocation

func (sm *SkillManager) RemoveLocation(id string) error

RemoveLocation removes a skill location by ID

func (*SkillManager) ScanIdes

func (sm *SkillManager) ScanIdes() (*typ.DiscoveryResult, error)

ScanIdes scans all IDE locations and returns discovered skills This is a comprehensive scan that checks all configured IDE locations

func (*SkillManager) ScanLocation

func (sm *SkillManager) ScanLocation(locationID string) (*typ.ScanResult, error)

ScanLocation scans a location directory for skill files

func (*SkillManager) UpdateLocation

func (sm *SkillManager) UpdateLocation(location typ.SkillLocation) error

UpdateLocation updates a skill location

func (*SkillManager) UpdateLocationSkillCount

func (sm *SkillManager) UpdateLocationSkillCount(id string, count int) error

UpdateLocationSkillCount updates the skill count for a location

type TemplateCacheData

type TemplateCacheData struct {
	Registry ProviderTemplateRegistry `json:"registry"`
	CachedAt time.Time                `json:"cached_at"`
	Version  string                   `json:"version"`
	ETag     string                   `json:"etag,omitempty"`
}

TemplateCacheData represents the cache file structure

type TemplateManager

type TemplateManager struct {
	// contains filtered or unexported fields
}

TemplateManager manages provider templates with -tier fallback

func NewDefaultTemplateManager

func NewDefaultTemplateManager() *TemplateManager

func NewEmbeddedOnlyTemplateManager

func NewEmbeddedOnlyTemplateManager() *TemplateManager

NewEmbeddedOnlyTemplateManager creates a template manager that only uses embedded templates This is useful for development, testing, or offline scenarios

func NewTemplateManager

func NewTemplateManager(githubURL string) *TemplateManager

NewTemplateManager creates a new template manager with default preference. If githubURL is empty, only embedded templates will be used (no GitHub sync).

func NewTemplateManagerWithPreference

func NewTemplateManagerWithPreference(githubURL string, preference TemplateSourcePreference) *TemplateManager

NewTemplateManagerWithPreference creates a new template manager with specified source preference. If githubURL is empty, only embedded templates will be used (no GitHub sync).

func (*TemplateManager) FetchFromGitHub

func (tm *TemplateManager) FetchFromGitHub(ctx context.Context) (*ProviderTemplateRegistry, error)

FetchFromGitHub fetches templates from GitHub and updates the storage

func (*TemplateManager) GetAllTemplates

func (tm *TemplateManager) GetAllTemplates() map[string]*ProviderTemplate

GetAllTemplates returns all templates

func (*TemplateManager) GetMaxTokensForModel

func (tm *TemplateManager) GetMaxTokensForModel(provider, model string) int

GetMaxTokensForModel returns the maximum allowed tokens for a specific model using the provider templates. If templates are not available, falls back to the global default. It checks in order: 1. Exact match of provider:model in templates 2. Model wildcard match (provider:*) in templates 3. Global default

func (*TemplateManager) GetMaxTokensForModelByProvider

func (tm *TemplateManager) GetMaxTokensForModelByProvider(provider *typ.Provider, model string) int

GetMaxTokensForModelByProvider returns the maximum allowed tokens for a specific model using the provider templates matched by APIBase or OAuthProvider. This is the preferred method as it correctly matches templates regardless of user-defined provider name.

func (*TemplateManager) GetModelsForProvider

func (tm *TemplateManager) GetModelsForProvider(provider *typ.Provider) ([]string, TemplateSource, error)

GetModelsForProvider returns models for a provider using template-only hierarchy: 1. GitHub/embedded templates with models list Note: API-based model fetching is now handled by the client layer (client.ModelLister) This method only returns static models from templates

func (*TemplateManager) GetTemplate

func (tm *TemplateManager) GetTemplate(id string) (*ProviderTemplate, error)

GetTemplate returns a provider template by ID

func (*TemplateManager) GetVersion

func (tm *TemplateManager) GetVersion() string

GetVersion returns the current template version

func (*TemplateManager) GetWebSearchSchemaForProvider added in v0.260224.0

func (tm *TemplateManager) GetWebSearchSchemaForProvider(provider *typ.Provider) *CapabilitySchema

GetWebSearchSchemaForProvider returns the web search capability schema for a provider Returns nil if the provider doesn't have web_search_schema defined or the schema doesn't exist

func (*TemplateManager) Initialize

func (tm *TemplateManager) Initialize(ctx context.Context) error

Initialize loads templates according to the source preference: - PreferenceDefault: Cache -> GitHub -> Embedded - PreferenceEmbedded: Embedded only (no network requests) - PreferenceEmbeddedFirst: Embedded -> Cache -> GitHub

func (*TemplateManager) ProviderHasBuiltInWebSearch added in v0.260224.0

func (tm *TemplateManager) ProviderHasBuiltInWebSearch(provider *typ.Provider) bool

ProviderHasBuiltInWebSearch checks if a provider has built-in web_search capability Returns true if the provider has a web_search_schema with BuiltIn=true

type TemplateSource

type TemplateSource int

TemplateSource tracks where templates were loaded from

const (
	// TemplateSourceGitHub - From GitHub templates
	TemplateSourceGitHub TemplateSource = iota
	// TemplateSourceLocal - From local embedded templates
	TemplateSourceLocal
)

type TemplateSourcePreference

type TemplateSourcePreference int

TemplateSourcePreference defines the priority order for loading templates

const (
	// PreferenceDefault: Cache -> GitHub -> Embedded
	PreferenceDefault TemplateSourcePreference = iota
	// PreferenceEmbedded: Embedded only (no network requests)
	PreferenceEmbedded
	// PreferenceEmbeddedFirst: Embedded -> Cache -> GitHub
	PreferenceEmbeddedFirst
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL