@plaiful/cli 0.7.0 → 0.8.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 +4 -0
- package/package.json +1 -1
- package/src/cli.js +76 -3
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ plaiful login
|
|
|
35
35
|
| Load your world into Plaiful | `plaiful seed world`, then `plaiful seed world --apply` (and `lore`, `map`, `personas`) |
|
|
36
36
|
| See what Plaiful has | `plaiful status`, `plaiful quests`, `plaiful lore`, `plaiful world`, `plaiful assets` |
|
|
37
37
|
| Get a cinematic script for a world event | `plaiful events script write <eventId> --wait`, then `plaiful events script export <eventId> --fountain` |
|
|
38
|
+
| Animate characters: a set of sprite sheets (idle, attacks, hurt, poses, a walk sheet) per record | `plaiful animation sets`, then `plaiful animation run <set> <agent> --all` |
|
|
38
39
|
| Publish your OVID declaration | `plaiful ovid check`, then `plaiful ovid publish` |
|
|
39
40
|
| Deploy and run worker agents | `plaiful agents deploy`, `plaiful agents run <name>` |
|
|
40
41
|
|
|
@@ -77,6 +78,9 @@ plaiful world # the world's states and events in story order, an
|
|
|
77
78
|
plaiful events script write y1-s2-m1-the-object-ev-the-recovery --wait # OVID writes the event's cinematic (a draft)
|
|
78
79
|
plaiful events script get y1-s2-m1-the-object-ev-the-recovery # the screenplay page, the versions, Soter's flags
|
|
79
80
|
plaiful events script export y1-s2-m1-the-object-ev-the-recovery --vo --out recovery-vo.csv # the voice-over sheet
|
|
81
|
+
plaiful animation sets # the animation sets you can use (sets show <id>: its states)
|
|
82
|
+
plaiful animation sets save # save your own sets from resources/animation/roadforge/*.json (sets delete <id>)
|
|
83
|
+
plaiful animation run creature crew-portrait --all # a set on an agent's records: one sprite sheet per state
|
|
80
84
|
plaiful agents # your product's SmartBuilder agents in dev (agents show <name>: one agent's config)
|
|
81
85
|
plaiful agents deploy # deploy or redeploy every config in resources/agents/roadforge/ (or name the files)
|
|
82
86
|
plaiful agents run crew-portrait role=medic # make one record (placeholder values as key=value)
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -69,6 +69,14 @@ const HELP = `plaiful ${version}: work on your Plaiful product from your game re
|
|
|
69
69
|
plaiful assets per agent: records, and how many have their art made, pending, failed or none
|
|
70
70
|
plaiful assets <agent> its records: state, why a render failed, where the files are
|
|
71
71
|
--state made|pending|failed|none --limit <n> (default 50)
|
|
72
|
+
plaiful animation sets the animation sets you can use (a set = a list of animation states, one sprite
|
|
73
|
+
sheet each, run together on a character): the built-ins, Plaiful's and yours
|
|
74
|
+
plaiful animation sets show <id> one set's states
|
|
75
|
+
plaiful animation sets save [files...] save your own sets from files (default: every .json in
|
|
76
|
+
resources/animation/<product>/; { id, name, states: [{ name, method, prompt }], style_ref? })
|
|
77
|
+
plaiful animation sets delete <id> delete one of your sets
|
|
78
|
+
plaiful animation run <set> <agent> [uuids...] run a set on an agent's records (--all: every record with its art
|
|
79
|
+
made; --style <sprite style>, else the set's; --force: make them again)
|
|
72
80
|
plaiful upload <files...> upload map tiles into your dev assets bucket (map-data/; --dest map-data)
|
|
73
81
|
plaiful clone [product] [dir] clone the game repo, write .env.development, docs pull, npm install, open Zed
|
|
74
82
|
--no-install --no-open
|
|
@@ -99,8 +107,8 @@ function parse(argv) {
|
|
|
99
107
|
const args = [];
|
|
100
108
|
for (let i = 0; i < argv.length; i += 1) {
|
|
101
109
|
const a = argv[i];
|
|
102
|
-
if (['--json', '--no-browser', '--help', '-h', '--version', '--apply', '--reset', '--rows', '--no-install', '--no-open', '--copies', '--no-render', '--wait', '--force', '--fountain', '--vo'].includes(a)) flags[a.replace(/^-+/, '')] = true;
|
|
103
|
-
else if (['--product', '--api', '--dir', '--dest', '--count', '--base', '--per-effort', '--track', '--series', '--state', '--limit', '--section', '--since', '--note', '--out'].includes(a)) {
|
|
110
|
+
if (['--json', '--no-browser', '--help', '-h', '--version', '--apply', '--reset', '--rows', '--no-install', '--no-open', '--copies', '--no-render', '--wait', '--force', '--fountain', '--vo', '--all'].includes(a)) flags[a.replace(/^-+/, '')] = true;
|
|
111
|
+
else if (['--product', '--api', '--dir', '--dest', '--count', '--base', '--per-effort', '--track', '--series', '--state', '--limit', '--section', '--since', '--note', '--out', '--style'].includes(a)) {
|
|
104
112
|
if (argv[i + 1] === undefined) throw new UsageError(`${a} needs a value`);
|
|
105
113
|
flags[a.slice(2)] = argv[i += 1];
|
|
106
114
|
} else if (a.startsWith('--')) throw new UsageError(`unknown option ${a}`);
|
|
@@ -978,6 +986,69 @@ async function midasPricing(ctx, [sub, name, value]) {
|
|
|
978
986
|
return save(qp);
|
|
979
987
|
}
|
|
980
988
|
|
|
989
|
+
// ── Animation sets (SPRITE_ANIMATION.md §5) ─────────────────────────────────────────────────────────────────────
|
|
990
|
+
|
|
991
|
+
const animationRoute = (r, rest = '') => `/partner/${encodeURIComponent(r.product)}/animation${rest}`;
|
|
992
|
+
const setLine = (x) => ` ${x.id.padEnd(22)} ${x.name}: ${x.states.length} states${x.builtin ? ' (built-in)' : x.yours ? ' (yours)' : ''}${x.style_ref ? `, style ${x.style_ref}` : ''}`;
|
|
993
|
+
|
|
994
|
+
async function animationSets(ctx, [sub, ...rest]) {
|
|
995
|
+
const r = repo(ctx);
|
|
996
|
+
if (!sub) {
|
|
997
|
+
const { data } = await ctx.call('GET', animationRoute(r, '/sets'));
|
|
998
|
+
const lines = [`Animation sets ${r.product} can use:`, ...data.sets.map(setLine),
|
|
999
|
+
`Sprite styles: ${data.sprite_styles.length ? data.sprite_styles.map((st) => st.id).join(', ') : 'none yet (make one in the CMS Styles tab, media Sprite animation)'}`];
|
|
1000
|
+
ctx.out(lines.join('\n'), data);
|
|
1001
|
+
return 0;
|
|
1002
|
+
}
|
|
1003
|
+
if (sub === 'show') {
|
|
1004
|
+
if (!rest[0]) throw new UsageError('plaiful animation sets show <id>');
|
|
1005
|
+
const { data } = await ctx.call('GET', animationRoute(r, `/sets/${encodeURIComponent(rest[0])}`));
|
|
1006
|
+
const x = data.set;
|
|
1007
|
+
const lines = [`${x.name} (${x.id})${x.description ? `: ${x.description}` : ''}`, ...x.states.map((st) => ` ${st.name.padEnd(14)} ${st.method.padEnd(6)} ${st.prompt || ''}`)];
|
|
1008
|
+
ctx.out(lines.join('\n'), data);
|
|
1009
|
+
return 0;
|
|
1010
|
+
}
|
|
1011
|
+
if (sub === 'delete') {
|
|
1012
|
+
if (!rest[0]) throw new UsageError('plaiful animation sets delete <id>');
|
|
1013
|
+
const { data } = await ctx.call('DELETE', animationRoute(r, `/sets/${encodeURIComponent(rest[0])}`));
|
|
1014
|
+
ctx.out(`Deleted ${rest[0]}. Records keep the sheets it made.`, data);
|
|
1015
|
+
return 0;
|
|
1016
|
+
}
|
|
1017
|
+
if (sub === 'save') {
|
|
1018
|
+
let files = rest;
|
|
1019
|
+
if (!files.length) {
|
|
1020
|
+
const dir = path.join(ctx.io.cwd(), 'resources', 'animation', r.product);
|
|
1021
|
+
if (!fs.existsSync(dir)) throw new UsageError(`no files named, and no ${path.relative(ctx.io.cwd(), dir)}/ folder: plaiful animation sets save <file.json>`);
|
|
1022
|
+
files = fs.readdirSync(dir).filter((n) => n.endsWith('.json')).map((n) => path.join(dir, n));
|
|
1023
|
+
if (!files.length) throw new UsageError(`${path.relative(ctx.io.cwd(), dir)}/ has no .json sets`);
|
|
1024
|
+
}
|
|
1025
|
+
for (const f of files) {
|
|
1026
|
+
const { file, json } = readJsonFile(ctx, f);
|
|
1027
|
+
if (!json.id) throw new UsageError(`${file}: a set needs an id (lowercase letters, digits and -)`);
|
|
1028
|
+
const { status, data } = await ctx.call('PUT', animationRoute(r, `/sets/${encodeURIComponent(json.id)}`), json);
|
|
1029
|
+
if (status >= 400) throw new ApiError(status, data);
|
|
1030
|
+
ctx.out(`Saved ${json.id}: ${(data.set && data.set.states.length) || 0} states.`, data);
|
|
1031
|
+
}
|
|
1032
|
+
return 0;
|
|
1033
|
+
}
|
|
1034
|
+
throw new UsageError(`plaiful animation sets, or sets show | save | delete (not "${sub}")`);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
async function animationRun(ctx, [setId, agent, ...uuids]) {
|
|
1038
|
+
const r = repo(ctx);
|
|
1039
|
+
if (!setId || !agent) throw new UsageError('plaiful animation run <set> <agent> [uuids...] (or --all)');
|
|
1040
|
+
if (!uuids.length && !ctx.flags.all) throw new UsageError('name the records (uuids), or --all for every record with its art made');
|
|
1041
|
+
const { data } = await ctx.call('POST', animationRoute(r, '/run'), {
|
|
1042
|
+
set: setId, agent, ...(ctx.flags.all ? { all: true } : { records: uuids }), ...(ctx.flags.style ? { style: ctx.flags.style } : {}), ...(ctx.flags.force ? { force: true } : {}),
|
|
1043
|
+
});
|
|
1044
|
+
const jobs = data.jobs || [];
|
|
1045
|
+
const lines = [`${setId} on ${agent} (style ${data.style}): ${jobs.length} sheet${jobs.length === 1 ? '' : 's'} started, ${(data.skipped || []).length} already made or running`];
|
|
1046
|
+
for (const x of (data.invalid || []).slice(0, 20)) lines.push(` skipped ${x.uuid || '?'}${x.state ? ` ${x.state}` : ''}: ${x.error}`);
|
|
1047
|
+
if (jobs.length) lines.push('They take a minute or two each; plaiful assets <agent> shows the records.');
|
|
1048
|
+
ctx.out(lines.join('\n'), data);
|
|
1049
|
+
return 0;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
981
1052
|
async function upload(ctx, files) {
|
|
982
1053
|
const r = repo(ctx);
|
|
983
1054
|
if (!files.length) throw new UsageError('upload what? plaiful upload <files...> (map tiles: ovid-map-*.json)');
|
|
@@ -1139,6 +1210,8 @@ const COMMANDS = {
|
|
|
1139
1210
|
lore: (ctx, rest) => lore(ctx, rest),
|
|
1140
1211
|
world: (ctx) => world(ctx),
|
|
1141
1212
|
'events script': (ctx, rest) => eventsScript(ctx, rest),
|
|
1213
|
+
'animation sets': (ctx, rest) => animationSets(ctx, rest),
|
|
1214
|
+
'animation run': (ctx, rest) => animationRun(ctx, rest),
|
|
1142
1215
|
upload: (ctx, files) => upload(ctx, files),
|
|
1143
1216
|
clone: (ctx, rest) => clone(ctx, rest),
|
|
1144
1217
|
env: (ctx) => envCmd(ctx),
|
|
@@ -1185,7 +1258,7 @@ async function main(argv, io = defaultIo()) {
|
|
|
1185
1258
|
const one = COMMANDS[a];
|
|
1186
1259
|
const ctx = makeContext(io, flags);
|
|
1187
1260
|
if (two) return await two(ctx, rest);
|
|
1188
|
-
if (one && !['ovid', 'midas', 'events'].includes(a)) return await one(ctx, b === undefined ? rest : [b, ...rest]);
|
|
1261
|
+
if (one && !['ovid', 'midas', 'events', 'animation'].includes(a)) return await one(ctx, b === undefined ? rest : [b, ...rest]);
|
|
1189
1262
|
throw new UsageError(`unknown command "${parsed.args.join(' ')}"`);
|
|
1190
1263
|
} catch (e) {
|
|
1191
1264
|
if (e instanceof UsageError) {
|