🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(cli): read the parser's camelCase keys in appliance build/sign/update (#4362)
Tanvir Ahamed0396c4c20457
diff --git a/v3/@claude-flow/cli/__tests__/appliance-kebab-flags.test.ts b/v3/@claude-flow/cli/__tests__/appliance-kebab-flags.test.tsnew file mode 100644index 0000000000..e6e6773b7d--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/appliance-kebab-flags.test.ts@@ -0,0 +1,112 @@+/**+ * `appliance build`, `appliance sign` and `appliance update` read kebab-case+ * keys (`ctx.flags['api-keys']`, `['generate-keys']`, `['key-dir']`,+ * `['public-key']`, `['no-backup']`), but the parser stores every long flag+ * under its camelCase key and turns `--no-foo` into `foo = false`. Those+ * flags were silently ignored. `build` also passed `outputPath`/`apiKeysPath`+ * where RvfaBuilder reads `output`/`apiKeys`, so every build threw+ * `The "paths[0]" argument must be of type string. Received undefined`,+ * and it printed `result.totalSize`, which BuildResult calls `size`.+ *+ * Runs the real parser and the real subcommand actions; only the RVFA+ * builder, signing and patching modules are mocked.+ */+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { fileURLToPath } from 'node:url';++const builderOptions: Record<string, unknown>[] = [];+const savedKeyDirs: string[] = [];+const applyOptions: Record<string, unknown>[] = [];+let written = '';++vi.mock('../src/appliance/rvfa-builder.js', () => ({+ RvfaBuilder: class {+ constructor(options: Record<string, unknown>) { builderOptions.push(options); }+ async build() { return { outputPath: 'out.rvf', size: 2048, sections: [], duration: 1, profile: 'cloud' }; }+ },+}));++vi.mock('../src/appliance/rvfa-signing.js', () => {+ const kp = { publicKey: Buffer.from('pub'), privateKey: Buffer.from('priv'), fingerprint: 'fp' };+ return {+ generateKeyPair: async () => kp,+ saveKeyPair: async (_kp: unknown, dir: string) => {+ savedKeyDirs.push(dir);+ return { publicKeyPath: `${dir}/rvfa-signing.pub`, privateKeyPath: `${dir}/rvfa-signing.key` };+ },+ loadKeyPair: async () => kp,+ RvfaSigner: class {+ async signAppliance() {+ return { algorithm: 'ed25519', publicKeyFingerprint: 'fp', signedAt: 'now', signature: 'ab'.repeat(32) };+ }+ },+ };+});++vi.mock('../src/appliance/rvfa-distribution.js', () => ({+ RvfaPatcher: {+ applyPatch: async (_file: string, _patch: Buffer, opts: Record<string, unknown>) => {+ applyOptions.push(opts);+ return { success: true, newSize: 1, patchedSection: 'ruflo', errors: [] };+ },+ },+}));++import applianceCommand from '../src/commands/appliance.js';+import { CommandParser } from '../src/parser.js';+import type { CommandContext, CommandResult } from '../src/types.js';++// Any existing file works: the actions only check that the paths exist.+const EXISTING = fileURLToPath(import.meta.url);++async function run(argv: string[]): Promise<CommandResult> {+ const parser = new CommandParser({ allowUnknownFlags: true });+ parser.registerCommand(applianceCommand);+ const { flags } = parser.parse(['appliance', ...argv]);+ const sub = applianceCommand.subcommands!.find((c) => c.name === argv[0])!;+ return (await sub.action!({ args: [], flags, cwd: process.cwd(), interactive: false } as unknown as CommandContext))!;+}++describe('appliance subcommands read the parser\'s camelCase flag keys', () => {+ beforeEach(() => {+ builderOptions.length = 0;+ savedKeyDirs.length = 0;+ applyOptions.length = 0;+ written = '';+ for (const stream of [process.stdout, process.stderr]) {+ vi.spyOn(stream, 'write').mockImplementation((s) => { written += String(s); return true; });+ }+ });++ it('build passes output and --api-keys under the names RvfaBuilder reads', async () => {+ const result = await run(['build', '-o', 'out.rvf', '--api-keys', 'keys.env']);+ expect(result).toMatchObject({ success: true });+ expect(builderOptions[0]).toMatchObject({ output: 'out.rvf', apiKeys: 'keys.env' });+ // No --models: leave the choice to the builder's per-profile default.+ expect(builderOptions[0].models).toBeUndefined();+ expect(written).toContain('Total size: 2.0 KB');+ });++ it('build forwards explicit --models', async () => {+ await run(['build', '--profile', 'hybrid', '-m', 'phi-3-mini-q4']);+ expect(builderOptions[0]).toMatchObject({ profile: 'hybrid', models: ['phi-3-mini-q4'] });+ });++ it('sign --generate-keys writes the key pair to --key-dir', async () => {+ const result = await run(['sign', '-f', EXISTING, '--generate-keys', '--key-dir', 'my-keys']);+ expect(result).toMatchObject({ success: true });+ expect(savedKeyDirs).toEqual(['my-keys']);+ });++ it('update passes --public-key and --no-backup to the patcher', async () => {+ const result = await run(['update', '-f', EXISTING, '-s', 'ruflo', '-p', EXISTING, '--public-key', EXISTING, '--no-backup']);+ expect(result).toMatchObject({ success: true });+ expect(applyOptions[0].publicKey).toBeInstanceOf(Buffer);+ expect(applyOptions[0].backup).toBe(false);+ });++ it('update keeps the backup by default', async () => {+ await run(['update', '-f', EXISTING, '-s', 'ruflo', '-p', EXISTING]);+ expect(applyOptions[0]).toMatchObject({ backup: true, publicKey: undefined });+ });+});diff --git a/v3/@claude-flow/cli/src/commands/appliance-advanced.ts b/v3/@claude-flow/cli/src/commands/appliance-advanced.tsindex 2be0051d67..b5e64dece4 100644--- a/v3/@claude-flow/cli/src/commands/appliance-advanced.ts+++ b/v3/@claude-flow/cli/src/commands/appliance-advanced.ts@@ -52,8 +52,8 @@ export const signCommand: Command = {action: async (ctx: CommandContext): Promise<CommandResult> => {const file = ctx.flags.file as string;const keyPath = ctx.flags.key as string | undefined;- const genKeys = ctx.flags['generate-keys'] as boolean;- const keyDir = ctx.flags['key-dir'] as string || '.rvfa-keys';+ const genKeys = ctx.flags.generateKeys as boolean;+ const keyDir = ctx.flags.keyDir as string || '.rvfa-keys';const signer = ctx.flags.signer as string | undefined;if (!file) return fail('--file is required');@@ -191,14 +191,14 @@ export const updateAppCommand: Command = {}let pubKey: Buffer | undefined;- if (ctx.flags['public-key']) {- const pkPath = ctx.flags['public-key'] as string;+ if (ctx.flags.publicKey) {+ const pkPath = ctx.flags.publicKey as string;if (!(await requireFile(pkPath))) return { success: false, exitCode: 1 };pubKey = fs.readFileSync(pkPath);}const result = await dist.RvfaPatcher.applyPatch(file, patchBuf, {- backup: !(ctx.flags['no-backup'] as boolean),+ backup: ctx.flags.backup !== false,verify: true,publicKey: pubKey,});diff --git a/v3/@claude-flow/cli/src/commands/appliance.ts b/v3/@claude-flow/cli/src/commands/appliance.tsindex 4de1d5b604..b97992b760 100644--- a/v3/@claude-flow/cli/src/commands/appliance.ts+++ b/v3/@claude-flow/cli/src/commands/appliance.ts@@ -94,7 +94,7 @@ const buildCommand: Command = {const outputPath = ctx.flags.output as string || 'ruflo.rvf';const arch = ctx.flags.arch as string || 'x86_64';const models = ctx.flags.models as string[] || [];- const apiKeysPath = ctx.flags['api-keys'] as string | undefined;+ const apiKeysPath = ctx.flags.apiKeys as string | undefined;header('RVFA Appliance Builder');output.printInfo(`Profile: ${output.highlight(profile)}`);@@ -105,7 +105,7 @@ const buildCommand: Command = {const startTime = Date.now();const RvfaBuilder = await loadModule<new (o: Record<string, unknown>) => {- build: () => Promise<{ totalSize: number; sections: Array<{ id: string; size: number }> }>;+ build: () => Promise<{ size: number; sections: Array<{ id: string; size: number }> }>;}>('../appliance/rvfa-builder.js', 'RvfaBuilder', 'builder');if (!RvfaBuilder) return { success: false, exitCode: 1 };@@ -118,7 +118,10 @@ const buildCommand: Command = {if (apiKeysPath) steps.splice(steps.length - 1, 0, 'Sealing API key vault');try {- const builder = new RvfaBuilder({ profile, outputPath, arch, models, apiKeysPath });+ const builder = new RvfaBuilder({+ profile, output: outputPath, arch, apiKeys: apiKeysPath,+ models: models.length > 0 ? models : undefined,+ });await runSteps(steps);const result = await builder.build();const duration = ((Date.now() - startTime) / 1000).toFixed(1);@@ -135,7 +138,7 @@ const buildCommand: Command = {}output.writeln();output.printSuccess(`Appliance written to ${output.bold(outputPath)}`);- output.printInfo(`Total size: ${output.bold(fmtSize(result.totalSize))} Duration: ${duration}s`);+ output.printInfo(`Total size: ${output.bold(fmtSize(result.size))} Duration: ${duration}s`);return { success: true, data: result };} catch (err) {return fail('Build failed', errMsg(err));