fix: allow plugin CLI registration for builtin memory command

The performance optimization that skips plugin loading for builtin
commands prevented memory-neo4j from registering its "neo4j" subcommand,
causing "openclaw memory neo4j sleep" to fail with "unknown command".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarun Sukhani
2026-02-15 06:56:05 +08:00
parent 68d4ca1e0d
commit a5e0487647
2 changed files with 18 additions and 0 deletions

View File

@@ -101,6 +101,16 @@ describe("shouldSkipPluginCommandRegistration", () => {
}),
).toBe(false);
});
it("keeps plugin registration for plugin-extensible builtins like memory", () => {
expect(
shouldSkipPluginCommandRegistration({
argv: ["node", "openclaw", "memory", "neo4j", "sleep"],
primary: "memory",
hasBuiltinPrimary: true,
}),
).toBe(false);
});
});
describe("shouldEnsureCliPath", () => {

View File

@@ -27,12 +27,20 @@ export function shouldRegisterPrimarySubcommand(argv: string[]): boolean {
return !hasHelpOrVersion(argv);
}
// Builtin commands that plugins are known to extend with subcommands.
// These must NOT skip plugin CLI registration even though they are builtins.
const PLUGIN_EXTENSIBLE_COMMANDS = new Set(["memory"]);
export function shouldSkipPluginCommandRegistration(params: {
argv: string[];
primary: string | null;
hasBuiltinPrimary: boolean;
}): boolean {
if (params.hasBuiltinPrimary) {
// Some builtins are extended by plugins (e.g. "memory" gains "neo4j" subcommand).
if (params.primary && PLUGIN_EXTENSIBLE_COMMANDS.has(params.primary)) {
return false;
}
return true;
}
if (!params.primary) {