@code-yeongyu/senpi-codemode 2026.9.22 → 2026.9.23-3
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/CHANGELOG.md +78 -0
- package/README.md +10 -8
- package/package.json +4 -4
- package/src/index.ts +3 -0
- package/src/tool/display-code.ts +145 -0
- package/src/tool/eval-request.ts +7 -12
- package/src/tool/eval-tool.ts +2 -2
- package/src/tool/render.ts +40 -12
- package/src/tool/types.ts +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,84 @@
|
|
|
12
12
|
|
|
13
13
|
### Removed
|
|
14
14
|
|
|
15
|
+
## [2026.9.23-3] - 2026-09-23
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Dense one-line JavaScript eval cells are previewed in the TUI broken at statement, block, and long-array boundaries with indentation, keeping the original tokens and comments. Unparseable, non-JavaScript, and already readable cells are shown as sent, and the code that runs is unchanged. ([#2050](https://github.com/code-yeongyu/senpi/issues/2050))
|
|
24
|
+
- The `eval` `summary` guide asks for a progress update saying what the agent is doing and why, in the language the user writes in, and summaries no longer have a length limit (the 80-character truncation is gone). A collapsed eval block shows the first three summary lines; expanding it shows the rest. ([#2050](https://github.com/code-yeongyu/senpi/issues/2050))
|
|
25
|
+
- Codemode CI tests use at most two fork workers, matching the coding-agent suite's interpreter-heavy test scheduling. Test deadlines, assertions, and local worker defaults are unchanged. ([#2039](https://github.com/code-yeongyu/senpi/issues/2039))
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
### Removed
|
|
30
|
+
|
|
31
|
+
## [2026.9.23-2] - 2026-09-23
|
|
32
|
+
|
|
33
|
+
### Breaking Changes
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
### Removed
|
|
42
|
+
|
|
43
|
+
## [2026.9.23] - 2026-09-23
|
|
44
|
+
|
|
45
|
+
### Breaking Changes
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
### Removed
|
|
54
|
+
|
|
55
|
+
## [2026.9.22-4] - 2026-09-22
|
|
56
|
+
|
|
57
|
+
### Breaking Changes
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
### Removed
|
|
66
|
+
|
|
67
|
+
## [2026.9.22-3] - 2026-09-22
|
|
68
|
+
|
|
69
|
+
### Breaking Changes
|
|
70
|
+
|
|
71
|
+
### Added
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
### Removed
|
|
78
|
+
|
|
79
|
+
## [2026.9.22-2] - 2026-09-22
|
|
80
|
+
|
|
81
|
+
### Breaking Changes
|
|
82
|
+
|
|
83
|
+
### Added
|
|
84
|
+
|
|
85
|
+
### Changed
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
|
|
89
|
+
- `wake_source_state` (live detached eval cells) is now published on the rpc channel as well as the in-process event bus, so out-of-process consumers see live cells the way the TUI footer does (#1943).
|
|
90
|
+
|
|
91
|
+
### Removed
|
|
92
|
+
|
|
15
93
|
## [2026.9.22] - 2026-09-21
|
|
16
94
|
|
|
17
95
|
### Breaking Changes
|
package/README.md
CHANGED
|
@@ -29,7 +29,9 @@ task-tool names are known.
|
|
|
29
29
|
session-adjacent spill files for large streams.
|
|
30
30
|
- TUI and HTML-export rendering for syntax-highlighted cells, status rows,
|
|
31
31
|
task progress, structured display values, truncation warnings, and image
|
|
32
|
-
fallbacks.
|
|
32
|
+
fallbacks. A JavaScript cell sent as dense one-line code is previewed broken
|
|
33
|
+
at statement, block, and long-array boundaries; the cell itself runs exactly
|
|
34
|
+
as sent.
|
|
33
35
|
- Runtime identity badges in eval headers — `eval py (3.14.7, ~/.venv/bin/python3)`,
|
|
34
36
|
`eval js (node 26.7.0, /opt/…/bin/node)` — with the same `runtime` info on
|
|
35
37
|
`EvalToolDetails` and its `cells` for RPC consumers; interpreter detection
|
|
@@ -207,13 +209,13 @@ same name/spec/mode; no worker state is reconstructed in the prelude.
|
|
|
207
209
|
|
|
208
210
|
## Required summary
|
|
209
211
|
|
|
210
|
-
Every `eval` run call MUST include a `summary` — one line in the
|
|
211
|
-
|
|
212
|
-
a
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
Every `eval` run call MUST include a `summary` — one line in the language the
|
|
213
|
+
user writes in: a progress update saying what the agent is doing and why, not
|
|
214
|
+
a label for the code. The
|
|
215
|
+
summary is shown in the TUI while the cell runs and in the finished result, so
|
|
216
|
+
you can always tell what is running and why. It has no length limit; a
|
|
217
|
+
collapsed block shows its first three lines. A run request without a
|
|
218
|
+
`summary` fails with a teaching error.
|
|
217
219
|
|
|
218
220
|
## Detached cells
|
|
219
221
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.23-3",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/parser": "8.0.4",
|
|
33
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.
|
|
33
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.23-3",
|
|
34
34
|
"typebox": "1.3.34"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@code-yeongyu/senpi": "2026.9.
|
|
37
|
+
"@code-yeongyu/senpi": "2026.9.23-3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@code-yeongyu/senpi": "2026.9.
|
|
40
|
+
"@code-yeongyu/senpi": "2026.9.23-3"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"senpi",
|
package/src/index.ts
CHANGED
|
@@ -114,6 +114,9 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
|
|
|
114
114
|
statusTicker.sync(entries);
|
|
115
115
|
};
|
|
116
116
|
const emitWakeSourceState = (state: WakeSourceState): void => {
|
|
117
|
+
// Same dual publication as the settle payload below: the in-process bus
|
|
118
|
+
// feeds the TUI footer, the rpc channel feeds out-of-process consumers.
|
|
119
|
+
pi.rpc?.emit(WAKE_SOURCE_STATE_EVENT, state);
|
|
117
120
|
pi.events?.emit(WAKE_SOURCE_STATE_EVENT, state);
|
|
118
121
|
};
|
|
119
122
|
const registerEvalForRuntime = (
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
import type { EvalLanguage } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
// Display-only: models often send a JS cell as one long line of joined statements. The preview
|
|
5
|
+
// breaks it at statement, block, and long-array boundaries and keeps every source token and
|
|
6
|
+
// comment verbatim. The tool arguments are never touched (senpi#1472).
|
|
7
|
+
const DENSE_LINE_LENGTH = 100;
|
|
8
|
+
const ARRAY_BREAK_LENGTH = 60;
|
|
9
|
+
const INDENT = " ";
|
|
10
|
+
const CACHE_LIMIT = 64;
|
|
11
|
+
|
|
12
|
+
type SourceNode = { readonly type: string; readonly start: number; readonly end: number };
|
|
13
|
+
|
|
14
|
+
// A whitespace/comma/comment region between two tokens that becomes a line break.
|
|
15
|
+
type Gap = {
|
|
16
|
+
readonly start: number;
|
|
17
|
+
readonly end: number;
|
|
18
|
+
readonly contentDepth: number;
|
|
19
|
+
readonly nextDepth: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const cache = new Map<string, string>();
|
|
23
|
+
|
|
24
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
25
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function sourceNode(value: unknown): SourceNode | undefined {
|
|
29
|
+
if (!isRecord(value)) return undefined;
|
|
30
|
+
const { type, start, end } = value;
|
|
31
|
+
if (typeof type !== "string" || typeof start !== "number" || typeof end !== "number") return undefined;
|
|
32
|
+
return { type, start, end };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sourceNodes(value: unknown): SourceNode[] {
|
|
36
|
+
if (!Array.isArray(value)) return [];
|
|
37
|
+
return value.flatMap((item) => sourceNode(item) ?? []);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isDense(code: string): boolean {
|
|
41
|
+
return code.split("\n").some((line) => line.length > DENSE_LINE_LENGTH);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function parseProgram(code: string): unknown {
|
|
45
|
+
try {
|
|
46
|
+
return parse(code, {
|
|
47
|
+
sourceType: "module",
|
|
48
|
+
allowAwaitOutsideFunction: true,
|
|
49
|
+
allowReturnOutsideFunction: true,
|
|
50
|
+
allowImportExportEverywhere: true,
|
|
51
|
+
}).program;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error instanceof SyntaxError) return undefined;
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function siblingGaps(children: readonly SourceNode[], depth: number): Gap[] {
|
|
59
|
+
return children.slice(1).map((child, index) => ({
|
|
60
|
+
start: children[index]?.end ?? child.start,
|
|
61
|
+
end: child.start,
|
|
62
|
+
contentDepth: depth,
|
|
63
|
+
nextDepth: depth,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Gaps for a bracketed container whose children move onto their own indented lines.
|
|
68
|
+
function containerGaps(container: SourceNode, children: readonly SourceNode[], depth: number): Gap[] {
|
|
69
|
+
const first = children[0];
|
|
70
|
+
const last = children.at(-1);
|
|
71
|
+
if (first === undefined || last === undefined) return [];
|
|
72
|
+
const inner = depth + 1;
|
|
73
|
+
return [
|
|
74
|
+
{ start: container.start + 1, end: first.start, contentDepth: inner, nextDepth: inner },
|
|
75
|
+
...siblingGaps(children, inner),
|
|
76
|
+
{ start: last.end, end: container.end - 1, contentDepth: inner, nextDepth: depth },
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function breakableChildren(node: SourceNode, record: Readonly<Record<string, unknown>>, code: string) {
|
|
81
|
+
if (node.type === "BlockStatement" || node.type === "StaticBlock") return sourceNodes(record.body);
|
|
82
|
+
if (node.type !== "ArrayExpression") return undefined;
|
|
83
|
+
const elements = sourceNodes(record.elements);
|
|
84
|
+
const text = code.slice(node.start, node.end);
|
|
85
|
+
if (elements.length < 2 || text.length <= ARRAY_BREAK_LENGTH || text.includes("\n")) return undefined;
|
|
86
|
+
return elements;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function collectGaps(value: unknown, depth: number, code: string, gaps: Gap[]): void {
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
for (const item of value) collectGaps(item, depth, code, gaps);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!isRecord(value)) return;
|
|
95
|
+
const node = sourceNode(value);
|
|
96
|
+
const children = node === undefined ? undefined : breakableChildren(node, value, code);
|
|
97
|
+
const breaks = node !== undefined && children !== undefined && children.length > 0;
|
|
98
|
+
if (breaks) gaps.push(...containerGaps(node, children, depth));
|
|
99
|
+
for (const [key, child] of Object.entries(value)) {
|
|
100
|
+
if (key === "loc" || key === "extra" || key.endsWith("Comments")) continue;
|
|
101
|
+
if (child !== null && typeof child === "object") collectGaps(child, breaks ? depth + 1 : depth, code, gaps);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function renderGap(text: string, gap: Gap): string {
|
|
106
|
+
let rest = text.trim();
|
|
107
|
+
let attached = "";
|
|
108
|
+
if (rest.startsWith(",") || rest.startsWith(";")) {
|
|
109
|
+
attached = rest.slice(0, 1);
|
|
110
|
+
rest = rest.slice(1).trim();
|
|
111
|
+
}
|
|
112
|
+
const contentIndent = INDENT.repeat(gap.contentDepth);
|
|
113
|
+
const content = rest
|
|
114
|
+
.split("\n")
|
|
115
|
+
.map((line) => line.trim())
|
|
116
|
+
.filter((line) => line.length > 0)
|
|
117
|
+
.map((line) => `\n${contentIndent}${line}`)
|
|
118
|
+
.join("");
|
|
119
|
+
return `${attached}${content}\n${INDENT.repeat(gap.nextDepth)}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function reformat(code: string): string {
|
|
123
|
+
const program = parseProgram(code);
|
|
124
|
+
if (!isRecord(program)) return code;
|
|
125
|
+
const gaps = siblingGaps(sourceNodes(program.body), 0);
|
|
126
|
+
collectGaps(program.body, 0, code, gaps);
|
|
127
|
+
gaps.sort((left, right) => left.start - right.start);
|
|
128
|
+
let output = "";
|
|
129
|
+
let cursor = 0;
|
|
130
|
+
for (const gap of gaps) {
|
|
131
|
+
output += code.slice(cursor, gap.start) + renderGap(code.slice(gap.start, gap.end), gap);
|
|
132
|
+
cursor = gap.end;
|
|
133
|
+
}
|
|
134
|
+
return (output + code.slice(cursor)).trim();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function displayCode(code: string, language: EvalLanguage): string {
|
|
138
|
+
if (language !== "js" || !isDense(code)) return code;
|
|
139
|
+
const cached = cache.get(code);
|
|
140
|
+
if (cached !== undefined) return cached;
|
|
141
|
+
const formatted = reformat(code);
|
|
142
|
+
if (cache.size >= CACHE_LIMIT) cache.delete(cache.keys().next().value ?? "");
|
|
143
|
+
cache.set(code, formatted);
|
|
144
|
+
return formatted;
|
|
145
|
+
}
|
package/src/tool/eval-request.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@code-yeongyu/senpi";
|
|
2
|
-
import {
|
|
2
|
+
import type { EvalControlInput, EvalToolInput, EvalToolRequest } from "./types.ts";
|
|
3
3
|
|
|
4
4
|
const NON_INTERACTIVE_MODES = new Set(["print", "json"]);
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// over-limit value is force-truncated here (prepareArguments runs before schema validation)
|
|
10
|
-
// instead of failing the call.
|
|
11
|
-
export function clampEvalSummary(value: unknown): string | undefined {
|
|
6
|
+
// A summary is one line of any length: whitespace (including newlines) collapses to single
|
|
7
|
+
// spaces, and a blank value counts as absent. The TUI bounds how much of it a collapsed block shows.
|
|
8
|
+
export function normalizeEvalSummary(value: unknown): string | undefined {
|
|
12
9
|
if (typeof value !== "string") return undefined;
|
|
13
10
|
const normalized = value.trim().replace(/\s+/gu, " ");
|
|
14
|
-
|
|
15
|
-
if (normalized.length <= EVAL_SUMMARY_MAX_LENGTH) return normalized;
|
|
16
|
-
return `${normalized.slice(0, EVAL_SUMMARY_MAX_LENGTH - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
11
|
+
return normalized.length === 0 ? undefined : normalized;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
export function parseEvalRequest(params: unknown): EvalToolRequest {
|
|
@@ -28,10 +23,10 @@ export function parseEvalRequest(params: unknown): EvalToolRequest {
|
|
|
28
23
|
throw new TypeError(`Unknown eval action "${String(params.action)}"`);
|
|
29
24
|
if (!isEvalLanguage(params.language)) throw new TypeError("eval run requires language");
|
|
30
25
|
if (typeof params.code !== "string") throw new TypeError("eval run requires code");
|
|
31
|
-
const summary =
|
|
26
|
+
const summary = normalizeEvalSummary(params.summary);
|
|
32
27
|
if (summary === undefined)
|
|
33
28
|
throw new TypeError(
|
|
34
|
-
"eval run requires summary — one line in the user's language: what
|
|
29
|
+
"eval run requires summary — one line in the user's language: what you are working on and for what purpose",
|
|
35
30
|
);
|
|
36
31
|
if (params.on_timeout !== undefined && params.on_timeout !== "detach" && params.on_timeout !== "error")
|
|
37
32
|
throw new TypeError(`Unknown eval on_timeout value "${String(params.on_timeout)}"`);
|
package/src/tool/eval-tool.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { buildEvalPrompt } from "../prompt/eval-prompt.ts";
|
|
9
9
|
import { EvalDetachedCellManager } from "./detached-cell-manager.ts";
|
|
10
10
|
import { executeEvalControl } from "./detached-eval-result.ts";
|
|
11
|
-
import {
|
|
11
|
+
import { isEvalControlRequest, normalizeEvalSummary, parseEvalRequest } from "./eval-request.ts";
|
|
12
12
|
import type { CreateEvalToolOptions } from "./eval-tool-options.ts";
|
|
13
13
|
import { runEvalCell } from "./run-eval-cell.ts";
|
|
14
14
|
import {
|
|
@@ -109,7 +109,7 @@ export function createEvalTool(options: CreateEvalToolOptions) {
|
|
|
109
109
|
const record = args as Record<string, unknown>;
|
|
110
110
|
if (record.action === "peek" || record.action === "stop" || record.action === "list")
|
|
111
111
|
return args as EvalToolRequest;
|
|
112
|
-
const summary =
|
|
112
|
+
const summary = normalizeEvalSummary(record.summary);
|
|
113
113
|
if (summary === undefined) delete record.summary;
|
|
114
114
|
else record.summary = summary;
|
|
115
115
|
return args as EvalToolRequest;
|
package/src/tool/render.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
truncateToVisualLines,
|
|
11
11
|
} from "@code-yeongyu/senpi";
|
|
12
12
|
import { formatTruncationWarning, stripOutputNotice, type TruncationMeta } from "../output/output-meta.ts";
|
|
13
|
+
import { displayCode } from "./display-code.ts";
|
|
14
|
+
import { normalizeEvalSummary } from "./eval-request.ts";
|
|
13
15
|
import {
|
|
14
16
|
JSON_TREE_MAX_DEPTH_COLLAPSED,
|
|
15
17
|
JSON_TREE_MAX_DEPTH_EXPANDED,
|
|
@@ -64,6 +66,7 @@ type RenderBlock =
|
|
|
64
66
|
| { readonly kind: "dynamic"; readonly render: (width: number) => readonly string[] };
|
|
65
67
|
|
|
66
68
|
const CODE_PREVIEW_LINES = 4;
|
|
69
|
+
const SUMMARY_PREVIEW_LINES = 3;
|
|
67
70
|
const OUTPUT_PREVIEW_LINES = 8;
|
|
68
71
|
const STATUS_PREVIEW_COUNT = 3;
|
|
69
72
|
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
|
|
@@ -182,6 +185,22 @@ function renderAllVisualLines(text: string, width: number): string[] {
|
|
|
182
185
|
return truncateToVisualLines(text, Number.POSITIVE_INFINITY, width).visualLines.map((line) => line.trimEnd());
|
|
183
186
|
}
|
|
184
187
|
|
|
188
|
+
// A summary has no length limit, so a collapsed block shows its first lines and marks the cut.
|
|
189
|
+
function summaryVisualLines(summary: string, width: number, expanded: boolean): string[] {
|
|
190
|
+
const lines = renderAllVisualLines(summary, width);
|
|
191
|
+
if (expanded || lines.length <= SUMMARY_PREVIEW_LINES) return lines;
|
|
192
|
+
const kept = renderAllVisualLines(summary, Math.max(1, width - 1)).slice(0, SUMMARY_PREVIEW_LINES);
|
|
193
|
+
kept[SUMMARY_PREVIEW_LINES - 1] = `${kept[SUMMARY_PREVIEW_LINES - 1] ?? ""}\u2026`;
|
|
194
|
+
return kept;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function summaryBlock(summary: string, theme: Theme | undefined, expanded: boolean): RenderBlock {
|
|
198
|
+
return {
|
|
199
|
+
kind: "dynamic",
|
|
200
|
+
render: (width) => summaryVisualLines(summary, width, expanded).map((line) => style(theme, "muted", line)),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
185
204
|
function renderTextBlock(block: Extract<RenderBlock, { kind: "text" }>, width: number): string[] {
|
|
186
205
|
if (block.maxVisualLines === undefined) return renderAllVisualLines(block.text, width);
|
|
187
206
|
const result = truncateToVisualLines(block.text, block.maxVisualLines, width);
|
|
@@ -286,7 +305,7 @@ function languageForHighlighter(language: EvalLanguage): "python" | "javascript"
|
|
|
286
305
|
|
|
287
306
|
function highlightedCode(code: string, language: EvalLanguage, theme: Theme | undefined): string {
|
|
288
307
|
const normalizedCode = code.trim().length > 0 ? code : "...";
|
|
289
|
-
const lines = highlightCode(normalizedCode, languageForHighlighter(language));
|
|
308
|
+
const lines = highlightCode(displayCode(normalizedCode, language), languageForHighlighter(language));
|
|
290
309
|
return (theme === undefined ? lines.map((line) => line.replace(/\u001b\[[0-9;]*m/gu, "")) : lines).join("\n");
|
|
291
310
|
}
|
|
292
311
|
|
|
@@ -618,11 +637,9 @@ function renderCell(cell: EvalCellResult, environment: RenderEnvironment, badges
|
|
|
618
637
|
if (cell.summary !== undefined) {
|
|
619
638
|
appendLines(
|
|
620
639
|
lines,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
color: "muted",
|
|
625
|
-
}),
|
|
640
|
+
summaryVisualLines(cell.summary, Math.max(1, environment.width - 2), environment.expanded).map(
|
|
641
|
+
(line) => `${style(environment.theme, "muted", "│ ")}${style(environment.theme, "muted", line)}`,
|
|
642
|
+
),
|
|
626
643
|
);
|
|
627
644
|
}
|
|
628
645
|
const innerWidth = Math.max(1, environment.width - 2);
|
|
@@ -883,6 +900,13 @@ function resultMetadata(
|
|
|
883
900
|
return [{ kind: "text", text: style(theme, "muted", metadata.join(" | ")) }];
|
|
884
901
|
}
|
|
885
902
|
|
|
903
|
+
// The call renderer reads the assistant message's raw arguments, which keep the provider's
|
|
904
|
+
// original summary (senpi#1472 detached preparation from the message), so it normalizes here,
|
|
905
|
+
// idempotently: an already-normalized value is returned unchanged.
|
|
906
|
+
function displaySummary(summary: string | undefined): string | undefined {
|
|
907
|
+
return normalizeEvalSummary(summary);
|
|
908
|
+
}
|
|
909
|
+
|
|
886
910
|
export function renderEvalCall(
|
|
887
911
|
args: EvalToolRequest,
|
|
888
912
|
theme: Theme | undefined,
|
|
@@ -905,10 +929,16 @@ export function renderEvalCall(
|
|
|
905
929
|
const timeout = args.timeout === undefined ? "" : ` timeout ${args.timeout}s`;
|
|
906
930
|
component.setBlocks([
|
|
907
931
|
{ kind: "text", text: style(theme, "toolTitle", `eval ${args.language}${reset}${timeout}`) },
|
|
908
|
-
...(args.summary === undefined
|
|
932
|
+
...(displaySummary(args.summary) === undefined
|
|
933
|
+
? []
|
|
934
|
+
: [summaryBlock(displaySummary(args.summary) ?? "", theme, context.expanded)]),
|
|
909
935
|
{
|
|
910
936
|
kind: "text",
|
|
911
|
-
text: style(
|
|
937
|
+
text: style(
|
|
938
|
+
theme,
|
|
939
|
+
"mdCodeBlock",
|
|
940
|
+
args.code.trim().length > 0 ? displayCode(args.code, args.language) : "...",
|
|
941
|
+
),
|
|
912
942
|
maxVisualLines: context.expanded ? undefined : CODE_PREVIEW_LINES,
|
|
913
943
|
collapseKind: "code",
|
|
914
944
|
theme,
|
|
@@ -930,7 +960,7 @@ export function renderEvalCall(
|
|
|
930
960
|
};
|
|
931
961
|
const cell: EvalCellResult = {
|
|
932
962
|
index: 0,
|
|
933
|
-
...(args.summary === undefined ? {} : { summary: args.summary }),
|
|
963
|
+
...(displaySummary(args.summary) === undefined ? {} : { summary: displaySummary(args.summary) ?? "" }),
|
|
934
964
|
code: args.code,
|
|
935
965
|
language: args.language,
|
|
936
966
|
output: "",
|
|
@@ -996,9 +1026,7 @@ export function renderEvalResult(
|
|
|
996
1026
|
const status = resultStatus(details, options, context.isError);
|
|
997
1027
|
const blocks: RenderBlock[] = [
|
|
998
1028
|
{ kind: "text", text: resultHeader(details, status, theme) },
|
|
999
|
-
...(details?.summary === undefined
|
|
1000
|
-
? []
|
|
1001
|
-
: [{ kind: "text" as const, text: style(theme, "muted", details.summary) }]),
|
|
1029
|
+
...(details?.summary === undefined ? [] : [summaryBlock(details.summary, theme, expanded)]),
|
|
1002
1030
|
...resultMetadata(details, options, theme, status),
|
|
1003
1031
|
{ kind: "blank" },
|
|
1004
1032
|
];
|
package/src/tool/types.ts
CHANGED
|
@@ -17,8 +17,6 @@ export function enabledLanguageList(enabled: EnabledEvalLanguages): EvalLanguage
|
|
|
17
17
|
return evalLanguageOrder.filter((language) => enabled[language]);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const EVAL_SUMMARY_MAX_LENGTH = 80;
|
|
21
|
-
|
|
22
20
|
/** The deadlines the schema teaches the model; every number comes from the resolved settings. */
|
|
23
21
|
export interface EvalDeadlineSeconds {
|
|
24
22
|
readonly runBudgetSeconds: number;
|
|
@@ -79,9 +77,8 @@ function evalInputProperties<Language extends TSchema>(languageSchema: Language,
|
|
|
79
77
|
code: Type.Optional(Type.String({ description: "Cell body, verbatim." })),
|
|
80
78
|
summary: Type.Optional(
|
|
81
79
|
Type.String({
|
|
82
|
-
maxLength: EVAL_SUMMARY_MAX_LENGTH,
|
|
83
80
|
description:
|
|
84
|
-
"REQUIRED for run.
|
|
81
|
+
"REQUIRED for run. One line in the language the user writes in: a progress update saying what you are doing and why, not a label for the code; shown in the TUI while the cell runs.",
|
|
85
82
|
}),
|
|
86
83
|
),
|
|
87
84
|
timeout: Type.Optional(Type.Number({ minimum: 1, description: timeoutFieldDescription(deadlines) })),
|