
    i                        d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	ddl
mZ ddlmZ erddl
mZ d	Z ed
          dfddZddZedk    r e             dS dS )zRCLI tool to generate Agent configuration files from natural language descriptions.    )annotationsN)Path)TYPE_CHECKING)create_client)AgentConfig)	LLMClienta  You are an expert at creating AI agent personas.
Given a natural language description, generate a JSON object with exactly these fields:
- "role": A concise job title for the agent (e.g., "Chief Product Officer")
- "system_prompt": A detailed system prompt that captures the persona's expertise, communication style, and focus areas. The prompt should instruct the agent on how to behave in a meeting context.

Output ONLY the JSON object, no other text.

Example input: "Mimics Steve Jobs' demanding product perspective"
Example output:
{
  "role": "Chief Product Officer",
  "system_prompt": "You are an extremely demanding product manager who obsesses over simplicity and user experience. In meetings, you challenge every assumption, push for 10x better solutions, and reject anything that feels mediocre. You focus on: user delight, simplicity, integration of hardware and software thinking, and saying no to 1000 things."
}agentsjsonnamestrdescriptionclientr   
output_dirr   fmtreturnr   c                   |                     t          d|dg          }|                                }|                    d          rUd|v r|                    dd          d         n|}|                    d          r
|dd         }|                                }t          j        |          }t          | |d	         |d
                   }|	                    dd           |dk    rdnd}	||  d|	 z  }
|
                                }|dk    r-|
                    t          j        |dd          d           n,|
                    t          j        |dd          d           |S )a  Generate an AgentConfig from a natural language description.

    Args:
        name: Unique identifier for the agent (used as filename).
        description: Natural language description of the agent persona.
        client: LLM client implementing the LLMClient protocol.
        output_dir: Directory where the config file will be saved.
        fmt: Output format, either "json" or "yaml".

    Returns:
        The populated AgentConfig instance.
    user)rolecontent)systemmessagesz```
   Nr   system_prompt)r   r   r   T)parentsexist_okyamlr
   .F)allow_unicodedefault_flow_stylezutf-8)encoding   )ensure_asciiindent)chatAGENT_BUILDER_SYSTEM_PROMPTstrip
startswithsplitendswithr
   loadsr   mkdir
model_dump
write_textr   dumpdumps)r   r   r   r   r   raw_responsecleaneddataconfigextoutput_pathconfig_dicts               4/root/projects/multi-agents-meeting/agent_builder.pybuild_agent_configr:   "   s   & ;;*!k::;   L
   ""G%   "/3w'--a((++GE"" 	#crclG--//:gD&\?+  F TD1116MM&&vC$.K##%%K
f}}Ik%PPP 	 	
 	
 	
 	

 	J{qAAA 	 	
 	
 	

 M    Nonec                    t          j        d          } |                     ddd           |                     ddd           |                     d	d
d           |                     dddgdd           |                                 }t	                      }t          |j        |j        |t          |j	                  |j
                  }t          d|j         d|j         d|j	         d|j         d|j
         
           dS )z"CLI entry point for agent_builder.z=Generate an Agent config from a natural language description.)r   z--descriptionTz2Natural language description of the agent persona.)requiredhelpz--namezUnique name for the agent.z--output-dirr	   z5Directory to save the config file (default: agents/).)defaultr?   z--formatr
   r   zOutput format (default: json).)choicesr@   r?   )r   r   r   r   r   zAgent 'z' (z) saved to /r   N)argparseArgumentParseradd_argument
parse_argsr   r:   r   r   r   r   formatprintr   )parserargsr   r5   s       r9   mainrK   \   s.   $S  F $=qrrr
46RSSS
?vwww

VV,<fSstttD__FY$((K  F 

iFK
i
iFK
i
iDO
i
ifk
i
i\`\g
i
ijjjjjr;   __main__)r   r   r   r   r   r   r   r   r   r   r   r   )r   r<   )__doc__
__future__r   rC   r
   pathlibr   typingr   r   src.llm_clientr   
src.modelsr   r   r'   r:   rK   __name__ r;   r9   <module>rU      s   X X " " " " " "                      ( ( ( ( ( ( " " " " " " )(((((( & tH~~7 7 7 7 7tk k k k. zDFFFFF r;   