claude-usage-limits 1.1.3 → 1.1.4
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usage-limits",
|
|
3
3
|
"displayName": "Usage Limits",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"description": "Puts your remaining Claude Code usage limit into Claude's context before every prompt, so it opens with what fits in the budget instead of starting work that gets cut off. Reports headroom as turns rather than percentages, prices a job before you start it, and detects your plan tier.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Ridelink",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-usage-limits",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Puts your remaining Claude Code usage limit into Claude's context before every prompt, so it opens with what fits in the budget instead of starting work that gets cut off. Reports headroom as turns rather than percentages, prices a job before you start it, and detects your plan tier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
@@ -43,10 +43,25 @@ function cacheFile() {
|
|
|
43
43
|
// ever got a hit and both paid for a full scan each time.
|
|
44
44
|
const KEEP_SESSIONS = 5;
|
|
45
45
|
|
|
46
|
+
// A cache written before slots were keyed by session keeps its fields at the
|
|
47
|
+
// top level, so upgrading would carry "at", "turnsLeft", "session" and
|
|
48
|
+
// "sessionId" forward as if each were a session, crowding out real slots and
|
|
49
|
+
// quietly undoing the per-session caching. Anything that is not a slot goes.
|
|
50
|
+
function keepSlots(parsed) {
|
|
51
|
+
if (!parsed || typeof parsed !== 'object') return {};
|
|
52
|
+
const slots = {};
|
|
53
|
+
for (const key of Object.keys(parsed)) {
|
|
54
|
+
const value = parsed[key];
|
|
55
|
+
if (value && typeof value === 'object' && Number.isFinite(value.at)) {
|
|
56
|
+
slots[key] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return slots;
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
function readCache() {
|
|
47
63
|
try {
|
|
48
|
-
|
|
49
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
64
|
+
return keepSlots(JSON.parse(fs.readFileSync(cacheFile(), 'utf8')));
|
|
50
65
|
} catch (err) {
|
|
51
66
|
return {};
|
|
52
67
|
}
|
|
@@ -285,6 +300,7 @@ module.exports = {
|
|
|
285
300
|
summariseOthers,
|
|
286
301
|
briefText,
|
|
287
302
|
settings,
|
|
303
|
+
keepSlots,
|
|
288
304
|
pickCached,
|
|
289
305
|
mergeCache,
|
|
290
306
|
KEEP_SESSIONS,
|