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: Edit /workspaces/claude-code-flow/src/cli/simple-commands/analysis.js

rUv7eb71681402f
diff --git a/.claude/checkpoints/task-1755116261.json b/.claude/checkpoints/task-1755116261.json
new file mode 100644
index 0000000000..a0bb8951bd
--- /dev/null
+++ b/.claude/checkpoints/task-1755116261.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250813-201740", "task": "add better instructions. for CLAUDE_CODE_ENABLE_TELEMETRY=1 with a flag that sets it. ", "timestamp": "2025-08-13T20:17:41Z", "commit": "f7793f159e9358771c8344917d612c3ea50d0247", "github_release": "true"}
diff --git a/src/cli/simple-commands/analysis.js b/src/cli/simple-commands/analysis.js
index 1d3962c325..91b36efb0e 100644
--- a/src/cli/simple-commands/analysis.js
+++ b/src/cli/simple-commands/analysis.js
@@ -36,6 +36,12 @@ export async function analysisAction(subArgs, flags) {
return;
}
+ // Handle telemetry setup
+ if (subcommand === 'setup-telemetry' || options['enable-telemetry']) {
+ await setupTelemetry();
+ if (subcommand === 'setup-telemetry') return;
+ }
+
try {
switch (subcommand) {
case 'bottleneck-detect':
@@ -264,10 +270,24 @@ USAGE:
claude-flow analysis <command> [options]
COMMANDS:
+ setup-telemetry Configure token tracking for Claude API calls
bottleneck-detect Detect performance bottlenecks in the system
performance-report Generate comprehensive performance reports
token-usage Analyze token consumption and costs
+GLOBAL OPTIONS:
+ --enable-telemetry Enable token tracking for this session
+ --help, -h Show this help message
+
+TELEMETRY SETUP:
+ claude-flow analysis setup-telemetry
+
+ This command will:
+ β€’ Set CLAUDE_CODE_ENABLE_TELEMETRY=1 in your environment
+ β€’ Create .env file with telemetry settings
+ β€’ Initialize token tracking directory
+ β€’ Show current telemetry status
+
BOTTLENECK DETECT OPTIONS:
--scope <scope> Analysis scope (default: system)
Options: system, swarm, agent, task, memory
@@ -284,29 +304,32 @@ TOKEN USAGE OPTIONS:
--agent <agent> Filter by agent type or ID (default: all)
--breakdown Include detailed breakdown by agent type
--cost-analysis Include cost projections and optimization
+ --enable-telemetry Enable token tracking for this session
EXAMPLES:
+ # First-time setup for token tracking
+ claude-flow analysis setup-telemetry
+
+ # Token usage with telemetry enabled
+ claude-flow analysis token-usage --enable-telemetry --breakdown
+
# Detect system-wide bottlenecks
claude-flow analysis bottleneck-detect --scope system
- # Agent-specific bottleneck analysis
- claude-flow analysis bottleneck-detect --scope agent --target coordinator-1
-
# Weekly performance report
claude-flow analysis performance-report --timeframe 7d --format detailed
- # Token usage with breakdown
+ # Token usage with full analysis
claude-flow analysis token-usage --breakdown --cost-analysis
- # Swarm-specific analysis
- claude-flow analysis bottleneck-detect --scope swarm --target swarm-123
-
🎯 Analysis helps with:
+ β€’ Token usage tracking & cost management
β€’ Performance optimization
- β€’ Cost management
β€’ Resource allocation
β€’ Bottleneck identification
β€’ Trend analysis
+
+πŸ’‘ TIP: Run 'analysis setup-telemetry' first to enable token tracking!
`);
}
@@ -316,26 +339,44 @@ async function showSimulatedTokenUsage(breakdown, costAnalysis) {
// Show honest message about no data instead of fake numbers
console.log(`\nπŸ”’ TOKEN USAGE ANALYSIS:`);
console.log(` ℹ️ No token usage data available yet.`);
- console.log(`\n Token tracking requires:`);
- console.log(` β€’ Claude Code API calls to be made`);
- console.log(` β€’ Commands run with --claude flag`);
- console.log(` β€’ Or set CLAUDE_CODE_ENABLE_TELEMETRY=1`);
- console.log(`\nπŸ’‘ To start tracking tokens:`);
- console.log(` 1. Run: export CLAUDE_CODE_ENABLE_TELEMETRY=1`);
- console.log(` 2. Use: ./claude-flow swarm "task" --claude`);
- console.log(` 3. Check back after running Claude commands`);
+ console.log(`\nπŸ“‹ QUICK SETUP - Choose one option:`);
+ console.log(`\n Option 1: Enable Telemetry (Recommended)`);
+ console.log(` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`);
+ console.log(` β”‚ ./claude-flow analysis setup-telemetry β”‚`);
+ console.log(` β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜`);
+
+ console.log(`\n Option 2: Manual Environment Variable`);
+ console.log(` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`);
+ console.log(` β”‚ export CLAUDE_CODE_ENABLE_TELEMETRY=1 β”‚`);
+ console.log(` β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜`);
+
+ console.log(`\n Option 3: Use --enable-telemetry Flag`);
+ console.log(` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”`);
+ console.log(` β”‚ ./claude-flow analysis token-usage --enable-telemetry β”‚`);
+ console.log(` β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜`);
+
+ console.log(`\nβœ… AFTER SETUP:`);
+ console.log(` 1. Run Claude commands: ./claude-flow swarm "task" --claude`);
+ console.log(` 2. Token usage will be automatically tracked`);
+ console.log(` 3. Return here to see real metrics`);
if (costAnalysis) {
- console.log(`\nπŸ’° Cost analysis will be available once tokens are tracked.`);
- console.log(` Pricing: $15/1M input tokens, $75/1M output tokens (Claude 3 Opus)`);
+ console.log(`\nπŸ’° COST TRACKING:`);
+ console.log(` β€’ Claude 3 Opus: $15/1M input, $75/1M output tokens`);
+ console.log(` β€’ Claude 3 Sonnet: $3/1M input, $15/1M output tokens`);
+ console.log(` β€’ Claude 3 Haiku: $0.25/1M input, $1.25/1M output tokens`);
}
if (breakdown) {
- console.log(`\nπŸ“Š Agent breakdown will show once agents use Claude Code.`);
- console.log(` Each agent type's token usage will be tracked separately.`);
+ console.log(`\nπŸ“Š AGENT BREAKDOWN:`);
+ console.log(` β€’ Each agent type's usage tracked separately`);
+ console.log(` β€’ Identifies high-consumption agents`);
+ console.log(` β€’ Provides optimization recommendations`);
}
- console.log(`\nπŸ“„ Reports will be generated once data is available.`);
- console.log(` Enable CLAUDE_CODE_ENABLE_TELEMETRY=1 for automatic tracking.`);
+ console.log(`\n❓ TROUBLESHOOTING:`);
+ console.log(` β€’ Check telemetry status: echo $CLAUDE_CODE_ENABLE_TELEMETRY`);
+ console.log(` β€’ View raw data: cat .claude-flow/metrics/token-usage.json`);
+ console.log(` β€’ Reset tracking: rm -rf .claude-flow/metrics/token-usage.json`);
}