@makemidas/cli 0.7.0 → 0.9.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/README.md CHANGED
@@ -48,6 +48,8 @@ makemidas film new "a 15-second social video for our mugs" --style social --max-
48
48
  | `template save\|update\|delete …` | Keep your own page as a template with fill-in fields |
49
49
  | `film new "<brief>"`, `film get/approve/redo/download …` | Film projects: script and storyboard, approved frames and clips, an assembled film ([below](#film-projects)) |
50
50
  | `brands [<id>\|default]`, `characters`, `assets [--q] [--kind]` | Saved brands (with their guidelines), characters and asset-library files to build on |
51
+ | `characters create "<name>" <image>` (or `--from <generationId> [--image n]`), `characters add <id> <image>` | Save a character from a JPG, PNG or WebP or one of your generated images (`--description` for its notes); up to 20 characters, 10 images each. Use it with `--character <id>` |
52
+ | `examples [words] [--kind] [-m <model>] [--limit 1-20]` | Real results with the model and the exact prompt that made each; free |
51
53
  | `assets upload <file\|url>… [--name] [--tag t]`, `assets delete <id>` | Keep files in the asset library, or remove one |
52
54
  | `get <id> [--wait]` | Fetch a generation and save its files |
53
55
  | `list [--limit n] [--before t]` | Recent generations |
@@ -55,7 +57,7 @@ makemidas film new "a 15-second social video for our mugs" --style social --max-
55
57
  | `credits` | Balance, plan, expiring credits |
56
58
  | `credits activity [--generation <id>] [--limit n] [--before t]` | Grants, charges and refunds, newest first; with `--generation`, what one generation charged and refunded |
57
59
  | `credits buy` (or `credits link`) | Links to buy a plan or credit pack, with prices; opens nothing |
58
- | `models [image\|video\|audio\|transcription\|edit]` | Model ids, options and credit prices |
60
+ | `models [image\|video\|audio\|transcription\|edit] [--for <use>]` | Model ids, options and credit prices; `--for draft\|final\|edit\|text\|references\|first-last\|sound` lists the image and video models good for that job |
59
61
  | `models <id>` | One model: options, defaults, voices, prices and an example request |
60
62
  | `estimate <command> "<prompt>"\|<file>` | Price a request without charging; `<command>` is `image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`, `upscale`, `upscale-video` or `avatar`, with that command's options |
61
63
  | `frames <video\|url> [--count 1-16] [--width 120-1920]` | Stills evenly spread over a clip and one contact sheet (`<name>-frames/sheet.jpg`), made on your computer with FFmpeg; free, nothing is sent |
@@ -108,12 +110,14 @@ stdin is not a terminal), 3 not signed in, 4 not enough credits, a plan
108
110
  limit or busy (also over `--max-credits`), 5 generation failed (credits
109
111
  refunded), 6 network or server error, 7 still rendering.
110
112
 
111
- Every generating request carries an `Idempotency-Key`. When its answer is
112
- lost (a dropped connection, a server error), the CLI asks again with the
113
- same key after 2, 5 and 10 seconds; MakeMidas answers the generation the
114
- first attempt started, so nothing is made or charged twice. Exit 6 after
115
- that means it still had no answer: look for the generation with
116
- `makemidas list` before running the command again.
113
+ Every request that spends credits carries an `Idempotency-Key`: generating,
114
+ `compare`, template videos (`render --video`, `html --video`) and film
115
+ `approve` and `redo`. When its answer is lost (a dropped connection, a
116
+ server error), the CLI asks again with the same key after 2, 5 and 10
117
+ seconds; MakeMidas answers what the first attempt made, so nothing is made
118
+ or charged twice. Exit 6 after that means it still had no answer: look for
119
+ it with `makemidas list` (or `makemidas film get <id>`) before running the
120
+ command again.
117
121
 
118
122
  ## Talking avatars
119
123
 
package/dist/api.js CHANGED
@@ -12,6 +12,16 @@ export const KINDS = [
12
12
  'transcription',
13
13
  'edit',
14
14
  ];
15
+ /** What `models --for` takes (server 0.7: `GET /models?use=`). */
16
+ export const MODEL_USES = [
17
+ 'draft',
18
+ 'final',
19
+ 'edit',
20
+ 'text',
21
+ 'references',
22
+ 'first-last',
23
+ 'sound',
24
+ ];
15
25
  const CONTENT_TYPES = {
16
26
  '.jpg': 'image/jpeg',
17
27
  '.jpeg': 'image/jpeg',
@@ -153,9 +163,13 @@ export class Api {
153
163
  credits() {
154
164
  return this.json('/credits');
155
165
  }
156
- async models(kind) {
157
- return (await this.json('/models', { query: { kind } }))
158
- .models;
166
+ async models(kind, use) {
167
+ return (await this.json('/models', { query: { kind, use } })).models;
168
+ }
169
+ /** Real results with their model and prompt; free. */
170
+ async examples(query) {
171
+ return (await this.json('/examples', { query }))
172
+ .examples;
159
173
  }
160
174
  /** One model; ids hold a slash, which is sent encoded. */
161
175
  modelDetails(id) {
@@ -171,6 +185,49 @@ export class Api {
171
185
  async characters() {
172
186
  return (await this.json('/characters')).characters;
173
187
  }
188
+ /** The request body for a character image: multipart file or JSON. */
189
+ async characterBody(source, fields) {
190
+ if ('generationId' in source) {
191
+ return {
192
+ method: 'POST',
193
+ json: {
194
+ ...fields,
195
+ generationId: source.generationId,
196
+ index: source.index ?? 0,
197
+ },
198
+ };
199
+ }
200
+ const type = CONTENT_TYPES[extname(source.file).toLowerCase()];
201
+ if (!type) {
202
+ throw new CliError(`${source.file}: a character image is a JPG, PNG or WebP file.`, EXIT.USAGE, 'invalid_file');
203
+ }
204
+ let bytes;
205
+ try {
206
+ bytes = new Uint8Array(await readFile(source.file));
207
+ }
208
+ catch {
209
+ throw new CliError(`Can't read ${source.file}`, EXIT.USAGE, 'invalid_file');
210
+ }
211
+ const form = new FormData();
212
+ for (const [key, value] of Object.entries(fields))
213
+ form.append(key, value);
214
+ form.append('file', new Blob([bytes], { type }), basename(source.file));
215
+ return { method: 'POST', form };
216
+ }
217
+ /** Save a new character from one image (up to 20 characters). */
218
+ async createCharacter(name, source, description) {
219
+ const body = await this.characterBody(source, {
220
+ name,
221
+ ...(description ? { description } : {}),
222
+ });
223
+ return (await this.json('/characters', body))
224
+ .character;
225
+ }
226
+ /** Add one image to a character (up to 10). */
227
+ async addCharacterImage(id, source) {
228
+ const body = await this.characterBody(source, {});
229
+ return (await this.json(`/characters/${encodeURIComponent(id)}/images`, body)).character;
230
+ }
174
231
  /** A page of the asset library, newest first. */
175
232
  assets(query) {
176
233
  return this.json('/assets', {
@@ -262,12 +319,18 @@ export class Api {
262
319
  * again answers the generation the first attempt started instead of
263
320
  * starting, and charging for, another.
264
321
  */
265
- async generate(input, key = randomUUID()) {
322
+ /**
323
+ * POST a request that spends credits with an Idempotency-Key, and send it
324
+ * again with the same key when the answer is lost, so the server answers
325
+ * what the first one made instead of charging twice. `lookup` says where
326
+ * to look when every try failed.
327
+ */
328
+ async postOnce(path, json, key, lookup) {
266
329
  for (let attempt = 0;; attempt++) {
267
330
  try {
268
- return await this.json('/generations', {
331
+ return await this.json(path, {
269
332
  method: 'POST',
270
- json: input,
333
+ json,
271
334
  headers: { 'Idempotency-Key': key },
272
335
  });
273
336
  }
@@ -277,13 +340,16 @@ export class Api {
277
340
  const delay = GENERATE_RETRY_MS[attempt];
278
341
  if (delay === undefined) {
279
342
  const last = error;
280
- throw new CliError(`${last.message}. It may have started anyway: look for it with \`makemidas list\` before running this again.`, last.exitCode, last.code, last.details);
343
+ throw new CliError(`${last.message}. It may have started anyway: ${lookup} before running this again.`, last.exitCode, last.code, last.details);
281
344
  }
282
345
  log(`No answer yet (${error.message}); asking again in ${delay / 1000} s with the same request key, so nothing is charged twice…`);
283
346
  await this.sleep(delay);
284
347
  }
285
348
  }
286
349
  }
350
+ generate(input, key = randomUUID()) {
351
+ return this.postOnce('/generations', input, key, 'look for it with `makemidas list`');
352
+ }
287
353
  /** Price a request without charging or creating anything. */
288
354
  estimate(input) {
289
355
  return this.json('/generations/estimate', {
@@ -297,11 +363,8 @@ export class Api {
297
363
  });
298
364
  }
299
365
  /** Run one prompt on 2-4 image models at once. */
300
- compare(input) {
301
- return this.json('/generations/compare', {
302
- method: 'POST',
303
- json: input,
304
- });
366
+ compare(input, key = randomUUID()) {
367
+ return this.postOnce('/generations/compare', input, key, 'look for them with `makemidas list`');
305
368
  }
306
369
  /** Delete a finished or failed generation and its files. */
307
370
  deleteGeneration(id) {
@@ -387,11 +450,8 @@ export class Api {
387
450
  return this.json('/renders', { method: 'POST', json: input });
388
451
  }
389
452
  /** A video; it answers while rendering, so read the generation until done. */
390
- videoRender(input) {
391
- return this.json('/video-renders', {
392
- method: 'POST',
393
- json: input,
394
- });
453
+ videoRender(input, key = randomUUID()) {
454
+ return this.postOnce('/video-renders', input, key, 'look for it with `makemidas list`');
395
455
  }
396
456
  // ---------------------------------------------------------------- films
397
457
  async films() {
@@ -427,14 +487,11 @@ export class Api {
427
487
  json: input,
428
488
  });
429
489
  }
430
- approveFilm(id, input) {
431
- return this.json(`/films/${encodeURIComponent(id)}/approve`, {
432
- method: 'POST',
433
- json: input,
434
- });
490
+ approveFilm(id, input, key = randomUUID()) {
491
+ return this.postOnce(`/films/${encodeURIComponent(id)}/approve`, input, key, `check it with \`makemidas film get ${id}\``);
435
492
  }
436
- redoShot(id, shotId, input) {
437
- return this.json(`/films/${encodeURIComponent(id)}/shots/${encodeURIComponent(shotId)}/redo`, { method: 'POST', json: input });
493
+ redoShot(id, shotId, input, key = randomUUID()) {
494
+ return this.postOnce(`/films/${encodeURIComponent(id)}/shots/${encodeURIComponent(shotId)}/redo`, input, key, `check it with \`makemidas film get ${id}\``);
438
495
  }
439
496
  resumeFilm(id) {
440
497
  return this.json(`/films/${encodeURIComponent(id)}/resume`, {
package/dist/args.js CHANGED
@@ -86,6 +86,9 @@ export function parse(argv) {
86
86
  'lower-thirds': { type: 'string' },
87
87
  characters: { type: 'string' },
88
88
  'avatar-model': { type: 'string' },
89
+ for: { type: 'string' },
90
+ from: { type: 'string' },
91
+ image: { type: 'string' },
89
92
  },
90
93
  });
91
94
  }
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Api, KINDS } from "./api.js";
2
+ import { Api, KINDS, MODEL_USES, } from "./api.js";
3
3
  import { audioInput, compareModels, compareOptions, editInput, filmSeconds, filmSettings, feedbackKind, generationInput, intOption, parse, renderBrand, renderOptions, sourceArg, templateValues, transcriptionInput, usageError, } from "./args.js";
4
4
  import * as commands from "./commands.js";
5
5
  import { filmEdit } from "./film-edit.js";
@@ -33,6 +33,13 @@ Usage:
33
33
  makemidas delete <id> [--yes] Delete a generation and its files
34
34
  makemidas brands [<id>|default] Saved brands, or one brand's guidelines
35
35
  makemidas characters Saved characters
36
+ makemidas characters create "<name>" <image>
37
+ Save a character from a JPG, PNG or WebP, or
38
+ --from <generationId> [--image n] for a
39
+ generated one (--description "notes")
40
+ makemidas characters add <id> <image> Add an image (or --from <generationId>)
41
+ makemidas examples [words] Real results with their model and prompt
42
+ (--kind, -m <model>, --limit 1-20); free
36
43
  makemidas assets [--q words] [--kind image|video|audio]
37
44
  Search the asset library
38
45
  makemidas assets upload <file|url>… Keep files in the asset library (--name, --tag)
@@ -47,7 +54,10 @@ Usage:
47
54
  video, music, sfx, speech, transcribe,
48
55
  remove-bg, upscale, upscale-video or avatar
49
56
  makemidas models [<kind>] Models, options and credit prices; kind is
50
- image, video, audio, transcription or edit
57
+ image, video, audio, transcription or edit;
58
+ --for draft|final|edit|text|references|
59
+ first-last|sound picks image and video models
60
+ by the job
51
61
  makemidas models <id> One model: options, defaults, prices
52
62
  makemidas frames <video|url> Stills and a contact sheet of a clip, made
53
63
  here with FFmpeg; free (--count 1-16,
@@ -270,6 +280,20 @@ function avatarSources(rest, character, command) {
270
280
  }
271
281
  return [rest[0], rest[1]];
272
282
  }
283
+ /** A character image: a local file, or `--from <generationId> [--image n]`. */
284
+ function characterSource(file, v) {
285
+ if (v.from) {
286
+ if (file)
287
+ throw usageError('Give a file or --from, not both.');
288
+ const image = intOption(v.image, 'image', 1, 16) ?? 1;
289
+ return { generationId: v.from, index: image - 1 };
290
+ }
291
+ if (v.image !== undefined)
292
+ throw usageError('--image goes with --from.');
293
+ if (!file)
294
+ throw usageError('Give an image file or --from <generationId>.');
295
+ return { file };
296
+ }
273
297
  /** Name, description and canvas of a saved template, from the options. */
274
298
  function savedTemplateRest(v) {
275
299
  const width = intOption(v.width, 'width', 200, 2048);
@@ -435,7 +459,34 @@ async function main(argv) {
435
459
  case 'brand':
436
460
  return commands.brands(api, g, rest[0]);
437
461
  case 'characters':
462
+ case 'character': {
463
+ const [sub, ...args] = rest;
464
+ if (sub === 'create' || sub === 'new') {
465
+ const [name, file] = args;
466
+ if (!name?.trim() || args.length > 2) {
467
+ throw usageError('Give a name and one image: `makemidas characters create "Mia" mia.png`, or `--from <generationId>`.');
468
+ }
469
+ return commands.characterCreate(api, g, name, characterSource(file, v), v.description);
470
+ }
471
+ if (sub === 'add') {
472
+ const [id, file] = args;
473
+ if (!id || args.length > 2) {
474
+ throw usageError('Give the character id and one image: `makemidas characters add <id> pose.png`, or `--from <generationId>`.');
475
+ }
476
+ return commands.characterAdd(api, g, id, characterSource(file, v));
477
+ }
478
+ if (sub) {
479
+ throw usageError('Use `characters`, `characters create` or `characters add`.');
480
+ }
438
481
  return commands.characters(api, g);
482
+ }
483
+ case 'examples':
484
+ return commands.examples(api, g, {
485
+ query: rest.join(' ').trim() || undefined,
486
+ kind: v.kind,
487
+ model: v.model,
488
+ limit: intOption(v.limit, 'limit', 1, 20),
489
+ });
439
490
  case 'assets':
440
491
  if (rest[0] === 'upload' || rest[0] === 'add') {
441
492
  return templates.assetUpload(api, g, rest.slice(1), {
@@ -519,7 +570,10 @@ async function main(argv) {
519
570
  if (kind && !isKind(kind)) {
520
571
  throw usageError(`--kind must be ${KINDS.join(', ')}.`);
521
572
  }
522
- return commands.models(api, g, kind);
573
+ if (v.for && !MODEL_USES.includes(v.for)) {
574
+ throw usageError(`--for must be ${MODEL_USES.join(', ')}.`);
575
+ }
576
+ return commands.models(api, g, kind, v.for);
523
577
  }
524
578
  case 'film':
525
579
  case 'films': {
package/dist/commands.js CHANGED
@@ -401,14 +401,19 @@ export async function creditActivity(api, g, opts) {
401
401
  print(`Older: makemidas credits activity --before ${nextBefore}`);
402
402
  }
403
403
  }
404
- export async function models(api, g, kind) {
405
- const result = await api.models(kind);
404
+ export async function models(api, g, kind, use) {
405
+ const result = await api.models(kind, use);
406
406
  if (g.json) {
407
407
  printJson({ models: result });
408
408
  return;
409
409
  }
410
+ if (use && !result.length) {
411
+ print(`No ${kind ? `${kind} ` : ''}models listed for ${use}.`);
412
+ return;
413
+ }
410
414
  for (const model of result) {
411
- print(`${headline(model)}: ${prices(model)}`);
415
+ const uses = model.uses?.length ? ` [${model.uses.join(', ')}]` : '';
416
+ print(`${headline(model)}: ${prices(model)}${uses}`);
412
417
  }
413
418
  }
414
419
  function headline(model) {
@@ -704,6 +709,38 @@ export async function brands(api, g, id) {
704
709
  print(`${brand.id} ${brand.isDefault ? '*' : ' '} ${brand.name}${palette ? ` ${palette}` : ''}`);
705
710
  }
706
711
  }
712
+ /** Real results with their model and exact prompt, to start from. */
713
+ export async function examples(api, g, query) {
714
+ const list = await api.examples(query);
715
+ if (g.json)
716
+ return printJson({ examples: list });
717
+ if (!list.length) {
718
+ return print('No examples match. Try fewer words, another kind, or no filter.');
719
+ }
720
+ for (const e of list) {
721
+ print(`${e.id} ${e.kind} ${e.model} (${e.modelLabel})`);
722
+ print(` ${e.prompt.replace(/\s+/g, ' ')}`);
723
+ print(` ${e.url}`);
724
+ }
725
+ }
726
+ function characterLine(c) {
727
+ return `${c.id} ${c.name} (${c.imageCount} image${c.imageCount === 1 ? '' : 's'})${c.description ? `: ${c.description}` : ''}`;
728
+ }
729
+ /** Save a new character from a local image or a generated one. */
730
+ export async function characterCreate(api, g, name, source, description) {
731
+ const character = await api.createCharacter(name, source, description);
732
+ if (g.json)
733
+ return printJson({ character });
734
+ log(`Saved character ${character.name}; use it with --character ${character.id}`);
735
+ print(characterLine(character));
736
+ }
737
+ /** Add one image to a saved character. */
738
+ export async function characterAdd(api, g, id, source) {
739
+ const character = await api.addCharacterImage(id, source);
740
+ if (g.json)
741
+ return printJson({ character });
742
+ print(characterLine(character));
743
+ }
707
744
  export async function characters(api, g) {
708
745
  const list = await api.characters();
709
746
  if (g.json)
@@ -711,7 +748,7 @@ export async function characters(api, g) {
711
748
  if (!list.length)
712
749
  return print('No saved characters (add one on makemidas.com/dashboard/characters).');
713
750
  for (const c of list) {
714
- print(`${c.id} ${c.name} (${c.imageCount} image${c.imageCount === 1 ? '' : 's'})${c.description ? `: ${c.description}` : ''}`);
751
+ print(characterLine(c));
715
752
  }
716
753
  }
717
754
  export async function assets(api, g, query) {
package/dist/config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
2
2
  import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
- export const VERSION = '0.7.0';
4
+ export const VERSION = '0.9.0';
5
5
  export const USER_AGENT = `makemidas-cli/${VERSION}`;
6
6
  export const DEFAULT_BASE_URL = 'https://makemidas.com';
7
7
  export function resolveBaseUrl(flag) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makemidas/cli",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "AI image, video and audio generation CLI for AI agents (Claude Code, Cursor, Codex) and people: Nano Banana, GPT Image, Seedream, Seedance, Kling, Veo, Suno and more, plus talking avatars, HTML templates and short films, through MakeMidas.",
5
5
  "keywords": [
6
6
  "ai-image-generator",