Skip to main content

ai_agent/utils/plugins/
hint_recommendation.rs

1// Source: ~/claudecode/openclaudecode/src/utils/plugins/hintRecommendation.ts
2#![allow(dead_code)]
3
4use std::collections::HashSet;
5use std::sync::Mutex;
6
7use once_cell::sync::Lazy;
8
9static TRIED_THIS_SESSION: Lazy<Mutex<HashSet<String>>> = Lazy::new(|| Mutex::new(HashSet::new()));
10
11/// Plugin-hint recommendation utilities.
12pub struct PluginHintRecommendation {
13    pub plugin_id: String,
14    pub plugin_name: String,
15    pub marketplace_name: String,
16    pub plugin_description: Option<String>,
17    pub source_command: String,
18}
19
20/// Claude code hint structure.
21pub struct ClaudeCodeHint {
22    pub value: String,
23    pub source_command: String,
24}
25
26/// Pre-store gate called when a plugin hint is detected.
27pub fn _maybe_record_plugin_hint(_hint: &ClaudeCodeHint) {
28    // Stub
29}
30
31/// Evaluate whether to show a plugin hint based on plugin and hint state.
32pub fn _should_show_hint(_plugin_id: &str) -> bool {
33    false
34}
35
36/// Resolve the pending hint to a renderable recommendation.
37pub async fn resolve_plugin_hint(
38    hint: &ClaudeCodeHint,
39) -> Result<Option<PluginHintRecommendation>, Box<dyn std::error::Error + Send + Sync>> {
40    let plugin_id = &hint.value;
41    let parsed = super::plugin_identifier::parse_plugin_identifier(plugin_id);
42
43    let plugin_data = super::marketplace_manager::get_plugin_by_id(plugin_id).await;
44
45    let marketplace_name = parsed.marketplace.clone().unwrap_or_default();
46
47    match plugin_data {
48        Some(data) => Ok(Some(PluginHintRecommendation {
49            plugin_id: plugin_id.clone(),
50            plugin_name: data.entry.name.clone(),
51            marketplace_name,
52            plugin_description: data.entry.description.clone(),
53            source_command: hint.source_command.clone(),
54        })),
55        None => {
56            log::debug!(
57                "[hint_recommendation] {} not found in marketplace cache",
58                plugin_id
59            );
60            Ok(None)
61        }
62    }
63}
64
65/// Record that a prompt for this plugin was surfaced.
66pub fn _mark_hint_plugin_shown(_plugin_id: &str) {
67    // Stub
68}
69
70/// Called when the user picks "don't show plugin installation hints again".
71pub fn _disable_hint_recommendations() {
72    // Stub
73}
74
75/// Test-only reset.
76pub fn _reset_hint_recommendation_for_testing() {
77    TRIED_THIS_SESSION.lock().unwrap().clear();
78}