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

@ldclabs/kip-lang

v0.1.0

Published

KIP (Knowledge Interaction Protocol) language toolkit: lexer, parser, formatter, and diagnostics

Readme

@ldclabs/kip-lang

TypeScript toolkit for KIP (Knowledge Interaction Protocol) — a structured query language for knowledge graphs.

Provides a full-featured lexer → parser → AST → formatter / diagnostics pipeline for .kip files.

Installation

pnpm add @ldclabs/kip-lang

Usage

Tokenize

import { tokenize } from '@ldclabs/kip-lang'

const tokens = tokenize('FIND(?x.name) WHERE { ?x {type: "Person"} }')
// Token[] with type, value, line, column, offset

Parse

import { parse } from '@ldclabs/kip-lang'

const { ast, diagnostics } = parse(`
FIND(?drug.name)
WHERE {
  ?drug {type: "Drug"}
  (?drug, "treats", {name: "Headache"})
}
LIMIT 10
`)

console.log(ast.statements[0].kind) // "FindStatement"
console.log(diagnostics)            // [] (no errors)

Format

import { format } from '@ldclabs/kip-lang'

const source = `UPSERT { CONCEPT ?x { {type: "Drug", name: "Aspirin"} SET ATTRIBUTES { risk_level: 2 } } }`

const formatted = format(source, {
  indentSize: 4,       // default: 4
  sortAttributes: true // default: true
})

Output:

UPSERT {
    CONCEPT ?x {
        {type: "Drug", name: "Aspirin"}
        SET ATTRIBUTES { risk_level: 2 }
    }
}

The formatter preserves comments and quoted/unquoted key styles from the original source.

A lighter alternative formatPreservingComments() is also available — it normalizes indentation at the line level without AST reconstruction.

Diagnose

import { diagnose } from '@ldclabs/kip-lang'

const diagnostics = diagnose('UPSERT { CONCEPT ?x { {type: "Drug"} }')
// [{ severity: "error", message: "Unclosed '{'", ... }]

Diagnostics cover:

  • Lexer errors (unknown characters, unterminated strings)
  • Bracket matching (unclosed / mismatched braces, brackets, parentheses)
  • Parser errors (unexpected tokens, missing clauses)

API Reference

| Export | Description | | -------------------------------------------- | -------------------------------------------------------- | | tokenize(source) | Tokenize KIP source into Token[] | | parse(source) | Parse into { ast: Program, diagnostics: Diagnostic[] } | | format(source, options?) | AST-based formatting with comment preservation | | formatPreservingComments(source, options?) | Line-level indent normalization | | diagnose(source) | Return Diagnostic[] (lexer + bracket + parser errors) | | TokenType | Enum of all token types | | KEYWORDS / FUNCTIONS | Maps of KIP keywords and built-in functions |

AST Node Types

All AST types are exported for downstream consumption:

  • Statements: FindStatement, UpsertStatement, DeleteStatement, DescribeStatement, SearchStatement
  • Blocks: ConceptBlock, PropositionBlock, SetAttributes, SetPropositions, WithMetadata
  • Patterns: ConceptPattern, PropositionPattern, FilterClause, NotClause, OptionalClause, UnionClause
  • Expressions: ObjectLiteral, ArrayLiteral, ObjectEntry, Expression

KIP Language

KIP is a structured query and mutation language for knowledge graphs. See the KIP Specification for full syntax details.

License

MIT