Set up MCP config for detected AI coding platforms.
(args: argparse.Namespace)
| 187 | |
| 188 | |
| 189 | def _handle_init(args: argparse.Namespace) -> None: |
| 190 | """Set up MCP config for detected AI coding platforms.""" |
| 191 | from .incremental import ensure_repo_gitignore_excludes_crg, find_repo_root |
| 192 | from .skills import install_platform_configs |
| 193 | |
| 194 | repo_root = Path(args.repo) if args.repo else find_repo_root() |
| 195 | if not repo_root: |
| 196 | repo_root = Path.cwd() |
| 197 | |
| 198 | dry_run = getattr(args, "dry_run", False) |
| 199 | target = getattr(args, "platform", "all") or "all" |
| 200 | if target == "claude-code": |
| 201 | target = "claude" |
| 202 | auto_yes = getattr(args, "yes", False) |
| 203 | skip_instructions = getattr(args, "no_instructions", False) |
| 204 | |
| 205 | print("Installing MCP server config...") |
| 206 | configured = install_platform_configs(repo_root, target=target, dry_run=dry_run) |
| 207 | |
| 208 | if not configured: |
| 209 | print("No platforms detected.") |
| 210 | else: |
| 211 | print(f"\nConfigured {len(configured)} platform(s): {', '.join(configured)}") |
| 212 | |
| 213 | # Preview the instruction files that would be touched (#173). |
| 214 | instr_targets = _instruction_files_to_modify(repo_root, target) |
| 215 | if instr_targets: |
| 216 | print() |
| 217 | print("Graph instructions will be injected into:") |
| 218 | for t in instr_targets: |
| 219 | print(f" {t}") |
| 220 | |
| 221 | if dry_run: |
| 222 | print("\n[dry-run] Would ensure .gitignore ignores .code-review-graph/.") |
| 223 | print("[dry-run] No files were modified.") |
| 224 | return |
| 225 | |
| 226 | gitignore_state = ensure_repo_gitignore_excludes_crg(repo_root) |
| 227 | if gitignore_state == "created": |
| 228 | print("Created .gitignore and added .code-review-graph/.") |
| 229 | elif gitignore_state == "updated": |
| 230 | print("Updated .gitignore with .code-review-graph/.") |
| 231 | else: |
| 232 | print(".gitignore already contains .code-review-graph/.") |
| 233 | |
| 234 | # Platform-native skills and hooks are installed by default where supported |
| 235 | # so the graph tools are used proactively. Use --no-skills / --no-hooks / |
| 236 | # --no-instructions to opt out. |
| 237 | skip_skills = getattr(args, "no_skills", False) |
| 238 | skip_hooks = getattr(args, "no_hooks", False) |
| 239 | # Legacy: --skills/--hooks/--all still accepted (no-op, everything is default) |
| 240 | |
| 241 | from .skills import ( |
| 242 | PLATFORMS, |
| 243 | generate_skills, |
| 244 | inject_claude_md, |
| 245 | inject_platform_instructions, |
| 246 | install_codex_hooks, |