2026-10-07 14:56:13 +00:00
|
|
|
# Composed consumer
|
|
|
|
|
|
2026-11-07 11:12:23 +00:00
|
|
|
This example is part of the ckprompt module and uses core v0.4.0, ckconfig
|
2026-11-07 05:01:30 +00:00
|
|
|
v0.3.0, ConfigKit v1.1.0, and PromptKit v0.20.0. It requires Go 1.27.0.
|
2026-11-07 11:12:23 +00:00
|
|
|
The current work uses the aligned local workspace until the required ckconfig
|
|
|
|
|
release is published.
|
2026-11-04 03:55:17 +00:00
|
|
|
|
2026-10-07 14:56:13 +00:00
|
|
|
This example composes application configuration, PromptKit configuration,
|
2026-10-12 17:26:11 +00:00
|
|
|
PromptKit comparison and catalogs, definition and requirements inspection, and
|
|
|
|
|
one application-owned command:
|
2026-10-07 14:56:13 +00:00
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
go run . config scopes
|
2026-10-11 02:13:16 +00:00
|
|
|
go run . config validate --scope all --campaign spring --limit=0
|
2026-10-11 21:54:39 +00:00
|
|
|
go run . config diff --scope app --config fixtures/before.yml --against-config fixtures/after.yml
|
|
|
|
|
go run . config diff --scope app --config fixtures/before.yml --against-config fixtures/after.yml --campaign spring --limit=0
|
2026-11-07 05:01:30 +00:00
|
|
|
go run . config diff --scope app --campaign spring --limit=0 --against-campaign autumn --against-limit=0 --set '/campaigns/spring/model="left"' --against-set '/campaigns/spring/model="right"' --details
|
2026-11-07 04:36:05 +00:00
|
|
|
go run . config diff --scope promptkit --config fixtures/before.yml --against-config fixtures/after.yml --campaign spring --against-campaign spring
|
2026-10-12 02:28:20 +00:00
|
|
|
go run . promptkit list prompts --config fixtures/before.yml --campaign spring
|
|
|
|
|
go run . promptkit list profiles --config fixtures/after.yml --campaign autumn --format yaml
|
2026-10-17 19:06:05 +00:00
|
|
|
go run . promptkit list backends --campaign spring
|
|
|
|
|
go run . promptkit list namespaces --campaign spring
|
|
|
|
|
go run . promptkit list collections --campaign spring
|
2026-10-19 19:56:33 +00:00
|
|
|
go run . list collections --campaign spring
|
|
|
|
|
go run . pk list bundles --campaign spring
|
2026-10-17 19:06:05 +00:00
|
|
|
go run . promptkit list prompts --namespace field-notes --campaign spring
|
2026-10-07 14:56:13 +00:00
|
|
|
go run . promptkit show prompt briefing --campaign spring --format yaml
|
2026-11-07 05:01:30 +00:00
|
|
|
go run . promptkit show prompt briefing --campaign spring --prompt-namespace field-notes
|
|
|
|
|
go run . promptkit show prepared briefing --campaign spring --input topic=sprint --profile spring --extra-params '{"campaign":"preview"}'
|
2026-10-19 19:56:33 +00:00
|
|
|
go run . pk show prompt briefing --campaign spring --fmt yaml
|
2026-10-07 14:56:13 +00:00
|
|
|
go run . promptkit show profile spring --campaign spring
|
2026-10-12 17:26:11 +00:00
|
|
|
go run . promptkit requirements show briefing --campaign spring
|
2026-11-07 04:27:28 +00:00
|
|
|
go run . promptkit requirements show briefing --campaign spring --var mode=full --format yaml
|
2026-11-07 04:16:09 +00:00
|
|
|
go run . promptkit requirements validate briefing --campaign spring --llm-input-file topic=fixtures/topic.txt
|
|
|
|
|
go run . promptkit requirements validate briefing --campaign spring --llm-input-file topic=fixtures/topic.txt --llm-var mode=full --llm-input-file notes=fixtures/notes.txt --format yaml
|
2026-10-12 22:22:51 +00:00
|
|
|
go run . promptkit requirements validate briefing --campaign spring
|
2026-11-07 04:27:28 +00:00
|
|
|
go run . promptkit test text_inference --campaign spring --prompt briefing --profile spring
|
2026-11-07 04:16:09 +00:00
|
|
|
go run . smoke text_inference --campaign spring --llm-prompt briefing --llm-profile spring
|
|
|
|
|
go run . promptkit test all --campaign spring --llm-prompt briefing --llm-profile spring
|
2026-10-19 19:56:33 +00:00
|
|
|
go run . pk --hlep
|
2026-10-07 14:56:13 +00:00
|
|
|
go run . session restore session-42 --campaign spring
|
2026-11-07 05:01:30 +00:00
|
|
|
go run . request inspect --llm-prompt briefing --llm-profile= --llm-model example --llm-input-text topic=sprint --format json
|
2026-10-07 14:56:13 +00:00
|
|
|
```
|
|
|
|
|
|
2026-10-19 19:56:33 +00:00
|
|
|
`newApp` installs application-owned command and flag aliases alongside the
|
|
|
|
|
complete `ckconfig` and `ckprompt` declarations. `list collections` and
|
|
|
|
|
`promptkit list bundles` both reach the canonical collection command; `pk`
|
|
|
|
|
shortens the PromptKit group. `--fmt` is scoped to named prompt inspection and
|
|
|
|
|
`--hlep` is available globally. The `smoke` shortcut retains the canonical
|
|
|
|
|
`promptkit test KIND` operand, including the special `all` aggregate.
|
|
|
|
|
|
2026-11-03 04:09:27 +00:00
|
|
|
The example installs `Completion("composed-example")`. Build it as
|
2026-11-03 13:12:36 +00:00
|
|
|
`go build -o composed-example .`. Initialize `bash-completion` first if using
|
|
|
|
|
Bash, then load a shell script as described in the
|
2026-11-03 04:09:27 +00:00
|
|
|
[CLI reference](../../../../docs/cli.md#shell-completion). Try completion after
|
|
|
|
|
`composed-example pk show prompt briefing --fmt=` or after the filename prefix
|
|
|
|
|
in `composed-example config show --config=fixtures/`. The already-entered `pk`
|
|
|
|
|
alias selects the PromptKit command context without loading an engine.
|
|
|
|
|
|
2026-11-07 05:01:30 +00:00
|
|
|
The composition installs `ckconfig.Command(suite)` and the complete
|
|
|
|
|
`ckprompt.Declarations(definitions)` in a `[]commandkit.Declaration` with
|
|
|
|
|
root-installed routing rules. The PromptKit declarations include scoped aliases;
|
|
|
|
|
the application-owned `request inspect` command reuses the flag collections
|
|
|
|
|
with their canonical names and does not install those aliases.
|
2026-10-19 19:59:41 +00:00
|
|
|
Group children remain canonical `Command` values. For command-only slices,
|
|
|
|
|
convert each `Command` to `Declaration` before appending aliases. The
|
|
|
|
|
[consumer guide](../../../../docs/consumers/guide.md#application-owned-aliases)
|
|
|
|
|
includes minimal direct-call and slice-conversion examples; this README documents
|
|
|
|
|
the maintained complete consumer.
|
|
|
|
|
|
2026-10-07 14:56:13 +00:00
|
|
|
The sources and session store are small in-memory fixtures. `--campaign` is a
|
|
|
|
|
typed selector shared by the app and PromptKit configuration scopes. Their
|
2026-10-11 13:07:00 +00:00
|
|
|
`ckconfig.Suite[*inspectionInput, *runCache]` uses `NewInput` to initialize each
|
|
|
|
|
selected scope's input separately and `NewState` to create one cache shared by
|
|
|
|
|
that invocation's acquisitions. Prompt/profile inspection prepares its input and
|
|
|
|
|
cache independently for its invocation, using the same application and engine
|
|
|
|
|
loader functions. See the
|
|
|
|
|
[consumer guide](https://gitea.maximumdirect.net/eric/CommandKit/src/branch/main/docs/consumers/guide.md)
|
|
|
|
|
and the suites' GoDoc for initialization timing and ownership.
|
2026-10-11 21:54:39 +00:00
|
|
|
|
2026-10-12 02:28:20 +00:00
|
|
|
The application-scope comparison reports the changed default campaign and the
|
|
|
|
|
updated `campaigns.spring.model`. The PromptKit-scope comparison selects spring
|
2026-11-06 01:03:55 +00:00
|
|
|
on both sides and reports the native engine change in the atomic profiles list.
|
2026-10-12 02:28:20 +00:00
|
|
|
The application input check requires `--limit=0` when `--campaign` is supplied.
|
|
|
|
|
Catalogs use the same selection-aware loader: the prompt catalog includes
|
2026-11-06 01:03:55 +00:00
|
|
|
`briefing`, and the profile catalog includes the selected `autumn` profile.
|
|
|
|
|
Prompt inspection uses an ID only. The default PromptKit bundle also contributes
|
|
|
|
|
profiles and a backend to the engine inventory and source reports. The synthetic `field-notes` collection
|
2026-10-17 19:06:05 +00:00
|
|
|
provides one backend, profile, and prompt for collection discovery and native
|
|
|
|
|
namespace filtering. The example's shared run cache keys successful results by
|
2026-11-07 05:01:30 +00:00
|
|
|
the complete supplied configuration/overlay selection, CLI overrides, and the
|
|
|
|
|
supplied campaign, including presence. The campaign override and application
|
|
|
|
|
scope's `--set` records are applied through ConfigKit before loading. The
|
|
|
|
|
PromptKit configuration scope does not enable `--set` because its released
|
|
|
|
|
configuration loader has no override handoff. An aggregate operation therefore
|
|
|
|
|
rejects overrides when that scope is selected. These are choices for this
|
|
|
|
|
example's loaders and do not define a CommandKit cache policy.
|
2026-10-17 19:06:05 +00:00
|
|
|
|
|
|
|
|
Smoke testing is explicitly wired with `ckprompt.WithSmokeTesting` and its
|
|
|
|
|
optional request builder is nil, so CommandKit forwards the selected native
|
|
|
|
|
request. Applications that need to adjust the request can provide a typed
|
|
|
|
|
builder that starts with the seed and returns the chosen native request:
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
definitions = ckprompt.WithSmokeTesting(definitions, loadEngine,
|
|
|
|
|
func(ctx context.Context, seed ckprompt.SmokeRequest, input *inspectionInput, state *runCache) (promptkit.SmokeTestRequest, error) {
|
|
|
|
|
request := seed.Request
|
|
|
|
|
request.ProfileID = "spring"
|
|
|
|
|
return request, nil
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The example injects a small in-memory `promptkit.LLMClient` through its shared
|
|
|
|
|
run state. Catalog, inspection, and requirements commands do not call it;
|
|
|
|
|
inference smoke commands do. No model service or credentials are required.
|
|
|
|
|
Native HTTP checks may retain unsupported or not-applicable observations because
|
2026-11-06 01:03:55 +00:00
|
|
|
the selected local backend does not configure a network probe. An aggregate smoke command can
|
2026-10-17 19:06:05 +00:00
|
|
|
return an operational outcome for a native diagnostic while still delivering
|
|
|
|
|
the complete aggregate report.
|
2026-10-12 17:26:11 +00:00
|
|
|
|
|
|
|
|
The first requirements command reports incomplete discovery: PromptKit records
|
|
|
|
|
the conditional `notes` input and a missing `mode` issue. Supplying `mode=full`
|
|
|
|
|
selects that branch, classifies the undeclared `notes` input as required, and
|
|
|
|
|
completes discovery. Both commands return successful reports; the result does
|
|
|
|
|
not execute the prompt or establish input, credential, or execution readiness.
|
|
|
|
|
See the [CLI reference](../../../../docs/cli.md#promptkit-requirements) for the
|
|
|
|
|
command and report contract.
|
2026-10-12 22:22:51 +00:00
|
|
|
|
2026-11-07 05:01:30 +00:00
|
|
|
The validation and preview commands exercise concrete PromptKit request preparation.
|
2026-10-12 22:22:51 +00:00
|
|
|
The first uses the builder's campaign-specific default topic variable and the
|
|
|
|
|
operator's topic file. The second also selects the notes branch and supplies its
|
2026-11-07 05:01:30 +00:00
|
|
|
file. Validation reports only `prompt_id` and `valid: true`; preview returns the
|
|
|
|
|
prepared request, including rendered messages and effective provider settings.
|
|
|
|
|
Neither executes the prompt. The validation command without inputs intentionally
|
|
|
|
|
fails because the prompt's
|
2026-10-12 22:22:51 +00:00
|
|
|
required `topic` artifact is not supplied. The builder defaults variables from
|
|
|
|
|
the selected campaign but leaves artifact bindings to the operator. The
|
|
|
|
|
`requirements show` commands remain discovery reports: partial discovery can
|
|
|
|
|
succeed even when a concrete request would fail validation.
|
2026-10-19 19:56:33 +00:00
|
|
|
|
2026-11-07 05:01:30 +00:00
|
|
|
Use the aligned local workspace to test the three current sources, as described in
|
|
|
|
|
the [developer guide](../../../../docs/development.md#documentation-validation).
|
|
|
|
|
Once released dependency requirements are aligned, `GOWORK=off go test ./...`
|
|
|
|
|
from this example directory checks it against its declared dependencies.
|