Skip to content

feat: add Kotlin Multiplatform (KMP) framework support#906

Merged
turnipdabeets merged 4 commits into
mainfrom
feat/kmp-support
Jul 16, 2026
Merged

feat: add Kotlin Multiplatform (KMP) framework support#906
turnipdabeets merged 4 commits into
mainfrom
feat/kmp-support

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

What

Adds Kotlin Multiplatform (KMP) as a supported framework in the wizard, following the existing mobile-framework pattern (Android / Swift).

  • New src/frameworks/kmp/kmp-wizard-agent.ts (KMP_AGENT_CONFIG)
  • Integration.kmp enum entry in src/lib/constants.ts, ordered before swift/android
  • FRAMEWORK_REGISTRY entry in src/lib/registry.ts

How it behaves

  • Detection requires a KMP signal a plain Android/Swift project doesn't have: a Gradle build file applying the Kotlin Multiplatform plugin (kotlin("multiplatform") / org.jetbrains.kotlin.multiplatform) or a src/commonMain source set. Ordered before Android/Swift in the enum (detection returns the first match) so a KMP project — which also looks like an Android/Swift project — resolves to KMP first, and non-KMP projects fall through to Android/Swift unchanged.
  • Install guidance tells the agent to add implementation("com.posthog:posthog-kmp:<VERSION>") to the shared module's commonMain dependencies and initialize from common code: PostHog.setup(config = PostHogConfig(apiKey, host), context = PostHogContext()), with the platform-specific PostHogContext (Android PostHogContext(application); iOS/Web no-arg).
  • Marked beta with a pre-release notice.

Why draft

The PostHog KMP SDK is currently 0.x pre-release and not yet on Maven Central, so com.posthog:posthog-kmp won't resolve until it publishes 0.0.1. Keeping this a draft until then. Companion work: the posthog.com docs page (/docs/libraries/kmp) and the install-taxonomy entry (wizard: true + status: 'wip', "Coming soon") are in a separate posthog.com PR.

Verification

  • pnpm build ✅ (binary loads, warlock smoke test passes)
  • vitest run on detection + TUI + CLI suites ✅ (287 tests)
  • eslint on changed files ✅ (0 errors, 0 warnings — matches the Android config)

🤖 Generated with Claude Code

Registers Kotlin Multiplatform in the wizard following the existing mobile
framework pattern (Android/Swift): a FrameworkConfig in src/frameworks/kmp,
an Integration.kmp enum entry, and a FRAMEWORK_REGISTRY entry.

Detection requires the Kotlin Multiplatform Gradle plugin or a commonMain
source set, and KMP is ordered before Android/Swift so a KMP project (which
also looks like an Android/Swift project) resolves to KMP first. The agent
prompts install com.posthog:posthog-kmp into the shared module's commonMain
dependencies and initialize PostHog from common code with a platform-specific
PostHogContext.

Marked beta with a pre-release notice — the KMP SDK is currently 0.x and not
yet published to Maven Central.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@turnipdabeets
turnipdabeets marked this pull request as ready for review July 15, 2026 15:20
@turnipdabeets
turnipdabeets requested a review from a team as a code owner July 15, 2026 15:20
@turnipdabeets
turnipdabeets requested a review from a team July 15, 2026 15:20
@gewenyu99

Copy link
Copy Markdown
Collaborator

Noice! Swing by FYI -> Context mill release needs to go out before this can be merge/released

@turnipdabeets

Copy link
Copy Markdown
Contributor Author

Quick update on the release gating 👇

posthog-kmp is now published to Maven Central (latest 0.0.2, both 0.0.1 and 0.0.2 are up), so the "SDK not on Maven yet" blocker is cleared — the install snippet resolves and the companion docs page is merged and live (/docs/libraries/kmp).

That leaves the context-mill release as the only remaining dependency here. I'm prepping the context-mill KMP PR now (adding posthog-kmp commandments/skill mirroring the other mobile SDKs) and will link it here once it's up. cc @gewenyu99

🤖 Generated with Claude Code

@turnipdabeets

Copy link
Copy Markdown
Contributor Author

Context-mill KMP PR is up 👉 PostHog/context-mill#240 (draft)

It adds the kmp integration skill + framework commandments. Identifiers line up with this PR: the generated skill id is kmp / integration-kmp, matching Integration.kmp / packageName: posthog-kmp / docsUrl: /docs/libraries/kmp here.

How the release gets cut (per context-mill's build-release.yml): merging #240 to main with the mcp-publish label auto-builds and publishes a new release (it auto-bumps the tag), or a maintainer runs the "Build and Release MCP Resources" workflow manually. Once that release is out, this PR is unblocked.

So the sequence is: merge context-mill#240 with mcp-publish (→ release) → merge/release this PR. cc @gewenyu99

🤖 Generated with Claude Code

@ioannisj ioannisj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add some unit tests as well in framework.test.ts?

Comment thread src/frameworks/kmp/kmp-wizard-agent.ts Outdated
Address review feedback on #906:

- Use the standard `posthog://docs/frameworks/kmp` docs reference in the agent
  context lines, matching every other framework config (was a raw web URL).
- Add unit tests in framework.test.ts mirroring the existing per-framework
  structure: a `kmp detect` block (claims the KMP plugin / commonMain source
  set; rejects a plain Android and a Flutter project), end-to-end cases (a KMP
  project resolves to `kmp`; a plain Android project still resolves to
  `android`, so ordering KMP ahead doesn't hijack it), and an enum-order
  assertion that `kmp` precedes `android`/`swift`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@turnipdabeets
turnipdabeets enabled auto-merge (squash) July 16, 2026 00:47
Merging main brought in the 'every Integration enum value resolves' guard,
which failed for the new Integration.kmp. Add the curated integration-kmp
menu entry (framework: kmp) mirroring the other detected mobile frameworks
(android/swift/react-native) so the enum→skill-variant contract holds.
@turnipdabeets
turnipdabeets merged commit 983dbe0 into main Jul 16, 2026
16 checks passed
@turnipdabeets
turnipdabeets deleted the feat/kmp-support branch July 16, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants