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(ruflo): disclose runtime drift without blocking launch

Rudy Celeklif719c88910f1
diff --git a/ruflo/bin/ruflo.js b/ruflo/bin/ruflo.js
index 4e9d99ff67..ab712ff5f9 100755
--- a/ruflo/bin/ruflo.js
+++ b/ruflo/bin/ruflo.js
@@ -29,22 +29,23 @@ const cliBase = pkgDir
? join(pkgDir, 'node_modules', '@claude-flow', 'cli')
: resolve(__dirname, '../../v3/@claude-flow/cli');
-// The wrapper and implementation ship in lockstep. A broad dependency range
-// previously let a current wrapper silently run an older cached CLI (#3306).
-// Check package metadata before either the fast --version path or an MCP
-// import, without loading the CLI or its expensive model dependencies.
-let wrapperVersion;
-let cliVersion;
+// The exact dependency pin prevents mismatches in normal installs. Existing
+// partial upgrades can still resolve a different CLI (#3306); make that
+// visible on stderr without taking an otherwise working command offline.
+let wrapperVersion = '0.0.0';
+let cliVersion = 'unknown';
+let versionProblem;
try {
wrapperVersion = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')).version;
cliVersion = JSON.parse(readFileSync(join(cliBase, 'package.json'), 'utf-8')).version;
} catch (error) {
- console.error(`ruflo: cannot verify installed CLI version: ${error.message}`);
- process.exit(1);
+ versionProblem = `cannot verify installed CLI version: ${error.message}`;
}
-if (!wrapperVersion || wrapperVersion !== cliVersion) {
- console.error(`ruflo: wrapper v${wrapperVersion || 'unknown'} requires @claude-flow/cli v${wrapperVersion || 'unknown'}, but resolved v${cliVersion || 'unknown'} at ${cliBase}`);
- process.exit(1);
+if (!versionProblem && wrapperVersion !== cliVersion) {
+ versionProblem = `wrapper v${wrapperVersion} expects @claude-flow/cli v${wrapperVersion}, but resolved v${cliVersion} at ${cliBase}`;
+}
+if (versionProblem) {
+ console.error(`ruflo: warning: ${versionProblem}; continuing. Reinstall ruflo to restore matching versions.`);
}
// #2256: --version / -V must not trigger heavy CLI/model imports.
diff --git a/ruflo/tests/wrapper-runtime-3306.test.mjs b/ruflo/tests/wrapper-runtime-3306.test.mjs
index f3349c5745..c2df7d1c97 100644
--- a/ruflo/tests/wrapper-runtime-3306.test.mjs
+++ b/ruflo/tests/wrapper-runtime-3306.test.mjs
@@ -1,12 +1,13 @@
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
-import { copyFileSync, existsSync, mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
+import { copyFileSync, existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import test from 'node:test';
const wrapperSource = fileURLToPath(new URL('../bin/ruflo.js', import.meta.url));
+const wrapperVersion = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
function install(t, cliVersion) {
const root = mkdtempSync(join(tmpdir(), 'ruflo-wrapper-3306-'));
@@ -16,10 +17,10 @@ function install(t, cliVersion) {
mkdirSync(join(wrapperDir, 'bin'), { recursive: true });
mkdirSync(join(cliDir, 'bin'), { recursive: true });
copyFileSync(wrapperSource, join(wrapperDir, 'bin', 'ruflo.js'));
- writeFileSync(join(wrapperDir, 'package.json'), JSON.stringify({ name: 'ruflo', version: '3.45.0', type: 'module' }));
+ writeFileSync(join(wrapperDir, 'package.json'), JSON.stringify({ name: 'ruflo', version: wrapperVersion, type: 'module' }));
writeFileSync(join(cliDir, 'package.json'), JSON.stringify({ name: '@claude-flow/cli', version: cliVersion, type: 'module' }));
writeFileSync(join(cliDir, 'bin', 'cli.js'), `import { writeFileSync } from 'node:fs';\nwriteFileSync(process.env.RUFLO_TEST_MARKER, 'launched');\n`);
- return { bin: join(wrapperDir, 'bin', 'ruflo.js'), marker: join(root, 'cli-launched') };
+ return { bin: join(wrapperDir, 'bin', 'ruflo.js'), cliDir, marker: join(root, 'cli-launched') };
}
function run(fixture, args) {
@@ -30,34 +31,46 @@ function run(fixture, args) {
}
test('matching wrapper and runtime report the version without importing the CLI', (t) => {
- const fixture = install(t, '3.45.0');
+ const fixture = install(t, wrapperVersion);
const result = run(fixture, ['--version']);
assert.equal(result.status, 0, result.stderr);
- assert.equal(result.stdout, 'ruflo v3.45.0\n');
+ assert.equal(result.stdout, `ruflo v${wrapperVersion}\n`);
+ assert.equal(result.stderr, '');
assert.equal(existsSync(fixture.marker), false);
});
-test('a stale runtime cannot masquerade as the current wrapper version', (t) => {
+test('a stale runtime is disclosed without breaking the version command', (t) => {
const fixture = install(t, '3.33.0');
const result = run(fixture, ['--version']);
- assert.equal(result.status, 1);
- assert.equal(result.stdout, '');
- assert.match(result.stderr, /3\.45\.0.*3\.33\.0/);
+ assert.equal(result.status, 0);
+ assert.equal(result.stdout, `ruflo v${wrapperVersion}\n`);
+ assert.match(result.stderr, new RegExp(`wrapper v${wrapperVersion.replaceAll('.', '\\.')}.*3\\.33\\.0`));
assert.equal(existsSync(fixture.marker), false);
});
-test('a stale runtime is refused before MCP protocol output or implementation import', (t) => {
+test('a stale runtime is disclosed on stderr and MCP still launches', (t) => {
const fixture = install(t, '3.33.0');
const result = run(fixture, ['mcp', 'start']);
- assert.equal(result.status, 1);
+ assert.equal(result.status, 0, result.stderr);
assert.equal(result.stdout, '');
- assert.match(result.stderr, /requires @claude-flow\/cli/);
+ assert.match(result.stderr, /expects @claude-flow\/cli/);
+ assert.equal(existsSync(fixture.marker), true);
+});
+
+test('missing CLI metadata warns without taking the version command offline', (t) => {
+ const fixture = install(t, wrapperVersion);
+ rmSync(join(fixture.cliDir, 'package.json'));
+ const result = run(fixture, ['--version']);
+ assert.equal(result.status, 0);
+ assert.equal(result.stdout, `ruflo v${wrapperVersion}\n`);
+ assert.match(result.stderr, /cannot verify installed CLI version/);
assert.equal(existsSync(fixture.marker), false);
});
test('a matching runtime still receives MCP commands', (t) => {
- const fixture = install(t, '3.45.0');
+ const fixture = install(t, wrapperVersion);
const result = run(fixture, ['mcp', 'start']);
assert.equal(result.status, 0, result.stderr);
+ assert.equal(result.stderr, '');
assert.equal(existsSync(fixture.marker), true);
});