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): retain positionals across flag parsing

Rudy Celeklic51808804d81
diff --git a/tests/parser-positional-flags.test.mjs b/tests/parser-positional-flags.test.mjs
new file mode 100644
index 0000000000..c98f91891f
--- /dev/null
+++ b/tests/parser-positional-flags.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';
+
+test('flags preserve positionals before and after them', () => {
+ const parser = new CommandParser();
+ parser.registerCommand({ name: 'memory', description: 'Memory', action() {} });
+ for (const args of [['memory', 'key', '--verbose', 'value'], ['memory', 'key', '--format=json']]) {
+ const result = parser.parse(args);
+ assert.deepEqual(result.flags._, result.positional);
+ assert.equal(result.flags._[0], 'key');
+ }
+});
+
+test('flag values are excluded from positionals', () => {
+ const result = new CommandParser().parse(['key', '--config', 'config.json', 'value']);
+ assert.deepEqual(result.flags._, ['key', 'value']);
+ assert.equal(result.flags.config, 'config.json');
+});
diff --git a/v3/@claude-flow/cli/src/parser.ts b/v3/@claude-flow/cli/src/parser.ts
index 026d18034e..557f97b050 100644
--- a/v3/@claude-flow/cli/src/parser.ts
+++ b/v3/@claude-flow/cli/src/parser.ts
@@ -229,7 +229,8 @@ export class CommandParser {
const parseResult = this.parseFlag(args, i, aliases, booleanFlags, stringFlags);
// Apply to result flags
- Object.assign(result.flags, parseResult.flags);
+ const { _: ignoredPositionals, ...parsedFlags } = parseResult.flags;
+ Object.assign(result.flags, parsedFlags);
i = parseResult.nextIndex;
continue;
}