|
| 1 | +# Plugin Development Guide |
| 2 | + |
| 3 | +> Rules and conventions for building Nowledge Mem integrations. Follow these when creating a new plugin or extending an existing one. |
| 4 | +
|
| 5 | +--- |
| 6 | + |
| 7 | +## Transport |
| 8 | + |
| 9 | +Use `nmem` CLI as the execution layer for memory operations. |
| 10 | + |
| 11 | +| Transport | When to use | Examples | |
| 12 | +|-----------|------------|----------| |
| 13 | +| **nmem CLI** | Agent plugins that can spawn subprocesses | OpenClaw, Alma, Bub, Droid, Claude Code, Gemini CLI | |
| 14 | +| **MCP** | Declarative runtimes that natively speak MCP and connect to the backend MCP server | Cursor | |
| 15 | +| **HTTP API** | UI extensions where subprocess spawning is inappropriate | Raycast, browser extension | |
| 16 | + |
| 17 | +**CLI resolution order:** |
| 18 | +1. `nmem` on PATH |
| 19 | +2. `uvx --from nmem-cli nmem` (auto-download fallback) |
| 20 | + |
| 21 | +**Credential handling:** |
| 22 | +- API key via `NMEM_API_KEY` environment variable only — never as a CLI argument or in logs |
| 23 | +- API URL via `--api-url` flag or `NMEM_API_URL` environment variable |
| 24 | +- Shared config file: `~/.nowledge-mem/config.json` (`apiUrl`, `apiKey`) |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Tool Naming |
| 29 | + |
| 30 | +### Canonical convention |
| 31 | + |
| 32 | +New tools should use the **`nowledge_mem_<action>`** prefix (underscore-separated). |
| 33 | + |
| 34 | +### Platform exceptions |
| 35 | + |
| 36 | +Some platforms have strong naming conventions that take precedence: |
| 37 | + |
| 38 | +| Platform | Convention | Reason | |
| 39 | +|----------|-----------|--------| |
| 40 | +| Bub | `mem.<action>` | Bub dot-namespace convention | |
| 41 | +| OpenClaw | `memory_<action>` for memory-slot tools | OpenClaw memory slot convention | |
| 42 | +| MCP backend | `memory_<action>` | Backend-defined tool surface | |
| 43 | + |
| 44 | +### Rules |
| 45 | + |
| 46 | +1. **Never rename a published tool name.** If alignment is needed, add the new name as an alias and deprecate the old one gradually. |
| 47 | +2. **Document the naming convention** in `integrations.json` under `toolNaming`. |
| 48 | +3. **New plugins** should use `nowledge_mem_<action>` unless the platform has a documented naming convention. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## Skill Alignment |
| 53 | + |
| 54 | +### Reference the shared behavioral guidance |
| 55 | + |
| 56 | +All behavioral heuristics (when to search, when to save, when to read Working Memory) should align with `community/shared/behavioral-guidance.md`. |
| 57 | + |
| 58 | +**Platform-specific additions** (MCP tool names for Cursor, Context Engine details for OpenClaw, Bub comma commands) are kept separate from the shared heuristics. |
| 59 | + |
| 60 | +### Skill naming |
| 61 | + |
| 62 | +Skill names use kebab-case and are consistent across all plugins: |
| 63 | + |
| 64 | +| Skill | Purpose | |
| 65 | +|-------|---------| |
| 66 | +| `read-working-memory` | Load daily briefing at session start | |
| 67 | +| `search-memory` | Proactive recall across memories and threads | |
| 68 | +| `distill-memory` | Capture decisions, insights, and learnings | |
| 69 | +| `save-handoff` | Structured resumable summary (when no real thread importer exists) | |
| 70 | +| `save-thread` | Real session capture (only when supported) | |
| 71 | +| `check-integration` | Detect agent, verify setup, guide plugin installation | |
| 72 | +| `status` | Connection and configuration diagnostics | |
| 73 | + |
| 74 | +### Autonomous save is required |
| 75 | + |
| 76 | +Every integration's distill/save guidance MUST include proactive save encouragement: |
| 77 | + |
| 78 | +> Save proactively when the conversation produces a decision, preference, plan, procedure, learning, or important context. Do not wait to be asked. |
| 79 | +
|
| 80 | +--- |
| 81 | + |
| 82 | +## Capabilities Checklist |
| 83 | + |
| 84 | +Every integration should provide at minimum: |
| 85 | + |
| 86 | +- [ ] **Working Memory read** — load daily briefing at session start |
| 87 | +- [ ] **Search** — proactive recall across memories, with thread fallback |
| 88 | +- [ ] **Distill** — save decisions and insights (with autonomous save encouragement) |
| 89 | +- [ ] **Status** — connection and configuration diagnostics |
| 90 | + |
| 91 | +Optional capabilities (require platform support): |
| 92 | + |
| 93 | +- [ ] **Auto-recall** — inject relevant memories before each response |
| 94 | +- [ ] **Auto-capture** — save session as searchable thread at session end |
| 95 | +- [ ] **Graph exploration** — connections, evolution chains, entity relationships |
| 96 | +- [ ] **Thread save** — real transcript import (only if parser exists) |
| 97 | +- [ ] **Slash commands** — quick access to common operations |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Thread Save Decision |
| 102 | + |
| 103 | +Before adding thread save to a new integration: |
| 104 | + |
| 105 | +1. **Does `nmem t save --from <runtime>` already have a parser?** If yes → delegate to CLI (Tier 1) |
| 106 | +2. **Can the plugin capture the session via lifecycle hooks?** If yes → implement plugin-level capture (Tier 2) |
| 107 | +3. **Neither?** → Use `save-handoff` and be honest about it (Tier 3) |
| 108 | + |
| 109 | +**Never fake `save-thread`** in a runtime that doesn't support real transcript import. |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Registry Checklist |
| 114 | + |
| 115 | +When shipping a new integration: |
| 116 | + |
| 117 | +1. [ ] Add entry to `community/integrations.json` — **always update the registry first** |
| 118 | +2. [ ] Align behavioral guidance with `community/shared/behavioral-guidance.md` |
| 119 | +3. [ ] Use `nowledge_mem_*` tool naming (or document platform convention) |
| 120 | +4. [ ] Update `community/README.md` integration table |
| 121 | +5. [ ] Verify `nowledge-labs-website/nowledge-mem/data/integrations.ts` alignment |
| 122 | +6. [ ] Add marketplace entry if applicable (`.claude-plugin/`, `.cursor-plugin/`, `.factory-plugin/`) |
| 123 | +7. [ ] Update `nowledge-mem-npx-skills/skills/check-integration/SKILL.md` detection table |
| 124 | +8. [ ] Add integration docs page to website (EN + ZH) |
| 125 | + |
| 126 | +When bumping a plugin **version**: |
| 127 | + |
| 128 | +1. [ ] Update `version` field in `community/integrations.json` |
| 129 | +2. [ ] Verify `nowledge-labs-website/nowledge-mem/data/integrations.ts` alignment |
| 130 | +3. [ ] Add marketplace entry version bump if applicable |
| 131 | + |
| 132 | +### Runtime Consumers |
| 133 | + |
| 134 | +The registry is fetched at runtime by multiple consumers. Changes to schema or field |
| 135 | +names affect all of them: |
| 136 | + |
| 137 | +| Consumer | How it reads | What it uses | |
| 138 | +|----------|-------------|-------------| |
| 139 | +| Desktop app (Tauri) | `fetch_plugin_registry` command — fetches from GitHub, caches to disk | `id`, `name`, `version` for update awareness | |
| 140 | +| `nmem plugins check` CLI | Direct `httpx.get()` — fetches from GitHub, caches to `~/.nowledge-mem/` | `id`, `name`, `version` for update awareness | |
| 141 | +| `check-integration` npx skill | Reads detection hints at skill invocation time | `install.command`, `install.docsUrl`, detection hints | |
| 142 | +| Website `integrations.ts` | Manually synced (not auto-fetched) | All fields for the integrations showcase page | |
0 commit comments