@mrc2204/agent-smart-memo 5.1.7 → 5.1.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/bin/asm.mjs +95 -4
- package/package.json +1 -1
package/bin/asm.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
2
|
+
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { runInitOpenClaw } from "../scripts/init-openclaw.mjs";
|
|
5
5
|
import { createShellRunner, runInitSetupFlow, runInstallPlatformFlow } from "../dist/cli/platform-installers.js";
|
|
6
6
|
import { runOpencodeMcpServer } from "./opencode-mcp-server.mjs";
|
|
@@ -8,6 +8,10 @@ import { runOpencodeMcpServer } from "./opencode-mcp-server.mjs";
|
|
|
8
8
|
const ASM_PLUGIN_PACKAGE = "@mrc2204/agent-smart-memo";
|
|
9
9
|
const ASM_PLUGIN_ID = "agent-smart-memo";
|
|
10
10
|
|
|
11
|
+
console.error("[ASM-TRACE] import.meta.url=", import.meta.url);
|
|
12
|
+
console.error("[ASM-TRACE] argv=", JSON.stringify(process.argv));
|
|
13
|
+
console.error("[ASM-TRACE] cwd=", process.cwd());
|
|
14
|
+
|
|
11
15
|
function text(value) {
|
|
12
16
|
return typeof value === "string" ? value.trim() : "";
|
|
13
17
|
}
|
|
@@ -40,12 +44,15 @@ export function parseAsmCliArgs(argv = []) {
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
if (first === "install") {
|
|
43
|
-
const platform = String(args[1] || "openclaw").trim().toLowerCase();
|
|
44
47
|
const hasExplicitPlatform = Boolean(args[1]);
|
|
48
|
+
if (!hasExplicitPlatform) {
|
|
49
|
+
return { command: "install-cli", argv: [] };
|
|
50
|
+
}
|
|
51
|
+
const platform = String(args[1] || "").trim().toLowerCase();
|
|
45
52
|
return {
|
|
46
53
|
command: "install-platform",
|
|
47
54
|
platform,
|
|
48
|
-
argv:
|
|
55
|
+
argv: args.slice(2),
|
|
49
56
|
};
|
|
50
57
|
}
|
|
51
58
|
|
|
@@ -80,6 +87,7 @@ export function printHelp(log = console.log) {
|
|
|
80
87
|
log("asm - Agent Smart Memo CLI");
|
|
81
88
|
log("");
|
|
82
89
|
log("Usage:");
|
|
90
|
+
log(" asm install # install / expose CLI only");
|
|
83
91
|
log(" asm setup-openclaw [--yes]");
|
|
84
92
|
log(" asm setup openclaw [--yes]");
|
|
85
93
|
log(" asm install openclaw [--yes]");
|
|
@@ -167,6 +175,84 @@ function parseProjectEventArgs(argv = []) {
|
|
|
167
175
|
return out;
|
|
168
176
|
}
|
|
169
177
|
|
|
178
|
+
function resolveUserBinDir() {
|
|
179
|
+
const home = process.env.HOME || process.cwd();
|
|
180
|
+
return join(home, '.local', 'bin');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function pathContains(dir) {
|
|
184
|
+
return String(process.env.PATH || '').split(':').includes(dir);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function detectShellProfile() {
|
|
188
|
+
const shell = String(process.env.SHELL || '').trim();
|
|
189
|
+
const home = process.env.HOME || process.cwd();
|
|
190
|
+
if (shell.endsWith('/zsh')) return { shell: 'zsh', profilePath: join(home, '.zshrc') };
|
|
191
|
+
if (shell.endsWith('/bash')) return { shell: 'bash', profilePath: join(home, '.bashrc') };
|
|
192
|
+
return { shell: shell || 'unknown', profilePath: join(home, '.profile') };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function profileHasPathLine(profilePath, userBin) {
|
|
196
|
+
try {
|
|
197
|
+
const content = readFileSync(profilePath, 'utf8');
|
|
198
|
+
return content.includes(userBin) || content.includes('$HOME/.local/bin');
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function appendPathLine(profilePath, userBin) {
|
|
205
|
+
const exportLine = `\n# Added by ASM CLI installer\nexport PATH=\"${userBin}:$PATH\"\n`;
|
|
206
|
+
const existing = (() => { try { return readFileSync(profilePath, 'utf8'); } catch { return ''; } })();
|
|
207
|
+
if (!existing.includes(userBin) && !existing.includes('$HOME/.local/bin')) {
|
|
208
|
+
writeFileSync(profilePath, `${existing}${exportLine}`, 'utf8');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function createAsmLauncher() {
|
|
213
|
+
const userBin = resolveUserBinDir();
|
|
214
|
+
mkdirSync(userBin, { recursive: true });
|
|
215
|
+
const launcherPath = join(userBin, 'asm');
|
|
216
|
+
const packageRoot = resolve(dirname(new URL(import.meta.url).pathname), '..');
|
|
217
|
+
const launcher = `#!/usr/bin/env bash\nnode \"${join(packageRoot, 'bin', 'asm.mjs')}\" \"$@\"\n`;
|
|
218
|
+
writeFileSync(launcherPath, launcher, 'utf8');
|
|
219
|
+
chmodSync(launcherPath, 0o755);
|
|
220
|
+
return { launcherPath, userBin };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function runCliBootstrapFlow({ log = console.log } = {}) {
|
|
224
|
+
log('[ASM-CLI] Installing / exposing ASM CLI only...');
|
|
225
|
+
log(`[ASM-CLI] Package: ${ASM_PLUGIN_PACKAGE}`);
|
|
226
|
+
const installed = createAsmLauncher();
|
|
227
|
+
log(`[ASM-CLI] Installed launcher: ${installed.launcherPath}`);
|
|
228
|
+
if (!pathContains(installed.userBin)) {
|
|
229
|
+
const detected = detectShellProfile();
|
|
230
|
+
log(`[ASM-CLI] ${installed.userBin} is not currently on PATH.`);
|
|
231
|
+
const shouldPatch = process.stdin.isTTY
|
|
232
|
+
? await askYesNo(`[ASM-CLI] Add ${installed.userBin} to ${detected.profilePath} now? [y/N] `)
|
|
233
|
+
: false;
|
|
234
|
+
if (shouldPatch) {
|
|
235
|
+
appendPathLine(detected.profilePath, installed.userBin);
|
|
236
|
+
log(`[ASM-CLI] Updated ${detected.profilePath}`);
|
|
237
|
+
log(`[ASM-CLI] Run: source ${detected.profilePath} (or open a new terminal)`);
|
|
238
|
+
process.env.PATH = `${installed.userBin}:${process.env.PATH || ''}`;
|
|
239
|
+
} else {
|
|
240
|
+
log(`[ASM-CLI] To enable 'asm' in future shells, add this line to ${detected.profilePath}:`);
|
|
241
|
+
log(` export PATH=\"${installed.userBin}:$PATH\"`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const verify = createShellRunner()('bash', ['-lc', `"${installed.launcherPath}" --help`]);
|
|
245
|
+
if (!verify.ok) {
|
|
246
|
+
return { ok: false, step: 'verify-cli-launcher', details: { stdout: verify.stdout, stderr: verify.stderr, launcherPath: installed.launcherPath } };
|
|
247
|
+
}
|
|
248
|
+
log('[ASM-CLI] asm launcher verified successfully.');
|
|
249
|
+
log('[ASM-CLI] Next steps:');
|
|
250
|
+
log(' 1) asm install openclaw');
|
|
251
|
+
log(' 2) asm install opencode');
|
|
252
|
+
log(' 3) asm install paperclip');
|
|
253
|
+
return { ok: true, step: 'install-cli', details: installed };
|
|
254
|
+
}
|
|
255
|
+
|
|
170
256
|
export async function runSetupOpenClawFlow({
|
|
171
257
|
runner = createShellRunner(),
|
|
172
258
|
initOpenClaw = runInitOpenClaw,
|
|
@@ -250,6 +336,11 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
250
336
|
return 0;
|
|
251
337
|
}
|
|
252
338
|
|
|
339
|
+
if (parsed.command === "install-cli") {
|
|
340
|
+
const result = await runCliBootstrapFlow({ log: console.log });
|
|
341
|
+
return result.ok ? 0 : 1;
|
|
342
|
+
}
|
|
343
|
+
|
|
253
344
|
if (parsed.command === "setup-openclaw") {
|
|
254
345
|
const result = await runSetupOpenClawFlow({ argv: parsed.argv });
|
|
255
346
|
return result.ok ? 0 : 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrc2204/agent-smart-memo",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.10",
|
|
4
4
|
"description": "Smart Memory Plugin for OpenClaw \u2014 structured slot memory with auto-capture, auto-recall, essence distillation, and Qdrant vector search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|