claude-flow-novice 2.14.30 → 2.14.32

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.
Files changed (81) hide show
  1. package/.claude/cfn-data/cfn-loop.db +0 -0
  2. package/.claude/commands/CFN_LOOP_TASK_MODE.md +1 -1
  3. package/.claude/skills/cfn-agent-discovery/agents-registry.json +10 -9
  4. package/.claude/skills/cfn-docker-agent-spawning/SKILL.md +394 -0
  5. package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +521 -0
  6. package/.claude/skills/cfn-docker-loop-orchestration/SKILL.md +449 -0
  7. package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +787 -0
  8. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +435 -0
  9. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +635 -0
  10. package/.claude/skills/cfn-docker-skill-mcp-selection/SKILL.md +289 -0
  11. package/.claude/skills/cfn-docker-skill-mcp-selection/skill-mcp-selector.js +472 -0
  12. package/.claude/skills/cfn-loop-validation/config.json +2 -2
  13. package/README.md +95 -0
  14. package/claude-assets/agents/README-AGENT_LIFECYCLE.md +10 -37
  15. package/claude-assets/agents/README-VALIDATION.md +8 -0
  16. package/claude-assets/agents/cfn-dev-team/CLAUDE.md +10 -9
  17. package/claude-assets/agents/cfn-dev-team/README.md +8 -0
  18. package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +2 -9
  19. package/claude-assets/agents/cfn-dev-team/coordinators/README.md +9 -1
  20. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +7 -12
  21. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +10 -5
  22. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +11 -10
  23. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +10 -5
  24. package/claude-assets/agents/cfn-dev-team/developers/README.md +9 -1
  25. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +2 -5
  26. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +11 -6
  27. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +2 -5
  28. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +2 -19
  29. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +11 -6
  30. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +9 -23
  31. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +10 -5
  32. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +2 -9
  33. package/claude-assets/agents/cfn-dev-team/documentation/README-VALIDATION.md +8 -0
  34. package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +10 -0
  35. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +2 -9
  36. package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +11 -6
  37. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +0 -5
  38. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +0 -3
  39. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +2 -8
  40. package/claude-assets/agents/cfn-dev-team/reviewers/README.md +9 -1
  41. package/claude-assets/agents/cfn-dev-team/reviewers/quality/quality-metrics.md +10 -0
  42. package/claude-assets/agents/cfn-dev-team/test-agent.md +10 -0
  43. package/claude-assets/agents/cfn-dev-team/testers/README.md +9 -1
  44. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +0 -7
  45. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +1 -38
  46. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +10 -5
  47. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +8 -34
  48. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +10 -5
  49. package/claude-assets/agents/csuite/cto-agent.md +10 -0
  50. package/claude-assets/agents/custom/cfn-system-expert.md +128 -1
  51. package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +5 -1
  52. package/claude-assets/agents/docker-team/csuite/c-suite-template.md +5 -1
  53. package/claude-assets/agents/docker-team/infrastructure/team-coordinator-template.md +5 -1
  54. package/claude-assets/agents/marketing_hybrid/cost_tracker.md +10 -0
  55. package/claude-assets/agents/marketing_hybrid/docker_deployer.md +10 -0
  56. package/claude-assets/agents/marketing_hybrid/zai_worker_spawner.md +10 -0
  57. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +9 -26
  58. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +1 -1
  59. package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +20 -0
  60. package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +20 -0
  61. package/claude-assets/skills/agent-lifecycle/SKILL.md +60 -0
  62. package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
  63. package/claude-assets/skills/agent-lifecycle/simple-audit.sh +31 -0
  64. package/claude-assets/skills/cfn-agent-discovery/agents-registry.json +10 -9
  65. package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +70 -10
  66. package/claude-assets/skills/cfn-loop-validation/config.json +2 -2
  67. package/claude-assets/skills/cfn-memory-management/SKILL.md +271 -0
  68. package/claude-assets/skills/cfn-memory-management/check-memory.sh +160 -0
  69. package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +197 -0
  70. package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +2 -2
  71. package/dist/agents/agent-loader.js +165 -146
  72. package/dist/agents/agent-loader.js.map +1 -1
  73. package/dist/cli/agent-command.js +44 -2
  74. package/dist/cli/agent-command.js.map +1 -1
  75. package/dist/cli/config-manager.js +91 -109
  76. package/dist/cli/config-manager.js.map +1 -1
  77. package/dist/cli/index.js +29 -2
  78. package/dist/cli/index.js.map +1 -1
  79. package/package.json +10 -2
  80. package/readme/README.md +71 -14
  81. package/scripts/memory-leak-prevention.sh +306 -0
package/dist/cli/index.js CHANGED
@@ -1,11 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * CLI Entry Point - v2.0
3
+ * CLI Entry Point - v2.1
4
4
  *
5
- * Handles agent spawning commands:
5
+ * Handles agent spawning commands with memory management:
6
6
  * npx claude-flow-novice agent <type> [options]
7
7
  */ // Load environment variables from .env file
8
8
  import 'dotenv/config';
9
+ // Apply safe memory defaults if not configured
10
+ if (!process.env.NODE_OPTIONS) {
11
+ // Set conservative 8GB limit (reduced from default 16GB)
12
+ process.env.NODE_OPTIONS = '--max-old-space-size=8192';
13
+ } else if (!process.env.NODE_OPTIONS.includes('max-old-space-size')) {
14
+ // Append memory limit to existing NODE_OPTIONS
15
+ process.env.NODE_OPTIONS += ' --max-old-space-size=8192';
16
+ }
17
+ // Enable memory profiling in development/debug mode
18
+ if (process.env.NODE_ENV === 'development' || process.env.CLAUDE_DEBUG) {
19
+ if (!process.env.NODE_OPTIONS.includes('inspect')) {
20
+ process.env.NODE_OPTIONS += ' --inspect=0.0.0.0:9229';
21
+ }
22
+ if (!process.env.NODE_OPTIONS.includes('heap-prof')) {
23
+ process.env.NODE_OPTIONS += ' --heap-prof';
24
+ }
25
+ }
9
26
  import { VERSION } from '../core/index.js';
10
27
  import { agentCommand } from './agent-command.js';
11
28
  /**
@@ -54,6 +71,16 @@ import { agentCommand } from './agent-command.js';
54
71
  case '-h':
55
72
  options.help = true;
56
73
  break;
74
+ case '--memory-limit':
75
+ options.memoryLimit = parseInt(value, 10);
76
+ i++;
77
+ break;
78
+ case '--enable-profiling':
79
+ options.enableProfiling = true;
80
+ break;
81
+ case '--debug':
82
+ options.debug = true;
83
+ break;
57
84
  }
58
85
  }
59
86
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * CLI Entry Point - v2.0\r\n *\r\n * Handles agent spawning commands:\r\n * npx claude-flow-novice agent <type> [options]\r\n */\r\n\r\n// Load environment variables from .env file\r\nimport 'dotenv/config';\r\n\r\nimport { VERSION } from '../core/index.js';\r\nimport { agentCommand, AgentCommandOptions } from './agent-command.js';\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(args: string[]): { command: string; agentType?: string; options: AgentCommandOptions } {\r\n const command = args[0] || 'help';\r\n const agentType = args[1] && !args[1].startsWith('--') ? args[1] : undefined;\r\n const options: AgentCommandOptions = {};\r\n\r\n // Parse options\r\n for (let i = agentType ? 2 : 1; i < args.length; i++) {\r\n const arg = args[i];\r\n const value = args[i + 1];\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = value;\r\n i++;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--agent-id':\r\n options.agentId = value;\r\n i++;\r\n break;\r\n case '--context':\r\n options.context = value;\r\n i++;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n i++;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n i++;\r\n break;\r\n case '--list':\r\n options.list = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n }\r\n }\r\n\r\n return { command, agentType, options };\r\n}\r\n\r\n/**\r\n * Display main CLI help\r\n */\r\nfunction displayHelp(): void {\r\n console.log(`\r\nClaude Flow Novice CLI v${VERSION}\r\n\r\nUsage:\r\n npx claude-flow-novice <command> [options]\r\n\r\nCommands:\r\n agent <type> [options] Spawn an agent for task execution\r\n --version Show version number\r\n --help Show this help message\r\n\r\nExamples:\r\n # Spawn an agent\r\n npx claude-flow-novice agent coder --context \"Implement feature\"\r\n\r\n # List available agents\r\n npx claude-flow-novice agent --list\r\n\r\n # Show version\r\n npx claude-flow-novice --version\r\n\r\nFor more information:\r\n https://github.com/yourusername/claude-flow-novice\r\n`);\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n\r\n // Handle version flag\r\n if (args.includes('--version') || args.includes('-v')) {\r\n console.log(`Claude Flow Novice v${VERSION}`);\r\n return;\r\n }\r\n\r\n // Handle help flag\r\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\r\n displayHelp();\r\n return;\r\n }\r\n\r\n const { command, agentType, options } = parseArgs(args);\r\n\r\n switch (command) {\r\n case 'agent':\r\n await agentCommand(agentType, options);\r\n break;\r\n\r\n default:\r\n console.error(`Unknown command: ${command}`);\r\n console.log('Run with --help for usage information');\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run CLI\r\nmain().catch((error) => {\r\n console.error('[claude-flow-novice] Fatal error:', error);\r\n process.exit(1);\r\n});\r\n"],"names":["VERSION","agentCommand","parseArgs","args","command","agentType","startsWith","undefined","options","i","length","arg","value","taskId","iteration","parseInt","agentId","context","mode","priority","parentTaskId","list","help","displayHelp","console","log","main","process","argv","slice","includes","error","exit","catch"],"mappings":";AACA;;;;;CAKC,GAED,4CAA4C;AAC5C,OAAO,gBAAgB;AAEvB,SAASA,OAAO,QAAQ,mBAAmB;AAC3C,SAASC,YAAY,QAA6B,qBAAqB;AAEvE;;CAEC,GACD,SAASC,UAAUC,IAAc;IAC/B,MAAMC,UAAUD,IAAI,CAAC,EAAE,IAAI;IAC3B,MAAME,YAAYF,IAAI,CAAC,EAAE,IAAI,CAACA,IAAI,CAAC,EAAE,CAACG,UAAU,CAAC,QAAQH,IAAI,CAAC,EAAE,GAAGI;IACnE,MAAMC,UAA+B,CAAC;IAEtC,gBAAgB;IAChB,IAAK,IAAIC,IAAIJ,YAAY,IAAI,GAAGI,IAAIN,KAAKO,MAAM,EAAED,IAAK;QACpD,MAAME,MAAMR,IAAI,CAACM,EAAE;QACnB,MAAMG,QAAQT,IAAI,CAACM,IAAI,EAAE;QAEzB,OAAQE;YACN,KAAK;gBACHH,QAAQK,MAAM,GAAGD;gBACjBH;gBACA;YACF,KAAK;gBACHD,QAAQM,SAAS,GAAGC,SAASH,OAAO;gBACpCH;gBACA;YACF,KAAK;gBACHD,QAAQQ,OAAO,GAAGJ;gBAClBH;gBACA;YACF,KAAK;gBACHD,QAAQS,OAAO,GAAGL;gBAClBH;gBACA;YACF,KAAK;gBACHD,QAAQU,IAAI,GAAGN;gBACfH;gBACA;YACF,KAAK;gBACHD,QAAQW,QAAQ,GAAGJ,SAASH,OAAO;gBACnCH;gBACA;YACF,KAAK;gBACHD,QAAQY,YAAY,GAAGR;gBACvBH;gBACA;YACF,KAAK;gBACHD,QAAQa,IAAI,GAAG;gBACf;YACF,KAAK;YACL,KAAK;gBACHb,QAAQc,IAAI,GAAG;gBACf;QACJ;IACF;IAEA,OAAO;QAAElB;QAASC;QAAWG;IAAQ;AACvC;AAEA;;CAEC,GACD,SAASe;IACPC,QAAQC,GAAG,CAAC,CAAC;wBACS,EAAEzB,QAAQ;;;;;;;;;;;;;;;;;;;;;;AAsBlC,CAAC;AACD;AAEA;;CAEC,GACD,eAAe0B;IACb,MAAMvB,OAAOwB,QAAQC,IAAI,CAACC,KAAK,CAAC;IAEhC,sBAAsB;IACtB,IAAI1B,KAAK2B,QAAQ,CAAC,gBAAgB3B,KAAK2B,QAAQ,CAAC,OAAO;QACrDN,QAAQC,GAAG,CAAC,CAAC,oBAAoB,EAAEzB,SAAS;QAC5C;IACF;IAEA,mBAAmB;IACnB,IAAIG,KAAKO,MAAM,KAAK,KAAKP,KAAK2B,QAAQ,CAAC,aAAa3B,KAAK2B,QAAQ,CAAC,OAAO;QACvEP;QACA;IACF;IAEA,MAAM,EAAEnB,OAAO,EAAEC,SAAS,EAAEG,OAAO,EAAE,GAAGN,UAAUC;IAElD,OAAQC;QACN,KAAK;YACH,MAAMH,aAAaI,WAAWG;YAC9B;QAEF;YACEgB,QAAQO,KAAK,CAAC,CAAC,iBAAiB,EAAE3B,SAAS;YAC3CoB,QAAQC,GAAG,CAAC;YACZE,QAAQK,IAAI,CAAC;IACjB;AACF;AAEA,UAAU;AACVN,OAAOO,KAAK,CAAC,CAACF;IACZP,QAAQO,KAAK,CAAC,qCAAqCA;IACnDJ,QAAQK,IAAI,CAAC;AACf"}
1
+ {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * CLI Entry Point - v2.1\r\n *\r\n * Handles agent spawning commands with memory management:\r\n * npx claude-flow-novice agent <type> [options]\r\n */\r\n\r\n// Load environment variables from .env file\r\nimport 'dotenv/config';\r\n\r\n// Apply safe memory defaults if not configured\r\nif (!process.env.NODE_OPTIONS) {\r\n // Set conservative 8GB limit (reduced from default 16GB)\r\n process.env.NODE_OPTIONS = '--max-old-space-size=8192';\r\n} else if (!process.env.NODE_OPTIONS.includes('max-old-space-size')) {\r\n // Append memory limit to existing NODE_OPTIONS\r\n process.env.NODE_OPTIONS += ' --max-old-space-size=8192';\r\n}\r\n\r\n// Enable memory profiling in development/debug mode\r\nif (process.env.NODE_ENV === 'development' || process.env.CLAUDE_DEBUG) {\r\n if (!process.env.NODE_OPTIONS.includes('inspect')) {\r\n process.env.NODE_OPTIONS += ' --inspect=0.0.0.0:9229';\r\n }\r\n if (!process.env.NODE_OPTIONS.includes('heap-prof')) {\r\n process.env.NODE_OPTIONS += ' --heap-prof';\r\n }\r\n}\r\n\r\nimport { VERSION } from '../core/index.js';\r\nimport { agentCommand, AgentCommandOptions } from './agent-command.js';\r\n\r\n/**\r\n * Parse command line arguments\r\n */\r\nfunction parseArgs(args: string[]): { command: string; agentType?: string; options: AgentCommandOptions } {\r\n const command = args[0] || 'help';\r\n const agentType = args[1] && !args[1].startsWith('--') ? args[1] : undefined;\r\n const options: AgentCommandOptions = {};\r\n\r\n // Parse options\r\n for (let i = agentType ? 2 : 1; i < args.length; i++) {\r\n const arg = args[i];\r\n const value = args[i + 1];\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n options.taskId = value;\r\n i++;\r\n break;\r\n case '--iteration':\r\n options.iteration = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--agent-id':\r\n options.agentId = value;\r\n i++;\r\n break;\r\n case '--context':\r\n options.context = value;\r\n i++;\r\n break;\r\n case '--mode':\r\n options.mode = value;\r\n i++;\r\n break;\r\n case '--priority':\r\n options.priority = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--parent-task-id':\r\n options.parentTaskId = value;\r\n i++;\r\n break;\r\n case '--list':\r\n options.list = true;\r\n break;\r\n case '--help':\r\n case '-h':\r\n options.help = true;\r\n break;\r\n case '--memory-limit':\r\n options.memoryLimit = parseInt(value, 10);\r\n i++;\r\n break;\r\n case '--enable-profiling':\r\n options.enableProfiling = true;\r\n break;\r\n case '--debug':\r\n options.debug = true;\r\n break;\r\n }\r\n }\r\n\r\n return { command, agentType, options };\r\n}\r\n\r\n/**\r\n * Display main CLI help\r\n */\r\nfunction displayHelp(): void {\r\n console.log(`\r\nClaude Flow Novice CLI v${VERSION}\r\n\r\nUsage:\r\n npx claude-flow-novice <command> [options]\r\n\r\nCommands:\r\n agent <type> [options] Spawn an agent for task execution\r\n --version Show version number\r\n --help Show this help message\r\n\r\nExamples:\r\n # Spawn an agent\r\n npx claude-flow-novice agent coder --context \"Implement feature\"\r\n\r\n # List available agents\r\n npx claude-flow-novice agent --list\r\n\r\n # Show version\r\n npx claude-flow-novice --version\r\n\r\nFor more information:\r\n https://github.com/yourusername/claude-flow-novice\r\n`);\r\n}\r\n\r\n/**\r\n * Main CLI entry point\r\n */\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n\r\n // Handle version flag\r\n if (args.includes('--version') || args.includes('-v')) {\r\n console.log(`Claude Flow Novice v${VERSION}`);\r\n return;\r\n }\r\n\r\n // Handle help flag\r\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\r\n displayHelp();\r\n return;\r\n }\r\n\r\n const { command, agentType, options } = parseArgs(args);\r\n\r\n switch (command) {\r\n case 'agent':\r\n await agentCommand(agentType, options);\r\n break;\r\n\r\n default:\r\n console.error(`Unknown command: ${command}`);\r\n console.log('Run with --help for usage information');\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run CLI\r\nmain().catch((error) => {\r\n console.error('[claude-flow-novice] Fatal error:', error);\r\n process.exit(1);\r\n});\r\n"],"names":["process","env","NODE_OPTIONS","includes","NODE_ENV","CLAUDE_DEBUG","VERSION","agentCommand","parseArgs","args","command","agentType","startsWith","undefined","options","i","length","arg","value","taskId","iteration","parseInt","agentId","context","mode","priority","parentTaskId","list","help","memoryLimit","enableProfiling","debug","displayHelp","console","log","main","argv","slice","error","exit","catch"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow-novice",
3
- "version": "2.14.30",
3
+ "version": "2.14.32",
4
4
  "description": "AI agent orchestration framework with namespace-isolated skills, agents, and CFN Loop validation. Safe installation with ~0.01% collision risk.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -24,6 +24,10 @@
24
24
  ".claude/skills/cfn-agent-output-processing/",
25
25
  ".claude/skills/cfn-agent-selector/",
26
26
  ".claude/skills/cfn-agent-spawning/",
27
+ ".claude/skills/cfn-docker-agent-spawning/",
28
+ ".claude/skills/cfn-docker-loop-orchestration/",
29
+ ".claude/skills/cfn-docker-redis-coordination/",
30
+ ".claude/skills/cfn-docker-skill-mcp-selection/",
27
31
  ".claude/skills/cfn-analytics/",
28
32
  ".claude/skills/cfn-backlog-management/",
29
33
  ".claude/skills/cfn-changelog-management/",
@@ -70,7 +74,11 @@
70
74
  "automation",
71
75
  "cli",
72
76
  "consensus",
73
- "validation"
77
+ "validation",
78
+ "docker",
79
+ "containers",
80
+ "memory-leaks",
81
+ "concurrent-execution"
74
82
  ],
75
83
  "author": "Claude Flow Novice Team",
76
84
  "license": "MIT",
package/readme/README.md CHANGED
@@ -12,24 +12,67 @@
12
12
 
13
13
  Claude Flow Novice is a production-ready AI agent orchestration framework built on a skills-first architecture with Redis-based coordination, zero-token waiting mechanisms, and multi-loop consensus validation (CFN Loop).
14
14
 
15
+ ## CFN Loop Execution Modes
16
+
17
+ ### Task Mode (Debugging - Full Visibility)
18
+ - **Spawn Method**: Main Chat spawns Task() agents directly
19
+ - **Cost**: $0.150/iteration (Anthropic provider)
20
+ - **Visibility**: Complete agent output in Main Chat
21
+ - **Use Case**: Debugging, learning, short tasks (<5 minutes)
22
+ - **Memory**: ANTI-023 protection prevents memory leaks
23
+ - **Audit**: Automatic audit trail storage in SQLite and Redis
24
+
25
+ ### CLI Mode (Production - Cost Optimized)
26
+ - **Spawn Method**: Coordinator spawns CLI agents via `npx claude-flow-novice`
27
+ - **Cost**: $0.054/iteration (64% savings vs Task mode)
28
+ - **Visibility**: Background execution with progress tracking
29
+ - **Use Case**: Production, long tasks, cost-sensitive workflows
30
+ - **Memory**: Redis-based coordination with recovery capabilities
31
+ - **Custom Routing**: Optional 5x cost reduction with Z.ai provider
32
+
33
+ ### Mode Selection Guide
34
+ - **Use Task Mode when**: Debugging issues, learning CFN Loop, short tasks requiring full visibility
35
+ - **Use CLI Mode when**: Production work, cost optimization, long-running tasks, background execution
36
+ - **Custom Routing**: `/custom-routing-activate` for 95-98% total cost savings when using CLI mode
37
+
38
+ ### Slash Commands
39
+ - **`/cfn-loop-task`**: Task mode execution (Main Chat → Task() agents)
40
+ - **`/cfn-loop-cli`**: CLI mode execution (Main Chat → coordinator → CLI agents)
41
+ - **Mode Parameters**: `--mode=mvp|standard|enterprise` with different confidence thresholds
42
+
43
+ ### Cost Comparison
44
+ - **Task Mode**: $0.150/iteration (full visibility, debugging)
45
+ - **CLI Mode**: $0.054/iteration (64% savings, production)
46
+ - **With Custom Routing**: $0.004-0.010/iteration (95-98% total savings)
47
+
15
48
  ## Quick Start
16
49
 
50
+ ### Task Mode (Debugging - Full Visibility)
17
51
  ```bash
18
52
  # Install and initialize
19
53
  npm install claude-flow-novice
20
54
  npx cfn-init
21
55
 
22
- # Initialize a swarm with skills
56
+ # Execute CFN Loop - Main Chat spawns Task() agents directly
57
+ /cfn-loop-task "Implement JWT authentication" --mode=standard
58
+
59
+ # Custom routing available for 5x cost reduction
60
+ /custom-routing-activate
61
+ ```
62
+
63
+ ### CLI Mode (Production - Cost Optimized)
64
+ ```bash
65
+ # Install and initialize
66
+ npm install claude-flow-novice
67
+ npx cfn-init
68
+
69
+ # Execute CFN Loop - Coordinator spawns CLI agents in background
70
+ /cfn-loop-cli "Implement JWT authentication" --mode=standard
71
+
72
+ # Initialize swarm with skills
23
73
  npx claude-flow-novice swarm "Task Description" \
24
74
  --skills=redis-coordination,agent-spawning \
25
75
  --strategy development
26
-
27
- # Execute CFN Loop with orchestration
28
- ./.claude/skills/redis-coordination/orchestrate-cfn-loop.sh \
29
- --task-id "unique-task-id" \
30
- --mode standard \
31
- --loop3-agents "researcher,backend-developer" \
32
- --loop2-agents "reviewer,tester"
33
76
  ```
