GeezerVison is showing github.com — fix(core): name the shell in the shell tool's Code Mode description by rekram1-node · Pull Request #65712 · anomalyco/opencode
Conversation
Issue for this PR
Closes #
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
With full_codemode on, the shell tool's description never said which OS and shell commands run in ("Commands run on macOS using zsh."). Session hooks added that sentence to the direct tool definitions each request, but under full_codemode shell is listed in the Code Mode catalog instead (#64284, #64515), so the hooks found nothing to change.
The tool now reads the shell when it is built and names it in both its direct and its Code Mode description. The context, compaction and generate hooks that patched it are gone. ShellSelect now publishes an internal shell-select.updated Bus event when the selected shell changes (defined in core, so it isn't part of the public event list), the same way agents and web search announce updates, and the shell tool rebuilds on it. The description always names the shell commands actually use, whichever plugin set it, and changing shell in config updates it after the selection reloads instead of depending on which plugin hears the config change first. The description is still the same string on every request, so it doesn't affect prompt caching.
How did you verify your code works?
bun run check passes. Shell tool, shell target environment, machine path, session shell and Code Mode tests pass, plus automation shell and config command tests. Two conditional process substitution tests in tool-shell.test.ts fail on my machine with and without this change.
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Code Mode fix works. With full_codemode, the pinned shell catalog entry now names the shell (Commands run on Linux using bash.); on the base it named none. The direct definition names it too. I checked this with temporary logging in the existing tool-shell.test.ts Code Mode and registry tests on the base and on the PR. Shell tool, target environment and machine path tests pass (157 pass, 23 skip). tsc -b for packages/core passes.
The public API is unchanged.
One regression, explained inline: once shell is changed in config, the description keeps naming the old shell until something else rebuilds the tools. The removed hooks looked up the shell on every request, so they never had this problem. I reproduced it: after changing opencode.json from /usr/bin/sh to /usr/bin/bash, shell selection gave /usr/bin/bash, but the description still said sh.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stale shell name after a config change is fixed. I reran the earlier test: after opencode.json changes from /usr/bin/sh to /usr/bin/bash, the shell tool description now names bash. Shell, config command and pty tests pass, and tsc -b for packages/core passes.
The public API is unchanged. ShellSelect.Interface gains a required changes stream, but that interface is internal to core, and its only other implementation, a test stub, was updated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to the internal shell-select.updated Bus event keeps the fix. After opencode.json changes from /usr/bin/sh to /usr/bin/bash, the shell tool description names bash. The shell, config command, pty and subagent tests pass, and tsc -b for packages/core passes.
The public API is unchanged. The new event is an ephemeral core event, like wellknown.updated, and isn't part of the SDK or OpenAPI event list.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|