Skip to content
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

Add JS and TS support to Get Github Repository Code Contents #1131

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions agixt/extensions/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ async def get_repo_code_contents(self, repo_url: str) -> str:
await self.clone_repo(repo_url)
python_files = []
powershell_files = []
js_files = []
ts_files = []
other_files = []
for root, dirs, files in os.walk(
os.path.join(os.getcwd(), "WORKSPACE", repo_name)
Expand All @@ -96,6 +98,10 @@ async def get_repo_code_contents(self, repo_url: str) -> str:
or file == "static-requirements.txt"
):
other_files.append(os.path.join(root, file))
if file.endswith(".js") or file.endswith(".jsx"):
js_files.append(os.path.join(root, file))
if file.endswith(".ts") or file.endswith(".tsx"):
ts_files.append(os.path.join(root, file))
if os.path.exists(os.path.join(os.getcwd(), "WORKSPACE", f"{repo_name}.md")):
os.remove(os.path.join(os.getcwd(), "WORKSPACE", f"{repo_name}.md"))
with open(
Expand All @@ -116,6 +122,16 @@ async def get_repo_code_contents(self, repo_url: str) -> str:
with open(file_path, "r") as python_file:
content = python_file.read()
markdown_file.write(f"```python\n{content}\n```\n\n")
for file_path in js_files:
markdown_file.write(f"**{file_path}**\n")
with open(file_path, "r") as js_file:
content = js_file.read()
markdown_file.write(f"```javascript\n{content}\n```\n\n")
for file_path in ts_files:
markdown_file.write(f"**{file_path}**\n")
with open(file_path, "r") as ts_file:
content = ts_file.read()
markdown_file.write(f"```typescript\n{content}\n```\n\n")

with open(
os.path.join(os.getcwd(), "WORKSPACE", f"{repo_name}.md"), "r"
Expand Down
2 changes: 1 addition & 1 deletion agixt/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.57
v1.4.58
Loading