{
  "markdown": "# Sugar\n\nPersistent memory for AI coding agents.\n\n<!-- mcp-name: io.github.cdnsteve/sugar -->\n\nYour AI agent starts every session with amnesia. The architecture decisions, conventions,\nand gotchas you explained last week are gone. Sugar is the local-first memory layer that\nremembers them for you - per project, across projects, on your machine.\n\nYour memory. Your machine. Your data.\n\n## What Sugar Does\n\nSugar is a memory layer your AI coding agent can read and write directly:\n\n- **Project memory** - Decisions, preferences, error patterns, and research stored per-project\n- **Global memory** - Standards and guidelines shared across every project you work on\n- **Semantic search** - Retrieve relevant context by meaning, not just keywords\n- **MCP integration** - Your AI agent reads and writes memory directly during sessions\n- **Local-first** - SQLite on your disk, no API keys, fully offline-capable\n- **Task queue** - Optional autonomous execution, powered by the same memory layer\n\n## Quick Start\n\n```bash\n# Install once, use in any project\npipx install sugarai\n\n# Initialize in your project\ncd ~/dev/my-app\nsugar init\n\n# Store what you know\nsugar remember \"We use async/await everywhere, never callbacks\" --type preference\nsugar remember \"JWT tokens use RS256, expire in 15 min - see auth/tokens.py\" --type decision\nsugar remember \"When tests fail with import errors, check __init__.py exports first\" --type error_pattern\n\n# Retrieve it later\nsugar recall \"authentication\"\nsugar recall \"how do we handle async\"\n```\n\nYour AI agent can also read and write memory directly - no copy-pasting required.\n\n## MCP Integration\n\nConnect Sugar's memory to your AI agent so it can access project context automatically.\n\n**Claude Code - Memory server (primary):**\n```bash\nclaude mcp add sugar -- sugar mcp memory\n```\n\n**Claude Code - Task server (optional):**\n```bash\nclaude mcp add sugar-tasks -- sugar mcp tasks\n```\n\nOnce 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.\n\n**Other MCP clients (Goose, Claude Desktop):**\n```bash\n# Goose\ngoose configure\n# Select \"Add Extension\" -> \"Command-line Extension\"\n# Name: sugar\n# Command: sugar mcp memory\n\n# OpenCode - one command setup\nsugar opencode setup\n```\n\n## Global Memory\n\nSome knowledge belongs to you, not just one project. Coding standards, preferred patterns, security practices - these should follow you everywhere.\n\n```bash\n# Store a guideline that applies to all your projects\nsugar remember \"Always validate and sanitize user input before any DB query\" \\\n  --type guideline --global\n\nsugar remember \"Use conventional commits: feat/fix/chore/docs/test\" \\\n  --type guideline --global\n\n# View your global guidelines\nsugar recall \"security\" --global\nsugar memories --global\n\n# Search works project-first, but guidelines always surface\nsugar recall \"database queries\"\n# Returns: project-specific memories + relevant global guidelines\n```\n\nGlobal memory lives at `~/.sugar/memory.db`. Project memory lives at `.sugar/memory.db`. When you search, project context wins - but `guideline` type memories from global always appear in results so your standards stay visible.\n\n**Via MCP**, pass `scope: \"global\"` to `store_learning` to save cross-project knowledge directly from your AI session.\n\n**Memory types:** `decision`, `preference`, `file_context`, `error_pattern`, `research`, `outcome`, `guideline`\n\nFull docs: [Memory System Guide](docs/user/memory.md)\n\n## How Memory Works\n\nSugar uses two SQLite databases and a tiered search strategy.\n\n**Two stores:**\n- **Project store** (`.sugar/memory.db`) - context specific to one project\n- **Global store** (`~/.sugar/memory.db`) - knowledge that applies everywhere\n\n**Seven memory types**, each with different retrieval behavior:\n\n| Type | Purpose | TTL |\n|------|---------|-----|\n| `decision` | Architecture and implementation choices | Never |\n| `preference` | How you like things done | Never |\n| `file_context` | What files and modules do | Never |\n| `error_pattern` | Bugs and their fixes | 90 days |\n| `research` | API docs, library findings | 60 days |\n| `outcome` | What worked, what didn't | 30 days |\n| `guideline` | Cross-project standards and best practices | Never |\n\n**Search strategy - project-first with reserved guideline slots:**\n\n1. Search the project store first (local context always wins)\n2. Reserve slots for global guidelines (cross-project standards always surface)\n3. Fill remaining slots with other global results\n4. Deduplicate across both stores\n\nThis means a mature project's local context dominates results. A new project with no local memory gets global knowledge automatically. And your guidelines are always visible regardless.\n\n**Search engine:** Semantic search via sentence-transformers (all-MiniLM-L6-v2, 384-dim vectors) with sqlite-vec. Falls back to SQLite FTS5 keyword search, then LIKE queries. No external API calls - everything runs locally.\n\n```bash\n# Install with semantic search (recommended)\npipx install 'sugarai[memory]'\n\n# Works without it too - just uses keyword matching\npipx install sugarai\n```\n\n**MCP tools available to your AI agent:**\n\n| Tool | What it does |\n|------|-------------|\n| `search_memory` | Search both stores, returns results with scope labels |\n| `store_learning` | Save a memory (pass `scope: \"global\"` for cross-project) |\n| `recall` | Get formatted markdown context for a topic |\n| `get_project_context` | Full project summary including global guidelines |\n| `list_recent_memories` | Browse recent memories by type |\n\n**MCP resources:**\n- `sugar://project/context` - project summary\n- `sugar://preferences` - coding preferences\n- `sugar://global/guidelines` - cross-project standards\n\n## Task Queue\n\nThe 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.\n\n```bash\n# Add tasks\nsugar add \"Fix authentication timeout\" --type bug_fix --urgent\nsugar add \"Add user profile settings\" --type feature\n\n# Start the autonomous loop\nsugar run\n```\n\nSugar 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.\n\n**Delegate from Claude Code mid-session:**\n```\n/sugar-task \"Fix login timeout\" --type bug_fix --urgent\n```\n\n**Advanced task options:**\nNew in 3.10: Task Orchestration decomposes large features into a 4-stage workflow (research, plan, implement, review) with specialist agent routing and dependency-ordered sub-tasks.\n```bash\n# Orchestrated execution - 4-stage workflow (New in 3.10)\nsugar add \"Add OAuth authentication\" --type feature --orchestrate\n\n# Iterative mode - loops until tests pass\nsugar add \"Implement rate limiting\" --ralph --max-iterations 10\n\n# Check queue status\nsugar list\nsugar status\n```\n\nFull docs: [Task Orchestration](docs/task_orchestration.md)\n\n## Autonomous Issue Resolution (optional)\n\nBecause Sugar remembers your codebase and conventions, it can also resolve routine issues\nautonomously. Point it at a GitHub repo, configure which labels to act on\n(`security`, `bug`, `dependabot`), and Sugar will read each issue, implement the fix, run your\ntests, and open a PR.\n\n```\nLabeled issue appears on GitHub\n  -> Sugar picks it up (label filter: \"security\", \"dependabot\", \"bug\")\n  -> AI agent reads the issue, analyzes the affected code\n  -> Fix implemented, tests run locally\n  -> PR opened - you review and merge\n```\n\nThis is one application of the memory layer, not the headline. Use Sugar purely as memory,\nor enable resolution - your choice. See [workflow examples](docs/workflows/) for security\nauto-fix, bug triage, test coverage, and more.\n\n## Supported AI Tools\n\nWorks with any CLI-based AI coding agent:\n\n| Agent | Memory MCP | Task MCP | Notes |\n|-------|-----------|---------|-------|\n| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Yes | Yes | Full support |\n| [OpenCode](https://github.com/opencode-ai/opencode) | Yes | Yes | `sugar opencode setup` |\n| [Goose](https://block.github.io/goose) | Yes | Yes | Via MCP |\n| [Aider](https://aider.chat) | Via CLI | Via CLI | Manual recall |\n\n## Installation\n\n**Recommended: pipx** - installs once, available everywhere, no venv conflicts:\n```bash\npipx install sugarai\n```\n\n**Upgrade / Uninstall:**\n```bash\npipx upgrade sugarai\npipx uninstall sugarai\n```\n\n<details>\n<summary>Other installation methods</summary>\n\n**pip** (requires venv activation each session)\n```bash\npip install sugarai\n```\n\n**uv**\n```bash\nuv pip install sugarai\n```\n\n**With semantic search (recommended for memory):**\n```bash\npipx install 'sugarai[memory]'\n```\n\n**With GitHub integration:**\n```bash\npipx install 'sugarai[github]'\n```\n\n**All features:**\n```bash\npipx install 'sugarai[all]'\n```\n\n</details>\n\nSugar 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.\n\n## Project Structure\n\n```\n~/.sugar/\n└── memory.db          # Global memory (guidelines, cross-project knowledge)\n\n~/dev/my-app/\n├── .sugar/\n│   ├── sugar.db       # Project memory + task queue\n│   ├── config.yaml    # Project settings\n│   └── prompts/       # Custom agent prompts\n└── src/\n```\n\n**Recommended .gitignore:**\n```gitignore\n.sugar/sugar.db\n.sugar/sugar.log\n.sugar/*.db-*\n```\n\nCommit `.sugar/config.yaml` and `.sugar/prompts/` to share settings with your team.\n\n## Configuration\n\n`.sugar/config.yaml` is created on `sugar init`:\n\n```yaml\nsugar:\n  dry_run: false\n  loop_interval: 300\n  max_concurrent_work: 3\n\nclaude:\n  enable_agents: true\n\ndiscovery:\n  github:\n    enabled: true\n    repo: \"user/repository\"\n```\n\n## Documentation\n\n- [Quick Start](docs/user/quick-start.md)\n- [Memory System](docs/user/memory.md)\n- [CLI Reference](docs/user/cli-reference.md)\n- [Task Orchestration](docs/task_orchestration.md)\n- [Goose Integration](docs/user/goose.md)\n- [OpenCode Integration](docs/user/opencode.md)\n- [GitHub Integration](docs/user/github-integration.md)\n- [Configuration Guide](docs/user/configuration-best-practices.md)\n- [Troubleshooting](docs/user/troubleshooting.md)\n\n## Requirements\n\n- Python 3.11+\n- 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\n\n## Contributing\n\nContributions welcome. See [CONTRIBUTING.md](docs/dev/contributing.md).\n\n```bash\ngit clone https://github.com/roboticforce/sugar.git\ncd sugar\nuv pip install -e \".[dev,test,github]\"\npytest tests/ -v\n```\n\n## License\n\n**Dual License: AGPL-3.0 + Commercial**\n\n- **Open Source (AGPL-3.0)**: Free for open source and personal use\n- **Commercial License**: For proprietary use - [sugar.roboticforce.io/licensing](https://sugar.roboticforce.io/licensing)\n\n---\n\n> Sugar is provided \"AS IS\" without warranty. Review all AI-generated code before use.\n",
  "bytes": 11134,
  "sha": "cdc1c9509330e476042df1b19f6801957b969a943deee26ed3eae0a48748a097",
  "repo_slug": "roboticforce/sugar",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_cdnsteve_sugar_81c01f61/readme"
}