| Metadata | Value |
|---|---|
| Status | Active |
| Version | 1.1.1 |
| Last Updated | 2026-02-19 |
| Author | Sangeetha Grantha Team |
A unified command-line tool for the Sangita Grantha project.
Recommended: Use mise for toolchain management (see .mise.toml in project root).
Tools managed by mise (see current versions):
.mise.toml).mise.toml).mise.toml)System requirements (not managed by mise):
Build the tool from source:
cd tools/sangita-cli
cargo build --release
The binary will be at target/release/sangita-cli.
Since Rust and other tools are managed by mise, run sangita-cli through mise:
# Development workflow
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- dev --start-db
# Database management - Reset existing database database
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- db reset
# Database management - Applying database schema and seed data changes
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- db migrate
# Testing
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- test steel-thread
# Extraction E2E (backend + queue + Python worker)
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- test extraction-e2e --timeout-seconds 600
# Blogspot HTML E2E scenario (auto-picks one URL from Dikshitar-Krithi-Test-20.csv)
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- test extraction-e2e --scenario blogspot-html --timeout-seconds 600
# Akhila 3-source regression (Blogspot HTML + Roman PDF + Sanskrit PDF fixtures)
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- test extraction-e2e --scenario akhila-three-source --timeout-seconds 600
# Large-set Dikshitar key collision scan (flags first10+raga+tala outliers, continues run)
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- \
test extraction-e2e --scenario dikshitar-key-collision \
--csv-path database/for_import/Dikshitar-Krithi-For-Import.csv \
--skip-migrations --skip-extraction-start --timeout-seconds 600
# Setup check
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- setup
This ensures:
.mise.toml).mise.toml).mise.toml)If mise is not available, ensure tools are installed manually with correct versions:
cd tools/sangita-cli
cargo run -- dev --start-db
Note: You must ensure tool versions match .mise.toml requirements manually.
Check environment and dependencies:
# Via mise (recommended)
mise exec -- cargo run --manifest-path tools/sangita-cli/Cargo.toml -- setup
# Or without mise
cd tools/sangita-cli
cargo run -- setup
Validate commit messages and manage Git hooks:
# Validate a commit message (reads from stdin if --message not provided)
cargo run -- commit check --message "Your commit message here"
# Install Git hooks (commit-msg and pre-commit)
cargo run -- commit install-hooks
# Remove installed Git hooks
cargo run -- commit uninstall-hooks
# Manually scan staged files for sensitive data
cargo run -- commit scan-sensitive
Commit Message Format:
All commits must include a reference to a documentation file in application_documentation/:
<subject line>
Ref: application_documentation/01-requirements/features/my-feature.md
<optional body>
Features:
Reset database (Drop → Create → Migrate → Seed):
cargo run -- db reset
Run migrations only:
cargo run -- db migrate
Start Backend and Frontend servers:
cargo run -- dev
Start the full stack (DB + Backend + Frontend) for manual verification:
cargo run -- dev --start-db
This will:
--start-db)/health endpointPress Ctrl+C to gracefully stop all services.
cargo run -- net infocargo run -- net configure --mode ip (or --mode mdns|pihole --target <hostname>)cargo run -- net verifyQuick health + search check:
cargo run -- test upload --base-url http://192.168.0.42:8080
Show where the mobile testing guides/checklists live:
cargo run -- mobile guide
Manage the containerised Python PDF extraction service for multi-format data ingestion:
# Build the PDF extractor Docker image
cargo run -- extraction build
# Start the extraction service (with database)
cargo run -- extraction start --with-db
# Start and follow logs
cargo run -- extraction start --with-db --follow
# View logs
cargo run -- extraction logs -f
# Check service and queue status
cargo run -- extraction status
# Stop the service
cargo run -- extraction stop
# Restart the service
cargo run -- extraction restart
Commands:
build - Build the Docker image from tools/krithi-extract-enrich-worker/start - Start the extraction worker (use --with-db to also start PostgreSQL)stop - Stop the extraction workerlogs - View container logs (-f to follow, -n 50 for tail count)status - Show container status and extraction queue statisticsrestart - Stop and restart the serviceRequirements:
--with-db or sangita-cli db start first)Sync version information from source files to documentation:
# Generate/update current-versions.md
cargo run -- docs sync-versions
# Check if versions are in sync (for CI - exits with error if out of sync)
cargo run -- docs sync-versions --check
# Validate documentation links (future feature)
cargo run -- docs validate-links
Sources of Truth:
gradle/libs.versions.toml - Backend/Mobile dependenciesmodules/frontend/sangita-admin-web/package.json - Frontend dependencies.mise.toml - Development toolchain versionsOutput: application_documentation/00-meta/current-versions.md
Run full backend extraction integration checks (no Playwright/UI dependency):
cargo run -- test extraction-e2e
What it validates automatically:
/healthINGESTED (PENDING -> PROCESSING -> DONE -> INGESTED)extraction_queue.status = INGESTEDextraction_method and extractor_versionresult_count threshold validationresult_payload sanity checkskrithi_source_evidenceUseful options:
# Run Blogspot HTML scenario (source URL is auto-selected from database/for_import/Dikshitar-Krithi-Test-20.csv)
cargo run -- test extraction-e2e --scenario blogspot-html
# Run Akhila 3-source convergence regression
# (uses fixtures in tools/sangita-cli/fixtures/extraction/)
cargo run -- test extraction-e2e --scenario akhila-three-source
# Run full Dikshitar collision scan and fail only if you request strict mode
cargo run -- test extraction-e2e --scenario dikshitar-key-collision --max-rows 200
cargo run -- test extraction-e2e --scenario dikshitar-key-collision --fail-on-collision
# Keep services up for manual debugging after test
cargo run -- test extraction-e2e --keep-services
# Reuse an already-running worker, skip migration step
cargo run -- test extraction-e2e --skip-extraction-start --skip-migrations
# Adjust source/page range and assertions
cargo run -- test extraction-e2e --source-url "<pdf-url>" --page-range "17-18" --min-result-count 1
Run focused harness checks for the TRACK-068 markdown workflow (mdskt.md/mdeng.md):
# Regenerate parser outputs + validate parity/artifacts
cargo run -- test track068-harness
# Validate existing artifacts only (skip parser/generator rerun)
cargo run -- test track068-harness --skip-regenerate
# Enforce strict ingestion gates (fail on unknown metadata/missing pallavi)
cargo run -- test track068-harness --enforce-ingestion-gates
# Skip semantic EN<->SA title/raga/tala alignment gate (diagnostics only)
cargo run -- test track068-harness --skip-semantic-alignment
What it verifies:
--skip-regenerate)skt_krithis.json and eng_krithis.json both contain the expected count (default 479)1..N) and identical across Sanskrit/English datasetsfinal_mdskt.mdfinal_mdeng.mdkrithi_comparison_report.csvkrithi_comparison_report.csv:
database/for_import/track_068_harness_report.jsonRequirements for semantic scoring:
uv must be installedtools/krithi-extract-enrich-worker/pyproject.toml must be availableRun the end-to-end smoke verification:
cargo run -- test steel-thread
What it checks:
/health)/v1/krithis/search)ADMIN_TOKEN)Manual Verification: After automated checks pass, the system stays running for manual verification:
http://localhost:5001http://0.0.0.0:8080ADMIN_TOKENPress Ctrl+C to stop servers and exit.
Environment variables (set in .env file):
API_HOST - Backend host (default: 0.0.0.0)API_PORT - Backend port (default: 8080)FRONTEND_PORT - Frontend port (default: 5001)ADMIN_TOKEN - Bearer token for admin endpoints (default: dev-admin-token)TEST_DATA_FILE - Path to test data JSON (default: tools/sangita-cli/test_data.json)cargo run -- db healthlsof -i :8080./gradlew :modules:backend:api:runcargo run -- db healthcargo run -- db startcd modules/frontend/sangita-admin-web && bun installlsof -i :5001cd modules/frontend/sangita-admin-web && bun run devThe commit guardrails are implemented in tools/sangita-cli/src/commands/commit.rs.
Dependencies
The implementation uses the following dependencies (already in Cargo.toml):
regex = "1.11.1" # Commit message parsing and sensitive data pattern matching
clap = { version = "4.5.53", features = ["derive"] } # CLI argument parsing
Command Structure
The CLI command structure (tools/sangita-cli/src/commands/commit.rs):
#[derive(Subcommand)]
pub enum CommitCommands {
/// Validate commit message format and reference
Check {
/// Commit message to validate (or read from stdin)
#[arg(long)]
message: Option<String>,
},
/// Scan staged files for sensitive data (used by pre-commit hook)
ScanSensitive,
/// Install Git hooks for commit validation
InstallHooks,
/// Remove installed Git hooks
UninstallHooks,
}
Git Hook Scripts
When install-hooks is run, it creates two hooks:
.git/hooks/commit-msg - Validates commit message format:
```bash
#!/bin/sh
exec “/path/to/sangita-cli” commit check –message “$(cat “$1”)”
2. **`.git/hooks/pre-commit`** - Scans for sensitive data:
```bash
#!/bin/sh
# Sangita Grantha Pre-commit Hook
# This hook scans staged files for sensitive data
exec "/path/to/sangita-cli" commit scan-sensitive
The hooks automatically detect the binary location (release/debug) or fall back to cargo run for development.
Validation Logic
(?i)ref:\s*(.+?)(?:\n|$) to find Ref: <path>.application_documentation/ directory.application_documentation/, and normalizes to absolute paths.Sensitive Data Scanning
The scan-sensitive command:
git diff --cached --name-onlyapi[_-]?key, SG_GEMINI_API_KEYsecret, password, tokenAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY