diff --git a/README.md b/README.md index 4f330ba9..866340e7 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Each directory is a standalone integration. Pick the one that matches your tool. | **[Windsurf Trajectory Extractor](https://github.com/jijiamoer/windsurf-trajectory-extractor)** | `git clone https://github.com/jijiamoer/windsurf-trajectory-extractor.git` | Offline protobuf extraction for Windsurf Cascade conversation history. | | **[Cursor Plugin](nowledge-mem-cursor-plugin)** | Link `nowledge-mem-cursor-plugin` into `~/.cursor/plugins/local/nowledge-mem-cursor` | Cursor-native plugin with session-start context, MCP recall, exact-session transcript capture, manual `save-thread`, and summary-only `save-handoff`. | | **[Codex Plugin](nowledge-mem-codex-plugin)** | `codex plugin marketplace add nowledge-co/community --sparse .agents --sparse nowledge-mem-codex-plugin` then `codex plugin add nowledge-mem@nowledge-community`; enable `plugins` and `hooks`, run setup, then trust the hooks when Codex asks | Native startup context and memory routing, bundled MCP retrieval and writes, plus Stop-hook capture of real Codex sessions. Coexists cleanly with Codex local Memory. | +| **[ZCode Plugin](https://github.com/nowledge-co/zcode-plugin)** | In ZCode **Settings → Plugins → Create → Add marketplace**, add `https://github.com/nowledge-co/zcode-plugin`, install `nowledge-mem-zcode`, and reload the Agent runtime | Standalone ZCode-native MCP + Skills package for guided Working Memory, proactive recall, distillation, status, and honest handoff summaries. It does not claim automatic transcript capture. | | **Raft (formerly Slock)** | Configure per-worker environment variables in Raft runtime config | Install the child runtime connector, set `NMEM_AGENT_ID=` per worker, and use Mem skills/MCP inside Raft. Raft-managed Codex rollouts are execution traces and are excluded from Codex Thread capture. | | **Lody** | Configure the child runtime in Lody Agent Config | Runtime launcher setup: install the child runtime connector first; set `NMEM_AGENT_ID=` only when that Agent Config represents a stable role. | | **Multica** | Configure the Multica agent MCP settings and custom environment | Multi-agent orchestrator setup: install the child runtime connector first; for Claude Code agents, save the Mem MCP config on the Multica agent; then set `NMEM_AGENT_ID=` in custom env. | diff --git a/integrations.json b/integrations.json index ff55225f..9e8cdfd2 100644 --- a/integrations.json +++ b/integrations.json @@ -1127,10 +1127,10 @@ "id": "zcode", "name": "ZCode", "category": "coding", - "type": "connector", - "version": null, - "directory": null, - "transport": "mcp+skills", + "type": "plugin", + "version": "0.1.0", + "directory": "nowledge-mem-zcode-plugin", + "transport": "plugin+mcp+skills", "capabilities": { "workingMemory": true, "search": true, @@ -1142,7 +1142,7 @@ }, "threadSave": { "method": "none", - "note": "ZCode supports plugins, MCP servers, hooks, and skills, but Nowledge Mem does not yet publish a ZCode-native hook package. Use MCP and skills now; add transcript import only after the ZCode session/hook contract is verified." + "note": "The ZCode package provides MCP and Skills, but Nowledge Mem does not yet have a verified ZCode transcript path or lifecycle capture contract. Use save-handoff for structured summaries; add transcript import only after the ZCode session/hook contract is independently verified." }, "autonomy": { "bootstrap": "guided", @@ -1150,27 +1150,27 @@ "distill": "guided", "threads": "handoff-only", "bestResultRequires": [ - "Add Nowledge Mem under Settings -> MCP Servers", - "Import or copy the Nowledge Mem skills under Settings -> Skills", - "Use the ZCode Agent restart/reload flow after MCP or skill changes", + "Add https://github.com/nowledge-co/zcode-plugin under ZCode Settings -> Plugins -> Create -> Add marketplace", + "Install and enable nowledge-mem-zcode, then reload the ZCode Agent runtime", + "Use the ZCode-owned MCP settings for remote or custom Mem endpoints", "Ask ZCode to save handoff summaries when a conversation should be searchable later" ] }, "install": { - "command": "nmem config mcp show --host zcode", - "updateCommand": "nmem config mcp show --host zcode", + "command": "Add https://github.com/nowledge-co/zcode-plugin under ZCode Settings -> Plugins -> Create -> Add marketplace, then install nowledge-mem-zcode", + "updateCommand": "Refresh the nowledge-co/zcode-plugin marketplace in ZCode Settings -> Plugins, then update nowledge-mem-zcode", "detectionHint": "Running inside ZCode; ~/.zcode/ exists", "agentGuide": { - "prompt": "Read https://mem.nowledge.co/SKILL.md and follow the instructions to install or update Nowledge Mem for ZCode. Verify with nmem status and the Context Bundle or Working Memory check, then summarize what changed.", - "promptZh": "读取 https://mem.nowledge.co/SKILL.md,按其中说明为 ZCode 安装或更新 Nowledge Mem。用 nmem status 和 Context Bundle 或 Working Memory 检查验证结果,并总结你改了什么。" + "prompt": "Read https://mem.nowledge.co/SKILL.md and follow the instructions to install or update Nowledge Mem for ZCode. Prefer the nowledge-mem-zcode plugin when ZCode plugin support is available. Verify with nmem status and the Context Bundle or Working Memory check, reload ZCode after changes, and summarize what changed.", + "promptZh": "读取 https://mem.nowledge.co/SKILL.md,按其中说明为 ZCode 安装或更新 Nowledge Mem。ZCode 支持插件时优先安装 nowledge-mem-zcode。用 nmem status 和 Context Bundle 或 Working Memory 检查验证结果,修改后重新加载 ZCode,并总结你改了什么。" }, "docsUrl": "/docs/integrations/zcode" }, "toolNaming": { "convention": "mcp-backend", - "note": "ZCode can use manually configured or plugin-provided MCP servers; this connector uses the Nowledge Mem MCP tools." + "note": "ZCode namespaces plugin MCP servers; this package exposes the standard Nowledge Mem MCP tools." }, - "skills": ["read-working-memory", "search-memory", "distill-memory", "save-handoff", "status"], + "skills": ["read-working-memory", "search-memory", "distill-memory", "save-handoff", "status", "check-integration"], "slashCommands": [] }, { diff --git a/nowledge-mem-npx-skills/skills/check-integration/SKILL.md b/nowledge-mem-npx-skills/skills/check-integration/SKILL.md index 5295acef..86e2e06e 100644 --- a/nowledge-mem-npx-skills/skills/check-integration/SKILL.md +++ b/nowledge-mem-npx-skills/skills/check-integration/SKILL.md @@ -95,6 +95,7 @@ The canonical source for this table is `community/integrations.json`. | **Alma** | Running inside Alma; `~/.config/alma/` exists | In Alma: Settings > Plugins > Marketplace, search "Nowledge Mem" | [Guide](https://mem.nowledge.co/docs/integrations/alma) | | **Droid** | Running inside Droid (Factory) | Add nowledge-co/community marketplace, install nowledge-mem@nowledge-community | [Guide](https://mem.nowledge.co/docs/integrations/droid) | | **Codex** | Running inside Codex desktop or Codex CLI; `~/.codex/` exists | `codex plugin marketplace add nowledge-co/community --sparse .agents --sparse nowledge-mem-codex-plugin && codex plugin add nowledge-mem@nowledge-community`, enable `[features] plugins = true`, `hooks = true`, and `[plugins."nowledge-mem@nowledge-community"] enabled = true`, then run the installed `scripts/install_hooks.py`. It adds the legacy `plugin_hooks` gate only when the host still needs it. Restart Codex and trust the Nowledge Mem hooks when prompted. If Codex local Memory is enabled, turn off **Allow memory generation from tool-assisted tasks**. | [Guide](https://mem.nowledge.co/docs/integrations/codex-cli) | +| **ZCode** | Running inside ZCode; `~/.zcode/` exists | In **Settings → Plugins → Create → Add marketplace**, add `https://github.com/nowledge-co/zcode-plugin`, install `nowledge-mem-zcode`, enable it, and reload the Agent runtime. Use `nmem config mcp show --host zcode` in ZCode's own MCP settings for remote Mem. This is guided MCP + Skills with handoff-only threads, not automatic transcript capture. | [Guide](https://mem.nowledge.co/docs/integrations/zcode) | | **Bub** | Running inside Bub | `pip install nowledge-mem-bub` | [Guide](https://mem.nowledge.co/docs/integrations/bub) | | **Pi** | Running as Pi agent; `~/.pi/` exists | `pi install npm:nowledge-mem-pi` | [Guide](https://mem.nowledge.co/docs/integrations/pi) | | **OMP** | Running as OMP agent; `~/.omp/` exists | `omp plugin install nowledge-mem-omp` | [Guide](https://mem.nowledge.co/docs/integrations/omp) | diff --git a/nowledge-mem-zcode-plugin/.mcp.json b/nowledge-mem-zcode-plugin/.mcp.json new file mode 100644 index 00000000..5f20f162 --- /dev/null +++ b/nowledge-mem-zcode-plugin/.mcp.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "nowledge-mem": { + "type": "http", + "url": "http://127.0.0.1:14242/mcp/", + "headers": { + "APP": "ZCode" + } + } + } +} diff --git a/nowledge-mem-zcode-plugin/.zcode-plugin/plugin.json b/nowledge-mem-zcode-plugin/.zcode-plugin/plugin.json new file mode 100644 index 00000000..f0c3f8dd --- /dev/null +++ b/nowledge-mem-zcode-plugin/.zcode-plugin/plugin.json @@ -0,0 +1,20 @@ +{ + "name": "nowledge-mem-zcode", + "version": "0.1.0", + "description": "Guided cross-tool memory for ZCode through Nowledge Mem MCP and Skills.", + "author": { + "name": "Nowledge Labs", + "email": "hello@nowledge-labs.ai", + "url": "https://nowledge-labs.ai" + }, + "homepage": "https://mem.nowledge.co/docs/integrations/zcode", + "repository": "https://github.com/nowledge-co/zcode-plugin", + "license": "MIT", + "keywords": [ + "zcode", + "memory", + "mcp", + "skills", + "nowledge" + ] +} diff --git a/nowledge-mem-zcode-plugin/CHANGELOG.md b/nowledge-mem-zcode-plugin/CHANGELOG.md new file mode 100644 index 00000000..e6c15418 --- /dev/null +++ b/nowledge-mem-zcode-plugin/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## [0.1.0] - 2026-08-08 + +### Added + +- Initial ZCode Plugin package with official `.zcode-plugin/plugin.json` metadata. +- Bundled Nowledge Mem HTTP MCP configuration with a credential-free local default. +- Skills for Context Bundle / Working Memory, proactive search, distillation, status, integration checks, and honest handoff summaries. +- Documentation of local and remote setup, reload behavior, user-owned overrides, and the handoff-only thread boundary. + +### Not included + +- Automatic recall injection, automatic transcript capture, pre-compaction capture, and full `save-thread` import remain deferred until ZCode exposes a verified lifecycle and transcript contract. diff --git a/nowledge-mem-zcode-plugin/README.md b/nowledge-mem-zcode-plugin/README.md new file mode 100644 index 00000000..6440a6a0 --- /dev/null +++ b/nowledge-mem-zcode-plugin/README.md @@ -0,0 +1,192 @@ +# Nowledge Mem for ZCode + +> A ZCode Plugin package that adds guided Nowledge Mem MCP tools and reusable Skills. + +## What it provides + +After the plugin is enabled, ZCode can use the Nowledge Mem MCP server and these Skills: + +- `read-working-memory` — read Context Bundle or Working Memory when starting or resuming work +- `search-memory` — proactively search memories and exact prior threads +- `distill-memory` — save durable decisions, procedures, learnings, and context +- `save-handoff` — save a structured, resumable summary when explicitly requested +- `status` — diagnose Nowledge Mem connectivity +- `check-integration` — verify setup and explain the capability contract + +This is a guided `MCP + Skills` integration. MCP tools are available to the agent, while Skills teach when to use them. Version 0.1.0 does not claim automatic recall injection, automatic full-transcript capture, pre-compaction capture, or `save-thread`: ZCode's session/transcript lifecycle contract has not been verified for this connector. + +## Manual installation + +The plugin package includes `.zcode-plugin/plugin.json` and a `marketplace.json` catalog for the standalone repository `https://github.com/nowledge-co/zcode-plugin`. ZCode has not published a default marketplace directory. For normal installation, use the standalone repository's marketplace source; the community checkout instructions below are only a development/review mirror. + +### macOS/Linux + +For normal installation, add the standalone repository's marketplace source in ZCode using the repository URL: + +```text +https://github.com/nowledge-co/zcode-plugin +``` + +For local development or review of this community checkout, choose a stable checkout location and clone the community repository: + +```bash +COMMUNITY_DIR="$HOME/src/nowledge-community" +git clone https://github.com/nowledge-co/community.git "$COMMUNITY_DIR" +``` + +If you already cloned it, update it later with: + +```bash +git -C "$HOME/src/nowledge-community" pull --ff-only +``` + +Create a persistent local marketplace directory under the user data directory. This is a project-recommended location, not a ZCode-defined default path: + +```bash +COMMUNITY_DIR="$HOME/src/nowledge-community" +MARKETPLACE_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/nowledge/zcode-marketplace" +mkdir -p "$MARKETPLACE_DIR" +python3 - "$MARKETPLACE_DIR" "$COMMUNITY_DIR/nowledge-mem-zcode-plugin" <<'PY' +import json +import pathlib +import sys + +marketplace_dir = pathlib.Path(sys.argv[1]).expanduser().resolve() +plugin_dir = pathlib.Path(sys.argv[2]).expanduser().resolve() +marketplace_dir.mkdir(parents=True, exist_ok=True) +marketplace = { + "name": "nowledge-community-zcode-local", + "description": "Local Nowledge Mem ZCode plugin source", + "plugins": [{ + "name": "nowledge-mem-zcode", + "version": "0.1.0", + "description": "Guided cross-tool memory for ZCode through Nowledge Mem MCP and Skills.", + "source": {"source": "directory", "path": str(plugin_dir)}, + }], +} +(marketplace_dir / "marketplace.json").write_text( + json.dumps(marketplace, indent=2) + "\n", encoding="utf-8" +) +print(f"Add this local marketplace directory in ZCode: {marketplace_dir}") +PY +``` + +Then open a ZCode workspace and: + +1. Go to **Settings → Plugins**. +2. Select **Create → Add marketplace**. +3. Choose the persistent directory printed by the command above. +4. In the **Personal** section, install and enable `nowledge-mem-zcode`. +5. Reload or restart the ZCode Agent runtime. + +The standalone repository's `marketplace.json` is the catalog used by the ZCode marketplace flow; `.zcode-plugin/plugin.json` remains the plugin manifest. The development-only generated catalog above is not a replacement for the standalone repository catalog. + +### Windows PowerShell + +Clone or update the community repository: + +```powershell +$CommunityDir = Join-Path $HOME "src\nowledge-community" +git clone https://github.com/nowledge-co/community.git $CommunityDir +# For an existing checkout instead: +# git -C $CommunityDir pull --ff-only +``` + +Create the persistent user-owned marketplace directory and its catalog: + +```powershell +$CommunityDir = Join-Path $HOME "src\nowledge-community" +$MarketplaceDir = Join-Path $env:LOCALAPPDATA "Nowledge\ZCode\marketplace" +$PluginDir = (Join-Path $CommunityDir "nowledge-mem-zcode-plugin") +New-Item -ItemType Directory -Force -Path $MarketplaceDir | Out-Null +@{ + name = "nowledge-community-zcode-local" + description = "Local Nowledge Mem ZCode plugin source" + plugins = @(@{ + name = "nowledge-mem-zcode" + version = "0.1.0" + description = "Guided cross-tool memory for ZCode through Nowledge Mem MCP and Skills." + source = @{ + source = "directory" + path = (Resolve-Path $PluginDir).Path + } + }) +} | ConvertTo-Json -Depth 5 | Set-Content -Encoding UTF8 (Join-Path $MarketplaceDir "marketplace.json") +Write-Host "Add this local marketplace directory in ZCode: $MarketplaceDir" +``` + +In ZCode, use **Settings → Plugins → Create → Add marketplace**, choose `$MarketplaceDir`, install and enable `nowledge-mem-zcode`, and reload the Agent runtime. + +### Updating the plugin and adding future plugins + +Keep both the community checkout and the user-owned marketplace directory at stable, accessible paths. ZCode does not document whether local marketplace sources are copied, cached, watched, or referenced directly, nor does it document a default storage path. Do not delete or move the source if you want the documented refresh workflow to keep working. + +To update this plugin: + +```bash +git -C "$HOME/src/nowledge-community" pull --ff-only +``` + +Then open **Settings → Plugins → Marketplace sources** and choose **Refresh this marketplace**. Use **Manage installed → Check for updates** when ZCode offers that action, and reload the Agent runtime if components do not appear immediately. + +To add another local plugin in the future, edit the persistent marketplace's `marketplace.json` and append another `plugins[]` entry with a unique `name`, version, description, and a valid absolute `directory` source path. Refresh the marketplace, then install and enable the new plugin from the Personal section. ZCode's documentation does not promise that a newly listed local plugin is automatically installed or that an existing install is automatically upgraded. + +For remote SSH/WSL workspaces, local plugins do not automatically move with the workspace. ZCode documents that marketplace plugins are reinstalled remotely and that the remote environment must be able to reach the marketplace source. Keep the source available on the remote side or use a reachable GitHub/Git source instead. + +## Mem connection + +The package's default `.mcp.json` uses the local Nowledge Mem Desktop endpoint: + +```text +http://127.0.0.1:14242/mcp/ +``` + +Start Nowledge Mem Desktop and verify the CLI when using local mode: + +```bash +nmem --json status +``` + +For Cloud, Access Anywhere, self-hosted, or another remote endpoint, configure the ZCode-owned MCP settings rather than editing the installed package: + +```bash +nmem config client set url https://mem.example.com +nmem config client set api-key nmem_your_key +nmem config mcp show --host zcode +``` + +Paste the generated MCP block into ZCode's own MCP settings and reload the Agent runtime. API keys are intentionally absent from this repository and must not be passed as command-line arguments or written to logs. Direct MCP clients do not automatically inherit `~/.nowledge-mem/config.json`. + +## Capability contract + +| Capability | ZCode behavior in 0.1.0 | +|---|---| +| Context Bundle / Working Memory | Guided by Skills and MCP | +| Memory and thread search | Guided and proactive when relevant | +| Distillation | Guided; search before update/add | +| Status | CLI fallback plus MCP server tools | +| Handoff | Explicit structured summary only | +| Automatic recall injection | Not provided | +| Automatic transcript capture | Not provided | +| Pre-compaction capture | Not provided | +| Full `save-thread` import | Not provided | + +A handoff is not a transcript. Do not describe `save-handoff` as lossless session capture. + +## Customize without editing the plugin + +Do not modify files under ZCode's installed plugin cache. Put project-specific memory guidance in the host's user/project instruction surface when available, or use ZCode's own settings and prompt customization. This keeps changes durable across plugin updates. + +## Permissions and security + +Enabling a third-party ZCode plugin grants it the permissions provided by its declared components. Review the manifest, `.mcp.json`, and Skills before enabling it. This package contains no executable hook or custom runtime process; its MCP server still has the access granted by the ZCode MCP client and the endpoint you configure. + +## Development + +Validate the self-contained package without credentials or a running ZCode UI: + +```bash +node scripts/validate-plugin.mjs +``` + +The repository also has a static integration contract test. There is currently no verified headless ZCode plugin harness, so a successful static test is not a claim of live UI verification. diff --git a/nowledge-mem-zcode-plugin/marketplace.json b/nowledge-mem-zcode-plugin/marketplace.json new file mode 100644 index 00000000..d86157bb --- /dev/null +++ b/nowledge-mem-zcode-plugin/marketplace.json @@ -0,0 +1,21 @@ +{ + "name": "nowledge-zcode", + "description": "Official Nowledge Mem plugin for ZCode.", + "owner": { + "name": "Nowledge Labs", + "email": "hello@nowledge-labs.ai", + "url": "https://nowledge-labs.ai" + }, + "plugins": [ + { + "name": "nowledge-mem-zcode", + "version": "0.1.0", + "description": "Guided cross-tool memory for ZCode through Nowledge Mem MCP and Skills.", + "category": "knowledge", + "tags": ["memory", "mcp", "skills", "zcode"], + "source": ".", + "homepage": "https://mem.nowledge.co/docs/integrations/zcode", + "repository": "https://github.com/nowledge-co/zcode-plugin" + } + ] +} diff --git a/nowledge-mem-zcode-plugin/scripts/validate-plugin.mjs b/nowledge-mem-zcode-plugin/scripts/validate-plugin.mjs new file mode 100644 index 00000000..65b02c3a --- /dev/null +++ b/nowledge-mem-zcode-plugin/scripts/validate-plugin.mjs @@ -0,0 +1,151 @@ +#!/usr/bin/env node + +import { readFileSync, readdirSync, statSync } from "node:fs"; +import { join, relative } from "node:path"; +import { fileURLToPath } from "node:url"; + +const pluginRoot = fileURLToPath(new URL("..", import.meta.url)); +const manifestPath = join(pluginRoot, ".zcode-plugin", "plugin.json"); +const marketplacePath = join(pluginRoot, "marketplace.json"); +const mcpPath = join(pluginRoot, ".mcp.json"); +const expectedSkills = [ + "check-integration", + "read-working-memory", + "search-memory", + "distill-memory", + "save-handoff", + "status", +]; + +function fail(message) { + console.error(`ZCode plugin validation failed: ${message}`); + process.exitCode = 1; +} + +function readJson(path, label) { + try { + return JSON.parse(readFileSync(path, "utf8")); + } catch (error) { + const detail = error instanceof Error ? error.message : String(error); + throw new Error(`${label} is not valid JSON: ${detail}`); + } +} + +function requireString(value, label) { + if (typeof value !== "string" || value.trim() === "") { + throw new Error(`${label} must be a non-empty string`); + } +} + +function validateManifest(manifest) { + requireString(manifest.name, "manifest.name"); + if (!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(manifest.name)) { + throw new Error("manifest.name does not match the ZCode name format"); + } + requireString(manifest.version, "manifest.version"); + if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(manifest.version)) { + throw new Error("manifest.version must be a semantic version"); + } + requireString(manifest.description, "manifest.description"); + if (!manifest.author || typeof manifest.author !== "object") { + throw new Error("manifest.author must be an object"); + } + requireString(manifest.author.name, "manifest.author.name"); + if (manifest.hooks !== undefined || manifest.agents !== undefined) { + throw new Error("0.1.0 does not declare unverified hooks or agents"); + } +} + +function validateMarketplace(marketplace, manifest) { + if (!marketplace || typeof marketplace !== "object") { + throw new Error("marketplace.json must contain an object"); + } + requireString(marketplace.name, "marketplace.name"); + if (!Array.isArray(marketplace.plugins) || marketplace.plugins.length !== 1) { + throw new Error("marketplace.json must declare exactly one plugin"); + } + const plugin = marketplace.plugins[0]; + if (!plugin || plugin.name !== manifest.name || plugin.version !== manifest.version) { + throw new Error("marketplace plugin name/version must match plugin.json"); + } + if (plugin.source !== ".") { + throw new Error("marketplace plugin source must be the standalone package root (.)"); + } + if (plugin.repository !== "https://github.com/nowledge-co/zcode-plugin") { + throw new Error("marketplace plugin repository must point to the standalone repository"); + } +} + +function validateMcp(mcp) { + if (!mcp.mcpServers || typeof mcp.mcpServers !== "object") { + throw new Error(".mcp.json must contain mcpServers"); + } + const names = Object.keys(mcp.mcpServers); + if (names.length !== 1 || names[0] !== "nowledge-mem") { + throw new Error(".mcp.json must declare exactly the nowledge-mem server"); + } + const server = mcp.mcpServers["nowledge-mem"]; + if (!server || server.type !== "http") { + throw new Error("nowledge-mem MCP server must use the ZCode http transport"); + } + requireString(server.url, "nowledge-mem.url"); + const url = new URL(server.url); + if (!/^https?:$/.test(url.protocol)) { + throw new Error("nowledge-mem.url must use http or https"); + } + const serialized = JSON.stringify(mcp).toLowerCase(); + for (const forbidden of ["api-key", "api_key", "authorization", "bearer", "password", "secret"]) { + if (serialized.includes(forbidden)) { + throw new Error(`.mcp.json contains a credential field: ${forbidden}`); + } + } +} + +function validateSkills() { + const skillsRoot = join(pluginRoot, "skills"); + const actualSkills = readdirSync(skillsRoot).filter((name) => + statSync(join(skillsRoot, name)).isDirectory(), + ).sort(); + if (JSON.stringify(actualSkills) !== JSON.stringify([...expectedSkills].sort())) { + throw new Error(`skills must be exactly: ${expectedSkills.join(", ")}`); + } + for (const skillName of expectedSkills) { + const skillPath = join(skillsRoot, skillName, "SKILL.md"); + const source = readFileSync(skillPath, "utf8"); + const match = source.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n/); + if (!match) { + throw new Error(`${relative(pluginRoot, skillPath)} is missing YAML frontmatter`); + } + const frontmatter = match[1]; + const name = frontmatter.match(/^name:\s*(.+)$/m)?.[1]?.trim(); + const description = frontmatter.match(/^description:\s*(.+)$/m)?.[1]?.trim(); + if (name !== skillName) { + throw new Error(`${relative(pluginRoot, skillPath)} has frontmatter name ${name ?? ""}`); + } + if (!description || description.length > 1024) { + throw new Error(`${relative(pluginRoot, skillPath)} needs a description of 1-1024 characters`); + } + if (/^name:\s*save-thread\s*$/m.test(frontmatter)) { + throw new Error(`${relative(pluginRoot, skillPath)} must not declare save-thread`); + } + } +} + +try { + const manifest = readJson(manifestPath, ".zcode-plugin/plugin.json"); + validateManifest(manifest); + validateMarketplace(readJson(marketplacePath, "marketplace.json"), manifest); + validateMcp(readJson(mcpPath, ".mcp.json")); + validateSkills(); + for (const forbiddenPath of ["hooks", "agents"]) { + try { + statSync(join(pluginRoot, forbiddenPath)); + throw new Error(`unexpected ${forbiddenPath}/ directory`); + } catch (error) { + if (error?.code !== "ENOENT") throw error; + } + } + console.log("ZCode plugin validation passed"); +} catch (error) { + fail(error instanceof Error ? error.message : String(error)); +} diff --git a/nowledge-mem-zcode-plugin/skills/check-integration/SKILL.md b/nowledge-mem-zcode-plugin/skills/check-integration/SKILL.md new file mode 100644 index 00000000..ccc437c4 --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/check-integration/SKILL.md @@ -0,0 +1,62 @@ +--- +name: check-integration +description: Check Nowledge Mem setup in ZCode, explain what the plugin provides, and guide local or remote MCP configuration when memory tools are unavailable. +--- + +# Check ZCode Integration + +Use this when Nowledge Mem setup is new, a memory tool is missing, or the user asks whether the integration is working. + +## Step 1: Verify the client + +Run: + +```bash +nmem --json status +``` + +If the command is missing, use the Nowledge Mem desktop app's bundled CLI installation, or install the standalone `nmem-cli` on a separate client machine. Do not replace a desktop-managed CLI with a standalone install unless the user asks for that. + +If status fails: + +- local machine: open Nowledge Mem Desktop and retry; +- remote machine: verify the URL and API key in the user's own client configuration; +- ZCode: check **Settings → MCP → Plugin MCP servers**, then reload/restart the Agent runtime. + +Never put an API key in a command argument, plugin file, or log. + +## Step 2: Install for ZCode + +In ZCode, open **Settings → Plugins → Create → Add marketplace**, add: + +```text +https://github.com/nowledge-co/zcode-plugin +``` + +Install and enable `nowledge-mem-zcode`, then reload the Agent runtime. After a standalone repository update, use **Marketplace sources → Refresh this marketplace**, then **Manage installed → Check for updates** for `nowledge-mem-zcode`, and reload if components do not appear immediately. + +## Expected behavior + +This ZCode package provides: + +- **Working Memory and Context Bundle:** guided through Skills and MCP; +- **Recall:** guided proactive searches across memories and threads; +- **Distillation:** guided durable saves using search-before-update/add; +- **Status:** CLI/MCP diagnostics; +- **Threads:** explicit structured handoff summaries only. + +It does **not** provide automatic recall injection, automatic full-transcript capture, pre-compaction capture, or a `save-thread` operation. The current registry intentionally remains `plugin+mcp+skills`, `autoCapture: false`, and `handoff-only` until ZCode's session and hook contract is verified. + +## Local installation + +For local testing, add the repository's ZCode marketplace or plugin directory from **Settings → Plugins → Create → Add marketplace**, install the ZCode package, enable it, and reload the Agent runtime. After package changes, refresh the marketplace source. + +## Remote Mem + +Do not edit installed plugin files. Configure the user's own ZCode MCP settings with: + +```bash +nmem config mcp show --host zcode +``` + +Paste the generated host-owned MCP block into ZCode and reload the Agent runtime. This is the supported path for Cloud, Access Anywhere, self-hosted, or any endpoint requiring authentication. diff --git a/nowledge-mem-zcode-plugin/skills/distill-memory/SKILL.md b/nowledge-mem-zcode-plugin/skills/distill-memory/SKILL.md new file mode 100644 index 00000000..ee4204fa --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/distill-memory/SKILL.md @@ -0,0 +1,42 @@ +--- +name: distill-memory +description: Save durable Nowledge Mem facts, preferences, decisions, plans, procedures, learnings, events, and important context when a ZCode conversation produces something worth remembering; do not wait to be asked. +--- + +# Distill Memory + +Save proactively when the conversation produces a durable fact, preference, decision, plan, procedure, learning, event, or important context. Do not wait to be asked. + +## Good candidates + +- Decisions with their rationale +- Repeatable procedures and non-obvious workarounds +- Lessons from debugging, incidents, or root-cause analysis +- Durable preferences or constraints +- Plans needed to resume work later +- Important context that would otherwise be lost + +Skip routine fixes, unstable work in progress, generic facts, and simple documentation answers. + +## Workflow + +1. Search first with MCP `memory_search` to avoid duplicates. +2. If the same decision, procedure, or preference already exists, refine it with `memory_update`. +3. Otherwise use `memory_add` with an atomic title and standalone content. +4. Use the matching `unit_type` (`fact`, `preference`, `decision`, `plan`, `procedure`, `learning`, `context`, or `event`) and meaningful labels/importance when known. +5. At the end of a substantial task, explicitly review whether one durable memory should be added or updated. + +Keep the new memory focused on what was learned or decided, not routine activity. If an ambient space is real and known, write to that space; otherwise keep the default lane. + +## CLI fallback + +If MCP is unavailable, use the active ambient space when one is known: + +```bash +nmem --json m search "" --space "" +nmem --json m add "" -t "" --unit-type decision -l "<label>" -i 0.8 --space "<space name>" +``` + +If no real ambient space is configured, omit `--space` and use the default lane. + +Use `nmem --json m update <memory_id> --content "<updated content>"` when an existing memory should evolve. diff --git a/nowledge-mem-zcode-plugin/skills/read-working-memory/SKILL.md b/nowledge-mem-zcode-plugin/skills/read-working-memory/SKILL.md new file mode 100644 index 00000000..28a7a57d --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/read-working-memory/SKILL.md @@ -0,0 +1,46 @@ +--- +name: read-working-memory +description: Read Nowledge Mem Context Bundle or Working Memory at the beginning of a ZCode session, when resuming work, or when the user asks about current priorities and context. +--- + +# Read Working Memory + +Start with the context that matters. When the Nowledge Mem MCP server is available, prefer `read_context_bundle` when identity, active space, rules, and Working Memory all matter. Use `read_working_memory` for a lightweight briefing. + +## When to use + +- Beginning a new conversation or returning to a project +- Resuming a review, regression, release, or earlier decision +- The user asks what they are working on or what the current context is + +## How to use + +1. Read the Context Bundle once when the task needs owner identity, AI Identity, active scope, active rules, or Working Memory. +2. Otherwise read Working Memory once near session start. +3. If Context Bundle already includes Working Memory, do not call it again unless the user asks or the session changes materially. +4. Use only relevant parts in the response; do not overwhelm the user. +5. For continuation work, follow the briefing with `search-memory` instead of stopping at the briefing. + +The MCP tool names are provided by ZCode's Nowledge Mem server. Do not invent host-specific tool names or claim that this Skill itself injects context automatically. + +## CLI fallback + +If MCP is unavailable and the `nmem` CLI is configured, use the active ambient space when one is known: + +```bash +nmem --json context --source-app zcode --space "<space name>" +``` + +For a lightweight briefing: + +```bash +nmem --json wm read --space "<space name>" +``` + +If no real ambient space is configured, omit `--space` and use the default lane. + +If the result says `exists: false`, explain that no Working Memory briefing exists yet and continue normally. If the command fails, report the connection issue without polluting the user's task. + +## Spaces + +If ZCode or the user provides a real ambient space, pass it through explicitly. Otherwise stay on the Default space; do not invent a new space because a prompt mentions a new topic. diff --git a/nowledge-mem-zcode-plugin/skills/save-handoff/SKILL.md b/nowledge-mem-zcode-plugin/skills/save-handoff/SKILL.md new file mode 100644 index 00000000..cea0b262 --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/save-handoff/SKILL.md @@ -0,0 +1,34 @@ +--- +name: save-handoff +description: Save a concise, structured Nowledge Mem handoff when the ZCode user explicitly requests a checkpoint, resumable summary, or place to continue later. +--- + +# Save Handoff + +Use this only when the user explicitly asks for a handoff, checkpoint, summary to resume later, or to remember where the work stands. + +This Skill creates a structured summary. It is **not** a full transcript import. ZCode's current Nowledge Mem integration has no verified transcript path or lifecycle contract, so do not call it `save-thread` and do not claim that the complete conversation was preserved. + +## Handoff format + +Include: + +- **Goal** +- **Decisions** +- **Files** +- **Risks** +- **Next** + +Prefer MCP thread creation when available. Otherwise use: + +```bash +nmem --json t create \ + -t "Session Handoff - <topic>" \ + -c "Goal: ... Decisions: ... Files: ... Risks: ... Next: ..." \ + --source zcode \ + --space "<space name>" +``` + +If no real ambient space is configured, omit `--space` and use the default lane. + +After success, report that a handoff was saved, include its title and thread ID when available, and state that it is a summary rather than a transcript import. If saving fails, report the error and do not imply that a checkpoint exists. diff --git a/nowledge-mem-zcode-plugin/skills/search-memory/SKILL.md b/nowledge-mem-zcode-plugin/skills/search-memory/SKILL.md new file mode 100644 index 00000000..085eabe5 --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/search-memory/SKILL.md @@ -0,0 +1,55 @@ +--- +name: search-memory +description: Proactively search Nowledge Mem memories and prior threads when earlier work, decisions, procedures, regressions, or exact conversation history could improve a ZCode response. +--- + +# Search Memory + +Search before rediscovering. Use Nowledge Mem when past knowledge would make the current task sharper; do not wait for the user to say “search my memory.” + +## Search signals + +Search strongly when: + +- The user references previous work, a prior fix, or an earlier decision +- The task resumes a named feature, bug, refactor, incident, release, or subsystem +- The user asks for rationale, procedures, or exact prior conversation history +- A current debugging pattern resembles something solved earlier +- The user says “like before,” “that approach,” or similar recall language + +For durable knowledge, use the MCP `memory_search` tool. For exact prior conversations, use `thread_search` and then fetch only the relevant messages with `thread_fetch_messages`. If the first results are weak, use deeper matching rather than over-fetching. + +## Routing rules + +1. Search memories first for decisions, facts, procedures, and learnings. +2. Search threads when the user needs the prior conversation itself. +3. Inspect the smallest result set that answers the question. +4. Keep an ambient space in the host's real lane; cross-space retrieval must be explicit. +5. Summarize only the strongest matches and say when nothing relevant was found. + +## Knowledge Filesystem (optional, host-specific) + +When the task needs nearby objects or a tree-like view, and the connected ZCode MCP server exposes the optional Knowledge Filesystem, use its `mem_fs` surface. The examples below are not guaranteed to be available in every host and the returned paths are Nowledge Mem object identifiers, not local operating-system paths: + +```text +capabilities +recall "session token strategy" --in /memories -k 5 +find /memories --label decisions --since 2026-01-01 +grep "JWT rotation" /memories +cat /memories/by-id/<id>.memory.md +``` + +Call `capabilities` before assuming roots or verbs. These paths identify Nowledge Mem objects; they are not local operating-system paths. + +## CLI fallback + +If the MCP server is unavailable, use the active ambient space when one is known: + +```bash +nmem --json m search "<query>" --space "<space name>" +nmem --json t search "<query>" --limit 5 --space "<space name>" +``` + +If no real ambient space is configured, omit `--space` and use the default lane. Do not invent a space merely because the topic changes. + +Use `nmem --json t show <thread_id> --limit 8 --offset 0 --content-limit 1200 --space "<space name>"` only after a thread result identifies a relevant conversation. If no real ambient space is configured, omit `--space`. diff --git a/nowledge-mem-zcode-plugin/skills/status/SKILL.md b/nowledge-mem-zcode-plugin/skills/status/SKILL.md new file mode 100644 index 00000000..c2f01a7f --- /dev/null +++ b/nowledge-mem-zcode-plugin/skills/status/SKILL.md @@ -0,0 +1,33 @@ +--- +name: status +description: Check whether Nowledge Mem is reachable and configured for ZCode, especially after setup or when memory operations fail. +--- + +# Status + +Run a quick health check when the user asks whether Mem is working, when an operation fails, or after initial setup. + +```bash +nmem --json status +``` + +Interpret the result briefly: + +- report reachability, mode, server version, and memory count when healthy; +- if there is no briefing or data yet, distinguish that from a connection failure; +- do not print API keys or copy credentials into logs. + +The CLI check and ZCode MCP check are separate diagnostics. A remote or custom ZCode MCP endpoint can be healthy even when the local CLI is not configured for the same server. + +If the local CLI check fails: + +1. **Local:** open the Nowledge Mem desktop app and retry. +2. **Remote CLI:** verify the URL and API key in the user's own `nmem` client configuration. + +For the ZCode MCP path, use the server's status tool when it is available. For remote or custom Mem, generate the host-owned configuration, paste it into ZCode's own MCP settings, and reload the Agent runtime: + +```bash +nmem config mcp show --host zcode +``` + +Do not treat a local `nmem --json status` failure as proof that the ZCode MCP server is unavailable, or vice versa. diff --git a/tests/plugin_e2e/test_key_plugins_e2e.py b/tests/plugin_e2e/test_key_plugins_e2e.py index b2b6317d..676d6bb1 100644 --- a/tests/plugin_e2e/test_key_plugins_e2e.py +++ b/tests/plugin_e2e/test_key_plugins_e2e.py @@ -41,6 +41,7 @@ BENCH_PACKAGE = COMMUNITY_ROOT / "nowledge-mem-bench" ALMA_PLUGIN = COMMUNITY_ROOT / "nowledge-mem-alma-plugin" AMP_PLUGIN = COMMUNITY_ROOT / "nowledge-mem-amp-plugin" +ZCODE_PLUGIN = COMMUNITY_ROOT / "nowledge-mem-zcode-plugin" KEY_HOSTS = {"claude", "codex", "openclaw", "hermes", "opencode", "pi"} @@ -1489,7 +1490,7 @@ def test_registry_connect_contract_points_agent_prompts_to_universal_skill(): assert "nmem t sync --from antigravity" in by_id["antigravity-extractor"][ "autonomy" ]["bestResultRequires"][0] - for connector_id in ["zcode", "mimo-code"]: + for connector_id in ["mimo-code"]: connector = by_id[connector_id] assert connector["version"] is None assert connector["transport"] == "mcp+skills" @@ -1504,6 +1505,9 @@ def test_registry_connect_contract_points_agent_prompts_to_universal_skill(): assert connector["threadSave"]["historicalCommand"] == ( f"nmem t sync --from {connector_id}" ) + assert by_id["zcode"]["version"] == "0.1.0" + assert by_id["zcode"]["directory"] == "nowledge-mem-zcode-plugin" + assert by_id["zcode"]["transport"] == "plugin+mcp+skills" assert by_id["zcode"]["threadSave"]["method"] == "none" assert by_id["zcode"]["autonomy"]["threads"] == "handoff-only" assert by_id["alma"]["version"] == "0.7.4" @@ -1527,6 +1531,84 @@ def test_registry_connect_contract_points_agent_prompts_to_universal_skill(): assert "nowledge_mem_context_bundle" in by_id["opencode"]["toolNaming"]["tools"] +def test_zcode_plugin_static_contract_is_self_contained(): + manifest = _read_json(ZCODE_PLUGIN / ".zcode-plugin" / "plugin.json") + marketplace = _read_json(ZCODE_PLUGIN / "marketplace.json") + mcp = _read_json(ZCODE_PLUGIN / ".mcp.json") + readme = (ZCODE_PLUGIN / "README.md").read_text(encoding="utf-8") + changelog = (ZCODE_PLUGIN / "CHANGELOG.md").read_text(encoding="utf-8") + registry = _read_json(COMMUNITY_ROOT / "integrations.json") + zcode_registry = next(item for item in registry["integrations"] if item.get("id") == "zcode") + expected_skills = [ + "check-integration", + "read-working-memory", + "search-memory", + "distill-memory", + "save-handoff", + "status", + ] + + assert manifest["name"] == "nowledge-mem-zcode" + assert manifest["version"] == "0.1.0" + assert manifest["repository"] == "https://github.com/nowledge-co/zcode-plugin" + assert marketplace["plugins"] == [ + { + "name": "nowledge-mem-zcode", + "version": "0.1.0", + "description": "Guided cross-tool memory for ZCode through Nowledge Mem MCP and Skills.", + "category": "knowledge", + "tags": ["memory", "mcp", "skills", "zcode"], + "source": ".", + "homepage": "https://mem.nowledge.co/docs/integrations/zcode", + "repository": "https://github.com/nowledge-co/zcode-plugin", + } + ] + assert not (COMMUNITY_ROOT / "marketplace.json").exists() + assert "git clone" in readme + assert "marketplace.json" in readme + assert "persistent" in readme.lower() + assert "Refresh this marketplace" in readme + assert "Add marketplace" in readme + assert "not a ZCode-defined default path" in readme + assert "separate Git" not in readme + assert "submodule" not in readme + assert "https://github.com/nowledge-co/zcode-plugin" in readme + assert "community/tree/main/marketplace.json" not in (COMMUNITY_ROOT / "README.md").read_text(encoding="utf-8") + assert "https://github.com/nowledge-co/zcode-plugin" in (COMMUNITY_ROOT / "README.md").read_text(encoding="utf-8") + assert "https://github.com/nowledge-co/zcode-plugin" in (COMMUNITY_ROOT / "nowledge-mem-npx-skills" / "skills" / "check-integration" / "SKILL.md").read_text(encoding="utf-8") + assert zcode_registry["type"] == "plugin" + assert zcode_registry["version"] == manifest["version"] + assert zcode_registry["directory"] == "nowledge-mem-zcode-plugin" + assert zcode_registry["transport"] == "plugin+mcp+skills" + assert zcode_registry["capabilities"]["autoRecall"] is False + assert zcode_registry["capabilities"]["autoCapture"] is False + assert zcode_registry["threadSave"]["method"] == "none" + assert zcode_registry["autonomy"]["threads"] == "handoff-only" + assert zcode_registry["skills"] == [ + "read-working-memory", + "search-memory", + "distill-memory", + "save-handoff", + "status", + "check-integration", + ] + assert mcp["mcpServers"]["nowledge-mem"]["type"] == "http" + assert mcp["mcpServers"]["nowledge-mem"]["url"] == "http://127.0.0.1:14242/mcp/" + assert mcp["mcpServers"]["nowledge-mem"]["headers"]["APP"] == "ZCode" + assert "Authorization" not in json.dumps(mcp) + assert "X-NMEM-API-Key" not in json.dumps(mcp) + assert not (ZCODE_PLUGIN / "hooks").exists() + assert not (ZCODE_PLUGIN / "agents").exists() + assert not (ZCODE_PLUGIN / "skills" / "save-thread").exists() + for skill in expected_skills: + source = (ZCODE_PLUGIN / "skills" / skill / "SKILL.md").read_text(encoding="utf-8") + assert f"name: {skill}" in source + assert "description:" in source + assert "save-handoff" in readme + assert "not a transcript" in readme.lower() + assert "0.1.0" in changelog + + def test_opencode_plugin_static_contract_is_self_contained(): pkg = _read_json(OPENCODE_PLUGIN / "package.json") source = (OPENCODE_PLUGIN / "src" / "index.ts").read_text(encoding="utf-8")