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

@synapsor/dsl

v1.0.0

Published

Preview SQL-like Synapsor authoring DSL compiler for canonical @synapsor/spec contracts.

Readme

@synapsor/dsl

@synapsor/dsl is a 0.1 preview authoring layer for Synapsor contracts.

The DSL is not the source of truth. It compiles to @synapsor/spec JSON, and the generated JSON is validated by @synapsor/spec.

Part of the Synapsor OSS toolchain:

Example

CREATE AGENT CONTEXT local_operator
  BIND tenant_id FROM ENVIRONMENT SYNAPSOR_TENANT_ID REQUIRED
  BIND principal FROM ENVIRONMENT SYNAPSOR_PRINCIPAL REQUIRED
  TENANT BINDING tenant_id
  PRINCIPAL BINDING principal
END

CREATE CAPABILITY billing.inspect_invoice
  DESCRIPTION 'Inspect one invoice in the trusted tenant before proposing a waiver.'
  RETURNS HINT 'Returns reviewed invoice fields plus evidence/query-audit handles.'
  USING CONTEXT local_operator
  SOURCE local_postgres
  ON public.invoices
  PRIMARY KEY id
  TENANT KEY tenant_id
  CONFLICT GUARD updated_at
  LOOKUP invoice_id BY id
  ARG invoice_id STRING REQUIRED MAX LENGTH 128 DESCRIPTION 'Invoice id such as INV-3001.'
  ALLOW READ id, tenant_id, status, late_fee_cents, updated_at
  REQUIRE EVIDENCE
  MAX ROWS 1
END

A longer worked contract lives in examples/billing-late-fee.synapsor.sql, and the runner README walks the full compile → validate → bundle → serve flow.

Use .synapsor.sql for authored DSL files so editors recognize the file as SQL and provide generic SQL highlighting. Existing .synapsor files remain supported for compatibility. The filename suffix does not change DSL semantics or generated canonical JSON; this repository does not provide Synapsor-specific semantic editor highlighting.

CLI

synapsor-dsl validate ./contract.synapsor.sql [--strict]
synapsor-dsl compile ./contract.synapsor.sql --out ./synapsor.contract.json [--strict]

Runner also exposes:

synapsor-runner dsl validate ./contract.synapsor.sql [--strict]
synapsor-runner dsl compile ./contract.synapsor.sql --out ./synapsor.contract.json [--strict]

--strict treats safety warnings as errors. Use it in CI for reviewed proposal contracts.

Continue from authored DSL to a local/Cloud-compatible contract with:

synapsor-dsl compile ./contract.synapsor.sql --out ./synapsor.contract.json --strict
synapsor-spec validate ./synapsor.contract.json
synapsor-runner contract bundle ./synapsor.contract.json --out ./synapsor-runner-bundle
synapsor-runner cloud push ./synapsor.contract.json --dry-run

The generated synapsor.contract.json is the portable source of truth. Runner configuration supplies local database env names and transport settings; Cloud stores immutable normalized versions and never needs database credentials in the contract.

Programmatic API

import { compileAgentDsl, parseAgentDsl, validateAgentDsl, formatAgentDsl, AgentDslError } from "@synapsor/dsl";
import { assertValidContract, normalizeContract } from "@synapsor/spec";

const source = `CREATE AGENT CONTEXT ...`;

const result = validateAgentDsl(source); // { ok, errors, warnings } with line/column entries
const ast = parseAgentDsl(source);       // AST with line/column spans

try {
  const contract = compileAgentDsl(source); // @synapsor/spec contract JSON
  assertValidContract(normalizeContract(contract));
} catch (error) {
  if (error instanceof AgentDslError) {
    console.error(`${error.message} at ${error.line}:${error.column}`);
  }
}

formatAgentDsl(source) returns a canonically formatted copy of the DSL text.

Supported Preview Constructs

  • CREATE AGENT CONTEXT
  • CREATE CAPABILITY
  • CREATE AGENT WORKFLOW
  • BIND ... FROM SESSION|ENVIRONMENT|CLOUD_SESSION|STATIC_DEV|HTTP_CLAIM
  • USING CONTEXT
  • DESCRIPTION
  • RETURNS HINT
  • ON schema.table
  • PRIMARY KEY
  • TENANT KEY
  • CONFLICT GUARD
  • ARG
  • ARG ... DESCRIPTION
  • ARG ... MIN ... MAX ... for NUMBER
  • ARG ... MAX LENGTH ... for STRING/TEXT
  • LOOKUP
  • ALLOW READ
  • KEEP OUT
  • REQUIRE EVIDENCE
  • PROPOSE ACTION
  • ALLOW WRITE
  • PATCH
  • BOUND
  • TRANSITION
  • APPROVAL ROLE
  • AUTO APPROVE WHEN field <= integer
  • LIMIT count PER DAY after auto-approval
  • LIMIT TOTAL integer PER DAY after auto-approval
  • optional PER OBJECT DAY scope for count/total limits
  • WRITEBACK DIRECT SQL|APP HANDLER|CLOUD WORKER|NONE
  • workflow ALLOW CAPABILITY

Unsupported Cloud-generated clauses such as ROOT EXTERNAL, JOIN EXTERNAL, RETURN ANSWER WITH CITATIONS, AUTO BRANCH, or AUTO MERGE fail explicitly instead of being ignored.

The complete clause grammar and constraints, including primary-key-only LOOKUP, fixed-string PATCH, workflow declarations, and writeback forms, are in the Synapsor DSL Reference.