Skip to content

interactive creation for allowed commands with execute_bash #2487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

omansour
Copy link

@omansour omansour commented Aug 4, 2025

SCR-20250806-leqh SCR-20250806-mcxs

Description of changes:

  • offer the user to save a pattern or the exact command when prompted for allowing a command
  • remove the 't' option from the option list when using execute_bash (which could led to unwanted further commands execution) (tbd)
  • if using an agent, commands are saved on the disk using the agent config file. (tbd)

related to

#1260 [RFC] Extra-granular Tool Permissions

#2483 Regex-formatted allowed commands for execute_bash tool

why ?

  • defined allowed commands on the fly
  • it's painful to exit q cli and restart it after adding a new command

See the video for a short demo.

Screen.Recording.2025-08-05.at.11.19.11_2.mov

I will be more than happy to discuss about this feature and adapt the functionalities if needed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@omansour omansour changed the title Add interactive 'a' option for execute tools with 4-option menu to cr… Pattern management and interactive creation for allowed commands with execute_bash Aug 4, 2025
…eate

allowed command patterns. Patterns are immediately saved to disk
if you use an agent.

in /tools, display the allowed commands
@omansour omansour force-pushed the trusted-commands-extension2 branch from 4744658 to 826db79 Compare August 5, 2025 08:23
@omansour omansour changed the title Pattern management and interactive creation for allowed commands with execute_bash interactive creation for allowed commands with execute_bash Aug 5, 2025
- Update interactive 'a' option to generate regex patterns instead of glob patterns
- Fix pattern generation for option 1: use regex::escape() for exact commands
- Fix pattern generation for option 2: use 'command\s.*' to match 'command ' + anything (but not command alone)
- Remove glob-based pattern matching code that conflicted with main branch's regex approach
- Update unit tests to reflect regex pattern behavior
- Fix bug where commands like 'git log -1' weren't matching the allowed pattern

Key changes:
- Option 1 now generates: 'touch\ test\.txt' (escaped exact match)
- Option 2 now generates: 'git\s.*' (matches 'git ' + anything, not 'git' alone)
- Maintains compatibility with main branch's regex-based allowedCommands system
- All tests passing with proper regex pattern validation

Fixes issue where interactive menu generated incompatible glob patterns
instead of the expected regex patterns used by the main branch.
@omansour omansour force-pushed the trusted-commands-extension2 branch from 9eecb1e to 6e17850 Compare August 5, 2025 09:35
@omansour omansour marked this pull request as ready for review August 5, 2025 09:35
- Format crates/chat-cli/src/cli/chat/mod.rs
- Format crates/chat-cli/src/cli/chat/tools/execute/mod.rs

This ensures the code follows the project's formatting standards
and should make the GitHub Action 'Fmt' check pass.
@omansour omansour marked this pull request as draft August 6, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant