From f8feb0fd585f4671fb255c4734f0fb419ae08ec5 Mon Sep 17 00:00:00 2001 From: william Date: Thu, 19 Nov 2026 17:23:20 +0800 Subject: [PATCH 1/2] Add official Kling AI Cursor plugin --- .cursor-plugin/marketplace.json | 5 + README.md | 1 + .../kling-ai/.cursor-plugin/plugin.json | 33 ++++ third_party/kling-ai/.gitignore | 6 + third_party/kling-ai/LICENSE | 21 +++ third_party/kling-ai/PRIVACY.md | 11 ++ third_party/kling-ai/README.md | 157 ++++++++++++++++++ third_party/kling-ai/assets/kling-logo.png | Bin 0 -> 3766 bytes third_party/kling-ai/mcp.json | 8 + third_party/kling-ai/package.json | 14 ++ third_party/kling-ai/rules/kling-ai.mdc | 27 +++ .../kling-ai/scripts/verify-plugin.mjs | 77 +++++++++ .../skills/kling-ai-generate-image/SKILL.md | 47 ++++++ .../references/prompt-construction.md | 43 +++++ .../references/scene-patterns.md | 28 ++++ .../skills/kling-ai-generate-video/SKILL.md | 44 +++++ .../references/model-routing.md | 19 +++ .../references/motion-and-shots.md | 56 +++++++ .../references/scene-patterns.md | 28 ++++ third_party/kling-ai/skills/kling-ai/SKILL.md | 72 ++++++++ .../kling-ai/references/asset-workflows.md | 38 +++++ .../references/capability-discovery.md | 23 +++ .../kling-ai/references/mcp-contract.md | 45 +++++ .../kling-ai/references/model-parameters.md | 57 +++++++ .../kling-ai/references/prompt-examples.md | 95 +++++++++++ .../kling-ai/references/tool-workflows.md | 35 ++++ .../kling-ai/references/troubleshooting.md | 69 ++++++++ third_party/kling-ai/tests/plugin.test.mjs | 46 +++++ 28 files changed, 1105 insertions(+) create mode 100644 third_party/kling-ai/.cursor-plugin/plugin.json create mode 100644 third_party/kling-ai/.gitignore create mode 100644 third_party/kling-ai/LICENSE create mode 100644 third_party/kling-ai/PRIVACY.md create mode 100644 third_party/kling-ai/README.md create mode 100644 third_party/kling-ai/assets/kling-logo.png create mode 100644 third_party/kling-ai/mcp.json create mode 100644 third_party/kling-ai/package.json create mode 100644 third_party/kling-ai/rules/kling-ai.mdc create mode 100644 third_party/kling-ai/scripts/verify-plugin.mjs create mode 100644 third_party/kling-ai/skills/kling-ai-generate-image/SKILL.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-image/references/prompt-construction.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-image/references/scene-patterns.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-video/references/motion-and-shots.md create mode 100644 third_party/kling-ai/skills/kling-ai-generate-video/references/scene-patterns.md create mode 100644 third_party/kling-ai/skills/kling-ai/SKILL.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/asset-workflows.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/capability-discovery.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/mcp-contract.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/model-parameters.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/prompt-examples.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/tool-workflows.md create mode 100644 third_party/kling-ai/skills/kling-ai/references/troubleshooting.md create mode 100644 third_party/kling-ai/tests/plugin.test.mjs diff --git a/.cursor-plugin/marketplace.json b/.cursor-plugin/marketplace.json index 1df957022..b47025825 100644 --- a/.cursor-plugin/marketplace.json +++ b/.cursor-plugin/marketplace.json @@ -813,6 +813,11 @@ "source": "third_party/lmty", "description": "Read tracked competitors, competitive intelligence reports, change logs, evidence, social mentions, and market feeds for your products, and browse LMTY's public Markets, event timelines, and company, product, and person profiles." }, + { + "name": "kling-ai", + "source": "third_party/kling-ai", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP." + }, { "name": "sabre-developer-hub", "source": "third_party/sabre-developer-hub", diff --git a/README.md b/README.md index e3e669db8..aa63f92a7 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Official Cursor plugins for popular developer tools, frameworks, and SaaS produc | `createos` | [CreateOS](third_party/createos/) | Cursor | Integrations | Deploy and manage projects, environments, deployments, domains, logs, cron jobs, security scans, templates, and sandboxes on NodeOps CreateOS. | | `fiscal-ai` | [Fiscal.ai](third_party/fiscal-ai/) | Cursor | Integrations | Pull source-linked financials, filings, ratios, prices, segments, KPIs, ownership, fund letters, and news from Fiscal.ai. | | `lmty` | [LMTY](third_party/lmty/) | Cursor | Integrations | Read tracked competitors, competitive intelligence reports, change logs, evidence, social mentions, and market feeds for your products, and browse LMTY's public Markets, event timelines, and company, product, and person profiles. | +| `kling-ai` | [Kling AI Plugin](third_party/kling-ai/) | KLING AI | Integrations | Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP. | | `sabre-developer-hub` | [Sabre Developer Hub](third_party/sabre-developer-hub/) | Cursor | Integrations | Search and read Sabre Developer Hub documentation, OpenAPI specs, and Sabre-published agent skills for travel APIs, SDKs, and product collections. | Author values match each plugin’s `plugin.json` `author.name` (Cursor lists `plugins@cursor.com` in the manifest). diff --git a/third_party/kling-ai/.cursor-plugin/plugin.json b/third_party/kling-ai/.cursor-plugin/plugin.json new file mode 100644 index 000000000..88f130921 --- /dev/null +++ b/third_party/kling-ai/.cursor-plugin/plugin.json @@ -0,0 +1,33 @@ +{ + "name": "kling-ai", + "$schema": "https://cursor.com/schemas/cursor-plugin/plugin.json", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "version": "1.4.1", + "author": { + "name": "KLING AI" + }, + "homepage": "https://kling.ai", + "repository": "https://github.com/klingai-tech/cursor-plugin", + "license": "MIT", + "keywords": [ + "kling", + "kling-ai", + "image-generation", + "video-generation", + "mcp", + "oauth" + ], + "logo": "assets/kling-logo.png", + "rules": "rules", + "skills": "skills", + "mcpServers": "mcp.json", + "tags": [ + "media", + "creative", + "ai-generation", + "video", + "image", + "mcp", + "oauth" + ] +} diff --git a/third_party/kling-ai/.gitignore b/third_party/kling-ai/.gitignore new file mode 100644 index 000000000..8b0797884 --- /dev/null +++ b/third_party/kling-ai/.gitignore @@ -0,0 +1,6 @@ +node_modules/ +.env +.env.* +outputs/ +assets/generated/ +.DS_Store diff --git a/third_party/kling-ai/LICENSE b/third_party/kling-ai/LICENSE new file mode 100644 index 000000000..15cab3eb4 --- /dev/null +++ b/third_party/kling-ai/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 KLING AI Pte Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/kling-ai/PRIVACY.md b/third_party/kling-ai/PRIVACY.md new file mode 100644 index 000000000..5d25fdfaf --- /dev/null +++ b/third_party/kling-ai/PRIVACY.md @@ -0,0 +1,11 @@ +# Privacy + +The plugin sends prompts, reference media, task identifiers, account queries, +and generation requests to the Kling AI Global remote MCP at +`https://kling.ai/mcp/plugin` only when Cursor invokes its tools. + +Cursor manages OAuth for the remote MCP connection. The packages do not request, +store, or log API keys, OAuth tokens, cookies, authorization headers, or local +credential files. They do not include a local MCP server or localhost monitor. + +Kling AI's privacy policy and terms apply to data processed by the service. diff --git a/third_party/kling-ai/README.md b/third_party/kling-ai/README.md new file mode 100644 index 000000000..4671c2341 --- /dev/null +++ b/third_party/kling-ai/README.md @@ -0,0 +1,157 @@ +# Kling AI for Cursor + +Generate images and videos, reuse Elements, and track Kling tasks from Cursor +Agent chat. This is the **Global** plugin on the `main` branch, version **1.4.1**. +Using a China account? See the [China plugin on the `cn` branch](https://github.com/klingai-tech/cursor-plugin/tree/cn). + +## Quick start + +### 1. Install the plugin + +Open Cursor desktop, switch the chat to **Agent**, and paste this request. + +> Install the Kling AI Cursor plugin from https://github.com/klingai-tech/cursor-plugin +> using the `main` branch. Follow Cursor’s local plugin instructions, then guide me +> through reloading Cursor, connecting my Kling AI Global account, and checking +> the connection and credits before creating any generation tasks. + +[Official Kling MCP & CLI guide](https://kling.ai/app/mcp/guide) · +[Cursor local plugin instructions](https://cursor.com/docs/plugins#test-plugins-locally) + +#### Install manually + +On macOS or Linux, run the following in a terminal. + +```bash +git clone --branch main --single-branch https://github.com/klingai-tech/cursor-plugin.git +cd cursor-plugin +mkdir -p ~/.cursor/plugins/local/kling-ai +cp -R .cursor-plugin assets rules skills mcp.json README.md ~/.cursor/plugins/local/kling-ai/ +``` + +
+Windows PowerShell + +```powershell +git clone --branch main --single-branch https://github.com/klingai-tech/cursor-plugin.git +Set-Location cursor-plugin +$pluginDir = Join-Path $HOME '.cursor/plugins/local/kling-ai' +New-Item -ItemType Directory -Force -Path $pluginDir | Out-Null +Copy-Item -Recurse -Force -Path .cursor-plugin, assets, rules, skills, mcp.json, README.md -Destination $pluginDir +``` + +
+ +If you already have the repository, update your `main` checkout and run the +copy commands from its root. When upgrading a local install that still has +`commands/kling-ai.md` in the plugin folder, remove that legacy file before reloading. + +The [Cursor Directory listing](https://cursor.directory/plugins/kling-ai) installs +its rule and MCP entry individually. Use the steps above to load the full plugin +and its `/kling-ai` Skill. + +### 2. Connect your Kling AI account + +1. Restart Cursor or run **Developer: Reload Window** from the Command Palette. +2. Open **Customize → Plugins** and check that **Kling AI** is loaded. Find the + enabled `kling-ai` MCP server in **Customize** and click **Connect**. +3. In the browser, sign in to your Kling AI Global account and authorize Cursor. + Return to Cursor and open a new Agent chat. The plugin supplies + `https://kling.ai/mcp/plugin` in its bundled [MCP config](mcp.json) and Cursor + handles OAuth. + +### 3. Try it in Agent chat + +Type `/kling-ai`, select the Skill, and send a prompt. + +- **Check the connection** · Check my Kling AI connection and available credits. Skip generation. +- **Generate an image** · Create a 4:5 product poster of a glass perfume bottle in warm studio light. Show the settings and wait for confirmation. +- **Animate a reference** · Use the attached product photo as the first frame of a 5-second video. Keep the product fixed while the camera slowly pushes in. + +For reference-based requests, attach the image or video in chat and say how it +should be used. For generation, review the final settings and confirm the +credit-consuming submission. Follow progress in the result card when it appears. +You can also ask Cursor to look up an existing task by its task number. + +See more prompt examples in [English](skills/kling-ai/references/prompt-examples.md#suggested-prompts) +or [中文](skills/kling-ai/references/prompt-examples.md#推荐提示词). + +## Troubleshooting + +- **Plugin or Skill missing.** Check that `.cursor-plugin/plugin.json` is inside the + local plugin folder, reload Cursor, and start a new Agent chat. On an Enterprise + account, your admin can check **Allow Local Plugin Imports**. +- **Connection or account issue.** Keep one Kling MCP entry active in Cursor and + reconnect the plugin’s `kling-ai` server. When switching from China to Global, + disconnect the previous session and authorize your Global account. +- **Task still running or result card missing.** Ask Cursor to check the existing + task number, if available. For other issues, see the [troubleshooting guide](skills/kling-ai/references/troubleshooting.md). + +## Capabilities + +- Text-to-image, reference-guided editing, and coherent image series. If no image model is specified, prefer Kling Image 4.0 when it is available and meets the request, then consider the account's compatible default. +- [Kling Image 4.0](https://kling.ai/quickstart/kling-image-4-user-guide) supports native 8K and Series Mode for up to 10 coherent images in one generation. Available settings follow the connected account's MCP capabilities. +- Kling 4.0: text-to-video, first/last/intermediate keyframes, and Omni-Ref with images, videos, audio, and Elements. Outputs are 3–30 seconds at 720p, with 1080p available to eligible accounts. +- Kling 4.0 Flash: text-to-video, single first-frame image-to-video, and Omni-Ref with images, videos, and Elements. Outputs are 3–20 seconds at 720p. +- Both Omni-Ref models support smart shot splitting. Synchronized sound generation and source audio retention are mutually exclusive. Model availability and settings follow the connected account. +- Live account-scoped model discovery, reference limits, and billing disclosures +- Media upload, Element management, motion library, credit checks, and task status +- Confirmation immediately before credit-consuming generation +- At most one submission per confirmed intent +- One self-refreshing MCP App per generation when available + +## Components + +| Component | Path | Purpose | +| --- | --- | --- | +| Manifest | `.cursor-plugin/plugin.json` | Plugin identity and native component entrypoints | +| MCP | `mcp.json` | Global remote OAuth MCP | +| Rule | `rules/kling-ai.mdc` | Routing, safety, and single-submission constraints | +| Core Skill | `skills/kling-ai/` | `/kling-ai` entrypoint, OAuth, account, media, Elements, status, and shared contract | +| Image Skill | `skills/kling-ai-generate-image/` | Image workflows, prompting, and quality gates | +| Video Skill | `skills/kling-ai-generate-video/` | Video, motion control, duration, and shot planning | + +## Generation contract + +1. Call `who_am_i` before generation and use the live service's canonical + models, arguments, enums, and inputs. +2. Upload local media with the remote upload tool and reuse one UUIDv7 + `taskTraceId` for the same objective. +3. Show final billable settings, including live-required billing disclosures, and + obtain explicit confirmation unless those settings are already authorized. +4. Check the current credit balance on the same connection immediately before + submission. If the balance is unavailable or insufficient, pause the task. +5. Call a generation tool at most once per confirmed intent; never retry an + ambiguous submission automatically. +6. When Cursor mounts the generation MCP App, let that App refresh internally + instead of creating duplicate model-side `query_tasks` cards. +7. If no App mounts, query at the provider-permitted interval until terminal, + cancelled, or the turn cannot continue. Report completion only after terminal + success with the requested number and type of usable results. If fewer results + are available, report the actual count. An explicit status request queries once. + +If credits run out, sign in to the same account on your region's official Kling +site and top up. Return to the same Cursor conversation and ask to continue the +paused task. If the original submission has a task number, Cursor checks it first. +If a new submission is safe, Cursor rechecks the balance and uses the original +settings. + +## Validation + +```bash +npm run check +npm test +for skill in skills/*; do + python3 "${CODEX_HOME:-$HOME/.codex}/skills/.system/skill-creator/scripts/quick_validate.py" "$skill" +done +``` + +## Official references + +- [Cursor Plugins](https://cursor.com/docs/plugins) +- [Cursor Plugins Reference](https://cursor.com/docs/reference/plugins) +- [Cursor MCP](https://cursor.com/docs/mcp) + +## License + +MIT. Kling AI and related marks belong to their respective owners. diff --git a/third_party/kling-ai/assets/kling-logo.png b/third_party/kling-ai/assets/kling-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..d8935f0c4cd5938c64c4223f069f19c5c046eaec GIT binary patch literal 3766 zcmV;n4oUHeP)`1$+w_xRr5;QRah;o;&94Go~7 zq9!IL2L}h~>FS}QqZJhu85tT85fS6$@F)}g=3JNqeH60!v%goKk$;rdS#=yeD zl9QC#+1fceI_~fAb98iRX=+7AMlCHa+uYrIe0=ls^ziZV)z;Utv$Q`yK+@CG&d<=j zzQ2o%jDv)Qe}I5&ZEj>_W$Wzh=I7^~o}Vf!E4sV9x45~dsHt#qa$sO#T3cL7OG~S) zt(cjbhlq%FcX(1$Q?9SDTwGmFPfwMWm!zhqjgOC3R#w?Jtj7QV4SPvMK~#9!?3!s` z+CUJ8Xa76dY%UHF!3(j9BK5wlx7Lcb*82UwOn)1Kg;s4si0uoWSNJm|PbRaoGf^5b zV#J6MBSwrEF=E7s5hF(QBa7A2$J)|T?PIArDd|5)R<@fH^M!R*h)}#fRe!u|RsT=- z@tL*r4FxEzh3mQ^#C+0P0oeF(SR1GRit5pV4QQ9eE3l^lr+zd?{|VCvQ-CtUZ^J?Z zt9MoU=MwXZqR z+ORkZ^TD8tr_>HRLh%~`3X}no&S6JknVK6+xp-ITc7(306ab|oe@ok0j0l?uqM~s+ zK$s;_?Occ52MYx_<=w4`iN}l8b#(R`%X4OF*i0daQlmAH@>33)S@<5Xv32zESx}bR zWiXpF+vAdkN?AFb)L5P*nOymE*b({y$Q_ja`2K@~z+^~+j`J>&9Hfb5pM8yu z{a5;`4`#hMSQ~0?be%5;P;MO?WlN#ndi|)=j&*T(btBhxZYOsxZGx?^v6_4HxIOrS zF*Y>k4{$oQ^eCaTr14ABssswB#lIXXZL=7;I3(vW*d6CjiPyE-z6$en5!)F!n_$^UR_1 z1j%G!UWLPf##Q{e6GAYi(>v3y3invdlT1D7APh!g;%##95MD2pd8yw2uKmDXq0q0P>q_bFXesQ=SmGqO?qR5}GlYtTx-K)2Kj+ z-(H$|!0ys3+Ve^X?57U&RG!0Pw?s0*w~oO6v!&}PbkSbe7@_g;#q(Vl>F;Ts4`GGz zT1=GC=Lq;$T=ORji&syro7U6O?e0d{hg$B-JKq$0N!Hpt;1#;umyX+ z9V0hPoxY(oT)_`3M~UJRwelKcZzy-u*JkgeKO7b13Py?2u+CwHevH2gS7DpXs8?e= zlM6T&Zu`!?4f9}A^`=c2X^&$&k1s1n1d1PsWDM(7&A&axLkQs&C9~-tj42@hHT%mNWhE@ulVzoo~MY9VRmfOyI4!ADCWc?q@e~D&u<+cO?Ir4VQ3k0 z`l{2U$NoUhG;X^BXVGVeg;19?H0w79TWRP0C^r(bs|Bum-+I(&7|6G+O4c(DVSIHqD9VwdlF| zOjlzGj$rH!>`YH4($R^8UWiVV>1rJJm<78jF7*jQ?L7y2h76fzh-u?}5uinbW2(m` z(Tq8_w@Wf>Yg0HZ!MdL2Ql?I~i5ht!obJ|`VO~qRhi%GWl~Pa-cf==i_v$&LGtBF% z`GHfu4?6J#X2@Za(R0*GCc6xk^Wmk6>E=)&G%bST{8=k~Ua##BBhW1fZ)et&J61h^ zVb07Nwg>~A>Qc85XfEVgSTW|=)Oj6&2}(u56R5*V@aiqSwV!g|odyfXoX*8GWlKT% zk+i!>sW^n_pv#&6k6T%FvtuQ7c66|Qws);vX#+uYGns5Q4+NwZp#lOvpdinJirD(7 zZBc96|Nm!tW|MG0DTgF%^#k`)du-S1FuOB5duQY+rWP5nX$u+})hyzG@_ru{q!c@~ zjJcmcb7FeO7p_fVaHU&uL^ig+OhALPm=8LJe|QG0RY5OsBtyUJI2bdPyarj6y*>dm z@DMd183oGnuh1MU#5Odd#n^i=)%tZw#$1yXL36fZ{qzrju?92vNwj0Y%P@UN48tldR!~|*Sa=vUUy=oFOj-*_sfaQ~Dtia! zeFTknBZlt;qF9iLD~U2PD>L;#78&WCl4@xtYGQZBkScfMJ6a63gTGOYcQ=ZiO+=oZ z;jDBw_GC`_dA15y56!ttoMDlj)kK+J^Doym(41!I7dXjzQKOckD6?bFY36d^y3hz^ z=E9ivpv<6ssP=0rtjt}oDnb+GFhYrjBMj7FMqHuXuj}&VTAw`u4GWG!g(er1-X09W zI+mKc3!28~ROB6@C0k5iQ5M+&6Aj@K=N0}vl_m+6$i=M&!P&D5lL6J0499MTNN5&6 zURB?uv!o;M>NOSvX<7r0o>{|KP2lvQNn+{*G{eLoB+_QQS{N+?+4+^n0#{(2?n?Ek zDKCU8A|nN(Zp>og9rYNr_2=eCG@;6tk;z>Gw`AAlWeD|WDkD&VoE^?vtdWiCn&c@6=E{XKF#a~HM2?JnfFdW_W zj(Yd!zrW;@0FGoV-MPxbaK7|3{qfuUo}{H0>j*pYbikQ@1wJ!{1TlnYoY0fe5bgL$ z-q7>u#i3*G6LtH}!{*%Utm9@T)OXK;>qYPqi;Ejl3FrSA@pfx{lqM#~Kcr4Rft1-- z^>A%H7k-mUJ$^R*lg{a--NuEz`ayTU-|3gT2j@oxy$eX1_1lo$Q~Tb@;dfod&rHMA zlukh;FagbMNY1~!t}AqzzOEbM!KzKQZLf9mhK1z(Be;xb*g8NGH0^jL4w=5!RC^fC z%(CAk;hpP$)>HPl1q`Yl%Tc-lDYH*Lvap;-0q3XnaApN`DOJ>$-$^B9i^BFpA#@M% zdC_bA>f>;=PaKhDpSwKB;a-k zm3eNG2X5f>XC9>g-x$bVJ8(%E4O6F?)kgaEy_g?(SH8&pA9Q+&2HPI6b>}e!V3C9Ml3B&TCL6WWW1UN&`3m zz>g0H+ow09$NT%oQEj+AXto7Bn?Y;{*m@nxg!BnbI>Y4yhVADghyeyiMEUjbabJG! zt3hUj`ALqwIXX{vJ`AqZr;F{@A*OSXO#=-!@`-F z1Md%l7Z+Ex#v2<1A7Hn4^S+#K&yCzql`n64Z@`N~{Bncz+x!Iq8*H$_1{-X!!3G;_ gu)zi!Z19Ts3sHFWTOdKl1ONa407*qoM6N<$f}~DZ=Kufz literal 0 HcmV?d00001 diff --git a/third_party/kling-ai/mcp.json b/third_party/kling-ai/mcp.json new file mode 100644 index 000000000..af9b9d008 --- /dev/null +++ b/third_party/kling-ai/mcp.json @@ -0,0 +1,8 @@ +{ + "mcpServers": { + "kling-ai": { + "type": "http", + "url": "https://kling.ai/mcp/plugin" + } + } +} diff --git a/third_party/kling-ai/package.json b/third_party/kling-ai/package.json new file mode 100644 index 000000000..f0ee305f6 --- /dev/null +++ b/third_party/kling-ai/package.json @@ -0,0 +1,14 @@ +{ + "name": "kling-ai-cursor-plugin", + "version": "1.4.1", + "private": true, + "type": "module", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "scripts": { + "check": "node scripts/verify-plugin.mjs", + "test": "node --test tests/*.test.mjs" + }, + "engines": { + "node": ">=20" + } +} diff --git a/third_party/kling-ai/rules/kling-ai.mdc b/third_party/kling-ai/rules/kling-ai.mdc new file mode 100644 index 000000000..ad4005f48 --- /dev/null +++ b/third_party/kling-ai/rules/kling-ai.mdc @@ -0,0 +1,27 @@ +--- +description: Use Kling AI for image, video, motion, asset, account, and task requests +globs: +alwaysApply: false +--- + +For Kling requests, use `$kling-ai` and route creative work to +`$kling-ai-generate-image` or `$kling-ai-generate-video`. Use only the +configured `kling-ai` Global MCP at `https://kling.ai/mcp/plugin`. +For prompt-only or storyboard-only requests, deliver the text without MCP calls. +During generation preparation, discover live model capabilities across relevant +tools and follow the dedicated Skill's model preferences. For video, include +`omni_ref_video` when available. Confirm final billable settings before generation +unless the same unsubmitted intent and unchanged settings are already explicitly +authorized. Submit each confirmed intent at most once. + +Check current credits on the same connection immediately before submitting. If +the balance is unavailable or insufficient, pause and follow the core Skill's +recovery workflow. When the user asks to resume and the original submission +has a task number, check that task first. + +Let a mounted generation MCP App refresh its own task. If no App is mounted +and a `generationId` is known, query at the provider-permitted interval until +terminal, cancelled, or the turn cannot continue. Report completion only after +terminal success with usable primary media. Query once for an explicit standalone +status request with a known task ID. Never switch regions or start or depend on +a local Kling MCP server. diff --git a/third_party/kling-ai/scripts/verify-plugin.mjs b/third_party/kling-ai/scripts/verify-plugin.mjs new file mode 100644 index 000000000..cf4dfea42 --- /dev/null +++ b/third_party/kling-ai/scripts/verify-plugin.mjs @@ -0,0 +1,77 @@ +#!/usr/bin/env node + +import { existsSync, readFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const SERVER_KEY = "kling-ai"; +const ENDPOINT = "https://kling.ai/mcp/plugin"; + +function readJson(path) { + return JSON.parse(readFileSync(path, "utf8")); +} + +export function verifyPlugin() { + const failures = []; + const check = (condition, message) => { + if (!condition) failures.push(message); + }; + + const packageJson = readJson(join(repoRoot, "package.json")); + const manifest = readJson(join(repoRoot, ".cursor-plugin/plugin.json")); + const mcp = readJson(join(repoRoot, "mcp.json")); + const servers = mcp.mcpServers ?? {}; + + check(manifest.name === "kling-ai", "manifest name must be kling-ai"); + check(manifest.version === packageJson.version, "manifest and package versions must match"); + check(manifest.homepage === "https://kling.ai", "homepage must use the Global Kling site"); + check( + manifest.repository === "https://github.com/klingai-tech/cursor-plugin", + "manifest repository must match this repository" + ); + check( + manifest.rules === "rules" && + manifest.skills === "skills" && + manifest.mcpServers === "mcp.json", + "manifest must reference native Cursor components" + ); + check(!Object.hasOwn(manifest, "commands"), "the core Skill provides the /kling-ai entrypoint"); + check(JSON.stringify(Object.keys(servers)) === JSON.stringify([SERVER_KEY]), `plugin must register only ${SERVER_KEY}`); + check(servers[SERVER_KEY]?.type === "http", "MCP transport must be http"); + check(servers[SERVER_KEY]?.url === ENDPOINT, `MCP endpoint must be ${ENDPOINT}`); + + for (const path of [ + "assets/kling-logo.png", + "rules/kling-ai.mdc", + "skills/kling-ai/SKILL.md", + "skills/kling-ai-generate-image/SKILL.md", + "skills/kling-ai-generate-video/SKILL.md" + ]) { + check(existsSync(join(repoRoot, path)), `${path} is missing`); + } + + for (const forbidden of [ + ".cursor-plugin/marketplace.json", + "commands/kling-ai.md", + "kling-ai", + "plugin.json", + "ui", + "server", + "mcp-app", + "scripts/kling-monitor.mjs" + ]) { + check(!existsSync(join(repoRoot, forbidden)), `single Global plugin must not bundle ${forbidden}`); + } + + if (failures.length > 0) { + throw new Error(`Cursor plugin verification failed:\n- ${failures.join("\n- ")}`); + } + + return { name: manifest.name, endpoint: ENDPOINT, version: manifest.version }; +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const result = verifyPlugin(); + console.log(`Verified ${result.name} ${result.version} at ${result.endpoint}.`); +} diff --git a/third_party/kling-ai/skills/kling-ai-generate-image/SKILL.md b/third_party/kling-ai/skills/kling-ai-generate-image/SKILL.md new file mode 100644 index 000000000..a1f305dae --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-image/SKILL.md @@ -0,0 +1,47 @@ +--- +name: kling-ai-generate-image +description: Write or refine Kling AI image prompts, or generate and edit images through the Kling AI MCP in Cursor. Use for Kling Image 4.0, text-to-image, image-to-image, coherent image series, posters, product photography, portraits, covers, advertising stills, visual concepts, and controlled variants. +--- + +# Kling AI image generation + +For prompt-only work, use [prompt construction](references/prompt-construction.md) to decide whether the prompt needs changes, then return it and finish. Preserve composition requirements such as left-side copy space. Skip MCP calls, submission-setting recommendations, and offers to generate. If generation needs a missing image, ask for it, explain its role, and stop there. + +For generation preparation or submission, follow the Cursor OAuth, billing confirmation, single-submission, status, and result rules in the [core Kling Skill](../kling-ai/SKILL.md). + +To continue a paused image task, follow [credit recovery](../kling-ai/references/tool-workflows.md#resuming-after-a-credit-pause) before preparing another submission. Keep the original prompt, settings, and reference roles. + +Read [scene patterns](references/scene-patterns.md) for product, advertising, portrait, poster, or cover work. For Element reuse or local media, also read the core [asset workflows](../kling-ai/references/asset-workflows.md). + +When the user leaves model selection open, prefer Kling Image 4.0 if the account's live `who_am_i` response lists it for the chosen image entry point and it meets the request. Otherwise, prefer the entry point's compatible live `defaultModel`, then consider another compatible live model. Honor an explicitly requested model, including a request for the account's live default. If that choice cannot fulfill the request, explain the limitation and wait for the user to choose how to proceed. + +## Workflow + +1. Use `text_to_image` for a new image. Use `image_to_image` when source media controls identity, product structure, composition, editable content, or style. An attachment alone does not determine the mode. +2. Ask only for missing information that materially changes the result: subject, destination and aspect ratio, required copy, reference roles, protected facts, or output count. +3. Create or reuse the UUIDv7 `taskTraceId` for this objective, follow [capability discovery](../kling-ai/references/capability-discovery.md), and select a compatible tool/model pair from this account's `who_am_i` response. Apply [model parameters](../kling-ai/references/model-parameters.md) before constructing arguments or reference bindings. +4. Upload local images when needed and bind the complete returned URL to the selected model's input slot, such as `image_1` when required. Use the exact `inputType` declared by the tool schema, including uppercase `URL` when declared. Reuse valid upload references when resuming. Never silently degrade to text-to-image after an upload failure. +5. Follow [prompt construction](references/prompt-construction.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Check that the prompt and actual reference roles agree. +6. Show the final mode, model, prompt summary, resolution, aspect ratio, output count, and reference roles. Obtain explicit approval under the core Skill's billing rule; honor an existing explicit authorization for the final settings. +7. After approval, check the actual request against the [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required arguments, and media slots. Immediately before calling `text_to_image` or `image_to_image`, call `query_membership_and_credits` on the same connection. If the balance is unavailable or insufficient, pause even if the upload succeeded. Otherwise submit once and follow the core Skill's result rules. + +## Mode rules + +- For Kling Image 4.0 (可灵图片 4.0), check the selected tool's live support for the requested resolution and generation mode together. The model supports native 8K and up to 10 images in Series Mode, subject to the connected account's available settings. Use the exact live resolution value when requested. +- Element support follows the selected model's declared resource types and binding argument, not the entry point name. +- Image-to-image may use one or more images with explicit roles. State the purpose of every image when multiple references are present. +- For a coherent image series, choose a live model that explicitly supports series generation and the requested count. Set the model's declared count field and enable its series control when declared. Multiple output images alone do not establish series support. If no eligible model supports the requested settings together, explain the limitation before submission. +- Before using an Element subject, follow the core asset workflow, call `element_get`, and choose a model that explicitly supports the resource type and binding argument. Check individual and combined reference caps, and bind the exact ID with the model's declared prompt and structured syntax. +- For a variant, lock every fact that the user did not ask to change. Change one major dimension per confirmed generation. +- A status request uses only `query_tasks`; it does not create an image. +- If image-to-image returns a resource error, follow [asset troubleshooting](../kling-ai/references/troubleshooting.md#upload-or-asset-reference-fails). Use a task number for recovery only when it belongs to this image-to-image submission. + +## Quality defaults + +- Prefer live-supported `2k` for normal delivery, `4k` for commercial work, advertising, fine materials, or crop-heavy post-production, and `1k` only for drafts, speed, or credit savings. Never lower a higher live default. +- Infer ratio from destination: `1:1` for square social or product media, `4:5` for portrait feeds, `9:16` for stories or vertical covers, and `16:9` for banners or thumbnails. +- Generate one image unless the user requests more. +- Unless the user explicitly requests text inside the generated image, prefer a clean image with intentional copy-safe space. +- Treat brand names, logos, faces, product structure, and user-provided copy as protected facts. Never invent performance, price, certification, ingredients, awards, effects, or statistics. + +Before submission, internally check focal subject, visual hierarchy, safe area, lighting, reference roles, and conflicting instructions. Claim visual QA only when the result was actually inspected. diff --git a/third_party/kling-ai/skills/kling-ai-generate-image/references/prompt-construction.md b/third_party/kling-ai/skills/kling-ai-generate-image/references/prompt-construction.md new file mode 100644 index 000000000..039002f49 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-image/references/prompt-construction.md @@ -0,0 +1,43 @@ +# Image prompt construction + +## Decide whether to revise + +- Honor requests to use a prompt verbatim. Otherwise, review the supplied prompt for the subject, protected facts, setting, composition, lighting, color, style, and constraints that affect the intended image. Leave unspecified creative details to the model when they do not affect the user's goal. +- If the prompt is clear, consistent, and sufficient for the task, return or submit it verbatim. Apply the same check to a general request to optimize it. +- Resolve material gaps, ambiguities, or conflicts from the request and reference media first. If a key detail is still unclear, ask before proceeding. When the user clarifies one phrase, change only that phrase. +- Change only the wording needed to satisfy the request or close the gap. If one extra sentence is enough, append it and preserve the rest verbatim. For generation, change reference syntax only as required by the selected model. If that conflicts with a request for verbatim use, clarify before submitting. + +## Recommended order + +Use the relevant items when writing a new prompt or adding missing information. + +1. Destination and medium: product photograph, editorial portrait, poster, thumbnail, or marketing still. +2. Subject and protected facts: identity, product structure, exact colors, logo, or copy. +3. Action or visual concept. +4. Environment, time, weather, and mood. +5. Composition: aspect ratio, framing, camera height, focal hierarchy, negative space, and safe areas. +6. Lighting and color. +7. Materials, textures, surface detail, and degree of realism. +8. Constraints: subject count, protected facts, and requested exclusions. + +Translate abstract requests such as "premium," "cinematic," or "high quality" into visible lighting, depth of field, material, color, and composition decisions instead of stacking adjectives. + +## Multiple references + +Assign roles before writing the creative prompt. Identity, product structure, composition, style, and official logo references are not interchangeable. Transfer only the visual traits the user selected from a style reference; do not transfer identity or composition unintentionally. + +## Coherent image series + +Describe what stays consistent across the series, such as the subject, outfit, or visual style. If the user specifies a sequence, preserve its order and match the scene count to the requested output count. + +## Exact text + +- Preserve user-provided copy verbatim. +- When the user agrees to add text later, prepare a base image with intentional space for the copy. +- For generated text, include the exact copy once with any specified placement, hierarchy, or language. Leave unspecified typography, color, and margins to the model. When adding one title, preserve existing labels. Restrict other text only when the user asks for that restriction. Check spelling and layout in the rendered image before judging accuracy. + +## Controlled variants + +Keep protected facts identical and change only one dimension at a time: concept, camera distance, composition, mood, color, or expression and action. Do not replace a clear creative decision with a batch of near-duplicates. + +Avoid conflicting camera instructions, long repetitive negative lists, and unverified product or brand claims. diff --git a/third_party/kling-ai/skills/kling-ai-generate-image/references/scene-patterns.md b/third_party/kling-ai/skills/kling-ai-generate-image/references/scene-patterns.md new file mode 100644 index 000000000..cf0af2799 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-image/references/scene-patterns.md @@ -0,0 +1,28 @@ +# Image scene patterns + +Choose one primary pattern that fits the destination. User-provided facts and brand assets take precedence. + +## Product and commerce + +- Studio catalog: accurate structure, neutral or brand-color backdrop, controlled soft light, and a grounded shadow without unrelated props. +- Lifestyle: a credible environment and use case with plausible hands, scale, and physical interaction. +- Material close-up: tight framing around texture, mechanics, or surface detail while preserving enough context to identify the product. +- Hero banner: place the product near one side's focal area and preserve negative space for deterministic typography. +- Concept visual: suspension, liquid, miniature scenes, or CGI-like materials are allowed, but the real product structure and label must remain accurate. + +## Advertising and social + +- Static ad: one hook, one subject, one piece of visual evidence, and a clear copy-safe area. +- UGC still: a credible phone-camera angle, natural environment, and realistic handling without fabricated testimonials. +- Carousel: establish consistent color, lens, light, margins, and product scale, then give each frame one distinct communication task. +- Campaign key visual: a memorable silhouette, a deliberate color mechanism, one dominant metaphor, and a simplified background. + +## People, covers, and posters + +- Portrait: define framing, expression, gaze, wardrobe, background, key/fill/rim light, and natural facial structure. +- Identity reference: lock bone structure, skin tone, hairline, apparent age, and distinguishing traits. +- Vertical cover: keep the key action in the upper focal area and reserve lower interface-safe space. +- Landscape thumbnail: one dominant face or object, strong subject separation, little clutter, and readability at small size. +- Poster: one visual proposition, deliberate hierarchy, clean copy space, and controlled color. + +When the user asks for creative directions, offer three materially different options - product fact, human context, and visual metaphor - then generate only after the user selects one. Do not submit three billable tasks automatically. diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md b/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md new file mode 100644 index 000000000..751dd5105 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md @@ -0,0 +1,44 @@ +--- +name: kling-ai-generate-video +description: Write or refine Kling AI video prompts and storyboards, or generate videos through the Kling AI MCP in Cursor. Use for text-to-video, image-to-video, omni reference (全能参考), Kling 4.0 (V4) and Kling 4.0 Flash (V4 Flash), keyframes, audio-guided video, motion control, product showcases, advertising clips, social videos, and cinematic shots. +--- + +# Kling AI video generation + +Deliver the user's current step under the [core Kling Skill](../kling-ai/SKILL.md). + +- **Prompt or storyboard only.** Use [motion and shots](references/motion-and-shots.md) to decide whether the supplied prompt needs changes or to plan new material. Return the requested creative text and finish without MCP calls, submission settings, or offers to generate. +- **Missing required asset.** Ask for the asset and explain its role, such as using a product image as the first frame. Stop before discovery or upload and defer other settings questions. +- **Final settings for approval.** Run generation preparation, present the proposed settings, and wait. +- **Authorized generation.** Honor existing approval for the same unsubmitted intent and unchanged settings. +- **Existing task.** Query the known task number once for an explicit status request. +- **Resume after a credit pause.** Follow [credit recovery](../kling-ai/references/tool-workflows.md#resuming-after-a-credit-pause). Keep the original model, prompt, output settings, and references. For image-to-video, verify the original first-frame slot and reference are still usable. + +Read [scene patterns](references/scene-patterns.md) for product, advertising, social, or cinematic work. For Elements, the motion library, or local media, also read the core [asset workflows](../kling-ai/references/asset-workflows.md). + +## Workflow + +1. Capture the requested model or family, duration, ratio, resolution, count, sound, shot intent, and reference roles. Clarify only details that materially change the result. Create or reuse the objective's UUIDv7 `taskTraceId`. +2. Use Cursor's current MCP tool list and `who_am_i` to compare eligible pairs following [capability discovery](../kling-ai/references/capability-discovery.md) and [video routing](references/model-routing.md). Check all requirements against the same live pair. A first-frame requirement needs a first-frame input. Required silence needs a declared sound-off setting that satisfies the request or an explicit silent-output guarantee. If no pair fits, report the unmet requirement and stop. +3. Read the selected tool's complete live `inputSchema` and the pair's [model parameters](../kling-ai/references/model-parameters.md) before uploading local media or building the request. Stop if a required upload fails. +4. Follow [motion and shots](references/motion-and-shots.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Bind every supported explicit setting to its own argument or applicable fixed model value. Verify the serialized request against the brief and [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required prompt, and first-frame slot. Check an explicit resolution such as `1080p` against the selected tool and model's live enum and conditions. +5. Show the final tool/model, prompt summary, output settings, shot structure, reference roles, and required billing disclosures. After approval, follow the [submission workflow](../kling-ai/references/tool-workflows.md#generation) for the credit check and single submission, then follow the core Skill's result rules. + +## Mode rules + +- Element use requires explicit support for its resource type and binding argument in the selected model; do not infer it from the entry point name. +- Image-to-video and omni reference distinguish first frame, tail frame, keyframes, identity or product reference, style, video, and audio. Pass only roles declared by the selected model and satisfy all conditional combination limits. Pure-text omni reference requires a model that permits no media input. +- Check audio inputs, generated sound, and source-audio retention separately using the selected model's live fields. Apply its sound dependencies and shot controls as described in [model parameters](../kling-ai/references/model-parameters.md). Report the settings actually sent and claim audio or video quality only after inspecting the result. +- Motion control requires a subject image. Choose exactly one motion source - a motion-library ID or a source video - as directed by the live tool. Use the core asset workflow to resolve library IDs and validate motion direction and duration. +- A multi-shot plan is one confirmed video task. Do not submit one generation per shot unless the user explicitly approves separate tasks. +- If image-to-video or omni reference returns a resource error, follow [asset troubleshooting](../kling-ai/references/troubleshooting.md#upload-or-asset-reference-fails) to check first-frame and reference inputs. Only the current video submission's task number can recover its status. + +## Quality defaults + +- Prefer `1080p` for normal delivery and supported `4k` for commercial, large-screen, or post-production work. Use `720p` for drafts, speed, credit savings, or model limitations. Never lower a higher live default. +- Use about 5 seconds for one action or shot, about 10 seconds for dialogue, a complete product action, or two connected beats, and longer only when supported and narratively necessary. +- Honor explicit duration, ratio, resolution, and count before applying defaults. Pass an explicitly requested ratio when supported, including with a first frame. If unspecified, infer it from the destination or preserve the first-frame composition when allowed. +- Use one primary camera movement in a five-second shot. Use multiple shots only when location, time, scale, or information state changes. +- Do not add unrequested narration, readable text, extra characters, product claims, prices, endorsements, or certifications. + +Before submission, internally check whether the action fits the duration, camera instructions conflict, first and tail frame intent is clear, references remain continuous, and multi-shot durations sum correctly. Claim visual QA only when the result was actually inspected. diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md b/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md new file mode 100644 index 000000000..fffafb1b0 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md @@ -0,0 +1,19 @@ +# Video entry points and model selection + +First follow [capability discovery](../../kling-ai/references/capability-discovery.md). A discovered tool is not proof that any particular model is enabled. Never route by tool count, a static model name, or an earlier account's capabilities. + +Compare the relevant entry points returned by successful discovery, including `omni_ref_video` (全能参考) when present. Filter out pairs that cannot meet the requested tool, model or family, output settings, sound, or reference roles before ranking. If discovery itself fails, refresh the connection or report the failure. If successful discovery omits an entry point, use the remaining eligible pairs. + +When the user leaves model selection open, prefer a compatible Kling 4.0 pair, with Omni-Ref preferred when eligible pairs are otherwise equivalent. Use Kling 4.0 Flash when the user prioritizes speed or credit savings and its live capabilities fit. Name the actual selected model in the recommendation. If no compatible Kling 4.0 pair fits, consider a compatible live default only when the user permits other models. If the requested model or family has no eligible pair, report the limitation and stop. + +## Intent and inputs + +- When the user names Kling 4.0 (V4) or Kling 4.0 Flash (V4 Flash), match the full model name or declared alias in the current account's discovery results. Kling 4.0 supports first, last, and intermediate keyframes for image-to-video and images, videos, audio, and Elements in Omni-Ref. Kling 4.0 Flash uses a single first frame for image-to-video and accepts images, videos, and Elements in Omni-Ref. Check the selected pair's live input slots, duration, and resolution. A separate audio reference requires a declared audio input slot. Generated sound and source audio retention use output settings. +- Text-only video can use `omni_ref_video` when the chosen model permits no media inputs. +- Image, video, Element, and audio references can use `omni_ref_video` only when the selected model supports each requested type and their combination. Do not treat its general tool description as every model's capability list. +- Keyframes belong to whichever discovered tool/model declares the needed frame inputs. Do not hardcode them to one entry point, invent intermediate frames, or substitute identity references for frame control. +- Motion transfer must use a model that explicitly supports that intent and all required inputs. Existing `motion_control` requests keep the subject image and exactly one motion source. +- Required silence eliminates pairs without a declared sound-off control that satisfies the request or an explicit silent-output guarantee. A text-to-video tool name, an absent audio field, or silence described in a prompt does not establish that capability. +- Do not move an omni model to `image_to_video` or `text_to_video`; tool/model pairs and their parameter sets are inseparable. + +After selection, apply [model parameters](../../kling-ai/references/model-parameters.md), including conditional reference caps, Elements, and audio exclusivity. One multi-shot plan remains one task unless separate tasks were explicitly approved. The core Skill's billing, single-submission, and result rules apply to omni reference too. diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/references/motion-and-shots.md b/third_party/kling-ai/skills/kling-ai-generate-video/references/motion-and-shots.md new file mode 100644 index 000000000..1968b12db --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-video/references/motion-and-shots.md @@ -0,0 +1,56 @@ +# Motion and shot planning + +## Decide whether to revise + +- Honor requests to use a prompt verbatim. Otherwise, review the supplied prompt for the subject, action, camera movement, timing, continuity, and constraints that affect the intended video. Leave unspecified creative details to the model when they do not affect the user's goal. +- If the prompt is clear, consistent, and sufficient for the task, return or submit it verbatim. Apply the same check to a general request to optimize it. +- Resolve material gaps, ambiguities, or conflicts from the request and reference media first. If a key detail is still unclear, ask before proceeding. +- Change only the wording needed to satisfy the request or close the gap. If the user supplies a sentence that can be added directly, append it and preserve the rest verbatim. When adding an ending, use the requested action, timing, and final position. Leave the intervening movement to the model unless the user specifies it. For generation, change reference syntax only as required by the selected model. If that conflicts with a request for verbatim use, clarify before submitting. + +## Motion-first prompt order + +Use the relevant items when writing a new prompt or adding missing information. Express action and continuity first, then use visible details such as lighting, materials, depth of field, and framing to convey the requested look. + +1. Format and duration intent. +2. Opening frame and subject position. +3. Beginning, development, and completion of the subject action. +4. One primary camera movement and its speed. +5. Environmental movement and physical effects. +6. Lighting, color, lens character, and time-of-day mood. +7. Continuity anchors such as identity, wardrobe, product structure, logo, architecture, and screen direction. +8. Necessary constraints such as no extra subjects, deformation, text, or watermark. + +## Camera choices + +- Locked-off: observation, product detail, or graphic composition. +- Slow push-in: emphasis, intimacy, or detail reveal. +- Pull-back reveal: expanded environment or scale. +- Lateral tracking: follow motion while preserving side relationships. +- Controlled orbit: dimensional display of a product or character. +- Crane rise or drop: establish or resolve spatial scale. +- Handheld follow: urgency or UGC realism; specify the intended stability. +- Whip pan: use only for a deliberate transition and name the final landing subject. + +Do not stack multiple camera-movement verbs into one five-second shot. + +For a continuous hand-object interaction, frame the entire action path so the participating hands and object stay visible through the action and its final handoff or placement. + +## Duration and multiple shots + +- 5 seconds: one action and one camera movement. +- 10 seconds: one action with setup and result, or two simple connected beats. +- 15 seconds or longer: plan a compact multi-beat sequence only when the live model supports it. + +For multiple shots, give each shot a duration, framing, one narrative task, subject action, camera movement, and continuity anchor. Shot durations must sum to the total duration. The full plan is still one generation submission. + +When a continuous hand-object interaction spans a cut, explicitly repeat the same hand grip, object position and support contact at the outgoing shot's end and the incoming shot's start. Use a brief stable beat only when it fits the requested pacing; continue the action without replaying steps or adding a long pause. + +## Reference media + +- A first frame locks the opening composition and motion starts from it. +- A tail frame defines the target ending only when the live model supports it. +- An identity reference locks face, apparent age, hair, wardrobe, proportions, and distinguishing traits. +- A product reference locks dimensions, material, label, logo placement, and moving parts. +- A motion-source video should preferably contain one shot, no occlusion, and one subject. Follow the live tool's exact duration and resolution limits. + +For advertising or explainer video, assign one communication task to each beat: hook, context, evidence, or close. Never invent performance claims, testimonials, statistics, prices, awards, or certifications. diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/references/scene-patterns.md b/third_party/kling-ai/skills/kling-ai-generate-video/references/scene-patterns.md new file mode 100644 index 000000000..2f290ed0f --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai-generate-video/references/scene-patterns.md @@ -0,0 +1,28 @@ +# Video scene patterns + +Choose one primary pattern. Combine patterns only when duration and the live model can support a coherent result. + +## Continuous shots and image-to-video + +- A continuous shot defines opening composition, subject action, camera path, environmental motion, and ending beat. Use one primary camera movement at a time. +- In image-to-video, treat the first frame as locked composition rather than a broad style reference. Describe plausible subject, fabric, hair, environmental, and camera motion. +- In a short clip, avoid combining large subject motion, aggressive camera movement, and a major scene transformation. + +## Product and advertising + +- Studio reveal: controlled orbit or push-in, accurate reflections, clean surfaces, and a clear silhouette. +- Feature demonstration: one real function or action per shot, with credible mechanics and hand interaction. +- Lifestyle: show usage context through action without unsupported claims. +- Unboxing: establish sealed product, opening, reveal, and detail in sequence; use multiple shots only when requested. +- Commercial: organize a hook, product evidence, and hero close-up. Prefer deterministic post-production for slogans and end cards. + +## Social, explainer, and narrative + +- UGC: natural eye-level framing, credible phone motion, an everyday environment, and restrained imperfection without fabricated testimonials. +- Explainer: express one idea per visual beat and avoid long readable paragraphs inside generated imagery. +- Multi-shot: use only when location, time, scale, or information state changes. Preserve identity, product structure, light direction, color, and screen direction. +- `9:16` vertical short: reveal the hook quickly, keep the key subject in the upper focal area, and preserve lower interface-safe space. +- `1:1` or portrait feed: use medium framing, a clean silhouette, and restrained lateral motion. +- `16:9` landscape: emphasize spatial orientation, entrances or reveals, and deliberate negative space. + +When the user asks for ideas, offer three directions - demonstration, emotion, and spectacle - and wait for a choice. Discussing three directions does not approve three generation tasks. diff --git a/third_party/kling-ai/skills/kling-ai/SKILL.md b/third_party/kling-ai/skills/kling-ai/SKILL.md new file mode 100644 index 000000000..57ed17e4f --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/SKILL.md @@ -0,0 +1,72 @@ +--- +name: kling-ai +description: Coordinate Kling AI creation requests and manage reusable subjects (Elements), the motion library, uploads, credits, task status, and account switching through the remote MCP in Cursor. Route image and video generation to their dedicated Skills. +license: MIT +--- + +# Kling AI for Cursor + +Use only the remote Global MCP configured by this plugin: `https://kling.ai/mcp/plugin`. `mcp.json` is the connection source of truth. Do not switch regions, register a second Kling MCP, or start or depend on a local MCP server. + +## Request routing + +- Identify the current deliverable first. Prompt or storyboard work ends with the requested text and needs no MCP call. If a required generation asset is missing, ask for it, explain its role, and stop before discovery or upload. If the user asks for final settings, discover compatible live capabilities, present the settings, and wait for approval. +- For image prompts, creation, or editing, follow [kling-ai-generate-image](../kling-ai-generate-image/SKILL.md). +- For video prompts, storyboards, generation, model selection, or motion transfer, follow [kling-ai-generate-video](../kling-ai-generate-video/SKILL.md). Include `omni_ref_video` (全能参考) in generation discovery when available, including for text-only video. +- Keep uploads, Elements, motion-library browsing, account operations, credit checks, and task status in this Skill. It also supplies the shared connection, billing, submission, and result rules for both generation Skills. +- Motion library: browse with `motion_library_list`. Resolve the selected motion, then follow the video Skill for `motion_control` with a subject image and exactly one motion source. +- Subject library / Elements: use `element_list`, `element_get`, `element_create`, `element_update`, or `element_delete` for the requested operation. Resolve real IDs before reuse. +- Account and credits: use `query_membership_and_credits`; model capabilities come from `who_am_i`. +- Existing tasks: use `query_tasks` with a known `generationId`. A status or library request never creates a generation. +- If a user reports a missing video, follow [result troubleshooting](references/troubleshooting.md#task-is-still-running-or-the-result-app-does-not-render) for the original submission. +- To continue after topping up, follow [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause). Check the original submission's task number if it exists. If the user only reports a top-up, refresh the balance without submitting. +- Sign-out or account switching: act only on an explicit user request, stay on the Global endpoint, and complete native Cursor OAuth before further Kling calls. + +Call only tools present in the live tool list. An attachment alone does not determine its role; clarify only when first frame, tail frame, identity/product reference, editable source, motion source, or style reference would materially change the request. + +Read [asset workflows](references/asset-workflows.md) for Elements, the motion library, or uploads. Before generation, follow [capability discovery](references/capability-discovery.md), then [model parameters](references/model-parameters.md), [tool workflows](references/tool-workflows.md), and the [MCP contract](references/mcp-contract.md). Use [prompt examples](references/prompt-examples.md) for creative direction and [troubleshooting](references/troubleshooting.md) after a failure. + +## Connection and task identity + +- Use OAuth through Cursor's native MCP connection flow (Customize → Plugins, then Connect on `kling-ai`). Never request an API key, token, cookie, authorization header, or credential file. Never log private account fields, upload tickets, or signed URLs. +- Let Cursor manage OAuth discovery, client registration, and credentials through its native MCP flow. This plugin does not configure a custom OAuth client name; do not invent registration overrides or block authorization because the host cannot set one. If the real OAuth flow fails, report the sanitized error and follow [troubleshooting](references/troubleshooting.md). +- Create one UUIDv7 `taskTraceId` for each unrelated new objective. Reuse it across discovery, upload, generation, and querying for that objective wherever the live tool accepts it. +- Preserve exact returned IDs. Present `generationId` as the task number; expose `taskTraceId` only when troubleshooting requires it. + +## Billing and single submission + +- Image, video, and motion generation consume credits. Call `who_am_i` during preparation and select only models returned in the current account's `availableModels` for the chosen tool, with their declared arguments, inputs, and combination limits. Follow capability discovery for cross-tool selection and refresh stale definitions before proceeding. Do not infer model access from a tool's existence, membership tier, or static examples. +- Show the final workflow, model, prompt summary, duration/resolution, aspect ratio, output count, and reference roles. Honor explicit authorization already given for the same unsubmitted intent and unchanged final settings. Otherwise, obtain confirmation before submission. An upload, library operation, or credit check is not generation approval. +- Include any billing disclosure required by the live model/tool in those final settings. For omni reference that declares per-second billing with input video duration included, explain both facts before submission; output duration alone is not the total billed duration. Do not invent a rate or total credit estimate. +- Immediately before each generation call, check the balance with `query_membership_and_credits` on the same connection. Pause when the current balance is unavailable, non-positive, or clearly insufficient, following [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause). +- Submit at most once per approved intent. A rejected call also counts as an attempt. A new attempt requires fresh explicit authorization after any failure, timeout, ambiguous response, or rendering problem. +- Do not save an Element automatically during ordinary generation. Element writes and deletion must follow the user's explicit request as described in [asset workflows](references/asset-workflows.md). + +## Generation and results + +1. Resolve reference roles, Elements, and motion sources; prepare local media before submission. Use the returned provider references exactly as the selected live schema requires. +2. Follow the [submission workflow](references/tool-workflows.md#generation) to confirm the final settings, check credits, and call the chosen tool once. A multi-shot plan remains one task unless the user approves separate tasks. +3. Use `query_tasks` for follow-up only with a known `generationId`. If a submission yields no known ID, report the returned error if present and any unknown creation or billing state, then stop. `query_tasks` requires the ID and cannot search account history or look up `taskTraceId`. A balance check or missing history entry cannot establish the outcome. A status response that omits the ID does not invalidate the known task number. +4. If Cursor renders the generation MCP App, let that App own task refresh. Do not poll the same task from the model or add duplicate media, thumbnails, or download links. +5. If no App renders, query the same `generationId` at the provider-permitted interval until terminal, cancelled, rate-limited, or the turn cannot continue. If a status lookup returns a resource error and explicitly asks to check the same ID later, allow one further lookup at that interval during ongoing polling. Stop on a repeated error or other query failure. Use the tool's text fallback and include at most one primary link per usable requested work. Do not add Markdown image/video embeds or claim an unmounted App was displayed. +6. For an explicit status request, query once and report the current state; do not start a long polling loop. +7. Report full completion only after terminal success with usable primary media of the requested type and count. Count only successful works when work-level status is present, and require actual video media for video results. If some requested works are missing, deliver the usable results and report the actual count, such as "Generated 2 of 3 images." If none are usable, report the discrepancy and keep the task number. +8. Use the returned status, known task number, any result link allowed above, and effective submitted settings. If a lookup fails or polling stops early, report the most recently confirmed state, such as submitted or processing, and say that the current state could not be refreshed. Report the state as unconfirmed only if no state was ever confirmed. Report an actual charge only when the tool returns it, such as `creditsConsumed`. Submission count and a local attempt budget are separate from credits. + +## Quality defaults + +Apply only when the user has not specified another choice and the live model supports it: + +- Prefer full-quality models. Use Turbo, fast, or low-cost modes when the user prioritizes drafts, speed, or credit savings. +- Images: prefer `2k` for normal delivery and `4k` for commercial or crop-heavy work; use `1k` for drafts or speed. Never lower a higher live default. +- Videos: prefer `1080p` for normal delivery and supported `4k` for commercial or post-production work; use `720p` for drafts, cost, speed, or model limitations. +- Generate one result unless more are requested. Use about 5 seconds for one action, about 10 seconds for two connected beats, and longer only when supported and needed. Motion-control duration comes from the selected source and live constraints. +- Pass a requested ratio when supported, including with a first frame. If unspecified, infer it from the destination or preserve the first-frame composition for image-to-video when the live schema allows it. + +## Failure behavior + +- Unauthorized: use native Cursor OAuth and continue only after authorization succeeds. +- Unsupported argument: refresh the live definitions, revise only unsupported settings, and obtain confirmation before a new generation. +- Insufficient credits: follow [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause) and report whether the task was paused before submission, rejected, or remains unconfirmed. +- Provider failure: report the sanitized provider message and preserve the task number. Follow [troubleshooting](references/troubleshooting.md) for resource and service errors. +- Expired media URL: query the original `generationId` for current outputs before reuse. A failed refresh is not permission to create a replacement task. diff --git a/third_party/kling-ai/skills/kling-ai/references/asset-workflows.md b/third_party/kling-ai/skills/kling-ai/references/asset-workflows.md new file mode 100644 index 000000000..39b10113a --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/asset-workflows.md @@ -0,0 +1,38 @@ +# Elements, motion library, and media uploads + +Use this reference for library operations and media preparation. The live `tools/list` and `who_am_i` responses define whether a tool is available, its arguments, input names, and resource limits. + +## Elements + +- To browse reusable subjects, call `element_list` and show the returned `id` and `name`. The list may not include the resource type; call `element_get(id)` before reuse, update, or generation. If a name is ambiguous, show candidates and ask the user to choose. Do not guess an ID. +- To create an Element, require an explicit request to save a reusable subject. Collect its name, description, tags, and resources, then validate the complete resource object against the [MCP contract](mcp-contract.md) before calling `element_create`. Do not create an Element automatically for an ordinary reference-image generation. +- To update an Element, call `element_get` first and merge the requested changes into the complete `name`, `description`, `resource`, and `tags`. Preserve fields the user did not change, including the existing image `resource.cover`. Treat `secondary[]` as a full replacement: preserve unmodified secondary images and keep the provider's 1–3 image constraint when declared. +- Do not silently convert an image Element into a video Element or vice versa. If replacing a cover requires delete-and-recreate, explain that the ID will change and obtain explicit authorization before deleting. +- Call `element_delete` only after the user explicitly identifies the Element to delete. A read-only library operation does not require a credit check or generation submission. + +## Using Elements in generation + +1. With a known ID, call `element_get`. With only a name, call `element_list`, resolve the choice, then call `element_get`. +2. Confirm that the current account can access the Element and inspect `resource` to determine whether it is an image or video resource. +3. Use an Element only when the selected model declares its binding argument and the actual resource type. Check `elementSupport` and conditional reference caps in [model parameters](model-parameters.md), including for `omni_ref_video`. Do not infer support or prohibition from the tool name. A video Element is not an image substitute. +4. Bind the exact Element ID in the prompt and structured argument using the selected model's declared syntax and serialization. For models declaring `<<>>` and an `elements` JSON-array string, use that format, such as `[{"id":"ELEMENT_ID","bindName":"subject"}]`; other models may declare additional type fields or different bindings. Do not copy an older model's shape or omit required bindings. +5. An Element does not replace required image inputs. Supply `image_1`, `first_image`, or another exact live input when the selected model requires it. For motion control, the subject `image` remains required. +6. After resolving the Element, follow the [image Skill](../../kling-ai-generate-image/SKILL.md) or [video Skill](../../kling-ai-generate-video/SKILL.md) for the requested output. Both use the core Skill's confirmation, credit, single-submission, and status rules. + +## Motion library and motion control + +- To browse saved motions, call `motion_library_list` and show the real name, `id`, duration, and audio availability. Use a host-rendered preview when available; otherwise include its returned preview link without embedding media. Durations returned in milliseconds may be displayed in seconds by dividing by 1000. An empty list is a valid result; do not invent motions. +- Selecting a motion by name requires an unambiguous match. If names collide or the intended motion is unclear, ask the user to choose. Browsing the library never calls `motion_control`. +- The current tool surface provides no motion create, update, or delete operation. Do not use `element_*` tools to manage motions. +- For motion control, pass the subject image as the live `image` input. Use exactly one motion source: the library ID as the `motionId` argument or a source video as the live `video` input. Never pass a preview URL as `motionId`, and do not pass both sources. +- Call `who_am_i` for the selected `motion_control` model and use only its declared `motionDirection`, `resolution`, and `keepOriginalSound` names and values. When `motionDirection=image_direction`, the motion source must satisfy the live 3–10 second constraint; do not pass the library duration as an undeclared `duration` argument. +- Continue with the [video Skill](../../kling-ai-generate-video/SKILL.md). Credit checks, confirmation, one submission, and querying by `generationId` still apply. + +## Local media uploads + +- Prefer media already attached in Cursor and accepted by the selected model. If a public URL is accepted by the live tool, use it directly; do not download it unnecessarily. A historical Kling result must be refreshed by `generationId` immediately before reuse, never reused from an old URL in conversation history. +- If no usable attachment reference exists and the live MCP exposes `file_upload`, request an upload ticket with the real filename, MIME type, byte size, and the same `taskTraceId`. Never send a local path as a remote URL. +- Complete the provider's second upload step with the returned ticket and upload URL using multipart form data containing `ticket` and the binary `file`. A ticket response is not upload completion; use the media URL only after the upload service confirms success. +- Bind the full media URL from the successful upload response directly to the input slot. Use `data.url` or the equivalent field declared by the live response. Preserve the path, query string, parameter order, case, and escaping, including signed parameters such as `x-kcdn-pid`, `pkey`, and `cacheKey`. Do not use the upload endpoint, a chat preview, or a truncated link as input. If the request can be inspected before submission, compare each uploaded `inputs[].url` with the source field exactly. If the complete URL is unavailable, pause the dependent operation and follow [asset troubleshooting](troubleshooting.md#upload-or-asset-reference-fails). +- Tickets are single-use and expire at the provider-declared `expireAt`. Never log or display tickets, signed upload URLs, credentials, cookies, or authorization headers. +- If the host cannot read the file or the live MCP lacks upload support, explain the limitation and ask the user to attach usable media. Do not submit a generation or write an Element that depends on unavailable media. Do not loop on failed ticket requests or uploads. diff --git a/third_party/kling-ai/skills/kling-ai/references/capability-discovery.md b/third_party/kling-ai/skills/kling-ai/references/capability-discovery.md new file mode 100644 index 000000000..7e9ae7fe5 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/capability-discovery.md @@ -0,0 +1,23 @@ +# Account-scoped capability discovery + +Read this before choosing a model for generation or a model recommendation. Status, credit, and library queries do not need model discovery. + +## Discover candidates + +1. Read the current connection's complete `tools/list`, following all pagination. Only discovered tools are candidates. A failed discovery is not an empty list and must not trigger a fallback to old capabilities. +2. If the live `who_am_i` schema declares `tools`, pass a nonempty set of relevant generation tools; otherwise read the full response. Do not invent model or field filters. For V4 discovery, include all discovered generation tools that support the requested output type and intent. +3. Treat `who_am_i.availableModels` and each tool's `models` as the authority for this account. Match requested canonical names or declared aliases within that set. A tool's existence, examples, membership tier, or `defaultModel` alone does not establish model access; the default must also belong to its model set. +4. If a requested model is missing from the filtered response, check the remaining discovered generation tools before concluding it was not returned. A model available only for another output type is not a candidate for this request. Explain that mismatch without claiming an account permission failure or changing the requested media type. +5. Fix one tool/model pair, then read [model parameters](model-parameters.md). Never move a model or its arguments to a different tool. + +## Video candidates + +For text-driven video, query the discovered `text_to_video` and `omni_ref_video` models together. For image-driven video, compare `image_to_video` and `omni_ref_video`. Include omni for text-only requests and check its live media requirements. Include other discovered tools that could satisfy the request, with `motion_control` for motion transfer. Follow [video model routing](../../kling-ai-generate-video/references/model-routing.md) for eligibility and ranking. + +## Selection and visibility + +- A user-specified model takes precedence when an eligible pair is returned. Match model names and families, including V4 and V4 Flash, using live canonical names and declared aliases. Identify the selected model by its returned name and recommend only models returned by the current account. +- Required references, duration, sound, speed, and budget take precedence over version preferences. Do not silently drop requirements, increase output count, or lower specifications to make a model fit. +- Reuse one successful discovery response during the same generation preparation. Refresh after reconnecting, switching account/endpoint, changed entitlements, a capability notification, or a rejected model/argument; query additional tools when the candidate set changes. +- A filtered response says nothing about unqueried tools. If full discovery still does not return a requested model, report only that the current connection did not return it. If the user says it is enabled, follow [capability troubleshooting](troubleshooting.md#model-capability-mismatch); do not guess a model identifier or probe access by generating. +- Model capability comes from `who_am_i`; request encoding comes from the tool's `inputSchema`. Tool examples cannot expand model capabilities. Refresh inconsistent or incomplete definitions; if no valid request satisfies both, stop before submission. diff --git a/third_party/kling-ai/skills/kling-ai/references/mcp-contract.md b/third_party/kling-ai/skills/kling-ai/references/mcp-contract.md new file mode 100644 index 000000000..4064a1ce1 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/mcp-contract.md @@ -0,0 +1,45 @@ +# Kling MCP input and output contract + +This reference records only stable tool-level constraints. Always take models, defaults, enums, required fields, item limits, and media inputs from the current `tools/list` and `who_am_i` response. + +## Tool groups + +- Discovery and account: `who_am_i`, `query_membership_and_credits`, `logout` +- Generation and status: `text_to_image`, `image_to_image`, `text_to_video`, `image_to_video`, `omni_ref_video`, `motion_control`, `query_tasks` +- Media and reuse: `file_upload`, `motion_library_list`, `element_create`, `element_list`, `element_get`, `element_update`, `element_delete` + +Call only tools that exist in the current tool list. + +## Generation request + +- Generation tools normally use `model`, `arguments[]`, `inputs[]`, `rationale`, and `taskTraceId`; the live tool `inputSchema` defines the actual outer request and encoding. Omit unused inputs when allowed, but never omit required media. +- Always pass the canonical model ID from `who_am_i` for the selected tool in the top-level `model` field, even if an older tool schema omits it from `required`. If the user did not name a model, select a compatible one and pass its ID. Reject missing, null, empty, or whitespace-only values. +- Each `arguments[]` item is `{name, value}`. Include every required argument once and use strings for values when the schema requires them. Include a meaningful `prompt` when required. Use an empty prompt only when the current mode permits it and it fits the user's intent. Use the selected model's exact resolution field, enum, and conditions. +- Each `inputs[]` item is `{name, inputType, url}`. Bind every required media input to the selected model's exact slot and use the tool schema's literal `inputType`, including uppercase `URL` when declared. Pass uploaded references according to the [media upload workflow](asset-workflows.md#local-media-uploads). +- `rationale` explains the user's objective and parameter choices. It does not replace the generation prompt. +- `taskTraceId` is a UUIDv7. Reuse it for one objective and create a fresh value for an unrelated objective. It supports tracing and does not make a repeated generation call idempotent. + +Follow [capability discovery](capability-discovery.md) before submission and reuse its successful response for the same preparation unless invalidated. Model capabilities come from `who_am_i`, while request structure comes from the tool `inputSchema`; general descriptions do not expand model capabilities. Refresh inconsistent definitions and stop if no valid request satisfies both. Apply the selected model's [parameter and combination constraints](model-parameters.md). + +## Stable gates + +- Element support is model-specific, not determined by an entry point's name. Do not pass an Element or prompt binding unless the selected model explicitly declares the binding argument and support for that resource type. +- Call `element_get` before using an Element. Check `elementSupport`, required media, individual and combined caps, and reference-video conditions for the selected model, including omni reference. +- `motion_control` requires a subject image. Follow the tool description when choosing exactly one motion source: a library `motionId` or a source video. +- When a model requires media from `file_upload`, do not pass a local path or arbitrary external URL directly. +- Never pass an undeclared argument, input name, or enum value. + +## Elements + +- An image Element uses a cover and the provider-allowed number of secondary images. Do not combine it with a video resource. +- A video Element uses a video resource and may include voice only when the tool allows it. Do not combine it with cover or secondary images. +- Use only tags declared by the tool description. +- Call `element_get` before `element_update`, then update the complete object so omitted fields are not cleared accidentally. +- Obtain explicit user confirmation before deletion or a delete-and-recreate workflow. + +## Known results + +- A generation submission normally returns `generationId` and `status`, and may return `creditsConsumed`. +- `query_tasks` normally returns task status, timestamps, and `works[]`. A work may include primary media, unwatermarked media, and cover URLs. Determine terminal state and media semantics from the live response. +- Signed URLs may expire. Never log them or treat them as permanent asset identifiers. +- For a tool without a public output schema, use the real response as returned. Do not invent fields or success states. diff --git a/third_party/kling-ai/skills/kling-ai/references/model-parameters.md b/third_party/kling-ai/skills/kling-ai/references/model-parameters.md new file mode 100644 index 000000000..265fc3b54 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/model-parameters.md @@ -0,0 +1,57 @@ +# Parameters for the selected model + +Read after [capability discovery](capability-discovery.md). Use the chosen tool/model pair's complete live `arguments`, `inputs`, defaults, enums, and conditional constraints. These rules do not supply a static model or specification table. + +## Request and output settings + +- Treat the model's arguments and inputs as field allowlists. Satisfy required fields and dependencies; omit undeclared fields and irrelevant optional fields. When there are no inputs, omit `inputs` unless the tool schema requires otherwise. +- Pass each argument name once and encode numbers, booleans, and JSON arrays as required by the tool schema. Use only exact enum values. Rebuild the request when changing models; do not carry over the previous model's fields. +- Honor explicit user settings first, then apply the Skill's quality preferences only within legal choices and compatible defaults. Never use prompt text to simulate an unsupported resolution, input, or sound capability. Unsupported required settings need resolution before submission. +- Serialize explicit supported settings as actual arguments; optional does not mean irrelevant when the user requested a value. In particular, a duration in the prompt does not override the duration default, and a first frame does not cancel an explicitly requested aspect ratio. An equivalent immutable model setting needs no invented field. +- Follow model-specific aspect-ratio rules first. If the model says to omit the optional ratio when a first frame is supplied and the user has not requested a ratio, omit it to preserve that frame. Otherwise, when a ratio field exists, set a legal value from the requested destination or compatible live default. An automatic ratio may depend on image/video inputs; for text-only requests that disallow automatic ratio, choose a legal explicit ratio. If no ratio field exists, omit it rather than inventing an alternative name. +- Duration must accommodate action, dialogue, pauses, and the ending within live limits. Do not delete dialogue, speed it up, or split it into multiple paid tasks to hide a conflict. +- Content-expanding defaults must respect the user's intent: if declared and supported, explicitly select one result, a single continuous shot, and no generated sound unless the request calls for more. This includes fields such as `imageCount`, `prefer_multi_shots`, `enable_audio`, and `enable_asmr` only when that model declares them. If the model cannot meet the requested output structure or silence, explain the limitation. +- Respect single-value enums. When `prefer_multi_shots` only allows `true`, follow the live schema and disclose the fixed setting. A normal continuous-shot request is prompt intent. For an explicit hard guarantee, require a live capability that guarantees it before submitting. The presence or absence of the field alone establishes neither cuts nor a continuous shot. + +### Binding example + +When the live outer schema uses an array of name/value pairs, a request for a +7-second, 9:16 clip needs separate entries like these, provided the selected model +declares both values: + +```json +{ + "arguments": [ + {"name": "prompt", "value": "The creative description..."}, + {"name": "duration", "value": "7"}, + {"name": "aspect_ratio", "value": "9:16"} + ] +} +``` + +Add the requested resolution, count and sound controls in the same format when +declared. Do not nest those settings inside the prompt item or encode the whole +request as its text. Keep reference inputs in the outer schema's input slots. +Before sending, compare every explicit requirement with the actual serialized +value or supported input; build the result summary from those values afterward. + +## References and Elements + +Apply only when using actual/required reference inputs or Elements. Read [asset workflows](asset-workflows.md) for lookup and upload operations. + +- Map each real asset to its declared input slot and prompt reference. Distinguish first/tail frames, identity/product references, style, motion, and source material for editing. Follow the selected model's binding syntax; do not copy syntax from another model. +- For ordered keyframes, preserve frame order and describe motion between successive supplied states. Settle into the final state without overshoot or snapback unless requested. Do not invent intermediate-frame slots, timestamps, or a frame-count formula. A first frame controls the opening, not all subsequent camera movement. +- Validate accepted resource origin, format, size, dimensions, and per-resource/total duration from live constraints. Inspect actual metadata when possible; never claim validation based only on filenames. Do not silently remove required assets after an upload failure or to fit a limit. +- Call `element_get` before reuse and check the actual resource type. The model must declare both the binding argument and support for that Element type. Follow `elementSupport` restrictions on image/video types, individual and total counts, and conditions when reference video is present. An Element does not replace required image inputs; a video Element's cover is not a substitute for the video resource. +- Check `maxItems` and `combinedItemCap` when declared. For `combinedItemCaps[]`, evaluate `whenAnyInputPrefixes` and `whenNoneInputPrefixes` against actual inputs, and satisfy every applicable cap. Count actual items, not the highest numbered slot; count Elements as specified. Library storage capacity is separate from the number of references allowed in one generation. +- Preserve the motion-control requirement for a subject image and exactly one supported motion source. Do not use a preview URL in place of a motion ID. + +## Sound and audio + +Check required sound behavior during [video model selection](../../kling-ai-generate-video/references/model-routing.md). Send only controls declared by the selected model. Omission of an optional field such as `music_prompt` does not guarantee silent output. + +- Distinguish newly generated sound, preserved source-video audio, silence, dialogue, and narration. Map them only to declared controls and values; a tool-level audio description does not establish support for every model. +- If the model makes `enable_audio` and `keepOriginalSound` mutually exclusive, never enable both. Only send either field if declared. Explain incompatible user requirements rather than hiding the conflict in the prompt. +- Audio references use only declared audio slots, formats, duration limits, and reference syntax. Never pass audio through image/video slots or assume that accepting audio guarantees voice cloning or exact speech. +- Preserve user-supplied dialogue verbatim, including speaker, language, tone, and order. Narration does not become on-screen dialogue, and dialogue does not automatically authorize subtitles or slogans. +- Check timing and audio intent against the prompt and actual parameters before submission. Report submitted audio settings when relevant. Claim actual sound or dialogue quality only after inspecting the audio track. diff --git a/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md b/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md new file mode 100644 index 000000000..48501c37a --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md @@ -0,0 +1,95 @@ +# Prompt and usage examples + +## Suggested prompts + +- Use Kling Image 4.0 to generate a series of three 8K images in one request. Show the same red panda in a vintage spacesuit exiting a space station, drifting past a porthole, and turning to look at the blue Earth. +- Use Kling 4.0 to generate a 20‑second cinematic video: a mech warrior slams down from height onto the ground, sending out a shockwave that instantly blasts apart rubble and dust, with the camera rapidly pushing in for a powerful impact. +- Use Kling 4.0 Flash to turn my sneaker product photo into a 20-second, 720p video. Start from the photo, slowly orbit the shoe, and end on a close-up of the upper. +- Use Kling AI to browse the motion library and preview saved motions; after I select one, apply it to my subject image with an available motion-control model to generate a video. +- Use Kling AI to save the front and side views of my character as my first reusable Element, named “Xiaobai”, to help keep the character consistent in later creations. + +## 推荐提示词 + +- 使用可灵图片 4.0 一次生成 3 张 8K 连续组图。让同一只身穿复古宇航服的小熊猫依次从空间站出舱、掠过舷窗、转身望向蓝色地球 +- 使用可灵 4.0 生成一段 20 秒电影感视频:机甲战士从高空重砸地面,冲击波瞬间震开碎石与尘雾,镜头快速推近,充满力量感 +- 使用可灵 4.0 Flash,把我提供的运动鞋商品图作为首帧,生成一段 20 秒、720p 的视频,镜头缓慢绕过鞋身,最后停在鞋面细节上 +- 使用可灵AI查看动作库,预览已保存的动作;选定后,用可用的动作控制模型将该动作应用到我提供的主体图片生成视频 +- 使用可灵AI将我提供的角色正面图和侧面图保存为第一个可复用主体,命名为“小白”,方便后续创作时保持角色一致 + +## Natural-language requests + +Text-to-video: + +> Use Kling AI to create a 5-second, 16:9 cinematic video: outside a convenience store on a rainy night, a vintage motorcycle slowly pulls to a stop as the camera smoothly pushes in from a wide shot. Keep this turn active after submission until the result appears. + +Image-to-video: + +> Turn my attached image into a 5-second video. Keep the subject's identity, facial features, and clothing consistent; only let the camera slowly orbit from the left to the front. Use 720p. + +Multi-shot VIDEO 3.0: + +> Create a 7-second, four-shot product video: a 1.5-second wide establishing shot, a 2-second push-in on the product, a 2-second side orbit, and a 1.5-second hold on the brand detail. Enable multi-shot mode and use natural transitions between shots. + +Text-to-image: + +> Use Kling AI to create a 16:9 hero image for a poster: a transparent glass teapot in a minimalist white studio with soft side lighting and negative space for a headline on the right. + +Immediate submission with explicit approval: + +> Submit immediately without asking for confirmation again: use Kling AI to create a 5-second, 16:9, 720p single-shot video. Outside a convenience store on a rainy night, a vintage motorcycle slowly pulls to a stop. + +Status check: + +> Check the current status of this Kling generationId once. Do not poll repeatedly. + +Motion-library browsing: + +> List my saved motions with their names, IDs, and durations. Do not generate anything. + +Motion control: + +> Use my attached subject image with the motion named "Walking" from my library. Resolve the motion and show the supported model and final settings before submitting. + +Element creation: + +> Save these reference images as a reusable subject named "Blue sneaker". Show which image will be the cover and use the others as secondary views. + +Element update: + +> Update only the description of "Blue sneaker" to "Blue suede sneaker with white sole". Keep its cover, secondary images, and tags unchanged. + +Element reuse: + +> Use my "Blue sneaker" Element in a product image. Check its resource type and model compatibility first, and tell me if another source image is required. + +## Prompt construction + +Prefer concrete direction in this order: + +1. subject and setting +2. action or transformation +3. camera and shot structure +4. lighting and visual style +5. identity or consistency constraints +6. exclusions only when they prevent a likely failure + +Avoid long lists of repeated negatives. For image-to-video, state what must +remain stable and what is allowed to move. + +## User-facing submission summary + +Use one compact block: + +```text +Ready to submit: image-to-video · VIDEO 3.0 Turbo · 5 seconds · 720p · single shot +Action: keep the subject stable while the camera slowly orbits from the left to the front +Submission will consume Kling AI credits. +Reply "Confirm submission" to create one generation task. +``` + +After acceptance: + +```text +The task was submitted once. Any follow-up will only query this generationId; it will not create another task. +You may end this conversation; the task will continue running on Kling AI. +``` diff --git a/third_party/kling-ai/skills/kling-ai/references/tool-workflows.md b/third_party/kling-ai/skills/kling-ai/references/tool-workflows.md new file mode 100644 index 000000000..462371863 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/tool-workflows.md @@ -0,0 +1,35 @@ +# Remote tool workflows + +## Generation + +1. Use the plugin's single `kling-ai` connection at `https://kling.ai/mcp/plugin` and follow [capability discovery](capability-discovery.md), including all tool-list pages and relevant new entry points. +2. Create or reuse the objective's UUIDv7 `taskTraceId`, reuse the successful `who_am_i` response for this preparation, and apply [model parameters](model-parameters.md) to the selected tool/model pair. Video selection follows [video routing](../../kling-ai-generate-video/references/model-routing.md), including `omni_ref_video` when available. Refresh capability data when invalidated, not just because another reference was loaded. +3. For Elements, motion-library selections, or local media, follow [asset workflows](asset-workflows.md). A library operation does not authorize generation. Do not silently fall back to text-only generation if a required reference is unavailable. +4. Show the final mode, model, prompt summary, resolution, duration when applicable, aspect ratio, output count, and reference roles. Include live-required billing disclosures, including per-second billing and input video duration when applicable. Describe shot controls only as declared by the model, without inferring the actual number of cuts. Obtain explicit approval under the core Skill's billing rule. +5. Validate the request against the [MCP contract](mcp-contract.md), then call `query_membership_and_credits` on the same connection immediately before submission. Pause if the current balance is unavailable, non-positive, explicitly insufficient, or below the live estimate for the exact settings. A positive balance alone cannot establish that an unknown cost is covered. Keep the original settings and follow the recovery steps below. +6. Call the selected generation tool once using its live schema. Preserve the returned `generationId` and confirmed state. Follow the [Cursor result rules](../SKILL.md#generation-and-results) for App refresh or headless polling. + +## Resuming after a credit pause + +1. Keep the intent, tool, canonical model ID, prompt, output settings, input slots and usable source references, `taskTraceId`, submission state, and any known `generationId` in the current conversation. Use the current balance from `query_membership_and_credits`. Report a shortfall only when the service supplies an estimate for the exact settings. +2. Tell the user the confirmed state. If the balance cannot be checked, explain that submission is paused until it can be verified. For insufficient credits, use the official production top-up link returned by the current connection for the account's region. If no such link is returned, direct the user to the official Kling homepage in the plugin manifest to sign in to the same account and top up from its account page. Ask the user to return to this Cursor conversation and say “Continue the previous task” after topping up. +3. If the user only says they topped up, refresh the balance and explain the next step. When they explicitly ask to continue, identify the original task and ask which one only if several match. If that submission has a `generationId`, check that task before any balance or preparation steps, report its state or result, and end the recovery without a new submission. Any source image or video task number is only for looking up the source media. +4. Continue toward submission only if generation had yet to be called or the service explicitly confirmed that no task was created and no credits were charged. If the outcome is ambiguous, stop and report what remains unconfirmed. +5. Keep the original `taskTraceId` and confirm the original model, settings, and references are still usable on the same connection. Reuse valid upload references and refresh expired ones from accessible originals. Ask only for media that cannot be recovered, and obtain approval before changing the model or billable settings. +6. Honor approval already given for an unsubmitted intent with unchanged settings. If a previous call was rejected without creation or charge, an explicit request to continue those confirmed settings provides fresh authorization. Recheck current credits just before the single submission. If the balance still blocks it, keep the task paused. + +## Read-only operations + +- Credits: call `query_membership_and_credits` once. +- Task status: call `query_tasks` once with a known `generationId`; do not start long-running polling for a direct status request. +- Model capabilities: call `who_am_i` without creating a task. +- Motion library: call `motion_library_list`; do not call `motion_control` merely to browse. +- Subject library: use `element_list` and `element_get` to resolve real subjects and resource types. + +## State changes + +- Create or update an Element only as requested, following the complete-resource rules in [asset workflows](asset-workflows.md). +- Delete an Element only when the user explicitly identifies the deletion target. A cover replacement that requires delete-and-recreate needs explicit authorization for the ID change. +- Call `logout` or switch accounts only when explicitly requested. Re-enter native Cursor OAuth through the MCP Connect flow and stop other Kling calls until authorization completes. + +Never retry a generation automatically. If a submission yields no known `generationId`, report the returned error if present and any unknown creation or billing state, then stop. diff --git a/third_party/kling-ai/skills/kling-ai/references/troubleshooting.md b/third_party/kling-ai/skills/kling-ai/references/troubleshooting.md new file mode 100644 index 000000000..8ad13b4b2 --- /dev/null +++ b/third_party/kling-ai/skills/kling-ai/references/troubleshooting.md @@ -0,0 +1,69 @@ +# Cursor troubleshooting + +## MCP tools are missing + +Use Cursor's MCP settings to verify that the plugin's `kling-ai` server is enabled and points to `https://kling.ai/mcp/plugin`. After changing plugin files, run `Developer: Reload Window`; if the tool definitions remain stale, start a new Cursor conversation and check its MCP diagnostics. Do not add a duplicate server or use an API key as a workaround. + +## Endpoint migration and authorization + +This release uses the Global endpoint `https://kling.ai/mcp/plugin`. The previous Cursor plugin endpoint was `https://kling.ai/mcp`. Before updating an existing connection, retain any outstanding task numbers and finish their status checks through the original connection. Disconnect the old host-managed OAuth session, update the plugin, then use Cursor's MCP Connect flow to authorize the Global account. Never transfer credentials between hosts or assume that regional task history and credits are shared. + +For an authorization failure, use Cursor's MCP Connect flow for `kling-ai`, and complete native OAuth. If sign-out or account switching was explicitly requested, call the live `logout` tool as documented and reauthorize before other Kling calls. Do not paste tokens, construct OAuth URLs manually, or add an `oauth_resource` override. `Developer: Reload Window` reloads plugin files; it does not refresh OAuth credentials. + +OAuth discovery and client registration belong to the host. Do not require a custom client name or try to add one to generation arguments, headers, or the MCP URL. If the server rejects the host's registration, preserve the sanitized error for the service maintainer instead of guessing metadata or requesting credentials in chat. + +## Parameter or resolution validation fails + +- Check the actual request for a missing, null, empty, or whitespace-only top-level `model`. Compare `arguments[]` and `inputs[]` with the selected model's required fields, including `prompt` and media slots. Use the exact slot names, such as `image_1` or `first_image`, declared for that model. +- Refresh live definitions and correct only the rejected fields or missing references. If an explicit resolution such as `1080p` was rejected, compare the submitted value with the refreshed enum and its conditions for the same account, connection, tool, and model. If they match, record the mismatch with the trace ID and sanitized fields for the maintainer. Ask the user to choose if their requested setting is unavailable. +- When diagnosing field changes, compare the model's original tool-call arguments with Cursor's outgoing MCP request and the live schema's `required` list if those are available. Record missing diagnostic data and omit credentials and signed URLs. + +## Upload or asset reference fails + +- Read the live `file_upload` schema and [asset workflow](asset-workflows.md). +- A ticket is only the first step. Complete the multipart upload with `ticket` and binary `file`, then use the confirmed media URL. +- Reuse the objective's `taskTraceId` where accepted. Never send local paths or expired signed URLs as remote media inputs. +- If upload is unavailable or fails, stop before dependent Element writes or generation. Do not silently switch to text-only generation or loop on upload requests. +- If the error concerns a missing resource or invalid signature, verify the complete upload response URL, its source, and the bound slot. Fix the reference and complete the authorized first submission only if the failure was in upload or local validation and generation has yet to be called. +- If the service says to retry with the same generation ID, look up the current submission's confirmed `generationId` using the [result rules](../SKILL.md#generation-and-results). An upload ID or a source image or video task number cannot stand in for it. If no ID belongs to this submission, preserve its trace ID and report that task creation and charging remain unconfirmed. +- For diagnosis, compare available stages of the same request from upload response through Cursor's model input, original tool arguments, and outgoing MCP request. Record unavailable stages. Compare only redacted URL summaries and query parameter names. A `ResourceNotFound` error alone cannot identify the stage that failed. + +## Model capability mismatch + +If the user says a requested model is enabled but it is absent, follow [capability discovery](capability-discovery.md): finish all tool-list pages, include `omni_ref_video` for video when present, and query remaining generation entry points before concluding the model was not returned. Check the actual connection, endpoint, and MCP version, then refresh discovery. Another client's results or website membership do not replace this connection's account-scoped capabilities. + +If the mismatch remains, report that the current connection did not return the requested model and the cause needs investigation. Do not label it an account-permission failure without evidence, change accounts/endpoints, probe guessed model names through generation, or silently fall back to an older model. Keep diagnostics sanitized; omit credentials, private account fields, and signed URLs. + +## Element or motion cannot be used + +- Resolve ambiguous names before selecting an ID. Use `element_get` to inspect the resource type and access before reuse or updates. +- Use Elements only with live models declaring both the resource type and binding argument, including conditional caps. Preserve required image inputs and use the model's prompt and structured bindings; entry point names alone do not establish support. +- Keep the existing cover and unmodified secondary images when updating an image Element. Do not change its resource type or delete-and-recreate without explicit authorization. +- Motion control requires a subject image and exactly one source: `motionId` or a video input. A library preview URL is not a motion ID. Validate source duration and model arguments; do not invent a `duration` parameter. +- An empty motion library is a valid result. The current tool surface has no motion create, update, or delete operation. + +## Task is still running or the result App does not render + +Follow the [Cursor result rules](../SKILL.md#generation-and-results). If the user reports a missing video and this submission has a task number, use the mounted App's current status or look up that task when the App is unavailable. Report progress while it runs, deliver the usable video on success, and preserve the task number and reason on failure. If a lookup fails, report the last confirmed state and explain that the refresh failed. + +A rendering problem is not a generation failure. Preserve the tool result and follow the core Skill's text fallback and completion rules. Do not register a local MCP server, embed duplicate media, or claim that an unmounted App was displayed. + +## Submission fails or times out + +If a `generationId` is known, follow the core Skill's App or headless result rules. If no ID is known, report the returned error and any unknown creation or billing state, then stop. A credit balance cannot establish the outcome, and `query_tasks` requires a known ID. Any new attempt needs fresh explicit authorization. + +For a provider failure, return the provider message and preserve task IDs. For unsupported arguments, refresh the live schema, revise the rejected settings, and obtain confirmation before any new generation. + +Treat a generic service-unavailable message as a service error even when the outer code is `InvalidParameter`. Follow up on a known task number. If there is no task number and the submission is ambiguous, stop and preserve the trace ID. Apply parameter troubleshooting when the service identifies a specific field. + +## Rate limit or full generation queue + +Distinguish a full generation queue from a rate-limited status query. For a full queue, keep the original settings and any task number. Report the returned waiting instructions and confirmed task state. If the service has no queue for this request, distinguish a confirmed rejection from an unconfirmed submission. When the user asks to continue, check any known task first and follow the [single-submission workflow](tool-workflows.md#generation). If a status query is rate-limited, stop polling and report the last confirmed state and task number. + +## Insufficient credits + +Use the current balance and provider response to distinguish a task paused before submission, a rejected call, and an unconfirmed submission. Membership allowances alone do not establish the available balance. Follow [credit recovery](tool-workflows.md#resuming-after-a-credit-pause). A balance change or request to view an existing result does not authorize a new submission. + +## Result link expired + +Query the original `generationId` for current outputs immediately before reuse. Do not treat signed URLs as permanent asset identifiers or log them. If the task cannot be queried in the current region, explain the limitation rather than creating a replacement task. diff --git a/third_party/kling-ai/tests/plugin.test.mjs b/third_party/kling-ai/tests/plugin.test.mjs new file mode 100644 index 000000000..f028d1a92 --- /dev/null +++ b/third_party/kling-ai/tests/plugin.test.mjs @@ -0,0 +1,46 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +import { verifyPlugin } from "../scripts/verify-plugin.mjs"; + +test("the Global Cursor plugin satisfies its package contract", () => { + const result = verifyPlugin(); + + assert.deepEqual(result, { + name: "kling-ai", + endpoint: "https://kling.ai/mcp/plugin", + version: "1.4.1" + }); +}); + +test("suggested prompts cover Image 4.0, both 4.0 video models, motions, and Elements in both languages", () => { + const examples = readFileSync(new URL("../skills/kling-ai/references/prompt-examples.md", import.meta.url), "utf8"); + + for (const [heading, expected] of [ + ["Suggested prompts", [ + /Kling Image 4\.0.*series of three 8K images in one request/, + /Kling 4\.0 to generate a 20/, + /Kling 4\.0 Flash.*20-second, 720p/, + /motion library/, + /reusable Element/ + ]], + ["推荐提示词", [ + /可灵图片 4\.0 一次生成 3 张 8K 连续组图/, + /可灵 4\.0 生成一段 20 秒/, + /可灵 4\.0 Flash.*首帧.*20 秒、720p/, + /动作库/, + /可复用主体/ + ]] + ]) { + const section = examples.split(`## ${heading}\n\n`)[1]?.split("\n## ")[0]; + assert.ok(section, `Missing section: ${heading}`); + const prompts = section.trim().split("\n"); + assert.equal(prompts.length, expected.length); + for (const [index, prompt] of prompts.entries()) { + assert.ok(prompt.startsWith("- ")); + assert.match(prompt, expected[index]); + assert.doesNotMatch(prompt, /最新|latest|V4/i); + } + } +}); From dd8f22bbd3966385314f3e4c39319a09fd5dae62 Mon Sep 17 00:00:00 2001 From: william Date: Sat, 21 Nov 2026 06:54:51 +0800 Subject: [PATCH 2/2] feat: add current Kling regional Cursor plugins --- .cursor-plugin/marketplace.json | 5 + README.md | 1 + .../kling-ai-cn/.cursor-plugin/plugin.json | 33 +++++ third_party/kling-ai-cn/.gitignore | 6 + third_party/kling-ai-cn/LICENSE | 21 +++ third_party/kling-ai-cn/PRIVACY.md | 11 ++ third_party/kling-ai-cn/README.md | 133 ++++++++++++++++++ third_party/kling-ai-cn/assets/kling-logo.png | Bin 0 -> 3766 bytes third_party/kling-ai-cn/mcp.json | 8 ++ third_party/kling-ai-cn/package.json | 14 ++ third_party/kling-ai-cn/rules/kling-ai.mdc | 27 ++++ .../kling-ai-cn/scripts/verify-plugin.mjs | 77 ++++++++++ .../skills/kling-ai-generate-image/SKILL.md | 47 +++++++ .../references/prompt-construction.md | 43 ++++++ .../references/scene-patterns.md | 28 ++++ .../skills/kling-ai-generate-video/SKILL.md | 44 ++++++ .../references/model-routing.md | 20 +++ .../references/motion-and-shots.md | 56 ++++++++ .../references/scene-patterns.md | 28 ++++ .../kling-ai-cn/skills/kling-ai/SKILL.md | 72 ++++++++++ .../kling-ai/references/asset-workflows.md | 38 +++++ .../references/capability-discovery.md | 23 +++ .../kling-ai/references/mcp-contract.md | 45 ++++++ .../kling-ai/references/model-parameters.md | 63 +++++++++ .../kling-ai/references/prompt-examples.md | 95 +++++++++++++ .../kling-ai/references/tool-workflows.md | 35 +++++ .../kling-ai/references/troubleshooting.md | 69 +++++++++ third_party/kling-ai-cn/tests/plugin.test.mjs | 46 ++++++ .../kling-ai/.cursor-plugin/plugin.json | 4 +- third_party/kling-ai/README.md | 4 +- third_party/kling-ai/package.json | 4 +- .../skills/kling-ai-generate-video/SKILL.md | 10 +- .../references/model-routing.md | 1 + .../kling-ai/references/model-parameters.md | 6 + .../kling-ai/references/prompt-examples.md | 4 +- third_party/kling-ai/tests/plugin.test.mjs | 8 +- 36 files changed, 1112 insertions(+), 17 deletions(-) create mode 100644 third_party/kling-ai-cn/.cursor-plugin/plugin.json create mode 100644 third_party/kling-ai-cn/.gitignore create mode 100644 third_party/kling-ai-cn/LICENSE create mode 100644 third_party/kling-ai-cn/PRIVACY.md create mode 100644 third_party/kling-ai-cn/README.md create mode 100644 third_party/kling-ai-cn/assets/kling-logo.png create mode 100644 third_party/kling-ai-cn/mcp.json create mode 100644 third_party/kling-ai-cn/package.json create mode 100644 third_party/kling-ai-cn/rules/kling-ai.mdc create mode 100644 third_party/kling-ai-cn/scripts/verify-plugin.mjs create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-image/SKILL.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-image/references/prompt-construction.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-image/references/scene-patterns.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-video/SKILL.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-video/references/model-routing.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-video/references/motion-and-shots.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai-generate-video/references/scene-patterns.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/SKILL.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/asset-workflows.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/capability-discovery.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/mcp-contract.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/model-parameters.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/prompt-examples.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/tool-workflows.md create mode 100644 third_party/kling-ai-cn/skills/kling-ai/references/troubleshooting.md create mode 100644 third_party/kling-ai-cn/tests/plugin.test.mjs diff --git a/.cursor-plugin/marketplace.json b/.cursor-plugin/marketplace.json index b47025825..b345a4b61 100644 --- a/.cursor-plugin/marketplace.json +++ b/.cursor-plugin/marketplace.json @@ -818,6 +818,11 @@ "source": "third_party/kling-ai", "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP." }, + { + "name": "kling-ai-cn", + "source": "third_party/kling-ai-cn", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through the China-region Kling MCP." + }, { "name": "sabre-developer-hub", "source": "third_party/sabre-developer-hub", diff --git a/README.md b/README.md index aa63f92a7..11929378a 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Official Cursor plugins for popular developer tools, frameworks, and SaaS produc | `fiscal-ai` | [Fiscal.ai](third_party/fiscal-ai/) | Cursor | Integrations | Pull source-linked financials, filings, ratios, prices, segments, KPIs, ownership, fund letters, and news from Fiscal.ai. | | `lmty` | [LMTY](third_party/lmty/) | Cursor | Integrations | Read tracked competitors, competitive intelligence reports, change logs, evidence, social mentions, and market feeds for your products, and browse LMTY's public Markets, event timelines, and company, product, and person profiles. | | `kling-ai` | [Kling AI Plugin](third_party/kling-ai/) | KLING AI | Integrations | Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP. | +| `kling-ai-cn` | [Kling AI China Plugin](third_party/kling-ai-cn/) | KLING AI | Integrations | Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through the China-region Kling MCP. | | `sabre-developer-hub` | [Sabre Developer Hub](third_party/sabre-developer-hub/) | Cursor | Integrations | Search and read Sabre Developer Hub documentation, OpenAPI specs, and Sabre-published agent skills for travel APIs, SDKs, and product collections. | Author values match each plugin’s `plugin.json` `author.name` (Cursor lists `plugins@cursor.com` in the manifest). diff --git a/third_party/kling-ai-cn/.cursor-plugin/plugin.json b/third_party/kling-ai-cn/.cursor-plugin/plugin.json new file mode 100644 index 000000000..1d43881c5 --- /dev/null +++ b/third_party/kling-ai-cn/.cursor-plugin/plugin.json @@ -0,0 +1,33 @@ +{ + "name": "kling-ai-cn", + "$schema": "https://cursor.com/schemas/cursor-plugin/plugin.json", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 (including HDR) and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "version": "1.4.2", + "author": { + "name": "KLING AI" + }, + "homepage": "https://klingai.com", + "repository": "https://github.com/klingai-tech/cursor-plugin", + "license": "MIT", + "keywords": [ + "kling", + "kling-ai", + "image-generation", + "video-generation", + "mcp", + "oauth" + ], + "logo": "assets/kling-logo.png", + "rules": "rules", + "skills": "skills", + "mcpServers": "mcp.json", + "tags": [ + "media", + "creative", + "ai-generation", + "video", + "image", + "mcp", + "oauth" + ] +} diff --git a/third_party/kling-ai-cn/.gitignore b/third_party/kling-ai-cn/.gitignore new file mode 100644 index 000000000..8b0797884 --- /dev/null +++ b/third_party/kling-ai-cn/.gitignore @@ -0,0 +1,6 @@ +node_modules/ +.env +.env.* +outputs/ +assets/generated/ +.DS_Store diff --git a/third_party/kling-ai-cn/LICENSE b/third_party/kling-ai-cn/LICENSE new file mode 100644 index 000000000..15cab3eb4 --- /dev/null +++ b/third_party/kling-ai-cn/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 KLING AI Pte Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/kling-ai-cn/PRIVACY.md b/third_party/kling-ai-cn/PRIVACY.md new file mode 100644 index 000000000..b3f14a5ab --- /dev/null +++ b/third_party/kling-ai-cn/PRIVACY.md @@ -0,0 +1,11 @@ +# Privacy + +The plugin sends prompts, reference media, task identifiers, account queries, +and generation requests to the Kling AI China remote MCP at +`https://klingai.com/mcp/plugin` only when Cursor invokes its tools. + +Cursor manages OAuth for the remote MCP connection. The packages do not request, +store, or log API keys, OAuth tokens, cookies, authorization headers, or local +credential files. They do not include a local MCP server or localhost monitor. + +Kling AI's privacy policy and terms apply to data processed by the service. diff --git a/third_party/kling-ai-cn/README.md b/third_party/kling-ai-cn/README.md new file mode 100644 index 000000000..8595bcef5 --- /dev/null +++ b/third_party/kling-ai-cn/README.md @@ -0,0 +1,133 @@ +# 可灵 AI Cursor 插件 + +This marketplace lists the upstream `cn` branch separately as `kling-ai-cn` so it can be installed alongside the Global listing. + +在 Cursor 的 Agent 对话中生成图片和视频、复用主体、查询任务进度。 +这是 `cn` 分支的**国内版**,版本 **1.4.2**。使用国际站账号请前往 +[`main` 分支](https://github.com/klingai-tech/cursor-plugin/tree/main)。 + +## 快速开始 + +### 1. 安装插件 + +打开 Cursor 桌面端,在 **Agent** 对话中粘贴这段话。 + +> 请从 https://github.com/klingai-tech/cursor-plugin 的 `cn` 分支安装可灵 AI Cursor 插件。 +> 参照 Cursor 的本地插件安装说明,安装后引导我重载 Cursor、连接可灵国内站账号, +> 并检查连接和可用灵感值。先不要发起生成任务。 + +[可灵 MCP & CLI 官方指南(国内)](https://klingai.com/app/mcp/guide) · +[Cursor 本地插件安装说明](https://cursor.com/docs/plugins#test-plugins-locally) + +#### 手动安装 + +macOS 或 Linux 用户可在终端运行以下命令。 + +```bash +git clone --branch cn --single-branch https://github.com/klingai-tech/cursor-plugin.git +cd cursor-plugin +mkdir -p ~/.cursor/plugins/local/kling-ai +cp -R .cursor-plugin assets rules skills mcp.json README.md ~/.cursor/plugins/local/kling-ai/ +``` + +
+Windows PowerShell + +```powershell +git clone --branch cn --single-branch https://github.com/klingai-tech/cursor-plugin.git +Set-Location cursor-plugin +$pluginDir = Join-Path $HOME '.cursor/plugins/local/kling-ai' +New-Item -ItemType Directory -Force -Path $pluginDir | Out-Null +Copy-Item -Recurse -Force -Path .cursor-plugin, assets, rules, skills, mcp.json, README.md -Destination $pluginDir +``` + +
+ +如果已经克隆过仓库,更新本地 `cn` 分支,在仓库根目录执行复制步骤即可。 +如果旧版的本地插件目录里还有 `commands/kling-ai.md`,请在重载前移除该旧文件。 + +[Cursor Directory 页面](https://cursor.directory/plugins/kling-ai)会分别添加 Rule 或 MCP。 +要安装包含 `/kling-ai` Skill 的完整插件,请使用上面的本地安装步骤。 + +### 2. 授权可灵账号 + +1. 重启 Cursor,或在命令面板运行 **Developer: Reload Window**。 +2. 打开 **Customize → Plugins**,确认 **Kling AI** 已加载。在 **Customize** 中找到已启用的 + `kling-ai` MCP 服务,点击 **Connect**。 +3. 在浏览器登录可灵国内站账号并授权 Cursor。返回 Cursor,新建一个 Agent 对话。 + 插件自带[国内站 MCP 配置](mcp.json),地址为 `https://klingai.com/mcp/plugin`,由 Cursor 完成 OAuth 授权。 + +### 3. 在 Agent 对话中试用 + +输入 `/kling-ai`,选中 Skill 后发送提示词。 + +- **检查连接** · 帮我检查可灵账号是否已连接,以及还有多少可用灵感值。先不发起生成。 +- **文生图** · 生成一张 4:5 的香水商品海报,玻璃瓶身、暖色棚拍光。先展示生成设置,等我确认后再提交。 +- **图生视频** · 用我附上的商品图做首帧,生成一段 5 秒视频。商品保持不动,镜头缓慢推近。 + +有参考图或视频时,把素材附在对话里,并说明它是首帧、风格参考还是主体素材。 +生成会消耗灵感值,请先核对设置再确认提交。提交后可以在结果卡片查看进度,也可以凭任务编号查询已有任务。 + +更多示例见[中文提示词](skills/kling-ai/references/prompt-examples.md#推荐提示词)和 +[英文提示词](skills/kling-ai/references/prompt-examples.md#suggested-prompts)。 + +## 常见问题 + +- **找不到插件或 Skill** · 确认本地插件目录内有 `.cursor-plugin/plugin.json`,重载 Cursor 后新建 Agent 对话。 + 企业版可请管理员确认 **Allow Local Plugin Imports** 已开启。 +- **连接失败或账号不对** · 在 Cursor 中仅保留一个启用的可灵 MCP 条目,再重新连接插件的 `kling-ai` 服务。 + 从国际版切换时,先断开旧连接,再用国内站账号授权。 +- **任务还在运行或结果卡片未显示** · 如果已有任务编号,请让 Cursor 查询原任务。其他问题见[故障排查](skills/kling-ai/references/troubleshooting.md)。 + +## 功能 + +- 文生图、参考图编辑和连续组图。未指定模型时,如果当前账号支持且符合需求,优先使用可灵图片 4.0,再考虑账号可用的默认模型。 +- [可灵图片 4.0](https://kling.ai/quickstart/kling-image-4-user-guide)支持原生 8K 和连续组图模式,单次最多生成 10 张连贯图片。 +- 可灵 4.0 支持文生视频、首尾帧与中间关键帧,以及使用图片、视频、音频和主体的全能参考。支持 3–30 秒,默认 720p。可用 1080p 或 4K 的账号可在文生视频、图生视频和全能参考中开启 HDR 输出。 +- 可灵 4.0 Flash 支持文生视频、单首帧图生视频,以及使用图片、视频和主体的全能参考。支持 3–20 秒、720p。 +- 两款视频模型的全能参考均支持智能分镜。同步生成声音和保留原视频音频最多启用一项。实际可用模型、参数、素材上限和计费信息以当前账号为准。 +- 支持素材上传、主体管理、动作库、灵感值查询和任务查询。生成前确认计费设置,每次确认对应一次提交,结果卡片可用时自动刷新。 + +## 插件组件 + +| 组件 | 路径 | 用途 | +| --- | --- | --- | +| 清单 | `.cursor-plugin/plugin.json` | 声明插件及组件入口 | +| MCP | `mcp.json` | 国内站远程 OAuth MCP | +| Rule | `rules/kling-ai.mdc` | 请求路由和单次提交规则 | +| 核心 Skill | `skills/kling-ai/` | `/kling-ai` 入口、授权、账号、素材、主体和任务查询 | +| 图片 Skill | `skills/kling-ai-generate-image/` | 图片生成、提示词和质量检查 | +| 视频 Skill | `skills/kling-ai-generate-video/` | 视频、动作控制、时长和镜头规划 | + +## 生成流程 + +1. 生成前调用 `who_am_i`,使用服务返回的模型、参数、枚举值和输入定义。 +2. 使用远程上传工具上传本地素材。同一目标复用一个 UUIDv7 `taskTraceId`。 +3. 展示最终生成设置和当前服务要求的计费信息。用户已经授权这些设置时可直接继续,否则先取得明确确认。 +4. 提交前在同一连接检查当前灵感值。余额不可用或不足时暂停。 +5. 每次确认最多调用一次生成工具。提交结果不明确时,禁止自动重试。 +6. Cursor 显示结果卡片时,由卡片自动刷新。卡片未显示时,按服务允许的间隔查询,直到任务结束、取消或对话无法继续。单次状态查询只查一次。 +7. 任务成功并返回所需类型、数量的可用结果后,才报告完成。结果不足时报告实际数量。 + +灵感值不足时,请在国内站用同一账号补充,然后回到原 Cursor 对话继续。 +Cursor 会先检查已有任务编号,并且只在可以安全提交时复核余额、按原设置提交。 + +## 开发验证 + +```bash +npm run check +npm test +for skill in skills/*; do + python3 "${CODEX_HOME:-$HOME/.codex}/skills/.system/skill-creator/scripts/quick_validate.py" "$skill" +done +``` + +## 官方资料 + +- [Cursor 插件文档](https://cursor.com/docs/plugins) +- [Cursor 插件参考](https://cursor.com/docs/reference/plugins) +- [Cursor MCP 文档](https://cursor.com/docs/mcp) + +## 许可证 + +MIT。可灵 AI 及相关商标归各自权利人所有。 diff --git a/third_party/kling-ai-cn/assets/kling-logo.png b/third_party/kling-ai-cn/assets/kling-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..d8935f0c4cd5938c64c4223f069f19c5c046eaec GIT binary patch literal 3766 zcmV;n4oUHeP)`1$+w_xRr5;QRah;o;&94Go~7 zq9!IL2L}h~>FS}QqZJhu85tT85fS6$@F)}g=3JNqeH60!v%goKk$;rdS#=yeD zl9QC#+1fceI_~fAb98iRX=+7AMlCHa+uYrIe0=ls^ziZV)z;Utv$Q`yK+@CG&d<=j zzQ2o%jDv)Qe}I5&ZEj>_W$Wzh=I7^~o}Vf!E4sV9x45~dsHt#qa$sO#T3cL7OG~S) zt(cjbhlq%FcX(1$Q?9SDTwGmFPfwMWm!zhqjgOC3R#w?Jtj7QV4SPvMK~#9!?3!s` z+CUJ8Xa76dY%UHF!3(j9BK5wlx7Lcb*82UwOn)1Kg;s4si0uoWSNJm|PbRaoGf^5b zV#J6MBSwrEF=E7s5hF(QBa7A2$J)|T?PIArDd|5)R<@fH^M!R*h)}#fRe!u|RsT=- z@tL*r4FxEzh3mQ^#C+0P0oeF(SR1GRit5pV4QQ9eE3l^lr+zd?{|VCvQ-CtUZ^J?Z zt9MoU=MwXZqR z+ORkZ^TD8tr_>HRLh%~`3X}no&S6JknVK6+xp-ITc7(306ab|oe@ok0j0l?uqM~s+ zK$s;_?Occ52MYx_<=w4`iN}l8b#(R`%X4OF*i0daQlmAH@>33)S@<5Xv32zESx}bR zWiXpF+vAdkN?AFb)L5P*nOymE*b({y$Q_ja`2K@~z+^~+j`J>&9Hfb5pM8yu z{a5;`4`#hMSQ~0?be%5;P;MO?WlN#ndi|)=j&*T(btBhxZYOsxZGx?^v6_4HxIOrS zF*Y>k4{$oQ^eCaTr14ABssswB#lIXXZL=7;I3(vW*d6CjiPyE-z6$en5!)F!n_$^UR_1 z1j%G!UWLPf##Q{e6GAYi(>v3y3invdlT1D7APh!g;%##95MD2pd8yw2uKmDXq0q0P>q_bFXesQ=SmGqO?qR5}GlYtTx-K)2Kj+ z-(H$|!0ys3+Ve^X?57U&RG!0Pw?s0*w~oO6v!&}PbkSbe7@_g;#q(Vl>F;Ts4`GGz zT1=GC=Lq;$T=ORji&syro7U6O?e0d{hg$B-JKq$0N!Hpt;1#;umyX+ z9V0hPoxY(oT)_`3M~UJRwelKcZzy-u*JkgeKO7b13Py?2u+CwHevH2gS7DpXs8?e= zlM6T&Zu`!?4f9}A^`=c2X^&$&k1s1n1d1PsWDM(7&A&axLkQs&C9~-tj42@hHT%mNWhE@ulVzoo~MY9VRmfOyI4!ADCWc?q@e~D&u<+cO?Ir4VQ3k0 z`l{2U$NoUhG;X^BXVGVeg;19?H0w79TWRP0C^r(bs|Bum-+I(&7|6G+O4c(DVSIHqD9VwdlF| zOjlzGj$rH!>`YH4($R^8UWiVV>1rJJm<78jF7*jQ?L7y2h76fzh-u?}5uinbW2(m` z(Tq8_w@Wf>Yg0HZ!MdL2Ql?I~i5ht!obJ|`VO~qRhi%GWl~Pa-cf==i_v$&LGtBF% z`GHfu4?6J#X2@Za(R0*GCc6xk^Wmk6>E=)&G%bST{8=k~Ua##BBhW1fZ)et&J61h^ zVb07Nwg>~A>Qc85XfEVgSTW|=)Oj6&2}(u56R5*V@aiqSwV!g|odyfXoX*8GWlKT% zk+i!>sW^n_pv#&6k6T%FvtuQ7c66|Qws);vX#+uYGns5Q4+NwZp#lOvpdinJirD(7 zZBc96|Nm!tW|MG0DTgF%^#k`)du-S1FuOB5duQY+rWP5nX$u+})hyzG@_ru{q!c@~ zjJcmcb7FeO7p_fVaHU&uL^ig+OhALPm=8LJe|QG0RY5OsBtyUJI2bdPyarj6y*>dm z@DMd183oGnuh1MU#5Odd#n^i=)%tZw#$1yXL36fZ{qzrju?92vNwj0Y%P@UN48tldR!~|*Sa=vUUy=oFOj-*_sfaQ~Dtia! zeFTknBZlt;qF9iLD~U2PD>L;#78&WCl4@xtYGQZBkScfMJ6a63gTGOYcQ=ZiO+=oZ z;jDBw_GC`_dA15y56!ttoMDlj)kK+J^Doym(41!I7dXjzQKOckD6?bFY36d^y3hz^ z=E9ivpv<6ssP=0rtjt}oDnb+GFhYrjBMj7FMqHuXuj}&VTAw`u4GWG!g(er1-X09W zI+mKc3!28~ROB6@C0k5iQ5M+&6Aj@K=N0}vl_m+6$i=M&!P&D5lL6J0499MTNN5&6 zURB?uv!o;M>NOSvX<7r0o>{|KP2lvQNn+{*G{eLoB+_QQS{N+?+4+^n0#{(2?n?Ek zDKCU8A|nN(Zp>og9rYNr_2=eCG@;6tk;z>Gw`AAlWeD|WDkD&VoE^?vtdWiCn&c@6=E{XKF#a~HM2?JnfFdW_W zj(Yd!zrW;@0FGoV-MPxbaK7|3{qfuUo}{H0>j*pYbikQ@1wJ!{1TlnYoY0fe5bgL$ z-q7>u#i3*G6LtH}!{*%Utm9@T)OXK;>qYPqi;Ejl3FrSA@pfx{lqM#~Kcr4Rft1-- z^>A%H7k-mUJ$^R*lg{a--NuEz`ayTU-|3gT2j@oxy$eX1_1lo$Q~Tb@;dfod&rHMA zlukh;FagbMNY1~!t}AqzzOEbM!KzKQZLf9mhK1z(Be;xb*g8NGH0^jL4w=5!RC^fC z%(CAk;hpP$)>HPl1q`Yl%Tc-lDYH*Lvap;-0q3XnaApN`DOJ>$-$^B9i^BFpA#@M% zdC_bA>f>;=PaKhDpSwKB;a-k zm3eNG2X5f>XC9>g-x$bVJ8(%E4O6F?)kgaEy_g?(SH8&pA9Q+&2HPI6b>}e!V3C9Ml3B&TCL6WWW1UN&`3m zz>g0H+ow09$NT%oQEj+AXto7Bn?Y;{*m@nxg!BnbI>Y4yhVADghyeyiMEUjbabJG! zt3hUj`ALqwIXX{vJ`AqZr;F{@A*OSXO#=-!@`-F z1Md%l7Z+Ex#v2<1A7Hn4^S+#K&yCzql`n64Z@`N~{Bncz+x!Iq8*H$_1{-X!!3G;_ gu)zi!Z19Ts3sHFWTOdKl1ONa407*qoM6N<$f}~DZ=Kufz literal 0 HcmV?d00001 diff --git a/third_party/kling-ai-cn/mcp.json b/third_party/kling-ai-cn/mcp.json new file mode 100644 index 000000000..87bf989f1 --- /dev/null +++ b/third_party/kling-ai-cn/mcp.json @@ -0,0 +1,8 @@ +{ + "mcpServers": { + "kling-ai": { + "type": "http", + "url": "https://klingai.com/mcp/plugin" + } + } +} diff --git a/third_party/kling-ai-cn/package.json b/third_party/kling-ai-cn/package.json new file mode 100644 index 000000000..91dc859c7 --- /dev/null +++ b/third_party/kling-ai-cn/package.json @@ -0,0 +1,14 @@ +{ + "name": "kling-ai-cursor-plugin", + "version": "1.4.2", + "private": true, + "type": "module", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 (including HDR) and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "scripts": { + "check": "node scripts/verify-plugin.mjs", + "test": "node --test tests/*.test.mjs" + }, + "engines": { + "node": ">=20" + } +} diff --git a/third_party/kling-ai-cn/rules/kling-ai.mdc b/third_party/kling-ai-cn/rules/kling-ai.mdc new file mode 100644 index 000000000..90e12896b --- /dev/null +++ b/third_party/kling-ai-cn/rules/kling-ai.mdc @@ -0,0 +1,27 @@ +--- +description: Use Kling AI for prompts, storyboards, image, video, motion, asset, account, and task requests +globs: +alwaysApply: false +--- + +For Kling requests, use `$kling-ai` and route creative work to +`$kling-ai-generate-image` or `$kling-ai-generate-video`. Use only the +configured `kling-ai` China MCP at `https://klingai.com/mcp/plugin`. +For prompt-only or storyboard-only requests, deliver the text without MCP calls. +During generation preparation, discover live model capabilities across relevant +tools and follow the dedicated Skill's model preferences. For video, include +`omni_ref_video` when available. Confirm final billable settings before generation +unless the same unsubmitted intent and unchanged settings are already explicitly +authorized. Submit each confirmed intent at most once. + +Check current credits on the same connection immediately before submitting. If +the balance is unavailable or insufficient, pause and follow the core Skill's +recovery workflow. When the user asks to resume and the original submission +has a task number, check that task first. + +Let a mounted generation MCP App refresh its own task. If no App is mounted +and a `generationId` is known, query at the provider-permitted interval until +terminal, cancelled, or the turn cannot continue. Report completion only after +terminal success with usable primary media. Query once for an explicit standalone +status request with a known task ID. Never switch regions or start or depend on +a local Kling MCP server. diff --git a/third_party/kling-ai-cn/scripts/verify-plugin.mjs b/third_party/kling-ai-cn/scripts/verify-plugin.mjs new file mode 100644 index 000000000..38de46216 --- /dev/null +++ b/third_party/kling-ai-cn/scripts/verify-plugin.mjs @@ -0,0 +1,77 @@ +#!/usr/bin/env node + +import { existsSync, readFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const SERVER_KEY = "kling-ai"; +const ENDPOINT = "https://klingai.com/mcp/plugin"; + +function readJson(path) { + return JSON.parse(readFileSync(path, "utf8")); +} + +export function verifyPlugin() { + const failures = []; + const check = (condition, message) => { + if (!condition) failures.push(message); + }; + + const packageJson = readJson(join(repoRoot, "package.json")); + const manifest = readJson(join(repoRoot, ".cursor-plugin/plugin.json")); + const mcp = readJson(join(repoRoot, "mcp.json")); + const servers = mcp.mcpServers ?? {}; + + check(manifest.name === "kling-ai", "manifest name must be kling-ai"); + check(manifest.version === packageJson.version, "manifest and package versions must match"); + check(manifest.homepage === "https://klingai.com", "homepage must use the China Kling site"); + check( + manifest.repository === "https://github.com/klingai-tech/cursor-plugin", + "manifest repository must match this repository" + ); + check( + manifest.rules === "rules" && + manifest.skills === "skills" && + manifest.mcpServers === "mcp.json", + "manifest must reference native Cursor components" + ); + check(!Object.hasOwn(manifest, "commands"), "the core Skill provides the /kling-ai entrypoint"); + check(JSON.stringify(Object.keys(servers)) === JSON.stringify([SERVER_KEY]), `plugin must register only ${SERVER_KEY}`); + check(servers[SERVER_KEY]?.type === "http", "MCP transport must be http"); + check(servers[SERVER_KEY]?.url === ENDPOINT, `MCP endpoint must be ${ENDPOINT}`); + + for (const path of [ + "assets/kling-logo.png", + "rules/kling-ai.mdc", + "skills/kling-ai/SKILL.md", + "skills/kling-ai-generate-image/SKILL.md", + "skills/kling-ai-generate-video/SKILL.md" + ]) { + check(existsSync(join(repoRoot, path)), `${path} is missing`); + } + + for (const forbidden of [ + ".cursor-plugin/marketplace.json", + "commands/kling-ai.md", + "kling-ai", + "plugin.json", + "ui", + "server", + "mcp-app", + "scripts/kling-monitor.mjs" + ]) { + check(!existsSync(join(repoRoot, forbidden)), `single China plugin must not bundle ${forbidden}`); + } + + if (failures.length > 0) { + throw new Error(`Cursor plugin verification failed:\n- ${failures.join("\n- ")}`); + } + + return { name: manifest.name, endpoint: ENDPOINT, version: manifest.version }; +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const result = verifyPlugin(); + console.log(`Verified ${result.name} ${result.version} at ${result.endpoint}.`); +} diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-image/SKILL.md b/third_party/kling-ai-cn/skills/kling-ai-generate-image/SKILL.md new file mode 100644 index 000000000..acac9217f --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-image/SKILL.md @@ -0,0 +1,47 @@ +--- +name: kling-ai-generate-image +description: Write or refine Kling AI image prompts, or generate and edit images through the Kling AI MCP in Cursor. Use for Kling Image 4.0, coherent image series, posters, product photography, portraits, covers, advertising stills, visual concepts, and controlled variants. +--- + +# Kling AI image generation + +For prompt-only work, use [prompt construction](references/prompt-construction.md) to decide whether the prompt needs changes, then return it and finish. Preserve composition requirements such as left-side copy space. Skip MCP calls, submission-setting recommendations, and offers to generate. If generation needs a missing image, ask for it, explain its role, and stop there. + +For generation preparation or submission, follow the Cursor OAuth, billing confirmation, single-submission, status, and result rules in the [core Kling Skill](../kling-ai/SKILL.md). + +To continue a paused image task, follow [credit recovery](../kling-ai/references/tool-workflows.md#resuming-after-a-credit-pause) before preparing another submission. Keep the original prompt, settings, and reference roles. + +Read [scene patterns](references/scene-patterns.md) for product, advertising, portrait, poster, or cover work. For Element reuse or local media, also read the core [asset workflows](../kling-ai/references/asset-workflows.md). + +When the user leaves model selection open, prefer Kling Image 4.0 if the account's live `who_am_i` response lists it for the chosen image entry point and it meets the request. Otherwise, prefer the entry point's compatible live `defaultModel`, then consider another compatible live model. Honor an explicitly requested model, including a request for the account's live default. If that choice cannot fulfill the request, explain the limitation and wait for the user to choose how to proceed. + +## Workflow + +1. Use `text_to_image` for a new image. Use `image_to_image` when source media controls identity, product structure, composition, editable content, or style. An attachment alone does not determine the mode. +2. Ask only for missing information that materially changes the result: subject, destination and aspect ratio, required copy, reference roles, protected facts, or output count. +3. Create or reuse the UUIDv7 `taskTraceId` for this objective, follow [capability discovery](../kling-ai/references/capability-discovery.md), and select a compatible tool/model pair from this account's `who_am_i` response. Apply [model parameters](../kling-ai/references/model-parameters.md) before constructing arguments or reference bindings. +4. Upload local images when needed and bind the complete returned URL to the selected model's input slot, such as `image_1` when required. Use the exact `inputType` declared by the tool schema, including uppercase `URL` when declared. Reuse valid upload references when resuming. Never silently degrade to text-to-image after an upload failure. +5. Follow [prompt construction](references/prompt-construction.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Check that the prompt and actual reference roles agree. +6. Show the final mode, model, prompt summary, resolution, aspect ratio, output count, and reference roles. Obtain explicit approval under the core Skill's billing rule; honor an existing explicit authorization for the final settings. +7. After approval, check the actual request against the [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required arguments, and media slots. Immediately before calling `text_to_image` or `image_to_image`, call `query_membership_and_credits` on the same connection. If the balance is unavailable or insufficient, pause even if the upload succeeded. Otherwise submit once and follow the core Skill's result rules. + +## Mode rules + +- For Kling Image 4.0 (可灵图片 4.0), check the selected tool's live support for the requested resolution and generation mode together. The model supports native 8K and up to 10 images in Series Mode, subject to the connected account's available settings. Use the exact live resolution value when requested. +- Element support follows the selected model's declared resource types and binding argument, not the entry point name. +- Image-to-image may use one or more images with explicit roles. State the purpose of every image when multiple references are present. +- For a coherent image series, choose a live model that explicitly supports series generation and the requested count. Set the model's declared count field and enable its series control when declared. Multiple output images alone do not establish series support. If no eligible model supports the requested settings together, explain the limitation before submission. +- Before using an Element subject, follow the core asset workflow, call `element_get`, and choose a model that explicitly supports the resource type and binding argument. Check individual and combined reference caps, and bind the exact ID with the model's declared prompt and structured syntax. +- For a variant, lock every fact that the user did not ask to change. Change one major dimension per confirmed generation. +- A status request uses only `query_tasks`; it does not create an image. +- If image-to-image returns a resource error, follow [asset troubleshooting](../kling-ai/references/troubleshooting.md#upload-or-asset-reference-fails). Use a task number for recovery only when it belongs to this image-to-image submission. + +## Quality defaults + +- Prefer live-supported `2k` for normal delivery, `4k` for commercial work, advertising, fine materials, or crop-heavy post-production, and `1k` only for drafts, speed, or credit savings. Never lower a higher live default. +- Infer ratio from destination: `1:1` for square social or product media, `4:5` for portrait feeds, `9:16` for stories or vertical covers, and `16:9` for banners or thumbnails. +- Generate one image unless the user requests more. +- Unless the user explicitly requests text inside the generated image, prefer a clean image with intentional copy-safe space. +- Treat brand names, logos, faces, product structure, and user-provided copy as protected facts. Never invent performance, price, certification, ingredients, awards, effects, or statistics. + +Before submission, internally check focal subject, visual hierarchy, safe area, lighting, reference roles, and conflicting instructions. Claim visual QA only when the result was actually inspected. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/prompt-construction.md b/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/prompt-construction.md new file mode 100644 index 000000000..039002f49 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/prompt-construction.md @@ -0,0 +1,43 @@ +# Image prompt construction + +## Decide whether to revise + +- Honor requests to use a prompt verbatim. Otherwise, review the supplied prompt for the subject, protected facts, setting, composition, lighting, color, style, and constraints that affect the intended image. Leave unspecified creative details to the model when they do not affect the user's goal. +- If the prompt is clear, consistent, and sufficient for the task, return or submit it verbatim. Apply the same check to a general request to optimize it. +- Resolve material gaps, ambiguities, or conflicts from the request and reference media first. If a key detail is still unclear, ask before proceeding. When the user clarifies one phrase, change only that phrase. +- Change only the wording needed to satisfy the request or close the gap. If one extra sentence is enough, append it and preserve the rest verbatim. For generation, change reference syntax only as required by the selected model. If that conflicts with a request for verbatim use, clarify before submitting. + +## Recommended order + +Use the relevant items when writing a new prompt or adding missing information. + +1. Destination and medium: product photograph, editorial portrait, poster, thumbnail, or marketing still. +2. Subject and protected facts: identity, product structure, exact colors, logo, or copy. +3. Action or visual concept. +4. Environment, time, weather, and mood. +5. Composition: aspect ratio, framing, camera height, focal hierarchy, negative space, and safe areas. +6. Lighting and color. +7. Materials, textures, surface detail, and degree of realism. +8. Constraints: subject count, protected facts, and requested exclusions. + +Translate abstract requests such as "premium," "cinematic," or "high quality" into visible lighting, depth of field, material, color, and composition decisions instead of stacking adjectives. + +## Multiple references + +Assign roles before writing the creative prompt. Identity, product structure, composition, style, and official logo references are not interchangeable. Transfer only the visual traits the user selected from a style reference; do not transfer identity or composition unintentionally. + +## Coherent image series + +Describe what stays consistent across the series, such as the subject, outfit, or visual style. If the user specifies a sequence, preserve its order and match the scene count to the requested output count. + +## Exact text + +- Preserve user-provided copy verbatim. +- When the user agrees to add text later, prepare a base image with intentional space for the copy. +- For generated text, include the exact copy once with any specified placement, hierarchy, or language. Leave unspecified typography, color, and margins to the model. When adding one title, preserve existing labels. Restrict other text only when the user asks for that restriction. Check spelling and layout in the rendered image before judging accuracy. + +## Controlled variants + +Keep protected facts identical and change only one dimension at a time: concept, camera distance, composition, mood, color, or expression and action. Do not replace a clear creative decision with a batch of near-duplicates. + +Avoid conflicting camera instructions, long repetitive negative lists, and unverified product or brand claims. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/scene-patterns.md b/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/scene-patterns.md new file mode 100644 index 000000000..cf0af2799 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-image/references/scene-patterns.md @@ -0,0 +1,28 @@ +# Image scene patterns + +Choose one primary pattern that fits the destination. User-provided facts and brand assets take precedence. + +## Product and commerce + +- Studio catalog: accurate structure, neutral or brand-color backdrop, controlled soft light, and a grounded shadow without unrelated props. +- Lifestyle: a credible environment and use case with plausible hands, scale, and physical interaction. +- Material close-up: tight framing around texture, mechanics, or surface detail while preserving enough context to identify the product. +- Hero banner: place the product near one side's focal area and preserve negative space for deterministic typography. +- Concept visual: suspension, liquid, miniature scenes, or CGI-like materials are allowed, but the real product structure and label must remain accurate. + +## Advertising and social + +- Static ad: one hook, one subject, one piece of visual evidence, and a clear copy-safe area. +- UGC still: a credible phone-camera angle, natural environment, and realistic handling without fabricated testimonials. +- Carousel: establish consistent color, lens, light, margins, and product scale, then give each frame one distinct communication task. +- Campaign key visual: a memorable silhouette, a deliberate color mechanism, one dominant metaphor, and a simplified background. + +## People, covers, and posters + +- Portrait: define framing, expression, gaze, wardrobe, background, key/fill/rim light, and natural facial structure. +- Identity reference: lock bone structure, skin tone, hairline, apparent age, and distinguishing traits. +- Vertical cover: keep the key action in the upper focal area and reserve lower interface-safe space. +- Landscape thumbnail: one dominant face or object, strong subject separation, little clutter, and readability at small size. +- Poster: one visual proposition, deliberate hierarchy, clean copy space, and controlled color. + +When the user asks for creative directions, offer three materially different options - product fact, human context, and visual metaphor - then generate only after the user selects one. Do not submit three billable tasks automatically. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-video/SKILL.md b/third_party/kling-ai-cn/skills/kling-ai-generate-video/SKILL.md new file mode 100644 index 000000000..f85b9c86c --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-video/SKILL.md @@ -0,0 +1,44 @@ +--- +name: kling-ai-generate-video +description: Write Kling AI and 可灵 video prompts or storyboards, prepare final settings or resolve a missing reference, and submit approved video generation in Cursor. Covers Kling 4.0 (V4) and Kling 4.0 Flash (V4 Flash), text, image, omni reference, keyframes, HDR video output (高动态范围视频), audio, and motion control. +--- + +# Kling AI video generation + +Deliver the user's current step under the [core Kling Skill](../kling-ai/SKILL.md). + +- **Prompt or storyboard only.** Use [motion and shots](references/motion-and-shots.md) to decide whether the supplied prompt needs changes or to plan new material. Return the requested creative text and finish without MCP calls, submission settings, or offers to generate. +- **Missing required asset.** Ask for the asset and explain its role, such as using a product image as the first frame. Stop before discovery or upload and defer other settings questions. +- **Final settings for approval.** Run generation preparation, present the proposed settings, and wait. +- **Authorized generation.** Honor existing approval for the same unsubmitted intent and unchanged settings. +- **Existing task.** Query the known task number once for an explicit status request. +- **Resume after a credit pause.** Follow [credit recovery](../kling-ai/references/tool-workflows.md#resuming-after-a-credit-pause). Keep the original model, prompt, output settings, and references. For image-to-video, verify the original first-frame slot and reference are still usable. + +Read [scene patterns](references/scene-patterns.md) for product, advertising, social, or cinematic work. For Elements, the motion library, or local media, also read the core [asset workflows](../kling-ai/references/asset-workflows.md). + +## Workflow + +1. Capture the requested model or family, duration, ratio, resolution, HDR intent, count, sound, shot intent, and reference roles. Clarify only details that materially change the result. Create or reuse the objective's UUIDv7 `taskTraceId`. +2. Use Cursor's current MCP tool list and `who_am_i` to compare eligible pairs following [capability discovery](../kling-ai/references/capability-discovery.md) and [video routing](references/model-routing.md). Check all requirements against the same live pair. A first-frame requirement needs a first-frame input. Required silence needs a declared sound-off setting that satisfies the request or an explicit silent-output guarantee. If no pair fits, report the unmet requirement and ask before changing any requested setting. +3. Read the selected tool's complete live `inputSchema` and the pair's [model parameters](../kling-ai/references/model-parameters.md) before uploading local media or building the request. Stop if a required upload fails. +4. Follow [motion and shots](references/motion-and-shots.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Bind every supported explicit setting to its own argument or applicable fixed model value. Verify the serialized request against the brief and [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required prompt, and first-frame slot. Check explicit resolution and [HDR output settings](../kling-ai/references/model-parameters.md#hdr-video-output) against the selected pair's live enums and conditions. +5. Show the final tool/model, prompt summary, output settings (including HDR mode when relevant), shot structure, reference roles, and required billing disclosures. After approval, follow the [submission workflow](../kling-ai/references/tool-workflows.md#generation) for the credit check and single submission, then follow the core Skill's result rules. + +## Mode rules + +- Element use requires explicit support for its resource type and binding argument in the selected model; do not infer it from the entry point name. +- Image-to-video and omni reference distinguish first frame, tail frame, keyframes, identity or product reference, style, video, and audio. Pass only roles declared by the selected model and satisfy all conditional combination limits. Pure-text omni reference requires a model that permits no media input. +- Check audio inputs, generated sound, and source-audio retention separately using the selected model's live fields. Apply its sound dependencies and shot controls as described in [model parameters](../kling-ai/references/model-parameters.md). Report the settings actually sent and claim audio or video quality only after inspecting the result. +- Motion control requires a subject image. Choose exactly one motion source - a motion-library ID or a source video - as directed by the live tool. Use the core asset workflow to resolve library IDs and validate motion direction and duration. +- A multi-shot plan is one confirmed video task. Do not submit one generation per shot unless the user explicitly approves separate tasks. +- If image-to-video or omni reference returns a resource error, follow [asset troubleshooting](../kling-ai/references/troubleshooting.md#upload-or-asset-reference-fails) to check first-frame and reference inputs. Only the current video submission's task number can recover its status. + +## Quality defaults + +- Prefer `1080p` for normal delivery and supported `4k` for commercial, large-screen, or post-production work. Use `720p` for drafts, speed, credit savings, or model limitations. Never lower a higher live default. +- Use about 5 seconds for one action or shot, about 10 seconds for dialogue, a complete product action, or two connected beats, and longer only when supported and narratively necessary. +- Honor explicit duration, ratio, resolution, and count before applying defaults. Pass an explicitly requested ratio when supported, including with a first frame. If unspecified, infer it from the destination or preserve the first-frame composition when allowed. +- Use one primary camera movement in a five-second shot. Use multiple shots only when location, time, scale, or information state changes. +- Do not add unrequested narration, readable text, extra characters, product claims, prices, endorsements, or certifications. + +Before submission, internally check whether the action fits the duration, camera instructions conflict, first and tail frame intent is clear, references remain continuous, and multi-shot durations sum correctly. Claim visual QA only when the result was actually inspected. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/model-routing.md b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/model-routing.md new file mode 100644 index 000000000..5edad1b3a --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/model-routing.md @@ -0,0 +1,20 @@ +# Video entry points and model selection + +First follow [capability discovery](../../kling-ai/references/capability-discovery.md). A discovered tool is not proof that any particular model is enabled. Never route by tool count, a static model name, or an earlier account's capabilities. + +Compare the relevant entry points returned by successful discovery, including `omni_ref_video` (全能参考) when present. Filter out pairs that cannot meet the requested tool, model or family, output settings, sound, or reference roles before ranking. If discovery itself fails, refresh the connection or report the failure. If successful discovery omits an entry point, use the remaining eligible pairs. + +When the user leaves model selection open, prefer a compatible Kling 4.0 pair, with Omni-Ref preferred when eligible pairs are otherwise equivalent. Use Kling 4.0 Flash when the user prioritizes speed or credit savings and its live capabilities fit. Name the actual selected model in the recommendation. If no compatible Kling 4.0 pair fits, consider a compatible live default only when the user permits other models. If the requested model or family has no eligible pair, report the limitation and stop. + +## Intent and inputs + +- When the user names Kling 4.0 (V4) or Kling 4.0 Flash (V4 Flash), match the full model name or declared alias in the current account's discovery results. Kling 4.0 supports first, last, and intermediate keyframes for image-to-video and images, videos, audio, and Elements in Omni-Ref. Kling 4.0 Flash uses a single first frame for image-to-video and accepts images, videos, and Elements in Omni-Ref. Check the selected pair's live input slots, duration, and resolution. A separate audio reference requires a declared audio input slot. Generated sound and source audio retention use output settings. +- Text-only video can use `omni_ref_video` when the chosen model permits no media inputs. +- Image, video, Element, and audio references can use `omni_ref_video` only when the selected model supports each requested type and their combination. Do not treat its general tool description as every model's capability list. +- Keyframes belong to whichever discovered tool/model declares the needed frame inputs. Do not hardcode them to one entry point, invent intermediate frames, or substitute identity references for frame control. +- Required HDR output needs a pair that declares `hdr=hdr` at an eligible resolution on the current account. Check Kling 4.0 (`kling-video-v4_0`) in `text_to_video`, `image_to_video`, and `omni_ref_video` as applicable to the requested inputs. +- Motion transfer must use a model that explicitly supports that intent and all required inputs. Existing `motion_control` requests keep the subject image and exactly one motion source. +- Required silence eliminates pairs without a declared sound-off control that satisfies the request or an explicit silent-output guarantee. A text-to-video tool name, an absent audio field, or silence described in a prompt does not establish that capability. +- Do not move an omni model to `image_to_video` or `text_to_video`; tool/model pairs and their parameter sets are inseparable. + +After selection, apply [model parameters](../../kling-ai/references/model-parameters.md), including conditional reference caps, Elements, and audio exclusivity. One multi-shot plan remains one task unless separate tasks were explicitly approved. The core Skill's billing, single-submission, and result rules apply to omni reference too. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/motion-and-shots.md b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/motion-and-shots.md new file mode 100644 index 000000000..1968b12db --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/motion-and-shots.md @@ -0,0 +1,56 @@ +# Motion and shot planning + +## Decide whether to revise + +- Honor requests to use a prompt verbatim. Otherwise, review the supplied prompt for the subject, action, camera movement, timing, continuity, and constraints that affect the intended video. Leave unspecified creative details to the model when they do not affect the user's goal. +- If the prompt is clear, consistent, and sufficient for the task, return or submit it verbatim. Apply the same check to a general request to optimize it. +- Resolve material gaps, ambiguities, or conflicts from the request and reference media first. If a key detail is still unclear, ask before proceeding. +- Change only the wording needed to satisfy the request or close the gap. If the user supplies a sentence that can be added directly, append it and preserve the rest verbatim. When adding an ending, use the requested action, timing, and final position. Leave the intervening movement to the model unless the user specifies it. For generation, change reference syntax only as required by the selected model. If that conflicts with a request for verbatim use, clarify before submitting. + +## Motion-first prompt order + +Use the relevant items when writing a new prompt or adding missing information. Express action and continuity first, then use visible details such as lighting, materials, depth of field, and framing to convey the requested look. + +1. Format and duration intent. +2. Opening frame and subject position. +3. Beginning, development, and completion of the subject action. +4. One primary camera movement and its speed. +5. Environmental movement and physical effects. +6. Lighting, color, lens character, and time-of-day mood. +7. Continuity anchors such as identity, wardrobe, product structure, logo, architecture, and screen direction. +8. Necessary constraints such as no extra subjects, deformation, text, or watermark. + +## Camera choices + +- Locked-off: observation, product detail, or graphic composition. +- Slow push-in: emphasis, intimacy, or detail reveal. +- Pull-back reveal: expanded environment or scale. +- Lateral tracking: follow motion while preserving side relationships. +- Controlled orbit: dimensional display of a product or character. +- Crane rise or drop: establish or resolve spatial scale. +- Handheld follow: urgency or UGC realism; specify the intended stability. +- Whip pan: use only for a deliberate transition and name the final landing subject. + +Do not stack multiple camera-movement verbs into one five-second shot. + +For a continuous hand-object interaction, frame the entire action path so the participating hands and object stay visible through the action and its final handoff or placement. + +## Duration and multiple shots + +- 5 seconds: one action and one camera movement. +- 10 seconds: one action with setup and result, or two simple connected beats. +- 15 seconds or longer: plan a compact multi-beat sequence only when the live model supports it. + +For multiple shots, give each shot a duration, framing, one narrative task, subject action, camera movement, and continuity anchor. Shot durations must sum to the total duration. The full plan is still one generation submission. + +When a continuous hand-object interaction spans a cut, explicitly repeat the same hand grip, object position and support contact at the outgoing shot's end and the incoming shot's start. Use a brief stable beat only when it fits the requested pacing; continue the action without replaying steps or adding a long pause. + +## Reference media + +- A first frame locks the opening composition and motion starts from it. +- A tail frame defines the target ending only when the live model supports it. +- An identity reference locks face, apparent age, hair, wardrobe, proportions, and distinguishing traits. +- A product reference locks dimensions, material, label, logo placement, and moving parts. +- A motion-source video should preferably contain one shot, no occlusion, and one subject. Follow the live tool's exact duration and resolution limits. + +For advertising or explainer video, assign one communication task to each beat: hook, context, evidence, or close. Never invent performance claims, testimonials, statistics, prices, awards, or certifications. diff --git a/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/scene-patterns.md b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/scene-patterns.md new file mode 100644 index 000000000..2f290ed0f --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai-generate-video/references/scene-patterns.md @@ -0,0 +1,28 @@ +# Video scene patterns + +Choose one primary pattern. Combine patterns only when duration and the live model can support a coherent result. + +## Continuous shots and image-to-video + +- A continuous shot defines opening composition, subject action, camera path, environmental motion, and ending beat. Use one primary camera movement at a time. +- In image-to-video, treat the first frame as locked composition rather than a broad style reference. Describe plausible subject, fabric, hair, environmental, and camera motion. +- In a short clip, avoid combining large subject motion, aggressive camera movement, and a major scene transformation. + +## Product and advertising + +- Studio reveal: controlled orbit or push-in, accurate reflections, clean surfaces, and a clear silhouette. +- Feature demonstration: one real function or action per shot, with credible mechanics and hand interaction. +- Lifestyle: show usage context through action without unsupported claims. +- Unboxing: establish sealed product, opening, reveal, and detail in sequence; use multiple shots only when requested. +- Commercial: organize a hook, product evidence, and hero close-up. Prefer deterministic post-production for slogans and end cards. + +## Social, explainer, and narrative + +- UGC: natural eye-level framing, credible phone motion, an everyday environment, and restrained imperfection without fabricated testimonials. +- Explainer: express one idea per visual beat and avoid long readable paragraphs inside generated imagery. +- Multi-shot: use only when location, time, scale, or information state changes. Preserve identity, product structure, light direction, color, and screen direction. +- `9:16` vertical short: reveal the hook quickly, keep the key subject in the upper focal area, and preserve lower interface-safe space. +- `1:1` or portrait feed: use medium framing, a clean silhouette, and restrained lateral motion. +- `16:9` landscape: emphasize spatial orientation, entrances or reveals, and deliberate negative space. + +When the user asks for ideas, offer three directions - demonstration, emotion, and spectacle - and wait for a choice. Discussing three directions does not approve three generation tasks. diff --git a/third_party/kling-ai-cn/skills/kling-ai/SKILL.md b/third_party/kling-ai-cn/skills/kling-ai/SKILL.md new file mode 100644 index 000000000..80a5f0e06 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/SKILL.md @@ -0,0 +1,72 @@ +--- +name: kling-ai +description: Handle Kling AI and 可灵 requests in Cursor, from writing prompts and storyboards to preparing and submitting approved image or video generation. Manage Elements, motion library, uploads, credits, existing tasks, and account switching through the configured MCP. +license: MIT +--- + +# Kling AI for Cursor + +Use only the remote China MCP configured by this plugin: `https://klingai.com/mcp/plugin`. `mcp.json` is the connection source of truth. Do not switch regions, register a second Kling MCP, or start or depend on a local MCP server. + +## Request routing + +- Identify the current deliverable first. Prompt or storyboard work ends with the requested text and needs no MCP call. If a required generation asset is missing, ask for it, explain its role, and stop before discovery or upload. If the user asks for final settings, discover compatible live capabilities, present the settings, and wait for approval. +- For image prompts, creation, or editing, follow [kling-ai-generate-image](../kling-ai-generate-image/SKILL.md). +- For video prompts, storyboards, generation, model selection, or motion transfer, follow [kling-ai-generate-video](../kling-ai-generate-video/SKILL.md). Include `omni_ref_video` (全能参考) in generation discovery when available, including for text-only video. +- Keep uploads, Elements, motion-library browsing, account operations, credit checks, and task status in this Skill. It also supplies the shared connection, billing, submission, and result rules for both generation Skills. +- Motion library: browse with `motion_library_list`. Resolve the selected motion, then follow the video Skill for `motion_control` with a subject image and exactly one motion source. +- Subject library / Elements: use `element_list`, `element_get`, `element_create`, `element_update`, or `element_delete` for the requested operation. Resolve real IDs before reuse. +- Account and credits: use `query_membership_and_credits`; model capabilities come from `who_am_i`. +- Existing tasks: use `query_tasks` with a known `generationId`. A status or library request never creates a generation. +- If a user reports a missing video, follow [result troubleshooting](references/troubleshooting.md#task-is-still-running-or-the-result-app-does-not-render) for the original submission. +- To continue after topping up, follow [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause). Check the original submission's task number if it exists. If the user only reports a top-up, refresh the balance without submitting. +- Sign-out or account switching: act only on an explicit user request, stay on the China endpoint, and complete native Cursor OAuth before further Kling calls. + +Call only tools present in the live tool list. An attachment alone does not determine its role; clarify only when first frame, tail frame, identity/product reference, editable source, motion source, or style reference would materially change the request. + +Read [asset workflows](references/asset-workflows.md) for Elements, the motion library, or uploads. Before generation, follow [capability discovery](references/capability-discovery.md), then [model parameters](references/model-parameters.md), [tool workflows](references/tool-workflows.md), and the [MCP contract](references/mcp-contract.md). Use [prompt examples](references/prompt-examples.md) for creative direction and [troubleshooting](references/troubleshooting.md) after a failure. + +## Connection and task identity + +- Use OAuth through Cursor's native MCP connection flow (Customize → Plugins, then Connect on `kling-ai`). Never request an API key, token, cookie, authorization header, or credential file. Never log private account fields, upload tickets, or signed URLs. +- Let Cursor manage OAuth discovery, client registration, and credentials through its native MCP flow. This plugin does not configure a custom OAuth client name; do not invent registration overrides or block authorization because the host cannot set one. If the real OAuth flow fails, report the sanitized error and follow [troubleshooting](references/troubleshooting.md). +- Create one UUIDv7 `taskTraceId` for each unrelated new objective. Reuse it across discovery, upload, generation, and querying for that objective wherever the live tool accepts it. +- Preserve exact returned IDs. Present `generationId` as the task number; expose `taskTraceId` only when troubleshooting requires it. + +## Billing and single submission + +- Image, video, and motion generation consume credits. Call `who_am_i` during preparation and select only models returned in the current account's `availableModels` for the chosen tool, with their declared arguments, inputs, and combination limits. Follow capability discovery for cross-tool selection and refresh stale definitions before proceeding. Do not infer model access from a tool's existence, membership tier, or static examples. +- Show the final workflow, model, prompt summary, duration/resolution, aspect ratio, output count, and reference roles. Honor explicit authorization already given for the same unsubmitted intent and unchanged final settings. Otherwise, obtain confirmation before submission. An upload, library operation, or credit check is not generation approval. +- Include any billing disclosure required by the live model/tool in those final settings. For omni reference that declares per-second billing with input video duration included, explain both facts before submission; output duration alone is not the total billed duration. Do not invent a rate or total credit estimate. +- Immediately before each generation call, check the balance with `query_membership_and_credits` on the same connection. Pause when the current balance is unavailable, non-positive, or clearly insufficient, following [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause). +- Submit at most once per approved intent. A rejected call also counts as an attempt. A new attempt requires fresh explicit authorization after any failure, timeout, ambiguous response, or rendering problem. +- Do not save an Element automatically during ordinary generation. Element writes and deletion must follow the user's explicit request as described in [asset workflows](references/asset-workflows.md). + +## Generation and results + +1. Resolve reference roles, Elements, and motion sources; prepare local media before submission. Use the returned provider references exactly as the selected live schema requires. +2. Follow the [submission workflow](references/tool-workflows.md#generation) to confirm the final settings, check credits, and call the chosen tool once. A multi-shot plan remains one task unless the user approves separate tasks. +3. Use `query_tasks` for follow-up only with a known `generationId`. If a submission yields no known ID, report the returned error if present and any unknown creation or billing state, then stop. `query_tasks` requires the ID and cannot search account history or look up `taskTraceId`. A balance check or missing history entry cannot establish the outcome. A status response that omits the ID does not invalidate the known task number. +4. If Cursor renders the generation MCP App, let that App own task refresh. Do not poll the same task from the model or add duplicate media, thumbnails, or download links. +5. If no App renders, query the same `generationId` at the provider-permitted interval until terminal, cancelled, rate-limited, or the turn cannot continue. If a status lookup returns a resource error and explicitly asks to check the same ID later, allow one further lookup at that interval during ongoing polling. Stop on a repeated error or other query failure. Use the tool's text fallback and include at most one primary link per usable requested work. Do not add Markdown image/video embeds or claim an unmounted App was displayed. +6. For an explicit status request, query once and report the current state; do not start a long polling loop. +7. Report full completion only after terminal success with usable primary media of the requested type and count. Count only successful works when work-level status is present, and require actual video media for video results. If some requested works are missing, deliver the usable results and report the actual count, such as "Generated 2 of 3 images." If none are usable, report the discrepancy and keep the task number. +8. Use the returned status, known task number, any result link allowed above, and effective submitted settings. If a lookup fails or polling stops early, report the most recently confirmed state, such as submitted or processing, and say that the current state could not be refreshed. Report the state as unconfirmed only if no state was ever confirmed. Report an actual charge only when the tool returns it, such as `creditsConsumed`. Submission count and a local attempt budget are separate from credits. + +## Quality defaults + +Apply only when the user has not specified another choice and the live model supports it: + +- Prefer full-quality models. Use Turbo, fast, or low-cost modes when the user prioritizes drafts, speed, or credit savings. +- Images: prefer `2k` for normal delivery and `4k` for commercial or crop-heavy work; use `1k` for drafts or speed. Never lower a higher live default. +- Videos: prefer `1080p` for normal delivery and supported `4k` for commercial or post-production work; use `720p` for drafts, cost, speed, or model limitations. +- Generate one result unless more are requested. Use about 5 seconds for one action, about 10 seconds for two connected beats, and longer only when supported and needed. Motion-control duration comes from the selected source and live constraints. +- Pass a requested ratio when supported, including with a first frame. If unspecified, infer it from the destination or preserve the first-frame composition for image-to-video when the live schema allows it. + +## Failure behavior + +- Unauthorized: use native Cursor OAuth and continue only after authorization succeeds. +- Unsupported argument: refresh the live definitions, revise only unsupported settings, and obtain confirmation before a new generation. +- Insufficient credits: follow [credit recovery](references/tool-workflows.md#resuming-after-a-credit-pause) and report whether the task was paused before submission, rejected, or remains unconfirmed. +- Provider failure: report the sanitized provider message and preserve the task number. Follow [troubleshooting](references/troubleshooting.md) for resource and service errors. +- Expired media URL: query the original `generationId` for current outputs before reuse. A failed refresh is not permission to create a replacement task. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/asset-workflows.md b/third_party/kling-ai-cn/skills/kling-ai/references/asset-workflows.md new file mode 100644 index 000000000..39b10113a --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/asset-workflows.md @@ -0,0 +1,38 @@ +# Elements, motion library, and media uploads + +Use this reference for library operations and media preparation. The live `tools/list` and `who_am_i` responses define whether a tool is available, its arguments, input names, and resource limits. + +## Elements + +- To browse reusable subjects, call `element_list` and show the returned `id` and `name`. The list may not include the resource type; call `element_get(id)` before reuse, update, or generation. If a name is ambiguous, show candidates and ask the user to choose. Do not guess an ID. +- To create an Element, require an explicit request to save a reusable subject. Collect its name, description, tags, and resources, then validate the complete resource object against the [MCP contract](mcp-contract.md) before calling `element_create`. Do not create an Element automatically for an ordinary reference-image generation. +- To update an Element, call `element_get` first and merge the requested changes into the complete `name`, `description`, `resource`, and `tags`. Preserve fields the user did not change, including the existing image `resource.cover`. Treat `secondary[]` as a full replacement: preserve unmodified secondary images and keep the provider's 1–3 image constraint when declared. +- Do not silently convert an image Element into a video Element or vice versa. If replacing a cover requires delete-and-recreate, explain that the ID will change and obtain explicit authorization before deleting. +- Call `element_delete` only after the user explicitly identifies the Element to delete. A read-only library operation does not require a credit check or generation submission. + +## Using Elements in generation + +1. With a known ID, call `element_get`. With only a name, call `element_list`, resolve the choice, then call `element_get`. +2. Confirm that the current account can access the Element and inspect `resource` to determine whether it is an image or video resource. +3. Use an Element only when the selected model declares its binding argument and the actual resource type. Check `elementSupport` and conditional reference caps in [model parameters](model-parameters.md), including for `omni_ref_video`. Do not infer support or prohibition from the tool name. A video Element is not an image substitute. +4. Bind the exact Element ID in the prompt and structured argument using the selected model's declared syntax and serialization. For models declaring `<<>>` and an `elements` JSON-array string, use that format, such as `[{"id":"ELEMENT_ID","bindName":"subject"}]`; other models may declare additional type fields or different bindings. Do not copy an older model's shape or omit required bindings. +5. An Element does not replace required image inputs. Supply `image_1`, `first_image`, or another exact live input when the selected model requires it. For motion control, the subject `image` remains required. +6. After resolving the Element, follow the [image Skill](../../kling-ai-generate-image/SKILL.md) or [video Skill](../../kling-ai-generate-video/SKILL.md) for the requested output. Both use the core Skill's confirmation, credit, single-submission, and status rules. + +## Motion library and motion control + +- To browse saved motions, call `motion_library_list` and show the real name, `id`, duration, and audio availability. Use a host-rendered preview when available; otherwise include its returned preview link without embedding media. Durations returned in milliseconds may be displayed in seconds by dividing by 1000. An empty list is a valid result; do not invent motions. +- Selecting a motion by name requires an unambiguous match. If names collide or the intended motion is unclear, ask the user to choose. Browsing the library never calls `motion_control`. +- The current tool surface provides no motion create, update, or delete operation. Do not use `element_*` tools to manage motions. +- For motion control, pass the subject image as the live `image` input. Use exactly one motion source: the library ID as the `motionId` argument or a source video as the live `video` input. Never pass a preview URL as `motionId`, and do not pass both sources. +- Call `who_am_i` for the selected `motion_control` model and use only its declared `motionDirection`, `resolution`, and `keepOriginalSound` names and values. When `motionDirection=image_direction`, the motion source must satisfy the live 3–10 second constraint; do not pass the library duration as an undeclared `duration` argument. +- Continue with the [video Skill](../../kling-ai-generate-video/SKILL.md). Credit checks, confirmation, one submission, and querying by `generationId` still apply. + +## Local media uploads + +- Prefer media already attached in Cursor and accepted by the selected model. If a public URL is accepted by the live tool, use it directly; do not download it unnecessarily. A historical Kling result must be refreshed by `generationId` immediately before reuse, never reused from an old URL in conversation history. +- If no usable attachment reference exists and the live MCP exposes `file_upload`, request an upload ticket with the real filename, MIME type, byte size, and the same `taskTraceId`. Never send a local path as a remote URL. +- Complete the provider's second upload step with the returned ticket and upload URL using multipart form data containing `ticket` and the binary `file`. A ticket response is not upload completion; use the media URL only after the upload service confirms success. +- Bind the full media URL from the successful upload response directly to the input slot. Use `data.url` or the equivalent field declared by the live response. Preserve the path, query string, parameter order, case, and escaping, including signed parameters such as `x-kcdn-pid`, `pkey`, and `cacheKey`. Do not use the upload endpoint, a chat preview, or a truncated link as input. If the request can be inspected before submission, compare each uploaded `inputs[].url` with the source field exactly. If the complete URL is unavailable, pause the dependent operation and follow [asset troubleshooting](troubleshooting.md#upload-or-asset-reference-fails). +- Tickets are single-use and expire at the provider-declared `expireAt`. Never log or display tickets, signed upload URLs, credentials, cookies, or authorization headers. +- If the host cannot read the file or the live MCP lacks upload support, explain the limitation and ask the user to attach usable media. Do not submit a generation or write an Element that depends on unavailable media. Do not loop on failed ticket requests or uploads. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/capability-discovery.md b/third_party/kling-ai-cn/skills/kling-ai/references/capability-discovery.md new file mode 100644 index 000000000..7e9ae7fe5 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/capability-discovery.md @@ -0,0 +1,23 @@ +# Account-scoped capability discovery + +Read this before choosing a model for generation or a model recommendation. Status, credit, and library queries do not need model discovery. + +## Discover candidates + +1. Read the current connection's complete `tools/list`, following all pagination. Only discovered tools are candidates. A failed discovery is not an empty list and must not trigger a fallback to old capabilities. +2. If the live `who_am_i` schema declares `tools`, pass a nonempty set of relevant generation tools; otherwise read the full response. Do not invent model or field filters. For V4 discovery, include all discovered generation tools that support the requested output type and intent. +3. Treat `who_am_i.availableModels` and each tool's `models` as the authority for this account. Match requested canonical names or declared aliases within that set. A tool's existence, examples, membership tier, or `defaultModel` alone does not establish model access; the default must also belong to its model set. +4. If a requested model is missing from the filtered response, check the remaining discovered generation tools before concluding it was not returned. A model available only for another output type is not a candidate for this request. Explain that mismatch without claiming an account permission failure or changing the requested media type. +5. Fix one tool/model pair, then read [model parameters](model-parameters.md). Never move a model or its arguments to a different tool. + +## Video candidates + +For text-driven video, query the discovered `text_to_video` and `omni_ref_video` models together. For image-driven video, compare `image_to_video` and `omni_ref_video`. Include omni for text-only requests and check its live media requirements. Include other discovered tools that could satisfy the request, with `motion_control` for motion transfer. Follow [video model routing](../../kling-ai-generate-video/references/model-routing.md) for eligibility and ranking. + +## Selection and visibility + +- A user-specified model takes precedence when an eligible pair is returned. Match model names and families, including V4 and V4 Flash, using live canonical names and declared aliases. Identify the selected model by its returned name and recommend only models returned by the current account. +- Required references, duration, sound, speed, and budget take precedence over version preferences. Do not silently drop requirements, increase output count, or lower specifications to make a model fit. +- Reuse one successful discovery response during the same generation preparation. Refresh after reconnecting, switching account/endpoint, changed entitlements, a capability notification, or a rejected model/argument; query additional tools when the candidate set changes. +- A filtered response says nothing about unqueried tools. If full discovery still does not return a requested model, report only that the current connection did not return it. If the user says it is enabled, follow [capability troubleshooting](troubleshooting.md#model-capability-mismatch); do not guess a model identifier or probe access by generating. +- Model capability comes from `who_am_i`; request encoding comes from the tool's `inputSchema`. Tool examples cannot expand model capabilities. Refresh inconsistent or incomplete definitions; if no valid request satisfies both, stop before submission. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/mcp-contract.md b/third_party/kling-ai-cn/skills/kling-ai/references/mcp-contract.md new file mode 100644 index 000000000..4064a1ce1 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/mcp-contract.md @@ -0,0 +1,45 @@ +# Kling MCP input and output contract + +This reference records only stable tool-level constraints. Always take models, defaults, enums, required fields, item limits, and media inputs from the current `tools/list` and `who_am_i` response. + +## Tool groups + +- Discovery and account: `who_am_i`, `query_membership_and_credits`, `logout` +- Generation and status: `text_to_image`, `image_to_image`, `text_to_video`, `image_to_video`, `omni_ref_video`, `motion_control`, `query_tasks` +- Media and reuse: `file_upload`, `motion_library_list`, `element_create`, `element_list`, `element_get`, `element_update`, `element_delete` + +Call only tools that exist in the current tool list. + +## Generation request + +- Generation tools normally use `model`, `arguments[]`, `inputs[]`, `rationale`, and `taskTraceId`; the live tool `inputSchema` defines the actual outer request and encoding. Omit unused inputs when allowed, but never omit required media. +- Always pass the canonical model ID from `who_am_i` for the selected tool in the top-level `model` field, even if an older tool schema omits it from `required`. If the user did not name a model, select a compatible one and pass its ID. Reject missing, null, empty, or whitespace-only values. +- Each `arguments[]` item is `{name, value}`. Include every required argument once and use strings for values when the schema requires them. Include a meaningful `prompt` when required. Use an empty prompt only when the current mode permits it and it fits the user's intent. Use the selected model's exact resolution field, enum, and conditions. +- Each `inputs[]` item is `{name, inputType, url}`. Bind every required media input to the selected model's exact slot and use the tool schema's literal `inputType`, including uppercase `URL` when declared. Pass uploaded references according to the [media upload workflow](asset-workflows.md#local-media-uploads). +- `rationale` explains the user's objective and parameter choices. It does not replace the generation prompt. +- `taskTraceId` is a UUIDv7. Reuse it for one objective and create a fresh value for an unrelated objective. It supports tracing and does not make a repeated generation call idempotent. + +Follow [capability discovery](capability-discovery.md) before submission and reuse its successful response for the same preparation unless invalidated. Model capabilities come from `who_am_i`, while request structure comes from the tool `inputSchema`; general descriptions do not expand model capabilities. Refresh inconsistent definitions and stop if no valid request satisfies both. Apply the selected model's [parameter and combination constraints](model-parameters.md). + +## Stable gates + +- Element support is model-specific, not determined by an entry point's name. Do not pass an Element or prompt binding unless the selected model explicitly declares the binding argument and support for that resource type. +- Call `element_get` before using an Element. Check `elementSupport`, required media, individual and combined caps, and reference-video conditions for the selected model, including omni reference. +- `motion_control` requires a subject image. Follow the tool description when choosing exactly one motion source: a library `motionId` or a source video. +- When a model requires media from `file_upload`, do not pass a local path or arbitrary external URL directly. +- Never pass an undeclared argument, input name, or enum value. + +## Elements + +- An image Element uses a cover and the provider-allowed number of secondary images. Do not combine it with a video resource. +- A video Element uses a video resource and may include voice only when the tool allows it. Do not combine it with cover or secondary images. +- Use only tags declared by the tool description. +- Call `element_get` before `element_update`, then update the complete object so omitted fields are not cleared accidentally. +- Obtain explicit user confirmation before deletion or a delete-and-recreate workflow. + +## Known results + +- A generation submission normally returns `generationId` and `status`, and may return `creditsConsumed`. +- `query_tasks` normally returns task status, timestamps, and `works[]`. A work may include primary media, unwatermarked media, and cover URLs. Determine terminal state and media semantics from the live response. +- Signed URLs may expire. Never log them or treat them as permanent asset identifiers. +- For a tool without a public output schema, use the real response as returned. Do not invent fields or success states. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/model-parameters.md b/third_party/kling-ai-cn/skills/kling-ai/references/model-parameters.md new file mode 100644 index 000000000..e456a307f --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/model-parameters.md @@ -0,0 +1,63 @@ +# Parameters for the selected model + +Read after [capability discovery](capability-discovery.md). Use the chosen tool/model pair's complete live `arguments`, `inputs`, defaults, enums, and conditional constraints. These rules do not supply a static model or specification table. + +## Request and output settings + +- Treat the model's arguments and inputs as field allowlists. Satisfy required fields and dependencies; omit undeclared fields and irrelevant optional fields. When there are no inputs, omit `inputs` unless the tool schema requires otherwise. +- Pass each argument name once and encode numbers, booleans, and JSON arrays as required by the tool schema. Use only exact enum values. Rebuild the request when changing models; do not carry over the previous model's fields. +- Honor explicit user settings first, then apply the Skill's quality preferences only within legal choices and compatible defaults. Never use prompt text to simulate an unsupported resolution, input, or sound capability. Unsupported required settings need resolution before submission. +- Serialize explicit supported settings as actual arguments; optional does not mean irrelevant when the user requested a value. In particular, a duration in the prompt does not override the duration default, and a first frame does not cancel an explicitly requested aspect ratio. An equivalent immutable model setting needs no invented field. +- Follow model-specific aspect-ratio rules first. If the model says to omit the optional ratio when a first frame is supplied and the user has not requested a ratio, omit it to preserve that frame. Otherwise, when a ratio field exists, set a legal value from the requested destination or compatible live default. An automatic ratio may depend on image/video inputs; for text-only requests that disallow automatic ratio, choose a legal explicit ratio. If no ratio field exists, omit it rather than inventing an alternative name. +- Duration must accommodate action, dialogue, pauses, and the ending within live limits. Do not delete dialogue, speed it up, or split it into multiple paid tasks to hide a conflict. +- Content-expanding defaults must respect the user's intent: if declared and supported, explicitly select one result, a single continuous shot, and no generated sound unless the request calls for more. This includes fields such as `imageCount`, `prefer_multi_shots`, `enable_audio`, and `enable_asmr` only when that model declares them. If the model cannot meet the requested output structure or silence, explain the limitation. +- Respect single-value enums. When `prefer_multi_shots` only allows `true`, follow the live schema and disclose the fixed setting. A normal continuous-shot request is prompt intent. For an explicit hard guarantee, require a live capability that guarantees it before submitting. The presence or absence of the field alone establishes neither cuts nor a continuous shot. + +### Binding example + +When the live outer schema uses an array of name/value pairs, a request for a +7-second, 9:16 clip needs separate entries like these, provided the selected model +declares both values: + +```json +{ + "arguments": [ + {"name": "prompt", "value": "The creative description..."}, + {"name": "duration", "value": "7"}, + {"name": "aspect_ratio", "value": "9:16"} + ] +} +``` + +Add the requested resolution, count and sound controls in the same format when +declared. Do not nest those settings inside the prompt item or encode the whole +request as its text. Keep reference inputs in the outer schema's input slots. +Before sending, compare every explicit requirement with the actual serialized +value or supported input; build the result summary from those values afterward. + +## HDR video output + +- Kling 4.0 declares string values `none` (default) and `hdr`. Enable HDR only when the user requests HDR output and the selected tool/model pair advertises it. Use the live default when the user leaves HDR unspecified. +- HDR requires `1080p` or `4k` on the connected account. When resolution is unspecified, apply the video quality defaults among the eligible HDR resolutions. If the user explicitly asks for `720p` HDR or another unavailable combination, explain the limitation and ask which setting to change before submission. +- Put HDR and resolution in separate entries in `arguments`, for example `{"name":"hdr","value":"hdr"}` and `{"name":"resolution","value":"1080p"}`. Show both in the settings for approval. Report the submitted mode and verify the result's actual HDR format only when output metadata is available. + +## References and Elements + +Apply only when using actual/required reference inputs or Elements. Read [asset workflows](asset-workflows.md) for lookup and upload operations. + +- Map each real asset to its declared input slot and prompt reference. Distinguish first/tail frames, identity/product references, style, motion, and source material for editing. Follow the selected model's binding syntax; do not copy syntax from another model. +- For ordered keyframes, preserve frame order and describe motion between successive supplied states. Settle into the final state without overshoot or snapback unless requested. Do not invent intermediate-frame slots, timestamps, or a frame-count formula. A first frame controls the opening, not all subsequent camera movement. +- Validate accepted resource origin, format, size, dimensions, and per-resource/total duration from live constraints. Inspect actual metadata when possible; never claim validation based only on filenames. Do not silently remove required assets after an upload failure or to fit a limit. +- Call `element_get` before reuse and check the actual resource type. The model must declare both the binding argument and support for that Element type. Follow `elementSupport` restrictions on image/video types, individual and total counts, and conditions when reference video is present. An Element does not replace required image inputs; a video Element's cover is not a substitute for the video resource. +- Check `maxItems` and `combinedItemCap` when declared. For `combinedItemCaps[]`, evaluate `whenAnyInputPrefixes` and `whenNoneInputPrefixes` against actual inputs, and satisfy every applicable cap. Count actual items, not the highest numbered slot; count Elements as specified. Library storage capacity is separate from the number of references allowed in one generation. +- Preserve the motion-control requirement for a subject image and exactly one supported motion source. Do not use a preview URL in place of a motion ID. + +## Sound and audio + +Check required sound behavior during [video model selection](../../kling-ai-generate-video/references/model-routing.md). Send only controls declared by the selected model. Omission of an optional field such as `music_prompt` does not guarantee silent output. + +- Distinguish newly generated sound, preserved source-video audio, silence, dialogue, and narration. Map them only to declared controls and values; a tool-level audio description does not establish support for every model. +- If the model makes `enable_audio` and `keepOriginalSound` mutually exclusive, never enable both. Only send either field if declared. Explain incompatible user requirements rather than hiding the conflict in the prompt. +- Audio references use only declared audio slots, formats, duration limits, and reference syntax. Never pass audio through image/video slots or assume that accepting audio guarantees voice cloning or exact speech. +- Preserve user-supplied dialogue verbatim, including speaker, language, tone, and order. Narration does not become on-screen dialogue, and dialogue does not automatically authorize subtitles or slogans. +- Check timing and audio intent against the prompt and actual parameters before submission. Report submitted audio settings when relevant. Claim actual sound or dialogue quality only after inspecting the audio track. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/prompt-examples.md b/third_party/kling-ai-cn/skills/kling-ai/references/prompt-examples.md new file mode 100644 index 000000000..44c953c69 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/prompt-examples.md @@ -0,0 +1,95 @@ +# Prompt and usage examples + +## Suggested prompts + +- Use Kling Image 4.0 to generate a series of three 8K images in one request. Show the same red panda in a vintage spacesuit exiting a space station, drifting past a porthole, and turning to look at the blue Earth. +- Use Kling 4.0 to generate a 20‑second cinematic video at 1080p with HDR output: a mech warrior slams down from height onto the ground, sending out a shockwave that instantly blasts apart rubble and dust, with the camera rapidly pushing in for a powerful impact. +- Use Kling 4.0 Flash to turn my sneaker product photo into a 20-second, 720p video. Start from the photo, slowly orbit the shoe, and end on a close-up of the upper. +- Use Kling AI to browse the motion library and preview saved motions; after I select one, apply it to my subject image with an available motion-control model to generate a video. +- Use Kling AI to save the front and side views of my character as my first reusable Element, named “Xiaobai”, to help keep the character consistent in later creations. + +## 推荐提示词 + +- 使用可灵图片 4.0 一次生成 3 张 8K 连续组图。让同一只身穿复古宇航服的小熊猫依次从空间站出舱、掠过舷窗、转身望向蓝色地球 +- 使用可灵 4.0 生成一段 20 秒、1080p 的 HDR 电影感视频:机甲战士从高空重砸地面,冲击波瞬间震开碎石与尘雾,镜头快速推近,充满力量感 +- 使用可灵 4.0 Flash,把我提供的运动鞋商品图作为首帧,生成一段 20 秒、720p 的视频,镜头缓慢绕过鞋身,最后停在鞋面细节上 +- 使用可灵AI查看动作库,预览已保存的动作;选定后,用可用的动作控制模型将该动作应用到我提供的主体图片生成视频 +- 使用可灵AI将我提供的角色正面图和侧面图保存为第一个可复用主体,命名为“小白”,方便后续创作时保持角色一致 + +## Natural-language requests + +Text-to-video: + +> Use Kling AI to create a 5-second, 16:9 cinematic video: outside a convenience store on a rainy night, a vintage motorcycle slowly pulls to a stop as the camera smoothly pushes in from a wide shot. Keep this turn active after submission until the result appears. + +Image-to-video: + +> Turn my attached image into a 5-second video. Keep the subject's identity, facial features, and clothing consistent; only let the camera slowly orbit from the left to the front. Use 720p. + +Multi-shot VIDEO 3.0: + +> Create a 7-second, four-shot product video: a 1.5-second wide establishing shot, a 2-second push-in on the product, a 2-second side orbit, and a 1.5-second hold on the brand detail. Enable multi-shot mode and use natural transitions between shots. + +Text-to-image: + +> Use Kling AI to create a 16:9 hero image for a poster: a transparent glass teapot in a minimalist white studio with soft side lighting and negative space for a headline on the right. + +Immediate submission with explicit approval: + +> Submit immediately without asking for confirmation again: use Kling AI to create a 5-second, 16:9, 720p single-shot video. Outside a convenience store on a rainy night, a vintage motorcycle slowly pulls to a stop. + +Status check: + +> Check the current status of this Kling generationId once. Do not poll repeatedly. + +Motion-library browsing: + +> List my saved motions with their names, IDs, and durations. Do not generate anything. + +Motion control: + +> Use my attached subject image with the motion named "Walking" from my library. Resolve the motion and show the supported model and final settings before submitting. + +Element creation: + +> Save these reference images as a reusable subject named "Blue sneaker". Show which image will be the cover and use the others as secondary views. + +Element update: + +> Update only the description of "Blue sneaker" to "Blue suede sneaker with white sole". Keep its cover, secondary images, and tags unchanged. + +Element reuse: + +> Use my "Blue sneaker" Element in a product image. Check its resource type and model compatibility first, and tell me if another source image is required. + +## Prompt construction + +Prefer concrete direction in this order: + +1. subject and setting +2. action or transformation +3. camera and shot structure +4. lighting and visual style +5. identity or consistency constraints +6. exclusions only when they prevent a likely failure + +Avoid long lists of repeated negatives. For image-to-video, state what must +remain stable and what is allowed to move. + +## User-facing submission summary + +Use one compact block: + +```text +Ready to submit: image-to-video · VIDEO 3.0 Turbo · 5 seconds · 720p · single shot +Action: keep the subject stable while the camera slowly orbits from the left to the front +Submission will consume Kling AI credits. +Reply "Confirm submission" to create one generation task. +``` + +After acceptance: + +```text +The task was submitted once. Any follow-up will only query this generationId; it will not create another task. +You may end this conversation; the task will continue running on Kling AI. +``` diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/tool-workflows.md b/third_party/kling-ai-cn/skills/kling-ai/references/tool-workflows.md new file mode 100644 index 000000000..1f7ab85d6 --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/tool-workflows.md @@ -0,0 +1,35 @@ +# Remote tool workflows + +## Generation + +1. Use the plugin's single `kling-ai` connection at `https://klingai.com/mcp/plugin` and follow [capability discovery](capability-discovery.md), including all tool-list pages and relevant new entry points. +2. Create or reuse the objective's UUIDv7 `taskTraceId`, reuse the successful `who_am_i` response for this preparation, and apply [model parameters](model-parameters.md) to the selected tool/model pair. Video selection follows [video routing](../../kling-ai-generate-video/references/model-routing.md), including `omni_ref_video` when available. Refresh capability data when invalidated, not just because another reference was loaded. +3. For Elements, motion-library selections, or local media, follow [asset workflows](asset-workflows.md). A library operation does not authorize generation. Do not silently fall back to text-only generation if a required reference is unavailable. +4. Show the final mode, model, prompt summary, resolution, duration when applicable, aspect ratio, output count, and reference roles. Include live-required billing disclosures, including per-second billing and input video duration when applicable. Describe shot controls only as declared by the model, without inferring the actual number of cuts. Obtain explicit approval under the core Skill's billing rule. +5. Validate the request against the [MCP contract](mcp-contract.md), then call `query_membership_and_credits` on the same connection immediately before submission. Pause if the current balance is unavailable, non-positive, explicitly insufficient, or below the live estimate for the exact settings. A positive balance alone cannot establish that an unknown cost is covered. Keep the original settings and follow the recovery steps below. +6. Call the selected generation tool once using its live schema. Preserve the returned `generationId` and confirmed state. Follow the [Cursor result rules](../SKILL.md#generation-and-results) for App refresh or headless polling. + +## Resuming after a credit pause + +1. Keep the intent, tool, canonical model ID, prompt, output settings, input slots and usable source references, `taskTraceId`, submission state, and any known `generationId` in the current conversation. Use the current balance from `query_membership_and_credits`. Report a shortfall only when the service supplies an estimate for the exact settings. +2. Tell the user the confirmed state. If the balance cannot be checked, explain that submission is paused until it can be verified. For insufficient credits, use the official production top-up link returned by the current connection for the account's region. If no such link is returned, direct the user to the official Kling homepage in the plugin manifest to sign in to the same account and top up from its account page. Ask the user to return to this Cursor conversation and say “Continue the previous task” after topping up. +3. If the user only says they topped up, refresh the balance and explain the next step. When they explicitly ask to continue, identify the original task and ask which one only if several match. If that submission has a `generationId`, check that task before any balance or preparation steps, report its state or result, and end the recovery without a new submission. Any source image or video task number is only for looking up the source media. +4. Continue toward submission only if generation had yet to be called or the service explicitly confirmed that no task was created and no credits were charged. If the outcome is ambiguous, stop and report what remains unconfirmed. +5. Keep the original `taskTraceId` and confirm the original model, settings, and references are still usable on the same connection. Reuse valid upload references and refresh expired ones from accessible originals. Ask only for media that cannot be recovered, and obtain approval before changing the model or billable settings. +6. Honor approval already given for an unsubmitted intent with unchanged settings. If a previous call was rejected without creation or charge, an explicit request to continue those confirmed settings provides fresh authorization. Recheck current credits just before the single submission. If the balance still blocks it, keep the task paused. + +## Read-only operations + +- Credits: call `query_membership_and_credits` once. +- Task status: call `query_tasks` once with a known `generationId`; do not start long-running polling for a direct status request. +- Model capabilities: call `who_am_i` without creating a task. +- Motion library: call `motion_library_list`; do not call `motion_control` merely to browse. +- Subject library: use `element_list` and `element_get` to resolve real subjects and resource types. + +## State changes + +- Create or update an Element only as requested, following the complete-resource rules in [asset workflows](asset-workflows.md). +- Delete an Element only when the user explicitly identifies the deletion target. A cover replacement that requires delete-and-recreate needs explicit authorization for the ID change. +- Call `logout` or switch accounts only when explicitly requested. Re-enter native Cursor OAuth through the MCP Connect flow and stop other Kling calls until authorization completes. + +Never retry a generation automatically. If a submission yields no known `generationId`, report the returned error if present and any unknown creation or billing state, then stop. diff --git a/third_party/kling-ai-cn/skills/kling-ai/references/troubleshooting.md b/third_party/kling-ai-cn/skills/kling-ai/references/troubleshooting.md new file mode 100644 index 000000000..63f08803d --- /dev/null +++ b/third_party/kling-ai-cn/skills/kling-ai/references/troubleshooting.md @@ -0,0 +1,69 @@ +# Cursor troubleshooting + +## MCP tools are missing + +Use Cursor's MCP settings to verify that the plugin's `kling-ai` server is enabled and points to `https://klingai.com/mcp/plugin`. After changing plugin files, run `Developer: Reload Window`; if the tool definitions remain stale, start a new Cursor conversation and check its MCP diagnostics. Do not add a duplicate server or use an API key as a workaround. + +## Endpoint migration and authorization + +This release uses the China endpoint `https://klingai.com/mcp/plugin`. When switching from another region, retain any outstanding task numbers and finish their status checks through the original connection. Disconnect the old host-managed OAuth session, update the plugin, then use Cursor's MCP Connect flow to authorize the China account. Never transfer credentials between hosts or assume that regional task history and credits are shared. + +For an authorization failure, use Cursor's MCP Connect flow for `kling-ai`, and complete native OAuth. If sign-out or account switching was explicitly requested, call the live `logout` tool as documented and reauthorize before other Kling calls. Do not paste tokens, construct OAuth URLs manually, or add an `oauth_resource` override. `Developer: Reload Window` reloads plugin files; it does not refresh OAuth credentials. + +OAuth discovery and client registration belong to the host. Do not require a custom client name or try to add one to generation arguments, headers, or the MCP URL. If the server rejects the host's registration, preserve the sanitized error for the service maintainer instead of guessing metadata or requesting credentials in chat. + +## Parameter or resolution validation fails + +- Check the actual request for a missing, null, empty, or whitespace-only top-level `model`. Compare `arguments[]` and `inputs[]` with the selected model's required fields, including `prompt` and media slots. Use the exact slot names, such as `image_1` or `first_image`, declared for that model. +- Refresh live definitions and correct only the rejected fields or missing references. If an explicit resolution such as `1080p` was rejected, compare the submitted value with the refreshed enum and its conditions for the same account, connection, tool, and model. If they match, record the mismatch with the trace ID and sanitized fields for the maintainer. Ask the user to choose if their requested setting is unavailable. +- When diagnosing field changes, compare the model's original tool-call arguments with Cursor's outgoing MCP request and the live schema's `required` list if those are available. Record missing diagnostic data and omit credentials and signed URLs. + +## Upload or asset reference fails + +- Read the live `file_upload` schema and [asset workflow](asset-workflows.md). +- A ticket is only the first step. Complete the multipart upload with `ticket` and binary `file`, then use the confirmed media URL. +- Reuse the objective's `taskTraceId` where accepted. Never send local paths or expired signed URLs as remote media inputs. +- If upload is unavailable or fails, stop before dependent Element writes or generation. Do not silently switch to text-only generation or loop on upload requests. +- If the error concerns a missing resource or invalid signature, verify the complete upload response URL, its source, and the bound slot. Fix the reference and complete the authorized first submission only if the failure was in upload or local validation and generation has yet to be called. +- If the service says to retry with the same generation ID, look up the current submission's confirmed `generationId` using the [result rules](../SKILL.md#generation-and-results). An upload ID or a source image or video task number cannot stand in for it. If no ID belongs to this submission, preserve its trace ID and report that task creation and charging remain unconfirmed. +- For diagnosis, compare available stages of the same request from upload response through Cursor's model input, original tool arguments, and outgoing MCP request. Record unavailable stages. Compare only redacted URL summaries and query parameter names. A `ResourceNotFound` error alone cannot identify the stage that failed. + +## Model capability mismatch + +If the user says a requested model is enabled but it is absent, follow [capability discovery](capability-discovery.md): finish all tool-list pages, include `omni_ref_video` for video when present, and query remaining generation entry points before concluding the model was not returned. Check the actual connection, endpoint, and MCP version, then refresh discovery. Another client's results or website membership do not replace this connection's account-scoped capabilities. + +If the mismatch remains, report that the current connection did not return the requested model and the cause needs investigation. Do not label it an account-permission failure without evidence, change accounts/endpoints, probe guessed model names through generation, or silently fall back to an older model. Keep diagnostics sanitized; omit credentials, private account fields, and signed URLs. + +## Element or motion cannot be used + +- Resolve ambiguous names before selecting an ID. Use `element_get` to inspect the resource type and access before reuse or updates. +- Use Elements only with live models declaring both the resource type and binding argument, including conditional caps. Preserve required image inputs and use the model's prompt and structured bindings; entry point names alone do not establish support. +- Keep the existing cover and unmodified secondary images when updating an image Element. Do not change its resource type or delete-and-recreate without explicit authorization. +- Motion control requires a subject image and exactly one source: `motionId` or a video input. A library preview URL is not a motion ID. Validate source duration and model arguments; do not invent a `duration` parameter. +- An empty motion library is a valid result. The current tool surface has no motion create, update, or delete operation. + +## Task is still running or the result App does not render + +Follow the [Cursor result rules](../SKILL.md#generation-and-results). If the user reports a missing video and this submission has a task number, use the mounted App's current status or look up that task when the App is unavailable. Report progress while it runs, deliver the usable video on success, and preserve the task number and reason on failure. If a lookup fails, report the last confirmed state and explain that the refresh failed. + +A rendering problem is not a generation failure. Preserve the tool result and follow the core Skill's text fallback and completion rules. Do not register a local MCP server, embed duplicate media, or claim that an unmounted App was displayed. + +## Submission fails or times out + +If a `generationId` is known, follow the core Skill's App or headless result rules. If no ID is known, report the returned error and any unknown creation or billing state, then stop. A credit balance cannot establish the outcome, and `query_tasks` requires a known ID. Any new attempt needs fresh explicit authorization. + +For a provider failure, return the provider message and preserve task IDs. For unsupported arguments, refresh the live schema, revise the rejected settings, and obtain confirmation before any new generation. + +Treat a generic service-unavailable message as a service error even when the outer code is `InvalidParameter`. Follow up on a known task number. If there is no task number and the submission is ambiguous, stop and preserve the trace ID. Apply parameter troubleshooting when the service identifies a specific field. + +## Rate limit or full generation queue + +Distinguish a full generation queue from a rate-limited status query. For a full queue, keep the original settings and any task number. Report the returned waiting instructions and confirmed task state. If the service has no queue for this request, distinguish a confirmed rejection from an unconfirmed submission. When the user asks to continue, check any known task first and follow the [single-submission workflow](tool-workflows.md#generation). If a status query is rate-limited, stop polling and report the last confirmed state and task number. + +## Insufficient credits + +Use the current balance and provider response to distinguish a task paused before submission, a rejected call, and an unconfirmed submission. Membership allowances alone do not establish the available balance. Follow [credit recovery](tool-workflows.md#resuming-after-a-credit-pause). A balance change or request to view an existing result does not authorize a new submission. + +## Result link expired + +Query the original `generationId` for current outputs immediately before reuse. Do not treat signed URLs as permanent asset identifiers or log them. If the task cannot be queried in the current region, explain the limitation rather than creating a replacement task. diff --git a/third_party/kling-ai-cn/tests/plugin.test.mjs b/third_party/kling-ai-cn/tests/plugin.test.mjs new file mode 100644 index 000000000..03fa2a496 --- /dev/null +++ b/third_party/kling-ai-cn/tests/plugin.test.mjs @@ -0,0 +1,46 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +import { verifyPlugin } from "../scripts/verify-plugin.mjs"; + +test("the China Cursor plugin satisfies its package contract", () => { + const result = verifyPlugin(); + + assert.deepEqual(result, { + name: "kling-ai", + endpoint: "https://klingai.com/mcp/plugin", + version: "1.4.2" + }); +}); + +test("suggested prompts cover Image 4.0, both 4.0 video models, HDR, motions, and Elements in both languages", () => { + const examples = readFileSync(new URL("../skills/kling-ai/references/prompt-examples.md", import.meta.url), "utf8"); + + for (const [heading, expected] of [ + ["Suggested prompts", [ + /Kling Image 4\.0.*series of three 8K images in one request/, + /Kling 4\.0 to generate a 20.*1080p with HDR output/, + /Kling 4\.0 Flash.*20-second, 720p/, + /motion library/, + /reusable Element/ + ]], + ["推荐提示词", [ + /可灵图片 4\.0 一次生成 3 张 8K 连续组图/, + /可灵 4\.0 生成一段 20 秒、1080p 的 HDR/, + /可灵 4\.0 Flash.*首帧.*20 秒、720p/, + /动作库/, + /可复用主体/ + ]] + ]) { + const section = examples.split(`## ${heading}\n\n`)[1]?.split("\n## ")[0]; + assert.ok(section, `Missing section: ${heading}`); + const prompts = section.trim().split("\n"); + assert.equal(prompts.length, expected.length); + for (const [index, prompt] of prompts.entries()) { + assert.ok(prompt.startsWith("- ")); + assert.match(prompt, expected[index]); + assert.doesNotMatch(prompt, /最新|latest|V4/i); + } + } +}); diff --git a/third_party/kling-ai/.cursor-plugin/plugin.json b/third_party/kling-ai/.cursor-plugin/plugin.json index 88f130921..a582fe7a0 100644 --- a/third_party/kling-ai/.cursor-plugin/plugin.json +++ b/third_party/kling-ai/.cursor-plugin/plugin.json @@ -1,8 +1,8 @@ { "name": "kling-ai", "$schema": "https://cursor.com/schemas/cursor-plugin/plugin.json", - "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP.", - "version": "1.4.1", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 (including HDR) and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "version": "1.4.2", "author": { "name": "KLING AI" }, diff --git a/third_party/kling-ai/README.md b/third_party/kling-ai/README.md index 4671c2341..3d4abbd82 100644 --- a/third_party/kling-ai/README.md +++ b/third_party/kling-ai/README.md @@ -1,7 +1,7 @@ # Kling AI for Cursor Generate images and videos, reuse Elements, and track Kling tasks from Cursor -Agent chat. This is the **Global** plugin on the `main` branch, version **1.4.1**. +Agent chat. This is the **Global** plugin on the `main` branch, version **1.4.2**. Using a China account? See the [China plugin on the `cn` branch](https://github.com/klingai-tech/cursor-plugin/tree/cn). ## Quick start @@ -91,7 +91,7 @@ or [中文](skills/kling-ai/references/prompt-examples.md#推荐提示词). - Text-to-image, reference-guided editing, and coherent image series. If no image model is specified, prefer Kling Image 4.0 when it is available and meets the request, then consider the account's compatible default. - [Kling Image 4.0](https://kling.ai/quickstart/kling-image-4-user-guide) supports native 8K and Series Mode for up to 10 coherent images in one generation. Available settings follow the connected account's MCP capabilities. -- Kling 4.0: text-to-video, first/last/intermediate keyframes, and Omni-Ref with images, videos, audio, and Elements. Outputs are 3–30 seconds at 720p, with 1080p available to eligible accounts. +- Kling 4.0: text-to-video, first/last/intermediate keyframes, and Omni-Ref with images, videos, audio, and Elements. Outputs are 3–30 seconds and default to 720p. Accounts with access to 1080p or 4K can enable HDR output in text-to-video, image-to-video, and Omni-Ref. - Kling 4.0 Flash: text-to-video, single first-frame image-to-video, and Omni-Ref with images, videos, and Elements. Outputs are 3–20 seconds at 720p. - Both Omni-Ref models support smart shot splitting. Synchronized sound generation and source audio retention are mutually exclusive. Model availability and settings follow the connected account. - Live account-scoped model discovery, reference limits, and billing disclosures diff --git a/third_party/kling-ai/package.json b/third_party/kling-ai/package.json index f0ee305f6..91dc859c7 100644 --- a/third_party/kling-ai/package.json +++ b/third_party/kling-ai/package.json @@ -1,9 +1,9 @@ { "name": "kling-ai-cursor-plugin", - "version": "1.4.1", + "version": "1.4.2", "private": true, "type": "module", - "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 and Kling 4.0 Flash, and reuse Elements through Kling MCP.", + "description": "Generate and edit images with Kling Image 4.0, create videos with Kling 4.0 (including HDR) and Kling 4.0 Flash, and reuse Elements through Kling MCP.", "scripts": { "check": "node scripts/verify-plugin.mjs", "test": "node --test tests/*.test.mjs" diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md b/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md index 751dd5105..ad0e75274 100644 --- a/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md +++ b/third_party/kling-ai/skills/kling-ai-generate-video/SKILL.md @@ -1,6 +1,6 @@ --- name: kling-ai-generate-video -description: Write or refine Kling AI video prompts and storyboards, or generate videos through the Kling AI MCP in Cursor. Use for text-to-video, image-to-video, omni reference (全能参考), Kling 4.0 (V4) and Kling 4.0 Flash (V4 Flash), keyframes, audio-guided video, motion control, product showcases, advertising clips, social videos, and cinematic shots. +description: Write or refine Kling AI video prompts and storyboards, or generate videos through the Kling AI MCP in Cursor. Use for text-to-video, image-to-video, omni reference (全能参考), Kling 4.0 (V4) and Kling 4.0 Flash (V4 Flash), keyframes, HDR video output, audio-guided video, motion control, product showcases, advertising clips, social videos, and cinematic shots. --- # Kling AI video generation @@ -18,11 +18,11 @@ Read [scene patterns](references/scene-patterns.md) for product, advertising, so ## Workflow -1. Capture the requested model or family, duration, ratio, resolution, count, sound, shot intent, and reference roles. Clarify only details that materially change the result. Create or reuse the objective's UUIDv7 `taskTraceId`. -2. Use Cursor's current MCP tool list and `who_am_i` to compare eligible pairs following [capability discovery](../kling-ai/references/capability-discovery.md) and [video routing](references/model-routing.md). Check all requirements against the same live pair. A first-frame requirement needs a first-frame input. Required silence needs a declared sound-off setting that satisfies the request or an explicit silent-output guarantee. If no pair fits, report the unmet requirement and stop. +1. Capture the requested model or family, duration, ratio, resolution, HDR intent, count, sound, shot intent, and reference roles. Clarify only details that materially change the result. Create or reuse the objective's UUIDv7 `taskTraceId`. +2. Use Cursor's current MCP tool list and `who_am_i` to compare eligible pairs following [capability discovery](../kling-ai/references/capability-discovery.md) and [video routing](references/model-routing.md). Check all requirements against the same live pair. A first-frame requirement needs a first-frame input. Required silence needs a declared sound-off setting that satisfies the request or an explicit silent-output guarantee. If no pair fits, report the unmet requirement and ask before changing any requested setting. 3. Read the selected tool's complete live `inputSchema` and the pair's [model parameters](../kling-ai/references/model-parameters.md) before uploading local media or building the request. Stop if a required upload fails. -4. Follow [motion and shots](references/motion-and-shots.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Bind every supported explicit setting to its own argument or applicable fixed model value. Verify the serialized request against the brief and [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required prompt, and first-frame slot. Check an explicit resolution such as `1080p` against the selected tool and model's live enum and conditions. -5. Show the final tool/model, prompt summary, output settings, shot structure, reference roles, and required billing disclosures. After approval, follow the [submission workflow](../kling-ai/references/tool-workflows.md#generation) for the credit check and single submission, then follow the core Skill's result rules. +4. Follow [motion and shots](references/motion-and-shots.md) for each new generation, edit, or variant. Reuse a suitable prompt verbatim, make only necessary changes, or write a new prompt if needed. Bind every supported explicit setting to its own argument or applicable fixed model value. Verify the serialized request against the brief and [MCP contract](../kling-ai/references/mcp-contract.md), including the top-level `model`, required prompt, and first-frame slot. Check explicit resolution and [HDR output settings](../kling-ai/references/model-parameters.md#hdr-video-output) against the selected pair's live enums and conditions. +5. Show the final tool/model, prompt summary, output settings (including HDR mode when relevant), shot structure, reference roles, and required billing disclosures. After approval, follow the [submission workflow](../kling-ai/references/tool-workflows.md#generation) for the credit check and single submission, then follow the core Skill's result rules. ## Mode rules diff --git a/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md b/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md index fffafb1b0..5edad1b3a 100644 --- a/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md +++ b/third_party/kling-ai/skills/kling-ai-generate-video/references/model-routing.md @@ -12,6 +12,7 @@ When the user leaves model selection open, prefer a compatible Kling 4.0 pair, w - Text-only video can use `omni_ref_video` when the chosen model permits no media inputs. - Image, video, Element, and audio references can use `omni_ref_video` only when the selected model supports each requested type and their combination. Do not treat its general tool description as every model's capability list. - Keyframes belong to whichever discovered tool/model declares the needed frame inputs. Do not hardcode them to one entry point, invent intermediate frames, or substitute identity references for frame control. +- Required HDR output needs a pair that declares `hdr=hdr` at an eligible resolution on the current account. Check Kling 4.0 (`kling-video-v4_0`) in `text_to_video`, `image_to_video`, and `omni_ref_video` as applicable to the requested inputs. - Motion transfer must use a model that explicitly supports that intent and all required inputs. Existing `motion_control` requests keep the subject image and exactly one motion source. - Required silence eliminates pairs without a declared sound-off control that satisfies the request or an explicit silent-output guarantee. A text-to-video tool name, an absent audio field, or silence described in a prompt does not establish that capability. - Do not move an omni model to `image_to_video` or `text_to_video`; tool/model pairs and their parameter sets are inseparable. diff --git a/third_party/kling-ai/skills/kling-ai/references/model-parameters.md b/third_party/kling-ai/skills/kling-ai/references/model-parameters.md index 265fc3b54..e456a307f 100644 --- a/third_party/kling-ai/skills/kling-ai/references/model-parameters.md +++ b/third_party/kling-ai/skills/kling-ai/references/model-parameters.md @@ -35,6 +35,12 @@ request as its text. Keep reference inputs in the outer schema's input slots. Before sending, compare every explicit requirement with the actual serialized value or supported input; build the result summary from those values afterward. +## HDR video output + +- Kling 4.0 declares string values `none` (default) and `hdr`. Enable HDR only when the user requests HDR output and the selected tool/model pair advertises it. Use the live default when the user leaves HDR unspecified. +- HDR requires `1080p` or `4k` on the connected account. When resolution is unspecified, apply the video quality defaults among the eligible HDR resolutions. If the user explicitly asks for `720p` HDR or another unavailable combination, explain the limitation and ask which setting to change before submission. +- Put HDR and resolution in separate entries in `arguments`, for example `{"name":"hdr","value":"hdr"}` and `{"name":"resolution","value":"1080p"}`. Show both in the settings for approval. Report the submitted mode and verify the result's actual HDR format only when output metadata is available. + ## References and Elements Apply only when using actual/required reference inputs or Elements. Read [asset workflows](asset-workflows.md) for lookup and upload operations. diff --git a/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md b/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md index 48501c37a..44c953c69 100644 --- a/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md +++ b/third_party/kling-ai/skills/kling-ai/references/prompt-examples.md @@ -3,7 +3,7 @@ ## Suggested prompts - Use Kling Image 4.0 to generate a series of three 8K images in one request. Show the same red panda in a vintage spacesuit exiting a space station, drifting past a porthole, and turning to look at the blue Earth. -- Use Kling 4.0 to generate a 20‑second cinematic video: a mech warrior slams down from height onto the ground, sending out a shockwave that instantly blasts apart rubble and dust, with the camera rapidly pushing in for a powerful impact. +- Use Kling 4.0 to generate a 20‑second cinematic video at 1080p with HDR output: a mech warrior slams down from height onto the ground, sending out a shockwave that instantly blasts apart rubble and dust, with the camera rapidly pushing in for a powerful impact. - Use Kling 4.0 Flash to turn my sneaker product photo into a 20-second, 720p video. Start from the photo, slowly orbit the shoe, and end on a close-up of the upper. - Use Kling AI to browse the motion library and preview saved motions; after I select one, apply it to my subject image with an available motion-control model to generate a video. - Use Kling AI to save the front and side views of my character as my first reusable Element, named “Xiaobai”, to help keep the character consistent in later creations. @@ -11,7 +11,7 @@ ## 推荐提示词 - 使用可灵图片 4.0 一次生成 3 张 8K 连续组图。让同一只身穿复古宇航服的小熊猫依次从空间站出舱、掠过舷窗、转身望向蓝色地球 -- 使用可灵 4.0 生成一段 20 秒电影感视频:机甲战士从高空重砸地面,冲击波瞬间震开碎石与尘雾,镜头快速推近,充满力量感 +- 使用可灵 4.0 生成一段 20 秒、1080p 的 HDR 电影感视频:机甲战士从高空重砸地面,冲击波瞬间震开碎石与尘雾,镜头快速推近,充满力量感 - 使用可灵 4.0 Flash,把我提供的运动鞋商品图作为首帧,生成一段 20 秒、720p 的视频,镜头缓慢绕过鞋身,最后停在鞋面细节上 - 使用可灵AI查看动作库,预览已保存的动作;选定后,用可用的动作控制模型将该动作应用到我提供的主体图片生成视频 - 使用可灵AI将我提供的角色正面图和侧面图保存为第一个可复用主体,命名为“小白”,方便后续创作时保持角色一致 diff --git a/third_party/kling-ai/tests/plugin.test.mjs b/third_party/kling-ai/tests/plugin.test.mjs index f028d1a92..5e10eecf6 100644 --- a/third_party/kling-ai/tests/plugin.test.mjs +++ b/third_party/kling-ai/tests/plugin.test.mjs @@ -10,24 +10,24 @@ test("the Global Cursor plugin satisfies its package contract", () => { assert.deepEqual(result, { name: "kling-ai", endpoint: "https://kling.ai/mcp/plugin", - version: "1.4.1" + version: "1.4.2" }); }); -test("suggested prompts cover Image 4.0, both 4.0 video models, motions, and Elements in both languages", () => { +test("suggested prompts cover Image 4.0, both 4.0 video models, HDR, motions, and Elements in both languages", () => { const examples = readFileSync(new URL("../skills/kling-ai/references/prompt-examples.md", import.meta.url), "utf8"); for (const [heading, expected] of [ ["Suggested prompts", [ /Kling Image 4\.0.*series of three 8K images in one request/, - /Kling 4\.0 to generate a 20/, + /Kling 4\.0 to generate a 20.*1080p with HDR output/, /Kling 4\.0 Flash.*20-second, 720p/, /motion library/, /reusable Element/ ]], ["推荐提示词", [ /可灵图片 4\.0 一次生成 3 张 8K 连续组图/, - /可灵 4\.0 生成一段 20 秒/, + /可灵 4\.0 生成一段 20 秒、1080p 的 HDR/, /可灵 4\.0 Flash.*首帧.*20 秒、720p/, /动作库/, /可复用主体/