@plaiful/cli 0.8.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/package.json +21 -21
- package/src/cli.js +422 -12
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ plaiful login
|
|
|
37
37
|
| Get a cinematic script for a world event | `plaiful events script write <eventId> --wait`, then `plaiful events script export <eventId> --fountain` |
|
|
38
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` |
|
|
39
39
|
| Publish your OVID declaration | `plaiful ovid check`, then `plaiful ovid publish` |
|
|
40
|
+
| Tell HERMES your studio's strategy | `plaiful hermes strategy check`, then `plaiful hermes strategy publish` (your studio's admins) |
|
|
40
41
|
| Deploy and run worker agents | `plaiful agents deploy`, `plaiful agents run <name>` |
|
|
41
42
|
|
|
42
43
|
Every load starts as a dry run: it shows what would change, and changes nothing until you add `--apply`.
|
|
@@ -72,12 +73,22 @@ plaiful seed personas # THESPIS personas and situations from resources/p
|
|
|
72
73
|
plaiful status # what OVID and THESPIS have in dev: counts per store, the clock, the declaration
|
|
73
74
|
plaiful assets # per agent: records, and how many have art made / pending / failed / none yet
|
|
74
75
|
plaiful assets crew-portrait --state failed # one agent's records: state, why a render failed, where the files are
|
|
76
|
+
plaiful assets battlefield --json # also: any step that failed ({step}_step_error), and a part's source_crop and depth_min / depth_max
|
|
77
|
+
plaiful assets regenerate battlefield --state step_failed --steps depth # re-run a step (or, without --steps, re-render: a new picture)
|
|
75
78
|
plaiful quests # the quests OVID wrote: steps, and what each pays (--track, --series); quests show <id>
|
|
76
79
|
plaiful lore # the lore sets (lore show <setId>: a set's snippets)
|
|
77
80
|
plaiful world # the world's states and events in story order, and the clock
|
|
78
81
|
plaiful events script write y1-s2-m1-the-object-ev-the-recovery --wait # OVID writes the event's cinematic (a draft)
|
|
79
82
|
plaiful events script get y1-s2-m1-the-object-ev-the-recovery # the screenplay page, the versions, Soter's flags
|
|
80
83
|
plaiful events script export y1-s2-m1-the-object-ev-the-recovery --vo --out recovery-vo.csv # the voice-over sheet
|
|
84
|
+
plaiful events script approve y1-s2-m1-the-object-ev-the-recovery 2 # the version the game gets (--retire withdraws it)
|
|
85
|
+
plaiful events storyboard draw y1-s2-m1-the-object-ev-the-recovery --style ink-wash --wait # a frame per shot
|
|
86
|
+
plaiful events storyboard get y1-s2-m1-the-object-ev-the-recovery --out boards/ # the frames, saved as PNGs
|
|
87
|
+
plaiful events edit y1-s2-m1-the-object-ev-the-recovery --title "The Recovery" # or --description, --order, --directives f.json
|
|
88
|
+
plaiful events delete <eventId> # and quests delete <questId>; --force for official canon
|
|
89
|
+
plaiful lore add the-sundered-wake --narrative "…" # lore reveal|hide <snippetId>, lore remove <setId>
|
|
90
|
+
plaiful world set kessel_well false --reason "raided" # world truth|faction|var add new ones
|
|
91
|
+
plaiful canon event <eventId> official
|
|
81
92
|
plaiful animation sets # the animation sets you can use (sets show <id>: its states)
|
|
82
93
|
plaiful animation sets save # save your own sets from resources/animation/roadforge/*.json (sets delete <id>)
|
|
83
94
|
plaiful animation run creature crew-portrait --all # a set on an agent's records: one sprite sheet per state
|
|
@@ -90,8 +101,12 @@ plaiful records import crew-portrait # dry run: records you wrote (reso
|
|
|
90
101
|
# into the agent's table; --apply writes them, --no-render skips the art
|
|
91
102
|
plaiful lists # the product's SSM lists
|
|
92
103
|
plaiful lists set shop_type tavern blacksmith healer # write one (lists get shop_type reads it)
|
|
104
|
+
plaiful midas check # check docs/plaiful/roadforge-midas-declaration.json (publish: plaiful midas publish; show)
|
|
105
|
+
plaiful midas health # MIDAS's analysis, per kind (balance: what's flagged; proposals; assess: run it now)
|
|
106
|
+
plaiful midas wallet <uid> # a player's balances and history (wallet "platform"); midas ledger check <file>: a report's dry run
|
|
93
107
|
plaiful midas pricing # what each quest pays, in your reward kinds (MIDAS); delivered in the quest's rewards
|
|
94
108
|
plaiful midas pricing set scrap --base 20 --per-effort 10 # price a kind (unset <kind>, weight <step> <n>, apply [file])
|
|
109
|
+
plaiful hermes strategy check # check docs/plaiful/hermes-strategy.json (publish: your studio's admins; no word: what HERMES has)
|
|
95
110
|
plaiful upload ovid-map-biomes-tiles.json ovid-map-kingdoms-tiles.json ovid-map-colors.json # map tiles → map-data/
|
|
96
111
|
plaiful whoami # who you are (or which key), and your products
|
|
97
112
|
plaiful logout
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@plaiful/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The Plaiful CLI: work on your Plaiful product from your game repo, with no AWS access",
|
|
5
|
-
"bin": {
|
|
6
|
-
"plaiful": "bin/plaiful.js"
|
|
7
|
-
},
|
|
8
|
-
"files": [
|
|
9
|
-
"bin",
|
|
10
|
-
"src",
|
|
11
|
-
"README.md"
|
|
12
|
-
],
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=18"
|
|
15
|
-
},
|
|
16
|
-
"license": "UNLICENSED",
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"registry": "https://registry.npmjs.org/",
|
|
19
|
-
"access": "public"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@plaiful/cli",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "The Plaiful CLI: work on your Plaiful product from your game repo, with no AWS access",
|
|
5
|
+
"bin": {
|
|
6
|
+
"plaiful": "bin/plaiful.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"license": "UNLICENSED",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"registry": "https://registry.npmjs.org/",
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|
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)
|
|
@@ -60,14 +77,31 @@ const HELP = `plaiful ${version}: work on your Plaiful product from your game re
|
|
|
60
77
|
plaiful records import <agent> [file] dry run: records you wrote, into the agent's table (default file:
|
|
61
78
|
resources/records/<product>/<agent>.json; matched on the agent's duplicate field)
|
|
62
79
|
--apply write them; --no-render don't make new records' art or sound
|
|
80
|
+
plaiful midas check [file] check your MIDAS declaration: your economy's kinds, wallet, items, schedule
|
|
81
|
+
(default: <docsDir>/<product>-midas-declaration.json)
|
|
82
|
+
plaiful midas publish [file] check it and publish it
|
|
83
|
+
plaiful midas show the declaration MIDAS has, with its defaults filled in
|
|
84
|
+
plaiful midas health MIDAS's analysis of your economy: per kind, what quests make available (and with a
|
|
85
|
+
wallet, what players earn and spend)
|
|
86
|
+
plaiful midas balance what MIDAS flagged, and why (--all for everything it checked)
|
|
87
|
+
plaiful midas proposals what MIDAS proposes (--status pending|approved|applied|dismissed)
|
|
88
|
+
plaiful midas assess run MIDAS's analysis now
|
|
89
|
+
plaiful midas wallet <player> one player's balances and recent earning / spending (wallet "platform")
|
|
90
|
+
plaiful midas ledger check <file> would your game's report be accepted (wallet "game"): a dry run
|
|
63
91
|
plaiful midas pricing what MIDAS pays per quest, in your reward kinds (delivered in each quest's rewards)
|
|
64
92
|
plaiful midas pricing set <kind> --base <n> --per-effort <n> price a kind (either option alone keeps the other)
|
|
65
93
|
plaiful midas pricing unset <kind> stop pricing a kind
|
|
66
94
|
plaiful midas pricing weight <step> <n> how much a quest step counts (combat, gather, explore, ...)
|
|
67
95
|
plaiful midas pricing apply [file] replace it all from a file (default:
|
|
68
96
|
resources/midas/<product>/quest-pricing.json; { kinds, objective_weights, ... })
|
|
97
|
+
plaiful hermes strategy your studio's strategy, the one HERMES judges the market against
|
|
98
|
+
plaiful hermes strategy check [file] check it (default: <docsDir>/hermes-strategy.json)
|
|
99
|
+
plaiful hermes strategy publish [file] check it and publish it as a new version (the studio's admins)
|
|
69
100
|
plaiful assets per agent: records, and how many have their art made, pending, failed or none
|
|
70
101
|
plaiful assets <agent> its records: state, why a render failed, where the files are
|
|
102
|
+
plaiful assets regenerate <agent> [uuids...] re-render records with the table's Art Style, as the Library's
|
|
103
|
+
Regenerate does: a new picture (--all, or --state failed|none|made|step_failed)
|
|
104
|
+
--steps depth[,normal] | --steps all only re-run those steps on the current picture (Regenerate → Steps)
|
|
71
105
|
--state made|pending|failed|none --limit <n> (default 50)
|
|
72
106
|
plaiful animation sets the animation sets you can use (a set = a list of animation states, one sprite
|
|
73
107
|
sheet each, run together on a character): the built-ins, Plaiful's and yours
|
|
@@ -107,8 +141,8 @@ function parse(argv) {
|
|
|
107
141
|
const args = [];
|
|
108
142
|
for (let i = 0; i < argv.length; i += 1) {
|
|
109
143
|
const a = argv[i];
|
|
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)) {
|
|
144
|
+
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;
|
|
145
|
+
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', '--status', '--steps'].includes(a)) {
|
|
112
146
|
if (argv[i + 1] === undefined) throw new UsageError(`${a} needs a value`);
|
|
113
147
|
flags[a.slice(2)] = argv[i += 1];
|
|
114
148
|
} else if (a.startsWith('--')) throw new UsageError(`unknown option ${a}`);
|
|
@@ -434,9 +468,9 @@ function ignoreClientConfig(docsDir) {
|
|
|
434
468
|
return { added, tracked };
|
|
435
469
|
}
|
|
436
470
|
|
|
437
|
-
function readDeclaration(ctx, r, file) {
|
|
438
|
-
const target = path.resolve(ctx.io.cwd(), file || path.join(r.docsDir, `${r.product}-
|
|
439
|
-
if (!fs.existsSync(target)) throw new UsageError(`no declaration at ${target} (write it first:
|
|
471
|
+
function readDeclaration(ctx, r, file, agent = 'ovid') {
|
|
472
|
+
const target = path.resolve(ctx.io.cwd(), file || path.join(r.docsDir, `${r.product}-${agent}-declaration.json`));
|
|
473
|
+
if (!fs.existsSync(target)) throw new UsageError(`no declaration at ${target} (write it first: ${agent}-declaration.md)`);
|
|
440
474
|
try { return { target, declaration: JSON.parse(fs.readFileSync(target, 'utf8')) }; } catch (e) {
|
|
441
475
|
throw new UsageError(`${target} isn't valid JSON: ${e.message}`);
|
|
442
476
|
}
|
|
@@ -478,6 +512,51 @@ async function ovidPublish(ctx, [file]) {
|
|
|
478
512
|
return 0;
|
|
479
513
|
}
|
|
480
514
|
|
|
515
|
+
// ── The studio's HERMES strategy (hermes-strategy.md) ──
|
|
516
|
+
function readStrategy(ctx, r, file) {
|
|
517
|
+
const target = path.resolve(ctx.io.cwd(), file || path.join(r.docsDir, 'hermes-strategy.json'));
|
|
518
|
+
if (!fs.existsSync(target)) throw new UsageError(`no strategy at ${target} (write it first: hermes-strategy.md)`);
|
|
519
|
+
try { return { target, strategy: JSON.parse(fs.readFileSync(target, 'utf8')) }; } catch (e) {
|
|
520
|
+
throw new UsageError(`${target} isn't valid JSON: ${e.message}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const strategyErrors = (data) => (data.errors || []).map((e) => ` ✗ ${e.path}: ${e.message}`);
|
|
525
|
+
|
|
526
|
+
async function hermesStrategyCheck(ctx, [file]) {
|
|
527
|
+
const r = repo(ctx);
|
|
528
|
+
const { target, strategy } = readStrategy(ctx, r, file);
|
|
529
|
+
const { data } = await ctx.call('POST', `/partner/${encodeURIComponent(r.product)}/hermes/strategy/check`, { strategy });
|
|
530
|
+
const head = data.success
|
|
531
|
+
? `${path.basename(target)} is valid. Publish it with: plaiful hermes strategy publish`
|
|
532
|
+
: `${path.basename(target)} has ${(data.errors || []).length} error(s); fix them and check again.`;
|
|
533
|
+
ctx.out([head, ...strategyErrors(data)].join('\n'), data);
|
|
534
|
+
return data.success ? 0 : 1;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async function hermesStrategyPublish(ctx, [file]) {
|
|
538
|
+
const r = repo(ctx);
|
|
539
|
+
const { target, strategy } = readStrategy(ctx, r, file);
|
|
540
|
+
const { data } = await ctx.call('PUT', `/partner/${encodeURIComponent(r.product)}/hermes/strategy`, { strategy });
|
|
541
|
+
if (!data.published) {
|
|
542
|
+
ctx.out([`Not published: ${data.error || `${path.basename(target)} has ${(data.errors || []).length} error(s)`}`, ...strategyErrors(data)].join('\n'), data);
|
|
543
|
+
return 1;
|
|
544
|
+
}
|
|
545
|
+
ctx.out(`Published ${path.basename(target)} as version ${data.strategy.version} of studio ${data.studio_id}'s strategy; HERMES uses it within about 5 minutes.`, data);
|
|
546
|
+
return 0;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
async function hermesStrategyShow(ctx, rest) {
|
|
550
|
+
if (rest.length) throw new UsageError(`plaiful hermes strategy, or strategy check | publish (not "${rest[0]}")`);
|
|
551
|
+
const r = repo(ctx);
|
|
552
|
+
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/hermes/strategy`);
|
|
553
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
554
|
+
const studio = data.studio_name || data.studio_id;
|
|
555
|
+
if (!data.strategy) ctx.out(`${studio} has no strategy yet: HERMES says so, and judges the market without one. Write <docsDir>/hermes-strategy.json, then plaiful hermes strategy publish.`);
|
|
556
|
+
else ctx.out(`${studio}'s strategy, version ${data.strategy.version} (${data.strategy.updated_at} by ${data.strategy.updated_by}):\n${JSON.stringify(data.strategy.strategy, null, 2)}`);
|
|
557
|
+
return 0;
|
|
558
|
+
}
|
|
559
|
+
|
|
481
560
|
async function ovidShow(ctx) {
|
|
482
561
|
const r = repo(ctx);
|
|
483
562
|
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/ovid/declaration`);
|
|
@@ -487,6 +566,166 @@ async function ovidShow(ctx) {
|
|
|
487
566
|
return 0;
|
|
488
567
|
}
|
|
489
568
|
|
|
569
|
+
// ── The MIDAS declaration (docs/agents/midas/multi-product-economy-plan.md §3) ──────────────────────────────────
|
|
570
|
+
|
|
571
|
+
const midasDeclRoute = (r, rest = '') => `/partner/${encodeURIComponent(r.product)}/midas/declaration${rest}`;
|
|
572
|
+
|
|
573
|
+
/** "scrap, ore, xp (only builds up)" */
|
|
574
|
+
const kindsText = (kinds) => (kinds || []).map((k) => `${k.label && k.label !== k.id ? `${k.label} (${k.id})` : k.id}${k.spendable === false ? ', only builds up' : ''}`).join('; ') || 'none';
|
|
575
|
+
|
|
576
|
+
function midasEffectiveText(e) {
|
|
577
|
+
if (!e) return [];
|
|
578
|
+
const items = e.items && e.items.enabled ? `on: ${e.items.collections.map((c) => c.collection).join(', ')}` : 'off';
|
|
579
|
+
return [
|
|
580
|
+
` kinds ${kindsText(e.kinds)}${e.kinds_from === 'ovid' ? ' (from your OVID reward kinds)' : ''}`,
|
|
581
|
+
` wallet ${e.wallet}`,
|
|
582
|
+
` items ${items}`,
|
|
583
|
+
` schedule ${e.analysis && e.analysis.schedule === 'daily' ? 'daily' : 'off (Assess Now)'}`,
|
|
584
|
+
];
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async function midasCheck(ctx, [file]) {
|
|
588
|
+
const r = repo(ctx);
|
|
589
|
+
const { target, declaration } = readDeclaration(ctx, r, file, 'midas');
|
|
590
|
+
const { data } = await ctx.call('POST', midasDeclRoute(r, '/check'), { declaration });
|
|
591
|
+
const head = data.ok
|
|
592
|
+
? `${path.basename(target)} is valid${(data.warnings || []).length ? `, with ${data.warnings.length} warning(s)` : ''}. Publish it with: plaiful midas publish`
|
|
593
|
+
: `${path.basename(target)} has ${data.errors.length} error(s); fix them and check again.`;
|
|
594
|
+
ctx.out([head, ...(data.ok ? midasEffectiveText(data.effective) : []), ...findingsText(data)].join('\n'), data);
|
|
595
|
+
return data.ok ? 0 : 1;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
async function midasPublish(ctx, [file]) {
|
|
599
|
+
const r = repo(ctx);
|
|
600
|
+
const { target, declaration } = readDeclaration(ctx, r, file, 'midas');
|
|
601
|
+
const { data } = await ctx.call('PUT', midasDeclRoute(r), { declaration });
|
|
602
|
+
if (!data.published) {
|
|
603
|
+
ctx.out([`Not published: ${data.error || `${path.basename(target)} has ${(data.errors || []).length} error(s)`}`, ...findingsText(data)].join('\n'), data);
|
|
604
|
+
return 1;
|
|
605
|
+
}
|
|
606
|
+
ctx.out([`Published ${path.basename(target)} for ${r.product}.`, ...midasEffectiveText(data.effective), ...findingsText(data),
|
|
607
|
+
'Check it took: plaiful midas show'].join('\n'), data);
|
|
608
|
+
return 0;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async function midasShow(ctx) {
|
|
612
|
+
const r = repo(ctx);
|
|
613
|
+
const { data } = await ctx.call('GET', midasDeclRoute(r));
|
|
614
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
615
|
+
const head = data.declaration
|
|
616
|
+
? `${r.product}'s MIDAS declaration, published ${data.updated_at || '(date unknown)'}${data.published_by ? ` by ${data.published_by}` : ''}:`
|
|
617
|
+
: `${r.product} has no MIDAS declaration yet; MIDAS uses its defaults:`;
|
|
618
|
+
ctx.out([head, ...midasEffectiveText(data.effective), ...findingsText({ warnings: data.warnings })].join('\n'));
|
|
619
|
+
return 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// ── MIDAS's analysis of the game (multi-product-economy-plan.md §9.1; the plaiful-economy-review skill) ──────────
|
|
623
|
+
|
|
624
|
+
const num = (v) => (v == null ? '—' : Number(v).toLocaleString('en-US', { maximumFractionDigits: 1 }));
|
|
625
|
+
const HEALTH_WORDS = { green: 'healthy', amber: 'needs a look', red: 'out of balance' };
|
|
626
|
+
|
|
627
|
+
/** What a flag means, in plain words (the CMS's Balance tab says the same). */
|
|
628
|
+
function flagWords(f) {
|
|
629
|
+
const k = f.kind || '';
|
|
630
|
+
switch (f.metric) {
|
|
631
|
+
case 'unpaidKind': return f.priced ? `no quest pays ${k} (it's priced: check OVID's rewards.types)` : `no quest pays ${k}: it has no quest price`;
|
|
632
|
+
case 'neverSpent': return `${num(f.value)} ${k} earned, none spent`;
|
|
633
|
+
case 'earnExceedsSpend': return `players earn ${f.value}× the ${k} they spend`;
|
|
634
|
+
case 'spendExceedsEarn': return `players spend ${f.value}× the ${k} they earn`;
|
|
635
|
+
case 'noReward': return 'pays nothing (no step carries effort)';
|
|
636
|
+
case 'rewardOutlier': return `pays ${num(f.value)} ${k}, over ${Math.round(f.value / f.median)}× the median quest (${num(f.median)})`;
|
|
637
|
+
case 'itemValueOutlier': return `worth ${num(f.value)} ${k}, ${f.direction} its group's median (${num(f.median)})`;
|
|
638
|
+
case 'unaffordable': return `costs ${num(f.value)} typical quests' ${k}`;
|
|
639
|
+
case 'trivialCost': return `costs under a quarter of one typical quest's ${k}`;
|
|
640
|
+
default: return f.metric;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
async function midasHealth(ctx) {
|
|
645
|
+
const r = repo(ctx);
|
|
646
|
+
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/midas/health`);
|
|
647
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
648
|
+
const s = data.summary;
|
|
649
|
+
if (!s || data.error) { ctx.out(`${r.product} has no economy analysis yet. Run one: plaiful midas assess`); return 0; }
|
|
650
|
+
const lines = [`${r.product}'s economy (dev): ${HEALTH_WORDS[s.overallHealth] || s.overallHealth}. ${s.flaggedItems} of ${s.totalItems} flagged; analyzed ${data.analyzedAt || '?'}`];
|
|
651
|
+
if (!s.priced) lines.push(' ! quests aren\'t priced yet: plaiful midas pricing set <kind> --base <n> --per-effort <n>');
|
|
652
|
+
for (const k of s.kinds || []) {
|
|
653
|
+
lines.push(` ${k.label}${k.label !== k.id ? ` (${k.id})` : ''}${k.spendable ? '' : ', builds up'}: ${num(k.supply)} from quests, median ${num(k.medianReward)} per quest, ${k.questsPaying} quests pay it`
|
|
654
|
+
+ (s.wallet && s.wallet !== 'none' ? `; last 30 days earned ${num(k.earned)}, spent ${num(k.spent)}` : '')
|
|
655
|
+
+ (k.held !== undefined ? `; players hold ${num(k.held)} (${k.holders} of ${k.players})` : ''));
|
|
656
|
+
}
|
|
657
|
+
lines.push('Details: plaiful midas balance; proposals: plaiful midas proposals');
|
|
658
|
+
ctx.out(lines.join('\n'), data);
|
|
659
|
+
return 0;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
async function midasBalance(ctx) {
|
|
663
|
+
const r = repo(ctx);
|
|
664
|
+
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/midas/balance`);
|
|
665
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
666
|
+
const items = (data.items || []).filter((si) => ctx.flags.all || !si.healthy);
|
|
667
|
+
if (!data.items || data.error) { ctx.out(`${r.product} has no economy analysis yet. Run one: plaiful midas assess`); return 0; }
|
|
668
|
+
const lines = [`${r.product}: ${items.length} ${ctx.flags.all ? 'checked' : 'flagged'} of ${data.items.length}${ctx.flags.all ? '' : ' (--all for everything)'}`];
|
|
669
|
+
for (const si of items) {
|
|
670
|
+
const it = si.item;
|
|
671
|
+
lines.push(` ${si.healthy ? '·' : si.severity === 'high' ? '✗' : '!'} ${it.name} [${it.category}]${si.flags.length ? ` ${si.flags.map(flagWords).join('; ')}` : ''}`);
|
|
672
|
+
}
|
|
673
|
+
ctx.out(lines.join('\n'), data);
|
|
674
|
+
return 0;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
async function midasProposals(ctx) {
|
|
678
|
+
const r = repo(ctx);
|
|
679
|
+
const qs = ctx.flags.status ? `?status=${encodeURIComponent(ctx.flags.status)}` : '';
|
|
680
|
+
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/midas/proposals${qs}`);
|
|
681
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
682
|
+
const list = data.proposals || [];
|
|
683
|
+
const lines = [`${r.product}: ${list.length} ${data.status || 'pending'} proposal(s)${list.length ? '. An editor approves them on the Economy page in the CMS (Proposals).' : ''}`];
|
|
684
|
+
for (const p of list) {
|
|
685
|
+
const change = p.proposedValue == null ? 'for the team to act on'
|
|
686
|
+
: `${p.field || 'value'}: ${p.currentValue == null ? 'none' : p.currentValue} → ${p.proposedValue}`;
|
|
687
|
+
lines.push(` [${p.severity}] ${p.type.replace(/_/g, ' ').toLowerCase()} · ${p.targetName}: ${change}`);
|
|
688
|
+
if (p.rationale) lines.push(` ${p.rationale}`);
|
|
689
|
+
}
|
|
690
|
+
ctx.out(lines.join('\n'), data);
|
|
691
|
+
return 0;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** `plaiful midas wallet <player>`: one player's balances and recent earning and spending (wallet "platform"). */
|
|
695
|
+
async function midasWallet(ctx, [player]) {
|
|
696
|
+
const r = repo(ctx);
|
|
697
|
+
if (!player) throw new UsageError('which player? plaiful midas wallet <player id> (their Firebase uid)');
|
|
698
|
+
const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/midas/wallet/${encodeURIComponent(player)}`);
|
|
699
|
+
if (ctx.flags.json) { ctx.out(data); return 0; }
|
|
700
|
+
const label = Object.fromEntries((data.kinds || []).map((k) => [k.id, k.label]));
|
|
701
|
+
const lines = [`${player} in ${r.product} (dev): ${Object.entries(data.balances || {}).map(([k, v]) => `${num(v)} ${label[k] || k}`).join(' · ') || 'nothing yet'}`];
|
|
702
|
+
for (const e of data.history || []) lines.push(` ${e.ts} ${e.delta > 0 ? '+' : ''}${num(e.delta)} ${label[e.kind] || e.kind} ${e.reason}${e.source_id ? ` (${e.source_id})` : ''}`);
|
|
703
|
+
ctx.out(lines.join('\n'), data);
|
|
704
|
+
return 0;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** `plaiful midas ledger check <file>`: would POST /game/wallet/report accept these entries (wallet "game")? */
|
|
708
|
+
async function midasLedger(ctx, [sub, file]) {
|
|
709
|
+
if (sub !== 'check' || !file) throw new UsageError('plaiful midas ledger check <file.json> (a list of { kind, delta, reason, idempotency_key }, or { "entries": [...] })');
|
|
710
|
+
const r = repo(ctx);
|
|
711
|
+
const { json } = readJsonFile(ctx, file);
|
|
712
|
+
const entries = Array.isArray(json) ? json : json && json.entries;
|
|
713
|
+
const { data } = await ctx.call('POST', `/partner/${encodeURIComponent(r.product)}/midas/ledger/check`, { entries });
|
|
714
|
+
if (ctx.flags.json) { ctx.out(data); return data.success ? 0 : 1; }
|
|
715
|
+
const lines = [data.success ? `${data.count} entries: all valid. Your game sends them with POST /game/wallet/report.` : `${(data.problems || []).length} problem(s):`];
|
|
716
|
+
for (const p of data.problems || []) lines.push(` ✗ ${p}`);
|
|
717
|
+
if (data.note) lines.push(` ! ${data.note}`);
|
|
718
|
+
ctx.out(lines.join('\n'), data);
|
|
719
|
+
return data.success ? 0 : 1;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
async function midasAssess(ctx) {
|
|
723
|
+
const r = repo(ctx);
|
|
724
|
+
const { data } = await ctx.call('POST', `/partner/${encodeURIComponent(r.product)}/midas/assess`, {});
|
|
725
|
+
ctx.out(`MIDAS is analyzing ${r.product}'s economy (about a minute). Then: plaiful midas health`, data);
|
|
726
|
+
return 0;
|
|
727
|
+
}
|
|
728
|
+
|
|
490
729
|
// ── Seeding (phase 2) ──────────────────────────────────────────────────────────────────────────────────────────
|
|
491
730
|
|
|
492
731
|
const STORES = ['world', 'lore', 'map', 'personas'];
|
|
@@ -740,6 +979,10 @@ const priceText = (p) => (p && Object.keys(p).length ? Object.entries(p).map(([k
|
|
|
740
979
|
|
|
741
980
|
async function quests(ctx, [sub, id]) {
|
|
742
981
|
const r = repo(ctx);
|
|
982
|
+
if (sub === 'delete') {
|
|
983
|
+
if (!id) throw new UsageError('which quest? plaiful quests delete <questId>');
|
|
984
|
+
return ovidEdit(ctx, 'delete_quest', { quest_id: id }, `Deleted quest ${id}.`);
|
|
985
|
+
}
|
|
743
986
|
if (sub === 'show') {
|
|
744
987
|
if (!id) throw new UsageError('which quest? plaiful quests show <id>');
|
|
745
988
|
const { data } = await ctx.call('GET', ovidRoute(r, `quests/${encodeURIComponent(id)}`));
|
|
@@ -756,7 +999,7 @@ async function quests(ctx, [sub, id]) {
|
|
|
756
999
|
ctx.out(lines.join('\n'), data);
|
|
757
1000
|
return 0;
|
|
758
1001
|
}
|
|
759
|
-
if (sub) throw new UsageError(`plaiful quests, or quests show <id> (not "${sub}")`);
|
|
1002
|
+
if (sub) throw new UsageError(`plaiful quests, or quests show | delete <id> (not "${sub}")`);
|
|
760
1003
|
const qs = new URLSearchParams();
|
|
761
1004
|
if (ctx.flags.track) qs.set('track', ctx.flags.track);
|
|
762
1005
|
if (ctx.flags.series) qs.set('series', ctx.flags.series);
|
|
@@ -776,6 +1019,7 @@ async function quests(ctx, [sub, id]) {
|
|
|
776
1019
|
|
|
777
1020
|
async function lore(ctx, [sub, id]) {
|
|
778
1021
|
const r = repo(ctx);
|
|
1022
|
+
if (['add', 'reveal', 'hide', 'remove'].includes(sub)) return loreEdit(ctx, sub, id);
|
|
779
1023
|
if (sub === 'show') {
|
|
780
1024
|
if (!id) throw new UsageError('which set? plaiful lore show <setId>');
|
|
781
1025
|
const { data } = await ctx.call('GET', ovidRoute(r, `lore/${encodeURIComponent(id)}`));
|
|
@@ -784,7 +1028,7 @@ async function lore(ctx, [sub, id]) {
|
|
|
784
1028
|
ctx.out(lines.join('\n'), data);
|
|
785
1029
|
return 0;
|
|
786
1030
|
}
|
|
787
|
-
if (sub) throw new UsageError(`plaiful lore, or lore show
|
|
1031
|
+
if (sub) throw new UsageError(`plaiful lore, or lore show | add | reveal | hide | remove (not "${sub}")`);
|
|
788
1032
|
const { data } = await ctx.call('GET', ovidRoute(r, 'lore'));
|
|
789
1033
|
const lines = [`${r.product}'s lore in dev: ${data.sets.length} sets`];
|
|
790
1034
|
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}` : ''}`);
|
|
@@ -792,7 +1036,11 @@ async function lore(ctx, [sub, id]) {
|
|
|
792
1036
|
return 0;
|
|
793
1037
|
}
|
|
794
1038
|
|
|
795
|
-
async function world(ctx) {
|
|
1039
|
+
async function world(ctx, [sub, ...rest] = []) {
|
|
1040
|
+
if (sub) {
|
|
1041
|
+
if (!['truth', 'faction', 'var', 'set'].includes(sub)) throw new UsageError(`plaiful world, or world truth | faction | var | set (not "${sub}")`);
|
|
1042
|
+
return worldEdit(ctx, sub, rest);
|
|
1043
|
+
}
|
|
796
1044
|
const r = repo(ctx);
|
|
797
1045
|
const { data } = await ctx.call('GET', ovidRoute(r, 'world'));
|
|
798
1046
|
const c = data.clock;
|
|
@@ -807,6 +1055,66 @@ async function world(ctx) {
|
|
|
807
1055
|
return 0;
|
|
808
1056
|
}
|
|
809
1057
|
|
|
1058
|
+
// ── OVID's edits (shared/ovid/edit-ops.js, the list OVID's chat tools use) ──────────────────────────────────────
|
|
1059
|
+
|
|
1060
|
+
/** A value typed on the command line: true / false, a number, or the word itself. */
|
|
1061
|
+
const typedValue = (v) => (v === 'true' ? true : v === 'false' ? false : v !== '' && !Number.isNaN(Number(v)) ? Number(v) : v);
|
|
1062
|
+
|
|
1063
|
+
async function ovidEdit(ctx, op, params, done) {
|
|
1064
|
+
const r = repo(ctx);
|
|
1065
|
+
const { data } = await ctx.call('POST', ovidRoute(r, 'edit'), { op, ...params, ...(ctx.flags.force ? { force: true } : {}) });
|
|
1066
|
+
ctx.out(`${done}${data.message ? ` (${data.message})` : ''}`, data);
|
|
1067
|
+
return 0;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
async function eventsEdit(ctx, [eventId]) {
|
|
1071
|
+
if (!eventId) throw new UsageError('which event? plaiful events edit <eventId> --title "…" (plaiful world lists them)');
|
|
1072
|
+
const params = { event_id: eventId };
|
|
1073
|
+
for (const [flag, key] of [['title', 'title'], ['description', 'description'], ['category', 'category']]) if (ctx.flags[flag] !== undefined) params[key] = ctx.flags[flag];
|
|
1074
|
+
if (ctx.flags.order !== undefined) params.sort_order = Number(ctx.flags.order);
|
|
1075
|
+
if (ctx.flags.directives) params.directives = readJsonFile(ctx, ctx.flags.directives).json;
|
|
1076
|
+
if (Object.keys(params).length === 1) throw new UsageError('what to change? --title, --description, --category, --order or --directives <file.json>');
|
|
1077
|
+
return ovidEdit(ctx, 'update_event', params, `Updated ${eventId}.`);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
async function eventsDelete(ctx, [eventId]) {
|
|
1081
|
+
if (!eventId) throw new UsageError('which event? plaiful events delete <eventId>');
|
|
1082
|
+
return ovidEdit(ctx, 'delete_event', { event_id: eventId }, `Deleted ${eventId} and the events under it.`);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
async function loreEdit(ctx, sub, id) {
|
|
1086
|
+
if (!id) throw new UsageError(`plaiful lore ${sub} <${sub === 'add' || sub === 'remove' ? 'setId' : 'snippetId'}>`);
|
|
1087
|
+
if (sub === 'add') {
|
|
1088
|
+
if (!ctx.flags.narrative) throw new UsageError('--narrative "…" is required: the lore itself');
|
|
1089
|
+
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}.`);
|
|
1090
|
+
}
|
|
1091
|
+
if (sub === 'reveal') return ovidEdit(ctx, 'reveal_lore', { snippet_id: id }, `${id} is known to the world now.`);
|
|
1092
|
+
if (sub === 'hide') return ovidEdit(ctx, 'hide_lore', { snippet_id: id }, `${id} is hidden again (players keep what they found).`);
|
|
1093
|
+
return ovidEdit(ctx, 'remove_lore_set', { lore_set_id: id }, `Removed ${id} and its snippets.`);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
async function worldEdit(ctx, sub, [id, value]) {
|
|
1097
|
+
if (sub === 'truth') {
|
|
1098
|
+
if (!id || !ctx.flags.statement) throw new UsageError('plaiful world truth <id> --statement "…"');
|
|
1099
|
+
return ovidEdit(ctx, 'add_truth', { truth_id: id, statement: ctx.flags.statement, category: ctx.flags.category, scope: ctx.flags.scope }, `Added truth ${id}.`);
|
|
1100
|
+
}
|
|
1101
|
+
if (sub === 'faction') {
|
|
1102
|
+
if (!id || !ctx.flags.name) throw new UsageError('plaiful world faction <id> --name "…"');
|
|
1103
|
+
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}.`);
|
|
1104
|
+
}
|
|
1105
|
+
if (!id || value === undefined) throw new UsageError(`plaiful world ${sub} <id> <value>${sub === 'set' ? ' --reason "…"' : ''}`);
|
|
1106
|
+
if (sub === 'var') return ovidEdit(ctx, 'add_world_variable', { variable_id: id, value: typedValue(value), description: ctx.flags.description }, `Added world variable ${id} = ${value}.`);
|
|
1107
|
+
if (!ctx.flags.reason) throw new UsageError('--reason "…" is required: why the world changed');
|
|
1108
|
+
return ovidEdit(ctx, 'set_world_variable', { variable_id: id, value: typedValue(value), reason: ctx.flags.reason }, `Set ${id} = ${value}.`);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
async function canon(ctx, [kind, id, status]) {
|
|
1112
|
+
if (!['event', 'quest'].includes(kind) || !id || !['official', 'draft', 'rejected'].includes(status)) {
|
|
1113
|
+
throw new UsageError('plaiful canon event|quest <id> official|draft|rejected');
|
|
1114
|
+
}
|
|
1115
|
+
return ovidEdit(ctx, 'set_canon_status', { kind, id, status }, `${kind} ${id} is ${status} now.`);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
810
1118
|
// ── Event scripts: OVID's cinematic for a state event ────────────────────────────────────────────────────────────
|
|
811
1119
|
|
|
812
1120
|
const SCRIPT_WAIT_MS = 5 * 60 * 1000;
|
|
@@ -831,7 +1139,7 @@ function scriptHeader(data) {
|
|
|
831
1139
|
|
|
832
1140
|
async function eventsScript(ctx, [sub, eventId, version]) {
|
|
833
1141
|
const r = repo(ctx);
|
|
834
|
-
if (!['write', 'get', 'export'].includes(sub)) throw new UsageError(`plaiful events script write | get | export <eventId> (not "${sub || ''}")`);
|
|
1142
|
+
if (!['write', 'get', 'export', 'approve'].includes(sub)) throw new UsageError(`plaiful events script write | get | export | approve <eventId> (not "${sub || ''}")`);
|
|
835
1143
|
if (!eventId) throw new UsageError(`which event? plaiful events script ${sub} <eventId> (plaiful world lists them)`);
|
|
836
1144
|
if (version !== undefined && !/^\d+$/.test(version)) throw new UsageError(`the version is a number (not "${version}")`);
|
|
837
1145
|
const route = ovidRoute(r, `events/${encodeURIComponent(eventId)}/script`);
|
|
@@ -841,6 +1149,12 @@ async function eventsScript(ctx, [sub, eventId, version]) {
|
|
|
841
1149
|
if (version) qs.set('version', version);
|
|
842
1150
|
return (await ctx.call('GET', `${route}${qs.toString() ? `?${qs}` : ''}`)).data;
|
|
843
1151
|
};
|
|
1152
|
+
if (sub === 'approve') {
|
|
1153
|
+
if (!version) throw new UsageError(`which version? plaiful events script approve ${eventId} <version> (plaiful events script get ${eventId} lists them)`);
|
|
1154
|
+
const { data } = await ctx.call('POST', `${route}/approve`, { version: Number(version), ...(ctx.flags.retire ? { retire: true } : {}), ...(ctx.flags.force ? { force: true } : {}) });
|
|
1155
|
+
ctx.out(data.status === 'approved' ? `Approved ${eventId} v${version}: the game gets this version.` : `Retired ${eventId} v${version}.`, data);
|
|
1156
|
+
return 0;
|
|
1157
|
+
}
|
|
844
1158
|
if (sub === 'write') {
|
|
845
1159
|
if (version !== undefined) throw new UsageError('write makes a new version; it takes no version number');
|
|
846
1160
|
const { data } = await ctx.call('POST', route, { ...(ctx.flags.note ? { note: ctx.flags.note } : {}), ...(ctx.flags.force ? { force: true } : {}) });
|
|
@@ -885,11 +1199,86 @@ async function eventsScript(ctx, [sub, eventId, version]) {
|
|
|
885
1199
|
return 0;
|
|
886
1200
|
}
|
|
887
1201
|
|
|
1202
|
+
// ── Storyboards (SPRITE_ANIMATION.md §13) ──────────────────────────────────────────────────────────────────────
|
|
1203
|
+
|
|
1204
|
+
const frameLines = (board) => (board.frames || []).map((f) => ` ${f.id.padEnd(6)} ${String(f.framing || '').padEnd(8)} ${(f.caption || '').split('\n')[0].slice(0, 90)}`);
|
|
1205
|
+
|
|
1206
|
+
async function eventsStoryboard(ctx, [sub, eventId, version]) {
|
|
1207
|
+
const r = repo(ctx);
|
|
1208
|
+
if (!['draw', 'get'].includes(sub)) throw new UsageError(`plaiful events storyboard draw | get <eventId> (not "${sub || ''}")`);
|
|
1209
|
+
if (!eventId) throw new UsageError(`which event? plaiful events storyboard ${sub} <eventId>`);
|
|
1210
|
+
if (version !== undefined && !/^\d+$/.test(version)) throw new UsageError(`the version is a number (not "${version}")`);
|
|
1211
|
+
const route = ovidRoute(r, `events/${encodeURIComponent(eventId)}/storyboard`);
|
|
1212
|
+
const read = async (v) => (await ctx.call('GET', `${route}${v ? `?version=${v}` : ''}`)).data;
|
|
1213
|
+
if (sub === 'draw') {
|
|
1214
|
+
if (!ctx.flags.style) throw new UsageError('--style <style> is required: the image style to draw in');
|
|
1215
|
+
const { data } = await ctx.call('POST', route, { style: ctx.flags.style, ...(version ? { version: Number(version) } : {}),
|
|
1216
|
+
...(ctx.flags.aspect ? { aspect: ctx.flags.aspect } : {}), ...(ctx.flags.frame ? { only: [ctx.flags.frame] } : {}) });
|
|
1217
|
+
const lines = [`Drawing ${eventId} v${data.version}: ${ctx.flags.frame ? `frame ${ctx.flags.frame}` : `${data.frames.length} frames`} (job ${data.job_id}).`];
|
|
1218
|
+
if ((data.cast_without_art || []).length) lines.push(` no art to match for ${data.cast_without_art.join(', ')}: drawn from the script's words`);
|
|
1219
|
+
if (!ctx.flags.wait) {
|
|
1220
|
+
lines.push(`It takes a few minutes: plaiful events storyboard get ${eventId} ${data.version}`);
|
|
1221
|
+
ctx.out(lines.join('\n'), data);
|
|
1222
|
+
return 0;
|
|
1223
|
+
}
|
|
1224
|
+
const until = Date.now() + SCRIPT_WAIT_MS * 2;
|
|
1225
|
+
let now = null;
|
|
1226
|
+
while (Date.now() < until) {
|
|
1227
|
+
await ctx.io.sleep(SCRIPT_POLL_MS);
|
|
1228
|
+
now = await read(data.version);
|
|
1229
|
+
if (now.storyboard && now.storyboard.job_id === data.job_id) break;
|
|
1230
|
+
}
|
|
1231
|
+
const done = now && now.storyboard && now.storyboard.job_id === data.job_id;
|
|
1232
|
+
lines.push(done ? `Done: ${now.storyboard.frames.length} frames.` : 'Still drawing; plaiful events storyboard get shows it when it lands.');
|
|
1233
|
+
if (done) lines.push(...frameLines(now.storyboard));
|
|
1234
|
+
ctx.out(lines.join('\n'), now || data);
|
|
1235
|
+
return done ? 0 : 1;
|
|
1236
|
+
}
|
|
1237
|
+
const data = await read(version);
|
|
1238
|
+
if (!data.storyboard) {
|
|
1239
|
+
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);
|
|
1240
|
+
return 0;
|
|
1241
|
+
}
|
|
1242
|
+
const lines = [`${eventId} v${data.version}: ${data.storyboard.frames.length} frames, style ${data.storyboard.style_ref}, ${data.storyboard.aspect}`, ...frameLines(data.storyboard)];
|
|
1243
|
+
if (ctx.flags.out) {
|
|
1244
|
+
const dir = path.resolve(ctx.io.cwd(), ctx.flags.out);
|
|
1245
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1246
|
+
for (const f of data.storyboard.frames) {
|
|
1247
|
+
if (!f.url) continue;
|
|
1248
|
+
const res = await ctx.io.fetch(f.url, { method: 'GET', headers: {} });
|
|
1249
|
+
if (!res.ok) throw new ApiError(res.status, { error: `couldn't download ${f.id}` });
|
|
1250
|
+
fs.writeFileSync(path.join(dir, `${f.id}.png`), Buffer.from(await res.arrayBuffer()));
|
|
1251
|
+
}
|
|
1252
|
+
lines.push(`saved the frames to ${dir}`);
|
|
1253
|
+
}
|
|
1254
|
+
ctx.out(lines.join('\n'), data);
|
|
1255
|
+
return 0;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
888
1258
|
// ── What the agents made ────────────────────────────────────────────────────────────────────────────────────────
|
|
889
1259
|
|
|
890
|
-
const countsText = (a) => `${a.records} records: ${a.made} made, ${a.pending} pending, ${a.failed} failed, ${a.none} none yet${a.truncated ? ' (first 2000)' : ''}`;
|
|
1260
|
+
const countsText = (a) => `${a.records} records: ${a.made} made, ${a.pending} pending, ${a.failed} failed, ${a.none} none yet${a.step_failed ? `; ${a.step_failed} with a failed step` : ''}${a.truncated ? ' (first 2000)' : ''}`;
|
|
1261
|
+
|
|
1262
|
+
async function assetsRegenerate(ctx, [agent, ...uuids]) {
|
|
1263
|
+
if (!agent) throw new UsageError('which agent? plaiful assets regenerate <agent> [uuids...] (or --all, --state <state>)');
|
|
1264
|
+
const r = repo(ctx);
|
|
1265
|
+
const body = {};
|
|
1266
|
+
if (uuids.length) body.records = uuids;
|
|
1267
|
+
if (ctx.flags.all) body.all = true;
|
|
1268
|
+
if (ctx.flags.state) body.state = String(ctx.flags.state);
|
|
1269
|
+
if (!body.records && !body.all && !body.state) throw new UsageError('which records? list their uuids, or --all, or --state failed|none|made|step_failed');
|
|
1270
|
+
if (ctx.flags.steps !== undefined) {
|
|
1271
|
+
if (ctx.flags.steps === true) throw new UsageError('--steps takes step names (--steps depth,normal) or all');
|
|
1272
|
+
body.steps = String(ctx.flags.steps) === 'all' ? 'all' : String(ctx.flags.steps).split(',').map((x) => x.trim()).filter(Boolean);
|
|
1273
|
+
}
|
|
1274
|
+
const { data } = await ctx.call('POST', `/partner/${encodeURIComponent(r.product)}/assets/${encodeURIComponent(agent)}/regenerate`, body);
|
|
1275
|
+
const what = data.mode === 'steps' ? `the ${data.steps.join(', ')} step${data.steps.length !== 1 ? 's' : ''} of ${data.style}` : `a new picture in ${data.style}`;
|
|
1276
|
+
ctx.out(`Started ${what} for ${data.records} ${agent} record${data.records !== 1 ? 's' : ''}. They render in the background: plaiful assets ${agent} shows each one as it lands.`, data);
|
|
1277
|
+
return 0;
|
|
1278
|
+
}
|
|
891
1279
|
|
|
892
|
-
async function assets(ctx, [agent]) {
|
|
1280
|
+
async function assets(ctx, [agent, ...rest]) {
|
|
1281
|
+
if (agent === 'regenerate') return assetsRegenerate(ctx, rest);
|
|
893
1282
|
const r = repo(ctx);
|
|
894
1283
|
const base = `/partner/${encodeURIComponent(r.product)}/assets`;
|
|
895
1284
|
if (!agent) {
|
|
@@ -912,6 +1301,9 @@ async function assets(ctx, [agent]) {
|
|
|
912
1301
|
const files = [rec.files && `${rec.files.base}.{${rec.files.try.join('|')}}`, ...Object.values(rec.media_files || {})].filter(Boolean);
|
|
913
1302
|
const where = rec.state === 'made' ? files.join(' ') : '';
|
|
914
1303
|
lines.push(` ${rec.state.padEnd(8)} ${rec.name || '(unnamed)'} ${rec.uuid}${why ? ` ${why}` : ''}${where ? ` ${where}` : ''}`);
|
|
1304
|
+
// A step that failed (a depth map): the art is made, the step's file isn't. Re-run it in the Library: Regenerate → Steps.
|
|
1305
|
+
for (const [step, err] of Object.entries(rec.step_errors || {})) lines.push(` ! step ${step} failed: ${err}`);
|
|
1306
|
+
if (rec.depth_match_error) lines.push(` ! depth not matched to the overview: ${rec.depth_match_error}`);
|
|
915
1307
|
}
|
|
916
1308
|
ctx.out(lines.join('\n'), data);
|
|
917
1309
|
return 0;
|
|
@@ -1199,17 +1591,35 @@ const COMMANDS = {
|
|
|
1199
1591
|
'ovid check': (ctx, rest) => ovidCheck(ctx, rest),
|
|
1200
1592
|
'ovid publish': (ctx, rest) => ovidPublish(ctx, rest),
|
|
1201
1593
|
'ovid show': (ctx) => ovidShow(ctx),
|
|
1594
|
+
'hermes strategy': (ctx, [sub, ...rest]) => {
|
|
1595
|
+
if (sub === 'check') return hermesStrategyCheck(ctx, rest);
|
|
1596
|
+
if (sub === 'publish') return hermesStrategyPublish(ctx, rest);
|
|
1597
|
+
return hermesStrategyShow(ctx, sub ? [sub, ...rest] : []);
|
|
1598
|
+
},
|
|
1202
1599
|
seed: (ctx, [store, ...paths]) => seedStore(ctx, store, paths),
|
|
1203
1600
|
status: (ctx) => status(ctx),
|
|
1204
1601
|
lists: (ctx, rest) => lists(ctx, rest),
|
|
1205
1602
|
agents: (ctx, rest) => agents(ctx, rest),
|
|
1206
1603
|
records: (ctx, rest) => records(ctx, rest),
|
|
1207
1604
|
'midas pricing': (ctx, rest) => midasPricing(ctx, rest),
|
|
1605
|
+
'midas check': (ctx, rest) => midasCheck(ctx, rest),
|
|
1606
|
+
'midas publish': (ctx, rest) => midasPublish(ctx, rest),
|
|
1607
|
+
'midas show': (ctx) => midasShow(ctx),
|
|
1608
|
+
'midas health': (ctx) => midasHealth(ctx),
|
|
1609
|
+
'midas balance': (ctx) => midasBalance(ctx),
|
|
1610
|
+
'midas proposals': (ctx) => midasProposals(ctx),
|
|
1611
|
+
'midas assess': (ctx) => midasAssess(ctx),
|
|
1612
|
+
'midas wallet': (ctx, rest) => midasWallet(ctx, rest),
|
|
1613
|
+
'midas ledger': (ctx, rest) => midasLedger(ctx, rest),
|
|
1208
1614
|
quests: (ctx, rest) => quests(ctx, rest),
|
|
1209
1615
|
assets: (ctx, rest) => assets(ctx, rest),
|
|
1210
1616
|
lore: (ctx, rest) => lore(ctx, rest),
|
|
1211
|
-
world: (ctx) => world(ctx),
|
|
1617
|
+
world: (ctx, rest) => world(ctx, rest),
|
|
1618
|
+
'events edit': (ctx, rest) => eventsEdit(ctx, rest),
|
|
1619
|
+
'events delete': (ctx, rest) => eventsDelete(ctx, rest),
|
|
1620
|
+
canon: (ctx, rest) => canon(ctx, rest),
|
|
1212
1621
|
'events script': (ctx, rest) => eventsScript(ctx, rest),
|
|
1622
|
+
'events storyboard': (ctx, rest) => eventsStoryboard(ctx, rest),
|
|
1213
1623
|
'animation sets': (ctx, rest) => animationSets(ctx, rest),
|
|
1214
1624
|
'animation run': (ctx, rest) => animationRun(ctx, rest),
|
|
1215
1625
|
upload: (ctx, files) => upload(ctx, files),
|