mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 02:03:16 +00:00
Fix read/write tool output formatting
- Remove code fences (```) from read output - show raw content - Show first 10 lines instead of 5 for read - Only show line count for write if > 10 lines - Remove indentation from read output - Cleaner, more minimal tool output display
This commit is contained in:
parent
4fa09814bd
commit
10520a8c41
3 changed files with 57 additions and 8 deletions
|
|
@ -1,4 +1,30 @@
|
||||||
Hello, World!
|
The Quick Brown Fox and the Lazy Dog
|
||||||
This line has been edited!
|
=====================================
|
||||||
This is line three.
|
|
||||||
Goodbye, World!
|
Once upon a time, in a forest clearing, there lived a remarkably quick brown fox.
|
||||||
|
This fox was known throughout the woodland for its incredible speed and agility.
|
||||||
|
|
||||||
|
Every morning, the fox would race through the trees, leaping over logs and streams.
|
||||||
|
The other animals watched in awe as it darted past them in a blur of russet fur.
|
||||||
|
|
||||||
|
Near the edge of the clearing, there also lived a very lazy dog.
|
||||||
|
This dog preferred napping in the warm sunshine to any sort of adventure.
|
||||||
|
|
||||||
|
One day, the fox challenged the dog to a race across the meadow.
|
||||||
|
The dog yawned and declined, saying "Why rush when you can rest?"
|
||||||
|
|
||||||
|
The fox laughed and zipped away, exploring distant hills and valleys.
|
||||||
|
The dog simply rolled over and continued its peaceful slumber.
|
||||||
|
|
||||||
|
As the sun set, the fox returned, exhausted from its day of running.
|
||||||
|
The dog opened one eye and wagged its tail contentedly.
|
||||||
|
|
||||||
|
"I've seen the whole world today!" exclaimed the tired fox proudly.
|
||||||
|
"And I've enjoyed every moment right here," replied the lazy dog.
|
||||||
|
|
||||||
|
Sometimes speed and adventure bring joy to life's journey.
|
||||||
|
Other times, stillness and contentment are the greatest treasures.
|
||||||
|
|
||||||
|
Both the quick fox and the lazy dog lived happily in their own ways.
|
||||||
|
|
||||||
|
The End.
|
||||||
|
|
|
||||||
|
|
@ -64,15 +64,14 @@ export class ToolExecutionComponent extends Container {
|
||||||
text = `**read** \`${path}\``;
|
text = `**read** \`${path}\``;
|
||||||
if (this.result) {
|
if (this.result) {
|
||||||
const lines = this.result.output.split("\n");
|
const lines = this.result.output.split("\n");
|
||||||
const maxLines = 5;
|
const maxLines = 10;
|
||||||
const displayLines = lines.slice(0, maxLines);
|
const displayLines = lines.slice(0, maxLines);
|
||||||
const remaining = lines.length - maxLines;
|
const remaining = lines.length - maxLines;
|
||||||
|
|
||||||
text += "\n```\n" + displayLines.join("\n");
|
text += "\n" + displayLines.join("\n");
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
text += `\n... (${remaining} more lines)`;
|
text += `\n... (${remaining} more lines)`;
|
||||||
}
|
}
|
||||||
text += "\n```";
|
|
||||||
|
|
||||||
if (this.result.isError) {
|
if (this.result.isError) {
|
||||||
text += " ❌";
|
text += " ❌";
|
||||||
|
|
@ -82,8 +81,12 @@ export class ToolExecutionComponent extends Container {
|
||||||
const path = this.args.path || "";
|
const path = this.args.path || "";
|
||||||
const content = this.args.content || "";
|
const content = this.args.content || "";
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
text = `**write** \`${path}\` (${lines.length} lines)`;
|
text = `**write** \`${path}\``;
|
||||||
if (this.result) {
|
if (this.result) {
|
||||||
|
const totalLines = lines.length;
|
||||||
|
if (totalLines > 10) {
|
||||||
|
text += ` (${totalLines} lines)`;
|
||||||
|
}
|
||||||
text += this.result.isError ? " ❌" : " ✓";
|
text += this.result.isError ? " ❌" : " ✓";
|
||||||
}
|
}
|
||||||
} else if (this.toolName === "edit") {
|
} else if (this.toolName === "edit") {
|
||||||
|
|
|
||||||
20
packages/test.txt
Normal file
20
packages/test.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
Line 1: The quick brown fox jumps over the lazy dog
|
||||||
|
Line 2: Testing the TUI renderer with multiple lines
|
||||||
|
Line 3: Each line contains some different text
|
||||||
|
Line 4: This is line number four
|
||||||
|
Line 5: Halfway through the first ten lines
|
||||||
|
Line 6: More content for testing purposes
|
||||||
|
Line 7: Seven is a lucky number
|
||||||
|
Line 8: Eight lines down, twelve to go
|
||||||
|
Line 9: Almost at line ten
|
||||||
|
Line 10: Double digits now
|
||||||
|
Line 11: Starting the second half
|
||||||
|
Line 12: A dozen lines complete
|
||||||
|
Line 13: Unlucky for some, lucky for others
|
||||||
|
Line 14: Fortnight means fourteen nights
|
||||||
|
Line 15: Three quarters of the way there
|
||||||
|
Line 16: Sweet sixteen
|
||||||
|
Line 17: Just a few more lines left
|
||||||
|
Line 18: Penultimate line coming up
|
||||||
|
Line 19: This is the second to last line
|
||||||
|
Line 20: The final line of this test file
|
||||||
Loading…
Add table
Add a link
Reference in a new issue