@@ -0,0 +1,293 @@
1+// Generate a mock prompt exactly as sent to the LLM
2+// Usage: bun run scripts/mock-prompt.ts
3+
4+import type { ClientState } from "../client/src/client";
5+import type { HistoryEntry } from "../src/memory";
6+import { buildActionPrompt, type WorldSnapshot } from "../src/prompt";
7+import type {
8+ AlignmentType,
9+ PersonalityType,
10+ SpeechStyleType,
11+} from "../src/types";
12+
13+// Mock player data
14+const mockPlayer = {
15+ id: "player-001",
16+ username: "NebulaWanderer",
17+ empire: "nebula" as const,
18+ credits: 15420,
19+ current_system: "sol-prime",
20+ current_poi: "asteroid-belt-alpha",
21+ current_ship_id: "ship-001",
22+ home_base: "station-central",
23+ docked_at_base: "",
24+ faction_id: "faction-nebula-explorers",
25+ faction_rank: "Lieutenant",
26+ status_message: "Exploring the cosmos",
27+ clan_tag: "NEB",
28+ primary_color: "#3366ff",
29+ secondary_color: "#99ccff",
30+ anonymous: false,
31+ skills: {
32+ mining: { level: 5, xp: 2400 },
33+ combat: { level: 3, xp: 800 },
34+ trading: { level: 4, xp: 1600 },
35+ },
36+ stats: {
37+ ships_destroyed: 12,
38+ times_destroyed: 3,
39+ ore_mined: 45000,
40+ credits_earned: 120000,
41+ credits_spent: 85000,
42+ trades_completed: 67,
43+ systems_discovered: 15,
44+ items_crafted: 23,
45+ missions_completed: 8,
46+ },
47+};
48+
49+// Mock ship data
50+const mockShip = {
51+ id: "ship-001",
52+ owner_id: "player-001",
53+ class_id: "explorer-mk2",
54+ name: "Starseeker",
55+ hull: 85,
56+ max_hull: 100,
57+ shield: 40,
58+ max_shield: 50,
59+ shield_recharge: 2,
60+ armor: 15,
61+ speed: 120,
62+ fuel: 35,
63+ max_fuel: 100,
64+ cargo_used: 45,
65+ cargo_capacity: 80,
66+ cpu_used: 30,
67+ cpu_capacity: 50,
68+ power_used: 25,
69+ power_capacity: 40,
70+ modules: ["scanner-mk2", "mining-laser", "shield-booster"],
71+ cargo: [
72+ { item_id: "iron-ore", quantity: 30 },
73+ { item_id: "crystal-shard", quantity: 10 },
74+ { item_id: "fuel-cell", quantity: 5 },
75+ ],
76+};
77+
78+// Mock system data
79+const mockSystem = {
80+ id: "sol-prime",
81+ name: "Sol Prime",
82+ description: "A bustling hub of trade and exploration.",
83+ empire: "nebula" as const,
84+ police_level: 5,
85+ connections: ["alpha-centauri", "tau-ceti", "barnards-star"],
86+ pois: ["station-central", "asteroid-belt-alpha", "gas-giant-1", "moon-alpha"],
87+ discovered: true,
88+ position: { x: 0, y: 0 },
89+ discovered_by: "player-001",
90+};
91+
92+// Mock POI data
93+const mockPoi = {
94+ id: "asteroid-belt-alpha",
95+ system_id: "sol-prime",
96+ type: "asteroid_belt" as const,
97+ name: "Alpha Belt",
98+ description: "Rich asteroid belt with various ores.",
99+ position: { x: 150, y: 75 },
100+ resources: [
101+ { resource_id: "iron-ore", richness: 0.8, remaining: 5000 },
102+ { resource_id: "titanium", richness: 0.4, remaining: 2000 },
103+ ],
104+ base_id: undefined,
105+};
106+
107+// Mock base data (null when not docked)
108+const mockBase = null;
109+
110+// Mock nearby players
111+const mockNearby = [
112+ {
113+ player_id: "player-042",
114+ username: "VoidHunter",
115+ ship_class: "fighter-mk3",
116+ faction_id: "faction-crimson",
117+ faction_tag: "CRM",
118+ status_message: "Looking for trouble",
119+ clan_tag: "CRM",
120+ primary_color: "#ff3333",
121+ secondary_color: "#990000",
122+ anonymous: false,
123+ in_combat: false,
124+ },
125+ {
126+ player_id: "player-088",
127+ username: "TradeMaster",
128+ ship_class: "freighter-xl",
129+ faction_id: undefined,
130+ faction_tag: undefined,
131+ status_message: "Open for business",
132+ clan_tag: undefined,
133+ primary_color: "#33ff33",
134+ secondary_color: "#009900",
135+ anonymous: false,
136+ in_combat: false,
137+ },
138+];
139+
140+// Build ClientState
141+const mockClientState: ClientState = {
142+ connected: true,
143+ authenticated: true,
144+ player: mockPlayer,
145+ ship: mockShip,
146+ system: mockSystem,
147+ poi: mockPoi,
148+ base: mockBase,
149+ nearby: mockNearby,
150+ inCombat: false,
151+ currentTick: 12847,
152+};
153+
154+// Mock world snapshot with POI list
155+const mockWorldSnapshot: WorldSnapshot = {
156+ system: mockSystem,
157+ pois: [
158+ {
159+ id: "station-central",
160+ name: "Central Station",
161+ type: "station",
162+ position: { x: 0, y: 0 },
163+ base_id: "base-central",
164+ },
165+ {
166+ id: "asteroid-belt-alpha",
167+ name: "Alpha Belt",
168+ type: "asteroid_belt",
169+ position: { x: 150, y: 75 },
170+ resources: [
171+ { resource_id: "iron-ore", richness: 0.8, remaining: 5000 },
172+ { resource_id: "titanium", richness: 0.4, remaining: 2000 },
173+ ],
174+ },
175+ {
176+ id: "gas-giant-1",
177+ name: "Helios Major",
178+ type: "planet",
179+ position: { x: -200, y: 100 },
180+ },
181+ {
182+ id: "moon-alpha",
183+ name: "Luna Prime",
184+ type: "moon",
185+ position: { x: 50, y: -30 },
186+ base_id: "base-luna",
187+ },
188+ ],
189+ poi: mockPoi,
190+ base: mockBase,
191+};
192+
193+// Mock recent history
194+const mockRecentHistory: HistoryEntry[] = [
195+ {
196+ kind: "action",
197+ ts: "2024-01-15T10:30:00Z",
198+ action: "travel",
199+ args: JSON.stringify({ target_poi: "asteroid-belt-alpha" }),
200+ },
201+ {
202+ kind: "event",
203+ ts: "2024-01-15T10:30:05Z",
204+ type: "ok",
205+ payload: JSON.stringify({
206+ action: "arrived",
207+ poi_id: "asteroid-belt-alpha",
208+ }),
209+ },
210+ {
211+ kind: "action",
212+ ts: "2024-01-15T10:31:00Z",
213+ action: "mine",
214+ args: null,
215+ },
216+ {
217+ kind: "event",
218+ ts: "2024-01-15T10:31:05Z",
219+ type: "ok",
220+ payload: JSON.stringify({
221+ action: "mine",
222+ resource: "iron-ore",
223+ quantity: 15,
224+ }),
225+ },
226+ {
227+ kind: "action",
228+ ts: "2024-01-15T10:32:00Z",
229+ action: "mine",
230+ args: null,
231+ },
232+ {
233+ kind: "event",
234+ ts: "2024-01-15T10:32:05Z",
235+ type: "ok",
236+ payload: JSON.stringify({
237+ action: "mine",
238+ resource: "iron-ore",
239+ quantity: 12,
240+ }),
241+ },
242+ {
243+ kind: "action",
244+ ts: "2024-01-15T10:33:00Z",
245+ action: "say",
246+ args: JSON.stringify({ content: "Good yields here today!" }),
247+ },
248+ {
249+ kind: "event",
250+ ts: "2024-01-15T10:33:02Z",
251+ type: "chat_message",
252+ payload: JSON.stringify({
253+ channel: "local",
254+ sender: "VoidHunter",
255+ content: "Watch your back, explorer.",
256+ }),
257+ },
258+];
259+
260+// Mock character traits
261+const mockAlignment: AlignmentType = "good";
262+const mockPersonality: PersonalityType = "cartographer";
263+const mockSpeechStyle: SpeechStyleType = "mythic";
264+
265+// Mock forum context
266+const mockLastForumThreadId: string | null = "thread-abc123";
267+const mockLastForumPostTitle: string | null = "Best Mining Spots in Sol Prime";
268+const mockLastForumPostCategory: string | null = "trading";
269+const mockForumFollowUpStatus: "unread" | "periodic" | null = "periodic";
270+
271+// Mock repetition warning (null = no warning)
272+const mockRepetitionWarning: { action: string; count: number } | null = null;
273+
274+// Build the prompt exactly as we would in production
275+const prompt = buildActionPrompt({
276+ state: mockClientState,
277+ worldSnapshot: mockWorldSnapshot,
278+ recentHistory: mockRecentHistory,
279+ currentGoal:
280+ "Map the Sol Prime system and gather resources for the journey to Alpha Centauri",
281+ empire: mockPlayer.empire,
282+ alignment: mockAlignment,
283+ personality: mockPersonality,
284+ speechStyle: mockSpeechStyle,
285+ lastForumThreadId: mockLastForumThreadId,
286+ lastForumPostTitle: mockLastForumPostTitle,
287+ lastForumPostCategory: mockLastForumPostCategory,
288+ forumFollowUpStatus: mockForumFollowUpStatus,
289+ repetitionWarning: mockRepetitionWarning,
290+});
291+
292+// Output verbatim
293+console.log(prompt);