|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Guidance for coding agents working in this repository. |
| 4 | + |
| 5 | +## What this is |
| 6 | + |
| 7 | +A Kotlin compiler plugin (`com.sourcegraph:semanticdb-kotlinc`) that emits |
| 8 | +[SemanticDB](https://scalameta.org/docs/semanticdb/specification.html) data for |
| 9 | +Kotlin sources, used with [scip-java](https://sourcegraph.github.io/scip-java) |
| 10 | +to produce [SCIP](https://github.com/sourcegraph/scip) indexes. See |
| 11 | +`README.md` for usage. |
| 12 | + |
| 13 | +## Layout |
| 14 | + |
| 15 | +- `build.sbt` — sbt build defining three projects: `kotlinc` (the plugin), |
| 16 | + `minimized` (compile fixtures + snapshot generation), and `snapshotsRunner` |
| 17 | + (runs scip-java). |
| 18 | +- `semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/` — |
| 19 | + main plugin sources (analyzer, registrars, SemanticDB builder/visitor). |
| 20 | +- `semanticdb-kotlinc/src/main/proto/` — protobuf definitions (Java codegen). |
| 21 | +- `semanticdb-kotlinc/src/test/kotlin/.../semanticdb_kotlinc/test/` — tests. |
| 22 | +- `semanticdb-kotlinc/minimized/` — fixtures and golden snapshots under |
| 23 | + `minimized/src/generatedSnapshots/resources/`. |
| 24 | +- `project/` — sbt version (`build.properties`) and plugins (`plugins.sbt`). |
| 25 | + |
| 26 | +## Setup |
| 27 | + |
| 28 | +- Build tool: sbt (`sbt.version` pinned in `project/build.properties`). |
| 29 | +- JDK: 11 (used by CI). |
| 30 | +- Kotlin version is pinned in `build.sbt` (`V.kotlin`); each release supports a |
| 31 | + single major Kotlin version (see the compatibility table in `README.md`). |
| 32 | + |
| 33 | +## Common commands |
| 34 | + |
| 35 | +Run from the repository root: |
| 36 | + |
| 37 | +```sh |
| 38 | +# Run the plugin's test suite |
| 39 | +sbt kotlinc/test |
| 40 | + |
| 41 | +# Regenerate the golden SemanticDB/SCIP snapshots |
| 42 | +sbt minimized/snapshots |
| 43 | + |
| 44 | +# Build the shaded fat-jar / publish locally |
| 45 | +sbt kotlinc/assembly |
| 46 | +sbt kotlinc/publishLocal |
| 47 | +``` |
| 48 | + |
| 49 | +## Conventions |
| 50 | + |
| 51 | +- After changing plugin behavior, regenerate snapshots with |
| 52 | + `sbt minimized/snapshots`. CI fails on snapshot drift via: |
| 53 | + |
| 54 | + ```sh |
| 55 | + git diff --exit-code semanticdb-kotlinc/minimized/src/generatedSnapshots |
| 56 | + ``` |
| 57 | + |
| 58 | +- Formatting for `.sbt`/Scala build files is handled by sbt-scalafmt |
| 59 | + (`sbt scalafmtAll`). |
| 60 | +- `kotlin-stdlib` and `kotlin-compiler-embeddable` are `Provided` — they are |
| 61 | + supplied by `kotlinc` at runtime and must not be bundled into the fat-jar. |
| 62 | + |
| 63 | +## CI |
| 64 | + |
| 65 | +`.github/workflows/ci.yml` runs `sbt kotlinc/test`, `sbt minimized/snapshots`, |
| 66 | +and the snapshot-drift check. `.github/workflows/release.yml` publishes via |
| 67 | +`sbt ci-release` on pushes to `main` and `v*` tags. |
0 commit comments