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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sourcesailor

v1.5.0

Published

A CLI tool for analyzing and documenting codebases

Downloads

77

Readme

SourceSailor

NPM Version

Testing

Navigate through your source code with ease.

About

SourceSailor-CLI is a sophisticated command-line interface (CLI) tool designed for developers to analyze and understand their codebases more effectively. Built with JavaScript and powered by the Node.js runtime, it integrates with OpenAI's API and employs Tree-Sitter grammars for parsing, making it capable of handling a wide variety of programming languages. This tool streamlines the process of analyzing project structures, dependencies, and code quality, providing valuable insights through generated reports.

:construction: Installation and Usage

To get started with SourceSailor-CLI, ensure you have Node.js installed on your system. Follow these steps to install and use the tool:

Installation

Install this CLI using

npm install -g sourcesailor

Commands

Setup

Set up the OpenAI API key and default model for SourceSailor:

SourceSailor setup --apiKey <your_api_key> [--model <model_name>] [--analysisDir <directory>]

Options:

  • --apiKey, -k: OpenAI API Key (required)
  • --model, -m: OpenAI Model (default: 'gpt-3.5-turbo')
  • --analysisDir, -a: Root directory to write the analysis. Default is the home directory. Use 'p' to use the codebase directory. (default: home directory)

Get Directory Structure (Added in 1.3.0)

Get the directory structure of the given path:

SourceSailor dirStructure <path|p> [--verbose] [--withContent] [--ignore]

Positional arguments:

  • <path>, -p: Path to the directory to analyze (required)

Options:

  • --verbose, -v: Run with verbose logging (default: false)
  • --withContent, -c: Include file content in the output (default: true)
  • --ignore, -i: Additional files or patterns to ignore for analysis. You can pass multiple patterns separated by commas (default: none)

Analyze

Analyze the given directory structure to understand the project structure and dependencies:

SourceSailor analyse <path> [--verbose] [--openai] [--streaming] [--ignore]

Positional arguments:

  • <path>, -p: Path to the directory to analyze (required)

Options:

  • --verbose, -v: Run with verbose logging (default: false)
  • --openai, -o: Use OpenAI to infer project structure (default: true)
  • --streaming, -s: Use OpenAI streaming to infer project structure (default: false)
  • --ignore, -i: Additional files or patterns to ignore for analysis. You can pass multiple patterns separated by commas (default: none) (Added in 1.3.0)

List Models

List all available OpenAI models:

SourceSailor listModels [--verbose]

Options:

  • --verbose, -v: Enable verbose output

List Config

List all available configurations:

SourceSailor listConfig [--verbose]

Options:

  • --verbose, -v: Enable verbose output

Update Config

Update the OpenAI API key and default model:

SourceSailor updateConfig [--apiKey <api_key>] [--model <model_name>] [--analysisDir <directory>]

Options:

  • --apiKey, -k: OpenAI API Key
  • --model, -m: OpenAI Model
  • --analysisDir, -a: Root directory to write the analysis. Default is the home directory. Use 'p' to use the codebase directory.

Set User Expertise

Set your expertise level for various programming languages and frameworks:

SourceSailor setExpertise

This interactive command will guide you through setting your expertise levels for different programming languages and frameworks. This information helps SourceSailor provide more tailored analysis and reports.

Prepare Report

Prepare a report based on the analysis:

SourceSailor prepareReport <path> [--verbose] [--streaming]

Positional arguments:

  • <path>, -p: Path to the analysis (required)

Options:

  • --verbose, -v: Enable verbose output
  • --streaming, -s: Stream the output to a file

Use the SourceSailor --help command to see the full list of available commands and options.

About the Code

The SourceSailor-CLI tool is structured around several key components, each serving a specific purpose in the code analysis process:

  • Commands Directory: Contains various CLI commands like analyse.mjs, listConfig.mjs, and more, which implement the tool's functionality.
  • OpenAI Integration: The openai.mjs module interfaces with the OpenAI API, enabling the tool to perform advanced code analysis.
  • ❌ :brain: Tree-Sitter Parsing: Utilizes Tree-Sitter grammars in treeParser.mjs and treeSitterFromFieNames.mjs for accurate code parsing across different languages. (Removed from the core functionality,See #9)
  • Dynamic Command Handling: Employs Yargs for building a flexible CLI interface, making it user-friendly and adaptable to various user needs.
  • Configurable Analysis Directory: Allows users to specify directories for storing analysis results, adding a layer of customization.
  • User Expertise Levels: The expertise.mjs module manages user expertise levels for different programming languages and frameworks, enhancing the tool's analysis capabilities.

:construction: Next Steps

  • Iterate through prompts (Will be ongoing evaluation)
  • Use Openrouter to switch models (Not planning to use, will switch to Gemini and Claude for future versions, may be by using plugins)
  • Use more prompts and CoT to work around the project (Will be ongoing evaluation)
  • Add Anthropic and Gemini models (See #3 and #2 respectively)
  • ❌ Use tree sitter to get better ideas of the project and codebase :brain: (Can be core functionality of the CLI) (Already in the code) (Removed from the core functionality,See #9 )
  • ✅ Write some reports per prompt and then pass it to CoT to generate a confident report (Already in the code)
  • Use the report as RAG. :bulb: (Highly speculative)
  • ✅ Use CLI decorators like colors and other decorators
  • ✅ Customised additional ignore list, AKA passing those files like we pass in gitignore
  • NPM Package