memory-bank-skill 5.2.0 → 5.3.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 +45 -147
- package/dist/plugin.js +702 -0
- package/package.json +6 -3
- package/plugin/memory-bank.ts +0 -893
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
-
for (let key of __getOwnPropNames(mod))
|
|
12
|
-
if (!__hasOwnProp.call(to, key))
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: () => mod[key],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __require = import.meta.require;
|
|
20
3
|
|
|
21
4
|
// src/cli.ts
|
|
22
5
|
import { promises as fs } from "fs";
|
|
@@ -24,7 +7,7 @@ import { homedir } from "os";
|
|
|
24
7
|
import { join, dirname } from "path";
|
|
25
8
|
import { createHash } from "crypto";
|
|
26
9
|
import { fileURLToPath } from "url";
|
|
27
|
-
var VERSION = "5.
|
|
10
|
+
var VERSION = "5.3.0";
|
|
28
11
|
var colors = {
|
|
29
12
|
reset: "\x1B[0m",
|
|
30
13
|
bold: "\x1B[1m",
|
|
@@ -163,26 +146,9 @@ async function installSkillFiles(packageRoot, undoStack, manifestFiles) {
|
|
|
163
146
|
details: destDir
|
|
164
147
|
};
|
|
165
148
|
}
|
|
166
|
-
async function
|
|
167
|
-
const srcPath = join(packageRoot, "plugin", "memory-bank.ts");
|
|
168
|
-
const destPath = join(homedir(), ".config", "opencode", "plugin", "memory-bank.ts");
|
|
169
|
-
if (!await exists(srcPath)) {
|
|
170
|
-
throw new Error(`Plugin source not found: ${srcPath}`);
|
|
171
|
-
}
|
|
172
|
-
const existed = await exists(destPath);
|
|
173
|
-
const content = await fs.readFile(srcPath);
|
|
174
|
-
await atomicWriteFile(destPath, content, undoStack);
|
|
175
|
-
manifestFiles.push({ path: destPath, sha256: sha256(content) });
|
|
176
|
-
return {
|
|
177
|
-
step: "Installing plugin",
|
|
178
|
-
status: existed ? "updated" : "created",
|
|
179
|
-
details: destPath
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
async function configureOpencodeJson(undoStack) {
|
|
149
|
+
async function installPluginToConfig(undoStack) {
|
|
183
150
|
const configPath = join(homedir(), ".config", "opencode", "opencode.json");
|
|
184
|
-
const
|
|
185
|
-
const pluginUrl = `file://${pluginPath}`;
|
|
151
|
+
const pluginPackage = "memory-bank-skill";
|
|
186
152
|
let config = {};
|
|
187
153
|
let existed = false;
|
|
188
154
|
let modified = false;
|
|
@@ -199,7 +165,7 @@ async function configureOpencodeJson(undoStack) {
|
|
|
199
165
|
|
|
200
166
|
` + JSON.stringify({
|
|
201
167
|
permission: { skill: "allow" },
|
|
202
|
-
plugin: [
|
|
168
|
+
plugin: [pluginPackage]
|
|
203
169
|
}, null, 2));
|
|
204
170
|
}
|
|
205
171
|
}
|
|
@@ -214,9 +180,16 @@ async function configureOpencodeJson(undoStack) {
|
|
|
214
180
|
if (!Array.isArray(config.plugin)) {
|
|
215
181
|
config.plugin = [];
|
|
216
182
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
183
|
+
const oldPluginUrl = `file://${join(homedir(), ".config", "opencode", "plugin", "memory-bank.ts")}`;
|
|
184
|
+
const oldPluginIndex = config.plugin.indexOf(oldPluginUrl);
|
|
185
|
+
if (oldPluginIndex !== -1) {
|
|
186
|
+
config.plugin.splice(oldPluginIndex, 1);
|
|
187
|
+
changes.push("Removed old file:// plugin reference");
|
|
188
|
+
modified = true;
|
|
189
|
+
}
|
|
190
|
+
if (!config.plugin.includes(pluginPackage)) {
|
|
191
|
+
config.plugin.push(pluginPackage);
|
|
192
|
+
changes.push(`Added plugin: ${pluginPackage}`);
|
|
220
193
|
modified = true;
|
|
221
194
|
}
|
|
222
195
|
if (modified) {
|
|
@@ -225,51 +198,11 @@ async function configureOpencodeJson(undoStack) {
|
|
|
225
198
|
await atomicWriteFile(configPath, newContent, undoStack);
|
|
226
199
|
}
|
|
227
200
|
return {
|
|
228
|
-
step: "Configuring opencode.json",
|
|
201
|
+
step: "Configuring plugin in opencode.json",
|
|
229
202
|
status: modified ? existed ? "updated" : "created" : "already-configured",
|
|
230
203
|
details: changes.join(", ") || "Already configured"
|
|
231
204
|
};
|
|
232
205
|
}
|
|
233
|
-
async function ensurePluginDependencies(undoStack) {
|
|
234
|
-
const packageJsonPath = join(homedir(), ".config", "opencode", "package.json");
|
|
235
|
-
let pkg = { dependencies: {} };
|
|
236
|
-
let existed = false;
|
|
237
|
-
let modified = false;
|
|
238
|
-
if (await exists(packageJsonPath)) {
|
|
239
|
-
existed = true;
|
|
240
|
-
try {
|
|
241
|
-
const content = await fs.readFile(packageJsonPath, "utf-8");
|
|
242
|
-
pkg = JSON.parse(content);
|
|
243
|
-
} catch (err) {
|
|
244
|
-
throw new Error(`Failed to parse ${packageJsonPath}: ${err}
|
|
245
|
-
|
|
246
|
-
` + `Please fix the JSON manually, or add this to your config:
|
|
247
|
-
|
|
248
|
-
` + JSON.stringify({
|
|
249
|
-
dependencies: {
|
|
250
|
-
"@opencode-ai/plugin": "^1.1.14"
|
|
251
|
-
}
|
|
252
|
-
}, null, 2));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (!pkg.dependencies) {
|
|
256
|
-
pkg.dependencies = {};
|
|
257
|
-
}
|
|
258
|
-
if (!pkg.dependencies["@opencode-ai/plugin"]) {
|
|
259
|
-
pkg.dependencies["@opencode-ai/plugin"] = "^1.1.14";
|
|
260
|
-
modified = true;
|
|
261
|
-
}
|
|
262
|
-
if (modified) {
|
|
263
|
-
const newContent = JSON.stringify(pkg, null, 2) + `
|
|
264
|
-
`;
|
|
265
|
-
await atomicWriteFile(packageJsonPath, newContent, undoStack);
|
|
266
|
-
}
|
|
267
|
-
return {
|
|
268
|
-
step: "Ensuring plugin dependencies",
|
|
269
|
-
status: modified ? existed ? "updated" : "created" : "already-configured",
|
|
270
|
-
details: modified ? "Added @opencode-ai/plugin" : "Already present"
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
206
|
async function writeManifest(manifestFiles, undoStack) {
|
|
274
207
|
const manifestPath = join(homedir(), ".config", "opencode", "skill", "memory-bank", ".manifest.json");
|
|
275
208
|
const manifest = {
|
|
@@ -280,24 +213,6 @@ async function writeManifest(manifestFiles, undoStack) {
|
|
|
280
213
|
await atomicWriteFile(manifestPath, JSON.stringify(manifest, null, 2) + `
|
|
281
214
|
`, undoStack);
|
|
282
215
|
}
|
|
283
|
-
async function runBunInstall() {
|
|
284
|
-
const opencodeDir = join(homedir(), ".config", "opencode");
|
|
285
|
-
const nodeModulesPath = join(opencodeDir, "node_modules", "@opencode-ai", "plugin");
|
|
286
|
-
if (await exists(nodeModulesPath)) {
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
try {
|
|
290
|
-
const { execSync } = await import("child_process");
|
|
291
|
-
execSync("bun install", {
|
|
292
|
-
cwd: opencodeDir,
|
|
293
|
-
stdio: "pipe",
|
|
294
|
-
timeout: 60000
|
|
295
|
-
});
|
|
296
|
-
return true;
|
|
297
|
-
} catch (err) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
216
|
async function install() {
|
|
302
217
|
log(`
|
|
303
218
|
${colors.bold}Memory Bank Skill Installer v${VERSION}${colors.reset}
|
|
@@ -307,34 +222,19 @@ ${colors.bold}Memory Bank Skill Installer v${VERSION}${colors.reset}
|
|
|
307
222
|
const manifestFiles = [];
|
|
308
223
|
const results = [];
|
|
309
224
|
try {
|
|
310
|
-
logStep(1,
|
|
225
|
+
logStep(1, 2, "Installing skill files...");
|
|
311
226
|
const r1 = await installSkillFiles(packageRoot, undoStack, manifestFiles);
|
|
312
227
|
logDetail(r1.details || "");
|
|
313
228
|
results.push(r1);
|
|
314
|
-
logStep(2,
|
|
315
|
-
const r2 = await
|
|
229
|
+
logStep(2, 2, "Configuring plugin...");
|
|
230
|
+
const r2 = await installPluginToConfig(undoStack);
|
|
316
231
|
logDetail(r2.details || "");
|
|
317
232
|
results.push(r2);
|
|
318
|
-
logStep(3, 5, "Configuring opencode.json...");
|
|
319
|
-
const r3 = await configureOpencodeJson(undoStack);
|
|
320
|
-
logDetail(r3.details || "");
|
|
321
|
-
results.push(r3);
|
|
322
|
-
logStep(4, 5, "Ensuring plugin dependencies...");
|
|
323
|
-
const r4 = await ensurePluginDependencies(undoStack);
|
|
324
|
-
logDetail(r4.details || "");
|
|
325
|
-
results.push(r4);
|
|
326
|
-
logStep(5, 5, "Installing dependencies...");
|
|
327
|
-
const bunSuccess = await runBunInstall();
|
|
328
|
-
if (bunSuccess) {
|
|
329
|
-
logDetail("Dependencies ready");
|
|
330
|
-
} else {
|
|
331
|
-
logDetail(`${colors.yellow}Run manually: cd ~/.config/opencode && bun install${colors.reset}`);
|
|
332
|
-
}
|
|
333
233
|
await writeManifest(manifestFiles, undoStack);
|
|
334
234
|
await cleanupBackups(undoStack);
|
|
335
235
|
const allSkipped = results.every((r) => r.status === "already-configured" || r.status === "skipped");
|
|
336
236
|
log("");
|
|
337
|
-
if (allSkipped
|
|
237
|
+
if (allSkipped) {
|
|
338
238
|
logSuccess(`Already installed (v${VERSION})`);
|
|
339
239
|
} else {
|
|
340
240
|
logSuccess("Installation complete!");
|
|
@@ -354,35 +254,33 @@ async function doctor() {
|
|
|
354
254
|
log(`
|
|
355
255
|
${colors.bold}Memory Bank Skill Doctor v${VERSION}${colors.reset}
|
|
356
256
|
`);
|
|
357
|
-
const checks = [
|
|
358
|
-
{
|
|
359
|
-
name: "Skill files",
|
|
360
|
-
path: join(homedir(), ".config", "opencode", "skill", "memory-bank", "SKILL.md")
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
name: "Plugin file",
|
|
364
|
-
path: join(homedir(), ".config", "opencode", "plugin", "memory-bank.ts")
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
name: "OpenCode config",
|
|
368
|
-
path: join(homedir(), ".config", "opencode", "opencode.json")
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
name: "Plugin dependencies",
|
|
372
|
-
path: join(homedir(), ".config", "opencode", "package.json")
|
|
373
|
-
}
|
|
374
|
-
];
|
|
375
257
|
let allOk = true;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
258
|
+
const skillPath = join(homedir(), ".config", "opencode", "skill", "memory-bank", "SKILL.md");
|
|
259
|
+
const skillOk = await exists(skillPath);
|
|
260
|
+
if (skillOk) {
|
|
261
|
+
log(`${colors.green}\u2713${colors.reset} Skill files`);
|
|
262
|
+
logDetail(skillPath);
|
|
263
|
+
} else {
|
|
264
|
+
log(`${colors.red}\u2717${colors.reset} Skill files`);
|
|
265
|
+
logDetail(`Missing: ${skillPath}`);
|
|
266
|
+
allOk = false;
|
|
267
|
+
}
|
|
268
|
+
const configPath = join(homedir(), ".config", "opencode", "opencode.json");
|
|
269
|
+
let pluginConfigured = false;
|
|
270
|
+
if (await exists(configPath)) {
|
|
271
|
+
try {
|
|
272
|
+
const content = await fs.readFile(configPath, "utf-8");
|
|
273
|
+
const config = JSON.parse(content);
|
|
274
|
+
pluginConfigured = Array.isArray(config.plugin) && config.plugin.includes("memory-bank-skill");
|
|
275
|
+
} catch {}
|
|
276
|
+
}
|
|
277
|
+
if (pluginConfigured) {
|
|
278
|
+
log(`${colors.green}\u2713${colors.reset} Plugin configured in opencode.json`);
|
|
279
|
+
logDetail("memory-bank-skill");
|
|
280
|
+
} else {
|
|
281
|
+
log(`${colors.red}\u2717${colors.reset} Plugin not configured`);
|
|
282
|
+
logDetail("Add 'memory-bank-skill' to plugin array in opencode.json");
|
|
283
|
+
allOk = false;
|
|
386
284
|
}
|
|
387
285
|
const manifestPath = join(homedir(), ".config", "opencode", "skill", "memory-bank", ".manifest.json");
|
|
388
286
|
if (await exists(manifestPath)) {
|