Agent SkillsDetachHead/rebased › pseudo-kmp

pseudo-kmp

GitHub

指导在JPS环境中配置和使用伪KMP模块,涵盖插件注册、依赖限制、源文件夹设置及IML文件配置,以模拟expect/actual声明。

.claude/skills/pseudo-kmp/SKILL.md DetachHead/rebased

Trigger Scenarios

创建或迁移使用伪KMP的模块 配置多平台模块的源文件夹和依赖

Install

npx skills add DetachHead/rebased --skill pseudo-kmp -g -y
More Options

Non-standard path

npx skills add https://github.com/DetachHead/rebased/tree/master/.claude/skills/pseudo-kmp -g -y

Use without installing

npx skills use DetachHead/rebased@pseudo-kmp

指定 Agent (Claude Code)

npx skills add DetachHead/rebased --skill pseudo-kmp -a claude-code -g -y

安装 repo 全部 skill

npx skills add DetachHead/rebased --all -g -y

预览 repo 内 skill

npx skills add DetachHead/rebased --list

SKILL.md

Frontmatter
{
    "name": "pseudo-kmp",
    "description": "Working with pseudo-KMP (Kotlin Multiplatform) modules in the IntelliJ monorepo. Use when creating, migrating, or modifying modules that use the expects-compiler-plugin for expect\/actual emulation in JPS projects."
}

Pseudo-KMP Modules

The monorepo is compiled by JPS, which does not support Kotlin Multiplatform. To emulate KMP expect/actual declarations, the Fleet team created the expects-compiler-plugin. This skill covers how to set up and work with modules that use this mechanism.

Documentation

Module Configuration Checklist

When creating or migrating a pseudo-KMP module:

  1. Register in the structure test. Add your module name to the multiplatformModules list in com.intellij.ideaProjectStructure.fast.MultiplatformModuleStructureTest (tests/ideaProjectStructure/testSrc/com/intellij/ideaProjectStructure/fast/MultiplatformModuleStructureTest.kt).

  2. Use only allowed library dependencies. The test enforces a closed set:

    • kotlin-stdlib
    • kotlinx-coroutines-core
    • kotlinx-coroutines-debug
    • jetbrains-annotations
    • kotlinx-serialization-core
    • kotlinx-serialization-json
    • kotlin-reflect
    • kotlinx-collections-immutable

    If you need a new library, add it to allowedMultiplatformLibraryDependencies in the test. Dependencies on other multiplatform modules (those in multiplatformModules) are also allowed.

  3. Set up source folders:

    • src/ — common code
    • srcJvm/ or srcJvmMain/ — JVM-specific code (Java code can live here too)
    • srcWasmJs/ or srcWasmJsMain/ — WasmJs-specific code
    • srcJsMain/ — JS-specific code
    • srcNativeMain/ — Native-specific code

    Important: Do NOT add srcWasmJs/srcWasmJsMain as a source root in the .iml file. The IDE would try to compile it in JVM mode.

  4. Add the .pseudoCommonKotlinSourceSet marker file to the common source root (e.g., src/.pseudoCommonKotlinSourceSet). This empty file tells the Kotlin plugin that the source set is common code, preventing Optimize Imports from removing imports that are unnecessary on JVM but mandatory in common code (e.g., @JvmStatic, @JvmField).

IML File Setup

Your .iml file needs two things: the multiplatformSupport dependency and the compiler plugin registration.

Use community/platform/util/multiplatform/intellij.platform.util.multiplatform.iml as a reference. To find the current plugin version, check that file rather than hardcoding.

1. Add the support module dependency (PROVIDED scope)

<orderEntry type="module" module-name="intellij.platform.multiplatformSupport" scope="PROVIDED" />

2. Add the Kotlin facet with expects-compiler-plugin

<facet type="kotlin-language" name="Kotlin">
  <configuration version="5" platform="JVM 1.8" allPlatforms="JVM [1.8]" useProjectSettings="false">
    <compilerSettings>
      <option name="additionalArguments" value="-Xjvm-default=all ..." />
    </compilerSettings>
    <compilerArguments>
      <stringArguments>
        <stringArg name="jvmTarget" arg="1.8" />
        <stringArg name="apiVersion" arg="2.3" />
        <stringArg name="languageVersion" arg="2.3" />
      </stringArguments>
      <arrayArguments>
        <arrayArg name="pluginClasspaths">
          <args>$MAVEN_REPOSITORY$/jetbrains/fleet/expects-compiler-plugin/{VERSION}/expects-compiler-plugin-{VERSION}.jar</args>
        </arrayArg>
      </arrayArguments>
    </compilerArguments>
  </configuration>
</facet>

Replace {VERSION} with the version from the reference IML.

Expect/Actual Pattern

Only top-level functions are supported. Both the expect and actual declarations must be in the same module.

