open-index/open-npm huggingface dataset:
npm package: @guardlabs/guardrail-cli
Description: CLI for provisioning and using Guardrail, the Guard Labs wallet-control product for agents.
Latest version: 0.1.3

# @guardlabs/guardrail-cli

CLI for provisioning and using Guardrail, the Guard Labs wallet-control product for agents.

## Usage

Run without installing globally:

```bash
npx @guardlabs/guardrail-cli create --chain-id 84532
```

Or install it globally:

```bash
npm install -g @guardlabs/guardrail-cli
guardrail --help
```

The installed command name is `guardrail`.

By default, the CLI targets the hosted Guard Labs backend at `https://api.guardlabs.ai`.
Use `--backend-url` only when you want to target a local or self-hosted backend.

Examples in this README omit `--backend-url` for the hosted path. Add it back only for custom deployments.

## Quickstart

Create a wallet request with an official USDC budget limited to `$10` per trailing 24 hours:

```bash
npx @guardlabs/guardrail-cli create \
  --chain-id 84532 \
  --usdc-period daily \
  --usdc-max 10 \
  --usdc-allow transfer,approve,increaseAllowance,permit,transferWithAuthorization
```

Wait for readiness:

```bash
npx @guardlabs/guardrail-cli await wal_xxx
```

Use the ready wallet:

```bash
npx @guardlabs/guardrail-cli call wal_xxx \
  --to 0x1111111111111111111111111111111111111111 \
  --data 0xa9059cbb \
  --value-wei 0
```

## Supported Chains

- `8453`: Base
- `84532`: Base Sepolia

## Docs

Full documentation lives in the repository:

- GitHub: https://github.com/guardlabs/guardrail
- Docs index: https://github.com/guardlabs/guardrail/blob/main/docs/README.md
- Quickstart: https://github.com/guardlabs/guardrail/blob/main/docs/quickstart.md
- CLI reference: https://github.com/guardlabs/guardrail/blob/main/docs/cli.md
npm package: @guardrail-ai/cli
Description: CLI for Guardrail — scan and fix AI-generated code for security, performance, and quality issues
Latest version: 0.2.2

# @guardrail-ai/cli

