feat(image): add auto recipe runner (MK-5 Layer 2) #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/image-auto-detect-MK-5"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements Layer 2 of MK-5:
monkey image auto <input> <output>. It classifies the input with the Layer 1 classifier (MK-6), loads the recipe for the resulting class, and applies an ordered chain of existing image filters. No new DSL, no new operators - the runner is a thin dispatcher over the same functions the CLI subcommands already call.Interface
monkey image auto <input> <output> [--class X] [--recipe-dir DIR]. With--classomitted the input is auto-detected;--classforces a class and skips detection. The chosen class and each step are reported on stderr, the final summary on stdout.A recipe is plain TOML, one table per step:
opis the kebab-case filter name,argsmirror that filter's flags, and any omitted arg falls back to the filter's own CLI default.Config resolution
Defaults ship embedded via
include_str!for all seven classes (unknownis a passthrough copy). Overrides are read from--recipe-dir DIR/<class>.tomlwhen given, else$XDG_CONFIG_HOME/monkey/recipes/<class>.toml(falling back to$HOME/.config/monkey/recipes/). This mirrors the existingclassify.tomloverride mechanism.Changes
src/image/recipe.rs: recipe schema, class -> recipe resolution, op dispatcher, arg-coercion helpers, tests.src/image/recipes/*.toml: seven embedded default recipes.src/image/classify.rs:ImageClass::from_label(inverse ofas_str) to parse--class.src/image/mod.rs:Autosubcommand variant + dispatch.README.md: newmonkey image autosection; updated the Layer 1 forward reference.Testing
just pre-commitgreen (fmt, clippy-D warnings, build, 66 tests). A unit test loads every embedded recipe and runs every named op end-to-end so a typo in a default recipe fails the suite. Manually verified in the builder image: auto-detect into acolor-photorecipe,--class binary-scanforcing, and a--recipe-diroverride each produced the expected steps and output.Closes MK-5 Layer 2. Layers 1 (classify, MK-6) done; Layer 3 (feedback log + tuner) remains.
🤖 Generated with Claude Code
Add `monkey image auto <input> <output>`: classifies the input via the Layer 1 classifier (or takes `--class` to force one), loads the matching class recipe, and applies an ordered list of existing image filters to the pixels. The runner is a thin dispatcher over the same filter functions the CLI already calls, so there is no new DSL or operator set. Recipes are TOML (`[[step]] op = "<filter>" args = {...}`); each omitted arg falls back to that filter's CLI default. Defaults ship embedded via `include_str!` for every class, with `unknown` as a passthrough copy. Users override a class by writing `recipes/<class>.toml` under `$XDG_CONFIG_HOME/monkey/` or by passing `--recipe-dir DIR`, mirroring the existing classify.toml override mechanism. Adds `ImageClass::from_label` (inverse of `as_str`) to parse `--class`, the recipe module with arg-coercion helpers and tests covering every embedded recipe end-to-end, and README docs for the new subcommand. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>