Skip to content

Commit 2a2bc74

Browse files
Copilotwax911
andauthored
chore: add GitHub skills and instruction files for support-query-builder (#427)
Agent-Logs-Url: https://github.com/AniTrend/support-query-builder/sessions/c14fa43e-3fed-457b-bae3-9b152f630d4e Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wax911 <7859175+wax911@users.noreply.github.com>
1 parent 0b0f460 commit 2a2bc74

11 files changed

Lines changed: 487 additions & 72 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
description: Use when editing Gradle files, module dependencies, version catalog entries, GitHub workflows, or buildSrc logic in support-query-builder.
3+
applyTo: build.gradle.kts, settings.gradle.kts, gradle/**/*.toml, buildSrc/**/*.kt, */build.gradle.kts, .github/workflows/*.yml
4+
---
5+
6+
# Build Logic Guidance
7+
8+
- Prefer the shared `co.anitrend.support.query.builder.plugin` plugin and `buildSrc` helpers over duplicating Android, Kotlin, Spotless, publishing, or test configuration in individual modules.
9+
- The pinned Java and Kotlin toolchain is 21. Keep new build logic compatible with `.java-version` (set to `21.0.8`) and the shared Android configuration. Systems are expected to have `jenv` installed; the `.java-version` file is what `jenv local` reads to align the active JDK.
10+
- Add or update dependency versions in `gradle/libs.versions.toml` first, then reference the alias from modules or build logic.
11+
- Keep module dependency changes aligned with the existing graph: `:core` and `:annotations` are JVM-only with no project dependencies; `:core:ext` depends only on `:core`; `:processor` depends only on `:annotations`.
12+
- `:annotations` and `:core` and `:processor` are classified as Kotlin library group (JVM-only, no Android plugin). `:core:ext` is an Android library. `:sample` is an Android application excluded from CI.
13+
- Shared Android defaults come from `buildSrc/.../ProjectConfiguration.kt`, including `compileSdk = 35`, `minSdk = 23`, `targetSdk = 35`, Java 21 compatibility, and `JvmTarget.JVM_21`.
14+
- Shared formatting comes from `buildSrc/.../ProjectSpotless.kt` and the license header file under `spotless/copyright.kt`.
15+
- Shared publishing behavior comes from `buildSrc/.../ProjectMaven.kt`; all published artifacts use the group `co.anitrend.query.builder` and are distributed via JitPack.
16+
- If you need a new convention across many modules, prefer adding it once in `buildSrc` instead of repeating it in each `build.gradle.kts` file.
17+
- When validating Gradle changes locally, pair the work with the existing `jenv-gradle-low-ram` skill if JDK alignment or memory pressure becomes a problem.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: Use when making architecture changes, module graph changes, package ownership changes, public API shifts, build logic updates, or editing repository customizations in support-query-builder. Keeps instructions, skills, and consumer-facing context aligned with current repository behavior.
3+
applyTo: build.gradle.kts, settings.gradle.kts, gradle/**/*.toml, buildSrc/**/*.kt, */build.gradle.kts, */src/main/**/*.kt, .github/instructions/*.md, .github/skills/**, README.md
4+
---
5+
6+
# Context Maintenance Guidance
7+
8+
- When a change materially alters repository reality, update the relevant repo guidance in the same patch instead of leaving instructions and skills stale.
9+
- Treat the following as context-bearing assets that may need maintenance after major changes: `.github/instructions/*.md`, `.github/skills/**`, and `README.md`.
10+
- Audit repo guidance when you change module boundaries, dependency direction, package ownership, shared build conventions, or consumer-facing extension points.
11+
- Audit the reference-map and build-dependencies skills when a module gains a new responsibility, a new package root becomes important, or the build and publishing workflow changes.
12+
- Remove or rewrite contradictory guidance instead of layering new instructions on top of obsolete ones.
13+
- Prefer updating an existing instruction or skill when the workflow still fits; add a new instruction or skill only when a genuinely new recurring concern appears.
14+
- Keep changes specific and low-churn: update only the files whose guidance is no longer true.
15+
- If a change affects how downstream apps should discover, import, or configure support-query-builder APIs, update the relevant consumer-facing guidance in the same change.
16+
- If repository memory is available, record durable repo facts after significant architectural or workflow changes so future tasks start with current context.
Lines changed: 39 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,56 @@
11
---
22
applyTo: **
3-
description: This file describes the architecture and module structure of the support-query-builder project.
3+
description: Use when understanding support-query-builder architecture, module boundaries, consumer-facing APIs, annotation processing, Room integration, or shared Gradle/buildSrc behavior.
44
---
55

6-
# Support Query Builder Architecture
6+
# Support Query Builder Context
77

8-
The support-query-builder project is a Kotlin library that provides a fluent SQL query builder with annotation processing capabilities for Android Room database integration. Its design goal is to generate type-safe SQL queries dynamically while maintaining compile-time verification through annotation processing.
8+
- `support-query-builder` is a reusable Kotlin library, not an app. Favor reusable abstractions, extension points, and stable consumer-facing APIs over app-specific behavior.
9+
- The library's primary purpose is to provide a fluent, type-safe SQL query builder that integrates with Android Room via generated schema objects and `SupportSQLiteQuery`.
10+
- Treat the published Dokka site as part of the product surface: `https://anitrend.github.io/support-query-builder/`.
911

10-
## Module Structure
12+
## Module Groups
1113

12-
The project is organized into distinct Gradle modules, each with specific responsibilities:
14+
- Core JVM modules: `:annotations`, `:core`, `:processor`
15+
- Android integration module: `:core:ext`
16+
- Development-only module: `:sample` (excluded from CI via `settings.gradle.kts`)
1317

14-
### Core Modules
15-
- **`:core`** - The main query builder library containing the core SQL query construction logic. This module provides the fluent builder API with support for complex queries including joins, unions, and chaining operations. It contains no Android-specific dependencies, making it a pure Kotlin library that can be used in any JVM environment.
16-
- **`:core:ext`** - Extension functions for the core module, primarily providing integration with Android Room's `SupportSQLiteQuery`. The main function `asSupportSQLiteQuery()` converts query builder instances to Room-compatible query objects.
18+
## Dependency Direction
1719

18-
### Annotation Processing
19-
- **`:annotations`** - Contains the annotation definitions used to mark Room entities for processing. This module is dependency-free and only defines the annotations that other modules consume.
20-
- **`:processor`** - Kotlin annotation processor (KAPT) that inspects Room entity annotations (`@Entity`, `@ColumnInfo`, `@Embedded`) and generates corresponding schema object classes. These generated objects mirror the entity structure and provide type-safe column references for the query builder.
20+
- `:annotations` is a JVM-only API module with no project dependencies. It only defines the `@EntitySchema` annotation and is the lowest layer.
21+
- `:core` is a pure JVM Kotlin module with no project dependencies. It owns the entire query builder API surface: `QueryBuilder`, `AbstractQueryBuilder`, `IQueryBuilder`, `Criteria`, `From`, `Order`, `Projection`, and their DSL helpers.
22+
- `:core:ext` is an Android library that depends on `:core`. It bridges the query builder to Room's `SupportSQLiteQuery` via extension functions.
23+
- `:processor` is a JVM KAPT module that depends on `:annotations`. It reads Room entity annotations and generates schema object classes using KotlinPoet and `auto-service`.
24+
- `:sample` depends on everything and is an Android application used for local development only.
25+
- Avoid introducing new dependencies that cause lower modules to depend on higher-layer ones.
2126

22-
### Development and Testing
23-
- **`:sample`** - Example application demonstrating library usage. This module is excluded from CI builds but serves as a practical reference for integration patterns and usage examples.
27+
## Package Expectations
2428

25-
## Architecture Principles
29+
- `:annotations` exposes `co.anitrend.support.query.builder.annotation` — the `@EntitySchema` annotation.
30+
- `:core` exposes `contract/`, `criteria/`, `from/`, `order/`, `projection/`, and the top-level `QueryBuilder` and `dsl/` entrypoints.
31+
- `:core:ext` exposes `co.anitrend.support.query.builder.core.ext` — the `asSupportSQLiteQuery()` extension and related Room helpers.
32+
- `:processor` exposes `extensions/`, `factory/`, `logger/`, and `model/` under `co.anitrend.support.query.builder.processor`. The `EntitySchemaProcessor` is the KAPT entry point.
2633

27-
### Type Safety
28-
The library emphasizes compile-time type safety through:
29-
- Generated schema objects that mirror Room entity definitions
30-
- Fluent builder API that prevents malformed SQL construction
31-
- Extension functions that seamlessly integrate with Room's type system
34+
## Build And Tooling Facts
3235

33-
### Room Integration
34-
The library is designed specifically for Room database integration:
35-
- Annotation processor reads Room entity annotations directly
36-
- Generated queries are compatible with Room's `@RawQuery` annotation
37-
- Support for Room's `SupportSQLiteQuery` interface through extension functions
36+
- All modules apply the shared `co.anitrend.support.query.builder.plugin` Gradle plugin from `buildSrc`.
37+
- Shared Android defaults live in `buildSrc/.../ProjectConfiguration.kt`: `compileSdk = 35`, `minSdk = 23`, `targetSdk = 35`, Java 21 source/target compatibility, and `JvmTarget.JVM_21` for Kotlin.
38+
- The repo Java pin is `.java-version = 21.0.8`. Systems are expected to have `jenv` installed; `.java-version` is picked up by `jenv local` to set the active JDK automatically. `buildSrc/.../ProjectConfiguration.kt` must stay aligned: `JavaVersion.VERSION_21` for Java source/target compatibility and `JvmTarget.JVM_21` for Kotlin must both match the `.java-version` major version (21).
39+
- Kotlin library group (JVM-only, no Android plugin): `:annotations`, `:core`, `:processor`. All other non-sample modules are Android libraries.
40+
- Dependency versions belong in `gradle/libs.versions.toml` before they are referenced from module build files.
41+
- Spotless and ktlint are enforced centrally via `buildSrc/.../ProjectSpotless.kt`, with the license header sourced from `spotless/copyright.kt`.
42+
- Publishing is configured centrally in `buildSrc/.../ProjectMaven.kt`; artifacts are distributed through JitPack under group `co.anitrend.query.builder`.
3843

39-
### Modularity
40-
The multi-module approach ensures:
41-
- Core logic is separate from Android-specific integrations
42-
- Annotation processing is isolated for clean build dependencies
43-
- Extensions can be optionally included based on project needs
44+
## Documentation Contract
4445

45-
## Build System
46+
- Dokka is configured centrally and the published site documents the public API surface.
47+
- When changing public behavior, update KDoc in the same change.
48+
- Document what the API does, when to use it, and what a consumer must provide or expect.
4649

47-
The project uses Gradle with Kotlin DSL and includes:
48-
- Custom build plugins in `buildSrc` for consistent configuration
49-
- Android library configuration for Room compatibility
50-
- Annotation processor configuration for code generation
51-
- JitPack integration for distribution
50+
## Working Heuristics
5251

53-
## Key Components
54-
55-
### Query Builder Core
56-
The core module provides a fluent API for constructing SQL SELECT queries with support for:
57-
- Table selection and aliasing
58-
- Column projection with type safety
59-
- JOIN operations (INNER, LEFT, RIGHT, FULL)
60-
- WHERE clause construction with parameter binding
61-
- GROUP BY and HAVING clauses
62-
- ORDER BY with multiple columns
63-
- UNION and UNION ALL operations
64-
- Subquery support
65-
66-
### Schema Generation
67-
The annotation processor generates Kotlin object classes that:
68-
- Mirror Room entity class structure
69-
- Provide compile-time column name verification
70-
- Support nested objects for `@Embedded` annotations
71-
- Generate table metadata for query construction
72-
73-
### Room Extensions
74-
Extension functions bridge the query builder with Room:
75-
- Convert builder instances to `SupportSQLiteQuery`
76-
- Handle parameter binding for dynamic queries
77-
- Maintain compatibility with Room's query execution model
78-
79-
## Documentation
80-
81-
Full documentation is available at: https://anitrend.github.io/support-query-builder/
82-
83-
The documentation includes:
84-
- API reference for all public classes and methods
85-
- Integration guides for Room database usage
86-
- Examples of complex query construction
87-
- Best practices for annotation processor usage
88-
89-
This modular architecture ensures the library remains focused on its core purpose while providing flexible integration options for different use cases and maintaining compatibility with the Android ecosystem.
52+
- Put new query builder logic in `:core` if it has no Android dependency; put Room-specific glue in `:core:ext`.
53+
- Annotation additions go in `:annotations` first; corresponding processor changes go in `:processor` in the same change.
54+
- Prefer shared build logic changes in `buildSrc` over copy-pasting Gradle configuration into individual modules.
55+
- When running Gradle locally, use the `jenv-gradle-low-ram` skill to align the JDK and manage memory pressure before invoking `./gradlew`.
56+
- When unsure where code belongs, consult the dependency direction above and confirm it before editing.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
description: Use when adding or changing public Kotlin APIs, KDoc, Dokka output, class docs, function docs, or property docs in support-query-builder modules.
3+
applyTo: annotations/src/main/**/*.kt, core/src/main/**/*.kt, core/ext/src/main/**/*.kt, processor/src/main/**/*.kt
4+
---
5+
6+
# KDoc And Dokka Guidance
7+
8+
- Treat KDoc as consumer documentation. The generated Dokka site is how downstream apps learn the library surface.
9+
- Document every new or changed public or protected class, interface, object, enum, annotation, function, and property that a consumer may touch.
10+
- Write documentation for someone outside this repo who does not already know the architecture. Explain what the API is for, when to use it, and which module or workflow it belongs to.
11+
- For abstract base types such as `AbstractQueryBuilder`, document the extension contract: what subclasses must override, invariants they must preserve, and when callbacks are invoked.
12+
- For builder types and DSL functions, document the expected call sequence, which methods are required vs optional, and how the final query is materialized.
13+
- For extension functions such as `asSupportSQLiteQuery()`, document the receiver, side effects, threading or lifecycle assumptions, and any important nullability or mutation behavior.
14+
- For annotation types such as `@EntitySchema`, document which annotation processor reads them, what code gets generated, and how the consumer should use the generated output.
15+
- Preserve the existing house style when possible: a short summary first, then focused detail, with `@param`, `@property`, `@return`, `@throws`, `@see`, and `@since` where they add value.
16+
- Do not invent version history. Only add `@since` when the version is already known or established in adjacent code.
17+
- Avoid placeholder KDoc that only restates the type name. Explain behavior, expectations, and integration points.
18+
- If behavior changes, update the docs in the same patch so the published site stays trustworthy.
19+
- There are no internal package suppressions in this project; document all public-facing code.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
name: jenv-gradle-low-ram
3+
description: 'Align jenv with .java-version and run Gradle reliably on low-RAM machines. Use for Java mismatch errors, Gradle OOMs, daemon memory pressure, and selecting safe build flags.'
4+
argument-hint: 'Describe your target task and available RAM, for example: assembleDebug on 8GB RAM'
5+
---
6+
# Jenv + Gradle Low-RAM Workflow
7+
8+
## What This Skill Produces
9+
10+
- A shell where `java` and Gradle use the Java version pinned by `.java-version`.
11+
- A repeatable Gradle command profile tuned for constrained memory.
12+
- Verification checks to confirm version alignment and build stability.
13+
14+
## When To Use
15+
16+
- Any time when `./gradlew` is about to be invoked in this repository.
17+
- Especially important for low-RAM machines where daemon/worker pressure can destabilize builds.
18+
- Required when verifying that Java from `.java-version` is the active runtime for Gradle.
19+
20+
## Procedure
21+
22+
1. Detect the required Java version.
23+
24+
```bash
25+
cat .java-version
26+
```
27+
28+
The expected output is `21.0.8`. Systems in this project are expected to have `jenv` installed; the `.java-version` file is read by `jenv local` to pin the active JDK for the working directory.
29+
30+
2. Verify `jenv` is installed and initialized.
31+
32+
```bash
33+
command -v jenv
34+
jenv versions
35+
jenv version
36+
```
37+
38+
Decision point:
39+
40+
- If `jenv` is not found, install it from https://github.com/jenv/jenv and run `eval "$(jenv init -)"` in your shell startup, then re-open the shell and retry.
41+
- If `jenv` is found but `jenv version` does not match `.java-version`, continue to step 3.
42+
43+
3. Align local Java to the repository pin.
44+
45+
```bash
46+
required_java="$(cat .java-version)"
47+
jenv local "$required_java"
48+
```
49+
50+
Decision point:
51+
52+
- If `jenv local` fails because the version is missing, install that JDK and run `jenv add <jdk-path>`, then retry.
53+
54+
4. Confirm runtime alignment before any Gradle task.
55+
56+
```bash
57+
java -version
58+
./gradlew -version
59+
```
60+
61+
Quality check:
62+
63+
- Gradle JVM version in `./gradlew -version` must match `.java-version` major version (21).
64+
65+
5. Run Gradle with low-memory-safe defaults.
66+
67+
Preferred one-off profile for building a debug variant:
68+
69+
```bash
70+
./gradlew --no-daemon --max-workers=2 \
71+
-Dorg.gradle.jvmargs="-Xmx1536m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" \
72+
:core:assembleDebug
73+
```
74+
75+
For running unit tests:
76+
77+
```bash
78+
./gradlew --no-daemon --max-workers=2 \
79+
-Dorg.gradle.jvmargs="-Xmx1792m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" \
80+
:core:test :processor:test
81+
```
82+
83+
For running all tests across modules:
84+
85+
```bash
86+
./gradlew --no-daemon --max-workers=2 \
87+
-Dorg.gradle.jvmargs="-Xmx1792m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8" \
88+
test
89+
```
90+
91+
6. If memory pressure continues, downgrade concurrency.
92+
93+
```bash
94+
./gradlew --no-daemon --max-workers=1 -Dorg.gradle.parallel=false :core:test
95+
```
96+
97+
7. If builds are stable and you want persistence, prefer user-local Gradle overrides (avoid committing repo-wide memory changes).
98+
99+
Suggested entries for `~/.gradle/gradle.properties`:
100+
101+
```properties
102+
org.gradle.daemon=false
103+
org.gradle.parallel=false
104+
org.gradle.workers.max=2
105+
org.gradle.jvmargs=-Xmx1536m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
106+
```
107+
108+
## Troubleshooting Branches
109+
110+
- `jenv version` correct but `java -version` wrong:
111+
Ensure shell init runs `eval "$(jenv init -)"` and enable export plugin with `jenv enable-plugin export`.
112+
- `Gradle daemon disappeared unexpectedly`:
113+
Retry with `--no-daemon --max-workers=1` and lower `-Xmx` if the OS is reclaiming memory aggressively.
114+
- Kotlin compile OOM:
115+
Keep workers low, disable parallel, and run module-targeted tasks (for example `:core:test` or `:processor:test`) instead of full-project builds.
116+
- KAPT out of memory (`:processor` module):
117+
Add `-Dkapt.use.worker.api=false` to avoid spawning an extra worker process during annotation processing.
118+
119+
## Completion Checks
120+
121+
- `.java-version` and `jenv version` resolve to the same Java release (`21.0.8`).
122+
- `./gradlew -version` reports the expected JVM (major version 21).
123+
- Target Gradle task completes without OOM or daemon crash.
124+
- Machine remains responsive during build (no prolonged swap thrash).
125+
126+
## Fast Invocation Examples
127+
128+
- "Align my shell to `.java-version` and run debug build with 8GB RAM settings"
129+
- "I get class file major version errors; fix jenv and verify Gradle JVM"
130+
- "Run unit tests with a low-memory Gradle profile and fallback if OOM occurs"
131+
- "Run only the processor module tests without spawning extra KAPT workers"

0 commit comments

Comments
 (0)