@vuau/agent-memory 0.1.1 → 0.2.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/README.md +9 -0
- package/dist/bin/cli.js +105 -2
- package/dist/index.js +96 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,9 +82,18 @@ npx @vuau/agent-memory init
|
|
|
82
82
|
npx @vuau/agent-memory init --force # Overwrite existing files
|
|
83
83
|
npx @vuau/agent-memory init --name "My App" # Custom project name
|
|
84
84
|
npx @vuau/agent-memory init --no-copilot # Skip copilot-instructions.md
|
|
85
|
+
npx @vuau/agent-memory init --opencode # Wire up OpenCode plugin
|
|
85
86
|
npx @vuau/agent-memory doctor # Validate structure
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
#### `--opencode` flag
|
|
90
|
+
|
|
91
|
+
Wires up the OpenCode plugin automatically:
|
|
92
|
+
- Creates/updates `.opencode/package.json` with `@vuau/agent-memory` dependency
|
|
93
|
+
- Creates/updates `opencode.json` with `"plugin": ["@vuau/agent-memory"]`
|
|
94
|
+
|
|
95
|
+
After running, restart OpenCode to activate the plugin.
|
|
96
|
+
|
|
88
97
|
## How It Works
|
|
89
98
|
|
|
90
99
|
### For AI Agents
|
package/dist/bin/cli.js
CHANGED
|
@@ -79,8 +79,57 @@ function scaffold(projectDir, config = {}, force = false) {
|
|
|
79
79
|
writeFileSync(specKeep, "");
|
|
80
80
|
result.created.push(`${SPEC_DIR}/.gitkeep`);
|
|
81
81
|
}
|
|
82
|
+
if (config.opencode) {
|
|
83
|
+
scaffoldOpenCode(projectDir, result, force);
|
|
84
|
+
}
|
|
82
85
|
return result;
|
|
83
86
|
}
|
|
87
|
+
function scaffoldOpenCode(projectDir, result, force) {
|
|
88
|
+
const PACKAGE_NAME = "@vuau/agent-memory";
|
|
89
|
+
const opencodePkgPath = join(projectDir, ".opencode", "package.json");
|
|
90
|
+
const opencodeDir = join(projectDir, ".opencode");
|
|
91
|
+
if (!existsSync(opencodeDir)) {
|
|
92
|
+
mkdirSync(opencodeDir, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
if (!existsSync(opencodePkgPath)) {
|
|
95
|
+
writeFileSync(
|
|
96
|
+
opencodePkgPath,
|
|
97
|
+
JSON.stringify({ dependencies: { [PACKAGE_NAME]: "latest" } }, null, 2) + "\n"
|
|
98
|
+
);
|
|
99
|
+
result.created.push(".opencode/package.json");
|
|
100
|
+
} else {
|
|
101
|
+
const pkg = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
|
|
102
|
+
const deps = pkg.dependencies || {};
|
|
103
|
+
if (!deps[PACKAGE_NAME] || force) {
|
|
104
|
+
deps[PACKAGE_NAME] = "latest";
|
|
105
|
+
pkg.dependencies = deps;
|
|
106
|
+
writeFileSync(opencodePkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
107
|
+
if (!deps[PACKAGE_NAME]) {
|
|
108
|
+
result.created.push(".opencode/package.json");
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
result.skipped.push(".opencode/package.json");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const opencodeJsonPath = join(projectDir, "opencode.json");
|
|
115
|
+
if (!existsSync(opencodeJsonPath)) {
|
|
116
|
+
writeFileSync(
|
|
117
|
+
opencodeJsonPath,
|
|
118
|
+
JSON.stringify({ plugin: [PACKAGE_NAME] }, null, 2) + "\n"
|
|
119
|
+
);
|
|
120
|
+
result.created.push("opencode.json");
|
|
121
|
+
} else {
|
|
122
|
+
const config = JSON.parse(readFileSync(opencodeJsonPath, "utf-8"));
|
|
123
|
+
const plugins = config.plugin || [];
|
|
124
|
+
if (!plugins.includes(PACKAGE_NAME)) {
|
|
125
|
+
config.plugin = [...plugins, PACKAGE_NAME];
|
|
126
|
+
writeFileSync(opencodeJsonPath, JSON.stringify(config, null, 2) + "\n");
|
|
127
|
+
result.created.push("opencode.json (merged plugin)");
|
|
128
|
+
} else {
|
|
129
|
+
result.skipped.push("opencode.json");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
84
133
|
function guessProjectName(dir) {
|
|
85
134
|
const pkgPath = join(dir, "package.json");
|
|
86
135
|
if (existsSync(pkgPath)) {
|
|
@@ -151,6 +200,53 @@ function doctor(projectDir) {
|
|
|
151
200
|
});
|
|
152
201
|
}
|
|
153
202
|
}
|
|
203
|
+
const opencodePkgPath = join2(projectDir, ".opencode", "package.json");
|
|
204
|
+
const opencodeJsonPath = join2(projectDir, "opencode.json");
|
|
205
|
+
const opencodeExists = existsSync2(join2(projectDir, ".opencode"));
|
|
206
|
+
if (opencodeExists) {
|
|
207
|
+
if (!existsSync2(opencodePkgPath)) {
|
|
208
|
+
issues.push({
|
|
209
|
+
level: "warning",
|
|
210
|
+
file: ".opencode/package.json",
|
|
211
|
+
message: "Missing \u2014 run 'agent-memory init --opencode' to wire up the plugin"
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
try {
|
|
215
|
+
const pkg = JSON.parse(readFileSync2(opencodePkgPath, "utf-8"));
|
|
216
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
217
|
+
if (!deps["@vuau/agent-memory"]) {
|
|
218
|
+
issues.push({
|
|
219
|
+
level: "warning",
|
|
220
|
+
file: ".opencode/package.json",
|
|
221
|
+
message: "@vuau/agent-memory not in dependencies \u2014 run 'agent-memory init --opencode'"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
} catch {
|
|
225
|
+
issues.push({ level: "warning", file: ".opencode/package.json", message: "Invalid JSON" });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (!existsSync2(opencodeJsonPath)) {
|
|
229
|
+
issues.push({
|
|
230
|
+
level: "warning",
|
|
231
|
+
file: "opencode.json",
|
|
232
|
+
message: "Missing \u2014 run 'agent-memory init --opencode' to wire up the plugin"
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
try {
|
|
236
|
+
const config = JSON.parse(readFileSync2(opencodeJsonPath, "utf-8"));
|
|
237
|
+
const plugins = config.plugin || [];
|
|
238
|
+
if (!plugins.includes("@vuau/agent-memory")) {
|
|
239
|
+
issues.push({
|
|
240
|
+
level: "warning",
|
|
241
|
+
file: "opencode.json",
|
|
242
|
+
message: "@vuau/agent-memory not in plugin array \u2014 run 'agent-memory init --opencode'"
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
} catch {
|
|
246
|
+
issues.push({ level: "warning", file: "opencode.json", message: "Invalid JSON" });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
154
250
|
return { ok: issues.filter((i) => i.level === "error").length === 0, issues };
|
|
155
251
|
}
|
|
156
252
|
|
|
@@ -170,18 +266,21 @@ Options (init):
|
|
|
170
266
|
--force Overwrite existing files
|
|
171
267
|
--name <name> Project name (default: from package.json)
|
|
172
268
|
--no-copilot Skip .github/copilot-instructions.md
|
|
269
|
+
--opencode Wire up OpenCode plugin (.opencode/package.json + opencode.json)
|
|
173
270
|
`);
|
|
174
271
|
}
|
|
175
272
|
function runInit() {
|
|
176
273
|
const force = args.includes("--force");
|
|
177
274
|
const noCopilot = args.includes("--no-copilot");
|
|
275
|
+
const opencode = args.includes("--opencode");
|
|
178
276
|
const nameIdx = args.indexOf("--name");
|
|
179
277
|
const projectName = nameIdx !== -1 ? args[nameIdx + 1] : void 0;
|
|
180
278
|
const cwd = process.cwd();
|
|
181
279
|
console.log(`Initializing agent memory in ${cwd}...`);
|
|
182
280
|
const result = scaffold(cwd, {
|
|
183
281
|
projectName,
|
|
184
|
-
copilotInstructions: !noCopilot
|
|
282
|
+
copilotInstructions: !noCopilot,
|
|
283
|
+
opencode
|
|
185
284
|
}, force);
|
|
186
285
|
if (result.created.length > 0) {
|
|
187
286
|
console.log("\nCreated:");
|
|
@@ -201,7 +300,11 @@ function runInit() {
|
|
|
201
300
|
console.log("\nNext steps:");
|
|
202
301
|
console.log(" 1. Edit AGENTS.md \u2014 add your project-specific rules");
|
|
203
302
|
console.log(" 2. Add spec files to .agents/spec/ for detailed documentation");
|
|
204
|
-
|
|
303
|
+
if (opencode) {
|
|
304
|
+
console.log(" 3. Restart OpenCode to activate the plugin");
|
|
305
|
+
} else {
|
|
306
|
+
console.log(" 3. For OpenCode: run with --opencode flag to wire up the plugin");
|
|
307
|
+
}
|
|
205
308
|
console.log("");
|
|
206
309
|
}
|
|
207
310
|
function runDoctor() {
|
package/dist/index.js
CHANGED
|
@@ -81,8 +81,57 @@ function scaffold(projectDir, config = {}, force = false) {
|
|
|
81
81
|
writeFileSync(specKeep, "");
|
|
82
82
|
result.created.push(`${SPEC_DIR}/.gitkeep`);
|
|
83
83
|
}
|
|
84
|
+
if (config.opencode) {
|
|
85
|
+
scaffoldOpenCode(projectDir, result, force);
|
|
86
|
+
}
|
|
84
87
|
return result;
|
|
85
88
|
}
|
|
89
|
+
function scaffoldOpenCode(projectDir, result, force) {
|
|
90
|
+
const PACKAGE_NAME = "@vuau/agent-memory";
|
|
91
|
+
const opencodePkgPath = join(projectDir, ".opencode", "package.json");
|
|
92
|
+
const opencodeDir = join(projectDir, ".opencode");
|
|
93
|
+
if (!existsSync(opencodeDir)) {
|
|
94
|
+
mkdirSync(opencodeDir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
if (!existsSync(opencodePkgPath)) {
|
|
97
|
+
writeFileSync(
|
|
98
|
+
opencodePkgPath,
|
|
99
|
+
JSON.stringify({ dependencies: { [PACKAGE_NAME]: "latest" } }, null, 2) + "\n"
|
|
100
|
+
);
|
|
101
|
+
result.created.push(".opencode/package.json");
|
|
102
|
+
} else {
|
|
103
|
+
const pkg = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
|
|
104
|
+
const deps = pkg.dependencies || {};
|
|
105
|
+
if (!deps[PACKAGE_NAME] || force) {
|
|
106
|
+
deps[PACKAGE_NAME] = "latest";
|
|
107
|
+
pkg.dependencies = deps;
|
|
108
|
+
writeFileSync(opencodePkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
109
|
+
if (!deps[PACKAGE_NAME]) {
|
|
110
|
+
result.created.push(".opencode/package.json");
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
result.skipped.push(".opencode/package.json");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const opencodeJsonPath = join(projectDir, "opencode.json");
|
|
117
|
+
if (!existsSync(opencodeJsonPath)) {
|
|
118
|
+
writeFileSync(
|
|
119
|
+
opencodeJsonPath,
|
|
120
|
+
JSON.stringify({ plugin: [PACKAGE_NAME] }, null, 2) + "\n"
|
|
121
|
+
);
|
|
122
|
+
result.created.push("opencode.json");
|
|
123
|
+
} else {
|
|
124
|
+
const config = JSON.parse(readFileSync(opencodeJsonPath, "utf-8"));
|
|
125
|
+
const plugins = config.plugin || [];
|
|
126
|
+
if (!plugins.includes(PACKAGE_NAME)) {
|
|
127
|
+
config.plugin = [...plugins, PACKAGE_NAME];
|
|
128
|
+
writeFileSync(opencodeJsonPath, JSON.stringify(config, null, 2) + "\n");
|
|
129
|
+
result.created.push("opencode.json (merged plugin)");
|
|
130
|
+
} else {
|
|
131
|
+
result.skipped.push("opencode.json");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
86
135
|
function guessProjectName(dir) {
|
|
87
136
|
const pkgPath = join(dir, "package.json");
|
|
88
137
|
if (existsSync(pkgPath)) {
|
|
@@ -329,6 +378,53 @@ function doctor(projectDir) {
|
|
|
329
378
|
});
|
|
330
379
|
}
|
|
331
380
|
}
|
|
381
|
+
const opencodePkgPath = join4(projectDir, ".opencode", "package.json");
|
|
382
|
+
const opencodeJsonPath = join4(projectDir, "opencode.json");
|
|
383
|
+
const opencodeExists = existsSync5(join4(projectDir, ".opencode"));
|
|
384
|
+
if (opencodeExists) {
|
|
385
|
+
if (!existsSync5(opencodePkgPath)) {
|
|
386
|
+
issues.push({
|
|
387
|
+
level: "warning",
|
|
388
|
+
file: ".opencode/package.json",
|
|
389
|
+
message: "Missing \u2014 run 'agent-memory init --opencode' to wire up the plugin"
|
|
390
|
+
});
|
|
391
|
+
} else {
|
|
392
|
+
try {
|
|
393
|
+
const pkg = JSON.parse(readFileSync5(opencodePkgPath, "utf-8"));
|
|
394
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
395
|
+
if (!deps["@vuau/agent-memory"]) {
|
|
396
|
+
issues.push({
|
|
397
|
+
level: "warning",
|
|
398
|
+
file: ".opencode/package.json",
|
|
399
|
+
message: "@vuau/agent-memory not in dependencies \u2014 run 'agent-memory init --opencode'"
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
} catch {
|
|
403
|
+
issues.push({ level: "warning", file: ".opencode/package.json", message: "Invalid JSON" });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (!existsSync5(opencodeJsonPath)) {
|
|
407
|
+
issues.push({
|
|
408
|
+
level: "warning",
|
|
409
|
+
file: "opencode.json",
|
|
410
|
+
message: "Missing \u2014 run 'agent-memory init --opencode' to wire up the plugin"
|
|
411
|
+
});
|
|
412
|
+
} else {
|
|
413
|
+
try {
|
|
414
|
+
const config = JSON.parse(readFileSync5(opencodeJsonPath, "utf-8"));
|
|
415
|
+
const plugins = config.plugin || [];
|
|
416
|
+
if (!plugins.includes("@vuau/agent-memory")) {
|
|
417
|
+
issues.push({
|
|
418
|
+
level: "warning",
|
|
419
|
+
file: "opencode.json",
|
|
420
|
+
message: "@vuau/agent-memory not in plugin array \u2014 run 'agent-memory init --opencode'"
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
} catch {
|
|
424
|
+
issues.push({ level: "warning", file: "opencode.json", message: "Invalid JSON" });
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
332
428
|
return { ok: issues.filter((i) => i.level === "error").length === 0, issues };
|
|
333
429
|
}
|
|
334
430
|
export {
|