Skip to content

fix: update formatters which were tied to outdated fields #20

Open
rsned wants to merge 4 commits intoSpaceMolt:mainfrom
rsned:main
Open

fix: update formatters which were tied to outdated fields #20
rsned wants to merge 4 commits intoSpaceMolt:mainfrom
rsned:main

Conversation

@rsned
Copy link

@rsned rsned commented Mar 23, 2026

The big finding: several formatters are broken because the server response structure
changed from what the formatters expect:

│  Command   │       Formatter expects       │      Server actually returns      │
|---|---|---|
│ get_system │ r.id && r.pois &&             │ r.system, r.poi,                  │
│            │ r.connections                 │ r.security_status                 │
│ get_poi    │ r.id && r.type && r.system_id │ r.poi, r.resources                │
│ get_cargo  │ r.cargo && r.cargo_used       │ r.cargo, r.used, r.capacity,      │
│            │                               │ r.available                       │
│ get_nearby │ Array.isArray(r.players)      │ r.nearby, r.pirates, r.count      │
- System info: read from r.system wrapper, display rich POI/connection data
- POI info: read from r.poi wrapper, show base details and services
- Cargo: field renamed from cargo_used to used
- Nearby: match r.nearby array, add pirate/NPC sections, player colors
- Add hexColor() helper for 24-bit ANSI terminal colors from player data
- Remove player ID lines from nearby output for cleaner display

- System info: read from r.system wrapper, display rich POI/connection data
- POI info: read from r.poi wrapper, show base details and services
- Cargo: field renamed from cargo_used to used
- Nearby: match r.nearby array, add pirate/NPC sections, player colors
- Add hexColor() helper for 24-bit ANSI terminal colors from player data
- Remove player ID lines from nearby output for cleaner display

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rsned
Copy link
Author

rsned commented Mar 23, 2026

$ bun run src/client.ts get_nearby

=== Nearby ===

Players (8):
  Kurarin.44 (prospector)
  MoltBot01 (prospector)
  Kurarin.Joker [KURA] (theoria) - "🃏 The cards of fate have been dealt. Destiny awaits."
  Hi-xi III [HEXC] (caravan)
  AuroraMiner (theoria)
  Kurarin.46 [KURA] (prospector)
  DM7-drone-010 [DMX7] (excavator)
  Cinder Wake [QTCG] (theoria)

Empire NPCs (1):
  [POLICE] Confederacy Patrol I - Confederacy Central Command (precept)

robert@dev:~/spacemolt/official_client/client$ smc  get_nearby

=== Response ===
{
  "nearby": [
    {
      "player_id": "da98c5498c10186bacd9048c0ec1e999",
      "username": "Kurarin.44",
      "primary_color": "#FFFFFF",
      "secondary_color": "#000000",
      "ship_class": "prospector",
      "in_combat": false
    },
...

get_system

$ bun run src/client.ts get_system

=== System: Sol ===
ID: sol
Empire: solarian
Police Level: 100 (Maximum Security (empire capital))
Description: The birthplace of humanity. Heart of the Solarian Confederacy.

Points of Interest:
  - Sol Star (sun) (15 online)  sol_star
  - Mercury (planet)  mercury
  - Venus (planet)  venus
  - Earth (planet) (2 online)  earth
  - Sol Central (station) [base] (874 online)  sol_central
  - Mars (planet) (4 online)  mars
  - Main Belt (asteroid_belt) (216 online)  main_belt
  - Jupiter (planet)  jupiter
  - Jovian Extraction Zone (gas_cloud) (2 online)  jovian_extraction_zone
  - Saturn (planet) (1 online)  saturn
  - Uranus (planet) (1 online)  uranus
  - Neptune (planet)  neptune
  - Kuiper Ice Fields (ice_field) (3 online)  kuiper_ice_fields

Connected Systems:
  - Sirius (715 ly)  sirius
  - Alpha Centauri (279 ly)  alpha_centauri

Current POI: Main Belt (asteroid_belt)  main_belt

$ smc  get_system

=== Response ===
{
  "action": "get_system",
  "system": {
    "id": "sol",
    "name": "Sol",
    "description": "The birthplace of humanity. Heart of the Solarian Confederacy.",
    "empire": "solarian",
    "police_level": 100,
    "security_status": "Maximum Security (empire capital)",
    "pois": [
      {
        "id": "sol_star",
        "name": "Sol Star",
        "type": "sun",
        "class": "G2V",
        "position": {
          "x": 0,
          "y": 0
        },
        "has_base": false,
        "online": 15
      },
      {
        "id": "mercury",

get_cargo

robert@dev:~/spacemolt/official_client/client$ bun run src/client.ts get_cargo

=== Cargo ===
Used: 3/70 (67 available)

  3x Nickel Ore (1 each)


$ smc  get_cargo

=== Response ===
{
  "cargo": [
    {
      "item_id": "nickel_ore",
      "name": "Nickel Ore",
      "quantity": 3,
      "size": 1
    }
  ],
  "used": 3,
  "capacity": 70,
  "available": 67
}

@rsned
Copy link
Author

rsned commented Mar 24, 2026

get_poi

=== POI: Main Belt ===
ID: main_belt
Type: asteroid_belt
System: sol
Description: Rich asteroid field between Mars and Jupiter. Contains rare Sol Alloy deposits.
Class: metallic

Resources:
  - Iron Ore: richness 80, depleted
  - Copper Ore: richness 60, 18/100000 (0.02% remaining)
  - Nickel Ore: richness 70, depleted
  - Titanium Ore: richness 25, 12/25000 (0.05% remaining)
  - Sol Alloy Ore: richness 15, 5/5000 (0.10% remaining)
  - Antimatter Containment Cell: richness 5, depleted
robert@dev:~/spacemolt/official_client/client$ 

…, POI resources

- Refactor formatters to NamedFormatter with name/hintKeys for drift detection
- Log [DRIFT WARNING] when response keys match a formatter's hints but format fails
- Extract formatPlayer() helper, shared by get_nearby and get_location
- Fix get_poi to show resources from top-level r.resources (moved from r.poi)
- Show remaining/max_remaining for resources, color-coded by percent left
- Strikethrough depleted resources, show POI class field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rsned
Copy link
Author

rsned commented Mar 24, 2026

It now warns when the formatter no longer triggers for a given command as well:

[DRIFT WARNING] 'travel' response has keys matching formatter(s) [system_info, poi_info] but none matched. Response keys: [action, online_players, online_players_count, online_players_truncated, poi, poi_id]

rsned and others added 2 commits March 23, 2026 19:21
…splay

- Add arrival formatter for travel/jump showing destination and online players
- Fix drift detection to require all hint keys (not just one) to reduce false positives
- Handle missing ship_class in formatPlayer() for travel responses

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add chat_sent formatter showing channel, timestamp, and message
- Show item IDs next to names in cargo display
- Change cargo size display from "(N each)" to "Size: N"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant