Metadata-Version: 2.4
Name: wherefore-build
Version: 0.18.0
Summary: A company that compiles: every asset generated from one source of truth, every change proven.
Author-email: Wherefore <hello@wherefore.build>
License-Expression: Apache-2.0
Project-URL: Homepage, https://wherefore.build
Project-URL: Repository, https://github.com/wherefore-build/wherefore
Keywords: build,documentation,single source of truth,ci,agents
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: Console
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: pictures
Requires-Dist: pillow; extra == "pictures"
Requires-Dist: numpy; extra == "pictures"
Provides-Extra: xlsx
Requires-Dist: openpyxl; extra == "xlsx"
Dynamic: license-file

<!-- Generated by corpus/readme.py from docs/README.template.md, src/wherefore/commands.json, features.json and principles.json. Edit those, not this. -->
# Wherefore

**Your company, compiled.**

Code has one source of truth: change it once, and everything built from it
follows. Everything else a company makes - the website, the docs, the pricing
page, the app's own words - is a copy of a copy, kept by hand, and it drifts.

Wherefore gives everything else what code has. Say each fact once. Generate
every asset from it. Anything left stale stops the change before it ships. AI
writes the rules; the build never improvises.

## A hardware company, compiled from one spec file

Wherefore was built alongside Chaotic Pendulums, a small hardware company
started to test the idea on something with more surface area than software. If
one source can hold machined parts, physics, suppliers and a storefront, it can
hold your app, website and docs. [How it is built](https://wherefore.build/#case).

## What it does

- **Scan** (since 0.3.0): where each stated value appears, and where the copies disagree; needs no setup. Given two places - a site and an app - what both state, and where they differ. `wherefore scan PATH|URL ...`
- **Start a corpus** (since 0.1.0): write a wherefore.json that declares nothing yet. `wherefore init [DIR]`
- **The gate** (since 0.1.0): every tracked file classified, every generated one current; puts the tree back unless --keep. `wherefore gate [--keep]`, `wherefore gate --restamp GROUP`
- **The build** (since 0.1.0): the roll: every generator - a Python script or any command - twice, compared with what is committed, and the results left in place. `wherefore build`, `wherefore list`
- **What builds what** (since 0.7.0): what builds what: run every generator once, trace what each reads and writes, and draw it as one self-contained page (and JSON) - changing nothing. `wherefore graph [--html PATH] [--json PATH|-] [--theme CSS ...] [--home URL [WORDS]]`
- **Proofs** (since 0.1.0): run the client's proofs, one at a time, in place. `wherefore prove [SCRIPT ...]`
- **Retired facts** (since 0.1.0): nothing a person reads still claims a retired value or phrase. `wherefore check retired`
- **Reach** (since 0.1.0): every fact, moved one at a time, reaches what it should. `wherefore check reach`
- **Claims** (since 0.1.0): every claim says only what its rule allows. `wherefore check claims`
- **Derived from elsewhere** (since 0.5.0): every copy taken from elsewhere still matches where it was taken from, read there now. `wherefore check upstream`
- **A page you publish but cannot build** (since 0.17.0): every page you publish but cannot build - a site on a hosted CMS - still states the source's facts, read live; a copy held by reading until it can be built. `wherefore check published`
- **One palette** (since 0.10.0): every colour anywhere is one the brand's source holds, or the file says, with why, whose colours they are. `wherefore check palette`
- **The pre-push hook** (since 0.1.0): a pre-push hook: no push leaves the corpus stale. `wherefore hook install`, `wherefore hook pre-push`
- **The skill, for Claude Code and Codex** (since 0.2.0): teaches your coding agent the rules, and starts a corpus with you: one fact, end to end. One skill, written where each agent reads it, and held to the release
- **Tell us** (since 0.12.0): feedback for the engine's makers - a bug, a question or a request, one topic each - with a title and the words, the release, the corpus's shape and the output given, nothing private; opened as an issue, or shown, or a link for the person to send. `wherefore report --title TITLE WORDS ... [--from FILE] [--show | --link]`
- **Releases that reach every client** (since 0.8.0): when the engine ships, every repository that pins it gets a pull request moving its pin, opened by the release itself, and the client's checks say what it still has to describe before it can build
- **Scan two repositories at once** (since 0.13.0): point the scan at your site and your app together: every place is tagged with where it came from, and the scan says what both state and where the two disagree - the drift between teams, with nothing installed
- **The scan says what it read** (since 0.16.0): beside the result, what each place contributed - how many files of each kind, and the kinds seen and not read; an app's own words, read out of its source; a table set apart from the stale copies; and the colours a site states, with the ones within a shade of each other, before any brand is declared

## The principles it enforces

1. **A fact exists in exactly one place.** Everything else is generated from it or checked against it.
2. **The build is deterministic.** Nothing in the build path calls a model.
3. **Fail loudly.** A change the build cannot handle stops it; nothing improvises.
4. **A check is not trusted until it has been shown to fail.**
5. **Sources versus outputs.** Every tracked file is *generated*, *authored* or *captured*. Generated files are never hand-edited, and a capture is stamped with what it was made from.

## Install

```
pip install wherefore-build       # Python 3.10+, standard library only
uv tool install wherefore-build   # or, as a command of its own
pipx install wherefore-build      # the same, with pipx
pip install 'wherefore-build[pictures,xlsx]'  # for picture and workbook comparison
```

It needs Python 3.10 or later and nothing else. Your project can be in any
language: Wherefore reads and checks files, whatever made them. With no Python
on the machine, `uv tool install` fetches one. A generator is a Python script
by default, or any command - a Node build, a shell script, a CAD export -
declared with `run` and held exactly as strictly.

The distribution is `wherefore-build`, because `wherefore` on PyPI is another
project's. What you import and what you type are `wherefore`.

## Use

```
pip install -e .                 # from a checkout of this repository
pip install -e '.[pictures,xlsx]' # with picture and workbook comparison

wherefore scan PATH|URL ...                                                           # where each stated value appears, and where the copies disagree; needs no setup. Given two places - a site and an app - what both state, and where they differ
wherefore init [DIR]                                                                  # write a wherefore.json that declares nothing yet
wherefore gate [--keep]                                                               # every tracked file classified, every generated one current; puts the tree back unless --keep
wherefore gate --restamp GROUP                                                        # record a re-made capture against its sources
wherefore build                                                                       # the roll: every generator - a Python script or any command - twice, compared with what is committed, and the results left in place
wherefore list                                                                        # run every generator once and say what each wrote
wherefore graph [--html PATH] [--json PATH|-] [--theme CSS ...] [--home URL [WORDS]]  # what builds what: run every generator once, trace what each reads and writes, and draw it as one self-contained page (and JSON) - changing nothing
wherefore prove [SCRIPT ...]                                                          # run the client's proofs, one at a time, in place
wherefore check retired                                                               # nothing a person reads still claims a retired value or phrase
wherefore check reach                                                                 # every fact, moved one at a time, reaches what it should
wherefore check claims                                                                # every claim says only what its rule allows
wherefore check upstream                                                              # every copy taken from elsewhere still matches where it was taken from, read there now
wherefore check palette                                                               # every colour anywhere is one the brand's source holds, or the file says, with why, whose colours they are
wherefore check published                                                             # every page you publish but cannot build - a site on a hosted CMS - still states the source's facts, read live; a copy held by reading until it can be built
wherefore hook install                                                                # a pre-push hook: no push leaves the corpus stale
wherefore hook pre-push                                                               # what the installed hook runs before a push; not for typing
wherefore report --title TITLE WORDS ... [--from FILE] [--show | --link]              # feedback for the engine's makers - a bug, a question or a request, one topic each - with a title and the words, the release, the corpus's shape and the output given, nothing private; opened as an issue, or shown, or a link for the person to send
```

**See what builds what.** `wherefore graph` runs every generator once, records
what each reads and writes, and draws the chain as one self-contained page:
sources, the scripts that read them, and everything they make - choose any file
to see where it comes from, or any source to see what changes with it. It puts
the tree back as it found it.

**Start with a scan.** `wherefore scan` needs no setup and no `wherefore.json`:
point it at a built site, a docs folder or a live address, and it reports every
value the company states more than one way - "start your {} day free trial", 14
in three places and 30 in one. Each is a fact to say once, in a source, and
build every copy from; the rest of Wherefore is how.

A client describes its corpus in `wherefore.json`: its sources, its generators
in order, its inventory of authored and captured files, and every exception to
byte-identity. Every exemption carries a `why`, and the engine refuses an entry
that has none. `tests/fixture/` is a complete, fictional example.

A client that configures the engine in Python instead, in the scripts its
proofs plant faults into, names those scripts in `entry`, and each command runs
the client's own script exactly as its CI does. The engine refuses a command
that is handed over and configured in `wherefore.json` as well, because that is
one fact in two places. Chaotic Pendulums is that kind of client.

## This repository

| path | what |
|---|---|
| `src/wherefore/` | the engine |
| `tests/fixture/` | Fernhollow Kettles, a fictional company the engine proves itself against |
| `proofs/` | the engine's proofs: each breaks the fixture one way and requires the right failure, in the right words |
| `tests/` | unit tests, and `test_phase5.py`: the fixture compiled from its sources alone |
| `tools/moved/` | the exact edits that turned each pendulum original into an engine module; `verify.py` re-runs them |
| `src/wherefore/skills/wherefore/` | the skill, shipped in the package: how a coding agent works in a corpus (`SKILL.md`) and starts one (`start.md`). A corpus's own copies are generated from the release it pins, by the `wherefore.skill` generator `wherefore init` declares: `.claude/skills/wherefore/` for Claude Code and `.agents/skills/wherefore/` for Codex, the same files in the open Agent Skills format |
| `CHANGELOG.md` | every release, newest first; a client upgrades only by moving its pin |
| `src/wherefore/releases.json` | every release again, as data - version, date, a title, a sentence and a picture of it working - for the company's changelog page; `tests/test_releases.py` holds it to `CHANGELOG.md` and runs the newest picture again |
| `corpus/`, `wherefore.json` | this repository as a client of its own engine: the README's generator, the corpus's checks and their proofs |
| `docs/README.template.md` | the README's text; the README is generated from it, `src/wherefore/commands.json` and `src/wherefore/principles.json` |
| `requirements-engine.txt` | the previous release, which judges this repository's own corpus |
| `LICENSE` | Apache-2.0 |
| `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md` | how to work on the engine and contribute to it, how everyone taking part behaves, and how to report a vulnerability |
| `PUBLISHING.md` | how a release reaches PyPI, and what this repository's history leaves out |

```
python3 -m unittest discover tests
for p in proofs/*_proof.py; do python3 "$p" || exit 1; done
```

## Licence

Apache-2.0 (`LICENSE`). The package is published as `wherefore-build`; what you
import and what you type are `wherefore`.
