@makemidas/cli 0.2.0 → 0.3.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 +66 -0
- package/dist/api.js +76 -1
- package/dist/args.js +71 -0
- package/dist/cli.js +118 -2
- package/dist/commands.js +47 -1
- package/dist/config.js +1 -1
- package/dist/films.js +357 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@ makemidas transcribe interview.m4a --format srt
|
|
|
37
37
|
| `upscale <image> [--scale 1\|2\|4\|8]` | Upscale an image (1 sharpens at the same size; default 2) |
|
|
38
38
|
| `upscale-video <video> [--resolution 1080P\|2K\|4K]` | Upscale an MP4 or MOV clip of up to 60 s (default 2K) |
|
|
39
39
|
| `compare "<prompt>" --models a,b[,c,d]` | One prompt on 2–4 image models, one image each |
|
|
40
|
+
| `film new "<brief>"`, `film get/approve/redo/download …` | Film projects: script and storyboard, approved frames and clips, an assembled film ([below](#film-projects)) |
|
|
41
|
+
| `brands [<id>\|default]`, `characters`, `assets [--q] [--kind]` | Saved brands (with their guidelines), characters and asset-library files to build on |
|
|
40
42
|
| `get <id> [--wait]` | Fetch a generation and save its files |
|
|
41
43
|
| `list [--limit n] [--before t]` | Recent generations |
|
|
42
44
|
| `delete <id> [--yes]` | Delete a finished or failed generation and its files (no refund) |
|
|
@@ -94,6 +96,70 @@ stdin is not a terminal), 3 not signed in, 4 not enough credits, a plan
|
|
|
94
96
|
limit or busy (also over `--max-credits`), 5 generation failed (credits
|
|
95
97
|
refunded), 6 network or server error, 7 still rendering.
|
|
96
98
|
|
|
99
|
+
## Brands, characters and the asset library
|
|
100
|
+
|
|
101
|
+
Images and videos can follow a saved brand and reuse saved characters and
|
|
102
|
+
library files:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
makemidas brands default # the brand's look and tone as text
|
|
106
|
+
makemidas image "our cold brew on a desk" --brand default --brand-logo
|
|
107
|
+
makemidas video "she waves at the camera" --character <id> -d 5
|
|
108
|
+
makemidas assets --q "product shot" --kind image
|
|
109
|
+
makemidas image "the same bottle on a beach" --ref asset:<id>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`--brand <id|default>` adds the brand's guidelines to the prompt (and, for
|
|
113
|
+
images, its style pictures as references; `--brand-logo` also sends its
|
|
114
|
+
logo). `--character <id>` sends the character's pictures as references.
|
|
115
|
+
`--ref asset:<id>` uses a file from the asset library like a local one.
|
|
116
|
+
|
|
117
|
+
## Film projects
|
|
118
|
+
|
|
119
|
+
A film project turns a brief into a short film: a text model you choose
|
|
120
|
+
writes the script and a storyboard of shots, an image model draws each
|
|
121
|
+
shot's first frame, a video model animates it, a voiceover model reads the
|
|
122
|
+
narration and a music model scores it, and MakeMidas assembles the film.
|
|
123
|
+
Each paid stage runs only at a price you approve, so an agent can show the
|
|
124
|
+
price and ask before it spends.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 1. Create it and write the storyboard (charged by the tokens it writes)
|
|
128
|
+
makemidas film new "A 20-second ad for our cold brew: a sleepy office wakes up" \
|
|
129
|
+
--seconds 20 --aspect 9:16 --max-credits 40
|
|
130
|
+
|
|
131
|
+
# 2. Read the storyboard, change it if you like, then approve the frames
|
|
132
|
+
makemidas film get <id>
|
|
133
|
+
makemidas film update <id> --file shots.json # optional
|
|
134
|
+
makemidas film approve <id> frames --quoted-credits <n> --wait
|
|
135
|
+
|
|
136
|
+
# 3. Check the frames, approve the clips, voiceover and music; it assembles
|
|
137
|
+
makemidas film approve <id> film --quoted-credits <n> --wait -o .
|
|
138
|
+
|
|
139
|
+
# Redo one piece, or take the pieces and cut it yourself
|
|
140
|
+
makemidas film redo <id> 2 clip --max-credits 40
|
|
141
|
+
makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- `approve`, `write` and `redo` need `--quoted-credits <n>` (the price `film
|
|
145
|
+
get` shows) or `--max-credits <n>`; without either they print the price
|
|
146
|
+
and exit 2. A changed price is refused (`price_changed`) and nothing is
|
|
147
|
+
charged.
|
|
148
|
+
- Settings: `--text-model`, `--video-model`, `-r`, `--frame-model`,
|
|
149
|
+
`--speech-model`, `--voice`, `--music-model <id|none>`, `--music-prompt`,
|
|
150
|
+
`--transition cut|fade|crossfade`, `--clip-audio`, `--brand <id|none>`. After
|
|
151
|
+
the film is approved only the voiceover model and voice can change.
|
|
152
|
+
- `--wait` follows the frames, the film and the assembly (`--timeout`,
|
|
153
|
+
default 15 minutes); it polls the assembly every 8 seconds, which keeps the
|
|
154
|
+
render moving. A paused project (out of credits) exits 4: top up, then
|
|
155
|
+
`makemidas film resume <id>`.
|
|
156
|
+
- `film download --pieces` saves every clip, voiceover and the music with a
|
|
157
|
+
`timeline.json` (start, duration and local file of each piece) for your own
|
|
158
|
+
ffmpeg cut or an agent's.
|
|
159
|
+
- The storyboard file for `film update --file` is a JSON list of shots (or
|
|
160
|
+
`{ "shots": [...] }`), each with `prompt` and `duration`, and optionally
|
|
161
|
+
`id` (keep a shot and its frame), `description`, `camera` and `voiceover`.
|
|
162
|
+
|
|
97
163
|
## Credits
|
|
98
164
|
|
|
99
165
|
Every generation spends credits at the same prices as the website. There
|
package/dist/api.js
CHANGED
|
@@ -127,8 +127,34 @@ export class Api {
|
|
|
127
127
|
modelDetails(id) {
|
|
128
128
|
return this.json(`/models/${encodeURIComponent(id)}`);
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
async brands() {
|
|
131
|
+
return (await this.json('/brands')).brands;
|
|
132
|
+
}
|
|
133
|
+
/** One brand; `default` is the default brand (or the only one). */
|
|
134
|
+
brand(id) {
|
|
135
|
+
return this.json(`/brands/${encodeURIComponent(id)}`);
|
|
136
|
+
}
|
|
137
|
+
async characters() {
|
|
138
|
+
return (await this.json('/characters')).characters;
|
|
139
|
+
}
|
|
140
|
+
/** A page of the asset library, newest first. */
|
|
141
|
+
assets(query) {
|
|
142
|
+
return this.json('/assets', {
|
|
143
|
+
query,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Upload a local image (or one downloaded from a URL) as a reference;
|
|
148
|
+
* `asset:<id>` uses a file from the asset library.
|
|
149
|
+
*/
|
|
131
150
|
async upload(source) {
|
|
151
|
+
if (source.startsWith('asset:')) {
|
|
152
|
+
const { id } = await this.json('/uploads', {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
json: { assetId: source.slice('asset:'.length) },
|
|
155
|
+
});
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
132
158
|
let bytes;
|
|
133
159
|
let type;
|
|
134
160
|
let name;
|
|
@@ -237,6 +263,55 @@ export class Api {
|
|
|
237
263
|
async list(query) {
|
|
238
264
|
return (await this.json('/generations', { query })).generations;
|
|
239
265
|
}
|
|
266
|
+
// ---------------------------------------------------------------- films
|
|
267
|
+
async films() {
|
|
268
|
+
return (await this.json('/films')).films;
|
|
269
|
+
}
|
|
270
|
+
film(id) {
|
|
271
|
+
return this.json(`/films/${encodeURIComponent(id)}`);
|
|
272
|
+
}
|
|
273
|
+
/** A new project from a brief; nothing is charged. */
|
|
274
|
+
createFilm(input) {
|
|
275
|
+
return this.json('/films', { method: 'POST', json: input });
|
|
276
|
+
}
|
|
277
|
+
updateFilm(id, input) {
|
|
278
|
+
return this.json(`/films/${encodeURIComponent(id)}`, {
|
|
279
|
+
method: 'PATCH',
|
|
280
|
+
json: input,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async deleteFilm(id) {
|
|
284
|
+
await this.request(`/films/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
285
|
+
}
|
|
286
|
+
/** The most writing the storyboard can cost. */
|
|
287
|
+
storyboardQuote(id, targetSeconds) {
|
|
288
|
+
return this.json(`/films/${encodeURIComponent(id)}/storyboard`, { query: { targetSeconds } });
|
|
289
|
+
}
|
|
290
|
+
writeStoryboard(id, input) {
|
|
291
|
+
return this.json(`/films/${encodeURIComponent(id)}/storyboard`, {
|
|
292
|
+
method: 'POST',
|
|
293
|
+
json: input,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
approveFilm(id, input) {
|
|
297
|
+
return this.json(`/films/${encodeURIComponent(id)}/approve`, {
|
|
298
|
+
method: 'POST',
|
|
299
|
+
json: input,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
redoShot(id, shotId, input) {
|
|
303
|
+
return this.json(`/films/${encodeURIComponent(id)}/shots/${encodeURIComponent(shotId)}/redo`, { method: 'POST', json: input });
|
|
304
|
+
}
|
|
305
|
+
resumeFilm(id) {
|
|
306
|
+
return this.json(`/films/${encodeURIComponent(id)}/resume`, {
|
|
307
|
+
method: 'POST',
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
assembleFilm(id) {
|
|
311
|
+
return this.json(`/films/${encodeURIComponent(id)}/assemble`, {
|
|
312
|
+
method: 'POST',
|
|
313
|
+
});
|
|
314
|
+
}
|
|
240
315
|
/** Download a signed output link. */
|
|
241
316
|
async download(url) {
|
|
242
317
|
let res;
|
package/dist/args.js
CHANGED
|
@@ -50,6 +50,23 @@ export function parse(argv) {
|
|
|
50
50
|
models: { type: 'string' },
|
|
51
51
|
generation: { type: 'string' },
|
|
52
52
|
yes: { type: 'boolean', short: 'y', default: false },
|
|
53
|
+
seconds: { type: 'string' },
|
|
54
|
+
brief: { type: 'string' },
|
|
55
|
+
'text-model': { type: 'string' },
|
|
56
|
+
'video-model': { type: 'string' },
|
|
57
|
+
'frame-model': { type: 'string' },
|
|
58
|
+
'speech-model': { type: 'string' },
|
|
59
|
+
'music-model': { type: 'string' },
|
|
60
|
+
'music-prompt': { type: 'string' },
|
|
61
|
+
transition: { type: 'string' },
|
|
62
|
+
brand: { type: 'string' },
|
|
63
|
+
'clip-audio': { type: 'boolean', default: false },
|
|
64
|
+
'no-write': { type: 'boolean', default: false },
|
|
65
|
+
file: { type: 'string' },
|
|
66
|
+
pieces: { type: 'boolean', default: false },
|
|
67
|
+
character: { type: 'string' },
|
|
68
|
+
'brand-logo': { type: 'boolean', default: false },
|
|
69
|
+
q: { type: 'string' },
|
|
53
70
|
},
|
|
54
71
|
});
|
|
55
72
|
}
|
|
@@ -98,6 +115,9 @@ const VISUAL_OPTIONS = [
|
|
|
98
115
|
'ref',
|
|
99
116
|
'frame-mode',
|
|
100
117
|
'audio',
|
|
118
|
+
'brand',
|
|
119
|
+
'brand-logo',
|
|
120
|
+
'character',
|
|
101
121
|
];
|
|
102
122
|
const MUSIC_OPTIONS = ['lyrics', 'title', 'instrumental'];
|
|
103
123
|
const SFX_OPTIONS = ['loop', 'bpm'];
|
|
@@ -122,7 +142,15 @@ export function generationInput(kind, prompt, v) {
|
|
|
122
142
|
...(v.resolution ? { resolution: v.resolution } : {}),
|
|
123
143
|
...(v.style ? { style: v.style } : {}),
|
|
124
144
|
...(v.enhance ? { enhance: true } : {}),
|
|
145
|
+
...(v.brand ? { brandId: v.brand } : {}),
|
|
146
|
+
...(v.character ? { characterId: v.character } : {}),
|
|
125
147
|
};
|
|
148
|
+
if (v['brand-logo']) {
|
|
149
|
+
if (kind !== 'image' || !v.brand) {
|
|
150
|
+
throw usageError('--brand-logo goes with --brand on images.');
|
|
151
|
+
}
|
|
152
|
+
input.brandLogo = true;
|
|
153
|
+
}
|
|
126
154
|
const count = intOption(v.count, 'count', 1, 4);
|
|
127
155
|
if (count)
|
|
128
156
|
input.count = count;
|
|
@@ -340,3 +368,46 @@ export function feedbackKind(value) {
|
|
|
340
368
|
}
|
|
341
369
|
return kind;
|
|
342
370
|
}
|
|
371
|
+
// ---------------------------------------------------------------- films
|
|
372
|
+
const TRANSITIONS = ['cut', 'fade', 'crossfade'];
|
|
373
|
+
/**
|
|
374
|
+
* Film settings from the command line. `none` turns music or the brand off;
|
|
375
|
+
* a voice of `default` uses the voiceover model's own.
|
|
376
|
+
*/
|
|
377
|
+
export function filmSettings(v) {
|
|
378
|
+
const settings = {};
|
|
379
|
+
if (v.aspect)
|
|
380
|
+
settings.aspectRatio = v.aspect;
|
|
381
|
+
if (v.resolution)
|
|
382
|
+
settings.resolution = v.resolution;
|
|
383
|
+
if (v['text-model'])
|
|
384
|
+
settings.textModel = v['text-model'];
|
|
385
|
+
if (v['video-model'])
|
|
386
|
+
settings.videoModel = v['video-model'];
|
|
387
|
+
if (v['frame-model'])
|
|
388
|
+
settings.frameModel = v['frame-model'];
|
|
389
|
+
if (v['speech-model'])
|
|
390
|
+
settings.speechModel = v['speech-model'];
|
|
391
|
+
if (v.voice)
|
|
392
|
+
settings.voice = v.voice === 'default' ? null : v.voice;
|
|
393
|
+
if (v['music-model']) {
|
|
394
|
+
settings.musicModel = v['music-model'] === 'none' ? null : v['music-model'];
|
|
395
|
+
}
|
|
396
|
+
if (v['music-prompt'])
|
|
397
|
+
settings.musicPrompt = v['music-prompt'];
|
|
398
|
+
if (v.brand)
|
|
399
|
+
settings.brandId = v.brand === 'none' ? null : v.brand;
|
|
400
|
+
if (v['clip-audio'])
|
|
401
|
+
settings.clipAudio = true;
|
|
402
|
+
if (v.transition) {
|
|
403
|
+
if (!TRANSITIONS.includes(v.transition)) {
|
|
404
|
+
throw usageError(`--transition must be ${TRANSITIONS.join(', ')}.`);
|
|
405
|
+
}
|
|
406
|
+
settings.transition = v.transition;
|
|
407
|
+
}
|
|
408
|
+
return settings;
|
|
409
|
+
}
|
|
410
|
+
/** About how long the film should be, in seconds. */
|
|
411
|
+
export function filmSeconds(v) {
|
|
412
|
+
return intOption(v.seconds, 'seconds', 10, 120);
|
|
413
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Api, KINDS } from "./api.js";
|
|
3
|
-
import { audioInput, compareModels, compareOptions, editInput, feedbackKind, generationInput, intOption, parse, sourceArg, transcriptionInput, usageError, } from "./args.js";
|
|
3
|
+
import { audioInput, compareModels, compareOptions, editInput, filmSeconds, filmSettings, feedbackKind, generationInput, intOption, parse, sourceArg, transcriptionInput, usageError, } from "./args.js";
|
|
4
4
|
import * as commands from "./commands.js";
|
|
5
|
+
import * as films from "./films.js";
|
|
5
6
|
import { resolveBaseUrl, VERSION } from "./config.js";
|
|
6
7
|
import { CliError, EXIT, formatError } from "./errors.js";
|
|
7
8
|
import { setQuiet } from "./output.js";
|
|
@@ -25,6 +26,10 @@ Usage:
|
|
|
25
26
|
makemidas get <id> Fetch a generation (and save its files)
|
|
26
27
|
makemidas list Recent generations
|
|
27
28
|
makemidas delete <id> [--yes] Delete a generation and its files
|
|
29
|
+
makemidas brands [<id>|default] Saved brands, or one brand's guidelines
|
|
30
|
+
makemidas characters Saved characters
|
|
31
|
+
makemidas assets [--q words] [--kind image|video|audio]
|
|
32
|
+
Files in the asset library
|
|
28
33
|
makemidas credits Credit balance and plan
|
|
29
34
|
makemidas credits buy Links and prices for plans and credit packs
|
|
30
35
|
makemidas estimate <command> "<prompt>|<file>"
|
|
@@ -37,15 +42,40 @@ Usage:
|
|
|
37
42
|
makemidas feedback "<message>" Send feedback (--kind bug|feature|praise|other,
|
|
38
43
|
--generation <id>)
|
|
39
44
|
|
|
45
|
+
Film projects (a brief → script and storyboard → frames → clips, voiceover
|
|
46
|
+
and music → one film; each paid stage is approved at the credits shown):
|
|
47
|
+
makemidas film new "<brief>" Create a project and write its storyboard
|
|
48
|
+
makemidas film list Your film projects
|
|
49
|
+
makemidas film get <id> [--wait] Storyboard, progress, prices, what's next;
|
|
50
|
+
saves the film once assembled
|
|
51
|
+
makemidas film write <id> Write (or rewrite) the storyboard
|
|
52
|
+
makemidas film update <id> Change --title, --brief, settings, or the
|
|
53
|
+
storyboard from --file shots.json
|
|
54
|
+
makemidas film approve <id> frames|film
|
|
55
|
+
Approve the next stage at its price
|
|
56
|
+
makemidas film redo <id> <shot> frame|clip|voice
|
|
57
|
+
Make one piece of a shot again
|
|
58
|
+
makemidas film resume <id> Carry on after a top-up
|
|
59
|
+
makemidas film assemble <id> Assemble the film (free; it starts on its
|
|
60
|
+
own once every piece is made)
|
|
61
|
+
makemidas film download <id> [--pieces]
|
|
62
|
+
The film, or every clip, voiceover and the
|
|
63
|
+
music with timeline.json to cut it yourself
|
|
64
|
+
makemidas film delete <id> [--yes] Delete the project (its generations stay)
|
|
65
|
+
|
|
40
66
|
Generation options (image, video, estimate):
|
|
41
67
|
-m, --model <id> Model id from \`makemidas models\` (default: cheapest)
|
|
42
68
|
-a, --aspect <ratio> e.g. 1:1, 16:9, 9:16
|
|
43
69
|
-r, --resolution <r> image: 1K | 2K | 4K; video: 480p | 720p | 1080p
|
|
44
70
|
-n, --count <n> Outputs, 1-4 (default 1)
|
|
45
|
-
--ref <file|url
|
|
71
|
+
--ref <file|url|asset:<id>>
|
|
72
|
+
Reference image; repeat for more. For videos: one is
|
|
46
73
|
the first frame, two are first and last frame
|
|
47
74
|
--style <id> photo, cinematic, film, anime, …
|
|
48
75
|
--enhance Let MakeMidas expand a short prompt
|
|
76
|
+
--brand <id> A saved brand: its look and tone join the prompt
|
|
77
|
+
(\`makemidas brands\`); --brand-logo also sends its logo
|
|
78
|
+
--character <id> A saved character as the reference (\`makemidas characters\`)
|
|
49
79
|
--quoted-credits <n> Refuse to charge anything else
|
|
50
80
|
--max-credits <n> Price it first, stop if it costs more, else run it
|
|
51
81
|
at exactly the quoted price (every generating command)
|
|
@@ -92,6 +122,22 @@ List options:
|
|
|
92
122
|
--limit <n> How many (default 20, max 50)
|
|
93
123
|
--before <ISO time> Older than this
|
|
94
124
|
|
|
125
|
+
Film options:
|
|
126
|
+
--seconds <n> About how long, 10-120 (default 30)
|
|
127
|
+
--title, --brief Name it; a new brief for \`write\` or \`update\`
|
|
128
|
+
-a, --aspect <ratio> 16:9, 9:16 or 1:1
|
|
129
|
+
--text-model <id> Writes the script (see \`makemidas models\`)
|
|
130
|
+
--video-model <id>, -r <res>, --frame-model <id>
|
|
131
|
+
--speech-model <id>, --voice <id|default>
|
|
132
|
+
--music-model <id|none>, --music-prompt <words>
|
|
133
|
+
--transition cut|fade|crossfade, --clip-audio, --brand <id|none>
|
|
134
|
+
--no-write film new: create it without writing the storyboard
|
|
135
|
+
--file <shots.json> film update: the whole storyboard, in order
|
|
136
|
+
--max-credits <n> Charge the step's price only if it is at most n
|
|
137
|
+
--quoted-credits <n> Charge exactly n (the price shown), or nothing
|
|
138
|
+
--wait, --timeout <min> Wait for the frames, the film or the assembly
|
|
139
|
+
-o, --out <dir> Where the film (or pieces) go (default .)
|
|
140
|
+
|
|
95
141
|
Global:
|
|
96
142
|
--json Machine-readable output on stdout
|
|
97
143
|
--quiet No progress on stderr
|
|
@@ -106,6 +152,8 @@ Examples:
|
|
|
106
152
|
makemidas transcribe interview.m4a --format srt
|
|
107
153
|
makemidas compare "a red fox in snow" --models a/one,b/two --max-credits 40
|
|
108
154
|
makemidas models google/gemini-omni-flash
|
|
155
|
+
makemidas film new "A 20-second ad for our cold brew" --max-credits 40
|
|
156
|
+
makemidas film approve <id> frames --quoted-credits 10 --wait
|
|
109
157
|
|
|
110
158
|
Credentials: \`auth login\`, or MAKEMIDAS_API_KEY (Settings → API keys).
|
|
111
159
|
|
|
@@ -219,6 +267,17 @@ async function main(argv) {
|
|
|
219
267
|
limit: intOption(v.limit, 'limit', 1, 50) ?? 20,
|
|
220
268
|
before: v.before,
|
|
221
269
|
});
|
|
270
|
+
case 'brands':
|
|
271
|
+
case 'brand':
|
|
272
|
+
return commands.brands(api, g, rest[0]);
|
|
273
|
+
case 'characters':
|
|
274
|
+
return commands.characters(api, g);
|
|
275
|
+
case 'assets':
|
|
276
|
+
return commands.assets(api, g, {
|
|
277
|
+
q: v.q ?? (rest.join(' ') || undefined),
|
|
278
|
+
kind: v.kind,
|
|
279
|
+
limit: intOption(v.limit, 'limit', 1, 60) ?? 20,
|
|
280
|
+
});
|
|
222
281
|
case 'credits': {
|
|
223
282
|
const [sub] = rest;
|
|
224
283
|
if (!sub)
|
|
@@ -271,6 +330,63 @@ async function main(argv) {
|
|
|
271
330
|
}
|
|
272
331
|
return commands.models(api, g, kind);
|
|
273
332
|
}
|
|
333
|
+
case 'film':
|
|
334
|
+
case 'films': {
|
|
335
|
+
const [sub, id, ...args] = rest;
|
|
336
|
+
const price = {
|
|
337
|
+
maxCredits: maxCredits(v),
|
|
338
|
+
quotedCredits: intOption(v['quoted-credits'], 'quoted-credits', 0, 1_000_000),
|
|
339
|
+
};
|
|
340
|
+
const filmWait = { wait: v.wait, timeoutMin };
|
|
341
|
+
switch (sub) {
|
|
342
|
+
case 'list':
|
|
343
|
+
case undefined:
|
|
344
|
+
return films.filmList(api, g);
|
|
345
|
+
case 'new':
|
|
346
|
+
case 'create':
|
|
347
|
+
return films.filmNew(api, g, {
|
|
348
|
+
brief: [id, ...args].filter(Boolean).join(' '),
|
|
349
|
+
...(v.title ? { title: v.title } : {}),
|
|
350
|
+
settings: filmSettings(v),
|
|
351
|
+
write: !v['no-write'],
|
|
352
|
+
targetSeconds: filmSeconds(v),
|
|
353
|
+
}, price);
|
|
354
|
+
case 'get':
|
|
355
|
+
case 'show':
|
|
356
|
+
return films.filmGet(api, g, id, save, filmWait);
|
|
357
|
+
case 'write':
|
|
358
|
+
return films.filmWrite(api, g, id, {
|
|
359
|
+
...(filmSeconds(v) !== undefined ? { targetSeconds: filmSeconds(v) } : {}),
|
|
360
|
+
...(v.brief ? { brief: v.brief } : {}),
|
|
361
|
+
}, price);
|
|
362
|
+
case 'update': {
|
|
363
|
+
const settings = filmSettings(v);
|
|
364
|
+
return films.filmUpdate(api, g, id, {
|
|
365
|
+
...(v.title ? { title: v.title } : {}),
|
|
366
|
+
...(v.brief ? { brief: v.brief } : {}),
|
|
367
|
+
...(Object.keys(settings).length ? { settings } : {}),
|
|
368
|
+
...(v.file ? { shots: await films.readStoryboard(v.file) } : {}),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
case 'approve':
|
|
372
|
+
return films.filmApprove(api, g, id, args[0], price, save, filmWait);
|
|
373
|
+
case 'redo':
|
|
374
|
+
return films.filmRedo(api, g, id, args[0], args[1], price, filmWait);
|
|
375
|
+
case 'resume':
|
|
376
|
+
return films.filmResume(api, g, id, filmWait);
|
|
377
|
+
case 'assemble':
|
|
378
|
+
return films.filmAssemble(api, g, id, save, filmWait);
|
|
379
|
+
case 'download':
|
|
380
|
+
return films.filmDownload(api, g, id, save, { pieces: v.pieces });
|
|
381
|
+
case 'delete':
|
|
382
|
+
return films.filmDelete(api, g, id, {
|
|
383
|
+
yes: v.yes,
|
|
384
|
+
interactive: Boolean(process.stdin.isTTY),
|
|
385
|
+
});
|
|
386
|
+
default:
|
|
387
|
+
throw usageError('Use `film new`, `list`, `get`, `write`, `update`, `approve`, `redo`, `resume`, `assemble`, `download` or `delete`.');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
274
390
|
default:
|
|
275
391
|
throw usageError(`Unknown command "${command}".`);
|
|
276
392
|
}
|
package/dist/commands.js
CHANGED
|
@@ -32,7 +32,7 @@ const EXTENSIONS = {
|
|
|
32
32
|
function outputPath(dir, generation, n, ext) {
|
|
33
33
|
return join(dir, `makemidas-${generation.id.slice(0, 8)}-${n}.${ext}`);
|
|
34
34
|
}
|
|
35
|
-
async function writeOutput(file, bytes, force) {
|
|
35
|
+
export async function writeOutput(file, bytes, force) {
|
|
36
36
|
if (existsSync(file) && !force) {
|
|
37
37
|
warn(`${file} exists; skipped (use --force to overwrite).`);
|
|
38
38
|
return false;
|
|
@@ -178,8 +178,11 @@ function formatSeconds(seconds) {
|
|
|
178
178
|
async function prepare(api, input, refs, media) {
|
|
179
179
|
const referenceIds = await uploadRefs(api, refs);
|
|
180
180
|
const fileId = media ? await uploadMedia(api, media.kind, media.source) : undefined;
|
|
181
|
+
// `--brand default` names the default brand; the API takes its id.
|
|
182
|
+
const brandId = input.brandId === 'default' ? (await api.brand('default')).id : input.brandId;
|
|
181
183
|
return {
|
|
182
184
|
...input,
|
|
185
|
+
...(brandId ? { brandId } : {}),
|
|
183
186
|
// Images and videos always send the list; other kinds only when given.
|
|
184
187
|
...(input.kind === 'image' || input.kind === 'video' || referenceIds.length
|
|
185
188
|
? { referenceIds }
|
|
@@ -631,3 +634,46 @@ export async function creditsLink(api, g) {
|
|
|
631
634
|
}
|
|
632
635
|
print(`Manage billing: ${result.billingUrl}`);
|
|
633
636
|
}
|
|
637
|
+
// ---------------------------------------------------------------------------
|
|
638
|
+
// brands, characters, assets (read-only: what a creative brief can use)
|
|
639
|
+
// ---------------------------------------------------------------------------
|
|
640
|
+
export async function brands(api, g, id) {
|
|
641
|
+
if (id) {
|
|
642
|
+
const brand = await api.brand(id);
|
|
643
|
+
if (g.json)
|
|
644
|
+
return printJson(brand);
|
|
645
|
+
print(`${brand.name} (${brand.id})${brand.isDefault ? ' · default' : ''}`);
|
|
646
|
+
print(brand.guidelines);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
const list = await api.brands();
|
|
650
|
+
if (g.json)
|
|
651
|
+
return printJson({ brands: list });
|
|
652
|
+
if (!list.length)
|
|
653
|
+
return print('No saved brands (add one on makemidas.com/dashboard/brands).');
|
|
654
|
+
for (const brand of list) {
|
|
655
|
+
const palette = brand.colors.map((c) => c.hex).join(' ');
|
|
656
|
+
print(`${brand.id} ${brand.isDefault ? '*' : ' '} ${brand.name}${palette ? ` ${palette}` : ''}`);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
export async function characters(api, g) {
|
|
660
|
+
const list = await api.characters();
|
|
661
|
+
if (g.json)
|
|
662
|
+
return printJson({ characters: list });
|
|
663
|
+
if (!list.length)
|
|
664
|
+
return print('No saved characters (add one on makemidas.com/dashboard/characters).');
|
|
665
|
+
for (const c of list) {
|
|
666
|
+
print(`${c.id} ${c.name} (${c.imageCount} image${c.imageCount === 1 ? '' : 's'})${c.description ? `: ${c.description}` : ''}`);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
export async function assets(api, g, query) {
|
|
670
|
+
const page = await api.assets(query);
|
|
671
|
+
if (g.json)
|
|
672
|
+
return printJson(page);
|
|
673
|
+
if (!page.assets.length)
|
|
674
|
+
return print('No matching files in the asset library.');
|
|
675
|
+
for (const a of page.assets) {
|
|
676
|
+
const size = a.width && a.height ? `${a.width}x${a.height}` : a.durationSeconds ? `${a.durationSeconds}s` : '';
|
|
677
|
+
print(`${a.id} ${a.kind.padEnd(5)} ${a.name}${size ? ` ${size}` : ''}${a.tags.length ? ` #${a.tags.join(' #')}` : ''}`);
|
|
678
|
+
}
|
|
679
|
+
}
|
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.
|
|
4
|
+
export const VERSION = '0.3.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/dist/films.js
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { readFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { askYesNo, writeOutput, } from "./commands.js";
|
|
4
|
+
import { CliError, EXIT } from "./errors.js";
|
|
5
|
+
import { log, print, printJson } from "./output.js";
|
|
6
|
+
/*
|
|
7
|
+
* `makemidas film …`: film projects. A brief becomes a script and a
|
|
8
|
+
* storyboard; the frames and then the film are approved at the credits
|
|
9
|
+
* shown; the service assembles the film, or the pieces and a timeline come
|
|
10
|
+
* down for an agent to assemble itself.
|
|
11
|
+
*/
|
|
12
|
+
/** Steps the service is working on; waiting polls through them. */
|
|
13
|
+
const WORKING = new Set(['making_frames', 'making_film', 'assembling']);
|
|
14
|
+
/** Seconds between polls: a render moves on each poll, so poll it often. */
|
|
15
|
+
const POLL_SECONDS = { assembling: 8, other: 15 };
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
const short = (id) => id.slice(0, 8);
|
|
18
|
+
function need(value, what) {
|
|
19
|
+
if (!value)
|
|
20
|
+
throw new CliError(`Give ${what}.`, EXIT.USAGE, 'usage');
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** The credits to send for a step priced at `credits`, or a refusal. */
|
|
24
|
+
export function priceFor(credits, what, price, retry) {
|
|
25
|
+
if (price.quotedCredits !== undefined)
|
|
26
|
+
return price.quotedCredits;
|
|
27
|
+
if (price.maxCredits === undefined) {
|
|
28
|
+
throw new CliError(`${what} costs ${credits} credits. Run again with --quoted-credits ${credits} (or --max-credits <n>): ${retry} --quoted-credits ${credits}`, EXIT.USAGE, 'quote_required');
|
|
29
|
+
}
|
|
30
|
+
if (credits > price.maxCredits) {
|
|
31
|
+
throw new CliError(`${what} costs ${credits} credits, over --max-credits ${price.maxCredits}. Nothing was charged.`, EXIT.CREDITS, 'over_budget');
|
|
32
|
+
}
|
|
33
|
+
return credits;
|
|
34
|
+
}
|
|
35
|
+
function pieceMark(label, piece) {
|
|
36
|
+
if (!piece)
|
|
37
|
+
return `${label} -`;
|
|
38
|
+
const marks = { queued: '…', running: '…', done: '✓', failed: '✗' };
|
|
39
|
+
return `${label} ${marks[piece.status]}`;
|
|
40
|
+
}
|
|
41
|
+
/** What to run next, as one line a person or an agent can follow. */
|
|
42
|
+
export function nextHint(film) {
|
|
43
|
+
const id = film.id;
|
|
44
|
+
switch (film.next) {
|
|
45
|
+
case 'write_storyboard':
|
|
46
|
+
return `Write the storyboard: makemidas film write ${id} --max-credits 40`;
|
|
47
|
+
case 'approve_frames':
|
|
48
|
+
return `Approve the first frames for ${film.pendingCredits} credits: makemidas film approve ${id} frames --quoted-credits ${film.pendingCredits}`;
|
|
49
|
+
case 'making_frames':
|
|
50
|
+
return `Drawing the first frames (they start within a minute): makemidas film get ${id} --wait`;
|
|
51
|
+
case 'approve_film':
|
|
52
|
+
return `Check the frames, then approve the film for ${film.pendingCredits} credits: makemidas film approve ${id} film --quoted-credits ${film.pendingCredits}`;
|
|
53
|
+
case 'making_film':
|
|
54
|
+
return `Making the clips, voiceover and music: makemidas film get ${id} --wait`;
|
|
55
|
+
case 'assemble':
|
|
56
|
+
return `Every piece is ready: makemidas film assemble ${id} (or makemidas film download ${id} --pieces to cut it yourself)`;
|
|
57
|
+
case 'assembling':
|
|
58
|
+
return `Assembling: makemidas film get ${id} --wait`;
|
|
59
|
+
case 'done':
|
|
60
|
+
return `Finished: makemidas film download ${id}`;
|
|
61
|
+
case 'paused':
|
|
62
|
+
return `Paused (${film.pausedReason ?? 'stopped'}): top up credits, then makemidas film resume ${id}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** A project as a few lines of text. */
|
|
66
|
+
export function describeFilm(film) {
|
|
67
|
+
const lines = [
|
|
68
|
+
`${film.title} (${film.id}) · ${film.stage} · ${film.shots.length} shot${film.shots.length === 1 ? '' : 's'} · ${film.seconds} s`,
|
|
69
|
+
];
|
|
70
|
+
for (const shot of film.shots) {
|
|
71
|
+
const parts = [
|
|
72
|
+
pieceMark('frame', shot.frame),
|
|
73
|
+
pieceMark('clip', shot.clip),
|
|
74
|
+
...(shot.voiceover ? [pieceMark('voice', shot.voice)] : []),
|
|
75
|
+
].join(' ');
|
|
76
|
+
lines.push(` ${shot.position + 1}. ${shot.duration}s [${parts}] ${shot.description || shot.prompt.slice(0, 80)}`);
|
|
77
|
+
if (shot.error)
|
|
78
|
+
lines.push(` error: ${shot.error}`);
|
|
79
|
+
}
|
|
80
|
+
if (film.assembly?.status === 'failed') {
|
|
81
|
+
lines.push(` assembly failed: ${film.assembly.error ?? 'unknown error'}`);
|
|
82
|
+
}
|
|
83
|
+
if (film.filmUrl)
|
|
84
|
+
lines.push(` film: ${film.filmUrl}`);
|
|
85
|
+
lines.push(`Next: ${nextHint(film)}`);
|
|
86
|
+
lines.push(`Web: ${film.webUrl}`);
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
function show(g, film, files = []) {
|
|
90
|
+
if (g.json)
|
|
91
|
+
printJson({ ...film, files });
|
|
92
|
+
else
|
|
93
|
+
for (const line of describeFilm(film))
|
|
94
|
+
print(line);
|
|
95
|
+
for (const file of files)
|
|
96
|
+
if (!g.json)
|
|
97
|
+
print(file);
|
|
98
|
+
}
|
|
99
|
+
/** Poll until the service stops working on the project, or time runs out. */
|
|
100
|
+
export async function waitForFilm(api, film, wait) {
|
|
101
|
+
const pause = wait.sleep ?? sleep;
|
|
102
|
+
const deadline = Date.now() + wait.timeoutMin * 60_000;
|
|
103
|
+
let current = film;
|
|
104
|
+
while (WORKING.has(current.next) && Date.now() < deadline) {
|
|
105
|
+
log(`${current.next.replace('_', ' ')}… (${short(current.id)})`);
|
|
106
|
+
const seconds = current.next === 'assembling' ? POLL_SECONDS.assembling : POLL_SECONDS.other;
|
|
107
|
+
await pause(seconds * 1000);
|
|
108
|
+
current = await api.film(current.id);
|
|
109
|
+
}
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
/** The exit a waited-on project ends with. */
|
|
113
|
+
function settle(film, waited) {
|
|
114
|
+
if (film.next === 'paused') {
|
|
115
|
+
throw new CliError(`Paused: ${film.pausedReason ?? 'stopped'}. Top up, then \`makemidas film resume ${film.id}\`.`, EXIT.CREDITS, film.pausedReason ?? 'paused');
|
|
116
|
+
}
|
|
117
|
+
if (film.assembly?.status === 'failed' && film.next !== 'done') {
|
|
118
|
+
throw new CliError(`Assembly failed: ${film.assembly.error ?? 'unknown error'}. Run \`makemidas film assemble ${film.id}\` again, or \`makemidas film download ${film.id} --pieces\` to cut it yourself.`, EXIT.FAILED, 'generation_failed');
|
|
119
|
+
}
|
|
120
|
+
if (waited && WORKING.has(film.next)) {
|
|
121
|
+
throw new CliError(`Still working (${film.next}). Run \`makemidas film get ${film.id} --wait\` later.`, EXIT.NOT_READY, 'not_ready');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Save the assembled film as `<dir>/film-<id>.mp4`. */
|
|
125
|
+
async function saveFilm(api, film, save) {
|
|
126
|
+
if (!save.out || !film.filmUrl)
|
|
127
|
+
return [];
|
|
128
|
+
const dir = resolve(save.out);
|
|
129
|
+
await mkdir(dir, { recursive: true });
|
|
130
|
+
const { bytes } = await api.download(film.filmUrl);
|
|
131
|
+
const file = join(dir, `film-${short(film.id)}.mp4`);
|
|
132
|
+
return (await writeOutput(file, bytes, save.force)) ? [file] : [];
|
|
133
|
+
}
|
|
134
|
+
const EXT = {
|
|
135
|
+
'video/mp4': 'mp4',
|
|
136
|
+
'audio/mpeg': 'mp3',
|
|
137
|
+
'audio/wav': 'wav',
|
|
138
|
+
'audio/x-wav': 'wav',
|
|
139
|
+
'audio/mp4': 'm4a',
|
|
140
|
+
'image/jpeg': 'jpg',
|
|
141
|
+
'image/png': 'png',
|
|
142
|
+
'image/webp': 'webp',
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Every piece of a finished storyboard into `<dir>/film-<id>/`: the clips,
|
|
146
|
+
* voiceovers and music, and `timeline.json` saying where each goes, with
|
|
147
|
+
* its paths swapped for the local files.
|
|
148
|
+
*/
|
|
149
|
+
async function savePieces(api, film, save) {
|
|
150
|
+
if (!film.timeline) {
|
|
151
|
+
throw new CliError(`The clips are not all made yet (${film.next}). Run \`makemidas film get ${film.id} --wait\` first.`, EXIT.NOT_READY, 'not_ready');
|
|
152
|
+
}
|
|
153
|
+
const dir = resolve(save.out ?? '.', `film-${short(film.id)}`);
|
|
154
|
+
await mkdir(dir, { recursive: true });
|
|
155
|
+
const files = [];
|
|
156
|
+
const fetchTo = async (url, name) => {
|
|
157
|
+
const { bytes, type } = await api.download(url);
|
|
158
|
+
const file = join(dir, `${name}.${EXT[type.split(';')[0].trim()] ?? 'bin'}`);
|
|
159
|
+
if (await writeOutput(file, bytes, save.force))
|
|
160
|
+
files.push(file);
|
|
161
|
+
return file;
|
|
162
|
+
};
|
|
163
|
+
const timeline = film.timeline;
|
|
164
|
+
const clips = [];
|
|
165
|
+
for (const [i, clip] of timeline.clips.entries()) {
|
|
166
|
+
clips.push({ ...clip, file: await fetchTo(clip.url, `clip-${i + 1}`) });
|
|
167
|
+
}
|
|
168
|
+
const voiceover = [];
|
|
169
|
+
for (const line of timeline.voiceover) {
|
|
170
|
+
const n = film.shots.findIndex((shot) => shot.id === line.shotId) + 1;
|
|
171
|
+
voiceover.push({ ...line, file: await fetchTo(line.url, `voice-${n}`) });
|
|
172
|
+
}
|
|
173
|
+
const music = timeline.music
|
|
174
|
+
? { ...timeline.music, file: await fetchTo(timeline.music.url, 'music') }
|
|
175
|
+
: null;
|
|
176
|
+
const local = { ...timeline, clips, voiceover, music };
|
|
177
|
+
const json = join(dir, 'timeline.json');
|
|
178
|
+
if (await writeOutput(json, new TextEncoder().encode(`${JSON.stringify(local, null, 2)}\n`), save.force)) {
|
|
179
|
+
files.push(json);
|
|
180
|
+
}
|
|
181
|
+
return files;
|
|
182
|
+
}
|
|
183
|
+
// ---------------------------------------------------------------- commands
|
|
184
|
+
export async function filmList(api, g) {
|
|
185
|
+
const films = await api.films();
|
|
186
|
+
if (g.json)
|
|
187
|
+
return printJson({ films });
|
|
188
|
+
if (!films.length) {
|
|
189
|
+
print('No film projects yet. Start one: makemidas film new "<brief>"');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
for (const film of films) {
|
|
193
|
+
print(`${film.id} ${film.stage.padEnd(10)} ${String(film.shots).padStart(2)} shots ${String(film.seconds).padStart(3)} s ${film.title}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** Make the storyboard, priced first; `price` caps the most it can cost. */
|
|
197
|
+
async function write(api, id, input, price) {
|
|
198
|
+
const quote = await api.storyboardQuote(id, input.targetSeconds);
|
|
199
|
+
const quoted = priceFor(quote.credits, `Writing the storyboard (${quote.model}, at most)`, price, `makemidas film write ${id}`);
|
|
200
|
+
log(`Writing the script and storyboard (up to ${quoted} credits, charged by what it writes)…`);
|
|
201
|
+
return api.writeStoryboard(id, { ...input, quotedCredits: quoted });
|
|
202
|
+
}
|
|
203
|
+
export async function filmNew(api, g, input, price) {
|
|
204
|
+
if (!input.brief.trim()) {
|
|
205
|
+
throw new CliError('Describe the film: `makemidas film new "a 10-second ad for …"`.', EXIT.USAGE, 'usage');
|
|
206
|
+
}
|
|
207
|
+
let film = await api.createFilm({
|
|
208
|
+
brief: input.brief,
|
|
209
|
+
...(input.title ? { title: input.title } : {}),
|
|
210
|
+
...(Object.keys(input.settings).length ? { settings: input.settings } : {}),
|
|
211
|
+
});
|
|
212
|
+
log(`Created film ${film.id}.`);
|
|
213
|
+
if (input.write) {
|
|
214
|
+
film = await write(api, film.id, { targetSeconds: input.targetSeconds }, price);
|
|
215
|
+
}
|
|
216
|
+
show(g, film);
|
|
217
|
+
}
|
|
218
|
+
export async function filmGet(api, g, id, save, wait) {
|
|
219
|
+
let film = await api.film(need(id, 'a film id: `makemidas film get <id>`'));
|
|
220
|
+
if (wait.wait)
|
|
221
|
+
film = await waitForFilm(api, film, wait);
|
|
222
|
+
const files = film.next === 'done' ? await saveFilm(api, film, save) : [];
|
|
223
|
+
show(g, film, files);
|
|
224
|
+
settle(film, wait.wait);
|
|
225
|
+
}
|
|
226
|
+
export async function filmWrite(api, g, id, input, price) {
|
|
227
|
+
const film = await write(api, need(id, 'a film id: `makemidas film write <id>`'), input, price);
|
|
228
|
+
show(g, film);
|
|
229
|
+
}
|
|
230
|
+
export async function filmApprove(api, g, id, stage, price, save, wait) {
|
|
231
|
+
const filmId = need(id, 'a film id: `makemidas film approve <id> frames|film`');
|
|
232
|
+
if (stage !== 'frames' && stage !== 'film') {
|
|
233
|
+
throw new CliError('Approve `frames` (the first frames) or `film` (clips, voiceover, music and the film).', EXIT.USAGE, 'usage');
|
|
234
|
+
}
|
|
235
|
+
let film = await api.film(filmId);
|
|
236
|
+
if (film.next !== `approve_${stage}`) {
|
|
237
|
+
throw new CliError(`Nothing to approve for ${stage} now. ${nextHint(film)}`, EXIT.USAGE, 'wrong_stage');
|
|
238
|
+
}
|
|
239
|
+
const quoted = priceFor(film.pendingCredits, stage === 'frames' ? 'Drawing the first frames' : 'Making the film', price, `makemidas film approve ${filmId} ${stage}`);
|
|
240
|
+
film = await api.approveFilm(filmId, { stage, quotedCredits: quoted });
|
|
241
|
+
log(`Approved ${stage} for ${quoted} credits.`);
|
|
242
|
+
if (wait.wait)
|
|
243
|
+
film = await waitForFilm(api, film, wait);
|
|
244
|
+
const files = film.next === 'done' ? await saveFilm(api, film, save) : [];
|
|
245
|
+
show(g, film, files);
|
|
246
|
+
settle(film, wait.wait);
|
|
247
|
+
}
|
|
248
|
+
/** A shot by its number in the storyboard (1-based) or its id. */
|
|
249
|
+
export function findShot(film, ref) {
|
|
250
|
+
const n = Number(ref);
|
|
251
|
+
const shot = Number.isInteger(n)
|
|
252
|
+
? film.shots.find((s) => s.position === n - 1)
|
|
253
|
+
: film.shots.find((s) => s.id === ref);
|
|
254
|
+
if (!shot) {
|
|
255
|
+
throw new CliError(`No shot ${ref}; give its number (1-${film.shots.length}) or id.`, EXIT.USAGE, 'not_found');
|
|
256
|
+
}
|
|
257
|
+
return shot;
|
|
258
|
+
}
|
|
259
|
+
export async function filmRedo(api, g, id, shotRef, part, price, wait) {
|
|
260
|
+
const filmId = need(id, 'a film id: `makemidas film redo <id> <shot> frame|clip|voice`');
|
|
261
|
+
if (part !== 'frame' && part !== 'clip' && part !== 'voice') {
|
|
262
|
+
throw new CliError('Redo a `frame`, `clip` or `voice`.', EXIT.USAGE, 'usage');
|
|
263
|
+
}
|
|
264
|
+
let film = await api.film(filmId);
|
|
265
|
+
const shot = findShot(film, need(shotRef, 'a shot number or id'));
|
|
266
|
+
// A new first frame after approval makes its clip again too.
|
|
267
|
+
const approved = film.stage === 'film' || film.stage === 'assembled';
|
|
268
|
+
const credits = shot.credits[part] + (part === 'frame' && approved ? shot.credits.clip : 0);
|
|
269
|
+
const quoted = priceFor(credits, `Redoing shot ${shot.position + 1}'s ${part}`, price, `makemidas film redo ${filmId} ${shot.position + 1} ${part}`);
|
|
270
|
+
film = await api.redoShot(filmId, shot.id, { part: part, quotedCredits: quoted });
|
|
271
|
+
log(`Redoing shot ${shot.position + 1}'s ${part} for ${quoted} credits.`);
|
|
272
|
+
if (wait.wait)
|
|
273
|
+
film = await waitForFilm(api, film, wait);
|
|
274
|
+
show(g, film);
|
|
275
|
+
settle(film, wait.wait);
|
|
276
|
+
}
|
|
277
|
+
export async function filmResume(api, g, id, wait) {
|
|
278
|
+
let film = await api.resumeFilm(need(id, 'a film id: `makemidas film resume <id>`'));
|
|
279
|
+
if (wait.wait)
|
|
280
|
+
film = await waitForFilm(api, film, wait);
|
|
281
|
+
show(g, film);
|
|
282
|
+
settle(film, wait.wait);
|
|
283
|
+
}
|
|
284
|
+
export async function filmAssemble(api, g, id, save, wait) {
|
|
285
|
+
let film = await api.assembleFilm(need(id, 'a film id: `makemidas film assemble <id>`'));
|
|
286
|
+
if (wait.wait)
|
|
287
|
+
film = await waitForFilm(api, film, wait);
|
|
288
|
+
const files = film.next === 'done' ? await saveFilm(api, film, save) : [];
|
|
289
|
+
show(g, film, files);
|
|
290
|
+
settle(film, wait.wait);
|
|
291
|
+
}
|
|
292
|
+
export async function filmDownload(api, g, id, save, opts) {
|
|
293
|
+
const film = await api.film(need(id, 'a film id: `makemidas film download <id>`'));
|
|
294
|
+
const out = { ...save, out: save.out ?? '.' };
|
|
295
|
+
let files;
|
|
296
|
+
if (opts.pieces) {
|
|
297
|
+
files = await savePieces(api, film, out);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
if (!film.filmUrl) {
|
|
301
|
+
throw new CliError(`The film is not assembled yet (${film.next}). ${nextHint(film)}`, EXIT.NOT_READY, 'not_ready');
|
|
302
|
+
}
|
|
303
|
+
files = await saveFilm(api, film, out);
|
|
304
|
+
}
|
|
305
|
+
if (g.json)
|
|
306
|
+
printJson({ id: film.id, files });
|
|
307
|
+
else
|
|
308
|
+
for (const file of files)
|
|
309
|
+
print(file);
|
|
310
|
+
}
|
|
311
|
+
/** The storyboard file `film update --file` reads: shots, or `{ shots }`. */
|
|
312
|
+
export async function readStoryboard(path) {
|
|
313
|
+
let raw;
|
|
314
|
+
try {
|
|
315
|
+
raw = await readFile(path, 'utf8');
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
throw new CliError(`Can't read ${path}`, EXIT.USAGE, 'invalid_file');
|
|
319
|
+
}
|
|
320
|
+
let json;
|
|
321
|
+
try {
|
|
322
|
+
json = JSON.parse(raw);
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
throw new CliError(`${path} is not valid JSON.`, EXIT.USAGE, 'invalid_file');
|
|
326
|
+
}
|
|
327
|
+
const shots = Array.isArray(json)
|
|
328
|
+
? json
|
|
329
|
+
: json.shots;
|
|
330
|
+
if (!Array.isArray(shots) || shots.length === 0) {
|
|
331
|
+
throw new CliError(`${path} must hold a list of shots (or { "shots": [...] }), each with prompt and duration.`, EXIT.USAGE, 'invalid_file');
|
|
332
|
+
}
|
|
333
|
+
return shots;
|
|
334
|
+
}
|
|
335
|
+
export async function filmUpdate(api, g, id, input) {
|
|
336
|
+
const filmId = need(id, 'a film id: `makemidas film update <id> …`');
|
|
337
|
+
if (!Object.keys(input).length) {
|
|
338
|
+
throw new CliError('Say what to change: --title, --brief, --file storyboard.json, or a setting such as --voice.', EXIT.USAGE, 'usage');
|
|
339
|
+
}
|
|
340
|
+
show(g, await api.updateFilm(filmId, input));
|
|
341
|
+
}
|
|
342
|
+
export async function filmDelete(api, g, id, opts) {
|
|
343
|
+
const filmId = need(id, 'a film id: `makemidas film delete <id>`');
|
|
344
|
+
if (!opts.yes) {
|
|
345
|
+
if (!opts.interactive) {
|
|
346
|
+
throw new CliError(`Deleting film ${filmId} removes the project and its assembled film (its generations stay). Run again with --yes to confirm.`, EXIT.USAGE, 'confirmation_required');
|
|
347
|
+
}
|
|
348
|
+
const ok = await (opts.confirm ?? askYesNo)(`Delete film project ${filmId}? Its frames and clips stay in your creations.`);
|
|
349
|
+
if (!ok)
|
|
350
|
+
throw new CliError('Not deleted.', EXIT.USAGE, 'cancelled');
|
|
351
|
+
}
|
|
352
|
+
await api.deleteFilm(filmId);
|
|
353
|
+
if (g.json)
|
|
354
|
+
printJson({ id: filmId, deleted: true });
|
|
355
|
+
else
|
|
356
|
+
print(`Deleted film ${filmId}.`);
|
|
357
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makemidas/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "AI image and video generation CLI for AI agents (Claude Code, Cursor, Codex) and people: Nano Banana, GPT Image, Seedream, Seedance, Kling, Veo and more through MakeMidas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-image-generator",
|