@pinkaphant/kolmo 0.4.5 → 0.4.6

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/AGENTS.md ADDED
@@ -0,0 +1,29 @@
1
+ # `@pinkaphant/kolmo` — Agent & Contributor Guide
2
+
3
+ `Kolmo` is a Kolmogorov-complexity 3D game engine where humans and AI agents share agency at every step — from `npx @pinkaphant/kolmo create` templates to declarative `<Game>` entities (`<Vehicle>`, `<Actor>`, `<Island>`, `<LongDrive>`, `<Sand3D>`, `<Junk>`, `<SuikaSystem>`) and live in-browser `navigator.modelContext` WebMCP tools (`useImporterWebMcp`).
4
+
5
+ ---
6
+
7
+ ## 1. Shared Human + AI Agency Workflow
8
+
9
+ 1. **Scaffold in One Command**: Run `npx @pinkaphant/kolmo create <dir> --template game|longline|dust|garage` ([bin/kolmo.mjs](./bin/kolmo.mjs)) to generate a runnable Vite 8 + TypeScript + Cloudflare Worker (`wrangler.jsonc`) app with pinned physics overrides.
10
+ 2. **Compose Self-Contained Entities**: Drop `<Vehicle>`, `<Actor>`, `<Island>`, `<LongDrive>`, `<Sand3D>`, `<Junk>`, `<SuikaSystem>`, `<Hud>`, and `<MobileTouchOverlay />` inside `<Game>` ([src/engine/kolmoGame.tsx](./src/engine/kolmoGame.tsx)). Each entity registers its own Koota ECS traits, Rapier colliders/joints, `KOLMO_emitter` VFX plumes, and `0.08`-deadzone touch bindings automatically.
11
+ 3. **Co-Author Assets via WebMCP & Import Gate**: Mount `<GlbImportGate />` ([src/importer/GlbImportGate.tsx](./src/importer/GlbImportGate.tsx)) to calibrate `.glb`, `.gltf`, OpenUSD (`.usd*`), or `.sand3d` Code-CAD scripts across 8 domains (`vehicle | c12 | launcher | person | prop | junk | suika | sand3d`). Browser-connected AI agents inspect and drive the exact same workbench through the 12 tools in [src/importer/importerWebMcpTools.ts](./src/importer/importerWebMcpTools.ts) (`importer_state`, `importer_capture_view`, `importer_load`, `importer_orient`, `importer_scale`, `importer_set_kind`, `importer_pop_wheels`, `importer_cut_part`, `importer_set_points`, `importer_export`).
12
+
13
+ ---
14
+
15
+ ## 2. Core Technical Architecture
16
+
17
+ - **Pinned Stack**: `"@pinkaphant/ecctrl": "2.0.4-beta.4"`, `"@dimforge/rapier3d-compat": "0.19.2"`, `"three": "0.184.0"`, `"@react-three/fiber": "^9.6.1"`, `"@react-three/rapier": "^2.2.0"`, `"koota": "^0.6.5"`, bundled via `@pinkaphant/kolmo/vite` (`externalizeRapierWasm()`, `KOLMO_SINGLETON_DEDUPE`, `KOLMO_ROLLDOWN_BUILD`).
18
+ - **Imperative R3F Loop (`useRef` + `useFrame`)**: Step Rapier inside `<KolmoPhysics>` (`<Physics paused timeStep="vary">` + `<TimeControl maxDelta={1 / 30}>`), reading `rapierWorld.timestep` and transient store state (`useGateStore.getState()`) with module-scoped scratch vectors. Drive `<KolmoHud>` and `<MobileTouchOverlay>` at 60 Hz through DOM `ref.current` mutations.
19
+ - **Koota SoA ECS**: Mutate `TransformTrait`, `VelocityTrait`, and `VehicleTelemetryTrait` in place via `.updateEach(..., { changeDetection: "never" })` or `writeEntityKinematics` / `writeVehicleTelemetry` ([src/engine/kolmoTraits.ts](./src/engine/kolmoTraits.ts)), and link actors to vehicles with `PilotLink = relation({ exclusive: true })`.
20
+ - **Real Vehicle & C12 Physics**: Compile Fritsch–Carlson monotone Pacejka tire LUTs (`@khr3/core/curves`), SI corner-load suspension (`solveWheelLoads` on `@pinkaphant/ecctrl@2.0.4-beta.4`), volume-weighted chassis inertia (`deriveChassisGeometryPlan`), cylindrical boolean wheel coring (`sliceCarWheelCylinders`), and exact `Z[1/2, sqrt(3)]` 3.0 m `C12` modular batches (`@khr3/c12`).
21
+ - **Co-op Room Multiplayer**: Pair Koota entity traits (`TransformTrait`, `VelocityTrait`, `PilotLink`) with Cloudflare Durable Objects WebSocket Hibernation (`partyserver` `static options = { hibernate: true }` + `partysocket` + `serializeAttachment`) for 1–8 player room-code co-op sessions.
22
+
23
+ ---
24
+
25
+ ## 3. Commands & Module Hygiene
26
+
27
+ - Keep every `.ts` / `.tsx` source module focused (`<= 250` lines) with calm Title/Sentence UI copy, `100dvh`, `env(safe-area-inset-*)`, and `>= 44x44 px` touch targets.
28
+ - Run `npm run typecheck`, `npm test`, and `npm run build` (plus `npx vite build` for the interactive `dist-example/` home page) with exit code `0`.
29
+ - Full subpath signatures live in [README.md](./README.md), [docs/api-reference.md](./docs/api-reference.md), and the portable agent skill [skills/kolmo-engine/SKILL.md](./skills/kolmo-engine/SKILL.md).
package/CLAUDE.md ADDED
@@ -0,0 +1,8 @@
1
+ @AGENTS.md
2
+
3
+ # `@pinkaphant/kolmo` — Claude Code Guide
4
+
5
+ Follow [AGENTS.md](./AGENTS.md), [README.md](./README.md), [docs/api-reference.md](./docs/api-reference.md), and [skills/kolmo-engine/SKILL.md](./skills/kolmo-engine/SKILL.md):
6
+ - Pin `"@pinkaphant/ecctrl": "2.0.4-beta.4"`, `"@dimforge/rapier3d-compat": "0.19.2"`, and `"three": "0.184.0"`.
7
+ - Compose `<Game>`, `<Vehicle>`, `<Actor>`, `<Island>`, `<LongDrive>`, `<Sand3D>`, `<Junk>`, `<SuikaSystem>`, `<Hud>`, `<MobileTouchOverlay />`, and `<GlbImportGate enableWebMcp />` with Koota SoA traits (`{ changeDetection: "never" }`) and `<= 250`-line modules.
8
+ - Verify with `npm run typecheck && npm test && npm run build`.
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # `@pinkaphant/kolmo`
2
2
 
