|
| 1 | +// CHANGE: separate project rule preparation by active agent mode |
| 2 | +// WHY: Codex, Claude Code, and Gemini CLI each have different native project-level config models |
| 3 | +// REF: issue-207 |
| 4 | +// PURITY: CORE |
| 5 | +// INVARIANT: Codex gets a bridge for skills that live outside CODEX_HOME; Claude/Gemini stay on native project-local discovery |
| 6 | +// COMPLEXITY: O(1) |
| 7 | +const entrypointProjectAgentRulesTemplate = String.raw`# Prepare project-local rules using each agent's native conventions. |
| 8 | +docker_git_detect_claude_project_rules() { |
| 9 | + local project_dir="${"$"}{TARGET_DIR:-}" |
| 10 | +
|
| 11 | + if [[ -z "$project_dir" || ! -d "$project_dir" ]]; then |
| 12 | + return 0 |
| 13 | + fi |
| 14 | +
|
| 15 | + if [[ -f "$project_dir/CLAUDE.md" \ |
| 16 | + || -f "$project_dir/.claude/CLAUDE.md" \ |
| 17 | + || -f "$project_dir/.claude/settings.json" \ |
| 18 | + || -d "$project_dir/.claude/agents" \ |
| 19 | + || -f "$project_dir/.mcp.json" ]]; then |
| 20 | + echo "[claude] project-local Claude rules available in $project_dir" |
| 21 | + fi |
| 22 | +} |
| 23 | +
|
| 24 | +docker_git_detect_gemini_project_rules() { |
| 25 | + local project_dir="${"$"}{TARGET_DIR:-}" |
| 26 | +
|
| 27 | + if [[ -z "$project_dir" || ! -d "$project_dir" ]]; then |
| 28 | + return 0 |
| 29 | + fi |
| 30 | +
|
| 31 | + if [[ -f "$project_dir/GEMINI.md" \ |
| 32 | + || -f "$project_dir/.gemini/settings.json" \ |
| 33 | + || -d "$project_dir/.gemini/commands" \ |
| 34 | + || -d "$project_dir/.gemini/skills" \ |
| 35 | + || -d "$project_dir/.agents/skills" ]]; then |
| 36 | + echo "[gemini] project-local Gemini rules available in $project_dir" |
| 37 | + fi |
| 38 | +} |
| 39 | +
|
| 40 | +docker_git_prepare_active_agent_project_rules() { |
| 41 | + case "$AGENT_MODE" in |
| 42 | + "codex") |
| 43 | + docker_git_sync_project_codex_skills |
| 44 | + ;; |
| 45 | + "claude") |
| 46 | + docker_git_detect_claude_project_rules |
| 47 | + ;; |
| 48 | + "gemini") |
| 49 | + docker_git_detect_gemini_project_rules |
| 50 | + ;; |
| 51 | + *) |
| 52 | + docker_git_sync_project_codex_skills |
| 53 | + docker_git_detect_claude_project_rules |
| 54 | + docker_git_detect_gemini_project_rules |
| 55 | + ;; |
| 56 | + esac |
| 57 | +}` |
| 58 | + |
| 59 | +export const renderEntrypointProjectAgentRules = (): string => entrypointProjectAgentRulesTemplate |
0 commit comments