From 4623f546e39652566a50910fba58988f0562b09b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 25 Aug 2026 23:01:58 +0000 Subject: [PATCH] Convert subproject AGENTS.md into skills --- .agents/skills/magisk-app/SKILL.md | 50 +++++++++++++++++++ .agents/skills/magisk-git/SKILL.md | 38 ++++++++++++++ .../skills/magisk-native/SKILL.md | 17 ++++--- AGENTS.md | 39 ++++++--------- app/AGENTS.md | 38 -------------- 5 files changed, 115 insertions(+), 67 deletions(-) create mode 100644 .agents/skills/magisk-app/SKILL.md create mode 100644 .agents/skills/magisk-git/SKILL.md rename native/AGENTS.md => .agents/skills/magisk-native/SKILL.md (83%) delete mode 100644 app/AGENTS.md diff --git a/.agents/skills/magisk-app/SKILL.md b/.agents/skills/magisk-app/SKILL.md new file mode 100644 index 000000000..231d41862 --- /dev/null +++ b/.agents/skills/magisk-app/SKILL.md @@ -0,0 +1,50 @@ +--- +name: magisk-app +description: Guidelines, architecture, development conventions, and build workflows for the Magisk Android application (app/ subproject). Use when working on, modifying, building, or testing code in app/ or any of its submodules (:core, :apk-ng, :shared, :stub, :stub-res, :test, :build-logic, :apk). +--- + +# Magisk App Subproject Guidelines + +Guidelines and workflows for developing and building the Android application in the `app/` subproject. + +## 1. Environment & Gradle Setup + +- **General Guidelines:** Always follow the top-level [`AGENTS.md`](../../../AGENTS.md) and [`magisk-git`](../magisk-git/SKILL.md) for repository rules, environment execution setup, and commit control policies. +- **Working Directory:** Set working directory to `app/` when running standalone Gradle commands, or execute build commands via `./build.py` from the repository root. +- **Environment Wrapper:** Standalone `./gradlew` commands MUST be prefixed with `../scripts/env.py` (e.g., `../scripts/env.py ./gradlew :apk-ng:assembleDebug`). Alternatively, run `./build.py app-ng` from the repository root (which configures the environment automatically and builds `:apk-ng`). + +## 2. Architecture & Submodules + +Multi-module Gradle project structure: +- **`:apk-ng`** (`apk-ng/`): Next-gen app variant. Primary target for UI and application features. +- **`:core`** (`core/`): Core domain logic, resources, Room DB, services. Primary target for core feature development. +- **`:shared`** (`shared/`): Shared utilities and common data structures. +- **`:stub`** (`stub/`): Lightweight stub app loader for hidden installs. +- **`:stub-res`** (`stub-res/`): Stub-specific Android resources. +- **`:test`** (`test/`): Application testing target. +- **`:build-logic`** (`build-logic/`): Custom Gradle plugins and build logic. +- **`:apk`** (`apk/`): Legacy app APK. **Maintenance mode:** Do NOT modify unless explicitly requested. + +## 3. Development Guidelines + +- **Target Modules:** All active app development occurs in `:core` and `:apk-ng`. Do NOT make changes to `:apk` unless explicitly requested. +- **Legacy Compatibility:** When modifying `:core` and `:shared`, make sure the `:apk` module is still buildable. +- **Language & UI:** Written in Kotlin/Java. **Prefer Kotlin for all new code.** Uses Jetpack Compose for UI (prefer over View XML). +- **String Resources:** Default strings in `core/src/main/res/values/strings.xml` and `stub-res/src/main/res/values/strings.xml`. Translations go in `values-[lang]/strings.xml`. +- **Data Stack:** Room, KSP, Wire (Protocol Buffers), Moshi. + +## 4. Workflows & Verification + +### From `app/` directory (prefixed with `../scripts/env.py`): +- **Build App (`:apk-ng` Debug):** `../scripts/env.py ./gradlew :apk-ng:assembleDebug` +- **Build Stub APK:** `../scripts/env.py ./gradlew :stub:assembleDebug` +- **Build Legacy APK (`:apk` Debug):** `../scripts/env.py ./gradlew :apk:assembleDebug` +- **Run Lint:** `../scripts/env.py ./gradlew lint` (or `../scripts/env.py ./gradlew :apk-ng:lintDebug`) +- **Run Unit Tests:** `../scripts/env.py ./gradlew test` +- **Clean Artifacts:** `../scripts/env.py ./gradlew clean` + +### From repository root (via `build.py`): +- **Build App (`:apk-ng`):** `./build.py app-ng` +- **Build Stub App:** `./build.py stub` +- **Build Legacy App (`:apk`):** `./build.py app` +- **Run App Tests:** `./build.py test` diff --git a/.agents/skills/magisk-git/SKILL.md b/.agents/skills/magisk-git/SKILL.md new file mode 100644 index 000000000..a2d401327 --- /dev/null +++ b/.agents/skills/magisk-git/SKILL.md @@ -0,0 +1,38 @@ +--- +name: magisk-git +description: Guidelines and instructions for Git operations, commit policies, and commit message formatting in the Magisk repository. Use when committing changes, amending commits, or formatting commit messages. +--- + +# Magisk Git & Commit Guidelines + +Guidelines and rules for Git operations and commit management in the Magisk repository. + +## 1. Commit Control & Approval + +- **NEVER** commit changes or amend an existing git commit without the user's explicit request or approval. +- Do not stage or commit files automatically as part of automated steps or task conclusions unless explicitly instructed by the user. + +## 2. Commit Message Formatting + +When explicitly requested to commit changes, format commit messages according to the following rules: + +1. **50/72 Rule:** + - **Subject line:** At most 50 characters. Keep it concise, descriptive, and written in the imperative mood (e.g., `Fix build failure on Android 14`, `Add support for custom mounts`). + - **Blank line:** Always include a blank line between the subject line and the commit body. + - **Body text:** Wrap body lines at 72 characters maximum. Explain the *what* and *why* behind the change. + +2. **Assisted-by Trailer:** + - Include an `Assisted-by: ` trailer in the commit message body (e.g., `Assisted-by: Gemini 3.7 Flash`, `Assisted-by: GPT-4o`, `Assisted-by: Claude 3.5 Sonnet`). + - **Note:** Always specify the underlying LLM model name, NOT the agent framework, runner, or harness name (such as Antigravity, AGY, etc.). + +## 3. Example Commit Message + +```text +Short summary of changes in 50 characters or less + +Detailed explanation of why this change was made and what problems +it solves. Wrap all lines in the message body to at most 72 +characters. + +Assisted-by: +``` diff --git a/native/AGENTS.md b/.agents/skills/magisk-native/SKILL.md similarity index 83% rename from native/AGENTS.md rename to .agents/skills/magisk-native/SKILL.md index b3f403361..fce92c495 100644 --- a/native/AGENTS.md +++ b/.agents/skills/magisk-native/SKILL.md @@ -1,12 +1,17 @@ -# AGENTS.md (native subproject) +--- +name: magisk-native +description: Guidelines, architecture, C++/Rust FFI bindings, development conventions, and build workflows for the Magisk native codebase (native/ subproject). Use when working on, modifying, building, debugging, or testing native C, C++, and Rust code in native/ (including magisk, magiskinit, magiskboot, magiskpolicy, resetprop, zygisk, and native crates/modules). +--- -Guidelines for AI models operating inside the `native/` subproject. Always include and follow the top-level [`AGENTS.md`](../AGENTS.md). +# Magisk Native Subproject Guidelines + +Guidelines and workflows for developing and building native C, C++, and Rust components in the `native/` subproject. ## 1. Environment & Build Requirements -- **General Guidelines:** Always follow the top-level [`AGENTS.md`](../AGENTS.md) for general repository rules, environment execution setup, and commit control policies. -- **Working Directory:** Execute commands from repo root via `./build.py`. -- **Pre-build Requirement:** ALWAYS run `./build.py native` at least once before editing native sources to generate FFI bindings, headers, and flags (`flags.h`, `flags.rs`, `*-rs.hpp`, `*-rs.cpp`, protobuf generated modules). +- **General Guidelines:** Always follow the top-level [`AGENTS.md`](../../../AGENTS.md) and [`magisk-git`](../magisk-git/SKILL.md) for general repository rules, environment execution setup, and commit control policies. +- **Working Directory:** Execute commands from repo root via `./build.py`. Standalone tool executions (e.g. `cargo`, `rustc`, `ndk-build`) MUST be prefixed with `scripts/env.py`. +- **Codegen Requirement:** ALWAYS run `./build.py gen` before editing native sources to generate FFI bindings, headers, and flags (`flags.h`, `flags.rs`, `*-rs.hpp`, `*-rs.cpp`, protobuf generated modules) without performing a full build. ## 2. Component Architecture @@ -56,7 +61,7 @@ The build process follows a two-stage hybrid pipeline orchestrated by `build.py` - **Build Specific Target(s):** `./build.py native [magisk|magiskinit|magiskboot|magiskpolicy|resetprop]` - **Rust Clippy Lint:** `./build.py clippy` - **Cargo Commands:** `./build.py cargo check`, `./build.py cargo test` -- **Generate IDE Database:** `./build.py gen` +- **Generate Bindings & IDE Files:** `./build.py gen` - **Clean Native Artifacts:** `./build.py clean native` ## 6. Rust & C++ Conventions diff --git a/AGENTS.md b/AGENTS.md index 5ec68a23f..fd3ee050d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,31 +2,24 @@ Guidelines and instructions for AI models and automated agents operating in the Magisk repository. -## 1. Environment & Execution Setup +## 1. Core Guidelines for AI Models -- **`build.py` Invocations:** `./build.py` imports `scripts/env.py` internally and configures the environment automatically. It does **not** need to be prefixed with `scripts/env.py` (e.g., `./build.py all` or `./build.py native`). -- **Direct Tool Executions:** Standalone commands outside of `build.py` (such as `./gradlew`, `cargo`, `rustc`, `ndk-build`, etc.) **MUST** be prefixed with `scripts/env.py` (e.g., `scripts/env.py ./gradlew assembleDebug`). -- **NDK Toolchain Setup:** If NDK toolchain dependencies are missing or outdated, run `./build.py ndk`. +1. **Git Control:** NEVER commit changes or amend an existing git commit without the user's explicit request or approval. Refer to the [`magisk-git`](.agents/skills/magisk-git/SKILL.md) skill for commit policies and formatting rules. +2. **Environment & Tool Invocations:** `./build.py` configures the build environment internally. Standalone tool executions (such as `./gradlew`, `cargo`, `rustc`, `ndk-build`, etc.) **MUST** be prefixed with `scripts/env.py` (e.g., `scripts/env.py ./gradlew assembleDebug`). +3. **Subproject Contexts:** Activate and follow subproject skills when working on specific codebases: + - `native/`: Refer to the [`magisk-native`](.agents/skills/magisk-native/SKILL.md) skill for architecture, FFI bindings, Rust conventions, and native workflows. + - `app/`: Refer to the [`magisk-app`](.agents/skills/magisk-app/SKILL.md) skill for app architecture, Compose/Kotlin conventions, and Gradle workflows. +4. **Verification Loop:** After making changes, verify compilation and run linting/checks for affected modules before concluding tasks. -## 2. Codebase Structure & Architecture +## 2. Repository Structure -- **`app/` (Android Application):** Multi-module Gradle project for the Android app. Refer to [`app/AGENTS.md`](app/AGENTS.md) for app architecture, submodules, Kotlin conventions, and Gradle workflows. -- **`native/` (Native Core Binaries):** C, C++, and Rust codebase for building native components (`magisk`, `magiskinit`, `magiskboot`, `magiskpolicy`, `resetprop`). Refer to [`native/AGENTS.md`](native/AGENTS.md) for native architecture, submodules, FFI compilation, and Rust conventions. -- **`build.py` (Primary Build Orchestrator):** Python script managing native builds, app packaging, Clippy runs, Cargo invocations, and cleanup. -- **`tools/` & `scripts/`:** Build scripts, helper utilities (e.g., `elf-cleaner`), and environment setup tools. +- **`app/`**: Android application multi-module Gradle project. +- **`native/`**: C, C++, and Rust native binaries and libraries (`magisk`, `magiskinit`, `magiskboot`, `magiskpolicy`, `resetprop`). +- **`build.py`**: Primary build orchestrator managing toolchains, native builds, and app packaging. +- **`tools/` & `scripts/`**: Helper utilities (e.g., `elf-cleaner`) and environment setup (`scripts/env.py`). -## 3. Build & Verification Workflows +## 3. Global Build Commands -- **Build Complete Project (APK + Native):** `./build.py all` -- **Build Native Components:** `./build.py native [target...]` -- **Build Application Targets:** `./build.py app`, `./build.py stub`, `./build.py test` -- **Rust Verification & Linting:** `./build.py clippy`, `./build.py cargo ` -- **Clean Build Artifacts:** `./build.py clean [native|cpp|rust|java|app]` - -## 4. Guidelines for AI Models - -1. **Git / Commit Control:** NEVER commit changes or amend an existing git commit without the user's explicit request or approval. When explicitly requested to commit changes, follow the 50/72 rule for commit messages (subject line <= 50 characters, blank line before body, wrap body lines at 72 characters) and include an `Assisted-by: ` trailer in the commit message body. Note: Always specify the underlying LLM model name, not the agent framework, runner, or harness name. -2. **Build Invocation:** Execute `./build.py ` directly without `scripts/env.py`. Prefix standalone tool executions (like `./gradlew` or raw `cargo`) with `scripts/env.py`. -3. **Pre-build Native Code:** Before modifying code in `native/`, build native binaries at least once with `./build.py native` to generate required bindings and header files. -4. **App Subproject Context:** Refer to [`app/AGENTS.md`](app/AGENTS.md) when working inside the `app/` subproject. -5. **Verification Loop:** After making changes, verify compilation and run linting/clippy checks for affected modules before concluding tasks. +- **Build Complete Project:** `./build.py all` +- **Clean All Artifacts:** `./build.py clean` +- **NDK Toolchain Setup:** `./build.py ndk` diff --git a/app/AGENTS.md b/app/AGENTS.md deleted file mode 100644 index 47088213d..000000000 --- a/app/AGENTS.md +++ /dev/null @@ -1,38 +0,0 @@ -# AGENTS.md (app subproject) - -Guidelines for AI models operating inside the `app/` subproject. Always include and follow the top-level [`AGENTS.md`](../AGENTS.md). - -## 1. Environment & Gradle Setup - -- **General Guidelines:** Always follow the top-level [`AGENTS.md`](../AGENTS.md) for general repository rules, environment execution setup, and commit control policies. -- **Working Directory:** Set working directory to `app/` when working on app code. -- **Environment Wrapper:** Standalone `./gradlew` commands MUST be prefixed with `../scripts/env.py` (e.g., `../scripts/env.py ./gradlew assembleDebug`), or run `./build.py app` from root. - -## 2. Architecture & Submodules - -Multi-module Gradle project structure: -- **`:apk`** (`apk/`): Legacy app APK. **Maintenance mode:** No new features should be added here. -- **`:apk-ng`** (`apk-ng/`): Next-gen app variant. Primary target for new UI/app features. -- **`:core`** (`core/`): Core domain logic, resources, Room DB, services. Primary target for core feature development. -- **`:shared`** (`shared/`): Shared utilities and common data structures. -- **`:stub`** (`stub/`): Lightweight stub app loader for hidden installs. -- **`:stub-res`** (`stub-res/`): Stub-specific Android resources. -- **`:test`** (`test/`): Application testing target. -- **`:build-logic`** (`build-logic/`): Custom Gradle plugins and build logic. - -## 3. Development Guidelines - -- **Feature Development:** `:apk` is in maintenance mode. All new development MUST occur in `:core` and `:apk-ng`. -- **Language & UI:** Written in Kotlin/Java. **Prefer Kotlin for all new code.** Uses Jetpack Compose for UI (prefer over View XML). -- **String Resources:** Default strings in `core/src/main/res/values/strings.xml` and `stub-res/src/main/res/values/strings.xml`. Translations go in `values-[lang]/strings.xml`. -- **Data Stack:** Room, KSP, Wire (Protocol Buffers), Moshi. - -## 4. Workflows & Verification (from `app/`) - -Prefix commands with `../scripts/env.py`: -- **Build Main APK (Debug):** `../scripts/env.py ./gradlew :apk:assembleDebug` -- **Build All Variants:** `../scripts/env.py ./gradlew assembleDebug` -- **Build Stub APK:** `../scripts/env.py ./gradlew :stub:assembleDebug` -- **Run Lint:** `../scripts/env.py ./gradlew lint` -- **Run Unit Tests:** `../scripts/env.py ./gradlew test` -- **Clean Artifacts:** `../scripts/env.py ./gradlew clean`