Add prepared request preview

This commit is contained in:
2026-11-07 04:19:58 +00:00
parent c3d5f551c3
commit 8e5e64c6e9
9 changed files with 297 additions and 54 deletions

View File

@@ -43,12 +43,12 @@ type variableAssignment struct {
}
type inputAssignment struct {
name string
path string
name string
value string
}
// Command captures the optional PromptKit catalogs, named inspection,
// requirements discovery, concrete request validation, and smoke-test
// requirements discovery, concrete request validation and preparation, and smoke-test
// callbacks and adds only supplied operations. Discovery and validation share the
// `requirements` group and remain independently optional. An absent suite
// claims no namespace; attached construction issues remain reportable. It adds
@@ -61,7 +61,7 @@ type inputAssignment struct {
// Named resource inspections return native reports through shared formatting.
// Catalog commands accept config/overlay selection and suite selectors.
func Command[I, S any](suite Suite[I, S]) commandkit.Command {
if suite.InspectPrompt == nil && suite.InspectProfile == nil && suite.InspectBackend == nil && suite.InspectRequirements == nil && suite.ValidateRequest == nil && suite.SmokeTest == nil && suite.ListPrompts == nil && suite.ListProfiles == nil && suite.ListBackends == nil && suite.ListNamespaces == nil && suite.ListCollections == nil {
if suite.InspectPrompt == nil && suite.InspectProfile == nil && suite.InspectBackend == nil && suite.InspectRequirements == nil && suite.ValidateRequest == nil && suite.PrepareRequest == nil && suite.SmokeTest == nil && suite.ListPrompts == nil && suite.ListProfiles == nil && suite.ListBackends == nil && suite.ListNamespaces == nil && suite.ListCollections == nil {
command := commandkit.NoCommand()
for _, issue := range suite.issues {
command = commandkit.WithError(command, issue)
@@ -81,6 +81,9 @@ func Command[I, S any](suite Suite[I, S]) commandkit.Command {
if suite.InspectBackend != nil {
showCommands = append(showCommands, newDefinitionCommand(suite, "backend"))
}
if suite.PrepareRequest != nil {
showCommands = append(showCommands, newPreparationCommand(suite))
}
if len(showCommands) != 0 {
rootCommands = append(rootCommands, commandkit.Group("show", "Show a named PromptKit definition.", showCommands...))
}
@@ -606,11 +609,9 @@ func parseVariableAssignment(raw string) (variableAssignment, error) {
}
func parseInputAssignment(raw string) (inputAssignment, error) {
name, path, found := strings.Cut(raw, "=")
name, value, found := strings.Cut(raw, "=")
if !found {
return inputAssignment{}, fmt.Errorf("input assignment %q must contain =", raw)
}
return inputAssignment{name: name, path: path}, nil
return inputAssignment{name: name, value: value}, nil
}
func stringDefault(value string) *string { return &value }