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

Checkpoint: File edits

rUva89403d686ce
diff --git a/package-lock.json b/package-lock.json
index 32d096931a..e129fd9518 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "claude-flow",
- "version": "3.1.0-alpha.23",
+ "version": "3.1.0-alpha.24",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "claude-flow",
- "version": "3.1.0-alpha.23",
+ "version": "3.1.0-alpha.24",
"license": "MIT",
"dependencies": {
"semver": "^7.6.0",
diff --git a/package.json b/package.json
index b261bf1159..8feed40e44 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
- "version": "3.1.0-alpha.23",
+ "version": "3.1.0-alpha.24",
"description": "Enterprise AI agent orchestration for Claude Code - Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "dist/index.js",
"type": "module",
diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json
index b2f2d8ba77..d355107818 100644
--- a/v3/@claude-flow/cli/package.json
+++ b/v3/@claude-flow/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/cli",
- "version": "3.1.0-alpha.23",
+ "version": "3.1.0-alpha.24",
"type": "module",
"description": "Claude Flow 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",
diff --git a/v3/@claude-flow/cli/src/init/executor.ts b/v3/@claude-flow/cli/src/init/executor.ts
index 7bfab537e0..a74bcbd469 100644
--- a/v3/@claude-flow/cli/src/init/executor.ts
+++ b/v3/@claude-flow/cli/src/init/executor.ts
@@ -917,38 +917,45 @@ async function copyAgents(
}
/**
- * Find source helpers directory
+ * Find source helpers directory.
+ * Validates that the directory contains hook-handler.cjs to avoid
+ * returning the target directory or an incomplete source.
*/
function findSourceHelpersDir(sourceBaseDir?: string): string | null {
const possiblePaths: string[] = [];
+ const SENTINEL_FILE = 'hook-handler.cjs'; // Must exist in valid source
// If explicit source base directory is provided, check it first
if (sourceBaseDir) {
possiblePaths.push(path.join(sourceBaseDir, '.claude', 'helpers'));
}
- // IMPORTANT: Check the package's own .claude/helpers directory
- // This is the primary path when running as an npm package
- // __dirname is typically /path/to/node_modules/@claude-flow/cli/dist/src/init
- // We need to go up 3 levels to reach the package root (dist/src/init -> dist/src -> dist -> root)
+ // Strategy 1: require.resolve to find package root (most reliable for npx)
+ try {
+ // Find our own package.json via require.resolve
+ const pkgJsonPath = require.resolve('@claude-flow/cli/package.json');
+ const pkgRoot = path.dirname(pkgJsonPath);
+ possiblePaths.push(path.join(pkgRoot, '.claude', 'helpers'));
+ } catch {
+ // Not installed as a package — skip
+ }
+
+ // Strategy 2: __dirname-based (dist/src/init -> package root)
const packageRoot = path.resolve(__dirname, '..', '..', '..');
const packageHelpers = path.join(packageRoot, '.claude', 'helpers');
- if (fs.existsSync(packageHelpers)) {
- possiblePaths.unshift(packageHelpers); // Add to beginning (highest priority)
- }
+ possiblePaths.push(packageHelpers);
- // From dist/src/init -> go up to project root
+ // Strategy 3: Walk up from __dirname looking for package root
let currentDir = __dirname;
for (let i = 0; i < 10; i++) {
const parentDir = path.dirname(currentDir);
+ if (parentDir === currentDir) break; // hit filesystem root
const helpersPath = path.join(parentDir, '.claude', 'helpers');
- if (fs.existsSync(helpersPath)) {
- possiblePaths.push(helpersPath);
- }
+ possiblePaths.push(helpersPath);
currentDir = parentDir;
}
- // Also check relative to process.cwd() for development
+ // Strategy 4: Check cwd-relative paths (for local dev)
const cwdBased = [
path.join(process.cwd(), '.claude', 'helpers'),
path.join(process.cwd(), '..', '.claude', 'helpers'),
@@ -956,8 +963,9 @@ function findSourceHelpersDir(sourceBaseDir?: string): string | null {
];
possiblePaths.push(...cwdBased);
+ // Return first path that exists AND contains the sentinel file
for (const p of possiblePaths) {
- if (fs.existsSync(p)) {
+ if (fs.existsSync(p) && fs.existsSync(path.join(p, SENTINEL_FILE))) {
return p;
}
}