claudekit-terminal 0.3.0 → 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
@@ -20,12 +20,16 @@ Sends anonymous usage counts (never your chats or code); turn it off with `claud
20
20
 
21
21
  | Free | ClaudeKit Pro |
22
22
  | --- | --- |
23
- | The status line: model, context, 5-hour and weekly use with resets, what a prompt cost, the daily budget, the "use it" nudge, the near-limit hint | The run-out forecast and replies left (status line and `usage`) |
24
- | `usage`, `week`, `map`, `tokens`, `pins`, `brief`, `prompts` and the prompt packs | `notify` ("Claude is back") |
25
- | `/ck-handoff`, `/ck-optimize`, `/ck-pin` and every `/ck-` prompt | `search`, `export`, `backup` (and `--auto`), `fork`, `reference`, `brief --start` |
23
+ | The status line: model, context, 5-hour and weekly use with resets, what a prompt cost, the daily budget, the "use it" nudge, the near-limit hint | The run-out time from 20% used, and replies left (status line and `usage`) |
24
+ | The run-out time once a limit is 70% used | `notify` ("Claude is back") |
25
+ | A warning before Claude Code deletes your chats | `backup` (and `--auto`) to keep them |
26
+ | `search` and `export` of chats from the last 7 days | `search` and `export` of every chat, `export --format json` and `--turns` |
27
+ | `usage`, `week`, `map`, `tokens`, `pins`, `brief`, `prompts` and the prompt packs | `fork`, `reference`, `brief --start` |
28
+ | `/ck-handoff`, `/ck-optimize`, `/ck-pin` and every `/ck-` prompt | Everything Pro in the browser extension, with the same licence |
26
29
 
27
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.
28
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.
29
33
  - Keys are checked on your computer and renew by themselves while your Pro does. `claudekit-terminal license` shows what you have.
30
34
  - **Used ClaudeKit in the terminal before 0.3.0?** Everything stays free for you until Jan 31, 2027.
31
35
 
@@ -47,13 +51,13 @@ Faster status line: `npm install -g claudekit-terminal`, then `claudekit-termina
47
51
  | `5h 62%` | Your 5-hour session limit used: green, yellow from 70%, red from 90% |
48
52
  | `+3%` | What your current prompt has cost of the session so far |
49
53
  | `resets 3:10 PM` | When the session resets, in your time. At 100% it says `back 3:10 PM` |
50
- | `out ~2:40 PM` | Pro: when you run out at your pace over the last hour (from 20% used) |
54
+ | `out ~2:40 PM` | When you run out at your pace over the last hour: from 70% used, or from 20% with Pro |
51
55
  | `~6 replies left` | Pro: about how many prompts are left at your pace on this model (from 50% used) |
52
56
  | `week 41% · Thu 9:00 AM · ~13%/day` | Your weekly limit, when it resets, and a daily budget |
53
57
  | `use it: resets in 10h` | In the last day before the weekly reset with 25% or more left: unused limit doesn't roll over |
54
58
  | `spend 63% of $500` | A spend limit, when your plan has one |
55
59
  | `near limit: /ck-handoff` | At 90%: save your context before you're cut off |
56
- | `2 chats expire ≤3d` | Claude Code deletes chats older than `cleanupPeriodDays` (30 days by default) without a word. This says when some are due within 3 days and aren't in your backup. `usage` and `search` say it too |
60
+ | `Claude Code deletes 2 chats ≤3d` | Claude Code deletes chats older than `cleanupPeriodDays` (30 days by default) without a word. This says when some are due within 3 days and aren't in your backup, for an hour, once a day at most. `usage` says it too, once a day |
57
61
 
58
62
  Limits show for Claude Pro, Max and Ultra plans, after the first reply in a session. With an API key you see the model and context only.
59
63
 
