-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
Β·125 lines (97 loc) Β· 3.47 KB
/
install.py
File metadata and controls
executable file
Β·125 lines (97 loc) Β· 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
"""Install script for lsearch Claude Code plugin."""
import json
import os
import subprocess
import sys
from pathlib import Path
def get_claude_dir() -> Path:
"""Get Claude Code configuration directory."""
home = Path.home()
return home / ".claude"
def get_settings_path() -> Path:
"""Get Claude settings.json path."""
return get_claude_dir() / "settings.json"
def install_package():
"""Install lsearch Python package."""
print("π¦ Installing lsearch package...")
result = subprocess.run(
[sys.executable, "-m", "pip", "install", "-e", "."],
cwd=Path(__file__).parent,
capture_output=True,
text=True
)
if result.returncode != 0:
print(f"β Failed to install package: {result.stderr}")
sys.exit(1)
print("β
Package installed")
def configure_mcp():
"""Configure MCP server in Claude settings."""
settings_path = get_settings_path()
# Load existing settings or create new
if settings_path.exists():
with open(settings_path, "r", encoding="utf-8") as f:
settings = json.load(f)
else:
settings = {}
# Add MCP server configuration
if "mcpServers" not in settings:
settings["mcpServers"] = {}
settings["mcpServers"]["lsearch"] = {
"command": "python",
"args": ["-m", "lsearch.server"]
}
# Save settings
settings_path.parent.mkdir(parents=True, exist_ok=True)
with open(settings_path, "w", encoding="utf-8") as f:
json.dump(settings, f, indent=2, ensure_ascii=False)
print(f"β
MCP server configured in {settings_path}")
def install_skills():
"""Install Claude skills and commands."""
claude_dir = get_claude_dir()
plugin_dir = Path(__file__).parent
# Install skill
skills_dir = claude_dir / "skills"
skills_dir.mkdir(exist_ok=True)
skill_src = plugin_dir / ".claude" / "skills" / "lsearch"
skill_dst = skills_dir / "lsearch"
if skill_src.exists():
import shutil
# Create skill directory
skill_dst.mkdir(exist_ok=True)
# Copy skill.yaml (required by Claude Code)
skill_yaml_src = skill_src / "skill.yaml"
skill_yaml_dst = skill_dst / "skill.yaml"
if skill_yaml_src.exists():
shutil.copy2(skill_yaml_src, skill_yaml_dst)
print(f"β
Skill installed to {skill_dst}")
else:
print(f"β οΈ Warning: skill.yaml not found in {skill_src}")
# Install commands
commands_dir = claude_dir / "commands"
commands_dir.mkdir(exist_ok=True)
commands_src = plugin_dir / ".claude" / "commands"
if commands_src.exists():
for cmd_file in commands_src.iterdir():
if cmd_file.is_file():
cmd_dst = commands_dir / cmd_file.name
import shutil
shutil.copy2(cmd_file, cmd_dst)
print(f"β
Commands installed to {commands_dir}")
def main():
"""Main installation function."""
print("π Installing lsearch Claude Code plugin...\n")
try:
install_package()
configure_mcp()
install_skills()
print("\n⨠Installation complete!")
print("\nNext steps:")
print("1. Restart Claude Code")
print("2. In your project directory, run: lsearch init")
print("3. Start using: lsearch: your query here")
except Exception as e:
print(f"\nβ Installation failed: {e}")
sys.exit(1)
if __name__ == "__main__":
main()