π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
π Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/analysis.js
rUv9c073680fe62
diff --git a/.claude/checkpoints/1755116334.json b/.claude/checkpoints/1755116334.jsonnew file mode 100644index 0000000000..8ac2705439--- /dev/null+++ b/.claude/checkpoints/1755116334.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250813-201854", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/analysis.js", "timestamp": "2025-08-13T20:18:54Z", "type": "pre-edit", "original_branch": "alpha-89"}diff --git a/.claude/checkpoints/1755116336.json b/.claude/checkpoints/1755116336.jsonnew file mode 100644index 0000000000..0e60c7edf6--- /dev/null+++ b/.claude/checkpoints/1755116336.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250813-201856", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/analysis.js", "timestamp": "2025-08-13T20:18:56Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 24 +++++++++ .claude-flow/metrics/task-metrics.json | 6 +-- .claude/checkpoints/task-1755116261.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/analysis.js | 85 +++++++++++++++++++++++--------- 6 files changed, 92 insertions(+), 26 deletions(-) "}diff --git a/analysis-reports/token-usage-1755116357970.csv b/analysis-reports/token-usage-1755116357970.csvnew file mode 100644index 0000000000..9d4f2b6113--- /dev/null+++ b/analysis-reports/token-usage-1755116357970.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 TYPEdiff --git a/src/cli/simple-commands/analysis.js b/src/cli/simple-commands/analysis.jsindex 91b36efb0e..85d3588e1e 100644--- a/src/cli/simple-commands/analysis.js+++ b/src/cli/simple-commands/analysis.js@@ -27,6 +27,82 @@ import {const __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);+async function setupTelemetry() {+ console.log(`\nπ§ TELEMETRY SETUP FOR TOKEN TRACKING\n`);+ console.log(`${'β'.repeat(60)}\n`);++ // Check current status+ const currentValue = process.env.CLAUDE_CODE_ENABLE_TELEMETRY;+ const isEnabled = currentValue === '1';++ console.log(`π Current Status: ${isEnabled ? 'β ENABLED' : 'β DISABLED'}`);+ console.log(` Environment Variable: CLAUDE_CODE_ENABLE_TELEMETRY=${currentValue || 'not set'}\n`);++ if (!isEnabled) {+ // Set the environment variable for current session+ process.env.CLAUDE_CODE_ENABLE_TELEMETRY = '1';++ console.log(`β Telemetry ENABLED for this session!\n`);++ // Create or update .env file+ const envPath = path.join(process.cwd(), '.env');+ let envContent = '';++ try {+ envContent = await fs.readFile(envPath, 'utf-8');+ } catch (err) {+ // .env doesn't exist yet+ }++ // Check if telemetry is already in .env+ if (!envContent.includes('CLAUDE_CODE_ENABLE_TELEMETRY')) {+ envContent += `\n# Enable token tracking for Claude API calls\nCLAUDE_CODE_ENABLE_TELEMETRY=1\n`;++ try {+ await fs.writeFile(envPath, envContent);+ console.log(`π Updated .env file with telemetry setting`);+ } catch (err) {+ console.log(`β οΈ Could not update .env file: ${err.message}`);+ }+ }++ // Also add to shell profile for persistence+ console.log(`\nπ To make this permanent, add to your shell profile:`);+ console.log(` ${'-'.repeat(50)}`);+ console.log(` echo 'export CLAUDE_CODE_ENABLE_TELEMETRY=1' >> ~/.bashrc`);+ console.log(` ${'-'.repeat(50)}\n`);+ }++ // Initialize token tracking directory+ const metricsDir = path.join(process.cwd(), '.claude-flow', 'metrics');+ try {+ await fs.mkdir(metricsDir, { recursive: true });+ console.log(`π Token tracking directory: ${metricsDir}`);+ } catch (err) {+ // Directory already exists+ }++ // Check for existing token data+ const tokenFile = path.join(metricsDir, 'token-usage.json');+ try {+ const data = await fs.readFile(tokenFile, 'utf-8');+ const tokenData = JSON.parse(data);+ console.log(`\nπ Existing token data found:`);+ console.log(` β’ Total tokens tracked: ${tokenData.totals?.total || 0}`);+ console.log(` β’ Sessions recorded: ${Object.keys(tokenData.sessions || {}).length}`);+ } catch (err) {+ console.log(`\nπ No existing token data (will be created on first use)`);+ }++ console.log(`\nπ NEXT STEPS:`);+ console.log(` 1. Run Claude commands with --claude flag`);+ console.log(` 2. Example: ./claude-flow swarm "analyze code" --claude`);+ console.log(` 3. Check usage: ./claude-flow analysis token-usage --breakdown`);++ console.log(`\n${'β'.repeat(60)}`);+ printSuccess(`Telemetry setup complete!`);+}+export async function analysisAction(subArgs, flags) {const subcommand = subArgs[0];const options = flags;