{"record":{"id":"4bf54e403df677e6","repo":"ruvnet/ruflo","slug":"aidefence-installed-but-failed-to-load-retryerr","errorCode":null,"errorMessage":"AIDefence installed but failed to load: ${retryError}.\nThis usually means npm installed the package somewhere Node's module resolver doesn't search (common with global installs of `claude-flow`). Recovery options:\n  1. Run `npm install --save @claude-flow/aidefence` in your project's working directory.\n  2. Or run `npx ruflo@latest mcp start` from a directory whose node_modules contains the package.\n  3. Or restart the MCP server after the install completes.","messagePattern":"AIDefence installed but failed to load: (.+?)\\.\nThis usually means npm installed the package somewhere Node's module resolver doesn't search \\(common with global installs of `claude-flow`\\)\\. Recovery options:\n  1\\. Run `npm install --save @claude-flow/aidefence` in your project's working directory\\.\n  2\\. Or run `npx ruflo@latest mcp start` from a directory whose node_modules contains the package\\.\n  3\\. Or restart the MCP server after the install completes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/security-tools.ts","lineNumber":120,"sourceCode":"      return instance;\n    }\n  } catch { /* fall through to file:// attempt */ }\n\n  // file:// + cache-bust attempt (covers globally-installed packages whose\n  // path the standard resolver missed but require.resolve can locate).\n  try {\n    const modulePath = require.resolve(packageName);\n    const cacheBust = `?t=${Date.now()}`;\n    const aidefence = await import(`file://${modulePath}${cacheBust}`);\n    const instance = aidefence.createAIDefence({ enableLearning: true });\n    if (!instance) {\n      throw new Error('createAIDefence returned null after install');\n    }\n    aidefenceInstance = instance;\n    console.error(`[claude-flow] ${packageName} loaded after install (file:// path)`);\n    return instance;\n  } catch (retryError) {\n    throw new Error(\n      `AIDefence installed but failed to load: ${retryError}.\\n` +\n      `This usually means npm installed the package somewhere Node's module resolver doesn't search ` +\n      `(common with global installs of \\`claude-flow\\`). Recovery options:\\n` +\n      `  1. Run \\`npm install --save @claude-flow/aidefence\\` in your project's working directory.\\n` +\n      `  2. Or run \\`npx ruflo@latest mcp start\\` from a directory whose node_modules contains the package.\\n` +\n      `  3. Or restart the MCP server after the install completes.`\n    );\n  }\n}\n\n/**\n * Scan input for AI manipulation threats\n */\nconst aidefenceScanTool: MCPTool = {\n  name: 'aidefence_scan',\n  description: 'Scan input text for AI manipulation threats (prompt injection, jailbreaks, PII). Returns threat assessment with <10ms latency. Use when nothing native exists — Claude Code does not have a PII / prompt-injection / adversarial-text scanner. Pair with any tool that ingests untrusted input (browser scrape, federation envelope, memory_import_claude).',\n  inputSchema: {\n    type: 'object',","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/security-tools.ts#L102-L138","documentation":"Error \"AIDefence installed but failed to load: ${retryError}.\nThis usually means npm installed the package somewhere Node's module resolver doesn't search (common with global installs of `claude-flow`). Recovery options:\n  1. Run `npm install --save @claude-flow/aidefence` in your project's working directory.\n  2. Or run `npx ruflo@latest mcp start` from a directory whose node_modules contains the package.\n  3. Or restart the MCP server after the install completes.\" thrown in ruvnet/ruflo.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/mcp-tools/security-tools.ts:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}