Created
August 3, 2025 13:18
-
-
Save kengonakajima/df762399179eac4b363b9ca16d415419 to your computer and use it in GitHub Desktop.
cipher のコードを見る
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cipher ナレッジグラフ EntityTypes 詳細仕様書 | |
| このドキュメントでは、Cipherのナレッジグラフで使用されるすべてのEntityType(エンティティタイプ)について、その概要と目的を詳しく説明します。 | |
| ================================================================================ | |
| # 1. プログラミング構造エンティティ | |
| ================================================================================ | |
| ## Function(関数) | |
| **概要**: プログラムの関数、メソッド、プロシージャを表すエンティティ | |
| **目的**: | |
| - コード内の実行可能な単位を識別 | |
| - 関数間の呼び出し関係を追跡 | |
| - 依存関係の分析を可能にする | |
| **抽出パターン**: | |
| - `function functionName()` | |
| - `def function_name():` | |
| - `const functionName = () => {}` | |
| - メソッド定義パターン | |
| ## Class(クラス) | |
| **概要**: オブジェクト指向プログラミングのクラス定義を表すエンティティ | |
| **目的**: | |
| - コードの構造化された設計を記録 | |
| - 継承関係(EXTENDS)の追跡 | |
| - インターフェース実装(IMPLEMENTS)の管理 | |
| **抽出パターン**: | |
| - `class ClassName` | |
| - `public class ClassName` | |
| - `export class ClassName` | |
| ## Variable(変数) | |
| **概要**: プログラム内の変数、定数、フィールドを表すエンティティ | |
| **目的**: | |
| - データフローの追跡 | |
| - 状態管理の理解 | |
| - 変数のスコープと使用箇所の記録 | |
| **抽出パターン**: | |
| - `const/let/var variableName` | |
| - フィールド宣言 | |
| - パラメータ定義 | |
| ## Module(モジュール) | |
| **概要**: コードのモジュール、パッケージ、名前空間を表すエンティティ | |
| **目的**: | |
| - コードの論理的な組織構造を記録 | |
| - インポート/エクスポート関係の管理 | |
| - 依存関係グラフの構築 | |
| **関係性**: CONTAINS(他のエンティティを含む) | |
| ================================================================================ | |
| # 2. ファイルシステムエンティティ | |
| ================================================================================ | |
| ## File(ファイル) | |
| **概要**: ソースコードファイル、設定ファイル、ドキュメントファイルを表すエンティティ | |
| **目的**: | |
| - プロジェクト構造の記録 | |
| - ファイル間の依存関係追跡 | |
| - コードの物理的な配置の管理 | |
| **抽出パターン**: | |
| - ファイルパス(.js, .ts, .py, .java など) | |
| - 相対パス、絶対パス | |
| - importステートメント内のパス | |
| ## Project(プロジェクト) | |
| **概要**: ソフトウェアプロジェクト全体を表す最上位エンティティ | |
| **目的**: | |
| - プロジェクトレベルの構造化 | |
| - 複数モジュールの統合管理 | |
| - プロジェクト間の依存関係記録 | |
| **関係性**: | |
| - CONTAINS(ファイル、モジュール) | |
| - DEPENDS_ON(他のプロジェクト) | |
| ================================================================================ | |
| # 3. 技術スタックエンティティ | |
| ================================================================================ | |
| ## Technology(技術) | |
| **概要**: プログラミング言語、フレームワーク、ライブラリを表すエンティティ | |
| **目的**: | |
| - 技術スタックの記録 | |
| - 技術間の互換性管理 | |
| - プロジェクトの技術的特徴の追跡 | |
| **例**: | |
| - 言語: JavaScript, Python, TypeScript, Java, C++ | |
| - フレームワーク: React, Vue, Angular, Express, Django | |
| - ツール: Docker, Kubernetes, Git | |
| ## Tool(ツール) | |
| **概要**: 開発ツール、ビルドツール、デプロイツールを表すエンティティ | |
| **目的**: | |
| - 開発環境の記録 | |
| - ビルドプロセスの理解 | |
| - CI/CDパイプラインの管理 | |
| **例**: | |
| - ビルドツール: npm, yarn, webpack, babel | |
| - バージョン管理: Git, SVN | |
| - コンテナ: Docker, Kubernetes | |
| ## Database(データベース) | |
| **概要**: データベースシステムとその構成要素を表すエンティティ | |
| **目的**: | |
| - データ永続化層の記録 | |
| - データベーススキーマの管理 | |
| - データフローの追跡 | |
| **例**: MongoDB, PostgreSQL, Redis, MySQL | |
| ================================================================================ | |
| # 4. 概念的エンティティ | |
| ================================================================================ | |
| ## Concept(概念) | |
| **概要**: プログラミング概念、デザインパターン、アルゴリズムを表すエンティティ | |
| **目的**: | |
| - 抽象的な知識の記録 | |
| - ベストプラクティスの管理 | |
| - 概念間の関連付け | |
| **例**: | |
| - デザインパターン: Singleton, Factory, Observer | |
| - アルゴリズム: QuickSort, BinarySearch | |
| - 概念: REST API, Microservices, Event-driven | |
| ## Command(コマンド) | |
| **概要**: CLIコマンド、シェルコマンド、操作手順を表すエンティティ | |
| **目的**: | |
| - 操作手順の記録 | |
| - 自動化スクリプトの管理 | |
| - コマンドライン知識の保存 | |
| **例**: | |
| - `npm install` | |
| - `git commit` | |
| - `docker run` | |
| ================================================================================ | |
| # 5. 組織・人的エンティティ | |
| ================================================================================ | |
| ## Person(人物) | |
| **概要**: 開発者、コントリビューター、ユーザーを表すエンティティ | |
| **目的**: | |
| - コード作成者の記録 | |
| - コラボレーション関係の追跡 | |
| - 責任範囲の明確化 | |
| **関係性**: | |
| - CREATES(コードを作成) | |
| - MAINTAINS(メンテナンス) | |
| - WORKS_WITH(協力関係) | |
| ## Organization(組織) | |
| **概要**: 企業、団体、オープンソースコミュニティを表すエンティティ | |
| **目的**: | |
| - プロジェクトの所有関係記録 | |
| - ライセンスと権利の管理 | |
| - コミュニティ構造の理解 | |
| **例**: Google, Microsoft, Apache Foundation | |
| ## Team(チーム) | |
| **概要**: 開発チーム、プロジェクトグループを表すエンティティ | |
| **目的**: | |
| - チーム構造の記録 | |
| - 責任範囲の分割 | |
| - コラボレーションパターンの追跡 | |
| **関係性**: BELONGS_TO(組織)、CONTAINS(人物) | |
| ================================================================================ | |
| # 6. API・サービスエンティティ | |
| ================================================================================ | |
| ## API(API) | |
| **概要**: REST API、GraphQL、gRPCなどのAPIエンドポイントを表すエンティティ | |
| **目的**: | |
| - APIインターフェースの記録 | |
| - エンドポイント間の関係管理 | |
| - API依存関係の追跡 | |
| **関係性**: EXPOSES(機能を公開)、USES(他のAPIを使用) | |
| ## Service(サービス) | |
| **概要**: マイクロサービス、Webサービス、バックエンドサービスを表すエンティティ | |
| **目的**: | |
| - サービス指向アーキテクチャの記録 | |
| - サービス間通信の管理 | |
| - デプロイメント構成の追跡 | |
| **関係性**: CALLS(他のサービスを呼び出す)、DEPENDS_ON | |
| ## Repository(リポジトリ) | |
| **概要**: Gitリポジトリ、コードリポジトリを表すエンティティ | |
| **目的**: | |
| - ソースコード管理構造の記録 | |
| - ブランチ戦略の管理 | |
| - コード履歴の追跡 | |
| **関係性**: CONTAINS(コード資産)、FORK_OF(フォーク関係) | |
| ================================================================================ | |
| # 7. エンティティ間の主要な関係タイプ | |
| ================================================================================ | |
| ## 依存関係 | |
| - **DEPENDS_ON**: 依存関係(ModuleがLibraryに依存) | |
| - **USES**: 使用関係(FunctionがVariableを使用) | |
| - **IMPORTS**: インポート関係(FileがModuleをインポート) | |
| ## 構造関係 | |
| - **CONTAINS**: 包含関係(ClassがFunctionを含む) | |
| - **BELONGS_TO**: 所属関係(FileがProjectに所属) | |
| - **EXTENDS**: 継承関係(ClassがClassを継承) | |
| - **IMPLEMENTS**: 実装関係(ClassがInterfaceを実装) | |
| ## 実行関係 | |
| - **CALLS**: 呼び出し関係(FunctionがFunctionを呼び出す) | |
| - **CREATES**: 作成関係(FunctionがObjectを作成) | |
| - **MODIFIES**: 変更関係(FunctionがVariableを変更) | |
| ## 協力関係 | |
| - **WORKS_WITH**: 協力関係(PersonがPersonと協力) | |
| - **MAINTAINS**: メンテナンス関係(PersonがProjectを管理) | |
| - **REFERENCES**: 参照関係(DocumentがConceptを参照) | |
| ================================================================================ | |
| # 8. エンティティ抽出の技術的詳細 | |
| ================================================================================ | |
| ## 抽出方法 | |
| 1. **LLMベース抽出**: | |
| - 自然言語処理による文脈理解 | |
| - 複雑な関係性の推論 | |
| - 曖昧な表現の解釈 | |
| 2. **正規表現ベース抽出**: | |
| - 高速で確実な既知パターンの抽出 | |
| - プログラミング言語固有の構文認識 | |
| - フォールバック機構として機能 | |
| ## 信頼度スコア | |
| 各エンティティには0.0-1.0の信頼度スコアが付与され: | |
| - 0.9以上: 明確に識別されたエンティティ | |
| - 0.7-0.9: 高い確率で正しいエンティティ | |
| - 0.5-0.7: コンテキストから推測されたエンティティ | |
| - 0.5未満: 不確実だが可能性のあるエンティティ | |
| ================================================================================ | |
| # まとめ | |
| ================================================================================ | |
| Cipherのナレッジグラフは、これらの多様なEntityTypeを使用して、ソフトウェア開発に関する包括的な知識構造を構築します。各エンティティタイプは特定の目的を持ち、相互に関連付けられることで、コードの理解、依存関係の分析、知識の発見を可能にします。 | |
| この柔軟なエンティティシステムにより、Cipherは単なるコード解析を超えて、プロジェクト全体の知識マネジメントシステムとして機能します。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cipher Prompts Collection | |
| This file contains all the prompts used in Cipher, organized by category and purpose. | |
| ================================================================================ | |
| # 1. SYSTEM PROMPTS AND CONFIGURATIONS | |
| ================================================================================ | |
| ## Default System Prompt (memAgent/cipher.yml) | |
| ``` | |
| You are an AI programming assistant focused on coding and reasoning tasks. You excel at: | |
| - Writing clean, efficient code | |
| - Debugging and problem-solving | |
| - Code review and optimization | |
| - Explaining complex technical concepts | |
| - Reasoning through programming challenges | |
| ``` | |
| ## Memory Search Tool Instruction (cipher-advanced-prompt.yml) | |
| ``` | |
| Use the memory search tool to retrieve facts, code, or context from previous interactions. Always search memory before answering if relevant. | |
| ``` | |
| ## Reasoning Patterns Tool Instruction (cipher-advanced-prompt.yml) | |
| ``` | |
| Use the reasoning patterns tool to find and apply problem-solving strategies from past sessions when the input contains reasoning steps. | |
| ``` | |
| ## Knowledge Graph Tool Instruction (cipher-advanced-prompt.yml) | |
| ``` | |
| Use the knowledge graph tools to manage, search, and relate entities and code concepts. Add nodes, search, and extract entities as needed. | |
| ``` | |
| ## Efficiency Guidelines (cipher-advanced-prompt.yml) | |
| ``` | |
| Follow efficiency guidelines: avoid redundant searches, batch related queries, and use tools strategically. | |
| ``` | |
| ## Automatic Tools Notice (cipher-advanced-prompt.yml) | |
| ``` | |
| Some tools run automatically in the background (e.g., memory extraction, reasoning evaluation). Manual invocation is not required. | |
| ``` | |
| ================================================================================ | |
| # 2. MEMORY OPERATION PROMPTS | |
| ================================================================================ | |
| ## Memory Management System Prompt | |
| ``` | |
| You are an intelligent memory management system for a programming-focused AI agent. Your task is to analyze extracted knowledge facts and determine the best memory operations (ADD, UPDATE, DELETE, NONE) based on similarity with existing memories and contextual understanding. | |
| IMPORTANT: Only process facts that contain significant programming knowledge, concepts, technical details, code patterns, or implementation information. Skip personal information, trivial conversations, or non-technical content. | |
| Consider these factors: | |
| 1. Technical relevance and programming value | |
| 2. Content similarity and semantic overlap | |
| 3. Information recency and relevance | |
| 4. Knowledge quality and completeness | |
| 5. Conversation context and technical needs | |
| 6. Implementation details and code patterns | |
| Rules: | |
| - ADD: For new, unique programming knowledge that doesn't duplicate existing memories | |
| - UPDATE: For enhanced or corrected versions of existing technical knowledge | |
| - DELETE: For outdated, incorrect, or contradictory technical information that should be removed | |
| - NONE: For duplicates, information already well-represented, or non-significant content | |
| Always preserve code blocks, commands, technical patterns, and implementation details exactly as provided. Focus on extracting meaningful programming concepts, algorithms, design patterns, best practices, and technical solutions. | |
| ``` | |
| ## Memory Decision Prompt Template | |
| ``` | |
| Analyze the following knowledge fact and determine the appropriate memory operation. Follow these steps: | |
| 1. Compare the fact to the provided similar memories (using semantic similarity, not just keywords). | |
| 2. If the fact is new and not present in any similar memory (similarity below threshold), choose ADD. | |
| 3. If the fact is more complete or correct than a similar memory, choose UPDATE and specify the targetMemoryId. | |
| 4. If the fact is redundant or already present, choose NONE. | |
| 5. If the fact contradicts an existing memory, choose DELETE and specify the targetMemoryId. | |
| 6. Always provide a confidence score (0.0 to 1.0) and clear reasoning. | |
| **Examples:** | |
| Example 1 (ADD): | |
| KNOWLEDGE FACT: | |
| "The 'merge_sort' function in Python recursively splits the array and merges sorted halves." | |
| SIMILAR EXISTING MEMORIES: | |
| No similar memories found. | |
| CONVERSATION CONTEXT: | |
| No specific context provided. | |
| JSON RESPONSE: | |
| { | |
| "operation": "ADD", | |
| "confidence": 0.95, | |
| "reasoning": "This is a new technical fact about merge sort not present in the memory base.", | |
| "targetMemoryId": null | |
| } | |
| Example 2 (UPDATE): | |
| KNOWLEDGE FACT: | |
| "The 'bubble_sort' function in Python sorts the array in-place and includes an optimization to stop early if no swaps are made." | |
| SIMILAR EXISTING MEMORIES: | |
| 1. ID: 12345 (similarity: 0.91) | |
| Content: The 'bubble_sort' function in Python sorts the array in-place. | |
| CONVERSATION CONTEXT: | |
| No specific context provided. | |
| JSON RESPONSE: | |
| { | |
| "operation": "UPDATE", | |
| "confidence": 0.9, | |
| "reasoning": "The new fact adds an optimization detail not present in the existing memory.", | |
| "targetMemoryId": 12345 | |
| } | |
| Example 3 (NONE): | |
| KNOWLEDGE FACT: | |
| "The 'quick_sort' function sorts an array in-place using a pivot." | |
| SIMILAR EXISTING MEMORIES: | |
| 1. ID: 67890 (similarity: 0.95) | |
| Content: The 'quick_sort' function sorts an array in-place using a pivot. | |
| CONVERSATION CONTEXT: | |
| No specific context provided. | |
| JSON RESPONSE: | |
| { | |
| "operation": "NONE", | |
| "confidence": 0.98, | |
| "reasoning": "The fact is already present in the memory base.", | |
| "targetMemoryId": 67890 | |
| } | |
| Example 4 (DELETE): | |
| KNOWLEDGE FACT: | |
| "The 'selection_sort' function in Python is NOT a stable sorting algorithm." | |
| SIMILAR EXISTING MEMORIES: | |
| 1. ID: 54321 (similarity: 0.92) | |
| Content: The 'selection_sort' function in Python is a stable sorting algorithm. | |
| CONVERSATION CONTEXT: | |
| No specific context provided. | |
| JSON RESPONSE: | |
| { | |
| "operation": "DELETE", | |
| "confidence": 0.93, | |
| "reasoning": "The new fact contradicts the existing memory, which incorrectly states that selection sort is stable.", | |
| "targetMemoryId": 54321 | |
| } | |
| --- | |
| KNOWLEDGE FACT: | |
| {fact} | |
| SIMILAR EXISTING MEMORIES: | |
| {similarMemories} | |
| CONVERSATION CONTEXT: | |
| {context} | |
| For this knowledge fact, respond ONLY with a single JSON object in the following format (do not include any explanation or text outside the JSON): | |
| { | |
| "operation": "ADD|UPDATE|DELETE|NONE", | |
| "confidence": 0.0-1.0, | |
| "reasoning": "Clear explanation of the decision", | |
| "targetMemoryId": "id-if-updating-or-deleting-or-none" | |
| } | |
| ``` | |
| ================================================================================ | |
| # 3. REASONING DETECTION PROMPTS | |
| ================================================================================ | |
| ## Reasoning Content Analysis Prompt | |
| ``` | |
| Analyze the following user input to determine if it contains reasoning content that would benefit from reflection memory tools. | |
| User Input: "{userInput}" | |
| Context: {context} | |
| Please analyze this input and respond with a JSON object containing: | |
| - "containsReasoning": boolean (true if the input contains reasoning patterns, thought processes, problem-solving steps, or analytical content) | |
| - "confidence": number (0.0 to 1.0, how confident you are in this assessment) | |
| - "detectedPatterns": array of strings (specific reasoning patterns you identified) | |
| - "explanation": string (brief explanation of your reasoning) | |
| Consider these factors: | |
| 1. Explicit reasoning markers (because, therefore, let me think, etc.) | |
| 2. Problem-solving language (debug, analyze, figure out, etc.) | |
| 3. Decision-making patterns (consider, evaluate, compare, etc.) | |
| 4. Technical reasoning (optimize, design, architecture, etc.) | |
| 5. Learning and reflection content (learn, understand, reflect, etc.) | |
| Respond only with the JSON object, no additional text. | |
| ``` | |
| ================================================================================ | |
| # 4. DYNAMIC PROMPT GENERATORS | |
| ================================================================================ | |
| ## Summary Generator Prompt | |
| ``` | |
| Summarize the following conversation in a concise paragraph (maximum 4-5 sentences) for the system prompt. | |
| {history} | |
| Summary: | |
| ``` | |
| ## Rules/Specs Extraction Generator Prompt | |
| ``` | |
| Extract any rules, requirements, or project specifications set by the user in the following conversation. List them clearly and concisely for the system prompt (maximum 4-5 sentences). | |
| {history} | |
| Rules/Specs: | |
| ``` | |
| ## Error Detection Generator Prompt | |
| ``` | |
| Identify any errors, bugs, or issues discussed or emphasized by the user in the following conversation. List them concisely for the system prompt (maximum 4-5 sentences). | |
| {history} | |
| Errors/Bugs: | |
| ``` | |
| ================================================================================ | |
| # 5. WORKSPACE MEMORY PROMPTS | |
| ================================================================================ | |
| ## Workspace Store Tool Description | |
| ``` | |
| Background tool that automatically stores team-related information including project progress, bugs, and collaboration context. | |
| ``` | |
| ## Workspace Extraction Patterns | |
| - Team member mentions: @mentions, "team", "colleague", "developer" | |
| - Progress indicators: "progress", "complete", "done", "finish", percentages | |
| - Bug information: "bug", "error", "issue", "fix", "resolve" | |
| - Project information: "project", "milestone", "deadline", "feature" | |
| ================================================================================ | |
| # 6. EXAMPLE SYSTEM PROMPTS FROM TESTS | |
| ================================================================================ | |
| ## Basic Test System Prompt | |
| ``` | |
| You are a helpful assistant | |
| ``` | |
| ## Helpful AI Assistant (from README example) | |
| ``` | |
| You are a helpful AI assistant with memory capabilities. | |
| ``` | |
| ## Test Context System Prompts | |
| ``` | |
| You are a helpful assistant with specific instructions. | |
| ``` | |
| ## Specialized Summarization Prompt | |
| ``` | |
| You are a helpful assistant specialized in summarization. | |
| ``` | |
| ================================================================================ | |
| # 7. PROMPT CONFIGURATION SCHEMAS | |
| ================================================================================ | |
| ## Static Provider Example | |
| ``` | |
| You are a helpful AI assistant. Please provide accurate and helpful responses. | |
| ``` | |
| ## Dynamic Provider Template Example | |
| ``` | |
| You are a helpful AI assistant specialized in {{domain}}. | |
| ``` | |
| ## Conditional Provider Examples | |
| ``` | |
| - User registered: "You are assisting a registered user. Personalization features are available." | |
| - Anonymous mode: "You are in anonymous mode. Limited features are available." | |
| ``` | |
| ================================================================================ | |
| # 8. EMBEDDING WARNING MESSAGES | |
| ================================================================================ | |
| ## Mixed Provider Setup Notice | |
| ``` | |
| You are using a mixed provider setup (non-OpenAI for LLM + OpenAI for embeddings). This is a valid configuration. | |
| ``` | |
| ================================================================================ | |
| # Notes | |
| ================================================================================ | |
| 1. All prompts in Cipher are designed to focus on programming knowledge and technical content | |
| 2. The system uses both static prompts and dynamic prompt generation based on context | |
| 3. Memory operations are designed to be intelligent and context-aware | |
| 4. Workspace memory is separate from technical memory and focuses on team collaboration | |
| 5. The prompt system is extensible through the enhanced prompt manager | |
| 6. All memory extraction filters out non-technical or trivial content | |
| 7. The system supports multiple LLM providers with provider-specific formatting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cipher プロンプト集 | |
| このファイルには、Cipherで使用されているすべてのプロンプトがカテゴリーと目的別に整理されています。 | |
| ================================================================================ | |
| # 1. システムプロンプトと設定 | |
| ================================================================================ | |
| ## デフォルトシステムプロンプト (memAgent/cipher.yml) | |
| ``` | |
| あなたはコーディングと推論タスクに特化したAIプログラミングアシスタントです。以下の分野で優れた能力を発揮します: | |
| - クリーンで効率的なコードの作成 | |
| - デバッグと問題解決 | |
| - コードレビューと最適化 | |
| - 複雑な技術概念の説明 | |
| - プログラミング課題の論理的思考 | |
| ``` | |
| ## メモリ検索ツール指示 (cipher-advanced-prompt.yml) | |
| ``` | |
| メモリ検索ツールを使用して、過去のやり取りから事実、コード、またはコンテキストを取得してください。関連性がある場合は、回答する前に必ずメモリを検索してください。 | |
| ``` | |
| ## 推論パターンツール指示 (cipher-advanced-prompt.yml) | |
| ``` | |
| 入力に推論ステップが含まれている場合、推論パターンツールを使用して、過去のセッションから問題解決戦略を見つけて適用してください。 | |
| ``` | |
| ## ナレッジグラフツール指示 (cipher-advanced-prompt.yml) | |
| ``` | |
| ナレッジグラフツールを使用して、エンティティとコード概念を管理、検索、関連付けてください。必要に応じてノードを追加、検索、エンティティを抽出してください。 | |
| ``` | |
| ## 効率性ガイドライン (cipher-advanced-prompt.yml) | |
| ``` | |
| 効率性ガイドラインに従ってください:冗長な検索を避け、関連するクエリをバッチ処理し、ツールを戦略的に使用してください。 | |
| ``` | |
| ## 自動ツール通知 (cipher-advanced-prompt.yml) | |
| ``` | |
| 一部のツールはバックグラウンドで自動的に実行されます(メモリ抽出、推論評価など)。手動での呼び出しは不要です。 | |
| ``` | |
| ================================================================================ | |
| # 2. メモリ操作プロンプト | |
| ================================================================================ | |
| ## メモリ管理システムプロンプト | |
| ``` | |
| あなたはプログラミング重視のAIエージェント用のインテリジェントなメモリ管理システムです。あなたのタスクは、抽出された知識の事実を分析し、既存のメモリとの類似性とコンテキストの理解に基づいて最適なメモリ操作(ADD、UPDATE、DELETE、NONE)を決定することです。 | |
| 重要:プログラミングの知識、概念、技術的詳細、コードパターン、または実装情報を含む重要な事実のみを処理してください。個人情報、些細な会話、または非技術的なコンテンツはスキップしてください。 | |
| 以下の要因を考慮してください: | |
| 1. 技術的関連性とプログラミング価値 | |
| 2. コンテンツの類似性と意味的重複 | |
| 3. 情報の最新性と関連性 | |
| 4. 知識の品質と完全性 | |
| 5. 会話のコンテキストと技術的ニーズ | |
| 6. 実装の詳細とコードパターン | |
| ルール: | |
| - ADD:既存のメモリと重複しない、新しくユニークなプログラミング知識 | |
| - UPDATE:既存の技術知識の強化版または修正版 | |
| - DELETE:削除すべき古い、不正確、または矛盾する技術情報 | |
| - NONE:重複、すでに十分に表現されている情報、または重要でないコンテンツ | |
| コードブロック、コマンド、技術パターン、実装の詳細は常に提供されたとおりに正確に保持してください。意味のあるプログラミング概念、アルゴリズム、デザインパターン、ベストプラクティス、技術的ソリューションの抽出に焦点を当ててください。 | |
| ``` | |
| ## メモリ決定プロンプトテンプレート | |
| ``` | |
| 以下の知識の事実を分析し、適切なメモリ操作を決定してください。次の手順に従ってください: | |
| 1. 提供された類似メモリと事実を比較します(キーワードだけでなく、意味的類似性を使用)。 | |
| 2. 事実が新しく、類似メモリに存在しない場合(類似度が閾値以下)、ADDを選択します。 | |
| 3. 事実が類似メモリよりも完全または正確な場合、UPDATEを選択し、targetMemoryIdを指定します。 | |
| 4. 事実が冗長またはすでに存在する場合、NONEを選択します。 | |
| 5. 事実が既存のメモリと矛盾する場合、DELETEを選択し、targetMemoryIdを指定します。 | |
| 6. 常に信頼度スコア(0.0から1.0)と明確な理由を提供してください。 | |
| **例:** | |
| 例1(ADD): | |
| 知識の事実: | |
| 「Pythonの'merge_sort'関数は、配列を再帰的に分割し、ソート済みの半分をマージします。」 | |
| 類似する既存のメモリ: | |
| 類似するメモリは見つかりませんでした。 | |
| 会話コンテキスト: | |
| 特定のコンテキストは提供されていません。 | |
| JSONレスポンス: | |
| { | |
| "operation": "ADD", | |
| "confidence": 0.95, | |
| "reasoning": "これはメモリベースに存在しないマージソートに関する新しい技術的事実です。", | |
| "targetMemoryId": null | |
| } | |
| 例2(UPDATE): | |
| 知識の事実: | |
| 「Pythonの'bubble_sort'関数は配列をインプレースでソートし、スワップが行われない場合に早期停止する最適化を含みます。」 | |
| 類似する既存のメモリ: | |
| 1. ID: 12345(類似度:0.91) | |
| 内容:Pythonの'bubble_sort'関数は配列をインプレースでソートします。 | |
| 会話コンテキスト: | |
| 特定のコンテキストは提供されていません。 | |
| JSONレスポンス: | |
| { | |
| "operation": "UPDATE", | |
| "confidence": 0.9, | |
| "reasoning": "新しい事実は既存のメモリに存在しない最適化の詳細を追加しています。", | |
| "targetMemoryId": 12345 | |
| } | |
| 例3(NONE): | |
| 知識の事実: | |
| 「'quick_sort'関数はピボットを使用して配列をインプレースでソートします。」 | |
| 類似する既存のメモリ: | |
| 1. ID: 67890(類似度:0.95) | |
| 内容:'quick_sort'関数はピボットを使用して配列をインプレースでソートします。 | |
| 会話コンテキスト: | |
| 特定のコンテキストは提供されていません。 | |
| JSONレスポンス: | |
| { | |
| "operation": "NONE", | |
| "confidence": 0.98, | |
| "reasoning": "事実はすでにメモリベースに存在しています。", | |
| "targetMemoryId": 67890 | |
| } | |
| 例4(DELETE): | |
| 知識の事実: | |
| 「Pythonの'selection_sort'関数は安定なソートアルゴリズムではありません。」 | |
| 類似する既存のメモリ: | |
| 1. ID: 54321(類似度:0.92) | |
| 内容:Pythonの'selection_sort'関数は安定なソートアルゴリズムです。 | |
| 会話コンテキスト: | |
| 特定のコンテキストは提供されていません。 | |
| JSONレスポンス: | |
| { | |
| "operation": "DELETE", | |
| "confidence": 0.93, | |
| "reasoning": "新しい事実は、選択ソートが安定であると誤って述べている既存のメモリと矛盾しています。", | |
| "targetMemoryId": 54321 | |
| } | |
| --- | |
| 知識の事実: | |
| {fact} | |
| 類似する既存のメモリ: | |
| {similarMemories} | |
| 会話コンテキスト: | |
| {context} | |
| この知識の事実について、以下の形式で単一のJSONオブジェクトのみで応答してください(JSON外の説明やテキストは含めないでください): | |
| { | |
| "operation": "ADD|UPDATE|DELETE|NONE", | |
| "confidence": 0.0-1.0, | |
| "reasoning": "決定の明確な説明", | |
| "targetMemoryId": "更新・削除・なしの場合のID" | |
| } | |
| ``` | |
| ================================================================================ | |
| # 3. 推論検出プロンプト | |
| ================================================================================ | |
| ## 推論コンテンツ分析プロンプト | |
| ``` | |
| 以下のユーザー入力を分析して、リフレクションメモリツールから恩恵を受ける推論コンテンツが含まれているかどうかを判断してください。 | |
| ユーザー入力:「{userInput}」 | |
| コンテキスト:{context} | |
| この入力を分析し、以下を含むJSONオブジェクトで応答してください: | |
| - "containsReasoning": boolean(入力に推論パターン、思考プロセス、問題解決ステップ、または分析的コンテンツが含まれている場合はtrue) | |
| - "confidence": number(0.0から1.0、この評価に対する確信度) | |
| - "detectedPatterns": 文字列の配列(特定した具体的な推論パターン) | |
| - "explanation": string(推論の簡潔な説明) | |
| 以下の要因を考慮してください: | |
| 1. 明示的な推論マーカー(なぜなら、したがって、考えてみると、など) | |
| 2. 問題解決言語(デバッグ、分析、解明、など) | |
| 3. 意思決定パターン(検討、評価、比較、など) | |
| 4. 技術的推論(最適化、設計、アーキテクチャ、など) | |
| 5. 学習と振り返りのコンテンツ(学ぶ、理解する、振り返る、など) | |
| JSONオブジェクトのみで応答し、追加のテキストは含めないでください。 | |
| ``` | |
| ================================================================================ | |
| # 4. 動的プロンプトジェネレーター | |
| ================================================================================ | |
| ## 要約ジェネレータープロンプト | |
| ``` | |
| 以下の会話をシステムプロンプト用に簡潔な段落(最大4-5文)で要約してください。 | |
| {history} | |
| 要約: | |
| ``` | |
| ## ルール/仕様抽出ジェネレータープロンプト | |
| ``` | |
| 以下の会話でユーザーが設定したルール、要件、またはプロジェクト仕様を抽出してください。システムプロンプト用に明確かつ簡潔にリストアップしてください(最大4-5文)。 | |
| {history} | |
| ルール/仕様: | |
| ``` | |
| ## エラー検出ジェネレータープロンプト | |
| ``` | |
| 以下の会話でユーザーが議論または強調したエラー、バグ、または問題を特定してください。システムプロンプト用に簡潔にリストアップしてください(最大4-5文)。 | |
| {history} | |
| エラー/バグ: | |
| ``` | |
| ================================================================================ | |
| # 5. ワークスペースメモリプロンプト | |
| ================================================================================ | |
| ## ワークスペースストアツール説明 | |
| ``` | |
| プロジェクトの進捗、バグ、コラボレーションコンテキストを含むチーム関連情報を自動的に保存するバックグラウンドツール。 | |
| ``` | |
| ## ワークスペース抽出パターン | |
| - チームメンバーの言及:@メンション、「チーム」、「同僚」、「開発者」 | |
| - 進捗インジケーター:「進捗」、「完了」、「終了」、「仕上げ」、パーセンテージ | |
| - バグ情報:「バグ」、「エラー」、「問題」、「修正」、「解決」 | |
| - プロジェクト情報:「プロジェクト」、「マイルストーン」、「締切」、「機能」 | |
| ================================================================================ | |
| # 6. テストからの例示システムプロンプト | |
| ================================================================================ | |
| ## 基本的なテストシステムプロンプト | |
| ``` | |
| あなたは役立つアシスタントです | |
| ``` | |
| ## 役立つAIアシスタント(README例から) | |
| ``` | |
| あなたはメモリ機能を持つ役立つAIアシスタントです。 | |
| ``` | |
| ## テストコンテキストシステムプロンプト | |
| ``` | |
| あなたは特定の指示を持つ役立つアシスタントです。 | |
| ``` | |
| ## 専門的な要約プロンプト | |
| ``` | |
| あなたは要約を専門とする役立つアシスタントです。 | |
| ``` | |
| ================================================================================ | |
| # 7. プロンプト設定スキーマ | |
| ================================================================================ | |
| ## 静的プロバイダーの例 | |
| ``` | |
| あなたは役立つAIアシスタントです。正確で役立つ応答を提供してください。 | |
| ``` | |
| ## 動的プロバイダーテンプレートの例 | |
| ``` | |
| あなたは{{domain}}を専門とする役立つAIアシスタントです。 | |
| ``` | |
| ## 条件付きプロバイダーの例 | |
| ``` | |
| - ユーザー登録済み:「登録済みユーザーをサポートしています。パーソナライゼーション機能が利用可能です。」 | |
| - 匿名モード:「匿名モードです。限定的な機能が利用可能です。」 | |
| ``` | |
| ================================================================================ | |
| # 8. 埋め込み警告メッセージ | |
| ================================================================================ | |
| ## 混合プロバイダー設定通知 | |
| ``` | |
| 混合プロバイダー設定(LLMは非OpenAI + 埋め込みはOpenAI)を使用しています。これは有効な設定です。 | |
| ``` | |
| ================================================================================ | |
| # 注記 | |
| ================================================================================ | |
| 1. Cipherのすべてのプロンプトは、プログラミング知識と技術的コンテンツに焦点を当てるように設計されています | |
| 2. システムは静的プロンプトとコンテキストに基づく動的プロンプト生成の両方を使用します | |
| 3. メモリ操作はインテリジェントでコンテキストを認識するように設計されています | |
| 4. ワークスペースメモリは技術的メモリとは別で、チームコラボレーションに焦点を当てています | |
| 5. プロンプトシステムは拡張プロンプトマネージャーを通じて拡張可能です | |
| 6. すべてのメモリ抽出は非技術的または些細なコンテンツをフィルタリングします | |
| 7. システムは複数のLLMプロバイダーをプロバイダー固有のフォーマットでサポートします |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cipher ツール技術説明書 | |
| このドキュメントでは、Cipherの核心的な2つのツールシステムである「ナレッジグラフツール」と「推論パターンツール」について技術的に詳しく説明します。 | |
| ================================================================================ | |
| # 1. ナレッジグラフツール (Knowledge Graph Tools) | |
| ================================================================================ | |
| ## 概要 | |
| ナレッジグラフツールは、プログラミング知識やコード概念をグラフ構造で管理するツール群です。エンティティ(ノード)とその関係性(エッジ)を使って、複雑な技術知識を構造化して保存・検索できます。 | |
| ## アーキテクチャ | |
| ### バックエンドサポート | |
| - **Neo4j**: 本番環境用のグラフデータベース | |
| - **In-Memory**: 開発・テスト用のメモリ内実装 | |
| - 抽象化層により、バックエンドを切り替え可能 | |
| ### 主要コンポーネント | |
| 1. **GraphManager**: グラフ操作の統合管理 | |
| 2. **KnowledgeGraphBackend**: バックエンド抽象インターフェース | |
| 3. **Entity Types**: Person, Function, Class, Variable, Project, File, Concept, Technology など | |
| ## ツール一覧と機能 | |
| ### 1. add_node (ノード追加) | |
| - エンティティをグラフに追加 | |
| - 重複チェック機能 | |
| - メタデータサポート(作成日時、説明、タグなど) | |
| ### 2. add_edge (エッジ追加) | |
| - エンティティ間の関係を定義 | |
| - 関係タイプ: IMPLEMENTS, USES, CALLS, EXTENDS, DEPENDS_ON など | |
| - 重み付けサポート | |
| ### 3. search_graph (グラフ検索) | |
| - テキストベースの検索 | |
| - ノードタイプによるフィルタリング | |
| - ファジーマッチング対応 | |
| ### 4. extract_entities (エンティティ抽出) | |
| ```typescript | |
| // 使用例 | |
| const result = await extractEntitiesTool.handler({ | |
| text: "The UserService class implements IAuthService interface and uses JWT tokens", | |
| options: { | |
| entityTypes: ["Class", "Interface", "Technology"], | |
| autoLink: true, | |
| linkTypes: ["IMPLEMENTS", "USES"] | |
| } | |
| }); | |
| ``` | |
| - 自然言語テキストからエンティティを自動抽出 | |
| - NLP技術を使用して名前付きエンティティを識別 | |
| - 自動的に関係性も生成可能 | |
| ### 5. intelligent_processor (インテリジェント処理) | |
| 最も高度なツールで、自然言語を解析して複雑なグラフ操作を実行: | |
| - "Long and Trang likes ice-cream" → Long, Trang, ice-creamエンティティとLIKES関係を作成 | |
| - "not Long but Nam and Trang" → Longを削除、Namを追加、Trangと関係を維持 | |
| - エンティティの競合を自動解決 | |
| - 信頼度スコアによる判断 | |
| ### 6. enhanced_search (拡張検索) | |
| - 意味的類似性検索 | |
| - 複数ホップのグラフトラバーサル | |
| - コンテキスト認識検索 | |
| ### 7. relationship_manager (関係管理) | |
| - 関係の一括更新 | |
| - 関係パターンの分析 | |
| - 循環依存の検出 | |
| ### 8. query_graph (グラフクエリ) | |
| - Cypherライククエリのサポート | |
| - 複雑なグラフパターンマッチング | |
| - 集計と分析機能 | |
| ## 技術的特徴 | |
| ### エンティティ構造 | |
| ```typescript | |
| interface GraphNode { | |
| id: string; | |
| name: string; | |
| type: string; | |
| attributes: Record<string, any>; | |
| metadata: { | |
| createdAt: string; | |
| updatedAt?: string; | |
| description?: string; | |
| tags?: string[]; | |
| }; | |
| } | |
| ``` | |
| ### 関係構造 | |
| ```typescript | |
| interface GraphEdge { | |
| id: string; | |
| from: string; | |
| to: string; | |
| type: string; | |
| weight?: number; | |
| attributes?: Record<string, any>; | |
| } | |
| ``` | |
| ================================================================================ | |
| # 2. 推論パターンツール (Reasoning Pattern Tools) | |
| ================================================================================ | |
| ## 概要 | |
| 推論パターンツールは、AIエージェントの思考プロセスと問題解決パターンを記録・検索するシステムです。過去の推論の成功例を学習し、類似の問題に適用できます。 | |
| ## アーキテクチャ | |
| ### メモリシステム | |
| - **Knowledge Memory**: プログラミング知識とコード情報 | |
| - **Reflection Memory**: 推論パターンと評価結果 | |
| - ベクトルデータベースによる意味的検索 | |
| ### 推論トレース構造 | |
| ```typescript | |
| interface ReasoningTrace { | |
| id: string; | |
| steps: Array<{ | |
| type: 'thought' | 'action' | 'observation' | 'decision' | 'conclusion' | 'reflection'; | |
| content: string; | |
| }>; | |
| metadata: { | |
| extractedAt: string; | |
| conversationLength: number; | |
| stepCount: number; | |
| hasExplicitMarkup: boolean; | |
| sessionId: string; | |
| taskContext: { | |
| goal: string; | |
| input: string; | |
| taskType: string; | |
| domain: string; | |
| complexity: 'low' | 'medium' | 'high'; | |
| }; | |
| }; | |
| } | |
| ``` | |
| ## 主要ツール | |
| ### 1. search_reasoning_patterns (推論パターン検索) | |
| ```typescript | |
| // 使用例 | |
| const patterns = await searchReasoningPatterns.handler({ | |
| query: "debugging async JavaScript errors", | |
| context: { | |
| taskType: "debugging", | |
| domain: "javascript", | |
| complexity: "high" | |
| }, | |
| options: { | |
| maxResults: 10, | |
| minQualityScore: 0.7, | |
| includeEvaluations: true | |
| } | |
| }); | |
| ``` | |
| #### 機能 | |
| - 意味的類似性による検索 | |
| - タスクタイプとドメインでフィルタリング | |
| - 品質スコアによるランキング | |
| - 重複クエリの自動除去(5分以内の類似クエリをスキップ) | |
| ### 2. store_reasoning_memory (推論メモリ保存) | |
| - 推論トレースと評価を統合して保存 | |
| - アトミックな操作(トレースと評価は常にセット) | |
| - 追記専用(append-only)設計 | |
| - ベクトルIDレンジ: 666667-999999 | |
| ### 3. extract_reasoning_steps (推論ステップ抽出) | |
| - 会話から推論プロセスを自動抽出 | |
| - 思考、アクション、観察、決定、結論、振り返りを分類 | |
| - タスクコンテキストの自動抽出 | |
| ### 4. evaluate_reasoning (推論評価) | |
| ```typescript | |
| interface ReasoningEvaluation { | |
| qualityScore: number; // 0.0-1.0 | |
| efficiencyScore: number; // 0.0-1.0 | |
| issues: Array<{ | |
| type: string; | |
| description: string; | |
| severity: 'low' | 'medium' | 'high'; | |
| }>; | |
| suggestions: string[]; | |
| shouldStore: boolean; | |
| } | |
| ``` | |
| ## 技術的特徴 | |
| ### 検索最適化 | |
| 1. **クエリ類似度計算**: レーベンシュタイン距離とトークン重複率 | |
| 2. **バッチ処理**: 複数の類似クエリを一度に処理 | |
| 3. **キャッシング**: セッション内での重複検索を防止 | |
| ### ベクトル埋め込み | |
| - 各推論パターンはベクトル化されて保存 | |
| - 意味的類似性による高速検索 | |
| - フォールバック機構(埋め込み失敗時) | |
| ### 品質管理 | |
| - 自動品質評価システム | |
| - 低品質パターンの自動フィルタリング | |
| - 継続的な学習と改善 | |
| ================================================================================ | |
| # 3. 統合と相互作用 | |
| ================================================================================ | |
| ## ツール間の連携 | |
| ### 1. 知識抽出フロー | |
| ``` | |
| ユーザー入力 | |
| ↓ | |
| 推論検出 (ReasoningContentDetector) | |
| ↓ | |
| 並列処理: | |
| - ナレッジグラフ: extract_entities → add_node → add_edge | |
| - メモリ: extract_and_operate_memory → vector store | |
| - 推論: extract_reasoning_steps → evaluate → store_reasoning_memory | |
| ``` | |
| ### 2. 検索統合 | |
| - memory_search: 知識メモリを検索 | |
| - search_reasoning_patterns: 推論パターンを検索 | |
| - search_graph: グラフ構造を検索 | |
| - SearchContextManager: 全検索結果を統合管理 | |
| ### 3. インテリジェント処理 | |
| 両システムが協調して動作: | |
| - グラフから構造化知識を取得 | |
| - 推論パターンから解決策を発見 | |
| - 新しい知識と推論を継続的に学習 | |
| ================================================================================ | |
| # 4. パフォーマンスと拡張性 | |
| ================================================================================ | |
| ## 最適化戦略 | |
| ### 1. ベクトルストア | |
| - Qdrant/Milvusによる高速検索 | |
| - 次元数: 1536(デフォルト) | |
| - コサイン類似度による検索 | |
| ### 2. グラフデータベース | |
| - Neo4jのインデックス最適化 | |
| - 関係のバッチ処理 | |
| - メモリ内キャッシング | |
| ### 3. 並行処理 | |
| - ツールの並列実行 | |
| - 非同期操作の活用 | |
| - リソースプーリング | |
| ## 拡張ポイント | |
| ### 1. カスタムエンティティタイプ | |
| - 新しいドメイン固有のエンティティを追加可能 | |
| - 関係タイプのカスタマイズ | |
| ### 2. 推論パターンの特化 | |
| - ドメイン固有の推論ステップタイプ | |
| - カスタム評価基準 | |
| ### 3. 検索アルゴリズム | |
| - カスタム類似度メトリクス | |
| - 特殊なフィルタリングロジック | |
| ================================================================================ | |
| # 5. まとめ | |
| ================================================================================ | |
| Cipherのナレッジグラフツールと推論パターンツールは、AIエージェントに構造化された知識管理と学習能力を提供します: | |
| 1. **ナレッジグラフ**: コードとプログラミング概念の関係を視覚的・構造的に管理 | |
| 2. **推論パターン**: 過去の問題解決プロセスから学習し、新しい問題に適用 | |
| 3. **統合システム**: 両ツールが協調して、より賢明な意思決定を支援 | |
| これらのツールにより、Cipherは単なるコード生成ツールを超えて、継続的に学習し進化するインテリジェントなプログラミングアシスタントとなります。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment