Initial Commit
This commit is contained in:
144
openspec/changes/enterprise-gaming-weather/proposal.md
Normal file
144
openspec/changes/enterprise-gaming-weather/proposal.md
Normal file
@@ -0,0 +1,144 @@
|
||||
# OpenSpec Change: enterprise-gaming-weather
|
||||
|
||||
- **Change ID**: enterprise-gaming-weather
|
||||
- **Package**: `@suaveplan/weather`
|
||||
- **Category**: gaming/world
|
||||
- **Target path**: `gaming/world/weather`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/weather.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/weather` on the genesis branch from scratch at enterprise quality. The package provides dynamic weather simulation with smooth transitions, regional zones, and gameplay effects. A `WeatherSystem` holds the current `WeatherState` (temperature, precipitation, wind, visibility, lightning) and advances it by transitioning toward a `WeatherPreset`; `WeatherZone` maps world regions to preset overrides; a `WeatherTransition` interpolates between two presets over a configurable duration. Genesis adds Zod preset schemas, structured errors, OTel weather-state gauge, injectable clock and RNG, and 100% coverage.
|
||||
|
||||
---
|
||||
|
||||
## Current-state audit (genesis)
|
||||
|
||||
Package does not exist on genesis yet — fresh build.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/error` (`workspace:^`) | `WeatherError`; `WEATHER.*` codes |
|
||||
| `@suaveplan/types` (`workspace:^`) | `Clock`, `Rng` |
|
||||
| `@suaveplan/events` (`workspace:^`) | `weather:changed`, `weather:lightning`, `weather:zone_entered` events |
|
||||
| `@suaveplan/day-night` (`workspace:^`) | `DayNightClock` for time-based weather probability |
|
||||
| `zod` (`catalog:forms`) | `WeatherPreset`, `WeatherZone` schemas |
|
||||
| `@opentelemetry/api` (`catalog:observability`) | Weather-state change counter |
|
||||
|
||||
---
|
||||
|
||||
## Public API surface
|
||||
|
||||
```ts
|
||||
interface WeatherPreset {
|
||||
name: string
|
||||
temperature: number // celsius
|
||||
precipitation: number // 0–1
|
||||
windSpeed: number // m/s
|
||||
windDirection: number // degrees
|
||||
visibility: number // 0–1 (1=clear, 0=zero visibility)
|
||||
fogDensity: number // 0–1
|
||||
cloudCover: number // 0–1
|
||||
lightningProbability?: number // per-minute probability 0–1
|
||||
}
|
||||
|
||||
interface WeatherState extends WeatherPreset {
|
||||
readonly isTransitioning: boolean
|
||||
readonly transitionProgress: number // 0–1
|
||||
}
|
||||
|
||||
function createWeatherSystem(options: WeatherSystemOptions): WeatherSystem
|
||||
|
||||
interface WeatherSystemOptions {
|
||||
initialPreset: WeatherPreset
|
||||
transitionDuration?: number // seconds, default 60
|
||||
clock?: Clock
|
||||
rng?: Rng
|
||||
}
|
||||
|
||||
interface WeatherSystem {
|
||||
transitionTo(preset: WeatherPreset, duration?: number): void
|
||||
tick(dt: number): void
|
||||
readonly state: WeatherState
|
||||
readonly currentPreset: WeatherPreset
|
||||
}
|
||||
|
||||
// Weather zones
|
||||
function createWeatherZone(options: WeatherZoneOptions): WeatherZone
|
||||
|
||||
interface WeatherZoneOptions {
|
||||
id: string
|
||||
center: Vec3
|
||||
radius: number
|
||||
preset: WeatherPreset
|
||||
blendRadius?: number // blend distance at zone edge
|
||||
}
|
||||
|
||||
interface WeatherZone {
|
||||
readonly id: string
|
||||
getBlendFactor(position: Vec3): number // 0 = outside, 1 = fully inside
|
||||
}
|
||||
|
||||
function blendWeather(base: WeatherPreset, override: WeatherPreset, factor: number): WeatherPreset
|
||||
```
|
||||
|
||||
### Error codes
|
||||
|
||||
```ts
|
||||
type WeatherErrorCode =
|
||||
| 'WEATHER_INVALID_PRESET'
|
||||
| 'WEATHER_ZONE_NOT_FOUND'
|
||||
| 'WEATHER_TRANSITION_INVALID'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
gaming/world/weather/
|
||||
package.json
|
||||
tsconfig.json
|
||||
vitest.config.ts
|
||||
src/
|
||||
index.ts
|
||||
error-codes.ts
|
||||
constants/index.ts
|
||||
types/common.ts
|
||||
types/common.md
|
||||
core/
|
||||
weather-system/
|
||||
weather-system.ts
|
||||
weather-system.md
|
||||
weather-system.types.ts
|
||||
weather-system.test.ts
|
||||
index.ts
|
||||
weather-zone/
|
||||
weather-zone.ts
|
||||
weather-zone.md
|
||||
weather-zone.types.ts
|
||||
weather-zone.test.ts
|
||||
index.ts
|
||||
presets/
|
||||
index.ts # CLEAR, RAIN, STORM, SNOW, FOG built-in presets
|
||||
utils/
|
||||
blend.ts
|
||||
blend.md
|
||||
blend.test.ts
|
||||
tests/
|
||||
integration.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Impact
|
||||
|
||||
**Downstream**: `@suaveplan/r3f-weather` renders rain particles, fog, lightning effects driven by `WeatherState`. Prerequisites: `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/events`, `@suaveplan/day-night`.
|
||||
47
openspec/changes/enterprise-gaming-weather/tasks.md
Normal file
47
openspec/changes/enterprise-gaming-weather/tasks.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Tasks: enterprise-gaming-weather
|
||||
|
||||
## 0. Pre-flight (non-negotiable)
|
||||
|
||||
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
|
||||
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
|
||||
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## Phase 1 — Scaffold
|
||||
|
||||
- [ ] Create `gaming/world/weather/` (`@suaveplan/weather`, `0.1.0`, `sideEffects: false`)
|
||||
- [ ] `tsconfig.json`, `vitest.config.ts`
|
||||
|
||||
## Phase 2 — Error codes & constants
|
||||
|
||||
- [ ] `src/error-codes.ts` + `src/constants/index.ts`
|
||||
- [ ] `src/presets/index.ts` — CLEAR, RAIN, STORM, SNOW, FOG presets
|
||||
|
||||
## Phase 3 — Types
|
||||
|
||||
- [ ] `src/types/common.ts` + `common.md`
|
||||
|
||||
## Phase 4 — Blend utility
|
||||
|
||||
- [ ] `src/utils/blend.ts` — `blendWeather` linear interpolation of all fields
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 5 — Weather zone
|
||||
|
||||
- [ ] `src/core/weather-zone/weather-zone.ts` — radius + blend edge, getBlendFactor
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 6 — Weather system
|
||||
|
||||
- [ ] `src/core/weather-system/weather-system.ts` — state machine, transitionTo/tick, lightning RNG, events, OTel
|
||||
- [ ] Tests (transition progress, lightning fires event, zone blend)
|
||||
- [ ] Docs
|
||||
|
||||
## Phase 7 — Integration tests
|
||||
|
||||
- [ ] `tests/integration.test.ts` — preset sequence: CLEAR → RAIN → STORM → tick through transitions
|
||||
|
||||
## Phase 8 — Pre-publish gate
|
||||
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/weather` green
|
||||
- [ ] 100% coverage
|
||||
- [ ] Publish: `bun scripts/publish.ts --package @suaveplan/weather`
|
||||
Reference in New Issue
Block a user