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

@fimbul-works/flatten

v1.0.1

Published

A utility for collecting project files and flattening them into a single directory

Downloads

130

Readme

Flatten - Project File Collection Utility

npm version License: MIT A command-line utility that collects project files based on glob patterns and flattens them into a single directory. Perfect for preparing codebases to share with AI assistants, creating project bundles, or organizing files for analysis.

Why Flatten?

When working with AI assistants on coding projects, you often need to share multiple files from different directories. Instead of copying and pasting individual files or dealing with complex folder structures, Flatten creates a clean, single-directory view of your project while preserving all path information.

Quick Start

npm install --save-dev @fimbul-works/flatten

# Use directly with npx
npx flatten --help

Basic Usage

# Initialize configuration
flatten --init

# Preview what would be copied
flatten --dry-run

# Copy files to default location
flatten

# Copy with custom target directory
flatten ./my-flattened-project/

How It Works

Flatten uses a bijective transformation to convert file paths into flat filenames while preserving all directory information:

| Original Path | Flattened Name | |---------------|----------------| | src/components/Button.tsx | src_components_Button.tsx | | lib/nav_bar.js | lib_nav__bar.js | | utils/api/client.ts | utils_api_client.ts | | index.ts | index.ts |

Transformation Rules:

  • Existing underscores in filenames → double underscore (__)
  • Directory separators (/ or \) → single underscore (_)
  • Path information is fully preserved and reversible

Do note that Flatten does not currently have an option to reverse the process.

Configuration

Create a .flatten file in your project root with glob patterns:

# Initialize with sensible defaults
flatten --init

Example .flatten configuration:

# Flatten Configuration File
#
# List file patterns to include (one per line)
# Use # for comments and ! to exclude files

# Essential project files
package.json
README.md

# Source code
src/**/*.js
src/**/*.ts
src/**/*.jsx
src/**/*.tsx
lib/**/*.js

# Configuration files
tsconfig.json
*.config.js
*.config.ts
.env.example

# Exclusion rules (files to ignore)
!**/*.d.ts
!**/*.test.*
!**/*.spec.*
!**/node_modules/**
!**/.git/**
!**/dist/**
!**/build/**

Command Line Options

flatten [OPTIONS] [TARGET_PATH]

Core Options

  • -i, --init - Initialize .flatten configuration file
  • -c, --clean - Clean target directory before copying
  • -n, --dry-run - Preview what would be copied without copying
  • -v, --verbose - Show detailed progress and file information

Advanced Options

  • -s, --symlinks - Follow symbolic links (use with caution)
  • -g, --gitignore - Automatically respect .gitignore patterns
  • --max-size SIZE - Skip files larger than specified size (e.g., 1MB, 500KB)
  • --stats - Show detailed operation statistics
  • -h, --help - Display help information

Examples

# Preview with verbose output
flatten --dry-run --verbose

# Clean target and respect gitignore
flatten --clean --gitignore

# Skip large files and show stats
flatten --max-size 1MB --stats

# Full cleanup with progress
flatten --clean --verbose --stats ./output/

📄 License

MIT


Built with ❤️ by FimbulWorks