@vasilvestre/opencode-dream-memory 0.3.1 → 0.4.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/.opencode/plugins/dream-memory.js +15 -4
- package/README.md +8 -2
- package/package.json +1 -1
|
@@ -75,9 +75,20 @@ export default {
|
|
|
75
75
|
const location = ctx.location ?? {};
|
|
76
76
|
const directory =
|
|
77
77
|
location.project?.canonical || location.project?.directory || location.directory;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const register = async (name) => {
|
|
79
|
+
await ctx.session.hook(name, (event) => {
|
|
80
|
+
try {
|
|
81
|
+
const block = memoryBlock(directory);
|
|
82
|
+
// Both events carry a system array of text parts. Compaction reads the
|
|
83
|
+
// same memory the agent loop does, so the summary keeps it. We append
|
|
84
|
+
// and never set event.result: the model still writes the summary.
|
|
85
|
+
if (block) event.system.push({ type: 'text', text: block });
|
|
86
|
+
} catch {
|
|
87
|
+
// A throwing hook breaks the request it runs on. Inject nothing.
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
await register('context');
|
|
92
|
+
await register('compaction');
|
|
82
93
|
},
|
|
83
94
|
};
|
package/README.md
CHANGED
|
@@ -10,6 +10,11 @@ Two pieces that give an OpenCode agent memory across sessions:
|
|
|
10
10
|
summarizes the conversation and the instructions file goes with it. A plugin
|
|
11
11
|
hook runs on every agent-loop request, so the same block is re-sent each turn.
|
|
12
12
|
|
|
13
|
+
The plugin also registers the `compaction` hook, so the memory reaches the
|
|
14
|
+
request that writes the summary. The model still writes the summary; the plugin
|
|
15
|
+
only adds context. Without that hook, a long session could compact away the
|
|
16
|
+
memory it just read.
|
|
17
|
+
|
|
13
18
|
## Install
|
|
14
19
|
|
|
15
20
|
Requirements: `opencode` and `jq` on `PATH`, `curl` or `wget` to download, and
|
|
@@ -197,10 +202,11 @@ the same thing as the two subcommands.
|
|
|
197
202
|
npm test
|
|
198
203
|
```
|
|
199
204
|
|
|
200
|
-
The plugin checks:
|
|
205
|
+
The plugin checks: both hooks register, missing files inject nothing, shared
|
|
201
206
|
memory alone injects one block, the current project's file is appended after it
|
|
202
207
|
while another project's stays out, an oversized file is truncated without the
|
|
203
|
-
whole block growing,
|
|
208
|
+
whole block growing, titles are dropped, the `compaction` hook injects the same
|
|
209
|
+
block as the `context` hook, and it never sets `result`. Then the corpus checks: the dream's
|
|
204
210
|
own sessions stay out, a labelled secret is redacted, a torn session export is
|
|
205
211
|
skipped instead of fatal, and a git data directory gets a preimage commit before
|
|
206
212
|
the deep pass.
|
package/package.json
CHANGED