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

docs-driven-api-updater

v1.0.2

Published

Universal docs-driven API updater that crawls official docs, plans safe code updates, and applies changes locally or in CI.

Readme

docs-driven-api-updater

Universal, TypeScript-first, ESM-only SDK maintenance tool that crawls third-party docs and proposes safe updates for integration wrappers, endpoint lists, and README method tables.

Install

npm install docs-driven-api-updater

Quick Start

npx docs-driven-api-updater init
cp .env.example .env
npx docs-driven-api-updater update --dry-run

Add Any API Integration

  1. Create a directory for the integration (example: src/integrations/shopify).
  2. Add a methods registry JSON (example: src/integrations/shopify/supported-methods.json).
  3. Add/update your wrapper .ts files in that integration directory.
  4. Register the integration in updater.config.json:
{
  "integrations": [
    {
      "name": "shopify",
      "docUrls": ["https://shopify.dev/docs/api/admin-rest"],
      "methodsFile": "src/integrations/shopify/supported-methods.json",
      "targetDir": "src/integrations/shopify"
    }
  ]
}
  1. Run updater preview:
npx docs-driven-api-updater update --dry-run

Updater Pipeline

The updater is docs-driven, not runtime mutation. It creates reviewable file updates for local/CI usage.

  1. Doc crawl: crawlAllDocs() fetches configured docs and extracts normalized text + table rows.
  2. Plan generation: askOllamaForPatchPlan() sends docs + current supported-methods.json to OpenRouter or Ollama and expects strict JSON:
    • summary
    • updatedMethods
    • changes
    • files (full file outputs)
    • readmeTable
  3. Diff planning: planDiffs() produces git-style previews for allowed targets:
    • src/integrations/*/*.ts
    • README.md
    • each integration supported-methods.json
  4. Safety gate: validateUpdaterPlanSafety() rejects suspicious plans (placeholder rewrites, destructive class replacements, abnormal file shrink).
  5. Preview + apply: runUpdateCommand() prints diffs, asks for confirmation (unless --yes/--ci), applies changes, syncs methods, and rebuilds.
  6. CI/PR flow: writes artifacts and opens PR rather than silently changing main.
flowchart LR
  A[Crawl Docs] --> B[Generate JSON Plan]
  B --> C[Safety Validation]
  C --> D[Plan Diffs]
  D --> E{Mode}
  E -->|Local| F[Preview + Confirm + Apply]
  E -->|CI| G[Artifacts + PR]

CLI Commands

init

Creates:

  • updater.config.json
  • .env.example
  • starter src/integrations/stripe/supported-methods.json

update

npx docs-driven-api-updater update [options]

Flags:

  • --dry-run: compute plan + preview diffs without writing files
  • --yes: auto-confirm apply
  • --ci: CI mode (non-interactive)
  • --open-pr: produce PR metadata artifacts
  • --fallback-models "modelA,modelB": CLI model failover override
  • --max-model-attempts 3: cap fallback attempts

Safety & Reliability

  • Provider abstraction: OpenRouter and local Ollama.
  • Fallback chain: tries multiple models with short backoff.
  • Retry-aware statuses: 402, 404, 408, 429.
  • Prompt truncation knobs: limit docs/method payload sizes.
  • Sanitized errors: avoids dumping secrets and huge request bodies.
  • Safety gate: rejects suspicious destructive model output patterns.

CI / PR Automation

Workflow: .github/workflows/auto-update-pr.yml

  • Supports schedule and manual dispatch.
  • Runs updater in CI mode.
  • Writes:
    • .artifacts/update-plan.json
    • .artifacts/update-diff-summary.json
    • .artifacts/pr-title.txt
    • .artifacts/pr-body.md
  • Opens PR (not direct mutation of main branch).
  • Supports dry_run dispatch input.

Error Handling Guide

  • Missing config: run npx docs-driven-api-updater init.
  • Provider auth errors: verify OPENROUTER_API_KEY or OLLAMA_HOST.
  • Schema validation failure: model output was not strict JSON; use fallback models or lower prompt size.
  • Safety gate failure: inspect .artifacts/update-plan.json and rerun with tighter prompts.
  • No diffs generated: docs may not contain relevant changes; verify docUrls and integration file paths.

Rate-Limit & Cost Control

Use .env knobs:

  • UPDATER_DOC_MAX_CHARS: lower docs payload size.
  • UPDATER_PROMPT_DOC_MAX_CHARS: hard cap LLM docs context.
  • UPDATER_PROMPT_METHODS_MAX_CHARS: cap methods context.
  • MAX_MODEL_ATTEMPTS: reduce fallback attempts.
  • UPDATER_LLM_TIMEOUT_MS: prevent runaway requests.

Strategy:

  1. Start with --dry-run.
  2. Keep integrations small and focused.
  3. Add only high-signal docs URLs.
  4. Run weekly in CI.

Updated Methods Snapshot

| Integration | Method | Status | Notes | |---|---|---|---| | stripe | customers.create | stable | baseline template method | | stripe | charges.create | stable | baseline template method |