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.

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

v0.4.0 — the core is real, and the gate now reports honestly about itself. SDXL conditioning is assembled in code. A local 5090 generate() has been run. One Cloud recipe has been run live.

  • 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.
  • Pre-1.0 deliberately, and a test enforces it. Promotion should follow evidence, not a version bump.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prompt_crafter-0.4.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prompt_crafter-0.4.0-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file prompt_crafter-0.4.0.tar.gz.

File metadata

  • Download URL: prompt_crafter-0.4.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prompt_crafter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7b065d28f9b5ac12879113d84b511b3196ef0e142c8e66b3bfe692d594dbd2eb
MD5 2c59f7b1a554c9cff0ebc1af5eb670e1
BLAKE2b-256 566053f503a9982a696b2b90bb7955aeeafea8af6428bbe8c211ec3c95705d0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_crafter-0.4.0.tar.gz:

Publisher: release.yml on mcp-tool-shop-org/prompt-craft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prompt_crafter-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: prompt_crafter-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prompt_crafter-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b3772b439801d416c767cdf89167183add9ae89ef7ce6ab7578e825c775d648
MD5 5ff18540582734344c76f9b3f54bacfa
BLAKE2b-256 05bfa85d40674ebca7f21a72d8e3e728df6b93a5878d8fce62a18f1295a8ac86

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_crafter-0.4.0-py3-none-any.whl:

Publisher: release.yml on mcp-tool-shop-org/prompt-craft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page