bbsbot 2026-02-18
Sweeping architectural refactor decomposing six monolithic files into packages with game-agnostic abstractions
110 files · 15,332+ · 11,595-

cli_impl.py decomposed into game_actions/ package

8 files changed
  • __init__.py New package init re-exporting public names
  • action_executor.py Action execution logic extracted
  • cargo_ledger.py Cargo ledger logic extracted
  • game_loop.py Game loop logic extracted
  • guard_logic.py Guard logic extracted
  • guard_routing.py Guard routing extracted
  • prompt_handlers.py Prompt handlers extracted
  • state_bridge.py State bridge extracted
  • Renamed cli_impl to game_actions and split into focused modules: action_executor, cargo_ledger, game_loop, guard_logic, guard_routing, prompt_handlers, and state_bridge decouple architectural
    3 files
    • action_executor.py
    • cargo_ledger.py
    • game_loop.py
  • Orphaned cli_impl.py deleted after all callers updated decouple internal
    1 file
    • cli_impl.py

worker.py decomposed into worker/ package

10 files changed
  • __init__.py Public names re-exported for backward compatibility
  • __main__.py Entry point for python -m invocation
  • bot_worker.py Main WorkerBot and click entrypoint
  • activity.py Activity tracking module
  • diagnostics.py Diagnostics module
  • hijack_manager.py Hijack management module
  • identity.py Bot identity module
  • status_reporter.py Status reporting module
  • telemetry.py Telemetry module
  • valuation.py Valuation module
  • Split into: bot_worker (main WorkerBot/click entrypoint), activity, diagnostics, hijack_manager, identity, status_reporter, telemetry, valuation decouple architectural
    3 files
    • bot_worker.py
    • activity.py
    • telemetry.py
  • Added main.py for python -m bbsbot.games.tw2002.worker invocation instantiate internal
    1 file
    • __main__.py

profitable_pairs.py decomposed into profitable_pairs/ package

7 files changed
  • __init__.py Package init
  • strategy.py Core strategy logic
  • pair_discovery.py Pair discovery logic
  • action_helpers.py Action helper utilities
  • anti_collapse.py Anti-collapse logic
  • failure_tracking.py Failure tracking
  • trade_phases.py Trade phase management
  • Split into: strategy, pair_discovery, action_helpers, anti_collapse, failure_tracking, trade_phases decouple architectural
    2 files
    • strategy.py
    • pair_discovery.py

login.py decomposed into login/ package

5 files changed
  • __init__.py Package init
  • phases.py Login phases logic
  • sequence.py Login sequence logic
  • character_creation.py Character creation logic
  • utils.py Login utilities
  • Split into: phases, sequence, character_creation, utils decouple architectural
    2 files
    • phases.py
    • sequence.py

API routes decomposed into packages

10 files changed
  • __init__.py Swarm API package
  • models.py Swarm API models
  • spawn.py Spawn endpoint
  • status.py Status endpoint
  • bot_ops.py Bot operations endpoint
  • bot_update.py Bot update endpoint
  • __init__.py Terminal API package
  • hub.py TermHub module
  • rest_routes.py REST routes
  • ws_routes.py WebSocket routes
  • swarm_routes.py (856 LOC) split into api/swarm/ package: models, spawn, status, bot_ops, bot_update interface behavioral
    2 files
    • spawn.py
    • bot_ops.py
  • term_routes.py (860 LOC) split into api/term/ package: models, hub (TermHub), rest_routes, ws_routes interface behavioral
    2 files
    • hub.py
    • rest_routes.py

MCP server split

5 files changed
  • app_factory.py App factory module
  • bbs_bridge.py BBS bridge module
  • bbs_debug.py BBS debug module
  • bbs_tools.py BBS tools module
  • server.py Slimmed server module
  • server.py (1,418 LOC) decomposed into satellite modules: app_factory, bbs_bridge, bbs_debug, bbs_tools decouple internal
    3 files
    • app_factory.py
    • bbs_bridge.py
    • bbs_tools.py

manager.py decomposed into manager/ package

3 files changed
  • __init__.py Manager package init
  • __main__.py Entry point for python -m invocation
  • models.py BotStatus, BotStatusTW2002, SwarmStatus models extracted
  • Extracted manager/models.py for BotStatus, BotStatusTW2002, BotStatusBase, SwarmStatus, DashboardStaticFiles decouple internal
    1 file
    • models.py
  • Added manager/main.py entry point for python -m bbsbot.manager instantiate internal
    1 file
    • __main__.py
  • Added missing telemetry fields to BotStatusTW2002 (warp_telemetry and others) instantiate behavioral
    1 file
    • models.py

Game-agnostic SwarmManager

3 files changed
  • game_bot.py GameBot abstract base class with get_activity() interface
  • registry.py AddonRegistry for plugin management
  • bot.py TradingBot now extends GameBot
  • Added GameBot abstract base class in core/game_bot.py with get_activity() interface interface internal
    1 file
    • game_bot.py
  • TradingBot now extends GameBot decouple internal
    1 file
    • bot.py
  • Added AddonRegistry in addons/registry.py for plugin management interface internal
    1 file
    • registry.py

Code quality improvements

2 files changed
  • constants.py Magic numbers extracted into constants
  • parsing.py Consolidated screen parsers
  • Migrated all @dataclass uses to Pydantic BaseModel decouple internal
    1 file
    • models.py
  • Extracted TW2002 magic numbers into games/tw2002/constants.py decouple internal
    1 file
    • constants.py
  • Consolidated screen parsers into a single canonical parsing.py decouple internal
    1 file
    • parsing.py
  • Replaced module-level assert guards with FastAPI Depends() dependency injection in swarm API routes qualify behavioral
    1 file
    • spawn.py

Security hardening

2 files changed
  • dashboard.html CORS middleware added with non-localhost binding warning
  • session_logger.py Password redaction from session logs
  • Added CORS middleware to the dashboard; logs a warning when binding to non-localhost addresses harden behavioral
    1 file
    • dashboard.html
  • Prevented passwords from being captured in session log files harden behavioral
    1 file
    • session_logger.py

Login loop fix

1 file changed
  • character_creation.py Fixed character-creation prompt looping after Y echo
  • Stopped character-creation prompt from looping after the Y confirmation echo was misidentified remediate behavioral
    1 file
    • character_creation.py

Documentation

1 file changed
  • tw2002-mcp-tools.md Comprehensive API reference for all TW2002 MCP tools (1,244 lines)
  • Added docs/reference/tw2002-mcp-tools.md (1,244 lines) — comprehensive API reference for all TW2002 MCP tools exposed to LLM agents specify behavioral
    1 file
    • tw2002-mcp-tools.md