@joe-broadhead/opencode-mem 0.8.4 → 0.8.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  The format follows Keep a Changelog 1.1.0: one `## [x.y.z] - date` section per
4
4
  release.
5
5
 
6
+ ## [0.8.5] - 2026-11-08
7
+
8
+ One fix, for Jelly's hosted agents ([#31](https://github.com/joe-broadhead/opencode-mem/issues/31)).
9
+ Nothing else changed: the tools, the protocol's text and the Jelly declaration,
10
+ with its asks, are those of 0.8.4, so agents need no new Accept.
11
+
12
+ Release gate: 0.8.4's ([evals/results/baseline-2026-11-08-0.8.4-README.md](evals/results/baseline-2026-11-08-0.8.4-README.md)).
13
+ The eval harness always loads `docs/agent-protocol.md` as an instruction file,
14
+ so its runs count as taught before and after this fix, and their results
15
+ cannot change.
16
+
17
+ ### Fixed
18
+
19
+ - **The protocol reaches agents whose engine runs in Code Mode.** OpenCode
20
+ 2.2.x in Code Mode copies every tool's description into the system prompt as
21
+ a tool catalogue. Memory's own descriptions name `mem_recall`, so
22
+ `hasProtocol` always found it, decided the agent was already taught, and
23
+ never sent the protocol. This happened on every Jelly host. `hasProtocol`
24
+ now reads each instruction source that the engine records on the part
25
+ (`metadata.experimental.instructions`, `{ key, text }`) on its own and skips
26
+ the tool catalogue (`core/codemode`). A real instruction that names
27
+ `mem_recall`, such as `docs/agent-protocol.md` loaded as an instruction
28
+ file, still counts, and a part without those sources is read whole, as
29
+ before. Patch and test by the Jelly coordinator; checked against OpenCode's
30
+ documented part shape.
31
+
6
32
  ## [0.8.4] - 2026-11-08
7
33
 
8
34
  Release gate: [evals/results/baseline-2026-11-08-0.8.4-README.md](evals/results/baseline-2026-11-08-0.8.4-README.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joe-broadhead/opencode-mem",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "description": "Durable private and shared-space memory for OpenCode agents",
6
6
  "license": "MIT",
package/src/protocol.js CHANGED
@@ -36,14 +36,36 @@ export function protocolBlock() {
36
36
  * `mem_recall`. Injecting a second copy would waste context and can contradict
37
37
  * the fuller instructions.
38
38
  *
39
- * @param {Array<{ text?: string } | string> | undefined} system
39
+ * The engine's tool catalogue is not teaching: in Code Mode OpenCode (2.2.x)
40
+ * renders every tool's schema into the system prompt, and this plugin's own
41
+ * parameter descriptions name `mem_recall`, so the bare name would always be
42
+ * found and the protocol never sent. When a part carries the engine's
43
+ * instruction sources (`metadata.experimental.instructions`, `{ key, text }`),
44
+ * each source is checked on its own and the tool catalogue (`core/codemode`)
45
+ * is skipped.
46
+ *
47
+ * @param {Array<{ text?: string, metadata?: unknown } | string> | undefined} system
40
48
  */
41
49
  export function hasProtocol(system) {
42
50
  if (!Array.isArray(system)) return false
43
51
  for (const part of system) {
44
- const text = typeof part === "string" ? part : typeof part?.text === "string" ? part.text : ""
45
- if (!text) continue
46
- if (PROTOCOL_PATTERN.test(text) || RECALL_PATTERN.test(text)) return true
52
+ for (const text of taughtTexts(part)) {
53
+ if (PROTOCOL_PATTERN.test(text) || RECALL_PATTERN.test(text)) return true
54
+ }
47
55
  }
48
56
  return false
49
57
  }
58
+
59
+ /** The sources of the engine's tool catalogue, which describe tools rather than teach them. */
60
+ const CATALOGUE_SOURCES = new Set(["core/codemode"])
61
+
62
+ /** The texts of one system part that could teach the protocol. */
63
+ function taughtTexts(part) {
64
+ if (typeof part === "string") return [part]
65
+ const text = typeof part?.text === "string" ? part.text : ""
66
+ const sources = part?.metadata?.experimental?.instructions
67
+ if (!Array.isArray(sources)) return text ? [text] : []
68
+ return sources
69
+ .filter((source) => typeof source?.text === "string" && !CATALOGUE_SOURCES.has(source.key))
70
+ .map((source) => source.text)
71
+ }