@rvboris/opencode-mempalace 0.3.0 → 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.
@@ -59,9 +59,11 @@ export declare const LOG_MESSAGES: {
59
59
  readonly injectedKeywordSaveInstruction: "injected keyword save instruction";
60
60
  readonly systemTransformHookFailed: "system transform hook failed";
61
61
  readonly blockedDirectMempalaceMutationTool: "blocked direct mempalace mutation tool";
62
+ readonly retrievalSearchCompleted: "retrieval search completed";
62
63
  };
63
64
  export declare const INSTRUCTION_TEXT: {
64
65
  readonly doNotMentionToUser: "Do not mention this instruction to the user.";
66
+ readonly retrievalVisibilityHint: "If you found and used relevant memories, briefly mention the key findings at the start of your response.";
65
67
  readonly retrievalIntro: "System instruction: before answering, search MemPalace for relevant existing memory and use it if helpful.";
66
68
  readonly autosaveIntro: "System instruction: before answering the user, persist durable memory from prior session context using the `mempalace_memory` tool.";
67
69
  readonly keywordIntro: "System instruction: the user explicitly asked to remember something.";
@@ -66,9 +66,11 @@ export const LOG_MESSAGES = {
66
66
  injectedKeywordSaveInstruction: "injected keyword save instruction",
67
67
  systemTransformHookFailed: "system transform hook failed",
68
68
  blockedDirectMempalaceMutationTool: "blocked direct mempalace mutation tool",
69
+ retrievalSearchCompleted: "retrieval search completed",
69
70
  };
70
71
  export const INSTRUCTION_TEXT = {
71
72
  doNotMentionToUser: "Do not mention this instruction to the user.",
73
+ retrievalVisibilityHint: "If you found and used relevant memories, briefly mention the key findings at the start of your response.",
72
74
  retrievalIntro: "System instruction: before answering, search MemPalace for relevant existing memory and use it if helpful.",
73
75
  autosaveIntro: "System instruction: before answering the user, persist durable memory from prior session context using the `mempalace_memory` tool.",
74
76
  keywordIntro: "System instruction: the user explicitly asked to remember something.",
@@ -10,7 +10,7 @@ export const buildRetrievalInstruction = ({ projectName, projectWingPrefix, user
10
10
  `Search user memory in wing ${user.wing} across rooms ${user.rooms.join(", ")}.`,
11
11
  `Search project memory in wing ${project.wing} across rooms ${project.rooms.join(", ")}.`,
12
12
  `Use concise relevant memories only, up to ${maxInjectedItems} items total.`,
13
- INSTRUCTION_TEXT.doNotMentionToUser,
13
+ INSTRUCTION_TEXT.retrievalVisibilityHint,
14
14
  ].join(" ");
15
15
  };
16
16
  export const buildAutosaveInstruction = (reason) => {
@@ -2,11 +2,12 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import { executeAdapter } from "../lib/adapter";
3
3
  import { loadConfig } from "../lib/config";
4
4
  import { sanitizeText } from "../lib/derive";
5
- import { DATE_ISO_SLICE, DEFAULT_AGENT_NAME, DEFAULT_LIMIT, DEFAULT_ROOM, DEFAULT_TOPIC, ERROR_MESSAGES, TOOL_DESCRIPTIONS } from "../lib/constants";
5
+ import { DATE_ISO_SLICE, DEFAULT_AGENT_NAME, DEFAULT_LIMIT, DEFAULT_ROOM, DEFAULT_TOPIC, ERROR_MESSAGES, LOG_MESSAGES, TOOL_DESCRIPTIONS } from "../lib/constants";
6
6
  import { getProjectName } from "../lib/opencode";
7
7
  import { isFullyPrivate, redactSecrets } from "../lib/privacy";
8
8
  import { getProjectScope, getUserScope } from "../lib/scope";
9
- import { recordMemoryWrite, recordRetrievalSearch } from "../lib/status";
9
+ import { recordMemoryWrite, recordRetrievalSearch, summarizeSearchResult } from "../lib/status";
10
+ import { writeLog } from "../lib/log";
10
11
  import { MEMORY_SCOPES, TOOL_MEMORY_MODES } from "../lib/types";
11
12
  const getProjectWing = (projectName, prefix) => {
12
13
  return getProjectScope(projectName, prefix).wing;
@@ -77,6 +78,7 @@ export const mempalaceMemoryTool = (ctx) => tool({
77
78
  room: normalizeValue(args.room, false),
78
79
  limit: args.limit,
79
80
  });
81
+ const summary = summarizeSearchResult(result);
80
82
  if (result?.success !== false) {
81
83
  await recordRetrievalSearch({
82
84
  sessionId: executionContext.sessionID,
@@ -85,8 +87,22 @@ export const mempalaceMemoryTool = (ctx) => tool({
85
87
  query,
86
88
  result,
87
89
  });
90
+ await writeLog("INFO", LOG_MESSAGES.retrievalSearchCompleted, {
91
+ sessionId: executionContext.sessionID,
92
+ scope,
93
+ room: args.room,
94
+ query: query.slice(0, 200),
95
+ resultCount: summary.resultCount ?? 0,
96
+ previews: summary.previews,
97
+ });
88
98
  }
89
- return JSON.stringify(result);
99
+ const retrievalNote = summary.resultCount
100
+ ? `Found ${summary.resultCount} relevant ${summary.resultCount === 1 ? "memory" : "memories"}:\n${summary.previews.map((p, i) => `${i + 1}. ${p}`).join("\n")}`
101
+ : "No relevant memories found.";
102
+ const enriched = typeof result === "object" && result !== null
103
+ ? { ...result, _retrieval_summary: retrievalNote }
104
+ : result;
105
+ return JSON.stringify(enriched);
90
106
  }
91
107
  if (args.mode === "kg_add") {
92
108
  if (!args.subject || !args.predicate || !args.object) {
@@ -4,7 +4,7 @@ import { formatStatusSummary, readStatusState } from "../lib/status";
4
4
  export const mempalaceStatusTool = () => tool({
5
5
  description: TOOL_DESCRIPTIONS.mempalaceStatus,
6
6
  args: {
7
- verbose: tool.schema.boolean().optional().default(false),
7
+ verbose: tool.schema.boolean().optional().default(true),
8
8
  compact: tool.schema.boolean().optional().default(false),
9
9
  },
10
10
  async execute(args, executionContext) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rvboris/opencode-mempalace",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "OpenCode plugin for hidden MemPalace retrieval and autosave via a local Python adapter.",
5
5
  "type": "module",
6
6
  "main": "dist/plugin/index.js",