notesoup 0.58.0 → 0.58.2
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/dist/plugins/claude/src/thresholds.js +18 -25
- package/dist/test/claude-mod.test.js +486 -80
- package/docs/claude-code-mod.md +17 -5
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +17 -26
- package/plugins/claude/hooks/register.ts +215 -148
- package/plugins/claude/src/thresholds.ts +17 -27
|
@@ -58,16 +58,6 @@ function tokenLimits(source, autoCompact, native, resetMargin, warningRunway) {
|
|
|
58
58
|
native: tokens, reset, warn: Math.max(MIN_POINT_TOKENS, reset - warningRunway), resetMargin, warningRunway,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
/** The percent fallback: the same reserves expressed as points of ASSUMED_WINDOW_TOKENS. */
|
|
62
|
-
function percentLimits(autoCompact, pct, resetMargin, warningRunway) {
|
|
63
|
-
const base = 100 * (1 - (CLAUDE_OUTPUT_RESERVE_TOKENS + CLAUDE_AUTOCOMPACT_BUFFER_TOKENS) / ASSUMED_WINDOW_TOKENS);
|
|
64
|
-
const native = pct === undefined ? base : Math.min(pct, base);
|
|
65
|
-
const reset = Math.max(MIN_POINT_PERCENT, native - (resetMargin / ASSUMED_WINDOW_TOKENS) * 100);
|
|
66
|
-
return {
|
|
67
|
-
source: "percent", autoCompact, unit: "percent",
|
|
68
|
-
native, reset, warn: Math.max(MIN_POINT_PERCENT, reset - (warningRunway / ASSUMED_WINDOW_TOKENS) * 100), resetMargin, warningRunway,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
61
|
/**
|
|
72
62
|
* Resolve the points from whatever the host could read. Every field is undocumented-adjacent,
|
|
73
63
|
* so a missing or malformed one degrades to the next source and finally to the percent
|
|
@@ -98,20 +88,23 @@ export function resolveClaudeLimits(facts) {
|
|
|
98
88
|
if (native > 0)
|
|
99
89
|
return tokenLimits("auto-compact", true, native, resetMargin, warningRunway);
|
|
100
90
|
}
|
|
101
|
-
// (b)
|
|
102
|
-
// window always answers here: falling through to the percent fallback would express the
|
|
103
|
-
// points on an assumed 200K window, which is later than the window notesoup can see.
|
|
91
|
+
// (b/c) Compute once, using the classic 200K capacity only when the host reports none.
|
|
104
92
|
const window = positiveNumber(usage.window);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
93
|
+
const capacity = window ?? ASSUMED_WINDOW_TOKENS;
|
|
94
|
+
const configured = configuredWindow(settings, env, breakdown.model);
|
|
95
|
+
const effective = Math.min(configured ?? capacity, capacity);
|
|
96
|
+
const available = effective - CLAUDE_OUTPUT_RESERVE_TOKENS;
|
|
97
|
+
const thresholdFromWindow = available - CLAUDE_AUTOCOMPACT_BUFFER_TOKENS;
|
|
98
|
+
const native = autoCompact
|
|
99
|
+
? pct === undefined ? thresholdFromWindow : Math.min(Math.floor(available * (pct / 100)), thresholdFromWindow)
|
|
100
|
+
: available;
|
|
101
|
+
const limits = tokenLimits(window === undefined ? "percent" : "window", autoCompact, native, resetMargin, warningRunway);
|
|
102
|
+
if (window !== undefined)
|
|
103
|
+
return limits;
|
|
104
|
+
return {
|
|
105
|
+
...limits, unit: "percent",
|
|
106
|
+
native: limits.native / capacity * 100,
|
|
107
|
+
reset: Math.max(MIN_POINT_PERCENT, limits.reset / capacity * 100),
|
|
108
|
+
warn: Math.max(MIN_POINT_PERCENT, limits.warn / capacity * 100),
|
|
109
|
+
};
|
|
117
110
|
}
|