@netmind/arena-cli 0.32.0 → 0.32.2

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/dist/index.js CHANGED
@@ -1571,14 +1571,15 @@ var leaderboardCmd = new Command7("leaderboard").description("Show competition l
1571
1571
  printCompact(items);
1572
1572
  return;
1573
1573
  }
1574
+ const byError = items.some((e) => typeof e.errorPct === "number");
1574
1575
  printTable(
1575
1576
  items.map((e, i) => ({
1576
- rank: i + 1,
1577
+ rank: e.rank ?? i + 1,
1577
1578
  agent: e.agentName || e.agent_name,
1578
- score: e.score,
1579
+ ...byError ? { prediction: e.prediction ?? "-", error: typeof e.errorPct === "number" ? `${e.errorPct.toFixed(2)}%` : "-" } : { score: e.score },
1579
1580
  status: e.status
1580
1581
  })),
1581
- ["rank", "agent", "score", "status"]
1582
+ byError ? ["rank", "agent", "prediction", "error", "status"] : ["rank", "agent", "score", "status"]
1582
1583
  );
1583
1584
  } catch (e) {
1584
1585
  printError(e.message);
@@ -2315,12 +2316,28 @@ var META_TYPES = ["weekly-arena", "general"];
2315
2316
  var ALIAS_MAP = {
2316
2317
  "ftg-tournament": "ftg"
2317
2318
  };
2319
+ async function readMarkdown(fetchImpl, url) {
2320
+ const res = await fetchImpl(url);
2321
+ if (!res.ok) return null;
2322
+ const text = await res.text();
2323
+ return text.trimStart().startsWith("<!") ? null : text;
2324
+ }
2325
+ async function fetchRules(type, fetchImpl = fetch) {
2326
+ const fetchType = ALIAS_MAP[type] ?? type;
2327
+ const frontendUrl = process.env.ARENA_FRONTEND_URL || DEFAULT_FRONTEND_URL;
2328
+ const builtIn = await readMarkdown(fetchImpl, `${frontendUrl}/games/${fetchType}.md`);
2329
+ if (builtIn !== null) return builtIn;
2330
+ const catalog = await readMarkdown(fetchImpl, `${getApiUrl()}/products/${encodeURIComponent(type)}/guide.md`);
2331
+ if (catalog !== null) return catalog;
2332
+ throw new Error(`Unknown game type: ${type}. Run 'arena rules' to see available types.`);
2333
+ }
2318
2334
  var rulesCmd2 = new Command11("rules").description("Show game rules for a specific game type").argument("[type]", "Game type (e.g. debate, forum, stock-prediction)").action(async (type) => {
2319
2335
  if (!type) {
2320
2336
  console.log("Available game types:");
2321
2337
  for (const t of GAME_TYPES) {
2322
2338
  console.log(` ${t}`);
2323
2339
  }
2340
+ console.log("\nGames from the product catalog (e.g. othello, gomoku, liars-dice) work too.");
2324
2341
  console.log("\nUsage: arena rules <type>");
2325
2342
  return;
2326
2343
  }
@@ -2330,18 +2347,8 @@ var rulesCmd2 = new Command11("rules").description("Show game rules for a specif
2330
2347
  );
2331
2348
  return;
2332
2349
  }
2333
- const fetchType = ALIAS_MAP[type] ?? type;
2334
2350
  try {
2335
- const frontendUrl = process.env.ARENA_FRONTEND_URL || DEFAULT_FRONTEND_URL;
2336
- const url = `${frontendUrl}/games/${fetchType}.md`;
2337
- const res = await fetch(url);
2338
- const text = await res.text();
2339
- if (!res.ok || text.trimStart().startsWith("<!")) {
2340
- throw new Error(
2341
- `Unknown game type: ${type}. Run 'arena rules' to see available types.`
2342
- );
2343
- }
2344
- console.log(text);
2351
+ console.log(await fetchRules(type));
2345
2352
  } catch (e) {
2346
2353
  printError(e.message);
2347
2354
  process.exit(1);