From dd4c5db3530349cea1c29675fc64a233c96c0d5c Mon Sep 17 00:00:00 2001 From: Josh XT Date: Wed, 6 Mar 2024 15:20:54 -0500 Subject: [PATCH] Add js and ts support to Get Code --- agixt/extensions/github.py | 16 ++++++++++++++++ agixt/version | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/agixt/extensions/github.py b/agixt/extensions/github.py index 46d9997b0deb..cb4f03162df3 100644 --- a/agixt/extensions/github.py +++ b/agixt/extensions/github.py @@ -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) @@ -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( @@ -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" diff --git a/agixt/version b/agixt/version index 7dcad9d52afb..9cfd238b8620 100644 --- a/agixt/version +++ b/agixt/version @@ -1 +1 @@ -v1.4.57 \ No newline at end of file +v1.4.58 \ No newline at end of file