claudekit-terminal 0.3.1 → 0.3.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
@@ -29,6 +29,7 @@ Sends anonymous usage counts (never your chats or code); turn it off with `claud
29
29
 
30
30
  - **Get Pro:** `claudekit-terminal pro` shows the price and opens a checkout in your browser. The key arrives by itself; if you close the terminal first, run `claudekit-terminal pro check` later. Add `monthly` for monthly.
31
31
  - **Already have Pro in the extension?** Open its popup, choose "Use Pro in your terminal", copy the key, then run `claudekit-terminal activate <key>`. A trial key works too.
32
+ - **On a team plan?** Run `claudekit-terminal activate CK-TEAM-XXXX-XXXX-XXXX` with the code your team's admin sent you.
32
33
  - Keys are checked on your computer and renew by themselves while your Pro does. `claudekit-terminal license` shows what you have.
33
34
  - **Used ClaudeKit in the terminal before 0.3.0?** Everything stays free for you until Jan 31, 2027.
34
35
 
package/lib/cli.js CHANGED
@@ -25,7 +25,7 @@ import { historyEnabled, latestReading, loadState, recordReading } from './state
25
25
  import { FALLBACK, colorEnabled, formatStatusLine, parseInput } from './statusline.js';
26
26
  import { countWords, estimateTokens } from './tokens.js';
27
27
  import { checkKey, forgetKey, saveKey } from './license.js';
28
- import { fetchKeyFor, fetchOffer, gateLines, offerLine, proStatus, refreshKeyIfDue } from './pro.js';
28
+ import { fetchKeyFor, fetchOffer, gateLines, offerLine, proStatus, redeemTeamCode, refreshKeyIfDue, teamCode } from './pro.js';
29
29
  import { SITE_NOTICE, TELEMETRY_NOTICE, apiBase, clearQueue, flagNames, flush, flushDue, statusSignals, telemetryAllowed, track } from './telemetry.js';
30
30
  import { GRANDFATHER_UNTIL, loadTerminal, saveTerminal } from './terminal-state.js';
31
31
  import { expiringChats, expiryLine } from './cleanup.js';
@@ -976,10 +976,11 @@ async function tokensCommand(argv, io) {
976
976
 
977
977
  const fmtDay = (iso) => new Date(iso).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
978
978
 
979
- function activateCommand(argv, io) {
979
+ async function activateCommand(argv, io) {
980
980
  const { words } = parseArgs(argv);
981
981
  const token = (words[0] ?? '').trim();
982
982
  if (!token) throw new Error(`Paste your key after the command: ${io.self.say} activate <key>. Get one from the ClaudeKit popup (Use Pro in your terminal), or with: ${io.self.say} pro`);
983
+ if (teamCode(token)) return activateTeamCode(token, io);
983
984
  const checked = checkKey(token, io.now());
984
985
  if (!checked.ok && checked.reason !== 'expired') throw new Error("That isn't a ClaudeKit Pro key. Copy it again from the ClaudeKit popup: Use Pro in your terminal.");
985
986
  if (!checked.ok) {
@@ -996,6 +997,36 @@ function activateCommand(argv, io) {
996
997
  return 0;
997
998
  }
998
999
 
1000
+ /** A Team Pro code (CK-TEAM-…) from the team's admin: it's redeemed for this terminal's install id, then the key is fetched. */
1001
+ async function activateTeamCode(code, io) {
1002
+ const state = io.state ?? loadTerminal(io.env, io.now());
1003
+ const installId = ensureInstallId(io, state);
1004
+ const redeemed = await redeemTeamCode(io.env, io.fetch, installId, code);
1005
+ if (!redeemed.ok) {
1006
+ io.out(redeemed.error);
1007
+ return 1;
1008
+ }
1009
+ const token = await fetchKeyFor(io.env, io.fetch, installId);
1010
+ const checked = token ? checkKey(token, io.now()) : null;
1011
+ if (!checked?.ok) {
1012
+ io.out(`Your team code is saved, but the key didn't arrive. Try again in a minute: ${io.self.say} pro check`);
1013
+ return 1;
1014
+ }
1015
+ saveKey(token, io.env);
1016
+ track(io.env, state, 'key_activated', 'team', io.now());
1017
+ io.out(`Team Pro is on in this terminal until ${fmtDay(checked.payload.exp)}. The key is checked on this computer and renews by itself while your team's Pro does.`);
1018
+ return 0;
1019
+ }
1020
+
1021
+ /** The install id this terminal uses for a checkout or a team code, made once and kept. */
1022
+ function ensureInstallId(io, state) {
1023
+ if (!state.installId) {
1024
+ state.installId = `ckx_${randomBytes(16).toString('hex')}`;
1025
+ saveTerminal(state, io.env);
1026
+ }
1027
+ return state.installId;
1028
+ }
1029
+
999
1030
  function licenseCommand(argv, io) {
1000
1031
  const { flags } = parseArgs(argv);
1001
1032
  if (flags.forget) {
@@ -1021,10 +1052,7 @@ async function proCommand(argv, io) {
1021
1052
  return 0;
1022
1053
  }
1023
1054
  // A checkout from the terminal uses its own install id, kept so the key can be picked up later.
1024
- if (!state.installId) {
1025
- state.installId = `ckx_${randomBytes(16).toString('hex')}`;
1026
- saveTerminal(state, io.env);
1027
- }
1055
+ ensureInstallId(io, state);
1028
1056
  if (flags.check || words[0] === 'check') return pickUpKey(io, state, 1);
1029
1057
  const period = words[0] === 'monthly' ? 'monthly' : 'yearly';
1030
1058
  const offer = await fetchOffer(io.env, io.fetch);
package/lib/docs.js CHANGED
@@ -31,7 +31,7 @@ Prompts:
31
31
 
32
32
  ClaudeKit Pro (one licence with the browser extension):
33
33
  pro get Pro from the terminal (checkout opens in your browser)
34
- activate <key> use a key copied from the ClaudeKit popup
34
+ activate <key> use a key copied from the ClaudeKit popup, or a team code
35
35
  license what Pro this terminal has
36
36
  telemetry off stop the anonymous usage counts (or DO_NOT_TRACK=1)
37
37
 
@@ -70,7 +70,8 @@ FREE AND PRO
70
70
  Jan 31, 2027.
71
71
  pro shows the price and opens a checkout in your browser; the key arrives by itself
72
72
  (or later: ${say} pro check). pro monthly for monthly.
73
- activate <key> a key from the ClaudeKit popup (Use Pro in your terminal). Keys are checked on
73
+ activate <key> a key from the ClaudeKit popup (Use Pro in your terminal), or a team code
74
+ (CK-TEAM-…) from your team's admin. Keys are checked on
74
75
  your computer and renew by themselves while your Pro does.
75
76
  license what Pro this terminal has (--forget removes the key)
76
77
 
package/lib/pro.js CHANGED
@@ -77,6 +77,29 @@ export async function refreshKeyIfDue(env, fetchImpl, now = Date.now()) {
77
77
  return false;
78
78
  }
79
79
 
80
+ const TEAM_CODE_ALPHABET = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
81
+
82
+ /** A Team Pro code (CK-TEAM-XXXX-XXXX-XXXX), read like the server reads it; null for anything else. */
83
+ export function teamCode(raw) {
84
+ if (typeof raw !== 'string' || raw.length > 64) return null;
85
+ let text = raw.toUpperCase().replace(/[^A-Z0-9]/g, '');
86
+ if (!text.startsWith('CKTEAM')) return null;
87
+ text = text.slice(6).replace(/O/g, '0').replace(/[IL]/g, '1');
88
+ return text.length === 12 && [...text].every((c) => TEAM_CODE_ALPHABET.includes(c)) ? text : null;
89
+ }
90
+
91
+ /** Redeem a team code for this terminal's install id. { ok, endsAt } or { ok: false, error }. */
92
+ export async function redeemTeamCode(env, fetchImpl, installId, code) {
93
+ const result = await fetchJson(fetchImpl, `${apiBase(env)}/v1/team/redeem`, {
94
+ method: 'POST',
95
+ headers: { 'content-type': 'application/json' },
96
+ body: JSON.stringify({ installId, code }),
97
+ });
98
+ if (!result) return { ok: false, error: 'Could not reach ClaudeKit. Check your connection and try again.' };
99
+ if (result.body?.ok === true) return { ok: true, endsAt: result.body.endsAt ?? null };
100
+ return { ok: false, error: typeof result.body?.error === 'string' ? result.body.error : 'Could not use that code.' };
101
+ }
102
+
80
103
  /** Ask the backend for this install's key (after a checkout from the terminal). */
81
104
  export async function fetchKeyFor(env, fetchImpl, installId) {
82
105
  const result = await fetchJson(fetchImpl, `${apiBase(env)}/v1/terminal/key?installId=${encodeURIComponent(installId)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudekit-terminal",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Your Claude limits, chats and prompts in the terminal: a status line for Claude Code, usage and week, prompt packs and /ck- commands free; all-time search and export, backup, notify, replies left and fork with ClaudeKit Pro. One command sets it up. Zero dependencies; anonymous usage counts you can turn off.",
5
5
  "type": "module",
6
6
  "bin": {