From 44784f46ed2b34abeee3d4f29e4c90fa9e92929e Mon Sep 17 00:00:00 2001 From: dougollerenshaw Date: Thu, 19 Sep 2024 13:59:09 -0700 Subject: [PATCH 1/2] Changes to control versioning --- .bumpversion.cfg | 12 ++++++++ .github/workflows/bump_version.yml | 47 ++++++++++++++++++++++++++++++ README.md | 23 ++++++++------- codeaide.py | 28 +----------------- codeaide/__main__.py | 30 +++++++++++++++++++ requirements.txt | 1 + setup.py | 30 +++++++++++++++++++ version.py | 2 ++ 8 files changed, 135 insertions(+), 38 deletions(-) create mode 100644 .bumpversion.cfg create mode 100644 .github/workflows/bump_version.yml create mode 100644 codeaide/__main__.py create mode 100644 setup.py create mode 100644 version.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..df88fba --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,12 @@ +[bumpversion] +current_version = 0.1.0 +commit = True +tag = True + +[bumpversion:file:version.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bumpversion:file:setup.py] +search = version="{current_version}" +replace = version="{new_version}" \ No newline at end of file diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml new file mode 100644 index 0000000..6c0c063 --- /dev/null +++ b/.github/workflows/bump_version.yml @@ -0,0 +1,47 @@ +name: Bump version + +on: + push: + branches: + - main + +jobs: + bump-version: + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + name: "Bump version and create changelog with commitizen" + steps: + - name: Check out + uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install commitizen + run: pip install commitizen + + - name: Bump version + id: cz + run: | + if git log -1 --pretty=%B | grep -qE '^(feat|fix|BREAKING CHANGE):|#(minor|major)'; then + cz bump --yes + else + cz bump --increment PATCH --yes + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + tags: true + + - name: Print Version + run: echo "Bumped to version ${{ steps.cz.outputs.version }}" \ No newline at end of file diff --git a/README.md b/README.md index 7f9375e..7ab1220 100644 --- a/README.md +++ b/README.md @@ -53,17 +53,6 @@ https://github.com/user-attachments/assets/8aa729ff-c431-4a61-a9ef-d17050a27d02 ## Usage -To test the API connection, run: - -``` -python codeaide.py test -``` -This will send a simple "Hi Claude, are we communicating?" prompt to the API. If your API key is set up properly and you have an internet connection, you'll see a response at the command line that looks something like this: -``` -Connection successful! -Claude says: Yes, we are communicating! I'm Claude, an AI assistant. How can I help you today? -``` - To start CodeAIde for actual code generation, run: ``` @@ -79,6 +68,18 @@ Follow the prompts to interact with the AI assistant. You can: - Copy the code to your clipboard or save it as a standalone file - Select and re-run any previous version of the code form the current conversation. + +To test the API connection, run: + +``` +python codeaide.py test +``` +This will send a simple "Hi Claude, are we communicating?" prompt to the API. If your API key is set up properly and you have an internet connection, you'll see a response at the command line that looks something like this: +``` +Connection successful! +Claude says: Yes, we are communicating! I'm Claude, an AI assistant. How can I help you today? +``` + ## Future feature roadmap The following features do not currently exist, but adding them in the future would make this project more useful: diff --git a/codeaide.py b/codeaide.py index c113c42..71d6544 100644 --- a/codeaide.py +++ b/codeaide.py @@ -1,30 +1,4 @@ -import sys - -from PyQt5.QtWidgets import QApplication - -from codeaide.logic.chat_handler import ChatHandler -from codeaide.ui.chat_window import ChatWindow -from codeaide.utils import api_utils - - -def main(): - chat_handler = ChatHandler() - - if len(sys.argv) > 1 and sys.argv[1] == "test": - success, message = chat_handler.check_api_connection() - success, message = api_utils.test_api_connection() - if success: - print("Connection successful!") - print("Claude says:", message) - else: - print("Connection failed.") - print("Error:", message) - else: - app = QApplication(sys.argv) - chat_window = ChatWindow(chat_handler) - chat_window.show() - sys.exit(app.exec_()) - +from codeaide.__main__ import main if __name__ == "__main__": main() diff --git a/codeaide/__main__.py b/codeaide/__main__.py new file mode 100644 index 0000000..c113c42 --- /dev/null +++ b/codeaide/__main__.py @@ -0,0 +1,30 @@ +import sys + +from PyQt5.QtWidgets import QApplication + +from codeaide.logic.chat_handler import ChatHandler +from codeaide.ui.chat_window import ChatWindow +from codeaide.utils import api_utils + + +def main(): + chat_handler = ChatHandler() + + if len(sys.argv) > 1 and sys.argv[1] == "test": + success, message = chat_handler.check_api_connection() + success, message = api_utils.test_api_connection() + if success: + print("Connection successful!") + print("Claude says:", message) + else: + print("Connection failed.") + print("Error:", message) + else: + app = QApplication(sys.argv) + chat_window = ChatWindow(chat_handler) + chat_window.show() + sys.exit(app.exec_()) + + +if __name__ == "__main__": + main() diff --git a/requirements.txt b/requirements.txt index c35bb96..be4f3c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ black isort pre-commit pyqt5 +bump2version \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..77f1ef0 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +from setuptools import setup, find_packages +from version import __version__ + +# Read requirements from requirements.txt +with open("requirements.txt") as f: + requirements = f.read().splitlines() + +setup( + name="codeaide", + version=__version__, + packages=find_packages(), + install_requires=requirements, + entry_points={ + "console_scripts": [ + "codeaide=codeaide.__main__:main", + ], + }, + author="Doug Ollerenshaw", + author_email="d.ollerenshaw@gmail.com", + description="A chat application leveraging large language models (LLMs) for code generation and execution", + long_description=open("README.md").read(), + long_description_content_type="text/markdown", + url="https://github.com/dougollerenshaw/CodeAIde", + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires=">=3.8", +) diff --git a/version.py b/version.py new file mode 100644 index 0000000..5c21c2b --- /dev/null +++ b/version.py @@ -0,0 +1,2 @@ +# version.py +__version__ = "0.1.0" From 0820bd47bc05193e1aae97e24fac3a9eddb77189 Mon Sep 17 00:00:00 2001 From: dougollerenshaw Date: Thu, 19 Sep 2024 14:00:53 -0700 Subject: [PATCH 2/2] Updated bump_version.yml action --- .github/workflows/bump_version.yml | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 6c0c063..fca8751 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -1,15 +1,58 @@ -name: Bump version +name: Version Management on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] push: branches: - main jobs: + preview-bump: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + name: "Preview version bump" + steps: + - name: Check out + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install commitizen + run: pip install commitizen + + - name: Preview version bump + id: preview + run: | + if git log -1 --pretty=%B | grep -qE '^(feat|fix|BREAKING CHANGE):|#(minor|major)'; then + NEW_VERSION=$(cz bump --dry-run) + else + NEW_VERSION=$(cz bump --increment PATCH --dry-run) + fi + echo "New version would be: $NEW_VERSION" + echo "::set-output name=new_version::$NEW_VERSION" + + - name: Comment PR + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.name, + body: 'When merged, this PR will bump the version to: ${{ steps.preview.outputs.new_version }}' + }) + bump-version: - if: "!startsWith(github.event.head_commit.message, 'bump:')" + if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest - name: "Bump version and create changelog with commitizen" + name: "Bump version and create changelog" steps: - name: Check out uses: actions/checkout@v2