ai/ai
1
0
Files
ai/claude/docs/submodule_management.md
2025-06-07 03:54:04 +09:00

4.6 KiB

サブモジュール管理システム

概要

ai.jsonの構造ベース設定を活用した高度なサブモジュール管理システム。 Git URLの自動生成、整合性チェック、一括管理機能を提供。

スクリプト: update-submodules.sh

基本使用法

# 全サブモジュール更新
./claude/scripts/update-submodules.sh --all

# 特定サブモジュール更新
./claude/scripts/update-submodules.sh --module=gpt

# 自動コミット付き更新
./claude/scripts/update-submodules.sh --all --auto

主要機能

1. 更新機能

全サブモジュール更新

./claude/scripts/update-submodules.sh --all [--auto] [--dry-run]
  • ai.jsonで定義されたブランチで各サブモジュールを更新
  • 構造ベースURL生成を使用
  • オプションで自動コミット

個別サブモジュール更新

./claude/scripts/update-submodules.sh --module=<name> [--auto]
  • 指定されたサブモジュールのみ更新
  • ai.jsonの設定を自動適用

2. 検証機能

URL整合性チェック

./claude/scripts/update-submodules.sh --validate
  • .gitmodulesとai.jsonのURL一致確認
  • 不整合があれば詳細レポート
  • 構造ベース生成URLとの比較

出力例:

🔍 Validating URL consistency between ai.json and .gitmodules...
✅ gpt: URLs match
✅ bot: URLs match
❌ card: URL mismatch
   .gitmodules: git@old.host:ai/card
   ai.json:     git@git.syui.ai:ai/card

3. 同期機能

.gitmodules同期

./claude/scripts/update-submodules.sh --sync [--auto]
  • ai.jsonの設定を.gitmodulesに反映
  • URL不整合の自動修正
  • オプションで変更を自動コミット

4. サブモジュール管理

新規追加

./claude/scripts/update-submodules.sh --add=<name> [--auto]
  • ai.jsonの設定に基づき新しいサブモジュールを追加
  • 構造ベースURLとブランチを自動適用

前提条件:

  • ai.jsonに対象プロジェクトが定義済み
  • リモートリポジトリが存在

削除

./claude/scripts/update-submodules.sh --remove=<name> [--auto]
  • サブモジュールを完全削除
  • .gitmodules、.git/config、ディレクトリを清理

オプション

共通オプション

オプション 説明
--auto 変更を自動コミット
--dry-run 実行内容をプレビュー(変更なし)
--help ヘルプ表示

操作オプション(排他)

オプション 説明
--all 全サブモジュール更新
--module=<name> 特定サブモジュール更新
--validate URL整合性チェック
--sync .gitmodules同期
--add=<name> サブモジュール追加
--remove=<name> サブモジュール削除

ai.json設定例

基本設定

{
  "metadata": {
    "git": {
      "host": "git.syui.ai",
      "protocol": "ssh"
    }
  },
  "ai": {
    "gpt": {
      "branch": "main",
      "type": "gpt"
    },
    "bot": {
      "branch": "claude",
      "type": "bot"
    }
  }
}

カスタムURL

{
  "ai": {
    "special": {
      "git_url": "git@special.host:custom/repo",
      "branch": "develop"
    }
  }
}

実行フロー

1. 設定読み込み

  • ai.jsonからgit設定とプロジェクト構造を読み込み
  • .gitmodulesから既存サブモジュール情報を取得

2. URL生成

  • 構造ベースロジックでGit URLを生成
  • カスタムURLがあれば優先使用

3. 操作実行

  • 指定された操作を実行
  • ログ出力とエラーハンドリング

4. 結果報告

  • 成功/失敗数の集計
  • 詳細ログの出力

トラブルシューティング

よくある問題

1. ブランチ不一致

❌ Failed to checkout branch claude

解決方法:

  • リモートブランチの存在確認
  • ai.jsonのブランチ設定確認

2. URL不整合

❌ card: URL mismatch

解決方法:

./claude/scripts/update-submodules.sh --sync --auto

3. 権限エラー

Permission denied (publickey)

解決方法:

  • SSH鍵の設定確認
  • リポジトリアクセス権限確認

ログ

ログファイル

.submodule-update.log

ログレベル

  • INFO: 正常操作
  • ERROR: エラー状況
  • DEBUG: 詳細情報(構造解析等)

関連ドキュメント