limitcast 0.13.0 → 0.13.1
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 +3 -3
- package/bin/limitcast.mjs +13 -5
- package/package.json +1 -1
- package/src/grok.mjs +44 -2
- package/src/guard.mjs +47 -4
- package/src/prices.mjs +17 -6
- package/src/report.mjs +4 -4
- package/src/subagents.mjs +14 -2
- package/src/where.mjs +3 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast
|
|
|
51
51
|
|
|
52
52
|
**Codex:** forecasts and reports need no setup (`~/.codex/sessions`, or `$CODEX_HOME/sessions`). With `--guard`, `install` also appends the guard to `~/.codex/hooks.json`, after your existing hooks so the ones you've already trusted keep their trust. Codex runs a new hook only once you approve it: start Codex and accept it. `limitcast doctor` shows whether it's trusted.
|
|
53
53
|
|
|
54
|
-
**Grok:** `report` reads each session's `~/.grok/sessions/*/*/usage.json
|
|
54
|
+
**Grok:** `report` reads each session's `~/.grok/sessions/*/*/usage.json` and prices Grok models at xAI list prices (the same API-equivalent column as Claude). `install` wraps `[ui.status_line]` in `~/.grok/config.toml` (session model, context % and cost on one line; the limitcast forecast under it). `--guard` writes `~/.grok/hooks/limitcast.json` matching `spawn_subagent`. Grok stores spend, not a % used, so the status line shows `grok 5h $X · 7d $Y` until you set a dollar cap (`limitcast budget grok <usd>`); then `status` forecasts that window and the guard blocks new spawns when it is on pace to run out. `limitcast subagent-model explore grok-4.3` writes `[subagents.models]` (restart Grok). Restart Grok to load the status line and hook.
|
|
55
55
|
|
|
56
56
|
## Commands
|
|
57
57
|
|
|
@@ -63,7 +63,7 @@ In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast
|
|
|
63
63
|
| `limitcast notify on/off/test` | **Pro.** A desktop notification when a Claude window turns NEAR, AT_RISK or HIT, and when it resets after a HIT. On macOS they come from a tiny limitcast notifier app, listed as "limitcast" in System Settings → Notifications |
|
|
64
64
|
| `limitcast notify ntfy <topic or https URL>` / `notify webhook <https URL>` | **Pro.** Also send every notification to your phone through [ntfy](https://ntfy.sh) (install the app, subscribe to the topic) or to a Slack or Discord incoming webhook. `off` removes it. Sent in the background, so no hook waits on the network |
|
|
65
65
|
| `limitcast budget subagents <percent>` / `off` | **Pro.** Once subagents have used that share of the current 5-hour window, the guard holds new ones until it resets. Priced from your own readings (needs about a day of use first) |
|
|
66
|
-
| `limitcast subagent-model <type> <sonnet\|opus\|haiku\|
|
|
66
|
+
| `limitcast subagent-model <type> <sonnet\|opus\|haiku\|claude-id\|grok-id>` / `off` | **Pro.** Run new subagents of that type (for example `Explore` or `explore`) on that model, unless the spawn names a model itself. Grok ids also write `[subagents.models]` in `~/.grok/config.toml` (restart Grok). Without arguments it lists what is pinned and the types you ran in the last 30 days. Needs `install --guard`; `results` counts the subagents it moved |
|
|
67
67
|
| `limitcast plan [--days N]`, `limitcast plan set <pro\|max5\|max20>` / `off` | **Pro.** Does your Claude plan fit how much you use? From a long-lived record of the peak of every 5-hour and weekly window (kept 120 days; it starts when you install this version) it says whether you reached your limits often enough to look at the next plan, or used so little that a smaller one would have fit, with the monthly price difference, and shows what your Claude Code tokens would cost at API list prices. Tell it your plan first with `plan set`. Plan prices (Pro $20, Max 5x $100, Max 20x $200) and the 5x / 20x multipliers are from claude.com/pricing (2026-10-26; the Max 20x price was not on that page: change any price in `prices.json`, `{"plans": {"max20": 200}}`). It assumes weekly limits scale like the 5-hour limit, and it cannot see extra-usage spend |
|
|
68
68
|
| `limitcast budget grok <usd>` / `off` / `7d <usd>` | **Pro.** Dollar cap for Grok's aligned 5-hour window (optional 7-day cap). Turns Grok spend into a % so `status` can forecast runout and the guard can block `spawn_subagent` |
|
|
69
69
|
| `limitcast after-reset [--src claude/codex] [--window 5h/7d] [--detach] -- <cmd>` | **Pro.** Wait for the window to reset, then run the command |
|
|
@@ -71,7 +71,7 @@ In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast
|
|
|
71
71
|
| `limitcast install [--guard] [--alerts]` / `uninstall` | Wire into Claude Code / restore your settings |
|
|
72
72
|
| `limitcast doctor [--fix]` | Check the setup, data freshness, license, and that Claude Code, Codex and Grok logs are still in a format limitcast reads. Also runs daily in the background and flags problems in the status line. `--fix` re-installs with the current Node (after a Node upgrade) |
|
|
73
73
|
| `limitcast trial` | Pro free for 7 days on this computer, no card, once |
|
|
74
|
-
| `limitcast report [--days N] [--out FILE]` | **Pro.** Tokens by tool, day, project, model and session; subagent share; and the API-equivalent cost: what the tokens would cost at the API's list prices (Claude models
|
|
74
|
+
| `limitcast report [--days N] [--out FILE]` | **Pro.** Tokens by tool, day, project, model and session; subagent share; and the API-equivalent cost: what the tokens would cost at the API's list prices (Claude and Grok models; a subscription is not billed this way). Prices are in the code as of 2026-10-26; add or change a model in `~/.local/state/limitcast/prices.json` (`{"models": {"claude-opus-4-1": {"input": 15, "output": 75}}}`, dollars per million tokens) |
|
|
75
75
|
| `limitcast report --why [--days N]` | **Pro.** Where your new tokens went: subagents, session starts, cache rebuilds after idle, tool results by tool, model output, and the largest single steps (Claude Code only) |
|
|
76
76
|
| `limitcast report --jobs [--days N]` | **Pro.** The scheduled (headless) jobs that spend the most tokens just starting: runs, average start, share of all new tokens, and how to launch a job leaner (Claude Code only) |
|
|
77
77
|
| `limitcast trim [--days N] [--share]` | Measured starting context of your latest session and how much you haven't used in N days (default 7). **Pro** names each item. `--share`: totals only, no names, safe to post |
|
package/bin/limitcast.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { coldCost, coldMessage, firstWarning } from '../src/cold.mjs';
|
|
|
22
22
|
import { forecastAll, oneClaudeAccount, resetTarget } from '../src/forecast.mjs';
|
|
23
23
|
import { formatChecks } from '../src/formats.mjs';
|
|
24
24
|
import {
|
|
25
|
+
applyGrokSubagentModel,
|
|
25
26
|
applyGrokTrim,
|
|
26
27
|
getGrokBudget,
|
|
27
28
|
grokConfigPath,
|
|
@@ -100,7 +101,7 @@ const HELP = `limitcast ${VERSION}: stretch your Claude Code, Codex and Grok pla
|
|
|
100
101
|
one starts; hold the first message after the prompt
|
|
101
102
|
cache expired (idle over 60 min, LIMITCAST_CACHE_MINUTES) and say what it costs
|
|
102
103
|
limitcast budget subagents <percent>|off hold new subagents once they used that much of the 5-hour window
|
|
103
|
-
limitcast subagent-model <type> <model>|off run new subagents of that type on sonnet, opus, haiku or a model id
|
|
104
|
+
limitcast subagent-model <type> <model>|off run new subagents of that type on sonnet, opus, haiku, grok-… or a model id
|
|
104
105
|
limitcast plan [--days N] does your Claude plan fit your use? Hit-limit and headroom evidence, and the monthly price difference
|
|
105
106
|
limitcast plan set <pro|max5|max20>|off tell limitcast which Claude plan you are on
|
|
106
107
|
limitcast budget grok <usd>|off Grok 5-hour dollar cap (Grok stores spend, not a % used; the guard
|
|
@@ -361,10 +362,16 @@ if (cmd === 'status') {
|
|
|
361
362
|
}
|
|
362
363
|
const [type, model] = args;
|
|
363
364
|
if (type && (model === undefined || (model !== 'off' && !validModel(model)))) {
|
|
364
|
-
console.log(
|
|
365
|
+
console.log(
|
|
366
|
+
'Usage: limitcast subagent-model <type> <sonnet|opus|haiku|claude-id|grok-id>|off\n limitcast subagent-model list them',
|
|
367
|
+
);
|
|
365
368
|
process.exit(1);
|
|
366
369
|
}
|
|
367
|
-
if (type)
|
|
370
|
+
if (type) {
|
|
371
|
+
const next = model === 'off' ? null : model;
|
|
372
|
+
setSubagentModel(type, next);
|
|
373
|
+
applyGrokSubagentModel(type, next);
|
|
374
|
+
}
|
|
368
375
|
const pinned = Object.entries(getSubagentModels());
|
|
369
376
|
console.log(pinned.length ? pinned.map(([t, m]) => `${t}: ${m}`).join('\n') : 'No subagent type is pinned to a model.');
|
|
370
377
|
const ran = new Map();
|
|
@@ -376,11 +383,12 @@ if (cmd === 'status') {
|
|
|
376
383
|
.map(([t, n]) => `${t} (${n})`)
|
|
377
384
|
.join(', ')}`,
|
|
378
385
|
);
|
|
379
|
-
if (pinned.length)
|
|
386
|
+
if (pinned.length) {
|
|
380
387
|
console.log(
|
|
381
388
|
'\nNew subagents of these types run on that model unless the spawn names one itself. Needs the guard: limitcast install --guard, then restart Claude Code.',
|
|
382
389
|
);
|
|
383
|
-
|
|
390
|
+
if (pinned.some(([, m]) => /^grok-/i.test(m))) console.log('Grok also writes [subagents.models] in ~/.grok/config.toml; restart Grok.');
|
|
391
|
+
} else console.log('\nExample: limitcast subagent-model Explore haiku');
|
|
384
392
|
process.exit(0);
|
|
385
393
|
} else if (cmd === 'budget') {
|
|
386
394
|
if (!isPro()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "limitcast",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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": {
|
package/src/grok.mjs
CHANGED
|
@@ -395,6 +395,48 @@ export function restoreStatusLine(toml, previous) {
|
|
|
395
395
|
* A one-line session summary from Grok's status-line JSON (model, context %, session cost).
|
|
396
396
|
* @param {any} feed
|
|
397
397
|
*/
|
|
398
|
+
/**
|
|
399
|
+
* Set or clear a Grok `[subagents.models]` pin. A non-grok model (or null) removes that type's key.
|
|
400
|
+
* @param {string} type
|
|
401
|
+
* @param {string|null} model
|
|
402
|
+
* @param {{path?:string}} [opts]
|
|
403
|
+
*/
|
|
404
|
+
export function applyGrokSubagentModel(type, model, { path = grokConfigPath() } = {}) {
|
|
405
|
+
if (!existsSync(path)) return false;
|
|
406
|
+
const grokId = typeof model === 'string' && /^grok-[a-z0-9.-]+$/i.test(model) ? model : null;
|
|
407
|
+
const prev = readFileSync(path, 'utf8');
|
|
408
|
+
const next = patchGrokSubagentModel(prev, type, grokId);
|
|
409
|
+
if (next === prev) return false;
|
|
410
|
+
backup(path);
|
|
411
|
+
writeText(path, next);
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Pure TOML patch for `[subagents.models.<type>]`. `model` null deletes the key; an empty table is removed.
|
|
417
|
+
* @param {string} toml
|
|
418
|
+
* @param {string} type
|
|
419
|
+
* @param {string|null} model
|
|
420
|
+
*/
|
|
421
|
+
export function patchGrokSubagentModel(toml, type, model) {
|
|
422
|
+
const key = type.toLowerCase().replace(/[^a-z0-9_-]/g, '');
|
|
423
|
+
if (!key) return toml;
|
|
424
|
+
const range = tableRange(toml, 'subagents.models');
|
|
425
|
+
if (!range) {
|
|
426
|
+
if (!model) return toml;
|
|
427
|
+
return `${toml.trimEnd()}\n\n[subagents.models]\n${key} = ${tomlString(model)}\n`;
|
|
428
|
+
}
|
|
429
|
+
const keys = parseTable(range.body);
|
|
430
|
+
if (model) keys[key] = model;
|
|
431
|
+
else delete keys[key];
|
|
432
|
+
if (!Object.keys(keys).length) {
|
|
433
|
+
const before = toml.slice(0, range.start).trimEnd();
|
|
434
|
+
const after = toml.slice(range.end).replace(/^\n+/, '');
|
|
435
|
+
return after ? `${before}\n\n${after}` : `${before}\n`;
|
|
436
|
+
}
|
|
437
|
+
return toml.slice(0, range.start) + renderTable('subagents.models', keys, range.body) + toml.slice(range.end);
|
|
438
|
+
}
|
|
439
|
+
|
|
398
440
|
export function grokSessionLine(feed) {
|
|
399
441
|
if (!feed || typeof feed !== 'object') return '';
|
|
400
442
|
if (feed.rate_limits) return ''; // Claude Code feed
|
|
@@ -548,7 +590,7 @@ function parseTable(body) {
|
|
|
548
590
|
/** @type {Record<string, string>} */
|
|
549
591
|
const keys = {};
|
|
550
592
|
for (const line of body.split('\n').slice(1)) {
|
|
551
|
-
const m = /^\s*([A-Za-z0-9_]+)\s*=\s*(.*)$/.exec(line);
|
|
593
|
+
const m = /^\s*([A-Za-z0-9_-]+)\s*=\s*(.*)$/.exec(line);
|
|
552
594
|
if (!m) continue;
|
|
553
595
|
keys[m[1]] = unquote(m[2].trim());
|
|
554
596
|
}
|
|
@@ -572,7 +614,7 @@ function unquote(v) {
|
|
|
572
614
|
function renderTable(name, keys, previousBody) {
|
|
573
615
|
const order = [];
|
|
574
616
|
for (const line of previousBody.split('\n').slice(1)) {
|
|
575
|
-
const m = /^\s*([A-Za-z0-9_]+)\s*=/.exec(line);
|
|
617
|
+
const m = /^\s*([A-Za-z0-9_-]+)\s*=/.exec(line);
|
|
576
618
|
if (m && keys[m[1]] !== undefined && !order.includes(m[1])) order.push(m[1]);
|
|
577
619
|
}
|
|
578
620
|
for (const k of Object.keys(keys)) if (!order.includes(k)) order.push(k);
|
package/src/guard.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { grokSamples } from './grok.mjs';
|
|
|
4
4
|
import { logBlock } from './results.mjs';
|
|
5
5
|
import { readCodex } from './sources.mjs';
|
|
6
6
|
import { KEEP_MS, load } from './store.mjs';
|
|
7
|
-
import { budgetMessage, budgetSpent, getBudget,
|
|
7
|
+
import { budgetMessage, budgetSpent, getBudget, loadSubagents, pinnedModel, spawnNotice, windowStart } from './subagents.mjs';
|
|
8
8
|
|
|
9
9
|
const NAMES = { claude: 'Claude', codex: 'Codex', grok: 'Grok' };
|
|
10
10
|
|
|
@@ -124,10 +124,10 @@ export async function runGuard(hook, now, minutes, { preview = false } = {}) {
|
|
|
124
124
|
// Not blocked, but a window is tight: run a new Claude subagent on Sonnet instead of the main (usually Opus) model.
|
|
125
125
|
const input = hook?.tool_input ?? hook?.toolInput;
|
|
126
126
|
const tight = forecasts.find((x) => x.src === 'claude' && (x.verdict === 'AT_RISK' || x.verdict === 'NEAR'));
|
|
127
|
+
const type = String(input?.subagent_type ?? input?.subagentType ?? '');
|
|
128
|
+
const pinned = isUnset(input?.model) && type ? pinnedModel(type) : undefined;
|
|
129
|
+
if (src === 'grok') return grokPinOrNotice(input, type, pinned, forecasts, now, preview);
|
|
127
130
|
if (src !== 'claude') return null;
|
|
128
|
-
// A subagent type pinned to a model (`limitcast subagent-model Explore haiku`) runs on it unless the spawn names a model itself.
|
|
129
|
-
const type = String(input?.subagent_type ?? '');
|
|
130
|
-
const pinned = isUnset(input?.model) && type ? getSubagentModels()[type] : undefined;
|
|
131
131
|
const model = pinned ?? input?.model;
|
|
132
132
|
if (!tight || !switchable(model)) {
|
|
133
133
|
if (pinned) {
|
|
@@ -193,3 +193,46 @@ export const switchable = (model) => model === undefined || model === null || mo
|
|
|
193
193
|
|
|
194
194
|
/** Whether a spawn names no model of its own, so a pinned one may apply. @param {unknown} model */
|
|
195
195
|
const isUnset = (model) => model === undefined || model === null || model === '' || model === 'inherit';
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Grok: pin via updatedInput only when the spawn already has a `model` field (adding one fails the tool schema and
|
|
199
|
+
* denies the call). [subagents.models] in config.toml covers the rest after restart. Spawn notice when a cap exists.
|
|
200
|
+
* @param {any} input
|
|
201
|
+
* @param {string} type
|
|
202
|
+
* @param {string|undefined} pinned
|
|
203
|
+
* @param {ReturnType<typeof import('./forecast.mjs').forecastAll>} forecasts
|
|
204
|
+
* @param {number} now
|
|
205
|
+
* @param {boolean} preview
|
|
206
|
+
*/
|
|
207
|
+
function grokPinOrNotice(input, type, pinned, forecasts, now, preview) {
|
|
208
|
+
const grokPin = pinned && /^grok-/i.test(pinned) ? pinned : undefined;
|
|
209
|
+
const hasModelField = input && typeof input === 'object' && Object.hasOwn(input, 'model');
|
|
210
|
+
if (grokPin && hasModelField) {
|
|
211
|
+
try {
|
|
212
|
+
logBlock({
|
|
213
|
+
t: now,
|
|
214
|
+
kind: 'default',
|
|
215
|
+
src: 'grok',
|
|
216
|
+
win: '5h',
|
|
217
|
+
pct: 0,
|
|
218
|
+
wall: now,
|
|
219
|
+
reset: now,
|
|
220
|
+
from: input?.model ?? 'default',
|
|
221
|
+
to: grokPin,
|
|
222
|
+
type,
|
|
223
|
+
...(preview ? { shadow: true } : {}),
|
|
224
|
+
});
|
|
225
|
+
} catch {
|
|
226
|
+
/* a failed log must not change the decision */
|
|
227
|
+
}
|
|
228
|
+
if (preview) return null;
|
|
229
|
+
return {
|
|
230
|
+
updatedInput: { ...input, model: grokPin },
|
|
231
|
+
reason: `limitcast: ${type} subagents run on ${grokPin}, the model you set for them. Set LIMITCAST_ALLOW=1 to keep the main model.`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
if (preview) return null;
|
|
235
|
+
const win = forecasts.find((x) => x.src === 'grok' && x.win === '5h' && x.verdict !== 'RESET');
|
|
236
|
+
const notice = spawnNotice(loadSubagents(now - 30 * 86400_000), type, win);
|
|
237
|
+
return notice ? { notice } : null;
|
|
238
|
+
}
|
package/src/prices.mjs
CHANGED
|
@@ -4,14 +4,16 @@ import { join } from 'node:path';
|
|
|
4
4
|
import { stateDir } from './store.mjs';
|
|
5
5
|
|
|
6
6
|
// What your tokens would cost at the API's list prices ("API-equivalent cost"). A subscription is not billed this way:
|
|
7
|
-
// it is a yardstick for what the plan covers. Claude models
|
|
7
|
+
// it is a yardstick for what the plan covers. Claude and Grok models; any other model is left out, never priced at 0.
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* USD per million tokens. input/output: base prices; readX: cache read as a multiple of input; over: the prices that
|
|
11
|
-
* apply to a call whose whole prompt is above `above` tokens. Cache writes
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* apply to a call whose whole prompt is above `above` tokens. Cache writes default to 1.25x input (5 minutes) or 2x
|
|
12
|
+
* (1 hour) for Claude; Grok sets writeX 1 (xAI lists cached input, not a write multiplier).
|
|
13
|
+
* Sources: platform.claude.com/docs/en/about-claude/pricing and docs.x.ai/developers/models, read 2026-10-26.
|
|
14
|
+
* Override or add models in ~/.local/state/limitcast/prices.json:
|
|
15
|
+
* {"models": {"claude-opus-4-1": {"input": 15, "output": 75, "readX": 0.1}}}.
|
|
16
|
+
* @typedef {{input:number, output:number, readX:number, writeX?:number, write1hX?:number, over?:{above:number, input:number, output:number, readX?:number}}} Price
|
|
15
17
|
* @type {Record<string, Price>}
|
|
16
18
|
*/
|
|
17
19
|
export const PRICES = {
|
|
@@ -19,6 +21,13 @@ export const PRICES = {
|
|
|
19
21
|
'claude-opus-5-5': { input: 4, output: 20, readX: 0.05 },
|
|
20
22
|
'claude-sonnet-5-5': { input: 2, output: 10, readX: 0.05 },
|
|
21
23
|
'claude-haiku-5-5': { input: 0.1, output: 0.5, readX: 0.1, over: { above: 100_000, input: 0.5, output: 2.5 } },
|
|
24
|
+
// xAI: cache read is listed in $/1M; writeX 1 = cache creation billed as input. Long-context at 200k prompt tokens.
|
|
25
|
+
'grok-4.7': { input: 2, output: 6, readX: 0.25, writeX: 1, write1hX: 1, over: { above: 200_000, input: 4, output: 12 } },
|
|
26
|
+
'grok-4.6': { input: 2, output: 6, readX: 0.25, writeX: 1, write1hX: 1, over: { above: 200_000, input: 4, output: 12 } },
|
|
27
|
+
'grok-4.5': { input: 2, output: 6, readX: 0.15, writeX: 1, write1hX: 1, over: { above: 200_000, input: 4, output: 12 } },
|
|
28
|
+
'grok-4.3': { input: 1.25, output: 2.5, readX: 0.16, writeX: 1, write1hX: 1, over: { above: 200_000, input: 2.5, output: 5 } },
|
|
29
|
+
'grok-4.20': { input: 1.25, output: 2.5, readX: 0.16, writeX: 1, write1hX: 1, over: { above: 200_000, input: 2.5, output: 5 } },
|
|
30
|
+
'grok-build-0.1': { input: 1, output: 2, readX: 0.2, writeX: 1, write1hX: 1, over: { above: 200_000, input: 2, output: 4 } },
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
const WRITE_5M = 1.25;
|
|
@@ -63,7 +72,9 @@ export function callCost(u, table = priceTable()) {
|
|
|
63
72
|
const p = base.over && u.input + u.cacheWrite + u.cacheRead > base.over.above ? { ...base, ...base.over } : base;
|
|
64
73
|
const w1h = Math.min(u.cacheWrite1h ?? 0, u.cacheWrite);
|
|
65
74
|
const w5m = u.cacheWrite - w1h;
|
|
66
|
-
|
|
75
|
+
const write5 = p.writeX ?? WRITE_5M;
|
|
76
|
+
const write1h = p.write1hX ?? WRITE_1H;
|
|
77
|
+
return (u.input * p.input + (w5m * write5 + w1h * write1h) * p.input + u.cacheRead * p.readX * p.input + u.output * p.output) / 1e6;
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
/**
|
package/src/report.mjs
CHANGED
|
@@ -14,9 +14,9 @@ export function burnReport(usage, { since, now }) {
|
|
|
14
14
|
const sum = (/** @type {Usage[]} */ xs) => xs.reduce((a, u) => a + total(u), 0);
|
|
15
15
|
const all = sum(usage);
|
|
16
16
|
const lines = [`# limitcast burn report`, '', `${day(since)} to ${day(now)} · ${fmt(all)} tokens`, ''];
|
|
17
|
-
if (!usage.length) return [...lines, 'No Claude Code or
|
|
17
|
+
if (!usage.length) return [...lines, 'No Claude Code, Codex or Grok usage in this period.'].join('\n');
|
|
18
18
|
|
|
19
|
-
// API-equivalent dollars: what the tokens would cost at list prices.
|
|
19
|
+
// API-equivalent dollars: what the tokens would cost at list prices. Claude and Grok models are priced; others show "-".
|
|
20
20
|
const cost = (/** @type {Usage[]} */ xs) => {
|
|
21
21
|
const c = costOf(xs);
|
|
22
22
|
return c.priced ? c.total : null;
|
|
@@ -36,7 +36,7 @@ export function burnReport(usage, { since, now }) {
|
|
|
36
36
|
if (all$.priced)
|
|
37
37
|
lines.push(
|
|
38
38
|
'',
|
|
39
|
-
`**API-equivalent cost: ${fmtUsd(all$.total)}** at list prices for Claude models, not what a subscription charges.` +
|
|
39
|
+
`**API-equivalent cost: ${fmtUsd(all$.total)}** at list prices for Claude and Grok models, not what a subscription charges.` +
|
|
40
40
|
(all$.unpriced ? ` ${fmt(all$.unpriced)} tokens on other models are not counted.` : ''),
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -93,7 +93,7 @@ export function burnReport(usage, { since, now }) {
|
|
|
93
93
|
'new tokens',
|
|
94
94
|
cost,
|
|
95
95
|
);
|
|
96
|
-
lines.push('', `_Generated by limitcast. Token counts come from your local Claude Code and
|
|
96
|
+
lines.push('', `_Generated by limitcast. Token counts come from your local Claude Code, Codex and Grok logs._`);
|
|
97
97
|
return lines.join('\n');
|
|
98
98
|
}
|
|
99
99
|
|
package/src/subagents.mjs
CHANGED
|
@@ -131,8 +131,20 @@ export function setBudget(pct) {
|
|
|
131
131
|
writeFileSync(configFile(), JSON.stringify({ ...cfg, subagentBudget: pct }));
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
/** A model a subagent type can be pinned to: sonnet, opus, haiku or a
|
|
135
|
-
export const validModel = (/** @type {unknown} */ m) => typeof m === 'string' && /^(sonnet|opus|haiku|claude-[a-z0-9.-]+)$/i.test(m);
|
|
134
|
+
/** A model a subagent type can be pinned to: sonnet, opus, haiku, a claude-... id, or a grok-... id. */
|
|
135
|
+
export const validModel = (/** @type {unknown} */ m) => typeof m === 'string' && /^(sonnet|opus|haiku|claude-[a-z0-9.-]+|grok-[a-z0-9.-]+)$/i.test(m);
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The pinned model for a subagent type, matching the stored name case-insensitively (Claude "Explore" vs Grok "explore").
|
|
139
|
+
* @param {unknown} type
|
|
140
|
+
*/
|
|
141
|
+
export function pinnedModel(type) {
|
|
142
|
+
if (typeof type !== 'string' || !type) return undefined;
|
|
143
|
+
const models = getSubagentModels();
|
|
144
|
+
if (models[type]) return models[type];
|
|
145
|
+
const want = type.toLowerCase();
|
|
146
|
+
return Object.entries(models).find(([t]) => t.toLowerCase() === want)?.[1];
|
|
147
|
+
}
|
|
136
148
|
|
|
137
149
|
/** @returns {Record<string, string>} the model each subagent type runs on by default, e.g. {Explore: 'haiku'} */
|
|
138
150
|
export function getSubagentModels() {
|
package/src/where.mjs
CHANGED
|
@@ -395,7 +395,9 @@ export function jobsReport(r, { since, now }) {
|
|
|
395
395
|
'',
|
|
396
396
|
`Every run loads your settings, plugins, hooks, MCP servers, skills and instruction files before it reads its prompt. "New tokens at start" is what counts against your limit; "starting prompt" is the whole context, cached or not. The smallest starting prompt among these jobs averages ${avg(lean.size, lean)} (${leanJob.replace(/\|/g, '/')}); the heaviest job's averages ${avg(ranked[0][1].size, ranked[0][1])}.`,
|
|
397
397
|
'',
|
|
398
|
-
'A job that does not need
|
|
398
|
+
'A job that does not need your hooks can leave them out and keep its claude.ai connectors: launch it with `claude -p --settings \'{"disableAllHooks": true}\'`. In a test on one scheduled job that cut each start from about 16k new tokens to about 5k.',
|
|
399
|
+
'',
|
|
400
|
+
'To leave out everything else too, add `--setting-sources "" --strict-mcp-config` (and `--mcp-config` for the servers it uses). That also drops the claude.ai connectors, plugins and permission rules, so a job that reads from one (HubSpot, Slack) cannot use it. Pass `--model` and `--permission-mode`, and check the job still does what it should.',
|
|
399
401
|
'',
|
|
400
402
|
'_Estimated from your local transcripts. A job is its first 45 characters of prompt, so runs of the same job group together._',
|
|
401
403
|
);
|