claude-flow 3.5.1 → 3.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "description": "Ruflo - 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",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -5,8 +5,9 @@
5
5
  * Created with ruv.io
6
6
  */
7
7
  import { output } from '../output.js';
8
- import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
9
- import { join } from 'path';
8
+ import { existsSync, readFileSync, statSync } from 'fs';
9
+ import { join, dirname } from 'path';
10
+ import { fileURLToPath } from 'url';
10
11
  import { execSync, exec } from 'child_process';
11
12
  import { promisify } from 'util';
12
13
  // Promisified exec with proper shell and env inheritance for cross-platform support
@@ -224,53 +225,35 @@ async function checkBuildTools() {
224
225
  async function checkVersionFreshness() {
225
226
  try {
226
227
  // Get current CLI version from package.json
228
+ // Use import.meta.url to reliably locate our own package.json,
229
+ // regardless of how deep the compiled file sits (e.g. dist/src/commands/).
227
230
  let currentVersion = '0.0.0';
228
231
  try {
229
- // Get directory of current module and walk up to find package.json
230
- const moduleUrl = new URL(import.meta.url);
231
- const modulePath = moduleUrl.protocol === 'file:' ? moduleUrl.pathname : import.meta.url;
232
- const moduleDir = modulePath.substring(0, modulePath.lastIndexOf('/'));
233
- // Look for package.json in multiple locations
234
- const possiblePaths = [
235
- join(moduleDir, '..', 'package.json'), // ../package.json from dist/commands
236
- join(moduleDir, '..', '..', 'package.json'), // ../../package.json from dist/commands
237
- join(process.cwd(), 'package.json'), // Current working directory
238
- join(process.cwd(), 'node_modules/@claude-flow/cli/package.json')
239
- ];
240
- // Also search in npx cache directories (Linux/macOS)
241
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
242
- if (homeDir) {
243
- // Check common npx cache locations
232
+ const thisFile = fileURLToPath(import.meta.url);
233
+ let dir = dirname(thisFile);
234
+ // Walk up from the current file's directory until we find the
235
+ // package.json that belongs to @claude-flow/cli (or claude-flow/cli).
236
+ // Walk until dirname(dir) === dir (filesystem root on any platform).
237
+ for (;;) {
238
+ const candidate = join(dir, 'package.json');
244
239
  try {
245
- const npxCacheDir = join(homeDir, '.npm', '_npx');
246
- if (existsSync(npxCacheDir)) {
247
- const cacheEntries = readdirSync(npxCacheDir);
248
- for (const entry of cacheEntries) {
249
- const npxPkgPath = join(npxCacheDir, entry, 'node_modules', '@claude-flow', 'cli', 'package.json');
250
- if (existsSync(npxPkgPath)) {
251
- possiblePaths.push(npxPkgPath);
252
- }
253
- }
254
- }
255
- }
256
- catch {
257
- // Ignore errors scanning npx cache
258
- }
259
- }
260
- for (const pkgPath of possiblePaths) {
261
- try {
262
- if (existsSync(pkgPath)) {
263
- const packageJson = JSON.parse(readFileSync(pkgPath, 'utf8'));
264
- // Make sure it's the right package
265
- if (packageJson.name === '@claude-flow/cli' && packageJson.version) {
266
- currentVersion = packageJson.version;
240
+ if (existsSync(candidate)) {
241
+ const pkg = JSON.parse(readFileSync(candidate, 'utf8'));
242
+ if (pkg.version &&
243
+ typeof pkg.name === 'string' &&
244
+ (pkg.name === '@claude-flow/cli' || pkg.name === 'claude-flow' || pkg.name === 'ruflo')) {
245
+ currentVersion = pkg.version;
267
246
  break;
268
247
  }
269
248
  }
270
249
  }
271
250
  catch {
272
- continue;
251
+ // Unreadable/invalid JSON -- skip and keep walking up
273
252
  }
253
+ const parent = dirname(dir);
254
+ if (parent === dir)
255
+ break; // reached root
256
+ dir = parent;
274
257
  }
275
258
  }
276
259
  catch {
@@ -284,7 +267,7 @@ async function checkVersionFreshness() {
284
267
  // Query npm for latest version (using alpha tag since that's what we publish to)
285
268
  let latestVersion = currentVersion;
286
269
  try {
287
- const npmInfo = await runCommand('npm view @claude-flow/cli@alpha version 2>/dev/null', 5000);
270
+ const npmInfo = await runCommand('npm view @claude-flow/cli@alpha version', 5000);
288
271
  latestVersion = npmInfo.trim();
289
272
  }
290
273
  catch {
@@ -217,12 +217,9 @@ function mergeSettingsForUpgrade(existing) {
217
217
  // Platform-specific command wrappers
218
218
  // Windows: Use PowerShell-compatible commands
219
219
  // Mac/Linux: Use bash-compatible commands with 2>/dev/null
220
- const teammateIdleCmd = isWindows
221
- ? 'npx @claude-flow/cli@latest hooks teammate-idle --auto-assign true 2>$null; exit 0'
222
- : 'npx @claude-flow/cli@latest hooks teammate-idle --auto-assign true 2>/dev/null || true';
223
- const taskCompletedCmd = isWindows
224
- ? 'if ($env:TASK_ID) { npx @claude-flow/cli@latest hooks task-completed --task-id $env:TASK_ID --train-patterns true 2>$null }; exit 0'
225
- : '[ -n "$TASK_ID" ] && npx @claude-flow/cli@latest hooks task-completed --task-id "$TASK_ID" --train-patterns true 2>/dev/null || true';
220
+ // NOTE: teammateIdleCmd and taskCompletedCmd were removed.
221
+ // TeammateIdle/TaskCompleted are not valid Claude Code hook events and caused warnings.
222
+ // Agent Teams hook config lives in claudeFlow.agentTeams.hooks instead.
226
223
  // 1. Merge env vars (preserve existing, add new)
227
224
  const existingEnv = existing.env || {};
228
225
  merged.env = {
@@ -278,36 +275,12 @@ function mergeSettingsForUpgrade(existing) {
278
275
  continueOnError: true,
279
276
  });
280
277
  }
281
- // Add TeammateIdle hook if not present
282
- if (!existingHooks.TeammateIdle) {
283
- merged.hooks.TeammateIdle = [
284
- {
285
- hooks: [
286
- {
287
- type: 'command',
288
- command: teammateIdleCmd,
289
- timeout: 5000,
290
- continueOnError: true,
291
- },
292
- ],
293
- },
294
- ];
295
- }
296
- // Add TaskCompleted hook if not present
297
- if (!existingHooks.TaskCompleted) {
298
- merged.hooks.TaskCompleted = [
299
- {
300
- hooks: [
301
- {
302
- type: 'command',
303
- command: taskCompletedCmd,
304
- timeout: 5000,
305
- continueOnError: true,
306
- },
307
- ],
308
- },
309
- ];
310
- }
278
+ // NOTE: TeammateIdle and TaskCompleted are NOT valid Claude Code hook events.
279
+ // They cause warnings when present in settings.json hooks.
280
+ // Remove them if they exist from a previous init.
281
+ delete merged.hooks.TeammateIdle;
282
+ delete merged.hooks.TaskCompleted;
283
+ // Their configuration lives in claudeFlow.agentTeams.hooks instead.
311
284
  // 3. Fix statusLine config (remove invalid fields, ensure correct format)
312
285
  // Claude Code only supports: type, command, padding
313
286
  const existingStatusLine = existing.statusLine;
@@ -526,8 +499,8 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
526
499
  'env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS',
527
500
  'hooks.SessionStart (auto-memory import)',
528
501
  'hooks.SessionEnd (auto-memory sync)',
529
- 'hooks.TeammateIdle',
530
- 'hooks.TaskCompleted',
502
+ 'hooks.TeammateIdle (removed — not a valid Claude Code hook)',
503
+ 'hooks.TaskCompleted (removed — not a valid Claude Code hook)',
531
504
  'claudeFlow.agentTeams',
532
505
  'claudeFlow.memory (learningBridge, memoryGraph, agentScopes)',
533
506
  ];
@@ -301,30 +301,8 @@ function generateHooksConfig(config) {
301
301
  ],
302
302
  },
303
303
  ];
304
- // TeammateIdle auto-assign pending tasks to idle teammates
305
- hooks.TeammateIdle = [
306
- {
307
- hooks: [
308
- {
309
- type: 'command',
310
- command: 'node .claude/helpers/hook-handler.cjs post-task',
311
- timeout: 5000,
312
- },
313
- ],
314
- },
315
- ];
316
- // TaskCompleted — train patterns and record completion
317
- hooks.TaskCompleted = [
318
- {
319
- hooks: [
320
- {
321
- type: 'command',
322
- command: 'node .claude/helpers/hook-handler.cjs post-task',
323
- timeout: 5000,
324
- },
325
- ],
326
- },
327
- ];
304
+ // NOTE: TeammateIdle and TaskCompleted are NOT valid Claude Code hook events.
305
+ // Their configuration lives in claudeFlow.agentTeams.hooks instead (see generateSettings).
328
306
  return hooks;
329
307
  }
330
308
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",