Files
craft-ai-integrations/docs/LAYOUT.md
T
Jeremy 2d80bb44a6 Phase 2e v2 and v3: provider-grouped model picker and the in-app missing-model popup
AiClient::picker returns a tool's models grouped by provider (only models able
to do the tool; providers with no key, switched off or not set up are shown
greyed with a way to fix them; a choice that stopped working says why).
ToolDesk::missing_model returns why a tool cannot run plus that picker, and a
choice binds for every app through ToolDesk::choose. SetupOption and
PickerGroup carry a local model's download size. craft-ai-egui has a neutral
model_picker and missing_model_popup, and a sample-data demo window.

Fixes: ToolDesk::choose now checks the chosen model on its own (it resolved for
the calling app, so an app's own working choice could mask an invalid suite
default); a stale ai-client ComfyUI test now serves a real PNG header.
Mutation groups v2 (27) and v3 (15), none surviving.
2026-10-13 15:27:25 +01:00

3.4 KiB

Layout: what lives where

This repository is the shared AI layer for the Craft apps: one connection, set up once, used by every app that has the tool. It owns connections, models, the tool to model binding, the picker data, consent and jobs. It does not own any app's interface. Each app decides how a tool looks (a prompt bar, a one-click button, a click on the image), in its own repository.

In this repository

Group Crates Owns
Core ai-model, ai-native, ai-client, ai-features The data model and provider trait (wasm-safe), secret stores, the shared store and its location, history and consent files, the app-facing client and tool desk, the tool catalogue and setup options.
Adapters ai-openai, ai-bfl, ai-vertex, ai-artcraft, ai-seedance, ai-comfyui, ai-sam3 One crate per provider API shape. Each is registered in ai-client's ProviderFactory.
Local runtime ai-comfy-env, ai-media Finding an existing ComfyUI, model sources and checksummed downloads, node packs, and durable media transfer.
Widgets ai-egui Theme-neutral egui widgets (status, consent, progress, connection panel, history, model picker) for apps that have no chrome of their own.

Crates keep the flat crates/ folder on purpose. PhotoCraft and the launcher reach into it by path today, so moving a crate breaks their builds.

docs/design/ holds designs (u2). docs/research/ holds the audits and the deliberate-bug scripts with their saved results; everything a script saves goes through docs/research/sam3-headless/scrub.py.

Not in this repository

What Where it goes
PhotoCraft's Select subject panel, Generate bar, ai_cmds, hover session storytold/photocraft, through its own PR and its maintainers
The launcher's Set up AI window, History page and ports storytold/craft-launcher
LightCraft's, EffectCraft's and any other app's adapter That app's repository
Anything that draws a toolbar or prompt bar The app. The shared crates never do.

The shared code knows an app only as an AppId string and as data in the catalogue's uses list. If a change here needs to name an app's behaviour, it belongs in the app.

How an app uses this

  1. Declare a role with the tool's id (the catalogue's Feature::role()), for example select-subject. Do not invent an id of your own.
  2. Call AiClient::status to grey the tool out, or to say that a model is needed. Never report a tool with no model as broken.
  3. Depend on a pinned git revision (a tag on main), not a path. Path dependencies are for local work only and must go before an app PR.
  4. A person's choice made for the whole suite is ToolDesk::choose (the default every app reads). AiClient::bind is that one app's own override.

Branches

  • main is a state that builds and passes its tests. Apps pin tags on it.
  • Work happens on short-lived branches off main and returns by pull request. A merged branch is deleted, local and remote.
  • Review that matters happens at the boundaries: the shared contract in craft-libs, and each app in its own repository.

Rules that apply to every change

Test first. A deliberate-bug check for safety rules, with no survivor ignored. Cargo targeted with -p, one process at a time, -j 8; no workspace-wide builds. Files under 500 lines. Nothing runs against a real provider, download or ComfyUI without an explicit go. Say plainly what was run and what was not.