claude-flow 2.5.0-alpha.139 → 2.7.0-alpha

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 (171) hide show
  1. package/.claude/agents/reasoning/README.md +171 -0
  2. package/.claude/agents/reasoning/agent.md +816 -0
  3. package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
  4. package/.claude/agents/reasoning/goal-planner.md +73 -0
  5. package/.claude/settings.json +2 -1
  6. package/.claude/sparc-modes.json +108 -0
  7. package/README.md +45 -55
  8. package/bin/claude-flow +1 -1
  9. package/dist/src/cli/command-registry.js +70 -6
  10. package/dist/src/cli/command-registry.js.map +1 -1
  11. package/dist/src/cli/commands/hive-mind/pause.js +2 -9
  12. package/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
  13. package/dist/src/cli/commands/index.js +1 -114
  14. package/dist/src/cli/commands/index.js.map +1 -1
  15. package/dist/src/cli/commands/swarm-spawn.js +5 -33
  16. package/dist/src/cli/commands/swarm-spawn.js.map +1 -1
  17. package/dist/src/cli/help-formatter.js +0 -3
  18. package/dist/src/cli/help-formatter.js.map +1 -1
  19. package/dist/src/cli/help-text.js +69 -7
  20. package/dist/src/cli/help-text.js.map +1 -1
  21. package/dist/src/cli/simple-cli.js +182 -172
  22. package/dist/src/cli/simple-cli.js.map +1 -1
  23. package/dist/src/cli/simple-commands/agent-booster.js +415 -0
  24. package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
  25. package/dist/src/cli/simple-commands/agent.js +856 -13
  26. package/dist/src/cli/simple-commands/agent.js.map +1 -1
  27. package/dist/src/cli/simple-commands/env-template.js +180 -0
  28. package/dist/src/cli/simple-commands/env-template.js.map +1 -0
  29. package/dist/src/cli/simple-commands/hooks.js +233 -0
  30. package/dist/src/cli/simple-commands/hooks.js.map +1 -1
  31. package/dist/src/cli/simple-commands/init/help.js +23 -0
  32. package/dist/src/cli/simple-commands/init/help.js.map +1 -1
  33. package/dist/src/cli/simple-commands/init/index.js +63 -0
  34. package/dist/src/cli/simple-commands/init/index.js.map +1 -1
  35. package/dist/src/cli/simple-commands/memory.js +307 -16
  36. package/dist/src/cli/simple-commands/memory.js.map +1 -1
  37. package/dist/src/cli/simple-commands/proxy.js +304 -0
  38. package/dist/src/cli/simple-commands/proxy.js.map +1 -0
  39. package/dist/src/cli/simple-commands/sparc.js +16 -19
  40. package/dist/src/cli/simple-commands/sparc.js.map +1 -1
  41. package/dist/src/cli/validation-helper.js.map +1 -1
  42. package/dist/src/execution/agent-executor.js +181 -0
  43. package/dist/src/execution/agent-executor.js.map +1 -0
  44. package/dist/src/execution/index.js +12 -0
  45. package/dist/src/execution/index.js.map +1 -0
  46. package/dist/src/execution/provider-manager.js +110 -0
  47. package/dist/src/execution/provider-manager.js.map +1 -0
  48. package/dist/src/hooks/index.js +0 -3
  49. package/dist/src/hooks/index.js.map +1 -1
  50. package/dist/src/hooks/redaction-hook.js +89 -0
  51. package/dist/src/hooks/redaction-hook.js.map +1 -0
  52. package/dist/src/mcp/claude-flow-tools.js +205 -150
  53. package/dist/src/mcp/claude-flow-tools.js.map +1 -1
  54. package/dist/src/mcp/mcp-server.js +125 -0
  55. package/dist/src/mcp/mcp-server.js.map +1 -1
  56. package/dist/src/sdk/query-control.js +293 -139
  57. package/dist/src/sdk/query-control.js.map +1 -1
  58. package/dist/src/sdk/session-forking.js +206 -129
  59. package/dist/src/sdk/session-forking.js.map +1 -1
  60. package/dist/src/utils/key-redactor.js +108 -0
  61. package/dist/src/utils/key-redactor.js.map +1 -0
  62. package/dist/src/utils/metrics-reader.js +37 -39
  63. package/dist/src/utils/metrics-reader.js.map +1 -1
  64. package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
  65. package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
  66. package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
  67. package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
  68. package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
  69. package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
  70. package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
  71. package/docs/COMMIT_SUMMARY.md +247 -0
  72. package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
  73. package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
  74. package/docs/ENV-SETUP-GUIDE.md +270 -0
  75. package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
  76. package/docs/FINAL_VALIDATION_REPORT.md +165 -0
  77. package/docs/HOOKS-V2-MODIFICATION.md +146 -0
  78. package/docs/INDEX.md +568 -0
  79. package/docs/INTEGRATION_COMPLETE.md +414 -0
  80. package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
  81. package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
  82. package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
  83. package/docs/README.md +35 -0
  84. package/docs/REASONING-AGENTS.md +482 -0
  85. package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
  86. package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
  87. package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
  88. package/docs/REASONINGBANK-BENCHMARK.md +396 -0
  89. package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
  90. package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
  91. package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
  92. package/docs/REASONINGBANK-DEMO.md +419 -0
  93. package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
  94. package/docs/REASONINGBANK-VALIDATION.md +532 -0
  95. package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
  96. package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
  97. package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
  98. package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
  99. package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
  100. package/docs/api/API_DOCUMENTATION.md +721 -0
  101. package/docs/architecture/ARCHITECTURE.md +1690 -0
  102. package/docs/ci-cd/README.md +368 -0
  103. package/docs/development/DEPLOYMENT.md +2348 -0
  104. package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
  105. package/docs/development/build-analysis-report.md +252 -0
  106. package/docs/development/pair-optimization.md +156 -0
  107. package/docs/development/token-tracking-status.md +103 -0
  108. package/docs/development/training-pipeline-demo.md +163 -0
  109. package/docs/development/training-pipeline-real-only.md +196 -0
  110. package/docs/epic-sdk-integration.md +1269 -0
  111. package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
  112. package/docs/experimental/computational_verification.py +436 -0
  113. package/docs/experimental/novel_approaches.md +560 -0
  114. package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
  115. package/docs/experimental/riemann_proof_attempt.md +124 -0
  116. package/docs/experimental/riemann_synthesis.md +277 -0
  117. package/docs/experimental/verification_results.json +12 -0
  118. package/docs/experimental/visualization_insights.md +720 -0
  119. package/docs/guides/USER_GUIDE.md +1138 -0
  120. package/docs/guides/token-tracking-guide.md +291 -0
  121. package/docs/reference/AGENTS.md +1011 -0
  122. package/docs/reference/MCP_TOOLS.md +2188 -0
  123. package/docs/reference/SPARC.md +717 -0
  124. package/docs/reference/SWARM.md +2000 -0
  125. package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
  126. package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
  127. package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
  128. package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
  129. package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
  130. package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
  131. package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
  132. package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
  133. package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
  134. package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
  135. package/docs/sdk/epic-sdk-integration.md +1269 -0
  136. package/docs/setup/remote-setup.md +93 -0
  137. package/docs/validation/final-validation-summary.md +220 -0
  138. package/docs/validation/verification-integration.md +190 -0
  139. package/docs/validation/verification-validation.md +349 -0
  140. package/docs/wiki/background-commands.md +1213 -0
  141. package/docs/wiki/session-persistence.md +342 -0
  142. package/docs/wiki/stream-chain-command.md +537 -0
  143. package/package.json +4 -2
  144. package/src/cli/command-registry.js +70 -5
  145. package/src/cli/commands/hive-mind/pause.ts +2 -15
  146. package/src/cli/commands/index.ts +1 -84
  147. package/src/cli/commands/swarm-spawn.ts +3 -47
  148. package/src/cli/help-text.js +42 -7
  149. package/src/cli/simple-cli.ts +18 -8
  150. package/src/cli/simple-commands/agent-booster.js +515 -0
  151. package/src/cli/simple-commands/agent.js +1001 -12
  152. package/src/cli/simple-commands/agent.ts +137 -0
  153. package/src/cli/simple-commands/config.ts +127 -0
  154. package/src/cli/simple-commands/env-template.js +190 -0
  155. package/src/cli/simple-commands/hooks.js +310 -0
  156. package/src/cli/simple-commands/init/help.js +23 -0
  157. package/src/cli/simple-commands/init/index.js +84 -6
  158. package/src/cli/simple-commands/memory.js +363 -16
  159. package/src/cli/simple-commands/proxy.js +384 -0
  160. package/src/cli/simple-commands/sparc.js +16 -19
  161. package/src/execution/agent-executor.ts +306 -0
  162. package/src/execution/index.ts +19 -0
  163. package/src/execution/provider-manager.ts +187 -0
  164. package/src/hooks/index.ts +0 -5
  165. package/src/hooks/redaction-hook.ts +115 -0
  166. package/src/mcp/claude-flow-tools.ts +203 -120
  167. package/src/mcp/mcp-server.js +86 -0
  168. package/src/sdk/query-control.ts +377 -223
  169. package/src/sdk/session-forking.ts +312 -207
  170. package/src/utils/key-redactor.js +178 -0
  171. package/src/utils/key-redactor.ts +184 -0
