Skip to content

waifu: split into libwaifu and libwaifu_modelmanager; CLI on their C APIs - #124

Merged
ling0322 merged 1 commit into
mainfrom
modelmanager-crate
Oct 15, 2026
Merged

ling0322 merged 1 commit into
mainfrom
modelmanager-crate

Conversation

@ling0322

Copy link
Copy Markdown
Owner

Splits the Rust side into two C libraries that share no code: libwaifu (waifu/), which runs a model given the path of its manifest, and libwaifu_modelmanager (waifu-modelmanager/), which owns the catalogue, fetching, config.toml and a model's default settings. The waifu command line is now its own crate, waifu-cli, statically linked against both and calling only their C APIs. Removes waifu-ffi and the cli/hub/engine features.

Layout

waifu/ libwaifu (cdylib + rlib) and include/waifu.h. waifu-ffi is folded in as src/c_api.rs.
waifu-modelmanager/ libwaifu_modelmanager (cdylib + rlib) and include/waifu_modelmanager.h. hub.rs, config.rs and suggested.rs moved here; yaml.rs is copied.
waifu-cli/ the waifu binary, one file, no dylibs at run time
waifu-tools/ the former waifu/examples and fetch_manifests, as binaries
waifu-app/swiftui, waifu-app/wpf the former macos/ and windows/

Neither library links the other: if one did, every extern "C" function of the one it linked would be exported from both, and a linker could bind an app's call to the wrong copy. Each header includes only system headers; the model manager's types carry its own prefix (WaifuModelManagerStatusCode, WAIFU_MODELMANAGER_OK, ...).

C API changes

  • WAIFU_ABI_VERSION is 2. waifu_engine_load_async and waifu_describe_json (renamed from waifu_modelmanager_describe_json) take a manifest path or "tones", not a published name.
  • waifu_describe_json says only what a request may hold: kind, image_keys/why_not, alignment, sampler, rate, styles, on_disk/bytes.
  • A draw runs the request's guidance and negative prompt as given. The engine used to substitute its own for a model it judged to take none.
  • New in libwaifu: waifu_devices_json.
  • New in libwaifu_modelmanager: waifu_modelmanager_manifest_path, _directory_json, _defaults_json.
  • Removed: waifu_set_bundled_manifests. The model manager reads bundled manifests and hands back their paths.

Apps

WaifuKit and the C# app adapt to the API and behave as before: load(name) fetches through the model manager and loads by path, and describeJSON merges describe with defaults. For every model kind, that merge was checked identical to the old waifu_describe_json. build-app.sh still bundles every manifest, through waifu-tools.

Also

  • waifu::text_normalizer, from indextts/normalize.rs, since CosyVoice3 uses it too.
  • IndexTTS's own docs (GPT, emotion, w2v-bert, codec, S2Mel, BigVGAN) merged into docs/indextts.md; the shared ones renamed audio_features.md and text_normalize.md.
  • CI tests waifu-modelmanager and waifu-cli and builds waifu-tools. CLAUDE.md gains a rule against changing the apps' behavior unasked.

Tests

Passing locally on macOS (Metal): unittest, waifu (391), waifu-modelmanager (61), waifu-cli (174), the waifu-tools build, and WaifuKit (9). The C# app compiles against a WPF SDK project on macOS.

Not run: model tests; a real draw or download through the CLI's screens; the Windows app; build-app.sh and the release workflow; the CLI's static link on Linux and Windows, which CI will be the first to build.

🤖 Generated with Claude Code

waifu is now libwaifu, a cdylib whose C API runs a model given the path of its
manifest. The new waifu-modelmanager crate is libwaifu_modelmanager: the
catalogue, fetching, config.toml and what a model's boxes start at. The two
share no code and no types, and each header stands alone.

- waifu-ffi and waifu-modelmanager's C API crate are folded into their crates
  (cdylib + rlib). hub.rs and config.rs moved to the model manager; yaml.rs is
  copied, since both read manifests.
- libwaifu: load and describe take a manifest path (ABI 2); describe says only
  what a request may hold; a draw runs the request as given. New
  waifu_devices_json.
- libwaifu_modelmanager: new manifest_path, directory_json and defaults_json,
  the last being the kind defaults and the manifest's suggested: block, which
  moved here from the engine.
- waifu-cli: the `waifu` binary, statically linked against both crates and
  calling nothing but their C APIs.
- waifu-tools: the old examples, as binaries.
- macOS and Windows apps move to waifu-app/swiftui and waifu-app/wpf and adapt
  to the API; they behave as before.
- IndexTTS's own docs merged into docs/indextts.md; the text normalizer moves
  to waifu::text_normalizer, shared with CosyVoice3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ling0322
ling0322 merged commit fec7836 into main Oct 15, 2026
0 of 3 checks passed
@ling0322
ling0322 deleted the modelmanager-crate branch October 24, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant