patchllm 0.2.2__py3-none-any.whl → 1.0.0__py3-none-any.whl

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 (54) hide show
  1. patchllm/__main__.py +0 -0
  2. patchllm/agent/__init__.py +0 -0
  3. patchllm/agent/actions.py +73 -0
  4. patchllm/agent/executor.py +57 -0
  5. patchllm/agent/planner.py +76 -0
  6. patchllm/agent/session.py +425 -0
  7. patchllm/cli/__init__.py +0 -0
  8. patchllm/cli/entrypoint.py +120 -0
  9. patchllm/cli/handlers.py +192 -0
  10. patchllm/cli/helpers.py +72 -0
  11. patchllm/interactive/__init__.py +0 -0
  12. patchllm/interactive/selector.py +100 -0
  13. patchllm/llm.py +39 -0
  14. patchllm/main.py +1 -323
  15. patchllm/parser.py +120 -64
  16. patchllm/patcher.py +118 -0
  17. patchllm/scopes/__init__.py +0 -0
  18. patchllm/scopes/builder.py +55 -0
  19. patchllm/scopes/constants.py +70 -0
  20. patchllm/scopes/helpers.py +147 -0
  21. patchllm/scopes/resolvers.py +82 -0
  22. patchllm/scopes/structure.py +64 -0
  23. patchllm/tui/__init__.py +0 -0
  24. patchllm/tui/completer.py +153 -0
  25. patchllm/tui/interface.py +703 -0
  26. patchllm/utils.py +19 -1
  27. patchllm/voice/__init__.py +0 -0
  28. patchllm/{listener.py → voice/listener.py} +8 -1
  29. patchllm-1.0.0.dist-info/METADATA +153 -0
  30. patchllm-1.0.0.dist-info/RECORD +51 -0
  31. patchllm-1.0.0.dist-info/entry_points.txt +2 -0
  32. {patchllm-0.2.2.dist-info → patchllm-1.0.0.dist-info}/top_level.txt +1 -0
  33. tests/__init__.py +0 -0
  34. tests/conftest.py +112 -0
  35. tests/test_actions.py +62 -0
  36. tests/test_agent.py +383 -0
  37. tests/test_completer.py +121 -0
  38. tests/test_context.py +140 -0
  39. tests/test_executor.py +60 -0
  40. tests/test_interactive.py +64 -0
  41. tests/test_parser.py +70 -0
  42. tests/test_patcher.py +71 -0
  43. tests/test_planner.py +53 -0
  44. tests/test_recipes.py +111 -0
  45. tests/test_scopes.py +47 -0
  46. tests/test_structure.py +48 -0
  47. tests/test_tui.py +397 -0
  48. tests/test_utils.py +31 -0
  49. patchllm/context.py +0 -238
  50. patchllm-0.2.2.dist-info/METADATA +0 -129
  51. patchllm-0.2.2.dist-info/RECORD +0 -12
  52. patchllm-0.2.2.dist-info/entry_points.txt +0 -2
  53. {patchllm-0.2.2.dist-info → patchllm-1.0.0.dist-info}/WHEEL +0 -0
  54. {patchllm-0.2.2.dist-info → patchllm-1.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,129 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: patchllm
3
- Version: 0.2.2
4
- Summary: Lightweight tool to manage contexts and update code with LLMs
5
- Author: nassimberrada
6
- License: MIT License
7
-
8
- Copyright (c) 2025 nassimberrada
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the “Software”), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- Requires-Python: >=3.8
28
- Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
- Requires-Dist: litellm
31
- Requires-Dist: python-dotenv
32
- Requires-Dist: rich
33
- Provides-Extra: voice
34
- Requires-Dist: SpeechRecognition; extra == "voice"
35
- Requires-Dist: pyttsx3; extra == "voice"
36
- Provides-Extra: url
37
- Requires-Dist: html2text; extra == "url"
38
- Dynamic: license-file
39
-
40
- <p align="center">
41
- <picture>
42
- <source srcset="./assets/logo_dark.png" media="(prefers-color-scheme: dark)">
43
- <source srcset="./assets/logo_light.png" media="(prefers-color-scheme: light)">
44
- <img src="./assets/logo_light.png" alt="PatchLLM Logo" height="200">
45
- </picture>
46
- </p>
47
-
48
- ## About
49
- PatchLLM is a command-line tool that lets you flexibly build LLM context from your codebase using glob patterns, URLs, and keyword searches. It then automatically applies file edits directly from the LLM's response.
50
-
51
- ## Usage
52
- PatchLLM is designed to be used directly from your terminal. The core workflow is to define a **scope** of files, provide a **task**, and choose an **action** (like patching files directly).
53
-
54
- ### 1. Initialize a Scope
55
- The easiest way to get started is to run the interactive initializer. This will create a `scopes.py` file for you, which holds your saved scopes.
56
-
57
- ```bash
58
- patchllm --init
59
- ```
60
-
61
- This will guide you through creating your first scope, including setting a base path and file patterns. You can add multiple scopes to this file for different projects or tasks.
62
-
63
- A generated `scopes.py` might look like this:
64
- ```python
65
- # scopes.py
66
- scopes = {
67
- "default": {
68
- "path": ".",
69
- "include_patterns": ["**/*.py"],
70
- "exclude_patterns": ["**/tests/*", "venv/*"],
71
- "urls": ["https://docs.python.org/3/library/argparse.html"]
72
- },
73
- "docs": {
74
- "path": "./docs",
75
- "include_patterns": ["**/*.md"],
76
- }
77
- }
78
- ```
79
-
80
- ### 2. Run a Task
81
- Use the `patchllm` command with a scope, a task, and an action flag like `--patch` (`-p`).
82
-
83
- ```bash
84
- # Apply a change using the 'default' scope and the --patch action
85
- patchllm -s default -t "Add type hints to the main function in main.py" -p
86
- ```
87
-
88
- The tool will then:
89
- 1. Build a context from the files and URLs matching your `default` scope.
90
- 2. Send the context and your task to the configured LLM.
91
- 3. Parse the response and automatically write the changes to the relevant files.
92
-
93
- ### All Commands & Options
94
-
95
- #### Core Patching Flow
96
- * `-s, --scope <name>`: Name of the scope to use from your `scopes.py` file.
97
- * `-t, --task "<instruction>"`: The task instruction for the LLM.
98
- * `-p, --patch`: Query the LLM and directly apply the file updates from the response. **This is the main action flag.**
99
-
100
- #### Scope Management
101
- * `-i, --init`: Create a new scope interactively.
102
- * `-sl, --list-scopes`: List all available scopes from your `scopes.py` file.
103
- * `-ss, --show-scope <name>`: Display the settings for a specific scope.
104
-
105
- #### I/O & Context Management
106
- * `-co, --context-out [filename]`: Export the generated context to a file (defaults to `context.md`) instead of running a task.
107
- * `-ci, --context-in <filename>`: Use a previously saved context file as input for a task.
108
- * `-tf, --to-file [filename]`: Send the LLM response to a file (defaults to `response.md`) instead of patching directly.
109
- * `-tc, --to-clipboard`: Copy the LLM response to the clipboard.
110
- * `-ff, --from-file <filename>`: Apply patches from a local file instead of an LLM response.
111
- * `-fc, --from-clipboard`: Apply patches directly from your clipboard content.
112
-
113
- #### General Options
114
- * `--model <model_name>`: Specify a different model (e.g., `gpt-4o`). Defaults to `gemini/gemini-1.5-flash`.
115
- * `--voice`: Enable voice recognition to provide the task instruction.
116
-
117
- ### Setup
118
-
119
- PatchLLM uses [LiteLLM](https://github.com/BerriAI/litellm) under the hood. Please refer to their documentation for setting up API keys (e.g., `OPENAI_API_KEY`, `GEMINI_API_KEY`) in a `.env` file and for a full list of available models.
120
-
121
- To use the voice feature (`--voice`), you will need to install extra dependencies:
122
- ```bash
123
- pip install "speechrecognition>=3.10" "pyttsx3>=2.90"
124
- # Note: speechrecognition may require PyAudio, which might have system-level dependencies.
125
- ```
126
-
127
- ## License
128
-
129
- This project is licensed under the MIT License. See the `LICENSE` file for details.
@@ -1,12 +0,0 @@
1
- patchllm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- patchllm/context.py,sha256=_05amx0WgmHGhJrjB72K-QaWEP6u7vIAanhNjqL7YtQ,8503
3
- patchllm/listener.py,sha256=VjQ_CrSRT4-PolXAAradPKyt8NSUaUQwvgPNH7Oi9q0,968
4
- patchllm/main.py,sha256=y5OGNXEvRWTlUpxj9N6j3Ryhko-XVy_NkQ5axhCzljI,14944
5
- patchllm/parser.py,sha256=DNcf9iUH8umExfK78CSIwac1Bbu7K9iE3754y7CvYzs,3229
6
- patchllm/utils.py,sha256=hz28hd017gRGT632VQAYLPdX0KAS1GLvZzeUDCKbLc0,647
7
- patchllm-0.2.2.dist-info/licenses/LICENSE,sha256=vZxgIRNxffjkTV2NWLemgYjDRu0hSMTyFXCZ1zEWbUc,1077
8
- patchllm-0.2.2.dist-info/METADATA,sha256=xr-iByWSfelUa5xwGgd7G_mROO17ZtxU9QVILbfZQEc,5689
9
- patchllm-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- patchllm-0.2.2.dist-info/entry_points.txt,sha256=xm-W7FKOQd3o9RgK_4krVnO2sC8phpYxDCobf0htLiU,48
11
- patchllm-0.2.2.dist-info/top_level.txt,sha256=SLIZj9EhBXbSnYrbnV8EjL-OfNz-hXRwABCPCjE5Fas,9
12
- patchllm-0.2.2.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- patchllm = patchllm.main:main