npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arcanada/output-guard

v0.1.5

Published

Validate, repair, retry LLM structured output (JSON / YAML / TOML / Python literal) — 15-strategy two-pass repair chain with Zod adapter.

Downloads

626

Readme

@arcanada/output-guard

npm version License: MIT CI TypeScript

Validate, repair, and retry LLM structured output (JSON / YAML / TOML / Python literal) — battle-tested 15-strategy repair chain with two-pass orchestrator.

Install

pnpm add @arcanada/output-guard

# or
npm install @arcanada/output-guard

# or
yarn add @arcanada/output-guard

Quick start

import { repair, OutputGuard } from '@arcanada/output-guard';
import { z } from 'zod';

const User = z.object({
  name: z.string(),
  age: z.number(),
});

// Functional API — format-only repair, no schema
const result = repair('{"name":"Alice","age":30,}', 'json');

console.log(result.data);              // { name: 'Alice', age: 30 }
console.log(result.repaired);          // true
console.log(result.pass);              // "A"
console.log(result.strategiesApplied); // ["fix-commas"]

Stateful API (with schema validation)

import { OutputGuard } from '@arcanada/output-guard';

const guard = new OutputGuard({ format: 'json', schema: User });
const result = guard.repair('```json\n{"name":"Bob","age":25}\n```');
// throws if schema mismatch; returns RepairResult<User> on success

Output format support

  • JSON — strict and relaxed parsing with common error recovery
  • YAML — with structural repair for indentation and missing keys
  • TOML — fixing malformed tables and value assignments
  • Python literal — parsing dict/list literals with safe eval
  • Auto-detect — set format: 'auto' to infer format from content

RepairResult semantics

interface RepairResult<T> {
  repaired: boolean;          // false when raw was already valid
  data?: T;                   // parsed + (optionally) schema-validated payload
  raw: string;                // original input as supplied
  strategiesApplied: string[]; // ordered list of repair strategies invoked
  pass: "A" | "B";            // "A" = combined-apply; "B" = isolating fallback
}

MAX_RETRIES exhaustion signals via thrown ParseError, not via a pass value.

Async wrapper for LLM calls

import { guardedGenerate } from '@arcanada/output-guard';
import { z } from 'zod';

const result = await guardedGenerate({
  generate: async (prompt) => callYourLLM(prompt),  // your LLM client
  prompt: 'Return JSON {"result": <integer>}',
  schema: z.object({ result: z.number() }),
  format: 'json',
  maxRetries: 3,
});

console.log(result.data);              // { result: 42 }
console.log(result.pass);              // "A" | "B"
console.log(result.strategiesApplied); // [] when raw was already valid

Error handling

  • ValidationError — schema validation failure
  • RepairExhaustedError — all repair strategies exhausted
  • FormatError — unsupported or unparseable format

Requirements

Node >= 18 (recommended 20+)

Documentation

Full API reference and guides: docs/ (Diataxis structure).
Source: packages/ts

License

MIT — see LICENSE


Жизнь одного человека имеет значение / One human life matters