npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@canonical/harnesses

v0.23.0

Published

AI harness detection, MCP config read/write for Claude Code, Cursor, Windsurf, Cline, Roo Code.

Readme

Harnesses

Detects AI harnesses (Claude Code, Cursor, Windsurf, Cline, Roo Code) and reads/writes their MCP server configuration. All operations are @canonical/task Tasks — dry-runnable, testable, composable.

import { detectHarnesses, writeMcpConfig } from "@canonical/harnesses";
import { runTask } from "@canonical/task";

const detected = await runTask(detectHarnesses("/my/project"));
// [{ harness: { id: "claude-code", ... }, confidence: "high", configPath: "/my/project/.mcp.json" }]

Installation

bun add @canonical/harnesses

Requires @canonical/task as a peer dependency.

Detection

detectHarnesses() checks the filesystem for known harness signals and returns matches sorted by confidence.

import { detectHarnesses } from "@canonical/harnesses";
import { runTask } from "@canonical/task";

const detected = await runTask(detectHarnesses("/my/project"));

for (const d of detected) {
  console.log(`${d.harness.name}: ${d.confidence}, config exists: ${d.configExists}`);
}

Each harness defines detection signals:

| Signal type | Confidence | Example | |-------------|------------|---------| | directory | high | ~/.claude exists | | file | high | .mcp.json exists | | extension | medium | VS Code extension installed | | process | medium | Running process name | | env | low | Environment variable hint |

Multiple harnesses can be detected simultaneously — a developer may use both Claude Code and Cursor.

MCP Configuration

Read, write, and remove MCP server entries from harness config files:

import { findHarnessById, readMcpConfig, writeMcpConfig, removeMcpConfig } from "@canonical/harnesses";
import { runTask } from "@canonical/task";

const claude = findHarnessById("claude-code")!;

// Read existing servers
const servers = await runTask(readMcpConfig(claude, "/my/project"));

// Add or update a server entry (merges with existing config)
await runTask(writeMcpConfig(claude, "/my/project", "pragma", {
  command: "pragma",
  args: ["mcp"],
}));

// Remove a server entry
await runTask(removeMcpConfig(claude, "/my/project", "pragma"));

Config merge behaviour:

  • If the config file doesn't exist, it is created (parent directory included)
  • If the file exists, the new entry is merged into the existing mcpServers object
  • Existing entries with the same name are overwritten
  • All other entries and fields in the config file are preserved

Harness Registry

The registry is pure data — adding a new harness is adding an entry, not writing new code.

| Harness | ID | Config path | Format | MCP key | Skills path | |---------|-----|------------|--------|---------|-------------| | Claude Code | claude-code | .mcp.json | JSON | mcpServers | .claude/skills/ | | Cursor | cursor | .cursor/mcp.json | JSON | mcpServers | .cursor/skills/ | | Windsurf | windsurf | ~/.codeium/windsurf/mcp_config.json | JSON | mcpServers | .windsurf/skills/ | | Cline | cline | .vscode/mcp.json | JSON | mcpServers | .agents/skills/ | | Roo Code | roo-code | .roo/mcp.json | JSON | mcpServers | .roo/skills/ | | OpenCode | opencode | opencode.json | JSON | mcp | .agents/skills/ | | Gemini CLI | gemini-cli | .gemini/settings.json | JSON | mcpServers | .agents/skills/ | | Codex | codex | .codex/config.toml | TOML | mcp_servers | .agents/skills/ | | VS Code | vscode | .vscode/mcp.json | JSON | servers | .agents/skills/ |

Each entry includes a version field (semver range) to support config format changes across harness versions. Multiple entries can exist for the same harness ID with different version ranges.

Codex uses TOML config — config read/write operations are not yet supported for TOML-based harnesses.

import { harnesses, findHarnessById } from "@canonical/harnesses";

// All known harnesses
console.log(harnesses.map(h => h.name));

// Lookup by ID
const cursor = findHarnessById("cursor");
console.log(cursor?.configPath("/project")); // "/project/.cursor/mcp.json"
console.log(cursor?.skillsPath("/project")); // "/project/.cursor/skills"

Testing

Because every function returns a Task, tests never touch the filesystem:

import { dryRunWith, collectEffects, type Effect } from "@canonical/task";
import { detectHarnesses } from "@canonical/harnesses";

test("detects Claude Code from ~/.claude directory", () => {
  const mocks = new Map([
    ["Exists", (effect: Effect) =>
      (effect as Effect & { _tag: "Exists" }).path.includes(".claude")],
  ]);

  const result = dryRunWith(detectHarnesses("/project"), mocks);
  expect(result.value[0].harness.id).toBe("claude-code");
});

License

LGPL-3.0