Files
elizaos--eliza/scripts/generate-view-heroes.mjs
wehub-resource-sync 426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
ci / test (push) Waiting to run
ci / lint-and-format (push) Waiting to run
ci / build (push) Waiting to run
ci / dev-startup (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
gitleaks / gitleaks (push) Waiting to run
Markdown Links / Relative Markdown Links (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Quality (Extended) / Homepage Build (PR smoke) (push) Waiting to run
Quality (Extended) / Comment-only diff guard (push) Waiting to run
Quality (Extended) / Format + Type Safety Ratchet (push) Waiting to run
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Waiting to run
Quality (Extended) / Develop Gate (lint) (push) Waiting to run
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

222 lines
6.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Generate clean, brand-consistent SVG hero images for plugin views that lack
* one. Heroes are probed at request time from `<pluginDir>/assets/hero.<ext>`
* by `packages/agent/src/api/views-registry.ts` (`.svg` is a supported hero
* extension). All existing real heroes are 1024x1024.
*
* The art itself (frame, palette, icon glyphs) is the shared, single source of
* truth in `@elizaos/shared` (`view-hero-art.ts`) — the same generator the
* agent uses for its runtime hero fallback and that view scaffolding uses to
* seed a new plugin's icon. This script owns curated fallback config and checks
* the full manifest-derived app catalog so hero omissions cannot silently ship.
*
* Output is deterministic: re-running produces byte-identical files. Run with
* `node scripts/generate-view-heroes.mjs` (requires `@elizaos/shared` built).
*/
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { mkdir, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { renderViewHeroSvg, VIEW_HERO_ICONS } from "@elizaos/shared";
const repoRoot = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"..",
);
/**
* Discover every plugin that declares an Eliza app surface (`elizaos.app` in its
* package.json) by scanning the plugins manifest — the same source the view
* catalog reads — so the generator can never silently omit a view-bearing
* plugin. Returns the plugin dir names (e.g. "plugin-calendar").
*/
function scanAppPluginDirs() {
const pluginsRoot = path.join(repoRoot, "plugins");
if (!existsSync(pluginsRoot)) return [];
const dirs = [];
for (const name of readdirSync(pluginsRoot)) {
const manifestPath = path.join(pluginsRoot, name, "package.json");
if (!existsSync(manifestPath)) continue;
try {
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
if (manifest?.elizaos?.app) dirs.push(name);
} catch {
// Unparseable manifest — skip; not a regression we own here.
}
}
return dirs.sort();
}
/** True when a plugin dir already ships a hero asset (svg or png). */
function pluginHasHeroAsset(pluginDir) {
const assetsDir = path.join(repoRoot, "plugins", pluginDir, "assets");
if (!existsSync(assetsDir)) return false;
return readdirSync(assetsDir).some((f) => /^hero.*\.(svg|png)$/.test(f));
}
/**
* Curated fallback config. The manifest coverage check below is the source of
* truth for completeness; this list controls generated art for app plugins that
* need a committed fallback hero.
*/
const views = [
{
out: "plugins/app-model-tester/assets/hero.svg",
id: "model-tester",
label: "Model Tester",
hue: 25,
icon: VIEW_HERO_ICONS.modelTester,
},
{
out: "plugins/plugin-app-control/assets/hero.svg",
id: "views",
label: "Views",
hue: 270,
icon: VIEW_HERO_ICONS.views,
},
{
out: "plugins/plugin-blocker/assets/hero.svg",
id: "focus",
label: "Focus",
hue: 348,
icon: VIEW_HERO_ICONS.focus,
},
{
out: "plugins/plugin-calendar/assets/hero.svg",
id: "calendar",
label: "Calendar",
hue: 12,
icon: VIEW_HERO_ICONS.calendar,
},
{
out: "plugins/plugin-native-settings/assets/hero.svg",
id: "device-settings",
label: "Device Settings",
hue: 96,
icon: VIEW_HERO_ICONS.views,
},
{
out: "plugins/plugin-facewear/assets/hero-facewear.svg",
id: "facewear",
label: "Facewear",
hue: 190,
icon: VIEW_HERO_ICONS.headphones,
},
{
out: "plugins/plugin-facewear/assets/hero-smartglasses.svg",
id: "smartglasses",
label: "Smartglasses",
hue: 300,
icon: VIEW_HERO_ICONS.glasses,
},
{
out: "plugins/plugin-finances/assets/hero.svg",
id: "finances",
label: "Finances",
hue: 150,
icon: VIEW_HERO_ICONS.finances,
},
{
out: "plugins/plugin-goals/assets/hero.svg",
id: "goals",
label: "Goals",
hue: 38,
icon: VIEW_HERO_ICONS.goals,
},
{
out: "plugins/plugin-health/assets/hero.svg",
id: "health",
label: "Health",
hue: 332,
icon: VIEW_HERO_ICONS.health,
},
{
out: "plugins/plugin-inbox/assets/hero.svg",
id: "inbox",
label: "Inbox",
hue: 168,
icon: VIEW_HERO_ICONS.inbox,
},
{
out: "plugins/plugin-messages/assets/hero.svg",
id: "messages",
label: "Messages",
hue: 256,
icon: VIEW_HERO_ICONS.messages,
},
{
out: "plugins/plugin-relationships/assets/hero.svg",
id: "relationships",
label: "Relationships",
hue: 286,
icon: VIEW_HERO_ICONS.vectorBrowser,
},
{
out: "plugins/plugin-todos/assets/hero.svg",
id: "todos",
label: "Todos",
hue: 52,
icon: VIEW_HERO_ICONS.todos,
},
{
out: "plugins/plugin-vector-browser/assets/hero.svg",
id: "vector-browser",
label: "Vector Browser",
hue: 286,
icon: VIEW_HERO_ICONS.vectorBrowser,
},
];
async function main() {
const written = [];
for (const view of views) {
const svg = renderViewHeroSvg({
id: view.id,
hue: view.hue,
iconSvg: view.icon,
label: view.label,
});
const absPath = path.resolve(repoRoot, view.out);
await mkdir(path.dirname(absPath), { recursive: true });
await writeFile(absPath, svg, "utf8");
written.push({ path: view.out, bytes: Buffer.byteLength(svg, "utf8") });
}
for (const entry of written) {
console.log(`${String(entry.bytes).padStart(6)} ${entry.path}`);
}
console.log(`\nWrote ${written.length} hero SVG files.`);
// Coverage, sourced from the manifest scan (#8796): every plugin that
// declares an Eliza app surface must ship a hero asset — either generated
// above (curated hue/icon) or committed directly. A plugin without one is a
// gap the catalog would render as an icon-only fallback.
const curatedDirs = new Set(
views.map((v) => v.out.split("/")[1]).filter(Boolean),
);
const appPlugins = scanAppPluginDirs();
const missing = appPlugins.filter(
(dir) => !pluginHasHeroAsset(dir) && !curatedDirs.has(dir),
);
console.log(
`\nManifest scan: ${appPlugins.length} app plugins, ${appPlugins.length - missing.length} with a hero asset.`,
);
if (missing.length > 0) {
console.error(
`\n⚠️ ${missing.length} app plugin(s) declare a surface but ship no hero asset:\n${missing
.map((d) => ` - plugins/${d}`)
.join(
"\n",
)}\nAdd a curated entry above or commit plugins/<name>/assets/hero.svg.`,
);
process.exitCode = 1;
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});