Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ code --install-extension your-publisher.agentmemory

---

## Agent Configuration API

### `configureAgents(agents: string[])`

Select which AI coding agents should receive memory bank sync. Only selected agents will have memory bank directories created and files synced.

**Example:**
```typescript
// Select KiloCode and OpenCode only
await api.configureAgents(['kilocode', 'opencode']);

// Get current selection
const current = await api.getActiveAgents();
console.log('Active agents:', current); // ['kilocode', 'opencode']
```

| Agent Key | Full Name | Type |
|-----------|-----------|------|
| `kilocode` | KiloCode | VS Code Extension |
| `cline` | Cline | VS Code Extension |
| `roocode` | RooCode | VS Code Extension |
| `opencode` | OpenCode | Terminal TUI |

Configuration is persisted in `.agentMemory/agents.json`:
```json
{
"selectedAgents": ["kilocode", "opencode"],
"createdAt": "2025-01-15T10:00:00Z",
"updatedAt": "2025-01-15T10:00:00Z"
}
```

---

## Getting the API

```typescript
Expand Down Expand Up @@ -218,7 +252,7 @@ unsubscribe();

Get statistics about memory usage.

**Returns:** `Promise<any>` - Statistics object with memory counts, cache info, etc.
**Returns:** `Promise<any>` - Statistics object with memory counts, cache info, agent sync status, etc.

**Example:**
```typescript
Expand All @@ -227,6 +261,8 @@ const stats = await api.getStats();
console.log(`Total memories: ${stats.totalMemories}`);
console.log(`By type:`, stats.byType);
console.log(`Cache size: ${stats.cache.size}`);
console.log(`Synced agents:`, stats.sync.agents);
console.log(`Config exists:`, stats.sync.configExists);
```

---
Expand Down Expand Up @@ -280,6 +316,12 @@ interface MemoryEvent {
agent: string;
timestamp: number;
}

interface AgentConfigData {
selectedAgents: string[];
createdAt: string;
updatedAt: string;
}
```

---
Expand All @@ -299,6 +341,9 @@ export async function activate(context: vscode.ExtensionContext) {

const memoryAPI = await agentMemoryExt.activate();

// Configure active agents (only KiloCode and OpenCode)
await memoryAPI.configureAgents(['kilocode', 'opencode']);

// Example: Store architecture decision
const storeDecision = vscode.commands.registerCommand('myext.storeDecision', async () => {
const key = await vscode.window.showInputBox({ prompt: 'Decision key' });
Expand Down Expand Up @@ -364,6 +409,9 @@ Query memories to help new developers understand the codebase.
### 5. Testing Framework
Store test patterns and retrieve them when generating new tests.

### 6. Agent Configuration Manager
Programmatically switch which agents sync with the memory bank based on team preferences.

---

## Best Practices
Expand All @@ -374,6 +422,7 @@ Store test patterns and retrieve them when generating new tests.
4. **Set createdBy**: Identify your extension in metadata for analytics
5. **Handle Errors**: Always check for null returns from `read()` and `update()`
6. **Unsubscribe**: Clean up event subscriptions when no longer needed
7. **Configure Agents Early**: Call `configureAgents()` during extension activation to set up the right agents for your workspace

---

Expand Down
63 changes: 57 additions & 6 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## System Overview

agentMemory is a **hybrid memory system** that enhances the built-in memory banks of KiloCode, Cline, and RooCode with powerful search, analytics, and automation capabilities while maintaining full compatibility with their markdown-based documentation.
agentMemory is a **hybrid memory system** that enhances the built-in memory banks of KiloCode, Cline, RooCode, and OpenCode with powerful search, analytics, and automation capabilities while maintaining full compatibility with their markdown-based documentation.

## Design Philosophy

Expand All @@ -14,8 +14,30 @@ Rather than replacing existing memory bank systems, agentMemory **enhances** the
2. **Syncing** bi-directionally to keep both systems in harmony
3. **Adding** capabilities they lack (search, analytics, automation)
4. **Maintaining** git-friendly, human-readable files
5. **Letting the user choose** which agents to sync with, preventing directory clutter

### Why Hybrid?
### Why Agent Selection?

Previously, agentMemory automatically configured **all** agents (KiloCode, Cline, RooCode, OpenCode) regardless of which ones the user actually uses. This created unnecessary files and directories in projects, causing confusion and clutter.

**Solution:** The user explicitly selects which agents to sync with. This selection is persisted in `.agentMemory/agents.json` and respected by:
- The VS Code Extension setup wizard
- The CLI server startup (`--agents=...` flag)
- The `configure_agents` MCP tool
- The bi-directional sync engine

### Agent Configuration Storage

```
.agentMemory/agents.json
{
"selectedAgents": ["kilocode", "opencode"],
"createdAt": "2025-01-15T10:00:00Z",
"updatedAt": "2025-01-15T12:30:00Z"
}
```

This file is the **single source of truth** for agent selection. All components read from it.

**Their Systems (Markdown)**
- ✅ Human-readable
Expand Down Expand Up @@ -125,9 +147,13 @@ Rather than replacing existing memory bank systems, agentMemory **enhances** the
- Bi-directional sync engine
- Parses markdown files from agents' memory banks
- Exports MCP memories to markdown format
- Supports KiloCode, Cline, and RooCode
- Supports KiloCode, Cline, RooCode, and OpenCode
- **Respects agent selection** from `.agentMemory/agents.json`
- **Only syncs to selected agents**, prevents directory clutter

**File Mapping:**
**Agent Configuration:**
All agent definitions (name, memory bank path, file mapping) live in `src/mcp-server/agent-config.ts` (`ALL_AGENTS`).
The sync engine reads `agents.json` to determine which agents to sync with.
```typescript
KiloCode: .kilocode/rules/memory-bank/
brief.md → architecture
Expand All @@ -152,22 +178,47 @@ RooCode: .roo/memory-bank/
techContext.md → decision
progress.md → feature
decisionLog.md → decision

OpenCode: .opencode/memory-bank/
architecture.md → architecture
patterns.md → pattern
decisions.md → decision
features.md → feature

OpenCode also syncs to AGENTS.md (project root) for session-start context.
```

### 3. Configuration Management (`src/config.ts`)

**Responsibilities:**
- Detect installed AI coding agents
- **Prompt user to select which agents to sync with** (via `showQuickPick` multi-select)
- Write MCP server config to `.vscode/settings.json`
- Persist agent selection to `.agentMemory/agents.json`
- Configure socket paths for each project

**Agent Selection Flow:**
```
1. Detect installed extensions (KiloCode, Cline, RooCode)
2. Detect OpenCode by file system (opencode.json, .opencode/)
3. Show QuickPick with all agents, pre-selecting installed ones
4. User picks which agents to sync with
5. Save selection to .agentMemory/agents.json
6. Only configure MCP settings for selected agents
```

**Agent Detection:**
```typescript
detectInstalledAgents(): string[] {
// Checks for:
// Checks for VS Code extensions:
// - saoudrizwan.claude-dev (Cline)
// - kilocode.kilo-code (KiloCode)
// - rooveterinaryinc.roo-cline (RooCode)
// - roo-code.roo-code (RooCode)
// - Continue.continue (Continue)

// Also checks for OpenCode by file system:
// - opencode.json in workspace root
// - .opencode/ directory in workspace
}
```

Expand Down
81 changes: 65 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,39 @@

**Hybrid Memory System for AI Coding Agents**

Seamlessly integrate with KiloCode, Cline, and RooCode's built-in memory banks while providing powerful search, analytics, and automation.
Seamlessly integrate with KiloCode, Cline, RooCode, and OpenCode's built-in memory banks while providing powerful search, analytics, and automation.

[![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/webzler.agentmemory?label=VS%20Code%20Marketplace)](https://marketplace.visualstudio.com/)
[![Installs](https://img.shields.io/visual-studio-marketplace/i/webzler.agentmemory)](https://marketplace.visualstudio.com/)

---

## 📢 Latest Release Highlights

### v0.2.0 — Agent Selector & OpenCode Support

**🎯 Agent Selection (New in v0.2.0)**
- You can now **choose which coding agents** to sync with instead of having all agents configured at once.
- Memory bank files are only created for the agents you actively use, keeping your project directory clean and uncluttered.
- Supports selection via:
- **VS Code Extension** — `showQuickPick` multi-select during setup
- **SKILL.md / Terminal** — Interactive readline prompt or `--agents` CLI flag
- **MCP Tool** — `configure_agents({ agents: "kilocode,opencode" })` anytime

**🤖 OpenCode Support (Added in v0.2.0)**
- Full compatibility with the **OpenCode** terminal-based agent.
- Syncs to `.opencode/memory-bank/` and maintains `AGENTS.md` + `.opencode/commands/`.

---

## 🚀 Now Available as an Antigravity Skill!

agentMemory is now fully compatible with **Antigravity**. Use it as a skill to give your agents persistent, searchable memory that syncs with your project documentation.

See [SKILL.md](SKILL.md) for usage instructions.

---


## 🚀 Now Available as an Antigravity Skill!

Expand Down Expand Up @@ -153,13 +179,22 @@ memory_search({

### 🤖 Multi-Agent Support

| Agent | Memory Bank Location | Sync Status |
|-------|---------------------|-------------|
| **KiloCode** | `.kilocode/rules/memory-bank/` | ✅ Full sync |
| **Cline** | `.clinerules/memory-bank/` | ✅ Full sync |
| **RooCode** | `.roo/memory-bank/` | ✅ Full sync |
| Agent | Type | Memory Bank Location | Sync Status |
|-------|------|---------------------|-------------|
| **KiloCode** | VS Code Extension | `.kilocode/rules/memory-bank/` | ✅ Selectable |
| **Cline** | VS Code Extension | `.clinerules/memory-bank/` | ✅ Selectable |
| **RooCode** | VS Code Extension | `.roo/memory-bank/` | ✅ Selectable |
| **OpenCode** | Terminal TUI | `AGENTS.md` + `.opencode/commands/` | ✅ Selectable |

**You choose which agents to sync.** Only selected agents receive:
- Memory bank directories
- MCP settings
- Synced markdown files
- `opencode.json` (OpenCode only)

**Files Synced:**
Use `configure_agents({ agents: "kilocode,opencode" })` to change your selection anytime.

**Files Synced (for selected agents only):**
- `projectBrief.md` / `brief.md`
- `architecture.md` / `systemPatterns.md`
- `productContext.md` / `product.md`
Expand All @@ -180,9 +215,10 @@ memory_search({
4. Reload VS Code

**That's it!** The extension will:
- ✅ Ask which agents to sync with (via QuickPick)
- ✅ Create MCP server configuration
- ✅ Inject memory-first instructions into memory banks
- ✅ Start bi-directional sync
- ✅ Inject memory-first instructions into selected memory banks
- ✅ Start bi-directional sync with **only** selected agents
- ✅ Enable dashboard

### Manual Installation
Expand Down Expand Up @@ -243,40 +279,53 @@ Agents treat this as **project architecture** and follow it automatically.
| `memory_list` | List by type | Show all architecture decisions |
| `memory_update` | Modify existing | Append to existing pattern |
| `memory_stats` | View analytics | Usage statistics |
| `configure_agents` | Change agent selection | `configure_agents({ agents: "kilocode,opencode" })` |

---

## � Project Structure

After installation, your project will have:
After installation, your project will have (only for **selected** agents):

```
your-project/
├── .vscode/
│ └── settings.json # MCP server config (auto-created)
├── .agentMemory/ # Our structured storage
├── .agentMemory/ # Our structured storage + config
│ ├── uuid-001.json # Memory: OAuth architecture
│ ├── uuid-002.json # Memory: API patterns
│ └── ...
│ └── agents.json # Active agent configuration ⭐ NEW
├── AGENTS.md # OpenCode rules (auto-created if OpenCode selected)
├── opencode.json # OpenCode MCP config (auto-created if selected)
├── .kilocode/rules/memory-bank/ # KiloCode memory bank
├── .opencode/ # ONLY if OpenCode is selected
│ └── commands/ # OpenCode custom commands
│ ├── memory-search.md
│ ├── memory-write.md
│ └── memory-review.md
├── .kilocode/rules/memory-bank/ # ONLY if KiloCode is selected
│ ├── brief.md # ⬍ Synced with our database
│ ├── architecture.md # ⬍ Auto-updated
│ ├── product.md # ⬍ Auto-updated
│ └── tech.md # ⬍ Auto-updated
├── .clinerules/memory-bank/ # Cline memory bank
├── .clinerules/memory-bank/ # ONLY if Cline is selected
│ ├── projectBrief.md # ⬍ Synced
│ ├── systemPatterns.md # ⬍ Synced
│ └── ... # ⬍ Synced
└── .roo/memory-bank/ # RooCode memory bank
└── .roo/memory-bank/ # ONLY if RooCode is selected
├── projectBrief.md # ⬍ Synced
├── decisionLog.md # ⬍ Synced
└── ... # ⬍ Synced
```

**Only the agents you select get directories and files created!** This keeps your project clean.

**All markdown files stay human-readable and git-friendly!**

---
Expand Down Expand Up @@ -323,7 +372,7 @@ your-project/
| **Search** | ✅ Fast indexed | ❌ No | ✅ Yes |
| **Analytics** | ✅ Dashboard | ❌ No | ❌ No |
| **Automation** | ✅ Auto-sync | ❌ Manual | ⚠️ Partial |
| **Multi-Agent** | ✅ All 3 | ✅ Per-agent | ✅ All |
| **Multi-Agent** | ✅ All 4 | ✅ Per-agent | ✅ All |
| **Git-Friendly** | ✅ Yes | ✅ Yes | ⚠️ Depends |
| **Cross-Project** | ✅ Yes | ❌ No | ❌ No |

Expand Down
Loading