Metadata-Version: 2.4
Name: sugarai
Version: 3.9.0
Summary: Persistent memory for AI coding agents. Cross-session context, global knowledge, and autonomous task execution.
Author-email: Steven Leggett <contact@roboticforce.io>
License: AGPL-3.0-or-later
Project-URL: Homepage, https://github.com/roboticforce/sugar
Project-URL: Documentation, https://sugar.roboticforce.io/
Project-URL: Repository, https://github.com/roboticforce/sugar
Project-URL: Bug Tracker, https://github.com/roboticforce/sugar/issues
Keywords: claude,autonomous,development,ai,automation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.1.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: aiosqlite>=0.19.0
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: asyncio-throttle>=1.0.0
Requires-Dist: setuptools>=45
Requires-Dist: claude-agent-sdk>=0.1.0
Provides-Extra: github
Requires-Dist: PyGithub>=1.59.0; extra == "github"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: flake8-docstrings>=1.7.0; extra == "dev"
Requires-Dist: isort>=5.12.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: bandit>=1.7.5; extra == "dev"
Requires-Dist: safety>=2.3.0; extra == "dev"
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
Requires-Dist: types-requests>=2.28.0; extra == "dev"
Requires-Dist: types-setuptools>=69.0.0; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == "mcp"
Requires-Dist: starlette>=0.27.0; extra == "mcp"
Requires-Dist: uvicorn>=0.22.0; extra == "mcp"
Provides-Extra: memory
Requires-Dist: sentence-transformers>=2.2.0; extra == "memory"
Requires-Dist: sqlite-vec>=0.1.0; extra == "memory"
Provides-Extra: opencode
Requires-Dist: aiohttp>=3.9.0; extra == "opencode"
Provides-Extra: all
Requires-Dist: sugarai[github,mcp,memory,opencode]; extra == "all"
Dynamic: license-file

# 🍰 Sugar

Persistent memory for AI coding agents.

<!-- mcp-name: io.github.cdnsteve/sugar -->

Sugar gives your AI agents memory that persists across sessions and projects. It remembers your decisions, patterns, and preferences so you stop re-explaining context every time you open a new session. The task queue builds on top of that memory layer to run work autonomously while you focus on other things.

## What Sugar Does

Every AI coding session starts cold. You explain the same architectural decisions, re-describe the same error patterns, and re-establish the same preferences - over and over.

Sugar fixes that. It stores what matters and surfaces it when relevant:

- **Project memory** - Decisions, preferences, error patterns, and research stored per-project
- **Global memory** - Standards and guidelines shared across every project you work on
- **Semantic search** - Retrieve relevant context by meaning, not just keywords
- **MCP integration** - Your AI agent reads and writes memory directly during sessions
- **Task queue** - Hand off work to run autonomously, powered by the same memory layer

## Quick Start

```bash
# Install once, use in any project
pipx install sugarai

# Initialize in your project
cd ~/dev/my-app
sugar init

# Store what you know
sugar remember "We use async/await everywhere, never callbacks" --type preference
sugar remember "JWT tokens use RS256, expire in 15 min - see auth/tokens.py" --type decision
sugar remember "When tests fail with import errors, check __init__.py exports first" --type error_pattern

# Retrieve it later
sugar recall "authentication"
sugar recall "how do we handle async"
```

Your AI agent can also read and write memory directly - no copy-pasting required.

## MCP Integration

Connect Sugar's memory to your AI agent so it can access project context automatically.

**Claude Code - Memory server (primary):**
```bash
claude mcp add sugar -- sugar mcp memory
```

**Claude Code - Task server (optional):**
```bash
claude mcp add sugar-tasks -- sugar mcp tasks
```

Once connected, Claude can call `store_learning` to save context mid-session and `search_memories` to pull relevant knowledge before starting work. The memory server works from any directory - global memory is always available even outside a Sugar project.

**Other MCP clients (Goose, Claude Desktop):**
```bash
# Goose
goose configure
# Select "Add Extension" -> "Command-line Extension"
# Name: sugar
# Command: sugar mcp memory

# OpenCode - one command setup
sugar opencode setup
```

## Global Memory (New in 3.8)

Some knowledge belongs to you, not just one project. Coding standards, preferred patterns, security practices - these should follow you everywhere.

```bash
# Store a guideline that applies to all your projects
sugar remember "Always validate and sanitize user input before any DB query" \
  --type guideline --global

sugar remember "Use conventional commits: feat/fix/chore/docs/test" \
  --type guideline --global

# View your global guidelines
sugar recall "security" --global
sugar memories --global

# Search works project-first, but guidelines always surface
sugar recall "database queries"
# Returns: project-specific memories + relevant global guidelines
```

Global memory lives at `~/.sugar/memory.db`. Project memory lives at `.sugar/sugar.db`. When you search, project context wins - but `guideline` type memories from global always appear in results so your standards stay visible.

