# Prompt Input Internals This document describes prompt input data package construction. ## Purpose `internal/promptinput` converts a structured briefing package and optional Recent Changes into the `data_package` JSON passed to Scriptorium prompts. ## Inputs And Outputs Inputs: - `briefing.Package` - optional `[]changes.Change` Outputs: - `promptinput.Package` containing schema version, RunID, report metadata, briefing content, Recent Changes, and source warnings. Briefing content includes configured location context, current conditions when available, structured weather story context when available, discussion key messages, and short/long-term AFD narratives when the Weather API provides them. - report metadata includes `currentLocalDate`, the generation date formatted as `YYYY-MM-DD` in the effective report timezone. - optional JSON file written by `promptinput.Save` ## Boundaries - This package owns the prompt input schema and validation. - It does not fetch weather data, derive forecast summaries, find prior snapshots, compare changes, or invoke Scriptorium. ## Config Fields Used None directly. Config-derived values, including timezone and prompt location context, are already present in briefing metadata before this package runs. ## External Adapters Used None. ## State Or Manifest Behavior `promptinput.Save` writes JSON atomically. Managed workspace paths are owned by `internal/state`. ## Skip And Resume Behavior None. Recent Changes is always present as an `items` list and may be empty. ## Failure Behavior Validation fails before render preflight when required top-level or briefing metadata fields are missing or inconsistent, or when no report content is present. Save failures include filesystem operation and path context. ## Tests Inspect: - `internal/promptinput/package_test.go` - `internal/app/app_test.go` ## Invariants - Scriptorium receives structured `data_package` JSON. - Briefing metadata and top-level report metadata must agree. - Recent Changes are not inferred from rendered report text.