diff --git a/README.md b/README.md index 37a7d69..b66a4d7 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,24 @@ To select a built-in palette in YAML, set `branding.theme` to `default` or ## Generate one diagnostic report +Render a normalized diagnostic JSON v1 through the shared Reportist engine: + ```bash -./beffroi.sh diagnostic-pdf capture.json diagnostic.pdf +./beffroi.sh diagnostic-pdf diagnostic.json diagnostic.pdf ``` -This runs the diagnostic plugin through the common Reportist engine. Choose a -configured palette with `DIAGNOSTICS_THEME=default`, `cic`, or `eridani`. -For an evidence-backed draft generation, run: +Set `DIAGNOSTICS_THEME=default`, `cic`, or `eridani` to choose a bundled palette. +Reportist can also emit its JSON intermediate directly: + +```bash +./beffroi.sh report diagnostic.json diagnostic.pdf \ + --plugin reports/plugins/diagnostics --plugin-input theme=cic \ + --emit-ir diagnostic.report.json +``` + +For a raw WinDiagnostics capture, run `./beffroi.sh capture-pdf capture.json +diagnostic.pdf`. This analyzes the capture first, then renders the diagnostic. +For a persistent evidence-backed draft generation, run: ```bash ./beffroi.sh diagnostic \ @@ -31,8 +42,10 @@ For an evidence-backed draft generation, run: 2026-09-15T12:00:00Z 'Diagnostic review' 'Reviewer Name' 2026-09-15 ``` -The output contains the normalized diagnostic, evidence-backed draft generation, -and rendered PDF. +The generation includes normalized diagnostic JSON, a Reportist JSON draft, +evidence snapshots, a hash manifest, and a PDF. Custom reports can use the same +tables, progress bars, finding lists, and section page breaks; see +[`reporter/examples/diagnostic-style.yaml`](reporter/examples/diagnostic-style.yaml). ## Generate every stored PDF @@ -62,8 +75,9 @@ destination. ## Commands ```text -./beffroi.sh report INPUT OUTPUT.pdf -./beffroi.sh diagnostic-pdf CAPTURE OUTPUT.pdf +./beffroi.sh report INPUT OUTPUT.pdf [Reportist options] +./beffroi.sh diagnostic-pdf DIAGNOSTIC.json OUTPUT.pdf +./beffroi.sh capture-pdf CAPTURE OUTPUT.pdf ./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME TITLE AUTHOR DATE ./beffroi.sh all NEW_OUTPUT_DIR [--include-json] ./beffroi.sh package BUILD_DIR ARTIFACT_DIR diff --git a/beffroi.sh b/beffroi.sh index eb01885..b4afb0d 100755 --- a/beffroi.sh +++ b/beffroi.sh @@ -5,8 +5,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" usage() { cat <<'EOF' Usage: - ./beffroi.sh report INPUT OUTPUT.pdf - ./beffroi.sh diagnostic-pdf CAPTURE OUTPUT.pdf + ./beffroi.sh report INPUT OUTPUT.pdf [Reportist options] + ./beffroi.sh diagnostic-pdf DIAGNOSTIC.json OUTPUT.pdf + ./beffroi.sh capture-pdf CAPTURE OUTPUT.pdf ./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME TITLE AUTHOR DATE ./beffroi.sh all NEW_OUTPUT_DIR [--include-json] ./beffroi.sh package BUILD_DIR ARTIFACT_DIR @@ -26,14 +27,20 @@ require() { command_name=${1:-help}; shift || true case "$command_name" in report) - [[ $# -eq 2 ]]||usage 2; require typst - reporter/render.sh "$1" --output "$2" + (($# >= 2))||usage 2; require typst + report_input=$1; report_output=$2; shift 2 + reporter/render.sh "$report_input" --output "$report_output" "$@" ;; diagnostic-pdf) [[ $# -eq 2 ]]||usage 2; require typst - reporter/render-plugin.sh reports/plugins/diagnostics "$1" "$2" \ - --author "${DIAGNOSTICS_AUTHOR:-Beffroi}" \ - --theme "${DIAGNOSTICS_THEME:-default}" + reports/plugins/diagnostics/tools/validate.sh "$1" >/dev/null + reporter/render.sh "$1" --plugin reports/plugins/diagnostics \ + --plugin-input "author=${DIAGNOSTICS_AUTHOR:-Beffroi}" \ + --plugin-input "theme=${DIAGNOSTICS_THEME:-default}" --output "$2" + ;; + capture-pdf) + [[ $# -eq 2 ]]||usage 2; require git typst + scripts/render-capture.sh "$1" "$2" ;; diagnostic) [[ $# -eq 7 ]]||usage 2; require git typst diff --git a/reporter b/reporter index da2882b..2eebf62 160000 --- a/reporter +++ b/reporter @@ -1 +1 @@ -Subproject commit da2882b4f8e08ef5f964377bf53bab0d25197866 +Subproject commit 2eebf62f122631f72234438f6b5be15955021300 diff --git a/reports b/reports index 6b9f69a..c42ba8c 160000 --- a/reports +++ b/reports @@ -1 +1 @@ -Subproject commit 6b9f69a1e671ca43726f76075d4f349deb7df05c +Subproject commit c42ba8c095d770d8d4620169587389f9d247a7e5 diff --git a/scripts/build-publication.sh b/scripts/build-publication.sh index ac3ccaa..4da9680 100755 --- a/scripts/build-publication.sh +++ b/scripts/build-publication.sh @@ -29,8 +29,7 @@ while IFS= read -r -d '' source; do relative=${source#reports/diagnostics/} output="$output_root/diagnostics/${relative%.json}.pdf" mkdir -p "$(dirname "$output")" - reporter/render-plugin.sh reports/plugins/diagnostics "$source" "$output" \ - --author "${DIAGNOSTICS_AUTHOR:-Beffroi}" --theme "${DIAGNOSTICS_THEME:-default}" + scripts/render-capture.sh "$source" "$output" ((count += 1)) done < <(find reports/diagnostics -type f -name '*.json' -print0 | sort -z) ((count > 0)) || { echo 'No diagnostic captures found' >&2; exit 1; } diff --git a/scripts/check-components.sh b/scripts/check-components.sh index f1c817a..fcccd3c 100755 --- a/scripts/check-components.sh +++ b/scripts/check-components.sh @@ -37,9 +37,9 @@ reporter/tests/test.sh echo "Checking reports ($(git -C reports rev-parse HEAD))" DIAGNOSTIC_VALIDATOR="$(pwd)/reports/plugins/diagnostics/tools/validate.sh" \ REPORT_VALIDATOR="$(pwd)/reporter/tools/validate.sh" \ -BRANDING="$(pwd)/reports/config/branding/default.json" \ +BRANDING="$(pwd)/reports/plugins/diagnostics/runtime/themes/default.json" \ BRANDING_ROOT="$(pwd)/reports" \ -BRANDING_DIRECTORY="$(pwd)/reports/config/branding" \ +BRANDING_DIRECTORY="$(pwd)/reports/plugins/diagnostics/runtime/themes" \ reports/tests/test.sh echo 'Checking stored Reportist YAML' @@ -60,9 +60,14 @@ typst eval --root "$pipeline_check_root" --input diagnostic=diagnostic.json \ 'query().first().value' >/dev/null test "$(head -c 5 "$pipeline_check_root/report.pdf")" = '%PDF-' -reporter/render-plugin.sh reports/plugins/diagnostics \ - reports/plugins/diagnostics/tests/fixtures/legacy/windiagnostics-v1.json \ - "$pipeline_check_parent/plugin.pdf" --theme eridani --author 'CI Test' +reporter/render.sh "$pipeline_check_root/diagnostic.json" \ + --plugin reports/plugins/diagnostics --plugin-input theme=eridani \ + --plugin-input 'author=CI Test' --output "$pipeline_check_parent/plugin.pdf" \ + --emit-ir "$pipeline_check_parent/plugin.ir.json" +reporter/tools/validate.sh "$pipeline_check_parent/plugin.ir.json" +reporter/render.sh "$pipeline_check_parent/plugin.ir.json" \ + --output "$pipeline_check_parent/replayed.pdf" +test "$(head -c 5 "$pipeline_check_parent/replayed.pdf")" = '%PDF-' test "$(head -c 5 "$pipeline_check_parent/plugin.pdf")" = '%PDF-' echo 'Component suites and the raw-capture-to-PDF integration pipeline passed.' diff --git a/scripts/render-capture.sh b/scripts/render-capture.sh new file mode 100755 index 0000000..ac346d2 --- /dev/null +++ b/scripts/render-capture.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Analyze a raw WinDiagnostics capture, then render its diagnostic JSON via Reportist. +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." +[[ $# -eq 2 ]] || { echo "Usage: $0 CAPTURE OUTPUT.pdf" >&2; exit 2; } +capture=$(realpath "$1"); output=$2 +[[ -f "$capture" ]] || { echo "Missing capture: $capture" >&2; exit 1; } +stage=$(mktemp -d "${TMPDIR:-/tmp}/beffroi-capture.XXXXXXXX") +trap 'rm -rf "$stage"' EXIT +cp -- "$capture" "$stage/capture.json" +cp -- reports/plugins/diagnostics/tools/capture-info.typ "$stage/capture-info.typ" +collected=$(typst eval --root "$stage" --input capture=capture.json --in "$stage/capture-info.typ" 'query().first().value') +collected=${collected#\"}; collected=${collected%\"} +reports/plugins/diagnostics/analyse.sh "$capture" --evidence-root "$(dirname "$capture")" \ + --output "$stage/diagnostic.json" --reference-time "$collected" \ + --producer-version "$(git -C reports rev-parse HEAD)" >/dev/null +reporter/render.sh "$stage/diagnostic.json" --plugin reports/plugins/diagnostics \ + --plugin-input "author=${DIAGNOSTICS_AUTHOR:-Beffroi}" \ + --plugin-input "theme=${DIAGNOSTICS_THEME:-default}" --output "$output" diff --git a/scripts/workflow-all.sh b/scripts/workflow-all.sh index 75620b4..63b2b3c 100755 --- a/scripts/workflow-all.sh +++ b/scripts/workflow-all.sh @@ -17,7 +17,7 @@ reports/plugins/diagnostics/tools/diagnostic-to-report-all.sh --diagnostic-dir " --generator-version "$(git -C reports rev-parse HEAD)" \ --diagnostic-validator "$PWD/reports/plugins/diagnostics/tools/validate.sh" \ --report-validator "$PWD/reporter/tools/validate.sh" \ - --branding "$PWD/reports/config/branding/default.json" --branding-root "$PWD/reports" + --branding "$PWD/reports/plugins/diagnostics/runtime/themes/default.json" --branding-root "$PWD/reports" while IFS= read -r -d '' report; do relative=${report#"$output_root/generations/"}; relative=${relative%/report.draft.json} reporter/render.sh "$report" --output "$output_root/pdfs/$relative.pdf" diff --git a/scripts/workflow.sh b/scripts/workflow.sh index 21648f0..36e2ff3 100755 --- a/scripts/workflow.sh +++ b/scripts/workflow.sh @@ -40,7 +40,7 @@ draft() { --generator-version "$(git -C reports rev-parse HEAD)" \ --diagnostic-validator "$(pwd)/reports/plugins/diagnostics/tools/validate.sh" \ --report-validator "$(pwd)/reporter/tools/validate.sh" \ - --branding reports/config/branding/default.json \ + --branding reports/plugins/diagnostics/runtime/themes/default.json \ --branding-root reports }