diff options
| author | adamdottv <[email protected]> | 2025-05-30 12:29:27 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-30 12:29:27 -0500 |
| commit | 6ebbcb3179119e6e2e1c35e41eb20ed283c0952c (patch) | |
| tree | a97412b7ff3777351b074d7525609756d1775e26 /js/src | |
| parent | 437de4ee36cc66e94c7b615f193ea53058c843b1 (diff) | |
| download | opencode-6ebbcb3179119e6e2e1c35e41eb20ed283c0952c.tar.gz opencode-6ebbcb3179119e6e2e1c35e41eb20ed283c0952c.zip | |
wip: refactoring tui
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/tool/view.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/js/src/tool/view.ts b/js/src/tool/view.ts index b36fa94f6..3ba36470d 100644 --- a/js/src/tool/view.ts +++ b/js/src/tool/view.ts @@ -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, + }, }; }, }); |
