limitcast 0.14.0 → 0.15.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 +3 -2
- package/bin/limitcast.mjs +8 -0
- package/package.json +1 -1
- package/src/memory.mjs +122 -0
- package/src/trim.mjs +2 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ limitcast install --guard # also the subagent guard (free: preview only)
|
|
|
45
45
|
limitcast doctor
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast:results` and `/limitcast:
|
|
48
|
+
In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast:results`, `/limitcast:trim`, `/limitcast:memory-audit` and `/limitcast:memory-split`: `/plugin marketplace add SamStull9007/limitcast`, then `/plugin install limitcast@limitcast`. The status-line recorder still comes from `limitcast install`.
|
|
49
49
|
|
|
50
50
|
`install` backs up `~/.claude/settings.json` and wraps your existing status line: it looks exactly the same, and the limitcast line (for example `limitcast: 5h 14% · 7d 18% · today 9% left`) goes on the line under it. `--guard` adds the subagent guard (without Pro it only records what it would block). Restart Claude Code to load it. `limitcast uninstall` puts everything back.
|
|
51
51
|
|
|
@@ -70,7 +70,8 @@ In Claude Code you can also add the plugin, for `/limitcast:status`, `/limitcast
|
|
|
70
70
|
| `limitcast after-reset [--src claude/codex] [--window 5h/7d] [--detach] -- <cmd>` | **Pro.** Wait for the window to reset, then run the command |
|
|
71
71
|
| `limitcast results --html [--out FILE]` | **Pro.** Results, current windows and the burn report on one page, opened in your browser |
|
|
72
72
|
| `limitcast install [--guard] [--alerts]` / `uninstall` | Wire into Claude Code / restore your settings |
|
|
73
|
-
| `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
|
+
| `limitcast doctor [--fix]` | Check the setup, data freshness, license, this project's auto-memory index (see `memory`), 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 (the memory line only shows when you run `doctor` yourself). `--fix` re-installs with the current Node (after a Node upgrade) |
|
|
74
|
+
| `limitcast memory [dir]` | Check this project's auto-memory folder (`~/.claude/projects/<project>/memory`): how much of `MEMORY.md` fits in what Claude Code loads each session (the first 200 lines or 25 KB; anything past that is never read), broken links, topic files nothing links to, and files over 150 lines. Read-only. In Claude Code, `/limitcast:memory-audit` takes it from there (stale, contradictory and unlinked notes) and `/limitcast:memory-split` splits an oversized file into a short hub plus topic files |
|
|
74
75
|
| `limitcast trial` | Pro free for 7 days on this computer, no card, once |
|
|
75
76
|
| `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) |
|
|
76
77
|
| `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) |
|
package/bin/limitcast.mjs
CHANGED
|
@@ -45,6 +45,7 @@ import { accountForecasts, bindingLine, compactHint, headroom, lastCall, lastCal
|
|
|
45
45
|
import { htmlPage } from '../src/html.mjs';
|
|
46
46
|
import { doctor, install, installedFeatures, readSettings, settingsPath, uninstall } from '../src/install.mjs';
|
|
47
47
|
import { activate, currentLicense, isPro, startTrial, trialStatus, UPGRADE_URL } from '../src/license.mjs';
|
|
48
|
+
import { memoryCheck, memoryDir, memoryReport, scanMemory } from '../src/memory.mjs';
|
|
48
49
|
import { buildNotifierApp, loadChannels, notifierApp, notifyChanges, notifyEnabled, send, setChannel, setNotify } from '../src/notify.mjs';
|
|
49
50
|
import { driftMessage, loadOverhead, recordOverhead, savedPerSession, savedSummary, snapshot } from '../src/overhead.mjs';
|
|
50
51
|
import { advise, getPlan, loadPeaks, PLANS, planPrices, planStats, recordPeaks, setPlan } from '../src/plan.mjs';
|
|
@@ -89,6 +90,7 @@ const HELP = `limitcast ${VERSION}: stretch your Claude Code, Codex and Grok pla
|
|
|
89
90
|
limitcast trim [--share] tokens every session loads before you type, and how much you never use
|
|
90
91
|
limitcast trim --codex the same for Codex: AGENTS.md size and MCP servers you haven't used
|
|
91
92
|
limitcast trim --grok the same for Grok: system prompt size and MCP servers you haven't used
|
|
93
|
+
limitcast memory [dir] check this project's auto-memory: load cap, broken links, unlinked and oversized files
|
|
92
94
|
limitcast results [--days N] limits you reached, how far ahead limitcast warned, what the guard blocked
|
|
93
95
|
[--share] totals only, safe to post
|
|
94
96
|
limitcast license show the license and re-check it with Polar
|
|
@@ -516,8 +518,14 @@ if (cmd === 'status') {
|
|
|
516
518
|
}
|
|
517
519
|
const checks = await healthChecks();
|
|
518
520
|
saveHealth(checks);
|
|
521
|
+
// Memory is per project: shown here, but kept out of the saved health that the daily background check overwrites.
|
|
522
|
+
const mem = memoryCheck(scanMemory(memoryDir()));
|
|
523
|
+
if (mem) checks.push(mem);
|
|
519
524
|
for (const c of checks) console.log(`${c.ok ? '✓' : '✗'} ${c.line}`);
|
|
520
525
|
process.exit(checks.every((c) => c.ok) ? 0 : 1);
|
|
526
|
+
} else if (cmd === 'memory') {
|
|
527
|
+
const dir = args.find((a) => !a.startsWith('-')) ?? memoryDir();
|
|
528
|
+
console.log(memoryReport(scanMemory(dir), dir));
|
|
521
529
|
} else if (cmd === 'report' || cmd === 'trim') {
|
|
522
530
|
const pro = isPro();
|
|
523
531
|
if (!pro && cmd === 'report') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "limitcast",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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": {
|
package/src/memory.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Claude Code loads only the first 200 lines or 25 KB of MEMORY.md into every session; the rest is never read.
|
|
6
|
+
const INDEX_LINES = 200;
|
|
7
|
+
const INDEX_BYTES = 25 * 1024;
|
|
8
|
+
// A topic file is read whole when opened, so one past this is worth splitting by topic.
|
|
9
|
+
const BIG_LINES = 150;
|
|
10
|
+
const BIG_BYTES = 24 * 1024;
|
|
11
|
+
|
|
12
|
+
/** The auto-memory folder Claude Code keeps for a project.
|
|
13
|
+
* @param {{home?:string, cwd?:string}} [where] */
|
|
14
|
+
export function memoryDir({ home = homedir(), cwd = process.cwd() } = {}) {
|
|
15
|
+
return join(home, '.claude', 'projects', cwd.replace(/[^A-Za-z0-9]/g, '-'), 'memory');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @param {string} text */
|
|
19
|
+
const lineCount = (text) => (text ? text.split('\n').length - (text.endsWith('\n') ? 1 : 0) : 0);
|
|
20
|
+
/** @param {string} s */
|
|
21
|
+
const slug = (s) => s.toLowerCase().replace(/\.md$/, '').replace(/[_\s]/g, '-');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What a memory folder looks like from the index down: how much of MEMORY.md loads, which links are broken,
|
|
25
|
+
* which topic files nothing reaches from the index, and which are big. Null when there is no index.
|
|
26
|
+
* @param {string} dir
|
|
27
|
+
*/
|
|
28
|
+
export function scanMemory(dir) {
|
|
29
|
+
const indexPath = join(dir, 'MEMORY.md');
|
|
30
|
+
if (!existsSync(indexPath)) return null;
|
|
31
|
+
const names = readdirSync(dir).filter((f) => f.endsWith('.md'));
|
|
32
|
+
/** @type {Map<string, string>} */
|
|
33
|
+
const text = new Map(names.map((f) => [f, readFileSync(join(dir, f), 'utf8')]));
|
|
34
|
+
const index = /** @type {string} */ (text.get('MEMORY.md'));
|
|
35
|
+
const bySlug = new Map(names.map((f) => [slug(f), f]));
|
|
36
|
+
|
|
37
|
+
const broken = /** @type {{from:string, target:string}[]} */ ([]);
|
|
38
|
+
const reached = new Set(['MEMORY.md']);
|
|
39
|
+
const queue = ['MEMORY.md'];
|
|
40
|
+
for (let f = queue.pop(); f; f = queue.pop()) {
|
|
41
|
+
const body = /** @type {string} */ (text.get(f));
|
|
42
|
+
const targets = [
|
|
43
|
+
...[...body.matchAll(/\]\(([^)\s#]+\.md)[^)]*\)/g)]
|
|
44
|
+
.map((m) => m[1])
|
|
45
|
+
.filter((t) => !/^[a-z]+:/.test(t))
|
|
46
|
+
.map((t) => {
|
|
47
|
+
if (!existsSync(join(dir, t))) broken.push({ from: f, target: t });
|
|
48
|
+
return t;
|
|
49
|
+
}),
|
|
50
|
+
// [[name]] links; one with no file yet is allowed (a note worth writing later), so never "broken".
|
|
51
|
+
...[...body.matchAll(/\[\[([^\]|#]+)/g)].map((m) => bySlug.get(slug(m[1].trim())) ?? ''),
|
|
52
|
+
];
|
|
53
|
+
for (const t of targets) {
|
|
54
|
+
if (!text.has(t) || reached.has(t)) continue;
|
|
55
|
+
reached.add(t);
|
|
56
|
+
queue.push(t);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const big = names
|
|
61
|
+
.filter((f) => f !== 'MEMORY.md')
|
|
62
|
+
.map((name) => ({
|
|
63
|
+
name,
|
|
64
|
+
lines: lineCount(/** @type {string} */ (text.get(name))),
|
|
65
|
+
bytes: Buffer.byteLength(/** @type {string} */ (text.get(name))),
|
|
66
|
+
}))
|
|
67
|
+
.filter((f) => f.lines > BIG_LINES || f.bytes > BIG_BYTES)
|
|
68
|
+
.sort((a, b) => b.lines - a.lines);
|
|
69
|
+
return {
|
|
70
|
+
dir,
|
|
71
|
+
index: { lines: lineCount(index), bytes: Buffer.byteLength(index) },
|
|
72
|
+
files: names.length - 1,
|
|
73
|
+
broken,
|
|
74
|
+
orphans: names.filter((f) => !reached.has(f)),
|
|
75
|
+
big,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @param {NonNullable<ReturnType<typeof scanMemory>>} s */
|
|
80
|
+
const overCap = (s) => s.index.lines > INDEX_LINES || s.index.bytes > INDEX_BYTES;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* One doctor line. Only an index past the cap fails: that is memory Claude silently never reads.
|
|
84
|
+
* @param {ReturnType<typeof scanMemory>} s
|
|
85
|
+
* @returns {{ok:boolean, line:string}|null}
|
|
86
|
+
*/
|
|
87
|
+
export function memoryCheck(s) {
|
|
88
|
+
if (!s) return null;
|
|
89
|
+
const size = `index ${s.index.lines}/${INDEX_LINES} lines, ${Math.round(s.index.bytes / 1000)}/25 KB`;
|
|
90
|
+
if (overCap(s))
|
|
91
|
+
return {
|
|
92
|
+
ok: false,
|
|
93
|
+
line: `Memory ${size}: Claude Code loads only the first ${INDEX_LINES} lines or 25 KB of MEMORY.md, so the rest is never read. Fix: /limitcast:memory-audit`,
|
|
94
|
+
};
|
|
95
|
+
const parts = [
|
|
96
|
+
s.index.lines >= INDEX_LINES * 0.8 || s.index.bytes >= INDEX_BYTES * 0.8 ? 'index close to the cap' : '',
|
|
97
|
+
s.orphans.length ? `${s.orphans.length} not linked from the index` : '',
|
|
98
|
+
s.broken.length ? `${s.broken.length} broken link${s.broken.length === 1 ? '' : 's'}` : '',
|
|
99
|
+
s.big.length ? `${s.big.length} file${s.big.length === 1 ? '' : 's'} over ${BIG_LINES} lines` : '',
|
|
100
|
+
].filter(Boolean);
|
|
101
|
+
const next = s.big.length ? '/limitcast:memory-audit, then /limitcast:memory-split' : '/limitcast:memory-audit';
|
|
102
|
+
return { ok: true, line: `Memory: ${s.files} files, ${size}${parts.length ? `; ${parts.join(', ')}. Run ${next}` : ', no problems'}` };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The sweep `/limitcast:memory-audit` and `/limitcast:memory-split` start from.
|
|
106
|
+
* @param {ReturnType<typeof scanMemory>} s
|
|
107
|
+
* @param {string} [dir] shown when there is no index */
|
|
108
|
+
export function memoryReport(s, dir = '') {
|
|
109
|
+
if (!s) return `No auto-memory index (MEMORY.md) in ${dir.replace(homedir(), '~')}`;
|
|
110
|
+
const out = [
|
|
111
|
+
`Memory: ${s.dir.replace(homedir(), '~')}`,
|
|
112
|
+
`Index: MEMORY.md ${s.index.lines} / ${INDEX_LINES} lines, ${(s.index.bytes / 1000).toFixed(1)} / 25 KB${overCap(s) ? ' (OVER: what is past the cap is never loaded)' : ''}`,
|
|
113
|
+
`Topic files: ${s.files}`,
|
|
114
|
+
];
|
|
115
|
+
if (s.orphans.length) out.push(`Not linked from the index (${s.orphans.length}): ${s.orphans.join(', ')}`);
|
|
116
|
+
if (s.broken.length) out.push(`Broken links (${s.broken.length}): ${s.broken.map((b) => `${b.from} -> ${b.target}`).join(', ')}`);
|
|
117
|
+
if (s.big.length)
|
|
118
|
+
out.push(
|
|
119
|
+
`Over ${BIG_LINES} lines or 24 KB (${s.big.length}): ${s.big.map((b) => `${b.name} (${b.lines} lines, ${Math.round(b.bytes / 1000)} KB)`).join(', ')}`,
|
|
120
|
+
);
|
|
121
|
+
return out.join('\n');
|
|
122
|
+
}
|
package/src/trim.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
+
import { memoryDir } from './memory.mjs';
|
|
5
6
|
import { fmt } from './report.mjs';
|
|
6
7
|
|
|
7
8
|
/** @typedef {import('./usage.mjs').Usage} Usage */
|
|
@@ -50,7 +51,7 @@ export function contributors({ home = homedir(), cwd = process.cwd() } = {}) {
|
|
|
50
51
|
file(join(claudeDir, 'CLAUDE.md'), 'Global CLAUDE.md');
|
|
51
52
|
if (cwd !== home) file(join(cwd, 'CLAUDE.md'), 'Project CLAUDE.md');
|
|
52
53
|
file(join(home, 'CLAUDE.md'), 'Home CLAUDE.md');
|
|
53
|
-
file(join(
|
|
54
|
+
file(join(memoryDir({ home, cwd }), 'MEMORY.md'), 'Auto-memory index');
|
|
54
55
|
files.sort((a, b) => b.tokens - a.tokens);
|
|
55
56
|
|
|
56
57
|
const overrides = readJson(join(claudeDir, 'settings.json'))?.skillOverrides ?? {};
|