claudekit-terminal 0.2.0 → 0.3.0
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 +34 -16
- package/lib/cleanup.js +90 -0
- package/lib/cli.js +386 -17
- package/lib/docs.js +60 -27
- package/lib/license.js +77 -0
- package/lib/pro.js +118 -0
- package/lib/state.js +28 -2
- package/lib/statusline.js +2 -0
- package/lib/telemetry.js +121 -0
- package/lib/terminal-state.js +68 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,7 +12,22 @@ npx claudekit-terminal setup
|
|
|
12
12
|
|
|
13
13
|
That's it. Send a message in Claude Code and the status line appears after the first reply. Undo it all with `npx claudekit-terminal remove`.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
No account, zero dependencies, Node.js 18 or newer. It's the terminal side of the [ClaudeKit browser extension](https://claudekit.app/get?utm_source=terminal&utm_medium=readme), with the same features wherever a terminal can. Seeing your limits is free; acting on them is **ClaudeKit Pro**, one licence for the terminal and the browser.
|
|
16
|
+
|
|
17
|
+
Sends anonymous usage counts (never your chats or code); turn it off with `claudekit-terminal telemetry off` or `DO_NOT_TRACK=1`. The Pro licence is checked offline.
|
|
18
|
+
|
|
19
|
+
## Free and Pro
|
|
20
|
+
|
|
21
|
+
| Free | ClaudeKit Pro |
|
|
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` |
|
|
26
|
+
|
|
27
|
+
- **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
|
+
- **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.
|
|
29
|
+
- Keys are checked on your computer and renew by themselves while your Pro does. `claudekit-terminal license` shows what you have.
|
|
30
|
+
- **Used ClaudeKit in the terminal before 0.3.0?** Everything stays free for you until Jan 31, 2027.
|
|
16
31
|
|
|
17
32
|
## What setup does
|
|
18
33
|
|
|
@@ -32,16 +47,17 @@ Faster status line: `npm install -g claudekit-terminal`, then `claudekit-termina
|
|
|
32
47
|
| `5h 62%` | Your 5-hour session limit used: green, yellow from 70%, red from 90% |
|
|
33
48
|
| `+3%` | What your current prompt has cost of the session so far |
|
|
34
49
|
| `resets 3:10 PM` | When the session resets, in your time. At 100% it says `back 3:10 PM` |
|
|
35
|
-
| `out ~2:40 PM` |
|
|
36
|
-
| `~6 replies left` |
|
|
50
|
+
| `out ~2:40 PM` | Pro: when you run out at your pace over the last hour (from 20% used) |
|
|
51
|
+
| `~6 replies left` | Pro: about how many prompts are left at your pace on this model (from 50% used) |
|
|
37
52
|
| `week 41% · Thu 9:00 AM · ~13%/day` | Your weekly limit, when it resets, and a daily budget |
|
|
38
53
|
| `use it: resets in 10h` | In the last day before the weekly reset with 25% or more left: unused limit doesn't roll over |
|
|
39
54
|
| `spend 63% of $500` | A spend limit, when your plan has one |
|
|
40
55
|
| `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 |
|
|
41
57
|
|
|
42
58
|
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.
|
|
43
59
|
|
|
44
|
-
Options: `--no-color` (or `NO_COLOR`), `--no-history` (or `CLAUDEKIT_NO_HISTORY=1`) to keep no numbers. Without
|
|
60
|
+
Options: `--no-color` (or `NO_COLOR`), and `--no-history` (or `CLAUDEKIT_NO_HISTORY=1`) to keep no numbers. Without the numbers, the forecast, prompt cost and replies left can't be worked out.
|
|
45
61
|
|
|
46
62
|
## Commands in Claude Code
|
|
47
63
|
|
|
@@ -60,19 +76,19 @@ Run them as `claudekit-terminal <command>` (or `npx claudekit-terminal <command>
|
|
|
60
76
|
|
|
61
77
|
**Your limits**
|
|
62
78
|
|
|
63
|
-
- `usage`: every limit with bars and reset times,
|
|
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.
|
|
64
80
|
- `week`: your Claude week, with weekly % used, busiest day, days active, limit hits, and a by-day chart.
|
|
65
|
-
- `notify
|
|
81
|
+
- `notify` (Pro): at a limit, waits and sends a desktop notification when Claude is back. `--test` sends one now.
|
|
66
82
|
|
|
67
83
|
**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.
|
|
68
84
|
|
|
69
|
-
- `search <words
|
|
85
|
+
- `search <words>` (Pro): every chat with all the words, the matching lines, and how to reopen it.
|
|
70
86
|
- `map [chat]`: a numbered outline of a chat, one line per prompt.
|
|
71
|
-
- `export [chat]
|
|
72
|
-
- `backup [folder]
|
|
73
|
-
- `fork [chat]
|
|
74
|
-
- `reference [chat]
|
|
75
|
-
- `brief`: your last Handoff Brief for this folder. `--start` opens a new session from it.
|
|
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.
|
|
88
|
+
- `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
|
+
- `fork [chat]` (Pro): opens a copy of a chat in Claude Code to try another direction, keeping the original.
|
|
90
|
+
- `reference [chat]` (Pro): saves a chat in `~/.claudekit/references`. Type `@<path>` in Claude Code to use it as context in another chat.
|
|
91
|
+
- `brief`: your last Handoff Brief for this folder. `--start` (Pro) opens a new session from it.
|
|
76
92
|
- `pins`: this folder's pins (`--all` for every folder). `pin "text"` adds one.
|
|
77
93
|
|
|
78
94
|
`[chat]` is the newest chat in this folder, a session id (or its first 4+ characters), or words from its title.
|
|
@@ -86,11 +102,13 @@ Run them as `claudekit-terminal <command>` (or `npx claudekit-terminal <command>
|
|
|
86
102
|
|
|
87
103
|
## Privacy
|
|
88
104
|
|
|
89
|
-
- It makes no network calls. (`npx` itself may check npm for a newer version; a global install avoids that.)
|
|
90
105
|
- 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.
|
|
91
|
-
- It keeps a few usage numbers in `~/.claudekit/usage.json
|
|
92
|
-
-
|
|
93
|
-
-
|
|
106
|
+
- 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
|
+
- **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.
|
|
108
|
+
- 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
|
+
- 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
|
+
- The status line never shows ads.
|
|
111
|
+
- `claudekit-terminal remove --all` deletes `~/.claudekit`, which holds the numbers, this terminal's id and your key. Backups you made stay where you put them.
|
|
94
112
|
|
|
95
113
|
## Moving from claudekit-statusline
|
|
96
114
|
|
package/lib/cleanup.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Claude Code deletes chats silently (docs: claude-directory "Cleaned up automatically"): a session
|
|
2
|
+
// file older than `cleanupPeriodDays` (default 30, minimum 1) goes in a background sweep after a
|
|
3
|
+
// session starts. Sessions started or last continued in Claude Desktop or Cowork are kept at any
|
|
4
|
+
// age unless `desktopSessionCleanupPeriodDays` is set. This finds the chats due to go in the next
|
|
5
|
+
// few days, so ClaudeKit can say so before they're gone (free), with backup (Pro) as the way to keep them.
|
|
6
|
+
|
|
7
|
+
import { closeSync, existsSync, fstatSync, openSync, readFileSync, readSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
import { DAY_MS } from './format.js';
|
|
11
|
+
import { defaultBackupDir, settingsPath } from './paths.js';
|
|
12
|
+
import { listSessions } from './transcripts.js';
|
|
13
|
+
|
|
14
|
+
function readDays(value) {
|
|
15
|
+
const n = Number(value);
|
|
16
|
+
return Number.isInteger(n) && n >= 1 ? n : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The retention settings from ~/.claude/settings.json. */
|
|
20
|
+
export function retention(env = process.env) {
|
|
21
|
+
try {
|
|
22
|
+
const settings = JSON.parse(readFileSync(settingsPath(env), 'utf8'));
|
|
23
|
+
return { days: readDays(settings?.cleanupPeriodDays) ?? 30, desktopDays: readDays(settings?.desktopSessionCleanupPeriodDays) };
|
|
24
|
+
} catch {
|
|
25
|
+
return { days: 30, desktopDays: null };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The last "entrypoint" recorded in a transcript (read from its end only). */
|
|
30
|
+
export function lastEntrypoint(path) {
|
|
31
|
+
try {
|
|
32
|
+
const fd = openSync(path, 'r');
|
|
33
|
+
try {
|
|
34
|
+
const size = fstatSync(fd).size;
|
|
35
|
+
const length = Math.min(size, 256 * 1024);
|
|
36
|
+
const buf = Buffer.alloc(length);
|
|
37
|
+
readSync(fd, buf, 0, length, size - length);
|
|
38
|
+
const matches = [...buf.toString('utf8').matchAll(/"entrypoint":"([^"]{1,40})"/g)];
|
|
39
|
+
return matches.length ? matches.at(-1)[1] : null;
|
|
40
|
+
} finally {
|
|
41
|
+
closeSync(fd);
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const isDesktop = (entrypoint) => typeof entrypoint === 'string' && /desktop|cowork/i.test(entrypoint);
|
|
49
|
+
|
|
50
|
+
/** Chat ids already copied by `backup` into the default folder, unchanged since. */
|
|
51
|
+
function backedUp(env) {
|
|
52
|
+
try {
|
|
53
|
+
const manifest = JSON.parse(readFileSync(join(defaultBackupDir(env), '.claudekit-backup.json'), 'utf8'));
|
|
54
|
+
return manifest?.chats && typeof manifest.chats === 'object' ? manifest.chats : {};
|
|
55
|
+
} catch {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Chats Claude Code will delete within `withinDays`, not already in the backup.
|
|
62
|
+
* @returns {{ count: number, days: number, soonest: number | null }}
|
|
63
|
+
*/
|
|
64
|
+
export function expiringChats(env = process.env, now = Date.now(), withinDays = 3) {
|
|
65
|
+
const { days, desktopDays } = retention(env);
|
|
66
|
+
const kept = backedUp(env);
|
|
67
|
+
let count = 0;
|
|
68
|
+
let soonest = null;
|
|
69
|
+
for (const file of listSessions(env)) {
|
|
70
|
+
const known = kept[file.id];
|
|
71
|
+
if (known && known.size === file.size && known.mtimeMs === file.mtimeMs && existsSync(join(defaultBackupDir(env), known.file))) continue;
|
|
72
|
+
const quickest = Math.min(days, desktopDays ?? days);
|
|
73
|
+
if (file.mtimeMs + (quickest - withinDays) * DAY_MS > now) continue;
|
|
74
|
+
const desktop = isDesktop(lastEntrypoint(file.path));
|
|
75
|
+
const limit = desktop ? desktopDays : days;
|
|
76
|
+
if (limit === null) continue;
|
|
77
|
+
const goesAt = file.mtimeMs + limit * DAY_MS;
|
|
78
|
+
if (goesAt - now > withinDays * DAY_MS) continue;
|
|
79
|
+
count += 1;
|
|
80
|
+
soonest = soonest === null ? goesAt : Math.min(soonest, goesAt);
|
|
81
|
+
}
|
|
82
|
+
return { count, days, soonest };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** "Claude Code will delete 3 chats in the next 3 days (…)". '' when none. */
|
|
86
|
+
export function expiryLine(found, say, withinDays = 3) {
|
|
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.`;
|
|
90
|
+
}
|