refactor: consolidate agent/editor plugins under integrations/ (#5491)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Kartik
2026-06-12 10:31:35 +05:30
committed by GitHub
co-authored by Claude
parent c676c2c458
commit 2c796d144f
295 changed files with 94 additions and 81 deletions
@@ -0,0 +1,47 @@
---
name: context-loader
description: Searches and injects relevant memories into context before starting work on a task or topic. Use when beginning a new task, switching context, or when past decisions, preferences, or knowledge need to be loaded.
---
# Context Loader
Pre-fetches relevant memories to prime context before working on a task or topic.
## When to use
- Session start (auto-triggered by the extension's `before_agent_start` event)
- User starts work on a specific topic or area
- User says "what do we know about X" or "context for X"
## Steps
1. **Extract topics** from current message/task. Identify: subject areas, people mentioned, project names, goal references.
2. **Run 2-4 parallel searches** using `mem0_memory` tool with `action="search"` and different query angles:
| Query angle | Purpose |
|---|---|
| Topic/subject name | Relevant decisions and preferences |
| People mentioned | Relationship context |
| Project/goal references | Progress and background |
| Broad context | Catch-all for anything relevant |
3. **Deduplicate** results by memory ID across all search responses.
4. **Output compact context block** (max 10 memories):
```
context-loader: loaded <N> memories for "<task summary>"
- [decisions] <content> [mem0:<short_id>]
- [preferences] <content> [mem0:<short_id>]
- [lessons] <content> [mem0:<short_id>]
```
5. If **zero results**: output nothing. Don't announce empty context.
## Constraints
- **Read-only** — never modify or delete memories
- **Max 10 memories** returned (most relevant only)
- **Silent on empty** — only surfaces findings if relevant context exists
- Skip memories already visible in current session context
@@ -0,0 +1,125 @@
---
name: dream
description: Consolidates stored memories by merging duplicates, resolving contradictions, and pruning stale entries. Use when memory count is high, search results feel noisy or repetitive, or periodic cleanup is needed to maintain memory quality.
---
# Dream — Memory Consolidation
This skill performs a memory consolidation pass: it fetches all memories, identifies near-duplicates, flags contradictions, and prunes stale entries. All proposed changes are shown as a diff for user approval before anything is modified.
**IMPORTANT: Execute steps strictly in order (1 -> 2 -> 3 -> 4 -> 5). Each step depends on the previous one. Do NOT run steps in parallel or skip ahead.**
## Step 1: Fetch ALL Memories
Use `mem0_memory` tool with `action="get_all"` to retrieve every memory.
If zero memories are found, print:
```
No memories found. Nothing to consolidate.
```
...and stop.
## Step 2: Analyze — Find Issues
Work entirely in-memory; do not modify anything yet.
Group memories by category. For each group, identify the following:
### 2a. Near-duplicate pairs (merge candidates)
Two memories are near-duplicates when they express the same fact but phrased differently (e.g., "Prefers morning meetings" and "Likes scheduling meetings early").
Heuristics — two memories are near-duplicates if **all** of these hold:
- If >60% of significant nouns/keywords overlap, treat as near-duplicate.
- Same category.
- Neither memory is pinned (content does not start with `[PINNED]`).
For each qualifying pair, draft a merged version that is more complete than either original.
### 2b. Contradictions
Two memories contradict when they assert opposing facts about the same topic (e.g., "Prefers cats" vs. "Allergic to cats, prefers dogs").
Identify the likely winner: the more recent memory wins. Store both IDs and their content for user review.
### 2c. Prune candidates
A memory is a prune candidate when **any** of the following is true:
1. It is older than 180 days AND has not been accessed recently.
2. Its content is extremely vague (fewer than 5 meaningful words).
**Always skip memories where content starts with `[PINNED]`**, regardless of age.
## Step 3: Print Diff Report
Print a structured diff before making any changes:
```
## dream — consolidation report
Merges (<N>):
[mem0:<id1>] + [mem0:<id2>] -> "<merged content, 100 chars>"
Conflicts (<N>):
[mem0:<idA>] vs [mem0:<idB>] — "<topic>" [A/B/skip]
Prune (<N>):
[mem0:<id>] — <category>, <age>d old
Proposed: <N> merges, <N> prunes, <N> conflicts. Apply? [Y/n]
```
If there are zero total proposals, print:
```
Dream complete. No duplicate, contradictory, or stale memories found.
```
...and stop.
## Step 4: Wait for User Input and Apply
### 4a. Contradictions
For each conflict pair, wait for the user to choose A, B, or skip.
### 4b. Final confirmation
After all conflict resolutions are collected, prompt: `Apply? [Y/n]`
If the user declines, print `Cancelled. No changes made.` and stop.
If confirmed, apply all changes:
**Merges:** Delete both originals, add the merged version using `mem0_memory` with `action="add"`.
**Contradictions (resolved):** Delete the loser using `mem0_memory` with `action="delete"`.
**Prunes:** Delete each using `mem0_memory` with `action="delete"`.
## Step 5: Print Summary
```
Dream complete — merged: <N>, pruned: <N>, conflicts resolved: <N>, skipped: <N>
```
## Auto mode
When invoked with `--auto` (e.g., `/mem0-dream --auto`), run non-interactively:
- **Merges**: applied automatically.
- **Prunes**: applied automatically.
- **Contradictions**: skipped — they require human judgment.
Print a compact summary:
```
[mem0-dream --auto] merged=<N> pruned=<N> conflicts_skipped=<N>
```
## See also
- `/mem0-forget` — targeted deletion of specific memories
- `/mem0-status` — quick health check
@@ -0,0 +1,53 @@
---
name: forget
description: Deletes memories by search query or memory ID with confirmation before removal. Use when removing outdated information, incorrect memories, sensitive data, or cleaning up after experiments.
---
# Forget
Delete specific memories from Mem0.
## Execution
### Step 1: Parse input
The user provides either:
- A search query: `/mem0-forget travel plans`
- A memory ID: `/mem0-forget <memory_id>`
If no argument, ask: "What should I forget? Provide a search query or memory ID."
### Step 2: Find memories
**If memory ID provided** (looks like a UUID or hex string):
- Use `mem0_memory` tool with `action="search"` and the ID as query, or look it up directly.
- Show: `Found: "<memory content first 120 chars>" (created <date>)`
**If search query provided:**
- Use `mem0_memory` tool with `action="search"`, `query=<user's query>`.
- Show numbered list:
```
Found <N> memories matching "<query>":
1. <content, 120 chars> [<category>] [ID: <short_id>]
2. ...
```
### Step 3: Confirm
Ask: "Delete which memories? Enter numbers (e.g., 1,3,5), 'all', or 'cancel'."
For a single memory ID, ask: "Delete this memory? [y/N]"
**Never delete without confirmation.** This is destructive.
### Step 4: Delete
For each confirmed memory, use `mem0_memory` tool with `action="delete"` and the memory ID.
### Step 5: Report
```
Deleted <N> memories.
```
If any deletions failed, report which ones and why.
@@ -0,0 +1,48 @@
---
name: pin
description: Pins or unpins a memory to protect it from pruning during dream consolidation. Use when a memory is critical and must never be removed, such as core preferences, important decisions, or immutable personal facts.
---
# Pin
Pin a memory to mark it as high-priority and protect from dream pruning.
## Execution
### Step 1: Find the memory
The user provides either a search query or memory ID.
**If memory ID:** Look it up directly.
**If search query:**
- Use `mem0_memory` tool with `action="search"`, `query=<query>`.
- Show numbered list with content previews.
- Ask: "Which memory to pin? Enter a number."
### Step 2: Pin it
Pinning works by prepending `[PINNED]` to the memory text. This marker tells the dream consolidation to skip it during pruning.
Use `mem0_memory` tool with `action="add"`, `content="[PINNED] <original memory text>"`.
Then delete the original using `mem0_memory` with `action="delete"` and the original memory ID.
**For new memories** (user wants to pin text that isn't stored yet):
- Use `mem0_memory` tool with `action="add"`, `content="[PINNED] <the user's text>"`.
### Step 3: Confirm
```
Pinned: "<memory content, first 80 chars>"
```
Append `...` only if content exceeds 80 characters.
### Unpin
If the user says "unpin":
1. Find the memory (search or by ID).
2. Create a new memory without the `[PINNED]` prefix.
3. Delete the pinned version.
4. Print: `Unpinned: "<content>..."`
@@ -0,0 +1,50 @@
---
name: remember
description: Stores a memory verbatim from user input with appropriate category classification. Use when the user says remember this, save this, store this, note that, or explicitly asks to record a preference, decision, goal, or lesson.
---
# Remember
Store a fact, preference, or learning directly into Mem0.
## Execution
### Step 1: Extract the content
The user provides the content as an argument: `/mem0-remember <text>`
If no text was provided, ask: "What should I remember?"
### Step 2: Classify the memory
Based on the content, pick the best category:
| Content signal | Category |
|---|---|
| "I prefer...", "I like...", "use X instead of Y" | `preferences` |
| "we decided...", "always use...", "never..." | `decisions` |
| "I learned...", "figured out...", "don't try..." | `lessons` |
| "my goal is...", "I want to...", "working toward..." | `goals` |
| "I work at...", "my role is...", "my team..." | `work` |
| "every day I...", "my workflow is..." | `routines` |
| "I'm working on...", "the project involves..." | `projects` |
| "John is...", "my manager...", "the team..." | `relationships` |
| "my name is...", "I'm from...", "I studied..." | `identity` |
| setup, tools, config, environment | `technical` |
| anything else | `lessons` |
### Step 3: Store
Use the `mem0_memory` tool with:
- `action="add"`
- `content="<the user's text>"`
The `/mem0-remember` command stores verbatim — no inference. This is already handled by the command.
### Step 4: Confirm
```
Remembered as <category>: "<content, first 80 chars>"
```
Append `...` only if content was truncated (longer than 80 chars).
@@ -0,0 +1,41 @@
---
name: search
description: Searches memories and displays compact one-liner results, or looks up a specific memory by ID. Use for quick memory lookups, checking if something was recorded, resolving [mem0:id] citations, or browsing memories without full category detail.
---
# Search / Peek
Quick semantic search with compact output. Lighter than `/mem0-tour`.
## Execution
### Step 1: Parse query
The user provides a search query: `/mem0-search favorite restaurants`
If no query provided, ask: "What should I search for?"
**Memory ID detection:** If the query matches a UUID pattern (`^[a-f0-9-]{20,}$`), treat it as a direct memory lookup instead of a search.
### Step 2: Search
Use `mem0_memory` tool with `action="search"`, `query=<user's query>`.
### Step 3: Display
Show compact results:
```
## mem0 search: "<query>" (<N> results)
1. [preferences] Prefers window seats on flights (2026-05-15) [mem0:a3f8b2c1]
2. [goals] Wants to visit Japan in 2027 (2026-05-10) [mem0:7e2d9f4a]
3. [identity] Lives in San Francisco (2026-05-08) [mem0:c4d5e6f7]
```
Format: `<number>. [<category>] <content, 80 chars> (<date>) [mem0:<short_id>]`
If no results:
```
No memories matching "<query>".
```
@@ -0,0 +1,89 @@
---
name: status
description: Diagnoses Mem0 connectivity, API key validity, and memory read/write functionality. Use when memory operations fail, searches return empty, or to verify the plugin is working correctly.
---
# Health Check / Status
Run a diagnostic check on the Mem0 plugin. Useful for troubleshooting.
## Execution
Run ALL checks, then display a single summary. Do not stop on the first failure.
### Check 1: API key
Verify the API key is configured. The plugin loads it from `MEM0_API_KEY` env var or `~/.pi/agent/mem0-config.json`.
- If not set: FAIL — "No API key configured"
- If set: PASS — show first 6 chars followed by `...`
### Check 2: Identity resolution
Report the resolved identity:
- `user_id`: from config, env, or system user
- `project_id`: auto-detected from current directory
- `session_id`: current session identifier
PASS if user_id and project_id are non-empty. WARN if any falls back to defaults.
### Check 3: Connectivity
Use `mem0_memory` tool with `action="search"`, `query="health check"`.
- If returns successfully (even empty): PASS
- If errors: FAIL — show the error message
### Check 4: Memory write capability
Use `mem0_memory` tool with `action="add"`, `content="Health check probe — safe to delete."`.
- If succeeds: PASS — then clean up by deleting the probe memory.
- If errors: FAIL — show the error.
### Display
```
## mem0 health
PASS API Key m0-dVe...
PASS Identity user=kartik, project=my-app, session=abc123
PASS Connectivity 142ms
PASS Write/Read write + delete OK
All checks passed.
```
If any check fails, add a `## Troubleshooting` section with specific fix steps.
## Extended mode: Memory Quality Analysis
When invoked with `--deep` (e.g., `/mem0-status --deep`), run the standard checks above **plus** a memory quality scan.
### Quality Check 1: Duplicates
Fetch all memories with `mem0_memory` `action="get_all"`. Compare pairs within the same category for high textual overlap (shared nouns > 60%). Report:
```
Potential duplicates: <N> pairs
[mem0:<id1>] ~ [mem0:<id2>] — both about "<shared topic>"
```
### Quality Check 2: Stale memories
Flag memories older than 180 days that haven't been accessed recently.
### Quality Check 3: Contradictions
Within each category, flag pairs that assert opposing facts.
### Quality summary
```
## Memory Quality
Duplicates: <N> · Stale: <N> · Contradictions: <N>
```
If all counts are 0: `Memory quality: clean.`
If any non-zero: append `Run /mem0-dream to fix.`
@@ -0,0 +1,88 @@
---
name: tour
description: Browses all stored memories grouped by category with full content display. Use when reviewing all memories, exploring stored knowledge, onboarding to a new session, or getting an overview of what the agent remembers.
---
# Memory Tour
Show the user what Mem0 has stored — a full walkthrough of all memories grouped by category.
## Cross-project mode
When invoked with `--all-projects` (e.g., `/mem0-tour --all-projects`), search across ALL projects:
1. Use `mem0_memory` tool with `action="get_all"`, `scope="global"` — no project filter.
2. Group results by project first, then by category within each project.
3. Display:
```
## <project_1> (<N> memories) <- current
**Goals** — <memory content>
...
## <project_2> (<N> memories)
...
<N> memories across <M> projects
```
4. Mark the current project with `<- current` in the heading.
If `--all-projects` is NOT present, use the standard single-project flow below.
## Search mode
When `/mem0-tour` receives a search query argument (e.g., `/mem0-tour cooking recipes`), run in **search mode** — compact one-liner results:
1. Use `mem0_memory` tool with `action="search"`, `query=<query>`.
2. Display compact results (same format as the search skill).
3. If no results: `No memories matching "<query>".`
If no query argument and no `--all-projects` flag, use the full tour flow below.
## Execution
### Step 1: Fetch ALL memories
Use `mem0_memory` tool with `action="get_all"`.
### Step 2: Group by category
Group memories using their `categories` field. Map to display names:
| Category | Display name |
|---|---|
| `identity` | Identity & Background |
| `preferences` | Preferences |
| `goals` | Goals & Aspirations |
| `projects` | Projects & Initiatives |
| `decisions` | Decisions |
| `technical` | Technical Knowledge |
| `relationships` | People & Relationships |
| `routines` | Routines & Workflows |
| `lessons` | Lessons Learned |
| `work` | Work & Professional |
| anything else | Other |
### Step 3: Display results
Sort groups by descending memory count. For each group:
```
## <display_name> (<count> memories)
- <full_memory_content> (<date>)
- ...
```
Show the **full memory text** for each entry — do NOT truncate. If a group has more than 10 entries, show top 10 by recency and note `... and <N> more`.
### Step 4: Print totals
```
<N> memories across <M> categories
```
### Step 5: Empty state
If zero memories found:
```
No memories stored yet. Start a conversation — Mem0 captures learnings automatically, or use /mem0-remember to store something manually.
```