3
- Declarative 3D game runtime for React Three Fiber and Rapier (`@pinkaphant/ecctrl`), combining procedural C12 island and highway world generation, PS1/Dreamcast/PS2 shaders, destructible BVH props, golden-ratio `<SuikaOrb>` and `<SuikaSystem>` rigid bodies, declarative `<Sand3D>` Code-CAD assemblies, and an 8-domain GLB/USD/Sand3D calibration workbench (`vehicle | c12 | launcher | person | prop | junk | suika | sand3d`).
3
+ Declarative 3D game runtime for React Three Fiber and Rapier (`@pinkaphant/ecctrl`), built around **Kolmogorov-complexity exploration with shared Human + AI agency** — from `npx @pinkaphant/kolmo create` starter templates to self-contained `<Game>` entities (`<Vehicle>`, `<Actor>`, `<Island>`, `<LongDrive>`, `<Sand3D>`, `<Junk>`, `<SuikaSystem>`), procedural C12 island and highway world generation, PS1/Dreamcast/PS2 shaders, and an 8-domain GLB/USD/Sand3D calibration workbench (`vehicle | c12 | launcher | person | prop | junk | suika | sand3d`) wired to browser `navigator.modelContext` WebMCP tools.
4
+
5
+ - **Agent & Contributor Guide**: [AGENTS.md](./AGENTS.md)
6
+ - **Portable Agent Skill**: [skills/kolmo-engine/SKILL.md](./skills/kolmo-engine/SKILL.md)
7
+ - **API Reference**: [docs/api-reference.md](./docs/api-reference.md)
8
+ - **Interactive Engine Home Page & Studio**: [example/App.tsx](./example/App.tsx), [example/KolmoHomeOverlay.tsx](./example/KolmoHomeOverlay.tsx), [example/kolmoHomeData.ts](./example/kolmoHomeData.ts) (`npm run dev`)
4
9
 
5
10
  ## Installation
6
11
 
