@mrc2204/agent-smart-memo 5.1.8 → 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 +80 -9
- 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
|
}
|
|
@@ -171,15 +175,82 @@ function parseProjectEventArgs(argv = []) {
|
|
|
171
175
|
return out;
|
|
172
176
|
}
|
|
173
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
|
+
|
|
174
223
|
export async function runCliBootstrapFlow({ log = console.log } = {}) {
|
|
175
|
-
log(
|
|
224
|
+
log('[ASM-CLI] Installing / exposing ASM CLI only...');
|
|
176
225
|
log(`[ASM-CLI] Package: ${ASM_PLUGIN_PACKAGE}`);
|
|
177
|
-
|
|
178
|
-
log(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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 };
|
|
183
254
|
}
|
|
184
255
|
|
|
185
256
|
export async function runSetupOpenClawFlow({
|
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",
|