Skip to content

Ship schema.json inside the npm package so $schema can resolve from node_modules #275

@OmerGronich

Description

@OmerGronich

Problem

The $schema examples in the docs and in fallow init's output point at a remote URL:

"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json"

That works in most setups, but it has three real downsides:

  1. Drifts from the installed version — the URL tracks main, while the installed CLI is pinned (e.g. 2.63.0). Schema validation can flag fields that are valid in the installed version, or miss new ones.
  2. Requires network on every fresh editor open — IDEs need to fetch and cache it; corporate proxies sometimes block raw.githubusercontent.com.
  3. No good offline / airgapped story — the only local alternative today is to run fallow config-schema > some/path/schema.json and reference that, which adds a generator step and a refresh policy on every fallow upgrade.

The CLI already exposes fallow config-schema, so the schema clearly exists — it just isn't shipped as a static artifact.

Proposed solution

Generate schema.json at publish time and include it in the files array of the package, so consumers can reference it directly from node_modules:

// .fallowrc.json
{
  "$schema": "./node_modules/fallow/schema.json",
  ...
}

Sketch of the change in fallow's package.json:

{
  "files": ["bin", "scripts", "skills", "schema.json"],
  "scripts": {
    "prepublishOnly": "node bin/fallow config-schema > schema.json"
  }
}

Benefits for consumers:

  • ✅ Always version-aligned — npm install resolves the matching schema automatically.
  • ✅ Zero network dependency.
  • ✅ Works offline / behind proxies / in airgapped CI.
  • ✅ Zero per-consumer maintenance — no generator script, no refresh policy.
  • ✅ IDE autocomplete + validation work out of the box.

Optional polish: have fallow init emit "$schema": "./node_modules/fallow/schema.json" by default once the file ships, with a fallback to the URL for users who haven't installed locally.

Alternatives considered

  • Pin the URL to a tag (.../v2.63.0/schema.json) — works, but every consumer has to remember to bump the URL on every upgrade, and it's still network-dependent.
  • Generate locally per-consumer (fallow config-schema > infra/schema.json + commit) — works, but adds a generator step, a refresh hook, and an extra committed file in every consuming repo.
  • Drop $schema entirely — loses IDE autocomplete and validation, regresses DX.

Shipping the schema in the package is the only option that's zero-network, zero-maintenance, and version-aligned for free.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions