Agent Skillswebiny/webiny-js › webiny-ai-powerups-content

webiny-ai-powerups-content

GitHub

通过调用AI Power Ups扩展,以编程方式生成或重写Headless CMS条目内容。适用于批量操作、生命周期钩子等场景,自动应用用户配置的模型和提示词,无需直接处理LLM细节。

skills/user-skills/api/ai-powerups-content/SKILL.md webiny/webiny-js

Trigger Scenarios

需要程序化生成CMS内容 在后台任务中调用AI生成摘要 使用配置好的AI模型重写文本

Install

npx skills add webiny/webiny-js --skill webiny-ai-powerups-content -g -y
More Options

Non-standard path

npx skills add https://github.com/webiny/webiny-js/tree/next/skills/user-skills/api/ai-powerups-content -g -y

Use without installing

npx skills use webiny/webiny-js@webiny-ai-powerups-content

指定 Agent (Claude Code)

npx skills add webiny/webiny-js --skill webiny-ai-powerups-content -a claude-code -g -y

安装 repo 全部 skill

npx skills add webiny/webiny-js --all -g -y

预览 repo 内 skill

npx skills add webiny/webiny-js --list

SKILL.md

Frontmatter
{
    "name": "webiny-ai-powerups-content",
    "description": "Generating Headless CMS entry content with AI from your own code, by delegating to the AI Power Ups extension instead of calling an LLM directly. Use this skill when the developer wants to generate\/summarize\/rewrite entry content programmatically (e.g. from a bulk action, a lifecycle hook, or a custom mutation) using the provider and the Writer\/Reader Personas and Projects the user configured in AI Power Ups. Requires the AI Power Ups extension (with a provider configured) and Webiny 6.5.0 or newer."
}

AI content generation via AI Power Ups

TL;DR

Inject CmsGenerateEntryContentUseCase (from webiny/api/ai-powerups) and call execute(...). It uses the provider the user configured in AI Power Ups and applies an optional Project, Writer Persona, or Reader Persona — so you never pick models, decrypt API keys, or hardcode prompts. It returns the AI-generated entry values as a JSON string; parse it and take the field(s) you want.

Prefer this over a raw Ai.generateText call whenever the point is "apply the user's configured AI setup" — it composes the product with itself and is far less plumbing.

Generate content

import { CmsGenerateEntryContentUseCase } from "webiny/api/ai-powerups";

class MyThing {
  constructor(private generate: CmsGenerateEntryContentUseCase.Interface) {}

  async run(model, entry, ctx) {
    const result = await this.generate.execute({
      modelId: model.modelId,
      prompt: `Write a one-sentence marketing summary for "${entry.values.name}". Fill only the "aiSummary" field.`,
      // Any of these are optional; they map to what the user configured in AI Power Ups:
      projectId: ctx?.projectId, // a bundled context (instructions + files + default personas)
      writerPersonaId: ctx?.writerPersonaId, // tone
      readerPersonaId: ctx?.readerPersonaId // audience
    });
    if (result.isFail()) {
      throw result.error; // e.g. "No AI provider configured. Add a provider in AI Power Ups settings."
    }
    return result.value; // { values, telemetry }
  }
}

Register the dependency: dependencies: [CmsGenerateEntryContentUseCase].

Output shape — important

result.value.values is an entry-shaped object keyed by the model's field ids (the use case is built to fill an entry from its schema). The AI decides which fields it fills, so:

  • Read only the field(s) you want (e.g. result.value.values.aiSummary) — do NOT blindly write the whole object back, or the AI could overwrite name, price, etc.
  • Type the values at the call site if you like: execute<{ aiSummary?: string }>(...), which makes result.value.values.aiSummary typed (defaults to Record<string, any>).
  • Guard for the field being absent (the model may not have filled it): fall back to "" and, if you're inside a converging background task, still mark the entry done so it doesn't loop.

Then persist with UpdateEntryUseCase (values nested; skipValidation: true for a targeted field write).

Admin — list configured contexts (for a picker)

To let the user pick a Project/Persona in the Admin UI, read AI Power Ups settings with GetSettingsFeature (from webiny/admin/ai-powerups):

import { useFeature } from "webiny/admin";
import { GetSettingsFeature } from "webiny/admin/ai-powerups";

const { useCase: getSettings } = useFeature(GetSettingsFeature);
const settings = await getSettings.execute();
// settings.writerPersonas.presets / settings.readerPersonas.presets / settings.projects.presets
// each preset: { id, name, description, ... }

Forward the chosen id(s) to your backend (e.g. via a bulk action's data).

Related

  • webiny-cms-bulk-actions — the common host for this: a bulk action whose processData calls CmsGenerateEntryContentUseCase and writes the result, as a background task.
  • @webiny/ai-powerups's AiImageEnrichmentTask shows the alternative (raw, hardcoded Ai.generateText) — use that only when you deliberately don't want the configured setup.

Version History

  • 80eb1c5 Current 2026-08-20 10:06

Same Skill Collection

.claude/skills/grill-me/SKILL.md
.claude/skills/prd-to-plan/SKILL.md
.claude/skills/preflight/SKILL.md
.claude/skills/tester/SKILL.md
.claude/skills/write-a-prd/SKILL.md
skills/repo-skills/add-feature-flag/SKILL.md
skills/user-skills/admin/admin-architect/SKILL.md
skills/user-skills/admin/admin-permissions/SKILL.md
skills/user-skills/admin/form-model/SKILL.md
skills/user-skills/admin/new-entry-wizard/SKILL.md
skills/user-skills/admin/website-builder/page-settings/SKILL.md
skills/user-skills/admin/website-builder/wb-preview-url-modifier/SKILL.md
skills/user-skills/api-bundle-size-limit/SKILL.md
skills/user-skills/api/api-architect/SKILL.md
skills/user-skills/api/cms-bulk-actions/SKILL.md
skills/user-skills/api/custom-field-type/SKILL.md
skills/user-skills/api/event-handler-pattern/SKILL.md
skills/user-skills/api/graphql-api/SKILL.md
skills/user-skills/api/http-route/SKILL.md
skills/user-skills/api/permissions/SKILL.md
skills/user-skills/api/use-case-pattern/SKILL.md
skills/user-skills/api/v5-to-v6-migration/SKILL.md
skills/user-skills/api/websocket-notifications/SKILL.md
skills/user-skills/cli-extensions/SKILL.md
skills/user-skills/configure-auth0/SKILL.md
skills/user-skills/configure-entraid/SKILL.md
skills/user-skills/configure-okta/SKILL.md
skills/user-skills/dependency-injection/SKILL.md
skills/user-skills/full-stack-architect/SKILL.md
skills/user-skills/generated/api/aco/SKILL.md
skills/user-skills/generated/api/cms/SKILL.md
skills/user-skills/generated/api/file-manager/SKILL.md
skills/user-skills/generated/api/scheduler/SKILL.md
skills/user-skills/generated/api/security/SKILL.md
skills/user-skills/generated/api/system/SKILL.md
skills/user-skills/generated/api/tenancy/SKILL.md
skills/user-skills/generated/api/tenant-manager/SKILL.md
skills/user-skills/generated/api/website-builder/SKILL.md
skills/user-skills/generated/infra/SKILL.md
skills/user-skills/infrastructure-extensions/SKILL.md
skills/user-skills/local-development/SKILL.md
skills/user-skills/mailer-smtp/SKILL.md
skills/user-skills/project-structure/SKILL.md
.claude/skills/webiny-skill-creator/SKILL.md
skills/user-skills/admin/ui-extensions/SKILL.md
skills/user-skills/cognito-federation/SKILL.md
skills/user-skills/content-models/SKILL.md
skills/user-skills/generated/admin/aco/SKILL.md
skills/user-skills/generated/admin/ai-powerups/SKILL.md

Metadata

Files
0
Version
80eb1c5
Hash
8a09f1d0
Indexed
2026-08-20 10:06

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-22 04:27
浙ICP备14020137号-1 $mapa de visitantes$