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

4.0 KB
Raw Blame
#!/usr/bin/env node
/**
 * Static guard for ruvnet/ruflo#2151 β€” enforce three-way version lockstep
 * across the umbrella packages that ship together:
 *
 *   - @claude-flow/cli  (v3/@claude-flow/cli/package.json)
 *   - claude-flow       (root package.json β€” umbrella)
 *   - ruflo             (ruflo/package.json β€” thin user-facing wrapper)
 *
 * Why: when these drift (e.g. [email protected] but [email protected], observed in
 * #2151), `npx ruflo --version` prints the bundled CLI's version (3.10.1),
 * not the wrapper's package.json version (3.10.2). Users see the "wrong"
 * version and reasonably assume the install is broken.
 *
 * The Publishing Rules in CLAUDE.md require all three to ship at the same
 * version. This audit enforces that locally so a drift can't reach a
 * release. Wired into v3-ci.yml as `umbrella-version-lockstep-audit`.
 *
 * Also asserts ruflo pins the exact CLI version (#3306). A range that merely
 * includes it can retain an older cached implementation behind a new wrapper.
 *
 * Exit codes:
 *   0 β€” versions identical and ruflo pins that CLI version
 *   1 β€” drift detected; remediation hints printed
 */

import { readFileSync, existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join, resolve } from 'node:path';
const __dirname = dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = resolve(__dirname, '..');

const TARGETS = [
  { label: '@claude-flow/cli', path: 'v3/@claude-flow/cli/package.json' },
  { label: 'claude-flow',       path: 'package.json' },
  { label: 'ruflo',             path: 'ruflo/package.json' },
];

function readPkg(rel) {
  const p = join(REPO_ROOT, rel);
  if (!existsSync(p)) return null;
  try { return JSON.parse(readFileSync(p, 'utf8')); }
  catch { return null; }
}

const versions = {};
const violations = [];

for (const { label, path } of TARGETS) {
  const pkg = readPkg(path);
  if (!pkg) {
    violations.push(`${label} (${path}) not found`);
    continue;
  }
  if (typeof pkg.version !== 'string' || pkg.version.trim().length === 0) {
    violations.push(`${label} (${path}) must declare a nonempty version string`);
    continue;
  }
  versions[label] = pkg.version;
}

console.log('umbrella-version-lockstep audit β€” three-package identity check');
for (const { label } of TARGETS) {
  console.log(`  ${label.padEnd(20)} ${versions[label] ?? '(missing)'}`);
}

const unique = new Set(Object.values(versions));
if (unique.size > 1) {
  violations.push(
    `version drift across umbrella packages: ${[...unique].join(' / ')}.\n` +
    `    Bump all three to the same version per CLAUDE.md "Publishing Rules" before shipping:\n` +
    `      v3/@claude-flow/cli/package.json   ← ${versions['@claude-flow/cli'] ?? '?'}\n` +
    `      package.json (claude-flow)         ← ${versions['claude-flow'] ?? '?'}\n` +
    `      ruflo/package.json                 ← ${versions['ruflo'] ?? '?'}`
  );
}

// Cross-check: ruflo must resolve exactly the CLI version it advertises.
const rufloPkg = readPkg('ruflo/package.json');
const cliVersion = versions['@claude-flow/cli'];
if (rufloPkg && cliVersion) {
  const range = rufloPkg.dependencies?.['@claude-flow/cli'];
  if (typeof range !== 'string' || range.length === 0) {
    violations.push('ruflo must declare its exact @claude-flow/cli dependency');
  } else {
    if (range !== cliVersion) {
      violations.push(
        `ruflo "@claude-flow/cli": "${range}" must pin cli's actual version ${cliVersion}.\n` +
        `    Update ruflo/package.json dependencies to "${cliVersion}".`
      );
    } else {
      console.log(`  ruflo dep "@claude-flow/cli": "${range}" matches ${cliVersion} βœ“`);
    }
  }
}

if (violations.length === 0) {
  console.log('\n  ok: all three umbrella packages at identical version, ruflo pins cli');
  process.exit(0);
}

console.error('\nviolations:');
for (const v of violations) console.error(`  βœ— ${v}`);
console.error(`\n${violations.length} violation(s).`);
console.error('Reference: ruvnet/ruflo#2151 (version mismatch β€” [email protected] + [email protected]).');
process.exit(1);