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

llm-file-context-bundler

v1.2.1

Published

A CLI tool to combine all TypeScript/JS files in a directory into a single file for LLM context.

Downloads

321

Readme

Sure! Based on your updated code and package.json, here's the rewritten README:


llm-file-context-bundler

A command-line tool to combine all TypeScript/JavaScript files in a directory into a single file for Large Language Model (LLM) context. This tool helps AI code assistants like GitHub Copilot and Codeium to have full context of your codebase, leading to smarter suggestions and auto-completions.

npm Package: llm-file-context-bundler

Table of Contents

Features

  • Combine Files: Merge all TypeScript/JavaScript files from a directory into a single file.
  • Watch Mode: Automatically recombine files when changes are detected.
  • Include/Exclude Patterns: Filter files using include and exclude patterns.
  • Verbose Logging: Get detailed logs of the combining process.

Installation

Install the package globally via npm:

npm install -g llm-file-context-bundler

Or using Yarn:

yarn global add llm-file-context-bundler

Or using pnpm:

pnpm add -g llm-file-context-bundler

The package is available on npm: llm-file-context-bundler

Usage

After installing, you can use the command llm-file-context-bundler in your terminal.

Options

  • -s, --source <path>: Source directory to scan for TypeScript files (default: ./src).
  • -o, --output <file>: Output file to write combined content (default: ./combined.ts).
  • -e, --exclude <patterns>: Comma-separated list of patterns to exclude.
  • -i, --include <patterns>: Comma-separated list of patterns to include.
  • -v, --verbose: Enable verbose logging.
  • -w, --watch: Watch the source directory for changes.

Examples

Basic Usage

Combine all TypeScript files in the src directory into combined.ts:

llm-file-context-bundler

Specify Source and Output

llm-file-context-bundler -s ./my-files -o ./output/combined.ts

Include and Exclude Patterns

Include only files matching .service.ts and exclude any in node_modules:

llm-file-context-bundler -i ".service.ts" -e "node_modules"

Enable Watch Mode

Automatically recombine files when changes are detected:

llm-file-context-bundler --watch

Verbose Logging

Get detailed logs during execution:

llm-file-context-bundler --verbose

Example Output

Given two TypeScript files in the ./src directory:

  • hello.ts:

    export function sayHello() {
      console.log("Hello, world!");
    }
  • goodbye.ts:

    export function sayGoodbye() {
      console.log("Goodbye, world!");
    }

Running the script:

llm-file-context-bundler -s ./src -o combined.ts -v

Console Output:

Application configuration:
  Source Directory: ./src
  Output File: combined.ts
  Include Patterns: []
  Exclude Patterns: []
Starting scan in directory: ./src
Found TypeScript file: ./src/hello.ts
Found TypeScript file: ./src/goodbye.ts
Reading file: ./src/hello.ts
Reading file: ./src/goodbye.ts
Combined files have been saved to combined.ts

Contents of combined.ts:

// @ts-nocheck
/* eslint-disable */

// ---- ./src/hello.ts ----
export function sayHello() {
  console.log("Hello, world!");
}

// ---- ./src/goodbye.ts ----
export function sayGoodbye() {
  console.log("Goodbye, world!");
}

Notes

  • Designed for TypeScript/JavaScript: The tool is intended to combine TypeScript or JavaScript files. If you need to combine other file types, you may adjust the isFileIncluded method in the code.
  • Include/Exclude Patterns: Use these options to fine-tune which files are combined. Patterns are simple substrings matched against the file paths.
  • Watch Mode: In watch mode, the tool monitors the source directory and automatically updates the combined file when changes are detected.
  • Verbose Mode: Provides detailed logs, which can be helpful for debugging or understanding the process flow.
  • Integration with AI Code Assistants: Combining your project files into one allows AI code assistants like GitHub Copilot and Codeium to have full context, leading to smarter suggestions and auto-completions.

License

This project is licensed under the MIT License.


Feel free to customize and enhance this tool to better suit your needs!