opencode-memoir 1.1.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -80
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -1102
- package/dist/index.js.map +4 -4
- package/dist/memory-saver.d.ts +6 -0
- package/dist/memory-saver.d.ts.map +1 -0
- package/dist/store.d.ts +13 -111
- package/dist/store.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/capture-hooks.d.ts +0 -7
- package/dist/capture-hooks.d.ts.map +0 -1
- package/dist/capture.d.ts +0 -44
- package/dist/capture.d.ts.map +0 -1
- package/dist/commands.d.ts +0 -12
- package/dist/commands.d.ts.map +0 -1
- package/dist/memoir-ops.d.ts +0 -7
- package/dist/memoir-ops.d.ts.map +0 -1
- package/dist/recall-gate.d.ts +0 -27
- package/dist/recall-gate.d.ts.map +0 -1
- package/dist/session-context.d.ts +0 -8
- package/dist/session-context.d.ts.map +0 -1
- package/dist/tools.d.ts +0 -49
- package/dist/tools.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -15
- package/dist/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
OpenCode plugin for [Memoir](https://github.com/zhangfengcdt/memoir): git-versioned, taxonomy-structured memory for coding agents.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Dynamically loads the `memoir-mcp` MCP server via `uvx` — no manual CLI installation needed.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -18,25 +18,14 @@ Add the package name to your OpenCode config (`~/.config/opencode/opencode.jsonc
|
|
|
18
18
|
|
|
19
19
|
OpenCode downloads and resolves the package from npm automatically; no manual install or `npm:` prefix needed. To pin a version, append it: `"opencode-memoir@1.0.0"`.
|
|
20
20
|
|
|
21
|
-
The `memoir` CLI is resolved automatically with no separate install — see [Memoir CLI resolution](#memoir-cli-resolution).
|
|
22
|
-
|
|
23
21
|
## Quick start
|
|
24
22
|
|
|
25
23
|
1. Install the plugin (see above)
|
|
26
|
-
2.
|
|
27
|
-
3. Start saving memories with `/memoir:remember` or let the agent auto-capture
|
|
24
|
+
2. Start coding — the agent can use `memoir_recall`, `memoir_remember`, `memoir_get` MCP tools automatically
|
|
28
25
|
|
|
29
26
|
## Store configuration
|
|
30
27
|
|
|
31
|
-
The plugin
|
|
32
|
-
|
|
33
|
-
| Source | Description |
|
|
34
|
-
|---|---|
|
|
35
|
-
| plugin option `store` | Highest-priority override when the plugin is loaded from `plugin[]` |
|
|
36
|
-
| `MEMOIR_STORE` | Portable global/project override |
|
|
37
|
-
| auto-derived path | `~/.memoir/<slug>`, where slug = git root (or resolved cwd) with `/` and `.` replaced by `-`; all worktrees share one store |
|
|
38
|
-
|
|
39
|
-
Example when loading through `plugin[]`:
|
|
28
|
+
The plugin delegates store path resolution to `memoir-mcp`. Override via `MEMOIR_STORE` env var or `store` plugin option:
|
|
40
29
|
|
|
41
30
|
```jsonc
|
|
42
31
|
{
|
|
@@ -48,70 +37,31 @@ Example when loading through `plugin[]`:
|
|
|
48
37
|
|
|
49
38
|
## Environment variables
|
|
50
39
|
|
|
51
|
-
All
|
|
40
|
+
All optional:
|
|
52
41
|
|
|
53
42
|
| Variable | Effect |
|
|
54
43
|
|---|---|
|
|
55
|
-
| `MEMOIR_STORE` | Override
|
|
56
|
-
| `MEMOIR_DEBUG=1` | Emit diagnostic logs to stderr (prefixed `[memoir]`)
|
|
57
|
-
| `MEMOIR_NO_CAPTURE=1` | Disable all capture — no metrics, no code-change tracking, no branch auto-match flush. Superset switch. |
|
|
58
|
-
| `MEMOIR_NO_METRICS=1` | Disable per-tool metrics only (`metrics.turn.<branch>`). Code-change tracking still runs. |
|
|
59
|
-
| `MEMOIR_NO_CODE_SUMMARY=1` | Disable code-change tracking only (`metrics.code.<branch>`). Metrics still run. |
|
|
60
|
-
| `MEMOIR_SANITIZE_SECRETS=0` | Disable the secret-pattern guard on `memoir_remember`. Sanitization is **on** by default; set to `0` only if the guard produces false positives you understand. |
|
|
61
|
-
|
|
62
|
-
Capture guards are checked at the collection point (`tool.execute.after`) and the flush point (`chat.message`), so setting them mid-session takes effect on the next turn.
|
|
63
|
-
|
|
64
|
-
## Commands
|
|
65
|
-
|
|
66
|
-
| Command | Description |
|
|
67
|
-
|---|---|
|
|
68
|
-
| `/memoir:status` | Show status for the current project store, including project git branch metadata |
|
|
69
|
-
| `/memoir:ui` | Launch or reopen the Memoir web UI |
|
|
70
|
-
| `/memoir:remember <memory>` | Ask the agent to save an explicit durable memory with a semantic path |
|
|
71
|
-
| `/memoir:recall <topic>` | Ask the agent to list and use relevant stored memories |
|
|
72
|
-
| `/memoir:onboard` | Populate or refresh the project onboarding snapshot |
|
|
73
|
-
| `/memoir:unmerged` | List memoir branches that have diverged from `main` |
|
|
74
|
-
|
|
75
|
-
## Tools
|
|
76
|
-
|
|
77
|
-
| Tool | Description |
|
|
78
|
-
|---|---|
|
|
79
|
-
| `memoir_status` | Run the status helper |
|
|
80
|
-
| `memoir_remember` | Save explicit content to one or more semantic paths; refuses secret-like content |
|
|
81
|
-
| `memoir_recall` | List memory keys via `summarize` for relevance selection |
|
|
82
|
-
| `memoir_get` | Fetch selected exact keys after `memoir_recall` |
|
|
44
|
+
| `MEMOIR_STORE` | Override store path (passed to memoir-mcp as `--store`) |
|
|
45
|
+
| `MEMOIR_DEBUG=1` | Emit diagnostic logs to stderr (prefixed `[memoir]`) |
|
|
83
46
|
|
|
84
47
|
## Hooks
|
|
85
48
|
|
|
86
|
-
The plugin registers eight OpenCode hooks, mirroring the Claude Code plugin's lifecycle:
|
|
87
|
-
|
|
88
49
|
| Hook | Purpose |
|
|
89
50
|
|---|---|
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `event` | On `session.created`, fetches the taxonomy overview in the background |
|
|
94
|
-
| `tool.execute.after` | Accumulates per-tool metrics + file edits for code change audit |
|
|
95
|
-
| `chat.message` | Auto-matches memoir branch to git branch, flushes capture, runs recall gate |
|
|
96
|
-
| `experimental.chat.system.transform` | Injects taxonomy context + recall instruction |
|
|
97
|
-
| `dispose` | Flushes remaining data, prunes session state |
|
|
98
|
-
|
|
99
|
-
See the [Memoir docs](https://zhangfengcdt.github.io/memoir/) for detailed hook behaviour.
|
|
51
|
+
| `chat.message` | Runs recall gate — detects when user context might benefit from memoir |
|
|
52
|
+
| `experimental.chat.system.transform` | Injects recall hint when the gate triggers |
|
|
53
|
+
| `dispose` | Clears pending recall state |
|
|
100
54
|
|
|
101
|
-
##
|
|
55
|
+
## How it works
|
|
102
56
|
|
|
103
|
-
|
|
104
|
-
2. `uvx --from memoir-ai==<pin> memoir` — ephemeral, pinned
|
|
105
|
-
3. `uv tool run --from memoir-ai==<pin> memoir` — pinned fallback
|
|
106
|
-
|
|
107
|
-
Every command passes an explicit `-s <store>` to keep the project git and Memoir store separate.
|
|
57
|
+
Instead of wrapping the `memoir` CLI and re-implementing tools in TypeScript, this plugin registers `memoir-mcp` as a dynamic MCP server. OpenCode starts the server via `uvx --from memoir-ai[mcp] memoir-mcp`, and all memoir tools (`memoir_recall`, `memoir_remember`, `memoir_get`, etc.) are available natively to the LLM.
|
|
108
58
|
|
|
109
59
|
## Development
|
|
110
60
|
|
|
111
61
|
### Prerequisites
|
|
112
62
|
|
|
113
63
|
- Node.js >= 20
|
|
114
|
-
- `
|
|
64
|
+
- `uv` installed (for `uvx` to run memoir-mcp)
|
|
115
65
|
|
|
116
66
|
### Setup
|
|
117
67
|
|
|
@@ -125,28 +75,15 @@ npm test # run the test suite
|
|
|
125
75
|
|
|
126
76
|
| File | Responsibility |
|
|
127
77
|
|---|---|
|
|
128
|
-
| `src/
|
|
129
|
-
| `src/
|
|
130
|
-
| `src/recall-gate.ts` | Secret pattern + sanitization toggle, recall-gate trigger logic |
|
|
131
|
-
| `src/index.ts` | Plugin wiring — tool definitions, hooks, command registration |
|
|
78
|
+
| `src/index.ts` | Plugin entry: MCP registration + hooks |
|
|
79
|
+
| `src/recall-gate.ts` | Recall-gate trigger logic |
|
|
132
80
|
| `src/debug.ts` | Shared debug logger |
|
|
133
81
|
|
|
134
|
-
### Tests
|
|
135
|
-
|
|
136
|
-
The suite runs with `tsx --test` (handles `.js` → `.ts` resolution under NodeNext).
|
|
137
|
-
|
|
138
|
-
To debug hooks locally, run OpenCode with `MEMOIR_DEBUG=1` and watch stderr for `[memoir]` lines.
|
|
139
|
-
|
|
140
82
|
## Publishing
|
|
141
83
|
|
|
142
84
|
Releases are fully automated — no manual `npm version` or `npm publish`.
|
|
143
85
|
|
|
144
|
-
1. Land changes on `main` via PR using [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`,
|
|
145
|
-
2. On push to `main`, `.github/workflows/semantic.yaml` runs [semantic-release](https://semantic-release.gitbook.io/)
|
|
146
|
-
3. The new tag triggers `.github/workflows/publish-npm.yaml`, which builds and runs `npm publish --provenance`
|
|
147
|
-
|
|
148
|
-
Published files are limited to `dist/` and `README.md` (see `files` in `package.json`); the `prepublishOnly` script runs `build` + `test` as a safety net.
|
|
149
|
-
|
|
150
|
-
## License
|
|
86
|
+
1. Land changes on `main` via PR using [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, etc.)
|
|
87
|
+
2. On push to `main`, `.github/workflows/semantic.yaml` runs [semantic-release](https://semantic-release.gitbook.io/)
|
|
88
|
+
3. The new tag triggers `.github/workflows/publish-npm.yaml`, which builds and runs `npm publish --provenance`
|
|
151
89
|
|
|
152
|
-
Apache-2.0
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import type { PluginModule } from "@opencode-ai/plugin";
|
|
2
|
-
/**
|
|
3
|
-
* V1 plugin module format: OpenCode's loader recognizes `{ id, server }` and
|
|
4
|
-
* ignores any other module exports. The legacy format (default-exported
|
|
5
|
-
* function) made the loader treat EVERY export as a plugin and fail on
|
|
6
|
-
* non-function exports ("Plugin export is not a function").
|
|
7
|
-
*/
|
|
8
2
|
declare const plugin: PluginModule;
|
|
9
3
|
export default plugin;
|
|
10
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA4IxE,QAAA,MAAM,MAAM,EAAE,YAGb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|