# @ramarivera/pi-langfuse

Pi extension that exports full Pi session traces, tool activity, token usage, and costs to Langfuse via OpenTelemetry.

By default it sends OTLP traces to:

```text
https://langfuse.ai.roxasroot.net/otel/v1/traces
```

Override with `PI_LANGFUSE_OTLP_ENDPOINT` when testing against another collector.

## Install

```sh
pi install npm:@ramarivera/pi-langfuse@0.1.0
```

## Local Development

This checkout is live-enabled for Pi through:

```text
.pi/extensions/langfuse/index.ts
```

That shim imports the package entrypoint in `src/index.ts`, which imports the extension factory from `src/extension.ts`. Tests use the same symbol so local behavior, package behavior, and manual Pi behavior do not drift.

```sh
npm install
npm run check
npm test
npm run test:e2e
npm pack --dry-run
```

## Publishing

Publishing uses GitHub Actions trusted publishing in `.github/workflows/publish.yml`.

Before the first publish, configure npm trusted publishing:

- owner/repo: `ramarivera/pi-langfuse`
- workflow: `.github/workflows/publish.yml`
- environment: blank unless the workflow is changed to require one

No `NPM_TOKEN` is required for trusted publishing.
