feat(coding-agent): added cell-by-cell Python execution tracking with duration and exit codes

- Added cell-by-cell Python execution tracking with duration and exit codes.
- Added template system with {{placeholders}} for task tool context rendering.
- Enhanced patch applicator to preserve exact indentation when intended.
- Changed Python tool to use cells array instead of single code parameter.
- Updated task tool schema to require vars instead of task field.
This commit is contained in:
can1357
2026-01-21 11:58:29 +01:00
parent 4555c8ba9d
commit 96822471c2
13 changed files with 769 additions and 142 deletions
@@ -1,7 +1,6 @@
import { describe, expect, it } from "bun:test";
import stripAnsi from "strip-ansi";
import { pythonToolRenderer } from "../../src/core/tools/python";
import { truncateTail } from "../../src/core/tools/truncate";
import { getThemeByName } from "../../src/modes/interactive/theme/theme";
describe("pythonToolRenderer", () => {
@@ -11,26 +10,37 @@ describe("pythonToolRenderer", () => {
const uiTheme = theme!;
const fullOutput = ["line 1", "line 2", "line 3", "line 4"].join("\n");
const truncation = truncateTail(fullOutput, { maxLines: 2, maxBytes: 128 });
const result = {
content: [{ type: "text", text: truncation.content }],
content: [{ type: "text", text: fullOutput }],
details: {
truncation,
fullOutput,
cells: [
{
index: 0,
title: "run",
code: "print('hello')",
output: fullOutput,
status: "complete" as const,
durationMs: 12,
},
],
},
};
const collapsed = pythonToolRenderer.renderResult(result, { expanded: false, isPartial: false }, uiTheme);
const collapsed = pythonToolRenderer.renderResult(
result,
{ expanded: false, isPartial: false, renderContext: { previewLines: 2 } },
uiTheme,
);
const collapsedLines = stripAnsi(collapsed.render(80).join("\n"));
expect(collapsedLines).toContain("line 4");
expect(collapsedLines).not.toContain("line 1");
expect(collapsedLines).toContain("Truncated:");
expect(collapsedLines).toContain("more lines");
const expanded = pythonToolRenderer.renderResult(result, { expanded: true, isPartial: false }, uiTheme);
const expandedLines = stripAnsi(expanded.render(80).join("\n"));
expect(expandedLines).toContain("line 1");
expect(expandedLines).toContain("line 4");
expect(expandedLines).not.toContain("Truncated:");
expect(expandedLines).not.toContain("more lines");
});
});