Imported from vinaosb/libertarian-constitution-and-laws (
tools/AGENTS.md). Install upstream withnpx skills add vinaosb/libertarian-constitution-and-laws --skill tools. Copyright stays with the author.
tools/
PowerShell build and generation scripts. This is a scripting domain, not legal text. Files here are the only PowerShell in the repository.
Files
| File | Lines | Purpose |
|---|---|---|
generate-framework.ps1 |
624 | Template engine. Reads a YAML config, walks en/modules/, substitutes {{param}}, resolves {{#if}} and {{#regional}} conditionals, writes a finished charter to build/. |
build-pdfs.ps1 |
251 | PDF pipeline. Groups source markdown by document group, invokes pandoc with typst (preferred) or xelatex (fallback), writes to output/en/files/. |
build.ps1 |
167 | Legacy entry point. Thin wrapper that calls build-pdfs.ps1. |
Usage
# Generate the consolidated PDF (single file containing everything)
pwsh -File tools/build-pdfs.ps1 -Target consolidated
# Generate per-document-group PDFs
pwsh -File tools/build-pdfs.ps1
# Generate the regional charter under the standard configuration
pwsh -File tools/generate-framework.ps1 -Config en/configs/standard-3level.yml
# Generate the local charter under the compact configuration
pwsh -File tools/generate-framework.ps1 -Config en/configs/compact-2level.yml
# Remove all generated PDFs
pwsh -File tools/build-pdfs.ps1 -Target clean
Dependencies
- PowerShell 7.0 or later (
pwsh). Windows PowerShell 5.1 will not work. pandoc3.0 or later.typst0.10 or later, orxelatexas fallback.- A
legal.cslcitation style file atassets/csl/legal.csl. - LaTeX templates in
templates/(legal-book.tex,cover-page.tex).
Outputs
| Path | Contents |
|---|---|
output/en/files/ |
Generated PDFs (consolidated and per-group), organized by language. |
build/ |
Generated framework charters, generation report, migration guide. |
Both directories are build artifacts. Do not commit their contents except by explicit request.
Continuous integration
.github/workflows/build-pdf.yml runs the PDF pipeline on every push and pull request to main, installs pandoc and TeX Live, and uploads the consolidated PDF as an artifact.
.github/workflows/structure-parity.yml runs the framework generator for both configurations and executes the QA gate scripts under .sisyphus/drafts/gates/. It fails the build on any unresolved placeholder, stale -draft suffix, old numbering format, or broken cross-reference. Local pre-flight should mirror these checks.
Encoding (critical on Windows)
PowerShell Set-Content -Encoding UTF8 on Windows PowerShell 5.1 emits a byte order mark. The BOM breaks downstream pandoc and typst processing. When a script in this directory writes content, it uses:
[System.IO.File]::WriteAllText($path, $content, [System.Text.UTF8Encoding]::new($false))
The constructor argument $false disables BOM emission. Preserve this pattern in any new script.
What lives elsewhere
- Module content that the generator consumes:
en/modules/anden/modules/AGENTS.md. - YAML configurations that parameterize generation:
en/configs/. - Generator spec, parameter reference, assembly order:
docs/FRAMEWORK-ARCHITECTURE.md. - QA gate scripts that CI invokes:
.sisyphus/drafts/gates/. - Universal drafting rules and encoding notes for legal text: root
AGENTS.md.
Gotchas
- The generator reads
en/configs/*.ymldirectly. Parameter names in modules must match YAML keys exactly (lowercase with underscores). build-pdfs.ps1preferstypst. Iftypstis not on PATH, it falls back toxelatex. The fallback is slower and produces slightly different pagination.- Generated charters in
build/must obey the same drafting rules as hand-written text. Run the same QA gates on generated output as on source.