Skip to content

Commit d43a277

Browse files
gold-ak47claude
andcommitted
feat: detect Claude Code plugin in treble init
After scaffolding .treble/, init now checks ~/.claude/plugins/ for the treble plugin. If missing, prints the exact commands to install: claude plugin marketplace add treble-app/cli claude plugin install treble Also detects whether the marketplace is already added and adjusts the instructions accordingly. Non-blocking — init still succeeds, this is guidance only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fa2c06a commit d43a277

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

src/commands/init.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ pub async fn run(figma_arg: Option<String>, flavor: String) -> Result<()> {
116116
println!(" File key: {}", file_key.dimmed());
117117
println!(" Flavor: {}", flavor.dimmed());
118118
println!(" Account: {}", selected_account_name.cyan());
119+
120+
// Check Claude Code plugin status
121+
check_claude_plugin();
122+
119123
println!(
120124
"\nNext: run {} to pull Figma data to disk",
121125
"treble sync".bold()
@@ -124,6 +128,58 @@ pub async fn run(figma_arg: Option<String>, flavor: String) -> Result<()> {
124128
Ok(())
125129
}
126130

131+
/// Check if the Treble Claude Code plugin is installed and print guidance.
132+
fn check_claude_plugin() {
133+
let home = match dirs::home_dir() {
134+
Some(h) => h,
135+
None => return,
136+
};
137+
138+
let plugins_dir = home.join(".claude").join("plugins");
139+
140+
// Check if marketplace is registered
141+
let marketplace_added = plugins_dir.join("known_marketplaces.json").is_file()
142+
&& std::fs::read_to_string(plugins_dir.join("known_marketplaces.json"))
143+
.map(|c| c.contains("\"treble-app\""))
144+
.unwrap_or(false);
145+
146+
// Check if plugin is installed
147+
let plugin_installed = plugins_dir.join("installed_plugins.json").is_file()
148+
&& std::fs::read_to_string(plugins_dir.join("installed_plugins.json"))
149+
.map(|c| c.contains("\"treble@treble-app\""))
150+
.unwrap_or(false);
151+
152+
if plugin_installed {
153+
return;
154+
}
155+
156+
println!();
157+
println!(
158+
" {} Treble Claude plugin not detected.",
159+
"Note:".yellow().bold()
160+
);
161+
println!(
162+
" The CLI needs its Claude Code plugin for {}, {}, etc.",
163+
"/treble:dev".bold(),
164+
"/treble:plan".bold()
165+
);
166+
println!();
167+
168+
if !marketplace_added {
169+
println!(" Run these in your terminal:");
170+
println!();
171+
println!(
172+
" {}",
173+
"claude plugin marketplace add treble-app/cli".bold()
174+
);
175+
println!(" {}", "claude plugin install treble".bold());
176+
} else {
177+
println!(" Run this in your terminal:");
178+
println!();
179+
println!(" {}", "claude plugin install treble".bold());
180+
}
181+
}
182+
127183
/// Extract a Figma file key from a URL or raw key string.
128184
/// Handles:
129185
/// - "abc123DEFghiJKL" (raw key)

0 commit comments

Comments
 (0)