commitai 2.0.0__py3-none-any.whl → 2.2.2__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.
- commitai/__init__.py +1 -1
- commitai/agent.py +46 -16
- commitai/cli.py +3 -2
- {commitai-2.0.0.dist-info → commitai-2.2.2.dist-info}/METADATA +10 -9
- commitai-2.2.2.dist-info/RECORD +11 -0
- commitai-2.0.0.dist-info/RECORD +0 -11
- {commitai-2.0.0.dist-info → commitai-2.2.2.dist-info}/WHEEL +0 -0
- {commitai-2.0.0.dist-info → commitai-2.2.2.dist-info}/entry_points.txt +0 -0
- {commitai-2.0.0.dist-info → commitai-2.2.2.dist-info}/licenses/LICENSE +0 -0
commitai/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# This __version__ string is read by hatchling during the build process
|
|
5
5
|
# Make sure to update it for new releases.
|
|
6
|
-
__version__ = "2.
|
|
6
|
+
__version__ = "2.2.2"
|
|
7
7
|
|
|
8
8
|
# The importlib.metadata approach is generally for reading the version
|
|
9
9
|
# of an *already installed* package at runtime. We don't need it here
|
commitai/agent.py
CHANGED
|
@@ -3,11 +3,11 @@ import os
|
|
|
3
3
|
import subprocess
|
|
4
4
|
from typing import Any, Dict, Type
|
|
5
5
|
|
|
6
|
-
from langchain.agents import AgentExecutor, create_tool_calling_agent
|
|
6
|
+
# from langchain.agents import AgentExecutor, create_tool_calling_agent # Removed
|
|
7
7
|
from langchain_core.language_models import BaseChatModel
|
|
8
|
-
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
9
8
|
from langchain_core.runnables import Runnable
|
|
10
9
|
from langchain_core.tools import BaseTool
|
|
10
|
+
from langgraph.prebuilt import create_react_agent
|
|
11
11
|
from pydantic import BaseModel, Field
|
|
12
12
|
|
|
13
13
|
# --- TOOLS ---
|
|
@@ -157,6 +157,9 @@ class TodoMiddleware:
|
|
|
157
157
|
# --- AGENT ---
|
|
158
158
|
|
|
159
159
|
|
|
160
|
+
# --- AGENT ---
|
|
161
|
+
|
|
162
|
+
|
|
160
163
|
def create_commit_agent(llm: BaseChatModel) -> Runnable:
|
|
161
164
|
# 1. Init Tools
|
|
162
165
|
tools = [ReadOnlyShellTool(), FileSearchTool(), FileReadTool()]
|
|
@@ -186,18 +189,22 @@ Protocol:
|
|
|
186
189
|
3. If clarification is needed, explore files.
|
|
187
190
|
4. Final Answer MUST be ONLY the commit message.
|
|
188
191
|
"""
|
|
189
|
-
prompt
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
# Note: create_react_agent handles the prompt internally or via state_modifier.
|
|
193
|
+
# We can pass a system string or a function. Since our prompt depends on dynamic
|
|
194
|
+
# variables (diff, explanation, etc.), we need to inject them. LangGraph's
|
|
195
|
+
# prebuilt agent usually takes a static system message. However, we can use the
|
|
196
|
+
# 'messages' state. But to keep it simple and compatible with existing 'invoke'
|
|
197
|
+
# interface: We will format the system prompt in the wrapper and pass it as the
|
|
198
|
+
# first message.
|
|
199
|
+
|
|
200
|
+
# Actually, create_react_agent supports 'state_modifier'.
|
|
201
|
+
# If we pass a formatted string, it works as system prompt.
|
|
202
|
+
|
|
203
|
+
# 4. Construct Graph
|
|
204
|
+
# We don't construct the graph with ALL variables pre-bound if they change per run.
|
|
205
|
+
# Instead, we'll format the prompt in the pipeline and pass it to the agent.
|
|
197
206
|
|
|
198
|
-
|
|
199
|
-
agent = create_tool_calling_agent(llm, tools, prompt)
|
|
200
|
-
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=False)
|
|
207
|
+
agent_graph = create_react_agent(llm, tools)
|
|
201
208
|
|
|
202
209
|
# 5. Pipeline with Middleware
|
|
203
210
|
def run_pipeline(inputs: Dict[str, Any]) -> str:
|
|
@@ -210,11 +217,34 @@ Protocol:
|
|
|
210
217
|
state.setdefault("explanation", "None")
|
|
211
218
|
state.setdefault("summary", "None")
|
|
212
219
|
state.setdefault("todo_str", "None")
|
|
213
|
-
|
|
220
|
+
|
|
221
|
+
# Format System Prompt
|
|
222
|
+
formatted_system_prompt = system_prompt.format(
|
|
223
|
+
explanation=state["explanation"],
|
|
224
|
+
todo_str=state["todo_str"],
|
|
225
|
+
summary=state["summary"],
|
|
226
|
+
diff=state.get("diff", ""),
|
|
227
|
+
)
|
|
214
228
|
|
|
215
229
|
# Run Agent
|
|
216
|
-
|
|
217
|
-
|
|
230
|
+
# LangGraph inputs: {"messages": [{"role": "user", "content": ...}]}
|
|
231
|
+
# We inject the system prompt as a SystemMessage or just update the state.
|
|
232
|
+
# create_react_agent primarily looks at 'messages'.
|
|
233
|
+
|
|
234
|
+
from langchain_core.messages import HumanMessage, SystemMessage
|
|
235
|
+
|
|
236
|
+
messages = [
|
|
237
|
+
SystemMessage(content=formatted_system_prompt),
|
|
238
|
+
HumanMessage(content="Generate the commit message."),
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
# Invoke graph
|
|
242
|
+
# result is a dict with 'messages'
|
|
243
|
+
result = agent_graph.invoke({"messages": messages})
|
|
244
|
+
|
|
245
|
+
# Extract last message content
|
|
246
|
+
last_message = result["messages"][-1]
|
|
247
|
+
return str(last_message.content)
|
|
218
248
|
|
|
219
249
|
# Wrap in RunnableLambda to expose 'invoke'
|
|
220
250
|
from langchain_core.runnables import RunnableLambda
|
commitai/cli.py
CHANGED
|
@@ -106,7 +106,8 @@ def _handle_commit(commit_message: str, commit_flag: bool) -> None:
|
|
|
106
106
|
final_commit_message = commit_message
|
|
107
107
|
if not commit_flag:
|
|
108
108
|
click.secho(
|
|
109
|
-
f"\n📝 Generated Commit Message:\n{'-'*40}\n
|
|
109
|
+
f"\n📝 Generated Commit Message:\n{'-' * 40}\n"
|
|
110
|
+
f"{commit_message}\n{'-' * 40}\n",
|
|
110
111
|
fg="green",
|
|
111
112
|
)
|
|
112
113
|
|
|
@@ -197,7 +198,7 @@ def generate_message(
|
|
|
197
198
|
template: Optional[str],
|
|
198
199
|
add: bool,
|
|
199
200
|
model: str,
|
|
200
|
-
deep: bool,
|
|
201
|
+
deep: bool = False,
|
|
201
202
|
) -> None:
|
|
202
203
|
explanation = " ".join(description)
|
|
203
204
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: commitai
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: Commitai helps you generate git commit messages using AI
|
|
5
5
|
Project-URL: Bug Tracker, https://github.com/lguibr/commitai/issues
|
|
6
6
|
Project-URL: Documentation, https://github.com/lguibr/commitai/blob/main/README.md
|
|
@@ -40,18 +40,19 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
40
40
|
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
41
41
|
Classifier: Topic :: Utilities
|
|
42
42
|
Requires-Python: >=3.10
|
|
43
|
-
Requires-Dist: click
|
|
44
|
-
Requires-Dist: langchain-community
|
|
45
|
-
Requires-Dist: langchain-core
|
|
46
|
-
Requires-Dist: langchain-google-genai
|
|
47
|
-
Requires-Dist: langchain
|
|
48
|
-
Requires-Dist:
|
|
43
|
+
Requires-Dist: click>=8.1
|
|
44
|
+
Requires-Dist: langchain-community>=0.4.0
|
|
45
|
+
Requires-Dist: langchain-core>=1.0
|
|
46
|
+
Requires-Dist: langchain-google-genai>=1.0
|
|
47
|
+
Requires-Dist: langchain>=1.0
|
|
48
|
+
Requires-Dist: langgraph>=1.0.0
|
|
49
|
+
Requires-Dist: pydantic>=2.0
|
|
49
50
|
Provides-Extra: test
|
|
50
|
-
Requires-Dist: langchain-google-genai
|
|
51
|
+
Requires-Dist: langchain-google-genai>=2.0.0; extra == 'test'
|
|
51
52
|
Requires-Dist: mypy>=1.9.0; extra == 'test'
|
|
52
53
|
Requires-Dist: pytest-cov>=3.0; extra == 'test'
|
|
53
54
|
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
54
|
-
Requires-Dist: ruff
|
|
55
|
+
Requires-Dist: ruff>=0.4.4; extra == 'test'
|
|
55
56
|
Requires-Dist: types-setuptools; extra == 'test'
|
|
56
57
|
Description-Content-Type: text/markdown
|
|
57
58
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
commitai/__init__.py,sha256=6977C2xbYqWwIRHhuFqmyoyI7MaMQmzb3SYtWjIJ4To,388
|
|
2
|
+
commitai/agent.py,sha256=dxTHlxpYWuOQU9purJMoZCWhTszY4pkQhhnXXuWvmWk,8330
|
|
3
|
+
commitai/chains.py,sha256=i5tQL9Qg-kP4yVCiQavhOLS9ljh72bxYALQ27Hoqivc,4612
|
|
4
|
+
commitai/cli.py,sha256=I_3c2q15e3KniprWidqry8ZLJJXg-jAcT2w9wO00_L4,11666
|
|
5
|
+
commitai/git.py,sha256=XWAloZWQuLrFHUyfh3SkOgLsL4kfKRtgj3fzuJjcL2A,1649
|
|
6
|
+
commitai/template.py,sha256=PAS3BUjj6fcdsvSheopU_0xGCLPMj-vvFeZVCNRf0VM,2274
|
|
7
|
+
commitai-2.2.2.dist-info/METADATA,sha256=sdVS1BuvMbvck6vWfNjv4tPrGyMI8RTff6bvhditrz8,13856
|
|
8
|
+
commitai-2.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
9
|
+
commitai-2.2.2.dist-info/entry_points.txt,sha256=qzWJQdPoR38mjQgRPRCB3tA7Kojtj3WrozlFWR4KhLY,128
|
|
10
|
+
commitai-2.2.2.dist-info/licenses/LICENSE,sha256=wVkmSz0UMpGw0xYxk4AmkPLd_tVFcuszTdNIoq02tJA,1087
|
|
11
|
+
commitai-2.2.2.dist-info/RECORD,,
|
commitai-2.0.0.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
commitai/__init__.py,sha256=__b9FU1YSgHa5pyZG0hsgo2bQrNVAFPUMH2o-pBKzzE,388
|
|
2
|
-
commitai/agent.py,sha256=fHh8d_ND9s0gqPaWqbHwmW9Kkt9dS5M6sRnGmhHb87Y,7037
|
|
3
|
-
commitai/chains.py,sha256=i5tQL9Qg-kP4yVCiQavhOLS9ljh72bxYALQ27Hoqivc,4612
|
|
4
|
-
commitai/cli.py,sha256=9-_y6STLCz-E7kHH6bX7CaV3aIxt8cdp-oa3IqbKDHY,11638
|
|
5
|
-
commitai/git.py,sha256=XWAloZWQuLrFHUyfh3SkOgLsL4kfKRtgj3fzuJjcL2A,1649
|
|
6
|
-
commitai/template.py,sha256=PAS3BUjj6fcdsvSheopU_0xGCLPMj-vvFeZVCNRf0VM,2274
|
|
7
|
-
commitai-2.0.0.dist-info/METADATA,sha256=Vjrry5eOeDtht4XyJuloAzQJXOBJf6WEVnMEx0R9BbE,13868
|
|
8
|
-
commitai-2.0.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
9
|
-
commitai-2.0.0.dist-info/entry_points.txt,sha256=qzWJQdPoR38mjQgRPRCB3tA7Kojtj3WrozlFWR4KhLY,128
|
|
10
|
-
commitai-2.0.0.dist-info/licenses/LICENSE,sha256=wVkmSz0UMpGw0xYxk4AmkPLd_tVFcuszTdNIoq02tJA,1087
|
|
11
|
-
commitai-2.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|