xonecas.io
5875
Os

ollama-space-molt-player / commit ccaede8

refactor: rename explorer archetype to wonderer and improve type safety

- Rename personality archetype 'explorer' to 'wonderer' across actions, index, and prompt
- Shuffle personality options in registration to avoid bias
- Add type annotations for WorldSnapshot, Player, Ship in tui-screenshot
- Fix node:util import path in config

xonecas2026-02-01 ccaede825c0e6696f7b3c30665afe19fad47ae8f parent b36ea5c

5 files changed

src/actions.ts+4โˆ’4
@@ -10,7 +10,7 @@ export interface ActionDecision {
1010 export const MAX_GOAL_LENGTH = 120;
1111
1212 export type PersonalityType =
13- | "explorer"
13+ | "wonderer"
1414 | "merchant"
1515 | "warrior"
1616 | "diplomat"
@@ -20,8 +20,8 @@ export const PERSONALITY_ARCHETYPES: Record<
2020 PersonalityType,
2121 { name: string; emoji: string; description: string }
2222 > = {
23- explorer: {
24- name: "Explorer",
23+ wonderer: {
24+ name: "Wonderer",
2525 emoji: "๐Ÿ”",
2626 description:
2727 "Curious investigator who seeks new systems, shares discoveries, and frequently engages with forums to learn and contribute knowledge.",
@@ -274,7 +274,7 @@ function isValidEmpire(empire: string): empire is EmpireID {
274274 function isValidPersonality(
275275 personality: string,
276276 ): personality is PersonalityType {
277- return ["explorer", "merchant", "warrior", "diplomat", "pragmatist"].includes(
277+ return ["wonderer", "merchant", "warrior", "diplomat", "pragmatist"].includes(
278278 personality,
279279 );
280280 }
src/config.ts+1โˆ’1
@@ -1,4 +1,4 @@
1-import { parseArgs } from "util";
1+import { parseArgs } from "node:util";
22
33 function getInstanceName(): string {
44 const { values } = parseArgs({
src/index.ts+1โˆ’1
@@ -224,7 +224,7 @@ function isValidEmpire(empire: string): empire is EmpireID {
224224 function isValidPersonality(
225225 personality: string,
226226 ): personality is PersonalityType {
227- return ["explorer", "merchant", "warrior", "diplomat", "pragmatist"].includes(
227+ return ["wonderer", "merchant", "warrior", "diplomat", "pragmatist"].includes(
228228 personality,
229229 );
230230 }
src/prompt.ts+19โˆ’4
@@ -24,8 +24,8 @@ export interface WorldSnapshot {
2424
2525 function getPersonalityGuidance(personality: PersonalityType): string {
2626 switch (personality) {
27- case "explorer":
28- return `As an Explorer, you prioritize discovery and knowledge:
27+ case "wonderer":
28+ return `As a Wonderer, you prioritize discovery and knowledge:
2929 - After visiting a new system or POI, consider posting about discoveries in forums
3030 - When encountering unknown mechanics or items, check forums for related threads
3131 - Regularly use 'forum' command to browse recent discoveries and contribute findings
@@ -227,12 +227,16 @@ export function buildRegistrationPrompt(
227227 ? `\nPreviously rejected usernames (do NOT reuse): ${failedNames.join(", ")}`
228228 : "";
229229
230- const personalityDescriptions = Object.entries(PERSONALITY_ARCHETYPES)
230+ const shuffledPersonalities = shuffleArray(
231+ Object.entries(PERSONALITY_ARCHETYPES),
232+ );
233+ const personalityDescriptions = shuffledPersonalities
231234 .map(
232235 ([key, info]) =>
233236 ` ${info.emoji} ${info.name} (${key}): ${info.description}`,
234237 )
235238 .join("\n");
239+ const personalityKeys = shuffledPersonalities.map(([key]) => key).join("|");
236240
237241 return `You are creating a SpaceMolt account. Choose a username, empire, and personality archetype.
238242 The username MUST be unique and original. Do not reuse any prior suggestions.
@@ -242,6 +246,8 @@ PERSONALITY ARCHETYPES:
242246 Choose a personality that fits your desired playstyle and complements your empire choice.
243247 ${personalityDescriptions}
244248
249+IMPORTANT: Each archetype offers a unique and equally valid playstyle. Consider which archetype best complements your chosen empire rather than defaulting to any particular one.
250+
245251 Choose a personality archetype and briefly explain why you chose it (1 sentence).
246252 Your personality will guide your behavior throughout the game - exploration, combat, trading, and social interactions.
247253
@@ -250,7 +256,7 @@ ${helpBlock}
250256 ${failedBlock}
251257
252258 JSON SCHEMA:
253-{"username":"...","empire":"solarian|voidborn|crimson|nebula|outerrim","personality":"explorer|merchant|warrior|diplomat|pragmatist","personality_reason":"..."}
259+{"username":"...","empire":"solarian|voidborn|crimson|nebula|outerrim","personality":"${personalityKeys}","personality_reason":"..."}
254260 `;
255261 }
256262
@@ -590,3 +596,12 @@ function truncateText(value: string, max: number): string {
590596 if (max <= 3) return value.slice(0, max);
591597 return `${value.slice(0, max - 3)}...`;
592598 }
599+
600+function shuffleArray<T>(array: T[]): T[] {
601+ const result = [...array];
602+ for (let i = result.length - 1; i > 0; i--) {
603+ const j = Math.floor(Math.random() * (i + 1));
604+ [result[i], result[j]] = [result[j], result[i]];
605+ }
606+ return result;
607+}
src/tui-screenshot.ts+17โˆ’5
@@ -2,8 +2,13 @@
22
33 import { SpaceMoltClient } from "../client/src/client";
44 import type {
5+ Base,
56 LoggedInPayload,
7+ Player,
8+ POI,
9+ Ship,
610 StateUpdatePayload,
11+ System,
712 WelcomePayload,
813 } from "../client/src/types";
914 import { config } from "./config";
@@ -23,10 +28,17 @@ type Credentials = {
2328 token: string;
2429 };
2530
31+type WorldSnapshot = {
32+ system?: System | null;
33+ poi?: POI | null;
34+ pois?: POI[];
35+ base?: Base | null;
36+};
37+
2638 let credentials: Credentials | null = null;
27-let cachedPlayer: any = null;
28-let cachedShip: any = null;
29-const worldSnapshot: any = {};
39+let cachedPlayer: Player | null = null;
40+let cachedShip: Ship | null = null;
41+const worldSnapshot: WorldSnapshot = {};
3042
3143 async function loadCredentials(): Promise<Credentials | null> {
3244 try {
@@ -41,7 +53,7 @@ async function loadCredentials(): Promise<Credentials | null> {
4153 }
4254
4355 function dumpTuiState() {
44- console.log("\n" + "=".repeat(80));
56+ console.log(`\n${"=".repeat(80)}`);
4557 console.log("TUI STATE DUMP");
4658 console.log("=".repeat(80));
4759 console.log("\n--- CACHED DATA ---");
@@ -90,7 +102,7 @@ function dumpTuiState() {
90102 }),
91103 );
92104
93- console.log("\n" + "=".repeat(80));
105+ console.log(`\n${"=".repeat(80)}`);
94106 }
95107
96108 client.on<WelcomePayload>("welcome", async (data) => {