OpenCode 插件,自动启动 agentmemory 后端并附带健康检查监控。
- Node.js ≥ 18.0.0
- 支持插件的 OpenCode
- agentmemory 后端(若未安装,插件会自动通过
npx @agentmemory/agentmemory安装)
注意: 本插件仅在 Windows 11 上测试过。如需其他平台支持,欢迎提交 Pull Request。
本插件会在 OpenCode 加载配置时自动启动 agentmemory 后端(REST API + iii-engine)。它会在每个 OpenCode 进程中执行一次,并每 60 秒对后端进行一次健康检查,若进程死亡则自动重启。
在 OpenCode 配置中添加:
OpenCode 会在启动时自动安装该包。更多详情请参阅 OpenCode 插件文档。
将插件文件放入 .opencode/plugins/ 目录:
.opencode/plugins/
└── agentmemory-launcher.ts
该目录下的文件会在启动时自动加载。
- 从最新的 GitHub Release 下载
agentmemory-launcher.ts - 将其放入
.opencode/plugins/目录:
.opencode/plugins/
└── agentmemory-launcher.ts
OpenCode 会在启动时自动加载 .opencode/plugins/ 目录下的 .ts 文件。
本启动器会启动 agentmemory 后端。要在 OpenCode 中使用 agentmemory,还需安装 agentmemory 插件,并参考 OpenCode agentmemory 插件使用指南 了解设置说明、可用工具及配置选项。
更新 agentmemory 到最新版本:
npx @agentmemory/agentmemory upgrade更新后,停止正在运行的 agentmemory 进程并清除 npx 缓存:
Windows (PowerShell):
# 停止 agentmemory 进程
Get-Process -Name "node" | Where-Object {
(Get-CimInstance Win32_Process -Filter "ProcessId = $($_.Id)").CommandLine -match 'agentmemory'
} | Stop-Process -Force
# 清除 npx 缓存
Get-ChildItem "$env:LOCALAPPDATA\npm-cache\_npx" -Directory | Where-Object {
Test-Path "$($_.FullName)\node_modules\@agentmemory"
} | Remove-Item -Recurse -Force重新启动 OpenCode,即可使用更新后的 agentmemory 版本。
- 首次加载配置时:插件启动一个健康检查定时器(间隔 60 秒)
- 健康检查:向后端发送
GET /agentmemory/livez请求(公开接口,无需认证) - 自动重启:如果健康检查失败,则在分离进程中执行
npx @agentmemory/agentmemory - 调试模式:设置环境变量
OPENCODE_AGENTMEMORY_DEBUG=1可输出详细日志
| 变量 | 默认值 | 描述 |
|---|---|---|
AGENTMEMORY_URL |
http://localhost:3111 |
后端 API URL |
OPENCODE_AGENTMEMORY_DEBUG |
未设置 | 设为 1 开启调试日志 |
插件导出一个符合 @opencode-ai/plugin 接口的对象:
import type { Plugin } from "@opencode-ai/plugin";
export const AgentmemoryLauncherPlugin: Plugin;该插件实现了 config 生命周期钩子,每次 OpenCode 加载配置时都会调用。
# 安装依赖
npm install
# 类型检查
npm run typecheck
# 构建
npm run build
# 运行测试
npm testGNU Affero General Public License v3.0
Copyright (C) 2026 Cle2ment.