@ai-game-assets/dev

中文文档
0.11.39发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 3218

Development server and AI providers for prompt-aware AI game assets.

原始使用文档

@ai-game-assets/dev

Local development server, AI providers, asset storage, and production manifest tooling for AI Game Assets.

Play the Space Invaders demo · View this package on npm · Read the full documentation

npm install -D @ai-game-assets/dev

Use this package during development to generate, edit, promote, and build game assets. Production games do not need the development server or AI credentials.

ElevenLabs voice lines

createElevenLabsAudioProvider() defaults voice-line generation to Eleven v4 (eleven_v4) through the text-to-speech API. Set voiceSettings.model on an asset or request to pin a different model, or pass voiceLineModel to the provider to change its default. Voice settings take precedence over audioSettings.model, then the provider default. Explicit legacy and custom models remain supported. Generated options save the resolved speech model in model and voiceSettings.model. Voice design, sound effects, and music use their own models.

Scaled variants

POST /__ai-assets/scaled-variant-options generates three candidates from the closest available source without writing PNGs or changing the manifest. It accepts the same source identity, requested dimensions, regeneration identity, and scaling method as generation. Each candidate includes index, dataUrl, dimensions, optional frameGrid, method, and sourceFile. AI animation enlargement sends the whole spritesheet in one request per candidate, with shared character-consistency and grid-preservation instructions. Source margins and spacing are removed before generation; unused cells stay transparent. Failed or canceled batches never replace a saved variant.

Promote a chosen candidate through POST /__ai-assets/scaled-variant with action: "select", its dataUrl, candidateSourceFile, effective method, requested frame width/height, and the original request identity. Selection validates dimensions, source provenance and stale regeneration requests, saves only the chosen pixels, and makes no further AI request. generateScaledVariantOptions is also exported for custom servers.

POST /__ai-assets/scaled-variant directly creates, promotes a selected candidate, touches up, or deletes a version-scoped resolution. Requests include assetId, versionName, sourceFile, action, and, for existing variants, id and expectedFile. Generate accepts width, height, and method (nearest, resample, or ai-upscale); touch-up accepts a PNG dataUrl with unchanged variant dimensions. Width/height describe each frame or tile when the source is a sheet. Responses include the updated manifest and variant. Generate and touch-up also return previewDataUrl containing the saved PNG, allowing immediate previews before public-file watchers expose the new URL.

The server validates image dimensions and frame geometry, rejects stale updates, reads only local source files within assetsDir, and saves immutable PNGs. Failed generation leaves existing variants unchanged. Variant files and metadata are retained in production manifest builds. Replaced files are retained because other target assets or provenance may reference them.

Strict resizing works without API credentials. AI enlargement uses the OpenAI Images edit API with the existing OPENAI_API_KEY; no additional provider token is needed. The default model is GPT Image 2.5 Sunburst with high quality and a fixed preservation prompt. Smaller targets are generated on an API-supported canvas and resized to the exact requested dimensions with nearest-neighbor sampling. The edited image's transparency is retained. OpenAI may refine details; use nearest for exact pixel preservation. Downscaling in AI mode uses deterministic smooth resizing without an API call.

A custom AiAssetUpscaleProvider implements upscale({ image, width, height, frameGrid?, signal }) and returns image bytes. Pass it as upscaleProvider to createAiAssetDevServer. createOpenAiUpscaleProvider({ apiKey?, model?, fetch? }), saveScaledVariant, and resizeScaledSource are exported for custom servers. The server selects the closest source, passes packed animation sheets with optional frameGrid metadata to the provider, and enforces exact output dimensions. Non-AI resizing remains per-cell to prevent colors bleeding across frame boundaries.

版本与发布记录

@ai-game-assets/dev 共发布 61 个版本,首次发布于 2026/06/17;过去 12 个月发布了 61 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.11.39latest2026/11/08今天
0.11.382026/11/08今天
0.11.372026/11/034 天前
0.11.362026/11/016 天前
0.11.352026/11/016 天前
0.11.342026/11/016 天前

关于 @ai-game-assets/dev 的常见问题

@ai-game-assets/dev 是什么?

Development server and AI providers for prompt-aware AI game assets.

如何安装 @ai-game-assets/dev?

在项目目录运行 npm install @ai-game-assets/dev,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ai-game-assets-dev,可以用 npx ai-game-assets-dev 直接运行。

@ai-game-assets/dev 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ai-game-assets/dev 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ai-game-assets/dev 可以商用吗?

@ai-game-assets/dev 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ai-game-assets/dev 的下载量有多少?

根据 npm 官方下载统计,@ai-game-assets/dev 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,218 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ai-game-assets/dev 还在维护吗?

最新版本 0.11.39 发布于 2026/11/08(今天);至今共发布 61 个版本,其中过去 12 个月发布了 61 个;首次发布于 2026/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。