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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mariozechner/lsp-cli

v0.1.3

Published

CLI tool to extract types from codebases using LSP servers

Downloads

140

Readme

LSP CLI

A command-line tool that uses Language Server Protocol (LSP) servers to extract symbol information from codebases.

Installation

npm install
npm run build

Usage

Development

npx tsx src/index.ts <directory> <language> <output-file>

Production (after build)

./dist/index.js <directory> <language> <output-file>

Global Installation

npm install -g .
lsp-cli <directory> <language> <output-file>

Options

  • -v, --verbose - Enable verbose logging
  • --llm - Print llms.md documentation to stdout (for LLM consumption)

Supported Languages

  • java - Java (requires JDK)
  • cpp - C++ (requires clang/gcc)
  • c - C (requires clang/gcc)
  • csharp - C# (requires .NET SDK)
  • haxe - Haxe (requires Haxe compiler)
  • typescript - TypeScript (requires Node.js)
  • dart - Dart (requires Dart SDK)

Example

# Analyze a Java project
npx tsx src/index.ts /path/to/java/project java types.json

# With verbose logging
npx tsx src/index.ts /path/to/java/project java types.json -v

# Print LLM documentation to stdout
lsp-cli --llm

Output

The tool outputs JSON with all symbols found in the codebase:

{
  "language": "java",
  "directory": "/path/to/project",
  "symbols": [
    {
      "name": "MyClass",
      "kind": "class",
      "file": "/path/to/project/src/MyClass.java",
      "range": {
        "start": { "line": 10, "character": 0 },
        "end": { "line": 25, "character": 1 }
      },
      "preview": "public class MyClass<T> extends BaseClass<T> implements MyInterface {",
      "documentation": "Class documentation from JavaDoc",
      "typeParameters": ["T"],
      "supertypes": [
        { "name": "BaseClass", "typeArguments": ["T"] },
        { "name": "MyInterface" }
      ],
      "children": [
        {
          "name": "myMethod",
          "kind": "method",
          "range": {
            "start": { "line": 12, "character": 4 },
            "end": { "line": 15, "character": 5 }
          },
          "preview": [
            "public String myMethod(int param) {",
            "    // Method implementation",
            "    return result;",
            "}"
          ]
        },
        {
          "name": "InnerClass",
          "kind": "class",
          "range": {
            "start": { "line": 17, "character": 4 },
            "end": { "line": 22, "character": 5 }
          },
          "preview": "public static class InnerClass {",
          "children": [
            {
              "name": "innerField",
              "kind": "field",
              "range": {
                "start": { "line": 18, "character": 8 },
                "end": { "line": 18, "character": 30 }
              },
              "preview": "private String innerField;"
            }
          ]
        }
      ]
    }
  ]
}

Note: The actual structure includes:

  • preview: Can be a single string or array of strings
  • children: Nested symbols (methods, fields, etc.) instead of members
  • typeParameters: Generic/template type parameter names (e.g., ["T", "U"]) (optional)
  • supertypes: Parent classes/interfaces as objects with name and optional typeArguments (optional)
  • documentation: JSDoc/JavaDoc comments (optional)
  • definition: For C/C++ declarations, links to implementation (optional)

Requirements

Toolchains

Each language requires its toolchain installed:

  • Java: JDK 11+
  • C/C++: clang or gcc
  • C#: .NET SDK
  • Haxe: Haxe compiler
  • TypeScript: Node.js
  • Dart: Dart SDK

Project Files

For best results, projects should have proper configuration:

  • Java: pom.xml, build.gradle, or .classpath
  • C/C++: compile_commands.json or .clangd
  • C#: .csproj or .sln
  • Haxe: build.hxml or haxe.json
  • TypeScript: tsconfig.json
  • Dart: pubspec.yaml

LSP Servers

The tool automatically downloads and installs LSP servers to ~/.lsp-cli/servers/ on first use.