v2 version of plugin-shell#1
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis update refactors the shell plugin to enhance security, modularity, and documentation. It introduces stricter environment-based configuration, a new shell service with per-conversation history and file operation tracking, and robust command/path validation utilities. The plugin’s actions and providers are reorganized, new tests are added, and all documentation is thoroughly rewritten for clarity and safety. Legacy code, tests, and providers are removed. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Action (executeCommand)
participant ShellService
participant PathUtils
participant Runtime
participant Provider (shellHistoryProvider)
User->>Action (executeCommand): Sends message with shell request
Action (executeCommand)->>PathUtils: Validate command safety
PathUtils-->>Action (executeCommand): Result (safe/unsafe)
Action (executeCommand)->>ShellService: Execute command (if safe)
ShellService->>PathUtils: Validate path/command
PathUtils-->>ShellService: Path/command validation result
ShellService->>ShellService: Run command (enforce timeout, restrict dir)
ShellService->>ShellService: Detect file operations
ShellService-->>Action (executeCommand): Command result (stdout, stderr, etc.)
Action (executeCommand)-->>User: Respond with output/result
User->>Provider (shellHistoryProvider): Requests shell history/context
Provider (shellHistoryProvider)->>ShellService: Get history, cwd, file ops
ShellService-->>Provider (shellHistoryProvider): History, cwd, file ops
Provider (shellHistoryProvider)-->>User: Structured history/context
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (30)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Overview
This PR enhances
@elizaos/plugin-shell(v2) with the most useful features from the original shell plugin while maintaining its superior security model. The plugin now provides a complete shell execution solution with history tracking, context awareness, and comprehensive file operation monitoring.🎯 Why These Changes?
After comparing both shell plugins, we identified that while v2 had better security and cross-platform support, it lacked some powerful features from v1:
This PR brings these features to v2 while maintaining its security-first design.
✨ New Features
1. Command History Tracking
2. Shell History Provider
SHELL_HISTORYprovider exposes command history to agent context3. File Operation Detection
Automatically detects and tracks common file operations:
touch,echo >)echo >,cat >)cat)mkdir)mv)cp)4. Clear History Action
CLEAR_SHELL_HISTORYaction for privacy control🔒 Security Maintained
All enhancements were implemented without compromising the existing security model:
📝 Code Changes
Modified Files:
src/services/shellService.ts- Added history tracking and file operation detectionsrc/actions/executeCommand.ts- Added conversation ID trackingsrc/index.ts- Added provider and new action to plugin exportspackage.json- Version bump to 0.2.0README.md- Complete rewrite following Twitter plugin formatNew Files:
src/providers/shellHistoryProvider.ts- Provides shell context to agentsrc/actions/clearHistory.ts- Clear history actionsrc/__tests__/shellHistory.test.ts- Comprehensive history testsCHANGELOG.md- Detailed changelog💡 Usage Examples
Basic Usage
History Context
The agent now maintains context between commands:
🧪 Testing
# All tests passing ✓ src/__tests__/pathUtils.test.ts (12) ✓ src/__tests__/shellHistory.test.ts (5) Test Files 2 passed (2) Tests 17 passed (17)📊 Migration Benefits
Users migrating from v1 to v2 now get:
🔄 Breaking Changes
None! This is a backward-compatible enhancement. Existing users of v2 will get new features without any code changes.
📚 Documentation
bun🚀 Future Opportunities
While maintaining the security model, future enhancements could include:
✅ Checklist
📸 Before/After Comparison
Before (v0.1.0):
After (v0.2.0):
This enhancement makes
@elizaos/plugin-shellthe clear choice for production environments that need both security and functionality. The plugin now combines v2's robust security model with v1's powerful features!You can copy this entire content and use it as your PR description when submitting the enhanced plugin-shell-v2 changes!
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor
Tests
Chores