Imported from ahfoss/kamila (
AGENTS.md). Install upstream withnpx skills add ahfoss/kamila. Copyright stays with the author.
AGENTS.md - Developer Guide for AI Assistants
This repository contains kamila, an R package implementing methods for clustering mixed-type (continuous and categorical) data, specifically KAMILA (KA-means for MIXed LArge data sets) and Modha-Spangler clustering.
This guide provides context, architecture guidelines, and operational instructions for AI agents modifying or maintaining this codebase.
1. Repository Architecture
kamila/
├── R/ # Core R functions & roxygen2 documentation
│ ├── kamila.R # Main KAMILA clustering algorithm
│ ├── modha_spangler.R # Modha-Spangler clustering algorithm
│ ├── gen_mixed_data.R # Mixed-type data generation utilities
│ ├── misc_functions.R # Internal helper functions
│ └── RcppExports.R # Auto-generated Rcpp function bindings
├── src/ # C++ acceleration layer (Rcpp)
│ ├── cppfunctions.cpp # C++ implementations of distance/cluster routines
│ └── RcppExports.cpp # Auto-generated Rcpp bindings
├── tests/
│ └── testthat/ # Unit test suite (testthat v3)
│ ├── test_kamila.R # KAMILA algorithm unit tests
│ └── test_gmsClust.R # Modha-Spangler unit tests
├── man/ # Rd documentation files (auto-generated by roxygen2)
├── .github/workflows/ # CI/CD GitHub Actions pipelines
│ ├── R-CMD-check.yaml # Multi-OS & R-version validation
│ ├── rhub.yaml # R-hub v2 multi-platform & sanitizer checks
│ ├── test-coverage.yaml # Code coverage reporting via covr/Codecov
│ └── lint.yaml # Code quality & delinting check via lintr
├── DESCRIPTION # R package metadata & dependencies
├── NAMESPACE # Auto-generated package exports/imports
└── .Rbuildignore # Non-package files ignored during R CMD check
2. Key Development Commands
Run all commands from the repository root directory using Rscript or an interactive R session:
| Action | Command |
|---|---|
| Load Package | Rscript -e "devtools::load_all()" |
| Recompile C++ (Rcpp) | Rscript -e "Rcpp::compileAttributes(); devtools::clean_dll()" |
| Run Unit Tests | Rscript -e "devtools::test()" |
| Run Full Package Check | Rscript -e "devtools::check(cran = TRUE)" |
| Generate Documentation | Rscript -e "devtools::document()" |
| Lint Codebase | Rscript -e "lintr::lint_package()" |
| Check Code Coverage | Rscript -e "covr::package_coverage()" |
| Validate R-hub Setup | Rscript -e "rhub::rhub_doctor()" |
| Run R-hub v2 Checks | Rscript -e "rhub::rhub_check()" |
3. Coding & Maintenance Standards
R Code Guidelines
- Roxygen2 Documentation: All exported functions must have
roxygen2header comments (#'). Do NOT edit.Rdfiles inman/directly; always editR/*.Rsource files and rundevtools::document(). - Imports: Declare external package dependencies in
DESCRIPTION(Imports:orSuggests:) and add@importFromtags in R source comments. - Input Validation: Use explicit input checks (
is.matrix(),is.data.frame(),stop()) to provide clear error messages for invalid parameter types.
C++ / Rcpp Guidelines
- Exporting: Annotate exported C++ functions with
// [[Rcpp::export]]. - Rebuilding Bindings: Whenever C++ function signatures change, run
Rcpp::compileAttributes()before testing or committing. - Memory Safety: Use Rcpp structures (
Rcpp::NumericMatrix,Rcpp::IntegerVector,Rcpp::NumericVector) and avoid unmanaged raw pointers.
News & Release Notes Maintenance
- Mandatory News Updates: Any changes, enhancements, bug fixes, deprecations, or version updates MUST be logged in
NEWS.mdfollowing CRAN package news standards.
Pre-Commit Verification & Testing
Before committing any changes, you MUST run and pass all verification checks:
- Unit Tests: Run
devtools::test(). All tests must pass with 0 failures and 0 errors. - Linter: Run
lintr::lint_package(). There must be 0 linter warnings or violations. - Code Coverage: Run
covr::package_coverage(). Code coverage MUST NOT decrease below 100% from any commit. Every new function, branch, edge case, and error condition must be accompanied by corresponding unit tests. - Package Check: Run
devtools::check(cran = TRUE). Ensure the package builds with 0 errors, 0 warnings, and 0 notes.
CI/CD & Ignored Files
- Ignore Rules: Never commit build artifacts (
*.o,*.so,*.dll,*.Rcheck/,00check.log,.RData). - CRAN Compliance: Ensure all non-package root files (
AGENTS.md,CONTRIBUTING.md,.lintr,.github/,codecov.yml) are listed in.Rbuildignore.
4. Git Commit & Branching Conventions
- Branch Management: NEVER commit or push directly to
masterunless explicitly requested by the user. Always perform development and commits on feature or bugfix branches (fix/*,feature/*). - Pre-Commit Checks: Do NOT commit without passing unit tests, lintr checks, and verifying 100% code coverage.
- Commit Format: Use concise Conventional Commit messages:
feat:New feature or parameter additionfix:Bug fix or error resolutiondocs:Documentation updates (roxygen2 / README / AGENTS.md / NEWS.md)ci:Pipeline changes (.github/workflows)test:Adding or updatingtestthatspecsrefactor:Code reorganization without behavior change