Common side (in src/)

Use linkToActual() as the function body:

import fleet.util.multiplatform.linkToActual

internal fun myFunction(param1: String, param2: Int): Boolean = linkToActual()

Platform side (in srcJvm/, srcWasmJs/, etc.)

Annotate with @Actual. The function name must be the expect function name + platform suffix:

import fleet.util.multiplatform.Actual

@Actual
internal fun myFunctionJvm(param1: String, param2: Int): Boolean {
  // JVM implementation
}

Platform suffixes

Platform Suffix Source folder
JVM Jvm srcJvm/ or srcJvmMain/
WasmJs WasmJs srcWasmJs/ or srcWasmJsMain/
JS Js srcJsMain/
Native Native srcNativeMain/
Multi-platform build Impl (rare)

Real example

Common (community/platform/util/base/multiplatform/src/com/intellij/util/text/CharArrayUtilKmp.kt):

internal fun getCharsPlatformSpecific(
  sequence: CharSequence, srcOffset: Int, dst: CharArray, dstOffset: Int, len: Int
): Boolean = linkToActual()

JVM actual (community/platform/util/base/multiplatform/srcJvmMain/com/intellij/util/text/jvm.kt):

@Actual
internal fun getCharsPlatformSpecificJvm(
  string: CharSequence, srcOffset: Int, dst: CharArray, dstOffset: Int, len: Int
): Boolean {
  if (string is CharBuffer) { /* ... */ }
  return false
}

Code Conversion Notes

  • The monorepo uses the JVM version of the Kotlin standard library, which differs from the common version. Check which declarations are available in common code.
  • @JvmStatic, @JvmField, and similar annotations are not auto-imported in common code. Import them manually. The .pseudoCommonKotlinSourceSet marker prevents the IDE from removing these imports.
  • Java code can remain in platform-specific source sets (srcJvm/).

After Editing

  1. Run ./build/jpsModelToBazel.cmd after modifying any .iml files.
  2. Run MultiplatformModuleStructureTest to validate module structure:
    ./tests.cmd --module tests.ideaProjectStructure --test com.intellij.ideaProjectStructure.fast.MultiplatformModuleStructureTest
    
  3. Lint changed files with mcp__ijproxy__lint_files.

Artifact Publication

The monorepo does not publish multiplatform artifacts to Maven Central directly. Separate repositories with Gradle infrastructure extract module sources, compile with true KMP, and publish. See fleet-multiplatform-deps and fleet-parser-collection in JetBrains Space.

Version History

  • 1f8708d Current 2026-08-16 15:39

Same Skill Collection

.agents/skills/actions/SKILL.md
.agents/skills/code-style/SKILL.md
.agents/skills/commits/SKILL.md
.agents/skills/debugging/SKILL.md
.agents/skills/driver-ui-tests/SKILL.md
.agents/skills/eel/SKILL.md
.agents/skills/extract-module/SKILL.md
.agents/skills/module-dependencies/SKILL.md
.agents/skills/module-set-pluginization/SKILL.md
.agents/skills/notebook-for-experiment/SKILL.md
.agents/skills/pseudo-kmp/SKILL.md
.agents/skills/registry/SKILL.md
.agents/skills/remote-dev/SKILL.md
.agents/skills/safe-push/SKILL.md
.agents/skills/ssr/SKILL.md
.agents/skills/testing-internals/SKILL.md
.agents/skills/testing/SKILL.md
.agents/skills/ui-accessibility/SKILL.md
.agents/skills/writing-tests/SKILL.md
.claude/skills/actions/SKILL.md
.claude/skills/code-style/SKILL.md
.claude/skills/commits/SKILL.md
.claude/skills/debugging/SKILL.md
.claude/skills/driver-ui-tests/SKILL.md
.claude/skills/eel/SKILL.md
.claude/skills/extract-module/SKILL.md
.claude/skills/jewel-pr-preparer/SKILL.md
.claude/skills/jewel-release-helper/SKILL.md
.claude/skills/managing-youtrack/SKILL.md
.claude/skills/module-dependencies/SKILL.md
.claude/skills/module-set-pluginization/SKILL.md
.claude/skills/notebook-for-experiment/SKILL.md
.claude/skills/registry/SKILL.md
.claude/skills/remote-dev/SKILL.md
.claude/skills/safe-push/SKILL.md
.claude/skills/ssr/SKILL.md
.claude/skills/testing-internals/SKILL.md
.claude/skills/testing/SKILL.md
.claude/skills/ui-accessibility/SKILL.md
.claude/skills/writing-tests/SKILL.md

Metadata

Files
0
Version
1f8708d
Hash
057226f9
Indexed
2026-08-16 15:39

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 16:41
浙ICP备14020137号-1 $mapa de visitantes$