Implement a library profile API and built-in profile docs

This commit is contained in:
2026-07-04 17:23:34 -05:00
parent 4669b73d38
commit d60ef66f53
10 changed files with 493 additions and 4 deletions

View File

@@ -58,9 +58,11 @@ type engineOptions struct {
llmClient llm.Client
promptDefs promptdef.Repository
profiles profile.Repository
memoryProfiles profile.Repository
validator validate.Validator
promptSource bool
profileSource bool
memorySource bool
validatorSource bool
}
@@ -127,6 +129,20 @@ func WithProfileFile(path string) Option {
}
}
// WithProfiles configures in-memory profiles that take precedence over
// configured profile files and built-in profiles.
func WithProfiles(profiles ...Profile) Option {
return func(options *engineOptions) error {
repo, err := newMemoryProfileRepository(profiles)
if err != nil {
return err
}
options.memoryProfiles = repo
options.memorySource = true
return nil
}
}
func WithSchemaFS(fsys fs.FS, root string) Option {
return func(options *engineOptions) error {
if fsys == nil {
@@ -178,6 +194,9 @@ func NewEngine(cfg Config, opts ...Option) (*Engine, error) {
if options.profileSource {
profiles = builtin.NewRepositoryWithPrimary(options.profiles)
}
if options.memorySource {
profiles = profile.NewOverlayRepository(options.memoryProfiles, profiles)
}
validator := options.validator
if !options.validatorSource {