@plaiful/cli 0.7.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.
- package/README.md +12 -0
- package/package.json +1 -1
- package/src/cli.js +233 -8
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,17 @@ 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 events script approve y1-s2-m1-the-object-ev-the-recovery 2 # the version the game gets (--retire withdraws it)
|
|
82
|
+
plaiful events storyboard draw y1-s2-m1-the-object-ev-the-recovery --style ink-wash --wait # a frame per shot
|
|
83
|
+
plaiful events storyboard get y1-s2-m1-the-object-ev-the-recovery --out boards/ # the frames, saved as PNGs
|
|
84
|
+
plaiful events edit y1-s2-m1-the-object-ev-the-recovery --title "The Recovery" # or --description, --order, --directives f.json
|
|
85
|
+
plaiful events delete <eventId> # and quests delete <questId>; --force for official canon
|
|
86
|
+
plaiful lore add the-sundered-wake --narrative "…" # lore reveal|hide <snippetId>, lore remove <setId>
|
|
87
|
+
plaiful world set kessel_well false --reason "raided" # world truth|faction|var add new ones
|
|
88
|
+
plaiful canon event <eventId> official
|
|
89
|
+
plaiful animation sets # the animation sets you can use (sets show <id>: its states)
|
|
90
|
+
plaiful animation sets save # save your own sets from resources/animation/roadforge/*.json (sets delete <id>)
|
|
91
|
+
plaiful animation run creature crew-portrait --all # a set on an agent's records: one sprite sheet per state
|
|
80
92
|
plaiful agents # your product's SmartBuilder agents in dev (agents show <name>: one agent's config)
|
|
81
93
|
plaiful agents deploy # deploy or redeploy every config in resources/agents/roadforge/ (or name the files)
|
|
82
94
|
plaiful agents run crew-portrait role=medic # make one record (placeholder values as key=value)
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -41,12 +41,29 @@ const HELP = `plaiful ${version}: work on your Plaiful product from your game re
|
|
|
41
41
|
plaiful quests show <id> one quest: its graph, steps, reward hint and price (--json: the whole record)
|
|
42
42
|
plaiful lore the lore sets, with known / hidden snippet counts
|
|
43
43
|
plaiful lore show <setId> one set's snippets
|
|
44
|
+
plaiful lore add <setId> --narrative "…" add a snippet at the end of a set (--hint, --title, --rarity, --known)
|
|
45
|
+
plaiful lore reveal <snippetId> make a snippet known to the world; lore hide <snippetId> hide it again
|
|
46
|
+
plaiful lore remove <setId> delete a set and its snippets (--force for official canon)
|
|
44
47
|
plaiful world the world's states and state events in story order, and the clock
|
|
48
|
+
plaiful world truth <id> --statement "…" add a world truth (--category foundational|cultural|historical|
|
|
49
|
+
cosmological|political|hidden_truth, --scope)
|
|
50
|
+
plaiful world faction <id> --name "…" add a faction (--description, --type, --homeland)
|
|
51
|
+
plaiful world var <id> <value> add a world variable (--description); world set <id> <value> --reason "…" set it
|
|
52
|
+
plaiful events edit <eventId> change an event (--title, --description, --category, --order <n>,
|
|
53
|
+
--directives <file.json>; --force for official canon)
|
|
54
|
+
plaiful events delete <eventId> delete an event and the events under it (--force for official canon)
|
|
55
|
+
plaiful quests delete <questId> delete a quest and its bindings (--force for official canon)
|
|
56
|
+
plaiful canon event|quest <id> official|draft|rejected set its canon status
|
|
45
57
|
plaiful events script write <eventId> ask OVID for a cinematic script for a state event (a new draft version;
|
|
46
58
|
--note "<what to change>", --wait to wait for it, --force to start over)
|
|
47
59
|
plaiful events script get <eventId> [version] the script as a screenplay page, its versions and the last request
|
|
48
60
|
plaiful events script export <eventId> [version] --fountain|--vo the screenplay (Fountain) or the voice-over
|
|
49
61
|
sheet (CSV); --out <file> to write it to a file
|
|
62
|
+
plaiful events script approve <eventId> <version> approve a version: the one the game gets (--retire to withdraw
|
|
63
|
+
it; --force for an official-canon event)
|
|
64
|
+
plaiful events storyboard draw <eventId> [version] --style <style> draw the script's storyboard, a frame per
|
|
65
|
+
shot (--aspect 16:9|4:3|1:1|9:16|21:9, --frame <id> to redraw one, --wait)
|
|
66
|
+
plaiful events storyboard get <eventId> [version] the frames and their captions (--out <dir> saves the images)
|
|
50
67
|
plaiful lists your product's SSM lists (NPC roles, SmartBuilder list values, ...)
|
|
51
68
|
plaiful lists get <name> one list (a name in your namespace, e.g. shop_type, or the full /path)
|
|
52
69
|
plaiful lists set <name> <values...> write a list (values as words, or one comma-separated argument)
|
|
@@ -69,6 +86,14 @@ const HELP = `plaiful ${version}: work on your Plaiful product from your game re
|
|
|
69
86
|
plaiful assets per agent: records, and how many have their art made, pending, failed or none
|
|
70
87
|
plaiful assets <agent> its records: state, why a render failed, where the files are
|
|
71
88
|
--state made|pending|failed|none --limit <n> (default 50)
|
|
89
|
+
plaiful animation sets the animation sets you can use (a set = a list of animation states, one sprite
|
|
90
|
+
sheet each, run together on a character): the built-ins, Plaiful's and yours
|
|
91
|
+
plaiful animation sets show <id> one set's states
|
|
92
|
+
plaiful animation sets save [files...] save your own sets from files (default: every .json in
|
|
93
|
+
resources/animation/<product>/; { id, name, states: [{ name, method, prompt }], style_ref? })
|
|
94
|
+
plaiful animation sets delete <id> delete one of your sets
|
|
95
|
+
plaiful animation run <set> <agent> [uuids...] run a set on an agent's records (--all: every record with its art
|
|
96
|
+
made; --style <sprite style>, else the set's; --force: make them again)
|
|
72
97
|
plaiful upload <files...> upload map tiles into your dev assets bucket (map-data/; --dest map-data)
|
|
73
98
|
plaiful clone [product] [dir] clone the game repo, write .env.development, docs pull, npm install, open Zed
|
|
74
99
|
--no-install --no-open
|
|
@@ -99,8 +124,8 @@ function parse(argv) {
|
|
|
99
124
|
const args = [];
|
|
100
125
|
for (let i = 0; i < argv.length; i += 1) {
|
|
101
126
|
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)) {
|
|
127
|
+
if (['--json', '--no-browser', '--help', '-h', '--version', '--apply', '--reset', '--rows', '--no-install', '--no-open', '--copies', '--no-render', '--wait', '--force', '--fountain', '--vo', '--all', '--retire', '--known'].includes(a)) flags[a.replace(/^-+/, '')] = true;
|
|
128
|
+
else if (['--product', '--api', '--dir', '--dest', '--count', '--base', '--per-effort', '--track', '--series', '--state', '--limit', '--section', '--since', '--note', '--out', '--style', '--aspect', '--frame', '--title', '--description', '--category', '--order', '--directives', '--narrative', '--hint', '--rarity', '--statement', '--name', '--reason', '--type', '--homeland', '--scope'].includes(a)) {
|
|
104
129
|
if (argv[i + 1] === undefined) throw new UsageError(`${a} needs a value`);
|
|
105
130
|
flags[a.slice(2)] = argv[i += 1];
|
|
106
131
|
} else if (a.startsWith('--')) throw new UsageError(`unknown option ${a}`);
|
|
@@ -732,6 +757,10 @@ const priceText = (p) => (p && Object.keys(p).length ? Object.entries(p).map(([k
|
|
|
732
757
|
|
|
733
758
|
async function quests(ctx, [sub, id]) {
|
|
734
759
|
const r = repo(ctx);
|
|
760
|
+
if (sub === 'delete') {
|
|
761
|
+
if (!id) throw new UsageError('which quest? plaiful quests delete <questId>');
|
|
762
|
+
return ovidEdit(ctx, 'delete_quest', { quest_id: id }, `Deleted quest ${id}.`);
|
|
763
|
+
}
|
|
735
764
|
if (sub === 'show') {
|
|
736
765
|
if (!id) throw new UsageError('which quest? plaiful quests show <id>');
|
|
737
766
|
const { data } = await ctx.call('GET', ovidRoute(r, `quests/${encodeURIComponent(id)}`));
|
|
@@ -748,7 +777,7 @@ async function quests(ctx, [sub, id]) {
|
|
|
748
777
|
ctx.out(lines.join('\n'), data);
|
|
749
778
|
return 0;
|
|
750
779
|
}
|
|
751
|
-
if (sub) throw new UsageError(`plaiful quests, or quests show <id> (not "${sub}")`);
|
|
780
|
+
if (sub) throw new UsageError(`plaiful quests, or quests show | delete <id> (not "${sub}")`);
|
|
752
781
|
const qs = new URLSearchParams();
|
|
753
782
|
if (ctx.flags.track) qs.set('track', ctx.flags.track);
|
|
754
783
|
if (ctx.flags.series) qs.set('series', ctx.flags.series);
|
|
@@ -768,6 +797,7 @@ async function quests(ctx, [sub, id]) {
|
|
|
768
797
|
|
|
769
798
|
async function lore(ctx, [sub, id]) {
|
|
770
799
|
const r = repo(ctx);
|
|
800
|
+
if (['add', 'reveal', 'hide', 'remove'].includes(sub)) return loreEdit(ctx, sub, id);
|
|
771
801
|
if (sub === 'show') {
|
|
772
802
|
if (!id) throw new UsageError('which set? plaiful lore show <setId>');
|
|
773
803
|
const { data } = await ctx.call('GET', ovidRoute(r, `lore/${encodeURIComponent(id)}`));
|
|
@@ -776,7 +806,7 @@ async function lore(ctx, [sub, id]) {
|
|
|
776
806
|
ctx.out(lines.join('\n'), data);
|
|
777
807
|
return 0;
|
|
778
808
|
}
|
|
779
|
-
if (sub) throw new UsageError(`plaiful lore, or lore show
|
|
809
|
+
if (sub) throw new UsageError(`plaiful lore, or lore show | add | reveal | hide | remove (not "${sub}")`);
|
|
780
810
|
const { data } = await ctx.call('GET', ovidRoute(r, 'lore'));
|
|
781
811
|
const lines = [`${r.product}'s lore in dev: ${data.sets.length} sets`];
|
|
782
812
|
for (const st of data.sets) lines.push(` ${st.lore_set_id} ${st.title || ''} ${st.snippets} snippets (${st.known} known, ${st.hidden} hidden)${st.source === 'plaiful-seed' ? '' : st.source ? ` from ${st.source}` : ''}`);
|
|
@@ -784,7 +814,11 @@ async function lore(ctx, [sub, id]) {
|
|
|
784
814
|
return 0;
|
|
785
815
|
}
|
|
786
816
|
|
|
787
|
-
async function world(ctx) {
|
|
817
|
+
async function world(ctx, [sub, ...rest] = []) {
|
|
818
|
+
if (sub) {
|
|
819
|
+
if (!['truth', 'faction', 'var', 'set'].includes(sub)) throw new UsageError(`plaiful world, or world truth | faction | var | set (not "${sub}")`);
|
|
820
|
+
return worldEdit(ctx, sub, rest);
|
|
821
|
+
}
|
|
788
822
|
const r = repo(ctx);
|
|
789
823
|
const { data } = await ctx.call('GET', ovidRoute(r, 'world'));
|
|
790
824
|
const c = data.clock;
|
|
@@ -799,6 +833,66 @@ async function world(ctx) {
|
|
|
799
833
|
return 0;
|
|
800
834
|
}
|
|
801
835
|
|
|
836
|
+
// ── OVID's edits (shared/ovid/edit-ops.js, the list OVID's chat tools use) ──────────────────────────────────────
|
|
837
|
+
|
|
838
|
+
/** A value typed on the command line: true / false, a number, or the word itself. */
|
|
839
|
+
const typedValue = (v) => (v === 'true' ? true : v === 'false' ? false : v !== '' && !Number.isNaN(Number(v)) ? Number(v) : v);
|
|
840
|
+
|
|
841
|
+
async function ovidEdit(ctx, op, params, done) {
|
|
842
|
+
const r = repo(ctx);
|
|
843
|
+
const { data } = await ctx.call('POST', ovidRoute(r, 'edit'), { op, ...params, ...(ctx.flags.force ? { force: true } : {}) });
|
|
844
|
+
ctx.out(`${done}${data.message ? ` (${data.message})` : ''}`, data);
|
|
845
|
+
return 0;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
async function eventsEdit(ctx, [eventId]) {
|
|
849
|
+
if (!eventId) throw new UsageError('which event? plaiful events edit <eventId> --title "…" (plaiful world lists them)');
|
|
850
|
+
const params = { event_id: eventId };
|
|
851
|
+
for (const [flag, key] of [['title', 'title'], ['description', 'description'], ['category', 'category']]) if (ctx.flags[flag] !== undefined) params[key] = ctx.flags[flag];
|
|
852
|
+
if (ctx.flags.order !== undefined) params.sort_order = Number(ctx.flags.order);
|
|
853
|
+
if (ctx.flags.directives) params.directives = readJsonFile(ctx, ctx.flags.directives).json;
|
|
854
|
+
if (Object.keys(params).length === 1) throw new UsageError('what to change? --title, --description, --category, --order or --directives <file.json>');
|
|
855
|
+
return ovidEdit(ctx, 'update_event', params, `Updated ${eventId}.`);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
async function eventsDelete(ctx, [eventId]) {
|
|
859
|
+
if (!eventId) throw new UsageError('which event? plaiful events delete <eventId>');
|
|
860
|
+
return ovidEdit(ctx, 'delete_event', { event_id: eventId }, `Deleted ${eventId} and the events under it.`);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
async function loreEdit(ctx, sub, id) {
|
|
864
|
+
if (!id) throw new UsageError(`plaiful lore ${sub} <${sub === 'add' || sub === 'remove' ? 'setId' : 'snippetId'}>`);
|
|
865
|
+
if (sub === 'add') {
|
|
866
|
+
if (!ctx.flags.narrative) throw new UsageError('--narrative "…" is required: the lore itself');
|
|
867
|
+
return ovidEdit(ctx, 'add_lore_snippet', { lore_set_id: id, narrative: ctx.flags.narrative, hint: ctx.flags.hint, title: ctx.flags.title, rarity: ctx.flags.rarity, ...(ctx.flags.known ? { world_known: true } : {}) }, `Added a snippet to ${id}.`);
|
|
868
|
+
}
|
|
869
|
+
if (sub === 'reveal') return ovidEdit(ctx, 'reveal_lore', { snippet_id: id }, `${id} is known to the world now.`);
|
|
870
|
+
if (sub === 'hide') return ovidEdit(ctx, 'hide_lore', { snippet_id: id }, `${id} is hidden again (players keep what they found).`);
|
|
871
|
+
return ovidEdit(ctx, 'remove_lore_set', { lore_set_id: id }, `Removed ${id} and its snippets.`);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
async function worldEdit(ctx, sub, [id, value]) {
|
|
875
|
+
if (sub === 'truth') {
|
|
876
|
+
if (!id || !ctx.flags.statement) throw new UsageError('plaiful world truth <id> --statement "…"');
|
|
877
|
+
return ovidEdit(ctx, 'add_truth', { truth_id: id, statement: ctx.flags.statement, category: ctx.flags.category, scope: ctx.flags.scope }, `Added truth ${id}.`);
|
|
878
|
+
}
|
|
879
|
+
if (sub === 'faction') {
|
|
880
|
+
if (!id || !ctx.flags.name) throw new UsageError('plaiful world faction <id> --name "…"');
|
|
881
|
+
return ovidEdit(ctx, 'add_faction', { faction_id: id, name: ctx.flags.name, description: ctx.flags.description, type: ctx.flags.type, homeland: ctx.flags.homeland }, `Added faction ${id}.`);
|
|
882
|
+
}
|
|
883
|
+
if (!id || value === undefined) throw new UsageError(`plaiful world ${sub} <id> <value>${sub === 'set' ? ' --reason "…"' : ''}`);
|
|
884
|
+
if (sub === 'var') return ovidEdit(ctx, 'add_world_variable', { variable_id: id, value: typedValue(value), description: ctx.flags.description }, `Added world variable ${id} = ${value}.`);
|
|
885
|
+
if (!ctx.flags.reason) throw new UsageError('--reason "…" is required: why the world changed');
|
|
886
|
+
return ovidEdit(ctx, 'set_world_variable', { variable_id: id, value: typedValue(value), reason: ctx.flags.reason }, `Set ${id} = ${value}.`);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
async function canon(ctx, [kind, id, status]) {
|
|
890
|
+
if (!['event', 'quest'].includes(kind) || !id || !['official', 'draft', 'rejected'].includes(status)) {
|
|
891
|
+
throw new UsageError('plaiful canon event|quest <id> official|draft|rejected');
|
|
892
|
+
}
|
|
893
|
+
return ovidEdit(ctx, 'set_canon_status', { kind, id, status }, `${kind} ${id} is ${status} now.`);
|
|
894
|
+
}
|
|
895
|
+
|
|
802
896
|
// ── Event scripts: OVID's cinematic for a state event ────────────────────────────────────────────────────────────
|
|
803
897
|
|
|
804
898
|
const SCRIPT_WAIT_MS = 5 * 60 * 1000;
|
|
@@ -823,7 +917,7 @@ function scriptHeader(data) {
|
|
|
823
917
|
|
|
824
918
|
async function eventsScript(ctx, [sub, eventId, version]) {
|
|
825
919
|
const r = repo(ctx);
|
|
826
|
-
if (!['write', 'get', 'export'].includes(sub)) throw new UsageError(`plaiful events script write | get | export <eventId> (not "${sub || ''}")`);
|
|
920
|
+
if (!['write', 'get', 'export', 'approve'].includes(sub)) throw new UsageError(`plaiful events script write | get | export | approve <eventId> (not "${sub || ''}")`);
|
|
827
921
|
if (!eventId) throw new UsageError(`which event? plaiful events script ${sub} <eventId> (plaiful world lists them)`);
|
|
828
922
|
if (version !== undefined && !/^\d+$/.test(version)) throw new UsageError(`the version is a number (not "${version}")`);
|
|
829
923
|
const route = ovidRoute(r, `events/${encodeURIComponent(eventId)}/script`);
|
|
@@ -833,6 +927,12 @@ async function eventsScript(ctx, [sub, eventId, version]) {
|
|
|
833
927
|
if (version) qs.set('version', version);
|
|
834
928
|
return (await ctx.call('GET', `${route}${qs.toString() ? `?${qs}` : ''}`)).data;
|
|
835
929
|
};
|
|
930
|
+
if (sub === 'approve') {
|
|
931
|
+
if (!version) throw new UsageError(`which version? plaiful events script approve ${eventId} <version> (plaiful events script get ${eventId} lists them)`);
|
|
932
|
+
const { data } = await ctx.call('POST', `${route}/approve`, { version: Number(version), ...(ctx.flags.retire ? { retire: true } : {}), ...(ctx.flags.force ? { force: true } : {}) });
|
|
933
|
+
ctx.out(data.status === 'approved' ? `Approved ${eventId} v${version}: the game gets this version.` : `Retired ${eventId} v${version}.`, data);
|
|
934
|
+
return 0;
|
|
935
|
+
}
|
|
836
936
|
if (sub === 'write') {
|
|
837
937
|
if (version !== undefined) throw new UsageError('write makes a new version; it takes no version number');
|
|
838
938
|
const { data } = await ctx.call('POST', route, { ...(ctx.flags.note ? { note: ctx.flags.note } : {}), ...(ctx.flags.force ? { force: true } : {}) });
|
|
@@ -877,6 +977,62 @@ async function eventsScript(ctx, [sub, eventId, version]) {
|
|
|
877
977
|
return 0;
|
|
878
978
|
}
|
|
879
979
|
|
|
980
|
+
// ── Storyboards (SPRITE_ANIMATION.md §13) ──────────────────────────────────────────────────────────────────────
|
|
981
|
+
|
|
982
|
+
const frameLines = (board) => (board.frames || []).map((f) => ` ${f.id.padEnd(6)} ${String(f.framing || '').padEnd(8)} ${(f.caption || '').split('\n')[0].slice(0, 90)}`);
|
|
983
|
+
|
|
984
|
+
async function eventsStoryboard(ctx, [sub, eventId, version]) {
|
|
985
|
+
const r = repo(ctx);
|
|
986
|
+
if (!['draw', 'get'].includes(sub)) throw new UsageError(`plaiful events storyboard draw | get <eventId> (not "${sub || ''}")`);
|
|
987
|
+
if (!eventId) throw new UsageError(`which event? plaiful events storyboard ${sub} <eventId>`);
|
|
988
|
+
if (version !== undefined && !/^\d+$/.test(version)) throw new UsageError(`the version is a number (not "${version}")`);
|
|
989
|
+
const route = ovidRoute(r, `events/${encodeURIComponent(eventId)}/storyboard`);
|
|
990
|
+
const read = async (v) => (await ctx.call('GET', `${route}${v ? `?version=${v}` : ''}`)).data;
|
|
991
|
+
if (sub === 'draw') {
|
|
992
|
+
if (!ctx.flags.style) throw new UsageError('--style <style> is required: the image style to draw in');
|
|
993
|
+
const { data } = await ctx.call('POST', route, { style: ctx.flags.style, ...(version ? { version: Number(version) } : {}),
|
|
994
|
+
...(ctx.flags.aspect ? { aspect: ctx.flags.aspect } : {}), ...(ctx.flags.frame ? { only: [ctx.flags.frame] } : {}) });
|
|
995
|
+
const lines = [`Drawing ${eventId} v${data.version}: ${ctx.flags.frame ? `frame ${ctx.flags.frame}` : `${data.frames.length} frames`} (job ${data.job_id}).`];
|
|
996
|
+
if ((data.cast_without_art || []).length) lines.push(` no art to match for ${data.cast_without_art.join(', ')}: drawn from the script's words`);
|
|
997
|
+
if (!ctx.flags.wait) {
|
|
998
|
+
lines.push(`It takes a few minutes: plaiful events storyboard get ${eventId} ${data.version}`);
|
|
999
|
+
ctx.out(lines.join('\n'), data);
|
|
1000
|
+
return 0;
|
|
1001
|
+
}
|
|
1002
|
+
const until = Date.now() + SCRIPT_WAIT_MS * 2;
|
|
1003
|
+
let now = null;
|
|
1004
|
+
while (Date.now() < until) {
|
|
1005
|
+
await ctx.io.sleep(SCRIPT_POLL_MS);
|
|
1006
|
+
now = await read(data.version);
|
|
1007
|
+
if (now.storyboard && now.storyboard.job_id === data.job_id) break;
|
|
1008
|
+
}
|
|
1009
|
+
const done = now && now.storyboard && now.storyboard.job_id === data.job_id;
|
|
1010
|
+
lines.push(done ? `Done: ${now.storyboard.frames.length} frames.` : 'Still drawing; plaiful events storyboard get shows it when it lands.');
|
|
1011
|
+
if (done) lines.push(...frameLines(now.storyboard));
|
|
1012
|
+
ctx.out(lines.join('\n'), now || data);
|
|
1013
|
+
return done ? 0 : 1;
|
|
1014
|
+
}
|
|
1015
|
+
const data = await read(version);
|
|
1016
|
+
if (!data.storyboard) {
|
|
1017
|
+
ctx.out(`${eventId} v${data.version}: no storyboard yet${data.job ? ` (one was started ${data.job.at})` : ''}: plaiful events storyboard draw ${eventId} --style <style>`, data);
|
|
1018
|
+
return 0;
|
|
1019
|
+
}
|
|
1020
|
+
const lines = [`${eventId} v${data.version}: ${data.storyboard.frames.length} frames, style ${data.storyboard.style_ref}, ${data.storyboard.aspect}`, ...frameLines(data.storyboard)];
|
|
1021
|
+
if (ctx.flags.out) {
|
|
1022
|
+
const dir = path.resolve(ctx.io.cwd(), ctx.flags.out);
|
|
1023
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1024
|
+
for (const f of data.storyboard.frames) {
|
|
1025
|
+
if (!f.url) continue;
|
|
1026
|
+
const res = await ctx.io.fetch(f.url, { method: 'GET', headers: {} });
|
|
1027
|
+
if (!res.ok) throw new ApiError(res.status, { error: `couldn't download ${f.id}` });
|
|
1028
|
+
fs.writeFileSync(path.join(dir, `${f.id}.png`), Buffer.from(await res.arrayBuffer()));
|
|
1029
|
+
}
|
|
1030
|
+
lines.push(`saved the frames to ${dir}`);
|
|
1031
|
+
}
|
|
1032
|
+
ctx.out(lines.join('\n'), data);
|
|
1033
|
+
return 0;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
880
1036
|
// ── What the agents made ────────────────────────────────────────────────────────────────────────────────────────
|
|
881
1037
|
|
|
882
1038
|
const countsText = (a) => `${a.records} records: ${a.made} made, ${a.pending} pending, ${a.failed} failed, ${a.none} none yet${a.truncated ? ' (first 2000)' : ''}`;
|
|
@@ -978,6 +1134,69 @@ async function midasPricing(ctx, [sub, name, value]) {
|
|
|
978
1134
|
return save(qp);
|
|
979
1135
|
}
|
|
980
1136
|
|
|
1137
|
+
// ── Animation sets (SPRITE_ANIMATION.md §5) ─────────────────────────────────────────────────────────────────────
|
|
1138
|
+
|
|
1139
|
+
const animationRoute = (r, rest = '') => `/partner/${encodeURIComponent(r.product)}/animation${rest}`;
|
|
1140
|
+
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}` : ''}`;
|
|
1141
|
+
|
|
1142
|
+
async function animationSets(ctx, [sub, ...rest]) {
|
|
1143
|
+
const r = repo(ctx);
|
|
1144
|
+
if (!sub) {
|
|
1145
|
+
const { data } = await ctx.call('GET', animationRoute(r, '/sets'));
|
|
1146
|
+
const lines = [`Animation sets ${r.product} can use:`, ...data.sets.map(setLine),
|
|
1147
|
+
`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)'}`];
|
|
1148
|
+
ctx.out(lines.join('\n'), data);
|
|
1149
|
+
return 0;
|
|
1150
|
+
}
|
|
1151
|
+
if (sub === 'show') {
|
|
1152
|
+
if (!rest[0]) throw new UsageError('plaiful animation sets show <id>');
|
|
1153
|
+
const { data } = await ctx.call('GET', animationRoute(r, `/sets/${encodeURIComponent(rest[0])}`));
|
|
1154
|
+
const x = data.set;
|
|
1155
|
+
const lines = [`${x.name} (${x.id})${x.description ? `: ${x.description}` : ''}`, ...x.states.map((st) => ` ${st.name.padEnd(14)} ${st.method.padEnd(6)} ${st.prompt || ''}`)];
|
|
1156
|
+
ctx.out(lines.join('\n'), data);
|
|
1157
|
+
return 0;
|
|
1158
|
+
}
|
|
1159
|
+
if (sub === 'delete') {
|
|
1160
|
+
if (!rest[0]) throw new UsageError('plaiful animation sets delete <id>');
|
|
1161
|
+
const { data } = await ctx.call('DELETE', animationRoute(r, `/sets/${encodeURIComponent(rest[0])}`));
|
|
1162
|
+
ctx.out(`Deleted ${rest[0]}. Records keep the sheets it made.`, data);
|
|
1163
|
+
return 0;
|
|
1164
|
+
}
|
|
1165
|
+
if (sub === 'save') {
|
|
1166
|
+
let files = rest;
|
|
1167
|
+
if (!files.length) {
|
|
1168
|
+
const dir = path.join(ctx.io.cwd(), 'resources', 'animation', r.product);
|
|
1169
|
+
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>`);
|
|
1170
|
+
files = fs.readdirSync(dir).filter((n) => n.endsWith('.json')).map((n) => path.join(dir, n));
|
|
1171
|
+
if (!files.length) throw new UsageError(`${path.relative(ctx.io.cwd(), dir)}/ has no .json sets`);
|
|
1172
|
+
}
|
|
1173
|
+
for (const f of files) {
|
|
1174
|
+
const { file, json } = readJsonFile(ctx, f);
|
|
1175
|
+
if (!json.id) throw new UsageError(`${file}: a set needs an id (lowercase letters, digits and -)`);
|
|
1176
|
+
const { status, data } = await ctx.call('PUT', animationRoute(r, `/sets/${encodeURIComponent(json.id)}`), json);
|
|
1177
|
+
if (status >= 400) throw new ApiError(status, data);
|
|
1178
|
+
ctx.out(`Saved ${json.id}: ${(data.set && data.set.states.length) || 0} states.`, data);
|
|
1179
|
+
}
|
|
1180
|
+
return 0;
|
|
1181
|
+
}
|
|
1182
|
+
throw new UsageError(`plaiful animation sets, or sets show | save | delete (not "${sub}")`);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
async function animationRun(ctx, [setId, agent, ...uuids]) {
|
|
1186
|
+
const r = repo(ctx);
|
|
1187
|
+
if (!setId || !agent) throw new UsageError('plaiful animation run <set> <agent> [uuids...] (or --all)');
|
|
1188
|
+
if (!uuids.length && !ctx.flags.all) throw new UsageError('name the records (uuids), or --all for every record with its art made');
|
|
1189
|
+
const { data } = await ctx.call('POST', animationRoute(r, '/run'), {
|
|
1190
|
+
set: setId, agent, ...(ctx.flags.all ? { all: true } : { records: uuids }), ...(ctx.flags.style ? { style: ctx.flags.style } : {}), ...(ctx.flags.force ? { force: true } : {}),
|
|
1191
|
+
});
|
|
1192
|
+
const jobs = data.jobs || [];
|
|
1193
|
+
const lines = [`${setId} on ${agent} (style ${data.style}): ${jobs.length} sheet${jobs.length === 1 ? '' : 's'} started, ${(data.skipped || []).length} already made or running`];
|
|
1194
|
+
for (const x of (data.invalid || []).slice(0, 20)) lines.push(` skipped ${x.uuid || '?'}${x.state ? ` ${x.state}` : ''}: ${x.error}`);
|
|
1195
|
+
if (jobs.length) lines.push('They take a minute or two each; plaiful assets <agent> shows the records.');
|
|
1196
|
+
ctx.out(lines.join('\n'), data);
|
|
1197
|
+
return 0;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
981
1200
|
async function upload(ctx, files) {
|
|
982
1201
|
const r = repo(ctx);
|
|
983
1202
|
if (!files.length) throw new UsageError('upload what? plaiful upload <files...> (map tiles: ovid-map-*.json)');
|
|
@@ -1137,8 +1356,14 @@ const COMMANDS = {
|
|
|
1137
1356
|
quests: (ctx, rest) => quests(ctx, rest),
|
|
1138
1357
|
assets: (ctx, rest) => assets(ctx, rest),
|
|
1139
1358
|
lore: (ctx, rest) => lore(ctx, rest),
|
|
1140
|
-
world: (ctx) => world(ctx),
|
|
1359
|
+
world: (ctx, rest) => world(ctx, rest),
|
|
1360
|
+
'events edit': (ctx, rest) => eventsEdit(ctx, rest),
|
|
1361
|
+
'events delete': (ctx, rest) => eventsDelete(ctx, rest),
|
|
1362
|
+
canon: (ctx, rest) => canon(ctx, rest),
|
|
1141
1363
|
'events script': (ctx, rest) => eventsScript(ctx, rest),
|
|
1364
|
+
'events storyboard': (ctx, rest) => eventsStoryboard(ctx, rest),
|
|
1365
|
+
'animation sets': (ctx, rest) => animationSets(ctx, rest),
|
|
1366
|
+
'animation run': (ctx, rest) => animationRun(ctx, rest),
|
|
1142
1367
|
upload: (ctx, files) => upload(ctx, files),
|
|
1143
1368
|
clone: (ctx, rest) => clone(ctx, rest),
|
|
1144
1369
|
env: (ctx) => envCmd(ctx),
|
|
@@ -1185,7 +1410,7 @@ async function main(argv, io = defaultIo()) {
|
|
|
1185
1410
|
const one = COMMANDS[a];
|
|
1186
1411
|
const ctx = makeContext(io, flags);
|
|
1187
1412
|
if (two) return await two(ctx, rest);
|
|
1188
|
-
if (one && !['ovid', 'midas', 'events'].includes(a)) return await one(ctx, b === undefined ? rest : [b, ...rest]);
|
|
1413
|
+
if (one && !['ovid', 'midas', 'events', 'animation'].includes(a)) return await one(ctx, b === undefined ? rest : [b, ...rest]);
|
|
1189
1414
|
throw new UsageError(`unknown command "${parsed.args.join(' ')}"`);
|
|
1190
1415
|
} catch (e) {
|
|
1191
1416
|
if (e instanceof UsageError) {
|