34
77
 
35
78
  ## Documentation Index
@@ -37,6 +80,7 @@ npx claude-flow-novice swarm "Task Description" \
37
80
  ### Core Concepts
38
81
  - **[Skills System](log-skills.md)** - Modular, reusable agent capabilities
39
82
  - **[CFN Loop](cfn-loop-modes.md)** - Three-loop consensus validation framework
83
+ - **[CFN Loop Task Mode](claude-assets/commands/CFN_LOOP_TASK_MODE.md)** - Task execution guide with agent specialization
40
84
  - **[Redis Coordination](logs-cli-redis.md)** - Zero-token agent coordination
41
85
 
42
86
  ### User Guides
@@ -83,17 +127,24 @@ npx claude-flow-novice swarm "Task Description" \
83
127
  - **Adaptive Modes**: MVP (fast), Standard (balanced), Enterprise (rigorous)
84
128
 
85
129
  ### Cost Optimization
86
- - **CLI Spawning Mode**: 95-98% cost savings vs Task tool
87
- - **Configurable**: `COST_SAVINGS_MODE=yes` in CLAUDE.md
88
- - **Safe Default**: Task tool spawning when disabled
130
+ - **CLI Mode**: 64% savings vs Task mode ($0.054 vs $0.150/iteration)
131
+ - **Custom Routing**: Optional 5x reduction with Z.ai provider (95-98% total savings)
132
+ - **Mode-Aware Architecture**: Task Mode agents use clean exit, CLI Mode uses Redis coordination
133
+ - **Memory Safety**: ANTI-023 protection prevents memory leaks in Task Mode
89
134
 
90
135
  ## Architecture Principles
91
136
 
92
137
  1. **Skills-Based Coordination**: All agent communication via explicit Redis dependencies
