Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv82cf740e6e2a
diff --git a/v3/@claude-flow/cli/src/commands/index.ts b/v3/@claude-flow/cli/src/commands/index.ts
index 0429d6c1c2..79287df229 100644
--- a/v3/@claude-flow/cli/src/commands/index.ts
+++ b/v3/@claude-flow/cli/src/commands/index.ts
@@ -176,10 +176,11 @@ export const commands: Command[] = [
/**
* Command registry map for quick lookup
+ * Supports both sync (core commands) and async (lazy-loaded) commands
*/
export const commandRegistry = new Map<string, Command>();
-// Register all commands and their aliases
+// Register core commands and their aliases
for (const cmd of commands) {
commandRegistry.set(cmd.name, cmd);
if (cmd.aliases) {
@@ -190,24 +191,46 @@ for (const cmd of commands) {
}
/**
- * Get command by name
+ * Get command by name (sync for core commands, returns undefined for lazy commands)
+ * Use getCommandAsync for lazy-loaded commands
*/
export function getCommand(name: string): Command | undefined {
- return commandRegistry.get(name);
+ return loadedCommands.get(name) || commandRegistry.get(name);
}
/**
- * Check if command exists
+ * Get command by name (async - supports lazy loading)
+ */
+export async function getCommandAsync(name: string): Promise<Command | undefined> {
+ // Check already-loaded commands first
+ const cached = loadedCommands.get(name);
+ if (cached) return cached;
+
+ // Check sync registry
+ const synced = commandRegistry.get(name);
+ if (synced) return synced;
+
+ // Try lazy loading
+ return loadCommand(name);
+}
+
+/**
+ * Check if command exists (sync check for core commands)
*/
export function hasCommand(name: string): boolean {
- return commandRegistry.has(name);
+ return loadedCommands.has(name) || commandRegistry.has(name) || name in commandLoaders;
}
/**
- * Get all command names (including aliases)
+ * Get all command names (including aliases and lazy-loadable)
*/
export function getCommandNames(): string[] {
- return Array.from(commandRegistry.keys());
+ const names = new Set([
+ ...Array.from(commandRegistry.keys()),
+ ...Array.from(loadedCommands.keys()),
+ ...Object.keys(commandLoaders),
+ ]);
+ return Array.from(names);
}
/**
@@ -217,6 +240,25 @@ export function getUniqueCommands(): Command[] {
return commands.filter(cmd => !cmd.hidden);
}
+/**
+ * Load all commands (populates lazy-loaded commands)
+ * Use this when you need all commands available synchronously
+ */
+export async function loadAllCommands(): Promise<Command[]> {
+ const allCommands: Command[] = [...commands];
+
+ for (const name of Object.keys(commandLoaders)) {
+ if (!loadedCommands.has(name)) {
+ const cmd = await loadCommand(name);
+ if (cmd && !allCommands.includes(cmd)) {
+ allCommands.push(cmd);
+ }
+ }
+ }
+
+ return allCommands;
+}
+
/**
* Setup commands in a CLI instance
*/
@@ -225,3 +267,13 @@ export function setupCommands(cli: { command: (cmd: Command) => void }): void {
cli.command(cmd);
}
}
+
+/**
+ * Setup all commands including lazy-loaded (async)
+ */
+export async function setupAllCommands(cli: { command: (cmd: Command) => void }): Promise<void> {
+ const allCommands = await loadAllCommands();
+ for (const cmd of allCommands) {
+ cli.command(cmd);
+ }
+}