What Layer Types Does HKUDS/CLI-Anything Support and How Are They Mapped to Sketch Primitives
HKUDS/CLI-Anything supports seven Krita layer types—paintlayer, grouplayer, vectorlayer, filterlayer, filllayer, clonelayer, and filelayer—each conceptually mapped to a corresponding Sketch primitive such as Bitmap, Group, Vector Shape, Effect, Fill, Clone, and Linked Image.
The CLI-Anything project implements a Krita-focused "project" model that tracks canvas state and layer hierarchies in a JSON file. Understanding what layer types HKUDS/CLI-Anything supports and their Sketch primitive mappings is essential for developers building cross-platform design workflows or planning future export functionality.
Supported Layer Types in krita/core/project.py
The authoritative list of valid layer types is defined as the VALID_LAYER_TYPES constant in krita/core/project.py (lines 18–26). This constant constrains all layer creation operations throughout the codebase.
# From krita/core/project.py
VALID_LAYER_TYPES = {
"paintlayer",
"grouplayer",
"vectorlayer",
"filterlayer",
"filllayer",
"clonelayer",
"filelayer"
}
Each type serves a distinct purpose in Krita's composition model and carries a conceptual equivalent in Sketch's primitive taxonomy.
Complete Layer Type to Sketch Primitive Mapping
| Krita Layer Type | Core Purpose | Sketch Primitive Equivalent |
|---|---|---|
paintlayer |
Standard raster layer holding pixel data | Bitmap — a raster image primitive |
grouplayer |
Container for hierarchical layer organization | Group — a folder containing other primitives |
vectorlayer |
SVG-like path and shape storage | Vector Shape — scalable geometry primitive |
filterlayer |
Filter stack without embedded pixels | Effect — non-destructive filter applied to targets |
filllayer |
Solid-color fill with optional masking | Fill — uniform color region primitive |
clonelayer |
Reference to another layer's content | Clone — data reference to another primitive |
filelayer |
External image file linkage | Linked Image — external raster resource reference |
These mappings are conceptual alignments rather than active code transformations. The CLI-Anything harness does not currently embed a Sketch exporter, but the layer taxonomy is deliberately designed to enable straightforward translation should Sketch export functionality be added.
Creating Layers via the CLI Interface
Layer creation flows through krita/krita_cli.py, the Click-based entry point that parses command-line arguments and forwards them to add_layer() in the core project module.
Add a Paintlayer
cli_anything krita layer add Sketch --type paintlayer --opacity 200
This creates a standard raster layer named "Sketch" with 78% opacity (Krita uses 0–255 scale).
Add a Vectorlayer
cli_anything krita layer add Icons --type vectorlayer
Creates a vector path layer suitable for icon assets that would map to Sketch's Vector Shape primitive.
Create a Hierarchical Group
cli_anything krita layer add Assets --type grouplayer
cli_anything krita layer add Background --type paintlayer
cli_anything krita layer add Foreground --type paintlayer
The grouplayer acts as a structural container—equivalent to a Sketch Group—organizing child layers.
Inspect Layer State
cli_anything krita layer list
Enumerates all layers with their types, verifying the internal project state against VALID_LAYER_TYPES.
Core Implementation Architecture
The layer type system spans four critical files:
krita/core/project.py— DefinesVALID_LAYER_TYPES, the project JSON schema, and core APIs includingadd_layer()that enforce type validationkrita/krita_cli.py— Click interface (lines 229–241) parsing--type,--opacity, and other flags before core delegationkrita/tests/test_core.py— Unit tests exercising each supported layer type and verifying mapping correctnesskrita/tests/test_full_e2e.py— End-to-end workflow tests including "Sketch" paintlayer and "Group" layer creation
The validation logic in add_layer() rejects any --type value absent from VALID_LAYER_TYPES, ensuring project integrity.
Why Sketch Primitive Alignment Matters
The HKUDS/CLI-Anything layer taxonomy anticipates future export pipelines. By aligning Krita's specialized layer model with Sketch's universal primitives:
- Bitmap handles Krita's pixel-centric
paintlayerandfilelayer - Group preserves
grouplayerhierarchy without structural loss - Vector Shape maintains
vectorlayerscalability - Effect captures
filterlayer's non-destructive semantics - Fill transfers
filllayercolor regions - Clone represents
clonelayerreference semantics
This design choice decouples the CLI harness from any single destination format while enabling clean extension to Sketch, Figma, or other design tool exporters.
Summary
- Seven layer types are supported:
paintlayer,grouplayer,vectorlayer,filterlayer,filllayer,clonelayer,filelayer VALID_LAYER_TYPESinkrita/core/project.pyserves as the authoritative constraint- Conceptual mappings to Sketch primitives enable future export functionality without architectural changes
- CLI commands route through
krita/krita_cli.pyto coreadd_layer()implementation - Type validation occurs at layer creation time, preventing invalid project states
Frequently Asked Questions
How does CLI-Anything validate layer types?
The add_layer() method in krita/core/project.py checks the --type argument against the VALID_LAYER_TYPES set. Invalid types trigger immediate rejection before any project file modification occurs.
Can I create custom layer types beyond the seven supported?
No. The VALID_LAYER_TYPES constant is fixed in the current implementation. Extending support would require modifying this constant and potentially adding corresponding Sketch primitive mappings.
Is there an active Sketch exporter in CLI-Anything?
No. The Sketch primitive mappings are conceptual preparation for future export functionality. The current codebase focuses on Krita project manipulation with forward-compatible layer taxonomy design.
Where are layer opacity and other attributes stored?
Layer metadata including opacity (0–255 scale), visible state, and name are serialized to the project JSON file, as implemented in krita/core/project.py and exercised through krita/krita_cli.py argument parsing.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →