Prefix rendered shell commands with '$ ' in logs

Shell commands in log output are now prefixed with '$ ' for improved readability and consistency with common shell output conventions. Updated related test data and test helper comments to reflect this change.
This commit is contained in:
Kynan Ware 2025-09-16 11:58:58 -06:00
parent d636f4c213
commit 97d3253aaf
4 changed files with 16 additions and 15 deletions

View file

@ -153,7 +153,7 @@ func renderLogEntry(entry chatCompletionChunkEntry, w io.Writer, io *iostreams.I
contentWithCommand := choice.Delta.Content
if v.Command != "" {
contentWithCommand = fmt.Sprintf("%s\n%s", v.Command, choice.Delta.Content)
contentWithCommand = fmt.Sprintf("$ %s\n%s", v.Command, choice.Delta.Content)
}
if err := renderFileContentAsMarkdown("commands.sh", contentWithCommand, w, io); err != nil {
return false, fmt.Errorf("failed to render bash command output: %w", err)

View file

@ -58,7 +58,8 @@ func TestFollow(t *testing.T) {
// Handy note for updating the testdata files when they change:
// ext := filepath.Ext(tt.log)
// stripped := strings.TrimSuffix(tt.log, ext)
// os.WriteFile(stripped+".want"+ext, stdout.Bytes(), 0644)
// stripped = strings.TrimSuffix(stripped, "-input")
// os.WriteFile(stripped+"-want"+ext, stdout.Bytes(), 0644)
want, err := os.ReadFile(tt.want)
require.NoError(t, err)

View file

@ -11,7 +11,7 @@ View repository
README.md
Bash: Check current directory and list all files
cd /home/runner/work/foo/foo && pwd && ls -la
$ cd /home/runner/work/foo/foo && pwd && ls -la
/home/runner/work/foo/foo
total 20
drwxr-xr-x 4 runner docker 4096 Sep 9 10:17 .
@ -36,8 +36,8 @@ View README.md
# foo
Bash: Check if there are any existing scripts or build files
cd /home/runner/work/foo/foo && find . -name "*.sh" -o -name "Makefile" -o -
name "package.json" -o -name "*.yml" -o -name "*.yaml"
$ cd /home/runner/work/foo/foo && find . -name "*.sh" -o -name "Makefile" -
o -name "package.json" -o -name "*.yml" -o -name "*.yaml"
./.github/workflows/upload-artifact.yml
./.github/workflows/manual-dispatch.yml
./.github/workflows/cache.yml
@ -195,7 +195,7 @@ Create: os_info.sh
Now let me make the script executable and test it:
Bash: Make script executable and test it
cd /home/runner/work/foo/foo && chmod +x os_info.sh && ./os_info.sh
$ cd /home/runner/work/foo/foo && chmod +x os_info.sh && ./os_info.sh
==================================================
OPERATING SYSTEM INFORMATION
==================================================
@ -270,7 +270,7 @@ diff --git a/home/runner/work/foo/foo/README.md
Let me verify the changes look good:
Bash: Check file permissions and final status
cd /home/runner/work/foo/foo && ls -la os_info.sh && echo "---" && git
$ cd /home/runner/work/foo/foo && ls -la os_info.sh && echo "---" && git
status
-rwxr-xr-x 1 runner docker 2139 Sep 9 10:18 os_info.sh
---
@ -323,7 +323,7 @@ Perfect! Let me test the script one more time to make sure everything is
working correctly and commit the changes:
Bash: Final test of the script
cd /home/runner/work/foo/foo && echo "Testing script execution:" && .
$ cd /home/runner/work/foo/foo && echo "Testing script execution:" && .
/os_info.sh | head -10
Testing script execution:
==================================================

View file

@ -6,7 +6,7 @@ I'll help you create a .yaml file with random fields in the repository. Let
and then create a plan.
Bash: Find documentation and config files to understand the repository
cd /home/runner/work/foo/foo && find . -type f -name "*.md" -o -name "*.
$ cd /home/runner/work/foo/foo && find . -type f -name "*.md" -o -name "*.
txt" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" | head -20
./README.md
./.github/workflows/upload-artifact.yml
@ -23,7 +23,7 @@ View repository
README.md
Bash: List all files in the root directory
cd /home/runner/work/foo/foo && ls -la
$ cd /home/runner/work/foo/foo && ls -la
total 20
drwxr-xr-x 4 runner runner 4096 Sep 11 13:35 .
drwxr-xr-x 3 runner runner 4096 Sep 11 13:34 ..
@ -37,7 +37,7 @@ View README.md
# foo
Bash: Check git status to understand current state
cd /home/runner/work/foo/foo && git --no-pager status
$ cd /home/runner/work/foo/foo && git --no-pager status
On branch copilot/fix-5b1c2fcb-9248-492c-84fa-04a3e0304d25
Your branch is up to date with 'origin/copilot/fix-5b1c2fcb-9248-492c-84fa-
04a3e0304d25'.
@ -197,13 +197,13 @@ Now let me verify that the YAML file is valid by testing it with a YAML
parser:
Bash: Validate the YAML file syntax
cd /home/runner/work/foo/foo && python3 -c "import yaml; yaml.
$ cd /home/runner/work/foo/foo && python3 -c "import yaml; yaml.
safe_load(open('sample-data.yaml', 'r')); print('YAML file is valid!')"
<exited with exit code 0>
Bash: Validate YAML and show structure
cd /home/runner/work/foo/foo && python3 -c "import yaml; data = yaml.
$ cd /home/runner/work/foo/foo && python3 -c "import yaml; data = yaml.
safe_load(open('sample-data.yaml', 'r')); print('YAML file is valid!');
print(f'Loaded {len(data)} top-level keys: {list(data.keys())}')"
@ -213,7 +213,7 @@ cd /home/runner/work/foo/foo && python3 -c "import yaml; data = yaml.
Let me try a different approach to verify the YAML:
Bash: Detailed YAML validation with content verification
cd /home/runner/work/foo/foo && python3 -c "
$ cd /home/runner/work/foo/foo && python3 -c "
import yaml
try:
with open('sample-data.yaml', 'r') as f:
@ -237,7 +237,7 @@ cd /home/runner/work/foo/foo && python3 -c "
Perfect! Let me also check the file contents and verify the current status:
Bash: Check git status to see the new file
cd /home/runner/work/foo/foo && git --no-pager status
$ cd /home/runner/work/foo/foo && git --no-pager status
On branch copilot/fix-5b1c2fcb-9248-492c-84fa-04a3e0304d25
Your branch is up to date with 'origin/copilot/fix-5b1c2fcb-9248-492c-84fa-
04a3e0304d25'.