Command-line utilities for Pathlight.
Two subcommands:
pathlight share— single-file HTML snapshot of a trace, zero deps to openpathlight fix— BYOK code-fixing agent that reads a failing trace, pulls source, and prints a unified diff (CLI mirror of the dashboard's "Fix this" flow)
npm install -g @pathlight/cli
# or run ad-hoc
npx @pathlight/cli <subcommand> [args]Export a single-file HTML snapshot of a trace. Perfect for attaching to bug reports, PR comments, or incident channels — the recipient doesn't need Pathlight installed, there are no network calls, and the file opens in any browser.
pathlight share abc123def --out ./bug-report.html| Flag | Default | Purpose |
|---|---|---|
--base-url <url> |
$PATHLIGHT_URL or http://localhost:4100 |
Collector URL |
--out <path> |
./pathlight-<id>.html |
Output file path |
--redact-input |
Replace input / toolArgs with [redacted] |
|
--redact-output |
Replace output / toolResult | |
--redact-errors |
Replace error messages |
Trace metadata, all spans (waterfall + per-span JSON), input/output, events, and git provenance if captured. No scripts other than the vanilla rendering logic — it's safe to send across security boundaries.
BYOK code-fixing agent. Reads a failing trace from your collector, pulls the
source files the trace's spans referenced (via _source.file metadata), and
asks an LLM (Anthropic or OpenAI, your key) to propose a unified diff.
The same engine powers the dashboard's "Fix this" button — the CLI is the headless / CI surface.
# Set your BYOK LLM key once per shell
export PATHLIGHT_LLM_API_KEY=sk-ant-... # or sk-... for OpenAI
# Path mode — read source from a local checkout (default mode)
pathlight fix trc_xxx --source-dir .
# Apply the proposed diff to the working tree (runs `git apply --check` first)
pathlight fix trc_xxx --source-dir . --apply
# Pipe the diff into your own review workflow
pathlight fix trc_xxx --source-dir . > /tmp/fix.patch
git checkout -b fix/trc_xxx
git apply /tmp/fix.patchProgress events go to stderr (# fetching trace, # reading 3 source files,
# calling anthropic claude-opus-4-7); the diff goes to stdout so piping
works cleanly.
export PATHLIGHT_LLM_API_KEY=sk-ant-...
export PATHLIGHT_GIT_TOKEN=ghp_... # read-only PAT
pathlight fix trc_xxx \
--git-url https://github.com/acme/repo.git \
--git-ref mainThe engine does a shallow clone (depth=1) into a tempdir, checks out the ref,
and cleans up on exit. Tokens never hit disk and are scrubbed from any error
output.
pathlight fix trc_xxx \
--bisect \
--from <known-good-sha> \
--to <known-bad-sha> \
--git-url https://github.com/acme/repo.gitBinary-searches the commit range — O(log₂ N) probe calls for N commits —
and returns the regression SHA plus a fix proposed against that commit.
The bisect endpoints are validated first: if from actually reproduces the
failure or to doesn't, the engine bails with an explanation rather than
silently picking the wrong SHA.
| Flag | Default | Purpose |
|---|---|---|
--source-dir <path> |
— | Path mode — read source from local dir |
--git-url <url> |
— | Git mode — clone + read source |
--git-ref <ref> |
HEAD |
Git ref to check out (mode: git/bisect) |
--bisect |
off | Switch to bisect mode (requires --from, --to, --git-url) |
--from <sha> |
— | Known-good SHA (bisect mode) |
--to <sha> |
— | Known-bad SHA (bisect mode) |
--mode <span|trace> |
span |
Which span(s) to fix (ignored in bisect) |
--provider <anthropic|openai> |
anthropic |
LLM provider |
--model <id> |
provider default | Override the model |
--apply |
off | Run git apply on the diff (path mode only) |
--base-url <url> |
$PATHLIGHT_URL or http://localhost:4100 |
Collector URL |
| Variable | Required for | Notes |
|---|---|---|
PATHLIGHT_LLM_API_KEY |
every pathlight fix call |
Anthropic sk-ant-… or OpenAI sk-… |
PATHLIGHT_GIT_TOKEN |
--git-url and --bisect |
Read-only PAT; never logged |
PATHLIGHT_URL |
optional | Collector URL (defaults to http://localhost:4100) |
| Provider | Default model |
|---|---|
anthropic |
claude-opus-4-7 |
openai |
gpt-5.4 |
Override per call with --model <id>.
# .github/workflows/agent-regressions.yml
- name: Auto-propose fix on failed run
if: failure()
env:
PATHLIGHT_URL: ${{ secrets.PATHLIGHT_URL }}
PATHLIGHT_LLM_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
pathlight fix "$LATEST_FAILED_TRACE_ID" --source-dir . > fix.patch
if [ -s fix.patch ]; then
gh pr comment "$PR_NUMBER" --body "$(printf '%s\n```diff\n%s\n```' \
'Pathlight proposed a fix for the failing trace:' "$(cat fix.patch)")"
fi- BYOK end-to-end. Pathlight never proxies your LLM traffic and never stores the keys you pass to the CLI.
PATHLIGHT_LLM_API_KEYandPATHLIGHT_GIT_TOKENare scrubbed from every error-path string before printing.- Each invocation emits a
fix.enginemeta-trace to your collector. The meta-trace carries mode, provider, model, token counts, and files changed — but never the diff body, the explanation, the API key, or the git token. --git-urlrequires read-only tokens. The CLI does not push, branch, or open PRs in v1.
The repo ships an example agent and a seed script that produces a failing
trace and demo files matched to its _source.file metadata:
# From the repo root, with a Pathlight stack running
node scripts/seed-screenshots.mjs # creates a project + failing trace
# Copy the printed "Fix-engine demo trace" id, then:
pathlight fix <printed-trace-id> \
--source-dir examples/quote-agentYou'll see the engine read examples/quote-agent/src/agents/quote.ts, identify
the JSON-parsing bug in composeEstimate, and emit a diff that tightens the
system prompt and adds a defensive parser.
- docs/fix.md — full feature deep-dive (modes, providers, source access, bisect internals)
- examples/fix-hello-world — minimal end-to-end loop
- examples/fix-bisect-regression — bisect walkthrough
- docs/byok-keys.md — encrypted key store the dashboard uses (CLI uses env vars instead)