vibedgames 0.9.0 → 0.10.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.
Files changed (88) hide show
  1. package/README.md +3 -2
  2. package/assets/align-framing.py +242 -0
  3. package/assets/render-model.py +406 -0
  4. package/assets/tilemap-editor.html +630 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +2 -2
  6. package/dist/chunk-2KVQJKIZ.js +6495 -0
  7. package/dist/{chunk-56OY4TEP.js → chunk-2SBBKY5C.js} +1361 -4493
  8. package/dist/{chunk-FC233UKH.js → chunk-2ZKS7V72.js} +16 -16
  9. package/dist/{chunk-BMTHAVMS.js → chunk-3HGBIUM5.js} +22 -19
  10. package/dist/chunk-3UGGMFJJ.js +22 -0
  11. package/dist/{chunk-3HUWAJQH.js → chunk-42K3BJJH.js} +93 -76
  12. package/dist/{chunk-ST5FC2W3.js → chunk-43P4U7CB.js} +20 -11
  13. package/dist/chunk-4FJXCS3K.js +741 -0
  14. package/dist/{chunk-WSRIF6K4.js → chunk-4UU622RK.js} +5 -4
  15. package/dist/chunk-5YPLKGY3.js +87 -0
  16. package/dist/chunk-6KXXZXSO.js +475 -0
  17. package/dist/chunk-7RPLQWR2.js +91 -0
  18. package/dist/{chunk-ZCYWDKYP.js → chunk-A556KALN.js} +14 -13
  19. package/dist/{chunk-UFR6G6BL.js → chunk-ABTUEIRC.js} +554 -254
  20. package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
  21. package/dist/{chunk-HNRVSBRK.js → chunk-BN3Q7UEC.js} +20 -17
  22. package/dist/chunk-BZOMEG3X.js +412 -0
  23. package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
  24. package/dist/{chunk-KZBZNTM4.js → chunk-CTY2WZQK.js} +9 -13
  25. package/dist/chunk-DB7WVFS7.js +80 -0
  26. package/dist/chunk-DOOQUFPG.js +73 -0
  27. package/dist/{chunk-K2U7L4RU.js → chunk-E3FJUPLT.js} +15 -21
  28. package/dist/chunk-E7NDOZ27.js +428 -0
  29. package/dist/{chunk-TBQ5BU3Q.js → chunk-F42QKWBB.js} +18 -18
  30. package/dist/chunk-FXXVXDTW.js +168 -0
  31. package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
  32. package/dist/chunk-GLEW7VJQ.js +45 -0
  33. package/dist/{chunk-AXTLPJ2F.js → chunk-H2C4QUTG.js} +8 -7
  34. package/dist/{chunk-H3IPLBXQ.js → chunk-HRKVAXNN.js} +17 -14
  35. package/dist/{chunk-UXCWSWWX.js → chunk-HSMG6U7J.js} +8 -7
  36. package/dist/chunk-HX5Q63UA.js +48 -0
  37. package/dist/chunk-HYOXGNWS.js +53 -0
  38. package/dist/chunk-I5LELJSK.js +22 -0
  39. package/dist/{chunk-7CXMMC5S.js → chunk-JN4WZCR7.js} +5 -4
  40. package/dist/{chunk-7QZSDU52.js → chunk-K36EOII3.js} +5 -4
  41. package/dist/chunk-KAGVI3CE.js +62 -0
  42. package/dist/chunk-KJK5CB6E.js +58 -0
  43. package/dist/chunk-KLFBAFXD.js +25 -0
  44. package/dist/{chunk-355VG7EO.js → chunk-LONQWRTR.js} +107 -77
  45. package/dist/{chunk-Z5TFZQ5U.js → chunk-LORGE2NB.js} +68 -62
  46. package/dist/{chunk-LY2GQ32S.js → chunk-MEAO33XW.js} +22 -20
  47. package/dist/{chunk-OD2MNYXD.js → chunk-MR5KIFI7.js} +23 -22
  48. package/dist/{chunk-2VUUMXAQ.js → chunk-N2UHAQXC.js} +18 -11
  49. package/dist/chunk-NCX6LYNJ.js +117 -0
  50. package/dist/chunk-OGX4DKIS.js +215 -0
  51. package/dist/chunk-OPUCUUID.js +41 -0
  52. package/dist/chunk-Q2QC6KAZ.js +132 -0
  53. package/dist/{chunk-NDHXM4PL.js → chunk-Q3XQPNF6.js} +12 -12
  54. package/dist/{chunk-RXHTGX7C.js → chunk-Q5NZNXJE.js} +6 -10
  55. package/dist/chunk-QLCVLCPM.js +126 -0
  56. package/dist/chunk-R2WVORGD.js +91 -0
  57. package/dist/chunk-RKS7SI5L.js +64 -0
  58. package/dist/{chunk-US6QZICZ.js → chunk-RPJR3S5S.js} +32 -18
  59. package/dist/chunk-RPSUFZAG.js +3307 -0
  60. package/dist/chunk-RRI23NK2.js +40 -0
  61. package/dist/chunk-S7HYWITX.js +57 -0
  62. package/dist/chunk-SBXCK2I2.js +48 -0
  63. package/dist/chunk-SUSX3QIA.js +62 -0
  64. package/dist/{chunk-6EWHKL7Z.js → chunk-SXYQL4GK.js} +7 -6
  65. package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
  66. package/dist/chunk-TXOE5UY5.js +72 -0
  67. package/dist/chunk-U6DTE5IX.js +124 -0
  68. package/dist/{chunk-UZM6OSW5.js → chunk-UPHB5HWO.js} +15 -13
  69. package/dist/chunk-UQ7VO6B3.js +91 -0
  70. package/dist/chunk-VB4WLJR2.js +47 -0
  71. package/dist/{chunk-25BAMW5X.js → chunk-VIEKOGKG.js} +18 -2
  72. package/dist/{chunk-LXS3NJYD.js → chunk-VZEJ2ZHE.js} +14 -15
  73. package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
  74. package/dist/chunk-ZHLPE6LI.js +71 -0
  75. package/dist/index.js +39 -36
  76. package/package.json +31 -16
  77. package/templates/none/src/main.ts +4 -0
  78. package/templates/none/vite.config.ts +0 -2
  79. package/templates/phaser/src/main.ts +0 -1
  80. package/templates/phaser/src/scenes/game-scene.ts +10 -8
  81. package/templates/phaser/vite.config.ts +0 -2
  82. package/templates/react-r3f/src/app.tsx +3 -1
  83. package/templates/react-r3f/src/main.tsx +1 -0
  84. package/templates/react-r3f/vite.config.ts +0 -2
  85. package/templates/threejs/src/main.ts +10 -1
  86. package/templates/threejs/vite.config.ts +0 -2
  87. package/LICENSE +0 -21
  88. package/dist/chunk-J6PKNPI2.js +0 -26
