@zilliz/memsearch-opencode 0.1.1 → 0.1.2

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/index.ts CHANGED
@@ -68,12 +68,15 @@ function deriveCollectionName(projectDir: string): string {
68
68
  }
69
69
 
70
70
  /**
71
- * Read the tail of the N most recent daily .md files for cold-start context.
71
+ * Summarize the N most recent daily .md files for cold-start context.
72
+ * Extracts headings (## Session, ### turns) and bullet content from each
73
+ * file so the agent sees the structure of past days (what sessions existed,
74
+ * what topics came up), not just the tail of whichever file is newest.
72
75
  */
73
76
  function getRecentMemories(
74
77
  memDir: string,
75
78
  count = 2,
76
- tailLines = 15
79
+ maxLinesPerFile = 30
77
80
  ): string {
78
81
  if (!existsSync(memDir)) return "";
79
82
 
@@ -84,23 +87,24 @@ function getRecentMemories(
84
87
 
85
88
  if (files.length === 0) return "";
86
89
 
87
- const bullets: string[] = [];
90
+ const summary: string[] = [];
88
91
  for (const file of files) {
89
92
  try {
90
93
  const content = readFileSync(join(memDir, file), "utf-8");
91
- const lines = content.split("\n").slice(-tailLines);
92
- const fileBullets = lines.filter((l) => l.startsWith("- ") || l.startsWith("[Human]") || l.startsWith("[Assistant]"));
93
- if (fileBullets.length > 0) {
94
- bullets.push(`[${file}]`, ...fileBullets);
94
+ const lines = content.split("\n")
95
+ .filter((l) => /^#{2,4}\s/.test(l) || l.startsWith("- ") || l.startsWith("[Human]") || l.startsWith("[Assistant]"))
96
+ .slice(0, maxLinesPerFile);
97
+ if (lines.length > 0) {
98
+ summary.push(`[${file}]`, ...lines);
95
99
  }
96
100
  } catch { /* skip */ }
97
101
  }
98
102
 
99
- if (bullets.length === 0) {
103
+ if (summary.length === 0) {
100
104
  return `You have ${files.length} past memory file(s). Use the memory_search tool when the user's question could benefit from historical context.`;
101
105
  }
102
106
 
103
- return `Recent memories (use memory_search for full search):\n${bullets.join("\n")}`;
107
+ return `Recent memories (use memory_search for full search):\n${summary.join("\n")}`;
104
108
  }
105
109
 
106
110
  /** Shell-escape a string for safe use inside single quotes. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zilliz/memsearch-opencode",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "memsearch plugin for OpenCode — semantic memory search across sessions",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memory-recall
3
- description: "Search and recall relevant memories from past sessions. Use when the user's question could benefit from historical context, past decisions, debugging notes, previous conversations, or project knowledge."
3
+ description: "Search and recall relevant memories from past sessions via memsearch. Use when the user's question could benefit from historical context, past decisions, debugging notes, previous conversations, or project knowledge -- especially questions like 'what did I decide about X', 'why did we do Y', or 'have I seen this before'. Also use when you see `[memsearch] Memory available` hints injected via SessionStart or UserPromptSubmit. Typical flow: search for 3-5 chunks, expand the most relevant, optionally deep-drill into original transcripts via the anchor format. Skip when the question is purely about current code state (use Read/Grep), ephemeral (today's task only), or the user has explicitly asked to ignore memory."
4
4
  allowed-tools: Bash
5
5
  ---
6
6
 
@@ -8,7 +8,7 @@ You are a memory retrieval agent for memsearch. Your job is to search past memor
8
8
 
9
9
  ## Project Collection
10
10
 
11
- Collection: !`bash __INSTALL_DIR__/scripts/derive-collection.sh`
11
+ Collection: !`bash -c 'root=$(git rev-parse --show-toplevel 2>/dev/null || true); if [ -n "$root" ]; then bash __INSTALL_DIR__/scripts/derive-collection.sh "$root"; else bash __INSTALL_DIR__/scripts/derive-collection.sh; fi'`
12
12
 
13
13
  ## Your Task
14
14
 
@@ -30,6 +30,16 @@ Search for memories relevant to: $ARGUMENTS
30
30
 
31
31
  5. **Return results**: Output a curated summary of the most relevant memories. Be concise — only include information that is genuinely useful for the user's current question.
32
32
 
33
+ ## When unsure what to search
34
+
35
+ If the user's question is vague or you can't form a concrete search query, explore the raw markdown first — it is the source of truth for memory:
36
+
37
+ - `ls -t .memsearch/memory/ | head -10` — recent daily logs
38
+ - `grep -h "^## " .memsearch/memory/*.md | sort -u | tail -40` — session headings across all days
39
+ - `cat .memsearch/memory/<YYYY-MM-DD>.md` — read a specific day
40
+
41
+ Once a concrete topic jumps out, go back to `memsearch search` with a specific query.
42
+
33
43
  ## Output Format
34
44
 
35
45
  Organize by relevance. For each memory include: