@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.
Files changed (99) hide show
  1. package/cli.js +63 -0
  2. package/dist/__tests__/checkpoint.test.d.ts +2 -0
  3. package/dist/__tests__/checkpoint.test.d.ts.map +1 -0
  4. package/dist/__tests__/fs-handler-decode.test.d.ts +2 -0
  5. package/dist/__tests__/fs-handler-decode.test.d.ts.map +1 -0
  6. package/dist/__tests__/idle-sweeper.test.d.ts +2 -0
  7. package/dist/__tests__/idle-sweeper.test.d.ts.map +1 -0
  8. package/dist/__tests__/mcp-config.test.d.ts +2 -0
  9. package/dist/__tests__/mcp-config.test.d.ts.map +1 -0
  10. package/dist/__tests__/schedule-runtime-spawn.test.d.ts +2 -0
  11. package/dist/__tests__/schedule-runtime-spawn.test.d.ts.map +1 -0
  12. package/dist/__tests__/schedule-runtime.test.d.ts +2 -0
  13. package/dist/__tests__/schedule-runtime.test.d.ts.map +1 -0
  14. package/dist/__tests__/session-limit.test.d.ts +2 -0
  15. package/dist/__tests__/session-limit.test.d.ts.map +1 -0
  16. package/dist/__tests__/swarm-cli-client.test.d.ts +2 -0
  17. package/dist/__tests__/swarm-cli-client.test.d.ts.map +1 -0
  18. package/dist/__tests__/swarm-control-dispatch.test.d.ts +2 -0
  19. package/dist/__tests__/swarm-control-dispatch.test.d.ts.map +1 -0
  20. package/dist/__tests__/swarm-session-bridge.test.d.ts +2 -0
  21. package/dist/__tests__/swarm-session-bridge.test.d.ts.map +1 -0
  22. package/dist/backend-adapter.d.ts +43 -0
  23. package/dist/backend-adapter.d.ts.map +1 -1
  24. package/dist/checkpoint.d.ts +67 -0
  25. package/dist/checkpoint.d.ts.map +1 -0
  26. package/dist/{chunk-RIK7IXSW.js → chunk-WJWCYGLQ.js} +1130 -147
  27. package/dist/chunk-WJWCYGLQ.js.map +1 -0
  28. package/dist/errors.d.ts +40 -0
  29. package/dist/errors.d.ts.map +1 -0
  30. package/dist/fs-handler.d.ts.map +1 -1
  31. package/dist/hub-connection.d.ts +13 -0
  32. package/dist/hub-connection.d.ts.map +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/schedule-runtime.d.ts +125 -0
  35. package/dist/schedule-runtime.d.ts.map +1 -0
  36. package/dist/session-manager.d.ts +102 -0
  37. package/dist/session-manager.d.ts.map +1 -1
  38. package/dist/skill-loader.d.ts +20 -0
  39. package/dist/skill-loader.d.ts.map +1 -1
  40. package/dist/start.d.ts +2 -0
  41. package/dist/start.d.ts.map +1 -1
  42. package/dist/start.js +1 -1
  43. package/dist/swarm-cli-client.d.ts +24 -0
  44. package/dist/swarm-cli-client.d.ts.map +1 -0
  45. package/dist/swarm-cli-client.js +83 -0
  46. package/dist/swarm-cli-client.js.map +1 -0
  47. package/dist/swarm-control-dispatch.d.ts +47 -0
  48. package/dist/swarm-control-dispatch.d.ts.map +1 -0
  49. package/dist/swarm-session-bridge.d.ts +22 -0
  50. package/dist/swarm-session-bridge.d.ts.map +1 -0
  51. package/package.json +6 -4
  52. package/skills/cocos-creator-3x-cn/SKILL.md +475 -0
  53. package/skills/cocos-creator-3x-cn/references/framework/asset-management.md +322 -0
  54. package/skills/cocos-creator-3x-cn/references/framework/component-system.md +348 -0
  55. package/skills/cocos-creator-3x-cn/references/framework/event-patterns.md +410 -0
  56. package/skills/cocos-creator-3x-cn/references/framework/playable-optimization.md +257 -0
  57. package/skills/cocos-creator-3x-cn/references/language/performance.md +363 -0
  58. package/skills/cocos-creator-3x-cn/references/language/quality-hygiene.md +307 -0
  59. package/skills/cocos-creator-3x-cn/references/review/architecture-review.md +183 -0
  60. package/skills/cocos-creator-3x-cn/references/review/quality-review.md +251 -0
  61. package/skills/cocos-performance-optimizer/SKILL.md +214 -0
  62. package/skills/game-development/2d-games/SKILL.md +129 -0
  63. package/skills/game-development/3d-games/SKILL.md +145 -0
  64. package/skills/game-development/SKILL.md +175 -0
  65. package/skills/game-development/game-art/SKILL.md +195 -0
  66. package/skills/game-development/game-audio/SKILL.md +200 -0
  67. package/skills/game-development/game-design/SKILL.md +139 -0
  68. package/skills/game-development/mobile-games/SKILL.md +118 -0
  69. package/skills/game-development/multiplayer/SKILL.md +142 -0
  70. package/skills/game-development/pc-games/SKILL.md +154 -0
  71. package/skills/game-development/vr-ar/SKILL.md +133 -0
  72. package/skills/game-development/web-games/SKILL.md +160 -0
  73. package/skills/game-engine/SKILL.md +140 -0
  74. package/skills/game-engine/assets/2d-maze-game.md +528 -0
  75. package/skills/game-engine/assets/2d-platform-game.md +1855 -0
  76. package/skills/game-engine/assets/gameBase-template-repo.md +310 -0
  77. package/skills/game-engine/assets/paddle-game-template.md +1528 -0
  78. package/skills/game-engine/assets/simple-2d-engine.md +507 -0
  79. package/skills/game-engine/references/3d-web-games.md +754 -0
  80. package/skills/game-engine/references/algorithms.md +843 -0
  81. package/skills/game-engine/references/basics.md +343 -0
  82. package/skills/game-engine/references/game-control-mechanisms.md +617 -0
  83. package/skills/game-engine/references/game-engine-core-principles.md +695 -0
  84. package/skills/game-engine/references/game-publishing.md +352 -0
  85. package/skills/game-engine/references/techniques.md +894 -0
  86. package/skills/game-engine/references/terminology.md +354 -0
  87. package/skills/game-engine/references/web-apis.md +1394 -0
  88. package/skills/theone-cocos-standards/SKILL.md +557 -0
  89. package/skills/theone-cocos-standards/references/framework/component-system.md +645 -0
  90. package/skills/theone-cocos-standards/references/framework/event-patterns.md +433 -0
  91. package/skills/theone-cocos-standards/references/framework/playable-optimization.md +429 -0
  92. package/skills/theone-cocos-standards/references/framework/size-optimization.md +308 -0
  93. package/skills/theone-cocos-standards/references/language/modern-typescript.md +658 -0
  94. package/skills/theone-cocos-standards/references/language/performance.md +580 -0
  95. package/skills/theone-cocos-standards/references/language/quality-hygiene.md +582 -0
  96. package/skills/theone-cocos-standards/references/review/architecture-review.md +250 -0
  97. package/skills/theone-cocos-standards/references/review/performance-review.md +288 -0
  98. package/skills/theone-cocos-standards/references/review/quality-review.md +239 -0
  99. package/dist/chunk-RIK7IXSW.js.map +0 -1
@@ -0,0 +1,343 @@
1
+ # Game Development Basics
2
+
3
+ A comprehensive reference covering web game development technologies, game architecture, and the anatomy of a game loop.
4
+
5
+ Sources:
6
+ - https://developer.mozilla.org/en-US/docs/Games/Introduction
7
+ - https://developer.mozilla.org/en-US/docs/Games/Anatomy
8
+
9
+ ---
10
+
11
+ ## Web Technologies for Game Development
12
+
13
+ ### Graphics and Rendering
14
+
15
+ - **WebGL** -- Hardware-accelerated 2D and 3D graphics based on OpenGL ES 2.0. Provides direct GPU access for high-performance rendering.
16
+ - **Canvas API** -- 2D drawing surface via the `<canvas>` element. Suitable for 2D games, sprite rendering, and pixel manipulation.
17
+ - **SVG** -- Scalable Vector Graphics for resolution-independent visuals. Useful for UI elements and simple vector-based games.
18
+ - **HTML/CSS** -- Standard web technologies for building game UI, menus, HUDs, and overlays.
19
+
20
+ ### Audio
21
+
22
+ - **Web Audio API** -- Advanced audio engine supporting real-time playback, synthesis, spatial audio, effects processing, and dynamic mixing.
23
+ - **HTML Audio Element** -- Simple sound playback for background music and basic sound effects.
24
+
25
+ ### Input and Controls
26
+
27
+ - **Gamepad API** -- Support for game controllers and gamepads, including button mapping and analog stick input.
28
+ - **Touch Events API** -- Multi-touch input handling for mobile devices.
29
+ - **Pointer Lock API** -- Locks the mouse cursor within the game area and provides raw coordinate deltas for precise camera/aiming control.
30
+ - **Device Sensors** -- Accelerometer and gyroscope access for motion-based input.
31
+ - **Full Screen API** -- Enables immersive full-screen game experiences.
32
+
33
+ ### Networking and Multiplayer
34
+
35
+ - **WebSockets API** -- Persistent, bidirectional communication channel for real-time multiplayer, chat, and live updates.
36
+ - **WebRTC API** -- Peer-to-peer connections for low-latency multiplayer, voice chat, and data channels.
37
+ - **Fetch API** -- HTTP requests for downloading game assets, loading level data, and transmitting non-real-time game state.
38
+
39
+ ### Data Storage and Performance
40
+
41
+ - **IndexedDB API** -- Client-side structured storage for save games, cached assets, and offline play support.
42
+ - **Typed Arrays** -- Direct access to raw binary data buffers for GL textures, audio samples, and compact game data.
43
+ - **Web Workers API** -- Background thread execution for offloading heavy computations (physics, pathfinding, AI) without blocking the main thread.
44
+
45
+ ### Languages and Compilation
46
+
47
+ - **JavaScript** -- The primary language for web game development.
48
+ - **C/C++ via Emscripten** -- Compile existing native game code to JavaScript or WebAssembly for web deployment.
49
+ - **WebAssembly (Wasm)** -- Near-native execution speed for performance-critical game code.
50
+
51
+ ---
52
+
53
+ ## Types of Games You Can Build
54
+
55
+ The modern web platform supports a full range of game types:
56
+
57
+ - 3D action games and shooters
58
+ - Role-playing games (RPGs)
59
+ - 2D platformers and side-scrollers
60
+ - Puzzle and strategy games
61
+ - Card and board games
62
+ - Casual and mobile-friendly games
63
+ - Multiplayer experiences with real-time networking
64
+
65
+ ---
66
+
67
+ ## Advantages of Web-Based Game Development
68
+
69
+ 1. **Universal reach** -- Games run on smartphones, tablets, PCs, and Smart TVs through the browser.
70
+ 2. **No app store dependency** -- Deploy directly on the web without store approval processes.
71
+ 3. **Full revenue control** -- No mandatory revenue share; use any payment processing system.
72
+ 4. **Instant updates** -- Push updates immediately without waiting for store review.
73
+ 5. **Own your analytics** -- Collect your own data or choose any analytics provider.
74
+ 6. **Direct player relationships** -- Engage players without intermediaries.
75
+ 7. **Inherent shareability** -- Games are linkable and discoverable via standard web mechanisms.
76
+
77
+ ---
78
+
79
+ ## Anatomy of a Game Loop
80
+
81
+ Every game operates through a continuous cycle of steps:
82
+
83
+ 1. **Present** -- Display the current game state to the player.
84
+ 2. **Accept** -- Receive user input (keyboard, mouse, gamepad, touch).
85
+ 3. **Interpret** -- Process raw input into meaningful game actions.
86
+ 4. **Calculate** -- Update the game state based on actions, physics, AI, and time.
87
+ 5. **Repeat** -- Loop back to present the updated state.
88
+
89
+ Games may be **event-driven** (turn-based, waiting for player action) or **per-frame** (continuously updating via a main loop).
90
+
91
+ ---
92
+
93
+ ## Building a Game Loop with requestAnimationFrame
94
+
95
+ ### Basic Main Loop
96
+
97
+ ```javascript
98
+ window.main = () => {
99
+ window.requestAnimationFrame(main);
100
+
101
+ // Your game logic here: update state, render frame
102
+ };
103
+
104
+ main(); // Start the cycle
105
+ ```
106
+
107
+ Key points:
108
+ - `requestAnimationFrame()` synchronizes callbacks to the browser's repaint schedule (typically 60 Hz).
109
+ - Schedule the next frame **before** performing loop work to maximize available computation time.
110
+
111
+ ### Self-Contained Main Loop (IIFE)
112
+
113
+ ```javascript
114
+ ;(() => {
115
+ function main() {
116
+ window.requestAnimationFrame(main);
117
+
118
+ // Game logic here
119
+ }
120
+
121
+ main();
122
+ })();
123
+ ```
124
+
125
+ ### Stoppable Main Loop
126
+
127
+ ```javascript
128
+ ;(() => {
129
+ function main() {
130
+ MyGame.stopMain = window.requestAnimationFrame(main);
131
+
132
+ // Game logic here
133
+ }
134
+
135
+ main();
136
+ })();
137
+
138
+ // To stop the loop:
139
+ window.cancelAnimationFrame(MyGame.stopMain);
140
+ ```
141
+
142
+ ---
143
+
144
+ ## Timing and Frame Rate
145
+
146
+ ### DOMHighResTimeStamp
147
+
148
+ `requestAnimationFrame` passes a `DOMHighResTimeStamp` to your callback, providing timing precision to 1/1000th of a millisecond.
149
+
150
+ ```javascript
151
+ ;(() => {
152
+ function main(tFrame) {
153
+ MyGame.stopMain = window.requestAnimationFrame(main);
154
+
155
+ // tFrame is a high-resolution timestamp in milliseconds
156
+ // Use it for delta-time calculations
157
+ }
158
+
159
+ main();
160
+ })();
161
+ ```
162
+
163
+ ### Frame Time Budget
164
+
165
+ At 60 Hz, each frame has approximately **16.67ms** of available processing time. The browser's frame cycle is:
166
+
167
+ 1. Start new frame (previous frame displayed to screen)
168
+ 2. Execute `requestAnimationFrame` callbacks
169
+ 3. Perform garbage collection and per-frame browser tasks
170
+ 4. Sleep until VSync, then repeat
171
+
172
+ ---
173
+
174
+ ## Simple Update and Render Pattern
175
+
176
+ The simplest approach when your game can sustain the target frame rate:
177
+
178
+ ```javascript
179
+ ;(() => {
180
+ function main(tFrame) {
181
+ MyGame.stopMain = window.requestAnimationFrame(main);
182
+
183
+ update(tFrame); // Process game logic
184
+ render(); // Draw the frame
185
+ }
186
+
187
+ main();
188
+ })();
189
+ ```
190
+
191
+ Assumptions:
192
+ - Each frame can process input and update state within the time budget.
193
+ - The simulation runs at the same rate as the display refresh (typically ~60 FPS).
194
+ - No frame interpolation is needed.
195
+
196
+ ---
197
+
198
+ ## Decoupled Update and Render with Fixed Timestep
199
+
200
+ For robust handling of variable refresh rates and consistent simulation behavior:
201
+
202
+ ```javascript
203
+ ;(() => {
204
+ function main(tFrame) {
205
+ MyGame.stopMain = window.requestAnimationFrame(main);
206
+ const nextTick = MyGame.lastTick + MyGame.tickLength;
207
+ let numTicks = 0;
208
+
209
+ // Calculate how many simulation updates are needed
210
+ if (tFrame > nextTick) {
211
+ const timeSinceTick = tFrame - MyGame.lastTick;
212
+ numTicks = Math.floor(timeSinceTick / MyGame.tickLength);
213
+ }
214
+
215
+ queueUpdates(numTicks);
216
+ render(tFrame);
217
+ MyGame.lastRender = tFrame;
218
+ }
219
+
220
+ function queueUpdates(numTicks) {
221
+ for (let i = 0; i < numTicks; i++) {
222
+ MyGame.lastTick += MyGame.tickLength;
223
+ update(MyGame.lastTick);
224
+ }
225
+ }
226
+
227
+ MyGame.lastTick = performance.now();
228
+ MyGame.lastRender = MyGame.lastTick;
229
+ MyGame.tickLength = 50; // 20 Hz simulation rate (50ms per tick)
230
+
231
+ setInitialState();
232
+ main(performance.now());
233
+ })();
234
+ ```
235
+
236
+ Benefits:
237
+ - **Deterministic simulation** -- Game logic runs at a fixed frequency regardless of display refresh rate.
238
+ - **Smooth rendering** -- Rendering can interpolate between simulation states for visual smoothness.
239
+ - **Portable behavior** -- Game behaves the same on 60 Hz, 120 Hz, and 144 Hz displays.
240
+
241
+ ---
242
+
243
+ ## Alternative Architecture Patterns
244
+
245
+ ### Separate setInterval for Updates
246
+
247
+ ```javascript
248
+ // Game logic updates at a fixed rate
249
+ setInterval(() => {
250
+ update();
251
+ }, 50); // 20 Hz
252
+
253
+ // Rendering synchronized to display
254
+ requestAnimationFrame(function render(tFrame) {
255
+ requestAnimationFrame(render);
256
+ draw();
257
+ });
258
+ ```
259
+
260
+ Drawback: `setInterval` continues running even when the tab is not visible, wasting resources.
261
+
262
+ ### Web Worker for Updates
263
+
264
+ ```javascript
265
+ // Heavy game logic runs in a background thread
266
+ const updateWorker = new Worker('game-update-worker.js');
267
+
268
+ requestAnimationFrame(function render(tFrame) {
269
+ requestAnimationFrame(render);
270
+ updateWorker.postMessage({ ticks: numTicksNeeded });
271
+ draw();
272
+ });
273
+ ```
274
+
275
+ Benefits: Does not block the main thread. Ideal for physics-heavy or AI-intensive games.
276
+ Drawback: Communication overhead between worker and main thread.
277
+
278
+ ### requestAnimationFrame Driving a Web Worker
279
+
280
+ ```javascript
281
+ ;(() => {
282
+ function main(tFrame) {
283
+ MyGame.stopMain = window.requestAnimationFrame(main);
284
+
285
+ // Signal worker to compute updates
286
+ updateWorker.postMessage({
287
+ lastTick: MyGame.lastTick,
288
+ numTicks: calculatedNumTicks
289
+ });
290
+
291
+ render(tFrame);
292
+ }
293
+
294
+ main();
295
+ })();
296
+ ```
297
+
298
+ Benefits: No reliance on legacy timers. Worker performs computation in parallel.
299
+
300
+ ---
301
+
302
+ ## Handling Tab Focus Loss
303
+
304
+ When a browser tab loses focus, `requestAnimationFrame` slows down or stops entirely. Strategies:
305
+
306
+ | Strategy | Description | Best For |
307
+ |---|---|---|
308
+ | Treat gap as pause | Skip elapsed time; do not update | Single-player games |
309
+ | Simulate the gap | Run all missed updates on regain | Simple simulations |
310
+ | Sync from server/peer | Fetch authoritative state | Multiplayer games |
311
+
312
+ Monitor the `numTicks` value after a focus-regain event. A very large value indicates the game was suspended and may need special handling rather than trying to simulate all missed frames.
313
+
314
+ ---
315
+
316
+ ## Comparison of Timing Approaches
317
+
318
+ | Approach | Pros | Cons |
319
+ |---|---|---|
320
+ | Simple update/render per frame | Easy to implement, responsive | Breaks on slow/fast hardware |
321
+ | Fixed timestep + interpolation | Consistent simulation, smooth visuals | More complex to implement |
322
+ | Quality scaling | Maintains frame rate dynamically | Requires adaptive quality systems |
323
+
324
+ ---
325
+
326
+ ## Performance Best Practices
327
+
328
+ - **Detach non-frame-critical code** from the main loop. Use events and callbacks for UI, network responses, and other asynchronous operations.
329
+ - **Use Web Workers** for computationally expensive tasks like physics, pathfinding, and AI.
330
+ - **Leverage GPU acceleration** through WebGL for rendering.
331
+ - **Stay within the frame budget** -- monitor your update + render time to keep it under 16.67ms for 60 FPS.
332
+ - **Throttle garbage collection pressure** by reusing objects and avoiding per-frame allocations.
333
+ - **Plan your timing strategy early** -- changing the game loop architecture mid-development is difficult and error-prone.
334
+
335
+ ---
336
+
337
+ ## Popular 3D Frameworks and Libraries
338
+
339
+ - **Three.js** -- General-purpose 3D library with a large ecosystem.
340
+ - **Babylon.js** -- Full-featured 3D game engine with physics, audio, and scene management.
341
+ - **A-Frame** -- Declarative 3D/VR framework built on Three.js.
342
+ - **PlayCanvas** -- Cloud-hosted 3D game engine with a visual editor.
343
+ - **Phaser** -- Popular 2D game framework with physics and input handling.