Skip to content

[Skill Upgrade]: creative/bg_remover — hardening to 0.2.0 #257

Description

@rosspeili

Skill ID

creative/bg_remover

Current manifest version

0.1.0

Proposed change

Follow-up upgrade to take creative/bg_remover from the solid v0.1.0 rembg wrapper (merged via #244) to a production-grade skill: same scope (still images, local-first), but tighter runtime behavior, clearer errors, better performance, and stronger test/docs coverage.

Baseline (current v0.1.0)

  • Lazy rembg + Pillow import, structured success / error_code envelope
  • Base64 + input_path / optional output_path, configurable model + alpha_matting
  • Mocked offline bundle tests; catalog + append-only instructions.md
  • Per-skill extra: skillware[creative_bg_remover]

Tightening gaps to address

Runtime / skill.py

  • Session reuse: Cache new_session(model) at class or module level (similar to novelty_extractor embedding cache) so repeated calls do not reload ONNX every execute.
  • Input validation before rembg: Explicit checks for missing file, empty file, unsupported/corrupt format — distinct error codes where helpful (e.g. FILE_NOT_FOUND, INVALID_INPUT) instead of generic PROCESSING_FAILED.
  • Size / sanity limits: Document and optionally enforce reasonable max dimensions or byte size to avoid OOM on host.
  • Path safety: Validate input_path / output_path (no directory traversal, parent dir exists or creatable for output).
  • Format normalization: Accept common inputs (JPEG, WebP) with clear behavior; document PNG-first output contract.
  • First-run UX: Optional structured hint in response or docs when model download occurs (without blocking v1 simplicity).

Cognition / instructions.md

  • Keep append-only skill context (no persona), see companion docs issue on instruction style.
  • Add any new error codes and session/first-run behavior after code changes.

Tests

  • Expand bundle tests for new error paths and session reuse (still mock rembg for CI).
  • Optional maintainer integration test under tests/skills/creative/ marked @pytest.mark.integration for real rembg (skipped in default CI).
  • Consider validate_params() usage examples if schema tightening lands.

Docs / examples

  • Runnable reference script (e.g. examples/bg_remover_demo.py) + examples/README.md row + agent_loops matrix update (replace (catalog page) where appropriate).
  • Full provider loop for at least one secondary provider if maintainers want parity with pdf_form_filler-class skills.

Manifest / packaging

  • Version bump (likely 0.2.0 if error codes or behavior change; patch if additive only).
  • Re-run python scripts/sync_extras.py if requirements change.
  • CHANGELOG under [Unreleased].

Non-goals (keep out of this upgrade unless explicitly scoped)

  • Video, batch folder processing, URL fetching inside the skill
  • Cloud SDK integration (S3/GCS/Azure/R2 remain host/agent responsibility)
  • Replacing rembg with a different engine

Acceptance criteria

  • Backward compatible defaults OR migration notes in catalog + CHANGELOG
  • pytest skills/creative/bg_remover/ and pytest tests/ pass
  • pytest tests/test_registry_docs.py passes
  • python scripts/sync_extras.py --check passes
  • Catalog + instructions updated for any new errors, limits, or performance notes
  • Maintainer can run one local PNG end-to-end with [creative_bg_remover] deps

Breaking change?

No — backward compatible

Likely touch points

  • manifest.yaml version bump
  • skill.py logic
  • instructions.md
  • test_skill.py
  • docs/skills/.md and catalog row
  • examples/*.py or examples/README.md

Metadata

Metadata

Labels

enhancementNew feature or request.skill upgradeEnhance an existing registry skill (not a new skill).

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions