t1k:cocos:base:asset-import
| Field | Value |
|---|---|
| Module | base |
| Version | 1.10.0 |
| Effort | medium |
| Tools | — |
Keywords: asset-bundle, asset-import, asset-pipeline, cocos, cocos-creator, incoming, naming, promote, validate
How to invoke
Section titled “How to invoke”/t1k:cocos:base:asset-importt1k-cocos-base-asset-import
Section titled “t1k-cocos-base-asset-import”Manifest-driven asset import pipeline for Cocos Creator 3.x projects. Reads incoming raw assets from assets/_Incoming/, validates naming and budgets against a project-level .claude/asset-pipeline.json (layered on top of kit defaults), and promotes accepted assets into their canonical folders with .meta co-moved.
This is the Cocos parallel of t1k-unity-base-asset-import. Same triage model (ACCEPTED-CLEAN / ACCEPTED-WITH-WARNING / REJECTED-ERROR), same report format, same override merge — only the engine-specific operations differ.
When to invoke
Section titled “When to invoke”- The user drops a batch of raw textures, prefabs, audio, scenes, or
.effectshaders intoassets/_Incoming/and wants them promoted. - The user asks “validate assets”, “check asset naming”, or “import these into the project”.
- CI gate: scan-only mode to fail the build on naming/budget violations before merge.
Inputs
Section titled “Inputs”- Manifest: project
.claude/asset-pipeline.json(project SSOT). If absent, kit defaults fromreferences/default-manifest-schema.mdapply. Project values override kit values key-by-key (no deep-merge of arrays — replacement only). - Incoming root:
assets/_Incoming/(configurable viaincomingRoot). - Mode flags:
- default → report only
--apply→ perform moves--apply --no-promote-warnings→ move onlyACCEPTED-CLEANfiles; leave warnings in_Incoming/
Workflow
Section titled “Workflow”- Load manifest. Read kit defaults (from this skill’s
references/default-manifest-schema.md); overlay project.claude/asset-pipeline.jsonif present. - Scan. Run
scripts/scan-incoming.cjs <project-root>→ JSON inventory of files underassets/_Incoming/, with detected type by extension + prefix. - Validate. Run
scripts/validate-naming.cjsagainst the merged manifest. Each file gets:triage:ACCEPTED-CLEAN|ACCEPTED-WITH-WARNING|REJECTED-ERRORreasons[]: regex mismatch, unknown prefix, budget warn/err, unknown extension, missing.metatargetFolder: resolved from manifestprefixes[*].targetFolderbundle: resolved from manifestfolderMap[targetFolder].bundle(Cocos Asset Bundle)
- Report. Render the markdown report per
references/report-format.md. Surface counts per triage level, per-file reasons, and the promotion plan. - Decide via AskUserQuestion. Options: proceed (
--apply), proceed-strict (--apply --no-promote-warnings), fix-and-rescan, abort. - Promote (only if user picks proceed).
scripts/promote-assets.cjs --apply:- For each accepted file,
mv <src> <dest>thenmv <src>.meta <dest>.meta(co-move). - If
<src>.metais missing, log a WARNING and skip the meta move; the editor will regenerate the meta on next refresh — but UUID changes, breaking refs. Project owner must approve via AskUserQuestion before promoting meta-less files. - Never regenerate or rewrite
.metacontent during promote — UUIDs are immutable. - Idempotent: skip if dest already exists with matching content (same SHA).
- For each accepted file,
Triage rules
Section titled “Triage rules”See references/triage-rules.md. Summary:
| Condition | Triage |
|---|---|
Regex matches + budget within maxSize/maxBytes + .meta present | ACCEPTED-CLEAN |
Regex matches + budget in warnAbove/warnBytes band, or .meta missing | ACCEPTED-WITH-WARNING |
Regex mismatch (and triage.rejectOnRegexMismatch=true), or budget over errAbove/errBytes (and triage.rejectOnErrCap=true), or unknown prefix | REJECTED-ERROR |
Cocos-specific deviations from the Unity sibling
Section titled “Cocos-specific deviations from the Unity sibling”- Asset root is
assets/(lowercase). Incoming root:assets/_Incoming/. .metafiles are JSON sidecars. ALWAYS co-move with the asset. NEVER regenerate — UUID changes break every reference in scenes/prefabs.- No MCP — promote uses plain shell
mv(orgit mvif file is tracked). - Asset Bundles replace Addressables.
folderMap[targetFolder].bundlenames the bundle; consumer’s editorcc.AssetManager/ bundle config picks it up. Nomanage_addressablesequivalent — bundle membership is config-driven. - Default prefixes:
T_,S_,M_,SFX_,BGM_,VFX_,SO_,Sh_,Prefab_,Scene_. NoAnim_/Ctrl_/Vcam_(Cocos uses different animation/camera workflows; consumer manifest may add them). - Extension hints:
.scene,.prefab,.effect(shader),.mtl(material),.png/.jpg/.webp(texture),.mp3/.wav/.ogg(audio),.asset.json(Cocos plugin asset). - Budgets mirror the mobile target. No DOTS-specific constraints.
Scripts
Section titled “Scripts”# Scan only — emits JSON inventorynode scripts/scan-incoming.cjs <project-root>
# Validate against manifest — emits JSON report with triagenode scripts/validate-naming.cjs <project-root>
# Promote (dry-run by default; --apply commits)node scripts/promote-assets.cjs <project-root>node scripts/promote-assets.cjs <project-root> --applynode scripts/promote-assets.cjs <project-root> --apply --no-promote-warningsReferences
Section titled “References”references/default-manifest-schema.md— full default manifest with Cocos prefixes and budgetsreferences/workflow.md— step-by-step flow + decision pointsreferences/triage-rules.md— exact triage thresholds and reason codesreferences/report-format.md— markdown report layoutreferences/project-override-pattern.md— how project.claude/asset-pipeline.jsonoverrides kit defaults
Gotchas
Section titled “Gotchas”- NEVER regenerate
.meta. Cocos UUIDs live in.meta; regenerating breaks every reference. If a.metais missing, promoting forces the editor to regenerate on next refresh → UUID changes → broken refs in scenes/prefabs/components. Always co-move or skip. - Atlas textures count under
texture.atlasbudget, nottexture. Project manifest must declare which textures are atlas pages via a label or folder convention (art/2d/atlases/). assets/_Incoming/is scratch space — never check it into the Cocos build’s Asset Bundle config. Promoted files inherit theirtargetFolder’s bundle.- Audio formats (
.mp3,.wav,.ogg) triggeraudio.sfxoraudio.bgmbased on prefix, not extension.BGM_*.mp3→audio.bgm;SFX_*.mp3→audio.sfx. - Shell
mvvsgit mv: if the source file is git-tracked (rare for incoming raw assets, but possible), usegit mvto preserve history.promote-assets.cjsdetects this automatically.