Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions colgrep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,13 @@ Config stored at `~/.config/colgrep/config.json`.

## Agent Integrations

| Agent | Install | Uninstall |
| ----------- | ------------------------------- | --------------------------------- |
| Claude Code | `colgrep --install-claude-code` | `colgrep --uninstall-claude-code` |
| OpenCode | `colgrep --install-opencode` | `colgrep --uninstall-opencode` |
| Codex | `colgrep --install-codex` | `colgrep --uninstall-codex` |
| Hermes | `colgrep --install-hermes` | `colgrep --uninstall-hermes` |
| Agent | Install | Uninstall |
| ----------- | ------------------------------------ | -------------------------------------- |
| Claude Code | `colgrep --install-agent claude` | `colgrep --uninstall-agent claude` |
| OpenCode | `colgrep --install-agent opencode` | `colgrep --uninstall-agent opencode` |
| Codex | `colgrep --install-agent codex` | `colgrep --uninstall-agent codex` |
| Hermes | `colgrep --install-agent hermes` | `colgrep --uninstall-agent hermes` |
| Droid | `colgrep --install-agent droid` | `colgrep --uninstall-agent droid` |

> Restart your agent after installing.

Expand Down
33 changes: 17 additions & 16 deletions colgrep/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use clap::{Parser, Subcommand};
use colgrep::install::Agent;

pub const MAIN_HELP: &str = "\
EXAMPLES:
Expand Down Expand Up @@ -366,36 +367,36 @@ pub struct Cli {
#[arg(long, value_name = "FLOAT")]
pub alpha: Option<f32>,

/// Install colgrep as a plugin for Claude Code
#[arg(long = "install-claude-code")]
/// Install colgrep for an AI coding agent
#[arg(long = "install-agent", value_name = "AGENT")]
pub install_agent: Option<Agent>,

/// Uninstall colgrep from an AI coding agent
#[arg(long = "uninstall-agent", value_name = "AGENT")]
pub uninstall_agent: Option<Agent>,

#[arg(long = "install-claude-code", hide = true)]
pub install_claude_code: bool,

/// Uninstall colgrep plugin from Claude Code
#[arg(long = "uninstall-claude-code")]
#[arg(long = "uninstall-claude-code", hide = true)]
pub uninstall_claude_code: bool,

/// Install colgrep for OpenCode
#[arg(long = "install-opencode")]
#[arg(long = "install-opencode", hide = true)]
pub install_opencode: bool,

/// Uninstall colgrep from OpenCode
#[arg(long = "uninstall-opencode")]
#[arg(long = "uninstall-opencode", hide = true)]
pub uninstall_opencode: bool,

/// Install colgrep for Codex
#[arg(long = "install-codex")]
#[arg(long = "install-codex", hide = true)]
pub install_codex: bool,

/// Uninstall colgrep from Codex
#[arg(long = "uninstall-codex")]
#[arg(long = "uninstall-codex", hide = true)]
pub uninstall_codex: bool,

/// Install colgrep for Hermes
#[arg(long = "install-hermes")]
#[arg(long = "install-hermes", hide = true)]
pub install_hermes: bool,

/// Uninstall colgrep from Hermes
#[arg(long = "uninstall-hermes")]
#[arg(long = "uninstall-hermes", hide = true)]
pub uninstall_hermes: bool,

/// Completely uninstall colgrep: remove from all AI tools, clear all indexes, and remove all data
Expand Down
2 changes: 1 addition & 1 deletion colgrep/src/install/claude_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ fn print_install_success() {
println!(" • Index updates automatically when files change");
println!();
println!(" {}", "To uninstall:".cyan().bold());
println!(" {}", "colgrep --uninstall-claude-code".green());
println!(" {}", "colgrep --uninstall-agent claude".green());
println!();
println!("{}", border.yellow());
println!();
Expand Down
2 changes: 1 addition & 1 deletion colgrep/src/install/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn print_codex_success() {
println!(" {}", "Example: \"find error handling logic\"".white());
println!();
println!(" {}", "To uninstall:".cyan().bold());
println!(" {}", "colgrep --uninstall-codex".green());
println!(" {}", "colgrep --uninstall-agent codex".green());
println!();
println!("{}", "═".repeat(70).cyan());
}
75 changes: 75 additions & 0 deletions colgrep/src/install/droid.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use anyhow::{Context, Result};
use colored::Colorize;
use std::fs;
use std::path::PathBuf;

use super::SKILL_MD;

fn get_skill_dir() -> Result<PathBuf> {
let home = dirs::home_dir().context("Could not determine home directory")?;
Ok(home.join(".factory").join("skills").join("colgrep"))
}

fn get_skill_md_path() -> Result<PathBuf> {
Ok(get_skill_dir()?.join("SKILL.md"))
}

fn create_skill() -> Result<()> {
let skill_dir = get_skill_dir()?;
fs::create_dir_all(&skill_dir)?;

let frontmatter = "\
---
name: colgrep
description: Semantic code search - finds code by meaning, not just text. Use as the PRIMARY search tool instead of Grep/Glob.
---

";

let skill_content = format!("{}{}", frontmatter, SKILL_MD);
fs::write(get_skill_md_path()?, skill_content)?;
Ok(())
}

fn remove_skill() -> Result<()> {
let skill_dir = get_skill_dir()?;
if skill_dir.exists() {
fs::remove_dir_all(&skill_dir)?;
}
Ok(())
}

pub fn install_droid() -> Result<()> {
println!("Installing colgrep for Droid (Factory)...");
create_skill()?;
let skill_path = get_skill_md_path()?;
println!(
"{} Created colgrep skill at {}",
"✓".green(),
skill_path.display()
);
println!();
println!("{}", "═".repeat(70).cyan());
println!(
" {} {}",
"✓".green().bold(),
"COLGREP INSTALLED FOR DROID (FACTORY)".green().bold()
);
println!(" Restart Droid sessions to pick up the new skill.");
println!(
" To uninstall: {}",
"colgrep --uninstall-agent droid".green()
);
println!("{}", "═".repeat(70).cyan());
Ok(())
}

pub fn uninstall_droid() -> Result<()> {
println!("Uninstalling colgrep from Droid (Factory)...");
remove_skill()?;
println!(
"{} Removed colgrep skill from ~/.factory/skills/colgrep/",
"✓".green()
);
Ok(())
}
5 changes: 4 additions & 1 deletion colgrep/src/install/hermes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ pub fn install_hermes() -> Result<()> {
"COLGREP INSTALLED FOR HERMES".green().bold()
);
println!(" Restart Hermes sessions to pick up the AGENTS.md update.");
println!(" To uninstall: {}", "colgrep --uninstall-hermes".green());
println!(
" To uninstall: {}",
"colgrep --uninstall-agent hermes".green()
);
println!("{}", "═".repeat(70).cyan());
Ok(())
}
Expand Down
35 changes: 35 additions & 0 deletions colgrep/src/install/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
mod claude_code;
mod codex;
mod droid;
mod hermes;
mod opencode;
mod uninstall;

use clap::ValueEnum;

pub use claude_code::{install_claude_code, uninstall_claude_code};
pub use codex::{install_codex, uninstall_codex};
pub use droid::{install_droid, uninstall_droid};
pub use hermes::{install_hermes, uninstall_hermes};
pub use opencode::{install_opencode, uninstall_opencode};
pub use uninstall::uninstall_all;

use anyhow::Result;

#[derive(ValueEnum, Clone, Debug)]
pub enum Agent {
Opencode,
Claude,
Codex,
Hermes,
Droid,
}

pub fn install_agent(agent: &Agent) -> Result<()> {
match agent {
Agent::Opencode => install_opencode(),
Agent::Claude => install_claude_code(),
Agent::Codex => install_codex(),
Agent::Hermes => install_hermes(),
Agent::Droid => install_droid(),
}
}

pub fn uninstall_agent(agent: &Agent) -> Result<()> {
match agent {
Agent::Opencode => uninstall_opencode(),
Agent::Claude => uninstall_claude_code(),
Agent::Codex => uninstall_codex(),
Agent::Hermes => uninstall_hermes(),
Agent::Droid => uninstall_droid(),
}
}

/// Shared skill instructions for all AI coding tools
pub const SKILL_MD: &str = include_str!("SKILL.md");
2 changes: 1 addition & 1 deletion colgrep/src/install/opencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn print_opencode_success() {
println!(" {}", "Example: \"find error handling logic\"".white());
println!();
println!(" {}", "To uninstall:".cyan().bold());
println!(" {}", "colgrep --uninstall-opencode".green());
println!(" {}", "colgrep --uninstall-agent opencode".green());
println!();
println!("{}", "═".repeat(70).cyan());
}
15 changes: 14 additions & 1 deletion colgrep/src/install/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use colored::Colorize;
use std::fs;
use std::path::PathBuf;

use super::{uninstall_claude_code, uninstall_codex, uninstall_hermes, uninstall_opencode};
use super::{
uninstall_claude_code, uninstall_codex, uninstall_droid, uninstall_hermes, uninstall_opencode,
};

/// Get the colgrep data directory (contains indices and config)
fn get_colgrep_data_dir() -> Result<PathBuf> {
Expand Down Expand Up @@ -113,6 +115,17 @@ fn uninstall_ai_tools() {
}
}

// Droid (Factory)
match uninstall_droid() {
Ok(()) => {}
Err(_) => {
println!(
" {} Droid (Factory): not installed or already removed",
"-".dimmed()
);
}
}

println!();
}

