Skip to content

test: bash tool PATH injection for .opencode/tools/ user tools#366

Merged
anandgupta42 merged 3 commits intomainfrom
claude/test-bash-path-injection-20260322-01KTCZNzQYZW4RiAP7t4Y1x2
Mar 22, 2026
Merged

test: bash tool PATH injection for .opencode/tools/ user tools#366
anandgupta42 merged 3 commits intomainfrom
claude/test-bash-path-injection-20260322-01KTCZNzQYZW4RiAP7t4Y1x2

Conversation

@anandgupta42
Copy link
Contributor

@anandgupta42 anandgupta42 commented Mar 22, 2026

What does this PR do?

1. Bash tool PATH injection — src/tool/bash.ts:166-210 (3 new tests)

The recent skill CLI commit (d6a1e6b) added PATH prepend logic to the bash tool so that user-created tools in .opencode/tools/ directories are automatically available during bash execution. Zero tests existed for this critical integration point. If PATH injection silently breaks, skill create would generate tools that users can't execute — the most common failure mode for the new skill workflow.

New coverage includes:

  • Tool execution via PATH: Creates an executable in .opencode/tools/, runs it by name through the bash tool, and verifies it produces correct output — proving the PATH injection actually works end-to-end
  • No duplicate PATH entries: Verifies that .opencode/tools/ directories appear at most once in PATH, preventing PATH pollution across repeated bash tool invocations
  • ALTIMATE_BIN_DIR priority: When set, verifies the bundled tools directory appears early in PATH (prepended, not appended), ensuring bundled tools like altimate-dbt take precedence over system commands

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage for recently shipped .opencode/tools/ PATH injection feature

How did you verify your code works?

GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null bun test test/tool/bash.test.ts
# 18 pass, 0 fail (15 existing + 3 new)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01KTCZNzQYZW4RiAP7t4Y1x2

Summary by CodeRabbit

  • Tests
    • Added tests for custom tool execution and PATH environment variable handling verification.

Adds 3 integration tests verifying that the bash tool correctly prepends
.opencode/tools/ directories to PATH, enabling user-created skill tools
to execute without requiring manual PATH configuration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01KTCZNzQYZW4RiAP7t4Y1x2
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Added test suite validating PATH injection behavior in BashTool. Tests verify custom tool execution from .opencode/tools, single occurrence of injected directory in PATH, and ALTIMATE_BIN_DIR priority when environment variable is set.

Changes

Cohort / File(s) Summary
PATH Injection Test Suite
packages/opencode/test/tool/bash.test.ts
Added three test cases with async filesystem setup to verify BashTool PATH injection: custom tool execution, PATH directory occurrence validation, and ALTIMATE_BIN_DIR priority handling when set.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A toolkit hops along the PATH so keen,
With custom tools injected in between,
Tests now verify each directory's place,
Ensuring priorities keep proper pace! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding tests for bash tool PATH injection for .opencode/tools/ user tools, which directly matches the changeset.
Description check ✅ Passed The PR description covers the key sections (Summary, Test Plan, Checklist) and provides comprehensive detail about what was tested, why it matters, and verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/test-bash-path-injection-20260322-01KTCZNzQYZW4RiAP7t4Y1x2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@anandgupta42 anandgupta42 merged commit 4c7b9ac into main Mar 22, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants