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

@agentspec/codegen

v0.2.4

Published

AgentSpec provider-agnostic code generation: supports Claude subscription, any OpenAI-compatible endpoint, and the Anthropic API

Readme

@agentspec/codegen

Provider-agnostic code generation for AgentSpec. Reads an agent.yaml manifest and generates complete, runnable agent code for any supported framework.

Install

npm install @agentspec/codegen

Quick Start

import { generateCode, resolveProvider } from '@agentspec/codegen'
import { loadManifest } from '@agentspec/sdk'

const { manifest } = loadManifest('./agent.yaml')
const provider = resolveProvider() // auto-detects Claude CLI > OpenAI-compatible > Anthropic API

const result = await generateCode(manifest, {
  framework: 'langgraph',
  provider,
})

console.log(Object.keys(result.files)) // ['agent.py', 'tools.py', ...]

Providers

Three built-in providers, auto-detected in priority order:

| Provider | Class | Requires | |----------|-------|----------| | Claude subscription | ClaudeSubscriptionProvider | claude CLI authenticated | | OpenAI-compatible | OpenAICompatibleProvider | AGENTSPEC_LLM_API_KEY + AGENTSPEC_LLM_MODEL | | Anthropic API | AnthropicApiProvider | ANTHROPIC_API_KEY env var |

The OpenAI-compatible provider works with any endpoint that speaks the OpenAI wire format: OpenRouter, Groq, Together, Ollama, Nvidia NIM, OpenAI.com, and others. Set AGENTSPEC_LLM_BASE_URL to point at a non-OpenAI endpoint.

Auto-detection

import { resolveProvider } from '@agentspec/codegen'

const provider = resolveProvider()                    // auto-detect
const provider = resolveProvider('openai-compatible') // force specific provider

Override via env var: AGENTSPEC_CODEGEN_PROVIDER=openai-compatible. Valid values: auto, claude-sub, claude-subscription, openai-compatible, anthropic-api.

Direct instantiation

import { AnthropicApiProvider, OpenAICompatibleProvider } from '@agentspec/codegen'

// Anthropic
const anthropic = new AnthropicApiProvider('sk-ant-...', 'https://proxy.example.com')

// OpenAI-compatible (e.g. OpenRouter)
const openrouter = new OpenAICompatibleProvider(
  'sk-or-v1-...',
  'qwen/qwen3-235b-a22b',
  'https://openrouter.ai/api/v1',
)

Frameworks

List available frameworks at runtime:

import { listFrameworks } from '@agentspec/codegen'
console.log(listFrameworks()) // ['langgraph', 'crewai', 'mastra', ...]

Add a new framework by creating a skill file in src/skills/<name>.md — no TypeScript code needed.

Streaming

Stream generation progress via onChunk:

const result = await generateCode(manifest, {
  framework: 'langgraph',
  provider,
  onChunk: (chunk) => {
    if (chunk.type === 'delta') {
      process.stdout.write(chunk.text)
    }
  },
})

Chunk types:

  • delta — text fragment with text, accumulated, and elapsedSec
  • heartbeat — keep-alive with elapsedSec
  • done — final result with result string and elapsedSec

Utilities

collect(stream)

Drain a provider stream to a single string:

import { collect, resolveProvider } from '@agentspec/codegen'

const provider = resolveProvider()
const text = await collect(provider.stream(systemPrompt, userPrompt, {}))

repairYaml(provider, yaml, errors)

Ask the LLM to fix schema validation errors in an agent.yaml:

import { repairYaml, resolveProvider } from '@agentspec/codegen'

const fixed = await repairYaml(resolveProvider(), badYaml, validationErrors)

probeProviders()

Diagnostic probe for all codegen providers (used by agentspec provider-status):

import { probeProviders } from '@agentspec/codegen'

const report = await probeProviders()
console.log(report.results)              // ProviderProbeResult[]: one per probe
console.log(report.env.resolvedProvider) // 'claude-subscription' | 'openai-compatible' | 'anthropic-api' | null

Error Handling

All errors are typed as CodegenError with a code property:

import { CodegenError } from '@agentspec/codegen'

try {
  await generateCode(manifest, { framework: 'langgraph', provider })
} catch (err) {
  if (err instanceof CodegenError) {
    console.error(err.code, err.message)
    // err.code: 'auth_failed' | 'generation_failed' | 'parse_failed' | ...
  }
}

Error codes: auth_failed, quota_exceeded, rate_limited, model_not_found, generation_failed, parse_failed, provider_unavailable, response_invalid