| Crates.io | kam |
| lib.rs | kam |
| version | 0.5.26 |
| created_at | 2025-12-06 23:46:54.077351+00 |
| updated_at | 2025-12-28 13:56:37.29206+00 |
| description | A lightweight, networkless CLI for scaffolding and packaging Magisk/Kernelsu/APU/Anykernel3/Astrbot/... modules. |
| homepage | https://github.com/MemDeco-WG/Kam |
| repository | https://github.com/MemDeco-WG/Kam |
| max_upload_size | |
| id | 1970920 |
| size | 2,350,781 |
English | ไธญๆ
! [WARNING โ ]It's under development. You can follow the development progress by checking the asl module in the kernelsu module repository. Testing will begin with the asl module.
CI checks:
.github/workflows/i18n-check.yml runs the exporter and verifies localized --help outputs
(e.g., kam build --help, kam tmpl import --help) under KAM_UI_LANGUAGE=zh/en to ensure
that help text is translated and to catch regressions early.Workflow goals:
cli.* translations with the WebUI so there's a single source of truth.If you want to update WebUI translations locally, run:
python3 Kam/scripts/export_cli_i18n.py
# then commit the resulting files under Kam/KamWEBUI/src/data/cli/
Contributions to extend translations and improve coverage are welcome. Use the skeleton script to discover gaps, add keys to src/i18n/en.toml (and provide translations in src/i18n/zh.toml), then run the exporter and commit results.
Kam is a CLI toolkit for scaffolding, building, packaging, and distributing Android module packages and templates (ksu/APU/Magisk/AnyTemplate). It focuses on rapid project initialization, reproducible builds, template management, and convenient repository/metadata export for module maintainers and distribution channels.
kam.toml configuration to module.prop and update.jsonkam config to manage global (~/.kam/config.toml) and project-level (./.kam/config.toml) settings to avoid repetitive editskam.toml into repo.json, module.json, track.json, config.json for marketplaces or registriescargo install kam
Or build from source:
git clone https://github.com/MemDeco-WG/Kam.git
cd Kam
cargo build --release
Using Kam template:
kam tmpl list
kam tmpl pull # download online
kam init my_awesome_module -t kam_template
Using Meta template (meta-module):
kam init my_meta_module -t meta_template
Using AnyKernel3 template (kernel module):
kam init my_kernel_module -t ak3_template
Pacman-style top-level flags
-Ss โ search the remote modules registry (example: kam -Ss <term>).
-S โ download a module by ID (example: kam -S <moduleId>).
-u, --update โ refresh the modules index before downloading (equivalent to kam repo sync --force).
You can combine flags, e.g. kam -Syu will update the index (-u), assume yes (-y), then attempt downloads (-S).
Edit the kam.toml configuration file:
[prop]
id = "my_awesome_module"
name = "My Awesome Module"
version = "1.0.0"
versionCode = 1
author = "YourName"
description = "An awesome module for Android"
updateJson = "https://example.com/update.json"
[mmrl.repo]
repository = "https://github.com/username/my_awesome_module"
changelog = "https://github.com/username/my_awesome_module/blob/main/CHANGELOG.md"
Kam provides a kam config command to manage per-project and global configuration, similar to git config:
Examples:
# Set a project-level configuration (stored in `./.kam/config.toml`)
kam config set prop.author "YourName"
# Get a project-level configuration
kam config get prop.author
# Set a global configuration (stored in `~/.kam/config.toml`)
kam config --global set prop.author "YourName"
# List configuration of current target (project or global)
kam config list
This avoids frequent manual edits of kam.toml for values that should be global or common across projects.
Add your module files to the src/<module_id>/ directory:
src/my_awesome_module/
โโโ module.prop # Auto-generated
โโโ customize.sh # Installation script
โโโ service.sh # Service script
โโโ system/ # System files
โ โโโ bin/
โ โโโ my_script
โโโ webroot/ # WebUI files (optional)
kam build
The built module will be generated in the dist/ directory.
Kam provides several built-in templates:
| Template | Description | Use Case |
|---|---|---|
-t kam_template (-t kam) |
Standard Kam module | General module development |
-t meta_template (-t meta) |
Meta-module template | Meta modules (modules of modules) |
-t ak3_template (-t ak3) |
AnyKernel3 template | Kernel modules |
--tmpl |
Template development template (maps to tmpl_template) |
Creating new templates |
Import a single template:
kam tmpl import templates/meta_template.tar.gz
Import multiple templates from a ZIP file:
kam tmpl import templates.zip
kam tmpl list
Export a single template:
kam tmpl export meta_template -o my_template.tar.gz
Note: When exporting templates as a single .tar.gz (template packaging), Kam will not execute pre-build or post-build hooks. Template packaging is treated as an artifact operation and hooks are not applied.
Export multiple templates to a ZIP:
kam tmpl export kam_template ak3_template -o my_templates.zip
kam tmpl import -f). The download link is recorded in the global config (~/.kam/config.toml) as tmpl.pull.url.tmpl.pull.last_download.# Use default download link (recorded in global config)
kam tmpl pull
# Provide URL (the URL will be recorded in global config)
kam tmpl pull https://example.com/templates.zip
kam tmpl pull:kam tmpl update
#### Additional Template Commands
```bash
# Remove a template from cache
kam tmpl remove template_name
# Show template cache directory
kam tmpl path
For more details on templates, see templates/README.md.
kam init - Initialize a New ProjectInitialize a new Kam project from templates (supports meta and kernel templates).
kam init [OPTIONS] [PATH]
Arguments:
[PATH] - Path to initialize the project. When running interactively (-i/--interactive), this PATH may be omitted; the interactive flow will prompt for it instead.Options:
--id <ID> - Project ID (default: folder name)--project-name <PROJECT_NAME> - Project name (default: "Example Module Name")--version <VERSION> - Project version (default: "1.0.0")--author <AUTHOR> - Author name (default: "Your Name")--update-json <UPDATE_JSON> - Update JSON URL (default: auto-generated from git)--description <DESCRIPTION> - Description (default: "Describe your module here")-f, --force - Force overwrite existing files-i, --interactive - Run the init interactively; ask for required values--var <VAR> - Template variables in key=value format-t, --template <TEMPLATE> - Template to use (built-in ID or local path)--tmpl - Create a template project (Template id: "tmpl_template")Examples:
kam init my_module -t kam_template
kam init my_module -t meta_template --interactive
kam init my_module --tmpl
kam build - Build and Package ModuleBuild and package a module into a deployable ZIP artifact.
kam build [OPTIONS] [PATH]
Arguments:
[PATH] - Path to the project (default: current directory)Options:
-a, --all - Build all workspace members-o, --output <OUTPUT> - Output directory (default: dist)-b, --bump - Enable KAM_BUMP_ENABLED environment variable (set to 1)-r, --release - Enable KAM_RELEASE_ENABLED environment variable (set to 1)-s, --sign - Enable KAM_SIGN_ENABLE environment variable (set to 1)-i, --interactive - Run build interactively; ask for confirmation when performing potentially destructive actions-P, --pre-release - Enable KAM_PRE_RELEASE environment variable (set to 1)-q, --quiet - Suppress most output; show only warnings and errorsExamples:
kam build
kam build --all
kam build --bump
kam build --release --sign
kam build --interactive
kam version - Manage Module VersionsManage module versions and bump policies.
kam version [VERSION]
Arguments:
[VERSION] - The new version (e.g. 1.0.1) or bump type (major, minor, patch)Examples:
kam version 1.0.1
kam version patch
kam version minor
kam version major
kam tmpl - Template ManagementManage templates: import, export, package, and list.
kam tmpl <COMMAND>
Subcommands:
kam tmpl list - List Available Templateskam tmpl list
kam tmpl import - Import Template(s)kam tmpl import [OPTIONS] <PATH>
<PATH> - Path to template archive (.tar.gz for single template, .zip for multiple templates)-n, --name <NAME> - Template name (optional, will use filename if not provided)-f, --force - Force overwrite if template already existskam tmpl export - Export Template(s)kam tmpl export [OPTIONS] --output <OUTPUT> [TEMPLATES]...
[TEMPLATES]... - Template name(s) to export (can specify multiple)-o, --output <OUTPUT> - Output file path (.tar.gz for single template, .zip for multiple templates)-f, --force - Force overwrite if output file already existskam tmpl pull - Download Templateskam tmpl pull [OPTIONS] [URL]
[URL] - Download URL (defaults to GitHub latest release templates ZIP)--global - (NOTE: URLs are always recorded in global config: ~/.kam/config.toml) The --global flag is accepted for CLI consistency but has no effectkam tmpl update - Update TemplatesRe-download based on recorded URL in config and import.
kam tmpl update
kam tmpl remove - Remove Templatekam tmpl remove <TEMPLATE>
kam tmpl path - Show Template Cache Directorykam tmpl path
kam cache - Manage Local CacheManage local template and artifact cache.
kam cache <COMMAND>
Subcommands:
kam cache list - List cached templateskam cache clean - Clean all cached templateskam cache add - Add a template to cache from a local directory or archivekam cache remove - Remove a template from cachekam cache path - Show cache directory pathkam validate - Validate ConfigurationValidate kam.toml configuration and templates.
kam validate [PATH]
Arguments:
[PATH] - Path to the project directory (default: current directory)kam check - Check Project FilesCheck project JSON/YAML/Markdown files (lint/format/parse).
kam check [OPTIONS] [PATH]
Arguments:
[PATH] - Path to the project directory (default: current directory)Options:
--json - Output results as JSONNote: kam check requires shellcheck to be installed on your PATH to check shell scripts. If shellcheck is not installed, kam check will fail with the message: ่ฏทๅฎ่ฃ
shellcheck
--fix - Try to automatically fix/format filesExamples:
kam check
kam check --json
kam check --fix
kam install - Install a module package to a connected deviceInstall a built module (.zip) to a connected device using the configured root manager. Kam will attempt to run the preferred install CLI (e.g., magisk, ksud, apd) and, if necessary, will attempt privilege escalation via su -c. When escalation is used, output is streamed live and any interactive prompts are forwarded to your terminal.
kam install [OPTIONS] [PATH]
Arguments:
[PATH] - Path to the module package (.zip). If omitted, Kam will attempt to find the artifact in the project's dist/ output directory.Options:
--manager <Manager> - Preferred root manager to use (Magisk, KernelSU, APatchSU). Overrides configured default.--dry-run - Print the derived install command without executing it.-q, --quiet - Suppress non-essential output.Examples:
kam install my_module.zip
kam install --manager KernelSU my_module.zip
kam install --dry-run my_module.zip
kam export - Export ConfigurationExport kam.toml to module.prop, module.json, repo.json, track.json, config.json, update.json.
kam export [FORMAT] [OUTPUT]
Arguments:
[FORMAT] - Export format: prop, json, update, repo, track, config[OUTPUT] - Output file path (default: write to a format-specific filename in the current directory)Examples:
kam export prop
kam export json module.json
kam export update
kam export repo
kam toml - TOML ManipulationInspect and edit kam.toml using dot-path keys (get/set/unset/list).
kam toml [OPTIONS] <COMMAND>
Options:
--file <FILE> - Operate on the project's kam.toml (default), or specify file using --fileSubcommands:
kam toml get <KEY> - Get a value by dot-separated key pathkam toml set <KEY> <VALUE> - Set a value by key (usage: kam toml set prop.name=value or kam toml set prop.name value)kam toml unset <KEY> - Unset/remove a keykam toml list - Dump the full tomlExamples:
kam toml get mmrl.repo.repository
kam toml set prop.name "My Module"
kam toml set prop.version=1.2.3
kam toml unset prop.not_used
kam toml list
kam config - Configuration ManagementManage per-project or global kam configuration (similar to git config).
kam config [OPTIONS] <COMMAND>
Options:
--global - Use the global configuration file (~/.kam/config.toml)--local - Force use of the local configuration file (project .kam/config.toml)Subcommands:
kam config get <KEY> - Get a configuration value by key (dot-separated path)kam config set <KEY> <VALUE> - Set a configuration value by keykam config unset <KEY> - Unset (remove) a configuration value by keykam config list - List all config values in the target fileExamples:
kam config set prop.author "YourName"
kam config --global set prop.author "YourName"
kam config get prop.author
kam config list
kam secret - Secret Keyring ManagementSecret keyring management (used by sign/verify tasks).
kam secret <COMMAND>
Subcommands:
kam secret list - List saved secretskam secret add <NAME> [FILE] - Add a secret from a value or file
-f, --file <FILE> - Path to a file to read the secret from-v, --value <VALUE> - Provide value directly--force-file - Force storing to local file instead of system keyring--password <PASSWORD> - Pass the password on the CLI (not recommended); password will be prompted if not set--with-backup - Also create a local fallback file under ~/.kam/secretskam secret get <NAME> - Get a secret and print it to stdout (or --out file)kam secret remove <NAME> - Remove a secretkam secret export <NAME> - Export secret to a file (by default decrypted). Use --encrypted to export encrypted blobkam secret import <NAME> <FILE> - Import secret from a file. If file is an encrypted KAM blob, it will be stored as-iskam secret export-pub <NAME> - Export public key from a stored private key secretkam secret import-cert - Import developer certificate chain from GitHub issue or filekam secret trust - Manage trusted Root CAsExamples:
kam secret add main --file private_key.pem
kam secret list
kam secret export-pub main
kam sign - Sign ArtifactsSign an artifact using a key from the keyring or a PEM file.
kam sign [OPTIONS] [SRC]
Arguments:
[SRC] - The artifact to sign (zip). If omitted, use --dist or --all to sign multiple filesOptions:
--secret <SECRET> - Name of the secret in kam keyring that holds the private key [default: main]--out <OUT> - Output directory (default: dist)--dist <DIR> - Sign all artifacts in given directory (instead of specifying single src file)--all - Sign all artifacts inside dist (alias of --dist --cert <CERT> - Certificate PEM chain path to include in signature metadata--key-path <KEY_PATH> - Optional path to a private key PEM file to use instead of the keyring secretExamples:
kam sign module.zip
kam sign --all
kam sign --dist dist --cert cert.pem
kam verify - Verify SignaturesVerify an artifact signature (.sig) or a sigstore bundle (DSSE).
kam verify [OPTIONS] [SRC]
Arguments:
[SRC] - Path to the artifact to verify (required for .sig verification)Options:
--sig <SIG> - Path to signature file (base64 .sig). If omitted, defaults to --bundle <BUNDLE> - Path to .sigstore.json bundle containing DSSE envelope and certs--cert <CERT> - Optional certificate PEM to use for verification (overrides bundle cert)--root <ROOT> - Optional root CA PEM to verify a certificate chain (trusted anchor)--secret <SECRET> - Name of secret in kam keyring that holds the private key; used to derive public key for verification [default: main]--key <KEY> - Path to public key PEM for verification (overrides derived key from secret)--cert-name <CERT_NAME> - Name of cached developer certificate to use for verification--cert-chain <CERT_CHAIN> - Path to certificate chain PEM file for verification--skip-crl - Skip CRL (Certificate Revocation List) check-v, --verbose - Verbose output showing verification stepsExamples:
kam verify module.zip
kam verify module.zip --sig module.zip.sig
kam verify module.zip --bundle module.zip.sigstore.json
kam verify module.zip --cert cert.pem --root root.pem
kam completions - Generate Shell CompletionsGenerate shell completion scripts for common shells.
kam completions [OPTIONS] <SHELL>
Arguments:
<SHELL> - Shell type for completion (bash, zsh, fish, powershell, elvish)Options:
-o, --out <OUT> - Output file. If omitted, prints to STDOUT--install - Install the completion script into the shell's completion directory (may require root)Examples:
kam completions bash > /etc/bash_completion.d/kam
kam completions fish -o ~/.config/fish/completions/kam.fish
kam completions zsh --install
kam about - Display About InformationDisplay about information for Kam and credits.
kam about
Kam supports optional network-backed functionality to increase security and convenience. These features are not required for basic scaffolding and builds, but may be enabled by flags or in future updates:
kam sign with Sigstore/timestamping enabled may contact a timestamp authority (TSA) or Sigstore services to generate RFC 3161 timestamped signatures or to record signatures on transparency logs (Rekor). This requires network access when enabled.
Note: kam sign does not request an RFC3161 timestamp by default. Use --timestamp to enable timestamping when needed.kam tmpl pull command will be added to make it easy to fetch and import templates from remote repositories or template registries.If you're unsure how to run a particular kam command or want interactive help, you can run the Kamcp (MCP) server which exposes a kam_exec tool and an AI assistant that can explain commands or run them for you. See https://github.com/MemDeco-WG/Kamcp for installation and usage instructions. Example interactions include asking the AI "How do I use kam tmpl pull?" or using kam_exec("-Ss <term>") to search the modules registry.
When possible, these features are optional and disabled by default.
You can inspect and modify your kam.toml directly from the CLI using the toml subcommand:
# Get a nested value by dot-separated key path
kam toml get mmrl.repo.repository
# Set a value: support both `key value` and `key=value` forms
kam toml set prop.name "My Module"
kam toml set prop.version=1.2.3
# Remove a value
kam toml unset prop.not_used
# Dump kam.toml
kam toml list
# Basic build
kam build
# build all
kam build -a # shorthand for --all
kam build --all
# Build with automatic version bump
kam build --bump
# Build and create GitHub Release
# Creates a GitHub release and uploads artifacts from `dist/` (signing and immutability optional)
kam build --release
#
# Example: Create an immutable signed release (skip re-upload if the same tag exists) and upload Sigstore
# attestation JSON (DSSE bundle copied as `*.attestation.json`) as release assets:
#
# kam build -r -s -i
# Debug mode
KAM_DEBUG=1 kam build
Verify common data files in the project (JSON, YAML, Markdown). This command checks for parse errors and basic formatting issues; add --fix to attempt automatic fixes.
# Check current directory and print results (human friendly)
kam check
# Output results as JSON
kam check --json
# Attempt to auto-fix/format files
kam check --fix
Kam supports executing custom scripts during the build process:
Note: The hook runner executes files directly and does not perform OS-specific interpreter selection or special-case file extensions. It simply executes each file found in the hooks directory and defers to the operating system for execution. Ensure your hook scripts are runnable on your target environment (for example, include a shebang and mark the script executable on Unix with chmod +x, or run shell scripts via WSL/Git Bash on Windows).
Create scripts in the hooks/pre-build/ directory:
hooks/pre-build/
โโโ 0.EXAMPLE.sh # Example pre-build hook (template)
โโโ 1.SYNC_MODULE_FILES.sh # Sync configuration files (script)
โโโ 2.BUILD_WEBUI.sh # Build WebUI
Create scripts in the hooks/post-build/ directory:
hooks/post-build/
โโโ 0.EXAMPLE.sh # Example post-build hook (template)
โโโ 1.VERIFY.sh # Verify build
โโโ 2.UPLOAD.sh # Upload artifacts
โโโ 3.NOTIFY.sh # Send notifications
The following environment variables are available in hook scripts:
| Variable | Description |
|---|---|
KAM_PROJECT_ROOT |
Absolute path to the project root directory |
KAM_HOOKS_ROOT |
Absolute path to the hooks directory |
KAM_MODULE_ROOT |
Absolute path to the module source directory (e.g., src/<id>) |
KAM_WEB_ROOT |
Absolute path to the module webroot directory |
KAM_DIST_DIR |
Absolute path to the build output directory (e.g., dist) |
KAM_MODULE_ID |
The module ID |
KAM_MODULE_VERSION |
The module version |
KAM_MODULE_VERSION_CODE |
The module version code |
KAM_MODULE_NAME |
The module name |
KAM_MODULE_AUTHOR |
The module author |
KAM_MODULE_DESCRIPTION |
The module description |
KAM_MODULE_UPDATE_JSON |
The module updateJson URL |
KAM_STAGE |
Current build stage: pre-build or post-build |
KAM_DEBUG |
Set to 1 to enable debug output |
KAM_HOME |
Override Kam's home directory (defaults to ~/.kam/). This controls where global configuration, caches, and secrets are stored. |
Kam automatically syncs kam.toml configuration to module files:
module.prop โ $KAM_MODULE_ROOT/module.prop
update.json โ $KAM_PROJECT_ROOT/update.json
[mmrl.repo] sectionKam supports adding WebUI interfaces to modules:
webui/ directorysrc/<module_id>/webroot/Kam supports workspace mode to manage multiple modules in one project:
[kam.workspace]
members = [
".",
"modules/module_a",
"modules/module_b",
]
# kam build --all
# equal to:
# kam build .
# kam build modules/module_a
# ...
[kam.build]
target_dir = "dist" # Output directory
output_file = "{{id}}" # Output filename template
hooks_dir = "hooks" # Hooks directory
source_dir = "src/{{id}}" # Source directory (optional)
Use template variables for conditional compilation:
[kam.tmpl.variables.feature_x]
var_type = "bool"
required = false
default = false
Use in scripts:
{% if feature_x %}
# Feature X related code
{% endif %}
my_module/
โโโ kam.toml # Kam configuration file
โโโ src/
โ โโโ my_module/ # Module source code
โ โโโ module.prop # Module properties (auto-generated)
โ โโโ customize.sh # Installation script
โ โโโ service.sh # Service script
โ โโโ system/ # System files
โโโ hooks/
โ โโโ pre-build/ # Pre-build hooks
โ โโโ post-build/ # Post-build hooks
โโโ webui/ # WebUI source code (optional)
โโโ dist/ # Build output
โโโ update.json # Update information (auto-generated)
โโโ README.md
Contributions, issues, and feature requests are welcome!
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
-Mmrl - Module repo.
Built with โค๏ธ and Rust