aicheat 0.4.0.post1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. aicheat-0.4.0.post1/.gitignore +178 -0
  2. aicheat-0.4.0.post1/.pre-commit-config.yaml +43 -0
  3. aicheat-0.4.0.post1/AGENTS.md +58 -0
  4. aicheat-0.4.0.post1/PKG-INFO +241 -0
  5. aicheat-0.4.0.post1/README.md +208 -0
  6. aicheat-0.4.0.post1/aicheat-demo.mp4 +0 -0
  7. aicheat-0.4.0.post1/docs/providers/README.md +3 -0
  8. aicheat-0.4.0.post1/docs/providers/llamacpp.md +36 -0
  9. aicheat-0.4.0.post1/docs/providers/openai.md +24 -0
  10. aicheat-0.4.0.post1/docs/providers/vllm.md +40 -0
  11. aicheat-0.4.0.post1/pyproject.toml +71 -0
  12. aicheat-0.4.0.post1/setup.cfg +4 -0
  13. aicheat-0.4.0.post1/src/aicheat/__init__.py +7 -0
  14. aicheat-0.4.0.post1/src/aicheat/_version.py +24 -0
  15. aicheat-0.4.0.post1/src/aicheat/chat.py +1192 -0
  16. aicheat-0.4.0.post1/src/aicheat/chat_utils.py +76 -0
  17. aicheat-0.4.0.post1/src/aicheat/commands.py +975 -0
  18. aicheat-0.4.0.post1/src/aicheat/completions.py +166 -0
  19. aicheat-0.4.0.post1/src/aicheat/config.py +93 -0
  20. aicheat-0.4.0.post1/src/aicheat/keybindings.py +45 -0
  21. aicheat-0.4.0.post1/src/aicheat/logger.py +50 -0
  22. aicheat-0.4.0.post1/src/aicheat/model_utils.py +22 -0
  23. aicheat-0.4.0.post1/src/aicheat/prompts/__init__.py +22 -0
  24. aicheat-0.4.0.post1/src/aicheat/prompts/default_system_prompt.md +11 -0
  25. aicheat-0.4.0.post1/src/aicheat/py.typed +0 -0
  26. aicheat-0.4.0.post1/src/aicheat/skills.py +147 -0
  27. aicheat-0.4.0.post1/src/aicheat/tools/__init__.py +9 -0
  28. aicheat-0.4.0.post1/src/aicheat/tools/code/__init__.py +6 -0
  29. aicheat-0.4.0.post1/src/aicheat/tools/code/python.py +121 -0
  30. aicheat-0.4.0.post1/src/aicheat/tools/core.py +159 -0
  31. aicheat-0.4.0.post1/src/aicheat/tools/git.py +125 -0
  32. aicheat-0.4.0.post1/src/aicheat/tools/shell.py +340 -0
  33. aicheat-0.4.0.post1/src/aicheat/tools/web.py +129 -0
  34. aicheat-0.4.0.post1/src/aicheat/types.py +5 -0
  35. aicheat-0.4.0.post1/src/aicheat/utils.py +171 -0
  36. aicheat-0.4.0.post1/src/aicheat.egg-info/PKG-INFO +241 -0
  37. aicheat-0.4.0.post1/src/aicheat.egg-info/SOURCES.txt +41 -0
  38. aicheat-0.4.0.post1/src/aicheat.egg-info/dependency_links.txt +1 -0
  39. aicheat-0.4.0.post1/src/aicheat.egg-info/entry_points.txt +2 -0
  40. aicheat-0.4.0.post1/src/aicheat.egg-info/requires.txt +13 -0
  41. aicheat-0.4.0.post1/src/aicheat.egg-info/top_level.txt +1 -0
  42. aicheat-0.4.0.post1/tests/conftest.py +50 -0
  43. aicheat-0.4.0.post1/tests/test_skills.py +239 -0