93
138
  2. **Multi-Layer Enforcement**: Coordination primitives at technical, skill, agent, and system layers
94
139
  3. **Centralized Orchestration**: Keep orchestration in dedicated skills, not distributed across components
95
- 4. **Post-Edit Validation**: All Edit/Write operations trigger validation hooks
96
- 5. **Parallel Agent Spawning**: All Task-based coordinators require parallel spawning (single message, multiple Task calls)
140
+ 4. **Mode-Aware Architecture**: Task Mode (direct Task() spawning) vs CLI Mode (coordinator-driven)
141
+ 5. **Post-Edit Validation**: All Edit/Write operations trigger validation hooks
142
+ 6. **Parallel Agent Spawning**: All Task-based coordinators require parallel spawning (single message, multiple Task calls)
143
+
144
+ ### Mode-Agent Profile Specialization
145
+ - **Task Mode Agents**: Clean exit protocol, direct Main Chat communication, audit trail storage
146
+ - **CLI Mode Agents**: Redis coordination, completion signaling, background execution
147
+ - **Coordinators**: Enhanced monitoring with recovery capabilities, progress tracking
97
148
 
98
149
  ## Migration Notes
99
150
 
@@ -102,7 +153,13 @@ npx claude-flow-novice swarm "Task Description" \
102
153
  - Added: Skills system, Redis coordination, zero-token waiting, orchestrate-cfn-loop.sh
103
154
  - Breaking: CFN Loop now requires orchestrator (no manual Task spawning)
104
155
 
105
- See [CHANGELOG.md](CHANGELOG.md) for full migration guide.
156
+ **v2.14 Changes:**
157
+ - **Dual-Mode Architecture**: Task Mode (Main Chat Task() spawning) vs CLI Mode (coordinator-driven)
158
+ - **Custom Routing**: Z.ai integration for 5x cost reduction in CLI mode
159
+ - **Memory Safety**: ANTI-023 protection prevents memory leaks in Task Mode
160
+ - **Enhanced Coordinators**: Progress tracking, recovery capabilities, multi-layer enforcement
161
+
162
+ See [CHANGELOG.md](CHANGELOG.md) and [CFN Loop Task Mode Guide](claude-assets/commands/CFN_LOOP_TASK_MODE.md) for migration details.
106
163
 
107
164
  ## Support
108
165
 
