harness-locate 0.2.4

Cross-platform library for configuration, path discovery and MCP server management for agentic code harnesses (Claude Code, OpenCode, Goose, AMP Code)
Documentation

harness-locate

Crates.io Documentation License: MIT

Cross-platform harness path discovery for AI coding CLI tools.

Features

  • Detect installed AI coding assistants (Claude Code, OpenCode, Goose, AMP Code)
  • Resolve configuration paths (global and project-scoped)
  • Unified MCP server configuration types
  • Cross-platform support (macOS, Linux, Windows)

Quick Start

Detect Installed Harnesses

use harness_locate::{Harness, HarnessKind};

// Check all installed harnesses
for harness in Harness::installed()? {
    println!("{} is installed", harness.kind());
}
# Ok::<(), harness_locate::Error>(())

Get Configuration Paths

use harness_locate::{Harness, HarnessKind, Scope};

let harness = Harness::locate(HarnessKind::ClaudeCode)?;
let config_dir = harness.config(&Scope::Global)?;
println!("Config at: {}", config_dir.display());
# Ok::<(), harness_locate::Error>(())

MCP Server Configuration

use harness_locate::{Harness, HarnessKind};
use harness_locate::mcp::{McpServer, StdioMcpServer};

let server = McpServer::Stdio(StdioMcpServer {
    command: "npx".to_string(),
    args: vec!["-y".to_string(), "@modelcontextprotocol/server-filesystem".to_string()],
    env: Default::default(),
    cwd: None,
    enabled: true,
    timeout_ms: None,
});

// Check compatibility
let harness = Harness::new(HarnessKind::OpenCode);
if harness.supports_mcp_server(&server) {
    println!("Server is supported");
}

Supported Harnesses

Harness Skills Commands MCP Rules
Claude Code Yes Yes Yes Yes
OpenCode Yes Yes Yes Yes
Goose Yes No Yes Yes
AMP Code Yes Yes Yes Yes

Resource Types

DirectoryResource

For directory-based resources (skills, commands):

  • path - Directory location
  • exists - Whether directory exists
  • structure - Flat or Nested layout
  • file_format - Expected file format

Directory Structure Patterns

Skills use nested structure (one subdirectory per skill):

~/.config/opencode/skill/
  my-skill/
    SKILL.md

Commands use flat structure (files directly in directory):

~/.config/opencode/command/
  my-command.md
  another-command.md

This pattern applies across all harnesses that support the resource type.

ConfigResource

For file-based configuration (MCP):

  • file - Config file path
  • key_path - JSON pointer to relevant section
  • format - JSON, YAML, etc.

License

MIT