@zilliz/memsearch-opencode 0.3.7 → 0.3.10

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
@@ -70,10 +70,43 @@ function deriveCollectionName(projectDir: string): string {
70
70
 
71
71
  /**
72
72
  * Summarize the N most recent daily .md files for cold-start context.
73
- * Extracts headings (## Session, ### turns) and bullet content from each
74
- * file so the agent sees the structure of past days (what sessions existed,
75
- * what topics came up), not just the tail of whichever file is newest.
73
+ * Extracts recent non-empty session sections so empty SessionStart headings
74
+ * do not crowd out useful context.
76
75
  */
76
+ function recentMemoryPreviewLines(content: string, maxLines: number): string[] {
77
+ const sections: string[][] = [];
78
+ let current: string[] = [];
79
+ let hasBody = false;
80
+
81
+ const flush = () => {
82
+ if (current.length > 0 && hasBody) {
83
+ sections.push(current);
84
+ }
85
+ current = [];
86
+ hasBody = false;
87
+ };
88
+
89
+ for (const rawLine of content.split("\n")) {
90
+ const line = rawLine.trimEnd();
91
+ if (/^##\s/.test(line)) {
92
+ flush();
93
+ current = [line];
94
+ continue;
95
+ }
96
+ if (/^#{3,4}\s/.test(line)) {
97
+ current.push(line);
98
+ continue;
99
+ }
100
+ if (line.startsWith("- ") || line.startsWith("[User]") || line.startsWith("[Assistant]")) {
101
+ current.push(line);
102
+ hasBody = true;
103
+ }
104
+ }
105
+
106
+ flush();
107
+ return sections.flat().slice(-maxLines);
108
+ }
109
+
77
110
  function getRecentMemories(
78
111
  memDir: string,
79
112
  count = 2,
@@ -92,9 +125,7 @@ function getRecentMemories(
92
125
  for (const file of files) {
93
126
  try {
94
127
  const content = readFileSync(join(memDir, file), "utf-8");
95
- const lines = content.split("\n")
96
- .filter((l) => /^#{2,4}\s/.test(l) || l.startsWith("- ") || l.startsWith("[User]") || l.startsWith("[Assistant]"))
97
- .slice(0, maxLinesPerFile);
128
+ const lines = recentMemoryPreviewLines(content, maxLinesPerFile);
98
129
  if (lines.length > 0) {
99
130
  summary.push(`[${file}]`, ...lines);
100
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zilliz/memsearch-opencode",
3
- "version": "0.3.7",
3
+ "version": "0.3.10",
4
4
  "description": "memsearch plugin for OpenCode — semantic memory search across sessions",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -15,7 +15,7 @@ When this skill is triggered, inspect the user's request text. If there is no co
15
15
 
16
16
  - Empty request or "check": diagnose current MemSearch setup.
17
17
  - "Show/get setting": read the requested resolved/global/project value.
18
- - "Set/enable/disable/change": make a safe project-scoped change after confirming ambiguous choices.
18
+ - "Set/enable/disable/change": choose global vs project scope explicitly; use global config for trusted plugin automation/provider/prompt/endpoint settings and project config only for allowlisted local indexing knobs.
19
19
  - "Not capturing/search empty/no memory": troubleshoot files, config, and index health.
20
20
  - "Use OpenAI/Gemini/Anthropic/native/model": configure provider routing.
21
21
  - "PROJECT.md/USER.md/profile/review": configure advanced maintenance.
@@ -114,14 +114,33 @@ Config is resolved from built-in defaults, global config, project config, env re
114
114
 
115
115
  Use `memsearch config list --resolved` for effective behavior, `--global` for global overrides, and `--project` for repository-specific overrides.
116
116
 
117
+ Since v0.4.11, project-local `.memsearch.toml` is restricted before it is merged.
118
+ Only these low-risk local indexing keys are honored from project config:
119
+
120
+ - `milvus.collection`
121
+ - `embedding.batch_size`
122
+ - `chunking.max_chunk_size`
123
+ - `chunking.overlap_lines`
124
+ - `watch.debounce_ms`
125
+
126
+ Trusted settings are ignored or rejected in project config. Put these in global
127
+ config (`~/.memsearch/config.toml`) or pass explicit CLI flags instead:
128
+
129
+ - provider/model/API endpoint/API key settings
130
+ - `[llm]` and `[llm.providers.*]`
131
+ - `[prompts]`
132
+ - plugin automation such as `plugins.opencode.project_review.enabled`,
133
+ `plugins.opencode.user_profile.enabled`, and
134
+ `plugins.opencode.memory_to_skill.enabled`
135
+
117
136
  Default recommendation:
118
137
 
119
138
  - Put reusable defaults in global config so users do not repeat setup in every project.
120
- - Put only project-specific overrides in project config.
121
- - Use global config for named LLM providers, common model choices, normal input/output defaults, and shared prompt defaults.
122
- - Use project config for one repo's enable/disable switches, unusual output files, special intervals, or repo-specific providers.
139
+ - Put only allowlisted local indexing overrides in project config.
140
+ - Use global config for named LLM providers, common model choices, plugin enable/disable switches, task intervals, install paths, and shared prompt defaults.
141
+ - If the user wants advanced maintenance enabled for all projects, set the plugin keys globally. The default relative `input_dir` / `output_file` values still resolve inside each current project.
123
142
 
124
- Maintenance `input_dir` and `output_file` may be relative even when configured globally. They are resolved from the current project directory at runtime. For custom prompt paths, prefer absolute paths in global config and relative paths in project config.
143
+ Maintenance `input_dir` and `output_file` may be relative even when configured globally. They are resolved from the current project directory at runtime, so a global `output_file = ".memsearch/PROJECT.md"` writes to each project's own `.memsearch/PROJECT.md`. For custom prompt paths, prefer absolute paths in global config; project prompt paths are not trusted.
125
144
 
126
145
  OpenCode plugin keys:
127
146
 
@@ -193,7 +212,7 @@ If advanced maintenance or `memory_to_skill` seems silent, check
193
212
  `.memsearch/.maintenance-state.json` for `<plugin>.<task>.last_error` and
194
213
  `last_failed_at`; background hook errors may not surface in the chat.
195
214
 
196
- Before enabling advanced maintenance, ask which provider to use, whether the default 24-hour interval is acceptable, and whether `.memsearch/PROJECT.md` / `.memsearch/USER.md` are acceptable output files.
215
+ Before enabling advanced maintenance, ask which provider to use, whether the default 24-hour interval is acceptable, whether `.memsearch/PROJECT.md` / `.memsearch/USER.md` are acceptable output files, and whether the user wants the enablement global. Do not write plugin automation keys with `--project`; v0.4.11+ project config ignores or rejects them.
197
216
 
198
217
  Prompt overrides:
199
218
 
@@ -207,8 +226,8 @@ memory_to_skill = ""
207
226
 
208
227
  Empty prompt paths mean use the built-in MemSearch prompts. Custom prompt files may use `{{AGENT_NAME}}`, `{{TASK_NAME}}`, `{{PROJECT_DIR}}`, `{{INPUT_DIR}}`, and `{{OUTPUT_FILE}}`; the runner appends existing output, recent journals, and digest automatically.
209
228
 
210
- Use `memsearch config set` for changes. After changing anything, show the command, the resolved value, and whether a new session is needed.
229
+ Use `memsearch config set` for changes. For trusted keys such as `plugins.*`, `[llm.providers.*]`, `[prompts]`, `embedding.provider`, or `milvus.uri`, set global config by omitting `--project`. Use `--project` only for allowlisted local indexing keys. After changing anything, show the command, the resolved value, and whether a new session is needed.
211
230
 
212
231
  MemSearch TOML changes are read lazily by the CLI, capture daemon, and maintenance runner, so values such as `plugins.opencode.summarize.*`, `plugins.opencode.project_review.*`, `plugins.opencode.user_profile.*`, `[llm.providers.*]`, `[prompts]`, `milvus.*`, and `embedding.*` usually apply on the next capture, recall, index, or maintenance invocation. Restart OpenCode after `opencode.json` or plugin package changes; if capture behavior still looks stale after TOML edits, restart OpenCode or the capture daemon. In final diagnostic/change summaries, make clear that this is MemSearch memory configuration, not OpenCode's own memory/config system.
213
232
 
214
- When useful, remind the user that they can either continue using this `memory-config` skill for guided configuration, or manually run `memsearch config init` for global interactive setup, `memsearch config init --project` for project interactive setup, and `memsearch config set/get/list` for direct CLI changes.
233
+ When useful, remind the user that they can either continue using this `memory-config` skill for guided configuration, or manually run `memsearch config init` for global interactive setup, `memsearch config init --project` for allowlisted project indexing setup, and `memsearch config set/get/list` for direct CLI changes.
@@ -90,14 +90,19 @@ The background pass mines automatically when enabled, starting from the summarie
90
90
 
91
91
  ```bash
92
92
  memsearch config get plugins.opencode.memory_to_skill.enabled 2>/dev/null || echo "false"
93
- # enable the background pass (do not enable silently)
94
- memsearch config set plugins.opencode.memory_to_skill.enabled true --project
93
+ # enable the background pass globally (do not enable silently)
94
+ memsearch config set plugins.opencode.memory_to_skill.enabled true
95
95
  # how eagerly history-mining distils (default 3; lower = more eager)
96
- memsearch config set plugins.opencode.memory_to_skill.min_occurrences 3 --project
96
+ memsearch config set plugins.opencode.memory_to_skill.min_occurrences 3
97
97
  # pre-set install targets (otherwise you are asked at install time)
98
- memsearch config set plugins.opencode.memory_to_skill.paths '[".agents/skills"]' --project
98
+ memsearch config set plugins.opencode.memory_to_skill.paths '[".agents/skills"]'
99
99
  ```
100
100
 
101
+ Since v0.4.11, project-local `.memsearch.toml` accepts only allowlisted local
102
+ indexing keys. Do not use `--project` for `plugins.*` settings such as
103
+ `memory_to_skill.enabled`, `min_occurrences`, or `paths`; put them in global
104
+ config instead.
105
+
101
106
  Note: `enabled` only gates the **background** (session-end) pass. The explicit
102
107
  commands above (`skills add`, `skills install`) always work, and you can mine history (C) directly.
103
108