@fidel-tools/validate-pack
The automated CLI validation and linting tool for verifying schema correctness, duplicate rules, and cyclic maps in Fidel Tools language packs.
Overview
@fidel-tools/validate-pack is a validation utility and CLI tool for Fidel Tools language packs. It performs static analysis checks to catch circular references, overlap errors, duplicate definitions, and schema schema mismatches that would cause runtime loops or errors in the main pipeline.
Features
- Schema Check: Validates language pack configuration against the
LanguagePackschema definitions. - Cycle Detection: Resolves graph chains in
char_mapandlabialized_mapto flag circular references. - Deduplication: Identifies overlapping rules in stemmer prefixes, suffixes, and stopword arrays.
- Auto-Fix: Auto-cleans array duplicates and configuration overlaps with a simple command flag.
Installation
Install globally for CLI usage or locally for programmatic access:
# Global CLI installation
pnpm add -g @fidel-tools/validate-pack
# Local project dependency
pnpm add @fidel-tools/validate-pack
CLI Usage
Run Validation
Verify a language pack JSON file:
validate-pack ./path/to/am.json
Auto-Fix Pack
Deduplicate arrays and fix rule conflicts inline:
validate-pack --fix ./path/to/am.json
Programmatic API
import { validatePack, fixPack } from '@fidel-tools/validate-pack';
import amPack from '@fidel-tools/lang-am';
// Validate pack schema and logic
const report = validatePack(amPack);
console.log(report.isValid); // true
console.log(report.errors); // List of warning/error messages
// Fix pack programmatically
const { fixedPack, fixedCount } = fixPack(amPack);
API Reference
validatePack(pack: any): { isValid: boolean, errors: string[] }
Validates schema compliance, character cycles, overlapping protection constraints, and list duplicates.
fixPack(pack: any): { fixedPack: any, fixedCount: number }
Resolves array duplicates, protects stemmer keys, and returns the updated pack.
License
Part of the Fidel Tools project. Licensed under the MIT License.