memory-bank-skill 5.11.0 → 5.12.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/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { fileURLToPath } from "url";
10
10
  // package.json
11
11
  var package_default = {
12
12
  name: "memory-bank-skill",
13
- version: "5.11.0",
13
+ version: "5.12.0",
14
14
  description: "Memory Bank - \u9879\u76EE\u8BB0\u5FC6\u7CFB\u7EDF\uFF0C\u8BA9 AI \u52A9\u624B\u5728\u6BCF\u6B21\u5BF9\u8BDD\u4E2D\u90FD\u80FD\u5FEB\u901F\u7406\u89E3\u9879\u76EE\u4E0A\u4E0B\u6587",
15
15
  type: "module",
16
16
  main: "dist/plugin.js",
package/dist/plugin.js CHANGED
@@ -4,17 +4,6 @@ import { stat, readFile, realpath } from "fs/promises";
4
4
  import { execSync } from "child_process";
5
5
  import path from "path";
6
6
  var DEBUG = process.env.MEMORY_BANK_DEBUG === "1";
7
- var DEFAULT_MAX_CHARS = 12000;
8
- var TRUNCATION_NOTICE = `
9
-
10
- ---
11
-
12
- [TRUNCATED] Memory Bank context exceeded size limit. Read files directly for complete content.`;
13
- var MEMORY_BANK_FILES = [
14
- "memory-bank/brief.md",
15
- "memory-bank/active.md",
16
- "memory-bank/_index.md"
17
- ];
18
7
  var SENTINEL_OPEN = "<memory-bank-bootstrap>";
19
8
  var SENTINEL_CLOSE = "</memory-bank-bootstrap>";
20
9
  var SERVICE_NAME = "memory-bank";
@@ -30,11 +19,6 @@ var agentBySessionID = new Map;
30
19
  function makeStateKey(sessionId, root) {
31
20
  return `${sessionId}::${root}`;
32
21
  }
33
- function maxChars() {
34
- const raw = process.env.MEMORY_BANK_MAX_CHARS;
35
- const n = raw ? Number(raw) : NaN;
36
- return Number.isFinite(n) && n > 0 ? Math.floor(n) : DEFAULT_MAX_CHARS;
37
- }
38
22
  function isPluginGeneratedPrompt(message, content) {
39
23
  if (message?.variant === PLUGIN_PROMPT_VARIANT)
40
24
  return true;
@@ -103,98 +87,21 @@ function createLogger(client) {
103
87
  flush: () => pending
104
88
  };
105
89
  }
106
- async function readTextCached(absPath) {
107
- try {
108
- const st = await stat(absPath);
109
- const cached = fileCache.get(absPath);
110
- if (cached && cached.mtimeMs === st.mtimeMs)
111
- return cached.text;
112
- const text = await readFile(absPath, "utf8");
113
- fileCache.set(absPath, { mtimeMs: st.mtimeMs, text });
114
- return text;
115
- } catch {
116
- return null;
117
- }
118
- }
119
- function truncateToBudget(text, budget) {
120
- if (text.length <= budget)
121
- return text;
122
- const reserve = TRUNCATION_NOTICE.length;
123
- if (budget <= reserve)
124
- return TRUNCATION_NOTICE.slice(0, budget);
125
- return text.slice(0, budget - reserve) + TRUNCATION_NOTICE;
126
- }
127
90
  async function buildMemoryBankContextWithMeta(projectRoot) {
128
- const fnStart = Date.now();
129
91
  if (DEBUG)
130
92
  console.error(`[MB-DEBUG] buildMemoryBankContextWithMeta START projectRoot=${projectRoot}`);
131
- const parts = [];
132
- const files = [];
133
- for (const rel of MEMORY_BANK_FILES) {
134
- const fileStart = Date.now();
135
- const abs = path.join(projectRoot, rel);
136
- if (DEBUG)
137
- console.error(`[MB-DEBUG] reading ${rel}...`);
138
- const content = await readTextCached(abs);
93
+ const mbPath = path.join(projectRoot, "memory-bank");
94
+ try {
95
+ await stat(mbPath);
96
+ } catch {
139
97
  if (DEBUG)
140
- console.error(`[MB-DEBUG] read ${rel} done, hasContent=${!!content}, elapsed=${Date.now() - fileStart}ms`);
141
- if (!content)
142
- continue;
143
- const trimmed = content.trim();
144
- if (!trimmed)
145
- continue;
146
- parts.push(`## ${rel}
147
-
148
- ${trimmed}`);
149
- files.push({ relPath: rel, chars: trimmed.length });
150
- }
151
- if (DEBUG)
152
- console.error(`[MB-DEBUG] all files read, parts=${parts.length}, totalElapsed=${Date.now() - fnStart}ms`);
153
- if (parts.length === 0)
98
+ console.error(`[MB-DEBUG] memory-bank not found`);
154
99
  return null;
155
- const fileList = files.map((f) => f.relPath.replace("memory-bank/", "")).join(", ");
156
- const totalChars = files.reduce((sum, f) => sum + f.chars, 0);
157
- const header = `# Memory Bank Bootstrap (Auto-injected by OpenCode plugin)
158
-
159
- ` + `Use \`memory-bank/_index.md\` to locate additional context files.
160
- ` + `Read more files from \`memory-bank/\` as needed based on the task.
161
-
162
- ` + `**AI \u884C\u4E3A\u6307\u4EE4**\uFF1A
163
- ` + `- \u6BCF\u6B21\u56DE\u590D\u672B\u5C3E\u52A0\u4E00\u884C\u786E\u8BA4\uFF1A\`| \uD83D\uDCDA Memory Bank | ${fileList} (${totalChars.toLocaleString()} chars) |\`
164
- ` + `- **Memory-first\uFF08\u6838\u5FC3\u539F\u5219\uFF09**\uFF1A
165
- ` + ` - \u4EFB\u4F55\u95EE\u9898\u5148\u67E5 _index.md \u5E76\u6253\u5F00\u76F8\u5173\u6587\u6863\uFF08active.md/brief.md/tech.md/docs/requirements/learnings/patterns.md\uFF09
166
- ` + ` - \u627E\u5230\u7B54\u6848 \u2192 \u5F15\u7528\u6587\u4EF6\u8DEF\u5F84\u76F4\u63A5\u56DE\u7B54\uFF1B_index.md \u4E0E\u5BF9\u5E94\u76EE\u5F55\u68C0\u7D22\u65E0\u679C\u6216\u786E\u8BA4\u5DF2\u8FC7\u65F6 \u2192 \u624D\u8BFB\u4EE3\u7801
167
- ` + ` - \u6587\u6863\u4E0E\u4EE3\u7801\u4E0D\u4E00\u81F4\u65F6\u4EE5\u4EE3\u7801\u4E3A\u51C6\uFF0C\u4F46\u5FC5\u987B\u63D0\u8BAE\u66F4\u65B0\u6587\u6863
168
- ` + ` - \u82E5\u56E0\u6587\u6863\u7F3A\u5931\u800C\u8BFB\u4E86\u4EE3\u7801 \u2192 \u8FD9\u672C\u8EAB\u5C31\u662F\u5199\u5165\u89E6\u53D1\u70B9\uFF0C\u9700\u70B9\u540D\u8981\u8865\u7684\u6587\u4EF6\u8DEF\u5F84
169
- ` + `- **\u6587\u6863\u9A71\u52A8\u5F00\u53D1**\uFF1A
170
- ` + ` - \u65B9\u6848\u8BA8\u8BBA\u5B8C\u6210\u540E\uFF0C**\u5148\u5199\u8BBE\u8BA1\u6587\u6863\u5230 memory-bank/docs/\uFF0C\u518D\u5199\u4EE3\u7801**
171
- ` + ` - \u8BBE\u8BA1\u6587\u6863\u662F\u5951\u7EA6\uFF0C\u4EE3\u7801\u5B9E\u73B0\u8981\u7B26\u5408\u6587\u6863
172
- ` + ` - \u5B9E\u73B0\u5B8C\u6210\u540E\u56DE\u987E\uFF1A\u5982\u6709\u504F\u5DEE\uFF0C\u51B3\u5B9A\u662F\u6539\u6587\u6863\u8FD8\u662F\u6539\u5B9E\u73B0
173
- ` + `- **\u5199\u5165\u89E6\u53D1\u573A\u666F**\uFF08\u8BED\u4E49\u5224\u65AD\uFF0C\u975E\u5173\u952E\u8BCD\u5339\u914D\uFF09\uFF1A
174
- ` + ` - \u65B9\u6848\u8BA8\u8BBA\u786E\u5B9A / \u8BBE\u8BA1\u53D8\u66F4\uFF08"\u91CD\u65B0\u8BBE\u8BA1"\u3001"\u6539\u4E00\u4E0B\u8BBE\u8BA1"\u3001"\u90A3\u5C31\u8FD9\u6837\u5427"\uFF09\u2192 \u68C0\u67E5 docs/design-*.md \u662F\u5426\u5DF2\u5B58\u5728\uFF0C\u5B58\u5728\u5219\u66F4\u65B0\uFF0C\u5426\u5219\u521B\u5EFA
175
- ` + ` - \u7528\u6237\u63CF\u8FF0\u65B0\u529F\u80FD/\u9700\u6C42\uFF08"\u6211\u9700\u8981..."\u3001"\u80FD\u4E0D\u80FD\u52A0..."\u3001"\u5E2E\u6211\u505A..."\u3001"\u8981\u5B9E\u73B0..."\uFF09\u2192 requirements/
176
- ` + ` - \u7528\u6237\u505A\u51FA\u6280\u672F\u9009\u578B\uFF08"\u6211\u4EEC\u7528 X \u5427"\u3001"\u51B3\u5B9A\u91C7\u7528..."\u3001"\u9009\u62E9..."\uFF09\u2192 patterns.md
177
- ` + ` - \u4FEE\u590D\u4E86 bug \u6216\u8E29\u5751\u7ECF\u9A8C\uFF08"\u539F\u6765\u95EE\u9898\u662F..."\u3001"\u8FD9\u4E2A\u5751\u662F..."\u3001"\u53D1\u73B0..."\uFF09\u2192 learnings/
178
- ` + ` - AI \u4FEE\u6539\u4E86\u4EE3\u7801/\u914D\u7F6E\u6587\u4EF6 \u2192 active.md\uFF08\u5982\u6D89\u53CA bug \u4FEE\u590D\u5219\u540C\u65F6 learnings/\uFF09
179
- ` + ` - \u5F53\u524D\u4EFB\u52A1\u5B8C\u6210\uFF0C\u7126\u70B9\u5207\u6362 \u2192 active.md
180
- ` + `- **Todo \u521B\u5EFA\u89C4\u5219\uFF08\u5FC5\u987B\uFF09**\uFF1A
181
- ` + ` - \u65B9\u6848\u8BA8\u8BBA\u5B8C\u6210\u540E\u5F00\u59CB\u843D\u5730\uFF1A\u7B2C\u4E00\u9879\u5FC5\u987B\u662F"\u5199\u5165\u8BBE\u8BA1\u6587\u6863\u5230 memory-bank/docs/"
182
- ` + ` - \u6700\u540E\u4E00\u9879\u5FC5\u987B\u662F"\u66F4\u65B0 Memory Bank"\uFF08\u68C0\u67E5\u89E6\u53D1\u573A\u666F\u5E76\u66F4\u65B0\u76F8\u5E94\u6587\u4EF6\uFF09
183
-
184
- ` + `---
185
-
186
- `;
187
- const wrapped = `${SENTINEL_OPEN}
188
- ` + header + parts.join(`
189
-
190
- ---
191
-
192
- `) + `
193
- ${SENTINEL_CLOSE}`;
194
- const budget = maxChars();
195
- const truncated = wrapped.length > budget;
196
- const text = truncateToBudget(wrapped, budget);
197
- return { text, files, totalChars, truncated };
100
+ }
101
+ const text = `${SENTINEL_OPEN}
102
+ ` + `**\u6267\u884C\u4EFB\u4F55\u5DE5\u4F5C\u6216\u56DE\u7B54\u95EE\u9898\u4E4B\u524D\uFF0C\u5FC5\u987B\u5148\u52A0\u8F7D \`/memory-bank\` skill\u3002**
103
+ ` + `${SENTINEL_CLOSE}`;
104
+ return { text, files: [], totalChars: 0, truncated: false };
198
105
  }
199
106
  async function buildMemoryBankContext(projectRoot) {
200
107
  const result = await buildMemoryBankContextWithMeta(projectRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-bank-skill",
3
- "version": "5.11.0",
3
+ "version": "5.12.0",
4
4
  "description": "Memory Bank - 项目记忆系统,让 AI 助手在每次对话中都能快速理解项目上下文",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",