limitcast 0.15.0 → 0.16.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/bin/limitcast.mjs CHANGED
@@ -43,13 +43,13 @@ import {
43
43
  import { runGuard } from '../src/guard.mjs';
44
44
  import { accountForecasts, bindingLine, compactHint, headroom, lastCall, lastCallTokens } from '../src/hints.mjs';
45
45
  import { htmlPage } from '../src/html.mjs';
46
+ import { insightsReport, insightsShare, periodInsights } from '../src/insights.mjs';
46
47
  import { doctor, install, installedFeatures, readSettings, settingsPath, uninstall } from '../src/install.mjs';
47
- import { activate, currentLicense, isPro, startTrial, trialStatus, UPGRADE_URL } from '../src/license.mjs';
48
48
  import { memoryCheck, memoryDir, memoryReport, scanMemory } from '../src/memory.mjs';
49
49
  import { buildNotifierApp, loadChannels, notifierApp, notifyChanges, notifyEnabled, send, setChannel, setNotify } from '../src/notify.mjs';
50
+ import { onboardingReport } from '../src/onboarding.mjs';
50
51
  import { driftMessage, loadOverhead, recordOverhead, savedPerSession, savedSummary, snapshot } from '../src/overhead.mjs';
51
52
  import { advise, getPlan, loadPeaks, PLANS, planPrices, planStats, recordPeaks, setPlan } from '../src/plan.mjs';
52
- import { activatePolar, deactivatePolar, refreshDue, refreshPolar } from '../src/polar.mjs';
53
53
  import { costOf, fmtUsd } from '../src/prices.mjs';
54
54
  import { burnReport } from '../src/report.mjs';
55
55
  import { loadBlocks, logBlock, resultsReport, resultsShare, resultsStats, weeklyDue, weeklyLine } from '../src/results.mjs';
@@ -75,17 +75,16 @@ import { forTerminal } from '../src/term.mjs';
75
75
  import { firstFlag, toolKey, toolNotice } from '../src/toolcheck.mjs';
76
76
  import { baseline, contributors, measuredSavings, shareSummary, startupReport, trimReport } from '../src/trim.mjs';
77
77
  import { claudeRoot, grokRoot, readUsage } from '../src/usage.mjs';
78
- import { dailyDue, foldEvents, loadValue, saveValue, scanSessions, valueSection, valueTotals } from '../src/value.mjs';
78
+ import { dailyDue, foldEvents, loadValue, saveValue, scanSessions, valuePeriod, valueSection, valueTotals } from '../src/value.mjs';
79
79
  import { attribute, jobsReport, whyReport, whySessions } from '../src/where.mjs';
80
80
 
81
81
  const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
82
82
  const HELP = `limitcast ${VERSION}: stretch your Claude Code, Codex and Grok plans
83
83
 
84
+ limitcast onboard read-only setup checks and a guided first useful result
84
85
  limitcast install [--guard] wire limitcast into Claude Code (and, with --guard, Codex and Grok); backs up settings
85
- (without Pro the guard is a preview: it records what it would block, never blocks)
86
86
  limitcast uninstall remove it and restore your original status line
87
87
  limitcast doctor [--fix] check the setup (--fix: re-install with this Node, e.g. after a Node upgrade)
88
- limitcast trial Pro free for 7 days on this computer, no card
89
88
  limitcast status [--json] used, burn rate, runout time, reset, and today's share of each weekly window
90
89
  limitcast trim [--share] tokens every session loads before you type, and how much you never use
91
90
  limitcast trim --codex the same for Codex: AGENTS.md size and MCP servers you haven't used
@@ -93,9 +92,9 @@ const HELP = `limitcast ${VERSION}: stretch your Claude Code, Codex and Grok pla
93
92
  limitcast memory [dir] check this project's auto-memory: load cap, broken links, unlinked and oversized files
94
93
  limitcast results [--days N] limits you reached, how far ahead limitcast warned, what the guard blocked
95
94
  [--share] totals only, safe to post
96
- limitcast license show the license and re-check it with Polar
95
+ limitcast license show the MIT license status
97
96
 
98
- Pro (${UPGRADE_URL})
97
+ All features are free (MIT License)
99
98
  limitcast trim [--days N] [--share] names what to cut and what each costs
100
99
  (--share: totals only, no names, safe to post)
101
100
  limitcast trim --apply / --undo hide those skills and turn off those MCP servers (backed up, reversible)
@@ -128,16 +127,14 @@ const HELP = `limitcast ${VERSION}: stretch your Claude Code, Codex and Grok pla
128
127
  limitcast report [--days N] [--out FILE] tokens by tool, day, project, model and session
129
128
  limitcast report --why [--days N] where the new tokens went: subagents, session starts, cache rebuilds, tool results
130
129
  limitcast report --jobs [--days N] the scheduled (headless) jobs that spend the most tokens just starting
131
- (status line, Pro: points to another account with room, and suggests /compact past ~150k tokens a call)
132
- limitcast activate <license-key> unlock Pro on this computer (online once; then a weekly check, offline up to 30 days)
133
- limitcast deactivate free this computer's activation to use the key elsewhere
130
+ (status line: points to another account with room, and suggests /compact past ~150k tokens a call)
134
131
 
135
132
  Used by Claude Code, Codex and Grok (set up by install)
136
133
  limitcast statusline [-- <cmd...>] record limit readings, then run your status-line command
137
- limitcast guard PreToolUse hook (Pro)
138
- limitcast prompt-check UserPromptSubmit hook: the cold-cache warning (Pro)
139
- limitcast subagent-receipt SubagentStop hook: what the subagent cost (Pro)
140
- limitcast drift [--hook] SessionStart hook: compare starting context with the last session (Pro)
134
+ limitcast guard PreToolUse hook
135
+ limitcast prompt-check UserPromptSubmit hook: the cold-cache warning
136
+ limitcast subagent-receipt SubagentStop hook: what the subagent cost
137
+ limitcast drift [--hook] SessionStart hook: compare starting context with the last session
141
138
  `;
142
139
 
143
140
  const [cmd, ...args] = process.argv.slice(2);
@@ -146,12 +143,14 @@ const flag = (/** @type {string} */ name) => {
146
143
  const i = args.indexOf(name);
147
144
  return i >= 0 ? args[i + 1] : undefined;
148
145
  };
149
- const days = () => Math.max(1, Number(flag('--days') ?? 7));
150
-
151
- // Interactive commands re-check a Polar license weekly; hooks (statusline, guard, drift --hook) never touch the network.
152
- if (['report', 'trim', 'saved', 'results', 'drift', 'doctor', 'license'].includes(cmd) && !args.includes('--hook')) {
153
- await refreshPolar({ force: cmd === 'license' }).catch(() => null);
154
- }
146
+ const days = () => {
147
+ const n = Number(flag('--days') ?? 7);
148
+ if (!Number.isFinite(n) || n <= 0 || !Number.isFinite(new Date(now - n * 86400_000).getTime())) {
149
+ console.error('--days must be a finite positive number.');
150
+ process.exit(1);
151
+ }
152
+ return Math.max(1, n);
153
+ };
155
154
 
156
155
  if (cmd === 'status') {
157
156
  const rows = forecastAll(oneClaudeAccount([...load(now - KEEP_MS), ...(await readCodex(now - KEEP_MS)), ...grokSamples(now)]), now);
@@ -160,12 +159,11 @@ if (cmd === 'status') {
160
159
  console.log(rows.length ? table(rows) : 'No data yet. Run `limitcast install`, then send a message in Claude Code, Codex or Grok.');
161
160
  const binds = bindingLine(rows, getGrokBudget(), clock);
162
161
  if (binds) console.log(`\n${binds}`);
163
- // Pro: the other Claude accounts limitcast has current readings for (the table shows the latest one).
164
- if (isPro())
165
- for (const a of accountForecasts(load(now - KEEP_MS), now).slice(1))
166
- console.log(
167
- `other Claude account (last used ${clock(a.lastSeen)}): ${a.rows.map((f) => `${f.win} ${f.verdict === 'RESET' ? 0 : Math.round(f.pct)}%${f.verdict === 'OK' || f.verdict === 'RESET' ? '' : ` ${f.verdict}`}`).join(' · ')}`,
168
- );
162
+ // the other Claude accounts limitcast has current readings for (the table shows the latest one).
163
+ for (const a of accountForecasts(load(now - KEEP_MS), now).slice(1))
164
+ console.log(
165
+ `other Claude account (last used ${clock(a.lastSeen)}): ${a.rows.map((f) => `${f.win} ${f.verdict === 'RESET' ? 0 : Math.round(f.pct)}%${f.verdict === 'OK' || f.verdict === 'RESET' ? '' : ` ${f.verdict}`}`).join(' · ')}`,
166
+ );
169
167
  const spend = grokSpendLine(now);
170
168
  if (spend) console.log(spend);
171
169
  else if (existsSync(grokRoot()) && !rows.some((f) => f.src === 'grok'))
@@ -183,13 +181,11 @@ if (cmd === 'status') {
183
181
  sid = feed?.session_id;
184
182
  record(claudeSamples(feed, now));
185
183
  saveFeedShape(feed);
186
- // Hook-only Pro users never run an interactive command, so the weekly Polar check starts here, detached.
187
- if (refreshDue(now)) spawn(process.execPath, [fileURLToPath(import.meta.url), 'license'], { detached: true, stdio: 'ignore' }).unref();
188
184
  // Readings are kept 8 days; the daily rollup folds what they showed into the long-term value record.
189
185
  if (dailyDue(now)) spawn(process.execPath, [fileURLToPath(import.meta.url), 'rollup'], { detached: true, stdio: 'ignore' }).unref();
190
186
  const health = healthHint();
191
187
  if (health) hints.push(health);
192
- if (isPro()) {
188
+ {
193
189
  const samples = load(now - KEEP_MS);
194
190
  if (notifyEnabled()) notifyChanges(forecastAll(oneClaudeAccount([...samples, ...grokSamples(now)], sid), now), clock);
195
191
  const room = headroom(samples, sid, now);
@@ -200,9 +196,6 @@ if (cmd === 'status') {
200
196
  const ctx = compactHint(lastCallTokens(feed.transcript_path));
201
197
  if (ctx) hints.push(ctx);
202
198
  }
203
- } else {
204
- const week = freeWeeklyHint(now);
205
- if (week) hints.push(week);
206
199
  }
207
200
  } catch {
208
201
  /* never break the status line */
@@ -230,10 +223,10 @@ if (cmd === 'status') {
230
223
  if (grokOwn) console.log(grokOwn);
231
224
  console.log(`limitcast: ${line}`);
232
225
  } else if (cmd === 'guard') {
233
- // Blocking is Pro; without a valid license the guard only previews (logs what Pro would block) and allows everything.
226
+ // The installed guard protects all users; LIMITCAST_ALLOW=1 remains the explicit override.
234
227
  if (process.env.LIMITCAST_ALLOW === '1') process.exit(0);
235
228
  try {
236
- const d = await runGuard(JSON.parse(readStdin()), now, Number(process.env.LIMITCAST_GUARD_MINUTES ?? 30), { preview: !isPro() });
229
+ const d = await runGuard(JSON.parse(readStdin()), now, Number(process.env.LIMITCAST_GUARD_MINUTES ?? 30), { preview: false });
237
230
  if (typeof d === 'string') {
238
231
  console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: d } }));
239
232
  } else if (d && 'notice' in d) {
@@ -258,14 +251,14 @@ if (cmd === 'status') {
258
251
  }
259
252
  } else if (cmd === 'prompt-check') {
260
253
  // UserPromptSubmit hook: hold the first message after the prompt cache expired, once, with its cost.
261
- // Pro blocks; free only records what Pro would have held. Fails open.
254
+ // The opt-in hook warns once and fails open on errors.
262
255
  try {
263
256
  const hook = JSON.parse(readStdin());
264
257
  const path = hook?.transcript_path;
265
258
  const last = process.env.LIMITCAST_ALLOW !== '1' && typeof path === 'string' && existsSync(path) ? lastCall(path) : null;
266
259
  const c = coldCost(hook?.prompt, last, now, { minutes: Number(process.env.LIMITCAST_CACHE_MINUTES ?? 60), calib: loadValue().calib });
267
260
  if (c && last && firstWarning(String(hook.session_id), last.t)) {
268
- const pro = isPro();
261
+ const pro = true;
269
262
  logBlock({
270
263
  t: now,
271
264
  kind: 'cold',
@@ -284,10 +277,10 @@ if (cmd === 'status') {
284
277
  /* a hook must never stop a prompt by failing */
285
278
  }
286
279
  } else if (cmd === 'tool-check') {
287
- // PostToolUse hook (Pro, installed with --alerts): tell the user, once per tool per session, about a very large tool
280
+ // PostToolUse hook (installed with --alerts): tell the user, once per tool per session, about a very large tool
288
281
  // result and what to ask for next time. Never reaches the model.
289
282
  try {
290
- if (isPro()) {
283
+ {
291
284
  const hook = JSON.parse(readStdin());
292
285
  const name = String(hook?.tool_name ?? '');
293
286
  const notice = name ? toolNotice(name, hook?.tool_response, loadValue().calib, Number(process.env.LIMITCAST_TOOL_TOKENS) || undefined) : null;
@@ -317,19 +310,13 @@ if (cmd === 'status') {
317
310
  read: u.read,
318
311
  ...(pct === null ? {} : { pct }),
319
312
  });
320
- if (isPro()) console.log(JSON.stringify({ systemMessage: receiptMessage(hook.agent_type, u, pct) }));
313
+ console.log(JSON.stringify({ systemMessage: receiptMessage(hook.agent_type, u, pct) }));
321
314
  }
322
315
  }
323
316
  } catch {
324
317
  /* a hook must never break the session */
325
318
  }
326
319
  } else if (cmd === 'plan') {
327
- if (!isPro()) {
328
- console.log(
329
- `\`limitcast plan\` is part of limitcast Pro: ${UPGRADE_URL}\nTry it free for 7 days: limitcast trial. Already bought it? limitcast activate <license-key>`,
330
- );
331
- process.exit(2);
332
- }
333
320
  if (args[0] === 'set') {
334
321
  const id = args[1];
335
322
  if (id !== 'off' && !(id in PLANS)) {
@@ -368,10 +355,6 @@ if (cmd === 'status') {
368
355
  console.log(forTerminal(out.join('\n')));
369
356
  process.exit(0);
370
357
  } else if (cmd === 'subagent-model') {
371
- if (!isPro()) {
372
- console.log(`Per-type subagent models are part of limitcast Pro: ${UPGRADE_URL}`);
373
- process.exit(2);
374
- }
375
358
  const [type, model] = args;
376
359
  if (type && (model === undefined || (model !== 'off' && !validModel(model)))) {
377
360
  console.log(
@@ -403,10 +386,6 @@ if (cmd === 'status') {
403
386
  } else console.log('\nExample: limitcast subagent-model Explore haiku');
404
387
  process.exit(0);
405
388
  } else if (cmd === 'budget') {
406
- if (!isPro()) {
407
- console.log(`Budgets are part of limitcast Pro: ${UPGRADE_URL}`);
408
- process.exit(2);
409
- }
410
389
  if (args[0] === 'grok') {
411
390
  const win = args[1] === '7d' || args[1] === '5h' ? args[1] : '5h';
412
391
  const value = args[1] === '7d' || args[1] === '5h' ? args[2] : args[1];
@@ -467,13 +446,7 @@ if (cmd === 'status') {
467
446
  } else if (cmd === 'install') {
468
447
  const wantGuard = args.includes('--guard');
469
448
  const wantAlerts = args.includes('--alerts');
470
- if (wantGuard && !isPro()) {
471
- console.log(
472
- `Without Pro the subagent guard runs as a preview: it never blocks, it records what Pro would have blocked (see \`limitcast results\`). Pro: ${UPGRADE_URL}`,
473
- );
474
- }
475
- if (wantAlerts && !isPro()) console.log(`Alerts and the weekly summary are part of limitcast Pro (${UPGRADE_URL}). Skipping them.`);
476
- for (const c of install({ guard: wantGuard, alerts: wantAlerts && isPro() })) console.log(`✓ ${c}`);
449
+ for (const c of install({ guard: wantGuard, alerts: wantAlerts })) console.log(`✓ ${c}`);
477
450
  console.log('Restart Claude Code, Codex and Grok to load it. Then: limitcast doctor');
478
451
  if (wantGuard && grokPresent() && !getGrokBudget())
479
452
  console.log('Grok stores spend, not a % used. Set a 5-hour dollar cap so the guard can block: limitcast budget grok <usd>');
@@ -500,19 +473,40 @@ if (cmd === 'status') {
500
473
  } catch {
501
474
  /* no transcripts yet */
502
475
  }
503
- console.log(
504
- `In a week, \`limitcast results\` shows every limit you hit and how far ahead limitcast warned you.${isPro() ? '' : ' Try Pro free for 7 days, no card: limitcast trial'}`,
505
- );
476
+ console.log(`In a week, \`limitcast results\` shows every limit you hit and how far ahead limitcast warned you.`);
506
477
  } else if (cmd === 'uninstall') {
507
478
  const changes = uninstall();
508
479
  console.log(changes.length ? changes.map((c) => `✓ ${c}`).join('\n') : 'Nothing to remove.');
480
+ } else if (cmd === 'onboard') {
481
+ const checks = await healthChecks();
482
+ let features = { statusLine: false, guard: false, alerts: false };
483
+ try {
484
+ features = installedFeatures();
485
+ } catch {
486
+ /* invalid settings are explained by doctor */
487
+ }
488
+ const latest = await latestInteractiveTranscript(claudeRoot());
489
+ const providers = [];
490
+ if (existsSync(settingsPath()) || latest) providers.push('Claude Code');
491
+ if (existsSync(codexConfigPath())) providers.push('Codex');
492
+ if (grokPresent()) providers.push('Grok');
493
+ console.log(
494
+ forTerminal(
495
+ onboardingReport({
496
+ checks,
497
+ features,
498
+ providers,
499
+ contextTokens: latest ? latest.pieces.reduce((n, p) => n + p.chars, 0) / 4 : null,
500
+ }),
501
+ ),
502
+ );
509
503
  } else if (cmd === 'doctor') {
510
504
  if (args.includes('--fix')) {
511
505
  // Re-install what is installed, with this Node and this copy of limitcast (after a Node upgrade, say).
512
506
  const f = installedFeatures();
513
507
  if (!f.statusLine) console.log('limitcast is not installed. Run `limitcast install` first.');
514
508
  else {
515
- for (const c of install({ guard: f.guard && isPro(), alerts: f.alerts && isPro() })) console.log(`✓ ${c}`);
509
+ for (const c of install({ guard: f.guard, alerts: f.alerts })) console.log(`✓ ${c}`);
516
510
  console.log('Restart Claude Code, Codex and Grok to load it. Codex asks you to approve the guard again: start Codex and accept it.');
517
511
  }
518
512
  }
@@ -527,13 +521,7 @@ if (cmd === 'status') {
527
521
  const dir = args.find((a) => !a.startsWith('-')) ?? memoryDir();
528
522
  console.log(memoryReport(scanMemory(dir), dir));
529
523
  } else if (cmd === 'report' || cmd === 'trim') {
530
- const pro = isPro();
531
- if (!pro && cmd === 'report') {
532
- console.log(
533
- `\`limitcast ${cmd}\` is part of limitcast Pro: ${UPGRADE_URL}\nTry it free for 7 days: limitcast trial. Already bought it? limitcast activate <license-key>`,
534
- );
535
- process.exit(2);
536
- }
524
+ const pro = true;
537
525
  const since = now - days() * 86400_000;
538
526
  if (cmd === 'trim' && args[0] === 'keep') {
539
527
  // The keep-list: servers and skills `trim --apply` never touches (Claude, Codex and Grok). Free to manage; apply is Pro.
@@ -550,11 +538,7 @@ if (cmd === 'status') {
550
538
  process.exit(0);
551
539
  }
552
540
  if (cmd === 'trim' && args.includes('--codex')) {
553
- // Codex: AGENTS.md and the MCP servers in ~/.codex/config.toml. Free counts them; Pro names them and turns them off.
554
- if ((args.includes('--apply') || args.includes('--undo')) && !pro) {
555
- console.log(`\`limitcast trim --codex --apply\` is part of limitcast Pro: ${UPGRADE_URL}`);
556
- process.exit(2);
557
- }
541
+ // Codex: AGENTS.md and the MCP servers in ~/.codex/config.toml.
558
542
  if (args.includes('--undo')) {
559
543
  const e = undoCodexTrim();
560
544
  console.log(
@@ -579,10 +563,6 @@ if (cmd === 'status') {
579
563
  process.exit(0);
580
564
  }
581
565
  if (cmd === 'trim' && args.includes('--grok')) {
582
- if ((args.includes('--apply') || args.includes('--undo')) && !pro) {
583
- console.log(`\`limitcast trim --grok --apply\` is part of limitcast Pro: ${UPGRADE_URL}`);
584
- process.exit(2);
585
- }
586
566
  if (args.includes('--undo')) {
587
567
  const e = undoGrokTrim();
588
568
  console.log(
@@ -626,27 +606,15 @@ if (cmd === 'status') {
626
606
  // Prefer the measured starting context of the latest interactive session; older Claude Code logs fall back to estimates.
627
607
  const latest = await latestInteractiveTranscript(claudeRoot());
628
608
  if (latest) recordOverhead(snapshot(latest));
629
- // Free: the measured totals without names (the --share view); Pro names what to cut.
630
- if (!pro && !latest) {
631
- console.log(`\`limitcast trim\` needs one Claude Code session first. Naming what to cut is Pro: ${UPGRADE_URL}`);
632
- process.exit(2);
633
- }
609
+ // The share view omits private names; the local view includes actionable detail.
634
610
  if (args.includes('--apply') || args.includes('--undo')) {
635
- if (!pro) {
636
- console.log(
637
- `\`limitcast trim --apply\` is part of limitcast Pro: ${UPGRADE_URL}\nTry it free for 7 days: limitcast trial. Already bought it? limitcast activate <license-key>`,
638
- );
639
- process.exit(2);
640
- }
641
611
  console.log(args.includes('--undo') ? undoMessage(undoTrim()) : applyMessage(latest, used));
642
612
  process.exit(0);
643
613
  }
644
614
  const keep = getKeep();
645
- if (latest && (args.includes('--share') || !pro)) text = shareSummary(baseline(usage), latest, used, days(), keep);
615
+ if (latest && args.includes('--share')) text = shareSummary(baseline(usage), latest, used, days(), keep);
646
616
  else text = latest ? startupReport(baseline(usage), latest, used, days(), keep) : trimReport(baseline(usage), contributors(), used, days());
647
- if (!pro)
648
- text += `\n\nPro names each item and what it costs, so you can cut it: ${UPGRADE_URL}\nTry it free for 7 days: limitcast trial. Already bought it? limitcast activate <license-key>`;
649
- else if (latest && !args.includes('--share')) {
617
+ if (latest && !args.includes('--share')) {
650
618
  const still = stillLoading(latest);
651
619
  text += still.length
652
620
  ? `\n\nStill loading after \`trim --apply\`: ${still.join(', ')}. A Claude Code session that was running may have rewritten ~/.claude.json; quit Claude Code and run \`limitcast trim --apply\` again.`
@@ -663,10 +631,6 @@ if (cmd === 'status') {
663
631
  } else if (cmd === 'drift') {
664
632
  // SessionStart hook: tells the user (systemMessage, never the model's context) when starting context grew.
665
633
  const hook = args.includes('--hook');
666
- if (!isPro()) {
667
- if (!hook) console.log(`\`limitcast drift\` is part of limitcast Pro: ${UPGRADE_URL}`);
668
- process.exit(hook ? 0 : 2);
669
- }
670
634
  try {
671
635
  const latest = await latestInteractiveTranscript(claudeRoot());
672
636
  const d = latest ? recordOverhead(snapshot(latest)) : null;
@@ -684,13 +648,9 @@ if (cmd === 'status') {
684
648
  const samples = [...load(since), ...(await readCodex(since))];
685
649
  const s = loadOverhead();
686
650
  // The daily rollup keeps the value record current; a session-start hook must not scan transcripts itself.
687
- const week = Object.values(loadValue().sessions).filter((x) => x.at >= since);
651
+ const week = valuePeriod(loadValue(), since, now);
688
652
  lines.push(
689
- weeklyLine(
690
- resultsStats({ now, days: 7, samples, blocks: loadBlocks(since), pro: true }),
691
- s ? savedPerSession(s) : null,
692
- week.reduce((a, x) => a + x.turns * x.savedPerTurn, 0),
693
- ),
653
+ weeklyLine(resultsStats({ now, days: 7, samples, blocks: loadBlocks(since), pro: true }), s ? savedPerSession(s) : null, week.tokens),
694
654
  );
695
655
  }
696
656
  if (lines.length) console.log(JSON.stringify({ systemMessage: lines.join('\n') }));
@@ -701,10 +661,6 @@ if (cmd === 'status') {
701
661
  if (!hook) throw e; // a hook must never break session start
702
662
  }
703
663
  } else if (cmd === 'saved') {
704
- if (!isPro()) {
705
- console.log(`\`limitcast saved\` is part of limitcast Pro: ${UPGRADE_URL}`);
706
- process.exit(2);
707
- }
708
664
  const latest = await latestInteractiveTranscript(claudeRoot());
709
665
  if (latest) recordOverhead(snapshot(latest));
710
666
  const s = loadOverhead();
@@ -712,10 +668,10 @@ if (cmd === 'status') {
712
668
  forTerminal(s ? savedSummary(s, await countInteractiveSince(claudeRoot(), s.first.at)) : 'Nothing measured yet. Run `limitcast trim` first.'),
713
669
  );
714
670
  } else if (cmd === 'results') {
715
- // Free shows limits reached, how far ahead limitcast warned, and the guard preview; Pro adds real blocks and savings.
716
- const pro = isPro();
671
+ // Historical previews remain separate from applied controls.
672
+ const pro = true;
717
673
  const since = now - days() * 86400_000;
718
- let saved = `Pro tracks how much your starting context shrinks and what that saves: ${UPGRADE_URL}`;
674
+ let saved = '';
719
675
  let perSession = null;
720
676
  if (pro) {
721
677
  const latest = await latestInteractiveTranscript(claudeRoot());
@@ -729,7 +685,9 @@ if (cmd === 'status') {
729
685
  }
730
686
  const samples = [...load(since), ...(await readCodex(since))];
731
687
  const blocks = loadBlocks(since);
732
- const totals = valueTotals(await refreshValue());
688
+ const value = await refreshValue();
689
+ const totals = valueTotals(value);
690
+ const insight = periodInsights({ value, usage: await readUsage(since - days() * 86400_000, {}), blocks, since, until: now });
733
691
  if (args.includes('--share'))
734
692
  console.log(
735
693
  resultsShare(resultsStats({ now, days: days(), samples, blocks, pro }), {
@@ -737,17 +695,16 @@ if (cmd === 'status') {
737
695
  pro,
738
696
  savedPerSession: perSession,
739
697
  notResent: totals.tokens,
740
- }),
698
+ }) +
699
+ '\n' +
700
+ insightsShare(insight, pro),
741
701
  );
742
702
  else if (args.includes('--html')) {
743
- // Pro: results, the current windows and the burn report on one page, opened in the browser.
744
- if (!pro) {
745
- console.log(`The HTML dashboard is part of limitcast Pro: ${UPGRADE_URL}`);
746
- process.exit(2);
747
- }
703
+ // results, the current windows and the burn report on one page, opened in the browser.
748
704
  const rows = forecastAll(oneClaudeAccount([...load(now - KEEP_MS), ...(await readCodex(now - KEEP_MS))]), now);
749
705
  const burn = burnReport(await readUsage(since, {}), { since, now }).replace(/^(#{1,2}) /gm, '#$1 ');
750
706
  const md = [
707
+ insightsReport(insight, pro),
751
708
  resultsReport({ now, days: days(), samples, blocks, pro, saved, value: valueSection(totals, { now, pro }), subagents: loadSubagents(since) }),
752
709
  '## Right now',
753
710
  '```',
@@ -766,15 +723,23 @@ if (cmd === 'status') {
766
723
  } else
767
724
  console.log(
768
725
  forTerminal(
769
- resultsReport({ now, days: days(), samples, blocks, pro, saved, value: valueSection(totals, { now, pro }), subagents: loadSubagents(since) }),
726
+ [
727
+ insightsReport(insight, pro),
728
+ resultsReport({
729
+ now,
730
+ days: days(),
731
+ samples,
732
+ blocks,
733
+ pro,
734
+ saved,
735
+ value: valueSection(totals, { now, pro }),
736
+ subagents: loadSubagents(since),
737
+ }),
738
+ ].join('\n\n'),
770
739
  ),
771
740
  );
772
741
  } else if (cmd === 'notify') {
773
742
  // Desktop notifications from the status line (Pro, opt-in).
774
- if (!isPro()) {
775
- console.log(`Desktop notifications are part of limitcast Pro: ${UPGRADE_URL}`);
776
- process.exit(2);
777
- }
778
743
  const what = args[0];
779
744
  if (what === 'ntfy' || what === 'webhook') {
780
745
  // Phone (ntfy) or Slack/Discord: every notification also goes there; setting one turns notifications on.
@@ -814,10 +779,6 @@ if (cmd === 'status') {
814
779
  );
815
780
  } else if (cmd === 'after-reset') {
816
781
  // Run a command once a window has reset: queue the heavy job instead of watching the clock.
817
- if (!isPro()) {
818
- console.log(`\`limitcast after-reset\` is part of limitcast Pro: ${UPGRADE_URL}`);
819
- process.exit(2);
820
- }
821
782
  const sep = args.indexOf('--');
822
783
  const command = sep >= 0 ? args.slice(sep + 1) : [];
823
784
  const src = flag('--src') ?? 'claude';
@@ -860,41 +821,8 @@ if (cmd === 'status') {
860
821
  } catch {
861
822
  /* next time */
862
823
  }
863
- } else if (cmd === 'activate') {
864
- // Signed offline keys start with LC1.; anything else is a Polar license key.
865
- const key = args[0] ?? '';
866
- const res = key.startsWith('LC1.') ? activate(key) : await activatePolar(key);
867
- console.log(res.ok ? `✓ limitcast Pro activated${res.claims.e ? ` for ${res.claims.e}` : ''}` : `✗ ${res.reason}`);
868
- process.exit(res.ok ? 0 : 1);
869
- } else if (cmd === 'deactivate') {
870
- const res = await deactivatePolar();
871
- console.log(res.ok ? '✓ This machine is deactivated; the key can be used on another computer.' : `✗ ${res.reason}`);
872
- process.exit(res.ok ? 0 : 1);
873
- } else if (cmd === 'license') {
874
- const l = currentLicense();
875
- console.log(l === null ? trialLine() : l.ok ? `Pro: ${l.claims.e}` : `License problem: ${l.reason}`);
876
- } else if (cmd === 'trial') {
877
- // Pro for 7 days on this machine, no card, once.
878
- if (currentLicense()?.ok) {
879
- console.log('You already have Pro.');
880
- process.exit(0);
881
- }
882
- const t = startTrial(now);
883
- if (!t.ok) {
884
- console.log(t.active ? `Your Pro trial is already running, until ${clock(t.ends)}.` : trialLine());
885
- process.exit(t.active ? 0 : 2);
886
- }
887
- console.log(
888
- [
889
- `✓ Pro trial on: 7 days, until ${new Date(t.ends).toLocaleDateString()}. No card, nothing to cancel.`,
890
- 'Try it:',
891
- ' limitcast install --guard --alerts block runaway subagents, move them to Sonnet when a window is tight',
892
- ' limitcast trim --apply cut the context you never use (limitcast trim --undo reverses it)',
893
- ' limitcast notify on a desktop notification before you hit a limit',
894
- ' limitcast results what it did for you, any time',
895
- `Keep Pro after the trial: ${UPGRADE_URL}`,
896
- ].join('\n'),
897
- );
824
+ } else if (['activate', 'deactivate', 'license', 'trial'].includes(cmd)) {
825
+ console.log('limitcast is free and open source under the MIT License. All features are available; no license key, account or trial is required.');
898
826
  } else if (cmd === '--version' || cmd === '-v') {
899
827
  console.log(VERSION);
900
828
  } else {
@@ -902,7 +830,7 @@ if (cmd === 'status') {
902
830
  process.exit(cmd && !['help', '--help', '-h'].includes(cmd) ? 1 : 0);
903
831
  }
904
832
 
905
- /** Everything `doctor` checks: setup, data freshness, license, and whether each tool's logs still parse. */
833
+ /** Everything `doctor` checks: setup, data freshness, and whether each tool's logs still parse. */
906
834
  async function healthChecks() {
907
835
  // Readings are only stored when they change, so freshness comes from the last feed the status line saw.
908
836
  let latest = 0;
@@ -911,9 +839,7 @@ async function healthChecks() {
911
839
  } catch {
912
840
  /* never fed */
913
841
  }
914
- const license = currentLicense();
915
- const checks = doctor({ samplesAgeMs: latest ? now - latest : null, license });
916
- if (license === null && trialStatus(now)) checks.push({ ok: true, line: trialLine() });
842
+ const checks = doctor({ samplesAgeMs: latest ? now - latest : null });
917
843
  return [...checks, ...(await formatChecks())];
918
844
  }
919
845
 
@@ -934,53 +860,10 @@ function saveHealth(checks) {
934
860
  mkdirSync(stateDir(), { recursive: true });
935
861
  writeFileSync(file, JSON.stringify({ at: now, failed }));
936
862
  const fresh = failed.filter((l) => !before.includes(l));
937
- if (fresh.length && isPro() && notifyEnabled()) send(`limitcast needs a fix: ${fresh[0]} Run: limitcast doctor`);
863
+ if (fresh.length && notifyEnabled()) send(`limitcast needs a fix: ${fresh[0]} Run: limitcast doctor`);
938
864
  return failed;
939
865
  }
940
866
 
941
- /**
942
- * Free installs: for one day a week, what the guard preview saw Pro would have done, e.g.
943
- * "this week Pro would have stopped 2 subagents and moved 5 to Sonnet · limitcast trial". Silent when it's nothing.
944
- * @param {number} t epoch ms
945
- */
946
- function freeWeeklyHint(t) {
947
- const file = join(stateDir(), 'free-weekly.json');
948
- let from = 0;
949
- try {
950
- from = JSON.parse(readFileSync(file, 'utf8')).from ?? 0;
951
- } catch {
952
- /* first run: start the clock */
953
- }
954
- const WEEK = 7 * 86400_000;
955
- if (!from || t >= from + 86400_000) {
956
- // First run starts a week out; afterwards the next day-long showing is a week after this one.
957
- from = from ? from + Math.ceil((t - from - 86400_000 + 1) / WEEK) * WEEK : t + WEEK;
958
- mkdirSync(stateDir(), { recursive: true });
959
- writeFileSync(file, JSON.stringify({ from }));
960
- }
961
- if (t < from) return null;
962
- const preview = loadBlocks(t - WEEK).filter((b) => b.shadow);
963
- const stopped = preview.filter((b) => !b.kind || b.kind === 'budget' || b.kind === 'today').length;
964
- const moved = preview.filter((b) => b.kind === 'switch').length;
965
- const cold = preview.filter((b) => b.kind === 'cold').length;
966
- if (!stopped && !moved && !cold) return null;
967
- const parts = [
968
- stopped ? `stopped ${stopped} subagent${stopped === 1 ? '' : 's'}` : '',
969
- moved ? `moved ${moved} to Sonnet` : '',
970
- cold ? `caught ${cold} cold-cache message${cold === 1 ? '' : 's'}` : '',
971
- ].filter(Boolean);
972
- return `this week Pro would have ${parts.join(' and ')} · limitcast trial`;
973
- }
974
-
975
- /** Free tier, a running trial, or an ended one, in one line. */
976
- function trialLine() {
977
- const t = trialStatus(now);
978
- if (!t) return `Free tier. Try Pro free for 7 days, no card: limitcast trial. Buy: ${UPGRADE_URL}`;
979
- if (t.active)
980
- return `Pro trial: ${Math.ceil((t.ends - now) / 86400_000)} days left (until ${new Date(t.ends).toLocaleDateString()}). Keep Pro: ${UPGRADE_URL}`;
981
- return `Pro trial ended ${new Date(t.ends).toLocaleDateString()}. Keep Pro: ${UPGRADE_URL}`;
982
- }
983
-
984
867
  /** The status-line hint while the last health check found something to fix. */
985
868
  function healthHint() {
986
869
  try {
@@ -1018,7 +901,7 @@ async function refreshValue() {
1018
901
  const change = limitChange(v.calibHistory ?? []);
1019
902
  if (change && (!v.limitChange || now - v.limitChange.at > 7 * 86400_000)) {
1020
903
  v.limitChange = { ...change, at: now };
1021
- if (isPro() && notifyEnabled()) send(limitChangeMessage(change));
904
+ if (notifyEnabled()) send(limitChangeMessage(change));
1022
905
  }
1023
906
  saveValue(v);
1024
907
  return v;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limitcast",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Stretch your Claude Code plan: measure what every session loads before you type, cut what you never use, and stop runaway subagents before they burn your window.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,5 +36,5 @@
36
36
  "url": "git+https://github.com/SamStull9007/limitcast.git"
37
37
  },
38
38
  "author": "Sam Stull",
39
- "license": "Elastic-2.0"
39
+ "license": "MIT"
40
40
  }