Add opt-in PromptKit namespaces
This commit is contained in:
@@ -19,6 +19,8 @@ type PromptRequest struct {
|
||||
Selection ckconfig.Selection
|
||||
// ID is the selected named prompt.
|
||||
ID string
|
||||
// Namespaces selects the native engine view; nil preserves the loader view.
|
||||
Namespaces *promptkit.Namespaces
|
||||
}
|
||||
|
||||
// ProfileRequest selects one named profile for inspection.
|
||||
@@ -27,6 +29,8 @@ type ProfileRequest struct {
|
||||
Selection ckconfig.Selection
|
||||
// ID is the selected named profile.
|
||||
ID string
|
||||
// Namespaces selects the native engine view; nil preserves the loader view.
|
||||
Namespaces *promptkit.Namespaces
|
||||
}
|
||||
|
||||
// BackendRequest selects one named backend for inspection.
|
||||
@@ -35,6 +39,8 @@ type BackendRequest struct {
|
||||
Selection ckconfig.Selection
|
||||
// ID is the selected named backend.
|
||||
ID string
|
||||
// Namespaces selects the native engine view; nil preserves the loader view.
|
||||
Namespaces *promptkit.Namespaces
|
||||
}
|
||||
|
||||
// CatalogRequest selects the configuration and native namespace filter for a
|
||||
@@ -68,6 +74,8 @@ type RequirementsRequest struct {
|
||||
// discovery context. Profile and session strings retain PromptKit's
|
||||
// empty-value semantics.
|
||||
Inspection promptkit.RequirementInspectionRequest
|
||||
// Namespaces selects the native engine view; nil preserves the loader view.
|
||||
Namespaces *promptkit.Namespaces
|
||||
}
|
||||
|
||||
// Suite describes application-owned input, shared state, and optional catalog,
|
||||
@@ -150,7 +158,8 @@ type Suite[I, S any] struct {
|
||||
// omits only this catalog command.
|
||||
ListCollections func(context.Context, ckconfig.Selection, I, S) (commandkit.Acquired[[]promptkit.CollectionInfo], error)
|
||||
|
||||
issues []error
|
||||
namespaces *promptkit.Namespaces
|
||||
issues []error
|
||||
}
|
||||
|
||||
// WithRequestValidation attaches PromptKit-backed concrete request validation
|
||||
@@ -205,6 +214,12 @@ func WithRequestValidation[I, S any](
|
||||
return commandkit.Acquired[struct{}]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, fmt.Errorf("PromptKit request validation before native validation: %w", err)
|
||||
}
|
||||
|
||||
engine, err = namespacedEngine(engine, request.Namespaces)
|
||||
if err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[struct{}]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
|
||||
if err := engine.ValidateRequest(ctx, concreteRequest); err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[struct{}]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
@@ -384,6 +399,11 @@ func FromEngine[I, S any](load func(context.Context, ckconfig.Selection, I, S) (
|
||||
if err != nil {
|
||||
return commandkit.Acquired[*promptkit.PromptInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
engine, err = namespacedEngine(engine, request.Namespaces)
|
||||
if err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.PromptInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
inspection, err := engine.InspectPrompt(ctx, request.ID)
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.PromptInspection]{Value: inspection, Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
@@ -393,6 +413,11 @@ func FromEngine[I, S any](load func(context.Context, ckconfig.Selection, I, S) (
|
||||
if err != nil {
|
||||
return commandkit.Acquired[*promptkit.ProfileInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
engine, err = namespacedEngine(engine, request.Namespaces)
|
||||
if err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.ProfileInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
inspection, err := engine.InspectProfile(ctx, request.ID)
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.ProfileInspection]{Value: inspection, Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
@@ -402,6 +427,11 @@ func FromEngine[I, S any](load func(context.Context, ckconfig.Selection, I, S) (
|
||||
if err != nil {
|
||||
return commandkit.Acquired[*promptkit.BackendInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
engine, err = namespacedEngine(engine, request.Namespaces)
|
||||
if err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.BackendInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
inspection, err := engine.InspectBackend(ctx, request.ID)
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.BackendInspection]{Value: inspection, Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
@@ -411,6 +441,11 @@ func FromEngine[I, S any](load func(context.Context, ckconfig.Selection, I, S) (
|
||||
if err != nil {
|
||||
return commandkit.Acquired[*promptkit.RequirementInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
engine, err = namespacedEngine(engine, request.Namespaces)
|
||||
if err != nil {
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.RequirementInspection]{Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
}
|
||||
inspection, err := engine.InspectRequirements(ctx, request.Inspection)
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.RequirementInspection]{Value: inspection, Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
|
||||
Reference in New Issue
Block a user