@mrc2204/agent-smart-memo 5.1.16 → 5.1.19
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/platform-installers.d.ts.map +1 -1
- package/dist/cli/platform-installers.js +259 -56
- package/dist/cli/platform-installers.js.map +1 -1
- package/dist/core/migrations/memory-foundation-migration.d.ts +33 -0
- package/dist/core/migrations/memory-foundation-migration.d.ts.map +1 -0
- package/dist/core/migrations/memory-foundation-migration.js +67 -0
- package/dist/core/migrations/memory-foundation-migration.js.map +1 -0
- package/dist/core/precedence/recall-precedence.d.ts +20 -0
- package/dist/core/precedence/recall-precedence.d.ts.map +1 -0
- package/dist/core/precedence/recall-precedence.js +36 -0
- package/dist/core/precedence/recall-precedence.js.map +1 -0
- package/dist/core/promotion/promotion-lifecycle.d.ts +20 -0
- package/dist/core/promotion/promotion-lifecycle.d.ts.map +1 -0
- package/dist/core/promotion/promotion-lifecycle.js +46 -0
- package/dist/core/promotion/promotion-lifecycle.js.map +1 -0
- package/dist/core/retrieval-policy.d.ts +26 -0
- package/dist/core/retrieval-policy.d.ts.map +1 -0
- package/dist/core/retrieval-policy.js +44 -0
- package/dist/core/retrieval-policy.js.map +1 -0
- package/dist/core/usecases/semantic-memory-usecase.d.ts +4 -3
- package/dist/core/usecases/semantic-memory-usecase.d.ts.map +1 -1
- package/dist/core/usecases/semantic-memory-usecase.js +56 -16
- package/dist/core/usecases/semantic-memory-usecase.js.map +1 -1
- package/dist/db/slot-db.d.ts +25 -1
- package/dist/db/slot-db.d.ts.map +1 -1
- package/dist/db/slot-db.js +391 -167
- package/dist/db/slot-db.js.map +1 -1
- package/dist/hooks/auto-capture.d.ts +4 -4
- package/dist/hooks/auto-capture.d.ts.map +1 -1
- package/dist/hooks/auto-capture.js +96 -26
- package/dist/hooks/auto-capture.js.map +1 -1
- package/dist/hooks/auto-recall.d.ts +3 -3
- package/dist/hooks/auto-recall.d.ts.map +1 -1
- package/dist/hooks/auto-recall.js +91 -49
- package/dist/hooks/auto-recall.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/services/qdrant.d.ts +3 -2
- package/dist/services/qdrant.d.ts.map +1 -1
- package/dist/services/qdrant.js +24 -7
- package/dist/services/qdrant.js.map +1 -1
- package/dist/shared/memory-config.d.ts +7 -0
- package/dist/shared/memory-config.d.ts.map +1 -1
- package/dist/shared/memory-config.js +67 -16
- package/dist/shared/memory-config.js.map +1 -1
- package/dist/types.d.ts +13 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -62
- package/bin/asm.mjs +0 -450
- package/bin/opencode-mcp-server.mjs +0 -318
- package/scripts/init-openclaw.mjs +0 -721
package/bin/asm.mjs
DELETED
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
-
import { runInitOpenClaw } from "../scripts/init-openclaw.mjs";
|
|
5
|
-
import { createShellRunner, runInitSetupFlow, runInstallPlatformFlow } from "../dist/cli/platform-installers.js";
|
|
6
|
-
import { runOpencodeMcpServer } from "./opencode-mcp-server.mjs";
|
|
7
|
-
import { resolveAsmRuntimeConfig } from "../dist/shared/asm-config.js";
|
|
8
|
-
|
|
9
|
-
const ASM_PLUGIN_PACKAGE = "@mrc2204/agent-smart-memo";
|
|
10
|
-
const ASM_PLUGIN_ID = "agent-smart-memo";
|
|
11
|
-
|
|
12
|
-
console.error("[ASM-TRACE] import.meta.url=", import.meta.url);
|
|
13
|
-
console.error("[ASM-TRACE] argv=", JSON.stringify(process.argv));
|
|
14
|
-
console.error("[ASM-TRACE] cwd=", process.cwd());
|
|
15
|
-
|
|
16
|
-
function text(value) {
|
|
17
|
-
return typeof value === "string" ? value.trim() : "";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function includesAsmPlugin(output) {
|
|
21
|
-
const haystack = String(output || "").toLowerCase();
|
|
22
|
-
return (
|
|
23
|
-
haystack.includes(ASM_PLUGIN_ID) ||
|
|
24
|
-
haystack.includes(ASM_PLUGIN_PACKAGE.toLowerCase())
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function parseAsmCliArgs(argv = []) {
|
|
29
|
-
let args = Array.isArray(argv) ? argv.map((x) => String(x)) : [];
|
|
30
|
-
if (args[0] === 'agent-smart-memo' || args[0] === '@mrc2204/agent-smart-memo') {
|
|
31
|
-
args = args.slice(1);
|
|
32
|
-
}
|
|
33
|
-
const first = args[0] || "";
|
|
34
|
-
|
|
35
|
-
if (!first || first === "help" || first === "--help" || first === "-h") {
|
|
36
|
-
return { command: "help", argv: [] };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (first === "setup-openclaw") {
|
|
40
|
-
return { command: "setup-openclaw", argv: args.slice(1) };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (first === "setup" && (args[1] || "") === "openclaw") {
|
|
44
|
-
return { command: "setup-openclaw", argv: args.slice(2) };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (first === "install") {
|
|
48
|
-
const hasExplicitPlatform = Boolean(args[1]);
|
|
49
|
-
if (!hasExplicitPlatform) {
|
|
50
|
-
return { command: "install-cli", argv: [] };
|
|
51
|
-
}
|
|
52
|
-
const platform = String(args[1] || "").trim().toLowerCase();
|
|
53
|
-
return {
|
|
54
|
-
command: "install-platform",
|
|
55
|
-
platform,
|
|
56
|
-
argv: args.slice(2),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (first === "init-setup") {
|
|
61
|
-
return { command: "init-setup", argv: args.slice(1) };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (first === "init" && (args[1] || "") === "setup") {
|
|
65
|
-
return { command: "init-setup", argv: args.slice(2) };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (first === "init-openclaw") {
|
|
69
|
-
return { command: "init-openclaw", argv: args.slice(1) };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (first === "init" && (args[1] || "") === "openclaw") {
|
|
73
|
-
return { command: "init-openclaw", argv: args.slice(2) };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (first === "project-event") {
|
|
77
|
-
return { command: "project-event", argv: args.slice(1) };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (first === "mcp" && (args[1] || "") === "opencode") {
|
|
81
|
-
return { command: "mcp-opencode", argv: args.slice(2) };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return { command: "unknown", argv: args };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function printHelp(log = console.log) {
|
|
88
|
-
log("asm - Agent Smart Memo CLI");
|
|
89
|
-
log("");
|
|
90
|
-
log("Usage:");
|
|
91
|
-
log(" asm install # install / expose CLI only");
|
|
92
|
-
log(" asm setup-openclaw [--yes]");
|
|
93
|
-
log(" asm setup openclaw [--yes]");
|
|
94
|
-
log(" asm install openclaw [--yes]");
|
|
95
|
-
log(" asm install paperclip");
|
|
96
|
-
log(" asm install opencode");
|
|
97
|
-
log(" asm init-setup [--yes]");
|
|
98
|
-
log(" asm init setup [--yes]");
|
|
99
|
-
log(" asm init-openclaw [--non-interactive]");
|
|
100
|
-
log(" asm init openclaw [--non-interactive]");
|
|
101
|
-
log(" asm project-event --project-id <id> --repo-root <path> [--event-type post_commit|post_merge|post_rewrite|manual] [--source-rev <sha>] [--changed-files a,b] [--deleted-files x,y] [--trusted-sync 0|1] [--full-snapshot 0|1]");
|
|
102
|
-
log(" asm help");
|
|
103
|
-
log("");
|
|
104
|
-
log("Roadmap commands (not implemented yet):");
|
|
105
|
-
log(" asm doctor");
|
|
106
|
-
log(" asm test-openclaw");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function detectPluginInstalled(runner = createShellRunner()) {
|
|
110
|
-
const tryJson = runner("openclaw", ["plugins", "list", "--json"]);
|
|
111
|
-
if (tryJson.ok) {
|
|
112
|
-
try {
|
|
113
|
-
const parsed = JSON.parse(tryJson.stdout || "{}");
|
|
114
|
-
const pool = [
|
|
115
|
-
...(Array.isArray(parsed) ? parsed : []),
|
|
116
|
-
...(Array.isArray(parsed?.plugins) ? parsed.plugins : []),
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
for (const item of pool) {
|
|
120
|
-
const name = text(item?.name || item?.id || item?.package || item?.pluginId);
|
|
121
|
-
if (!name) continue;
|
|
122
|
-
if (includesAsmPlugin(name)) {
|
|
123
|
-
return { installed: true, source: "list-json" };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
} catch {
|
|
127
|
-
if (includesAsmPlugin(tryJson.stdout)) {
|
|
128
|
-
return { installed: true, source: "list-json-text" };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const tryText = runner("openclaw", ["plugins", "list"]);
|
|
134
|
-
if (tryText.ok && includesAsmPlugin(tryText.stdout)) {
|
|
135
|
-
return { installed: true, source: "list-text" };
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return { installed: false, source: "missing" };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function parseNonInteractiveFlags(argv = []) {
|
|
142
|
-
const args = Array.isArray(argv) ? argv.map((x) => String(x).trim()).filter(Boolean) : [];
|
|
143
|
-
const hasYes = args.includes("--yes") || args.includes("-y");
|
|
144
|
-
const hasNonInteractive = args.includes("--non-interactive");
|
|
145
|
-
|
|
146
|
-
return {
|
|
147
|
-
nonInteractive: hasYes || hasNonInteractive,
|
|
148
|
-
autoApply: hasYes || hasNonInteractive,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function parseProjectEventArgs(argv = []) {
|
|
153
|
-
const args = Array.isArray(argv) ? argv.map((x) => String(x)) : [];
|
|
154
|
-
const out = {
|
|
155
|
-
projectId: "",
|
|
156
|
-
repoRoot: "",
|
|
157
|
-
sourceRev: "",
|
|
158
|
-
eventType: "manual",
|
|
159
|
-
changedFiles: [],
|
|
160
|
-
deletedFiles: [],
|
|
161
|
-
trustedSync: false,
|
|
162
|
-
fullSnapshot: false,
|
|
163
|
-
};
|
|
164
|
-
for (let i = 0; i < args.length; i++) {
|
|
165
|
-
const cur = args[i];
|
|
166
|
-
const next = args[i + 1] || "";
|
|
167
|
-
if (cur === "--project-id") { out.projectId = next; i++; continue; }
|
|
168
|
-
if (cur === "--repo-root") { out.repoRoot = next; i++; continue; }
|
|
169
|
-
if (cur === "--source-rev") { out.sourceRev = next; i++; continue; }
|
|
170
|
-
if (cur === "--event-type") { out.eventType = next || "manual"; i++; continue; }
|
|
171
|
-
if (cur === "--changed-files") { out.changedFiles = next ? next.split(",").map((s) => s.trim()).filter(Boolean) : []; i++; continue; }
|
|
172
|
-
if (cur === "--deleted-files") { out.deletedFiles = next ? next.split(",").map((s) => s.trim()).filter(Boolean) : []; i++; continue; }
|
|
173
|
-
if (cur === "--trusted-sync") { out.trustedSync = next === "1" || next === "true"; i++; continue; }
|
|
174
|
-
if (cur === "--full-snapshot") { out.fullSnapshot = next === "1" || next === "true"; i++; continue; }
|
|
175
|
-
}
|
|
176
|
-
return out;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function resolveUserBinDir() {
|
|
180
|
-
const home = process.env.HOME || process.cwd();
|
|
181
|
-
return join(home, '.local', 'bin');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function pathContains(dir) {
|
|
185
|
-
return String(process.env.PATH || '').split(':').includes(dir);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function detectShellProfile() {
|
|
189
|
-
const shell = String(process.env.SHELL || '').trim();
|
|
190
|
-
const home = process.env.HOME || process.cwd();
|
|
191
|
-
if (shell.endsWith('/zsh')) return { shell: 'zsh', profilePath: join(home, '.zshrc') };
|
|
192
|
-
if (shell.endsWith('/bash')) return { shell: 'bash', profilePath: join(home, '.bashrc') };
|
|
193
|
-
return { shell: shell || 'unknown', profilePath: join(home, '.profile') };
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function profileHasPathLine(profilePath, userBin) {
|
|
197
|
-
try {
|
|
198
|
-
const content = readFileSync(profilePath, 'utf8');
|
|
199
|
-
return content.includes(userBin) || content.includes('$HOME/.local/bin');
|
|
200
|
-
} catch {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function appendPathLine(profilePath, userBin) {
|
|
206
|
-
const exportLine = `\n# Added by ASM CLI installer\nexport PATH=\"${userBin}:$PATH\"\n`;
|
|
207
|
-
const existing = (() => { try { return readFileSync(profilePath, 'utf8'); } catch { return ''; } })();
|
|
208
|
-
if (!existing.includes(userBin) && !existing.includes('$HOME/.local/bin')) {
|
|
209
|
-
writeFileSync(profilePath, `${existing}${exportLine}`, 'utf8');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function createAsmLauncher() {
|
|
214
|
-
const userBin = resolveUserBinDir();
|
|
215
|
-
mkdirSync(userBin, { recursive: true });
|
|
216
|
-
const launcherPath = join(userBin, 'asm');
|
|
217
|
-
const packageRoot = resolve(dirname(new URL(import.meta.url).pathname), '..');
|
|
218
|
-
const launcher = `#!/usr/bin/env bash\nnode \"${join(packageRoot, 'bin', 'asm.mjs')}\" \"$@\"\n`;
|
|
219
|
-
writeFileSync(launcherPath, launcher, 'utf8');
|
|
220
|
-
chmodSync(launcherPath, 0o755);
|
|
221
|
-
return { launcherPath, userBin };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export async function runCliBootstrapFlow({ log = console.log } = {}) {
|
|
225
|
-
log('[ASM-CLI] Installing / exposing ASM CLI only...');
|
|
226
|
-
log(`[ASM-CLI] Package: ${ASM_PLUGIN_PACKAGE}`);
|
|
227
|
-
const installed = createAsmLauncher();
|
|
228
|
-
log(`[ASM-CLI] Installed launcher: ${installed.launcherPath}`);
|
|
229
|
-
if (!pathContains(installed.userBin)) {
|
|
230
|
-
const detected = detectShellProfile();
|
|
231
|
-
log(`[ASM-CLI] ${installed.userBin} is not currently on PATH.`);
|
|
232
|
-
const shouldPatch = process.stdin.isTTY
|
|
233
|
-
? await askYesNo(`[ASM-CLI] Add ${installed.userBin} to ${detected.profilePath} now? [y/N] `)
|
|
234
|
-
: false;
|
|
235
|
-
if (shouldPatch) {
|
|
236
|
-
appendPathLine(detected.profilePath, installed.userBin);
|
|
237
|
-
log(`[ASM-CLI] Updated ${detected.profilePath}`);
|
|
238
|
-
log(`[ASM-CLI] Run: source ${detected.profilePath} (or open a new terminal)`);
|
|
239
|
-
process.env.PATH = `${installed.userBin}:${process.env.PATH || ''}`;
|
|
240
|
-
} else {
|
|
241
|
-
log(`[ASM-CLI] To enable 'asm' in future shells, add this line to ${detected.profilePath}:`);
|
|
242
|
-
log(` export PATH=\"${installed.userBin}:$PATH\"`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const verify = createShellRunner()('bash', ['-lc', `"${installed.launcherPath}" --help`]);
|
|
246
|
-
if (!verify.ok) {
|
|
247
|
-
return { ok: false, step: 'verify-cli-launcher', details: { stdout: verify.stdout, stderr: verify.stderr, launcherPath: installed.launcherPath } };
|
|
248
|
-
}
|
|
249
|
-
log('[ASM-CLI] asm launcher verified successfully.');
|
|
250
|
-
log('[ASM-CLI] Next steps:');
|
|
251
|
-
log(' 1) asm install openclaw');
|
|
252
|
-
log(' 2) asm install opencode');
|
|
253
|
-
log(' 3) asm install paperclip');
|
|
254
|
-
return { ok: true, step: 'install-cli', details: installed };
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export async function runSetupOpenClawFlow({
|
|
258
|
-
runner = createShellRunner(),
|
|
259
|
-
initOpenClaw = runInitOpenClaw,
|
|
260
|
-
log = console.log,
|
|
261
|
-
argv = [],
|
|
262
|
-
} = {}) {
|
|
263
|
-
log("[ASM-84] setup-openclaw: checking OpenClaw CLI ...");
|
|
264
|
-
const openclawVersion = runner("openclaw", ["--version"]);
|
|
265
|
-
if (!openclawVersion.ok) {
|
|
266
|
-
log("[ASM-84] ❌ openclaw binary not found or not executable.");
|
|
267
|
-
if (openclawVersion.stderr) log(`[ASM-84] details: ${openclawVersion.stderr}`);
|
|
268
|
-
if (openclawVersion.error) log(`[ASM-84] error: ${openclawVersion.error}`);
|
|
269
|
-
log("[ASM-84] Please install OpenClaw first, then re-run: asm setup-openclaw");
|
|
270
|
-
return { ok: false, step: "check-openclaw" };
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const pluginState = detectPluginInstalled(runner);
|
|
274
|
-
const setupSummary = pluginState.installed
|
|
275
|
-
? {
|
|
276
|
-
alreadyConfigured: [`plugin installed: ${ASM_PLUGIN_PACKAGE}`],
|
|
277
|
-
willAdd: [],
|
|
278
|
-
willUpdate: ["openclaw.json bootstrap via init-openclaw wizard"],
|
|
279
|
-
}
|
|
280
|
-
: {
|
|
281
|
-
alreadyConfigured: [],
|
|
282
|
-
willAdd: [`plugin install: ${ASM_PLUGIN_PACKAGE}`],
|
|
283
|
-
willUpdate: ["openclaw.json bootstrap via init-openclaw wizard"],
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
log("[ASM-84] Setup summary (before execution):");
|
|
287
|
-
log(`- already configured (${setupSummary.alreadyConfigured.length})`);
|
|
288
|
-
if (!setupSummary.alreadyConfigured.length) log(" • (none)");
|
|
289
|
-
for (const item of setupSummary.alreadyConfigured) log(` • ${item}`);
|
|
290
|
-
log(`- will add (${setupSummary.willAdd.length})`);
|
|
291
|
-
if (!setupSummary.willAdd.length) log(" • (none)");
|
|
292
|
-
for (const item of setupSummary.willAdd) log(` • ${item}`);
|
|
293
|
-
log(`- will update (${setupSummary.willUpdate.length})`);
|
|
294
|
-
if (!setupSummary.willUpdate.length) log(" • (none)");
|
|
295
|
-
for (const item of setupSummary.willUpdate) log(` • ${item}`);
|
|
296
|
-
|
|
297
|
-
if (pluginState.installed) {
|
|
298
|
-
log(`[ASM-84] plugin already installed (${pluginState.source}).`);
|
|
299
|
-
} else {
|
|
300
|
-
log(`[ASM-84] plugin not detected. Installing: ${ASM_PLUGIN_PACKAGE}`);
|
|
301
|
-
const install = runner("openclaw", ["plugins", "install", ASM_PLUGIN_PACKAGE]);
|
|
302
|
-
if (!install.ok) {
|
|
303
|
-
log("[ASM-84] ❌ failed to install plugin via OpenClaw CLI.");
|
|
304
|
-
if (install.stdout) log(install.stdout);
|
|
305
|
-
if (install.stderr) log(install.stderr);
|
|
306
|
-
return { ok: false, step: "install-plugin" };
|
|
307
|
-
}
|
|
308
|
-
log("[ASM-84] plugin install command completed.");
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const mode = parseNonInteractiveFlags(argv);
|
|
312
|
-
if (mode.nonInteractive) {
|
|
313
|
-
log("[ASM-84] non-interactive mode enabled; applying defaults/merged config without prompt.");
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
log("[ASM-84] launching init-openclaw bootstrap flow ...");
|
|
317
|
-
const result = await initOpenClaw({ interactive: !mode.nonInteractive, autoApply: mode.autoApply });
|
|
318
|
-
|
|
319
|
-
if (!result?.applied) {
|
|
320
|
-
log("[ASM-84] setup-openclaw ended without changes (aborted or no write).");
|
|
321
|
-
return { ok: true, step: "init-openclaw", applied: false };
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
log("[ASM-84] ✅ setup-openclaw completed.");
|
|
325
|
-
log("[ASM-84] Next steps:");
|
|
326
|
-
log(" 1) Restart OpenClaw runtime");
|
|
327
|
-
log(" 2) Verify plugin loaded and memory tools available");
|
|
328
|
-
log(" 3) Run a quick smoke: memory_slot_set + memory_slot_get");
|
|
329
|
-
|
|
330
|
-
return { ok: true, step: "done", applied: true };
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export async function main(argv = process.argv.slice(2)) {
|
|
334
|
-
const parsed = parseAsmCliArgs(argv);
|
|
335
|
-
if (parsed.command === "help") {
|
|
336
|
-
printHelp();
|
|
337
|
-
return 0;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (parsed.command === "install-cli") {
|
|
341
|
-
const result = await runCliBootstrapFlow({ log: console.log });
|
|
342
|
-
return result.ok ? 0 : 1;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (parsed.command === "setup-openclaw") {
|
|
346
|
-
const result = await runSetupOpenClawFlow({ argv: parsed.argv });
|
|
347
|
-
return result.ok ? 0 : 1;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (parsed.command === "install-platform") {
|
|
351
|
-
const result = await runInstallPlatformFlow({
|
|
352
|
-
platform: parsed.platform,
|
|
353
|
-
runner: createShellRunner(),
|
|
354
|
-
initOpenClaw: runInitOpenClaw,
|
|
355
|
-
log: console.log,
|
|
356
|
-
argv: parsed.argv,
|
|
357
|
-
env: process.env,
|
|
358
|
-
homeDir: process.env.HOME,
|
|
359
|
-
});
|
|
360
|
-
return result.ok ? 0 : 1;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (parsed.command === "init-setup") {
|
|
364
|
-
const result = await runInitSetupFlow({ log: console.log, env: process.env, homeDir: process.env.HOME, argv: parsed.argv });
|
|
365
|
-
return result.ok ? 0 : 1;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (parsed.command === "init-openclaw") {
|
|
369
|
-
const mode = parseNonInteractiveFlags(parsed.argv);
|
|
370
|
-
try {
|
|
371
|
-
const result = await runInitOpenClaw({ interactive: !mode.nonInteractive, autoApply: mode.autoApply });
|
|
372
|
-
return result?.applied || mode.autoApply ? 0 : 0;
|
|
373
|
-
} catch (error) {
|
|
374
|
-
console.error(`[ASM-84] init-openclaw failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
375
|
-
return 1;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (parsed.command === "mcp-opencode") {
|
|
380
|
-
await runOpencodeMcpServer();
|
|
381
|
-
return 0;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (parsed.command === "project-event") {
|
|
385
|
-
const event = parseProjectEventArgs(parsed.argv);
|
|
386
|
-
if (!event.projectId || !event.repoRoot) {
|
|
387
|
-
console.error('[ASM-87] project-event requires --project-id and --repo-root');
|
|
388
|
-
return 1;
|
|
389
|
-
}
|
|
390
|
-
const runtime = resolveAsmRuntimeConfig({ env: process.env, homeDir: process.env.HOME });
|
|
391
|
-
|
|
392
|
-
process.env.OPENCLAW_SLOTDB_DIR = runtime.slotDbDir;
|
|
393
|
-
process.env.AGENT_MEMO_PROJECT_WORKSPACE_ROOT = event.repoRoot;
|
|
394
|
-
process.env.AGENT_MEMO_REPO_CLONE_ROOT = event.repoRoot;
|
|
395
|
-
process.env.PROJECT_WORKSPACE_ROOT = event.repoRoot;
|
|
396
|
-
process.env.REPO_CLONE_ROOT = event.repoRoot;
|
|
397
|
-
process.env.QDRANT_COLLECTION = runtime.qdrantCollection;
|
|
398
|
-
process.env.LLM_BASE_URL = runtime.llmBaseUrl;
|
|
399
|
-
process.env.LLM_API_KEY = runtime.llmApiKey;
|
|
400
|
-
process.env.LLM_MODEL = runtime.llmModel;
|
|
401
|
-
process.env.EMBED_MODEL = runtime.embedModel;
|
|
402
|
-
process.env.EMBEDDING_MODEL = runtime.embedModel;
|
|
403
|
-
process.env.EMBEDDING_DIMENSIONS = String(runtime.embedDimensions);
|
|
404
|
-
process.env.AGENT_MEMO_QDRANT_HOST = runtime.qdrantHost;
|
|
405
|
-
process.env.AGENT_MEMO_QDRANT_PORT = String(runtime.qdrantPort);
|
|
406
|
-
process.env.AGENT_MEMO_QDRANT_COLLECTION = runtime.qdrantCollection;
|
|
407
|
-
process.env.AGENT_MEMO_QDRANT_VECTOR_SIZE = String(runtime.qdrantVectorSize);
|
|
408
|
-
process.env.AGENT_MEMO_EMBED_BASE_URL = runtime.embedBaseUrl;
|
|
409
|
-
process.env.AGENT_MEMO_EMBED_MODEL = runtime.embedModel;
|
|
410
|
-
process.env.AGENT_MEMO_EMBED_DIMENSIONS = String(runtime.embedDimensions);
|
|
411
|
-
|
|
412
|
-
const slotDbDir = runtime.slotDbDir;
|
|
413
|
-
|
|
414
|
-
const { SlotDB } = await import('../dist/db/slot-db.js');
|
|
415
|
-
const { DefaultMemoryUseCasePort } = await import('../dist/core/usecases/default-memory-usecase-port.js');
|
|
416
|
-
const db = new SlotDB(slotDbDir);
|
|
417
|
-
const usecase = new DefaultMemoryUseCasePort(db);
|
|
418
|
-
try {
|
|
419
|
-
const result = await usecase.run('project.index_event', {
|
|
420
|
-
context: { userId: 'telegram:dm:5165741309', agentId: 'assistant', metadata: { projectWorkspaceRoot: event.repoRoot } },
|
|
421
|
-
meta: { source: 'cli', toolName: 'asm.project-event', projectWorkspaceRoot: event.repoRoot },
|
|
422
|
-
payload: {
|
|
423
|
-
project_id: event.projectId,
|
|
424
|
-
repo_root: event.repoRoot,
|
|
425
|
-
source_rev: event.sourceRev || null,
|
|
426
|
-
event_type: event.eventType,
|
|
427
|
-
changed_files: event.changedFiles,
|
|
428
|
-
deleted_files: event.deletedFiles,
|
|
429
|
-
trusted_sync: event.trustedSync,
|
|
430
|
-
full_snapshot: event.fullSnapshot,
|
|
431
|
-
},
|
|
432
|
-
});
|
|
433
|
-
console.log(JSON.stringify(result, null, 2));
|
|
434
|
-
db.close();
|
|
435
|
-
return 0;
|
|
436
|
-
} catch (error) {
|
|
437
|
-
db.close();
|
|
438
|
-
console.error(`[ASM-87] project-event failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
439
|
-
return 1;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
console.error(`[ASM-84] Unknown command: ${argv.join(" ") || "(empty)"}`);
|
|
444
|
-
printHelp(console.error);
|
|
445
|
-
return 1;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
main().then((code) => {
|
|
449
|
-
process.exitCode = code;
|
|
450
|
-
});
|