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

@@ -71,8 +71,8 @@ type RequirementsRequest struct {
}
// Suite describes application-owned input, shared state, and optional catalog,
// named inspection, requirements discovery, concrete request validation, and
// smoke testing capabilities. Its private issues retain adapter construction
// named inspection, requirements discovery, request validation and preparation,
// and smoke testing capabilities. Its private issues retain adapter construction
// failures.
// Factory results and callback effects remain caller-owned: Command does not
// deep-copy arbitrary objects or repair aliases returned by factories.
@@ -81,19 +81,19 @@ type RequirementsRequest struct {
// Factories are not invoked during construction, installation, help, or version,
// and need not run after failure.
type Suite[I, S any] struct {
// NewInput is called once when inspection, requirements, validation, smoke,
// NewInput is called once when inspection, requirements, validation, preparation, smoke,
// or catalog input preparation is reached, before applying selectors and
// calling CheckInput.
// If nil, input is the zero value of I, including nil for pointer types.
NewInput func() I
// NewState is called once when an inspection, validation, smoke, or catalog
// NewState is called once when an inspection, validation, preparation, smoke, or catalog
// callback is reached, after input checks pass. If nil, state is the zero
// value of S, including nil for pointer types.
NewState func() S
// Selectors declares the original typed flags accepted by inspection,
// requirements, validation, smoke, and catalog commands.
// requirements, validation, preparation, smoke, and catalog commands.
Selectors []commandkit.Flag[I]
// CheckInput validates selected inspection, requirements, validation, smoke,
// CheckInput validates selected inspection, requirements, validation, preparation, smoke,
// or catalog input before state creation.
CheckInput func(ckconfig.Selection, I) error
// InspectPrompt inspects the selected prompt after input and state
@@ -119,6 +119,9 @@ type Suite[I, S any] struct {
// context, and an empty value on success; PromptKit errors are returned
// unchanged where supported.
ValidateRequest func(context.Context, ValidationRequest, I, S) (commandkit.Acquired[struct{}], error)
// PrepareRequest independently enables `promptkit show prepared`, returning
// the native prepared request and any acquisition diagnostics.
PrepareRequest func(context.Context, PreparationRequest, I, S) (commandkit.Acquired[*promptkit.PreparedRun], error)
// SmokeTest runs one concrete native smoke-test operation after input and
// state preparation. It is optional; nil omits only the smoke-test command.
// The acquisition retains a native report, independent diagnostics, and