Metadata-Version: 2.4
Name: fluxgram-plugin-devkit
Version: 2.7.0
Summary: Build and validate FluxGram plugin packages
License-Expression: GPL-2.0-only
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=41

# FluxGram Plugin Devkit

Installable command-line tools, stable Java API 2.1, and fingerprinted E5 host stubs for building external FluxGram plugins.

```sh
python3 -m pip install fluxgram-plugin-devkit
fp doctor
fp init my-plugin --template hybrid
```

`fp` is the short command; `fluxgram-plugin` remains available as a compatible alias. Devkit 2.7 creates editor-ready Python, Java, and hybrid projects. Python templates include a Pyright configuration and development requirements. Java templates include a Gradle project whose compile-only classpath uses generated files under `.fluxgram/ide`. Run `fp prepare-ide` after cloning a project or updating the devkit to restore those ignored files. The Java template demonstrates the low-level composer native-draw replacement and therefore produces a host-bound schema 5 package. `install`, `reload`, and `logs` work with the release package by default; install and reload require temporary developer access enabled in FluxGram and use a shell-only bounded provider without remote shell paths or shell interpolation. Every non-streaming ADB command has a 120-second timeout; the `logs` logcat stream continues until interrupted after its bounded device and process checks complete.

Signing is an explicit offline step and is not part of `fp build`. Generate an encrypted P-256 PKCS#8 key outside the plugin project, sign a validated schema 4 or 5 archive, and verify the resulting schema 6 archive with:

```sh
fp keygen --output /secure/developer-key.pem
fp sign dist/plugin.fgplugin --key /secure/developer-key.pem --output dist/plugin.signed.fgplugin
fp verify dist/plugin.signed.fgplugin --expect-key-id p256:KNOWN_KEY_ID
```

Use `--password-file` for non-interactive operation; passwords are never accepted through a command-line value, project configuration, or environment variable. The embedded public key proves package integrity after signing but does not identify a trusted author by itself. Compare the printed key ID through an independent channel. Signed schema 6 packages are installable by compatible clients; `build`, `install`, and `reload` continue to create unsigned schema 4 or 5 packages until `sign` or `rotate` is used explicitly.

To rotate an existing signing identity, sign the transition with both encrypted keys and sign the package with the new key:

```sh
fp rotate dist/plugin.fgplugin \
  --from-key /secure/old-key.pem \
  --to-key /secure/new-key.pem \
  --from-generation 0 \
  --output dist/plugin.rotated.fgplugin
```

Use `--from-password-file` and `--to-password-file` for non-interactive operation. The destination generation is always the source generation plus one. `fp verify` reports the cryptographically verified source and destination key IDs and generations, but cannot determine whether that transition matches a particular device's locally pinned identity. Each package carries one sequential transition; keep bridge releases available for users on older generations.

Java API 2.1 includes lifecycle-managed ART method hooks and custom settings blocks. `registerSettingsBlock()` creates a separate plugin-owned Android `View` for each open settings screen, provides current Telegram theme colors, and cleans the block on screen close, disable, reload, removal, or explicit registration close. UI code stays on the main thread; `postAction()` delivers bounded asynchronous work to the plugin worker.

A Java plugin registers an exact reflected `Method` or `Constructor` through `JavaPluginContext.registerMethodHook`. Before and after callbacks run synchronously on the target method's thread, must not block or call Python, and receive an isolated argument array whose changes are committed only after a successful callback and active-generation check. The callback can set the result or throwable and can invoke the original once from the before phase. Managed registrations are ordered by priority, plugin ID, and registration sequence; after callbacks run in reverse order.

Java API 2.0 moved the public ABI to `org.fluxgram`. API 1.x plugins use the former package namespace and must be rebuilt for 2.x. `registerChatSelectionAction` provides one host-owned action in the ordinary chat selection toolbar. The callback receives an immutable server-backed message identity with message, dialog, and optional sender IDs. Availability and invocation run synchronously on the main thread, so implementations must remain fast and must not call Python or perform I/O.

Direct AliuHook/XposedBridge access remains possible for full-trust Java plugins, but direct registrations are outside FluxGram lifecycle tracking and must retain and close every `Unhook` themselves.

See the [developer kit guide](https://github.com/mrhexvel/fluxgram-plugin/blob/main/docs/developer-kit.md) for requirements, trust boundaries, project format, commands, and testing guidance. The [API reference](https://github.com/mrhexvel/fluxgram-plugin/blob/main/docs/api-reference.md) indexes the contracts also available through Python and Java editor hover.
