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

fix(cli): honor the first positional command slot

Rudy Celeklif7319fa63221
diff --git a/tests/parser-command-slot.test.mjs b/tests/parser-command-slot.test.mjs
new file mode 100644
index 0000000000..3dd1e46d70
--- /dev/null
+++ b/tests/parser-command-slot.test.mjs
@@ -0,0 +1,19 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { CommandParser } from '../v3/@claude-flow/cli/src/parser.ts';
+const parser = () => { const p = new CommandParser(); p.registerCommand({ name: 'memory', description: 'Memory', action() {} }); return p; };
+test('unknown command slot is not replaced by later command names', () => {
+ const result = parser().parse(['unknown', 'memory']);
+ assert.deepEqual(result.command, []);
+ assert.deepEqual(result.positional, ['unknown', 'memory']);
+});
+test('end-of-options arguments remain literal positionals', () => {
+ const result = parser().parse(['--', 'memory']);
+ assert.deepEqual(result.command, []);
+ assert.deepEqual(result.positional, ['memory']);
+});
+test('leading flag values do not occupy the command slot', () => {
+ const result = parser().parse(['--config', 'memory', 'memory']);
+ assert.deepEqual(result.command, ['memory']);
+ assert.equal(result.flags.config, 'memory');
+});
diff --git a/v3/@claude-flow/cli/src/parser.ts b/v3/@claude-flow/cli/src/parser.ts
index 026d18034e..4643816b3b 100644
--- a/v3/@claude-flow/cli/src/parser.ts
+++ b/v3/@claude-flow/cli/src/parser.ts
@@ -213,6 +213,7 @@ export class CommandParser {
let i = 0;
let parsingFlags = true;
+ let commandSlotAvailable = true;
while (i < args.length) {
const arg = args[i];
@@ -238,7 +239,9 @@ export class CommandParser {
// Fix for #1596: treat lazy command names as commands here too so that
// downstream dispatch sees `commandPath = ['daemon', 'start']` instead of
// `commandPath = ['start'], positional = ['daemon']`.
- if (result.command.length === 0 && this.isKnownCommandName(arg)) {
+ const isCommandSlot = commandSlotAvailable && parsingFlags;
+ commandSlotAvailable = false;
+ if (isCommandSlot && this.isKnownCommandName(arg)) {
// This is a command
result.command.push(arg);