net-art 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/net-art/SKILL.md +118 -0
- package/README.md +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Net-art
|
|
3
|
+
description: Use the Net-art pixel-art CLI or live server to generate, inspect, atomically edit, and export canonical 8x8, 16x16, or 32x32 pixel art. Produce high-quality pixel art with clear silhouettes, limited coherent palettes, intentional shading, and readback verification.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Net-art for AI agents
|
|
7
|
+
|
|
8
|
+
Use this skill when driving Net-art, producing or fixing pixel art, or verifying agent-visible canvas state. Net-art has exactly three engine tools: `write_pixels`, `read_pixels`, `edit_pixels`. PNG export is separate, not a fourth engine tool. No MCP, layers, animation, non-square canvases, cloud service, or hidden state.
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
From a Net-art repo checkout, run `npm install`, `npm run build`, then `node dist/cli/pixelart.js ...`. From an installed package, use `pixelart ...`. CLI output is JSON on stdout; do not require a TTY. Stable errors are `{ "ok": false, "error": { "code", "message", "field?" } }`. Exit codes: `0` success, `1` validation, `2` revision conflict, `3` IO, `4` not found/server. JSON input can be a file path or `-` for stdin.
|
|
13
|
+
|
|
14
|
+
Default project is `pixelart.json`. `write_pixels`, `read_pixels`, and `edit_pixels` accept `--project <path>`. Agent shells and humans share the same canonical state. Offline mode edits the file; `pixelart serve --project pixelart.json --port 4173` starts one local writer. With `--server http://127.0.0.1:4173`, send commands through that server. Pick one writer per project; do not edit the file directly while serving.
|
|
15
|
+
|
|
16
|
+
## Canonical state
|
|
17
|
+
|
|
18
|
+
- `size` is exactly `8`, `16`, or `32`; canvas is square.
|
|
19
|
+
- `pixels` is a flat row-major array length `size * size`; `(x,y) -> y*size + x`.
|
|
20
|
+
- Colors output as lowercase `#rrggbbaa`; transparent is `#00000000`.
|
|
21
|
+
- Accepted input colors include `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `"transparent"`, and `null`; canonical output is always `#rrggbbaa`.
|
|
22
|
+
- `name` is optional display name. `palette` is optional; pixels are truth. If `palette` is omitted, it is derived in first-appearance order. `revision` starts at `0`; increments only on canonical change; no-op writes/edits do not bump it; callers cannot set or reset `revision`.
|
|
23
|
+
- Successful reads return `ok`, `revision`, `size`, `name`, `pixels`, `palette`, `updatedAt`. `edit_pixels` also returns `applied` and `changed_pixels: [{x,y,from,to}]`.
|
|
24
|
+
|
|
25
|
+
## `write_pixels`
|
|
26
|
+
|
|
27
|
+
Create or overwrite the whole canvas in one batch. Never emit individual per-pixel writes. Supply every pixel; no partial update. Full batch is required before reading back.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pixelart write_pixels \
|
|
31
|
+
--project pixelart.json \
|
|
32
|
+
--size 8 \
|
|
33
|
+
--pixels pixels.json \
|
|
34
|
+
[--palette palette.json] \
|
|
35
|
+
[--name sprite] \
|
|
36
|
+
[--server http://127.0.0.1:4173]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`pixels.json` is `["#00000000", "#ff0000ff", ...]` length `size*size`. `pixels` may be `-` for stdin. Output includes canonical snapshot. `write_pixels` can overwrite `size` only with a complete matching `pixels` array.
|
|
40
|
+
|
|
41
|
+
## `read_pixels`
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pixelart read_pixels --project pixelart.json
|
|
45
|
+
pixelart read_pixels --server http://127.0.0.1:4173
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
No mutation. Use `revision` before `edit_pixels`. Verify `ok`, `size`, full `pixels`, `palette`, and canonical colors; do not assume generation succeeded.
|
|
49
|
+
|
|
50
|
+
## `edit_pixels`
|
|
51
|
+
|
|
52
|
+
Atomic ordered edit; validate all; no partial mutation. Prefer targeted edits for mistakes instead of rewriting the whole canvas.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pixelart edit_pixels \
|
|
56
|
+
--project pixelart.json \
|
|
57
|
+
--ops ops.json \
|
|
58
|
+
[--base-revision 3] \
|
|
59
|
+
[--server http://127.0.0.1:4173]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`ops.json` is `{ "base_revision": 3, "ops": [...] }` or a bare array. `base_revision` may be in file or `--base-revision`. If present it must equal current `revision`; mismatch returns `revision_conflict`, exit `2`, no mutation. If omitted, last-write-wins. Retry safe pattern: `read_pixels` -> recompute -> `edit_pixels` with `base_revision`.
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"base_revision": 3,
|
|
67
|
+
"ops": [
|
|
68
|
+
{ "type": "set", "x": 3, "y": 3, "color": "#00ff00ff" },
|
|
69
|
+
{ "type": "rect", "x": 0, "y": 0, "w": 8, "h": 1, "color": "#ffffffff" },
|
|
70
|
+
{ "type": "fill", "x": 4, "y": 4, "color": "#ff0000ff" },
|
|
71
|
+
{ "type": "clear" }
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `set`: integer in-bounds `x,y`; `color` `"transparent"`/`null` erases.
|
|
77
|
+
- `rect`: integer `x,y,w,h`, `w>=1`, `h>=1`; clipped to canvas; filled `color`.
|
|
78
|
+
- `fill`: 4-neighbor flood fill same-color region from `x,y`.
|
|
79
|
+
- `clear`: all transparent; size retained.
|
|
80
|
+
Ops are ordered; invalid op rejects entire edit. No extra ops. Human UI edits use `edit_pixels` with `base_revision`; undo/redo are local UI, not engine tools.
|
|
81
|
+
|
|
82
|
+
## PNG export
|
|
83
|
+
|
|
84
|
+
PNG is not a fourth tool. `pixelart export --project pixelart.json --out art.png --scale 16`. `scale` is positive integer; no anti-aliasing; transparency preserved; output size `size*scale`. Server `GET /api/export.png?scale=16`. Web UI exports PNG. Verify signature/dimensions if needed; do not claim visual inspection without seeing pixels.
|
|
85
|
+
|
|
86
|
+
## Live server / web UI
|
|
87
|
+
|
|
88
|
+
`pixelart serve --project pixelart.json --port 4173 --host 127.0.0.1`. APIs: `GET /api/read_pixels`, `POST /api/write_pixels`, `POST /api/edit_pixels`, `GET /api/export.png`, `GET /api/health`. WebSocket `/ws` sends `{type:"hello",...}` then `{type:"state",...}`; one broadcast per mutation. Web UI is vanilla canvas; no extra engine tools.
|
|
89
|
+
|
|
90
|
+
## Agent workflow for high-quality pixel art
|
|
91
|
+
|
|
92
|
+
1. **Brief.** Choose `size` `8|16|32`, square sprite/icon/tile/scene, subject, viewpoint, pose, background transparent vs filled, light direction, outline policy, symmetry, palette size, target scale, PNG output. Ask only if ambiguity changes work; otherwise choose sensible defaults. `8x8` = tiny symbol; `16x16` = readable sprite; `32x32` = detailed sprite with restraint.
|
|
93
|
+
2. **Plan silhouette first.** Ensure readable silhouette at `1x`; no noisy stray pixels; cluster shapes; align intentionally; use symmetry where it serves subject; keep simple negative space. Do not anti-alias canvas pixels. Canvas `image-rendering:pixelated`.
|
|
94
|
+
3. **Plan palette.** Limited coherent palette. `8x8` usually 2-4 colors; `16x16` 4-8; `32x32` still limited. Pick transparent `#00000000`, outline, base, shadow, highlight, one accent. Use harmonious ramps; shadows cooler/darker, highlights warmer/lighter as appropriate; avoid pure black/white unless intentional. `palette` optional but no unlisted accidental colors. Keep transparency separate from dark outline.
|
|
95
|
+
4. **Draw in one full `write_pixels`.** Produce complete row-major `size*size` canonical `#rrggbbaa`. No per-pixel calls. Simple art may have few colors; do not fill every pixel accidentally. Use `#00000000` for transparent.
|
|
96
|
+
5. **Construct deliberately.** Use `fill` for contiguous regions, `rect` for clean spans, `set` for details. No random dithering on `8x8`; use sparse intentional dithering on `16/32` only. Keep outlines consistent; avoid isolated shading; shade clusters; no AA; no half-alpha unless purposeful; preserve canonical color independence from chrome.
|
|
97
|
+
6. **Read back.** `read_pixels`; verify `ok`, `size`, length, canonical lowercase colors, no unintended palette drift, `revision`, changed pixels. Compare to intended composition.
|
|
98
|
+
7. **Fix mistakes atomically.** `edit_pixels` targeted `set`/`rect`/`fill`/`clear`, with `base_revision` from read. Do not claim success before readback. On `revision_conflict`, re-read and recompute. On validation, no partial mutation.
|
|
99
|
+
8. **Verify output.** Re-read final state; export PNG integer scale; check PNG signature/dimensions `size*scale`; no AA; transparency. Report what was generated/checked, not visual claims without evidence.
|
|
100
|
+
9. **Persist safely.** Project JSON atomic; corrupt project rejected, not silently reset. No secrets in project.
|
|
101
|
+
|
|
102
|
+
## Non-goals
|
|
103
|
+
|
|
104
|
+
No AI generation inside Net-art; no MCP; no auth/cloud; no multi-user CRDT; no layers/animation; no non-square; no `swap_color`, `shift`, `flip`, `rotate`, `set_palette`; no engine undo; no `idempotency_key`; no GIF/sprite sheet; no `region` reads.
|
|
105
|
+
|
|
106
|
+
## Minimal reliable pattern
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 1. full batch
|
|
110
|
+
pixelart write_pixels --project pixelart.json --size 8 --pixels pixels.json --name sprite
|
|
111
|
+
# 2. read
|
|
112
|
+
pixelart read_pixels --project pixelart.json
|
|
113
|
+
# 3. targeted atomic fix with current revision
|
|
114
|
+
pixelart edit_pixels --project pixelart.json --ops ops.json --base-revision 1
|
|
115
|
+
# 4. verify
|
|
116
|
+
pixelart read_pixels --project pixelart.json
|
|
117
|
+
pixelart export --project pixelart.json --out sprite.png --scale 16
|
|
118
|
+
```
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Net-art v0.0.
|
|
1
|
+
# Net-art v0.0.2
|
|
2
2
|
|
|
3
3
|
Agent-native pixel art engine for extremely fast pixel art generation. One canonical canvas, one revision, three engine tools. A self-hosted webapp shows live agent work and lets a human edit manually. No cloud, no external service.
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "net-art",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Agent-native pixel art engine for extremely fast pixel art generation with a self-hosted live web UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"url": "https://github.com/beast-ofcourse/Net-art/issues"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
".opencode/skills/net-art/SKILL.md"
|
|
17
18
|
],
|
|
18
19
|
"bin": {
|
|
19
20
|
"pixelart": "dist/cli/pixelart.js"
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"@types/node": "^22.15.0",
|
|
41
42
|
"@types/pngjs": "^6.0.5",
|
|
42
43
|
"@types/ws": "^8.5.13",
|
|
44
|
+
"tsx": "^4.20.6",
|
|
43
45
|
"typescript": "^5.9.0",
|
|
44
|
-
"vitest": "^3.2.4"
|
|
45
|
-
"tsx": "^4.20.6"
|
|
46
|
+
"vitest": "^3.2.4"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": ">=22"
|