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

sourcebot-code

v0.1.12

Published

CLI for searching code across Sourcebot instances

Readme

Sourcebot CLI

A command-line interface for searching code across multiple repository instances using Sourcebot.

Features

  • Initialize configuration - Set up Sourcebot host and API credentials interactively
  • List repositories - View all indexed repositories with optional filtering
  • Search code - Find code patterns across all repositories
  • JSON output - All commands support JSON output for programmatic use
  • Flexible configuration - Use config file, environment variables, or CLI flags

Installation

npm install sourcebot-cli

Configuration

Interactive Setup

sourcebot init

This creates a configuration file at ~/.sourcebot/config.json:

{
  "host": "https://sourcebot.example.com",
  "apiKey": "your-api-key"
}

Environment Variables

export SOURCEBOT_HOST=https://sourcebot.example.com
export SOURCEBOT_API_KEY=your-api-key

CLI Flags

Pass credentials directly to commands:

sourcebot list --host https://sourcebot.example.com --key your-api-key

Precedence (highest to lowest):

  1. CLI flags (--host, --key)
  2. Environment variables (SOURCEBOT_HOST, SOURCEBOT_API_KEY)
  3. Config file (~/.sourcebot/config.json)

Commands

sourcebot init

Initialize and test your Sourcebot configuration.

sourcebot init

Validates the host URL and API key by connecting to the Sourcebot instance.

sourcebot list [options]

List all indexed repositories.

sourcebot list
sourcebot list --name=ceres
sourcebot list --type=gitlab
sourcebot list --match=".*bpm.*" --json

Options:

  • --name <string> - Filter by repository name (case-insensitive substring)
  • --type <string> - Filter by code host type (gitlab, github, bitbucket)
  • --match <regex> - Filter by regex pattern on display name
  • --json - Output in JSON format (default: table)
  • --host <string> - Override Sourcebot host
  • --key <string> - Override API key

sourcebot search <query> [options]

Search for code patterns across repositories.

sourcebot search "transactionLog"
sourcebot search "transactionLog" --matches=100
sourcebot search "transactionLog" --context=50 --json

Options:

  • --matches <number> - Limit number of matches (default: 50)
  • --context <number> - Context lines per match (default: 99999999)
  • --repo <id> - Filter results to specific repository ID
  • --json - Output in JSON format (default: table)
  • --host <string> - Override Sourcebot host
  • --key <string> - Override API key

Output Formats

Table (default)

Clean, human-readable tables:

ID    Display Name                    Type    Indexed At
────  ──────────────────────────────  ──────  ──────────────────────
3059  ceres/ceresintegracionromaneos  gitlab  2026-03-25
3967  servicefactory/mymsa            gitlab  2026-03-25

JSON

Complete structured data with metadata:

{
  "success": true,
  "data": [...],
  "meta": {
    "count": 2,
    "filtered": true,
    "filter": { "name": "ceres" }
  }
}

Development

Setup

npm install
npm run dev

Build

npm run build

Test

npm run test

Type Check

npm run typecheck

API Reference

SourcebotClient

import { SourcebotClient } from 'sourcebot-cli';

const client = new SourcebotClient({
  host: 'https://sourcebot.example.com',
  apiKey: 'your-api-key',
});

// List repositories
const repos = await client.listRepos();

// Search code
const results = await client.search('query', {
  matches: 50,
  contextLines: 99999999,
});

Config Management

import { loadConfig, saveConfig } from 'sourcebot-cli';

// Load configuration (respects precedence)
const config = loadConfig({
  host: 'https://custom.host',
});

// Save configuration
saveConfig({
  host: 'https://sourcebot.example.com',
  apiKey: 'api-key',
});

Filtering

import { filterRepos } from 'sourcebot-cli';

const filtered = filterRepos(repos, {
  name: 'ceres',
  type: 'gitlab',
  match: '.*integration.*',
});

Security Notes

  • Never commit ~/.sourcebot/config.json to version control
  • Use environment variables for CI/CD pipelines
  • Credentials are only sent to the specified Sourcebot host
  • Config file is stored in user home directory with restricted permissions

License

MIT