Skip to content

Commit 35a5dee

Browse files
saga4saga4
authored andcommitted
init ++
1 parent c465aea commit 35a5dee

File tree

10 files changed

+443
-452
lines changed

10 files changed

+443
-452
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ def parse_args() -> Namespace:
2626
# Integrate command - native integrations (replaces setup)
2727
integrate_parser = subparsers.add_parser("integrate", help="Integrate codeflash with development tools")
2828
integrate_subparsers = integrate_parser.add_subparsers(dest="integration_target", help="Integration targets")
29-
29+
3030
# Claude Code integration
3131
claude_parser = integrate_subparsers.add_parser("claude", help="Integrate with Claude Code")
32-
claude_parser.add_argument("--project", action="store_true",
33-
help="Also create project-specific subagent")
34-
claude_parser.add_argument("--force", action="store_true",
35-
help="Force integration even if Claude Code not detected")
36-
claude_parser.add_argument("--remove", action="store_true",
37-
help="Remove Claude Code integration")
38-
32+
claude_parser.add_argument("--project", action="store_true", help="Also create project-specific subagent")
33+
claude_parser.add_argument(
34+
"--force", action="store_true", help="Force integration even if Claude Code not detected"
35+
)
36+
claude_parser.add_argument("--remove", action="store_true", help="Remove Claude Code integration")
37+
3938
# Status command
4039
status_parser = integrate_subparsers.add_parser("status", help="Show integration status")
41-
40+
4241
def integration_handler():
4342
from codeflash.cli_cmds.cmd_integrate import handle_integration
43+
4444
handle_integration()
45-
45+
4646
integrate_parser.set_defaults(func=integration_handler)
4747

4848
trace_optimize = subparsers.add_parser("optimize", help="Trace and optimize a Python project.")

codeflash/cli_cmds/cmd_integrate.py

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
def handle_integration():
1010
"""Handle integration subcommands."""
11-
import argparse
12-
1311
# Get the arguments after 'codeflash integrate'
1412
args = sys.argv[2:] # Skip 'codeflash integrate'
15-
13+
1614
if not args or args[0] == "status":
1715
show_integration_status()
1816
elif args[0] == "claude":
@@ -26,66 +24,63 @@ def handle_integration():
2624
def handle_claude_integration(args):
2725
"""Handle Claude Code integration."""
2826
import argparse
29-
27+
3028
parser = argparse.ArgumentParser(prog="codeflash integrate claude")
31-
parser.add_argument("--project", action="store_true",
32-
help="Also create project-specific subagent")
33-
parser.add_argument("--force", action="store_true",
34-
help="Force integration even if Claude Code not detected")
35-
parser.add_argument("--remove", action="store_true",
36-
help="Remove Claude Code integration")
37-
29+
parser.add_argument("--project", action="store_true", help="Also create project-specific subagent")
30+
parser.add_argument("--force", action="store_true", help="Force integration even if Claude Code not detected")
31+
parser.add_argument("--remove", action="store_true", help="Remove Claude Code integration")
32+
3833
parsed_args = parser.parse_args(args)
39-
34+
4035
integration = ClaudeCodeIntegration()
41-
36+
4237
if parsed_args.remove:
4338
success, message = integration.remove_integration()
4439
print(message)
4540
sys.exit(0 if success else 1)
46-
41+
4742
# Perform integration
4843
project_path = str(Path.cwd()) if parsed_args.project else None
4944
success = setup_claude_integration(
50-
include_project=parsed_args.project,
51-
project_path=project_path,
52-
force=parsed_args.force
45+
include_project=parsed_args.project, project_path=project_path, force=parsed_args.force
5346
)
54-
47+
5548
sys.exit(0 if success else 1)
5649

5750

5851
def show_integration_status():
5952
"""Show current integration status."""
6053
print("🔍 Codeflash Integration Status")
6154
print("=" * 40)
62-
55+
6356
# Claude Code status
6457
integration = ClaudeCodeIntegration()
6558
status = integration.get_integration_status()
66-
59+
6760
print("\n📋 Claude Code Integration:")
6861
print(f" Claude Available: {'✅' if status['claude_available'] else '❌'}")
69-
70-
if status['config_path']:
62+
63+
if status["config_path"]:
7164
print(f" Config File: {status['config_path']}")
7265
else:
7366
print(" Config File: ❌ Not found")
74-
67+
7568
print(f" Agents Directory: {status['agents_directory']}")
7669
print(f" Subagents Installed: {len(status['installed_subagents'])}/3")
77-
for subagent in status['installed_subagents']:
70+
for subagent in status["installed_subagents"]:
7871
print(f" ✅ {subagent}")
79-
80-
missing_subagents = set(["codeflash-optimizer", "codeflash-profiler", "codeflash-reviewer"]) - set(status['installed_subagents'])
72+
73+
missing_subagents = set(["codeflash-optimizer", "codeflash-profiler", "codeflash-reviewer"]) - set(
74+
status["installed_subagents"]
75+
)
8176
for subagent in missing_subagents:
8277
print(f" ❌ {subagent}")
83-
78+
8479
print(f" MCP Tools: {'✅' if status['mcp_tools_configured'] else '❌'}")
8580
print(f" System: {status['system']}")
86-
81+
8782
# Overall status
88-
if status['claude_available'] and status['all_subagents_installed']:
83+
if status["claude_available"] and status["all_subagents_installed"]:
8984
print("\n🎉 Complete Claude Code integration is active!")
9085
print("\nAvailable subagents:")
9186
print(" @codeflash-optimizer - AI-powered code optimization")
@@ -95,17 +90,17 @@ def show_integration_status():
9590
print(" '@codeflash-optimizer optimize my slow function'")
9691
print(" '@codeflash-profiler find bottlenecks in my script'")
9792
print(" '@codeflash-reviewer review this code for performance'")
98-
elif status['claude_available'] and status['installed_subagents']:
93+
elif status["claude_available"] and status["installed_subagents"]:
9994
print(f"\n⚠️ Partial integration ({len(status['installed_subagents'])}/3 subagents)")
10095
print(" Run: codeflash integrate claude # to install all subagents")
101-
elif status['claude_available']:
96+
elif status["claude_available"]:
10297
print("\n⚠️ Claude Code available but subagents not installed")
10398
print(" Run: codeflash integrate claude")
10499
else:
105100
print("\n📖 Install Claude Code to enable integration:")
106101
print(" Visit: https://docs.anthropic.com/en/docs/claude-code")
107102
print(" Then run: codeflash integrate claude")
108-
103+
109104
# Check for project-specific integration
110105
project_agent = Path.cwd() / ".claude" / "agents" / "codeflash-optimizer.md"
111106
if project_agent.exists():
@@ -116,4 +111,4 @@ def show_integration_status():
116111

117112

118113
if __name__ == "__main__":
119-
handle_integration()
114+
handle_integration()

