JSPM

@guardrail-ai/core

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q48974F
  • License MIT

Core rule engine, types, and utilities for Guardrail

Package Exports

  • @guardrail-ai/core
  • @guardrail-ai/core/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@guardrail-ai/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@guardrail-ai/core

Core rule engine, AST parser, file discovery, and types for Guardrail.

Install

npm install @guardrail-ai/core

Usage

import { GuardrailEngine, parseSource } from '@guardrail-ai/core';

const engine = new GuardrailEngine({ severityThreshold: 'warning' });
engine.registerRules(myRules);

const summary = await engine.scan('./src');
console.log(`Found ${summary.totalViolations} issues`);

API

  • GuardrailEngine — Main scanning engine. Register rules, scan files/directories.
  • parseSource(source, filePath) — Babel AST parser with TypeScript/JSX support.
  • discoverFiles(path, config) — Glob-based file discovery with ignore patterns.
  • loadConfig(searchFrom?) — Load .guardrailrc.json or guardrail.config.js via cosmiconfig.
  • ScanCache — Content-hash based file caching for incremental scans.

Types

interface Rule {
  id: string;
  name: string;
  description: string;
  severity: 'critical' | 'high' | 'warning' | 'info';
  category: 'security' | 'performance' | 'quality' | 'ai-codegen';
  detect(context: RuleContext): Violation[];
}

License

MIT