Skip to content
Draft
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added

- `mnemon setup --target zcode` now installs a ZCode-compatible Mnemon skill.
With `--global`, setup also registers user-level `SessionStart`,
`UserPromptSubmit`, and `Stop` process hooks in
`~/.zcode/cli/config.json`; project-local setup intentionally skips hooks
because ZCode does not execute project-level hook configuration.
- `mnemon setup --eject --target zcode` removes Mnemon-owned ZCode files and
hook entries while preserving unrelated skills, hook events, and settings.

### Tests

- Added ZCode coverage for embedded artifacts, hook registration, unrelated
configuration preservation, and scoped eject cleanup.

## [0.1.15] - 2026-06-18

### Added
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ One command deploys the mnemon skill, prompt files, and Cursor lifecycle hooks
to `.cursor/`. The integration primes new agent sessions with Mnemon guidance
and memory status, then nudges for durable-memory writeback after responses.

### [ZCode](https://zcode.z.ai/)

```bash
mnemon setup --target zcode --global --yes
```

ZCode installs the Mnemon skill under `~/.zcode/skills/` and registers
user-level lifecycle hooks in `~/.zcode/cli/config.json`. The hooks prime new
sessions, add recall guidance before model calls, and prompt for durable-memory
writeback at stop. Without `--global`, setup installs only the project skill;
ZCode currently ignores project-level hook configuration.

### [TRAE](https://www.trae.ai/) (TRAE Work)

```bash
Expand Down Expand Up @@ -319,7 +331,7 @@ memory is useful.

- **Zero user-side operation** — install once; supported runtimes can use hooks, minimal runtimes can use persistent rules
- **LLM-supervised** — the host LLM decides what to remember, update, and forget; no embedded LLM, no API keys
- **Multi-framework support** — Claude Code, Codex, Cursor, TRAE/TRAE Work, Qoder/QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, and Hermes Agent (hooks/plugins), OpenClaw (plugins), Pi (extensions), Nanobot (skills), DeepSeek Harness (via the dsh-mnemon plugin), and more
- **Multi-framework support** — Claude Code, Codex, Cursor, ZCode, TRAE/TRAE Work, Qoder/QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, and Hermes Agent (hooks/plugins), OpenClaw (plugins), Pi (extensions), Nanobot (skills), DeepSeek Harness (via the dsh-mnemon plugin), and more
- **Runtime-native integration** — runtime-specific `SKILL.md`, shared `guide.md`, and supported hooks or extensions
- **Four-graph architecture** — temporal, entity, causal, and semantic edges, not just vector similarity
- **Intent-native protocol** — three primitives (`remember`, `link`, `recall`) map to the LLM's cognitive vocabulary, not database syntax; structured JSON output with signal transparency
Expand Down Expand Up @@ -370,7 +382,7 @@ All your local agentic AIs — across sessions and frameworks — sharing one po
```

The foundation is in place: a single `~/.mnemon` database that any agent can
read and write. Claude Code, Codex, Cursor, TRAE/TRAE Work, Qoder/QoderWork,
read and write. Claude Code, Codex, Cursor, ZCode, TRAE/TRAE Work, Qoder/QoderWork,
CodeBuddy, WorkBuddy, Kimi Code, OpenCode, and Hermes Agent setup automate hook/plugin installation;
OpenClaw can use plugin hooks; Pi integrates via native skills and TypeScript
lifecycle extensions; Nanobot integrates via skill files; NanoClaw integrates
Expand Down
120 changes: 113 additions & 7 deletions cmd/memory/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ var setupCmd = &cobra.Command{
Short: "Deploy mnemon into LLM CLI environments",
Long: `Detect installed LLM CLIs and deploy mnemon integration.

By default, installs to project-local config (.claude/, .codex/, .cursor/, .trae/, .qoder/, .codebuddy/, .workbuddy/, .opencode/, .openclaw/, .nanobot/, .pi/).
Use --global to install to user-wide config (~/.claude/, ~/.codex/, ~/.cursor/, ~/.trae/, ~/.qoder/, ~/.codebuddy/, ~/.workbuddy/, ~/.config/opencode/, ~/.openclaw/, ~/.nanobot/workspace/, ~/.pi/agent/).
By default, installs to project-local config (.claude/, .codex/, .cursor/, .zcode/, .trae/, .qoder/, .codebuddy/, .workbuddy/, .opencode/, .openclaw/, .nanobot/, .pi/).
Use --global to install to user-wide config (~/.claude/, ~/.codex/, ~/.cursor/, ~/.zcode/, ~/.trae/, ~/.qoder/, ~/.codebuddy/, ~/.workbuddy/, ~/.config/opencode/, ~/.openclaw/, ~/.nanobot/workspace/, ~/.pi/agent/).
Hermes Agent, QoderWork, and Kimi Code use native user config at ~/.hermes/, ~/.qoderwork/, and ~/.kimi-code/.

Supported environments: Claude Code, Codex, Cursor, Trae, Qoder, QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, OpenClaw, Nanobot, Pi, Hermes Agent.
Supported environments: Claude Code, Codex, Cursor, ZCode, Trae, Qoder, QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, OpenClaw, Nanobot, Pi, Hermes Agent.

Examples:
mnemon setup # Interactive: project-local install
mnemon setup --global # Interactive: user-wide install
mnemon setup --target claude-code # Non-interactive: Claude Code only
mnemon setup --target cursor # Non-interactive: Cursor skill only
mnemon setup --target zcode --global # Non-interactive: ZCode skill and user hooks
mnemon setup --target trae # Non-interactive: Trae skill and hooks
mnemon setup --target qoder # Non-interactive: Qoder skill and hooks
mnemon setup --target qoderwork # Non-interactive: QoderWork skill and hooks
Expand All @@ -48,16 +49,16 @@ Examples:
}

func init() {
setupCmd.Flags().StringVar(&setupTarget, "target", "", "target environment (claude-code, codex, cursor, trae, qoder, qoderwork, codebuddy, workbuddy, kimi, opencode, openclaw, nanobot, pi, hermes)")
setupCmd.Flags().StringVar(&setupTarget, "target", "", "target environment (claude-code, codex, cursor, zcode, trae, qoder, qoderwork, codebuddy, workbuddy, kimi, opencode, openclaw, nanobot, pi, hermes)")
setupCmd.Flags().BoolVar(&setupEject, "eject", false, "remove mnemon integrations")
setupCmd.Flags().BoolVar(&setupYes, "yes", false, "auto-confirm all prompts (CI-friendly)")
setupCmd.Flags().BoolVar(&setupGlobal, "global", false, "install to user-wide config instead of project-local config")
rootCmd.AddCommand(setupCmd)
}

func runSetup(cmd *cobra.Command, args []string) error {
if setupTarget != "" && setupTarget != "claude-code" && setupTarget != "codex" && setupTarget != "cursor" && setupTarget != "trae" && setupTarget != "qoder" && setupTarget != "qoderwork" && setupTarget != "codebuddy" && setupTarget != "workbuddy" && setupTarget != "kimi" && setupTarget != "opencode" && setupTarget != "openclaw" && setupTarget != "nanobot" && setupTarget != "pi" && setupTarget != "hermes" {
return fmt.Errorf("invalid target %q (must be claude-code, codex, cursor, trae, qoder, qoderwork, codebuddy, workbuddy, kimi, opencode, openclaw, nanobot, pi, or hermes)", setupTarget)
if setupTarget != "" && setupTarget != "claude-code" && setupTarget != "codex" && setupTarget != "cursor" && setupTarget != "zcode" && setupTarget != "trae" && setupTarget != "qoder" && setupTarget != "qoderwork" && setupTarget != "codebuddy" && setupTarget != "workbuddy" && setupTarget != "kimi" && setupTarget != "opencode" && setupTarget != "openclaw" && setupTarget != "nanobot" && setupTarget != "pi" && setupTarget != "hermes" {
return fmt.Errorf("invalid target %q (must be claude-code, codex, cursor, zcode, trae, qoder, qoderwork, codebuddy, workbuddy, kimi, opencode, openclaw, nanobot, pi, or hermes)", setupTarget)
}

envs := setup.DetectEnvironments(setupGlobal)
Expand Down Expand Up @@ -93,7 +94,7 @@ func runInstallFlow(envs []setup.Environment) error {

if len(detected) == 0 {
fmt.Println("\nNo supported LLM CLI environments detected.")
fmt.Println("Install Claude Code, Codex, Cursor, Trae, Qoder, QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, OpenClaw, Nanobot, Pi, or Hermes Agent, then run 'mnemon setup' again.")
fmt.Println("Install Claude Code, Codex, Cursor, ZCode, Trae, Qoder, QoderWork, CodeBuddy, WorkBuddy, Kimi Code, OpenCode, OpenClaw, Nanobot, Pi, or Hermes Agent, then run 'mnemon setup' again.")
return nil
}

Expand Down Expand Up @@ -139,6 +140,8 @@ func installEnv(env *setup.Environment) error {
err = installCodex(env)
case "cursor":
err = installCursor(env)
case "zcode":
err = installZCode(env)
case "trae":
err = installTrae(env)
case "qoder":
Expand Down Expand Up @@ -510,6 +513,103 @@ func selectCursorOptionalHooks() setup.HookSelection {
return sel
}

// ─── ZCode ─────────────────────────────────────────────────────────

func installZCode(env *setup.Environment) error {
configDir := env.ConfigDir
globalInstall := setupGlobal

if !setupGlobal && !setupYes && setup.IsInteractive() {
home := setup.HomeDir()
localDir := ".zcode"
globalDir := home + "/.zcode"
idx := setup.SelectOne("Install scope",
[]string{
fmt.Sprintf("Local — skill for this project only (%s/)", localDir),
fmt.Sprintf("Global — skill and lifecycle hooks (%s/)", globalDir),
}, 0)
if idx == 1 {
configDir = globalDir
globalInstall = true
} else {
configDir = localDir
}
}

totalSteps := 2
if globalInstall {
totalSteps = 4
}
fmt.Printf("\nSetting up ZCode (%s)...\n", configDir)

fmt.Printf("\n[1/%d] Skill\n", totalSteps)
if path, err := setup.ZCodeWriteSkill(configDir); err != nil {
setup.StatusError(0, 0, "Skill", err)
return err
} else {
setup.StatusOK(0, 0, "Skill", path)
}

fmt.Printf("\n[2/%d] Prompts\n", totalSteps)
var promptPath string
if path, err := setup.WritePromptFiles(); err != nil {
setup.StatusError(0, 0, "Prompts", err)
return err
} else {
setup.StatusOK(0, 0, "Prompts", path)
promptPath = path
}

if !globalInstall {
fmt.Println()
fmt.Println("Setup complete!")
fmt.Printf(" Skill %s/skills/mnemon/SKILL.md\n", configDir)
fmt.Printf(" Prompts %s/ (guide.md, skill.md)\n", promptPath)
fmt.Println()
fmt.Println("ZCode currently ignores project-level hooks; use '--global' to install lifecycle hooks.")
fmt.Println("Refresh Settings → Skills or start a new ZCode session to activate.")
fmt.Println("Run 'mnemon setup --eject --target zcode' to remove.")
return nil
}

fmt.Printf("\n[3/%d] Hooks\n", totalSteps)
hooks := []struct {
label, filename string
content []byte
}{
{label: "Hook: prime", filename: "prime.sh", content: assets.ZCodePrimeHook},
{label: "Hook: remind", filename: "user_prompt.sh", content: assets.ZCodeUserPromptHook},
{label: "Hook: nudge", filename: "stop.sh", content: assets.ZCodeStopHook},
}
for _, hook := range hooks {
if path, err := setup.ZCodeWriteHook(configDir, hook.filename, hook.content); err != nil {
setup.StatusError(0, 0, hook.label, err)
return err
} else {
setup.StatusOK(0, 0, hook.label, path)
}
}

fmt.Printf("\n[4/%d] Config\n", totalSteps)
if path, err := setup.ZCodeRegisterHooks(configDir); err != nil {
setup.StatusError(0, 0, "Hooks config", err)
return err
} else {
setup.StatusUpdated(0, 0, "Hooks config", path)
}

fmt.Println()
fmt.Println("Setup complete!")
fmt.Printf(" Skill %s/skills/mnemon/SKILL.md\n", configDir)
fmt.Printf(" Hooks %s/cli/config.json (SessionStart, UserPromptSubmit, Stop)\n", configDir)
fmt.Printf(" Prompts %s/ (guide.md, skill.md)\n", promptPath)
fmt.Println()
fmt.Println("Start a new ZCode session to activate the mnemon skill and hooks.")
fmt.Println("Run 'mnemon setup --eject --target zcode --global' to remove.")

return nil
}

// ─── Trae ───────────────────────────────────────────────────────────

func installTrae(env *setup.Environment) error {
Expand Down Expand Up @@ -1407,6 +1507,12 @@ func ejectEnv(env *setup.Environment) error {
return errs[0]
}

case "zcode":
errs := setup.ZCodeEject(env.ConfigDir)
if len(errs) > 0 {
return errs[0]
}

case "trae":
errs := setup.TraeEject(env.ConfigDir)
ejectMarkdown("AGENTS.md", "Remove memory guidance from ./AGENTS.md?")
Expand Down
5 changes: 3 additions & 2 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mnemon setup --global
mnemon setup --target claude-code
mnemon setup --target codex
mnemon setup --target cursor
mnemon setup --target zcode --global
mnemon setup --target trae
mnemon setup --target qoder
mnemon setup --target qoderwork
Expand All @@ -55,8 +56,8 @@ mnemon setup --eject --target claude-code

| Flag | Default | Description |
|---|---|---|
| `--global` | `false` | Install to user-wide config instead of project-local (recommended for Nanobot: installs to `~/.nanobot/workspace/`; Pi installs to `~/.pi/agent/`; Hermes installs to `~/.hermes/`; QoderWork installs to `~/.qoderwork/`; Kimi Code installs to `~/.kimi-code/` or `$KIMI_CODE_HOME/`; OpenCode installs to `~/.config/opencode/`) |
| `--target <name>` | (auto-detect) | Target environment: `claude-code`, `codex`, `cursor`, `trae`, `qoder`, `qoderwork`, `codebuddy`, `workbuddy`, `kimi`, `opencode`, `openclaw`, `nanobot`, `pi`, or `hermes` |
| `--global` | `false` | Install to user-wide config instead of project-local (required for ZCode lifecycle hooks; recommended for Nanobot: installs to `~/.nanobot/workspace/`; Pi installs to `~/.pi/agent/`; Hermes installs to `~/.hermes/`; QoderWork installs to `~/.qoderwork/`; Kimi Code installs to `~/.kimi-code/` or `$KIMI_CODE_HOME/`; OpenCode installs to `~/.config/opencode/`) |
| `--target <name>` | (auto-detect) | Target environment: `claude-code`, `codex`, `cursor`, `zcode`, `trae`, `qoder`, `qoderwork`, `codebuddy`, `workbuddy`, `kimi`, `opencode`, `openclaw`, `nanobot`, `pi`, or `hermes` |
| `--eject` | `false` | Remove mnemon integrations |
| `--yes` | `false` | Auto-confirm all prompts |

Expand Down
13 changes: 12 additions & 1 deletion docs/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ mnemon setup

`mnemon setup` 自动检测 Claude Code,交互式部署技能文件、钩子和行为引导。启动新会话 — 记忆自动运作。

### [ZCode](https://zcode.z.ai/)

```bash
mnemon setup --target zcode --global --yes
```

ZCode 会将 Mnemon skill 安装到 `~/.zcode/skills/`,并在
`~/.zcode/cli/config.json` 中注册用户级生命周期 hooks。新会话会注入记忆状态,
模型调用前会收到 recall 指引,停止时会评估 durable-memory 回写。不加
`--global` 时只安装项目 skill,因为 ZCode 当前不会执行项目级 hooks 配置。

### [TRAE](https://www.trae.ai/) (TRAE Work)

```bash
Expand Down Expand Up @@ -283,7 +294,7 @@ store 可见。**Remind** 触发 recall 判断。**Nudge** 触发 writeback 判

- **零用户操作** — 安装一次;支持 hook 的 runtime 可用 hook,minimal runtime 可用持久规则
- **LLM 监督式** — 宿主 LLM 主动决定记什么、更新什么、遗忘什么;无内嵌 LLM,无 API 密钥
- **多框架支持** — Claude Code、Codex、Cursor、TRAE/TRAE Work、Qoder/QoderWork、CodeBuddy、WorkBuddy、Kimi Code、OpenCode 和 Hermes Agent(hooks/plugins)、OpenClaw(plugins)、Pi(extensions)、Nanobot(skills)、DeepSeek Harness(通过 dsh-mnemon 插件)等
- **多框架支持** — Claude Code、Codex、Cursor、ZCode、TRAE/TRAE Work、Qoder/QoderWork、CodeBuddy、WorkBuddy、Kimi Code、OpenCode 和 Hermes Agent(hooks/plugins)、OpenClaw(plugins)、Pi(extensions)、Nanobot(skills)、DeepSeek Harness(通过 dsh-mnemon 插件)等
- **Runtime 原生集成** — 各 runtime 的 `SKILL.md`、共享 `guide.md`,以及受支持的 hook 或 extension
- **四图架构** — 时序、实体、因果、语义四种边,不仅仅是向量相似度
- **意图原生协议** — 三个原语(`remember`、`link`、`recall`)映射到 LLM 的认知词汇而非数据库语法;结构化 JSON 输出,带信号透明度
Expand Down
5 changes: 3 additions & 2 deletions docs/zh/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mnemon setup --global
mnemon setup --target claude-code
mnemon setup --target codex
mnemon setup --target cursor
mnemon setup --target zcode --global
mnemon setup --target trae
mnemon setup --target qoder
mnemon setup --target qoderwork
Expand All @@ -55,8 +56,8 @@ mnemon setup --eject --target claude-code

| 标志 | 默认值 | 说明 |
|---|---|---|
| `--global` | `false` | 安装到用户级配置而非项目本地(Nanobot 推荐安装到 `~/.nanobot/workspace/`;Pi 安装到 `~/.pi/agent/`;Hermes 安装到 `~/.hermes/`;QoderWork 安装到 `~/.qoderwork/`;Kimi Code 安装到 `~/.kimi-code/` 或 `$KIMI_CODE_HOME/`;OpenCode 安装到 `~/.config/opencode/`) |
| `--target <name>` | (自动检测) | 目标环境:`claude-code`、`codex`、`cursor`、`trae`、`qoder`、`qoderwork`、`codebuddy`、`workbuddy`、`kimi`、`opencode`、`openclaw`、`nanobot`、`pi` 或 `hermes` |
| `--global` | `false` | 安装到用户级配置而非项目本地(ZCode 生命周期 hooks 必须使用;Nanobot 推荐安装到 `~/.nanobot/workspace/`;Pi 安装到 `~/.pi/agent/`;Hermes 安装到 `~/.hermes/`;QoderWork 安装到 `~/.qoderwork/`;Kimi Code 安装到 `~/.kimi-code/` 或 `$KIMI_CODE_HOME/`;OpenCode 安装到 `~/.config/opencode/`) |
| `--target <name>` | (自动检测) | 目标环境:`claude-code`、`codex`、`cursor`、`zcode`、`trae`、`qoder`、`qoderwork`、`codebuddy`、`workbuddy`、`kimi`、`opencode`、`openclaw`、`nanobot`、`pi` 或 `hermes` |
| `--eject` | `false` | 移除 mnemon 集成 |
| `--yes` | `false` | 自动确认所有提示 |

Expand Down
14 changes: 13 additions & 1 deletion internal/memory/setup/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ var CursorStopHook []byte
//go:embed cursor/compact.sh
var CursorCompactHook []byte

//go:embed zcode/SKILL.md
var ZCodeSkill []byte

//go:embed zcode/prime.sh
var ZCodePrimeHook []byte

//go:embed zcode/user_prompt.sh
var ZCodeUserPromptHook []byte

//go:embed zcode/stop.sh
var ZCodeStopHook []byte

//go:embed trae/SKILL.md
var TraeSkill []byte

Expand Down Expand Up @@ -163,5 +175,5 @@ var HermesCompactHook []byte

// All returns the embedded filesystem for inspection.
//
//go:embed claude codex cursor trae qoder qoderwork codebuddy workbuddy kimi opencode openclaw nanoclaw nanobot pi hermes
//go:embed claude codex cursor zcode trae qoder qoderwork codebuddy workbuddy kimi opencode openclaw nanoclaw nanobot pi hermes
var All embed.FS
Loading
Loading