Add opt-in PromptKit namespaces
This commit is contained in:
@@ -12,10 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type definitionInput[I any] struct {
|
||||
selection ckconfig.Selection
|
||||
id string
|
||||
captured commandkit.FlagValues[I]
|
||||
selected I
|
||||
namespaces namespaceInput
|
||||
selection ckconfig.Selection
|
||||
id string
|
||||
captured commandkit.FlagValues[I]
|
||||
selected I
|
||||
}
|
||||
|
||||
type catalogInput[I any] struct {
|
||||
@@ -29,6 +30,7 @@ type catalogInput[I any] struct {
|
||||
}
|
||||
|
||||
type requirementsInput[I any] struct {
|
||||
namespaces namespaceInput
|
||||
selection ckconfig.Selection
|
||||
inspection promptkit.RequirementInspectionRequest
|
||||
resources ResourceInput
|
||||
@@ -244,6 +246,10 @@ func newDefinitionCommand[I, S any](suite Suite[I, S], name string) commandkit.C
|
||||
(*input).selection.Overlay = value
|
||||
}),
|
||||
)
|
||||
if suite.namespaces != nil {
|
||||
flags = append(flags, namespaceFlags(func(input **definitionInput[I]) *namespaceInput { return &(*input).namespaces }, name)...)
|
||||
}
|
||||
|
||||
spec := commandkit.CommandSpec[*definitionInput[I]]{
|
||||
Name: name,
|
||||
Summary: "Inspect a named PromptKit " + name + ".",
|
||||
@@ -292,9 +298,14 @@ func newRequirementsCommand[I, S any](suite Suite[I, S]) commandkit.Command {
|
||||
inputs := NewPromptInputFlags(func(input **requirementsInput[I]) *PromptInputs { return &(*input).inputs })
|
||||
flags = append(flags, resources.Profile, resources.SessionID, inputs.Variable)
|
||||
|
||||
if suite.namespaces != nil {
|
||||
flags = append(flags, namespaceFlags(func(input **requirementsInput[I]) *namespaceInput { return &(*input).namespaces }, "prompt", "profile")...)
|
||||
}
|
||||
|
||||
spec := commandkit.CommandSpec[*requirementsInput[I]]{
|
||||
Name: "show",
|
||||
Summary: "Inspect requirements for a named PromptKit prompt.",
|
||||
Name: "show",
|
||||
Summary: "Inspect requirements for a named PromptKit prompt.",
|
||||
Description: "Profile selection establishes the reported profile identity, not a different set of requirements. A profile namespace qualifies an explicitly supplied short profile ID, not the prompt’s stored default reference.",
|
||||
NewInput: func() *requirementsInput[I] {
|
||||
return &requirementsInput[I]{}
|
||||
},
|
||||
@@ -398,21 +409,21 @@ func runDefinitionInspection[I, S any](invocation commandkit.Invocation, suite S
|
||||
switch kind {
|
||||
case "prompt":
|
||||
var result commandkit.Acquired[*promptkit.PromptInspection]
|
||||
result, err = suite.InspectPrompt(invocation.Context, PromptRequest{Selection: input.selection, ID: input.id}, input.selected, state)
|
||||
result, err = suite.InspectPrompt(invocation.Context, PromptRequest{Selection: input.selection, ID: input.id, Namespaces: selectedNamespaces(suite.namespaces, input.namespaces)}, input.selected, state)
|
||||
if result.Value != nil {
|
||||
value = result.Value
|
||||
}
|
||||
diagnostics, explanation = result.Diagnostics, result.Explanation
|
||||
case "profile":
|
||||
var result commandkit.Acquired[*promptkit.ProfileInspection]
|
||||
result, err = suite.InspectProfile(invocation.Context, ProfileRequest{Selection: input.selection, ID: input.id}, input.selected, state)
|
||||
result, err = suite.InspectProfile(invocation.Context, ProfileRequest{Selection: input.selection, ID: input.id, Namespaces: selectedNamespaces(suite.namespaces, input.namespaces)}, input.selected, state)
|
||||
if result.Value != nil {
|
||||
value = result.Value
|
||||
}
|
||||
diagnostics, explanation = result.Diagnostics, result.Explanation
|
||||
case "backend":
|
||||
var result commandkit.Acquired[*promptkit.BackendInspection]
|
||||
result, err = suite.InspectBackend(invocation.Context, BackendRequest{Selection: input.selection, ID: input.id}, input.selected, state)
|
||||
result, err = suite.InspectBackend(invocation.Context, BackendRequest{Selection: input.selection, ID: input.id, Namespaces: selectedNamespaces(suite.namespaces, input.namespaces)}, input.selected, state)
|
||||
if result.Value != nil {
|
||||
value = result.Value
|
||||
}
|
||||
@@ -518,7 +529,7 @@ func runRequirementsInspection[I, S any](invocation commandkit.Invocation, suite
|
||||
}
|
||||
}
|
||||
|
||||
request := RequirementsRequest{Selection: input.selection, Inspection: input.inspection}
|
||||
request := RequirementsRequest{Selection: input.selection, Inspection: input.inspection, Namespaces: selectedNamespaces(suite.namespaces, input.namespaces)}
|
||||
acquired, err := suite.InspectRequirements(invocation.Context, request, input.selected, state)
|
||||
queuePromptDiagnostics(invocation.Reporter(), acquired.Diagnostics)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user