7
12
  ```bash
8
- npm install @pinkaphant/kolmo @khr3/core @khr3/c12 @khr3/assets @khr3/vehicles @khr3/launchers @pinkaphant/ecctrl@2.0.4-beta.2 @dimforge/rapier3d-compat@0.19.2
13
+ npm install @pinkaphant/kolmo @khr3/core @khr3/c12 @khr3/assets @khr3/vehicles @khr3/launchers @pinkaphant/ecctrl@2.0.4-beta.4 @dimforge/rapier3d-compat@0.19.2
9
14
  ```
10
15
 
11
16
  Pin physics runtime versions in `package.json` `overrides`:
@@ -14,7 +19,7 @@ Pin physics runtime versions in `package.json` `overrides`:
14
19
  {
15
20
  "overrides": {
16
21
  "@dimforge/rapier3d-compat": "0.19.2",
17
- "@pinkaphant/ecctrl": "2.0.4-beta.2"
22
+ "@pinkaphant/ecctrl": "2.0.4-beta.4"
18
23
  }
19
24
  }
20
25
  ```
package/bin/kolmo.mjs CHANGED
@@ -52,7 +52,7 @@ fs.writeFileSync(path.join(targetDir, "package.json"), JSON.stringify({
52
52
  },
53
53
  overrides: {
54
54
  "@dimforge/rapier3d-compat": "0.19.2",
55
- "@pinkaphant/ecctrl": "2.0.4-beta.2",
55
+ "@pinkaphant/ecctrl": "2.0.4-beta.4",
56
56
  },
57
57
  devDependencies: {
58
58
  "@types/node": "^22.20.5",
@@ -1,6 +1,6 @@
1
1
  # `@pinkaphant/kolmo` API Reference
2
2
 
3
- Declarative 3D game runtime combining React Three Fiber and Rapier (`@pinkaphant/ecctrl`), procedural C12 island and highway world generation, PS1/Dreamcast/PS2 shaders, offline PaperShell cars, destructible BVH props, golden-ratio Suika orbs, declarative `<Sand3D>` Code-CAD assemblies, and the 8-domain GLB/USD/Sand3D calibration workbench with cylindrical wheel coring.
3
+ Declarative 3D game runtime combining React Three Fiber and Rapier (`@pinkaphant/ecctrl@2.0.4-beta.4`), procedural C12 island and highway world generation, PS1/Dreamcast/PS2 shaders, parametric Kolmogorov math cars and math trucks, destructible BVH props, golden-ratio Suika orbs, declarative `<Sand3D>` Code-CAD assemblies, and the 8-domain GLB/USD/Sand3D calibration workbench with cylindrical wheel coring.
4
4
 
5
5
  ## Subpath Exports
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinkaphant/kolmo",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Low-overhead retro 3D game runtime: declarative React Three Fiber world & vehicle engine, C12 road/island/long-drive generator, PS1/Dreamcast/PS2 retro shader stack, and GLB import calibration gate.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -68,9 +68,12 @@
68
68
  "files": [
69
69
  "dist",
70
70
  "docs",
71
+ "skills",
72
+ "AGENTS.md",
71
73
  "bin",
72
74
  "LICENSE",
73
- "README.md"
75
+ "README.md",
76
+ "CLAUDE.md"
74
77
  ],
75
78
  "publishConfig": {
76
79
  "access": "public"
@@ -94,11 +97,11 @@
94
97
  },
95
98
  "overrides": {
96
99
  "@dimforge/rapier3d-compat": "0.19.2",
97
- "@pinkaphant/ecctrl": "2.0.4-beta.2"
100
+ "@pinkaphant/ecctrl": "2.0.4-beta.4"
98
101
  },
99
102
  "peerDependencies": {
100
103
  "@dimforge/rapier3d-compat": "0.19.2",
101
- "@pinkaphant/ecctrl": "2.0.4-beta.2",
104
+ "@pinkaphant/ecctrl": "2.0.4-beta.4",
102
105
  "@react-three/drei": "^10.7.7",
103
106
  "@react-three/fiber": "^9.0.0",
104
107
  "@react-three/rapier": "^2.2.0",
@@ -110,7 +113,7 @@
110
113
  },
111
114
  "devDependencies": {
112
115
  "@dimforge/rapier3d-compat": "0.19.2",
113
- "@pinkaphant/ecctrl": "2.0.4-beta.2",
116
+ "@pinkaphant/ecctrl": "2.0.4-beta.4",
114
117
  "@react-three/drei": "^10.7.7",
115
118
  "@react-three/fiber": "^9.6.1",
116
119
  "@react-three/rapier": "^2.2.0",
@@ -140,7 +143,7 @@
140
143
  ],
141
144
  "repository": {
142
145
  "type": "git",
143
- "url": "git+https://github.com/pinkAphant/kolmo.git"
146
+ "url": "git+https://github.com/pinkAphant/Kolmo.git"
144
147
  },
145
148
  "homepage": "https://github.com/pinkAphant/kolmo#readme",
146
149
  "bugs": {
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: kolmo-engine
3
+ description: Build, extend, calibrate, and network 3D games on @pinkaphant/kolmo (Kolmogorov Game Engine) using declarative R3F entities (<Game>, <Vehicle>, <Actor>, <Island>, <LongDrive>, <Sand3D>, <Junk>, <SuikaSystem>), Koota SoA ECS, @khr3/* physics/C12 packages, WebMCP asset tools, and PartyServer + PartySocket Cloudflare Durable Object co-op rooms.
4
+ ---
5
+
6
+ # Kolmo Game Engine Skill (`@pinkaphant/kolmo`)
7
+
8
+ Use this skill whenever building or extending a game, vehicle, C12 world, `.glb`/`.usd`/`.sand3d` asset pipeline, WebMCP integration, or 1–8 player co-op room with `@pinkaphant/kolmo`.
9
+
10
+ ## 1. Quick Scaffold & Pinned `package.json`
11
+
12
+ Scaffold a fresh project in one command:
13
+
14
+ ```bash
15
+ npx @pinkaphant/kolmo create my-game --template game # game | longline | dust | garage
16
+ ```
17
+
18
+ Keep physics and Three.js singletons pinned in `package.json` and `vite.config.ts`:
19
+
20
+ ```json
21
+ {
22
+ "dependencies": {
23
+ "@dimforge/rapier3d-compat": "0.19.2",
24
+ "@pinkaphant/ecctrl": "2.0.4-beta.4",
25
+ "@pinkaphant/kolmo": "^0.4.5",
26
+ "koota": "^0.6.6",
27
+ "three": "0.184.0"
28
+ },
29
+ "overrides": {
30
+ "@dimforge/rapier3d-compat": "0.19.2",
31
+ "@pinkaphant/ecctrl": "2.0.4-beta.4",
32
+ "three": "0.184.0"
33
+ }
34
+ }
35
+ ```
36
+
37
+ ```ts
38
+ import react from "@vitejs/plugin-react";
39
+ import { defineConfig } from "vite";
40
+ import { KOLMO_ROLLDOWN_BUILD, KOLMO_SINGLETON_DEDUPE, externalizeRapierWasm } from "@pinkaphant/kolmo/vite";
41
+
42
+ export default defineConfig({
43
+ plugins: [react(), externalizeRapierWasm()],
44
+ resolve: { dedupe: KOLMO_SINGLETON_DEDUPE },
45
+ build: KOLMO_ROLLDOWN_BUILD,
46
+ });
47
+ ```
48
+
49
+ ## 2. Declarative Entities That Take Care of Everything
50
+
51
+ Mount self-contained entities inside `<Game>`:
52
+
53
+ ```tsx
54
+ import { Actor, Game, Hud, Island, Junk, MobileTouchOverlay, Sand3D, SuikaSystem, Vehicle } from "@pinkaphant/kolmo";
55
+
56
+ export function App() {
57
+ return (
58
+ <Game retro="dreamcast" skybox="day">
59
+ <Island seed={77} size={960} settlementTier="town" />
60
+ {/* Drop any raw or KHR-rigged .glb URL/bytes — Kolmo auto-scales SI meters, cores wheels, and solves SI corner-load suspension! */}
61
+ <Vehicle src="/cars/rally_coupe.glb" horsepower={320} piloted />
62
+ <Sand3D recipe="hinged_ammo_chest" position={[4.5, 1.2, 6]} />
63
+ <Junk id="crate_01" position={[-4.5, 1.2, 6]} />
64
+ <SuikaSystem />
65
+ <Actor />
66
+ <Hud />
67
+ <MobileTouchOverlay />
68
+ </Game>
69
+ );
70
+ }
71
+ ```
72
+
73
+ - **`<Vehicle>`**: Accepts `preset` (`PAPER_SHELL_PRESETS`), `src` (URL), `rawGlbBytes`, or `bundle`. Uncalibrated 1-mesh car `.glb` files are automatically normalized to SI meters (`+Y` up, `+Z` forward, `[1, 1, 1]` scale), wheel-cored, and tuned with Pacejka curves + SI corner-load suspension (`solveWheelLoads` on `@pinkaphant/ecctrl@2.0.4-beta.4`) via `loadOrAutoCompileVehicleGlb`.
74
+ - **`<Sand3D>`**: Compiles `.sand3d` Code-CAD scripts, `SAND3D_RECIPES`, OpenUSD, or `.glb` files and mounts `<KolmoVehicle>` (if wheels/propellers exist) or `<KolmoProp>` (for articulated KHR joints).
75
+ - **`<Actor>` + `<Hud>` + `<MobileTouchOverlay />`**: Provides `Ecctrl` character movement, `[F]` vehicle boarding/exiting (`PilotLink`), 60 Hz DOM-ref HUD telemetry, and `0.08`-deadzone mobile landscape controls.
76
+
77
+ ## 3. Imperative R3F + Koota SoA ECS Pattern
78
+
79
+ - **Mutate via `useRef` + `useFrame`**: Reuse module-level `THREE.Vector3` / `Quaternion` / `Matrix4` objects inside `useFrame((_, delta) => ...)`. Read `rapierWorld.timestep` when syncing with Rapier.
80
+ - **Koota SoA Fast Path**: Write continuous entity kinematics directly into Koota's typed arrays with `{ changeDetection: "never" }` or `writeEntityKinematics`:
81
+
82
+ ```ts
83
+ import { PositionTrait, VelocityTrait } from "./traits";
84
+
85
+ world.query(PositionTrait, VelocityTrait).updateEach(
86
+ ([pos, vel]) => {
87
+ pos.x += vel.vx * dt;
88
+ pos.y += vel.vy * dt;
89
+ pos.z += vel.vz * dt;
90
+ },
91
+ { changeDetection: "never" },
92
+ );
93
+ ```
94
+
95
+ - **Exact 3.0 m C12 Instancing**: Place modular walls, floors, foundations, doorways, and roofs using `@khr3/c12` (`yaw12` `0..11` `30°` steps in `Z[1/2, sqrt(3)]`) and batch into single draw calls with `instanceBatches(pieces)`.
96
+
97
+ ## 4. Shared Human + AI Agency via WebMCP (`@pinkaphant/kolmo/importer`)
98
+
99
+ When `<GlbImportGate enableWebMcp />` is mounted, browser agents access `navigator.modelContext` (or invoke `createImporterWebMcpTools` directly in tests/automation):
100
+
101
+ 1. `importer_state` / `importer_capture_view` — Inspect bounds, wheel count, calibration lock, and viewport PNG.
102
+ 2. `importer_list_models` / `importer_load` — Browse catalog or load any `.glb` URL / vault key.
103
+ 3. `importer_set_kind` / `importer_orient` / `importer_scale` — Choose domain (`vehicle | c12 | launcher | person | prop | junk | suika`), rotate in exact 90° turns, and normalize to SI meters (`Y = 0` ground contact).
104
+ 4. `importer_pop_wheels` / `importer_cut_part` / `importer_set_points` — Detect axles, peel hinged doors/hoods/trunks, and stamp `seat`, `muzzle`, `grip_primary`, or `thruster` sockets.
105
+ 5. `importer_export` — Bake compliant `KHR_physics_rigid_bodies` `.glb` bytes or spawn straight into the live `<Game>` world (`{ spawnInWorld: true }`).
106
+
107
+ ## 5. Co-op Room Multiplayer (1–8 Players, Hibernating Cloudflare DO)
108
+
109
+ For Valheim/Grounded-style peer-simulated co-op rooms by room code:
110
+ - **Server (`partyserver`)**: Subclass `Server` with `static options = { hibernate: true }`, assign a server-generated connection ID on upgrade, persist compact per-peer state (`pos`, `quat`, `vehicleId`, `callsign`, C12/world deltas `<= 2 KB`) via `conn.serializeAttachment(...)` / `conn.setState(...)`, rehydrate open sockets on wake via `deserializeAttachment()`, and broadcast room events to the 1–8 peers.
111
+ - **Client (`partysocket` + Koota)**: Connect by room code (`room: code`), throttle outbound local Koota `TransformTrait` / `PilotLink` snapshots to `15–20 Hz`, and interpolate remote peer entities in `useFrame` with `1 - Math.exp(-12 * dt)` damping.