Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ This file is the primary context for any AI coding agent working on this reposit
- **Genre:** Hybrid MMO + Top-down ARPG (NOT full open-world MMORPG)
- **References:** Diablo IV, Path of Exile 2, Lost Ark
- **Setting:** Near-future ~2050, post-apocalyptic, MetaDOS universe
- **Tone:** Dark sci-fi, cyberpunk, cultivation-progression, AI NPC society
- **Tone:** Dark sci-fi, cyberpunk, body/soul survival, AI NPC society

## Four Signature Features (DO NOT LOSE TRACK)

1. **AI Agent 24/7** - When the player is offline, an LLM-driven AI agent fully controls their character (farms, quests, socializes with NPCs and other players' agents). When the player returns, they take over control. This is a near-unique feature in MMO/ARPG space.
2. **Reincarnation with progression reset** - Death is permanent for the body. Consciousness transfers to a new body via SECOND token or special item. Progression resets (roguelike-MMO hybrid). Cultivation tier may carry over partial.
2. **Reincarnation with progression reset** - Death is permanent for the body. Consciousness transfers to a new body via SECOND token or special item. Current-body progression resets in a roguelike-MMO hybrid loop. Durable soul/profile carryover rules are deferred until the reincarnation design is sharper.
3. **Time-as-Currency** - Time is both the current body's survival resource and a spendable economy resource, adapted from MetaDOS and the `In Time` inspiration. Running out of body time triggers death/reincarnation; spending time creates hard tactical tradeoffs.
4. **Consciousness transfer to NPC/synthetic bodies** - Sci-fi explanation (mind upload, synthetic bodies, Nibirium-enhanced cloning). NOT spiritual reincarnation.
4. **Consciousness transfer to NPC/synthetic bodies** - Sci-fi explanation (mind upload, synthetic bodies, cloning, and body imprinting). NOT spiritual reincarnation.

## Actor and Body Model (CORE)

Expand All @@ -27,18 +27,16 @@ This file is the primary context for any AI coding agent working on this reposit
- Each important actor body should eventually resolve to a bundle: `BodyProfile`, `CharacterStats`, `CharacterTraits`, `SoulProfile`, `MemoryRecord`, `AgentPolicy` or NPC policy, `AgentRuntime`, and `AgentActivity`.
- Reincarnation destroys or retires the current body. The durable player consciousness transfers into a new body, with only explicitly designed layers carrying over.

## Cultivation System (sci-fi, not Chinese-style)
## Advanced Body Progression (DEFERRED)

6 tiers:
The previous cultivation / Nibirium XP concept is explicitly deferred and must
not be implemented in the current vertical slice. It felt too close to a
traditional XP bar. The slice uses level and character stats as the progression
baseline.

1. Awakening - Activate Nibirium absorption
2. Enhancement - Body strengthening
3. Core Formation - Energy core formation
4. Evolution - DNA / special ability evolution
5. Transcendence - Beyond human limits
6. Ascension - Near-divine

International-friendly framing. Explained via science (Nibirium, biotech, consciousness transfer).
Future advanced body or soul progression needs a fresh design pass before any
implementation. Do not add cultivation tiers, Nibirium XP, tier-up rituals, or
Cultivation Master mechanics without a new approved design update.

## Gameplay Architecture

Expand Down Expand Up @@ -96,7 +94,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci

- Migrate LLM calls to `api.dos.ai` / Go LLM Gateway, models:
- Haiku 4.5 for NPC chat (fast, cheap)
- Sonnet 4.6 for boss / quest / cultivation master dialog
- Sonnet 4.6 for boss / quest-critical dialog
- RAG memory: Supabase pgvector or Qdrant
- Voice: OpenAI Realtime API via ephemeral token (NOT API key in client) OR ElevenLabs
- Client AI: Unity Sentis for small perception (optional, phase 3)
Expand Down Expand Up @@ -126,7 +124,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci
- Agent operates within Fusion server tick (server-authoritative)
- Agent decision loop: pull state from Fusion -> reason via LLM gateway -> emit action intent -> server validates -> apply
- Anti-abuse: agent inherits player's rate limit + capability cap
- Agent persona: derived from player history + character cultivation tier
- Agent persona: derived from player history, current body stats, and player profile
- Agent death = body death = reincarnation triggered (same as player death)

### NFT / Blockchain
Expand Down Expand Up @@ -233,7 +231,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci
- Guild / social (phase 2)
- Reincarnation mechanic
- AI agent for offline players
- Cultivation tier progression
- Advanced body progression beyond level/stats is deferred until redesigned

### Recommended Reading List

Expand Down Expand Up @@ -305,7 +303,6 @@ Scope:
- Reincarnation MVP (die -> SECOND token -> respawn with reset)
- Time-as-currency MVP (body time meter, earn/spend loop, zero time triggers reincarnation placeholder)
- AI agent control (simple: agent farms one designated area when player offline)
- 2 cultivation tiers playable (Awakening + Enhancement)
- NFT Hunter skin equip + escrow
- Multiplayer 4-20 players per zone
- Basic chat (Nakama channels first, Supabase sidecar only if useful)
Expand All @@ -316,7 +313,7 @@ OUT of scope for vertical slice:
- Marketplace
- Pet breeding
- Multiple zones
- Tier 3-6 cultivation
- Advanced body progression
- Voice NPC
- Full quest system

Expand All @@ -336,6 +333,7 @@ OUT of scope for vertical slice:
- Final game name (SECOND SPAWN is codename, may rename after vertical slice playable)
- SECOND token economy design (cost per reincarnation, source, sink)
- BodyTime tuning (where time drains, how it is earned, how it can be spent, and whether it can convert to/from SECOND token)
- Advanced body or soul progression replacing the deferred concept
- Hunter NFT integration approach: Option 1 (preset hero) vs Hybrid 1+3 (modular pieces)
- Phase 2 LLM model split (when to use Haiku vs Sonnet)
- Voice NPC vendor (OpenAI Realtime vs ElevenLabs vs self-host)
Expand Down
34 changes: 16 additions & 18 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ This file is the primary context for any AI coding agent working on this reposit
- **Genre:** Hybrid MMO + Top-down ARPG (NOT full open-world MMORPG)
- **References:** Diablo IV, Path of Exile 2, Lost Ark
- **Setting:** Near-future ~2050, post-apocalyptic, MetaDOS universe
- **Tone:** Dark sci-fi, cyberpunk, cultivation-progression, AI NPC society
- **Tone:** Dark sci-fi, cyberpunk, body/soul survival, AI NPC society

## Four Signature Features (DO NOT LOSE TRACK)

1. **AI Agent 24/7** - When the player is offline, an LLM-driven AI agent fully controls their character (farms, quests, socializes with NPCs and other players' agents). When the player returns, they take over control. This is a near-unique feature in MMO/ARPG space.
2. **Reincarnation with progression reset** - Death is permanent for the body. Consciousness transfers to a new body via SECOND token or special item. Progression resets (roguelike-MMO hybrid). Cultivation tier may carry over partial.
2. **Reincarnation with progression reset** - Death is permanent for the body. Consciousness transfers to a new body via SECOND token or special item. Current-body progression resets in a roguelike-MMO hybrid loop. Durable soul/profile carryover rules are deferred until the reincarnation design is sharper.
3. **Time-as-Currency** - Time is both the current body's survival resource and a spendable economy resource, adapted from MetaDOS and the `In Time` inspiration. Running out of body time triggers death/reincarnation; spending time creates hard tactical tradeoffs.
4. **Consciousness transfer to NPC/synthetic bodies** - Sci-fi explanation (mind upload, synthetic bodies, Nibirium-enhanced cloning). NOT spiritual reincarnation.
4. **Consciousness transfer to NPC/synthetic bodies** - Sci-fi explanation (mind upload, synthetic bodies, cloning, and body imprinting). NOT spiritual reincarnation.

## Actor and Body Model (CORE)

Expand All @@ -27,18 +27,16 @@ This file is the primary context for any AI coding agent working on this reposit
- Each important actor body should eventually resolve to a bundle: `BodyProfile`, `CharacterStats`, `CharacterTraits`, `SoulProfile`, `MemoryRecord`, `AgentPolicy` or NPC policy, `AgentRuntime`, and `AgentActivity`.
- Reincarnation destroys or retires the current body. The durable player consciousness transfers into a new body, with only explicitly designed layers carrying over.

## Cultivation System (sci-fi, not Chinese-style)
## Advanced Body Progression (DEFERRED)

6 tiers:
The previous cultivation / Nibirium XP concept is explicitly deferred and must
not be implemented in the current vertical slice. It felt too close to a
traditional XP bar. The slice uses level and character stats as the progression
baseline.

1. Awakening - Activate Nibirium absorption
2. Enhancement - Body strengthening
3. Core Formation - Energy core formation
4. Evolution - DNA / special ability evolution
5. Transcendence - Beyond human limits
6. Ascension - Near-divine

International-friendly framing. Explained via science (Nibirium, biotech, consciousness transfer).
Future advanced body or soul progression needs a fresh design pass before any
implementation. Do not add cultivation tiers, Nibirium XP, tier-up rituals, or
Cultivation Master mechanics without a new approved design update.

## Gameplay Architecture

Expand Down Expand Up @@ -96,7 +94,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci

- Migrate LLM calls to `api.dos.ai` / Go LLM Gateway, models:
- Haiku 4.5 for NPC chat (fast, cheap)
- Sonnet 4.6 for boss / quest / cultivation master dialog
- Sonnet 4.6 for boss / quest-critical dialog
- RAG memory: Supabase pgvector or Qdrant
- Voice: OpenAI Realtime API via ephemeral token (NOT API key in client) OR ElevenLabs
- Client AI: Unity Sentis for small perception (optional, phase 3)
Expand Down Expand Up @@ -126,7 +124,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci
- Agent operates within Fusion server tick (server-authoritative)
- Agent decision loop: pull state from Fusion -> reason via LLM gateway -> emit action intent -> server validates -> apply
- Anti-abuse: agent inherits player's rate limit + capability cap
- Agent persona: derived from player history + character cultivation tier
- Agent persona: derived from player history, current body stats, and player profile
- Agent death = body death = reincarnation triggered (same as player death)

### NFT / Blockchain
Expand Down Expand Up @@ -233,7 +231,7 @@ International-friendly framing. Explained via science (Nibirium, biotech, consci
- Guild / social (phase 2)
- Reincarnation mechanic
- AI agent for offline players
- Cultivation tier progression
- Advanced body progression beyond level/stats is deferred until redesigned

### Recommended Reading List

Expand Down Expand Up @@ -305,7 +303,6 @@ Scope:
- Reincarnation MVP (die -> SECOND token -> respawn with reset)
- Time-as-currency MVP (body time meter, earn/spend loop, zero time triggers reincarnation placeholder)
- AI agent control (simple: agent farms one designated area when player offline)
- 2 cultivation tiers playable (Awakening + Enhancement)
- NFT Hunter skin equip + escrow
- Multiplayer 4-20 players per zone
- Basic chat (Nakama channels first, Supabase sidecar only if useful)
Expand All @@ -316,7 +313,7 @@ OUT of scope for vertical slice:
- Marketplace
- Pet breeding
- Multiple zones
- Tier 3-6 cultivation
- Advanced body progression
- Voice NPC
- Full quest system

Expand All @@ -336,6 +333,7 @@ OUT of scope for vertical slice:
- Final game name (SECOND SPAWN is codename, may rename after vertical slice playable)
- SECOND token economy design (cost per reincarnation, source, sink)
- BodyTime tuning (where time drains, how it is earned, how it can be spent, and whether it can convert to/from SECOND token)
- Advanced body or soul progression replacing the deferred concept
- Hunter NFT integration approach: Option 1 (preset hero) vs Hybrid 1+3 (modular pieces)
- Phase 2 LLM model split (when to use Haiku vs Sonnet)
- Voice NPC vendor (OpenAI Realtime vs ElevenLabs vs self-host)
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ versioned release tag yet, so entries are organized as pre-alpha snapshots.
- Nakama OSS backend base with TypeScript runtime modules, local config, custom
Supabase-auth bridge, profile bootstrap, soul update, memory write, and agent
decision RPC.
- Agent context, soul, character trait, BodyTime, cultivation, policy, and memory
- Agent context, soul, character trait, BodyTime, level/stats, policy, and memory
contracts.
- Unity gateway client with Nakama fallback, local memory seeding, NPC chat,
speech bubble, and prototype voice cue.
Expand Down
7 changes: 2 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ especially `docs/design/02-vertical-slice-spec.md` and
- [x] Go LLM gateway scaffold with health/readiness, character context, memory,
soul update, NPC chat, voice-session contract, and agent decision routes.
- [x] Agent context contract covering player profile, body state, soul,
traits, cultivation, BodyTime, agent policy, and compact memory.
traits, level/stats, BodyTime, agent policy, and compact memory.
- [x] Prototype Unity gateway client with Nakama fallback, profile/memory sync,
NPC chat, local voice cue, and speech bubble.
- [x] Local player agent prototype toggle for bounded movement intent.
Expand Down Expand Up @@ -70,7 +70,6 @@ MVP, and a visible offline-agent prototype.
- [ ] Add BodyTime meter MVP with one earn source and one spend sink.
- [ ] Add reincarnation placeholder flow: death -> SECOND token check ->
respawn with current-body reset.
- [ ] Add cultivation tiers 1-2: Awakening and Enhancement.
- [ ] Add one dungeon instance with one boss and grounded dialogue.
- [ ] Add one Hunter NFT skin equip placeholder with DOS Chain escrow design
still server-authoritative.
Expand All @@ -84,7 +83,6 @@ MVP, and a visible offline-agent prototype.
- [ ] Add RAG memory for NPCs with Supabase pgvector or Qdrant.
- [ ] Expand quest system beyond the first vertical slice questline.
- [ ] Add multiple zones with travel.
- [ ] Add cultivation tiers 3-4.
- [ ] Add marketplace and NFT trade.
- [ ] Add guild system before PvP.
- [ ] Add voice NPC if ephemeral-token cost and reliability are acceptable.
Expand All @@ -93,7 +91,6 @@ MVP, and a visible offline-agent prototype.

- [ ] Guild PvP up to 50v50.
- [ ] Pet breeding system.
- [ ] Cultivation tiers 5-6.
- [ ] Movement-only mount system.
- [ ] Economy balancing.
- [ ] Live ops infrastructure.
Expand All @@ -104,7 +101,7 @@ MVP, and a visible offline-agent prototype.
- [ ] Seasons and content updates.
- [ ] Modding support.
- [ ] Sentis on-device AI for client perception.
- [ ] More cultivation paths.
- [ ] Redesign advanced body or soul progression after the vertical slice.

## Deliberately Out of Scope

Expand Down
9 changes: 0 additions & 9 deletions Unity/Assets/_SecondSpawn/Scripts/AI/AgentContextDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public sealed class BodyProfileDto
public CharacterStatsDto stats;
public CharacterTraitsDto characteristics;
public BodyTimeDto time;
public CultivationDto cultivation;
public string lifecycle = "alive";
public AgentPolicyDto agent_policy;
public SoulProfileDto soul;
Expand Down Expand Up @@ -101,13 +100,6 @@ public sealed class BodyTimeEventRequestDto
public string note;
}

[Serializable]
public sealed class CultivationDto
{
public string tier;
public long progress_xp;
}

[Serializable]
public sealed class AgentPolicyDto
{
Expand Down Expand Up @@ -202,7 +194,6 @@ public sealed class ActorProfileRequestDto
public CharacterStatsDto stats;
public CharacterTraitsDto characteristics;
public BodyTimeDto time;
public CultivationDto cultivation;
public SoulProfileDto soul;
public AgentPolicyDto agent_policy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ private sealed class GatewayBodyProfileDto
public CharacterStatsDto stats;
public CharacterTraitsDto characteristics;
public BodyTimeDto time;
public CultivationDto cultivation;
public AgentPolicyDto agent_policy;
public SoulProfileDto soul;
public MemoryRecordDto[] memory;
Expand All @@ -588,7 +587,6 @@ public static GatewayBodyProfileDto From(BodyProfileDto body)
stats = body.stats,
characteristics = body.characteristics,
time = body.time,
cultivation = body.cultivation,
agent_policy = body.agent_policy,
soul = body.soul,
memory = body.memory
Expand Down
6 changes: 2 additions & 4 deletions Unity/Assets/_SecondSpawn/Scripts/Networking/NetworkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ namespace SecondSpawn.Networking
/// owns every <c>[Networked]</c> property. Per Pillar 4 (Server-authoritative
/// gameplay) and Hard Rule #2 (LLM never mutates state directly).</para>
///
/// <para>Vertical slice scope: position + rotation + cultivation tier +
/// HP + agent flag. Inventory, quest progress, NFT lock state are
/// <para>Vertical slice scope: position, rotation, level, combat stats,
/// BodyTime, HP, and agent flag. Inventory, quest progress, NFT lock state are
/// persisted in Supabase (durable layer), not held in
/// <c>[Networked]</c> properties (session layer).</para>
/// </summary>
[DisallowMultipleComponent]
[RequireComponent(typeof(SimpleKCC))]
public sealed class NetworkPlayer : NetworkBehaviour
{
[Networked] public int CultivationTier { get; set; }
[Networked] public float Hp { get; set; }
[Networked] public float Stamina { get; set; }
[Networked] public int Level { get; set; }
Expand Down Expand Up @@ -68,7 +67,6 @@ public override void Spawned()

if (HasStateAuthority)
{
CultivationTier = 1; // Awakening - starting tier per docs/design/04-cultivation-system.md
ApplyDefaultStats();
if (EquipmentVisualId == EquipmentVisualCatalog.None)
{
Expand Down
2 changes: 1 addition & 1 deletion Unity/Assets/_SecondSpawn/Scripts/UI/HUDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void OnGUI()
var rect = new Rect(_panelPosition.x, _panelPosition.y, _panelSize.x, _panelSize.y);
GUI.Box(rect, "SECOND SPAWN");
GUILayout.BeginArea(new Rect(rect.x + 12f, rect.y + 24f, rect.width - 24f, rect.height - 32f));
GUILayout.Label($"Level {player.Level} | Tier {player.CultivationTier}", _labelStyle);
GUILayout.Label($"Level {player.Level}", _labelStyle);
GUILayout.Label($"HP {player.Hp:0}/{player.MaxHealth} | Energy {player.Stamina:0}/{player.MaxEnergy}", _labelStyle);
GUILayout.Label($"ATK {player.AttackPower} | DEF {player.DefensePower} | AGI {player.Agility}", _labelStyle);
GUILayout.Label($"BodyTime {FormatSeconds(player.BodyTimeRemainingSeconds)} / {FormatSeconds(player.BodyTimeMaxSeconds)}", _labelStyle);
Expand Down
2 changes: 1 addition & 1 deletion backend/gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ following boundaries; the prototype has not wired every item yet:
- Per-player rate limits + daily token budget (Redis)
- Server-side intent validation (no LLM-driven state mutation)
- Prompt injection defense (reuses DOSafe patterns)
- Provider routing (Anthropic for boss / cultivation master dialogue,
- Provider routing (Anthropic for boss / quest-critical dialogue,
Convai for general NPC dialogue in phase 1)

Reuses the operational pattern of `D:\Projects\DOSRouter` (the Go LLM
Expand Down
Loading
Loading