@peekling/cli 0.1.0
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/AUTHORS +8 -0
- package/LICENSE +202 -0
- package/LICENSING.md +20 -0
- package/NOTICE +6 -0
- package/README.md +264 -0
- package/dist/atomic-directory.d.ts +2 -0
- package/dist/atomic-directory.d.ts.map +1 -0
- package/dist/atomic-directory.js +28 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +100 -0
- package/dist/doctor.d.ts +12 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +121 -0
- package/dist/image.d.ts +4 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +7 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +569 -0
- package/dist/png.d.ts +7 -0
- package/dist/png.d.ts.map +1 -0
- package/dist/png.js +169 -0
- package/dist/zip.d.ts +2 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +119 -0
- package/package.json +63 -0
package/AUTHORS
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Peekling CLI was originally designed and developed by Prajwal S. Venkateshmurthy (https://prajwal.me).
|
|
2
|
+
|
|
3
|
+
Other contributors are recorded in the repository history.
|
|
4
|
+
|
|
5
|
+
This is a factual authorship record. Licensing terms and applicable
|
|
6
|
+
notice-retention requirements are in LICENSE and NOTICE. Redistributions must
|
|
7
|
+
comply with Section 4 of the Apache License 2.0, including its applicable
|
|
8
|
+
notice-retention requirements.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/LICENSING.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Licensing and attribution
|
|
2
|
+
|
|
3
|
+
The Peekling CLI code and documentation are licensed under Apache-2.0. The
|
|
4
|
+
license allows personal and commercial use, modification, distribution, and
|
|
5
|
+
sublicensing subject to its terms.
|
|
6
|
+
|
|
7
|
+
Redistributions must comply with Section 4 of the Apache License 2.0, including
|
|
8
|
+
its applicable notice-retention requirements. When a distribution includes a
|
|
9
|
+
`NOTICE` file, Section 4 describes how readable copies of applicable NOTICE
|
|
10
|
+
attributions may be provided. Apache-2.0 does not require every website using
|
|
11
|
+
Peekling to display a visible attribution.
|
|
12
|
+
|
|
13
|
+
`AUTHORS` is a factual authorship record and does not add a license condition.
|
|
14
|
+
Imported, generated, and compiled character assets retain their declared pack
|
|
15
|
+
licenses. The Peekling name, logo, official mascot, and other distinctive brand
|
|
16
|
+
identity are outside this code license except as allowed by applicable law or
|
|
17
|
+
separate permission. See Section 6 of Apache-2.0.
|
|
18
|
+
|
|
19
|
+
The Apache License text controls if this summary conflicts with it. This summary
|
|
20
|
+
is informational and is not legal advice.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# `@peekling/cli`
|
|
2
|
+
|
|
3
|
+
Use the Peekling command line to check Configuration before deployment, create
|
|
4
|
+
and validate native Packs, compile artist-friendly source files, or import a
|
|
5
|
+
supported Codex Pet v2 bundle with explicit licensing metadata.
|
|
6
|
+
|
|
7
|
+
These commands run in Node and stay out of the browser runtime.
|
|
8
|
+
|
|
9
|
+
## Prerequisites and installation
|
|
10
|
+
|
|
11
|
+
- Node.js 22.14.0 or newer
|
|
12
|
+
- JSON Configuration and Pack files for Doctor
|
|
13
|
+
- Original or properly licensed source art for Pack authoring
|
|
14
|
+
|
|
15
|
+
Install the CLI as a development dependency:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install --save-dev @peekling/cli@0.1.0
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Run it through `npx` so the project-local version is used:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx peekling doctor ./peekling.json --pack ./my-character/character.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Expected result for valid inputs:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Peekling Doctor found no configuration errors.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Doctor exits with status `0` when the report is valid and status `1` when it
|
|
34
|
+
finds errors.
|
|
35
|
+
|
|
36
|
+
## Command reference
|
|
37
|
+
|
|
38
|
+
| Command | Use it for | Main output |
|
|
39
|
+
| ---------------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------- |
|
|
40
|
+
| `peekling doctor <configuration.json>` | Check Configuration, Plan, and optional Pack references | Human or JSON diagnostics |
|
|
41
|
+
| `peekling create <directory> --name <name>` | Create a working synthetic native Pack scaffold | New Pack directory |
|
|
42
|
+
| `peekling validate <directory>` | Verify a compiled Pack and its assets | Pack identity, State count, geometry, and bytes |
|
|
43
|
+
| `peekling pack <source-directory> --out <directory>` | Compile named source frames into dense runtime atlases | Runtime-ready Pack directory |
|
|
44
|
+
| `peekling import codex <input> --out <directory>` | Wrap a Codex Pet v2 bundle with provenance | Imported adapter bundle |
|
|
45
|
+
|
|
46
|
+
The command grammar is closed. Unknown options, duplicate options, missing
|
|
47
|
+
values, and extra positional arguments fail before command work begins.
|
|
48
|
+
|
|
49
|
+
## Check Configuration with Doctor
|
|
50
|
+
|
|
51
|
+
Use `--pack` when the Plan refers to Pack States or Capabilities. Use
|
|
52
|
+
`--base-url` when relative resource URLs should be checked against a deployment
|
|
53
|
+
page.
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npx peekling doctor ./peekling.json \
|
|
57
|
+
--pack ./my-character/character.json \
|
|
58
|
+
--base-url https://example.com/app/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Add `--json` for deterministic machine-readable output:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npx peekling doctor ./peekling.json \
|
|
65
|
+
--pack ./my-character/character.json \
|
|
66
|
+
--base-url https://example.com/app/ \
|
|
67
|
+
--json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
A successful JSON report has this shape:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"valid": true,
|
|
75
|
+
"errors": [],
|
|
76
|
+
"warnings": []
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Each diagnostic contains a code, data path, explanation, and suggested fix.
|
|
81
|
+
Doctor reads JSON data only. It does not import project modules, evaluate
|
|
82
|
+
Configuration code, call host callbacks, fetch resources, or contact a network
|
|
83
|
+
service.
|
|
84
|
+
|
|
85
|
+
Relative resource and content-link references may resolve against an HTTP
|
|
86
|
+
development base URL. Serialized absolute resource URLs must use canonical HTTPS
|
|
87
|
+
without credentials, malformed hosts or ports, whitespace, control characters,
|
|
88
|
+
backslashes, or noncanonical IP spelling. Theme colors accept only lowercase
|
|
89
|
+
`transparent` or exact 3, 4, 6, or 8 digit hex values.
|
|
90
|
+
|
|
91
|
+
## Create a Pack scaffold
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npx peekling create ./my-character --name my-character
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Expected result:
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
Created native Peekling pack at ./my-character
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The directory contains a visibly synthetic geometric atlas so validation can run
|
|
104
|
+
immediately. Replace that fixture with original, properly licensed art. Update
|
|
105
|
+
the Pack license, provenance, and `metadata.description` before using the Pack
|
|
106
|
+
outside local development.
|
|
107
|
+
|
|
108
|
+
Commands refuse to overwrite an existing output directory.
|
|
109
|
+
|
|
110
|
+
## Compile artist source into a runtime Pack
|
|
111
|
+
|
|
112
|
+
`peekling pack` accepts a source directory containing `source.json`, license and
|
|
113
|
+
provenance files, and either row-based sheets or named frame directories.
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
my-character-source/
|
|
117
|
+
source.json
|
|
118
|
+
source-1x.png
|
|
119
|
+
LICENSE
|
|
120
|
+
PROVENANCE.md
|
|
121
|
+
|
|
|
122
|
+
| peekling pack
|
|
123
|
+
v
|
|
124
|
+
my-character/
|
|
125
|
+
character.json
|
|
126
|
+
atlas-1x.png
|
|
127
|
+
LICENSE
|
|
128
|
+
PROVENANCE.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
In other words, author stable frame names and source locations. The compiler
|
|
132
|
+
then assigns dense numeric runtime frame IDs and writes the validated manifest.
|
|
133
|
+
|
|
134
|
+
A minimal row-sheet `source.json` looks like this:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"format": 1,
|
|
139
|
+
"name": "my-character",
|
|
140
|
+
"version": "0.1.0",
|
|
141
|
+
"license": "CC-BY-4.0",
|
|
142
|
+
"metadata": {
|
|
143
|
+
"description": "A small companion for the example application."
|
|
144
|
+
},
|
|
145
|
+
"logicalCellSize": 32,
|
|
146
|
+
"sources": [
|
|
147
|
+
{
|
|
148
|
+
"density": 1,
|
|
149
|
+
"sheet": "source-1x.png",
|
|
150
|
+
"columns": 16,
|
|
151
|
+
"rows": 1
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"states": {
|
|
155
|
+
"idle": {
|
|
156
|
+
"row": 0,
|
|
157
|
+
"frames": ["idle-a", "idle-b"],
|
|
158
|
+
"loop": true,
|
|
159
|
+
"fps": 4
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For that example, `source-1x.png` is a 16-column sheet with 32×32 source cells
|
|
166
|
+
and at least the two named frames in row `0`. Each State must choose either
|
|
167
|
+
uniform `fps` or one duration per frame.
|
|
168
|
+
|
|
169
|
+
Compile it:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
npx peekling pack ./my-character-source --out ./my-character
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Expected result:
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
Compiled dense native pack to ./my-character
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The compiler emits a deterministic 16-column atlas, removes unused source cells,
|
|
182
|
+
preserves the logical canvas, keeps frame order identical across declared
|
|
183
|
+
densities, and hashes each output atlas. A source may declare one through three
|
|
184
|
+
unique densities from `1`, `2`, and `4`.
|
|
185
|
+
|
|
186
|
+
## Validate a compiled Pack
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
npx peekling validate ./my-character
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
A successful result reports the exact Pack identity and measured atlas:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
Valid my-character@0.1.0: 1 states, 512x64 atlas (1234 bytes)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The dimensions and byte count above are illustrative. The command prints the
|
|
199
|
+
values measured from your files. Validation checks paths, hashes, geometry,
|
|
200
|
+
alpha, required Capabilities, timing, density variants, PNG chunk order, CRC
|
|
201
|
+
values, and a bounded image decode.
|
|
202
|
+
|
|
203
|
+
## Import a Codex Pet v2 bundle
|
|
204
|
+
|
|
205
|
+
The import command requires an output path plus explicit license, author,
|
|
206
|
+
source, and rights text:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
npx peekling import codex ./pet.codex-pet --out ./imported \
|
|
210
|
+
--license CC-BY-4.0 \
|
|
211
|
+
--author "Artist name" \
|
|
212
|
+
--source "Original Codex Pet v2 bundle" \
|
|
213
|
+
--rights "Licensed by the named author for redistribution"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Expected result:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
Imported Codex Pet v2 bundle to ./imported
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The command copies `pet.json` and the atlas byte-for-byte, writes
|
|
223
|
+
`peekling.json`, and preserves an input `.codex-pet` archive as
|
|
224
|
+
`source.codex-pet`. It never evaluates or copies bundled executable files.
|
|
225
|
+
|
|
226
|
+
The default supported atlas is `spritesheet.webp`. A self-hosted
|
|
227
|
+
`spritesheet.png` requires the explicit `--allow-png` flag:
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
npx peekling import codex ./png-pet-directory --out ./imported-png \
|
|
231
|
+
--allow-png \
|
|
232
|
+
--license CC-BY-4.0 \
|
|
233
|
+
--author "Artist name" \
|
|
234
|
+
--source "Original Codex Pet v2 directory" \
|
|
235
|
+
--rights "Licensed by the named author for redistribution"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The flag allows the existing PNG bytes. It does not convert the image or grant
|
|
239
|
+
rights to redistribute it.
|
|
240
|
+
|
|
241
|
+
## File and write safety
|
|
242
|
+
|
|
243
|
+
Doctor rejects non-JSON files, symbolic links, invalid UTF-8, duplicate object
|
|
244
|
+
keys, and inputs over 64 KiB. It confirms file identity before and during a
|
|
245
|
+
bounded read. Run it against project inputs that another user cannot rewrite at
|
|
246
|
+
the same time.
|
|
247
|
+
|
|
248
|
+
Pack-writing commands stage output in a temporary sibling directory and finish
|
|
249
|
+
with an atomic rename. They do not overwrite an existing destination. Source
|
|
250
|
+
paths must remain inside the declared source directory, and source allocations
|
|
251
|
+
are bounded before image pixels are decoded.
|
|
252
|
+
|
|
253
|
+
## Related documentation
|
|
254
|
+
|
|
255
|
+
- [Configure Peekling](../../docs/configuration.md)
|
|
256
|
+
- [`@peekling/preflight`](../preflight/README.md)
|
|
257
|
+
- [`@peekling/vite`](../vite/README.md)
|
|
258
|
+
- [`@peekling/adapter-codex-pet`](../adapter-codex-pet/README.md)
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
Apache-2.0. Imported and generated character assets retain their separately
|
|
263
|
+
declared licenses. See [licensing and attribution](LICENSING.md) for notice
|
|
264
|
+
retention, authorship, and brand boundaries.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-directory.d.ts","sourceRoot":"","sources":["../src/atomic-directory.ts"],"names":[],"mappings":"AAaA,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { lstat, mkdir, mkdtemp, rename, rm } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
async function assertAbsent(target) {
|
|
4
|
+
try {
|
|
5
|
+
await lstat(target);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
if (error.code === "ENOENT")
|
|
9
|
+
return;
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
throw new Error(`Refusing to overwrite existing path: ${target}`);
|
|
13
|
+
}
|
|
14
|
+
export async function atomicDirectory(target, writer) {
|
|
15
|
+
const absolute = path.resolve(target);
|
|
16
|
+
await assertAbsent(absolute);
|
|
17
|
+
await mkdir(path.dirname(absolute), { recursive: true });
|
|
18
|
+
const temp = await mkdtemp(path.join(path.dirname(absolute), ".peekling-"));
|
|
19
|
+
try {
|
|
20
|
+
await writer(temp);
|
|
21
|
+
await assertAbsent(absolute);
|
|
22
|
+
await rename(temp, absolute);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
await rm(temp, { recursive: true, force: true });
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createPack, importCodexPet, packAuthoringSource, validatePackDirectory, } from "./index.js";
|
|
3
|
+
import { runDoctor } from "./doctor.js";
|
|
4
|
+
function required(value, message) {
|
|
5
|
+
if (!value)
|
|
6
|
+
throw new Error(message);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function argumentsFor(args, positionalLimit, valueOptions = [], booleanOptions = []) {
|
|
10
|
+
const positionals = [];
|
|
11
|
+
const options = new Map();
|
|
12
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
13
|
+
const argument = args[index];
|
|
14
|
+
if (!argument.startsWith("--")) {
|
|
15
|
+
if (positionals.length >= positionalLimit) {
|
|
16
|
+
throw new Error(`Unexpected positional argument ${argument}`);
|
|
17
|
+
}
|
|
18
|
+
positionals.push(argument);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const name = argument.slice(2);
|
|
22
|
+
if (options.has(name))
|
|
23
|
+
throw new Error(`Duplicate option --${name}`);
|
|
24
|
+
if (booleanOptions.includes(name)) {
|
|
25
|
+
options.set(name, true);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!valueOptions.includes(name)) {
|
|
29
|
+
throw new Error(`Unknown option --${name}`);
|
|
30
|
+
}
|
|
31
|
+
const value = args[index + 1];
|
|
32
|
+
if (!value || value.startsWith("--")) {
|
|
33
|
+
throw new Error(`--${name} requires a value`);
|
|
34
|
+
}
|
|
35
|
+
options.set(name, value);
|
|
36
|
+
index += 1;
|
|
37
|
+
}
|
|
38
|
+
return { positionals, options };
|
|
39
|
+
}
|
|
40
|
+
async function main(args) {
|
|
41
|
+
const [command] = args;
|
|
42
|
+
if (command === "doctor") {
|
|
43
|
+
const { positionals, options } = argumentsFor(args.slice(1), 1, ["pack", "base-url"], ["json"]);
|
|
44
|
+
const [first] = positionals;
|
|
45
|
+
const packPath = options.get("pack");
|
|
46
|
+
const baseUrl = options.get("base-url");
|
|
47
|
+
const result = await runDoctor(required(first, "Usage: peekling doctor <configuration.json> [--pack character.json] [--json]"), {
|
|
48
|
+
...(typeof packPath === "string" ? { packPath } : {}),
|
|
49
|
+
...(typeof baseUrl === "string" ? { baseUrl } : {}),
|
|
50
|
+
...(options.get("json") === true ? { json: true } : {}),
|
|
51
|
+
});
|
|
52
|
+
process.stdout.write(result.output);
|
|
53
|
+
process.exitCode = result.exitCode;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (command === "create") {
|
|
57
|
+
const { positionals, options } = argumentsFor(args.slice(1), 1, ["name"]);
|
|
58
|
+
const [first] = positionals;
|
|
59
|
+
await createPack(required(first, "Usage: peekling create <directory> --name <name>"), required(options.get("name"), "create requires --name"));
|
|
60
|
+
console.log(`Created native Peekling pack at ${first}`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (command === "validate") {
|
|
64
|
+
const { positionals } = argumentsFor(args.slice(1), 1);
|
|
65
|
+
const [first] = positionals;
|
|
66
|
+
const result = await validatePackDirectory(required(first, "Usage: peekling validate <directory>"));
|
|
67
|
+
console.log(`Valid ${result.name}@${result.version}: ${result.states} states, ${result.atlas.width}x${result.atlas.height} atlas (${result.atlas.bytes} bytes)`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (command === "pack") {
|
|
71
|
+
const { positionals, options } = argumentsFor(args.slice(1), 1, ["out"]);
|
|
72
|
+
const [first] = positionals;
|
|
73
|
+
const output = required(options.get("out"), "pack requires --out");
|
|
74
|
+
await packAuthoringSource(required(first, "Usage: peekling pack <source-directory> --out <directory>"), output);
|
|
75
|
+
console.log(`Compiled dense native pack to ${output}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (command === "import") {
|
|
79
|
+
const { positionals, options } = argumentsFor(args.slice(1), 2, ["out", "license", "author", "source", "rights"], ["allow-png"]);
|
|
80
|
+
const [kind, second] = positionals;
|
|
81
|
+
if (kind !== "codex") {
|
|
82
|
+
throw new Error("Usage: peekling import codex <input> --out <directory> [metadata]");
|
|
83
|
+
}
|
|
84
|
+
const input = required(second, "Usage: peekling import codex <input> --out <directory> [metadata]");
|
|
85
|
+
await importCodexPet(input, required(options.get("out"), "import codex requires --out"), {
|
|
86
|
+
license: required(options.get("license"), "import codex requires --license"),
|
|
87
|
+
author: required(options.get("author"), "import codex requires --author"),
|
|
88
|
+
source: required(options.get("source"), "import codex requires --source"),
|
|
89
|
+
rights: required(options.get("rights"), "import codex requires --rights"),
|
|
90
|
+
...(options.get("allow-png") === true ? { allowPng: true } : {}),
|
|
91
|
+
});
|
|
92
|
+
console.log(`Imported Codex Pet v2 bundle to ${options.get("out")}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw new Error("Usage: peekling <doctor|create|pack|validate|import codex> ...");
|
|
96
|
+
}
|
|
97
|
+
void main(process.argv.slice(2)).catch((error) => {
|
|
98
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
99
|
+
process.exitCode = 1;
|
|
100
|
+
});
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PreflightResult } from "@peekling/preflight";
|
|
2
|
+
export interface DoctorOptions {
|
|
3
|
+
readonly packPath?: string;
|
|
4
|
+
readonly baseUrl?: string;
|
|
5
|
+
readonly json?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function runDoctor(configPath: string, options?: DoctorOptions): Promise<{
|
|
8
|
+
report: PreflightResult;
|
|
9
|
+
output: string;
|
|
10
|
+
exitCode: 0 | 1;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC,CAkCvE"}
|