Adopt native PromptKit resource inspection
This commit is contained in:
@@ -29,6 +29,14 @@ type ProfileRequest struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
// BackendRequest selects one named backend for inspection.
|
||||
type BackendRequest struct {
|
||||
// Selection carries configuration and overlay values supplied to the command.
|
||||
Selection ckconfig.Selection
|
||||
// ID is the selected named backend.
|
||||
ID string
|
||||
}
|
||||
|
||||
// CatalogRequest selects the configuration and native namespace filter for a
|
||||
// prompt, profile, or backend catalog operation. A zero Filter preserves
|
||||
// PromptKit's native default selection.
|
||||
@@ -96,6 +104,8 @@ type Suite[I, S any] struct {
|
||||
// preparation. Its acquisition carries independent loader diagnostics and
|
||||
// terminal context alongside any native inspection result.
|
||||
InspectProfile func(context.Context, ProfileRequest, I, S) (commandkit.Acquired[*promptkit.ProfileInspection], error)
|
||||
// InspectBackend independently enables inspection of one named backend.
|
||||
InspectBackend func(context.Context, BackendRequest, I, S) (commandkit.Acquired[*promptkit.BackendInspection], error)
|
||||
// InspectRequirements inspects native PromptKit requirements after input and
|
||||
// state preparation. Its acquisition carries independent loader diagnostics
|
||||
// and terminal context alongside any native inspection result. It is
|
||||
@@ -300,9 +310,9 @@ func promptKitContextError(ctx context.Context) error {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
// FromEngine supplies eight PromptKit-backed callbacks: prompt, profile,
|
||||
// backend, namespace, and collection catalogs, plus named prompt and profile
|
||||
// inspection and requirements discovery.
|
||||
// FromEngine supplies nine PromptKit-backed callbacks: prompt, profile,
|
||||
// backend, namespace, and collection catalogs; named prompt, profile, and
|
||||
// backend inspection; and requirements discovery.
|
||||
// The requirements callback forwards RequirementsRequest.Inspection to
|
||||
// Engine.InspectRequirements. Concrete request validation is an independent
|
||||
// capability and can be composed explicitly with WithRequestValidation. Smoke
|
||||
@@ -384,6 +394,15 @@ func FromEngine[I, S any](load func(context.Context, ckconfig.Selection, I, S) (
|
||||
messages = messages.withOperationError(err)
|
||||
return commandkit.Acquired[*promptkit.ProfileInspection]{Value: inspection, Diagnostics: messages.diagnostics, Explanation: messages.explanation}, err
|
||||
},
|
||||
InspectBackend: func(ctx context.Context, request BackendRequest, input I, state S) (commandkit.Acquired[*promptkit.BackendInspection], error) {
|
||||
engine, _, messages, err := loadPromptKitEngine(ctx, request.Selection, input, state, "", load)
|
||||
if err != nil {
|
||||
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
|
||||
},
|
||||
InspectRequirements: func(ctx context.Context, request RequirementsRequest, input I, state S) (commandkit.Acquired[*promptkit.RequirementInspection], error) {
|
||||
engine, _, messages, err := loadPromptKitEngine(ctx, request.Selection, input, state, "", load)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user