

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# AGENTS.md (native subproject)23Guidelines for AI models operating inside the `native/` subproject.45## 1. Environment & Build Requirements67- **Working Directory:** Execute commands from repo root via `./build.py`.8- **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).910## 2. Component Architecture1112Native C, C++, and Rust source modules under `native/src/`:13- **`base/`**: System wrappers, logging, custom string abstractions (`Utf8CStr`), mount helpers, and common utilities (C++/Rust).14- **`boot/`**: Boot image parsing, unpacking, repacking, and ramdisk patching logic (`magiskboot`) (Rust/C++).15- **`core/`**: Magisk daemon (`magiskd`), Zygisk engine, `su` implementation, applets, and system properties (`resetprop`) (C++/Rust).16- **`init/`**: Early boot `magiskinit`, ramdisk patching, SELinux pre-init (C/C++/Rust).17- **`sepolicy/`**: SELinux policy engine (`libpolicy`) and `magiskpolicy` CLI (C++/Rust).18- **`external/`**: Embedded dependencies (`cxx-rs`, `selinux`, `crt0`, `system_properties`, `lsplt`, `lz4-sys`, `xz-embedded`).1920### Key Native Binary Output Targets21- `magisk`: Core daemon, Zygisk, `su`, and applets executable.22- `magiskinit`: Early init replacement executable (static).23- `magiskboot`: Boot image patcher executable (static).24- `magiskpolicy`: SELinux policy tool executable.25- `resetprop`: System property reader/writer executable.2627## 3. Build System Orchestration2829The build process follows a two-stage hybrid pipeline orchestrated by `build.py`:3031```321. dump_flags_native() --> Outputs flags.h & flags.rs to native/out/generated/332. build_rust_src() --> Cargo build outputs lib<tgt>.a for each target ABI34 Cargo build.rs runs cxx_gen to produce *-rs.hpp / *-rs.cpp35 Cargo build.rs runs pb-rs to generate Protobuf bindings36 Static libraries moved to native/out/<arch>/lib<tgt>-rs.a373. build_cpp_src() --> ndk-build runs using Android.mk & Application.mk38 Android-rs.mk imports lib<tgt>-rs.a as PREBUILT_STATIC_LIBRARY39 Compiles C/C++ sources + *-rs.cpp bridge files + cxx.cc404. clean_elf() --> tools/elf-cleaner strips incompatible ELF dynamic tags41```4243## 4. FFI Architecture & Mechanics4445- **Bridge Engine:** C++/Rust FFI uses `cxx` (`cxx-rs`) via `#[cxx::bridge]` modules declared in crate `lib.rs` files.46- **Header & Source Generation:**47 - `codegen.rs` (`gen_cxx_binding()`) invokes `cxx_gen` in crate `build.rs` scripts.48 - Automatically generates C++ bridge headers (`*-rs.hpp`) and source wrappers (`*-rs.cpp`) directly in each crate directory.49 - Generates bindings for `base-rs`, `core-rs`, `init-rs`, `boot-rs`, and `policy-rs`.50- **Linking:** Generated `*-rs.cpp` bridge code and `cxx.cc` are compiled directly by `ndk-build` alongside native C++ source files, linking against the compiled Rust static library (`lib<tgt>-rs.a`).5152## 5. Build Targets & Commands (from Root)5354- **Build All Native Binaries:** `./build.py native`55- **Build Specific Target(s):** `./build.py native [magisk|magiskinit|magiskboot|magiskpolicy|resetprop]`56- **Rust Clippy Lint:** `./build.py clippy`57- **Cargo Commands:** `./build.py cargo check`, `./build.py cargo test`58- **Generate IDE Database:** `./build.py gen`59- **Clean Native Artifacts:** `./build.py clean native`6061## 6. Rust & C++ Conventions6263- **Rust Edition & Profile:** Rust Edition 2024. Profile configured with `panic = "immediate-abort"` across dev and release profiles.64- **C++ Standard:** C++20 with `libc++` static linking.65- **Clippy Rules:** `unwrap_used = "deny"` in workspace configuration. **Do NOT use `.unwrap()` in Rust code.** Use `?`, `unwrap_or`, `unwrap_or_else`, or pattern matching.66- **Incremental Build Protection:** File writers (`write_if_diff`) skip rewriting identical generated files to preserve compilation timestamps and avoid unnecessary rebuilds.6768## 7. Magisk Rust Patterns & Non-Standard Idioms6970AI models modifying or writing Rust code in `native/src/` MUST follow these Magisk-specific idioms:71721. **Custom String Handling (`Utf8CStr` & `cstr!`):**73 - Standard C/C++ APIs require null-terminated UTF-8 strings. Do NOT create intermediate `CString` allocations.74 - Use `&Utf8CStr` for string references, `Utf8CString` for heap buffers, and `Utf8CStrBufArr<N>` for stack buffers (`base/cstr.rs`).75 - Use `cstr!("literal")` for compile-time null-terminated static strings.76 - Use `StringExt::nul_terminate` for in-place null byte termination using reserved string capacity.77782. **Instant Logging Error Model (`LoggedError`):**79 - Application logic does NOT use standard error enums or `anyhow`.80 - Errors are logged immediately at the failure point via `log_err!`, `.log()`, or `.log_with_msg()` and converted into zero-sized `LoggedError` / `LoggedResult<T>`.81 - In debug builds, `#[track_caller]` logs the file and line number of error sites automatically. Use `.silent()` to silence expected failures.82833. **Libc System Call Conversions (`LibcReturn`):**84 - When calling raw libc or C system APIs in Rust or `xwrap.rs`, use `LibcReturn::into_os_result` or `check_err` to automatically map negative integer returns or null pointers into `OsResult` or `LoggedResult`.85864. **Zero Allocation & Binary Size Rules:**87 - Prefer custom `argh` derivation (`base/argh.rs`) for command-line parsing instead of adding standard argument dependencies.88 - Avoid `serde` overhead; use procedural `Encodable`/`Decodable` binary traits over UNIX domain sockets for IPC.89905. **Nightly Synchronization & IPC:**91 - Magisk uses nightly features (`unix_socket_ancillary_data`, `nonpoison_mutex`).92 - Use non-poisoning mutexes/condvars for daemon threading and `send_fd`/`recv_fd` for raw file descriptor passing.93
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| topjohnwu/MagiskAGENTS.md · 62k | AGENTS.md | setupbuildlint-formatarch+2 | 78/100 | 14 days ago | |
| topjohnwu/Magiskapp/AGENTS.md · 62k | AGENTS.md | setupstyle | 56/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 201k | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| aaif-goose/gooseAGENTS.md · 53k | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 8 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| deepseek-ai/deepseek-harnessnative/landlock-run/AGENTS.md · 104k | AGENTS.md | setupteststylearch+3 | 100/100 | today | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | today | |
| vllm-project/vllmAGENTS.md · 89k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 14 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/topjohnwu-magisk-native-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.