From 436c7cde95540541663d0b83e3d4291a61d1cf65 Mon Sep 17 00:00:00 2001 From: rUv Date: Wed, 13 Aug 2025 20:34:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/src/cli/simple-commands/analysis.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/1755117241.json | 1 + .claude/checkpoints/1755117243.json | 1 + src/cli/simple-commands/analysis.js | 61 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .claude/checkpoints/1755117241.json create mode 100644 .claude/checkpoints/1755117243.json diff --git a/.claude/checkpoints/1755117241.json b/.claude/checkpoints/1755117241.json new file mode 100644 index 0000000000..fd4258c152 --- /dev/null +++ b/.claude/checkpoints/1755117241.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250813-203401", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/analysis.js", "timestamp": "2025-08-13T20:34:01Z", "type": "pre-edit", "original_branch": "alpha-89"} diff --git a/.claude/checkpoints/1755117243.json b/.claude/checkpoints/1755117243.json new file mode 100644 index 0000000000..a270f3150c --- /dev/null +++ b/.claude/checkpoints/1755117243.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250813-203403", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/analysis.js", "timestamp": "2025-08-13T20:34:03Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 120 +++++++++++++++++++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1755117172.json | 1 + .claude/checkpoints/1755117174.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/analysis.js | 6 ++ 7 files changed, 132 insertions(+), 4 deletions(-) "} diff --git a/src/cli/simple-commands/analysis.js b/src/cli/simple-commands/analysis.js index 3e222f6db7..eaf637fbc1 100644 --- a/src/cli/simple-commands/analysis.js +++ b/src/cli/simple-commands/analysis.js @@ -427,6 +427,67 @@ EXAMPLES: // Helper functions for real token tracking are now imported from token-tracker.js +async function claudeMonitorCommand(subArgs, flags) { + const sessionId = subArgs[1] || 'current'; + const interval = flags.interval || 5000; + + console.log(`šŸ“Š Starting Claude session monitor...`); + console.log(` Session ID: ${sessionId}`); + console.log(` Update interval: ${interval / 1000}s`); + console.log(` Press Ctrl+C to stop monitoring\n`); + + try { + // Import the telemetry module + const { monitorClaudeSession } = await import('./claude-telemetry.js'); + + // Start monitoring + const stopMonitor = await monitorClaudeSession(sessionId, interval); + + // Handle graceful shutdown + process.on('SIGINT', () => { + stopMonitor(); + process.exit(0); + }); + + // Keep process running + await new Promise(() => {}); + } catch (error) { + printError(`Failed to start Claude monitor: ${error.message}`); + console.log('\nšŸ’” TIP: Make sure Claude is installed and accessible'); + } +} + +async function claudeCostCommand(subArgs, flags) { + console.log(`šŸ’° Retrieving Claude session cost information...`); + + try { + // Import the telemetry module + const { extractCostCommand } = await import('./claude-telemetry.js'); + + // Get cost data + const costData = await extractCostCommand(); + + console.log('\nšŸ“Š Current Session Usage:'); + console.log(` Input Tokens: ${costData.tokens.input || 0}`); + console.log(` Output Tokens: ${costData.tokens.output || 0}`); + console.log(` Total Tokens: ${costData.tokens.total || 0}`); + + if (costData.costs.length > 0) { + console.log(` Estimated Cost: $${costData.costs[0]}`); + } + + // Also show pricing info + console.log('\nšŸ’° Claude 3 Pricing:'); + console.log(' • Opus: $15/1M input, $75/1M output'); + console.log(' • Sonnet: $3/1M input, $15/1M output'); + console.log(' • Haiku: $0.25/1M input, $1.25/1M output'); + + } catch (error) { + printError(`Failed to retrieve cost data: ${error.message}`); + console.log('\nšŸ’” TIP: Run this while Claude is active or immediately after'); + } +} + async function showSimulatedTokenUsage(breakdown, costAnalysis) { // Show honest message about no data instead of fake numbers console.log(`\nšŸ”¢ TOKEN USAGE ANALYSIS:`);