Generate Daily reports through scriptorium

This commit is contained in:
2026-05-29 17:47:42 +00:00
parent 7ac73f758b
commit b17a3591e0
14 changed files with 543 additions and 113 deletions

View File

@@ -1,21 +1,23 @@
# Weatherreporter CLI
`weatherreporter generate daily` currently writes managed Daily preparation
artifacts under the configured workspace and runs `scriptorium render` as a
preflight check. Other report generation and scheduled runs still resolve
configuration, report definitions, and valid periods, then return a
not-implemented error.
`weatherreporter generate daily` currently writes a Daily Markdown report
through `scriptorium`, after writing managed preparation artifacts and running
`scriptorium render` as a preflight check. Other report generation and scheduled
runs still resolve configuration, report definitions, and valid periods, then
return a not-implemented error.
## Shortest Useful Command
```sh
weatherreporter generate daily --date 2026-05-29 --out ./daily.data_package.json
weatherreporter generate daily --date 2026-05-29 --out ./daily.md
```
The command parses flags, loads configuration, fetches weather data, builds a
Daily briefing, writes workspace artifacts, and invokes
`scriptorium render --input data_package=<managed_path> --format json`. When
`--out` is supplied, it also writes a copy of the data package to that path.
Daily briefing, writes workspace artifacts, invokes
`scriptorium render --input data_package=<managed_path> --format json`, then
invokes `scriptorium run --input data_package=<managed_path> --out <managed_report>`.
When `--out` is supplied, it also writes a copy of the Markdown report to that
path.
## Command Overview
@@ -30,10 +32,10 @@ weatherreporter run evening
```
`generate daily` writes a briefing snapshot, prompt input data package, render
preflight output, and metadata file under the configured workspace. Other
`generate` commands resolve one report request and stop before report
generation. `run` commands resolve a scheduled batch request and stop before
execution.
preflight output, Markdown report, and metadata file under the configured
workspace. Other `generate` commands resolve one report request and stop before
report generation. `run` commands resolve a scheduled batch request and stop
before execution.
## Flags
@@ -41,7 +43,7 @@ execution.
- `--config PATH`: load configuration from `PATH` instead of `/usr/local/etc/weatherreporter/config.yml`.
- `--units VALUE`: override configured Weather API units.
- `--tz NAME`: override configured Weather API timezone.
- `--out PATH`: optional extra data package copy for `generate daily`; reserved for later generated report output on other `generate` commands.
- `--out PATH`: optional Markdown report copy for `generate daily`; reserved for later generated report output on other `generate` commands.
- `--date YYYY-MM-DD`: optional date for `generate daily`; defaults to the current local date in the configured timezone.
- `--start TIME`: required start time for `generate storm`.
- `--end TIME`: required end time for `generate storm`.

View File

@@ -5,7 +5,7 @@ This document describes the implemented `scriptorium` subprocess adapter.
## Purpose
`internal/adapters/scriptorium` runs `scriptorium render` to preflight prompt
wiring without LLM generation.
wiring and `scriptorium run` to generate report artifacts.
## Inputs and Outputs
@@ -13,12 +13,13 @@ Input:
- prompt ID
- prompt input data package path
- report output path for `run`
- configured binary, config path, profile, timeout, and extra arguments
Output:
- captured stdout
- captured stderr
- captured stdout, with truncation tracking
- captured stderr, with truncation tracking
- exit code
- full argv used for inspection
@@ -37,15 +38,22 @@ The render invocation shape is:
scriptorium render --prompt <prompt_id> --input data_package=<path> --format json
```
The run invocation shape is:
```text
scriptorium run --prompt <prompt_id> --input data_package=<path> --out <artifact_path>
```
Configured `--config` and `--profile` values are added when present. Arguments
are passed directly as argv, not through a shell. Stdout and stderr are captured
separately. `SaveRenderResult` writes the captured result as JSON for inspection.
## Failure Behavior
Nonzero render exits return both the captured result and an error containing
the exit code and stderr. Command execution respects context cancellation and
the configured timeout.
Nonzero render and run exits return both the captured result and an error
containing the exit code and stderr. Run exit code `2` is treated as an error
but may still produce a report artifact. Command execution respects context
cancellation and the configured timeout.
## Tests
@@ -59,5 +67,5 @@ Inspect:
- `scriptorium` details stay inside the adapter package.
- The input name for prompt packages is always `data_package`.
- Render preflight is orchestration behavior; final report generation is not
implemented in this adapter yet.
- Render preflight remains orchestration behavior; this adapter only exposes the
subprocess operations.

View File

@@ -16,12 +16,14 @@ Inputs:
- briefing package
- prompt input data package
- `scriptorium render` result
- rendered report path preparation
Outputs:
- briefing snapshot JSON
- prompt input data package JSON
- render preflight JSON
- Markdown report path
- metadata JSON
- prior Daily snapshot metadata when available
@@ -47,7 +49,8 @@ Workspace subdirectories must be relative paths that stay under
Managed artifact names use RunID, which is generated from report generation time
and report ID. Daily metadata is stored beside Daily briefing snapshots by valid
local date. Prior Daily snapshot lookup reads metadata for the same valid local
date and returns the latest earlier run.
date and returns the latest earlier run. The store prepares the managed Markdown
report path before `scriptorium run` writes it.
## Failure Behavior

View File

@@ -2,15 +2,15 @@
## Normal Workflow
The implemented preparation workflow is:
The implemented Daily generation workflow is:
```text
weatherreporter generate daily --date 2026-05-29
```
The command fetches weather data, builds the Daily briefing, builds the prompt
input data package, runs `scriptorium render`, and writes inspectable artifacts
under the configured workspace.
input data package, runs `scriptorium render`, runs `scriptorium run`, and
writes inspectable artifacts under the configured workspace.
## Filesystem Layout
@@ -36,8 +36,8 @@ workspace/
<run_id>.md
```
The report path is reserved in metadata for the eventual rendered report. The
current workflow does not write the Markdown report.
The Markdown report is written to the managed report path. When `--out` is
provided, the managed report is also copied to that path.
## Run Identifiers
@@ -52,7 +52,7 @@ date do not overwrite each other.
## Metadata
Each Daily preparation writes metadata that links:
Each Daily generation writes metadata that links:
- RunID
- report ID and prompt ID
@@ -61,7 +61,7 @@ Each Daily preparation writes metadata that links:
- briefing snapshot path
- prompt input data package path
- preflight output path
- reserved rendered report path
- rendered report path
## Recovery
@@ -69,5 +69,9 @@ If render preflight exits nonzero after producing a result, the captured stdout,
stderr, exit code, and command are still written to the preflight artifact, and
metadata is still written for inspection.
If `scriptorium run` exits nonzero after writing a report, the generated report
and metadata remain available for inspection. Exit code `2` is still returned as
an error because it indicates validation failed, even if report output exists.
The application does not currently implement resume, cleanup, archive, or
remote storage behavior.