@@ -86,6 +86,17 @@ export async function hooksAction(subArgs, flags) {
86
86
  await notifyCommand(subArgs, flags);
87
87
  break;
88
88
 
89
+ // NEW: PreToolUse Modification Hooks (v2.0.10+)
90
+ case 'modify-bash':
91
+ await modifyBashCommand(subArgs, flags);
92
+ break;
93
+ case 'modify-file':
94
+ await modifyFileCommand(subArgs, flags);
95
+ break;
96
+ case 'modify-git-commit':
97
+ await modifyGitCommitCommand(subArgs, flags);
98
+ break;
99
+
89
100
  default:
90
101
  printError(`Unknown hooks command: ${subcommand}`);
91
102
  showHooksHelp();
@@ -1155,6 +1166,282 @@ async function notifyCommand(subArgs, flags) {
1155
1166
  }
1156
1167
  }
1157
1168
 
1169
+ // ===== PRETOOLUSE MODIFICATION HOOKS (v2.0.10+) =====
1170
+
1171
+ async function modifyBashCommand(subArgs, flags) {
1172
+ // Read JSON from stdin with timeout to detect if data is piped
1173
+ let input = '';
1174
+ let hasInput = false;
1175
+
1176
+ const timeout = setTimeout(() => {
1177
+ if (!hasInput) {
1178
+ console.log('Usage: echo \'{"tool_input":{"command":"your command"}}\' | claude-flow hooks modify-bash');
1179
+ console.log('\nThis hook reads JSON from stdin and outputs modified JSON.');
1180
+ console.log('It is designed for use with Claude Code v2.0.10+ PreToolUse feature.');
1181
+ console.log('\nExample:');
1182
+ console.log(' echo \'{"tool_input":{"command":"rm test.txt"}}\' | claude-flow hooks modify-bash');
1183
+ process.exit(0);
1184
+ }
1185
+ }, 100); // 100ms timeout
1186
+
1187
+ for await (const chunk of process.stdin) {
1188
+ hasInput = true;
1189
+ clearTimeout(timeout);
1190
+ input += chunk;
1191
+ }
1192
+
1193
+ if (!input.trim()) {
1194
+ return; // Silently exit if no input
1195
+ }
1196
+
1197
+ const toolInput = JSON.parse(input);
1198
+ const command = toolInput.tool_input?.command || '';
1199
+
1200
+ if (!command) {
1201
+ console.log(input); // Pass through if no command
1202
+ return;
1203
+ }
1204
+
1205
+ let modifiedCommand = command;
1206
+ const notes = [];
1207
+
1208
+ // 1. Safety: Add -i flag to rm commands
1209
+ if (/^rm\s/.test(command) && !/-[iI]/.test(command)) {
1210
+ modifiedCommand = command.replace(/^rm /, 'rm -i ');
1211
+ notes.push('[Safety: Added -i flag for interactive confirmation]');
1212
+ }
1213
+
1214
+ // 2. Aliases
1215
+ if (/^ll(\s|$)/.test(command)) {
1216
+ modifiedCommand = command.replace(/^ll/, 'ls -lah');
1217
+ notes.push('[Alias: ll → ls -lah]');
1218
+ } else if (/^la(\s|$)/.test(command)) {
1219
+ modifiedCommand = command.replace(/^la/, 'ls -la');
1220
+ notes.push('[Alias: la → ls -la]');
1221
+ }
1222
+
1223
+ // 3. Path correction: Redirect test files to /tmp
1224
+ if (/>\s*test.*\.(txt|log|tmp|json|md)/.test(command) && !/\/tmp\//.test(command)) {
1225
+ modifiedCommand = command.replace(/>\s*(test[^/]*\.(txt|log|tmp|json|md))/, '> /tmp/$1');
1226
+ notes.push('[Path: Redirected test file to /tmp/]');
1227
+ }
1228
+
1229
+ // 4. Secret detection
1230
+ if (/(password|secret|token|api[-_]?key|auth)/i.test(command) && !/#\s*SECRETS_OK/.test(command)) {
1231
+ notes.push('[Security: Command contains sensitive keywords. Add "# SECRETS_OK" to bypass]');
1232
+ }
1233
+
1234
+ // Output modified JSON
1235
+ const output = {
1236
+ ...toolInput,
1237
+ tool_input: {
1238
+ ...toolInput.tool_input,
1239
+ command: modifiedCommand,
1240
+ },
1241
+ };
1242
+
1243
+ if (notes.length > 0) {
1244
+ output.modification_notes = notes.join(' ');
1245
+ }
1246
+
1247
+ console.log(JSON.stringify(output, null, 2));
1248
+ }
1249
+
1250
+ async function modifyFileCommand(subArgs, flags) {
1251
+ // Read JSON from stdin with timeout to detect if data is piped
1252
+ let input = '';
1253
+ let hasInput = false;
1254
+
1255
+ const timeout = setTimeout(() => {
1256
+ if (!hasInput) {
1257
+ console.log('Usage: echo \'{"tool_input":{"file_path":"your/file.js"}}\' | claude-flow hooks modify-file');
1258
+ console.log('\nThis hook reads JSON from stdin and outputs modified JSON.');
1259
+ console.log('It is designed for use with Claude Code v2.0.10+ PreToolUse feature.');
1260
+ console.log('\nExample:');
1261
+ console.log(' echo \'{"tool_input":{"file_path":"test.js"}}\' | claude-flow hooks modify-file');
1262
+ process.exit(0);
1263
+ }
1264
+ }, 100); // 100ms timeout
1265
+
1266
+ for await (const chunk of process.stdin) {
1267
+ hasInput = true;
1268
+ clearTimeout(timeout);
1269
+ input += chunk;
1270
+ }
1271
+
1272
+ if (!input.trim()) {
1273
+ return; // Silently exit if no input
1274
+ }
1275
+
1276
+ const toolInput = JSON.parse(input);
1277
+ const filePath = toolInput.tool_input?.file_path || toolInput.tool_input?.path || '';
1278
+
1279
+ if (!filePath) {
1280
+ console.log(input); // Pass through if no file path
1281
+ return;
1282
+ }
1283
+
1284
+ let modifiedPath = filePath;
1285
+ let shouldModify = false;
1286
+ const notes = [];
1287
+
1288
+ // 1. Root folder protection
1289
+ const isRootFile = /^[^/]*\.(js|ts|jsx|tsx|py|java|go|rs|cpp|c|h)$/.test(filePath) ||
1290
+ /^test.*\.(txt|log|tmp|json|md)$/.test(filePath) ||
1291
+ /^(temp|tmp|working)/.test(filePath);
1292
+
1293
+ if (isRootFile) {
1294
+ if (/test.*\.(test|spec)\.|\.test\.|\.spec\./.test(filePath)) {
1295
+ modifiedPath = `tests/${filePath}`;
1296
+ shouldModify = true;
1297
+ notes.push('[Organization: Moved test file to /tests/]');
1298
+ } else if (/test.*\.md|temp.*\.md|working.*\.md|scratch.*\.md/.test(filePath)) {
1299
+ modifiedPath = `docs/working/${filePath}`;
1300
+ shouldModify = true;
1301
+ notes.push('[Organization: Moved working document to /docs/working/]');
1302
+ } else if (/\.(js|ts|jsx|tsx|py)$/.test(filePath)) {
1303
+ modifiedPath = `src/${filePath}`;
1304
+ shouldModify = true;
1305
+ notes.push('[Organization: Moved source file to /src/]');
1306
+ } else if (/^(temp|tmp|scratch)/.test(filePath)) {
1307
+ modifiedPath = `/tmp/${filePath}`;
1308
+ shouldModify = true;
1309
+ notes.push('[Organization: Redirected temporary file to /tmp/]');
1310
+ }
1311
+ }
1312
+
1313
+ // 2. Format hints
1314
+ if (/\.(ts|tsx|js|jsx)$/.test(modifiedPath)) {
1315
+ notes.push('[Tip: Auto-format with Prettier/ESLint recommended]');
1316
+ } else if (/\.py$/.test(modifiedPath)) {
1317
+ notes.push('[Tip: Auto-format with Black/autopep8 recommended]');
1318
+ }
1319
+
1320
+ // Output modified JSON
1321
+ const output = {
1322
+ ...toolInput,
1323
+ tool_input: {
1324
+ ...toolInput.tool_input,
1325
+ },
1326
+ };
1327
+
1328
+ if (shouldModify) {
1329
+ if (toolInput.tool_input.file_path) {
1330
+ output.tool_input.file_path = modifiedPath;
1331
+ } else {
1332
+ output.tool_input.path = modifiedPath;
1333
+ }
1334
+ }
1335
+
1336
+ if (notes.length > 0) {
1337
+ output.modification_notes = notes.join(' ');
1338
+ }
1339
+
1340
+ console.log(JSON.stringify(output, null, 2));
1341
+ }
1342
+
1343
+ async function modifyGitCommitCommand(subArgs, flags) {
1344
+ // Read JSON from stdin with timeout to detect if data is piped
1345
+ let input = '';
1346
+ let hasInput = false;
1347
+
1348
+ const timeout = setTimeout(() => {
1349
+ if (!hasInput) {
1350
+ console.log('Usage: echo \'{"tool_input":{"command":"git commit -m \\"message\\""}}\' | claude-flow hooks modify-git-commit');
1351
+ console.log('\nThis hook reads JSON from stdin and outputs modified JSON.');
1352
+ console.log('It is designed for use with Claude Code v2.0.10+ PreToolUse feature.');
1353
+ console.log('\nExample:');
1354
+ console.log(' echo \'{"tool_input":{"command":"git commit -m \\"fix bug\\""}}\' | claude-flow hooks modify-git-commit');
1355
+ process.exit(0);
1356
+ }
1357
+ }, 100); // 100ms timeout
1358
+
1359
+ for await (const chunk of process.stdin) {
1360
+ hasInput = true;
1361
+ clearTimeout(timeout);
1362
+ input += chunk;
1363
+ }
1364
+
1365
+ if (!input.trim()) {
1366
+ return; // Silently exit if no input
1367
+ }
1368
+
1369
+ const toolInput = JSON.parse(input);
1370
+ const command = toolInput.tool_input?.command || '';
1371
+
1372
+ if (!command || !/git commit/.test(command)) {
1373
+ console.log(input); // Pass through if not git commit
1374
+ return;
1375
+ }
1376
+
1377
+ // Extract commit message
1378
+ const msgMatch = command.match(/-m\s+["']([^"']+)["']/) || command.match(/-m\s+(\S+)/);
1379
+ const commitMsg = msgMatch ? msgMatch[1] : '';
1380
+
1381
+ if (!commitMsg || /^\[(feat|fix|docs|style|refactor|test|chore|perf)\]/.test(commitMsg)) {
1382
+ console.log(input); // Already formatted or no message
1383
+ return;
1384
+ }
1385
+
1386
+ const notes = [];
1387
+
1388
+ // Get current branch
1389
+ let branch = 'main';
1390
+ let ticket = '';
1391
+ try {
1392
+ const { execSync } = await import('child_process');
1393
+ branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();
1394
+
1395
+ // Extract JIRA ticket
1396
+ const ticketMatch = branch.match(/[A-Z]+-[0-9]+/);
1397
+ if (ticketMatch) {
1398
+ ticket = ticketMatch[0];
1399
+ }
1400
+ } catch {
1401
+ // Git not available, continue
1402
+ }
1403
+
1404
+ // Detect conventional commit type
1405
+ let type = 'chore';
1406
+ if (/^(add|implement|create|new)/i.test(commitMsg)) type = 'feat';
1407
+ else if (/^(fix|resolve|patch|correct)/i.test(commitMsg)) type = 'fix';
1408
+ else if (/^(update|modify|change|improve)/i.test(commitMsg)) type = 'refactor';
1409
+ else if (/^(doc|documentation|readme)/i.test(commitMsg)) type = 'docs';
1410
+ else if (/^(test|testing|spec)/i.test(commitMsg)) type = 'test';
1411
+ else if (/^(style|format|lint)/i.test(commitMsg)) type = 'style';
1412
+ else if (/^(perf|optimize|speed)/i.test(commitMsg)) type = 'perf';
1413
+
1414
+ // Format message
1415
+ let formattedMsg = ticket
1416
+ ? `[${type}] ${commitMsg} (${ticket})`
1417
+ : `[${type}] ${commitMsg}`;
1418
+
1419
+ // Add co-author
1420
+ if (!/Co-Authored-By/.test(command)) {
1421
+ formattedMsg += `\n\nšŸ¤– Generated with Claude Flow\nCo-Authored-By: claude-flow <noreply@ruv.io>`;
1422
+ }
1423
+
1424
+ // Replace message in command
1425
+ const modifiedCommand = command.replace(
1426
+ /-m\s+["'][^"']+["']|-m\s+\S+/,
1427
+ `-m "$(cat <<'EOF'\n${formattedMsg}\nEOF\n)"`
1428
+ );
1429
+
1430
+ notes.push(`[Auto-formatted: ${type} type${ticket ? ` + ${ticket}` : ''}]`);
1431
+
1432
+ // Output modified JSON
1433
+ const output = {
1434
+ ...toolInput,
1435
+ tool_input: {
1436
+ ...toolInput.tool_input,
1437
+ command: modifiedCommand,
1438
+ },
1439
+ modification_notes: notes.join(' '),
1440
+ };
1441
+
1442
+ console.log(JSON.stringify(output, null, 2));
1443
+ }
1444
+
1158
1445
  function showHooksHelp() {
1159
1446
  console.log('Claude Flow Hooks (with .swarm/memory.db persistence):\n');
1160
1447
 
@@ -1194,6 +1481,23 @@ function showHooksHelp() {
1194
1481
  console.log(' session-restore Load previous session state');
1195
1482
  console.log(' notify Custom notifications');
1196
1483
 
1484
+ console.log('\n===== NEW: PreToolUse Modification Hooks (v2.0.10+) =====');
1485
+ console.log(' modify-bash Modify Bash tool inputs (reads/writes JSON via stdin/stdout)');
1486
+ console.log(' • Safety: Adds -i flag to rm commands');
1487
+ console.log(' • Aliases: ll → ls -lah, la → ls -la');
1488
+ console.log(' • Path correction: Redirects test files to /tmp');
1489
+ console.log(' • Secret detection: Warns about sensitive keywords');
1490
+ console.log('');
1491
+ console.log(' modify-file Modify Write/Edit tool inputs (reads/writes JSON via stdin/stdout)');
1492
+ console.log(' • Root folder protection: Moves files to appropriate directories');
1493
+ console.log(' • Organization: Tests → /tests/, Sources → /src/, Docs → /docs/');
1494
+ console.log(' • Format hints: Suggests Prettier, Black, etc.');
1495
+ console.log('');
1496
+ console.log(' modify-git-commit Modify git commit messages (reads/writes JSON via stdin/stdout)');
1497
+ console.log(' • Conventional commits: Auto-adds [feat], [fix], [docs], etc.');
1498
+ console.log(' • Ticket extraction: Extracts JIRA tickets from branch names');
1499
+ console.log(' • Co-author: Adds Claude Flow co-author footer');
1500
+
1197
1501
  console.log('\nExamples:');
1198
1502
  console.log(' hooks pre-command --command "npm test" --validate-safety true');
1199
1503
  console.log(' hooks pre-edit --file "src/app.js" --auto-assign-agents true');
@@ -1202,12 +1506,18 @@ function showHooksHelp() {
1202
1506
  console.log(' hooks session-end --generate-summary true --export-metrics true');
1203
1507
  console.log(' hooks agent-spawned --name "CodeReviewer" --type "reviewer"');
1204
1508
  console.log(' hooks notify --message "Build completed" --level "success"');
1509
+ console.log('');
1510
+ console.log(' # New modification hooks (stdin/stdout JSON):');
1511
+ console.log(' echo \'{"tool_input":{"command":"rm test.txt"}}\' | hooks modify-bash');
1512
+ console.log(' echo \'{"tool_input":{"file_path":"test.js"}}\' | hooks modify-file');
1513
+ console.log(' echo \'{"tool_input":{"command":"git commit -m \\"fix bug\\""}}\' | hooks modify-git-commit');
1205
1514
 
1206
1515
  console.log('\nCompatibility:');
1207
1516
  console.log(' • pre-command and pre-bash are aliases');
1208
1517
  console.log(' • post-command and post-bash are aliases');
1209
1518
  console.log(' • Both --dash-case and camelCase parameters supported');
1210
1519
  console.log(' • All parameters from settings.json template supported');
1520
+ console.log(' • New modification hooks work with Claude Code v2.0.10+ PreToolUse feature');
1211
1521
  }
1212
1522
 
1213
1523
  export default hooksAction;
@@ -14,6 +14,19 @@ export function showInitHelp() {
14
14
  console.log(' --dry-run, -d Preview what would be created without making changes');
15
15
  console.log(' --help, -h Show this help message');
16
16
  console.log();
17
+ console.log('Environment Configuration:');
18
+ console.log(' --env Generate .env template for API keys');
19
+ console.log(' • Required for ReasoningBank memory');
20
+ console.log(' • Includes setup instructions');
21
+ console.log(' • Cost optimization guide');
22
+ console.log();
23
+ console.log('Specialized Agent Setup:');
24
+ console.log(' --agent reasoning Setup ReasoningBank agents with closed-loop learning');
25
+ console.log(' Includes goal-planner and sublinear-goal-planner agents');
26
+ console.log(' • +26% success rate (70% → 88%)');
27
+ console.log(' • -25% token usage (cost savings)');
28
+ console.log(' • 3.2x learning velocity (faster improvement)');
29
+ console.log();
17
30
  console.log('Alternative Initialization Modes:');
18
31
  console.log(' --basic Use basic initialization (pre-v2.0.0 behavior)');
19
32
  console.log(' --sparc, -s Initialize with SPARC development environment');
@@ -44,6 +57,10 @@ export function showInitHelp() {
44
57
  console.log(' --validate --skip-mode-test Skip SPARC mode testing');
45
58
  console.log();
46
59
  console.log('Examples:');
60
+ console.log('šŸ“‹ ENVIRONMENT SETUP:');
61
+ console.log(' claude-flow init --env # Generate .env template');
62
+ console.log(' claude-flow init --env --force # Overwrite existing .env');
63
+ console.log();
47
64
  console.log('🌊 CLAUDE FLOW v2.0.0 (DEFAULT):');
48
65
  console.log(' claude-flow init # ⭐ DEFAULT: Full Claude Flow v2.0.0 setup');
49
66
  console.log(' claude-flow init --force # Overwrite existing configuration');
@@ -60,6 +77,12 @@ export function showInitHelp() {
60
77
  console.log(' claude-flow init --dry-run --sparc # Preview initialization');
61
78
  console.log(' claude-flow init --minimal # Minimal setup');
62
79
  console.log();
80
+ console.log('🧠 REASONING AGENTS WITH REASONINGBANK:');
81
+ console.log(' claude-flow init --agent reasoning # Setup ReasoningBank agents');
82
+ console.log(' claude-flow init --agent reasoning --force # Overwrite existing setup');
83
+ console.log(' # Note: Requires .env with API keys for actual learning');
84
+ console.log(' # Use: npx agentic-flow --agent goal-planner --task "your task"');
85
+ console.log();
63
86
  console.log('šŸ” VERIFICATION & PAIR PROGRAMMING:');
64
87
  console.log(' claude-flow init --verify # Truth Verification System setup');
65
88
  console.log(' claude-flow init --pair # Pair Programming mode setup');
@@ -340,10 +340,34 @@ export async function initCommand(subArgs, flags) {
340
340
  return;
341
341
  }
342
342
 
343
+ // Handle --env flag for .env template generation
344
+ if (flags.env || subArgs.includes('--env')) {
345
+ const { generateEnvTemplate } = await import('../env-template.js');
346
+ const workingDir = process.env.PWD || process.cwd();
347
+ const force = flags.force || flags.f;
348
+
349
+ console.log('šŸ“‹ Generating .env template file...\n');
350
+ const result = await generateEnvTemplate(workingDir, force);
351
+
352
+ if (result.created) {
353
+ console.log('\nšŸ“š Next steps:');
354
+ console.log('1. Open .env file and add your API keys');
355
+ console.log('2. Get keys from:');
356
+ console.log(' • Anthropic: https://console.anthropic.com/settings/keys');
357
+ console.log(' • OpenRouter: https://openrouter.ai/keys');
358
+ console.log('3. Enable memory: claude-flow agent run coder "task" --enable-memory\n');
359
+ console.log('šŸ’” See docs/REASONINGBANK-COST-OPTIMIZATION.md for cost savings tips');
360
+ } else if (result.exists) {
361
+ console.log('šŸ’” To overwrite: claude-flow init --env --force');
362
+ }
363
+
364
+ return;
365
+ }
366
+
343
367
  // Check for verification flags first
344
- const hasVerificationFlags = subArgs.includes('--verify') || subArgs.includes('--pair') ||
368
+ const hasVerificationFlags = subArgs.includes('--verify') || subArgs.includes('--pair') ||
345
369
  flags.verify || flags.pair;
346
-
370
+
347
371
  // Handle Flow Nexus minimal init
348
372
  if (flags['flow-nexus']) {
349
373
  return await flowNexusMinimalInit(flags, subArgs);
@@ -1299,6 +1323,10 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) {
1299
1323
  const dryRun = flags.dryRun || flags['dry-run'] || flags.d;
1300
1324
  const initSparc = flags.roo || (subArgs && subArgs.includes('--roo')); // SPARC only with --roo flag
1301
1325
 
1326
+ // Parse --agent flag for specialized agent setup
1327
+ const agentType = flags.agent || (subArgs && subArgs.find(arg => arg.startsWith('--agent='))?.split('=')[1]);
1328
+ const initReasoning = agentType === 'reasoning' || (subArgs && subArgs.includes('--agent') && subArgs.includes('reasoning'));
1329
+
1302
1330
  // Store parameters to avoid scope issues in async context
1303
1331
  const args = subArgs || [];
1304
1332
  const options = flags || {};
@@ -1668,29 +1696,79 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
1668
1696
  force: force,
1669
1697
  dryRun: dryRun
1670
1698
  });
1671
-
1699
+
1672
1700
  if (agentResult.success) {
1673
1701
  await validateAgentSystem(workingDir);
1674
-
1702
+
1675
1703
  // Copy command files including Flow Nexus commands
1676
1704
  console.log('\nšŸ“š Setting up command system...');
1677
1705
  const commandResult = await copyCommandFiles(workingDir, {
1678
1706
  force: force,
1679
1707
  dryRun: dryRun
1680
1708
  });
1681
-
1709
+
1682
1710
  if (commandResult.success) {
1683
1711
  console.log('āœ… āœ“ Command system setup complete with Flow Nexus integration');
1684
1712
  } else {
1685
1713
  console.log('āš ļø Command system setup failed:', commandResult.error);
1686
1714
  }
1687
-
1715
+
1688
1716
  console.log('āœ… āœ“ Agent system setup complete with 64 specialized agents');
1689
1717
  } else {
1690
1718
  console.log('āš ļø Agent system setup failed:', agentResult.error);
1691
1719
  }
1720
+
1721
+ // Setup reasoning agents if --agent reasoning flag is used
1722
+ if (initReasoning) {
1723
+ console.log('\n🧠 Setting up reasoning agents with ReasoningBank integration...');
1724
+ try {
1725
+ const reasoningAgentsDir = `${workingDir}/.claude/agents/reasoning`;
1726
+ await fs.mkdir(reasoningAgentsDir, { recursive: true });
1727
+
1728
+ // Import path module
1729
+ const path = await import('path');
1730
+ const { fileURLToPath } = await import('url');
1731
+ const { dirname, join } = path.default;
1732
+
1733
+ // Get the source reasoning agents directory
1734
+ const __filename = fileURLToPath(import.meta.url);
1735
+ const __dirname = dirname(__filename);
1736
+ const sourceReasoningDir = join(__dirname, '../../../../.claude/agents/reasoning');
1737
+
1738
+ // Copy reasoning agent files
1739
+ try {
1740
+ const reasoningFiles = await fs.readdir(sourceReasoningDir);
1741
+ let copiedReasoningAgents = 0;
1742
+
1743
+ for (const file of reasoningFiles) {
1744
+ if (file.endsWith('.md')) {
1745
+ const sourcePath = join(sourceReasoningDir, file);
1746
+ const destPath = join(reasoningAgentsDir, file);
1747
+ const content = await fs.readFile(sourcePath, 'utf8');
1748
+ await fs.writeFile(destPath, content);
1749
+ copiedReasoningAgents++;
1750
+ }
1751
+ }
1752
+
1753
+ printSuccess(`āœ“ Copied ${copiedReasoningAgents} reasoning agent files`);
1754
+ console.log(' šŸ“š Reasoning agents available:');
1755
+ console.log(' • goal-planner - Goal-Oriented Action Planning specialist');
1756
+ console.log(' • sublinear-goal-planner - Sub-linear complexity goal planning');
1757
+ console.log(' šŸ’” Use: npx agentic-flow --agent goal-planner --task "your task"');
1758
+ console.log(' šŸ“– Documentation: .claude/agents/reasoning/README.md');
1759
+ } catch (err) {
1760
+ console.log(` āš ļø Could not copy reasoning agents: ${err.message}`);
1761
+ console.log(' Reasoning agents may not be available yet');
1762
+ }
1763
+ } catch (err) {
1764
+ console.log(` āš ļø Reasoning agent setup failed: ${err.message}`);
1765
+ }
1766
+ }
1692
1767
  } else {
1693
1768
  console.log(' [DRY RUN] Would create agent system with 64 specialized agents');
1769
+ if (initReasoning) {
1770
+ console.log(' [DRY RUN] Would also setup reasoning agents with ReasoningBank integration');
1771
+ }
1694
1772
  }
1695
1773
 
1696
1774
  // Optional: Setup monitoring and telemetry