prompt_store/lib.rs
1//! # prompt-store: A secure, encrypted CLI and library for managing AI prompts.
2//!
3//! This crate provides both a command-line interface and a Rust library for securely
4//! storing, organizing, and executing AI prompts and multi-step prompt chains.
5//!
6//! ## Library Usage Example
7//!
8//! ```no_run
9//! use prompt_store::{PromptStore, RunOutput};
10//! use llm::builder::{LLMBuilder, LLMBackend};
11//! use llm::chain::LLMRegistry;
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//! // Initialize the store once. This handles loading the encryption key.
16//! // For non-interactive environments, prefer `PromptStore::with_password("my-secret")`.
17//! let store = PromptStore::init()?;
18//!
19//! // Setup LLM providers
20//! let openai_key = std::env::var("OPENAI_API_KEY")?;
21//! let openai_llm = LLMBuilder::new()
22//! .backend(LLMBackend::OpenAI)
23//! .api_key(openai_key)
24//! .model("gpt-4o-mini")
25//! .build()?;
26//!
27//! let mut registry = LLMRegistry::new();
28//! registry.insert("openai", openai_llm);
29//!
30//! // --- Run a single stored prompt ---
31//! let output = store.prompt("my-prompt-id")
32//! .vars([("name", "Alice")])
33//! .backend(registry.get("openai").unwrap())
34//! .run()
35//! .await?;
36//!
37//! if let RunOutput::Prompt(text) = output {
38//! println!("Single prompt output: {}", text);
39//! }
40//!
41//! // --- Define and run a dynamic chain ---
42//! let chain_output = store.chain(®istry)
43//! .step("analysis", "prompt-for-analysis") // Loads a prompt with ID/title "prompt-for-analysis"
44//! .with_provider("openai")
45//! .step_raw("synthesis", "Synthesize the following: {{analysis}}") // Uses a raw string as a prompt
46//! .with_provider("openai")
47//! .vars([("input_data", "Some data to analyze.")])
48//! .run()
49//! .await?;
50//!
51//! if let RunOutput::Chain(map) = chain_output {
52//! println!("Final chain output: {}", map.get("synthesis").unwrap());
53//! }
54//!
55//! Ok(())
56//! }
57//! ```
58
59pub mod api;
60pub mod cli;
61pub mod commands;
62pub mod core;
63pub mod ui;
64
65// Main library entry points
66pub use api::{PromptStore, RunError, RunOutput, StoreError};