# PromptComposer テンプレートベースのプロンプト構築システム。Handlebarsテンプレートエンジンによる動的プロンプト生成。 ## 基本使用方法 ```rust // 初期化 let composer = PromptComposer::from_config_file("role.yaml", context)?; composer.initialize_session(&messages)?; // プロンプト構築 let messages = composer.compose(&user_messages)?; ``` ## テンプレート構文 ### 変数展開 ```handlebars {{workspace.project_name}} # プロジェクト名 {{workspace.project_type}} # プロジェクト種別 {{model.provider}}/{{model.model_name}} # モデル情報 {{tools_schema}} # ツールスキーマ ``` ### 条件分岐 ```handlebars {{#if workspace.has_nia_md}} Project info: {{workspace_content}} {{/if}} {{#eq workspace.project_type "Rust"}} Focus on memory safety and performance. {{/eq}} ``` ### 繰り返し処理 ```handlebars {{#each tools}} - **{{name}}**: {{description}} {{/each}} ``` ### パーシャルテンプレート ```handlebars {{> header}} {{> coding_guidelines}} {{> footer}} ``` ## カスタムヘルパー ### include_file 外部ファイルを読み込み: ```handlebars {{include_file "~/.config/nia/templates/guidelines.md"}} ``` ### workspace_content ワークスペースのnia.md内容を取得: ```handlebars {{workspace_content}} ``` ## 利用可能なコンテキスト変数 - `workspace`: プロジェクト情報(root_path、project_type、git_info等) - `model`: LLMモデル情報(provider、model_name、capabilities) - `session`: セッション情報(conversation_id、message_count) - `user_input`: ユーザー入力内容 - `tools_schema`: ツール定義JSON