dsh-skill-deterministic-pixel-art 0.1.1 → 0.1.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/README.md +6 -6
- package/README.zh-CN.md +6 -6
- package/package.json +1 -1
- package/skill-manifest.json +5 -5
- package/skills/deterministic-pixel-art/references/workflows.md +4 -0
- package/skills/deterministic-pixel-art/scripts/pixelart/__init__.py +1 -1
- package/skills/deterministic-pixel-art/scripts/pixelart/cli.py +15 -9
- package/skills/deterministic-pixel-art/scripts/pixelart/edit.py +15 -6
- package/skills/deterministic-pixel-art/scripts/pixelart/metadata.py +12 -3
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ should return absolute file paths.
|
|
|
33
33
|
| `dsh-skill-deterministic-pixel-art` | npm package name |
|
|
34
34
|
| `deterministic-pixel-art` | Skill name to use in a conversation |
|
|
35
35
|
|
|
36
|
-
This directory targets bundle **0.1.
|
|
36
|
+
This directory targets bundle **0.1.2**, supporting DSH core and DSH Skill
|
|
37
37
|
**0.2.2-rc.1 through 0.2.2-rc.3**. Node must be **>=24.9.0** and Cordis
|
|
38
38
|
**~4.1.0**. Drawing requires Python **3.10+** and Pillow **>=10.4,<13**.
|
|
39
39
|
Earlier versions, future release candidates and stable releases are outside this
|
|
@@ -45,10 +45,10 @@ package in the profile used for chat. CLI users with an existing working profile
|
|
|
45
45
|
can replace `YOUR-PROFILE` with its non-`desktop` profile name:
|
|
46
46
|
|
|
47
47
|
```text
|
|
48
|
-
dsh plugin --profile YOUR-PROFILE add dsh-skill-deterministic-pixel-art@0.1.
|
|
48
|
+
dsh plugin --profile YOUR-PROFILE add dsh-skill-deterministic-pixel-art@0.1.2
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
If 0.1.
|
|
51
|
+
If 0.1.2 is absent from the registry, it has not been published yet. Build a local
|
|
52
52
|
candidate using the [instructions below](#build-a-local-package); the old 0.1.0
|
|
53
53
|
package declares support for rc.1 only. The npm CLI does not manage Electron's
|
|
54
54
|
reserved `desktop` profile; use the desktop's plugin interface or bundled command.
|
|
@@ -67,18 +67,18 @@ dsh --profile pixel-art --from-default-profile headless --help
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
This initializes the profile without a model call. Then choose **one** installation
|
|
70
|
-
method. When the official npm registry provides version **0.1.
|
|
70
|
+
method. When the official npm registry provides version **0.1.2**, use its exact
|
|
71
71
|
package version:
|
|
72
72
|
|
|
73
73
|
```text
|
|
74
|
-
dsh plugin --profile pixel-art add dsh-skill-deterministic-pixel-art@0.1.
|
|
74
|
+
dsh plugin --profile pixel-art add dsh-skill-deterministic-pixel-art@0.1.2
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
For a local candidate, build the archive using the instructions below and use its
|
|
78
78
|
absolute path instead; quote paths containing spaces:
|
|
79
79
|
|
|
80
80
|
```text
|
|
81
|
-
dsh plugin --profile pixel-art add "/absolute/path/to/dsh-skill-deterministic-pixel-art-0.1.
|
|
81
|
+
dsh plugin --profile pixel-art add "/absolute/path/to/dsh-skill-deterministic-pixel-art-0.1.2.tgz"
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
Both methods install into `pixel-art`; Desktop uses a separate profile.
|
package/README.zh-CN.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
| `dsh-skill-deterministic-pixel-art` | npm 安装包名 |
|
|
31
31
|
| `deterministic-pixel-art` | 对话中使用的 Skill 名称 |
|
|
32
32
|
|
|
33
|
-
本目录对应 bundle **0.1.
|
|
33
|
+
本目录对应 bundle **0.1.2**,支持 DSH core 与 DSH Skill
|
|
34
34
|
**0.2.2-rc.1 至 0.2.2-rc.3**。Node 要求 **>=24.9.0**,Cordis 为
|
|
35
35
|
**~4.1.0**;绘图需要 Python **3.10+**、Pillow **>=10.4,<13**。
|
|
36
36
|
更早版本、未来 rc 及正式版不在兼容声明内。桌面应用版本与内核版本不同,可用
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
已有正常配置的 CLI 用户,可将 `YOUR-PROFILE` 换成自己的非 `desktop` profile:
|
|
41
41
|
|
|
42
42
|
```text
|
|
43
|
-
dsh plugin --profile YOUR-PROFILE add dsh-skill-deterministic-pixel-art@0.1.
|
|
43
|
+
dsh plugin --profile YOUR-PROFILE add dsh-skill-deterministic-pixel-art@0.1.2
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
若 registry 尚无 0.1.
|
|
46
|
+
若 registry 尚无 0.1.2,说明该版本尚未发布;本地候选按文末的
|
|
47
47
|
[打包说明](#生成本地包)生成,不要将仅声明 rc.1 的旧 0.1.0 当作新版替代。
|
|
48
48
|
npm CLI 不管理 Electron 专用的 `desktop` profile;桌面使用其自身的插件入口
|
|
49
49
|
或内置命令。npm 安装无需等待市场收录。
|
|
@@ -60,16 +60,16 @@ dsh --profile pixel-art --from-default-profile headless --help
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
这条命令初始化配置,不调用模型。随后**选择一种**安装方式。官方 npm registry
|
|
63
|
-
提供 **0.1.
|
|
63
|
+
提供 **0.1.2** 时,使用精确包版本:
|
|
64
64
|
|
|
65
65
|
```text
|
|
66
|
-
dsh plugin --profile pixel-art add dsh-skill-deterministic-pixel-art@0.1.
|
|
66
|
+
dsh plugin --profile pixel-art add dsh-skill-deterministic-pixel-art@0.1.2
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
本地候选按文末说明生成归档,改用其绝对路径;含空格路径保留引号:
|
|
70
70
|
|
|
71
71
|
```text
|
|
72
|
-
dsh plugin --profile pixel-art add "/absolute/path/to/dsh-skill-deterministic-pixel-art-0.1.
|
|
72
|
+
dsh plugin --profile pixel-art add "/absolute/path/to/dsh-skill-deterministic-pixel-art-0.1.2.tgz"
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
两种方式都安装到 `pixel-art`;Desktop 使用独立的 profile。
|
package/package.json
CHANGED
package/skill-manifest.json
CHANGED
|
@@ -73,21 +73,21 @@
|
|
|
73
73
|
"references/sources.md": "72d8ef7cc656e9b632d6c35b92c431598cf32254c26cd97056c85286eedd646b",
|
|
74
74
|
"references/text-workflow.md": "7cd64f3235004d0b23e6e2d837a4b46569d4407d24a9ac99fe1fd32491e0ce20",
|
|
75
75
|
"references/ui.md": "fccea168e299771f55e8ce6794ee29895f6ec1f53d2cc7a443385f9f8039fe25",
|
|
76
|
-
"references/workflows.md": "
|
|
76
|
+
"references/workflows.md": "4be0b69e3f71c9450573e0fe6a4036ea4471f2721b0a8c60d46d2fdb55fa830e",
|
|
77
77
|
"requirements.txt": "41b54a6fb2918667ca47a61d73b522629d84490f3d78f0f20b21135faba10d35",
|
|
78
78
|
"scripts/pixel_art.py": "48e5bbd53e402b5e82b0ab16ea52e9d0bb166040a0bbcfd570b3198d7b56f17f",
|
|
79
|
-
"scripts/pixelart/__init__.py": "
|
|
79
|
+
"scripts/pixelart/__init__.py": "61f4a6629df4288f90f9aca9f37e7679cb0fbd502b8ca5f677ad3b0d74c13577",
|
|
80
80
|
"scripts/pixelart/__main__.py": "935a1c1166b0c1ea35a82256345000bf2c73ded718d77773bc27a71ecce28f7d",
|
|
81
81
|
"scripts/pixelart/analysis.py": "2d8b8c0d3edd9ec809202dcb83d5cc5a49cebe46583a0793d9689c117b3d3771",
|
|
82
82
|
"scripts/pixelart/assembly.py": "d83b77642a008142afa912d9deeacbcda069f3a66e62097c01d2e4d140f12dfe",
|
|
83
|
-
"scripts/pixelart/cli.py": "
|
|
83
|
+
"scripts/pixelart/cli.py": "8afbc527d18058a369deff7bfc74a1f52a7a317bda8e4ce11a307f626b01e458",
|
|
84
84
|
"scripts/pixelart/compat.py": "98aa940594f525dab4f58c91012f1dbb1f24615c36b7f317be5a433af81cf203",
|
|
85
85
|
"scripts/pixelart/context.py": "d15774a0f2bd076c1d5258a47d157b4d776d00fd4a934d89f6ecf12539c0acd1",
|
|
86
86
|
"scripts/pixelart/core.py": "7f4ee5643f5dbb03b57408ed5b75a4fe0d492e86a64e4fa9c9de2fb29b5cd7c7",
|
|
87
|
-
"scripts/pixelart/edit.py": "
|
|
87
|
+
"scripts/pixelart/edit.py": "eb13999e67a1c8483ab662f6117b4db2289f13b0b9dbc01c74f780b50e2a4681",
|
|
88
88
|
"scripts/pixelart/ingest.py": "781e3bd693f1cc408d4aed7eab0f07008602c2c375941b5cbd6749fff31c7bb4",
|
|
89
89
|
"scripts/pixelart/jsonio.py": "5da4f59c9c8deeba79fda0c8c12863097e12bcf360e68bbb280f7cac62e57b6f",
|
|
90
|
-
"scripts/pixelart/metadata.py": "
|
|
90
|
+
"scripts/pixelart/metadata.py": "afc784afb2549b591be5416ce444c6c0a8d1ab8563c291454c079f9eaade47d2",
|
|
91
91
|
"scripts/pixelart/output.py": "c3c17d615c388c6c2f65555b3a69ab38243e44830245371217c572a0fca193d0",
|
|
92
92
|
"scripts/pixelart/presets.py": "89b5fa58e1c14818a38918a1dc47875347c67f24e09df580e750e29a10312941",
|
|
93
93
|
"scripts/pixelart/review.py": "871be22819e6b44446c92935f03fc46a94efafa6b7cdb2801c359403de16cd4e",
|
|
@@ -21,6 +21,8 @@ Try `assets/workflows/atlas-before.png`, `atlas-before-layout.json` and `atlas-r
|
|
|
21
21
|
|
|
22
22
|
`replace-cell --image-out ... --metadata ...` writes the complete atlas block and a fresh `rgba_sha256`. A standalone cell render correctly has no atlas block; that does not describe the metadata produced by atlas replacement. No manual sidecar construction is needed.
|
|
23
23
|
|
|
24
|
+
Embedded layout records are limited to 256 KiB of serialized UTF-8, including JSON escapes for non-ASCII names. `render --embed-metadata` and `recolor` reject oversized records before publishing any outputs. Separate layout JSON files and in-memory layouts do not share this embedded-record limit. For a large layout, render without `--embed-metadata` and keep the `--metadata` sidecar; reduce or split the layout before using `recolor`, which always embeds a fresh record.
|
|
25
|
+
|
|
24
26
|
## Candidates without overwriting evidence
|
|
25
27
|
|
|
26
28
|
When exploring variants, give each a directory such as `candidates/v01/` containing its spec, PNG, fresh layout and optional review. Use `v02/` for another candidate; keep paths meaningful rather than repeatedly occupying a shared `final.*`. After selecting a result, write the delivery paths. This is a useful convention, not a requirement to produce alternatives for every small edit.
|
|
@@ -31,6 +33,8 @@ A later revision can use another candidate directory, or an explicit `--force` r
|
|
|
31
33
|
|
|
32
34
|
`verify` compares all decoded RGBA, including RGB under alpha zero. Repeat `--allow-region X Y W H` for multiple rectangles. `--allow-mask allowed.png` accepts nonzero L/1 intensity or RGBA/LA alpha; RGB-only masks are rejected. Regions/mask combine by union. Mask size must match. A hollow border needs a hollow mask, not its enclosing rectangle.
|
|
33
35
|
|
|
36
|
+
Candidate, baseline and mask must be single-frame PNGs with at most 8-bit channels. Unsupported formats, higher bit depths and animations exit 2; they are not silently reduced to 8-bit pixels or a first frame. Python `verify_edit` accepts decoded `1`, `L`, `LA`, `P`, `RGB` or `RGBA` images and single-frame masks with the channels above. Pass original decoded inputs: converting modes or copying a frame before verification can discard evidence the API cannot recover.
|
|
37
|
+
|
|
34
38
|
Exit codes: 0 valid boundary; 1 outside changes; 2 input/output error. `--out verification.json` saves counts, outside xywh bbox, up to 64 coordinates and omitted count. This does not judge appearance or state meaning. `validate` checks the image against its specified rules.
|
|
35
39
|
|
|
36
40
|
## Scoped color variants
|
|
@@ -4,7 +4,7 @@ from .spec import render
|
|
|
4
4
|
|
|
5
5
|
__all__ = ['Canvas', 'PixelArtError', 'color', 'make_preview', 'outline', 'render', 'validate',
|
|
6
6
|
'inspect_image', 'image_to_spec','replace_cell','recolor_image','verify_edit','assemble']
|
|
7
|
-
__version__ = '1.
|
|
7
|
+
__version__ = '1.3.0'
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def inspect_image(image, context=None, *, region=None, cell=None, grid=False, comparison=None, metadata=None):
|
|
@@ -27,7 +27,7 @@ def read_image(path):
|
|
|
27
27
|
return opened.copy()
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def
|
|
30
|
+
def _read_edit_png(path, operation):
|
|
31
31
|
"""Reject unsupported source/mask formats before copying away frame info."""
|
|
32
32
|
from .core import dimensions
|
|
33
33
|
|
|
@@ -38,13 +38,15 @@ def _read_recolor_png(path):
|
|
|
38
38
|
or header[:8] != b'\x89PNG\r\n\x1a\n'
|
|
39
39
|
or header[12:16] != b'IHDR'
|
|
40
40
|
):
|
|
41
|
-
raise PixelArtError('
|
|
41
|
+
raise PixelArtError(f'{operation}: expected a PNG input')
|
|
42
42
|
if header[24] > 8:
|
|
43
|
-
raise PixelArtError('
|
|
43
|
+
raise PixelArtError(f'{operation}: PNG bit depth above 8 is not supported')
|
|
44
44
|
with Image.open(path) as opened:
|
|
45
45
|
dimensions(opened.size)
|
|
46
46
|
if getattr(opened, 'n_frames', 1) != 1:
|
|
47
|
-
raise PixelArtError(
|
|
47
|
+
raise PixelArtError(
|
|
48
|
+
f'{operation}: animated/multiframe PNG is not supported'
|
|
49
|
+
)
|
|
48
50
|
return opened.copy()
|
|
49
51
|
|
|
50
52
|
|
|
@@ -260,10 +262,12 @@ def main(argv=None):
|
|
|
260
262
|
|
|
261
263
|
check_alias([args.image, args.compare, args.allow_mask], [args.out])
|
|
262
264
|
report = verify_edit(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
+
_read_edit_png(args.image, 'verify.image'),
|
|
266
|
+
_read_edit_png(args.compare, 'verify.compare'),
|
|
265
267
|
regions=args.allow_region,
|
|
266
|
-
mask=
|
|
268
|
+
mask=_read_edit_png(args.allow_mask, 'verify.mask')
|
|
269
|
+
if args.allow_mask
|
|
270
|
+
else None,
|
|
267
271
|
)
|
|
268
272
|
if args.out:
|
|
269
273
|
publish(
|
|
@@ -281,8 +285,10 @@ def main(argv=None):
|
|
|
281
285
|
[args.image, args.allow_mask, args.metadata],
|
|
282
286
|
[args.out, args.report, args.metadata_out],
|
|
283
287
|
)
|
|
284
|
-
source =
|
|
285
|
-
mask =
|
|
288
|
+
source = _read_edit_png(args.image, 'recolor')
|
|
289
|
+
mask = (
|
|
290
|
+
_read_edit_png(args.allow_mask, 'recolor') if args.allow_mask else None
|
|
291
|
+
)
|
|
286
292
|
context, layout_verification = merge_layout(
|
|
287
293
|
source, metadata=read_json(args.metadata) if args.metadata else None
|
|
288
294
|
)
|
|
@@ -6,6 +6,16 @@ from .core import PixelArtError,color,dimensions
|
|
|
6
6
|
from .context import _box
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
def _check_edit_image(image, where):
|
|
10
|
+
dimensions(image.size)
|
|
11
|
+
if getattr(image, 'n_frames', 1) != 1:
|
|
12
|
+
raise PixelArtError(f'{where}: animated/multiframe images are not supported')
|
|
13
|
+
if image.mode not in ('1', 'L', 'LA', 'P', 'RGB', 'RGBA'):
|
|
14
|
+
raise PixelArtError(
|
|
15
|
+
f'{where}: requires decoded 8-bit grayscale, palette, RGB or RGBA pixels'
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
9
19
|
def replace_cell(spec,name,replacement):
|
|
10
20
|
"""Return a new valid atlas spec; no I/O and no change to the original."""
|
|
11
21
|
from .spec import render
|
|
@@ -32,6 +42,8 @@ def _allowed_mask(size,regions,mask,where):
|
|
|
32
42
|
x,y,w,h=_box(region,size,where+'.region')
|
|
33
43
|
pen.rectangle((x,y,x+w-1,y+h-1),fill=255)
|
|
34
44
|
if mask is not None:
|
|
45
|
+
if getattr(mask, 'n_frames', 1) != 1:
|
|
46
|
+
raise PixelArtError(f'{where}.mask: animated/multiframe masks are not supported')
|
|
35
47
|
if mask.size!=size:raise PixelArtError(f'{where}.mask: dimensions must match')
|
|
36
48
|
if mask.mode in ('RGBA','LA'):channel=mask.getchannel('A')
|
|
37
49
|
elif mask.mode in ('L','1'):channel=mask.convert('L')
|
|
@@ -49,11 +61,7 @@ def recolor_image(image,mapping,*,regions=None,mask=None):
|
|
|
49
61
|
object selection takes place. Returned pixels do not inherit PNG metadata;
|
|
50
62
|
callers must validate source layout and publish a fresh output record.
|
|
51
63
|
"""
|
|
52
|
-
|
|
53
|
-
if getattr(image,'n_frames',1)!=1:
|
|
54
|
-
raise PixelArtError('recolor: animated/multiframe images are not supported')
|
|
55
|
-
if image.mode not in ('1','L','LA','P','RGB','RGBA'):
|
|
56
|
-
raise PixelArtError('recolor: requires decoded 8-bit grayscale, palette, RGB or RGBA pixels')
|
|
64
|
+
_check_edit_image(image, 'recolor')
|
|
57
65
|
pairs=list(mapping.items()) if isinstance(mapping,Mapping) else mapping
|
|
58
66
|
if not isinstance(pairs,(list,tuple)) or not pairs:
|
|
59
67
|
raise PixelArtError('recolor.mapping: expected a nonempty mapping or list of color pairs')
|
|
@@ -97,7 +105,8 @@ def verify_edit(image,comparison,*,regions=None,mask=None):
|
|
|
97
105
|
nonzero intensity (L/1); RGB masks are rejected to avoid an all-allowed trap.
|
|
98
106
|
All reported rectangles are [x,y,width,height]. No artwork is changed.
|
|
99
107
|
"""
|
|
100
|
-
|
|
108
|
+
_check_edit_image(image, 'verify.image')
|
|
109
|
+
_check_edit_image(comparison, 'verify.compare')
|
|
101
110
|
if image.size!=comparison.size:raise PixelArtError('verify: comparison dimensions must match')
|
|
102
111
|
allowed=_allowed_mask(image.size,regions,mask,'verify')
|
|
103
112
|
raw=image.convert('RGBA').tobytes();old=comparison.convert('RGBA').tobytes();permissions=allowed.tobytes()
|
|
@@ -11,6 +11,12 @@ from .core import PixelArtError
|
|
|
11
11
|
from .jsonio import parse_json
|
|
12
12
|
|
|
13
13
|
PNG_KEY = 'pixelart:layout'
|
|
14
|
+
MAX_LAYOUT_BYTES = 256 * 1024
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _check_record_size(text, source):
|
|
18
|
+
if len(text.encode('utf-8')) > MAX_LAYOUT_BYTES:
|
|
19
|
+
raise PixelArtError(f'{source} metadata exceeds 256 KiB')
|
|
14
20
|
|
|
15
21
|
|
|
16
22
|
def rgba_digest(image):
|
|
@@ -28,8 +34,12 @@ def encode_png(image, metadata=None):
|
|
|
28
34
|
buffer = BytesIO()
|
|
29
35
|
options = {}
|
|
30
36
|
if metadata is not None:
|
|
37
|
+
serialized = json.dumps(
|
|
38
|
+
metadata, ensure_ascii=True, sort_keys=True, separators=(',', ':')
|
|
39
|
+
)
|
|
40
|
+
_check_record_size(serialized, 'embedded')
|
|
31
41
|
info = PngInfo()
|
|
32
|
-
info.add_text(PNG_KEY,
|
|
42
|
+
info.add_text(PNG_KEY, serialized)
|
|
33
43
|
options['pnginfo'] = info
|
|
34
44
|
image.save(buffer, format='PNG', **options)
|
|
35
45
|
return buffer.getvalue()
|
|
@@ -55,8 +65,7 @@ def merge_layout(image, context=None, metadata=None, *, require_bound_atlas=Fals
|
|
|
55
65
|
if record is None:
|
|
56
66
|
continue
|
|
57
67
|
if isinstance(record, str):
|
|
58
|
-
|
|
59
|
-
raise PixelArtError(f'{source} metadata exceeds 256 KiB')
|
|
68
|
+
_check_record_size(record, source)
|
|
60
69
|
record = parse_json(record)
|
|
61
70
|
if not isinstance(record, Mapping) or set(record)-{'version','size','mode','atlas','rgba_sha256'}:
|
|
62
71
|
raise PixelArtError(f'{source} metadata: unknown fields or not an object')
|