Metadata-Version: 2.1
Name: agent-git
Version: 0.2.0
Summary: Git for AI Memory. Prevent hallucinations with save points.
Home-page: https://github.com/moustaphamoussa/agent-git
Author: Moustapha Moussa
Author-email: moustapha.moussa@example.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# 🧠 AgentGit: The "Save Button" for AI Agents

**Give your LLM the power to Undo.**

AgentGit is a version control library designed for **AI Agents** (not just humans). It allows Agents to snapshot their own memory, recover from hallucinations, and manage their own state safely.

> "Seamlessly integrates with OpenAI, Anthropic, LangChain, and OpenClaw."

## 🚀 Why?

Most Agents are fragile. If they write bad data to `memory.md` or `state.json`, it's permanent.
**AgentGit** solves this by giving the Agent a **Tool** to save its work.

- **Auto-Save:** Agent learns something new? -> `commit()`
- **Auto-Fix:** Agent detects a mistake? -> `checkout()`

## 📦 Installation

```bash
pip install agent-git
```

## 🤖 Usage: The "AI-Native" Way

Don't run manual commands. **Give the tools to your bot.**

### 1. Integration with OpenAI / Anthropic
AgentGit comes with pre-built tool definitions. Just import and pass them to your model.

```python
import openai
from agent_git import AgentGit, get_llm_tools

# 1. Initialize Memory
memory = AgentGit(root_dir="./agent_workspace")
memory.init()

# 2. Get the Tools (JSON Schema is built-in!)
tools = get_llm_tools() 

# 3. Give them to the Agent
response = openai.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Update my user profile to say I love Python."}],
    tools=tools  # <--- Agent can now call 'agent_git_commit' itself!
)
```

### 2. Integration with OpenClaw / Claude Code
AgentGit includes a **Skill Definition** that teaches autonomous agents how to use it.

```python
from agent_git import get_skill_text

print(get_skill_text())
# Output:
# # Skill: AgentGit (Memory Version Control)
# Use this skill to save/restore memory states...
# - agent_git_commit(message, files)
# ...
```

## ⚡ What the Agent Does

Once equipped, your Agent handles the rest:

1.  **The Agent Writes Memory:**
    > *Agent:* "I will update `user_preferences.json`."

2.  **The Agent Commits (Automatically):**
    > *Agent:* "Calling `agent_git_commit(message='Updated user preference', files=['user_preferences.json'])`."

3.  **The Agent Fixes Hallucinations:**
    > *User:* "Wait, I didn't say that!"
    > *Agent:* "My apologies. Calling `agent_git_checkout(commit_hash='PREVIOUS_HASH')` to restore the correct state."

## 🛠 Manual CLI (For Humans)

You can still inspect what your Agent is doing:

```bash
# See the Agent's save history
agent-git log

# [93a8571] 🤖: Learned about Blender
# [a1b2c3d] 🤖: Updated project roadmap
```

## 🔮 Roadmap
- **LangChain Middleware:** Auto-commit on every `AgentFinish` event.
- **AutoGPT Plugin:** Drop-in persistence layer.
- **Remote Sync:** Push agent memory to private GitHub repos.

---
*Built by [Moustapha Moussa](https://github.com/Kakaymi10) for the Open Source AI Community.*