@@ -0,0 +1,215 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ Bitmap,
9
+ HIGH_FRINGE_REMOVAL_RATIO,
10
+ cleanChroma,
11
+ despillChroma,
12
+ fail,
13
+ failUsage,
14
+ getFlag,
15
+ getInt,
16
+ getNumber,
17
+ getString,
18
+ globFrames,
19
+ keyMatte,
20
+ main,
21
+ parseArgs,
22
+ parseColor,
23
+ removeChromaFringe,
24
+ writeJsonFile
25
+ } from "./chunk-2KVQJKIZ.js";
26
+ import "./chunk-2SBBKY5C.js";
27
+ import "./chunk-GKDUYJ7R.js";
28
+
29
+ // src/commands/asset/chroma-clean.ts
30
+ import { existsSync, statSync } from "node:fs";
31
+ import path from "node:path";
32
+ var inputsFor = (input = "", glob = "*.png") => {
33
+ if (!existsSync(input)) {
34
+ fail(`input not found: ${input}`);
35
+ }
36
+ if (!statSync(input).isDirectory()) {
37
+ return [input];
38
+ }
39
+ const frames = globFrames(input, glob);
40
+ if (frames.length === 0) {
41
+ fail(`no files matched ${glob} in ${input}`);
42
+ }
43
+ return frames;
44
+ };
45
+ var siblingOutput = (src = "", suffix = "") => {
46
+ const name = path.basename(src).replace(/\.[^.]+$/u, "");
47
+ return path.join(path.dirname(src), `${name}-${suffix}.png`);
48
+ };
49
+ var run = (argv) => {
50
+ main(() => {
51
+ const args = parseArgs([...argv], {
52
+ booleans: ["keep-largest", "no-decontam", "whole-image"],
53
+ values: [
54
+ "chroma",
55
+ "despill-radius",
56
+ "edge-radius",
57
+ "fringe-radius",
58
+ "glob",
59
+ "input",
60
+ "out",
61
+ "out-dir",
62
+ "tolerance"
63
+ ]
64
+ });
65
+ const chromaOf = () => {
66
+ const [r, g, b] = parseColor(getString(args, "chroma") ?? "#00FF00");
67
+ const rgb = [r, g, b];
68
+ return rgb;
69
+ };
70
+ const requiredInput = () => {
71
+ const input = getString(args, "input") ?? "";
72
+ if (input === "") {
73
+ failUsage("--input is required");
74
+ }
75
+ return input;
76
+ };
77
+ const clean = () => {
78
+ const input = requiredInput();
79
+ const chroma = chromaOf();
80
+ const settings = {
81
+ chroma,
82
+ decontam: !getFlag(args, "no-decontam"),
83
+ despillRadius: getInt(args, "despill-radius", 2),
84
+ fringeRadius: getInt(args, "fringe-radius", 1),
85
+ tolerance: getNumber(args, "tolerance", 90)
86
+ };
87
+ const cleanOne = (src = "", out2 = "") => {
88
+ const result = cleanChroma(Bitmap.fromFile(src), settings);
89
+ result.image.toFile(out2);
90
+ return {
91
+ chromaRgb: chroma,
92
+ decontam: result.decontam,
93
+ despill: result.despill,
94
+ fringe: result.fringe,
95
+ input: src,
96
+ key: result.key,
97
+ output: out2
98
+ };
99
+ };
100
+ if (statSync(input).isDirectory()) {
101
+ const outDir = getString(args, "out-dir") ?? input;
102
+ const frames = inputsFor(input, getString(args, "glob")).map(
103
+ (frame) => cleanOne(frame, path.join(outDir, path.basename(frame)))
104
+ );
105
+ writeJsonFile(path.join(outDir, "clean-metadata.json"), {
106
+ frames,
107
+ inputDir: input,
108
+ outDir
109
+ });
110
+ console.log(outDir);
111
+ return;
112
+ }
113
+ const out = getString(args, "out") ?? siblingOutput(input, "clean");
114
+ const meta = cleanOne(input, out);
115
+ writeJsonFile(path.join(path.dirname(out), "clean-metadata.json"), meta);
116
+ console.log(out);
117
+ };
118
+ const outDirFor = (input = "") => getString(args, "out-dir") ?? (statSync(input).isDirectory() ? input : path.dirname(input));
119
+ const despill = () => {
120
+ const input = requiredInput();
121
+ const chroma = chromaOf();
122
+ const edgeRadius = getInt(args, "edge-radius", 2);
123
+ const bandOnly = !getFlag(args, "whole-image");
124
+ const frames = inputsFor(input, getString(args, "glob"));
125
+ const outDir = outDirFor(input);
126
+ const metadata = frames.map((frame) => {
127
+ const { image, record } = despillChroma(Bitmap.fromFile(frame), {
128
+ bandOnly,
129
+ chroma,
130
+ edgeRadius
131
+ });
132
+ const out = path.join(outDir, path.basename(frame));
133
+ image.toFile(out);
134
+ return { input: frame, output: out, ...record };
135
+ });
136
+ writeJsonFile(path.join(outDir, "despill-metadata.json"), {
137
+ bandOnly,
138
+ chromaRgb: chroma,
139
+ edgeRadius,
140
+ frames: metadata
141
+ });
142
+ console.log(outDir);
143
+ };
144
+ const fringe = () => {
145
+ const input = requiredInput();
146
+ const chroma = chromaOf();
147
+ const edgeRadius = getInt(args, "edge-radius", 1);
148
+ const frames = inputsFor(input, getString(args, "glob"));
149
+ const outDir = outDirFor(input);
150
+ const results = frames.map((frame) => {
151
+ const { image, record } = removeChromaFringe(Bitmap.fromFile(frame), {
152
+ chroma,
153
+ edgeRadius
154
+ });
155
+ const out = path.join(outDir, path.basename(frame));
156
+ image.toFile(out);
157
+ return { frame, out, record };
158
+ });
159
+ const warnings = results.filter(({ record }) => record.warning !== null && record.warning !== "").map(({ frame, record }) => ({
160
+ frame: path.basename(frame),
161
+ keptPixels: record.keptPixels,
162
+ removedFringePixels: record.removedFringePixels,
163
+ removedToKeptRatio: record.removedToKeptRatio,
164
+ warning: record.warning
165
+ }));
166
+ writeJsonFile(path.join(outDir, "fringe-metadata.json"), {
167
+ chromaRgb: chroma,
168
+ edgeRadius,
169
+ frames: results.map(({ frame, out, record }) => ({ input: frame, output: out, ...record })),
170
+ highRemovalRatioThreshold: HIGH_FRINGE_REMOVAL_RATIO,
171
+ warnings
172
+ });
173
+ console.log(outDir);
174
+ };
175
+ const key = () => {
176
+ const [, src = ""] = args.positionals;
177
+ const option = getString(args, "input");
178
+ if (src === "" && (option === void 0 || option === "")) {
179
+ failUsage("--input is required");
180
+ }
181
+ const input = option ?? src;
182
+ if (statSync(input).isDirectory()) {
183
+ fail("key expects a single PNG; use fringe/despill for directories");
184
+ }
185
+ const { image, record } = keyMatte(Bitmap.fromFile(input), {
186
+ chroma: chromaOf(),
187
+ keepLargest: getFlag(args, "keep-largest"),
188
+ tolerance: getNumber(args, "tolerance", 90)
189
+ });
190
+ const out = getString(args, "out") ?? siblingOutput(input, "keyed");
191
+ image.toFile(out);
192
+ writeJsonFile(path.join(path.dirname(out), "key-metadata.json"), {
193
+ input,
194
+ output: out,
195
+ ...record
196
+ });
197
+ console.log(out);
198
+ };
199
+ const mode = (/* @__PURE__ */ new Map([
200
+ ["clean", clean],
201
+ ["despill", despill],
202
+ ["fringe", fringe],
203
+ ["key", key]
204
+ ])).get(args.positionals[0] ?? "");
205
+ if (mode === void 0) {
206
+ fail(
207
+ `Usage: vg asset chroma-clean <clean|key|fringe|despill> --input <path> [--chroma '#00FF00']`
208
+ );
209
+ }
210
+ mode?.();
211
+ });
212
+ };
213
+ export {
214
+ run
215
+ };
@@ -0,0 +1,41 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ consola
9
+ } from "./chunk-D2RF35HJ.js";
10
+
11
+ // src/lib/raw-tools.ts
12
+ var rawTool = (load) => async () => {
13
+ const module = await load();
14
+ return module.run;
15
+ };
16
+ var usage = (group, tools) => [
17
+ `Usage: vg ${group} <tool> [args]`,
18
+ "",
19
+ ...Object.entries(tools).map(([name, entry]) => ` ${name.padEnd(26)}${entry.description}`)
20
+ ].join("\n");
21
+ var runRawTool = async (group, tools, argv) => {
22
+ const [name = "", ...rest] = argv;
23
+ if (name === "" || name === "--help" || name === "-h") {
24
+ console.log(usage(group, tools));
25
+ process.exit(0);
26
+ }
27
+ const entry = Object.hasOwn(tools, name) ? tools[name] : void 0;
28
+ if (entry === void 0) {
29
+ consola.error(`Unknown ${group} tool: ${name}
30
+
31
+ ${usage(group, tools)}`);
32
+ process.exit(2);
33
+ }
34
+ const run = await entry.load();
35
+ await run(rest);
36
+ };
37
+
38
+ export {
39
+ rawTool,
40
+ runRawTool
41
+ };
@@ -0,0 +1,132 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ rawTool,
9
+ runRawTool
10
+ } from "./chunk-OPUCUUID.js";
11
+ import {
12
+ defineCommand
13
+ } from "./chunk-MBXCVCC4.js";
14
+ import "./chunk-D2RF35HJ.js";
15
+ import "./chunk-GKDUYJ7R.js";
16
+
17
+ // src/commands/asset.ts
18
+ var ASSET_TOOLS = {
19
+ "align-framing": {
20
+ description: "Crop or align a reference image to a render's framing (needs uv).",
21
+ load: rawTool(async () => await import("./chunk-3UGGMFJJ.js"))
22
+ },
23
+ "aseprite-inspect": {
24
+ description: "Parse an .aseprite file into JSON: frames, layers, tags, optional cel decode.",
25
+ load: rawTool(async () => await import("./chunk-ZHLPE6LI.js"))
26
+ },
27
+ "build-sequence-gif": {
28
+ description: "Assemble ordered frames into an animated GIF preview.",
29
+ load: rawTool(async () => await import("./chunk-DOOQUFPG.js"))
30
+ },
31
+ "chroma-clean": {
32
+ description: "Key out a chroma background, trim fringe and despill.",
33
+ load: rawTool(async () => await import("./chunk-OGX4DKIS.js"))
34
+ },
35
+ "image-util": {
36
+ description: "Report PNG sizes, nearest-neighbour upscale, or Lanczos resize.",
37
+ load: rawTool(async () => await import("./chunk-7RPLQWR2.js"))
38
+ },
39
+ "manifest-check": {
40
+ description: "Check an asset manifest against the files on disk.",
41
+ load: rawTool(async () => await import("./chunk-KAGVI3CE.js"))
42
+ },
43
+ "manifest-export-json": {
44
+ description: "Convert an assets_index.lua manifest to JSON.",
45
+ load: rawTool(async () => await import("./chunk-GLEW7VJQ.js"))
46
+ },
47
+ "normalize-canvas": {
48
+ description: "Pad frames to one canvas size with a shared baseline.",
49
+ load: rawTool(async () => await import("./chunk-TXOE5UY5.js"))
50
+ },
51
+ "normalize-factory": {
52
+ description: "Strip generator metadata from image-to-threejs factory output.",
53
+ load: rawTool(async () => await import("./chunk-5YPLKGY3.js"))
54
+ },
55
+ "pack-spritesheet": {
56
+ description: "Pack a folder of frames into a spritesheet plus JSON.",
57
+ load: rawTool(async () => await import("./chunk-VB4WLJR2.js"))
58
+ },
59
+ "pixel-snapper": {
60
+ description: "Snap a generated image onto a true pixel grid with a reduced palette.",
61
+ load: rawTool(async () => await import("./chunk-HYOXGNWS.js"))
62
+ },
63
+ "pixel-snapper-sheet": {
64
+ description: "Pixel-snap each cell of a known-layout spritesheet.",
65
+ load: rawTool(async () => await import("./chunk-S7HYWITX.js"))
66
+ },
67
+ "process-sheet": {
68
+ description: "Turn a generated pose board into clean, aligned animation frames.",
69
+ load: rawTool(async () => await import("./chunk-U6DTE5IX.js"))
70
+ },
71
+ "recover-component-frames": {
72
+ description: "Recover frames from a pose board by connected components.",
73
+ load: rawTool(async () => await import("./chunk-RKS7SI5L.js"))
74
+ },
75
+ "ref-sxs": {
76
+ description: "Put a reference shot beside a capture, plus a blurred twin.",
77
+ load: rawTool(async () => await import("./chunk-UQ7VO6B3.js"))
78
+ },
79
+ "render-model": {
80
+ description: "Render a three.js factory from fixed cameras for review (needs uv).",
81
+ load: rawTool(async () => await import("./chunk-I5LELJSK.js"))
82
+ },
83
+ "sheet-probe": {
84
+ description: "Probe a spritesheet or folder for frame grid and empty cells.",
85
+ load: rawTool(async () => await import("./chunk-KJK5CB6E.js"))
86
+ },
87
+ "sheet-qc": {
88
+ description: "Quality-check a spritesheet: frame drift, clipping, jitter.",
89
+ load: rawTool(async () => await import("./chunk-SUSX3QIA.js"))
90
+ },
91
+ "size-contract": {
92
+ description: "Derive, audit or prompt for a sprite size contract.",
93
+ load: rawTool(async () => await import("./chunk-QLCVLCPM.js"))
94
+ },
95
+ sizes: {
96
+ description: "List every image's dimensions under a folder (CSV/JSON).",
97
+ load: rawTool(async () => await import("./chunk-HX5Q63UA.js"))
98
+ },
99
+ "sprite-baseline": {
100
+ description: "Measure or fix sprites' feet baseline and centre.",
101
+ load: rawTool(async () => await import("./chunk-DB7WVFS7.js"))
102
+ },
103
+ "sprite-presets": {
104
+ description: "List animation presets: frames, timing and poses per action.",
105
+ load: rawTool(async () => await import("./chunk-R2WVORGD.js"))
106
+ },
107
+ "sprite-prompt": {
108
+ description: "Write the generation prompt for a sprite anchor or pose board.",
109
+ load: rawTool(async () => await import("./chunk-NCX6LYNJ.js"))
110
+ },
111
+ "tilemap-editor": {
112
+ description: "Edit a tilemap in the browser, or export tileset grids and map renders.",
113
+ load: rawTool(async () => await import("./chunk-FXXVXDTW.js"))
114
+ }
115
+ };
116
+ var runAsset = async (argv) => {
117
+ await runRawTool("asset", ASSET_TOOLS, argv);
118
+ };
119
+ var assetCommand = defineCommand({
120
+ meta: {
121
+ description: "Local image, sprite and tilemap tools the skills run (`vg asset --help` lists them). All arguments pass through to the tool.",
122
+ name: "asset"
123
+ },
124
+ run: async ({ rawArgs }) => {
125
+ await runAsset(rawArgs);
126
+ }
127
+ });
128
+ export {
129
+ ASSET_TOOLS,
130
+ assetCommand,
131
+ runAsset
132
+ };
@@ -4,6 +4,9 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
+ import {
8
+ assertKnownFlags
9
+ } from "./chunk-RZ4DIJQW.js";
7
10
  import {
8
11
  SETTINGS,
9
12
  SETTING_KEYS,
@@ -13,22 +16,20 @@ import {
13
16
  saveSetting,
14
17
  settingsPath,
15
18
  validate
16
- } from "./chunk-7CXMMC5S.js";
17
- import "./chunk-RXHTGX7C.js";
19
+ } from "./chunk-JN4WZCR7.js";
20
+ import "./chunk-Q5NZNXJE.js";
18
21
  import {
19
22
  outputArgs,
20
23
  writeStructured
21
- } from "./chunk-ZYCSYJWX.js";
24
+ } from "./chunk-COSLGSVO.js";
22
25
  import {
23
- assertKnownFlags
24
- } from "./chunk-RZ4DIJQW.js";
26
+ defineCommand
27
+ } from "./chunk-MBXCVCC4.js";
25
28
  import {
26
29
  consola
27
30
  } from "./chunk-D2RF35HJ.js";
