cocos-creator-hotupdate

cocos-creator-hotupdate is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 32 tokens per session (4,080 once invoked), scanned A, original, MIT.

A guide to updating a Cocos Creator game's scripts, resources, or settings after release, without submitting a new app-store version. It covers version files, partial downloads, checks, and rollback.

In plain words
What is it for?
Use it when setting up or troubleshooting native-package game updates, generating resource checksums and version files, configuring CDN caching, handling update errors, or adding rollback protection.
Why use it?
It helps prevent clients from keeping old or mismatched resources, missing updates because of cached version files, or being left with damaged update data after a failed update.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/cocos-creator-hotupdate
Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill cocos-creator-hotupdate
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cocos-creator-hotupdate

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator-hotupdate.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator-hotupdate)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator-hotupdate"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator-hotupdate.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,080 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.04080
Opus 5 $0.00016 $0.02040
Sonnet 5 $0.00006 $0.00816
Haiku 4.5 $0.00003 $0.00408

Measured 5d ago against content hash a158b7bfcacf, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

cocos-creator-hotupdate scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- 发布前用 `curl -I https://cdn.example.com/version.manifest` 确认响应头无长期缓存。
skills/cocos-creator-hotupdate/SKILL.md · 334 lines

How it starts

The opening of the file, as written. The whole thing — 334 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cocos Creator 热更新

何时用

  • 需要在不重新发版到应用商店的前提下更新游戏脚本、资源或配置时。
  • 配置 CDN 服务器上的 project.manifest / version.manifest,或排查热更新失败/资源不一致问题时。
  • 热更新后游戏仍加载旧资源,或搜索路径设置不当导致热更内容无法生效时。
  • 热更异常导致本地热更目录数据损坏,需要实现回滚兜底方案时。

核心规则

1. manifest 配置:版本号与资源 MD5 必须与实际文件一致

规则: project.manifest 里每个资源条目的 MD5 值必须与服务器上实际文件的 MD5 对应;version.manifest 的版本号在每次发布热更时必须递增;两个 manifest 文件本身不得被 CDN 长期缓存(Cache-Control: no-cache 或极短 TTL)。

为什么: 手写或脚本生成 manifest 时最常见的错误是"构建后忘记重新生成 manifest"——资源 MD5 还是上一次构建的值,与服务器实际文件不匹配。AssetsManager 对比 MD5 时发现一致,认为不需要更新,结果新资源从未被下载,玩家看到的是旧内容但没有任何报错,开发者以为热更成功。另一个陷阱:CDN 把 version.manifest 缓存了 24 小时,服务器上版本号已经更新,客户端拿到的还是旧版本号,不触发更新流程,线上问题持续数小时才被发现。

怎么做:

  • 构建流程集成 jsb-link/res 目录的 MD5 计算脚本,每次构建自动生成 manifest,禁止手写。
  • Creator 官方提供了 version-generator.js 工具(位于引擎目录),CI/CD 流程在构建后自动调用。
  • CDN 配置:project.manifestversion.manifest 设置 Cache-Control: no-storemax-age=60
  • 发布前用 curl -I https://cdn.example.com/version.manifest 确认响应头无长期缓存。
  • 版本号使用时间戳或语义化版本,绝不复用旧版本号(热更服务器有旧版本号缓存时会跳过更新)。

2. 用 AssetsManager 走引擎热更流程,监听全部关键事件

规则: 必须监听 UPDATE_PROGRESSION(进度)、ALREADY_UP_TO_DATE(已最新)、UPDATE_FINISHED(完成)、ERROR_DOWNLOAD(下载失败)、ERROR_VERIFY(校验失败)等事件,在每个错误事件里记录日志并作出对应处理,不能只监听 UPDATE_FINISHED 就认为热更逻辑完整。

为什么: 只监听成功事件是 AI 生成热更代码时最普遍的问题:assetManager 的事件码有十余个,AI 通常只生成 UPDATE_FINISHED 的处理,其余全部忽略。结果:网络慢导致部分文件下载超时(ERROR_DOWNLOAD)没有触发重试,用户停在进度条 90% 永久卡死;资源下载后文件损坏(ERROR_VERIFY)没有删除损坏文件并重试,下次启动直接崩溃。ERROR_FAILED_DECOMPRESS 在 Android 低版本上尤其常见,忽略它会导致 zip 格式 bundle 无法解压,表现为进入某个功能模块时白屏。

怎么做:

import { native } from "cc";

export class HotUpdateManager {
    private _am: native.AssetsManager | null = null;
    private _updating = false;

    init(manifestPath: string, storagePath: string) {
        if (!native.AssetsManager) return; // 非原生平台跳过
        this._am = new native.AssetsManager(manifestPath, storagePath);
        this._am.setVerifyCallback((filePath, asset) => {
            // ✅ 可在此自定义校验逻辑(默认 MD5 校验已够用,返回 true 表示通过)
            return true;
        });
    }

    checkUpdate(): Promise<boolean> {
        return new Promise((resolve) => {
            if (!this._am) { resolve(false); return; }
            this._am.setEventCallback((event) => {
                const code = event.getEventCode();
                const EventCode = native.AssetsManager.EventCode;
                if (code === EventCode.ALREADY_UP_TO_DATE) {
                    resolve(false); // 无需更新
                } else if (code === EventCode.NEW_VERSION_FOUND) {
                    resolve(true); // 有新版本
                } else if (code === EventCode.ERROR_DOWNLOAD_MANIFEST ||
                           code === EventCode.ERROR_PARSE_MANIFEST) {
                    console.error("manifest 获取失败:", event.getMessage());
                    resolve(false); // 降级:当做无更新处理
                }
            });
            this._am.checkUpdate();
        });
    }

    update(onProgress: (percent: number) => void): Promise<void> {
        return new Promise((resolve, reject) => {
            if (!this._am || this._updating) return;
            this._updating = true;
            const EventCode = native.AssetsManager.EventCode;
            this._am.setEventCallback((event) => {
                const code = event.getEventCode();
                switch (code) {
                    case EventCode.UPDATE_PROGRESSION:
                        onProgress(event.getPercent());
                        break;
                    case EventCode.UPDATE_FINISHED:
                        this._updating = false;
                        resolve();
                        break;
                    case EventCode.ERROR_DOWNLOAD:
                        console.error("下载失败:", event.getAssetId(), event.getMessage());
                        // ✅ 单个文件下载失败继续其他文件,全部完成后统一重试失败列表
                        break;
                    case EventCode.ERROR_VERIFY:
                        console.error("校验失败:", event.getAssetId());
                        this._am!.downloadFailedAssets(); // ✅ 重新下载校验失败的文件
                        break;
                    case EventCode.ERROR_FAILED_DECOMPRESS:
                        console.error("解压失败:", event.getMessage());
                        this._updating = false;
                        reject(new Error("decompress_failed"));
                        break;
                    case EventCode.UPDATE_FAILED:
                        this._updating = false;
                        reject(new Error(event.getMessage()));
                        break;
                }
            });
            this._am.update();
        });
    }
}

Read the full file on GitHub · 334 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 334 lines · 32 tokens per session scan A a158b7bfcacf

Subscribe to this mod's changes

cocos-creator-hotupdate is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (6 stars, last pushed 2mo ago), licensed MIT. It adds 32 tokens to every session and 4,080 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

chinese-git-workflow

国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 69 tokens

brainstorming

在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。.

jnMetaCode/superpowers-zh · 40 tokens

chinese-commit-conventions

中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 65 tokens

chinese-documentation

中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-code-review

中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

mcp-builder

MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力.

jnMetaCode/superpowers-zh · 32 tokens