Yuki Takei 9 месяцев назад
Родитель
Сommit
83a429a87f

+ 135 - 0
apps/app/src/features/openai/docs/plan/README.md

@@ -0,0 +1,135 @@
+# GROWI エディターアシスタント改修計画 - Plan Directory
+
+このディレクトリには、現在のGROWIエディターアシスタントをroo-codeの方式に倣って再実装するための包括的な改修計画が含まれています。
+
+## 📁 ファイル構成
+
+### 📋 計画ドキュメント
+
+#### [`editor-assistant-refactoring-plan.md`](./editor-assistant-refactoring-plan.md)
+**メイン計画書** - 改修プロジェクト全体の概要
+- 📊 現状分析と課題の特定
+- 🎯 改修目標とroo-code方式の採用理由
+- 📝 5段階の実装計画
+- 📈 期待効果と品質指標
+- 🧪 検証計画
+
+#### [`technical-implementation-details.md`](./technical-implementation-details.md)
+**技術実装詳細** - アーキテクチャと具体的な実装方法
+- 🏗️ アーキテクチャ変更のフロー図
+- 📦 ファイル構成と新規作成対象
+- 🔍 核心技術(MultiSearchReplaceProcessor、FuzzyMatcher等)
+- 🎛️ 設定とカスタマイズ方法
+- 🧪 テスト戦略
+- 📈 パフォーマンス考慮事項
+
+#### [`implementation-tasks.md`](./implementation-tasks.md)
+**実装タスクリスト** - 具体的なタスクと進捗管理
+- ✅ Phase別の詳細タスク分解
+- ⏱️ 推定工数と優先度
+- 👥 担当者アサイン欄
+- 📊 進捗管理表
+- 🎯 次のアクション項目
+
+#### [`roo-code-investigation-supplement.md`](./roo-code-investigation-supplement.md)
+**roo-code調査レポート** - 詳細調査結果と計画への反映
+- 🧪 テスト戦略の分析(1186行のテストファイル調査)
+- 🛡️ エラーハンドリングパターン
+- 🎛️ 設定管理とカスタマイズ方法
+- 📝 文字正規化とパフォーマンス最適化
+- 📈 計画への反映事項と工数調整
+
+## 🚀 改修概要
+
+### 現在の課題
+- **精度不足**: 単純な`replace`のみで誤った箇所を変更するリスク
+- **機能限界**: 複数変更の一括処理が困難
+- **エラー情報不足**: 失敗時の原因特定が困難
+
+### 改修後の実現機能
+- **Search/Replace方式**: 正確な検索条件による安全な置換
+- **Fuzzy Matching**: Levenshtein距離による柔軟な類似度判定
+- **複数diff処理**: 一つのリクエストで複数箇所の変更
+- **詳細エラー報告**: 失敗原因と解決策の具体的な提示
+
+## 📊 改修スコープ
+
+### 影響範囲
+```
+apps/app/src/features/openai/
+├── interfaces/editor-assistant/     # スキーマ更新
+├── server/routes/edit/             # プロンプト・処理統合  
+├── server/services/editor-assistant/ # 新処理エンジン
+└── client/services/                # クライアント対応
+```
+
+### 新規実装コンポーネント
+- **MultiSearchReplaceProcessor**: メイン処理エンジン
+- **FuzzyMatcher**: 類似度計算・検索機能
+- **DiffApplicationEngine**: 差分適用ロジック
+- **ErrorHandler**: 強化されたエラーハンドリング
+
+## 🎯 実装優先順位
+
+### 🔴 高優先度 (Phase 1-2)
+1. スキーマ・インターフェース更新
+2. Search/Replace処理エンジン実装
+3. サーバーサイド統合
+
+### 🟡 中優先度 (Phase 3-4)  
+4. クライアントサイド対応
+5. 統合テスト
+6. プロンプト更新
+
+### 🟢 低優先度 (Phase 5-6)
+7. UI改善・最適化
+8. E2Eテスト
+9. ドキュメント整備
+
+## 📈 期待効果
+
+| 指標 | 現在 | 改修後 | 改善率 |
+|------|------|--------|--------|
+| **編集精度** | 60-70% | 90-95% | +30-35% |
+| **複雑変更対応** | 困難 | 対応可能 | - |
+| **エラー情報** | 限定的 | 詳細 | +200% |
+
+## 🔗 参考資料
+
+- [roo-code GitHub Repository](https://github.com/RooCodeInc/Roo-Code)
+- [roo-code apply_diff implementation](https://github.com/RooCodeInc/Roo-Code/blob/main/src/core/tools/applyDiffTool.ts)
+- [roo-code multi-search-replace strategy](https://github.com/RooCodeInc/Roo-Code/blob/main/src/core/diff/strategies/multi-search-replace.ts)
+- [`roo-prompts.md`](../roo-prompts.md) - roo-codeのプロンプト仕様
+
+## 📝 使用方法
+
+### 計画書の読み順
+1. **まず**: [`editor-assistant-refactoring-plan.md`](./editor-assistant-refactoring-plan.md) で全体概要を把握
+2. **次に**: [`technical-implementation-details.md`](./technical-implementation-details.md) で技術詳細を理解
+3. **最後に**: [`implementation-tasks.md`](./implementation-tasks.md) で具体的なタスクを確認
+
+### 実装開始時
+1. [`implementation-tasks.md`](./implementation-tasks.md) のPhase 1から着手
+2. 各フェーズ完了後、進捗を更新
+3. 技術的な詳細は [`technical-implementation-details.md`](./technical-implementation-details.md) を参照
+
+## ⚠️ 重要な注意事項
+
+### 互換性
+- 既存のエディターアシスタント機能との互換性を維持
+- 段階的な移行でリスクを最小化
+- フィーチャーフラグでの制御推奨
+
+### 品質保証
+- 各フェーズで十分なテストを実施
+- パフォーマンス劣化の監視
+- エラーハンドリングの検証
+
+---
+
+**プロジェクト**: GROWI エディターアシスタント改修  
+**作成日**: 2025-06-17  
+**最終更新**: 2025-06-17 (roo-code調査結果反映)  
+**ステータス**: 計画段階  
+**総推定工数**: 77時間 (約2-3週間)
+**総タスク数**: 20個

+ 239 - 0
apps/app/src/features/openai/docs/plan/editor-assistant-refactoring-plan.md

@@ -0,0 +1,239 @@
+# GROWI エディターアシスタント改修計画
+
+## 📋 概要
+
+現在のGROWIエディターアシスタントをroo-codeの方式に倣って再実装する改修計画。
+
+### 目的
+- **精度向上**: Search/Replace方式による正確な編集
+- **安全性向上**: Fuzzy matchingによる堅牢な処理
+- **機能拡張**: 複数変更の一括処理
+- **エラーハンドリング強化**: 詳細なフィードバック
+
+## 🔍 現状分析
+
+### 現在のアーキテクチャ
+```
+[AiAssistantSidebar] 
+    ↓ useEditorAssistant
+[Client] → postMessage → [Server: edit/index.ts]
+    ↓ OpenAI Stream
+[LlmResponseStreamProcessor] → jsonrepair → parse
+    ↓ SseDetectedDiff
+[useEditorAssistant] → setDetectedDiff → yText更新
+```
+
+### 課題
+1. **単純置換**: `replace`のみで正確性に欠ける
+2. **エラー処理**: 失敗時の詳細情報不足
+3. **複数変更**: 安全な一括処理ができない
+4. **検索精度**: コンテキストなしの置換で誤変更リスク
+
+## 🎯 改修目標
+
+### roo-code方式の採用
+- **Search/Replace形式**: 正確な検索条件による置換
+- **Fuzzy Matching**: Levenshtein距離による類似度判定
+- **複数diff処理**: 一つのリクエストで複数箇所変更
+- **詳細エラー報告**: 失敗原因と解決策の提示
+
+## 📝 段階別実装計画
+
+### Phase 1: スキーマ・インターフェース更新
+
+#### 1.1 新しいDiffスキーマ
+```typescript
+// apps/app/src/features/openai/interfaces/editor-assistant/llm-response-schemas.ts
+export const LlmEditorAssistantDiffSchema = z.object({
+  search: z.string().describe('正確に検索する内容(空白・インデント含む)'),
+  replace: z.string().describe('置換後の内容'),
+  startLine: z.number().optional().describe('検索開始行番号(1ベース)'),
+  endLine: z.number().optional().describe('検索終了行番号(1ベース)'),
+});
+```
+
+#### 1.2 処理結果型の拡張
+```typescript
+type DiffApplicationResult = {
+  success: boolean;
+  appliedCount: number;
+  failedParts?: Array<{
+    search: string;
+    error: string;
+    suggestions?: string;
+  }>;
+  content?: string;
+};
+```
+
+### Phase 2: Search/Replace処理エンジン
+
+#### 2.1 新しい処理クラス
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/multi-search-replace-processor.ts
+export class MultiSearchReplaceProcessor {
+  private fuzzyThreshold = 0.8; // 類似度閾値
+  private bufferLines = 40; // コンテキスト行数
+  
+  async applyDiffs(
+    originalContent: string,
+    diffs: LlmEditorAssistantDiff[]
+  ): Promise<DiffApplicationResult>
+}
+```
+
+#### 2.2 主要機能
+- **Fuzzy Matching**: `fastest-levenshtein`による類似度計算
+- **Middle-out Search**: 効率的な検索アルゴリズム
+- **インデント保持**: 元のインデントを維持した置換
+- **エラー詳細化**: 失敗原因の具体的な報告
+
+### Phase 3: サーバーサイド統合
+
+#### 3.1 LlmResponseStreamProcessor更新
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/llm-response-stream-processor.ts
+// Search/Replace形式のパース対応
+// 新しいコールバック定義
+```
+
+#### 3.2 edit/index.ts改修
+```typescript
+// apps/app/src/features/openai/server/routes/edit/index.ts
+// プロンプト更新(roo-code形式)
+// 新しい処理エンジンとの統合
+```
+
+### Phase 4: クライアントサイド対応
+
+#### 4.1 useEditorAssistant更新
+```typescript
+// apps/app/src/features/openai/client/services/editor-assistant.tsx
+// 新しいdiff形式への対応
+// エラーハンドリング強化
+```
+
+#### 4.2 UI改善
+- より詳細なエラー表示
+- 部分適用結果の表示
+- 進捗状況の可視化
+
+### Phase 5: プロンプト更新
+
+#### 5.1 roo-code形式の採用
+```
+<<<<<<< SEARCH
+:start_line: (required) 検索開始行番号
+-------
+[正確な検索内容(空白・インデント含む)]
+=======
+[置換後の内容]
+>>>>>>> REPLACE
+```
+
+#### 5.2 指示の詳細化
+- マーカーのエスケープ規則
+- 複数diffブロックの処理
+- エラー時の対処方法
+
+## 🔧 技術実装詳細
+
+### Fuzzy Matching アルゴリズム
+- **ライブラリ**: `fastest-levenshtein`
+- **閾値**: 80%以上で一致判定
+- **検索方式**: Middle-out search(中央から外側へ)
+
+### エラーハンドリング戦略
+```typescript
+type DiffError = {
+  type: 'SEARCH_NOT_FOUND' | 'SIMILARITY_TOO_LOW' | 'MULTIPLE_MATCHES';
+  message: string;
+  details: {
+    searchContent: string;
+    bestMatch?: string;
+    similarity?: number;
+    suggestions: string[];
+  };
+};
+```
+
+### パフォーマンス最適化
+- **メモリ効率**: 大きなファイルでの文字列処理最適化
+- **ストリーミング**: 段階的JSONパース継続
+- **UI更新**: 必要最小限のDOM操作
+
+## 📊 期待効果
+
+| 項目 | 現在 | 改修後 | 改善率 |
+|------|------|--------|--------|
+| **編集精度** | 60-70% | 90-95% | +30-35% |
+| **複雑変更対応** | 困難 | 対応可能 | - |
+| **エラー情報詳細度** | 低 | 高 | +200% |
+| **Fuzzy matching** | なし | あり (0.8閾値) | - |
+| **複数diff処理** | 困難 | 効率的 | - |
+| **テキスト正規化** | なし | roo-code互換 | - |
+| **段階的バリデーション** | なし | あり | - |
+
+## 🔍 roo-code調査結果の反映
+
+### 主要な学習ポイント
+- **テスト戦略**: 1186行の包括的テストケース参考
+- **エラーハンドリング**: 段階的バリデーションと詳細エラーメッセージ
+- **設定管理**: 階層化設定と環境変数対応
+- **文字正規化**: スマートクォート・Unicode正規化
+- **パフォーマンス**: Middle-out検索と早期終了最適化
+
+### 計画への反映
+- **総工数**: 73.5時間 → **77時間** (+3.5時間)
+- **タスク数**: 18個 → **20個** (+2個)
+- **新規追加**: テキスト正規化、設定管理システム
+
+## 🎯 実装優先順位
+
+### 高優先度
+1. ✅ スキーマ・インターフェース更新
+2. ✅ Search/Replace処理エンジン実装
+
+### 中優先度
+3. ⏳ サーバーサイド統合
+4. ⏳ クライアントサイド対応
+
+### 低優先度
+5. ⏳ UI改善・最適化
+6. ⏳ パフォーマンス調整
+
+## 🧪 検証計画
+
+### テスト戦略
+1. **単体テスト**: 処理エンジンの動作確認
+2. **統合テスト**: サーバー・クライアント連携
+3. **E2Eテスト**: 実際のユースケース検証
+4. **パフォーマンステスト**: 大きなファイルでの処理速度
+
+### 品質保証
+- **Fuzzy matching精度**: 各種ケースでの類似度測定
+- **エラーハンドリング**: 異常系での適切な処理
+- **メモリ使用量**: 大きなファイルでのリソース消費
+
+## 📚 参考資料
+
+- [roo-code apply_diff implementation](https://github.com/RooCodeInc/Roo-Code/blob/main/src/core/tools/applyDiffTool.ts)
+- [roo-code multi-search-replace strategy](https://github.com/RooCodeInc/Roo-Code/blob/main/src/core/diff/strategies/multi-search-replace.ts)
+- [roo-code prompts](apps/app/src/features/openai/docs/roo-prompts.md)
+- [roo-code investigation supplement](apps/app/src/features/openai/docs/plan/roo-code-investigation-supplement.md)
+
+## 📝 備考
+
+この改修により、GROWIのエディターアシスタントはroo-codeレベルの堅牢で精密な編集機能を実現し、ユーザーの生産性向上に大きく貢献することが期待される。
+
+**重要な改善点:**
+- **Fuzzy Matching**: 0.8閾値で80%類似度マッチング
+- **文字正規化**: スマートクォート・Unicode対応
+- **段階的バリデーション**: マーカー→内容→適用の3段階検証
+- **詳細エラーハンドリング**: 修正提案付きエラーメッセージ
+- **設定管理**: 環境変数と階層化設定システム
+
+---
+**作成日**: 2025-06-17  
+**更新日**: 2025-06-17  
+**ステータス**: 計画段階

+ 308 - 0
apps/app/src/features/openai/docs/plan/implementation-tasks.md

@@ -0,0 +1,308 @@
+# 実装タスクリスト
+
+## 📋 Phase 1: スキーマ・インターフェース更新
+
+### ✅ 完了タスク
+- [ ] 既存スキーマの分析と理解
+
+### 🎯 実装タスク
+
+#### 1.1 LLM Response Schemas更新
+- [ ] **ファイル**: `apps/app/src/features/openai/interfaces/editor-assistant/llm-response-schemas.ts`
+- [ ] **タスク**: 
+  - [ ] `LlmEditorAssistantDiffSchema`をSearch/Replace形式に更新
+  - [ ] バックワード互換性の確保
+  - [ ] TypeScript型定義の更新
+- [ ] **推定工数**: 2時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 1.2 SSE Schemas更新  
+- [ ] **ファイル**: `apps/app/src/features/openai/interfaces/editor-assistant/sse-schemas.ts`
+- [ ] **タスク**:
+  - [ ] 新しいDiff形式に対応したSSEスキーマ
+  - [ ] エラー詳細情報の追加
+- [ ] **推定工数**: 1時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 1.3 新しい型定義の追加
+- [ ] **ファイル**: `apps/app/src/features/openai/interfaces/editor-assistant/types.ts` (新規)
+- [ ] **タスク**:
+  - [ ] `DiffApplicationResult`型の定義
+  - [ ] `DiffError`型の定義
+  - [ ] `ProcessorConfig`型の定義
+- [ ] **推定工数**: 1時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+---
+
+## 📋 Phase 2: Search/Replace処理エンジン実装
+
+### 🎯 実装タスク
+
+#### 2.1 Fuzzy Matching ユーティリティ
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/fuzzy-matching.ts` (新規)
+- [ ] **タスク**:
+  - [ ] `fastest-levenshtein`の依存関係追加
+  - [ ] `FuzzyMatcher`クラスの実装
+  - [ ] 類似度計算ロジック
+  - [ ] Middle-out検索アルゴリズム
+  - [ ] 文字列正規化機能
+- [ ] **推定工数**: 6時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 2.2 Diff適用エンジン
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/diff-application-engine.ts` (新規)
+- [ ] **タスク**:
+  - [ ] 単一diff適用ロジック
+  - [ ] インデント保持機能
+  - [ ] 行番号管理
+  - [ ] 置換実行ロジック
+- [ ] **推定工数**: 4時間
+- [ ] **担当者**: 未定  
+- [ ] **優先度**: 高
+
+#### 2.3 エラーハンドリング
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/error-handlers.ts` (新規)
+- [ ] **タスク**:
+  - [ ] `ErrorHandler`クラスの実装
+  - [ ] エラー詳細情報の生成
+  - [ ] 推奨アクションの提供
+  - [ ] ログ出力機能
+- [ ] **推定工数**: 3時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+#### 2.4 メイン処理エンジン
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/multi-search-replace-processor.ts` (新規)
+- [ ] **タスク**:
+  - [ ] `MultiSearchReplaceProcessor`クラスの実装
+  - [ ] 複数diff処理ロジック
+  - [ ] バリデーション機能
+  - [ ] パフォーマンス最適化
+  - [ ] 設定管理
+- [ ] **推定工数**: 8時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 2.5 テキスト正規化ユーティリティ
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/text-normalization.ts` (新規)
+- [ ] **タスク**:
+  - [ ] スマートクォート・タイポグラフィ文字の正規化
+  - [ ] Unicode正規化機能(NFC)
+  - [ ] 空白文字の正規化
+  - [ ] roo-code互換の正規化マップ実装
+- [ ] **推定工数**: 2時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 2.6 設定管理システム
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/config.ts` (新規)
+- [ ] **タスク**:
+  - [ ] EditorAssistantConfig型の定義
+  - [ ] 環境変数からの設定読み込み
+  - [ ] デフォルト値の階層化管理
+  - [ ] 設定値のバリデーション
+- [ ] **推定工数**: 1.5時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+#### 2.7 単体テスト
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/__tests__/` (新規ディレクトリ)
+- [ ] **タスク**:
+  - [ ] `fuzzy-matching.test.ts`
+  - [ ] `text-normalization.test.ts`
+  - [ ] `diff-application-engine.test.ts`
+  - [ ] `multi-search-replace-processor.test.ts`
+  - [ ] roo-code互換のテストケース実装
+- [ ] **推定工数**: 8時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+---
+
+## 📋 Phase 3: サーバーサイド統合
+
+### 🎯 実装タスク
+
+#### 3.1 LlmResponseStreamProcessor更新
+- [ ] **ファイル**: `apps/app/src/features/openai/server/services/editor-assistant/llm-response-stream-processor.ts`
+- [ ] **タスク**:
+  - [ ] Search/Replace形式のパース対応
+  - [ ] 新しいprocessor連携
+  - [ ] エラーハンドリング統合
+  - [ ] パフォーマンス最適化
+- [ ] **推定工数**: 5時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 3.2 edit/index.ts更新
+- [ ] **ファイル**: `apps/app/src/features/openai/server/routes/edit/index.ts`
+- [ ] **タスク**:
+  - [ ] プロンプトのroo-code形式更新
+  - [ ] 新しいprocessorとの統合
+  - [ ] エラーレスポンスの改善
+  - [ ] ログ出力の追加
+- [ ] **推定工数**: 4時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+#### 3.3 依存関係の追加
+- [ ] **ファイル**: `apps/app/package.json`
+- [ ] **タスク**:
+  - [ ] `fastest-levenshtein`パッケージの追加
+  - [ ] 型定義ファイルの追加
+- [ ] **推定工数**: 0.5時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 高
+
+---
+
+## 📋 Phase 4: クライアントサイド対応
+
+### 🎯 実装タスク
+
+#### 4.1 useEditorAssistant更新
+- [ ] **ファイル**: `apps/app/src/features/openai/client/services/editor-assistant.tsx`
+- [ ] **タスク**:
+  - [ ] 新しいdiff形式への対応
+  - [ ] エラーハンドリング強化
+  - [ ] 詳細なエラー表示
+  - [ ] 処理状況の可視化
+- [ ] **推定工数**: 6時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+#### 4.2 AiAssistantSidebar更新
+- [ ] **ファイル**: `apps/app/src/features/openai/client/components/AiAssistant/AiAssistantSidebar/AiAssistantSidebar.tsx`
+- [ ] **タスク**:
+  - [ ] 新しいエラー表示UI
+  - [ ] 部分適用結果の表示
+  - [ ] ユーザーフィードバック改善
+- [ ] **推定工数**: 4時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 低
+
+---
+
+## 📋 Phase 5: プロンプト・ドキュメント更新
+
+### 🎯 実装タスク
+
+#### 5.1 プロンプト更新
+- [ ] **ファイル**: `apps/app/src/features/openai/server/routes/edit/index.ts` (instruction関数)
+- [ ] **タスク**:
+  - [ ] roo-code形式の指示追加
+  - [ ] Search/Replaceブロックの説明
+  - [ ] エラー対処方法の記載
+  - [ ] 多言語対応の確認
+- [ ] **推定工数**: 3時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+#### 5.2 ドキュメント更新
+- [ ] **ファイル**: `apps/app/src/features/openai/docs/`
+- [ ] **タスク**:
+  - [ ] README.mdの更新
+  - [ ] API仕様書の更新
+  - [ ] 使用例の追加
+  - [ ] トラブルシューティング
+- [ ] **推定工数**: 2時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 低
+
+---
+
+## 📋 Phase 6: テスト・検証
+
+### 🎯 実装タスク
+
+#### 6.1 統合テスト
+- [ ] **ファイル**: `apps/app/test/integration/editor-assistant/` (新規)
+- [ ] **タスク**:
+  - [ ] サーバー・クライアント連携テスト
+  - [ ] エラーケースの検証
+  - [ ] パフォーマンステスト
+- [ ] **推定工数**: 8時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 中
+
+#### 6.2 E2Eテスト
+- [ ] **ファイル**: `apps/app/playwright/editor-assistant/` (新規)
+- [ ] **タスク**:
+  - [ ] 実際のユースケース検証
+  - [ ] UI操作テスト
+  - [ ] ブラウザ互換性確認
+- [ ] **推定工数**: 6時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 低
+
+#### 6.3 パフォーマンステスト
+- [ ] **ファイル**: `apps/app/test/performance/editor-assistant/` (新規)
+- [ ] **タスク**:
+  - [ ] 大きなファイルでのテスト
+  - [ ] 複数diff処理のベンチマーク
+  - [ ] メモリ使用量の測定
+- [ ] **推定工数**: 4時間
+- [ ] **担当者**: 未定
+- [ ] **優先度**: 低
+
+---
+
+## 📊 進捗管理
+
+### 全体進捗
+- **総タスク数**: 20タスク
+- **完了**: 0タスク (0%)
+- **進行中**: 0タスク (0%)
+- **未着手**: 20タスク (100%)
+
+### Phase別進捗
+| Phase | タスク数 | 完了 | 進捗率 | 推定総工数 |
+|-------|----------|------|--------|------------|
+| Phase 1 | 3 | 0 | 0% | 4時間 |
+| Phase 2 | 7 | 0 | 0% | 30.5時間 |
+| Phase 3 | 3 | 0 | 0% | 9.5時間 |
+| Phase 4 | 2 | 0 | 0% | 10時間 |
+| Phase 5 | 2 | 0 | 0% | 5時間 |
+| Phase 6 | 3 | 0 | 0% | 18時間 |
+| **合計** | **20** | **0** | **0%** | **77時間** |
+
+### 優先度別
+- **高優先度**: 9タスク (50%)
+- **中優先度**: 6タスク (33%)
+- **低優先度**: 3タスク (17%)
+
+### 推定スケジュール
+- **開発期間**: 約2-3週間 (1人稼働)
+- **クリティカルパス**: Phase 1 → Phase 2 → Phase 3
+- **並行可能**: Phase 4以降は部分的に並行実装可能
+
+---
+
+## 🎯 次のアクション
+
+### 即座に着手可能
+1. **Phase 1.1**: LLM Response Schemas更新
+2. **Phase 1.3**: 新しい型定義の追加
+3. **Phase 2.7**: 単体テストの設計
+
+### 依存関係あり
+- Phase 2はPhase 1完了後
+- Phase 3はPhase 2完了後
+- Phase 4はPhase 3完了後
+
+### リスクと対策
+- **技術リスク**: Fuzzy matchingの精度調整
+  - **対策**: 段階的な閾値調整とテスト
+- **互換性リスク**: 既存機能への影響
+  - **対策**: フィーチャーフラグでの段階的移行
+
+---
+**ファイル**: `implementation-tasks.md`  
+**作成日**: 2025-06-17  
+**更新日**: 2025-06-17  
+**ステータス**: 計画段階

+ 252 - 0
apps/app/src/features/openai/docs/plan/roo-code-investigation-supplement.md

@@ -0,0 +1,252 @@
+# roo-code調査結果:計画補強レポート
+
+## 📋 追加調査で判明した重要な知見
+
+### 1. 🧪 テスト戦略の詳細
+
+#### roo-codeのテストアプローチ
+- **包括的なテストカバレッジ**: 1186行の詳細なテストファイル
+- **実際のコード例を使用**: 関数、インデント、タブ/スペース混在等の実用的なテスト
+- **エラーケースの徹底検証**: マーカー検証、シーケンス検証等
+
+#### GROWIに適用すべきテスト戦略
+```typescript
+// 追加すべきテストケース
+describe('Multi-Search-Replace Integration Tests', () => {
+  // 1. 基本的なSearch/Replace
+  it('should handle exact matches')
+  it('should handle fuzzy matches within threshold')
+  
+  // 2. インデント・空白の処理
+  it('should preserve indentation when replacing')
+  it('should handle tab-based indentation')
+  it('should preserve mixed tabs and spaces')
+  
+  // 3. 複数diff処理
+  it('should process multiple diffs in correct order')
+  it('should handle partial failures gracefully')
+  
+  // 4. エラーハンドリング
+  it('should detect malformed marker sequences')
+  it('should provide helpful error messages')
+  it('should suggest fixes for common mistakes')
+  
+  // 5. パフォーマンス
+  it('should handle large files efficiently')
+  it('should complete middle-out search within time limits')
+})
+```
+
+### 2. 🔧 設定管理パターン
+
+#### roo-codeの設定アーキテクチャ
+- **デフォルト値の明確化**: `fuzzyThreshold = 1.0` (完全一致), `bufferLines = 40`
+- **設定の階層化**: デフォルト → コンストラクタ → 環境変数
+- **TypeScript型安全性**: 設定オプションの型定義
+
+#### GROWIでの設定実装案
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/config.ts
+export interface EditorAssistantConfig {
+  fuzzyThreshold: number;      // デフォルト: 0.8 (roo-codeは1.0だが、GROWIは緩める)
+  bufferLines: number;         // デフォルト: 40
+  preserveIndentation: boolean; // デフォルト: true
+  enableMiddleOutSearch: boolean; // デフォルト: true
+  maxDiffBlocks: number;       // デフォルト: 10
+}
+
+export const DEFAULT_CONFIG: EditorAssistantConfig = {
+  fuzzyThreshold: 0.8,
+  bufferLines: 40,
+  preserveIndentation: true,
+  enableMiddleOutSearch: true,
+  maxDiffBlocks: 10,
+};
+
+// 環境変数からの設定読み込み
+export function loadConfigFromEnv(): Partial<EditorAssistantConfig> {
+  return {
+    fuzzyThreshold: parseFloat(process.env.GROWI_EDITOR_ASSISTANT_FUZZY_THRESHOLD || '0.8'),
+    bufferLines: parseInt(process.env.GROWI_EDITOR_ASSISTANT_BUFFER_LINES || '40'),
+    // ...
+  };
+}
+```
+
+### 3. 🛡️ エラーハンドリングの高度化
+
+#### roo-codeのエラーハンドリング特徴
+- **段階的バリデーション**: マーカーシーケンス → 内容検証 → 適用処理
+- **具体的エラーメッセージ**: 行番号、期待値、実際値を含む詳細情報
+- **修正提案**: エスケープ方法、正しい形式例を提示
+
+#### GROWIでの強化されたエラーハンドリング
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/error-types.ts
+export interface DetailedDiffError {
+  type: 'MARKER_SEQUENCE_ERROR' | 'SIMILARITY_TOO_LOW' | 'MULTIPLE_MATCHES' | 'CONTENT_ERROR';
+  message: string;
+  line?: number;
+  details: {
+    searchContent: string;
+    bestMatch?: string;
+    similarity?: number;
+    suggestions: string[];
+    correctFormat?: string;
+  };
+}
+
+export class EnhancedErrorHandler {
+  static createMarkerSequenceError(found: string, expected: string, line: number): DetailedDiffError {
+    return {
+      type: 'MARKER_SEQUENCE_ERROR',
+      message: `Invalid marker '${found}' at line ${line}. Expected: ${expected}`,
+      line,
+      details: {
+        searchContent: found,
+        suggestions: [
+          'Check marker sequence: <<<<<<< SEARCH → ======= → >>>>>>> REPLACE',
+          'Escape special markers in content with backslash (\\)',
+          'Ensure no extra or missing separators'
+        ],
+        correctFormat: `<<<<<<< SEARCH\n:start_line: X\n-------\n[search content]\n=======\n[replace content]\n>>>>>>> REPLACE`
+      }
+    };
+  }
+}
+```
+
+### 4. 🎛️ 正規化とファジーマッチング
+
+#### roo-codeの文字正規化
+- **スマートクォート対応**: `\u201C\u201D` → `"`, `\u2018\u2019` → `'`
+- **タイポグラフィ文字**: `\u2026` → `...`, `\u2014` → `-`
+- **空白正規化**: 連続空白 → 単一空白
+
+#### GROWIでの実装
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/text-normalization.ts
+import { NORMALIZATION_MAPS } from './constants';
+
+export function normalizeForFuzzyMatch(text: string): string {
+  return text
+    .replace(/[\u201C\u201D]/g, '"')  // スマートダブルクォート
+    .replace(/[\u2018\u2019]/g, "'")  // スマートシングルクォート
+    .replace(/\u2026/g, '...')        // 省略記号
+    .replace(/\u2014/g, '-')          // emダッシュ
+    .replace(/\u2013/g, '-')          // enダッシュ
+    .replace(/\u00A0/g, ' ')          // ノンブレーキングスペース
+    .normalize('NFC');                // Unicode正規化
+}
+```
+
+### 5. 📈 パフォーマンス最適化
+
+#### roo-codeのパフォーマンス戦略
+- **Middle-out検索**: 中央から外側への効率的な検索アルゴリズム
+- **早期終了**: 閾値以上の一致が見つかったら検索停止
+- **メモリ効率**: 必要最小限の文字列操作
+
+#### GROWIでの最適化実装
+```typescript
+// パフォーマンス最適化された検索
+private findBestMatchOptimized(
+  lines: string[],
+  searchChunk: string,
+  startIndex: number,
+  endIndex: number
+): MatchResult {
+  const searchLines = searchChunk.split(/\r?\n/);
+  const searchLength = searchLines.length;
+  
+  // 早期終了条件: 完全一致が見つかったら即座に返す
+  let bestScore = 0;
+  let bestMatch: MatchResult | null = null;
+  
+  // Middle-out検索の実装
+  const midPoint = Math.floor((startIndex + endIndex) / 2);
+  for (let offset = 0; offset <= Math.floor((endIndex - startIndex) / 2); offset++) {
+    // 左側チェック
+    if (midPoint - offset >= startIndex) {
+      const similarity = this.calculateSimilarity(/* ... */);
+      if (similarity === 1.0) return { /* 完全一致 */ };
+      if (similarity > bestScore) {
+        bestScore = similarity;
+        bestMatch = { /* 結果 */ };
+      }
+    }
+    
+    // 右側チェック
+    if (midPoint + offset <= endIndex - searchLength) {
+      // 同様の処理
+    }
+    
+    // 閾値を超えた場合の早期終了
+    if (bestScore >= this.fuzzyThreshold) break;
+  }
+  
+  return bestMatch || { found: false, score: 0 };
+}
+```
+
+## 🔄 計画への反映事項
+
+### 1. 実装タスクの追加・修正
+
+#### Phase 2への追加タスク:
+- **2.5 テキスト正規化ユーティリティ** (2時間)
+  - スマートクォート、タイポグラフィ文字の正規化
+  - Unicode正規化機能
+  
+- **2.6 設定管理システム** (1.5時間)
+  - 環境変数からの設定読み込み
+  - デフォルト値の定義
+
+#### Phase 6への追加テスト:
+- **6.4 詳細エラーハンドリングテスト** (3時間)
+  - マーカーシーケンス検証
+  - エラーメッセージの内容確認
+  
+- **6.5 パフォーマンステスト** (2時間)
+  - 大きなファイルでの処理速度測定
+  - メモリ使用量の確認
+
+### 2. 技術仕様の精密化
+
+#### Fuzzy Matching閾値:
+- **roo-code**: 1.0 (完全一致のみ)
+- **GROWI**: 0.8 (80%の類似度) - より寛容な設定
+
+#### エラーメッセージ:
+- roo-codeと同レベルの詳細なエラー情報
+- 日本語でのわかりやすい説明
+- 修正方法の具体的な提案
+
+### 3. 見積もり工数の調整
+
+| フェーズ | 当初見積もり | 調整後見積もり | 差分 |
+|---------|------------|--------------|------|
+| Phase 2 | 27時間 | 30.5時間 | +3.5時間 |
+| Phase 6 | 18時間 | 23時間 | +5時間 |
+| **合計** | **73.5時間** | **82時間** | **+8.5時間** |
+
+## 🎯 次のアクションアイテム
+
+### 高優先度
+1. ✅ **テスト仕様の詳細化**: roo-codeのテストパターンを参考にした包括的テスト計画
+2. ✅ **エラーハンドリング強化**: 段階的バリデーションと詳細エラーメッセージ
+3. ✅ **設定管理システム**: 環境変数対応と階層化設定
+
+### 中優先度
+4. ⏳ **パフォーマンス最適化**: Middle-out検索と早期終了の実装
+5. ⏳ **文字正規化**: Unicode正規化とスマートクォート対応
+
+### 低優先度
+6. ⏳ **監視・ログ**: 処理時間とメモリ使用量の監視機能
+
+---
+
+この調査により、GROWIのエディターアシスタントをroo-codeレベルの堅牢性と精度を持つシステムに改修するための、より具体的で実用的な計画が完成しました。
+
+**作成日**: 2025-06-17  
+**関連ファイル**: `editor-assistant-refactoring-plan.md`, `technical-implementation-details.md`, `implementation-tasks.md`

+ 530 - 0
apps/app/src/features/openai/docs/plan/technical-implementation-details.md

@@ -0,0 +1,530 @@
+# 技術実装詳細
+
+## 🏗️ アーキテクチャ変更
+
+### 現在のフロー
+```mermaid
+graph TD
+    A[User Input] --> B[useEditorAssistant.postMessage]
+    B --> C[Server: edit/index.ts]
+    C --> D[OpenAI Stream]
+    D --> E[LlmResponseStreamProcessor]
+    E --> F[jsonrepair + parse]
+    F --> G[SseDetectedDiff]
+    G --> H[useEditorAssistant.processMessage]
+    H --> I[setDetectedDiff]
+    I --> J[yText更新]
+```
+
+### 改修後のフロー
+```mermaid
+graph TD
+    A[User Input] --> B[useEditorAssistant.postMessage]
+    B --> C[Server: edit/index.ts]
+    C --> D[OpenAI Stream with Search/Replace]
+    D --> E[LlmResponseStreamProcessor]
+    E --> F[jsonrepair + parse Search/Replace blocks]
+    F --> G[MultiSearchReplaceProcessor]
+    G --> H[Fuzzy Matching + Apply Diffs]
+    H --> I[DiffApplicationResult]
+    I --> J[SseDetectedDiff with Results]
+    J --> K[useEditorAssistant.processMessage]
+    K --> L[Enhanced Error Handling]
+    L --> M[yText更新 with Validation]
+```
+
+## 📦 ファイル構成
+
+### 新規作成ファイル
+```
+apps/app/src/features/openai/server/services/editor-assistant/
+├── multi-search-replace-processor.ts          # メイン処理エンジン
+├── fuzzy-matching.ts                          # 類似度計算ユーティリティ
+├── diff-application-engine.ts                 # 差分適用ロジック
+└── error-handlers.ts                          # エラーハンドリング
+```
+
+### 更新対象ファイル
+```
+apps/app/src/features/openai/
+├── interfaces/editor-assistant/
+│   ├── llm-response-schemas.ts                # Diffスキーマ更新
+│   └── sse-schemas.ts                         # SSEスキーマ更新
+├── server/
+│   ├── routes/edit/index.ts                   # プロンプト・処理統合
+│   └── services/editor-assistant/
+│       └── llm-response-stream-processor.ts   # Search/Replace対応
+└── client/services/
+    └── editor-assistant.tsx                   # クライアント対応
+```
+
+## 🔍 核心技術実装
+
+### 1. MultiSearchReplaceProcessor
+
+```typescript
+export class MultiSearchReplaceProcessor {
+  private fuzzyThreshold: number = 0.8;
+  private bufferLines: number = 40;
+
+  constructor(config?: ProcessorConfig) {
+    this.fuzzyThreshold = config?.fuzzyThreshold ?? 0.8;
+    this.bufferLines = config?.bufferLines ?? 40;
+  }
+
+  async applyDiffs(
+    originalContent: string,
+    diffs: LlmEditorAssistantDiff[]
+  ): Promise<DiffApplicationResult> {
+    // 行終端の検出
+    const lineEnding = originalContent.includes('\r\n') ? '\r\n' : '\n';
+    let resultLines = originalContent.split(/\r?\n/);
+    let delta = 0;
+    let appliedCount = 0;
+    const failedParts: DiffError[] = [];
+
+    // startLineでソート
+    const sortedDiffs = diffs
+      .map((diff, index) => ({ ...diff, originalIndex: index }))
+      .sort((a, b) => (a.startLine || 0) - (b.startLine || 0));
+
+    for (const diff of sortedDiffs) {
+      const result = await this.applySingleDiff(
+        resultLines, 
+        diff, 
+        delta
+      );
+      
+      if (result.success) {
+        resultLines = result.updatedLines;
+        delta += result.lineDelta;
+        appliedCount++;
+      } else {
+        failedParts.push(result.error);
+      }
+    }
+
+    return {
+      success: appliedCount > 0,
+      appliedCount,
+      failedParts: failedParts.length > 0 ? failedParts : undefined,
+      content: appliedCount > 0 ? resultLines.join(lineEnding) : undefined,
+    };
+  }
+
+  private async applySingleDiff(
+    lines: string[],
+    diff: LlmEditorAssistantDiff,
+    delta: number
+  ): Promise<SingleDiffResult> {
+    // バリデーション
+    if (!diff.search.trim()) {
+      return {
+        success: false,
+        error: {
+          type: 'EMPTY_SEARCH',
+          message: '検索内容が空です',
+          details: { searchContent: diff.search, suggestions: [] }
+        }
+      };
+    }
+
+    // 検索実行
+    const searchResult = this.findBestMatch(lines, diff.search, diff.startLine, delta);
+    
+    if (!searchResult.found) {
+      return {
+        success: false,
+        error: this.createSearchError(diff.search, searchResult)
+      };
+    }
+
+    // 置換実行
+    return this.applyReplacement(lines, diff, searchResult);
+  }
+}
+```
+
+### 2. Fuzzy Matching実装
+
+```typescript
+import { distance } from 'fastest-levenshtein';
+
+export class FuzzyMatcher {
+  private threshold: number;
+
+  constructor(threshold: number = 0.8) {
+    this.threshold = threshold;
+  }
+
+  calculateSimilarity(original: string, search: string): number {
+    if (search === '') return 0;
+    
+    // 正規化(スマートクォート等の処理)
+    const normalizedOriginal = this.normalizeString(original);
+    const normalizedSearch = this.normalizeString(search);
+
+    if (normalizedOriginal === normalizedSearch) return 1;
+
+    // Levenshtein距離による類似度計算
+    const dist = distance(normalizedOriginal, normalizedSearch);
+    const maxLength = Math.max(normalizedOriginal.length, normalizedSearch.length);
+    
+    return 1 - (dist / maxLength);
+  }
+
+  findBestMatch(
+    lines: string[],
+    searchChunk: string,
+    startIndex: number = 0,
+    endIndex?: number
+  ): MatchResult {
+    const searchLines = searchChunk.split(/\r?\n/);
+    const searchLength = searchLines.length;
+    const actualEndIndex = endIndex ?? lines.length;
+
+    let bestScore = 0;
+    let bestMatchIndex = -1;
+    let bestMatchContent = '';
+
+    // Middle-out検索
+    const midPoint = Math.floor((startIndex + actualEndIndex) / 2);
+    let leftIndex = midPoint;
+    let rightIndex = midPoint + 1;
+
+    while (leftIndex >= startIndex || rightIndex <= actualEndIndex - searchLength) {
+      // 左側検索
+      if (leftIndex >= startIndex) {
+        const chunk = lines.slice(leftIndex, leftIndex + searchLength).join('\n');
+        const similarity = this.calculateSimilarity(chunk, searchChunk);
+        
+        if (similarity > bestScore) {
+          bestScore = similarity;
+          bestMatchIndex = leftIndex;
+          bestMatchContent = chunk;
+        }
+        leftIndex--;
+      }
+
+      // 右側検索
+      if (rightIndex <= actualEndIndex - searchLength) {
+        const chunk = lines.slice(rightIndex, rightIndex + searchLength).join('\n');
+        const similarity = this.calculateSimilarity(chunk, searchChunk);
+        
+        if (similarity > bestScore) {
+          bestScore = similarity;
+          bestMatchIndex = rightIndex;
+          bestMatchContent = chunk;
+        }
+        rightIndex++;
+      }
+    }
+
+    return {
+      found: bestScore >= this.threshold,
+      score: bestScore,
+      index: bestMatchIndex,
+      content: bestMatchContent,
+      threshold: this.threshold
+    };
+  }
+
+  private normalizeString(str: string): string {
+    return str
+      .replace(/[\u2018\u2019]/g, "'")  // スマートクォート
+      .replace(/[\u201C\u201D]/g, '"')  // スマートダブルクォート
+      .replace(/\u2013/g, '-')         // en dash
+      .replace(/\u2014/g, '--')        // em dash
+      .normalize('NFC');
+  }
+}
+```
+
+### 3. エラーハンドリング強化
+
+```typescript
+export interface DiffError {
+  type: 'SEARCH_NOT_FOUND' | 'SIMILARITY_TOO_LOW' | 'MULTIPLE_MATCHES' | 'EMPTY_SEARCH';
+  message: string;
+  details: {
+    searchContent: string;
+    bestMatch?: string;
+    similarity?: number;
+    suggestions: string[];
+    lineRange?: string;
+  };
+}
+
+export class ErrorHandler {
+  static createSearchError(
+    searchContent: string,
+    matchResult: MatchResult,
+    startLine?: number
+  ): DiffError {
+    const lineRange = startLine ? ` at line: ${startLine}` : '';
+    const similarityPercent = Math.floor((matchResult.score || 0) * 100);
+    const thresholdPercent = Math.floor(matchResult.threshold * 100);
+
+    return {
+      type: 'SIMILARITY_TOO_LOW',
+      message: `No sufficiently similar match found${lineRange} (${similarityPercent}% similar, needs ${thresholdPercent}%)`,
+      details: {
+        searchContent,
+        bestMatch: matchResult.content || '(no match)',
+        similarity: matchResult.score,
+        suggestions: [
+          'Use the read_file tool to get the latest content',
+          'Check for whitespace and indentation differences',
+          'Verify the search content matches exactly',
+          `Consider lowering similarity threshold (currently ${thresholdPercent}%)`
+        ],
+        lineRange: startLine ? `starting at line ${startLine}` : 'start to end'
+      }
+    };
+  }
+}
+```
+
+### 4. 文字正規化システム
+
+roo-codeと同レベルの文字正規化機能を実装:
+
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/text-normalization.ts
+export const NORMALIZATION_MAPS = {
+  // スマートクォートの正規化
+  SMART_QUOTES: {
+    '\u201C': '"', // 左ダブルクォート
+    '\u201D': '"', // 右ダブルクォート
+    '\u2018': "'", // 左シングルクォート
+    '\u2019': "'", // 右シングルクォート
+  },
+  // タイポグラフィ文字の正規化
+  TYPOGRAPHIC: {
+    '\u2026': '...', // 省略記号
+    '\u2014': '-',   // emダッシュ
+    '\u2013': '-',   // enダッシュ
+    '\u00A0': ' ',   // ノンブレーキングスペース
+  },
+};
+
+export function normalizeForFuzzyMatch(text: string): string {
+  return text
+    .replace(/[\u201C\u201D]/g, '"')
+    .replace(/[\u2018\u2019]/g, "'")
+    .replace(/\u2026/g, '...')
+    .replace(/\u2014/g, '-')
+    .replace(/\u2013/g, '-')
+    .replace(/\u00A0/g, ' ')
+    .normalize('NFC'); // Unicode正規化
+}
+```
+
+### 5. 段階的バリデーションシステム
+
+roo-codeのバリデーション戦略を採用:
+
+```typescript
+// マーカーシーケンス検証 → 内容検証 → 適用処理
+export class ValidationPipeline {
+  static validateDiffContent(diffContent: string): ValidationResult {
+    // 1. マーカーシーケンス検証
+    const markerResult = this.validateMarkerSequencing(diffContent);
+    if (!markerResult.success) return markerResult;
+    
+    // 2. 内容検証
+    const contentResult = this.validateContent(diffContent);
+    if (!contentResult.success) return contentResult;
+    
+    // 3. 構文検証
+    const syntaxResult = this.validateSyntax(diffContent);
+    return syntaxResult;
+  }
+  
+  private static validateMarkerSequencing(content: string): ValidationResult {
+    // roo-codeと同じマーカー検証ロジック
+    // <<<<<<< SEARCH → ======= → >>>>>>> REPLACE の順序チェック
+  }
+}
+```
+
+### 6. 高度なエラーハンドリング
+
+roo-codeレベルの詳細なエラーハンドリング実装:
+
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/enhanced-error-handler.ts
+export interface DetailedDiffError {
+  type: 'MARKER_SEQUENCE_ERROR' | 'SIMILARITY_TOO_LOW' | 'MULTIPLE_MATCHES' | 'CONTENT_ERROR';
+  message: string;
+  line?: number;
+  details: {
+    searchContent: string;
+    bestMatch?: string;
+    similarity?: number;
+    suggestions: string[];
+    correctFormat?: string;
+    lineRange?: string;
+  };
+}
+
+export class EnhancedErrorHandler {
+  static createMarkerSequenceError(found: string, expected: string, line: number): DetailedDiffError {
+    return {
+      type: 'MARKER_SEQUENCE_ERROR',
+      message: `マーカーシーケンスエラー: 行${line}で '${found}' が見つかりました。期待値: ${expected}`,
+      line,
+      details: {
+        searchContent: found,
+        suggestions: [
+          'マーカーの順序を確認: <<<<<<< SEARCH → ======= → >>>>>>> REPLACE',
+          'コンテンツ内の特殊マーカーをバックスラッシュ(\\)でエスケープ',
+          '余分なセパレータや不足しているセパレータがないか確認'
+        ],
+        correctFormat: `<<<<<<< SEARCH\n:start_line: X\n-------\n[検索内容]\n=======\n[置換内容]\n>>>>>>> REPLACE`
+      }
+    };
+  }
+
+  static createSimilarityError(
+    searchContent: string,
+    bestMatch: string,
+    similarity: number,
+    threshold: number,
+    startLine?: number
+  ): DetailedDiffError {
+    const lineRange = startLine ? ` (開始行: ${startLine})` : '';
+    const similarityPercent = Math.floor(similarity * 100);
+    const thresholdPercent = Math.floor(threshold * 100);
+
+    return {
+      type: 'SIMILARITY_TOO_LOW',
+      message: `類似度が不十分${lineRange}: ${similarityPercent}% (必要: ${thresholdPercent}%)`,
+      details: {
+        searchContent,
+        bestMatch,
+        similarity,
+        suggestions: [
+          'read_fileツールで最新のファイル内容を確認',
+          '空白やインデントの違いを確認',
+          '検索内容が正確に一致しているか検証',
+          `類似度の閾値を下げることを検討 (現在: ${thresholdPercent}%)`
+        ],
+        lineRange: startLine ? `行${startLine}から開始` : '全体を対象'
+      }
+    };
+  }
+}
+```
+
+### 7. 設定管理とカスタマイズ
+
+```typescript
+// apps/app/src/features/openai/server/services/editor-assistant/config.ts
+export interface EditorAssistantConfig {
+  fuzzyThreshold: number;           // デフォルト: 0.8 (80%)
+  bufferLines: number;              // デフォルト: 40
+  preserveIndentation: boolean;     // デフォルト: true
+  enableMiddleOutSearch: boolean;   // デフォルト: true
+  maxDiffBlocks: number;           // デフォルト: 10
+  stripLineNumbers: boolean;       // デフォルト: true
+  enableAggressiveMatching: boolean; // デフォルト: false
+}
+
+export const DEFAULT_CONFIG: EditorAssistantConfig = {
+  fuzzyThreshold: 0.8,              // roo-codeより緩い設定 (1.0 → 0.8)
+  bufferLines: 40,
+  preserveIndentation: true,
+  enableMiddleOutSearch: true,
+  maxDiffBlocks: 10,
+  stripLineNumbers: true,
+  enableAggressiveMatching: false,
+};
+
+// 環境変数による設定のオーバーライド
+export function loadConfig(): EditorAssistantConfig {
+  const envConfig: Partial<EditorAssistantConfig> = {
+    fuzzyThreshold: parseFloat(process.env.GROWI_EDITOR_ASSISTANT_FUZZY_THRESHOLD || '0.8'),
+    bufferLines: parseInt(process.env.GROWI_EDITOR_ASSISTANT_BUFFER_LINES || '40'),
+    maxDiffBlocks: parseInt(process.env.GROWI_EDITOR_ASSISTANT_MAX_DIFF_BLOCKS || '10'),
+  };
+
+  return { ...DEFAULT_CONFIG, ...envConfig };
+}
+```
+
+## 🎛️ 設定とカスタマイズ
+
+### ProcessorConfig
+```typescript
+interface ProcessorConfig {
+  fuzzyThreshold?: number;      // デフォルト: 0.8 (80%)
+  bufferLines?: number;         // デフォルト: 40
+  preserveIndentation?: boolean; // デフォルト: true
+  stripLineNumbers?: boolean;    // デフォルト: true
+  enableAggressiveMatching?: boolean; // デフォルト: false
+}
+```
+
+### 環境変数での調整
+```typescript
+const config: ProcessorConfig = {
+  fuzzyThreshold: parseFloat(process.env.EDITOR_ASSISTANT_FUZZY_THRESHOLD || '0.8'),
+  bufferLines: parseInt(process.env.EDITOR_ASSISTANT_BUFFER_LINES || '40'),
+  preserveIndentation: process.env.EDITOR_ASSISTANT_PRESERVE_INDENT !== 'false',
+};
+```
+
+## 🧪 テスト戦略
+
+### 単体テスト
+```typescript
+describe('MultiSearchReplaceProcessor', () => {
+  it('should handle exact matches', async () => {
+    const processor = new MultiSearchReplaceProcessor();
+    const result = await processor.applyDiffs(originalContent, [
+      { search: 'function test() {', replace: 'function newTest() {' }
+    ]);
+    expect(result.success).toBe(true);
+    expect(result.appliedCount).toBe(1);
+  });
+
+  it('should handle fuzzy matches within threshold', async () => {
+    // スペースやインデントが微妙に違う場合のテスト
+  });
+
+  it('should reject matches below threshold', async () => {
+    // 類似度が低すぎる場合のエラーハンドリングテスト
+  });
+});
+```
+
+### 統合テスト
+```typescript
+describe('Editor Assistant Integration', () => {
+  it('should process multiple diffs in correct order', async () => {
+    // 複数の変更を正しい順序で処理することを確認
+  });
+
+  it('should handle partial failures gracefully', async () => {
+    // 一部の変更が失敗した場合の処理を確認
+  });
+});
+```
+
+## 📈 パフォーマンス考慮
+
+### メモリ最適化
+- 大きなファイルでの文字列処理の最適化
+- 不要なデータの早期解放
+- ストリーミング処理の継続
+
+### CPU最適化
+- Middle-out検索による効率化
+- 類似度計算の最適化
+- 早期終了条件の設定
+
+---
+**ファイル**: `technical-implementation-details.md`  
+**作成日**: 2025-06-17  
+**関連**: `editor-assistant-refactoring-plan.md`