28
- import "./chunk-J6PKNPI2.js";
29
- import {
30
- defineCommand
31
- } from "./chunk-MBXCVCC4.js";
31
+ import "./chunk-RPSUFZAG.js";
32
+ import "./chunk-2SBBKY5C.js";
32
33
  import "./chunk-GKDUYJ7R.js";
33
34
 
34
35
  // src/commands/config.ts
@@ -42,7 +43,7 @@ var requireKey = (key) => {
42
43
  return key;
43
44
  }
44
45
  consola.error(`Unknown setting: ${key}. Settings: ${SETTING_KEYS.join(", ")}.`);
45
- process.exit(1);
46
+ return process.exit(1);
46
47
  };
47
48
  var describeSource = (setting) => {
48
49
  if (setting.source === "env") {
@@ -120,7 +121,7 @@ var setCommand = defineCommand({
120
121
  const key = requireKey(args.key);
121
122
  const value = args.value.trim();
122
123
  const problem = validate(key, value);
123
- if (problem) {
124
+ if (problem !== null && problem !== "") {
124
125
  consola.error(problem);
125
126
  process.exit(1);
126
127
  }
@@ -153,7 +154,6 @@ var unsetCommand = defineCommand({
153
154
  }
154
155
  });
155
156
  var configCommand = defineCommand({
156
- // Declared so citty skips `--field <value>` when looking for a subcommand.
157
157
  args: outputArgs,
158
158
  default: "list",
159
159
  meta: {
@@ -7,8 +7,9 @@ var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  isJsonNumber,
9
9
  isJsonObject,
10
- isJsonString
11
- } from "./chunk-J6PKNPI2.js";
10
+ isJsonString,
11
+ parseJson
12
+ } from "./chunk-RPSUFZAG.js";
12
13
 
13
14
  // src/lib/config.ts
14
15
  import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "node:fs";
@@ -27,7 +28,7 @@ var getConfig = () => {
27
28
  }
28
29
  let raw;
29
30
  try {
30
- raw = JSON.parse(readFileSync(file, "utf-8"));
31
+ raw = parseJson(readFileSync(file, "utf-8"));
31
32
  } catch {
32
33
  return null;
33
34
  }
@@ -60,13 +61,8 @@ var clearConfig = () => {
60
61
  unlinkSync(file);
61
62
  }
62
63
  };
63
- var getBaseUrl = () => process.env.VG_API_URL ?? getConfig()?.baseUrl ?? "https://vibedgames.com";
64
- var getToken = () => (
65
- // VG_TOKEN lets local/CI runs authenticate without touching the saved
66
- // login (e.g. a seeded dev session), so headless testing never clobbers
67
- // the user's real `vg login` credentials.
68
- process.env.VG_TOKEN ?? getConfig()?.token ?? null
69
- );
64
+ var getBaseUrl = () => process.env.VG_API_URL ?? getConfig()?.baseUrl ?? "https://www.vibedgames.com";
65
+ var getToken = () => process.env.VG_TOKEN ?? getConfig()?.token ?? null;
70
66
 
71
67
  export {
72
68
  getConfigDir,
@@ -0,0 +1,126 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ FRAME_HEIGHT,
9
+ FRAME_WIDTH,
10
+ auditSizeContract,
11
+ deriveSizeContract,
12
+ fail,
13
+ failUsage,
14
+ getFlag,
15
+ getString,
16
+ loadSizeContract,
17
+ main,
18
+ parseArgs,
19
+ parseJsonText,
20
+ promptGuidanceForContract,
21
+ toPythonJson,
22
+ writeJsonFile
23
+ } from "./chunk-2KVQJKIZ.js";
24
+ import "./chunk-2SBBKY5C.js";
25
+ import "./chunk-GKDUYJ7R.js";
26
+
27
+ // src/commands/asset/size-contract.ts
28
+ import { readFileSync } from "node:fs";
29
+ var leadingInteger = (text = "") => Number(/^\s*[+-]?\d+/u.exec(text)?.[0] ?? Number.NaN);
30
+ var parseCell = (value = "") => {
31
+ const parts = value.toLowerCase().split("x");
32
+ if (parts.length !== 2) {
33
+ fail(`cell must be WxH, got: '${value}'`);
34
+ }
35
+ const width = leadingInteger(parts[0]);
36
+ const height = leadingInteger(parts[1]);
37
+ if (!Number.isFinite(width) || !Number.isFinite(height)) {
38
+ fail(`cell must be WxH integers, got: '${value}'`);
39
+ }
40
+ const cell = [width, height];
41
+ return cell;
42
+ };
43
+ var readContract = (path = "") => {
44
+ if (path === "") {
45
+ failUsage("--contract is required");
46
+ }
47
+ return loadSizeContract(parseJsonText(readFileSync(path, "utf-8")), path);
48
+ };
49
+ var run = (argv) => {
50
+ main(() => {
51
+ const args = parseArgs([...argv], {
52
+ booleans: ["strict"],
53
+ values: [
54
+ "action",
55
+ "anchor-policy",
56
+ "cell",
57
+ "contract",
58
+ "direction",
59
+ "frame-glob",
60
+ "name",
61
+ "out",
62
+ "pivot",
63
+ "source",
64
+ "stage"
65
+ ]
66
+ });
67
+ const audit = () => {
68
+ const source = getString(args, "source") ?? "";
69
+ if (source === "") {
70
+ failUsage("--source is required");
71
+ }
72
+ const contract = readContract(getString(args, "contract"));
73
+ const report = auditSizeContract(source, contract, {
74
+ frameGlob: getString(args, "frame-glob") ?? "frame-*.png",
75
+ stage: getString(args, "stage") ?? "runtime"
76
+ });
77
+ const out = getString(args, "out") ?? "";
78
+ if (out !== "") {
79
+ writeJsonFile(out, report);
80
+ }
81
+ console.log(toPythonJson(report));
82
+ if (getFlag(args, "strict") && report.status !== "pass") {
83
+ process.exit(1);
84
+ }
85
+ };
86
+ const derive = () => {
87
+ const source = getString(args, "source") ?? "";
88
+ const out = getString(args, "out") ?? "";
89
+ if (source === "") {
90
+ failUsage("--source is required");
91
+ }
92
+ if (out === "") {
93
+ failUsage("--out is required");
94
+ }
95
+ const contract = deriveSizeContract(source, {
96
+ action: getString(args, "action") ?? null,
97
+ anchorPolicy: getString(args, "anchor-policy") ?? "grounded",
98
+ cellSize: parseCell(getString(args, "cell") ?? `${FRAME_WIDTH}x${FRAME_HEIGHT}`),
99
+ direction: getString(args, "direction") ?? null,
100
+ frameGlob: getString(args, "frame-glob") ?? "frame-*.png",
101
+ name: getString(args, "name") ?? null,
102
+ pivot: getString(args, "pivot") ?? "base-center"
103
+ });
104
+ writeJsonFile(out, contract);
105
+ console.log(out);
106
+ };
107
+ const prompt = () => {
108
+ const contract = readContract(getString(args, "contract"));
109
+ for (const line of promptGuidanceForContract(contract)) {
110
+ console.log(`- ${line}`);
111
+ }
112
+ };
113
+ const mode = (/* @__PURE__ */ new Map([
114
+ ["audit", audit],
115
+ ["derive", derive],
116
+ ["prompt", prompt]
117
+ ])).get(args.positionals[0] ?? "");
118
+ if (mode === void 0) {
119
+ failUsage("Usage: vg asset size-contract <derive|audit|prompt> ...");
120
+ }
121
+ mode?.();
122
+ });
123
+ };
124
+ export {
125
+ run
126
+ };