-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Patch scripts + first patch (#6) #2150
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Ran Prettier on all files - https://github.com/RooVetGit/Roo-Code/pull/404 | ||
| # Ran Prettier on all files - https://github.com/RooVetGit/Rootastic/pull/404 | ||
| 60a0a824b96a0b326af4d8871b6903f4ddcfe114 | ||
| 579bdd9dbf6d2d569e5e7adb5ff6292b1e42ea34 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| npm run build && code --install-extension bin/rootastic-*.vsix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import os | ||
| import re | ||
|
|
||
|
|
||
|
|
||
| replacements = [ | ||
| # { | ||
| # "start_marker": "CAPABILITIES\n\n", | ||
| # "new_content": """ | ||
| # Test 1 | ||
| # """ | ||
| # }, | ||
| # { | ||
| # "start_marker": "USER'S CUSTOM INSTRUCTIONS\n\n", | ||
| # "new_content": """ | ||
| # Test 2 | ||
| # """ | ||
| # }, | ||
| # # Add more sections here if desired | ||
| ] | ||
|
|
||
| def replace_section(text, start_marker, new_content): | ||
| pattern = rf"({re.escape(start_marker)})(.*?)(?=(?:\n|\`|\')\s*:\s*\"\"|$)" | ||
| return re.sub(pattern, rf"\1{new_content}", text, flags=re.DOTALL) | ||
|
|
||
| def patch_instructions(base_directory): | ||
|
|
||
| if base_directory == "": | ||
| base_directory = os.getcwd() | ||
|
|
||
| for root, dirs, files in os.walk(base_directory): | ||
| for filename in files: | ||
| if filename.endswith(".ts"): | ||
| filepath = os.path.join(root, filename) | ||
| with open(filepath, "r", encoding="utf-8") as f: | ||
| original_text = f.read() | ||
|
|
||
| new_text = original_text | ||
| for rep in replacements: | ||
| new_text = replace_section( | ||
| new_text, | ||
| rep["start_marker"], | ||
| rep["new_content"], | ||
| ) | ||
|
|
||
| if new_text != original_text: | ||
| with open(filepath, "w", encoding="utf-8") as f: | ||
| f.write(new_text) | ||
| print(f"Patched: {filepath}") | ||
|
|
||
| def patch_name(base_directory): | ||
| if base_directory == "": | ||
| base_directory = os.getcwd() | ||
|
|
||
| for root, dirs, files in os.walk(base_directory): | ||
| for filename in files: | ||
| filepath = os.path.join(root, filename) | ||
| if os.path.isfile(filepath): | ||
| try: | ||
| with open(filepath, 'r', encoding='utf-8') as f: | ||
| content = f.read() | ||
|
|
||
| new_content = re.sub(r'(?i)roo-?code', lambda m: 'rootastic' if m.group().islower() else 'Rootastic', content) | ||
|
|
||
| if new_content != content: | ||
| with open(filepath, 'w', encoding='utf-8') as f: | ||
| f.write(new_content) | ||
| print(f"Renamed Rootastic references in: {filepath}") | ||
| except UnicodeDecodeError: | ||
| # Skip binary files and files with non-UTF-8 encoding | ||
| continue | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Adjust the path if necessary | ||
| patch_dir = "src/core/prompts/sections" | ||
| patch_instructions(patch_dir) | ||
| patch_name("") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| set -e # exit immediately if a command exits with a non-zero status | ||
|
|
||
| # Step 1: Fetch and merge upstream changes from the master/main branch | ||
| git fetch upstream | ||
| git checkout main | ||
| git merge upstream/main | ||
|
|
||
| # Step 2: Apply the custom patch | ||
| if git apply --check myCustom.patch; then | ||
| git apply myCustom.patch | ||
| echo "Custom patch applied successfully." | ||
| else | ||
| echo "Error: Patch did not apply cleanly. Please resolve conflicts manually." | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Consider adding unit tests for the patch functions (like
replace_section) to ensure that the regex-based replacements work as intended. This will help catch any subtle issues with the patching logic.