Improve Shell Command Output Handling for Large Outputs

Solves - #741

Key Changes -

  • Metadata Block: Includes command, total_stdout_chars, total_stderr_chars, truncated, temp_file, and exit_code.

  • Improved Output Tagging: Displays the first and last 20,000 characters with <stdout> and <stderr> tags, and shows a <truncated> tag for omitted characters. Full output is saved to a temp file.

  • Consistent Formatting: Aligns output format with other tools for better readability.

  • Better Empty Output Handling: Provides a clear success or failure message if both stdout and stderr are empty.

Example Output

For Large Output:

---
command: cat large_test.txt
total_stdout_chars: 50000
total_stderr_chars: 0
truncated: true
temp_file: /tmp/forge_shell_xxxxx.txt
exit_code: 0
---
<stdout chars="0-20000">
(first 20,000 chars)
</stdout>
<truncated>
...output truncated (10,000 characters not shown)...
</truncated>
<stdout chars="30000-50000">
(last 20,000 chars)
</stdout>

/claim #741

Claim

Total prize pool $150
Total paid $0
Status Pending
Submitted May 03, 2025
Last updated May 03, 2025

Contributors

LU

Luffy

@luffy-orf

100%

Sponsors

FO

Forge

@antinomyhq

$150