@pixelvibing/cli 0.12.0 → 0.14.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.
@@ -520,12 +520,17 @@ class TooFewCredits extends Error {
520
520
  this.credits = credits;
521
521
  }
522
522
  }
523
- function costIn(prices, kind, quality, frames) {
523
+ function costIn(prices, kind) {
524
524
  const price = prices.kinds[kind];
525
525
  if (price === void 0) return null;
526
- if ("credits" in price) return price.credits;
527
- if ("byFrames" in price) return price.byFrames[String(frames ?? 8)] ?? null;
528
- return price.byQuality[quality ?? "high"] ?? null;
526
+ return "credits" in price ? price.credits : price.upTo;
527
+ }
528
+ function costWords(prices, kind) {
529
+ const price = prices.kinds[kind];
530
+ if (price === void 0) return null;
531
+ const most = "credits" in price ? price.credits : price.upTo;
532
+ const credits = `${most} credit${most === 1 ? "" : "s"}`;
533
+ return "credits" in price ? credits : `up to ${credits}, what it does not use given back`;
529
534
  }
530
535
  const id = (value) => encodeURIComponent(value);
531
536
  function createWebApi(fetcher = (input, init2) => fetch(input, init2), base = API_BASE) {
@@ -3678,22 +3683,23 @@ function jobDelay(elapsedMs) {
3678
3683
  return 1e4;
3679
3684
  }
3680
3685
  const jobEnded = (job) => job.state === "done" || job.state === "failed";
3681
- function jobWords(job) {
3686
+ function jobStage(job) {
3687
+ if (job.progress !== void 0) return job.progress.stage;
3682
3688
  switch (job.state) {
3683
3689
  case "queued":
3684
- return job.attempts > 0 ? "waiting to be tried again" : "waiting in line";
3690
+ return job.attempts > 0 ? "waiting" : "queued";
3685
3691
  case "running":
3686
- return "being drawn";
3687
- case "done":
3688
- return "done";
3689
- case "failed":
3690
- return job.reason === null ? "failed" : `failed: ${job.reason}`;
3692
+ return "generating";
3693
+ default:
3694
+ return job.state;
3691
3695
  }
3692
3696
  }
3697
+ function jobWords(job) {
3698
+ const stage = jobStage(job);
3699
+ return stage === "failed" && job.reason !== null ? `failed: ${job.reason}` : stage;
3700
+ }
3693
3701
  function costOf(prices, request) {
3694
- const quality = request.body.quality;
3695
- const frames = request.body.frameCount;
3696
- return costIn(prices, request.kind, typeof quality === "string" ? quality : void 0, typeof frames === "number" ? frames : void 0);
3702
+ return costIn(prices, request.kind);
3697
3703
  }
3698
3704
  async function startGeneration(api, project, request) {
3699
3705
  const ids = {};
@@ -3833,8 +3839,8 @@ function sentSketch(sketch, description) {
3833
3839
  function sketchSendProblem(sketch, description) {
3834
3840
  return sketchProblem(sentSketch(sketch, description));
3835
3841
  }
3836
- function sketchBody(sketch, description, quality) {
3837
- return { ...sentSketch(sketch, description), quality };
3842
+ function sketchBody(sketch, description) {
3843
+ return { ...sentSketch(sketch, description) };
3838
3844
  }
3839
3845
  const LARGEST_FOOTPRINT = {
3840
3846
  cols: Math.min(Math.floor(WINDOW_PX.width / SCALES.at(-1)), Math.floor(MAX_ASSEMBLED_PX / TILE_SIZE)),
@@ -3861,7 +3867,6 @@ const MAX_CELL = 16;
3861
3867
  const MIN_CELL = 8;
3862
3868
  const ROUTE_MAX_EDGE = 3840;
3863
3869
  const ROUTE_MAX_PIXELS = 8294400;
3864
- const DEFAULT_QUALITY = "medium";
3865
3870
  const ROUTE_MIN_PIXELS = 655360;
3866
3871
  const ROUTE_STEP = 16;
3867
3872
  function gridForCells(cols, rows, cellsPerTile = CELLS_PER_TILE) {
@@ -3892,10 +3897,6 @@ function designCanvas(tiles) {
3892
3897
  if (scale === null) return null;
3893
3898
  return { cols: tiles.cols, rows: tiles.rows, scale, width: tiles.cols * scale, height: tiles.rows * scale };
3894
3899
  }
3895
- const EDIT_QUALITIES = ["low", "medium", "high", "xhigh", "max"];
3896
- function isEditQuality(value) {
3897
- return typeof value === "string" && EDIT_QUALITIES.includes(value);
3898
- }
3899
3900
  const GENERATED = {
3900
3901
  object: { references: 8, words: "an object" },
3901
3902
  creature: { references: 3, words: "a creature" },
@@ -4004,8 +4005,8 @@ async function requestOf(context, kind, args) {
4004
4005
  const instruction = stringOf(args, "instruction")?.trim() ?? "";
4005
4006
  const set = kind === "hud" || kind === "icons";
4006
4007
  if (instruction === "" && !set) throw new CliError("say what to make with --instruction");
4007
- const quality = stringOf(args, "quality") ?? DEFAULT_QUALITY;
4008
- if (!isEditQuality(quality)) throw new CliError(`--quality is one of ${EDIT_QUALITIES.join(", ")}`);
4008
+ if (stringOf(args, "quality") !== void 0)
4009
+ context.io.warn("--quality is the platform's to choose now: it draws each asset at the quality it needs, and nothing was sent for it.\n");
4009
4010
  const paths = stringsOf(args, "reference");
4010
4011
  if (paths.length > known.references)
4011
4012
  throw new CliError(known.references === 0 ? `${known.words} takes no reference` : `${known.words} takes at most ${known.references} references`);
@@ -4017,7 +4018,7 @@ async function requestOf(context, kind, args) {
4017
4018
  for (const path of paths) styles.push(await referenceOf(context, path));
4018
4019
  return {
4019
4020
  kind,
4020
- body: sketchBody(sketch, instruction, quality),
4021
+ body: sketchBody(sketch, instruction),
4021
4022
  ...styles.length > 0 ? { images: { references: styles } } : {},
4022
4023
  words: `${words2}${styles.length > 0 ? `, in the style of ${styles.length} reference${styles.length === 1 ? "" : "s"}` : ""}: ${instruction}`
4023
4024
  };
@@ -4026,14 +4027,14 @@ async function requestOf(context, kind, args) {
4026
4027
  if (set) {
4027
4028
  const { fields, words: words2 } = interfaceFields(kind, args);
4028
4029
  if (stringOf(args, "tiles") !== void 0) throw new CliError("--tiles is a level design's");
4029
- const body2 = { ...fields, ...instruction === "" ? {} : { instruction }, quality };
4030
+ const body2 = { ...fields, ...instruction === "" ? {} : { instruction } };
4030
4031
  return { kind, body: body2, words: instruction === "" ? words2 : `${words2}; ${instruction}` };
4031
4032
  }
4032
4033
  for (const flag of ["pieces", "names", "purpose"])
4033
4034
  if (stringOf(args, flag) !== void 0) throw new CliError(`--${flag} is ${flag === "pieces" ? "a HUD set's" : "an icon set's"}`);
4034
4035
  const references = [];
4035
4036
  for (const path of paths) references.push(await referenceOf(context, path));
4036
- const body = { instruction, quality };
4037
+ const body = { instruction };
4037
4038
  let words = `${known.words}: ${instruction}`;
4038
4039
  if (kind === "object") {
4039
4040
  const footprint = sizeOf(stringOf(args, "size") ?? "1x1", "--size");
@@ -4054,7 +4055,7 @@ async function requestOf(context, kind, args) {
4054
4055
  }
4055
4056
  async function confirmed(context, platform, what, cost, yes) {
4056
4057
  const credits = (await platform.web.billing()).credits;
4057
- const priced = cost === null ? "at a cost the platform will say" : `for ${cost} credit${cost === 1 ? "" : "s"}`;
4058
+ const priced = cost === null ? "at a cost the platform will say" : `for ${cost}`;
4058
4059
  context.io.warn(`Making ${what}, ${priced}; the account has ${credits}.
4059
4060
  `);
4060
4061
  if (yes) return;
@@ -4078,7 +4079,7 @@ async function followed(context, platform, jobId) {
4078
4079
  const generate = {
4079
4080
  name: "generate",
4080
4081
  summary: "Generate an object, a creature, a level design, a HUD set, icons, a HUD mockup or a UI sketch on the platform, then pull it",
4081
- usage: "<object|creature|level-design|hud|icons|hud-mockup|ui-sketch> [--instruction <text>] [--size <c>x<r>|<px>] [--tiles <c>x<r>] [--pieces <list>] [--names <list>] [--purpose skill|item] [--sketch <json>] [--reference <png>]… [--quality <q>] [--yes]",
4082
+ usage: "<object|creature|level-design|hud|icons|hud-mockup|ui-sketch> [--instruction <text>] [--size <c>x<r>|<px>] [--tiles <c>x<r>] [--pieces <list>] [--names <list>] [--purpose skill|item] [--sketch <json>] [--reference <png>]… [--yes]",
4082
4083
  options: {
4083
4084
  instruction: {
4084
4085
  type: "string",
@@ -4100,7 +4101,7 @@ const generate = {
4100
4101
  description: "a UI sketch's file: { canvas: { width, height }, shapes: [{ label, kind, x, y, width, height, radius?, sides?, caption?, note?, border?, hollow? }] }"
4101
4102
  },
4102
4103
  reference: { type: "string", multiple: true, value: "<png>", description: "an image to draw from" },
4103
- quality: { type: "string", value: "<quality>", description: `${EDIT_QUALITIES.join(", ")}; ${DEFAULT_QUALITY} unless given` },
4104
+ quality: { type: "string", value: "<quality>", description: "the platform's to choose now; ignored, and said so" },
4104
4105
  yes: { type: "boolean", short: "y", description: "start it without asking, once the cost is said" },
4105
4106
  as: { type: "string", value: "<name>", description: "land it under this name instead of the platform's" },
4106
4107
  aside: { type: "boolean", description: "keep a folder's own map and art under pixelvibing/before-platform/, and write it from the platform" }
@@ -4113,8 +4114,9 @@ const generate = {
4113
4114
  const request = await requestOf(context, kind, args);
4114
4115
  await checkFolder(local, flagOf(args, "aside"));
4115
4116
  const platform = await signedIn(context);
4116
- const cost = costOf(await platform.web.prices(), request);
4117
- await confirmed(context, platform, request.words, cost, flagOf(args, "yes"));
4117
+ const prices = await platform.web.prices();
4118
+ const cost = costOf(prices, request);
4119
+ await confirmed(context, platform, request.words, costWords(prices, request.kind), flagOf(args, "yes"));
4118
4120
  const jobId = await paying(platform, () => startGeneration(platform.web, project, request));
4119
4121
  context.io.warn(`Started the job ${jobId}.
4120
4122
  `);
@@ -4284,7 +4286,7 @@ const guideRevise = {
4284
4286
  if (instruction === "") throw new CliError("say what to change in the style guide");
4285
4287
  if (!flagOf(args, "force") && await unpushed(local)) throw new CliError(CHANGED);
4286
4288
  const platform = await signedIn(context);
4287
- const cost = costIn(await platform.web.prices(), GUIDE_KIND);
4289
+ const cost = costWords(await platform.web.prices(), GUIDE_KIND);
4288
4290
  await confirmed(context, platform, `a revision of the style guide: ${instruction}`, cost, flagOf(args, "yes"));
4289
4291
  const jobId = await paying(platform, () => platform.web.reviseGuide(project, instruction));
4290
4292
  context.io.warn(`Started the job ${jobId}.
@@ -4577,7 +4579,7 @@ const move = {
4577
4579
  );
4578
4580
  }
4579
4581
  };
4580
- const version = "0.12.0";
4582
+ const version = "0.14.0";
4581
4583
  const manifest = {
4582
4584
  version
4583
4585
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixelvibing/cli",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "PixelVibing: pixel art game assets from the command line, and the Skills that teach coding assistants to make them.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://pixelvibing.com",
@@ -47,8 +47,8 @@ Each generation spends the account's credits.
47
47
  - **The options.**
48
48
  - `--size` is an object's footprint in whole tiles, `1x1` unless given.
49
49
  - `--tiles` is how many tiles a level design is across, `6x4` unless given.
50
- - `--quality` is `low`, `medium` (the default), `high`, `xhigh` or `max`; the higher,
51
- the dearer.
50
+ - No quality is given: the platform draws each asset at the quality it needs. The cost
51
+ printed is the most it may take, and what it does not use is given back.
52
52
  - `--reference` is a PNG to draw from, repeated for several: at most 8 for an object,
53
53
  3 for a creature, a level design, a HUD mockup or a UI sketch, none for a HUD set or icons. A UI
54
54
  sketch's references are a style to follow (frames, materials, a way of drawing), never what to draw.