@plaiful/cli 0.10.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.
Files changed (3) hide show
  1. package/README.md +7 -0
  2. package/package.json +21 -21
  3. package/src/cli.js +264 -6
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,6 +73,8 @@ 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
@@ -98,8 +101,12 @@ plaiful records import crew-portrait # dry run: records you wrote (reso
98
101
  # into the agent's table; --apply writes them, --no-render skips the art
99
102
  plaiful lists # the product's SSM lists
100
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
101
107
  plaiful midas pricing # what each quest pays, in your reward kinds (MIDAS); delivered in the quest's rewards
102
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)
103
110
  plaiful upload ovid-map-biomes-tiles.json ovid-map-kingdoms-tiles.json ovid-map-colors.json # map tiles → map-data/
104
111
  plaiful whoami # who you are (or which key), and your products
105
112
  plaiful logout
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "name": "@plaiful/cli",
3
- "version": "0.10.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
@@ -77,14 +77,31 @@ const HELP = `plaiful ${version}: work on your Plaiful product from your game re
77
77
  plaiful records import <agent> [file] dry run: records you wrote, into the agent's table (default file:
78
78
  resources/records/<product>/<agent>.json; matched on the agent's duplicate field)
79
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
80
91
  plaiful midas pricing what MIDAS pays per quest, in your reward kinds (delivered in each quest's rewards)
81
92
  plaiful midas pricing set <kind> --base <n> --per-effort <n> price a kind (either option alone keeps the other)
82
93
  plaiful midas pricing unset <kind> stop pricing a kind
83
94
  plaiful midas pricing weight <step> <n> how much a quest step counts (combat, gather, explore, ...)
84
95
  plaiful midas pricing apply [file] replace it all from a file (default:
85
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)
86
100
  plaiful assets per agent: records, and how many have their art made, pending, failed or none
87
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)
88
105
  --state made|pending|failed|none --limit <n> (default 50)
89
106
  plaiful animation sets the animation sets you can use (a set = a list of animation states, one sprite
90
107
  sheet each, run together on a character): the built-ins, Plaiful's and yours
@@ -125,7 +142,7 @@ function parse(argv) {
125
142
  for (let i = 0; i < argv.length; i += 1) {
126
143
  const a = argv[i];
127
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;
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)) {
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)) {
129
146
  if (argv[i + 1] === undefined) throw new UsageError(`${a} needs a value`);
130
147
  flags[a.slice(2)] = argv[i += 1];
131
148
  } else if (a.startsWith('--')) throw new UsageError(`unknown option ${a}`);
@@ -451,9 +468,9 @@ function ignoreClientConfig(docsDir) {
451
468
  return { added, tracked };
452
469
  }
453
470
 
454
- function readDeclaration(ctx, r, file) {
455
- const target = path.resolve(ctx.io.cwd(), file || path.join(r.docsDir, `${r.product}-ovid-declaration.json`));
456
- if (!fs.existsSync(target)) throw new UsageError(`no declaration at ${target} (write it first: ovid-declaration.md)`);
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)`);
457
474
  try { return { target, declaration: JSON.parse(fs.readFileSync(target, 'utf8')) }; } catch (e) {
458
475
  throw new UsageError(`${target} isn't valid JSON: ${e.message}`);
459
476
  }
@@ -495,6 +512,51 @@ async function ovidPublish(ctx, [file]) {
495
512
  return 0;
496
513
  }
497
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
+
498
560
  async function ovidShow(ctx) {
499
561
  const r = repo(ctx);
500
562
  const { data } = await ctx.call('GET', `/partner/${encodeURIComponent(r.product)}/ovid/declaration`);
@@ -504,6 +566,166 @@ async function ovidShow(ctx) {
504
566
  return 0;
505
567
  }
506
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
+
507
729
  // ── Seeding (phase 2) ──────────────────────────────────────────────────────────────────────────────────────────
508
730
 
509
731
  const STORES = ['world', 'lore', 'map', 'personas'];
@@ -1035,9 +1257,28 @@ async function eventsStoryboard(ctx, [sub, eventId, version]) {
1035
1257
 
1036
1258
  // ── What the agents made ────────────────────────────────────────────────────────────────────────────────────────
1037
1259
 
1038
- 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)' : ''}`;
1039
1261
 
1040
- async function assets(ctx, [agent]) {
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
+ }
1279
+
1280
+ async function assets(ctx, [agent, ...rest]) {
1281
+ if (agent === 'regenerate') return assetsRegenerate(ctx, rest);
1041
1282
  const r = repo(ctx);
1042
1283
  const base = `/partner/${encodeURIComponent(r.product)}/assets`;
1043
1284
  if (!agent) {
@@ -1060,6 +1301,9 @@ async function assets(ctx, [agent]) {
1060
1301
  const files = [rec.files && `${rec.files.base}.{${rec.files.try.join('|')}}`, ...Object.values(rec.media_files || {})].filter(Boolean);
1061
1302
  const where = rec.state === 'made' ? files.join(' ') : '';
1062
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}`);
1063
1307
  }
1064
1308
  ctx.out(lines.join('\n'), data);
1065
1309
  return 0;
@@ -1347,12 +1591,26 @@ const COMMANDS = {
1347
1591
  'ovid check': (ctx, rest) => ovidCheck(ctx, rest),
1348
1592
  'ovid publish': (ctx, rest) => ovidPublish(ctx, rest),
1349
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
+ },
1350
1599
  seed: (ctx, [store, ...paths]) => seedStore(ctx, store, paths),
1351
1600
  status: (ctx) => status(ctx),
1352
1601
  lists: (ctx, rest) => lists(ctx, rest),
1353
1602
  agents: (ctx, rest) => agents(ctx, rest),
1354
1603
  records: (ctx, rest) => records(ctx, rest),
1355
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),
1356
1614
  quests: (ctx, rest) => quests(ctx, rest),
1357
1615
  assets: (ctx, rest) => assets(ctx, rest),
1358
1616
  lore: (ctx, rest) => lore(ctx, rest),