@@ -76,15 +80,15 @@ Run them as `claudekit-terminal <command>` (or `npx claudekit-terminal <command>
76
80
 
77
81
  **Your limits**
78
82
 
79
- - `usage`: every limit with bars and reset times, what your last prompt and this chat cost, cost per model, and days without a limit. With Pro, it adds the run-out forecast and replies left.
83
+ - `usage`: every limit with bars and reset times, what your last prompt and this chat cost, cost per model, days without a limit, and when you'll run out once a limit is 70% used. With Pro, the run-out time shows from 20%, plus replies left.
80
84
  - `week`: your Claude week, with weekly % used, busiest day, days active, limit hits, and a by-day chart.
81
85
  - `notify` (Pro): at a limit, waits and sends a desktop notification when Claude is back. `--test` sends one now.
82
86
 
83
87
  **Your chats.** Claude Code keeps every chat in `~/.claude/projects` and deletes them after 30 days by default. These commands read those files and never change them.
84
88
 
85
- - `search <words>` (Pro): every chat with all the words, the matching lines, and how to reopen it.
89
+ - `search <words>`: chats from the last 7 days with all the words, the matching lines, and how to reopen each. With Pro, every chat however old.
86
90
  - `map [chat]`: a numbered outline of a chat, one line per prompt.
87
- - `export [chat]` (Pro): Markdown by default. Use `--format json` or `txt`, `--turns 3-5` (or `2,4`) for some prompts, and `--out file.md`, or `--out -` to print.
91
+ - `export [chat]`: a chat from the last 7 days as Markdown (default) or `--format txt`; `--out file.md`, or `--out -` to print. With Pro: any chat, `--format json`, and `--turns 3-5` (or `2,4`) for some prompts.
88
92
  - `backup [folder]` (Pro): one Markdown file per chat, by project, in `~/claudekit-backup`, writing only new and changed chats. `--auto` backs up after every session; `--auto off` stops it.
89
93
  - `fork [chat]` (Pro): opens a copy of a chat in Claude Code to try another direction, keeping the original.
90
94
  - `reference [chat]` (Pro): saves a chat in `~/.claudekit/references`. Type `@<path>` in Claude Code to use it as context in another chat.
@@ -105,6 +109,7 @@ Run them as `claudekit-terminal <command>` (or `npx claudekit-terminal <command>
105
109
  - It reads the JSON Claude Code passes to the status line, and Claude Code's chat files on your computer when you run a chat command.
106
110
  - It keeps a few usage numbers in `~/.claudekit/usage.json`: readings for 8 days (percent used, reset times, when each reading was taken, the model family, and short numbers standing for the session and prompt), and one line per day for 90 days (that day's peak 5-hour and weekly %, and its limit hits). No chat text. It also keeps what you save (pins, briefs, references) and your Pro key.
107
111
  - **Anonymous usage counts.** It sends a random id for this terminal, the version, your OS family (macOS, Windows, Linux) and Node.js major version. For each command it sends the name, the names of the flags used (never their values), the exit code and how long it took. It also sends words like `pro_gate: notify` or `key_activated: paid`, and whether a key came from the extension. Once a day it sends whether your limits show (a paid Claude plan), whether you hit a limit, and a usage band. It never sends your chats, prompts, code, file paths, project or repo names, or your key. Counts go out about once an hour from a command you run; the status line never waits on the network. The server keeps the country Cloudflare reports, not your IP address.
112
+ - Setups may appear on claudekit.app as "someone in <country> set it up", with no other detail. Weekly totals show there only once they're 50 or more.
108
113
  - Nothing is sent before you've seen the notice once in a command, so the status line alone never sends anything. Nothing at all is sent after `claudekit-terminal telemetry off`, with `DO_NOT_TRACK=1`, or in CI.
109
114
  - The Pro key is checked on your computer. The network is used to send those counts, to fetch or renew a key, and by `pro` to show the price. `npx` itself may check npm for a newer version; a global install avoids that.
110
115
  - The status line never shows ads.
package/lib/cleanup.js CHANGED
@@ -82,9 +82,9 @@ export function expiringChats(env = process.env, now = Date.now(), withinDays =
82
82
  return { count, days, soonest };
83
83
  }
84
84
 
85
- /** "Claude Code will delete 3 chats in the next 3 days (…)". '' when none. */
85
+ /** "3 chats will be deleted by Claude Code in the next 3 days. …" '' when none. */
86
86
  export function expiryLine(found, say, withinDays = 3) {
87
87
  if (!found?.count) return '';
88
- const chats = found.count === 1 ? '1 chat' : `${found.count} chats`;
89
- return `Claude Code will delete ${chats} in the next ${withinDays} days (it keeps ${found.days} days). Keep them: ${say} backup (Pro), or raise "cleanupPeriodDays" in ~/.claude/settings.json.`;
88
+ const one = found.count === 1;
89
+ return `${one ? '1 chat' : `${found.count} chats`} will be deleted by Claude Code in the next ${withinDays} days (it keeps ${found.days} days). \`${say} backup\` keeps ${one ? 'it' : 'them'} (Pro), or raise "cleanupPeriodDays" in ~/.claude/settings.json.`;
90
90
  }
package/lib/cli.js CHANGED
@@ -25,8 +25,8 @@ 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';
29
- import { TELEMETRY_NOTICE, apiBase, clearQueue, flagNames, flush, flushDue, statusSignals, telemetryAllowed, track } from './telemetry.js';
28
+ import { fetchKeyFor, fetchOffer, gateLines, offerLine, proStatus, redeemTeamCode, refreshKeyIfDue, teamCode } from './pro.js';
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';
32
32
  import { randomBytes } from 'node:crypto';
@@ -200,7 +200,7 @@ export async function run(argv, io = defaultIo()) {
200
200
  function showNotices(io, state, command) {
201
201
  let changed = false;
202
202
  if (!state.noticeShown.grandfather && state.grandfatherUntil && Date.parse(state.grandfatherUntil) > io.now()) {
203
- io.err(`Heads-up: ClaudeKit Pro features in the terminal (run-out forecast, notify, search, export, backup, fork, reference) are part of ClaudeKit Pro from 0.3.0. They stay free for you until Jan 31, 2027. After that they're in ClaudeKit Pro, one licence with the browser extension: ${io.self.say} pro`);
203
+ io.err(`Heads-up: ClaudeKit Pro features in the terminal (the early run-out forecast and replies left, notify, search and export beyond 7 days, backup, fork, reference) are part of ClaudeKit Pro from 0.3.0. They stay free for you until Jan 31, 2027. After that they're in ClaudeKit Pro, one licence with the browser extension: ${io.self.say} pro`);
204
204
  state.noticeShown.grandfather = true;
205
205
  changed = true;
206
206
  track(io.env, state, 'notice', 'grandfather', io.now());
@@ -208,19 +208,32 @@ function showNotices(io, state, command) {
208
208
  if (!state.noticeShown.telemetry && command !== 'telemetry') {
209
209
  io.err(TELEMETRY_NOTICE(io.self.say));
210
210
  state.noticeShown.telemetry = true;
211
+ state.noticeShown.site = true;
211
212
  changed = true;
212
213
  track(io.env, state, 'notice', 'telemetry', io.now());
214
+ } else if (state.noticeShown.telemetry && !state.noticeShown.site && command !== 'telemetry') {
215
+ // Seen before 0.3.1: say once that setups may appear on the site (nothing to say if counts are off).
216
+ if (state.telemetry !== false) io.err(SITE_NOTICE(io.self.say));
217
+ state.noticeShown.site = true;
218
+ changed = true;
219
+ track(io.env, state, 'notice', 'site', io.now());
213
220
  }
214
221
  if (changed) saveTerminal(state, io.env);
215
222
  }
216
223
 
224
+ /** This terminal's Pro status; a key that has ended or ends within 5 days is refreshed first. */
225
+ async function currentPro(io, state) {
226
+ const status = proStatus(io.env, state, io.now());
227
+ if (status.key === 'expired' || (status.via === 'key' && Date.parse(status.exp) - io.now() < 5 * 86_400_000)) {
228
+ if (await refreshKeyIfDue(io.env, io.fetch, io.now())) return proStatus(io.env, state, io.now());
229
+ }
230
+ return status;
231
+ }
232
+
217
233
  /** Pro, or the reason it isn't, printed. Counts the gate hit. A key near its end is refreshed first. */
218
234
  async function requirePro(io, feature, { silent = false } = {}) {
219
235
  const state = io.state ?? loadTerminal(io.env, io.now());
220
- let status = proStatus(io.env, state, io.now());
221
- if (status.key === 'expired' || (status.via === 'key' && Date.parse(status.exp) - io.now() < 5 * 86_400_000)) {
222
- if (await refreshKeyIfDue(io.env, io.fetch, io.now())) status = proStatus(io.env, state, io.now());
223
- }
236
+ const status = await currentPro(io, state);
224
237
  if (status.pro) return true;
225
238
  track(io.env, state, 'pro_gate', feature, io.now());
226
239
  if (status.key === 'expired') track(io.env, state, 'key_expired', status.trial ? 'trial' : 'paid', io.now());
@@ -241,14 +254,9 @@ function forecastFor(readings, cur, key, pro) {
241
254
  return forecast(readings, cur, key);
242
255
  }
243
256
 
244
- /** Pro status for a command with free and Pro parts (a key near its end is refreshed first). */
257
+ /** Pro, for a command with free and Pro parts. Nothing is printed or counted. */
245
258
  async function hasPro(io) {
246
- const state = io.state ?? loadTerminal(io.env, io.now());
247
- const status = proStatus(io.env, state, io.now());
248
- if (status.pro && !(status.via === 'key' && Date.parse(status.exp) - io.now() < 5 * 86_400_000)) return true;
249
- if (status.key === 'none' && !status.pro) return false;
250
- if (await refreshKeyIfDue(io.env, io.fetch, io.now())) return proStatus(io.env, state, io.now()).pro;
251
- return status.pro;
259
+ return (await currentPro(io, io.state ?? loadTerminal(io.env, io.now()))).pro;
252
260
  }
253
261
 
254
262
  // ---------------------------------------------------------------- status line
@@ -316,9 +324,15 @@ function statusNotice(terminal, now) {
316
324
  return null;
317
325
  }
318
326
 
319
- /** "3 chats expire ≤3d" when Claude Code is about to delete chats; checked at most once an hour. */
327
+ /**
328
+ * "Claude Code deletes 3 chats ≤3d" when chats are about to go. Once a day at most (owner, Dec 4):
329
+ * the note stays for its first hour that day. The files are checked at most once an hour.
330
+ */
320
331
  function expirySegment(io, terminal, now) {
321
332
  try {
333
+ const day = new Date(now).toISOString().slice(0, 10);
334
+ const shown = terminal.expiryNote;
335
+ if (shown?.day === day && now - Date.parse(shown.from) >= 3_600_000) return null;
322
336
  const cached = terminal.expiring;
323
337
  let count = cached && now - Date.parse(cached.at) < 3_600_000 ? cached.count : null;
324
338
  if (count === null) {
@@ -326,7 +340,13 @@ function expirySegment(io, terminal, now) {
326
340
  terminal.expiring = { at: new Date(now).toISOString(), count };
327
341
  saveTerminal(terminal, io.env);
328
342
  }
329
- return count > 0 ? `${count} ${count === 1 ? 'chat expires' : 'chats expire'} ≤3d` : null;
343
+ if (!(count > 0)) return null;
344
+ if (shown?.day !== day) {
345
+ terminal.expiryNote = { day, from: new Date(now).toISOString() };
346
+ terminal.expiryWarnedAt = new Date(now).toISOString();
347
+ saveTerminal(terminal, io.env);
348
+ }
349
+ return `Claude Code deletes ${count} ${count === 1 ? 'chat' : 'chats'} ≤3d`;
330
350
  } catch {
331
351
  return null;
332
352
  }
@@ -377,7 +397,7 @@ function setupCommand(argv, io) {
377
397
  ? `ClaudeKit Pro is on until ${new Date(status.exp).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}.`
378
398
  : status.via === 'grandfather'
379
399
  ? 'Pro features stay free for you until Jan 31, 2027.'
380
- : `Free: the status line, usage, week, prompts, tokens, pins. Pro (forecast, notify, search, export, backup, fork): ${self.say} pro`);
400
+ : `Free: the status line, usage, week, the last 7 days of search and export, prompts, tokens, pins. Pro (early forecast, replies left, notify, all-time search, backup, fork): ${self.say} pro`);
381
401
  io.out(lines.join('\n'));
382
402
  if (io.state) {
383
403
  if (!result.statusLine.kept) track(io.env, io.state, 'setup_step', 'settings', io.now());
@@ -749,7 +769,12 @@ async function backupCommand(argv, io) {
749
769
  const { words, flags } = parseArgs(argv);
750
770
  const off = flags.auto === 'off' || words[0] === 'off';
751
771
  // The automatic backup's hook runs with --quiet after every session: without Pro it stays quiet.
752
- if (!off && !(await requirePro(io, flags.auto !== undefined ? 'backup_auto' : 'backup', { silent: flags.quiet === true }))) return flags.quiet ? 0 : 4;
772
+ // A backup someone runs within a day of the deletion warning counts as that warning's click-through
773
+ // (the session-end hook's --quiet run doesn't).
774
+ const warned = Date.parse(io.state?.expiryWarnedAt ?? '');
775
+ const afterWarning = flags.quiet !== true && Number.isFinite(warned) && io.now() - warned < 86_400_000;
776
+ const feature = flags.auto !== undefined ? 'backup_auto' : afterWarning ? 'backup_warning' : 'backup';
777
+ if (!off && !(await requirePro(io, feature, { silent: flags.quiet === true }))) return flags.quiet ? 0 : 4;
753
778
  if (flags.auto !== undefined) return autoBackup(words, flags, io);
754
779
  const dir = resolve(io.cwd, words[0] ?? defaultBackupDir(io.env));
755
780
  const manifestPath = join(dir, '.claudekit-backup.json');
@@ -951,10 +976,11 @@ async function tokensCommand(argv, io) {
951
976
 
952
977
  const fmtDay = (iso) => new Date(iso).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
953
978
 
954
- function activateCommand(argv, io) {
979
+ async function activateCommand(argv, io) {
955
980
  const { words } = parseArgs(argv);
956
981
  const token = (words[0] ?? '').trim();
957
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);
958
984
  const checked = checkKey(token, io.now());
959
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.");
960
986
  if (!checked.ok) {
@@ -971,6 +997,36 @@ function activateCommand(argv, io) {
971
997
  return 0;
972
998
  }
973
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
+
974
1030
  function licenseCommand(argv, io) {
975
1031
  const { flags } = parseArgs(argv);
976
1032
  if (flags.forget) {
@@ -983,7 +1039,7 @@ function licenseCommand(argv, io) {
983
1039
  if (status.via === 'key') io.out(`ClaudeKit Pro${status.trial ? ' (free trial)' : ''} is on until ${fmtDay(status.exp)}.`);
984
1040
  else if (status.via === 'grandfather') io.out(`Pro features are free for you until ${fmtDay(GRANDFATHER_UNTIL)}, because you used ClaudeKit in the terminal before 0.3.0. Keep them after that: ${io.self.say} pro`);
985
1041
  else if (status.key === 'expired') io.out(`Your Pro key ended on ${fmtDay(status.exp)}. Copy a new one from the ClaudeKit popup, or: ${io.self.say} pro`);
986
- else io.out(`Free. Pro adds the run-out forecast, notify, search, export, backup, fork and reference: ${io.self.say} pro`);
1042
+ else io.out(`Free. Pro adds the run-out time from 20% and replies left, notify, all-time search and export, backup, fork and reference: ${io.self.say} pro`);
987
1043
  return 0;
988
1044
  }
989
1045
 
@@ -996,16 +1052,13 @@ async function proCommand(argv, io) {
996
1052
  return 0;
997
1053
  }
998
1054
  // A checkout from the terminal uses its own install id, kept so the key can be picked up later.
999
- if (!state.installId) {
1000
- state.installId = `ckx_${randomBytes(16).toString('hex')}`;
1001
- saveTerminal(state, io.env);
1002
- }
1055
+ ensureInstallId(io, state);
1003
1056
  if (flags.check || words[0] === 'check') return pickUpKey(io, state, 1);
1004
1057
  const period = words[0] === 'monthly' ? 'monthly' : 'yearly';
1005
1058
  const offer = await fetchOffer(io.env, io.fetch);
1006
1059
  const url = `${apiBase(io.env)}/v1/billing/checkout?period=${period}&installId=${state.installId}&source=terminal`;
1007
1060
  io.out([
1008
- 'ClaudeKit Pro: the run-out forecast and replies left, "Claude is back" notifications, search, export, backup, fork and reference chats in the terminal, plus everything Pro in the browser extension. One licence.',
1061
+ 'ClaudeKit Pro: the run-out time from 20% and replies left, "Claude is back" notifications, all-time search and export, backups, fork and reference chats in the terminal, plus everything Pro in the browser extension. One licence.',
1009
1062
  offer ? offerLine(offer) : 'Prices: claudekit.app/pricing',
1010
1063
  '',
1011
1064
  `Checkout (${period}${period === 'yearly' ? `; monthly: ${io.self.say} pro monthly` : ''}):`,
package/lib/docs.js CHANGED
@@ -11,14 +11,14 @@ Set up (one command):
11
11
  ${say} remove undo it (--all also deletes ~/.claudekit)
12
12
 
13
13
  Your limits:
14
- usage every limit, what prompts cost (Pro: run-out forecast, replies left)
14
+ usage every limit, what prompts cost, the run-out time from 70% (Pro: from 20%, replies left)
15
15
  week your Claude week: busiest day, days active, limit hits
16
16
  notify Pro wait, then tell you when Claude is back after a limit
17
17
 
18
18
  Your chats (Claude Code's own files on this computer):
19
- search Pro search every chat
19
+ search search your chats from the last 7 days (Pro: every chat)
20
20
  map [chat] numbered outline of a chat
21
- export Pro save a chat as Markdown (--format json|txt, --turns 3-5, --out file)
21
+ export save a chat from the last 7 days as Markdown or text (Pro: any chat, json, --turns)
22
22
  backup Pro every chat as Markdown in ~/claudekit-backup (--auto: after each session)
23
23
  fork Pro open a copy of a chat to try another direction
24
24
  reference Pro save a chat to bring into another one with @
@@ -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
 
@@ -60,15 +60,18 @@ SET UP
60
60
 
61
61
  FREE AND PRO
62
62
  Free: the status line (model, context, 5-hour and weekly use and resets, what a prompt cost, the
63
- daily budget, the "use it" nudge, the near-limit hint), usage, week, prompts and packs,
64
- /ck- commands, tokens, pins, map, brief.
65
- Pro: the run-out forecast and replies left (status line and usage), notify, search, export,
66
- backup (and --auto), fork, reference, brief --start.
63
+ daily budget, the "use it" nudge, the near-limit hint, the warning before Claude Code
64
+ deletes chats), the run-out time once a limit is 70% used, usage, week, search and export
65
+ of chats from the last 7 days, prompts and packs, /ck- commands, tokens, pins, map, brief.
66
+ Pro: the run-out time from 20% used and replies left (status line and usage), notify,
67
+ search and export of every chat, export as JSON and --turns ranges, backup (and --auto),
68
+ fork, reference, brief --start.
67
69
  If you used ClaudeKit in the terminal before 0.3.0, everything stays free for you until
68
70
  Jan 31, 2027.
69
71
  pro shows the price and opens a checkout in your browser; the key arrives by itself
70
72
  (or later: ${say} pro check). pro monthly for monthly.
71
- 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
72
75
  your computer and renew by themselves while your Pro does.
73
76
  license what Pro this terminal has (--forget removes the key)
74
77
 
@@ -78,15 +81,16 @@ THE STATUS LINE (inside Claude Code)
78
81
  5h 62% your 5-hour session limit used (green, yellow from 70%, red from 90%)
79
82
  +3% what your current prompt has cost of the session so far
80
83
  resets 3:10 PM when the session resets, in your time (at 100%: "back 3:10 PM")
81
- out ~2:40 PM Pro: when you run out at your pace over the last hour (from 20% used)
84
+ out ~2:40 PM when you run out at your pace over the last hour (from 70% used; Pro: from 20%)
82
85
  ~6 replies left Pro: about how many prompts are left at your pace on this model (from 50% used)
83
86
  week 41% your weekly limit, when it resets, and a daily budget (~13%/day)
84
87
  use it in the last day before the weekly reset with 25%+ left: unused limit doesn't roll over
85
88
  spend 63% a spend limit, when your plan has one
86
89
  near limit at 90%: type /ck-handoff to save your context before you're cut off
87
- chats expire Claude Code deletes chats older than cleanupPeriodDays (30 by default) without a
88
- word; this says when some are due within 3 days and aren't backed up (usage and
89
- search say it too)
90
+ Claude Code deletes 2 chats ≤3d
91
+ Claude Code deletes chats older than cleanupPeriodDays (30 by default) without a
92
+ word; this says when some are due within 3 days and aren't backed up. Once a day
93
+ at most, for an hour (usage says it too, once a day)
90
94
  Limits show for Claude Pro, Max and Ultra plans, after the first reply in a session.
91
95
  Options: --no-color (or NO_COLOR), --no-history (or CLAUDEKIT_NO_HISTORY=1) keeps no numbers.
92
96
 
@@ -103,7 +107,8 @@ COMMANDS IN CLAUDE CODE (type them; Claude never runs them on its own)
103
107
 
104
108
  YOUR LIMITS
105
109
  usage every limit with bars and reset times, what your last prompt and this chat
106
- cost, per-model cost, days without a limit (Pro: run-out forecast, replies left)
110
+ cost, per-model cost, days without a limit, the run-out time from 70% used
111
+ (Pro: from 20%, and replies left)
107
112
  week your Claude week: weekly % used, busiest day, days active, limit hits, by day
108
113
  notify Pro at a limit, waits and sends a desktop notification when Claude is back
109
114
  (--test sends one now)
@@ -111,10 +116,11 @@ YOUR LIMITS
111
116
  YOUR CHATS
112
117
  Claude Code keeps every chat in ~/.claude/projects and deletes them after 30 days by default.
113
118
  These commands read those files; they never change them.
114
- search Pro every chat that has all the words, with the matching lines and how to reopen it
119
+ search every chat from the last 7 days that has all the words, with the matching lines
120
+ and how to reopen it (Pro: every chat, however old)
115
121
  map [chat] a numbered outline: one line per prompt
116
- export Pro Markdown (default), --format json or txt; --turns 3-5 or 2,4 for some prompts;
117
- --out file.md, or --out - to print it
122
+ export a chat from the last 7 days as Markdown (default) or --format txt; --out file.md,
123
+ or --out - to print it. Pro: any chat, --format json, --turns 3-5 or 2,4
118
124
  backup Pro one Markdown file per chat, by project, in ~/claudekit-backup; only new and
119
125
  changed chats are written. --auto turns on a backup after every session,
120
126
  --auto off turns it off
@@ -142,7 +148,9 @@ PRIVACY
142
148
  major version; per command its name, flag names (never values), exit code and duration; words
143
149
  like "pro_gate: notify"; and once a day whether limits show (a paid Claude plan), a limit hit and
144
150
  a usage band. Never your chats, prompts, code, file paths, project or repo names, or your key.
145
- Counts go out about once an hour from a command; the status line never waits on the network. Nothing is sent before you've seen the notice once, and nothing at all after
151
+ Counts go out about once an hour from a command; the status line never waits on the network.
152
+ Setups may appear on claudekit.app as "someone in <country> set it up", with no other detail.
153
+ Nothing is sent before you've seen the notice once, and nothing at all after
146
154
  ${say} telemetry off, with DO_NOT_TRACK=1, or in CI.
147
155
  The Pro key is checked on your computer. The network is used to send those counts, to fetch or
148
156
  renew a key, and by pro to show the price. npx itself may check npm for a newer version; a
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/lib/telemetry.js CHANGED
@@ -13,8 +13,14 @@ import { kitDir } from './paths.js';
13
13
  const MAX_QUEUE = 200;
14
14
  const queuePath = (env) => join(kitDir(env), 'events.json');
15
15
 
16
+ /** Said on the site's terminal page from 0.3.1 (Sales spec, Dec 4): country only, no other detail. */
17
+ export const SITE_LINE = "Setups may appear on claudekit.app as 'someone in <country> set it up', with no other detail.";
18
+
16
19
  export const TELEMETRY_NOTICE = (say) =>
17
- `ClaudeKit for the terminal sends anonymous usage counts (which commands run and when a Pro feature is asked for; never your chats, code, file paths or keys) so we can make it better. Turn it off any time: ${say} telemetry off (or set DO_NOT_TRACK=1).`;
20
+ `ClaudeKit for the terminal sends anonymous usage counts (which commands run and when a Pro feature is asked for; never your chats, code, file paths or keys) so we can make it better. ${SITE_LINE} Turn it off any time: ${say} telemetry off (or set DO_NOT_TRACK=1).`;
21
+
22
+ /** For people who saw the notice before 0.3.1 said that. */
23
+ export const SITE_NOTICE = (say) => `New in 0.3.1: ${SITE_LINE} Turn usage counts off: ${say} telemetry off`;
18
24
 
19
25
  export function apiBase(env = process.env) {
20
26
  return (env.CLAUDEKIT_API || 'https://api.claudekit.app').replace(/\/$/, '');
@@ -1,12 +1,16 @@
1
1
  // ~/.claudekit/terminal.json: this terminal's own settings.
2
2
  // id random "ckt_…" id for the anonymous usage counts (never tied to a person)
3
3
  // telemetry false once turned off
4
- // noticeShown { telemetry, grandfather }: one-time notices already shown
4
+ // noticeShown { telemetry, site, grandfather }: one-time notices already shown (site: the 0.3.1
5
+ // line that setups may appear on claudekit.app)
5
6
  // grandfatherUntil set for people who used ClaudeKit in the terminal before 0.3.0: every
6
7
  // feature stays free for them until then (Terminal Pro, Dec 2026)
7
8
  // hints { command: 'YYYY-MM-DD' }: the last day a "Pro: …" hint was shown for it
8
9
  // installId the id a terminal checkout used, so `pro` can pick up its key later
9
10
  // lastDaily 'YYYY-MM-DD' of the status line's last daily count
11
+ // expiring { at, count }: chats Claude Code deletes within 3 days, checked hourly
12
+ // expiryNote { day, from }: the day's status-line deletion note (shown for its first hour)
13
+ // expiryWarnedAt when the deletion warning was last shown (a backup soon after counts it)
10
14
 
11
15
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
12
16
  import { randomBytes } from 'node:crypto';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claudekit-terminal",
3
- "version": "0.3.0",
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; forecasts, notify, search, export, backup and fork with ClaudeKit Pro. One command sets it up. Zero dependencies; anonymous usage counts you can turn off.",
3
+ "version": "0.3.2",
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": {
7
7
  "claudekit-terminal": "bin/claudekit-terminal.js"