Adopt OpenCode plugin as @posthog/opencode (rebrand, repackage, e2e fixes)#1
Conversation
- Rename package opencode-posthog -> @posthog/opencode - author: PostHog; credit Nejc Drobnič via contributors + README - Point repository/bugs/homepage at PostHog/posthog-opencode - LICENSE: keep Nejc copyright, add PostHog, Inc. - $ai_lib: opencode-posthog -> posthog-opencode (matches @posthog/openclaw convention) - Remove personal .github/FUNDING.yml - Update tests, README, CHANGELOG accordingly Adopted from github.com/Quantumlyy/opencode-posthog (MIT). Full history preserved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfe00d5d99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Migrate toolchain bun -> pnpm (pnpm-lock.yaml, pnpm-workspace.yaml, .nvmrc=24, engines) - Build dist with tsc (posthog-node external, not bundled) via tsconfig.build.json - CI + setup action -> pnpm (typecheck/lint/test/build) - Replace release workflow with the PostHog template used by @posthog/pi and @posthog/openclaw: label-triggered, Release approval environment, GitHub App token, npm OIDC trusted publishing (--provenance), Slack + PostHog notifications - version.ts -> literal synced by the release workflow - Add vitest.config.ts; add changeset for the initial @posthog/opencode release Keeps the dist build (idiomatic for OpenCode plugins, which resolve a compiled package entrypoint), while adopting PostHog's pnpm + publishing conventions. Verified: pnpm typecheck/lint clean, 41/41 tests, build emits dist, dist loads.
Update: packaging + publishing aligned to PostHog standard (commit
|
posthog-node's flush() resolves before the HTTP send completes, so a short-lived `opencode run` invocation would exit and drop its final $ai_generation/$ai_span/$ai_trace events. Add a dispose hook (awaited by OpenCode during plugin teardown) that calls client.shutdown(), which drains all pending events and awaits the network round-trip. The session.idle flush is kept for prompt delivery during long-lived interactive sessions.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e64cb410ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
OpenCode emits message.updated for the same user message multiple times per turn. The plugin created a new trace on every one, wiping the accumulated prompt ($ai_input) and assistant model info before the generation was built on step-finish — so real sessions showed 'No input' and model 'unknown' (synthetic single-fire harness missed this). - Only start a new trace for a genuinely new user message id; ignore repeat updates of the same message. - Resolve generation model/provider from the assistant message the step belongs to (assistantMessages[part.messageID]) instead of a lagging pointer. - Add src/index.test.ts regression test reproducing the real event ordering. Verified against the captured real event stream: model=gpt-5.4-mini, provider=openai, $ai_input + trace input_state now populated. 42 tests pass.
Satisfy PostHog org security checks: - Pin all GitHub Actions to full-length commit SHAs (org ruleset requirement). - Add pnpm minimumReleaseAge=10080 (7d) with our own packages excluded, matching the monorepo (semgrep-package-managers supply-chain rule).
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Adopts the community plugin
Quantumlyy/opencode-posthog(MIT, by Nejc Drobnič) as the official PostHog LLM Analytics plugin for OpenCode —@posthog/opencode, alongside@posthog/piand@posthog/openclaw.mainpreserves Nejc's full git history; this PR is the rebrand + repackage + fixes on top.Security audit (adopted third-party code) — clean
posthog-node→@posthog/core(both PostHog).posthog-node→ the configuredPOSTHOG_HOST; reads onlyPOSTHOG_*env. No secrets ever committed.Changes
opencode-posthog→@posthog/opencode;author: PostHog, Nejc credited (contributors+ README); repo URLs → PostHog org; LICENSE keeps Nejc + adds PostHog; removed personalFUNDING.yml;$ai_lib→posthog-opencode.distwithtsc(posthog-nodeexternal); CI + setup → pnpm; release workflow = the pi/openclaw template (label-triggered,Releaseapproval env, GitHub App token, npm OIDC trusted publishing + provenance). Kept the compileddistbecause OpenCode resolves a compiled package entrypoint (verified via its loader + real plugins).disposehook →client.shutdown()so short-livedopencode runreliably delivers tail events (posthog-nodeflush()resolves before the HTTP send completes).message.updated(OpenCode fires it 3×/turn) — fixes$ai_model/$ai_providerunknownand was wiping accumulated state. Generation now resolves model by the step'smessageID. Regression test added.minimumReleaseAgeset.Verified end-to-end (live PostHog project)
✅ Events deliver on exit (dispose) · ✅
$ai_generation/$ai_span/$ai_traceland taggedframework=opencode· ✅ model/provider correct (gpt-5.4-mini/openai) · ✅ tool spans + generation→span parenting · ✅cost: 0confirmed real (OpenAI via oauth). 42 unit tests pass; all CI green.Known follow-up (not blocking — pre-existing, can iterate later)
$ai_input/$ai_output_choicescontent capture is still incomplete in real multi-step/tool sessions (model/spans/structure are correct; the prompt/response content fields can be null). Tracked for a fast-follow.Org-admin setup required before the first release
See the pinned checklist comment (GitHub App,
Releaseenvironment, env secrets, ruleset bypasses, org secret grants,npx setup-npm-trusted-publish @posthog/opencode).