mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 17:54:23 +01:00
wip: refactoring tui
This commit is contained in:
@@ -97,13 +97,15 @@ export const view = Tool.define({
|
||||
`This is an image file of type: ${isImage}\nUse a different tool to process images`,
|
||||
);
|
||||
const lines = await file.text().then((text) => text.split("\n"));
|
||||
const content = lines.slice(offset, offset + limit).map((line, index) => {
|
||||
line =
|
||||
line.length > MAX_LINE_LENGTH
|
||||
? line.substring(0, MAX_LINE_LENGTH) + "..."
|
||||
: line;
|
||||
const raw = lines.slice(offset, offset + limit).map((line) => {
|
||||
return line.length > MAX_LINE_LENGTH
|
||||
? line.substring(0, MAX_LINE_LENGTH) + "..."
|
||||
: line;
|
||||
});
|
||||
const content = raw.map((line, index) => {
|
||||
return `${(index + offset + 1).toString().padStart(5, "0")}| ${line}`;
|
||||
});
|
||||
const preview = raw.slice(0, 20).join("\n");
|
||||
|
||||
let output = "<file>\n";
|
||||
output += content.join("\n");
|
||||
@@ -121,6 +123,9 @@ export const view = Tool.define({
|
||||
|
||||
return {
|
||||
output,
|
||||
metadata: {
|
||||
preview,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user