Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-trace-reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@posthog/opencode': patch
---

Fix missing `$ai_input` and `$ai_model`/`$ai_provider` on generations and traces. OpenCode emits `message.updated` for the same user message several times per turn, and the plugin was starting a fresh trace on each one — wiping the captured prompt and the assistant model info before the generation was built. A new trace now starts only for a genuinely new user message, and the generation resolves model/provider from the specific assistant message the step belongs to.
5 changes: 5 additions & 0 deletions .changeset/flush-on-dispose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@posthog/opencode': patch
---

Flush and shut down the PostHog client on plugin dispose so short-lived `opencode run` invocations reliably deliver their final events. Previously the plugin only flushed on `session.idle`, but `posthog-node`'s `flush()` resolves before the HTTP request completes, so a process that exits immediately could drop its last generation, span, and trace.
5 changes: 5 additions & 0 deletions .changeset/official-posthog-opencode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@posthog/opencode': minor
---

Adopt as the official PostHog LLM Analytics plugin for OpenCode and align packaging with the PostHog standard: publish as `@posthog/opencode`, migrate the toolchain from bun to pnpm, and adopt the approval-gated release workflow with npm OIDC trusted publishing and provenance.
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

47 changes: 17 additions & 30 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# MIT License
#
# Copyright (c) 2026 PostHog Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: Setup
description: Setup Node.js and install dependencies

Expand All @@ -32,19 +10,28 @@ inputs:
runs:
using: composite
steps:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Setup pnpm
uses: pnpm/action-setup@c336a2788d9774dccfdeb4823a5058ccc9f07453 # v4.3.0

- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version-file: .nvmrc
cache: 'pnpm'

- name: Cache dependencies
uses: actions/cache@v4
id: pnpm-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
path: |
**/node_modules
.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
${{ runner.os }}-bun-
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
${{ runner.os }}-pnpm-

- name: Install dependencies
if: inputs.install == 'true'
run: bun install --frozen-lockfile
run: pnpm install --frozen-lockfile
shell: bash
33 changes: 7 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# MIT License
#
# Copyright (c) 2026 PostHog Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: CI

on:
Expand All @@ -32,16 +10,19 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6

- name: Setup environment
uses: ./.github/actions/setup

- name: Typecheck
run: bun run typecheck
run: pnpm typecheck

- name: Lint
run: bun run lint
run: pnpm lint

- name: Test
run: bun run test
run: pnpm test

- name: Build
run: pnpm build
Loading
Loading