@xynogen/pix-runtime 0.5.1 → 0.5.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/README.md +3 -2
- package/package.json +1 -1
- package/src/pix-command.ts +16 -5
- package/src/sections/compaction.ts +4 -3
package/README.md
CHANGED
|
@@ -58,8 +58,9 @@ to calculate the trigger; the default is `60` and `0` disables the self-trigger
|
|
|
58
58
|
`compaction.minimumTokens` is the absolute floor for that calculation. The
|
|
59
59
|
effective threshold is `max(contextWindow × triggerPercent, minimumTokens)`, so
|
|
60
60
|
a 300K-context model at 10% waits for 100K tokens instead of compacting at 30K.
|
|
61
|
-
The default floor is 100K
|
|
62
|
-
600K
|
|
61
|
+
The default floor is 100K and the hard minimum is 25K (values below clamp up);
|
|
62
|
+
`/pix` offers 25K, 50K, 100K, 150K, 200K, 300K, 400K, 600K, 800K, and 1M.
|
|
63
|
+
pix-core consumes both settings.
|
|
63
64
|
|
|
64
65
|
Collapse policy helpers:
|
|
65
66
|
|
package/package.json
CHANGED
package/src/pix-command.ts
CHANGED
|
@@ -37,6 +37,17 @@ function row<T>(r: SettingRow<T>): SettingRow<unknown> {
|
|
|
37
37
|
return r as SettingRow<unknown>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** Render a token count as a compact label: 1_000_000 → "1M", 150_000 → "150k". */
|
|
41
|
+
function formatTokens(tokens: number): string {
|
|
42
|
+
return tokens % 1_000_000 === 0 ? `${tokens / 1_000_000}M` : `${tokens / 1000}k`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Parse a compact token label ("1M", "150k") back to an absolute count. */
|
|
46
|
+
function parseTokens(label: string): number {
|
|
47
|
+
const n = Number.parseFloat(label);
|
|
48
|
+
return /m$/i.test(label) ? n * 1_000_000 : n * 1000;
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
const SETTINGS: SettingRow<unknown>[] = [
|
|
41
52
|
row({
|
|
42
53
|
section: "Pretty",
|
|
@@ -90,9 +101,9 @@ const SETTINGS: SettingRow<unknown>[] = [
|
|
|
90
101
|
section: "Compaction",
|
|
91
102
|
label: "Minimum tokens",
|
|
92
103
|
handle: compactionSection,
|
|
93
|
-
values: ["100k", "150k", "200k", "300k", "400k", "
|
|
94
|
-
read: (v) =>
|
|
95
|
-
patch: (value) => ({ minimumTokens:
|
|
104
|
+
values: ["25k", "50k", "100k", "150k", "200k", "300k", "400k", "600k", "800k", "1M"],
|
|
105
|
+
read: (v) => formatTokens(v.minimumTokens),
|
|
106
|
+
patch: (value) => ({ minimumTokens: parseTokens(value) }),
|
|
96
107
|
}),
|
|
97
108
|
row({
|
|
98
109
|
section: "Gate",
|
|
@@ -114,7 +125,7 @@ function buildSummary(runtime: PixRuntime): string {
|
|
|
114
125
|
lastSection = row.section;
|
|
115
126
|
}
|
|
116
127
|
const value = row.read(runtime.get(row.handle));
|
|
117
|
-
const isDefault = value === row.
|
|
128
|
+
const isDefault = value === row.read(row.handle.defaults);
|
|
118
129
|
lines.push(` ${row.label}: ${value}${isDefault ? "" : " *"}`);
|
|
119
130
|
}
|
|
120
131
|
return lines.join("\n");
|
|
@@ -186,7 +197,7 @@ export function registerPixCommand(pi: ExtensionAPI, runtime: PixRuntime): void
|
|
|
186
197
|
const cursor = sel ? theme.fg("accent", "→") : " ";
|
|
187
198
|
const label = theme.fg(sel ? "accent" : "text", row.label.padEnd(labelW));
|
|
188
199
|
const value = row.read(runtime.get(row.handle));
|
|
189
|
-
const isDefault = value === row.
|
|
200
|
+
const isDefault = value === row.read(row.handle.defaults);
|
|
190
201
|
settingBodyLines[i] = body.length;
|
|
191
202
|
body.push(`${cursor} ${label} ${theme.fg(isDefault ? "dim" : "success", value)}`);
|
|
192
203
|
}
|
|
@@ -14,11 +14,12 @@ export interface CompactionConfig {
|
|
|
14
14
|
minimumTokens: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const MINIMUM_TOKEN_FLOOR =
|
|
17
|
+
const MINIMUM_TOKEN_FLOOR = 25_000;
|
|
18
|
+
const MINIMUM_TOKEN_DEFAULT = 100_000;
|
|
18
19
|
|
|
19
20
|
const DEFAULTS: Readonly<CompactionConfig> = {
|
|
20
21
|
triggerPercent: 60,
|
|
21
|
-
minimumTokens:
|
|
22
|
+
minimumTokens: MINIMUM_TOKEN_DEFAULT,
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
/** Clamp to [0, 100]; non-numbers fall back. */
|
|
@@ -27,7 +28,7 @@ function pctOr(v: unknown, fallback: number): number {
|
|
|
27
28
|
return Math.min(100, Math.max(0, v));
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
/** Require a finite token floor of at least
|
|
31
|
+
/** Require a finite token floor of at least 25k. */
|
|
31
32
|
function minimumTokensOr(v: unknown, fallback: number): number {
|
|
32
33
|
if (typeof v !== "number" || !Number.isFinite(v)) return fallback;
|
|
33
34
|
return Math.max(MINIMUM_TOKEN_FLOOR, Math.round(v));
|