open-index/open-npm huggingface dataset:
npm package: @harnesskit/collector
Description: CLI for forwarding ingestion events to the API.
Latest version: 0.1.0

# HarnessKit Collector

CLI for forwarding ingestion events to the API.

## Quickstart

Build the CLI:

```bash
pnpm --filter @harnesskit/collector build
```

One-time install (writes `~/.harnesskit/config.json` and enables the OpenCode plugin):

```bash
curl -sSL http://localhost:3001/install/opencode | bash -s -- \
  --api-key $API_KEY \
  --project-id $PROJECT_ID
```

Claude Code install (writes config and adds hooks to `~/.claude/settings.json`):

```bash
curl -sSL http://localhost:3001/install/claude-code | bash -s -- \
  --api-key $API_KEY \
  --project-id $PROJECT_ID
```

Send events (JSON array or NDJSON):

```bash
cat events.json | pnpm --filter @harnesskit/collector dev -- ingest
```

Hook usage (streams JSON array or NDJSON):

```bash
harnesskit-opencode-hook
```

From this repo without installing a global bin:

```bash
pnpm --filter @harnesskit/collector exec harnesskit-opencode-hook
```

Environment variables:

- `HARNESSKIT_API_URL`
- `HARNESSKIT_API_KEY`
- `HARNESSKIT_PROJECT_ID`
- `HARNESSKIT_TOOL_SOURCE`
- `HARNESSKIT_VERSION`
- `HARNESSKIT_BUFFER_PATH`
- `HARNESSKIT_MAX_RETRIES`
- `HARNESSKIT_RETRY_BASE_MS`
- `HARNESSKIT_RETRY_MAX_MS`
- `HARNESSKIT_REDACT_ALLOWLIST`
- `HARNESSKIT_REDACT_DENYLIST`
- `HARNESSKIT_REDACT_KEYS`
- `HARNESSKIT_REDACT_MAX_STRING`
- `HARNESSKIT_REDACT_MAX_DEPTH`

Config file: `~/.harnesskit/config.json`

```json
{
  "apiUrl": "http://localhost:3001",
  "apiKey": "...",
  "projectId": "...",
  "toolSource": "claude_code"
}
```

## Hook Wrappers

The hook entrypoints set `tool_source` when it is missing on events:

- `harnesskit-claude-hook`
- `harnesskit-codex-hook`
- `harnesskit-opencode-hook`

Pipe event JSON into the hook binary and it will forward to the API.

OpenCode example (pipe the OpenCode JSON event stream):

```bash
opencode <your args> | harnesskit-opencode-hook
```

## OpenCode plugin (recommended)

OpenCode can load an npm plugin that streams events directly to HarnessKit.
The installer above adds it automatically. To do it manually, add this to your
OpenCode config (`~/.config/opencode/opencode.json`):

```json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@harnesskit/opencode"]
}
```

Make sure `~/.harnesskit/config.json` contains `apiUrl`, `apiKey`, and `projectId`,
or export `HARNESSKIT_API_URL`, `HARNESSKIT_API_KEY`, and `HARNESSKIT_PROJECT_ID`.

## Buffering & Retry

When the API is unavailable, batches are buffered to disk and retried on the next run.
The default buffer file is `~/.harnesskit/queue.ndjson`.

## Redaction

Client-side redaction applies to action payloads before sending. It can:

- Denylist or allowlist file paths
- Redact values by key names (e.g., secrets/tokens)
- Truncate long strings and deep payloads
  Print redacted events without sending:

```bash
pnpm --filter @harnesskit/collector dev -- --file events.json --dry-run --print-redacted
```
npm package: @harnesskit/opencode
Description: Capture OpenCode sessions and send telemetry to HarnessKit.
Latest version: 0.1.0

# HarnessKit OpenCode Plugin

Capture OpenCode sessions and send telemetry to HarnessKit.

## Install (OpenCode config)

Add the plugin to your OpenCode config (`~/.config/opencode/opencode.json` or project `opencode.json`):

```json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@harnesskit/opencode"]
}
```

## Configure HarnessKit

Set HarnessKit credentials via `~/.harnesskit/config.json`:

```json
{
  "apiUrl": "https://api.harnesskit.io",
  "apiKey": "<YOUR_API_KEY>",
  "projectId": "<YOUR_PROJECT_ID>",
  "toolSource": "opencode"
}
```

Or set environment variables (highest priority):

```bash
export HARNESSKIT_API_URL=https://api.harnesskit.io
export HARNESSKIT_API_KEY=...
export HARNESSKIT_PROJECT_ID=...
```

## Notes

- The plugin listens to OpenCode events and posts sessions + actions to HarnessKit.
- If OpenCode is offline, the collector buffer handles retries.