codeflash/cli_cmds/cmd_setup.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""Setup command for codeflash integrations and configurations."""
22

33
import sys
4-
from typing import Optional
54

65
import click
76

8-
from codeflash.cli_cmds.console import logger
97
from codeflash.mcp.integration import ClaudeCodeIntegration
108

119

@@ -15,7 +13,7 @@
1513
@click.option("--remove", is_flag=True, help="Remove the integration")
1614
def setup_integrations(integration: str, force: bool = False, remove: bool = False):
1715
"""Set up codeflash integrations with various tools and editors.
18-
16+
1917
Available integrations:
2018
- claude-code: Set up as Claude Code MCP server subagent
2119
- status: Show current integration status
@@ -32,60 +30,60 @@ def setup_integrations(integration: str, force: bool = False, remove: bool = Fal
3230
def setup_claude_code(force: bool = False, remove: bool = False):
3331
"""Set up Claude Code integration."""
3432
integration = ClaudeCodeIntegration()
35-
33+
3634
if remove:
3735
success, message = integration.remove_integration()
3836
click.echo(message)
3937
sys.exit(0 if success else 1)
40-
38+
4139
success, message = integration.setup_integration(force=force)
4240
click.echo(message)
43-
41+
4442
if success:
4543
click.echo("\n🎉 Codeflash is now available as a Claude Code subagent!")
4644
click.echo("\nUsage examples in Claude Code:")
4745
click.echo("• 'Optimize the bubble_sort function using codeflash'")
48-
click.echo("• 'Use codeflash to trace and optimize my main.py script'")
46+
click.echo("• 'Use codeflash to trace and optimize my main.py script'")
4947
click.echo("• 'Initialize codeflash in this project'")
5048
click.echo("• 'Run codeflash benchmarks to measure performance'")
5149
click.echo("\n📝 Restart Claude Code to load the new MCP server.")
52-
50+
5351
# Show quick verification steps
5452
click.echo("\n🔍 Verification steps:")
5553
click.echo("1. Restart Claude Code")
5654
click.echo("2. In Claude Code, type: 'Show me codeflash help'")
5755
click.echo("3. Claude Code should respond with codeflash functionality")
58-
56+
5957
sys.exit(0 if success else 1)
6058

6159

6260
def show_integration_status():
6361
"""Show current integration status for all supported tools."""
6462
integration = ClaudeCodeIntegration()
6563
status = integration.get_status()
66-
64+
6765
click.echo("🔍 Codeflash Integration Status\n")
68-
66+
6967
# Claude Code status
7068
click.echo("📋 Claude Code:")
7169
if status["claude_code_installed"]:
7270
click.echo(" ✅ Claude Code is installed")
7371
else:
7472
click.echo(" ❌ Claude Code not found")
75-
73+
7674
if status["config_file"]:
7775
click.echo(f" 📁 Config file: {status['config_file']}")
7876
else:
7977
click.echo(" 📁 No config file found")
80-
78+
8179
if status["codeflash_configured"]:
8280
click.echo(" ✅ Codeflash MCP server is configured")
8381
else:
8482
click.echo(" ❌ Codeflash MCP server not configured")
85-
83+
8684
click.echo(f" 🔧 MCP executable: {status['mcp_executable']}")
8785
click.echo(f" 💻 System: {status['system']}")
88-
86+
8987
# Overall status
9088
if status["claude_code_installed"] and status["codeflash_configured"]:
9189
click.echo("\n🎉 All integrations are working!")
@@ -99,10 +97,11 @@ def show_integration_status():
9997

10098
# Function that can be called from main CLI
10199
def setup_claude_code_integration(force: bool = False):
102-
"""Setup function that can be called from main CLI."""
100+
"""Setup function that can be called from main CLI."""
103101
from codeflash.mcp.integration import setup_claude_code_integration as _setup
102+
104103
return _setup(force=force)
105104

106105

107106
if __name__ == "__main__":
108-
setup_integrations()
107+
setup_integrations()

codeflash/install_hooks.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
#!/usr/bin/env python3
22
"""Post-install hooks for codeflash to set up integrations automatically."""
33

4-
import os
54
import sys
6-
from pathlib import Path
5+
76

87
def post_install_hook():
98
"""Run after codeflash installation to set up integrations."""
109
try:
1110
# Only auto-setup in interactive environments
1211
if not sys.stdin.isatty():
1312
return
14-
13+
1514
from codeflash.integrations.claude_code import ClaudeCodeIntegration
16-
15+
1716
integration = ClaudeCodeIntegration()
18-
17+
1918
# Check if Claude Code is available
2019
if not integration.is_claude_code_available():
2120
print("\n📖 Claude Code integration available!")
2221
print(" Install Claude Code: https://docs.anthropic.com/en/docs/claude-code")
2322
print(" Then run: codeflash integrate claude")
2423
return
25-
24+
2625
# Check if already configured
2726
status = integration.get_integration_status()
2827
if status["subagent_installed"]:
2928
print("\n✅ Codeflash Claude Code integration is already active!")
3029
return
31-
30+
3231
print("\n🚀 Claude Code detected! Setting up codeflash subagent...")
33-
32+
3433
success, message = integration.setup_complete_integration()
3534
if success:
3635
print("✅ Codeflash subagent installed!")
@@ -39,15 +38,15 @@ def post_install_hook():
3938
print(" Or let Claude auto-invoke for performance tasks")
4039
print("\n📝 Restart Claude Code to activate the subagent")
4140
else:
42-
print(f"⚠️ Auto-setup encountered issues:")
41+
print("⚠️ Auto-setup encountered issues:")
4342
print(message)
4443
print("\n Run manually: codeflash integrate claude")
45-
44+
4645
except Exception as e:
4746
# Silently fail to avoid breaking installation
4847
print(f"\n⚠️ Auto-integration encountered an issue: {e}")
4948
print(" Run manually: codeflash integrate claude")
5049

5150

5251
if __name__ == "__main__":
53-
post_install_hook()
52+
post_install_hook()

codeflash/integrations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Claude Code and other integrations for codeflash."""
22

3-
__version__ = "1.0.0"
3+
__version__ = "1.0.0"

0 commit comments

Comments
 (0)