(
os: &Os,
session: &mut ChatSession,
name: String,
global: bool,
)
| 1671 | } |
| 1672 | |
| 1673 | async fn execute_edit( |
| 1674 | os: &Os, |
| 1675 | session: &mut ChatSession, |
| 1676 | name: String, |
| 1677 | global: bool, |
| 1678 | ) -> Result<ChatState, ChatError> { |
| 1679 | // Validate prompt name |
| 1680 | if let Err(validation_error) = validate_prompt_name(&name) { |
| 1681 | queue!( |
| 1682 | session.stderr, |
| 1683 | style::Print("\n"), |
| 1684 | StyledText::error_fg(), |
| 1685 | style::Print("❌ Invalid prompt name: "), |
| 1686 | style::Print(validation_error), |
| 1687 | style::Print("\n"), |
| 1688 | StyledText::reset(), |
| 1689 | )?; |
| 1690 | return Ok(ChatState::PromptUser { |
| 1691 | skip_printing_tools: true, |
| 1692 | }); |
| 1693 | } |
| 1694 | |
| 1695 | let prompts = Prompts::new(&name, os).map_err(|e| ChatError::Custom(e.to_string().into()))?; |
| 1696 | let (local_exists, global_exists) = (prompts.local.exists(), prompts.global.exists()); |
| 1697 | |
| 1698 | // Find the target prompt to edit |
| 1699 | let target_prompt = if global { |
| 1700 | if !global_exists { |
| 1701 | queue!( |
| 1702 | session.stderr, |
| 1703 | style::Print("\n"), |
| 1704 | StyledText::warning_fg(), |
| 1705 | style::Print("Global prompt "), |
| 1706 | StyledText::brand_fg(), |
| 1707 | style::Print(&name), |
| 1708 | StyledText::warning_fg(), |
| 1709 | style::Print(" not found.\n"), |
| 1710 | StyledText::reset(), |
| 1711 | )?; |
| 1712 | return Ok(ChatState::PromptUser { |
| 1713 | skip_printing_tools: true, |
| 1714 | }); |
| 1715 | } |
| 1716 | &prompts.global |
| 1717 | } else if local_exists { |
| 1718 | &prompts.local |
| 1719 | } else if global_exists { |
| 1720 | // Found global prompt, but user wants to edit local |
| 1721 | queue!( |
| 1722 | session.stderr, |
| 1723 | style::Print("\n"), |
| 1724 | StyledText::warning_fg(), |
| 1725 | style::Print("Local prompt "), |
| 1726 | StyledText::brand_fg(), |
| 1727 | style::Print(&name), |
| 1728 | StyledText::warning_fg(), |
| 1729 | style::Print(" not found, but global version exists.\n"), |
| 1730 | style::Print("Use "), |
nothing calls this directly
no test coverage detected