Add PromptKit requirements validation command
This commit is contained in:
@@ -44,20 +44,25 @@ type variableAssignment struct {
|
||||
value string
|
||||
}
|
||||
|
||||
// Command captures the optional PromptKit catalog, named inspection, and
|
||||
// requirements inspection callbacks and adds only supplied operations. An
|
||||
// absent suite claims no namespace; attached construction issues remain
|
||||
// reportable. It adds no configuration family; callers compose ConfigScope
|
||||
// independently. Construction, installation, help, and version do not run
|
||||
// suite factories or providers. Command captures suite callbacks and selector
|
||||
// metadata; callback-referenced objects and effects remain caller-owned. Suite
|
||||
// documents invocation input and state initialization, zero values, and caller
|
||||
// ownership of returned objects.
|
||||
type inputAssignment struct {
|
||||
name string
|
||||
path string
|
||||
}
|
||||
|
||||
// Command captures the optional PromptKit catalog, named inspection,
|
||||
// requirements inspection, and concrete request validation callbacks and adds
|
||||
// only supplied operations. An absent suite claims no namespace; attached
|
||||
// construction issues remain reportable. It adds no configuration family;
|
||||
// callers compose ConfigScope independently. Construction, installation, help,
|
||||
// and version do not run suite factories or providers. Command captures suite
|
||||
// callbacks and selector metadata; callback-referenced objects and effects
|
||||
// remain caller-owned. Suite documents invocation input and state initialization,
|
||||
// zero values, and caller ownership of returned objects.
|
||||
// Catalog commands accept config/overlay selection and suite selectors, and
|
||||
// render YAML with `yaml` as the only format and default. Named-show formats are
|
||||
// unchanged.
|
||||
func Command[I, S any](suite Suite[I, S]) commandkit.Command {
|
||||
if suite.InspectPrompt == nil && suite.InspectProfile == nil && suite.InspectRequirements == nil && suite.ListPrompts == nil && suite.ListProfiles == nil {
|
||||
if suite.InspectPrompt == nil && suite.InspectProfile == nil && suite.InspectRequirements == nil && suite.ValidateRequest == nil && suite.ListPrompts == nil && suite.ListProfiles == nil {
|
||||
command := commandkit.NoCommand()
|
||||
for _, issue := range suite.issues {
|
||||
command = commandkit.WithError(command, issue)
|
||||
@@ -87,10 +92,17 @@ func Command[I, S any](suite Suite[I, S]) commandkit.Command {
|
||||
if len(listCommands) != 0 {
|
||||
rootCommands = append(rootCommands, commandkit.Group("list", "List PromptKit catalogs.", listCommands...))
|
||||
}
|
||||
requirementsCommands := make([]commandkit.Command, 0, 2)
|
||||
if suite.InspectRequirements != nil {
|
||||
rootCommands = append(rootCommands, commandkit.Group("requirements", "Inspect prompt requirements.", newRequirementsCommand(suite)))
|
||||
requirementsCommands = append(requirementsCommands, newRequirementsCommand(suite))
|
||||
}
|
||||
command := commandkit.RootGroup("promptkit", "Inspect and list PromptKit definitions and requirements.", rootCommands...)
|
||||
if suite.ValidateRequest != nil {
|
||||
requirementsCommands = append(requirementsCommands, newValidationCommand(suite))
|
||||
}
|
||||
if len(requirementsCommands) != 0 {
|
||||
rootCommands = append(rootCommands, commandkit.Group("requirements", "Inspect and validate prompt requirements.", requirementsCommands...))
|
||||
}
|
||||
command := commandkit.RootGroup("promptkit", "Inspect, validate, and list PromptKit definitions and requirements.", rootCommands...)
|
||||
for _, issue := range suite.issues {
|
||||
command = commandkit.WithError(command, issue)
|
||||
}
|
||||
@@ -721,4 +733,12 @@ func parseVariableAssignment(raw string) (variableAssignment, error) {
|
||||
return variableAssignment{key: key, value: value}, nil
|
||||
}
|
||||
|
||||
func parseInputAssignment(raw string) (inputAssignment, error) {
|
||||
name, path, found := strings.Cut(raw, "=")
|
||||
if !found {
|
||||
return inputAssignment{}, fmt.Errorf("input assignment %q must contain =", raw)
|
||||
}
|
||||
return inputAssignment{name: name, path: path}, nil
|
||||
}
|
||||
|
||||
func stringDefault(value string) *string { return &value }
|
||||
|
||||
Reference in New Issue
Block a user