@@ -0,0 +1,178 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
+
4
+ ### Python ###
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
165
+
166
+ ### Python Patch ###
167
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168
+ poetry.toml
169
+
170
+ # ruff
171
+ .ruff_cache/
172
+
173
+ # LSP config files
174
+ pyrightconfig.json
175
+
176
+ # End of https://www.toptal.com/developers/gitignore/api/python
177
+
178
+ src/aicheat/_version.py
@@ -0,0 +1,43 @@
1
+ default_language_version:
2
+ python: python3
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v5.0.0
6
+ hooks:
7
+ - id: check-added-large-files
8
+ - id: check-case-conflict
9
+ - id: check-docstring-first
10
+ - id: check-executables-have-shebangs
11
+ - id: check-json
12
+ - id: check-merge-conflict
13
+ args: ["--assume-in-merge"]
14
+ - id: check-toml
15
+ - id: check-yaml
16
+ - id: end-of-file-fixer
17
+ - id: mixed-line-ending
18
+ args: ["--fix=lf"]
19
+ - id: sort-simple-yaml
20
+ - id: trailing-whitespace
21
+ - repo: https://github.com/astral-sh/ruff-pre-commit
22
+ rev: "v0.11.8"
23
+ hooks:
24
+ - id: ruff
25
+ args: [--fix, --exit-non-zero-on-fix]
26
+ - id: ruff-format
27
+ - repo: https://github.com/codespell-project/codespell
28
+ rev: v2.4.1
29
+ hooks:
30
+ - id: codespell
31
+ additional_dependencies: ["tomli"]
32
+ - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
33
+ rev: v2.14.0
34
+ hooks:
35
+ - id: pretty-format-toml
36
+ args: [--autofix, --no-sort]
37
+ - id: pretty-format-yaml
38
+ args: [--autofix, --indent, "2", "--offset", "2", --preserve-quotes]
39
+ - repo: https://github.com/asottile/pyupgrade
40
+ rev: v3.15.0
41
+ hooks:
42
+ - id: pyupgrade
43
+ args: [--py38-plus]
@@ -0,0 +1,58 @@
1
+ # aicheat
2
+
3
+ `aicheat` is a python cli-based coding assistant.
4
+
5
+ ## Features
6
+
7
+ - Uses `prompt-toolkit` for input, leveraging its powerful line-editing capabilities
8
+ - Theming support using `pygments`
9
+ - Live streaming of model output using `rich.live.Live`
10
+ - Tool calling capabilities
11
+ - `AGENTS.md`/`CLAUDE.md` file support
12
+ - Skills support
13
+
14
+ ## Installation
15
+
16
+ The package can be installed in editable mode.
17
+
18
+ ```bash
19
+ uv pip install -e '.[dev]'
20
+ ```
21
+
22
+ This will install the `aicheat` entrypoint script and make changes immediately available after modifying the code.
23
+
24
+ ## Development
25
+
26
+ - New commands can be defined as functions in the `aicheat.commands` module, these should be registered using the `aicheat.commands.command_handler` decorator
27
+ - New tools can be defined as submodules in the `aicheat.tools` module. New tools:
28
+ - Have to be registered using the `aicheat.tools.core.tool` decorator, which registers tools in the registry (`aicheat.tools.registry`)
29
+ - Registered (and enabled) tools are made available to the model on every call
30
+ - `aicheat.tools.get_tools` can be used to retrieve enabled tools
31
+ - Tools can be enabled enabled/disabled at runtime by users by setting the `enabled` attribute
32
+ - Tools/tools modules are automatically loaded from `aicheat.tools` submodules, the mechanism used to accomplish this is `aicheat.utils._init_submodules`, which needs to be invoked in every module's, see `aicheat.code`'s `__init__.py` for an example.
33
+
34
+ ## Tests
35
+
36
+ A minimal set of tests is defined in the `tests` directory. These use `pytest` and can be run like so:
37
+
38
+ ```bash
39
+ pytest tests
40
+ # Select tests using: -k
41
+ pytest tests -k test_skills # runs all the skills tests
42
+ pytest tests/test_skills.py # run the full skills test module
43
+ ```
44
+
45
+ New features should implement unit tests and integrations tests, when possible.
46
+
47
+ ## Release Process
48
+
49
+ To create release notes for a new version:
50
+
51
+ 1. Check what commits have been added since the last release using the `git_updates` tool
52
+ 2. Examine specific commits with `git show COMMIT_HASH` to understand the changes
53
+ 3. Review previous release notes format by checking the annotated tag with `git show LAST_VERSION`
54
+ 4. Create release notes following the established format (New, Fixes, Misc sections as appropriate)
55
+ 5. Save the release notes in a file named after the version (e.g., `v0.2.3.md`)
56
+ 6. Create a new annotated tag with `git tag -a v0.2.3 -m "$(cat v0.2.3.md)"`
57
+
58
+ This process ensures consistent documentation of changes and follows the project's established conventions.
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: aicheat
3
+ Version: 0.4.0.post1
4
+ Summary: A CLI programming assistant for computer-science tasks
5
+ Author-email: brethil <bretello@distruzione.org>
6
+ License: GPLv3
7
+ Keywords: ai,cli,coding-assistant,llm,developer-tools
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Software Development
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Utilities
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: openai>=2.0.0
22
+ Requires-Dist: rich>=13.0.0
23
+ Requires-Dist: prompt_toolkit>=3.0.0
24
+ Requires-Dist: httpx>=0.25.0
25
+ Requires-Dist: pygments>=2.16.0
26
+ Requires-Dist: tomlkit>=0.14.0
27
+ Requires-Dist: pygit2>=1.19.1
28
+ Requires-Dist: pyyaml>=6
29
+ Provides-Extra: dev
30
+ Requires-Dist: ruff>=0.15.4; extra == "dev"
31
+ Requires-Dist: typing-extensions>=4.0.0; extra == "dev"
32
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
33
+
34
+ # aicheat
35
+
36
+ A command-line based AI coding assistant
37
+
38
+ [![demo](aicheat-demo.mp4)](https://asciinema.org/a/1vcAJJKvLWtSu6Ni)
39
+
40
+ ## Features
41
+
42
+ - Supports OpenAI-compatible inference servers (such as vLLM/llama.cpp/OpenAI, ...)
43
+ - Powerful line editing/completion capabilities thanks to [`prompt-toolkit`](https://github.com/prompt-toolkit/python-prompt-toolkit)
44
+ - Theming support using `pygments`
45
+ - Extensibility via custom tool definitions
46
+ - Skills support
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # Install a stable version
52
+ uv pip install git+https://git.decapod.one/brethil/aicheat@v0.4.0
53
+
54
+ # Install the latest main
55
+ uv pip install git+https://git.decapod.one/brethil/aicheat@main
56
+
57
+ # Install the latest dev
58
+ uv pip install git+https://git.decapod.one/brethil/aicheat@dev
59
+
60
+ # Clone and install (development)
61
+ git clone https://git.decapod.one/brethil/aicheat
62
+ uv pip install -e ".[dev]"
63
+ ```
64
+
65
+ ## Quick Start
66
+
67
+ - `AICHEAT_HOST`: path to an OpenAI-compatible server, such as [vllm](https://github.com/vllm-project/vllm), or [llama.cpp](https://github.com/ggerganov/llama.cpp), see instructions in [docs](docs/)
68
+ - `OPENAI_API_KEY`: (optional) set if API Key is required to connect to `AICHEAT_HOST`
69
+ - `AICHEAT_MODEL`: (optional) set default model. If a single model is available on `AICHEAT_HOST`, it is automatically selected. If multiple models are available, user is prompted to select the model.
70
+
71
+ Note: this should also work with the official OpenAI API, although this is untested.
72
+
73
+ Start chatting:
74
+
75
+ ```bash
76
+ aicheat
77
+
78
+ # Optionally, a starting message can be provided:
79
+ aicheat "What's the current status of this git repo?"
80
+
81
+ # optional: select a model
82
+ export AICHEAT_MODEL="your-model-name"
83
+ ```
84
+
85
+ In the `aicheat` "REPL":
86
+
87
+ - Type `/help` for available commands
88
+ - Type `/tools` to see available tools
89
+ - Use `/theme list` to list/select available themes, using `/config save` to persist the theme choice.
90
+ - Prefix messages with `!` to run a shell command, e.g. `!uptime` calls `uptime`.
91
+ - Type a question to start chatting
92
+
93
+ ## Provider Documentation
94
+
95
+ See [docs/providers/](docs/providers/) for detailed instructions on using aicheat with different OpenAI-compatible API providers:
96
+
97
+ - [OpenAI API](docs/providers/openai.md)
98
+ - [vLLM](docs/providers/vllm.md)
99
+ - [llama.cpp](docs/providers/llamacpp.md)
100
+ - [Local providers (Ollama, LM Studio, etc.)](docs/providers/local.md)
101
+
102
+ ## Usage Examples
103
+
104
+ ### Basic Usage
105
+
106
+ ```bash
107
+ # Start a chat session
108
+ aicheat
109
+
110
+ # Start with an initial prompt
111
+ aicheat "What's the status of this git repo?"
112
+
113
+ aicheat
114
+ ```
115
+
116
+ ### In-Chat Commands
117
+
118
+ Once in the chat, you can use these commands:
119
+
120
+ - `/help` - List available commands
121
+ - `/tools` - List available tools
122
+ - `/clear` - Clear the conversation history (or hit ctrl-c twice)
123
+ - `/multiline` - Toggle multiline input mode, also see Editor/Multiline section below
124
+ - `/model` - Show/set the active model
125
+ - `/fragment <file> [prompt]` - Include a file in the session with optional instructions
126
+
127
+ ## Tool Calling
128
+
129
+ aicheat comes with several built-in tools
130
+
131
+ ### File Operations
132
+
133
+ - `read_file(filename)` - Read the content of a file
134
+ - `write_file(filename, content)` - Write content to a file
135
+ - `apply_patch(filename, content)` - Patch a file
136
+ - `search(pattern, path)` - Search for patterns in files using ripgrep
137
+
138
+ ### System & Shell
139
+
140
+ - `execute_shell_command(cmd)` - Execute shell commands (with confirmation)
141
+ - `man(program_name)` - Retrieve man pages for programs
142
+ - `pwd()` - Get current working directory
143
+ - `cd(path)` - Change directory
144
+
145
+ ### Git Integration
146
+
147
+ - `git_status()` - Show git status as a diff
148
+ - `git_updates(from_refish)` - Show commits since last tag/release
149
+ - `git_show_patch(commit_id)` - Show patch for a specific commit
150
+ - `git_list_files()` - List all git-tracked files
151
+
152
+ ### Code Execution
153
+
154
+ - `execute_python_code(code)` - Execute Python code snippets (with confirmation)
155
+
156
+ ### Web & Documentation
157
+
158
+ - `cheat_sh_search(program_name)` - Search cheat.sh for program documentation
159
+
160
+ ## Adding Custom Tools
161
+
162
+ You can extend aicheat with custom tools by creating new modules in `src/aicheat/tools/`.
163
+
164
+ Here's an example for a `ping` tool to check network status:
165
+
166
+ ```python
167
+ from aicheat.tools.core import tool
168
+ from subprocess import check_output, CalledProcessError, STDOUT
169
+ import re
170
+
171
+
172
+ @tool(
173
+ message_template="🌐 Pinging {host} {count} times}"
174
+ requires_confirmation=False,
175
+ )
176
+ def ping(host: str, count: int) -> str:
177
+ """Pings a host using the unix `ping` tool"""
178
+ if not host:
179
+ return "No host provided"
180
+
181
+ try:
182
+ result = check_output(
183
+ ["ping", "-c", str(count), host],
184
+ text=True,
185
+ stderr=STDOUT, # redirect stderr to stdout
186
+ )
187
+ except CalledProcessError as exc:
188
+ result = f"ping failed with returncode={exc.returncode}\noutput:\n{exc.stdout}"
189
+
190
+ return result
191
+ ```
192
+
193
+ Note: `@tool()` must always be called with parentheses.
194
+
195
+ For more examples, see:
196
+
197
+ - `aicheat.tools.shell` - Shell-related tools
198
+ - `aicheat.tools.git` - Git-related tools
199
+ - `aicheat.tools.code.python` - Python-related code tools
200
+
201
+ ## Tips & Tricks
202
+
203
+ ### Shell Integration
204
+
205
+ Add an alias to `aicheat` so that it's prefixed by noglob, making it easier to give initial prompts from the shell without expanding globs:
206
+
207
+ ```bash
208
+ echo "alias aicheat=\"noglob aicheat\"" >> ~/.zshrc
209
+ ```
210
+
211
+ ### Editor/Multiline
212
+
213
+ The REPL uses `prompt-toolkit` to leverage its powerful line-editing capabilities. `aicheat`, depending on your `$EDITOR` value supports:
214
+
215
+ - emacs-style line-editing shortcuts:
216
+ - use `ctrl-x ctrl-e` to open the current line in your `$EDITOR`)
217
+ - ctrl-a/ctrl-e to move to beginning/end of the current line and other emacs-style movements
218
+ - vi-style line-editing shortcuts:
219
+ - `vv` to open the current line in your `$EDITOR`
220
+ - modal editing and other vi-style movement shortcuts
221
+
222
+ Multiline editing is also supported, either via `/multiline` or via `ctrl-v`. This can be useful to paste text/code.
223
+
224
+ ## Requirements
225
+
226
+ - Python 3.8+
227
+ - An OpenAI-compatible API server (like vLLM or llama.cpp)
228
+ - [`ripgrep`](https://github.com/BurntSushi/ripgrep) (optional, for improved search functionality)
229
+ - `cht.sh` CLI tool (optional, for [cheat.sh](https://cheat.sh) functionality)
230
+
231
+ ## License
232
+
233
+ # MIT
234
+
235
+ - `aicheat.tools.shell` shell-related tools
236
+ - `aicheat.tools.git` git-related tools
237
+ - `aicheat.tools.code.python` python-related code tools
238
+
239
+ ## Skills
240
+
241
+ Load skills using `/skill load path/to/skill`