@@ -0,0 +1,306 @@
1
+ #!/bin/bash
2
+
3
+ # Memory Leak Detection and Prevention Script
4
+ # Implements recommendations from memory leak analysis
5
+
6
+ set -euo pipefail
7
+
8
+ # Configuration
9
+ DEFAULT_MEMORY_LIMIT="8192" # 8GB limit instead of 16GB
10
+ DEFAULT_NODE_OPTIONS="--max-old-space-size=$DEFAULT_MEMORY_LIMIT"
11
+ PROFILING_DIR="/tmp/claude-memory-profiles"
12
+ LOG_FILE="/tmp/claude-memory-monitor.log"
13
+
14
+ # Colors for output
15
+ RED='\033[0;31m'
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ BLUE='\033[0;34m'
19
+ NC='\033[0m' # No Color
20
+
21
+ # Create profiling directory
22
+ mkdir -p "$PROFILING_DIR"
23
+
24
+ log() {
25
+ echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
26
+ }
27
+
28
+ show_help() {
29
+ cat << EOF
30
+ Memory Leak Detection and Prevention Tool
31
+
32
+ Usage: $0 [COMMAND] [OPTIONS]
33
+
34
+ Commands:
35
+ profile Start Claude with heap profiling enabled
36
+ monitor Monitor existing Claude process memory usage
37
+ limit Set memory limits for Claude sessions
38
+ install-tools Install strace and perf for WSL
39
+ analyze Analyze existing memory profiles
40
+ config Show current memory configuration
41
+
42
+ Options:
43
+ --limit MB Set memory limit in MB (default: 8192)
44
+ --pid PID Monitor specific process ID
45
+ --duration SEC Monitoring duration in seconds (default: 300)
46
+ --output DIR Output directory for profiles (default: /tmp/claude-memory-profiles)
47
+
48
+ Examples:
49
+ $0 profile --limit 6144 # Start Claude with 6GB limit and profiling
50
+ $0 monitor --pid 12345 --duration 600 # Monitor PID 12345 for 10 minutes
51
+ $0 install-tools # Install strace and perf
52
+ $0 analyze --output ./profiles # Analyze existing profiles
53
+ EOF
54
+ }
55
+
56
+ install_debug_tools() {
57
+ log "${BLUE}Installing strace and perf for debugging...${NC}"
58
+
59
+ if command -v apt-get &> /dev/null; then
60
+ sudo apt-get update
61
+ sudo apt-get install -y strace linux-tools-generic linux-perf
62
+ elif command -v yum &> /dev/null; then
63
+ sudo yum install -y strace perf
64
+ else
65
+ log "${RED}Unsupported package manager. Please install strace and perf manually.${NC}"
66
+ return 1
67
+ fi
68
+
69
+ # Configure perf for non-root users
70
+ echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid >/dev/null 2>&1 || true
71
+ echo 0 | sudo tee /proc/sys/kernel/kptr_restrict >/dev/null 2>&1 || true
72
+
73
+ log "${GREEN}Debug tools installed successfully${NC}"
74
+ }
75
+
76
+ start_with_profiling() {
77
+ local memory_limit=${1:-$DEFAULT_MEMORY_LIMIT}
78
+
79
+ log "${BLUE}Starting Claude with heap profiling and memory limit: ${memory_limit}MB${NC}"
80
+
81
+ # Set up environment for profiling
82
+ export NODE_OPTIONS="--max-old-space-size=$memory_limit --inspect=0.0.0.0:9229 --heap-prof"
83
+ export CLAUDE_MEMORY_PROFILE_DIR="$PROFILING_DIR"
84
+
85
+ # Create profile filename with timestamp
86
+ local profile_file="${PROFILING_DIR}/claude-profile-$(date +%Y%m%d-%H%M%S)"
87
+
88
+ log "${GREEN}Environment variables set:${NC}"
89
+ log " NODE_OPTIONS: $NODE_OPTIONS"
90
+ log " Profile directory: $PROFILING_DIR"
91
+ log "${YELLOW}Claude will start with debugging enabled on port 9229${NC}"
92
+ log "${YELLOW}Use Chrome DevTools or chrome://inspect to connect${NC}"
93
+
94
+ # Start Claude CLI with profiling
95
+ log "${BLUE}Starting Claude CLI...${NC}"
96
+ npx claude-flow-novice "$@"
97
+ }
98
+
99
+ monitor_memory() {
100
+ local target_pid=${1:-}
101
+ local duration=${2:-300}
102
+ local output_file="${PROFILING_DIR}/memory-monitor-$(date +%Y%m%d-%H%M%S).csv"
103
+
104
+ if [[ -z "$target_pid" ]]; then
105
+ log "${RED}Error: PID required for monitoring. Use --pid to specify.${NC}"
106
+ return 1
107
+ fi
108
+
109
+ log "${BLUE}Monitoring PID $target_pid for ${duration} seconds...${NC}"
110
+ log "Results will be saved to: $output_file"
111
+
112
+ # Create CSV header
113
+ echo "timestamp,pid,rss_mb,vms_mb,cpu_percent,open_files,connections" > "$output_file"
114
+
115
+ local start_time=$(date +%s)
116
+ local end_time=$((start_time + duration))
117
+
118
+ while [[ $(date +%s) -lt $end_time ]]; do
119
+ if ! kill -0 "$target_pid" 2>/dev/null; then
120
+ log "${RED}Process $target_pid is no longer running${NC}"
121
+ break
122
+ fi
123
+
124
+ local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
125
+ local stats=$(ps -p "$target_pid" -o pid,rss,vms,pcpu --no-headers 2>/dev/null || echo "")
126
+
127
+ if [[ -n "$stats" ]]; then
128
+ local rss_mb=$(echo "$stats" | awk '{print int($2/1024)}')
129
+ local vms_mb=$(echo "$stats" | awk '{print int($3/1024)}')
130
+ local cpu_percent=$(echo "$stats" | awk '{print $4}')
131
+
132
+ # Count open files and network connections
133
+ local open_files=$(lsof -p "$target_pid" 2>/dev/null | wc -l || echo "0")
134
+ local connections=$(netstat -p 2>/dev/null | grep "$target_pid/" | wc -l || echo "0")
135
+
136
+ echo "$timestamp,$target_pid,$rss_mb,$vms_mb,$cpu_percent,$open_files,$connections" >> "$output_file"
137
+
138
+ # Alert if memory exceeds threshold
139
+ if [[ $rss_mb -gt 8192 ]]; then
140
+ log "${RED}⚠️ High memory usage detected: ${rss_mb}MB RSS${NC}"
141
+ fi
142
+
143
+ log "Memory: ${rss_mb}MB RSS, ${vms_mb}MB VMS, CPU: ${cpu_percent}%, Files: $open_files, Connections: $connections"
144
+ fi
145
+
146
+ sleep 10
147
+ done
148
+
149
+ log "${GREEN}Monitoring completed. Data saved to: $output_file${NC}"
150
+ }
151
+
152
+ set_memory_limits() {
153
+ local limit_mb=${1:-8192}
154
+
155
+ log "${BLUE}Setting memory limits to ${limit_mb}MB...${NC}"
156
+
157
+ # Update shell configuration
158
+ local shell_rc="$HOME/.bashrc"
159
+ if [[ -f "$HOME/.zshrc" ]]; then
160
+ shell_rc="$HOME/.zshrc"
161
+ fi
162
+
163
+ # Remove existing NODE_OPTIONS lines
164
+ sed -i '/^export NODE_OPTIONS="--max-old-space-size=/d' "$shell_rc" 2>/dev/null || true
165
+
166
+ # Add new limit
167
+ echo "export NODE_OPTIONS=\"--max-old-space-size=$limit_mb\"" >> "$shell_rc"
168
+
169
+ log "${GREEN}Memory limit set to ${limit_mb}MB in $shell_rc${NC}"
170
+ log "${YELLOW}Restart your shell or run: source $shell_rc${NC}"
171
+ }
172
+
173
+ analyze_profiles() {
174
+ local profile_dir=${1:-$PROFILING_DIR}
175
+
176
+ log "${BLUE}Analyzing memory profiles in $profile_dir...${NC}"
177
+
178
+ if [[ ! -d "$profile_dir" ]]; then
179
+ log "${RED}Profile directory $profile_dir does not exist${NC}"
180
+ return 1
181
+ fi
182
+
183
+ # Find heap profile files
184
+ local heap_profiles=($(find "$profile_dir" -name "*.heapprofile" 2>/dev/null))
185
+
186
+ if [[ ${#heap_profiles[@]} -eq 0 ]]; then
187
+ log "${YELLOW}No heap profiles found in $profile_dir${NC}"
188
+ return 1
189
+ fi
190
+
191
+ log "${GREEN}Found ${#heap_profiles[@]} heap profile(s)${NC}"
192
+
193
+ for profile in "${heap_profiles[@]}"; do
194
+ log "${BLUE}Analyzing: $(basename "$profile")${NC}"
195
+
196
+ # Basic analysis - find top allocations
197
+ if command -v node &> /dev/null; then
198
+ echo "Top 10 allocations in $(basename "$profile"):" > "${profile}.analysis"
199
+ node -e "
200
+ const fs = require('fs');
201
+ const data = JSON.parse(fs.readFileSync('$profile', 'utf8'));
202
+ const allocations = data.heapProfile || data;
203
+ if (allocations && allocations.samples) {
204
+ allocations.samples
205
+ .sort((a, b) => b.size - a.size)
206
+ .slice(0, 10)
207
+ .forEach((sample, i) => {
208
+ console.log(\`\${i+1}. \${sample.functionName || 'unknown'}: \${(sample.size/1024/1024).toFixed(2)}MB\`);
209
+ });
210
+ }
211
+ " >> "${profile}.analysis"
212
+
213
+ log "${GREEN}Analysis saved to: ${profile}.analysis${NC}"
214
+ fi
215
+ done
216
+ }
217
+
218
+ show_config() {
219
+ log "${BLUE}Current Memory Configuration:${NC}"
220
+
221
+ # Show current NODE_OPTIONS
222
+ if [[ -n "${NODE_OPTIONS:-}" ]]; then
223
+ log " NODE_OPTIONS: $NODE_OPTIONS"
224
+ else
225
+ log " NODE_OPTIONS: (not set)"
226
+ fi
227
+
228
+ # Show current limits
229
+ local current_limit=$(echo "$NODE_OPTIONS" | grep -o 'max-old-space-size=[0-9]*' | cut -d'=' -f2 || echo "unlimited")
230
+ log " Memory limit: ${current_limit}MB"
231
+
232
+ # Show available memory
233
+ if command -v free &> /dev/null; then
234
+ local total_mem=$(free -m | awk 'NR==2{print $2}')
235
+ local available_mem=$(free -m | awk 'NR==2{print $7}')
236
+ log " System memory: ${available_mem}MB available / ${total_mem}MB total"
237
+ fi
238
+
239
+ # Show profile directory
240
+ log " Profile directory: $PROFILING_DIR"
241
+ log " Log file: $LOG_FILE"
242
+ }
243
+
244
+ # Parse command line arguments
245
+ case "${1:-}" in
246
+ "profile")
247
+ shift
248
+ local limit=$DEFAULT_MEMORY_LIMIT
249
+ while [[ $# -gt 0 ]]; do
250
+ case $1 in
251
+ --limit) limit="$2"; shift 2 ;;
252
+ *) shift ;;
253
+ esac
254
+ done
255
+ start_with_profiling "$limit"
256
+ ;;
257
+ "monitor")
258
+ shift
259
+ local pid=""
260
+ local duration=300
261
+ while [[ $# -gt 0 ]]; do
262
+ case $1 in
263
+ --pid) pid="$2"; shift 2 ;;
264
+ --duration) duration="$2"; shift 2 ;;
265
+ *) shift ;;
266
+ esac
267
+ done
268
+ monitor_memory "$pid" "$duration"
269
+ ;;
270
+ "limit")
271
+ shift
272
+ local limit=$DEFAULT_MEMORY_LIMIT
273
+ while [[ $# -gt 0 ]]; do
274
+ case $1 in
275
+ --limit) limit="$2"; shift 2 ;;
276
+ *) shift ;;
277
+ esac
278
+ done
279
+ set_memory_limits "$limit"
280
+ ;;
281
+ "install-tools")
282
+ install_debug_tools
283
+ ;;
284
+ "analyze")
285
+ shift
286
+ local dir=$PROFILING_DIR
287
+ while [[ $# -gt 0 ]]; do
288
+ case $1 in
289
+ --output) dir="$2"; shift 2 ;;
290
+ *) shift ;;
291
+ esac
292
+ done
293
+ analyze_profiles "$dir"
294
+ ;;
295
+ "config")
296
+ show_config
297
+ ;;
298
+ "help"|"-h"|"--help")
299
+ show_help
300
+ ;;
301
+ *)
302
+ log "${RED}Unknown command: ${1:-}${NC}"
303
+ show_help
304
+ exit 1
305
+ ;;
306
+ esac