Skip to content

feat(cli): add kotlin.md and detect Kotlin from root build files #72

Description

@amondnet

Context

Follow-up to #65 (option A in #65 (comment)).

#65 proposed kotlin.md, but only java.md shipped. Detection maps build.gradle, build.gradle.kts, and pom.xml to java, and --lang has no kotlin value. As a result, Kotlin Gradle projects such as Android or Spring Boot are linked to java.md, which is condensed from the Google Java Style Guide. Some of its rules contradict Kotlin conventions. For example, "a source file holds exactly one top-level class" conflicts with Kotlin's guidance on grouping several top-level declarations in one file. @pleaseai/ast-grep-config already ships rules/kotlin, so only the guide and the detection are missing.

Proposal

  • Add packages/cli/rules/kotlin.md, condensed from the Kotlin coding conventions (kotlinlang.org) the same way java.md was condensed from the Google guide. Check the license first, and add attribution to NOTICE.md if it is required.
  • Add kotlin to LANGUAGES, so that --lang kotlin, the AGENTS block, guide sync, and doctor all pick it up.
  • Detect Kotlin from the project root only. The project is Kotlin when either of these holds:
    • build.gradle(.kts) or settings.gradle(.kts) applies the Kotlin plugin (org.jetbrains.kotlin, kotlin(, or libs.plugins.kotlin).
    • src/main/kotlin exists.
  • A Gradle or Maven project without those signals stays java. When Java sources are also present (src/main/java containing .java files), select both.
  • Detection in workspace members (submodule build files) stays out of scope and follows the detection-depth open question in feat(cli): detect languages, run without package.json, and split rules into rules/<lang>.md #65.

Acceptance criteria

  • kotlin.md ships, with attribution added if its source license requires it.
  • Fixtures select the expected languages:
    • An Android-style root build.gradle.kts with alias(libs.plugins.kotlin.android) apply false → kotlin.
    • A Spring Boot Kotlin project using kotlin("jvm") → kotlin.
    • A plain Java Gradle project → java.
    • A Maven project → java.
    • A mixed Java and Kotlin project → both.
  • --lang kotlin is accepted and listed in the unknown-value error.
  • init/update copy kotlin.md into .agents/code-style/ and link it, and doctor reports it.
  • README / cli.mdx (en and ko) list kotlin and the detection signals.

Refs #65

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions