Skip to main content
Glama

normalize_edge_runs

Merge lone one-pixel runs on diagonal pixel-art edges into neighboring runs to even out slope wander, reporting jagged-corner counts before and after while leaving spikes, notches, and intentional steps untouched.

Instructions

Even out the run lengths along a silhouette's diagonals, conservatively.

A hand-drawn diagonal is built from runs of consistent length: a 1:2 slope is two
pixels, two pixels, two pixels, held steady, and broken only on purpose. A generated
one wanders, runs of 3, 1, 2, 1, 4 where a person would have drawn 2, 2, 2, 2, and
that wander is the most recognisable tell in generated pixel art, ahead of both colour
and shading. `assess_sprite` already counts it as `jaggy_corners`, which on a boundary
stepping one way is exactly the number of steps; this is what to do about the count
when the wander is a lone short run. It is not a fix for every jagged-corner reading:
consecutive one-pixel runs are declined, so a sawtooth edge that steps out and back a
pixel at a time can fire that reading and leave this with nothing to merge.

What it changes is narrow on purpose: a run of **exactly one**, with a run of at least
two on either side, stepping the same way on both sides, by exactly one pixel each
time. That run is merged into whichever neighbour lies further out, which paints one
pixel in the colour of the pixel beside it. Everything else is left alone and counted
under `kept`, so a pass that declines to touch something says which rule stopped it:

* `diagonal`: the run sits next to another one-pixel run, so this is a 1:1 diagonal,
  already the most even edge there is;
* `feature`: the run is further out, or further in, than both its neighbours. That is a
  spike or a notch, a local extremum, and somebody drew it: a horn, a finger, a chip
  in the stone;
* `step`: the step either side is more than one pixel, so this is a change of slope;
* `thin`: the edge belongs to something thinner than `min_span`, where adding a pixel
  reshapes the feature instead of smoothing its edge;
* `no_gain`: the merge would not lower the jagged-corner count, measured over the four
  2x2 windows the one new pixel can change.

Because it only ever adds a pixel, and only ever a value the boundary already held
somewhere else, **the silhouette's extent cannot move and nothing can be eaten**. Both
are checked rather than promised: a plan whose bounding box differs from the
original's is refused and nothing is written.

Args:
    min_span: How thick the mass behind an edge has to be before its edge is treated
        as an edge, measured as the unbroken run of drawn pixels inward from the
        boundary. The default of 3 is the smallest value at which the added pixel is a
        minority of what it joins. Raise it to protect thin limbs; 2 is the floor.
    layer: The layer whose silhouette is read and written (default: top layer).
    frame: Target frame, 1-based.

Returns `jaggy_corners_before` and `jaggy_corners_after` every call, so the claim is in
the result rather than in this docstring, along with `runs_merged` and `by_side`. A
pass with nothing to merge is **refused**, and the refusal carries the tally above: a
silhouette this cannot improve is the normal case for art that was drawn by hand.

Two Aseprite launches, one to read the silhouette and one to paint: the decision about
which runs are stumbles is arithmetic over the whole shape, and the shape is only
knowable with the file open. The read ignores any active selection, because the
geometry is a fact about the whole silhouette, while the write honours it like every
other drawing tool. When the mask refuses some of the planned pixels, the after figure
is withheld rather than reported against a shape that was not painted.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "filename": "<filename>"
    },
    "name": "normalize_edge_runs"
  }
}

Input Schema

NameRequiredDescriptionDefault
frameNoDefault: 1.
layerNo
filenameYes
min_spanNoDefault: 3.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.11.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=false and openWorldHint=false; the description supplies far more — the narrow change rule, the fact it only ever adds a pixel so extent cannot move, the bounding-box self-check, the read/write asymmetry around selections, and the withholding of the after figure when the mask refuses pixels. This is an unusually full behavioral account for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded and the bulleted decline rules are scannable, but the prose occasionally expands beyond what an agent needs (e.g. the aside about wander being 'ahead of both colour and shading'). Dense for its length, yet nearly every clause carries operational content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a four-parameter mutation tool with no output schema, the description covers everything material: what changes, what is refused, the return keys (`jaggy_corners_before/after`, `runs_merged`, `by_side`), the two-launch cost, and selection-mask interaction. Nothing an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 50%, so the description must compensate, and it does: `min_span` gets a rationale for the default of 3, a floor of 2, and when to raise it; `layer` defaults to the top layer; `frame` is 1-based. This adds real meaning beyond the bare types and defaults in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource — 'Even out the run lengths along a silhouette's diagonals, conservatively' — then pins the exact scope (lone one-pixel runs) and explicitly contrasts it with `assess_sprite`, which counts the problem rather than fixing it. An agent can distinguish this from the diagnostic sibling without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to act and when not to: 'It is not a fix for every jagged-corner reading' and 'a sawtooth edge... can fire that reading and leave this with nothing to merge.' It routes the agent to `assess_sprite` for the count and enumerates the decline conditions, so the boundary of applicability is fully drawn.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools