@earntori/cli 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @earntori/cli
2
2
 
3
3
  ```
4
- npx @earntori/cli login # sign in with GitHub (device flow)
5
- npx @earntori/cli status # balance + keys
6
- npx @earntori/cli key --limit 5 --write env # mint a $5 capped AI key into .env
4
+ npx @earntori/cli login # sign in with GitHub (device flow)
5
+ npx @earntori/cli status # balance + keys
6
+ npx @earntori/cli key --limit 5 --write env # mint a $5 capped AI key into .env
7
7
  ```
8
- Your credits, in your tools, in one command. https://www.earntori.com
8
+ Your credits, in your tools, in one command. Docs: https://www.earntori.com/developers
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ function out(o, human) { console.log(json ? JSON.stringify(o, null, 2) : human);
21
21
  function die(msg) { console.error(json ? JSON.stringify({ error: msg }) : `\u2717 ${msg}`); process.exit(1); }
22
22
  const usd = (c) => `$${(c / 100).toFixed(2)}`;
23
23
  async function api(cfg, method, path, body) {
24
- const r = await fetch(`${cfg.base}${path}`, { method, headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": "@earntori/cli/0.1.0" }, body: body ? JSON.stringify(body) : undefined });
24
+ const r = await fetch(`${cfg.base}${path}`, { method, headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": "@earntori/cli/0.1.2" }, body: body ? JSON.stringify(body) : undefined });
25
25
  const t = await r.text();
26
26
  let j = null;
27
27
  try {
@@ -91,15 +91,32 @@ async function key() {
91
91
  die(`--write ${write} is not supported yet; use --write env`);
92
92
  out({ ...r, wrote: write === "env" ? (flag("file") ?? ".env") : null }, `\u2713 AI key minted \u2014 cap ${usd(r.limitCents)} \u2014 shown once:\n\n ${r.key}\n\nUse it anywhere the OpenAI API works: base URL https://openrouter.ai/api/v1, pick any major model.\n Cursor: Settings \u2192 Models \u2192 OpenAI API key + override base URL\n Claude Code / others: set OPENAI_API_KEY and OPENAI_BASE_URL${note}`);
93
93
  }
94
+ async function stats() {
95
+ const cfg = loadCfg();
96
+ if (!cfg)
97
+ die("Not signed in \u2014 run: tori login");
98
+ const r = await api(cfg, "GET", "/api/v1/developer/stats");
99
+ if (!r.registered)
100
+ return out(r, "No integration registered yet \u2014 register at " + cfg.base + "/developer to get a tori_sk_ key.");
101
+ const s = r.stats, m = s.program.milestones;
102
+ out(r, `${r.integration.name} (${r.integration.vehicleType ?? "unspecified"})\n` +
103
+ `Rewards issued: ${s.rewardsIssued} (${usd(s.rewardsIssuedCents)})\n` +
104
+ `Users reached: ${s.usersReached}\n` +
105
+ `Rewards claimed: ${s.rewardsClaimed}\n` +
106
+ `Redemptions routed: ${s.redemptionsRouted}\n` +
107
+ `External rewards: ${s.external.issued} issued \u00B7 ${s.external.paid} paid \u00B7 ${s.external.unconfirmed} unconfirmed\n` +
108
+ `\nDeveloper program \u2014 credits earned: ${usd(s.program.creditsEarnedCents)}\n` +
109
+ ` starter ${m.starter ? "\u2713" : "\u00B7"} first reward claimed ${m.firstRewardClaimed ? "\u2713" : "\u00B7"} first redemption routed ${m.firstRedemptionRouted ? "\u2713" : "\u00B7"}`);
110
+ }
94
111
  function logout() { if (existsSync(CONFIG))
95
112
  unlinkSync(CONFIG); out({ ok: true }, "\u2713 Signed out"); }
96
- function help() { console.log(`tori \u2014 Tori CLI\n\n tori login [--base URL] sign in with GitHub (device flow)\n tori status [--json] balance + your AI keys\n tori key --limit 5 [--write env] [--file .env] [--json]\n tori stats developer program stats (coming with the stats endpoint)\n tori logout\n`); }
113
+ function help() { console.log(`tori \u2014 Tori CLI\n\n tori login [--base URL] sign in with GitHub (device flow)\n tori status [--json] balance + your AI keys\n tori key --limit 5 [--write env] [--file .env] [--json]\n tori stats [--json] your integration + developer program numbers\n tori logout\n`); }
97
114
  (async () => {
98
115
  switch (cmd) {
99
116
  case "login": return login();
100
117
  case "status": return status();
101
118
  case "key": return key();
102
- case "stats": return out({ pending: true }, "tori stats arrives with the developer stats endpoint (piece G). For now: https://www.earntori.com/developer");
119
+ case "stats": return stats();
103
120
  case "logout": return logout();
104
121
  default: return help();
105
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earntori/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Tori CLI — sign in with GitHub, check your credits, mint a capped AI key into your tools.",
5
5
  "license": "MIT",
6
6
  "type": "module",