CLI for [Guardrail](https://github.com/Manavarya09/Guardrail) — scan and fix AI-generated code for security, performance, and quality issues.

## Install

```bash
npm install -g @guardrail-ai/cli
```

## Commands

```bash
# Scan a directory
guardrail scan ./src

# Auto-fix issues
guardrail fix ./src

# Dry-run (show diffs without applying)
guardrail fix ./src --dry-run

# Watch mode
guardrail watch ./src

# Generate HTML report
guardrail scan ./src --report html

# JSON output
guardrail scan ./src --json

# Filter by severity
guardrail scan ./src --severity high

# Filter by rules
guardrail scan ./src --rules "security/sql-injection,security/no-eval"

# Initialize config
guardrail init
```

## Output

```
  Guardrail — scanning for issues...

src/api/auth.ts
   CRIT  12:6   Hardcoded secret in variable "API_KEY"   [security/hardcoded-api-key]
   HIGH  28:2   cors() called with no arguments            [security/insecure-cors]
   WARN  45:4   Sequential await inside loop               [performance/inefficient-loop]
   WARN  52:0   console.log() call                         [ai-codegen/console-log-spam]  (fixable)

Found 4 issues in 1 file (0.03s)
  1 critical, 1 high, 2 warnings
  1 issue is auto-fixable (run guardrail fix)
```

## 22 rules across 4 categories

Security, AI-Codegen, Quality, and Performance. See the [full rules list](https://github.com/Manavarya09/Guardrail#22-built-in-rules).

## License

MIT
npm package: @guardrail-ai/core
Description: Core rule engine, types, and utilities for Guardrail
Latest version: 0.2.2

# @guardrail-ai/core

Core rule engine, AST parser, file discovery, and types for [Guardrail](https://github.com/Manavarya09/Guardrail).

## Install

```bash
npm install @guardrail-ai/core
```

## Usage

```typescript
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

```typescript
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
npm package: @guardrail-ai/fixer
Description: AST-based auto-fix engine for Guardrail
Latest version: 0.2.2

# @guardrail-ai/fixer

AST-based auto-fix engine for [Guardrail](https://github.com/Manavarya09/Guardrail). Applies fixes from rule violations and outputs unified diffs.

## Install

```bash
npm install @guardrail-ai/fixer
```

## Usage

```typescript
import { FixerEngine } from '@guardrail-ai/fixer';

const fixer = new FixerEngine();

// Dry run — returns diff without writing
const result = await fixer.applyFixes(filePath, violations, false);
console.log(result.diff);
console.log(`${result.applied} fixes applied`);

// Write fixes to disk
await fixer.applyFixes(filePath, violations, true);
```

## How it works

1. Sorts fixes bottom-to-top to preserve line numbers
2. Applies line-based replacements from violation fix suggestions
3. Generates unified diffs via the `diff` package
4. Optionally writes the fixed file to disk

## License

MIT
npm package: @guardrail-ai/rules
Description: Built-in detection rules for Guardrail (19 rules across security, performance, quality, and AI-codegen)
Latest version: 0.2.2

# @guardrail-ai/rules

22 built-in detection rules for [Guardrail](https://github.com/Manavarya09/Guardrail).

## Install

```bash
npm install @guardrail-ai/rules
```

## Usage

```typescript
import { builtinRules } from '@guardrail-ai/rules';
import { GuardrailEngine } from '@guardrail-ai/core';

const engine = new GuardrailEngine();
engine.registerRules(builtinRules);
```

## Rules

### Security (8)
| Rule | Severity |
|------|----------|
| `security/hardcoded-api-key` | critical |
| `security/sql-injection` | critical |
| `security/no-eval` | critical |
| `security/insecure-cors` | high |
| `security/env-var-leak` | high |
| `security/unsafe-regex` | high |
| `security/no-secrets-in-logs` | high |
| `security/no-rate-limiting` | info |

### AI-Codegen (10)
| Rule | Severity |
|------|----------|
| `ai-codegen/hallucinated-import` | high |
| `ai-codegen/placeholder-code` | warning |
| `ai-codegen/hardcoded-localhost` | warning |
| `ai-codegen/overly-broad-catch` | warning |
| `ai-codegen/unused-imports` | warning |
| `ai-codegen/any-type-abuse` | warning |
| `ai-codegen/fetch-without-error-handling` | warning |
| `ai-codegen/promise-without-catch` | warning |
| `ai-codegen/console-log-spam` | info |
| `ai-codegen/magic-numbers` | info |

### Quality (2)
| Rule | Severity |
|------|----------|
| `quality/dead-code` | warning |
| `quality/duplicate-logic` | warning |

### Performance (2)
| Rule | Severity |
|------|----------|
| `performance/inefficient-loop` | warning |
| `performance/n-plus-one-query` | high |

## License

MIT
npm package: @guardrail-sim/insights
Description: Policy insights, health checks, and best practice recommendations for guardrail-sim
Latest version: 0.2.1

# @guardrail-sim/insights

[![npm version](https://img.shields.io/npm/v/@guardrail-sim/insights)](https://www.npmjs.com/package/@guardrail-sim/insights)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

Automated health checks for your pricing policies. Catches things like missing margin floors, overly permissive approval rates, and untested volume tiers — with actionable recommendations.

Part of [guardrail-sim](https://github.com/jeffgreendesign/guardrail-sim).

## Install

```bash
npm install @guardrail-sim/insights
```

## Quick Start

```typescript
import { analyzePolicy } from '@guardrail-sim/insights';

const report = await analyzePolicy({
  policy: {
    id: 'wholesale-v1',
    name: 'B2B Wholesale',
    ruleCount: 3,
    hasMarginFloor: true,
    marginFloorValue: 0.15,
    hasMaxDiscountCap: true,
    maxDiscountCapValue: 0.25,
    hasVolumeTiers: false,
    hasSegmentRules: false,
  },
});

// report.summary => { critical: 0, warning: 1, info: 2, total: 3 }
```

## What It Checks

24+ built-in checks across three categories:

- **Policy health** — missing rules, conflicting conditions, low margin floors
- **Margin protection** — approval rates too high/low, margin erosion trends
- **Simulation analysis** — unused rules, segment imbalances, rejection patterns

For more control, use `createRecommendationEngine(config)` to filter by category, severity, or load custom insight packs.

## Docs

- [Insights Reference](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/packages/insights.mdx)

## License

MIT
npm package: @guardrail-sim/mcp-server
Description: MCP server exposing evaluate_policy tool for AI agents
Latest version: 0.3.0

# @guardrail-sim/mcp-server

[![npm version](https://img.shields.io/npm/v/@guardrail-sim/mcp-server)](https://www.npmjs.com/package/@guardrail-sim/mcp-server)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

MCP server that exposes pricing policy tools to AI agents. Run it, point your MCP client at it, and your agent can evaluate discounts, check policy rules, and simulate checkouts.

Part of [guardrail-sim](https://github.com/jeffgreendesign/guardrail-sim).

## Quick Start

```bash
npx @guardrail-sim/mcp-server
```

Or install globally:

```bash
npm install -g @guardrail-sim/mcp-server
guardrail-mcp
```

## Tools

| Tool                         | What it does                                        |
| ---------------------------- | --------------------------------------------------- |
| `evaluate_policy`            | Check a proposed discount against the active policy |
| `get_policy_summary`         | Return all policy rules in plain English            |
| `get_max_discount`           | Find the best discount available for a given order  |
| `validate_discount_code`     | Validate a code and return UCP-standard error codes |
| `simulate_checkout_discount` | Run a full UCP checkout with discounts applied      |

## Programmatic Usage

```typescript
import { createServer } from '@guardrail-sim/mcp-server';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = createServer();
await server.connect(new StdioServerTransport());
```

## Docs

- [MCP Tools Reference](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/mcp-tools.mdx)
- [Architecture](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/architecture.mdx)

## License

MIT
npm package: @guardrail-sim/policy-engine
Description: Deterministic policy evaluation engine using json-rules-engine for AI pricing governance
Latest version: 0.2.1

# @guardrail-sim/policy-engine

[![npm version](https://img.shields.io/npm/v/@guardrail-sim/policy-engine)](https://www.npmjs.com/package/@guardrail-sim/policy-engine)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

Rules engine for B2B pricing policies. Define margin floors, discount caps, and volume tiers — evaluate orders against them deterministically.

Built on [json-rules-engine](https://github.com/CacheControl/json-rules-engine). Part of [guardrail-sim](https://github.com/jeffgreendesign/guardrail-sim).

## Install

```bash
npm install @guardrail-sim/policy-engine
```

## Quick Start

```typescript
import { PolicyEngine, defaultPolicy } from '@guardrail-sim/policy-engine';

const engine = new PolicyEngine(defaultPolicy);

const result = await engine.evaluate(
  { order_value: 5000, quantity: 100, product_margin: 0.4 },
  0.12 // 12% proposed discount
);

result.approved; // true
result.violations; // [] — no violations
result.calculated_margin; // 0.28
```

The default policy ships with three rules: 15% margin floor, 25% discount cap, and volume-based tiers (10% base, 15% for 100+ units).

## API

- **`PolicyEngine(policy)`** — create an engine from a policy definition
- **`engine.evaluate(order, discount)`** — check a proposed discount against the rules
- **`calculateMaxDiscount(order)`** — find the highest discount an order can receive
- **`calculateAllocations(amount, lineItems, method)`** — split a discount across line items
- **`defaultPolicy`** — the built-in policy (good for testing and demos)

## Docs

- [Getting Started](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/getting-started.mdx)
- [Policy Concepts](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/concepts/policies.mdx)

## License

MIT
npm package: @guardrail-sim/ucp-types
Description: UCP (Universal Commerce Protocol) type definitions for guardrail-sim
Latest version: 1.0.0

# @guardrail-sim/ucp-types

[![npm version](https://img.shields.io/npm/v/@guardrail-sim/ucp-types)](https://www.npmjs.com/package/@guardrail-sim/ucp-types)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

TypeScript types for the [Universal Commerce Protocol](https://ucp.dev) — discount requests, checkout sessions, line items, payments, and converter functions to bridge between guardrail-sim's policy engine and UCP-formatted responses.

Part of [guardrail-sim](https://github.com/jeffgreendesign/guardrail-sim).

## Install

```bash
npm install @guardrail-sim/ucp-types
```

## Usage

```typescript
import {
  buildDiscountExtensionResponse,
  fromUCPLineItems,
} from '@guardrail-sim/ucp-types/converters';
import { PolicyEngine, defaultPolicy } from '@guardrail-sim/policy-engine';

// Convert UCP line items into a policy engine order
const order = fromUCPLineItems(checkoutLineItems, { productMargin: 0.35 });

// Evaluate and build a UCP-shaped response
const engine = new PolicyEngine(defaultPolicy);
const evaluation = await engine.evaluate(order, 0.15);
const response = buildDiscountExtensionResponse(['SUMMER20'], evaluation, 1500, 'Summer Sale');
```

## Entry Points

- **`@guardrail-sim/ucp-types`** — everything re-exported from one place
- **`@guardrail-sim/ucp-types/discount`** — `DiscountRequest`, `DiscountResponse`, error codes
- **`@guardrail-sim/ucp-types/checkout`** — `CheckoutResponse`, `LineItem`, `Buyer`, payment types
- **`@guardrail-sim/ucp-types/converters`** — `buildDiscountExtensionResponse`, `fromUCPLineItems`, `toUCPErrorCode`, etc.

## Docs

- [UCP Types Reference](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/packages/ucp-types.mdx)
- [UCP Concepts](https://github.com/jeffgreendesign/guardrail-sim/blob/main/docs/concepts/ucp.mdx)

## License

MIT
npm package: @guardrailai/cli
Description: Guardrail CLI — Ship with confidence. AI-native code scanning, security analysis, and quality gates.
Author: Guardrail Team
Latest version: 2.6.0

# @guardrail/cli

**Ship with confidence.** AI-native code scanning, security analysis, and quality gates.

```bash
npm install -g @guardrail/cli
```

## Quick Start

```bash
# Scan your codebase for issues
guardrail scan

# Check if your app is ship-ready
guardrail ship

# Initialize guardrail in your project
guardrail init

# Generate AI editor rules (Cursor, Windsurf, Copilot, Claude)
guardrail context
```

## Commands

| Command | Tier | Description |
|---------|------|-------------|
| `guardrail scan` | Free | Route integrity, security analysis, code quality |
| `guardrail validate` | Free | AI code validation |
| `guardrail badge` | Free | Generate ship badges for README |
| `guardrail context` | Free | AI rules for Cursor, Windsurf, Copilot, Claude |
| `guardrail doctor` | Free | Environment diagnostics |
| `guardrail ship` | Starter | Plain-English ship readiness audit |
| `guardrail gate` | Starter | CI/CD quality gate (pass/fail) |
| `guardrail reality` | Starter | Playwright browser testing |
| `guardrail ai-test` | Pro | Autonomous AI agent testing |
| `guardrail fix --all` | Pro | One-click auto-fix |
| `guardrail audit` | Compliance | SOC2/HIPAA/GDPR audit trail |

## Scan Output (Tiered)

**Free** — See severity counts + blurred findings + upgrade prompt
**Starter ($9.99/mo)** — Full finding details (file, line, description)
**Pro ($29.99/mo)** — Full details + auto-fix suggestions + AI agent

## CI/CD Integration

```yaml
# GitHub Actions
- name: Guardrail Gate
  run: npx @guardrail/cli gate
```

```yaml
# GitLab CI
guardrail:
  script: npx @guardrail/cli gate
```

## Links

- **Website**: https://guardrail.dev
- **Docs**: https://docs.guardrail.dev
- **Pricing**: https://guardrail.dev/pricing

## License

MIT