burnrate 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,7 +44,7 @@ The players who learn to work WITH Claude—analyzing intel, optimizing routes,
44
44
  **One command to set up, then you're in.**
45
45
 
46
46
  ```bash
47
- npx burnrate-setup
47
+ npx burnrate setup
48
48
  ```
49
49
 
50
50
  The setup wizard connects to the live server, auto-configures your Claude Code MCP settings, and verifies the connection.
@@ -55,7 +55,7 @@ The setup wizard connects to the live server, auto-configures your Claude Code M
55
55
  Use burnrate_join to create a character named "YourName"
56
56
  ```
57
57
 
58
- You'll get an API key. Run `npx burnrate-setup` again and paste it in, or manually add `"BURNRATE_API_KEY": "your-key"` to the env block in `~/.claude/settings.json`. Restart Claude Code one more time, and you're set.
58
+ You'll get an API key. Run `npx burnrate setup` again and paste it in, or manually add `"BURNRATE_API_KEY": "your-key"` to the env block in `~/.claude/settings.json`. Restart Claude Code one more time, and you're set.
59
59
 
60
60
  ### Setup from Source (Alternative)
61
61
 
package/dist/cli/index.js CHANGED
@@ -4,22 +4,29 @@
4
4
  * A logistics war MMO for Claude Code
5
5
  * The front doesn't feed itself.
6
6
  */
7
- // Route 'setup' command to the setup script before loading heavy dependencies
7
+ // Route lightweight commands BEFORE any heavy imports.
8
+ // ESM resolves all static imports before executing code, so we must
9
+ // dynamic-import and exit before static imports would load better-sqlite3.
8
10
  if (process.argv[2] === 'setup') {
9
- // setup.ts uses top-level await, so this import won't resolve
10
- // until the entire setup wizard completes
11
11
  await import('./setup.js');
12
12
  process.exit(0);
13
13
  }
14
- import { Command } from 'commander';
15
- import { GameDatabase } from '../db/database.js';
16
- import { GameEngine } from '../core/engine.js';
17
- import { generateWorld, seedMarkets } from '../core/worldgen.js';
18
- import { formatView, formatZone, formatRoutes, formatMarket, formatShipments, formatEvents, formatHelp } from './format.js';
19
- import { TIER_LIMITS } from '../core/types.js';
20
- import path from 'path';
21
- import os from 'os';
22
- import fs from 'fs';
14
+ if (process.argv[2] === 'mcp') {
15
+ await import('../mcp/server.js');
16
+ // MCP server runs indefinitely via stdio, so this line is only
17
+ // reached if the server exits on its own
18
+ process.exit(0);
19
+ }
20
+ // Heavy imports — only reached when NOT running setup
21
+ const { Command } = await import('commander');
22
+ const { GameDatabase } = await import('../db/database.js');
23
+ const { GameEngine } = await import('../core/engine.js');
24
+ const { generateWorld, seedMarkets } = await import('../core/worldgen.js');
25
+ const { formatView, formatZone, formatRoutes, formatMarket, formatShipments, formatEvents, formatHelp } = await import('./format.js');
26
+ const { getSupplyState, TIER_LIMITS, SHIPMENT_SPECS } = await import('../core/types.js');
27
+ const path = await import('path');
28
+ const os = await import('os');
29
+ const fs = await import('fs');
23
30
  // Database path
24
31
  const DB_DIR = path.join(os.homedir(), '.burnrate');
25
32
  const DB_PATH = path.join(DB_DIR, 'game.db');
@@ -1121,3 +1128,4 @@ program
1121
1128
  });
1122
1129
  // Parse and execute
1123
1130
  program.parse();
1131
+ export {};
package/dist/cli/setup.js CHANGED
@@ -72,20 +72,25 @@ async function main() {
72
72
  console.log(' ⚠ Could not validate key (server unreachable).');
73
73
  }
74
74
  }
75
- // 5. Find MCP server path
76
- // When installed via npm, the MCP server is in the package's dist/ folder
77
- // When running from source, it's relative to this file
78
- let mcpServerPath;
79
- // Check if we're running from an npm install (dist/cli/setup.js)
75
+ // 5. Determine MCP server config
76
+ // Detect whether we're running from source (git clone) or npx
80
77
  const distPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', 'mcp', 'server.js');
81
- if (fs.existsSync(distPath)) {
82
- mcpServerPath = distPath;
78
+ const isFromSource = !distPath.includes('node_modules');
79
+ let mcpCommand;
80
+ let mcpArgs;
81
+ if (isFromSource && fs.existsSync(distPath)) {
82
+ // Running from cloned source — use direct path
83
+ mcpCommand = 'node';
84
+ mcpArgs = [distPath];
85
+ console.log(`\nMCP server: ${distPath} (source)`);
83
86
  }
84
87
  else {
85
- // Fallback: ask the user
86
- mcpServerPath = await ask('Path to MCP server (dist/mcp/server.js)', path.join(process.cwd(), 'dist', 'mcp', 'server.js'));
88
+ // Installed via npx/npm — use npx to resolve package at runtime
89
+ // This is stable and doesn't depend on ephemeral npx cache paths
90
+ mcpCommand = 'npx';
91
+ mcpArgs = ['-y', 'burnrate', 'mcp'];
92
+ console.log(`\nMCP server: npx burnrate mcp (npm package)`);
87
93
  }
88
- console.log(`\nMCP server path: ${mcpServerPath}`);
89
94
  // 6. Write Claude Code settings
90
95
  const claudeSettingsDir = path.join(os.homedir(), '.claude');
91
96
  const claudeSettingsPath = path.join(claudeSettingsDir, 'settings.json');
@@ -108,8 +113,8 @@ async function main() {
108
113
  env.BURNRATE_API_KEY = apiKey;
109
114
  }
110
115
  settings.mcpServers.burnrate = {
111
- command: 'node',
112
- args: [mcpServerPath],
116
+ command: mcpCommand,
117
+ args: mcpArgs,
113
118
  env
114
119
  };
115
120
  // Ensure directory exists
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burnrate",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "A logistics war MMO for Claude Code. The front doesn't feed itself.",
5
5
  "type": "module",
6
6
  "main": "dist/cli/index.js",