Skip to content
Draft
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
42 changes: 42 additions & 0 deletions src-tauri/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ pub fn harness_resolve_grok() -> Result<CursorBinary, String> {
})
}

/// Resolve the OpenCrabs CLI (`opencrabs`).
#[tauri::command(async)]
pub fn harness_resolve_opencrabs() -> Result<CursorBinary, String> {
resolve_opencrabs()
.map(|path| CursorBinary {
path: path.to_string_lossy().into_owned(),
})
.ok_or_else(|| {
"OpenCrabs CLI not found. Install OpenCrabs from https://github.com/opencrabs/opencrabs, then retry."
.into()
})
}

/// Bind an ephemeral loopback port for `opencode serve`.
#[tauri::command]
pub fn harness_free_port() -> Result<u16, String> {
Expand Down Expand Up @@ -1412,6 +1425,35 @@ fn resolve_grok() -> Option<PathBuf> {
first_binary_matching(candidates, is_grok_agent)
}

fn resolve_opencrabs() -> Option<PathBuf> {
let home = dirs_home().map(PathBuf::from);
let mut candidates: Vec<PathBuf> = Vec::new();

if let Some(home) = &home {
candidates.push(home.join(".opencrabs/bin/opencrabs"));
candidates.push(home.join(".local/bin/opencrabs"));
candidates.push(home.join(".cargo/bin/opencrabs"));
candidates.push(home.join(".npm-global/bin/opencrabs"));
candidates.push(home.join("n/bin/opencrabs"));
}
#[cfg(target_os = "macos")]
candidates.push(PathBuf::from("/opt/homebrew/bin/opencrabs"));
candidates.push(PathBuf::from("/usr/local/bin/opencrabs"));
candidates.push(PathBuf::from("/usr/bin/opencrabs"));
candidates.push(PathBuf::from("/snap/bin/opencrabs"));
if let Some(from_shell) = which_via_login_shell("opencrabs") {
candidates.push(from_shell);
}

first_binary_matching(candidates, is_opencrabs_binary)
}

/// No same-named collision is known for `opencrabs`; an executable with the
/// right name is the agent CLI.
fn is_opencrabs_binary(path: &Path) -> bool {
binary_name_eq(path, "opencrabs")
}

fn is_pi_coding_agent(path: &Path) -> bool {
if !path.is_file() {
return false;
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ pub fn run() {
harness::harness_resolve_pi,
harness::harness_resolve_fx,
harness::harness_resolve_grok,
harness::harness_resolve_opencrabs,
harness::harness_free_port,
harness::harness_spawn,
harness::harness_write,
Expand Down
21 changes: 21 additions & 0 deletions src/assets/providers/opencrabs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/chrome/HarnessIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cursor from "../assets/providers/cursor.svg";
import fx from "../assets/providers/fx.svg";
import grok from "../assets/providers/grok.svg";
import omp from "../assets/providers/omp.svg";
import opencrabs from "../assets/providers/opencrabs.svg";
import opencode from "../assets/providers/opencode.svg";
import pi from "../assets/providers/pi.svg";
import type { HarnessId } from "../lib/session";
Expand All @@ -18,6 +19,7 @@ export const HARNESS_ICONS: Record<HarnessId, string> = {
pi,
omp,
fx,
opencrabs,
};

/** White marks that must follow `currentColor` so they stay visible in light mode. */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function fallbackName(mimeType: string): string {
return "attachment";
}

function fileUri(path: string): string {
export function fileUri(path: string): string {
const normalized = path.replace(/\\/g, "/");
const abs = normalized.startsWith("/") ? normalized : `/${normalized}`;
return `file://${abs.split("/").map(encodeURIComponent).join("/")}`;
Expand Down
14 changes: 14 additions & 0 deletions src/lib/harness/availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
resolveGrokBinary,
resolveOmpBinary,
resolveOpenCodeBinary,
resolveOpenCrabsBinary,
resolvePiBinary,
} from "./child";
import { isLiveHarness } from "./registry";
Expand All @@ -30,6 +31,10 @@ const CLI: Record<HarnessId, { name: string; install?: string }> = {
pi: { name: "Pi CLI", install: "npm i -g @earendil-works/pi-coding-agent" },
omp: { name: "omp CLI", install: "curl -fsSL https://omp.sh/install | sh" },
fx: { name: "fx CLI", install: "curl -fsSL https://fx.sh/setup.sh | bash" },
opencrabs: {
name: "OpenCrabs CLI",
install: "https://github.com/opencrabs/opencrabs",
},
};

let availability: HarnessAvailability = {
Expand All @@ -41,6 +46,7 @@ let availability: HarnessAvailability = {
pi: false,
omp: false,
fx: false,
opencrabs: false,
};
let version = 0;
let inflight: Promise<void> | null = null;
Expand Down Expand Up @@ -159,6 +165,14 @@ export function probeHarnessAvailability(
return [id, false] as const;
}
}
if (id === "opencrabs") {
try {
await resolveOpenCrabsBinary();
return [id, true] as const;
} catch {
return [id, false] as const;
}
}
return [id, false] as const;
}),
)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/harness/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ export function resolveGrokBinary(): Promise<{ path: string }> {
return invoke("harness_resolve_grok");
}

export function resolveOpenCrabsBinary(): Promise<{ path: string }> {
return invoke("harness_resolve_opencrabs");
}

export function freeHarnessPort(): Promise<number> {
return invoke("harness_free_port");
}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/harness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export {
forgetGrokSession,
bindGrokSession,
} from "./grok";
export {
sendOpenCrabsTurn,
cancelOpenCrabsTurn,
respondOpenCrabsApproval,
stopOpenCrabsSession,
forgetOpenCrabsSession,
bindOpenCrabsSession,
} from "./opencrabs";
export { generateCursorSessionTitle } from "./cursorTitle";
export { generateCodexSessionTitle } from "./codexTitle";
export { generateOpenCodeSessionTitle } from "./opencodeTitle";
Expand Down
Loading