**Via MCP**, pass `scope: "global"` to `store_learning` to save cross-project knowledge directly from your AI session.

**Memory types:** `decision`, `preference`, `file_context`, `error_pattern`, `research`, `outcome`, `guideline`

Full docs: [Memory System Guide](docs/user/memory.md)

## Task Queue

The task queue lets you hand off work and let it run autonomously. It reads from the same memory store, so Sugar already knows your preferences and patterns before it starts.

```bash
# Add tasks
sugar add "Fix authentication timeout" --type bug_fix --urgent
sugar add "Add user profile settings" --type feature

# Start the autonomous loop
sugar run
```

Sugar picks up tasks, executes them with your configured AI agent, runs tests, commits working code, and moves to the next task. It runs until the queue is empty or you stop it.

**Delegate from Claude Code mid-session:**
```
/sugar-task "Fix login timeout" --type bug_fix --urgent
```

**Advanced task options:**
```bash
# Orchestrated execution (research -> plan -> implement -> review)
sugar add "Add OAuth authentication" --type feature --orchestrate

# Iterative mode - loops until tests pass
sugar add "Implement rate limiting" --ralph --max-iterations 10

# Check queue status
sugar list
sugar status
```

Full docs: [Task Orchestration](docs/task_orchestration.md)

## Supported AI Tools

Works with any CLI-based AI coding agent:

| Agent | Memory MCP | Task MCP | Notes |
|-------|-----------|---------|-------|
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Yes | Yes | Full support |
| [OpenCode](https://github.com/opencode-ai/opencode) | Yes | Yes | `sugar opencode setup` |
| [Goose](https://block.github.io/goose) | Yes | Yes | Via MCP |
| [Aider](https://aider.chat) | Via CLI | Via CLI | Manual recall |

## Installation

**Recommended: pipx** - installs once, available everywhere, no venv conflicts:
```bash
pipx install sugarai
```

**Upgrade / Uninstall:**
```bash
pipx upgrade sugarai
pipx uninstall sugarai
```

<details>
<summary>Other installation methods</summary>

**pip** (requires venv activation each session)
```bash
pip install sugarai
```

**uv**
```bash
uv pip install sugarai
```

**With semantic search (recommended for memory):**
```bash
pipx install 'sugarai[memory]'
```

**With GitHub integration:**
```bash
pipx install 'sugarai[github]'
```

**All features:**
```bash
pipx install 'sugarai[all]'
```

</details>

Sugar is **project-local** by default. Each project gets its own `.sugar/` folder with its own database and config. Global memory lives at `~/.sugar/`. Like `git` - one installation, per-project state.

## Project Structure

```
~/.sugar/
└── memory.db          # Global memory (guidelines, cross-project knowledge)

~/dev/my-app/
├── .sugar/
│   ├── sugar.db       # Project memory + task queue
│   ├── config.yaml    # Project settings
│   └── prompts/       # Custom agent prompts
└── src/
```

**Recommended .gitignore:**
```gitignore
.sugar/sugar.db
.sugar/sugar.log
.sugar/*.db-*
```

Commit `.sugar/config.yaml` and `.sugar/prompts/` to share settings with your team.

## Configuration

`.sugar/config.yaml` is created on `sugar init`:

```yaml
sugar:
  dry_run: false
  loop_interval: 300
  max_concurrent_work: 3

claude:
  enable_agents: true

discovery:
  github:
    enabled: true
    repo: "user/repository"
```

## Documentation

- [Quick Start](docs/user/quick-start.md)
- [Memory System](docs/user/memory.md)
- [CLI Reference](docs/user/cli-reference.md)
- [Task Orchestration](docs/task_orchestration.md)
- [Goose Integration](docs/user/goose.md)
- [OpenCode Integration](docs/user/opencode.md)
- [GitHub Integration](docs/user/github-integration.md)
- [Configuration Guide](docs/user/configuration-best-practices.md)
- [Troubleshooting](docs/user/troubleshooting.md)

## Requirements

- Python 3.11+
- A CLI-based AI agent: [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [OpenCode](https://github.com/opencode-ai/opencode), [Aider](https://aider.chat), or similar

## Contributing

Contributions welcome. See [CONTRIBUTING.md](docs/dev/contributing.md).

```bash
git clone https://github.com/roboticforce/sugar.git
cd sugar
uv pip install -e ".[dev,test,github]"
pytest tests/ -v
```

## License

**Dual License: AGPL-3.0 + Commercial**

- **Open Source (AGPL-3.0)**: Free for open source and personal use
- **Commercial License**: For proprietary use - [sugar.roboticforce.io/licensing](https://sugar.roboticforce.io/licensing)

---

> Sugar is provided "AS IS" without warranty. Review all AI-generated code before use.
