mu-harness 0.30.0 → 0.31.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/esm/commands/defaults.js +21 -21
- package/package.json +3 -3
- package/script/commands/defaults.js +21 -21
package/esm/commands/defaults.js
CHANGED
|
@@ -47,13 +47,13 @@ const GRID_CELLS = GRID_COLS * GRID_ROWS;
|
|
|
47
47
|
const GRID_WIDTH = GRID_COLS * 2 - 1; // glyphs joined by single spaces
|
|
48
48
|
const USED = '⛁'; // a filled context cell (Claude Code's /context glyph)
|
|
49
49
|
const FREEG = '⛶'; // a free cell
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
// the companion strips them (plain text), keeping the labelled breakdown readable.
|
|
50
|
+
// Truecolor SGR — distinct, readable hues (mu's TUI utils + the companion both strip/parse
|
|
51
|
+
// these correctly). Secondary text uses a single grey so only the category glyphs carry colour.
|
|
53
52
|
const RESET = '\x1b[0m';
|
|
54
|
-
const
|
|
53
|
+
const GREY = '\x1b[38;2;153;153;153m';
|
|
55
54
|
const BOLD = '\x1b[1m';
|
|
56
|
-
const
|
|
55
|
+
const ITALIC = '\x1b[3m';
|
|
56
|
+
const BUFFER_COLOR = '\x1b[38;2;255;193;7m'; // amber — the compaction reserve
|
|
57
57
|
const paint = (s, color) => `${color}${s}${RESET}`;
|
|
58
58
|
const fmtTok = (n) => (n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`);
|
|
59
59
|
const pctStr = (n, w) => {
|
|
@@ -121,16 +121,16 @@ export const createContextCommand = () => ({
|
|
|
121
121
|
}
|
|
122
122
|
return { n: estTokens(text.length), exact: false };
|
|
123
123
|
};
|
|
124
|
-
// label, text,
|
|
124
|
+
// label, text, truecolor — distinct hues across the wheel, in render order.
|
|
125
125
|
const SPEC = [
|
|
126
|
-
['System prompt', sys.agent, '\x1b[
|
|
127
|
-
['Environment', sys.env, '\x1b[
|
|
128
|
-
['Instructions', sys.instructions, '\x1b[
|
|
129
|
-
['Memory', sys.memory, '\x1b[
|
|
130
|
-
['Tools', `${toolSchemas}\n${sys.toolPrompts}`, '\x1b[
|
|
131
|
-
['You', byRole('user'), '\x1b[
|
|
132
|
-
['Agent', byRole('assistant'), '\x1b[
|
|
133
|
-
['Tool results', byRole('tool'), '\x1b[
|
|
126
|
+
['System prompt', sys.agent, '\x1b[38;2;239;108;82m'], // coral — the agent prompt
|
|
127
|
+
['Environment', sys.env, '\x1b[38;2;129;199;132m'], // green — the <env> block
|
|
128
|
+
['Instructions', sys.instructions, '\x1b[38;2;100;181;246m'], // blue — AGENTS.md / CLAUDE.md
|
|
129
|
+
['Memory', sys.memory, '\x1b[38;2;186;104;200m'], // purple — MEMORY.md
|
|
130
|
+
['Tools', `${toolSchemas}\n${sys.toolPrompts}`, '\x1b[38;2;77;182;172m'], // teal — schemas + tool prompts
|
|
131
|
+
['You', byRole('user'), '\x1b[38;2;121;134;203m'], // indigo — your messages
|
|
132
|
+
['Agent', byRole('assistant'), '\x1b[38;2;240;98;146m'], // pink — assistant replies
|
|
133
|
+
['Tool results', byRole('tool'), '\x1b[38;2;0;188;212m'], // cyan — tool results (distinct from amber buffer)
|
|
134
134
|
];
|
|
135
135
|
const measured = await Promise.all(SPEC.map(([, text]) => measure(text)));
|
|
136
136
|
const cats = SPEC.map(([label, , color], i) => ({ label, n: measured[i].n, color })).filter((c) => c.n > 0);
|
|
@@ -145,18 +145,18 @@ export const createContextCommand = () => ({
|
|
|
145
145
|
const info = [];
|
|
146
146
|
if (model) {
|
|
147
147
|
info.push(model.split('/').pop() ?? model);
|
|
148
|
-
info.push(paint(model,
|
|
148
|
+
info.push(paint(model, GREY));
|
|
149
149
|
}
|
|
150
150
|
if (window > 0)
|
|
151
|
-
info.push(paint(`${mark(total)}/${fmtTok(window)} tokens (${pctStr(total, window)})`,
|
|
151
|
+
info.push(paint(`${mark(total)}/${fmtTok(window)} tokens (${pctStr(total, window)})`, GREY));
|
|
152
152
|
info.push('');
|
|
153
|
-
info.push(
|
|
153
|
+
info.push(`${ITALIC}${GREY}Estimated usage by category${RESET}`);
|
|
154
154
|
for (const c of cats) {
|
|
155
|
-
info.push(`${paint(USED, c.color)} ${c.label}: ${paint(`${mark(c.n)} tokens (${pctStr(c.n, window)})`,
|
|
155
|
+
info.push(`${paint(USED, c.color)} ${c.label}: ${paint(`${mark(c.n)} tokens (${pctStr(c.n, window)})`, GREY)}`);
|
|
156
156
|
}
|
|
157
157
|
if (window > 0) {
|
|
158
|
-
info.push(`${paint(USED, BUFFER_COLOR)} Compaction buffer: ${paint(`${fmtTok(buffer)} tokens (${pctStr(buffer, window)})`,
|
|
159
|
-
info.push(`${paint(FREEG,
|
|
158
|
+
info.push(`${paint(USED, BUFFER_COLOR)} Compaction buffer: ${paint(`${fmtTok(buffer)} tokens (${pctStr(buffer, window)})`, GREY)}`);
|
|
159
|
+
info.push(`${paint(FREEG, GREY)} Free space: ${paint(`${fmtTok(free)} (${pctStr(free, window)})`, GREY)}`);
|
|
160
160
|
}
|
|
161
161
|
const lines = [`${BOLD}Context Usage${RESET}`];
|
|
162
162
|
if (window > 0) {
|
|
@@ -170,7 +170,7 @@ export const createContextCommand = () => ({
|
|
|
170
170
|
const bufCells = Math.min(ratio(buffer), Math.max(0, GRID_CELLS - cells.length));
|
|
171
171
|
const freeCells = Math.max(0, GRID_CELLS - cells.length - bufCells);
|
|
172
172
|
for (let i = 0; i < freeCells; i++)
|
|
173
|
-
cells.push(paint(FREEG,
|
|
173
|
+
cells.push(paint(FREEG, GREY));
|
|
174
174
|
for (let i = 0; i < bufCells; i++)
|
|
175
175
|
cells.push(paint(USED, BUFFER_COLOR));
|
|
176
176
|
cells.length = GRID_CELLS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mu-harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Agent harness: createHarness wires mu-core into a host — XDG paths, model registry, plugins, disk-loaded agents & skills, sub-agents, sessions (JSONL + SQLite catalog), slash commands, permission/approval hooks, an optional scheduler, and a composable TUI chat app",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./script/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@swc/wasm-typescript": "^1.15.0",
|
|
24
24
|
"cli-highlight": "^2.1.11",
|
|
25
25
|
"croner": "^9.0.0",
|
|
26
|
-
"mu-core": "^0.
|
|
27
|
-
"mu-tui": "^0.
|
|
26
|
+
"mu-core": "^0.31.0",
|
|
27
|
+
"mu-tui": "^0.31.0",
|
|
28
28
|
"ws": "^8.18.0"
|
|
29
29
|
},
|
|
30
30
|
"_generatedBy": "dnt@dev",
|
|
@@ -54,13 +54,13 @@ const GRID_CELLS = GRID_COLS * GRID_ROWS;
|
|
|
54
54
|
const GRID_WIDTH = GRID_COLS * 2 - 1; // glyphs joined by single spaces
|
|
55
55
|
const USED = '⛁'; // a filled context cell (Claude Code's /context glyph)
|
|
56
56
|
const FREEG = '⛶'; // a free cell
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
// the companion strips them (plain text), keeping the labelled breakdown readable.
|
|
57
|
+
// Truecolor SGR — distinct, readable hues (mu's TUI utils + the companion both strip/parse
|
|
58
|
+
// these correctly). Secondary text uses a single grey so only the category glyphs carry colour.
|
|
60
59
|
const RESET = '\x1b[0m';
|
|
61
|
-
const
|
|
60
|
+
const GREY = '\x1b[38;2;153;153;153m';
|
|
62
61
|
const BOLD = '\x1b[1m';
|
|
63
|
-
const
|
|
62
|
+
const ITALIC = '\x1b[3m';
|
|
63
|
+
const BUFFER_COLOR = '\x1b[38;2;255;193;7m'; // amber — the compaction reserve
|
|
64
64
|
const paint = (s, color) => `${color}${s}${RESET}`;
|
|
65
65
|
const fmtTok = (n) => (n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`);
|
|
66
66
|
const pctStr = (n, w) => {
|
|
@@ -128,16 +128,16 @@ const createContextCommand = () => ({
|
|
|
128
128
|
}
|
|
129
129
|
return { n: estTokens(text.length), exact: false };
|
|
130
130
|
};
|
|
131
|
-
// label, text,
|
|
131
|
+
// label, text, truecolor — distinct hues across the wheel, in render order.
|
|
132
132
|
const SPEC = [
|
|
133
|
-
['System prompt', sys.agent, '\x1b[
|
|
134
|
-
['Environment', sys.env, '\x1b[
|
|
135
|
-
['Instructions', sys.instructions, '\x1b[
|
|
136
|
-
['Memory', sys.memory, '\x1b[
|
|
137
|
-
['Tools', `${toolSchemas}\n${sys.toolPrompts}`, '\x1b[
|
|
138
|
-
['You', byRole('user'), '\x1b[
|
|
139
|
-
['Agent', byRole('assistant'), '\x1b[
|
|
140
|
-
['Tool results', byRole('tool'), '\x1b[
|
|
133
|
+
['System prompt', sys.agent, '\x1b[38;2;239;108;82m'], // coral — the agent prompt
|
|
134
|
+
['Environment', sys.env, '\x1b[38;2;129;199;132m'], // green — the <env> block
|
|
135
|
+
['Instructions', sys.instructions, '\x1b[38;2;100;181;246m'], // blue — AGENTS.md / CLAUDE.md
|
|
136
|
+
['Memory', sys.memory, '\x1b[38;2;186;104;200m'], // purple — MEMORY.md
|
|
137
|
+
['Tools', `${toolSchemas}\n${sys.toolPrompts}`, '\x1b[38;2;77;182;172m'], // teal — schemas + tool prompts
|
|
138
|
+
['You', byRole('user'), '\x1b[38;2;121;134;203m'], // indigo — your messages
|
|
139
|
+
['Agent', byRole('assistant'), '\x1b[38;2;240;98;146m'], // pink — assistant replies
|
|
140
|
+
['Tool results', byRole('tool'), '\x1b[38;2;0;188;212m'], // cyan — tool results (distinct from amber buffer)
|
|
141
141
|
];
|
|
142
142
|
const measured = await Promise.all(SPEC.map(([, text]) => measure(text)));
|
|
143
143
|
const cats = SPEC.map(([label, , color], i) => ({ label, n: measured[i].n, color })).filter((c) => c.n > 0);
|
|
@@ -152,18 +152,18 @@ const createContextCommand = () => ({
|
|
|
152
152
|
const info = [];
|
|
153
153
|
if (model) {
|
|
154
154
|
info.push(model.split('/').pop() ?? model);
|
|
155
|
-
info.push(paint(model,
|
|
155
|
+
info.push(paint(model, GREY));
|
|
156
156
|
}
|
|
157
157
|
if (window > 0)
|
|
158
|
-
info.push(paint(`${mark(total)}/${fmtTok(window)} tokens (${pctStr(total, window)})`,
|
|
158
|
+
info.push(paint(`${mark(total)}/${fmtTok(window)} tokens (${pctStr(total, window)})`, GREY));
|
|
159
159
|
info.push('');
|
|
160
|
-
info.push(
|
|
160
|
+
info.push(`${ITALIC}${GREY}Estimated usage by category${RESET}`);
|
|
161
161
|
for (const c of cats) {
|
|
162
|
-
info.push(`${paint(USED, c.color)} ${c.label}: ${paint(`${mark(c.n)} tokens (${pctStr(c.n, window)})`,
|
|
162
|
+
info.push(`${paint(USED, c.color)} ${c.label}: ${paint(`${mark(c.n)} tokens (${pctStr(c.n, window)})`, GREY)}`);
|
|
163
163
|
}
|
|
164
164
|
if (window > 0) {
|
|
165
|
-
info.push(`${paint(USED, BUFFER_COLOR)} Compaction buffer: ${paint(`${fmtTok(buffer)} tokens (${pctStr(buffer, window)})`,
|
|
166
|
-
info.push(`${paint(FREEG,
|
|
165
|
+
info.push(`${paint(USED, BUFFER_COLOR)} Compaction buffer: ${paint(`${fmtTok(buffer)} tokens (${pctStr(buffer, window)})`, GREY)}`);
|
|
166
|
+
info.push(`${paint(FREEG, GREY)} Free space: ${paint(`${fmtTok(free)} (${pctStr(free, window)})`, GREY)}`);
|
|
167
167
|
}
|
|
168
168
|
const lines = [`${BOLD}Context Usage${RESET}`];
|
|
169
169
|
if (window > 0) {
|
|
@@ -177,7 +177,7 @@ const createContextCommand = () => ({
|
|
|
177
177
|
const bufCells = Math.min(ratio(buffer), Math.max(0, GRID_CELLS - cells.length));
|
|
178
178
|
const freeCells = Math.max(0, GRID_CELLS - cells.length - bufCells);
|
|
179
179
|
for (let i = 0; i < freeCells; i++)
|
|
180
|
-
cells.push(paint(FREEG,
|
|
180
|
+
cells.push(paint(FREEG, GREY));
|
|
181
181
|
for (let i = 0; i < bufCells; i++)
|
|
182
182
|
cells.push(paint(USED, BUFFER_COLOR));
|
|
183
183
|
cells.length = GRID_CELLS;
|