Skip to main content

prompt-crafter

Say what the picture must contain. Check that it does. Refuse when it doesn't.

A generative image pipeline will happily hand you a hero with the wrong face, the wrong palette and none of the faction's markings — and report success, because nothing looked. prompt-crafter replaces the opaque prose prompt with a typed contract of depictable claims, uses that same list twice — once to write the prompt, once to check the pixels — and blocks the asset when a required claim is not there.

The one idea: the contract's atom list is the same list used twice. Writing the prompt and checking the result read from one source, so the thing you asked for is the thing that gets verified. That is what closes the loop an opaque prompt leaves open.

Install

pip install prompt-crafter
pcraft --help

The distribution is prompt-crafter; the import package and the command are pcraft. Requires Python 3.11+. CI runs 3.11 and 3.13 on the core + [dev]. The [image] extra is not claimed on 3.11. The core's only runtime dependency is pydantic.

Model tiers are bring-your-own: the model-tier verifiers need t2v-metrics (PyPI) and ai-eyes-mcp (a separate mcp-tool-shop package), which no extra declares — no version has been integration-tested against this build, and pinning one would claim a compatibility nobody measured. pcraft doctor reports both under "model tier". The deterministic palette verifier needs neither — it reads PNGs with the stdlib, no Pillow required.

pcraft demo              # the whole loop end-to-end, no GPU, deterministic stubs
pcraft list              # contract ids in the store
pcraft validate          # resolve + compile the question DAG, no generate
pcraft gate <image>      # check an image against a contract
pcraft recipe            # emit the Cloud Kontext + fist-only Fill graph
pcraft replay <record>   # re-read a bound asset's provenance receipt

What a contract looks like

Not a prose prompt. A list of atomic, depictable, individually checkable claims:

  • must_have — a garment, a palette, a silhouette, a sigil. Each names which gate tier verifies it, a severity, and optionally a depends_on edge, so there is no point verifying the colour of an axe that is not there.
  • must_not — anti-constraints, verified as absence on the pixels. Not a negative prompt: negative prompts leave residual features and fall to paraphrase.
  • identity_ref — a reference plate. Identity is conditioning, not tokens. Anatomical text makes a diffusion model render a specimen; a reference image binds the specific face.

Contracts inherit — a character extends a faction — and inheritance is fail-closed: a child may raise a requirement, never relax or silently drop one it inherited.

The exit code is the point

exit meaning
0 the gate ran and every required atom passed
1 bad arguments or a malformed contract
2 it ran, and a required atom failed
3 it ran, and the result is unconfirmed — the human band
4 it could not run

The 2 / 4 split is the whole design. "I could not check" and "I checked and it is bad" are different facts. Merging them is why browsers soft-fail certificate revocation, and why monitoring standards have carried a distinct unknown verdict since the 1990s. Every gate transcript also reports how many required tiers actually executed, so a gate that quietly stopped checking cannot read as a pass.

The verifier is always a different model family from the generator, enforced by a guard that refuses to run otherwise. CLIPScore is not used as the gate metric — it behaves as a bag of concepts, blind to which attribute belongs to which object.

Honest status

v1.0.0 — the INTERFACES are stable. The pictures are not finished, and this document does not pretend otherwise.

A 1.0.0 here is a claim about the CLI, the import paths, the exit codes and the two on-disk formats — enumerated in STABILITY.md, along with what is deliberately excluded. It is not a claim that the plate lands in the pixels. The gaps below are real and they get better in minor releases; what stops moving is the surface you build against.

  • 338 tests passing (counted 2026-08-18), GPU-free and deterministic. The whole suite runs against a mock generator and verifier, which is what proves the plugin boundary holds.
  • Flux Fill inpaint is wired. method=reference writes the Cloud recipe (GATE_CLOUD_SUBMIT). ControlNet pose and IP-Adapter stay refused on Flux.
  • The eleven compound decision points in the core are mutation-tested — 20 of 21 mutants killed, and the survivor is named rather than hidden.
  • SDXL ControlNet OpenPose, IP-Adapter, LoRA, InstantID, and regional inpaint are wired and covered by fake-torch tests. InstantID and IP-Adapter cannot share one generate. Two IP-Adapter plates stay on one adapter (all images; scale is the strongest lock). Local generate() ran on the 5090 (2026-08-18, seed 169405236028824). The frame is orcish; grip, sigil, and bracer did not land. Flux refuses those identity methods.
  • pcraft recipe emits the Cloud Kontext stitch + left crop + fist-only Fill graph. A live Cloud submit (2026-08-18) produced a single-panel crop and kept the bracer.
  • Tier-2 is a real DSG expansion. Escalation is a contrastive checkpoint. A live GEPA compile ran 2026-08-18 on local Ollama hermes3:8b (600B was not up). Pinned sprite.synth.v1-gepa.json. The seed artifact is untouched. The per-asset loop still uses TemplateSynthesizer.
  • The identity sub-gate is not wired. Its thresholds have no holdout.
  • v1.0.0 is a claim about interfaces, not pictures. The CLI commands, the exit-code contract, the listed import paths, and both on-disk formats are semver-covered -- STABILITY.md in the repo names each one, and names what is excluded. The capability gaps above stay disclosed and close in minor releases.

Trust

No credentials are read, stored or transmitted. No telemetry — there is no opt-out because there is nothing to opt out of. The core imports no networking library at all; the optional extras reach a model host by their nature, and installing them is a choice. File operations are not sandboxed: --records-dir and --db write where you point them, deliberately, for a local-first tool.

Deliberate refusals carry a code, a message and a hint, and raise rather than assert — so -O cannot delete them, and the suite runs a second time under -O to prove it.


Documentation and handbook → · Source · Changelog

MIT

Metadata

Release files for prompt-crafter 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prompt-crafter 1.0.1
File Size Uploaded
prompt_crafter-1.0.1.tar.gz 2.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for prompt-crafter 1.0.1
File Interpreter ABI Platform
prompt_crafter-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.7 MB

Release files / prompt_crafter-1.0.1.tar.gz

Download URL prompt_crafter-1.0.1.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
21d979a6fa254127cae1488e9d79e7d068694d79a4814e1566a107cc862ce172
BLAKE2b-256 checksum
How to use checksums
aa5bc85b081f62265bdad5afd383c973c20fefa4da1fbc7975446eb699caff0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / prompt_crafter-1.0.1-py3-none-any.whl

Download URL prompt_crafter-1.0.1-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
386818e9a7c9d300ef421813eef91a7150849f63cf92ea9cab825e7a6c57b1da
BLAKE2b-256 checksum
How to use checksums
dbe6459c276d80b3c1f7a31d3ef1790f9b92bbb299134a02dfa63199768b0f81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page