Add Promptkit debug capture for generated reports
This commit is contained in:
12
docs/cli.md
12
docs/cli.md
@@ -17,10 +17,10 @@ required Weather API endpoint.
|
||||
|
||||
```text
|
||||
weatherreporter --help
|
||||
weatherreporter generate daily --date YYYY-MM-DD [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--quiet]
|
||||
weatherreporter generate today [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--date YYYY-MM-DD] [--quiet]
|
||||
weatherreporter generate tomorrow [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--quiet]
|
||||
weatherreporter generate hourly [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--quiet]
|
||||
weatherreporter generate daily --date YYYY-MM-DD [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--llm-debug-dir PATH] [--quiet]
|
||||
weatherreporter generate today [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--date YYYY-MM-DD] [--llm-debug-dir PATH] [--quiet]
|
||||
weatherreporter generate tomorrow [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--llm-debug-dir PATH] [--quiet]
|
||||
weatherreporter generate hourly [--config PATH] [--units VALUE] [--tz NAME] [--out PATH] [--llm-debug-dir PATH] [--quiet]
|
||||
weatherreporter run morning [--config PATH] [--units VALUE] [--tz NAME] [--out-dir PATH] [--quiet]
|
||||
weatherreporter run evening [--config PATH] [--units VALUE] [--tz NAME] [--out-dir PATH] [--quiet]
|
||||
weatherreporter inspect reports [--config PATH] [--limit N]
|
||||
@@ -81,7 +81,7 @@ time, valid period, and status:
|
||||
|
||||
When available, the summary also includes `reportPath`, `metadataPath`,
|
||||
`dataPackagePath`, `preparationPath`, `executionPath`, `generatedTextRawPath`,
|
||||
`generatedTextPath`, and `renderContextPath`. `outputPath` is included only
|
||||
`generatedTextPath`, `renderContextPath`, and `llmDebugPath`. `outputPath` is included only
|
||||
when `--out` wrote an extra copy. Distributor notification, when attempted,
|
||||
adds `notificationPath` and may add a compact `notification` object.
|
||||
|
||||
@@ -108,6 +108,7 @@ batch=morning total=2 succeeded=2 failed=0
|
||||
| `--units VALUE` | `generate`, `run` | Override `weather_api.units` for this command. |
|
||||
| `--tz NAME` | `generate`, `run` | Override `weather_api.timezone` for this command. |
|
||||
| `--out PATH` | every `generate` command | Write an extra Markdown report copy. |
|
||||
| `--llm-debug-dir PATH` | every `generate` command | Write requested sensitive prompt diagnostics outside the managed workspace. The path must be absolute. |
|
||||
| `--out-dir PATH` | `run morning`, `run evening` | Write extra Markdown report copies in `PATH`. |
|
||||
| `--quiet` | `generate`, `run` | Suppress action summaries and routine batch status output. |
|
||||
| `--date YYYY-MM-DD` | `generate daily`, `generate today` | Required for Daily; optional for Today. |
|
||||
@@ -122,6 +123,7 @@ no Distributor-specific CLI flags. See the [configuration reference](config.md).
|
||||
weatherreporter generate daily --date 2026-05-29 --out ./daily.md
|
||||
weatherreporter generate today --date 2026-05-29 --out ./today.md
|
||||
weatherreporter generate hourly --out ./hourly.md
|
||||
weatherreporter generate today --llm-debug-dir /var/tmp/weatherreporter-debug
|
||||
weatherreporter run morning --out-dir ./reports
|
||||
```
|
||||
|
||||
|
||||
@@ -151,6 +151,9 @@ Promptkit configuration selects the executor and prompt/profile checks for
|
||||
every `generate` command. Scriptorium settings remain in use by batch commands
|
||||
while their compatibility workflow remains active.
|
||||
|
||||
Prompt debug capture has no YAML setting. Use `--llm-debug-dir PATH` on an
|
||||
individual `generate` command when explicitly needed.
|
||||
|
||||
| Field | Default | Rules |
|
||||
| --- | --- | --- |
|
||||
| `profile` | empty | Optional explicit execution profile. Otherwise the prompt's declared default is used. |
|
||||
|
||||
@@ -32,8 +32,9 @@ safe project-owned identity and provenance values.
|
||||
## Single-Report Workflow
|
||||
|
||||
`GenerateDetailed` resolves the requested report using the configured registry
|
||||
and current time, verifies the exact Promptkit prompt and selected profile, and
|
||||
only then collects weather data. Inspection failure produces no collection or
|
||||
and current time, initializes any requested prompt-debug root, verifies the
|
||||
exact Promptkit prompt and selected profile, and only then collects weather
|
||||
data. Debug initialization or inspection failure produces no collection or
|
||||
managed artifacts.
|
||||
|
||||
Single-report generation requires a non-nil normalized bundle and then performs this
|
||||
@@ -46,8 +47,10 @@ ordered work:
|
||||
3. Serialize and save the prompt data package once, then use those exact bytes
|
||||
for Promptkit execution.
|
||||
4. Save preparation provenance and V2 metadata from the preparation callback
|
||||
before provider execution. Save execution provenance after raw output is
|
||||
persisted, then save updated metadata.
|
||||
before provider execution. When requested, save preparation diagnostics in
|
||||
the isolated debug store before the callback returns. Save execution
|
||||
diagnostics immediately after a completed execution result, then persist raw
|
||||
output and execution provenance before saving updated metadata.
|
||||
5. Validate and save generated text, build and save a render context, and
|
||||
render the managed Markdown template.
|
||||
6. Optionally make an output copy, save final metadata, optionally notify
|
||||
@@ -67,6 +70,10 @@ output, an execution receipt, and metadata before returning. If later report
|
||||
generation fails, the result retains every reached safe artifact path; output
|
||||
copies and notification are skipped until rendering succeeds.
|
||||
|
||||
The optional debug writer receives sensitive content only when explicitly
|
||||
enabled. Its path is added to the report result only after a debug artifact is
|
||||
successfully written; it is never copied into normal state records.
|
||||
|
||||
## Batch And Inspection Workflows
|
||||
|
||||
`RunBatchDetailed` collects once, asks the report registry to plan the batch
|
||||
|
||||
@@ -17,6 +17,10 @@ factory maps `promptkit` configuration to the Promptkit adapter, while tests can
|
||||
inject a factory without importing dependency types. Each `generate` request
|
||||
constructs one executor after configuration loads and passes it to the app.
|
||||
|
||||
All four `generate` commands also accept `--llm-debug-dir PATH`. The CLI passes
|
||||
only this explicit request to the app; the app initializes the secure debug
|
||||
root before prompt inspection. `run` commands do not accept the flag.
|
||||
|
||||
For inspection, it loads configuration, builds the appropriate app inspection
|
||||
request, and writes the returned value. Inspection is read-only; the inspected
|
||||
artifact types and user invocation remain owned by the [CLI reference](../cli.md)
|
||||
@@ -29,7 +33,7 @@ carry report identity, status, relevant artifact paths, and notification
|
||||
summary data. Batch summaries carry aggregate counts, per-report outcomes, and
|
||||
the optional batch notification result. The translation deliberately excludes
|
||||
full module snapshots, prompt packages, raw generated text, Scriptorium output,
|
||||
and complete Distributor payloads.
|
||||
complete Distributor payloads, and prompt-debug content.
|
||||
|
||||
When an action returns both a result and an error, the CLI writes the failed
|
||||
summary before returning that error. Parse, configuration-load, and other
|
||||
|
||||
@@ -25,6 +25,22 @@ Distributor notification is attempted. `--out` writes an extra operator copy;
|
||||
it never changes the managed report or upload source. A successful generate
|
||||
command prints its summary to stdout unless `--quiet` is used.
|
||||
|
||||
## Optional Prompt Debug Capture
|
||||
|
||||
Use `--llm-debug-dir` only when content-rich prompt diagnostics are required:
|
||||
|
||||
```sh
|
||||
weatherreporter generate today --llm-debug-dir /var/tmp/weatherreporter-debug
|
||||
```
|
||||
|
||||
The directory must be absolute and is initialized before prompt inspection or
|
||||
weather collection. Capture files are stored outside the managed workspace,
|
||||
with restrictive permissions, under the report ID, valid date, and RunID.
|
||||
They can contain rendered prompts and generated output, so the normal metadata,
|
||||
CLI summary, and routine logs contain only the optional directory path—not
|
||||
their content. A capture-write failure stops that run before later work can
|
||||
continue.
|
||||
|
||||
Run a scheduled batch with the same configured collection:
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user