@mclawnet/agent 0.6.20 → 0.6.21
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/package.json +4 -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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# TypeScript Quality Review
|
|
2
|
+
|
|
3
|
+
This review focuses on TypeScript code quality issues including access modifiers, strict mode compliance, error handling, and code hygiene.
|
|
4
|
+
|
|
5
|
+
## TypeScript Strict Mode Violations
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// ❌ CRITICAL: Strict mode disabled
|
|
9
|
+
// tsconfig.json
|
|
10
|
+
{
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"strict": false // Bad!
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ✅ CORRECT: Enable strict mode
|
|
17
|
+
{
|
|
18
|
+
"compilerOptions": {
|
|
19
|
+
"strict": true,
|
|
20
|
+
"noImplicitAny": true,
|
|
21
|
+
"strictNullChecks": true,
|
|
22
|
+
"strictFunctionTypes": true,
|
|
23
|
+
"strictBindCallApply": true,
|
|
24
|
+
"strictPropertyInitialization": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Severity: 🔴 Critical
|
|
29
|
+
// Fix: Enable strict mode in tsconfig.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Access Modifier Violations
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// ❌ CRITICAL: Missing access modifiers
|
|
36
|
+
@ccclass('NoModifiers')
|
|
37
|
+
export class NoModifiers extends Component {
|
|
38
|
+
playerNode: Node | null = null; // Implicitly public!
|
|
39
|
+
currentHealth: number = 100; // Implicitly public!
|
|
40
|
+
|
|
41
|
+
updateHealth(value: number) { // Implicitly public!
|
|
42
|
+
this.currentHealth = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ✅ CORRECT: Explicit modifiers
|
|
47
|
+
@ccclass('WithModifiers')
|
|
48
|
+
export class WithModifiers extends Component {
|
|
49
|
+
@property(Node)
|
|
50
|
+
private readonly playerNode: Node | null = null;
|
|
51
|
+
|
|
52
|
+
private currentHealth: number = 100;
|
|
53
|
+
|
|
54
|
+
public updateHealth(value: number): void {
|
|
55
|
+
this.currentHealth = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Severity: 🔴 Critical
|
|
60
|
+
// Fix: Add access modifiers (public/private/protected) to all members
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Silent Error Handling
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// ❌ CRITICAL: Silent failures
|
|
67
|
+
@ccclass('SilentErrors')
|
|
68
|
+
export class SilentErrors extends Component {
|
|
69
|
+
public getPlayer(id: string): Player | undefined {
|
|
70
|
+
const player = this.players.get(id);
|
|
71
|
+
return player; // Caller doesn't know why it failed
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ✅ CORRECT: Throw exceptions
|
|
76
|
+
@ccclass('ThrowExceptions')
|
|
77
|
+
export class ThrowExceptions extends Component {
|
|
78
|
+
public getPlayer(id: string): Player {
|
|
79
|
+
const player = this.players.get(id);
|
|
80
|
+
if (!player) {
|
|
81
|
+
throw new Error(`Player not found: ${id}`);
|
|
82
|
+
}
|
|
83
|
+
return player;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Severity: 🔴 Critical
|
|
88
|
+
// Fix: Throw exceptions for errors, not silent failures
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## console.log in Production
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// ❌ CRITICAL: Unconditional console.log
|
|
95
|
+
@ccclass('ConsoleLogBad')
|
|
96
|
+
export class ConsoleLogBad extends Component {
|
|
97
|
+
protected update(dt: number): void {
|
|
98
|
+
console.log('Update'); // In production build!
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ✅ CORRECT: Conditional or removed
|
|
103
|
+
@ccclass('ConsoleLogGood')
|
|
104
|
+
export class ConsoleLogGood extends Component {
|
|
105
|
+
protected update(dt: number): void {
|
|
106
|
+
if (CC_DEBUG) {
|
|
107
|
+
console.log('Update');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Severity: 🔴 Critical (for playables)
|
|
113
|
+
// Impact: Bundle size increase, performance
|
|
114
|
+
// Fix: Wrap in CC_DEBUG or remove entirely
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Inline Comments Instead of Descriptive Names
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// ❌ IMPORTANT: Comments explaining unclear code
|
|
121
|
+
@ccclass('InlineCommentsBad')
|
|
122
|
+
export class InlineCommentsBad extends Component {
|
|
123
|
+
private h: number = 100; // health
|
|
124
|
+
|
|
125
|
+
public td(a: number): void { // take damage
|
|
126
|
+
this.h = this.h - a; // subtract
|
|
127
|
+
if (this.h <= 0) { // dead
|
|
128
|
+
this.hd(); // handle death
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ✅ CORRECT: Self-explanatory names
|
|
134
|
+
@ccclass('InlineCommentsGood')
|
|
135
|
+
export class InlineCommentsGood extends Component {
|
|
136
|
+
private currentHealth: number = 100;
|
|
137
|
+
|
|
138
|
+
public takeDamage(amount: number): void {
|
|
139
|
+
this.currentHealth -= amount;
|
|
140
|
+
if (this.isDead()) {
|
|
141
|
+
this.handleDeath();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private isDead(): boolean {
|
|
146
|
+
return this.currentHealth <= 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private handleDeath(): void {
|
|
150
|
+
// Implementation
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Severity: 🟡 Important
|
|
155
|
+
// Fix: Use descriptive names, remove inline comments
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Missing readonly/const
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// ❌ IMPORTANT: Mutable when should be immutable
|
|
162
|
+
@ccclass('MissingReadonly')
|
|
163
|
+
export class MissingReadonly extends Component {
|
|
164
|
+
@property(Node)
|
|
165
|
+
private targetNode: Node | null = null; // Should be readonly
|
|
166
|
+
|
|
167
|
+
private maxHealth: number = 100; // Should be static readonly
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ✅ CORRECT: Use readonly/const
|
|
171
|
+
@ccclass('WithReadonly')
|
|
172
|
+
export class WithReadonly extends Component {
|
|
173
|
+
@property(Node)
|
|
174
|
+
private readonly targetNode: Node | null = null;
|
|
175
|
+
|
|
176
|
+
private static readonly MAX_HEALTH: number = 100;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Severity: 🟡 Important
|
|
180
|
+
// Fix: Add readonly to fields not reassigned, use static readonly for constants
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Using `any` Type
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// ❌ IMPORTANT: Using any without justification
|
|
187
|
+
@ccclass('UsingAny')
|
|
188
|
+
export class UsingAny extends Component {
|
|
189
|
+
private data: any = {}; // Type safety lost
|
|
190
|
+
|
|
191
|
+
public processData(input: any): any {
|
|
192
|
+
return input; // No type checking
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ✅ CORRECT: Use proper types
|
|
197
|
+
interface PlayerData {
|
|
198
|
+
id: string;
|
|
199
|
+
name: string;
|
|
200
|
+
level: number;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@ccclass('WithTypes')
|
|
204
|
+
export class WithTypes extends Component {
|
|
205
|
+
private data: Map<string, PlayerData> = new Map();
|
|
206
|
+
|
|
207
|
+
public processData(input: PlayerData): PlayerData {
|
|
208
|
+
return input;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Severity: 🟡 Important
|
|
213
|
+
// Fix: Define proper types and interfaces, avoid `any`
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Summary: Quality Review Checklist
|
|
217
|
+
|
|
218
|
+
**🔴 Critical (Must Fix):**
|
|
219
|
+
- [ ] TypeScript strict mode enabled in tsconfig.json
|
|
220
|
+
- [ ] All members have access modifiers (public/private/protected)
|
|
221
|
+
- [ ] Exceptions thrown for errors (no silent failures)
|
|
222
|
+
- [ ] console.log removed or wrapped in CC_DEBUG
|
|
223
|
+
- [ ] No nullable warnings (proper null handling)
|
|
224
|
+
|
|
225
|
+
**🟡 Important (Should Fix):**
|
|
226
|
+
- [ ] readonly used for non-reassigned fields
|
|
227
|
+
- [ ] const used for constants (not let)
|
|
228
|
+
- [ ] No inline comments (self-explanatory code)
|
|
229
|
+
- [ ] Optional chaining (?.) for safe access
|
|
230
|
+
- [ ] Nullish coalescing (??) for defaults
|
|
231
|
+
- [ ] No `any` types without justification
|
|
232
|
+
|
|
233
|
+
**🟢 Nice to Have:**
|
|
234
|
+
- [ ] Arrow functions for callbacks
|
|
235
|
+
- [ ] Destructuring for cleaner code
|
|
236
|
+
- [ ] Type guards for type safety
|
|
237
|
+
- [ ] Utility types (Partial, Required, etc.)
|
|
238
|
+
|
|
239
|
+
**Code quality is the foundation - fix these issues before performance optimization.**
|