mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 05:03:26 +00:00
Syntax highlighting improvements
- Fix cli-highlight import (use static import instead of dynamic require) - Add syntax highlighting to read/write tool output - Update dark/light themes with VS Code default syntax colors - Add highlightCode and getLanguageFromPath exports - Upgrade @google/genai to 1.34.0 for IMAGE_RECITATION/IMAGE_OTHER FinishReason - Add AGENTS.md rule: never downgrade code to fix type errors from outdated deps
This commit is contained in:
parent
d2088f7789
commit
1a944f50f9
7 changed files with 133 additions and 39 deletions
|
|
@ -12,7 +12,7 @@ import {
|
|||
import stripAnsi from "strip-ansi";
|
||||
import type { CustomAgentTool } from "../../../core/custom-tools/types.js";
|
||||
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "../../../core/tools/truncate.js";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { getLanguageFromPath, highlightCode, theme } from "../theme/theme.js";
|
||||
|
||||
/**
|
||||
* Convert absolute path to tilde notation if it's in home directory
|
||||
|
|
@ -280,13 +280,19 @@ export class ToolExecutionComponent extends Container {
|
|||
|
||||
if (this.result) {
|
||||
const output = this.getTextOutput();
|
||||
const lines = output.split("\n");
|
||||
const rawPath = this.args?.file_path || this.args?.path || "";
|
||||
const lang = getLanguageFromPath(rawPath);
|
||||
const lines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
|
||||
|
||||
const maxLines = this.expanded ? lines.length : 10;
|
||||
const displayLines = lines.slice(0, maxLines);
|
||||
const remaining = lines.length - maxLines;
|
||||
|
||||
text += "\n\n" + displayLines.map((line: string) => theme.fg("toolOutput", replaceTabs(line))).join("\n");
|
||||
text +=
|
||||
"\n\n" +
|
||||
displayLines
|
||||
.map((line: string) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line))))
|
||||
.join("\n");
|
||||
if (remaining > 0) {
|
||||
text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
|
||||
}
|
||||
|
|
@ -318,9 +324,15 @@ export class ToolExecutionComponent extends Container {
|
|||
}
|
||||
}
|
||||
} else if (this.toolName === "write") {
|
||||
const path = shortenPath(this.args?.file_path || this.args?.path || "");
|
||||
const rawPath = this.args?.file_path || this.args?.path || "";
|
||||
const path = shortenPath(rawPath);
|
||||
const fileContent = this.args?.content || "";
|
||||
const lines = fileContent ? fileContent.split("\n") : [];
|
||||
const lang = getLanguageFromPath(rawPath);
|
||||
const lines = fileContent
|
||||
? lang
|
||||
? highlightCode(replaceTabs(fileContent), lang)
|
||||
: fileContent.split("\n")
|
||||
: [];
|
||||
const totalLines = lines.length;
|
||||
|
||||
text =
|
||||
|
|
@ -336,7 +348,11 @@ export class ToolExecutionComponent extends Container {
|
|||
const displayLines = lines.slice(0, maxLines);
|
||||
const remaining = lines.length - maxLines;
|
||||
|
||||
text += "\n\n" + displayLines.map((line: string) => theme.fg("toolOutput", replaceTabs(line))).join("\n");
|
||||
text +=
|
||||
"\n\n" +
|
||||
displayLines
|
||||
.map((line: string) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line))))
|
||||
.join("\n");
|
||||
if (remaining > 0) {
|
||||
text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue