git: eeff19a86cb7 - main - misc/py-aider-chat: new port - AI pair programming in your terminal

From: Dave Cottlehuber <dch_at_FreeBSD.org>
Date: Wed, 22 May 2024 17:12:07 UTC
The branch main has been updated by dch:

URL: https://cgit.FreeBSD.org/ports/commit/?id=eeff19a86cb78d6cd5f24472a27c9569e31f1bb0

commit eeff19a86cb78d6cd5f24472a27c9569e31f1bb0
Author:     Dave Cottlehuber <dch@FreeBSD.org>
AuthorDate: 2024-05-22 14:44:29 +0000
Commit:     Dave Cottlehuber <dch@FreeBSD.org>
CommitDate: 2024-05-22 17:11:40 +0000

    misc/py-aider-chat: new port - AI pair programming in your terminal
    
    Sponsored by:   SkunkWerks, GmbH
---
 misc/Makefile                                  |  1 +
 misc/py-aider-chat/Makefile                    | 64 +++++++++++++++++++++
 misc/py-aider-chat/distinfo                    |  3 +
 misc/py-aider-chat/files/patch-aider_scrape.py | 77 ++++++++++++++++++++++++++
 misc/py-aider-chat/pkg-descr                   |  7 +++
 5 files changed, 152 insertions(+)

diff --git a/misc/Makefile b/misc/Makefile
index 746c8d91b560..854115f19acf 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -403,6 +403,7 @@
     SUBDIR += py-SimpleSoapy
     SUBDIR += py-SoapySDR
     SUBDIR += py-accelerate
+    SUBDIR += py-aider-chat
     SUBDIR += py-alive-progress
     SUBDIR += py-anthropic
     SUBDIR += py-apache-beam
diff --git a/misc/py-aider-chat/Makefile b/misc/py-aider-chat/Makefile
new file mode 100644
index 000000000000..7ad42ea7a540
--- /dev/null
+++ b/misc/py-aider-chat/Makefile
@@ -0,0 +1,64 @@
+PORTNAME=	aider_chat
+DISTVERSION=	0.35.0
+CATEGORIES=	misc python
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+DISTNAME=	aider_chat-${PORTVERSION}
+
+MAINTAINER=	dch@FreeBSD.org
+COMMENT=	AI pair programming in your terminal
+WWW=		https://aider.chat/
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE.txt
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools>=0:devel/py-setuptools@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}arrow>0:devel/py-arrow@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}backoff>0:devel/py-backoff@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}beautifulsoup>=0:www/py-beautifulsoup@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}cachetools>0:devel/py-cachetools@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}configargparse>0:devel/py-configargparse@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}diff-match-patch>=0:textproc/py-diff-match-patch@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}diskcache>=0:devel/py-diskcache@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}flake8>0:devel/py-flake8@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}gitpython>0:devel/py-gitpython@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}greenlet>=0:devel/py-greenlet@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}grep-ast>0:textproc/py-grep-ast@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}huggingface-hub>0:misc/py-huggingface-hub@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}jsonschema>=0:devel/py-jsonschema@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}litellm>=1.24.5:misc/py-litellm@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}networkx>0:math/py-networkx@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}numpy>=0,1:math/py-numpy@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}openai>=1.0.0:misc/py-openai@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pathspec>0:devel/py-pathspec@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pillow>0:graphics/py-pillow@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}prompt-toolkit>0:devel/py-prompt-toolkit@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pypandoc>=0:textproc/py-pypandoc@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pyyaml-include>=1.2:devel/py-pyyaml-include@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}rich>0:textproc/py-rich@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}scipy>0:science/py-scipy@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sounddevice>=0:audio/py-sounddevice@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}SoundFile>=0.12.1:audio/py-SoundFile@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}streamlit>0:www/py-streamlit@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tiktoken>=0.7.0:textproc/py-tiktoken@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tokenizers>0:textproc/py-tokenizers@${PY_FLAVOR}
+# missing
+# playwright
+# pypandoc
+# google-generativeai
+USES=		python shebangfix
+USE_PYTHON=	autoplist concurrent distutils
+
+NO_ARCH=	yes
+
+PORTDOCS=	README.md
+
+OPTIONS_DEFINE=	DOCS
+
+post-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_MAN} ${PORTDOCS:S|^|${WRKSRC}/|} \
+		${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/misc/py-aider-chat/distinfo b/misc/py-aider-chat/distinfo
new file mode 100644
index 000000000000..a2576e44b6c7
--- /dev/null
+++ b/misc/py-aider-chat/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1716356303
+SHA256 (aider_chat-0.35.0.tar.gz) = a2d5471f5648281fb89f65b2d38f4b3affbca5240a7b5be8c8afac460f4793ca
+SIZE (aider_chat-0.35.0.tar.gz) = 113504
diff --git a/misc/py-aider-chat/files/patch-aider_scrape.py b/misc/py-aider-chat/files/patch-aider_scrape.py
new file mode 100644
index 000000000000..5f93628d7a07
--- /dev/null
+++ b/misc/py-aider-chat/files/patch-aider_scrape.py
@@ -0,0 +1,77 @@
+--- aider/scrape.py.orig	2024-05-13 18:19:39 UTC
++++ aider/scrape.py
+@@ -6,7 +6,6 @@ from bs4 import BeautifulSoup
+ import httpx
+ import pypandoc
+ from bs4 import BeautifulSoup
+-from playwright.sync_api import sync_playwright
+ 
+ from aider import __version__
+ 
+@@ -42,14 +41,11 @@ class Scraper:
+         """
+         Scrape a url and turn it into readable markdown.
+ 
+-        `url` - the URLto scrape.
++        `url` - the URL to scrape.
+         """
+         self.try_playwright()
+ 
+-        if self.playwright_available:
+-            content = self.scrape_with_playwright(url)
+-        else:
+-            content = self.scrape_with_httpx(url)
++        content = self.scrape_with_httpx(url)
+ 
+         if not content:
+             return
+@@ -62,49 +58,6 @@ class Scraper:
+         return content
+ 
+     # Internals...
+-    def scrape_with_playwright(self, url):
+-        with sync_playwright() as p:
+-            try:
+-                browser = p.chromium.launch()
+-            except Exception as e:
+-                self.playwright_available = False
+-                self.print_error(e)
+-                return
+-
+-            page = browser.new_page()
+-
+-            user_agent = page.evaluate("navigator.userAgent")
+-            user_agent = user_agent.replace("Headless", "")
+-            user_agent = user_agent.replace("headless", "")
+-            user_agent += " " + aider_user_agent
+-
+-            page = browser.new_page(user_agent=user_agent)
+-            page.goto(url)
+-            content = page.content()
+-            browser.close()
+-
+-        return content
+-
+-    def try_playwright(self):
+-        if self.playwright_available is not None:
+-            return
+-
+-        with sync_playwright() as p:
+-            try:
+-                p.chromium.launch()
+-                self.playwright_available = True
+-            except Exception:
+-                self.playwright_available = False
+-
+-    def get_playwright_instructions(self):
+-        if self.playwright_available in (True, None):
+-            return
+-        if self.playwright_instructions_shown:
+-            return
+-
+-        self.playwright_instructions_shown = True
+-        return PLAYWRIGHT_INFO
+-
+     def scrape_with_httpx(self, url):
+         headers = {"User-Agent": f"Mozilla./5.0 ({aider_user_agent})"}
+         try:
diff --git a/misc/py-aider-chat/pkg-descr b/misc/py-aider-chat/pkg-descr
new file mode 100644
index 000000000000..0c86531a716e
--- /dev/null
+++ b/misc/py-aider-chat/pkg-descr
@@ -0,0 +1,7 @@
+Aider is a command line tool that lets you pair program with LLMs, to edit
+code stored in your local git repository. Aider will directly edit the
+code in your local source files, and git commit the changes with sensible
+commit messages. You can start a new project or work with an existing git
+repo. Aider is unique in that it lets you ask for changes to pre-existing,
+larger codebases. Aider works well with GPT-4o, Claude 3 Opus, GPT-3.5 and
+supports connecting to almost any LLM.