Coverage for mcp_bridge/tools/init.py: 0%
25 statements
« prev ^ index » next coverage.py v7.10.1, created at 2026-01-10 00:20 -0500
« prev ^ index » next coverage.py v7.10.1, created at 2026-01-10 00:20 -0500
1"""
2Repository bootstrap logic for Stravinsky.
3"""
5import logging
6from pathlib import Path
8from .templates import CLAUDE_MD_TEMPLATE, SLASH_COMMANDS
10logger = logging.getLogger(__name__)
12def bootstrap_repo(project_path: str | Path | None = None) -> str:
13 """
14 Bootstrap a repository for Stravinsky MCP usage.
16 Creates:
17 - .claude/commands/ (with standard slash commands)
18 - Appends/Creates CLAUDE.md
19 """
20 root = Path(project_path or Path.cwd())
22 # 1. Setup Slash Commands
23 commands_dir = root / ".claude" / "commands"
24 commands_dir.mkdir(parents=True, exist_ok=True)
26 commands_created = 0
27 for filename, content in SLASH_COMMANDS.items():
28 cmd_file = commands_dir / filename
29 if not cmd_file.exists():
30 cmd_file.write_text(content)
31 commands_created += 1
33 # 2. Setup CLAUDE.md
34 claude_md = root / "CLAUDE.md"
35 if not claude_md.exists():
36 claude_md.write_text("# Project Notes\n\n" + CLAUDE_MD_TEMPLATE)
37 claude_msg = "Created CLAUDE.md"
38 else:
39 content = claude_md.read_text()
40 if "Stravinsky MCP" not in content:
41 with open(claude_md, "a") as f:
42 f.write("\n\n" + CLAUDE_MD_TEMPLATE)
43 claude_msg = "Updated CLAUDE.md with Stravinsky instructions"
44 else:
45 claude_msg = "CLAUDE.md already configured"
47 return (
48 f"✅ Repository Initialized!\n"
49 f"- {claude_msg}\n"
50 f"- Installed {commands_created} new slash commands to .claude/commands/stra/"
51 )