mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-05 23:11:43 +09:00
Merge pull request #4944 from ruvnet/fix/4940-bundle-security-zod4
fix(release): ship zod 4 inside the bundled security package; release 3.75.1 (#4940)
This commit is contained in:
8 files changed
+182
-13
No files matched your search
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "claude-flow",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "claude-flow",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"bundleDependencies": [
|
||||
"@claude-flow/codex",
|
||||
"@claude-flow/mcp",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "claude-flow",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"workspaces": [
|
||||
"v3/@claude-flow/codex",
|
||||
"v3/@claude-flow/mcp",
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ruflo",
|
||||
"mcpName": "io.github.ruvnet/ruflo",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
|
||||
"main": "bin/ruflo.js",
|
||||
"type": "module",
|
||||
@@ -41,7 +41,7 @@
|
||||
"package:rvf": "bash src/scripts/package-rvf.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"@claude-flow/cli": "3.75.0"
|
||||
"@claude-flow/cli": "3.75.1"
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"overrides": {
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@
|
||||
"subfolder": "ruflo"
|
||||
},
|
||||
"websiteUrl": "https://github.com/ruvnet/ruflo",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"packages": [
|
||||
{
|
||||
"registryType": "npm",
|
||||
"identifier": "ruflo",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"runtimeHint": "npx",
|
||||
"transport": {
|
||||
"type": "stdio"
|
||||
|
||||
@@ -51,3 +51,66 @@ assert.equal(alignBundledRuntimeVersion(target, {
|
||||
}), false);
|
||||
|
||||
console.log('bundled runtime manifest is self-contained and preserves source metadata');
|
||||
|
||||
// #4940: a vendored dependency stays declared and its files ship in the bundle.
|
||||
{
|
||||
const { mkdtemp, mkdir, writeFile, readFile, rm, access } = await import('node:fs/promises');
|
||||
const { tmpdir } = await import('node:os');
|
||||
const { join } = await import('node:path');
|
||||
const { vendorDependency, satisfiesCaretOrExact } = await import('../stage-internal-runtime-bundles.mjs');
|
||||
assert.equal(satisfiesCaretOrExact('4.6.7', '^4.6.7'), true);
|
||||
assert.equal(satisfiesCaretOrExact('4.7.0', '^4.6.7'), true);
|
||||
assert.equal(satisfiesCaretOrExact('4.6.6', '^4.6.7'), false);
|
||||
assert.equal(satisfiesCaretOrExact('5.0.0', '^4.6.7'), false);
|
||||
assert.equal(satisfiesCaretOrExact('3.25.76', '^4.6.7'), false);
|
||||
assert.equal(satisfiesCaretOrExact('4.6.7', '4.6.7'), true);
|
||||
assert.throws(() => satisfiesCaretOrExact('4.6.7', '>=4'), /Unsupported/);
|
||||
assert.throws(() => satisfiesCaretOrExact('0.2.1', '^0.2.0'), /Unsupported/);
|
||||
|
||||
const withVendored = createBundledRuntimeManifest(
|
||||
{ name: '@claude-flow/example', version: '1.0.0', dependencies: { leaf: '^4.6.7', other: '^1.0.0' } },
|
||||
['leaf'],
|
||||
);
|
||||
assert.deepEqual(withVendored.dependencies, { leaf: '^4.6.7' });
|
||||
assert.deepEqual(withVendored.rufloBundledRuntime.sourceDependencies.dependencies, {
|
||||
leaf: '^4.6.7',
|
||||
other: '^1.0.0',
|
||||
});
|
||||
assert.throws(
|
||||
() => createBundledRuntimeManifest({ name: 'x', dependencies: {} }, ['leaf']),
|
||||
/does not declare its vendored dependency leaf/,
|
||||
);
|
||||
|
||||
const root = await mkdtemp(join(tmpdir(), 'stage-vendored-'));
|
||||
try {
|
||||
const source = join(root, 'source');
|
||||
const staged = join(root, 'staged');
|
||||
const fixture = async (name, manifest) => {
|
||||
const directory = join(source, 'node_modules', name);
|
||||
await mkdir(join(directory, 'node_modules', 'nested'), { recursive: true });
|
||||
await writeFile(join(directory, 'package.json'), JSON.stringify({ name, main: 'index.js', ...manifest }));
|
||||
await writeFile(join(directory, 'index.js'), 'module.exports = 4;\n');
|
||||
await writeFile(join(directory, 'node_modules', 'nested', 'x.js'), '');
|
||||
};
|
||||
await mkdir(source, { recursive: true });
|
||||
await writeFile(join(source, 'package.json'), '{"name":"@claude-flow/example"}');
|
||||
await fixture('leaf', { version: '4.6.9' });
|
||||
await fixture('old', { version: '3.25.76' });
|
||||
await fixture('tree', { version: '1.0.0', dependencies: { more: '^1.0.0' } });
|
||||
const pkg = { name: '@claude-flow/example', dependencies: { leaf: '^4.6.7', old: '^4.6.7', tree: '^1.0.0' } };
|
||||
|
||||
assert.equal(await vendorDependency(source, staged, pkg, 'leaf'), '4.6.9');
|
||||
const copied = JSON.parse(await readFile(join(staged, 'node_modules', 'leaf', 'package.json'), 'utf8'));
|
||||
assert.equal(copied.version, '4.6.9');
|
||||
await access(join(staged, 'node_modules', 'leaf', 'index.js'));
|
||||
await assert.rejects(access(join(staged, 'node_modules', 'leaf', 'node_modules')));
|
||||
|
||||
// The workspace copy must satisfy the declared range, or zod 3 ships again.
|
||||
await assert.rejects(vendorDependency(source, staged, pkg, 'old'), /workspace resolved 3\.25\.76/);
|
||||
await assert.rejects(vendorDependency(source, staged, pkg, 'tree'), /dependencies of its own/);
|
||||
await assert.rejects(vendorDependency(source, staged, pkg, 'absent'), /does not declare/);
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
console.log('vendored dependencies are declared, range-checked and copied without nested trees');
|
||||
}
|
||||
@@ -49,10 +49,19 @@ const packDest = mkdtempSync(join(tmpdir(), 'cli-pack-'));
|
||||
let tarball;
|
||||
{
|
||||
console.log(`[1/5] packing CLI to ${packDest}`);
|
||||
const pnpm = run('pnpm', ['pack', '--pack-destination', packDest], { cwd: CLI_DIR });
|
||||
if (pnpm.code === 0) {
|
||||
// #4940: pack what a release packs. A release stages the bundled runtime
|
||||
// packages (and their vendored dependencies) and then runs npm pack; a bare
|
||||
// `pnpm pack` bundles the workspace links, which is not the published shape.
|
||||
let pnpm = { code: 1, stderr: 'skipped: staged bundles are packed with npm' };
|
||||
try {
|
||||
const { stageInternalRuntimeBundles } = await import('./stage-internal-runtime-bundles.mjs');
|
||||
await stageInternalRuntimeBundles(CLI_DIR, { build: false });
|
||||
const staged = run('npm', ['pack', '--ignore-scripts', '--pack-destination', packDest], { cwd: CLI_DIR });
|
||||
if (staged.code !== 0) fail(`npm pack of the staged CLI failed:\n${staged.stderr}`);
|
||||
const tgz = readdirSync(packDest).find((f) => f.endsWith('.tgz'));
|
||||
if (tgz) tarball = join(packDest, tgz);
|
||||
} catch (error) {
|
||||
fail(`staging the bundled runtime packages failed: ${error?.stack ?? error}`);
|
||||
}
|
||||
if (!tarball) {
|
||||
// Fallback to npm pack — works when run with pnpm-resolved workspace already installed
|
||||
@@ -112,4 +121,20 @@ if (ver.code !== 0 || !ver.stdout.trim()) {
|
||||
}
|
||||
console.log(` ${ver.stdout.trim()}`);
|
||||
|
||||
console.log(`[5/5] ok — installed cleanly, no "Invalid Version" regression`);
|
||||
// #4940: every bundled runtime package must load from the installed CLI. The
|
||||
// bundled security package once resolved `zod` to the CLI's zod 3 and its root
|
||||
// export threw `z.config is not a function`; --version never imports it.
|
||||
const cliRoot = join(scratch, 'node_modules', '@claude-flow', 'cli');
|
||||
for (const name of installedPkg.bundleDependencies ?? installedPkg.bundledDependencies ?? []) {
|
||||
const load = run('node', ['--input-type=module', '-e',
|
||||
`import { createRequire } from 'node:module'; import { pathToFileURL } from 'node:url';
|
||||
const r = createRequire(${JSON.stringify(join(cliRoot, 'package.json'))});
|
||||
await import(pathToFileURL(r.resolve(${JSON.stringify(name)})).href);`], { cwd: scratch });
|
||||
if (load.code !== 0) {
|
||||
console.error(load.stderr);
|
||||
fail(`bundled ${name} does not import from the installed CLI (exit ${load.code})`);
|
||||
}
|
||||
console.log(` bundled ${name} imports`);
|
||||
}
|
||||
|
||||
console.log(`[5/5] ok — installed cleanly, no "Invalid Version" regression, bundled runtimes import`);
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
writeFile,
|
||||
} from 'node:fs/promises';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -23,6 +24,11 @@ export const INTERNAL_RUNTIME_PACKAGES = [
|
||||
name: '@claude-flow/security',
|
||||
requiredAssets: ['dist'],
|
||||
optionalAssets: ['README.md'],
|
||||
// #4940: security needs zod >=4.6.7 while the CLI and the umbrella keep
|
||||
// zod 3. npm never installs the dependencies of a bundled package, so a
|
||||
// declaration alone still resolves `zod` to the wrapper's zod 3 and the
|
||||
// root export dies at `z.config`. The files have to ship in the bundle.
|
||||
vendoredDependencies: ['zod'],
|
||||
},
|
||||
{
|
||||
directory: 'codex',
|
||||
@@ -125,7 +131,7 @@ async function validateEntrypoints(packageRoot, packageJson) {
|
||||
}
|
||||
}
|
||||
|
||||
export function createBundledRuntimeManifest(packageJson) {
|
||||
export function createBundledRuntimeManifest(packageJson, vendoredDependencies = []) {
|
||||
const dependencyMetadata = {};
|
||||
for (const field of [
|
||||
'dependencies',
|
||||
@@ -146,12 +152,80 @@ export function createBundledRuntimeManifest(packageJson) {
|
||||
},
|
||||
};
|
||||
delete bundledManifest.dependencies;
|
||||
// A vendored dependency ships inside this package's own node_modules. It
|
||||
// stays declared so the manifest matches the files and npm packs them.
|
||||
const vendored = {};
|
||||
for (const name of vendoredDependencies) {
|
||||
const range = packageJson.dependencies?.[name];
|
||||
if (range === undefined) {
|
||||
throw new Error(`${packageJson.name} does not declare its vendored dependency ${name}`);
|
||||
}
|
||||
vendored[name] = range;
|
||||
}
|
||||
if (Object.keys(vendored).length > 0) bundledManifest.dependencies = vendored;
|
||||
delete bundledManifest.optionalDependencies;
|
||||
delete bundledManifest.peerDependencies;
|
||||
delete bundledManifest.peerDependenciesMeta;
|
||||
return bundledManifest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Range check for a vendored dependency, without a semver package: this script
|
||||
* also runs in CI jobs that install only the v3 workspace. Accepts an exact
|
||||
* version or a caret range on a major >= 1; anything else is refused so an
|
||||
* unusual range is looked at, not guessed.
|
||||
*/
|
||||
export function satisfiesCaretOrExact(version, range) {
|
||||
const parse = (value) => /^(\d+)\.(\d+)\.(\d+)$/.exec(value)?.slice(1).map(Number);
|
||||
const got = parse(version);
|
||||
const caret = range.startsWith('^');
|
||||
const want = parse(caret ? range.slice(1) : range);
|
||||
if (!got || !want) throw new Error(`Unsupported vendored version or range: ${version} vs ${range}`);
|
||||
if (!caret) return got.join('.') === want.join('.');
|
||||
if (want[0] === 0) throw new Error(`Unsupported vendored range (0.x caret): ${range}`);
|
||||
if (got[0] !== want[0]) return false;
|
||||
return got[1] !== want[1] ? got[1] > want[1] : got[2] >= want[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy one dependency of a bundled package into that package's node_modules,
|
||||
* from the copy the workspace build resolved. Only leaf packages qualify: a
|
||||
* vendored dependency with dependencies of its own would need them vendored
|
||||
* too, so that is refused instead of shipping a tree that cannot load.
|
||||
*/
|
||||
export async function vendorDependency(sourceRoot, stagedRoot, packageJson, name) {
|
||||
const range = packageJson.dependencies?.[name];
|
||||
if (range === undefined) {
|
||||
throw new Error(`${packageJson.name} does not declare its vendored dependency ${name}`);
|
||||
}
|
||||
let directory = dirname(createRequire(join(sourceRoot, 'package.json')).resolve(name));
|
||||
let manifest;
|
||||
for (;;) {
|
||||
try {
|
||||
const candidate = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8'));
|
||||
if (candidate.name === name) { manifest = candidate; break; }
|
||||
} catch { /* keep walking up to the package root */ }
|
||||
const parent = dirname(directory);
|
||||
if (parent === directory) throw new Error(`Cannot find the package root of ${name}`);
|
||||
directory = parent;
|
||||
}
|
||||
if (!satisfiesCaretOrExact(manifest.version, range)) {
|
||||
throw new Error(
|
||||
`${packageJson.name} needs ${name}@${range}, but the workspace resolved ${manifest.version}`,
|
||||
);
|
||||
}
|
||||
const own = { ...manifest.dependencies, ...manifest.optionalDependencies, ...manifest.peerDependencies };
|
||||
if (Object.keys(own).length > 0) {
|
||||
throw new Error(`${name}@${manifest.version} has dependencies of its own and cannot be vendored`);
|
||||
}
|
||||
await cp(directory, join(stagedRoot, 'node_modules', name), {
|
||||
recursive: true,
|
||||
dereference: true,
|
||||
filter: (source) => !source.slice(directory.length).split(/[\\/]/).includes('node_modules'),
|
||||
});
|
||||
return manifest.version;
|
||||
}
|
||||
|
||||
export function alignBundledRuntimeVersion(targetPackageJson, runtimePackageJson) {
|
||||
const current = targetPackageJson.dependencies?.[runtimePackageJson.name];
|
||||
if (current === undefined) {
|
||||
@@ -224,8 +298,15 @@ export async function stageInternalRuntimeBundles(
|
||||
await mkdir(temporary, { recursive: true });
|
||||
await writeFile(
|
||||
join(temporary, 'package.json'),
|
||||
`${JSON.stringify(createBundledRuntimeManifest(packageJson), null, 2)}\n`,
|
||||
`${JSON.stringify(
|
||||
createBundledRuntimeManifest(packageJson, runtimePackage.vendoredDependencies),
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
for (const name of runtimePackage.vendoredDependencies ?? []) {
|
||||
await vendorDependency(sourceRoot, temporary, packageJson, name);
|
||||
}
|
||||
for (const asset of runtimePackage.requiredAssets) {
|
||||
await copyRequired(join(sourceRoot, asset), join(temporary, asset));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@claude-flow/cli",
|
||||
"version": "3.75.0",
|
||||
"version": "3.75.1",
|
||||
"type": "module",
|
||||
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
||||
"main": "dist/src/index.js",
|
||||
|
||||
Reference in new issue
Block a user