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/test-tokens.js

rUv7e0cbd7fec09
diff --git a/.claude/checkpoints/task-1755116636.json b/.claude/checkpoints/task-1755116636.json
new file mode 100644
index 0000000000..01742489e8
--- /dev/null
+++ b/.claude/checkpoints/task-1755116636.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250813-202355", "task": "still not working ", "timestamp": "2025-08-13T20:23:56Z", "commit": "39e234a7e05090e3d23cb24ff317e20634d9d617", "github_release": "true"}
diff --git a/analysis-reports/token-usage-1755116676493.csv b/analysis-reports/token-usage-1755116676493.csv
new file mode 100644
index 0000000000..9d4f2b6113
--- /dev/null
+++ b/analysis-reports/token-usage-1755116676493.csv
@@ -0,0 +1,8 @@
+Timestamp,Session,Agent,Command,Input Tokens,Output Tokens,Total
+
+SUMMARY
+Total Input Tokens,0
+Total Output Tokens,0
+Total Tokens,0
+
+BY AGENT TYPE
diff --git a/src/cli/simple-commands/test-tokens.js b/src/cli/simple-commands/test-tokens.js
new file mode 100644
index 0000000000..e92cf6bd93
--- /dev/null
+++ b/src/cli/simple-commands/test-tokens.js
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+/**
+ * Test command to simulate token tracking
+ * This demonstrates how token tracking would work with real Claude API calls
+ */
+
+import { trackTokens } from './token-tracker.js';
+import { printSuccess, printInfo } from '../utils.js';
+
+export async function testTokensCommand(args, flags) {
+ console.log('\nπŸ”¬ TOKEN TRACKING TEST\n');
+ console.log('This simulates token usage from Claude API calls.');
+ console.log('In production, these values would come from actual API responses.\n');
+
+ // Simulate different agent types making API calls
+ const testScenarios = [
+ {
+ agentType: 'researcher',
+ command: 'swarm',
+ inputTokens: 1250,
+ outputTokens: 3420,
+ description: 'Research task on AI trends'
+ },
+ {
+ agentType: 'coder',
+ command: 'swarm',
+ inputTokens: 2100,
+ outputTokens: 5800,
+ description: 'Generate API implementation'
+ },
+ {
+ agentType: 'analyzer',
+ command: 'analysis',
+ inputTokens: 890,
+ outputTokens: 2150,
+ description: 'Code quality analysis'
+ },
+ {
+ agentType: 'coordinator',
+ command: 'hive-mind',
+ inputTokens: 650,
+ outputTokens: 1200,
+ description: 'Task coordination'
+ }
+ ];
+
+ console.log('πŸ“Š Simulating token usage from multiple agents:\n');
+
+ for (const scenario of testScenarios) {
+ console.log(`πŸ€– ${scenario.agentType.toUpperCase()} Agent`);
+ console.log(` Task: ${scenario.description}`);
+ console.log(` Input: ${scenario.inputTokens.toLocaleString()} tokens`);
+ console.log(` Output: ${scenario.outputTokens.toLocaleString()} tokens`);
+
+ // Track the tokens
+ const result = await trackTokens({
+ sessionId: `test-session-${Date.now()}`,
+ agentType: scenario.agentType,
+ command: scenario.command,
+ inputTokens: scenario.inputTokens,
+ outputTokens: scenario.outputTokens,
+ metadata: {
+ description: scenario.description,
+ test: true
+ }
+ });
+
+ console.log(` βœ… Tracked! Grand total: ${result.grandTotal.toLocaleString()} tokens\n`);
+ }
+
+ // Calculate totals
+ const totalInput = testScenarios.reduce((sum, s) => sum + s.inputTokens, 0);
+ const totalOutput = testScenarios.reduce((sum, s) => sum + s.outputTokens, 0);
+ const totalTokens = totalInput + totalOutput;
+
+ // Calculate cost (Claude 3 Opus pricing)
+ const inputCost = (totalInput / 1000000) * 15.00;
+ const outputCost = (totalOutput / 1000000) * 75.00;
+ const totalCost = inputCost + outputCost;
+
+ console.log('πŸ“ˆ SESSION SUMMARY:');
+ console.log(` Total Input: ${totalInput.toLocaleString()} tokens`);
+ console.log(` Total Output: ${totalOutput.toLocaleString()} tokens`);
+ console.log(` Total Tokens: ${totalTokens.toLocaleString()} tokens`);
+ console.log(` Estimated Cost: $${totalCost.toFixed(4)}`);
+
+ printSuccess('\nβœ… Test tokens tracked successfully!');
+ console.log('\nπŸ’‘ Now run: ./claude-flow analysis token-usage --breakdown --cost-analysis');
+ console.log(' to see the tracked data in the analysis report.\n');
+}
+
+// CLI entry point
+if (import.meta.url === `file://${process.argv[1]}`) {
+ testTokensCommand(process.argv.slice(2), {});
+}
\ No newline at end of file