Expand Down
5 changes: 3 additions & 2 deletions colgrep/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ pub use parser::{

// Install commands for AI coding tools
pub use install::{
install_claude_code, install_codex, install_hermes, install_opencode, uninstall_all,
uninstall_claude_code, uninstall_codex, uninstall_hermes, uninstall_opencode,
install_agent, install_claude_code, install_codex, install_droid, install_hermes,
install_opencode, uninstall_agent, uninstall_all, uninstall_claude_code, uninstall_codex,
uninstall_droid, uninstall_hermes, uninstall_opencode, Agent,
};

// Signal handling
Expand Down
13 changes: 11 additions & 2 deletions colgrep/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use rayon::ThreadPoolBuilder;

use colgrep::{
acceleration::{apply_acceleration_mode, env_acceleration_mode, AccelerationMode},
install_claude_code, install_codex, install_hermes, install_opencode, setup_signal_handler,
uninstall_all, uninstall_claude_code, uninstall_codex, uninstall_hermes, uninstall_opencode,
install_agent, install_claude_code, install_codex, install_hermes, install_opencode,
setup_signal_handler, uninstall_agent, uninstall_all, uninstall_claude_code, uninstall_codex,
uninstall_hermes, uninstall_opencode,
};

use cli::{Cli, Commands};
Expand Down Expand Up @@ -41,6 +42,14 @@ fn main() -> Result<()> {
apply_acceleration_mode(acceleration_mode);

// Handle global flags before subcommands
if let Some(ref agent) = cli.install_agent {
return install_agent(agent);
}

if let Some(ref agent) = cli.uninstall_agent {
return uninstall_agent(agent);
}

if cli.install_claude_code {
return install_claude_code();
}
Expand Down