@mclawnet/agent 0.6.20 → 0.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +63 -0
- package/dist/__tests__/checkpoint.test.d.ts +2 -0
- package/dist/__tests__/checkpoint.test.d.ts.map +1 -0
- package/dist/__tests__/fs-handler-decode.test.d.ts +2 -0
- package/dist/__tests__/fs-handler-decode.test.d.ts.map +1 -0
- package/dist/__tests__/idle-sweeper.test.d.ts +2 -0
- package/dist/__tests__/idle-sweeper.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-config.test.d.ts +2 -0
- package/dist/__tests__/mcp-config.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-runtime-spawn.test.d.ts +2 -0
- package/dist/__tests__/schedule-runtime-spawn.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-runtime.test.d.ts +2 -0
- package/dist/__tests__/schedule-runtime.test.d.ts.map +1 -0
- package/dist/__tests__/session-limit.test.d.ts +2 -0
- package/dist/__tests__/session-limit.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-cli-client.test.d.ts +2 -0
- package/dist/__tests__/swarm-cli-client.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-control-dispatch.test.d.ts +2 -0
- package/dist/__tests__/swarm-control-dispatch.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-session-bridge.test.d.ts +2 -0
- package/dist/__tests__/swarm-session-bridge.test.d.ts.map +1 -0
- package/dist/backend-adapter.d.ts +43 -0
- package/dist/backend-adapter.d.ts.map +1 -1
- package/dist/checkpoint.d.ts +67 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/{chunk-RIK7IXSW.js → chunk-WJWCYGLQ.js} +1130 -147
- package/dist/chunk-WJWCYGLQ.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fs-handler.d.ts.map +1 -1
- package/dist/hub-connection.d.ts +13 -0
- package/dist/hub-connection.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/schedule-runtime.d.ts +125 -0
- package/dist/schedule-runtime.d.ts.map +1 -0
- package/dist/session-manager.d.ts +102 -0
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/skill-loader.d.ts +20 -0
- package/dist/skill-loader.d.ts.map +1 -1
- package/dist/start.d.ts +2 -0
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +1 -1
- package/dist/swarm-cli-client.d.ts +24 -0
- package/dist/swarm-cli-client.d.ts.map +1 -0
- package/dist/swarm-cli-client.js +83 -0
- package/dist/swarm-cli-client.js.map +1 -0
- package/dist/swarm-control-dispatch.d.ts +47 -0
- package/dist/swarm-control-dispatch.d.ts.map +1 -0
- package/dist/swarm-session-bridge.d.ts +22 -0
- package/dist/swarm-session-bridge.d.ts.map +1 -0
- package/package.json +6 -4
- package/skills/cocos-creator-3x-cn/SKILL.md +475 -0
- package/skills/cocos-creator-3x-cn/references/framework/asset-management.md +322 -0
- package/skills/cocos-creator-3x-cn/references/framework/component-system.md +348 -0
- package/skills/cocos-creator-3x-cn/references/framework/event-patterns.md +410 -0
- package/skills/cocos-creator-3x-cn/references/framework/playable-optimization.md +257 -0
- package/skills/cocos-creator-3x-cn/references/language/performance.md +363 -0
- package/skills/cocos-creator-3x-cn/references/language/quality-hygiene.md +307 -0
- package/skills/cocos-creator-3x-cn/references/review/architecture-review.md +183 -0
- package/skills/cocos-creator-3x-cn/references/review/quality-review.md +251 -0
- package/skills/cocos-performance-optimizer/SKILL.md +214 -0
- package/skills/game-development/2d-games/SKILL.md +129 -0
- package/skills/game-development/3d-games/SKILL.md +145 -0
- package/skills/game-development/SKILL.md +175 -0
- package/skills/game-development/game-art/SKILL.md +195 -0
- package/skills/game-development/game-audio/SKILL.md +200 -0
- package/skills/game-development/game-design/SKILL.md +139 -0
- package/skills/game-development/mobile-games/SKILL.md +118 -0
- package/skills/game-development/multiplayer/SKILL.md +142 -0
- package/skills/game-development/pc-games/SKILL.md +154 -0
- package/skills/game-development/vr-ar/SKILL.md +133 -0
- package/skills/game-development/web-games/SKILL.md +160 -0
- package/skills/game-engine/SKILL.md +140 -0
- package/skills/game-engine/assets/2d-maze-game.md +528 -0
- package/skills/game-engine/assets/2d-platform-game.md +1855 -0
- package/skills/game-engine/assets/gameBase-template-repo.md +310 -0
- package/skills/game-engine/assets/paddle-game-template.md +1528 -0
- package/skills/game-engine/assets/simple-2d-engine.md +507 -0
- package/skills/game-engine/references/3d-web-games.md +754 -0
- package/skills/game-engine/references/algorithms.md +843 -0
- package/skills/game-engine/references/basics.md +343 -0
- package/skills/game-engine/references/game-control-mechanisms.md +617 -0
- package/skills/game-engine/references/game-engine-core-principles.md +695 -0
- package/skills/game-engine/references/game-publishing.md +352 -0
- package/skills/game-engine/references/techniques.md +894 -0
- package/skills/game-engine/references/terminology.md +354 -0
- package/skills/game-engine/references/web-apis.md +1394 -0
- package/skills/theone-cocos-standards/SKILL.md +557 -0
- package/skills/theone-cocos-standards/references/framework/component-system.md +645 -0
- package/skills/theone-cocos-standards/references/framework/event-patterns.md +433 -0
- package/skills/theone-cocos-standards/references/framework/playable-optimization.md +429 -0
- package/skills/theone-cocos-standards/references/framework/size-optimization.md +308 -0
- package/skills/theone-cocos-standards/references/language/modern-typescript.md +658 -0
- package/skills/theone-cocos-standards/references/language/performance.md +580 -0
- package/skills/theone-cocos-standards/references/language/quality-hygiene.md +582 -0
- package/skills/theone-cocos-standards/references/review/architecture-review.md +250 -0
- package/skills/theone-cocos-standards/references/review/performance-review.md +288 -0
- package/skills/theone-cocos-standards/references/review/quality-review.md +239 -0
- package/dist/chunk-RIK7IXSW.js.map +0 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Bundle Size Optimization (<5MB Target)
|
|
2
|
+
|
|
3
|
+
## Texture Compression (Biggest Impact)
|
|
4
|
+
|
|
5
|
+
**Target: <5MB total bundle size for playable ads**
|
|
6
|
+
|
|
7
|
+
Texture compression is the single biggest factor in bundle size. Enable compression for all platforms.
|
|
8
|
+
|
|
9
|
+
### Build Settings Configuration
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
// Project Settings → Build → Web Mobile
|
|
13
|
+
{
|
|
14
|
+
"textureCompression": {
|
|
15
|
+
"web-mobile": "auto", // Auto-select best compression
|
|
16
|
+
"web-desktop": "auto",
|
|
17
|
+
"android": "etc1", // ETC1 for Android
|
|
18
|
+
"ios": "pvrtc" // PVRTC for iOS
|
|
19
|
+
},
|
|
20
|
+
"packAutoAtlas": true, // Auto-generate atlases
|
|
21
|
+
"md5Cache": false, // Disable for smaller output
|
|
22
|
+
"inlineSpriteFrames": true // Reduce file count
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Texture Size Guidelines
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// ✅ EXCELLENT: Optimal texture sizes for playables
|
|
30
|
+
|
|
31
|
+
// Character sprites: 512x512 max (often 256x256 is enough)
|
|
32
|
+
// UI elements: 256x256 max
|
|
33
|
+
// Backgrounds: 1024x1024 max (or use tiled smaller textures)
|
|
34
|
+
// Effects: 128x128 or 256x256
|
|
35
|
+
// Icons: 64x64 or 128x128
|
|
36
|
+
|
|
37
|
+
// ❌ WRONG: Oversized textures
|
|
38
|
+
// - 2048x2048 for small character sprites
|
|
39
|
+
// - High-res images that won't be seen at that scale
|
|
40
|
+
// Use appropriate sizes for display resolution
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Asset Optimization Priority
|
|
44
|
+
|
|
45
|
+
### 1. Textures (50-60% of bundle)
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// ✅ EXCELLENT: Sprite atlas configuration
|
|
49
|
+
// Combine multiple small textures into single atlas
|
|
50
|
+
// - Character animations: single atlas
|
|
51
|
+
// - UI elements: single atlas
|
|
52
|
+
// - Effects: single atlas
|
|
53
|
+
|
|
54
|
+
// Auto-atlas settings (Project Settings):
|
|
55
|
+
// - Max Width: 2048
|
|
56
|
+
// - Max Height: 2048
|
|
57
|
+
// - Padding: 2
|
|
58
|
+
// - Allow Rotation: true
|
|
59
|
+
// - Force Square: false
|
|
60
|
+
|
|
61
|
+
// ❌ WRONG: Individual texture files
|
|
62
|
+
// Each separate texture = separate HTTP request + worse compression
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Audio (20-30% of bundle)
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// ✅ EXCELLENT: Audio optimization
|
|
69
|
+
// - Format: MP3 or OGG (not WAV)
|
|
70
|
+
// - Background music: 128kbps max, short loops (<30 seconds)
|
|
71
|
+
// - Sound effects: 64kbps, very short (<2 seconds)
|
|
72
|
+
|
|
73
|
+
// ❌ WRONG: Uncompressed audio
|
|
74
|
+
// - WAV files: 10-20x larger than compressed
|
|
75
|
+
// - Long music tracks: use short loops
|
|
76
|
+
// - High bitrate: 320kbps unnecessary for playables
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3. Code (5-10% of bundle)
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// ✅ EXCELLENT: Code minification
|
|
83
|
+
// rollup.config.js or webpack.config.js
|
|
84
|
+
export default {
|
|
85
|
+
mode: 'production',
|
|
86
|
+
optimization: {
|
|
87
|
+
minimize: true,
|
|
88
|
+
minimizer: [
|
|
89
|
+
new TerserPlugin({
|
|
90
|
+
terserOptions: {
|
|
91
|
+
compress: {
|
|
92
|
+
drop_console: true, // Remove console.log
|
|
93
|
+
drop_debugger: true, // Remove debugger
|
|
94
|
+
dead_code: true, // Remove unreachable code
|
|
95
|
+
unused: true // Remove unused variables
|
|
96
|
+
},
|
|
97
|
+
mangle: { toplevel: true } // Shorten variable names
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// ✅ EXCELLENT: Import only what you need
|
|
105
|
+
import { Vec3, Node } from 'cc'; // Specific imports
|
|
106
|
+
|
|
107
|
+
// ❌ WRONG: Import entire module
|
|
108
|
+
import * as cc from 'cc'; // Imports everything (larger bundle)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 4. Fonts (5-10% of bundle)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// ✅ EXCELLENT: Bitmap fonts for playables
|
|
115
|
+
// - Pre-render characters to texture
|
|
116
|
+
// - Include only needed characters: "0123456789,."
|
|
117
|
+
// - Much smaller than TTF fonts
|
|
118
|
+
|
|
119
|
+
// Create bitmap font:
|
|
120
|
+
// 1. Use BMFont tool or online generator
|
|
121
|
+
// 2. Include only needed characters
|
|
122
|
+
// 3. Export as .fnt + .png
|
|
123
|
+
// 4. Import to Cocos Creator as BitmapFont
|
|
124
|
+
|
|
125
|
+
// ❌ WRONG: TTF fonts
|
|
126
|
+
// - Large file size (hundreds of KB)
|
|
127
|
+
// - System fonts vary by platform
|
|
128
|
+
// - Use bitmap fonts for playables
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Build Configuration for Minimum Size
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
// Project Settings → Build → Web Mobile
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
// Bundle settings
|
|
138
|
+
"inlineSpriteFrames": true, // Reduce file count
|
|
139
|
+
"md5Cache": false, // Disable MD5 in filenames
|
|
140
|
+
"mainBundleCompressionType": "default",
|
|
141
|
+
"mainBundleIsRemote": false,
|
|
142
|
+
|
|
143
|
+
// Code optimization
|
|
144
|
+
"debug": false, // Disable debug mode
|
|
145
|
+
"sourceMaps": false, // Disable source maps
|
|
146
|
+
"separateEngine": false, // Include engine in bundle
|
|
147
|
+
|
|
148
|
+
// Texture optimization
|
|
149
|
+
"packAutoAtlas": true, // Auto-generate atlases
|
|
150
|
+
"textureCompression": "auto", // Enable compression
|
|
151
|
+
|
|
152
|
+
// Feature exclusions
|
|
153
|
+
"excludeScenes": [], // Remove unused scenes
|
|
154
|
+
"useBuiltinServer": false // Playables don't need server
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Removing Unused Assets
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// ✅ EXCELLENT: Regular asset cleanup
|
|
162
|
+
|
|
163
|
+
// 1. Use Cocos Creator's "Find References" feature
|
|
164
|
+
// - Right-click asset → Find References
|
|
165
|
+
// - Delete if no references found
|
|
166
|
+
|
|
167
|
+
// 2. Check build output
|
|
168
|
+
// - Review build folder size after each build
|
|
169
|
+
// - Identify largest files
|
|
170
|
+
// - Remove unused assets
|
|
171
|
+
|
|
172
|
+
// 3. Remove debug assets before build
|
|
173
|
+
// - Test levels
|
|
174
|
+
// - Debug sprites and textures
|
|
175
|
+
// - Development-only tools
|
|
176
|
+
// - Temporary assets
|
|
177
|
+
|
|
178
|
+
// ❌ WRONG: Keep all assets "just in case"
|
|
179
|
+
// - Unused textures add unnecessary size
|
|
180
|
+
// - Clean up regularly during development
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Real-World Example: Size Breakdown
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// Target: <5MB playable bundle
|
|
187
|
+
// Typical optimized breakdown:
|
|
188
|
+
|
|
189
|
+
// Textures: 2.5MB (50%)
|
|
190
|
+
// - Character sprites: 800KB (sprite atlas, ETC1 compressed)
|
|
191
|
+
// - UI elements: 600KB (sprite atlas, ETC1 compressed)
|
|
192
|
+
// - Background: 700KB (1024x1024, compressed, or tiled)
|
|
193
|
+
// - Effects: 400KB (sprite atlas, compressed)
|
|
194
|
+
|
|
195
|
+
// Code: 400KB (8%)
|
|
196
|
+
// - Cocos engine: 200KB (minified, tree-shaken)
|
|
197
|
+
// - Game logic: 200KB (minified, dead code removed)
|
|
198
|
+
|
|
199
|
+
// Audio: 1.5MB (30%)
|
|
200
|
+
// - Background music: 1MB (MP3, 128kbps, 60s loop)
|
|
201
|
+
// - Sound effects: 500KB (MP3, 64kbps, 10 short clips)
|
|
202
|
+
|
|
203
|
+
// Other: 600KB (12%)
|
|
204
|
+
// - Bitmap fonts: 200KB (only needed characters)
|
|
205
|
+
// - Config files: 100KB (JSON, minified)
|
|
206
|
+
// - Misc assets: 300KB
|
|
207
|
+
|
|
208
|
+
// Total: 5.0MB (within ad network limit)
|
|
209
|
+
|
|
210
|
+
// ❌ BAD EXAMPLE: Unoptimized (12MB+)
|
|
211
|
+
// - Textures: 8MB (no compression, individual files)
|
|
212
|
+
// - Audio: 3MB (WAV files, long tracks)
|
|
213
|
+
// - Code: 800KB (no minification, dev mode)
|
|
214
|
+
// - Fonts: 400KB (TTF fonts)
|
|
215
|
+
// Total: 12.2MB (rejected by ad networks!)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Monitoring Bundle Size
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# ✅ EXCELLENT: Monitor size regularly
|
|
222
|
+
|
|
223
|
+
# 1. Check build output size
|
|
224
|
+
du -sh build/web-mobile/
|
|
225
|
+
|
|
226
|
+
# 2. Break down by asset type
|
|
227
|
+
du -sh build/web-mobile/assets/
|
|
228
|
+
du -sh build/web-mobile/src/
|
|
229
|
+
|
|
230
|
+
# 3. Find largest files
|
|
231
|
+
find build/web-mobile -type f -exec du -h {} \; | sort -rh | head -20
|
|
232
|
+
|
|
233
|
+
# 4. Set size budget in CI/CD
|
|
234
|
+
# Fail build if bundle >5MB
|
|
235
|
+
# Alert if bundle >4.5MB (warning threshold)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Lazy Loading Pattern (Optional)
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { _decorator, Component, resources, Prefab } from 'cc';
|
|
242
|
+
const { ccclass } = _decorator;
|
|
243
|
+
|
|
244
|
+
@ccclass('LazyLoader')
|
|
245
|
+
export class LazyLoader extends Component {
|
|
246
|
+
// ✅ EXCELLENT: Load levels on demand
|
|
247
|
+
// For playables with multiple levels, load only current level
|
|
248
|
+
|
|
249
|
+
private levelPrefabs: Map<number, Prefab> = new Map();
|
|
250
|
+
|
|
251
|
+
public async loadLevel(levelId: number): Promise<void> {
|
|
252
|
+
if (this.levelPrefabs.has(levelId)) {
|
|
253
|
+
return; // Already loaded
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const path = `levels/level_${levelId}`;
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
resources.load(path, Prefab, (err, prefab) => {
|
|
259
|
+
if (err) {
|
|
260
|
+
reject(err);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
this.levelPrefabs.set(levelId, prefab);
|
|
264
|
+
resolve();
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ✅ GOOD: Unload previous level
|
|
270
|
+
public async switchLevel(fromLevel: number, toLevel: number): Promise<void> {
|
|
271
|
+
const prevPrefab = this.levelPrefabs.get(fromLevel);
|
|
272
|
+
if (prevPrefab) {
|
|
273
|
+
prevPrefab.decRef();
|
|
274
|
+
this.levelPrefabs.delete(fromLevel);
|
|
275
|
+
}
|
|
276
|
+
await this.loadLevel(toLevel);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ❌ WRONG: Loading all levels at start
|
|
281
|
+
// - Increases initial bundle size
|
|
282
|
+
// - Longer load time
|
|
283
|
+
// - Only load what's needed for first level
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Size Optimization Checklist
|
|
287
|
+
|
|
288
|
+
**🔴 Critical (Biggest Impact):**
|
|
289
|
+
- [ ] Enable texture compression (auto or platform-specific)
|
|
290
|
+
- [ ] Use sprite atlases (combine textures)
|
|
291
|
+
- [ ] Reduce texture dimensions (512x512 max for characters)
|
|
292
|
+
- [ ] Compress audio (MP3/OGG, 64-128kbps)
|
|
293
|
+
- [ ] Remove unused assets
|
|
294
|
+
|
|
295
|
+
**🟡 Important:**
|
|
296
|
+
- [ ] Enable code minification (drop_console, dead_code removal)
|
|
297
|
+
- [ ] Use bitmap fonts (not TTF)
|
|
298
|
+
- [ ] Disable source maps in production
|
|
299
|
+
- [ ] Import specific modules (tree shaking)
|
|
300
|
+
- [ ] Remove debug/test assets
|
|
301
|
+
|
|
302
|
+
**🟢 Nice to Have:**
|
|
303
|
+
- [ ] Lazy load levels (if multiple levels)
|
|
304
|
+
- [ ] Monitor bundle size in CI/CD
|
|
305
|
+
- [ ] Set size budget alerts (<5MB hard limit)
|
|
306
|
+
- [ ] Track size trends over time
|
|
307
|
+
|
|
308
|
+
**Target: <5MB total bundle size for playable ad approval.**
|