Skip to main content

foundry_mcp/core/ops/
get_foundry_help.rs

1//! Core op for get_foundry_help (tool/CLI-agnostic)
2
3use anyhow::Result;
4
5use crate::types::responses::{
6    FoundryResponse, GetFoundryHelpResponse, HelpContent, ValidationStatus,
7};
8
9#[derive(Debug, Clone)]
10pub struct Input {
11    pub topic: Option<String>,
12}
13
14pub async fn run(input: Input) -> Result<FoundryResponse<GetFoundryHelpResponse>> {
15    let topic = input.topic.as_deref().unwrap_or("overview");
16    let content = match topic {
17        "workflows" => create_workflows_help(),
18        "decision-points" => create_decision_points_help(),
19        "content-examples" => create_content_examples_help(),
20        "project-structure" => create_project_structure_help(),
21        "parameter-guidance" => create_parameter_guidance_help(),
22        "tool-capabilities" => create_tool_capabilities_help(),
23        "edit-commands" => create_edit_commands_help(),
24        _ => create_overview_help(),
25    };
26
27    let next_steps = vec![
28        "Available help topics: workflows, decision-points, content-examples, project-structure, parameter-guidance, tool-capabilities, edit-commands".to_string(),
29        "Choose topics based on what you need guidance for".to_string(),
30        "Use decision-points topic to understand when each tool is appropriate".to_string(),
31        "Use edit-commands topic for deterministic, idempotent spec edits with examples".to_string(),
32    ];
33
34    let workflow_hints = vec![
35        "Help topics provide user-driven decision support, not automated sequences".to_string(),
36        "All commands return JSON for programmatic consumption".to_string(),
37        "Content must be provided by LLMs as arguments - Foundry manages structure only"
38            .to_string(),
39        "Always wait for user intent before suggesting tools".to_string(),
40    ];
41
42    Ok(FoundryResponse {
43        data: GetFoundryHelpResponse {
44            topic: topic.to_string(),
45            content,
46        },
47        next_steps,
48        validation_status: ValidationStatus::Complete,
49        workflow_hints,
50    })
51}
52
53fn create_overview_help() -> HelpContent {
54    crate::cli::commands::get_foundry_help::create_overview_help()
55}
56
57fn create_workflows_help() -> HelpContent {
58    crate::cli::commands::get_foundry_help::create_workflows_help()
59}
60
61fn create_content_examples_help() -> HelpContent {
62    crate::cli::commands::get_foundry_help::create_content_examples_help()
63}
64
65fn create_project_structure_help() -> HelpContent {
66    crate::cli::commands::get_foundry_help::create_project_structure_help()
67}
68
69fn create_parameter_guidance_help() -> HelpContent {
70    crate::cli::commands::get_foundry_help::create_parameter_guidance_help()
71}
72
73fn create_decision_points_help() -> HelpContent {
74    crate::cli::commands::get_foundry_help::create_decision_points_help()
75}
76
77fn create_tool_capabilities_help() -> HelpContent {
78    crate::cli::commands::get_foundry_help::create_tool_capabilities_help()
79}
80
81fn create_edit_commands_help() -> HelpContent {
82    crate::cli::commands::get_foundry_help::create_edit_commands_help()
83}